1234567891011121314151617181920 |
- var ze=Object.defineProperty;var Ke=(e,t)=>{for(var n in t)ze(e,n,{get:t[n],enumerable:!0})};var ve={};Ke(ve,{analyzeMetafile:()=>ct,analyzeMetafileSync:()=>gt,build:()=>st,buildSync:()=>ft,context:()=>ot,default:()=>bt,formatMessages:()=>ut,formatMessagesSync:()=>pt,initialize:()=>yt,stop:()=>mt,transform:()=>at,transformSync:()=>dt,version:()=>lt});function Oe(e){let t=i=>{if(i===null)n.write8(0);else if(typeof i=="boolean")n.write8(1),n.write8(+i);else if(typeof i=="number")n.write8(2),n.write32(i|0);else if(typeof i=="string")n.write8(3),n.write(Z(i));else if(i instanceof Uint8Array)n.write8(4),n.write(i);else if(i instanceof Array){n.write8(5),n.write32(i.length);for(let u of i)t(u)}else{let u=Object.keys(i);n.write8(6),n.write32(u.length);for(let l of u)n.write(Z(l)),t(i[l])}},n=new de;return n.write32(0),n.write32(e.id<<1|+!e.isRequest),t(e.value),xe(n.buf,n.len-4,0),n.buf.subarray(0,n.len)}function Se(e){let t=()=>{switch(n.read8()){case 0:return null;case 1:return!!n.read8();case 2:return n.read32();case 3:return re(n.read());case 4:return n.read();case 5:{let g=n.read32(),s=[];for(let m=0;m<g;m++)s.push(t());return s}case 6:{let g=n.read32(),s={};for(let m=0;m<g;m++)s[re(n.read())]=t();return s}default:throw new Error("Invalid packet")}},n=new de(e),i=n.read32(),u=(i&1)===0;i>>>=1;let l=t();if(n.ptr!==e.length)throw new Error("Invalid packet");return{id:i,isRequest:u,value:l}}var de=class{constructor(t=new Uint8Array(1024)){this.buf=t;this.len=0;this.ptr=0}_write(t){if(this.len+t>this.buf.length){let n=new Uint8Array((this.len+t)*2);n.set(this.buf),this.buf=n}return this.len+=t,this.len-t}write8(t){let n=this._write(1);this.buf[n]=t}write32(t){let n=this._write(4);xe(this.buf,t,n)}write(t){let n=this._write(4+t.length);xe(this.buf,t.length,n),this.buf.set(t,n+4)}_read(t){if(this.ptr+t>this.buf.length)throw new Error("Invalid packet");return this.ptr+=t,this.ptr-t}read8(){return this.buf[this._read(1)]}read32(){return Ee(this.buf,this._read(4))}read(){let t=this.read32(),n=new Uint8Array(t),i=this._read(n.length);return n.set(this.buf.subarray(i,i+t)),n}},Z,re,Re;if(typeof TextEncoder!="undefined"&&typeof TextDecoder!="undefined"){let e=new TextEncoder,t=new TextDecoder;Z=n=>e.encode(n),re=n=>t.decode(n),Re='new TextEncoder().encode("")'}else if(typeof Buffer!="undefined")Z=e=>Buffer.from(e),re=e=>{let{buffer:t,byteOffset:n,byteLength:i}=e;return Buffer.from(t,n,i).toString()},Re='Buffer.from("")';else throw new Error("No UTF-8 codec found");if(!(Z("")instanceof Uint8Array))throw new Error(`Invariant violation: "${Re} instanceof Uint8Array" is incorrectly false
- This indicates that your JavaScript environment is broken. You cannot use
- esbuild in this environment because esbuild relies on this invariant. This
- is not a problem with esbuild. You need to fix your environment instead.
- `);function Ee(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function xe(e,t,n){e[n++]=t,e[n++]=t>>8,e[n++]=t>>16,e[n++]=t>>24}var V=JSON.stringify,ke="warning",$e="silent";function Me(e){if(G(e,"target"),e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var me=()=>null,W=e=>typeof e=="boolean"?null:"a boolean",y=e=>typeof e=="string"?null:"a string",ye=e=>e instanceof RegExp?null:"a RegExp object",oe=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Ve=e=>typeof e=="number"&&e===(e|0)&&e>=0&&e<=65535?null:"a valid port number",Fe=e=>typeof e=="function"?null:"a function",K=e=>Array.isArray(e)?null:"an array",ee=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",Ye=e=>typeof e=="object"&&e!==null?null:"an array or an object",Je=e=>e instanceof WebAssembly.Module?null:"a WebAssembly.Module",Ce=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",Pe=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",Ge=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",Qe=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",Te=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array",He=e=>typeof e=="string"||e instanceof URL?null:"a string or a URL";function r(e,t,n,i){let u=e[n];if(t[n+""]=!0,u===void 0)return;let l=i(u);if(l!==null)throw new Error(`${V(n)} must be ${l}`);return u}function Y(e,t,n){for(let i in e)if(!(i in t))throw new Error(`Invalid option ${n}: ${V(i)}`)}function De(e){let t=Object.create(null),n=r(e,t,"wasmURL",He),i=r(e,t,"wasmModule",Je),u=r(e,t,"worker",W);return Y(e,t,"in initialize() call"),{wasmURL:n,wasmModule:i,worker:u}}function Be(e){let t;if(e!==void 0){t=Object.create(null);for(let n in e){let i=e[n];if(typeof i=="string"||i===!1)t[n]=i;else throw new Error(`Expected ${V(n)} in mangle cache to map to either a string or false`)}}return t}function he(e,t,n,i,u){let l=r(t,n,"color",W),g=r(t,n,"logLevel",y),s=r(t,n,"logLimit",oe);l!==void 0?e.push(`--color=${l}`):i&&e.push("--color=true"),e.push(`--log-level=${g||u}`),e.push(`--log-limit=${s||0}`)}function G(e,t,n){if(typeof e!="string")throw new Error(`Expected value for ${t}${n!==void 0?" "+V(n):""} to be a string, got ${typeof e} instead`);return e}function Ue(e,t,n){let i=r(t,n,"legalComments",y),u=r(t,n,"sourceRoot",y),l=r(t,n,"sourcesContent",W),g=r(t,n,"target",Qe),s=r(t,n,"format",y),m=r(t,n,"globalName",y),U=r(t,n,"mangleProps",ye),F=r(t,n,"reserveProps",ye),b=r(t,n,"mangleQuoted",W),j=r(t,n,"minify",W),T=r(t,n,"minifySyntax",W),L=r(t,n,"minifyWhitespace",W),N=r(t,n,"minifyIdentifiers",W),S=r(t,n,"lineLimit",oe),_=r(t,n,"drop",K),J=r(t,n,"dropLabels",K),w=r(t,n,"charset",y),p=r(t,n,"treeShaking",W),f=r(t,n,"ignoreAnnotations",W),o=r(t,n,"jsx",y),v=r(t,n,"jsxFactory",y),O=r(t,n,"jsxFragment",y),M=r(t,n,"jsxImportSource",y),E=r(t,n,"jsxDev",W),a=r(t,n,"jsxSideEffects",W),c=r(t,n,"define",ee),h=r(t,n,"logOverride",ee),C=r(t,n,"supported",ee),P=r(t,n,"pure",K),$=r(t,n,"keepNames",W),x=r(t,n,"platform",y),A=r(t,n,"tsconfigRaw",Ge);if(i&&e.push(`--legal-comments=${i}`),u!==void 0&&e.push(`--source-root=${u}`),l!==void 0&&e.push(`--sources-content=${l}`),g&&(Array.isArray(g)?e.push(`--target=${Array.from(g).map(Me).join(",")}`):e.push(`--target=${Me(g)}`)),s&&e.push(`--format=${s}`),m&&e.push(`--global-name=${m}`),x&&e.push(`--platform=${x}`),A&&e.push(`--tsconfig-raw=${typeof A=="string"?A:JSON.stringify(A)}`),j&&e.push("--minify"),T&&e.push("--minify-syntax"),L&&e.push("--minify-whitespace"),N&&e.push("--minify-identifiers"),S&&e.push(`--line-limit=${S}`),w&&e.push(`--charset=${w}`),p!==void 0&&e.push(`--tree-shaking=${p}`),f&&e.push("--ignore-annotations"),_)for(let R of _)e.push(`--drop:${G(R,"drop")}`);if(J&&e.push(`--drop-labels=${Array.from(J).map(R=>G(R,"dropLabels")).join(",")}`),U&&e.push(`--mangle-props=${U.source}`),F&&e.push(`--reserve-props=${F.source}`),b!==void 0&&e.push(`--mangle-quoted=${b}`),o&&e.push(`--jsx=${o}`),v&&e.push(`--jsx-factory=${v}`),O&&e.push(`--jsx-fragment=${O}`),M&&e.push(`--jsx-import-source=${M}`),E&&e.push("--jsx-dev"),a&&e.push("--jsx-side-effects"),c)for(let R in c){if(R.indexOf("=")>=0)throw new Error(`Invalid define: ${R}`);e.push(`--define:${R}=${G(c[R],"define",R)}`)}if(h)for(let R in h){if(R.indexOf("=")>=0)throw new Error(`Invalid log override: ${R}`);e.push(`--log-override:${R}=${G(h[R],"log override",R)}`)}if(C)for(let R in C){if(R.indexOf("=")>=0)throw new Error(`Invalid supported: ${R}`);let k=C[R];if(typeof k!="boolean")throw new Error(`Expected value for supported ${V(R)} to be a boolean, got ${typeof k} instead`);e.push(`--supported:${R}=${k}`)}if(P)for(let R of P)e.push(`--pure:${G(R,"pure")}`);$&&e.push("--keep-names")}function Xe(e,t,n,i,u){var se;let l=[],g=[],s=Object.create(null),m=null,U=null;he(l,t,s,n,i),Ue(l,t,s);let F=r(t,s,"sourcemap",Pe),b=r(t,s,"bundle",W),j=r(t,s,"splitting",W),T=r(t,s,"preserveSymlinks",W),L=r(t,s,"metafile",W),N=r(t,s,"outfile",y),S=r(t,s,"outdir",y),_=r(t,s,"outbase",y),J=r(t,s,"tsconfig",y),w=r(t,s,"resolveExtensions",K),p=r(t,s,"nodePaths",K),f=r(t,s,"mainFields",K),o=r(t,s,"conditions",K),v=r(t,s,"external",K),O=r(t,s,"packages",y),M=r(t,s,"alias",ee),E=r(t,s,"loader",ee),a=r(t,s,"outExtension",ee),c=r(t,s,"publicPath",y),h=r(t,s,"entryNames",y),C=r(t,s,"chunkNames",y),P=r(t,s,"assetNames",y),$=r(t,s,"inject",K),x=r(t,s,"banner",ee),A=r(t,s,"footer",ee),R=r(t,s,"entryPoints",Ye),k=r(t,s,"absWorkingDir",y),D=r(t,s,"stdin",ee),q=(se=r(t,s,"write",W))!=null?se:u,B=r(t,s,"allowOverwrite",W),H=r(t,s,"mangleCache",ee);if(s.plugins=!0,Y(t,s,`in ${e}() call`),F&&l.push(`--sourcemap${F===!0?"":`=${F}`}`),b&&l.push("--bundle"),B&&l.push("--allow-overwrite"),j&&l.push("--splitting"),T&&l.push("--preserve-symlinks"),L&&l.push("--metafile"),N&&l.push(`--outfile=${N}`),S&&l.push(`--outdir=${S}`),_&&l.push(`--outbase=${_}`),J&&l.push(`--tsconfig=${J}`),O&&l.push(`--packages=${O}`),w){let d=[];for(let I of w){if(G(I,"resolve extension"),I.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${I}`);d.push(I)}l.push(`--resolve-extensions=${d.join(",")}`)}if(c&&l.push(`--public-path=${c}`),h&&l.push(`--entry-names=${h}`),C&&l.push(`--chunk-names=${C}`),P&&l.push(`--asset-names=${P}`),f){let d=[];for(let I of f){if(G(I,"main field"),I.indexOf(",")>=0)throw new Error(`Invalid main field: ${I}`);d.push(I)}l.push(`--main-fields=${d.join(",")}`)}if(o){let d=[];for(let I of o){if(G(I,"condition"),I.indexOf(",")>=0)throw new Error(`Invalid condition: ${I}`);d.push(I)}l.push(`--conditions=${d.join(",")}`)}if(v)for(let d of v)l.push(`--external:${G(d,"external")}`);if(M)for(let d in M){if(d.indexOf("=")>=0)throw new Error(`Invalid package name in alias: ${d}`);l.push(`--alias:${d}=${G(M[d],"alias",d)}`)}if(x)for(let d in x){if(d.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${d}`);l.push(`--banner:${d}=${G(x[d],"banner",d)}`)}if(A)for(let d in A){if(d.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${d}`);l.push(`--footer:${d}=${G(A[d],"footer",d)}`)}if($)for(let d of $)l.push(`--inject:${G(d,"inject")}`);if(E)for(let d in E){if(d.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${d}`);l.push(`--loader:${d}=${G(E[d],"loader",d)}`)}if(a)for(let d in a){if(d.indexOf("=")>=0)throw new Error(`Invalid out extension: ${d}`);l.push(`--out-extension:${d}=${G(a[d],"out extension",d)}`)}if(R)if(Array.isArray(R))for(let d=0,I=R.length;d<I;d++){let X=R[d];if(typeof X=="object"&&X!==null){let te=Object.create(null),Q=r(X,te,"in",y),ue=r(X,te,"out",y);if(Y(X,te,"in entry point at index "+d),Q===void 0)throw new Error('Missing property "in" for entry point at index '+d);if(ue===void 0)throw new Error('Missing property "out" for entry point at index '+d);g.push([ue,Q])}else g.push(["",G(X,"entry point at index "+d)])}else for(let d in R)g.push([d,G(R[d],"entry point",d)]);if(D){let d=Object.create(null),I=r(D,d,"contents",Te),X=r(D,d,"resolveDir",y),te=r(D,d,"sourcefile",y),Q=r(D,d,"loader",y);Y(D,d,'in "stdin" object'),te&&l.push(`--sourcefile=${te}`),Q&&l.push(`--loader=${Q}`),X&&(U=X),typeof I=="string"?m=Z(I):I instanceof Uint8Array&&(m=I)}let z=[];if(p)for(let d of p)d+="",z.push(d);return{entries:g,flags:l,write:q,stdinContents:m,stdinResolveDir:U,absWorkingDir:k,nodePaths:z,mangleCache:Be(H)}}function Ze(e,t,n,i){let u=[],l=Object.create(null);he(u,t,l,n,i),Ue(u,t,l);let g=r(t,l,"sourcemap",Pe),s=r(t,l,"sourcefile",y),m=r(t,l,"loader",y),U=r(t,l,"banner",y),F=r(t,l,"footer",y),b=r(t,l,"mangleCache",ee);return Y(t,l,`in ${e}() call`),g&&u.push(`--sourcemap=${g===!0?"external":g}`),s&&u.push(`--sourcefile=${s}`),m&&u.push(`--loader=${m}`),U&&u.push(`--banner=${U}`),F&&u.push(`--footer=${F}`),{flags:u,mangleCache:Be(b)}}function je(e){let t={},n={didClose:!1,reason:""},i={},u=0,l=0,g=new Uint8Array(16*1024),s=0,m=w=>{let p=s+w.length;if(p>g.length){let o=new Uint8Array(p*2);o.set(g),g=o}g.set(w,s),s+=w.length;let f=0;for(;f+4<=s;){let o=Ee(g,f);if(f+4+o>s)break;f+=4,L(g.subarray(f,f+o)),f+=o}f>0&&(g.copyWithin(0,f,s),s-=f)},U=w=>{n.didClose=!0,w&&(n.reason=": "+(w.message||w));let p="The service was stopped"+n.reason;for(let f in i)i[f](p,null);i={}},F=(w,p,f)=>{if(n.didClose)return f("The service is no longer running"+n.reason,null);let o=u++;i[o]=(v,O)=>{try{f(v,O)}finally{w&&w.unref()}},w&&w.ref(),e.writeToStdin(Oe({id:o,isRequest:!0,value:p}))},b=(w,p)=>{if(n.didClose)throw new Error("The service is no longer running"+n.reason);e.writeToStdin(Oe({id:w,isRequest:!1,value:p}))},j=async(w,p)=>{try{if(p.command==="ping"){b(w,{});return}if(typeof p.key=="number"){let f=t[p.key];if(!f)return;let o=f[p.command];if(o){await o(w,p);return}}throw new Error("Invalid command: "+p.command)}catch(f){let o=[ie(f,e,null,void 0,"")];try{b(w,{errors:o})}catch(v){}}},T=!0,L=w=>{if(T){T=!1;let f=String.fromCharCode(...w);if(f!=="0.25.1")throw new Error(`Cannot start service: Host version "0.25.1" does not match binary version ${V(f)}`);return}let p=Se(w);if(p.isRequest)j(p.id,p.value);else{let f=i[p.id];delete i[p.id],p.value.error?f(p.value.error,{}):f(null,p.value)}};return{readFromStdout:m,afterClose:U,service:{buildOrContext:({callName:w,refs:p,options:f,isTTY:o,defaultWD:v,callback:O})=>{let M=0,E=l++,a={},c={ref(){++M===1&&p&&p.ref()},unref(){--M===0&&(delete t[E],p&&p.unref())}};t[E]=a,c.ref(),et(w,E,F,b,c,e,a,f,o,v,(h,C)=>{try{O(h,C)}finally{c.unref()}})},transform:({callName:w,refs:p,input:f,options:o,isTTY:v,fs:O,callback:M})=>{let E=Le(),a=c=>{try{if(typeof f!="string"&&!(f instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:h,mangleCache:C}=Ze(w,o,v,$e),P={command:"transform",flags:h,inputFS:c!==null,input:c!==null?Z(c):typeof f=="string"?Z(f):f};C&&(P.mangleCache=C),F(p,P,($,x)=>{if($)return M(new Error($),null);let A=ae(x.errors,E),R=ae(x.warnings,E),k=1,D=()=>{if(--k===0){let q={warnings:R,code:x.code,map:x.map,mangleCache:void 0,legalComments:void 0};"legalComments"in x&&(q.legalComments=x==null?void 0:x.legalComments),x.mangleCache&&(q.mangleCache=x==null?void 0:x.mangleCache),M(null,q)}};if(A.length>0)return M(ce("Transform failed",A,R),null);x.codeFS&&(k++,O.readFile(x.code,(q,B)=>{q!==null?M(q,null):(x.code=B,D())})),x.mapFS&&(k++,O.readFile(x.map,(q,B)=>{q!==null?M(q,null):(x.map=B,D())})),D()})}catch(h){let C=[];try{he(C,o,{},v,$e)}catch($){}let P=ie(h,e,E,void 0,"");F(p,{command:"error",flags:C,error:P},()=>{P.detail=E.load(P.detail),M(ce("Transform failed",[P],[]),null)})}};if((typeof f=="string"||f instanceof Uint8Array)&&f.length>1024*1024){let c=a;a=()=>O.writeFile(f,c)}a(null)},formatMessages:({callName:w,refs:p,messages:f,options:o,callback:v})=>{if(!o)throw new Error(`Missing second argument in ${w}() call`);let O={},M=r(o,O,"kind",y),E=r(o,O,"color",W),a=r(o,O,"terminalWidth",oe);if(Y(o,O,`in ${w}() call`),M===void 0)throw new Error(`Missing "kind" in ${w}() call`);if(M!=="error"&&M!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${w}() call`);let c={command:"format-msgs",messages:ne(f,"messages",null,"",a),isWarning:M==="warning"};E!==void 0&&(c.color=E),a!==void 0&&(c.terminalWidth=a),F(p,c,(h,C)=>{if(h)return v(new Error(h),null);v(null,C.messages)})},analyzeMetafile:({callName:w,refs:p,metafile:f,options:o,callback:v})=>{o===void 0&&(o={});let O={},M=r(o,O,"color",W),E=r(o,O,"verbose",W);Y(o,O,`in ${w}() call`);let a={command:"analyze-metafile",metafile:f};M!==void 0&&(a.color=M),E!==void 0&&(a.verbose=E),F(p,a,(c,h)=>{if(c)return v(new Error(c),null);v(null,h.result)})}}}}function et(e,t,n,i,u,l,g,s,m,U,F){let b=Le(),j=e==="context",T=(S,_)=>{let J=[];try{he(J,s,{},m,ke)}catch(p){}let w=ie(S,l,b,void 0,_);n(u,{command:"error",flags:J,error:w},()=>{w.detail=b.load(w.detail),F(ce(j?"Context failed":"Build failed",[w],[]),null)})},L;if(typeof s=="object"){let S=s.plugins;if(S!==void 0){if(!Array.isArray(S))return T(new Error('"plugins" must be an array'),"");L=S}}if(L&&L.length>0){if(l.isSync)return T(new Error("Cannot use plugins in synchronous API calls"),"");tt(t,n,i,u,l,g,s,L,b).then(S=>{if(!S.ok)return T(S.error,S.pluginName);try{N(S.requestPlugins,S.runOnEndCallbacks,S.scheduleOnDisposeCallbacks)}catch(_){T(_,"")}},S=>T(S,""));return}try{N(null,(S,_)=>_([],[]),()=>{})}catch(S){T(S,"")}function N(S,_,J){let w=l.hasFS,{entries:p,flags:f,write:o,stdinContents:v,stdinResolveDir:O,absWorkingDir:M,nodePaths:E,mangleCache:a}=Xe(e,s,m,ke,w);if(o&&!l.hasFS)throw new Error('The "write" option is unavailable in this environment');let c={command:"build",key:t,entries:p,flags:f,write:o,stdinContents:v,stdinResolveDir:O,absWorkingDir:M||U,nodePaths:E,context:j};S&&(c.plugins=S),a&&(c.mangleCache=a);let h=($,x)=>{let A={errors:ae($.errors,b),warnings:ae($.warnings,b),outputFiles:void 0,metafile:void 0,mangleCache:void 0},R=A.errors.slice(),k=A.warnings.slice();$.outputFiles&&(A.outputFiles=$.outputFiles.map(rt)),$.metafile&&(A.metafile=JSON.parse($.metafile)),$.mangleCache&&(A.mangleCache=$.mangleCache),$.writeToStdout!==void 0&&console.log(re($.writeToStdout).replace(/\n$/,"")),_(A,(D,q)=>{if(R.length>0||D.length>0){let B=ce("Build failed",R.concat(D),k.concat(q));return x(B,null,D,q)}x(null,A,D,q)})},C,P;j&&(g["on-end"]=($,x)=>new Promise(A=>{h(x,(R,k,D,q)=>{let B={errors:D,warnings:q};P&&P(R,k),C=void 0,P=void 0,i($,B),A()})})),n(u,c,($,x)=>{if($)return F(new Error($),null);if(!j)return h(x,(k,D)=>(J(),F(k,D)));if(x.errors.length>0)return F(ce("Context failed",x.errors,x.warnings),null);let A=!1,R={rebuild:()=>(C||(C=new Promise((k,D)=>{let q;P=(H,z)=>{q||(q=()=>H?D(H):k(z))};let B=()=>{n(u,{command:"rebuild",key:t},(z,se)=>{z?D(new Error(z)):q?q():B()})};B()})),C),watch:(k={})=>new Promise((D,q)=>{if(!l.hasFS)throw new Error('Cannot use the "watch" API in this environment');Y(k,{},"in watch() call"),n(u,{command:"watch",key:t},z=>{z?q(new Error(z)):D(void 0)})}),serve:(k={})=>new Promise((D,q)=>{if(!l.hasFS)throw new Error('Cannot use the "serve" API in this environment');let B={},H=r(k,B,"port",Ve),z=r(k,B,"host",y),se=r(k,B,"servedir",y),d=r(k,B,"keyfile",y),I=r(k,B,"certfile",y),X=r(k,B,"fallback",y),te=r(k,B,"onRequest",Fe);Y(k,B,"in serve() call");let Q={command:"serve",key:t,onRequest:!!te};H!==void 0&&(Q.port=H),z!==void 0&&(Q.host=z),se!==void 0&&(Q.servedir=se),d!==void 0&&(Q.keyfile=d),I!==void 0&&(Q.certfile=I),X!==void 0&&(Q.fallback=X),n(u,Q,(ue,qe)=>{if(ue)return q(new Error(ue));te&&(g["serve-request"]=(Ie,We)=>{te(We.args),i(Ie,{})}),D(qe)})}),cancel:()=>new Promise(k=>{if(A)return k();n(u,{command:"cancel",key:t},()=>{k()})}),dispose:()=>new Promise(k=>{if(A)return k();A=!0,n(u,{command:"dispose",key:t},()=>{k(),J(),u.unref()})})};u.ref(),F(null,R)})}}var tt=async(e,t,n,i,u,l,g,s,m)=>{let U=[],F=[],b={},j={},T=[],L=0,N=0,S=[],_=!1;s=[...s];for(let p of s){let f={};if(typeof p!="object")throw new Error(`Plugin at index ${N} must be an object`);let o=r(p,f,"name",y);if(typeof o!="string"||o==="")throw new Error(`Plugin at index ${N} is missing a name`);try{let v=r(p,f,"setup",Fe);if(typeof v!="function")throw new Error("Plugin is missing a setup function");Y(p,f,`on plugin ${V(o)}`);let O={name:o,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};N++;let E=v({initialOptions:g,resolve:(a,c={})=>{if(!_)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof a!="string")throw new Error("The path to resolve must be a string");let h=Object.create(null),C=r(c,h,"pluginName",y),P=r(c,h,"importer",y),$=r(c,h,"namespace",y),x=r(c,h,"resolveDir",y),A=r(c,h,"kind",y),R=r(c,h,"pluginData",me),k=r(c,h,"with",ee);return Y(c,h,"in resolve() call"),new Promise((D,q)=>{let B={command:"resolve",path:a,key:e,pluginName:o};if(C!=null&&(B.pluginName=C),P!=null&&(B.importer=P),$!=null&&(B.namespace=$),x!=null&&(B.resolveDir=x),A!=null)B.kind=A;else throw new Error('Must specify "kind" when calling "resolve"');R!=null&&(B.pluginData=m.store(R)),k!=null&&(B.with=nt(k,"with")),t(i,B,(H,z)=>{H!==null?q(new Error(H)):D({errors:ae(z.errors,m),warnings:ae(z.warnings,m),path:z.path,external:z.external,sideEffects:z.sideEffects,namespace:z.namespace,suffix:z.suffix,pluginData:m.load(z.pluginData)})})})},onStart(a){let c='This error came from the "onStart" callback registered here:',h=pe(new Error(c),u,"onStart");U.push({name:o,callback:a,note:h}),O.onStart=!0},onEnd(a){let c='This error came from the "onEnd" callback registered here:',h=pe(new Error(c),u,"onEnd");F.push({name:o,callback:a,note:h}),O.onEnd=!0},onResolve(a,c){let h='This error came from the "onResolve" callback registered here:',C=pe(new Error(h),u,"onResolve"),P={},$=r(a,P,"filter",ye),x=r(a,P,"namespace",y);if(Y(a,P,`in onResolve() call for plugin ${V(o)}`),$==null)throw new Error("onResolve() call is missing a filter");let A=L++;b[A]={name:o,callback:c,note:C},O.onResolve.push({id:A,filter:$.source,namespace:x||""})},onLoad(a,c){let h='This error came from the "onLoad" callback registered here:',C=pe(new Error(h),u,"onLoad"),P={},$=r(a,P,"filter",ye),x=r(a,P,"namespace",y);if(Y(a,P,`in onLoad() call for plugin ${V(o)}`),$==null)throw new Error("onLoad() call is missing a filter");let A=L++;j[A]={name:o,callback:c,note:C},O.onLoad.push({id:A,filter:$.source,namespace:x||""})},onDispose(a){T.push(a)},esbuild:u.esbuild});E&&await E,S.push(O)}catch(v){return{ok:!1,error:v,pluginName:o}}}l["on-start"]=async(p,f)=>{m.clear();let o={errors:[],warnings:[]};await Promise.all(U.map(async({name:v,callback:O,note:M})=>{try{let E=await O();if(E!=null){if(typeof E!="object")throw new Error(`Expected onStart() callback in plugin ${V(v)} to return an object`);let a={},c=r(E,a,"errors",K),h=r(E,a,"warnings",K);Y(E,a,`from onStart() callback in plugin ${V(v)}`),c!=null&&o.errors.push(...ne(c,"errors",m,v,void 0)),h!=null&&o.warnings.push(...ne(h,"warnings",m,v,void 0))}}catch(E){o.errors.push(ie(E,u,m,M&&M(),v))}})),n(p,o)},l["on-resolve"]=async(p,f)=>{let o={},v="",O,M;for(let E of f.ids)try{({name:v,callback:O,note:M}=b[E]);let a=await O({path:f.path,importer:f.importer,namespace:f.namespace,resolveDir:f.resolveDir,kind:f.kind,pluginData:m.load(f.pluginData),with:f.with});if(a!=null){if(typeof a!="object")throw new Error(`Expected onResolve() callback in plugin ${V(v)} to return an object`);let c={},h=r(a,c,"pluginName",y),C=r(a,c,"path",y),P=r(a,c,"namespace",y),$=r(a,c,"suffix",y),x=r(a,c,"external",W),A=r(a,c,"sideEffects",W),R=r(a,c,"pluginData",me),k=r(a,c,"errors",K),D=r(a,c,"warnings",K),q=r(a,c,"watchFiles",K),B=r(a,c,"watchDirs",K);Y(a,c,`from onResolve() callback in plugin ${V(v)}`),o.id=E,h!=null&&(o.pluginName=h),C!=null&&(o.path=C),P!=null&&(o.namespace=P),$!=null&&(o.suffix=$),x!=null&&(o.external=x),A!=null&&(o.sideEffects=A),R!=null&&(o.pluginData=m.store(R)),k!=null&&(o.errors=ne(k,"errors",m,v,void 0)),D!=null&&(o.warnings=ne(D,"warnings",m,v,void 0)),q!=null&&(o.watchFiles=ge(q,"watchFiles")),B!=null&&(o.watchDirs=ge(B,"watchDirs"));break}}catch(a){o={id:E,errors:[ie(a,u,m,M&&M(),v)]};break}n(p,o)},l["on-load"]=async(p,f)=>{let o={},v="",O,M;for(let E of f.ids)try{({name:v,callback:O,note:M}=j[E]);let a=await O({path:f.path,namespace:f.namespace,suffix:f.suffix,pluginData:m.load(f.pluginData),with:f.with});if(a!=null){if(typeof a!="object")throw new Error(`Expected onLoad() callback in plugin ${V(v)} to return an object`);let c={},h=r(a,c,"pluginName",y),C=r(a,c,"contents",Te),P=r(a,c,"resolveDir",y),$=r(a,c,"pluginData",me),x=r(a,c,"loader",y),A=r(a,c,"errors",K),R=r(a,c,"warnings",K),k=r(a,c,"watchFiles",K),D=r(a,c,"watchDirs",K);Y(a,c,`from onLoad() callback in plugin ${V(v)}`),o.id=E,h!=null&&(o.pluginName=h),C instanceof Uint8Array?o.contents=C:C!=null&&(o.contents=Z(C)),P!=null&&(o.resolveDir=P),$!=null&&(o.pluginData=m.store($)),x!=null&&(o.loader=x),A!=null&&(o.errors=ne(A,"errors",m,v,void 0)),R!=null&&(o.warnings=ne(R,"warnings",m,v,void 0)),k!=null&&(o.watchFiles=ge(k,"watchFiles")),D!=null&&(o.watchDirs=ge(D,"watchDirs"));break}}catch(a){o={id:E,errors:[ie(a,u,m,M&&M(),v)]};break}n(p,o)};let J=(p,f)=>f([],[]);F.length>0&&(J=(p,f)=>{(async()=>{let o=[],v=[];for(let{name:O,callback:M,note:E}of F){let a,c;try{let h=await M(p);if(h!=null){if(typeof h!="object")throw new Error(`Expected onEnd() callback in plugin ${V(O)} to return an object`);let C={},P=r(h,C,"errors",K),$=r(h,C,"warnings",K);Y(h,C,`from onEnd() callback in plugin ${V(O)}`),P!=null&&(a=ne(P,"errors",m,O,void 0)),$!=null&&(c=ne($,"warnings",m,O,void 0))}}catch(h){a=[ie(h,u,m,E&&E(),O)]}if(a){o.push(...a);try{p.errors.push(...a)}catch(h){}}if(c){v.push(...c);try{p.warnings.push(...c)}catch(h){}}}f(o,v)})()});let w=()=>{for(let p of T)setTimeout(()=>p(),0)};return _=!0,{ok:!0,requestPlugins:S,runOnEndCallbacks:J,scheduleOnDisposeCallbacks:w}};function Le(){let e=new Map,t=0;return{clear(){e.clear()},load(n){return e.get(n)},store(n){if(n===void 0)return-1;let i=t++;return e.set(i,n),i}}}function pe(e,t,n){let i,u=!1;return()=>{if(u)return i;u=!0;try{let l=(e.stack+"").split(`
- `);l.splice(1,1);let g=Ne(t,l,n);if(g)return i={text:e.message,location:g},i}catch(l){}}}function ie(e,t,n,i,u){let l="Internal error",g=null;try{l=(e&&e.message||e)+""}catch(s){}try{g=Ne(t,(e.stack+"").split(`
- `),"")}catch(s){}return{id:"",pluginName:u,text:l,location:g,notes:i?[i]:[],detail:n?n.store(e):-1}}function Ne(e,t,n){let i=" at ";if(e.readFileSync&&!t[0].startsWith(i)&&t[1].startsWith(i))for(let u=1;u<t.length;u++){let l=t[u];if(l.startsWith(i))for(l=l.slice(i.length);;){let g=/^(?:new |async )?\S+ \((.*)\)$/.exec(l);if(g){l=g[1];continue}if(g=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(l),g){l=g[1];continue}if(g=/^(\S+):(\d+):(\d+)$/.exec(l),g){let s;try{s=e.readFileSync(g[1],"utf8")}catch(b){break}let m=s.split(/\r\n|\r|\n|\u2028|\u2029/)[+g[2]-1]||"",U=+g[3]-1,F=m.slice(U,U+n.length)===n?n.length:0;return{file:g[1],namespace:"file",line:+g[2],column:Z(m.slice(0,U)).length,length:Z(m.slice(U,U+F)).length,lineText:m+`
- `+t.slice(1).join(`
- `),suggestion:""}}break}}return null}function ce(e,t,n){let i=5;e+=t.length<1?"":` with ${t.length} error${t.length<2?"":"s"}:`+t.slice(0,i+1).map((l,g)=>{if(g===i)return`
- ...`;if(!l.location)return`
- error: ${l.text}`;let{file:s,line:m,column:U}=l.location,F=l.pluginName?`[plugin: ${l.pluginName}] `:"";return`
- ${s}:${m}:${U}: ERROR: ${F}${l.text}`}).join("");let u=new Error(e);for(let[l,g]of[["errors",t],["warnings",n]])Object.defineProperty(u,l,{configurable:!0,enumerable:!0,get:()=>g,set:s=>Object.defineProperty(u,l,{configurable:!0,enumerable:!0,value:s})});return u}function ae(e,t){for(let n of e)n.detail=t.load(n.detail);return e}function Ae(e,t,n){if(e==null)return null;let i={},u=r(e,i,"file",y),l=r(e,i,"namespace",y),g=r(e,i,"line",oe),s=r(e,i,"column",oe),m=r(e,i,"length",oe),U=r(e,i,"lineText",y),F=r(e,i,"suggestion",y);if(Y(e,i,t),U){let b=U.slice(0,(s&&s>0?s:0)+(m&&m>0?m:0)+(n&&n>0?n:80));!/[\x7F-\uFFFF]/.test(b)&&!/\n/.test(U)&&(U=b)}return{file:u||"",namespace:l||"",line:g||0,column:s||0,length:m||0,lineText:U||"",suggestion:F||""}}function ne(e,t,n,i,u){let l=[],g=0;for(let s of e){let m={},U=r(s,m,"id",y),F=r(s,m,"pluginName",y),b=r(s,m,"text",y),j=r(s,m,"location",Ce),T=r(s,m,"notes",K),L=r(s,m,"detail",me),N=`in element ${g} of "${t}"`;Y(s,m,N);let S=[];if(T)for(let _ of T){let J={},w=r(_,J,"text",y),p=r(_,J,"location",Ce);Y(_,J,N),S.push({text:w||"",location:Ae(p,N,u)})}l.push({id:U||"",pluginName:F||i,text:b||"",location:Ae(j,N,u),notes:S,detail:n?n.store(L):-1}),g++}return l}function ge(e,t){let n=[];for(let i of e){if(typeof i!="string")throw new Error(`${V(t)} must be an array of strings`);n.push(i)}return n}function nt(e,t){let n=Object.create(null);for(let i in e){let u=e[i];if(typeof u!="string")throw new Error(`key ${V(i)} in object ${V(t)} must be a string`);n[i]=u}return n}function rt({path:e,contents:t,hash:n}){let i=null;return{path:e,contents:t,hash:n,get text(){let u=this.contents;return(i===null||u!==t)&&(t=u,i=re(u)),i}}}var lt="0.25.1",st=e=>fe().build(e),ot=e=>fe().context(e),at=(e,t)=>fe().transform(e,t),ut=(e,t)=>fe().formatMessages(e,t),ct=(e,t)=>fe().analyzeMetafile(e,t),ft=()=>{throw new Error('The "buildSync" API only works in node')},dt=()=>{throw new Error('The "transformSync" API only works in node')},pt=()=>{throw new Error('The "formatMessagesSync" API only works in node')},gt=()=>{throw new Error('The "analyzeMetafileSync" API only works in node')},mt=()=>(be&&be(),Promise.resolve()),le,be,we,fe=()=>{if(we)return we;throw le?new Error('You need to wait for the promise returned from "initialize" to be resolved before calling this'):new Error('You need to call "initialize" before calling this')},yt=e=>{e=De(e||{});let t=e.wasmURL,n=e.wasmModule,i=e.worker!==!1;if(!t&&!n)throw new Error('Must provide either the "wasmURL" option or the "wasmModule" option');if(le)throw new Error('Cannot call "initialize" more than once');return le=ht(t||"",n,i),le.catch(()=>{le=void 0}),le},ht=async(e,t,n)=>{let i,u,l=new Promise(b=>u=b);if(n){let b=new Blob(['onmessage=(postMessage=>{\n// Copyright 2018 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\nlet onmessage,globalThis={};for(let r=self;r;r=Object.getPrototypeOf(r))for(let f of Object.getOwnPropertyNames(r))f in globalThis||Object.defineProperty(globalThis,f,{get:()=>self[f]});(()=>{const r=()=>{const c=new Error("not implemented");return c.code="ENOSYS",c};if(!globalThis.fs){let c="";globalThis.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(i,s){c+=y.decode(s);const n=c.lastIndexOf(`\n`);return n!=-1&&(console.log(c.substring(0,n)),c=c.substring(n+1)),s.length},write(i,s,n,o,u,h){if(n!==0||o!==s.length||u!==null){h(r());return}const m=this.writeSync(i,s);h(null,m)},chmod(i,s,n){n(r())},chown(i,s,n,o){o(r())},close(i,s){s(r())},fchmod(i,s,n){n(r())},fchown(i,s,n,o){o(r())},fstat(i,s){s(r())},fsync(i,s){s(null)},ftruncate(i,s,n){n(r())},lchown(i,s,n,o){o(r())},link(i,s,n){n(r())},lstat(i,s){s(r())},mkdir(i,s,n){n(r())},open(i,s,n,o){o(r())},read(i,s,n,o,u,h){h(r())},readdir(i,s){s(r())},readlink(i,s){s(r())},rename(i,s,n){n(r())},rmdir(i,s){s(r())},stat(i,s){s(r())},symlink(i,s,n){n(r())},truncate(i,s,n){n(r())},unlink(i,s){s(r())},utimes(i,s,n,o){o(r())}}}if(globalThis.process||(globalThis.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw r()},pid:-1,ppid:-1,umask(){throw r()},cwd(){throw r()},chdir(){throw r()}}),!globalThis.crypto)throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");if(!globalThis.performance)throw new Error("globalThis.performance is not available, polyfill required (performance.now only)");if(!globalThis.TextEncoder)throw new Error("globalThis.TextEncoder is not available, polyfill required");if(!globalThis.TextDecoder)throw new Error("globalThis.TextDecoder is not available, polyfill required");const f=new TextEncoder("utf-8"),y=new TextDecoder("utf-8");globalThis.Go=class{constructor(){this.argv=["js"],this.env={},this.exit=t=>{t!==0&&console.warn("exit code:",t)},this._exitPromise=new Promise(t=>{this._resolveExitPromise=t}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;const c=(t,e)=>{this.mem.setUint32(t+0,e,!0),this.mem.setUint32(t+4,Math.floor(e/4294967296),!0)},i=(t,e)=>{this.mem.setUint32(t+0,e,!0)},s=t=>{const e=this.mem.getUint32(t+0,!0),l=this.mem.getInt32(t+4,!0);return e+l*4294967296},n=t=>{const e=this.mem.getFloat64(t,!0);if(e===0)return;if(!isNaN(e))return e;const l=this.mem.getUint32(t,!0);return this._values[l]},o=(t,e)=>{if(typeof e=="number"&&e!==0){if(isNaN(e)){this.mem.setUint32(t+4,2146959360,!0),this.mem.setUint32(t,0,!0);return}this.mem.setFloat64(t,e,!0);return}if(e===void 0){this.mem.setFloat64(t,0,!0);return}let a=this._ids.get(e);a===void 0&&(a=this._idPool.pop(),a===void 0&&(a=this._values.length),this._values[a]=e,this._goRefCounts[a]=0,this._ids.set(e,a)),this._goRefCounts[a]++;let g=0;switch(typeof e){case"object":e!==null&&(g=1);break;case"string":g=2;break;case"symbol":g=3;break;case"function":g=4;break}this.mem.setUint32(t+4,2146959360|g,!0),this.mem.setUint32(t,a,!0)},u=t=>{const e=s(t+0),l=s(t+8);return new Uint8Array(this._inst.exports.mem.buffer,e,l)},h=t=>{const e=s(t+0),l=s(t+8),a=new Array(l);for(let g=0;g<l;g++)a[g]=n(e+g*8);return a},m=t=>{const e=s(t+0),l=s(t+8);return y.decode(new DataView(this._inst.exports.mem.buffer,e,l))},d=Date.now()-performance.now();this.importObject={_gotest:{add:(t,e)=>t+e},gojs:{"runtime.wasmExit":t=>{t>>>=0;const e=this.mem.getInt32(t+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(e)},"runtime.wasmWrite":t=>{t>>>=0;const e=s(t+8),l=s(t+16),a=this.mem.getInt32(t+24,!0);globalThis.fs.writeSync(e,new Uint8Array(this._inst.exports.mem.buffer,l,a))},"runtime.resetMemoryDataView":t=>{t>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":t=>{t>>>=0,c(t+8,(d+performance.now())*1e6)},"runtime.walltime":t=>{t>>>=0;const e=new Date().getTime();c(t+8,e/1e3),this.mem.setInt32(t+16,e%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":t=>{t>>>=0;const e=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(e,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(e);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},s(t+8))),this.mem.setInt32(t+16,e,!0)},"runtime.clearTimeoutEvent":t=>{t>>>=0;const e=this.mem.getInt32(t+8,!0);clearTimeout(this._scheduledTimeouts.get(e)),this._scheduledTimeouts.delete(e)},"runtime.getRandomData":t=>{t>>>=0,crypto.getRandomValues(u(t+8))},"syscall/js.finalizeRef":t=>{t>>>=0;const e=this.mem.getUint32(t+8,!0);if(this._goRefCounts[e]--,this._goRefCounts[e]===0){const l=this._values[e];this._values[e]=null,this._ids.delete(l),this._idPool.push(e)}},"syscall/js.stringVal":t=>{t>>>=0,o(t+24,m(t+8))},"syscall/js.valueGet":t=>{t>>>=0;const e=Reflect.get(n(t+8),m(t+16));t=this._inst.exports.getsp()>>>0,o(t+32,e)},"syscall/js.valueSet":t=>{t>>>=0,Reflect.set(n(t+8),m(t+16),n(t+32))},"syscall/js.valueDelete":t=>{t>>>=0,Reflect.deleteProperty(n(t+8),m(t+16))},"syscall/js.valueIndex":t=>{t>>>=0,o(t+24,Reflect.get(n(t+8),s(t+16)))},"syscall/js.valueSetIndex":t=>{t>>>=0,Reflect.set(n(t+8),s(t+16),n(t+24))},"syscall/js.valueCall":t=>{t>>>=0;try{const e=n(t+8),l=Reflect.get(e,m(t+16)),a=h(t+32),g=Reflect.apply(l,e,a);t=this._inst.exports.getsp()>>>0,o(t+56,g),this.mem.setUint8(t+64,1)}catch(e){t=this._inst.exports.getsp()>>>0,o(t+56,e),this.mem.setUint8(t+64,0)}},"syscall/js.valueInvoke":t=>{t>>>=0;try{const e=n(t+8),l=h(t+16),a=Reflect.apply(e,void 0,l);t=this._inst.exports.getsp()>>>0,o(t+40,a),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,o(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueNew":t=>{t>>>=0;try{const e=n(t+8),l=h(t+16),a=Reflect.construct(e,l);t=this._inst.exports.getsp()>>>0,o(t+40,a),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,o(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueLength":t=>{t>>>=0,c(t+16,parseInt(n(t+8).length))},"syscall/js.valuePrepareString":t=>{t>>>=0;const e=f.encode(String(n(t+8)));o(t+16,e),c(t+24,e.length)},"syscall/js.valueLoadString":t=>{t>>>=0;const e=n(t+8);u(t+16).set(e)},"syscall/js.valueInstanceOf":t=>{t>>>=0,this.mem.setUint8(t+24,n(t+8)instanceof n(t+16)?1:0)},"syscall/js.copyBytesToGo":t=>{t>>>=0;const e=u(t+8),l=n(t+32);if(!(l instanceof Uint8Array||l instanceof Uint8ClampedArray)){this.mem.setUint8(t+48,0);return}const a=l.subarray(0,e.length);e.set(a),c(t+40,a.length),this.mem.setUint8(t+48,1)},"syscall/js.copyBytesToJS":t=>{t>>>=0;const e=n(t+8),l=u(t+16);if(!(e instanceof Uint8Array||e instanceof Uint8ClampedArray)){this.mem.setUint8(t+48,0);return}const a=l.subarray(0,e.length);e.set(a),c(t+40,a.length),this.mem.setUint8(t+48,1)},debug:t=>{console.log(t)}}}}async run(c){if(!(c instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=c,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let i=4096;const s=d=>{const t=i,e=f.encode(d+"\\0");return new Uint8Array(this.mem.buffer,i,e.length).set(e),i+=e.length,i%8!==0&&(i+=8-i%8),t},n=this.argv.length,o=[];this.argv.forEach(d=>{o.push(s(d))}),o.push(0),Object.keys(this.env).sort().forEach(d=>{o.push(s(`${d}=${this.env[d]}`))}),o.push(0);const h=i;if(o.forEach(d=>{this.mem.setUint32(i,d,!0),this.mem.setUint32(i+4,0,!0),i+=8}),i>=12288)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(n,h),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(c){const i=this;return function(){const s={id:c,this:this,args:arguments};return i._pendingEvent=s,i._resume(),s.result}}}})(),onmessage=({data:r})=>{let f=new TextDecoder,y=globalThis.fs,c="";y.writeSync=(u,h)=>{if(u===1)postMessage(h);else if(u===2){c+=f.decode(h);let m=c.split(`\n`);m.length>1&&console.log(m.slice(0,-1).join(`\n`)),c=m[m.length-1]}else throw new Error("Bad write");return h.length};let i=[],s,n=0;onmessage=({data:u})=>(u.length>0&&(i.push(u),s&&s()),o),y.read=(u,h,m,d,t,e)=>{if(u!==0||m!==0||d!==h.length||t!==null)throw new Error("Bad read");if(i.length===0){s=()=>y.read(u,h,m,d,t,e);return}let l=i[0],a=Math.max(0,Math.min(d,l.length-n));h.set(l.subarray(n,n+a),m),n+=a,n===l.length&&(i.shift(),n=0),e(null,a)};let o=new globalThis.Go;return o.argv=["","--service=0.25.1"],tryToInstantiateModule(r,o).then(u=>{postMessage(null),o.run(u)},u=>{postMessage(u)}),o};async function tryToInstantiateModule(r,f){if(r instanceof WebAssembly.Module)return WebAssembly.instantiate(r,f.importObject);const y=await fetch(r);if(!y.ok)throw new Error(`Failed to download ${JSON.stringify(r)}`);if("instantiateStreaming"in WebAssembly&&/^application\\/wasm($|;)/i.test(y.headers.get("Content-Type")||""))return(await WebAssembly.instantiateStreaming(y,f.importObject)).instance;const c=await y.arrayBuffer();return(await WebAssembly.instantiate(c,f.importObject)).instance}return r=>onmessage(r);})(postMessage)'],{type:"text/javascript"});i=new Worker(URL.createObjectURL(b))}else{let b=(postMessage=>{
- // Copyright 2018 The Go Authors. All rights reserved.
- // Use of this source code is governed by a BSD-style
- // license that can be found in the LICENSE file.
- let onmessage,globalThis={};for(let r=self;r;r=Object.getPrototypeOf(r))for(let f of Object.getOwnPropertyNames(r))f in globalThis||Object.defineProperty(globalThis,f,{get:()=>self[f]});(()=>{const r=()=>{const c=new Error("not implemented");return c.code="ENOSYS",c};if(!globalThis.fs){let c="";globalThis.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(i,s){c+=y.decode(s);const n=c.lastIndexOf(`
- `);return n!=-1&&(console.log(c.substring(0,n)),c=c.substring(n+1)),s.length},write(i,s,n,o,u,h){if(n!==0||o!==s.length||u!==null){h(r());return}const m=this.writeSync(i,s);h(null,m)},chmod(i,s,n){n(r())},chown(i,s,n,o){o(r())},close(i,s){s(r())},fchmod(i,s,n){n(r())},fchown(i,s,n,o){o(r())},fstat(i,s){s(r())},fsync(i,s){s(null)},ftruncate(i,s,n){n(r())},lchown(i,s,n,o){o(r())},link(i,s,n){n(r())},lstat(i,s){s(r())},mkdir(i,s,n){n(r())},open(i,s,n,o){o(r())},read(i,s,n,o,u,h){h(r())},readdir(i,s){s(r())},readlink(i,s){s(r())},rename(i,s,n){n(r())},rmdir(i,s){s(r())},stat(i,s){s(r())},symlink(i,s,n){n(r())},truncate(i,s,n){n(r())},unlink(i,s){s(r())},utimes(i,s,n,o){o(r())}}}if(globalThis.process||(globalThis.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw r()},pid:-1,ppid:-1,umask(){throw r()},cwd(){throw r()},chdir(){throw r()}}),!globalThis.crypto)throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");if(!globalThis.performance)throw new Error("globalThis.performance is not available, polyfill required (performance.now only)");if(!globalThis.TextEncoder)throw new Error("globalThis.TextEncoder is not available, polyfill required");if(!globalThis.TextDecoder)throw new Error("globalThis.TextDecoder is not available, polyfill required");const f=new TextEncoder("utf-8"),y=new TextDecoder("utf-8");globalThis.Go=class{constructor(){this.argv=["js"],this.env={},this.exit=t=>{t!==0&&console.warn("exit code:",t)},this._exitPromise=new Promise(t=>{this._resolveExitPromise=t}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;const c=(t,e)=>{this.mem.setUint32(t+0,e,!0),this.mem.setUint32(t+4,Math.floor(e/4294967296),!0)},i=(t,e)=>{this.mem.setUint32(t+0,e,!0)},s=t=>{const e=this.mem.getUint32(t+0,!0),l=this.mem.getInt32(t+4,!0);return e+l*4294967296},n=t=>{const e=this.mem.getFloat64(t,!0);if(e===0)return;if(!isNaN(e))return e;const l=this.mem.getUint32(t,!0);return this._values[l]},o=(t,e)=>{if(typeof e=="number"&&e!==0){if(isNaN(e)){this.mem.setUint32(t+4,2146959360,!0),this.mem.setUint32(t,0,!0);return}this.mem.setFloat64(t,e,!0);return}if(e===void 0){this.mem.setFloat64(t,0,!0);return}let a=this._ids.get(e);a===void 0&&(a=this._idPool.pop(),a===void 0&&(a=this._values.length),this._values[a]=e,this._goRefCounts[a]=0,this._ids.set(e,a)),this._goRefCounts[a]++;let g=0;switch(typeof e){case"object":e!==null&&(g=1);break;case"string":g=2;break;case"symbol":g=3;break;case"function":g=4;break}this.mem.setUint32(t+4,2146959360|g,!0),this.mem.setUint32(t,a,!0)},u=t=>{const e=s(t+0),l=s(t+8);return new Uint8Array(this._inst.exports.mem.buffer,e,l)},h=t=>{const e=s(t+0),l=s(t+8),a=new Array(l);for(let g=0;g<l;g++)a[g]=n(e+g*8);return a},m=t=>{const e=s(t+0),l=s(t+8);return y.decode(new DataView(this._inst.exports.mem.buffer,e,l))},d=Date.now()-performance.now();this.importObject={_gotest:{add:(t,e)=>t+e},gojs:{"runtime.wasmExit":t=>{t>>>=0;const e=this.mem.getInt32(t+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(e)},"runtime.wasmWrite":t=>{t>>>=0;const e=s(t+8),l=s(t+16),a=this.mem.getInt32(t+24,!0);globalThis.fs.writeSync(e,new Uint8Array(this._inst.exports.mem.buffer,l,a))},"runtime.resetMemoryDataView":t=>{t>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":t=>{t>>>=0,c(t+8,(d+performance.now())*1e6)},"runtime.walltime":t=>{t>>>=0;const e=new Date().getTime();c(t+8,e/1e3),this.mem.setInt32(t+16,e%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":t=>{t>>>=0;const e=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(e,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(e);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},s(t+8))),this.mem.setInt32(t+16,e,!0)},"runtime.clearTimeoutEvent":t=>{t>>>=0;const e=this.mem.getInt32(t+8,!0);clearTimeout(this._scheduledTimeouts.get(e)),this._scheduledTimeouts.delete(e)},"runtime.getRandomData":t=>{t>>>=0,crypto.getRandomValues(u(t+8))},"syscall/js.finalizeRef":t=>{t>>>=0;const e=this.mem.getUint32(t+8,!0);if(this._goRefCounts[e]--,this._goRefCounts[e]===0){const l=this._values[e];this._values[e]=null,this._ids.delete(l),this._idPool.push(e)}},"syscall/js.stringVal":t=>{t>>>=0,o(t+24,m(t+8))},"syscall/js.valueGet":t=>{t>>>=0;const e=Reflect.get(n(t+8),m(t+16));t=this._inst.exports.getsp()>>>0,o(t+32,e)},"syscall/js.valueSet":t=>{t>>>=0,Reflect.set(n(t+8),m(t+16),n(t+32))},"syscall/js.valueDelete":t=>{t>>>=0,Reflect.deleteProperty(n(t+8),m(t+16))},"syscall/js.valueIndex":t=>{t>>>=0,o(t+24,Reflect.get(n(t+8),s(t+16)))},"syscall/js.valueSetIndex":t=>{t>>>=0,Reflect.set(n(t+8),s(t+16),n(t+24))},"syscall/js.valueCall":t=>{t>>>=0;try{const e=n(t+8),l=Reflect.get(e,m(t+16)),a=h(t+32),g=Reflect.apply(l,e,a);t=this._inst.exports.getsp()>>>0,o(t+56,g),this.mem.setUint8(t+64,1)}catch(e){t=this._inst.exports.getsp()>>>0,o(t+56,e),this.mem.setUint8(t+64,0)}},"syscall/js.valueInvoke":t=>{t>>>=0;try{const e=n(t+8),l=h(t+16),a=Reflect.apply(e,void 0,l);t=this._inst.exports.getsp()>>>0,o(t+40,a),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,o(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueNew":t=>{t>>>=0;try{const e=n(t+8),l=h(t+16),a=Reflect.construct(e,l);t=this._inst.exports.getsp()>>>0,o(t+40,a),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,o(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueLength":t=>{t>>>=0,c(t+16,parseInt(n(t+8).length))},"syscall/js.valuePrepareString":t=>{t>>>=0;const e=f.encode(String(n(t+8)));o(t+16,e),c(t+24,e.length)},"syscall/js.valueLoadString":t=>{t>>>=0;const e=n(t+8);u(t+16).set(e)},"syscall/js.valueInstanceOf":t=>{t>>>=0,this.mem.setUint8(t+24,n(t+8)instanceof n(t+16)?1:0)},"syscall/js.copyBytesToGo":t=>{t>>>=0;const e=u(t+8),l=n(t+32);if(!(l instanceof Uint8Array||l instanceof Uint8ClampedArray)){this.mem.setUint8(t+48,0);return}const a=l.subarray(0,e.length);e.set(a),c(t+40,a.length),this.mem.setUint8(t+48,1)},"syscall/js.copyBytesToJS":t=>{t>>>=0;const e=n(t+8),l=u(t+16);if(!(e instanceof Uint8Array||e instanceof Uint8ClampedArray)){this.mem.setUint8(t+48,0);return}const a=l.subarray(0,e.length);e.set(a),c(t+40,a.length),this.mem.setUint8(t+48,1)},debug:t=>{console.log(t)}}}}async run(c){if(!(c instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=c,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let i=4096;const s=d=>{const t=i,e=f.encode(d+"\0");return new Uint8Array(this.mem.buffer,i,e.length).set(e),i+=e.length,i%8!==0&&(i+=8-i%8),t},n=this.argv.length,o=[];this.argv.forEach(d=>{o.push(s(d))}),o.push(0),Object.keys(this.env).sort().forEach(d=>{o.push(s(`${d}=${this.env[d]}`))}),o.push(0);const h=i;if(o.forEach(d=>{this.mem.setUint32(i,d,!0),this.mem.setUint32(i+4,0,!0),i+=8}),i>=12288)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(n,h),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(c){const i=this;return function(){const s={id:c,this:this,args:arguments};return i._pendingEvent=s,i._resume(),s.result}}}})(),onmessage=({data:r})=>{let f=new TextDecoder,y=globalThis.fs,c="";y.writeSync=(u,h)=>{if(u===1)postMessage(h);else if(u===2){c+=f.decode(h);let m=c.split(`
- `);m.length>1&&console.log(m.slice(0,-1).join(`
- `)),c=m[m.length-1]}else throw new Error("Bad write");return h.length};let i=[],s,n=0;onmessage=({data:u})=>(u.length>0&&(i.push(u),s&&s()),o),y.read=(u,h,m,d,t,e)=>{if(u!==0||m!==0||d!==h.length||t!==null)throw new Error("Bad read");if(i.length===0){s=()=>y.read(u,h,m,d,t,e);return}let l=i[0],a=Math.max(0,Math.min(d,l.length-n));h.set(l.subarray(n,n+a),m),n+=a,n===l.length&&(i.shift(),n=0),e(null,a)};let o=new globalThis.Go;return o.argv=["","--service=0.25.1"],tryToInstantiateModule(r,o).then(u=>{postMessage(null),o.run(u)},u=>{postMessage(u)}),o};async function tryToInstantiateModule(r,f){if(r instanceof WebAssembly.Module)return WebAssembly.instantiate(r,f.importObject);const y=await fetch(r);if(!y.ok)throw new Error(`Failed to download ${JSON.stringify(r)}`);if("instantiateStreaming"in WebAssembly&&/^application\/wasm($|;)/i.test(y.headers.get("Content-Type")||""))return(await WebAssembly.instantiateStreaming(y,f.importObject)).instance;const c=await y.arrayBuffer();return(await WebAssembly.instantiate(c,f.importObject)).instance}return r=>onmessage(r);})(T=>i.onmessage({data:T})),j;i={onmessage:null,postMessage:T=>setTimeout(()=>{try{j=b({data:T})}catch(L){u(L)}}),terminate(){if(j)for(let T of j._scheduledTimeouts.values())clearTimeout(T)}}}let g,s,m=new Promise((b,j)=>{g=b,s=j});i.onmessage=({data:b})=>{i.onmessage=({data:j})=>U(j),b?s(b):g()},i.postMessage(t||new URL(e,location.href).toString());let{readFromStdout:U,service:F}=je({writeToStdin(b){i.postMessage(b)},isSync:!1,hasFS:!1,esbuild:ve});await m,be=()=>{i.terminate(),le=void 0,be=void 0,we=void 0},we={build:b=>new Promise((j,T)=>{l.then(T),F.buildOrContext({callName:"build",refs:null,options:b,isTTY:!1,defaultWD:"/",callback:(L,N)=>L?T(L):j(N)})}),context:b=>new Promise((j,T)=>{l.then(T),F.buildOrContext({callName:"context",refs:null,options:b,isTTY:!1,defaultWD:"/",callback:(L,N)=>L?T(L):j(N)})}),transform:(b,j)=>new Promise((T,L)=>{l.then(L),F.transform({callName:"transform",refs:null,input:b,options:j||{},isTTY:!1,fs:{readFile(N,S){S(new Error("Internal error"),null)},writeFile(N,S){S(null)}},callback:(N,S)=>N?L(N):T(S)})}),formatMessages:(b,j)=>new Promise((T,L)=>{l.then(L),F.formatMessages({callName:"formatMessages",refs:null,messages:b,options:j,callback:(N,S)=>N?L(N):T(S)})}),analyzeMetafile:(b,j)=>new Promise((T,L)=>{l.then(L),F.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof b=="string"?b:JSON.stringify(b),options:j,callback:(N,S)=>N?L(N):T(S)})})}},bt=ve;export{ct as analyzeMetafile,gt as analyzeMetafileSync,st as build,ft as buildSync,ot as context,bt as default,ut as formatMessages,pt as formatMessagesSync,yt as initialize,mt as stop,at as transform,dt as transformSync,lt as version};
|