just-git 1.3.5 → 1.3.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/README.md +9 -1
- package/dist/{hooks-t3k-y0u_.d.ts → hooks-DNBNCTgb.d.ts} +7 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/repo/index.d.ts +119 -4
- package/dist/repo/index.js +11 -10
- package/dist/server/index.d.ts +105 -2
- package/dist/server/index.js +66 -39
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -1,41 +1,68 @@
|
|
|
1
|
-
var ye=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});function T(r){return r!=null&&typeof r=="object"&&"reject"in r&&r.reject===!0}var J="0000000000000000000000000000000000000000",at=(()=>{let r=new Array(256);for(let e=0;e<256;e++)r[e]=(e>>4).toString(16)+(e&15).toString(16);return r})();function be(r){let e="";for(let t=0;t<20;t++)e+=at[r[t]];return e}function Q(r,e){let t="";for(let n=0;n<20;n++)t+=at[r[e+n]];return t}function me(r){let e=new Uint8Array(20);for(let t=0;t<20;t++)e[t]=parseInt(r.slice(t*2,t*2+2),16);return e}var lr=new TextEncoder;function je(r){return typeof r=="string"?lr.encode(r):r}function dr(){if(typeof globalThis.Bun<"u")return()=>{let r=new Bun.CryptoHasher("sha1"),e={update(t){return r.update(je(t)),e},hex:()=>Promise.resolve(r.digest("hex"))};return e};try{let r=ye(["node","crypto"].join(":"));if(typeof r.createHash=="function")return()=>{let e=r.createHash("sha1"),t={update(n){return e.update(je(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t}}catch{}if(typeof globalThis.crypto?.subtle?.digest=="function")return()=>{let r=[],e={update(t){return r.push(je(t)),e},async hex(){let t=0;for(let i of r)t+=i.byteLength;let n=new Uint8Array(t),s=0;for(let i of r)n.set(i,s),s+=i.byteLength;let o=await crypto.subtle.digest("SHA-1",n);return be(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 it=dr(),G=it;async function ct(r){return it().update(r).hex()}var pr=new Set(["tree","commit","tag"]),ge=class{map=new Map;currentBytes=0;maxBytes;constructor(e=16*1024*1024){this.maxBytes=e}get(e){return this.map.get(e)}set(e,t){if(!pr.has(t.type))return;let n=t.content.byteLength;if(!(n>this.maxBytes/2)&&!this.map.has(e)){for(;this.currentBytes+n>this.maxBytes&&this.map.size>0;){let s=this.map.keys().next().value;this.currentBytes-=this.map.get(s).content.byteLength,this.map.delete(s)}this.map.set(e,t),this.currentBytes+=n}}get size(){return this.map.size}get bytes(){return this.currentBytes}clear(){this.map.clear(),this.currentBytes=0}};var L=Uint8Array,F=Uint16Array,ur=Int32Array,ft=new L([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]),lt=new L([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 L([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dt=(r,e)=>{let t=new F(31);for(let s=0;s<31;++s)t[s]=e+=1<<r[s-1];let n=new ur(t[30]);for(let s=1;s<30;++s)for(let o=t[s];o<t[s+1];++o)n[o]=o-t[s]<<5|s;return{b:t,r:n}},{b:pt}=dt(ft,2);pt[28]=258;var{b:yr}=dt(lt,0),Ie=new F(32768);for(let r=0;r<32768;++r){let e=(r&43690)>>1|(r&21845)<<1;e=(e&52428)>>2|(e&13107)<<2,e=(e&61680)>>4|(e&3855)<<4,Ie[r]=((e&65280)>>8|(e&255)<<8)>>1}var ee=(r,e,t)=>{let n=r.length,s=0,o=new F(e);for(;s<n;++s)r[s]&&++o[r[s]-1];let i=new F(e);for(s=1;s<e;++s)i[s]=i[s-1]+o[s-1]<<1;let a;if(t){a=new F(1<<e);let l=15-e;for(s=0;s<n;++s)if(r[s]){let c=s<<4|r[s],f=e-r[s],d=i[r[s]-1]++<<f;for(let p=d|(1<<f)-1;d<=p;++d)a[Ie[d]>>l]=c}}else for(a=new F(n),s=0;s<n;++s)r[s]&&(a[s]=Ie[i[r[s]-1]++]>>15-r[s]);return a},te=new L(288);for(let r=0;r<144;++r)te[r]=8;for(let r=144;r<256;++r)te[r]=9;for(let r=256;r<280;++r)te[r]=7;for(let r=280;r<288;++r)te[r]=8;var ut=new L(32);for(let r=0;r<32;++r)ut[r]=5;var br=ee(te,9,1),mr=ee(ut,5,1),Se=r=>{let e=r[0];for(let t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},U=(r,e,t)=>{let n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},Ae=(r,e)=>{let t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},ht=r=>(r+7)/8|0,gr=(r,e,t)=>((e==null||e<0)&&(e=0),(t==null||t>r.length)&&(t=r.length),new L(r.subarray(e,t))),H=(r,e)=>{let t=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(e||t[r]||"unknown inflate error")},yt=(r,e,t,n)=>{let s=r.length,o=n?n.length:0;if(!s||e.f&&!e.l)return t||new L(0);let i=!t,a=i||e.i!=2,l=e.i;i&&(t=new L(s*3));let c=y=>{let g=t.length;if(y>g){let w=new L(Math.max(g*2,y));w.set(t),t=w}},f=e.f||0,d=e.p||0,p=e.b||0,u=e.l,h=e.d,m=e.m,R=e.n,b=s*8;do{if(!u){f=U(r,d,1);let E=U(r,d+1,3);if(d+=3,E)if(E==1)u=br,h=mr,m=9,R=5;else if(E==2){let x=U(r,d,31)+257,O=U(r,d+10,15)+4,j=x+U(r,d+5,31)+1;d+=14;let P=new L(j),A=new L(19);for(let N=0;N<O;++N)A[hr[N]]=U(r,d+N*3,7);d+=O*3;let B=Se(A),I=(1<<B)-1,C=ee(A,B,1);for(let N=0;N<j;){let st=C[U(r,d,I)];d+=st&15;let Z=st>>4;if(Z<16)P[N++]=Z;else{let ot=0,he=0;for(Z==16?(he=3+U(r,d,3),d+=2,ot=P[N-1]):Z==17?(he=3+U(r,d,7),d+=3):Z==18&&(he=11+U(r,d,127),d+=7);he--;)P[N++]=ot}}let $=P.subarray(0,x),nt=P.subarray(x);m=Se($),R=Se(nt),u=ee($,m,1),h=ee(nt,R,1)}else H(1);else{let x=ht(d)+4,O=r[x-4]|r[x-3]<<8,j=x+O;if(j>s){l&&H(0);break}a&&c(p+O),t.set(r.subarray(x,j),p),e.b=p+=O,e.p=d=j*8,e.f=f;continue}if(d>b){l&&H(0);break}}a&&c(p+131072);let y=(1<<m)-1,g=(1<<R)-1,w=d;for(;;w=d){let E=u[Ae(r,d)&y],x=E>>4;if(d+=E&15,d>b){l&&H(0);break}if(E||H(2),x<256)t[p++]=x;else if(x==256){w=d,u=null;break}else{let O=x-254;if(x>264){let I=x-257,C=ft[I];O=U(r,d,(1<<C)-1)+pt[I],d+=C}let j=h[Ae(r,d)&g],P=j>>4;j||H(3),d+=j&15;let A=yr[P];if(P>3){let I=lt[P];A+=Ae(r,d)&(1<<I)-1,d+=I}if(d>b){l&&H(0);break}a&&c(p+131072);let B=p+O;if(p<A){let I=o-A,C=Math.min(A,B);for(I+p<0&&H(3);p<C;++p)t[p]=n[I+p]}for(;p<B;++p)t[p]=t[p-A]}}e.l=u,e.p=w,e.b=p,e.f=f,u&&(f=1,e.m=m,e.d=h,e.n=R)}while(!f);return p!=t.length&&i?gr(t,0,p):t.subarray(0,p)},bt=r=>(((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&H(0,"invalid zlib data"),r[1]&32&&H(0,"zlib dictionaries are not supported"),2);function mt(r){let e=bt(r);return yt(r.subarray(e,-4),{i:2})}function Te(r){let e=bt(r),t={i:2},n=yt(r.subarray(e),t),s=ht(t.p);return{result:n,bytesConsumed:e+s+4}}async function Rr(){let r;if(!(typeof document<"u"))try{r=ye(["node","zlib"].join(":"))}catch{try{r=await import(["node","zlib"].join(":"))}catch{}}if(r&&typeof r.deflateSync=="function"&&typeof r.inflateSync=="function"){let n=null;try{let s=r.inflateSync(r.deflateSync(Buffer.from("x")),{info:!0});s?.engine&&typeof s.engine.bytesWritten=="number"&&(n=o=>{let i=r.inflateSync(o,{info:!0});return{result:new Uint8Array(i.buffer),bytesConsumed:i.engine.bytesWritten}})}catch{}return{deflateSync:s=>new Uint8Array(r.deflateSync(s)),inflateSync:s=>new Uint8Array(r.inflateSync(s)),inflateWithConsumed:n??Te}}let t;return typeof globalThis.CompressionStream=="function"?t=async n=>{let s=new CompressionStream("deflate"),o=s.writable.getWriter();return o.write(n),o.close(),new Uint8Array(await new Response(s.readable).arrayBuffer())}:t=()=>{throw new Error("No deflate implementation available. Requires node:zlib or CompressionStream.")},{deflateSync:t,inflateSync:mt,inflateWithConsumed:Te}}var xr=null;function gt(){return xr??=Rr()}async function Re(r){return await(await gt()).deflateSync(r)}async function Ue(r,e){let t=await gt(),{result:n,bytesConsumed:s}=t.inflateWithConsumed(r);if(n.byteLength!==e)throw new Error(`Inflate size mismatch: got ${n.byteLength}, expected ${e}`);return{result:n,bytesConsumed:s}}var z=1346454347,we=2,wt=1,Et=2,Ot=3,Pt=4,_=6,re=7,vt={[wt]:"commit",[Et]:"tree",[Ot]:"blob",[Pt]:"tag"},kt={commit:wt,tree:Et,blob:Ot,tag:Pt};async function jt(r,e){let t=new DataView(r.buffer,r.byteOffset,r.byteLength),n=t.getUint32(0);if(n!==z)throw new Error(`Invalid pack signature: 0x${n.toString(16)} (expected 0x${z.toString(16)})`);let s=t.getUint32(4);if(s!==we)throw new Error(`Unsupported pack version: ${s}`);if(r.byteLength>=32){let c=Q(r,r.byteLength-20),f=G();f.update(r.subarray(0,r.byteLength-20));let d=await f.hex();if(d!==c)throw new Error(`pack checksum mismatch: expected ${c}, computed ${d}`)}let o=t.getUint32(8),i=[],a=12;for(let c=0;c<o;c++){let f=await wr(r,a);i.push(f),a=f.nextOffset}return(await Er(i,e)).map((c,f)=>({...c,offset:i[f].headerOffset,nextOffset:i[f].nextOffset}))}async function wr(r,e){let t=e,n=r[e++],s=n>>4&7,o=n&15,i=4;for(;n&128;)n=r[e++],o|=(n&127)<<i,i+=7;let a,l;if(s===_){let d=r[e++];for(a=d&127;d&128;)a+=1,d=r[e++],a=(a<<7)+(d&127);a=t-a}else s===re&&(l=Q(r,e),e+=20);let{result:c,bytesConsumed:f}=await Ue(r.subarray(e),o);return{headerOffset:t,typeNum:s,inflated:c,baseOffset:a,baseHash:l,nextOffset:e+f}}var Rt=50;async function Er(r,e){let t=new Map;for(let o=0;o<r.length;o++)t.set(r[o].headerOffset,o);let n=new Array(r.length).fill(null);async function s(o,i=0){if(i>Rt)throw new Error(`delta chain depth ${i} exceeds limit of ${Rt}`);let a=n[o];if(a)return a;let l=r[o];if(l.typeNum!==_&&l.typeNum!==re){let u=vt[l.typeNum];if(!u)throw new Error(`Unknown object type: ${l.typeNum}`);let h={type:u,content:l.inflated,hash:await q(u,l.inflated)};return n[o]=h,h}if(l.typeNum===_){let u=t.get(l.baseOffset);if(u===void 0)throw new Error(`OFS_DELTA base not found at offset ${l.baseOffset}`);let h=await s(u,i+1),m=xe(h.content,l.inflated),R={type:h.type,content:m,hash:await q(h.type,m)};return n[o]=R,R}let c=await Or(r,n,l.baseHash,s),f;if(c!==void 0)f=await s(c,i+1);else if(e){let u=await e(l.baseHash);u&&(f=u)}if(!f)throw new Error(`REF_DELTA base not found for hash ${l.baseHash}`);let d=xe(f.content,l.inflated),p={type:f.type,content:d,hash:await q(f.type,d)};return n[o]=p,p}for(let o=0;o<r.length;o++)await s(o);return n}async function Or(r,e,t,n){for(let s=0;s<e.length;s++)if(e[s]?.hash===t)return s;for(let s=0;s<r.length;s++){let o=r[s];if(o.typeNum!==_&&o.typeNum!==re&&(await n(s)).hash===t)return s}}var Le=class{buf=new Uint8Array(0);iter;eof=!1;_bytesRead=0;hasher;constructor(e,t=!1){this.iter=e[Symbol.asyncIterator](),this.hasher=t?G():null}get bytesRead(){return this._bytesRead}async pullMore(){if(this.eof)return!1;let{value:e,done:t}=await this.iter.next();if(t||!e)return this.eof=!0,!1;if(this.buf.byteLength===0)this.buf=new Uint8Array(e);else{let n=new Uint8Array(this.buf.byteLength+e.byteLength);n.set(this.buf),n.set(e,this.buf.byteLength),this.buf=n}return!0}async ensure(e){for(;this.buf.byteLength<e;)if(!await this.pullMore())throw new Error(`Unexpected end of pack data: needed ${e} bytes, have ${this.buf.byteLength}`)}consume(e){let t=new Uint8Array(this.buf.subarray(0,e));return this.hasher?.update(t),this.buf=this.buf.subarray(e),this._bytesRead+=e,t}async readByte(){return await this.ensure(1),this.consume(1)[0]}async readExact(e){return await this.ensure(e),this.consume(e)}async readRaw(e){await this.ensure(e);let t=new Uint8Array(this.buf.subarray(0,e));return this.buf=this.buf.subarray(e),this._bytesRead+=e,t}async inflateNext(e){for(this.buf.byteLength===0&&!this.eof&&await this.pullMore();;)try{let{result:t,bytesConsumed:n}=await Ue(this.buf,e);return this.consume(n),t}catch{if(!this.eof&&await this.pullMore())continue;throw new Error(`Failed to inflate pack entry at byte ${this._bytesRead} (expected ${e} bytes)`)}}async hashHex(){if(!this.hasher)throw new Error("Hashing not enabled");return this.hasher.hex()}};async function*St(r,e){let t=new Le(r,!0),n=await t.readExact(12),s=new DataView(n.buffer,n.byteOffset,n.byteLength),o=s.getUint32(0);if(o!==z)throw new Error(`Invalid pack signature: 0x${o.toString(16)} (expected 0x${z.toString(16)})`);let i=s.getUint32(4);if(i!==we)throw new Error(`Unsupported pack version: ${i}`);let a=s.getUint32(8),l=new Map,c=new Map;for(let p=0;p<a;p++){let u=t.bytesRead,h=await t.readByte(),m=h>>4&7,R=h&15,b=4;for(;h&128;)h=await t.readByte(),R|=(h&127)<<b,b+=7;let y,g;if(m===_){let x=await t.readByte();for(y=x&127;x&128;)y+=1,x=await t.readByte(),y=(y<<7)+(x&127);y=u-y}else if(m===re){let x=await t.readExact(20);g=Q(x,0)}let w=await t.inflateNext(R),E;if(m!==_&&m!==re){let x=vt[m];if(!x)throw new Error(`Unknown object type: ${m}`);E={type:x,content:w,hash:await q(x,w)}}else if(m===_){let x=l.get(y);if(!x)throw new Error(`OFS_DELTA base not found at offset ${y}`);let O=xe(x.content,w);E={type:x.type,content:O,hash:await q(x.type,O)}}else{let x=c.get(g);if(!x&&e&&(x=await e(g)??void 0),!x)throw new Error(`REF_DELTA base not found for hash ${g}`);let O=xe(x.content,w);E={type:x.type,content:O,hash:await q(x.type,O)}}l.set(u,E),c.set(E.hash,E),yield E}let f=Q(await t.readRaw(20),0),d=await t.hashHex();if(d!==f)throw new Error(`pack checksum mismatch: expected ${f}, computed ${d}`)}function xe(r,e){let t=0,{value:n,newPos:s}=xt(e,t);if(t=s,n!==r.byteLength)throw new Error(`Delta base size mismatch: expected ${n}, got ${r.byteLength}`);let{value:o,newPos:i}=xt(e,t);t=i;let a=new Uint8Array(o),l=0;for(;t<e.byteLength;){let c=e[t++];if(c&128){let f=0,d=0;c&1&&(f=e[t++]),c&2&&(f|=e[t++]<<8),c&4&&(f|=e[t++]<<16),c&8&&(f|=e[t++]<<24),c&16&&(d=e[t++]),c&32&&(d|=e[t++]<<8),c&64&&(d|=e[t++]<<16),d===0&&(d=65536),a.set(r.subarray(f,f+d),l),l+=d}else if(c>0)a.set(e.subarray(t,t+c),l),l+=c,t+=c;else throw new Error("Unexpected delta opcode 0x00 (reserved)")}if(l!==o)throw new Error(`Delta produced ${l} bytes, expected ${o}`);return a}async function Ee(r){let e=[],t=new Map,n=new Uint8Array(12),s=new DataView(n.buffer);s.setUint32(0,z),s.setUint32(4,we),s.setUint32(8,r.length),e.push(n);let o=12,i=[];for(let a of r){let l=o;t.set(a.hash,o);let c=a.delta&&a.deltaBaseHash?t.get(a.deltaBaseHash):void 0;if(a.delta&&c!==void 0){let f=Ce(_,a.delta.byteLength),d=vr(o-c),p=await Re(a.delta);e.push(f,d,p),o+=f.byteLength+d.byteLength+p.byteLength}else{let f=kt[a.type],d=Ce(f,a.content.byteLength),p=await Re(a.content);e.push(d,p),o+=d.byteLength+p.byteLength}i.push({hash:a.hash,offset:l,nextOffset:o})}return{data:await Pr(e),entries:i}}async function*At(r,e){let t=G(),n=new Uint8Array(12),s=new DataView(n.buffer);s.setUint32(0,z),s.setUint32(4,we),s.setUint32(8,r),t.update(n),yield n;for await(let o of e){let i=kt[o.type],a=Ce(i,o.content.byteLength),l=await Re(o.content);t.update(a),t.update(l),yield kr(a,l)}yield me(await t.hex())}async function Pr(r){let e=0;for(let i of r)e+=i.byteLength;e+=20;let t=new Uint8Array(e),n=0;for(let i of r)t.set(i,n),n+=i.byteLength;let s=G();s.update(t.subarray(0,n));let o=await s.hex();return t.set(me(o),n),t}function vr(r){let e=[];e.push(r&127);let t=r>>>7;for(;t>0;)e.unshift(128|--t&127),t>>>=7;return new Uint8Array(e)}function Ce(r,e){let t=[],n=r<<4|e&15;for(e>>=4;e>0;)t.push(n|128),n=e&127,e>>=7;return t.push(n),new Uint8Array(t)}function xt(r,e){let t=0,n=0,s;do s=r[e++],t|=(s&127)<<n,n+=7;while(s&128);return{value:t,newPos:e}}function kr(r,e){let t=new Uint8Array(r.byteLength+e.byteLength);return t.set(r,0),t.set(e,r.byteLength),t}var jr=new TextEncoder;async function q(r,e){let t=jr.encode(`${r} ${e.byteLength}\0`),n=G();return n.update(t),n.update(e),n.hex()}var Sr=new TextEncoder,Hn=new TextDecoder;function It(r,e){let t=Sr.encode(`${r} ${e.byteLength}\0`),n=new Uint8Array(t.byteLength+e.byteLength);return n.set(t),n.set(e,t.byteLength),n}function ne(r){let e=r.indexOf("<"),t=r.indexOf(">");if(e===-1||t===-1)throw new Error(`Malformed identity line: "${r}"`);let n=r.slice(0,e).trimEnd(),s=r.slice(e+1,t),o=r.slice(t+2),[i="0",a="+0000"]=o.split(" "),l=parseInt(i,10);return{name:n,email:s,timestamp:l,timezone:a}}var Bn=new TextEncoder,Ir=new TextDecoder;function se(r){let e=Ir.decode(r),t=e.indexOf(`
|
|
1
|
+
var Ee=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});function I(r){return r!=null&&typeof r=="object"&&"reject"in r&&r.reject===!0}var re="0000000000000000000000000000000000000000",Rt=(()=>{let r=new Array(256);for(let e=0;e<256;e++)r[e]=(e>>4).toString(16)+(e&15).toString(16);return r})();function ke(r){let e="";for(let t=0;t<20;t++)e+=Rt[r[t]];return e}function ne(r,e){let t="";for(let n=0;n<20;n++)t+=Rt[r[e+n]];return t}function Pe(r){let e=new Uint8Array(20);for(let t=0;t<20;t++)e[t]=parseInt(r.slice(t*2,t*2+2),16);return e}var Sr=new TextEncoder;function He(r){return typeof r=="string"?Sr.encode(r):r}function Ar(){if(typeof globalThis.Bun<"u")return()=>{let r=new Bun.CryptoHasher("sha1"),e={update(t){return r.update(He(t)),e},hex:()=>Promise.resolve(r.digest("hex"))};return e};try{let r=Ee(["node","crypto"].join(":"));if(typeof r.createHash=="function")return()=>{let e=r.createHash("sha1"),t={update(n){return e.update(He(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t}}catch{}if(typeof globalThis.crypto?.subtle?.digest=="function")return()=>{let r=[],e={update(t){return r.push(He(t)),e},async hex(){let t=0;for(let i of r)t+=i.byteLength;let n=new Uint8Array(t),s=0;for(let i of r)n.set(i,s),s+=i.byteLength;let a=await crypto.subtle.digest("SHA-1",n);return ke(new Uint8Array(a))}};return e};throw new Error("No SHA-1 implementation available. Requires Bun, Node.js, Deno, or a browser with Web Crypto.")}var xt=Ar(),G=xt;async function Ot(r){return xt().update(r).hex()}var jr=new Set(["tree","commit","tag"]),ve=class{map=new Map;currentBytes=0;maxBytes;constructor(e=16*1024*1024){this.maxBytes=e}get(e){return this.map.get(e)}set(e,t){if(!jr.has(t.type))return;let n=t.content.byteLength;if(!(n>this.maxBytes/2)&&!this.map.has(e)){for(;this.currentBytes+n>this.maxBytes&&this.map.size>0;){let s=this.map.keys().next().value;this.currentBytes-=this.map.get(s).content.byteLength,this.map.delete(s)}this.map.set(e,t),this.currentBytes+=n}}get size(){return this.map.size}get bytes(){return this.currentBytes}clear(){this.map.clear(),this.currentBytes=0}};var N=Uint8Array,q=Uint16Array,Ir=Int32Array,Et=new N([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]),kt=new N([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]),Tr=new N([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Pt=(r,e)=>{let t=new q(31);for(let s=0;s<31;++s)t[s]=e+=1<<r[s-1];let n=new Ir(t[30]);for(let s=1;s<30;++s)for(let a=t[s];a<t[s+1];++a)n[a]=a-t[s]<<5|s;return{b:t,r:n}},{b:vt}=Pt(Et,2);vt[28]=258;var{b:Ur}=Pt(kt,0),Be=new q(32768);for(let r=0;r<32768;++r){let e=(r&43690)>>1|(r&21845)<<1;e=(e&52428)>>2|(e&13107)<<2,e=(e&61680)>>4|(e&3855)<<4,Be[r]=((e&65280)>>8|(e&255)<<8)>>1}var se=(r,e,t)=>{let n=r.length,s=0,a=new q(e);for(;s<n;++s)r[s]&&++a[r[s]-1];let i=new q(e);for(s=1;s<e;++s)i[s]=i[s-1]+a[s-1]<<1;let o;if(t){o=new q(1<<e);let f=15-e;for(s=0;s<n;++s)if(r[s]){let c=s<<4|r[s],l=e-r[s],d=i[r[s]-1]++<<l;for(let p=d|(1<<l)-1;d<=p;++d)o[Be[d]>>f]=c}}else for(o=new q(n),s=0;s<n;++s)r[s]&&(o[s]=Be[i[r[s]-1]++]>>15-r[s]);return o},ae=new N(288);for(let r=0;r<144;++r)ae[r]=8;for(let r=144;r<256;++r)ae[r]=9;for(let r=256;r<280;++r)ae[r]=7;for(let r=280;r<288;++r)ae[r]=8;var St=new N(32);for(let r=0;r<32;++r)St[r]=5;var Lr=se(ae,9,1),Cr=se(St,5,1),De=r=>{let e=r[0];for(let t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},D=(r,e,t)=>{let n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},Ne=(r,e)=>{let t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},At=r=>(r+7)/8|0,Hr=(r,e,t)=>((e==null||e<0)&&(e=0),(t==null||t>r.length)&&(t=r.length),new N(r.subarray(e,t))),B=(r,e)=>{let t=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(e||t[r]||"unknown inflate error")},jt=(r,e,t,n)=>{let s=r.length,a=n?n.length:0;if(!s||e.f&&!e.l)return t||new N(0);let i=!t,o=i||e.i!=2,f=e.i;i&&(t=new N(s*3));let c=b=>{let R=t.length;if(b>R){let E=new N(Math.max(R*2,b));E.set(t),t=E}},l=e.f||0,d=e.p||0,p=e.b||0,h=e.l,u=e.d,m=e.m,x=e.n,y=s*8;do{if(!h){l=D(r,d,1);let w=D(r,d+1,3);if(d+=3,w)if(w==1)h=Lr,u=Cr,m=9,x=5;else if(w==2){let g=D(r,d,31)+257,k=D(r,d+10,15)+4,v=g+D(r,d+5,31)+1;d+=14;let j=new N(v),P=new N(19);for(let M=0;M<k;++M)P[Tr[M]]=D(r,d+M*3,7);d+=k*3;let C=De(P),S=(1<<C)-1,H=se(P,C,1);for(let M=0;M<v;){let gt=H[D(r,d,S)];d+=gt&15;let te=gt>>4;if(te<16)j[M++]=te;else{let wt=0,Oe=0;for(te==16?(Oe=3+D(r,d,3),d+=2,wt=j[M-1]):te==17?(Oe=3+D(r,d,7),d+=3):te==18&&(Oe=11+D(r,d,127),d+=7);Oe--;)j[M++]=wt}}let $=j.subarray(0,g),mt=j.subarray(g);m=De($),x=De(mt),h=se($,m,1),u=se(mt,x,1)}else B(1);else{let g=At(d)+4,k=r[g-4]|r[g-3]<<8,v=g+k;if(v>s){f&&B(0);break}o&&c(p+k),t.set(r.subarray(g,v),p),e.b=p+=k,e.p=d=v*8,e.f=l;continue}if(d>y){f&&B(0);break}}o&&c(p+131072);let b=(1<<m)-1,R=(1<<x)-1,E=d;for(;;E=d){let w=h[Ne(r,d)&b],g=w>>4;if(d+=w&15,d>y){f&&B(0);break}if(w||B(2),g<256)t[p++]=g;else if(g==256){E=d,h=null;break}else{let k=g-254;if(g>264){let S=g-257,H=Et[S];k=D(r,d,(1<<H)-1)+vt[S],d+=H}let v=u[Ne(r,d)&R],j=v>>4;v||B(3),d+=v&15;let P=Ur[j];if(j>3){let S=kt[j];P+=Ne(r,d)&(1<<S)-1,d+=S}if(d>y){f&&B(0);break}o&&c(p+131072);let C=p+k;if(p<P){let S=a-P,H=Math.min(P,C);for(S+p<0&&B(3);p<H;++p)t[p]=n[S+p]}for(;p<C;++p)t[p]=t[p-P]}}e.l=h,e.p=E,e.b=p,e.f=l,h&&(l=1,e.m=m,e.d=u,e.n=x)}while(!l);return p!=t.length&&i?Hr(t,0,p):t.subarray(0,p)},It=r=>(((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&B(0,"invalid zlib data"),r[1]&32&&B(0,"zlib dictionaries are not supported"),2);function Tt(r){let e=It(r);return jt(r.subarray(e,-4),{i:2})}function Me(r){let e=It(r),t={i:2},n=jt(r.subarray(e),t),s=At(t.p);return{result:n,bytesConsumed:e+s+4}}async function Dr(){let r;if(!(typeof document<"u"))try{r=Ee(["node","zlib"].join(":"))}catch{try{r=await import(["node","zlib"].join(":"))}catch{}}if(r&&typeof r.deflateSync=="function"&&typeof r.inflateSync=="function"){let n=null;try{let s=r.inflateSync(r.deflateSync(Buffer.from("x")),{info:!0});s?.engine&&typeof s.engine.bytesWritten=="number"&&(n=a=>{let i=r.inflateSync(a,{info:!0});return{result:new Uint8Array(i.buffer),bytesConsumed:i.engine.bytesWritten}})}catch{}return{deflateSync:s=>new Uint8Array(r.deflateSync(s)),inflateSync:s=>new Uint8Array(r.inflateSync(s)),inflateWithConsumed:n??Me}}let t;return typeof globalThis.CompressionStream=="function"?t=async n=>{let s=new CompressionStream("deflate"),a=s.writable.getWriter();return a.write(n),a.close(),new Uint8Array(await new Response(s.readable).arrayBuffer())}:t=()=>{throw new Error("No deflate implementation available. Requires node:zlib or CompressionStream.")},{deflateSync:t,inflateSync:Tt,inflateWithConsumed:Me}}var Nr=null;function Ut(){return Nr??=Dr()}async function Se(r){return await(await Ut()).deflateSync(r)}async function $e(r,e){let t=await Ut(),{result:n,bytesConsumed:s}=t.inflateWithConsumed(r);if(n.byteLength!==e)throw new Error(`Inflate size mismatch: got ${n.byteLength}, expected ${e}`);return{result:n,bytesConsumed:s}}var z=1346454347,je=2,Ht=1,Dt=2,Nt=3,Bt=4,W=6,oe=7,Mt={[Ht]:"commit",[Dt]:"tree",[Nt]:"blob",[Bt]:"tag"},$t={commit:Ht,tree:Dt,blob:Nt,tag:Bt};async function Wt(r,e){let t=new DataView(r.buffer,r.byteOffset,r.byteLength),n=t.getUint32(0);if(n!==z)throw new Error(`Invalid pack signature: 0x${n.toString(16)} (expected 0x${z.toString(16)})`);let s=t.getUint32(4);if(s!==je)throw new Error(`Unsupported pack version: ${s}`);if(r.byteLength>=32){let c=ne(r,r.byteLength-20),l=G();l.update(r.subarray(0,r.byteLength-20));let d=await l.hex();if(d!==c)throw new Error(`pack checksum mismatch: expected ${c}, computed ${d}`)}let a=t.getUint32(8),i=[],o=12;for(let c=0;c<a;c++){let l=await Br(r,o);i.push(l),o=l.nextOffset}return(await Mr(i,e)).map((c,l)=>({...c,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function Br(r,e){let t=e,n=r[e++],s=n>>4&7,a=n&15,i=4;for(;n&128;)n=r[e++],a|=(n&127)<<i,i+=7;let o,f;if(s===W){let d=r[e++];for(o=d&127;d&128;)o+=1,d=r[e++],o=(o<<7)+(d&127);o=t-o}else s===oe&&(f=ne(r,e),e+=20);let{result:c,bytesConsumed:l}=await $e(r.subarray(e),a);return{headerOffset:t,typeNum:s,inflated:c,baseOffset:o,baseHash:f,nextOffset:e+l}}var Lt=50;async function Mr(r,e){let t=new Map;for(let a=0;a<r.length;a++)t.set(r[a].headerOffset,a);let n=new Array(r.length).fill(null);async function s(a,i=0){if(i>Lt)throw new Error(`delta chain depth ${i} exceeds limit of ${Lt}`);let o=n[a];if(o)return o;let f=r[a];if(f.typeNum!==W&&f.typeNum!==oe){let h=Mt[f.typeNum];if(!h)throw new Error(`Unknown object type: ${f.typeNum}`);let u={type:h,content:f.inflated,hash:await V(h,f.inflated)};return n[a]=u,u}if(f.typeNum===W){let h=t.get(f.baseOffset);if(h===void 0)throw new Error(`OFS_DELTA base not found at offset ${f.baseOffset}`);let u=await s(h,i+1),m=Ae(u.content,f.inflated),x={type:u.type,content:m,hash:await V(u.type,m)};return n[a]=x,x}let c=await $r(r,n,f.baseHash,s),l;if(c!==void 0)l=await s(c,i+1);else if(e){let h=await e(f.baseHash);h&&(l=h)}if(!l)throw new Error(`REF_DELTA base not found for hash ${f.baseHash}`);let d=Ae(l.content,f.inflated),p={type:l.type,content:d,hash:await V(l.type,d)};return n[a]=p,p}for(let a=0;a<r.length;a++)await s(a);return n}async function $r(r,e,t,n){for(let s=0;s<e.length;s++)if(e[s]?.hash===t)return s;for(let s=0;s<r.length;s++){let a=r[s];if(a.typeNum!==W&&a.typeNum!==oe&&(await n(s)).hash===t)return s}}var We=class{buf=new Uint8Array(0);iter;eof=!1;_bytesRead=0;hasher;constructor(e,t=!1){this.iter=e[Symbol.asyncIterator](),this.hasher=t?G():null}get bytesRead(){return this._bytesRead}async pullMore(){if(this.eof)return!1;let{value:e,done:t}=await this.iter.next();if(t||!e)return this.eof=!0,!1;if(this.buf.byteLength===0)this.buf=new Uint8Array(e);else{let n=new Uint8Array(this.buf.byteLength+e.byteLength);n.set(this.buf),n.set(e,this.buf.byteLength),this.buf=n}return!0}async ensure(e){for(;this.buf.byteLength<e;)if(!await this.pullMore())throw new Error(`Unexpected end of pack data: needed ${e} bytes, have ${this.buf.byteLength}`)}consume(e){let t=new Uint8Array(this.buf.subarray(0,e));return this.hasher?.update(t),this.buf=this.buf.subarray(e),this._bytesRead+=e,t}async readByte(){return await this.ensure(1),this.consume(1)[0]}async readExact(e){return await this.ensure(e),this.consume(e)}async readRaw(e){await this.ensure(e);let t=new Uint8Array(this.buf.subarray(0,e));return this.buf=this.buf.subarray(e),this._bytesRead+=e,t}async inflateNext(e){for(this.buf.byteLength===0&&!this.eof&&await this.pullMore();;)try{let{result:t,bytesConsumed:n}=await $e(this.buf,e);return this.consume(n),t}catch{if(!this.eof&&await this.pullMore())continue;throw new Error(`Failed to inflate pack entry at byte ${this._bytesRead} (expected ${e} bytes)`)}}async hashHex(){if(!this.hasher)throw new Error("Hashing not enabled");return this.hasher.hex()}};async function*_t(r,e){let t=new We(r,!0),n=await t.readExact(12),s=new DataView(n.buffer,n.byteOffset,n.byteLength),a=s.getUint32(0);if(a!==z)throw new Error(`Invalid pack signature: 0x${a.toString(16)} (expected 0x${z.toString(16)})`);let i=s.getUint32(4);if(i!==je)throw new Error(`Unsupported pack version: ${i}`);let o=s.getUint32(8),f=new Map,c=new Map;for(let p=0;p<o;p++){let h=t.bytesRead,u=await t.readByte(),m=u>>4&7,x=u&15,y=4;for(;u&128;)u=await t.readByte(),x|=(u&127)<<y,y+=7;let b,R;if(m===W){let g=await t.readByte();for(b=g&127;g&128;)b+=1,g=await t.readByte(),b=(b<<7)+(g&127);b=h-b}else if(m===oe){let g=await t.readExact(20);R=ne(g,0)}let E=await t.inflateNext(x),w;if(m!==W&&m!==oe){let g=Mt[m];if(!g)throw new Error(`Unknown object type: ${m}`);w={type:g,content:E,hash:await V(g,E)}}else if(m===W){let g=f.get(b);if(!g)throw new Error(`OFS_DELTA base not found at offset ${b}`);let k=Ae(g.content,E);w={type:g.type,content:k,hash:await V(g.type,k)}}else{let g=c.get(R);if(!g&&e&&(g=await e(R)??void 0),!g)throw new Error(`REF_DELTA base not found for hash ${R}`);let k=Ae(g.content,E);w={type:g.type,content:k,hash:await V(g.type,k)}}f.set(h,w),c.set(w.hash,w),yield w}let l=ne(await t.readRaw(20),0),d=await t.hashHex();if(d!==l)throw new Error(`pack checksum mismatch: expected ${l}, computed ${d}`)}function Ae(r,e){let t=0,{value:n,newPos:s}=Ct(e,t);if(t=s,n!==r.byteLength)throw new Error(`Delta base size mismatch: expected ${n}, got ${r.byteLength}`);let{value:a,newPos:i}=Ct(e,t);t=i;let o=new Uint8Array(a),f=0;for(;t<e.byteLength;){let c=e[t++];if(c&128){let l=0,d=0;c&1&&(l=e[t++]),c&2&&(l|=e[t++]<<8),c&4&&(l|=e[t++]<<16),c&8&&(l|=e[t++]<<24),c&16&&(d=e[t++]),c&32&&(d|=e[t++]<<8),c&64&&(d|=e[t++]<<16),d===0&&(d=65536),o.set(r.subarray(l,l+d),f),f+=d}else if(c>0)o.set(e.subarray(t,t+c),f),f+=c,t+=c;else throw new Error("Unexpected delta opcode 0x00 (reserved)")}if(f!==a)throw new Error(`Delta produced ${f} bytes, expected ${a}`);return o}async function K(r){let e=[],t=new Map,n=new Uint8Array(12),s=new DataView(n.buffer);s.setUint32(0,z),s.setUint32(4,je),s.setUint32(8,r.length),e.push(n);let a=12,i=[];for(let o of r){let f=a;t.set(o.hash,a);let c=o.delta&&o.deltaBaseHash?t.get(o.deltaBaseHash):void 0;if(o.delta&&c!==void 0){let l=_e(W,o.delta.byteLength),d=_r(a-c),p=await Se(o.delta);e.push(l,d,p),a+=l.byteLength+d.byteLength+p.byteLength}else{let l=$t[o.type],d=_e(l,o.content.byteLength),p=await Se(o.content);e.push(d,p),a+=d.byteLength+p.byteLength}i.push({hash:o.hash,offset:f,nextOffset:a})}return{data:await Wr(e),entries:i}}async function*Ft(r,e){let t=G(),n=new Uint8Array(12),s=new DataView(n.buffer);s.setUint32(0,z),s.setUint32(4,je),s.setUint32(8,r),t.update(n),yield n;for await(let a of e){let i=$t[a.type],o=_e(i,a.content.byteLength),f=await Se(a.content);t.update(o),t.update(f),yield Fr(o,f)}yield Pe(await t.hex())}async function Wr(r){let e=0;for(let i of r)e+=i.byteLength;e+=20;let t=new Uint8Array(e),n=0;for(let i of r)t.set(i,n),n+=i.byteLength;let s=G();s.update(t.subarray(0,n));let a=await s.hex();return t.set(Pe(a),n),t}function _r(r){let e=[];e.push(r&127);let t=r>>>7;for(;t>0;)e.unshift(128|--t&127),t>>>=7;return new Uint8Array(e)}function _e(r,e){let t=[],n=r<<4|e&15;for(e>>=4;e>0;)t.push(n|128),n=e&127,e>>=7;return t.push(n),new Uint8Array(t)}function Ct(r,e){let t=0,n=0,s;do s=r[e++],t|=(s&127)<<n,n+=7;while(s&128);return{value:t,newPos:e}}function Fr(r,e){let t=new Uint8Array(r.byteLength+e.byteLength);return t.set(r,0),t.set(e,r.byteLength),t}var Gr=new TextEncoder;async function V(r,e){let t=Gr.encode(`${r} ${e.byteLength}\0`),n=G();return n.update(t),n.update(e),n.hex()}var qr=new TextEncoder,Qn=new TextDecoder;function Gt(r,e){let t=qr.encode(`${r} ${e.byteLength}\0`),n=new Uint8Array(t.byteLength+e.byteLength);return n.set(t),n.set(e,t.byteLength),n}function ie(r){let e=r.indexOf("<"),t=r.indexOf(">");if(e===-1||t===-1)throw new Error(`Malformed identity line: "${r}"`);let n=r.slice(0,e).trimEnd(),s=r.slice(e+1,t),a=r.slice(t+2),[i="0",o="+0000"]=a.split(" "),f=parseInt(i,10);return{name:n,email:s,timestamp:f,timezone:o}}var ns=new TextEncoder,zr=new TextDecoder;function ce(r){let e=zr.decode(r),t=e.indexOf(`
|
|
2
2
|
|
|
3
|
-
`),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+2),
|
|
4
|
-
`)){let
|
|
3
|
+
`),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+2),a="",i=[],o,f;for(let c of n.split(`
|
|
4
|
+
`)){let l=c.indexOf(" ");if(l===-1)continue;let d=c.slice(0,l),p=c.slice(l+1);switch(d){case"tree":a=p;break;case"parent":i.push(p);break;case"author":o=ie(p);break;case"committer":f=ie(p);break}}if(!a)throw new Error("Commit missing tree field");if(!o)throw new Error("Commit missing author field");if(!f)throw new Error("Commit missing committer field");return{type:"commit",tree:a,parents:i,author:o,committer:f,message:s}}var os=new TextEncoder,Kr=new TextDecoder;function X(r){let e=Kr.decode(r),t=e.indexOf(`
|
|
5
5
|
|
|
6
|
-
`),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+2),
|
|
7
|
-
`)){let f=c.indexOf(" ");if(f===-1)continue;let d=c.slice(0,f),p=c.slice(f+1);switch(d){case"object":o=p;break;case"type":i=p;break;case"tag":a=p;break;case"tagger":l=ne(p);break}}if(!o)throw new Error("Tag missing object field");if(!a)throw new Error("Tag missing tag name field");if(!l)throw new Error("Tag missing tagger field");return{type:"tag",object:o,objectType:i,name:a,tagger:l,message:s}}async function oe(r,e){return r.objectStore.read(e)}async function ae(r,e){return r.objectStore.exists(e)}var qn=new TextDecoder;async function X(r,e){let t=await oe(r,e);if(t.type!=="commit")throw new Error(`Expected commit object for ${e}, got ${t.type}`);return se(t.content)}function Tt(r){return typeof r=="string"?{type:"direct",hash:r}:r}var He=".lock";var Ur=[1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,5,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,4,4];function Lr(r,e,t){let n=0,s=!1,o=e;for(;o<r.length;o++){let a=r.charCodeAt(o);switch(a<128?Ur[a]:0){case 1:break;case 2:if(n===46)return{len:-1,starConsumed:s};n=a;continue;case 3:if(n===64)return{len:-1,starConsumed:s};n=a;continue;case 4:return{len:-1,starConsumed:s};case 5:if(!t)return{len:-1,starConsumed:s};s=!0,n=a;continue;default:n=a;continue}break}let i=o-e;return i===0?{len:0,starConsumed:s}:r.charCodeAt(e)===46?{len:-1,starConsumed:s}:i>=He.length&&r.slice(o-He.length,o)===He?{len:-1,starConsumed:s}:{len:i,starConsumed:s}}function Ut(r,e=0){if(r==="@"||r.length===0)return!1;let t=0,n=0,s=!!(e&2);for(;t<=r.length;){let{len:o,starConsumed:i}=Lr(r,t,s);if(o<0||o===0)return!1;i&&(s=!1),n++,t+=o+1}return!(r.charCodeAt(r.length-1)===46||!(e&1)&&n<2)}var Cr=10;async function Hr(r,e){return r.refStore.readRef(e)}async function Lt(r,e){let t=e;for(let n=0;n<Cr;n++){let s=await Hr(r,t);if(!s)return null;if(s.type==="direct")return s.hash;t=s.target}throw new Error(`Symbolic ref loop detected resolving "${e}"`)}var Vn=new TextEncoder,Ct=new TextDecoder,Dr=new Set(["100644","100755","040000","120000","160000"]);function Nr(r){return r.length===4&&r.toLowerCase()===".git"}function Mr(r,e){if(r.length===0)throw new Error("invalid tree entry: empty name");if(r.includes("/"))throw new Error(`invalid tree entry: name contains slash: '${r}'`);if(r.includes("\0"))throw new Error("invalid tree entry: name contains null byte");if(r==="."||r==="..")throw new Error(`invalid tree entry: '${r}'`);if(Nr(r))throw new Error(`invalid tree entry: '${r}'`);if(!Dr.has(e))throw new Error(`invalid tree entry mode: '${e}' for '${r}'`)}function De(r){let e=[],t=0;for(;t<r.byteLength;){let n=r.indexOf(32,t);if(n===-1)break;let s=Ct.decode(r.subarray(t,n)),o=r.indexOf(0,n+1);if(o===-1)break;let i=Ct.decode(r.subarray(n+1,o)),a=r.subarray(o+1,o+21),l=be(a),c=s.padStart(6,"0");Mr(i,c),e.push({mode:c,name:i,hash:l}),t=o+21}return{type:"tree",entries:e}}async function Ne(r,e,t){if(e===t)return!0;let n=new Set,s=[t],o=0;for(;o<s.length;){let i=s[o++];if(i===e)return!0;if(n.has(i))continue;n.add(i);let a;try{a=await X(r,i)}catch{continue}for(let l of a.parents)n.has(l)||s.push(l)}return!1}var Pe=new Uint32Array([0,2874782929,1454598562,4260027763,104818581,2909197124,1351355959,4225088230,209637162,2804382715,1523426952,4053013081,172075199,2702711918,1559413021,4155209164,419274324,3013880453,1313798134,3843506983,516094401,3046853904,1215402083,3811058866,344150398,3218793903,1110456540,3916008461,314324715,3118826042,1141858121,4015451032,838548648,2594343033,1732793610,3423723995,935615293,2627596268,1635201695,3392046670,1032188802,2531018579,1798740512,3228511985,1002083351,2430804166,1829371317,3327150436,688300796,2187269677,2142620510,3572268943,792315241,2220913080,2039131339,3537049626,628649430,2384582919,1942684788,3633492133,591858243,2283716242,1978950625,3735934768,1677097296,3366964609,893718770,2652677155,1707679429,3465587220,863663975,2552480694,1871230586,3302032043,960225240,2455923465,1773654511,3270403390,1057273933,2489126044,2064377604,3495056341,767069862,2262907511,2100592785,3597481024,730327347,2162056674,2004166702,3693911295,566641036,2325738845,1900695483,3658742634,670639641,2359333576,1376601592,4183093545,79572058,2951190667,1412571757,4285241020,42027983,2849570590,1584630482,4113186307,146858864,2744735649,1481436487,4078262678,251626725,2779131956,1257298860,3785977725,474198542,3071936223,1288682553,3885369576,444388763,2972016970,1183716486,3990331479,272465188,3143944693,1085371155,3957901250,369236657,3176902240,1823819377,3354194592,973483987,2438961922,1787437540,3251868981,1010387014,2539715735,1623951707,3415358858,913891577,2636207144,1727327950,3450690079,809994092,2602447805,1950930981,3742461172,586920327,2309096790,1920450480,3643673441,616879634,2409456323,2016810767,3547309022,780500653,2245839484,2114547866,3578840139,683284792,2212736489,1565424345,4128755208,201134971,2695145386,1534139724,4029196701,230847726,2795225151,1362146803,4201185570,126082129,2899994752,1460654694,4233520823,29146052,2867138325,1169417357,4008333404,318803247,3092855294,1133282072,3906287561,356510394,3194379883,1238182823,3801390966,528368133,3022517972,1341279282,3836475619,423699856,2987954497,256065313,2753203184,1508923011,4071219794,159144116,2720394341,1607414038,4103505351,54390795,2825143514,1435408809,4275514744,84055966,2925208399,1404173884,4175973101,398369141,3169260964,1091422423,3931405318,293717728,3134747185,1194504002,3966442387,465595999,2962872974,1299384317,3861558060,503253450,3064380699,1263296616,3759527097,1052246921,2514597720,1745578539,3276988154,948397084,2480853197,1848905150,3312302447,851889315,2577365106,1685431553,3475771856,888777526,2678071271,1649066644,3373495877,642096605,2367432972,1895232639,3685695662,544930376,2334346905,1992922090,3717211963,708530935,2170742310,2089302869,3620835204,738473314,2271052211,2058837184,3522095121]),Br=new Uint32Array([0,2125799437,1446245579,679924934,121527623,2039184714,1359849868,800622977,243055246,1892260483,1481592389,653946440,155379657,2012727236,1601245954,566506255,486110492,1649169681,1254785495,880779738,466036827,1701972054,1307892880,859962525,310759314,1815146399,1152793433,973282132,364614357,1796125400,1133012510,1027425811,972220984,1195887157,1874927347,292830974,1053603711,1081710450,1761559476,373973945,932073654,1228632251,1639818365,520651888,816844273,1308962300,1719925050,406247735,621518628,1539227433,1933077487,227363810,573948515,1551950446,1946564264,179508901,729228714,1438778791,2101662049,66187628,743012589,1392269536,2054851622,80718891,1944441968,223409277,634790075,1533214902,1960544567,175024442,585661948,1549622769,2107207422,53235443,732600885,1428142648,2057778105,68293556,747947890,1377953663,1864147308,296321377,959403431,1201305002,1747123243,379051046,1041303776,1084500205,1633688546,534068207,928247593,1239863076,1717454501,418080424,812495470,1322816099,1243037256,883039813,472173187,1653729934,1294557967,865878786,454727620,1706014665,1147897030,987669707,307785741,1827491840,1129699713,1038154124,359017802,1808993607,1458457428,677079897,14532511,2120785810,1372591635,795162142,132375256,2035729109,1486025178,640143831,245433617,1880368412,1605151901,555322512,161437782,1999272027,1284643889,841432124,446818554,1679083767,1269580150,890855803,497006013,1663735216,1122936511,1012631218,350048884,1785229945,1171323896,996531189,333647667,1834364734,1349216557,786319648,106470886,2028846571,1465201770,702551143,23511201,2144592044,1578619811,547550126,136587112,1989216101,1495895780,664579817,253393455,1907317282,1969288713,198563332,592642754,1575363279,1918806862,216763203,611147653,1524137864,2065452167,94989450,758102092,1402640449,2082607552,43463117,705815819,1420084486,1771668245,388801304,1068136414,1092573139,1856495186,269680223,949234329,1176570516,1743075739,424679830,836160848,1331948893,1624990940,510543057,921210903,1214099482,1064814657,1103292492,1766079626,401677447,944346374,1190966539,1853514189,282018240,822833871,1337873090,1731757572,428713481,909455240,1216352133,1611062083,515111758,596557149,1564187984,1975339414,185100699,615571482,1510326295,1921193169,204879068,770836435,1397172190,2076308248,91542293,718035604,1417247385,2097131103,38440530,109388409,2016412276,1354159794,772011711,29065022,2131648307,1468566517,691907576,150575351,1984739578,1590324284,545213489,264750512,1903355325,1509175675,658575734,444356453,1690924904,1280287662,855278499,490867234,1677142575,1265762025,902094564,335605227,1790299622,1110645024,1015429421,322875564,1837863073,1158497383,1001940074]),Oe=64,$r=4,Me=4096,Ht=65536,_r=127;function Wr(r){let e=r.byteLength;if(e===0)return null;let t=(e-1)/16|0;if(t===0)return null;let n=t>>>2;n<16&&(n=16),n=Fr(n);let s=n-1,o=new Uint32Array(n),i=[],a=-1>>>0;for(let p=t*16-16;p>=0;p-=16){let u=0;for(let h=1;h<=16;h++)u=(u<<8|r[p+h])^Pe[u>>>23];if(u=u>>>0,u===a)i[i.length-1].ptr=p+16;else{a=u;let h=u&s;i.push({ptr:p+16,val:u}),o[h]++}}let l=new Map;for(let p of i){let u=p.val&s,h=l.get(u);h||(h=[],l.set(u,h)),h.push(p)}for(let[p,u]of l){if(u.length<=Oe)continue;let h=[],m=u.length/Oe;for(let R=0;R<Oe;R++)h.push(u[Math.floor(R*m)]);l.set(p,h),o[p]=Oe}let c=new Uint32Array(n+1),f=[],d=0;for(let p=0;p<n;p++){c[p]=d;let u=l.get(p);if(u){for(let h of u)f.push(h);d+=u.length}}return c[n]=d,{src:r,hashMask:s,buckets:c,entries:f}}function Gr(r,e,t){if(!r||e.byteLength===0)return null;let n=r.src.byteLength,s=e.byteLength,o=r.src,i=new Uint8Array(Math.max(s,1024)),a=0;function l(m){for(;a+m>i.length;){let R=new Uint8Array(i.length*2);R.set(i),i=R}}a=Nt(i,a,n),a=Nt(i,a,s),l(18),a++;let c=0,f=0,d=Math.min(16,s);for(let m=0;m<d;m++)i[a++]=e[m],c=(c<<8|e[m])^Pe[c>>>23],f++;c=c>>>0;let p=d,u=0,h=0;for(;p<s;){if(h<Me){c^=Br[e[p-16]],c=((c<<8|e[p])^Pe[c>>>23])>>>0;let m=c&r.hashMask,R=r.buckets[m],b=r.buckets[m+1];for(let y=R;y<b;y++){let g=r.entries[y];if(g.val!==c)continue;let w=g.ptr,E=o.byteLength-w,x=s-p;if(E>x&&(E=x),E<=h)break;let O=0;for(;O<E&&o[w+O]===e[p+O];)O++;if(O>h&&(h=O,u=w,h>=Me))break}}if(h<$r)l(2),f===0&&a++,i[a++]=e[p++],f++,f===_r&&(i[a-f-1]=f,f=0),h=0;else{if(f>0){for(;u>0&&o[u-1]===e[p-1];)if(h++,u--,p--,a--,!(--f>0)){a--,f=-1;break}f>0&&(i[a-f-1]=f),f=0}let m=h>Ht?h-Ht:0;h-=m,l(8);let R=a++,b=128;if(u&255&&(i[a++]=u&255,b|=1),u&65280&&(i[a++]=u>>>8&255,b|=2),u&16711680&&(i[a++]=u>>>16&255,b|=4),u&4278190080&&(i[a++]=u>>>24&255,b|=8),h&255&&(i[a++]=h&255,b|=16),h&65280&&(i[a++]=h>>>8&255,b|=32),i[R]=b,p+=h,u+=h,h=m,u>4294967295&&(h=0),h<Me){c=0;for(let y=-16;y<0;y++)c=(c<<8|e[p+y])^Pe[c>>>23];c=c>>>0}}if(t&&a>t)return null}return f>0&&(i[a-f-1]=f),t&&a>t?null:i.subarray(0,a)}var Dt={blob:0,tree:1,commit:2,tag:3};function Mt(r,e){let t=e?.window??10,n=e?.depth??50,s=r.slice().sort((c,f)=>{let d=Dt[c.type]??99,p=Dt[f.type]??99;return d!==p?d-p:f.content.byteLength-c.content.byteLength}),o=new Map,i=[],a=[],l=[];for(let c=0;c<s.length;c++){let f=s[c],d={hash:f.hash,type:f.type,content:f.content,depth:0},p=null,u=null,h=Math.max(0,c-t);for(let m=c-1;m>=h;m--){let R=s[m];if(R.type!==f.type||(o.get(R.hash)?.depth??0)>=n||f.content.byteLength<R.content.byteLength>>>5)continue;let g=a[m-h]??null;if(!g)continue;let w=p?p.byteLength:f.content.byteLength/2|0;if(w<16)continue;let E=Gr(g,f.content,w);E&&(!p||E.byteLength<p.byteLength)&&(p=E,u=R.hash)}if(p&&u){d.delta=p,d.deltaBase=u;let m=o.get(u);d.depth=(m?.depth??0)+1}o.set(f.hash,d),i.push(d),a.length>=t&&(a.shift(),l.shift()),a.push(Wr(f.content)),l.push(f.hash)}return i}function Fr(r){let e=r;return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e<16?16:e}function Nt(r,e,t){let n=t;do{let s=n&127;n>>>=7,n>0&&(s|=128),r[e++]=s}while(n>0);return e}var qr=2147483647;async function Bt(r,e,t,n){if(t>=qr)return{shallow:[],unshallow:[...n]};let s=new Map,o=[];for(let c of e)!s.has(c)&&await ae(r,c)&&(s.set(c,1),o.push({hash:c,level:1}));let i=new Set,a=0;for(;a<o.length;){let{hash:c,level:f}=o[a++];if(f>=t){i.add(c);continue}let d;try{d=await X(r,c)}catch{continue}for(let p of d.parents)!s.has(p)&&await ae(r,p)&&(s.set(p,f+1),o.push({hash:p,level:f+1}))}let l=[];for(let c of n){let f=s.get(c);f!==void 0&&f<t&&l.push(c)}return{shallow:[...i],unshallow:l}}async function fe(r,e,t,n,s){let o=s??n,i=new Set;for(let f of t)await ie(r,f,i,o);let a=[...e];if(s&&n)for(let f of s)try{let d=await X(r,f);for(let p of d.parents)i.has(p)||a.push(p)}catch{}let l=[],c=new Set;for(let f of a)await ce(r,f,i,c,l,n);return{count:l.length,objects:zr(l)}}async function $t(r,e,t,n,s){let{count:o,objects:i}=await fe(r,e,t,n,s);return{count:o,objects:Xr(r,i)}}async function*zr(r){for(let e of r)yield e}async function*Xr(r,e){for await(let t of e){let n=await oe(r,t.hash);yield{hash:t.hash,type:t.type,content:n.content}}}async function _t(r){let e=[];for await(let t of r.objects)e.push(t);return e}async function ie(r,e,t,n){if(t.has(e)||(t.add(e),!await ae(r,e)))return;let s=await oe(r,e);switch(s.type){case"commit":{let o=se(s.content);if(await ie(r,o.tree,t,n),!n?.has(e))for(let i of o.parents)await ie(r,i,t,n);break}case"tree":{let o=De(s.content);for(let i of o.entries)await ie(r,i.hash,t,n);break}case"tag":{let o=W(s.content);await ie(r,o.object,t,n);break}case"blob":break}}async function ce(r,e,t,n,s,o){if(n.has(e)||t.has(e))return;n.add(e);let i=await oe(r,e);switch(s.push({hash:e,type:i.type}),i.type){case"commit":{let a=se(i.content);if(await ce(r,a.tree,t,n,s,o),!o?.has(e))for(let l of a.parents)await ce(r,l,t,n,s,o);break}case"tree":{let a=De(i.content);for(let l of a.entries)await ce(r,l.hash,t,n,s,o);break}case"tag":{let a=W(i.content);await ce(r,a.object,t,n,s,o);break}case"blob":break}}var Kr=new TextEncoder,Gt=new TextDecoder,Wt=65520,Yr=new Uint8Array([48,48,48,48]);function v(r){let e=typeof r=="string"?Kr.encode(r):r,t=4+e.byteLength;if(t>Wt)throw new Error(`pkt-line too long: ${t} bytes (max ${Wt})`);let n=t.toString(16).padStart(4,"0"),s=new Uint8Array(t);return s[0]=n.charCodeAt(0),s[1]=n.charCodeAt(1),s[2]=n.charCodeAt(2),s[3]=n.charCodeAt(3),s.set(e,4),s}function D(){return Yr.slice()}function M(...r){let e=0;for(let s of r)e+=s.byteLength;let t=new Uint8Array(e),n=0;for(let s of r)t.set(s,n),n+=s.byteLength;return t}function Ft(r){let e=[],t=0;for(;t<r.byteLength;){if(t+4>r.byteLength)throw new Error("Truncated pkt-line header");let n=Gt.decode(r.subarray(t,t+4)),s=parseInt(n,16);if(Number.isNaN(s))throw new Error(`Invalid pkt-line length: ${n}`);if(s===0){e.push({type:"flush"}),t+=4;continue}if(s<4)throw new Error(`Invalid pkt-line length: ${s}`);if(t+s>r.byteLength)throw new Error(`Truncated pkt-line: need ${s} bytes at offset ${t}, have ${r.byteLength-t}`);e.push({type:"data",data:r.subarray(t+4,t+s)}),t+=s}return e}function qt(r){if(r.type==="flush")return"";let e=Gt.decode(r.data);return e.endsWith(`
|
|
8
|
-
`)?e.slice(0,-1):e}var
|
|
9
|
-
`));else for(let i=0;i<r.length;i++){let
|
|
10
|
-
`)):n.push(
|
|
11
|
-
`))}return n.push(
|
|
12
|
-
`),
|
|
13
|
-
`));for(let
|
|
14
|
-
`));s.push(
|
|
15
|
-
`));let
|
|
16
|
-
`)),s.push(
|
|
17
|
-
`))}else s.push(
|
|
18
|
-
`));if(e){let
|
|
19
|
-
`));for(let t of r.unshallow)e.push(
|
|
20
|
-
`));return e.push(
|
|
21
|
-
`));for(let i of n.unshallow)
|
|
22
|
-
`));
|
|
23
|
-
`));let
|
|
24
|
-
`)),s.push(
|
|
25
|
-
`))}else s.push(
|
|
26
|
-
`));if(yield
|
|
27
|
-
`)?
|
|
6
|
+
`),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+2),a="",i="commit",o="",f;for(let c of n.split(`
|
|
7
|
+
`)){let l=c.indexOf(" ");if(l===-1)continue;let d=c.slice(0,l),p=c.slice(l+1);switch(d){case"object":a=p;break;case"type":i=p;break;case"tag":o=p;break;case"tagger":f=ie(p);break}}if(!a)throw new Error("Tag missing object field");if(!o)throw new Error("Tag missing tag name field");if(!f)throw new Error("Tag missing tagger field");return{type:"tag",object:a,objectType:i,name:o,tagger:f,message:s}}async function fe(r,e){return r.objectStore.read(e)}async function le(r,e){return r.objectStore.exists(e)}var fs=new TextDecoder;async function Y(r,e){let t=await fe(r,e);if(t.type!=="commit")throw new Error(`Expected commit object for ${e}, got ${t.type}`);return ce(t.content)}function qt(r){return typeof r=="string"?{type:"direct",hash:r}:r}var Fe=".lock";var Xr=[1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,5,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,4,4];function Yr(r,e,t){let n=0,s=!1,a=e;for(;a<r.length;a++){let o=r.charCodeAt(a);switch(o<128?Xr[o]:0){case 1:break;case 2:if(n===46)return{len:-1,starConsumed:s};n=o;continue;case 3:if(n===64)return{len:-1,starConsumed:s};n=o;continue;case 4:return{len:-1,starConsumed:s};case 5:if(!t)return{len:-1,starConsumed:s};s=!0,n=o;continue;default:n=o;continue}break}let i=a-e;return i===0?{len:0,starConsumed:s}:r.charCodeAt(e)===46?{len:-1,starConsumed:s}:i>=Fe.length&&r.slice(a-Fe.length,a)===Fe?{len:-1,starConsumed:s}:{len:i,starConsumed:s}}function Vt(r,e=0){if(r==="@"||r.length===0)return!1;let t=0,n=0,s=!!(e&2);for(;t<=r.length;){let{len:a,starConsumed:i}=Yr(r,t,s);if(a<0||a===0)return!1;i&&(s=!1),n++,t+=a+1}return!(r.charCodeAt(r.length-1)===46||!(e&1)&&n<2)}var Zr=10;async function Jr(r,e){return r.refStore.readRef(e)}async function Ge(r,e){let t=e;for(let n=0;n<Zr;n++){let s=await Jr(r,t);if(!s)return null;if(s.type==="direct")return s.hash;t=s.target}throw new Error(`Symbolic ref loop detected resolving "${e}"`)}var hs=new TextEncoder,zt=new TextDecoder,Qr=new Set(["100644","100755","040000","120000","160000"]);function en(r){return r.length===4&&r.toLowerCase()===".git"}function tn(r,e){if(r.length===0)throw new Error("invalid tree entry: empty name");if(r.includes("/"))throw new Error(`invalid tree entry: name contains slash: '${r}'`);if(r.includes("\0"))throw new Error("invalid tree entry: name contains null byte");if(r==="."||r==="..")throw new Error(`invalid tree entry: '${r}'`);if(en(r))throw new Error(`invalid tree entry: '${r}'`);if(!Qr.has(e))throw new Error(`invalid tree entry mode: '${e}' for '${r}'`)}function qe(r){let e=[],t=0;for(;t<r.byteLength;){let n=r.indexOf(32,t);if(n===-1)break;let s=zt.decode(r.subarray(t,n)),a=r.indexOf(0,n+1);if(a===-1)break;let i=zt.decode(r.subarray(n+1,a)),o=r.subarray(a+1,a+21),f=ke(o),c=s.padStart(6,"0");tn(i,c),e.push({mode:c,name:i,hash:f}),t=a+21}return{type:"tree",entries:e}}async function Ve(r,e,t){if(e===t)return!0;let n=new Set,s=[t],a=0;for(;a<s.length;){let i=s[a++];if(i===e)return!0;if(n.has(i))continue;n.add(i);let o;try{o=await Y(r,i)}catch{continue}for(let f of o.parents)n.has(f)||s.push(f)}return!1}var Te=new Uint32Array([0,2874782929,1454598562,4260027763,104818581,2909197124,1351355959,4225088230,209637162,2804382715,1523426952,4053013081,172075199,2702711918,1559413021,4155209164,419274324,3013880453,1313798134,3843506983,516094401,3046853904,1215402083,3811058866,344150398,3218793903,1110456540,3916008461,314324715,3118826042,1141858121,4015451032,838548648,2594343033,1732793610,3423723995,935615293,2627596268,1635201695,3392046670,1032188802,2531018579,1798740512,3228511985,1002083351,2430804166,1829371317,3327150436,688300796,2187269677,2142620510,3572268943,792315241,2220913080,2039131339,3537049626,628649430,2384582919,1942684788,3633492133,591858243,2283716242,1978950625,3735934768,1677097296,3366964609,893718770,2652677155,1707679429,3465587220,863663975,2552480694,1871230586,3302032043,960225240,2455923465,1773654511,3270403390,1057273933,2489126044,2064377604,3495056341,767069862,2262907511,2100592785,3597481024,730327347,2162056674,2004166702,3693911295,566641036,2325738845,1900695483,3658742634,670639641,2359333576,1376601592,4183093545,79572058,2951190667,1412571757,4285241020,42027983,2849570590,1584630482,4113186307,146858864,2744735649,1481436487,4078262678,251626725,2779131956,1257298860,3785977725,474198542,3071936223,1288682553,3885369576,444388763,2972016970,1183716486,3990331479,272465188,3143944693,1085371155,3957901250,369236657,3176902240,1823819377,3354194592,973483987,2438961922,1787437540,3251868981,1010387014,2539715735,1623951707,3415358858,913891577,2636207144,1727327950,3450690079,809994092,2602447805,1950930981,3742461172,586920327,2309096790,1920450480,3643673441,616879634,2409456323,2016810767,3547309022,780500653,2245839484,2114547866,3578840139,683284792,2212736489,1565424345,4128755208,201134971,2695145386,1534139724,4029196701,230847726,2795225151,1362146803,4201185570,126082129,2899994752,1460654694,4233520823,29146052,2867138325,1169417357,4008333404,318803247,3092855294,1133282072,3906287561,356510394,3194379883,1238182823,3801390966,528368133,3022517972,1341279282,3836475619,423699856,2987954497,256065313,2753203184,1508923011,4071219794,159144116,2720394341,1607414038,4103505351,54390795,2825143514,1435408809,4275514744,84055966,2925208399,1404173884,4175973101,398369141,3169260964,1091422423,3931405318,293717728,3134747185,1194504002,3966442387,465595999,2962872974,1299384317,3861558060,503253450,3064380699,1263296616,3759527097,1052246921,2514597720,1745578539,3276988154,948397084,2480853197,1848905150,3312302447,851889315,2577365106,1685431553,3475771856,888777526,2678071271,1649066644,3373495877,642096605,2367432972,1895232639,3685695662,544930376,2334346905,1992922090,3717211963,708530935,2170742310,2089302869,3620835204,738473314,2271052211,2058837184,3522095121]),rn=new Uint32Array([0,2125799437,1446245579,679924934,121527623,2039184714,1359849868,800622977,243055246,1892260483,1481592389,653946440,155379657,2012727236,1601245954,566506255,486110492,1649169681,1254785495,880779738,466036827,1701972054,1307892880,859962525,310759314,1815146399,1152793433,973282132,364614357,1796125400,1133012510,1027425811,972220984,1195887157,1874927347,292830974,1053603711,1081710450,1761559476,373973945,932073654,1228632251,1639818365,520651888,816844273,1308962300,1719925050,406247735,621518628,1539227433,1933077487,227363810,573948515,1551950446,1946564264,179508901,729228714,1438778791,2101662049,66187628,743012589,1392269536,2054851622,80718891,1944441968,223409277,634790075,1533214902,1960544567,175024442,585661948,1549622769,2107207422,53235443,732600885,1428142648,2057778105,68293556,747947890,1377953663,1864147308,296321377,959403431,1201305002,1747123243,379051046,1041303776,1084500205,1633688546,534068207,928247593,1239863076,1717454501,418080424,812495470,1322816099,1243037256,883039813,472173187,1653729934,1294557967,865878786,454727620,1706014665,1147897030,987669707,307785741,1827491840,1129699713,1038154124,359017802,1808993607,1458457428,677079897,14532511,2120785810,1372591635,795162142,132375256,2035729109,1486025178,640143831,245433617,1880368412,1605151901,555322512,161437782,1999272027,1284643889,841432124,446818554,1679083767,1269580150,890855803,497006013,1663735216,1122936511,1012631218,350048884,1785229945,1171323896,996531189,333647667,1834364734,1349216557,786319648,106470886,2028846571,1465201770,702551143,23511201,2144592044,1578619811,547550126,136587112,1989216101,1495895780,664579817,253393455,1907317282,1969288713,198563332,592642754,1575363279,1918806862,216763203,611147653,1524137864,2065452167,94989450,758102092,1402640449,2082607552,43463117,705815819,1420084486,1771668245,388801304,1068136414,1092573139,1856495186,269680223,949234329,1176570516,1743075739,424679830,836160848,1331948893,1624990940,510543057,921210903,1214099482,1064814657,1103292492,1766079626,401677447,944346374,1190966539,1853514189,282018240,822833871,1337873090,1731757572,428713481,909455240,1216352133,1611062083,515111758,596557149,1564187984,1975339414,185100699,615571482,1510326295,1921193169,204879068,770836435,1397172190,2076308248,91542293,718035604,1417247385,2097131103,38440530,109388409,2016412276,1354159794,772011711,29065022,2131648307,1468566517,691907576,150575351,1984739578,1590324284,545213489,264750512,1903355325,1509175675,658575734,444356453,1690924904,1280287662,855278499,490867234,1677142575,1265762025,902094564,335605227,1790299622,1110645024,1015429421,322875564,1837863073,1158497383,1001940074]),Ie=64,nn=4,ze=4096,Kt=65536,sn=127;function an(r){let e=r.byteLength;if(e===0)return null;let t=(e-1)/16|0;if(t===0)return null;let n=t>>>2;n<16&&(n=16),n=cn(n);let s=n-1,a=new Uint32Array(n),i=[],o=-1>>>0;for(let p=t*16-16;p>=0;p-=16){let h=0;for(let u=1;u<=16;u++)h=(h<<8|r[p+u])^Te[h>>>23];if(h=h>>>0,h===o)i[i.length-1].ptr=p+16;else{o=h;let u=h&s;i.push({ptr:p+16,val:h}),a[u]++}}let f=new Map;for(let p of i){let h=p.val&s,u=f.get(h);u||(u=[],f.set(h,u)),u.push(p)}for(let[p,h]of f){if(h.length<=Ie)continue;let u=[],m=h.length/Ie;for(let x=0;x<Ie;x++)u.push(h[Math.floor(x*m)]);f.set(p,u),a[p]=Ie}let c=new Uint32Array(n+1),l=[],d=0;for(let p=0;p<n;p++){c[p]=d;let h=f.get(p);if(h){for(let u of h)l.push(u);d+=h.length}}return c[n]=d,{src:r,hashMask:s,buckets:c,entries:l}}function on(r,e,t){if(!r||e.byteLength===0)return null;let n=r.src.byteLength,s=e.byteLength,a=r.src,i=new Uint8Array(Math.max(s,1024)),o=0;function f(m){for(;o+m>i.length;){let x=new Uint8Array(i.length*2);x.set(i),i=x}}o=Yt(i,o,n),o=Yt(i,o,s),f(18),o++;let c=0,l=0,d=Math.min(16,s);for(let m=0;m<d;m++)i[o++]=e[m],c=(c<<8|e[m])^Te[c>>>23],l++;c=c>>>0;let p=d,h=0,u=0;for(;p<s;){if(u<ze){c^=rn[e[p-16]],c=((c<<8|e[p])^Te[c>>>23])>>>0;let m=c&r.hashMask,x=r.buckets[m],y=r.buckets[m+1];for(let b=x;b<y;b++){let R=r.entries[b];if(R.val!==c)continue;let E=R.ptr,w=a.byteLength-E,g=s-p;if(w>g&&(w=g),w<=u)break;let k=0;for(;k<w&&a[E+k]===e[p+k];)k++;if(k>u&&(u=k,h=E,u>=ze))break}}if(u<nn)f(2),l===0&&o++,i[o++]=e[p++],l++,l===sn&&(i[o-l-1]=l,l=0),u=0;else{if(l>0){for(;h>0&&a[h-1]===e[p-1];)if(u++,h--,p--,o--,!(--l>0)){o--,l=-1;break}l>0&&(i[o-l-1]=l),l=0}let m=u>Kt?u-Kt:0;u-=m,f(8);let x=o++,y=128;if(h&255&&(i[o++]=h&255,y|=1),h&65280&&(i[o++]=h>>>8&255,y|=2),h&16711680&&(i[o++]=h>>>16&255,y|=4),h&4278190080&&(i[o++]=h>>>24&255,y|=8),u&255&&(i[o++]=u&255,y|=16),u&65280&&(i[o++]=u>>>8&255,y|=32),i[x]=y,p+=u,h+=u,u=m,h>4294967295&&(u=0),u<ze){c=0;for(let b=-16;b<0;b++)c=(c<<8|e[p+b])^Te[c>>>23];c=c>>>0}}if(t&&o>t)return null}return l>0&&(i[o-l-1]=l),t&&o>t?null:i.subarray(0,o)}var Xt={blob:0,tree:1,commit:2,tag:3};function Zt(r,e){let t=e?.window??10,n=e?.depth??50,s=r.slice().sort((c,l)=>{let d=Xt[c.type]??99,p=Xt[l.type]??99;return d!==p?d-p:l.content.byteLength-c.content.byteLength}),a=new Map,i=[],o=[],f=[];for(let c=0;c<s.length;c++){let l=s[c],d={hash:l.hash,type:l.type,content:l.content,depth:0},p=null,h=null,u=Math.max(0,c-t);for(let m=c-1;m>=u;m--){let x=s[m];if(x.type!==l.type||(a.get(x.hash)?.depth??0)>=n||l.content.byteLength<x.content.byteLength>>>5)continue;let R=o[m-u]??null;if(!R)continue;let E=p?p.byteLength:l.content.byteLength/2|0;if(E<16)continue;let w=on(R,l.content,E);w&&(!p||w.byteLength<p.byteLength)&&(p=w,h=x.hash)}if(p&&h){d.delta=p,d.deltaBase=h;let m=a.get(h);d.depth=(m?.depth??0)+1}a.set(l.hash,d),i.push(d),o.length>=t&&(o.shift(),f.shift()),o.push(an(l.content)),f.push(l.hash)}return i}function cn(r){let e=r;return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e<16?16:e}function Yt(r,e,t){let n=t;do{let s=n&127;n>>>=7,n>0&&(s|=128),r[e++]=s}while(n>0);return e}var fn=2147483647;async function Ke(r,e,t,n){if(t>=fn)return{shallow:[],unshallow:[...n]};let s=new Map,a=[];for(let c of e)!s.has(c)&&await le(r,c)&&(s.set(c,1),a.push({hash:c,level:1}));let i=new Set,o=0;for(;o<a.length;){let{hash:c,level:l}=a[o++];if(l>=t){i.add(c);continue}let d;try{d=await Y(r,c)}catch{continue}for(let p of d.parents)!s.has(p)&&await le(r,p)&&(s.set(p,l+1),a.push({hash:p,level:l+1}))}let f=[];for(let c of n){let l=s.get(c);l!==void 0&&l<t&&f.push(c)}return{shallow:[...i],unshallow:f}}async function ue(r,e,t,n,s){let a=s??n,i=new Set;for(let l of t)await de(r,l,i,a);let o=[...e];if(s&&n)for(let l of s)try{let d=await Y(r,l);for(let p of d.parents)i.has(p)||o.push(p)}catch{}let f=[],c=new Set;for(let l of o)await pe(r,l,i,c,f,n);return{count:f.length,objects:ln(f)}}async function Jt(r,e,t,n,s){let{count:a,objects:i}=await ue(r,e,t,n,s);return{count:a,objects:dn(r,i)}}async function*ln(r){for(let e of r)yield e}async function*dn(r,e){for await(let t of e){let n=await fe(r,t.hash);yield{hash:t.hash,type:t.type,content:n.content}}}async function Qt(r){let e=[];for await(let t of r.objects)e.push(t);return e}async function de(r,e,t,n){if(t.has(e)||(t.add(e),!await le(r,e)))return;let s=await fe(r,e);switch(s.type){case"commit":{let a=ce(s.content);if(await de(r,a.tree,t,n),!n?.has(e))for(let i of a.parents)await de(r,i,t,n);break}case"tree":{let a=qe(s.content);for(let i of a.entries)await de(r,i.hash,t,n);break}case"tag":{let a=X(s.content);await de(r,a.object,t,n);break}case"blob":break}}async function pe(r,e,t,n,s,a){if(n.has(e)||t.has(e))return;n.add(e);let i=await fe(r,e);switch(s.push({hash:e,type:i.type}),i.type){case"commit":{let o=ce(i.content);if(await pe(r,o.tree,t,n,s,a),!a?.has(e))for(let f of o.parents)await pe(r,f,t,n,s,a);break}case"tree":{let o=qe(i.content);for(let f of o.entries)await pe(r,f.hash,t,n,s,a);break}case"tag":{let o=X(i.content);await pe(r,o.object,t,n,s,a);break}case"blob":break}}var pn=new TextEncoder,tr=new TextDecoder,er=65520,un=new Uint8Array([48,48,48,48]),hn=new Uint8Array([48,48,48,49]),vs=new Uint8Array([48,48,48,50]);function O(r){let e=typeof r=="string"?pn.encode(r):r,t=4+e.byteLength;if(t>er)throw new Error(`pkt-line too long: ${t} bytes (max ${er})`);let n=t.toString(16).padStart(4,"0"),s=new Uint8Array(t);return s[0]=n.charCodeAt(0),s[1]=n.charCodeAt(1),s[2]=n.charCodeAt(2),s[3]=n.charCodeAt(3),s.set(e,4),s}function L(){return un.slice()}function F(){return hn.slice()}function T(...r){let e=0;for(let s of r)e+=s.byteLength;let t=new Uint8Array(e),n=0;for(let s of r)t.set(s,n),n+=s.byteLength;return t}function Xe(r){let e=[],t=0;for(;t<r.byteLength;){if(t+4>r.byteLength)throw new Error("Truncated pkt-line header");let n=tr.decode(r.subarray(t,t+4)),s=parseInt(n,16);if(Number.isNaN(s))throw new Error(`Invalid pkt-line length: ${n}`);if(s===0){e.push({type:"flush"}),t+=4;continue}if(s===1){e.push({type:"delim"}),t+=4;continue}if(s===2){e.push({type:"response-end"}),t+=4;continue}if(s<4)throw new Error(`Invalid pkt-line length: ${s}`);if(t+s>r.byteLength)throw new Error(`Truncated pkt-line: need ${s} bytes at offset ${t}, have ${r.byteLength-t}`);e.push({type:"data",data:r.subarray(t+4,t+s)}),t+=s}return e}function Ye(r){if(r.type!=="data")return"";let e=tr.decode(r.data);return e.endsWith(`
|
|
8
|
+
`)?e.slice(0,-1):e}var Ue=65515;function Le(r,e,t){let n=[],s=[...e];t&&s.push(`symref=HEAD:${t}`),s.push("agent=just-git/1.0");let a=s.join(" ");if(r.length===0)n.push(O(`0000000000000000000000000000000000000000 capabilities^{}\0${a}
|
|
9
|
+
`));else for(let i=0;i<r.length;i++){let o=r[i];i===0?n.push(O(`${o.hash} ${o.name}\0${a}
|
|
10
|
+
`)):n.push(O(`${o.hash} ${o.name}
|
|
11
|
+
`))}return n.push(L()),T(...n)}function rr(r,e,t,n){let s=T(O(`# service=${e}
|
|
12
|
+
`),L()),a=Le(r,t,n),i=new Uint8Array(s.byteLength+a.byteLength);return i.set(s,0),i.set(a,s.byteLength),i}function nr(r){let e=Xe(r),t=[],n=[],s=[],a=[],i,o=!1;for(let f of e){if(f.type==="flush")continue;let c=Ye(f);if(c.startsWith("want ")){let l=c.slice(5);if(t.length===0){let d=l.indexOf(" ");d!==-1?(t.push(l.slice(0,d)),a=l.slice(d+1).split(" ").filter(Boolean)):t.push(l)}else t.push(l)}else c.startsWith("have ")?n.push(c.slice(5)):c.startsWith("shallow ")?s.push(c.slice(8)):c.startsWith("deepen ")?(i=parseInt(c.slice(7),10),Number.isNaN(i)&&(i=void 0)):c==="done"&&(o=!0)}return{wants:t,haves:n,capabilities:a,clientShallows:s,depth:i,done:o}}function he(r,e,t,n){let s=[];if(n){for(let a of n.shallow)s.push(O(`shallow ${a}
|
|
13
|
+
`));for(let a of n.unshallow)s.push(O(`unshallow ${a}
|
|
14
|
+
`));s.push(L())}if(t&&t.length>0){for(let i of t)s.push(O(`ACK ${i} common
|
|
15
|
+
`));let a=t[t.length-1];s.push(O(`ACK ${a} ready
|
|
16
|
+
`)),s.push(O(`ACK ${a}
|
|
17
|
+
`))}else s.push(O(`NAK
|
|
18
|
+
`));if(e){let a=0;for(;a<r.byteLength;){let i=Math.min(Ue,r.byteLength-a);s.push(ye(1,r.subarray(a,a+i))),a+=i}s.push(L())}else{let a=new Uint8Array(r.byteLength);a.set(r),s.push(a)}return T(...s)}function sr(r){let e=[];for(let t of r.shallow)e.push(O(`shallow ${t}
|
|
19
|
+
`));for(let t of r.unshallow)e.push(O(`unshallow ${t}
|
|
20
|
+
`));return e.push(L()),T(...e)}async function*ar(r,e,t,n){if(n){let a=[];for(let i of n.shallow)a.push(O(`shallow ${i}
|
|
21
|
+
`));for(let i of n.unshallow)a.push(O(`unshallow ${i}
|
|
22
|
+
`));a.push(L()),yield T(...a)}let s=[];if(t&&t.length>0){for(let i of t)s.push(O(`ACK ${i} common
|
|
23
|
+
`));let a=t[t.length-1];s.push(O(`ACK ${a} ready
|
|
24
|
+
`)),s.push(O(`ACK ${a}
|
|
25
|
+
`))}else s.push(O(`NAK
|
|
26
|
+
`));if(yield T(...s),e){for await(let a of r){let i=0;for(;i<a.byteLength;){let o=Math.min(Ue,a.byteLength-i);yield ye(1,a.subarray(i,i+o)),i+=o}}yield L()}else for await(let a of r)yield a}function or(r){let e=new TextDecoder,t=[],n=[],s=0,a=!1;for(;s<r.byteLength&&!(s+4>r.byteLength);){let o=e.decode(r.subarray(s,s+4)),f=parseInt(o,16);if(Number.isNaN(f))break;if(f===0){a=!0,s+=4;break}if(f<4||s+f>r.byteLength)break;let c=r.subarray(s+4,s+f);s+=f;let l=c.indexOf(0),d;if(l!==-1)d=e.decode(c.subarray(0,l)),n=e.decode(c.subarray(l+1)).replace(/\n$/,"").split(" ").filter(Boolean);else{let h=e.decode(c);d=h.endsWith(`
|
|
27
|
+
`)?h.slice(0,-1):h}let p=d.split(" ");p.length>=3&&t.push({oldHash:p[0],newHash:p[1],refName:p[2]})}let i=s<r.byteLength?r.subarray(s):new Uint8Array(0);return{commands:t,packData:i,capabilities:n,sawFlush:a}}function Z(r,e,t){let n=[];n.push(O(r?`unpack ok
|
|
28
28
|
`:`unpack error
|
|
29
|
-
`));for(let
|
|
30
|
-
`)):n.push(
|
|
31
|
-
`));n.push(
|
|
32
|
-
`)
|
|
33
|
-
`)
|
|
34
|
-
`)
|
|
35
|
-
`)
|
|
36
|
-
`)
|
|
37
|
-
`)),
|
|
38
|
-
`))
|
|
29
|
+
`));for(let a of e)a.ok?n.push(O(`ok ${a.name}
|
|
30
|
+
`)):n.push(O(`ng ${a.name} ${a.error??"failed"}
|
|
31
|
+
`));n.push(L());let s=T(...n);if(t){let a=[];return a.push(ye(1,s)),a.push(L()),T(...a)}return s}function ye(r,e){let t=new Uint8Array(1+e.byteLength);return t[0]=r,t.set(e,1),O(t)}function Ze(r){let e=[];e.push(O(`version 2
|
|
32
|
+
`));for(let t of r)e.push(O(`${t}
|
|
33
|
+
`));return e.push(L()),T(...e)}function Je(r){let e=Xe(r),t="",n=[],s=[],a=!1;for(let i of e){if(i.type==="flush"||i.type==="response-end")break;if(i.type==="delim"){a=!0;continue}let o=Ye(i);o&&(a?s.push(o):o.startsWith("command=")?t=o.slice(8):n.push(o))}return{command:t,capabilities:n,args:s}}function Qe(r){let e=[];for(let t of r){let n=`${t.hash} ${t.name}`;t.symrefTarget&&(n+=` symref-target:${t.symrefTarget}`),t.peeledHash&&(n+=` peeled:${t.peeledHash}`),e.push(O(`${n}
|
|
34
|
+
`))}return e.push(L()),T(...e)}function et(r){let e=[],t=[],n=[],s=[],a=!1,i,o=!1,f=!1;for(let c of r)c.startsWith("want ")?e.push(c.slice(5)):c.startsWith("have ")?t.push(c.slice(5)):c.startsWith("shallow ")?n.push(c.slice(8)):c.startsWith("deepen ")?(i=parseInt(c.slice(7),10),Number.isNaN(i)&&(i=void 0)):c.startsWith("want-ref ")?s.push(c.slice(9)):c==="done"?a=!0:c==="include-tag"?o=!0:c==="ofs-delta"&&(f=!0);return{wants:e,haves:t,done:a,clientShallows:n,depth:i,includeTag:o,ofsDeltas:f,wantRefs:s}}function J(r,e){let t=[],{commonHashes:n,shallowInfo:s,wantedRefs:a}=e??{};if(n&&n.length>0){t.push(O(`acknowledgments
|
|
35
|
+
`));for(let o of n)t.push(O(`ACK ${o}
|
|
36
|
+
`));t.push(O(`ready
|
|
37
|
+
`)),t.push(F())}if(s&&(s.shallow.length>0||s.unshallow.length>0)){t.push(O(`shallow-info
|
|
38
|
+
`));for(let o of s.shallow)t.push(O(`shallow ${o}
|
|
39
|
+
`));for(let o of s.unshallow)t.push(O(`unshallow ${o}
|
|
40
|
+
`));t.push(F())}if(a&&a.length>0){t.push(O(`wanted-refs
|
|
41
|
+
`));for(let o of a)t.push(O(`${o.hash} ${o.name}
|
|
42
|
+
`));t.push(F())}t.push(O(`packfile
|
|
43
|
+
`));let i=0;for(;i<r.byteLength;){let o=Math.min(Ue,r.byteLength-i);t.push(ye(1,r.subarray(i,i+o))),i+=o}return t.push(L()),T(...t)}function ir(r,e){let t=[];if(t.push(O(`acknowledgments
|
|
44
|
+
`)),r.length>0)for(let n of r)t.push(O(`ACK ${n}
|
|
45
|
+
`));else t.push(O(`NAK
|
|
46
|
+
`));return e&&t.push(O(`ready
|
|
47
|
+
`)),t.push(L()),T(...t)}async function*cr(r,e){let{commonHashes:t,shallowInfo:n,wantedRefs:s}=e??{};if(t&&t.length>0){let a=[];a.push(O(`acknowledgments
|
|
48
|
+
`));for(let i of t)a.push(O(`ACK ${i}
|
|
49
|
+
`));a.push(O(`ready
|
|
50
|
+
`)),a.push(F()),yield T(...a)}if(n&&(n.shallow.length>0||n.unshallow.length>0)){let a=[];a.push(O(`shallow-info
|
|
51
|
+
`));for(let i of n.shallow)a.push(O(`shallow ${i}
|
|
52
|
+
`));for(let i of n.unshallow)a.push(O(`unshallow ${i}
|
|
53
|
+
`));a.push(F()),yield T(...a)}if(s&&s.length>0){let a=[];a.push(O(`wanted-refs
|
|
54
|
+
`));for(let i of s)a.push(O(`${i.hash} ${i.name}
|
|
55
|
+
`));a.push(F()),yield T(...a)}yield O(`packfile
|
|
56
|
+
`);for await(let a of r){let i=0;for(;i<a.byteLength;){let o=Math.min(Ue,a.byteLength-i);yield ye(1,a.subarray(i,i+o)),i+=o}}yield L()}var Q=class{entries=new Map;currentBytes=0;maxBytes;hits=0;misses=0;constructor(e=256*1024*1024){this.maxBytes=e}static key(e,t,n){if(n.length>0)return null;let s=t.slice().sort();return`${e}\0${s.join(",")}`}get(e){let t=this.entries.get(e);return t?this.hits++:this.misses++,t}set(e,t){if(this.entries.has(e))return;let n=t.packData.byteLength;if(!(n>this.maxBytes)){for(;this.currentBytes+n>this.maxBytes&&this.entries.size>0;){let s=this.entries.keys().next().value;this.currentBytes-=this.entries.get(s).packData.byteLength,this.entries.delete(s)}this.entries.set(e,t),this.currentBytes+=n}}clear(){this.entries.clear(),this.currentBytes=0}get stats(){return{entries:this.entries.size,bytes:this.currentBytes,hits:this.hits,misses:this.misses}}},fr=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","allow-reachable-sha1-in-want","shallow"],lr=["report-status","side-band-64k","ofs-delta","delete-refs"];async function dr(r){let e=await r.refStore.listRefs("refs"),t=await r.refStore.readRef("HEAD"),n=[],s=null,a;if(t)if(t.type==="symbolic"){a=t.target;let o=await r.refStore.readRef(t.target);o?.type==="direct"&&(s=o.hash)}else s=t.hash;let i=e.slice().sort((o,f)=>o.name<f.name?-1:o.name>f.name?1:0);if(!s&&i.length>0){let o=bn(i);o&&(s=o.hash,a=o.name)}s&&n.push({name:"HEAD",hash:s});for(let o of i)if(n.push({name:o.name,hash:o.hash}),o.name.startsWith("refs/tags/"))try{let f=await r.objectStore.read(o.hash);if(f.type==="tag"){let c=X(f.content);n.push({name:`${o.name}^{}`,hash:c.object})}}catch{}return{refs:n,headTarget:a}}var yn=["refs/heads/main","refs/heads/master"];function bn(r){for(let t of yn){let n=r.find(s=>s.name===t);if(n)return n}return r.find(t=>t.name.startsWith("refs/heads/"))??null}function tt(r,e,t){return rr(r,e,e==="git-upload-pack"?fr:lr,t)}function rt(r,e,t){return Le(r,e==="git-upload-pack"?fr:lr,t)}async function _(r,e,t,n,s){let{refs:a,headTarget:i}=await dr(r),o=a;if(n?.advertiseRefs){let f=await n.advertiseRefs({repo:r,repoId:e,refs:a,service:t,session:s});if(I(f))return f;f&&(o=f)}return{refs:o,headTarget:i}}async function be(r,e,t){let{wants:n,haves:s,capabilities:a,clientShallows:i,depth:o,done:f}=nr(e);if(n.length===0)return he(new Uint8Array(0),!1);let c=a.includes("multi_ack_detailed"),l=a.includes("side-band-64k"),d,p,h;if(i.length>0&&(h=new Set(i)),o!==void 0){let R=await Ke(r,n,o,h??new Set);d=R,p=new Set(R.shallow)}if(d&&!f)return sr(d);let u;if(c&&s.length>0){u=[];for(let R of s)await r.objectStore.exists(R)&&u.push(R);u.length===0&&(u=void 0)}let m=!p&&t?.cache&&t.cacheKey?Q.key(t.cacheKey,n,s):null;if(m&&t?.cache){let R=t.cache.get(m);if(R)return he(R.packData,l,u)}let x=a.includes("include-tag"),y={repo:r,wants:n,haves:s,includeTag:x,shallowBoundary:p,clientShallowBoundary:h,cache:t?.cache,cacheKey:m,deltaWindow:t?.deltaWindow};if(t?.noDelta){let R=await hr(y);if(!R){let{data:E}=await K([]);return he(E,l,u,d)}return yr(ar(R,l,u,d))}let b=await ur(y);return he(b,l,u,d)}async function pr(r,e){let t=[],n=await r.refStore.listRefs("refs/tags");for(let s of n)if(!e.has(s.hash))try{let a=await r.objectStore.read(s.hash);if(a.type==="tag"){let i=X(a.content);e.has(i.object)&&(t.push({hash:s.hash,type:"tag",content:a.content}),e.add(s.hash))}}catch{}return t}async function ur(r){let{repo:e,wants:t,haves:n,includeTag:s,shallowBoundary:a,clientShallowBoundary:i}=r,o=await Jt(e,t,n,a,i);if(o.count===0){let{data:u}=await K([]);return u}let f=await Qt(o),c=new Set(f.map(u=>u.hash));if(s){let u=await pr(e,c);f.push(...u)}let l=r.deltaWindow?{window:r.deltaWindow}:void 0,d=Zt(f,l),p=d.map(u=>({hash:u.hash,type:u.type,content:u.content,delta:u.delta,deltaBaseHash:u.deltaBase})),{data:h}=await K(p);if(r.cacheKey&&r.cache){let u=d.filter(m=>m.delta).length;r.cache.set(r.cacheKey,{packData:h,objectCount:f.length,deltaCount:u})}return h}async function hr(r){let{repo:e,wants:t,haves:n,includeTag:s,shallowBoundary:a,clientShallowBoundary:i}=r,{count:o,objects:f}=await ue(e,t,n,a,i);if(o===0)return null;let c=[];for await(let u of f)c.push(u);let l=new Set(c.map(u=>u.hash)),d=s?await pr(e,l):[],p=c.length+d.length;async function*h(){for(let u of c){let m=await e.objectStore.read(u.hash);yield{type:m.type,content:m.content}}for(let u of d)yield{type:u.type,content:u.content}}return Ft(p,h())}function yr(r){let e=r[Symbol.asyncIterator]();return new ReadableStream({async pull(t){let{value:n,done:s}=await e.next();s?t.close():t.enqueue(n)}})}async function nt(r,e){let{commands:t,packData:n,capabilities:s,sawFlush:a}=or(e),i=!0;if(n.byteLength>0)try{await r.objectStore.ingestPack(n)}catch{i=!1}return{updates:await br(r,t,i),unpackOk:i,capabilities:s,sawFlush:a}}async function st(r,e,t,n,s=!0){let a=!0;if(e.some(f=>f.newHash!==re))try{let c=_t(n,async l=>{try{return await r.objectStore.read(l)}catch{return null}});await r.objectStore.ingestPackStream(c)}catch{a=!1}return{updates:await br(r,e,a),unpackOk:a,capabilities:t,sawFlush:s}}async function br(r,e,t){let n=[];for(let s of e){let a=s.oldHash===re,i=s.newHash===re,o=!1;if(!a&&!i&&t)try{o=await Ve(r,s.oldHash,s.newHash)}catch{}n.push({ref:s.refName,oldHash:a?null:s.oldHash,newHash:s.newHash,isFF:o,isCreate:a,isDelete:i})}return n}async function ee(r){let{repo:e,repoId:t,ingestResult:n,hooks:s,session:a}=r,{updates:i}=n;if(s?.preReceive){let c=await s.preReceive({repo:e,repoId:t,updates:i,session:a});if(I(c)){let l=c.message??"pre-receive hook declined";return{refResults:i.map(d=>({ref:d.ref,ok:!1,error:l})),applied:[]}}}let o=[],f=[];for(let c of i){if(c.ref==="HEAD"){o.push({ref:c.ref,ok:!1,error:"HEAD cannot be updated via push"});continue}if(!c.isDelete&&!Vt(c.ref)){o.push({ref:c.ref,ok:!1,error:"invalid refname"});continue}if(s?.update){let l=await s.update({repo:e,repoId:t,update:c,session:a});if(I(l)){o.push({ref:c.ref,ok:!1,error:l.message??"update hook declined"});continue}}if(!c.isDelete&&!await e.objectStore.exists(c.newHash)){o.push({ref:c.ref,ok:!1,error:"missing objects"});continue}try{let l=c.isCreate?null:c.oldHash,d=c.isDelete?null:{type:"direct",hash:c.newHash};if(!await e.refStore.compareAndSwapRef(c.ref,l,d)){o.push({ref:c.ref,ok:!1,error:"failed to lock"});continue}o.push({ref:c.ref,ok:!0}),f.push(c)}catch(l){o.push({ref:c.ref,ok:!1,error:l instanceof Error?l.message:String(l)})}}if(s?.postReceive&&f.length>0)try{await s.postReceive({repo:e,repoId:t,updates:f,session:a})}catch{}return{refResults:o,applied:f}}async function at(r,e){let t=[];for(let n of e){let s;n.oldHash!==void 0?s=n.oldHash:s=await Ge(r,n.ref);let a=s===null,i=n.newHash===null,o=n.newHash??re,f=!1;if(!a&&!i)try{f=await Ve(r,s,o)}catch{}t.push({ref:n.ref,oldHash:s,newHash:o,isFF:f,isCreate:a,isDelete:i})}return t}var mn=["agent=just-git/1.0","ls-refs=unborn","fetch=shallow","server-option","object-format=sha1"];function me(){return Ze(mn)}async function ge(r,e,t,n,s){let a=t.includes("symrefs"),i=t.includes("peel"),o=t.includes("unborn"),f=t.filter(h=>h.startsWith("ref-prefix ")).map(h=>h.slice(11)),c=await _(r,e,"git-upload-pack",n,s);if(I(c))return c;let{refs:l,headTarget:d}=c,p=[];for(let h of l){if(h.name.endsWith("^{}")||f.length>0&&!f.some(m=>h.name.startsWith(m)))continue;let u={hash:h.hash,name:h.name};if(a&&h.name==="HEAD"&&d&&(u.symrefTarget=d),i&&h.name.startsWith("refs/tags/")){let m=l.find(x=>x.name===`${h.name}^{}`);m&&(u.peeledHash=m.hash)}p.push(u)}return o&&!p.some(h=>h.name==="HEAD")&&d&&(f.length===0||f.some(u=>"HEAD".startsWith(u)))&&p.unshift({hash:"unborn",name:"HEAD",symrefTarget:d}),Qe(p)}async function we(r,e,t){let{wants:n,haves:s,done:a,clientShallows:i,depth:o,includeTag:f,wantRefs:c}=et(e);if(n.length===0&&c.length===0){let{data:w}=await K([]);return J(w)}let l=[],d=[...n];for(let w of c){let g=await Ge(r,w);g&&(l.push({hash:g,name:w}),d.includes(g)||d.push(g))}let p,h,u;if(i.length>0&&(u=new Set(i)),o!==void 0){let w=await Ke(r,d,o,u??new Set);p=w,h=new Set(w.shallow)}let m;if(s.length>0){m=[];for(let w of s)await r.objectStore.exists(w)&&m.push(w);m.length===0&&(m=void 0)}let x=m&&m.length>0;if(!a&&!x)return ir(m??[]);let y=!h&&t?.cache&&t.cacheKey?Q.key(t.cacheKey,d,s):null,b={commonHashes:m,shallowInfo:p,wantedRefs:l.length>0?l:void 0};if(y&&t?.cache){let w=t.cache.get(y);if(w)return J(w.packData,b)}let R={repo:r,wants:d,haves:s,includeTag:f,shallowBoundary:h,clientShallowBoundary:u,cache:t?.cache,cacheKey:y,deltaWindow:t?.deltaWindow};if(t?.noDelta){let w=await hr(R);if(!w){let{data:g}=await K([]);return J(g,b)}return yr(cr(w,b))}let E=await ur(R);return J(E,b)}function gn(r){let e=/--protocol=version=2/.test(r),n=r.replace(/\s*--protocol=version=\d+/g,"").match(/^git[\s-](upload-pack|receive-pack)\s+'?([^']+?)'?\s*$/);if(!n)return null;let s=`git-${n[1]}`,a=n[2];return a.startsWith("/")&&(a=a.slice(1)),e?{service:s,repoPath:a,protocolV2:e}:{service:s,repoPath:a}}var wn=new TextEncoder;async function gr(r,e,t){let{resolveRepo:n,hooks:s,packCache:a,packOptions:i,session:o}=t,f=e.writable.getWriter();try{let c=gn(r);if(!c)return Re(e,`fatal: unrecognized command '${r}'
|
|
57
|
+
`),128;let{service:l,repoPath:d}=c,p=await n(d);if(!p)return Re(e,`fatal: '${d}' does not appear to be a git repository
|
|
58
|
+
`),128;let{repo:h,repoId:u}=p;if(c.protocolV2&&l==="git-upload-pack"){let y=await _(h,u,l,s,o);if(I(y))return Re(e,`fatal: ${y.message??"access denied"}
|
|
59
|
+
`),128;await f.write(me());let b=new Ce(e.readable);try{await En(b,f,h,u,{hooks:s,packCache:a,packOptions:i,session:o})}finally{b.release()}return 0}let m=await _(h,u,l,s,o);if(I(m))return Re(e,`fatal: ${m.message??"access denied"}
|
|
60
|
+
`),128;await f.write(rt(m.refs,l,m.headTarget));let x=new Ce(e.readable);try{if(l==="git-upload-pack"){let y=await xn(x),b=await be(h,y,{cache:a,cacheKey:u,noDelta:i?.noDelta,deltaWindow:i?.deltaWindow});await wr(f,b)}else{let{commands:y,capabilities:b}=await On(x),R=x.streamRemaining();await Rn({writer:f,repo:h,repoId:u,commands:y,capabilities:b,packStream:R,hooks:s,session:o})}}finally{x.release()}return 0}catch(c){return t.onError?.(c),Re(e,`fatal: internal error
|
|
61
|
+
`),128}finally{try{await f.close()}catch{}}}async function Rn(r){let{writer:e,repo:t,repoId:n,commands:s,capabilities:a,packStream:i,hooks:o,session:f}=r,c=await st(t,s,a,i);if(c.updates.length===0)return;let l=c.capabilities.includes("side-band-64k"),d=c.capabilities.includes("report-status");if(!c.unpackOk){if(d){let h=c.updates.map(u=>({name:u.ref,ok:!1,error:"unpack failed"}));await e.write(Z(!1,h,l))}return}let{refResults:p}=await ee({repo:t,repoId:n,ingestResult:c,hooks:o,session:f});if(d){let h=p.map(u=>({name:u.ref,ok:u.ok,error:u.error}));await e.write(Z(!0,h,l))}}function Re(r,e){r.writeStderr?.(wn.encode(e))}var mr=new TextDecoder,Ce=class{buf=new Uint8Array(0);byteReader;eof=!1;constructor(e){this.byteReader=e.getReader()}async fill(e){for(;this.buf.byteLength<e&&!this.eof;){let t=await this.byteReader.read();if(t.done||!t.value){this.eof=!0;break}let n=t.value,s=new Uint8Array(this.buf.byteLength+n.byteLength);s.set(this.buf),s.set(n,this.buf.byteLength),this.buf=s}return this.buf.byteLength>=e}consume(e){let t=this.buf.subarray(0,e);return this.buf=this.buf.subarray(e),t}async readPktLine(){if(!await this.fill(4))return null;let e=mr.decode(this.buf.subarray(0,4)),t=parseInt(e,16);if(t===0)return{type:"flush",raw:this.consume(4)};if(t===1)return{type:"delim",raw:this.consume(4)};if(t===2)return{type:"response-end",raw:this.consume(4)};if(t<4||!await this.fill(t))return null;let n=new Uint8Array(this.consume(t));return{type:"data",raw:n,text:mr.decode(n.subarray(4))}}async*streamRemaining(){for(this.buf.byteLength>0&&(yield this.consume(this.buf.byteLength));!this.eof;){let e=await this.byteReader.read();if(e.done||!e.value){this.eof=!0;break}yield e.value}}release(){this.byteReader.releaseLock()}};async function xn(r){let e=[];for(;;){let t=await r.readPktLine();if(!t||(e.push(t.raw),t.type==="data"&&t.text.trimEnd()==="done"))break}return Pn(e)}async function On(r){let e=[],t=[],n=!0;for(;;){let s=await r.readPktLine();if(!s||s.type==="flush")break;if(s.type!=="data")continue;let a=s.text;if(a.endsWith(`
|
|
62
|
+
`)&&(a=a.slice(0,-1)),n){let o=a.indexOf("\0");o!==-1&&(t=a.slice(o+1).split(" ").filter(Boolean),a=a.slice(0,o)),n=!1}let i=a.split(" ");i.length>=3&&e.push({oldHash:i[0],newHash:i[1],refName:i[2]})}return{commands:e,capabilities:t}}async function En(r,e,t,n,s){let{hooks:a,packCache:i,packOptions:o,session:f}=s;for(;;){let c=await kn(r);if(!c)break;if(c.command==="ls-refs"){let l=await ge(t,n,c.args,a,f);if(I(l))break;await e.write(l)}else if(c.command==="fetch"){let l=await we(t,c.args,{cache:i,cacheKey:n,noDelta:o?.noDelta,deltaWindow:o?.deltaWindow});await wr(e,l)}else break}}async function kn(r){let e="",t=[],n=[],s=!1,a=!1;for(;;){let i=await r.readPktLine();if(!i)return a?{command:e,capabilities:t,args:n}:null;if(i.type==="flush"){if(!a)return null;break}if(i.type==="response-end")break;if(i.type==="delim"){s=!0;continue}a=!0;let o=i.text;o.endsWith(`
|
|
63
|
+
`)&&(o=o.slice(0,-1)),s?n.push(o):o.startsWith("command=")?e=o.slice(8):t.push(o)}return e?{command:e,capabilities:t,args:n}:null}function Pn(r){if(r.length===0)return new Uint8Array(0);if(r.length===1)return r[0];let e=0;for(let s of r)e+=s.byteLength;let t=new Uint8Array(e),n=0;for(let s of r)t.set(s,n),n+=s.byteLength;return t}async function wr(r,e){if(e instanceof ReadableStream){let t=e.getReader();try{for(;;){let{value:n,done:s}=await t.read();if(s)break;await r.write(n)}}finally{t.releaseLock()}}else await r.write(e)}async function xr(r,e,t,n){let s=n?.dryRun??!1,a=await Rr(r),i=vn(a);if(i.length===0)return{deleted:0,retained:0};let o=await ue(r,i,[]),f=new Set;for await(let h of o.objects)f.add(h.hash);let c=await e.listObjectHashes(t),l=[];for(let h of c)f.has(h)||l.push(h);let d=await Rr(r);return Sn(a,d)?s||l.length===0?{deleted:l.length,retained:f.size}:{deleted:await e.deleteObjects(t,l),retained:f.size}:{deleted:0,retained:f.size,aborted:!0}}async function Rr(r){return r.refStore.listRefs()}function vn(r){let e=new Set;for(let t of r)e.add(t.hash);return Array.from(e)}function Sn(r,e){if(r.length!==e.length)return!1;let t=new Map;for(let n of r)t.set(n.name,n.hash);for(let n of e)if(t.get(n.name)!==n.hash)return!1;return!0}function Or(r){function e(t){return{objectStore:new ot(r,t),refStore:new it(r,t)}}return{async createRepo(t,n){if(await r.hasRepo(t))throw new Error(`repo '${t}' already exists`);let a=n?.defaultBranch??"main";return await r.insertRepo(t),await r.putRef(t,"HEAD",{type:"symbolic",target:`refs/heads/${a}`}),e(t)},async repo(t){return await r.hasRepo(t)?e(t):null},async deleteRepo(t){await r.deleteRepo(t)}}}var ot=class{constructor(e,t){this.driver=e;this.repoId=t}cache=new ve;async write(e,t){let n=Gt(e,t),s=await Ot(n);return await this.driver.putObject(this.repoId,s,e,t),s}async read(e){let t=this.cache.get(e);if(t)return t;let n=await this.driver.getObject(this.repoId,e);if(!n)throw new Error(`object ${e} not found`);return this.cache.set(e,n),n}async exists(e){return!!await this.driver.hasObject(this.repoId,e)}async ingestPack(e){if(e.byteLength<32)return 0;let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=t.getUint32(0);if(n!==1346454347)throw new Error(`invalid pack signature: 0x${n.toString(16)} (expected 0x5041434b)`);let s=t.getUint32(4);if(s!==2)throw new Error(`unsupported pack version: ${s}`);if(t.getUint32(8)===0)return 0;let i=this.driver,o=this.repoId,f=await Wt(e,async c=>{let l=await i.getObject(o,c);return l?{type:l.type,content:new Uint8Array(l.content)}:null});return await i.putObjects(o,f.map(c=>({hash:c.hash,type:c.type,content:c.content}))),f.length}async ingestPackStream(e){let t=[];for await(let n of e)t.push({hash:n.hash,type:n.type,content:n.content});return t.length===0?0:(await this.driver.putObjects(this.repoId,t),t.length)}async findByPrefix(e){return e.length<4?[]:Array.from(await this.driver.findObjectsByPrefix(this.repoId,e))}},it=class{constructor(e,t){this.driver=e;this.repoId=t}async readRef(e){return await this.driver.getRef(this.repoId,e)??null}async writeRef(e,t){await this.driver.putRef(this.repoId,e,qt(t))}async deleteRef(e){await this.driver.removeRef(this.repoId,e)}async listRefs(e){let t=await this.driver.listRefs(this.repoId,e),n=[];for(let s of t)if(s.ref.type==="direct")n.push({name:s.name,hash:s.ref.hash});else if(s.ref.type==="symbolic"){let a=await ct(i=>this.driver.getRef(this.repoId,i),s.ref.target);a&&n.push({name:s.name,hash:a})}return n}async compareAndSwapRef(e,t,n){return!!await this.driver.atomicRefUpdate(this.repoId,s=>xe(s.getRef(e),a=>{let i=a?a.type==="direct"?a.hash:ct(o=>s.getRef(o),a.target):null;return xe(i,o=>{if(t===null){if(a!==null)return!1}else if(o!==t)return!1;return n===null?xe(s.removeRef(e),()=>!0):xe(s.putRef(e,n),()=>!0)})}))}};function xe(r,e){return r instanceof Promise?r.then(e):e(r)}function ct(r,e,t=0){return t>10?null:xe(r(e),n=>n?n.type==="direct"?n.hash:n.type==="symbolic"?ct(r,n.target,t+1):null:null)}var An={http:r=>({transport:"http",request:r}),ssh:r=>({transport:"ssh",username:r.username})};function Er(r){if(r.length===0)return!1;for(let t=0;t<r.length;t++){let n=r.charCodeAt(t);if(n===0||n<32||n===127||n===92)return!1}let e=r.split("/");for(let t of e)if(t.length===0||t.charCodeAt(0)===46)return!1;return!0}function jn(r){if(!r||!r.storage)throw new TypeError("createServer: config.storage is required. Example: createServer({ storage: new MemoryStorage() })");let e=Or(r.storage),t=r.resolve??(y=>y),n=r.autoCreate,{basePath:s}=r;async function a(y){if(!Er(y))return null;let b=await t(y);if(b==null||b!==y&&!Er(b))return null;let R=await e.repo(b);if(R)return{repo:R,repoId:b};if(!n)return null;let E=typeof n=="object"?{defaultBranch:n.defaultBranch}:void 0;return{repo:await e.createRepo(b,E),repoId:b}}let i=Un(r.policy,r.hooks),o=r.session??An,f=r.packCache===!1?void 0:new Q(r.packCache?.maxBytes),c=r.onError===!1?void 0:r.onError??(y=>{let b=y instanceof Error?y.message:String(y);console.error(`[server] Internal error: ${b}`)}),l=!1,d=0,p=null,h=null;function u(){return l?!1:(d++,!0)}function m(){d--,l&&d===0&&p?.()}let x={async fetch(y){if(!u())return new Response("Service Unavailable",{status:503});let b;try{if(!o.http)return new Response("HTTP session builder not configured",{status:501});let R=await o.http(y);if(R instanceof Response)return R;b=R;let E=new URL(y.url),w=decodeURIComponent(E.pathname);if(s){let g=s.replace(/\/+$/,"");if(!w.startsWith(g))return new Response("Not Found",{status:404});w=w.slice(g.length)}if(w.startsWith("/")||(w=`/${w}`),w.endsWith("/info/refs")&&y.method==="GET"){let g=E.searchParams.get("service");if(g!=="git-upload-pack"&&g!=="git-receive-pack")return new Response("Unsupported service",{status:403});let k=ft(w,"/info/refs"),v=await a(k);if(!v)return new Response("Not Found",{status:404});if(kr(y)&&g==="git-upload-pack"){let S=await _(v.repo,v.repoId,g,i,b);if(I(S))return new Response(S.message??"Forbidden",{status:403});let H=me();return new Response(H,{headers:{"Content-Type":`application/x-${g}-advertisement`,"Cache-Control":"no-cache"}})}let P=await _(v.repo,v.repoId,g,i,b);if(I(P))return new Response(P.message??"Forbidden",{status:403});let C=tt(P.refs,g,P.headTarget);return new Response(C,{headers:{"Content-Type":`application/x-${g}-advertisement`,"Cache-Control":"no-cache"}})}if(w.endsWith("/git-upload-pack")&&y.method==="POST"){let g=ft(w,"/git-upload-pack"),k=await a(g);if(!k)return new Response("Not Found",{status:404});let v=await Pr(y);if(kr(y)){let P=Je(v),C="application/x-git-upload-pack-result";if(P.command==="ls-refs"){let S=await ge(k.repo,k.repoId,P.args,i,b);return I(S)?new Response(S.message??"Forbidden",{status:403}):new Response(S,{headers:{"Content-Type":C}})}if(P.command==="fetch"){let S=await we(k.repo,P.args,{cache:f,cacheKey:k.repoId,noDelta:r.packOptions?.noDelta,deltaWindow:r.packOptions?.deltaWindow});return new Response(S,{headers:{"Content-Type":C}})}return new Response(`unknown command: ${P.command}`,{status:400})}let j=await be(k.repo,v,{cache:f,cacheKey:k.repoId,noDelta:r.packOptions?.noDelta,deltaWindow:r.packOptions?.deltaWindow});return new Response(j,{headers:{"Content-Type":"application/x-git-upload-pack-result"}})}if(w.endsWith("/git-receive-pack")&&y.method==="POST"){let g=ft(w,"/git-receive-pack"),k=await a(g);if(!k)return new Response("Not Found",{status:404});let v=await Pr(y),j=await nt(k.repo,v);if(!j.sawFlush&&j.updates.length===0)return new Response("Bad Request",{status:400});let P=j.capabilities.includes("side-band-64k"),C=j.capabilities.includes("report-status");if(!j.unpackOk){if(C){let H=j.updates.map($=>({name:$.ref,ok:!1,error:"unpack failed"}));return new Response(Z(!1,H,P),{headers:{"Content-Type":"application/x-git-receive-pack-result"}})}return new Response(new Uint8Array(0),{headers:{"Content-Type":"application/x-git-receive-pack-result"}})}let{refResults:S}=await ee({repo:k.repo,repoId:k.repoId,ingestResult:j,hooks:i,session:b});if(C){let H=S.map($=>({name:$.ref,ok:$.ok,error:$.error}));return new Response(Z(!0,H,P),{headers:{"Content-Type":"application/x-git-receive-pack-result"}})}return new Response(new Uint8Array(0),{headers:{"Content-Type":"application/x-git-receive-pack-result"}})}return new Response("Not Found",{status:404})}catch(R){return c?.(R,b),new Response("Internal Server Error",{status:500})}finally{m()}},async handleSession(y,b,R){if(!u())return b.writeStderr?.(new TextEncoder().encode(`fatal: server shutting down
|
|
64
|
+
`)),128;try{if(!o.ssh)return b.writeStderr?.(new TextEncoder().encode(`fatal: SSH session builder not configured
|
|
65
|
+
`)),128;let E=await o.ssh(R??{});return await gr(y,b,{resolveRepo:a,hooks:i,packCache:f,packOptions:r.packOptions,session:E,onError:c?w=>c(w,E):void 0})}finally{m()}},async updateRefs(y,b,R){if(!u())throw new Error("Server is shutting down");try{let E=await x.requireRepo(y),w=await at(E,b);return ee({repo:E,repoId:y,ingestResult:{updates:w,unpackOk:!0,capabilities:[],sawFlush:!0},hooks:i,session:R})}finally{m()}},nodeHandler(y,b){let R=[];y.on("data",E=>R.push(new Uint8Array(E))),y.on("error",()=>{b.writeHead(500),b.end("Internal Server Error")}),y.on("end",()=>{In(x,y,R,b).catch(()=>{try{b.writeHead(500),b.end("Internal Server Error")}catch{}})})},createRepo:(y,b)=>e.createRepo(y,b),repo:y=>e.repo(y),async requireRepo(y){let b=await e.repo(y);if(!b)throw new Error(`Repository "${y}" not found`);return b},deleteRepo:y=>e.deleteRepo(y),async gc(y,b){if(!u())throw new Error("Server is shutting down");try{let R=await x.requireRepo(y);return xr(R,r.storage,y,b)}finally{m()}},get closed(){return l},asNetwork(y="http://git"){return{allowed:[y.endsWith("/")?y:`${y}/`],fetch:(R,E)=>x.fetch(new Request(R,E))}},async close(y){if(l)return h??Promise.resolve();if(l=!0,f?.clear(),d!==0){if(h=new Promise(b=>{p=b}),y?.signal){if(y.signal.aborted){p();return}let b=()=>p?.();y.signal.addEventListener("abort",b,{once:!0}),h.then(()=>y.signal.removeEventListener("abort",b))}return h}}};return x}function kr(r){let e=r.headers.get("git-protocol");return e!==null&&e.includes("version=2")}function ft(r,e){let t=r.slice(0,-e.length);return t.startsWith("/")&&(t=t.slice(1)),t}async function Pr(r){let e=new Uint8Array(await r.arrayBuffer()),t=r.headers.get("content-encoding");if(t==="gzip"||t==="x-gzip"){let n=new DecompressionStream("gzip"),s=n.writable.getWriter();return s.write(e),s.close(),new Uint8Array(await new Response(n.readable).arrayBuffer())}return e}async function In(r,e,t,n){let s=typeof e.headers.host=="string"?e.headers.host:"localhost",a=new URL(e.url??"/",`http://${s}`),i=new Headers;for(let[h,u]of Object.entries(e.headers))if(u!==void 0)if(Array.isArray(u))for(let m of u)i.append(h,m);else i.set(h,u);let o=e.method??"GET",f;if(o!=="GET"&&o!=="HEAD"){let h=0;for(let x of t)h+=x.byteLength;let u=new Uint8Array(h),m=0;for(let x of t)u.set(x,m),m+=x.byteLength;f=u}let c=new Request(a.href,{method:o,headers:i,body:f}),l=await r.fetch(c),d={};l.headers.forEach((h,u)=>{d[u]=h}),n.writeHead(l.status,d);let p=new Uint8Array(await l.arrayBuffer());p.byteLength>0&&n.write(p),n.end()}function Tn(r){let{protectedBranches:e=[],denyNonFastForward:t=!1,denyDeletes:n=!1,immutableTags:s=!1}=r,a=new Set(e.map(o=>o.startsWith("refs/")?o:`refs/heads/${o}`)),i={};return a.size>0&&(i.preReceive=async o=>{for(let f of o.updates)if(a.has(f.ref)){if(f.isDelete)return{reject:!0,message:`cannot delete protected branch ${f.ref}`};if(!f.isCreate&&!f.isFF)return{reject:!0,message:`non-fast-forward push to protected branch ${f.ref}`}}}),(t||n||s)&&(i.update=async o=>{if(n&&o.update.isDelete)return{reject:!0,message:"ref deletion denied"};if(s&&o.update.ref.startsWith("refs/tags/")){if(o.update.isDelete)return{reject:!0,message:"tag deletion denied"};if(!o.update.isCreate)return{reject:!0,message:"tag overwrite denied"}}if(t&&!o.update.isCreate&&!o.update.isDelete&&!o.update.isFF)return{reject:!0,message:"non-fast-forward"}}),i}function Un(r,e){let t=r?Tn(r):void 0;return t&&e?vr(t,e):t??e}function vr(...r){let e=r.filter(o=>o!=null);if(e.length===0)return{};if(e.length===1)return e[0];let t={},n=e.filter(o=>o.preReceive).map(o=>o.preReceive);n.length>0&&(t.preReceive=async o=>{for(let f of n){let c=await f(o);if(I(c))return c}});let s=e.filter(o=>o.update).map(o=>o.update);s.length>0&&(t.update=async o=>{for(let f of s){let c=await f(o);if(I(c))return c}});let a=e.filter(o=>o.postReceive).map(o=>o.postReceive);a.length>0&&(t.postReceive=async o=>{for(let f of a)try{await f(o)}catch{}});let i=e.filter(o=>o.advertiseRefs).map(o=>o.advertiseRefs);return i.length>0&&(t.advertiseRefs=async o=>{let f=o.refs;for(let c of i){let l=await c({...o,refs:f});if(I(l))return l;l&&(f=l)}return f}),t}var lt=class{repos=new Set;objects=new Map;refs=new Map;hasRepo(e){return this.repos.has(e)}insertRepo(e){this.repos.add(e)}deleteRepo(e){this.repos.delete(e),this.objects.get(e)?.clear(),this.objects.delete(e),this.refs.get(e)?.clear(),this.refs.delete(e)}getObject(e,t){let n=this.getObjMap(e).get(t);return n?{type:n.type,content:new Uint8Array(n.content)}:null}putObject(e,t,n,s){let a=this.getObjMap(e);a.has(t)||a.set(t,{type:n,content:new Uint8Array(s)})}putObjects(e,t){let n=this.getObjMap(e);for(let s of t)n.has(s.hash)||n.set(s.hash,{type:s.type,content:new Uint8Array(s.content)})}hasObject(e,t){return this.getObjMap(e).has(t)}findObjectsByPrefix(e,t){let n=[];for(let s of this.getObjMap(e).keys())s.startsWith(t)&&n.push(s);return n}listObjectHashes(e){return Array.from(this.getObjMap(e).keys())}deleteObjects(e,t){let n=this.getObjMap(e),s=0;for(let a of t)n.delete(a)&&s++;return s}getRef(e,t){return this.getRefMap(e).get(t)??null}putRef(e,t,n){this.getRefMap(e).set(t,n)}removeRef(e,t){this.getRefMap(e).delete(t)}listRefs(e,t){let n=[];for(let[s,a]of this.getRefMap(e))t&&!s.startsWith(t)||n.push({name:s,ref:a});return n}atomicRefUpdate(e,t){let n=this.getRefMap(e);return t({getRef:s=>n.get(s)??null,putRef:(s,a)=>{n.set(s,a)},removeRef:s=>{n.delete(s)}})}repoIds(){return Array.from(this.repos)}getObjMap(e){let t=this.objects.get(e);return t||(t=new Map,this.objects.set(e,t)),t}getRefMap(e){let t=this.refs.get(e);return t||(t=new Map,this.refs.set(e,t)),t}};var Ln=`
|
|
39
66
|
CREATE TABLE IF NOT EXISTS repos (
|
|
40
67
|
id TEXT PRIMARY KEY
|
|
41
68
|
);
|
|
@@ -56,7 +83,7 @@ CREATE TABLE IF NOT EXISTS git_refs (
|
|
|
56
83
|
target TEXT,
|
|
57
84
|
PRIMARY KEY (repo_id, name)
|
|
58
85
|
) WITHOUT ROWID;
|
|
59
|
-
`;function
|
|
86
|
+
`;function Cn(r){return{repoInsert:r.prepare("INSERT INTO repos (id) VALUES (?)"),repoExists:r.prepare("SELECT 1 FROM repos WHERE id = ? LIMIT 1"),repoDelete:r.prepare("DELETE FROM repos WHERE id = ?"),objInsert:r.prepare("INSERT OR IGNORE INTO git_objects (repo_id, hash, type, content) VALUES (?, ?, ?, ?)"),objRead:r.prepare("SELECT type, content FROM git_objects WHERE repo_id = ? AND hash = ?"),objExists:r.prepare("SELECT 1 FROM git_objects WHERE repo_id = ? AND hash = ? LIMIT 1"),objPrefix:r.prepare("SELECT hash FROM git_objects WHERE repo_id = ? AND hash GLOB ?"),objDeleteAll:r.prepare("DELETE FROM git_objects WHERE repo_id = ?"),objListHashes:r.prepare("SELECT hash FROM git_objects WHERE repo_id = ?"),objDelete:r.prepare("DELETE FROM git_objects WHERE repo_id = ? AND hash = ?"),refRead:r.prepare("SELECT type, hash, target FROM git_refs WHERE repo_id = ? AND name = ?"),refWrite:r.prepare("INSERT OR REPLACE INTO git_refs (repo_id, name, type, hash, target) VALUES (?, ?, ?, ?, ?)"),refDelete:r.prepare("DELETE FROM git_refs WHERE repo_id = ? AND name = ?"),refList:r.prepare("SELECT name, type, hash, target FROM git_refs WHERE repo_id = ? AND name GLOB ?"),refListAll:r.prepare("SELECT name, type, hash, target FROM git_refs WHERE repo_id = ?"),refDeleteAll:r.prepare("DELETE FROM git_refs WHERE repo_id = ?")}}var pt=class{constructor(e){this.db=e;e.run(Ln),this.stmts=Cn(e),this.batchInsertTx=e.transaction(t=>{for(let n of t)this.stmts.objInsert.run(n.repoId,n.hash,n.type,n.content)}),this.batchDeleteTx=e.transaction((t,n,s)=>{let a=0;for(let i of n)this.stmts.objDelete.run(t,i),a++;s(a)})}stmts;batchInsertTx;batchDeleteTx;hasRepo(e){return this.stmts.repoExists.get(e)!==null}insertRepo(e){this.stmts.repoInsert.run(e)}deleteRepo(e){this.stmts.repoDelete.run(e),this.stmts.objDeleteAll.run(e),this.stmts.refDeleteAll.run(e)}getObject(e,t){let n=this.stmts.objRead.get(e,t);return n?{type:n.type,content:new Uint8Array(n.content)}:null}putObject(e,t,n,s){this.stmts.objInsert.run(e,t,n,s)}putObjects(e,t){this.batchInsertTx(t.map(n=>({repoId:e,...n})))}hasObject(e,t){return this.stmts.objExists.get(e,t)!==null}findObjectsByPrefix(e,t){return this.stmts.objPrefix.all(e,`${t}*`).map(s=>s.hash)}listObjectHashes(e){return this.stmts.objListHashes.all(e).map(n=>n.hash)}deleteObjects(e,t){if(t.length===0)return 0;let n=0;return this.batchDeleteTx(e,t,s=>{n+=s}),n}getRef(e,t){let n=this.stmts.refRead.get(e,t);return dt(n)}putRef(e,t,n){n.type==="symbolic"?this.stmts.refWrite.run(e,t,"symbolic",null,n.target):this.stmts.refWrite.run(e,t,"direct",n.hash,null)}removeRef(e,t){this.stmts.refDelete.run(e,t)}listRefs(e,t){return(t?this.stmts.refList.all(e,`${t}*`):this.stmts.refListAll.all(e)).flatMap(s=>{let a=dt(s);return a?[{name:s.name,ref:a}]:[]})}atomicRefUpdate(e,t){let n=this.stmts;return this.db.transaction(()=>t({getRef:a=>dt(n.refRead.get(e,a)),putRef:(a,i)=>{i.type==="symbolic"?n.refWrite.run(e,a,"symbolic",null,i.target):n.refWrite.run(e,a,"direct",i.hash,null)},removeRef:a=>{n.refDelete.run(e,a)}}))()}};function dt(r){return r?r.type==="symbolic"&&r.target?{type:"symbolic",target:r.target}:r.type==="direct"&&r.hash?{type:"direct",hash:r.hash}:null:null}var Hn=`
|
|
60
87
|
CREATE TABLE IF NOT EXISTS repos (
|
|
61
88
|
id TEXT PRIMARY KEY
|
|
62
89
|
);
|
|
@@ -77,7 +104,7 @@ CREATE TABLE IF NOT EXISTS git_refs (
|
|
|
77
104
|
target TEXT,
|
|
78
105
|
PRIMARY KEY (repo_id, name)
|
|
79
106
|
) WITHOUT ROWID;
|
|
80
|
-
`;function
|
|
107
|
+
`;function U(r){return{run:(...e)=>{r.run(...e)},get:(...e)=>r.get(...e)??null,all:(...e)=>r.all(...e)}}function Dn(r){return{repoInsert:U(r.prepare("INSERT INTO repos (id) VALUES (?)")),repoExists:U(r.prepare("SELECT 1 FROM repos WHERE id = ? LIMIT 1")),repoDelete:U(r.prepare("DELETE FROM repos WHERE id = ?")),objInsert:U(r.prepare("INSERT OR IGNORE INTO git_objects (repo_id, hash, type, content) VALUES (?, ?, ?, ?)")),objRead:U(r.prepare("SELECT type, content FROM git_objects WHERE repo_id = ? AND hash = ?")),objExists:U(r.prepare("SELECT 1 FROM git_objects WHERE repo_id = ? AND hash = ? LIMIT 1")),objPrefix:U(r.prepare("SELECT hash FROM git_objects WHERE repo_id = ? AND hash GLOB ?")),objDeleteAll:U(r.prepare("DELETE FROM git_objects WHERE repo_id = ?")),objListHashes:U(r.prepare("SELECT hash FROM git_objects WHERE repo_id = ?")),objDelete:U(r.prepare("DELETE FROM git_objects WHERE repo_id = ? AND hash = ?")),refRead:U(r.prepare("SELECT type, hash, target FROM git_refs WHERE repo_id = ? AND name = ?")),refWrite:U(r.prepare("INSERT OR REPLACE INTO git_refs (repo_id, name, type, hash, target) VALUES (?, ?, ?, ?, ?)")),refDelete:U(r.prepare("DELETE FROM git_refs WHERE repo_id = ? AND name = ?")),refList:U(r.prepare("SELECT name, type, hash, target FROM git_refs WHERE repo_id = ? AND name GLOB ?")),refListAll:U(r.prepare("SELECT name, type, hash, target FROM git_refs WHERE repo_id = ?")),refDeleteAll:U(r.prepare("DELETE FROM git_refs WHERE repo_id = ?"))}}var ht=class{constructor(e){this.db=e;e.exec(Hn),this.stmts=Dn(e),this.batchInsertTx=e.transaction(t=>{for(let n of t)this.stmts.objInsert.run(n.repoId,n.hash,n.type,n.content)}),this.batchDeleteTx=e.transaction((t,n,s)=>{let a=0;for(let i of n)this.stmts.objDelete.run(t,i),a++;s(a)})}stmts;batchInsertTx;batchDeleteTx;hasRepo(e){return this.stmts.repoExists.get(e)!==null}insertRepo(e){this.stmts.repoInsert.run(e)}deleteRepo(e){this.stmts.repoDelete.run(e),this.stmts.objDeleteAll.run(e),this.stmts.refDeleteAll.run(e)}getObject(e,t){let n=this.stmts.objRead.get(e,t);return n?{type:n.type,content:new Uint8Array(n.content)}:null}putObject(e,t,n,s){this.stmts.objInsert.run(e,t,n,s)}putObjects(e,t){this.batchInsertTx(t.map(n=>({repoId:e,...n})))}hasObject(e,t){return this.stmts.objExists.get(e,t)!==null}findObjectsByPrefix(e,t){return this.stmts.objPrefix.all(e,`${t}*`).map(s=>s.hash)}listObjectHashes(e){return this.stmts.objListHashes.all(e).map(n=>n.hash)}deleteObjects(e,t){if(t.length===0)return 0;let n=0;return this.batchDeleteTx(e,t,s=>{n+=s}),n}getRef(e,t){let n=this.stmts.refRead.get(e,t);return ut(n)}putRef(e,t,n){n.type==="symbolic"?this.stmts.refWrite.run(e,t,"symbolic",null,n.target):this.stmts.refWrite.run(e,t,"direct",n.hash,null)}removeRef(e,t){this.stmts.refDelete.run(e,t)}listRefs(e,t){return(t?this.stmts.refList.all(e,`${t}*`):this.stmts.refListAll.all(e)).flatMap(s=>{let a=ut(s);return a?[{name:s.name,ref:a}]:[]})}atomicRefUpdate(e,t){let n=this.stmts;return this.db.transaction(()=>t({getRef:a=>ut(n.refRead.get(e,a)),putRef:(a,i)=>{i.type==="symbolic"?n.refWrite.run(e,a,"symbolic",null,i.target):n.refWrite.run(e,a,"direct",i.hash,null)},removeRef:a=>{n.refDelete.run(e,a)}}))()}};function ut(r){return r?r.type==="symbolic"&&r.target?{type:"symbolic",target:r.target}:r.type==="direct"&&r.hash?{type:"direct",hash:r.hash}:null:null}var Nn=`
|
|
81
108
|
CREATE TABLE IF NOT EXISTS repos (
|
|
82
109
|
id TEXT PRIMARY KEY
|
|
83
110
|
);
|
|
@@ -98,5 +125,5 @@ CREATE TABLE IF NOT EXISTS git_refs (
|
|
|
98
125
|
target TEXT,
|
|
99
126
|
PRIMARY KEY (repo_id, name)
|
|
100
127
|
);
|
|
101
|
-
`,
|
|
102
|
-
ON CONFLICT (repo_id, name) DO UPDATE SET type = EXCLUDED.type, hash = EXCLUDED.hash, target = EXCLUDED.target`,refDelete:"DELETE FROM git_refs WHERE repo_id = $1 AND name = $2",refList:"SELECT name, type, hash, target FROM git_refs WHERE repo_id = $1 AND name LIKE $2",refListAll:"SELECT name, type, hash, target FROM git_refs WHERE repo_id = $1",refDeleteAll:"DELETE FROM git_refs WHERE repo_id = $1"},
|
|
128
|
+
`,A={repoInsert:"INSERT INTO repos (id) VALUES ($1)",repoExists:"SELECT 1 FROM repos WHERE id = $1 LIMIT 1",repoDelete:"DELETE FROM repos WHERE id = $1",objInsert:"INSERT INTO git_objects (repo_id, hash, type, content) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING",objRead:"SELECT type, content FROM git_objects WHERE repo_id = $1 AND hash = $2",objExists:"SELECT 1 FROM git_objects WHERE repo_id = $1 AND hash = $2 LIMIT 1",objPrefix:"SELECT hash FROM git_objects WHERE repo_id = $1 AND hash LIKE $2",objDeleteAll:"DELETE FROM git_objects WHERE repo_id = $1",objListHashes:"SELECT hash FROM git_objects WHERE repo_id = $1",refRead:"SELECT type, hash, target FROM git_refs WHERE repo_id = $1 AND name = $2",refReadForUpdate:"SELECT type, hash, target FROM git_refs WHERE repo_id = $1 AND name = $2 FOR UPDATE",refWrite:`INSERT INTO git_refs (repo_id, name, type, hash, target) VALUES ($1, $2, $3, $4, $5)
|
|
129
|
+
ON CONFLICT (repo_id, name) DO UPDATE SET type = EXCLUDED.type, hash = EXCLUDED.hash, target = EXCLUDED.target`,refDelete:"DELETE FROM git_refs WHERE repo_id = $1 AND name = $2",refList:"SELECT name, type, hash, target FROM git_refs WHERE repo_id = $1 AND name LIKE $2",refListAll:"SELECT name, type, hash, target FROM git_refs WHERE repo_id = $1",refDeleteAll:"DELETE FROM git_refs WHERE repo_id = $1"},bt=class r{constructor(e){this.pool=e}static async create(e){return await e.query(Nn),new r(e)}async transaction(e){let t=await this.pool.connect();try{await t.query("BEGIN");let n=await e((s,a)=>t.query(s,a));return await t.query("COMMIT"),n}catch(n){throw await t.query("ROLLBACK"),n}finally{t.release()}}async hasRepo(e){let{rows:t}=await this.pool.query(A.repoExists,[e]);return t.length>0}async insertRepo(e){await this.pool.query(A.repoInsert,[e])}async deleteRepo(e){await this.pool.query(A.repoDelete,[e]),await this.pool.query(A.objDeleteAll,[e]),await this.pool.query(A.refDeleteAll,[e])}async getObject(e,t){let{rows:n}=await this.pool.query(A.objRead,[e,t]),s=n[0];return s?{type:s.type,content:new Uint8Array(s.content)}:null}async putObject(e,t,n,s){await this.pool.query(A.objInsert,[e,t,n,s])}async putObjects(e,t){await this.transaction(async n=>{for(let s of t)await n(A.objInsert,[e,s.hash,s.type,s.content])})}async hasObject(e,t){let{rows:n}=await this.pool.query(A.objExists,[e,t]);return n.length>0}async findObjectsByPrefix(e,t){let{rows:n}=await this.pool.query(A.objPrefix,[e,`${t}%`]);return n.map(s=>s.hash)}async listObjectHashes(e){let{rows:t}=await this.pool.query(A.objListHashes,[e]);return t.map(n=>n.hash)}async deleteObjects(e,t){if(t.length===0)return 0;let{rows:n}=await this.pool.query("DELETE FROM git_objects WHERE repo_id = $1 AND hash = ANY($2::text[]) RETURNING hash",[e,Array.from(t)]);return n.length}async getRef(e,t){let{rows:n}=await this.pool.query(A.refRead,[e,t]);return yt(n[0]??null)}async putRef(e,t,n){n.type==="symbolic"?await this.pool.query(A.refWrite,[e,t,"symbolic",null,n.target]):await this.pool.query(A.refWrite,[e,t,"direct",n.hash,null])}async removeRef(e,t){await this.pool.query(A.refDelete,[e,t])}async listRefs(e,t){let n;return t?{rows:n}=await this.pool.query(A.refList,[e,`${t}%`]):{rows:n}=await this.pool.query(A.refListAll,[e]),n.flatMap(s=>{let a=yt(s);return a?[{name:s.name,ref:a}]:[]})}async atomicRefUpdate(e,t){return this.transaction(async n=>t({getRef:async s=>{let{rows:a}=await n(A.refReadForUpdate,[e,s]);return yt(a[0]??null)},putRef:async(s,a)=>{a.type==="symbolic"?await n(A.refWrite,[e,s,"symbolic",null,a.target]):await n(A.refWrite,[e,s,"direct",a.hash,null])},removeRef:async s=>{await n(A.refDelete,[e,s])}}))}};function yt(r){return r?r.type==="symbolic"&&r.target?{type:"symbolic",target:r.target}:r.type==="direct"&&r.hash?{type:"direct",hash:r.hash}:null:null}export{ht as BetterSqlite3Storage,pt as BunSqliteStorage,lt as MemoryStorage,bt as PgStorage,_ as advertiseRefsWithHooks,ee as applyReceivePack,tt as buildRefAdvertisementBytes,rt as buildRefListBytes,Le as buildRefListPktLines,Ze as buildV2CapabilityAdvertisement,me as buildV2CapabilityAdvertisementBytes,J as buildV2FetchResponse,Qe as buildV2LsRefsResponse,dr as collectRefs,vr as composeHooks,jn as createServer,ge as handleLsRefs,be as handleUploadPack,we as handleV2Fetch,nt as ingestReceivePack,st as ingestReceivePackFromStream,Je as parseV2CommandRequest,et as parseV2FetchArgs,at as resolveRefUpdates};
|