import{S as e,h as t,l as n,m as r,n as i,p as a,t as o,x as s,y as c}from"./github-B-FmP-qI.js";import{a as l,c as u,d,f,i as p,l as m,m as h,n as g,o as _,p as v,s as y}from"./utils-CZUacPOo.js";import{o as b,s as x,t as S}from"./get-packages.cjs-Lk6WyPet.js";import{t as C}from"./readChangesetState-Otq6gfkp.js";import w from"node:fs/promises";import T from"node:path";import{promises as E}from"fs";import{relative as D,resolve as O}from"path";const k=async(e,t)=>(await e.graphql(` query getRepositoryMetadata( $owner: String! $repo: String! $baseRef: String! $targetRef: String! ) { repository(owner: $owner, name: $repo) { id baseRef: ref(qualifiedName: $baseRef) { id target { oid ... on Tag { target { oid } } } } targetBranch: ref(qualifiedName: $targetRef) { id target { oid } } } } `,t)).repository,A=async(e,t)=>e.graphql(` mutation createCommitOnBranch($input: CreateCommitOnBranchInput!) { createCommitOnBranch(input: $input) { commit { oid } ref { id } } } `,t),j=e=>`branch`in e?`refs/heads/${e.branch}`:`tag`in e?`refs/tags/${e.tag}`:`HEAD`,M=(e,t)=>{if(`commit`in e)return e.commit;if(!t?.target)throw Error(`Could not determine oid from ref: ${JSON.stringify(t)}`);return`target`in t.target?t.target.target.oid:t.target.oid},N=e=>typeof e==`object`&&!!e&&`status`in e&&`message`in e&&typeof e.status==`number`&&typeof e.message==`string`&&e.status===422&&e.message.includes(`Reference already exists`),P=async({octokit:e,refId:t,baseOid:n,message:r,fileChanges:i})=>{let a=typeof r==`string`?{headline:r.split(` `)[0]?.trim()??``,body:r.split(` `).slice(1).join(` `).trim()}:r;return A(e,{input:{branch:{id:t},expectedHeadOid:n,message:a,fileChanges:i}})},ee=async({octokit:e,owner:t,repo:n,branch:r,base:i,force:a=!1,message:o,fileChanges:s,log:c})=>{let l=`${t}/${n}`,u=j(i),d=`refs/heads/${r}`;c?.debug(`Getting repo info ${l}`);let f=await k(e,{owner:t,repo:n,baseRef:u,targetRef:d});if(c?.debug(`Repo info: ${JSON.stringify(f,null,2)}`),!f)throw Error(`Repository ${JSON.stringify(l)} not found`);if(!(`commit`in i)&&!f.baseRef)throw Error(`Ref ${JSON.stringify(u)} not found`);let p=f.baseRef,m=M(i,f.baseRef),h=f.targetBranch?.target?.oid??null,g=`branch`in i&&i.branch===r,_;if(g)_=a?`force-update`:`update`;else if(h===null)_=`create`;else if(a)_=`force-update`;else if(h===m)_=`update`;else throw Error(`Branch ${r} exists already and does not match base ${m}, force is set to false`);if(_===`force-update`){let i=`changesets-ghcommit-temp/${r}`,a;try{let r=(await e.rest.git.createRef({owner:t,repo:n,ref:`refs/heads/${i}`,sha:m})).data.node_id;if(!r)throw Error(`Failed to create temporary branch ${i}`);a=r}catch(r){if(!N(r))throw r;let o=(await e.rest.git.updateRef({owner:t,repo:n,ref:`heads/${i}`,sha:m,force:!0})).data.node_id;if(!o)throw Error(`Failed to update temporary branch ${i}`);a=o}c?.debug(`Creating commit on branch ${i}`);let l=(await P({octokit:e,refId:a,baseOid:m,message:o,fileChanges:s})).createCommitOnBranch?.commit?.oid;if(!l)throw Error(`Failed to determine head commit of temporary branch ${i}`);let u=(await e.rest.git.updateRef({owner:t,repo:n,ref:`heads/${r}`,sha:l,force:!0})).data.node_id;if(!u)throw Error(`Failed to update branch ${r}`);return await e.rest.git.deleteRef({owner:t,repo:n,ref:`heads/${i}`}),{refId:u}}let v;if(_===`create`){let i=(await e.rest.git.createRef({owner:t,repo:n,ref:`refs/heads/${r}`,sha:m})).data.node_id;if(!i)throw Error(`Failed to create branch ${r}`);v=i}else v=g?p.id:f.targetBranch.id;return c?.debug(`Creating commit on branch ${r}`),{refId:(await P({octokit:e,refId:v,baseOid:m,message:o,fileChanges:s})).createCommitOnBranch?.ref?.id??null}},te=async({fileChanges:e,...t})=>ee({...t,fileChanges:{additions:e.additions?.map(({path:e,contents:t})=>({path:e,contents:t.toString(`base64`)})),deletions:e.deletions?.map(e=>({path:e}))}});var ne=c(((e,t)=>{var n=function(e){if(e||={},this.Promise=e.Promise||Promise,this.queues=Object.create(null),this.domainReentrant=e.domainReentrant||!1,this.domainReentrant){if(typeof process>`u`||process.domain===void 0)throw 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||n.DEFAULT_TIMEOUT,this.maxOccupationTime=e.maxOccupationTime||n.DEFAULT_MAX_OCCUPATION_TIME,this.maxExecutionTime=e.maxExecutionTime||n.DEFAULT_MAX_EXECUTION_TIME,e.maxPending===1/0||Number.isInteger(e.maxPending)&&e.maxPending>=0?this.maxPending=e.maxPending:this.maxPending=n.DEFAULT_MAX_PENDING};n.DEFAULT_TIMEOUT=0,n.DEFAULT_MAX_OCCUPATION_TIME=0,n.DEFAULT_MAX_EXECUTION_TIME=0,n.DEFAULT_MAX_PENDING=1e3,n.prototype.acquire=function(e,t,n,r){if(Array.isArray(e))return this._acquireBatch(e,t,n,r);if(typeof t!=`function`)throw Error(`You must pass a function to execute`);var i=null,a=null,o=null;typeof n!=`function`&&(r=n,n=null,o=new this.Promise(function(e,t){i=e,a=t})),r||={};var s=!1,c=null,l=null,u=null,d=this,f=function(t,r,c){l&&=(clearTimeout(l),null),u&&=(clearTimeout(u),null),t&&(d.queues[e]&&d.queues[e].length===0&&delete d.queues[e],d.domainReentrant&&delete d.domains[e]),s||=(o?r?a(r):i(c):typeof n==`function`&&n(r,c),!0),t&&d.queues[e]&&d.queues[e].length>0&&d.queues[e].shift()()},p=function(n){if(s)return f(n);c&&=(clearTimeout(c),null),d.domainReentrant&&n&&(d.domains[e]=process.domain);var i=r.maxExecutionTime||d.maxExecutionTime;if(i&&(u=setTimeout(function(){d.queues[e]&&f(n,Error(`Maximum execution time is exceeded `+e))},i)),t.length===1){var a=!1;try{t(function(e,t){a||(a=!0,f(n,e,t))})}catch(e){a||(a=!0,f(n,e))}}else d._promiseTry(function(){return t()}).then(function(e){f(n,void 0,e)},function(e){f(n,e)})};d.domainReentrant&&process.domain&&(p=process.domain.bind(p));var m=r.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)f(!1,Error(`Too many pending tasks in queue `+e));else{var h=function(){p(!0)};r.skipQueue?d.queues[e].unshift(h):d.queues[e].push(h);var g=r.timeout||d.timeout;g&&(c=setTimeout(function(){c=null,f(!1,Error(`async-lock timed out in queue `+e))},g))}var _=r.maxOccupationTime||d.maxOccupationTime;if(_&&(l=setTimeout(function(){d.queues[e]&&f(!1,Error(`Maximum occupation time is exceeded in queue `+e))},_)),o)return o},n.prototype._acquireBatch=function(e,t,n,r){typeof n!=`function`&&(r=n,n=null);var i=this,a=function(e,t){return function(n){i.acquire(e,t,n,r)}},o=e.reduceRight(function(e,t){return a(t,e)},t);if(typeof n==`function`)o(n);else return new this.Promise(function(e,t){o.length===1?o(function(n,r){n?t(n):e(r)}):e(o())})},n.prototype.isBusy=function(e){return e?!!this.queues[e]:Object.keys(this.queues).length>0},n.prototype._promiseTry=function(e){try{return this.Promise.resolve(e())}catch(e){return this.Promise.reject(e)}},t.exports=n})),re=c(((e,t)=>{t.exports=ne()})),ie=c(((e,t)=>{var n={}.toString;t.exports=Array.isArray||function(e){return n.call(e)==`[object Array]`}})),ae=c(((e,t)=>{t.exports=TypeError})),oe=c(((e,t)=>{t.exports=Object})),se=c(((e,t)=>{t.exports=Error})),F=c(((e,t)=>{t.exports=EvalError})),I=c(((e,t)=>{t.exports=RangeError})),ce=c(((e,t)=>{t.exports=ReferenceError})),le=c(((e,t)=>{t.exports=SyntaxError})),ue=c(((e,t)=>{t.exports=URIError})),de=c(((e,t)=>{t.exports=Math.abs})),L=c(((e,t)=>{t.exports=Math.floor})),fe=c(((e,t)=>{t.exports=Math.max})),pe=c(((e,t)=>{t.exports=Math.min})),R=c(((e,t)=>{t.exports=Math.pow})),z=c(((e,t)=>{t.exports=Math.round})),B=c(((e,t)=>{t.exports=Number.isNaN||function(e){return e!==e}})),me=c(((e,t)=>{var n=B();t.exports=function(e){return n(e)||e===0?e:e<0?-1:1}})),V=c(((e,t)=>{t.exports=Object.getOwnPropertyDescriptor})),H=c(((e,t)=>{var n=V();if(n)try{n([],`length`)}catch{n=null}t.exports=n})),U=c(((e,t)=>{var n=Object.defineProperty||!1;if(n)try{n({},`a`,{value:1})}catch{n=!1}t.exports=n})),W=c(((e,t)=>{t.exports=function(){if(typeof Symbol!=`function`||typeof Object.getOwnPropertySymbols!=`function`)return!1;if(typeof Symbol.iterator==`symbol`)return!0;var e={},t=Symbol(`test`),n=Object(t);if(typeof t==`string`||Object.prototype.toString.call(t)!==`[object Symbol]`||Object.prototype.toString.call(n)!==`[object Symbol]`)return!1;var r=42;for(var i in e[t]=r,e)return!1;if(typeof Object.keys==`function`&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames==`function`&&Object.getOwnPropertyNames(e).length!==0)return!1;var a=Object.getOwnPropertySymbols(e);if(a.length!==1||a[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor==`function`){var o=Object.getOwnPropertyDescriptor(e,t);if(o.value!==r||o.enumerable!==!0)return!1}return!0}})),G=c(((e,t)=>{var n=typeof Symbol<`u`&&Symbol,r=W();t.exports=function(){return typeof n!=`function`||typeof Symbol!=`function`||typeof n(`foo`)!=`symbol`||typeof Symbol(`bar`)!=`symbol`?!1:r()}})),K=c(((e,t)=>{t.exports=typeof Reflect<`u`&&Reflect.getPrototypeOf||null})),q=c(((e,t)=>{t.exports=oe().getPrototypeOf||null})),J=c(((e,t)=>{var n=`Function.prototype.bind called on incompatible `,r=Object.prototype.toString,i=Math.max,a=`[object Function]`,o=function(e,t){for(var n=[],r=0;r{var n=J();t.exports=Function.prototype.bind||n})),he=c(((e,t)=>{t.exports=Function.prototype.call})),ge=c(((e,t)=>{t.exports=Function.prototype.apply})),X=c(((e,t)=>{t.exports=typeof Reflect<`u`&&Reflect&&Reflect.apply})),_e=c(((e,t)=>{var n=Y(),r=ge(),i=he();t.exports=X()||n.call(i,r)})),ve=c(((e,t)=>{var n=Y(),r=ae(),i=he(),a=_e();t.exports=function(e){if(e.length<1||typeof e[0]!=`function`)throw new r(`a function is required`);return a(n,i,e)}})),Z=c(((e,t)=>{var n=ve(),r=H(),i;try{i=[].__proto__===Array.prototype}catch(e){if(!e||typeof e!=`object`||!(`code`in e)||e.code!==`ERR_PROTO_ACCESS`)throw e}var a=!!i&&r&&r(Object.prototype,`__proto__`),o=Object,s=o.getPrototypeOf;t.exports=a&&typeof a.get==`function`?n([a.get]):typeof s==`function`?function(e){return s(e==null?e:o(e))}:!1})),Q=c(((e,t)=>{var n=K(),r=q(),i=Z();t.exports=n?function(e){return n(e)}:r?function(e){if(!e||typeof e!=`object`&&typeof e!=`function`)throw TypeError(`getProto: not an object`);return r(e)}:i?function(e){return i(e)}:null})),ye=c(((e,t)=>{var n=Function.prototype.call,r=Object.prototype.hasOwnProperty;t.exports=Y().call(n,r)})),be=c(((e,t)=>{var n,r=oe(),i=se(),a=F(),o=I(),s=ce(),c=le(),l=ae(),u=ue(),d=de(),f=L(),p=fe(),m=pe(),h=R(),g=z(),_=me(),v=Function,y=function(e){try{return v(`"use strict"; return (`+e+`).constructor;`)()}catch{}},b=H(),x=U(),S=function(){throw new l},C=b?function(){try{return arguments.callee,S}catch{try{return b(arguments,`callee`).get}catch{return S}}}():S,w=G()(),T=Q(),E=q(),D=K(),O=ge(),k=he(),A={},j=typeof Uint8Array>`u`||!T?n:T(Uint8Array),M={__proto__:null,"%AggregateError%":typeof AggregateError>`u`?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>`u`?n:ArrayBuffer,"%ArrayIteratorPrototype%":w&&T?T([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":A,"%AsyncGenerator%":A,"%AsyncGeneratorFunction%":A,"%AsyncIteratorPrototype%":A,"%Atomics%":typeof Atomics>`u`?n:Atomics,"%BigInt%":typeof BigInt>`u`?n:BigInt,"%BigInt64Array%":typeof BigInt64Array>`u`?n:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>`u`?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>`u`?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":i,"%eval%":eval,"%EvalError%":a,"%Float16Array%":typeof Float16Array>`u`?n:Float16Array,"%Float32Array%":typeof Float32Array>`u`?n:Float32Array,"%Float64Array%":typeof Float64Array>`u`?n:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>`u`?n:FinalizationRegistry,"%Function%":v,"%GeneratorFunction%":A,"%Int8Array%":typeof Int8Array>`u`?n:Int8Array,"%Int16Array%":typeof Int16Array>`u`?n:Int16Array,"%Int32Array%":typeof Int32Array>`u`?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":w&&T?T(T([][Symbol.iterator]())):n,"%JSON%":typeof JSON==`object`?JSON:n,"%Map%":typeof Map>`u`?n:Map,"%MapIteratorPrototype%":typeof Map>`u`||!w||!T?n:T(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":r,"%Object.getOwnPropertyDescriptor%":b,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>`u`?n:Promise,"%Proxy%":typeof Proxy>`u`?n:Proxy,"%RangeError%":o,"%ReferenceError%":s,"%Reflect%":typeof Reflect>`u`?n:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>`u`?n:Set,"%SetIteratorPrototype%":typeof Set>`u`||!w||!T?n:T(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>`u`?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":w&&T?T(``[Symbol.iterator]()):n,"%Symbol%":w?Symbol:n,"%SyntaxError%":c,"%ThrowTypeError%":C,"%TypedArray%":j,"%TypeError%":l,"%Uint8Array%":typeof Uint8Array>`u`?n:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>`u`?n:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>`u`?n:Uint16Array,"%Uint32Array%":typeof Uint32Array>`u`?n:Uint32Array,"%URIError%":u,"%WeakMap%":typeof WeakMap>`u`?n:WeakMap,"%WeakRef%":typeof WeakRef>`u`?n:WeakRef,"%WeakSet%":typeof WeakSet>`u`?n:WeakSet,"%Function.prototype.call%":k,"%Function.prototype.apply%":O,"%Object.defineProperty%":x,"%Object.getPrototypeOf%":E,"%Math.abs%":d,"%Math.floor%":f,"%Math.max%":p,"%Math.min%":m,"%Math.pow%":h,"%Math.round%":g,"%Math.sign%":_,"%Reflect.getPrototypeOf%":D};if(T)try{null.error}catch(e){M[`%Error.prototype%`]=T(T(e))}var N=function e(t){var n;if(t===`%AsyncFunction%`)n=y(`async function () {}`);else if(t===`%GeneratorFunction%`)n=y(`function* () {}`);else if(t===`%AsyncGeneratorFunction%`)n=y(`async function* () {}`);else if(t===`%AsyncGenerator%`){var r=e(`%AsyncGeneratorFunction%`);r&&(n=r.prototype)}else if(t===`%AsyncIteratorPrototype%`){var i=e(`%AsyncGenerator%`);i&&T&&(n=T(i.prototype))}return M[t]=n,n},P={__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`]},ee=Y(),te=ye(),ne=ee.call(k,Array.prototype.concat),re=ee.call(O,Array.prototype.splice),ie=ee.call(k,String.prototype.replace),B=ee.call(k,String.prototype.slice),V=ee.call(k,RegExp.prototype.exec),W=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,J=/\\(\\)?/g,X=function(e){var t=B(e,0,1),n=B(e,-1);if(t===`%`&&n!==`%`)throw new c("invalid intrinsic syntax, expected closing `%`");if(n===`%`&&t!==`%`)throw new c("invalid intrinsic syntax, expected opening `%`");var r=[];return ie(e,W,function(e,t,n,i){r[r.length]=n?ie(i,J,`$1`):t||e}),r},_e=function(e,t){var n=e,r;if(te(P,n)&&(r=P[n],n=`%`+r[0]+`%`),te(M,n)){var i=M[n];if(i===A&&(i=N(n)),i===void 0&&!t)throw new l(`intrinsic `+e+` exists, but is not available. Please file an issue!`);return{alias:r,name:n,value:i}}throw new c(`intrinsic `+e+` does not exist!`)};t.exports=function(e,t){if(typeof e!=`string`||e.length===0)throw new l(`intrinsic name must be a non-empty string`);if(arguments.length>1&&typeof t!=`boolean`)throw new l(`"allowMissing" argument must be a boolean`);if(V(/^%?[^%]*%?$/,e)===null)throw new c("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=X(e),r=n.length>0?n[0]:``,i=_e(`%`+r+`%`,t),a=i.name,o=i.value,s=!1,u=i.alias;u&&(r=u[0],re(n,ne([0,1],u)));for(var d=1,f=!0;d=n.length){var g=b(o,p);f=!!g,o=f&&`get`in g&&!(`originalValue`in g.get)?g.get:o[p]}else f=te(o,p),o=o[p];f&&!s&&(M[a]=o)}}return o}})),xe=c(((e,t)=>{var n=be(),r=ve(),i=r([n(`%String.prototype.indexOf%`)]);t.exports=function(e,t){var a=n(e,!!t);return typeof a==`function`&&i(e,`.prototype.`)>-1?r([a]):a}})),Se=c(((e,t)=>{var n=Function.prototype.toString,r=typeof Reflect==`object`&&Reflect!==null&&Reflect.apply,i,a;if(typeof r==`function`&&typeof Object.defineProperty==`function`)try{i=Object.defineProperty({},`length`,{get:function(){throw a}}),a={},r(function(){throw 42},null,i)}catch(e){e!==a&&(r=null)}else r=null;var o=/^\s*class\b/,s=function(e){try{var t=n.call(e);return o.test(t)}catch{return!1}},c=function(e){try{return s(e)?!1:(n.call(e),!0)}catch{return!1}},l=Object.prototype.toString,u=`[object Object]`,d=`[object Function]`,f=`[object GeneratorFunction]`,p=`[object HTMLAllCollection]`,m=`[object HTML document.all class]`,h=`[object HTMLCollection]`,g=typeof Symbol==`function`&&!!Symbol.toStringTag,_=!(0 in[,]),v=function(){return!1};if(typeof document==`object`){var y=document.all;l.call(y)===l.call(document.all)&&(v=function(e){if((_||!e)&&(e===void 0||typeof e==`object`))try{var t=l.call(e);return(t===p||t===m||t===h||t===u)&&e(``)==null}catch{}return!1})}t.exports=r?function(e){if(v(e))return!0;if(!e||typeof e!=`function`&&typeof e!=`object`)return!1;try{r(e,null,i)}catch(e){if(e!==a)return!1}return!s(e)&&c(e)}:function(e){if(v(e))return!0;if(!e||typeof e!=`function`&&typeof e!=`object`)return!1;if(g)return c(e);if(s(e))return!1;var t=l.call(e);return t!==d&&t!==f&&!/^\[object HTML/.test(t)?!1:c(e)}})),Ce=c(((e,t)=>{var n=Se(),r=Object.prototype.toString,i=Object.prototype.hasOwnProperty,a=function(e,t,n){for(var r=0,a=e.length;r=3&&(i=r),c(e)?a(e,t,i):typeof e==`string`?o(e,t,i):s(e,t,i)}})),$=c(((e,t)=>{t.exports=[`Float16Array`,`Float32Array`,`Float64Array`,`Int8Array`,`Int16Array`,`Int32Array`,`Uint8Array`,`Uint8ClampedArray`,`Uint16Array`,`Uint32Array`,`BigInt64Array`,`BigUint64Array`]})),we=c(((e,t)=>{var n=$(),r=typeof globalThis>`u`?global:globalThis;t.exports=function(){for(var e=[],t=0;t{var n=U(),r=le(),i=ae(),a=H();t.exports=function(e,t,o){if(!e||typeof e!=`object`&&typeof e!=`function`)throw new i("`obj` must be an object or a function`");if(typeof t!=`string`&&typeof t!=`symbol`)throw new i("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!=`boolean`&&arguments[3]!==null)throw new i("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!=`boolean`&&arguments[4]!==null)throw new i("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!=`boolean`&&arguments[5]!==null)throw new i("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!=`boolean`)throw new i("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,c=arguments.length>4?arguments[4]:null,l=arguments.length>5?arguments[5]:null,u=arguments.length>6?arguments[6]:!1,d=!!a&&a(e,t);if(n)n(e,t,{configurable:l===null&&d?d.configurable:!l,enumerable:s===null&&d?d.enumerable:!s,value:o,writable:c===null&&d?d.writable:!c});else if(u||!s&&!c&&!l)e[t]=o;else throw new r(`This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.`)}})),Ee=c(((e,t)=>{var n=U(),r=function(){return!!n};r.hasArrayLengthDefineBug=function(){if(!n)return null;try{return n([],`length`,{value:1}).length!==1}catch{return!0}},t.exports=r})),De=c(((e,t)=>{var n=be(),r=Te(),i=Ee()(),a=H(),o=ae(),s=n(`%Math.floor%`);t.exports=function(e,t){if(typeof e!=`function`)throw new o("`fn` is not a function");if(typeof t!=`number`||t<0||t>4294967295||s(t)!==t)throw new o("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],c=!0,l=!0;if(`length`in e&&a){var u=a(e,`length`);u&&!u.configurable&&(c=!1),u&&!u.writable&&(l=!1)}return(c||l||!n)&&(i?r(e,`length`,t,!0,!0):r(e,`length`,t)),e}})),Oe=c(((e,t)=>{var n=Y(),r=ge(),i=_e();t.exports=function(){return i(n,r,arguments)}})),ke=c(((e,t)=>{var n=De(),r=U(),i=ve(),a=Oe();t.exports=function(e){var t=i(arguments),r=1+e.length-(arguments.length-1);return n(t,r>0?r:0,!0)},r?r(t.exports,`apply`,{value:a}):t.exports.apply=a})),Ae=c(((e,t)=>{var n=W();t.exports=function(){return n()&&!!Symbol.toStringTag}})),je=c(((e,t)=>{var n=Ce(),r=we(),i=ke(),a=xe(),o=H(),s=Q(),c=a(`Object.prototype.toString`),l=Ae()(),u=typeof globalThis>`u`?global:globalThis,d=r(),f=a(`String.prototype.slice`),p=a(`Array.prototype.indexOf`,!0)||function(e,t){for(var n=0;n-1?t:t===`Object`?g(e):!1}return o?h(e):null}})),Me=c(((e,t)=>{var n=je();t.exports=function(e){return!!n(e)}})),Ne=c(((e,t)=>{var n=ae(),r=xe()(`TypedArray.prototype.buffer`,!0),i=Me();t.exports=r||function(e){if(!i(e))throw new n(`Not a Typed Array`);return e.buffer}})),Pe=c(((e,t)=>{var n=v().Buffer,r=ie(),i=Ne(),a=ArrayBuffer.isView||function(e){try{return i(e),!0}catch{return!1}},o=typeof Uint8Array<`u`,s=typeof ArrayBuffer<`u`&&typeof Uint8Array<`u`,c=s&&(n.prototype instanceof Uint8Array||n.TYPED_ARRAY_SUPPORT);t.exports=function(e,t){if(n.isBuffer(e))return e.constructor&&!(`isBuffer`in e)?n.from(e):e;if(typeof e==`string`)return n.from(e,t);if(s&&a(e)){if(e.byteLength===0)return n.alloc(0);if(c){var i=n.from(e.buffer,e.byteOffset,e.byteLength);if(i.byteLength===e.byteLength)return i}var l=e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),u=n.from(l);if(u.length===e.byteLength)return u}if(o&&e instanceof Uint8Array)return n.from(e);var d=r(e);if(d)for(var f=0;f255||~~p!==p)throw RangeError(`Array items must be numbers in the range 0-255.`)}if(d||n.isBuffer(e)&&e.constructor&&typeof e.constructor.isBuffer==`function`&&e.constructor.isBuffer(e))return n.from(e);throw TypeError(`The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.`)}})),Fe=c(((e,t)=>{var n=v().Buffer,r=Pe();function i(e,t){this._block=n.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}i.prototype.update=function(e,t){e=r(e,t||`utf8`);for(var n=this._block,i=this._blockSize,a=e.length,o=this._len,s=0;s=this._finalSize&&(this._update(this._block),this._block.fill(0));var n=this._len*8;if(n<=4294967295)this._block.writeUInt32BE(n,this._blockSize-4);else{var r=(n&4294967295)>>>0,i=(n-r)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var a=this._hash();return e?a.toString(e):a},i.prototype._update=function(){throw Error(`_update must be implemented by subclass`)},t.exports=i})),Ie=c(((e,t)=>{var n=h(),r=Fe(),i=v().Buffer,a=[1518500249,1859775393,-1894007588,-899497514],o=Array(80);function s(){this.init(),this._w=o,r.call(this,64,56)}n(s,r),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function c(e){return e<<1|e>>>31}function l(e){return e<<5|e>>>27}function u(e){return e<<30|e>>>2}function d(e,t,n,r){return e===0?t&n|~t&r:e===2?t&n|t&r|n&r:t^n^r}s.prototype._update=function(e){for(var t=this._w,n=this._a|0,r=this._b|0,i=this._c|0,o=this._d|0,s=this._e|0,f=0;f<16;++f)t[f]=e.readInt32BE(f*4);for(;f<80;++f)t[f]=c(t[f-3]^t[f-8]^t[f-14]^t[f-16]);for(var p=0;p<80;++p){var m=~~(p/20),h=l(n)+d(m,r,i,o)+s+t[p]+a[m]|0;s=o,o=i,i=u(r),r=n,n=h}this._a=n+this._a|0,this._b=r+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0},s.prototype._hash=function(){var e=i.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},t.exports=s})),Le=c((e=>{var t=typeof Uint8Array<`u`&&typeof Uint16Array<`u`&&typeof Int32Array<`u`;function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.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 TypeError(r+`must be non-object`);for(var i in r)n(r,i)&&(e[i]=r[i])}}return e},e.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var r={arraySet:function(e,t,n,r,i){if(t.subarray&&e.subarray){e.set(t.subarray(n,n+r),i);return}for(var a=0;a{var t=Le(),n=4,r=0,i=1,a=2;function o(e){for(var t=e.length;--t>=0;)e[t]=0}var s=0,c=1,l=2,u=3,d=258,f=29,p=256,m=p+1+f,h=30,g=19,_=2*m+1,v=15,y=16,b=7,x=256,S=16,C=17,w=18,T=[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],E=[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],D=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],O=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],k=512,A=Array((m+2)*2);o(A);var j=Array(h*2);o(j);var M=Array(k);o(M);var N=Array(d-u+1);o(N);var P=Array(f);o(P);var ee=Array(h);o(ee);function te(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}var ne,re,ie;function ae(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function oe(e){return e<256?M[e]:M[256+(e>>>7)]}function se(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function F(e,t,n){e.bi_valid>y-n?(e.bi_buf|=t<>y-e.bi_valid,e.bi_valid+=n-y):(e.bi_buf|=t<>>=1,n<<=1;while(--t>0);return n>>>1}function le(e){e.bi_valid===16?(se(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)}function ue(e,t){var n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length,l,u,d,f,p,m,h=0;for(f=0;f<=v;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;l<_;l++)u=e.heap[l],f=n[n[u*2+1]*2+1]+1,f>c&&(f=c,h++),n[u*2+1]=f,!(u>r)&&(e.bl_count[f]++,p=0,u>=s&&(p=o[u-s]),m=n[u*2],e.opt_len+=m*(f+p),a&&(e.static_len+=m*(i[u*2+1]+p)));if(h!==0){do{for(f=c-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[c]--,h-=2}while(h>0);for(f=c;f!==0;f--)for(u=e.bl_count[f];u!==0;)d=e.heap[--l],!(d>r)&&(n[d*2+1]!==f&&(e.opt_len+=(f-n[d*2+1])*n[d*2],n[d*2+1]=f),u--)}}function de(e,t,n){var r=Array(v+1),i=0,a,o;for(a=1;a<=v;a++)r[a]=i=i+n[a-1]<<1;for(o=0;o<=t;o++){var s=e[o*2+1];s!==0&&(e[o*2]=ce(r[s]++,s))}}function L(){var e,t,n,r,i,a=Array(v+1);for(n=0,r=0;r>=7;r8?se(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function R(e,n,r,i){pe(e),i&&(se(e,r),se(e,~r)),t.arraySet(e.pending_buf,e.window,n,r,e.pending),e.pending+=r}function z(e,t,n,r){var i=t*2,a=n*2;return e[i]>1;o>=1;o--)B(e,n,o);l=a;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],B(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,n[l*2]=n[o*2]+n[s*2],e.depth[l]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,n[o*2+1]=n[s*2+1]=l,e.heap[1]=l++,B(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],ue(e,t),de(n,c,e.bl_count)}function H(e,t,n){var r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)a=o,o=t[(r+1)*2+1],!(++s=3&&e.bl_tree[O[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function G(e,t,n,r){var i;for(F(e,t-257,5),F(e,n-1,5),F(e,r-4,4),i=0;i>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return r;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return i;for(n=32;n0?(e.strm.data_type===a&&(e.strm.data_type=K(e)),V(e,e.l_desc),V(e,e.d_desc),u=W(e),o=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=o&&(o=s)):o=s=r+5,r+4<=o&&t!==-1?Y(e,t,r,i):e.strategy===n||s===o?(F(e,(c<<1)+ +!!i,3),me(e,A,j)):(F(e,(l<<1)+ +!!i,3),G(e,e.l_desc.max_code+1,e.d_desc.max_code+1,u+1),me(e,e.dyn_ltree,e.dyn_dtree)),fe(e),i&&pe(e)}function X(e,t,n){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]=n&255,e.last_lit++,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(N[n]+p+1)*2]++,e.dyn_dtree[oe(t)*2]++),e.last_lit===e.lit_bufsize-1}e._tr_init=J,e._tr_stored_block=Y,e._tr_flush_block=ge,e._tr_tally=X,e._tr_align=he})),ze=c(((e,t)=>{function n(e,t,n,r){for(var i=e&65535|0,a=e>>>16&65535|0,o=0;n!==0;){o=n>2e3?2e3:n,n-=o;do i=i+t[r++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0}t.exports=n})),Be=c(((e,t)=>{function n(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}var r=n();function i(e,t,n,i){var a=r,o=i+n;e^=-1;for(var s=i;s>>8^a[(e^t[s])&255];return e^-1}t.exports=i})),Ve=c(((e,t)=>{t.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`}})),He=c((e=>{var t=Le(),n=Re(),r=ze(),i=Be(),a=Ve(),o=0,s=1,c=3,l=4,u=5,d=0,f=1,p=-2,m=-3,h=-5,g=-1,_=1,v=2,y=3,b=4,x=0,S=2,C=8,w=9,T=15,E=8,D=286,O=30,k=19,A=2*D+1,j=15,M=3,N=258,P=N+M+1,ee=32,te=42,ne=69,re=73,ie=91,ae=103,oe=113,se=666,F=1,I=2,ce=3,le=4,ue=3;function de(e,t){return e.msg=a[t],t}function L(e){return(e<<1)-(e>4?9:0)}function fe(e){for(var t=e.length;--t>=0;)e[t]=0}function pe(e){var n=e.state,r=n.pending;r>e.avail_out&&(r=e.avail_out),r!==0&&(t.arraySet(e.output,n.pending_buf,n.pending_out,r,e.next_out),e.next_out+=r,n.pending_out+=r,e.total_out+=r,e.avail_out-=r,n.pending-=r,n.pending===0&&(n.pending_out=0))}function R(e,t){n._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,pe(e.strm)}function z(e,t){e.pending_buf[e.pending++]=t}function B(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function me(e,n,a,o){var s=e.avail_in;return s>o&&(s=o),s===0?0:(e.avail_in-=s,t.arraySet(n,e.input,e.next_in,s,a),e.state.wrap===1?e.adler=r(e.adler,n,s,a):e.state.wrap===2&&(e.adler=i(e.adler,n,s,a)),e.next_in+=s,e.total_in+=s,s)}function V(e,t){var n=e.max_chain_length,r=e.strstart,i,a,o=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-P?e.strstart-(e.w_size-P):0,l=e.window,u=e.w_mask,d=e.prev,f=e.strstart+N,p=l[r+o-1],m=l[r+o];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do{if(i=t,l[i+o]!==m||l[i+o-1]!==p||l[i]!==l[r]||l[++i]!==l[r+1])continue;r+=2,i++;do;while(l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&ro){if(e.match_start=t,o=a,a>=s)break;p=l[r+o-1],m=l[r+o]}}while((t=d[t&u])>c&&--n!==0);return o<=e.lookahead?o:e.lookahead}function H(e){var n=e.w_size,r,i,a,o,s;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=n+(n-P)){t.arraySet(e.window,e.window,n,n,0),e.match_start-=n,e.strstart-=n,e.block_start-=n,i=e.hash_size,r=i;do a=e.head[--r],e.head[r]=a>=n?a-n:0;while(--i);i=n,r=i;do a=e.prev[--r],e.prev[r]=a>=n?a-n:0;while(--i);o+=n}if(e.strm.avail_in===0)break;if(i=me(e.strm,e.window,e.strstart+e.lookahead,o),e.lookahead+=i,e.lookahead+e.insert>=M)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(H(e),e.lookahead===0&&t===o)return F;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((e.strstart===0||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,R(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-P&&(R(e,!1),e.strm.avail_out===0))return F}return e.insert=0,t===l?(R(e,!0),e.strm.avail_out===0?ce:le):(e.strstart>e.block_start&&(R(e,!1),e.strm.avail_out),F)}function W(e,t){for(var r,i;;){if(e.lookahead=M&&(e.ins_h=(e.ins_h<=M)if(i=n._tr_tally(e,e.strstart-e.match_start,e.match_length-M),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=M){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<=M&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=M-1)),e.prev_length>=M&&e.match_length<=e.prev_length){a=e.strstart+e.lookahead-M,i=n._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-M),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=a&&(e.ins_h=(e.ins_h<=M&&e.strstart>0&&(a=e.strstart-1,i=c[a],i===c[++a]&&i===c[++a]&&i===c[++a])){s=e.strstart+N;do;while(i===c[++a]&&i===c[++a]&&i===c[++a]&&i===c[++a]&&i===c[++a]&&i===c[++a]&&i===c[++a]&&i===c[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=M?(r=n._tr_tally(e,1,e.match_length-M),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=n._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(R(e,!1),e.strm.avail_out===0))return F}return e.insert=0,t===l?(R(e,!0),e.strm.avail_out===0?ce:le):e.last_lit&&(R(e,!1),e.strm.avail_out===0)?F:I}function q(e,t){for(var r;;){if(e.lookahead===0&&(H(e),e.lookahead===0)){if(t===o)return F;break}if(e.match_length=0,r=n._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(R(e,!1),e.strm.avail_out===0))return F}return e.insert=0,t===l?(R(e,!0),e.strm.avail_out===0?ce:le):e.last_lit&&(R(e,!1),e.strm.avail_out===0)?F:I}function J(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}var Y=[new J(0,0,0,0,U),new J(4,4,8,4,W),new J(4,5,16,8,W),new J(4,6,32,32,W),new J(4,4,16,16,G),new J(8,16,32,32,G),new J(8,16,128,128,G),new J(8,32,128,256,G),new J(32,128,258,1024,G),new J(32,258,258,4096,G)];function he(e){e.window_size=2*e.w_size,fe(e.head),e.max_lazy_match=Y[e.level].max_lazy,e.good_match=Y[e.level].good_length,e.nice_match=Y[e.level].nice_length,e.max_chain_length=Y[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=M-1,e.match_available=0,e.ins_h=0}function ge(){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=C,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 t.Buf16(A*2),this.dyn_dtree=new t.Buf16((2*O+1)*2),this.bl_tree=new t.Buf16((2*k+1)*2),fe(this.dyn_ltree),fe(this.dyn_dtree),fe(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new t.Buf16(j+1),this.heap=new t.Buf16(2*D+1),fe(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new t.Buf16(2*D+1),fe(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}function X(e){var t;return!e||!e.state?de(e,p):(e.total_in=e.total_out=0,e.data_type=S,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?te:oe,e.adler=t.wrap===2?0:1,t.last_flush=o,n._tr_init(t),d)}function _e(e){var t=X(e);return t===d&&he(e.state),t}function ve(e,t){return!e||!e.state||e.state.wrap!==2?p:(e.state.gzhead=t,d)}function Z(e,n,r,i,a,o){if(!e)return p;var s=1;if(n===g&&(n=6),i<0?(s=0,i=-i):i>15&&(s=2,i-=16),a<1||a>w||r!==C||i<8||i>15||n<0||n>9||o<0||o>b)return de(e,p);i===8&&(i=9);var c=new ge;return e.state=c,c.strm=e,c.wrap=s,c.gzhead=null,c.w_bits=i,c.w_size=1<u||t<0)return e?de(e,p):p;if(a=e.state,!e.output||!e.input&&e.avail_in!==0||a.status===se&&t!==l)return de(e,e.avail_out===0?h:p);if(a.strm=e,r=a.last_flush,a.last_flush=t,a.status===te)if(a.wrap===2)e.adler=0,z(a,31),z(a,139),z(a,8),a.gzhead?(z(a,+!!a.gzhead.text+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),z(a,a.gzhead.time&255),z(a,a.gzhead.time>>8&255),z(a,a.gzhead.time>>16&255),z(a,a.gzhead.time>>24&255),z(a,a.level===9?2:a.strategy>=v||a.level<2?4:0),z(a,a.gzhead.os&255),a.gzhead.extra&&a.gzhead.extra.length&&(z(a,a.gzhead.extra.length&255),z(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(e.adler=i(e.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=ne):(z(a,0),z(a,0),z(a,0),z(a,0),z(a,0),z(a,a.level===9?2:a.strategy>=v||a.level<2?4:0),z(a,ue),a.status=oe);else{var _=C+(a.w_bits-8<<4)<<8,b=-1;b=a.strategy>=v||a.level<2?0:a.level<6?1:a.level===6?2:3,_|=b<<6,a.strstart!==0&&(_|=ee),_+=31-_%31,a.status=oe,B(a,_),a.strstart!==0&&(B(a,e.adler>>>16),B(a,e.adler&65535)),e.adler=1}if(a.status===ne)if(a.gzhead.extra){for(m=a.pending;a.gzindex<(a.gzhead.extra.length&65535)&&!(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>m&&(e.adler=i(e.adler,a.pending_buf,a.pending-m,m)),pe(e),m=a.pending,a.pending===a.pending_buf_size));)z(a,a.gzhead.extra[a.gzindex]&255),a.gzindex++;a.gzhead.hcrc&&a.pending>m&&(e.adler=i(e.adler,a.pending_buf,a.pending-m,m)),a.gzindex===a.gzhead.extra.length&&(a.gzindex=0,a.status=re)}else a.status=re;if(a.status===re)if(a.gzhead.name){m=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>m&&(e.adler=i(e.adler,a.pending_buf,a.pending-m,m)),pe(e),m=a.pending,a.pending===a.pending_buf_size)){g=1;break}g=a.gzindexm&&(e.adler=i(e.adler,a.pending_buf,a.pending-m,m)),g===0&&(a.gzindex=0,a.status=ie)}else a.status=ie;if(a.status===ie)if(a.gzhead.comment){m=a.pending;do{if(a.pending===a.pending_buf_size&&(a.gzhead.hcrc&&a.pending>m&&(e.adler=i(e.adler,a.pending_buf,a.pending-m,m)),pe(e),m=a.pending,a.pending===a.pending_buf_size)){g=1;break}g=a.gzindexm&&(e.adler=i(e.adler,a.pending_buf,a.pending-m,m)),g===0&&(a.status=ae)}else a.status=ae;if(a.status===ae&&(a.gzhead.hcrc?(a.pending+2>a.pending_buf_size&&pe(e),a.pending+2<=a.pending_buf_size&&(z(a,e.adler&255),z(a,e.adler>>8&255),e.adler=0,a.status=oe)):a.status=oe),a.pending!==0){if(pe(e),e.avail_out===0)return a.last_flush=-1,d}else if(e.avail_in===0&&L(t)<=L(r)&&t!==l)return de(e,h);if(a.status===se&&e.avail_in!==0)return de(e,h);if(e.avail_in!==0||a.lookahead!==0||t!==o&&a.status!==se){var x=a.strategy===v?q(a,t):a.strategy===y?K(a,t):Y[a.level].func(a,t);if((x===ce||x===le)&&(a.status=se),x===F||x===ce)return e.avail_out===0&&(a.last_flush=-1),d;if(x===I&&(t===s?n._tr_align(a):t!==u&&(n._tr_stored_block(a,0,0,!1),t===c&&(fe(a.head),a.lookahead===0&&(a.strstart=0,a.block_start=0,a.insert=0))),pe(e),e.avail_out===0))return a.last_flush=-1,d}return t===l?a.wrap<=0?f:(a.wrap===2?(z(a,e.adler&255),z(a,e.adler>>8&255),z(a,e.adler>>16&255),z(a,e.adler>>24&255),z(a,e.total_in&255),z(a,e.total_in>>8&255),z(a,e.total_in>>16&255),z(a,e.total_in>>24&255)):(B(a,e.adler>>>16),B(a,e.adler&65535)),pe(e),a.wrap>0&&(a.wrap=-a.wrap),a.pending===0?f:d):d}function be(e){var t;return!e||!e.state?p:(t=e.state.status,t!==te&&t!==ne&&t!==re&&t!==ie&&t!==ae&&t!==oe&&t!==se?de(e,p):(e.state=null,t===oe?de(e,m):d))}function xe(e,n){var i=n.length,a,o,s,c,l,u,f,m;if(!e||!e.state||(a=e.state,c=a.wrap,c===2||c===1&&a.status!==te||a.lookahead))return p;for(c===1&&(e.adler=r(e.adler,n,i,0)),a.wrap=0,i>=a.w_size&&(c===0&&(fe(a.head),a.strstart=0,a.block_start=0,a.insert=0),m=new t.Buf8(a.w_size),t.arraySet(m,n,i-a.w_size,a.w_size,0),n=m,i=a.w_size),l=e.avail_in,u=e.next_in,f=e.input,e.avail_in=i,e.next_in=0,e.input=n,H(a);a.lookahead>=M;){o=a.strstart,s=a.lookahead-(M-1);do a.ins_h=(a.ins_h<{var t=Le(),n=!0,r=!0;try{String.fromCharCode.apply(null,[0])}catch{n=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{r=!1}for(var i=new t.Buf8(256),a=0;a<256;a++)i[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;i[254]=i[254]=1,e.string2buf=function(e){var n,r,i,a,o,s=e.length,c=0;for(a=0;a>>6,n[o++]=128|r&63):r<65536?(n[o++]=224|r>>>12,n[o++]=128|r>>>6&63,n[o++]=128|r&63):(n[o++]=240|r>>>18,n[o++]=128|r>>>12&63,n[o++]=128|r>>>6&63,n[o++]=128|r&63);return n};function o(e,i){if(i<65534&&(e.subarray&&r||!e.subarray&&n))return String.fromCharCode.apply(null,t.shrinkBuf(e,i));for(var a=``,o=0;o4){l[r++]=65533,n+=s-1;continue}for(a&=s===2?31:s===3?15:7;s>1&&n1){l[r++]=65533;continue}a<65536?l[r++]=a:(a-=65536,l[r++]=55296|a>>10&1023,l[r++]=56320|a&1023)}return o(l,r)},e.utf8border=function(e,t){var n;for(t||=e.length,t>e.length&&(t=e.length),n=t-1;n>=0&&(e[n]&192)==128;)n--;return n<0||n===0?t:n+i[e[n]]>t?n:t}})),We=c(((e,t)=>{function n(){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}t.exports=n})),Ge=c((e=>{var t=He(),n=Le(),r=Ue(),i=Ve(),a=We(),o=Object.prototype.toString,s=0,c=4,l=0,u=1,d=2,f=-1,p=0,m=8;function h(e){if(!(this instanceof h))return new h(e);this.options=n.assign({level:f,method:m,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:``},e||{});var s=this.options;s.raw&&s.windowBits>0?s.windowBits=-s.windowBits:s.gzip&&s.windowBits>0&&s.windowBits<16&&(s.windowBits+=16),this.err=0,this.msg=``,this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var c=t.deflateInit2(this.strm,s.level,s.method,s.windowBits,s.memLevel,s.strategy);if(c!==l)throw Error(i[c]);if(s.header&&t.deflateSetHeader(this.strm,s.header),s.dictionary){var u=typeof s.dictionary==`string`?r.string2buf(s.dictionary):o.call(s.dictionary)===`[object ArrayBuffer]`?new Uint8Array(s.dictionary):s.dictionary;if(c=t.deflateSetDictionary(this.strm,u),c!==l)throw Error(i[c]);this._dict_set=!0}}h.prototype.push=function(e,i){var a=this.strm,f=this.options.chunkSize,p,m;if(this.ended)return!1;m=i===~~i?i:i===!0?c:s,typeof e==`string`?a.input=r.string2buf(e):o.call(e)===`[object ArrayBuffer]`?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(a.avail_out===0&&(a.output=new n.Buf8(f),a.next_out=0,a.avail_out=f),p=t.deflate(a,m),p!==u&&p!==l)return this.onEnd(p),this.ended=!0,!1;(a.avail_out===0||a.avail_in===0&&(m===c||m===d))&&(this.options.to===`string`?this.onData(r.buf2binstring(n.shrinkBuf(a.output,a.next_out))):this.onData(n.shrinkBuf(a.output,a.next_out)))}while((a.avail_in>0||a.avail_out===0)&&p!==u);return m===c?(p=t.deflateEnd(this.strm),this.onEnd(p),this.ended=!0,p===l):m===d?(this.onEnd(l),a.avail_out=0,!0):!0},h.prototype.onData=function(e){this.chunks.push(e)},h.prototype.onEnd=function(e){e===l&&(this.options.to===`string`?this.result=this.chunks.join(``):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function g(e,t){var n=new h(t);if(n.push(e,!0),n.err)throw n.msg||i[n.err];return n.result}function _(e,t){return t||={},t.raw=!0,g(e,t)}function v(e,t){return t||={},t.gzip=!0,g(e,t)}e.Deflate=h,e.deflate=g,e.deflateRaw=_,e.gzip=v})),Ke=c(((e,t)=>{var n=30,r=12;t.exports=function(e,t){var i=e.state,a=e.next_in,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D=e.input,O;o=a+(e.avail_in-5),s=e.next_out,O=e.output,c=s-(t-e.avail_out),l=s+(e.avail_out-257),u=i.dmax,d=i.wsize,f=i.whave,p=i.wnext,m=i.window,h=i.hold,g=i.bits,_=i.lencode,v=i.distcode,y=(1<>>24,h>>>=S,g-=S,S=x>>>16&255,S===0)O[s++]=x&65535;else if(S&16){C=x&65535,S&=15,S&&(g>>=S,g-=S),g<15&&(h+=D[a++]<>>24,h>>>=S,g-=S,S=x>>>16&255,S&16){if(w=x&65535,S&=15,gu){e.msg=`invalid distance too far back`,i.mode=n;break top}if(h>>>=S,g-=S,S=s-c,w>S){if(S=w-S,S>f&&i.sane){e.msg=`invalid distance too far back`,i.mode=n;break top}if(T=0,E=m,p===0){if(T+=d-S,S2;)O[s++]=E[T++],O[s++]=E[T++],O[s++]=E[T++],C-=3;C&&(O[s++]=E[T++],C>1&&(O[s++]=E[T++]))}else{T=s-w;do O[s++]=O[T++],O[s++]=O[T++],O[s++]=O[T++],C-=3;while(C>2);C&&(O[s++]=O[T++],C>1&&(O[s++]=O[T++]))}}else if(S&64){e.msg=`invalid distance code`,i.mode=n;break top}else{x=v[(x&65535)+(h&(1<>3,a-=C,g-=C<<3,h&=(1<{var n=Le(),r=15,i=852,a=592,o=0,s=1,c=2,l=[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],u=[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],d=[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],f=[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];t.exports=function(e,t,p,m,h,g,_,v){var y=v.bits,b=0,x=0,S=0,C=0,w=0,T=0,E=0,D=0,O=0,k=0,A,j,M,N,P,ee=null,te=0,ne,re=new n.Buf16(r+1),ie=new n.Buf16(r+1),ae=null,oe=0,se,F,I;for(b=0;b<=r;b++)re[b]=0;for(x=0;x=1&&re[C]===0;C--);if(w>C&&(w=C),C===0)return h[g++]=20971520,h[g++]=20971520,v.bits=1,0;for(S=1;S0&&(e===o||C!==1))return-1;for(ie[1]=0,b=1;bi||e===c&&O>a)return 1;for(;;){se=b-E,_[x]ne?(F=ae[oe+_[x]],I=ee[te+_[x]]):(F=96,I=0),A=1<>E)+j]=se<<24|F<<16|I|0;while(j!==0);for(A=1<>=1;if(A===0?k=0:(k&=A-1,k+=A),x++,--re[b]===0){if(b===C)break;b=t[p+_[x]]}if(b>w&&(k&N)!==M){for(E===0&&(E=w),P+=S,T=b-E,D=1<i||e===c&&O>a)return 1;M=k&N,h[M]=w<<24|T<<16|P-g|0}}return k!==0&&(h[P+k]=b-E<<24|4194304),v.bits=w,0}})),Je=c((e=>{var t=Le(),n=ze(),r=Be(),i=Ke(),a=qe(),o=0,s=1,c=2,l=4,u=5,d=6,f=0,p=1,m=2,h=-2,g=-3,_=-4,v=-5,y=8,b=1,x=2,S=3,C=4,w=5,T=6,E=7,D=8,O=9,k=10,A=11,j=12,M=13,N=14,P=15,ee=16,te=17,ne=18,re=19,ie=20,ae=21,oe=22,se=23,F=24,I=25,ce=26,le=27,ue=28,de=29,L=30,fe=31,pe=32,R=852,z=592,B=15;function me(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function V(){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 t.Buf16(320),this.work=new t.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function H(e){var n;return!e||!e.state?h:(n=e.state,e.total_in=e.total_out=n.total=0,e.msg=``,n.wrap&&(e.adler=n.wrap&1),n.mode=b,n.last=0,n.havedict=0,n.dmax=32768,n.head=null,n.hold=0,n.bits=0,n.lencode=n.lendyn=new t.Buf32(R),n.distcode=n.distdyn=new t.Buf32(z),n.sane=1,n.back=-1,f)}function U(e){var t;return!e||!e.state?h:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,H(e))}function W(e,t){var n,r;return!e||!e.state||(r=e.state,t<0?(n=0,t=-t):(n=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?h:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,U(e))}function G(e,t){var n,r;return e?(r=new V,e.state=r,r.window=null,n=W(e,t),n!==f&&(e.state=null),n):h}function K(e){return G(e,B)}var q=!0,J,Y;function he(e){if(q){var n;for(J=new t.Buf32(512),Y=new t.Buf32(32),n=0;n<144;)e.lens[n++]=8;for(;n<256;)e.lens[n++]=9;for(;n<280;)e.lens[n++]=7;for(;n<288;)e.lens[n++]=8;for(a(s,e.lens,0,288,J,0,e.work,{bits:9}),n=0;n<32;)e.lens[n++]=5;a(c,e.lens,0,32,Y,0,e.work,{bits:5}),q=!1}e.lencode=J,e.lenbits=9,e.distcode=Y,e.distbits=5}function ge(e,n,r,i){var a,o=e.state;return o.window===null&&(o.wsize=1<=o.wsize?(t.arraySet(o.window,n,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(a=o.wsize-o.wnext,a>i&&(a=i),t.arraySet(o.window,n,r-i,a,o.wnext),i-=a,i?(t.arraySet(o.window,n,r-i,i,0),o.wnext=i,o.whave=o.wsize):(o.wnext+=a,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,z.check=r(z.check,Te,2,0),K=0,q=0,z.mode=x;break}if(z.flags=0,z.head&&(z.head.done=!1),!(z.wrap&1)||(((K&255)<<8)+(K>>8))%31){e.msg=`incorrect header check`,z.mode=L;break}if((K&15)!==y){e.msg=`unknown compression method`,z.mode=L;break}if(K>>>=4,q-=4,$=(K&15)+8,z.wbits===0)z.wbits=$;else if($>z.wbits){e.msg=`invalid window size`,z.mode=L;break}z.dmax=1<<$,e.adler=z.check=1,z.mode=K&512?k:j,K=0,q=0;break;case x:for(;q<16;){if(W===0)break inf_leave;W--,K+=B[H++]<>8&1),z.flags&512&&(Te[0]=K&255,Te[1]=K>>>8&255,z.check=r(z.check,Te,2,0)),K=0,q=0,z.mode=S;case S:for(;q<32;){if(W===0)break inf_leave;W--,K+=B[H++]<>>8&255,Te[2]=K>>>16&255,Te[3]=K>>>24&255,z.check=r(z.check,Te,4,0)),K=0,q=0,z.mode=C;case C:for(;q<16;){if(W===0)break inf_leave;W--,K+=B[H++]<>8),z.flags&512&&(Te[0]=K&255,Te[1]=K>>>8&255,z.check=r(z.check,Te,2,0)),K=0,q=0,z.mode=w;case w:if(z.flags&1024){for(;q<16;){if(W===0)break inf_leave;W--,K+=B[H++]<>>8&255,z.check=r(z.check,Te,2,0)),K=0,q=0}else z.head&&(z.head.extra=null);z.mode=T;case T:if(z.flags&1024&&(X=z.length,X>W&&(X=W),X&&(z.head&&($=z.head.extra_len-z.length,z.head.extra||(z.head.extra=Array(z.head.extra_len)),t.arraySet(z.head.extra,B,H,X,$)),z.flags&512&&(z.check=r(z.check,B,X,H)),W-=X,H+=X,z.length-=X),z.length))break inf_leave;z.length=0,z.mode=E;case E:if(z.flags&2048){if(W===0)break inf_leave;X=0;do $=B[H+ X++],z.head&&$&&z.length<65536&&(z.head.name+=String.fromCharCode($));while($&&X>9&1,z.head.done=!0),e.adler=z.check=0,z.mode=j;break;case k:for(;q<32;){if(W===0)break inf_leave;W--,K+=B[H++]<>>=q&7,q-=q&7,z.mode=le;break}for(;q<3;){if(W===0)break inf_leave;W--,K+=B[H++]<>>=1,--q,K&3){case 0:z.mode=N;break;case 1:if(he(z),z.mode=ie,R===d){K>>>=2,q-=2;break inf_leave}break;case 2:z.mode=te;break;case 3:e.msg=`invalid block type`,z.mode=L}K>>>=2,q-=2;break;case N:for(K>>>=q&7,q-=q&7;q<32;){if(W===0)break inf_leave;W--,K+=B[H++]<>>16^65535)){e.msg=`invalid stored block lengths`,z.mode=L;break}if(z.length=K&65535,K=0,q=0,z.mode=P,R===d)break inf_leave;case P:z.mode=ee;case ee:if(X=z.length,X){if(X>W&&(X=W),X>G&&(X=G),X===0)break inf_leave;t.arraySet(V,B,H,X,U),W-=X,H+=X,G-=X,U+=X,z.length-=X;break}z.mode=j;break;case te:for(;q<14;){if(W===0)break inf_leave;W--,K+=B[H++]<>>=5,q-=5,z.ndist=(K&31)+1,K>>>=5,q-=5,z.ncode=(K&15)+4,K>>>=4,q-=4,z.nlen>286||z.ndist>30){e.msg=`too many length or distance symbols`,z.mode=L;break}z.have=0,z.mode=ne;case ne:for(;z.have>>=3,q-=3}for(;z.have<19;)z.lens[Oe[z.have++]]=0;if(z.lencode=z.lendyn,z.lenbits=7,Ee={bits:z.lenbits},we=a(o,z.lens,0,19,z.lencode,0,z.work,Ee),z.lenbits=Ee.bits,we){e.msg=`invalid code lengths set`,z.mode=L;break}z.have=0,z.mode=re;case re:for(;z.have>>24,ye=Z>>>16&255,be=Z&65535,!(Q<=q);){if(W===0)break inf_leave;W--,K+=B[H++]<>>=Q,q-=Q,z.lens[z.have++]=be;else{if(be===16){for(De=Q+2;q>>=Q,q-=Q,z.have===0){e.msg=`invalid bit length repeat`,z.mode=L;break}$=z.lens[z.have-1],X=3+(K&3),K>>>=2,q-=2}else if(be===17){for(De=Q+3;q>>=Q,q-=Q,$=0,X=3+(K&7),K>>>=3,q-=3}else{for(De=Q+7;q>>=Q,q-=Q,$=0,X=11+(K&127),K>>>=7,q-=7}if(z.have+X>z.nlen+z.ndist){e.msg=`invalid bit length repeat`,z.mode=L;break}for(;X--;)z.lens[z.have++]=$}}if(z.mode===L)break;if(z.lens[256]===0){e.msg=`invalid code -- missing end-of-block`,z.mode=L;break}if(z.lenbits=9,Ee={bits:z.lenbits},we=a(s,z.lens,0,z.nlen,z.lencode,0,z.work,Ee),z.lenbits=Ee.bits,we){e.msg=`invalid literal/lengths set`,z.mode=L;break}if(z.distbits=6,z.distcode=z.distdyn,Ee={bits:z.distbits},we=a(c,z.lens,z.nlen,z.ndist,z.distcode,0,z.work,Ee),z.distbits=Ee.bits,we){e.msg=`invalid distances set`,z.mode=L;break}if(z.mode=ie,R===d)break inf_leave;case ie:z.mode=ae;case ae:if(W>=6&&G>=258){e.next_out=U,e.avail_out=G,e.next_in=H,e.avail_in=W,z.hold=K,z.bits=q,i(e,Y),U=e.next_out,V=e.output,G=e.avail_out,H=e.next_in,B=e.input,W=e.avail_in,K=z.hold,q=z.bits,z.mode===j&&(z.back=-1);break}for(z.back=0;Z=z.lencode[K&(1<>>24,ye=Z>>>16&255,be=Z&65535,!(Q<=q);){if(W===0)break inf_leave;W--,K+=B[H++]<>xe)],Q=Z>>>24,ye=Z>>>16&255,be=Z&65535,!(xe+Q<=q);){if(W===0)break inf_leave;W--,K+=B[H++]<>>=xe,q-=xe,z.back+=xe}if(K>>>=Q,q-=Q,z.back+=Q,z.length=be,ye===0){z.mode=ce;break}if(ye&32){z.back=-1,z.mode=j;break}if(ye&64){e.msg=`invalid literal/length code`,z.mode=L;break}z.extra=ye&15,z.mode=oe;case oe:if(z.extra){for(De=z.extra;q>>=z.extra,q-=z.extra,z.back+=z.extra}z.was=z.length,z.mode=se;case se:for(;Z=z.distcode[K&(1<>>24,ye=Z>>>16&255,be=Z&65535,!(Q<=q);){if(W===0)break inf_leave;W--,K+=B[H++]<>xe)],Q=Z>>>24,ye=Z>>>16&255,be=Z&65535,!(xe+Q<=q);){if(W===0)break inf_leave;W--,K+=B[H++]<>>=xe,q-=xe,z.back+=xe}if(K>>>=Q,q-=Q,z.back+=Q,ye&64){e.msg=`invalid distance code`,z.mode=L;break}z.offset=be,z.extra=ye&15,z.mode=F;case F:if(z.extra){for(De=z.extra;q>>=z.extra,q-=z.extra,z.back+=z.extra}if(z.offset>z.dmax){e.msg=`invalid distance too far back`,z.mode=L;break}z.mode=I;case I:if(G===0)break inf_leave;if(X=Y-G,z.offset>X){if(X=z.offset-X,X>z.whave&&z.sane){e.msg=`invalid distance too far back`,z.mode=L;break}X>z.wnext?(X-=z.wnext,_e=z.wsize-X):_e=z.wnext-X,X>z.length&&(X=z.length),ve=z.window}else ve=V,_e=U-z.offset,X=z.length;X>G&&(X=G),G-=X,z.length-=X;do V[U++]=ve[_e++];while(--X);z.length===0&&(z.mode=ae);break;case ce:if(G===0)break inf_leave;V[U++]=z.length,G--,z.mode=ae;break;case le:if(z.wrap){for(;q<32;){if(W===0)break inf_leave;W--,K|=B[H++]<{t.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}})),Xe=c(((e,t)=>{function n(){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}t.exports=n})),Ze=c((e=>{var t=Je(),n=Le(),r=Ue(),i=Ye(),a=Ve(),o=We(),s=Xe(),c=Object.prototype.toString;function l(e){if(!(this instanceof l))return new l(e);this.options=n.assign({chunkSize:16384,windowBits:0,to:``},e||{});var u=this.options;u.raw&&u.windowBits>=0&&u.windowBits<16&&(u.windowBits=-u.windowBits,u.windowBits===0&&(u.windowBits=-15)),u.windowBits>=0&&u.windowBits<16&&!(e&&e.windowBits)&&(u.windowBits+=32),u.windowBits>15&&u.windowBits<48&&(u.windowBits&15||(u.windowBits|=15)),this.err=0,this.msg=``,this.ended=!1,this.chunks=[],this.strm=new o,this.strm.avail_out=0;var d=t.inflateInit2(this.strm,u.windowBits);if(d!==i.Z_OK||(this.header=new s,t.inflateGetHeader(this.strm,this.header),u.dictionary&&(typeof u.dictionary==`string`?u.dictionary=r.string2buf(u.dictionary):c.call(u.dictionary)===`[object ArrayBuffer]`&&(u.dictionary=new Uint8Array(u.dictionary)),u.raw&&(d=t.inflateSetDictionary(this.strm,u.dictionary),d!==i.Z_OK))))throw Error(a[d])}l.prototype.push=function(e,a){var o=this.strm,s=this.options.chunkSize,l=this.options.dictionary,u,d,f,p,m,h=!1;if(this.ended)return!1;d=a===~~a?a:a===!0?i.Z_FINISH:i.Z_NO_FLUSH,typeof e==`string`?o.input=r.binstring2buf(e):c.call(e)===`[object ArrayBuffer]`?o.input=new Uint8Array(e):o.input=e,o.next_in=0,o.avail_in=o.input.length;do{if(o.avail_out===0&&(o.output=new n.Buf8(s),o.next_out=0,o.avail_out=s),u=t.inflate(o,i.Z_NO_FLUSH),u===i.Z_NEED_DICT&&l&&(u=t.inflateSetDictionary(this.strm,l)),u===i.Z_BUF_ERROR&&h===!0&&(u=i.Z_OK,h=!1),u!==i.Z_STREAM_END&&u!==i.Z_OK)return this.onEnd(u),this.ended=!0,!1;o.next_out&&(o.avail_out===0||u===i.Z_STREAM_END||o.avail_in===0&&(d===i.Z_FINISH||d===i.Z_SYNC_FLUSH))&&(this.options.to===`string`?(f=r.utf8border(o.output,o.next_out),p=o.next_out-f,m=r.buf2string(o.output,f),o.next_out=p,o.avail_out=s-p,p&&n.arraySet(o.output,o.output,f,p,0),this.onData(m)):this.onData(n.shrinkBuf(o.output,o.next_out))),o.avail_in===0&&o.avail_out===0&&(h=!0)}while((o.avail_in>0||o.avail_out===0)&&u!==i.Z_STREAM_END);return u===i.Z_STREAM_END&&(d=i.Z_FINISH),d===i.Z_FINISH?(u=t.inflateEnd(this.strm),this.onEnd(u),this.ended=!0,u===i.Z_OK):d===i.Z_SYNC_FLUSH?(this.onEnd(i.Z_OK),o.avail_out=0,!0):!0},l.prototype.onData=function(e){this.chunks.push(e)},l.prototype.onEnd=function(e){e===i.Z_OK&&(this.options.to===`string`?this.result=this.chunks.join(``):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function u(e,t){var n=new l(t);if(n.push(e,!0),n.err)throw n.msg||a[n.err];return n.result}function d(e,t){return t||={},t.raw=!0,u(e,t)}e.Inflate=l,e.inflate=u,e.inflateRaw=d,e.ungzip=u})),Qe=c(((e,t)=>{var n=Le().assign,r=Ge(),i=Ze(),a=Ye(),o={};n(o,r,i,a),t.exports=o})),$e=c(((e,t)=>{function n(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function r(e,t,r){return t=t instanceof RegExp?t:new RegExp(n(t),`g`),e.replace(t,r)}t.exports={clean:function(e){if(typeof e!=`string`)throw Error(`Expected a string, received: `+e);return e=r(e,`./`,`/`),e=r(e,`..`,`.`),e=r(e,` `,`-`),e=r(e,/^[~^:?*\\\-]/g,``),e=r(e,/[~^:?*\\]/g,`-`),e=r(e,/[~^:?*\\\-]$/g,``),e=r(e,`@{`,`-`),e=r(e,/\.$/g,``),e=r(e,/\/$/g,``),e=r(e,/\.lock$/g,``),e}}})),et=c(((e,t)=>{t.exports=function(e,t){var n=e,r=t,i=n.length,a=r.length,o=!1,s=null,c=i+1,l=[],u=[],d=[],f=``,p=-1,m=0,h=1,g,_,v=function(){i>=a&&(g=n,_=i,n=r,r=g,i=a,a=_,o=!0,c=i+1)},y=function(e,t,n){return{x:e,y:t,k:n}},b=function(e,t){return{elem:e,t}},x=function(e,t,o){var s=t>o?l[e-1+c]:l[e+1+c],d,f=Math.max(t,o);for(d=f-e;d=0;--c)for(;as-a?(o?d[d.length]=new b(r[s],p):d[d.length]=new b(r[s],h),++i,++s):e[c].y-e[c].x=e+1;--p)n[p+c]=x(p,n[p-1+c]+1,n[p+1+c]);n[e+c]=x(e,n[e-1+c]+1,n[e+1+c])}while(n[e+c]!==a);for(s=e+2*r,o=l[e+c],d=[];o!==-1;)d[d.length]=new y(u[o].x,u[o].y,null),o=u[o].k;S(d)}}}})),tt=c(((e,t)=>{var n=et();function r(e,t){var r=new n(e,t);r.compose();for(var i=r.getses(),a,o,s=e.length-1,c=t.length-1,l=i.length-1;l>=0;--l)i[l].t===r.SES_COMMON?(o?(o.chain={file1index:s,file2index:c,chain:null},o=o.chain):(a={file1index:s,file2index:c,chain:null},o=a),s--,c--):i[l].t===r.SES_DELETE?s--:i[l].t===r.SES_ADD&&c--;var u={file1index:-1,file2index:-1,chain:null};return o?(o.chain=u,a):u}function i(e,t){for(var n=[],i=e.length,a=t.length,o=r(e,t);o!==null;o=o.chain){var s=i-o.file1index-1,c=a-o.file2index-1;i=o.file1index,a=o.file2index,(s||c)&&n.push({file1:[i+1,s],file2:[a+1,c]})}return n.reverse(),n}function a(e,t,n){var r,a=i(t,e),o=i(t,n),s=[];function c(e,t){s.push([e.file1[0],t,e.file1[1],e.file2[0],e.file2[1]])}for(r=0;ru&&(l.push([1,u,e-u]),u=e)}for(var f=0;fg)break;g=Math.max(g,v+_[2]),f++}if(d(h),p==f)m[4]>0&&l.push([m[1],m[3],m[4]]);else{var y={0:[e.length,-1,t.length,-1],2:[n.length,-1,t.length,-1]};for(r=p;r<=f;r++){m=s[r];var b=y[m[1]],x=m[0],S=x+m[2],C=m[3],w=C+m[4];b[0]=Math.min(C,b[0]),b[1]=Math.max(w,b[1]),b[2]=Math.min(x,b[2]),b[3]=Math.max(S,b[3])}var T=y[0][0]+(h-y[0][2]),E=y[0][1]+(g-y[0][3]),D=y[2][0]+(h-y[2][2]),O=y[2][1]+(g-y[2][3]);l.push([-1,T,E-T,h,g-h,D,O-D])}u=g}return d(t.length),l}function o(e,t,n){var r=[],i=[e,t,n],o=a(e,t,n),s=[];function c(){s.length&&r.push({ok:s}),s=[]}function l(e){for(var t=0;t{Object.defineProperty(e,`__esModule`,{value:!0});function t(e){return e&&typeof e==`object`&&`default`in e?e.default:e}var n=t(re()),r=t(Ie()),i=t(f()),a=t(Qe()),o=s(`crypto`),c=t(x()),l=t(b());t($e()),t(tt());var u=class e extends Error{constructor(e){super(e),this.caller=``}toJSON(){return{code:this.code,data:this.data,caller:this.caller,message:this.message,stack:this.stack}}fromJSON(t){let n=new e(t.message);return n.code=t.code,n.data=t.data,n.caller=t.caller,n.stack=t.stack,n}get isIsomorphicGitError(){return!0}},d=class e extends u{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=e.code,this.data={filepaths:t}}};d.code=`UnmergedPathsError`;var p=class e extends u{constructor(t){super(`An internal error caused this command to fail.\n\nIf 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.\n\nPlease file a bug report at https://github.com/isomorphic-git/isomorphic-git/issues with this error message: ${t}`),this.code=this.name=e.code,this.data={message:t}}};p.code=`InternalError`;var m=class e extends u{constructor(t){super(`The filepath "${t}" contains unsafe character sequences`),this.code=this.name=e.code,this.data={filepath:t}}};m.code=`UnsafeFilepathError`;var h=class{constructor(e){this.buffer=e,this._start=0}eof(){return this._start>=this.buffer.length}tell(){return this._start}seek(e){this._start=e}slice(e){let t=this.buffer.slice(this._start,this._start+e);return this._start+=e,t}toString(e,t){let n=this.buffer.toString(e,this._start,this._start+t);return this._start+=t,n}write(e,t,n){let r=this.buffer.write(e,this._start,t,n);return this._start+=t,r}copy(e,t,n){let r=e.copy(this.buffer,this._start,t,n);return this._start+=r,r}readUInt8(){let e=this.buffer.readUInt8(this._start);return this._start+=1,e}writeUInt8(e){let t=this.buffer.writeUInt8(e,this._start);return this._start+=1,t}readUInt16BE(){let e=this.buffer.readUInt16BE(this._start);return this._start+=2,e}writeUInt16BE(e){let t=this.buffer.writeUInt16BE(e,this._start);return this._start+=2,t}readUInt32BE(){let e=this.buffer.readUInt32BE(this._start);return this._start+=4,e}writeUInt32BE(e){let t=this.buffer.writeUInt32BE(e,this._start);return this._start+=4,t}};function g(e,t){return-(et)}function _(e,t){return g(e.path,t.path)}function v(e){let t=e>0?e>>12:0;t!==4&&t!==8&&t!==10&&t!==14&&(t=8);let n=e&511;return n=n&73?493:420,t!==8&&(n=0),(t<<12)+n}let y=2**32;function S(e,t,n,r){if(e!==void 0&&t!==void 0)return[e,t];n===void 0&&(n=r.valueOf());let i=Math.floor(n/1e3);return[i,(n-i*1e3)*1e6]}function C(e){let[t,n]=S(e.ctimeSeconds,e.ctimeNanoseconds,e.ctimeMs,e.ctime),[r,i]=S(e.mtimeSeconds,e.mtimeNanoseconds,e.mtimeMs,e.mtime);return{ctimeSeconds:t%y,ctimeNanoseconds:n%y,mtimeSeconds:r%y,mtimeNanoseconds:i%y,dev:e.dev%y,ino:e.ino%y,mode:v(e.mode%y),uid:e.uid%y,gid:e.gid%y,size:e.size>-1?e.size%y:0}}function w(e){let t=``;for(let n of new Uint8Array(e))n<16&&(t+=`0`),t+=n.toString(16);return t}let T=null;async function E(e){return T===null&&(T=await k()),T?O(e):D(e)}function D(e){return new r().update(e).digest(`hex`)}async function O(e){return w(await crypto.subtle.digest(`SHA-1`,e))}async function k(){try{return await O(new Uint8Array([]))===`da39a3ee5e6b4b0d3255bfef95601890afd80709`}catch{}return!1}function A(e){return{assumeValid:!!(e&32768),extended:!!(e&16384),stage:(e&12288)>>12,nameLength:e&4095}}function j(e){let t=e.flags;return t.extended=!1,t.nameLength=Math.min(Buffer.from(e.path).length,4095),(t.assumeValid?32768:0)+(t.extended?16384:0)+((t.stage&3)<<12)+(t.nameLength&4095)}var M=class e{constructor(e,t){this._dirty=!1,this._unmergedPaths=t||new Set,this._entries=e||new Map}_addEntry(e){if(e.flags.stage===0)e.stages=[e],this._entries.set(e.path,e),this._unmergedPaths.delete(e.path);else{let t=this._entries.get(e.path);t||=(this._entries.set(e.path,e),e),t.stages[e.flags.stage]=e,this._unmergedPaths.add(e.path)}}static async from(t){if(Buffer.isBuffer(t))return e.fromBuffer(t);if(t===null)return new e(null);throw new p(`invalid type passed to GitIndex.from`)}static async fromBuffer(t){if(t.length===0)throw new p(`Index file is empty (.git/index)`);let n=new e,r=new h(t),i=r.toString(`utf8`,4);if(i!==`DIRC`)throw new p(`Invalid dircache magic file number: ${i}`);let a=await E(t.slice(0,-20)),o=t.slice(-20).toString(`hex`);if(o!==a)throw new p(`Invalid checksum in GitIndex buffer: expected ${o} but saw ${a}`);let s=r.readUInt32BE();if(s!==2)throw new p(`Unsupported dircache version: ${s}`);let c=r.readUInt32BE(),l=0;for(;!r.eof()&&le.stages.length>1?e.stages.filter(e=>e):e)}*[Symbol.iterator](){for(let e of this.entries)yield e}insert({filepath:e,stats:t,oid:n,stage:r=0}){t||={ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,mode:0,uid:0,gid:0,size:0},t=C(t);let i=Buffer.from(e),a={ctimeSeconds:t.ctimeSeconds,ctimeNanoseconds:t.ctimeNanoseconds,mtimeSeconds:t.mtimeSeconds,mtimeNanoseconds:t.mtimeNanoseconds,dev:t.dev,ino:t.ino,mode:t.mode||33188,uid:t.uid,gid:t.gid,size:t.size,path:e,oid:n,flags:{assumeValid:!1,extended:!1,stage:r,nameLength:i.length<4095?i.length:4095},stages:[]};this._addEntry(a),this._dirty=!0}delete({filepath:e}){if(this._entries.has(e))this._entries.delete(e);else for(let t of this._entries.keys())t.startsWith(e+`/`)&&this._entries.delete(t);this._unmergedPaths.has(e)&&this._unmergedPaths.delete(e),this._dirty=!0}clear(){this._entries.clear(),this._dirty=!0}has({filepath:e}){return this._entries.has(e)}render(){return this.entries.map(e=>`${e.mode.toString(8)} ${e.oid} ${e.path}`).join(` `)}static async _entryToBuffer(e){let t=Buffer.from(e.path),n=Math.ceil((62+t.length+1)/8)*8,r=Buffer.alloc(n),i=new h(r),a=C(e);return i.writeUInt32BE(a.ctimeSeconds),i.writeUInt32BE(a.ctimeNanoseconds),i.writeUInt32BE(a.mtimeSeconds),i.writeUInt32BE(a.mtimeNanoseconds),i.writeUInt32BE(a.dev),i.writeUInt32BE(a.ino),i.writeUInt32BE(a.mode),i.writeUInt32BE(a.uid),i.writeUInt32BE(a.gid),i.writeUInt32BE(a.size),i.write(e.oid,20,`hex`),i.writeUInt16BE(j(e)),i.write(e.path,t.length,`utf8`),r}async toObject(){let t=Buffer.alloc(12),n=new h(t);n.write(`DIRC`,4,`utf8`),n.writeUInt32BE(2),n.writeUInt32BE(this.entriesFlat.length);let r=[];for(let t of this.entries)if(r.push(e._entryToBuffer(t)),t.stages.length>1)for(let n of t.stages)n&&n!==t&&r.push(e._entryToBuffer(n));r=await Promise.all(r);let i=Buffer.concat(r),a=Buffer.concat([t,i]),o=await E(a);return Buffer.concat([a,Buffer.from(o,`hex`)])}};function N(e,t,n=!0,r=!0){let i=C(e),a=C(t);return n&&i.mode!==a.mode||i.mtimeSeconds!==a.mtimeSeconds||i.ctimeSeconds!==a.ctimeSeconds||i.uid!==a.uid||i.gid!==a.gid||r&&i.ino!==a.ino||i.size!==a.size}let P=null,ee=Symbol(`IndexCache`);function te(){return{map:new Map,stats:new Map}}async function ne(e,t,n){let[r,i]=await Promise.all([e.lstat(t),e.read(t)]),a=await M.from(i);n.map.set(t,a),n.stats.set(t,r)}async function ie(e,t,n){let r=n.stats.get(t);if(r===void 0)return!0;if(r===null)return!1;let i=await e.lstat(t);return i===null?!1:N(r,i)}var ae=class{static async acquire({fs:e,gitdir:t,cache:r,allowUnmerged:i=!0},a){r[ee]||(r[ee]=te());let o=`${t}/index`;P===null&&(P=new n({maxPending:1/0}));let s,c=[];return await P.acquire(o,async()=>{let t=r[ee];await ie(e,o,t)&&await ne(e,o,t);let n=t.map.get(o);if(c=n.unmergedPaths,c.length&&!i)throw new d(c);if(s=await a(n),n._dirty){let r=await n.toObject();await e.write(o,r),t.stats.set(o,await e.lstat(o)),n._dirty=!1}}),s}};function oe(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t>-1&&(e=e.slice(t+1)),e}function se(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t===-1?`.`:t===0?`/`:e.slice(0,t)}let F=Symbol(`GitWalkSymbol`);var I=class e extends u{constructor(t){super(`Could not find ${t}.`),this.code=this.name=e.code,this.data={what:t}}};I.code=`NotFoundError`;var ce=class e extends u{constructor(t,n,r,i){super(`Object ${t} ${i?`at ${i}`:``}was anticipated to be a ${r} but it is a ${n}.`),this.code=this.name=e.code,this.data={oid:t,actual:n,expected:r,filepath:i}}};ce.code=`ObjectTypeError`;var le=class e extends u{constructor(t){super(`Expected a 40-char hex object id but saw "${t}".`),this.code=this.name=e.code,this.data={value:t}}};le.code=`InvalidOidError`;var ue=class e extends u{constructor(t){super(`Could not find a fetch refspec for remote "${t}". Make sure the config file has an entry like the following: [remote "${t}"] \tfetch = +refs/heads/*:refs/remotes/origin/* `),this.code=this.name=e.code,this.data={remote:t}}};ue.code=`NoRefspecError`;var de=class e{constructor(e){if(this.refs=new Map,this.parsedConfig=[],e){let t=null;this.parsedConfig=e.trim().split(` `).map(e=>{if(/^\s*#/.test(e))return{line:e,comment:!0};let n=e.indexOf(` `);if(e.startsWith(`^`)){let n=e.slice(1);return this.refs.set(t+`^{}`,n),{line:e,ref:t,peeled:n}}else{let r=e.slice(0,n);return t=e.slice(n+1),this.refs.set(t,r),{line:e,ref:t,oid:r}}})}return this}static from(t){return new e(t)}delete(e){this.parsedConfig=this.parsedConfig.filter(t=>t.ref!==e),this.refs.delete(e)}toString(){return this.parsedConfig.map(({line:e})=>e).join(` `)+` `}},L=class e{constructor({remotePath:e,localPath:t,force:n,matchPrefix:r}){Object.assign(this,{remotePath:e,localPath:t,force:n,matchPrefix:r})}static from(t){let[n,r,i,a,o]=t.match(/^(\+?)(.*?)(\*?):(.*?)(\*?)$/).slice(1),s=n===`+`,c=i===`*`;if(c!==(o===`*`))throw new p(`Invalid refspec`);return new e({remotePath:r,localPath:a,force:s,matchPrefix:c})}translate(e){if(this.matchPrefix){if(e.startsWith(this.remotePath))return this.localPath+e.replace(this.remotePath,``)}else if(e===this.remotePath)return this.localPath;return null}reverseTranslate(e){if(this.matchPrefix){if(e.startsWith(this.localPath))return this.remotePath+e.replace(this.localPath,``)}else if(e===this.localPath)return this.remotePath;return null}},fe=class e{constructor(e=[]){this.rules=e}static from(t){let n=[];for(let e of t)n.push(L.from(e));return new e(n)}add(e){let t=L.from(e);this.rules.push(t)}translate(e){let t=[];for(let n of this.rules)for(let r of e){let e=n.translate(r);e&&t.push([r,e])}return t}translateOne(e){let t=null;for(let n of this.rules){let r=n.translate(e);r&&(t=r)}return t}localNamespaces(){return this.rules.filter(e=>e.matchPrefix).map(e=>e.localPath.replace(/\/$/,``))}};function pe(e,t){let n=e.replace(/\^\{\}$/,``),r=t.replace(/\^\{\}$/,``),i=-(nr);return i===0?e.endsWith(`^{}`)?1:-1:i}function R(e,t){let n=``,r=0,i=-1,a=0,o=`\0`;for(let s=0;s<=e.length;++s){if(s2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}else if(n.length!==0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}function z(e){if(!e.length)return`.`;let t=e[0]===`/`,n=e.at(-1)===`/`;return e=R(e,!t),e.length?(n&&(e+=`/`),t?`/${e}`:e):t?`/`:n?`./`:`.`}function B(...e){if(e.length===0)return`.`;let t;for(let n=0;n0&&(t===void 0?t=r:t+=`/`+r)}return t===void 0?`.`:z(t)}let me=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},V=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}`)},H={core:{filemode:V,bare:V,logallrefupdates:V,symlinks:V,ignorecase:V,bigFileThreshold:me}},U=/^\[([A-Za-z0-9-.]+)(?: "(.*)")?\]$/,W=/^[A-Za-z0-9-.]+$/,G=/^([A-Za-z][A-Za-z-]*)(?: *= *(.*))?$/,K=/^[A-Za-z][A-Za-z-]*$/,q=/^(.*?)( *[#;].*)$/,J=e=>{let t=U.exec(e);if(t!=null){let[e,n]=t.slice(1);return[e,n]}return null},Y=e=>{let t=G.exec(e);if(t!=null){let[e,n=`true`]=t.slice(1);return[e,X(he(n))]}return null},he=e=>{let t=q.exec(e);if(t==null)return e;let[n,r]=t.slice(1);return ge(n)&&ge(r)?`${n}${r}`:n},ge=e=>(e.match(/(?:^|[^\\])"/g)||[]).length%2!=0,X=e=>e.split(``).reduce((e,t,n,r)=>{let i=t===`"`&&r[n-1]!==`\\`,a=t===`\\`&&r[n+1]===`"`;return i||a?e:e+t},``),_e=e=>e==null?null:e.toLowerCase(),ve=(e,t,n)=>[_e(e),t,_e(n)].filter(e=>e!=null).join(`.`),Z=e=>{let t=e.split(`.`),n=t.shift(),r=t.pop(),i=t.length?t.join(`.`):void 0;return{section:n,subsection:i,name:r,path:ve(n,i,r),sectionPath:ve(n,i,null),isSection:!!n}},Q=(e,t)=>e.reduce((e,n,r)=>t(n)?r:e,-1);var ye=class e{constructor(e){let t=null,n=null;this.parsedConfig=e?e.split(` `).map(e=>{let r=null,i=null,a=e.trim(),o=J(a),s=o!=null;if(s)[t,n]=o;else{let e=Y(a);e!=null&&([r,i]=e)}let c=ve(t,n,r);return{line:e,isSection:s,section:t,subsection:n,name:r,value:i,path:c}}):[]}static from(t){return new e(t)}async get(e,t=!1){let n=Z(e).path,r=this.parsedConfig.filter(e=>e.path===n).map(({section:e,name:t,value:n})=>{let r=H[e]&&H[e][t];return r?r(n):n});return t?r:r.pop()}async getall(e){return this.get(e,!0)}async getSubsections(e){return this.parsedConfig.filter(t=>t.isSection&&t.section===e).map(e=>e.subsection)}async deleteSection(e,t){this.parsedConfig=this.parsedConfig.filter(n=>!(n.section===e&&n.subsection===t))}async append(e,t){return this.set(e,t,!0)}async set(e,t,n=!1){let{section:r,subsection:i,name:a,path:o,sectionPath:s,isSection:c}=Z(e),l=Q(this.parsedConfig,e=>e.path===o);if(t==null)l!==-1&&this.parsedConfig.splice(l,1);else if(l!==-1){let e=this.parsedConfig[l],r=Object.assign({},e,{name:a,value:t,modified:!0});n?this.parsedConfig.splice(l+1,0,r):this.parsedConfig[l]=r}else{let e=this.parsedConfig.findIndex(e=>e.path===s),n={section:r,subsection:i,name:a,value:t,modified:!0,path:o};if(W.test(r)&&K.test(a))if(e>=0)this.parsedConfig.splice(e+1,0,n);else{let e={isSection:c,section:r,subsection:i,modified:!0,path:s};this.parsedConfig.push(e,n)}}}toString(){return this.parsedConfig.map(({line:e,section:t,subsection:n,name:r,value:i,modified:a=!1})=>a?r!=null&&i!=null?typeof i==`string`&&/[#;]/.test(i)?`\t${r} = "${i}"`:`\t${r} = ${i}`:n==null?`[${t}]`:`[${t} "${n}"]`:e).join(` `)}},be=class{static async get({fs:e,gitdir:t}){let n=await e.read(`${t}/config`,{encoding:`utf8`});return ye.from(n)}static async save({fs:e,gitdir:t,config:n}){await e.write(`${t}/config`,n.toString(),{encoding:`utf8`})}};let xe=e=>[`${e}`,`refs/${e}`,`refs/tags/${e}`,`refs/heads/${e}`,`refs/remotes/${e}`,`refs/remotes/${e}/HEAD`],Se=[`config`,`description`,`index`,`shallow`,`commondir`],Ce;async function $(e,t){return Ce===void 0&&(Ce=new n),Ce.acquire(e,t)}var we=class e{static async updateRemoteRefs({fs:t,gitdir:n,remote:r,refs:i,symrefs:a,tags:o,refspecs:s=void 0,prune:c=!1,pruneTags:l=!1}){for(let e of i.values())if(!e.match(/[0-9a-f]{40}/))throw new le(e);let u=await be.get({fs:t,gitdir:n});if(!s){if(s=await u.getall(`remote.${r}.fetch`),s.length===0)throw new ue(r);s.unshift(`+HEAD:refs/remotes/${r}/HEAD`)}let d=fe.from(s),f=new Map;if(l){let r=await e.listRefs({fs:t,gitdir:n,filepath:`refs/tags`});await e.deleteRefs({fs:t,gitdir:n,refs:r.map(e=>`refs/tags/${e}`)})}if(o){for(let r of i.keys())if(r.startsWith(`refs/tags`)&&!r.endsWith(`^{}`)&&!await e.exists({fs:t,gitdir:n,ref:r})){let e=i.get(r);f.set(r,e)}}let p=d.translate([...i.keys()]);for(let[e,t]of p){let n=i.get(e);f.set(t,n)}let m=d.translate([...a.keys()]);for(let[e,t]of m){let n=a.get(e),r=d.translateOne(n);r&&f.set(t,`ref: ${r}`)}let h=[];if(c){for(let r of d.localNamespaces()){let i=(await e.listRefs({fs:t,gitdir:n,filepath:r})).map(e=>`${r}/${e}`);for(let e of i)f.has(e)||h.push(e)}h.length>0&&await e.deleteRefs({fs:t,gitdir:n,refs:h})}for(let[e,r]of f)await $(e,async()=>t.write(B(n,e),`${r.trim()}\n`,`utf8`));return{pruned:h}}static async writeRef({fs:e,gitdir:t,ref:n,value:r}){if(!r.match(/[0-9a-f]{40}/))throw new le(r);await $(n,async()=>e.write(B(t,n),`${r.trim()}\n`,`utf8`))}static async writeSymbolicRef({fs:e,gitdir:t,ref:n,value:r}){await $(n,async()=>e.write(B(t,n),`ref: ${r.trim()}\n`,`utf8`))}static async deleteRef({fs:t,gitdir:n,ref:r}){return e.deleteRefs({fs:t,gitdir:n,refs:[r]})}static async deleteRefs({fs:e,gitdir:t,refs:n}){await Promise.all(n.map(n=>e.rm(B(t,n))));let r=await $(`packed-refs`,async()=>e.read(`${t}/packed-refs`,{encoding:`utf8`})),i=de.from(r),a=i.refs.size;for(let e of n)i.refs.has(e)&&i.delete(e);i.refs.sizee.write(`${t}/packed-refs`,r,{encoding:`utf8`})))}static async resolve({fs:t,gitdir:n,ref:r,depth:i=void 0}){if(i!==void 0&&(i--,i===-1))return r;if(r.startsWith(`ref: `))return r=r.slice(5),e.resolve({fs:t,gitdir:n,ref:r,depth:i});if(r.length===40&&/[0-9a-f]{40}/.test(r))return r;let a=await e.packedRefs({fs:t,gitdir:n}),o=xe(r).filter(e=>!Se.includes(e));for(let r of o){let o=await $(r,async()=>await t.read(`${n}/${r}`,{encoding:`utf8`})||a.get(r));if(o)return e.resolve({fs:t,gitdir:n,ref:o.trim(),depth:i})}throw new I(r)}static async exists({fs:t,gitdir:n,ref:r}){try{return await e.expand({fs:t,gitdir:n,ref:r}),!0}catch{return!1}}static async expand({fs:t,gitdir:n,ref:r}){if(r.length===40&&/[0-9a-f]{40}/.test(r))return r;let i=await e.packedRefs({fs:t,gitdir:n}),a=xe(r);for(let e of a)if(await $(e,async()=>t.exists(`${n}/${e}`))||i.has(e))return e;throw new I(r)}static async expandAgainstMap({ref:e,map:t}){let n=xe(e);for(let e of n)if(await t.has(e))return e;throw new I(e)}static resolveAgainstMap({ref:t,fullref:n=t,depth:r=void 0,map:i}){if(r!==void 0&&(r--,r===-1))return{fullref:n,oid:t};if(t.startsWith(`ref: `))return t=t.slice(5),e.resolveAgainstMap({ref:t,fullref:n,depth:r,map:i});if(t.length===40&&/[0-9a-f]{40}/.test(t))return{fullref:n,oid:t};let a=xe(t);for(let t of a){let n=i.get(t);if(n)return e.resolveAgainstMap({ref:n.trim(),fullref:t,depth:r,map:i})}throw new I(t)}static async packedRefs({fs:e,gitdir:t}){let n=await $(`packed-refs`,async()=>e.read(`${t}/packed-refs`,{encoding:`utf8`}));return de.from(n).refs}static async listRefs({fs:t,gitdir:n,filepath:r}){let i=e.packedRefs({fs:t,gitdir:n}),a=null;try{a=await t.readdirDeep(`${n}/${r}`),a=a.map(e=>e.replace(`${n}/${r}/`,``))}catch{a=[]}for(let e of(await i).keys())e.startsWith(r)&&(e=e.replace(r+`/`,``),a.includes(e)||a.push(e));return a.sort(pe),a}static async listBranches({fs:t,gitdir:n,remote:r}){return r?e.listRefs({fs:t,gitdir:n,filepath:`refs/remotes/${r}`}):e.listRefs({fs:t,gitdir:n,filepath:`refs/heads`})}static async listTags({fs:t,gitdir:n}){return(await e.listRefs({fs:t,gitdir:n,filepath:`refs/tags`})).filter(e=>!e.endsWith(`^{}`))}};function Te(e,t){return g(Ee(e),Ee(t))}function Ee(e){return e.mode===`040000`?e.path+`/`:e.path}function De(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 p(`Unexpected GitTree entry mode: ${e}`)}function Oe(e){let t=[],n=0;for(;n`${e.mode} ${e.type} ${e.oid} ${e.path}`).join(` `)}toObject(){let e=[...this._entries];return e.sort(Te),Buffer.concat(e.map(e=>{let t=Buffer.from(e.mode.replace(/^0/,``)),n=Buffer.from(` `),r=Buffer.from(e.path,`utf8`),i=Buffer.from([0]),a=Buffer.from(e.oid,`hex`);return Buffer.concat([t,n,r,i,a])}))}entries(){return this._entries}*[Symbol.iterator](){for(let e of this._entries)yield e}},Me=class{static wrap({type:e,object:t}){let n=`${e} ${t.length}\x00`,r=n.length,i=r+t.length,a=new Uint8Array(i);for(let e=0;e>=1,i+=8;return r}function Re(e,t){let n=e.readUInt8();if(n&128){let r=Le(e,n&15,4),i=Le(e,(n&112)>>4,3);return i===0&&(i=65536),t.slice(r,r+i)}else return e.slice(n)}function ze(e){let t=[e];return{next(){return Promise.resolve({done:t.length===0,value:t.pop()})},return(){return t=[],{}},[Symbol.asyncIterator](){return this}}}function Be(e){return e[Symbol.asyncIterator]?e[Symbol.asyncIterator]():e[Symbol.iterator]?e[Symbol.iterator]():e.next?e:ze(e)}var Ve=class{constructor(e){if(typeof Buffer>`u`)throw Error(`Missing Buffer dependency`);this.stream=Be(e),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(e){if(!this.eof())return this.started||await this._init(),this.cursor+e>this.buffer.length&&(this._trim(),await this._accumulate(e)),this._moveCursor(e),this.buffer.slice(this.undoCursor,this.cursor)}async skip(e){this.eof()||(this.started||await this._init(),this.cursor+e>this.buffer.length&&(this._trim(),await this._accumulate(e)),this._moveCursor(e))}async undo(){this.cursor=this.undoCursor}async _next(){this.started=!0;let{done:e,value:t}=await this.stream.next();return e&&(this._ended=!0,!t)?Buffer.alloc(0):(t&&=Buffer.from(t),t)}_trim(){this.buffer=this.buffer.slice(this.undoCursor),this.cursor-=this.undoCursor,this._discardedBytes+=this.undoCursor,this.undoCursor=0}_moveCursor(e){this.undoCursor=this.cursor,this.cursor+=e,this.cursor>this.buffer.length&&(this.cursor=this.buffer.length)}async _accumulate(e){if(this._ended)return;let t=[this.buffer];for(;this.cursor+e>He(t);){let e=await this._next();if(this._ended)break;t.push(e)}this.buffer=Buffer.concat(t)}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()}};function He(e){return e.reduce((e,t)=>e+t.length,0)}async function Ue(e,t){let n=new Ve(e),r=await n.read(4);if(r=r.toString(`utf8`),r!==`PACK`)throw new p(`Invalid PACK header '${r}'`);let i=await n.read(4);if(i=i.readUInt32BE(0),i!==2)throw new p(`Invalid packfile version: ${i}`);let o=await n.read(4);if(o=o.readUInt32BE(0),!(o<1))for(;!n.eof()&&o--;){let e=n.tell(),{type:r,length:i,ofs:s,reference:c}=await We(n),l=new a.Inflate;for(;!l.result;){let a=await n.chunk();if(!a)break;if(l.push(a,!1),l.err)throw new p(`Pako error: ${l.msg}`);if(l.result){if(l.result.length!==i)throw new p(`Inflated object size is different from that stated in packfile.`);await n.undo(),await n.read(a.length-l.strm.avail_in);let u=n.tell();await t({data:l.result,type:r,num:o,offset:e,end:u,reference:c,ofs:s})}}}}async function We(e){let t=await e.byte(),n=t>>4&7,r=t&15;if(t&128){let n=4;do t=await e.byte(),r|=(t&127)<e+1<<7|t,-1)}function Xe(e,t){let n=t,r=4,i=null;do i=e.readUInt8(),n|=(i&127)<2048*1024*1024)throw new p(`To keep implementation simple, I haven't implemented the layer 5 feature needed to support packfiles > 2GB in size.`);r.seek(r.tell()+1020);let a=r.readUInt32BE(),o=[];for(let e=0;e{d===null&&(d=s);let c=Math.floor((d-s)*100/d);c!==f&&r&&await r({phase:`Receiving objects`,loaded:d-s,total:d}),f=c,t=a[t],([`commit`,`tree`,`blob`,`tag`].includes(t)||t===`ofs-delta`||t===`ref-delta`)&&(o[i]={type:t,offset:i})});let p=Object.keys(o).map(Number);for(let[e,n]of p.entries()){let r=e+1===p.length?t.byteLength-20:p[e+1],a=o[n],s=i.buf(t.slice(n,r))>>>0;a.end=r,a.crc=s}let m=new e({pack:Promise.resolve(t),packfileSha:s,crcs:l,hashes:c,offsets:u,getExternalRefDelta:n});f=null;let h=0,g=[0,0,0,0,0,0,0,0,0,0,0,0];for(let e in o){e=Number(e);let t=Math.floor(h*100/d);t!==f&&r&&await r({phase:`Resolving deltas`,loaded:h,total:d}),h++,f=t;let n=o[e];if(!n.oid)try{m.readDepth=0,m.externalReadDepth=0;let{type:t,object:r}=await m.readSlice({start:e});g[m.readDepth]+=1;let i=await E(Me.wrap({type:t,object:r}));n.oid=i,c.push(i),u.set(i,e),l[i]=n.crc}catch{continue}}return c.sort(),m}async toBuffer(){let e=[],t=(t,n)=>{e.push(Buffer.from(t,n))};t(`ff744f63`,`hex`),t(`00000002`,`hex`);let n=new h(Buffer.alloc(256*4));for(let e=0;e<256;e++){let t=0;for(let n of this.hashes)parseInt(n.slice(0,2),16)<=e&&t++;n.writeUInt32BE(t)}e.push(n.buffer);for(let e of this.hashes)t(e,`hex`);let r=new h(Buffer.alloc(this.hashes.length*4));for(let e of this.hashes)r.writeUInt32BE(this.crcs[e]);e.push(r.buffer);let i=new h(Buffer.alloc(this.hashes.length*4));for(let e of this.hashes)i.writeUInt32BE(this.offsets.get(e));e.push(i.buffer),t(this.packfileSha,`hex`);let a=Buffer.concat(e),o=await E(a),s=Buffer.alloc(20);return s.write(o,`hex`),Buffer.concat([a,s])}async load({pack:e}){this.pack=e}async unload(){this.pack=null}async read({oid:e}){if(!this.offsets.get(e)){if(this.getExternalRefDelta)return this.externalReadDepth++,this.getExternalRefDelta(e);throw new p(`Could not read object ${e} from packfile`)}let t=this.offsets.get(e);return this.readSlice({start:t})}async readSlice({start:e}){if(this.offsetCache[e])return Object.assign({},this.offsetCache[e]);this.readDepth++;let t={16:`commit`,32:`tree`,48:`blob`,64:`tag`,96:`ofs_delta`,112:`ref_delta`},n=await this.pack;if(!n)throw new p(`Could not read packfile data. The packfile may be missing, corrupted, or too large to read into memory.`);let r=n.slice(e),i=new h(r),a=i.readUInt8(),o=a&112,s=t[o];if(s===void 0)throw new p(`Unrecognized type: 0b`+o.toString(2));let c=a&15,l=c;a&128&&(l=Xe(i,c));let u=null,d=null;if(s===`ofs_delta`){let t=e-Ye(i);({object:u,type:s}=await this.readSlice({start:t}))}if(s===`ref_delta`){let e=i.slice(20).toString(`hex`);({object:u,type:s}=await this.read({oid:e}))}let f=r.slice(i.tell());if(d=Buffer.from(await Ke(f)),d.byteLength!==l)throw new p(`Packfile told us object would have length ${l} but it had length ${d.byteLength}`);return u&&(d=Buffer.from(Pe(d,u))),this.readDepth>3&&(this.offsetCache[e]={type:s,object:d}),{type:s,format:`content`,object:d}}};let et=Symbol(`PackfileCache`);async function nt({fs:e,filename:t,getExternalRefDelta:n,emitter:r,emitterPrefix:i}){let a=await e.read(t);return Ze.fromIdx({idx:a,getExternalRefDelta:n})}function rt({fs:e,cache:t,filename:n,getExternalRefDelta:r,emitter:i,emitterPrefix:a}){t[et]||(t[et]=new Map);let o=t[et].get(n);return o||(o=nt({fs:e,filename:n,getExternalRefDelta:r,emitter:i,emitterPrefix:a}),t[et].set(n,o)),o}let it=8*1024*1024;async function at(e,{start:t=0,end:n=e.length}={}){let r=o.createHash(`sha1`);for(let i=t;ie.endsWith(`.idx`));for(let i of o){let o=`${n}/objects/pack/${i}`,s=await rt({fs:e,cache:t,filename:o,getExternalRefDelta:a});if(s.error)throw new p(s.error);if(s.offsets.has(r)){let t=o.replace(/idx$/,`pack`);s.pack||=e.read(t);let n=await s.pack;if(!n)throw s.pack=null,new p(`Could not read packfile at ${t}. The file may be missing, corrupted, or too large to read into memory.`);if(!s._checksumVerified){let e=s.packfileSha,t=n.subarray(-20),r=Array.from(t).map(e=>e.toString(16).padStart(2,`0`)).join(``);if(r!==e)throw new p(`Packfile trailer mismatch: expected ${e}, got ${r}. The packfile may be corrupted.`);let i=await at(n,{start:0,end:n.length-20});if(i!==e)throw new p(`Packfile payload corrupted: calculated ${i} but expected ${e}. The packfile may have been tampered with.`);s._checksumVerified=!0}let c=await s.read({oid:r,getExternalRefDelta:a});return c.format=`content`,c.source=`objects/pack/${i.replace(/idx$/,`pack`)}`,c}}return null}async function st({fs:e,cache:t,gitdir:n,oid:r,format:i=`content`}){let a=r=>st({fs:e,cache:t,gitdir:n,oid:r}),o;if(r===`4b825dc642cb6eb9a060e54bf8d69288fbee4904`&&(o={format:`wrapped`,object:Buffer.from(`tree 0\0`)}),o||=await Ne({fs:e,gitdir:n,oid:r}),!o){if(o=await ot({fs:e,cache:t,gitdir:n,oid:r,getExternalRefDelta:a}),!o)throw new I(r);return o}if(i===`deflated`||(o.format===`deflated`&&(o.object=Buffer.from(await Ke(o.object)),o.format=`wrapped`),i===`wrapped`))return o;let s=await E(o.object);if(s!==r)throw new p(`SHA check failed! Expected ${r}, computed ${s}`);let{object:c,type:l}=Me.unwrap(o.object);if(o.type=l,o.object=c,o.format=`content`,i===`content`)return o;throw new p(`invalid requested format "${i}"`)}var ct=class e extends u{constructor(t,n,r=!0){super(`Failed to create ${t} at ${n} because it already exists.${r?` (Hint: use 'force: true' parameter to overwrite existing ${t}.)`:``}`),this.code=this.name=e.code,this.data={noun:t,where:n,canForce:r}}};ct.code=`AlreadyExistsError`;var lt=class e extends u{constructor(t,n,r){super(`Found multiple ${t} matching "${n}" (${r.join(`, `)}). Use a longer abbreviation length to disambiguate them.`),this.code=this.name=e.code,this.data={nouns:t,short:n,matches:r}}};lt.code=`AmbiguousError`;var ut=class e extends u{constructor(t){super(`Your local changes to the following files would be overwritten by checkout: ${t.join(`, `)}`),this.code=this.name=e.code,this.data={filepaths:t}}};ut.code=`CheckoutConflictError`;var dt=class e extends u{constructor(t,n){super(`Cannot cherry-pick merge commit ${t}. Merge commits have ${n} parents and require specifying which parent to use as the base.`),this.code=this.name=e.code,this.data={oid:t,parentCount:n}}};dt.code=`CherryPickMergeCommitError`;var ft=class e extends u{constructor(t){super(`Cannot cherry-pick root commit ${t}. Root commits have no parents.`),this.code=this.name=e.code,this.data={oid:t}}};ft.code=`CherryPickRootCommitError`;var pt=class e extends u{constructor(t,n){super(`Failed to checkout "${t}" because commit ${n} is not available locally. Do a git fetch to make the branch available locally.`),this.code=this.name=e.code,this.data={ref:t,oid:n}}};pt.code=`CommitNotFetchedError`;var mt=class e extends u{constructor(){super(`Empty response from git server.`),this.code=this.name=e.code,this.data={}}};mt.code=`EmptyServerResponseError`;var ht=class e extends u{constructor(){super(`A simple fast-forward merge was not possible.`),this.code=this.name=e.code,this.data={}}};ht.code=`FastForwardError`;var gt=class e extends u{constructor(t,n){super(`One or more branches were not updated: ${t}`),this.code=this.name=e.code,this.data={prettyDetails:t,result:n}}};gt.code=`GitPushError`;var _t=class e extends u{constructor(t,n,r){super(`HTTP Error: ${t} ${n}`),this.code=this.name=e.code,this.data={statusCode:t,statusMessage:n,response:r}}};_t.code=`HttpError`;var vt=class e extends u{constructor(t){let n=`invalid filepath`;t===`leading-slash`||t===`trailing-slash`?n=`"filepath" parameter should not include leading or trailing directory separators because these can cause problems on some platforms.`:t===`directory`&&(n=`"filepath" should not be a directory.`),super(n),this.code=this.name=e.code,this.data={reason:t}}};vt.code=`InvalidFilepathError`;var yt=class e extends u{constructor(t,n){super(`"${t}" would be an invalid git reference. (Hint: a valid alternative would be "${n}".)`),this.code=this.name=e.code,this.data={ref:t,suggestion:n}}};yt.code=`InvalidRefNameError`;var bt=class e extends u{constructor(t){super(`Maximum search depth of ${t} exceeded.`),this.code=this.name=e.code,this.data={depth:t}}};bt.code=`MaxDepthError`;var xt=class e extends u{constructor(){super(`Merges with conflicts are not supported yet.`),this.code=this.name=e.code,this.data={}}};xt.code=`MergeNotSupportedError`;var St=class e extends u{constructor(t,n,r,i){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=e.code,this.data={filepaths:t,bothModified:n,deleteByUs:r,deleteByTheirs:i}}};St.code=`MergeConflictError`;var Ct=class e extends u{constructor(t){super(`No name was provided for ${t} in the argument or in the .git/config file.`),this.code=this.name=e.code,this.data={role:t}}};Ct.code=`MissingNameError`;var wt=class e extends u{constructor(t){super(`The function requires a "${t}" parameter but none was provided.`),this.code=this.name=e.code,this.data={parameter:t}}};wt.code=`MissingParameterError`;var Tt=class e extends u{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=e.code,this.data={errors:t},this.errors=t}};Tt.code=`MultipleGitError`;var Et=class e extends u{constructor(t,n){super(`Expected "${t}" but received "${n}".`),this.code=this.name=e.code,this.data={expected:t,actual:n}}};Et.code=`ParseError`;var Dt=class e extends u{constructor(t){let n=``;t===`not-fast-forward`?n=` because it was not a simple fast-forward`:t===`tag-exists`&&(n=` because tag already exists`),super(`Push rejected${n}. Use "force: true" to override.`),this.code=this.name=e.code,this.data={reason:t}}};Dt.code=`PushRejectedError`;var Ot=class e extends u{constructor(t,n){super(`Remote does not support the "${t}" so the "${n}" parameter cannot be used.`),this.code=this.name=e.code,this.data={capability:t,parameter:n}}};Ot.code=`RemoteCapabilityError`;var kt=class e extends u{constructor(t,n){super(`Remote did not reply using the "smart" HTTP protocol. Expected "001e# service=git-upload-pack" but received: ${t}`),this.code=this.name=e.code,this.data={preview:t,response:n}}};kt.code=`SmartHttpError`;var At=class e extends u{constructor(t,n,r){super(`Git remote "${t}" uses an unrecognized transport protocol: "${n}"`),this.code=this.name=e.code,this.data={url:t,transport:n,suggestion:r}}};At.code=`UnknownTransportError`;var jt=class e extends u{constructor(t){super(`Cannot parse remote URL: "${t}"`),this.code=this.name=e.code,this.data={url:t}}};jt.code=`UrlParseError`;var Mt=class e extends u{constructor(){super(`The operation was canceled.`),this.code=this.name=e.code,this.data={}}};Mt.code=`UserCanceledError`;var Nt=class e extends u{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=e.code,this.data={filepath:t}}};Nt.code=`IndexResetError`;var Pt=class e extends u{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=e.code,this.data={ref:t}}};Pt.code=`NoCommitError`;function Ft({name:e,email:t,timestamp:n,timezoneOffset:r}){return r=It(r),`${e} <${t}> ${n} ${r}`}function It(e){let t=Lt(Rt(e));e=Math.abs(e);let n=Math.floor(e/60);e-=n*60;let r=String(n),i=String(e);return r.length<2&&(r=`0`+r),i.length<2&&(i=`0`+i),(t===-1?`-`:`+`)+r+i}function Lt(e){return Math.sign(e)||(Object.is(e,-0)?-1:1)}function Rt(e){return e===0?e:-e}function zt(e){return e=e.replace(/\r/g,``),e=e.replace(/^\n+/,``),e=e.replace(/\n+$/,``)+` `,e}function Bt(e){let[,t,n,r,i]=e.match(/^(.*) <(.*)> (.*) (.*)$/);return{name:t,email:n,timestamp:Number(r),timezoneOffset:Vt(i)}}function Vt(e){let[,t,n,r]=e.match(/(\+|-)(\d\d)(\d\d)/);return r=(t===`+`?1:-1)*(Number(n)*60+Number(r)),Ht(r)}function Ht(e){return e===0?e:-e}var Ut=class e{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=e.render(t);else throw new p(`invalid type passed to GitAnnotatedTag constructor`)}static from(t){return new e(t)}static render(e){return`object ${e.object} type ${e.type} tag ${e.tag} tagger ${Ft(e.tagger)} ${e.message} ${e.gpgsig?e.gpgsig:``}`}justHeaders(){return this._tag.slice(0,this._tag.indexOf(` `))}message(){let e=this.withoutSignature();return e.slice(e.indexOf(` `)+2)}parse(){return Object.assign(this.headers(),{message:this.message(),gpgsig:this.gpgsig()})}render(){return this._tag}headers(){let e=this.justHeaders().split(` `),t=[];for(let n of e)n[0]===` `?t[t.length-1]+=` `+n.slice(1):t.push(n);let n={};for(let e of t){let t=e.slice(0,e.indexOf(` `)),r=e.slice(e.indexOf(` `)+1);Array.isArray(n[t])?n[t].push(r):n[t]=r}return n.tagger&&=Bt(n.tagger),n.committer&&=Bt(n.committer),n}withoutSignature(){let e=zt(this._tag);return e.indexOf(` -----BEGIN PGP SIGNATURE-----`)===-1?e:e.slice(0,e.lastIndexOf(` -----BEGIN PGP SIGNATURE-----`))}gpgsig(){if(this._tag.indexOf(` -----BEGIN PGP SIGNATURE-----`)!==-1)return zt(this._tag.slice(this._tag.indexOf(`-----BEGIN PGP SIGNATURE-----`),this._tag.indexOf(`-----END PGP SIGNATURE-----`)+27))}payload(){return this.withoutSignature()+` `}toObject(){return Buffer.from(this._tag,`utf8`)}static async sign(t,n,r){let i=t.payload(),{signature:a}=await n({payload:i,secretKey:r});a=zt(a);let o=i+a;return e.from(o)}};function Wt(e){return e.trim().split(` `).map(e=>` `+e).join(` `)+` `}function Gt(e){return e.split(` `).map(e=>e.replace(/^ /,``)).join(` `)}var Kt=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 p(`invalid type passed to GitCommit constructor`)}static fromPayloadSignature({payload:t,signature:n}){let r=e.justHeaders(t),i=e.justMessage(t);return new e(zt(r+` gpgsig`+Wt(n)+` `+i))}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(e){return zt(e.slice(e.indexOf(` `)+2))}static justHeaders(e){return e.slice(0,e.indexOf(` `))}parseHeaders(){let t=e.justHeaders(this._commit).split(` `),n=[];for(let e of t)e[0]===` `?n[n.length-1]+=` `+e.slice(1):n.push(e);let r={parent:[]};for(let e of n){let t=e.slice(0,e.indexOf(` `)),n=e.slice(e.indexOf(` `)+1);Array.isArray(r[t])?r[t].push(n):r[t]=n}return r.author&&=Bt(r.author),r.committer&&=Bt(r.committer),r}static renderHeaders(e){let t=``;if(e.tree?t+=`tree ${e.tree}\n`:t+=`tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 `,e.parent){if(e.parent.length===void 0)throw new p(`commit 'parent' property should be an array`);for(let n of e.parent)t+=`parent ${n}\n`}let n=e.author;t+=`author ${Ft(n)}\n`;let r=e.committer||e.author;return t+=`committer ${Ft(r)}\n`,e.gpgsig&&(t+=`gpgsig`+Wt(e.gpgsig)),t}static render(t){return e.renderHeaders(t)+` `+zt(t.message)}render(){return this._commit}withoutSignature(){let e=zt(this._commit);if(e.indexOf(` gpgsig`)===-1)return e;let t=e.slice(0,e.indexOf(` gpgsig`)),n=e.slice(e.indexOf(`-----END PGP SIGNATURE----- `)+28);return zt(t+` `+n)}isolateSignature(){return Gt(this._commit.slice(this._commit.indexOf(`-----BEGIN PGP SIGNATURE-----`),this._commit.indexOf(`-----END PGP SIGNATURE-----`)+27))}static async sign(t,n,r){let i=t.withoutSignature(),a=e.justMessage(t._commit),{signature:o}=await n({payload:i,secretKey:r});o=zt(o);let s=e.justHeaders(t._commit)+` gpgsig`+Wt(o)+` `+a;return e.from(s)}};async function qt({fs:e,cache:t,gitdir:n,oid:r}){if(r===`4b825dc642cb6eb9a060e54bf8d69288fbee4904`)return{tree:je.from([]),oid:r};let{type:i,object:a}=await st({fs:e,cache:t,gitdir:n,oid:r});if(i===`tag`)return r=Ut.from(a).parse().object,qt({fs:e,cache:t,gitdir:n,oid:r});if(i===`commit`)return r=Kt.from(a).parse().tree,qt({fs:e,cache:t,gitdir:n,oid:r});if(i!==`tree`)throw new ce(r,i,`tree`);return{tree:je.from(a),oid:r}}var Jt=class{constructor({fs:e,gitdir:t,ref:n,cache:r}){this.fs=e,this.cache=r,this.gitdir=t,this.mapPromise=(async()=>{let r=new Map,i;try{i=await we.resolve({fs:e,gitdir:t,ref:n})}catch(e){e instanceof I&&(i=`4b825dc642cb6eb9a060e54bf8d69288fbee4904`)}let a=await qt({fs:e,cache:this.cache,gitdir:t,oid:i});return a.type=`tree`,a.mode=`40000`,r.set(`.`,a),r})();let i=this;this.ConstructEntry=class{constructor(e){this._fullpath=e,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return i.type(this)}async mode(){return i.mode(this)}async stat(){return i.stat(this)}async content(){return i.content(this)}async oid(){return i.oid(this)}}}async readdir(e){let t=e._fullpath,{fs:n,cache:r,gitdir:i}=this,a=await this.mapPromise,o=a.get(t);if(!o)throw Error(`No obj for ${t}`);let s=o.oid;if(!s)throw Error(`No oid for obj ${JSON.stringify(o)}`);if(o.type!==`tree`)return null;let{type:c,object:l}=await st({fs:n,cache:r,gitdir:i,oid:s});if(c!==o.type)throw new ce(s,c,o.type);let u=je.from(l);for(let e of u)a.set(B(t,e.path),e);return u.entries().map(e=>B(t,e.path))}async type(e){if(e._type===!1){let{type:t}=(await this.mapPromise).get(e._fullpath);e._type=t}return e._type}async mode(e){if(e._mode===!1){let{mode:t}=(await this.mapPromise).get(e._fullpath);e._mode=v(parseInt(t,8))}return e._mode}async stat(e){}async content(e){if(e._content===!1){let t=await this.mapPromise,{fs:n,cache:r,gitdir:i}=this,a=t.get(e._fullpath).oid,{type:o,object:s}=await st({fs:n,cache:r,gitdir:i,oid:a});o===`blob`?e._content=new Uint8Array(s):e._content=void 0}return e._content}async oid(e){return e._oid===!1&&(e._oid=(await this.mapPromise).get(e._fullpath).oid),e._oid}};function Yt({ref:e=`HEAD`}={}){let t=Object.create(null);return Object.defineProperty(t,F,{value:function({fs:t,gitdir:n,cache:r}){return new Jt({fs:t,gitdir:n,ref:e,cache:r})}}),Object.freeze(t),t}var Xt=class{constructor({fs:e,dir:t,gitdir:n,cache:r,refresh:i=!0}){this.fs=e,this.cache=r,this.dir=t,this.gitdir=n,this.refresh=i,this.config=null;let a=this;this.ConstructEntry=class{constructor(e){this._fullpath=e,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)}}}async readdir(e){let t=e._fullpath,{fs:n,dir:r}=this,i=await n.readdir(B(r,t));return i===null?null:i.map(e=>B(t,e))}async type(e){return e._type===!1&&await e.stat(),e._type}async mode(e){return e._mode===!1&&await e.stat(),e._mode}async stat(e){if(e._stat===!1){let{fs:t,dir:n}=this,r=await t.lstat(`${n}/${e._fullpath}`);if(!r)throw Error(`ENOENT: no such file or directory, lstat '${e._fullpath}'`);let i=r.isDirectory()?`tree`:`blob`;i===`blob`&&!r.isFile()&&!r.isSymbolicLink()&&(i=`special`),e._type=i,r=C(r),e._mode=r.mode,r.size===-1&&e._actualSize&&(r.size=e._actualSize),e._stat=r}return e._stat}async content(e){if(e._content===!1){let{fs:t,dir:n,gitdir:r}=this;if(await e.type()===`tree`)e._content=void 0;else{let i;if(await e.mode()>>12==10)i=await t.readlink(`${n}/${e._fullpath}`);else{let a=await(await this._getGitConfig(t,r)).get(`core.autocrlf`);i=await t.read(`${n}/${e._fullpath}`,{autocrlf:a})}e._actualSize=i.length,e._stat&&e._stat.size===-1&&(e._stat.size=e._actualSize),e._content=new Uint8Array(i)}}return e._content}async oid(e){if(e._oid===!1){let t=this,{fs:n,gitdir:r,cache:i}=this,a;await ae.acquire({fs:n,gitdir:r,cache:i},async function(i){let o=i.entriesMap.get(e._fullpath),s=await e.stat(),c=await(await t._getGitConfig(n,r)).get(`core.filemode`),l=typeof process<`u`?process.platform!==`win32`:!0;if(!o||N(s,o,c,l)){let n=await e.content();n===void 0?a=void 0:(a=await E(Me.wrap({type:`blob`,object:n})),t.refresh&&o&&a===o.oid&&(!c||s.mode===o.mode)&&N(s,o,c,l)&&i.insert({filepath:e._fullpath,stats:s,oid:a}))}else a=o.oid}),e._oid=a}return e._oid}async _getGitConfig(e,t){return this.config||=await be.get({fs:e,gitdir:t}),this.config}};function Zt({refresh:e=!0}={}){let t=Object.create(null);return Object.defineProperty(t,F,{value:function({fs:t,dir:n,gitdir:r,cache:i}){return new Xt({fs:t,dir:n,gitdir:r,cache:i,refresh:e})}}),Object.freeze(t),t}function Qt(e,t){let n=t-e;return Array.from({length:n},(t,n)=>e+n)}let $t=Array.prototype.flat===void 0?e=>e.reduce((e,t)=>e.concat(t),[]):e=>e.flat();var en=class{constructor(){this.value=null}consider(e){e!=null&&(this.value===null||et,reduce:o=async(e,t)=>{let n=$t(t);return e!==void 0&&n.unshift(e),n},iterate:s=(e,t)=>Promise.all([...t].map(e))}){let c=i.map(i=>i[F]({fs:e,dir:n,gitdir:r,cache:t})),l=Array(c.length).fill(`.`),u=Qt(0,c.length),d=async e=>(u.forEach(t=>{let n=e[t];e[t]=n&&new c[t].ConstructEntry(n)}),{entries:e,children:tn((await Promise.all(u.map(t=>{let n=e[t];return n?c[t].readdir(n):[]}))).map(e=>(e===null?[]:e)[Symbol.iterator]()))}),f=async e=>{let{entries:t,children:n}=await d(e),r=t.find(e=>e&&e._fullpath)._fullpath,i=await a(r,t);if(i!==null){let e=await s(f,n);return e=e.filter(e=>e!==void 0),o(i,e)}};return f(l)}async function rn(e,t){let n=await e.readdir(t);n==null?await e.rm(t):n.length?await Promise.all(n.map(n=>{let r=B(t,n);return e.lstat(r).then(t=>{if(t)return t.isDirectory()?rn(e,r):e.rm(r)})})).then(()=>e.rmdir(t)):await e.rmdir(t)}function an(e){return on(e)&&sn(e.then)&&sn(e.catch)}function on(e){return e&&typeof e==`object`}function sn(e){return typeof e==`function`}function cn(e){return an((e=>{try{return e.readFile().catch(e=>e)}catch(e){return e}})(e))}let ln=[`readFile`,`writeFile`,`mkdir`,`rmdir`,`unlink`,`stat`,`lstat`,`readdir`,`readlink`,`symlink`];function un(e,t){if(cn(t))for(let n of ln)e[`_${n}`]=t[n].bind(t);else for(let n of ln)e[`_${n}`]=c(t[n].bind(t));cn(t)?(t.cp&&(e._cp=t.cp.bind(t)),t.rm?e._rm=t.rm.bind(t):t.rmdir.length>1?e._rm=t.rmdir.bind(t):e._rm=rn.bind(null,e)):(t.cp&&(e._cp=c(t.cp.bind(t))),t.rm?e._rm=c(t.rm.bind(t)):t.rmdir.length>2?e._rm=c(t.rmdir.bind(t)):e._rm=rn.bind(null,e))}var dn=class{constructor(e){if(e._original_unwrapped_fs!==void 0)return e;let t=Object.getOwnPropertyDescriptor(e,`promises`);t&&t.enumerable?un(this,e.promises):un(this,e),this._original_unwrapped_fs=e}async exists(e,t={}){try{return await this._stat(e),!0}catch(e){if(e.code===`ENOENT`||e.code===`ENOTDIR`||(e.code||``).includes(`ENS`))return!1;throw console.log(`Unhandled error in "FileSystem.exists()" function`,e),e}}async read(e,t={}){try{let n=await this._readFile(e,t);if(t.autocrlf===`true`)try{n=new TextDecoder(`utf8`,{fatal:!0}).decode(n),n=n.replace(/\r\n/g,` `),n=new TextEncoder().encode(n)}catch{}return typeof n!=`string`&&(n=Buffer.from(n)),n}catch{return null}}async write(e,t,n={}){try{await this._writeFile(e,t,n)}catch{await this.mkdir(se(e)),await this._writeFile(e,t,n)}}async mkdir(e,t=!1){try{await this._mkdir(e)}catch(n){if(n===null||n.code===`EEXIST`)return;if(t)throw n;if(n.code===`ENOENT`){let t=se(e);if(t===`.`||t===`/`||t===e)throw n;await this.mkdir(t),await this.mkdir(e,!0)}}}async rm(e){try{await this._unlink(e)}catch(e){if(e.code!==`ENOENT`)throw e}}async rmdir(e,t){try{t&&t.recursive?await this._rm(e,t):await this._rmdir(e)}catch(e){if(e.code!==`ENOENT`)throw e}}async readdir(e){try{let t=await this._readdir(e);return t.sort(g),t}catch(e){return e.code===`ENOTDIR`?null:[]}}async readdirDeep(e){let t=await this._readdir(e);return(await Promise.all(t.map(async t=>{let n=e+`/`+t;return(await this._stat(n)).isDirectory()?this.readdirDeep(n):n}))).reduce((e,t)=>e.concat(t),[])}async lstat(e){try{return await this._lstat(e)}catch(e){if(e.code===`ENOENT`||(e.code||``).includes(`ENS`))return null;throw e}}async readlink(e,t={encoding:`buffer`}){try{let n=await this._readlink(e,t);return Buffer.isBuffer(n)?n:Buffer.from(n)}catch(e){if(e.code===`ENOENT`||(e.code||``).includes(`ENS`))return null;throw e}}async writelink(e,t){return this._symlink(t.toString(`utf8`),e)}};function fn(e,t){if(t===void 0)throw new wt(e)}function pn(e){return e.startsWith(`/`)||/^[a-zA-Z]:[\\/]/.test(e)}async function mn({fsp:e,dotgit:t}){fn(`fsp`,e),fn(`dotgit`,t);let n=await e._stat(t).catch(()=>({isFile:()=>!1,isDirectory:()=>!1}));return n.isDirectory()?t:n.isFile()?e._readFile(t,`utf8`).then(e=>e.trimRight().substr(8)).then(e=>pn(e)?e:B(se(t),e)):t}var hn=class{static async isIgnored({fs:e,dir:t,gitdir:n=B(t,`.git`),filepath:r}){if(oe(r)===`.git`)return!0;if(r===`.`)return!1;let i=``,a=B(n,`info`,`exclude`);await e.exists(a)&&(i=await e.read(a,`utf8`));let o=[{gitignore:B(t,`.gitignore`),filepath:r}],s=r.split(`/`).filter(Boolean);for(let e=1;ei.add(e))}),i}static async write({fs:e,gitdir:t,oids:r}){bn===null&&(bn=new n);let i=B(t,`shallow`);if(r.size>0){let t=[...r].join(` `)+` `;await bn.acquire(i,async function(){await e.write(i,t,{encoding:`utf8`})})}else await bn.acquire(i,async function(){await e.rm(i)})}};async function Sn({fs:e,filepath:t}){if(await e.exists(B(t,`.git`)))return t;{let n=se(t);if(n===t)throw new I(`git root for ${t}`);return Sn({fs:e,filepath:n})}}async function Cn({fs:e,filepath:t}){try{return fn(`fs`,e),fn(`filepath`,t),await Sn({fs:new dn(e),filepath:t})}catch(e){throw e.caller=`git.findRoot`,e}}async function wn({fs:e,dir:t,gitdir:n=B(t,`.git`),filepath:r}){try{fn(`fs`,e),fn(`dir`,t),fn(`gitdir`,n),fn(`filepath`,r);let i=new dn(e),a=await mn({fsp:i,dotgit:n});return hn.isIgnored({fs:i,dir:t,gitdir:a,filepath:r})}catch(e){throw e.caller=`git.isIgnored`,e}}function Tn(e,t){return e.committer.timestamp-t.committer.timestamp}async function En({fs:e,cache:t,gitdir:n,oid:r,fileId:i}){if(i===`e69de29bb2d1d6434b8b29ae775ad8c2e48c5391`)return;let a=r,o,s=await qt({fs:e,cache:t,gitdir:n,oid:r}),c=s.tree;return i===s.oid?o=s.path:(o=await Dn({fs:e,cache:t,gitdir:n,tree:c,fileId:i,oid:a}),Array.isArray(o)&&(o.length===0?o=void 0:o.length===1&&(o=o[0]))),o}async function Dn({fs:e,cache:t,gitdir:n,tree:r,fileId:i,oid:a,filepaths:o=[],parentPath:s=``}){let c=r.entries().map(function(r){let c;return r.oid===i?(c=B(s,r.path),o.push(c)):r.type===`tree`&&(c=st({fs:e,cache:t,gitdir:n,oid:r.oid}).then(function({object:c}){return Dn({fs:e,cache:t,gitdir:n,tree:je.from(c),fileId:i,oid:a,filepaths:o,parentPath:B(s,r.path)})})),c});return await Promise.all(c),o}async function On({fs:e,cache:t,gitdir:n,filepath:r,ref:i,depth:a,since:o,force:s,follow:c}){let l=o===void 0?void 0:Math.floor(o.valueOf()/1e3),u=[],d=await xn.read({fs:e,gitdir:n}),f=[await _n({fs:e,cache:t,gitdir:n,oid:await we.resolve({fs:e,gitdir:n,ref:i})})],p,m,h;function g(e){h&&r&&u.push(e)}for(;f.length>0;){let i=f.pop();if(l!==void 0&&i.commit.committer.timestamp<=l)break;if(r){let a;try{a=await vn({fs:e,cache:t,gitdir:n,oid:i.commit.tree,filepath:r}),m&&p!==a&&u.push(m),p=a,m=i,h=!0}catch(a){if(a instanceof I){let o=c&&p;if(o&&(o=await En({fs:e,cache:t,gitdir:n,oid:i.commit.tree,fileId:p}),o))if(Array.isArray(o)){if(m){let i=await En({fs:e,cache:t,gitdir:n,oid:m.commit.tree,fileId:p});if(Array.isArray(i))if(o=o.filter(e=>i.indexOf(e)===-1),o.length===1)o=o[0],r=o,m&&u.push(m);else{o=!1,m&&u.push(m);break}}}else r=o,m&&u.push(m);if(!o){if(h&&p&&(u.push(m),!s))break;if(!s&&!c)throw a}m=i,h=!1}else throw a}}else u.push(i);if(a!==void 0&&u.length===a){g(i);break}if(!d.has(i.oid))for(let r of i.commit.parent){let i=await _n({fs:e,cache:t,gitdir:n,oid:r});f.map(e=>e.oid).includes(i.oid)||f.push(i)}f.length===0&&g(i),f.sort((e,t)=>Tn(e.commit,t.commit))}return u}async function kn({fs:e,dir:t,gitdir:n=B(t,`.git`),filepath:r,ref:i=`HEAD`,depth:a,since:o,force:s,follow:c,cache:l={}}){try{fn(`fs`,e),fn(`gitdir`,n),fn(`ref`,i);let t=new dn(e);return await On({fs:t,cache:l,gitdir:await mn({fsp:t,dotgit:n}),filepath:r,ref:i,depth:a,since:o,force:s,follow:c})}catch(e){throw e.caller=`git.log`,e}}async function An({fs:e,dir:t,gitdir:n=B(t,`.git`),trees:r,map:i,reduce:a,iterate:o,cache:s={}}){try{fn(`fs`,e),fn(`gitdir`,n),fn(`trees`,r);let c=new dn(e);return await nn({fs:c,cache:s,dir:t,gitdir:await mn({fsp:c,dotgit:n}),trees:r,map:i,reduce:a,iterate:o})}catch(e){throw e.caller=`git.walk`,e}}e.TREE=Yt,e.WORKDIR=Zt,e.findRoot=Cn,e.isIgnored=wn,e.log=kn,e.walk=An}))(),1);const rt={directory:16384,file:33188,executableFile:33261,symlink:40960},it=async({base:e,cwd:t,recursivelyFindRoot:n=!0,filterFiles:r,log:i,...a})=>{let o=e?.commit??`HEAD`,s=O(t),c=n?await nt.findRoot({fs:E,filepath:s}):s,l=(await nt.log({fs:E,dir:c,ref:o,depth:1}))[0]?.oid;if(!l)throw Error(`Could not determine oid for ${o}`);let u=s===c?null:D(c,s)+`/`,d=[nt.TREE({ref:l}),nt.WORKDIR()],f=[],p=[],m={additions:f,deletions:p};return await nt.walk({fs:E,dir:c,trees:d,map:async(e,[t,n])=>{if(await nt.isIgnored({fs:E,dir:c,filepath:e})||await t?.oid()===await n?.oid()&&!t==!n)return null;if(await t?.mode()===rt.symlink||await n?.mode()===rt.symlink)throw Error(`Unexpected symlink at ${e}, GitHub API only supports files and directories. You may need to add this file to .gitignore`);if(await n?.mode()===rt.executableFile)throw Error(`Unexpected executable file at ${e}, GitHub API only supports non-executable files and directories. You may need to add this file to .gitignore`);if(await t?.type()===`tree`||await n?.type()===`tree`)return!0;if(u&&!e.startsWith(u)||r&&!r(e))return null;if(n){let t=await n.content();if(!t)throw Error(`Could not determine content of file ${e}`);f.push({path:e,contents:Buffer.from(t)})}else return p.push(e),null;return!0}}),te({...a,fileChanges:m,log:i,base:{commit:l}})},at=async(e,t)=>{await r(`git`,[`push`,`origin`,`HEAD:${e}`,`--force`],t)},ot=async(e,n)=>{let{stderr:i}=await t(`git`,[`checkout`,e],{ignoreReturnCode:!0,...n});i.toString().includes(`Switched to a new branch '${e}'`)||await r(`git`,[`checkout`,`-b`,e],n)},st=async(e,t)=>{await r(`git`,[`reset`,`--hard`,e],t)},ct=async(e,t)=>{await r(`git`,[`add`,`.`],t),await r(`git`,[`commit`,`-m`,e],t)},lt=async e=>{let{stdout:n}=await t(`git`,[`status`,`--porcelain`],e);return!n.length};var ut=class{octokit;cwd;constructor(e){this.octokit=e.octokit??null,this.cwd=e.cwd}async setupUser(){this.octokit||(await r(`git`,[`config`,`user.name`,`"github-actions[bot]"`],{cwd:this.cwd}),await r(`git`,[`config`,`user.email`,`"41898282+github-actions[bot]@users.noreply.github.com"`],{cwd:this.cwd}))}async pushTag(e){if(this.octokit)return this.octokit.rest.git.createRef({...o.repo,ref:`refs/tags/${e}`,sha:o.sha}).catch(t=>{a(`Failed to create tag ${e}: ${t.message}`)});await r(`git`,[`push`,`origin`,e],{cwd:this.cwd})}async prepareBranch(e){this.octokit||(await ot(e,{cwd:this.cwd}),await st(o.sha,{cwd:this.cwd}))}async pushChanges({branch:e,message:t}){if(this.octokit)return this.cwd,it({octokit:this.octokit,...o.repo,branch:e,message:t,base:{commit:o.sha},cwd:this.cwd,force:!0});await lt({cwd:this.cwd})||await ct(t,{cwd:this.cwd}),await at(e,{cwd:this.cwd})}},dt=e(d(),1),ft=`0.0.0-development`,pt=()=>Promise.resolve();function mt(e,t,n){return e.retryLimiter.schedule(ht,e,t,n)}async function ht(e,t,n){let{pathname:r}=new URL(n.url,`http://github.test`),i=gt(n.method,r),a=!i&&n.method!==`GET`&&n.method!==`HEAD`,o=n.method===`GET`&&r.startsWith(`/search/`),s=r.startsWith(`/graphql`),c=~~t.retryCount>0?{priority:0,weight:0}:{};e.clustering&&(c.expiration=1e3*60),(a||s)&&await e.write.key(e.id).schedule(c,pt),a&&e.triggersNotification(r)&&await e.notifications.key(e.id).schedule(c,pt),o&&await e.search.key(e.id).schedule(c,pt);let l=(i?e.auth:e.global).key(e.id).schedule(c,t,n);if(s){let e=await l;if(e.data.errors!=null&&e.data.errors.some(e=>e.type===`RATE_LIMITED`))throw Object.assign(Error(`GraphQL Rate Limit Exceeded`),{response:e,data:e.data})}return l}function gt(e,t){return e===`PATCH`&&/^\/applications\/[^/]+\/token\/scoped$/.test(t)||e===`POST`&&(/^\/applications\/[^/]+\/token$/.test(t)||/^\/app\/installations\/[^/]+\/access_tokens$/.test(t)||t===`/login/oauth/access_token`)}var _t=[`/orgs/{org}/invitations`,`/orgs/{org}/invitations/{invitation_id}`,`/orgs/{org}/teams/{team_slug}/discussions`,`/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments`,`/repos/{owner}/{repo}/collaborators/{username}`,`/repos/{owner}/{repo}/commits/{commit_sha}/comments`,`/repos/{owner}/{repo}/issues`,`/repos/{owner}/{repo}/issues/{issue_number}/comments`,`/repos/{owner}/{repo}/issues/{issue_number}/sub_issue`,`/repos/{owner}/{repo}/issues/{issue_number}/sub_issues/priority`,`/repos/{owner}/{repo}/pulls`,`/repos/{owner}/{repo}/pulls/{pull_number}/comments`,`/repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies`,`/repos/{owner}/{repo}/pulls/{pull_number}/merge`,`/repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers`,`/repos/{owner}/{repo}/pulls/{pull_number}/reviews`,`/repos/{owner}/{repo}/releases`,`/teams/{team_id}/discussions`,`/teams/{team_id}/discussions/{discussion_number}/comments`];function vt(e){let t=`^(?:${e.map(e=>e.split(`/`).map(e=>e.startsWith(`{`)?`(?:.+?)`:e).join(`/`)).map(e=>`(?:${e})`).join(`|`)})[^/]*$`;return new RegExp(t,`i`)}var yt=vt(_t),bt=yt.test.bind(yt),xt={},St=function(e,t){xt.global=new e.Group({id:`octokit-global`,maxConcurrent:10,...t}),xt.auth=new e.Group({id:`octokit-auth`,maxConcurrent:1,...t}),xt.search=new e.Group({id:`octokit-search`,maxConcurrent:1,minTime:2e3,...t}),xt.write=new e.Group({id:`octokit-write`,maxConcurrent:1,minTime:1e3,...t}),xt.notifications=new e.Group({id:`octokit-notifications`,maxConcurrent:1,minTime:3e3,...t})};function Ct(e,t){let{enabled:n=!0,Bottleneck:r=dt.default,id:i=`no-id`,timeout:a=1e3*60*2,connection:o}=t.throttle||{};if(!n)return{};let s={timeout:a};o!==void 0&&(s.connection=o),xt.global??St(r,s);let c=Object.assign({clustering:o!=null,triggersNotification:bt,fallbackSecondaryRateRetryAfter:60,retryAfterBaseValue:1e3,retryLimiter:new r,id:i,...xt},t.throttle);if(typeof c.onSecondaryRateLimit!=`function`||typeof c.onRateLimit!=`function`)throw Error(`octokit/plugin-throttling error: You must pass the onSecondaryRateLimit and onRateLimit error handlers. See https://octokit.github.io/rest.js/#throttling const octokit = new Octokit({ throttle: { onSecondaryRateLimit: (retryAfter, options) => {/* ... */}, onRateLimit: (retryAfter, options) => {/* ... */} } }) `);let l={},u=new r.Events(l);return l.on(`secondary-limit`,c.onSecondaryRateLimit),l.on(`rate-limit`,c.onRateLimit),l.on(`error`,t=>e.log.warn(`Error in throttling-plugin limit handler`,t)),c.retryLimiter.on(`failed`,async function(t,n){let[r,i,a]=n.args,{pathname:o}=new URL(a.url,`http://github.test`);if(!(o.startsWith(`/graphql`)&&t.status!==401||t.status===403||t.status===429))return;let s=~~i.retryCount;i.retryCount=s,a.request.retryCount=s;let{wantRetry:c,retryAfter:l=0}=await(async function(){if(/\bsecondary rate\b/i.test(t.message)){let n=Number(t.response.headers[`retry-after`])||r.fallbackSecondaryRateRetryAfter;return{wantRetry:await u.trigger(`secondary-limit`,n,a,e,s),retryAfter:n}}if(t.response.headers!=null&&t.response.headers[`x-ratelimit-remaining`]===`0`||(t.response.data?.errors??[]).some(e=>e.type===`RATE_LIMITED`)){let n=new Date(~~t.response.headers[`x-ratelimit-reset`]*1e3).getTime(),r=Math.max(Math.ceil((n-Date.now())/1e3)+1,0);return{wantRetry:await u.trigger(`rate-limit`,r,a,e,s),retryAfter:r}}return{}})();if(c)return i.retryCount++,l*r.retryAfterBaseValue}),e.hook.wrap(`request`,mt.bind(null,c)),{}}Ct.VERSION=ft,Ct.triggersNotification=bt;const wt=e=>i(e,{throttle:{onRateLimit:(e,t,r,i)=>{if(a(`Request quota exhausted for request ${t.method} ${t.url}`),i<=2)return n(`Retrying after ${e} seconds!`),!0},onSecondaryRateLimit:(e,t,r,i)=>{if(a(`SecondaryRateLimit detected for request ${t.method} ${t.url}`),i<=2)return n(`Retrying after ${e} seconds!`),!0}}},Ct);var Tt=S();const Et=async(e,{pkg:t,tagName:n})=>{let r;try{r=await w.readFile(T.join(t.dir,`CHANGELOG.md`),`utf8`)}catch(e){if(u(e,`ENOENT`))return;throw e}let i=l(r,t.packageJson.version);if(!i)throw Error(`Could not find changelog entry for ${t.packageJson.name}@${t.packageJson.version}`);await e.rest.repos.createRelease({name:n,tag_name:n,body:i.content,prerelease:t.packageJson.version.includes(`-`),...o.repo})};async function Dt({script:e,fromPackDir:n,githubToken:r,git:i,octokit:a,createGithubReleases:o,cwd:s}){let c,l={cwd:s,ignoreReturnCode:!0,env:{...process.env,GITHUB_TOKEN:r}};if(e)c=await t(e,void 0,l);else{let e=[`publish`];n&&e.push(`--from-pack-dir`,n),c=await _(e,l)}let{packages:u,tool:d}=await(0,Tt.getPackages)(s),f=[];if(d!==`root`){let e=/New tag:\s+(@[^/]+\/[^@]+|[^/]+)@([^\s]+)/,t=new Map(u.map(e=>[e.packageJson.name,e]));for(let n of c.stdout.split(` `)){let r=n.match(e);if(r===null)continue;let i=r[1],a=t.get(i);if(a===void 0)throw Error(`Package "${i}" not found.This is probably a bug in the action, please open an issue`);f.push(a)}o&&await Promise.all(f.map(async e=>{let t=`${e.packageJson.name}@${e.packageJson.version}`;await i.pushTag(t),await Et(a,{pkg:e,tagName:t})}))}else{if(u.length===0)throw Error(`No package found.This is probably a bug in the action, please open an issue`);let e=u[0],t=/New tag:/;for(let n of c.stdout.split(` `))if(n.match(t)){if(f.push(e),o){let t=`v${e.packageJson.version}`;await i.pushTag(t),await Et(a,{pkg:e,tagName:t})}break}}return f.length?{published:!0,publishedPackages:f.map(e=>({name:e.packageJson.name,version:e.packageJson.version})),exitCode:c.exitCode}:{published:!1,exitCode:c.exitCode}}async function Ot({hasPublishScript:e,preState:t,changedPackagesInfo:n,prBodyMaxCharacters:r,branch:i}){let a=`This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and ${e?`the packages will be published to npm automatically`:`publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing)`}. If you're not ready to do a release yet, that's fine, whenever you add more changesets to ${i}, this PR will be updated. `,o=t?`⚠️⚠️⚠️⚠️⚠️⚠️ \`${i}\` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run \`changeset pre exit\` on \`${i}\`. ⚠️⚠️⚠️⚠️⚠️⚠️ `:``,s=`# Releases`,c=[a,o,s,...n.map(e=>`${e.header}\n\n${e.content}`)].join(` `);return c.length>r&&(c=[a,o,s,` > The changelog information of each package has been omitted from this message, as the content exceeds the size limit. `,...n.map(e=>`${e.header}\n\n`)].join(` `)),c.length>r&&(c=[a,o,s,` > All release information have been omitted from this message, as the content exceeds the size limit.`].join(` `)),c}async function kt({script:e,githubToken:t,git:i,octokit:a,cwd:s=process.cwd(),prTitle:c=`Version Packages`,commitMessage:u=`Version Packages`,hasPublishScript:d=!1,prBodyMaxCharacters:f=6e4,branch:h=o.ref.replace(`refs/heads/`,``),prDraft:_}){let v=`changeset-release/${h}`,{preState:b}=await C(s);await i.prepareBranch(v);let x=await y(s),S={...process.env,GITHUB_TOKEN:t};e?await r(e,void 0,{cwd:s,env:S}):await g([`version`],{cwd:s,env:S});let E=await p(s,x),D=Promise.all(E.map(async e=>{let t=l(await w.readFile(T.join(e.dir,`CHANGELOG.md`),`utf8`),e.packageJson.version);return{highestLevel:t.highestLevel,private:!!e.packageJson.private,content:t.content,header:`## ${e.packageJson.name}@${e.packageJson.version}`}})),O=`${c}${b?` (${b.tag})`:``}`,k=`${u}${b?` (${b.tag})`:``}`,A=await a.rest.pulls.list({...o.repo,state:`open`,head:`${o.repo.owner}:${v}`,base:h});n(`Existing pull requests: ${JSON.stringify(A.data,null,2)}`),await i.pushChanges({branch:v,message:k});let j=await Ot({hasPublishScript:d,preState:b,branch:h,changedPackagesInfo:(await D).filter(e=>e).sort(m),prBodyMaxCharacters:f});if(A.data.length===0){n(`creating pull request`);let{data:e}=await a.rest.pulls.create({base:h,head:v,title:O,body:j,draft:_!==void 0,...o.repo});return{pullRequestNumber:e.number}}else{let[e]=A.data;n(`updating found pull request #${e.number}`);let t=` mutation UpdatePullRequest( $pullRequestId: ID! $title: String! $body: String! ) { ${_===`always`?` convertPullRequestToDraft( input: { pullRequestId: $pullRequestId } ) { pullRequest { id } }`:``} updatePullRequest( input: { pullRequestId: $pullRequestId title: $title body: $body state: OPEN } ) { pullRequest { id } } } `;return await a.graphql(t,{pullRequestId:e.node_id,title:O,body:j}),{pullRequestNumber:e.number}}}export{ut as i,kt as n,wt as r,Dt as t};