just-git 1.5.7 → 1.5.8

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.
@@ -1,11 +1,11 @@
1
- var Le=(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 U(r){return r!=null&&typeof r=="object"&&"reject"in r&&r.reject===!0}var X="0000000000000000000000000000000000000000",Tt=(()=>{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 Ce(r){let e="";for(let t=0;t<20;t++)e+=Tt[r[t]];return e}function ce(r,e){let t="";for(let n=0;n<20;n++)t+=Tt[r[e+n]];return t}function fe(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 qr=new Set(["tree","commit","tag"]),He=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(!qr.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 Vr=new TextEncoder;function Xe(r){return typeof r=="string"?Vr.encode(r):r}function zr(){if(typeof globalThis.Bun<"u")return()=>{let r=new Bun.CryptoHasher("sha1"),e={update(t){return r.update(Xe(t)),e},hex:()=>Promise.resolve(r.digest("hex"))};return e};try{let r=Le(["node","crypto"].join(":"));if(typeof r.createHash=="function")return()=>{let e=r.createHash("sha1"),t={update(n){return e.update(Xe(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(Xe(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 Ce(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 Ut=zr(),Y=Ut;async function Lt(r){return Ut().update(r).hex()}var M=Uint8Array,Z=Uint16Array,Kr=Int32Array,Ct=new M([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]),Ht=new M([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]),Xr=new M([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 Z(31);for(let s=0;s<31;++s)t[s]=e+=1<<r[s-1];let n=new Kr(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:Bt}=Dt(Ct,2);Bt[28]=258;var{b:Yr}=Dt(Ht,0),Je=new Z(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,Je[r]=((e&65280)>>8|(e&255)<<8)>>1}var le=(r,e,t)=>{let n=r.length,s=0,a=new Z(e);for(;s<n;++s)r[s]&&++a[r[s]-1];let i=new Z(e);for(s=1;s<e;++s)i[s]=i[s-1]+a[s-1]<<1;let o;if(t){o=new Z(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 u=d|(1<<l)-1;d<=u;++d)o[Je[d]>>f]=c}}else for(o=new Z(n),s=0;s<n;++s)r[s]&&(o[s]=Je[i[r[s]-1]++]>>15-r[s]);return o},de=new M(288);for(let r=0;r<144;++r)de[r]=8;for(let r=144;r<256;++r)de[r]=9;for(let r=256;r<280;++r)de[r]=7;for(let r=280;r<288;++r)de[r]=8;var _t=new M(32);for(let r=0;r<32;++r)_t[r]=5;var Zr=le(de,9,1),Jr=le(_t,5,1),Ye=r=>{let e=r[0];for(let t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},N=(r,e,t)=>{let n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},Ze=(r,e)=>{let t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},Nt=r=>(r+7)/8|0,Qr=(r,e,t)=>((e==null||e<0)&&(e=0),(t==null||t>r.length)&&(t=r.length),new M(r.subarray(e,t))),$=(r,e)=>{let t=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(e||t[r]||"unknown inflate error")},Mt=(r,e,t,n)=>{let s=r.length,a=n?n.length:0;if(!s||e.f&&!e.l)return t||new M(0);let i=!t,o=i||e.i!=2,f=e.i;i&&(t=new M(s*3));let c=A=>{let x=t.length;if(A>x){let m=new M(Math.max(x*2,A));m.set(t),t=m}},l=e.f||0,d=e.p||0,u=e.b||0,h=e.l,p=e.d,g=e.m,R=e.n,P=s*8;do{if(!h){l=N(r,d,1);let b=N(r,d+1,3);if(d+=3,b)if(b==1)h=Zr,p=Jr,g=9,R=5;else if(b==2){let y=N(r,d,31)+257,w=N(r,d+10,15)+4,O=y+N(r,d+5,31)+1;d+=14;let E=new M(O),S=new M(19);for(let T=0;T<w;++T)S[Xr[T]]=N(r,d+T*3,7);d+=w*3;let j=Ye(S),v=(1<<j)-1,L=le(S,j,1);for(let T=0;T<O;){let G=L[N(r,d,v)];d+=G&15;let oe=G>>4;if(oe<16)E[T++]=oe;else{let It=0,Ue=0;for(oe==16?(Ue=3+N(r,d,3),d+=2,It=E[T-1]):oe==17?(Ue=3+N(r,d,7),d+=3):oe==18&&(Ue=11+N(r,d,127),d+=7);Ue--;)E[T++]=It}}let H=E.subarray(0,y),F=E.subarray(y);g=Ye(H),R=Ye(F),h=le(H,g,1),p=le(F,R,1)}else $(1);else{let y=Nt(d)+4,w=r[y-4]|r[y-3]<<8,O=y+w;if(O>s){f&&$(0);break}o&&c(u+w),t.set(r.subarray(y,O),u),e.b=u+=w,e.p=d=O*8,e.f=l;continue}if(d>P){f&&$(0);break}}o&&c(u+131072);let A=(1<<g)-1,x=(1<<R)-1,m=d;for(;;m=d){let b=h[Ze(r,d)&A],y=b>>4;if(d+=b&15,d>P){f&&$(0);break}if(b||$(2),y<256)t[u++]=y;else if(y==256){m=d,h=null;break}else{let w=y-254;if(y>264){let v=y-257,L=Ct[v];w=N(r,d,(1<<L)-1)+Bt[v],d+=L}let O=p[Ze(r,d)&x],E=O>>4;O||$(3),d+=O&15;let S=Yr[E];if(E>3){let v=Ht[E];S+=Ze(r,d)&(1<<v)-1,d+=v}if(d>P){f&&$(0);break}o&&c(u+131072);let j=u+w;if(u<S){let v=a-S,L=Math.min(S,j);for(v+u<0&&$(3);u<L;++u)t[u]=n[v+u]}for(;u<j;++u)t[u]=t[u-S]}}e.l=h,e.p=m,e.b=u,e.f=l,h&&(l=1,e.m=g,e.d=p,e.n=R)}while(!l);return u!=t.length&&i?Qr(t,0,u):t.subarray(0,u)},Ft=r=>(((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&$(0,"invalid zlib data"),r[1]&32&&$(0,"zlib dictionaries are not supported"),2);function $t(r){let e=Ft(r);return Mt(r.subarray(e,-4),{i:2})}function Qe(r){let e=Ft(r),t={i:2},n=Mt(r.subarray(e),t),s=Nt(t.p);return{result:n,bytesConsumed:e+s+4}}async function en(){let r;if(!(typeof document<"u"))try{r=Le(["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??Qe}}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:$t,inflateWithConsumed:Qe}}var tn=null;function Wt(){return tn??=en()}async function De(r){return await(await Wt()).deflateSync(r)}async function et(r,e){let t=await Wt(),{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 Q=1346454347,_e=2,Vt=1,zt=2,Kt=3,Xt=4,q=6,ue=7,Yt={[Vt]:"commit",[zt]:"tree",[Kt]:"blob",[Xt]:"tag"},Zt={commit:Vt,tree:zt,blob:Kt,tag:Xt};async function Jt(r,e){let t=new DataView(r.buffer,r.byteOffset,r.byteLength),n=t.getUint32(0);if(n!==Q)throw new Error(`Invalid pack signature: 0x${n.toString(16)} (expected 0x${Q.toString(16)})`);let s=t.getUint32(4);if(s!==_e)throw new Error(`Unsupported pack version: ${s}`);if(r.byteLength>=32){let c=ce(r,r.byteLength-20),l=Y();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 rn(r,o);i.push(l),o=l.nextOffset}return(await nn(i,e)).map((c,l)=>({...c,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function rn(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===q){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===ue&&(f=ce(r,e),e+=20);let{result:c,bytesConsumed:l}=await et(r.subarray(e),a);return{headerOffset:t,typeNum:s,inflated:c,baseOffset:o,baseHash:f,nextOffset:e+l}}var Gt=50;async function nn(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>Gt)throw new Error(`delta chain depth ${i} exceeds limit of ${Gt}`);let o=n[a];if(o)return o;let f=r[a];if(f.typeNum!==q&&f.typeNum!==ue){let h=Yt[f.typeNum];if(!h)throw new Error(`Unknown object type: ${f.typeNum}`);let p={type:h,content:f.inflated,hash:await J(h,f.inflated)};return n[a]=p,p}if(f.typeNum===q){let h=t.get(f.baseOffset);if(h===void 0)throw new Error(`OFS_DELTA base not found at offset ${f.baseOffset}`);let p=await s(h,i+1),g=Be(p.content,f.inflated),R={type:p.type,content:g,hash:await J(p.type,g)};return n[a]=R,R}let c=await sn(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=Be(l.content,f.inflated),u={type:l.type,content:d,hash:await J(l.type,d)};return n[a]=u,u}for(let a=0;a<r.length;a++)await s(a);return n}async function sn(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!==q&&a.typeNum!==ue&&(await n(s)).hash===t)return s}}var tt=class{buf=new Uint8Array(0);iter;eof=!1;_bytesRead=0;hasher;constructor(e,t=!1){this.iter=e[Symbol.asyncIterator](),this.hasher=t?Y():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 et(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*Qt(r,e){let t=new tt(r,!0),n=await t.readExact(12),s=new DataView(n.buffer,n.byteOffset,n.byteLength),a=s.getUint32(0);if(a!==Q)throw new Error(`Invalid pack signature: 0x${a.toString(16)} (expected 0x${Q.toString(16)})`);let i=s.getUint32(4);if(i!==_e)throw new Error(`Unsupported pack version: ${i}`);let o=s.getUint32(8),f=new Map,c=new Map;for(let u=0;u<o;u++){let h=t.bytesRead,p=await t.readByte(),g=p>>4&7,R=p&15,P=4;for(;p&128;)p=await t.readByte(),R|=(p&127)<<P,P+=7;let A,x;if(g===q){let y=await t.readByte();for(A=y&127;y&128;)A+=1,y=await t.readByte(),A=(A<<7)+(y&127);A=h-A}else if(g===ue){let y=await t.readExact(20);x=ce(y,0)}let m=await t.inflateNext(R),b;if(g!==q&&g!==ue){let y=Yt[g];if(!y)throw new Error(`Unknown object type: ${g}`);b={type:y,content:m,hash:await J(y,m)}}else if(g===q){let y=f.get(A);if(!y)throw new Error(`OFS_DELTA base not found at offset ${A}`);let w=Be(y.content,m);b={type:y.type,content:w,hash:await J(y.type,w)}}else{let y=c.get(x);if(!y&&e&&(y=await e(x)??void 0),!y)throw new Error(`REF_DELTA base not found for hash ${x}`);let w=Be(y.content,m);b={type:y.type,content:w,hash:await J(y.type,w)}}f.set(h,b),c.set(b.hash,b),yield b}let l=ce(await t.readRaw(20),0),d=await t.hashHex();if(d!==l)throw new Error(`pack checksum mismatch: expected ${l}, computed ${d}`)}function Be(r,e){let t=0,{value:n,newPos:s}=qt(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}=qt(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 ee(r){let e=[],t=new Map,n=new Uint8Array(12),s=new DataView(n.buffer);s.setUint32(0,Q),s.setUint32(4,_e),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=rt(q,o.delta.byteLength),d=on(a-c),u=await De(o.delta);e.push(l,d,u),a+=l.byteLength+d.byteLength+u.byteLength}else{let l=Zt[o.type],d=rt(l,o.content.byteLength),u=await De(o.content);e.push(d,u),a+=d.byteLength+u.byteLength}i.push({hash:o.hash,offset:f,nextOffset:a})}return{data:await an(e),entries:i}}async function*er(r,e){let t=Y(),n=new Uint8Array(12),s=new DataView(n.buffer);s.setUint32(0,Q),s.setUint32(4,_e),s.setUint32(8,r),t.update(n),yield n;for await(let a of e){let i=Zt[a.type],o=rt(i,a.content.byteLength),f=await De(a.content);t.update(o),t.update(f),yield cn(o,f)}yield fe(await t.hex())}async function an(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=Y();s.update(t.subarray(0,n));let a=await s.hex();return t.set(fe(a),n),t}function on(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 rt(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 qt(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 cn(r,e){let t=new Uint8Array(r.byteLength+e.byteLength);return t.set(r,0),t.set(e,r.byteLength),t}var fn=new TextEncoder;async function J(r,e){let t=fn.encode(`${r} ${e.byteLength}\0`),n=Y();return n.update(t),n.update(e),n.hex()}var ln=new TextEncoder,As=new TextDecoder;function tr(r,e){let t=ln.encode(`${r} ${e.byteLength}\0`),n=new Uint8Array(t.byteLength+e.byteLength);return n.set(t),n.set(e,t.byteLength),n}function pe(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}}function Ne(r){return`${r.name} <${r.email}> ${r.timestamp} ${r.timezone}`}var dn=new TextEncoder,un=new TextDecoder;function he(r){let e=un.decode(r),t=e.indexOf(`
1
+ var Le=(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 U(r){return r!=null&&typeof r=="object"&&"reject"in r&&r.reject===!0}var X="0000000000000000000000000000000000000000",Tt=(()=>{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 Ce(r){let e="";for(let t=0;t<20;t++)e+=Tt[r[t]];return e}function ce(r,e){let t="";for(let n=0;n<20;n++)t+=Tt[r[e+n]];return t}function fe(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 qr=new Set(["tree","commit","tag"]),He=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(!qr.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 Vr=new TextEncoder;function Xe(r){return typeof r=="string"?Vr.encode(r):r}function zr(){if(typeof globalThis.Bun<"u")return()=>{let r=new Bun.CryptoHasher("sha1"),e={update(t){return r.update(Xe(t)),e},hex:()=>Promise.resolve(r.digest("hex"))};return e};try{let r=Le(["node","crypto"].join(":"));if(typeof r.createHash=="function")return()=>{let e=r.createHash("sha1"),t={update(n){return e.update(Xe(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(Xe(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 Ce(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 Ut=zr(),Y=Ut;async function Lt(r){return Ut().update(r).hex()}var F=Uint8Array,Z=Uint16Array,Kr=Int32Array,Ct=new F([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]),Ht=new F([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]),Xr=new F([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 Z(31);for(let s=0;s<31;++s)t[s]=e+=1<<r[s-1];let n=new Kr(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:Bt}=Dt(Ct,2);Bt[28]=258;var{b:Yr}=Dt(Ht,0),Je=new Z(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,Je[r]=((e&65280)>>8|(e&255)<<8)>>1}var le=(r,e,t)=>{let n=r.length,s=0,a=new Z(e);for(;s<n;++s)r[s]&&++a[r[s]-1];let i=new Z(e);for(s=1;s<e;++s)i[s]=i[s-1]+a[s-1]<<1;let o;if(t){o=new Z(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 u=d|(1<<l)-1;d<=u;++d)o[Je[d]>>f]=c}}else for(o=new Z(n),s=0;s<n;++s)r[s]&&(o[s]=Je[i[r[s]-1]++]>>15-r[s]);return o},de=new F(288);for(let r=0;r<144;++r)de[r]=8;for(let r=144;r<256;++r)de[r]=9;for(let r=256;r<280;++r)de[r]=7;for(let r=280;r<288;++r)de[r]=8;var _t=new F(32);for(let r=0;r<32;++r)_t[r]=5;var Zr=le(de,9,1),Jr=le(_t,5,1),Ye=r=>{let e=r[0];for(let t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},N=(r,e,t)=>{let n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},Ze=(r,e)=>{let t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},Nt=r=>(r+7)/8|0,Qr=(r,e,t)=>((e==null||e<0)&&(e=0),(t==null||t>r.length)&&(t=r.length),new F(r.subarray(e,t))),$=(r,e)=>{let t=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(e||t[r]||"unknown inflate error")},Ft=(r,e,t,n)=>{let s=r.length,a=n?n.length:0;if(!s||e.f&&!e.l)return t||new F(0);let i=!t,o=i||e.i!=2,f=e.i;i&&(t=new F(s*3));let c=A=>{let x=t.length;if(A>x){let m=new F(Math.max(x*2,A));m.set(t),t=m}},l=e.f||0,d=e.p||0,u=e.b||0,h=e.l,p=e.d,g=e.m,R=e.n,P=s*8;do{if(!h){l=N(r,d,1);let b=N(r,d+1,3);if(d+=3,b)if(b==1)h=Zr,p=Jr,g=9,R=5;else if(b==2){let y=N(r,d,31)+257,w=N(r,d+10,15)+4,O=y+N(r,d+5,31)+1;d+=14;let E=new F(O),S=new F(19);for(let T=0;T<w;++T)S[Xr[T]]=N(r,d+T*3,7);d+=w*3;let j=Ye(S),v=(1<<j)-1,L=le(S,j,1);for(let T=0;T<O;){let G=L[N(r,d,v)];d+=G&15;let oe=G>>4;if(oe<16)E[T++]=oe;else{let It=0,Ue=0;for(oe==16?(Ue=3+N(r,d,3),d+=2,It=E[T-1]):oe==17?(Ue=3+N(r,d,7),d+=3):oe==18&&(Ue=11+N(r,d,127),d+=7);Ue--;)E[T++]=It}}let H=E.subarray(0,y),M=E.subarray(y);g=Ye(H),R=Ye(M),h=le(H,g,1),p=le(M,R,1)}else $(1);else{let y=Nt(d)+4,w=r[y-4]|r[y-3]<<8,O=y+w;if(O>s){f&&$(0);break}o&&c(u+w),t.set(r.subarray(y,O),u),e.b=u+=w,e.p=d=O*8,e.f=l;continue}if(d>P){f&&$(0);break}}o&&c(u+131072);let A=(1<<g)-1,x=(1<<R)-1,m=d;for(;;m=d){let b=h[Ze(r,d)&A],y=b>>4;if(d+=b&15,d>P){f&&$(0);break}if(b||$(2),y<256)t[u++]=y;else if(y==256){m=d,h=null;break}else{let w=y-254;if(y>264){let v=y-257,L=Ct[v];w=N(r,d,(1<<L)-1)+Bt[v],d+=L}let O=p[Ze(r,d)&x],E=O>>4;O||$(3),d+=O&15;let S=Yr[E];if(E>3){let v=Ht[E];S+=Ze(r,d)&(1<<v)-1,d+=v}if(d>P){f&&$(0);break}o&&c(u+131072);let j=u+w;if(u<S){let v=a-S,L=Math.min(S,j);for(v+u<0&&$(3);u<L;++u)t[u]=n[v+u]}for(;u<j;++u)t[u]=t[u-S]}}e.l=h,e.p=m,e.b=u,e.f=l,h&&(l=1,e.m=g,e.d=p,e.n=R)}while(!l);return u!=t.length&&i?Qr(t,0,u):t.subarray(0,u)},Mt=r=>(((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&$(0,"invalid zlib data"),r[1]&32&&$(0,"zlib dictionaries are not supported"),2);function $t(r){let e=Mt(r);return Ft(r.subarray(e,-4),{i:2})}function Qe(r){let e=Mt(r),t={i:2},n=Ft(r.subarray(e),t),s=Nt(t.p);return{result:n,bytesConsumed:e+s+4}}async function en(){let r;if(!(typeof document<"u"))try{r=Le(["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??Qe}}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:$t,inflateWithConsumed:Qe}}var tn=null;function Wt(){return tn??=en()}async function De(r){return await(await Wt()).deflateSync(r)}async function et(r,e){let t=await Wt(),{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 Q=1346454347,_e=2,Vt=1,zt=2,Kt=3,Xt=4,q=6,ue=7,Yt={[Vt]:"commit",[zt]:"tree",[Kt]:"blob",[Xt]:"tag"},Zt={commit:Vt,tree:zt,blob:Kt,tag:Xt};async function Jt(r,e){let t=new DataView(r.buffer,r.byteOffset,r.byteLength),n=t.getUint32(0);if(n!==Q)throw new Error(`Invalid pack signature: 0x${n.toString(16)} (expected 0x${Q.toString(16)})`);let s=t.getUint32(4);if(s!==_e)throw new Error(`Unsupported pack version: ${s}`);if(r.byteLength>=32){let c=ce(r,r.byteLength-20),l=Y();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 rn(r,o);i.push(l),o=l.nextOffset}return(await nn(i,e)).map((c,l)=>({...c,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function rn(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===q){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===ue&&(f=ce(r,e),e+=20);let{result:c,bytesConsumed:l}=await et(r.subarray(e),a);return{headerOffset:t,typeNum:s,inflated:c,baseOffset:o,baseHash:f,nextOffset:e+l}}var Gt=50;async function nn(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>Gt)throw new Error(`delta chain depth ${i} exceeds limit of ${Gt}`);let o=n[a];if(o)return o;let f=r[a];if(f.typeNum!==q&&f.typeNum!==ue){let h=Yt[f.typeNum];if(!h)throw new Error(`Unknown object type: ${f.typeNum}`);let p={type:h,content:f.inflated,hash:await J(h,f.inflated)};return n[a]=p,p}if(f.typeNum===q){let h=t.get(f.baseOffset);if(h===void 0)throw new Error(`OFS_DELTA base not found at offset ${f.baseOffset}`);let p=await s(h,i+1),g=Be(p.content,f.inflated),R={type:p.type,content:g,hash:await J(p.type,g)};return n[a]=R,R}let c=await sn(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=Be(l.content,f.inflated),u={type:l.type,content:d,hash:await J(l.type,d)};return n[a]=u,u}for(let a=0;a<r.length;a++)await s(a);return n}async function sn(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!==q&&a.typeNum!==ue&&(await n(s)).hash===t)return s}}var tt=class{buf=new Uint8Array(0);iter;eof=!1;_bytesRead=0;hasher;constructor(e,t=!1){this.iter=e[Symbol.asyncIterator](),this.hasher=t?Y():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 et(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*Qt(r,e){let t=new tt(r,!0),n=await t.readExact(12),s=new DataView(n.buffer,n.byteOffset,n.byteLength),a=s.getUint32(0);if(a!==Q)throw new Error(`Invalid pack signature: 0x${a.toString(16)} (expected 0x${Q.toString(16)})`);let i=s.getUint32(4);if(i!==_e)throw new Error(`Unsupported pack version: ${i}`);let o=s.getUint32(8),f=new Map,c=new Map;for(let u=0;u<o;u++){let h=t.bytesRead,p=await t.readByte(),g=p>>4&7,R=p&15,P=4;for(;p&128;)p=await t.readByte(),R|=(p&127)<<P,P+=7;let A,x;if(g===q){let y=await t.readByte();for(A=y&127;y&128;)A+=1,y=await t.readByte(),A=(A<<7)+(y&127);A=h-A}else if(g===ue){let y=await t.readExact(20);x=ce(y,0)}let m=await t.inflateNext(R),b;if(g!==q&&g!==ue){let y=Yt[g];if(!y)throw new Error(`Unknown object type: ${g}`);b={type:y,content:m,hash:await J(y,m)}}else if(g===q){let y=f.get(A);if(!y)throw new Error(`OFS_DELTA base not found at offset ${A}`);let w=Be(y.content,m);b={type:y.type,content:w,hash:await J(y.type,w)}}else{let y=c.get(x);if(!y&&e&&(y=await e(x)??void 0),!y)throw new Error(`REF_DELTA base not found for hash ${x}`);let w=Be(y.content,m);b={type:y.type,content:w,hash:await J(y.type,w)}}f.set(h,b),c.set(b.hash,b),yield b}let l=ce(await t.readRaw(20),0),d=await t.hashHex();if(d!==l)throw new Error(`pack checksum mismatch: expected ${l}, computed ${d}`)}function Be(r,e){let t=0,{value:n,newPos:s}=qt(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}=qt(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 ee(r){let e=[],t=new Map,n=new Uint8Array(12),s=new DataView(n.buffer);s.setUint32(0,Q),s.setUint32(4,_e),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=rt(q,o.delta.byteLength),d=on(a-c),u=await De(o.delta);e.push(l,d,u),a+=l.byteLength+d.byteLength+u.byteLength}else{let l=Zt[o.type],d=rt(l,o.content.byteLength),u=await De(o.content);e.push(d,u),a+=d.byteLength+u.byteLength}i.push({hash:o.hash,offset:f,nextOffset:a})}return{data:await an(e),entries:i}}async function*er(r,e){let t=Y(),n=new Uint8Array(12),s=new DataView(n.buffer);s.setUint32(0,Q),s.setUint32(4,_e),s.setUint32(8,r),t.update(n),yield n;for await(let a of e){let i=Zt[a.type],o=rt(i,a.content.byteLength),f=await De(a.content);t.update(o),t.update(f),yield cn(o,f)}yield fe(await t.hex())}async function an(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=Y();s.update(t.subarray(0,n));let a=await s.hex();return t.set(fe(a),n),t}function on(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 rt(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 qt(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 cn(r,e){let t=new Uint8Array(r.byteLength+e.byteLength);return t.set(r,0),t.set(e,r.byteLength),t}var fn=new TextEncoder;async function J(r,e){let t=fn.encode(`${r} ${e.byteLength}\0`),n=Y();return n.update(t),n.update(e),n.hex()}var ln=new TextEncoder,As=new TextDecoder;function tr(r,e){let t=ln.encode(`${r} ${e.byteLength}\0`),n=new Uint8Array(t.byteLength+e.byteLength);return n.set(t),n.set(e,t.byteLength),n}function pe(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}}function Ne(r){return`${r.name} <${r.email}> ${r.timestamp} ${r.timezone}`}var dn=new TextEncoder,un=new TextDecoder;function he(r){let e=un.decode(r),t=e.indexOf(`
2
2
 
3
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
4
  `)){let l=c.indexOf(" ");if(l===-1)continue;let d=c.slice(0,l),u=c.slice(l+1);switch(d){case"tree":a=u;break;case"parent":i.push(u);break;case"author":o=pe(u);break;case"committer":f=pe(u);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}}function rr(r){let e=[];e.push(`tree ${r.tree}`);for(let t of r.parents)e.push(`parent ${t}`);return e.push(`author ${Ne(r.author)}`),e.push(`committer ${Ne(r.committer)}`),e.push(""),e.push(r.message),dn.encode(e.join(`
5
5
  `))}var js=new TextEncoder,pn=new TextDecoder;function te(r){let e=pn.decode(r),t=e.indexOf(`
6
6
 
7
7
  `),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(`
8
- `)){let l=c.indexOf(" ");if(l===-1)continue;let d=c.slice(0,l),u=c.slice(l+1);switch(d){case"object":a=u;break;case"type":i=u;break;case"tag":o=u;break;case"tagger":f=pe(u);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 Me(r,e,t){let n=await r.objectStore.write(e,t);return r.hooks?.onObjectWrite?.({repo:r,type:e,hash:n}),n}async function z(r,e){return r.objectStore.read(e)}async function ye(r,e){return r.objectStore.exists(e)}var Us=new TextDecoder;async function V(r,e){let t=await z(r,e);if(t.type!=="commit")throw new Error(`Expected commit object for ${e}, got ${t.type}`);return he(t.content)}var hn=new TextEncoder,nr=new TextDecoder,yn=new Set(["100644","100755","040000","120000","160000"]);function mn(r){return r.length===4&&r.toLowerCase()===".git"}function bn(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(mn(r))throw new Error(`invalid tree entry: '${r}'`);if(!yn.has(e))throw new Error(`invalid tree entry mode: '${e}' for '${r}'`)}function me(r){let e=[],t=0;for(;t<r.byteLength;){let n=r.indexOf(32,t);if(n===-1)break;let s=nr.decode(r.subarray(t,n)),a=r.indexOf(0,n+1);if(a===-1)break;let i=nr.decode(r.subarray(n+1,a)),o=r.subarray(a+1,a+21),f=Ce(o),c=s.padStart(6,"0");bn(i,c),e.push({mode:c,name:i,hash:f}),t=a+21}return{type:"tree",entries:e}}function sr(r){let e=[];for(let a of r.entries){let i=a.mode.replace(/^0+/,""),o=hn.encode(`${i} ${a.name}\0`),f=fe(a.hash);e.push(o),e.push(f)}let t=e.reduce((a,i)=>a+i.byteLength,0),n=new Uint8Array(t),s=0;for(let a of e)n.set(a,s),s+=a.byteLength;return n}function ar(r){return typeof r=="string"?{type:"direct",hash:r}:r}var nt=".lock";var gn=[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 wn(r,e,t){let n=0,s=!1,a=e;for(;a<r.length;a++){let o=r.charCodeAt(a);switch(o<128?gn[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>=nt.length&&r.slice(a-nt.length,a)===nt?{len:-1,starConsumed:s}:{len:i,starConsumed:s}}function st(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}=wn(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 Rn=10;async function xn(r,e){return r.refStore.readRef(e)}async function be(r,e){let t=e;for(let n=0;n<Rn;n++){let s=await xn(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}"`)}function kn(r){let e=Math.abs(r),t=r<=0?"+":"-",n=String(Math.floor(e/60)).padStart(2,"0"),s=String(e%60).padStart(2,"0");return`${t}${n}${s}`}function ir(r){if("timestamp"in r)return r;let e=r.date??new Date;return{name:r.name,email:r.email,timestamp:Math.floor(e.getTime()/1e3),timezone:kn(e.getTimezoneOffset())}}async function cr(r,e){let t=e.branch?`refs/heads/${e.branch}`:null,n=t?await be(r,t):null,s=null;n&&(s=(await V(r,n)).tree);let a=[];for(let[u,h]of Object.entries(e.files))if(h===null)a.push({path:u,hash:null});else{let p=typeof h=="string"?new TextEncoder().encode(h):h,g=await Me(r,"blob",p);a.push({path:u,hash:g})}let i;s?i=await An(r,s,a):i=await it(r,null,at(a));let o=ir(e.author),f=e.committer?ir(e.committer):o,l=rr({type:"commit",tree:i,parents:n?[n]:[],author:o,committer:f,message:e.message});return{hash:await Me(r,"commit",l),parentHash:n}}async function An(r,e,t){return it(r,e,at(t))}function at(r){let e=new Map,t=new Map;for(let n of r){let s=n.path.indexOf("/");if(s===-1)e.set(n.path,{hash:n.hash,mode:n.mode??"100644"});else{let a=n.path.slice(0,s),i=n.path.slice(s+1),o=t.get(a);o||(o=[],t.set(a,o)),o.push({...n,path:i})}}return{files:e,dirs:t}}async function or(r,e){let t=await z(r,e);if(t.type!=="tree")throw new Error(`Expected tree object, got ${t.type}`);return me(t.content).entries}async function it(r,e,t){let n=new Map;if(e)for(let i of await or(r,e))n.set(i.name,i);for(let[i,{hash:o,mode:f}]of t.files)o===null?n.delete(i):n.set(i,{name:i,hash:o,mode:f});for(let[i,o]of t.dirs){let f=n.get(i),c=f?.mode==="040000"?f.hash:null,l=at(o),d=await it(r,c,l);(await or(r,d)).length===0?n.delete(i):n.set(i,{name:i,hash:d,mode:"040000"})}let s=[...n.values()].sort((i,o)=>{let f=i.mode==="040000"?`${i.name}/`:i.name,c=o.mode==="040000"?`${o.name}/`:o.name;return f<c?-1:f>c?1:0}),a=sr({type:"tree",entries:s});return Me(r,"tree",a)}async function ot(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 V(r,i)}catch{continue}for(let f of o.parents)n.has(f)||s.push(f)}return!1}var $e=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]),En=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]),Fe=64,Pn=4,ct=4096,fr=65536,On=127;function Sn(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=jn(n);let s=n-1,a=new Uint32Array(n),i=[],o=-1>>>0;for(let u=t*16-16;u>=0;u-=16){let h=0;for(let p=1;p<=16;p++)h=(h<<8|r[u+p])^$e[h>>>23];if(h=h>>>0,h===o)i[i.length-1].ptr=u+16;else{o=h;let p=h&s;i.push({ptr:u+16,val:h}),a[p]++}}let f=new Map;for(let u of i){let h=u.val&s,p=f.get(h);p||(p=[],f.set(h,p)),p.push(u)}for(let[u,h]of f){if(h.length<=Fe)continue;let p=[],g=h.length/Fe;for(let R=0;R<Fe;R++)p.push(h[Math.floor(R*g)]);f.set(u,p),a[u]=Fe}let c=new Uint32Array(n+1),l=[],d=0;for(let u=0;u<n;u++){c[u]=d;let h=f.get(u);if(h){for(let p of h)l.push(p);d+=h.length}}return c[n]=d,{src:r,hashMask:s,buckets:c,entries:l}}function vn(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(g){for(;o+g>i.length;){let R=new Uint8Array(i.length*2);R.set(i),i=R}}o=dr(i,o,n),o=dr(i,o,s),f(18),o++;let c=0,l=0,d=Math.min(16,s);for(let g=0;g<d;g++)i[o++]=e[g],c=(c<<8|e[g])^$e[c>>>23],l++;c=c>>>0;let u=d,h=0,p=0;for(;u<s;){if(p<ct){c^=En[e[u-16]],c=((c<<8|e[u])^$e[c>>>23])>>>0;let g=c&r.hashMask,R=r.buckets[g],P=r.buckets[g+1];for(let A=R;A<P;A++){let x=r.entries[A];if(x.val!==c)continue;let m=x.ptr,b=a.byteLength-m,y=s-u;if(b>y&&(b=y),b<=p)break;let w=0;for(;w<b&&a[m+w]===e[u+w];)w++;if(w>p&&(p=w,h=m,p>=ct))break}}if(p<Pn)f(2),l===0&&o++,i[o++]=e[u++],l++,l===On&&(i[o-l-1]=l,l=0),p=0;else{if(l>0){for(;h>0&&a[h-1]===e[u-1];)if(p++,h--,u--,o--,!(--l>0)){o--,l=-1;break}l>0&&(i[o-l-1]=l),l=0}let g=p>fr?p-fr:0;p-=g,f(8);let R=o++,P=128;if(h&255&&(i[o++]=h&255,P|=1),h&65280&&(i[o++]=h>>>8&255,P|=2),h&16711680&&(i[o++]=h>>>16&255,P|=4),h&4278190080&&(i[o++]=h>>>24&255,P|=8),p&255&&(i[o++]=p&255,P|=16),p&65280&&(i[o++]=p>>>8&255,P|=32),i[R]=P,u+=p,h+=p,p=g,h>4294967295&&(p=0),p<ct){c=0;for(let A=-16;A<0;A++)c=(c<<8|e[u+A])^$e[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 lr={blob:0,tree:1,commit:2,tag:3};function ur(r,e){let t=e?.window??10,n=e?.depth??50,s=r.slice().sort((c,l)=>{let d=lr[c.type]??99,u=lr[l.type]??99;return d!==u?d-u: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},u=null,h=null,p=Math.max(0,c-t);for(let g=c-1;g>=p;g--){let R=s[g];if(R.type!==l.type||(a.get(R.hash)?.depth??0)>=n||l.content.byteLength<R.content.byteLength>>>5)continue;let x=o[g-p]??null;if(!x)continue;let m=u?u.byteLength:l.content.byteLength/2|0;if(m<16)continue;let b=vn(x,l.content,m);b&&(!u||b.byteLength<u.byteLength)&&(u=b,h=R.hash)}if(u&&h){d.delta=u,d.deltaBase=h;let g=a.get(h);d.depth=(g?.depth??0)+1}a.set(l.hash,d),i.push(d),o.length>=t&&(o.shift(),f.shift()),o.push(Sn(l.content)),f.push(l.hash)}return i}function jn(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 dr(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 In=2147483647;async function ft(r,e,t,n){if(t>=In)return{shallow:[],unshallow:[...n]};let s=new Map,a=[];for(let c of e)!s.has(c)&&await ye(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 V(r,c)}catch{continue}for(let u of d.parents)!s.has(u)&&await ye(r,u)&&(s.set(u,l+1),a.push({hash:u,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 Re(r,e,t,n,s){let a=s??n,i=new Set;for(let l of t)await ge(r,l,i,a);let o=[...e];if(s&&n)for(let l of s)try{let d=await V(r,l);for(let u of d.parents)i.has(u)||o.push(u)}catch{}let f=[],c=new Set;for(let l of o)await we(r,l,i,c,f,n);return{count:f.length,objects:Tn(f)}}async function pr(r,e,t,n,s){let{count:a,objects:i}=await Re(r,e,t,n,s);return{count:a,objects:Un(r,i)}}async function*Tn(r){for(let e of r)yield e}async function*Un(r,e){for await(let t of e){let n=await z(r,t.hash);yield{hash:t.hash,type:t.type,content:n.content}}}async function hr(r){let e=[];for await(let t of r.objects)e.push(t);return e}async function ge(r,e,t,n){if(t.has(e)||(t.add(e),!await ye(r,e)))return;let s=await z(r,e);switch(s.type){case"commit":{let a=he(s.content);if(await ge(r,a.tree,t,n),!n?.has(e))for(let i of a.parents)await ge(r,i,t,n);break}case"tree":{let a=me(s.content);for(let i of a.entries)await ge(r,i.hash,t,n);break}case"tag":{let a=te(s.content);await ge(r,a.object,t,n);break}case"blob":break}}async function we(r,e,t,n,s,a){if(n.has(e)||t.has(e))return;n.add(e);let i=await z(r,e);switch(s.push({hash:e,type:i.type}),i.type){case"commit":{let o=he(i.content);if(await we(r,o.tree,t,n,s,a),!a?.has(e))for(let f of o.parents)await we(r,f,t,n,s,a);break}case"tree":{let o=me(i.content);for(let f of o.entries)await we(r,f.hash,t,n,s,a);break}case"tag":{let o=te(i.content);await we(r,o.object,t,n,s,a);break}case"blob":break}}var Ln=new TextEncoder,mr=new TextDecoder,yr=65520,Cn=new Uint8Array([48,48,48,48]),Hn=new Uint8Array([48,48,48,49]),ea=new Uint8Array([48,48,48,50]);function k(r){let e=typeof r=="string"?Ln.encode(r):r,t=4+e.byteLength;if(t>yr)throw new Error(`pkt-line too long: ${t} bytes (max ${yr})`);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 _(){return Cn.slice()}function K(){return Hn.slice()}function B(...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 lt(r){let e=[],t=0;for(;t<r.byteLength;){if(t+4>r.byteLength)throw new Error("Truncated pkt-line header");let n=mr.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 dt(r){if(r.type!=="data")return"";let e=mr.decode(r.data);return e.endsWith(`
8
+ `)){let l=c.indexOf(" ");if(l===-1)continue;let d=c.slice(0,l),u=c.slice(l+1);switch(d){case"object":a=u;break;case"type":i=u;break;case"tag":o=u;break;case"tagger":f=pe(u);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,t){let n=await r.objectStore.write(e,t);return r.hooks?.onObjectWrite?.({repo:r,type:e,hash:n}),n}async function z(r,e){return r.objectStore.read(e)}async function ye(r,e){return r.objectStore.exists(e)}var Us=new TextDecoder;async function V(r,e){let t=await z(r,e);if(t.type!=="commit")throw new Error(`Expected commit object for ${e}, got ${t.type}`);return he(t.content)}var hn=new TextEncoder,nr=new TextDecoder,yn=new Set(["100644","100755","040000","120000","160000"]);function mn(r){return r.length===4&&r.toLowerCase()===".git"}function bn(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(mn(r))throw new Error(`invalid tree entry: '${r}'`);if(!yn.has(e))throw new Error(`invalid tree entry mode: '${e}' for '${r}'`)}function me(r){let e=[],t=0;for(;t<r.byteLength;){let n=r.indexOf(32,t);if(n===-1)break;let s=nr.decode(r.subarray(t,n)),a=r.indexOf(0,n+1);if(a===-1)break;let i=nr.decode(r.subarray(n+1,a)),o=r.subarray(a+1,a+21),f=Ce(o),c=s.padStart(6,"0");bn(i,c),e.push({mode:c,name:i,hash:f}),t=a+21}return{type:"tree",entries:e}}function sr(r){let e=[];for(let a of r.entries){let i=a.mode.replace(/^0+/,""),o=hn.encode(`${i} ${a.name}\0`),f=fe(a.hash);e.push(o),e.push(f)}let t=e.reduce((a,i)=>a+i.byteLength,0),n=new Uint8Array(t),s=0;for(let a of e)n.set(a,s),s+=a.byteLength;return n}function ar(r){return typeof r=="string"?{type:"direct",hash:r}:r}var nt=".lock";var gn=[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 wn(r,e,t){let n=0,s=!1,a=e;for(;a<r.length;a++){let o=r.charCodeAt(a);switch(o<128?gn[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>=nt.length&&r.slice(a-nt.length,a)===nt?{len:-1,starConsumed:s}:{len:i,starConsumed:s}}function st(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}=wn(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 Rn=10;async function xn(r,e){return r.refStore.readRef(e)}async function be(r,e){let t=e;for(let n=0;n<Rn;n++){let s=await xn(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}"`)}function kn(r){let e=Math.abs(r),t=r<=0?"+":"-",n=String(Math.floor(e/60)).padStart(2,"0"),s=String(e%60).padStart(2,"0");return`${t}${n}${s}`}function ir(r){if("timestamp"in r)return r;let e=r.date??new Date;return{name:r.name,email:r.email,timestamp:Math.floor(e.getTime()/1e3),timezone:kn(e.getTimezoneOffset())}}async function cr(r,e){let t=e.branch?`refs/heads/${e.branch}`:null,n=t?await be(r,t):null,s=null;n&&(s=(await V(r,n)).tree);let a=[];for(let[u,h]of Object.entries(e.files))if(h===null)a.push({path:u,hash:null});else{let p=typeof h=="string"?new TextEncoder().encode(h):h,g=await Fe(r,"blob",p);a.push({path:u,hash:g})}let i;s?i=await An(r,s,a):i=await it(r,null,at(a));let o=ir(e.author),f=e.committer?ir(e.committer):o,l=rr({type:"commit",tree:i,parents:n?[n]:[],author:o,committer:f,message:e.message});return{hash:await Fe(r,"commit",l),parentHash:n}}async function An(r,e,t){return it(r,e,at(t))}function at(r){let e=new Map,t=new Map;for(let n of r){let s=n.path.indexOf("/");if(s===-1)e.set(n.path,{hash:n.hash,mode:n.mode??"100644"});else{let a=n.path.slice(0,s),i=n.path.slice(s+1),o=t.get(a);o||(o=[],t.set(a,o)),o.push({...n,path:i})}}return{files:e,dirs:t}}async function or(r,e){let t=await z(r,e);if(t.type!=="tree")throw new Error(`Expected tree object, got ${t.type}`);return me(t.content).entries}async function it(r,e,t){let n=new Map;if(e)for(let i of await or(r,e))n.set(i.name,i);for(let[i,{hash:o,mode:f}]of t.files)o===null?n.delete(i):n.set(i,{name:i,hash:o,mode:f});for(let[i,o]of t.dirs){let f=n.get(i),c=f?.mode==="040000"?f.hash:null,l=at(o),d=await it(r,c,l);(await or(r,d)).length===0?n.delete(i):n.set(i,{name:i,hash:d,mode:"040000"})}let s=[...n.values()].sort((i,o)=>{let f=i.mode==="040000"?`${i.name}/`:i.name,c=o.mode==="040000"?`${o.name}/`:o.name;return f<c?-1:f>c?1:0}),a=sr({type:"tree",entries:s});return Fe(r,"tree",a)}async function ot(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 V(r,i)}catch{continue}for(let f of o.parents)n.has(f)||s.push(f)}return!1}var $e=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]),En=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]),Me=64,Pn=4,ct=4096,fr=65536,On=127;function Sn(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=jn(n);let s=n-1,a=new Uint32Array(n),i=[],o=-1>>>0;for(let u=t*16-16;u>=0;u-=16){let h=0;for(let p=1;p<=16;p++)h=(h<<8|r[u+p])^$e[h>>>23];if(h=h>>>0,h===o)i[i.length-1].ptr=u+16;else{o=h;let p=h&s;i.push({ptr:u+16,val:h}),a[p]++}}let f=new Map;for(let u of i){let h=u.val&s,p=f.get(h);p||(p=[],f.set(h,p)),p.push(u)}for(let[u,h]of f){if(h.length<=Me)continue;let p=[],g=h.length/Me;for(let R=0;R<Me;R++)p.push(h[Math.floor(R*g)]);f.set(u,p),a[u]=Me}let c=new Uint32Array(n+1),l=[],d=0;for(let u=0;u<n;u++){c[u]=d;let h=f.get(u);if(h){for(let p of h)l.push(p);d+=h.length}}return c[n]=d,{src:r,hashMask:s,buckets:c,entries:l}}function vn(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(g){for(;o+g>i.length;){let R=new Uint8Array(i.length*2);R.set(i),i=R}}o=dr(i,o,n),o=dr(i,o,s),f(18),o++;let c=0,l=0,d=Math.min(16,s);for(let g=0;g<d;g++)i[o++]=e[g],c=(c<<8|e[g])^$e[c>>>23],l++;c=c>>>0;let u=d,h=0,p=0;for(;u<s;){if(p<ct){c^=En[e[u-16]],c=((c<<8|e[u])^$e[c>>>23])>>>0;let g=c&r.hashMask,R=r.buckets[g],P=r.buckets[g+1];for(let A=R;A<P;A++){let x=r.entries[A];if(x.val!==c)continue;let m=x.ptr,b=a.byteLength-m,y=s-u;if(b>y&&(b=y),b<=p)break;let w=0;for(;w<b&&a[m+w]===e[u+w];)w++;if(w>p&&(p=w,h=m,p>=ct))break}}if(p<Pn)f(2),l===0&&o++,i[o++]=e[u++],l++,l===On&&(i[o-l-1]=l,l=0),p=0;else{if(l>0){for(;h>0&&a[h-1]===e[u-1];)if(p++,h--,u--,o--,!(--l>0)){o--,l=-1;break}l>0&&(i[o-l-1]=l),l=0}let g=p>fr?p-fr:0;p-=g,f(8);let R=o++,P=128;if(h&255&&(i[o++]=h&255,P|=1),h&65280&&(i[o++]=h>>>8&255,P|=2),h&16711680&&(i[o++]=h>>>16&255,P|=4),h&4278190080&&(i[o++]=h>>>24&255,P|=8),p&255&&(i[o++]=p&255,P|=16),p&65280&&(i[o++]=p>>>8&255,P|=32),i[R]=P,u+=p,h+=p,p=g,h>4294967295&&(p=0),p<ct){c=0;for(let A=-16;A<0;A++)c=(c<<8|e[u+A])^$e[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 lr={blob:0,tree:1,commit:2,tag:3};function ur(r,e){let t=e?.window??10,n=e?.depth??50,s=r.slice().sort((c,l)=>{let d=lr[c.type]??99,u=lr[l.type]??99;return d!==u?d-u: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},u=null,h=null,p=Math.max(0,c-t);for(let g=c-1;g>=p;g--){let R=s[g];if(R.type!==l.type||(a.get(R.hash)?.depth??0)>=n||l.content.byteLength<R.content.byteLength>>>5)continue;let x=o[g-p]??null;if(!x)continue;let m=u?u.byteLength:l.content.byteLength/2|0;if(m<16)continue;let b=vn(x,l.content,m);b&&(!u||b.byteLength<u.byteLength)&&(u=b,h=R.hash)}if(u&&h){d.delta=u,d.deltaBase=h;let g=a.get(h);d.depth=(g?.depth??0)+1}a.set(l.hash,d),i.push(d),o.length>=t&&(o.shift(),f.shift()),o.push(Sn(l.content)),f.push(l.hash)}return i}function jn(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 dr(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 In=2147483647;async function ft(r,e,t,n){if(t>=In)return{shallow:[],unshallow:[...n]};let s=new Map,a=[];for(let c of e)!s.has(c)&&await ye(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 V(r,c)}catch{continue}for(let u of d.parents)!s.has(u)&&await ye(r,u)&&(s.set(u,l+1),a.push({hash:u,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 Re(r,e,t,n,s){let a=s??n,i=new Set;for(let l of t)await ge(r,l,i,a);let o=[...e];if(s&&n)for(let l of s)try{let d=await V(r,l);for(let u of d.parents)i.has(u)||o.push(u)}catch{}let f=[],c=new Set;for(let l of o)await we(r,l,i,c,f,n);return{count:f.length,objects:Tn(f)}}async function pr(r,e,t,n,s){let{count:a,objects:i}=await Re(r,e,t,n,s);return{count:a,objects:Un(r,i)}}async function*Tn(r){for(let e of r)yield e}async function*Un(r,e){for await(let t of e){let n=await z(r,t.hash);yield{hash:t.hash,type:t.type,content:n.content}}}async function hr(r){let e=[];for await(let t of r.objects)e.push(t);return e}async function ge(r,e,t,n){if(t.has(e)||(t.add(e),!await ye(r,e)))return;let s=await z(r,e);switch(s.type){case"commit":{let a=he(s.content);if(await ge(r,a.tree,t,n),!n?.has(e))for(let i of a.parents)await ge(r,i,t,n);break}case"tree":{let a=me(s.content);for(let i of a.entries)await ge(r,i.hash,t,n);break}case"tag":{let a=te(s.content);await ge(r,a.object,t,n);break}case"blob":break}}async function we(r,e,t,n,s,a){if(n.has(e)||t.has(e))return;n.add(e);let i=await z(r,e);switch(s.push({hash:e,type:i.type}),i.type){case"commit":{let o=he(i.content);if(await we(r,o.tree,t,n,s,a),!a?.has(e))for(let f of o.parents)await we(r,f,t,n,s,a);break}case"tree":{let o=me(i.content);for(let f of o.entries)await we(r,f.hash,t,n,s,a);break}case"tag":{let o=te(i.content);await we(r,o.object,t,n,s,a);break}case"blob":break}}var Ln=new TextEncoder,mr=new TextDecoder,yr=65520,Cn=new Uint8Array([48,48,48,48]),Hn=new Uint8Array([48,48,48,49]),ea=new Uint8Array([48,48,48,50]);function k(r){let e=typeof r=="string"?Ln.encode(r):r,t=4+e.byteLength;if(t>yr)throw new Error(`pkt-line too long: ${t} bytes (max ${yr})`);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 _(){return Cn.slice()}function K(){return Hn.slice()}function B(...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 lt(r){let e=[],t=0;for(;t<r.byteLength;){if(t+4>r.byteLength)throw new Error("Truncated pkt-line header");let n=mr.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 dt(r){if(r.type!=="data")return"";let e=mr.decode(r.data);return e.endsWith(`
9
9
  `)?e.slice(0,-1):e}var We=65515;function Ge(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(k(`0000000000000000000000000000000000000000 capabilities^{}\0${a}
10
10
  `));else for(let i=0;i<r.length;i++){let o=r[i];i===0?n.push(k(`${o.hash} ${o.name}\0${a}
11
11
  `)):n.push(k(`${o.hash} ${o.name}
@@ -54,16 +54,16 @@ var Le=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(
54
54
  `));a.push(K()),yield B(...a)}if(s&&s.length>0){let a=[];a.push(k(`wanted-refs
55
55
  `));for(let i of s)a.push(k(`${i.hash} ${i.name}
56
56
  `));a.push(K()),yield B(...a)}yield k(`packfile
57
- `);for await(let a of r){let i=0;for(;i<a.byteLength;){let o=Math.min(We,a.byteLength-i);yield ke(1,a.subarray(i,i+o)),i+=o}}yield _()}var D=class extends Error{status=413;constructor(e){super(e),this.name="RequestLimitError"}};function Er(r){async function e(t){let n=r.getForkParent?await r.getForkParent(t):null;return{objectStore:new mt(r,t,n),refStore:new bt(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){if(r.listForks){let n=await r.listForks(t);if(n.length>0)throw new Error(`cannot delete repo '${t}': has ${n.length} active fork(s)`)}await r.deleteRepo(t)},async forkRepo(t,n,s){if(!r.forkRepo||!r.getForkParent||!r.listForks)throw new Error("storage backend does not support forks");if(!await r.hasRepo(t))throw new Error(`source repo '${t}' not found`);if(await r.hasRepo(n))throw new Error(`repo '${n}' already exists`);let f=await r.getForkParent(t)??t;await r.insertRepo(n),await r.forkRepo(f,n);let c=await r.listRefs(t);for(let d of c)await r.putRef(n,d.name,d.ref);let l=await r.getRef(t,"HEAD");if(l)await r.putRef(n,"HEAD",l);else{let d=s?.defaultBranch??"main";await r.putRef(n,"HEAD",{type:"symbolic",target:`refs/heads/${d}`})}return e(n)}}}function qe(r){return typeof r=="object"&&r!==null&&typeof r.preparePack=="function"&&typeof r.commitPack=="function"&&typeof r.deleteObjects=="function"}var mt=class{constructor(e,t,n=null){this.driver=e;this.repoId=t;this.parentId=n}cache=new He;async write(e,t){let n=tr(e,t),s=await Lt(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&&this.parentId&&(n=await this.driver.getObject(this.parentId,e)),!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)?!0:this.parentId?!!await this.driver.hasObject(this.parentId,e):!1}async preparePack(e){if(e.byteLength<32)return[];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[];let i=this.driver,o=this.repoId,f=this.parentId;return(await Jt(e,async l=>{let d=await i.getObject(o,l);return!d&&f&&(d=await i.getObject(f,l)),d?{type:d.type,content:new Uint8Array(d.content)}:null})).map(l=>({hash:l.hash,type:l.type,content:l.content}))}async preparePackStream(e){let t=[];for await(let n of e)t.push({hash:n.hash,type:n.type,content:n.content});return t}async commitPack(e){return e.length===0?0:(await this.driver.putObjects(this.repoId,e),e.length)}async ingestPack(e){let t=await this.preparePack(e);return this.commitPack(t)}async ingestPackStream(e){let t=await this.preparePackStream(e);return this.commitPack(t)}async deleteObjects(e){return e.length===0?0:this.driver.deleteObjects(this.repoId,e)}async findByPrefix(e){if(e.length<4)return[];let t=await this.driver.findObjectsByPrefix(this.repoId,e);if(!this.parentId)return Array.from(t);let n=await this.driver.findObjectsByPrefix(this.parentId,e),s=new Set(t);for(let a of n)s.add(a);return Array.from(s)}},bt=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,ar(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 gt(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=>Ae(s.getRef(e),a=>{let i=a?a.type==="direct"?a.hash:gt(o=>s.getRef(o),a.target):null;return Ae(i,o=>{if(t===null){if(a!==null)return!1}else if(o!==t)return!1;return n===null?Ae(s.removeRef(e),()=>!0):Ae(s.putRef(e,n),()=>!0)})}))}};function Ae(r,e){return r instanceof Promise?r.then(e):e(r)}function gt(r,e,t=0){return t>10?null:Ae(r(e),n=>n?n.type==="direct"?n.hash:n.type==="symbolic"?gt(r,n.target,t+1):null:null)}var se=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}}},Pr=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","shallow"],Or=["report-status","side-band-64k","ofs-delta","delete-refs"];async function Sr(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=te(f.content);n.push({name:`${o.name}^{}`,hash:c.object})}}catch{}return{refs:n,headTarget:a}}var Dn=["refs/heads/main","refs/heads/master"];function Bn(r){for(let t of Dn){let n=r.find(s=>s.name===t);if(n)return n}return r.find(t=>t.name.startsWith("refs/heads/"))??null}function wt(r,e,t){return br(r,e,e==="git-upload-pack"?Pr:Or,t)}function Rt(r,e,t){return Ge(r,e==="git-upload-pack"?Pr:Or,t)}async function W(r,e,t,n,s){let{refs:a,headTarget:i}=await Sr(r),o=a;if(n?.advertiseRefs){let f=await n.advertiseRefs({repo:r,repoId:e,refs:a,service:t,auth:s});if(U(f))return f;f&&(o=f)}return{refs:o,headTarget:i}}function Ee(r){let e=new Map,t=new Set;for(let n of r.refs)e.set(n.name,n.hash),t.add(n.hash);return{allowedRefHashes:e,allowedWantHashes:t}}async function Pe(r,e,t){let{wants:n,haves:s,capabilities:a,clientShallows:i,depth:o,done:f}=gr(e);if(n.length===0)return xe(new Uint8Array(0),!1);if(t?.authorizedFetchSet){for(let x of n)if(!t.authorizedFetchSet.allowedWantHashes.has(x))return{reject:!0,message:`forbidden want ${x}`}}let c=a.includes("multi_ack_detailed"),l=a.includes("side-band-64k"),d,u,h;if(i.length>0&&(h=new Set(i)),o!==void 0){let x=await ft(r,n,o,h??new Set);d=x,u=new Set(x.shallow)}if(d&&!f)return wr(d);let p;if(c&&s.length>0){p=[];for(let x of s)await r.objectStore.exists(x)&&p.push(x);p.length===0&&(p=void 0)}let g=!u&&t?.cache&&t.cacheKey?se.key(t.cacheKey,n,s):null;if(g&&t?.cache){let x=t.cache.get(g);if(x)return xe(x.packData,l,p)}let R=a.includes("include-tag"),P={repo:r,wants:n,haves:s,includeTag:R,shallowBoundary:u,clientShallowBoundary:h,cache:t?.cache,cacheKey:g,deltaWindow:t?.deltaWindow};if(t?.noDelta){let x=await Ir(P);if(!x){let{data:m}=await ee([]);return xe(m,l,p,d)}return Tr(Rr(x,l,p,d))}let A=await jr(P);return xe(A,l,p,d)}async function vr(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=te(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 jr(r){let{repo:e,wants:t,haves:n,includeTag:s,shallowBoundary:a,clientShallowBoundary:i}=r,o=await pr(e,t,n,a,i);if(o.count===0){let{data:p}=await ee([]);return p}let f=await hr(o),c=new Set(f.map(p=>p.hash));if(s){let p=await vr(e,c);f.push(...p)}let l=r.deltaWindow?{window:r.deltaWindow}:void 0,d=ur(f,l),u=d.map(p=>({hash:p.hash,type:p.type,content:p.content,delta:p.delta,deltaBaseHash:p.deltaBase})),{data:h}=await ee(u);if(r.cacheKey&&r.cache){let p=d.filter(g=>g.delta).length;r.cache.set(r.cacheKey,{packData:h,objectCount:f.length,deltaCount:p})}return h}async function Ir(r){let{repo:e,wants:t,haves:n,includeTag:s,shallowBoundary:a,clientShallowBoundary:i}=r,{count:o,objects:f}=await Re(e,t,n,a,i);if(o===0)return null;let c=[];for await(let p of f)c.push(p);let l=new Set(c.map(p=>p.hash)),d=s?await vr(e,l):[],u=c.length+d.length;async function*h(){for(let p of c){let g=await e.objectStore.read(p.hash);yield{type:g.type,content:g.content}}for(let p of d)yield{type:p.type,content:p.content}}return er(u,h())}function Tr(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 Ur(r,e){return await r.commitPack(e),e.map(t=>t.hash)}async function _n(r,e){qe(r.objectStore)&&await r.objectStore.deleteObjects(e)}async function xt(r,e,t){let{commands:n,packData:s,capabilities:a,sawFlush:i}=xr(e),o=!0,f;if(s.byteLength>0)try{if(Mn(s,t),qe(r.objectStore)){let l=await r.objectStore.preparePack(s);f=await Ur(r.objectStore,l)}else await r.objectStore.ingestPack(s)}catch(l){if(l instanceof D)throw l;o=!1}return{updates:await Lr(r,n,o),unpackOk:o,capabilities:a,sawFlush:i,ingestedHashes:f}}async function kt(r,e,t,n,s=!0,a){let i=!0,o;if(e.some(l=>l.newHash!==X))try{let l=async u=>{try{return await r.objectStore.read(u)}catch{return null}},d=Qt(Fn(n,a),l);if(qe(r.objectStore)){let u=await r.objectStore.preparePackStream(d);o=await Ur(r.objectStore,u)}else await r.objectStore.ingestPackStream(d)}catch(l){if(l instanceof D)throw l;i=!1}return{updates:await Lr(r,e,i),unpackOk:i,capabilities:t,sawFlush:s,ingestedHashes:o}}async function Lr(r,e,t){let n=[];for(let s of e){let a=s.oldHash===X,i=s.newHash===X;if(a)n.push({ref:s.refName,oldHash:null,newHash:s.newHash,isFF:!1,isCreate:!0,isDelete:!1});else if(i)n.push({ref:s.refName,oldHash:s.oldHash,newHash:s.newHash,isFF:!1,isCreate:!1,isDelete:!0});else{let o=!1;if(t)try{o=await ot(r,s.oldHash,s.newHash)}catch{}n.push({ref:s.refName,oldHash:s.oldHash,newHash:s.newHash,isFF:o,isCreate:!1,isDelete:!1})}}return n}async function Ve(r,e){let t=[],n=[];for(let s of e){if(s.ref==="HEAD"){t.push({ref:s.ref,ok:!1,error:"HEAD cannot be updated via push"});continue}if(!s.isDelete&&!st(s.ref)){t.push({ref:s.ref,ok:!1,error:"invalid refname"});continue}if(!s.isDelete&&!await r.objectStore.exists(s.newHash)){t.push({ref:s.ref,ok:!1,error:"missing objects"});continue}try{let a=s.isCreate?null:s.oldHash,i=s.isDelete?null:{type:"direct",hash:s.newHash};if(!await r.refStore.compareAndSwapRef(s.ref,a,i)){t.push({ref:s.ref,ok:!1,error:"failed to lock"});continue}t.push({ref:s.ref,ok:!0}),n.push(s)}catch(a){t.push({ref:s.ref,ok:!1,error:a instanceof Error?a.message:String(a)})}}return{refResults:t,applied:n}}async function Oe(r){let{repo:e,repoId:t,ingestResult:n,hooks:s,auth:a}=r,{updates:i}=n;if(s?.preReceive){let c=await s.preReceive({repo:e,repoId:t,updates:i,auth:a});if(U(c)){n.ingestedHashes?.length&&await _n(e,n.ingestedHashes);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&&!st(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,auth:a});if(U(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,auth:a})}catch{}return{refResults:o,applied:f}}async function ze(r,e){let t=[];for(let n of e){let s=n.oldHash!==void 0?n.oldHash:await be(r,n.ref);if(s===null)t.push({ref:n.ref,oldHash:null,newHash:n.newHash??X,isFF:!1,isCreate:!0,isDelete:!1});else if(n.newHash===null)t.push({ref:n.ref,oldHash:s,newHash:X,isFF:!1,isCreate:!1,isDelete:!0});else{let a=!1;try{a=await ot(r,s,n.newHash)}catch{}t.push({ref:n.ref,oldHash:s,newHash:n.newHash,isFF:a,isCreate:!1,isDelete:!1})}}return t}var Nn=["agent=just-git/1.0","ls-refs=unborn","fetch=shallow","server-option","object-format=sha1"];function Se(){return ut(Nn)}async function ve(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 W(r,e,"git-upload-pack",n,s);if(U(c))return c;let{refs:l,headTarget:d}=c,u=[];for(let h of l){if(h.name.endsWith("^{}")||f.length>0&&!f.some(g=>h.name.startsWith(g)))continue;let p={hash:h.hash,name:h.name};if(a&&h.name==="HEAD"&&d&&(p.symrefTarget=d),i&&h.name.startsWith("refs/tags/")){let g=l.find(R=>R.name===`${h.name}^{}`);g&&(p.peeledHash=g.hash)}u.push(p)}return o&&!u.some(h=>h.name==="HEAD")&&d&&(f.length===0||f.some(p=>"HEAD".startsWith(p)))&&u.unshift({hash:"unborn",name:"HEAD",symrefTarget:d}),ht(u)}async function je(r,e,t){let{wants:n,haves:s,done:a,clientShallows:i,depth:o,includeTag:f,wantRefs:c}=yt(e);if(n.length===0&&c.length===0){let{data:y}=await ee([]);return ne(y)}let l=t?.authorizedFetchSet,d=[],u=[...n];for(let y of c)if(l){let w=l.allowedRefHashes.get(y);if(!w)return{reject:!0,message:`forbidden want-ref ${y}`};d.push({hash:w,name:y}),u.includes(w)||u.push(w)}else{let w=await be(r,y);w&&(d.push({hash:w,name:y}),u.includes(w)||u.push(w))}if(l){for(let y of n)if(!l.allowedWantHashes.has(y))return{reject:!0,message:`forbidden want ${y}`}}let h,p,g;if(i.length>0&&(g=new Set(i)),o!==void 0){let y=await ft(r,u,o,g??new Set);h=y,p=new Set(y.shallow)}let R;if(s.length>0){R=[];for(let y of s)await r.objectStore.exists(y)&&R.push(y);R.length===0&&(R=void 0)}let P=R&&R.length>0;if(!a&&!P)return kr(R??[]);let A=!p&&t?.cache&&t.cacheKey?se.key(t.cacheKey,u,s):null,x={commonHashes:R,shallowInfo:h,wantedRefs:d.length>0?d:void 0};if(A&&t?.cache){let y=t.cache.get(A);if(y)return ne(y.packData,x)}let m={repo:r,wants:u,haves:s,includeTag:f,shallowBoundary:p,clientShallowBoundary:g,cache:t?.cache,cacheKey:A,deltaWindow:t?.deltaWindow};if(t?.noDelta){let y=await Ir(m);if(!y){let{data:w}=await ee([]);return ne(w,x)}return Tr(Ar(y,x))}let b=await jr(m);return ne(b,x)}function Mn(r,e){if(e){if(e.maxPackBytes!==void 0&&r.byteLength>e.maxPackBytes)throw new D("Pack payload too large");if(e.maxPackObjects!==void 0&&r.byteLength>=12&&new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(8)>e.maxPackObjects)throw new D("Pack contains too many objects")}}async function*Fn(r,e){if(!e){for await(let a of r)yield a;return}let t=0,n=new Uint8Array(12),s=0;for await(let a of r){if(t+=a.byteLength,e.maxPackBytes!==void 0&&t>e.maxPackBytes)throw new D("Pack payload too large");if(s<12){let i=Math.min(12-s,a.byteLength);if(n.set(a.subarray(0,i),s),s+=i,s===12&&e.maxPackObjects!==void 0&&new DataView(n.buffer).getUint32(8)>e.maxPackObjects)throw new D("Pack contains too many objects")}yield a}}function $n(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 Hr(r,e,t){let{resolveRepo:n,hooks:s,packCache:a,packOptions:i,receiveLimits:o,fetchLimits:f,auth:c}=t,l=e.writable.getWriter();try{let d=$n(r);if(!d)return Ie(e,`fatal: unrecognized command '${r}'
57
+ `);for await(let a of r){let i=0;for(;i<a.byteLength;){let o=Math.min(We,a.byteLength-i);yield ke(1,a.subarray(i,i+o)),i+=o}}yield _()}var D=class extends Error{status=413;constructor(e){super(e),this.name="RequestLimitError"}};function Er(r){async function e(t){let n=r.getForkParent?await r.getForkParent(t):null;return{objectStore:new mt(r,t,n),refStore:new bt(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){if(r.listForks){let n=await r.listForks(t);if(n.length>0)throw new Error(`cannot delete repo '${t}': has ${n.length} active fork(s)`)}await r.deleteRepo(t)},async forkRepo(t,n,s){if(!r.forkRepo||!r.getForkParent||!r.listForks)throw new Error("storage backend does not support forks");if(!await r.hasRepo(t))throw new Error(`source repo '${t}' not found`);if(await r.hasRepo(n))throw new Error(`repo '${n}' already exists`);let f=await r.getForkParent(t)??t;await r.insertRepo(n),await r.forkRepo(f,n);let c=await r.listRefs(t);for(let d of c)await r.putRef(n,d.name,d.ref);let l=await r.getRef(t,"HEAD");if(l)await r.putRef(n,"HEAD",l);else{let d=s?.defaultBranch??"main";await r.putRef(n,"HEAD",{type:"symbolic",target:`refs/heads/${d}`})}return e(n)}}}function qe(r){return typeof r=="object"&&r!==null&&typeof r.preparePack=="function"&&typeof r.commitPack=="function"&&typeof r.deleteObjects=="function"}var mt=class{constructor(e,t,n=null){this.driver=e;this.repoId=t;this.parentId=n}cache=new He;async write(e,t){let n=tr(e,t),s=await Lt(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&&this.parentId&&(n=await this.driver.getObject(this.parentId,e)),!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)?!0:this.parentId?!!await this.driver.hasObject(this.parentId,e):!1}async preparePack(e){if(e.byteLength<32)return[];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[];let i=this.driver,o=this.repoId,f=this.parentId;return(await Jt(e,async l=>{let d=await i.getObject(o,l);return!d&&f&&(d=await i.getObject(f,l)),d?{type:d.type,content:new Uint8Array(d.content)}:null})).map(l=>({hash:l.hash,type:l.type,content:l.content}))}async preparePackStream(e){let t=[];for await(let n of e)t.push({hash:n.hash,type:n.type,content:n.content});return t}async commitPack(e){return e.length===0?0:(await this.driver.putObjects(this.repoId,e),e.length)}async ingestPack(e){let t=await this.preparePack(e);return this.commitPack(t)}async ingestPackStream(e){let t=await this.preparePackStream(e);return this.commitPack(t)}async deleteObjects(e){return e.length===0?0:this.driver.deleteObjects(this.repoId,e)}async findByPrefix(e){if(e.length<4)return[];let t=await this.driver.findObjectsByPrefix(this.repoId,e);if(!this.parentId)return Array.from(t);let n=await this.driver.findObjectsByPrefix(this.parentId,e),s=new Set(t);for(let a of n)s.add(a);return Array.from(s)}},bt=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,ar(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 gt(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=>Ae(s.getRef(e),a=>{let i=a?a.type==="direct"?a.hash:gt(o=>s.getRef(o),a.target):null;return Ae(i,o=>{if(t===null){if(a!==null)return!1}else if(o!==t)return!1;return n===null?Ae(s.removeRef(e),()=>!0):Ae(s.putRef(e,n),()=>!0)})}))}};function Ae(r,e){return r instanceof Promise?r.then(e):e(r)}function gt(r,e,t=0){return t>10?null:Ae(r(e),n=>n?n.type==="direct"?n.hash:n.type==="symbolic"?gt(r,n.target,t+1):null:null)}var se=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}}},Pr=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","shallow"],Or=["report-status","side-band-64k","ofs-delta","delete-refs"];async function Sr(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=te(f.content);n.push({name:`${o.name}^{}`,hash:c.object})}}catch{}return{refs:n,headTarget:a}}var Dn=["refs/heads/main","refs/heads/master"];function Bn(r){for(let t of Dn){let n=r.find(s=>s.name===t);if(n)return n}return r.find(t=>t.name.startsWith("refs/heads/"))??null}function wt(r,e,t){return br(r,e,e==="git-upload-pack"?Pr:Or,t)}function Rt(r,e,t){return Ge(r,e==="git-upload-pack"?Pr:Or,t)}async function W(r,e,t,n,s){let{refs:a,headTarget:i}=await Sr(r),o=a;if(n?.advertiseRefs){let f=await n.advertiseRefs({repo:r,repoId:e,refs:a,service:t,auth:s});if(U(f))return f;f&&(o=f)}return{refs:o,headTarget:i}}function Ee(r){let e=new Map,t=new Set;for(let n of r.refs)e.set(n.name,n.hash),t.add(n.hash);return{allowedRefHashes:e,allowedWantHashes:t}}async function Pe(r,e,t){let{wants:n,haves:s,capabilities:a,clientShallows:i,depth:o,done:f}=gr(e);if(n.length===0)return xe(new Uint8Array(0),!1);if(t?.authorizedFetchSet){for(let x of n)if(!t.authorizedFetchSet.allowedWantHashes.has(x))return{reject:!0,message:`forbidden want ${x}`}}let c=a.includes("multi_ack_detailed"),l=a.includes("side-band-64k"),d,u,h;if(i.length>0&&(h=new Set(i)),o!==void 0){let x=await ft(r,n,o,h??new Set);d=x,u=new Set(x.shallow)}if(d&&!f)return wr(d);let p;if(c&&s.length>0){p=[];for(let x of s)await r.objectStore.exists(x)&&p.push(x);p.length===0&&(p=void 0)}let g=!u&&t?.cache&&t.cacheKey?se.key(t.cacheKey,n,s):null;if(g&&t?.cache){let x=t.cache.get(g);if(x)return xe(x.packData,l,p)}let R=a.includes("include-tag"),P={repo:r,wants:n,haves:s,includeTag:R,shallowBoundary:u,clientShallowBoundary:h,cache:t?.cache,cacheKey:g,deltaWindow:t?.deltaWindow};if(t?.noDelta){let x=await Ir(P);if(!x){let{data:m}=await ee([]);return xe(m,l,p,d)}return Tr(Rr(x,l,p,d))}let A=await jr(P);return xe(A,l,p,d)}async function vr(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=te(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 jr(r){let{repo:e,wants:t,haves:n,includeTag:s,shallowBoundary:a,clientShallowBoundary:i}=r,o=await pr(e,t,n,a,i);if(o.count===0){let{data:p}=await ee([]);return p}let f=await hr(o),c=new Set(f.map(p=>p.hash));if(s){let p=await vr(e,c);f.push(...p)}let l=r.deltaWindow?{window:r.deltaWindow}:void 0,d=ur(f,l),u=d.map(p=>({hash:p.hash,type:p.type,content:p.content,delta:p.delta,deltaBaseHash:p.deltaBase})),{data:h}=await ee(u);if(r.cacheKey&&r.cache){let p=d.filter(g=>g.delta).length;r.cache.set(r.cacheKey,{packData:h,objectCount:f.length,deltaCount:p})}return h}async function Ir(r){let{repo:e,wants:t,haves:n,includeTag:s,shallowBoundary:a,clientShallowBoundary:i}=r,{count:o,objects:f}=await Re(e,t,n,a,i);if(o===0)return null;let c=[];for await(let p of f)c.push(p);let l=new Set(c.map(p=>p.hash)),d=s?await vr(e,l):[],u=c.length+d.length;async function*h(){for(let p of c){let g=await e.objectStore.read(p.hash);yield{type:g.type,content:g.content}}for(let p of d)yield{type:p.type,content:p.content}}return er(u,h())}function Tr(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 Ur(r,e){return await r.commitPack(e),e.map(t=>t.hash)}async function _n(r,e){qe(r.objectStore)&&await r.objectStore.deleteObjects(e)}async function xt(r,e,t){let{commands:n,packData:s,capabilities:a,sawFlush:i}=xr(e),o=!0,f;if(s.byteLength>0)try{if(Fn(s,t),qe(r.objectStore)){let l=await r.objectStore.preparePack(s);f=await Ur(r.objectStore,l)}else await r.objectStore.ingestPack(s)}catch(l){if(l instanceof D)throw l;o=!1}return{updates:await Lr(r,n,o),unpackOk:o,capabilities:a,sawFlush:i,ingestedHashes:f}}async function kt(r,e,t,n,s=!0,a){let i=!0,o;if(e.some(l=>l.newHash!==X))try{let l=async u=>{try{return await r.objectStore.read(u)}catch{return null}},d=Qt(Mn(n,a),l);if(qe(r.objectStore)){let u=await r.objectStore.preparePackStream(d);o=await Ur(r.objectStore,u)}else await r.objectStore.ingestPackStream(d)}catch(l){if(l instanceof D)throw l;i=!1}return{updates:await Lr(r,e,i),unpackOk:i,capabilities:t,sawFlush:s,ingestedHashes:o}}async function Lr(r,e,t){let n=[];for(let s of e){let a=s.oldHash===X,i=s.newHash===X;if(a)n.push({ref:s.refName,oldHash:null,newHash:s.newHash,isFF:!1,isCreate:!0,isDelete:!1});else if(i)n.push({ref:s.refName,oldHash:s.oldHash,newHash:s.newHash,isFF:!1,isCreate:!1,isDelete:!0});else{let o=!1;if(t)try{o=await ot(r,s.oldHash,s.newHash)}catch{}n.push({ref:s.refName,oldHash:s.oldHash,newHash:s.newHash,isFF:o,isCreate:!1,isDelete:!1})}}return n}async function Ve(r,e){let t=[],n=[];for(let s of e){if(s.ref==="HEAD"){t.push({ref:s.ref,ok:!1,error:"HEAD cannot be updated via push"});continue}if(!s.isDelete&&!st(s.ref)){t.push({ref:s.ref,ok:!1,error:"invalid refname"});continue}if(!s.isDelete&&!await r.objectStore.exists(s.newHash)){t.push({ref:s.ref,ok:!1,error:"missing objects"});continue}try{let a=s.isCreate?null:s.oldHash,i=s.isDelete?null:{type:"direct",hash:s.newHash};if(!await r.refStore.compareAndSwapRef(s.ref,a,i)){t.push({ref:s.ref,ok:!1,error:"failed to lock"});continue}t.push({ref:s.ref,ok:!0}),n.push(s)}catch(a){t.push({ref:s.ref,ok:!1,error:a instanceof Error?a.message:String(a)})}}return{refResults:t,applied:n}}async function Oe(r){let{repo:e,repoId:t,ingestResult:n,hooks:s,auth:a}=r,{updates:i}=n;if(s?.preReceive){let c=await s.preReceive({repo:e,repoId:t,updates:i,auth:a});if(U(c)){n.ingestedHashes?.length&&await _n(e,n.ingestedHashes);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&&!st(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,auth:a});if(U(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,auth:a})}catch{}return{refResults:o,applied:f}}async function ze(r,e){let t=[];for(let n of e){let s=n.oldHash!==void 0?n.oldHash:await be(r,n.ref);if(s===null)t.push({ref:n.ref,oldHash:null,newHash:n.newHash??X,isFF:!1,isCreate:!0,isDelete:!1});else if(n.newHash===null)t.push({ref:n.ref,oldHash:s,newHash:X,isFF:!1,isCreate:!1,isDelete:!0});else{let a=!1;try{a=await ot(r,s,n.newHash)}catch{}t.push({ref:n.ref,oldHash:s,newHash:n.newHash,isFF:a,isCreate:!1,isDelete:!1})}}return t}var Nn=["agent=just-git/1.0","ls-refs=unborn","fetch=shallow","server-option","object-format=sha1"];function Se(){return ut(Nn)}async function ve(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 W(r,e,"git-upload-pack",n,s);if(U(c))return c;let{refs:l,headTarget:d}=c,u=[];for(let h of l){if(h.name.endsWith("^{}")||f.length>0&&!f.some(g=>h.name.startsWith(g)))continue;let p={hash:h.hash,name:h.name};if(a&&h.name==="HEAD"&&d&&(p.symrefTarget=d),i&&h.name.startsWith("refs/tags/")){let g=l.find(R=>R.name===`${h.name}^{}`);g&&(p.peeledHash=g.hash)}u.push(p)}return o&&!u.some(h=>h.name==="HEAD")&&d&&(f.length===0||f.some(p=>"HEAD".startsWith(p)))&&u.unshift({hash:"unborn",name:"HEAD",symrefTarget:d}),ht(u)}async function je(r,e,t){let{wants:n,haves:s,done:a,clientShallows:i,depth:o,includeTag:f,wantRefs:c}=yt(e);if(n.length===0&&c.length===0){let{data:y}=await ee([]);return ne(y)}let l=t?.authorizedFetchSet,d=[],u=[...n];for(let y of c)if(l){let w=l.allowedRefHashes.get(y);if(!w)return{reject:!0,message:`forbidden want-ref ${y}`};d.push({hash:w,name:y}),u.includes(w)||u.push(w)}else{let w=await be(r,y);w&&(d.push({hash:w,name:y}),u.includes(w)||u.push(w))}if(l){for(let y of n)if(!l.allowedWantHashes.has(y))return{reject:!0,message:`forbidden want ${y}`}}let h,p,g;if(i.length>0&&(g=new Set(i)),o!==void 0){let y=await ft(r,u,o,g??new Set);h=y,p=new Set(y.shallow)}let R;if(s.length>0){R=[];for(let y of s)await r.objectStore.exists(y)&&R.push(y);R.length===0&&(R=void 0)}let P=R&&R.length>0;if(!a&&!P)return kr(R??[]);let A=!p&&t?.cache&&t.cacheKey?se.key(t.cacheKey,u,s):null,x={commonHashes:R,shallowInfo:h,wantedRefs:d.length>0?d:void 0};if(A&&t?.cache){let y=t.cache.get(A);if(y)return ne(y.packData,x)}let m={repo:r,wants:u,haves:s,includeTag:f,shallowBoundary:p,clientShallowBoundary:g,cache:t?.cache,cacheKey:A,deltaWindow:t?.deltaWindow};if(t?.noDelta){let y=await Ir(m);if(!y){let{data:w}=await ee([]);return ne(w,x)}return Tr(Ar(y,x))}let b=await jr(m);return ne(b,x)}function Fn(r,e){if(e){if(e.maxPackBytes!==void 0&&r.byteLength>e.maxPackBytes)throw new D("Pack payload too large");if(e.maxPackObjects!==void 0&&r.byteLength>=12&&new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(8)>e.maxPackObjects)throw new D("Pack contains too many objects")}}async function*Mn(r,e){if(!e){for await(let a of r)yield a;return}let t=0,n=new Uint8Array(12),s=0;for await(let a of r){if(t+=a.byteLength,e.maxPackBytes!==void 0&&t>e.maxPackBytes)throw new D("Pack payload too large");if(s<12){let i=Math.min(12-s,a.byteLength);if(n.set(a.subarray(0,i),s),s+=i,s===12&&e.maxPackObjects!==void 0&&new DataView(n.buffer).getUint32(8)>e.maxPackObjects)throw new D("Pack contains too many objects")}yield a}}function $n(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 Hr(r,e,t){let{resolveRepo:n,hooks:s,packCache:a,packOptions:i,receiveLimits:o,fetchLimits:f,auth:c}=t,l=e.writable.getWriter();try{let d=$n(r);if(!d)return Ie(e,`fatal: unrecognized command '${r}'
58
58
  `),128;let{service:u,repoPath:h}=d,p=await n(h);if(!p)return Ie(e,`fatal: '${h}' does not appear to be a git repository
59
59
  `),128;let{repo:g,repoId:R}=p;if(d.protocolV2&&u==="git-upload-pack"){let x=await W(g,R,u,s,c);if(U(x))return ae(e,x);await l.write(Se());let m=new Ke(e.readable);try{return await zn(m,l,g,R,e,{hooks:s,packCache:a,packOptions:i,receiveLimits:o,fetchLimits:f,auth:c})}finally{m.release()}}let P=await W(g,R,u,s,c);if(U(P))return ae(e,P);await l.write(Rt(P.refs,u,P.headTarget));let A=new Ke(e.readable);try{if(u==="git-upload-pack"){let x=s?.advertiseRefs?Ee(P):void 0,m=await qn(A,f?.maxRequestBytes),b=await Pe(g,m,{cache:a,cacheKey:R,noDelta:i?.noDelta,deltaWindow:i?.deltaWindow,authorizedFetchSet:x});if(U(b))return ae(e,b);await Dr(l,b)}else{let{commands:x,capabilities:m}=await Vn(A),b=A.streamRemaining();await Gn({writer:l,repo:g,repoId:R,commands:x,capabilities:m,packStream:b,hooks:s,receiveLimits:o,auth:c})}}finally{A.release()}return 0}catch(d){return d instanceof D?(Ie(e,`fatal: ${d.message}
60
60
  `),128):(t.onError?.(d),Ie(e,`fatal: internal error
61
61
  `),128)}finally{try{await l.close()}catch{}}}async function Gn(r){let{writer:e,repo:t,repoId:n,commands:s,capabilities:a,packStream:i,hooks:o,receiveLimits:f,auth:c}=r,l=await kt(t,s,a,i,!0,f);if(l.updates.length===0)return;let d=l.capabilities.includes("side-band-64k"),u=l.capabilities.includes("report-status");if(!l.unpackOk){if(u){let p=l.updates.map(g=>({name:g.ref,ok:!1,error:"unpack failed"}));await e.write(re(!1,p,d))}return}let{refResults:h}=await Oe({repo:t,repoId:n,ingestResult:l,hooks:o,auth:c});if(u){let p=h.map(g=>({name:g.ref,ok:g.ok,error:g.error}));await e.write(re(!0,p,d))}}function Ie(r,e){r.writeStderr?.(Wn.encode(e))}function ae(r,e){return Ie(r,`fatal: ${e.message??"access denied"}
62
62
  `),128}var Cr=new TextDecoder,Ke=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=Cr.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:Cr.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 qn(r,e){let t=[],n=0;for(;;){let s=await r.readPktLine();if(!s)break;if(n+=s.raw.byteLength,e!==void 0&&n>e)throw new D("Request body too large");if(t.push(s.raw),s.type==="data"&&s.text.trimEnd()==="done")break}return Xn(t)}async function Vn(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(`
63
63
  `)&&(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 zn(r,e,t,n,s,a){let{hooks:i,packCache:o,packOptions:f,fetchLimits:c,auth:l}=a;for(;;){let d=await Kn(r,c?.maxRequestBytes);if(!d)break;if(d.command==="ls-refs"){let u=await ve(t,n,d.args,i,l);if(U(u))return ae(s,u);await e.write(u)}else if(d.command==="fetch"){let u;if(i?.advertiseRefs){let p=await W(t,n,"git-upload-pack",i,l);if(U(p))return ae(s,p);u=Ee(p)}let h=await je(t,d.args,{cache:o,cacheKey:n,noDelta:f?.noDelta,deltaWindow:f?.deltaWindow,authorizedFetchSet:u});if(U(h))return ae(s,h);await Dr(e,h)}else break}return 0}async function Kn(r,e){let t="",n=[],s=[],a=!1,i=!1,o=0;for(;;){let f=await r.readPktLine();if(!f)return i?{command:t,capabilities:n,args:s}:null;if(f.type==="flush"){if(!i)return null;break}if(f.type==="response-end")break;if(o+=f.raw.byteLength,e!==void 0&&o>e)throw new D("Request body too large");if(f.type==="delim"){a=!0;continue}i=!0;let c=f.text;c.endsWith(`
64
- `)&&(c=c.slice(0,-1)),a?s.push(c):c.startsWith("command=")?t=c.slice(8):n.push(c)}return t?{command:t,capabilities:n,args:s}:null}function Xn(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 Dr(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 _r(r,e,t,n,s){let a=n?.dryRun??!1,i=await Br(r),o=Yn(i);if(s)for(let p of s)o.push(p);if(o.length===0)return{deleted:0,retained:0};let f=await Re(r,o,[]),c=new Set;for await(let p of f.objects)c.add(p.hash);let l=await e.listObjectHashes(t),d=[];for(let p of l)c.has(p)||d.push(p);let u=await Br(r);return Zn(i,u)?a||d.length===0?{deleted:d.length,retained:c.size}:{deleted:await e.deleteObjects(t,d),retained:c.size}:{deleted:0,retained:c.size,aborted:!0}}async function Br(r){return r.refStore.listRefs()}function Yn(r){let e=new Set;for(let t of r)e.add(t.hash);return Array.from(e)}function Zn(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}var Te=class{repos=new Set;objects=new Map;refs=new Map;forks=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),this.forks.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)}})}forkRepo(e,t){this.forks.set(t,e)}getForkParent(e){return this.forks.get(e)??null}listForks(e){let t=[];for(let[n,s]of this.forks)s===e&&t.push(n);return t}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 Nr=new WeakMap,Jn={http:r=>({transport:"http",request:r}),ssh:r=>({transport:"ssh",username:r.username})};function Mr(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 Qn(r={}){let e=r.storage??new Te,t=Er(e),n=r.resolve??(m=>m),s=r.autoCreate,{basePath:a}=r,i={maxRequestBytes:128*1024*1024,maxInflatedBytes:256*1024*1024,maxPackBytes:128*1024*1024,maxPackObjects:25e4,...r.receiveLimits},o={maxRequestBytes:10*1024*1024,maxInflatedBytes:20*1024*1024,...r.fetchLimits};async function f(m){if(!Mr(m))return null;let b=await n(m);if(b==null||b!==m&&!Mr(b))return null;let y=await t.repo(b);if(y)return{repo:y,repoId:b};if(!s)return null;let w=typeof s=="object"?{defaultBranch:s.defaultBranch}:void 0;return{repo:await t.createRepo(b,w),repoId:b}}let c=rs(r.policy,r.hooks),l=r.auth??Jn,d=r.packCache===!1?void 0:new se(r.packCache?.maxBytes),u=r.onError===!1?void 0:r.onError??(m=>{let b=m instanceof Error?m.message:String(m);console.error(`[server] Internal error: ${b}`)}),h=!1,p=0,g=null,R=null;function P(){return h?!1:(p++,!0)}function A(){p--,h&&p===0&&g?.()}let x={async fetch(m){if(!P())return new Response("Service Unavailable",{status:503});let b;try{let y=Nr.get(m);if(y!==void 0)b=y;else{if(!l.http)return new Response("HTTP auth provider not configured",{status:501});let E=await l.http(m);if(E instanceof Response)return E;b=E}let w=new URL(m.url),O=decodeURIComponent(w.pathname);if(a){let E=a.replace(/\/+$/,"");if(!O.startsWith(E))return new Response("Not Found",{status:404});O=O.slice(E.length)}if(O.startsWith("/")||(O=`/${O}`),O.endsWith("/info/refs")&&m.method==="GET"){let E=w.searchParams.get("service");if(E!=="git-upload-pack"&&E!=="git-receive-pack")return new Response("Unsupported service",{status:403});let S=At(O,"/info/refs"),j=await f(S);if(!j)return new Response("Not Found",{status:404});if(Fr(m)&&E==="git-upload-pack"){let F=await W(j.repo,j.repoId,E,c,b);if(U(F))return ie(F);let T=Se();return new Response(T,{headers:{"Content-Type":`application/x-${E}-advertisement`,"Cache-Control":"no-cache"}})}let L=await W(j.repo,j.repoId,E,c,b);if(U(L))return ie(L);let H=wt(L.refs,E,L.headTarget);return new Response(H,{headers:{"Content-Type":`application/x-${E}-advertisement`,"Cache-Control":"no-cache"}})}if(O.endsWith("/git-upload-pack")&&m.method==="POST"){let E=At(O,"/git-upload-pack"),S=await f(E);if(!S)return new Response("Not Found",{status:404});let j;if(c?.advertiseRefs){let H=await W(S.repo,S.repoId,"git-upload-pack",c,b);if(U(H))return ie(H);j=Ee(H)}let v=await $r(m,o);if(Fr(m)){let H=pt(v),F="application/x-git-upload-pack-result";if(H.command==="ls-refs"){let T=await ve(S.repo,S.repoId,H.args,c,b);return U(T)?ie(T):new Response(T,{headers:{"Content-Type":F}})}if(H.command==="fetch"){let T=await je(S.repo,H.args,{cache:d,cacheKey:S.repoId,noDelta:r.packOptions?.noDelta,deltaWindow:r.packOptions?.deltaWindow,authorizedFetchSet:j});return U(T)?ie(T):new Response(T,{headers:{"Content-Type":F}})}return new Response(`unknown command: ${H.command}`,{status:400})}let L=await Pe(S.repo,v,{cache:d,cacheKey:S.repoId,noDelta:r.packOptions?.noDelta,deltaWindow:r.packOptions?.deltaWindow,authorizedFetchSet:j});return U(L)?ie(L):new Response(L,{headers:{"Content-Type":"application/x-git-upload-pack-result"}})}if(O.endsWith("/git-receive-pack")&&m.method==="POST"){let E=At(O,"/git-receive-pack"),S=await f(E);if(!S)return new Response("Not Found",{status:404});let j=await $r(m,i),v=await xt(S.repo,j,i);if(!v.sawFlush&&v.updates.length===0)return new Response("Bad Request",{status:400});let L=v.capabilities.includes("side-band-64k"),H=v.capabilities.includes("report-status");if(!v.unpackOk){if(H){let T=v.updates.map(G=>({name:G.ref,ok:!1,error:"unpack failed"}));return new Response(re(!1,T,L),{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:F}=await Oe({repo:S.repo,repoId:S.repoId,ingestResult:v,hooks:c,auth:b});if(H){let T=F.map(G=>({name:G.ref,ok:G.ok,error:G.error}));return new Response(re(!0,T,L),{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(y){return y instanceof D?new Response(y.message,{status:y.status}):(u?.(y,b),new Response("Internal Server Error",{status:500}))}finally{A()}},async handleSession(m,b,y){if(!P())return b.writeStderr?.(new TextEncoder().encode(`fatal: server shutting down
64
+ `)&&(c=c.slice(0,-1)),a?s.push(c):c.startsWith("command=")?t=c.slice(8):n.push(c)}return t?{command:t,capabilities:n,args:s}:null}function Xn(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 Dr(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 _r(r,e,t,n,s){let a=n?.dryRun??!1,i=await Br(r),o=Yn(i);if(s)for(let p of s)o.push(p);if(o.length===0)return{deleted:0,retained:0};let f=await Re(r,o,[]),c=new Set;for await(let p of f.objects)c.add(p.hash);let l=await e.listObjectHashes(t),d=[];for(let p of l)c.has(p)||d.push(p);let u=await Br(r);return Zn(i,u)?a||d.length===0?{deleted:d.length,retained:c.size}:{deleted:await e.deleteObjects(t,d),retained:c.size}:{deleted:0,retained:c.size,aborted:!0}}async function Br(r){return r.refStore.listRefs()}function Yn(r){let e=new Set;for(let t of r)e.add(t.hash);return Array.from(e)}function Zn(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}var Te=class{repos=new Set;objects=new Map;refs=new Map;forks=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),this.forks.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)}})}forkRepo(e,t){this.forks.set(t,e)}getForkParent(e){return this.forks.get(e)??null}listForks(e){let t=[];for(let[n,s]of this.forks)s===e&&t.push(n);return t}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 Nr=new WeakMap,Jn={http:r=>({transport:"http",request:r}),ssh:r=>({transport:"ssh",username:r.username})};function Fr(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 Qn(r={}){let e=r.storage??new Te,t=Er(e),n=r.resolve??(m=>m),s=r.autoCreate,{basePath:a}=r,i={maxRequestBytes:128*1024*1024,maxInflatedBytes:256*1024*1024,maxPackBytes:128*1024*1024,maxPackObjects:25e4,...r.receiveLimits},o={maxRequestBytes:10*1024*1024,maxInflatedBytes:20*1024*1024,...r.fetchLimits};async function f(m){if(!Fr(m))return null;let b=await n(m);if(b==null||b!==m&&!Fr(b))return null;let y=await t.repo(b);if(y)return{repo:y,repoId:b};if(!s)return null;let w=typeof s=="object"?{defaultBranch:s.defaultBranch}:void 0;return{repo:await t.createRepo(b,w),repoId:b}}let c=rs(r.policy,r.hooks),l=r.auth??Jn,d=r.packCache===!1?void 0:new se(r.packCache?.maxBytes),u=r.onError===!1?void 0:r.onError??(m=>{let b=m instanceof Error?m.message:String(m);console.error(`[server] Internal error: ${b}`)}),h=!1,p=0,g=null,R=null;function P(){return h?!1:(p++,!0)}function A(){p--,h&&p===0&&g?.()}let x={async fetch(m){if(!P())return new Response("Service Unavailable",{status:503});let b;try{let y=Nr.get(m);if(y!==void 0)b=y;else{if(!l.http)return new Response("HTTP auth provider not configured",{status:501});let E=await l.http(m);if(E instanceof Response)return E;b=E}let w=new URL(m.url),O=decodeURIComponent(w.pathname);if(a){let E=a.replace(/\/+$/,"");if(!O.startsWith(E))return new Response("Not Found",{status:404});O=O.slice(E.length)}if(O.startsWith("/")||(O=`/${O}`),O.endsWith("/info/refs")&&m.method==="GET"){let E=w.searchParams.get("service");if(E!=="git-upload-pack"&&E!=="git-receive-pack")return new Response("Unsupported service",{status:403});let S=At(O,"/info/refs"),j=await f(S);if(!j)return new Response("Not Found",{status:404});if(Mr(m)&&E==="git-upload-pack"){let M=await W(j.repo,j.repoId,E,c,b);if(U(M))return ie(M);let T=Se();return new Response(T,{headers:{"Content-Type":`application/x-${E}-advertisement`,"Cache-Control":"no-cache"}})}let L=await W(j.repo,j.repoId,E,c,b);if(U(L))return ie(L);let H=wt(L.refs,E,L.headTarget);return new Response(H,{headers:{"Content-Type":`application/x-${E}-advertisement`,"Cache-Control":"no-cache"}})}if(O.endsWith("/git-upload-pack")&&m.method==="POST"){let E=At(O,"/git-upload-pack"),S=await f(E);if(!S)return new Response("Not Found",{status:404});let j;if(c?.advertiseRefs){let H=await W(S.repo,S.repoId,"git-upload-pack",c,b);if(U(H))return ie(H);j=Ee(H)}let v=await $r(m,o);if(Mr(m)){let H=pt(v),M="application/x-git-upload-pack-result";if(H.command==="ls-refs"){let T=await ve(S.repo,S.repoId,H.args,c,b);return U(T)?ie(T):new Response(T,{headers:{"Content-Type":M}})}if(H.command==="fetch"){let T=await je(S.repo,H.args,{cache:d,cacheKey:S.repoId,noDelta:r.packOptions?.noDelta,deltaWindow:r.packOptions?.deltaWindow,authorizedFetchSet:j});return U(T)?ie(T):new Response(T,{headers:{"Content-Type":M}})}return new Response(`unknown command: ${H.command}`,{status:400})}let L=await Pe(S.repo,v,{cache:d,cacheKey:S.repoId,noDelta:r.packOptions?.noDelta,deltaWindow:r.packOptions?.deltaWindow,authorizedFetchSet:j});return U(L)?ie(L):new Response(L,{headers:{"Content-Type":"application/x-git-upload-pack-result"}})}if(O.endsWith("/git-receive-pack")&&m.method==="POST"){let E=At(O,"/git-receive-pack"),S=await f(E);if(!S)return new Response("Not Found",{status:404});let j=await $r(m,i),v=await xt(S.repo,j,i);if(!v.sawFlush&&v.updates.length===0)return new Response("Bad Request",{status:400});let L=v.capabilities.includes("side-band-64k"),H=v.capabilities.includes("report-status");if(!v.unpackOk){if(H){let T=v.updates.map(G=>({name:G.ref,ok:!1,error:"unpack failed"}));return new Response(re(!1,T,L),{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:M}=await Oe({repo:S.repo,repoId:S.repoId,ingestResult:v,hooks:c,auth:b});if(H){let T=M.map(G=>({name:G.ref,ok:G.ok,error:G.error}));return new Response(re(!0,T,L),{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(y){return y instanceof D?new Response(y.message,{status:y.status}):(u?.(y,b),new Response("Internal Server Error",{status:500}))}finally{A()}},async handleSession(m,b,y){if(!P())return b.writeStderr?.(new TextEncoder().encode(`fatal: server shutting down
65
65
  `)),128;try{if(!l.ssh)return b.writeStderr?.(new TextEncoder().encode(`fatal: SSH auth provider not configured
66
- `)),128;let w=await l.ssh(y??{});return await Hr(m,b,{resolveRepo:f,hooks:c,packCache:d,packOptions:r.packOptions,receiveLimits:i,fetchLimits:o,auth:w,onError:u?O=>u(O,w):void 0})}finally{A()}},async updateRefs(m,b){if(!P())throw new Error("Server is shutting down");try{let y=await x.requireRepo(m),w=await ze(y,b);return Ve(y,w)}finally{A()}},async commit(m,b){if(!P())throw new Error("Server is shutting down");try{let y=await x.requireRepo(m),w=await cr(y,b),O=`refs/heads/${b.branch}`,E=await ze(y,[{ref:O,newHash:w.hash,oldHash:w.parentHash}]),j=(await Ve(y,E)).refResults[0];if(!j?.ok)throw new Error(j?.error??"ref update failed");return w}finally{A()}},nodeHandler(m,b){let y=[],w=0,O=!1,j=new URL(m.url??"/","http://localhost").pathname.endsWith("/git-upload-pack")?o.maxRequestBytes:i.maxRequestBytes;m.on("data",v=>{if(!O){if(w+=v.byteLength,m.method!=="GET"&&m.method!=="HEAD"&&j!==void 0&&w>j){O=!0,y.length=0,b.writeHead(413),b.end("Request body too large");try{m.destroy?.()}catch{}return}y.push(new Uint8Array(v))}}),m.on("error",()=>{b.writeHead(500),b.end("Internal Server Error")}),m.on("end",()=>{O||es(x,m,y,b).catch(()=>{try{b.writeHead(500),b.end("Internal Server Error")}catch{}})})},createRepo:(m,b)=>t.createRepo(m,b),repo:m=>t.repo(m),async requireRepo(m){let b=await t.repo(m);if(!b)throw new Error(`Repository "${m}" not found`);return b},deleteRepo:m=>t.deleteRepo(m),async forkRepo(m,b,y){if(!P())throw new Error("Server is shutting down");try{return await t.forkRepo(m,b,y)}finally{A()}},async gc(m,b){if(!P())throw new Error("Server is shutting down");try{let y=await x.requireRepo(m),w;if(e.listForks&&e.getForkParent&&!await e.getForkParent(m)){let E=await e.listForks(m);if(E.length>0){w=[];for(let S of E){let j=await t.repo(S);if(!j)continue;let v=await j.refStore.listRefs();for(let L of v)w.push(L.hash)}}}return _r(y,e,m,b,w)}finally{A()}},get closed(){return h},asNetwork(m="http://git",b){return{allowed:[m.endsWith("/")?m:`${m}/`],fetch:(w,O)=>{let E=new Request(w,O);return b!==void 0&&Nr.set(E,b),x.fetch(E)}}},async close(m){if(h)return R??Promise.resolve();if(h=!0,d?.clear(),p!==0){if(R=new Promise(b=>{g=b}),m?.signal){if(m.signal.aborted){g();return}let b=()=>g?.();m.signal.addEventListener("abort",b,{once:!0}),R.then(()=>m.signal.removeEventListener("abort",b))}return R}}};return x}function ie(r){return new Response(r.message??"Forbidden",{status:403})}function Fr(r){let e=r.headers.get("git-protocol");return e!==null&&e.includes("version=2")}function At(r,e){let t=r.slice(0,-e.length);return t.startsWith("/")&&(t=t.slice(1)),t}async function $r(r,e){let t=r.headers.get("content-length");if(t){let a=Number(t);if(Number.isFinite(a)&&e.maxRequestBytes!==void 0&&a>e.maxRequestBytes)throw new D("Request body too large")}let n=await Wr(r.body,e.maxRequestBytes,"Request body too large"),s=r.headers.get("content-encoding");if(s==="gzip"||s==="x-gzip"){let a=new DecompressionStream("gzip"),i=a.writable.getWriter(),o=new Uint8Array(n.byteLength);return o.set(n),await i.write(o),await i.close(),Wr(a.readable,e.maxInflatedBytes,"Decompressed body too large")}return n}async function Wr(r,e,t){if(!r)return new Uint8Array(0);let n=r.getReader(),s=[],a=0;try{for(;;){let{value:f,done:c}=await n.read();if(c)break;if(f){if(a+=f.byteLength,e!==void 0&&a>e)throw new D(t);s.push(f)}}}finally{n.releaseLock()}if(s.length===0)return new Uint8Array(0);let i=new Uint8Array(a),o=0;for(let f of s)i.set(f,o),o+=f.byteLength;return i}async function es(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,p]of Object.entries(e.headers))if(p!==void 0)if(Array.isArray(p))for(let g of p)i.append(h,g);else i.set(h,p);let o=e.method??"GET",f;if(o!=="GET"&&o!=="HEAD"){let h=0;for(let R of t)h+=R.byteLength;let p=new Uint8Array(h),g=0;for(let R of t)p.set(R,g),g+=R.byteLength;f=p}let c=new Request(a.href,{method:o,headers:i,body:f}),l=await r.fetch(c),d={};l.headers.forEach((h,p)=>{d[p]=h}),n.writeHead(l.status,d);let u=new Uint8Array(await l.arrayBuffer());u.byteLength>0&&n.write(u),n.end()}function ts(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 rs(r,e){let t=r?ts(r):void 0;return t&&e?Gr(t,e):t??e}function Gr(...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(U(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(U(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(U(l))return l;l&&(f=l)}return f}),t}var ns=`
66
+ `)),128;let w=await l.ssh(y??{});return await Hr(m,b,{resolveRepo:f,hooks:c,packCache:d,packOptions:r.packOptions,receiveLimits:i,fetchLimits:o,auth:w,onError:u?O=>u(O,w):void 0})}finally{A()}},async updateRefs(m,b){if(!P())throw new Error("Server is shutting down");try{let y=await x.requireRepo(m),w=await ze(y,b);return Ve(y,w)}finally{A()}},async commit(m,b){if(!P())throw new Error("Server is shutting down");try{let y=await x.requireRepo(m),w=await cr(y,b),O=`refs/heads/${b.branch}`,E=await ze(y,[{ref:O,newHash:w.hash,oldHash:w.parentHash}]),j=(await Ve(y,E)).refResults[0];if(!j?.ok)throw new Error(j?.error??"ref update failed");return w}finally{A()}},nodeHandler(m,b){let y=[],w=0,O=!1,j=new URL(m.url??"/","http://localhost").pathname.endsWith("/git-upload-pack")?o.maxRequestBytes:i.maxRequestBytes;m.on("data",v=>{if(!O){if(w+=v.byteLength,m.method!=="GET"&&m.method!=="HEAD"&&j!==void 0&&w>j){O=!0,y.length=0,b.writeHead(413),b.end("Request body too large");try{m.destroy?.()}catch{}return}y.push(new Uint8Array(v))}}),m.on("error",()=>{b.writeHead(500),b.end("Internal Server Error")}),m.on("end",()=>{O||es(x,m,y,b).catch(()=>{try{b.writeHead(500),b.end("Internal Server Error")}catch{}})})},createRepo:(m,b)=>t.createRepo(m,b),repo:m=>t.repo(m),async requireRepo(m){let b=await t.repo(m);if(!b)throw new Error(`Repository "${m}" not found`);return b},deleteRepo:m=>t.deleteRepo(m),async forkRepo(m,b,y){if(!P())throw new Error("Server is shutting down");try{return await t.forkRepo(m,b,y)}finally{A()}},async gc(m,b){if(!P())throw new Error("Server is shutting down");try{let y=await x.requireRepo(m),w;if(e.listForks&&e.getForkParent&&!await e.getForkParent(m)){let E=await e.listForks(m);if(E.length>0){w=[];for(let S of E){let j=await t.repo(S);if(!j)continue;let v=await j.refStore.listRefs();for(let L of v)w.push(L.hash)}}}return _r(y,e,m,b,w)}finally{A()}},get closed(){return h},asNetwork(m="http://git",b){return{allowed:[m.endsWith("/")?m:`${m}/`],fetch:(w,O)=>{let E=new Request(w,O);return b!==void 0&&Nr.set(E,b),x.fetch(E)}}},async close(m){if(h)return R??Promise.resolve();if(h=!0,d?.clear(),p!==0){if(R=new Promise(b=>{g=b}),m?.signal){if(m.signal.aborted){g();return}let b=()=>g?.();m.signal.addEventListener("abort",b,{once:!0}),R.then(()=>m.signal.removeEventListener("abort",b))}return R}}};return x}function ie(r){return new Response(r.message??"Forbidden",{status:403})}function Mr(r){let e=r.headers.get("git-protocol");return e!==null&&e.includes("version=2")}function At(r,e){let t=r.slice(0,-e.length);return t.startsWith("/")&&(t=t.slice(1)),t}async function $r(r,e){let t=r.headers.get("content-length");if(t){let a=Number(t);if(Number.isFinite(a)&&e.maxRequestBytes!==void 0&&a>e.maxRequestBytes)throw new D("Request body too large")}let n=await Wr(r.body,e.maxRequestBytes,"Request body too large"),s=r.headers.get("content-encoding");if(s==="gzip"||s==="x-gzip"){let a=new DecompressionStream("gzip"),i=a.writable.getWriter(),o=new Uint8Array(n.byteLength);return o.set(n),await i.write(o),await i.close(),Wr(a.readable,e.maxInflatedBytes,"Decompressed body too large")}return n}async function Wr(r,e,t){if(!r)return new Uint8Array(0);let n=r.getReader(),s=[],a=0;try{for(;;){let{value:f,done:c}=await n.read();if(c)break;if(f){if(a+=f.byteLength,e!==void 0&&a>e)throw new D(t);s.push(f)}}}finally{n.releaseLock()}if(s.length===0)return new Uint8Array(0);let i=new Uint8Array(a),o=0;for(let f of s)i.set(f,o),o+=f.byteLength;return i}async function es(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,p]of Object.entries(e.headers))if(p!==void 0)if(Array.isArray(p))for(let g of p)i.append(h,g);else i.set(h,p);let o=e.method??"GET",f;if(o!=="GET"&&o!=="HEAD"){let h=0;for(let R of t)h+=R.byteLength;let p=new Uint8Array(h),g=0;for(let R of t)p.set(R,g),g+=R.byteLength;f=p}let c=new Request(a.href,{method:o,headers:i,body:f}),l=await r.fetch(c),d={};l.headers.forEach((h,p)=>{d[p]=h}),n.writeHead(l.status,d);let u=new Uint8Array(await l.arrayBuffer());u.byteLength>0&&n.write(u),n.end()}function ts(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 rs(r,e){let t=r?ts(r):void 0;return t&&e?Gr(t,e):t??e}function Gr(...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(U(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(U(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(U(l))return l;l&&(f=l)}return f}),t}var ns=`
67
67
  CREATE TABLE IF NOT EXISTS git_repos (
68
68
  id TEXT PRIMARY KEY
69
69
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "just-git",
3
- "version": "1.5.7",
3
+ "version": "1.5.8",
4
4
  "description": "Pure TypeScript git implementation: virtual filesystem client and embeddable server.",
5
5
  "keywords": [
6
6
  "agent",