@legit-sdk/core 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server.js +15 -129
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -1,148 +1,34 @@
|
|
|
1
1
|
// legit-sdk server bundle (Node.js)
|
|
2
2
|
|
|
3
|
-
var gv=Object.create;var ca=Object.defineProperty;var yv=Object.getOwnPropertyDescriptor;var bv=Object.getOwnPropertyNames;var _v=Object.getPrototypeOf,vv=Object.prototype.hasOwnProperty;var Fv=(e,t,r)=>t in e?ca(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var o=(e,t)=>ca(e,"name",{value:t,configurable:!0}),X=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var O=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Sv=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of bv(t))!vv.call(e,n)&&n!==r&&ca(e,n,{get:()=>t[n],enumerable:!(i=yv(t,n))||i.enumerable});return e};var le=(e,t,r)=>(r=e!=null?gv(_v(e)):{},Sv(t||!e||!e.__esModule?ca(r,"default",{value:e,enumerable:!0}):r,e));var $=(e,t,r)=>Fv(e,typeof t!="symbol"?t+"":t,r);var Vu=O((tC,Wu)=>{"use strict";var Ue=o(function(e){if(e=e||{},this.Promise=e.Promise||Promise,this.queues=Object.create(null),this.domainReentrant=e.domainReentrant||!1,this.domainReentrant){if(typeof process>"u"||typeof process.domain>"u")throw new Error("Domain-reentrant locks require `process.domain` to exist. Please flip `opts.domainReentrant = false`, use a NodeJS version that still implements Domain, or install a browser polyfill.");this.domains=Object.create(null)}this.timeout=e.timeout||Ue.DEFAULT_TIMEOUT,this.maxOccupationTime=e.maxOccupationTime||Ue.DEFAULT_MAX_OCCUPATION_TIME,this.maxExecutionTime=e.maxExecutionTime||Ue.DEFAULT_MAX_EXECUTION_TIME,e.maxPending===1/0||Number.isInteger(e.maxPending)&&e.maxPending>=0?this.maxPending=e.maxPending:this.maxPending=Ue.DEFAULT_MAX_PENDING},"AsyncLock");Ue.DEFAULT_TIMEOUT=0;Ue.DEFAULT_MAX_OCCUPATION_TIME=0;Ue.DEFAULT_MAX_EXECUTION_TIME=0;Ue.DEFAULT_MAX_PENDING=1e3;Ue.prototype.acquire=function(e,t,r,i){if(Array.isArray(e))return this._acquireBatch(e,t,r,i);if(typeof t!="function")throw new Error("You must pass a function to execute");var n=null,a=null,s=null;typeof r!="function"&&(i=r,r=null,s=new this.Promise(function(_,k){n=_,a=k})),i=i||{};var l=!1,u=null,c=null,f=null,d=this,h=o(function(_,k,F){c&&(clearTimeout(c),c=null),f&&(clearTimeout(f),f=null),_&&(d.queues[e]&&d.queues[e].length===0&&delete d.queues[e],d.domainReentrant&&delete d.domains[e]),l||(s?k?a(k):n(F):typeof r=="function"&&r(k,F),l=!0),_&&d.queues[e]&&d.queues[e].length>0&&d.queues[e].shift()()},"done"),p=o(function(_){if(l)return h(_);u&&(clearTimeout(u),u=null),d.domainReentrant&&_&&(d.domains[e]=process.domain);var k=i.maxExecutionTime||d.maxExecutionTime;if(k&&(f=setTimeout(function(){d.queues[e]&&h(_,new Error("Maximum execution time is exceeded "+e))},k)),t.length===1){var F=!1;try{t(function(S,P){F||(F=!0,h(_,S,P))})}catch(S){F||(F=!0,h(_,S))}}else d._promiseTry(function(){return t()}).then(function(S){h(_,void 0,S)},function(S){h(_,S)})},"exec");d.domainReentrant&&process.domain&&(p=process.domain.bind(p));var m=i.maxPending||d.maxPending;if(!d.queues[e])d.queues[e]=[],p(!0);else if(d.domainReentrant&&process.domain&&process.domain===d.domains[e])p(!1);else if(d.queues[e].length>=m)h(!1,new Error("Too many pending tasks in queue "+e));else{var w=o(function(){p(!0)},"taskFn");i.skipQueue?d.queues[e].unshift(w):d.queues[e].push(w);var y=i.timeout||d.timeout;y&&(u=setTimeout(function(){u=null,h(!1,new Error("async-lock timed out in queue "+e))},y))}var g=i.maxOccupationTime||d.maxOccupationTime;if(g&&(c=setTimeout(function(){d.queues[e]&&h(!1,new Error("Maximum occupation time is exceeded in queue "+e))},g)),s)return s};Ue.prototype._acquireBatch=function(e,t,r,i){typeof r!="function"&&(i=r,r=null);var n=this,a=o(function(l,u){return function(c){n.acquire(l,u,c,i)}},"getFn"),s=e.reduceRight(function(l,u){return a(u,l)},t);if(typeof r=="function")s(r);else return new this.Promise(function(l,u){s.length===1?s(function(c,f){c?u(c):l(f)}):l(s())})};Ue.prototype.isBusy=function(e){return e?!!this.queues[e]:Object.keys(this.queues).length>0};Ue.prototype._promiseTry=function(e){try{return this.Promise.resolve(e())}catch(t){return this.Promise.reject(t)}};Wu.exports=Ue});var Zu=O((iC,Gu)=>{"use strict";Gu.exports=Vu()});var Ku=O((nC,el)=>{typeof Object.create=="function"?el.exports=o(function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))},"inherits"):el.exports=o(function(t,r){if(r){t.super_=r;var i=o(function(){},"TempCtor");i.prototype=r.prototype,t.prototype=new i,t.prototype.constructor=t}},"inherits")});var Yu=O((oC,rl)=>{try{if(tl=X("util"),typeof tl.inherits!="function")throw"";rl.exports=tl.inherits}catch{rl.exports=Ku()}var tl});var Zi=O((il,Ju)=>{var ma=X("buffer"),mt=ma.Buffer;function Xu(e,t){for(var r in e)t[r]=e[r]}o(Xu,"copyProps");mt.from&&mt.alloc&&mt.allocUnsafe&&mt.allocUnsafeSlow?Ju.exports=ma:(Xu(ma,il),il.Buffer=hr);function hr(e,t,r){return mt(e,t,r)}o(hr,"SafeBuffer");hr.prototype=Object.create(mt.prototype);Xu(mt,hr);hr.from=function(e,t,r){if(typeof e=="number")throw new TypeError("Argument must not be a number");return mt(e,t,r)};hr.alloc=function(e,t,r){if(typeof e!="number")throw new TypeError("Argument must be a number");var i=mt(e);return t!==void 0?typeof r=="string"?i.fill(t,r):i.fill(t):i.fill(0),i};hr.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return mt(e)};hr.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return ma.SlowBuffer(e)}});var ed=O((lC,Qu)=>{var Rv={}.toString;Qu.exports=Array.isArray||function(e){return Rv.call(e)=="[object Array]"}});var zr=O((cC,td)=>{"use strict";td.exports=TypeError});var nl=O((fC,rd)=>{"use strict";rd.exports=Object});var nd=O((uC,id)=>{"use strict";id.exports=Error});var od=O((dC,ad)=>{"use strict";ad.exports=EvalError});var ld=O((hC,sd)=>{"use strict";sd.exports=RangeError});var fd=O((pC,cd)=>{"use strict";cd.exports=ReferenceError});var al=O((mC,ud)=>{"use strict";ud.exports=SyntaxError});var hd=O((wC,dd)=>{"use strict";dd.exports=URIError});var md=O((gC,pd)=>{"use strict";pd.exports=Math.abs});var gd=O((yC,wd)=>{"use strict";wd.exports=Math.floor});var bd=O((bC,yd)=>{"use strict";yd.exports=Math.max});var vd=O((_C,_d)=>{"use strict";_d.exports=Math.min});var Sd=O((vC,Fd)=>{"use strict";Fd.exports=Math.pow});var kd=O((FC,Ed)=>{"use strict";Ed.exports=Math.round});var Pd=O((SC,xd)=>{"use strict";xd.exports=Number.isNaN||o(function(t){return t!==t},"isNaN")});var Ad=O((kC,Td)=>{"use strict";var Cv=Pd();Td.exports=o(function(t){return Cv(t)||t===0?t:t<0?-1:1},"sign")});var Dd=O((PC,Od)=>{"use strict";Od.exports=Object.getOwnPropertyDescriptor});var Wr=O((TC,Rd)=>{"use strict";var wa=Dd();if(wa)try{wa([],"length")}catch{wa=null}Rd.exports=wa});var Ki=O((AC,Cd)=>{"use strict";var ga=Object.defineProperty||!1;if(ga)try{ga({},"a",{value:1})}catch{ga=!1}Cd.exports=ga});var ol=O((OC,Id)=>{"use strict";Id.exports=o(function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},r=Symbol("test"),i=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var n=42;t[r]=n;for(var a in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var s=Object.getOwnPropertySymbols(t);if(s.length!==1||s[0]!==r||!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var l=Object.getOwnPropertyDescriptor(t,r);if(l.value!==n||l.enumerable!==!0)return!1}return!0},"hasSymbols")});var $d=O((RC,Nd)=>{"use strict";var Bd=typeof Symbol<"u"&&Symbol,Iv=ol();Nd.exports=o(function(){return typeof Bd!="function"||typeof Symbol!="function"||typeof Bd("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Iv()},"hasNativeSymbols")});var sl=O((IC,Ld)=>{"use strict";Ld.exports=typeof Reflect<"u"&&Reflect.getPrototypeOf||null});var ll=O((BC,Md)=>{"use strict";var Bv=nl();Md.exports=Bv.getPrototypeOf||null});var qd=O((NC,Hd)=>{"use strict";var Nv="Function.prototype.bind called on incompatible ",$v=Object.prototype.toString,Lv=Math.max,Mv="[object Function]",jd=o(function(t,r){for(var i=[],n=0;n<t.length;n+=1)i[n]=t[n];for(var a=0;a<r.length;a+=1)i[a+t.length]=r[a];return i},"concatty"),jv=o(function(t,r){for(var i=[],n=r||0,a=0;n<t.length;n+=1,a+=1)i[a]=t[n];return i},"slicy"),Hv=o(function(e,t){for(var r="",i=0;i<e.length;i+=1)r+=e[i],i+1<e.length&&(r+=t);return r},"joiny");Hd.exports=o(function(t){var r=this;if(typeof r!="function"||$v.apply(r)!==Mv)throw new TypeError(Nv+r);for(var i=jv(arguments,1),n,a=o(function(){if(this instanceof n){var f=r.apply(this,jd(i,arguments));return Object(f)===f?f:this}return r.apply(t,jd(i,arguments))},"binder"),s=Lv(0,r.length-i.length),l=[],u=0;u<s;u++)l[u]="$"+u;if(n=Function("binder","return function ("+Hv(l,",")+"){ return binder.apply(this,arguments); }")(a),r.prototype){var c=o(function(){},"Empty");c.prototype=r.prototype,n.prototype=new c,c.prototype=null}return n},"bind")});var Vr=O((LC,Ud)=>{"use strict";var qv=qd();Ud.exports=Function.prototype.bind||qv});var ya=O((MC,zd)=>{"use strict";zd.exports=Function.prototype.call});var ba=O((jC,Wd)=>{"use strict";Wd.exports=Function.prototype.apply});var Gd=O((HC,Vd)=>{"use strict";Vd.exports=typeof Reflect<"u"&&Reflect&&Reflect.apply});var cl=O((qC,Zd)=>{"use strict";var Uv=Vr(),zv=ba(),Wv=ya(),Vv=Gd();Zd.exports=Vv||Uv.call(Wv,zv)});var _a=O((UC,Kd)=>{"use strict";var Gv=Vr(),Zv=zr(),Kv=ya(),Yv=cl();Kd.exports=o(function(t){if(t.length<1||typeof t[0]!="function")throw new Zv("a function is required");return Yv(Gv,Kv,t)},"callBindBasic")});var th=O((WC,eh)=>{"use strict";var Xv=_a(),Yd=Wr(),Jd;try{Jd=[].__proto__===Array.prototype}catch(e){if(!e||typeof e!="object"||!("code"in e)||e.code!=="ERR_PROTO_ACCESS")throw e}var fl=!!Jd&&Yd&&Yd(Object.prototype,"__proto__"),Qd=Object,Xd=Qd.getPrototypeOf;eh.exports=fl&&typeof fl.get=="function"?Xv([fl.get]):typeof Xd=="function"?o(function(t){return Xd(t==null?t:Qd(t))},"getDunder"):!1});var ul=O((GC,ah)=>{"use strict";var rh=sl(),ih=ll(),nh=th();ah.exports=rh?o(function(t){return rh(t)},"getProto"):ih?o(function(t){if(!t||typeof t!="object"&&typeof t!="function")throw new TypeError("getProto: not an object");return ih(t)},"getProto"):nh?o(function(t){return nh(t)},"getProto"):null});var sh=O((KC,oh)=>{"use strict";var Jv=Function.prototype.call,Qv=Object.prototype.hasOwnProperty,eF=Vr();oh.exports=eF.call(Jv,Qv)});var pl=O((YC,hh)=>{"use strict";var H,tF=nl(),rF=nd(),iF=od(),nF=ld(),aF=fd(),Yr=al(),Kr=zr(),oF=hd(),sF=md(),lF=gd(),cF=bd(),fF=vd(),uF=Sd(),dF=kd(),hF=Ad(),uh=Function,dl=o(function(e){try{return uh('"use strict"; return ('+e+").constructor;")()}catch{}},"getEvalledConstructor"),Yi=Wr(),pF=Ki(),hl=o(function(){throw new Kr},"throwTypeError"),mF=Yi?function(){try{return arguments.callee,hl}catch{try{return Yi(arguments,"callee").get}catch{return hl}}}():hl,Gr=$d()(),be=ul(),wF=ll(),gF=sl(),dh=ba(),Xi=ya(),Zr={},yF=typeof Uint8Array>"u"||!be?H:be(Uint8Array),pr={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?H:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?H:ArrayBuffer,"%ArrayIteratorPrototype%":Gr&&be?be([][Symbol.iterator]()):H,"%AsyncFromSyncIteratorPrototype%":H,"%AsyncFunction%":Zr,"%AsyncGenerator%":Zr,"%AsyncGeneratorFunction%":Zr,"%AsyncIteratorPrototype%":Zr,"%Atomics%":typeof Atomics>"u"?H:Atomics,"%BigInt%":typeof BigInt>"u"?H:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?H:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?H:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?H:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":rF,"%eval%":eval,"%EvalError%":iF,"%Float16Array%":typeof Float16Array>"u"?H:Float16Array,"%Float32Array%":typeof Float32Array>"u"?H:Float32Array,"%Float64Array%":typeof Float64Array>"u"?H:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?H:FinalizationRegistry,"%Function%":uh,"%GeneratorFunction%":Zr,"%Int8Array%":typeof Int8Array>"u"?H:Int8Array,"%Int16Array%":typeof Int16Array>"u"?H:Int16Array,"%Int32Array%":typeof Int32Array>"u"?H:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Gr&&be?be(be([][Symbol.iterator]())):H,"%JSON%":typeof JSON=="object"?JSON:H,"%Map%":typeof Map>"u"?H:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Gr||!be?H:be(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":tF,"%Object.getOwnPropertyDescriptor%":Yi,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?H:Promise,"%Proxy%":typeof Proxy>"u"?H:Proxy,"%RangeError%":nF,"%ReferenceError%":aF,"%Reflect%":typeof Reflect>"u"?H:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?H:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Gr||!be?H:be(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?H:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Gr&&be?be(""[Symbol.iterator]()):H,"%Symbol%":Gr?Symbol:H,"%SyntaxError%":Yr,"%ThrowTypeError%":mF,"%TypedArray%":yF,"%TypeError%":Kr,"%Uint8Array%":typeof Uint8Array>"u"?H:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?H:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?H:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?H:Uint32Array,"%URIError%":oF,"%WeakMap%":typeof WeakMap>"u"?H:WeakMap,"%WeakRef%":typeof WeakRef>"u"?H:WeakRef,"%WeakSet%":typeof WeakSet>"u"?H:WeakSet,"%Function.prototype.call%":Xi,"%Function.prototype.apply%":dh,"%Object.defineProperty%":pF,"%Object.getPrototypeOf%":wF,"%Math.abs%":sF,"%Math.floor%":lF,"%Math.max%":cF,"%Math.min%":fF,"%Math.pow%":uF,"%Math.round%":dF,"%Math.sign%":hF,"%Reflect.getPrototypeOf%":gF};if(be)try{null.error}catch(e){lh=be(be(e)),pr["%Error.prototype%"]=lh}var lh,bF=o(function e(t){var r;if(t==="%AsyncFunction%")r=dl("async function () {}");else if(t==="%GeneratorFunction%")r=dl("function* () {}");else if(t==="%AsyncGeneratorFunction%")r=dl("async function* () {}");else if(t==="%AsyncGenerator%"){var i=e("%AsyncGeneratorFunction%");i&&(r=i.prototype)}else if(t==="%AsyncIteratorPrototype%"){var n=e("%AsyncGenerator%");n&&be&&(r=be(n.prototype))}return pr[t]=r,r},"doEval"),ch={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Ji=Vr(),va=sh(),_F=Ji.call(Xi,Array.prototype.concat),vF=Ji.call(dh,Array.prototype.splice),fh=Ji.call(Xi,String.prototype.replace),Fa=Ji.call(Xi,String.prototype.slice),FF=Ji.call(Xi,RegExp.prototype.exec),SF=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,EF=/\\(\\)?/g,kF=o(function(t){var r=Fa(t,0,1),i=Fa(t,-1);if(r==="%"&&i!=="%")throw new Yr("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&r!=="%")throw new Yr("invalid intrinsic syntax, expected opening `%`");var n=[];return fh(t,SF,function(a,s,l,u){n[n.length]=l?fh(u,EF,"$1"):s||a}),n},"stringToPath"),xF=o(function(t,r){var i=t,n;if(va(ch,i)&&(n=ch[i],i="%"+n[0]+"%"),va(pr,i)){var a=pr[i];if(a===Zr&&(a=bF(i)),typeof a>"u"&&!r)throw new Kr("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:n,name:i,value:a}}throw new Yr("intrinsic "+t+" does not exist!")},"getBaseIntrinsic");hh.exports=o(function(t,r){if(typeof t!="string"||t.length===0)throw new Kr("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new Kr('"allowMissing" argument must be a boolean');if(FF(/^%?[^%]*%?$/,t)===null)throw new Yr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=kF(t),n=i.length>0?i[0]:"",a=xF("%"+n+"%",r),s=a.name,l=a.value,u=!1,c=a.alias;c&&(n=c[0],vF(i,_F([0,1],c)));for(var f=1,d=!0;f<i.length;f+=1){var h=i[f],p=Fa(h,0,1),m=Fa(h,-1);if((p==='"'||p==="'"||p==="`"||m==='"'||m==="'"||m==="`")&&p!==m)throw new Yr("property names with quotes must have matching quotes");if((h==="constructor"||!d)&&(u=!0),n+="."+h,s="%"+n+"%",va(pr,s))l=pr[s];else if(l!=null){if(!(h in l)){if(!r)throw new Kr("base intrinsic for "+t+" exists, but the property is not available.");return}if(Yi&&f+1>=i.length){var w=Yi(l,h);d=!!w,d&&"get"in w&&!("originalValue"in w.get)?l=w.get:l=l[h]}else d=va(l,h),l=l[h];d&&!u&&(pr[s]=l)}}return l},"GetIntrinsic")});var ml=O((JC,wh)=>{"use strict";var ph=pl(),mh=_a(),PF=mh([ph("%String.prototype.indexOf%")]);wh.exports=o(function(t,r){var i=ph(t,!!r);return typeof i=="function"&&PF(t,".prototype.")>-1?mh([i]):i},"callBoundIntrinsic")});var _h=O((eI,bh)=>{"use strict";var yh=Function.prototype.toString,Xr=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,gl,Sa;if(typeof Xr=="function"&&typeof Object.defineProperty=="function")try{gl=Object.defineProperty({},"length",{get:o(function(){throw Sa},"get")}),Sa={},Xr(function(){throw 42},null,gl)}catch(e){e!==Sa&&(Xr=null)}else Xr=null;var TF=/^\s*class\b/,yl=o(function(t){try{var r=yh.call(t);return TF.test(r)}catch{return!1}},"isES6ClassFunction"),wl=o(function(t){try{return yl(t)?!1:(yh.call(t),!0)}catch{return!1}},"tryFunctionToStr"),Ea=Object.prototype.toString,AF="[object Object]",OF="[object Function]",DF="[object GeneratorFunction]",RF="[object HTMLAllCollection]",CF="[object HTML document.all class]",IF="[object HTMLCollection]",BF=typeof Symbol=="function"&&!!Symbol.toStringTag,NF=!(0 in[,]),bl=o(function(){return!1},"isDocumentDotAll");typeof document=="object"&&(gh=document.all,Ea.call(gh)===Ea.call(document.all)&&(bl=o(function(t){if((NF||!t)&&(typeof t>"u"||typeof t=="object"))try{var r=Ea.call(t);return(r===RF||r===CF||r===IF||r===AF)&&t("")==null}catch{}return!1},"isDocumentDotAll")));var gh;bh.exports=o(Xr?function(t){if(bl(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;try{Xr(t,null,gl)}catch(r){if(r!==Sa)return!1}return!yl(t)&&wl(t)}:function(t){if(bl(t))return!0;if(!t||typeof t!="function"&&typeof t!="object")return!1;if(BF)return wl(t);if(yl(t))return!1;var r=Ea.call(t);return r!==OF&&r!==DF&&!/^\[object HTML/.test(r)?!1:wl(t)},"isCallable")});var Sh=O((rI,Fh)=>{"use strict";var $F=_h(),LF=Object.prototype.toString,vh=Object.prototype.hasOwnProperty,MF=o(function(t,r,i){for(var n=0,a=t.length;n<a;n++)vh.call(t,n)&&(i==null?r(t[n],n,t):r.call(i,t[n],n,t))},"forEachArray"),jF=o(function(t,r,i){for(var n=0,a=t.length;n<a;n++)i==null?r(t.charAt(n),n,t):r.call(i,t.charAt(n),n,t)},"forEachString"),HF=o(function(t,r,i){for(var n in t)vh.call(t,n)&&(i==null?r(t[n],n,t):r.call(i,t[n],n,t))},"forEachObject");function qF(e){return LF.call(e)==="[object Array]"}o(qF,"isArray");Fh.exports=o(function(t,r,i){if(!$F(r))throw new TypeError("iterator must be a function");var n;arguments.length>=3&&(n=i),qF(t)?MF(t,r,n):typeof t=="string"?jF(t,r,n):HF(t,r,n)},"forEach")});var kh=O((nI,Eh)=>{"use strict";Eh.exports=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]});var Ph=O((aI,xh)=>{"use strict";var _l=kh(),UF=globalThis;xh.exports=o(function(){for(var t=[],r=0;r<_l.length;r++)typeof UF[_l[r]]=="function"&&(t[t.length]=_l[r]);return t},"availableTypedArrays")});var Dh=O((sI,Oh)=>{"use strict";var Th=Ki(),zF=al(),Jr=zr(),Ah=Wr();Oh.exports=o(function(t,r,i){if(!t||typeof t!="object"&&typeof t!="function")throw new Jr("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Jr("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Jr("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Jr("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Jr("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Jr("`loose`, if provided, must be a boolean");var n=arguments.length>3?arguments[3]:null,a=arguments.length>4?arguments[4]:null,s=arguments.length>5?arguments[5]:null,l=arguments.length>6?arguments[6]:!1,u=!!Ah&&Ah(t,r);if(Th)Th(t,r,{configurable:s===null&&u?u.configurable:!s,enumerable:n===null&&u?u.enumerable:!n,value:i,writable:a===null&&u?u.writable:!a});else if(l||!n&&!a&&!s)t[r]=i;else throw new zF("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},"defineDataProperty")});var Ih=O((cI,Ch)=>{"use strict";var vl=Ki(),Rh=o(function(){return!!vl},"hasPropertyDescriptors");Rh.hasArrayLengthDefineBug=o(function(){if(!vl)return null;try{return vl([],"length",{value:1}).length!==1}catch{return!0}},"hasArrayLengthDefineBug");Ch.exports=Rh});var Mh=O((uI,Lh)=>{"use strict";var WF=pl(),Bh=Dh(),VF=Ih()(),Nh=Wr(),$h=zr(),GF=WF("%Math.floor%");Lh.exports=o(function(t,r){if(typeof t!="function")throw new $h("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||GF(r)!==r)throw new $h("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],n=!0,a=!0;if("length"in t&&Nh){var s=Nh(t,"length");s&&!s.configurable&&(n=!1),s&&!s.writable&&(a=!1)}return(n||a||!i)&&(VF?Bh(t,"length",r,!0,!0):Bh(t,"length",r)),t},"setFunctionLength")});var Hh=O((hI,jh)=>{"use strict";var ZF=Vr(),KF=ba(),YF=cl();jh.exports=o(function(){return YF(ZF,KF,arguments)},"applyBind")});var zh=O((mI,ka)=>{"use strict";var XF=Mh(),qh=Ki(),JF=_a(),Uh=Hh();ka.exports=o(function(t){var r=JF(arguments),i=t.length-(arguments.length-1);return XF(r,1+(i>0?i:0),!0)},"callBind");qh?qh(ka.exports,"apply",{value:Uh}):ka.exports.apply=Uh});var Vh=O((gI,Wh)=>{"use strict";var QF=ol();Wh.exports=o(function(){return QF()&&!!Symbol.toStringTag},"hasToStringTagShams")});var Xh=O((bI,Yh)=>{"use strict";var Ta=Sh(),eS=Ph(),Gh=zh(),Sl=ml(),Pa=Wr(),xa=ul(),tS=Sl("Object.prototype.toString"),Kh=Vh()(),Zh=globalThis,Fl=eS(),El=Sl("String.prototype.slice"),rS=Sl("Array.prototype.indexOf",!0)||o(function(t,r){for(var i=0;i<t.length;i+=1)if(t[i]===r)return i;return-1},"indexOf"),Aa={__proto__:null};Kh&&Pa&&xa?Ta(Fl,function(e){var t=new Zh[e];if(Symbol.toStringTag in t&&xa){var r=xa(t),i=Pa(r,Symbol.toStringTag);if(!i&&r){var n=xa(r);i=Pa(n,Symbol.toStringTag)}Aa["$"+e]=Gh(i.get)}}):Ta(Fl,function(e){var t=new Zh[e],r=t.slice||t.set;r&&(Aa["$"+e]=Gh(r))});var iS=o(function(t){var r=!1;return Ta(Aa,function(i,n){if(!r)try{"$"+i(t)===n&&(r=El(n,1))}catch{}}),r},"tryAllTypedArrays"),nS=o(function(t){var r=!1;return Ta(Aa,function(i,n){if(!r)try{i(t),r=El(n,1)}catch{}}),r},"tryAllSlices");Yh.exports=o(function(t){if(!t||typeof t!="object")return!1;if(!Kh){var r=El(tS(t),8,-1);return rS(Fl,r)>-1?r:r!=="Object"?!1:nS(t)}return Pa?iS(t):null},"whichTypedArray")});var Qh=O((vI,Jh)=>{"use strict";var aS=Xh();Jh.exports=o(function(t){return!!aS(t)},"isTypedArray")});var tp=O((SI,ep)=>{"use strict";var oS=zr(),sS=ml(),lS=sS("TypedArray.prototype.buffer",!0),cS=Qh();ep.exports=lS||o(function(t){if(!cS(t))throw new oS("Not a Typed Array");return t.buffer},"typedArrayBuffer")});var np=O((kI,ip)=>{"use strict";var nt=Zi().Buffer,fS=ed(),uS=tp(),dS=ArrayBuffer.isView||o(function(t){try{return uS(t),!0}catch{return!1}},"isView"),hS=typeof Uint8Array<"u",rp=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",pS=rp&&(nt.prototype instanceof Uint8Array||nt.TYPED_ARRAY_SUPPORT);ip.exports=o(function(t,r){if(nt.isBuffer(t))return t.constructor&&!("isBuffer"in t)?nt.from(t):t;if(typeof t=="string")return nt.from(t,r);if(rp&&dS(t)){if(t.byteLength===0)return nt.alloc(0);if(pS){var i=nt.from(t.buffer,t.byteOffset,t.byteLength);if(i.byteLength===t.byteLength)return i}var n=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),a=nt.from(n);if(a.length===t.byteLength)return a}if(hS&&t instanceof Uint8Array)return nt.from(t);var s=fS(t);if(s)for(var l=0;l<t.length;l+=1){var u=t[l];if(typeof u!="number"||u<0||u>255||~~u!==u)throw new RangeError("Array items must be numbers in the range 0-255.")}if(s||nt.isBuffer(t)&&t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t))return nt.from(t);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')},"toBuffer")});var op=O((PI,ap)=>{"use strict";var mS=Zi().Buffer,wS=np();function Oa(e,t){this._block=mS.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}o(Oa,"Hash");Oa.prototype.update=function(e,t){e=wS(e,t||"utf8");for(var r=this._block,i=this._blockSize,n=e.length,a=this._len,s=0;s<n;){for(var l=a%i,u=Math.min(n-s,i-l),c=0;c<u;c++)r[l+c]=e[s+c];a+=u,s+=u,a%i===0&&this._update(r)}return this._len+=n,this};Oa.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var i=(r&4294967295)>>>0,n=(r-i)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(i,this._blockSize-4)}this._update(this._block);var a=this._hash();return e?a.toString(e):a};Oa.prototype._update=function(){throw new Error("_update must be implemented by subclass")};ap.exports=Oa});var cp=O((AI,lp)=>{"use strict";var gS=Yu(),sp=op(),yS=Zi().Buffer,bS=[1518500249,1859775393,-1894007588,-899497514],_S=new Array(80);function Qi(){this.init(),this._w=_S,sp.call(this,64,56)}o(Qi,"Sha1");gS(Qi,sp);Qi.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function vS(e){return e<<1|e>>>31}o(vS,"rotl1");function FS(e){return e<<5|e>>>27}o(FS,"rotl5");function SS(e){return e<<30|e>>>2}o(SS,"rotl30");function ES(e,t,r,i){return e===0?t&r|~t&i:e===2?t&r|t&i|r&i:t^r^i}o(ES,"ft");Qi.prototype._update=function(e){for(var t=this._w,r=this._a|0,i=this._b|0,n=this._c|0,a=this._d|0,s=this._e|0,l=0;l<16;++l)t[l]=e.readInt32BE(l*4);for(;l<80;++l)t[l]=vS(t[l-3]^t[l-8]^t[l-14]^t[l-16]);for(var u=0;u<80;++u){var c=~~(u/20),f=FS(r)+ES(c,i,n,a)+s+t[u]+bS[c]|0;s=a,a=n,n=SS(i),i=r,r=f}this._a=r+this._a|0,this._b=i+this._b|0,this._c=n+this._c|0,this._d=a+this._d|0,this._e=s+this._e|0};Qi.prototype._hash=function(){var e=yS.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};lp.exports=Qi});var up=O(kl=>{var fp;(function(e){typeof DO_NOT_EXPORT_CRC>"u"?typeof kl=="object"?e(kl):typeof define=="function"&&define.amd?define(function(){var t={};return e(t),t}):e(fp={}):e(fp={})})(function(e){e.version="1.2.2";function t(){for(var b=0,x=new Array(256),v=0;v!=256;++v)b=v,b=b&1?-306674912^b>>>1:b>>>1,b=b&1?-306674912^b>>>1:b>>>1,b=b&1?-306674912^b>>>1:b>>>1,b=b&1?-306674912^b>>>1:b>>>1,b=b&1?-306674912^b>>>1:b>>>1,b=b&1?-306674912^b>>>1:b>>>1,b=b&1?-306674912^b>>>1:b>>>1,b=b&1?-306674912^b>>>1:b>>>1,x[v]=b;return typeof Int32Array<"u"?new Int32Array(x):x}o(t,"signed_crc_table");var r=t();function i(b){var x=0,v=0,A=0,T=typeof Int32Array<"u"?new Int32Array(4096):new Array(4096);for(A=0;A!=256;++A)T[A]=b[A];for(A=0;A!=256;++A)for(v=b[A],x=256+A;x<4096;x+=256)v=T[x]=v>>>8^b[v&255];var R=[];for(A=1;A!=16;++A)R[A-1]=typeof Int32Array<"u"?T.subarray(A*256,A*256+256):T.slice(A*256,A*256+256);return R}o(i,"slice_by_16_tables");var n=i(r),a=n[0],s=n[1],l=n[2],u=n[3],c=n[4],f=n[5],d=n[6],h=n[7],p=n[8],m=n[9],w=n[10],y=n[11],g=n[12],_=n[13],k=n[14];function F(b,x){for(var v=x^-1,A=0,T=b.length;A<T;)v=v>>>8^r[(v^b.charCodeAt(A++))&255];return~v}o(F,"crc32_bstr");function S(b,x){for(var v=x^-1,A=b.length-15,T=0;T<A;)v=k[b[T++]^v&255]^_[b[T++]^v>>8&255]^g[b[T++]^v>>16&255]^y[b[T++]^v>>>24]^w[b[T++]]^m[b[T++]]^p[b[T++]]^h[b[T++]]^d[b[T++]]^f[b[T++]]^c[b[T++]]^u[b[T++]]^l[b[T++]]^s[b[T++]]^a[b[T++]]^r[b[T++]];for(A+=15;T<A;)v=v>>>8^r[(v^b[T++])&255];return~v}o(S,"crc32_buf");function P(b,x){for(var v=x^-1,A=0,T=b.length,R=0,B=0;A<T;)R=b.charCodeAt(A++),R<128?v=v>>>8^r[(v^R)&255]:R<2048?(v=v>>>8^r[(v^(192|R>>6&31))&255],v=v>>>8^r[(v^(128|R&63))&255]):R>=55296&&R<57344?(R=(R&1023)+64,B=b.charCodeAt(A++)&1023,v=v>>>8^r[(v^(240|R>>8&7))&255],v=v>>>8^r[(v^(128|R>>2&63))&255],v=v>>>8^r[(v^(128|B>>6&15|(R&3)<<4))&255],v=v>>>8^r[(v^(128|B&63))&255]):(v=v>>>8^r[(v^(224|R>>12&15))&255],v=v>>>8^r[(v^(128|R>>6&63))&255],v=v>>>8^r[(v^(128|R&63))&255]);return~v}o(P,"crc32_str"),e.table=r,e.bstr=F,e.buf=S,e.str=P})});var Dt=O(Te=>{"use strict";var kS=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function xS(e,t){return Object.prototype.hasOwnProperty.call(e,t)}o(xS,"_has");Te.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if(typeof r!="object")throw new TypeError(r+"must be non-object");for(var i in r)xS(r,i)&&(e[i]=r[i])}}return e};Te.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var PS={arraySet:o(function(e,t,r,i,n){if(t.subarray&&e.subarray){e.set(t.subarray(r,r+i),n);return}for(var a=0;a<i;a++)e[n+a]=t[r+a]},"arraySet"),flattenChunks:o(function(e){var t,r,i,n,a,s;for(i=0,t=0,r=e.length;t<r;t++)i+=e[t].length;for(s=new Uint8Array(i),n=0,t=0,r=e.length;t<r;t++)a=e[t],s.set(a,n),n+=a.length;return s},"flattenChunks")},TS={arraySet:o(function(e,t,r,i,n){for(var a=0;a<i;a++)e[n+a]=t[r+a]},"arraySet"),flattenChunks:o(function(e){return[].concat.apply([],e)},"flattenChunks")};Te.setTyped=function(e){e?(Te.Buf8=Uint8Array,Te.Buf16=Uint16Array,Te.Buf32=Int32Array,Te.assign(Te,PS)):(Te.Buf8=Array,Te.Buf16=Array,Te.Buf32=Array,Te.assign(Te,TS))};Te.setTyped(kS)});var Ip=O(ti=>{"use strict";var AS=Dt(),OS=4,dp=0,hp=1,DS=2;function ei(e){for(var t=e.length;--t>=0;)e[t]=0}o(ei,"zero");var RS=0,bp=1,CS=2,IS=3,BS=258,Rl=29,on=256,tn=on+1+Rl,Qr=30,Cl=19,_p=2*tn+1,mr=15,xl=16,NS=7,Il=256,vp=16,Fp=17,Sp=18,Ol=[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],Da=[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],$S=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Ep=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],LS=512,Rt=new Array((tn+2)*2);ei(Rt);var en=new Array(Qr*2);ei(en);var rn=new Array(LS);ei(rn);var nn=new Array(BS-IS+1);ei(nn);var Bl=new Array(Rl);ei(Bl);var Ra=new Array(Qr);ei(Ra);function Pl(e,t,r,i,n){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=i,this.max_length=n,this.has_stree=e&&e.length}o(Pl,"StaticTreeDesc");var kp,xp,Pp;function Tl(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}o(Tl,"TreeDesc");function Tp(e){return e<256?rn[e]:rn[256+(e>>>7)]}o(Tp,"d_code");function an(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}o(an,"put_short");function Ne(e,t,r){e.bi_valid>xl-r?(e.bi_buf|=t<<e.bi_valid&65535,an(e,e.bi_buf),e.bi_buf=t>>xl-e.bi_valid,e.bi_valid+=r-xl):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}o(Ne,"send_bits");function wt(e,t,r){Ne(e,r[t*2],r[t*2+1])}o(wt,"send_code");function Ap(e,t){var r=0;do r|=e&1,e>>>=1,r<<=1;while(--t>0);return r>>>1}o(Ap,"bi_reverse");function MS(e){e.bi_valid===16?(an(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}o(MS,"bi_flush");function jS(e,t){var r=t.dyn_tree,i=t.max_code,n=t.stat_desc.static_tree,a=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,l=t.stat_desc.extra_base,u=t.stat_desc.max_length,c,f,d,h,p,m,w=0;for(h=0;h<=mr;h++)e.bl_count[h]=0;for(r[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;c<_p;c++)f=e.heap[c],h=r[r[f*2+1]*2+1]+1,h>u&&(h=u,w++),r[f*2+1]=h,!(f>i)&&(e.bl_count[h]++,p=0,f>=l&&(p=s[f-l]),m=r[f*2],e.opt_len+=m*(h+p),a&&(e.static_len+=m*(n[f*2+1]+p)));if(w!==0){do{for(h=u-1;e.bl_count[h]===0;)h--;e.bl_count[h]--,e.bl_count[h+1]+=2,e.bl_count[u]--,w-=2}while(w>0);for(h=u;h!==0;h--)for(f=e.bl_count[h];f!==0;)d=e.heap[--c],!(d>i)&&(r[d*2+1]!==h&&(e.opt_len+=(h-r[d*2+1])*r[d*2],r[d*2+1]=h),f--)}}o(jS,"gen_bitlen");function Op(e,t,r){var i=new Array(mr+1),n=0,a,s;for(a=1;a<=mr;a++)i[a]=n=n+r[a-1]<<1;for(s=0;s<=t;s++){var l=e[s*2+1];l!==0&&(e[s*2]=Ap(i[l]++,l))}}o(Op,"gen_codes");function HS(){var e,t,r,i,n,a=new Array(mr+1);for(r=0,i=0;i<Rl-1;i++)for(Bl[i]=r,e=0;e<1<<Ol[i];e++)nn[r++]=i;for(nn[r-1]=i,n=0,i=0;i<16;i++)for(Ra[i]=n,e=0;e<1<<Da[i];e++)rn[n++]=i;for(n>>=7;i<Qr;i++)for(Ra[i]=n<<7,e=0;e<1<<Da[i]-7;e++)rn[256+n++]=i;for(t=0;t<=mr;t++)a[t]=0;for(e=0;e<=143;)Rt[e*2+1]=8,e++,a[8]++;for(;e<=255;)Rt[e*2+1]=9,e++,a[9]++;for(;e<=279;)Rt[e*2+1]=7,e++,a[7]++;for(;e<=287;)Rt[e*2+1]=8,e++,a[8]++;for(Op(Rt,tn+1,a),e=0;e<Qr;e++)en[e*2+1]=5,en[e*2]=Ap(e,5);kp=new Pl(Rt,Ol,on+1,tn,mr),xp=new Pl(en,Da,0,Qr,mr),Pp=new Pl(new Array(0),$S,0,Cl,NS)}o(HS,"tr_static_init");function Dp(e){var t;for(t=0;t<tn;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Qr;t++)e.dyn_dtree[t*2]=0;for(t=0;t<Cl;t++)e.bl_tree[t*2]=0;e.dyn_ltree[Il*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}o(Dp,"init_block");function Rp(e){e.bi_valid>8?an(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}o(Rp,"bi_windup");function qS(e,t,r,i){Rp(e),i&&(an(e,r),an(e,~r)),AS.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}o(qS,"copy_block");function pp(e,t,r,i){var n=t*2,a=r*2;return e[n]<e[a]||e[n]===e[a]&&i[t]<=i[r]}o(pp,"smaller");function Al(e,t,r){for(var i=e.heap[r],n=r<<1;n<=e.heap_len&&(n<e.heap_len&&pp(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!pp(t,i,e.heap[n],e.depth));)e.heap[r]=e.heap[n],r=n,n<<=1;e.heap[r]=i}o(Al,"pqdownheap");function mp(e,t,r){var i,n,a=0,s,l;if(e.last_lit!==0)do i=e.pending_buf[e.d_buf+a*2]<<8|e.pending_buf[e.d_buf+a*2+1],n=e.pending_buf[e.l_buf+a],a++,i===0?wt(e,n,t):(s=nn[n],wt(e,s+on+1,t),l=Ol[s],l!==0&&(n-=Bl[s],Ne(e,n,l)),i--,s=Tp(i),wt(e,s,r),l=Da[s],l!==0&&(i-=Ra[s],Ne(e,i,l)));while(a<e.last_lit);wt(e,Il,t)}o(mp,"compress_block");function Dl(e,t){var r=t.dyn_tree,i=t.stat_desc.static_tree,n=t.stat_desc.has_stree,a=t.stat_desc.elems,s,l,u=-1,c;for(e.heap_len=0,e.heap_max=_p,s=0;s<a;s++)r[s*2]!==0?(e.heap[++e.heap_len]=u=s,e.depth[s]=0):r[s*2+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=u<2?++u:0,r[c*2]=1,e.depth[c]=0,e.opt_len--,n&&(e.static_len-=i[c*2+1]);for(t.max_code=u,s=e.heap_len>>1;s>=1;s--)Al(e,r,s);c=a;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Al(e,r,1),l=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=l,r[c*2]=r[s*2]+r[l*2],e.depth[c]=(e.depth[s]>=e.depth[l]?e.depth[s]:e.depth[l])+1,r[s*2+1]=r[l*2+1]=c,e.heap[1]=c++,Al(e,r,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],jS(e,t),Op(r,u,e.bl_count)}o(Dl,"build_tree");function wp(e,t,r){var i,n=-1,a,s=t[0*2+1],l=0,u=7,c=4;for(s===0&&(u=138,c=3),t[(r+1)*2+1]=65535,i=0;i<=r;i++)a=s,s=t[(i+1)*2+1],!(++l<u&&a===s)&&(l<c?e.bl_tree[a*2]+=l:a!==0?(a!==n&&e.bl_tree[a*2]++,e.bl_tree[vp*2]++):l<=10?e.bl_tree[Fp*2]++:e.bl_tree[Sp*2]++,l=0,n=a,s===0?(u=138,c=3):a===s?(u=6,c=3):(u=7,c=4))}o(wp,"scan_tree");function gp(e,t,r){var i,n=-1,a,s=t[0*2+1],l=0,u=7,c=4;for(s===0&&(u=138,c=3),i=0;i<=r;i++)if(a=s,s=t[(i+1)*2+1],!(++l<u&&a===s)){if(l<c)do wt(e,a,e.bl_tree);while(--l!==0);else a!==0?(a!==n&&(wt(e,a,e.bl_tree),l--),wt(e,vp,e.bl_tree),Ne(e,l-3,2)):l<=10?(wt(e,Fp,e.bl_tree),Ne(e,l-3,3)):(wt(e,Sp,e.bl_tree),Ne(e,l-11,7));l=0,n=a,s===0?(u=138,c=3):a===s?(u=6,c=3):(u=7,c=4)}}o(gp,"send_tree");function US(e){var t;for(wp(e,e.dyn_ltree,e.l_desc.max_code),wp(e,e.dyn_dtree,e.d_desc.max_code),Dl(e,e.bl_desc),t=Cl-1;t>=3&&e.bl_tree[Ep[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}o(US,"build_bl_tree");function zS(e,t,r,i){var n;for(Ne(e,t-257,5),Ne(e,r-1,5),Ne(e,i-4,4),n=0;n<i;n++)Ne(e,e.bl_tree[Ep[n]*2+1],3);gp(e,e.dyn_ltree,t-1),gp(e,e.dyn_dtree,r-1)}o(zS,"send_all_trees");function WS(e){var t=4093624447,r;for(r=0;r<=31;r++,t>>>=1)if(t&1&&e.dyn_ltree[r*2]!==0)return dp;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return hp;for(r=32;r<on;r++)if(e.dyn_ltree[r*2]!==0)return hp;return dp}o(WS,"detect_data_type");var yp=!1;function VS(e){yp||(HS(),yp=!0),e.l_desc=new Tl(e.dyn_ltree,kp),e.d_desc=new Tl(e.dyn_dtree,xp),e.bl_desc=new Tl(e.bl_tree,Pp),e.bi_buf=0,e.bi_valid=0,Dp(e)}o(VS,"_tr_init");function Cp(e,t,r,i){Ne(e,(RS<<1)+(i?1:0),3),qS(e,t,r,!0)}o(Cp,"_tr_stored_block");function GS(e){Ne(e,bp<<1,3),wt(e,Il,Rt),MS(e)}o(GS,"_tr_align");function ZS(e,t,r,i){var n,a,s=0;e.level>0?(e.strm.data_type===DS&&(e.strm.data_type=WS(e)),Dl(e,e.l_desc),Dl(e,e.d_desc),s=US(e),n=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=n&&(n=a)):n=a=r+5,r+4<=n&&t!==-1?Cp(e,t,r,i):e.strategy===OS||a===n?(Ne(e,(bp<<1)+(i?1:0),3),mp(e,Rt,en)):(Ne(e,(CS<<1)+(i?1:0),3),zS(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),mp(e,e.dyn_ltree,e.dyn_dtree)),Dp(e),i&&Rp(e)}o(ZS,"_tr_flush_block");function KS(e,t,r){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=r&255,e.last_lit++,t===0?e.dyn_ltree[r*2]++:(e.matches++,t--,e.dyn_ltree[(nn[r]+on+1)*2]++,e.dyn_dtree[Tp(t)*2]++),e.last_lit===e.lit_bufsize-1}o(KS,"_tr_tally");ti._tr_init=VS;ti._tr_stored_block=Cp;ti._tr_flush_block=ZS;ti._tr_tally=KS;ti._tr_align=GS});var Nl=O(($I,Bp)=>{"use strict";function YS(e,t,r,i){for(var n=e&65535|0,a=e>>>16&65535|0,s=0;r!==0;){s=r>2e3?2e3:r,r-=s;do n=n+t[i++]|0,a=a+n|0;while(--s);n%=65521,a%=65521}return n|a<<16|0}o(YS,"adler32");Bp.exports=YS});var $l=O((MI,Np)=>{"use strict";function XS(){for(var e,t=[],r=0;r<256;r++){e=r;for(var i=0;i<8;i++)e=e&1?3988292384^e>>>1:e>>>1;t[r]=e}return t}o(XS,"makeTable");var JS=XS();function QS(e,t,r,i){var n=JS,a=i+r;e^=-1;for(var s=i;s<a;s++)e=e>>>8^n[(e^t[s])&255];return e^-1}o(QS,"crc32");Np.exports=QS});var Ca=O((HI,$p)=>{"use strict";$p.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}});var Vp=O(bt=>{"use strict";var Ae=Dt(),Ke=Ip(),Hp=Nl(),qt=$l(),eE=Ca(),br=0,tE=1,rE=3,Gt=4,Lp=5,yt=0,Mp=1,Ye=-2,iE=-3,Ll=-5,nE=-1,aE=1,Ia=2,oE=3,sE=4,lE=0,cE=2,La=8,fE=9,uE=15,dE=8,hE=29,pE=256,jl=pE+1+hE,mE=30,wE=19,gE=2*jl+1,yE=15,z=3,Wt=258,at=Wt+z+1,bE=32,Ma=42,Hl=69,Ba=73,Na=91,$a=103,wr=113,ln=666,we=1,cn=2,gr=3,ni=4,_E=3;function Vt(e,t){return e.msg=eE[t],t}o(Vt,"err");function jp(e){return(e<<1)-(e>4?9:0)}o(jp,"rank");function zt(e){for(var t=e.length;--t>=0;)e[t]=0}o(zt,"zero");function Ut(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),r!==0&&(Ae.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,t.pending===0&&(t.pending_out=0))}o(Ut,"flush_pending");function ve(e,t){Ke._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Ut(e.strm)}o(ve,"flush_block_only");function Z(e,t){e.pending_buf[e.pending++]=t}o(Z,"put_byte");function sn(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}o(sn,"putShortMSB");function vE(e,t,r,i){var n=e.avail_in;return n>i&&(n=i),n===0?0:(e.avail_in-=n,Ae.arraySet(t,e.input,e.next_in,n,r),e.state.wrap===1?e.adler=Hp(e.adler,t,n,r):e.state.wrap===2&&(e.adler=qt(e.adler,t,n,r)),e.next_in+=n,e.total_in+=n,n)}o(vE,"read_buf");function qp(e,t){var r=e.max_chain_length,i=e.strstart,n,a,s=e.prev_length,l=e.nice_match,u=e.strstart>e.w_size-at?e.strstart-(e.w_size-at):0,c=e.window,f=e.w_mask,d=e.prev,h=e.strstart+Wt,p=c[i+s-1],m=c[i+s];e.prev_length>=e.good_match&&(r>>=2),l>e.lookahead&&(l=e.lookahead);do if(n=t,!(c[n+s]!==m||c[n+s-1]!==p||c[n]!==c[i]||c[++n]!==c[i+1])){i+=2,n++;do;while(c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&c[++i]===c[++n]&&i<h);if(a=Wt-(h-i),i=h-Wt,a>s){if(e.match_start=t,s=a,a>=l)break;p=c[i+s-1],m=c[i+s]}}while((t=d[t&f])>u&&--r!==0);return s<=e.lookahead?s:e.lookahead}o(qp,"longest_match");function yr(e){var t=e.w_size,r,i,n,a,s;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-at)){Ae.arraySet(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,i=e.hash_size,r=i;do n=e.head[--r],e.head[r]=n>=t?n-t:0;while(--i);i=t,r=i;do n=e.prev[--r],e.prev[r]=n>=t?n-t:0;while(--i);a+=t}if(e.strm.avail_in===0)break;if(i=vE(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=i,e.lookahead+e.insert>=z)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[s+z-1])&e.hash_mask,e.prev[s&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=s,s++,e.insert--,!(e.lookahead+e.insert<z)););}while(e.lookahead<at&&e.strm.avail_in!==0)}o(yr,"fill_window");function FE(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(yr(e),e.lookahead===0&&t===br)return we;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+r;if((e.strstart===0||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,ve(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-at&&(ve(e,!1),e.strm.avail_out===0))return we}return e.insert=0,t===Gt?(ve(e,!0),e.strm.avail_out===0?gr:ni):(e.strstart>e.block_start&&(ve(e,!1),e.strm.avail_out===0),we)}o(FE,"deflate_stored");function Ml(e,t){for(var r,i;;){if(e.lookahead<at){if(yr(e),e.lookahead<at&&t===br)return we;if(e.lookahead===0)break}if(r=0,e.lookahead>=z&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+z-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),r!==0&&e.strstart-r<=e.w_size-at&&(e.match_length=qp(e,r)),e.match_length>=z)if(i=Ke._tr_tally(e,e.strstart-e.match_start,e.match_length-z),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=z){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+z-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else i=Ke._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(ve(e,!1),e.strm.avail_out===0))return we}return e.insert=e.strstart<z-1?e.strstart:z-1,t===Gt?(ve(e,!0),e.strm.avail_out===0?gr:ni):e.last_lit&&(ve(e,!1),e.strm.avail_out===0)?we:cn}o(Ml,"deflate_fast");function ri(e,t){for(var r,i,n;;){if(e.lookahead<at){if(yr(e),e.lookahead<at&&t===br)return we;if(e.lookahead===0)break}if(r=0,e.lookahead>=z&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+z-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=z-1,r!==0&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-at&&(e.match_length=qp(e,r),e.match_length<=5&&(e.strategy===aE||e.match_length===z&&e.strstart-e.match_start>4096)&&(e.match_length=z-1)),e.prev_length>=z&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-z,i=Ke._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-z),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=n&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+z-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=z-1,e.strstart++,i&&(ve(e,!1),e.strm.avail_out===0))return we}else if(e.match_available){if(i=Ke._tr_tally(e,0,e.window[e.strstart-1]),i&&ve(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return we}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=Ke._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<z-1?e.strstart:z-1,t===Gt?(ve(e,!0),e.strm.avail_out===0?gr:ni):e.last_lit&&(ve(e,!1),e.strm.avail_out===0)?we:cn}o(ri,"deflate_slow");function SE(e,t){for(var r,i,n,a,s=e.window;;){if(e.lookahead<=Wt){if(yr(e),e.lookahead<=Wt&&t===br)return we;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=z&&e.strstart>0&&(n=e.strstart-1,i=s[n],i===s[++n]&&i===s[++n]&&i===s[++n])){a=e.strstart+Wt;do;while(i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&n<a);e.match_length=Wt-(a-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=z?(r=Ke._tr_tally(e,1,e.match_length-z),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Ke._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(ve(e,!1),e.strm.avail_out===0))return we}return e.insert=0,t===Gt?(ve(e,!0),e.strm.avail_out===0?gr:ni):e.last_lit&&(ve(e,!1),e.strm.avail_out===0)?we:cn}o(SE,"deflate_rle");function EE(e,t){for(var r;;){if(e.lookahead===0&&(yr(e),e.lookahead===0)){if(t===br)return we;break}if(e.match_length=0,r=Ke._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(ve(e,!1),e.strm.avail_out===0))return we}return e.insert=0,t===Gt?(ve(e,!0),e.strm.avail_out===0?gr:ni):e.last_lit&&(ve(e,!1),e.strm.avail_out===0)?we:cn}o(EE,"deflate_huff");function gt(e,t,r,i,n){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=i,this.func=n}o(gt,"Config");var ii;ii=[new gt(0,0,0,0,FE),new gt(4,4,8,4,Ml),new gt(4,5,16,8,Ml),new gt(4,6,32,32,Ml),new gt(4,4,16,16,ri),new gt(8,16,32,32,ri),new gt(8,16,128,128,ri),new gt(8,32,128,256,ri),new gt(32,128,258,1024,ri),new gt(32,258,258,4096,ri)];function kE(e){e.window_size=2*e.w_size,zt(e.head),e.max_lazy_match=ii[e.level].max_lazy,e.good_match=ii[e.level].good_length,e.nice_match=ii[e.level].nice_length,e.max_chain_length=ii[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=z-1,e.match_available=0,e.ins_h=0}o(kE,"lm_init");function xE(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=La,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Ae.Buf16(gE*2),this.dyn_dtree=new Ae.Buf16((2*mE+1)*2),this.bl_tree=new Ae.Buf16((2*wE+1)*2),zt(this.dyn_ltree),zt(this.dyn_dtree),zt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Ae.Buf16(yE+1),this.heap=new Ae.Buf16(2*jl+1),zt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Ae.Buf16(2*jl+1),zt(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}o(xE,"DeflateState");function Up(e){var t;return!e||!e.state?Vt(e,Ye):(e.total_in=e.total_out=0,e.data_type=cE,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?Ma:wr,e.adler=t.wrap===2?0:1,t.last_flush=br,Ke._tr_init(t),yt)}o(Up,"deflateResetKeep");function zp(e){var t=Up(e);return t===yt&&kE(e.state),t}o(zp,"deflateReset");function PE(e,t){return!e||!e.state||e.state.wrap!==2?Ye:(e.state.gzhead=t,yt)}o(PE,"deflateSetHeader");function Wp(e,t,r,i,n,a){if(!e)return Ye;var s=1;if(t===nE&&(t=6),i<0?(s=0,i=-i):i>15&&(s=2,i-=16),n<1||n>fE||r!==La||i<8||i>15||t<0||t>9||a<0||a>sE)return Vt(e,Ye);i===8&&(i=9);var l=new xE;return e.state=l,l.strm=e,l.wrap=s,l.gzhead=null,l.w_bits=i,l.w_size=1<<l.w_bits,l.w_mask=l.w_size-1,l.hash_bits=n+7,l.hash_size=1<<l.hash_bits,l.hash_mask=l.hash_size-1,l.hash_shift=~~((l.hash_bits+z-1)/z),l.window=new Ae.Buf8(l.w_size*2),l.head=new Ae.Buf16(l.hash_size),l.prev=new Ae.Buf16(l.w_size),l.lit_bufsize=1<<n+6,l.pending_buf_size=l.lit_bufsize*4,l.pending_buf=new Ae.Buf8(l.pending_buf_size),l.d_buf=1*l.lit_bufsize,l.l_buf=3*l.lit_bufsize,l.level=t,l.strategy=a,l.method=r,zp(e)}o(Wp,"deflateInit2");function TE(e,t){return Wp(e,t,La,uE,dE,lE)}o(TE,"deflateInit");function AE(e,t){var r,i,n,a;if(!e||!e.state||t>Lp||t<0)return e?Vt(e,Ye):Ye;if(i=e.state,!e.output||!e.input&&e.avail_in!==0||i.status===ln&&t!==Gt)return Vt(e,e.avail_out===0?Ll:Ye);if(i.strm=e,r=i.last_flush,i.last_flush=t,i.status===Ma)if(i.wrap===2)e.adler=0,Z(i,31),Z(i,139),Z(i,8),i.gzhead?(Z(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),Z(i,i.gzhead.time&255),Z(i,i.gzhead.time>>8&255),Z(i,i.gzhead.time>>16&255),Z(i,i.gzhead.time>>24&255),Z(i,i.level===9?2:i.strategy>=Ia||i.level<2?4:0),Z(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(Z(i,i.gzhead.extra.length&255),Z(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=qt(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=Hl):(Z(i,0),Z(i,0),Z(i,0),Z(i,0),Z(i,0),Z(i,i.level===9?2:i.strategy>=Ia||i.level<2?4:0),Z(i,_E),i.status=wr);else{var s=La+(i.w_bits-8<<4)<<8,l=-1;i.strategy>=Ia||i.level<2?l=0:i.level<6?l=1:i.level===6?l=2:l=3,s|=l<<6,i.strstart!==0&&(s|=bE),s+=31-s%31,i.status=wr,sn(i,s),i.strstart!==0&&(sn(i,e.adler>>>16),sn(i,e.adler&65535)),e.adler=1}if(i.status===Hl)if(i.gzhead.extra){for(n=i.pending;i.gzindex<(i.gzhead.extra.length&65535)&&!(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=qt(e.adler,i.pending_buf,i.pending-n,n)),Ut(e),n=i.pending,i.pending===i.pending_buf_size));)Z(i,i.gzhead.extra[i.gzindex]&255),i.gzindex++;i.gzhead.hcrc&&i.pending>n&&(e.adler=qt(e.adler,i.pending_buf,i.pending-n,n)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=Ba)}else i.status=Ba;if(i.status===Ba)if(i.gzhead.name){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=qt(e.adler,i.pending_buf,i.pending-n,n)),Ut(e),n=i.pending,i.pending===i.pending_buf_size)){a=1;break}i.gzindex<i.gzhead.name.length?a=i.gzhead.name.charCodeAt(i.gzindex++)&255:a=0,Z(i,a)}while(a!==0);i.gzhead.hcrc&&i.pending>n&&(e.adler=qt(e.adler,i.pending_buf,i.pending-n,n)),a===0&&(i.gzindex=0,i.status=Na)}else i.status=Na;if(i.status===Na)if(i.gzhead.comment){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=qt(e.adler,i.pending_buf,i.pending-n,n)),Ut(e),n=i.pending,i.pending===i.pending_buf_size)){a=1;break}i.gzindex<i.gzhead.comment.length?a=i.gzhead.comment.charCodeAt(i.gzindex++)&255:a=0,Z(i,a)}while(a!==0);i.gzhead.hcrc&&i.pending>n&&(e.adler=qt(e.adler,i.pending_buf,i.pending-n,n)),a===0&&(i.status=$a)}else i.status=$a;if(i.status===$a&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&Ut(e),i.pending+2<=i.pending_buf_size&&(Z(i,e.adler&255),Z(i,e.adler>>8&255),e.adler=0,i.status=wr)):i.status=wr),i.pending!==0){if(Ut(e),e.avail_out===0)return i.last_flush=-1,yt}else if(e.avail_in===0&&jp(t)<=jp(r)&&t!==Gt)return Vt(e,Ll);if(i.status===ln&&e.avail_in!==0)return Vt(e,Ll);if(e.avail_in!==0||i.lookahead!==0||t!==br&&i.status!==ln){var u=i.strategy===Ia?EE(i,t):i.strategy===oE?SE(i,t):ii[i.level].func(i,t);if((u===gr||u===ni)&&(i.status=ln),u===we||u===gr)return e.avail_out===0&&(i.last_flush=-1),yt;if(u===cn&&(t===tE?Ke._tr_align(i):t!==Lp&&(Ke._tr_stored_block(i,0,0,!1),t===rE&&(zt(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),Ut(e),e.avail_out===0))return i.last_flush=-1,yt}return t!==Gt?yt:i.wrap<=0?Mp:(i.wrap===2?(Z(i,e.adler&255),Z(i,e.adler>>8&255),Z(i,e.adler>>16&255),Z(i,e.adler>>24&255),Z(i,e.total_in&255),Z(i,e.total_in>>8&255),Z(i,e.total_in>>16&255),Z(i,e.total_in>>24&255)):(sn(i,e.adler>>>16),sn(i,e.adler&65535)),Ut(e),i.wrap>0&&(i.wrap=-i.wrap),i.pending!==0?yt:Mp)}o(AE,"deflate");function OE(e){var t;return!e||!e.state?Ye:(t=e.state.status,t!==Ma&&t!==Hl&&t!==Ba&&t!==Na&&t!==$a&&t!==wr&&t!==ln?Vt(e,Ye):(e.state=null,t===wr?Vt(e,iE):yt))}o(OE,"deflateEnd");function DE(e,t){var r=t.length,i,n,a,s,l,u,c,f;if(!e||!e.state||(i=e.state,s=i.wrap,s===2||s===1&&i.status!==Ma||i.lookahead))return Ye;for(s===1&&(e.adler=Hp(e.adler,t,r,0)),i.wrap=0,r>=i.w_size&&(s===0&&(zt(i.head),i.strstart=0,i.block_start=0,i.insert=0),f=new Ae.Buf8(i.w_size),Ae.arraySet(f,t,r-i.w_size,i.w_size,0),t=f,r=i.w_size),l=e.avail_in,u=e.next_in,c=e.input,e.avail_in=r,e.next_in=0,e.input=t,yr(i);i.lookahead>=z;){n=i.strstart,a=i.lookahead-(z-1);do i.ins_h=(i.ins_h<<i.hash_shift^i.window[n+z-1])&i.hash_mask,i.prev[n&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=n,n++;while(--a);i.strstart=n,i.lookahead=z-1,yr(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=z-1,i.match_available=0,e.next_in=u,e.input=c,e.avail_in=l,i.wrap=s,yt}o(DE,"deflateSetDictionary");bt.deflateInit=TE;bt.deflateInit2=Wp;bt.deflateReset=zp;bt.deflateResetKeep=Up;bt.deflateSetHeader=PE;bt.deflate=AE;bt.deflateEnd=OE;bt.deflateSetDictionary=DE;bt.deflateInfo="pako deflate (from Nodeca project)"});var ql=O(ai=>{"use strict";var ja=Dt(),Gp=!0,Zp=!0;try{String.fromCharCode.apply(null,[0])}catch{Gp=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Zp=!1}var fn=new ja.Buf8(256);for(Ct=0;Ct<256;Ct++)fn[Ct]=Ct>=252?6:Ct>=248?5:Ct>=240?4:Ct>=224?3:Ct>=192?2:1;var Ct;fn[254]=fn[254]=1;ai.string2buf=function(e){var t,r,i,n,a,s=e.length,l=0;for(n=0;n<s;n++)r=e.charCodeAt(n),(r&64512)===55296&&n+1<s&&(i=e.charCodeAt(n+1),(i&64512)===56320&&(r=65536+(r-55296<<10)+(i-56320),n++)),l+=r<128?1:r<2048?2:r<65536?3:4;for(t=new ja.Buf8(l),a=0,n=0;a<l;n++)r=e.charCodeAt(n),(r&64512)===55296&&n+1<s&&(i=e.charCodeAt(n+1),(i&64512)===56320&&(r=65536+(r-55296<<10)+(i-56320),n++)),r<128?t[a++]=r:r<2048?(t[a++]=192|r>>>6,t[a++]=128|r&63):r<65536?(t[a++]=224|r>>>12,t[a++]=128|r>>>6&63,t[a++]=128|r&63):(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63,t[a++]=128|r>>>6&63,t[a++]=128|r&63);return t};function Kp(e,t){if(t<65534&&(e.subarray&&Zp||!e.subarray&&Gp))return String.fromCharCode.apply(null,ja.shrinkBuf(e,t));for(var r="",i=0;i<t;i++)r+=String.fromCharCode(e[i]);return r}o(Kp,"buf2binstring");ai.buf2binstring=function(e){return Kp(e,e.length)};ai.binstring2buf=function(e){for(var t=new ja.Buf8(e.length),r=0,i=t.length;r<i;r++)t[r]=e.charCodeAt(r);return t};ai.buf2string=function(e,t){var r,i,n,a,s=t||e.length,l=new Array(s*2);for(i=0,r=0;r<s;){if(n=e[r++],n<128){l[i++]=n;continue}if(a=fn[n],a>4){l[i++]=65533,r+=a-1;continue}for(n&=a===2?31:a===3?15:7;a>1&&r<s;)n=n<<6|e[r++]&63,a--;if(a>1){l[i++]=65533;continue}n<65536?l[i++]=n:(n-=65536,l[i++]=55296|n>>10&1023,l[i++]=56320|n&1023)}return Kp(l,i)};ai.utf8border=function(e,t){var r;for(t=t||e.length,t>e.length&&(t=e.length),r=t-1;r>=0&&(e[r]&192)===128;)r--;return r<0||r===0?t:r+fn[e[r]]>t?r:t}});var Ul=O((VI,Yp)=>{"use strict";function RE(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}o(RE,"ZStream");Yp.exports=RE});var em=O(hn=>{"use strict";var un=Vp(),dn=Dt(),Wl=ql(),Vl=Ca(),CE=Ul(),Qp=Object.prototype.toString,IE=0,zl=4,oi=0,Xp=1,Jp=2,BE=-1,NE=0,$E=8;function _r(e){if(!(this instanceof _r))return new _r(e);this.options=dn.assign({level:BE,method:$E,chunkSize:16384,windowBits:15,memLevel:8,strategy:NE,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new CE,this.strm.avail_out=0;var r=un.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==oi)throw new Error(Vl[r]);if(t.header&&un.deflateSetHeader(this.strm,t.header),t.dictionary){var i;if(typeof t.dictionary=="string"?i=Wl.string2buf(t.dictionary):Qp.call(t.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(t.dictionary):i=t.dictionary,r=un.deflateSetDictionary(this.strm,i),r!==oi)throw new Error(Vl[r]);this._dict_set=!0}}o(_r,"Deflate");_r.prototype.push=function(e,t){var r=this.strm,i=this.options.chunkSize,n,a;if(this.ended)return!1;a=t===~~t?t:t===!0?zl:IE,typeof e=="string"?r.input=Wl.string2buf(e):Qp.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;do{if(r.avail_out===0&&(r.output=new dn.Buf8(i),r.next_out=0,r.avail_out=i),n=un.deflate(r,a),n!==Xp&&n!==oi)return this.onEnd(n),this.ended=!0,!1;(r.avail_out===0||r.avail_in===0&&(a===zl||a===Jp))&&(this.options.to==="string"?this.onData(Wl.buf2binstring(dn.shrinkBuf(r.output,r.next_out))):this.onData(dn.shrinkBuf(r.output,r.next_out)))}while((r.avail_in>0||r.avail_out===0)&&n!==Xp);return a===zl?(n=un.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===oi):(a===Jp&&(this.onEnd(oi),r.avail_out=0),!0)};_r.prototype.onData=function(e){this.chunks.push(e)};_r.prototype.onEnd=function(e){e===oi&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=dn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Gl(e,t){var r=new _r(t);if(r.push(e,!0),r.err)throw r.msg||Vl[r.err];return r.result}o(Gl,"deflate");function LE(e,t){return t=t||{},t.raw=!0,Gl(e,t)}o(LE,"deflateRaw");function ME(e,t){return t=t||{},t.gzip=!0,Gl(e,t)}o(ME,"gzip");hn.Deflate=_r;hn.deflate=Gl;hn.deflateRaw=LE;hn.gzip=ME});var rm=O((YI,tm)=>{"use strict";var Ha=30,jE=12;tm.exports=o(function(t,r){var i,n,a,s,l,u,c,f,d,h,p,m,w,y,g,_,k,F,S,P,b,x,v,A,T;i=t.state,n=t.next_in,A=t.input,a=n+(t.avail_in-5),s=t.next_out,T=t.output,l=s-(r-t.avail_out),u=s+(t.avail_out-257),c=i.dmax,f=i.wsize,d=i.whave,h=i.wnext,p=i.window,m=i.hold,w=i.bits,y=i.lencode,g=i.distcode,_=(1<<i.lenbits)-1,k=(1<<i.distbits)-1;e:do{w<15&&(m+=A[n++]<<w,w+=8,m+=A[n++]<<w,w+=8),F=y[m&_];t:for(;;){if(S=F>>>24,m>>>=S,w-=S,S=F>>>16&255,S===0)T[s++]=F&65535;else if(S&16){P=F&65535,S&=15,S&&(w<S&&(m+=A[n++]<<w,w+=8),P+=m&(1<<S)-1,m>>>=S,w-=S),w<15&&(m+=A[n++]<<w,w+=8,m+=A[n++]<<w,w+=8),F=g[m&k];r:for(;;){if(S=F>>>24,m>>>=S,w-=S,S=F>>>16&255,S&16){if(b=F&65535,S&=15,w<S&&(m+=A[n++]<<w,w+=8,w<S&&(m+=A[n++]<<w,w+=8)),b+=m&(1<<S)-1,b>c){t.msg="invalid distance too far back",i.mode=Ha;break e}if(m>>>=S,w-=S,S=s-l,b>S){if(S=b-S,S>d&&i.sane){t.msg="invalid distance too far back",i.mode=Ha;break e}if(x=0,v=p,h===0){if(x+=f-S,S<P){P-=S;do T[s++]=p[x++];while(--S);x=s-b,v=T}}else if(h<S){if(x+=f+h-S,S-=h,S<P){P-=S;do T[s++]=p[x++];while(--S);if(x=0,h<P){S=h,P-=S;do T[s++]=p[x++];while(--S);x=s-b,v=T}}}else if(x+=h-S,S<P){P-=S;do T[s++]=p[x++];while(--S);x=s-b,v=T}for(;P>2;)T[s++]=v[x++],T[s++]=v[x++],T[s++]=v[x++],P-=3;P&&(T[s++]=v[x++],P>1&&(T[s++]=v[x++]))}else{x=s-b;do T[s++]=T[x++],T[s++]=T[x++],T[s++]=T[x++],P-=3;while(P>2);P&&(T[s++]=T[x++],P>1&&(T[s++]=T[x++]))}}else if(S&64){t.msg="invalid distance code",i.mode=Ha;break e}else{F=g[(F&65535)+(m&(1<<S)-1)];continue r}break}}else if(S&64)if(S&32){i.mode=jE;break e}else{t.msg="invalid literal/length code",i.mode=Ha;break e}else{F=y[(F&65535)+(m&(1<<S)-1)];continue t}break}}while(n<a&&s<u);P=w>>3,n-=P,w-=P<<3,m&=(1<<w)-1,t.next_in=n,t.next_out=s,t.avail_in=n<a?5+(a-n):5-(n-a),t.avail_out=s<u?257+(u-s):257-(s-u),i.hold=m,i.bits=w},"inflate_fast")});var cm=O((JI,lm)=>{"use strict";var im=Dt(),si=15,nm=852,am=592,om=0,Zl=1,sm=2,HE=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],qE=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],UE=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],zE=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];lm.exports=o(function(t,r,i,n,a,s,l,u){var c=u.bits,f=0,d=0,h=0,p=0,m=0,w=0,y=0,g=0,_=0,k=0,F,S,P,b,x,v=null,A=0,T,R=new im.Buf16(si+1),B=new im.Buf16(si+1),M=null,de=0,Be,tt,rt;for(f=0;f<=si;f++)R[f]=0;for(d=0;d<n;d++)R[r[i+d]]++;for(m=c,p=si;p>=1&&R[p]===0;p--);if(m>p&&(m=p),p===0)return a[s++]=1<<24|64<<16|0,a[s++]=1<<24|64<<16|0,u.bits=1,0;for(h=1;h<p&&R[h]===0;h++);for(m<h&&(m=h),g=1,f=1;f<=si;f++)if(g<<=1,g-=R[f],g<0)return-1;if(g>0&&(t===om||p!==1))return-1;for(B[1]=0,f=1;f<si;f++)B[f+1]=B[f]+R[f];for(d=0;d<n;d++)r[i+d]!==0&&(l[B[r[i+d]]++]=d);if(t===om?(v=M=l,T=19):t===Zl?(v=HE,A-=257,M=qE,de-=257,T=256):(v=UE,M=zE,T=-1),k=0,d=0,f=h,x=s,w=m,y=0,P=-1,_=1<<m,b=_-1,t===Zl&&_>nm||t===sm&&_>am)return 1;for(;;){Be=f-y,l[d]<T?(tt=0,rt=l[d]):l[d]>T?(tt=M[de+l[d]],rt=v[A+l[d]]):(tt=96,rt=0),F=1<<f-y,S=1<<w,h=S;do S-=F,a[x+(k>>y)+S]=Be<<24|tt<<16|rt|0;while(S!==0);for(F=1<<f-1;k&F;)F>>=1;if(F!==0?(k&=F-1,k+=F):k=0,d++,--R[f]===0){if(f===p)break;f=r[i+l[d]]}if(f>m&&(k&b)!==P){for(y===0&&(y=m),x+=h,w=f-y,g=1<<w;w+y<p&&(g-=R[w+y],!(g<=0));)w++,g<<=1;if(_+=1<<w,t===Zl&&_>nm||t===sm&&_>am)return 1;P=k&b,a[P]=m<<24|w<<16|x-s|0}}return k!==0&&(a[x+k]=f-y<<24|64<<16|0),u.bits=m,0},"inflate_table")});var zm=O(ot=>{"use strict";var ze=Dt(),ec=Nl(),_t=$l(),WE=rm(),pn=cm(),VE=0,Bm=1,Nm=2,fm=4,GE=5,qa=6,vr=0,ZE=1,KE=2,Xe=-2,$m=-3,tc=-4,YE=-5,um=8,Lm=1,dm=2,hm=3,pm=4,mm=5,wm=6,gm=7,ym=8,bm=9,_m=10,Wa=11,It=12,Kl=13,vm=14,Yl=15,Fm=16,Sm=17,Em=18,km=19,Ua=20,za=21,xm=22,Pm=23,Tm=24,Am=25,Om=26,Xl=27,Dm=28,Rm=29,re=30,rc=31,XE=32,JE=852,QE=592,e1=15,t1=e1;function Cm(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}o(Cm,"zswap32");function r1(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new ze.Buf16(320),this.work=new ze.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}o(r1,"InflateState");function Mm(e){var t;return!e||!e.state?Xe:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=Lm,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new ze.Buf32(JE),t.distcode=t.distdyn=new ze.Buf32(QE),t.sane=1,t.back=-1,vr)}o(Mm,"inflateResetKeep");function jm(e){var t;return!e||!e.state?Xe:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,Mm(e))}o(jm,"inflateReset");function Hm(e,t){var r,i;return!e||!e.state||(i=e.state,t<0?(r=0,t=-t):(r=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?Xe:(i.window!==null&&i.wbits!==t&&(i.window=null),i.wrap=r,i.wbits=t,jm(e))}o(Hm,"inflateReset2");function qm(e,t){var r,i;return e?(i=new r1,e.state=i,i.window=null,r=Hm(e,t),r!==vr&&(e.state=null),r):Xe}o(qm,"inflateInit2");function i1(e){return qm(e,t1)}o(i1,"inflateInit");var Im=!0,Jl,Ql;function n1(e){if(Im){var t;for(Jl=new ze.Buf32(512),Ql=new ze.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(pn(Bm,e.lens,0,288,Jl,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;pn(Nm,e.lens,0,32,Ql,0,e.work,{bits:5}),Im=!1}e.lencode=Jl,e.lenbits=9,e.distcode=Ql,e.distbits=5}o(n1,"fixedtables");function Um(e,t,r,i){var n,a=e.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new ze.Buf8(a.wsize)),i>=a.wsize?(ze.arraySet(a.window,t,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(n=a.wsize-a.wnext,n>i&&(n=i),ze.arraySet(a.window,t,r-i,n,a.wnext),i-=n,i?(ze.arraySet(a.window,t,r-i,i,0),a.wnext=i,a.whave=a.wsize):(a.wnext+=n,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=n))),0}o(Um,"updatewindow");function a1(e,t){var r,i,n,a,s,l,u,c,f,d,h,p,m,w,y=0,g,_,k,F,S,P,b,x,v=new ze.Buf8(4),A,T,R=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return Xe;r=e.state,r.mode===It&&(r.mode=Kl),s=e.next_out,n=e.output,u=e.avail_out,a=e.next_in,i=e.input,l=e.avail_in,c=r.hold,f=r.bits,d=l,h=u,x=vr;e:for(;;)switch(r.mode){case Lm:if(r.wrap===0){r.mode=Kl;break}for(;f<16;){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}if(r.wrap&2&&c===35615){r.check=0,v[0]=c&255,v[1]=c>>>8&255,r.check=_t(r.check,v,2,0),c=0,f=0,r.mode=dm;break}if(r.flags=0,r.head&&(r.head.done=!1),!(r.wrap&1)||(((c&255)<<8)+(c>>8))%31){e.msg="incorrect header check",r.mode=re;break}if((c&15)!==um){e.msg="unknown compression method",r.mode=re;break}if(c>>>=4,f-=4,b=(c&15)+8,r.wbits===0)r.wbits=b;else if(b>r.wbits){e.msg="invalid window size",r.mode=re;break}r.dmax=1<<b,e.adler=r.check=1,r.mode=c&512?_m:It,c=0,f=0;break;case dm:for(;f<16;){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}if(r.flags=c,(r.flags&255)!==um){e.msg="unknown compression method",r.mode=re;break}if(r.flags&57344){e.msg="unknown header flags set",r.mode=re;break}r.head&&(r.head.text=c>>8&1),r.flags&512&&(v[0]=c&255,v[1]=c>>>8&255,r.check=_t(r.check,v,2,0)),c=0,f=0,r.mode=hm;case hm:for(;f<32;){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}r.head&&(r.head.time=c),r.flags&512&&(v[0]=c&255,v[1]=c>>>8&255,v[2]=c>>>16&255,v[3]=c>>>24&255,r.check=_t(r.check,v,4,0)),c=0,f=0,r.mode=pm;case pm:for(;f<16;){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}r.head&&(r.head.xflags=c&255,r.head.os=c>>8),r.flags&512&&(v[0]=c&255,v[1]=c>>>8&255,r.check=_t(r.check,v,2,0)),c=0,f=0,r.mode=mm;case mm:if(r.flags&1024){for(;f<16;){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}r.length=c,r.head&&(r.head.extra_len=c),r.flags&512&&(v[0]=c&255,v[1]=c>>>8&255,r.check=_t(r.check,v,2,0)),c=0,f=0}else r.head&&(r.head.extra=null);r.mode=wm;case wm:if(r.flags&1024&&(p=r.length,p>l&&(p=l),p&&(r.head&&(b=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),ze.arraySet(r.head.extra,i,a,p,b)),r.flags&512&&(r.check=_t(r.check,i,p,a)),l-=p,a+=p,r.length-=p),r.length))break e;r.length=0,r.mode=gm;case gm:if(r.flags&2048){if(l===0)break e;p=0;do b=i[a+p++],r.head&&b&&r.length<65536&&(r.head.name+=String.fromCharCode(b));while(b&&p<l);if(r.flags&512&&(r.check=_t(r.check,i,p,a)),l-=p,a+=p,b)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=ym;case ym:if(r.flags&4096){if(l===0)break e;p=0;do b=i[a+p++],r.head&&b&&r.length<65536&&(r.head.comment+=String.fromCharCode(b));while(b&&p<l);if(r.flags&512&&(r.check=_t(r.check,i,p,a)),l-=p,a+=p,b)break e}else r.head&&(r.head.comment=null);r.mode=bm;case bm:if(r.flags&512){for(;f<16;){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}if(c!==(r.check&65535)){e.msg="header crc mismatch",r.mode=re;break}c=0,f=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=It;break;case _m:for(;f<32;){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}e.adler=r.check=Cm(c),c=0,f=0,r.mode=Wa;case Wa:if(r.havedict===0)return e.next_out=s,e.avail_out=u,e.next_in=a,e.avail_in=l,r.hold=c,r.bits=f,KE;e.adler=r.check=1,r.mode=It;case It:if(t===GE||t===qa)break e;case Kl:if(r.last){c>>>=f&7,f-=f&7,r.mode=Xl;break}for(;f<3;){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}switch(r.last=c&1,c>>>=1,f-=1,c&3){case 0:r.mode=vm;break;case 1:if(n1(r),r.mode=Ua,t===qa){c>>>=2,f-=2;break e}break;case 2:r.mode=Sm;break;case 3:e.msg="invalid block type",r.mode=re}c>>>=2,f-=2;break;case vm:for(c>>>=f&7,f-=f&7;f<32;){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}if((c&65535)!==(c>>>16^65535)){e.msg="invalid stored block lengths",r.mode=re;break}if(r.length=c&65535,c=0,f=0,r.mode=Yl,t===qa)break e;case Yl:r.mode=Fm;case Fm:if(p=r.length,p){if(p>l&&(p=l),p>u&&(p=u),p===0)break e;ze.arraySet(n,i,a,p,s),l-=p,a+=p,u-=p,s+=p,r.length-=p;break}r.mode=It;break;case Sm:for(;f<14;){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}if(r.nlen=(c&31)+257,c>>>=5,f-=5,r.ndist=(c&31)+1,c>>>=5,f-=5,r.ncode=(c&15)+4,c>>>=4,f-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=re;break}r.have=0,r.mode=Em;case Em:for(;r.have<r.ncode;){for(;f<3;){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}r.lens[R[r.have++]]=c&7,c>>>=3,f-=3}for(;r.have<19;)r.lens[R[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,A={bits:r.lenbits},x=pn(VE,r.lens,0,19,r.lencode,0,r.work,A),r.lenbits=A.bits,x){e.msg="invalid code lengths set",r.mode=re;break}r.have=0,r.mode=km;case km:for(;r.have<r.nlen+r.ndist;){for(;y=r.lencode[c&(1<<r.lenbits)-1],g=y>>>24,_=y>>>16&255,k=y&65535,!(g<=f);){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}if(k<16)c>>>=g,f-=g,r.lens[r.have++]=k;else{if(k===16){for(T=g+2;f<T;){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}if(c>>>=g,f-=g,r.have===0){e.msg="invalid bit length repeat",r.mode=re;break}b=r.lens[r.have-1],p=3+(c&3),c>>>=2,f-=2}else if(k===17){for(T=g+3;f<T;){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}c>>>=g,f-=g,b=0,p=3+(c&7),c>>>=3,f-=3}else{for(T=g+7;f<T;){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}c>>>=g,f-=g,b=0,p=11+(c&127),c>>>=7,f-=7}if(r.have+p>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=re;break}for(;p--;)r.lens[r.have++]=b}}if(r.mode===re)break;if(r.lens[256]===0){e.msg="invalid code -- missing end-of-block",r.mode=re;break}if(r.lenbits=9,A={bits:r.lenbits},x=pn(Bm,r.lens,0,r.nlen,r.lencode,0,r.work,A),r.lenbits=A.bits,x){e.msg="invalid literal/lengths set",r.mode=re;break}if(r.distbits=6,r.distcode=r.distdyn,A={bits:r.distbits},x=pn(Nm,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,A),r.distbits=A.bits,x){e.msg="invalid distances set",r.mode=re;break}if(r.mode=Ua,t===qa)break e;case Ua:r.mode=za;case za:if(l>=6&&u>=258){e.next_out=s,e.avail_out=u,e.next_in=a,e.avail_in=l,r.hold=c,r.bits=f,WE(e,h),s=e.next_out,n=e.output,u=e.avail_out,a=e.next_in,i=e.input,l=e.avail_in,c=r.hold,f=r.bits,r.mode===It&&(r.back=-1);break}for(r.back=0;y=r.lencode[c&(1<<r.lenbits)-1],g=y>>>24,_=y>>>16&255,k=y&65535,!(g<=f);){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}if(_&&!(_&240)){for(F=g,S=_,P=k;y=r.lencode[P+((c&(1<<F+S)-1)>>F)],g=y>>>24,_=y>>>16&255,k=y&65535,!(F+g<=f);){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}c>>>=F,f-=F,r.back+=F}if(c>>>=g,f-=g,r.back+=g,r.length=k,_===0){r.mode=Om;break}if(_&32){r.back=-1,r.mode=It;break}if(_&64){e.msg="invalid literal/length code",r.mode=re;break}r.extra=_&15,r.mode=xm;case xm:if(r.extra){for(T=r.extra;f<T;){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}r.length+=c&(1<<r.extra)-1,c>>>=r.extra,f-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=Pm;case Pm:for(;y=r.distcode[c&(1<<r.distbits)-1],g=y>>>24,_=y>>>16&255,k=y&65535,!(g<=f);){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}if(!(_&240)){for(F=g,S=_,P=k;y=r.distcode[P+((c&(1<<F+S)-1)>>F)],g=y>>>24,_=y>>>16&255,k=y&65535,!(F+g<=f);){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}c>>>=F,f-=F,r.back+=F}if(c>>>=g,f-=g,r.back+=g,_&64){e.msg="invalid distance code",r.mode=re;break}r.offset=k,r.extra=_&15,r.mode=Tm;case Tm:if(r.extra){for(T=r.extra;f<T;){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}r.offset+=c&(1<<r.extra)-1,c>>>=r.extra,f-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=re;break}r.mode=Am;case Am:if(u===0)break e;if(p=h-u,r.offset>p){if(p=r.offset-p,p>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=re;break}p>r.wnext?(p-=r.wnext,m=r.wsize-p):m=r.wnext-p,p>r.length&&(p=r.length),w=r.window}else w=n,m=s-r.offset,p=r.length;p>u&&(p=u),u-=p,r.length-=p;do n[s++]=w[m++];while(--p);r.length===0&&(r.mode=za);break;case Om:if(u===0)break e;n[s++]=r.length,u--,r.mode=za;break;case Xl:if(r.wrap){for(;f<32;){if(l===0)break e;l--,c|=i[a++]<<f,f+=8}if(h-=u,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=r.flags?_t(r.check,n,h,s-h):ec(r.check,n,h,s-h)),h=u,(r.flags?c:Cm(c))!==r.check){e.msg="incorrect data check",r.mode=re;break}c=0,f=0}r.mode=Dm;case Dm:if(r.wrap&&r.flags){for(;f<32;){if(l===0)break e;l--,c+=i[a++]<<f,f+=8}if(c!==(r.total&4294967295)){e.msg="incorrect length check",r.mode=re;break}c=0,f=0}r.mode=Rm;case Rm:x=ZE;break e;case re:x=$m;break e;case rc:return tc;case XE:default:return Xe}return e.next_out=s,e.avail_out=u,e.next_in=a,e.avail_in=l,r.hold=c,r.bits=f,(r.wsize||h!==e.avail_out&&r.mode<re&&(r.mode<Xl||t!==fm))&&Um(e,e.output,e.next_out,h-e.avail_out)?(r.mode=rc,tc):(d-=e.avail_in,h-=e.avail_out,e.total_in+=d,e.total_out+=h,r.total+=h,r.wrap&&h&&(e.adler=r.check=r.flags?_t(r.check,n,h,e.next_out-h):ec(r.check,n,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===It?128:0)+(r.mode===Ua||r.mode===Yl?256:0),(d===0&&h===0||t===fm)&&x===vr&&(x=YE),x)}o(a1,"inflate");function o1(e){if(!e||!e.state)return Xe;var t=e.state;return t.window&&(t.window=null),e.state=null,vr}o(o1,"inflateEnd");function s1(e,t){var r;return!e||!e.state||(r=e.state,!(r.wrap&2))?Xe:(r.head=t,t.done=!1,vr)}o(s1,"inflateGetHeader");function l1(e,t){var r=t.length,i,n,a;return!e||!e.state||(i=e.state,i.wrap!==0&&i.mode!==Wa)?Xe:i.mode===Wa&&(n=1,n=ec(n,t,r,0),n!==i.check)?$m:(a=Um(e,t,r,r),a?(i.mode=rc,tc):(i.havedict=1,vr))}o(l1,"inflateSetDictionary");ot.inflateReset=jm;ot.inflateReset2=Hm;ot.inflateResetKeep=Mm;ot.inflateInit=i1;ot.inflateInit2=qm;ot.inflate=a1;ot.inflateEnd=o1;ot.inflateGetHeader=s1;ot.inflateSetDictionary=l1;ot.inflateInfo="pako inflate (from Nodeca project)"});var ic=O((rB,Wm)=>{"use strict";Wm.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}});var Gm=O((iB,Vm)=>{"use strict";function c1(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}o(c1,"GZheader");Vm.exports=c1});var Km=O(wn=>{"use strict";var li=zm(),mn=Dt(),Va=ql(),ce=ic(),nc=Ca(),f1=Ul(),u1=Gm(),Zm=Object.prototype.toString;function Fr(e){if(!(this instanceof Fr))return new Fr(e);this.options=mn.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new f1,this.strm.avail_out=0;var r=li.inflateInit2(this.strm,t.windowBits);if(r!==ce.Z_OK)throw new Error(nc[r]);if(this.header=new u1,li.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=Va.string2buf(t.dictionary):Zm.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=li.inflateSetDictionary(this.strm,t.dictionary),r!==ce.Z_OK)))throw new Error(nc[r])}o(Fr,"Inflate");Fr.prototype.push=function(e,t){var r=this.strm,i=this.options.chunkSize,n=this.options.dictionary,a,s,l,u,c,f=!1;if(this.ended)return!1;s=t===~~t?t:t===!0?ce.Z_FINISH:ce.Z_NO_FLUSH,typeof e=="string"?r.input=Va.binstring2buf(e):Zm.call(e)==="[object ArrayBuffer]"?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;do{if(r.avail_out===0&&(r.output=new mn.Buf8(i),r.next_out=0,r.avail_out=i),a=li.inflate(r,ce.Z_NO_FLUSH),a===ce.Z_NEED_DICT&&n&&(a=li.inflateSetDictionary(this.strm,n)),a===ce.Z_BUF_ERROR&&f===!0&&(a=ce.Z_OK,f=!1),a!==ce.Z_STREAM_END&&a!==ce.Z_OK)return this.onEnd(a),this.ended=!0,!1;r.next_out&&(r.avail_out===0||a===ce.Z_STREAM_END||r.avail_in===0&&(s===ce.Z_FINISH||s===ce.Z_SYNC_FLUSH))&&(this.options.to==="string"?(l=Va.utf8border(r.output,r.next_out),u=r.next_out-l,c=Va.buf2string(r.output,l),r.next_out=u,r.avail_out=i-u,u&&mn.arraySet(r.output,r.output,l,u,0),this.onData(c)):this.onData(mn.shrinkBuf(r.output,r.next_out))),r.avail_in===0&&r.avail_out===0&&(f=!0)}while((r.avail_in>0||r.avail_out===0)&&a!==ce.Z_STREAM_END);return a===ce.Z_STREAM_END&&(s=ce.Z_FINISH),s===ce.Z_FINISH?(a=li.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===ce.Z_OK):(s===ce.Z_SYNC_FLUSH&&(this.onEnd(ce.Z_OK),r.avail_out=0),!0)};Fr.prototype.onData=function(e){this.chunks.push(e)};Fr.prototype.onEnd=function(e){e===ce.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=mn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function ac(e,t){var r=new Fr(t);if(r.push(e,!0),r.err)throw r.msg||nc[r.err];return r.result}o(ac,"inflate");function d1(e,t){return t=t||{},t.raw=!0,ac(e,t)}o(d1,"inflateRaw");wn.Inflate=Fr;wn.inflate=ac;wn.inflateRaw=d1;wn.ungzip=ac});var Jm=O((sB,Xm)=>{"use strict";var h1=Dt().assign,p1=em(),m1=Km(),w1=ic(),Ym={};h1(Ym,p1,m1,w1);Xm.exports=Ym});var tw=O((lB,ew)=>{"use strict";var Qm=o((e,t)=>function(...r){let i=t.promiseModule;return new i((n,a)=>{t.multiArgs?r.push((...s)=>{t.errorFirst?s[0]?a(s):(s.shift(),n(s)):n(s)}):t.errorFirst?r.push((s,l)=>{s?a(s):n(l)}):r.push(n),e.apply(this,r)})},"processFn");ew.exports=(e,t)=>{t=Object.assign({exclude:[/.+(Sync|Stream)$/],errorFirst:!0,promiseModule:Promise},t);let r=typeof e;if(!(e!==null&&(r==="object"||r==="function")))throw new TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${e===null?"null":r}\``);let i=o(a=>{let s=o(l=>typeof l=="string"?a===l:l.test(a),"match");return t.include?t.include.some(s):!t.exclude.some(s)},"filter"),n;r==="function"?n=o(function(...a){return t.excludeMain?e(...a):Qm(e,t).apply(this,a)},"ret"):n=Object.create(Object.getPrototypeOf(e));for(let a in e){let s=e[a];n[a]=typeof s=="function"&&i(a)?Qm(s,t):s}return n}});var iw=O((fB,rw)=>{"use strict";function g1(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}o(g1,"escapeRegExp");function vt(e,t,r){return t=t instanceof RegExp?t:new RegExp(g1(t),"g"),e.replace(t,r)}o(vt,"replaceAll");var y1={clean:o(function(t){if(typeof t!="string")throw new Error("Expected a string, received: "+t);return t=vt(t,"./","/"),t=vt(t,"..","."),t=vt(t," ","-"),t=vt(t,/^[~^:?*\\\-]/g,""),t=vt(t,/[~^:?*\\]/g,"-"),t=vt(t,/[~^:?*\\\-]$/g,""),t=vt(t,"@{","-"),t=vt(t,/\.$/g,""),t=vt(t,/\/$/g,""),t=vt(t,/\.lock$/g,""),t},"clean")};rw.exports=y1});var aw=O((dB,nw)=>{nw.exports=function(e,t){var r=e,i=t,n=r.length,a=i.length,s=!1,l=null,u=n+1,c=[],f=[],d=[],h="",p=-1,m=0,w=1,y,g,_=o(function(){n>=a&&(y=r,g=n,r=i,i=y,n=a,a=g,s=!0,u=n+1)},"init"),k=o(function(b,x,v){return{x:b,y:x,k:v}},"P"),F=o(function(b,x){return{elem:b,t:x}},"seselem"),S=o(function(b,x,v){var A,T,R;for(x>v?A=c[b-1+u]:A=c[b+1+u],R=Math.max(x,v),T=R-b;T<n&&R<a&&r[T]===i[R];)++T,++R;return c[b+u]=f.length,f[f.length]=new k(T,R,A),R},"snake"),P=o(function(b){var x,v,A,T,R;for(x=v=1,A=T=0,R=b.length-1;R>=0;--R)for(;A<b[R].x||T<b[R].y;)b[R].y-b[R].x>T-A?(s?d[d.length]=new F(i[T],p):d[d.length]=new F(i[T],w),++v,++T):b[R].y-b[R].x<T-A?(s?d[d.length]=new F(r[A],w):d[d.length]=new F(r[A],p),++x,++A):(d[d.length]=new F(r[A],m),h+=r[A],++x,++v,++A,++T)},"recordseq");return _(),{SES_DELETE:-1,SES_COMMON:0,SES_ADD:1,editdistance:o(function(){return l},"editdistance"),getlcs:o(function(){return h},"getlcs"),getses:o(function(){return d},"getses"),compose:o(function(){var b,x,v,A,T,R,B,M;for(b=a-n,x=n+a+3,v={},B=0;B<x;++B)v[B]=-1,c[B]=-1;A=-1;do{for(++A,M=-A;M<=b-1;++M)v[M+u]=S(M,v[M-1+u]+1,v[M+1+u]);for(M=b+A;M>=b+1;--M)v[M+u]=S(M,v[M-1+u]+1,v[M+1+u]);v[b+u]=S(b,v[b-1+u]+1,v[b+1+u])}while(v[b+u]!==a);for(l=b+2*A,T=c[b+u],R=[];T!==-1;)R[R.length]=new k(f[T].x,f[T].y,null),T=f[T].k;P(R)},"compose")}}});var lw=O((pB,sw)=>{var b1=aw();function _1(e,t){var r=new b1(e,t);r.compose();for(var i=r.getses(),n,a,s=e.length-1,l=t.length-1,u=i.length-1;u>=0;--u)i[u].t===r.SES_COMMON?(a?(a.chain={file1index:s,file2index:l,chain:null},a=a.chain):(n={file1index:s,file2index:l,chain:null},a=n),s--,l--):i[u].t===r.SES_DELETE?s--:i[u].t===r.SES_ADD&&l--;var c={file1index:-1,file2index:-1,chain:null};return a?(a.chain=c,n):c}o(_1,"longestCommonSubsequence");function ow(e,t){for(var r=[],i=e.length,n=t.length,a=_1(e,t);a!==null;a=a.chain){var s=i-a.file1index-1,l=n-a.file2index-1;i=a.file1index,n=a.file2index,(s||l)&&r.push({file1:[i+1,s],file2:[n+1,l]})}return r.reverse(),r}o(ow,"diffIndices");function v1(e,t,r){var i,n=ow(t,e),a=ow(t,r),s=[];function l(B,M){s.push([B.file1[0],M,B.file1[1],B.file2[0],B.file2[1]])}for(o(l,"addHunk"),i=0;i<n.length;i++)l(n[i],0);for(i=0;i<a.length;i++)l(a[i],2);s.sort(function(B,M){return B[0]-M[0]});var u=[],c=0;function f(B){B>c&&(u.push([1,c,B-c]),c=B)}o(f,"copyCommon");for(var d=0;d<s.length;d++){for(var h=d,p=s[d],m=p[0],w=m+p[2];d<s.length-1;){var y=s[d+1],g=y[0];if(g>w)break;w=Math.max(w,g+y[2]),d++}if(f(m),h==d)p[4]>0&&u.push([p[1],p[3],p[4]]);else{var _={0:[e.length,-1,t.length,-1],2:[r.length,-1,t.length,-1]};for(i=h;i<=d;i++){p=s[i];var k=p[1],F=_[k],S=p[0],P=S+p[2],b=p[3],x=b+p[4];F[0]=Math.min(b,F[0]),F[1]=Math.max(x,F[1]),F[2]=Math.min(S,F[2]),F[3]=Math.max(P,F[3])}var v=_[0][0]+(m-_[0][2]),A=_[0][1]+(w-_[0][3]),T=_[2][0]+(m-_[2][2]),R=_[2][1]+(w-_[2][3]);u.push([-1,v,A-v,m,w-m,T,R-T])}c=w}return f(t.length),u}o(v1,"diff3MergeIndices");function F1(e,t,r){var i=[],n=[e,t,r],a=v1(e,t,r),s=[];function l(){s.length&&i.push({ok:s}),s=[]}o(l,"flushOk");function u(p){for(var m=0;m<p.length;m++)s.push(p[m])}o(u,"pushOk");function c(p){if(p[2]!=p[6])return!0;for(var m=p[1],w=p[5],y=0;y<p[2];y++)if(e[y+m]!=r[y+w])return!0;return!1}o(c,"isTrueConflict");for(var f=0;f<a.length;f++){var d=a[f],h=d[0];h==-1?c(d)?(l(),i.push({conflict:{a:e.slice(d[1],d[1]+d[2]),aIndex:d[1],o:t.slice(d[3],d[3]+d[4]),oIndex:d[3],b:r.slice(d[5],d[5]+d[6]),bIndex:d[5]}})):u(n[0].slice(d[1],d[1]+d[2])):u(n[h].slice(d[1],d[1]+d[2]))}return l(),i}o(F1,"diff3Merge");sw.exports=F1});var ue=O(I=>{"use strict";Object.defineProperty(I,"__esModule",{value:!0});function ir(e){return e&&typeof e=="object"&&"default"in e?e.default:e}o(ir,"_interopDefault");var bn=ir(Zu()),Dw=ir(cp()),S1=ir(up()),Dc=ir(Jm()),oc=ir(tw()),E1=ir(X("ignore")),_n=ir(iw()),k1=ir(lw()),ao=class ao extends Error{constructor(t){super(t),this.caller=""}toJSON(){return{code:this.code,data:this.data,caller:this.caller,message:this.message,stack:this.stack}}fromJSON(t){let r=new ao(t.message);return r.code=t.code,r.data=t.data,r.caller=t.caller,r.stack=t.stack,r}get isIsomorphicGitError(){return!0}};o(ao,"BaseError");var W=ao,oo=class oo extends W{constructor(t){super(`Modifying the index is not possible because you have unmerged files: ${t.toString}. Fix them up in the work tree, and then use 'git add/rm as appropriate to mark resolution and make a commit.`),this.code=this.name=oo.code,this.data={filepaths:t}}};o(oo,"UnmergedPathsError");var vn=oo;vn.code="UnmergedPathsError";var so=class so extends W{constructor(t){super(`An internal error caused this command to fail.
|
|
4
|
-
|
|
5
|
-
If you're not a developer, report the bug to the developers of the application you're using. If this is a bug in isomorphic-git then you should create a proper bug yourselves. The bug should include a minimal reproduction and details about the version and environment.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
`)
|
|
9
|
-
[remote "${t}"]
|
|
10
|
-
fetch = +refs/heads/*:refs/remotes/origin/*
|
|
11
|
-
`),this.code=this.name=ho.code,this.data={remote:t}}};o(ho,"NoRefspecError");var Fn=ho;Fn.code="NoRefspecError";var po=class po{constructor(t){if(this.refs=new Map,this.parsedConfig=[],t){let r=null;this.parsedConfig=t.trim().split(`
|
|
12
|
-
`).map(i=>{if(/^\s*#/.test(i))return{line:i,comment:!0};let n=i.indexOf(" ");if(i.startsWith("^")){let a=i.slice(1);return this.refs.set(r+"^{}",a),{line:i,ref:r,peeled:a}}else{let a=i.slice(0,n);return r=i.slice(n+1),this.refs.set(r,a),{line:i,ref:r,oid:a}}})}return this}static from(t){return new po(t)}delete(t){this.parsedConfig=this.parsedConfig.filter(r=>r.ref!==t),this.refs.delete(t)}toString(){return this.parsedConfig.map(({line:t})=>t).join(`
|
|
13
|
-
`)+`
|
|
14
|
-
`}};o(po,"GitPackedRefs");var Xa=po,mo=class mo{constructor({remotePath:t,localPath:r,force:i,matchPrefix:n}){Object.assign(this,{remotePath:t,localPath:r,force:i,matchPrefix:n})}static from(t){let[r,i,n,a,s]=t.match(/^(\+?)(.*?)(\*?):(.*?)(\*?)$/).slice(1),l=r==="+",u=n==="*";if(u!==(s==="*"))throw new L("Invalid refspec");return new mo({remotePath:i,localPath:a,force:l,matchPrefix:u})}translate(t){if(this.matchPrefix){if(t.startsWith(this.remotePath))return this.localPath+t.replace(this.remotePath,"")}else if(t===this.remotePath)return this.localPath;return null}reverseTranslate(t){if(this.matchPrefix){if(t.startsWith(this.localPath))return this.remotePath+t.replace(this.localPath,"")}else if(t===this.localPath)return this.remotePath;return null}};o(mo,"GitRefSpec");var Ja=mo,wo=class wo{constructor(t=[]){this.rules=t}static from(t){let r=[];for(let i of t)r.push(Ja.from(i));return new wo(r)}add(t){let r=Ja.from(t);this.rules.push(r)}translate(t){let r=[];for(let i of this.rules)for(let n of t){let a=i.translate(n);a&&r.push([n,a])}return r}translateOne(t){let r=null;for(let i of this.rules){let n=i.translate(t);n&&(r=n)}return r}localNamespaces(){return this.rules.filter(t=>t.matchPrefix).map(t=>t.localPath.replace(/\/$/,""))}};o(wo,"GitRefSpecSet");var vc=wo;function B1(e,t){let r=e.replace(/\^\{\}$/,""),i=t.replace(/\^\{\}$/,""),n=-(r<i)||+(r>i);return n===0?e.endsWith("^{}")?1:-1:n}o(B1,"compareRefNames");function N1(e,t){let r="",i=0,n=-1,a=0,s="\0";for(let l=0;l<=e.length;++l){if(l<e.length)s=e[l];else{if(s==="/")break;s="/"}if(s==="/"){if(!(n===l-1||a===1))if(a===2){if(r.length<2||i!==2||r.at(-1)!=="."||r.at(-2)!=="."){if(r.length>2){let u=r.lastIndexOf("/");u===-1?(r="",i=0):(r=r.slice(0,u),i=r.length-1-r.lastIndexOf("/")),n=l,a=0;continue}else if(r.length!==0){r="",i=0,n=l,a=0;continue}}t&&(r+=r.length>0?"/..":"..",i=2)}else r.length>0?r+="/"+e.slice(n+1,l):r=e.slice(n+1,l),i=l-n-1;n=l,a=0}else s==="."&&a!==-1?++a:a=-1}return r}o(N1,"normalizeString");function $1(e){if(!e.length)return".";let t=e[0]==="/",r=e.at(-1)==="/";return e=N1(e,!t),e.length?(r&&(e+="/"),t?`/${e}`:e):t?"/":r?"./":"."}o($1,"normalize");function D(...e){if(e.length===0)return".";let t;for(let r=0;r<e.length;++r){let i=e[r];i.length>0&&(t===void 0?t=i:t+="/"+i)}return t===void 0?".":$1(t)}o(D,"join");var L1=o(e=>{if(typeof e=="number")return e;e=e.toLowerCase();let t=parseInt(e);return e.endsWith("k")&&(t*=1024),e.endsWith("m")&&(t*=1024*1024),e.endsWith("g")&&(t*=1024*1024*1024),t},"num"),gn=o(e=>{if(typeof e=="boolean")return e;if(e=e.trim().toLowerCase(),e==="true"||e==="yes"||e==="on")return!0;if(e==="false"||e==="no"||e==="off")return!1;throw Error(`Expected 'true', 'false', 'yes', 'no', 'on', or 'off', but got ${e}`)},"bool"),fw={core:{filemode:gn,bare:gn,logallrefupdates:gn,symlinks:gn,ignorecase:gn,bigFileThreshold:L1}},M1=/^\[([A-Za-z0-9-.]+)(?: "(.*)")?\]$/,j1=/^[A-Za-z0-9-.]+$/,H1=/^([A-Za-z][A-Za-z-]*)(?: *= *(.*))?$/,q1=/^[A-Za-z][A-Za-z-]*$/,U1=/^(.*?)( *[#;].*)$/,z1=o(e=>{let t=M1.exec(e);if(t!=null){let[r,i]=t.slice(1);return[r,i]}return null},"extractSectionLine"),W1=o(e=>{let t=H1.exec(e);if(t!=null){let[r,i="true"]=t.slice(1),n=V1(i),a=G1(n);return[r,a]}return null},"extractVariableLine"),V1=o(e=>{let t=U1.exec(e);if(t==null)return e;let[r,i]=t.slice(1);return uw(r)&&uw(i)?`${r}${i}`:r},"removeComments"),uw=o(e=>(e.match(/(?:^|[^\\])"/g)||[]).length%2!==0,"hasOddNumberOfQuotes"),G1=o(e=>e.split("").reduce((t,r,i,n)=>{let a=r==='"'&&n[i-1]!=="\\",s=r==="\\"&&n[i+1]==='"';return a||s?t:t+r},""),"removeQuotes"),dw=o(e=>e!=null?e.toLowerCase():null,"lower"),Fc=o((e,t,r)=>[dw(e),t,dw(r)].filter(i=>i!=null).join("."),"getPath"),hw=o(e=>{let t=e.split("."),r=t.shift(),i=t.pop(),n=t.length?t.join("."):void 0;return{section:r,subsection:n,name:i,path:Fc(r,n,i),sectionPath:Fc(r,n,null),isSection:!!r}},"normalizePath"),Z1=o((e,t)=>e.reduce((r,i,n)=>t(i)?n:r,-1),"findLastIndex"),go=class go{constructor(t){let r=null,i=null;this.parsedConfig=t?t.split(`
|
|
15
|
-
`).map(n=>{let a=null,s=null,l=n.trim(),u=z1(l),c=u!=null;if(c)[r,i]=u;else{let d=W1(l);d!=null&&([a,s]=d)}let f=Fc(r,i,a);return{line:n,isSection:c,section:r,subsection:i,name:a,value:s,path:f}}):[]}static from(t){return new go(t)}async get(t,r=!1){let i=hw(t).path,n=this.parsedConfig.filter(a=>a.path===i).map(({section:a,name:s,value:l})=>{let u=fw[a]&&fw[a][s];return u?u(l):l});return r?n:n.pop()}async getall(t){return this.get(t,!0)}async getSubsections(t){return this.parsedConfig.filter(r=>r.isSection&&r.section===t).map(r=>r.subsection)}async deleteSection(t,r){this.parsedConfig=this.parsedConfig.filter(i=>!(i.section===t&&i.subsection===r))}async append(t,r){return this.set(t,r,!0)}async set(t,r,i=!1){let{section:n,subsection:a,name:s,path:l,sectionPath:u,isSection:c}=hw(t),f=Z1(this.parsedConfig,d=>d.path===l);if(r==null)f!==-1&&this.parsedConfig.splice(f,1);else if(f!==-1){let d=this.parsedConfig[f],h=Object.assign({},d,{name:s,value:r,modified:!0});i?this.parsedConfig.splice(f+1,0,h):this.parsedConfig[f]=h}else{let d=this.parsedConfig.findIndex(p=>p.path===u),h={section:n,subsection:a,name:s,value:r,modified:!0,path:l};if(j1.test(n)&&q1.test(s))if(d>=0)this.parsedConfig.splice(d+1,0,h);else{let p={isSection:c,section:n,subsection:a,modified:!0,path:u};this.parsedConfig.push(p,h)}}}toString(){return this.parsedConfig.map(({line:t,section:r,subsection:i,name:n,value:a,modified:s=!1})=>s?n!=null&&a!=null?typeof a=="string"&&/[#;]/.test(a)?` ${n} = "${a}"`:` ${n} = ${a}`:i!=null?`[${r} "${i}"]`:`[${r}]`:t).join(`
|
|
16
|
-
`)}};o(go,"GitConfig");var Sc=go,Hc=class Hc{static async get({fs:t,gitdir:r}){let i=await t.read(`${r}/config`,{encoding:"utf8"});return Sc.from(i)}static async save({fs:t,gitdir:r,config:i}){await t.write(`${r}/config`,i.toString(),{encoding:"utf8"})}};o(Hc,"GitConfigManager");var se=Hc,Ga=o(e=>[`${e}`,`refs/${e}`,`refs/tags/${e}`,`refs/heads/${e}`,`refs/remotes/${e}`,`refs/remotes/${e}/HEAD`],"refpaths"),K1=["config","description","index","shallow","commondir"],fc;async function Zt(e,t){return fc===void 0&&(fc=new bn),fc.acquire(e,t)}o(Zt,"acquireLock");var he=class he{static async updateRemoteRefs({fs:t,gitdir:r,remote:i,refs:n,symrefs:a,tags:s,refspecs:l=void 0,prune:u=!1,pruneTags:c=!1}){for(let y of n.values())if(!y.match(/[0-9a-f]{40}/))throw new Xt(y);let f=await se.get({fs:t,gitdir:r});if(!l){if(l=await f.getall(`remote.${i}.fetch`),l.length===0)throw new Fn(i);l.unshift(`+HEAD:refs/remotes/${i}/HEAD`)}let d=vc.from(l),h=new Map;if(c){let y=await he.listRefs({fs:t,gitdir:r,filepath:"refs/tags"});await he.deleteRefs({fs:t,gitdir:r,refs:y.map(g=>`refs/tags/${g}`)})}if(s){for(let y of n.keys())if(y.startsWith("refs/tags")&&!y.endsWith("^{}")&&!await he.exists({fs:t,gitdir:r,ref:y})){let g=n.get(y);h.set(y,g)}}let p=d.translate([...n.keys()]);for(let[y,g]of p){let _=n.get(y);h.set(g,_)}let m=d.translate([...a.keys()]);for(let[y,g]of m){let _=a.get(y),k=d.translateOne(_);k&&h.set(g,`ref: ${k}`)}let w=[];if(u){for(let y of d.localNamespaces()){let g=(await he.listRefs({fs:t,gitdir:r,filepath:y})).map(_=>`${y}/${_}`);for(let _ of g)h.has(_)||w.push(_)}w.length>0&&await he.deleteRefs({fs:t,gitdir:r,refs:w})}for(let[y,g]of h)await Zt(y,async()=>t.write(D(r,y),`${g.trim()}
|
|
17
|
-
`,"utf8"));return{pruned:w}}static async writeRef({fs:t,gitdir:r,ref:i,value:n}){if(!n.match(/[0-9a-f]{40}/))throw new Xt(n);await Zt(i,async()=>t.write(D(r,i),`${n.trim()}
|
|
18
|
-
`,"utf8"))}static async writeSymbolicRef({fs:t,gitdir:r,ref:i,value:n}){await Zt(i,async()=>t.write(D(r,i),`ref: ${n.trim()}
|
|
19
|
-
`,"utf8"))}static async deleteRef({fs:t,gitdir:r,ref:i}){return he.deleteRefs({fs:t,gitdir:r,refs:[i]})}static async deleteRefs({fs:t,gitdir:r,refs:i}){await Promise.all(i.map(l=>t.rm(D(r,l))));let n=await Zt("packed-refs",async()=>t.read(`${r}/packed-refs`,{encoding:"utf8"})),a=Xa.from(n),s=a.refs.size;for(let l of i)a.refs.has(l)&&a.delete(l);a.refs.size<s&&(n=a.toString(),await Zt("packed-refs",async()=>t.write(`${r}/packed-refs`,n,{encoding:"utf8"})))}static async resolve({fs:t,gitdir:r,ref:i,depth:n=void 0}){if(n!==void 0&&(n--,n===-1))return i;if(i.startsWith("ref: "))return i=i.slice(5),he.resolve({fs:t,gitdir:r,ref:i,depth:n});if(i.length===40&&/[0-9a-f]{40}/.test(i))return i;let a=await he.packedRefs({fs:t,gitdir:r}),s=Ga(i).filter(l=>!K1.includes(l));for(let l of s){let u=await Zt(l,async()=>await t.read(`${r}/${l}`,{encoding:"utf8"})||a.get(l));if(u)return he.resolve({fs:t,gitdir:r,ref:u.trim(),depth:n})}throw new J(i)}static async exists({fs:t,gitdir:r,ref:i}){try{return await he.expand({fs:t,gitdir:r,ref:i}),!0}catch{return!1}}static async expand({fs:t,gitdir:r,ref:i}){if(i.length===40&&/[0-9a-f]{40}/.test(i))return i;let n=await he.packedRefs({fs:t,gitdir:r}),a=Ga(i);for(let s of a)if(await Zt(s,async()=>t.exists(`${r}/${s}`))||n.has(s))return s;throw new J(i)}static async expandAgainstMap({ref:t,map:r}){let i=Ga(t);for(let n of i)if(await r.has(n))return n;throw new J(t)}static resolveAgainstMap({ref:t,fullref:r=t,depth:i=void 0,map:n}){if(i!==void 0&&(i--,i===-1))return{fullref:r,oid:t};if(t.startsWith("ref: "))return t=t.slice(5),he.resolveAgainstMap({ref:t,fullref:r,depth:i,map:n});if(t.length===40&&/[0-9a-f]{40}/.test(t))return{fullref:r,oid:t};let a=Ga(t);for(let s of a){let l=n.get(s);if(l)return he.resolveAgainstMap({ref:l.trim(),fullref:s,depth:i,map:n})}throw new J(t)}static async packedRefs({fs:t,gitdir:r}){let i=await Zt("packed-refs",async()=>t.read(`${r}/packed-refs`,{encoding:"utf8"}));return Xa.from(i).refs}static async listRefs({fs:t,gitdir:r,filepath:i}){let n=he.packedRefs({fs:t,gitdir:r}),a=null;try{a=await t.readdirDeep(`${r}/${i}`),a=a.map(s=>s.replace(`${r}/${i}/`,""))}catch{a=[]}for(let s of(await n).keys())s.startsWith(i)&&(s=s.replace(i+"/",""),a.includes(s)||a.push(s));return a.sort(B1),a}static async listBranches({fs:t,gitdir:r,remote:i}){return i?he.listRefs({fs:t,gitdir:r,filepath:`refs/remotes/${i}`}):he.listRefs({fs:t,gitdir:r,filepath:"refs/heads"})}static async listTags({fs:t,gitdir:r}){return(await he.listRefs({fs:t,gitdir:r,filepath:"refs/tags"})).filter(n=>!n.endsWith("^{}"))}};o(he,"GitRefManager");var C=he;function Y1(e,t){return Wo(pw(e),pw(t))}o(Y1,"compareTreeEntryPath");function pw(e){return e.mode==="040000"?e.path+"/":e.path}o(pw,"appendSlashIfDir");function Nw(e){switch(e){case"040000":return"tree";case"100644":return"blob";case"100755":return"blob";case"120000":return"blob";case"160000":return"commit"}throw new L(`Unexpected GitTree entry mode: ${e}`)}o(Nw,"mode2type$1");function X1(e){let t=[],r=0;for(;r<e.length;){let i=e.indexOf(32,r);if(i===-1)throw new L(`GitTree: Error parsing buffer at byte location ${r}: Could not find the next space character.`);let n=e.indexOf(0,r);if(n===-1)throw new L(`GitTree: Error parsing buffer at byte location ${r}: Could not find the next null character.`);let a=e.slice(r,i).toString("utf8");a==="40000"&&(a="040000");let s=Nw(a),l=e.slice(i+1,n).toString("utf8");if(l.includes("\\")||l.includes("/"))throw new di(l);let u=e.slice(n+1,n+21).toString("hex");r=n+21,t.push({mode:a,path:l,oid:u,type:s})}return t}o(X1,"parseBuffer");function J1(e){if(typeof e=="number"&&(e=e.toString(8)),e.match(/^0?4.*/))return"040000";if(e.match(/^1006.*/))return"100644";if(e.match(/^1007.*/))return"100755";if(e.match(/^120.*/))return"120000";if(e.match(/^160.*/))return"160000";throw new L(`Could not understand file mode: ${e}`)}o(J1,"limitModeToAllowed");function Q1(e){return!e.oid&&e.sha&&(e.oid=e.sha),e.mode=J1(e.mode),e.type||(e.type=Nw(e.mode)),e}o(Q1,"nudgeIntoShape");var yo=class yo{constructor(t){if(Buffer.isBuffer(t))this._entries=X1(t);else if(Array.isArray(t))this._entries=t.map(Q1);else throw new L("invalid type passed to GitTree constructor");this._entries.sort(Rw)}static from(t){return new yo(t)}render(){return this._entries.map(t=>`${t.mode} ${t.type} ${t.oid} ${t.path}`).join(`
|
|
20
|
-
`)}toObject(){let t=[...this._entries];return t.sort(Y1),Buffer.concat(t.map(r=>{let i=Buffer.from(r.mode.replace(/^0/,"")),n=Buffer.from(" "),a=Buffer.from(r.path,"utf8"),s=Buffer.from([0]),l=Buffer.from(r.oid,"hex");return Buffer.concat([i,n,a,s,l])}))}entries(){return this._entries}*[Symbol.iterator](){for(let t of this._entries)yield t}};o(yo,"GitTree");var Me=yo,qc=class qc{static wrap({type:t,object:r}){let i=`${t} ${r.length}\0`,n=i.length,a=n+r.length,s=new Uint8Array(a);for(let l=0;l<n;l++)s[l]=i.charCodeAt(l);return s.set(r,n),s}static unwrap(t){let r=t.indexOf(32),i=t.indexOf(0),n=t.slice(0,r).toString("utf8"),a=t.slice(r+1,i).toString("utf8"),s=t.length-(i+1);if(parseInt(a)!==s)throw new L(`Length mismatch: expected ${a} bytes but got ${s} instead.`);return{type:n,object:Buffer.from(t.slice(i+1))}}};o(qc,"GitObject");var Jt=qc;async function $w({fs:e,gitdir:t,oid:r}){let i=`objects/${r.slice(0,2)}/${r.slice(2)}`,n=await e.read(`${t}/${i}`);return n?{object:n,format:"deflated",source:i}:null}o($w,"readObjectLoose");function ek(e,t){let r=new Je(e),i=mw(r);if(i!==t.byteLength)throw new L(`applyDelta expected source buffer to be ${i} bytes but the provided buffer was ${t.length} bytes`);let n=mw(r),a,s=gw(r,t);if(s.byteLength===n)a=s;else{a=Buffer.alloc(n);let l=new Je(a);for(l.copy(s);!r.eof();)l.copy(gw(r,t));let u=l.tell();if(n!==u)throw new L(`applyDelta expected target buffer to be ${n} bytes but the resulting buffer was ${u} bytes`)}return a}o(ek,"applyDelta");function mw(e){let t=0,r=0,i=null;do i=e.readUInt8(),t|=(i&127)<<r,r+=7;while(i&128);return t}o(mw,"readVarIntLE");function ww(e,t,r){let i=0,n=0;for(;r--;)t&1&&(i|=e.readUInt8()<<n),t>>=1,n+=8;return i}o(ww,"readCompactLE");function gw(e,t){let r=e.readUInt8(),i=128,n=15,a=112;if(r&i){let s=ww(e,r&n,4),l=ww(e,(r&a)>>4,3);return l===0&&(l=65536),t.slice(s,s+l)}else return e.slice(r)}o(gw,"readOp");function tk(e){let t=[e];return{next(){return Promise.resolve({done:t.length===0,value:t.pop()})},return(){return t=[],{}},[Symbol.asyncIterator](){return this}}}o(tk,"fromValue");function Lw(e){return e[Symbol.asyncIterator]?e[Symbol.asyncIterator]():e[Symbol.iterator]?e[Symbol.iterator]():e.next?e:tk(e)}o(Lw,"getIterator");var Uc=class Uc{constructor(t){if(typeof Buffer>"u")throw new Error("Missing Buffer dependency");this.stream=Lw(t),this.buffer=null,this.cursor=0,this.undoCursor=0,this.started=!1,this._ended=!1,this._discardedBytes=0}eof(){return this._ended&&this.cursor===this.buffer.length}tell(){return this._discardedBytes+this.cursor}async byte(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(1),this.buffer[this.undoCursor]}async chunk(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(this.buffer.length),this.buffer.slice(this.undoCursor,this.cursor)}async read(t){if(!this.eof())return this.started||await this._init(),this.cursor+t>this.buffer.length&&(this._trim(),await this._accumulate(t)),this._moveCursor(t),this.buffer.slice(this.undoCursor,this.cursor)}async skip(t){this.eof()||(this.started||await this._init(),this.cursor+t>this.buffer.length&&(this._trim(),await this._accumulate(t)),this._moveCursor(t))}async undo(){this.cursor=this.undoCursor}async _next(){this.started=!0;let{done:t,value:r}=await this.stream.next();return t&&(this._ended=!0,!r)?Buffer.alloc(0):(r&&(r=Buffer.from(r)),r)}_trim(){this.buffer=this.buffer.slice(this.undoCursor),this.cursor-=this.undoCursor,this._discardedBytes+=this.undoCursor,this.undoCursor=0}_moveCursor(t){this.undoCursor=this.cursor,this.cursor+=t,this.cursor>this.buffer.length&&(this.cursor=this.buffer.length)}async _accumulate(t){if(this._ended)return;let r=[this.buffer];for(;this.cursor+t>rk(r);){let i=await this._next();if(this._ended)break;r.push(i)}this.buffer=Buffer.concat(r)}async _loadnext(){this._discardedBytes+=this.buffer.length,this.undoCursor=0,this.cursor=0,this.buffer=await this._next()}async _init(){this.buffer=await this._next()}};o(Uc,"StreamReader");var Qa=Uc;function rk(e){return e.reduce((t,r)=>t+r.length,0)}o(rk,"lengthBuffers");async function ik(e,t){let r=new Qa(e),i=await r.read(4);if(i=i.toString("utf8"),i!=="PACK")throw new L(`Invalid PACK header '${i}'`);let n=await r.read(4);if(n=n.readUInt32BE(0),n!==2)throw new L(`Invalid packfile version: ${n}`);let a=await r.read(4);if(a=a.readUInt32BE(0),!(a<1))for(;!r.eof()&&a--;){let s=r.tell(),{type:l,length:u,ofs:c,reference:f}=await nk(r),d=new Dc.Inflate;for(;!d.result;){let h=await r.chunk();if(!h)break;if(d.push(h,!1),d.err)throw new L(`Pako error: ${d.msg}`);if(d.result){if(d.result.length!==u)throw new L("Inflated object size is different from that stated in packfile.");await r.undo(),await r.read(h.length-d.strm.avail_in);let p=r.tell();await t({data:d.result,type:l,num:a,offset:s,end:p,reference:f,ofs:c})}}}}o(ik,"listpack");async function nk(e){let t=await e.byte(),r=t>>4&7,i=t&15;if(t&128){let s=4;do t=await e.byte(),i|=(t&127)<<s,s+=7;while(t&128)}let n,a;if(r===6){let s=0;n=0;let l=[];do t=await e.byte(),n|=(t&127)<<s,s+=7,l.push(t);while(t&128);a=Buffer.from(l)}return r===7&&(a=await e.read(20)),{type:r,length:i,ofs:n,reference:a}}o(nk,"parseHeader");var uc=!1;async function Mw(e){return uc===null&&(uc=ok()),uc?ak(e):Dc.inflate(e)}o(Mw,"inflate");async function ak(e){let t=new DecompressionStream("deflate"),r=new Blob([e]).stream().pipeThrough(t);return new Uint8Array(await new Response(r).arrayBuffer())}o(ak,"browserInflate");function ok(){try{if(new DecompressionStream("deflate"))return!0}catch{}return!1}o(ok,"testDecompressionStream");function sk(e){let t=[],r=0,i=0;do{r=e.readUInt8();let n=r&127;t.push(n),i=r&128}while(i);return t.reduce((n,a)=>n+1<<7|a,-1)}o(sk,"decodeVarInt");function lk(e,t){let r=t,i=4,n=null;do n=e.readUInt8(),r|=(n&127)<<i,i+=7;while(n&128);return r}o(lk,"otherVarIntDecode");var yn=class yn{constructor(t){Object.assign(this,t),this.offsetCache={}}static async fromIdx({idx:t,getExternalRefDelta:r}){let i=new Je(t);if(i.slice(4).toString("hex")!=="ff744f63")return;let a=i.readUInt32BE();if(a!==2)throw new L(`Unable to read version ${a} packfile IDX. (Only version 2 supported)`);if(t.byteLength>2048*1024*1024)throw new L("To keep implementation simple, I haven't implemented the layer 5 feature needed to support packfiles > 2GB in size.");i.seek(i.tell()+4*255);let s=i.readUInt32BE(),l=[];for(let f=0;f<s;f++){let d=i.slice(20).toString("hex");l[f]=d}i.seek(i.tell()+4*s);let u=new Map;for(let f=0;f<s;f++)u.set(l[f],i.readUInt32BE());let c=i.slice(20).toString("hex");return new yn({hashes:l,crcs:{},offsets:u,packfileSha:c,getExternalRefDelta:r})}static async fromPack({pack:t,getExternalRefDelta:r,onProgress:i}){let n={1:"commit",2:"tree",3:"blob",4:"tag",6:"ofs-delta",7:"ref-delta"},a={},s=t.slice(-20).toString("hex"),l=[],u={},c=new Map,f=null,d=null;await ik([t],async({data:y,type:g,reference:_,offset:k,num:F})=>{f===null&&(f=F);let S=Math.floor((f-F)*100/f);S!==d&&i&&await i({phase:"Receiving objects",loaded:f-F,total:f}),d=S,g=n[g],["commit","tree","blob","tag"].includes(g)?a[k]={type:g,offset:k}:g==="ofs-delta"?a[k]={type:g,offset:k}:g==="ref-delta"&&(a[k]={type:g,offset:k})});let h=Object.keys(a).map(Number);for(let[y,g]of h.entries()){let _=y+1===h.length?t.byteLength-20:h[y+1],k=a[g],F=S1.buf(t.slice(g,_))>>>0;k.end=_,k.crc=F}let p=new yn({pack:Promise.resolve(t),packfileSha:s,crcs:u,hashes:l,offsets:c,getExternalRefDelta:r});d=null;let m=0,w=[0,0,0,0,0,0,0,0,0,0,0,0];for(let y in a){y=Number(y);let g=Math.floor(m*100/f);g!==d&&i&&await i({phase:"Resolving deltas",loaded:m,total:f}),m++,d=g;let _=a[y];if(!_.oid)try{p.readDepth=0,p.externalReadDepth=0;let{type:k,object:F}=await p.readSlice({start:y});w[p.readDepth]+=1;let S=await Nt(Jt.wrap({type:k,object:F}));_.oid=S,l.push(S),c.set(S,y),u[S]=_.crc}catch{continue}}return l.sort(),p}async toBuffer(){let t=[],r=o((c,f)=>{t.push(Buffer.from(c,f))},"write");r("ff744f63","hex"),r("00000002","hex");let i=new Je(Buffer.alloc(256*4));for(let c=0;c<256;c++){let f=0;for(let d of this.hashes)parseInt(d.slice(0,2),16)<=c&&f++;i.writeUInt32BE(f)}t.push(i.buffer);for(let c of this.hashes)r(c,"hex");let n=new Je(Buffer.alloc(this.hashes.length*4));for(let c of this.hashes)n.writeUInt32BE(this.crcs[c]);t.push(n.buffer);let a=new Je(Buffer.alloc(this.hashes.length*4));for(let c of this.hashes)a.writeUInt32BE(this.offsets.get(c));t.push(a.buffer),r(this.packfileSha,"hex");let s=Buffer.concat(t),l=await Nt(s),u=Buffer.alloc(20);return u.write(l,"hex"),Buffer.concat([s,u])}async load({pack:t}){this.pack=t}async unload(){this.pack=null}async read({oid:t}){if(!this.offsets.get(t)){if(this.getExternalRefDelta)return this.externalReadDepth++,this.getExternalRefDelta(t);throw new L(`Could not read object ${t} from packfile`)}let r=this.offsets.get(t);return this.readSlice({start:r})}async readSlice({start:t}){if(this.offsetCache[t])return Object.assign({},this.offsetCache[t]);this.readDepth++;let r={16:"commit",32:"tree",48:"blob",64:"tag",96:"ofs_delta",112:"ref_delta"};if(!this.pack)throw new L("Tried to read from a GitPackIndex with no packfile loaded into memory");let i=(await this.pack).slice(t),n=new Je(i),a=n.readUInt8(),s=a&112,l=r[s];if(l===void 0)throw new L("Unrecognized type: 0b"+s.toString(2));let u=a&15,c=u;a&128&&(c=lk(n,u));let d=null,h=null;if(l==="ofs_delta"){let m=sk(n),w=t-m;({object:d,type:l}=await this.readSlice({start:w}))}if(l==="ref_delta"){let m=n.slice(20).toString("hex");({object:d,type:l}=await this.read({oid:m}))}let p=i.slice(n.tell());if(h=Buffer.from(await Mw(p)),h.byteLength!==c)throw new L(`Packfile told us object would have length ${c} but it had length ${h.byteLength}`);return d&&(h=Buffer.from(ek(h,d))),this.readDepth>3&&(this.offsetCache[t]={type:l,object:h}),{type:l,format:"content",object:h}}};o(yn,"GitPackIndex");var Sn=yn,Za=Symbol("PackfileCache");async function ck({fs:e,filename:t,getExternalRefDelta:r,emitter:i,emitterPrefix:n}){let a=await e.read(t);return Sn.fromIdx({idx:a,getExternalRefDelta:r})}o(ck,"loadPackIndex");function Rc({fs:e,cache:t,filename:r,getExternalRefDelta:i,emitter:n,emitterPrefix:a}){t[Za]||(t[Za]=new Map);let s=t[Za].get(r);return s||(s=ck({fs:e,filename:r,getExternalRefDelta:i,emitter:n,emitterPrefix:a}),t[Za].set(r,s)),s}o(Rc,"readPackIndex");async function fk({fs:e,cache:t,gitdir:r,oid:i,format:n="content",getExternalRefDelta:a}){let s=await e.readdir(D(r,"objects/pack"));s=s.filter(l=>l.endsWith(".idx"));for(let l of s){let u=`${r}/objects/pack/${l}`,c=await Rc({fs:e,cache:t,filename:u,getExternalRefDelta:a});if(c.error)throw new L(c.error);if(c.offsets.has(i)){if(!c.pack){let d=u.replace(/idx$/,"pack");c.pack=e.read(d)}let f=await c.read({oid:i,getExternalRefDelta:a});return f.format="content",f.source=`objects/pack/${l.replace(/idx$/,"pack")}`,f}}return null}o(fk,"readObjectPacked");async function Q({fs:e,cache:t,gitdir:r,oid:i,format:n="content"}){let a=o(f=>Q({fs:e,cache:t,gitdir:r,oid:f}),"getExternalRefDelta"),s;if(i==="4b825dc642cb6eb9a060e54bf8d69288fbee4904"&&(s={format:"wrapped",object:Buffer.from("tree 0\0")}),s||(s=await $w({fs:e,gitdir:r,oid:i})),!s){if(s=await fk({fs:e,cache:t,gitdir:r,oid:i,getExternalRefDelta:a}),!s)throw new J(i);return s}if(n==="deflated"||(s.format==="deflated"&&(s.object=Buffer.from(await Mw(s.object)),s.format="wrapped"),n==="wrapped"))return s;let l=await Nt(s.object);if(l!==i)throw new L(`SHA check failed! Expected ${i}, computed ${l}`);let{object:u,type:c}=Jt.unwrap(s.object);if(s.type=c,s.object=u,s.format="content",n==="content")return s;throw new L(`invalid requested format "${n}"`)}o(Q,"_readObject");var bo=class bo extends W{constructor(t,r,i=!0){super(`Failed to create ${t} at ${r} because it already exists.${i?` (Hint: use 'force: true' parameter to overwrite existing ${t}.)`:""}`),this.code=this.name=bo.code,this.data={noun:t,where:r,canForce:i}}};o(bo,"AlreadyExistsError");var st=bo;st.code="AlreadyExistsError";var _o=class _o extends W{constructor(t,r,i){super(`Found multiple ${t} matching "${r}" (${i.join(", ")}). Use a longer abbreviation length to disambiguate them.`),this.code=this.name=_o.code,this.data={nouns:t,short:r,matches:i}}};o(_o,"AmbiguousError");var En=_o;En.code="AmbiguousError";var vo=class vo extends W{constructor(t){super(`Your local changes to the following files would be overwritten by checkout: ${t.join(", ")}`),this.code=this.name=vo.code,this.data={filepaths:t}}};o(vo,"CheckoutConflictError");var kn=vo;kn.code="CheckoutConflictError";var Fo=class Fo extends W{constructor(t,r){super(`Failed to checkout "${t}" because commit ${r} is not available locally. Do a git fetch to make the branch available locally.`),this.code=this.name=Fo.code,this.data={ref:t,oid:r}}};o(Fo,"CommitNotFetchedError");var xn=Fo;xn.code="CommitNotFetchedError";var So=class So extends W{constructor(){super("Empty response from git server."),this.code=this.name=So.code,this.data={}}};o(So,"EmptyServerResponseError");var Pn=So;Pn.code="EmptyServerResponseError";var Eo=class Eo extends W{constructor(){super("A simple fast-forward merge was not possible."),this.code=this.name=Eo.code,this.data={}}};o(Eo,"FastForwardError");var Tn=Eo;Tn.code="FastForwardError";var ko=class ko extends W{constructor(t,r){super(`One or more branches were not updated: ${t}`),this.code=this.name=ko.code,this.data={prettyDetails:t,result:r}}};o(ko,"GitPushError");var An=ko;An.code="GitPushError";var xo=class xo extends W{constructor(t,r,i){super(`HTTP Error: ${t} ${r}`),this.code=this.name=xo.code,this.data={statusCode:t,statusMessage:r,response:i}}};o(xo,"HttpError");var mi=xo;mi.code="HttpError";var Po=class Po extends W{constructor(t){let r="invalid filepath";t==="leading-slash"||t==="trailing-slash"?r='"filepath" parameter should not include leading or trailing directory separators because these can cause problems on some platforms.':t==="directory"&&(r='"filepath" should not be a directory.'),super(r),this.code=this.name=Po.code,this.data={reason:t}}};o(Po,"InvalidFilepathError");var Qt=Po;Qt.code="InvalidFilepathError";var To=class To extends W{constructor(t,r){super(`"${t}" would be an invalid git reference. (Hint: a valid alternative would be "${r}".)`),this.code=this.name=To.code,this.data={ref:t,suggestion:r}}};o(To,"InvalidRefNameError");var lt=To;lt.code="InvalidRefNameError";var Ao=class Ao extends W{constructor(t){super(`Maximum search depth of ${t} exceeded.`),this.code=this.name=Ao.code,this.data={depth:t}}};o(Ao,"MaxDepthError");var On=Ao;On.code="MaxDepthError";var Oo=class Oo extends W{constructor(){super("Merges with conflicts are not supported yet."),this.code=this.name=Oo.code,this.data={}}};o(Oo,"MergeNotSupportedError");var wi=Oo;wi.code="MergeNotSupportedError";var Do=class Do extends W{constructor(t,r,i,n){super(`Automatic merge failed with one or more merge conflicts in the following files: ${t.toString()}. Fix conflicts then commit the result.`),this.code=this.name=Do.code,this.data={filepaths:t,bothModified:r,deleteByUs:i,deleteByTheirs:n}}};o(Do,"MergeConflictError");var gi=Do;gi.code="MergeConflictError";var Ro=class Ro extends W{constructor(t){super(`No name was provided for ${t} in the argument or in the .git/config file.`),this.code=this.name=Ro.code,this.data={role:t}}};o(Ro,"MissingNameError");var Ee=Ro;Ee.code="MissingNameError";var Co=class Co extends W{constructor(t){super(`The function requires a "${t}" parameter but none was provided.`),this.code=this.name=Co.code,this.data={parameter:t}}};o(Co,"MissingParameterError");var Le=Co;Le.code="MissingParameterError";var Io=class Io extends W{constructor(t){super('There are multiple errors that were thrown by the method. Please refer to the "errors" property to see more'),this.code=this.name=Io.code,this.data={errors:t},this.errors=t}};o(Io,"MultipleGitError");var Dn=Io;Dn.code="MultipleGitError";var Bo=class Bo extends W{constructor(t,r){super(`Expected "${t}" but received "${r}".`),this.code=this.name=Bo.code,this.data={expected:t,actual:r}}};o(Bo,"ParseError");var kr=Bo;kr.code="ParseError";var No=class No extends W{constructor(t){let r="";t==="not-fast-forward"?r=" because it was not a simple fast-forward":t==="tag-exists"&&(r=" because tag already exists"),super(`Push rejected${r}. Use "force: true" to override.`),this.code=this.name=No.code,this.data={reason:t}}};o(No,"PushRejectedError");var yi=No;yi.code="PushRejectedError";var $o=class $o extends W{constructor(t,r){super(`Remote does not support the "${t}" so the "${r}" parameter cannot be used.`),this.code=this.name=$o.code,this.data={capability:t,parameter:r}}};o($o,"RemoteCapabilityError");var Yt=$o;Yt.code="RemoteCapabilityError";var Lo=class Lo extends W{constructor(t,r){super(`Remote did not reply using the "smart" HTTP protocol. Expected "001e# service=git-upload-pack" but received: ${t}`),this.code=this.name=Lo.code,this.data={preview:t,response:r}}};o(Lo,"SmartHttpError");var Rn=Lo;Rn.code="SmartHttpError";var Mo=class Mo extends W{constructor(t,r,i){super(`Git remote "${t}" uses an unrecognized transport protocol: "${r}"`),this.code=this.name=Mo.code,this.data={url:t,transport:r,suggestion:i}}};o(Mo,"UnknownTransportError");var Cn=Mo;Cn.code="UnknownTransportError";var jo=class jo extends W{constructor(t){super(`Cannot parse remote URL: "${t}"`),this.code=this.name=jo.code,this.data={url:t}}};o(jo,"UrlParseError");var In=jo;In.code="UrlParseError";var Ho=class Ho extends W{constructor(){super("The operation was canceled."),this.code=this.name=Ho.code,this.data={}}};o(Ho,"UserCanceledError");var bi=Ho;bi.code="UserCanceledError";var qo=class qo extends W{constructor(t){super(`Could not merge index: Entry for '${t}' is not up to date. Either reset the index entry to HEAD, or stage your unstaged changes.`),this.code=this.name=qo.code,this.data={filepath:t}}};o(qo,"IndexResetError");var Bn=qo;Bn.code="IndexResetError";var Uo=class Uo extends W{constructor(t){super(`"${t}" does not point to any commit. You're maybe working on a repository with no commits yet. `),this.code=this.name=Uo.code,this.data={ref:t}}};o(Uo,"NoCommitError");var Nn=Uo;Nn.code="NoCommitError";var jw=Object.freeze({__proto__:null,AlreadyExistsError:st,AmbiguousError:En,CheckoutConflictError:kn,CommitNotFetchedError:xn,EmptyServerResponseError:Pn,FastForwardError:Tn,GitPushError:An,HttpError:mi,InternalError:L,InvalidFilepathError:Qt,InvalidOidError:Xt,InvalidRefNameError:lt,MaxDepthError:On,MergeNotSupportedError:wi,MergeConflictError:gi,MissingNameError:Ee,MissingParameterError:Le,MultipleGitError:Dn,NoRefspecError:Fn,NotFoundError:J,ObjectTypeError:Oe,ParseError:kr,PushRejectedError:yi,RemoteCapabilityError:Yt,SmartHttpError:Rn,UnknownTransportError:Cn,UnsafeFilepathError:di,UrlParseError:In,UserCanceledError:bi,UnmergedPathsError:vn,IndexResetError:Bn,NoCommitError:Nn});function Ec({name:e,email:t,timestamp:r,timezoneOffset:i}){return i=uk(i),`${e} <${t}> ${r} ${i}`}o(Ec,"formatAuthor");function uk(e){let t=dk(hk(e));e=Math.abs(e);let r=Math.floor(e/60);e-=r*60;let i=String(r),n=String(e);return i.length<2&&(i="0"+i),n.length<2&&(n="0"+n),(t===-1?"-":"+")+i+n}o(uk,"formatTimezoneOffset");function dk(e){return Math.sign(e)||(Object.is(e,-0)?-1:1)}o(dk,"simpleSign");function hk(e){return e===0?e:-e}o(hk,"negateExceptForZero");function Bt(e){return e=e.replace(/\r/g,""),e=e.replace(/^\n+/,""),e=e.replace(/\n+$/,"")+`
|
|
21
|
-
`,e}o(Bt,"normalizeNewlines");function eo(e){let[,t,r,i,n]=e.match(/^(.*) <(.*)> (.*) (.*)$/);return{name:t,email:r,timestamp:Number(i),timezoneOffset:pk(n)}}o(eo,"parseAuthor");function pk(e){let[,t,r,i]=e.match(/(\+|-)(\d\d)(\d\d)/);return i=(t==="+"?1:-1)*(Number(r)*60+Number(i)),mk(i)}o(pk,"parseTimezoneOffset");function mk(e){return e===0?e:-e}o(mk,"negateExceptForZero$1");var ci=class ci{constructor(t){if(typeof t=="string")this._tag=t;else if(Buffer.isBuffer(t))this._tag=t.toString("utf8");else if(typeof t=="object")this._tag=ci.render(t);else throw new L("invalid type passed to GitAnnotatedTag constructor")}static from(t){return new ci(t)}static render(t){return`object ${t.object}
|
|
22
|
-
type ${t.type}
|
|
23
|
-
tag ${t.tag}
|
|
24
|
-
tagger ${Ec(t.tagger)}
|
|
25
|
-
|
|
26
|
-
${t.message}
|
|
27
|
-
${t.gpgsig?t.gpgsig:""}`}justHeaders(){return this._tag.slice(0,this._tag.indexOf(`
|
|
28
|
-
|
|
29
|
-
`))}message(){let t=this.withoutSignature();return t.slice(t.indexOf(`
|
|
30
|
-
|
|
31
|
-
`)+2)}parse(){return Object.assign(this.headers(),{message:this.message(),gpgsig:this.gpgsig()})}render(){return this._tag}headers(){let t=this.justHeaders().split(`
|
|
32
|
-
`),r=[];for(let n of t)n[0]===" "?r[r.length-1]+=`
|
|
33
|
-
`+n.slice(1):r.push(n);let i={};for(let n of r){let a=n.slice(0,n.indexOf(" ")),s=n.slice(n.indexOf(" ")+1);Array.isArray(i[a])?i[a].push(s):i[a]=s}return i.tagger&&(i.tagger=eo(i.tagger)),i.committer&&(i.committer=eo(i.committer)),i}withoutSignature(){let t=Bt(this._tag);return t.indexOf(`
|
|
34
|
-
-----BEGIN PGP SIGNATURE-----`)===-1?t:t.slice(0,t.lastIndexOf(`
|
|
35
|
-
-----BEGIN PGP SIGNATURE-----`))}gpgsig(){if(this._tag.indexOf(`
|
|
36
|
-
-----BEGIN PGP SIGNATURE-----`)===-1)return;let t=this._tag.slice(this._tag.indexOf("-----BEGIN PGP SIGNATURE-----"),this._tag.indexOf("-----END PGP SIGNATURE-----")+27);return Bt(t)}payload(){return this.withoutSignature()+`
|
|
37
|
-
`}toObject(){return Buffer.from(this._tag,"utf8")}static async sign(t,r,i){let n=t.payload(),{signature:a}=await r({payload:n,secretKey:i});a=Bt(a);let s=n+a;return ci.from(s)}};o(ci,"GitAnnotatedTag");var Ve=ci;function dc(e){return e.trim().split(`
|
|
38
|
-
`).map(t=>" "+t).join(`
|
|
39
|
-
`)+`
|
|
40
|
-
`}o(dc,"indent");function wk(e){return e.split(`
|
|
41
|
-
`).map(t=>t.replace(/^ /,"")).join(`
|
|
42
|
-
`)}o(wk,"outdent");var $e=class $e{constructor(t){if(typeof t=="string")this._commit=t;else if(Buffer.isBuffer(t))this._commit=t.toString("utf8");else if(typeof t=="object")this._commit=$e.render(t);else throw new L("invalid type passed to GitCommit constructor")}static fromPayloadSignature({payload:t,signature:r}){let i=$e.justHeaders(t),n=$e.justMessage(t),a=Bt(i+`
|
|
43
|
-
gpgsig`+dc(r)+`
|
|
44
|
-
`+n);return new $e(a)}static from(t){return new $e(t)}toObject(){return Buffer.from(this._commit,"utf8")}headers(){return this.parseHeaders()}message(){return $e.justMessage(this._commit)}parse(){return Object.assign({message:this.message()},this.headers())}static justMessage(t){return Bt(t.slice(t.indexOf(`
|
|
45
|
-
|
|
46
|
-
`)+2))}static justHeaders(t){return t.slice(0,t.indexOf(`
|
|
47
|
-
|
|
48
|
-
`))}parseHeaders(){let t=$e.justHeaders(this._commit).split(`
|
|
49
|
-
`),r=[];for(let n of t)n[0]===" "?r[r.length-1]+=`
|
|
50
|
-
`+n.slice(1):r.push(n);let i={parent:[]};for(let n of r){let a=n.slice(0,n.indexOf(" ")),s=n.slice(n.indexOf(" ")+1);Array.isArray(i[a])?i[a].push(s):i[a]=s}return i.author&&(i.author=eo(i.author)),i.committer&&(i.committer=eo(i.committer)),i}static renderHeaders(t){let r="";if(t.tree?r+=`tree ${t.tree}
|
|
51
|
-
`:r+=`tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
|
52
|
-
`,t.parent){if(t.parent.length===void 0)throw new L("commit 'parent' property should be an array");for(let a of t.parent)r+=`parent ${a}
|
|
53
|
-
`}let i=t.author;r+=`author ${Ec(i)}
|
|
54
|
-
`;let n=t.committer||t.author;return r+=`committer ${Ec(n)}
|
|
55
|
-
`,t.gpgsig&&(r+="gpgsig"+dc(t.gpgsig)),r}static render(t){return $e.renderHeaders(t)+`
|
|
56
|
-
`+Bt(t.message)}render(){return this._commit}withoutSignature(){let t=Bt(this._commit);if(t.indexOf(`
|
|
57
|
-
gpgsig`)===-1)return t;let r=t.slice(0,t.indexOf(`
|
|
58
|
-
gpgsig`)),i=t.slice(t.indexOf(`-----END PGP SIGNATURE-----
|
|
59
|
-
`)+28);return Bt(r+`
|
|
60
|
-
`+i)}isolateSignature(){let t=this._commit.slice(this._commit.indexOf("-----BEGIN PGP SIGNATURE-----"),this._commit.indexOf("-----END PGP SIGNATURE-----")+27);return wk(t)}static async sign(t,r,i){let n=t.withoutSignature(),a=$e.justMessage(t._commit),{signature:s}=await r({payload:n,secretKey:i});s=Bt(s);let u=$e.justHeaders(t._commit)+`
|
|
61
|
-
gpgsig`+dc(s)+`
|
|
62
|
-
`+a;return $e.from(u)}};o($e,"GitCommit");var je=$e;async function _i({fs:e,cache:t,gitdir:r,oid:i}){if(i==="4b825dc642cb6eb9a060e54bf8d69288fbee4904")return{tree:Me.from([]),oid:i};let{type:n,object:a}=await Q({fs:e,cache:t,gitdir:r,oid:i});if(n==="tag")return i=Ve.from(a).parse().object,_i({fs:e,cache:t,gitdir:r,oid:i});if(n==="commit")return i=je.from(a).parse().tree,_i({fs:e,cache:t,gitdir:r,oid:i});if(n!=="tree")throw new Oe(i,n,"tree");return{tree:Me.from(a),oid:i}}o(_i,"resolveTree");var zc=class zc{constructor({fs:t,gitdir:r,ref:i,cache:n}){var s;this.fs=t,this.cache=n,this.gitdir=r,this.mapPromise=(async()=>{let l=new Map,u;try{u=await C.resolve({fs:t,gitdir:r,ref:i})}catch(f){f instanceof J&&(u="4b825dc642cb6eb9a060e54bf8d69288fbee4904")}let c=await _i({fs:t,cache:this.cache,gitdir:r,oid:u});return c.type="tree",c.mode="40000",l.set(".",c),l})();let a=this;this.ConstructEntry=(s=class{constructor(u){this._fullpath=u,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return a.type(this)}async mode(){return a.mode(this)}async stat(){return a.stat(this)}async content(){return a.content(this)}async oid(){return a.oid(this)}},o(s,"TreeEntry"),s)}async readdir(t){let r=t._fullpath,{fs:i,cache:n,gitdir:a}=this,s=await this.mapPromise,l=s.get(r);if(!l)throw new Error(`No obj for ${r}`);let u=l.oid;if(!u)throw new Error(`No oid for obj ${JSON.stringify(l)}`);if(l.type!=="tree")return null;let{type:c,object:f}=await Q({fs:i,cache:n,gitdir:a,oid:u});if(c!==l.type)throw new Oe(u,c,l.type);let d=Me.from(f);for(let h of d)s.set(D(r,h.path),h);return d.entries().map(h=>D(r,h.path))}async type(t){if(t._type===!1){let r=await this.mapPromise,{type:i}=r.get(t._fullpath);t._type=i}return t._type}async mode(t){if(t._mode===!1){let r=await this.mapPromise,{mode:i}=r.get(t._fullpath);t._mode=Cw(parseInt(i,8))}return t._mode}async stat(t){}async content(t){if(t._content===!1){let r=await this.mapPromise,{fs:i,cache:n,gitdir:a}=this,l=r.get(t._fullpath).oid,{type:u,object:c}=await Q({fs:i,cache:n,gitdir:a,oid:l});u!=="blob"?t._content=void 0:t._content=new Uint8Array(c)}return t._content}async oid(t){if(t._oid===!1){let i=(await this.mapPromise).get(t._fullpath);t._oid=i.oid}return t._oid}};o(zc,"GitWalkerRepo");var kc=zc;function We({ref:e="HEAD"}={}){let t=Object.create(null);return Object.defineProperty(t,Vo,{value:o(function({fs:r,gitdir:i,cache:n}){return new kc({fs:r,gitdir:i,ref:e,cache:n})},"value")}),Object.freeze(t),t}o(We,"TREE");var Wc=class Wc{constructor({fs:t,dir:r,gitdir:i,cache:n}){var s;this.fs=t,this.cache=n,this.dir=r,this.gitdir=i,this.config=null;let a=this;this.ConstructEntry=(s=class{constructor(u){this._fullpath=u,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return a.type(this)}async mode(){return a.mode(this)}async stat(){return a.stat(this)}async content(){return a.content(this)}async oid(){return a.oid(this)}},o(s,"WorkdirEntry"),s)}async readdir(t){let r=t._fullpath,{fs:i,dir:n}=this,a=await i.readdir(D(n,r));return a===null?null:a.map(s=>D(r,s))}async type(t){return t._type===!1&&await t.stat(),t._type}async mode(t){return t._mode===!1&&await t.stat(),t._mode}async stat(t){if(t._stat===!1){let{fs:r,dir:i}=this,n=await r.lstat(`${i}/${t._fullpath}`);if(!n)throw new Error(`ENOENT: no such file or directory, lstat '${t._fullpath}'`);let a=n.isDirectory()?"tree":"blob";a==="blob"&&!n.isFile()&&!n.isSymbolicLink()&&(a="special"),t._type=a,n=hi(n),t._mode=n.mode,n.size===-1&&t._actualSize&&(n.size=t._actualSize),t._stat=n}return t._stat}async content(t){if(t._content===!1){let{fs:r,dir:i,gitdir:n}=this;if(await t.type()==="tree")t._content=void 0;else{let s=await(await this._getGitConfig(r,n)).get("core.autocrlf"),l=await r.read(`${i}/${t._fullpath}`,{autocrlf:s});t._actualSize=l.length,t._stat&&t._stat.size===-1&&(t._stat.size=t._actualSize),t._content=new Uint8Array(l)}}return t._content}async oid(t){if(t._oid===!1){let r=this,{fs:i,gitdir:n,cache:a}=this,s;await fe.acquire({fs:i,gitdir:n,cache:a},async function(l){let u=l.entriesMap.get(t._fullpath),c=await t.stat(),d=await(await r._getGitConfig(i,n)).get("core.filemode"),h=typeof process<"u"?process.platform!=="win32":!0;if(!u||Ka(c,u,d,h)){let p=await t.content();p===void 0?s=void 0:(s=await Nt(Jt.wrap({type:"blob",object:p})),u&&s===u.oid&&(!d||c.mode===u.mode)&&Ka(c,u,d,h)&&l.insert({filepath:t._fullpath,stats:c,oid:s}))}else s=u.oid}),t._oid=s}return t._oid}async _getGitConfig(t,r){return this.config?this.config:(this.config=await se.get({fs:t,gitdir:r}),this.config)}};o(Wc,"GitWalkerFs");var xc=Wc;function xi(){let e=Object.create(null);return Object.defineProperty(e,Vo,{value:o(function({fs:t,dir:r,gitdir:i,cache:n}){return new xc({fs:t,dir:r,gitdir:i,cache:n})},"value")}),Object.freeze(e),e}o(xi,"WORKDIR");function gk(e,t){let r=t-e;return Array.from({length:r},(i,n)=>e+n)}o(gk,"arrayRange");var Hw=typeof Array.prototype.flat>"u"?e=>e.reduce((t,r)=>t.concat(r),[]):e=>e.flat(),Vc=class Vc{constructor(){this.value=null}consider(t){t!=null&&(this.value===null?this.value=t:t<this.value&&(this.value=t))}reset(){this.value=null}};o(Vc,"RunningMinimum");var Pc=Vc;function*yk(e){let t=new Pc,r,i=[],n=e.length;for(let a=0;a<n;a++)i[a]=e[a].next().value,i[a]!==void 0&&t.consider(i[a]);if(t.value!==null)for(;;){let a=[];r=t.value,t.reset();for(let s=0;s<n;s++)i[s]!==void 0&&i[s]===r?(a[s]=i[s],i[s]=e[s].next().value):a[s]=null,i[s]!==void 0&&t.consider(i[s]);if(yield a,t.value===null)return}}o(yk,"unionOfIterators");async function er({fs:e,cache:t,dir:r,gitdir:i,trees:n,map:a=o(async(u,c)=>c,"map"),reduce:s=o(async(u,c)=>{let f=Hw(c);return u!==void 0&&f.unshift(u),f},"reduce"),iterate:l=o((u,c)=>Promise.all([...c].map(u)),"iterate")}){let u=n.map(p=>p[Vo]({fs:e,dir:r,gitdir:i,cache:t})),c=new Array(u.length).fill("."),f=gk(0,u.length),d=o(async p=>{f.forEach(y=>{let g=p[y];p[y]=g&&new u[y].ConstructEntry(g)});let w=(await Promise.all(f.map(y=>{let g=p[y];return g?u[y].readdir(g):[]}))).map(y=>(y===null?[]:y)[Symbol.iterator]());return{entries:p,children:yk(w)}},"unionWalkerFromReaddir"),h=o(async p=>{let{entries:m,children:w}=await d(p),y=m.find(_=>_&&_._fullpath)._fullpath,g=await a(y,m);if(g!==null){let _=await l(h,w);return _=_.filter(k=>k!==void 0),s(g,_)}},"walk");return h(c)}o(er,"_walk");async function Tc(e,t){let r=await e.readdir(t);r==null?await e.rm(t):r.length?await Promise.all(r.map(i=>{let n=D(t,i);return e.lstat(n).then(a=>{if(a)return a.isDirectory()?Tc(e,n):e.rm(n)})})).then(()=>e.rmdir(t)):await e.rmdir(t)}o(Tc,"rmRecursive");function bk(e){return _k(e)&&yw(e.then)&&yw(e.catch)}o(bk,"isPromiseLike");function _k(e){return e&&typeof e=="object"}o(_k,"isObject");function yw(e){return typeof e=="function"}o(yw,"isFunction");function bw(e){return bk(o(r=>{try{return r.readFile().catch(i=>i)}catch(i){return i}},"test")(e))}o(bw,"isPromiseFs");var _w=["readFile","writeFile","mkdir","rmdir","unlink","stat","lstat","readdir","readlink","symlink"];function vw(e,t){if(bw(t))for(let r of _w)e[`_${r}`]=t[r].bind(t);else for(let r of _w)e[`_${r}`]=oc(t[r].bind(t));bw(t)?t.rm?e._rm=t.rm.bind(t):t.rmdir.length>1?e._rm=t.rmdir.bind(t):e._rm=Tc.bind(null,e):t.rm?e._rm=oc(t.rm.bind(t)):t.rmdir.length>2?e._rm=oc(t.rmdir.bind(t)):e._rm=Tc.bind(null,e)}o(vw,"bindFs");var Gc=class Gc{constructor(t){if(typeof t._original_unwrapped_fs<"u")return t;let r=Object.getOwnPropertyDescriptor(t,"promises");r&&r.enumerable?vw(this,t.promises):vw(this,t),this._original_unwrapped_fs=t}async exists(t,r={}){try{return await this._stat(t),!0}catch(i){if(i.code==="ENOENT"||i.code==="ENOTDIR"||(i.code||"").includes("ENS"))return!1;throw console.log('Unhandled error in "FileSystem.exists()" function',i),i}}async read(t,r={}){try{let i=await this._readFile(t,r);if(r.autocrlf==="true")try{i=new TextDecoder("utf8",{fatal:!0}).decode(i),i=i.replace(/\r\n/g,`
|
|
63
|
-
`),i=new TextEncoder().encode(i)}catch{}return typeof i!="string"&&(i=Buffer.from(i)),i}catch{return null}}async write(t,r,i={}){try{await this._writeFile(t,r,i)}catch{await this.mkdir(pi(t)),await this._writeFile(t,r,i)}}async mkdir(t,r=!1){try{await this._mkdir(t)}catch(i){if(i===null||i.code==="EEXIST")return;if(r)throw i;if(i.code==="ENOENT"){let n=pi(t);if(n==="."||n==="/"||n===t)throw i;await this.mkdir(n),await this.mkdir(t,!0)}}}async rm(t){try{await this._unlink(t)}catch(r){if(r.code!=="ENOENT")throw r}}async rmdir(t,r){try{r&&r.recursive?await this._rm(t,r):await this._rmdir(t)}catch(i){if(i.code!=="ENOENT")throw i}}async readdir(t){try{let r=await this._readdir(t);return r.sort(Wo),r}catch(r){return r.code==="ENOTDIR"?null:[]}}async readdirDeep(t){let r=await this._readdir(t);return(await Promise.all(r.map(async n=>{let a=t+"/"+n;return(await this._stat(a)).isDirectory()?this.readdirDeep(a):a}))).reduce((n,a)=>n.concat(a),[])}async lstat(t){try{return await this._lstat(t)}catch(r){if(r.code==="ENOENT"||(r.code||"").includes("ENS"))return null;throw r}}async readlink(t,r={encoding:"buffer"}){try{let i=await this._readlink(t,r);return Buffer.isBuffer(i)?i:Buffer.from(i)}catch(i){if(i.code==="ENOENT"||(i.code||"").includes("ENS"))return null;throw i}}async writelink(t,r){return this._symlink(r.toString("utf8"),t)}};o(Gc,"FileSystem");var N=Gc;function E(e,t){if(t===void 0)throw new Le(e)}o(E,"assertParameter");async function to(e,t){return!e&&!t?!1:e&&!t||!e&&t?!0:!(await e.type()==="tree"&&await t.type()==="tree"||await e.type()===await t.type()&&await e.mode()===await t.mode()&&await e.oid()===await t.oid())}o(to,"modified");async function qw({fs:e,dir:t,gitdir:r=D(t,".git"),commit:i="HEAD",cache:n={}}){try{E("fs",e),E("dir",t),E("gitdir",r);let a=new N(e),s=[We({ref:i}),xi(),Tr()],l=[];await fe.acquire({fs:a,gitdir:r,cache:n},async function(c){l=c.unmergedPaths});let u=await er({fs:a,cache:n,dir:t,gitdir:r,trees:s,map:o(async function(c,[f,d,h]){let p=!await to(d,h),m=l.includes(c),w=!await to(h,f);if(p||m)return f?{path:c,mode:await f.mode(),oid:await f.oid(),type:await f.type(),content:await f.content()}:void 0;if(w)return!1;throw new Bn(c)},"map")});await fe.acquire({fs:a,gitdir:r,cache:n},async function(c){for(let f of u)if(f!==!1){if(!f){await a.rmdir(`${t}/${f.path}`,{recursive:!0}),c.delete({filepath:f.path});continue}if(f.type==="blob"){let d=new TextDecoder().decode(f.content);await a.write(`${t}/${f.path}`,d,{mode:f.mode}),c.insert({filepath:f.path,oid:f.oid,stage:0})}}})}catch(a){throw a.caller="git.abortMerge",a}}o(qw,"abortMerge");var Zc=class Zc{static async isIgnored({fs:t,dir:r,gitdir:i=D(r,".git"),filepath:n}){if(Ya(n)===".git")return!0;if(n===".")return!1;let a="",s=D(i,"info","exclude");await t.exists(s)&&(a=await t.read(s,"utf8"));let l=[{gitignore:D(r,".gitignore"),filepath:n}],u=n.split("/").filter(Boolean);for(let f=1;f<u.length;f++){let d=u.slice(0,f).join("/"),h=u.slice(f).join("/");l.push({gitignore:D(r,d,".gitignore"),filepath:h})}let c=!1;for(let f of l){let d;try{d=await t.read(f.gitignore,"utf8")}catch(m){if(m.code==="NOENT")continue}let h=E1().add(a);h.add(d);let p=pi(f.filepath);if(p!=="."&&h.ignores(p))return!0;c?c=!h.test(f.filepath).unignored:c=h.test(f.filepath).ignored}return c}};o(Zc,"GitIgnoreManager");var tr=Zc;async function vk({fs:e,gitdir:t,object:r,format:i,oid:n}){if(i!=="deflated")throw new L("GitObjectStoreLoose expects objects to write to be in deflated format");let a=`objects/${n.slice(0,2)}/${n.slice(2)}`,s=`${t}/${a}`;await e.exists(s)||await e.write(s,r)}o(vk,"writeObjectLoose");var hc=null;async function Uw(e){return hc===null&&(hc=Sk()),hc?Fk(e):Dc.deflate(e)}o(Uw,"deflate");async function Fk(e){let t=new CompressionStream("deflate"),r=new Blob([e]).stream().pipeThrough(t);return new Uint8Array(await new Response(r).arrayBuffer())}o(Fk,"browserDeflate");function Sk(){try{return new CompressionStream("deflate").writable.close(),new Blob([]).stream().cancel(),!0}catch{return!1}}o(Sk,"testCompressionStream");async function He({fs:e,gitdir:t,type:r,object:i,format:n="content",oid:a=void 0,dryRun:s=!1}){return n!=="deflated"&&(n!=="wrapped"&&(i=Jt.wrap({type:r,object:i})),a=await Nt(i),i=Buffer.from(await Uw(i))),s||await vk({fs:e,gitdir:t,object:i,format:"deflated",oid:a}),a}o(He,"_writeObject");function zw(e){let t;for(;~(t=e.indexOf(92));)e[t]=47;return e}o(zw,"posixifyPathBuffer");async function Ww({fs:e,dir:t,gitdir:r=D(t,".git"),filepath:i,cache:n={},force:a=!1,parallel:s=!0}){try{E("fs",e),E("dir",t),E("gitdir",r),E("filepath",i);let l=new N(e);await fe.acquire({fs:l,gitdir:r,cache:n},async u=>{let f=await(await se.get({fs:l,gitdir:r})).get("core.autocrlf");return Ac({dir:t,gitdir:r,fs:l,filepath:i,index:u,force:a,parallel:s,autocrlf:f})})}catch(l){throw l.caller="git.add",l}}o(Ww,"add");async function Ac({dir:e,gitdir:t,fs:r,filepath:i,index:n,force:a,parallel:s,autocrlf:l}){i=Array.isArray(i)?i:[i];let u=i.map(async h=>{if(!a&&await tr.isIgnored({fs:r,dir:e,gitdir:t,filepath:h}))return;let p=await r.lstat(D(e,h));if(!p)throw new J(h);if(p.isDirectory()){let m=await r.readdir(D(e,h));if(s){let w=m.map(y=>Ac({dir:e,gitdir:t,fs:r,filepath:[D(h,y)],index:n,force:a,parallel:s,autocrlf:l}));await Promise.all(w)}else for(let w of m)await Ac({dir:e,gitdir:t,fs:r,filepath:[D(h,w)],index:n,force:a,parallel:s,autocrlf:l})}else{let m=p.isSymbolicLink()?await r.readlink(D(e,h)).then(zw):await r.read(D(e,h),{autocrlf:l});if(m===null)throw new J(h);let w=await He({fs:r,gitdir:t,type:"blob",object:m});n.insert({filepath:h,stats:p,oid:w})}}),c=await Promise.allSettled(u),f=c.filter(h=>h.status==="rejected").map(h=>h.reason);if(f.length>1)throw new Dn(f);if(f.length===1)throw f[0];return c.filter(h=>h.status==="fulfilled"&&h.value).map(h=>h.value)}o(Ac,"addToIndex");async function $n({fs:e,gitdir:t,path:r}){return(await se.get({fs:e,gitdir:t})).get(r)}o($n,"_getConfig");function Vw(e,...t){for(let r of t)if(r)for(let i of Object.keys(r)){let n=r[i];n!==void 0&&(e[i]=n)}return e}o(Vw,"assignDefined");async function rr({fs:e,gitdir:t,author:r,commit:i}){let n=Math.floor(Date.now()/1e3),a={name:await $n({fs:e,gitdir:t,path:"user.name"}),email:await $n({fs:e,gitdir:t,path:"user.email"})||"",timestamp:n,timezoneOffset:new Date(n*1e3).getTimezoneOffset()},s=Vw({},a,i?i.author:void 0,r);if(s.name!==void 0)return s}o(rr,"normalizeAuthorObject");async function vi({fs:e,gitdir:t,author:r,committer:i,commit:n}){let a=Math.floor(Date.now()/1e3),s={name:await $n({fs:e,gitdir:t,path:"user.name"}),email:await $n({fs:e,gitdir:t,path:"user.email"})||"",timestamp:a,timezoneOffset:new Date(a*1e3).getTimezoneOffset()},l=Vw({},s,n?n.committer:void 0,r,i);if(l.name!==void 0)return l}o(vi,"normalizeCommitterObject");async function Gw({fs:e,cache:t,gitdir:r,oid:i}){let{type:n,object:a}=await Q({fs:e,cache:t,gitdir:r,oid:i});if(n==="tag")return i=Ve.from(a).parse().object,Gw({fs:e,cache:t,gitdir:r,oid:i});if(n!=="commit")throw new Oe(i,n,"commit");return{commit:je.from(a),oid:i}}o(Gw,"resolveCommit");async function Fi({fs:e,cache:t,gitdir:r,oid:i}){let{commit:n,oid:a}=await Gw({fs:e,cache:t,gitdir:r,oid:i});return{oid:a,commit:n.parse(),payload:n.withoutSignature()}}o(Fi,"_readCommit");async function Go({fs:e,cache:t,onSign:r,gitdir:i,message:n,author:a,committer:s,signingKey:l,amend:u=!1,dryRun:c=!1,noUpdateBranch:f=!1,ref:d,parent:h,tree:p}){let m=!1;d||(d=await C.resolve({fs:e,gitdir:i,ref:"HEAD",depth:2}));let w,y;try{w=await C.resolve({fs:e,gitdir:i,ref:d}),y=await Fi({fs:e,gitdir:i,oid:w,cache:{}})}catch{m=!0}if(u&&m)throw new Nn(d);let g=u?await rr({fs:e,gitdir:i,author:a,commit:y.commit}):await rr({fs:e,gitdir:i,author:a});if(!g)throw new Ee("author");let _=u?await vi({fs:e,gitdir:i,author:g,committer:s,commit:y.commit}):await vi({fs:e,gitdir:i,author:g,committer:s});if(!_)throw new Ee("committer");return fe.acquire({fs:e,gitdir:i,cache:t,allowUnmerged:!1},async function(k){let S=Bw(k.entries).get(".");if(p||(p=await Zw({fs:e,gitdir:i,inode:S,dryRun:c})),h?h=await Promise.all(h.map(x=>C.resolve({fs:e,gitdir:i,ref:x}))):u?h=y.commit.parent:h=w?[w]:[],!n)if(u)n=y.commit.message;else throw new Le("message");let P=je.from({tree:p,parent:h,author:g,committer:_,message:n});l&&(P=await je.sign(P,r,l));let b=await He({fs:e,gitdir:i,type:"commit",object:P.toObject(),dryRun:c});return!f&&!c&&await C.writeRef({fs:e,gitdir:i,ref:d,value:b}),b})}o(Go,"_commit");async function Zw({fs:e,gitdir:t,inode:r,dryRun:i}){let n=r.children;for(let u of n)u.type==="tree"&&(u.metadata.mode="040000",u.metadata.oid=await Zw({fs:e,gitdir:t,inode:u,dryRun:i}));let a=n.map(u=>({mode:u.metadata.mode,path:u.basename,oid:u.metadata.oid,type:u.type})),s=Me.from(a);return await He({fs:e,gitdir:t,type:"tree",object:s.toObject(),dryRun:i})}o(Zw,"constructTree");async function Mn({fs:e,cache:t,gitdir:r,oid:i,filepath:n}){if(n.startsWith("/"))throw new Qt("leading-slash");if(n.endsWith("/"))throw new Qt("trailing-slash");let a=i,s=await _i({fs:e,cache:t,gitdir:r,oid:i}),l=s.tree;if(n==="")i=s.oid;else{let u=n.split("/");i=await Kw({fs:e,cache:t,gitdir:r,tree:l,pathArray:u,oid:a,filepath:n})}return i}o(Mn,"resolveFilepath");async function Kw({fs:e,cache:t,gitdir:r,tree:i,pathArray:n,oid:a,filepath:s}){let l=n.shift();for(let u of i)if(u.path===l){if(n.length===0)return u.oid;{let{type:c,object:f}=await Q({fs:e,cache:t,gitdir:r,oid:u.oid});if(c!=="tree")throw new Oe(a,c,"tree",s);return i=Me.from(f),Kw({fs:e,cache:t,gitdir:r,tree:i,pathArray:n,oid:a,filepath:s})}}throw new J(`file or directory found at "${a}:${s}"`)}o(Kw,"_resolveFilepath");async function Pi({fs:e,cache:t,gitdir:r,oid:i,filepath:n=void 0}){n!==void 0&&(i=await Mn({fs:e,cache:t,gitdir:r,oid:i,filepath:n}));let{tree:a,oid:s}=await _i({fs:e,cache:t,gitdir:r,oid:i});return{oid:s,tree:a.entries()}}o(Pi,"_readTree");async function jn({fs:e,gitdir:t,tree:r}){let i=Me.from(r).toObject();return await He({fs:e,gitdir:t,type:"tree",object:i,format:"content"})}o(jn,"_writeTree");async function Ek({fs:e,cache:t,onSign:r,gitdir:i,ref:n,oid:a,note:s,force:l,author:u,committer:c,signingKey:f}){let d;try{d=await C.resolve({gitdir:i,fs:e,ref:n})}catch(g){if(!(g instanceof J))throw g}let p=(await Pi({fs:e,cache:t,gitdir:i,oid:d||"4b825dc642cb6eb9a060e54bf8d69288fbee4904"})).tree;if(l)p=p.filter(g=>g.path!==a);else for(let g of p)if(g.path===a)throw new st("note",a);typeof s=="string"&&(s=Buffer.from(s,"utf8"));let m=await He({fs:e,gitdir:i,type:"blob",object:s,format:"content"});p.push({mode:"100644",path:a,oid:m,type:"blob"});let w=await jn({fs:e,gitdir:i,tree:p});return await Go({fs:e,cache:t,onSign:r,gitdir:i,ref:n,tree:w,parent:d&&[d],message:`Note added by 'isomorphic-git addNote'
|
|
64
|
-
`,author:u,committer:c,signingKey:f})}o(Ek,"_addNote");async function Yw({fs:e,onSign:t,dir:r,gitdir:i=D(r,".git"),ref:n="refs/notes/commits",oid:a,note:s,force:l,author:u,committer:c,signingKey:f,cache:d={}}){try{E("fs",e),E("gitdir",i),E("oid",a),E("note",s),f&&E("onSign",t);let h=new N(e),p=await rr({fs:h,gitdir:i,author:u});if(!p)throw new Ee("author");let m=await vi({fs:h,gitdir:i,author:p,committer:c});if(!m)throw new Ee("committer");return await Ek({fs:new N(h),cache:d,onSign:t,gitdir:i,ref:n,oid:a,note:s,force:l,author:p,committer:m,signingKey:f})}catch(h){throw h.caller="git.addNote",h}}o(Yw,"addNote");var kk=/(^|[/.])([/.]|$)|^@$|@{|[\x00-\x20\x7f~^:?*[\\]|\.lock(\/|$)/;function Ln(e,t){if(typeof e!="string")throw new TypeError("Reference name must be a string");return!kk.test(e)&&(!!t||e.includes("/"))}o(Ln,"isValidRef");async function Xw({fs:e,gitdir:t,remote:r,url:i,force:n}){if(!Ln(r,!0))throw new lt(r,_n.clean(r));let a=await se.get({fs:e,gitdir:t});if(!n&&(await a.getSubsections("remote")).includes(r)&&i!==await a.get(`remote.${r}.url`))throw new st("remote",r);await a.set(`remote.${r}.url`,i),await a.set(`remote.${r}.fetch`,`+refs/heads/*:refs/remotes/${r}/*`),await se.save({fs:e,gitdir:t,config:a})}o(Xw,"_addRemote");async function Jw({fs:e,dir:t,gitdir:r=D(t,".git"),remote:i,url:n,force:a=!1}){try{return E("fs",e),E("gitdir",r),E("remote",i),E("url",n),await Xw({fs:new N(e),gitdir:r,remote:i,url:n,force:a})}catch(s){throw s.caller="git.addRemote",s}}o(Jw,"addRemote");async function xk({fs:e,cache:t,onSign:r,gitdir:i,ref:n,tagger:a,message:s=n,gpgsig:l,object:u,signingKey:c,force:f=!1}){if(n=n.startsWith("refs/tags/")?n:`refs/tags/${n}`,!f&&await C.exists({fs:e,gitdir:i,ref:n}))throw new st("tag",n);let d=await C.resolve({fs:e,gitdir:i,ref:u||"HEAD"}),{type:h}=await Q({fs:e,cache:t,gitdir:i,oid:d}),p=Ve.from({object:d,type:h,tag:n.replace("refs/tags/",""),tagger:a,message:s,gpgsig:l});c&&(p=await Ve.sign(p,r,c));let m=await He({fs:e,gitdir:i,type:"tag",object:p.toObject()});await C.writeRef({fs:e,gitdir:i,ref:n,value:m})}o(xk,"_annotatedTag");async function Qw({fs:e,onSign:t,dir:r,gitdir:i=D(r,".git"),ref:n,tagger:a,message:s=n,gpgsig:l,object:u,signingKey:c,force:f=!1,cache:d={}}){try{E("fs",e),E("gitdir",i),E("ref",n),c&&E("onSign",t);let h=new N(e),p=await rr({fs:h,gitdir:i,author:a});if(!p)throw new Ee("tagger");return await xk({fs:h,cache:d,onSign:t,gitdir:i,ref:n,tagger:p,message:s,gpgsig:l,object:u,signingKey:c,force:f})}catch(h){throw h.caller="git.annotatedTag",h}}o(Qw,"annotatedTag");async function Pk({fs:e,gitdir:t,ref:r,object:i,checkout:n=!1,force:a=!1}){if(!Ln(r,!0))throw new lt(r,_n.clean(r));let s=`refs/heads/${r}`;if(!a&&await C.exists({fs:e,gitdir:t,ref:s}))throw new st("branch",r,!1);let l;try{l=await C.resolve({fs:e,gitdir:t,ref:i||"HEAD"})}catch{}l&&await C.writeRef({fs:e,gitdir:t,ref:s,value:l}),n&&await C.writeSymbolicRef({fs:e,gitdir:t,ref:"HEAD",value:s})}o(Pk,"_branch");async function eg({fs:e,dir:t,gitdir:r=D(t,".git"),ref:i,object:n,checkout:a=!1,force:s=!1}){try{return E("fs",e),E("gitdir",r),E("ref",i),await Pk({fs:new N(e),gitdir:r,ref:i,object:n,checkout:a,force:s})}catch(l){throw l.caller="git.branch",l}}o(eg,"branch");var tg=o((e,t)=>e==="."||t==null||t.length===0||t==="."?!0:t.length>=e.length?t.startsWith(e):e.startsWith(t),"worthWalking");async function Cc({fs:e,cache:t,onProgress:r,onPostCheckout:i,dir:n,gitdir:a,remote:s,ref:l,filepaths:u,noCheckout:c,noUpdateHead:f,dryRun:d,force:h,track:p=!0,nonBlocking:m=!1,batchSize:w=100}){let y;if(i)try{y=await C.resolve({fs:e,gitdir:a,ref:"HEAD"})}catch{y="0000000000000000000000000000000000000000"}let g;try{g=await C.resolve({fs:e,gitdir:a,ref:l})}catch(_){if(l==="HEAD")throw _;let k=`${s}/${l}`;if(g=await C.resolve({fs:e,gitdir:a,ref:k}),p){let F=await se.get({fs:e,gitdir:a});await F.set(`branch.${l}.remote`,s),await F.set(`branch.${l}.merge`,`refs/heads/${l}`),await se.save({fs:e,gitdir:a,config:F})}await C.writeRef({fs:e,gitdir:a,ref:`refs/heads/${l}`,value:g})}if(!c){let _;try{_=await Tk({fs:e,cache:t,onProgress:r,dir:n,gitdir:a,ref:l,force:h,filepaths:u})}catch(b){throw b instanceof J&&b.data.what===g?new xn(l,g):b}let k=_.filter(([b])=>b==="conflict").map(([b,x])=>x);if(k.length>0)throw new kn(k);let F=_.filter(([b])=>b==="error").map(([b,x])=>x);if(F.length>0)throw new L(F.join(", "));if(d){i&&await i({previousHead:y,newHead:g,type:u!=null&&u.length>0?"file":"branch"});return}let S=0,P=_.length;if(await fe.acquire({fs:e,gitdir:a,cache:t},async function(b){await Promise.all(_.filter(([x])=>x==="delete"||x==="delete-index").map(async function([x,v]){let A=`${n}/${v}`;x==="delete"&&await e.rm(A),b.delete({filepath:v}),r&&await r({phase:"Updating workdir",loaded:++S,total:P})}))}),await fe.acquire({fs:e,gitdir:a,cache:t},async function(b){for(let[x,v]of _)if(x==="rmdir"||x==="rmdir-index"){let A=`${n}/${v}`;try{x==="rmdir"&&await e.rmdir(A),b.delete({filepath:v}),r&&await r({phase:"Updating workdir",loaded:++S,total:P})}catch(T){if(T.code==="ENOTEMPTY")console.log(`Did not delete ${v} because directory is not empty`);else throw T}}}),await Promise.all(_.filter(([b])=>b==="mkdir"||b==="mkdir-index").map(async function([b,x]){let v=`${n}/${x}`;await e.mkdir(v),r&&await r({phase:"Updating workdir",loaded:++S,total:P})})),m){let b=_.filter(([v])=>v==="create"||v==="create-index"||v==="update"||v==="mkdir-index"),x=await Fw("Update Working Dir",b.map(([v,A,T,R,B])=>()=>Ok({fs:e,cache:t,gitdir:a,dir:n},[v,A,T,R,B])),r,w);await fe.acquire({fs:e,gitdir:a,cache:t,allowUnmerged:!0},async function(v){await Fw("Update Index",x.map(([A,T,R])=>()=>Ak({index:v,fullpath:A,oid:T,stats:R})),r,w)})}else await fe.acquire({fs:e,gitdir:a,cache:t,allowUnmerged:!0},async function(b){await Promise.all(_.filter(([x])=>x==="create"||x==="create-index"||x==="update"||x==="mkdir-index").map(async function([x,v,A,T,R]){let B=`${n}/${v}`;try{if(x!=="create-index"&&x!=="mkdir-index"){let{object:de}=await Q({fs:e,cache:t,gitdir:a,oid:A});if(R&&await e.rm(B),T===33188)await e.write(B,de);else if(T===33261)await e.write(B,de,{mode:511});else if(T===40960)await e.writelink(B,de);else throw new L(`Invalid mode 0o${T.toString(8)} detected in blob ${A}`)}let M=await e.lstat(B);T===33261&&(M.mode=493),x==="mkdir-index"&&(M.mode=57344),b.insert({filepath:v,stats:M,oid:A}),r&&await r({phase:"Updating workdir",loaded:++S,total:P})}catch(M){console.log(M)}}))});i&&await i({previousHead:y,newHead:g,type:u!=null&&u.length>0?"file":"branch"})}if(!f){let _=await C.expand({fs:e,gitdir:a,ref:l});_.startsWith("refs/heads")?await C.writeSymbolicRef({fs:e,gitdir:a,ref:"HEAD",value:_}):await C.writeRef({fs:e,gitdir:a,ref:"HEAD",value:g})}}o(Cc,"_checkout");async function Tk({fs:e,cache:t,onProgress:r,dir:i,gitdir:n,ref:a,force:s,filepaths:l}){let u=0;return er({fs:e,cache:t,dir:i,gitdir:n,trees:[We({ref:a}),xi(),Tr()],map:o(async function(c,[f,d,h]){if(c===".")return;if(l&&!l.some(m=>tg(c,m)))return null;switch(r&&await r({phase:"Analyzing workdir",loaded:++u}),[!!h,!!f,!!d].map(Number).join("")){case"000":return;case"001":return s&&l&&l.includes(c)?["delete",c]:void 0;case"010":switch(await f.type()){case"tree":return["mkdir",c];case"blob":return["create",c,await f.oid(),await f.mode()];case"commit":return["mkdir-index",c,await f.oid(),await f.mode()];default:return["error",`new entry Unhandled type ${await f.type()}`]}case"011":switch(`${await f.type()}-${await d.type()}`){case"tree-tree":return;case"tree-blob":case"blob-tree":return["conflict",c];case"blob-blob":return await f.oid()!==await d.oid()?s?["update",c,await f.oid(),await f.mode(),await f.mode()!==await d.mode()]:["conflict",c]:await f.mode()!==await d.mode()?s?["update",c,await f.oid(),await f.mode(),!0]:["conflict",c]:["create-index",c,await f.oid(),await f.mode()];case"commit-tree":return;case"commit-blob":return["conflict",c];default:return["error",`new entry Unhandled type ${f.type}`]}case"100":return["delete-index",c];case"101":switch(await h.type()){case"tree":return["rmdir-index",c];case"blob":return await h.oid()!==await d.oid()?s?["delete",c]:["conflict",c]:["delete",c];case"commit":return["rmdir-index",c];default:return["error",`delete entry Unhandled type ${await h.type()}`]}case"110":case"111":switch(`${await h.type()}-${await f.type()}`){case"tree-tree":return;case"blob-blob":{if(await h.oid()===await f.oid()&&await h.mode()===await f.mode()&&!s)return;if(d){if(await d.oid()!==await h.oid()&&await d.oid()!==await f.oid())return s?["update",c,await f.oid(),await f.mode(),await f.mode()!==await d.mode()]:["conflict",c]}else if(s)return["update",c,await f.oid(),await f.mode(),await f.mode()!==await h.mode()];return await f.mode()!==await h.mode()?["update",c,await f.oid(),await f.mode(),!0]:await f.oid()!==await h.oid()?["update",c,await f.oid(),await f.mode(),!1]:void 0}case"tree-blob":return["update-dir-to-blob",c,await f.oid()];case"blob-tree":return["update-blob-to-tree",c];case"commit-commit":return["mkdir-index",c,await f.oid(),await f.mode()];default:return["error",`update entry Unhandled type ${await h.type()}-${await f.type()}`]}}},"map"),reduce:o(async function(c,f){return f=Hw(f),c?c&&c[0]==="rmdir"?(f.push(c),f):(f.unshift(c),f):f},"reduce")})}o(Tk,"analyze");async function Ak({index:e,fullpath:t,stats:r,oid:i}){try{e.insert({filepath:t,stats:r,oid:i})}catch(n){console.warn(`Error inserting ${t} into index:`,n)}}o(Ak,"updateIndex");async function Ok({fs:e,cache:t,gitdir:r,dir:i},[n,a,s,l,u]){let c=`${i}/${a}`;if(n!=="create-index"&&n!=="mkdir-index"){let{object:d}=await Q({fs:e,cache:t,gitdir:r,oid:s});if(u&&await e.rm(c),l===33188)await e.write(c,d);else if(l===33261)await e.write(c,d,{mode:511});else if(l===40960)await e.writelink(c,d);else throw new L(`Invalid mode 0o${l.toString(8)} detected in blob ${s}`)}let f=await e.lstat(c);return l===33261&&(f.mode=493),n==="mkdir-index"&&(f.mode=57344),[a,s,f]}o(Ok,"updateWorkingDir");async function Fw(e,t,r,i){let n=[];try{for(let a=0;a<t.length;a+=i){let s=t.slice(a,a+i).map(u=>u());(await Promise.allSettled(s)).forEach(u=>{u.status==="fulfilled"&&n.push(u.value)}),r&&await r({phase:"Updating workdir",loaded:a+s.length,total:t.length})}return n}catch(a){console.error(`Error during ${e}: ${a}`)}return n}o(Fw,"batchAllSettled");async function Ic({fs:e,onProgress:t,onPostCheckout:r,dir:i,gitdir:n=D(i,".git"),remote:a="origin",ref:s,filepaths:l,noCheckout:u=!1,noUpdateHead:c=s===void 0,dryRun:f=!1,force:d=!1,track:h=!0,cache:p={},nonBlocking:m=!1,batchSize:w=100}){try{E("fs",e),E("dir",i),E("gitdir",n);let y=s||"HEAD";return await Cc({fs:new N(e),cache:p,onProgress:t,onPostCheckout:r,dir:i,gitdir:n,remote:a,ref:y,filepaths:l,noCheckout:u,noUpdateHead:c,dryRun:f,force:d,track:h,nonBlocking:m,batchSize:w})}catch(y){throw y.caller="git.checkout",y}}o(Ic,"checkout");var Dk=/^refs\/(heads\/|tags\/|remotes\/)?(.*)/;function Er(e){let t=Dk.exec(e);return t?t[1]==="remotes/"&&e.endsWith("/HEAD")?t[2].slice(0,-5):t[2]:e}o(Er,"abbreviateRef");async function nr({fs:e,gitdir:t,fullname:r=!1,test:i=!1}){let n=await C.resolve({fs:e,gitdir:t,ref:"HEAD",depth:2});if(i)try{await C.resolve({fs:e,gitdir:t,ref:n})}catch{return}if(n.startsWith("refs/"))return r?n:Er(n)}o(nr,"_currentBranch");function Rk(e){return e=e.replace(/^git@([^:]+):/,"https://$1/"),e=e.replace(/^ssh:\/\//,"https://"),e}o(Rk,"translateSSHtoHTTP");function rg({username:e="",password:t=""}){return`Basic ${Buffer.from(`${e}:${t}`).toString("base64")}`}o(rg,"calculateBasicAuthHeader");async function Hn(e,t){let r=Lw(e);for(;;){let{value:i,done:n}=await r.next();if(i&&await t(i),n)break}r.return&&r.return()}o(Hn,"forAwait");async function ro(e){let t=0,r=[];await Hn(e,a=>{r.push(a),t+=a.byteLength});let i=new Uint8Array(t),n=0;for(let a of r)i.set(a,n),n+=a.byteLength;return i}o(ro,"collect");function Sw(e){let t=e.match(/^https?:\/\/([^/]+)@/);if(t==null)return{url:e,auth:{}};t=t[1];let[r,i]=t.split(":");return e=e.replace(`${t}@`,""),{url:e,auth:{username:r,password:i}}}o(Sw,"extractAuthFromUrl");function Oc(e,t){let r=t.toString(16);return"0".repeat(e-r.length)+r}o(Oc,"padHex");var Kc=class Kc{static flush(){return Buffer.from("0000","utf8")}static delim(){return Buffer.from("0001","utf8")}static encode(t){typeof t=="string"&&(t=Buffer.from(t));let r=t.length+4,i=Oc(4,r);return Buffer.concat([Buffer.from(i,"utf8"),t])}static streamReader(t){let r=new Qa(t);return o(async function(){try{let n=await r.read(4);if(n==null)return!0;if(n=parseInt(n.toString("utf8"),16),n===0||n===1)return null;let a=await r.read(n-4);return a??!0}catch(n){return t.error=n,!0}},"read")}};o(Kc,"GitPktLine");var ae=Kc;async function Ew(e){let t={},r;for(;r=await e(),r!==!0;){if(r===null)continue;r=r.toString("utf8").replace(/\n$/,"");let i=r.indexOf("=");if(i>-1){let n=r.slice(0,i),a=r.slice(i+1);t[n]=a}else t[r]=!0}return{protocolVersion:2,capabilities2:t}}o(Ew,"parseCapabilitiesV2");async function kw(e,{service:t}){let r=new Set,i=new Map,n=new Map,a=ae.streamReader(e),s=await a();for(;s===null;)s=await a();if(s===!0)throw new Pn;if(s.includes("version 2"))return Ew(a);if(s.toString("utf8").replace(/\n$/,"")!==`# service=${t}`)throw new kr(`# service=${t}\\n`,s.toString("utf8"));let l=await a();for(;l===null;)l=await a();if(l===!0)return{capabilities:r,refs:i,symrefs:n};if(l=l.toString("utf8"),l.includes("version 2"))return Ew(a);let[u,c]=pc(l,"\0","\\x00");if(c.split(" ").map(f=>r.add(f)),u!=="0000000000000000000000000000000000000000 capabilities^{}"){let[f,d]=pc(u," "," ");for(i.set(d,f);;){let h=await a();if(h===!0)break;if(h!==null){let[p,m]=pc(h.toString("utf8")," "," ");i.set(m,p)}}}for(let f of r)if(f.startsWith("symref=")){let d=f.match(/symref=([^:]+):(.*)/);d.length===3&&n.set(d[1],d[2])}return{protocolVersion:1,capabilities:r,refs:i,symrefs:n}}o(kw,"parseRefsAdResponse");function pc(e,t,r){let i=e.trim().split(t);if(i.length!==2)throw new kr(`Two strings separated by '${r}'`,e.toString("utf8"));return i}o(pc,"splitAndAssert");var xw=o((e,t)=>e.endsWith("?")?`${e}${t}`:`${e}/${t.replace(/^https?:\/\//,"")}`,"corsProxify"),Pw=o((e,t)=>{(t.username||t.password)&&(e.Authorization=rg(t)),t.headers&&Object.assign(e,t.headers)},"updateHeaders"),mc=o(async e=>{try{let t=Buffer.from(await ro(e.body)),r=t.toString("utf8");return{preview:r.length<256?r:r.slice(0,256)+"...",response:r,data:t}}catch{return{}}},"stringifyBody"),Yc=class Yc{static async capabilities(){return["discover","connect"]}static async discover({http:t,onProgress:r,onAuth:i,onAuthSuccess:n,onAuthFailure:a,corsProxy:s,service:l,url:u,headers:c,protocolVersion:f}){let{url:d,auth:h}=Sw(u),p=s?xw(s,d):d;(h.username||h.password)&&(c.Authorization=rg(h)),f===2&&(c["Git-Protocol"]="version=2");let m,w,y=!1;do if(m=await t.request({onProgress:r,method:"GET",url:`${p}/info/refs?service=${l}`,headers:c}),w=!1,m.statusCode===401||m.statusCode===203){let g=y?a:i;if(g){if(h=await g(d,{...h,headers:{...c}}),h&&h.cancel)throw new bi;h&&(Pw(c,h),y=!0,w=!0)}}else m.statusCode===200&&y&&n&&await n(d,h);while(w);if(m.statusCode!==200){let{response:g}=await mc(m);throw new mi(m.statusCode,m.statusMessage,g)}if(m.headers["content-type"]===`application/x-${l}-advertisement`){let g=await kw(m.body,{service:l});return g.auth=h,g}else{let{preview:g,response:_,data:k}=await mc(m);try{let F=await kw([k],{service:l});return F.auth=h,F}catch{throw new Rn(g,_)}}}static async connect({http:t,onProgress:r,corsProxy:i,service:n,url:a,auth:s,body:l,headers:u}){let c=Sw(a);c&&(a=c.url),i&&(a=xw(i,a)),u["content-type"]=`application/x-${n}-request`,u.accept=`application/x-${n}-result`,Pw(u,s);let f=await t.request({onProgress:r,method:"POST",url:`${a}/${n}`,body:l,headers:u});if(f.statusCode!==200){let{response:d}=mc(f);throw new mi(f.statusCode,f.statusMessage,d)}return f}};o(Yc,"GitRemoteHTTP");var Si=Yc,Xc=class Xc{static getRemoteHelperFor({url:t}){let r=new Map;r.set("http",Si),r.set("https",Si);let i=Ck({url:t});if(!i)throw new In(t);if(r.has(i.transport))return r.get(i.transport);throw new Cn(t,i.transport,i.transport==="ssh"?Rk(t):void 0)}};o(Xc,"GitRemoteManager");var Ei=Xc;function Ck({url:e}){if(e.startsWith("git@"))return{transport:"ssh",address:e};let t=e.match(/(\w+)(:\/\/|::)(.*)/);if(t!==null){if(t[2]==="://")return{transport:t[1],address:t[0]};if(t[2]==="::")return{transport:t[1],address:t[3]}}}o(Ck,"parseRemoteUrl");var Sr=null,Jc=class Jc{static async read({fs:t,gitdir:r}){Sr===null&&(Sr=new bn);let i=D(r,"shallow"),n=new Set;return await Sr.acquire(i,async function(){let a=await t.read(i,{encoding:"utf8"});if(a===null||a.trim()==="")return n;a.trim().split(`
|
|
65
|
-
`).map(s=>n.add(s))}),n}static async write({fs:t,gitdir:r,oids:i}){Sr===null&&(Sr=new bn);let n=D(r,"shallow");if(i.size>0){let a=[...i].join(`
|
|
66
|
-
`)+`
|
|
67
|
-
`;await Sr.acquire(n,async function(){await t.write(n,a,{encoding:"utf8"})})}else await Sr.acquire(n,async function(){await t.rm(n)})}};o(Jc,"GitShallowManager");var xr=Jc;async function Ik({fs:e,gitdir:t,oid:r}){let i=`objects/${r.slice(0,2)}/${r.slice(2)}`;return e.exists(`${t}/${i}`)}o(Ik,"hasObjectLoose");async function Bk({fs:e,cache:t,gitdir:r,oid:i,getExternalRefDelta:n}){let a=await e.readdir(D(r,"objects/pack"));a=a.filter(s=>s.endsWith(".idx"));for(let s of a){let l=`${r}/objects/pack/${s}`,u=await Rc({fs:e,cache:t,filename:l,getExternalRefDelta:n});if(u.error)throw new L(u.error);if(u.offsets.has(i))return!0}return!1}o(Bk,"hasObjectPacked");async function Tw({fs:e,cache:t,gitdir:r,oid:i,format:n="content"}){let a=o(l=>Q({fs:e,cache:t,gitdir:r,oid:l}),"getExternalRefDelta"),s=await Ik({fs:e,gitdir:r,oid:i});return s||(s=await Bk({fs:e,cache:t,gitdir:r,oid:i,getExternalRefDelta:a})),s}o(Tw,"hasObject");function Nk(e){let n="5041434b"+"00000002"+"00000000";return e.slice(0,12).toString("hex")===n}o(Nk,"emptyPackfile");function ig(e,t){let r=e.map(i=>i.split("=",1)[0]);return t.filter(i=>{let n=i.split("=",1)[0];return r.includes(n)})}o(ig,"filterCapabilities");var Zo={name:"isomorphic-git",version:"1.34.1",agent:"git/isomorphic-git@1.34.1"},Qc=class Qc{constructor(){this._queue=[]}write(t){if(this._ended)throw Error("You cannot write to a FIFO that has already been ended!");if(this._waiting){let r=this._waiting;this._waiting=null,r({value:t})}else this._queue.push(t)}end(){if(this._ended=!0,this._waiting){let t=this._waiting;this._waiting=null,t({done:!0})}}destroy(t){this.error=t,this.end()}async next(){if(this._queue.length>0)return{value:this._queue.shift()};if(this._ended)return{done:!0};if(this._waiting)throw Error("You cannot call read until the previous call to read has returned!");return new Promise(t=>{this._waiting=t})}};o(Qc,"FIFO");var ui=Qc;function $k(e){let t=e.indexOf("\r"),r=e.indexOf(`
|
|
68
|
-
`);return t===-1&&r===-1?-1:t===-1?r+1:r===-1?t+1:r===t+1?r+1:Math.min(t,r)+1}o($k,"findSplit");function ng(e){let t=new ui,r="";return(async()=>(await Hn(e,i=>{for(i=i.toString("utf8"),r+=i;;){let n=$k(r);if(n===-1)break;t.write(r.slice(0,n)),r=r.slice(n)}}),r.length>0&&t.write(r),t.end()))(),t}o(ng,"splitLines");var ef=class ef{static demux(t){let r=ae.streamReader(t),i=new ui,n=new ui,a=new ui,s=o(async function(){let l=await r();if(l===null)return s();if(l===!0){i.end(),a.end(),t.error?n.destroy(t.error):n.end();return}switch(l[0]){case 1:{n.write(l.slice(1));break}case 2:{a.write(l.slice(1));break}case 3:{let u=l.slice(1);a.write(u),i.end(),a.end(),n.destroy(new Error(u.toString("utf8")));return}default:i.write(l)}s()},"nextBit");return s(),{packetlines:i,packfile:n,progress:a}}};o(ef,"GitSideBand");var io=ef;async function Lk(e){let{packetlines:t,packfile:r,progress:i}=io.demux(e),n=[],a=[],s=[],l=!1,u=!1;return new Promise((c,f)=>{Hn(t,d=>{let h=d.toString("utf8").trim();if(h.startsWith("shallow")){let p=h.slice(-41).trim();p.length!==40&&f(new Xt(p)),n.push(p)}else if(h.startsWith("unshallow")){let p=h.slice(-41).trim();p.length!==40&&f(new Xt(p)),a.push(p)}else if(h.startsWith("ACK")){let[,p,m]=h.split(" ");s.push({oid:p,status:m}),m||(u=!0)}else h.startsWith("NAK")?(l=!0,u=!0):(u=!0,l=!0);u&&(e.error?f(e.error):c({shallows:n,unshallows:a,acks:s,nak:l,packfile:r,progress:i}))}).finally(()=>{u||(e.error?f(e.error):c({shallows:n,unshallows:a,acks:s,nak:l,packfile:r,progress:i}))})})}o(Lk,"parseUploadPackResponse");function Mk({capabilities:e=[],wants:t=[],haves:r=[],shallows:i=[],depth:n=null,since:a=null,exclude:s=[]}){let l=[];t=[...new Set(t)];let u=` ${e.join(" ")}`;for(let c of t)l.push(ae.encode(`want ${c}${u}
|
|
69
|
-
`)),u="";for(let c of i)l.push(ae.encode(`shallow ${c}
|
|
70
|
-
`));n!==null&&l.push(ae.encode(`deepen ${n}
|
|
71
|
-
`)),a!==null&&l.push(ae.encode(`deepen-since ${Math.floor(a.valueOf()/1e3)}
|
|
72
|
-
`));for(let c of s)l.push(ae.encode(`deepen-not ${c}
|
|
73
|
-
`));l.push(ae.flush());for(let c of r)l.push(ae.encode(`have ${c}
|
|
74
|
-
`));return l.push(ae.encode(`done
|
|
75
|
-
`)),l}o(Mk,"writeUploadPackRequest");async function Bc({fs:e,cache:t,http:r,onProgress:i,onMessage:n,onAuth:a,onAuthSuccess:s,onAuthFailure:l,gitdir:u,ref:c,remoteRef:f,remote:d,url:h,corsProxy:p,depth:m=null,since:w=null,exclude:y=[],relative:g=!1,tags:_=!1,singleBranch:k=!1,headers:F={},prune:S=!1,pruneTags:P=!1}){let b=c||await nr({fs:e,gitdir:u,test:!0}),x=await se.get({fs:e,gitdir:u}),v=d||b&&await x.get(`branch.${b}.remote`)||"origin",A=h||await x.get(`remote.${v}.url`);if(typeof A>"u")throw new Le("remote OR url");let T=f||b&&await x.get(`branch.${b}.merge`)||c||"HEAD";p===void 0&&(p=await x.get("http.corsProxy"));let R=Ei.getRemoteHelperFor({url:A}),B=await R.discover({http:r,onAuth:a,onAuthSuccess:s,onAuthFailure:l,corsProxy:p,service:"git-upload-pack",url:A,headers:F,protocolVersion:1}),M=B.auth,de=B.refs;if(de.size===0)return{defaultBranch:null,fetchHead:null,fetchHeadDescription:null};if(m!==null&&!B.capabilities.has("shallow"))throw new Yt("shallow","depth");if(w!==null&&!B.capabilities.has("deepen-since"))throw new Yt("deepen-since","since");if(y.length>0&&!B.capabilities.has("deepen-not"))throw new Yt("deepen-not","exclude");if(g===!0&&!B.capabilities.has("deepen-relative"))throw new Yt("deepen-relative","relative");let Be,tt;try{let G=C.resolveAgainstMap({ref:T,map:de});Be=G.fullref,tt=G.oid}catch{}for(let G of de.keys())G===Be||G==="HEAD"||G.startsWith("refs/heads/")||_&&G.startsWith("refs/tags/")||de.delete(G);let rt=ig([...B.capabilities],["multi_ack_detailed","no-done","side-band-64k","ofs-delta",`agent=${Zo.agent}`]);g&&rt.push("deepen-relative");let Hs=k?[tt]:de.values(),qs=k?[b]:await C.listRefs({fs:e,gitdir:u,filepath:"refs"}),qe=[];for(let G of qs)try{G=await C.expand({fs:e,gitdir:u,ref:G});let _e=await C.resolve({fs:e,gitdir:u,ref:G});await Tw({fs:e,cache:t,gitdir:u,oid:_e})&&qe.push(_e)}catch{}qe=[...new Set(qe)];let ne=await xr.read({fs:e,gitdir:u}),ht=B.capabilities.has("shallow")?[...ne]:[],Se=Mk({capabilities:rt,wants:Hs,haves:qe,shallows:ht,depth:m,since:w,exclude:y}),Wi=Buffer.from(await ro(Se)),dr=await R.connect({http:r,onProgress:i,corsProxy:p,service:"git-upload-pack",url:A,auth:M,body:[Wi],headers:F}),me=await Lk(dr.body);dr.headers&&(me.headers=dr.headers);for(let G of me.shallows)if(!ne.has(G))try{let{object:_e}=await Q({fs:e,cache:t,gitdir:u,oid:G}),Ge=new je(_e),pt=await Promise.all(Ge.headers().parent.map(Gi=>Tw({fs:e,cache:t,gitdir:u,oid:Gi})));pt.length===0||pt.every(Gi=>Gi)||ne.add(G)}catch{ne.add(G)}for(let G of me.unshallows)ne.delete(G);if(await xr.write({fs:e,gitdir:u,oids:ne}),k){let G=new Map([[Be,tt]]),_e=new Map,Ge=10,pt=Be;for(;Ge--;){let zs=B.symrefs.get(pt);if(zs===void 0)break;_e.set(pt,zs),pt=zs}let Us=de.get(pt);Us&&G.set(pt,Us);let{pruned:Gi}=await C.updateRemoteRefs({fs:e,gitdir:u,remote:v,refs:G,symrefs:_e,tags:_,prune:S});S&&(me.pruned=Gi)}else{let{pruned:G}=await C.updateRemoteRefs({fs:e,gitdir:u,remote:v,refs:de,symrefs:B.symrefs,tags:_,prune:S,pruneTags:P});S&&(me.pruned=G)}if(me.HEAD=B.symrefs.get("HEAD"),me.HEAD===void 0)try{let{oid:G}=C.resolveAgainstMap({ref:"HEAD",map:de});for(let[_e,Ge]of de.entries())if(_e!=="HEAD"&&Ge===G){me.HEAD=_e;break}}catch{}let wv=Be&&Be.startsWith("refs/tags")?"tag":"branch";if(me.FETCH_HEAD={oid:tt,description:`${wv} '${Er(Be)}' of ${A}`},i||n){let G=ng(me.progress);Hn(G,async _e=>{if(n&&await n(_e),i){let Ge=_e.match(/([^:]*).*\((\d+?)\/(\d+?)\)/);Ge&&await i({phase:Ge[1].trim(),loaded:parseInt(Ge[2],10),total:parseInt(Ge[3],10)})}})}let la=Buffer.from(await ro(me.packfile));if(dr.body.error)throw dr.body.error;let Hu=la.slice(-20).toString("hex"),Vi={defaultBranch:me.HEAD,fetchHead:me.FETCH_HEAD.oid,fetchHeadDescription:me.FETCH_HEAD.description};if(me.headers&&(Vi.headers=me.headers),S&&(Vi.pruned=me.pruned),Hu!==""&&!Nk(la)){Vi.packfile=`objects/pack/pack-${Hu}.pack`;let G=D(u,Vi.packfile);await e.write(G,la);let _e=o(pt=>Q({fs:e,cache:t,gitdir:u,oid:pt}),"getExternalRefDelta"),Ge=await Sn.fromPack({pack:la,getExternalRefDelta:_e,onProgress:i});await e.write(G.replace(/\.pack$/,".idx"),await Ge.toBuffer())}return Vi}o(Bc,"_fetch");async function ag({fs:e,bare:t=!1,dir:r,gitdir:i=t?r:D(r,".git"),defaultBranch:n="master"}){if(await e.exists(i+"/config"))return;let a=["hooks","info","objects/info","objects/pack","refs/heads","refs/tags"];a=a.map(s=>i+"/"+s);for(let s of a)await e.mkdir(s);await e.write(i+"/config",`[core]
|
|
76
|
-
repositoryformatversion = 0
|
|
77
|
-
filemode = false
|
|
78
|
-
bare = ${t}
|
|
79
|
-
`+(t?"":` logallrefupdates = true
|
|
80
|
-
`)+` symlinks = false
|
|
81
|
-
ignorecase = true
|
|
82
|
-
`),await e.write(i+"/HEAD",`ref: refs/heads/${n}
|
|
83
|
-
`)}o(ag,"_init");async function jk({fs:e,cache:t,http:r,onProgress:i,onMessage:n,onAuth:a,onAuthSuccess:s,onAuthFailure:l,onPostCheckout:u,dir:c,gitdir:f,url:d,corsProxy:h,ref:p,remote:m,depth:w,since:y,exclude:g,relative:_,singleBranch:k,noCheckout:F,noTags:S,headers:P,nonBlocking:b,batchSize:x=100}){try{if(await ag({fs:e,gitdir:f}),await Xw({fs:e,gitdir:f,remote:m,url:d,force:!1}),h){let T=await se.get({fs:e,gitdir:f});await T.set("http.corsProxy",h),await se.save({fs:e,gitdir:f,config:T})}let{defaultBranch:v,fetchHead:A}=await Bc({fs:e,cache:t,http:r,onProgress:i,onMessage:n,onAuth:a,onAuthSuccess:s,onAuthFailure:l,gitdir:f,ref:p,remote:m,corsProxy:h,depth:w,since:y,exclude:g,relative:_,singleBranch:k,headers:P,tags:!S});if(A===null)return;p=p||v,p=p.replace("refs/heads/",""),await Cc({fs:e,cache:t,onProgress:i,onPostCheckout:u,dir:c,gitdir:f,ref:p,remote:m,noCheckout:F,nonBlocking:b,batchSize:x})}catch(v){throw await e.rmdir(f,{recursive:!0,maxRetries:10}).catch(()=>{}),v}}o(jk,"_clone");async function og({fs:e,http:t,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:a,onAuthFailure:s,onPostCheckout:l,dir:u,gitdir:c=D(u,".git"),url:f,corsProxy:d=void 0,ref:h=void 0,remote:p="origin",depth:m=void 0,since:w=void 0,exclude:y=[],relative:g=!1,singleBranch:_=!1,noCheckout:k=!1,noTags:F=!1,headers:S={},cache:P={},nonBlocking:b=!1,batchSize:x=100}){try{return E("fs",e),E("http",t),E("gitdir",c),k||E("dir",u),E("url",f),await jk({fs:new N(e),cache:P,http:t,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:a,onAuthFailure:s,onPostCheckout:l,dir:u,gitdir:c,url:f,corsProxy:d,ref:h,remote:p,depth:m,since:w,exclude:y,relative:g,singleBranch:_,noCheckout:k,noTags:F,headers:S,nonBlocking:b,batchSize:x})}catch(v){throw v.caller="git.clone",v}}o(og,"clone");async function sg({fs:e,onSign:t,dir:r,gitdir:i=D(r,".git"),message:n,author:a,committer:s,signingKey:l,amend:u=!1,dryRun:c=!1,noUpdateBranch:f=!1,ref:d,parent:h,tree:p,cache:m={}}){try{E("fs",e),u||E("message",n),l&&E("onSign",t);let w=new N(e);return await Go({fs:w,cache:m,onSign:t,gitdir:i,message:n,author:a,committer:s,signingKey:l,amend:u,dryRun:c,noUpdateBranch:f,ref:d,parent:h,tree:p})}catch(w){throw w.caller="git.commit",w}}o(sg,"commit");async function lg({fs:e,dir:t,gitdir:r=D(t,".git"),fullname:i=!1,test:n=!1}){try{return E("fs",e),E("gitdir",r),await nr({fs:new N(e),gitdir:r,fullname:i,test:n})}catch(a){throw a.caller="git.currentBranch",a}}o(lg,"currentBranch");async function Hk({fs:e,gitdir:t,ref:r}){if(r=r.startsWith("refs/heads/")?r:`refs/heads/${r}`,!await C.exists({fs:e,gitdir:t,ref:r}))throw new J(r);let n=await C.expand({fs:e,gitdir:t,ref:r}),a=await nr({fs:e,gitdir:t,fullname:!0});if(n===a){let u=await C.resolve({fs:e,gitdir:t,ref:n});await C.writeRef({fs:e,gitdir:t,ref:"HEAD",value:u})}await C.deleteRef({fs:e,gitdir:t,ref:n});let s=Er(r),l=await se.get({fs:e,gitdir:t});await l.deleteSection("branch",s),await se.save({fs:e,gitdir:t,config:l})}o(Hk,"_deleteBranch");async function cg({fs:e,dir:t,gitdir:r=D(t,".git"),ref:i}){try{return E("fs",e),E("ref",i),await Hk({fs:new N(e),gitdir:r,ref:i})}catch(n){throw n.caller="git.deleteBranch",n}}o(cg,"deleteBranch");async function fg({fs:e,dir:t,gitdir:r=D(t,".git"),ref:i}){try{E("fs",e),E("ref",i),await C.deleteRef({fs:new N(e),gitdir:r,ref:i})}catch(n){throw n.caller="git.deleteRef",n}}o(fg,"deleteRef");async function qk({fs:e,gitdir:t,remote:r}){let i=await se.get({fs:e,gitdir:t});await i.deleteSection("remote",r),await se.save({fs:e,gitdir:t,config:i})}o(qk,"_deleteRemote");async function ug({fs:e,dir:t,gitdir:r=D(t,".git"),remote:i}){try{return E("fs",e),E("remote",i),await qk({fs:new N(e),gitdir:r,remote:i})}catch(n){throw n.caller="git.deleteRemote",n}}o(ug,"deleteRemote");async function Uk({fs:e,gitdir:t,ref:r}){r=r.startsWith("refs/tags/")?r:`refs/tags/${r}`,await C.deleteRef({fs:e,gitdir:t,ref:r})}o(Uk,"_deleteTag");async function dg({fs:e,dir:t,gitdir:r=D(t,".git"),ref:i}){try{return E("fs",e),E("ref",i),await Uk({fs:new N(e),gitdir:r,ref:i})}catch(n){throw n.caller="git.deleteTag",n}}o(dg,"deleteTag");async function zk({fs:e,gitdir:t,oid:r}){let i=r.slice(0,2);return(await e.readdir(`${t}/objects/${i}`)).map(a=>`${i}${a}`).filter(a=>a.startsWith(r))}o(zk,"expandOidLoose");async function Wk({fs:e,cache:t,gitdir:r,oid:i,getExternalRefDelta:n}){let a=[],s=await e.readdir(D(r,"objects/pack"));s=s.filter(l=>l.endsWith(".idx"));for(let l of s){let u=`${r}/objects/pack/${l}`,c=await Rc({fs:e,cache:t,filename:u,getExternalRefDelta:n});if(c.error)throw new L(c.error);for(let f of c.offsets.keys())f.startsWith(i)&&a.push(f)}return a}o(Wk,"expandOidPacked");async function Vk({fs:e,cache:t,gitdir:r,oid:i}){let n=o(l=>Q({fs:e,cache:t,gitdir:r,oid:l}),"getExternalRefDelta"),a=await zk({fs:e,gitdir:r,oid:i}),s=await Wk({fs:e,cache:t,gitdir:r,oid:i,getExternalRefDelta:n});for(let l of s)a.indexOf(l)===-1&&a.push(l);if(a.length===1)return a[0];throw a.length>1?new En("oids",i,a):new J(`an object matching "${i}"`)}o(Vk,"_expandOid");async function hg({fs:e,dir:t,gitdir:r=D(t,".git"),oid:i,cache:n={}}){try{return E("fs",e),E("gitdir",r),E("oid",i),await Vk({fs:new N(e),cache:n,gitdir:r,oid:i})}catch(a){throw a.caller="git.expandOid",a}}o(hg,"expandOid");async function pg({fs:e,dir:t,gitdir:r=D(t,".git"),ref:i}){try{return E("fs",e),E("gitdir",r),E("ref",i),await C.expand({fs:new N(e),gitdir:r,ref:i})}catch(n){throw n.caller="git.expandRef",n}}o(pg,"expandRef");async function Nc({fs:e,cache:t,gitdir:r,oids:i}){let n={},a=i.length,s=i.map((l,u)=>({index:u,oid:l}));for(;s.length;){let l=new Set;for(let{oid:c,index:f}of s)n[c]||(n[c]=new Set),n[c].add(f),n[c].size===a&&l.add(c);if(l.size>0)return[...l];let u=new Map;for(let{oid:c,index:f}of s)try{let{object:d}=await Q({fs:e,cache:t,gitdir:r,oid:c}),h=je.from(d),{parent:p}=h.parseHeaders();for(let m of p)(!n[m]||!n[m].has(f))&&u.set(m+":"+f,{oid:m,index:f})}catch{}s=Array.from(u.values())}return[]}o(Nc,"_findMergeBase");var wc=/^.*(\r?\n|$)/gm;function Gk({branches:e,contents:t}){let r=e[1],i=e[2],n=t[0],a=t[1],s=t[2],l=a.match(wc),u=n.match(wc),c=s.match(wc),f=k1(l,u,c),d=7,h="",p=!0;for(let m of f)m.ok&&(h+=m.ok.join("")),m.conflict&&(p=!1,h+=`${"<".repeat(d)} ${r}
|
|
84
|
-
`,h+=m.conflict.a.join(""),h+=`${"=".repeat(d)}
|
|
85
|
-
`,h+=m.conflict.b.join(""),h+=`${">".repeat(d)} ${i}
|
|
86
|
-
`);return{cleanMerge:p,mergedText:h}}o(Gk,"mergeFile");async function Zk({fs:e,cache:t,dir:r,gitdir:i=D(r,".git"),index:n,ourOid:a,baseOid:s,theirOid:l,ourName:u="ours",baseName:c="base",theirName:f="theirs",dryRun:d=!1,abortOnConflict:h=!0,mergeDriver:p}){let m=We({ref:a}),w=We({ref:s}),y=We({ref:l}),g=[],_=[],k=[],F=[],S=await er({fs:e,cache:t,dir:r,gitdir:i,trees:[m,w,y],map:o(async function(P,[b,x,v]){let A=Ya(P),T=await to(b,x),R=await to(v,x);switch(`${T}-${R}`){case"false-false":return{mode:await x.mode(),path:A,oid:await x.oid(),type:await x.type()};case"false-true":return!v&&await b.type()==="tree"?{mode:await b.mode(),path:A,oid:await b.oid(),type:await b.type()}:v?{mode:await v.mode(),path:A,oid:await v.oid(),type:await v.type()}:void 0;case"true-false":return!b&&await v.type()==="tree"?{mode:await v.mode(),path:A,oid:await v.oid(),type:await v.type()}:b?{mode:await b.mode(),path:A,oid:await b.oid(),type:await b.type()}:void 0;case"true-true":{if(b&&v&&await b.type()==="tree"&&await v.type()==="tree")return{mode:await b.mode(),path:A,oid:await b.oid(),type:"tree"};if(b&&v&&await b.type()==="blob"&&await v.type()==="blob")return Kk({fs:e,gitdir:i,path:A,ours:b,base:x,theirs:v,ourName:u,baseName:c,theirName:f,mergeDriver:p}).then(async B=>{if(B.cleanMerge)h||n.insert({filepath:P,oid:B.mergeResult.oid,stage:0});else if(g.push(P),_.push(P),!h){let M="";x&&await x.type()==="blob"&&(M=await x.oid());let de=await b.oid(),Be=await v.oid();n.delete({filepath:P}),M&&n.insert({filepath:P,oid:M,stage:1}),n.insert({filepath:P,oid:de,stage:2}),n.insert({filepath:P,oid:Be,stage:3})}return B.mergeResult});if(x&&!b&&v&&await x.type()==="blob"&&await v.type()==="blob"){if(g.push(P),k.push(P),!h){let B=await x.oid(),M=await v.oid();n.delete({filepath:P}),n.insert({filepath:P,oid:B,stage:1}),n.insert({filepath:P,oid:M,stage:3})}return{mode:await v.mode(),oid:await v.oid(),type:"blob",path:A}}if(x&&b&&!v&&await x.type()==="blob"&&await b.type()==="blob"){if(g.push(P),F.push(P),!h){let B=await x.oid(),M=await b.oid();n.delete({filepath:P}),n.insert({filepath:P,oid:B,stage:1}),n.insert({filepath:P,oid:M,stage:2})}return{mode:await b.mode(),oid:await b.oid(),type:"blob",path:A}}if(x&&!b&&!v&&(await x.type()==="blob"||await x.type()==="tree"))return;throw new wi}}},"map"),reduce:g.length!==0&&(!r||h)?void 0:async(P,b)=>{let x=b.filter(Boolean);if(P&&!(P&&P.type==="tree"&&x.length===0&&P.path!==".")){if(x.length>0||P.path==="."&&x.length===0){let A=new Me(x).toObject(),T=await He({fs:e,gitdir:i,type:"tree",object:A,dryRun:d});P.oid=T}return P}}});return g.length!==0?(r&&!h&&await er({fs:e,cache:t,dir:r,gitdir:i,trees:[We({ref:S.oid})],map:o(async function(P,[b]){let x=`${r}/${P}`;if(await b.type()==="blob"){let v=await b.mode(),A=new TextDecoder().decode(await b.content());await e.write(x,A,{mode:v})}return!0},"map")}),new gi(g,_,k,F)):S.oid}o(Zk,"mergeTree");async function Kk({fs:e,gitdir:t,path:r,ours:i,base:n,theirs:a,ourName:s,theirName:l,baseName:u,dryRun:c,mergeDriver:f=Gk}){let d="blob",h="100755",p="",m="";n&&await n.type()==="blob"&&(h=await n.mode(),p=await n.oid(),m=Buffer.from(await n.content()).toString("utf8"));let w=h===await i.mode()?await a.mode():await i.mode();if(await i.oid()===await a.oid())return{cleanMerge:!0,mergeResult:{mode:w,path:r,oid:await i.oid(),type:d}};if(await i.oid()===p)return{cleanMerge:!0,mergeResult:{mode:w,path:r,oid:await a.oid(),type:d}};if(await a.oid()===p)return{cleanMerge:!0,mergeResult:{mode:w,path:r,oid:await i.oid(),type:d}};let y=Buffer.from(await i.content()).toString("utf8"),g=Buffer.from(await a.content()).toString("utf8"),{mergedText:_,cleanMerge:k}=await f({branches:[u,s,l],contents:[m,y,g],path:r}),F=await He({fs:e,gitdir:t,type:"blob",object:Buffer.from(_,"utf8"),dryRun:c});return{cleanMerge:k,mergeResult:{mode:w,path:r,oid:F,type:d}}}o(Kk,"mergeBlobs");async function mg({fs:e,cache:t,dir:r,gitdir:i,ours:n,theirs:a,fastForward:s=!0,fastForwardOnly:l=!1,dryRun:u=!1,noUpdateBranch:c=!1,abortOnConflict:f=!0,message:d,author:h,committer:p,signingKey:m,onSign:w,mergeDriver:y,allowUnrelatedHistories:g=!1}){n===void 0&&(n=await nr({fs:e,gitdir:i,fullname:!0})),n=await C.expand({fs:e,gitdir:i,ref:n}),a=await C.expand({fs:e,gitdir:i,ref:a});let _=await C.resolve({fs:e,gitdir:i,ref:n}),k=await C.resolve({fs:e,gitdir:i,ref:a}),F=await Nc({fs:e,cache:t,gitdir:i,oids:[_,k]});if(F.length!==1)if(F.length===0&&g)F.push("4b825dc642cb6eb9a060e54bf8d69288fbee4904");else throw new wi;let S=F[0];if(S===k)return{oid:_,alreadyMerged:!0};if(s&&S===_)return!u&&!c&&await C.writeRef({fs:e,gitdir:i,ref:n,value:k}),{oid:k,fastForward:!0};{if(l)throw new Tn;let P=await fe.acquire({fs:e,gitdir:i,cache:t,allowUnmerged:!1},async x=>Zk({fs:e,cache:t,dir:r,gitdir:i,index:x,ourOid:_,theirOid:k,baseOid:S,ourName:Er(n),baseName:"base",theirName:Er(a),dryRun:u,abortOnConflict:f,mergeDriver:y}));if(P instanceof gi)throw P;return d||(d=`Merge branch '${Er(a)}' into ${Er(n)}`),{oid:await Go({fs:e,cache:t,gitdir:i,message:d,ref:n,tree:P,parent:[_,k],author:h,committer:p,signingKey:m,onSign:w,dryRun:u,noUpdateBranch:c}),tree:P,mergeCommit:!0}}}o(mg,"_merge");async function wg({fs:e,cache:t,http:r,onProgress:i,onMessage:n,onAuth:a,onAuthSuccess:s,onAuthFailure:l,dir:u,gitdir:c,ref:f,url:d,remote:h,remoteRef:p,prune:m,pruneTags:w,fastForward:y,fastForwardOnly:g,corsProxy:_,singleBranch:k,headers:F,author:S,committer:P,signingKey:b}){try{if(!f){let A=await nr({fs:e,gitdir:c});if(!A)throw new Le("ref");f=A}let{fetchHead:x,fetchHeadDescription:v}=await Bc({fs:e,cache:t,http:r,onProgress:i,onMessage:n,onAuth:a,onAuthSuccess:s,onAuthFailure:l,gitdir:c,corsProxy:_,ref:f,url:d,remote:h,remoteRef:p,singleBranch:k,headers:F,prune:m,pruneTags:w});await mg({fs:e,cache:t,gitdir:c,ours:f,theirs:x,fastForward:y,fastForwardOnly:g,message:`Merge ${v}`,author:S,committer:P,signingKey:b,dryRun:!1,noUpdateBranch:!1}),await Cc({fs:e,cache:t,onProgress:i,dir:u,gitdir:c,ref:f,remote:h,noCheckout:!1})}catch(x){throw x.caller="git.pull",x}}o(wg,"_pull");async function gg({fs:e,http:t,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:a,onAuthFailure:s,dir:l,gitdir:u=D(l,".git"),ref:c,url:f,remote:d,remoteRef:h,corsProxy:p,singleBranch:m,headers:w={},cache:y={}}){try{E("fs",e),E("http",t),E("gitdir",u);let g={name:"",email:"",timestamp:Date.now(),timezoneOffset:0};return await wg({fs:new N(e),cache:y,http:t,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:a,onAuthFailure:s,dir:l,gitdir:u,ref:c,url:f,remote:d,remoteRef:h,fastForwardOnly:!0,corsProxy:p,singleBranch:m,headers:w,author:g,committer:g})}catch(g){throw g.caller="git.fastForward",g}}o(gg,"fastForward");async function yg({fs:e,http:t,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:a,onAuthFailure:s,dir:l,gitdir:u=D(l,".git"),ref:c,remote:f,remoteRef:d,url:h,corsProxy:p,depth:m=null,since:w=null,exclude:y=[],relative:g=!1,tags:_=!1,singleBranch:k=!1,headers:F={},prune:S=!1,pruneTags:P=!1,cache:b={}}){try{return E("fs",e),E("http",t),E("gitdir",u),await Bc({fs:new N(e),cache:b,http:t,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:a,onAuthFailure:s,gitdir:u,ref:c,remote:f,remoteRef:d,url:h,corsProxy:p,depth:m,since:w,exclude:y,relative:g,tags:_,singleBranch:k,headers:F,prune:S,pruneTags:P})}catch(x){throw x.caller="git.fetch",x}}o(yg,"fetch");async function bg({fs:e,dir:t,gitdir:r=D(t,".git"),oids:i,cache:n={}}){try{return E("fs",e),E("gitdir",r),E("oids",i),await Nc({fs:new N(e),cache:n,gitdir:r,oids:i})}catch(a){throw a.caller="git.findMergeBase",a}}o(bg,"findMergeBase");async function _g({fs:e,filepath:t}){if(await e.exists(D(t,".git")))return t;{let r=pi(t);if(r===t)throw new J(`git root for ${t}`);return _g({fs:e,filepath:r})}}o(_g,"_findRoot");async function vg({fs:e,filepath:t}){try{return E("fs",e),E("filepath",t),await _g({fs:new N(e),filepath:t})}catch(r){throw r.caller="git.findRoot",r}}o(vg,"findRoot");async function Fg({fs:e,dir:t,gitdir:r=D(t,".git"),path:i}){try{return E("fs",e),E("gitdir",r),E("path",i),await $n({fs:new N(e),gitdir:r,path:i})}catch(n){throw n.caller="git.getConfig",n}}o(Fg,"getConfig");async function Yk({fs:e,gitdir:t,path:r}){return(await se.get({fs:e,gitdir:t})).getall(r)}o(Yk,"_getConfigAll");async function Sg({fs:e,dir:t,gitdir:r=D(t,".git"),path:i}){try{return E("fs",e),E("gitdir",r),E("path",i),await Yk({fs:new N(e),gitdir:r,path:i})}catch(n){throw n.caller="git.getConfigAll",n}}o(Sg,"getConfigAll");async function Eg({http:e,onAuth:t,onAuthSuccess:r,onAuthFailure:i,corsProxy:n,url:a,headers:s={},forPush:l=!1}){try{E("http",e),E("url",a);let c=await Ei.getRemoteHelperFor({url:a}).discover({http:e,onAuth:t,onAuthSuccess:r,onAuthFailure:i,corsProxy:n,service:l?"git-receive-pack":"git-upload-pack",url:a,headers:s,protocolVersion:1}),f={capabilities:[...c.capabilities]};for(let[d,h]of c.refs){let p=d.split("/"),m=p.pop(),w=f;for(let y of p)w[y]=w[y]||{},w=w[y];w[m]=h}for(let[d,h]of c.symrefs){let p=d.split("/"),m=p.pop(),w=f;for(let y of p)w[y]=w[y]||{},w=w[y];w[m]=h}return f}catch(u){throw u.caller="git.getRemoteInfo",u}}o(Eg,"getRemoteInfo");function kg(e,t,r,i){let n=[];for(let[a,s]of e.refs){if(t&&!a.startsWith(t))continue;if(a.endsWith("^{}")){if(i){let u=a.replace("^{}",""),c=n[n.length-1],f=c.ref===u?c:n.find(d=>d.ref===u);if(f===void 0)throw new Error("I did not expect this to happen");f.peeled=s}continue}let l={ref:a,oid:s};r&&e.symrefs.has(a)&&(l.target=e.symrefs.get(a)),n.push(l)}return n}o(kg,"formatInfoRefs");async function xg({http:e,onAuth:t,onAuthSuccess:r,onAuthFailure:i,corsProxy:n,url:a,headers:s={},forPush:l=!1,protocolVersion:u=2}){try{E("http",e),E("url",a);let f=await Ei.getRemoteHelperFor({url:a}).discover({http:e,onAuth:t,onAuthSuccess:r,onAuthFailure:i,corsProxy:n,service:l?"git-receive-pack":"git-upload-pack",url:a,headers:s,protocolVersion:u});if(f.protocolVersion===2)return{protocolVersion:f.protocolVersion,capabilities:f.capabilities2};let d={};for(let h of f.capabilities){let[p,m]=h.split("=");m?d[p]=m:d[p]=!0}return{protocolVersion:1,capabilities:d,refs:kg(f,void 0,!0,!0)}}catch(c){throw c.caller="git.getRemoteInfo2",c}}o(xg,"getRemoteInfo2");async function Xk({type:e,object:t,format:r="content",oid:i=void 0}){return r!=="deflated"&&(r!=="wrapped"&&(t=Jt.wrap({type:e,object:t})),i=await Nt(t)),{oid:i,object:t}}o(Xk,"hashObject");async function Pg({object:e}){try{E("object",e),typeof e=="string"?e=Buffer.from(e,"utf8"):e instanceof Uint8Array||(e=new Uint8Array(e));let t="blob",{oid:r,object:i}=await Xk({type:t,format:"content",object:e});return{oid:r,type:t,object:i,format:"wrapped"}}catch(t){throw t.caller="git.hashBlob",t}}o(Pg,"hashBlob");async function Jk({fs:e,cache:t,onProgress:r,dir:i,gitdir:n,filepath:a}){try{a=D(i,a);let s=await e.read(a),l=o(c=>Q({fs:e,cache:t,gitdir:n,oid:c}),"getExternalRefDelta"),u=await Sn.fromPack({pack:s,getExternalRefDelta:l,onProgress:r});return await e.write(a.replace(/\.pack$/,".idx"),await u.toBuffer()),{oids:[...u.hashes]}}catch(s){throw s.caller="git.indexPack",s}}o(Jk,"_indexPack");async function Tg({fs:e,onProgress:t,dir:r,gitdir:i=D(r,".git"),filepath:n,cache:a={}}){try{return E("fs",e),E("dir",r),E("gitdir",r),E("filepath",n),await Jk({fs:new N(e),cache:a,onProgress:t,dir:r,gitdir:i,filepath:n})}catch(s){throw s.caller="git.indexPack",s}}o(Tg,"indexPack");async function Ag({fs:e,bare:t=!1,dir:r,gitdir:i=t?r:D(r,".git"),defaultBranch:n="master"}){try{return E("fs",e),E("gitdir",i),t||E("dir",r),await ag({fs:new N(e),bare:t,dir:r,gitdir:i,defaultBranch:n})}catch(a){throw a.caller="git.init",a}}o(Ag,"init");async function Og({fs:e,cache:t,gitdir:r,oid:i,ancestor:n,depth:a}){let s=await xr.read({fs:e,gitdir:r});if(!i)throw new Le("oid");if(!n)throw new Le("ancestor");if(i===n)return!1;let l=[i],u=new Set,c=0;for(;l.length;){if(c++===a)throw new On(a);let f=l.shift(),{type:d,object:h}=await Q({fs:e,cache:t,gitdir:r,oid:f});if(d!=="commit")throw new Oe(f,d,"commit");let p=je.from(h).parse();for(let m of p.parent)if(m===n)return!0;if(!s.has(f))for(let m of p.parent)u.has(m)||(l.push(m),u.add(m))}return!1}o(Og,"_isDescendent");async function Dg({fs:e,dir:t,gitdir:r=D(t,".git"),oid:i,ancestor:n,depth:a=-1,cache:s={}}){try{return E("fs",e),E("gitdir",r),E("oid",i),E("ancestor",n),await Og({fs:new N(e),cache:s,gitdir:r,oid:i,ancestor:n,depth:a})}catch(l){throw l.caller="git.isDescendent",l}}o(Dg,"isDescendent");async function Rg({fs:e,dir:t,gitdir:r=D(t,".git"),filepath:i}){try{return E("fs",e),E("dir",t),E("gitdir",r),E("filepath",i),tr.isIgnored({fs:new N(e),dir:t,gitdir:r,filepath:i})}catch(n){throw n.caller="git.isIgnored",n}}o(Rg,"isIgnored");async function Cg({fs:e,dir:t,gitdir:r=D(t,".git"),remote:i}){try{return E("fs",e),E("gitdir",r),C.listBranches({fs:new N(e),gitdir:r,remote:i})}catch(n){throw n.caller="git.listBranches",n}}o(Cg,"listBranches");async function Qk({fs:e,gitdir:t,ref:r,cache:i}){if(r){let n=await C.resolve({gitdir:t,fs:e,ref:r}),a=[];return await Ig({fs:e,cache:i,gitdir:t,oid:n,filenames:a,prefix:""}),a}else return fe.acquire({fs:e,gitdir:t,cache:i},async function(n){return n.entries.map(a=>a.path)})}o(Qk,"_listFiles");async function Ig({fs:e,cache:t,gitdir:r,oid:i,filenames:n,prefix:a}){let{tree:s}=await Pi({fs:e,cache:t,gitdir:r,oid:i});for(let l of s)l.type==="tree"?await Ig({fs:e,cache:t,gitdir:r,oid:l.oid,filenames:n,prefix:D(a,l.path)}):n.push(D(a,l.path))}o(Ig,"accumulateFilesFromOid");async function Bg({fs:e,dir:t,gitdir:r=D(t,".git"),ref:i,cache:n={}}){try{return E("fs",e),E("gitdir",r),await Qk({fs:new N(e),cache:n,gitdir:r,ref:i})}catch(a){throw a.caller="git.listFiles",a}}o(Bg,"listFiles");async function ex({fs:e,cache:t,gitdir:r,ref:i}){let n;try{n=await C.resolve({gitdir:r,fs:e,ref:i})}catch(l){if(l instanceof J)return[]}return(await Pi({fs:e,cache:t,gitdir:r,oid:n})).tree.map(l=>({target:l.path,note:l.oid}))}o(ex,"_listNotes");async function Ng({fs:e,dir:t,gitdir:r=D(t,".git"),ref:i="refs/notes/commits",cache:n={}}){try{return E("fs",e),E("gitdir",r),E("ref",i),await ex({fs:new N(e),cache:n,gitdir:r,ref:i})}catch(a){throw a.caller="git.listNotes",a}}o(Ng,"listNotes");async function $g({fs:e,dir:t,gitdir:r=D(t,".git"),filepath:i}){try{return E("fs",e),E("gitdir",r),C.listRefs({fs:new N(e),gitdir:r,filepath:i})}catch(n){throw n.caller="git.listRefs",n}}o($g,"listRefs");async function tx({fs:e,gitdir:t}){let r=await se.get({fs:e,gitdir:t}),i=await r.getSubsections("remote");return Promise.all(i.map(async a=>{let s=await r.get(`remote.${a}.url`);return{remote:a,url:s}}))}o(tx,"_listRemotes");async function Lg({fs:e,dir:t,gitdir:r=D(t,".git")}){try{return E("fs",e),E("gitdir",r),await tx({fs:new N(e),gitdir:r})}catch(i){throw i.caller="git.listRemotes",i}}o(Lg,"listRemotes");async function rx(e){let t=ae.streamReader(e),r=[],i;for(;i=await t(),i!==!0;){if(i===null)continue;i=i.toString("utf8").replace(/\n$/,"");let[n,a,...s]=i.split(" "),l={ref:a,oid:n};for(let u of s){let[c,f]=u.split(":");c==="symref-target"?l.target=f:c==="peeled"&&(l.peeled=f)}r.push(l)}return r}o(rx,"parseListRefsResponse");async function ix({prefix:e,symrefs:t,peelTags:r}){let i=[];return i.push(ae.encode(`command=ls-refs
|
|
87
|
-
`)),i.push(ae.encode(`agent=${Zo.agent}
|
|
88
|
-
`)),(r||t||e)&&i.push(ae.delim()),r&&i.push(ae.encode("peel")),t&&i.push(ae.encode("symrefs")),e&&i.push(ae.encode(`ref-prefix ${e}`)),i.push(ae.flush()),i}o(ix,"writeListRefsRequest");async function Mg({http:e,onAuth:t,onAuthSuccess:r,onAuthFailure:i,corsProxy:n,url:a,headers:s={},forPush:l=!1,protocolVersion:u=2,prefix:c,symrefs:f,peelTags:d}){try{E("http",e),E("url",a);let h=await Si.discover({http:e,onAuth:t,onAuthSuccess:r,onAuthFailure:i,corsProxy:n,service:l?"git-receive-pack":"git-upload-pack",url:a,headers:s,protocolVersion:u});if(h.protocolVersion===1)return kg(h,c,f,d);let p=await ix({prefix:c,symrefs:f,peelTags:d}),m=await Si.connect({http:e,auth:h.auth,headers:s,corsProxy:n,service:l?"git-receive-pack":"git-upload-pack",url:a,body:p});return rx(m.body)}catch(h){throw h.caller="git.listServerRefs",h}}o(Mg,"listServerRefs");async function jg({fs:e,dir:t,gitdir:r=D(t,".git")}){try{return E("fs",e),E("gitdir",r),C.listTags({fs:new N(e),gitdir:r})}catch(i){throw i.caller="git.listTags",i}}o(jg,"listTags");function nx(e,t){return e.committer.timestamp-t.committer.timestamp}o(nx,"compareAge");var ax="e69de29bb2d1d6434b8b29ae775ad8c2e48c5391";async function Aw({fs:e,cache:t,gitdir:r,oid:i,fileId:n}){if(n===ax)return;let a=i,s,l=await _i({fs:e,cache:t,gitdir:r,oid:i}),u=l.tree;return n===l.oid?s=l.path:(s=await Hg({fs:e,cache:t,gitdir:r,tree:u,fileId:n,oid:a}),Array.isArray(s)&&(s.length===0?s=void 0:s.length===1&&(s=s[0]))),s}o(Aw,"resolveFileIdInTree");async function Hg({fs:e,cache:t,gitdir:r,tree:i,fileId:n,oid:a,filepaths:s=[],parentPath:l=""}){let u=i.entries().map(function(c){let f;return c.oid===n?(f=D(l,c.path),s.push(f)):c.type==="tree"&&(f=Q({fs:e,cache:t,gitdir:r,oid:c.oid}).then(function({object:d}){return Hg({fs:e,cache:t,gitdir:r,tree:Me.from(d),fileId:n,oid:a,filepaths:s,parentPath:D(l,c.path)})})),f});return await Promise.all(u),s}o(Hg,"_resolveFileId");async function ox({fs:e,cache:t,gitdir:r,filepath:i,ref:n,depth:a,since:s,force:l,follow:u}){let c=typeof s>"u"?void 0:Math.floor(s.valueOf()/1e3),f=[],d=await xr.read({fs:e,gitdir:r}),h=await C.resolve({fs:e,gitdir:r,ref:n}),p=[await Fi({fs:e,cache:t,gitdir:r,oid:h})],m,w,y;function g(_){y&&i&&f.push(_)}for(o(g,"endCommit");p.length>0;){let _=p.pop();if(c!==void 0&&_.commit.committer.timestamp<=c)break;if(i){let k;try{k=await Mn({fs:e,cache:t,gitdir:r,oid:_.commit.tree,filepath:i}),w&&m!==k&&f.push(w),m=k,w=_,y=!0}catch(F){if(F instanceof J){let S=u&&m;if(S&&(S=await Aw({fs:e,cache:t,gitdir:r,oid:_.commit.tree,fileId:m}),S))if(Array.isArray(S)){if(w){let P=await Aw({fs:e,cache:t,gitdir:r,oid:w.commit.tree,fileId:m});if(Array.isArray(P))if(S=S.filter(b=>P.indexOf(b)===-1),S.length===1)S=S[0],i=S,w&&f.push(w);else{S=!1,w&&f.push(w);break}}}else i=S,w&&f.push(w);if(!S){if(y&&m&&(f.push(w),!l))break;if(!l&&!u)throw F}w=_,y=!1}else throw F}}else f.push(_);if(a!==void 0&&f.length===a){g(_);break}if(!d.has(_.oid))for(let k of _.commit.parent){let F=await Fi({fs:e,cache:t,gitdir:r,oid:k});p.map(S=>S.oid).includes(F.oid)||p.push(F)}p.length===0&&g(_),p.sort((k,F)=>nx(k.commit,F.commit))}return f}o(ox,"_log");async function qg({fs:e,dir:t,gitdir:r=D(t,".git"),filepath:i,ref:n="HEAD",depth:a,since:s,force:l,follow:u,cache:c={}}){try{return E("fs",e),E("gitdir",r),E("ref",n),await ox({fs:new N(e),cache:c,gitdir:r,filepath:i,ref:n,depth:a,since:s,force:l,follow:u})}catch(f){throw f.caller="git.log",f}}o(qg,"log");async function Ug({fs:e,onSign:t,dir:r,gitdir:i=D(r,".git"),ours:n,theirs:a,fastForward:s=!0,fastForwardOnly:l=!1,dryRun:u=!1,noUpdateBranch:c=!1,abortOnConflict:f=!0,message:d,author:h,committer:p,signingKey:m,cache:w={},mergeDriver:y,allowUnrelatedHistories:g=!1}){try{E("fs",e),m&&E("onSign",t);let _=new N(e),k=await rr({fs:_,gitdir:i,author:h});if(!k&&(!l||!s))throw new Ee("author");let F=await vi({fs:_,gitdir:i,author:k,committer:p});if(!F&&(!l||!s))throw new Ee("committer");return await mg({fs:_,cache:w,dir:r,gitdir:i,ours:n,theirs:a,fastForward:s,fastForwardOnly:l,dryRun:u,noUpdateBranch:c,abortOnConflict:f,message:d,author:k,committer:F,signingKey:m,onSign:t,mergeDriver:y,allowUnrelatedHistories:g})}catch(_){throw _.caller="git.merge",_}}o(Ug,"merge");var sx={commit:16,tree:32,blob:48,tag:64,ofs_delta:96,ref_delta:112};async function zg({fs:e,cache:t,dir:r,gitdir:i=D(r,".git"),oids:n}){let a=new Dw,s=[];function l(f,d){let h=Buffer.from(f,d);s.push(h),a.update(h)}o(l,"write");async function u({stype:f,object:d}){let h=sx[f],p=d.length,m=p>15?128:0,w=p&15;p=p>>>4;let y=(m|h|w).toString(16);for(l(y,"hex");m;)m=p>127?128:0,y=m|p&127,l(Oc(2,y),"hex"),p=p>>>7;l(Buffer.from(await Uw(d)))}o(u,"writeObject"),l("PACK"),l("00000002","hex"),l(Oc(8,n.length),"hex");for(let f of n){let{type:d,object:h}=await Q({fs:e,cache:t,gitdir:i,oid:f});await u({write:l,object:h,stype:d})}let c=a.digest();return s.push(c),s}o(zg,"_pack");async function lx({fs:e,cache:t,gitdir:r,oids:i,write:n}){let a=await zg({fs:e,cache:t,gitdir:r,oids:i}),s=Buffer.from(await ro(a)),u=`pack-${s.slice(-20).toString("hex")}.pack`;return n?(await e.write(D(r,`objects/pack/${u}`),s),{filename:u}):{filename:u,packfile:new Uint8Array(s)}}o(lx,"_packObjects");async function Wg({fs:e,dir:t,gitdir:r=D(t,".git"),oids:i,write:n=!1,cache:a={}}){try{return E("fs",e),E("gitdir",r),E("oids",i),await lx({fs:new N(e),cache:a,gitdir:r,oids:i,write:n})}catch(s){throw s.caller="git.packObjects",s}}o(Wg,"packObjects");async function Vg({fs:e,http:t,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:a,onAuthFailure:s,dir:l,gitdir:u=D(l,".git"),ref:c,url:f,remote:d,remoteRef:h,prune:p=!1,pruneTags:m=!1,fastForward:w=!0,fastForwardOnly:y=!1,corsProxy:g,singleBranch:_,headers:k={},author:F,committer:S,signingKey:P,cache:b={}}){try{E("fs",e),E("gitdir",u);let x=new N(e),v=await rr({fs:x,gitdir:u,author:F});if(!v)throw new Ee("author");let A=await vi({fs:x,gitdir:u,author:v,committer:S});if(!A)throw new Ee("committer");return await wg({fs:x,cache:b,http:t,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:a,onAuthFailure:s,dir:l,gitdir:u,ref:c,url:f,remote:d,remoteRef:h,fastForward:w,fastForwardOnly:y,corsProxy:g,singleBranch:_,headers:k,author:v,committer:A,signingKey:P,prune:p,pruneTags:m})}catch(x){throw x.caller="git.pull",x}}o(Vg,"pull");async function cx({fs:e,cache:t,dir:r,gitdir:i=D(r,".git"),start:n,finish:a}){let s=await xr.read({fs:e,gitdir:i}),l=new Set,u=new Set;for(let d of n)l.add(await C.resolve({fs:e,gitdir:i,ref:d}));for(let d of a)try{let h=await C.resolve({fs:e,gitdir:i,ref:d});u.add(h)}catch{}let c=new Set;async function f(d){c.add(d);let{type:h,object:p}=await Q({fs:e,cache:t,gitdir:i,oid:d});if(h==="tag"){let w=Ve.from(p).headers().object;return f(w)}if(h!=="commit")throw new Oe(d,h,"commit");if(!s.has(d)){let w=je.from(p).headers().parent;for(d of w)!u.has(d)&&!c.has(d)&&await f(d)}}o(f,"walk");for(let d of l)await f(d);return c}o(cx,"listCommitsAndTags");async function gc({fs:e,cache:t,dir:r,gitdir:i=D(r,".git"),oids:n}){let a=new Set;async function s(l){if(a.has(l))return;a.add(l);let{type:u,object:c}=await Q({fs:e,cache:t,gitdir:i,oid:l});if(u==="tag"){let d=Ve.from(c).headers().object;await s(d)}else if(u==="commit"){let d=je.from(c).headers().tree;await s(d)}else if(u==="tree"){let f=Me.from(c);for(let d of f)d.type==="blob"&&a.add(d.oid),d.type==="tree"&&await s(d.oid)}}o(s,"walk");for(let l of n)await s(l);return a}o(gc,"listObjects");async function fx(e){let t={},r="",i=ae.streamReader(e),n=await i();for(;n!==!0;)n!==null&&(r+=n.toString("utf8")+`
|
|
89
|
-
`),n=await i();let a=r.toString("utf8").split(`
|
|
90
|
-
`);if(n=a.shift(),!n.startsWith("unpack "))throw new kr('unpack ok" or "unpack [error message]',n);t.ok=n==="unpack ok",t.ok||(t.error=n.slice(7)),t.refs={};for(let s of a){if(s.trim()==="")continue;let l=s.slice(0,2),u=s.slice(3),c=u.indexOf(" ");c===-1&&(c=u.length);let f=u.slice(0,c),d=u.slice(c+1);t.refs[f]={ok:l==="ok",error:d}}return t}o(fx,"parseReceivePackResponse");async function ux({capabilities:e=[],triplets:t=[]}){let r=[],i=`\0 ${e.join(" ")}`;for(let n of t)r.push(ae.encode(`${n.oldoid} ${n.oid} ${n.fullRef}${i}
|
|
91
|
-
`)),i="";return r.push(ae.flush()),r}o(ux,"writeReceivePackRequest");async function dx({fs:e,cache:t,http:r,onProgress:i,onMessage:n,onAuth:a,onAuthSuccess:s,onAuthFailure:l,onPrePush:u,gitdir:c,ref:f,remoteRef:d,remote:h,url:p,force:m=!1,delete:w=!1,corsProxy:y,headers:g={}}){let _=f||await nr({fs:e,gitdir:c});if(typeof _>"u")throw new Le("ref");let k=await se.get({fs:e,gitdir:c});h=h||await k.get(`branch.${_}.pushRemote`)||await k.get("remote.pushDefault")||await k.get(`branch.${_}.remote`)||"origin";let F=p||await k.get(`remote.${h}.pushurl`)||await k.get(`remote.${h}.url`);if(typeof F>"u")throw new Le("remote OR url");let S=d||await k.get(`branch.${_}.merge`);if(typeof F>"u")throw new Le("remoteRef");y===void 0&&(y=await k.get("http.corsProxy"));let P=await C.expand({fs:e,gitdir:c,ref:_}),b=w?"0000000000000000000000000000000000000000":await C.resolve({fs:e,gitdir:c,ref:P}),x=Ei.getRemoteHelperFor({url:F}),v=await x.discover({http:r,onAuth:a,onAuthSuccess:s,onAuthFailure:l,corsProxy:y,service:"git-receive-pack",url:F,headers:g,protocolVersion:1}),A=v.auth,T;if(!S)T=P;else try{T=await C.expandAgainstMap({ref:S,map:v.refs})}catch(ne){if(ne instanceof J)T=S.startsWith("refs/")?S:`refs/heads/${S}`;else throw ne}let R=v.refs.get(T)||"0000000000000000000000000000000000000000";if(u&&!await u({remote:h,url:F,localRef:{ref:w?"(delete)":P,oid:b},remoteRef:{ref:T,oid:R}}))throw new bi;let B=!v.capabilities.has("no-thin"),M=new Set;if(!w){let ne=[...v.refs.values()],ht=new Set;if(R!=="0000000000000000000000000000000000000000"){let Se=await Nc({fs:e,cache:t,gitdir:c,oids:[b,R]});for(let Wi of Se)ne.push(Wi);B&&(ht=await gc({fs:e,cache:t,gitdir:c,oids:Se}))}if(!ne.includes(b)){let Se=await cx({fs:e,cache:t,gitdir:c,start:[b],finish:ne});M=await gc({fs:e,cache:t,gitdir:c,oids:Se})}if(B){try{let Se=await C.resolve({fs:e,gitdir:c,ref:`refs/remotes/${h}/HEAD`,depth:2}),{oid:Wi}=await C.resolveAgainstMap({ref:Se.replace(`refs/remotes/${h}/`,""),fullref:Se,map:v.refs}),dr=[Wi];for(let me of await gc({fs:e,cache:t,gitdir:c,oids:dr}))ht.add(me)}catch{}for(let Se of ht)M.delete(Se)}if(b===R&&(m=!0),!m){if(P.startsWith("refs/tags")&&R!=="0000000000000000000000000000000000000000")throw new yi("tag-exists");if(b!=="0000000000000000000000000000000000000000"&&R!=="0000000000000000000000000000000000000000"&&!await Og({fs:e,cache:t,gitdir:c,oid:b,ancestor:R,depth:-1}))throw new yi("not-fast-forward")}}let de=ig([...v.capabilities],["report-status","side-band-64k",`agent=${Zo.agent}`]),Be=await ux({capabilities:de,triplets:[{oldoid:R,oid:b,fullRef:T}]}),tt=w?[]:await zg({fs:e,cache:t,gitdir:c,oids:[...M]}),rt=await x.connect({http:r,onProgress:i,corsProxy:y,service:"git-receive-pack",url:F,auth:A,headers:g,body:[...Be,...tt]}),{packfile:Hs,progress:qs}=await io.demux(rt.body);if(n){let ne=ng(qs);Hn(ne,async ht=>{await n(ht)})}let qe=await fx(Hs);if(rt.headers&&(qe.headers=rt.headers),h&&qe.ok&&qe.refs[T].ok&&!P.startsWith("refs/tags")){let ne=`refs/remotes/${h}/${T.replace("refs/heads","")}`;w?await C.deleteRef({fs:e,gitdir:c,ref:ne}):await C.writeRef({fs:e,gitdir:c,ref:ne,value:b})}if(qe.ok&&Object.values(qe.refs).every(ne=>ne.ok))return qe;{let ne=Object.entries(qe.refs).filter(([ht,Se])=>!Se.ok).map(([ht,Se])=>`
|
|
92
|
-
- ${ht}: ${Se.error}`).join("");throw new An(ne,qe)}}o(dx,"_push");async function Gg({fs:e,http:t,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:a,onAuthFailure:s,onPrePush:l,dir:u,gitdir:c=D(u,".git"),ref:f,remoteRef:d,remote:h="origin",url:p,force:m=!1,delete:w=!1,corsProxy:y,headers:g={},cache:_={}}){try{return E("fs",e),E("http",t),E("gitdir",c),await dx({fs:new N(e),cache:_,http:t,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:a,onAuthFailure:s,onPrePush:l,gitdir:c,ref:f,remoteRef:d,remote:h,url:p,force:m,delete:w,corsProxy:y,headers:g})}catch(k){throw k.caller="git.push",k}}o(Gg,"push");async function Zg({fs:e,cache:t,gitdir:r,oid:i}){let{type:n,object:a}=await Q({fs:e,cache:t,gitdir:r,oid:i});if(n==="tag")return i=Ve.from(a).parse().object,Zg({fs:e,cache:t,gitdir:r,oid:i});if(n!=="blob")throw new Oe(i,n,"blob");return{oid:i,blob:new Uint8Array(a)}}o(Zg,"resolveBlob");async function Kg({fs:e,cache:t,gitdir:r,oid:i,filepath:n=void 0}){return n!==void 0&&(i=await Mn({fs:e,cache:t,gitdir:r,oid:i,filepath:n})),await Zg({fs:e,cache:t,gitdir:r,oid:i})}o(Kg,"_readBlob");async function Yg({fs:e,dir:t,gitdir:r=D(t,".git"),oid:i,filepath:n,cache:a={}}){try{return E("fs",e),E("gitdir",r),E("oid",i),await Kg({fs:new N(e),cache:a,gitdir:r,oid:i,filepath:n})}catch(s){throw s.caller="git.readBlob",s}}o(Yg,"readBlob");async function $c({fs:e,dir:t,gitdir:r=D(t,".git"),oid:i,cache:n={}}){try{return E("fs",e),E("gitdir",r),E("oid",i),await Fi({fs:new N(e),cache:n,gitdir:r,oid:i})}catch(a){throw a.caller="git.readCommit",a}}o($c,"readCommit");async function hx({fs:e,cache:t,gitdir:r,ref:i="refs/notes/commits",oid:n}){let a=await C.resolve({gitdir:r,fs:e,ref:i}),{blob:s}=await Kg({fs:e,cache:t,gitdir:r,oid:a,filepath:n});return s}o(hx,"_readNote");async function Xg({fs:e,dir:t,gitdir:r=D(t,".git"),ref:i="refs/notes/commits",oid:n,cache:a={}}){try{return E("fs",e),E("gitdir",r),E("ref",i),E("oid",n),await hx({fs:new N(e),cache:a,gitdir:r,ref:i,oid:n})}catch(s){throw s.caller="git.readNote",s}}o(Xg,"readNote");async function Jg({fs:e,dir:t,gitdir:r=D(t,".git"),oid:i,format:n="parsed",filepath:a=void 0,encoding:s=void 0,cache:l={}}){try{E("fs",e),E("gitdir",r),E("oid",i);let u=new N(e);a!==void 0&&(i=await Mn({fs:u,cache:l,gitdir:r,oid:i,filepath:a}));let f=await Q({fs:u,cache:l,gitdir:r,oid:i,format:n==="parsed"?"content":n});if(f.oid=i,n==="parsed")switch(f.format="parsed",f.type){case"commit":f.object=je.from(f.object).parse();break;case"tree":f.object=Me.from(f.object).entries();break;case"blob":s?f.object=f.object.toString(s):(f.object=new Uint8Array(f.object),f.format="content");break;case"tag":f.object=Ve.from(f.object).parse();break;default:throw new Oe(f.oid,f.type,"blob|commit|tag|tree")}else(f.format==="deflated"||f.format==="wrapped")&&(f.type=f.format);return f}catch(u){throw u.caller="git.readObject",u}}o(Jg,"readObject");async function px({fs:e,cache:t,gitdir:r,oid:i}){let{type:n,object:a}=await Q({fs:e,cache:t,gitdir:r,oid:i,format:"content"});if(n!=="tag")throw new Oe(i,n,"tag");let s=Ve.from(a);return{oid:i,tag:s.parse(),payload:s.payload()}}o(px,"_readTag");async function Qg({fs:e,dir:t,gitdir:r=D(t,".git"),oid:i,cache:n={}}){try{return E("fs",e),E("gitdir",r),E("oid",i),await px({fs:new N(e),cache:n,gitdir:r,oid:i})}catch(a){throw a.caller="git.readTag",a}}o(Qg,"readTag");async function ey({fs:e,dir:t,gitdir:r=D(t,".git"),oid:i,filepath:n=void 0,cache:a={}}){try{return E("fs",e),E("gitdir",r),E("oid",i),await Pi({fs:new N(e),cache:a,gitdir:r,oid:i,filepath:n})}catch(s){throw s.caller="git.readTree",s}}o(ey,"readTree");async function ty({fs:e,dir:t,gitdir:r=D(t,".git"),filepath:i,cache:n={}}){try{E("fs",e),E("gitdir",r),E("filepath",i),await fe.acquire({fs:new N(e),gitdir:r,cache:n},async function(a){a.delete({filepath:i})})}catch(a){throw a.caller="git.remove",a}}o(ty,"remove");async function mx({fs:e,cache:t,onSign:r,gitdir:i,ref:n="refs/notes/commits",oid:a,author:s,committer:l,signingKey:u}){let c;try{c=await C.resolve({gitdir:i,fs:e,ref:n})}catch(m){if(!(m instanceof J))throw m}let d=(await Pi({fs:e,cache:t,gitdir:i,oid:c||"4b825dc642cb6eb9a060e54bf8d69288fbee4904"})).tree;d=d.filter(m=>m.path!==a);let h=await jn({fs:e,gitdir:i,tree:d});return await Go({fs:e,cache:t,onSign:r,gitdir:i,ref:n,tree:h,parent:c&&[c],message:`Note removed by 'isomorphic-git removeNote'
|
|
93
|
-
`,author:s,committer:l,signingKey:u})}o(mx,"_removeNote");async function ry({fs:e,onSign:t,dir:r,gitdir:i=D(r,".git"),ref:n="refs/notes/commits",oid:a,author:s,committer:l,signingKey:u,cache:c={}}){try{E("fs",e),E("gitdir",i),E("oid",a);let f=new N(e),d=await rr({fs:f,gitdir:i,author:s});if(!d)throw new Ee("author");let h=await vi({fs:f,gitdir:i,author:d,committer:l});if(!h)throw new Ee("committer");return await mx({fs:f,cache:c,onSign:t,gitdir:i,ref:n,oid:a,author:d,committer:h,signingKey:u})}catch(f){throw f.caller="git.removeNote",f}}o(ry,"removeNote");async function wx({fs:e,gitdir:t,oldref:r,ref:i,checkout:n=!1}){if(!Ln(i,!0))throw new lt(i,_n.clean(i));if(!Ln(r,!0))throw new lt(r,_n.clean(r));let a=`refs/heads/${r}`,s=`refs/heads/${i}`;if(await C.exists({fs:e,gitdir:t,ref:s}))throw new st("branch",i,!1);let u=await C.resolve({fs:e,gitdir:t,ref:a,depth:1});await C.writeRef({fs:e,gitdir:t,ref:s,value:u}),await C.deleteRef({fs:e,gitdir:t,ref:a});let f=await nr({fs:e,gitdir:t,fullname:!0})===a;(n||f)&&await C.writeSymbolicRef({fs:e,gitdir:t,ref:"HEAD",value:s})}o(wx,"_renameBranch");async function iy({fs:e,dir:t,gitdir:r=D(t,".git"),ref:i,oldref:n,checkout:a=!1}){try{return E("fs",e),E("gitdir",r),E("ref",i),E("oldref",n),await wx({fs:new N(e),gitdir:r,ref:i,oldref:n,checkout:a})}catch(s){throw s.caller="git.renameBranch",s}}o(iy,"renameBranch");async function ny({gitdir:e,type:t,object:r}){return Nt(Jt.wrap({type:t,object:r}))}o(ny,"hashObject$1");async function ay({fs:e,dir:t,gitdir:r=D(t,".git"),filepath:i,ref:n,cache:a={}}){try{E("fs",e),E("gitdir",r),E("filepath",i);let s=new N(e),l,u;try{l=await C.resolve({fs:s,gitdir:r,ref:n||"HEAD"})}catch(d){if(n)throw d}if(l)try{l=await Mn({fs:s,cache:a,gitdir:r,oid:l,filepath:i})}catch{l=null}let c={ctime:new Date(0),mtime:new Date(0),dev:0,ino:0,mode:0,uid:0,gid:0,size:0},f=t&&await s.read(D(t,i));f&&(u=await ny({gitdir:r,type:"blob",object:f}),l===u&&(c=await s.lstat(D(t,i)))),await fe.acquire({fs:s,gitdir:r,cache:a},async function(d){d.delete({filepath:i}),l&&d.insert({filepath:i,stats:c,oid:l})})}catch(s){throw s.caller="git.reset",s}}o(ay,"resetIndex");async function oy({fs:e,dir:t,gitdir:r=D(t,".git"),ref:i,depth:n}){try{return E("fs",e),E("gitdir",r),E("ref",i),await C.resolve({fs:new N(e),gitdir:r,ref:i,depth:n})}catch(a){throw a.caller="git.resolveRef",a}}o(oy,"resolveRef");async function sy({fs:e,dir:t,gitdir:r=D(t,".git"),path:i,value:n,append:a=!1}){try{E("fs",e),E("gitdir",r),E("path",i);let s=new N(e),l=await se.get({fs:s,gitdir:r});a?await l.append(i,n):await l.set(i,n),await se.save({fs:s,gitdir:r,config:l})}catch(s){throw s.caller="git.setConfig",s}}o(sy,"setConfig");async function ly({fs:e,gitdir:t,commit:r}){let i=je.from(r).toObject();return await He({fs:e,gitdir:t,type:"commit",object:i,format:"content"})}o(ly,"_writeCommit");var zo=class zo{static get timezoneOffsetForRefLogEntry(){let t=new Date().getTimezoneOffset(),r=Math.abs(Math.floor(t/60)),i=Math.abs(t%60).toString().padStart(2,"0");return`${t>0?"-":"+"}${r.toString().padStart(2,"0")}${i}`}static createStashReflogEntry(t,r,i){let n=t.name.replace(/\s/g,""),a="0000000000000000000000000000000000000000",s=Math.floor(Date.now()/1e3),l=zo.timezoneOffsetForRefLogEntry;return`${a} ${r} ${n} ${t.email} ${s} ${l} ${i}
|
|
94
|
-
`}static getStashReflogEntry(t,r=!1){return t.split(`
|
|
95
|
-
`).filter(a=>a).reverse().map((a,s)=>r?`stash@{${s}}: ${a.split(" ")[1]}`:a)}};o(zo,"GitRefStash");var no=zo,gx={stage:Tr,workdir:xi},yc;async function ki(e,t){return yc===void 0&&(yc=new bn),yc.acquire(e,t)}o(ki,"acquireLock$1");async function yx(e,t,r,i,n=null){let a=D(r,i),s=await e.lstat(a);if(!s)throw new J(a);if(s.isDirectory())throw new L(`${a}: file expected, but found directory`);let l=n?await $w({fs:e,gitdir:t,oid:n}):void 0,u=l?n:void 0;return l||await ki({fs:e,gitdir:t,currentFilepath:a},async()=>{let c=s.isSymbolicLink()?await e.readlink(a).then(zw):await e.read(a);if(c===null)throw new J(a);u=await He({fs:e,gitdir:t,type:"blob",object:c})}),u}o(yx,"checkAndWriteBlob");async function bx({fs:e,dir:t,gitdir:r,entries:i}){async function n(a){if(a.type==="tree"){if(!a.oid){let s=await Promise.all(a.children.map(n));a.oid=await jn({fs:e,gitdir:r,tree:s}),a.mode=16384}}else a.type==="blob"&&(a.oid=await yx(e,r,t,a.path,a.oid),a.mode=33188);return a.path=a.path.split("/").pop(),a}return o(n,"processTreeEntry"),Promise.all(i.map(n))}o(bx,"processTreeEntries");async function Ow({fs:e,dir:t,gitdir:r,treePair:i}){let n=i[1]==="stage",a=i.map(p=>typeof p=="string"?gx[p]():p),s=[],f=await er({fs:e,cache:{},dir:t,gitdir:r,trees:a,map:o(async(p,[m,w])=>{if(!(p==="."||await tr.isIgnored({fs:e,dir:t,gitdir:r,filepath:p}))&&w)return(!m||await m.oid()!==await w.oid()&&await w.oid()!==void 0)&&s.push([m,w]),{mode:await w.mode(),path:p,oid:await w.oid(),type:await w.type()}},"map"),reduce:o(async(p,m)=>(m=m.filter(Boolean),p?(p.children=m,p):m.length>0?m:void 0),"reduce"),iterate:o(async(p,m)=>{let w=[];for(let y of m){let[g,_]=y;n?_&&(await e.exists(`${t}/${_.toString()}`)?w.push(y):s.push([null,_])):g&&(_?w.push(y):s.push([g,null]))}return w.length?Promise.all(w.map(p)):[]},"iterate")});if(s.length===0||f.length===0)return null;let h=(await bx({fs:e,dir:t,gitdir:r,entries:f})).filter(Boolean).map(p=>({mode:p.mode,path:p.path,oid:p.oid,type:p.type}));return jn({fs:e,gitdir:r,tree:h})}o(Ow,"writeTreeChanges");async function _x({fs:e,dir:t,gitdir:r,stashCommit:i,parentCommit:n,wasStaged:a}){let s=[],l=[],u=await er({fs:e,cache:{},dir:t,gitdir:r,trees:[We({ref:n}),We({ref:i})],map:o(async(c,[f,d])=>{if(c==="."||await tr.isIgnored({fs:e,dir:t,gitdir:r,filepath:c}))return;let h=d?await d.type():await f.type();if(h!=="tree"&&h!=="blob")return;if(!d&&f){let m=h==="tree"?"rmdir":"rm";return h==="tree"&&s.push(c),h==="blob"&&a&&l.push({filepath:c,oid:await f.oid()}),{method:m,filepath:c}}let p=await d.oid();if(!f||await f.oid()!==p)return h==="tree"?{method:"mkdir",filepath:c}:(a&&l.push({filepath:c,oid:p,stats:await e.lstat(D(t,c))}),{method:"write",filepath:c,oid:p})},"map")});await ki({fs:e,gitdir:r,dirRemoved:s,ops:u},async()=>{for(let c of u){let f=D(t,c.filepath);switch(c.method){case"rmdir":await e.rmdir(f);break;case"mkdir":await e.mkdir(f);break;case"rm":await e.rm(f);break;case"write":if(!s.some(d=>f.startsWith(d))){let{object:d}=await Q({fs:e,cache:{},gitdir:r,oid:c.oid});await e.exists(f)&&await e.rm(f),await e.write(f,d)}break}}}),await fe.acquire({fs:e,gitdir:r,cache:{}},async c=>{l.forEach(({filepath:f,stats:d,oid:h})=>{c.insert({filepath:f,stats:d,oid:h})})})}o(_x,"applyTreeChanges");var fi=class fi{constructor({fs:t,dir:r,gitdir:i=D(r,".git")}){Object.assign(this,{fs:t,dir:r,gitdir:i,_author:null})}static get refStash(){return"refs/stash"}static get refLogsStash(){return"logs/refs/stash"}get refStashPath(){return D(this.gitdir,fi.refStash)}get refLogsStashPath(){return D(this.gitdir,fi.refLogsStash)}async getAuthor(){if(!this._author&&(this._author=await rr({fs:this.fs,gitdir:this.gitdir,author:{}}),!this._author))throw new Ee("author");return this._author}async getStashSHA(t,r){return await this.fs.exists(this.refStashPath)?(r||await this.readStashReflogs({parsed:!1}))[t].split(" ")[1]:null}async writeStashCommit({message:t,tree:r,parent:i}){return ly({fs:this.fs,gitdir:this.gitdir,commit:{message:t,tree:r,parent:i,author:await this.getAuthor(),committer:await this.getAuthor()}})}async readStashCommit(t){let r=await this.readStashReflogs({parsed:!1});if(t!==0&&(t<0||t>r.length-1))throw new lt(`stash@${t}`,"number that is in range of [0, num of stash pushed]");let i=await this.getStashSHA(t,r);return i?Fi({fs:this.fs,cache:{},gitdir:this.gitdir,oid:i}):{}}async writeStashRef(t){return C.writeRef({fs:this.fs,gitdir:this.gitdir,ref:fi.refStash,value:t})}async writeStashReflogEntry({stashCommit:t,message:r}){let i=await this.getAuthor(),n=no.createStashReflogEntry(i,t,r),a=this.refLogsStashPath;await ki({filepath:a,entry:n},async()=>{let s=await this.fs.exists(a)?await this.fs.read(a,"utf8"):"";await this.fs.write(a,s+n,"utf8")})}async readStashReflogs({parsed:t=!1}){if(!await this.fs.exists(this.refLogsStashPath))return[];let r=await this.fs.read(this.refLogsStashPath,"utf8");return no.getStashReflogEntry(r,t)}};o(fi,"GitStashManager");var Pr=fi;async function cy({fs:e,dir:t,gitdir:r,message:i=""}){let n=new Pr({fs:e,dir:t,gitdir:r});await n.getAuthor();let a=await nr({fs:e,gitdir:r,fullname:!1}),s=await C.resolve({fs:e,gitdir:r,ref:"HEAD"}),u=(await $c({fs:e,dir:t,gitdir:r,oid:s})).commit.message,c=[s],f=null,d=We({ref:"HEAD"}),h=await Ow({fs:e,dir:t,gitdir:r,treePair:[We({ref:"HEAD"}),"stage"]});if(h){let y=await n.writeStashCommit({message:`stash-Index: WIP on ${a} - ${new Date().toISOString()}`,tree:h,parent:c});c.push(y),f=h,d=Tr()}let p=await Ow({fs:e,dir:t,gitdir:r,treePair:[d,"workdir"]});if(p){let y=await n.writeStashCommit({message:`stash-WorkDir: WIP on ${a} - ${new Date().toISOString()}`,tree:p,parent:[c[c.length-1]]});c.push(y),f=p}if(!f||!h&&!p)throw new J("changes, nothing to stash");let m=(i.trim()||`WIP on ${a}`)+`: ${s.substring(0,7)} ${u}`;return{stashCommit:await n.writeStashCommit({message:m,tree:f,parent:c}),stashMsg:m,branch:a,stashMgr:n}}o(cy,"_createStashCommit");async function vx({fs:e,dir:t,gitdir:r,message:i=""}){let{stashCommit:n,stashMsg:a,branch:s,stashMgr:l}=await cy({fs:e,dir:t,gitdir:r,message:i});return await l.writeStashRef(n),await l.writeStashReflogEntry({stashCommit:n,message:a}),await Ic({fs:e,dir:t,gitdir:r,ref:s,track:!1,force:!0}),n}o(vx,"_stashPush");async function Fx({fs:e,dir:t,gitdir:r,message:i=""}){let{stashCommit:n}=await cy({fs:e,dir:t,gitdir:r,message:i});return n}o(Fx,"_stashCreate");async function fy({fs:e,dir:t,gitdir:r,refIdx:i=0}){let a=await new Pr({fs:e,dir:t,gitdir:r}).readStashCommit(i),{parent:s=null}=a.commit?a.commit:{};if(!(!s||!Array.isArray(s)))for(let l=0;l<s.length-1;l++){let c=(await Fi({fs:e,cache:{},gitdir:r,oid:s[l+1]})).commit.message.startsWith("stash-Index");await _x({fs:e,dir:t,gitdir:r,stashCommit:s[l+1],parentCommit:s[l],wasStaged:c})}}o(fy,"_stashApply");async function uy({fs:e,dir:t,gitdir:r,refIdx:i=0}){let n=new Pr({fs:e,dir:t,gitdir:r});if(!(await n.readStashCommit(i)).commit)return;let s=n.refStashPath;await ki(s,async()=>{await e.exists(s)&&await e.rm(s)});let l=await n.readStashReflogs({parsed:!1});if(!l.length)return;l.splice(i,1);let u=n.refLogsStashPath;await ki({reflogEntries:l,stashReflogPath:u,stashMgr:n},async()=>{if(l.length){await e.write(u,l.reverse().join(`
|
|
96
|
-
`)+`
|
|
97
|
-
`,"utf8");let c=l[l.length-1].split(" ")[1];await n.writeStashRef(c)}else await e.rm(u)})}o(uy,"_stashDrop");async function Sx({fs:e,dir:t,gitdir:r}){return new Pr({fs:e,dir:t,gitdir:r}).readStashReflogs({parsed:!0})}o(Sx,"_stashList");async function Ex({fs:e,dir:t,gitdir:r}){let i=new Pr({fs:e,dir:t,gitdir:r}),n=[i.refStashPath,i.refLogsStashPath];await ki(n,async()=>{await Promise.all(n.map(async a=>{if(await e.exists(a))return e.rm(a)}))})}o(Ex,"_stashClear");async function kx({fs:e,dir:t,gitdir:r,refIdx:i=0}){await fy({fs:e,dir:t,gitdir:r,refIdx:i}),await uy({fs:e,dir:t,gitdir:r,refIdx:i})}o(kx,"_stashPop");async function dy({fs:e,dir:t,gitdir:r=D(t,".git"),op:i="push",message:n="",refIdx:a=0}){E("fs",e),E("dir",t),E("gitdir",r),E("op",i);let s={push:vx,apply:fy,drop:uy,list:Sx,clear:Ex,pop:kx,create:Fx},l=["apply","drop","pop"];try{let u=new N(e);["refs","logs","logs/refs"].map(d=>D(r,d)).forEach(async d=>{await u.exists(d)||await u.mkdir(d)});let f=s[i];if(f){if(l.includes(i)&&a<0)throw new lt(`stash@${a}`,"number that is in range of [0, num of stash pushed]");return await f({fs:u,dir:t,gitdir:r,message:n,refIdx:a})}throw new Error(`To be implemented: ${i}`)}catch(u){throw u.caller="git.stash",u}}o(dy,"stash");async function hy({fs:e,dir:t,gitdir:r=D(t,".git"),filepath:i,cache:n={}}){try{E("fs",e),E("gitdir",r),E("filepath",i);let a=new N(e);if(await tr.isIgnored({fs:a,gitdir:r,dir:t,filepath:i}))return"ignored";let l=await xx({fs:a,cache:n,gitdir:r}),u=await py({fs:a,cache:n,gitdir:r,tree:l,path:i}),c=await fe.acquire({fs:a,gitdir:r,cache:n},async function(w){for(let y of w)if(y.path===i)return y;return null}),f=await a.lstat(D(t,i)),d=u!==null,h=c!==null,p=f!==null,m=o(async()=>{if(h&&!Ka(c,f))return c.oid;{let w=await a.read(D(t,i)),y=await ny({gitdir:r,type:"blob",object:w});return h&&c.oid===y&&f.size!==-1&&fe.acquire({fs:a,gitdir:r,cache:n},async function(g){g.insert({filepath:i,stats:f,oid:y})}),y}},"getWorkdirOid");if(!d&&!p&&!h)return"absent";if(!d&&!p&&h)return"*absent";if(!d&&p&&!h)return"*added";if(!d&&p&&h)return await m()===c.oid?"added":"*added";if(d&&!p&&!h)return"deleted";if(d&&!p&&h)return u===c.oid,"*deleted";if(d&&p&&!h)return await m()===u?"*undeleted":"*undeletemodified";if(d&&p&&h){let w=await m();return w===u?w===c.oid?"unmodified":"*unmodified":w===c.oid?"modified":"*modified"}}catch(a){throw a.caller="git.status",a}}o(hy,"status");async function py({fs:e,cache:t,gitdir:r,tree:i,path:n}){typeof n=="string"&&(n=n.split("/"));let a=n.shift();for(let s of i)if(s.path===a){if(n.length===0)return s.oid;let{type:l,object:u}=await Q({fs:e,cache:t,gitdir:r,oid:s.oid});if(l==="tree"){let c=Me.from(u);return py({fs:e,cache:t,gitdir:r,tree:c,path:n})}if(l==="blob")throw new Oe(s.oid,l,"blob",n.join("/"))}return null}o(py,"getOidAtPath");async function xx({fs:e,cache:t,gitdir:r}){let i;try{i=await C.resolve({fs:e,gitdir:r,ref:"HEAD"})}catch(a){if(a instanceof J)return[]}let{tree:n}=await Pi({fs:e,cache:t,gitdir:r,oid:i});return n}o(xx,"getHeadTree");async function my({fs:e,dir:t,gitdir:r=D(t,".git"),ref:i="HEAD",filepaths:n=["."],filter:a,cache:s={},ignored:l=!1}){try{E("fs",e),E("gitdir",r),E("ref",i);let u=new N(e);return await er({fs:u,cache:s,dir:t,gitdir:r,trees:[We({ref:i}),xi(),Tr()],map:o(async function(c,[f,d,h]){if(!f&&!h&&d&&!l&&await tr.isIgnored({fs:u,dir:t,filepath:c})||!n.some(P=>tg(c,P)))return null;if(a&&!a(c))return;let[p,m,w]=await Promise.all([f&&f.type(),d&&d.type(),h&&h.type()]),y=[p,m,w].includes("blob");if((p==="tree"||p==="special")&&!y)return;if(p==="commit")return null;if((m==="tree"||m==="special")&&!y)return;if(w==="commit")return null;if((w==="tree"||w==="special")&&!y)return;let g=p==="blob"?await f.oid():void 0,_=w==="blob"?await h.oid():void 0,k;p!=="blob"&&m==="blob"&&w!=="blob"?k="42":m==="blob"&&(k=await d.oid());let F=[void 0,g,k,_],S=F.map(P=>F.indexOf(P));return S.shift(),[c,...S]},"map")})}catch(u){throw u.caller="git.statusMatrix",u}}o(my,"statusMatrix");async function wy({fs:e,dir:t,gitdir:r=D(t,".git"),ref:i,object:n,force:a=!1}){try{E("fs",e),E("gitdir",r),E("ref",i);let s=new N(e);if(i===void 0)throw new Le("ref");i=i.startsWith("refs/tags/")?i:`refs/tags/${i}`;let l=await C.resolve({fs:s,gitdir:r,ref:n||"HEAD"});if(!a&&await C.exists({fs:s,gitdir:r,ref:i}))throw new st("tag",i);await C.writeRef({fs:s,gitdir:r,ref:i,value:l})}catch(s){throw s.caller="git.tag",s}}o(wy,"tag");async function gy({fs:e,dir:t,gitdir:r=D(t,".git"),cache:i={},filepath:n,oid:a,mode:s,add:l,remove:u,force:c}){try{E("fs",e),E("gitdir",r),E("filepath",n);let f=new N(e);if(u)return await fe.acquire({fs:f,gitdir:r,cache:i},async function(h){if(!c){let p=await f.lstat(D(t,n));if(p){if(p.isDirectory())throw new Qt("directory");return}}h.has({filepath:n})&&h.delete({filepath:n})});let d;if(!a){if(d=await f.lstat(D(t,n)),!d)throw new J(`file at "${n}" on disk and "remove" not set`);if(d.isDirectory())throw new Qt("directory")}return await fe.acquire({fs:f,gitdir:r,cache:i},async function(h){if(!l&&!h.has({filepath:n}))throw new J(`file at "${n}" in index and "add" not set`);let p;if(a)p={ctime:new Date(0),mtime:new Date(0),dev:0,ino:0,mode:s,uid:0,gid:0,size:0};else{p=d;let m=p.isSymbolicLink()?await f.readlink(D(t,n)):await f.read(D(t,n));a=await He({fs:f,gitdir:r,type:"blob",format:"content",object:m})}return h.insert({filepath:n,oid:a,stats:p}),a})}catch(f){throw f.caller="git.updateIndex",f}}o(gy,"updateIndex$1");function yy(){try{return Zo.version}catch(e){throw e.caller="git.version",e}}o(yy,"version");async function by({fs:e,dir:t,gitdir:r=D(t,".git"),trees:i,map:n,reduce:a,iterate:s,cache:l={}}){try{return E("fs",e),E("gitdir",r),E("trees",i),await er({fs:new N(e),cache:l,dir:t,gitdir:r,trees:i,map:n,reduce:a,iterate:s})}catch(u){throw u.caller="git.walk",u}}o(by,"walk");async function _y({fs:e,dir:t,gitdir:r=D(t,".git"),blob:i}){try{return E("fs",e),E("gitdir",r),E("blob",i),await He({fs:new N(e),gitdir:r,type:"blob",object:i,format:"content"})}catch(n){throw n.caller="git.writeBlob",n}}o(_y,"writeBlob");async function vy({fs:e,dir:t,gitdir:r=D(t,".git"),commit:i}){try{return E("fs",e),E("gitdir",r),E("commit",i),await ly({fs:new N(e),gitdir:r,commit:i})}catch(n){throw n.caller="git.writeCommit",n}}o(vy,"writeCommit");async function Fy({fs:e,dir:t,gitdir:r=D(t,".git"),type:i,object:n,format:a="parsed",oid:s,encoding:l=void 0}){try{let u=new N(e);if(a==="parsed"){switch(i){case"commit":n=je.from(n).toObject();break;case"tree":n=Me.from(n).toObject();break;case"blob":n=Buffer.from(n,l);break;case"tag":n=Ve.from(n).toObject();break;default:throw new Oe(s||"",i,"blob|commit|tag|tree")}a="content"}return s=await He({fs:u,gitdir:r,type:i,object:n,oid:s,format:a}),s}catch(u){throw u.caller="git.writeObject",u}}o(Fy,"writeObject");async function Sy({fs:e,dir:t,gitdir:r=D(t,".git"),ref:i,value:n,force:a=!1,symbolic:s=!1}){try{E("fs",e),E("gitdir",r),E("ref",i),E("value",n);let l=new N(e);if(!Ln(i,!0))throw new lt(i,_n.clean(i));if(!a&&await C.exists({fs:l,gitdir:r,ref:i}))throw new st("ref",i);s?await C.writeSymbolicRef({fs:l,gitdir:r,ref:i,value:n}):(n=await C.resolve({fs:l,gitdir:r,ref:n}),await C.writeRef({fs:l,gitdir:r,ref:i,value:n}))}catch(l){throw l.caller="git.writeRef",l}}o(Sy,"writeRef");async function Px({fs:e,gitdir:t,tag:r}){let i=Ve.from(r).toObject();return await He({fs:e,gitdir:t,type:"tag",object:i,format:"content"})}o(Px,"_writeTag");async function Ey({fs:e,dir:t,gitdir:r=D(t,".git"),tag:i}){try{return E("fs",e),E("gitdir",r),E("tag",i),await Px({fs:new N(e),gitdir:r,tag:i})}catch(n){throw n.caller="git.writeTag",n}}o(Ey,"writeTag");async function ky({fs:e,dir:t,gitdir:r=D(t,".git"),tree:i}){try{return E("fs",e),E("gitdir",r),E("tree",i),await jn({fs:new N(e),gitdir:r,tree:i})}catch(n){throw n.caller="git.writeTree",n}}o(ky,"writeTree");var Tx={Errors:jw,STAGE:Tr,TREE:We,WORKDIR:xi,add:Ww,abortMerge:qw,addNote:Yw,addRemote:Jw,annotatedTag:Qw,branch:eg,checkout:Ic,clone:og,commit:sg,getConfig:Fg,getConfigAll:Sg,setConfig:sy,currentBranch:lg,deleteBranch:cg,deleteRef:fg,deleteRemote:ug,deleteTag:dg,expandOid:hg,expandRef:pg,fastForward:gg,fetch:yg,findMergeBase:bg,findRoot:vg,getRemoteInfo:Eg,getRemoteInfo2:xg,hashBlob:Pg,indexPack:Tg,init:Ag,isDescendent:Dg,isIgnored:Rg,listBranches:Cg,listFiles:Bg,listNotes:Ng,listRefs:$g,listRemotes:Lg,listServerRefs:Mg,listTags:jg,log:qg,merge:Ug,packObjects:Wg,pull:Vg,push:Gg,readBlob:Yg,readCommit:$c,readNote:Xg,readObject:Jg,readTag:Qg,readTree:ey,remove:ty,removeNote:ry,renameBranch:iy,resetIndex:ay,updateIndex:gy,resolveRef:oy,status:hy,statusMatrix:my,tag:wy,version:yy,walk:by,writeBlob:_y,writeCommit:vy,writeObject:Fy,writeRef:Sy,writeTag:Ey,writeTree:ky,stash:dy};I.Errors=jw;I.STAGE=Tr;I.TREE=We;I.WORKDIR=xi;I.abortMerge=qw;I.add=Ww;I.addNote=Yw;I.addRemote=Jw;I.annotatedTag=Qw;I.branch=eg;I.checkout=Ic;I.clone=og;I.commit=sg;I.currentBranch=lg;I.default=Tx;I.deleteBranch=cg;I.deleteRef=fg;I.deleteRemote=ug;I.deleteTag=dg;I.expandOid=hg;I.expandRef=pg;I.fastForward=gg;I.fetch=yg;I.findMergeBase=bg;I.findRoot=vg;I.getConfig=Fg;I.getConfigAll=Sg;I.getRemoteInfo=Eg;I.getRemoteInfo2=xg;I.hashBlob=Pg;I.indexPack=Tg;I.init=Ag;I.isDescendent=Dg;I.isIgnored=Rg;I.listBranches=Cg;I.listFiles=Bg;I.listNotes=Ng;I.listRefs=$g;I.listRemotes=Lg;I.listServerRefs=Mg;I.listTags=jg;I.log=qg;I.merge=Ug;I.packObjects=Wg;I.pull=Vg;I.push=Gg;I.readBlob=Yg;I.readCommit=$c;I.readNote=Xg;I.readObject=Jg;I.readTag=Qg;I.readTree=ey;I.remove=ty;I.removeNote=ry;I.renameBranch=iy;I.resetIndex=ay;I.resolveRef=oy;I.setConfig=sy;I.stash=dy;I.status=hy;I.statusMatrix=my;I.tag=wy;I.updateIndex=gy;I.version=yy;I.walk=by;I.writeBlob=_y;I.writeCommit=vy;I.writeObject=Fy;I.writeRef=Sy;I.writeTag=Ey;I.writeTree=ky});var Iy=O((KB,Cy)=>{Cy.exports=function(e,t){var r=[];e.on("data",function(i){r.push(i)}),e.once("end",function(){t&&t(null,Buffer.concat(r)),t=null}),e.once("error",function(i){t&&t(i),t=null})}});var Ny=O((YB,By)=>{"use strict";var Cx=["aborted","complete","headers","httpVersion","httpVersionMinor","httpVersionMajor","method","rawHeaders","rawTrailers","setTimeout","socket","statusCode","statusMessage","trailers","url"];By.exports=(e,t)=>{if(t._readableState.autoDestroy)throw new Error("The second stream must have the `autoDestroy` option set to `false`");let r=new Set(Object.keys(e).concat(Cx)),i={};for(let n of r)n in t||(i[n]={get(){let a=e[n];return typeof a=="function"?a.bind(e):a},set(a){e[n]=a},enumerable:!0,configurable:!1});return Object.defineProperties(t,i),e.once("aborted",()=>{t.destroy(),t.emit("aborted")}),e.once("close",()=>{e.complete&&t.readable?t.once("end",()=>{t.emit("close")}):t.emit("close")}),t}});var Ly=O((XB,$y)=>{"use strict";var{Transform:Ix,PassThrough:Bx}=X("stream"),of=X("zlib"),Nx=Ny();$y.exports=e=>{let t=(e.headers["content-encoding"]||"").toLowerCase();if(!["gzip","deflate","br"].includes(t))return e;let r=t==="br";if(r&&typeof of.createBrotliDecompress!="function")return e.destroy(new Error("Brotli is not supported on Node.js < 12")),e;let i=!0,n=new Ix({transform(l,u,c){i=!1,c(null,l)},flush(l){l()}}),a=new Bx({autoDestroy:!1,destroy(l,u){e.destroy(),u(l)}}),s=r?of.createBrotliDecompress():of.createUnzip();return s.once("error",l=>{if(i&&!e.readable){a.end();return}a.destroy(l)}),Nx(e,a),e.pipe(n).pipe(s).pipe(a),a}});var Hy=O((JB,jy)=>{jy.exports=My;function My(e,t){if(e&&t)return My(e)(t);if(typeof e!="function")throw new TypeError("need wrapper function");return Object.keys(e).forEach(function(i){r[i]=e[i]}),r;function r(){for(var i=new Array(arguments.length),n=0;n<i.length;n++)i[n]=arguments[n];var a=e.apply(this,i),s=i[i.length-1];return typeof a=="function"&&a!==s&&Object.keys(s).forEach(function(l){a[l]=s[l]}),a}o(r,"wrapper")}o(My,"wrappy")});var zy=O((e2,sf)=>{var qy=Hy();sf.exports=qy(Qo);sf.exports.strict=qy(Uy);Qo.proto=Qo(function(){Object.defineProperty(Function.prototype,"once",{value:o(function(){return Qo(this)},"value"),configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:o(function(){return Uy(this)},"value"),configurable:!0})});function Qo(e){var t=o(function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))},"f");return t.called=!1,t}o(Qo,"once");function Uy(e){var t=o(function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},"f"),r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=!1,t}o(Uy,"onceStrict")});var Zy=O((r2,Gy)=>{Gy.exports=Ti;var $x=Iy(),Wy=Ly(),Lx=X("http"),Mx=X("https"),jx=zy(),Hx=X("querystring"),Vy=X("url"),lf=o(e=>e!==null&&typeof e=="object"&&typeof e.pipe=="function","isStream");function Ti(e,t){if(e=Object.assign({maxRedirects:10},typeof e=="string"?{url:e}:e),t=jx(t),e.url){let{hostname:l,port:u,protocol:c,auth:f,path:d}=Vy.parse(e.url);delete e.url,!l&&!u&&!c&&!f?e.path=d:Object.assign(e,{hostname:l,port:u,protocol:c,auth:f,path:d})}let r={"accept-encoding":"gzip, deflate"};e.headers&&Object.keys(e.headers).forEach(l=>r[l.toLowerCase()]=e.headers[l]),e.headers=r;let i;e.body?i=e.json&&!lf(e.body)?JSON.stringify(e.body):e.body:e.form&&(i=typeof e.form=="string"?e.form:Hx.stringify(e.form),e.headers["content-type"]="application/x-www-form-urlencoded"),i&&(e.method||(e.method="POST"),lf(i)||(e.headers["content-length"]=Buffer.byteLength(i)),e.json&&!e.form&&(e.headers["content-type"]="application/json")),delete e.body,delete e.form,e.json&&(e.headers.accept="application/json"),e.method&&(e.method=e.method.toUpperCase());let n=e.hostname,s=(e.protocol==="https:"?Mx:Lx).request(e,l=>{if(e.followRedirects!==!1&&l.statusCode>=300&&l.statusCode<400&&l.headers.location){e.url=l.headers.location,delete e.headers.host,l.resume();let c=Vy.parse(e.url).hostname;return c!==null&&c!==n&&(delete e.headers.cookie,delete e.headers.authorization),e.method==="POST"&&[301,302].includes(l.statusCode)&&(e.method="GET",delete e.headers["content-length"],delete e.headers["content-type"]),e.maxRedirects--===0?t(new Error("too many redirects")):Ti(e,t)}let u=typeof Wy=="function"&&e.method!=="HEAD";t(null,u?Wy(l):l)});return s.on("timeout",()=>{s.abort(),t(new Error("Request timed out"))}),s.on("error",t),lf(i)?i.on("error",t).pipe(s):s.end(i),s}o(Ti,"simpleGet");Ti.concat=(e,t)=>Ti(e,(r,i)=>{if(r)return t(r);$x(i,(n,a)=>{if(n)return t(n);if(e.json)try{a=JSON.parse(a.toString())}catch(s){return t(s,i,a)}t(null,i,a)})});["get","post","put","patch","head","delete"].forEach(e=>{Ti[e]=(t,r)=>(typeof t=="string"&&(t={url:t}),Ti(Object.assign({method:e.toUpperCase()},t),r))})});var ie=O((n2,Ky)=>{"use strict";var ff=class ff extends Error{constructor(t){if(!Array.isArray(t))throw new TypeError(`Expected input to be an Array, got ${typeof t}`);let r="";for(let i=0;i<t.length;i++)r+=` ${t[i].stack}
|
|
98
|
-
`;super(r),this.name="AggregateError",this.errors=t}};o(ff,"AggregateError");var cf=ff;Ky.exports={AggregateError:cf,ArrayIsArray(e){return Array.isArray(e)},ArrayPrototypeIncludes(e,t){return e.includes(t)},ArrayPrototypeIndexOf(e,t){return e.indexOf(t)},ArrayPrototypeJoin(e,t){return e.join(t)},ArrayPrototypeMap(e,t){return e.map(t)},ArrayPrototypePop(e,t){return e.pop(t)},ArrayPrototypePush(e,t){return e.push(t)},ArrayPrototypeSlice(e,t,r){return e.slice(t,r)},Error,FunctionPrototypeCall(e,t,...r){return e.call(t,...r)},FunctionPrototypeSymbolHasInstance(e,t){return Function.prototype[Symbol.hasInstance].call(e,t)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(e,t){return Object.defineProperties(e,t)},ObjectDefineProperty(e,t,r){return Object.defineProperty(e,t,r)},ObjectGetOwnPropertyDescriptor(e,t){return Object.getOwnPropertyDescriptor(e,t)},ObjectKeys(e){return Object.keys(e)},ObjectSetPrototypeOf(e,t){return Object.setPrototypeOf(e,t)},Promise,PromisePrototypeCatch(e,t){return e.catch(t)},PromisePrototypeThen(e,t,r){return e.then(t,r)},PromiseReject(e){return Promise.reject(e)},PromiseResolve(e){return Promise.resolve(e)},ReflectApply:Reflect.apply,RegExpPrototypeTest(e,t){return e.test(t)},SafeSet:Set,String,StringPrototypeSlice(e,t,r){return e.slice(t,r)},StringPrototypeToLowerCase(e){return e.toLowerCase()},StringPrototypeToUpperCase(e){return e.toUpperCase()},StringPrototypeTrim(e){return e.trim()},Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,SymbolDispose:Symbol.dispose||Symbol("Symbol.dispose"),SymbolAsyncDispose:Symbol.asyncDispose||Symbol("Symbol.asyncDispose"),TypedArrayPrototypeSet(e,t,r){return e.set(t,r)},Boolean,Uint8Array}});var uf=O((o2,Yy)=>{"use strict";Yy.exports={format(e,...t){return e.replace(/%([sdifj])/g,function(...[r,i]){let n=t.shift();return i==="f"?n.toFixed(6):i==="j"?JSON.stringify(n):i==="s"&&typeof n=="object"?`${n.constructor!==Object?n.constructor.name:""} {}`.trim():n.toString()})},inspect(e){switch(typeof e){case"string":if(e.includes("'"))if(e.includes('"')){if(!e.includes("`")&&!e.includes("${"))return`\`${e}\``}else return`"${e}"`;return`'${e}'`;case"number":return isNaN(e)?"NaN":Object.is(e,-0)?String(e):e;case"bigint":return`${String(e)}n`;case"boolean":case"undefined":return String(e);case"object":return"{}"}}}});var ke=O((s2,Qy)=>{"use strict";var{format:qx,inspect:es}=uf(),{AggregateError:Ux}=ie(),zx=globalThis.AggregateError||Ux,Wx=Symbol("kIsNodeError"),Vx=["string","function","number","object","Function","Object","boolean","bigint","symbol"],Gx=/^([A-Z][a-z0-9]*)+$/,Zx="__node_internal_",ts={};function Dr(e,t){if(!e)throw new ts.ERR_INTERNAL_ASSERTION(t)}o(Dr,"assert");function Xy(e){let t="",r=e.length,i=e[0]==="-"?1:0;for(;r>=i+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}o(Xy,"addNumericalSeparator");function Kx(e,t,r){if(typeof t=="function")return Dr(t.length<=r.length,`Code: ${e}; The provided arguments length (${r.length}) does not match the required ones (${t.length}).`),t(...r);let i=(t.match(/%[dfijoOs]/g)||[]).length;return Dr(i===r.length,`Code: ${e}; The provided arguments length (${r.length}) does not match the required ones (${i}).`),r.length===0?t:qx(t,...r)}o(Kx,"getMessage");function Fe(e,t,r){r||(r=Error);let n=class n extends r{constructor(...s){super(Kx(e,t,s))}toString(){return`${this.name} [${e}]: ${this.message}`}};o(n,"NodeError");let i=n;Object.defineProperties(i.prototype,{name:{value:r.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${e}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),i.prototype.code=e,i.prototype[Wx]=!0,ts[e]=i}o(Fe,"E");function Jy(e){let t=Zx+e.name;return Object.defineProperty(e,"name",{value:t}),e}o(Jy,"hideStackFrames");function Yx(e,t){if(e&&t&&e!==t){if(Array.isArray(t.errors))return t.errors.push(e),t;let r=new zx([t,e],t.message);return r.code=t.code,r}return e||t}o(Yx,"aggregateTwoErrors");var hf=class hf extends Error{constructor(t="The operation was aborted",r=void 0){if(r!==void 0&&typeof r!="object")throw new ts.ERR_INVALID_ARG_TYPE("options","Object",r);super(t,r),this.code="ABORT_ERR",this.name="AbortError"}};o(hf,"AbortError");var df=hf;Fe("ERR_ASSERTION","%s",Error);Fe("ERR_INVALID_ARG_TYPE",(e,t,r)=>{Dr(typeof e=="string","'name' must be a string"),Array.isArray(t)||(t=[t]);let i="The ";e.endsWith(" argument")?i+=`${e} `:i+=`"${e}" ${e.includes(".")?"property":"argument"} `,i+="must be ";let n=[],a=[],s=[];for(let u of t)Dr(typeof u=="string","All expected entries have to be of type string"),Vx.includes(u)?n.push(u.toLowerCase()):Gx.test(u)?a.push(u):(Dr(u!=="object",'The value "object" should be written as "Object"'),s.push(u));if(a.length>0){let u=n.indexOf("object");u!==-1&&(n.splice(n,u,1),a.push("Object"))}if(n.length>0){switch(n.length){case 1:i+=`of type ${n[0]}`;break;case 2:i+=`one of type ${n[0]} or ${n[1]}`;break;default:{let u=n.pop();i+=`one of type ${n.join(", ")}, or ${u}`}}(a.length>0||s.length>0)&&(i+=" or ")}if(a.length>0){switch(a.length){case 1:i+=`an instance of ${a[0]}`;break;case 2:i+=`an instance of ${a[0]} or ${a[1]}`;break;default:{let u=a.pop();i+=`an instance of ${a.join(", ")}, or ${u}`}}s.length>0&&(i+=" or ")}switch(s.length){case 0:break;case 1:s[0].toLowerCase()!==s[0]&&(i+="an "),i+=`${s[0]}`;break;case 2:i+=`one of ${s[0]} or ${s[1]}`;break;default:{let u=s.pop();i+=`one of ${s.join(", ")}, or ${u}`}}if(r==null)i+=`. Received ${r}`;else if(typeof r=="function"&&r.name)i+=`. Received function ${r.name}`;else if(typeof r=="object"){var l;if((l=r.constructor)!==null&&l!==void 0&&l.name)i+=`. Received an instance of ${r.constructor.name}`;else{let u=es(r,{depth:-1});i+=`. Received ${u}`}}else{let u=es(r,{colors:!1});u.length>25&&(u=`${u.slice(0,25)}...`),i+=`. Received type ${typeof r} (${u})`}return i},TypeError);Fe("ERR_INVALID_ARG_VALUE",(e,t,r="is invalid")=>{let i=es(t);return i.length>128&&(i=i.slice(0,128)+"..."),`The ${e.includes(".")?"property":"argument"} '${e}' ${r}. Received ${i}`},TypeError);Fe("ERR_INVALID_RETURN_VALUE",(e,t,r)=>{var i;let n=r!=null&&(i=r.constructor)!==null&&i!==void 0&&i.name?`instance of ${r.constructor.name}`:`type ${typeof r}`;return`Expected ${e} to be returned from the "${t}" function but got ${n}.`},TypeError);Fe("ERR_MISSING_ARGS",(...e)=>{Dr(e.length>0,"At least one arg needs to be specified");let t,r=e.length;switch(e=(Array.isArray(e)?e:[e]).map(i=>`"${i}"`).join(" or "),r){case 1:t+=`The ${e[0]} argument`;break;case 2:t+=`The ${e[0]} and ${e[1]} arguments`;break;default:{let i=e.pop();t+=`The ${e.join(", ")}, and ${i} arguments`}break}return`${t} must be specified`},TypeError);Fe("ERR_OUT_OF_RANGE",(e,t,r)=>{Dr(t,'Missing "range" argument');let i;if(Number.isInteger(r)&&Math.abs(r)>2**32)i=Xy(String(r));else if(typeof r=="bigint"){i=String(r);let n=BigInt(2)**BigInt(32);(r>n||r<-n)&&(i=Xy(i)),i+="n"}else i=es(r);return`The value of "${e}" is out of range. It must be ${t}. Received ${i}`},RangeError);Fe("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error);Fe("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error);Fe("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error);Fe("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error);Fe("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error);Fe("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);Fe("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error);Fe("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error);Fe("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error);Fe("ERR_STREAM_WRITE_AFTER_END","write after end",Error);Fe("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);Qy.exports={AbortError:df,aggregateTwoErrors:Jy(Yx),hideStackFrames:Jy,codes:ts}});var cb=O((Wn,zn)=>{"use strict";Object.defineProperty(Wn,"__esModule",{value:!0});var ab=new WeakMap,pf=new WeakMap;function ee(e){let t=ab.get(e);return console.assert(t!=null,"'this' is expected an Event object, but got",e),t}o(ee,"pd");function eb(e){if(e.passiveListener!=null){typeof console<"u"&&typeof console.error=="function"&&console.error("Unable to preventDefault inside passive event listener invocation.",e.passiveListener);return}e.event.cancelable&&(e.canceled=!0,typeof e.event.preventDefault=="function"&&e.event.preventDefault())}o(eb,"setCancelFlag");function Ai(e,t){ab.set(this,{eventTarget:e,event:t,eventPhase:2,currentTarget:e,canceled:!1,stopped:!1,immediateStopped:!1,passiveListener:null,timeStamp:t.timeStamp||Date.now()}),Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let r=Object.keys(t);for(let i=0;i<r.length;++i){let n=r[i];n in this||Object.defineProperty(this,n,ob(n))}}o(Ai,"Event");Ai.prototype={get type(){return ee(this).event.type},get target(){return ee(this).eventTarget},get currentTarget(){return ee(this).currentTarget},composedPath(){let e=ee(this).currentTarget;return e==null?[]:[e]},get NONE(){return 0},get CAPTURING_PHASE(){return 1},get AT_TARGET(){return 2},get BUBBLING_PHASE(){return 3},get eventPhase(){return ee(this).eventPhase},stopPropagation(){let e=ee(this);e.stopped=!0,typeof e.event.stopPropagation=="function"&&e.event.stopPropagation()},stopImmediatePropagation(){let e=ee(this);e.stopped=!0,e.immediateStopped=!0,typeof e.event.stopImmediatePropagation=="function"&&e.event.stopImmediatePropagation()},get bubbles(){return!!ee(this).event.bubbles},get cancelable(){return!!ee(this).event.cancelable},preventDefault(){eb(ee(this))},get defaultPrevented(){return ee(this).canceled},get composed(){return!!ee(this).event.composed},get timeStamp(){return ee(this).timeStamp},get srcElement(){return ee(this).eventTarget},get cancelBubble(){return ee(this).stopped},set cancelBubble(e){if(!e)return;let t=ee(this);t.stopped=!0,typeof t.event.cancelBubble=="boolean"&&(t.event.cancelBubble=!0)},get returnValue(){return!ee(this).canceled},set returnValue(e){e||eb(ee(this))},initEvent(){}};Object.defineProperty(Ai.prototype,"constructor",{value:Ai,configurable:!0,writable:!0});typeof window<"u"&&typeof window.Event<"u"&&(Object.setPrototypeOf(Ai.prototype,window.Event.prototype),pf.set(window.Event.prototype,Ai));function ob(e){return{get(){return ee(this).event[e]},set(t){ee(this).event[e]=t},configurable:!0,enumerable:!0}}o(ob,"defineRedirectDescriptor");function Xx(e){return{value(){let t=ee(this).event;return t[e].apply(t,arguments)},configurable:!0,enumerable:!0}}o(Xx,"defineCallDescriptor");function Jx(e,t){let r=Object.keys(t);if(r.length===0)return e;function i(n,a){e.call(this,n,a)}o(i,"CustomEvent"),i.prototype=Object.create(e.prototype,{constructor:{value:i,configurable:!0,writable:!0}});for(let n=0;n<r.length;++n){let a=r[n];if(!(a in e.prototype)){let l=typeof Object.getOwnPropertyDescriptor(t,a).value=="function";Object.defineProperty(i.prototype,a,l?Xx(a):ob(a))}}return i}o(Jx,"defineWrapper");function sb(e){if(e==null||e===Object.prototype)return Ai;let t=pf.get(e);return t==null&&(t=Jx(sb(Object.getPrototypeOf(e)),e),pf.set(e,t)),t}o(sb,"getWrapper");function Qx(e,t){let r=sb(Object.getPrototypeOf(t));return new r(e,t)}o(Qx,"wrapEvent");function eP(e){return ee(e).immediateStopped}o(eP,"isStopped");function tP(e,t){ee(e).eventPhase=t}o(tP,"setEventPhase");function rP(e,t){ee(e).currentTarget=t}o(rP,"setCurrentTarget");function tb(e,t){ee(e).passiveListener=t}o(tb,"setPassiveListener");var lb=new WeakMap,rb=1,ib=2,rs=3;function is(e){return e!==null&&typeof e=="object"}o(is,"isObject");function Un(e){let t=lb.get(e);if(t==null)throw new TypeError("'this' is expected an EventTarget object, but got another value.");return t}o(Un,"getListeners");function iP(e){return{get(){let r=Un(this).get(e);for(;r!=null;){if(r.listenerType===rs)return r.listener;r=r.next}return null},set(t){typeof t!="function"&&!is(t)&&(t=null);let r=Un(this),i=null,n=r.get(e);for(;n!=null;)n.listenerType===rs?i!==null?i.next=n.next:n.next!==null?r.set(e,n.next):r.delete(e):i=n,n=n.next;if(t!==null){let a={listener:t,listenerType:rs,passive:!1,once:!1,next:null};i===null?r.set(e,a):i.next=a}},configurable:!0,enumerable:!0}}o(iP,"defineEventAttributeDescriptor");function mf(e,t){Object.defineProperty(e,`on${t}`,iP(t))}o(mf,"defineEventAttribute");function nb(e){function t(){ct.call(this)}o(t,"CustomEventTarget"),t.prototype=Object.create(ct.prototype,{constructor:{value:t,configurable:!0,writable:!0}});for(let r=0;r<e.length;++r)mf(t.prototype,e[r]);return t}o(nb,"defineCustomEventTarget");function ct(){if(this instanceof ct){lb.set(this,new Map);return}if(arguments.length===1&&Array.isArray(arguments[0]))return nb(arguments[0]);if(arguments.length>0){let e=new Array(arguments.length);for(let t=0;t<arguments.length;++t)e[t]=arguments[t];return nb(e)}throw new TypeError("Cannot call a class as a function")}o(ct,"EventTarget");ct.prototype={addEventListener(e,t,r){if(t==null)return;if(typeof t!="function"&&!is(t))throw new TypeError("'listener' should be a function or an object.");let i=Un(this),n=is(r),s=(n?!!r.capture:!!r)?rb:ib,l={listener:t,listenerType:s,passive:n&&!!r.passive,once:n&&!!r.once,next:null},u=i.get(e);if(u===void 0){i.set(e,l);return}let c=null;for(;u!=null;){if(u.listener===t&&u.listenerType===s)return;c=u,u=u.next}c.next=l},removeEventListener(e,t,r){if(t==null)return;let i=Un(this),a=(is(r)?!!r.capture:!!r)?rb:ib,s=null,l=i.get(e);for(;l!=null;){if(l.listener===t&&l.listenerType===a){s!==null?s.next=l.next:l.next!==null?i.set(e,l.next):i.delete(e);return}s=l,l=l.next}},dispatchEvent(e){if(e==null||typeof e.type!="string")throw new TypeError('"event.type" should be a string.');let t=Un(this),r=e.type,i=t.get(r);if(i==null)return!0;let n=Qx(this,e),a=null;for(;i!=null;){if(i.once?a!==null?a.next=i.next:i.next!==null?t.set(r,i.next):t.delete(r):a=i,tb(n,i.passive?i.listener:null),typeof i.listener=="function")try{i.listener.call(this,n)}catch(s){typeof console<"u"&&typeof console.error=="function"&&console.error(s)}else i.listenerType!==rs&&typeof i.listener.handleEvent=="function"&&i.listener.handleEvent(n);if(eP(n))break;i=i.next}return tb(n,null),tP(n,0),rP(n,null),!n.defaultPrevented}};Object.defineProperty(ct.prototype,"constructor",{value:ct,configurable:!0,writable:!0});typeof window<"u"&&typeof window.EventTarget<"u"&&Object.setPrototypeOf(ct.prototype,window.EventTarget.prototype);Wn.defineEventAttribute=mf;Wn.EventTarget=ct;Wn.default=ct;zn.exports=ct;zn.exports.EventTarget=zn.exports.default=ct;zn.exports.defineEventAttribute=mf});var Oi=O((Gn,Vn)=>{"use strict";Object.defineProperty(Gn,"__esModule",{value:!0});var wf=cb(),gf=class gf extends wf.EventTarget{constructor(){throw super(),new TypeError("AbortSignal cannot be constructed directly")}get aborted(){let t=ns.get(this);if(typeof t!="boolean")throw new TypeError(`Expected 'this' to be an 'AbortSignal' object, but got ${this===null?"null":typeof this}`);return t}};o(gf,"AbortSignal");var or=gf;wf.defineEventAttribute(or.prototype,"abort");function nP(){let e=Object.create(or.prototype);return wf.EventTarget.call(e),ns.set(e,!1),e}o(nP,"createAbortSignal");function aP(e){ns.get(e)===!1&&(ns.set(e,!0),e.dispatchEvent({type:"abort"}))}o(aP,"abortSignal");var ns=new WeakMap;Object.defineProperties(or.prototype,{aborted:{enumerable:!0}});typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol"&&Object.defineProperty(or.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortSignal"});var yf=class yf{constructor(){ub.set(this,nP())}get signal(){return fb(this)}abort(){aP(fb(this))}};o(yf,"AbortController");var sr=yf,ub=new WeakMap;function fb(e){let t=ub.get(e);if(t==null)throw new TypeError(`Expected 'this' to be an 'AbortController' object, but got ${e===null?"null":typeof e}`);return t}o(fb,"getSignal");Object.defineProperties(sr.prototype,{signal:{enumerable:!0},abort:{enumerable:!0}});typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol"&&Object.defineProperty(sr.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortController"});Gn.AbortController=sr;Gn.AbortSignal=or;Gn.default=sr;Vn.exports=sr;Vn.exports.AbortController=Vn.exports.default=sr;Vn.exports.AbortSignal=or});var Ce=O((u2,_f)=>{"use strict";var oP=X("buffer"),{format:sP,inspect:lP}=uf(),{codes:{ERR_INVALID_ARG_TYPE:bf}}=ke(),{kResistStopPropagation:cP,AggregateError:fP,SymbolDispose:uP}=ie(),dP=globalThis.AbortSignal||Oi().AbortSignal,hP=globalThis.AbortController||Oi().AbortController,pP=Object.getPrototypeOf(async function(){}).constructor,db=globalThis.Blob||oP.Blob,mP=o(typeof db<"u"?function(t){return t instanceof db}:function(t){return!1},"isBlob"),hb=o((e,t)=>{if(e!==void 0&&(e===null||typeof e!="object"||!("aborted"in e)))throw new bf(t,"AbortSignal",e)},"validateAbortSignal"),wP=o((e,t)=>{if(typeof e!="function")throw new bf(t,"Function",e)},"validateFunction");_f.exports={AggregateError:fP,kEmptyObject:Object.freeze({}),once(e){let t=!1;return function(...r){t||(t=!0,e.apply(this,r))}},createDeferredPromise:o(function(){let e,t;return{promise:new Promise((i,n)=>{e=i,t=n}),resolve:e,reject:t}},"createDeferredPromise"),promisify(e){return new Promise((t,r)=>{e((i,...n)=>i?r(i):t(...n))})},debuglog(){return function(){}},format:sP,inspect:lP,types:{isAsyncFunction(e){return e instanceof pP},isArrayBufferView(e){return ArrayBuffer.isView(e)}},isBlob:mP,deprecate(e,t){return e},addAbortListener:X("events").addAbortListener||o(function(t,r){if(t===void 0)throw new bf("signal","AbortSignal",t);hb(t,"signal"),wP(r,"listener");let i;return t.aborted?queueMicrotask(()=>r()):(t.addEventListener("abort",r,{__proto__:null,once:!0,[cP]:!0}),i=o(()=>{t.removeEventListener("abort",r)},"removeEventListener")),{__proto__:null,[uP](){var n;(n=i)===null||n===void 0||n()}}},"addAbortListener"),AbortSignalAny:dP.any||o(function(t){if(t.length===1)return t[0];let r=new hP,i=o(()=>r.abort(),"abort");return t.forEach(n=>{hb(n,"signals"),n.addEventListener("abort",i,{once:!0})}),r.signal.addEventListener("abort",()=>{t.forEach(n=>n.removeEventListener("abort",i))},{once:!0}),r.signal},"AbortSignalAny")};_f.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")});var Ri=O((h2,Sb)=>{"use strict";var{ArrayIsArray:Ff,ArrayPrototypeIncludes:gb,ArrayPrototypeJoin:yb,ArrayPrototypeMap:gP,NumberIsInteger:Sf,NumberIsNaN:yP,NumberMAX_SAFE_INTEGER:bP,NumberMIN_SAFE_INTEGER:_P,NumberParseInt:vP,ObjectPrototypeHasOwnProperty:FP,RegExpPrototypeExec:bb,String:SP,StringPrototypeToUpperCase:EP,StringPrototypeTrim:kP}=ie(),{hideStackFrames:Qe,codes:{ERR_SOCKET_BAD_PORT:xP,ERR_INVALID_ARG_TYPE:xe,ERR_INVALID_ARG_VALUE:Di,ERR_OUT_OF_RANGE:Rr,ERR_UNKNOWN_SIGNAL:pb}}=ke(),{normalizeEncoding:PP}=Ce(),{isAsyncFunction:TP,isArrayBufferView:AP}=Ce().types,mb={};function OP(e){return e===(e|0)}o(OP,"isInt32");function DP(e){return e===e>>>0}o(DP,"isUint32");var RP=/^[0-7]+$/,CP="must be a 32-bit unsigned integer or an octal string";function IP(e,t,r){if(typeof e>"u"&&(e=r),typeof e=="string"){if(bb(RP,e)===null)throw new Di(t,e,CP);e=vP(e,8)}return _b(e,t),e}o(IP,"parseFileMode");var BP=Qe((e,t,r=_P,i=bP)=>{if(typeof e!="number")throw new xe(t,"number",e);if(!Sf(e))throw new Rr(t,"an integer",e);if(e<r||e>i)throw new Rr(t,`>= ${r} && <= ${i}`,e)}),NP=Qe((e,t,r=-2147483648,i=2147483647)=>{if(typeof e!="number")throw new xe(t,"number",e);if(!Sf(e))throw new Rr(t,"an integer",e);if(e<r||e>i)throw new Rr(t,`>= ${r} && <= ${i}`,e)}),_b=Qe((e,t,r=!1)=>{if(typeof e!="number")throw new xe(t,"number",e);if(!Sf(e))throw new Rr(t,"an integer",e);let i=r?1:0,n=4294967295;if(e<i||e>n)throw new Rr(t,`>= ${i} && <= ${n}`,e)});function Ef(e,t){if(typeof e!="string")throw new xe(t,"string",e)}o(Ef,"validateString");function $P(e,t,r=void 0,i){if(typeof e!="number")throw new xe(t,"number",e);if(r!=null&&e<r||i!=null&&e>i||(r!=null||i!=null)&&yP(e))throw new Rr(t,`${r!=null?`>= ${r}`:""}${r!=null&&i!=null?" && ":""}${i!=null?`<= ${i}`:""}`,e)}o($P,"validateNumber");var LP=Qe((e,t,r)=>{if(!gb(r,e)){let n="must be one of: "+yb(gP(r,a=>typeof a=="string"?`'${a}'`:SP(a)),", ");throw new Di(t,e,n)}});function vb(e,t){if(typeof e!="boolean")throw new xe(t,"boolean",e)}o(vb,"validateBoolean");function vf(e,t,r){return e==null||!FP(e,t)?r:e[t]}o(vf,"getOwnPropertyValueOrDefault");var MP=Qe((e,t,r=null)=>{let i=vf(r,"allowArray",!1),n=vf(r,"allowFunction",!1);if(!vf(r,"nullable",!1)&&e===null||!i&&Ff(e)||typeof e!="object"&&(!n||typeof e!="function"))throw new xe(t,"Object",e)}),jP=Qe((e,t)=>{if(e!=null&&typeof e!="object"&&typeof e!="function")throw new xe(t,"a dictionary",e)}),as=Qe((e,t,r=0)=>{if(!Ff(e))throw new xe(t,"Array",e);if(e.length<r){let i=`must be longer than ${r}`;throw new Di(t,e,i)}});function HP(e,t){as(e,t);for(let r=0;r<e.length;r++)Ef(e[r],`${t}[${r}]`)}o(HP,"validateStringArray");function qP(e,t){as(e,t);for(let r=0;r<e.length;r++)vb(e[r],`${t}[${r}]`)}o(qP,"validateBooleanArray");function UP(e,t){as(e,t);for(let r=0;r<e.length;r++){let i=e[r],n=`${t}[${r}]`;if(i==null)throw new xe(n,"AbortSignal",i);Fb(i,n)}}o(UP,"validateAbortSignalArray");function zP(e,t="signal"){if(Ef(e,t),mb[e]===void 0)throw mb[EP(e)]!==void 0?new pb(e+" (signals must use all capital letters)"):new pb(e)}o(zP,"validateSignalName");var WP=Qe((e,t="buffer")=>{if(!AP(e))throw new xe(t,["Buffer","TypedArray","DataView"],e)});function VP(e,t){let r=PP(t),i=e.length;if(r==="hex"&&i%2!==0)throw new Di("encoding",t,`is invalid for data of length ${i}`)}o(VP,"validateEncoding");function GP(e,t="Port",r=!0){if(typeof e!="number"&&typeof e!="string"||typeof e=="string"&&kP(e).length===0||+e!==+e>>>0||e>65535||e===0&&!r)throw new xP(t,e,r);return e|0}o(GP,"validatePort");var Fb=Qe((e,t)=>{if(e!==void 0&&(e===null||typeof e!="object"||!("aborted"in e)))throw new xe(t,"AbortSignal",e)}),ZP=Qe((e,t)=>{if(typeof e!="function")throw new xe(t,"Function",e)}),KP=Qe((e,t)=>{if(typeof e!="function"||TP(e))throw new xe(t,"Function",e)}),YP=Qe((e,t)=>{if(e!==void 0)throw new xe(t,"undefined",e)});function XP(e,t,r){if(!gb(r,e))throw new xe(t,`('${yb(r,"|")}')`,e)}o(XP,"validateUnion");var JP=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function wb(e,t){if(typeof e>"u"||!bb(JP,e))throw new Di(t,e,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}o(wb,"validateLinkHeaderFormat");function QP(e){if(typeof e=="string")return wb(e,"hints"),e;if(Ff(e)){let t=e.length,r="";if(t===0)return r;for(let i=0;i<t;i++){let n=e[i];wb(n,"hints"),r+=n,i!==t-1&&(r+=", ")}return r}throw new Di("hints",e,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}o(QP,"validateLinkHeaderValue");Sb.exports={isInt32:OP,isUint32:DP,parseFileMode:IP,validateArray:as,validateStringArray:HP,validateBooleanArray:qP,validateAbortSignalArray:UP,validateBoolean:vb,validateBuffer:WP,validateDictionary:jP,validateEncoding:VP,validateFunction:ZP,validateInt32:NP,validateInteger:BP,validateNumber:$P,validateObject:MP,validateOneOf:LP,validatePlainFunction:KP,validatePort:GP,validateSignalName:zP,validateString:Ef,validateUint32:_b,validateUndefined:YP,validateUnion:XP,validateAbortSignal:Fb,validateLinkHeaderValue:QP}});var kt=O((m2,Lb)=>{"use strict";var{SymbolAsyncIterator:Eb,SymbolIterator:kb,SymbolFor:Cr}=ie(),xb=Cr("nodejs.stream.destroyed"),Pb=Cr("nodejs.stream.errored"),kf=Cr("nodejs.stream.readable"),xf=Cr("nodejs.stream.writable"),Tb=Cr("nodejs.stream.disturbed"),eT=Cr("nodejs.webstream.isClosedPromise"),tT=Cr("nodejs.webstream.controllerErrorFunction");function os(e,t=!1){var r;return!!(e&&typeof e.pipe=="function"&&typeof e.on=="function"&&(!t||typeof e.pause=="function"&&typeof e.resume=="function")&&(!e._writableState||((r=e._readableState)===null||r===void 0?void 0:r.readable)!==!1)&&(!e._writableState||e._readableState))}o(os,"isReadableNodeStream");function ss(e){var t;return!!(e&&typeof e.write=="function"&&typeof e.on=="function"&&(!e._readableState||((t=e._writableState)===null||t===void 0?void 0:t.writable)!==!1))}o(ss,"isWritableNodeStream");function rT(e){return!!(e&&typeof e.pipe=="function"&&e._readableState&&typeof e.on=="function"&&typeof e.write=="function")}o(rT,"isDuplexNodeStream");function Et(e){return e&&(e._readableState||e._writableState||typeof e.write=="function"&&typeof e.on=="function"||typeof e.pipe=="function"&&typeof e.on=="function")}o(Et,"isNodeStream");function Ab(e){return!!(e&&!Et(e)&&typeof e.pipeThrough=="function"&&typeof e.getReader=="function"&&typeof e.cancel=="function")}o(Ab,"isReadableStream");function Ob(e){return!!(e&&!Et(e)&&typeof e.getWriter=="function"&&typeof e.abort=="function")}o(Ob,"isWritableStream");function Db(e){return!!(e&&!Et(e)&&typeof e.readable=="object"&&typeof e.writable=="object")}o(Db,"isTransformStream");function iT(e){return Ab(e)||Ob(e)||Db(e)}o(iT,"isWebStream");function nT(e,t){return e==null?!1:t===!0?typeof e[Eb]=="function":t===!1?typeof e[kb]=="function":typeof e[Eb]=="function"||typeof e[kb]=="function"}o(nT,"isIterable");function ls(e){if(!Et(e))return null;let t=e._writableState,r=e._readableState,i=t||r;return!!(e.destroyed||e[xb]||i!=null&&i.destroyed)}o(ls,"isDestroyed");function Rb(e){if(!ss(e))return null;if(e.writableEnded===!0)return!0;let t=e._writableState;return t!=null&&t.errored?!1:typeof t?.ended!="boolean"?null:t.ended}o(Rb,"isWritableEnded");function aT(e,t){if(!ss(e))return null;if(e.writableFinished===!0)return!0;let r=e._writableState;return r!=null&&r.errored?!1:typeof r?.finished!="boolean"?null:!!(r.finished||t===!1&&r.ended===!0&&r.length===0)}o(aT,"isWritableFinished");function oT(e){if(!os(e))return null;if(e.readableEnded===!0)return!0;let t=e._readableState;return!t||t.errored?!1:typeof t?.ended!="boolean"?null:t.ended}o(oT,"isReadableEnded");function Cb(e,t){if(!os(e))return null;let r=e._readableState;return r!=null&&r.errored?!1:typeof r?.endEmitted!="boolean"?null:!!(r.endEmitted||t===!1&&r.ended===!0&&r.length===0)}o(Cb,"isReadableFinished");function Ib(e){return e&&e[kf]!=null?e[kf]:typeof e?.readable!="boolean"?null:ls(e)?!1:os(e)&&e.readable&&!Cb(e)}o(Ib,"isReadable");function Bb(e){return e&&e[xf]!=null?e[xf]:typeof e?.writable!="boolean"?null:ls(e)?!1:ss(e)&&e.writable&&!Rb(e)}o(Bb,"isWritable");function sT(e,t){return Et(e)?ls(e)?!0:!(t?.readable!==!1&&Ib(e)||t?.writable!==!1&&Bb(e)):null}o(sT,"isFinished");function lT(e){var t,r;return Et(e)?e.writableErrored?e.writableErrored:(t=(r=e._writableState)===null||r===void 0?void 0:r.errored)!==null&&t!==void 0?t:null:null}o(lT,"isWritableErrored");function cT(e){var t,r;return Et(e)?e.readableErrored?e.readableErrored:(t=(r=e._readableState)===null||r===void 0?void 0:r.errored)!==null&&t!==void 0?t:null:null}o(cT,"isReadableErrored");function fT(e){if(!Et(e))return null;if(typeof e.closed=="boolean")return e.closed;let t=e._writableState,r=e._readableState;return typeof t?.closed=="boolean"||typeof r?.closed=="boolean"?t?.closed||r?.closed:typeof e._closed=="boolean"&&Nb(e)?e._closed:null}o(fT,"isClosed");function Nb(e){return typeof e._closed=="boolean"&&typeof e._defaultKeepAlive=="boolean"&&typeof e._removedConnection=="boolean"&&typeof e._removedContLen=="boolean"}o(Nb,"isOutgoingMessage");function $b(e){return typeof e._sent100=="boolean"&&Nb(e)}o($b,"isServerResponse");function uT(e){var t;return typeof e._consuming=="boolean"&&typeof e._dumped=="boolean"&&((t=e.req)===null||t===void 0?void 0:t.upgradeOrConnect)===void 0}o(uT,"isServerRequest");function dT(e){if(!Et(e))return null;let t=e._writableState,r=e._readableState,i=t||r;return!i&&$b(e)||!!(i&&i.autoDestroy&&i.emitClose&&i.closed===!1)}o(dT,"willEmitClose");function hT(e){var t;return!!(e&&((t=e[Tb])!==null&&t!==void 0?t:e.readableDidRead||e.readableAborted))}o(hT,"isDisturbed");function pT(e){var t,r,i,n,a,s,l,u,c,f;return!!(e&&((t=(r=(i=(n=(a=(s=e[Pb])!==null&&s!==void 0?s:e.readableErrored)!==null&&a!==void 0?a:e.writableErrored)!==null&&n!==void 0?n:(l=e._readableState)===null||l===void 0?void 0:l.errorEmitted)!==null&&i!==void 0?i:(u=e._writableState)===null||u===void 0?void 0:u.errorEmitted)!==null&&r!==void 0?r:(c=e._readableState)===null||c===void 0?void 0:c.errored)!==null&&t!==void 0?t:!((f=e._writableState)===null||f===void 0)&&f.errored))}o(pT,"isErrored");Lb.exports={isDestroyed:ls,kIsDestroyed:xb,isDisturbed:hT,kIsDisturbed:Tb,isErrored:pT,kIsErrored:Pb,isReadable:Ib,kIsReadable:kf,kIsClosedPromise:eT,kControllerErrorFunction:tT,kIsWritable:xf,isClosed:fT,isDuplexNodeStream:rT,isFinished:sT,isIterable:nT,isReadableNodeStream:os,isReadableStream:Ab,isReadableEnded:oT,isReadableFinished:Cb,isReadableErrored:cT,isNodeStream:Et,isWebStream:iT,isWritable:Bb,isWritableNodeStream:ss,isWritableStream:Ob,isWritableEnded:Rb,isWritableFinished:aT,isWritableErrored:lT,isServerRequest:uT,isServerResponse:$b,willEmitClose:dT,isTransformStream:Db}});var Lt=O((g2,Df)=>{"use strict";var lr=X("process/"),{AbortError:Gb,codes:mT}=ke(),{ERR_INVALID_ARG_TYPE:wT,ERR_STREAM_PREMATURE_CLOSE:Mb}=mT,{kEmptyObject:Tf,once:Af}=Ce(),{validateAbortSignal:gT,validateFunction:yT,validateObject:bT,validateBoolean:_T}=Ri(),{Promise:vT,PromisePrototypeThen:FT,SymbolDispose:Zb}=ie(),{isClosed:ST,isReadable:jb,isReadableNodeStream:Pf,isReadableStream:ET,isReadableFinished:Hb,isReadableErrored:qb,isWritable:Ub,isWritableNodeStream:zb,isWritableStream:kT,isWritableFinished:Wb,isWritableErrored:Vb,isNodeStream:xT,willEmitClose:PT,kIsClosedPromise:TT}=kt(),Ci;function AT(e){return e.setHeader&&typeof e.abort=="function"}o(AT,"isRequest");var Of=o(()=>{},"nop");function Kb(e,t,r){var i,n;if(arguments.length===2?(r=t,t=Tf):t==null?t=Tf:bT(t,"options"),yT(r,"callback"),gT(t.signal,"options.signal"),r=Af(r),ET(e)||kT(e))return OT(e,t,r);if(!xT(e))throw new wT("stream",["ReadableStream","WritableStream","Stream"],e);let a=(i=t.readable)!==null&&i!==void 0?i:Pf(e),s=(n=t.writable)!==null&&n!==void 0?n:zb(e),l=e._writableState,u=e._readableState,c=o(()=>{e.writable||h()},"onlegacyfinish"),f=PT(e)&&Pf(e)===a&&zb(e)===s,d=Wb(e,!1),h=o(()=>{d=!0,e.destroyed&&(f=!1),!(f&&(!e.readable||a))&&(!a||p)&&r.call(e)},"onfinish"),p=Hb(e,!1),m=o(()=>{p=!0,e.destroyed&&(f=!1),!(f&&(!e.writable||s))&&(!s||d)&&r.call(e)},"onend"),w=o(S=>{r.call(e,S)},"onerror"),y=ST(e),g=o(()=>{y=!0;let S=Vb(e)||qb(e);if(S&&typeof S!="boolean")return r.call(e,S);if(a&&!p&&Pf(e,!0)&&!Hb(e,!1))return r.call(e,new Mb);if(s&&!d&&!Wb(e,!1))return r.call(e,new Mb);r.call(e)},"onclose"),_=o(()=>{y=!0;let S=Vb(e)||qb(e);if(S&&typeof S!="boolean")return r.call(e,S);r.call(e)},"onclosed"),k=o(()=>{e.req.on("finish",h)},"onrequest");AT(e)?(e.on("complete",h),f||e.on("abort",g),e.req?k():e.on("request",k)):s&&!l&&(e.on("end",c),e.on("close",c)),!f&&typeof e.aborted=="boolean"&&e.on("aborted",g),e.on("end",m),e.on("finish",h),t.error!==!1&&e.on("error",w),e.on("close",g),y?lr.nextTick(g):l!=null&&l.errorEmitted||u!=null&&u.errorEmitted?f||lr.nextTick(_):(!a&&(!f||jb(e))&&(d||Ub(e)===!1)||!s&&(!f||Ub(e))&&(p||jb(e)===!1)||u&&e.req&&e.aborted)&&lr.nextTick(_);let F=o(()=>{r=Of,e.removeListener("aborted",g),e.removeListener("complete",h),e.removeListener("abort",g),e.removeListener("request",k),e.req&&e.req.removeListener("finish",h),e.removeListener("end",c),e.removeListener("close",c),e.removeListener("finish",h),e.removeListener("end",m),e.removeListener("error",w),e.removeListener("close",g)},"cleanup");if(t.signal&&!y){let S=o(()=>{let P=r;F(),P.call(e,new Gb(void 0,{cause:t.signal.reason}))},"abort");if(t.signal.aborted)lr.nextTick(S);else{Ci=Ci||Ce().addAbortListener;let P=Ci(t.signal,S),b=r;r=Af((...x)=>{P[Zb](),b.apply(e,x)})}}return F}o(Kb,"eos");function OT(e,t,r){let i=!1,n=Of;if(t.signal)if(n=o(()=>{i=!0,r.call(e,new Gb(void 0,{cause:t.signal.reason}))},"abort"),t.signal.aborted)lr.nextTick(n);else{Ci=Ci||Ce().addAbortListener;let s=Ci(t.signal,n),l=r;r=Af((...u)=>{s[Zb](),l.apply(e,u)})}let a=o((...s)=>{i||lr.nextTick(()=>r.apply(e,s))},"resolverFn");return FT(e[TT].promise,a,a),Of}o(OT,"eosWeb");function DT(e,t){var r;let i=!1;return t===null&&(t=Tf),(r=t)!==null&&r!==void 0&&r.cleanup&&(_T(t.cleanup,"cleanup"),i=t.cleanup),new vT((n,a)=>{let s=Kb(e,t,l=>{i&&s(),l?a(l):n()})})}o(DT,"finished");Df.exports=Kb;Df.exports.finished=DT});var Ir=O((b2,i0)=>{"use strict";var xt=X("process/"),{aggregateTwoErrors:RT,codes:{ERR_MULTIPLE_CALLBACK:CT},AbortError:IT}=ke(),{Symbol:Jb}=ie(),{kIsDestroyed:BT,isDestroyed:NT,isFinished:$T,isServerRequest:LT}=kt(),Qb=Jb("kDestroy"),Rf=Jb("kConstruct");function e0(e,t,r){e&&(e.stack,t&&!t.errored&&(t.errored=e),r&&!r.errored&&(r.errored=e))}o(e0,"checkError");function MT(e,t){let r=this._readableState,i=this._writableState,n=i||r;return i!=null&&i.destroyed||r!=null&&r.destroyed?(typeof t=="function"&&t(),this):(e0(e,i,r),i&&(i.destroyed=!0),r&&(r.destroyed=!0),n.constructed?Yb(this,e,t):this.once(Qb,function(a){Yb(this,RT(a,e),t)}),this)}o(MT,"destroy");function Yb(e,t,r){let i=!1;function n(a){if(i)return;i=!0;let s=e._readableState,l=e._writableState;e0(a,l,s),l&&(l.closed=!0),s&&(s.closed=!0),typeof r=="function"&&r(a),a?xt.nextTick(jT,e,a):xt.nextTick(t0,e)}o(n,"onDestroy");try{e._destroy(t||null,n)}catch(a){n(a)}}o(Yb,"_destroy");function jT(e,t){Cf(e,t),t0(e)}o(jT,"emitErrorCloseNT");function t0(e){let t=e._readableState,r=e._writableState;r&&(r.closeEmitted=!0),t&&(t.closeEmitted=!0),(r!=null&&r.emitClose||t!=null&&t.emitClose)&&e.emit("close")}o(t0,"emitCloseNT");function Cf(e,t){let r=e._readableState,i=e._writableState;i!=null&&i.errorEmitted||r!=null&&r.errorEmitted||(i&&(i.errorEmitted=!0),r&&(r.errorEmitted=!0),e.emit("error",t))}o(Cf,"emitErrorNT");function HT(){let e=this._readableState,t=this._writableState;e&&(e.constructed=!0,e.closed=!1,e.closeEmitted=!1,e.destroyed=!1,e.errored=null,e.errorEmitted=!1,e.reading=!1,e.ended=e.readable===!1,e.endEmitted=e.readable===!1),t&&(t.constructed=!0,t.destroyed=!1,t.closed=!1,t.closeEmitted=!1,t.errored=null,t.errorEmitted=!1,t.finalCalled=!1,t.prefinished=!1,t.ended=t.writable===!1,t.ending=t.writable===!1,t.finished=t.writable===!1)}o(HT,"undestroy");function If(e,t,r){let i=e._readableState,n=e._writableState;if(n!=null&&n.destroyed||i!=null&&i.destroyed)return this;i!=null&&i.autoDestroy||n!=null&&n.autoDestroy?e.destroy(t):t&&(t.stack,n&&!n.errored&&(n.errored=t),i&&!i.errored&&(i.errored=t),r?xt.nextTick(Cf,e,t):Cf(e,t))}o(If,"errorOrDestroy");function qT(e,t){if(typeof e._construct!="function")return;let r=e._readableState,i=e._writableState;r&&(r.constructed=!1),i&&(i.constructed=!1),e.once(Rf,t),!(e.listenerCount(Rf)>1)&&xt.nextTick(UT,e)}o(qT,"construct");function UT(e){let t=!1;function r(i){if(t){If(e,i??new CT);return}t=!0;let n=e._readableState,a=e._writableState,s=a||n;n&&(n.constructed=!0),a&&(a.constructed=!0),s.destroyed?e.emit(Qb,i):i?If(e,i,!0):xt.nextTick(zT,e)}o(r,"onConstruct");try{e._construct(i=>{xt.nextTick(r,i)})}catch(i){xt.nextTick(r,i)}}o(UT,"constructNT");function zT(e){e.emit(Rf)}o(zT,"emitConstructNT");function Xb(e){return e?.setHeader&&typeof e.abort=="function"}o(Xb,"isRequest");function r0(e){e.emit("close")}o(r0,"emitCloseLegacy");function WT(e,t){e.emit("error",t),xt.nextTick(r0,e)}o(WT,"emitErrorCloseLegacy");function VT(e,t){!e||NT(e)||(!t&&!$T(e)&&(t=new IT),LT(e)?(e.socket=null,e.destroy(t)):Xb(e)?e.abort():Xb(e.req)?e.req.abort():typeof e.destroy=="function"?e.destroy(t):typeof e.close=="function"?e.close():t?xt.nextTick(WT,e,t):xt.nextTick(r0,e),e.destroyed||(e[BT]=!0))}o(VT,"destroyer");i0.exports={construct:qT,destroyer:VT,destroy:MT,undestroy:HT,errorOrDestroy:If}});var us=O((v2,a0)=>{"use strict";var{ArrayIsArray:GT,ObjectSetPrototypeOf:n0}=ie(),{EventEmitter:cs}=X("events");function fs(e){cs.call(this,e)}o(fs,"Stream");n0(fs.prototype,cs.prototype);n0(fs,cs);fs.prototype.pipe=function(e,t){let r=this;function i(f){e.writable&&e.write(f)===!1&&r.pause&&r.pause()}o(i,"ondata"),r.on("data",i);function n(){r.readable&&r.resume&&r.resume()}o(n,"ondrain"),e.on("drain",n),!e._isStdio&&(!t||t.end!==!1)&&(r.on("end",s),r.on("close",l));let a=!1;function s(){a||(a=!0,e.end())}o(s,"onend");function l(){a||(a=!0,typeof e.destroy=="function"&&e.destroy())}o(l,"onclose");function u(f){c(),cs.listenerCount(this,"error")===0&&this.emit("error",f)}o(u,"onerror"),Bf(r,"error",u),Bf(e,"error",u);function c(){r.removeListener("data",i),e.removeListener("drain",n),r.removeListener("end",s),r.removeListener("close",l),r.removeListener("error",u),e.removeListener("error",u),r.removeListener("end",c),r.removeListener("close",c),e.removeListener("close",c)}return o(c,"cleanup"),r.on("end",c),r.on("close",c),e.on("close",c),e.emit("pipe",r),e};function Bf(e,t,r){if(typeof e.prependListener=="function")return e.prependListener(t,r);!e._events||!e._events[t]?e.on(t,r):GT(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]}o(Bf,"prependListener");a0.exports={Stream:fs,prependListener:Bf}});var Zn=O((S2,ds)=>{"use strict";var{SymbolDispose:ZT}=ie(),{AbortError:o0,codes:KT}=ke(),{isNodeStream:s0,isWebStream:YT,kControllerErrorFunction:XT}=kt(),JT=Lt(),{ERR_INVALID_ARG_TYPE:l0}=KT,Nf,QT=o((e,t)=>{if(typeof e!="object"||!("aborted"in e))throw new l0(t,"AbortSignal",e)},"validateAbortSignal");ds.exports.addAbortSignal=o(function(t,r){if(QT(t,"signal"),!s0(r)&&!YT(r))throw new l0("stream",["ReadableStream","WritableStream","Stream"],r);return ds.exports.addAbortSignalNoValidate(t,r)},"addAbortSignal");ds.exports.addAbortSignalNoValidate=function(e,t){if(typeof e!="object"||!("aborted"in e))return t;let r=s0(t)?()=>{t.destroy(new o0(void 0,{cause:e.reason}))}:()=>{t[XT](new o0(void 0,{cause:e.reason}))};if(e.aborted)r();else{Nf=Nf||Ce().addAbortListener;let i=Nf(e,r);JT(t,i[ZT])}return t}});var u0=O((k2,f0)=>{"use strict";var{StringPrototypeSlice:c0,SymbolIterator:eA,TypedArrayPrototypeSet:hs,Uint8Array:tA}=ie(),{Buffer:$f}=X("buffer"),{inspect:rA}=Ce(),Ii;f0.exports=(Ii=class{constructor(){this.head=null,this.tail=null,this.length=0}push(t){let r={data:t,next:null};this.length>0?this.tail.next=r:this.head=r,this.tail=r,++this.length}unshift(t){let r={data:t,next:this.head};this.length===0&&(this.tail=r),this.head=r,++this.length}shift(){if(this.length===0)return;let t=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,t}clear(){this.head=this.tail=null,this.length=0}join(t){if(this.length===0)return"";let r=this.head,i=""+r.data;for(;(r=r.next)!==null;)i+=t+r.data;return i}concat(t){if(this.length===0)return $f.alloc(0);let r=$f.allocUnsafe(t>>>0),i=this.head,n=0;for(;i;)hs(r,i.data,n),n+=i.data.length,i=i.next;return r}consume(t,r){let i=this.head.data;if(t<i.length){let n=i.slice(0,t);return this.head.data=i.slice(t),n}return t===i.length?this.shift():r?this._getString(t):this._getBuffer(t)}first(){return this.head.data}*[eA](){for(let t=this.head;t;t=t.next)yield t.data}_getString(t){let r="",i=this.head,n=0;do{let a=i.data;if(t>a.length)r+=a,t-=a.length;else{t===a.length?(r+=a,++n,i.next?this.head=i.next:this.head=this.tail=null):(r+=c0(a,0,t),this.head=i,i.data=c0(a,t));break}++n}while((i=i.next)!==null);return this.length-=n,r}_getBuffer(t){let r=$f.allocUnsafe(t),i=t,n=this.head,a=0;do{let s=n.data;if(t>s.length)hs(r,s,i-t),t-=s.length;else{t===s.length?(hs(r,s,i-t),++a,n.next?this.head=n.next:this.head=this.tail=null):(hs(r,new tA(s.buffer,s.byteOffset,t),i-t),this.head=n,n.data=s.slice(t));break}++a}while((n=n.next)!==null);return this.length-=a,r}[Symbol.for("nodejs.util.inspect.custom")](t,r){return rA(this,{...r,depth:0,customInspect:!1})}},o(Ii,"BufferList"),Ii)});var Kn=O((P2,m0)=>{"use strict";var{MathFloor:iA,NumberIsInteger:nA}=ie(),{validateInteger:aA}=Ri(),{ERR_INVALID_ARG_VALUE:oA}=ke().codes,d0=16*1024,h0=16;function sA(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}o(sA,"highWaterMarkFrom");function p0(e){return e?h0:d0}o(p0,"getDefaultHighWaterMark");function lA(e,t){aA(t,"value",0),e?h0=t:d0=t}o(lA,"setDefaultHighWaterMark");function cA(e,t,r,i){let n=sA(t,i,r);if(n!=null){if(!nA(n)||n<0){let a=i?`options.${r}`:"options.highWaterMark";throw new oA(a,n)}return iA(n)}return p0(e.objectMode)}o(cA,"getHighWaterMark");m0.exports={getHighWaterMark:cA,getDefaultHighWaterMark:p0,setDefaultHighWaterMark:lA}});var y0=O(g0=>{"use strict";var Mf=Zi().Buffer,w0=Mf.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function fA(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}o(fA,"_normalizeEncoding");function uA(e){var t=fA(e);if(typeof t!="string"&&(Mf.isEncoding===w0||!w0(e)))throw new Error("Unknown encoding: "+e);return t||e}o(uA,"normalizeEncoding");g0.StringDecoder=Yn;function Yn(e){this.encoding=uA(e);var t;switch(this.encoding){case"utf16le":this.text=gA,this.end=yA,t=4;break;case"utf8":this.fillLast=pA,t=4;break;case"base64":this.text=bA,this.end=_A,t=3;break;default:this.write=vA,this.end=FA;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Mf.allocUnsafe(t)}o(Yn,"StringDecoder");Yn.prototype.write=function(e){if(e.length===0)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""};Yn.prototype.end=wA;Yn.prototype.text=mA;Yn.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function Lf(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}o(Lf,"utf8CheckByte");function dA(e,t,r){var i=t.length-1;if(i<r)return 0;var n=Lf(t[i]);return n>=0?(n>0&&(e.lastNeed=n-1),n):--i<r||n===-2?0:(n=Lf(t[i]),n>=0?(n>0&&(e.lastNeed=n-2),n):--i<r||n===-2?0:(n=Lf(t[i]),n>=0?(n>0&&(n===2?n=0:e.lastNeed=n-3),n):0))}o(dA,"utf8CheckIncomplete");function hA(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"\uFFFD";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"\uFFFD";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"\uFFFD"}}o(hA,"utf8CheckExtraBytes");function pA(e){var t=this.lastTotal-this.lastNeed,r=hA(this,e,t);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}o(pA,"utf8FillLast");function mA(e,t){var r=dA(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var i=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)}o(mA,"utf8Text");function wA(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t}o(wA,"utf8End");function gA(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}o(gA,"utf16Text");function yA(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}o(yA,"utf16End");function bA(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}o(bA,"base64Text");function _A(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}o(_A,"base64End");function vA(e){return e.toString(this.encoding)}o(vA,"simpleWrite");function FA(e){return e&&e.length?this.write(e):""}o(FA,"simpleEnd")});var jf=O((D2,F0)=>{"use strict";var b0=X("process/"),{PromisePrototypeThen:SA,SymbolAsyncIterator:_0,SymbolIterator:v0}=ie(),{Buffer:EA}=X("buffer"),{ERR_INVALID_ARG_TYPE:kA,ERR_STREAM_NULL_VALUES:xA}=ke().codes;function PA(e,t,r){let i;if(typeof t=="string"||t instanceof EA)return new e({objectMode:!0,...r,read(){this.push(t),this.push(null)}});let n;if(t&&t[_0])n=!0,i=t[_0]();else if(t&&t[v0])n=!1,i=t[v0]();else throw new kA("iterable",["Iterable"],t);let a=new e({objectMode:!0,highWaterMark:1,...r}),s=!1;a._read=function(){s||(s=!0,u())},a._destroy=function(c,f){SA(l(c),()=>b0.nextTick(f,c),d=>b0.nextTick(f,d||c))};async function l(c){let f=c!=null,d=typeof i.throw=="function";if(f&&d){let{value:h,done:p}=await i.throw(c);if(await h,p)return}if(typeof i.return=="function"){let{value:h}=await i.return();await h}}o(l,"close");async function u(){for(;;){try{let{value:c,done:f}=n?await i.next():i.next();if(f)a.push(null);else{let d=c&&typeof c.then=="function"?await c:c;if(d===null)throw s=!1,new xA;if(a.push(d))continue;s=!1}}catch(c){a.destroy(c)}break}}return o(u,"next"),a}o(PA,"from");F0.exports=PA});var Jn=O((C2,j0)=>{"use strict";var ft=X("process/"),{ArrayPrototypeIndexOf:TA,NumberIsInteger:AA,NumberIsNaN:OA,NumberParseInt:DA,ObjectDefineProperties:Zf,ObjectKeys:RA,ObjectSetPrototypeOf:k0,Promise:x0,SafeSet:CA,SymbolAsyncDispose:IA,SymbolAsyncIterator:BA,Symbol:NA}=ie();j0.exports=j;j.ReadableState=gs;var{EventEmitter:$A}=X("events"),{Stream:cr,prependListener:LA}=us(),{Buffer:Hf}=X("buffer"),{addAbortSignal:MA}=Zn(),P0=Lt(),U=Ce().debuglog("stream",e=>{U=e}),jA=u0(),$i=Ir(),{getHighWaterMark:HA,getDefaultHighWaterMark:qA}=Kn(),{aggregateTwoErrors:S0,codes:{ERR_INVALID_ARG_TYPE:UA,ERR_METHOD_NOT_IMPLEMENTED:zA,ERR_OUT_OF_RANGE:WA,ERR_STREAM_PUSH_AFTER_EOF:VA,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:GA},AbortError:ZA}=ke(),{validateObject:KA}=Ri(),Br=NA("kPaused"),{StringDecoder:T0}=y0(),YA=jf();k0(j.prototype,cr.prototype);k0(j,cr);var qf=o(()=>{},"nop"),{errorOrDestroy:Bi}=$i,Ni=1,XA=2,A0=4,Xn=8,O0=16,ps=32,ms=64,D0=128,JA=256,QA=512,eO=1024,Vf=2048,Gf=4096,tO=8192,rO=16384,iO=32768,R0=65536,nO=1<<17,aO=1<<18;function ge(e){return{enumerable:!1,get(){return(this.state&e)!==0},set(t){t?this.state|=e:this.state&=~e}}}o(ge,"makeBitMapDescriptor");Zf(gs.prototype,{objectMode:ge(Ni),ended:ge(XA),endEmitted:ge(A0),reading:ge(Xn),constructed:ge(O0),sync:ge(ps),needReadable:ge(ms),emittedReadable:ge(D0),readableListening:ge(JA),resumeScheduled:ge(QA),errorEmitted:ge(eO),emitClose:ge(Vf),autoDestroy:ge(Gf),destroyed:ge(tO),closed:ge(rO),closeEmitted:ge(iO),multiAwaitDrain:ge(R0),readingMore:ge(nO),dataEmitted:ge(aO)});function gs(e,t,r){typeof r!="boolean"&&(r=t instanceof Pt()),this.state=Vf|Gf|O0|ps,e&&e.objectMode&&(this.state|=Ni),r&&e&&e.readableObjectMode&&(this.state|=Ni),this.highWaterMark=e?HA(this,e,"readableHighWaterMark",r):qA(!1),this.buffer=new jA,this.length=0,this.pipes=[],this.flowing=null,this[Br]=null,e&&e.emitClose===!1&&(this.state&=~Vf),e&&e.autoDestroy===!1&&(this.state&=~Gf),this.errored=null,this.defaultEncoding=e&&e.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.decoder=null,this.encoding=null,e&&e.encoding&&(this.decoder=new T0(e.encoding),this.encoding=e.encoding)}o(gs,"ReadableState");function j(e){if(!(this instanceof j))return new j(e);let t=this instanceof Pt();this._readableState=new gs(e,this,t),e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.construct=="function"&&(this._construct=e.construct),e.signal&&!t&&MA(e.signal,this)),cr.call(this,e),$i.construct(this,()=>{this._readableState.needReadable&&ws(this,this._readableState)})}o(j,"Readable");j.prototype.destroy=$i.destroy;j.prototype._undestroy=$i.undestroy;j.prototype._destroy=function(e,t){t(e)};j.prototype[$A.captureRejectionSymbol]=function(e){this.destroy(e)};j.prototype[IA]=function(){let e;return this.destroyed||(e=this.readableEnded?null:new ZA,this.destroy(e)),new x0((t,r)=>P0(this,i=>i&&i!==e?r(i):t(null)))};j.prototype.push=function(e,t){return C0(this,e,t,!1)};j.prototype.unshift=function(e,t){return C0(this,e,t,!0)};function C0(e,t,r,i){U("readableAddChunk",t);let n=e._readableState,a;if(n.state&Ni||(typeof t=="string"?(r=r||n.defaultEncoding,n.encoding!==r&&(i&&n.encoding?t=Hf.from(t,r).toString(n.encoding):(t=Hf.from(t,r),r=""))):t instanceof Hf?r="":cr._isUint8Array(t)?(t=cr._uint8ArrayToBuffer(t),r=""):t!=null&&(a=new UA("chunk",["string","Buffer","Uint8Array"],t))),a)Bi(e,a);else if(t===null)n.state&=~Xn,lO(e,n);else if(n.state&Ni||t&&t.length>0)if(i)if(n.state&A0)Bi(e,new GA);else{if(n.destroyed||n.errored)return!1;Uf(e,n,t,!0)}else if(n.ended)Bi(e,new VA);else{if(n.destroyed||n.errored)return!1;n.state&=~Xn,n.decoder&&!r?(t=n.decoder.write(t),n.objectMode||t.length!==0?Uf(e,n,t,!1):ws(e,n)):Uf(e,n,t,!1)}else i||(n.state&=~Xn,ws(e,n));return!n.ended&&(n.length<n.highWaterMark||n.length===0)}o(C0,"readableAddChunk");function Uf(e,t,r,i){t.flowing&&t.length===0&&!t.sync&&e.listenerCount("data")>0?(t.state&R0?t.awaitDrainWriters.clear():t.awaitDrainWriters=null,t.dataEmitted=!0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.state&ms&&ys(e)),ws(e,t)}o(Uf,"addChunk");j.prototype.isPaused=function(){let e=this._readableState;return e[Br]===!0||e.flowing===!1};j.prototype.setEncoding=function(e){let t=new T0(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;let r=this._readableState.buffer,i="";for(let n of r)i+=t.write(n);return r.clear(),i!==""&&r.push(i),this._readableState.length=i.length,this};var oO=1073741824;function sO(e){if(e>oO)throw new WA("size","<= 1GiB",e);return e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++,e}o(sO,"computeNewHighWaterMark");function E0(e,t){return e<=0||t.length===0&&t.ended?0:t.state&Ni?1:OA(e)?t.flowing&&t.length?t.buffer.first().length:t.length:e<=t.length?e:t.ended?t.length:0}o(E0,"howMuchToRead");j.prototype.read=function(e){U("read",e),e===void 0?e=NaN:AA(e)||(e=DA(e,10));let t=this._readableState,r=e;if(e>t.highWaterMark&&(t.highWaterMark=sO(e)),e!==0&&(t.state&=~D0),e===0&&t.needReadable&&((t.highWaterMark!==0?t.length>=t.highWaterMark:t.length>0)||t.ended))return U("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?zf(this):ys(this),null;if(e=E0(e,t),e===0&&t.ended)return t.length===0&&zf(this),null;let i=(t.state&ms)!==0;if(U("need readable",i),(t.length===0||t.length-e<t.highWaterMark)&&(i=!0,U("length less than watermark",i)),t.ended||t.reading||t.destroyed||t.errored||!t.constructed)i=!1,U("reading, ended or constructing",i);else if(i){U("do read"),t.state|=Xn|ps,t.length===0&&(t.state|=ms);try{this._read(t.highWaterMark)}catch(a){Bi(this,a)}t.state&=~ps,t.reading||(e=E0(r,t))}let n;return e>0?n=L0(e,t):n=null,n===null?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.multiAwaitDrain?t.awaitDrainWriters.clear():t.awaitDrainWriters=null),t.length===0&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&zf(this)),n!==null&&!t.errorEmitted&&!t.closeEmitted&&(t.dataEmitted=!0,this.emit("data",n)),n};function lO(e,t){if(U("onEofChunk"),!t.ended){if(t.decoder){let r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?ys(e):(t.needReadable=!1,t.emittedReadable=!0,I0(e))}}o(lO,"onEofChunk");function ys(e){let t=e._readableState;U("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(U("emitReadable",t.flowing),t.emittedReadable=!0,ft.nextTick(I0,e))}o(ys,"emitReadable");function I0(e){let t=e._readableState;U("emitReadable_",t.destroyed,t.length,t.ended),!t.destroyed&&!t.errored&&(t.length||t.ended)&&(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,N0(e)}o(I0,"emitReadable_");function ws(e,t){!t.readingMore&&t.constructed&&(t.readingMore=!0,ft.nextTick(cO,e,t))}o(ws,"maybeReadMore");function cO(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){let r=t.length;if(U("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}o(cO,"maybeReadMore_");j.prototype._read=function(e){throw new zA("_read()")};j.prototype.pipe=function(e,t){let r=this,i=this._readableState;i.pipes.length===1&&(i.multiAwaitDrain||(i.multiAwaitDrain=!0,i.awaitDrainWriters=new CA(i.awaitDrainWriters?[i.awaitDrainWriters]:[]))),i.pipes.push(e),U("pipe count=%d opts=%j",i.pipes.length,t);let a=(!t||t.end!==!1)&&e!==ft.stdout&&e!==ft.stderr?l:y;i.endEmitted?ft.nextTick(a):r.once("end",a),e.on("unpipe",s);function s(g,_){U("onunpipe"),g===r&&_&&_.hasUnpiped===!1&&(_.hasUnpiped=!0,f())}o(s,"onunpipe");function l(){U("onend"),e.end()}o(l,"onend");let u,c=!1;function f(){U("cleanup"),e.removeListener("close",m),e.removeListener("finish",w),u&&e.removeListener("drain",u),e.removeListener("error",p),e.removeListener("unpipe",s),r.removeListener("end",l),r.removeListener("end",y),r.removeListener("data",h),c=!0,u&&i.awaitDrainWriters&&(!e._writableState||e._writableState.needDrain)&&u()}o(f,"cleanup");function d(){c||(i.pipes.length===1&&i.pipes[0]===e?(U("false write response, pause",0),i.awaitDrainWriters=e,i.multiAwaitDrain=!1):i.pipes.length>1&&i.pipes.includes(e)&&(U("false write response, pause",i.awaitDrainWriters.size),i.awaitDrainWriters.add(e)),r.pause()),u||(u=fO(r,e),e.on("drain",u))}o(d,"pause"),r.on("data",h);function h(g){U("ondata");let _=e.write(g);U("dest.write",_),_===!1&&d()}o(h,"ondata");function p(g){if(U("onerror",g),y(),e.removeListener("error",p),e.listenerCount("error")===0){let _=e._writableState||e._readableState;_&&!_.errorEmitted?Bi(e,g):e.emit("error",g)}}o(p,"onerror"),LA(e,"error",p);function m(){e.removeListener("finish",w),y()}o(m,"onclose"),e.once("close",m);function w(){U("onfinish"),e.removeListener("close",m),y()}o(w,"onfinish"),e.once("finish",w);function y(){U("unpipe"),r.unpipe(e)}return o(y,"unpipe"),e.emit("pipe",r),e.writableNeedDrain===!0?d():i.flowing||(U("pipe resume"),r.resume()),e};function fO(e,t){return o(function(){let i=e._readableState;i.awaitDrainWriters===t?(U("pipeOnDrain",1),i.awaitDrainWriters=null):i.multiAwaitDrain&&(U("pipeOnDrain",i.awaitDrainWriters.size),i.awaitDrainWriters.delete(t)),(!i.awaitDrainWriters||i.awaitDrainWriters.size===0)&&e.listenerCount("data")&&e.resume()},"pipeOnDrainFunctionResult")}o(fO,"pipeOnDrain");j.prototype.unpipe=function(e){let t=this._readableState,r={hasUnpiped:!1};if(t.pipes.length===0)return this;if(!e){let n=t.pipes;t.pipes=[],this.pause();for(let a=0;a<n.length;a++)n[a].emit("unpipe",this,{hasUnpiped:!1});return this}let i=TA(t.pipes,e);return i===-1?this:(t.pipes.splice(i,1),t.pipes.length===0&&this.pause(),e.emit("unpipe",this,r),this)};j.prototype.on=function(e,t){let r=cr.prototype.on.call(this,e,t),i=this._readableState;return e==="data"?(i.readableListening=this.listenerCount("readable")>0,i.flowing!==!1&&this.resume()):e==="readable"&&!i.endEmitted&&!i.readableListening&&(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,U("on readable",i.length,i.reading),i.length?ys(this):i.reading||ft.nextTick(uO,this)),r};j.prototype.addListener=j.prototype.on;j.prototype.removeListener=function(e,t){let r=cr.prototype.removeListener.call(this,e,t);return e==="readable"&&ft.nextTick(B0,this),r};j.prototype.off=j.prototype.removeListener;j.prototype.removeAllListeners=function(e){let t=cr.prototype.removeAllListeners.apply(this,arguments);return(e==="readable"||e===void 0)&&ft.nextTick(B0,this),t};function B0(e){let t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&t[Br]===!1?t.flowing=!0:e.listenerCount("data")>0?e.resume():t.readableListening||(t.flowing=null)}o(B0,"updateReadableListening");function uO(e){U("readable nexttick read 0"),e.read(0)}o(uO,"nReadingNextTick");j.prototype.resume=function(){let e=this._readableState;return e.flowing||(U("resume"),e.flowing=!e.readableListening,dO(this,e)),e[Br]=!1,this};function dO(e,t){t.resumeScheduled||(t.resumeScheduled=!0,ft.nextTick(hO,e,t))}o(dO,"resume");function hO(e,t){U("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),N0(e),t.flowing&&!t.reading&&e.read(0)}o(hO,"resume_");j.prototype.pause=function(){return U("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(U("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[Br]=!0,this};function N0(e){let t=e._readableState;for(U("flow",t.flowing);t.flowing&&e.read()!==null;);}o(N0,"flow");j.prototype.wrap=function(e){let t=!1;e.on("data",i=>{!this.push(i)&&e.pause&&(t=!0,e.pause())}),e.on("end",()=>{this.push(null)}),e.on("error",i=>{Bi(this,i)}),e.on("close",()=>{this.destroy()}),e.on("destroy",()=>{this.destroy()}),this._read=()=>{t&&e.resume&&(t=!1,e.resume())};let r=RA(e);for(let i=1;i<r.length;i++){let n=r[i];this[n]===void 0&&typeof e[n]=="function"&&(this[n]=e[n].bind(e))}return this};j.prototype[BA]=function(){return $0(this)};j.prototype.iterator=function(e){return e!==void 0&&KA(e,"options"),$0(this,e)};function $0(e,t){typeof e.read!="function"&&(e=j.wrap(e,{objectMode:!0}));let r=pO(e,t);return r.stream=e,r}o($0,"streamToAsyncIterator");async function*pO(e,t){let r=qf;function i(s){this===e?(r(),r=qf):r=s}o(i,"next"),e.on("readable",i);let n,a=P0(e,{writable:!1},s=>{n=s?S0(n,s):null,r(),r=qf});try{for(;;){let s=e.destroyed?null:e.read();if(s!==null)yield s;else{if(n)throw n;if(n===null)return;await new x0(i)}}}catch(s){throw n=S0(n,s),n}finally{(n||t?.destroyOnReturn!==!1)&&(n===void 0||e._readableState.autoDestroy)?$i.destroyer(e,null):(e.off("readable",i),a())}}o(pO,"createAsyncIterator");Zf(j.prototype,{readable:{__proto__:null,get(){let e=this._readableState;return!!e&&e.readable!==!1&&!e.destroyed&&!e.errorEmitted&&!e.endEmitted},set(e){this._readableState&&(this._readableState.readable=!!e)}},readableDidRead:{__proto__:null,enumerable:!1,get:o(function(){return this._readableState.dataEmitted},"get")},readableAborted:{__proto__:null,enumerable:!1,get:o(function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)},"get")},readableHighWaterMark:{__proto__:null,enumerable:!1,get:o(function(){return this._readableState.highWaterMark},"get")},readableBuffer:{__proto__:null,enumerable:!1,get:o(function(){return this._readableState&&this._readableState.buffer},"get")},readableFlowing:{__proto__:null,enumerable:!1,get:o(function(){return this._readableState.flowing},"get"),set:o(function(e){this._readableState&&(this._readableState.flowing=e)},"set")},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.objectMode:!1}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return this._readableState?this._readableState.closed:!1}},destroyed:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.destroyed:!1},set(e){this._readableState&&(this._readableState.destroyed=e)}},readableEnded:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}});Zf(gs.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[Br]!==!1},set(e){this[Br]=!!e}}});j._fromList=L0;function L0(e,t){if(t.length===0)return null;let r;return t.objectMode?r=t.buffer.shift():!e||e>=t.length?(t.decoder?r=t.buffer.join(""):t.buffer.length===1?r=t.buffer.first():r=t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r}o(L0,"fromList");function zf(e){let t=e._readableState;U("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,ft.nextTick(mO,t,e))}o(zf,"endReadable");function mO(e,t){if(U("endReadableNT",e.endEmitted,e.length),!e.errored&&!e.closeEmitted&&!e.endEmitted&&e.length===0){if(e.endEmitted=!0,t.emit("end"),t.writable&&t.allowHalfOpen===!1)ft.nextTick(wO,t);else if(e.autoDestroy){let r=t._writableState;(!r||r.autoDestroy&&(r.finished||r.writable===!1))&&t.destroy()}}}o(mO,"endReadableNT");function wO(e){e.writable&&!e.writableEnded&&!e.destroyed&&e.end()}o(wO,"endWritableNT");j.from=function(e,t){return YA(j,e,t)};var Wf;function M0(){return Wf===void 0&&(Wf={}),Wf}o(M0,"lazyWebStreams");j.fromWeb=function(e,t){return M0().newStreamReadableFromReadableStream(e,t)};j.toWeb=function(e,t){return M0().newReadableStreamFromStreamReadable(e,t)};j.wrap=function(e,t){var r,i;return new j({objectMode:(r=(i=e.readableObjectMode)!==null&&i!==void 0?i:e.objectMode)!==null&&r!==void 0?r:!0,...t,destroy(n,a){$i.destroyer(e,n),a(n)}}).wrap(e)}});var Ss=O((B2,J0)=>{"use strict";var Nr=X("process/"),{ArrayPrototypeSlice:U0,Error:gO,FunctionPrototypeSymbolHasInstance:z0,ObjectDefineProperty:W0,ObjectDefineProperties:yO,ObjectSetPrototypeOf:V0,StringPrototypeToLowerCase:bO,Symbol:_O,SymbolHasInstance:vO}=ie();J0.exports=oe;oe.WritableState=ta;var{EventEmitter:FO}=X("events"),Qn=us().Stream,{Buffer:bs}=X("buffer"),Fs=Ir(),{addAbortSignal:SO}=Zn(),{getHighWaterMark:EO,getDefaultHighWaterMark:kO}=Kn(),{ERR_INVALID_ARG_TYPE:xO,ERR_METHOD_NOT_IMPLEMENTED:PO,ERR_MULTIPLE_CALLBACK:G0,ERR_STREAM_CANNOT_PIPE:TO,ERR_STREAM_DESTROYED:ea,ERR_STREAM_ALREADY_FINISHED:AO,ERR_STREAM_NULL_VALUES:OO,ERR_STREAM_WRITE_AFTER_END:DO,ERR_UNKNOWN_ENCODING:Z0}=ke().codes,{errorOrDestroy:Li}=Fs;V0(oe.prototype,Qn.prototype);V0(oe,Qn);function Xf(){}o(Xf,"nop");var Mi=_O("kOnFinished");function ta(e,t,r){typeof r!="boolean"&&(r=t instanceof Pt()),this.objectMode=!!(e&&e.objectMode),r&&(this.objectMode=this.objectMode||!!(e&&e.writableObjectMode)),this.highWaterMark=e?EO(this,e,"writableHighWaterMark",r):kO(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;let i=!!(e&&e.decodeStrings===!1);this.decodeStrings=!i,this.defaultEncoding=e&&e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=CO.bind(void 0,t),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,vs(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!e||e.emitClose!==!1,this.autoDestroy=!e||e.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[Mi]=[]}o(ta,"WritableState");function vs(e){e.buffered=[],e.bufferedIndex=0,e.allBuffers=!0,e.allNoop=!0}o(vs,"resetBuffer");ta.prototype.getBuffer=o(function(){return U0(this.buffered,this.bufferedIndex)},"getBuffer");W0(ta.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function oe(e){let t=this instanceof Pt();if(!t&&!z0(oe,this))return new oe(e);this._writableState=new ta(e,this,t),e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final),typeof e.construct=="function"&&(this._construct=e.construct),e.signal&&SO(e.signal,this)),Qn.call(this,e),Fs.construct(this,()=>{let r=this._writableState;r.writing||Qf(this,r),eu(this,r)})}o(oe,"Writable");W0(oe,vO,{__proto__:null,value:o(function(e){return z0(this,e)?!0:this!==oe?!1:e&&e._writableState instanceof ta},"value")});oe.prototype.pipe=function(){Li(this,new TO)};function K0(e,t,r,i){let n=e._writableState;if(typeof r=="function")i=r,r=n.defaultEncoding;else{if(!r)r=n.defaultEncoding;else if(r!=="buffer"&&!bs.isEncoding(r))throw new Z0(r);typeof i!="function"&&(i=Xf)}if(t===null)throw new OO;if(!n.objectMode)if(typeof t=="string")n.decodeStrings!==!1&&(t=bs.from(t,r),r="buffer");else if(t instanceof bs)r="buffer";else if(Qn._isUint8Array(t))t=Qn._uint8ArrayToBuffer(t),r="buffer";else throw new xO("chunk",["string","Buffer","Uint8Array"],t);let a;return n.ending?a=new DO:n.destroyed&&(a=new ea("write")),a?(Nr.nextTick(i,a),Li(e,a,!0),a):(n.pendingcb++,RO(e,n,t,r,i))}o(K0,"_write");oe.prototype.write=function(e,t,r){return K0(this,e,t,r)===!0};oe.prototype.cork=function(){this._writableState.corked++};oe.prototype.uncork=function(){let e=this._writableState;e.corked&&(e.corked--,e.writing||Qf(this,e))};oe.prototype.setDefaultEncoding=o(function(t){if(typeof t=="string"&&(t=bO(t)),!bs.isEncoding(t))throw new Z0(t);return this._writableState.defaultEncoding=t,this},"setDefaultEncoding");function RO(e,t,r,i,n){let a=t.objectMode?1:r.length;t.length+=a;let s=t.length<t.highWaterMark;return s||(t.needDrain=!0),t.writing||t.corked||t.errored||!t.constructed?(t.buffered.push({chunk:r,encoding:i,callback:n}),t.allBuffers&&i!=="buffer"&&(t.allBuffers=!1),t.allNoop&&n!==Xf&&(t.allNoop=!1)):(t.writelen=a,t.writecb=n,t.writing=!0,t.sync=!0,e._write(r,i,t.onwrite),t.sync=!1),s&&!t.errored&&!t.destroyed}o(RO,"writeOrBuffer");function H0(e,t,r,i,n,a,s){t.writelen=i,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new ea("write")):r?e._writev(n,t.onwrite):e._write(n,a,t.onwrite),t.sync=!1}o(H0,"doWrite");function q0(e,t,r,i){--t.pendingcb,i(r),Jf(t),Li(e,r)}o(q0,"onwriteError");function CO(e,t){let r=e._writableState,i=r.sync,n=r.writecb;if(typeof n!="function"){Li(e,new G0);return}r.writing=!1,r.writecb=null,r.length-=r.writelen,r.writelen=0,t?(t.stack,r.errored||(r.errored=t),e._readableState&&!e._readableState.errored&&(e._readableState.errored=t),i?Nr.nextTick(q0,e,r,t,n):q0(e,r,t,n)):(r.buffered.length>r.bufferedIndex&&Qf(e,r),i?r.afterWriteTickInfo!==null&&r.afterWriteTickInfo.cb===n?r.afterWriteTickInfo.count++:(r.afterWriteTickInfo={count:1,cb:n,stream:e,state:r},Nr.nextTick(IO,r.afterWriteTickInfo)):Y0(e,r,1,n))}o(CO,"onwrite");function IO({stream:e,state:t,count:r,cb:i}){return t.afterWriteTickInfo=null,Y0(e,t,r,i)}o(IO,"afterWriteTick");function Y0(e,t,r,i){for(!t.ending&&!e.destroyed&&t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"));r-- >0;)t.pendingcb--,i();t.destroyed&&Jf(t),eu(e,t)}o(Y0,"afterWrite");function Jf(e){if(e.writing)return;for(let n=e.bufferedIndex;n<e.buffered.length;++n){var t;let{chunk:a,callback:s}=e.buffered[n],l=e.objectMode?1:a.length;e.length-=l,s((t=e.errored)!==null&&t!==void 0?t:new ea("write"))}let r=e[Mi].splice(0);for(let n=0;n<r.length;n++){var i;r[n]((i=e.errored)!==null&&i!==void 0?i:new ea("end"))}vs(e)}o(Jf,"errorBuffer");function Qf(e,t){if(t.corked||t.bufferProcessing||t.destroyed||!t.constructed)return;let{buffered:r,bufferedIndex:i,objectMode:n}=t,a=r.length-i;if(!a)return;let s=i;if(t.bufferProcessing=!0,a>1&&e._writev){t.pendingcb-=a-1;let l=t.allNoop?Xf:c=>{for(let f=s;f<r.length;++f)r[f].callback(c)},u=t.allNoop&&s===0?r:U0(r,s);u.allBuffers=t.allBuffers,H0(e,t,!0,t.length,u,"",l),vs(t)}else{do{let{chunk:l,encoding:u,callback:c}=r[s];r[s++]=null;let f=n?1:l.length;H0(e,t,!1,f,l,u,c)}while(s<r.length&&!t.writing);s===r.length?vs(t):s>256?(r.splice(0,s),t.bufferedIndex=0):t.bufferedIndex=s}t.bufferProcessing=!1}o(Qf,"clearBuffer");oe.prototype._write=function(e,t,r){if(this._writev)this._writev([{chunk:e,encoding:t}],r);else throw new PO("_write()")};oe.prototype._writev=null;oe.prototype.end=function(e,t,r){let i=this._writableState;typeof e=="function"?(r=e,e=null,t=null):typeof t=="function"&&(r=t,t=null);let n;if(e!=null){let a=K0(this,e,t);a instanceof gO&&(n=a)}return i.corked&&(i.corked=1,this.uncork()),n||(!i.errored&&!i.ending?(i.ending=!0,eu(this,i,!0),i.ended=!0):i.finished?n=new AO("end"):i.destroyed&&(n=new ea("end"))),typeof r=="function"&&(n||i.finished?Nr.nextTick(r,n):i[Mi].push(r)),this};function _s(e){return e.ending&&!e.destroyed&&e.constructed&&e.length===0&&!e.errored&&e.buffered.length===0&&!e.finished&&!e.writing&&!e.errorEmitted&&!e.closeEmitted}o(_s,"needFinish");function BO(e,t){let r=!1;function i(n){if(r){Li(e,n??G0());return}if(r=!0,t.pendingcb--,n){let a=t[Mi].splice(0);for(let s=0;s<a.length;s++)a[s](n);Li(e,n,t.sync)}else _s(t)&&(t.prefinished=!0,e.emit("prefinish"),t.pendingcb++,Nr.nextTick(Yf,e,t))}o(i,"onFinish"),t.sync=!0,t.pendingcb++;try{e._final(i)}catch(n){i(n)}t.sync=!1}o(BO,"callFinal");function NO(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"&&!t.destroyed?(t.finalCalled=!0,BO(e,t)):(t.prefinished=!0,e.emit("prefinish")))}o(NO,"prefinish");function eu(e,t,r){_s(t)&&(NO(e,t),t.pendingcb===0&&(r?(t.pendingcb++,Nr.nextTick((i,n)=>{_s(n)?Yf(i,n):n.pendingcb--},e,t)):_s(t)&&(t.pendingcb++,Yf(e,t))))}o(eu,"finishMaybe");function Yf(e,t){t.pendingcb--,t.finished=!0;let r=t[Mi].splice(0);for(let i=0;i<r.length;i++)r[i]();if(e.emit("finish"),t.autoDestroy){let i=e._readableState;(!i||i.autoDestroy&&(i.endEmitted||i.readable===!1))&&e.destroy()}}o(Yf,"finish");yO(oe.prototype,{closed:{__proto__:null,get(){return this._writableState?this._writableState.closed:!1}},destroyed:{__proto__:null,get(){return this._writableState?this._writableState.destroyed:!1},set(e){this._writableState&&(this._writableState.destroyed=e)}},writable:{__proto__:null,get(){let e=this._writableState;return!!e&&e.writable!==!1&&!e.destroyed&&!e.errored&&!e.ending&&!e.ended},set(e){this._writableState&&(this._writableState.writable=!!e)}},writableFinished:{__proto__:null,get(){return this._writableState?this._writableState.finished:!1}},writableObjectMode:{__proto__:null,get(){return this._writableState?this._writableState.objectMode:!1}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return this._writableState?this._writableState.ending:!1}},writableNeedDrain:{__proto__:null,get(){let e=this._writableState;return e?!e.destroyed&&!e.ending&&e.needDrain:!1}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:o(function(){return!!(this._writableState.writable!==!1&&(this._writableState.destroyed||this._writableState.errored)&&!this._writableState.finished)},"get")}});var $O=Fs.destroy;oe.prototype.destroy=function(e,t){let r=this._writableState;return!r.destroyed&&(r.bufferedIndex<r.buffered.length||r[Mi].length)&&Nr.nextTick(Jf,r),$O.call(this,e,t),this};oe.prototype._undestroy=Fs.undestroy;oe.prototype._destroy=function(e,t){t(e)};oe.prototype[FO.captureRejectionSymbol]=function(e){this.destroy(e)};var Kf;function X0(){return Kf===void 0&&(Kf={}),Kf}o(X0,"lazyWebStreams");oe.fromWeb=function(e,t){return X0().newStreamWritableFromWritableStream(e,t)};oe.toWeb=function(e){return X0().newWritableStreamFromStreamWritable(e)}});var h_=O(($2,d_)=>{var tu=X("process/"),LO=X("buffer"),{isReadable:MO,isWritable:jO,isIterable:Q0,isNodeStream:HO,isReadableNodeStream:e_,isWritableNodeStream:t_,isDuplexNodeStream:qO,isReadableStream:r_,isWritableStream:i_}=kt(),n_=Lt(),{AbortError:f_,codes:{ERR_INVALID_ARG_TYPE:UO,ERR_INVALID_RETURN_VALUE:a_}}=ke(),{destroyer:Hi}=Ir(),zO=Pt(),u_=Jn(),WO=Ss(),{createDeferredPromise:o_}=Ce(),s_=jf(),l_=globalThis.Blob||LO.Blob,VO=o(typeof l_<"u"?function(t){return t instanceof l_}:function(t){return!1},"isBlob"),GO=globalThis.AbortController||Oi().AbortController,{FunctionPrototypeCall:c_}=ie(),ru=class ru extends zO{constructor(t){super(t),t?.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),t?.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}};o(ru,"Duplexify");var fr=ru;d_.exports=o(function e(t,r){if(qO(t))return t;if(e_(t))return ji({readable:t});if(t_(t))return ji({writable:t});if(HO(t))return ji({writable:!1,readable:!1});if(r_(t))return ji({readable:u_.fromWeb(t)});if(i_(t))return ji({writable:WO.fromWeb(t)});if(typeof t=="function"){let{value:n,write:a,final:s,destroy:l}=ZO(t);if(Q0(n))return s_(fr,n,{objectMode:!0,write:a,final:s,destroy:l});let u=n?.then;if(typeof u=="function"){let c,f=c_(u,n,d=>{if(d!=null)throw new a_("nully","body",d)},d=>{Hi(c,d)});return c=new fr({objectMode:!0,readable:!1,write:a,final(d){s(async()=>{try{await f,tu.nextTick(d,null)}catch(h){tu.nextTick(d,h)}})},destroy:l})}throw new a_("Iterable, AsyncIterable or AsyncFunction",r,n)}if(VO(t))return e(t.arrayBuffer());if(Q0(t))return s_(fr,t,{objectMode:!0,writable:!1});if(r_(t?.readable)&&i_(t?.writable))return fr.fromWeb(t);if(typeof t?.writable=="object"||typeof t?.readable=="object"){let n=t!=null&&t.readable?e_(t?.readable)?t?.readable:e(t.readable):void 0,a=t!=null&&t.writable?t_(t?.writable)?t?.writable:e(t.writable):void 0;return ji({readable:n,writable:a})}let i=t?.then;if(typeof i=="function"){let n;return c_(i,t,a=>{a!=null&&n.push(a),n.push(null)},a=>{Hi(n,a)}),n=new fr({objectMode:!0,writable:!1,read(){}})}throw new UO(r,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],t)},"duplexify");function ZO(e){let{promise:t,resolve:r}=o_(),i=new GO,n=i.signal;return{value:e(async function*(){for(;;){let s=t;t=null;let{chunk:l,done:u,cb:c}=await s;if(tu.nextTick(c),u)return;if(n.aborted)throw new f_(void 0,{cause:n.reason});({promise:t,resolve:r}=o_()),yield l}}(),{signal:n}),write(s,l,u){let c=r;r=null,c({chunk:s,done:!1,cb:u})},final(s){let l=r;r=null,l({done:!0,cb:s})},destroy(s,l){i.abort(),l(s)}}}o(ZO,"fromAsyncGen");function ji(e){let t=e.readable&&typeof e.readable.read!="function"?u_.wrap(e.readable):e.readable,r=e.writable,i=!!MO(t),n=!!jO(r),a,s,l,u,c;function f(d){let h=u;u=null,h?h(d):d&&c.destroy(d)}return o(f,"onfinished"),c=new fr({readableObjectMode:!!(t!=null&&t.readableObjectMode),writableObjectMode:!!(r!=null&&r.writableObjectMode),readable:i,writable:n}),n&&(n_(r,d=>{n=!1,d&&Hi(t,d),f(d)}),c._write=function(d,h,p){r.write(d,h)?p():a=p},c._final=function(d){r.end(),s=d},r.on("drain",function(){if(a){let d=a;a=null,d()}}),r.on("finish",function(){if(s){let d=s;s=null,d()}})),i&&(n_(t,d=>{i=!1,d&&Hi(t,d),f(d)}),t.on("readable",function(){if(l){let d=l;l=null,d()}}),t.on("end",function(){c.push(null)}),c._read=function(){for(;;){let d=t.read();if(d===null){l=c._read;return}if(!c.push(d))return}}),c._destroy=function(d,h){!d&&u!==null&&(d=new f_),l=null,a=null,s=null,u===null?h(d):(u=h,Hi(r,d),Hi(t,d))},c}o(ji,"_duplexify")});var Pt=O((M2,w_)=>{"use strict";var{ObjectDefineProperties:KO,ObjectGetOwnPropertyDescriptor:Mt,ObjectKeys:YO,ObjectSetPrototypeOf:p_}=ie();w_.exports=ut;var au=Jn(),et=Ss();p_(ut.prototype,au.prototype);p_(ut,au);{let e=YO(et.prototype);for(let t=0;t<e.length;t++){let r=e[t];ut.prototype[r]||(ut.prototype[r]=et.prototype[r])}}function ut(e){if(!(this instanceof ut))return new ut(e);au.call(this,e),et.call(this,e),e?(this.allowHalfOpen=e.allowHalfOpen!==!1,e.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),e.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}o(ut,"Duplex");KO(ut.prototype,{writable:{__proto__:null,...Mt(et.prototype,"writable")},writableHighWaterMark:{__proto__:null,...Mt(et.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...Mt(et.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...Mt(et.prototype,"writableBuffer")},writableLength:{__proto__:null,...Mt(et.prototype,"writableLength")},writableFinished:{__proto__:null,...Mt(et.prototype,"writableFinished")},writableCorked:{__proto__:null,...Mt(et.prototype,"writableCorked")},writableEnded:{__proto__:null,...Mt(et.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...Mt(et.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set(e){this._readableState&&this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}});var iu;function m_(){return iu===void 0&&(iu={}),iu}o(m_,"lazyWebStreams");ut.fromWeb=function(e,t){return m_().newStreamDuplexFromReadableWritablePair(e,t)};ut.toWeb=function(e){return m_().newReadableWritablePairFromDuplex(e)};var nu;ut.from=function(e){return nu||(nu=h_()),nu(e,"body")}});var lu=O((H2,y_)=>{"use strict";var{ObjectSetPrototypeOf:g_,Symbol:XO}=ie();y_.exports=jt;var{ERR_METHOD_NOT_IMPLEMENTED:JO}=ke().codes,su=Pt(),{getHighWaterMark:QO}=Kn();g_(jt.prototype,su.prototype);g_(jt,su);var ra=XO("kCallback");function jt(e){if(!(this instanceof jt))return new jt(e);let t=e?QO(this,e,"readableHighWaterMark",!0):null;t===0&&(e={...e,highWaterMark:null,readableHighWaterMark:t,writableHighWaterMark:e.writableHighWaterMark||0}),su.call(this,e),this._readableState.sync=!1,this[ra]=null,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",eD)}o(jt,"Transform");function ou(e){typeof this._flush=="function"&&!this.destroyed?this._flush((t,r)=>{if(t){e?e(t):this.destroy(t);return}r!=null&&this.push(r),this.push(null),e&&e()}):(this.push(null),e&&e())}o(ou,"final");function eD(){this._final!==ou&&ou.call(this)}o(eD,"prefinish");jt.prototype._final=ou;jt.prototype._transform=function(e,t,r){throw new JO("_transform()")};jt.prototype._write=function(e,t,r){let i=this._readableState,n=this._writableState,a=i.length;this._transform(e,t,(s,l)=>{if(s){r(s);return}l!=null&&this.push(l),n.ended||a===i.length||i.length<i.highWaterMark?r():this[ra]=r})};jt.prototype._read=function(){if(this[ra]){let e=this[ra];this[ra]=null,e()}}});var fu=O((U2,__)=>{"use strict";var{ObjectSetPrototypeOf:b_}=ie();__.exports=qi;var cu=lu();b_(qi.prototype,cu.prototype);b_(qi,cu);function qi(e){if(!(this instanceof qi))return new qi(e);cu.call(this,e)}o(qi,"PassThrough");qi.prototype._transform=function(e,t,r){r(null,e)}});var Ps=O((W2,k_)=>{var ia=X("process/"),{ArrayIsArray:tD,Promise:rD,SymbolAsyncIterator:iD,SymbolDispose:nD}=ie(),xs=Lt(),{once:aD}=Ce(),oD=Ir(),v_=Pt(),{aggregateTwoErrors:sD,codes:{ERR_INVALID_ARG_TYPE:bu,ERR_INVALID_RETURN_VALUE:uu,ERR_MISSING_ARGS:lD,ERR_STREAM_DESTROYED:cD,ERR_STREAM_PREMATURE_CLOSE:fD},AbortError:uD}=ke(),{validateFunction:dD,validateAbortSignal:hD}=Ri(),{isIterable:$r,isReadable:du,isReadableNodeStream:ks,isNodeStream:F_,isTransformStream:Ui,isWebStream:pD,isReadableStream:hu,isReadableFinished:mD}=kt(),wD=globalThis.AbortController||Oi().AbortController,pu,mu,wu;function S_(e,t,r){let i=!1;e.on("close",()=>{i=!0});let n=xs(e,{readable:t,writable:r},a=>{i=!a});return{destroy:o(a=>{i||(i=!0,oD.destroyer(e,a||new cD("pipe")))},"destroy"),cleanup:n}}o(S_,"destroyer");function gD(e){return dD(e[e.length-1],"streams[stream.length - 1]"),e.pop()}o(gD,"popCallback");function gu(e){if($r(e))return e;if(ks(e))return yD(e);throw new bu("val",["Readable","Iterable","AsyncIterable"],e)}o(gu,"makeAsyncIterable");async function*yD(e){mu||(mu=Jn()),yield*mu.prototype[iD].call(e)}o(yD,"fromReadable");async function Es(e,t,r,{end:i}){let n,a=null,s=o(c=>{if(c&&(n=c),a){let f=a;a=null,f()}},"resume"),l=o(()=>new rD((c,f)=>{n?f(n):a=o(()=>{n?f(n):c()},"onresolve")}),"wait");t.on("drain",s);let u=xs(t,{readable:!1},s);try{t.writableNeedDrain&&await l();for await(let c of e)t.write(c)||await l();i&&(t.end(),await l()),r()}catch(c){r(n!==c?sD(n,c):c)}finally{u(),t.off("drain",s)}}o(Es,"pumpToNode");async function yu(e,t,r,{end:i}){Ui(t)&&(t=t.writable);let n=t.getWriter();try{for await(let a of e)await n.ready,n.write(a).catch(()=>{});await n.ready,i&&await n.close(),r()}catch(a){try{await n.abort(a),r(a)}catch(s){r(s)}}}o(yu,"pumpToWeb");function bD(...e){return E_(e,aD(gD(e)))}o(bD,"pipeline");function E_(e,t,r){if(e.length===1&&tD(e[0])&&(e=e[0]),e.length<2)throw new lD("streams");let i=new wD,n=i.signal,a=r?.signal,s=[];hD(a,"options.signal");function l(){m(new uD)}o(l,"abort"),wu=wu||Ce().addAbortListener;let u;a&&(u=wu(a,l));let c,f,d=[],h=0;function p(k){m(k,--h===0)}o(p,"finish");function m(k,F){var S;if(k&&(!c||c.code==="ERR_STREAM_PREMATURE_CLOSE")&&(c=k),!(!c&&!F)){for(;d.length;)d.shift()(c);(S=u)===null||S===void 0||S[nD](),i.abort(),F&&(c||s.forEach(P=>P()),ia.nextTick(t,c,f))}}o(m,"finishImpl");let w;for(let k=0;k<e.length;k++){let F=e[k],S=k<e.length-1,P=k>0,b=S||r?.end!==!1,x=k===e.length-1;if(F_(F)){let v=function(A){A&&A.name!=="AbortError"&&A.code!=="ERR_STREAM_PREMATURE_CLOSE"&&p(A)};var _=v;if(o(v,"onError"),b){let{destroy:A,cleanup:T}=S_(F,S,P);d.push(A),du(F)&&x&&s.push(T)}F.on("error",v),du(F)&&x&&s.push(()=>{F.removeListener("error",v)})}if(k===0)if(typeof F=="function"){if(w=F({signal:n}),!$r(w))throw new uu("Iterable, AsyncIterable or Stream","source",w)}else $r(F)||ks(F)||Ui(F)?w=F:w=v_.from(F);else if(typeof F=="function"){if(Ui(w)){var y;w=gu((y=w)===null||y===void 0?void 0:y.readable)}else w=gu(w);if(w=F(w,{signal:n}),S){if(!$r(w,!0))throw new uu("AsyncIterable",`transform[${k-1}]`,w)}else{var g;pu||(pu=fu());let v=new pu({objectMode:!0}),A=(g=w)===null||g===void 0?void 0:g.then;if(typeof A=="function")h++,A.call(w,B=>{f=B,B!=null&&v.write(B),b&&v.end(),ia.nextTick(p)},B=>{v.destroy(B),ia.nextTick(p,B)});else if($r(w,!0))h++,Es(w,v,p,{end:b});else if(hu(w)||Ui(w)){let B=w.readable||w;h++,Es(B,v,p,{end:b})}else throw new uu("AsyncIterable or Promise","destination",w);w=v;let{destroy:T,cleanup:R}=S_(w,!1,!0);d.push(T),x&&s.push(R)}}else if(F_(F)){if(ks(w)){h+=2;let v=_D(w,F,p,{end:b});du(F)&&x&&s.push(v)}else if(Ui(w)||hu(w)){let v=w.readable||w;h++,Es(v,F,p,{end:b})}else if($r(w))h++,Es(w,F,p,{end:b});else throw new bu("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],w);w=F}else if(pD(F)){if(ks(w))h++,yu(gu(w),F,p,{end:b});else if(hu(w)||$r(w))h++,yu(w,F,p,{end:b});else if(Ui(w))h++,yu(w.readable,F,p,{end:b});else throw new bu("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],w);w=F}else w=v_.from(F)}return(n!=null&&n.aborted||a!=null&&a.aborted)&&ia.nextTick(l),w}o(E_,"pipelineImpl");function _D(e,t,r,{end:i}){let n=!1;if(t.on("close",()=>{n||r(new fD)}),e.pipe(t,{end:!1}),i){let s=function(){n=!0,t.end()};var a=s;o(s,"endFn"),mD(e)?ia.nextTick(s):e.once("end",s)}else r();return xs(e,{readable:!0,writable:!1},s=>{let l=e._readableState;s&&s.code==="ERR_STREAM_PREMATURE_CLOSE"&&l&&l.ended&&!l.errored&&!l.errorEmitted?e.once("end",r).once("error",r):r(s)}),xs(t,{readable:!1,writable:!0},r)}o(_D,"pipe");k_.exports={pipelineImpl:E_,pipeline:bD}});var vu=O((G2,D_)=>{"use strict";var{pipeline:vD}=Ps(),Ts=Pt(),{destroyer:FD}=Ir(),{isNodeStream:As,isReadable:x_,isWritable:P_,isWebStream:_u,isTransformStream:Lr,isWritableStream:T_,isReadableStream:A_}=kt(),{AbortError:SD,codes:{ERR_INVALID_ARG_VALUE:O_,ERR_MISSING_ARGS:ED}}=ke(),kD=Lt();D_.exports=o(function(...t){if(t.length===0)throw new ED("streams");if(t.length===1)return Ts.from(t[0]);let r=[...t];if(typeof t[0]=="function"&&(t[0]=Ts.from(t[0])),typeof t[t.length-1]=="function"){let p=t.length-1;t[p]=Ts.from(t[p])}for(let p=0;p<t.length;++p)if(!(!As(t[p])&&!_u(t[p]))){if(p<t.length-1&&!(x_(t[p])||A_(t[p])||Lr(t[p])))throw new O_(`streams[${p}]`,r[p],"must be readable");if(p>0&&!(P_(t[p])||T_(t[p])||Lr(t[p])))throw new O_(`streams[${p}]`,r[p],"must be writable")}let i,n,a,s,l;function u(p){let m=s;s=null,m?m(p):p?l.destroy(p):!h&&!d&&l.destroy()}o(u,"onfinished");let c=t[0],f=vD(t,u),d=!!(P_(c)||T_(c)||Lr(c)),h=!!(x_(f)||A_(f)||Lr(f));if(l=new Ts({writableObjectMode:!!(c!=null&&c.writableObjectMode),readableObjectMode:!!(f!=null&&f.readableObjectMode),writable:d,readable:h}),d){if(As(c))l._write=function(m,w,y){c.write(m,w)?y():i=y},l._final=function(m){c.end(),n=m},c.on("drain",function(){if(i){let m=i;i=null,m()}});else if(_u(c)){let w=(Lr(c)?c.writable:c).getWriter();l._write=async function(y,g,_){try{await w.ready,w.write(y).catch(()=>{}),_()}catch(k){_(k)}},l._final=async function(y){try{await w.ready,w.close().catch(()=>{}),n=y}catch(g){y(g)}}}let p=Lr(f)?f.readable:f;kD(p,()=>{if(n){let m=n;n=null,m()}})}if(h){if(As(f))f.on("readable",function(){if(a){let p=a;a=null,p()}}),f.on("end",function(){l.push(null)}),l._read=function(){for(;;){let p=f.read();if(p===null){a=l._read;return}if(!l.push(p))return}};else if(_u(f)){let m=(Lr(f)?f.readable:f).getReader();l._read=async function(){for(;;)try{let{value:w,done:y}=await m.read();if(!l.push(w))return;if(y){l.push(null);return}}catch{return}}}}return l._destroy=function(p,m){!p&&s!==null&&(p=new SD),a=null,i=null,n=null,s===null?m(p):(s=m,As(f)&&FD(f,p))},l},"compose")});var H_=O((K2,Eu)=>{"use strict";var xD=globalThis.AbortController||Oi().AbortController,{codes:{ERR_INVALID_ARG_VALUE:PD,ERR_INVALID_ARG_TYPE:na,ERR_MISSING_ARGS:TD,ERR_OUT_OF_RANGE:AD},AbortError:Tt}=ke(),{validateAbortSignal:Mr,validateInteger:R_,validateObject:jr}=Ri(),OD=ie().Symbol("kWeak"),DD=ie().Symbol("kResistStopPropagation"),{finished:RD}=Lt(),CD=vu(),{addAbortSignalNoValidate:ID}=Zn(),{isWritable:BD,isNodeStream:ND}=kt(),{deprecate:$D}=Ce(),{ArrayPrototypePush:LD,Boolean:MD,MathFloor:C_,Number:jD,NumberIsNaN:HD,Promise:I_,PromiseReject:B_,PromiseResolve:qD,PromisePrototypeThen:N_,Symbol:L_}=ie(),Os=L_("kEmpty"),$_=L_("kEof");function UD(e,t){if(t!=null&&jr(t,"options"),t?.signal!=null&&Mr(t.signal,"options.signal"),ND(e)&&!BD(e))throw new PD("stream",e,"must be writable");let r=CD(this,e);return t!=null&&t.signal&&ID(t.signal,r),r}o(UD,"compose");function Ds(e,t){if(typeof e!="function")throw new na("fn",["Function","AsyncFunction"],e);t!=null&&jr(t,"options"),t?.signal!=null&&Mr(t.signal,"options.signal");let r=1;t?.concurrency!=null&&(r=C_(t.concurrency));let i=r-1;return t?.highWaterMark!=null&&(i=C_(t.highWaterMark)),R_(r,"options.concurrency",1),R_(i,"options.highWaterMark",0),i+=r,o(async function*(){let a=Ce().AbortSignalAny([t?.signal].filter(MD)),s=this,l=[],u={signal:a},c,f,d=!1,h=0;function p(){d=!0,m()}o(p,"onCatch");function m(){h-=1,w()}o(m,"afterItemProcessed");function w(){f&&!d&&h<r&&l.length<i&&(f(),f=null)}o(w,"maybeResume");async function y(){try{for await(let g of s){if(d)return;if(a.aborted)throw new Tt;try{if(g=e(g,u),g===Os)continue;g=qD(g)}catch(_){g=B_(_)}h+=1,N_(g,m,p),l.push(g),c&&(c(),c=null),!d&&(l.length>=i||h>=r)&&await new I_(_=>{f=_})}l.push($_)}catch(g){let _=B_(g);N_(_,m,p),l.push(_)}finally{d=!0,c&&(c(),c=null)}}o(y,"pump"),y();try{for(;;){for(;l.length>0;){let g=await l[0];if(g===$_)return;if(a.aborted)throw new Tt;g!==Os&&(yield g),l.shift(),w()}await new I_(g=>{c=g})}}finally{d=!0,f&&(f(),f=null)}},"map").call(this)}o(Ds,"map");function zD(e=void 0){return e!=null&&jr(e,"options"),e?.signal!=null&&Mr(e.signal,"options.signal"),o(async function*(){let r=0;for await(let n of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new Tt({cause:e.signal.reason});yield[r++,n]}},"asIndexedPairs").call(this)}o(zD,"asIndexedPairs");async function M_(e,t=void 0){for await(let r of Su.call(this,e,t))return!0;return!1}o(M_,"some");async function WD(e,t=void 0){if(typeof e!="function")throw new na("fn",["Function","AsyncFunction"],e);return!await M_.call(this,async(...r)=>!await e(...r),t)}o(WD,"every");async function VD(e,t){for await(let r of Su.call(this,e,t))return r}o(VD,"find");async function GD(e,t){if(typeof e!="function")throw new na("fn",["Function","AsyncFunction"],e);async function r(i,n){return await e(i,n),Os}o(r,"forEachFn");for await(let i of Ds.call(this,r,t));}o(GD,"forEach");function Su(e,t){if(typeof e!="function")throw new na("fn",["Function","AsyncFunction"],e);async function r(i,n){return await e(i,n)?i:Os}return o(r,"filterFn"),Ds.call(this,r,t)}o(Su,"filter");var ku=class ku extends TD{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}};o(ku,"ReduceAwareErrMissingArgs");var Fu=ku;async function ZD(e,t,r){var i;if(typeof e!="function")throw new na("reducer",["Function","AsyncFunction"],e);r!=null&&jr(r,"options"),r?.signal!=null&&Mr(r.signal,"options.signal");let n=arguments.length>1;if(r!=null&&(i=r.signal)!==null&&i!==void 0&&i.aborted){let c=new Tt(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await RD(this.destroy(c)),c}let a=new xD,s=a.signal;if(r!=null&&r.signal){let c={once:!0,[OD]:this,[DD]:!0};r.signal.addEventListener("abort",()=>a.abort(),c)}let l=!1;try{for await(let c of this){var u;if(l=!0,r!=null&&(u=r.signal)!==null&&u!==void 0&&u.aborted)throw new Tt;n?t=await e(t,c,{signal:s}):(t=c,n=!0)}if(!l&&!n)throw new Fu}finally{a.abort()}return t}o(ZD,"reduce");async function KD(e){e!=null&&jr(e,"options"),e?.signal!=null&&Mr(e.signal,"options.signal");let t=[];for await(let i of this){var r;if(e!=null&&(r=e.signal)!==null&&r!==void 0&&r.aborted)throw new Tt(void 0,{cause:e.signal.reason});LD(t,i)}return t}o(KD,"toArray");function YD(e,t){let r=Ds.call(this,e,t);return o(async function*(){for await(let n of r)yield*n},"flatMap").call(this)}o(YD,"flatMap");function j_(e){if(e=jD(e),HD(e))return 0;if(e<0)throw new AD("number",">= 0",e);return e}o(j_,"toIntegerOrInfinity");function XD(e,t=void 0){return t!=null&&jr(t,"options"),t?.signal!=null&&Mr(t.signal,"options.signal"),e=j_(e),o(async function*(){var i;if(t!=null&&(i=t.signal)!==null&&i!==void 0&&i.aborted)throw new Tt;for await(let a of this){var n;if(t!=null&&(n=t.signal)!==null&&n!==void 0&&n.aborted)throw new Tt;e--<=0&&(yield a)}},"drop").call(this)}o(XD,"drop");function JD(e,t=void 0){return t!=null&&jr(t,"options"),t?.signal!=null&&Mr(t.signal,"options.signal"),e=j_(e),o(async function*(){var i;if(t!=null&&(i=t.signal)!==null&&i!==void 0&&i.aborted)throw new Tt;for await(let a of this){var n;if(t!=null&&(n=t.signal)!==null&&n!==void 0&&n.aborted)throw new Tt;if(e-- >0&&(yield a),e<=0)return}},"take").call(this)}o(JD,"take");Eu.exports.streamReturningOperators={asIndexedPairs:$D(zD,"readable.asIndexedPairs will be removed in a future version."),drop:XD,filter:Su,flatMap:YD,map:Ds,take:JD,compose:UD};Eu.exports.promiseReturningOperators={every:WD,forEach:GD,reduce:ZD,toArray:KD,some:M_,find:VD}});var xu=O((X2,q_)=>{"use strict";var{ArrayPrototypePop:QD,Promise:eR}=ie(),{isIterable:tR,isNodeStream:rR,isWebStream:iR}=kt(),{pipelineImpl:nR}=Ps(),{finished:aR}=Lt();Pu();function oR(...e){return new eR((t,r)=>{let i,n,a=e[e.length-1];if(a&&typeof a=="object"&&!rR(a)&&!tR(a)&&!iR(a)){let s=QD(e);i=s.signal,n=s.end}nR(e,(s,l)=>{s?r(s):t(l)},{signal:i,end:n})})}o(oR,"pipeline");q_.exports={finished:aR,pipeline:oR}});var Pu=O((Q2,X_)=>{"use strict";var{Buffer:sR}=X("buffer"),{ObjectDefineProperty:Ht,ObjectKeys:W_,ReflectApply:V_}=ie(),{promisify:{custom:G_}}=Ce(),{streamReturningOperators:U_,promiseReturningOperators:z_}=H_(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:Z_}}=ke(),lR=vu(),{setDefaultHighWaterMark:cR,getDefaultHighWaterMark:fR}=Kn(),{pipeline:K_}=Ps(),{destroyer:uR}=Ir(),Y_=Lt(),Tu=xu(),aa=kt(),te=X_.exports=us().Stream;te.isDestroyed=aa.isDestroyed;te.isDisturbed=aa.isDisturbed;te.isErrored=aa.isErrored;te.isReadable=aa.isReadable;te.isWritable=aa.isWritable;te.Readable=Jn();for(let e of W_(U_)){let r=function(...i){if(new.target)throw Z_();return te.Readable.from(V_(t,this,i))};o(r,"fn");let t=U_[e];Ht(r,"name",{__proto__:null,value:t.name}),Ht(r,"length",{__proto__:null,value:t.length}),Ht(te.Readable.prototype,e,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}for(let e of W_(z_)){let r=function(...i){if(new.target)throw Z_();return V_(t,this,i)};o(r,"fn");let t=z_[e];Ht(r,"name",{__proto__:null,value:t.name}),Ht(r,"length",{__proto__:null,value:t.length}),Ht(te.Readable.prototype,e,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}te.Writable=Ss();te.Duplex=Pt();te.Transform=lu();te.PassThrough=fu();te.pipeline=K_;var{addAbortSignal:dR}=Zn();te.addAbortSignal=dR;te.finished=Y_;te.destroy=uR;te.compose=lR;te.setDefaultHighWaterMark=cR;te.getDefaultHighWaterMark=fR;Ht(te,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return Tu}});Ht(K_,G_,{__proto__:null,enumerable:!0,get(){return Tu.pipeline}});Ht(Y_,G_,{__proto__:null,enumerable:!0,get(){return Tu.finished}});te.Stream=te;te._isUint8Array=o(function(t){return t instanceof Uint8Array},"isUint8Array");te._uint8ArrayToBuffer=o(function(t){return sR.from(t.buffer,t.byteOffset,t.byteLength)},"_uint8ArrayToBuffer")});var J_=O((tN,q)=>{"use strict";var ye=X("stream");if(ye&&process.env.READABLE_STREAM==="disable"){let e=ye.promises;q.exports._uint8ArrayToBuffer=ye._uint8ArrayToBuffer,q.exports._isUint8Array=ye._isUint8Array,q.exports.isDisturbed=ye.isDisturbed,q.exports.isErrored=ye.isErrored,q.exports.isReadable=ye.isReadable,q.exports.Readable=ye.Readable,q.exports.Writable=ye.Writable,q.exports.Duplex=ye.Duplex,q.exports.Transform=ye.Transform,q.exports.PassThrough=ye.PassThrough,q.exports.addAbortSignal=ye.addAbortSignal,q.exports.finished=ye.finished,q.exports.destroy=ye.destroy,q.exports.pipeline=ye.pipeline,q.exports.compose=ye.compose,Object.defineProperty(ye,"promises",{configurable:!0,enumerable:!0,get(){return e}}),q.exports.Stream=ye.Stream}else{let e=Pu(),t=xu(),r=e.Readable.destroy;q.exports=e.Readable,q.exports._uint8ArrayToBuffer=e._uint8ArrayToBuffer,q.exports._isUint8Array=e._isUint8Array,q.exports.isDisturbed=e.isDisturbed,q.exports.isErrored=e.isErrored,q.exports.isReadable=e.isReadable,q.exports.Readable=e.Readable,q.exports.Writable=e.Writable,q.exports.Duplex=e.Duplex,q.exports.Transform=e.Transform,q.exports.PassThrough=e.PassThrough,q.exports.addAbortSignal=e.addAbortSignal,q.exports.finished=e.finished,q.exports.destroy=e.destroy,q.exports.destroy=r,q.exports.pipeline=e.pipeline,q.exports.compose=e.compose,Object.defineProperty(e,"promises",{configurable:!0,enumerable:!0,get(){return t}}),q.exports.Stream=e.Stream}q.exports.default=q.exports});import*as Ks from"path";var Ws=class Ws{constructor(t,r){$(this,"entries",[]);$(this,"currentIndex",0);$(this,"closed",!1);$(this,"compositFs");$(this,"dirPath");$(this,"initialized",!1);this.compositFs=t,this.dirPath=r}async initialize(){if(this.initialized)return;let t=new Set;for(let r of[...this.compositFs.subFilesystems].reverse()){let i=await r.readdir(this.dirPath);for(let n of i)t.add(n)}for(let r of Array.from(t)){let i=this.dirPath+"/"+r;await this.compositFs.hiddenFilesFileSystem?.responsible(i)||this.entries.push({name:r,path:i})}this.initialized=!0}async*[Symbol.asyncIterator](){for(await this.initialize();this.currentIndex<this.entries.length&&!this.closed;){let t=this.entries[this.currentIndex++];try{let r=await this.compositFs.stat(t.path);yield{name:t.name,isFile:o(()=>r.isFile(),"isFile"),isDirectory:o(()=>r.isDirectory(),"isDirectory"),isBlockDevice:o(()=>r.isBlockDevice(),"isBlockDevice"),isCharacterDevice:o(()=>r.isCharacterDevice(),"isCharacterDevice"),isSymbolicLink:o(()=>r.isSymbolicLink(),"isSymbolicLink"),isFIFO:o(()=>r.isFIFO(),"isFIFO"),isSocket:o(()=>r.isSocket(),"isSocket")}}catch(r){console.debug(`Failed to stat ${t.path}:`,r)}}}async read(){if(this.closed)throw new Error("Directory handle is closed");if(await this.initialize(),this.currentIndex>=this.entries.length)return null;let t=this.entries[this.currentIndex++];try{let r=await this.compositFs.stat(t.path);return{name:t.name,isFile:o(()=>r.isFile(),"isFile"),isDirectory:o(()=>r.isDirectory(),"isDirectory"),isBlockDevice:o(()=>r.isBlockDevice(),"isBlockDevice"),isCharacterDevice:o(()=>r.isCharacterDevice(),"isCharacterDevice"),isSymbolicLink:o(()=>r.isSymbolicLink(),"isSymbolicLink"),isFIFO:o(()=>r.isFIFO(),"isFIFO"),isSocket:o(()=>r.isSocket(),"isSocket")}}catch{return this.read()}}async close(){this.closed=!0,this.entries=[]}get path(){return this.dirPath}};o(Ws,"CompositeFsDir");var Ur=Ws;var Vs=class Vs{constructor(t){$(this,"delegate");$(this,"compositeFs");$(this,"_subFsFileDescriptor");$(this,"handleType","file");$(this,"_compositFsFileDescriptor",-1);this.delegate=t.fs,this._subFsFileDescriptor=t.subFsFileDescriptor,this._compositFsFileDescriptor=-1,this.compositeFs=t.compositeFs;let r=this._subFsFileDescriptor}get fsType(){return this.delegate.fileType()}get subFsFileDescriptor(){return this._subFsFileDescriptor}get fd(){return this._compositFsFileDescriptor}realize(t){if(this._compositFsFileDescriptor!==-1)throw new Error("was already realized");this._compositFsFileDescriptor=t}readableWebStream(t){throw new Error("Method not implemented.")}async appendFile(t,r){return await this.compositeFs.logOperationOnFileDescsriptor(this,"appendFile",{data:t,options:r}),await this.delegate.appendFile(this,t,r)}async chmod(t){return await this.compositeFs.logOperationOnFileDescsriptor(this,"chmod",{mode:t}),this.delegate.fchmod(this,t)}async chown(t,r){return await this.compositeFs.logOperationOnFileDescsriptor(this,"chown",{uid:t,gid:r}),this.delegate.fchown(this,t,r)}async close(){return await this.compositeFs.logOperationOnFileDescsriptor(this,"close",{}),this.compositeFs.close(this)}async datasync(){return await this.compositeFs.logOperationOnFileDescsriptor(this,"datasync",{}),this.delegate.dataSync(this)}async read(t,r,i,n){return await this.compositeFs.logOperationOnFileDescsriptor(this,"read",{targetBufferLength:t.length,offset:r,length:i,position:n}),await this.delegate.read(this,t,r,i,n)}async readv(t,r){return await this.compositeFs.logOperationOnFileDescsriptor(this,"readv",{buffers:t,position:r}),this.delegate.readv(this,t,r)}async stat(t){return await this.compositeFs.logOperationOnFileDescsriptor(this,"stat",{options:t}),this.delegate.fstat(this,t)}async truncate(t){return await this.compositeFs.logOperationOnFileDescsriptor(this,"truncate",{len:t}),this.delegate.ftruncate(this,t)}async utimes(t,r){return await this.compositeFs.logOperationOnFileDescsriptor(this,"utimes",{atime:t,mtime:r}),this.delegate.futimes(this,t,r)}async write(t,r,i,n){return await this.compositeFs.logOperationOnFileDescsriptor(this,"write",{buffer:t,offset:r,length:i,position:n}),this.delegate.write(this,t,r,i,n)}async writev(t,r){return await this.compositeFs.logOperationOnFileDescsriptor(this,"writev",{buffers:t,position:r}),this.delegate.writev(this,t,r)}async sync(){return await this.compositeFs.logOperationOnFileDescsriptor(this,"sync",{}),this.delegate.dataSync(this)}};o(Vs,"CompositFsFileHandle");var it=Vs;import*as qu from"path";import{createFsFromVolume as Ev,Volume as kv}from"memfs";var Gs=class Gs{constructor({name:t,parentFs:r,gitRoot:i}){$(this,"compositFs");$(this,"gitRoot");$(this,"name");this.name=t,this.compositFs=r,this.gitRoot=i}toStr(t){return typeof t=="string"?t:Buffer.isBuffer(t)?t.toString():t&&typeof t=="object"&&"fd"in t?`FileHandle(fd=${t.fd})`:String(t)}async open(t,r,i){throw new Error(`open not implemented for: ${this.toStr(t)}`)}async access(t,r){throw new Error(`access not implemented for: ${this.toStr(t)}`)}async stat(t,r){throw new Error(`lstat not implemented for: ${this.toStr(t)}`)}async lstat(t,r){throw new Error(`lstat not implemented for: ${this.toStr(t)}`)}async opendir(t,r){throw new Error(`opendir not implemented for: ${this.toStr(t)}`)}async link(t,r){throw new Error(`link not implemented for: ${this.toStr(t)}`)}async mkdir(t,r){throw new Error(`mkdir not implemented for: ${this.toStr(t)}`)}async readdir(t,r){throw new Error(`readdir not implemented for: ${this.toStr(t)}`)}async readlink(t,...r){throw new Error(`readlink not implemented for: ${this.toStr(t)}`)}async unlink(t){throw new Error(`unlink not implemented for: ${this.toStr(t)}`)}async rename(t,r){throw new Error(`rename not implemented for: ${this.toStr(t)}`)}async rmdir(t,...r){throw new Error(`rmdir not implemented for: ${this.toStr(t)}`)}async symlink(t,r,i){throw new Error(`symlink not implemented for: ${this.toStr(r)}`)}async lookup(t){throw new Error(`lookup not implemented for: ${this.toStr(t)}`)}resolvePath(t){throw new Error(`resolvePath not implemented for fd: ${t}`)}async close(t){this.compositFs.close(t)}async dataSync(t){throw new Error(`dataSync not implemented for: ${t.subFsFileDescriptor}`)}async read(t,r,i,n,a){throw new Error(`read not implemented for: ${t.subFsFileDescriptor}`)}async appendFile(t,r,i){throw new Error(`appendFile not implemented for: ${t.subFsFileDescriptor}`)}async fchmod(t,r){throw new Error(`fchmod not implemented for: ${t.subFsFileDescriptor}`)}async fchown(t,r,i){throw new Error(`fchown not implemented for: ${t.subFsFileDescriptor}`)}async ftruncate(t,r){throw new Error(`ftruncate not implemented for: ${t.subFsFileDescriptor}`)}async fstat(t,r){throw new Error(`fstat not implemented for: ${t.subFsFileDescriptor}`)}async futimes(t,r,i){throw new Error(`futimes not implemented for: ${t.subFsFileDescriptor}`)}async write(t,r,i,n,a){throw new Error(`write not implemented for: ${t.subFsFileDescriptor}`)}async writev(t,r,i){throw new Error(`writev not implemented for: ${t.subFsFileDescriptor}`)}async readv(t,r,i){throw new Error(`readv not implemented for: ${t.subFsFileDescriptor}`)}async readFile(t,r){throw new Error(`readFile not implemented for: ${this.toStr(t)}`)}async writeFile(t,r,i){throw new Error(`writeFile not implemented for: ${this.toStr(t)}`)}};o(Gs,"BaseCompositeSubFs");var Ze=Gs;var Zs=class Zs extends Ze{constructor({name:r,parentFs:i,gitRoot:n,passThroughFs:a}){super({name:r,parentFs:i,gitRoot:n});$(this,"openFh",new Map);$(this,"memFs",Ev(new kv));$(this,"targetFs");this.compositFs=i,this.gitRoot=n,this.targetFs=a}async responsible(r){return!0}fileType(){return 4}async open(r,i,n){let a=qu.dirname(r),s=await this.targetFs.promises.open(r,i,n);return this.openFh.set(s.fd,s),new it({fs:this,compositeFs:this.compositFs,subFsFileDescriptor:s.fd,parentFsFileDescriptors:[]})}async access(r,i){return await this.targetFs.promises.access(r,i)}async stat(r,...i){return this.targetFs.promises.stat(r,{bigint:!1})}async lstat(r,...i){return this.targetFs.promises.lstat(r,{bigint:!1})}async opendir(r,i){let n=await this.targetFs.promises.opendir(r,i);return new Ur(this.compositFs,r.toString())}async link(r,i){return await this.targetFs.promises.link(r,i)}async mkdir(r,i){await this.targetFs.promises.mkdir(r,i)}async readdir(r,...i){return this.targetFs.promises.readdir(r,...i)}async readlink(r,...i){throw new Error("not implemented")}async unlink(r){return await this.targetFs.promises.unlink(r)}async rename(r,i){return await this.targetFs.promises.rename(r,i)}async rmdir(r,i){return await this.targetFs.promises.rmdir(r,i)}async symlink(r,i,n){return await this.targetFs.promises.symlink(r,i,n)}async lookup(r){throw new Error(`lookup is not implemented for: ${this.toStr(r)}`)}async close(r){let i=this.openFh.get(r.subFsFileDescriptor);i&&(this.openFh.delete(r.subFsFileDescriptor),await i.close())}async dataSync(r){let i=this.openFh.get(r.subFsFileDescriptor);if(i)return await i.sync()}async read(r,i,n,a,s){let l=this.openFh.get(r.subFsFileDescriptor);if(l)return await l.read(i,n,a,s);throw new Error(`File handle not found: ${r.subFsFileDescriptor}`)}async fchmod(r,i){let n=this.openFh.get(r.subFsFileDescriptor);if(n)return await n.chmod(i)}async fchown(r,i,n){let a=this.openFh.get(r.subFsFileDescriptor);if(a)return await a.chown(i,n)}async write(r,i,n,a,s){let l=this.openFh.get(r.subFsFileDescriptor);if(l)return await l.write(i,n,a,s);throw new Error(`File handle not found: ${r.subFsFileDescriptor}`)}async ftruncate(r,i){let n=this.openFh.get(r.subFsFileDescriptor);if(n)return await n.truncate(i)}resolvePath(r){throw new Error(`resolvePath is not implemented: resolvePath(${r})`)}async fstat(r,i){let n=this.openFh.get(r.subFsFileDescriptor);if(n)return await n.stat(i);throw new Error(`File handle not found: ${r.subFsFileDescriptor}`)}async futimes(r,i,n){let a=this.openFh.get(r.subFsFileDescriptor);if(a)return await a.utimes(i,n)}async writev(r,i,n){let a=this.openFh.get(r.subFsFileDescriptor);if(a)return await a.writev(i,n??void 0);throw new Error(`File handle not found: ${r.subFsFileDescriptor}`)}async readv(r,i,n){let a=this.openFh.get(r.subFsFileDescriptor);if(a)return await a.readv(i,n??void 0);throw new Error(`File handle not found: ${r.subFsFileDescriptor}`)}async readFile(r,i){return this.targetFs.promises.readFile(r,i)}async writeFile(r,i,n){return this.targetFs.promises.writeFile(r,i,n)}};o(Zs,"PassThroughToAsyncFsSubFs");var fa=Zs;var Ys=class Ys{constructor({name:t,storageFs:r,gitRoot:i,defaultBranch:n="main"}){$(this,"promises");$(this,"gitRoot");$(this,"ephemeralFilesFileSystem");$(this,"hiddenFilesFileSystem");$(this,"passThroughFileSystem");$(this,"subFilesystems",[]);$(this,"parentFs");$(this,"name");$(this,"defaultBranch");$(this,"gitCache");$(this,"pathToFileDescriptors",new Map);$(this,"openFileHandles",new Map);$(this,"logOperation");this.name=t,this.gitRoot=i,this.defaultBranch=n,this.promises={access:this.access.bind(this),opendir:this.opendir.bind(this),mkdir:this.mkdir.bind(this),readdir:this.readdir.bind(this),open:this.open.bind(this),stat:this.stat.bind(this),lstat:this.lstat.bind(this),link:this.link.bind(this),readlink:this.readlink.bind(this),unlink:this.unlink.bind(this),rename:this.rename.bind(this),rmdir:this.rmdir.bind(this),symlink:this.symlink.bind(this),readFile:this.readFile.bind(this),writeFile:this.writeFile.bind(this),getFilehandle:this.getFilehandle.bind(this)},this.passThroughFileSystem=new fa({name:t+"-passthrough",passThroughFs:r,gitRoot:i,parentFs:this})}getNextFileDescriptor(){let t=Array.from(this.openFileHandles.keys());return t.length===0?1:Math.max(...t)+1}setLoggger(t){this.logOperation=t}async logOperationOnFileDescsriptor(t,r,i){if(!this.logOperation)return;let n=[];for(let[a,s]of this.pathToFileDescriptors.entries())s.includes(t.fd)&&n.push(a);if(n.length!==0)return this.logOperation?.({fsName:t.delegate.name,fd:t,path:n[0],operation:r,operationArgs:i})}getFilehandle(t){return this.openFileHandles.get(t)}setEphemeralFilesSubFs(t){this.ephemeralFilesFileSystem=t}setHiddenFilesSubFs(t){this.hiddenFilesFileSystem=t}addSubFs(t){this.subFilesystems.push(t)}async getResponsibleFs(t){if(!t.toString().startsWith(this.gitRoot)&&this.gitRoot!=="./")throw new Error("tried to access a file ("+t+") outside of the legit folder: "+this.gitRoot);if(!this.hiddenFilesFileSystem)throw new Error(this.name+" intialize hidden fs first!");if(!this.ephemeralFilesFileSystem)throw new Error(this.name+" intialize ephemeral fs first!");if(await this.hiddenFilesFileSystem.responsible(t.toString()))return this.hiddenFilesFileSystem;if(await this.ephemeralFilesFileSystem.responsible(t.toString()))return this.ephemeralFilesFileSystem;for(let r of this.subFilesystems)if(await r.responsible(t.toString()))return r;return this.passThroughFileSystem}async access(t,r){let i=await this.getResponsibleFs(t);return await this.logOperation?.({fsName:i.name,path:t,operation:"access",operationArgs:{mode:r}}),i.access(t,r)}async opendir(t,r){await this.logOperation?.({fsName:this.name,path:t.toString(),operation:"opendir",operationArgs:{options:r}});let i=t.toString();if(!i.startsWith(this.gitRoot))throw new Error("tried to access a directory ("+i+") outside of the legit folder: "+this.gitRoot);return new Ur(this,i)}async mkdir(t,r){let i=await this.getResponsibleFs(t);return await this.logOperation?.({fsName:i.name,path:t.toString(),operation:"mkdir",operationArgs:{options:r}}),i.mkdir(t,r)}async readdir(t,r){await this.logOperation?.({fsName:this.name,path:t.toString(),operation:"readdir",operationArgs:{options:r}});let i=new Set;for(let n of[...this.subFilesystems].reverse()){let a=await n.readdir(t,r);for(let s of a)await this.ephemeralFilesFileSystem?.responsible((t=="/"?"":t)+"/"+s)||i.add(s)}try{let n=await this.passThroughFileSystem.readdir(t,r);for(let a of n)await this.ephemeralFilesFileSystem?.responsible((t=="/"?"":t)+"/"+a)||i.add(a)}catch(n){if(n.code!=="ENOENT")throw new Error("error reading ephemeral fs: "+n)}try{let n=await this.ephemeralFilesFileSystem.readdir(t,r);for(let a of n)i.add(a)}catch(n){if(n.code!=="ENOENT")throw new Error("error reading ephemeral fs: "+n)}for(let n of i){let a=(t=="/"?"":t)+"/"+n;await this.hiddenFilesFileSystem.responsible(a)&&i.delete(n)}return Array.from(i)}async open(t,r,i){let n=await this.getResponsibleFs(t);await this.logOperation?.({fsName:n.name,path:t,operation:"open",operationArgs:{flags:r,mode:i}});let a=await n.open(t,r,i),s=this.getNextFileDescriptor();return a.realize(s),this.openFileHandles.set(s,a),this.pathToFileDescriptors.get(t)||this.pathToFileDescriptors.set(t,[]),this.pathToFileDescriptors.get(t).push(s),a}async close(t){try{await t.delegate.close(t)}catch(r){throw r}finally{for(let[r,i]of this.pathToFileDescriptors.entries()){let n=i.indexOf(t.fd);if(n!==-1){i.splice(n,1),i.length===0&&this.pathToFileDescriptors.delete(r);break}}this.openFileHandles.delete(t.fd)}}async stat(t,r){let i=t.toString(),n=await this.getResponsibleFs(t);return await this.logOperation?.({fsName:n.name,path:i,operation:"stat",operationArgs:{opts:r}}),n.stat(t)}async lstat(t,r){let i=await this.getResponsibleFs(t);return await this.logOperation?.({fsName:i.name,path:t.toString(),operation:"lstat",operationArgs:{opts:r}}),i.lstat(t,r)}async link(t,r){throw new Error("not implemented")}async readlink(t,r){throw new Error("not implemented")}async unlink(t){let r=await this.getResponsibleFs(t);return await this.logOperation?.({fsName:r.name,path:t.toString(),operation:"unlink",operationArgs:{}}),r.unlink(t)}async rename(t,r){if(this.hiddenFilesFileSystem){if(await this.hiddenFilesFileSystem.responsible(Ks.basename(t.toString())))throw new Error("Renaming of hidden Files is not allowed "+t);if(await this.hiddenFilesFileSystem.responsible(Ks.basename(r.toString())))throw new Error("Renaming to hidden Files is not allowed "+r)}let i=await this.getResponsibleFs(t),n=await this.getResponsibleFs(r);if(i===n)return await this.logOperation?.({fsName:i.name,path:t.toString(),operation:"rename",operationArgs:{oldPath:t,newPath:r}}),i.rename(t,r);let a=await i.open(t.toString(),"r");try{let s=await i.fstat(a),l=Buffer.alloc(s.size);await i.read(a,l,0,s.size,0),await i.close(a),await n.writeFile(r.toString(),l,"utf8"),await i.unlink(t)}catch(s){try{await i.close(a)}catch{}throw s}}async rmdir(t,r){let i=await this.getResponsibleFs(t);return await this.logOperation?.({fsName:i.name,path:t.toString(),operation:"rmdir",operationArgs:{dirPath:t,options:r}}),i.rmdir(t,r)}async symlink(t,r,i){throw new Error("not implemented")}async readFile(t,r){await this.logOperation?.({fsName:this.name,path:t.toString(),operation:"readFile",operationArgs:{path:t,options:r}});let i=!0,n;if(typeof t=="number"){i=!1;let a=this.getFilehandle(t);if(!a)throw new Error("Invalid file descriptor");n=a}else if(typeof t=="string")n=await this.open(t,"r");else throw new Error("only filehandle and path are supported atm");try{let s=(await n.stat()).size;if(typeof s=="bigint"){if(s>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("File too large to read into buffer");s=Number(s)}let l=Buffer.alloc(s),{bytesRead:u}=await n.read(l,0,s,0);if(r&&typeof r.encoding=="string")return l.slice(0,u).toString(r.encoding);if(typeof r=="string"){if(r==="utf8"||r==="utf-8")return l.slice(0,u).toString(r);throw new Error("Unsupported encoding: "+r)}return l.slice(0,u)}finally{n&&i&&await n.close()}}async writeFile(t,r,i){await this.logOperation?.({fsName:this.name,path:t.toString(),operation:"writeFile",operationArgs:{data:r,options:i}});let n=typeof t!="number",a,s,l,u="w";if(typeof i=="string"?s=i:i&&typeof i=="object"&&(s=i.encoding,l=i.mode,u=i.flag||"w"),typeof t=="number"){let c=this.getFilehandle(t);if(!c)throw new Error("Invalid file descriptor");a=c}else if(typeof t=="string")a=await this.open(t,u,l);else throw new Error("only filehandle and path are supported atm");try{let c;if(typeof r=="string")c=Buffer.from(r,s||"utf8");else if(r instanceof Buffer)c=r;else if(r instanceof Uint8Array)c=Buffer.from(r);else throw new Error("Invalid data type for writeFile");let f=0;for(;f<c.length;){let{bytesWritten:d}=await a.write(c,f,c.length-f,f);f+=d}}finally{a&&n&&await a.close()}}};o(Ys,"CompositeFs");var ua=Ys;import xv from"ignore";var Xs=class Xs extends Ze{constructor({name:r,parentFs:i,gitRoot:n,hiddenFiles:a}){super({name:r,parentFs:i,gitRoot:n});$(this,"ig");this.ig=xv(),this.ig.add(a)}async responsible(r){let i=r.replace(/\\/g,"/"),n=i.startsWith("./")?i.slice(2):i;return n=n.startsWith("/")?n.slice(1):n,n===""||n==="."?!1:this.ig.ignores(n)}fileType(){return 255}error(r){return new Error(`Access to hidden file is not allowed: ${this.toStr(r)}`)}async open(r,i,n){throw this.error(r)}async access(r){throw this.error(r)}async stat(r){throw this.error(r)}async lstat(r){throw this.error(r)}async opendir(r){throw this.error(r)}async link(r){throw this.error(r)}async mkdir(r){throw this.error(r)}async readdir(r){throw this.error(r)}async readlink(r){throw this.error(r)}async unlink(r){throw this.error(r)}async rename(r){throw this.error(r)}async rmdir(r){throw this.error(r)}async symlink(r,i){throw this.error(i)}async lookup(r){throw this.error(r)}resolvePath(r){throw new Error(`Access to hidden file is not allowed: resolvePath(${r})`)}async close(r){throw new Error("Access to hidden file is not allowed: close: "+r.subFsFileDescriptor)}async dataSync(r){throw new Error("Access to hidden file is not allowed: dataSync: "+r.subFsFileDescriptor)}async read(r,i,n,a,s){throw new Error("Access to hidden file is not allowed: readFileHandle: "+r.subFsFileDescriptor)}};o(Xs,"HiddenFileSubFs");var da=Xs;import*as ha from"path";import{createFsFromVolume as Pv,Volume as Tv}from"memfs";import Av from"ignore";var Js=class Js extends Ze{constructor({name:r,parentFs:i,gitRoot:n,ephemeralPatterns:a}){super({name:r,parentFs:i,gitRoot:n});$(this,"openFh",new Map);$(this,"memFs",Pv(new Tv));$(this,"ig");$(this,"patterns");this.compositFs=i,this.gitRoot=n,this.ig=Av(),this.ig.add(a),this.patterns=a}normalizePath(r){let i=typeof r=="string"?r:r.toString();return i.startsWith("/")?i:"/"+i}async responsible(r){let i=r.replace(/\\/g,"/"),n=i.startsWith("./")?i.slice(2):i;return n=n.startsWith("/")?n.slice(1):n,n===""||n==="."?!1:this.ig.ignores(n)}fileType(){return 5}async open(r,i,n){let a=this.normalizePath(r),s=ha.dirname(a);s&&s!=="/"&&s!=="."&&await this.memFs.promises.mkdir(s,{recursive:!0});let l=await this.memFs.promises.open(a,i,n);return this.openFh.set(l.fd,l),new it({fs:this,compositeFs:this.compositFs,subFsFileDescriptor:l.fd,parentFsFileDescriptors:[l.fd]})}async access(r,i){let n=this.normalizePath(r);return await this.memFs.promises.access(n,i)}async stat(r,i){let n=this.normalizePath(r);return this.memFs.promises.stat(n,{bigint:!1})}async lstat(r,i){let n=this.normalizePath(r);return this.memFs.promises.lstat(n,{bigint:!1})}async opendir(r,i){let n=this.normalizePath(r);return await this.memFs.promises.opendir(n,i)}async link(r,i){let n=this.normalizePath(r),a=this.normalizePath(i);return await this.memFs.promises.link(n,a)}async mkdir(r,i){let n=this.normalizePath(r);if(!(typeof i=="object"&&i&&"recursive"in i&&i.recursive)){let s=ha.dirname(n);if(s&&s!=="/"&&s!==".")try{await this.memFs.promises.stat(s)}catch{await this.memFs.promises.mkdir(s,{recursive:!0})}}await this.memFs.promises.mkdir(n,i)}async readdir(r,...i){let n=this.normalizePath(r),a=await this.memFs.promises.readdir(n,...i);return console.log("EPHEMERAL: READDIR: ",a),a}async readlink(r){throw new Error("readlink is not implemented for EphemeralFileSubFs")}async unlink(r){let i=this.normalizePath(r);return await this.memFs.promises.unlink(i)}async rename(r,i){let n=this.normalizePath(r),a=this.normalizePath(i);return await this.memFs.promises.rename(n,a)}async rmdir(r,i){let n=this.normalizePath(r);return await this.memFs.promises.rmdir(n,i)}async symlink(r,i,n){let a=this.normalizePath(r),s=this.normalizePath(i);return await this.memFs.promises.symlink(a,s,n)}async lookup(r){throw new Error(`lookup is not implemented for: ${this.toStr(r)}`)}async close(r){let i=this.openFh.get(r.subFsFileDescriptor);i&&(await i.close(),this.openFh.delete(r.subFsFileDescriptor))}async dataSync(r){let i=this.openFh.get(r.subFsFileDescriptor);if(i)return await i.datasync()}async read(r,i,n,a,s){let l=this.openFh.get(r.subFsFileDescriptor);if(l)return await l.read(i,n,a,s);throw new Error(`File handle not found: ${r.subFsFileDescriptor}`)}async fchmod(r,i){let n=this.openFh.get(r.subFsFileDescriptor);if(n)return await n.chmod(i)}async fchown(r,i,n){let a=this.openFh.get(r.subFsFileDescriptor);if(a)return await a.chown(i,n)}async write(r,i,n,a,s){let l=this.openFh.get(r.subFsFileDescriptor);if(l)return await l.write(i,n,a,s);throw new Error(`File handle not found: ${r.subFsFileDescriptor}`)}async ftruncate(r,i){let n=this.openFh.get(r.subFsFileDescriptor);if(n)return await n.truncate(i)}resolvePath(r){throw new Error(`resolvePath is not implemented: resolvePath(${r})`)}async fstat(r,i){let n=this.openFh.get(r.subFsFileDescriptor);if(n)return await n.stat(i);throw new Error(`File handle not found: ${r.subFsFileDescriptor}`)}async futimes(r,i,n){let a=this.openFh.get(r.subFsFileDescriptor);if(a)return await a.utimes(i,n)}async writev(r,i,n){let a=this.openFh.get(r.subFsFileDescriptor);if(a)return await a.writev(i,n??void 0);throw new Error(`File handle not found: ${r.subFsFileDescriptor}`)}async readv(r,i,n){let a=this.openFh.get(r.subFsFileDescriptor);if(a)return await a.readv(i,n??void 0);throw new Error(`File handle not found: ${r.subFsFileDescriptor}`)}async readFile(r,i){if(typeof r=="string"||Buffer.isBuffer(r)){let n=this.normalizePath(r);return this.memFs.promises.readFile(n,i)}return super.readFile(r,i)}async writeFile(r,i,n){let a=this.normalizePath(r),s=ha.dirname(a);return s&&s!=="/"&&s!=="."&&await this.memFs.promises.mkdir(s,{recursive:!0}),this.memFs.promises.writeFile(a,i,n)}};o(Js,"EphemeralSubFs");var pa=Js;import*as zu from"path";import{createFsFromVolume as Ov,Volume as Dv}from"memfs";var Qs=class Qs extends Ze{constructor({name:r,parentFs:i,gitRoot:n}){super({name:r,parentFs:i,gitRoot:n});$(this,"openFh",new Map);$(this,"memFs",Ov(new Dv));$(this,"targetFs");if(this.compositFs=i,this.gitRoot=n,this.compositFs.parentFs===void 0)throw new Error("PassThroughSubFs not allowed in root fs");this.targetFs=this.compositFs.parentFs}async responsible(r){return!0}fileType(){return 4}async open(r,i,n){let a=zu.dirname(r),s=await this.targetFs.promises.open(r,i,n);return this.openFh.set(s.fd,s),new it({fs:this,compositeFs:this.compositFs,subFsFileDescriptor:s.fd,parentFsFileDescriptors:[s.fd]})}async access(r,i){return await this.targetFs.promises.access(r,i)}async stat(r,i){return this.targetFs.promises.stat(r,{bigint:!1})}async lstat(r,i){return this.targetFs.promises.lstat(r,{bigint:!1})}async opendir(r,i){return await this.targetFs.promises.opendir(r,i)}async link(r,i){return await this.targetFs.promises.link(r,i)}async mkdir(r,i){let n=typeof r=="string"?r:r.toString();return await this.targetFs.promises.mkdir(n,i)}async readdir(r,...i){return this.targetFs.promises.readdir(r,...i)}async readlink(r,...i){throw new Error("not implemented")}async unlink(r){return await this.targetFs.promises.unlink(r)}async rename(r,i){return await this.targetFs.promises.rename(r,i)}async rmdir(r,i){return await this.targetFs.promises.rmdir(r,i)}async symlink(r,i,n){return await this.targetFs.promises.symlink(r,i,n)}async lookup(r){throw new Error(`lookup is not implemented for: ${this.toStr(r)}`)}async close(r){let i=this.openFh.get(r.subFsFileDescriptor);i&&(await i.close(),this.openFh.delete(r.subFsFileDescriptor))}async dataSync(r){let i=this.openFh.get(r.subFsFileDescriptor);if(i)return await i.sync()}async read(r,i,n,a,s){let l=this.openFh.get(r.subFsFileDescriptor);if(l)return await l.read(i,n,a,s);throw new Error(`File handle not found: ${r.subFsFileDescriptor}`)}async fchmod(r,i){let n=this.openFh.get(r.subFsFileDescriptor);if(n)return await n.chmod(i)}async fchown(r,i,n){let a=this.openFh.get(r.subFsFileDescriptor);if(a)return await a.chown(i,n)}async write(r,i,n,a,s){let l=this.openFh.get(r.subFsFileDescriptor);if(l)return await l.write(i,n,a,s);throw new Error(`File handle not found: ${r.subFsFileDescriptor}`)}async ftruncate(r,i){let n=this.openFh.get(r.subFsFileDescriptor);if(n)return await n.truncate(i)}resolvePath(r){throw new Error(`resolvePath is not implemented: resolvePath(${r})`)}async fstat(r,i){let n=this.openFh.get(r.subFsFileDescriptor);if(n)return await n.stat(i);throw new Error(`File handle not found: ${r.subFsFileDescriptor}`)}async futimes(r,i,n){let a=this.openFh.get(r.subFsFileDescriptor);if(a)return await a.utimes(i,n)}async writev(r,i,n){let a=this.openFh.get(r.subFsFileDescriptor);if(a)return await a.writev(i,n??void 0);throw new Error(`File handle not found: ${r.subFsFileDescriptor}`)}async readv(r,i,n){let a=this.openFh.get(r.subFsFileDescriptor);if(a)return await a.readv(i,n??void 0);throw new Error(`File handle not found: ${r.subFsFileDescriptor}`)}async readFile(r,i){return typeof r=="string"||Buffer.isBuffer(r)?this.targetFs.readFile(r.toString(),i):super.readFile(r,i)}async writeFile(r,i,n){let a=typeof n=="object"&&n.flag?n.flag:"w",s=await this.targetFs.open(r,a);try{let l;if(typeof i=="string"){let u=typeof n=="object"&&n.encoding?n.encoding:"utf8";l=Buffer.from(i,u)}else Buffer.isBuffer(i)?l=i:l=Buffer.from(i);await s.write(l,0,l.length,0)}finally{await this.targetFs.close(s)}}};o(Qs,"PassThroughSubFs");var Uu=Qs;var rf=le(ue(),1);import*as nf from"path";import{createFsFromVolume as Dx,Volume as Rx}from"memfs";var tf=class tf{constructor(t){this.routes=t;$(this,"compiledRoutes");let r={},i=o((n,a)=>{if(typeof n.type=="string"){r[a]={handler:n,siblings:[]};let s=n}else{let s=[];for(let[l,u]of Object.entries(n))if(l==="."){if(r[a])throw new Error(`Conflict: multiple handlers for path '${a}', '.' and optional '[[parameter_name]]' defined?`);r[a]={handler:u,siblings:s}}else if(l.startsWith("[[")&&l.endsWith("]]")){if(r[a])throw new Error(`Conflict: multiple handlers for path '${a}', '.' and optional '[[parameter_name]]' defined?`);r[a]={handler:u,siblings:s},l.startsWith("[[...")?r[a?`${a}/${l}`:l]={handler:u,siblings:[]}:i(u,a?`${a}/${l}`:l)}else l.startsWith("[")&&l.endsWith("]")?l.startsWith("[...")?r[a?`${a}/${l}`:l]={handler:u,siblings:[]}:i(u,a?`${a}/${l}`:l):(s.push({segment:l,type:u["."]?"folder":"file"}),i(u,a?`${a}/${l}`:l))}},"walk");i(t,""),this.compiledRoutes=Object.entries(r).map(([n,a])=>{let s=[],l=n.split("/").map(c=>{if(c.startsWith("[[")&&c.endsWith("]]")){let f=c.slice(2,-2).replace(/^\.\.\./,"");return s.push(f),"(.*)"}if(c.startsWith("[")&&c.endsWith("]")){let f=c.slice(1,-1);return s.push(f),"([^/]+)"}return c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}).join("/");return{regex:new RegExp(`^${l}$`),paramNames:s,staticSiblings:a.siblings,handler:a.handler}})}match(t){t.length>1&&t.endsWith("/")&&(t=t.replace(/\/+$/,""));for(let{regex:r,paramNames:i,handler:n,staticSiblings:a}of this.compiledRoutes){let s=t.match(r);if(!s)continue;let l={};for(let u=0;u<i.length;u++)l[i[u]]=decodeURIComponent(s[u+1]||"");return{handler:n,params:l,staticSiblings:a}}}};o(tf,"LegitPathRouter");var Ko=tf;var St=le(ue(),1);var Ax=new Set([" ","~","^",":","?","*","[","\\"]),Ox=[/^\/|\/$/,/\/\//,/\.$/,/\.lock$/,/^@$/,/@\{/],Py="\u2002";function xy(e){let t=e.codePointAt(0);return!(t>=0&&t<=31||t===127||Ax.has(e))}o(xy,"isValidChar");function Ty(e){let t="";for(let r of e)r===" "?t+=Py:xy(r)?t+=r:t+="%"+r.codePointAt(0);for(let r of Ox)if(r.test(t))return Array.from(t).map(i=>xy(i)?i:"%"+i.codePointAt(0)).join("");return t}o(Ty,"encodeName");function Ay(e){return e.replace(/%(\d+)/g,(t,r)=>String.fromCodePoint(parseInt(r,10))).replace(new RegExp(Py,"g")," ")}o(Ay,"decodeName");function ar(e){return e.replace(/\./g,"%2E").replace(/\//g,".")}o(ar,"encodeBranchNameForVfs");function pe(e){return e.replace(/\./g,"/").replace(/%2E/g,".")}o(pe,"decodeBranchNameFromVfs");async function V(e,t,r,i){try{return await St.default.resolveRef({fs:e,dir:t,ref:`refs/heads/${pe(r)}`})}catch{return}}o(V,"tryResolveRef");async function $t({dir:e,fs:t,treeOid:r,deletePathParts:i,addPathParts:n,addObj:a,addKeepIfEmpty:s,deleteKeepIfNotEmpty:l,keepFilename:u=".keep",gitCache:c}){let[f,...d]=n??[],[h,...p]=i??[],m=[];if(r){let{tree:w}=await St.default.readTree({fs:t,dir:e,oid:r,cache:c||{}});m=[...w]}if(f===h){let w=f;if(w===void 0)throw new Error("illegal arguement - called with out a path part");if(d.length===0)throw new Error("can not move into it self");if(p.length===0)throw new Error("can not move from it self");let y=m.findIndex(S=>S.path===w),_=(y!==-1?m[y]:void 0)?.oid,k=await $t({dir:e,fs:t,treeOid:_,addPathParts:d,deletePathParts:p,addObj:a,addKeepIfEmpty:s,deleteKeepIfNotEmpty:l});if(k===void 0)throw new Error("on the same path we expect an update - respectivly a newly created subTreeOid");let F=!1;if(k!==_){F=!0;let S={mode:"040000",path:w,oid:k,type:"tree"};y!==-1?m[y]=S:m.push(S)}if(r==null&&!F)throw new Error("Illegal state - if the currentOid is undefined - a new tree should have been created (an update should have happened)");if(F)return await St.default.writeTree({fs:t,dir:e,tree:m});if(r===void 0)throw new Error("currentOid should be set - since the sub tree didn't exist and ");return r}else{let w=!1,y;if(h){let g=m.findIndex(k=>k.path===h),_=g!==-1?m[g]:void 0;if(_===void 0)throw new Error("Element doesnt exist in tree");if(p.length>0){if(_&&_.type!=="tree")throw new Error("SubPart of the path for the obj to delete is not a tree");let k=await $t({dir:e,fs:t,treeOid:_.oid,addPathParts:void 0,deletePathParts:p,addObj:a,addKeepIfEmpty:s,deleteKeepIfNotEmpty:l});if(k===_.oid)throw new Error("in case of a delete we expect a different subtree oid");w=!0,k===void 0?m.splice(g,1):m[g]={mode:"040000",path:h,oid:k,type:"tree"}}else if(w=!0,m.splice(g,1),m.length===0&&s){let k=new Uint8Array(0),F=await St.default.writeBlob({fs:t,dir:e,blob:k});m.push({mode:"100644",oid:F,path:u,type:"blob"})}y=_}if(f){let g=m.findIndex(k=>k.path===f),_=g!==-1?m[g]:void 0;if(d.length>0){if(_&&_.type!=="tree")throw new Error("SubPart of the path for the obj to add is not a tree");let k=await $t({dir:e,fs:t,treeOid:_?.oid,addPathParts:d,deletePathParts:void 0,addObj:a,addKeepIfEmpty:s,deleteKeepIfNotEmpty:l});if(k===void 0)throw new Error("in case we add, we expect an update - respectivly a newly created subTreeOid");if(k!==_?.oid){w=!0;let F={mode:"040000",path:f,oid:k,type:"tree"};if(g!==-1)m[g]=F;else if(m.push(F),l&&m.length>1){let S=m.findIndex(P=>P.path===u);S!==-1&&m.splice(S,1)}}}else{if(w=!0,a){let k={mode:a.type==="tree"?"040000":"100644",path:f,oid:a.oid,type:a.type};if(g!==-1)m[g]=k;else{if(l&&m.length>0){let F=m.findIndex(S=>S.path===u);F!==-1&&m.splice(F,1)}m.push(k)}}if(s&&m.length===0){let k=new Uint8Array(0),F=await St.default.writeBlob({fs:t,dir:e,blob:k});m.push({mode:"100644",oid:F,path:u,type:"blob"})}}}if(m.length===0)return;if(w)return await St.default.writeTree({fs:t,dir:e,tree:m});if(r===void 0)throw new Error("currentOid should be set - since the sub tree didn't exist and ");return r}}o($t,"buildUpdatedTree");async function Oy(e,t,r,i,n=0,a={}){let{tree:s}=await St.default.readTree({fs:e,dir:t,oid:r,cache:a});if(i.length===n)return{type:"tree",entries:s.map(c=>De({parent:i.join("/"),name:c.path,isDir:c.type==="tree"})),oid:r};let l=i[n],u=s.find(c=>c.path===l);if(u){if(i.length===n+1){if(u.type==="blob")return{type:"blob",oid:u.oid};if(u.type==="tree"){let c=await St.default.readTree({fs:e,dir:t,oid:u.oid,cache:a});return{type:"tree",entries:c.tree.map(f=>De({parent:i.join("/"),name:f.path,isDir:f.type==="tree"})),oid:c.oid}}}else if(u.type==="tree")return await Oy(e,t,u.oid,i,n+1,a)}}o(Oy,"findGitObjectAtPath");async function Ar({filePath:e,gitRoot:t,nodeFs:r,commitSha:i,pathParams:n,gitCache:a}){let s=a||{};if(!n.filePath){let c=await St.default.readTree({fs:r,dir:t,oid:i,cache:s});return{type:"tree",entries:c.tree.map(d=>De({parent:e,name:d.path,isDir:d.type==="tree"})),oid:c.oid}}let l=n.filePath?n.filePath.split("/"):[];return await Oy(r,t,i,l,0,s)}o(Ar,"resolveGitObjAtPath");function De(e){return{name:e.name,isFile:o(()=>!e.isDir,"isFile"),isDirectory:o(()=>e.isDir,"isDirectory"),isBlockDevice:o(()=>!0,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isFIFO:o(()=>!1,"isFIFO"),isSocket:o(()=>!1,"isSocket"),parentPath:e.parent,path:e.parent}}o(De,"toDirEntry");var qn=class qn extends Ze{constructor({name:r,parentFs:i,gitStorageFs:n,gitRoot:a,routerConfig:s}){super({name:r,parentFs:i,gitRoot:a});$(this,"pathRouter");$(this,"memFs");$(this,"openFh",{});$(this,"storageFs");this.pathRouter=new Ko(s),this.gitRoot=a,this.storageFs=n,this.memFs=Dx(new Rx)}async getAuthor(){let r=await rf.default.getConfig({fs:this.storageFs,dir:this.gitRoot,path:"user.name"}),i=await rf.default.getConfig({fs:this.storageFs,dir:this.gitRoot,path:"user.email"}),n=Math.floor(Date.now()/1e3),a=new Date().getTimezoneOffset();return{name:r,email:i,date:n,timezoneOffset:a}}async responsible(r){return!0}getRouteHandler(r){let i=r;this.gitRoot&&r.startsWith(this.gitRoot)&&(this.gitRoot==="/"?i=r.slice(this.gitRoot.length):i=r.slice(this.gitRoot.length+1));let n=i.indexOf(`/${qn.LEGIT_DIR}`);if(n===-1)return this.pathRouter.match(i);let a=i.slice(n+1);return this.pathRouter.match(i)}async open(r,i,n){let a=this.getRouteHandler(r);if(!a)throw new Error("Not a virtual legit file");if(!(a?.handler.writeFile!==void 0)&&(i.includes("w")||i.includes("a")))throw new Error(`Write operations not allowed for ${a?.handler.type}`);if(i.includes("x")&&a?.handler.type!=="gitBranchFileVirtualFile"&&a?.handler.type!=="claudeVirtualSessionFileVirtualFile")throw new Error(`Exclusive operations not allowed for ${a?.handler.type}`);let l=await this.getAuthor(),u=await a.handler.getFile({cacheFs:this.memFs,filePath:r,userSpaceFs:this.compositFs,gitRoot:this.gitRoot,nodeFs:this.storageFs,pathParams:a.params,author:l}),c=!1;for(let m of Object.values(this.openFh))m.path===r&&(c=!0);if((u||c)&&i.includes("x"))throw Object.assign(new Error(`EEXIST: file already exists, open '${r}'`),{code:"EEXIST",errno:-17,syscall:"open",path:r});if(!u&&!c&&!(i.includes("w")||i.includes("a")))throw Object.assign(new Error(`ENOENT: no such file or directory, open '${r}'`),{code:"ENOENT",errno:-2,syscall:"open",path:r});let f=nf.dirname(r);if(await this.memFs.promises.mkdir(f,{recursive:!0}),u===void 0&&!i.includes("x")||u&&u.type==="file")try{let m=await this.memFs.promises.access(r)}catch{await this.memFs.promises.writeFile(r,"")}let d=await this.memFs.promises.open(r,i,n),h=d.fd,p=new it({fs:this,compositeFs:this.compositFs,subFsFileDescriptor:h,parentFsFileDescriptors:[]});return this.openFh[h]={path:r,mode:i,fh:d,openSha:u?.oid,readSha:void 0,unflushed:[]},(i.includes("x")||i.includes("w"))&&this.openFh[h].unflushed.push({length:0,start:0}),p}async mkdir(r,i){let n=r.toString(),a=this.getRouteHandler(n),s=i?{options:i}:{};try{let l=await this.getAuthor();await a?.handler.mkdir({cacheFs:this.memFs,filePath:r.toString(),userSpaceFs:this.compositFs,nodeFs:this.storageFs,gitRoot:this.gitRoot,pathParams:a.params,...s,author:l});let u=typeof i=="object"?{...i,recursive:!0}:{recursive:!0};await this.memFs.promises.mkdir(r,u);let c=n.split("/"),f="";for(let d=1;d<=c.length;d++){f=c.slice(0,d).join("/");try{if((await this.memFs.promises.stat(f)).isDirectory()){let p=await this.memFs.promises.open(f,"r");this.openFh[p.fd]={path:f,mode:"r",fh:p,openSha:void 0,readSha:void 0,unflushed:[]}}}catch{}}}catch(l){throw l}}async access(r,i){await this.stat(r)}async futimes(r,i,n){let a=this.openFh[r.subFsFileDescriptor];if(!a)throw new Error("Invalid file handle");return await a.fh.utimes(i,n)}async fstat(r,i){let n=this.openFh[r.subFsFileDescriptor];if(!n)throw new Error("Invalid file handle");return this.stat(n.path,i)}async ftruncate(r,i){let n=this.openFh[r.subFsFileDescriptor];if(!n)throw new Error("Invalid file handle");return n.unflushed.push({length:0,start:0}),await n.fh.truncate(i)}async stat(r,i){let n=r.toString(),a=Object.values(this.openFh).find(c=>c.path===n&&c.unflushed.length>0);if(a&&a.unflushed.length>0)return await a.fh.stat(i);let s=this.getRouteHandler(n);if(!s)throw new Error(`ENOENT: no such file or directory, stat '${n}'`);let l=await this.getAuthor();return await s.handler.getStats({cacheFs:this.memFs,filePath:n,userSpaceFs:this.compositFs,gitRoot:this.gitRoot,nodeFs:this.storageFs,pathParams:s.params,author:l})}async lstat(r,i){return this.stat(r,i)}async readdir(r,i){let n=r.toString(),a=this.getRouteHandler(n);if(!a)throw new Error(`ENOENT: no such file or directory, scandir '${n}'`);let s=await this.getAuthor(),l=await a?.handler.getFile({cacheFs:this.memFs,filePath:n,userSpaceFs:this.compositFs,gitRoot:this.gitRoot,nodeFs:this.storageFs,pathParams:a.params,author:s});if(l){if(l.type!=="directory")throw new Error("not a folder");let u=a?.staticSiblings??[],c=Array.from(new Set([...l.content,...u.map(f=>De({name:f.segment,parent:n,isDir:f.type==="folder"}))])).sort((f,d)=>f.name.localeCompare(d.name,void 0,{numeric:!0,sensitivity:"base"}));return i?.withFileTypes?c:c.map(f=>f.name)}return[]}async read(r,i,n,a,s){let l=r.subFsFileDescriptor,u=this.openFh[l];if(!u)throw new Error("Invalid file handle");if(u.unflushed.length===0){let c=this.getRouteHandler(u.path),f=await this.getAuthor(),d=await c.handler.getFile({cacheFs:this.memFs,filePath:u.path,userSpaceFs:this.compositFs,gitRoot:this.gitRoot,nodeFs:this.storageFs,pathParams:c?.params,author:f});if(!d?.content)throw new Error("couldnt access content");if(d.type!=="file")throw new Error("not a file");let h=typeof d.content=="string"?Buffer.from(d.content):d.content,p=typeof s=="number"?s:0,m=Math.min(p+a,h.length),w=Math.max(0,m-p);return h.copy(i,n,p,p+w),{bytesRead:w,buffer:i}}return await u.fh.read(i,n,a,s)}async write(r,i,n,a,s){let l=this.openFh[r.subFsFileDescriptor];if(!l)throw new Error("Invalid file handle");let u=l.mode;if(!u.includes("w")&&!u.includes("a")&&!u.includes("+"))throw Object.assign(new Error("EBADF: bad file descriptor, write"),{code:"EBADF",errno:-9,syscall:"write"});if(l.unflushed.length===0){let h=this.getRouteHandler(l.path),p=await this.getAuthor(),m=await h.handler.getFile({cacheFs:this.memFs,filePath:l.path,userSpaceFs:this.compositFs,gitRoot:this.gitRoot,nodeFs:this.storageFs,pathParams:h.params,author:p});m&&m.oid&&(await this.memFs.promises.writeFile(l.path,m.content),l.readSha=m.oid)}let c=await l.fh.write(i,n,a,s),f=n??0,d=s??0;return l.unflushed.push({start:d,length:a||i.byteLength-f+d}),c}async close(r){let i=r.subFsFileDescriptor,n=this.openFh[i];if(!n)throw new Error("Invalid file handle");try{await this.dataSync(r),await n.fh.close()}finally{delete this.openFh[i]}}async dataSync(r){let i=r.subFsFileDescriptor,n=this.openFh[i];if(!n)throw new Error("Invalid file handle");if(n.unflushed.length>0){let a=this.getRouteHandler(n.path);if(a&&a.handler.writeFile){let s=await this.memFs.promises.readFile(n.path),l=await this.getAuthor();await a.handler.writeFile({cacheFs:this.memFs,filePath:n.path,userSpaceFs:this.compositFs,gitRoot:this.gitRoot,nodeFs:this.storageFs,content:s,pathParams:a.params,author:l})}n.unflushed=[]}}async readFile(r,i){let n=typeof r=="string"?r:Buffer.isBuffer(r)?r.toString():r.fd?`FileHandle(${r.fd})`:r.toString(),a=null;typeof i=="string"?a=i:i&&typeof i=="object"&&i.encoding&&(a=i.encoding);let s=await this.open(n,"r");try{let u=(await this.fstat(s)).size,c=Buffer.alloc(u);return await this.read(s,c,0,u,0),await this.close(s),a?c.toString(a):c}catch(l){try{await this.close(s)}catch{}throw l}}async writeFile(r,i,n){let a="w",s="utf8",l;typeof n=="string"?s=n:n&&typeof n=="object"&&(n.flag&&(a=String(n.flag)),n.encoding&&(s=n.encoding),n.mode&&(l=typeof n.mode=="string"?parseInt(n.mode,8):n.mode));let u=await this.open(r,a,l);try{let c;typeof i=="string"?c=Buffer.from(i,s):Buffer.isBuffer(i)?c=i:i instanceof Uint8Array?c=Buffer.from(i):ArrayBuffer.isView(i)?c=Buffer.from(i.buffer,i.byteOffset,i.byteLength):c=Buffer.from(i),await this.write(u,c,0,c.length,0)}finally{await this.close(u)}}async rename(r,i){let n=r.toString(),a=i.toString(),s=this.getRouteHandler(n),l=this.getRouteHandler(a);if(s?.handler.type==="gitBranchFileVirtualFile"&&l?.handler.type==="gitBranchFileVirtualFile"){let u=!0;try{await this.memFs.promises.access(a)}catch{u=!1}let c=!0;try{await this.stat(a)}catch{c=!1}let f=!0;try{await this.stat(n)}catch{f=!1}let d=!0;try{await this.memFs.promises.access(n)}catch{d=!1}if(d){let w=nf.dirname(a);try{await this.memFs.promises.access(w)}catch{await this.memFs.promises.mkdir(w,{recursive:!0})}await this.memFs.promises.rename(r,i)}let h=this.getRouteHandler(n);if(!h)throw new Error("VF not found");let p=await this.getAuthor(),m=await h.handler.rename({cacheFs:this.memFs,filePath:n,userSpaceFs:this.compositFs,gitRoot:this.gitRoot,nodeFs:this.storageFs,newPath:a,pathParams:h?.params??{},newPathParams:l?.params??{},author:p})}else throw new Error(`Unsupported rename operation from ${s?.handler.type} to ${l?.handler.type}`)}async fchmod(r,i){}async unlink(r){let i=r.toString(),n=this.getRouteHandler(i);if(n?.handler.unlink!==void 0)try{let a=await this.getAuthor();await n.handler.unlink({cacheFs:this.memFs,filePath:i,userSpaceFs:this.compositFs,nodeFs:this.storageFs,gitRoot:this.gitRoot,pathParams:n.params,author:a})}catch(a){let s=!1;for(let[l,u]of Object.entries(this.openFh))u.path===i&&u.unflushed.length>0&&(s=!0);if(!s)throw a}finally{let a=!1;for(let[s,l]of Object.entries(this.openFh))l.path===i&&(a=!0,await l.fh.close(),delete this.openFh[Number(s)]);a&&await this.memFs.promises.unlink(i)}else throw new Error(`Cannot unlink ${n?.handler.type} files`)}async rmdir(r,...i){let n=r.toString(),a=this.getRouteHandler(n);if(a?.handler.rmdir!==void 0){let s=await this.getAuthor();await a.handler.rmdir({cacheFs:this.memFs,filePath:n,userSpaceFs:this.compositFs,nodeFs:this.storageFs,gitRoot:this.gitRoot,pathParams:a.params,author:s});let l=!1;for(let[u,c]of Object.entries(this.openFh))c.path===n&&(l=!0,await c.fh.close(),delete this.openFh[Number(u)]);l&&await this.memFs.promises.rmdir(n,{recursive:!0})}else throw new Error(`Cannot rmdir
|
|
99
|
-
${a?.handler.type} directories`)}fileType(){return 10}};o(qn,"GitSubFs"),$(qn,"LEGIT_DIR",".legit");var Yo=qn;var Or=le(ue(),1);var Dy=le(ue(),1);var af="-operation";async function Re(e,t,r){return(await Dy.default.listBranches({fs:e,dir:t})).filter(n=>n.endsWith("__"+r+af))[0]}o(Re,"resolveOperationBranchName");var Xo=le(ue(),1);async function K(e,t){try{let r=await Xo.default.getConfig({fs:t,dir:e,path:"user.legit-current-branch"});if(r)return ar(r)}catch{}try{let r=await Xo.default.getConfig({fs:t,dir:e,path:"init.defaultBranch"});return ar(r)||"main"}catch{return"main"}}o(K,"getCurrentBranch");async function Ry(e,t,r){await Xo.default.setConfig({fs:t,dir:e,path:"user.legit-current-branch",value:pe(r)})}o(Ry,"setCurrentBranch");var Jo={type:"gitBranchOperationsVirtualFile",rootType:"file",getStats:o(async e=>{let{gitRoot:t,nodeFs:r,pathParams:i}=e;i.branchName===void 0&&(i.branchName=await K(t,r));let n=await Re(r,t,i.branchName),a,s=!1;if(n)try{a=await Or.default.resolveRef({fs:r,dir:t,ref:n}),s=!0}catch{try{a=await Or.default.resolveRef({fs:r,dir:t,ref:`refs/heads/${n}`}),s=!0}catch{throw new Error(`Base Branch ${i.branchName} for operations does not exis`)}}else try{a=await Or.default.resolveRef({fs:r,dir:t,ref:`refs/heads/${i.branchName}`})}catch{throw new Error(`Base Branch ${i.branchName} for operations does not exis`)}let l=await Or.default.readCommit({fs:r,dir:t,oid:a}),{commit:u}=l,c=u.committer.timestamp*1e3;try{return{mode:420,size:(s?await Jo.getFile(e):void 0)?.content?.length??0,atimeMs:c,mtimeMs:c,ctimeMs:c,birthtimeMs:c,atime:new Date(c),mtime:new Date(c),ctime:new Date(c),birthtime:new Date(c),isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:0}}catch{throw new Error("ENOENT: no such file or directory, stat operationHistory")}},"getStats"),getFile:o(async e=>{let{gitRoot:t,nodeFs:r,pathParams:i}=e;i.branchName===void 0&&(i.branchName=await K(t,r));let n=await Re(r,t,i.branchName),a=[];if(n){let u=await Or.default.resolveRef({fs:r,dir:t,ref:`refs/heads/${n}`}),c=!1,f=u;for(;f&&!c;){let d=await Or.default.readCommit({fs:r,dir:t,oid:f});a.push({oid:d.oid,parentOids:d.commit.parent,message:d.commit.message,originBranchOid:"unset"}),f=d.commit.parent&&d.commit.parent.length>0?d.commit.parent[0]:null,d.commit.parent.length===2&&d.commit.parent[0]===d.commit.parent[1]&&(c=!0)}}let s;for(let u=a.length-1;u>=0;u--){let c=a[u];if(s===void 0){if(c.parentOids.length!==2&&c.parentOids[0]!==c.parentOids[1])throw new Error(`Operation commit ${c.oid} does not have two parents as expected`);s=c.parentOids[1]}c.parentOids.length===2&&(s=c.parentOids[1]),c.originBranchOid=s}let l=Buffer.from(JSON.stringify(a,null,2),"utf-8");return{type:"file",content:l,mode:420,size:l.length}},"getFile"),rename:o(async function(e){throw new Error("not implemented")},"rename"),mkdir:o(async function(e){throw new Error("not implemented")},"mkdir")};var Ie=le(ue(),1);var Q_=le(Zy(),1);function hR(e){let t=[e];return{next(){return Promise.resolve({done:t.length===0,value:t.pop()})},return(){return t=[],{}},[Symbol.asyncIterator](){return this}}}o(hR,"fromValue");function pR(e){return e[Symbol.asyncIterator]?e[Symbol.asyncIterator]():e[Symbol.iterator]?e[Symbol.iterator]():e.next?e:hR(e)}o(pR,"getIterator");async function ev(e,t){let r=pR(e);for(;;){let{value:i,done:n}=await r.next();if(i&&await t(i),n)break}r.return&&r.return()}o(ev,"forAwait");function mR(e){let{PassThrough:t}=J_(),r=new t;return setTimeout(async()=>{await ev(e,i=>r.write(i)),r.end()},1),r}o(mR,"asyncIteratorToStream");async function wR(e){let t=0,r=[];await ev(e,a=>{r.push(a),t+=a.byteLength});let i=new Uint8Array(t),n=0;for(let a of r)i.set(a,n),n+=a.byteLength;return i}o(wR,"collect");function gR(e){let t=Object.getOwnPropertyDescriptor(e,Symbol.asyncIterator);if(t&&t.enumerable)return e;let r=!1,i=[],n={};return e.on("data",a=>{i.push(a),n.resolve&&(n.resolve({value:i.shift(),done:!1}),n={})}),e.on("error",a=>{n.reject&&(n.reject(a),n={})}),e.on("end",()=>{r=!0,n.resolve&&(n.resolve({done:!0}),n={})}),{next(){return new Promise((a,s)=>{if(i.length===0&&r)return a({done:!0});if(i.length>0)return a({value:i.shift(),done:!1});i.length===0&&!r&&(n={resolve:a,reject:s})})},return(){e.removeAllListeners(),e.destroy&&e.destroy()},[Symbol.asyncIterator](){return this}}}o(gR,"fromNodeStream");async function yR({onProgress:e,url:t,method:r="GET",headers:i={},agent:n,body:a}){return a&&Array.isArray(a)?a=Buffer.from(await wR(a)):a&&(a=mR(a)),new Promise((s,l)=>{(0,Q_.default)({url:t,method:r,headers:i,agent:n,body:a},(u,c)=>{if(u)return l(u);try{let f=gR(c);s({url:c.url,method:c.method,statusCode:c.statusCode,statusMessage:c.statusMessage,body:f,headers:c.headers})}catch(f){l(f)}})})}o(yR,"request");var bR={request:yR},Rs=bR;var ur="legit",tv=o(({fs:e,gitRepoPath:t,serverUrl:r="https://hub.legitcontrol.com",auth:i,anonymousBranch:n,authHeaderPrefix:a="Bearer "})=>{let s=!1;async function l(y){let g=await i.getMaxAccessTokenForBranch(y);if(!g)throw new Error(`No access token for branch ${y}`);await Ie.default.fetch({fs:e,http:Rs,dir:t,singleBranch:!0,ref:`${y}`,remote:ur,url:r,headers:{Authorization:`${a}${g}`}});let _=await Ie.default.resolveRef({fs:e,dir:t,ref:`${ur}/${y}`});await Ie.default.writeRef({fs:e,dir:t,ref:`refs/heads/${y}`,value:_})}o(l,"loadBranch");let u=[];async function c(){let y=await i.getMaxAccessTokenForBranch("todo");await Ie.default.fetch({fs:e,http:Rs,dir:t,remote:ur,url:r,headers:{Authorization:`${a}${y}`}});let g=await Ie.default.listBranches({fs:e,dir:t});for(let _ of g){if(_===n)continue;let k=`${ur}/${_}`,F,S;try{F=await Ie.default.resolveRef({fs:e,dir:t,ref:_})}catch(P){console.log(`Could not resolve local ref ${_}:`,P)}try{S=await Ie.default.resolveRef({fs:e,dir:t,ref:k})}catch{S=void 0}if(F&&S){if(F!==S){let P=await Ie.default.findMergeBase({fs:e,dir:t,oids:[F,S]});if(P[0]!==F&&P[0]!==S){let b=await Ie.default.merge({fs:e,dir:t,ours:F,theirs:S,fastForwardOnly:!1,abortOnConflict:!1,author:{name:"Your Name",email:"your.email@example.com"},mergeDriver:o(async({branches:x,contents:v,path:A})=>{let[T,R,B]=v;return console.log(`Merging ${x[0]} with ${x[1]}...`),console.log("merged:"),console.log(v),{cleanMerge:!0,mergedText:B===void 0?R:B}},"mergeDriver")});await Ie.default.writeRef({fs:e,dir:t,ref:`refs/heads/${_}`,value:b.oid,force:!0})}P[0]===F?(console.log(`branch ${_} differs - remote ahaed, not behind`),await Ie.default.writeRef({fs:e,dir:t,ref:`refs/heads/${_}`,value:S,force:!0})):P[0]===S?(console.log(`branch ${_} differs - local ahead, not behind`),u.push(_)):(console.log(`branch ${_} differs - both changed`),u.push(_))}}else F&&!S&&u.push(_)}}o(c,"pull");async function f(y){if((await i.getUser()).type!=="local")for(let g of y){let _=await i.getMaxAccessTokenForBranch(g);await Ie.default.push({fs:e,http:Rs,dir:t,remote:ur,url:r,ref:g,headers:{Authorization:`Bearer ${_}`}})}}o(f,"push");let d=Promise.resolve();async function h(y){d=d.then(()=>f(y)),await d}o(h,"sequentialPush");async function p(){await Ie.default.getConfig({fs:e,dir:t,path:`remote.${ur}.fetch`})||await Ie.default.setConfig({fs:e,dir:t,path:`remote.${ur}.fetch`,value:`+refs/heads/*:refs/remotes/${ur}/*`});try{await c();let g=[...new Set(u)].filter(_=>_.indexOf(n)===-1);await h(g),u=[]}catch(g){console.error("Error monitoring changes:",g)}finally{s&&setTimeout(p,1e3)}}o(p,"pullPushTick");function m(){s=!0,p()}o(m,"startSync");function w(){s=!1}return o(w,"stopSync"),{start:o(()=>{s||(m(),s=!0)},"start"),stop:o(()=>{w()},"stop"),isRunning:o(()=>s,"isRunning"),loadBranch:l,sequentialPush:h}},"createLegitSyncService");var Pe=le(ue(),1);import{createFsFromVolume as _R,Volume as vR}from"memfs";var rv=o((e,t)=>{let r={type:"local",id:"local",name:"Local User",email:"local@legitcontrol.com"};return{getUser:o(async()=>r,"getUser"),signInAnonymously:o(async()=>{r.type="anonymous",r.id=crypto.randomUUID(),r.email=`anonymous-sha1-${r.id}-@legitcontrol.com`},"signInAnonymously"),addAccessToken:o(async i=>{let n=await e.getUserTokens(r.id);n.accessTokens.push(i),await e.setUserTokens(r.id,n)},"addAccessToken"),getMaxAccessTokenForBranch:o(async i=>{let n=await e.getUserTokens(r.id);if(!(n.accessTokens===void 0||n.accessTokens.length===0))return n.accessTokens[0]},"getMaxAccessTokenForBranch")}},"createSessionManager");var Au=le(ue(),1);function iv(e){let t=JSON.stringify(e),r=new TextEncoder().encode(t),i="";return typeof btoa=="function"?i=btoa(String.fromCharCode(...r)):i=Buffer.from(r).toString("base64"),i.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}o(iv,"encodeConfigJson");function nv(e){let t=e.replace(/-/g,"+").replace(/_/g,"/")+"===".slice((e.length+3)%4),r;typeof atob=="function"?r=atob(t):r=Buffer.from(t,"base64").toString("binary");let i=Uint8Array.from(r,a=>a.charCodeAt(0)),n=new TextDecoder().decode(i);return JSON.parse(n)}o(nv,"decodeConfigJson");var av="user.legit-tokens";function ov({storageFs:e,gitRoot:t}){return{getUserTokens:o(async r=>{let i=await Au.default.getConfig({fs:e,dir:t,path:av});return i?nv(i):{accessTokens:[]}},"getUserTokens"),setUserTokens:o(async(r,i)=>await Au.default.setConfig({fs:e,dir:t,path:av,value:iv(i)}),"setUserTokens")}}o(ov,"createGitConfigTokenStore");var Y=le(ue(),1);var Cs=class Cs extends Error{constructor(r,i){super(r);$(this,"code","ENOENT");$(this,"path");this.name="ENOENTError",this.path=i,Object.setPrototypeOf(this,Cs.prototype)}};o(Cs,"ENOENTError");var Hr=Cs;function Is(e){return e&&e.gitCache!==void 0?e.gitCache:e&&e.parentFs?Is(e.parentFs):{}}o(Is,"getGitCacheFromFs");var Bs={type:"gitBranchFileVirtualFile",rootType:"folder",getStats:o(async({gitRoot:e,nodeFs:t,filePath:r,cacheFs:i,pathParams:n,userSpaceFs:a})=>{n.branchName===void 0&&(n.branchName=await K(e,t));let s=await V(t,e,n.branchName);if(!s)throw new Hr(`ENOENT: no such file or directory, stat '${r}'`,r);let l=await Ar({filePath:r,gitRoot:e,nodeFs:t,commitSha:s,pathParams:n,gitCache:Is(a)});if(!l)throw new Hr(`ENOENT: no such file or directory, stat '${r}'`,r);let u=await Y.default.readCommit({fs:t,dir:e,oid:s}),{commit:c}=u,f=await Y.default.log({fs:t,dir:e,ref:s,filepath:n.filePath,depth:1}),d=c.committer.timestamp*1e3,h=f.length>0?f[0].commit.committer.timestamp*1e3:d;if(l.type==="tree")return{mode:420,size:0,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!0,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:0,atimeMs:h,mtimeMs:h,ctimeMs:h,birthtimeMs:d,atime:new Date(h),mtime:new Date(h),ctime:new Date(h),birthtime:new Date(h)};{let{blob:p}=await Y.default.readBlob({fs:t,dir:e,oid:l.oid});return{mode:420,size:p.length,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:Math.ceil(p.length/4096),atimeMs:h,mtimeMs:h,ctimeMs:h,birthtimeMs:h,atime:new Date(h),mtime:new Date(h),ctime:new Date(h),birthtime:new Date(h)}}},"getStats"),getFile:o(async({filePath:e,gitRoot:t,nodeFs:r,cacheFs:i,pathParams:n,userSpaceFs:a})=>{n.branchName===void 0&&(n.branchName=await K(t,r));try{let s=await V(r,t,n.branchName);if(!s){let u=await Y.default.resolveRef({fs:r,dir:t,ref:"HEAD"});if(await Y.default.branch({fs:r,dir:t,ref:n.branchName,object:u}),s=await V(r,t,n.branchName),!s)throw new Error("Could not create branch for getFile")}let l=await Ar({filePath:e,gitRoot:t,nodeFs:r,commitSha:s,pathParams:n,gitCache:Is(a)});if(!l)return;if(l.type==="blob"){let{blob:u}=await Y.default.readBlob({fs:r,dir:t,oid:l.oid});return{type:"file",content:Buffer.from(u),mode:420,size:u.length,oid:l.oid}}else{let u=[];try{let f=await i.promises.stat(e);if(f&&f.isDirectory()){let d=await i.promises.readdir(e,{withFileTypes:!0});u.push(...d)}}catch{}return{type:"directory",content:Array.from(new Set([...u,...l.entries])).map(f=>({...f,name:f.name.toString(),path:`${e}`,parentPath:`${e}`})),mode:493}}}catch{return}},"getFile"),unlink:o(async({filePath:e,gitRoot:t,nodeFs:r,cacheFs:i,pathParams:n,author:a})=>{if(n.branchName===void 0&&(n.branchName=await K(t,r)),!n.filePath)throw new Error("filePath should be in pathParams");let s=await V(r,t,n.branchName);if(!s)throw new Error("Invalid branch file path - branch must exist");let l=await Y.default.readTree({fs:r,dir:t,oid:s}),u=await $t({dir:t,fs:r,treeOid:l.oid,deletePathParts:n.filePath.split("/"),addPathParts:void 0,addObj:void 0,deleteKeepIfNotEmpty:!1,addKeepIfEmpty:!0,keepFilename:".keep"});if(u!==l.oid){let c=await Y.default.commit({fs:r,dir:t,message:`Delete ${n.filePath}`,tree:u,noUpdateBranch:!0,parent:[s],author:a});await Y.default.writeRef({fs:r,dir:t,ref:`refs/heads/${pe(n.branchName)}`,value:c,force:!0})}},"unlink"),writeFile:o(async({filePath:e,gitRoot:t,nodeFs:r,content:i,cacheFs:n,pathParams:a,author:s})=>{if(a.branchName===void 0&&(a.branchName=await K(t,r)),a.filePath===void 0)throw new Error("filePath should be in pathParams");let l;typeof i=="string"?l=new TextEncoder().encode(i):l=new Uint8Array(i);let u=await Y.default.writeBlob({fs:r,dir:t,blob:l}),c=await V(r,t,a.branchName);if(!c){let h=await Y.default.resolveRef({fs:r,dir:t,ref:"HEAD"});if(await Y.default.branch({fs:r,dir:t,ref:pe(a.branchName),object:h}),c=await V(r,t,a.branchName),!c)throw new Error("Could not create branch for writeFile")}let f=await Y.default.readTree({fs:r,dir:t,oid:c}),d=await $t({dir:t,fs:r,treeOid:f.oid,deletePathParts:void 0,addPathParts:a.filePath.split("/"),addObj:{type:"blob",oid:u},deleteKeepIfNotEmpty:!0,addKeepIfEmpty:!1,keepFilename:".keep"});if(d!==f.oid){let h=await Y.default.commit({fs:r,dir:t,message:`\u{1F4BE} Change '${a.filePath}'`,tree:d,noUpdateBranch:!0,parent:[c],author:s});await Y.default.writeRef({fs:r,dir:t,ref:`refs/heads/${pe(a.branchName)}`,value:h,force:!0});let p=await V(r,t,a.branchName);if(h!==p)throw new Error("Failed to update branch after file deletion")}},"writeFile"),rename:o(async function({filePath:e,newPath:t,gitRoot:r,nodeFs:i,pathParams:n,newPathParams:a,author:s,userSpaceFs:l}){if(n.branchName===void 0&&(n.branchName=await K(r,i)),n.filePath===void 0)throw new Error("filePath should be in pathParams");if(a.branchName===void 0&&(a.branchName=await K(r,i)),a.filePath===void 0)throw new Error("filePath should be in newPathParams");let u=await V(i,r,n.branchName);if(!u)throw new Error("Invalid branch file path - source branch must exist");let c=await V(i,r,a.branchName);if(!c){let p=await Y.default.resolveRef({fs:i,dir:r,ref:"HEAD"});if(await Y.default.branch({fs:i,dir:r,ref:pe(a.branchName),object:p}),c=await V(i,r,a.branchName),c===void 0)throw new Error("Could not create branch for rename operation")}if(a.branchName!==n.branchName)throw new Error("cross branch move not implemented yet");let f=await Ar({gitRoot:r,nodeFs:i,commitSha:u,filePath:e,pathParams:n,gitCache:Is(l)});if(f===void 0)throw new Error("no obj at path exists");let d=await $t({dir:r,fs:i,deletePathParts:n.filePath.split("/"),addPathParts:a.filePath.split("/"),addObj:f.type==="blob"?{type:"blob",oid:f.oid}:{type:"tree",oid:f.oid,entries:f.entries.map(p=>p.name.toString())},treeOid:c,addKeepIfEmpty:!0,deleteKeepIfNotEmpty:!0}),h=await Y.default.readTree({fs:i,dir:r,oid:u});if(d!==h.oid){let p=await Y.default.commit({fs:i,dir:r,message:`\u{1F500} Rename '${n.filePath}' to '${a.filePath}'`,tree:d,noUpdateBranch:!0,parent:[c],author:s});await Y.default.writeRef({fs:i,dir:r,ref:`refs/heads/${pe(a.branchName)}`,value:p,force:!0})}},"rename"),mkdir:o(async function(e){e.pathParams.branchName===void 0&&(e.pathParams.branchName=await K(e.gitRoot,e.nodeFs));let t=await V(e.nodeFs,e.gitRoot,e.pathParams.branchName);if(e.pathParams.filePath===void 0&&(e.pathParams.filePath="/",t!==void 0))throw new Error("Folder exists");try{throw await Bs.getStats(e),new Error("Folder exists")}catch{}if(e.filePath.endsWith("/")&&(e.filePath=e.filePath.replace(/\/+$/,"")),e.pathParams&&typeof e.pathParams.filePath=="string"&&(e.pathParams.filePath=e.pathParams.filePath.replace(/\/+$/,"")),!t){let s=await Y.default.resolveRef({fs:e.nodeFs,dir:e.gitRoot,ref:"HEAD"});if(await Y.default.branch({fs:e.nodeFs,dir:e.gitRoot,ref:pe(e.pathParams.branchName),object:s}),t=await V(e.nodeFs,e.gitRoot,e.pathParams.branchName),t===void 0)throw new Error("Could not create branch for mkdir operation")}let r=await Y.default.readTree({fs:e.nodeFs,dir:e.gitRoot,oid:t}),i=new Uint8Array(0),n=await Y.default.writeBlob({fs:e.nodeFs,dir:e.gitRoot,blob:i}),a=await $t({dir:e.gitRoot,fs:e.nodeFs,treeOid:r.oid,deletePathParts:void 0,addPathParts:[...e.pathParams.filePath.split("/"),".keep"],addObj:{type:"blob",oid:n},deleteKeepIfNotEmpty:!0,addKeepIfEmpty:!0,keepFilename:".keep"});if(a!==r.oid){let s=await Y.default.commit({fs:e.nodeFs,dir:e.gitRoot,message:`\u{1F4BE} Change '${e.pathParams.filePath}'`,tree:a,noUpdateBranch:!0,parent:[t],author:e.author});await Y.default.writeRef({fs:e.nodeFs,dir:e.gitRoot,ref:`refs/heads/${pe(e.pathParams.branchName)}`,value:s,force:!0})}},"mkdir"),rmdir:o(async({filePath:e,gitRoot:t,nodeFs:r,cacheFs:i,pathParams:n,author:a})=>{if(n.branchName===void 0&&(n.branchName=await K(t,r)),!n.filePath)throw new Error("filePath should be in pathParams");let s=await V(r,t,n.branchName);if(!s)throw new Error("Invalid branch file path - branch must exist");let l=await Y.default.readTree({fs:r,dir:t,oid:s}),u=await $t({dir:t,fs:r,treeOid:l.oid,deletePathParts:n.filePath.split("/"),addPathParts:void 0,addObj:void 0,deleteKeepIfNotEmpty:!1,addKeepIfEmpty:!0,keepFilename:".keep"});if(u!==l.oid){let c=await Y.default.commit({fs:r,dir:t,message:`Delete ${n.filePath}`,tree:u,noUpdateBranch:!0,parent:[s],author:a});await Y.default.writeRef({fs:r,dir:t,ref:`refs/heads/${pe(n.branchName)}`,value:c,force:!0})}},"rmdir")};var Ou=le(ue(),1);var sv={type:"gitBranchesListVirtualFile",rootType:"folder",getStats:o(async({gitRoot:e,nodeFs:t})=>{let r=e+"/.git";try{return await t.promises.stat(r)}catch{throw new Error(`ENOENT: no such file or directory, stat '${r}'`)}},"getStats"),getFile:o(async({gitRoot:e,nodeFs:t,filePath:r})=>{try{let i=await Ou.default.listBranches({fs:t,dir:e}),n=await Promise.all(i.map(async a=>{let s=await Ou.default.resolveRef({fs:t,dir:e,ref:a});return De({parent:r,name:ar(a),isDir:!0})}));return{type:"directory",content:n,mode:493,size:n}}catch(i){throw i}},"getFile"),rename:o(async e=>{throw new Error("not implemented")},"rename"),mkdir:o(async function(e){throw new Error("not implemented")},"mkdir")};var zi=le(ue(),1);function Du(e){return e&&e.gitCache!==void 0?e.gitCache:e&&e.parentFs?Du(e.parentFs):{}}o(Du,"getGitCacheFromFs");var Ru={type:"gitBranchHeadVirtualFile",rootType:"file",getStats:o(async({gitRoot:e,nodeFs:t,pathParams:r,userSpaceFs:i})=>{r.branchName===void 0&&(r.branchName=await K(e,t));let n=await V(t,e,r.branchName);if(!n)throw new Error(`Branch ${r.branchName} does not exist in the repository`);let a=await zi.default.readCommit({fs:t,dir:e,oid:n,cache:Du(i)}),{commit:s}=a,l=s.committer.timestamp*1e3;return{mode:420,size:40,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:Math.ceil(40/4096),atimeMs:l,mtimeMs:l,ctimeMs:l,birthtimeMs:l,atime:new Date(l),mtime:new Date(l),ctime:new Date(l),birthtime:new Date(l)}},"getStats"),getFile:o(async({gitRoot:e,nodeFs:t,pathParams:r,userSpaceFs:i})=>{r.branchName===void 0&&(r.branchName=await K(e,t));try{let n;try{n=await zi.default.resolveRef({fs:t,dir:e,ref:r.branchName})}catch{n=await zi.default.resolveRef({fs:t,dir:e,ref:`refs/heads/${r.branchName}`})}return{type:"file",content:n+`
|
|
100
|
-
`,mode:420,size:n.length}}catch{return}},"getFile"),writeFile:o(async({filePath:e,gitRoot:t,nodeFs:r,content:i,cacheFs:n,pathParams:a,userSpaceFs:s})=>{console.log("gitBranchHeadVirtualFile writeFile called",{pathParams:a,content:i}),a.branchName===void 0&&(a.branchName=await K(t,r));let l=i.toString().trim();try{await zi.default.readCommit({fs:r,dir:t,oid:l,cache:Du(s)})}catch{throw new Error(`Commit ${l} does not exist in the repository`)}await zi.default.writeRef({fs:r,dir:t,ref:"refs/heads/"+a.branchName,value:l,force:!0})},"writeFile"),rename(e){throw new Error("not implementsd")},mkdir:o(async function(e){throw new Error("not implemented")},"mkdir")};var Cu={type:"legitVirtualFile",rootType:"folder",getStats:o(async({gitRoot:e,nodeFs:t})=>{let r=e+"/.git";try{return await t.promises.stat(r)}catch{throw new Error(`ENOENT: no such file or directory, stat '${r}'`)}},"getStats"),getFile:o(async({gitRoot:e,nodeFs:t})=>({type:"directory",content:[],mode:493,size:0}),"getFile"),rename(e){throw new Error("not implemented")},mkdir:o(async function(e){throw new Error("not implemented")},"mkdir")};var Ns=le(ue(),1);function $s(e){return e&&e.gitCache!==void 0?e.gitCache:e&&e.parentFs?$s(e.parentFs):{}}o($s,"getGitCacheFromFs");var lv={type:"gitCommitFileVirtualFile",rootType:"file",getStats:o(async({filePath:e,gitRoot:t,nodeFs:r,pathParams:i,userSpaceFs:n})=>{if(!i.sha_1_1_2)throw new Error("sha_1_1_2 should be in pathParams");if(!i.sha1_3__40)throw new Error("sha1_3__40 should be in pathParams");let a=i.sha_1_1_2+i.sha1_3__40,s=await Ar({filePath:e,gitRoot:t,nodeFs:r,commitSha:a,pathParams:i,gitCache:$s(n)});if(!s)throw new Hr(`ENOENT: no such file or directory, stat '${e}'`,e);let l=await Ns.default.readCommit({fs:r,dir:t,oid:a}),{commit:u}=l,c=u.committer.timestamp*1e3;if(s.type==="tree")return{mode:420,size:0,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!0,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:0,atimeMs:c,mtimeMs:c,ctimeMs:c,birthtimeMs:c,atime:new Date(c),mtime:new Date(c),ctime:new Date(c),birthtime:new Date(c)};{let{blob:f}=await Ns.default.readBlob({fs:r,dir:t,oid:s.oid});return{mode:420,size:f.length,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:Math.ceil(f.length/4096),atimeMs:c,mtimeMs:c,ctimeMs:c,birthtimeMs:c,atime:new Date(c),mtime:new Date(c),ctime:new Date(c),birthtime:new Date(c)}}},"getStats"),getFile:o(async({filePath:e,gitRoot:t,nodeFs:r,pathParams:i,userSpaceFs:n})=>{if(!i.sha_1_1_2)throw new Error("sha_1_1_2 should be in pathParams");if(!i.sha1_3__40)throw new Error("sha1_3__40 should be in pathParams");let a=i.sha_1_1_2+i.sha1_3__40;try{let s=await Ar({filePath:e,gitRoot:t,nodeFs:r,commitSha:a,pathParams:i,gitCache:$s(n)});if(!s)return;if(s.type==="blob"){let{blob:l}=await Ns.default.readBlob({fs:r,dir:t,oid:s.oid,cache:$s(n)});return{type:"file",content:Buffer.from(l),mode:420,size:l.length,oid:s.oid}}else return{type:"directory",content:Array.from(new Set([...s.entries.filter(u=>u.name!==".keep")])).map(u=>({...u,name:u.name.toString(),path:`${e}`,parentPath:`${e}`})),mode:493}}catch{return}},"getFile"),rename(e){throw new Error("not implementsd")},mkdir:o(async function(e){throw new Error("not implemented")},"mkdir")};var Ls=le(ue(),1);var Iu={type:"gitCommitVirtualFolder",rootType:"folder",getStats:o(async e=>{let t=e.gitRoot+"/.git";try{return await e.nodeFs.promises.stat(t)}catch{throw new Error(`ENOENT: no such file or directory, stat '${t}'`)}},"getStats"),getFile:o(async({filePath:e,gitRoot:t,nodeFs:r,pathParams:i})=>{let n=await Ls.default.listBranches({fs:r,dir:t}),a=new Set,s=new Set;for(let c of n){let f=`refs/heads/${c}`;try{let d=await Ls.default.resolveRef({fs:r,dir:t,ref:f});a.add(d)}catch{}}for(let c of a){let f=await Ls.default.log({fs:r,dir:t,ref:c});for(let d of f)s.add(d.oid)}if(!i.sha_1_1_2){let c=new Set;for(let d of s)if(c.add(d.slice(0,2)),c.size>=256)break;let f=Array.from(c).sort().map(d=>De({parent:e,name:d,isDir:!0}));return{type:"directory",content:f,mode:493,size:f}}let l=new Set;for(let c of s)c.startsWith(i.sha_1_1_2)&&l.add(c.slice(2,40));let u=Array.from(l).sort().map(c=>De({parent:e,name:c,isDir:!0}));return{type:"directory",content:u,mode:493,size:u.length}},"getFile"),rename(e){throw new Error("not implementsd")},mkdir:o(async function(e){throw new Error("not implemented")},"mkdir")};var dt=le(ue(),1);var Bu={type:"gitBranchOperationVirtualFile",rootType:"file",getStats:o(async e=>{let{gitRoot:t,nodeFs:r,pathParams:i}=e;i.branchName===void 0&&(i.branchName=await K(t,r));let n=await V(r,t,i.branchName);if(!n)throw new Error(`Base Branch ${i.branchName} for operations does not exis`);let a=await Re(r,t,i.branchName),s=!1;if(a)try{n=await dt.default.resolveRef({fs:r,dir:t,ref:a}),s=!0}catch{try{n=await dt.default.resolveRef({fs:r,dir:t,ref:`refs/heads/${a}`}),s=!0}catch{}}let l=await dt.default.readCommit({fs:r,dir:t,oid:n}),{commit:u}=l,c=u.committer.timestamp*1e3;try{return{mode:420,size:40,atimeMs:c,mtimeMs:c,ctimeMs:c,birthtimeMs:c,atime:new Date(c),mtime:new Date(c),ctime:new Date(c),birthtime:new Date(c),isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:0}}catch{throw new Error("ENOENT: no such file or directory, stat operationHistory")}},"getStats"),getFile:o(async e=>{let{gitRoot:t,nodeFs:r,pathParams:i}=e;i.branchName===void 0&&(i.branchName=await K(t,r));let n=await Re(r,t,i.branchName),a,s=!1;if(n){if(a=await V(r,t,n),s=!0,!a)throw new Error(`Base Branch ${n} for operations does not exis`)}else if(a=await V(r,t,i.branchName),!a)throw new Error(`Base Branch ${i.branchName} for operations does not exis`);return{type:"file",content:Buffer.from(a),mode:420,size:a.length}},"getFile"),writeFile:o(async({filePath:e,gitRoot:t,nodeFs:r,content:i,cacheFs:n,pathParams:a,author:s})=>{a.branchName===void 0&&(a.branchName=await K(t,r));let l;typeof i=="string"?l=new TextEncoder().encode(i):l=new Uint8Array(i);let u=await dt.default.writeBlob({fs:r,dir:t,blob:l}),c=await V(r,t,a.branchName);if(!c)throw new Error("Invalid branch file path - branch doesn't exist");let f=await Re(r,t,a.branchName),d=!1;f||(f="legit/__"+a.branchName+af,await dt.default.branch({fs:r,dir:t,ref:f,object:c}),d=!0);let h=await dt.default.resolveRef({fs:r,dir:t,ref:`refs/heads/${f}`}),p=await dt.default.readTree({fs:r,dir:t,oid:c}),m;i instanceof ArrayBuffer?m=Buffer.from(i).toString("utf-8"):typeof i=="string"?m=i:i instanceof Uint8Array?m=Buffer.from(i).toString("utf-8"):m=String(i);let w=!1;if(!d){let g=await dt.default.findMergeBase({fs:r,dir:t,oids:w?[h]:[h,c]});g.length===1&&g[0]===c&&(w=!0)}let y=await dt.default.commit({fs:r,dir:t,message:m,tree:p.oid,noUpdateBranch:!0,author:s,parent:w?d?[c,c]:[h]:[h,c]});await dt.default.writeRef({fs:r,dir:t,ref:`refs/heads/${f}`,value:y,force:!0})},"writeFile"),rename:o(async function({filePath:e,newPath:t,gitRoot:r,nodeFs:i,pathParams:n,newPathParams:a}){throw new Error("not implemented")},"rename"),mkdir:o(async function(e){throw new Error("not implemented")},"mkdir")};var oa=le(ue(),1);var cv={type:"getThreadName",rootType:"file",getStats:o(async e=>{let{gitRoot:t,nodeFs:r,pathParams:i}=e,n=await V(r,t,i.branchName);if(!n)throw new Error(`Base Branch ${i.branchName} for operations does not exis`);let a=await Re(r,t,i.branchName),s=!1;if(a)try{n=await oa.default.resolveRef({fs:r,dir:t,ref:a}),s=!0}catch{try{n=await oa.default.resolveRef({fs:r,dir:t,ref:`refs/heads/${a}`}),s=!0}catch{}}let l=await oa.default.readCommit({fs:r,dir:t,oid:n}),{commit:u}=l,c=u.committer.timestamp*1e3;try{return{mode:420,size:40,atimeMs:c,mtimeMs:c,ctimeMs:c,birthtimeMs:c,atime:new Date(c),mtime:new Date(c),ctime:new Date(c),birthtime:new Date(c),isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:0}}catch{throw new Error("ENOENT: no such file or directory, stat operationHistory")}},"getStats"),getFile:o(async e=>{let{gitRoot:t,nodeFs:r,pathParams:i}=e,n=await Re(r,t,i.branchName),a;if(n){let s="legit/",l=`__${i.branchName}-operation`;return n.startsWith(s)&&n.endsWith(l)?a=n.slice(s.length,n.length-l.length):a=n,{type:"file",content:Buffer.from(Ay(a)),mode:420,size:a.length}}return{type:"file",content:Buffer.from(""),mode:420,size:0}},"getFile"),writeFile:o(async({filePath:e,gitRoot:t,nodeFs:r,content:i,cacheFs:n,pathParams:a})=>{if(a.branchName===void 0)throw new Error("branchName should be in pathParams");let s=await Re(r,t,a.branchName);if(s){let l=`legit/${Ty(i.toString())}__${a.branchName}-operation`;await oa.default.renameBranch({fs:r,dir:t,oldref:s,ref:l}),s=l}},"writeFile"),rename:o(async function({filePath:e,newPath:t,gitRoot:r,nodeFs:i,pathParams:n,newPathParams:a}){throw new Error("not implemented")},"rename"),mkdir:o(async function(e){throw new Error("not implemented")},"mkdir")};var Nu=le(ue(),1);var $u={type:"gitBranchHistory",rootType:"file",getStats:o(async({gitRoot:e,nodeFs:t,pathParams:r})=>{r.branchName===void 0&&(r.branchName=await K(e,t));let i=await V(t,e,r.branchName);if(!i)throw new Error(`Branch ${r.branchName} does not exist`);let n=await Nu.default.readCommit({fs:t,dir:e,oid:i}),{commit:a}=n,s=a.committer.timestamp*1e3;return{mode:420,size:1e5,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:Math.ceil(40/4096),atimeMs:s,mtimeMs:s,ctimeMs:s,birthtimeMs:s,atime:new Date(s),mtime:new Date(s),ctime:new Date(s),birthtime:new Date(s)}},"getStats"),getFile:o(async e=>{let{gitRoot:t,nodeFs:r,pathParams:i}=e,n=i.branchName;n===void 0&&(n=await K(t,r));let a=[];if(n){let l=await V(r,t,n),u=!1,c=l;for(;c&&!u;){let f=await Nu.default.readCommit({fs:r,dir:t,oid:c});a.push({oid:f.oid,...f.commit}),c=f.commit.parent[0]}}let s=Buffer.from(JSON.stringify(a,null,2),"utf-8");return{type:"file",content:s,mode:420,size:s.length}},"getFile"),rename:o(async e=>{throw new Error("not implemented")},"rename"),mkdir:o(async function(e){throw new Error("not implemented")},"mkdir")};var At=le(ue(),1);var Lu={type:"gitBranchOperationHeadVirtualFile",rootType:"file",getStats:o(async({gitRoot:e,nodeFs:t,pathParams:r})=>{r.branchName===void 0&&(r.branchName=await K(e,t));let i=await Re(t,e,r.branchName);if(!i){let u=new Date(0);return{mode:420,size:0,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:Math.ceil(40/4096),atimeMs:u.getTime(),mtimeMs:u.getTime(),ctimeMs:u.getTime(),birthtimeMs:u.getTime(),atime:u,mtime:u,ctime:u,birthtime:u}}let n;try{n=await At.default.resolveRef({fs:t,dir:e,ref:i})}catch{n=await At.default.resolveRef({fs:t,dir:e,ref:`refs/heads/${i}`})}let a=await At.default.readCommit({fs:t,dir:e,oid:n}),{commit:s}=a,l=s.committer.timestamp*1e3;return{mode:420,size:40,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:Math.ceil(40/4096),atimeMs:l,mtimeMs:l,ctimeMs:l,birthtimeMs:l,atime:new Date(l),mtime:new Date(l),ctime:new Date(l),birthtime:new Date(l)}},"getStats"),getFile:o(async({gitRoot:e,nodeFs:t,pathParams:r})=>{r.branchName===void 0&&(r.branchName=await K(e,t));let i=await Re(t,e,r.branchName);if(!i)return{type:"file",content:"",mode:420,size:0};try{let n;try{n=await At.default.resolveRef({fs:t,dir:e,ref:i})}catch{n=await At.default.resolveRef({fs:t,dir:e,ref:`refs/heads/${i}`})}return{type:"file",content:n+`
|
|
101
|
-
`,mode:420,size:n.length}}catch{return}},"getFile"),writeFile:o(async({filePath:e,gitRoot:t,nodeFs:r,content:i,cacheFs:n,pathParams:a})=>{a.branchName===void 0&&(a.branchName=await K(t,r));let s=await Re(r,t,a.branchName),l=await At.default.resolveRef({fs:r,dir:t,ref:`refs/heads/${s}`});if(!s)throw new Error(`Operation branch name could not be resolved for branch ${a.branchName}`);let u=i.toString().trim(),c,f,d=!1;if(!l)throw new Error(`Operation branch ref could not be resolved for branch ${s}`);let h=l;for(;h&&!d;){let p=await At.default.readCommit({fs:r,dir:t,oid:h});if(p.oid===u&&(c=p.oid),h=p.commit.parent&&p.commit.parent.length>0?p.commit.parent[0]:null,p.commit.parent.length===2){if(p.commit.parent[0]===p.commit.parent[1])d=!0;else if(c!==void 0){f=p.commit.parent[1];break}}}if(c===void 0)throw new Error(`Cant rollback to ${u} couldn't find newOperationBranchHead ${c}`);if(f===void 0)throw new Error(`Cant rollback to ${u} couldn't find newBranchHead ${f}`);await At.default.writeRef({fs:r,dir:t,ref:"refs/heads/"+s,value:c,force:!0}),await At.default.writeRef({fs:r,dir:t,ref:"refs/heads/"+a.branchName,value:f,force:!0})},"writeFile"),rename(e){throw new Error("not implementsd")},mkdir:o(async function(e){throw new Error("not implemented")},"mkdir")};var uv=le(ue(),1);var Ms=le(ue(),1);async function sa(e,t){try{let r=await Ms.default.getConfig({fs:t,dir:e,path:"user.legit-target-branch"});if(r)return ar(r)}catch{}try{let r=await Ms.default.getConfig({fs:t,dir:e,path:"init.defaultBranch"});return ar(r)||"main"}catch{return"main"}}o(sa,"getTargetBranch");async function fv(e,t,r){await Ms.default.setConfig({fs:t,dir:e,path:"user.legit-target-branch",value:pe(r)})}o(fv,"setTargetBranch");var dv={type:"gitCurrentBranchVirtualFile",rootType:"file",getStats:o(async({gitRoot:e,nodeFs:t})=>{let i=(await K(e,t)).length;return{mode:420,size:i,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:Math.ceil(i/4096),atimeMs:Date.now(),mtimeMs:Date.now(),ctimeMs:Date.now(),birthtimeMs:Date.now(),atime:new Date,mtime:new Date,ctime:new Date,birthtime:new Date}},"getStats"),getFile:o(async({gitRoot:e,nodeFs:t})=>{let r=await K(e,t);return{type:"file",content:r+`
|
|
102
|
-
`,mode:420,size:r.length+1}},"getFile"),writeFile:o(async({gitRoot:e,nodeFs:t,content:r})=>{let i=r.toString().trim();if(!await V(t,e,i)){let a=await sa(e,t),s=await V(t,e,a);if(!s)throw new Error(`Ref branch ${a} does not exist in the repository`);await uv.default.branch({fs:t,dir:e,ref:pe(i),object:s})}await Ry(e,t,i)},"writeFile"),rename(e){throw new Error("not implemented")},mkdir:o(async function(e){throw new Error("not implemented")},"mkdir")};var Ot="session_data",js=JSON.stringify({env:{CLAUDE_CONFIG_DIR:`.claude/${Ot}`}},null,2),hv={type:"claudeVirtualSessionFileVirtualFile",rootType:"folder",getStats:o(async({gitRoot:e,nodeFs:t,filePath:r,cacheFs:i,pathParams:n})=>{let a=r.replace(/\\/g,"/");if(a.endsWith(".claude")||a.endsWith(`.claude/${Ot}`)||a.endsWith(`.claude/${Ot}/debug`)||a.endsWith(`.claude/${Ot}/projects`)||new RegExp(`\\.claude\\/${Ot}\\/projects\\/[^/]+$`).test(a)){let u=new Date(0);return{mode:16877,size:0,isFile:o(()=>!1,"isFile"),isDirectory:o(()=>!0,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:0,atimeMs:0,mtimeMs:0,ctimeMs:0,birthtimeMs:0,atime:u,mtime:u,ctime:u,birthtime:u}}let s=new Date(0);return a.endsWith(".claude/settings.json")?{mode:420,size:js.length,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:Math.ceil(js.length/4096),atimeMs:s,mtimeMs:s,ctimeMs:s,birthtimeMs:s,atime:s,mtime:s,ctime:s,birthtime:s}:await i.promises.stat(r)},"getStats"),getFile:o(async({filePath:e,gitRoot:t,nodeFs:r,cacheFs:i,pathParams:n})=>{let a=e.replace(/\\/g,"/");if((a.endsWith(".claude")||a.endsWith(".claude/session_data")||a.endsWith(".claude/session_data/projects")||a.endsWith(".claude/session_data/debug")||/\.claude\/session_data\/projects\/[^/]+$/.test(a))&&await i.promises.mkdir(e,{recursive:!0}),a.endsWith(".claude/settings.json"))return{type:"file",content:js,mode:420,size:js.length,oid:"unknown"};try{if((await i.promises.stat(e)).isFile()){let l=await i.promises.readFile(e);return{type:"file",content:l,mode:420,size:l.length,oid:"unknown"}}else{let l=await i.promises.readdir(e,{withFileTypes:!0});if(a.endsWith(".claude")){let u=l.find(f=>f.name.toString()==="settings.json");u||l.push(De({name:"settings.json",parent:e,isDir:!1}));let c=l.find(f=>f.name.toString()===Ot);u||l.push(De({name:Ot,parent:e,isDir:!0}))}if(a.endsWith(`.claude/${Ot}`)&&(l.find(c=>c.name.toString()==="projects")||l.push(De({name:"projects",parent:e,isDir:!0}))),a.endsWith(`.claude/${Ot}/projects`)&&!l.find(c=>c.name.toString()==="projects")){let c=a.replace(`.claude/${Ot}/projects`,"");l.push(De({name:c.replaceAll("/","-"),parent:e,isDir:!0}))}return{type:"directory",content:l.map(u=>({...u,name:u.name.toString(),path:`${e}`,parentPath:`${e}`})),mode:493}}}catch{return}},"getFile"),unlink:o(async({filePath:e,gitRoot:t,nodeFs:r,cacheFs:i,pathParams:n,author:a})=>{await i.promises.unlink(e)},"unlink"),writeFile:o(async({filePath:e,gitRoot:t,nodeFs:r,content:i,cacheFs:n,userSpaceFs:a,pathParams:s,author:l})=>{let u=e.replace(/\\/g,"/"),c=/\/projects\/([^/]+)\/([^/]+\.jsonl)$/,f=u.match(c);if(f){let d=f[1],h=f[2];console.log({folder:d,file:h}),await n.promises.stat(e).then(()=>!0).catch(()=>!1)||await n.promises.writeFile(e,"");let w=(await n.promises.readFile(e,"utf-8")).split(`
|
|
103
|
-
`);if(w.length>1){let y=w[w.length-2]||"",g=JSON.parse(y),_="";if(g.type==="user"){let k=g.message?.content;if(Array.isArray(k)&&k[0]?.type==="tool_result"){let S=k[0],P=typeof S.content=="string"?S.content:JSON.stringify(S.content);_=`\u{1F47E} Tool Result (${g.toolUseResult?.type||"unknown"}): ${P}
|
|
3
|
+
var ze=Object.defineProperty;var Ft=(n,i,e)=>i in n?ze(n,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[i]=e;var o=(n,i)=>ze(n,"name",{value:i,configurable:!0});var p=(n,i,e)=>Ft(n,typeof i!="symbol"?i+"":i,e);import*as ge from"path";var he=class he{constructor(i,e){p(this,"entries",[]);p(this,"currentIndex",0);p(this,"closed",!1);p(this,"compositFs");p(this,"dirPath");p(this,"initialized",!1);this.compositFs=i,this.dirPath=e}async initialize(){if(this.initialized)return;let i=new Set;for(let e of[...this.compositFs.subFilesystems].reverse()){let t=await e.readdir(this.dirPath);for(let r of t)i.add(r)}for(let e of Array.from(i)){let t=this.dirPath+"/"+e;await this.compositFs.hiddenFilesFileSystem?.responsible(t)||this.entries.push({name:e,path:t})}this.initialized=!0}async*[Symbol.asyncIterator](){for(await this.initialize();this.currentIndex<this.entries.length&&!this.closed;){let i=this.entries[this.currentIndex++];try{let e=await this.compositFs.stat(i.path);yield{name:i.name,isFile:o(()=>e.isFile(),"isFile"),isDirectory:o(()=>e.isDirectory(),"isDirectory"),isBlockDevice:o(()=>e.isBlockDevice(),"isBlockDevice"),isCharacterDevice:o(()=>e.isCharacterDevice(),"isCharacterDevice"),isSymbolicLink:o(()=>e.isSymbolicLink(),"isSymbolicLink"),isFIFO:o(()=>e.isFIFO(),"isFIFO"),isSocket:o(()=>e.isSocket(),"isSocket")}}catch(e){console.debug(`Failed to stat ${i.path}:`,e)}}}async read(){if(this.closed)throw new Error("Directory handle is closed");if(await this.initialize(),this.currentIndex>=this.entries.length)return null;let i=this.entries[this.currentIndex++];try{let e=await this.compositFs.stat(i.path);return{name:i.name,isFile:o(()=>e.isFile(),"isFile"),isDirectory:o(()=>e.isDirectory(),"isDirectory"),isBlockDevice:o(()=>e.isBlockDevice(),"isBlockDevice"),isCharacterDevice:o(()=>e.isCharacterDevice(),"isCharacterDevice"),isSymbolicLink:o(()=>e.isSymbolicLink(),"isSymbolicLink"),isFIFO:o(()=>e.isFIFO(),"isFIFO"),isSocket:o(()=>e.isSocket(),"isSocket")}}catch{return this.read()}}async close(){this.closed=!0,this.entries=[]}get path(){return this.dirPath}};o(he,"CompositeFsDir");var W=he;var pe=class pe{constructor(i){p(this,"delegate");p(this,"compositeFs");p(this,"_subFsFileDescriptor");p(this,"handleType","file");p(this,"_compositFsFileDescriptor",-1);this.delegate=i.fs,this._subFsFileDescriptor=i.subFsFileDescriptor,this._compositFsFileDescriptor=-1,this.compositeFs=i.compositeFs;let e=this._subFsFileDescriptor}get fsType(){return this.delegate.fileType()}get subFsFileDescriptor(){return this._subFsFileDescriptor}get fd(){return this._compositFsFileDescriptor}realize(i){if(this._compositFsFileDescriptor!==-1)throw new Error("was already realized");this._compositFsFileDescriptor=i}readableWebStream(i){throw new Error("Method not implemented.")}async appendFile(i,e){return await this.compositeFs.logOperationOnFileDescsriptor(this,"appendFile",{data:i,options:e}),await this.delegate.appendFile(this,i,e)}async chmod(i){return await this.compositeFs.logOperationOnFileDescsriptor(this,"chmod",{mode:i}),this.delegate.fchmod(this,i)}async chown(i,e){return await this.compositeFs.logOperationOnFileDescsriptor(this,"chown",{uid:i,gid:e}),this.delegate.fchown(this,i,e)}async close(){return await this.compositeFs.logOperationOnFileDescsriptor(this,"close",{}),this.compositeFs.close(this)}async datasync(){return await this.compositeFs.logOperationOnFileDescsriptor(this,"datasync",{}),this.delegate.dataSync(this)}async read(i,e,t,r){return await this.compositeFs.logOperationOnFileDescsriptor(this,"read",{targetBufferLength:i.length,offset:e,length:t,position:r}),await this.delegate.read(this,i,e,t,r)}async readv(i,e){return await this.compositeFs.logOperationOnFileDescsriptor(this,"readv",{buffers:i,position:e}),this.delegate.readv(this,i,e)}async stat(i){return await this.compositeFs.logOperationOnFileDescsriptor(this,"stat",{options:i}),this.delegate.fstat(this,i)}async truncate(i){return await this.compositeFs.logOperationOnFileDescsriptor(this,"truncate",{len:i}),this.delegate.ftruncate(this,i)}async utimes(i,e){return await this.compositeFs.logOperationOnFileDescsriptor(this,"utimes",{atime:i,mtime:e}),this.delegate.futimes(this,i,e)}async write(i,e,t,r){return await this.compositeFs.logOperationOnFileDescsriptor(this,"write",{buffer:i,offset:e,length:t,position:r}),this.delegate.write(this,i,e,t,r)}async writev(i,e){return await this.compositeFs.logOperationOnFileDescsriptor(this,"writev",{buffers:i,position:e}),this.delegate.writev(this,i,e)}async sync(){return await this.compositeFs.logOperationOnFileDescsriptor(this,"sync",{}),this.delegate.dataSync(this)}};o(pe,"CompositFsFileHandle");var I=pe;import*as je from"path";import{createFsFromVolume as gt,Volume as wt}from"memfs";var ue=class ue{constructor({name:i,parentFs:e,gitRoot:t}){p(this,"compositFs");p(this,"gitRoot");p(this,"name");this.name=i,this.compositFs=e,this.gitRoot=t}toStr(i){return typeof i=="string"?i:Buffer.isBuffer(i)?i.toString():i&&typeof i=="object"&&"fd"in i?`FileHandle(fd=${i.fd})`:String(i)}async open(i,e,t){throw new Error(`open not implemented for: ${this.toStr(i)}`)}async access(i,e){throw new Error(`access not implemented for: ${this.toStr(i)}`)}async stat(i,e){throw new Error(`lstat not implemented for: ${this.toStr(i)}`)}async lstat(i,e){throw new Error(`lstat not implemented for: ${this.toStr(i)}`)}async opendir(i,e){throw new Error(`opendir not implemented for: ${this.toStr(i)}`)}async link(i,e){throw new Error(`link not implemented for: ${this.toStr(i)}`)}async mkdir(i,e){throw new Error(`mkdir not implemented for: ${this.toStr(i)}`)}async readdir(i,e){throw new Error(`readdir not implemented for: ${this.toStr(i)}`)}async readlink(i,...e){throw new Error(`readlink not implemented for: ${this.toStr(i)}`)}async unlink(i){throw new Error(`unlink not implemented for: ${this.toStr(i)}`)}async rename(i,e){throw new Error(`rename not implemented for: ${this.toStr(i)}`)}async rmdir(i,...e){throw new Error(`rmdir not implemented for: ${this.toStr(i)}`)}async symlink(i,e,t){throw new Error(`symlink not implemented for: ${this.toStr(e)}`)}async lookup(i){throw new Error(`lookup not implemented for: ${this.toStr(i)}`)}resolvePath(i){throw new Error(`resolvePath not implemented for fd: ${i}`)}async close(i){this.compositFs.close(i)}async dataSync(i){throw new Error(`dataSync not implemented for: ${i.subFsFileDescriptor}`)}async read(i,e,t,r,s){throw new Error(`read not implemented for: ${i.subFsFileDescriptor}`)}async appendFile(i,e,t){throw new Error(`appendFile not implemented for: ${i.subFsFileDescriptor}`)}async fchmod(i,e){throw new Error(`fchmod not implemented for: ${i.subFsFileDescriptor}`)}async fchown(i,e,t){throw new Error(`fchown not implemented for: ${i.subFsFileDescriptor}`)}async ftruncate(i,e){throw new Error(`ftruncate not implemented for: ${i.subFsFileDescriptor}`)}async fstat(i,e){throw new Error(`fstat not implemented for: ${i.subFsFileDescriptor}`)}async futimes(i,e,t){throw new Error(`futimes not implemented for: ${i.subFsFileDescriptor}`)}async write(i,e,t,r,s){throw new Error(`write not implemented for: ${i.subFsFileDescriptor}`)}async writev(i,e,t){throw new Error(`writev not implemented for: ${i.subFsFileDescriptor}`)}async readv(i,e,t){throw new Error(`readv not implemented for: ${i.subFsFileDescriptor}`)}async readFile(i,e){throw new Error(`readFile not implemented for: ${this.toStr(i)}`)}async writeFile(i,e,t){throw new Error(`writeFile not implemented for: ${this.toStr(i)}`)}};o(ue,"BaseCompositeSubFs");var L=ue;var Fe=class Fe extends L{constructor({name:e,parentFs:t,gitRoot:r,passThroughFs:s}){super({name:e,parentFs:t,gitRoot:r});p(this,"openFh",new Map);p(this,"memFs",gt(new wt));p(this,"targetFs");this.compositFs=t,this.gitRoot=r,this.targetFs=s}async responsible(e){return!0}fileType(){return 4}async open(e,t,r){let s=je.dirname(e),a=await this.targetFs.promises.open(e,t,r);return this.openFh.set(a.fd,a),new I({fs:this,compositeFs:this.compositFs,subFsFileDescriptor:a.fd,parentFsFileDescriptors:[]})}async access(e,t){return await this.targetFs.promises.access(e,t)}async stat(e,...t){return this.targetFs.promises.stat(e,{bigint:!1})}async lstat(e,...t){return this.targetFs.promises.lstat(e,{bigint:!1})}async opendir(e,t){let r=await this.targetFs.promises.opendir(e,t);return new W(this.compositFs,e.toString())}async link(e,t){return await this.targetFs.promises.link(e,t)}async mkdir(e,t){await this.targetFs.promises.mkdir(e,t)}async readdir(e,...t){return this.targetFs.promises.readdir(e,...t)}async readlink(e,...t){throw new Error("not implemented")}async unlink(e){return await this.targetFs.promises.unlink(e)}async rename(e,t){return await this.targetFs.promises.rename(e,t)}async rmdir(e,t){return await this.targetFs.promises.rmdir(e,t)}async symlink(e,t,r){return await this.targetFs.promises.symlink(e,t,r)}async lookup(e){throw new Error(`lookup is not implemented for: ${this.toStr(e)}`)}async close(e){let t=this.openFh.get(e.subFsFileDescriptor);t&&(this.openFh.delete(e.subFsFileDescriptor),await t.close())}async dataSync(e){let t=this.openFh.get(e.subFsFileDescriptor);if(t)return await t.sync()}async read(e,t,r,s,a){let l=this.openFh.get(e.subFsFileDescriptor);if(l)return await l.read(t,r,s,a);throw new Error(`File handle not found: ${e.subFsFileDescriptor}`)}async fchmod(e,t){let r=this.openFh.get(e.subFsFileDescriptor);if(r)return await r.chmod(t)}async fchown(e,t,r){let s=this.openFh.get(e.subFsFileDescriptor);if(s)return await s.chown(t,r)}async write(e,t,r,s,a){let l=this.openFh.get(e.subFsFileDescriptor);if(l)return await l.write(t,r,s,a);throw new Error(`File handle not found: ${e.subFsFileDescriptor}`)}async ftruncate(e,t){let r=this.openFh.get(e.subFsFileDescriptor);if(r)return await r.truncate(t)}resolvePath(e){throw new Error(`resolvePath is not implemented: resolvePath(${e})`)}async fstat(e,t){let r=this.openFh.get(e.subFsFileDescriptor);if(r)return await r.stat(t);throw new Error(`File handle not found: ${e.subFsFileDescriptor}`)}async futimes(e,t,r){let s=this.openFh.get(e.subFsFileDescriptor);if(s)return await s.utimes(t,r)}async writev(e,t,r){let s=this.openFh.get(e.subFsFileDescriptor);if(s)return await s.writev(t,r??void 0);throw new Error(`File handle not found: ${e.subFsFileDescriptor}`)}async readv(e,t,r){let s=this.openFh.get(e.subFsFileDescriptor);if(s)return await s.readv(t,r??void 0);throw new Error(`File handle not found: ${e.subFsFileDescriptor}`)}async readFile(e,t){return this.targetFs.promises.readFile(e,t)}async writeFile(e,t,r){return this.targetFs.promises.writeFile(e,t,r)}};o(Fe,"PassThroughToAsyncFsSubFs");var X=Fe;var we=class we{constructor({name:i,storageFs:e,gitRoot:t,defaultBranch:r="main"}){p(this,"promises");p(this,"gitRoot");p(this,"ephemeralFilesFileSystem");p(this,"hiddenFilesFileSystem");p(this,"passThroughFileSystem");p(this,"subFilesystems",[]);p(this,"parentFs");p(this,"name");p(this,"defaultBranch");p(this,"gitCache");p(this,"pathToFileDescriptors",new Map);p(this,"openFileHandles",new Map);p(this,"logOperation");this.name=i,this.gitRoot=t,this.defaultBranch=r,this.promises={access:this.access.bind(this),opendir:this.opendir.bind(this),mkdir:this.mkdir.bind(this),readdir:this.readdir.bind(this),open:this.open.bind(this),stat:this.stat.bind(this),lstat:this.lstat.bind(this),link:this.link.bind(this),readlink:this.readlink.bind(this),unlink:this.unlink.bind(this),rename:this.rename.bind(this),rmdir:this.rmdir.bind(this),symlink:this.symlink.bind(this),readFile:this.readFile.bind(this),writeFile:this.writeFile.bind(this),getFilehandle:this.getFilehandle.bind(this)},this.passThroughFileSystem=new X({name:i+"-passthrough",passThroughFs:e,gitRoot:t,parentFs:this})}getNextFileDescriptor(){let i=Array.from(this.openFileHandles.keys());return i.length===0?1:Math.max(...i)+1}setLoggger(i){this.logOperation=i}async logOperationOnFileDescsriptor(i,e,t){if(!this.logOperation)return;let r=[];for(let[s,a]of this.pathToFileDescriptors.entries())a.includes(i.fd)&&r.push(s);if(r.length!==0)return this.logOperation?.({fsName:i.delegate.name,fd:i,path:r[0],operation:e,operationArgs:t})}getFilehandle(i){return this.openFileHandles.get(i)}setEphemeralFilesSubFs(i){this.ephemeralFilesFileSystem=i}setHiddenFilesSubFs(i){this.hiddenFilesFileSystem=i}addSubFs(i){this.subFilesystems.push(i)}async getResponsibleFs(i){if(!i.toString().startsWith(this.gitRoot)&&this.gitRoot!=="./")throw new Error("tried to access a file ("+i+") outside of the legit folder: "+this.gitRoot);if(!this.hiddenFilesFileSystem)throw new Error(this.name+" intialize hidden fs first!");if(!this.ephemeralFilesFileSystem)throw new Error(this.name+" intialize ephemeral fs first!");if(await this.hiddenFilesFileSystem.responsible(i.toString()))return this.hiddenFilesFileSystem;if(await this.ephemeralFilesFileSystem.responsible(i.toString()))return this.ephemeralFilesFileSystem;for(let e of this.subFilesystems)if(await e.responsible(i.toString()))return e;return this.passThroughFileSystem}async access(i,e){let t=await this.getResponsibleFs(i);return await this.logOperation?.({fsName:t.name,path:i,operation:"access",operationArgs:{mode:e}}),t.access(i,e)}async opendir(i,e){await this.logOperation?.({fsName:this.name,path:i.toString(),operation:"opendir",operationArgs:{options:e}});let t=i.toString();if(!t.startsWith(this.gitRoot))throw new Error("tried to access a directory ("+t+") outside of the legit folder: "+this.gitRoot);return new W(this,t)}async mkdir(i,e){let t=await this.getResponsibleFs(i);return await this.logOperation?.({fsName:t.name,path:i.toString(),operation:"mkdir",operationArgs:{options:e}}),t.mkdir(i,e)}async readdir(i,e){await this.logOperation?.({fsName:this.name,path:i.toString(),operation:"readdir",operationArgs:{options:e}});let t=new Set;for(let r of[...this.subFilesystems].reverse()){let s=await r.readdir(i,e);for(let a of s)await this.ephemeralFilesFileSystem?.responsible((i=="/"?"":i)+"/"+a)||t.add(a)}try{let r=await this.passThroughFileSystem.readdir(i,e);for(let s of r)await this.ephemeralFilesFileSystem?.responsible((i=="/"?"":i)+"/"+s)||t.add(s)}catch(r){if(r.code!=="ENOENT")throw new Error("error reading ephemeral fs: "+r)}try{let r=await this.ephemeralFilesFileSystem.readdir(i,e);for(let s of r)t.add(s)}catch(r){if(r.code!=="ENOENT")throw new Error("error reading ephemeral fs: "+r)}for(let r of t){let s=(i=="/"?"":i)+"/"+r;await this.hiddenFilesFileSystem.responsible(s)&&t.delete(r)}return Array.from(t)}async open(i,e,t){let r=await this.getResponsibleFs(i);await this.logOperation?.({fsName:r.name,path:i,operation:"open",operationArgs:{flags:e,mode:t}});let s=await r.open(i,e,t),a=this.getNextFileDescriptor();return s.realize(a),this.openFileHandles.set(a,s),this.pathToFileDescriptors.get(i)||this.pathToFileDescriptors.set(i,[]),this.pathToFileDescriptors.get(i).push(a),s}async close(i){try{await i.delegate.close(i)}catch(e){throw e}finally{for(let[e,t]of this.pathToFileDescriptors.entries()){let r=t.indexOf(i.fd);if(r!==-1){t.splice(r,1),t.length===0&&this.pathToFileDescriptors.delete(e);break}}this.openFileHandles.delete(i.fd)}}async stat(i,e){let t=i.toString(),r=await this.getResponsibleFs(i);return await this.logOperation?.({fsName:r.name,path:t,operation:"stat",operationArgs:{opts:e}}),r.stat(i)}async lstat(i,e){let t=await this.getResponsibleFs(i);return await this.logOperation?.({fsName:t.name,path:i.toString(),operation:"lstat",operationArgs:{opts:e}}),t.lstat(i,e)}async link(i,e){throw new Error("not implemented")}async readlink(i,e){throw new Error("not implemented")}async unlink(i){let e=await this.getResponsibleFs(i);return await this.logOperation?.({fsName:e.name,path:i.toString(),operation:"unlink",operationArgs:{}}),e.unlink(i)}async rename(i,e){if(this.hiddenFilesFileSystem){if(await this.hiddenFilesFileSystem.responsible(ge.basename(i.toString())))throw new Error("Renaming of hidden Files is not allowed "+i);if(await this.hiddenFilesFileSystem.responsible(ge.basename(e.toString())))throw new Error("Renaming to hidden Files is not allowed "+e)}let t=await this.getResponsibleFs(i),r=await this.getResponsibleFs(e);if(t===r)return await this.logOperation?.({fsName:t.name,path:i.toString(),operation:"rename",operationArgs:{oldPath:i,newPath:e}}),t.rename(i,e);let s=await t.open(i.toString(),"r");try{let a=await t.fstat(s),l=Buffer.alloc(a.size);await t.read(s,l,0,a.size,0),await t.close(s),await r.writeFile(e.toString(),l,"utf8"),await t.unlink(i)}catch(a){try{await t.close(s)}catch{}throw a}}async rmdir(i,e){let t=await this.getResponsibleFs(i);return await this.logOperation?.({fsName:t.name,path:i.toString(),operation:"rmdir",operationArgs:{dirPath:i,options:e}}),t.rmdir(i,e)}async symlink(i,e,t){throw new Error("not implemented")}async readFile(i,e){await this.logOperation?.({fsName:this.name,path:i.toString(),operation:"readFile",operationArgs:{path:i,options:e}});let t=!0,r;if(typeof i=="number"){t=!1;let s=this.getFilehandle(i);if(!s)throw new Error("Invalid file descriptor");r=s}else if(typeof i=="string")r=await this.open(i,"r");else throw new Error("only filehandle and path are supported atm");try{let a=(await r.stat()).size;if(typeof a=="bigint"){if(a>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("File too large to read into buffer");a=Number(a)}let l=Buffer.alloc(a),{bytesRead:c}=await r.read(l,0,a,0);if(e&&typeof e.encoding=="string")return l.slice(0,c).toString(e.encoding);if(typeof e=="string"){if(e==="utf8"||e==="utf-8")return l.slice(0,c).toString(e);throw new Error("Unsupported encoding: "+e)}return l.slice(0,c)}finally{r&&t&&await r.close()}}async writeFile(i,e,t){await this.logOperation?.({fsName:this.name,path:i.toString(),operation:"writeFile",operationArgs:{data:e,options:t}});let r=typeof i!="number",s,a,l,c="w";if(typeof t=="string"?a=t:t&&typeof t=="object"&&(a=t.encoding,l=t.mode,c=t.flag||"w"),typeof i=="number"){let m=this.getFilehandle(i);if(!m)throw new Error("Invalid file descriptor");s=m}else if(typeof i=="string")s=await this.open(i,c,l);else throw new Error("only filehandle and path are supported atm");try{let m;if(typeof e=="string")m=Buffer.from(e,a||"utf8");else if(e instanceof Buffer)m=e;else if(e instanceof Uint8Array)m=Buffer.from(e);else throw new Error("Invalid data type for writeFile");let d=0;for(;d<m.length;){let{bytesWritten:f}=await s.write(m,d,m.length-d,d);d+=f}}finally{s&&r&&await s.close()}}};o(we,"CompositeFs");var Q=we;import yt from"ignore";var ye=class ye extends L{constructor({name:e,parentFs:t,gitRoot:r,hiddenFiles:s}){super({name:e,parentFs:t,gitRoot:r});p(this,"ig");this.ig=yt(),this.ig.add(s)}async responsible(e){let t=e.replace(/\\/g,"/"),r=t.startsWith("./")?t.slice(2):t;return r=r.startsWith("/")?r.slice(1):r,r===""||r==="."?!1:this.ig.ignores(r)}fileType(){return 255}error(e){return new Error(`Access to hidden file is not allowed: ${this.toStr(e)}`)}async open(e,t,r){throw this.error(e)}async access(e){throw this.error(e)}async stat(e){throw this.error(e)}async lstat(e){throw this.error(e)}async opendir(e){throw this.error(e)}async link(e){throw this.error(e)}async mkdir(e){throw this.error(e)}async readdir(e){throw this.error(e)}async readlink(e){throw this.error(e)}async unlink(e){throw this.error(e)}async rename(e){throw this.error(e)}async rmdir(e){throw this.error(e)}async symlink(e,t){throw this.error(t)}async lookup(e){throw this.error(e)}resolvePath(e){throw new Error(`Access to hidden file is not allowed: resolvePath(${e})`)}async close(e){throw new Error("Access to hidden file is not allowed: close: "+e.subFsFileDescriptor)}async dataSync(e){throw new Error("Access to hidden file is not allowed: dataSync: "+e.subFsFileDescriptor)}async read(e,t,r,s,a){throw new Error("Access to hidden file is not allowed: readFileHandle: "+e.subFsFileDescriptor)}};o(ye,"HiddenFileSubFs");var Y=ye;import*as Z from"path";import{createFsFromVolume as bt,Volume as vt}from"memfs";import Pt from"ignore";var be=class be extends L{constructor({name:e,parentFs:t,gitRoot:r,ephemeralPatterns:s}){super({name:e,parentFs:t,gitRoot:r});p(this,"openFh",new Map);p(this,"memFs",bt(new vt));p(this,"ig");p(this,"patterns");this.compositFs=t,this.gitRoot=r,this.ig=Pt(),this.ig.add(s),this.patterns=s}normalizePath(e){let t=typeof e=="string"?e:e.toString();return t.startsWith("/")?t:"/"+t}async responsible(e){let t=e.replace(/\\/g,"/"),r=t.startsWith("./")?t.slice(2):t;return r=r.startsWith("/")?r.slice(1):r,r===""||r==="."?!1:this.ig.ignores(r)}fileType(){return 5}async open(e,t,r){let s=this.normalizePath(e),a=Z.dirname(s);a&&a!=="/"&&a!=="."&&await this.memFs.promises.mkdir(a,{recursive:!0});let l=await this.memFs.promises.open(s,t,r);return this.openFh.set(l.fd,l),new I({fs:this,compositeFs:this.compositFs,subFsFileDescriptor:l.fd,parentFsFileDescriptors:[l.fd]})}async access(e,t){let r=this.normalizePath(e);return await this.memFs.promises.access(r,t)}async stat(e,t){let r=this.normalizePath(e);return this.memFs.promises.stat(r,{bigint:!1})}async lstat(e,t){let r=this.normalizePath(e);return this.memFs.promises.lstat(r,{bigint:!1})}async opendir(e,t){let r=this.normalizePath(e);return await this.memFs.promises.opendir(r,t)}async link(e,t){let r=this.normalizePath(e),s=this.normalizePath(t);return await this.memFs.promises.link(r,s)}async mkdir(e,t){let r=this.normalizePath(e);if(!(typeof t=="object"&&t&&"recursive"in t&&t.recursive)){let a=Z.dirname(r);if(a&&a!=="/"&&a!==".")try{await this.memFs.promises.stat(a)}catch{await this.memFs.promises.mkdir(a,{recursive:!0})}}await this.memFs.promises.mkdir(r,t)}async readdir(e,...t){let r=this.normalizePath(e),s=await this.memFs.promises.readdir(r,...t);return console.log("EPHEMERAL: READDIR: ",s),s}async readlink(e){throw new Error("readlink is not implemented for EphemeralFileSubFs")}async unlink(e){let t=this.normalizePath(e);return await this.memFs.promises.unlink(t)}async rename(e,t){let r=this.normalizePath(e),s=this.normalizePath(t);return await this.memFs.promises.rename(r,s)}async rmdir(e,t){let r=this.normalizePath(e);return await this.memFs.promises.rmdir(r,t)}async symlink(e,t,r){let s=this.normalizePath(e),a=this.normalizePath(t);return await this.memFs.promises.symlink(s,a,r)}async lookup(e){throw new Error(`lookup is not implemented for: ${this.toStr(e)}`)}async close(e){let t=this.openFh.get(e.subFsFileDescriptor);t&&(await t.close(),this.openFh.delete(e.subFsFileDescriptor))}async dataSync(e){let t=this.openFh.get(e.subFsFileDescriptor);if(t)return await t.datasync()}async read(e,t,r,s,a){let l=this.openFh.get(e.subFsFileDescriptor);if(l)return await l.read(t,r,s,a);throw new Error(`File handle not found: ${e.subFsFileDescriptor}`)}async fchmod(e,t){let r=this.openFh.get(e.subFsFileDescriptor);if(r)return await r.chmod(t)}async fchown(e,t,r){let s=this.openFh.get(e.subFsFileDescriptor);if(s)return await s.chown(t,r)}async write(e,t,r,s,a){let l=this.openFh.get(e.subFsFileDescriptor);if(l)return await l.write(t,r,s,a);throw new Error(`File handle not found: ${e.subFsFileDescriptor}`)}async ftruncate(e,t){let r=this.openFh.get(e.subFsFileDescriptor);if(r)return await r.truncate(t)}resolvePath(e){throw new Error(`resolvePath is not implemented: resolvePath(${e})`)}async fstat(e,t){let r=this.openFh.get(e.subFsFileDescriptor);if(r)return await r.stat(t);throw new Error(`File handle not found: ${e.subFsFileDescriptor}`)}async futimes(e,t,r){let s=this.openFh.get(e.subFsFileDescriptor);if(s)return await s.utimes(t,r)}async writev(e,t,r){let s=this.openFh.get(e.subFsFileDescriptor);if(s)return await s.writev(t,r??void 0);throw new Error(`File handle not found: ${e.subFsFileDescriptor}`)}async readv(e,t,r){let s=this.openFh.get(e.subFsFileDescriptor);if(s)return await s.readv(t,r??void 0);throw new Error(`File handle not found: ${e.subFsFileDescriptor}`)}async readFile(e,t){if(typeof e=="string"||Buffer.isBuffer(e)){let r=this.normalizePath(e);return this.memFs.promises.readFile(r,t)}return super.readFile(e,t)}async writeFile(e,t,r){let s=this.normalizePath(e),a=Z.dirname(s);return a&&a!=="/"&&a!=="."&&await this.memFs.promises.mkdir(a,{recursive:!0}),this.memFs.promises.writeFile(s,t,r)}};o(be,"EphemeralSubFs");var ee=be;import*as We from"path";import{createFsFromVolume as kt,Volume as Dt}from"memfs";var ve=class ve extends L{constructor({name:e,parentFs:t,gitRoot:r}){super({name:e,parentFs:t,gitRoot:r});p(this,"openFh",new Map);p(this,"memFs",kt(new Dt));p(this,"targetFs");if(this.compositFs=t,this.gitRoot=r,this.compositFs.parentFs===void 0)throw new Error("PassThroughSubFs not allowed in root fs");this.targetFs=this.compositFs.parentFs}async responsible(e){return!0}fileType(){return 4}async open(e,t,r){let s=We.dirname(e),a=await this.targetFs.promises.open(e,t,r);return this.openFh.set(a.fd,a),new I({fs:this,compositeFs:this.compositFs,subFsFileDescriptor:a.fd,parentFsFileDescriptors:[a.fd]})}async access(e,t){return await this.targetFs.promises.access(e,t)}async stat(e,t){return this.targetFs.promises.stat(e,{bigint:!1})}async lstat(e,t){return this.targetFs.promises.lstat(e,{bigint:!1})}async opendir(e,t){return await this.targetFs.promises.opendir(e,t)}async link(e,t){return await this.targetFs.promises.link(e,t)}async mkdir(e,t){let r=typeof e=="string"?e:e.toString();return await this.targetFs.promises.mkdir(r,t)}async readdir(e,...t){return this.targetFs.promises.readdir(e,...t)}async readlink(e,...t){throw new Error("not implemented")}async unlink(e){return await this.targetFs.promises.unlink(e)}async rename(e,t){return await this.targetFs.promises.rename(e,t)}async rmdir(e,t){return await this.targetFs.promises.rmdir(e,t)}async symlink(e,t,r){return await this.targetFs.promises.symlink(e,t,r)}async lookup(e){throw new Error(`lookup is not implemented for: ${this.toStr(e)}`)}async close(e){let t=this.openFh.get(e.subFsFileDescriptor);t&&(await t.close(),this.openFh.delete(e.subFsFileDescriptor))}async dataSync(e){let t=this.openFh.get(e.subFsFileDescriptor);if(t)return await t.sync()}async read(e,t,r,s,a){let l=this.openFh.get(e.subFsFileDescriptor);if(l)return await l.read(t,r,s,a);throw new Error(`File handle not found: ${e.subFsFileDescriptor}`)}async fchmod(e,t){let r=this.openFh.get(e.subFsFileDescriptor);if(r)return await r.chmod(t)}async fchown(e,t,r){let s=this.openFh.get(e.subFsFileDescriptor);if(s)return await s.chown(t,r)}async write(e,t,r,s,a){let l=this.openFh.get(e.subFsFileDescriptor);if(l)return await l.write(t,r,s,a);throw new Error(`File handle not found: ${e.subFsFileDescriptor}`)}async ftruncate(e,t){let r=this.openFh.get(e.subFsFileDescriptor);if(r)return await r.truncate(t)}resolvePath(e){throw new Error(`resolvePath is not implemented: resolvePath(${e})`)}async fstat(e,t){let r=this.openFh.get(e.subFsFileDescriptor);if(r)return await r.stat(t);throw new Error(`File handle not found: ${e.subFsFileDescriptor}`)}async futimes(e,t,r){let s=this.openFh.get(e.subFsFileDescriptor);if(s)return await s.utimes(t,r)}async writev(e,t,r){let s=this.openFh.get(e.subFsFileDescriptor);if(s)return await s.writev(t,r??void 0);throw new Error(`File handle not found: ${e.subFsFileDescriptor}`)}async readv(e,t,r){let s=this.openFh.get(e.subFsFileDescriptor);if(s)return await s.readv(t,r??void 0);throw new Error(`File handle not found: ${e.subFsFileDescriptor}`)}async readFile(e,t){return typeof e=="string"||Buffer.isBuffer(e)?this.targetFs.readFile(e.toString(),t):super.readFile(e,t)}async writeFile(e,t,r){let s=typeof r=="object"&&r.flag?r.flag:"w",a=await this.targetFs.open(e,s);try{let l;if(typeof t=="string"){let c=typeof r=="object"&&r.encoding?r.encoding:"utf8";l=Buffer.from(t,c)}else Buffer.isBuffer(t)?l=t:l=Buffer.from(t);await a.write(l,0,l.length,0)}finally{await this.targetFs.close(a)}}};o(ve,"PassThroughSubFs");var _e=ve;import Xe from"@legit-sdk/isomorphic-git";import*as ke from"path";import{createFsFromVolume as Ot,Volume as Bt}from"memfs";var Pe=class Pe{constructor(i){this.routes=i;p(this,"compiledRoutes");let e={},t=o((r,s)=>{if(typeof r.type=="string"){e[s]={handler:r,siblings:[]};let a=r}else{let a=[];for(let[l,c]of Object.entries(r))if(l==="."){if(e[s])throw new Error(`Conflict: multiple handlers for path '${s}', '.' and optional '[[parameter_name]]' defined?`);e[s]={handler:c,siblings:a}}else if(l.startsWith("[[")&&l.endsWith("]]")){if(e[s])throw new Error(`Conflict: multiple handlers for path '${s}', '.' and optional '[[parameter_name]]' defined?`);e[s]={handler:c,siblings:a},l.startsWith("[[...")?e[s?`${s}/${l}`:l]={handler:c,siblings:[]}:t(c,s?`${s}/${l}`:l)}else l.startsWith("[")&&l.endsWith("]")?l.startsWith("[...")?e[s?`${s}/${l}`:l]={handler:c,siblings:[]}:t(c,s?`${s}/${l}`:l):(a.push({segment:l,type:c["."]?"folder":"file"}),t(c,s?`${s}/${l}`:l))}},"walk");t(i,""),this.compiledRoutes=Object.entries(e).map(([r,s])=>{let a=[],l=r.split("/").map(m=>{if(m.startsWith("[[")&&m.endsWith("]]")){let d=m.slice(2,-2).replace(/^\.\.\./,"");return a.push(d),"(.*)"}if(m.startsWith("[")&&m.endsWith("]")){let d=m.slice(1,-1);return a.push(d),"([^/]+)"}return m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}).join("/");return{regex:new RegExp(`^${l}$`),paramNames:a,staticSiblings:s.siblings,handler:s.handler}})}match(i){i.length>1&&i.endsWith("/")&&(i=i.replace(/\/+$/,""));for(let{regex:e,paramNames:t,handler:r,staticSiblings:s}of this.compiledRoutes){let a=i.match(e);if(!a)continue;let l={};for(let c=0;c<t.length;c++)l[t[c]]=decodeURIComponent(a[c+1]||"");return{handler:r,params:l,staticSiblings:s}}}};o(Pe,"LegitPathRouter");var te=Pe;import $ from"@legit-sdk/isomorphic-git";var St=new Set([" ","~","^",":","?","*","[","\\"]),Et=[/^\/|\/$/,/\/\//,/\.$/,/\.lock$/,/^@$/,/@\{/],Ge="\u2002";function Ue(n){let i=n.codePointAt(0);return!(i>=0&&i<=31||i===127||St.has(n))}o(Ue,"isValidChar");function Je(n){let i="";for(let e of n)e===" "?i+=Ge:Ue(e)?i+=e:i+="%"+e.codePointAt(0);for(let e of Et)if(e.test(i))return Array.from(i).map(t=>Ue(t)?t:"%"+t.codePointAt(0)).join("");return i}o(Je,"encodeName");function Ke(n){return n.replace(/%(\d+)/g,(i,e)=>String.fromCodePoint(parseInt(e,10))).replace(new RegExp(Ge,"g")," ")}o(Ke,"decodeName");function M(n){return n.replace(/\./g,"%2E").replace(/\//g,".")}o(M,"encodeBranchNameForVfs");function B(n){return n.replace(/\./g,"/").replace(/%2E/g,".")}o(B,"decodeBranchNameFromVfs");async function b(n,i,e,t){try{return await $.resolveRef({fs:n,dir:i,ref:`refs/heads/${B(e)}`})}catch{return}}o(b,"tryResolveRef");async function x({dir:n,fs:i,treeOid:e,deletePathParts:t,addPathParts:r,addObj:s,addKeepIfEmpty:a,deleteKeepIfNotEmpty:l,keepFilename:c=".keep",gitCache:m}){let[d,...f]=r??[],[h,...F]=t??[],u=[];if(e){let{tree:v}=await $.readTree({fs:i,dir:n,oid:e,cache:m||{}});u=[...v]}if(d===h){let v=d;if(v===void 0)throw new Error("illegal arguement - called with out a path part");if(f.length===0)throw new Error("can not move into it self");if(F.length===0)throw new Error("can not move from it self");let O=u.findIndex(D=>D.path===v),g=(O!==-1?u[O]:void 0)?.oid,w=await x({dir:n,fs:i,treeOid:g,addPathParts:f,deletePathParts:F,addObj:s,addKeepIfEmpty:a,deleteKeepIfNotEmpty:l});if(w===void 0)throw new Error("on the same path we expect an update - respectivly a newly created subTreeOid");let P=!1;if(w!==g){P=!0;let D={mode:"040000",path:v,oid:w,type:"tree"};O!==-1?u[O]=D:u.push(D)}if(e==null&&!P)throw new Error("Illegal state - if the currentOid is undefined - a new tree should have been created (an update should have happened)");if(P)return await $.writeTree({fs:i,dir:n,tree:u});if(e===void 0)throw new Error("currentOid should be set - since the sub tree didn't exist and ");return e}else{let v=!1,O;if(h){let y=u.findIndex(w=>w.path===h),g=y!==-1?u[y]:void 0;if(g===void 0)throw new Error("Element doesnt exist in tree");if(F.length>0){if(g&&g.type!=="tree")throw new Error("SubPart of the path for the obj to delete is not a tree");let w=await x({dir:n,fs:i,treeOid:g.oid,addPathParts:void 0,deletePathParts:F,addObj:s,addKeepIfEmpty:a,deleteKeepIfNotEmpty:l});if(w===g.oid)throw new Error("in case of a delete we expect a different subtree oid");v=!0,w===void 0?u.splice(y,1):u[y]={mode:"040000",path:h,oid:w,type:"tree"}}else if(v=!0,u.splice(y,1),u.length===0&&a){let w=new Uint8Array(0),P=await $.writeBlob({fs:i,dir:n,blob:w});u.push({mode:"100644",oid:P,path:c,type:"blob"})}O=g}if(d){let y=u.findIndex(w=>w.path===d),g=y!==-1?u[y]:void 0;if(f.length>0){if(g&&g.type!=="tree")throw new Error("SubPart of the path for the obj to add is not a tree");let w=await x({dir:n,fs:i,treeOid:g?.oid,addPathParts:f,deletePathParts:void 0,addObj:s,addKeepIfEmpty:a,deleteKeepIfNotEmpty:l});if(w===void 0)throw new Error("in case we add, we expect an update - respectivly a newly created subTreeOid");if(w!==g?.oid){v=!0;let P={mode:"040000",path:d,oid:w,type:"tree"};if(y!==-1)u[y]=P;else if(u.push(P),l&&u.length>1){let D=u.findIndex(S=>S.path===c);D!==-1&&u.splice(D,1)}}}else{if(v=!0,s){let w={mode:s.type==="tree"?"040000":"100644",path:d,oid:s.oid,type:s.type};if(y!==-1)u[y]=w;else{if(l&&u.length>0){let P=u.findIndex(D=>D.path===c);P!==-1&&u.splice(P,1)}u.push(w)}}if(a&&u.length===0){let w=new Uint8Array(0),P=await $.writeBlob({fs:i,dir:n,blob:w});u.push({mode:"100644",oid:P,path:c,type:"blob"})}}}if(u.length===0)return;if(v)return await $.writeTree({fs:i,dir:n,tree:u});if(e===void 0)throw new Error("currentOid should be set - since the sub tree didn't exist and ");return e}}o(x,"buildUpdatedTree");async function qe(n,i,e,t,r=0,s={}){let{tree:a}=await $.readTree({fs:n,dir:i,oid:e,cache:s});if(t.length===r)return{type:"tree",entries:a.map(m=>T({parent:t.join("/"),name:m.path,isDir:m.type==="tree"})),oid:e};let l=t[r],c=a.find(m=>m.path===l);if(c){if(t.length===r+1){if(c.type==="blob")return{type:"blob",oid:c.oid};if(c.type==="tree"){let m=await $.readTree({fs:n,dir:i,oid:c.oid,cache:s});return{type:"tree",entries:m.tree.map(d=>T({parent:t.join("/"),name:d.path,isDir:d.type==="tree"})),oid:m.oid}}}else if(c.type==="tree")return await qe(n,i,c.oid,t,r+1,s)}}o(qe,"findGitObjectAtPath");async function j({filePath:n,gitRoot:i,nodeFs:e,commitSha:t,pathParams:r,gitCache:s}){let a=s||{};if(!r.filePath){let m=await $.readTree({fs:e,dir:i,oid:t,cache:a});return{type:"tree",entries:m.tree.map(f=>T({parent:n,name:f.path,isDir:f.type==="tree"})),oid:m.oid}}let l=r.filePath?r.filePath.split("/"):[];return await qe(e,i,t,l,0,a)}o(j,"resolveGitObjAtPath");function T(n){return{name:n.name,isFile:o(()=>!n.isDir,"isFile"),isDirectory:o(()=>n.isDir,"isDirectory"),isBlockDevice:o(()=>!0,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isFIFO:o(()=>!1,"isFIFO"),isSocket:o(()=>!1,"isSocket"),parentPath:n.parent,path:n.parent}}o(T,"toDirEntry");var J=class J extends L{constructor({name:e,parentFs:t,gitStorageFs:r,gitRoot:s,routerConfig:a}){super({name:e,parentFs:t,gitRoot:s});p(this,"pathRouter");p(this,"memFs");p(this,"openFh",{});p(this,"storageFs");this.pathRouter=new te(a),this.gitRoot=s,this.storageFs=r,this.memFs=Ot(new Bt)}async getAuthor(){let e=await Xe.getConfig({fs:this.storageFs,dir:this.gitRoot,path:"user.name"}),t=await Xe.getConfig({fs:this.storageFs,dir:this.gitRoot,path:"user.email"}),r=Math.floor(Date.now()/1e3),s=new Date().getTimezoneOffset();return{name:e,email:t,date:r,timezoneOffset:s}}async responsible(e){return!0}getRouteHandler(e){let t=e;this.gitRoot&&e.startsWith(this.gitRoot)&&(this.gitRoot==="/"?t=e.slice(this.gitRoot.length):t=e.slice(this.gitRoot.length+1));let r=t.indexOf(`/${J.LEGIT_DIR}`);if(r===-1)return this.pathRouter.match(t);let s=t.slice(r+1);return this.pathRouter.match(t)}async open(e,t,r){let s=this.getRouteHandler(e);if(!s)throw new Error("Not a virtual legit file");if(!(s?.handler.writeFile!==void 0)&&(t.includes("w")||t.includes("a")))throw new Error(`Write operations not allowed for ${s?.handler.type}`);if(t.includes("x")&&s?.handler.type!=="gitBranchFileVirtualFile"&&s?.handler.type!=="claudeVirtualSessionFileVirtualFile")throw new Error(`Exclusive operations not allowed for ${s?.handler.type}`);let l=await this.getAuthor(),c=await s.handler.getFile({cacheFs:this.memFs,filePath:e,userSpaceFs:this.compositFs,gitRoot:this.gitRoot,nodeFs:this.storageFs,pathParams:s.params,author:l}),m=!1;for(let u of Object.values(this.openFh))u.path===e&&(m=!0);if((c||m)&&t.includes("x"))throw Object.assign(new Error(`EEXIST: file already exists, open '${e}'`),{code:"EEXIST",errno:-17,syscall:"open",path:e});if(!c&&!m&&!(t.includes("w")||t.includes("a")))throw Object.assign(new Error(`ENOENT: no such file or directory, open '${e}'`),{code:"ENOENT",errno:-2,syscall:"open",path:e});let d=ke.dirname(e);if(await this.memFs.promises.mkdir(d,{recursive:!0}),c===void 0&&!t.includes("x")||c&&c.type==="file")try{let u=await this.memFs.promises.access(e)}catch{await this.memFs.promises.writeFile(e,"")}let f=await this.memFs.promises.open(e,t,r),h=f.fd,F=new I({fs:this,compositeFs:this.compositFs,subFsFileDescriptor:h,parentFsFileDescriptors:[]});return this.openFh[h]={path:e,mode:t,fh:f,openSha:c?.oid,readSha:void 0,unflushed:[]},(t.includes("x")||t.includes("w"))&&this.openFh[h].unflushed.push({length:0,start:0}),F}async mkdir(e,t){let r=e.toString(),s=this.getRouteHandler(r),a=t?{options:t}:{};try{let l=await this.getAuthor();await s?.handler.mkdir({cacheFs:this.memFs,filePath:e.toString(),userSpaceFs:this.compositFs,nodeFs:this.storageFs,gitRoot:this.gitRoot,pathParams:s.params,...a,author:l});let c=typeof t=="object"?{...t,recursive:!0}:{recursive:!0};await this.memFs.promises.mkdir(e,c);let m=r.split("/"),d="";for(let f=1;f<=m.length;f++){d=m.slice(0,f).join("/");try{if((await this.memFs.promises.stat(d)).isDirectory()){let F=await this.memFs.promises.open(d,"r");this.openFh[F.fd]={path:d,mode:"r",fh:F,openSha:void 0,readSha:void 0,unflushed:[]}}}catch{}}}catch(l){throw l}}async access(e,t){await this.stat(e)}async futimes(e,t,r){let s=this.openFh[e.subFsFileDescriptor];if(!s)throw new Error("Invalid file handle");return await s.fh.utimes(t,r)}async fstat(e,t){let r=this.openFh[e.subFsFileDescriptor];if(!r)throw new Error("Invalid file handle");return this.stat(r.path,t)}async ftruncate(e,t){let r=this.openFh[e.subFsFileDescriptor];if(!r)throw new Error("Invalid file handle");return r.unflushed.push({length:0,start:0}),await r.fh.truncate(t)}async stat(e,t){let r=e.toString(),s=Object.values(this.openFh).find(m=>m.path===r&&m.unflushed.length>0);if(s&&s.unflushed.length>0)return await s.fh.stat(t);let a=this.getRouteHandler(r);if(!a)throw new Error(`ENOENT: no such file or directory, stat '${r}'`);let l=await this.getAuthor();return await a.handler.getStats({cacheFs:this.memFs,filePath:r,userSpaceFs:this.compositFs,gitRoot:this.gitRoot,nodeFs:this.storageFs,pathParams:a.params,author:l})}async lstat(e,t){return this.stat(e,t)}async readdir(e,t){let r=e.toString(),s=this.getRouteHandler(r);if(!s)throw new Error(`ENOENT: no such file or directory, scandir '${r}'`);let a=await this.getAuthor(),l=await s?.handler.getFile({cacheFs:this.memFs,filePath:r,userSpaceFs:this.compositFs,gitRoot:this.gitRoot,nodeFs:this.storageFs,pathParams:s.params,author:a});if(l){if(l.type!=="directory")throw new Error("not a folder");let c=s?.staticSiblings??[],m=Array.from(new Set([...l.content,...c.map(d=>T({name:d.segment,parent:r,isDir:d.type==="folder"}))])).sort((d,f)=>d.name.localeCompare(f.name,void 0,{numeric:!0,sensitivity:"base"}));return t?.withFileTypes?m:m.map(d=>d.name)}return[]}async read(e,t,r,s,a){let l=e.subFsFileDescriptor,c=this.openFh[l];if(!c)throw new Error("Invalid file handle");if(c.unflushed.length===0){let m=this.getRouteHandler(c.path),d=await this.getAuthor(),f=await m.handler.getFile({cacheFs:this.memFs,filePath:c.path,userSpaceFs:this.compositFs,gitRoot:this.gitRoot,nodeFs:this.storageFs,pathParams:m?.params,author:d});if(!f?.content)throw new Error("couldnt access content");if(f.type!=="file")throw new Error("not a file");let h=typeof f.content=="string"?Buffer.from(f.content):f.content,F=typeof a=="number"?a:0,u=Math.min(F+s,h.length),v=Math.max(0,u-F);return h.copy(t,r,F,F+v),{bytesRead:v,buffer:t}}return await c.fh.read(t,r,s,a)}async write(e,t,r,s,a){let l=this.openFh[e.subFsFileDescriptor];if(!l)throw new Error("Invalid file handle");let c=l.mode;if(!c.includes("w")&&!c.includes("a")&&!c.includes("+"))throw Object.assign(new Error("EBADF: bad file descriptor, write"),{code:"EBADF",errno:-9,syscall:"write"});if(l.unflushed.length===0){let h=this.getRouteHandler(l.path),F=await this.getAuthor(),u=await h.handler.getFile({cacheFs:this.memFs,filePath:l.path,userSpaceFs:this.compositFs,gitRoot:this.gitRoot,nodeFs:this.storageFs,pathParams:h.params,author:F});u&&u.oid&&(await this.memFs.promises.writeFile(l.path,u.content),l.readSha=u.oid)}let m=await l.fh.write(t,r,s,a),d=r??0,f=a??0;return l.unflushed.push({start:f,length:s||t.byteLength-d+f}),m}async close(e){let t=e.subFsFileDescriptor,r=this.openFh[t];if(!r)throw new Error("Invalid file handle");try{await this.dataSync(e),await r.fh.close()}finally{delete this.openFh[t]}}async dataSync(e){let t=e.subFsFileDescriptor,r=this.openFh[t];if(!r)throw new Error("Invalid file handle");if(r.unflushed.length>0){let s=this.getRouteHandler(r.path);if(s&&s.handler.writeFile){let a=await this.memFs.promises.readFile(r.path),l=await this.getAuthor();await s.handler.writeFile({cacheFs:this.memFs,filePath:r.path,userSpaceFs:this.compositFs,gitRoot:this.gitRoot,nodeFs:this.storageFs,content:a,pathParams:s.params,author:l})}r.unflushed=[]}}async readFile(e,t){let r=typeof e=="string"?e:Buffer.isBuffer(e)?e.toString():e.fd?`FileHandle(${e.fd})`:e.toString(),s=null;typeof t=="string"?s=t:t&&typeof t=="object"&&t.encoding&&(s=t.encoding);let a=await this.open(r,"r");try{let c=(await this.fstat(a)).size,m=Buffer.alloc(c);return await this.read(a,m,0,c,0),await this.close(a),s?m.toString(s):m}catch(l){try{await this.close(a)}catch{}throw l}}async writeFile(e,t,r){let s="w",a="utf8",l;typeof r=="string"?a=r:r&&typeof r=="object"&&(r.flag&&(s=String(r.flag)),r.encoding&&(a=r.encoding),r.mode&&(l=typeof r.mode=="string"?parseInt(r.mode,8):r.mode));let c=await this.open(e,s,l);try{let m;typeof t=="string"?m=Buffer.from(t,a):Buffer.isBuffer(t)?m=t:t instanceof Uint8Array?m=Buffer.from(t):ArrayBuffer.isView(t)?m=Buffer.from(t.buffer,t.byteOffset,t.byteLength):m=Buffer.from(t),await this.write(c,m,0,m.length,0)}finally{await this.close(c)}}async rename(e,t){let r=e.toString(),s=t.toString(),a=this.getRouteHandler(r),l=this.getRouteHandler(s);if(a?.handler.type==="gitBranchFileVirtualFile"&&l?.handler.type==="gitBranchFileVirtualFile"){let c=!0;try{await this.memFs.promises.access(s)}catch{c=!1}let m=!0;try{await this.stat(s)}catch{m=!1}let d=!0;try{await this.stat(r)}catch{d=!1}let f=!0;try{await this.memFs.promises.access(r)}catch{f=!1}if(f){let v=ke.dirname(s);try{await this.memFs.promises.access(v)}catch{await this.memFs.promises.mkdir(v,{recursive:!0})}await this.memFs.promises.rename(e,t)}let h=this.getRouteHandler(r);if(!h)throw new Error("VF not found");let F=await this.getAuthor(),u=await h.handler.rename({cacheFs:this.memFs,filePath:r,userSpaceFs:this.compositFs,gitRoot:this.gitRoot,nodeFs:this.storageFs,newPath:s,pathParams:h?.params??{},newPathParams:l?.params??{},author:F})}else throw new Error(`Unsupported rename operation from ${a?.handler.type} to ${l?.handler.type}`)}async fchmod(e,t){}async unlink(e){let t=e.toString(),r=this.getRouteHandler(t);if(r?.handler.unlink!==void 0)try{let s=await this.getAuthor();await r.handler.unlink({cacheFs:this.memFs,filePath:t,userSpaceFs:this.compositFs,nodeFs:this.storageFs,gitRoot:this.gitRoot,pathParams:r.params,author:s})}catch(s){let a=!1;for(let[l,c]of Object.entries(this.openFh))c.path===t&&c.unflushed.length>0&&(a=!0);if(!a)throw s}finally{let s=!1;for(let[a,l]of Object.entries(this.openFh))l.path===t&&(s=!0,await l.fh.close(),delete this.openFh[Number(a)]);s&&await this.memFs.promises.unlink(t)}else throw new Error(`Cannot unlink ${r?.handler.type} files`)}async rmdir(e,...t){let r=e.toString(),s=this.getRouteHandler(r);if(s?.handler.rmdir!==void 0){let a=await this.getAuthor();await s.handler.rmdir({cacheFs:this.memFs,filePath:r,userSpaceFs:this.compositFs,nodeFs:this.storageFs,gitRoot:this.gitRoot,pathParams:s.params,author:a});let l=!1;for(let[c,m]of Object.entries(this.openFh))m.path===r&&(l=!0,await m.fh.close(),delete this.openFh[Number(c)]);l&&await this.memFs.promises.rmdir(r,{recursive:!0})}else throw new Error(`Cannot rmdir
|
|
4
|
+
${s?.handler.type} directories`)}fileType(){return 10}};o(J,"GitSubFs"),p(J,"LEGIT_DIR",".legit");var ie=J;import U from"@legit-sdk/isomorphic-git";import Tt from"@legit-sdk/isomorphic-git";var De="-operation";async function C(n,i,e){return(await Tt.listBranches({fs:n,dir:i})).filter(r=>r.endsWith("__"+e+De))[0]}o(C,"resolveOperationBranchName");import Se from"@legit-sdk/isomorphic-git";async function k(n,i){try{let e=await Se.getConfig({fs:i,dir:n,path:"user.legit-current-branch"});if(e)return M(e)}catch{}try{let e=await Se.getConfig({fs:i,dir:n,path:"init.defaultBranch"});return M(e)||"main"}catch{return"main"}}o(k,"getCurrentBranch");async function Qe(n,i,e){await Se.setConfig({fs:i,dir:n,path:"user.legit-current-branch",value:B(e)})}o(Qe,"setCurrentBranch");var re={type:"gitBranchOperationsVirtualFile",rootType:"file",getStats:o(async n=>{let{gitRoot:i,nodeFs:e,pathParams:t}=n;t.branchName===void 0&&(t.branchName=await k(i,e));let r=await C(e,i,t.branchName),s,a=!1;if(r)try{s=await U.resolveRef({fs:e,dir:i,ref:r}),a=!0}catch{try{s=await U.resolveRef({fs:e,dir:i,ref:`refs/heads/${r}`}),a=!0}catch{throw new Error(`Base Branch ${t.branchName} for operations does not exis`)}}else try{s=await U.resolveRef({fs:e,dir:i,ref:`refs/heads/${t.branchName}`})}catch{throw new Error(`Base Branch ${t.branchName} for operations does not exis`)}let l=await U.readCommit({fs:e,dir:i,oid:s}),{commit:c}=l,m=c.committer.timestamp*1e3;try{return{mode:420,size:(a?await re.getFile(n):void 0)?.content?.length??0,atimeMs:m,mtimeMs:m,ctimeMs:m,birthtimeMs:m,atime:new Date(m),mtime:new Date(m),ctime:new Date(m),birthtime:new Date(m),isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:0}}catch{throw new Error("ENOENT: no such file or directory, stat operationHistory")}},"getStats"),getFile:o(async n=>{let{gitRoot:i,nodeFs:e,pathParams:t}=n;t.branchName===void 0&&(t.branchName=await k(i,e));let r=await C(e,i,t.branchName),s=[];if(r){let c=await U.resolveRef({fs:e,dir:i,ref:`refs/heads/${r}`}),m=!1,d=c;for(;d&&!m;){let f=await U.readCommit({fs:e,dir:i,oid:d});s.push({oid:f.oid,parentOids:f.commit.parent,message:f.commit.message,originBranchOid:"unset"}),d=f.commit.parent&&f.commit.parent.length>0?f.commit.parent[0]:null,f.commit.parent.length===2&&f.commit.parent[0]===f.commit.parent[1]&&(m=!0)}}let a;for(let c=s.length-1;c>=0;c--){let m=s[c];if(a===void 0){if(m.parentOids.length!==2&&m.parentOids[0]!==m.parentOids[1])throw new Error(`Operation commit ${m.oid} does not have two parents as expected`);a=m.parentOids[1]}m.parentOids.length===2&&(a=m.parentOids[1]),m.originBranchOid=a}let l=Buffer.from(JSON.stringify(s,null,2),"utf-8");return{type:"file",content:l,mode:420,size:l.length}},"getFile"),rename:o(async function(n){throw new Error("not implemented")},"rename"),mkdir:o(async function(n){throw new Error("not implemented")},"mkdir")};import H from"@legit-sdk/isomorphic-git";import Ee from"@legit-sdk/isomorphic-git/http/node";var z="legit",Ye=o(({fs:n,gitRepoPath:i,serverUrl:e="https://hub.legitcontrol.com",auth:t,anonymousBranch:r,authHeaderPrefix:s="Bearer "})=>{let a=!1;async function l(O){let y=await t.getMaxAccessTokenForBranch(O);if(!y)throw new Error(`No access token for branch ${O}`);await H.fetch({fs:n,http:Ee,dir:i,singleBranch:!0,ref:`${O}`,remote:z,url:e,headers:{Authorization:`${s}${y}`}});let g=await H.resolveRef({fs:n,dir:i,ref:`${z}/${O}`});await H.writeRef({fs:n,dir:i,ref:`refs/heads/${O}`,value:g})}o(l,"loadBranch");let c=[];async function m(){let O=await t.getMaxAccessTokenForBranch("todo");await H.fetch({fs:n,http:Ee,dir:i,remote:z,url:e,headers:{Authorization:`${s}${O}`}});let y=await H.listBranches({fs:n,dir:i});for(let g of y){if(g===r)continue;let w=`${z}/${g}`,P,D;try{P=await H.resolveRef({fs:n,dir:i,ref:g})}catch(S){console.log(`Could not resolve local ref ${g}:`,S)}try{D=await H.resolveRef({fs:n,dir:i,ref:w})}catch{D=void 0}if(P&&D){if(P!==D){let S=await H.findMergeBase({fs:n,dir:i,oids:[P,D]});if(S[0]!==P&&S[0]!==D){let Ve=await H.merge({fs:n,dir:i,ours:P,theirs:D,fastForwardOnly:!1,abortOnConflict:!1,author:{name:"Your Name",email:"your.email@example.com"},mergeDriver:o(async({branches:ce,contents:de,path:fe})=>{let[It,ut,Me]=de;return console.log(`Merging ${ce[0]} with ${ce[1]}...`),console.log("merged:"),console.log(de),{cleanMerge:!0,mergedText:Me===void 0?ut:Me}},"mergeDriver")});await H.writeRef({fs:n,dir:i,ref:`refs/heads/${g}`,value:Ve.oid,force:!0})}S[0]===P?(console.log(`branch ${g} differs - remote ahaed, not behind`),await H.writeRef({fs:n,dir:i,ref:`refs/heads/${g}`,value:D,force:!0})):S[0]===D?(console.log(`branch ${g} differs - local ahead, not behind`),c.push(g)):(console.log(`branch ${g} differs - both changed`),c.push(g))}}else P&&!D&&c.push(g)}}o(m,"pull");async function d(O){if((await t.getUser()).type!=="local")for(let y of O){let g=await t.getMaxAccessTokenForBranch(y);await H.push({fs:n,http:Ee,dir:i,remote:z,url:e,ref:y,headers:{Authorization:`Bearer ${g}`}})}}o(d,"push");let f=Promise.resolve();async function h(O){f=f.then(()=>d(O)),await f}o(h,"sequentialPush");async function F(){await H.getConfig({fs:n,dir:i,path:`remote.${z}.fetch`})||await H.setConfig({fs:n,dir:i,path:`remote.${z}.fetch`,value:`+refs/heads/*:refs/remotes/${z}/*`});try{await m();let y=[...new Set(c)].filter(g=>g.indexOf(r)===-1);await h(y),c=[]}catch(y){console.error("Error monitoring changes:",y)}finally{a&&setTimeout(F,1e3)}}o(F,"pullPushTick");function u(){a=!0,F()}o(u,"startSync");function v(){a=!1}return o(v,"stopSync"),{start:o(()=>{a||(u(),a=!0)},"start"),stop:o(()=>{v()},"stop"),isRunning:o(()=>a,"isRunning"),loadBranch:l,sequentialPush:h}},"createLegitSyncService");import N from"@legit-sdk/isomorphic-git";import{createFsFromVolume as Nt,Volume as Ht}from"memfs";var Ze=o((n,i)=>{let e={type:"local",id:"local",name:"Local User",email:"local@legitcontrol.com"};return{getUser:o(async()=>e,"getUser"),signInAnonymously:o(async()=>{e.type="anonymous",e.id=crypto.randomUUID(),e.email=`anonymous-sha1-${e.id}-@legitcontrol.com`},"signInAnonymously"),addAccessToken:o(async t=>{let r=await n.getUserTokens(e.id);r.accessTokens.push(t),await n.setUserTokens(e.id,r)},"addAccessToken"),getMaxAccessTokenForBranch:o(async t=>{let r=await n.getUserTokens(e.id);if(!(r.accessTokens===void 0||r.accessTokens.length===0))return r.accessTokens[0]},"getMaxAccessTokenForBranch")}},"createSessionManager");import it from"@legit-sdk/isomorphic-git";function et(n){let i=JSON.stringify(n),e=new TextEncoder().encode(i),t="";return typeof btoa=="function"?t=btoa(String.fromCharCode(...e)):t=Buffer.from(e).toString("base64"),t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}o(et,"encodeConfigJson");function tt(n){let i=n.replace(/-/g,"+").replace(/_/g,"/")+"===".slice((n.length+3)%4),e;typeof atob=="function"?e=atob(i):e=Buffer.from(i,"base64").toString("binary");let t=Uint8Array.from(e,s=>s.charCodeAt(0)),r=new TextDecoder().decode(t);return JSON.parse(r)}o(tt,"decodeConfigJson");var rt="user.legit-tokens";function st({storageFs:n,gitRoot:i}){return{getUserTokens:o(async e=>{let t=await it.getConfig({fs:n,dir:i,path:rt});return t?tt(t):{accessTokens:[]}},"getUserTokens"),setUserTokens:o(async(e,t)=>await it.setConfig({fs:n,dir:i,path:rt,value:et(t)}),"setUserTokens")}}o(st,"createGitConfigTokenStore");import E from"@legit-sdk/isomorphic-git";var se=class se extends Error{constructor(e,t){super(e);p(this,"code","ENOENT");p(this,"path");this.name="ENOENTError",this.path=t,Object.setPrototypeOf(this,se.prototype)}};o(se,"ENOENTError");var _=se;function ne(n){return n&&n.gitCache!==void 0?n.gitCache:n&&n.parentFs?ne(n.parentFs):{}}o(ne,"getGitCacheFromFs");var oe={type:"gitBranchFileVirtualFile",rootType:"folder",getStats:o(async({gitRoot:n,nodeFs:i,filePath:e,cacheFs:t,pathParams:r,userSpaceFs:s})=>{r.branchName===void 0&&(r.branchName=await k(n,i));let a=await b(i,n,r.branchName);if(!a)throw new _(`ENOENT: no such file or directory, stat '${e}'`,e);let l=await j({filePath:e,gitRoot:n,nodeFs:i,commitSha:a,pathParams:r,gitCache:ne(s)});if(!l)throw new _(`ENOENT: no such file or directory, stat '${e}'`,e);let c=await E.readCommit({fs:i,dir:n,oid:a}),{commit:m}=c,d=await E.log({fs:i,dir:n,ref:a,filepath:r.filePath,depth:1}),f=m.committer.timestamp*1e3,h=d.length>0?d[0].commit.committer.timestamp*1e3:f;if(l.type==="tree")return{mode:420,size:0,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!0,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:0,atimeMs:h,mtimeMs:h,ctimeMs:h,birthtimeMs:f,atime:new Date(h),mtime:new Date(h),ctime:new Date(h),birthtime:new Date(h)};{let{blob:F}=await E.readBlob({fs:i,dir:n,oid:l.oid});return{mode:420,size:F.length,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:Math.ceil(F.length/4096),atimeMs:h,mtimeMs:h,ctimeMs:h,birthtimeMs:h,atime:new Date(h),mtime:new Date(h),ctime:new Date(h),birthtime:new Date(h)}}},"getStats"),getFile:o(async({filePath:n,gitRoot:i,nodeFs:e,cacheFs:t,pathParams:r,userSpaceFs:s})=>{r.branchName===void 0&&(r.branchName=await k(i,e));try{let a=await b(e,i,r.branchName);if(!a){let c=await E.resolveRef({fs:e,dir:i,ref:"HEAD"});if(await E.branch({fs:e,dir:i,ref:r.branchName,object:c}),a=await b(e,i,r.branchName),!a)throw new Error("Could not create branch for getFile")}let l=await j({filePath:n,gitRoot:i,nodeFs:e,commitSha:a,pathParams:r,gitCache:ne(s)});if(!l)return;if(l.type==="blob"){let{blob:c}=await E.readBlob({fs:e,dir:i,oid:l.oid});return{type:"file",content:Buffer.from(c),mode:420,size:c.length,oid:l.oid}}else{let c=[];try{let d=await t.promises.stat(n);if(d&&d.isDirectory()){let f=await t.promises.readdir(n,{withFileTypes:!0});c.push(...f)}}catch{}return{type:"directory",content:Array.from(new Set([...c,...l.entries])).map(d=>({...d,name:d.name.toString(),path:`${n}`,parentPath:`${n}`})),mode:493}}}catch{return}},"getFile"),unlink:o(async({filePath:n,gitRoot:i,nodeFs:e,cacheFs:t,pathParams:r,author:s})=>{if(r.branchName===void 0&&(r.branchName=await k(i,e)),!r.filePath)throw new Error("filePath should be in pathParams");let a=await b(e,i,r.branchName);if(!a)throw new Error("Invalid branch file path - branch must exist");let l=await E.readTree({fs:e,dir:i,oid:a}),c=await x({dir:i,fs:e,treeOid:l.oid,deletePathParts:r.filePath.split("/"),addPathParts:void 0,addObj:void 0,deleteKeepIfNotEmpty:!1,addKeepIfEmpty:!0,keepFilename:".keep"});if(c!==l.oid){let m=await E.commit({fs:e,dir:i,message:`Delete ${r.filePath}`,tree:c,noUpdateBranch:!0,parent:[a],author:s});await E.writeRef({fs:e,dir:i,ref:`refs/heads/${B(r.branchName)}`,value:m,force:!0})}},"unlink"),writeFile:o(async({filePath:n,gitRoot:i,nodeFs:e,content:t,cacheFs:r,pathParams:s,author:a})=>{if(s.branchName===void 0&&(s.branchName=await k(i,e)),s.filePath===void 0)throw new Error("filePath should be in pathParams");let l;typeof t=="string"?l=new TextEncoder().encode(t):l=new Uint8Array(t);let c=await E.writeBlob({fs:e,dir:i,blob:l}),m=await b(e,i,s.branchName);if(!m){let h=await E.resolveRef({fs:e,dir:i,ref:"HEAD"});if(await E.branch({fs:e,dir:i,ref:B(s.branchName),object:h}),m=await b(e,i,s.branchName),!m)throw new Error("Could not create branch for writeFile")}let d=await E.readTree({fs:e,dir:i,oid:m}),f=await x({dir:i,fs:e,treeOid:d.oid,deletePathParts:void 0,addPathParts:s.filePath.split("/"),addObj:{type:"blob",oid:c},deleteKeepIfNotEmpty:!0,addKeepIfEmpty:!1,keepFilename:".keep"});if(f!==d.oid){let h=await E.commit({fs:e,dir:i,message:`\u{1F4BE} Change '${s.filePath}'`,tree:f,noUpdateBranch:!0,parent:[m],author:a});await E.writeRef({fs:e,dir:i,ref:`refs/heads/${B(s.branchName)}`,value:h,force:!0});let F=await b(e,i,s.branchName);if(h!==F)throw new Error("Failed to update branch after file deletion")}},"writeFile"),rename:o(async function({filePath:n,newPath:i,gitRoot:e,nodeFs:t,pathParams:r,newPathParams:s,author:a,userSpaceFs:l}){if(r.branchName===void 0&&(r.branchName=await k(e,t)),r.filePath===void 0)throw new Error("filePath should be in pathParams");if(s.branchName===void 0&&(s.branchName=await k(e,t)),s.filePath===void 0)throw new Error("filePath should be in newPathParams");let c=await b(t,e,r.branchName);if(!c)throw new Error("Invalid branch file path - source branch must exist");let m=await b(t,e,s.branchName);if(!m){let F=await E.resolveRef({fs:t,dir:e,ref:"HEAD"});if(await E.branch({fs:t,dir:e,ref:B(s.branchName),object:F}),m=await b(t,e,s.branchName),m===void 0)throw new Error("Could not create branch for rename operation")}if(s.branchName!==r.branchName)throw new Error("cross branch move not implemented yet");let d=await j({gitRoot:e,nodeFs:t,commitSha:c,filePath:n,pathParams:r,gitCache:ne(l)});if(d===void 0)throw new Error("no obj at path exists");let f=await x({dir:e,fs:t,deletePathParts:r.filePath.split("/"),addPathParts:s.filePath.split("/"),addObj:d.type==="blob"?{type:"blob",oid:d.oid}:{type:"tree",oid:d.oid,entries:d.entries.map(F=>F.name.toString())},treeOid:m,addKeepIfEmpty:!0,deleteKeepIfNotEmpty:!0}),h=await E.readTree({fs:t,dir:e,oid:c});if(f!==h.oid){let F=await E.commit({fs:t,dir:e,message:`\u{1F500} Rename '${r.filePath}' to '${s.filePath}'`,tree:f,noUpdateBranch:!0,parent:[m],author:a});await E.writeRef({fs:t,dir:e,ref:`refs/heads/${B(s.branchName)}`,value:F,force:!0})}},"rename"),mkdir:o(async function(n){n.pathParams.branchName===void 0&&(n.pathParams.branchName=await k(n.gitRoot,n.nodeFs));let i=await b(n.nodeFs,n.gitRoot,n.pathParams.branchName);if(n.pathParams.filePath===void 0&&(n.pathParams.filePath="/",i!==void 0))throw new Error("Folder exists");try{throw await oe.getStats(n),new Error("Folder exists")}catch{}if(n.filePath.endsWith("/")&&(n.filePath=n.filePath.replace(/\/+$/,"")),n.pathParams&&typeof n.pathParams.filePath=="string"&&(n.pathParams.filePath=n.pathParams.filePath.replace(/\/+$/,"")),!i){let a=await E.resolveRef({fs:n.nodeFs,dir:n.gitRoot,ref:"HEAD"});if(await E.branch({fs:n.nodeFs,dir:n.gitRoot,ref:B(n.pathParams.branchName),object:a}),i=await b(n.nodeFs,n.gitRoot,n.pathParams.branchName),i===void 0)throw new Error("Could not create branch for mkdir operation")}let e=await E.readTree({fs:n.nodeFs,dir:n.gitRoot,oid:i}),t=new Uint8Array(0),r=await E.writeBlob({fs:n.nodeFs,dir:n.gitRoot,blob:t}),s=await x({dir:n.gitRoot,fs:n.nodeFs,treeOid:e.oid,deletePathParts:void 0,addPathParts:[...n.pathParams.filePath.split("/"),".keep"],addObj:{type:"blob",oid:r},deleteKeepIfNotEmpty:!0,addKeepIfEmpty:!0,keepFilename:".keep"});if(s!==e.oid){let a=await E.commit({fs:n.nodeFs,dir:n.gitRoot,message:`\u{1F4BE} Change '${n.pathParams.filePath}'`,tree:s,noUpdateBranch:!0,parent:[i],author:n.author});await E.writeRef({fs:n.nodeFs,dir:n.gitRoot,ref:`refs/heads/${B(n.pathParams.branchName)}`,value:a,force:!0})}},"mkdir"),rmdir:o(async({filePath:n,gitRoot:i,nodeFs:e,cacheFs:t,pathParams:r,author:s})=>{if(r.branchName===void 0&&(r.branchName=await k(i,e)),!r.filePath)throw new Error("filePath should be in pathParams");let a=await b(e,i,r.branchName);if(!a)throw new Error("Invalid branch file path - branch must exist");let l=await E.readTree({fs:e,dir:i,oid:a}),c=await x({dir:i,fs:e,treeOid:l.oid,deletePathParts:r.filePath.split("/"),addPathParts:void 0,addObj:void 0,deleteKeepIfNotEmpty:!1,addKeepIfEmpty:!0,keepFilename:".keep"});if(c!==l.oid){let m=await E.commit({fs:e,dir:i,message:`Delete ${r.filePath}`,tree:c,noUpdateBranch:!0,parent:[a],author:s});await E.writeRef({fs:e,dir:i,ref:`refs/heads/${B(r.branchName)}`,value:m,force:!0})}},"rmdir")};import nt from"@legit-sdk/isomorphic-git";var ot={type:"gitBranchesListVirtualFile",rootType:"folder",getStats:o(async({gitRoot:n,nodeFs:i})=>{let e=n+"/.git";try{return await i.promises.stat(e)}catch{throw new Error(`ENOENT: no such file or directory, stat '${e}'`)}},"getStats"),getFile:o(async({gitRoot:n,nodeFs:i,filePath:e})=>{try{let t=await nt.listBranches({fs:i,dir:n}),r=await Promise.all(t.map(async s=>{let a=await nt.resolveRef({fs:i,dir:n,ref:s});return T({parent:e,name:M(s),isDir:!0})}));return{type:"directory",content:r,mode:493,size:r}}catch(t){throw t}},"getFile"),rename:o(async n=>{throw new Error("not implemented")},"rename"),mkdir:o(async function(n){throw new Error("not implemented")},"mkdir")};import K from"@legit-sdk/isomorphic-git";function Oe(n){return n&&n.gitCache!==void 0?n.gitCache:n&&n.parentFs?Oe(n.parentFs):{}}o(Oe,"getGitCacheFromFs");var Be={type:"gitBranchHeadVirtualFile",rootType:"file",getStats:o(async({gitRoot:n,nodeFs:i,pathParams:e,userSpaceFs:t})=>{e.branchName===void 0&&(e.branchName=await k(n,i));let r=await b(i,n,e.branchName);if(!r)throw new Error(`Branch ${e.branchName} does not exist in the repository`);let s=await K.readCommit({fs:i,dir:n,oid:r,cache:Oe(t)}),{commit:a}=s,l=a.committer.timestamp*1e3;return{mode:420,size:40,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:Math.ceil(40/4096),atimeMs:l,mtimeMs:l,ctimeMs:l,birthtimeMs:l,atime:new Date(l),mtime:new Date(l),ctime:new Date(l),birthtime:new Date(l)}},"getStats"),getFile:o(async({gitRoot:n,nodeFs:i,pathParams:e,userSpaceFs:t})=>{e.branchName===void 0&&(e.branchName=await k(n,i));try{let r;try{r=await K.resolveRef({fs:i,dir:n,ref:e.branchName})}catch{r=await K.resolveRef({fs:i,dir:n,ref:`refs/heads/${e.branchName}`})}return{type:"file",content:r+`
|
|
5
|
+
`,mode:420,size:r.length}}catch{return}},"getFile"),writeFile:o(async({filePath:n,gitRoot:i,nodeFs:e,content:t,cacheFs:r,pathParams:s,userSpaceFs:a})=>{console.log("gitBranchHeadVirtualFile writeFile called",{pathParams:s,content:t}),s.branchName===void 0&&(s.branchName=await k(i,e));let l=t.toString().trim();try{await K.readCommit({fs:e,dir:i,oid:l,cache:Oe(a)})}catch{throw new Error(`Commit ${l} does not exist in the repository`)}await K.writeRef({fs:e,dir:i,ref:"refs/heads/"+s.branchName,value:l,force:!0})},"writeFile"),rename(n){throw new Error("not implementsd")},mkdir:o(async function(n){throw new Error("not implemented")},"mkdir")};var Te={type:"legitVirtualFile",rootType:"folder",getStats:o(async({gitRoot:n,nodeFs:i})=>{let e=n+"/.git";try{return await i.promises.stat(e)}catch{throw new Error(`ENOENT: no such file or directory, stat '${e}'`)}},"getStats"),getFile:o(async({gitRoot:n,nodeFs:i})=>({type:"directory",content:[],mode:493,size:0}),"getFile"),rename(n){throw new Error("not implemented")},mkdir:o(async function(n){throw new Error("not implemented")},"mkdir")};import Ce from"@legit-sdk/isomorphic-git";function ae(n){return n&&n.gitCache!==void 0?n.gitCache:n&&n.parentFs?ae(n.parentFs):{}}o(ae,"getGitCacheFromFs");var at={type:"gitCommitFileVirtualFile",rootType:"file",getStats:o(async({filePath:n,gitRoot:i,nodeFs:e,pathParams:t,userSpaceFs:r})=>{if(!t.sha_1_1_2)throw new Error("sha_1_1_2 should be in pathParams");if(!t.sha1_3__40)throw new Error("sha1_3__40 should be in pathParams");let s=t.sha_1_1_2+t.sha1_3__40,a=await j({filePath:n,gitRoot:i,nodeFs:e,commitSha:s,pathParams:t,gitCache:ae(r)});if(!a)throw new _(`ENOENT: no such file or directory, stat '${n}'`,n);let l=await Ce.readCommit({fs:e,dir:i,oid:s}),{commit:c}=l,m=c.committer.timestamp*1e3;if(a.type==="tree")return{mode:420,size:0,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!0,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:0,atimeMs:m,mtimeMs:m,ctimeMs:m,birthtimeMs:m,atime:new Date(m),mtime:new Date(m),ctime:new Date(m),birthtime:new Date(m)};{let{blob:d}=await Ce.readBlob({fs:e,dir:i,oid:a.oid});return{mode:420,size:d.length,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:Math.ceil(d.length/4096),atimeMs:m,mtimeMs:m,ctimeMs:m,birthtimeMs:m,atime:new Date(m),mtime:new Date(m),ctime:new Date(m),birthtime:new Date(m)}}},"getStats"),getFile:o(async({filePath:n,gitRoot:i,nodeFs:e,pathParams:t,userSpaceFs:r})=>{if(!t.sha_1_1_2)throw new Error("sha_1_1_2 should be in pathParams");if(!t.sha1_3__40)throw new Error("sha1_3__40 should be in pathParams");let s=t.sha_1_1_2+t.sha1_3__40;try{let a=await j({filePath:n,gitRoot:i,nodeFs:e,commitSha:s,pathParams:t,gitCache:ae(r)});if(!a)return;if(a.type==="blob"){let{blob:l}=await Ce.readBlob({fs:e,dir:i,oid:a.oid,cache:ae(r)});return{type:"file",content:Buffer.from(l),mode:420,size:l.length,oid:a.oid}}else return{type:"directory",content:Array.from(new Set([...a.entries.filter(c=>c.name!==".keep")])).map(c=>({...c,name:c.name.toString(),path:`${n}`,parentPath:`${n}`})),mode:493}}catch{return}},"getFile"),rename(n){throw new Error("not implementsd")},mkdir:o(async function(n){throw new Error("not implemented")},"mkdir")};import Ne from"@legit-sdk/isomorphic-git";var He={type:"gitCommitVirtualFolder",rootType:"folder",getStats:o(async n=>{let i=n.gitRoot+"/.git";try{return await n.nodeFs.promises.stat(i)}catch{throw new Error(`ENOENT: no such file or directory, stat '${i}'`)}},"getStats"),getFile:o(async({filePath:n,gitRoot:i,nodeFs:e,pathParams:t})=>{let r=await Ne.listBranches({fs:e,dir:i}),s=new Set,a=new Set;for(let m of r){let d=`refs/heads/${m}`;try{let f=await Ne.resolveRef({fs:e,dir:i,ref:d});s.add(f)}catch{}}for(let m of s){let d=await Ne.log({fs:e,dir:i,ref:m});for(let f of d)a.add(f.oid)}if(!t.sha_1_1_2){let m=new Set;for(let f of a)if(m.add(f.slice(0,2)),m.size>=256)break;let d=Array.from(m).sort().map(f=>T({parent:n,name:f,isDir:!0}));return{type:"directory",content:d,mode:493,size:d}}let l=new Set;for(let m of a)m.startsWith(t.sha_1_1_2)&&l.add(m.slice(2,40));let c=Array.from(l).sort().map(m=>T({parent:n,name:m,isDir:!0}));return{type:"directory",content:c,mode:493,size:c.length}},"getFile"),rename(n){throw new Error("not implementsd")},mkdir:o(async function(n){throw new Error("not implemented")},"mkdir")};import A from"@legit-sdk/isomorphic-git";var Le={type:"gitBranchOperationVirtualFile",rootType:"file",getStats:o(async n=>{let{gitRoot:i,nodeFs:e,pathParams:t}=n;t.branchName===void 0&&(t.branchName=await k(i,e));let r=await b(e,i,t.branchName);if(!r)throw new Error(`Base Branch ${t.branchName} for operations does not exis`);let s=await C(e,i,t.branchName),a=!1;if(s)try{r=await A.resolveRef({fs:e,dir:i,ref:s}),a=!0}catch{try{r=await A.resolveRef({fs:e,dir:i,ref:`refs/heads/${s}`}),a=!0}catch{}}let l=await A.readCommit({fs:e,dir:i,oid:r}),{commit:c}=l,m=c.committer.timestamp*1e3;try{return{mode:420,size:40,atimeMs:m,mtimeMs:m,ctimeMs:m,birthtimeMs:m,atime:new Date(m),mtime:new Date(m),ctime:new Date(m),birthtime:new Date(m),isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:0}}catch{throw new Error("ENOENT: no such file or directory, stat operationHistory")}},"getStats"),getFile:o(async n=>{let{gitRoot:i,nodeFs:e,pathParams:t}=n;t.branchName===void 0&&(t.branchName=await k(i,e));let r=await C(e,i,t.branchName),s,a=!1;if(r){if(s=await b(e,i,r),a=!0,!s)throw new Error(`Base Branch ${r} for operations does not exis`)}else if(s=await b(e,i,t.branchName),!s)throw new Error(`Base Branch ${t.branchName} for operations does not exis`);return{type:"file",content:Buffer.from(s),mode:420,size:s.length}},"getFile"),writeFile:o(async({filePath:n,gitRoot:i,nodeFs:e,content:t,cacheFs:r,pathParams:s,author:a})=>{s.branchName===void 0&&(s.branchName=await k(i,e));let l;typeof t=="string"?l=new TextEncoder().encode(t):l=new Uint8Array(t);let c=await A.writeBlob({fs:e,dir:i,blob:l}),m=await b(e,i,s.branchName);if(!m)throw new Error("Invalid branch file path - branch doesn't exist");let d=await C(e,i,s.branchName),f=!1;d||(d="legit/__"+s.branchName+De,await A.branch({fs:e,dir:i,ref:d,object:m}),f=!0);let h=await A.resolveRef({fs:e,dir:i,ref:`refs/heads/${d}`}),F=await A.readTree({fs:e,dir:i,oid:m}),u;t instanceof ArrayBuffer?u=Buffer.from(t).toString("utf-8"):typeof t=="string"?u=t:t instanceof Uint8Array?u=Buffer.from(t).toString("utf-8"):u=String(t);let v=!1;if(!f){let y=await A.findMergeBase({fs:e,dir:i,oids:v?[h]:[h,m]});y.length===1&&y[0]===m&&(v=!0)}let O=await A.commit({fs:e,dir:i,message:u,tree:F.oid,noUpdateBranch:!0,author:a,parent:v?f?[m,m]:[h]:[h,m]});await A.writeRef({fs:e,dir:i,ref:`refs/heads/${d}`,value:O,force:!0})},"writeFile"),rename:o(async function({filePath:n,newPath:i,gitRoot:e,nodeFs:t,pathParams:r,newPathParams:s}){throw new Error("not implemented")},"rename"),mkdir:o(async function(n){throw new Error("not implemented")},"mkdir")};import le from"@legit-sdk/isomorphic-git";var lt={type:"getThreadName",rootType:"file",getStats:o(async n=>{let{gitRoot:i,nodeFs:e,pathParams:t}=n,r=await b(e,i,t.branchName);if(!r)throw new Error(`Base Branch ${t.branchName} for operations does not exis`);let s=await C(e,i,t.branchName),a=!1;if(s)try{r=await le.resolveRef({fs:e,dir:i,ref:s}),a=!0}catch{try{r=await le.resolveRef({fs:e,dir:i,ref:`refs/heads/${s}`}),a=!0}catch{}}let l=await le.readCommit({fs:e,dir:i,oid:r}),{commit:c}=l,m=c.committer.timestamp*1e3;try{return{mode:420,size:40,atimeMs:m,mtimeMs:m,ctimeMs:m,birthtimeMs:m,atime:new Date(m),mtime:new Date(m),ctime:new Date(m),birthtime:new Date(m),isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:0}}catch{throw new Error("ENOENT: no such file or directory, stat operationHistory")}},"getStats"),getFile:o(async n=>{let{gitRoot:i,nodeFs:e,pathParams:t}=n,r=await C(e,i,t.branchName),s;if(r){let a="legit/",l=`__${t.branchName}-operation`;return r.startsWith(a)&&r.endsWith(l)?s=r.slice(a.length,r.length-l.length):s=r,{type:"file",content:Buffer.from(Ke(s)),mode:420,size:s.length}}return{type:"file",content:Buffer.from(""),mode:420,size:0}},"getFile"),writeFile:o(async({filePath:n,gitRoot:i,nodeFs:e,content:t,cacheFs:r,pathParams:s})=>{if(s.branchName===void 0)throw new Error("branchName should be in pathParams");let a=await C(e,i,s.branchName);if(a){let l=`legit/${Je(t.toString())}__${s.branchName}-operation`;await le.renameBranch({fs:e,dir:i,oldref:a,ref:l}),a=l}},"writeFile"),rename:o(async function({filePath:n,newPath:i,gitRoot:e,nodeFs:t,pathParams:r,newPathParams:s}){throw new Error("not implemented")},"rename"),mkdir:o(async function(n){throw new Error("not implemented")},"mkdir")};import mt from"@legit-sdk/isomorphic-git";var Ie={type:"gitBranchHistory",rootType:"file",getStats:o(async({gitRoot:n,nodeFs:i,pathParams:e})=>{e.branchName===void 0&&(e.branchName=await k(n,i));let t=await b(i,n,e.branchName);if(!t)throw new Error(`Branch ${e.branchName} does not exist`);let r=await mt.readCommit({fs:i,dir:n,oid:t}),{commit:s}=r,a=s.committer.timestamp*1e3;return{mode:420,size:1e5,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:Math.ceil(40/4096),atimeMs:a,mtimeMs:a,ctimeMs:a,birthtimeMs:a,atime:new Date(a),mtime:new Date(a),ctime:new Date(a),birthtime:new Date(a)}},"getStats"),getFile:o(async n=>{let{gitRoot:i,nodeFs:e,pathParams:t}=n,r=t.branchName;r===void 0&&(r=await k(i,e));let s=[];if(r){let l=await b(e,i,r),c=!1,m=l;for(;m&&!c;){let d=await mt.readCommit({fs:e,dir:i,oid:m});s.push({oid:d.oid,...d.commit}),m=d.commit.parent[0]}}let a=Buffer.from(JSON.stringify(s,null,2),"utf-8");return{type:"file",content:a,mode:420,size:a.length}},"getFile"),rename:o(async n=>{throw new Error("not implemented")},"rename"),mkdir:o(async function(n){throw new Error("not implemented")},"mkdir")};import V from"@legit-sdk/isomorphic-git";var Ae={type:"gitBranchOperationHeadVirtualFile",rootType:"file",getStats:o(async({gitRoot:n,nodeFs:i,pathParams:e})=>{e.branchName===void 0&&(e.branchName=await k(n,i));let t=await C(i,n,e.branchName);if(!t){let c=new Date(0);return{mode:420,size:0,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:Math.ceil(40/4096),atimeMs:c.getTime(),mtimeMs:c.getTime(),ctimeMs:c.getTime(),birthtimeMs:c.getTime(),atime:c,mtime:c,ctime:c,birthtime:c}}let r;try{r=await V.resolveRef({fs:i,dir:n,ref:t})}catch{r=await V.resolveRef({fs:i,dir:n,ref:`refs/heads/${t}`})}let s=await V.readCommit({fs:i,dir:n,oid:r}),{commit:a}=s,l=a.committer.timestamp*1e3;return{mode:420,size:40,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:Math.ceil(40/4096),atimeMs:l,mtimeMs:l,ctimeMs:l,birthtimeMs:l,atime:new Date(l),mtime:new Date(l),ctime:new Date(l),birthtime:new Date(l)}},"getStats"),getFile:o(async({gitRoot:n,nodeFs:i,pathParams:e})=>{e.branchName===void 0&&(e.branchName=await k(n,i));let t=await C(i,n,e.branchName);if(!t)return{type:"file",content:"",mode:420,size:0};try{let r;try{r=await V.resolveRef({fs:i,dir:n,ref:t})}catch{r=await V.resolveRef({fs:i,dir:n,ref:`refs/heads/${t}`})}return{type:"file",content:r+`
|
|
6
|
+
`,mode:420,size:r.length}}catch{return}},"getFile"),writeFile:o(async({filePath:n,gitRoot:i,nodeFs:e,content:t,cacheFs:r,pathParams:s})=>{s.branchName===void 0&&(s.branchName=await k(i,e));let a=await C(e,i,s.branchName),l=await V.resolveRef({fs:e,dir:i,ref:`refs/heads/${a}`});if(!a)throw new Error(`Operation branch name could not be resolved for branch ${s.branchName}`);let c=t.toString().trim(),m,d,f=!1;if(!l)throw new Error(`Operation branch ref could not be resolved for branch ${a}`);let h=l;for(;h&&!f;){let F=await V.readCommit({fs:e,dir:i,oid:h});if(F.oid===c&&(m=F.oid),h=F.commit.parent&&F.commit.parent.length>0?F.commit.parent[0]:null,F.commit.parent.length===2){if(F.commit.parent[0]===F.commit.parent[1])f=!0;else if(m!==void 0){d=F.commit.parent[1];break}}}if(m===void 0)throw new Error(`Cant rollback to ${c} couldn't find newOperationBranchHead ${m}`);if(d===void 0)throw new Error(`Cant rollback to ${c} couldn't find newBranchHead ${d}`);await V.writeRef({fs:e,dir:i,ref:"refs/heads/"+a,value:m,force:!0}),await V.writeRef({fs:e,dir:i,ref:"refs/heads/"+s.branchName,value:d,force:!0})},"writeFile"),rename(n){throw new Error("not implementsd")},mkdir:o(async function(n){throw new Error("not implemented")},"mkdir")};import Ct from"@legit-sdk/isomorphic-git";import Re from"@legit-sdk/isomorphic-git";async function q(n,i){try{let e=await Re.getConfig({fs:i,dir:n,path:"user.legit-target-branch"});if(e)return M(e)}catch{}try{let e=await Re.getConfig({fs:i,dir:n,path:"init.defaultBranch"});return M(e)||"main"}catch{return"main"}}o(q,"getTargetBranch");async function ct(n,i,e){await Re.setConfig({fs:i,dir:n,path:"user.legit-target-branch",value:B(e)})}o(ct,"setTargetBranch");var dt={type:"gitCurrentBranchVirtualFile",rootType:"file",getStats:o(async({gitRoot:n,nodeFs:i})=>{let t=(await k(n,i)).length;return{mode:420,size:t,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:Math.ceil(t/4096),atimeMs:Date.now(),mtimeMs:Date.now(),ctimeMs:Date.now(),birthtimeMs:Date.now(),atime:new Date,mtime:new Date,ctime:new Date,birthtime:new Date}},"getStats"),getFile:o(async({gitRoot:n,nodeFs:i})=>{let e=await k(n,i);return{type:"file",content:e+`
|
|
7
|
+
`,mode:420,size:e.length+1}},"getFile"),writeFile:o(async({gitRoot:n,nodeFs:i,content:e})=>{let t=e.toString().trim();if(!await b(i,n,t)){let s=await q(n,i),a=await b(i,n,s);if(!a)throw new Error(`Ref branch ${s} does not exist in the repository`);await Ct.branch({fs:i,dir:n,ref:B(t),object:a})}await Qe(n,i,t)},"writeFile"),rename(n){throw new Error("not implemented")},mkdir:o(async function(n){throw new Error("not implemented")},"mkdir")};var R="session_data",me=JSON.stringify({env:{CLAUDE_CONFIG_DIR:`.claude/${R}`}},null,2),ft={type:"claudeVirtualSessionFileVirtualFile",rootType:"folder",getStats:o(async({gitRoot:n,nodeFs:i,filePath:e,cacheFs:t,pathParams:r})=>{let s=e.replace(/\\/g,"/");if(s.endsWith(".claude")||s.endsWith(`.claude/${R}`)||s.endsWith(`.claude/${R}/debug`)||s.endsWith(`.claude/${R}/projects`)||new RegExp(`\\.claude\\/${R}\\/projects\\/[^/]+$`).test(s)){let c=new Date(0);return{mode:16877,size:0,isFile:o(()=>!1,"isFile"),isDirectory:o(()=>!0,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:0,atimeMs:0,mtimeMs:0,ctimeMs:0,birthtimeMs:0,atime:c,mtime:c,ctime:c,birthtime:c}}let a=new Date(0);return s.endsWith(".claude/settings.json")?{mode:420,size:me.length,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:Math.ceil(me.length/4096),atimeMs:a,mtimeMs:a,ctimeMs:a,birthtimeMs:a,atime:a,mtime:a,ctime:a,birthtime:a}:await t.promises.stat(e)},"getStats"),getFile:o(async({filePath:n,gitRoot:i,nodeFs:e,cacheFs:t,pathParams:r})=>{let s=n.replace(/\\/g,"/");if((s.endsWith(".claude")||s.endsWith(".claude/session_data")||s.endsWith(".claude/session_data/projects")||s.endsWith(".claude/session_data/debug")||/\.claude\/session_data\/projects\/[^/]+$/.test(s))&&await t.promises.mkdir(n,{recursive:!0}),s.endsWith(".claude/settings.json"))return{type:"file",content:me,mode:420,size:me.length,oid:"unknown"};try{if((await t.promises.stat(n)).isFile()){let l=await t.promises.readFile(n);return{type:"file",content:l,mode:420,size:l.length,oid:"unknown"}}else{let l=await t.promises.readdir(n,{withFileTypes:!0});if(s.endsWith(".claude")){let c=l.find(d=>d.name.toString()==="settings.json");c||l.push(T({name:"settings.json",parent:n,isDir:!1}));let m=l.find(d=>d.name.toString()===R);c||l.push(T({name:R,parent:n,isDir:!0}))}if(s.endsWith(`.claude/${R}`)&&(l.find(m=>m.name.toString()==="projects")||l.push(T({name:"projects",parent:n,isDir:!0}))),s.endsWith(`.claude/${R}/projects`)&&!l.find(m=>m.name.toString()==="projects")){let m=s.replace(`.claude/${R}/projects`,"");l.push(T({name:m.replaceAll("/","-"),parent:n,isDir:!0}))}return{type:"directory",content:l.map(c=>({...c,name:c.name.toString(),path:`${n}`,parentPath:`${n}`})),mode:493}}}catch{return}},"getFile"),unlink:o(async({filePath:n,gitRoot:i,nodeFs:e,cacheFs:t,pathParams:r,author:s})=>{await t.promises.unlink(n)},"unlink"),writeFile:o(async({filePath:n,gitRoot:i,nodeFs:e,content:t,cacheFs:r,userSpaceFs:s,pathParams:a,author:l})=>{let c=n.replace(/\\/g,"/"),m=/\/projects\/([^/]+)\/([^/]+\.jsonl)$/,d=c.match(m);if(d){let f=d[1],h=d[2];console.log({folder:f,file:h}),await r.promises.stat(n).then(()=>!0).catch(()=>!1)||await r.promises.writeFile(n,"");let v=(await r.promises.readFile(n,"utf-8")).split(`
|
|
8
|
+
`);if(v.length>1){let O=v[v.length-2]||"",y=JSON.parse(O),g="";if(y.type==="user"){let w=y.message?.content;if(Array.isArray(w)&&w[0]?.type==="tool_result"){let D=w[0],S=typeof D.content=="string"?D.content:JSON.stringify(D.content);g=`\u{1F47E} Tool Result (${y.toolUseResult?.type||"unknown"}): ${S}
|
|
104
9
|
|
|
105
10
|
---
|
|
106
11
|
|
|
107
|
-
`}else
|
|
12
|
+
`}else g=`\u{1F464} ${typeof w=="string"?w:w?.[0]?.content||"User action"}
|
|
108
13
|
|
|
109
14
|
---
|
|
110
15
|
|
|
111
|
-
`}else if(
|
|
16
|
+
`}else if(y.type==="assistant"){let w=y.message?.content?.[0],P="";w?.type==="text"?P=w.text:w?.type==="tool_use"?P=`Used tool: ${w.name} with input: ${JSON.stringify(w.input)}`:P="Assistant response",g=`\u{1F47E} ${P}
|
|
112
17
|
|
|
113
18
|
---
|
|
114
19
|
|
|
115
|
-
`}else
|
|
20
|
+
`}else y.type==="file-history-snapshot"?g=`System: File history snapshot for message ${y.messageId}
|
|
116
21
|
|
|
117
22
|
---
|
|
118
23
|
|
|
119
|
-
`:
|
|
24
|
+
`:g=`System: ${y.type||"unknown action"}
|
|
120
25
|
|
|
121
26
|
---
|
|
122
27
|
|
|
123
|
-
`;await
|
|
124
|
-
`,mode:420,size:2}}catch{return}},"getFile"),writeFile:o(async({gitRoot:
|
|
125
|
-
`,mode:420,size:
|
|
126
|
-
|
|
127
|
-
${u}
|
|
128
|
-
|
|
129
|
-
`)},"createFsOperationFileLogger");export{ua as CompositeFs,pa as EphemeralSubFs,Yo as GitSubFs,da as HiddenFileSubFs,Uu as PassThroughSubFs,cL as createFsOperationFileLogger,tv as createLegitSyncService,Jo as gitBranchOperationsVirtualFile,FR as openLegitFs,oL as openLegitFsWithMemoryFs};
|
|
130
|
-
/*!
|
|
131
|
-
* This code for `path.join` is directly copied from @zenfs/core/path for bundle size improvements.
|
|
132
|
-
* SPDX-License-Identifier: LGPL-3.0-or-later
|
|
133
|
-
* Copyright (c) James Prevett and other ZenFS contributors.
|
|
134
|
-
*/
|
|
135
|
-
/*! Bundled license information:
|
|
136
|
-
|
|
137
|
-
safe-buffer/index.js:
|
|
138
|
-
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
139
|
-
|
|
140
|
-
crc-32/crc32.js:
|
|
141
|
-
(*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com *)
|
|
28
|
+
`;await s.promises.writeFile(i+"/.legit/operation",g+O)}}else console.log("No match"),await r.promises.writeFile(n,t)},"writeFile"),rename:o(async function({filePath:n,newPath:i,gitRoot:e,nodeFs:t,pathParams:r,newPathParams:s,author:a,cacheFs:l}){await l.promises.rename(n,i)},"rename"),mkdir:o(async function(n){await n.cacheFs.promises.mkdir(n.filePath,{recursive:!0})},"mkdir"),rmdir:o(async({filePath:n,gitRoot:i,nodeFs:e,cacheFs:t,pathParams:r,author:s})=>{},"rmdir")};import G from"@legit-sdk/isomorphic-git";function $e(n){return n&&n.gitCache!==void 0?n.gitCache:n&&n.parentFs?$e(n.parentFs):{}}o($e,"getGitCacheFromFs");var ht={type:"gitApplyCurrentChangesToVirtualFile",rootType:"file",getStats:o(async({gitRoot:n,nodeFs:i,pathParams:e,userSpaceFs:t})=>{let r=new Date(0);return{mode:420,size:40,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:Math.ceil(40/4096),atimeMs:r,mtimeMs:r,ctimeMs:r,birthtimeMs:r,atime:r,mtime:r,ctime:r,birthtime:r}},"getStats"),getFile:o(async({gitRoot:n,nodeFs:i,pathParams:e,userSpaceFs:t})=>{try{return{type:"file",content:`
|
|
29
|
+
`,mode:420,size:2}}catch{return}},"getFile"),writeFile:o(async({gitRoot:n,nodeFs:i,content:e,userSpaceFs:t,author:r})=>{let s=await k(n,i),a=e.toString().trim(),l=await b(i,n,s,$e(t));if(!l)throw new Error(`Source branch ${s} does not exist`);let c=await b(i,n,a,$e(t));if(!c)throw new Error(`Target branch ${a} does not exist`);let m=await G.readTree({fs:i,dir:n,oid:l});if(await G.readTree({fs:i,dir:n,oid:c})===m)return;let f=await G.commit({fs:i,dir:n,message:"Changes from "+s+" applied to "+a,tree:m.oid,noUpdateBranch:!0,author:r,parent:[l,c]}),h=await G.commit({fs:i,dir:n,message:"Changes from "+s+" applied to "+a,tree:m.oid,noUpdateBranch:!0,author:r,parent:[l,f]});await G.writeRef({fs:i,dir:n,ref:"refs/heads/"+B(a),value:f,force:!0}),await G.writeRef({fs:i,dir:n,ref:"refs/heads/"+B(s),value:h,force:!0})},"writeFile"),rename(n){throw new Error("not implementsd")},mkdir:o(async function(n){throw new Error("not implemented")},"mkdir")};var pt={type:"gitTargetBranchVirtualFile",rootType:"file",getStats:o(async({gitRoot:n,nodeFs:i})=>{let t=(await q(n,i)).length;return{mode:420,size:t,isFile:o(()=>!0,"isFile"),isDirectory:o(()=>!1,"isDirectory"),isSymbolicLink:o(()=>!1,"isSymbolicLink"),isBlockDevice:o(()=>!1,"isBlockDevice"),isCharacterDevice:o(()=>!1,"isCharacterDevice"),isSocket:o(()=>!1,"isSocket"),isFIFO:o(()=>!1,"isFIFO"),isFileSync:o(()=>!0,"isFileSync"),isDirectorySync:o(()=>!1,"isDirectorySync"),dev:0,ino:0,nlink:1,uid:0,gid:0,rdev:0,blksize:4096,blocks:Math.ceil(t/4096),atimeMs:Date.now(),mtimeMs:Date.now(),ctimeMs:Date.now(),birthtimeMs:Date.now(),atime:new Date,mtime:new Date,ctime:new Date,birthtime:new Date}},"getStats"),getFile:o(async({gitRoot:n,nodeFs:i})=>{let e=await q(n,i);return{type:"file",content:e+`
|
|
30
|
+
`,mode:420,size:e.length+1}},"getFile"),writeFile:o(async({gitRoot:n,nodeFs:i,content:e})=>{let t=e.toString().trim();if(!await b(i,n,t))throw new Error(`Branch ${t} does not exist in the repository`);await ct(n,i,t)},"writeFile"),rename(n){throw new Error("not implemented")},mkdir:o(async function(n){throw new Error("not implemented")},"mkdir")};function xe(n){return n&&n.gitCache!==void 0?n.gitCache:n&&n.parentFs?xe(n.parentFs):{}}o(xe,"getGitCache");async function hn(n){let i=new Ht,e=Nt(i);return Lt({...n,storageFs:n?.storageFs?n.storageFs:e,gitRoot:n?.gitRoot||"/"})}o(hn,"openLegitFsWithMemoryFs");async function Lt({storageFs:n,gitRoot:i,anonymousBranch:e="anonymous",showKeepFiles:t=!1,initialAuthor:r={type:"local",id:"local",name:"Local User",email:"local@legitcontrol.com"},serverUrl:s="https://hub.legitcontrol.com",publicKey:a,claudeHandler:l}){await n.promises.readdir(i+"/.git").then(()=>!0).catch(()=>!1)||(await N.init({fs:n,dir:"/",defaultBranch:e}),await n.promises.writeFile(i+"/.gitignore",""),await n.promises.writeFile(i+"/.keep",""),await N.add({fs:n,dir:"/",filepath:".keep",cache:xe(n)}),await N.commit({fs:n,dir:"/",message:"Initial commit",author:{name:"Test",email:"test@example.com"},cache:xe(n)}),await N.setConfig({fs:n,dir:i,path:"init.defaultBranch",value:e})),await N.getConfig({fs:n,dir:i,path:"user.legit_user_id"})||await N.setConfig({fs:n,dir:i,path:"user.legit_user_id",value:r.name}),await N.getConfig({fs:n,dir:i,path:"user.name"})||await N.setConfig({fs:n,dir:i,path:"user.name",value:r.name}),await N.getConfig({fs:n,dir:i,path:"user.email"})||await N.setConfig({fs:n,dir:i,path:"user.email",value:r.email});let h=new Q({name:"git",storageFs:n,gitRoot:i,defaultBranch:e});h.gitCache={};let F={".legit":{".":Te,operation:Le,head:Be,operationHead:Ae,operationHistory:re,history:Ie,currentBranch:dt,"target-branch":pt,"apply-changes":ht,branches:{".":ot,"[branchName]":{".legit":{".":Te,operation:Le,head:Be,operationHead:Ae,operationHistory:re,history:Ie,threadName:lt},"[[...filePath]]":oe}},commits:{".":He,"[sha_1_1_2]":{".":He,"[sha1_3__40]":{"[[...filePath]]":at}}}},".claude":{"[[...filePath]]":ft},"[[...filePath]]":oe};!l&&F[".claude"]&&delete F[".claude"];let u=new ie({name:"git-subfs",parentFs:h,gitRoot:i,gitStorageFs:n,routerConfig:F}),v=t?[".git"]:[".git",".keep"],O=new Y({name:"git-hidden-subfs",parentFs:h,gitRoot:i,hiddenFiles:v}),y=new ee({name:"git-ephemeral-subfs",parentFs:h,gitRoot:i,ephemeralPatterns:["**/._*","**/.DS_Store","**/.AppleDouble/","**/.AppleDB","**/.AppleDesktop","**/.Spotlight-V100","**/.TemporaryItems","**/.Trashes","**/.fseventsd","**/.VolumeIcon.icns","**/.ql_disablethumbnails","**/.~lock.*","**/lu[0-9a-zA-Z]*.tmp","**/.metaentries.json.tmp","**/**.tmp.**","**/**.sb-**"]});h.addSubFs(u),h.setHiddenFilesSubFs(O),h.setEphemeralFilesSubFs(y);let g=st({storageFs:n,gitRoot:i}),w=Ze(g,a),P=Ye({fs:n,gitRepoPath:i,serverUrl:s,auth:w,anonymousBranch:e}),D=Object.assign(h,{auth:w,sync:P,setLogger(S){h.setLoggger(S)},push:o(async S=>{},"push"),shareCurrentBranch:o(async()=>{if((await w.getUser()).type==="local")throw new Error("login first - for example anonymously using legitfs.auth.signInAnonymously()");let S=await D.getCurrentBranch();return S===e&&(S=(await w.getUser()).id,await N.renameBranch({fs:n,dir:i,oldref:e,ref:S})),await P.sequentialPush([S]),D.setCurrentBranch(S),S},"shareCurrentBranch"),setCurrentBranch:o(async S=>{(await N.listBranches({fs:n,dir:i})).includes(S)||await P?.loadBranch(S);let fe=(await N.listBranches({fs:n,dir:i})).includes(S);if(console.log("branchExistsAfter",fe),!fe)throw new Error(`Branch ${S} does not exist`);await N.setConfig({fs:n,dir:i,path:"init.defaultBranch",value:S})},"setCurrentBranch"),getCurrentBranch:o(async()=>{let S=await N.getConfig({fs:n,dir:i,path:"init.defaultBranch"});if(!S)throw new Error("No current branch set");return S},"getCurrentBranch")});return D}o(Lt,"openLegitFs");var Fn=o(n=>async i=>{if(!i.path.includes(".legit/branches/")||(i.path.match(/\.legit/g)||[]).length>1)return;let[e,t]=i.path.split(".legit/branches/"),[r,...s]=t.split("/"),a=s.join("/"),l=e+".legit/branches/"+r+"/.legit/operation",c=JSON.stringify(i.operationArgs,(m,d)=>Buffer.isBuffer(d)?{__buffer__:d.toString("base64")}:d);console.log(l,`[${i.fsName}].${i.operation}(${i.fd?i.fd.fd+" - ":""}${i.path})
|
|
142
31
|
|
|
143
|
-
|
|
144
|
-
(*! simple-concat. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
32
|
+
${c}
|
|
145
33
|
|
|
146
|
-
|
|
147
|
-
(*! simple-get. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
148
|
-
*/
|
|
34
|
+
`)},"createFsOperationFileLogger");export{Q as CompositeFs,ee as EphemeralSubFs,ie as GitSubFs,Y as HiddenFileSubFs,_e as PassThroughSubFs,Fn as createFsOperationFileLogger,Ye as createLegitSyncService,re as gitBranchOperationsVirtualFile,Lt as openLegitFs,hn as openLegitFsWithMemoryFs};
|