@wp-playground/storage 3.0.31 → 3.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +17 -17
- package/index.cjs.map +1 -1
- package/index.js +553 -549
- package/index.js.map +1 -1
- package/package.json +6 -6
package/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";var an=Object.create;var Ue=Object.defineProperty;var sn=Object.getOwnPropertyDescriptor;var cn=Object.getOwnPropertyNames;var fn=Object.getPrototypeOf,un=Object.prototype.hasOwnProperty;var ln=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of cn(t))!un.call(n,o)&&o!==e&&Ue(n,o,{get:()=>t[o],enumerable:!(r=sn(t,o))||r.enumerable});return n};var Pe=(n,t,e)=>(e=n!=null?an(fn(n)):{},ln(t||!n||!n.__esModule?Ue(e,"default",{value:n,enumerable:!0}):e,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const rt=require("@php-wasm/util"),hn=require("octokit"),pn=require("crc-32"),he=require("pako"),K=require("@php-wasm/stream-compression"),at=require("@zip.js/zip.js");function dn(n){return new hn.Octokit({auth:n})}function yn(n,t=""){t.length&&!t.endsWith("/")&&(t+="/");const e={};for(const r of n)r.path.startsWith(t)&&(e[r.path.substring(t.length)]=r.content);return e}async function sr(n,t,e,r,o,c={}){c.progress||(c.progress={foundFiles:0,downloadedFiles:0});const{onProgress:f}=c,s=[],h=[],{data:y}=await n.rest.repos.getContent({owner:t,repo:e,path:o,ref:r});if(!Array.isArray(y))throw new Error(`Expected the list of files to be an array, but got ${typeof y}`);for(const b of y)b.type==="file"?(++c.progress.foundFiles,f==null||f(c.progress),s.push(gn(n,t,e,r,b).then(v=>(++c.progress.downloadedFiles,f==null||f(c.progress),v)))):b.type==="dir"&&h.push(sr(n,t,e,r,b.path,c));const d=await Promise.all(s),w=(await Promise.all(h)).flatMap(b=>b);return[...d,...w]}const wn=new rt.Semaphore({concurrency:15});async function gn(n,t,e,r,o){const c=await wn.acquire();try{const{data:f}=await n.rest.repos.getContent({owner:t,repo:e,ref:r,path:o.path});if(!("content"in f))throw new Error(`No content found for ${o.path}`);return{name:o.name,path:o.path,content:mn(f.content)}}finally{c()}}function mn(n){const t=window.atob(n),e=t.length,r=new Uint8Array(e);for(let o=0;o<e;o++)r[o]=t.charCodeAt(o);return r}async function bn(n,t,e,r,o){var d;const{data:c}=await n.rest.pulls.get({owner:t,repo:e,pull_number:r}),s=(d=(await n.rest.actions.listWorkflowRuns({owner:t,repo:e,branch:c.head.ref,workflow_id:o})).data.workflow_runs[0])==null?void 0:d.id,h=await n.rest.actions.listWorkflowRunArtifacts({owner:t,repo:e,run_id:s});return(await n.rest.actions.downloadArtifact({owner:t,repo:e,artifact_id:h.data.artifacts[0].id,archive_format:"zip"})).data}async function vn(n,t,e){var c;const{data:r,headers:o}=await n.request("GET /repos/{owner}/{repo}",{owner:t,repo:e});return!(!o["x-oauth-scopes"]||!((c=r.permissions)!=null&&c.push))}async function En(n,t,e,r,o){await n.request("GET /repos/{owner}/{repo}/branches/{branch}",{owner:t,repo:e,branch:r}).then(()=>!0,()=>!1)?await n.request("PATCH /repos/{owner}/{repo}/git/refs/{ref}",{owner:t,repo:e,sha:o,ref:`heads/${r}`}):await n.request("POST /repos/{owner}/{repo}/git/refs",{owner:t,repo:e,sha:o,ref:`refs/heads/${r}`})}async function xn(n,t,e){const r=await n.request("GET /user");return(await n.request("GET /repos/{owner}/{repo}/forks",{owner:t,repo:e})).data.find(f=>f.owner&&f.owner.login===r.data.login)||await n.request("POST /repos/{owner}/{repo}/forks",{owner:t,repo:e}),r.data.login}async function An(n,t,e,r,o,c){const{data:{sha:f}}=await n.request("POST /repos/{owner}/{repo}/git/commits",{owner:t,repo:e,message:r,tree:c,parents:[o]});return f}async function Bn(n,t,e,r,o){const c=await cr(n,t,e,r,o);if(c.length===0)return null;const{data:{sha:f}}=await n.request("POST /repos/{owner}/{repo}/git/trees",{owner:t,repo:e,base_tree:r,tree:c});return f}async function cr(n,t,e,r,o){const c=[];for(const[f,s]of o.create)c.push(se(n,t,e,f,s));for(const[f,s]of o.update)c.push(se(n,t,e,f,s));for(const f of o.delete)c.push(ur(n,t,e,r,f));return Promise.all(c).then(f=>f.filter(s=>!!s))}const fr=new rt.Semaphore({concurrency:10});async function se(n,t,e,r,o){const c=await fr.acquire();try{if(ArrayBuffer.isView(o))try{const f=new TextDecoder("utf-8",{fatal:!0}).decode(o);return{path:r,content:f,mode:"100644"}}catch{const{data:{sha:f}}=await n.rest.git.createBlob({owner:t,repo:e,encoding:"base64",content:Sn(o)});return{path:r,sha:f,mode:"100644"}}else return{path:r,content:o,mode:"100644"}}finally{c()}}async function ur(n,t,e,r,o){const c=await fr.acquire();try{return await n.request("HEAD /repos/{owner}/{repo}/contents/:path",{owner:t,repo:e,ref:r,path:o}),{path:o,mode:"100644",sha:null}}catch{return}finally{c()}}function Sn(n){const t=[],e=n.byteLength;for(let r=0;r<e;r++)t.push(String.fromCharCode(n[r]));return window.btoa(t.join(""))}async function*Fn(n,t,{exceptPaths:e=[]}={}){if(t=rt.normalizePath(t),!await n.isDir(t)){await n.fileExists(t)&&(yield{path:t,read:async()=>await n.readFileAsBuffer(t)});return}const r=[t];for(;r.length;){const o=r.pop();if(!o)return;const c=await n.listFiles(o);for(const f of c){const s=rt.joinPaths(o,f);e.includes(s.substring(t.length+1))||(await n.isDir(s)?r.push(s):yield{path:s,read:async()=>await n.readFileAsBuffer(s)})}}}async function In(n,t){const e={create:new Map,update:new Map,delete:new Set},r=new Set;for await(const o of t){r.add(o.path);const c=n.get(o.path),f=await o.read();c?_n(c,f)||e.update.set(o.path,f):e.create.set(o.path,f)}for(const o of n.keys())r.has(o)||e.delete.add(o);return e}function _n(n,t){return n.length===t.length&&n.every((e,r)=>e===t[r])}async function lr(n){return n.type==="local-fs"?n.handle:hr(n.path)}async function hr(n){const t=n.split("/").filter(r=>r.length>0);let e=await navigator.storage.getDirectory();for(const r of t)e=await e.getDirectoryHandle(r,{create:!0});return e}async function $n(n){const e=await(await navigator.storage.getDirectory()).resolve(n);if(e===null)throw new DOMException("Unable to resolve path of OPFS directory handle.","NotFoundError");return"/"+e.join("/")}async function Un(n){const t=await lr(n);for await(const e of t.keys())await t.removeEntry(e,{recursive:!0})}function Pn(n){let t=[n];return{next(){return Promise.resolve({done:t.length===0,value:t.pop()})},return(){return t=[],{}},[Symbol.asyncIterator](){return this}}}function pr(n){return n[Symbol.asyncIterator]?n[Symbol.asyncIterator]():n[Symbol.iterator]?n[Symbol.iterator]():n.next?n:Pn(n)}class dr{constructor(t){if(typeof Buffer>"u")throw new Error("Missing Buffer dependency");this.stream=pr(t),this.buffer=null,this.cursor=0,this.undoCursor=0,this.started=!1,this._ended=!1,this._discardedBytes=0}eof(){return this._ended&&this.cursor===this.buffer.length}tell(){return this._discardedBytes+this.cursor}async byte(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(1),this.buffer[this.undoCursor]}async chunk(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(this.buffer.length),this.buffer.slice(this.undoCursor,this.cursor)}async read(t){if(!this.eof())return this.started||await this._init(),this.cursor+t>this.buffer.length&&(this._trim(),await this._accumulate(t)),this._moveCursor(t),this.buffer.slice(this.undoCursor,this.cursor)}async skip(t){this.eof()||(this.started||await this._init(),this.cursor+t>this.buffer.length&&(this._trim(),await this._accumulate(t)),this._moveCursor(t))}async undo(){this.cursor=this.undoCursor}async _next(){this.started=!0;let{done:t,value:e}=await this.stream.next();return t&&(this._ended=!0,!e)?Buffer.alloc(0):(e&&(e=Buffer.from(e)),e)}_trim(){this.buffer=this.buffer.slice(this.undoCursor),this.cursor-=this.undoCursor,this._discardedBytes+=this.undoCursor,this.undoCursor=0}_moveCursor(t){this.undoCursor=this.cursor,this.cursor+=t,this.cursor>this.buffer.length&&(this.cursor=this.buffer.length)}async _accumulate(t){if(this._ended)return;const e=[this.buffer];for(;this.cursor+t>kn(e);){const r=await this._next();if(this._ended)break;e.push(r)}this.buffer=Buffer.concat(e)}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 kn(n){return n.reduce((t,e)=>t+e.length,0)}function Tn(n,t){const e=t.toString(16);return"0".repeat(n-e.length)+e}class D{static flush(){return Buffer.from("0000","utf8")}static delim(){return Buffer.from("0001","utf8")}static encode(t){typeof t=="string"&&(t=Buffer.from(t));const e=t.length+4,r=Tn(4,e);return Buffer.concat([Buffer.from(r,"utf8"),t])}static streamReader(t){const e=new dr(t);return async function(){try{let o=await e.read(4);if(o==null)return!0;if(o=parseInt(o.toString("utf8"),16),o===0||o===1)return null;const c=await e.read(o-4);return c??!0}catch(o){return t.error=o,!0}}}}class ot extends Error{constructor(t){super(t),this.caller=""}toJSON(){return{code:this.code,data:this.data,caller:this.caller,message:this.message,stack:this.stack}}fromJSON(t){const e=new ot(t.message);return e.code=t.code,e.data=t.data,e.caller=t.caller,e.stack=t.stack,e}get isIsomorphicGitError(){return!0}}class F extends ot{constructor(t){super(`An internal error caused this command to fail. Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/issues with this error message: ${t}`),this.code=this.name=F.code,this.data={message:t}}}F.code="InternalError";class ht extends ot{constructor(t){super(`The filepath "${t}" contains unsafe character sequences`),this.code=this.name=ht.code,this.data={filepath:t}}}ht.code="UnsafeFilepathError";function yr(n,t){return-(n<t)||+(n>t)}function wr(n,t){return yr(n.path,t.path)}function On(n,t){return yr(ke(n),ke(t))}function ke(n){return n.mode==="040000"?n.path+"/":n.path}function gr(n){switch(n){case"040000":return"tree";case"100644":return"blob";case"100755":return"blob";case"120000":return"blob";case"160000":return"commit"}throw new F(`Unexpected GitTree entry mode: ${n}`)}function Rn(n){const t=[];let e=0;for(;e<n.length;){const r=n.indexOf(32,e);if(r===-1)throw new F(`GitTree: Error parsing buffer at byte location ${e}: Could not find the next space character.`);const o=n.indexOf(0,e);if(o===-1)throw new F(`GitTree: Error parsing buffer at byte location ${e}: Could not find the next null character.`);let c=n.slice(e,r).toString("utf8");c==="40000"&&(c="040000");const f=gr(c),s=n.slice(r+1,o).toString("utf8");if(s.includes("\\")||s.includes("/"))throw new ht(s);const h=n.slice(o+1,o+21).toString("hex");e=o+21,t.push({mode:c,path:s,oid:h,type:f})}return t}function Dn(n){if(typeof n=="number"&&(n=n.toString(8)),n.match(/^0?4.*/))return"040000";if(n.match(/^1006.*/))return"100644";if(n.match(/^1007.*/))return"100755";if(n.match(/^120.*/))return"120000";if(n.match(/^160.*/))return"160000";throw new F(`Could not understand file mode: ${n}`)}function jn(n){return!n.oid&&n.sha&&(n.oid=n.sha),n.mode=Dn(n.mode),n.type||(n.type=gr(n.mode)),n}class pe{constructor(t){if(Buffer.isBuffer(t))this._entries=Rn(t);else if(Array.isArray(t))this._entries=t.map(jn);else throw new F("invalid type passed to GitTree constructor");this._entries.sort(wr)}static from(t){return new pe(t)}render(){return this._entries.map(t=>`${t.mode} ${t.type} ${t.oid} ${t.path}`).join(`
|
|
2
|
-
`)}toObject(){const t=[...this._entries];return t.sort(
|
|
3
|
-
`,n}function At(n){const[,t,e,r,o]=n.match(/^(.*) <(.*)> (.*) (.*)$/);return{name:t,email:e,timestamp:Number(r),timezoneOffset:
|
|
1
|
+
"use strict";var cn=Object.create;var Pe=Object.defineProperty;var fn=Object.getOwnPropertyDescriptor;var un=Object.getOwnPropertyNames;var ln=Object.getPrototypeOf,hn=Object.prototype.hasOwnProperty;var pn=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of un(t))!hn.call(n,o)&&o!==e&&Pe(n,o,{get:()=>t[o],enumerable:!(r=fn(t,o))||r.enumerable});return n};var ke=(n,t,e)=>(e=n!=null?cn(ln(n)):{},pn(t||!n||!n.__esModule?Pe(e,"default",{value:n,enumerable:!0}):e,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const rt=require("@php-wasm/util"),dn=require("octokit"),yn=require("crc-32"),pe=require("pako"),K=require("@php-wasm/stream-compression"),at=require("@zip.js/zip.js");function wn(n){return new dn.Octokit({auth:n})}function gn(n,t=""){t.length&&!t.endsWith("/")&&(t+="/");const e={};for(const r of n)r.path.startsWith(t)&&(e[r.path.substring(t.length)]=r.content);return e}async function fr(n,t,e,r,o,c={}){c.progress||(c.progress={foundFiles:0,downloadedFiles:0});const{onProgress:f}=c,s=[],h=[],{data:y}=await n.rest.repos.getContent({owner:t,repo:e,path:o,ref:r});if(!Array.isArray(y))throw new Error(`Expected the list of files to be an array, but got ${typeof y}`);for(const b of y)b.type==="file"?(++c.progress.foundFiles,f==null||f(c.progress),s.push(bn(n,t,e,r,b).then(v=>(++c.progress.downloadedFiles,f==null||f(c.progress),v)))):b.type==="dir"&&h.push(fr(n,t,e,r,b.path,c));const d=await Promise.all(s),w=(await Promise.all(h)).flatMap(b=>b);return[...d,...w]}const mn=new rt.Semaphore({concurrency:15});async function bn(n,t,e,r,o){const c=await mn.acquire();try{const{data:f}=await n.rest.repos.getContent({owner:t,repo:e,ref:r,path:o.path});if(!("content"in f))throw new Error(`No content found for ${o.path}`);return{name:o.name,path:o.path,content:vn(f.content)}}finally{c()}}function vn(n){const t=window.atob(n),e=t.length,r=new Uint8Array(e);for(let o=0;o<e;o++)r[o]=t.charCodeAt(o);return r}async function En(n,t,e,r,o){var d;const{data:c}=await n.rest.pulls.get({owner:t,repo:e,pull_number:r}),s=(d=(await n.rest.actions.listWorkflowRuns({owner:t,repo:e,branch:c.head.ref,workflow_id:o})).data.workflow_runs[0])==null?void 0:d.id,h=await n.rest.actions.listWorkflowRunArtifacts({owner:t,repo:e,run_id:s});return(await n.rest.actions.downloadArtifact({owner:t,repo:e,artifact_id:h.data.artifacts[0].id,archive_format:"zip"})).data}async function xn(n,t,e){var c;const{data:r,headers:o}=await n.request("GET /repos/{owner}/{repo}",{owner:t,repo:e});return!(!o["x-oauth-scopes"]||!((c=r.permissions)!=null&&c.push))}async function An(n,t,e,r,o){await n.request("GET /repos/{owner}/{repo}/branches/{branch}",{owner:t,repo:e,branch:r}).then(()=>!0,()=>!1)?await n.request("PATCH /repos/{owner}/{repo}/git/refs/{ref}",{owner:t,repo:e,sha:o,ref:`heads/${r}`}):await n.request("POST /repos/{owner}/{repo}/git/refs",{owner:t,repo:e,sha:o,ref:`refs/heads/${r}`})}async function Bn(n,t,e){const r=await n.request("GET /user");return(await n.request("GET /repos/{owner}/{repo}/forks",{owner:t,repo:e})).data.find(f=>f.owner&&f.owner.login===r.data.login)||await n.request("POST /repos/{owner}/{repo}/forks",{owner:t,repo:e}),r.data.login}async function Sn(n,t,e,r,o,c){const{data:{sha:f}}=await n.request("POST /repos/{owner}/{repo}/git/commits",{owner:t,repo:e,message:r,tree:c,parents:[o]});return f}async function Fn(n,t,e,r,o){const c=await ur(n,t,e,r,o);if(c.length===0)return null;const{data:{sha:f}}=await n.request("POST /repos/{owner}/{repo}/git/trees",{owner:t,repo:e,base_tree:r,tree:c});return f}async function ur(n,t,e,r,o){const c=[];for(const[f,s]of o.create)c.push(ce(n,t,e,f,s));for(const[f,s]of o.update)c.push(ce(n,t,e,f,s));for(const f of o.delete)c.push(hr(n,t,e,r,f));return Promise.all(c).then(f=>f.filter(s=>!!s))}const lr=new rt.Semaphore({concurrency:10});async function ce(n,t,e,r,o){const c=await lr.acquire();try{if(ArrayBuffer.isView(o))try{const f=new TextDecoder("utf-8",{fatal:!0}).decode(o);return{path:r,content:f,mode:"100644"}}catch{const{data:{sha:f}}=await n.rest.git.createBlob({owner:t,repo:e,encoding:"base64",content:In(o)});return{path:r,sha:f,mode:"100644"}}else return{path:r,content:o,mode:"100644"}}finally{c()}}async function hr(n,t,e,r,o){const c=await lr.acquire();try{return await n.request("HEAD /repos/{owner}/{repo}/contents/:path",{owner:t,repo:e,ref:r,path:o}),{path:o,mode:"100644",sha:null}}catch{return}finally{c()}}function In(n){const t=[],e=n.byteLength;for(let r=0;r<e;r++)t.push(String.fromCharCode(n[r]));return window.btoa(t.join(""))}async function*_n(n,t,{exceptPaths:e=[]}={}){if(t=rt.normalizePath(t),!await n.isDir(t)){await n.fileExists(t)&&(yield{path:t,read:async()=>await n.readFileAsBuffer(t)});return}const r=[t];for(;r.length;){const o=r.pop();if(!o)return;const c=await n.listFiles(o);for(const f of c){const s=rt.joinPaths(o,f);e.includes(s.substring(t.length+1))||(await n.isDir(s)?r.push(s):yield{path:s,read:async()=>await n.readFileAsBuffer(s)})}}}async function $n(n,t){const e={create:new Map,update:new Map,delete:new Set},r=new Set;for await(const o of t){r.add(o.path);const c=n.get(o.path),f=await o.read();c?Un(c,f)||e.update.set(o.path,f):e.create.set(o.path,f)}for(const o of n.keys())r.has(o)||e.delete.add(o);return e}function Un(n,t){return n.length===t.length&&n.every((e,r)=>e===t[r])}async function pr(n){return n.type==="local-fs"?n.handle:dr(n.path)}async function dr(n){const t=n.split("/").filter(r=>r.length>0);let e=await navigator.storage.getDirectory();for(const r of t)e=await e.getDirectoryHandle(r,{create:!0});return e}async function Pn(n){const e=await(await navigator.storage.getDirectory()).resolve(n);if(e===null)throw new DOMException("Unable to resolve path of OPFS directory handle.","NotFoundError");return"/"+e.join("/")}async function kn(n){const t=await pr(n);for await(const e of t.keys())await t.removeEntry(e,{recursive:!0})}function Tn(n){let t=[n];return{next(){return Promise.resolve({done:t.length===0,value:t.pop()})},return(){return t=[],{}},[Symbol.asyncIterator](){return this}}}function yr(n){return n[Symbol.asyncIterator]?n[Symbol.asyncIterator]():n[Symbol.iterator]?n[Symbol.iterator]():n.next?n:Tn(n)}class wr{constructor(t){if(typeof Buffer>"u")throw new Error("Missing Buffer dependency");this.stream=yr(t),this.buffer=null,this.cursor=0,this.undoCursor=0,this.started=!1,this._ended=!1,this._discardedBytes=0}eof(){return this._ended&&this.cursor===this.buffer.length}tell(){return this._discardedBytes+this.cursor}async byte(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(1),this.buffer[this.undoCursor]}async chunk(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(this.buffer.length),this.buffer.slice(this.undoCursor,this.cursor)}async read(t){if(!this.eof())return this.started||await this._init(),this.cursor+t>this.buffer.length&&(this._trim(),await this._accumulate(t)),this._moveCursor(t),this.buffer.slice(this.undoCursor,this.cursor)}async skip(t){this.eof()||(this.started||await this._init(),this.cursor+t>this.buffer.length&&(this._trim(),await this._accumulate(t)),this._moveCursor(t))}async undo(){this.cursor=this.undoCursor}async _next(){this.started=!0;let{done:t,value:e}=await this.stream.next();return t&&(this._ended=!0,!e)?Buffer.alloc(0):(e&&(e=Buffer.from(e)),e)}_trim(){this.buffer=this.buffer.slice(this.undoCursor),this.cursor-=this.undoCursor,this._discardedBytes+=this.undoCursor,this.undoCursor=0}_moveCursor(t){this.undoCursor=this.cursor,this.cursor+=t,this.cursor>this.buffer.length&&(this.cursor=this.buffer.length)}async _accumulate(t){if(this._ended)return;const e=[this.buffer];for(;this.cursor+t>On(e);){const r=await this._next();if(this._ended)break;e.push(r)}this.buffer=Buffer.concat(e)}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 On(n){return n.reduce((t,e)=>t+e.length,0)}function Rn(n,t){const e=t.toString(16);return"0".repeat(n-e.length)+e}class D{static flush(){return Buffer.from("0000","utf8")}static delim(){return Buffer.from("0001","utf8")}static encode(t){typeof t=="string"&&(t=Buffer.from(t));const e=t.length+4,r=Rn(4,e);return Buffer.concat([Buffer.from(r,"utf8"),t])}static streamReader(t){const e=new wr(t);return async function(){try{let o=await e.read(4);if(o==null)return!0;if(o=parseInt(o.toString("utf8"),16),o===0||o===1)return null;const c=await e.read(o-4);return c??!0}catch(o){return t.error=o,!0}}}}class ot extends Error{constructor(t){super(t),this.caller=""}toJSON(){return{code:this.code,data:this.data,caller:this.caller,message:this.message,stack:this.stack}}fromJSON(t){const e=new ot(t.message);return e.code=t.code,e.data=t.data,e.caller=t.caller,e.stack=t.stack,e}get isIsomorphicGitError(){return!0}}class F extends ot{constructor(t){super(`An internal error caused this command to fail. Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/issues with this error message: ${t}`),this.code=this.name=F.code,this.data={message:t}}}F.code="InternalError";class ht extends ot{constructor(t){super(`The filepath "${t}" contains unsafe character sequences`),this.code=this.name=ht.code,this.data={filepath:t}}}ht.code="UnsafeFilepathError";function gr(n,t){return-(n<t)||+(n>t)}function mr(n,t){return gr(n.path,t.path)}function Dn(n,t){return gr(Te(n),Te(t))}function Te(n){return n.mode==="040000"?n.path+"/":n.path}function br(n){switch(n){case"040000":return"tree";case"100644":return"blob";case"100755":return"blob";case"120000":return"blob";case"160000":return"commit"}throw new F(`Unexpected GitTree entry mode: ${n}`)}function jn(n){const t=[];let e=0;for(;e<n.length;){const r=n.indexOf(32,e);if(r===-1)throw new F(`GitTree: Error parsing buffer at byte location ${e}: Could not find the next space character.`);const o=n.indexOf(0,e);if(o===-1)throw new F(`GitTree: Error parsing buffer at byte location ${e}: Could not find the next null character.`);let c=n.slice(e,r).toString("utf8");c==="40000"&&(c="040000");const f=br(c),s=n.slice(r+1,o).toString("utf8");if(s.includes("\\")||s.includes("/"))throw new ht(s);const h=n.slice(o+1,o+21).toString("hex");e=o+21,t.push({mode:c,path:s,oid:h,type:f})}return t}function Cn(n){if(typeof n=="number"&&(n=n.toString(8)),n.match(/^0?4.*/))return"040000";if(n.match(/^1006.*/))return"100644";if(n.match(/^1007.*/))return"100755";if(n.match(/^120.*/))return"120000";if(n.match(/^160.*/))return"160000";throw new F(`Could not understand file mode: ${n}`)}function Nn(n){return!n.oid&&n.sha&&(n.oid=n.sha),n.mode=Cn(n.mode),n.type||(n.type=br(n.mode)),n}class de{constructor(t){if(Buffer.isBuffer(t))this._entries=jn(t);else if(Array.isArray(t))this._entries=t.map(Nn);else throw new F("invalid type passed to GitTree constructor");this._entries.sort(mr)}static from(t){return new de(t)}render(){return this._entries.map(t=>`${t.mode} ${t.type} ${t.oid} ${t.path}`).join(`
|
|
2
|
+
`)}toObject(){const t=[...this._entries];return t.sort(Dn),Buffer.concat(t.map(e=>{const r=Buffer.from(e.mode.replace(/^0/,"")),o=Buffer.from(" "),c=Buffer.from(e.path,"utf8"),f=Buffer.from([0]),s=Buffer.from(e.oid,"hex");return Buffer.concat([r,o,c,f,s])}))}entries(){return this._entries}*[Symbol.iterator](){for(const t of this._entries)yield t}}function fe({name:n,email:t,timestamp:e,timezoneOffset:r}){return r=Mn(r),`${n} <${t}> ${e} ${r}`}function Mn(n){const t=Ln(qn(n));n=Math.abs(n);const e=Math.floor(n/60);n-=e*60;let r=String(e),o=String(n);return r.length<2&&(r="0"+r),o.length<2&&(o="0"+o),(t===-1?"-":"+")+r+o}function Ln(n){return Math.sign(n)||(Object.is(n,-0)?-1:1)}function qn(n){return n===0?n:-n}function V(n){return n=n.replace(/\r/g,""),n=n.replace(/^\n+/,""),n=n.replace(/\n+$/,"")+`
|
|
3
|
+
`,n}function At(n){const[,t,e,r,o]=n.match(/^(.*) <(.*)> (.*) (.*)$/);return{name:t,email:e,timestamp:Number(r),timezoneOffset:Gn(o)}}function Gn(n){let[,t,e,r]=n.match(/(\+|-)(\d\d)(\d\d)/);return r=(t==="+"?1:-1)*(Number(e)*60+Number(r)),Hn(r)}function Hn(n){return n===0?n:-n}class st{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=st.render(t);else throw new F("invalid type passed to GitAnnotatedTag constructor")}static from(t){return new st(t)}static render(t){return`object ${t.object}
|
|
4
4
|
type ${t.type}
|
|
5
5
|
tag ${t.tag}
|
|
6
|
-
tagger ${
|
|
6
|
+
tagger ${fe(t.tagger)}
|
|
7
7
|
|
|
8
8
|
${t.message}
|
|
9
9
|
${t.gpgsig?t.gpgsig:""}`}justHeaders(){return this._tag.slice(0,this._tag.indexOf(`
|
|
@@ -19,7 +19,7 @@ ${t.gpgsig?t.gpgsig:""}`}justHeaders(){return this._tag.slice(0,this._tag.indexO
|
|
|
19
19
|
`}toObject(){return Buffer.from(this._tag,"utf8")}static async sign(t,e,r){const o=t.payload();let{signature:c}=await e({payload:o,secretKey:r});c=V(c);const f=o+c;return st.from(f)}}function Dt(n){return n.trim().split(`
|
|
20
20
|
`).map(t=>" "+t).join(`
|
|
21
21
|
`)+`
|
|
22
|
-
`}function
|
|
22
|
+
`}function zn(n){return n.split(`
|
|
23
23
|
`).map(t=>t.replace(/^ /,"")).join(`
|
|
24
24
|
`)}class M{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=M.render(t);else throw new F("invalid type passed to GitCommit constructor")}static fromPayloadSignature({payload:t,signature:e}){const r=M.justHeaders(t),o=M.justMessage(t),c=V(r+`
|
|
25
25
|
gpgsig`+Dt(e)+`
|
|
@@ -32,44 +32,44 @@ gpgsig`+Dt(e)+`
|
|
|
32
32
|
`+o.slice(1):e.push(o);const r={parent:[]};for(const o of e){const c=o.slice(0,o.indexOf(" ")),f=o.slice(o.indexOf(" ")+1);Array.isArray(r[c])?r[c].push(f):r[c]=f}return r.author&&(r.author=At(r.author)),r.committer&&(r.committer=At(r.committer)),r}static renderHeaders(t){let e="";if(t.tree?e+=`tree ${t.tree}
|
|
33
33
|
`:e+=`tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
|
34
34
|
`,t.parent){if(t.parent.length===void 0)throw new F("commit 'parent' property should be an array");for(const c of t.parent)e+=`parent ${c}
|
|
35
|
-
`}const r=t.author;e+=`author ${
|
|
36
|
-
`;const o=t.committer||t.author;return e+=`committer ${
|
|
35
|
+
`}const r=t.author;e+=`author ${fe(r)}
|
|
36
|
+
`;const o=t.committer||t.author;return e+=`committer ${fe(o)}
|
|
37
37
|
`,t.gpgsig&&(e+="gpgsig"+Dt(t.gpgsig)),e}static render(t){return M.renderHeaders(t)+`
|
|
38
38
|
`+V(t.message)}render(){return this._commit}withoutSignature(){const t=V(this._commit);if(t.indexOf(`
|
|
39
39
|
gpgsig`)===-1)return t;const e=t.slice(0,t.indexOf(`
|
|
40
40
|
gpgsig`)),r=t.slice(t.indexOf(`-----END PGP SIGNATURE-----
|
|
41
41
|
`)+28);return V(e+`
|
|
42
|
-
`+r)}isolateSignature(){const t=this._commit.slice(this._commit.indexOf("-----BEGIN PGP SIGNATURE-----"),this._commit.indexOf("-----END PGP SIGNATURE-----")+27);return
|
|
42
|
+
`+r)}isolateSignature(){const t=this._commit.slice(this._commit.indexOf("-----BEGIN PGP SIGNATURE-----"),this._commit.indexOf("-----END PGP SIGNATURE-----")+27);return zn(t)}static async sign(t,e,r){const o=t.withoutSignature(),c=M.justMessage(t._commit);let{signature:f}=await e({payload:o,secretKey:r});f=V(f);const h=M.justHeaders(t._commit)+`
|
|
43
43
|
gpgsig`+Dt(f)+`
|
|
44
|
-
`+c;return M.from(h)}}class
|
|
44
|
+
`+c;return M.from(h)}}class Wn{static wrap({type:t,object:e}){return Buffer.concat([Buffer.from(`${t} ${e.byteLength.toString()}\0`),Buffer.from(e)])}static unwrap(t){const e=t.indexOf(32),r=t.indexOf(0),o=t.slice(0,e).toString("utf8"),c=t.slice(e+1,r).toString("utf8"),f=t.length-(r+1);if(parseInt(c)!==f)throw new F(`Length mismatch: expected ${c} bytes but got ${f} instead.`);return{type:o,object:Buffer.from(t.slice(r+1))}}}class z{constructor(t){this.buffer=t,this._start=0}eof(){return this._start>=this.buffer.length}tell(){return this._start}seek(t){this._start=t}slice(t){const e=this.buffer.slice(this._start,this._start+t);return this._start+=t,e}toString(t,e){const r=this.buffer.toString(t,this._start,this._start+e);return this._start+=e,r}write(t,e,r){const o=this.buffer.write(t,this._start,e,r);return this._start+=e,o}copy(t,e,r){const o=t.copy(this.buffer,this._start,e,r);return this._start+=o,o}readUInt8(){const t=this.buffer.readUInt8(this._start);return this._start+=1,t}writeUInt8(t){const e=this.buffer.writeUInt8(t,this._start);return this._start+=1,e}readUInt16BE(){const t=this.buffer.readUInt16BE(this._start);return this._start+=2,t}writeUInt16BE(t){const e=this.buffer.writeUInt16BE(t,this._start);return this._start+=2,e}readUInt32BE(){const t=this.buffer.readUInt32BE(this._start);return this._start+=4,t}writeUInt32BE(t){const e=this.buffer.writeUInt32BE(t,this._start);return this._start+=4,e}}function Vn(n,t){const e=new z(n),r=Oe(e);if(r!==t.byteLength)throw new F(`applyDelta expected source buffer to be ${r} bytes but the provided buffer was ${t.length} bytes`);const o=Oe(e);let c;const f=De(e,t);if(f.byteLength===o)c=f;else{c=Buffer.alloc(o);const s=new z(c);for(s.copy(f);!e.eof();)s.copy(De(e,t));const h=s.tell();if(o!==h)throw new F(`applyDelta expected target buffer to be ${o} bytes but the resulting buffer was ${h} bytes`)}return c}function Oe(n){let t=0,e=0,r=null;do r=n.readUInt8(),t|=(r&127)<<e,e+=7;while(r&128);return t}function Re(n,t,e){let r=0,o=0;for(;e--;)t&1&&(r|=n.readUInt8()<<o),t>>=1,o+=8;return r}function De(n,t){const e=n.readUInt8(),r=128,o=15,c=112;if(e&r){const f=Re(n,e&o,4);let s=Re(n,(e&c)>>4,3);return s===0&&(s=65536),t.slice(f,f+s)}else return n.slice(e)}async function Jn(n,t){const e=new wr(n);let r=await e.read(4);if(r=r.toString("utf8"),r!=="PACK")throw new F(`Invalid PACK header '${r}'`);let o=await e.read(4);if(o=o.readUInt32BE(0),o!==2)throw new F(`Invalid packfile version: ${o}`);let c=await e.read(4);if(c=c.readUInt32BE(0),!(c<1))for(;!e.eof()&&c--;){const f=e.tell(),{type:s,length:h,ofs:y,reference:d}=await Yn(e),w=new pe.Inflate;for(;!w.result;){const b=await e.chunk();if(!b)break;if(w.push(b,!1),w.err)throw new F(`Pako error: ${w.msg}`);if(w.result){if(w.result.length!==h)throw new F("Inflated object size is different from that stated in packfile.");await e.undo(),await e.read(b.length-w.strm.avail_in);const v=e.tell();await t({data:w.result,type:s,num:c,offset:f,end:v,reference:d,ofs:y})}}}}async function Yn(n){let t=await n.byte();const e=t>>4&7;let r=t&15;if(t&128){let f=4;do t=await n.byte(),r|=(t&127)<<f,f+=7;while(t&128)}let o,c;if(e===6){let f=0;o=0;const s=[];do t=await n.byte(),o|=(t&127)<<f,f+=7,s.push(t);while(t&128);c=Buffer.from(s)}return e===7&&(c=await n.read(20)),{type:e,length:r,ofs:o,reference:c}}async function Xn(n){return pe.inflate(n)}var vr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Kn(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var ue={exports:{}};typeof Object.create=="function"?ue.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:ue.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}};var Zn=ue.exports,le={exports:{}},ye={},$t={};$t.byteLength=ei;$t.toByteArray=ni;$t.fromByteArray=ai;var W=[],L=[],Qn=typeof Uint8Array<"u"?Uint8Array:Array,jt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Z=0,ti=jt.length;Z<ti;++Z)W[Z]=jt[Z],L[jt.charCodeAt(Z)]=Z;L[45]=62;L[95]=63;function Er(n){var t=n.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=n.indexOf("=");e===-1&&(e=t);var r=e===t?0:4-e%4;return[e,r]}function ei(n){var t=Er(n),e=t[0],r=t[1];return(e+r)*3/4-r}function ri(n,t,e){return(t+e)*3/4-e}function ni(n){var t,e=Er(n),r=e[0],o=e[1],c=new Qn(ri(n,r,o)),f=0,s=o>0?r-4:r,h;for(h=0;h<s;h+=4)t=L[n.charCodeAt(h)]<<18|L[n.charCodeAt(h+1)]<<12|L[n.charCodeAt(h+2)]<<6|L[n.charCodeAt(h+3)],c[f++]=t>>16&255,c[f++]=t>>8&255,c[f++]=t&255;return o===2&&(t=L[n.charCodeAt(h)]<<2|L[n.charCodeAt(h+1)]>>4,c[f++]=t&255),o===1&&(t=L[n.charCodeAt(h)]<<10|L[n.charCodeAt(h+1)]<<4|L[n.charCodeAt(h+2)]>>2,c[f++]=t>>8&255,c[f++]=t&255),c}function ii(n){return W[n>>18&63]+W[n>>12&63]+W[n>>6&63]+W[n&63]}function oi(n,t,e){for(var r,o=[],c=t;c<e;c+=3)r=(n[c]<<16&16711680)+(n[c+1]<<8&65280)+(n[c+2]&255),o.push(ii(r));return o.join("")}function ai(n){for(var t,e=n.length,r=e%3,o=[],c=16383,f=0,s=e-r;f<s;f+=c)o.push(oi(n,f,f+c>s?s:f+c));return r===1?(t=n[e-1],o.push(W[t>>2]+W[t<<4&63]+"==")):r===2&&(t=(n[e-2]<<8)+n[e-1],o.push(W[t>>10]+W[t>>4&63]+W[t<<2&63]+"=")),o.join("")}var we={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */we.read=function(n,t,e,r,o){var c,f,s=o*8-r-1,h=(1<<s)-1,y=h>>1,d=-7,w=e?o-1:0,b=e?-1:1,v=n[t+w];for(w+=b,c=v&(1<<-d)-1,v>>=-d,d+=s;d>0;c=c*256+n[t+w],w+=b,d-=8);for(f=c&(1<<-d)-1,c>>=-d,d+=r;d>0;f=f*256+n[t+w],w+=b,d-=8);if(c===0)c=1-y;else{if(c===h)return f?NaN:(v?-1:1)*(1/0);f=f+Math.pow(2,r),c=c-y}return(v?-1:1)*f*Math.pow(2,c-r)};we.write=function(n,t,e,r,o,c){var f,s,h,y=c*8-o-1,d=(1<<y)-1,w=d>>1,b=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,v=r?0:c-1,_=r?1:-1,U=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,f=d):(f=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-f))<1&&(f--,h*=2),f+w>=1?t+=b/h:t+=b*Math.pow(2,1-w),t*h>=2&&(f++,h/=2),f+w>=d?(s=0,f=d):f+w>=1?(s=(t*h-1)*Math.pow(2,o),f=f+w):(s=t*Math.pow(2,w-1)*Math.pow(2,o),f=0));o>=8;n[e+v]=s&255,v+=_,s/=256,o-=8);for(f=f<<o|s,y+=o;y>0;n[e+v]=f&255,v+=_,f/=256,y-=8);n[e+v-_]|=U*128};/*!
|
|
45
45
|
* The buffer module from node.js, for the browser.
|
|
46
46
|
*
|
|
47
47
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
48
48
|
* @license MIT
|
|
49
|
-
*/(function(n){var t=$t,e=ye,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=s,n.SlowBuffer=I,n.INSPECT_MAX_BYTES=50;var o=2147483647;n.kMaxLength=o,s.TYPED_ARRAY_SUPPORT=c(),!s.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{var u=new Uint8Array(1),i={foo:function(){return 42}};return Object.setPrototypeOf(i,Uint8Array.prototype),Object.setPrototypeOf(u,i),u.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function f(u){if(u>o)throw new RangeError('The value "'+u+'" is invalid for option "size"');var i=new Uint8Array(u);return Object.setPrototypeOf(i,s.prototype),i}function s(u,i,a){if(typeof u=="number"){if(typeof i=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return w(u)}return h(u,i,a)}s.poolSize=8192;function h(u,i,a){if(typeof u=="string")return b(u,i);if(ArrayBuffer.isView(u))return _(u);if(u==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof u);if(q(u,ArrayBuffer)||u&&q(u.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(q(u,SharedArrayBuffer)||u&&q(u.buffer,SharedArrayBuffer)))return U(u,i,a);if(typeof u=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var l=u.valueOf&&u.valueOf();if(l!=null&&l!==u)return s.from(l,i,a);var p=B(u);if(p)return p;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof u[Symbol.toPrimitive]=="function")return s.from(u[Symbol.toPrimitive]("string"),i,a);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof u)}s.from=function(u,i,a){return h(u,i,a)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function y(u){if(typeof u!="number")throw new TypeError('"size" argument must be of type number');if(u<0)throw new RangeError('The value "'+u+'" is invalid for option "size"')}function d(u,i,a){return y(u),u<=0?f(u):i!==void 0?typeof a=="string"?f(u).fill(i,a):f(u).fill(i):f(u)}s.alloc=function(u,i,a){return d(u,i,a)};function w(u){return y(u),f(u<0?0:x(u)|0)}s.allocUnsafe=function(u){return w(u)},s.allocUnsafeSlow=function(u){return w(u)};function b(u,i){if((typeof i!="string"||i==="")&&(i="utf8"),!s.isEncoding(i))throw new TypeError("Unknown encoding: "+i);var a=E(u,i)|0,l=f(a),p=l.write(u,i);return p!==a&&(l=l.slice(0,p)),l}function v(u){for(var i=u.length<0?0:x(u.length)|0,a=f(i),l=0;l<i;l+=1)a[l]=u[l]&255;return a}function _(u){if(q(u,Uint8Array)){var i=new Uint8Array(u);return U(i.buffer,i.byteOffset,i.byteLength)}return v(u)}function U(u,i,a){if(i<0||u.byteLength<i)throw new RangeError('"offset" is outside of buffer bounds');if(u.byteLength<i+(a||0))throw new RangeError('"length" is outside of buffer bounds');var l;return i===void 0&&a===void 0?l=new Uint8Array(u):a===void 0?l=new Uint8Array(u,i):l=new Uint8Array(u,i,a),Object.setPrototypeOf(l,s.prototype),l}function B(u){if(s.isBuffer(u)){var i=x(u.length)|0,a=f(i);return a.length===0||u.copy(a,0,0,i),a}if(u.length!==void 0)return typeof u.length!="number"||Rt(u.length)?f(0):v(u);if(u.type==="Buffer"&&Array.isArray(u.data))return v(u.data)}function x(u){if(u>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return u|0}function I(u){return+u!=u&&(u=0),s.alloc(+u)}s.isBuffer=function(i){return i!=null&&i._isBuffer===!0&&i!==s.prototype},s.compare=function(i,a){if(q(i,Uint8Array)&&(i=s.from(i,i.offset,i.byteLength)),q(a,Uint8Array)&&(a=s.from(a,a.offset,a.byteLength)),!s.isBuffer(i)||!s.isBuffer(a))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(i===a)return 0;for(var l=i.length,p=a.length,g=0,m=Math.min(l,p);g<m;++g)if(i[g]!==a[g]){l=i[g],p=a[g];break}return l<p?-1:p<l?1:0},s.isEncoding=function(i){switch(String(i).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(i,a){if(!Array.isArray(i))throw new TypeError('"list" argument must be an Array of Buffers');if(i.length===0)return s.alloc(0);var l;if(a===void 0)for(a=0,l=0;l<i.length;++l)a+=i[l].length;var p=s.allocUnsafe(a),g=0;for(l=0;l<i.length;++l){var m=i[l];if(q(m,Uint8Array))g+m.length>p.length?s.from(m).copy(p,g):Uint8Array.prototype.set.call(p,m,g);else if(s.isBuffer(m))m.copy(p,g);else throw new TypeError('"list" argument must be an Array of Buffers');g+=m.length}return p};function E(u,i){if(s.isBuffer(u))return u.length;if(ArrayBuffer.isView(u)||q(u,ArrayBuffer))return u.byteLength;if(typeof u!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof u);var a=u.length,l=arguments.length>2&&arguments[2]===!0;if(!l&&a===0)return 0;for(var p=!1;;)switch(i){case"ascii":case"latin1":case"binary":return a;case"utf8":case"utf-8":return Ot(u).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a*2;case"hex":return a>>>1;case"base64":return Ie(u).length;default:if(p)return l?-1:Ot(u).length;i=(""+i).toLowerCase(),p=!0}}s.byteLength=E;function P(u,i,a){var l=!1;if((i===void 0||i<0)&&(i=0),i>this.length||((a===void 0||a>this.length)&&(a=this.length),a<=0)||(a>>>=0,i>>>=0,a<=i))return"";for(u||(u="utf8");;)switch(u){case"hex":return Zr(this,i,a);case"utf8":case"utf-8":return xe(this,i,a);case"ascii":return Xr(this,i,a);case"latin1":case"binary":return Kr(this,i,a);case"base64":return Jr(this,i,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Qr(this,i,a);default:if(l)throw new TypeError("Unknown encoding: "+u);u=(u+"").toLowerCase(),l=!0}}s.prototype._isBuffer=!0;function j(u,i,a){var l=u[i];u[i]=u[a],u[a]=l}s.prototype.swap16=function(){var i=this.length;if(i%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var a=0;a<i;a+=2)j(this,a,a+1);return this},s.prototype.swap32=function(){var i=this.length;if(i%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var a=0;a<i;a+=4)j(this,a,a+3),j(this,a+1,a+2);return this},s.prototype.swap64=function(){var i=this.length;if(i%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var a=0;a<i;a+=8)j(this,a,a+7),j(this,a+1,a+6),j(this,a+2,a+5),j(this,a+3,a+4);return this},s.prototype.toString=function(){var i=this.length;return i===0?"":arguments.length===0?xe(this,0,i):P.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(i){if(!s.isBuffer(i))throw new TypeError("Argument must be a Buffer");return this===i?!0:s.compare(this,i)===0},s.prototype.inspect=function(){var i="",a=n.INSPECT_MAX_BYTES;return i=this.toString("hex",0,a).replace(/(.{2})/g,"$1 ").trim(),this.length>a&&(i+=" ... "),"<Buffer "+i+">"},r&&(s.prototype[r]=s.prototype.inspect),s.prototype.compare=function(i,a,l,p,g){if(q(i,Uint8Array)&&(i=s.from(i,i.offset,i.byteLength)),!s.isBuffer(i))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof i);if(a===void 0&&(a=0),l===void 0&&(l=i?i.length:0),p===void 0&&(p=0),g===void 0&&(g=this.length),a<0||l>i.length||p<0||g>this.length)throw new RangeError("out of range index");if(p>=g&&a>=l)return 0;if(p>=g)return-1;if(a>=l)return 1;if(a>>>=0,l>>>=0,p>>>=0,g>>>=0,this===i)return 0;for(var m=g-p,S=l-a,$=Math.min(m,S),k=this.slice(p,g),C=i.slice(a,l),T=0;T<$;++T)if(k[T]!==C[T]){m=k[T],S=C[T];break}return m<S?-1:S<m?1:0};function ve(u,i,a,l,p){if(u.length===0)return-1;if(typeof a=="string"?(l=a,a=0):a>2147483647?a=2147483647:a<-2147483648&&(a=-2147483648),a=+a,Rt(a)&&(a=p?0:u.length-1),a<0&&(a=u.length+a),a>=u.length){if(p)return-1;a=u.length-1}else if(a<0)if(p)a=0;else return-1;if(typeof i=="string"&&(i=s.from(i,l)),s.isBuffer(i))return i.length===0?-1:Ee(u,i,a,l,p);if(typeof i=="number")return i=i&255,typeof Uint8Array.prototype.indexOf=="function"?p?Uint8Array.prototype.indexOf.call(u,i,a):Uint8Array.prototype.lastIndexOf.call(u,i,a):Ee(u,[i],a,l,p);throw new TypeError("val must be string, number or Buffer")}function Ee(u,i,a,l,p){var g=1,m=u.length,S=i.length;if(l!==void 0&&(l=String(l).toLowerCase(),l==="ucs2"||l==="ucs-2"||l==="utf16le"||l==="utf-16le")){if(u.length<2||i.length<2)return-1;g=2,m/=2,S/=2,a/=2}function $(_e,$e){return g===1?_e[$e]:_e.readUInt16BE($e*g)}var k;if(p){var C=-1;for(k=a;k<m;k++)if($(u,k)===$(i,C===-1?0:k-C)){if(C===-1&&(C=k),k-C+1===S)return C*g}else C!==-1&&(k-=k-C),C=-1}else for(a+S>m&&(a=m-S),k=a;k>=0;k--){for(var T=!0,vt=0;vt<S;vt++)if($(u,k+vt)!==$(i,vt)){T=!1;break}if(T)return k}return-1}s.prototype.includes=function(i,a,l){return this.indexOf(i,a,l)!==-1},s.prototype.indexOf=function(i,a,l){return ve(this,i,a,l,!0)},s.prototype.lastIndexOf=function(i,a,l){return ve(this,i,a,l,!1)};function qr(u,i,a,l){a=Number(a)||0;var p=u.length-a;l?(l=Number(l),l>p&&(l=p)):l=p;var g=i.length;l>g/2&&(l=g/2);for(var m=0;m<l;++m){var S=parseInt(i.substr(m*2,2),16);if(Rt(S))return m;u[a+m]=S}return m}function Hr(u,i,a,l){return bt(Ot(i,u.length-a),u,a,l)}function zr(u,i,a,l){return bt(rn(i),u,a,l)}function Wr(u,i,a,l){return bt(Ie(i),u,a,l)}function Vr(u,i,a,l){return bt(nn(i,u.length-a),u,a,l)}s.prototype.write=function(i,a,l,p){if(a===void 0)p="utf8",l=this.length,a=0;else if(l===void 0&&typeof a=="string")p=a,l=this.length,a=0;else if(isFinite(a))a=a>>>0,isFinite(l)?(l=l>>>0,p===void 0&&(p="utf8")):(p=l,l=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var g=this.length-a;if((l===void 0||l>g)&&(l=g),i.length>0&&(l<0||a<0)||a>this.length)throw new RangeError("Attempt to write outside buffer bounds");p||(p="utf8");for(var m=!1;;)switch(p){case"hex":return qr(this,i,a,l);case"utf8":case"utf-8":return Hr(this,i,a,l);case"ascii":case"latin1":case"binary":return zr(this,i,a,l);case"base64":return Wr(this,i,a,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Vr(this,i,a,l);default:if(m)throw new TypeError("Unknown encoding: "+p);p=(""+p).toLowerCase(),m=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Jr(u,i,a){return i===0&&a===u.length?t.fromByteArray(u):t.fromByteArray(u.slice(i,a))}function xe(u,i,a){a=Math.min(u.length,a);for(var l=[],p=i;p<a;){var g=u[p],m=null,S=g>239?4:g>223?3:g>191?2:1;if(p+S<=a){var $,k,C,T;switch(S){case 1:g<128&&(m=g);break;case 2:$=u[p+1],($&192)===128&&(T=(g&31)<<6|$&63,T>127&&(m=T));break;case 3:$=u[p+1],k=u[p+2],($&192)===128&&(k&192)===128&&(T=(g&15)<<12|($&63)<<6|k&63,T>2047&&(T<55296||T>57343)&&(m=T));break;case 4:$=u[p+1],k=u[p+2],C=u[p+3],($&192)===128&&(k&192)===128&&(C&192)===128&&(T=(g&15)<<18|($&63)<<12|(k&63)<<6|C&63,T>65535&&T<1114112&&(m=T))}}m===null?(m=65533,S=1):m>65535&&(m-=65536,l.push(m>>>10&1023|55296),m=56320|m&1023),l.push(m),p+=S}return Yr(l)}var Ae=4096;function Yr(u){var i=u.length;if(i<=Ae)return String.fromCharCode.apply(String,u);for(var a="",l=0;l<i;)a+=String.fromCharCode.apply(String,u.slice(l,l+=Ae));return a}function Xr(u,i,a){var l="";a=Math.min(u.length,a);for(var p=i;p<a;++p)l+=String.fromCharCode(u[p]&127);return l}function Kr(u,i,a){var l="";a=Math.min(u.length,a);for(var p=i;p<a;++p)l+=String.fromCharCode(u[p]);return l}function Zr(u,i,a){var l=u.length;(!i||i<0)&&(i=0),(!a||a<0||a>l)&&(a=l);for(var p="",g=i;g<a;++g)p+=on[u[g]];return p}function Qr(u,i,a){for(var l=u.slice(i,a),p="",g=0;g<l.length-1;g+=2)p+=String.fromCharCode(l[g]+l[g+1]*256);return p}s.prototype.slice=function(i,a){var l=this.length;i=~~i,a=a===void 0?l:~~a,i<0?(i+=l,i<0&&(i=0)):i>l&&(i=l),a<0?(a+=l,a<0&&(a=0)):a>l&&(a=l),a<i&&(a=i);var p=this.subarray(i,a);return Object.setPrototypeOf(p,s.prototype),p};function O(u,i,a){if(u%1!==0||u<0)throw new RangeError("offset is not uint");if(u+i>a)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(i,a,l){i=i>>>0,a=a>>>0,l||O(i,a,this.length);for(var p=this[i],g=1,m=0;++m<a&&(g*=256);)p+=this[i+m]*g;return p},s.prototype.readUintBE=s.prototype.readUIntBE=function(i,a,l){i=i>>>0,a=a>>>0,l||O(i,a,this.length);for(var p=this[i+--a],g=1;a>0&&(g*=256);)p+=this[i+--a]*g;return p},s.prototype.readUint8=s.prototype.readUInt8=function(i,a){return i=i>>>0,a||O(i,1,this.length),this[i]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(i,a){return i=i>>>0,a||O(i,2,this.length),this[i]|this[i+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(i,a){return i=i>>>0,a||O(i,2,this.length),this[i]<<8|this[i+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(i,a){return i=i>>>0,a||O(i,4,this.length),(this[i]|this[i+1]<<8|this[i+2]<<16)+this[i+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(i,a){return i=i>>>0,a||O(i,4,this.length),this[i]*16777216+(this[i+1]<<16|this[i+2]<<8|this[i+3])},s.prototype.readIntLE=function(i,a,l){i=i>>>0,a=a>>>0,l||O(i,a,this.length);for(var p=this[i],g=1,m=0;++m<a&&(g*=256);)p+=this[i+m]*g;return g*=128,p>=g&&(p-=Math.pow(2,8*a)),p},s.prototype.readIntBE=function(i,a,l){i=i>>>0,a=a>>>0,l||O(i,a,this.length);for(var p=a,g=1,m=this[i+--p];p>0&&(g*=256);)m+=this[i+--p]*g;return g*=128,m>=g&&(m-=Math.pow(2,8*a)),m},s.prototype.readInt8=function(i,a){return i=i>>>0,a||O(i,1,this.length),this[i]&128?(255-this[i]+1)*-1:this[i]},s.prototype.readInt16LE=function(i,a){i=i>>>0,a||O(i,2,this.length);var l=this[i]|this[i+1]<<8;return l&32768?l|4294901760:l},s.prototype.readInt16BE=function(i,a){i=i>>>0,a||O(i,2,this.length);var l=this[i+1]|this[i]<<8;return l&32768?l|4294901760:l},s.prototype.readInt32LE=function(i,a){return i=i>>>0,a||O(i,4,this.length),this[i]|this[i+1]<<8|this[i+2]<<16|this[i+3]<<24},s.prototype.readInt32BE=function(i,a){return i=i>>>0,a||O(i,4,this.length),this[i]<<24|this[i+1]<<16|this[i+2]<<8|this[i+3]},s.prototype.readFloatLE=function(i,a){return i=i>>>0,a||O(i,4,this.length),e.read(this,i,!0,23,4)},s.prototype.readFloatBE=function(i,a){return i=i>>>0,a||O(i,4,this.length),e.read(this,i,!1,23,4)},s.prototype.readDoubleLE=function(i,a){return i=i>>>0,a||O(i,8,this.length),e.read(this,i,!0,52,8)},s.prototype.readDoubleBE=function(i,a){return i=i>>>0,a||O(i,8,this.length),e.read(this,i,!1,52,8)};function N(u,i,a,l,p,g){if(!s.isBuffer(u))throw new TypeError('"buffer" argument must be a Buffer instance');if(i>p||i<g)throw new RangeError('"value" argument is out of bounds');if(a+l>u.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(i,a,l,p){if(i=+i,a=a>>>0,l=l>>>0,!p){var g=Math.pow(2,8*l)-1;N(this,i,a,l,g,0)}var m=1,S=0;for(this[a]=i&255;++S<l&&(m*=256);)this[a+S]=i/m&255;return a+l},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(i,a,l,p){if(i=+i,a=a>>>0,l=l>>>0,!p){var g=Math.pow(2,8*l)-1;N(this,i,a,l,g,0)}var m=l-1,S=1;for(this[a+m]=i&255;--m>=0&&(S*=256);)this[a+m]=i/S&255;return a+l},s.prototype.writeUint8=s.prototype.writeUInt8=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,1,255,0),this[a]=i&255,a+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,2,65535,0),this[a]=i&255,this[a+1]=i>>>8,a+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,2,65535,0),this[a]=i>>>8,this[a+1]=i&255,a+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,4,4294967295,0),this[a+3]=i>>>24,this[a+2]=i>>>16,this[a+1]=i>>>8,this[a]=i&255,a+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,4,4294967295,0),this[a]=i>>>24,this[a+1]=i>>>16,this[a+2]=i>>>8,this[a+3]=i&255,a+4},s.prototype.writeIntLE=function(i,a,l,p){if(i=+i,a=a>>>0,!p){var g=Math.pow(2,8*l-1);N(this,i,a,l,g-1,-g)}var m=0,S=1,$=0;for(this[a]=i&255;++m<l&&(S*=256);)i<0&&$===0&&this[a+m-1]!==0&&($=1),this[a+m]=(i/S>>0)-$&255;return a+l},s.prototype.writeIntBE=function(i,a,l,p){if(i=+i,a=a>>>0,!p){var g=Math.pow(2,8*l-1);N(this,i,a,l,g-1,-g)}var m=l-1,S=1,$=0;for(this[a+m]=i&255;--m>=0&&(S*=256);)i<0&&$===0&&this[a+m+1]!==0&&($=1),this[a+m]=(i/S>>0)-$&255;return a+l},s.prototype.writeInt8=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,1,127,-128),i<0&&(i=255+i+1),this[a]=i&255,a+1},s.prototype.writeInt16LE=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,2,32767,-32768),this[a]=i&255,this[a+1]=i>>>8,a+2},s.prototype.writeInt16BE=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,2,32767,-32768),this[a]=i>>>8,this[a+1]=i&255,a+2},s.prototype.writeInt32LE=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,4,2147483647,-2147483648),this[a]=i&255,this[a+1]=i>>>8,this[a+2]=i>>>16,this[a+3]=i>>>24,a+4},s.prototype.writeInt32BE=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,4,2147483647,-2147483648),i<0&&(i=4294967295+i+1),this[a]=i>>>24,this[a+1]=i>>>16,this[a+2]=i>>>8,this[a+3]=i&255,a+4};function Be(u,i,a,l,p,g){if(a+l>u.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("Index out of range")}function Se(u,i,a,l,p){return i=+i,a=a>>>0,p||Be(u,i,a,4),e.write(u,i,a,l,23,4),a+4}s.prototype.writeFloatLE=function(i,a,l){return Se(this,i,a,!0,l)},s.prototype.writeFloatBE=function(i,a,l){return Se(this,i,a,!1,l)};function Fe(u,i,a,l,p){return i=+i,a=a>>>0,p||Be(u,i,a,8),e.write(u,i,a,l,52,8),a+8}s.prototype.writeDoubleLE=function(i,a,l){return Fe(this,i,a,!0,l)},s.prototype.writeDoubleBE=function(i,a,l){return Fe(this,i,a,!1,l)},s.prototype.copy=function(i,a,l,p){if(!s.isBuffer(i))throw new TypeError("argument should be a Buffer");if(l||(l=0),!p&&p!==0&&(p=this.length),a>=i.length&&(a=i.length),a||(a=0),p>0&&p<l&&(p=l),p===l||i.length===0||this.length===0)return 0;if(a<0)throw new RangeError("targetStart out of bounds");if(l<0||l>=this.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("sourceEnd out of bounds");p>this.length&&(p=this.length),i.length-a<p-l&&(p=i.length-a+l);var g=p-l;return this===i&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(a,l,p):Uint8Array.prototype.set.call(i,this.subarray(l,p),a),g},s.prototype.fill=function(i,a,l,p){if(typeof i=="string"){if(typeof a=="string"?(p=a,a=0,l=this.length):typeof l=="string"&&(p=l,l=this.length),p!==void 0&&typeof p!="string")throw new TypeError("encoding must be a string");if(typeof p=="string"&&!s.isEncoding(p))throw new TypeError("Unknown encoding: "+p);if(i.length===1){var g=i.charCodeAt(0);(p==="utf8"&&g<128||p==="latin1")&&(i=g)}}else typeof i=="number"?i=i&255:typeof i=="boolean"&&(i=Number(i));if(a<0||this.length<a||this.length<l)throw new RangeError("Out of range index");if(l<=a)return this;a=a>>>0,l=l===void 0?this.length:l>>>0,i||(i=0);var m;if(typeof i=="number")for(m=a;m<l;++m)this[m]=i;else{var S=s.isBuffer(i)?i:s.from(i,p),$=S.length;if($===0)throw new TypeError('The value "'+i+'" is invalid for argument "value"');for(m=0;m<l-a;++m)this[m+a]=S[m%$]}return this};var tn=/[^+/0-9A-Za-z-_]/g;function en(u){if(u=u.split("=")[0],u=u.trim().replace(tn,""),u.length<2)return"";for(;u.length%4!==0;)u=u+"=";return u}function Ot(u,i){i=i||1/0;for(var a,l=u.length,p=null,g=[],m=0;m<l;++m){if(a=u.charCodeAt(m),a>55295&&a<57344){if(!p){if(a>56319){(i-=3)>-1&&g.push(239,191,189);continue}else if(m+1===l){(i-=3)>-1&&g.push(239,191,189);continue}p=a;continue}if(a<56320){(i-=3)>-1&&g.push(239,191,189),p=a;continue}a=(p-55296<<10|a-56320)+65536}else p&&(i-=3)>-1&&g.push(239,191,189);if(p=null,a<128){if((i-=1)<0)break;g.push(a)}else if(a<2048){if((i-=2)<0)break;g.push(a>>6|192,a&63|128)}else if(a<65536){if((i-=3)<0)break;g.push(a>>12|224,a>>6&63|128,a&63|128)}else if(a<1114112){if((i-=4)<0)break;g.push(a>>18|240,a>>12&63|128,a>>6&63|128,a&63|128)}else throw new Error("Invalid code point")}return g}function rn(u){for(var i=[],a=0;a<u.length;++a)i.push(u.charCodeAt(a)&255);return i}function nn(u,i){for(var a,l,p,g=[],m=0;m<u.length&&!((i-=2)<0);++m)a=u.charCodeAt(m),l=a>>8,p=a%256,g.push(p),g.push(l);return g}function Ie(u){return t.toByteArray(en(u))}function bt(u,i,a,l){for(var p=0;p<l&&!(p+a>=i.length||p>=u.length);++p)i[p+a]=u[p];return p}function q(u,i){return u instanceof i||u!=null&&u.constructor!=null&&u.constructor.name!=null&&u.constructor.name===i.name}function Rt(u){return u!==u}var on=function(){for(var u="0123456789abcdef",i=new Array(256),a=0;a<16;++a)for(var l=a*16,p=0;p<16;++p)i[l+p]=u[a]+u[p];return i}()})(de);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(n,t){var e=de,r=e.Buffer;function o(f,s){for(var h in f)s[h]=f[h]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=e:(o(e,t),t.Buffer=c);function c(f,s,h){return r(f,s,h)}c.prototype=Object.create(r.prototype),o(r,c),c.from=function(f,s,h){if(typeof f=="number")throw new TypeError("Argument must not be a number");return r(f,s,h)},c.alloc=function(f,s,h){if(typeof f!="number")throw new TypeError("Argument must be a number");var y=r(f);return s!==void 0?typeof h=="string"?y.fill(s,h):y.fill(s):y.fill(0),y},c.allocUnsafe=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return r(f)},c.allocUnsafeSlow=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(f)}})(ue,ue.exports);var we=ue.exports,oi={}.toString,ai=Array.isArray||function(n){return oi.call(n)=="[object Array]"},pt=TypeError,vr=Object,si=Error,ci=EvalError,fi=RangeError,ui=ReferenceError,Er=SyntaxError,li=URIError,hi=Math.abs,pi=Math.floor,di=Math.max,yi=Math.min,wi=Math.pow,gi=Math.round,mi=Number.isNaN||function(t){return t!==t},bi=mi,vi=function(t){return bi(t)||t===0?t:t<0?-1:1},Ei=Object.getOwnPropertyDescriptor,Et=Ei;if(Et)try{Et([],"length")}catch{Et=null}var dt=Et,xt=Object.defineProperty||!1;if(xt)try{xt({},"a",{value:1})}catch{xt=!1}var Ut=xt,Ct,De;function xr(){return De||(De=1,Ct=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),r=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var o=42;t[e]=o;for(var c in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var f=Object.getOwnPropertySymbols(t);if(f.length!==1||f[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var s=Object.getOwnPropertyDescriptor(t,e);if(s.value!==o||s.enumerable!==!0)return!1}return!0}),Ct}var Nt,je;function xi(){if(je)return Nt;je=1;var n=typeof Symbol<"u"&&Symbol,t=xr();return Nt=function(){return typeof n!="function"||typeof Symbol!="function"||typeof n("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},Nt}var Mt,Ce;function Ar(){return Ce||(Ce=1,Mt=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),Mt}var Lt,Ne;function Br(){if(Ne)return Lt;Ne=1;var n=vr;return Lt=n.getPrototypeOf||null,Lt}var Ai="Function.prototype.bind called on incompatible ",Bi=Object.prototype.toString,Si=Math.max,Fi="[object Function]",Me=function(t,e){for(var r=[],o=0;o<t.length;o+=1)r[o]=t[o];for(var c=0;c<e.length;c+=1)r[c+t.length]=e[c];return r},Ii=function(t,e){for(var r=[],o=e,c=0;o<t.length;o+=1,c+=1)r[c]=t[o];return r},_i=function(n,t){for(var e="",r=0;r<n.length;r+=1)e+=n[r],r+1<n.length&&(e+=t);return e},$i=function(t){var e=this;if(typeof e!="function"||Bi.apply(e)!==Fi)throw new TypeError(Ai+e);for(var r=Ii(arguments,1),o,c=function(){if(this instanceof o){var d=e.apply(this,Me(r,arguments));return Object(d)===d?d:this}return e.apply(t,Me(r,arguments))},f=Si(0,e.length-r.length),s=[],h=0;h<f;h++)s[h]="$"+h;if(o=Function("binder","return function ("+_i(s,",")+"){ return binder.apply(this,arguments); }")(c),e.prototype){var y=function(){};y.prototype=e.prototype,o.prototype=new y,y.prototype=null}return o},Ui=$i,yt=Function.prototype.bind||Ui,ge=Function.prototype.call,me=Function.prototype.apply,Pi=typeof Reflect<"u"&&Reflect&&Reflect.apply,ki=yt,Ti=me,Oi=ge,Ri=Pi,Sr=Ri||ki.call(Oi,Ti),Di=yt,ji=pt,Ci=ge,Ni=Sr,be=function(t){if(t.length<1||typeof t[0]!="function")throw new ji("a function is required");return Ni(Di,Ci,t)},Gt,Le;function Mi(){if(Le)return Gt;Le=1;var n=be,t=dt,e;try{e=[].__proto__===Array.prototype}catch(f){if(!f||typeof f!="object"||!("code"in f)||f.code!=="ERR_PROTO_ACCESS")throw f}var r=!!e&&t&&t(Object.prototype,"__proto__"),o=Object,c=o.getPrototypeOf;return Gt=r&&typeof r.get=="function"?n([r.get]):typeof c=="function"?function(s){return c(s==null?s:o(s))}:!1,Gt}var qt,Ge;function Fr(){if(Ge)return qt;Ge=1;var n=Ar(),t=Br(),e=Mi();return qt=n?function(o){return n(o)}:t?function(o){if(!o||typeof o!="object"&&typeof o!="function")throw new TypeError("getProto: not an object");return t(o)}:e?function(o){return e(o)}:null,qt}var Ht,qe;function Li(){if(qe)return Ht;qe=1;var n=Function.prototype.call,t=Object.prototype.hasOwnProperty,e=yt;return Ht=e.call(n,t),Ht}var A,Gi=vr,qi=si,Hi=ci,zi=fi,Wi=ui,nt=Er,et=pt,Vi=li,Ji=hi,Yi=pi,Xi=di,Ki=yi,Zi=wi,Qi=gi,to=vi,Ir=Function,zt=function(n){try{return Ir('"use strict"; return ('+n+").constructor;")()}catch{}},ct=dt,eo=Ut,Wt=function(){throw new et},ro=ct?function(){try{return arguments.callee,Wt}catch{try{return ct(arguments,"callee").get}catch{return Wt}}}():Wt,Q=xi()(),R=Fr(),no=Br(),io=Ar(),_r=me,wt=ge,tt={},oo=typeof Uint8Array>"u"||!R?A:R(Uint8Array),Y={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?A:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?A:ArrayBuffer,"%ArrayIteratorPrototype%":Q&&R?R([][Symbol.iterator]()):A,"%AsyncFromSyncIteratorPrototype%":A,"%AsyncFunction%":tt,"%AsyncGenerator%":tt,"%AsyncGeneratorFunction%":tt,"%AsyncIteratorPrototype%":tt,"%Atomics%":typeof Atomics>"u"?A:Atomics,"%BigInt%":typeof BigInt>"u"?A:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?A:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?A:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?A:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":qi,"%eval%":eval,"%EvalError%":Hi,"%Float16Array%":typeof Float16Array>"u"?A:Float16Array,"%Float32Array%":typeof Float32Array>"u"?A:Float32Array,"%Float64Array%":typeof Float64Array>"u"?A:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?A:FinalizationRegistry,"%Function%":Ir,"%GeneratorFunction%":tt,"%Int8Array%":typeof Int8Array>"u"?A:Int8Array,"%Int16Array%":typeof Int16Array>"u"?A:Int16Array,"%Int32Array%":typeof Int32Array>"u"?A:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Q&&R?R(R([][Symbol.iterator]())):A,"%JSON%":typeof JSON=="object"?JSON:A,"%Map%":typeof Map>"u"?A:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Q||!R?A:R(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Gi,"%Object.getOwnPropertyDescriptor%":ct,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?A:Promise,"%Proxy%":typeof Proxy>"u"?A:Proxy,"%RangeError%":zi,"%ReferenceError%":Wi,"%Reflect%":typeof Reflect>"u"?A:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?A:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Q||!R?A:R(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?A:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Q&&R?R(""[Symbol.iterator]()):A,"%Symbol%":Q?Symbol:A,"%SyntaxError%":nt,"%ThrowTypeError%":ro,"%TypedArray%":oo,"%TypeError%":et,"%Uint8Array%":typeof Uint8Array>"u"?A:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?A:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?A:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?A:Uint32Array,"%URIError%":Vi,"%WeakMap%":typeof WeakMap>"u"?A:WeakMap,"%WeakRef%":typeof WeakRef>"u"?A:WeakRef,"%WeakSet%":typeof WeakSet>"u"?A:WeakSet,"%Function.prototype.call%":wt,"%Function.prototype.apply%":_r,"%Object.defineProperty%":eo,"%Object.getPrototypeOf%":no,"%Math.abs%":Ji,"%Math.floor%":Yi,"%Math.max%":Xi,"%Math.min%":Ki,"%Math.pow%":Zi,"%Math.round%":Qi,"%Math.sign%":to,"%Reflect.getPrototypeOf%":io};if(R)try{null.error}catch(n){var ao=R(R(n));Y["%Error.prototype%"]=ao}var so=function n(t){var e;if(t==="%AsyncFunction%")e=zt("async function () {}");else if(t==="%GeneratorFunction%")e=zt("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=zt("async function* () {}");else if(t==="%AsyncGenerator%"){var r=n("%AsyncGeneratorFunction%");r&&(e=r.prototype)}else if(t==="%AsyncIteratorPrototype%"){var o=n("%AsyncGenerator%");o&&R&&(e=R(o.prototype))}return Y[t]=e,e},He={__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"]},gt=yt,Bt=Li(),co=gt.call(wt,Array.prototype.concat),fo=gt.call(_r,Array.prototype.splice),ze=gt.call(wt,String.prototype.replace),St=gt.call(wt,String.prototype.slice),uo=gt.call(wt,RegExp.prototype.exec),lo=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,ho=/\\(\\)?/g,po=function(t){var e=St(t,0,1),r=St(t,-1);if(e==="%"&&r!=="%")throw new nt("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&e!=="%")throw new nt("invalid intrinsic syntax, expected opening `%`");var o=[];return ze(t,lo,function(c,f,s,h){o[o.length]=s?ze(h,ho,"$1"):f||c}),o},yo=function(t,e){var r=t,o;if(Bt(He,r)&&(o=He[r],r="%"+o[0]+"%"),Bt(Y,r)){var c=Y[r];if(c===tt&&(c=so(r)),typeof c>"u"&&!e)throw new et("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:o,name:r,value:c}}throw new nt("intrinsic "+t+" does not exist!")},$r=function(t,e){if(typeof t!="string"||t.length===0)throw new et("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new et('"allowMissing" argument must be a boolean');if(uo(/^%?[^%]*%?$/,t)===null)throw new nt("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=po(t),o=r.length>0?r[0]:"",c=yo("%"+o+"%",e),f=c.name,s=c.value,h=!1,y=c.alias;y&&(o=y[0],fo(r,co([0,1],y)));for(var d=1,w=!0;d<r.length;d+=1){var b=r[d],v=St(b,0,1),_=St(b,-1);if((v==='"'||v==="'"||v==="`"||_==='"'||_==="'"||_==="`")&&v!==_)throw new nt("property names with quotes must have matching quotes");if((b==="constructor"||!w)&&(h=!0),o+="."+b,f="%"+o+"%",Bt(Y,f))s=Y[f];else if(s!=null){if(!(b in s)){if(!e)throw new et("base intrinsic for "+t+" exists, but the property is not available.");return}if(ct&&d+1>=r.length){var U=ct(s,b);w=!!U,w&&"get"in U&&!("originalValue"in U.get)?s=U.get:s=s[b]}else w=Bt(s,b),s=s[b];w&&!h&&(Y[f]=s)}}return s},Ur=$r,Pr=be,wo=Pr([Ur("%String.prototype.indexOf%")]),kr=function(t,e){var r=Ur(t,!!e);return typeof r=="function"&&wo(t,".prototype.")>-1?Pr([r]):r},Vt,We;function go(){if(We)return Vt;We=1;var n=Function.prototype.toString,t=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,e,r;if(typeof t=="function"&&typeof Object.defineProperty=="function")try{e=Object.defineProperty({},"length",{get:function(){throw r}}),r={},t(function(){throw 42},null,e)}catch(I){I!==r&&(t=null)}else t=null;var o=/^\s*class\b/,c=function(E){try{var P=n.call(E);return o.test(P)}catch{return!1}},f=function(E){try{return c(E)?!1:(n.call(E),!0)}catch{return!1}},s=Object.prototype.toString,h="[object Object]",y="[object Function]",d="[object GeneratorFunction]",w="[object HTMLAllCollection]",b="[object HTML document.all class]",v="[object HTMLCollection]",_=typeof Symbol=="function"&&!!Symbol.toStringTag,U=!(0 in[,]),B=function(){return!1};if(typeof document=="object"){var x=document.all;s.call(x)===s.call(document.all)&&(B=function(E){if((U||!E)&&(typeof E>"u"||typeof E=="object"))try{var P=s.call(E);return(P===w||P===b||P===v||P===h)&&E("")==null}catch{}return!1})}return Vt=t?function(E){if(B(E))return!0;if(!E||typeof E!="function"&&typeof E!="object")return!1;try{t(E,null,e)}catch(P){if(P!==r)return!1}return!c(E)&&f(E)}:function(E){if(B(E))return!0;if(!E||typeof E!="function"&&typeof E!="object")return!1;if(_)return f(E);if(c(E))return!1;var P=s.call(E);return P!==y&&P!==d&&!/^\[object HTML/.test(P)?!1:f(E)},Vt}var Jt,Ve;function mo(){if(Ve)return Jt;Ve=1;var n=go(),t=Object.prototype.toString,e=Object.prototype.hasOwnProperty,r=function(h,y,d){for(var w=0,b=h.length;w<b;w++)e.call(h,w)&&(d==null?y(h[w],w,h):y.call(d,h[w],w,h))},o=function(h,y,d){for(var w=0,b=h.length;w<b;w++)d==null?y(h.charAt(w),w,h):y.call(d,h.charAt(w),w,h)},c=function(h,y,d){for(var w in h)e.call(h,w)&&(d==null?y(h[w],w,h):y.call(d,h[w],w,h))};function f(s){return t.call(s)==="[object Array]"}return Jt=function(h,y,d){if(!n(y))throw new TypeError("iterator must be a function");var w;arguments.length>=3&&(w=d),f(h)?r(h,y,w):typeof h=="string"?o(h,y,w):c(h,y,w)},Jt}var Yt,Je;function bo(){return Je||(Je=1,Yt=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),Yt}var Xt,Ye;function vo(){if(Ye)return Xt;Ye=1;var n=bo(),t=typeof globalThis>"u"?mr:globalThis;return Xt=function(){for(var r=[],o=0;o<n.length;o++)typeof t[n[o]]=="function"&&(r[r.length]=n[o]);return r},Xt}var Kt={exports:{}},Zt,Xe;function Eo(){if(Xe)return Zt;Xe=1;var n=Ut,t=Er,e=pt,r=dt;return Zt=function(c,f,s){if(!c||typeof c!="object"&&typeof c!="function")throw new e("`obj` must be an object or a function`");if(typeof f!="string"&&typeof f!="symbol")throw new e("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new e("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new e("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new e("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new e("`loose`, if provided, must be a boolean");var h=arguments.length>3?arguments[3]:null,y=arguments.length>4?arguments[4]:null,d=arguments.length>5?arguments[5]:null,w=arguments.length>6?arguments[6]:!1,b=!!r&&r(c,f);if(n)n(c,f,{configurable:d===null&&b?b.configurable:!d,enumerable:h===null&&b?b.enumerable:!h,value:s,writable:y===null&&b?b.writable:!y});else if(w||!h&&!y&&!d)c[f]=s;else throw new t("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Zt}var Qt,Ke;function xo(){if(Ke)return Qt;Ke=1;var n=Ut,t=function(){return!!n};return t.hasArrayLengthDefineBug=function(){if(!n)return null;try{return n([],"length",{value:1}).length!==1}catch{return!0}},Qt=t,Qt}var te,Ze;function Ao(){if(Ze)return te;Ze=1;var n=$r,t=Eo(),e=xo()(),r=dt,o=pt,c=n("%Math.floor%");return te=function(s,h){if(typeof s!="function")throw new o("`fn` is not a function");if(typeof h!="number"||h<0||h>4294967295||c(h)!==h)throw new o("`length` must be a positive 32-bit integer");var y=arguments.length>2&&!!arguments[2],d=!0,w=!0;if("length"in s&&r){var b=r(s,"length");b&&!b.configurable&&(d=!1),b&&!b.writable&&(w=!1)}return(d||w||!y)&&(e?t(s,"length",h,!0,!0):t(s,"length",h)),s},te}var ee,Qe;function Bo(){if(Qe)return ee;Qe=1;var n=yt,t=me,e=Sr;return ee=function(){return e(n,t,arguments)},ee}var tr;function So(){return tr||(tr=1,function(n){var t=Ao(),e=Ut,r=be,o=Bo();n.exports=function(f){var s=r(arguments),h=f.length-(arguments.length-1);return t(s,1+(h>0?h:0),!0)},e?e(n.exports,"apply",{value:o}):n.exports.apply=o}(Kt)),Kt.exports}var re,er;function Fo(){if(er)return re;er=1;var n=xr();return re=function(){return n()&&!!Symbol.toStringTag},re}var ne,rr;function Io(){if(rr)return ne;rr=1;var n=mo(),t=vo(),e=So(),r=kr,o=dt,c=Fr(),f=r("Object.prototype.toString"),s=Fo()(),h=typeof globalThis>"u"?mr:globalThis,y=t(),d=r("String.prototype.slice"),w=r("Array.prototype.indexOf",!0)||function(B,x){for(var I=0;I<B.length;I+=1)if(B[I]===x)return I;return-1},b={__proto__:null};s&&o&&c?n(y,function(U){var B=new h[U];if(Symbol.toStringTag in B&&c){var x=c(B),I=o(x,Symbol.toStringTag);if(!I&&x){var E=c(x);I=o(E,Symbol.toStringTag)}b["$"+U]=e(I.get)}}):n(y,function(U){var B=new h[U],x=B.slice||B.set;x&&(b["$"+U]=e(x))});var v=function(B){var x=!1;return n(b,function(I,E){if(!x)try{"$"+I(B)===E&&(x=d(E,1))}catch{}}),x},_=function(B){var x=!1;return n(b,function(I,E){if(!x)try{I(B),x=d(E,1)}catch{}}),x};return ne=function(B){if(!B||typeof B!="object")return!1;if(!s){var x=d(f(B),8,-1);return w(y,x)>-1?x:x!=="Object"?!1:_(B)}return o?v(B):null},ne}var ie,nr;function _o(){if(nr)return ie;nr=1;var n=Io();return ie=function(e){return!!n(e)},ie}var $o=pt,Uo=kr,Po=Uo("TypedArray.prototype.buffer",!0),ko=_o(),To=Po||function(t){if(!ko(t))throw new $o("Not a Typed Array");return t.buffer},G=we.Buffer,Oo=ai,Ro=To,Do=ArrayBuffer.isView||function(t){try{return Ro(t),!0}catch{return!1}},jo=typeof Uint8Array<"u",Tr=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",Co=Tr&&(G.prototype instanceof Uint8Array||G.TYPED_ARRAY_SUPPORT),No=function(t,e){if(G.isBuffer(t))return t.constructor&&!("isBuffer"in t)?G.from(t):t;if(typeof t=="string")return G.from(t,e);if(Tr&&Do(t)){if(t.byteLength===0)return G.alloc(0);if(Co){var r=G.from(t.buffer,t.byteOffset,t.byteLength);if(r.byteLength===t.byteLength)return r}var o=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),c=G.from(o);if(c.length===t.byteLength)return c}if(jo&&t instanceof Uint8Array)return G.from(t);var f=Oo(t);if(f)for(var s=0;s<t.length;s+=1){var h=t[s];if(typeof h!="number"||h<0||h>255||~~h!==h)throw new RangeError("Array items must be numbers in the range 0-255.")}if(f||G.isBuffer(t)&&t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t))return G.from(t);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')},Mo=we.Buffer,Lo=No;function Pt(n,t){this._block=Mo.alloc(n),this._finalSize=t,this._blockSize=n,this._len=0}Pt.prototype.update=function(n,t){n=Lo(n,t||"utf8");for(var e=this._block,r=this._blockSize,o=n.length,c=this._len,f=0;f<o;){for(var s=c%r,h=Math.min(o-f,r-s),y=0;y<h;y++)e[s+y]=n[f+y];c+=h,f+=h,c%r===0&&this._update(e)}return this._len+=o,this};Pt.prototype.digest=function(n){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var e=this._len*8;if(e<=4294967295)this._block.writeUInt32BE(e,this._blockSize-4);else{var r=(e&4294967295)>>>0,o=(e-r)/4294967296;this._block.writeUInt32BE(o,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var c=this._hash();return n?c.toString(n):c};Pt.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Go=Pt,qo=Xn,Or=Go,Ho=we.Buffer,zo=[1518500249,1859775393,-1894007588,-899497514],Wo=new Array(80);function mt(){this.init(),this._w=Wo,Or.call(this,64,56)}qo(mt,Or);mt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Vo(n){return n<<1|n>>>31}function Jo(n){return n<<5|n>>>27}function Yo(n){return n<<30|n>>>2}function Xo(n,t,e,r){return n===0?t&e|~t&r:n===2?t&e|t&r|e&r:t^e^r}mt.prototype._update=function(n){for(var t=this._w,e=this._a|0,r=this._b|0,o=this._c|0,c=this._d|0,f=this._e|0,s=0;s<16;++s)t[s]=n.readInt32BE(s*4);for(;s<80;++s)t[s]=Vo(t[s-3]^t[s-8]^t[s-14]^t[s-16]);for(var h=0;h<80;++h){var y=~~(h/20),d=Jo(e)+Xo(y,r,o,c)+f+t[h]+zo[y]|0;f=c,c=o,o=Yo(r),r=e,e=d}this._a=e+this._a|0,this._b=r+this._b|0,this._c=o+this._c|0,this._d=c+this._d|0,this._e=f+this._e|0};mt.prototype._hash=function(){var n=Ho.allocUnsafe(20);return n.writeInt32BE(this._a|0,0),n.writeInt32BE(this._b|0,4),n.writeInt32BE(this._c|0,8),n.writeInt32BE(this._d|0,12),n.writeInt32BE(this._e|0,16),n};var Ko=mt;const Zo=Yn(Ko);function Qo(n){let t="";for(const e of new Uint8Array(n))e<16&&(t+="0"),t+=e.toString(16);return t}let oe=null;async function Ft(n){return oe===null&&(oe=await ea()),oe?Rr(n):ta(n)}function ta(n){return new Zo().update(n).digest("hex")}async function Rr(n){const t=await crypto.subtle.digest("SHA-1",n);return Qo(t)}async function ea(){try{if(await Rr(new Uint8Array([]))==="da39a3ee5e6b4b0d3255bfef95601890afd80709")return!0}catch{}return!1}function ra(n){const t=[];let e=0,r=0;do{e=n.readUInt8();const o=e&127;t.push(o),r=e&128}while(r);return t.reduce((o,c)=>o+1<<7|c,-1)}function na(n,t){let e=t,r=4,o=null;do o=n.readUInt8(),e|=(o&127)<<r,r+=7;while(o&128);return e}class it{constructor(t){Object.assign(this,t),this.offsetCache={}}static async fromIdx({idx:t,getExternalRefDelta:e}){const r=new z(t);if(r.slice(4).toString("hex")!=="ff744f63")return;const c=r.readUInt32BE();if(c!==2)throw new F(`Unable to read version ${c} packfile IDX. (Only version 2 supported)`);if(t.byteLength>2048*1024*1024)throw new F("To keep implementation simple, I haven't implemented the layer 5 feature needed to support packfiles > 2GB in size.");r.seek(r.tell()+4*255);const f=r.readUInt32BE(),s=[];for(let d=0;d<f;d++){const w=r.slice(20).toString("hex");s[d]=w}r.seek(r.tell()+4*f);const h=new Map;for(let d=0;d<f;d++)h.set(s[d],r.readUInt32BE());const y=r.slice(20).toString("hex");return new it({hashes:s,crcs:{},offsets:h,packfileSha:y,getExternalRefDelta:e})}static async fromPack({pack:t,getExternalRefDelta:e,onProgress:r}){const o={1:"commit",2:"tree",3:"blob",4:"tag",6:"ofs-delta",7:"ref-delta"},c={},f=t.slice(-20).toString("hex"),s=[],h={},y=new Map;let d=null,w=null;await Wn([t],async({data:B,type:x,reference:I,offset:E,num:P})=>{d===null&&(d=P);const j=Math.floor((d-P)*100/d);j!==w&&r&&await r({phase:"Receiving objects",loaded:d-P,total:d}),w=j,x=o[x],["commit","tree","blob","tag"].includes(x)?c[E]={type:x,offset:E}:x==="ofs-delta"?c[E]={type:x,offset:E}:x==="ref-delta"&&(c[E]={type:x,offset:E})});const b=Object.keys(c).map(Number);for(const[B,x]of b.entries()){const I=B+1===b.length?t.byteLength-20:b[B+1],E=c[x],P=pn.buf(t.slice(x,I))>>>0;E.end=I,E.crc=P}const v=new it({pack:Promise.resolve(t),packfileSha:f,crcs:h,hashes:s,offsets:y,getExternalRefDelta:e});w=null;let _=0;const U=[0,0,0,0,0,0,0,0,0,0,0,0];for(let B in c){B=Number(B);const x=Math.floor(_*100/d);x!==w&&r&&await r({phase:"Resolving deltas",loaded:_,total:d}),_++,w=x;const I=c[B];if(!I.oid)try{v.readDepth=0,v.externalReadDepth=0;const{type:E,object:P}=await v.readSlice({start:B});U[v.readDepth]+=1;const j=await Ft(Hn.wrap({type:E,object:P}));I.oid=j,s.push(j),y.set(j,B),h[j]=I.crc}catch{continue}}return s.sort(),v}async toBuffer(){const t=[],e=(y,d)=>{t.push(Buffer.from(y,d))};e("ff744f63","hex"),e("00000002","hex");const r=new z(Buffer.alloc(256*4));for(let y=0;y<256;y++){let d=0;for(const w of this.hashes)parseInt(w.slice(0,2),16)<=y&&d++;r.writeUInt32BE(d)}t.push(r.buffer);for(const y of this.hashes)e(y,"hex");const o=new z(Buffer.alloc(this.hashes.length*4));for(const y of this.hashes)o.writeUInt32BE(this.crcs[y]);t.push(o.buffer);const c=new z(Buffer.alloc(this.hashes.length*4));for(const y of this.hashes)c.writeUInt32BE(this.offsets.get(y));t.push(c.buffer),e(this.packfileSha,"hex");const f=Buffer.concat(t),s=await Ft(f),h=Buffer.alloc(20);return h.write(s,"hex"),Buffer.concat([f,h])}async load({pack:t}){this.pack=t}async unload(){this.pack=null}async read({oid:t}){if(!this.offsets.get(t)){if(this.getExternalRefDelta)return this.externalReadDepth++,this.getExternalRefDelta(t);throw new F(`Could not read object ${t} from packfile`)}const e=this.offsets.get(t);return this.readSlice({start:e})}async readSlice({start:t}){if(this.offsetCache[t])return Object.assign({},this.offsetCache[t]);this.readDepth++;const e={16:"commit",32:"tree",48:"blob",64:"tag",96:"ofs_delta",112:"ref_delta"};if(!this.pack)throw new F("Tried to read from a GitPackIndex with no packfile loaded into memory");const r=(await this.pack).slice(t),o=new z(r),c=o.readUInt8(),f=c&112;let s=e[f];if(s===void 0)throw new F("Unrecognized type: 0b"+f.toString(2));const h=c&15;let y=h;c&128&&(y=na(o,h));let w=null,b=null;if(s==="ofs_delta"){const _=ra(o),U=t-_;({object:w,type:s}=await this.readSlice({start:U}))}if(s==="ref_delta"){const _=o.slice(20).toString("hex");({object:w,type:s}=await this.read({oid:_}))}const v=r.slice(o.tell());if(b=Buffer.from(await Jn(v)),b.byteLength!==y)throw new F(`Packfile told us object would have length ${y} but it had length ${b.byteLength}`);return w&&(b=Buffer.from(zn(b,w))),this.readDepth>3&&(this.offsetCache[t]={type:s,object:b}),{type:s,format:"content",object:b}}}class ft extends ot{constructor(t){super(`Expected a 40-char hex object id but saw "${t}".`),this.code=this.name=ft.code,this.data={value:t}}}ft.code="InvalidOidError";class kt extends ot{constructor(t,e,r,o){super(`Object ${t} ${o?`at ${o}`:""}was anticipated to be a ${r} but it is a ${e}.`),this.code=this.name=kt.code,this.data={oid:t,actual:e,expected:r,filepath:o}}}kt.code="ObjectTypeError";function ia(n){let t=n>0?n>>12:0;t!==4&&t!==8&&t!==10&&t!==14&&(t=8);let e=n&511;return e&73?e=493:e=420,t!==8&&(e=0),(t<<12)+e}const H=2**32;function ir(n,t,e,r){if(n!==void 0&&t!==void 0)return[n,t];e===void 0&&(e=r.valueOf());const o=Math.floor(e/1e3),c=(e-o*1e3)*1e6;return[o,c]}function or(n){const[t,e]=ir(n.ctimeSeconds,n.ctimeNanoseconds,n.ctimeMs,n.ctime),[r,o]=ir(n.mtimeSeconds,n.mtimeNanoseconds,n.mtimeMs,n.mtime);return{ctimeSeconds:t%H,ctimeNanoseconds:e%H,mtimeSeconds:r%H,mtimeNanoseconds:o%H,dev:n.dev%H,ino:n.ino%H,mode:ia(n.mode%H),uid:n.uid%H,gid:n.gid%H,size:n.size>-1?n.size%H:0}}function oa(n){return{assumeValid:!!(n&32768),extended:!!(n&16384),stage:(n&12288)>>12,nameLength:n&4095}}function aa(n){const t=n.flags;return t.extended=!1,t.nameLength=Math.min(Buffer.from(n.path).length,4095),(t.assumeValid?32768:0)+(t.extended?16384:0)+((t.stage&3)<<12)+(t.nameLength&4095)}class J{constructor(t,e){this._dirty=!1,this._unmergedPaths=e||new Set,this._entries=t||new Map}_addEntry(t){if(t.flags.stage===0)t.stages=[t],this._entries.set(t.path,t),this._unmergedPaths.delete(t.path);else{let e=this._entries.get(t.path);e||(this._entries.set(t.path,t),e=t),e.stages[t.flags.stage]=t,this._unmergedPaths.add(t.path)}}static async from(t){if(Buffer.isBuffer(t))return J.fromBuffer(t);if(t===null)return new J(null);throw new F("invalid type passed to GitIndex.from")}static async fromBuffer(t){if(t.length===0)throw new F("Index file is empty (.git/index)");const e=new J,r=new z(t),o=r.toString("utf8",4);if(o!=="DIRC")throw new F(`Invalid dircache magic file number: ${o}`);const c=await Ft(t.slice(0,-20)),f=t.slice(-20).toString("hex");if(f!==c)throw new F(`Invalid checksum in GitIndex buffer: expected ${f} but saw ${c}`);const s=r.readUInt32BE();if(s!==2)throw new F(`Unsupported dircache version: ${s}`);const h=r.readUInt32BE();let y=0;for(;!r.eof()&&y<h;){const d={};d.ctimeSeconds=r.readUInt32BE(),d.ctimeNanoseconds=r.readUInt32BE(),d.mtimeSeconds=r.readUInt32BE(),d.mtimeNanoseconds=r.readUInt32BE(),d.dev=r.readUInt32BE(),d.ino=r.readUInt32BE(),d.mode=r.readUInt32BE(),d.uid=r.readUInt32BE(),d.gid=r.readUInt32BE(),d.size=r.readUInt32BE(),d.oid=r.slice(20).toString("hex");const w=r.readUInt16BE();d.flags=oa(w);const b=t.indexOf(0,r.tell()+1)-r.tell();if(b<1)throw new F(`Got a path length of: ${b}`);if(d.path=r.toString("utf8",b),d.path.includes("..\\")||d.path.includes("../"))throw new ht(d.path);let v=8-(r.tell()-12)%8;for(v===0&&(v=8);v--;){const _=r.readUInt8();if(_!==0)throw new F(`Expected 1-8 null characters but got '${_}' after ${d.path}`);if(r.eof())throw new F("Unexpected end of file")}d.stages=[],e._addEntry(d),y++}return e}get unmergedPaths(){return[...this._unmergedPaths]}get entries(){return[...this._entries.values()].sort(wr)}get entriesMap(){return this._entries}get entriesFlat(){return[...this.entries].flatMap(t=>t.stages.length>1?t.stages.filter(e=>e):t)}*[Symbol.iterator](){for(const t of this.entries)yield t}insert({filepath:t,stats:e,oid:r,stage:o=0}){e||(e={ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,mode:0,uid:0,gid:0,size:0}),e=or(e);const c=Buffer.from(t),f={ctimeSeconds:e.ctimeSeconds,ctimeNanoseconds:e.ctimeNanoseconds,mtimeSeconds:e.mtimeSeconds,mtimeNanoseconds:e.mtimeNanoseconds,dev:e.dev,ino:e.ino,mode:e.mode||33188,uid:e.uid,gid:e.gid,size:e.size,path:t,oid:r,flags:{assumeValid:!1,extended:!1,stage:o,nameLength:c.length<4095?c.length:4095},stages:[]};this._addEntry(f),this._dirty=!0}delete({filepath:t}){if(this._entries.has(t))this._entries.delete(t);else for(const e of this._entries.keys())e.startsWith(t+"/")&&this._entries.delete(e);this._unmergedPaths.has(t)&&this._unmergedPaths.delete(t),this._dirty=!0}clear(){this._entries.clear(),this._dirty=!0}has({filepath:t}){return this._entries.has(t)}render(){return this.entries.map(t=>`${t.mode.toString(8)} ${t.oid} ${t.path}`).join(`
|
|
50
|
-
`)}static async _entryToBuffer(t){const e=Buffer.from(t.path),r=Math.ceil((62+e.length+1)/8)*8,o=Buffer.alloc(r),c=new z(o),f=
|
|
49
|
+
*/(function(n){var t=$t,e=we,r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=s,n.SlowBuffer=I,n.INSPECT_MAX_BYTES=50;var o=2147483647;n.kMaxLength=o,s.TYPED_ARRAY_SUPPORT=c(),!s.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{var u=new Uint8Array(1),i={foo:function(){return 42}};return Object.setPrototypeOf(i,Uint8Array.prototype),Object.setPrototypeOf(u,i),u.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function f(u){if(u>o)throw new RangeError('The value "'+u+'" is invalid for option "size"');var i=new Uint8Array(u);return Object.setPrototypeOf(i,s.prototype),i}function s(u,i,a){if(typeof u=="number"){if(typeof i=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return w(u)}return h(u,i,a)}s.poolSize=8192;function h(u,i,a){if(typeof u=="string")return b(u,i);if(ArrayBuffer.isView(u))return _(u);if(u==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof u);if(G(u,ArrayBuffer)||u&&G(u.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(G(u,SharedArrayBuffer)||u&&G(u.buffer,SharedArrayBuffer)))return U(u,i,a);if(typeof u=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var l=u.valueOf&&u.valueOf();if(l!=null&&l!==u)return s.from(l,i,a);var p=B(u);if(p)return p;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof u[Symbol.toPrimitive]=="function")return s.from(u[Symbol.toPrimitive]("string"),i,a);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof u)}s.from=function(u,i,a){return h(u,i,a)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function y(u){if(typeof u!="number")throw new TypeError('"size" argument must be of type number');if(u<0)throw new RangeError('The value "'+u+'" is invalid for option "size"')}function d(u,i,a){return y(u),u<=0?f(u):i!==void 0?typeof a=="string"?f(u).fill(i,a):f(u).fill(i):f(u)}s.alloc=function(u,i,a){return d(u,i,a)};function w(u){return y(u),f(u<0?0:x(u)|0)}s.allocUnsafe=function(u){return w(u)},s.allocUnsafeSlow=function(u){return w(u)};function b(u,i){if((typeof i!="string"||i==="")&&(i="utf8"),!s.isEncoding(i))throw new TypeError("Unknown encoding: "+i);var a=E(u,i)|0,l=f(a),p=l.write(u,i);return p!==a&&(l=l.slice(0,p)),l}function v(u){for(var i=u.length<0?0:x(u.length)|0,a=f(i),l=0;l<i;l+=1)a[l]=u[l]&255;return a}function _(u){if(G(u,Uint8Array)){var i=new Uint8Array(u);return U(i.buffer,i.byteOffset,i.byteLength)}return v(u)}function U(u,i,a){if(i<0||u.byteLength<i)throw new RangeError('"offset" is outside of buffer bounds');if(u.byteLength<i+(a||0))throw new RangeError('"length" is outside of buffer bounds');var l;return i===void 0&&a===void 0?l=new Uint8Array(u):a===void 0?l=new Uint8Array(u,i):l=new Uint8Array(u,i,a),Object.setPrototypeOf(l,s.prototype),l}function B(u){if(s.isBuffer(u)){var i=x(u.length)|0,a=f(i);return a.length===0||u.copy(a,0,0,i),a}if(u.length!==void 0)return typeof u.length!="number"||Rt(u.length)?f(0):v(u);if(u.type==="Buffer"&&Array.isArray(u.data))return v(u.data)}function x(u){if(u>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return u|0}function I(u){return+u!=u&&(u=0),s.alloc(+u)}s.isBuffer=function(i){return i!=null&&i._isBuffer===!0&&i!==s.prototype},s.compare=function(i,a){if(G(i,Uint8Array)&&(i=s.from(i,i.offset,i.byteLength)),G(a,Uint8Array)&&(a=s.from(a,a.offset,a.byteLength)),!s.isBuffer(i)||!s.isBuffer(a))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(i===a)return 0;for(var l=i.length,p=a.length,g=0,m=Math.min(l,p);g<m;++g)if(i[g]!==a[g]){l=i[g],p=a[g];break}return l<p?-1:p<l?1:0},s.isEncoding=function(i){switch(String(i).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(i,a){if(!Array.isArray(i))throw new TypeError('"list" argument must be an Array of Buffers');if(i.length===0)return s.alloc(0);var l;if(a===void 0)for(a=0,l=0;l<i.length;++l)a+=i[l].length;var p=s.allocUnsafe(a),g=0;for(l=0;l<i.length;++l){var m=i[l];if(G(m,Uint8Array))g+m.length>p.length?s.from(m).copy(p,g):Uint8Array.prototype.set.call(p,m,g);else if(s.isBuffer(m))m.copy(p,g);else throw new TypeError('"list" argument must be an Array of Buffers');g+=m.length}return p};function E(u,i){if(s.isBuffer(u))return u.length;if(ArrayBuffer.isView(u)||G(u,ArrayBuffer))return u.byteLength;if(typeof u!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof u);var a=u.length,l=arguments.length>2&&arguments[2]===!0;if(!l&&a===0)return 0;for(var p=!1;;)switch(i){case"ascii":case"latin1":case"binary":return a;case"utf8":case"utf-8":return Ot(u).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a*2;case"hex":return a>>>1;case"base64":return _e(u).length;default:if(p)return l?-1:Ot(u).length;i=(""+i).toLowerCase(),p=!0}}s.byteLength=E;function P(u,i,a){var l=!1;if((i===void 0||i<0)&&(i=0),i>this.length||((a===void 0||a>this.length)&&(a=this.length),a<=0)||(a>>>=0,i>>>=0,a<=i))return"";for(u||(u="utf8");;)switch(u){case"hex":return tn(this,i,a);case"utf8":case"utf-8":return Ae(this,i,a);case"ascii":return Zr(this,i,a);case"latin1":case"binary":return Qr(this,i,a);case"base64":return Xr(this,i,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return en(this,i,a);default:if(l)throw new TypeError("Unknown encoding: "+u);u=(u+"").toLowerCase(),l=!0}}s.prototype._isBuffer=!0;function j(u,i,a){var l=u[i];u[i]=u[a],u[a]=l}s.prototype.swap16=function(){var i=this.length;if(i%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var a=0;a<i;a+=2)j(this,a,a+1);return this},s.prototype.swap32=function(){var i=this.length;if(i%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var a=0;a<i;a+=4)j(this,a,a+3),j(this,a+1,a+2);return this},s.prototype.swap64=function(){var i=this.length;if(i%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var a=0;a<i;a+=8)j(this,a,a+7),j(this,a+1,a+6),j(this,a+2,a+5),j(this,a+3,a+4);return this},s.prototype.toString=function(){var i=this.length;return i===0?"":arguments.length===0?Ae(this,0,i):P.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(i){if(!s.isBuffer(i))throw new TypeError("Argument must be a Buffer");return this===i?!0:s.compare(this,i)===0},s.prototype.inspect=function(){var i="",a=n.INSPECT_MAX_BYTES;return i=this.toString("hex",0,a).replace(/(.{2})/g,"$1 ").trim(),this.length>a&&(i+=" ... "),"<Buffer "+i+">"},r&&(s.prototype[r]=s.prototype.inspect),s.prototype.compare=function(i,a,l,p,g){if(G(i,Uint8Array)&&(i=s.from(i,i.offset,i.byteLength)),!s.isBuffer(i))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof i);if(a===void 0&&(a=0),l===void 0&&(l=i?i.length:0),p===void 0&&(p=0),g===void 0&&(g=this.length),a<0||l>i.length||p<0||g>this.length)throw new RangeError("out of range index");if(p>=g&&a>=l)return 0;if(p>=g)return-1;if(a>=l)return 1;if(a>>>=0,l>>>=0,p>>>=0,g>>>=0,this===i)return 0;for(var m=g-p,S=l-a,$=Math.min(m,S),k=this.slice(p,g),C=i.slice(a,l),T=0;T<$;++T)if(k[T]!==C[T]){m=k[T],S=C[T];break}return m<S?-1:S<m?1:0};function Ee(u,i,a,l,p){if(u.length===0)return-1;if(typeof a=="string"?(l=a,a=0):a>2147483647?a=2147483647:a<-2147483648&&(a=-2147483648),a=+a,Rt(a)&&(a=p?0:u.length-1),a<0&&(a=u.length+a),a>=u.length){if(p)return-1;a=u.length-1}else if(a<0)if(p)a=0;else return-1;if(typeof i=="string"&&(i=s.from(i,l)),s.isBuffer(i))return i.length===0?-1:xe(u,i,a,l,p);if(typeof i=="number")return i=i&255,typeof Uint8Array.prototype.indexOf=="function"?p?Uint8Array.prototype.indexOf.call(u,i,a):Uint8Array.prototype.lastIndexOf.call(u,i,a):xe(u,[i],a,l,p);throw new TypeError("val must be string, number or Buffer")}function xe(u,i,a,l,p){var g=1,m=u.length,S=i.length;if(l!==void 0&&(l=String(l).toLowerCase(),l==="ucs2"||l==="ucs-2"||l==="utf16le"||l==="utf-16le")){if(u.length<2||i.length<2)return-1;g=2,m/=2,S/=2,a/=2}function $($e,Ue){return g===1?$e[Ue]:$e.readUInt16BE(Ue*g)}var k;if(p){var C=-1;for(k=a;k<m;k++)if($(u,k)===$(i,C===-1?0:k-C)){if(C===-1&&(C=k),k-C+1===S)return C*g}else C!==-1&&(k-=k-C),C=-1}else for(a+S>m&&(a=m-S),k=a;k>=0;k--){for(var T=!0,vt=0;vt<S;vt++)if($(u,k+vt)!==$(i,vt)){T=!1;break}if(T)return k}return-1}s.prototype.includes=function(i,a,l){return this.indexOf(i,a,l)!==-1},s.prototype.indexOf=function(i,a,l){return Ee(this,i,a,l,!0)},s.prototype.lastIndexOf=function(i,a,l){return Ee(this,i,a,l,!1)};function zr(u,i,a,l){a=Number(a)||0;var p=u.length-a;l?(l=Number(l),l>p&&(l=p)):l=p;var g=i.length;l>g/2&&(l=g/2);for(var m=0;m<l;++m){var S=parseInt(i.substr(m*2,2),16);if(Rt(S))return m;u[a+m]=S}return m}function Wr(u,i,a,l){return bt(Ot(i,u.length-a),u,a,l)}function Vr(u,i,a,l){return bt(on(i),u,a,l)}function Jr(u,i,a,l){return bt(_e(i),u,a,l)}function Yr(u,i,a,l){return bt(an(i,u.length-a),u,a,l)}s.prototype.write=function(i,a,l,p){if(a===void 0)p="utf8",l=this.length,a=0;else if(l===void 0&&typeof a=="string")p=a,l=this.length,a=0;else if(isFinite(a))a=a>>>0,isFinite(l)?(l=l>>>0,p===void 0&&(p="utf8")):(p=l,l=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var g=this.length-a;if((l===void 0||l>g)&&(l=g),i.length>0&&(l<0||a<0)||a>this.length)throw new RangeError("Attempt to write outside buffer bounds");p||(p="utf8");for(var m=!1;;)switch(p){case"hex":return zr(this,i,a,l);case"utf8":case"utf-8":return Wr(this,i,a,l);case"ascii":case"latin1":case"binary":return Vr(this,i,a,l);case"base64":return Jr(this,i,a,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Yr(this,i,a,l);default:if(m)throw new TypeError("Unknown encoding: "+p);p=(""+p).toLowerCase(),m=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Xr(u,i,a){return i===0&&a===u.length?t.fromByteArray(u):t.fromByteArray(u.slice(i,a))}function Ae(u,i,a){a=Math.min(u.length,a);for(var l=[],p=i;p<a;){var g=u[p],m=null,S=g>239?4:g>223?3:g>191?2:1;if(p+S<=a){var $,k,C,T;switch(S){case 1:g<128&&(m=g);break;case 2:$=u[p+1],($&192)===128&&(T=(g&31)<<6|$&63,T>127&&(m=T));break;case 3:$=u[p+1],k=u[p+2],($&192)===128&&(k&192)===128&&(T=(g&15)<<12|($&63)<<6|k&63,T>2047&&(T<55296||T>57343)&&(m=T));break;case 4:$=u[p+1],k=u[p+2],C=u[p+3],($&192)===128&&(k&192)===128&&(C&192)===128&&(T=(g&15)<<18|($&63)<<12|(k&63)<<6|C&63,T>65535&&T<1114112&&(m=T))}}m===null?(m=65533,S=1):m>65535&&(m-=65536,l.push(m>>>10&1023|55296),m=56320|m&1023),l.push(m),p+=S}return Kr(l)}var Be=4096;function Kr(u){var i=u.length;if(i<=Be)return String.fromCharCode.apply(String,u);for(var a="",l=0;l<i;)a+=String.fromCharCode.apply(String,u.slice(l,l+=Be));return a}function Zr(u,i,a){var l="";a=Math.min(u.length,a);for(var p=i;p<a;++p)l+=String.fromCharCode(u[p]&127);return l}function Qr(u,i,a){var l="";a=Math.min(u.length,a);for(var p=i;p<a;++p)l+=String.fromCharCode(u[p]);return l}function tn(u,i,a){var l=u.length;(!i||i<0)&&(i=0),(!a||a<0||a>l)&&(a=l);for(var p="",g=i;g<a;++g)p+=sn[u[g]];return p}function en(u,i,a){for(var l=u.slice(i,a),p="",g=0;g<l.length-1;g+=2)p+=String.fromCharCode(l[g]+l[g+1]*256);return p}s.prototype.slice=function(i,a){var l=this.length;i=~~i,a=a===void 0?l:~~a,i<0?(i+=l,i<0&&(i=0)):i>l&&(i=l),a<0?(a+=l,a<0&&(a=0)):a>l&&(a=l),a<i&&(a=i);var p=this.subarray(i,a);return Object.setPrototypeOf(p,s.prototype),p};function O(u,i,a){if(u%1!==0||u<0)throw new RangeError("offset is not uint");if(u+i>a)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(i,a,l){i=i>>>0,a=a>>>0,l||O(i,a,this.length);for(var p=this[i],g=1,m=0;++m<a&&(g*=256);)p+=this[i+m]*g;return p},s.prototype.readUintBE=s.prototype.readUIntBE=function(i,a,l){i=i>>>0,a=a>>>0,l||O(i,a,this.length);for(var p=this[i+--a],g=1;a>0&&(g*=256);)p+=this[i+--a]*g;return p},s.prototype.readUint8=s.prototype.readUInt8=function(i,a){return i=i>>>0,a||O(i,1,this.length),this[i]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(i,a){return i=i>>>0,a||O(i,2,this.length),this[i]|this[i+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(i,a){return i=i>>>0,a||O(i,2,this.length),this[i]<<8|this[i+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(i,a){return i=i>>>0,a||O(i,4,this.length),(this[i]|this[i+1]<<8|this[i+2]<<16)+this[i+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(i,a){return i=i>>>0,a||O(i,4,this.length),this[i]*16777216+(this[i+1]<<16|this[i+2]<<8|this[i+3])},s.prototype.readIntLE=function(i,a,l){i=i>>>0,a=a>>>0,l||O(i,a,this.length);for(var p=this[i],g=1,m=0;++m<a&&(g*=256);)p+=this[i+m]*g;return g*=128,p>=g&&(p-=Math.pow(2,8*a)),p},s.prototype.readIntBE=function(i,a,l){i=i>>>0,a=a>>>0,l||O(i,a,this.length);for(var p=a,g=1,m=this[i+--p];p>0&&(g*=256);)m+=this[i+--p]*g;return g*=128,m>=g&&(m-=Math.pow(2,8*a)),m},s.prototype.readInt8=function(i,a){return i=i>>>0,a||O(i,1,this.length),this[i]&128?(255-this[i]+1)*-1:this[i]},s.prototype.readInt16LE=function(i,a){i=i>>>0,a||O(i,2,this.length);var l=this[i]|this[i+1]<<8;return l&32768?l|4294901760:l},s.prototype.readInt16BE=function(i,a){i=i>>>0,a||O(i,2,this.length);var l=this[i+1]|this[i]<<8;return l&32768?l|4294901760:l},s.prototype.readInt32LE=function(i,a){return i=i>>>0,a||O(i,4,this.length),this[i]|this[i+1]<<8|this[i+2]<<16|this[i+3]<<24},s.prototype.readInt32BE=function(i,a){return i=i>>>0,a||O(i,4,this.length),this[i]<<24|this[i+1]<<16|this[i+2]<<8|this[i+3]},s.prototype.readFloatLE=function(i,a){return i=i>>>0,a||O(i,4,this.length),e.read(this,i,!0,23,4)},s.prototype.readFloatBE=function(i,a){return i=i>>>0,a||O(i,4,this.length),e.read(this,i,!1,23,4)},s.prototype.readDoubleLE=function(i,a){return i=i>>>0,a||O(i,8,this.length),e.read(this,i,!0,52,8)},s.prototype.readDoubleBE=function(i,a){return i=i>>>0,a||O(i,8,this.length),e.read(this,i,!1,52,8)};function N(u,i,a,l,p,g){if(!s.isBuffer(u))throw new TypeError('"buffer" argument must be a Buffer instance');if(i>p||i<g)throw new RangeError('"value" argument is out of bounds');if(a+l>u.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(i,a,l,p){if(i=+i,a=a>>>0,l=l>>>0,!p){var g=Math.pow(2,8*l)-1;N(this,i,a,l,g,0)}var m=1,S=0;for(this[a]=i&255;++S<l&&(m*=256);)this[a+S]=i/m&255;return a+l},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(i,a,l,p){if(i=+i,a=a>>>0,l=l>>>0,!p){var g=Math.pow(2,8*l)-1;N(this,i,a,l,g,0)}var m=l-1,S=1;for(this[a+m]=i&255;--m>=0&&(S*=256);)this[a+m]=i/S&255;return a+l},s.prototype.writeUint8=s.prototype.writeUInt8=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,1,255,0),this[a]=i&255,a+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,2,65535,0),this[a]=i&255,this[a+1]=i>>>8,a+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,2,65535,0),this[a]=i>>>8,this[a+1]=i&255,a+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,4,4294967295,0),this[a+3]=i>>>24,this[a+2]=i>>>16,this[a+1]=i>>>8,this[a]=i&255,a+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,4,4294967295,0),this[a]=i>>>24,this[a+1]=i>>>16,this[a+2]=i>>>8,this[a+3]=i&255,a+4},s.prototype.writeIntLE=function(i,a,l,p){if(i=+i,a=a>>>0,!p){var g=Math.pow(2,8*l-1);N(this,i,a,l,g-1,-g)}var m=0,S=1,$=0;for(this[a]=i&255;++m<l&&(S*=256);)i<0&&$===0&&this[a+m-1]!==0&&($=1),this[a+m]=(i/S>>0)-$&255;return a+l},s.prototype.writeIntBE=function(i,a,l,p){if(i=+i,a=a>>>0,!p){var g=Math.pow(2,8*l-1);N(this,i,a,l,g-1,-g)}var m=l-1,S=1,$=0;for(this[a+m]=i&255;--m>=0&&(S*=256);)i<0&&$===0&&this[a+m+1]!==0&&($=1),this[a+m]=(i/S>>0)-$&255;return a+l},s.prototype.writeInt8=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,1,127,-128),i<0&&(i=255+i+1),this[a]=i&255,a+1},s.prototype.writeInt16LE=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,2,32767,-32768),this[a]=i&255,this[a+1]=i>>>8,a+2},s.prototype.writeInt16BE=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,2,32767,-32768),this[a]=i>>>8,this[a+1]=i&255,a+2},s.prototype.writeInt32LE=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,4,2147483647,-2147483648),this[a]=i&255,this[a+1]=i>>>8,this[a+2]=i>>>16,this[a+3]=i>>>24,a+4},s.prototype.writeInt32BE=function(i,a,l){return i=+i,a=a>>>0,l||N(this,i,a,4,2147483647,-2147483648),i<0&&(i=4294967295+i+1),this[a]=i>>>24,this[a+1]=i>>>16,this[a+2]=i>>>8,this[a+3]=i&255,a+4};function Se(u,i,a,l,p,g){if(a+l>u.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("Index out of range")}function Fe(u,i,a,l,p){return i=+i,a=a>>>0,p||Se(u,i,a,4),e.write(u,i,a,l,23,4),a+4}s.prototype.writeFloatLE=function(i,a,l){return Fe(this,i,a,!0,l)},s.prototype.writeFloatBE=function(i,a,l){return Fe(this,i,a,!1,l)};function Ie(u,i,a,l,p){return i=+i,a=a>>>0,p||Se(u,i,a,8),e.write(u,i,a,l,52,8),a+8}s.prototype.writeDoubleLE=function(i,a,l){return Ie(this,i,a,!0,l)},s.prototype.writeDoubleBE=function(i,a,l){return Ie(this,i,a,!1,l)},s.prototype.copy=function(i,a,l,p){if(!s.isBuffer(i))throw new TypeError("argument should be a Buffer");if(l||(l=0),!p&&p!==0&&(p=this.length),a>=i.length&&(a=i.length),a||(a=0),p>0&&p<l&&(p=l),p===l||i.length===0||this.length===0)return 0;if(a<0)throw new RangeError("targetStart out of bounds");if(l<0||l>=this.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("sourceEnd out of bounds");p>this.length&&(p=this.length),i.length-a<p-l&&(p=i.length-a+l);var g=p-l;return this===i&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(a,l,p):Uint8Array.prototype.set.call(i,this.subarray(l,p),a),g},s.prototype.fill=function(i,a,l,p){if(typeof i=="string"){if(typeof a=="string"?(p=a,a=0,l=this.length):typeof l=="string"&&(p=l,l=this.length),p!==void 0&&typeof p!="string")throw new TypeError("encoding must be a string");if(typeof p=="string"&&!s.isEncoding(p))throw new TypeError("Unknown encoding: "+p);if(i.length===1){var g=i.charCodeAt(0);(p==="utf8"&&g<128||p==="latin1")&&(i=g)}}else typeof i=="number"?i=i&255:typeof i=="boolean"&&(i=Number(i));if(a<0||this.length<a||this.length<l)throw new RangeError("Out of range index");if(l<=a)return this;a=a>>>0,l=l===void 0?this.length:l>>>0,i||(i=0);var m;if(typeof i=="number")for(m=a;m<l;++m)this[m]=i;else{var S=s.isBuffer(i)?i:s.from(i,p),$=S.length;if($===0)throw new TypeError('The value "'+i+'" is invalid for argument "value"');for(m=0;m<l-a;++m)this[m+a]=S[m%$]}return this};var rn=/[^+/0-9A-Za-z-_]/g;function nn(u){if(u=u.split("=")[0],u=u.trim().replace(rn,""),u.length<2)return"";for(;u.length%4!==0;)u=u+"=";return u}function Ot(u,i){i=i||1/0;for(var a,l=u.length,p=null,g=[],m=0;m<l;++m){if(a=u.charCodeAt(m),a>55295&&a<57344){if(!p){if(a>56319){(i-=3)>-1&&g.push(239,191,189);continue}else if(m+1===l){(i-=3)>-1&&g.push(239,191,189);continue}p=a;continue}if(a<56320){(i-=3)>-1&&g.push(239,191,189),p=a;continue}a=(p-55296<<10|a-56320)+65536}else p&&(i-=3)>-1&&g.push(239,191,189);if(p=null,a<128){if((i-=1)<0)break;g.push(a)}else if(a<2048){if((i-=2)<0)break;g.push(a>>6|192,a&63|128)}else if(a<65536){if((i-=3)<0)break;g.push(a>>12|224,a>>6&63|128,a&63|128)}else if(a<1114112){if((i-=4)<0)break;g.push(a>>18|240,a>>12&63|128,a>>6&63|128,a&63|128)}else throw new Error("Invalid code point")}return g}function on(u){for(var i=[],a=0;a<u.length;++a)i.push(u.charCodeAt(a)&255);return i}function an(u,i){for(var a,l,p,g=[],m=0;m<u.length&&!((i-=2)<0);++m)a=u.charCodeAt(m),l=a>>8,p=a%256,g.push(p),g.push(l);return g}function _e(u){return t.toByteArray(nn(u))}function bt(u,i,a,l){for(var p=0;p<l&&!(p+a>=i.length||p>=u.length);++p)i[p+a]=u[p];return p}function G(u,i){return u instanceof i||u!=null&&u.constructor!=null&&u.constructor.name!=null&&u.constructor.name===i.name}function Rt(u){return u!==u}var sn=function(){for(var u="0123456789abcdef",i=new Array(256),a=0;a<16;++a)for(var l=a*16,p=0;p<16;++p)i[l+p]=u[a]+u[p];return i}()})(ye);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(n,t){var e=ye,r=e.Buffer;function o(f,s){for(var h in f)s[h]=f[h]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=e:(o(e,t),t.Buffer=c);function c(f,s,h){return r(f,s,h)}c.prototype=Object.create(r.prototype),o(r,c),c.from=function(f,s,h){if(typeof f=="number")throw new TypeError("Argument must not be a number");return r(f,s,h)},c.alloc=function(f,s,h){if(typeof f!="number")throw new TypeError("Argument must be a number");var y=r(f);return s!==void 0?typeof h=="string"?y.fill(s,h):y.fill(s):y.fill(0),y},c.allocUnsafe=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return r(f)},c.allocUnsafeSlow=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(f)}})(le,le.exports);var ge=le.exports,si={}.toString,ci=Array.isArray||function(n){return si.call(n)=="[object Array]"},pt=TypeError,xr=Object,fi=Error,ui=EvalError,li=RangeError,hi=ReferenceError,Ar=SyntaxError,pi=URIError,di=Math.abs,yi=Math.floor,wi=Math.max,gi=Math.min,mi=Math.pow,bi=Math.round,vi=Number.isNaN||function(t){return t!==t},Ei=vi,xi=function(t){return Ei(t)||t===0?t:t<0?-1:1},Ai=Object.getOwnPropertyDescriptor,Et=Ai;if(Et)try{Et([],"length")}catch{Et=null}var dt=Et,xt=Object.defineProperty||!1;if(xt)try{xt({},"a",{value:1})}catch{xt=!1}var Ut=xt,Ct,je;function Br(){return je||(je=1,Ct=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},e=Symbol("test"),r=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(r)!=="[object Symbol]")return!1;var o=42;t[e]=o;for(var c in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var f=Object.getOwnPropertySymbols(t);if(f.length!==1||f[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var s=Object.getOwnPropertyDescriptor(t,e);if(s.value!==o||s.enumerable!==!0)return!1}return!0}),Ct}var Nt,Ce;function Bi(){if(Ce)return Nt;Ce=1;var n=typeof Symbol<"u"&&Symbol,t=Br();return Nt=function(){return typeof n!="function"||typeof Symbol!="function"||typeof n("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:t()},Nt}var Mt,Ne;function Sr(){return Ne||(Ne=1,Mt=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),Mt}var Lt,Me;function Fr(){if(Me)return Lt;Me=1;var n=xr;return Lt=n.getPrototypeOf||null,Lt}var Si="Function.prototype.bind called on incompatible ",Fi=Object.prototype.toString,Ii=Math.max,_i="[object Function]",Le=function(t,e){for(var r=[],o=0;o<t.length;o+=1)r[o]=t[o];for(var c=0;c<e.length;c+=1)r[c+t.length]=e[c];return r},$i=function(t,e){for(var r=[],o=e,c=0;o<t.length;o+=1,c+=1)r[c]=t[o];return r},Ui=function(n,t){for(var e="",r=0;r<n.length;r+=1)e+=n[r],r+1<n.length&&(e+=t);return e},Pi=function(t){var e=this;if(typeof e!="function"||Fi.apply(e)!==_i)throw new TypeError(Si+e);for(var r=$i(arguments,1),o,c=function(){if(this instanceof o){var d=e.apply(this,Le(r,arguments));return Object(d)===d?d:this}return e.apply(t,Le(r,arguments))},f=Ii(0,e.length-r.length),s=[],h=0;h<f;h++)s[h]="$"+h;if(o=Function("binder","return function ("+Ui(s,",")+"){ return binder.apply(this,arguments); }")(c),e.prototype){var y=function(){};y.prototype=e.prototype,o.prototype=new y,y.prototype=null}return o},ki=Pi,yt=Function.prototype.bind||ki,me=Function.prototype.call,qt,qe;function be(){return qe||(qe=1,qt=Function.prototype.apply),qt}var Ti=typeof Reflect<"u"&&Reflect&&Reflect.apply,Oi=yt,Ri=be(),Di=me,ji=Ti,Ir=ji||Oi.call(Di,Ri),Ci=yt,Ni=pt,Mi=me,Li=Ir,ve=function(t){if(t.length<1||typeof t[0]!="function")throw new Ni("a function is required");return Li(Ci,Mi,t)},Gt,Ge;function qi(){if(Ge)return Gt;Ge=1;var n=ve,t=dt,e;try{e=[].__proto__===Array.prototype}catch(f){if(!f||typeof f!="object"||!("code"in f)||f.code!=="ERR_PROTO_ACCESS")throw f}var r=!!e&&t&&t(Object.prototype,"__proto__"),o=Object,c=o.getPrototypeOf;return Gt=r&&typeof r.get=="function"?n([r.get]):typeof c=="function"?function(s){return c(s==null?s:o(s))}:!1,Gt}var Ht,He;function _r(){if(He)return Ht;He=1;var n=Sr(),t=Fr(),e=qi();return Ht=n?function(o){return n(o)}:t?function(o){if(!o||typeof o!="object"&&typeof o!="function")throw new TypeError("getProto: not an object");return t(o)}:e?function(o){return e(o)}:null,Ht}var zt,ze;function Gi(){if(ze)return zt;ze=1;var n=Function.prototype.call,t=Object.prototype.hasOwnProperty,e=yt;return zt=e.call(n,t),zt}var A,Hi=xr,zi=fi,Wi=ui,Vi=li,Ji=hi,nt=Ar,et=pt,Yi=pi,Xi=di,Ki=yi,Zi=wi,Qi=gi,to=mi,eo=bi,ro=xi,$r=Function,Wt=function(n){try{return $r('"use strict"; return ('+n+").constructor;")()}catch{}},ct=dt,no=Ut,Vt=function(){throw new et},io=ct?function(){try{return arguments.callee,Vt}catch{try{return ct(arguments,"callee").get}catch{return Vt}}}():Vt,Q=Bi()(),R=_r(),oo=Fr(),ao=Sr(),Ur=be(),wt=me,tt={},so=typeof Uint8Array>"u"||!R?A:R(Uint8Array),Y={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?A:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?A:ArrayBuffer,"%ArrayIteratorPrototype%":Q&&R?R([][Symbol.iterator]()):A,"%AsyncFromSyncIteratorPrototype%":A,"%AsyncFunction%":tt,"%AsyncGenerator%":tt,"%AsyncGeneratorFunction%":tt,"%AsyncIteratorPrototype%":tt,"%Atomics%":typeof Atomics>"u"?A:Atomics,"%BigInt%":typeof BigInt>"u"?A:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?A:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?A:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?A:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":zi,"%eval%":eval,"%EvalError%":Wi,"%Float16Array%":typeof Float16Array>"u"?A:Float16Array,"%Float32Array%":typeof Float32Array>"u"?A:Float32Array,"%Float64Array%":typeof Float64Array>"u"?A:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?A:FinalizationRegistry,"%Function%":$r,"%GeneratorFunction%":tt,"%Int8Array%":typeof Int8Array>"u"?A:Int8Array,"%Int16Array%":typeof Int16Array>"u"?A:Int16Array,"%Int32Array%":typeof Int32Array>"u"?A:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Q&&R?R(R([][Symbol.iterator]())):A,"%JSON%":typeof JSON=="object"?JSON:A,"%Map%":typeof Map>"u"?A:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Q||!R?A:R(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Hi,"%Object.getOwnPropertyDescriptor%":ct,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?A:Promise,"%Proxy%":typeof Proxy>"u"?A:Proxy,"%RangeError%":Vi,"%ReferenceError%":Ji,"%Reflect%":typeof Reflect>"u"?A:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?A:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Q||!R?A:R(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?A:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Q&&R?R(""[Symbol.iterator]()):A,"%Symbol%":Q?Symbol:A,"%SyntaxError%":nt,"%ThrowTypeError%":io,"%TypedArray%":so,"%TypeError%":et,"%Uint8Array%":typeof Uint8Array>"u"?A:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?A:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?A:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?A:Uint32Array,"%URIError%":Yi,"%WeakMap%":typeof WeakMap>"u"?A:WeakMap,"%WeakRef%":typeof WeakRef>"u"?A:WeakRef,"%WeakSet%":typeof WeakSet>"u"?A:WeakSet,"%Function.prototype.call%":wt,"%Function.prototype.apply%":Ur,"%Object.defineProperty%":no,"%Object.getPrototypeOf%":oo,"%Math.abs%":Xi,"%Math.floor%":Ki,"%Math.max%":Zi,"%Math.min%":Qi,"%Math.pow%":to,"%Math.round%":eo,"%Math.sign%":ro,"%Reflect.getPrototypeOf%":ao};if(R)try{null.error}catch(n){var co=R(R(n));Y["%Error.prototype%"]=co}var fo=function n(t){var e;if(t==="%AsyncFunction%")e=Wt("async function () {}");else if(t==="%GeneratorFunction%")e=Wt("function* () {}");else if(t==="%AsyncGeneratorFunction%")e=Wt("async function* () {}");else if(t==="%AsyncGenerator%"){var r=n("%AsyncGeneratorFunction%");r&&(e=r.prototype)}else if(t==="%AsyncIteratorPrototype%"){var o=n("%AsyncGenerator%");o&&R&&(e=R(o.prototype))}return Y[t]=e,e},We={__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"]},gt=yt,Bt=Gi(),uo=gt.call(wt,Array.prototype.concat),lo=gt.call(Ur,Array.prototype.splice),Ve=gt.call(wt,String.prototype.replace),St=gt.call(wt,String.prototype.slice),ho=gt.call(wt,RegExp.prototype.exec),po=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,yo=/\\(\\)?/g,wo=function(t){var e=St(t,0,1),r=St(t,-1);if(e==="%"&&r!=="%")throw new nt("invalid intrinsic syntax, expected closing `%`");if(r==="%"&&e!=="%")throw new nt("invalid intrinsic syntax, expected opening `%`");var o=[];return Ve(t,po,function(c,f,s,h){o[o.length]=s?Ve(h,yo,"$1"):f||c}),o},go=function(t,e){var r=t,o;if(Bt(We,r)&&(o=We[r],r="%"+o[0]+"%"),Bt(Y,r)){var c=Y[r];if(c===tt&&(c=fo(r)),typeof c>"u"&&!e)throw new et("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:o,name:r,value:c}}throw new nt("intrinsic "+t+" does not exist!")},Pr=function(t,e){if(typeof t!="string"||t.length===0)throw new et("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof e!="boolean")throw new et('"allowMissing" argument must be a boolean');if(ho(/^%?[^%]*%?$/,t)===null)throw new nt("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=wo(t),o=r.length>0?r[0]:"",c=go("%"+o+"%",e),f=c.name,s=c.value,h=!1,y=c.alias;y&&(o=y[0],lo(r,uo([0,1],y)));for(var d=1,w=!0;d<r.length;d+=1){var b=r[d],v=St(b,0,1),_=St(b,-1);if((v==='"'||v==="'"||v==="`"||_==='"'||_==="'"||_==="`")&&v!==_)throw new nt("property names with quotes must have matching quotes");if((b==="constructor"||!w)&&(h=!0),o+="."+b,f="%"+o+"%",Bt(Y,f))s=Y[f];else if(s!=null){if(!(b in s)){if(!e)throw new et("base intrinsic for "+t+" exists, but the property is not available.");return}if(ct&&d+1>=r.length){var U=ct(s,b);w=!!U,w&&"get"in U&&!("originalValue"in U.get)?s=U.get:s=s[b]}else w=Bt(s,b),s=s[b];w&&!h&&(Y[f]=s)}}return s},kr=Pr,Tr=ve,mo=Tr([kr("%String.prototype.indexOf%")]),Or=function(t,e){var r=kr(t,!!e);return typeof r=="function"&&mo(t,".prototype.")>-1?Tr([r]):r},Jt,Je;function bo(){if(Je)return Jt;Je=1;var n=Function.prototype.toString,t=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,e,r;if(typeof t=="function"&&typeof Object.defineProperty=="function")try{e=Object.defineProperty({},"length",{get:function(){throw r}}),r={},t(function(){throw 42},null,e)}catch(I){I!==r&&(t=null)}else t=null;var o=/^\s*class\b/,c=function(E){try{var P=n.call(E);return o.test(P)}catch{return!1}},f=function(E){try{return c(E)?!1:(n.call(E),!0)}catch{return!1}},s=Object.prototype.toString,h="[object Object]",y="[object Function]",d="[object GeneratorFunction]",w="[object HTMLAllCollection]",b="[object HTML document.all class]",v="[object HTMLCollection]",_=typeof Symbol=="function"&&!!Symbol.toStringTag,U=!(0 in[,]),B=function(){return!1};if(typeof document=="object"){var x=document.all;s.call(x)===s.call(document.all)&&(B=function(E){if((U||!E)&&(typeof E>"u"||typeof E=="object"))try{var P=s.call(E);return(P===w||P===b||P===v||P===h)&&E("")==null}catch{}return!1})}return Jt=t?function(E){if(B(E))return!0;if(!E||typeof E!="function"&&typeof E!="object")return!1;try{t(E,null,e)}catch(P){if(P!==r)return!1}return!c(E)&&f(E)}:function(E){if(B(E))return!0;if(!E||typeof E!="function"&&typeof E!="object")return!1;if(_)return f(E);if(c(E))return!1;var P=s.call(E);return P!==y&&P!==d&&!/^\[object HTML/.test(P)?!1:f(E)},Jt}var Yt,Ye;function vo(){if(Ye)return Yt;Ye=1;var n=bo(),t=Object.prototype.toString,e=Object.prototype.hasOwnProperty,r=function(h,y,d){for(var w=0,b=h.length;w<b;w++)e.call(h,w)&&(d==null?y(h[w],w,h):y.call(d,h[w],w,h))},o=function(h,y,d){for(var w=0,b=h.length;w<b;w++)d==null?y(h.charAt(w),w,h):y.call(d,h.charAt(w),w,h)},c=function(h,y,d){for(var w in h)e.call(h,w)&&(d==null?y(h[w],w,h):y.call(d,h[w],w,h))};function f(s){return t.call(s)==="[object Array]"}return Yt=function(h,y,d){if(!n(y))throw new TypeError("iterator must be a function");var w;arguments.length>=3&&(w=d),f(h)?r(h,y,w):typeof h=="string"?o(h,y,w):c(h,y,w)},Yt}var Xt,Xe;function Eo(){return Xe||(Xe=1,Xt=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),Xt}var Kt,Ke;function xo(){if(Ke)return Kt;Ke=1;var n=Eo(),t=typeof globalThis>"u"?vr:globalThis;return Kt=function(){for(var r=[],o=0;o<n.length;o++)typeof t[n[o]]=="function"&&(r[r.length]=n[o]);return r},Kt}var Zt={exports:{}},Qt,Ze;function Ao(){if(Ze)return Qt;Ze=1;var n=Ut,t=Ar,e=pt,r=dt;return Qt=function(c,f,s){if(!c||typeof c!="object"&&typeof c!="function")throw new e("`obj` must be an object or a function`");if(typeof f!="string"&&typeof f!="symbol")throw new e("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new e("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new e("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new e("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new e("`loose`, if provided, must be a boolean");var h=arguments.length>3?arguments[3]:null,y=arguments.length>4?arguments[4]:null,d=arguments.length>5?arguments[5]:null,w=arguments.length>6?arguments[6]:!1,b=!!r&&r(c,f);if(n)n(c,f,{configurable:d===null&&b?b.configurable:!d,enumerable:h===null&&b?b.enumerable:!h,value:s,writable:y===null&&b?b.writable:!y});else if(w||!h&&!y&&!d)c[f]=s;else throw new t("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Qt}var te,Qe;function Bo(){if(Qe)return te;Qe=1;var n=Ut,t=function(){return!!n};return t.hasArrayLengthDefineBug=function(){if(!n)return null;try{return n([],"length",{value:1}).length!==1}catch{return!0}},te=t,te}var ee,tr;function So(){if(tr)return ee;tr=1;var n=Pr,t=Ao(),e=Bo()(),r=dt,o=pt,c=n("%Math.floor%");return ee=function(s,h){if(typeof s!="function")throw new o("`fn` is not a function");if(typeof h!="number"||h<0||h>4294967295||c(h)!==h)throw new o("`length` must be a positive 32-bit integer");var y=arguments.length>2&&!!arguments[2],d=!0,w=!0;if("length"in s&&r){var b=r(s,"length");b&&!b.configurable&&(d=!1),b&&!b.writable&&(w=!1)}return(d||w||!y)&&(e?t(s,"length",h,!0,!0):t(s,"length",h)),s},ee}var re,er;function Fo(){if(er)return re;er=1;var n=yt,t=be(),e=Ir;return re=function(){return e(n,t,arguments)},re}var rr;function Io(){return rr||(rr=1,function(n){var t=So(),e=Ut,r=ve,o=Fo();n.exports=function(f){var s=r(arguments),h=f.length-(arguments.length-1);return t(s,1+(h>0?h:0),!0)},e?e(n.exports,"apply",{value:o}):n.exports.apply=o}(Zt)),Zt.exports}var ne,nr;function _o(){if(nr)return ne;nr=1;var n=Br();return ne=function(){return n()&&!!Symbol.toStringTag},ne}var ie,ir;function $o(){if(ir)return ie;ir=1;var n=vo(),t=xo(),e=Io(),r=Or,o=dt,c=_r(),f=r("Object.prototype.toString"),s=_o()(),h=typeof globalThis>"u"?vr:globalThis,y=t(),d=r("String.prototype.slice"),w=r("Array.prototype.indexOf",!0)||function(B,x){for(var I=0;I<B.length;I+=1)if(B[I]===x)return I;return-1},b={__proto__:null};s&&o&&c?n(y,function(U){var B=new h[U];if(Symbol.toStringTag in B&&c){var x=c(B),I=o(x,Symbol.toStringTag);if(!I&&x){var E=c(x);I=o(E,Symbol.toStringTag)}b["$"+U]=e(I.get)}}):n(y,function(U){var B=new h[U],x=B.slice||B.set;x&&(b["$"+U]=e(x))});var v=function(B){var x=!1;return n(b,function(I,E){if(!x)try{"$"+I(B)===E&&(x=d(E,1))}catch{}}),x},_=function(B){var x=!1;return n(b,function(I,E){if(!x)try{I(B),x=d(E,1)}catch{}}),x};return ie=function(B){if(!B||typeof B!="object")return!1;if(!s){var x=d(f(B),8,-1);return w(y,x)>-1?x:x!=="Object"?!1:_(B)}return o?v(B):null},ie}var oe,or;function Uo(){if(or)return oe;or=1;var n=$o();return oe=function(e){return!!n(e)},oe}var Po=pt,ko=Or,To=ko("TypedArray.prototype.buffer",!0),Oo=Uo(),Ro=To||function(t){if(!Oo(t))throw new Po("Not a Typed Array");return t.buffer},q=ge.Buffer,Do=ci,jo=Ro,Co=ArrayBuffer.isView||function(t){try{return jo(t),!0}catch{return!1}},No=typeof Uint8Array<"u",Rr=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",Mo=Rr&&(q.prototype instanceof Uint8Array||q.TYPED_ARRAY_SUPPORT),Lo=function(t,e){if(q.isBuffer(t))return t.constructor&&!("isBuffer"in t)?q.from(t):t;if(typeof t=="string")return q.from(t,e);if(Rr&&Co(t)){if(t.byteLength===0)return q.alloc(0);if(Mo){var r=q.from(t.buffer,t.byteOffset,t.byteLength);if(r.byteLength===t.byteLength)return r}var o=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),c=q.from(o);if(c.length===t.byteLength)return c}if(No&&t instanceof Uint8Array)return q.from(t);var f=Do(t);if(f)for(var s=0;s<t.length;s+=1){var h=t[s];if(typeof h!="number"||h<0||h>255||~~h!==h)throw new RangeError("Array items must be numbers in the range 0-255.")}if(f||q.isBuffer(t)&&t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t))return q.from(t);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')},qo=ge.Buffer,Go=Lo;function Pt(n,t){this._block=qo.alloc(n),this._finalSize=t,this._blockSize=n,this._len=0}Pt.prototype.update=function(n,t){n=Go(n,t||"utf8");for(var e=this._block,r=this._blockSize,o=n.length,c=this._len,f=0;f<o;){for(var s=c%r,h=Math.min(o-f,r-s),y=0;y<h;y++)e[s+y]=n[f+y];c+=h,f+=h,c%r===0&&this._update(e)}return this._len+=o,this};Pt.prototype.digest=function(n){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var e=this._len*8;if(e<=4294967295)this._block.writeUInt32BE(e,this._blockSize-4);else{var r=(e&4294967295)>>>0,o=(e-r)/4294967296;this._block.writeUInt32BE(o,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var c=this._hash();return n?c.toString(n):c};Pt.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Ho=Pt,zo=Zn,Dr=Ho,Wo=ge.Buffer,Vo=[1518500249,1859775393,-1894007588,-899497514],Jo=new Array(80);function mt(){this.init(),this._w=Jo,Dr.call(this,64,56)}zo(mt,Dr);mt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Yo(n){return n<<1|n>>>31}function Xo(n){return n<<5|n>>>27}function Ko(n){return n<<30|n>>>2}function Zo(n,t,e,r){return n===0?t&e|~t&r:n===2?t&e|t&r|e&r:t^e^r}mt.prototype._update=function(n){for(var t=this._w,e=this._a|0,r=this._b|0,o=this._c|0,c=this._d|0,f=this._e|0,s=0;s<16;++s)t[s]=n.readInt32BE(s*4);for(;s<80;++s)t[s]=Yo(t[s-3]^t[s-8]^t[s-14]^t[s-16]);for(var h=0;h<80;++h){var y=~~(h/20),d=Xo(e)+Zo(y,r,o,c)+f+t[h]+Vo[y]|0;f=c,c=o,o=Ko(r),r=e,e=d}this._a=e+this._a|0,this._b=r+this._b|0,this._c=o+this._c|0,this._d=c+this._d|0,this._e=f+this._e|0};mt.prototype._hash=function(){var n=Wo.allocUnsafe(20);return n.writeInt32BE(this._a|0,0),n.writeInt32BE(this._b|0,4),n.writeInt32BE(this._c|0,8),n.writeInt32BE(this._d|0,12),n.writeInt32BE(this._e|0,16),n};var Qo=mt;const ta=Kn(Qo);function ea(n){let t="";for(const e of new Uint8Array(n))e<16&&(t+="0"),t+=e.toString(16);return t}let ae=null;async function Ft(n){return ae===null&&(ae=await na()),ae?jr(n):ra(n)}function ra(n){return new ta().update(n).digest("hex")}async function jr(n){const t=await crypto.subtle.digest("SHA-1",n);return ea(t)}async function na(){try{if(await jr(new Uint8Array([]))==="da39a3ee5e6b4b0d3255bfef95601890afd80709")return!0}catch{}return!1}function ia(n){const t=[];let e=0,r=0;do{e=n.readUInt8();const o=e&127;t.push(o),r=e&128}while(r);return t.reduce((o,c)=>o+1<<7|c,-1)}function oa(n,t){let e=t,r=4,o=null;do o=n.readUInt8(),e|=(o&127)<<r,r+=7;while(o&128);return e}class it{constructor(t){Object.assign(this,t),this.offsetCache={}}static async fromIdx({idx:t,getExternalRefDelta:e}){const r=new z(t);if(r.slice(4).toString("hex")!=="ff744f63")return;const c=r.readUInt32BE();if(c!==2)throw new F(`Unable to read version ${c} packfile IDX. (Only version 2 supported)`);if(t.byteLength>2048*1024*1024)throw new F("To keep implementation simple, I haven't implemented the layer 5 feature needed to support packfiles > 2GB in size.");r.seek(r.tell()+4*255);const f=r.readUInt32BE(),s=[];for(let d=0;d<f;d++){const w=r.slice(20).toString("hex");s[d]=w}r.seek(r.tell()+4*f);const h=new Map;for(let d=0;d<f;d++)h.set(s[d],r.readUInt32BE());const y=r.slice(20).toString("hex");return new it({hashes:s,crcs:{},offsets:h,packfileSha:y,getExternalRefDelta:e})}static async fromPack({pack:t,getExternalRefDelta:e,onProgress:r}){const o={1:"commit",2:"tree",3:"blob",4:"tag",6:"ofs-delta",7:"ref-delta"},c={},f=t.slice(-20).toString("hex"),s=[],h={},y=new Map;let d=null,w=null;await Jn([t],async({data:B,type:x,reference:I,offset:E,num:P})=>{d===null&&(d=P);const j=Math.floor((d-P)*100/d);j!==w&&r&&await r({phase:"Receiving objects",loaded:d-P,total:d}),w=j,x=o[x],["commit","tree","blob","tag"].includes(x)?c[E]={type:x,offset:E}:x==="ofs-delta"?c[E]={type:x,offset:E}:x==="ref-delta"&&(c[E]={type:x,offset:E})});const b=Object.keys(c).map(Number);for(const[B,x]of b.entries()){const I=B+1===b.length?t.byteLength-20:b[B+1],E=c[x],P=yn.buf(t.slice(x,I))>>>0;E.end=I,E.crc=P}const v=new it({pack:Promise.resolve(t),packfileSha:f,crcs:h,hashes:s,offsets:y,getExternalRefDelta:e});w=null;let _=0;const U=[0,0,0,0,0,0,0,0,0,0,0,0];for(let B in c){B=Number(B);const x=Math.floor(_*100/d);x!==w&&r&&await r({phase:"Resolving deltas",loaded:_,total:d}),_++,w=x;const I=c[B];if(!I.oid)try{v.readDepth=0,v.externalReadDepth=0;const{type:E,object:P}=await v.readSlice({start:B});U[v.readDepth]+=1;const j=await Ft(Wn.wrap({type:E,object:P}));I.oid=j,s.push(j),y.set(j,B),h[j]=I.crc}catch{continue}}return s.sort(),v}async toBuffer(){const t=[],e=(y,d)=>{t.push(Buffer.from(y,d))};e("ff744f63","hex"),e("00000002","hex");const r=new z(Buffer.alloc(256*4));for(let y=0;y<256;y++){let d=0;for(const w of this.hashes)parseInt(w.slice(0,2),16)<=y&&d++;r.writeUInt32BE(d)}t.push(r.buffer);for(const y of this.hashes)e(y,"hex");const o=new z(Buffer.alloc(this.hashes.length*4));for(const y of this.hashes)o.writeUInt32BE(this.crcs[y]);t.push(o.buffer);const c=new z(Buffer.alloc(this.hashes.length*4));for(const y of this.hashes)c.writeUInt32BE(this.offsets.get(y));t.push(c.buffer),e(this.packfileSha,"hex");const f=Buffer.concat(t),s=await Ft(f),h=Buffer.alloc(20);return h.write(s,"hex"),Buffer.concat([f,h])}async load({pack:t}){this.pack=t}async unload(){this.pack=null}async read({oid:t}){if(!this.offsets.get(t)){if(this.getExternalRefDelta)return this.externalReadDepth++,this.getExternalRefDelta(t);throw new F(`Could not read object ${t} from packfile`)}const e=this.offsets.get(t);return this.readSlice({start:e})}async readSlice({start:t}){if(this.offsetCache[t])return Object.assign({},this.offsetCache[t]);this.readDepth++;const e={16:"commit",32:"tree",48:"blob",64:"tag",96:"ofs_delta",112:"ref_delta"};if(!this.pack)throw new F("Tried to read from a GitPackIndex with no packfile loaded into memory");const r=(await this.pack).slice(t),o=new z(r),c=o.readUInt8(),f=c&112;let s=e[f];if(s===void 0)throw new F("Unrecognized type: 0b"+f.toString(2));const h=c&15;let y=h;c&128&&(y=oa(o,h));let w=null,b=null;if(s==="ofs_delta"){const _=ia(o),U=t-_;({object:w,type:s}=await this.readSlice({start:U}))}if(s==="ref_delta"){const _=o.slice(20).toString("hex");({object:w,type:s}=await this.read({oid:_}))}const v=r.slice(o.tell());if(b=Buffer.from(await Xn(v)),b.byteLength!==y)throw new F(`Packfile told us object would have length ${y} but it had length ${b.byteLength}`);return w&&(b=Buffer.from(Vn(b,w))),this.readDepth>3&&(this.offsetCache[t]={type:s,object:b}),{type:s,format:"content",object:b}}}class ft extends ot{constructor(t){super(`Expected a 40-char hex object id but saw "${t}".`),this.code=this.name=ft.code,this.data={value:t}}}ft.code="InvalidOidError";class kt extends ot{constructor(t,e,r,o){super(`Object ${t} ${o?`at ${o}`:""}was anticipated to be a ${r} but it is a ${e}.`),this.code=this.name=kt.code,this.data={oid:t,actual:e,expected:r,filepath:o}}}kt.code="ObjectTypeError";function aa(n){let t=n>0?n>>12:0;t!==4&&t!==8&&t!==10&&t!==14&&(t=8);let e=n&511;return e&73?e=493:e=420,t!==8&&(e=0),(t<<12)+e}const H=2**32;function ar(n,t,e,r){if(n!==void 0&&t!==void 0)return[n,t];e===void 0&&(e=r.valueOf());const o=Math.floor(e/1e3),c=(e-o*1e3)*1e6;return[o,c]}function sr(n){const[t,e]=ar(n.ctimeSeconds,n.ctimeNanoseconds,n.ctimeMs,n.ctime),[r,o]=ar(n.mtimeSeconds,n.mtimeNanoseconds,n.mtimeMs,n.mtime);return{ctimeSeconds:t%H,ctimeNanoseconds:e%H,mtimeSeconds:r%H,mtimeNanoseconds:o%H,dev:n.dev%H,ino:n.ino%H,mode:aa(n.mode%H),uid:n.uid%H,gid:n.gid%H,size:n.size>-1?n.size%H:0}}function sa(n){return{assumeValid:!!(n&32768),extended:!!(n&16384),stage:(n&12288)>>12,nameLength:n&4095}}function ca(n){const t=n.flags;return t.extended=!1,t.nameLength=Math.min(Buffer.from(n.path).length,4095),(t.assumeValid?32768:0)+(t.extended?16384:0)+((t.stage&3)<<12)+(t.nameLength&4095)}class J{constructor(t,e){this._dirty=!1,this._unmergedPaths=e||new Set,this._entries=t||new Map}_addEntry(t){if(t.flags.stage===0)t.stages=[t],this._entries.set(t.path,t),this._unmergedPaths.delete(t.path);else{let e=this._entries.get(t.path);e||(this._entries.set(t.path,t),e=t),e.stages[t.flags.stage]=t,this._unmergedPaths.add(t.path)}}static async from(t){if(Buffer.isBuffer(t))return J.fromBuffer(t);if(t===null)return new J(null);throw new F("invalid type passed to GitIndex.from")}static async fromBuffer(t){if(t.length===0)throw new F("Index file is empty (.git/index)");const e=new J,r=new z(t),o=r.toString("utf8",4);if(o!=="DIRC")throw new F(`Invalid dircache magic file number: ${o}`);const c=await Ft(t.slice(0,-20)),f=t.slice(-20).toString("hex");if(f!==c)throw new F(`Invalid checksum in GitIndex buffer: expected ${f} but saw ${c}`);const s=r.readUInt32BE();if(s!==2)throw new F(`Unsupported dircache version: ${s}`);const h=r.readUInt32BE();let y=0;for(;!r.eof()&&y<h;){const d={};d.ctimeSeconds=r.readUInt32BE(),d.ctimeNanoseconds=r.readUInt32BE(),d.mtimeSeconds=r.readUInt32BE(),d.mtimeNanoseconds=r.readUInt32BE(),d.dev=r.readUInt32BE(),d.ino=r.readUInt32BE(),d.mode=r.readUInt32BE(),d.uid=r.readUInt32BE(),d.gid=r.readUInt32BE(),d.size=r.readUInt32BE(),d.oid=r.slice(20).toString("hex");const w=r.readUInt16BE();d.flags=sa(w);const b=t.indexOf(0,r.tell()+1)-r.tell();if(b<1)throw new F(`Got a path length of: ${b}`);if(d.path=r.toString("utf8",b),d.path.includes("..\\")||d.path.includes("../"))throw new ht(d.path);let v=8-(r.tell()-12)%8;for(v===0&&(v=8);v--;){const _=r.readUInt8();if(_!==0)throw new F(`Expected 1-8 null characters but got '${_}' after ${d.path}`);if(r.eof())throw new F("Unexpected end of file")}d.stages=[],e._addEntry(d),y++}return e}get unmergedPaths(){return[...this._unmergedPaths]}get entries(){return[...this._entries.values()].sort(mr)}get entriesMap(){return this._entries}get entriesFlat(){return[...this.entries].flatMap(t=>t.stages.length>1?t.stages.filter(e=>e):t)}*[Symbol.iterator](){for(const t of this.entries)yield t}insert({filepath:t,stats:e,oid:r,stage:o=0}){e||(e={ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,mode:0,uid:0,gid:0,size:0}),e=sr(e);const c=Buffer.from(t),f={ctimeSeconds:e.ctimeSeconds,ctimeNanoseconds:e.ctimeNanoseconds,mtimeSeconds:e.mtimeSeconds,mtimeNanoseconds:e.mtimeNanoseconds,dev:e.dev,ino:e.ino,mode:e.mode||33188,uid:e.uid,gid:e.gid,size:e.size,path:t,oid:r,flags:{assumeValid:!1,extended:!1,stage:o,nameLength:c.length<4095?c.length:4095},stages:[]};this._addEntry(f),this._dirty=!0}delete({filepath:t}){if(this._entries.has(t))this._entries.delete(t);else for(const e of this._entries.keys())e.startsWith(t+"/")&&this._entries.delete(e);this._unmergedPaths.has(t)&&this._unmergedPaths.delete(t),this._dirty=!0}clear(){this._entries.clear(),this._dirty=!0}has({filepath:t}){return this._entries.has(t)}render(){return this.entries.map(t=>`${t.mode.toString(8)} ${t.oid} ${t.path}`).join(`
|
|
50
|
+
`)}static async _entryToBuffer(t){const e=Buffer.from(t.path),r=Math.ceil((62+e.length+1)/8)*8,o=Buffer.alloc(r),c=new z(o),f=sr(t);return c.writeUInt32BE(f.ctimeSeconds),c.writeUInt32BE(f.ctimeNanoseconds),c.writeUInt32BE(f.mtimeSeconds),c.writeUInt32BE(f.mtimeNanoseconds),c.writeUInt32BE(f.dev),c.writeUInt32BE(f.ino),c.writeUInt32BE(f.mode),c.writeUInt32BE(f.uid),c.writeUInt32BE(f.gid),c.writeUInt32BE(f.size),c.write(t.oid,20,"hex"),c.writeUInt16BE(ca(t)),c.write(t.path,e.length,"utf8"),o}async toObject(){const t=Buffer.alloc(12),e=new z(t);e.write("DIRC",4,"utf8"),e.writeUInt32BE(2),e.writeUInt32BE(this.entriesFlat.length);let r=[];for(const s of this.entries)if(r.push(J._entryToBuffer(s)),s.stages.length>1)for(const h of s.stages)h&&h!==s&&r.push(J._entryToBuffer(h));r=await Promise.all(r);const o=Buffer.concat(r),c=Buffer.concat([t,o]),f=await Ft(c);return Buffer.concat([c,Buffer.from(f,"hex")])}}async function Cr(n,t){const e=yr(n);for(;;){const{value:r,done:o}=await e.next();if(r&&await t(r),o)break}e.return&&e.return()}async function ut(n){let t=0;const e=[];await Cr(n,c=>{e.push(c),t+=c.byteLength});const r=new Uint8Array(t);let o=0;for(const c of e)r.set(c,o),o+=c.byteLength;return r}class se{constructor(){this._queue=[]}write(t){if(this._ended)throw Error("You cannot write to a FIFO that has already been ended!");if(this._waiting){const e=this._waiting;this._waiting=null,e({value:t})}else this._queue.push(t)}end(){if(this._ended=!0,this._waiting){const t=this._waiting;this._waiting=null,t({done:!0})}}destroy(t){this.error=t,this.end()}async next(){if(this._queue.length>0)return{value:this._queue.shift()};if(this._ended)return{done:!0};if(this._waiting)throw Error("You cannot call read until the previous call to read has returned!");return new Promise(t=>{this._waiting=t})}}class fa{static demux(t){const e=D.streamReader(t),r=new se,o=new se,c=new se,f=async function(){const s=await e();if(s===null)return f();if(s===!0){r.end(),c.end(),t.error?o.destroy(t.error):o.end();return}switch(s[0]){case 1:{o.write(s.slice(1));break}case 2:{c.write(s.slice(1));break}case 3:{const h=s.slice(1);c.write(h),r.end(),c.end(),o.destroy(new Error(h.toString("utf8")));return}default:r.write(s)}f()};return f(),{packetlines:r,packfile:o,progress:c}}}async function Nr(n){const{packetlines:t,packfile:e,progress:r}=fa.demux(n),o=[],c=[],f=[];let s=!1,h=!1;return new Promise((y,d)=>{Cr(t,w=>{const b=w.toString("utf8").trim();if(b.startsWith("shallow")){const v=b.slice(-41).trim();v.length!==40&&d(new ft(v)),o.push(v)}else if(b.startsWith("unshallow")){const v=b.slice(-41).trim();v.length!==40&&d(new ft(v)),c.push(v)}else if(b.startsWith("ACK")){const[,v,_]=b.split(" ");f.push({oid:v,status:_}),_||(h=!0)}else b.startsWith("NAK")?(s=!0,h=!0):(h=!0,s=!0);h&&(n.error?d(n.error):y({shallows:o,unshallows:c,acks:f,nak:s,packfile:e,progress:r}))}).finally(()=>{h||(n.error?d(n.error):y({shallows:o,unshallows:c,acks:f,nak:s,packfile:e,progress:r}))})})}typeof globalThis.Buffer>"u"&&(globalThis.Buffer=ye.Buffer);class Tt extends Error{constructor(t,e){super(`Authentication required to access private repository: ${t}`),this.name="GitAuthenticationError",this.repoUrl=t,this.status=e}}async function ua(n,t,e,r){const o=(r==null?void 0:r.additionalHeaders)||{},c=await qr(n,t,o),f=await wa(c.idx,t,e),s=e.map(v=>f[v].oid),h=s.length>0?await ga(n,s,o):null,y={};if(await Promise.all(e.map(async v=>{h&&(y[v]=await Gr(h.idx,f[v].oid))})),!(r!=null&&r.withObjects))return{files:y};const d=[],w=await c.idx.toBuffer();if(d.push({name:`pack-${c.idx.packfileSha}`,pack:c.packfile,index:lt(w),promisor:c.promisor}),h){const v=await h.idx.toBuffer();d.push({name:`pack-${h.idx.packfileSha}`,pack:h.packfile,index:lt(v),promisor:h.promisor})}const b={};for(const v of e)b[v]=f[v].oid;return{files:y,packfiles:d,objects:[...await cr(c),...await cr(h)],fileOids:b}}const la=/^[0-9a-f]{40}$/i;async function ha(n,t,e={}){const r=await qr(n,t,e),o=await ya(r.idx,t);return o!=null&&o.object?Mr(o):[]}async function pa(n,t,e={}){const r=await da(n,t);if(r.resolvedOid)return r.resolvedOid;const o=await he(n,r.refname,e);if(!o)throw new Error(`Git ref "${r.refname}" not found at ${n}`);return o}function Mr(n){return n.object.map(t=>{if(t.type==="blob")return{name:t.path,type:"file"};if(t.type==="tree"&&t.object)return{name:t.path,type:"folder",children:Mr(t)}}).filter(t=>!!(t!=null&&t.name))}async function Lr(n,t,e={}){const r=Buffer.from(await ut([D.encode(`command=ls-refs
|
|
51
51
|
`),D.encode(`agent=git/2.37.3
|
|
52
52
|
`),D.encode(`object-format=sha1
|
|
53
53
|
`),D.delim(),D.encode(`peel
|
|
54
54
|
`),D.encode(`ref-prefix ${t}
|
|
55
|
-
`),D.flush()])),o=await fetch(n+"/git-upload-pack",{method:"POST",headers:{Accept:"application/x-git-upload-pack-advertisement","content-type":"application/x-git-upload-pack-request","Content-Length":`${r.length}`,"Git-Protocol":"version=2",...e},body:r});if(!o.ok)throw o.status===401||o.status===403?new Tt(n,o.status):new Error(`Failed to fetch git refs from ${n}: ${o.status} ${o.statusText}`);const c={};for await(const f of
|
|
55
|
+
`),D.flush()])),o=await fetch(n+"/git-upload-pack",{method:"POST",headers:{Accept:"application/x-git-upload-pack-advertisement","content-type":"application/x-git-upload-pack-request","Content-Length":`${r.length}`,"Git-Protocol":"version=2",...e},body:r});if(!o.ok)throw o.status===401||o.status===403?new Tt(n,o.status):new Error(`Failed to fetch git refs from ${n}: ${o.status} ${o.statusText}`);const c={};for await(const f of ma(o)){const s=f.indexOf(" "),h=f.slice(0,s),d=f.slice(s+1,f.length-1).split(" ")[0];c[d]=h}return c}async function da(n,t){switch(t.type??"infer"){case"commit":return{kind:"commit",refname:t.value,resolvedOid:t.value};case"branch":return{kind:"refname",refname:`refs/heads/${t.value.trim()}`};case"tag":return{kind:"refname",refname:`refs/tags/${t.value.trim()}`};case"refname":return{kind:"refname",refname:t.value.trim()};case"infer":{const r=t.value.trim();if(r===""||r==="HEAD")return{kind:"refname",refname:"HEAD"};if(r.startsWith("refs/"))return{kind:"refname",refname:r};if(la.test(r))return{kind:"commit",refname:r,resolvedOid:r};const o=`refs/heads/${r}`,c=await he(n,o);if(c)return{kind:"refname",refname:o,resolvedOid:c};const f=`refs/tags/${r}`,s=await he(n,f);if(s)return{kind:"refname",refname:f,resolvedOid:s};throw new Error(`Git ref "${t.value}" not found at ${n}`)}default:throw new Error(`Invalid ref type: ${t.type}`)}}async function he(n,t,e){const r=await Lr(n,t,e),o=[t,`${t}^{}`];for(const c of o){const f=c.trim();if(f in r)return r[f]}return null}async function qr(n,t,e){const r=Buffer.from(await ut([D.encode(`want ${t} multi_ack_detailed no-done side-band-64k thin-pack ofs-delta agent=git/2.37.3 filter
|
|
56
56
|
`),D.encode(`filter blob:none
|
|
57
57
|
`),D.encode(`shallow ${t}
|
|
58
58
|
`),D.encode(`deepen 1
|
|
59
59
|
`),D.flush(),D.encode(`done
|
|
60
60
|
`),D.encode(`done
|
|
61
|
-
`)])),o=await fetch(n+"/git-upload-pack",{method:"POST",headers:{Accept:"application/x-git-upload-pack-advertisement","content-type":"application/x-git-upload-pack-request","Content-Length":`${r.length}`,...e},body:r});if(!o.ok)throw o.status===401||o.status===403?new Tt(n,o.status):new Error(`Failed to fetch git objects from ${n}: ${o.status} ${o.statusText}`);const c=
|
|
61
|
+
`)])),o=await fetch(n+"/git-upload-pack",{method:"POST",headers:{Accept:"application/x-git-upload-pack-advertisement","content-type":"application/x-git-upload-pack-request","Content-Length":`${r.length}`,...e},body:r});if(!o.ok)throw o.status===401||o.status===403?new Tt(n,o.status):new Error(`Failed to fetch git objects from ${n}: ${o.status} ${o.statusText}`);const c=Hr(o.body),f=await Nr(c),s=Buffer.from(await ut(f.packfile)),h=await it.fromPack({pack:s}),y=h.read;return h.read=async function({oid:d,...w}){const b=await y.call(this,{oid:d,...w});return b.oid=d,b},{idx:h,packfile:lt(s),promisor:!0}}async function ya(n,t){const e=await n.read({oid:t});X(e);const r=await n.read({oid:e.object.tree}),o=[r];for(;o.length>0;){const c=o.pop(),f=await n.read({oid:c.oid});if(X(f),c.object=f.object,f.type==="tree")for(const s of f.object)s.type==="tree"&&o.push(s)}return r}async function cr(n){if(!n)return[];const t=[],e=new Set;for(const r of n.idx.hashes??[]){if(e.has(r))continue;const o=n.idx.offsets.get(r);if(o===void 0)continue;const{type:c,object:f}=await n.idx.readSlice({start:o});c==="ofs_delta"||c==="ref_delta"||f&&(e.add(r),t.push({oid:r,type:c,body:lt(f)}))}return t}async function wa(n,t,e){const r=await n.read({oid:t});X(r);const o=await n.read({oid:r.object.tree});X(o);const c={};for(const f of e){let s=o;const h=f.split("/");for(const y of h){if(s.type!=="tree")throw new Error(`Path not found in the repo: ${f}`);let d=!1;for(const w of s.object)if(w.path===y){try{s=await n.read({oid:w.oid}),X(s)}catch{s=w}d=!0;break}if(!d)throw new Error(`Path not found in the repo: ${f}`)}c[f]=s}return c}async function ga(n,t,e){const r=Buffer.from(await ut([...t.map(y=>D.encode(`want ${y} multi_ack_detailed no-done side-band-64k thin-pack ofs-delta agent=git/2.37.3
|
|
62
62
|
`)),D.flush(),D.encode(`done
|
|
63
|
-
`)])),o=await fetch(n+"/git-upload-pack",{method:"POST",headers:{Accept:"application/x-git-upload-pack-advertisement","content-type":"application/x-git-upload-pack-request","Content-Length":`${r.length}`,...e},body:r});if(!o.ok)throw o.status===401||o.status===403?new Tt(n,o.status):new Error(`Failed to fetch git objects from ${n}: ${o.status} ${o.statusText}`);const c=
|
|
63
|
+
`)])),o=await fetch(n+"/git-upload-pack",{method:"POST",headers:{Accept:"application/x-git-upload-pack-advertisement","content-type":"application/x-git-upload-pack-request","Content-Length":`${r.length}`,...e},body:r});if(!o.ok)throw o.status===401||o.status===403?new Tt(n,o.status):new Error(`Failed to fetch git objects from ${n}: ${o.status} ${o.statusText}`);const c=Hr(o.body),f=await Nr(c),s=Buffer.from(await ut(f.packfile));return s.byteLength===0?{idx:await it.fromPack({pack:s}),packfile:new Uint8Array,promisor:!1}:{idx:await it.fromPack({pack:s}),packfile:lt(s),promisor:!1}}async function Gr(n,t){const e=await n.read({oid:t});if(X(e),e.type==="blob")return e.object;const r={};for(const{path:o,oid:c,type:f}of e.object)if(f==="blob"){const s=await n.read({oid:c});X(s),r[o]=s.object}else f==="tree"&&(r[o]=await Gr(n,c));return r}function X(n){if(n.object instanceof Buffer)switch(n.type){case"commit":n.object=M.from(n.object).parse();break;case"tree":n.object=de.from(n.object).entries();break;case"blob":n.object=new Uint8Array(n.object),n.format="content";break;case"tag":n.object=st.from(n.object).parse();break;default:throw new kt(n.oid,n.type,"blob|commit|tag|tree")}}async function*ma(n){const t=await n.text();let e=0;for(;e<=t.length;){const r=parseInt(t.substring(e,e+4),16);if(r===0)break;yield t.substring(e+4,e+r),e+=r}}function Hr(n){if(n[Symbol.asyncIterator])return n;const t=n.getReader();return{next(){return t.read()},return(){return t.releaseLock(),{}},[Symbol.asyncIterator](){return this}}}function lt(n){return n instanceof Uint8Array,Uint8Array.from(n)}const ba=pe.deflate,va=/^[0-9a-f]{40}$/i;async function Ea(n){const t={},e=new TextEncoder;return await Promise.all(n.map(async({oid:r,type:o,body:c})=>{if(!r||c.length===0)return;const f=e.encode(`${o} ${c.length}\0`),s=new Uint8Array(f.length+c.length);s.set(f,0),s.set(c,f.length);const h=await ba(s),y=r.slice(0,2),d=r.slice(2);t[`.git/objects/${y}/${d}`]=h})),t}function xa(n,t,e){const r=(n==null?void 0:n.trim())??"";let o=null;switch(t){case"branch":r&&(o=`refs/heads/${r}`);break;case"refname":o=r||null;break;case"tag":r.startsWith("refs/")?o=r:r&&(o=`refs/tags/${r}`);break;case"commit":o=null;break;default:r.startsWith("refs/")?o=r:va.test(r)?o=null:r&&r!=="HEAD"&&(o=`refs/heads/${r}`);break}const c=o?`ref: ${o}
|
|
64
64
|
`:`${e}
|
|
65
|
-
`,f=o&&o.startsWith("refs/heads/")?o:void 0,s=f==null?void 0:f.slice(11),h=o&&o.startsWith("refs/tags/")?o:void 0,y=h==null?void 0:h.slice(10);return{headContent:c,branchName:s,branchRef:f,tagName:y}}function
|
|
65
|
+
`,f=o&&o.startsWith("refs/heads/")?o:void 0,s=f==null?void 0:f.slice(11),h=o&&o.startsWith("refs/tags/")?o:void 0,y=h==null?void 0:h.slice(10);return{headContent:c,branchName:s,branchRef:f,tagName:y}}function Aa(n,{branchName:t,partialCloneFilter:e}){const o=["[core]",` repositoryformatversion = ${e?1:0}`," filemode = true"," bare = false"," logallrefupdates = true"," ignorecase = true"," precomposeunicode = true",'[remote "origin"]',` url = ${n}`," fetch = +refs/heads/*:refs/remotes/origin/*"," fetch = +refs/tags/*:refs/tags/*"];return e&&(o.push(" promisor = true"),o.push(` partialclonefilter = ${e}`),o.push("[extensions]"),o.push(" partialclone = origin")),t&&o.push(`[branch "${t}"]`," remote = origin",` merge = refs/heads/${t}`),o.join(`
|
|
66
66
|
`)+`
|
|
67
|
-
`}async function
|
|
67
|
+
`}async function Ba({repoUrl:n,commitHash:t,ref:e,refType:r,objects:o,fileOids:c,pathPrefix:f}){const s={},h=xa(e,r,t);s[".git/HEAD"]=h.headContent,s[".git/config"]=Aa(n,{branchName:h.branchName}),s[".git/description"]=`WordPress Playground clone
|
|
68
68
|
`,s[".git/shallow"]=`${t}
|
|
69
69
|
`,s[".git/refs/heads/.gitkeep"]="",s[".git/refs/tags/.gitkeep"]="",s[".git/refs/remotes/.gitkeep"]="",h.branchRef&&h.branchName&&(s[".git/logs/HEAD"]=`ref: ${h.branchRef}
|
|
70
70
|
`,s[`.git/${h.branchRef}`]=`${t}
|
|
71
71
|
`,s[`.git/refs/remotes/origin/${h.branchName}`]=`${t}
|
|
72
72
|
`,s[".git/refs/remotes/origin/HEAD"]=`ref: refs/remotes/origin/${h.branchName}
|
|
73
73
|
`),h.tagName&&(s[`.git/refs/tags/${h.tagName}`]=`${t}
|
|
74
|
-
`),Object.assign(s,await ba(o));const y=new J;for(const[w,b]of Object.entries(c)){const v=w.substring(f.length).replace(/^\/+/,"");y.insert({filepath:v,oid:b,stats:{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,mode:33188,uid:0,gid:0,size:0}})}const d=await y.toObject();return s[".git/index"]=Uint8Array.from(d),s}function Aa(n,t){t=rt.normalizePath(t);const e=["",".","/"].includes(t);let r=n;if(e)t="";else{const f=t.split("/");for(const s of f){const h=r==null?void 0:r.find(y=>y.name===s);if((h==null?void 0:h.type)==="folder")r=h.children;else return h?[h.name]:[]}}const o=[],c=[{tree:r,path:t}];for(;c.length>0;){const{tree:f,path:s}=c.pop();for(const h of f){const y=`${s}${s?"/":""}${h.name}`;h.type==="folder"?c.push({tree:h.children,path:y}):o.push(y)}}return o}function Ba(n,t){return n.startsWith(t)?n.substring(t.length):n}async function Sa(n,t){await t.clear();const e=async r=>{const o=await n.listFiles(r);for(const c of o){const f=r==="/"?`/${c}`:`${r}/${c}`;if(await n.isDir(f))await t.mkdir(f),await e(f);else{const s=await n.read(f),h=new Uint8Array(await s.arrayBuffer());await t.writeFile(f,h)}}};await e("/")}class Fa extends EventTarget{constructor(t){super(),this.encoder=new TextEncoder,this.decoder=new TextDecoder,this.backend=t}async isDir(t){return this.backend.isDir(t)}async fileExists(t){return this.backend.fileExists(t)}async read(t){return this.backend.read(t)}async readFileAsText(t){const r=await(await this.read(t)).arrayBuffer();return this.decoder.decode(r)}async listFiles(t){return this.backend.listFiles(t)}async writeFile(t,e){const r=typeof e=="string"?this.encoder.encode(e):e;await this.backend.writeFile(t,r),this.dispatchEvent(new Event("change"))}async mkdir(t,e){await this.backend.mkdir(t,(e==null?void 0:e.recursive)??!1),this.dispatchEvent(new Event("change"))}async rmdir(t,e){await this.backend.rmdir(t,(e==null?void 0:e.recursive)??!1),this.dispatchEvent(new Event("change"))}async mv(t,e){t!==e&&(await this.backend.mv(t,e),this.dispatchEvent(new Event("change")))}async unlink(t){await this.backend.unlink(t),this.dispatchEvent(new Event("change"))}async clear(){await this.backend.clear(),this.dispatchEvent(new Event("change"))}}class Ia{constructor(t){this.fileTree=t}async read(t){let e=this.getEntryAtPath(t);if(typeof e=="string")e=new TextEncoder().encode(e);else if(!(e instanceof Uint8Array))throw new Error(`Unsupported content type: ${typeof e}`);const r=new ReadableStream({start(o){o.enqueue(e),o.close()}});return new K.StreamedFile(r,t,{filesize:e.byteLength})}getEntryAtPath(t){let e=t.replace(/^\//,""),r=this.fileTree;for(;e;){if(r[e])return r[e];const o=e.split("/"),c=o.shift();if(!c||!r[c])break;r=r[c],e=o.join("/")}throw new Error(`File not found at ${t}`)}}class It{constructor(t){this.entries=new Map,this.zipReader=t}static fromStream(t){const e=new at.ZipReader(new at.BlobReader(new K.StreamedFile(t,"archive.zip")));return new It(e)}static fromArrayBuffer(t){const e=new at.ZipReader(new at.BlobReader(new Blob([t])));return new It(e)}async read(t){const e=await this.getEntry(t),r=await e.getData(new at.BlobWriter);return new K.StreamedFile(r.stream(),t,{filesize:e.uncompressedSize})}async getEntry(t){const r=(await this.getEntries()).get(t.replace(/^\//,""));if(!r)throw new Error(`File ${t} not found in the zip.`);return r}async getEntries(){if(this.entries.size===0){const t=await this.zipReader.getEntries();for(const e of t)this.entries.set(e.filename,e)}return this.entries}}class _a{constructor(t){if(!t.length)throw new Error("OverlayFilesystem requires at least one filesystem");this.filesystems=t}async read(t){const e=[];for(const o of this.filesystems)try{return await o.read(t)}catch(c){e.push(c instanceof Error?c:new Error(String(c)))}const r=e.map(o=>o.message).join("; ");throw new Error(`Failed to read ${t} from any filesystem: ${r}`,{cause:e})}}class $a{constructor(t){if(this.baseUrl="",this.options=t,this.isDataUrl=t.baseUrl.startsWith("data:"),this.isDataUrl)return;const e=new URL("./",t.baseUrl);if(e.protocol!=="http:"&&e.protocol!=="https:")throw new Error("Unsupported protocol: "+e.protocol+". Only HTTP and HTTPS are supported.");this.baseUrl=e.origin+e.pathname}async read(t){if(this.isDataUrl)throw new Error("FetchFilesystem cannot fetch files from data URLs");t=rt.normalizePath(t);const e=t.replace(/^\//,""),r=new URL(e,this.baseUrl).toString();if(!r.startsWith(this.baseUrl))throw new Error(`Refused to read a file outside of the base URL: ${r}`);const o=this.options.corsProxy?`${this.options.corsProxy}${encodeURIComponent(r)}`:r,c=await fetch(o);if(!c.ok)throw new Error(`Failed to fetch file at ${t}: ${c.statusText}`);const f=c.headers.get("content-length")?parseInt(c.headers.get("content-length"),10):void 0;return new K.StreamedFile(c.body,t,{filesize:f})}}class Ua{constructor(t){this.root=t}async ensureNodeModules(){if(!this.fs||!this.path){try{this.fs=await import("fs"),this.path=await import("path")}catch{this.fs=require("fs"),this.path=require("path")}this.root=this.path.resolve(this.root)+this.path.sep}}async read(t){if(await this.ensureNodeModules(),t=this.path.resolve(this.root,this.path.normalize(t.replace(/^\//,""))),!t.startsWith(this.root))throw new Error(`Refused to read a file outside of the root directory: ${t}`);return new Promise((e,r)=>{const o=this.path.resolve(t),c=this.fs.createReadStream(o);c.on("error",f=>{r(new Error(`Failed to read file at ${t}: ${f.message}`))}),this.fs.stat(o,(f,s)=>{f?r(new Error(`Failed to read file at ${t}: ${f.message}`)):e(new K.StreamedFile(Pa(c),t,{filesize:s.size}))})})}}function Pa(n){return new ReadableStream({start(e){n.on("data",r=>e.enqueue(r)),n.on("end",()=>e.close())}})}class _t{constructor(t){this.opfsRoot=t}static fromDirectoryHandle(t){return new _t(t)}static async fromPath(t,e=!1){if(typeof navigator>"u")throw new Error("OPFS not available: navigator is undefined");if(!navigator.storage||!navigator.storage.getDirectory)throw new Error("OPFS not available: storage API not supported");let r=await navigator.storage.getDirectory();const o=t.split("/").filter(Boolean);for(const c of o)r=await r.getDirectoryHandle(c,{create:e});return new _t(r)}async clear(){for await(const[t]of this.opfsRoot.entries())try{await this.opfsRoot.removeEntry(t,{recursive:!0})}catch{}}async read(t){const e=await this.readFileAsBuffer(t),r=new ReadableStream({start(o){o.enqueue(e),o.close()}});return new K.StreamedFile(r,t,{filesize:e.byteLength})}async isDir(t){if(t==="/")return!0;try{const e=t.split("/").filter(Boolean);let r=this.opfsRoot;for(const o of e)r=await r.getDirectoryHandle(o);return!0}catch{return!1}}async fileExists(t){const e=t.split("/").filter(Boolean);if(e.length===0)return!0;const r=e.pop();try{let o=this.opfsRoot;for(const c of e)o=await o.getDirectoryHandle(c);try{return await o.getFileHandle(r),!0}catch{return await o.getDirectoryHandle(r),!0}}catch{return!1}}async listFiles(t){let e=this.opfsRoot;if(t!=="/"){const o=t.split("/").filter(Boolean);for(const c of o)e=await e.getDirectoryHandle(c)}const r=[];for await(const[o]of e.entries())r.push(o);return r}async writeFile(t,e){const r=t.split("/").filter(Boolean),o=r.pop();if(!o)throw new Error(`Invalid file path: ${t}`);let c=this.opfsRoot;for(const h of r)c=await c.getDirectoryHandle(h);const s=await(await c.getFileHandle(o,{create:!0})).createWritable();await s.write(e),await s.close()}async mkdir(t,e=!1){const r=t.split("/").filter(Boolean);let o=this.opfsRoot;for(let c=0;c<r.length;c++){const f=r[c],s=c===r.length-1;o=await o.getDirectoryHandle(f,{create:e||s})}}async rmdir(t,e){const r=t.split("/").filter(Boolean),o=r.pop();if(!o)return;let c=this.opfsRoot;for(const f of r)c=await c.getDirectoryHandle(f);await c.removeEntry(o,{recursive:e})}async mv(t,e){if(await this.isDir(t))await this.copyDir(t,e),await this.rmdir(t,!0);else{const o=await this.readFileAsBuffer(t);await this.writeFile(e,o),await this.unlink(t)}}async unlink(t){const e=t.split("/").filter(Boolean),r=e.pop();if(!r)return;let o=this.opfsRoot;for(const c of e)o=await o.getDirectoryHandle(c);try{await o.removeEntry(r)}catch{}}async readFileAsBuffer(t){const e=t.split("/").filter(Boolean),r=e.pop();if(!r)throw new Error(`Invalid file path: ${t}`);let o=this.opfsRoot;for(const s of e)o=await o.getDirectoryHandle(s);const f=await(await o.getFileHandle(r)).getFile();return new Uint8Array(await f.arrayBuffer())}async copyDir(t,e){await this.mkdir(e);const r=await this.listFiles(t);for(const o of r){const c=t==="/"?`/${o}`:`${t}/${o}`,f=e==="/"?`/${o}`:`${e}/${o}`;if(await this.isDir(c))await this.copyDir(c,f);else{const s=await this.readFileAsBuffer(c);await this.writeFile(f,s)}}}}class ka{constructor(t={}){this.root={type:"dir",children:{}};for(const[e,r]of Object.entries(t))this.writeFileSync(e,r)}async read(t){const r=this.getFile(t).content,o=new ReadableStream({start(c){c.enqueue(r),c.close()}});return new K.StreamedFile(o,t,{filesize:r.byteLength})}async isDir(t){const e=this.getNode(t);return!!e&&e.type==="dir"}async fileExists(t){return!!this.getNode(t)}async listFiles(t){const e=this.getNode(t);return!e||e.type!=="dir"?[]:Object.keys(e.children)}async writeFile(t,e){this.writeFileSync(t,e)}async mkdir(t,e=!1){if(t==="/")return;const{parent:r,name:o}=e?this.getOrCreateParent(t):this.getParent(t);r.children[o]||(r.children[o]={type:"dir",children:{}})}async rmdir(t,e){const{parent:r,name:o}=this.getParent(t),c=r.children[o];if(!(!c||c.type!=="dir")){if(!e&&Object.keys(c.children).length>0)throw new Error("Directory not empty");delete r.children[o]}}async mv(t,e){const{parent:r,name:o}=this.getParent(t),c=r.children[o];if(!c)throw new Error(`Source not found: ${t}`);const{parent:f,name:s}=this.getParent(e);f.children[s]=c,delete r.children[o]}async unlink(t){const{parent:e,name:r}=this.getParent(t),o=e.children[r];o&&o.type==="file"&&delete e.children[r]}async clear(){this.root={type:"dir",children:{}}}writeFileSync(t,e){const{parent:r,name:o}=this.getParent(t);r.children[o]={type:"file",content:new Uint8Array(e)}}getNode(t){if(t==="/")return this.root;const e=t.split("/").filter(Boolean);let r=this.root;for(const o of e){if(r.type!=="dir")return;const c=r.children[o];if(!c)return;r=c}return r}getDir(t){const e=this.getNode(t);if(!e||e.type!=="dir")throw new Error(`Directory not found: ${t}`);return e}getFile(t){const e=this.getNode(t);if(!e||e.type!=="file")throw new Error(`File not found: ${t}`);return e}getParent(t){const e=t.split("/").filter(Boolean),r=e.pop();if(!r)throw new Error(`Invalid path: ${t}`);const o=e.length?`/${e.join("/")}`:"/",c=this.getNode(o);if(!c||c.type!=="dir")throw new Error(`Parent directory not found: ${o}`);return{parent:c,name:r}}getOrCreateParent(t){const e=t.split("/").filter(Boolean),r=e.pop();if(!r)throw new Error(`Invalid path: ${t}`);const o=e.length?`/${e.join("/")}`:"/";return{parent:this.ensureDir(o),name:r}}ensureDir(t){if(t==="/")return this.root;const e=t.split("/").filter(Boolean);let r=this.root;for(const o of e){const c=r.children[o];if(!c){const f={type:"dir",children:{}};r.children[o]=f,r=f;continue}if(c.type!=="dir")throw new Error(`Path segment "${o}" is not a directory in ${t}`);r=c}return r}}exports.EventedFilesystem=Fa;exports.FetchFilesystem=$a;exports.GitAuthenticationError=Tt;exports.InMemoryFilesystem=Ia;exports.InMemoryFilesystemBackend=ka;exports.NodeJsFilesystem=Ua;exports.OpfsFilesystemBackend=_t;exports.OverlayFilesystem=_a;exports.ZipFilesystem=It;exports.changeset=In;exports.clearContentsFromMountDevice=Un;exports.copyFilesystem=Sa;exports.createClient=dn;exports.createCommit=An;exports.createDotGitDirectory=xa;exports.createOrUpdateBranch=En;exports.createTree=Bn;exports.createTreeNode=se;exports.createTreeNodes=cr;exports.deleteFile=ur;exports.directoryHandleFromMountDevice=lr;exports.directoryHandleToOpfsPath=$n;exports.filesListToObject=yn;exports.fork=xn;exports.getArtifact=bn;exports.getFilesFromDirectory=sr;exports.iterateFiles=Fn;exports.listDescendantFiles=Aa;exports.listGitFiles=ua;exports.listGitRefs=Nr;exports.mayPush=vn;exports.opfsPathToDirectoryHandle=hr;exports.removePathPrefix=Ba;exports.resolveCommitHash=la;exports.sparseCheckout=ca;
|
|
74
|
+
`),Object.assign(s,await Ea(o));const y=new J;for(const[w,b]of Object.entries(c)){const v=w.substring(f.length).replace(/^\/+/,"");y.insert({filepath:v,oid:b,stats:{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,mode:33188,uid:0,gid:0,size:0}})}const d=await y.toObject();return s[".git/index"]=Uint8Array.from(d),s}function Sa(n,t){t=rt.normalizePath(t);const e=["",".","/"].includes(t);let r=n;if(e)t="";else{const f=t.split("/");for(const s of f){const h=r==null?void 0:r.find(y=>y.name===s);if((h==null?void 0:h.type)==="folder")r=h.children;else return h?[h.name]:[]}}const o=[],c=[{tree:r,path:t}];for(;c.length>0;){const{tree:f,path:s}=c.pop();for(const h of f){const y=`${s}${s?"/":""}${h.name}`;h.type==="folder"?c.push({tree:h.children,path:y}):o.push(y)}}return o}function Fa(n,t){return n.startsWith(t)?n.substring(t.length):n}async function Ia(n,t){await t.clear();const e=async r=>{const o=await n.listFiles(r);for(const c of o){const f=r==="/"?`/${c}`:`${r}/${c}`;if(await n.isDir(f))await t.mkdir(f),await e(f);else{const s=await n.read(f),h=new Uint8Array(await s.arrayBuffer());await t.writeFile(f,h)}}};await e("/")}class _a extends EventTarget{constructor(t){super(),this.encoder=new TextEncoder,this.decoder=new TextDecoder,this.backend=t}async isDir(t){return this.backend.isDir(t)}async fileExists(t){return this.backend.fileExists(t)}async read(t){return this.backend.read(t)}async readFileAsText(t){const r=await(await this.read(t)).arrayBuffer();return this.decoder.decode(r)}async listFiles(t){return this.backend.listFiles(t)}async writeFile(t,e){const r=typeof e=="string"?this.encoder.encode(e):e;await this.backend.writeFile(t,r),this.dispatchEvent(new Event("change"))}async mkdir(t,e){await this.backend.mkdir(t,(e==null?void 0:e.recursive)??!1),this.dispatchEvent(new Event("change"))}async rmdir(t,e){await this.backend.rmdir(t,(e==null?void 0:e.recursive)??!1),this.dispatchEvent(new Event("change"))}async mv(t,e){t!==e&&(await this.backend.mv(t,e),this.dispatchEvent(new Event("change")))}async unlink(t){await this.backend.unlink(t),this.dispatchEvent(new Event("change"))}async clear(){await this.backend.clear(),this.dispatchEvent(new Event("change"))}}class $a{constructor(t){this.fileTree=t}async read(t){let e=this.getEntryAtPath(t);if(typeof e=="string")e=new TextEncoder().encode(e);else if(!(e instanceof Uint8Array))throw new Error(`Unsupported content type: ${typeof e}`);const r=new ReadableStream({start(o){o.enqueue(e),o.close()}});return new K.StreamedFile(r,t,{filesize:e.byteLength})}getEntryAtPath(t){let e=t.replace(/^\//,""),r=this.fileTree;for(;e;){if(r[e])return r[e];const o=e.split("/"),c=o.shift();if(!c||!r[c])break;r=r[c],e=o.join("/")}throw new Error(`File not found at ${t}`)}}class It{constructor(t){this.entries=new Map,this.zipReader=t}static fromStream(t){const e=new at.ZipReader(new at.BlobReader(new K.StreamedFile(t,"archive.zip")));return new It(e)}static fromArrayBuffer(t){const e=new at.ZipReader(new at.BlobReader(new Blob([t])));return new It(e)}async read(t){const e=await this.getEntry(t),r=await e.getData(new at.BlobWriter);return new K.StreamedFile(r.stream(),t,{filesize:e.uncompressedSize})}async getEntry(t){const r=(await this.getEntries()).get(t.replace(/^\//,""));if(!r)throw new Error(`File ${t} not found in the zip.`);return r}async getEntries(){if(this.entries.size===0){const t=await this.zipReader.getEntries();for(const e of t)this.entries.set(e.filename,e)}return this.entries}}class Ua{constructor(t){if(!t.length)throw new Error("OverlayFilesystem requires at least one filesystem");this.filesystems=t}async read(t){const e=[];for(const o of this.filesystems)try{return await o.read(t)}catch(c){e.push(c instanceof Error?c:new Error(String(c)))}const r=e.map(o=>o.message).join("; ");throw new Error(`Failed to read ${t} from any filesystem: ${r}`,{cause:e})}}class Pa{constructor(t){if(this.baseUrl="",this.options=t,this.isDataUrl=t.baseUrl.startsWith("data:"),this.isDataUrl)return;const e=new URL("./",t.baseUrl);if(e.protocol!=="http:"&&e.protocol!=="https:")throw new Error("Unsupported protocol: "+e.protocol+". Only HTTP and HTTPS are supported.");this.baseUrl=e.origin+e.pathname}async read(t){if(this.isDataUrl)throw new Error("FetchFilesystem cannot fetch files from data URLs");t=rt.normalizePath(t);const e=t.replace(/^\//,""),r=new URL(e,this.baseUrl).toString();if(!r.startsWith(this.baseUrl))throw new Error(`Refused to read a file outside of the base URL: ${r}`);const o=this.options.corsProxy?`${this.options.corsProxy}${encodeURIComponent(r)}`:r,c=await fetch(o);if(!c.ok)throw new Error(`Failed to fetch file at ${t}: ${c.statusText}`);const f=c.headers.get("content-length")?parseInt(c.headers.get("content-length"),10):void 0;return new K.StreamedFile(c.body,t,{filesize:f})}}class ka{constructor(t){this.root=t}async ensureNodeModules(){if(!this.fs||!this.path){try{this.fs=await import("fs"),this.path=await import("path")}catch{this.fs=require("fs"),this.path=require("path")}this.root=this.path.resolve(this.root)+this.path.sep}}async read(t){if(await this.ensureNodeModules(),t=this.path.resolve(this.root,this.path.normalize(t.replace(/^\//,""))),!t.startsWith(this.root))throw new Error(`Refused to read a file outside of the root directory: ${t}`);return new Promise((e,r)=>{const o=this.path.resolve(t),c=this.fs.createReadStream(o);c.on("error",f=>{r(new Error(`Failed to read file at ${t}: ${f.message}`))}),this.fs.stat(o,(f,s)=>{f?r(new Error(`Failed to read file at ${t}: ${f.message}`)):e(new K.StreamedFile(Ta(c),t,{filesize:s.size}))})})}}function Ta(n){return new ReadableStream({start(e){n.on("data",r=>e.enqueue(r)),n.on("end",()=>e.close())}})}class _t{constructor(t){this.opfsRoot=t}static fromDirectoryHandle(t){return new _t(t)}static async fromPath(t,e=!1){if(typeof navigator>"u")throw new Error("OPFS not available: navigator is undefined");if(!navigator.storage||!navigator.storage.getDirectory)throw new Error("OPFS not available: storage API not supported");let r=await navigator.storage.getDirectory();const o=t.split("/").filter(Boolean);for(const c of o)r=await r.getDirectoryHandle(c,{create:e});return new _t(r)}async clear(){for await(const[t]of this.opfsRoot.entries())try{await this.opfsRoot.removeEntry(t,{recursive:!0})}catch{}}async read(t){const e=await this.readFileAsBuffer(t),r=new ReadableStream({start(o){o.enqueue(e),o.close()}});return new K.StreamedFile(r,t,{filesize:e.byteLength})}async isDir(t){if(t==="/")return!0;try{const e=t.split("/").filter(Boolean);let r=this.opfsRoot;for(const o of e)r=await r.getDirectoryHandle(o);return!0}catch{return!1}}async fileExists(t){const e=t.split("/").filter(Boolean);if(e.length===0)return!0;const r=e.pop();try{let o=this.opfsRoot;for(const c of e)o=await o.getDirectoryHandle(c);try{return await o.getFileHandle(r),!0}catch{return await o.getDirectoryHandle(r),!0}}catch{return!1}}async listFiles(t){let e=this.opfsRoot;if(t!=="/"){const o=t.split("/").filter(Boolean);for(const c of o)e=await e.getDirectoryHandle(c)}const r=[];for await(const[o]of e.entries())r.push(o);return r}async writeFile(t,e){const r=t.split("/").filter(Boolean),o=r.pop();if(!o)throw new Error(`Invalid file path: ${t}`);let c=this.opfsRoot;for(const h of r)c=await c.getDirectoryHandle(h);const s=await(await c.getFileHandle(o,{create:!0})).createWritable();await s.write(e),await s.close()}async mkdir(t,e=!1){const r=t.split("/").filter(Boolean);let o=this.opfsRoot;for(let c=0;c<r.length;c++){const f=r[c],s=c===r.length-1;o=await o.getDirectoryHandle(f,{create:e||s})}}async rmdir(t,e){const r=t.split("/").filter(Boolean),o=r.pop();if(!o)return;let c=this.opfsRoot;for(const f of r)c=await c.getDirectoryHandle(f);await c.removeEntry(o,{recursive:e})}async mv(t,e){if(await this.isDir(t))await this.copyDir(t,e),await this.rmdir(t,!0);else{const o=await this.readFileAsBuffer(t);await this.writeFile(e,o),await this.unlink(t)}}async unlink(t){const e=t.split("/").filter(Boolean),r=e.pop();if(!r)return;let o=this.opfsRoot;for(const c of e)o=await o.getDirectoryHandle(c);try{await o.removeEntry(r)}catch{}}async readFileAsBuffer(t){const e=t.split("/").filter(Boolean),r=e.pop();if(!r)throw new Error(`Invalid file path: ${t}`);let o=this.opfsRoot;for(const s of e)o=await o.getDirectoryHandle(s);const f=await(await o.getFileHandle(r)).getFile();return new Uint8Array(await f.arrayBuffer())}async copyDir(t,e){await this.mkdir(e);const r=await this.listFiles(t);for(const o of r){const c=t==="/"?`/${o}`:`${t}/${o}`,f=e==="/"?`/${o}`:`${e}/${o}`;if(await this.isDir(c))await this.copyDir(c,f);else{const s=await this.readFileAsBuffer(c);await this.writeFile(f,s)}}}}class Oa{constructor(t={}){this.root={type:"dir",children:{}};for(const[e,r]of Object.entries(t))this.writeFileSync(e,r)}async read(t){const r=this.getFile(t).content,o=new ReadableStream({start(c){c.enqueue(r),c.close()}});return new K.StreamedFile(o,t,{filesize:r.byteLength})}async isDir(t){const e=this.getNode(t);return!!e&&e.type==="dir"}async fileExists(t){return!!this.getNode(t)}async listFiles(t){const e=this.getNode(t);return!e||e.type!=="dir"?[]:Object.keys(e.children)}async writeFile(t,e){this.writeFileSync(t,e)}async mkdir(t,e=!1){if(t==="/")return;const{parent:r,name:o}=e?this.getOrCreateParent(t):this.getParent(t);r.children[o]||(r.children[o]={type:"dir",children:{}})}async rmdir(t,e){const{parent:r,name:o}=this.getParent(t),c=r.children[o];if(!(!c||c.type!=="dir")){if(!e&&Object.keys(c.children).length>0)throw new Error("Directory not empty");delete r.children[o]}}async mv(t,e){const{parent:r,name:o}=this.getParent(t),c=r.children[o];if(!c)throw new Error(`Source not found: ${t}`);const{parent:f,name:s}=this.getParent(e);f.children[s]=c,delete r.children[o]}async unlink(t){const{parent:e,name:r}=this.getParent(t),o=e.children[r];o&&o.type==="file"&&delete e.children[r]}async clear(){this.root={type:"dir",children:{}}}writeFileSync(t,e){const{parent:r,name:o}=this.getParent(t);r.children[o]={type:"file",content:new Uint8Array(e)}}getNode(t){if(t==="/")return this.root;const e=t.split("/").filter(Boolean);let r=this.root;for(const o of e){if(r.type!=="dir")return;const c=r.children[o];if(!c)return;r=c}return r}getDir(t){const e=this.getNode(t);if(!e||e.type!=="dir")throw new Error(`Directory not found: ${t}`);return e}getFile(t){const e=this.getNode(t);if(!e||e.type!=="file")throw new Error(`File not found: ${t}`);return e}getParent(t){const e=t.split("/").filter(Boolean),r=e.pop();if(!r)throw new Error(`Invalid path: ${t}`);const o=e.length?`/${e.join("/")}`:"/",c=this.getNode(o);if(!c||c.type!=="dir")throw new Error(`Parent directory not found: ${o}`);return{parent:c,name:r}}getOrCreateParent(t){const e=t.split("/").filter(Boolean),r=e.pop();if(!r)throw new Error(`Invalid path: ${t}`);const o=e.length?`/${e.join("/")}`:"/";return{parent:this.ensureDir(o),name:r}}ensureDir(t){if(t==="/")return this.root;const e=t.split("/").filter(Boolean);let r=this.root;for(const o of e){const c=r.children[o];if(!c){const f={type:"dir",children:{}};r.children[o]=f,r=f;continue}if(c.type!=="dir")throw new Error(`Path segment "${o}" is not a directory in ${t}`);r=c}return r}}exports.EventedFilesystem=_a;exports.FetchFilesystem=Pa;exports.GitAuthenticationError=Tt;exports.InMemoryFilesystem=$a;exports.InMemoryFilesystemBackend=Oa;exports.NodeJsFilesystem=ka;exports.OpfsFilesystemBackend=_t;exports.OverlayFilesystem=Ua;exports.ZipFilesystem=It;exports.changeset=$n;exports.clearContentsFromMountDevice=kn;exports.copyFilesystem=Ia;exports.createClient=wn;exports.createCommit=Sn;exports.createDotGitDirectory=Ba;exports.createOrUpdateBranch=An;exports.createTree=Fn;exports.createTreeNode=ce;exports.createTreeNodes=ur;exports.deleteFile=hr;exports.directoryHandleFromMountDevice=pr;exports.directoryHandleToOpfsPath=Pn;exports.filesListToObject=gn;exports.fork=Bn;exports.getArtifact=En;exports.getFilesFromDirectory=fr;exports.iterateFiles=_n;exports.listDescendantFiles=Sa;exports.listGitFiles=ha;exports.listGitRefs=Lr;exports.mayPush=xn;exports.opfsPathToDirectoryHandle=dr;exports.removePathPrefix=Fa;exports.resolveCommitHash=pa;exports.sparseCheckout=ua;
|
|
75
75
|
//# sourceMappingURL=index.cjs.map
|