phala 1.1.0-beta.10 → 1.1.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api/index.js CHANGED
@@ -1,45 +1,43 @@
1
1
  import { createRequire } from 'module';const require = createRequire(import.meta.url);
2
- var ti=Object.create;var mo=Object.defineProperty;var ri=Object.getOwnPropertyDescriptor;var oi=Object.getOwnPropertyNames;var ni=Object.getPrototypeOf,si=Object.prototype.hasOwnProperty;var we=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var E=(e,t)=>()=>(e&&(t=e(e=0)),t);var W=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ii=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of oi(t))!si.call(e,n)&&n!==r&&mo(e,n,{get:()=>t[n],enumerable:!(o=ri(t,n))||o.enumerable});return e};var ht=(e,t,r)=>(r=e!=null?ti(ni(e)):{},ii(t||!e||!e.__esModule?mo(r,"default",{value:e,enumerable:!0}):r,e));var xo=W((Ru,ho)=>{var Ze=1e3,Ye=Ze*60,Qe=Ye*60,je=Qe*24,ai=je*7,ci=je*365.25;ho.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return li(e);if(r==="number"&&isFinite(e))return t.long?ui(e):pi(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function li(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),o=(t[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return r*ci;case"weeks":case"week":case"w":return r*ai;case"days":case"day":case"d":return r*je;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Qe;case"minutes":case"minute":case"mins":case"min":case"m":return r*Ye;case"seconds":case"second":case"secs":case"sec":case"s":return r*Ze;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function pi(e){var t=Math.abs(e);return t>=je?Math.round(e/je)+"d":t>=Qe?Math.round(e/Qe)+"h":t>=Ye?Math.round(e/Ye)+"m":t>=Ze?Math.round(e/Ze)+"s":e+"ms"}function ui(e){var t=Math.abs(e);return t>=je?zt(e,t,je,"day"):t>=Qe?zt(e,t,Qe,"hour"):t>=Ye?zt(e,t,Ye,"minute"):t>=Ze?zt(e,t,Ze,"second"):e+" ms"}function zt(e,t,r,o){var n=t>=r*1.5;return Math.round(e/r)+" "+o+(n?"s":"")}});var _r=W((Uu,go)=>{function fi(e){r.debug=r,r.default=r,r.coerce=l,r.disable=i,r.enable=n,r.enabled=a,r.humanize=xo(),r.destroy=u,Object.keys(e).forEach(f=>{r[f]=e[f]}),r.names=[],r.skips=[],r.formatters={};function t(f){let p=0;for(let d=0;d<f.length;d++)p=(p<<5)-p+f.charCodeAt(d),p|=0;return r.colors[Math.abs(p)%r.colors.length]}r.selectColor=t;function r(f){let p,d=null,h,I;function T(...P){if(!T.enabled)return;let V=T,K=Number(new Date),O=K-(p||K);V.diff=O,V.prev=p,V.curr=K,p=K,P[0]=r.coerce(P[0]),typeof P[0]!="string"&&P.unshift("%O");let Q=0;P[0]=P[0].replace(/%([a-zA-Z%])/g,(te,Ut)=>{if(te==="%%")return"%";Q++;let fo=r.formatters[Ut];if(typeof fo=="function"){let ei=P[Q];te=fo.call(V,ei),P.splice(Q,1),Q--}return te}),r.formatArgs.call(V,P),(V.log||r.log).apply(V,P)}return T.namespace=f,T.useColors=r.useColors(),T.color=r.selectColor(f),T.extend=o,T.destroy=r.destroy,Object.defineProperty(T,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(h!==r.namespaces&&(h=r.namespaces,I=r.enabled(f)),I),set:P=>{d=P}}),typeof r.init=="function"&&r.init(T),T}function o(f,p){let d=r(this.namespace+(typeof p>"u"?":":p)+f);return d.log=this.log,d}function n(f){r.save(f),r.namespaces=f,r.names=[],r.skips=[];let p=(typeof f=="string"?f:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let d of p)d[0]==="-"?r.skips.push(d.slice(1)):r.names.push(d)}function s(f,p){let d=0,h=0,I=-1,T=0;for(;d<f.length;)if(h<p.length&&(p[h]===f[d]||p[h]==="*"))p[h]==="*"?(I=h,T=d,h++):(d++,h++);else if(I!==-1)h=I+1,T++,d=T;else return!1;for(;h<p.length&&p[h]==="*";)h++;return h===p.length}function i(){let f=[...r.names,...r.skips.map(p=>"-"+p)].join(",");return r.enable(""),f}function a(f){for(let p of r.skips)if(s(f,p))return!1;for(let p of r.names)if(s(f,p))return!0;return!1}function l(f){return f instanceof Error?f.stack||f.message:f}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}go.exports=fi});var bo=W((X,Ft)=>{X.formatArgs=di;X.save=hi;X.load=xi;X.useColors=mi;X.storage=gi();X.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();X.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function mi(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function di(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Ft.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(r++,n==="%c"&&(o=r))}),e.splice(o,0,t)}X.log=console.debug||console.log||(()=>{});function hi(e){try{e?X.storage.setItem("debug",e):X.storage.removeItem("debug")}catch{}}function xi(){let e;try{e=X.storage.getItem("debug")||X.storage.getItem("DEBUG")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function gi(){try{return localStorage}catch{}}Ft.exports=_r()(X);var{formatters:bi}=Ft.exports;bi.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var vo=W((zu,yo)=>{"use strict";yo.exports=(e,t=process.argv)=>{let r=e.startsWith("-")?"":e.length===1?"-":"--",o=t.indexOf(r+e),n=t.indexOf("--");return o!==-1&&(n===-1||o<n)}});var Co=W((Fu,_o)=>{"use strict";var yi=we("os"),wo=we("tty"),re=vo(),{env:z}=process,Ie;re("no-color")||re("no-colors")||re("color=false")||re("color=never")?Ie=0:(re("color")||re("colors")||re("color=true")||re("color=always"))&&(Ie=1);"FORCE_COLOR"in z&&(z.FORCE_COLOR==="true"?Ie=1:z.FORCE_COLOR==="false"?Ie=0:Ie=z.FORCE_COLOR.length===0?1:Math.min(parseInt(z.FORCE_COLOR,10),3));function Cr(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function kr(e,t){if(Ie===0)return 0;if(re("color=16m")||re("color=full")||re("color=truecolor"))return 3;if(re("color=256"))return 2;if(e&&!t&&Ie===void 0)return 0;let r=Ie||0;if(z.TERM==="dumb")return r;if(process.platform==="win32"){let o=yi.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in z)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(o=>o in z)||z.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in z)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(z.TEAMCITY_VERSION)?1:0;if(z.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in z){let o=parseInt((z.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(z.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(z.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(z.TERM)||"COLORTERM"in z?1:r}function vi(e){let t=kr(e,e&&e.isTTY);return Cr(t)}_o.exports={supportsColor:vi,stdout:Cr(kr(!0,wo.isatty(1))),stderr:Cr(kr(!0,wo.isatty(2)))}});var To=W((F,Ot)=>{var wi=we("tty"),Ht=we("util");F.init=Ii;F.log=Ti;F.formatArgs=Ci;F.save=Ei;F.load=Si;F.useColors=_i;F.destroy=Ht.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");F.colors=[6,2,3,4,5,1];try{let e=Co();e&&(e.stderr||e).level>=2&&(F.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}F.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let r=t.substring(6).toLowerCase().replace(/_([a-z])/g,(n,s)=>s.toUpperCase()),o=process.env[t];return/^(yes|on|true|enabled)$/i.test(o)?o=!0:/^(no|off|false|disabled)$/i.test(o)?o=!1:o==="null"?o=null:o=Number(o),e[r]=o,e},{});function _i(){return"colors"in F.inspectOpts?!!F.inspectOpts.colors:wi.isatty(process.stderr.fd)}function Ci(e){let{namespace:t,useColors:r}=this;if(r){let o=this.color,n="\x1B[3"+(o<8?o:"8;5;"+o),s=` ${n};1m${t} \x1B[0m`;e[0]=s+e[0].split(`
2
+ var oi=Object.create;var ho=Object.defineProperty;var ni=Object.getOwnPropertyDescriptor;var si=Object.getOwnPropertyNames;var ii=Object.getPrototypeOf,ai=Object.prototype.hasOwnProperty;var we=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var E=(e,t)=>()=>(e&&(t=e(e=0)),t);var W=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ci=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of si(t))!ai.call(e,n)&&n!==r&&ho(e,n,{get:()=>t[n],enumerable:!(o=ni(t,n))||o.enumerable});return e};var ht=(e,t,r)=>(r=e!=null?oi(ii(e)):{},ci(t||!e||!e.__esModule?ho(r,"default",{value:e,enumerable:!0}):r,e));var go=W((zu,xo)=>{var Je=1e3,Ze=Je*60,Ye=Ze*60,je=Ye*24,li=je*7,pi=je*365.25;xo.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return ui(e);if(r==="number"&&isFinite(e))return t.long?mi(e):fi(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function ui(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),o=(t[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return r*pi;case"weeks":case"week":case"w":return r*li;case"days":case"day":case"d":return r*je;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Ye;case"minutes":case"minute":case"mins":case"min":case"m":return r*Ze;case"seconds":case"second":case"secs":case"sec":case"s":return r*Je;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function fi(e){var t=Math.abs(e);return t>=je?Math.round(e/je)+"d":t>=Ye?Math.round(e/Ye)+"h":t>=Ze?Math.round(e/Ze)+"m":t>=Je?Math.round(e/Je)+"s":e+"ms"}function mi(e){var t=Math.abs(e);return t>=je?Ut(e,t,je,"day"):t>=Ye?Ut(e,t,Ye,"hour"):t>=Ze?Ut(e,t,Ze,"minute"):t>=Je?Ut(e,t,Je,"second"):e+" ms"}function Ut(e,t,r,o){var n=t>=r*1.5;return Math.round(e/r)+" "+o+(n?"s":"")}});var wr=W((Hu,bo)=>{function di(e){r.debug=r,r.default=r,r.coerce=l,r.disable=i,r.enable=n,r.enabled=a,r.humanize=go(),r.destroy=u,Object.keys(e).forEach(f=>{r[f]=e[f]}),r.names=[],r.skips=[],r.formatters={};function t(f){let p=0;for(let d=0;d<f.length;d++)p=(p<<5)-p+f.charCodeAt(d),p|=0;return r.colors[Math.abs(p)%r.colors.length]}r.selectColor=t;function r(f){let p,d=null,h,I;function T(...P){if(!T.enabled)return;let V=T,K=Number(new Date),O=K-(p||K);V.diff=O,V.prev=p,V.curr=K,p=K,P[0]=r.coerce(P[0]),typeof P[0]!="string"&&P.unshift("%O");let Q=0;P[0]=P[0].replace(/%([a-zA-Z%])/g,(te,Rt)=>{if(te==="%%")return"%";Q++;let mo=r.formatters[Rt];if(typeof mo=="function"){let ri=P[Q];te=mo.call(V,ri),P.splice(Q,1),Q--}return te}),r.formatArgs.call(V,P),(V.log||r.log).apply(V,P)}return T.namespace=f,T.useColors=r.useColors(),T.color=r.selectColor(f),T.extend=o,T.destroy=r.destroy,Object.defineProperty(T,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(h!==r.namespaces&&(h=r.namespaces,I=r.enabled(f)),I),set:P=>{d=P}}),typeof r.init=="function"&&r.init(T),T}function o(f,p){let d=r(this.namespace+(typeof p>"u"?":":p)+f);return d.log=this.log,d}function n(f){r.save(f),r.namespaces=f,r.names=[],r.skips=[];let p=(typeof f=="string"?f:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let d of p)d[0]==="-"?r.skips.push(d.slice(1)):r.names.push(d)}function s(f,p){let d=0,h=0,I=-1,T=0;for(;d<f.length;)if(h<p.length&&(p[h]===f[d]||p[h]==="*"))p[h]==="*"?(I=h,T=d,h++):(d++,h++);else if(I!==-1)h=I+1,T++,d=T;else return!1;for(;h<p.length&&p[h]==="*";)h++;return h===p.length}function i(){let f=[...r.names,...r.skips.map(p=>"-"+p)].join(",");return r.enable(""),f}function a(f){for(let p of r.skips)if(s(f,p))return!1;for(let p of r.names)if(s(f,p))return!0;return!1}function l(f){return f instanceof Error?f.stack||f.message:f}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}bo.exports=di});var yo=W((X,zt)=>{X.formatArgs=xi;X.save=gi;X.load=bi;X.useColors=hi;X.storage=yi();X.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();X.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function hi(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function xi(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+zt.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(r++,n==="%c"&&(o=r))}),e.splice(o,0,t)}X.log=console.debug||console.log||(()=>{});function gi(e){try{e?X.storage.setItem("debug",e):X.storage.removeItem("debug")}catch{}}function bi(){let e;try{e=X.storage.getItem("debug")||X.storage.getItem("DEBUG")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function yi(){try{return localStorage}catch{}}zt.exports=wr()(X);var{formatters:vi}=zt.exports;vi.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var wo=W((Fu,vo)=>{"use strict";vo.exports=(e,t=process.argv)=>{let r=e.startsWith("-")?"":e.length===1?"-":"--",o=t.indexOf(r+e),n=t.indexOf("--");return o!==-1&&(n===-1||o<n)}});var ko=W((Ou,Co)=>{"use strict";var wi=we("os"),_o=we("tty"),re=wo(),{env:z}=process,Ie;re("no-color")||re("no-colors")||re("color=false")||re("color=never")?Ie=0:(re("color")||re("colors")||re("color=true")||re("color=always"))&&(Ie=1);"FORCE_COLOR"in z&&(z.FORCE_COLOR==="true"?Ie=1:z.FORCE_COLOR==="false"?Ie=0:Ie=z.FORCE_COLOR.length===0?1:Math.min(parseInt(z.FORCE_COLOR,10),3));function _r(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Cr(e,t){if(Ie===0)return 0;if(re("color=16m")||re("color=full")||re("color=truecolor"))return 3;if(re("color=256"))return 2;if(e&&!t&&Ie===void 0)return 0;let r=Ie||0;if(z.TERM==="dumb")return r;if(process.platform==="win32"){let o=wi.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in z)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(o=>o in z)||z.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in z)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(z.TEAMCITY_VERSION)?1:0;if(z.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in z){let o=parseInt((z.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(z.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(z.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(z.TERM)||"COLORTERM"in z?1:r}function _i(e){let t=Cr(e,e&&e.isTTY);return _r(t)}Co.exports={supportsColor:_i,stdout:_r(Cr(!0,_o.isatty(1))),stderr:_r(Cr(!0,_o.isatty(2)))}});var Eo=W((H,Ft)=>{var Ci=we("tty"),Ht=we("util");H.init=Pi;H.log=Si;H.formatArgs=Ti;H.save=Ii;H.load=Ai;H.useColors=ki;H.destroy=Ht.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");H.colors=[6,2,3,4,5,1];try{let e=ko();e&&(e.stderr||e).level>=2&&(H.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}H.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let r=t.substring(6).toLowerCase().replace(/_([a-z])/g,(n,s)=>s.toUpperCase()),o=process.env[t];return/^(yes|on|true|enabled)$/i.test(o)?o=!0:/^(no|off|false|disabled)$/i.test(o)?o=!1:o==="null"?o=null:o=Number(o),e[r]=o,e},{});function ki(){return"colors"in H.inspectOpts?!!H.inspectOpts.colors:Ci.isatty(process.stderr.fd)}function Ti(e){let{namespace:t,useColors:r}=this;if(r){let o=this.color,n="\x1B[3"+(o<8?o:"8;5;"+o),s=` ${n};1m${t} \x1B[0m`;e[0]=s+e[0].split(`
3
3
  `).join(`
4
- `+s),e.push(n+"m+"+Ot.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=ki()+t+" "+e[0]}function ki(){return F.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Ti(...e){return process.stderr.write(Ht.formatWithOptions(F.inspectOpts,...e)+`
5
- `)}function Ei(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function Si(){return process.env.DEBUG}function Ii(e){e.inspectOpts={};let t=Object.keys(F.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=F.inspectOpts[t[r]]}Ot.exports=_r()(F);var{formatters:ko}=Ot.exports;ko.o=function(e){return this.inspectOpts.colors=this.useColors,Ht.inspect(e,this.inspectOpts).split(`
6
- `).map(t=>t.trim()).join(" ")};ko.O=function(e){return this.inspectOpts.colors=this.useColors,Ht.inspect(e,this.inspectOpts)}});var Eo=W((Hu,Tr)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Tr.exports=bo():Tr.exports=To()});var Er,Io=E(()=>{Er="2.38.6"});function Ao(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?Ao(e.cause,t):t?null:e}var Sr,g,oe=E(()=>{Io();Sr={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${Er}`},g=class extends Error{constructor(t,r={}){let o=(()=>r.cause instanceof g?r.cause.details:r.cause?.message?r.cause.message:r.details)(),n=(()=>r.cause instanceof g&&r.cause.docsPath||r.docsPath)(),s=Sr.getDocsUrl?.({...r,docsPath:n}),i=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...o?[`Details: ${o}`]:[],...Sr.version?[`Version: ${Sr.version}`]:[]].join(`
7
- `);super(i,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=o,this.docsPath=n,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=t,this.version=Er}walk(t){return Ao(this,t)}}});var jt,Nt,Ir=E(()=>{oe();jt=class extends g{constructor({max:t,min:r,signed:o,size:n,value:s}){super(`Number "${s}" is not in safe ${n?`${n*8}-bit ${o?"signed":"unsigned"} `:""}integer range ${t?`(${r} to ${t})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}},Nt=class extends g{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}});function de(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}var et=E(()=>{});function ne(e){return de(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}var xt=E(()=>{et()});function gt(e,{dir:t="left"}={}){let r=typeof e=="string"?e.replace("0x",""):e,o=0;for(let n=0;n<r.length-1&&r[t==="left"?n:r.length-n-1].toString()==="0";n++)o++;return r=t==="left"?r.slice(o):r.slice(0,r.length-o),typeof e=="string"?(r.length===1&&t==="right"&&(r=`${r}0`),`0x${r.length%2===1?`0${r}`:r}`):r}var Po=E(()=>{});var bt,yt,Ar=E(()=>{oe();bt=class extends g{constructor({offset:t,position:r,size:o}){super(`Slice ${r==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${o}).`,{name:"SliceOffsetOutOfBoundsError"})}},yt=class extends g{constructor({size:t,targetSize:r,type:o}){super(`${o.charAt(0).toUpperCase()}${o.slice(1).toLowerCase()} size (${t}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}});function Ae(e,{dir:t,size:r=32}={}){return typeof e=="string"?Ai(e,{dir:t,size:r}):Pi(e,{dir:t,size:r})}function Ai(e,{dir:t,size:r=32}={}){if(r===null)return e;let o=e.replace("0x","");if(o.length>r*2)throw new yt({size:Math.ceil(o.length/2),targetSize:r,type:"hex"});return`0x${o[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function Pi(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new yt({size:e.length,targetSize:r,type:"bytes"});let o=new Uint8Array(r);for(let n=0;n<r;n++){let s=t==="right";o[s?n:r-n-1]=e[s?n:e.length-n-1]}return o}var Pr=E(()=>{Ar()});function le(e,t={}){return typeof e=="number"||typeof e=="bigint"?_(e,t):typeof e=="string"?Ri(e,t):typeof e=="boolean"?Li(e,t):J(e,t)}function Li(e,t={}){let r=`0x${Number(e)}`;return typeof t.size=="number"?(Pe(r,{size:t.size}),Ae(r,{size:t.size})):r}function J(e,t={}){let r="";for(let n=0;n<e.length;n++)r+=Bi[e[n]];let o=`0x${r}`;return typeof t.size=="number"?(Pe(o,{size:t.size}),Ae(o,{dir:"right",size:t.size})):o}function _(e,t={}){let{signed:r,size:o}=t,n=BigInt(e),s;o?r?s=(1n<<BigInt(o)*8n-1n)-1n:s=2n**(BigInt(o)*8n)-1n:typeof e=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));let i=typeof s=="bigint"&&r?-s-1n:0;if(s&&n>s||n<i){let l=typeof e=="bigint"?"n":"";throw new jt({max:s?`${s}${l}`:void 0,min:`${i}${l}`,signed:r,size:o,value:`${e}${l}`})}let a=`0x${(r&&n<0?(1n<<BigInt(o*8))+BigInt(n):n).toString(16)}`;return o?Ae(a,{size:o}):a}function Ri(e,t={}){let r=$i.encode(e);return J(r,t)}var Bi,$i,se=E(()=>{Ir();Pr();Ge();Bi=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));$i=new TextEncoder});function Gt(e,t={}){return typeof e=="number"||typeof e=="bigint"?Fi(e,t):typeof e=="boolean"?zi(e,t):de(e)?pe(e,t):Br(e,t)}function zi(e,t={}){let r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(Pe(r,{size:t.size}),Ae(r,{size:t.size})):r}function Bo(e){if(e>=_e.zero&&e<=_e.nine)return e-_e.zero;if(e>=_e.A&&e<=_e.F)return e-(_e.A-10);if(e>=_e.a&&e<=_e.f)return e-(_e.a-10)}function pe(e,t={}){let r=e;t.size&&(Pe(r,{size:t.size}),r=Ae(r,{dir:"right",size:t.size}));let o=r.slice(2);o.length%2&&(o=`0${o}`);let n=o.length/2,s=new Uint8Array(n);for(let i=0,a=0;i<n;i++){let l=Bo(o.charCodeAt(a++)),u=Bo(o.charCodeAt(a++));if(l===void 0||u===void 0)throw new g(`Invalid byte sequence ("${o[a-2]}${o[a-1]}" in "${o}").`);s[i]=l*16+u}return s}function Fi(e,t){let r=_(e,t);return pe(r)}function Br(e,t={}){let r=Ui.encode(e);return typeof t.size=="number"?(Pe(r,{size:t.size}),Ae(r,{dir:"right",size:t.size})):r}var Ui,_e,Be=E(()=>{oe();et();Pr();Ge();se();Ui=new TextEncoder;_e={zero:48,nine:57,A:65,F:70,a:97,f:102}});function Pe(e,{size:t}){if(ne(e)>t)throw new Nt({givenSize:ne(e),maxSize:t})}function De(e,t={}){let{signed:r}=t;t.size&&Pe(e,{size:t.size});let o=BigInt(e);if(!r)return o;let n=(e.length-2)/2,s=(1n<<BigInt(n)*8n-1n)-1n;return o<=s?o:o-BigInt(`0x${"f".padStart(n*2,"f")}`)-1n}function Me(e,t={}){return Number(De(e,t))}var Ge=E(()=>{Ir();xt()});function tt(e,t){return({exclude:r,format:o})=>({exclude:r,format:(n,s)=>{let i=t(n,s);if(r)for(let a of r)delete i[a];return{...i,...o(n,s)}},type:e})}var Dt=E(()=>{});var If,Af,Pf,Bf,Lf,$f,Rf,Uf,zf,Ff,Hf,Of,jf,Nf,Gf,Df,Mf,qf,Vf,Kf,Wf,Xf,Jf,Zf,Yf,Qf,em,tm,rm,om,nm,sm,im,am,cm,lm,pm,um,fm,mm,dm,hm,xm,gm,bm,ym,vm,wm,_m,Cm,km,Tm,Em,Sm,Im,Am,Pm,Bm,Lm,$m,Rm,Um,zm,Fm,Hm,Om,jm,Nm,Gm,Dm,Mm,qm,Vm,Km,Wm,Xm,Jm,Zm,Ym,Qm,ed,td,rd,od,nd,sd,id,ad,cd,ld,pd,ud,fd,md,dd,Mt,zo=E(()=>{If=2n**(8n-1n)-1n,Af=2n**(16n-1n)-1n,Pf=2n**(24n-1n)-1n,Bf=2n**(32n-1n)-1n,Lf=2n**(40n-1n)-1n,$f=2n**(48n-1n)-1n,Rf=2n**(56n-1n)-1n,Uf=2n**(64n-1n)-1n,zf=2n**(72n-1n)-1n,Ff=2n**(80n-1n)-1n,Hf=2n**(88n-1n)-1n,Of=2n**(96n-1n)-1n,jf=2n**(104n-1n)-1n,Nf=2n**(112n-1n)-1n,Gf=2n**(120n-1n)-1n,Df=2n**(128n-1n)-1n,Mf=2n**(136n-1n)-1n,qf=2n**(144n-1n)-1n,Vf=2n**(152n-1n)-1n,Kf=2n**(160n-1n)-1n,Wf=2n**(168n-1n)-1n,Xf=2n**(176n-1n)-1n,Jf=2n**(184n-1n)-1n,Zf=2n**(192n-1n)-1n,Yf=2n**(200n-1n)-1n,Qf=2n**(208n-1n)-1n,em=2n**(216n-1n)-1n,tm=2n**(224n-1n)-1n,rm=2n**(232n-1n)-1n,om=2n**(240n-1n)-1n,nm=2n**(248n-1n)-1n,sm=2n**(256n-1n)-1n,im=-(2n**(8n-1n)),am=-(2n**(16n-1n)),cm=-(2n**(24n-1n)),lm=-(2n**(32n-1n)),pm=-(2n**(40n-1n)),um=-(2n**(48n-1n)),fm=-(2n**(56n-1n)),mm=-(2n**(64n-1n)),dm=-(2n**(72n-1n)),hm=-(2n**(80n-1n)),xm=-(2n**(88n-1n)),gm=-(2n**(96n-1n)),bm=-(2n**(104n-1n)),ym=-(2n**(112n-1n)),vm=-(2n**(120n-1n)),wm=-(2n**(128n-1n)),_m=-(2n**(136n-1n)),Cm=-(2n**(144n-1n)),km=-(2n**(152n-1n)),Tm=-(2n**(160n-1n)),Em=-(2n**(168n-1n)),Sm=-(2n**(176n-1n)),Im=-(2n**(184n-1n)),Am=-(2n**(192n-1n)),Pm=-(2n**(200n-1n)),Bm=-(2n**(208n-1n)),Lm=-(2n**(216n-1n)),$m=-(2n**(224n-1n)),Rm=-(2n**(232n-1n)),Um=-(2n**(240n-1n)),zm=-(2n**(248n-1n)),Fm=-(2n**(256n-1n)),Hm=2n**8n-1n,Om=2n**16n-1n,jm=2n**24n-1n,Nm=2n**32n-1n,Gm=2n**40n-1n,Dm=2n**48n-1n,Mm=2n**56n-1n,qm=2n**64n-1n,Vm=2n**72n-1n,Km=2n**80n-1n,Wm=2n**88n-1n,Xm=2n**96n-1n,Jm=2n**104n-1n,Zm=2n**112n-1n,Ym=2n**120n-1n,Qm=2n**128n-1n,ed=2n**136n-1n,td=2n**144n-1n,rd=2n**152n-1n,od=2n**160n-1n,nd=2n**168n-1n,sd=2n**176n-1n,id=2n**184n-1n,ad=2n**192n-1n,cd=2n**200n-1n,ld=2n**208n-1n,pd=2n**216n-1n,ud=2n**224n-1n,fd=2n**232n-1n,md=2n**240n-1n,dd=2n**248n-1n,Mt=2n**256n-1n});function qe(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}var $r=E(()=>{});var wt,qt,Vt,Fo=E(()=>{oe();wt=class extends g{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}},qt=class extends g{constructor({length:t,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}},Vt=class extends g{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}});function Kt(e,{recursiveReadLimit:t=8192}={}){let r=Object.create(Gi);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}var Gi,Rr=E(()=>{Fo();Gi={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new Vt({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new qt({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new wt({offset:e});let t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new wt({offset:e});let t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){let t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){let r=t??this.position;return this.assertPosition(r+e-1),this.bytes.subarray(r,r+e)},inspectUint8(e){let t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){let t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){let t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){let t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,e&255),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();let e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();let r=this.inspectBytes(e);return this.position+=t??e,r},readUint8(){this.assertReadLimit(),this._touch();let e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();let e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();let e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();let e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){let t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;let e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}}});var jo,No=E(()=>{jo={ether:-9,wei:9}});function Go(e,t){let r=e.toString(),o=r.startsWith("-");o&&(r=r.slice(1)),r=r.padStart(t,"0");let[n,s]=[r.slice(0,r.length-t),r.slice(r.length-t)];return s=s.replace(/(0+)$/,""),`${o?"-":""}${n||"0"}${s?`.${s}`:""}`}var Do=E(()=>{});function _t(e,t="wei"){return Go(e,jo[t])}var Mo=E(()=>{No();Do()});function qi(e){let t=Object.entries(e).map(([o,n])=>n===void 0||n===!1?null:[o,n]).filter(Boolean),r=t.reduce((o,[n])=>Math.max(o,n.length),0);return t.map(([o,n])=>` ${`${o}:`.padEnd(r+1)} ${n}`).join(`
8
- `)}var Wt,Xt,Jt,Zt=E(()=>{oe();Wt=class extends g{constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}},Xt=class extends g{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",qi(t),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}},Jt=class extends g{constructor({storageKey:t}){super(`Size for storage key "${t}" is invalid. Expected 32 bytes. Got ${Math.floor((t.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}});function Vi(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ur(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ve(e,...t){if(!Vi(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function nt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function er(e,t){Ve(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Vo(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Le(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function tr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ue(e,t){return e<<32-t|e>>>t}function Wi(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Xi(e){for(let t=0;t<e.length;t++)e[t]=Wi(e[t]);return e}function Ji(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Ct(e){return typeof e=="string"&&(e=Ji(e)),Ve(e),e}function rr(e){let t=o=>e().update(Ct(o)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}var Ki,zr,ot,or=E(()=>{Ki=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();zr=Ki?e=>e:Xi;ot=class{}});function Yi(e,t=!1){return t?{h:Number(e&sr),l:Number(e>>Xo&sr)}:{h:Number(e>>Xo&sr)|0,l:Number(e&sr)|0}}function Jo(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=Yi(e[s],t);[o[s],n[s]]=[i,a]}return[o,n]}var sr,Xo,Zo,Yo,Qo,en,tn=E(()=>{sr=BigInt(4294967295),Xo=BigInt(32);Zo=(e,t,r)=>e<<r|t>>>32-r,Yo=(e,t,r)=>t<<r|e>>>32-r,Qo=(e,t,r)=>t<<r-32|e>>>64-r,en=(e,t,r)=>e<<r-32|t>>>64-r});var ie,pr=E(()=>{oe();ie=class extends g{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}});var Ke,pn=E(()=>{oe();Ke=class extends g{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}});var ur,We,Fr,Hr,Or,jr,Nr,Gr,Dr,Mr,kt,un=E(()=>{Mo();oe();ur=class extends g{constructor({cause:t,message:r}={}){let o=r?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${o?`with reason: ${o}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"})}};Object.defineProperty(ur,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(ur,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});We=class extends g{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${_t(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}};Object.defineProperty(We,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});Fr=class extends g{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${_t(r)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}};Object.defineProperty(Fr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});Hr=class extends g{constructor({cause:t,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}is higher than the next one expected.`,{cause:t,name:"NonceTooHighError"})}};Object.defineProperty(Hr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});Or=class extends g{constructor({cause:t,nonce:r}={}){super([`Nonce provided for the transaction ${r?`(${r}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
9
- `),{cause:t,name:"NonceTooLowError"})}};Object.defineProperty(Or,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});jr=class extends g{constructor({cause:t,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}exceeds the maximum allowed nonce.`,{cause:t,name:"NonceMaxValueError"})}};Object.defineProperty(jr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});Nr=class extends g{constructor({cause:t}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
10
- `),{cause:t,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}};Object.defineProperty(Nr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});Gr=class extends g{constructor({cause:t,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:t,name:"IntrinsicGasTooHighError"})}};Object.defineProperty(Gr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});Dr=class extends g{constructor({cause:t,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction is too low.`,{cause:t,name:"IntrinsicGasTooLowError"})}};Object.defineProperty(Dr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});Mr=class extends g{constructor({cause:t}){super("The transaction type is not supported for this chain.",{cause:t,name:"TransactionTypeNotSupportedError"})}};Object.defineProperty(Mr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});kt=class extends g{constructor({cause:t,maxPriorityFeePerGas:r,maxFeePerGas:o}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${_t(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${o?` = ${_t(o)} gwei`:""}).`].join(`
11
- `),{cause:t,name:"TipAboveFeeCapError"})}};Object.defineProperty(kt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/})});var it,qr=E(()=>{it=class extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){let r=super.get(t);return super.has(t)&&r!==void 0&&(this.delete(t),super.set(t,r)),r}set(t,r){if(super.set(t,r),this.maxSize&&this.size>this.maxSize){let o=this.keys().next().value;o&&this.delete(o)}return this}}});function la(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let i=0;i<10;i++)r[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){let a=(i+8)%10,l=(i+2)%10,u=r[l],f=r[l+1],p=fn(u,f,1)^r[a],d=mn(u,f,1)^r[a+1];for(let h=0;h<50;h+=10)e[i+h]^=p,e[i+h+1]^=d}let n=e[2],s=e[3];for(let i=0;i<24;i++){let a=hn[i],l=fn(n,s,a),u=mn(n,s,a),f=dn[i];n=e[f],s=e[f+1],e[f]=l,e[f+1]=u}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)r[a]=e[i+a];for(let a=0;a<10;a++)e[i+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=aa[o],e[1]^=ca[o]}Le(r)}var ra,Tt,oa,na,sa,ia,dn,hn,xn,gn,aa,ca,fn,mn,Et,pa,bn,yn=E(()=>{tn();or();ra=BigInt(0),Tt=BigInt(1),oa=BigInt(2),na=BigInt(7),sa=BigInt(256),ia=BigInt(113),dn=[],hn=[],xn=[];for(let e=0,t=Tt,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],dn.push(2*(5*o+r)),hn.push((e+1)*(e+2)/2%64);let n=ra;for(let s=0;s<7;s++)t=(t<<Tt^(t>>na)*ia)%sa,t&oa&&(n^=Tt<<(Tt<<BigInt(s))-Tt);xn.push(n)}gn=Jo(xn,!0),aa=gn[0],ca=gn[1],fn=(e,t,r)=>r>32?Qo(e,t,r):Zo(e,t,r),mn=(e,t,r)=>r>32?en(e,t,r):Yo(e,t,r);Et=class extends ot{constructor(t,r,o,n=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=r,this.outputLen=o,this.enableXOF=n,this.rounds=s,Ur(o),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Vo(this.state)}clone(){return this._cloneInto()}keccak(){zr(this.state32),la(this.state32,this.rounds),zr(this.state32),this.posOut=0,this.pos=0}update(t){nt(this),t=Ct(t),Ve(t);let{blockLen:r,state:o}=this,n=t.length;for(let s=0;s<n;){let i=Math.min(r-this.pos,n-s);for(let a=0;a<i;a++)o[this.pos++]^=t[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:r,pos:o,blockLen:n}=this;t[o]^=r,r&128&&o===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){nt(this,!1),Ve(t),this.finish();let r=this.state,{blockLen:o}=this;for(let n=0,s=t.length;n<s;){this.posOut>=o&&this.keccak();let i=Math.min(o-this.posOut,s-n);t.set(r.subarray(this.posOut,this.posOut+i),n),this.posOut+=i,n+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Ur(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(er(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Le(this.state)}_cloneInto(t){let{blockLen:r,suffix:o,outputLen:n,rounds:s,enableXOF:i}=this;return t||(t=new Et(r,o,n,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=o,t.outputLen=n,t.enableXOF=i,t.destroyed=this.destroyed,t}},pa=(e,t,r)=>rr(()=>new Et(t,e,r)),bn=(()=>pa(1,136,256/8))()});function vn(e,t){let r=t||"hex",o=bn(de(e,{strict:!1})?Gt(e):e);return r==="bytes"?o:le(o)}var wn=E(()=>{yn();et();Be();se()});function _n(e,t){if(Vr.has(`${e}.${t}`))return Vr.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),o=vn(Br(r),"bytes"),n=(t?r.substring(`${t}0x`.length):r).split("");for(let i=0;i<40;i+=2)o[i>>1]>>4>=8&&n[i]&&(n[i]=n[i].toUpperCase()),(o[i>>1]&15)>=8&&n[i+1]&&(n[i+1]=n[i+1].toUpperCase());let s=`0x${n.join("")}`;return Vr.set(`${e}.${t}`,s),s}var Vr,Cn=E(()=>{Be();wn();qr();Vr=new it(8192)});function he(e,t){let{strict:r=!0}=t??{},o=`${e}.${r}`;if(Kr.has(o))return Kr.get(o);let n=(()=>ua.test(e)?e.toLowerCase()===e?!0:r?_n(e)===e:!0:!1)();return Kr.set(o,n),n}var ua,Kr,fr=E(()=>{qr();Cn();ua=/^0x[a-fA-F0-9]{40}$/,Kr=new it(8192)});function kn(e,t,r,{strict:o}={}){return de(e,{strict:!1})?ma(e,t,r,{strict:o}):fa(e,t,r,{strict:o})}function Tn(e,t){if(typeof t=="number"&&t>0&&t>ne(e)-1)throw new bt({offset:t,position:"start",size:ne(e)})}function En(e,t,r){if(typeof t=="number"&&typeof r=="number"&&ne(e)!==r-t)throw new bt({offset:r,position:"end",size:ne(e)})}function fa(e,t,r,{strict:o}={}){Tn(e,t);let n=e.slice(t,r);return o&&En(n,t,r),n}function ma(e,t,r,{strict:o}={}){Tn(e,t);let n=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return o&&En(n,t,r),n}var Sn=E(()=>{Ar();et();xt()});var Zr=W(Pt=>{"use strict";var ka=Pt&&Pt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Pt,"__esModule",{value:!0});Pt.encryptEnvVars=Sa;var Xr=we("@noble/curves/ed25519"),Jr=ka(we("crypto"));function Ta(e){var t,r;return e=e.startsWith("0x")?e.slice(2):e,new Uint8Array((r=(t=e.match(/.{1,2}/g))===null||t===void 0?void 0:t.map(o=>parseInt(o,16)))!==null&&r!==void 0?r:[])}function Ea(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Sa(e,t){let r=JSON.stringify({env:e}),o=Xr.x25519.utils.randomPrivateKey(),n=Xr.x25519.getPublicKey(o),s=Ta(t),i=Xr.x25519.getSharedSecret(o,s),a=await Jr.default.subtle.importKey("raw",i,{name:"AES-GCM",length:256},!0,["encrypt"]),l=Jr.default.getRandomValues(new Uint8Array(12)),u=await Jr.default.subtle.encrypt({name:"AES-GCM",iv:l},a,new TextEncoder().encode(r)),f=new Uint8Array(n.length+l.length+u.byteLength);return f.set(n),f.set(l,n.length),f.set(new Uint8Array(u),n.length+l.length),Ea(f)}});var Fn=W(Bt=>{"use strict";var Ia=Bt&&Bt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Bt,"__esModule",{value:!0});Bt.getComposeHash=La;var Aa=Ia(we("crypto"));function Yr(e){return e==null?e:Array.isArray(e)?e.map(Yr):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let o=e[r];return t[r]=Yr(o),t},{}):e}function Pa(e){let t={...e};return t.runner==="bash"&&"docker_compose_file"in t?delete t.docker_compose_file:t.runner==="docker-compose"&&"bash_script"in t&&delete t.bash_script,"pre_launch_script"in t&&!t.pre_launch_script&&delete t.pre_launch_script,t}function Ba(e){let t=Yr(e);return JSON.stringify(t,(r,o)=>typeof o=="number"&&(isNaN(o)||!isFinite(o))?null:o)}function La(e,t=!1){t&&(e=Pa(e));let r=Ba(e);return Aa.default.createHash("sha256").update(r,"utf8").digest("hex")}});var ss=W(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.toBig=y.shrSL=y.shrSH=y.rotrSL=y.rotrSH=y.rotrBL=y.rotrBH=y.rotr32L=y.rotr32H=y.rotlSL=y.rotlSH=y.rotlBL=y.rotlBH=y.add5L=y.add5H=y.add4L=y.add4H=y.add3L=y.add3H=void 0;y.add=Yn;y.fromBig=eo;y.split=Hn;var xr=BigInt(2**32-1),Qr=BigInt(32);function eo(e,t=!1){return t?{h:Number(e&xr),l:Number(e>>Qr&xr)}:{h:Number(e>>Qr&xr)|0,l:Number(e&xr)|0}}function Hn(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=eo(e[s],t);[o[s],n[s]]=[i,a]}return[o,n]}var On=(e,t)=>BigInt(e>>>0)<<Qr|BigInt(t>>>0);y.toBig=On;var jn=(e,t,r)=>e>>>r;y.shrSH=jn;var Nn=(e,t,r)=>e<<32-r|t>>>r;y.shrSL=Nn;var Gn=(e,t,r)=>e>>>r|t<<32-r;y.rotrSH=Gn;var Dn=(e,t,r)=>e<<32-r|t>>>r;y.rotrSL=Dn;var Mn=(e,t,r)=>e<<64-r|t>>>r-32;y.rotrBH=Mn;var qn=(e,t,r)=>e>>>r-32|t<<64-r;y.rotrBL=qn;var Vn=(e,t)=>t;y.rotr32H=Vn;var Kn=(e,t)=>e;y.rotr32L=Kn;var Wn=(e,t,r)=>e<<r|t>>>32-r;y.rotlSH=Wn;var Xn=(e,t,r)=>t<<r|e>>>32-r;y.rotlSL=Xn;var Jn=(e,t,r)=>t<<r-32|e>>>64-r;y.rotlBH=Jn;var Zn=(e,t,r)=>e<<r-32|t>>>64-r;y.rotlBL=Zn;function Yn(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/2**32|0)|0,l:n|0}}var Qn=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);y.add3L=Qn;var es=(e,t,r,o)=>t+r+o+(e/2**32|0)|0;y.add3H=es;var ts=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0);y.add4L=ts;var rs=(e,t,r,o,n)=>t+r+o+n+(e/2**32|0)|0;y.add4H=rs;var os=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0);y.add5L=os;var ns=(e,t,r,o,n,s)=>t+r+o+n+s+(e/2**32|0)|0;y.add5H=ns;var $a={fromBig:eo,split:Hn,toBig:On,shrSH:jn,shrSL:Nn,rotrSH:Gn,rotrSL:Dn,rotrBH:Mn,rotrBL:qn,rotr32H:Vn,rotr32L:Kn,rotlSH:Wn,rotlSL:Xn,rotlBH:Jn,rotlBL:Zn,add:Yn,add3L:Qn,add3H:es,add4L:ts,add4H:rs,add5H:ns,add5L:os};y.default=$a});var is=W(gr=>{"use strict";Object.defineProperty(gr,"__esModule",{value:!0});gr.crypto=void 0;var Re=we("node:crypto");gr.crypto=Re&&typeof Re=="object"&&"webcrypto"in Re?Re.webcrypto:Re&&typeof Re=="object"&&"randomBytes"in Re?Re:void 0});var ds=W(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.wrapXOFConstructorWithOpts=x.wrapConstructorWithOpts=x.wrapConstructor=x.Hash=x.nextTick=x.swap32IfBE=x.byteSwapIfBE=x.swap8IfBE=x.isLE=void 0;x.isBytes=cs;x.anumber=to;x.abytes=ct;x.ahash=Ra;x.aexists=Ua;x.aoutput=za;x.u8=Fa;x.u32=Ha;x.clean=Oa;x.createView=ja;x.rotr=Na;x.rotl=Ga;x.byteSwap=oo;x.byteSwap32=ls;x.bytesToHex=Ma;x.hexToBytes=qa;x.asyncLoop=Ka;x.utf8ToBytes=no;x.bytesToUtf8=Wa;x.toBytes=br;x.kdfInputToBytes=Xa;x.concatBytes=Ja;x.checkOpts=Za;x.createHasher=us;x.createOptHasher=fs;x.createXOFer=ms;x.randomBytes=Ya;var at=is();function cs(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function to(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ct(e,...t){if(!cs(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ra(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");to(e.outputLen),to(e.blockLen)}function Ua(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function za(e,t){ct(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Fa(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Ha(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Oa(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ja(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Na(e,t){return e<<32-t|e>>>t}function Ga(e,t){return e<<t|e>>>32-t>>>0}x.isLE=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function oo(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}x.swap8IfBE=x.isLE?e=>e:e=>oo(e);x.byteSwapIfBE=x.swap8IfBE;function ls(e){for(let t=0;t<e.length;t++)e[t]=oo(e[t]);return e}x.swap32IfBE=x.isLE?e=>e:ls;var ps=(()=>typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function")(),Da=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ma(e){if(ct(e),ps)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Da[e[r]];return t}var Te={_0:48,_9:57,A:65,F:70,a:97,f:102};function as(e){if(e>=Te._0&&e<=Te._9)return e-Te._0;if(e>=Te.A&&e<=Te.F)return e-(Te.A-10);if(e>=Te.a&&e<=Te.f)return e-(Te.a-10)}function qa(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(ps)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){let i=as(e.charCodeAt(s)),a=as(e.charCodeAt(s+1));if(i===void 0||a===void 0){let l=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+s)}o[n]=i*16+a}return o}var Va=async()=>{};x.nextTick=Va;async function Ka(e,t,r){let o=Date.now();for(let n=0;n<e;n++){r(n);let s=Date.now()-o;s>=0&&s<t||(await(0,x.nextTick)(),o+=s)}}function no(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Wa(e){return new TextDecoder().decode(e)}function br(e){return typeof e=="string"&&(e=no(e)),ct(e),e}function Xa(e){return typeof e=="string"&&(e=no(e)),ct(e),e}function Ja(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];ct(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let s=e[o];r.set(s,n),n+=s.length}return r}function Za(e,t){if(t!==void 0&&{}.toString.call(t)!=="[object Object]")throw new Error("options should be object or undefined");return Object.assign(e,t)}var ro=class{};x.Hash=ro;function us(e){let t=o=>e().update(br(o)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function fs(e){let t=(o,n)=>e(n).update(br(o)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=o=>e(o),t}function ms(e){let t=(o,n)=>e(n).update(br(o)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=o=>e(o),t}x.wrapConstructor=us;x.wrapConstructorWithOpts=fs;x.wrapXOFConstructorWithOpts=ms;function Ya(e=32){if(at.crypto&&typeof at.crypto.getRandomValues=="function")return at.crypto.getRandomValues(new Uint8Array(e));if(at.crypto&&typeof at.crypto.randomBytes=="function")return Uint8Array.from(at.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}});var Cs=W(A=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0});A.shake256=A.shake128=A.keccak_512=A.keccak_384=A.keccak_256=A.keccak_224=A.sha3_512=A.sha3_384=A.sha3_256=A.sha3_224=A.Keccak=void 0;A.keccakP=ws;var $t=ss(),G=ds(),Qa=BigInt(0),Lt=BigInt(1),ec=BigInt(2),tc=BigInt(7),rc=BigInt(256),oc=BigInt(113),gs=[],bs=[],ys=[];for(let e=0,t=Lt,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],gs.push(2*(5*o+r)),bs.push((e+1)*(e+2)/2%64);let n=Qa;for(let s=0;s<7;s++)t=(t<<Lt^(t>>tc)*oc)%rc,t&ec&&(n^=Lt<<(Lt<<BigInt(s))-Lt);ys.push(n)}var vs=(0,$t.split)(ys,!0),nc=vs[0],sc=vs[1],hs=(e,t,r)=>r>32?(0,$t.rotlBH)(e,t,r):(0,$t.rotlSH)(e,t,r),xs=(e,t,r)=>r>32?(0,$t.rotlBL)(e,t,r):(0,$t.rotlSL)(e,t,r);function ws(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let i=0;i<10;i++)r[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){let a=(i+8)%10,l=(i+2)%10,u=r[l],f=r[l+1],p=hs(u,f,1)^r[a],d=xs(u,f,1)^r[a+1];for(let h=0;h<50;h+=10)e[i+h]^=p,e[i+h+1]^=d}let n=e[2],s=e[3];for(let i=0;i<24;i++){let a=bs[i],l=hs(n,s,a),u=xs(n,s,a),f=gs[i];n=e[f],s=e[f+1],e[f]=l,e[f+1]=u}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)r[a]=e[i+a];for(let a=0;a<10;a++)e[i+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=nc[o],e[1]^=sc[o]}(0,G.clean)(r)}var Xe=class extends G.Hash{constructor(t,r,o,n=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=r,this.outputLen=o,this.enableXOF=n,this.rounds=s,(0,G.anumber)(o),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=(0,G.u32)(this.state)}clone(){return this._cloneInto()}keccak(){(0,G.swap32IfBE)(this.state32),ws(this.state32,this.rounds),(0,G.swap32IfBE)(this.state32),this.posOut=0,this.pos=0}update(t){(0,G.aexists)(this),t=(0,G.toBytes)(t),(0,G.abytes)(t);let{blockLen:r,state:o}=this,n=t.length;for(let s=0;s<n;){let i=Math.min(r-this.pos,n-s);for(let a=0;a<i;a++)o[this.pos++]^=t[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:r,pos:o,blockLen:n}=this;t[o]^=r,r&128&&o===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){(0,G.aexists)(this,!1),(0,G.abytes)(t),this.finish();let r=this.state,{blockLen:o}=this;for(let n=0,s=t.length;n<s;){this.posOut>=o&&this.keccak();let i=Math.min(o-this.posOut,s-n);t.set(r.subarray(this.posOut,this.posOut+i),n),this.posOut+=i,n+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return(0,G.anumber)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,G.aoutput)(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,(0,G.clean)(this.state)}_cloneInto(t){let{blockLen:r,suffix:o,outputLen:n,rounds:s,enableXOF:i}=this;return t||(t=new Xe(r,o,n,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=o,t.outputLen=n,t.enableXOF=i,t.destroyed=this.destroyed,t}};A.Keccak=Xe;var Ue=(e,t,r)=>(0,G.createHasher)(()=>new Xe(t,e,r));A.sha3_224=(()=>Ue(6,144,224/8))();A.sha3_256=(()=>Ue(6,136,256/8))();A.sha3_384=(()=>Ue(6,104,384/8))();A.sha3_512=(()=>Ue(6,72,512/8))();A.keccak_224=(()=>Ue(1,144,224/8))();A.keccak_256=(()=>Ue(1,136,256/8))();A.keccak_384=(()=>Ue(1,104,384/8))();A.keccak_512=(()=>Ue(1,72,512/8))();var _s=(e,t,r)=>(0,G.createXOFer)((o={})=>new Xe(t,e,o.dkLen===void 0?r:o.dkLen,!0));A.shake128=(()=>_s(31,168,128/8))();A.shake256=(()=>_s(31,136,256/8))()});var ks=W(so=>{"use strict";Object.defineProperty(so,"__esModule",{value:!0});so.verifyEnvEncryptPublicKey=cc;var ic=Cs(),ac=we("@noble/curves/secp256k1");function cc(e,t,r){if(t.length!==65)return null;let o=Buffer.from("dstack-env-encrypt-pubkey","utf8"),n=r;r.startsWith("0x")&&(n=r.slice(2));let s=Buffer.from(n,"hex"),i=Buffer.from(":","utf8"),a=Buffer.concat([o,i,s,Buffer.from(e)]),l=(0,ic.keccak_256)(a);try{let u=t.slice(0,32),f=t.slice(32,64),p=t[64],d=new Uint8Array(64);d.set(u,0),d.set(f,32);let h=ac.secp256k1.Signature.fromCompact(d).addRecoveryBit(p).recoverPublicKey(l);return"0x"+Buffer.from(h.toRawBytes(!0)).toString("hex")}catch(u){return console.error("signature verification failed:",u),null}}});var As=ht(Eo(),1);import{ofetch as lc}from"ofetch";function So(e){return{all:e=e||new Map,on:function(t,r){var o=e.get(t);o?o.push(r):e.set(t,[r])},off:function(t,r){var o=e.get(t);o&&(r?o.splice(o.indexOf(r)>>>0,1):e.set(t,[]))},emit:function(t,r){var o=e.get(t);o&&o.slice().map(function(n){n(r)}),(o=e.get("*"))&&o.slice().map(function(n){n(t,r)})}}}import{z as H}from"zod";import{z as ze}from"zod";import{z as w}from"zod";import{z as Fe}from"zod";function Ne(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}Dt();Ge();Dt();var Lr={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function vt(e,t){let r={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?Me(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?Me(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Lr[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(r.authorizationList=Hi(e.authorizationList)),r.yParity=(()=>{if(e.yParity)return Number(e.yParity);if(typeof r.v=="bigint"){if(r.v===0n||r.v===27n)return 0;if(r.v===1n||r.v===28n)return 1;if(r.v>=35n)return r.v%2n===0n?1:0}})(),r.type==="legacy"&&(delete r.accessList,delete r.maxFeePerBlobGas,delete r.maxFeePerGas,delete r.maxPriorityFeePerGas,delete r.yParity),r.type==="eip2930"&&(delete r.maxFeePerBlobGas,delete r.maxFeePerGas,delete r.maxPriorityFeePerGas),r.type==="eip1559"&&delete r.maxFeePerBlobGas,r}var Lo=tt("transaction",vt);function Hi(e){return e.map(t=>({address:t.address,chainId:Number(t.chainId),nonce:Number(t.nonce),r:t.r,s:t.s,yParity:Number(t.yParity)}))}function Oi(e,t){let r=(e.transactions??[]).map(o=>typeof o=="string"?o:vt(o));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:r,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}var $o=tt("block",Oi);function Ro(e,{args:t,eventName:r}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...r?{args:t,eventName:r}:{}}}Ge();Dt();var ji={"0x0":"reverted","0x1":"success"};function Ni(e,t){let r={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map(o=>Ro(o)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Me(e.transactionIndex):null,status:e.status?ji[e.status]:null,type:e.type?Lr[e.type]||e.type:null};return e.blobGasPrice&&(r.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(r.blobGasUsed=BigInt(e.blobGasUsed)),r}var Uo=tt("transactionReceipt",Ni);oe();Rr();Be();se();function Ce(e,t="hex"){let r=Ho(e),o=Kt(new Uint8Array(r.length));return r.encode(o),t==="hex"?J(o.bytes):o.bytes}function Ho(e){return Array.isArray(e)?Di(e.map(t=>Ho(t))):Mi(e)}function Di(e){let t=e.reduce((n,s)=>n+s.length,0),r=Oo(t);return{length:(()=>t<=55?1+t:1+r+t)(),encode(n){t<=55?n.pushByte(192+t):(n.pushByte(192+55+r),r===1?n.pushUint8(t):r===2?n.pushUint16(t):r===3?n.pushUint24(t):n.pushUint32(t));for(let{encode:s}of e)s(n)}}}function Mi(e){let t=typeof e=="string"?pe(e):e,r=Oo(t.length);return{length:(()=>t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+r+t.length)(),encode(n){t.length===1&&t[0]<128?n.pushBytes(t):t.length<=55?(n.pushByte(128+t.length),n.pushBytes(t)):(n.pushByte(128+55+r),r===1?n.pushUint8(t.length):r===2?n.pushUint16(t.length):r===3?n.pushUint24(t.length):n.pushUint32(t.length),n.pushBytes(t))}}}function Oo(e){if(e<2**8)return 1;if(e<2**16)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new g("Length is too large.")}Zt();se();function qo(e){if(!e||e.length===0)return[];let t=[];for(let r of e){let{chainId:o,nonce:n,...s}=r,i=r.address;t.push([o?le(o):"0x",i,n?le(n):"0x",...rt({},s)])}return t}Be();se();function Yt(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),o=typeof e.blobs[0]=="string"?e.blobs.map(s=>pe(s)):e.blobs,n=[];for(let s of o)n.push(Uint8Array.from(t.blobToKzgCommitment(s)));return r==="bytes"?n:n.map(s=>J(s))}Be();se();function Qt(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),o=typeof e.blobs[0]=="string"?e.blobs.map(i=>pe(i)):e.blobs,n=typeof e.commitments[0]=="string"?e.commitments.map(i=>pe(i)):e.commitments,s=[];for(let i=0;i<o.length;i++){let a=o[i],l=n[i];s.push(Uint8Array.from(t.computeBlobKzgProof(a,l)))}return r==="bytes"?s:s.map(i=>J(i))}se();or();function Zi(e,t,r,o){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,o);let n=BigInt(32),s=BigInt(4294967295),i=Number(r>>n&s),a=Number(r&s),l=o?4:0,u=o?0:4;e.setUint32(t+l,i,o),e.setUint32(t+u,a,o)}function Ko(e,t,r){return e&t^~e&r}function Wo(e,t,r){return e&t^e&r^t&r}var nr=class extends ot{constructor(t,r,o,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(t),this.view=tr(this.buffer)}update(t){nt(this),t=Ct(t),Ve(t);let{view:r,buffer:o,blockLen:n}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(n-this.pos,s-i);if(a===n){let l=tr(t);for(;n<=s-i;i+=n)this.process(l,i);continue}o.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){nt(this),er(t,this),this.finished=!0;let{buffer:r,view:o,blockLen:n,isLE:s}=this,{pos:i}=this;r[i++]=128,Le(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let p=i;p<n;p++)r[p]=0;Zi(o,n-8,BigInt(this.length*8),s),this.process(o,0);let a=tr(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=l/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<u;p++)a.setUint32(4*p,f[p],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let o=t.slice(0,r);return this.destroy(),o}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:o,length:n,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=n,t.pos=a,n%r&&t.buffer.set(o),t}clone(){return this._cloneInto()}},ke=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);or();var Qi=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),$e=new Uint32Array(64),ir=class extends nr{constructor(t=32){super(64,t,8,!1),this.A=ke[0]|0,this.B=ke[1]|0,this.C=ke[2]|0,this.D=ke[3]|0,this.E=ke[4]|0,this.F=ke[5]|0,this.G=ke[6]|0,this.H=ke[7]|0}get(){let{A:t,B:r,C:o,D:n,E:s,F:i,G:a,H:l}=this;return[t,r,o,n,s,i,a,l]}set(t,r,o,n,s,i,a,l){this.A=t|0,this.B=r|0,this.C=o|0,this.D=n|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=l|0}process(t,r){for(let p=0;p<16;p++,r+=4)$e[p]=t.getUint32(r,!1);for(let p=16;p<64;p++){let d=$e[p-15],h=$e[p-2],I=ue(d,7)^ue(d,18)^d>>>3,T=ue(h,17)^ue(h,19)^h>>>10;$e[p]=T+$e[p-7]+I+$e[p-16]|0}let{A:o,B:n,C:s,D:i,E:a,F:l,G:u,H:f}=this;for(let p=0;p<64;p++){let d=ue(a,6)^ue(a,11)^ue(a,25),h=f+d+Ko(a,l,u)+Qi[p]+$e[p]|0,T=(ue(o,2)^ue(o,13)^ue(o,22))+Wo(o,n,s)|0;f=u,u=l,l=a,a=i+h|0,i=s,s=n,n=o,o=h+T|0}o=o+this.A|0,n=n+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,l=l+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(o,n,s,i,a,l,u,f)}roundClean(){Le($e)}destroy(){this.set(0,0,0,0,0,0,0,0),Le(this.buffer)}};var rn=rr(()=>new ir);var on=rn;et();Be();se();function nn(e,t){let r=t||"hex",o=on(de(e,{strict:!1})?Gt(e):e);return r==="bytes"?o:le(o)}function sn(e){let{commitment:t,version:r=1}=e,o=e.to??(typeof t=="string"?"hex":"bytes"),n=nn(t,"bytes");return n.set([r],0),o==="bytes"?n:J(n)}function an(e){let{commitments:t,version:r}=e,o=e.to??(typeof t[0]=="string"?"hex":"bytes"),n=[];for(let s of t)n.push(sn({commitment:s,to:o,version:r}));return n}oe();var ar=class extends g{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}},st=class extends g{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}},cr=class extends g{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}},lr=class extends g{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${1}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}};Rr();xt();Be();se();function cn(e){let t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?pe(e.data):e.data,o=ne(r);if(!o)throw new st;if(o>761855)throw new ar({maxSize:761855,size:o});let n=[],s=!0,i=0;for(;s;){let a=Kt(new Uint8Array(131072)),l=0;for(;l<4096;){let u=r.slice(i,i+(32-1));if(a.pushByte(0),a.pushBytes(u),u.length<31){a.pushByte(128),s=!1;break}l++,i+=31}n.push(a)}return t==="bytes"?n.map(a=>a.bytes):n.map(a=>J(a.bytes))}function ln(e){let{data:t,kzg:r,to:o}=e,n=e.blobs??cn({data:t,to:o}),s=e.commitments??Yt({blobs:n,kzg:r,to:o}),i=e.proofs??Qt({blobs:n,commitments:s,kzg:r,to:o}),a=[];for(let l=0;l<n.length;l++)a.push({blob:n[l],commitment:s[l],proof:i[l]});return a}$r();Po();se();zo();pr();oe();pn();un();fr();xt();Sn();Ge();function In(e){let{authorizationList:t}=e;if(t)for(let r of t){let{chainId:o}=r,n=r.address;if(!he(n))throw new ie({address:n});if(o<0)throw new Ke({chainId:o})}mr(e)}function An(e){let{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new st;for(let r of t){let o=ne(r),n=Me(kn(r,0,1));if(o!==32)throw new cr({hash:r,size:o});if(n!==1)throw new lr({hash:r,version:n})}}mr(e)}function mr(e){let{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:o,to:n}=e;if(t<=0)throw new Ke({chainId:t});if(n&&!he(n))throw new ie({address:n});if(o&&o>Mt)throw new We({maxFeePerGas:o});if(r&&o&&r>o)throw new kt({maxFeePerGas:o,maxPriorityFeePerGas:r})}function Pn(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:o,maxFeePerGas:n,to:s}=e;if(t<=0)throw new Ke({chainId:t});if(s&&!he(s))throw new ie({address:s});if(r||n)throw new g("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(o&&o>Mt)throw new We({maxFeePerGas:o})}function Bn(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:o,maxFeePerGas:n,to:s}=e;if(s&&!he(s))throw new ie({address:s});if(typeof t<"u"&&t<=0)throw new Ke({chainId:t});if(r||n)throw new g("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(o&&o>Mt)throw new We({maxFeePerGas:o})}Zt();function Ln(e){if(e.type)return e.type;if(typeof e.authorizationList<"u")return"eip7702";if(typeof e.blobs<"u"||typeof e.blobVersionedHashes<"u"||typeof e.maxFeePerBlobGas<"u"||typeof e.sidecars<"u")return"eip4844";if(typeof e.maxFeePerGas<"u"||typeof e.maxPriorityFeePerGas<"u")return"eip1559";if(typeof e.gasPrice<"u")return typeof e.accessList<"u"?"eip2930":"legacy";throw new Xt({transaction:e})}pr();Zt();fr();function St(e){if(!e||e.length===0)return[];let t=[];for(let r=0;r<e.length;r++){let{address:o,storageKeys:n}=e[r];for(let s=0;s<n.length;s++)if(n[s].length-2!==64)throw new Jt({storageKey:n[s]});if(!he(o,{strict:!1}))throw new ie({address:o});t.push([o,n])}return t}function $n(e,t){let r=Ln(e);return r==="eip1559"?xa(e,t):r==="eip2930"?ga(e,t):r==="eip4844"?ha(e,t):r==="eip7702"?da(e,t):ba(e,t)}function da(e,t){let{authorizationList:r,chainId:o,gas:n,nonce:s,to:i,value:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:f,data:p}=e;In(e);let d=St(f),h=qo(r);return qe(["0x04",Ce([_(o),s?_(s):"0x",u?_(u):"0x",l?_(l):"0x",n?_(n):"0x",i??"0x",a?_(a):"0x",p??"0x",d,h,...rt(e,t)])])}function ha(e,t){let{chainId:r,gas:o,nonce:n,to:s,value:i,maxFeePerBlobGas:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:f,data:p}=e;An(e);let d=e.blobVersionedHashes,h=e.sidecars;if(e.blobs&&(typeof d>"u"||typeof h>"u")){let O=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(te=>J(te)),Q=e.kzg,ce=Yt({blobs:O,kzg:Q});if(typeof d>"u"&&(d=an({commitments:ce})),typeof h>"u"){let te=Qt({blobs:O,commitments:ce,kzg:Q});h=ln({blobs:O,commitments:ce,proofs:te})}}let I=St(f),T=[_(r),n?_(n):"0x",u?_(u):"0x",l?_(l):"0x",o?_(o):"0x",s??"0x",i?_(i):"0x",p??"0x",I,a?_(a):"0x",d??[],...rt(e,t)],P=[],V=[],K=[];if(h)for(let O=0;O<h.length;O++){let{blob:Q,commitment:ce,proof:te}=h[O];P.push(Q),V.push(ce),K.push(te)}return qe(["0x03",h?Ce([T,P,V,K]):Ce(T)])}function xa(e,t){let{chainId:r,gas:o,nonce:n,to:s,value:i,maxFeePerGas:a,maxPriorityFeePerGas:l,accessList:u,data:f}=e;mr(e);let p=St(u),d=[_(r),n?_(n):"0x",l?_(l):"0x",a?_(a):"0x",o?_(o):"0x",s??"0x",i?_(i):"0x",f??"0x",p,...rt(e,t)];return qe(["0x02",Ce(d)])}function ga(e,t){let{chainId:r,gas:o,data:n,nonce:s,to:i,value:a,accessList:l,gasPrice:u}=e;Pn(e);let f=St(l),p=[_(r),s?_(s):"0x",u?_(u):"0x",o?_(o):"0x",i??"0x",a?_(a):"0x",n??"0x",f,...rt(e,t)];return qe(["0x01",Ce(p)])}function ba(e,t){let{chainId:r=0,gas:o,data:n,nonce:s,to:i,value:a,gasPrice:l}=e;Bn(e);let u=[s?_(s):"0x",l?_(l):"0x",o?_(o):"0x",i??"0x",a?_(a):"0x",n??"0x"];if(t){let f=(()=>{if(t.v>=35n)return(t.v-35n)/2n>0?t.v:27n+(t.v===35n?0n:1n);if(r>0)return BigInt(r*2)+BigInt(35n+t.v-27n);let h=27n+(t.v===27n?0n:1n);if(t.v!==h)throw new Wt({v:t.v});return h})(),p=gt(t.r),d=gt(t.s);u=[...u,_(f),p==="0x00"?"0x":p,d==="0x00"?"0x":d]}else r>0&&(u=[...u,_(r),"0x","0x"]);return Ce(u)}function rt(e,t){let r=t??e,{v:o,yParity:n}=r;if(typeof r.r>"u")return[];if(typeof r.s>"u")return[];if(typeof o>"u"&&typeof n>"u")return[];let s=gt(r.r),i=gt(r.s);return[(()=>typeof n=="number"?n?_(1):"0x":o===0n?"0x":o===1n?_(1):o===27n?"0x":_(1))(),s==="0x00"?"0x":s,i==="0x00"?"0x":i]}var Rn={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};Ge();var Un={block:$o({format(e){return{transactions:e.transactions?.map(r=>{if(typeof r=="string")return r;let o=vt(r);return o.typeHex==="0x7e"&&(o.isSystemTx=r.isSystemTx,o.mint=r.mint?De(r.mint):void 0,o.sourceHash=r.sourceHash,o.type="deposit"),o}),stateRoot:e.stateRoot}}}),transaction:Lo({format(e){let t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?De(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:Uo({format(e){return{l1GasPrice:e.l1GasPrice?De(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?De(e.l1GasUsed):null,l1Fee:e.l1Fee?De(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};pr();fr();$r();se();function ya(e,t){return wa(e)?va(e):$n(e,t)}var zn={transaction:ya};function va(e){_a(e);let{sourceHash:t,data:r,from:o,gas:n,isSystemTx:s,mint:i,to:a,value:l}=e,u=[t,o,a??"0x",i?le(i):"0x",l?le(l):"0x",n?le(n):"0x",s?"0x1":"0x",r??"0x"];return qe(["0x7e",Ce(u)])}function wa(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function _a(e){let{from:t,to:r}=e;if(t&&!he(t))throw new ie({address:t});if(r&&!he(r))throw new ie({address:r})}var Wr={blockTime:2e3,contracts:Rn,formatters:Un,serializers:zn};var dr=Ne({id:31337,name:"Anvil",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["http://127.0.0.1:8545"],webSocket:["ws://127.0.0.1:8545"]}}});var It=1,At=Ne({...Wr,id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://basescan.org",apiUrl:"https://api.basescan.org/api"}},contracts:{...Wr.contracts,disputeGameFactory:{[It]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[It]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[It]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[It]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:It}),Ca=Ne({...At,experimental_preconfirmationTime:200,rpcUrls:{default:{http:["https://mainnet-preconf.base.org"]}}});var hr=Ne({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:12e3,rpcUrls:{default:{http:["https://eth.merkle.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensUniversalResolver:{address:"0xeeeeeeee14d718c2b47d9923deab1335e144eeee",blockCreated:23085558},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}});import{z as $}from"zod";import{z as ee}from"zod";import{z as m}from"zod";import{z as Rt}from"zod";import{z as ae}from"zod";import{z as v}from"zod";import{z as C}from"zod";import{z as M}from"zod";import ml from"crypto";import{z as be}from"zod";import{z as fe}from"zod";import{z as j}from"zod";import{z as Z}from"zod";import{z as Y}from"zod";import{z as ql}from"zod";import{z as Es}from"zod";import{z as ye}from"zod";import{z as ft}from"zod";import{z as Je}from"zod";import{z as yp}from"zod";import{z as Cp}from"zod";import{z as S}from"zod";import{z as ge}from"zod";import{z as Hp}from"zod";import{z as L}from"zod";import{z as b}from"zod";import{z as ut}from"zod";import{z as Ss}from"zod";import{z as D}from"zod";import{z as Gs}from"zod";import{z as xe}from"zod";import{z as U}from"zod";var Qx=ht(Zr(),1);import{z as B}from"zod";var wu=ht(Zr(),1),_u=ht(Fn(),1),Cu=ht(ks(),1);import{z as pt}from"zod";var pc=H.object({detail:H.union([H.string(),H.array(H.object({msg:H.string(),type:H.string().optional(),ctx:H.record(H.unknown()).optional(),loc:H.array(H.union([H.string(),H.number()])).optional(),input:H.unknown().optional()}).passthrough()),H.record(H.unknown())]).optional(),type:H.string().optional(),code:H.string().optional()}),ve=class extends Error{constructor(e,t){super(e),this.name=this.constructor.name,this.status=t.status,this.statusText=t.statusText,this.detail=t.detail,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},io=class yr extends ve{constructor(t,r){super(t,{status:r?.status??0,statusText:r?.statusText??"Unknown Error",detail:r?.detail||t}),this.name="RequestError",this.isRequestError=!0,this.data=r?.data,this.request=r?.request,this.response=r?.response,this.code=r?.code,this.type=r?.type}static fromFetchError(t){let r=pc.safeParse(t.data);return r.success?new yr(t.message,{status:t.status??void 0,statusText:t.statusText??void 0,data:t.data,request:t.request??void 0,response:t.response??void 0,detail:r.data.detail,code:r.data.code??void 0,type:r.data.type??void 0}):new yr(t.message,{status:t.status??void 0,statusText:t.statusText??void 0,data:t.data,request:t.request??void 0,response:t.response??void 0,detail:t.data?.detail||"Unknown API error",code:t.status?.toString()??void 0})}static fromError(t,r){return new yr(t.message,{request:r??void 0,detail:t.message})}},uc=class extends ve{constructor(e,t){super(e,t),this.isValidationError=!0,this.validationErrors=t.validationErrors}},fc=class extends ve{constructor(){super(...arguments),this.isAuthError=!0}},Ps=class extends ve{constructor(){super(...arguments),this.isBusinessError=!0}},mc=class extends ve{constructor(){super(...arguments),this.isServerError=!0}},dc=class extends ve{constructor(){super(...arguments),this.isUnknownError=!0}};function hc(e){if(!e||!Array.isArray(e))return"unknown";let t=e.filter(r=>typeof r=="string"?!["body","query","path","header"].includes(r):!0);return t.length>0?t.join("."):"unknown"}function Bs(e){if(!Array.isArray(e))return{errors:[],message:typeof e=="string"?e:"Validation error"};let t=e.map((n,s)=>{let i=hc(n.loc),a=i;return i==="unknown"&&n.type&&(a=n.type==="missing"?"required field":n.type),{field:a,message:n.msg,type:n.type,context:n.ctx}}),r=t.length,o=r===1?`Validation failed: ${t[0].message}`:`Validation failed (${r} issue${r>1?"s":""})`;return{errors:t,message:o}}function xc(e){return e===422?"validation":e===401||e===403?"auth":e>=400&&e<500?"business":e>=500?"server":"unknown"}function gc(e,t,r){if(e===422&&Array.isArray(t)){let{message:o}=Bs(t);return o}if(typeof t=="string")return t;if(t&&typeof t=="object"&&"message"in t){let o=t.message;if(typeof o=="string")return o}return r}function bc(e){let t=e.status??0,r=e.statusText??"Unknown Error",o=e.detail,n=vc(o);if(n)return new yc(n.message,{status:t,statusText:r,detail:o,errorCode:n.error_code,structuredDetails:n.details,suggestions:n.suggestions,links:n.links});let s=xc(t),i=gc(t,o,e.message),a={status:t,statusText:r,detail:o};if(s==="validation"&&Array.isArray(o)){let{errors:l}=Bs(o);return new uc(i,{...a,validationErrors:l})}return s==="auth"?new fc(i,a):s==="business"?new Ps(i,a):s==="server"?new mc(i,a):new dc(i,a)}var yc=class extends Ps{constructor(e,t){super(e,t),this.isResourceError=!0,this.errorCode=t.errorCode,this.structuredDetails=t.structuredDetails,this.suggestions=t.suggestions,this.links=t.links}};function vc(e){if(!e||typeof e!="object")return null;let t=e;return t.error_code&&typeof t.error_code=="string"&&t.message&&typeof t.message=="string"?{error_code:t.error_code,message:t.message,details:t.details,suggestions:t.suggestions,links:t.links}:null}var ao=["2025-05-31","2025-10-28"],lt=(0,As.default)("phala::api-client");function wc(e){return Object.entries(e).map(([t,r])=>` -H "${t}: ${r}"`).join(`
12
- `)}function _c(e){return e?` -d '${(typeof e=="string"?e:JSON.stringify(e,null,2)).replace(/'/g,"\\'")}'`:""}function Ts(e,t,r,o){let n=[];r.forEach((a,l)=>{n.push(`${l}: ${a}`)});let s=n.join(`
4
+ `+s),e.push(n+"m+"+Ft.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=Ei()+t+" "+e[0]}function Ei(){return H.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Si(...e){return process.stderr.write(Ht.formatWithOptions(H.inspectOpts,...e)+`
5
+ `)}function Ii(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function Ai(){return process.env.DEBUG}function Pi(e){e.inspectOpts={};let t=Object.keys(H.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=H.inspectOpts[t[r]]}Ft.exports=wr()(H);var{formatters:To}=Ft.exports;To.o=function(e){return this.inspectOpts.colors=this.useColors,Ht.inspect(e,this.inspectOpts).split(`
6
+ `).map(t=>t.trim()).join(" ")};To.O=function(e){return this.inspectOpts.colors=this.useColors,Ht.inspect(e,this.inspectOpts)}});var So=W((ju,kr)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?kr.exports=yo():kr.exports=Eo()});var Tr,Ao=E(()=>{Tr="2.38.6"});function Po(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?Po(e.cause,t):t?null:e}var Er,b,oe=E(()=>{Ao();Er={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${Tr}`},b=class e extends Error{constructor(t,r={}){let o=r.cause instanceof e?r.cause.details:r.cause?.message?r.cause.message:r.details,n=r.cause instanceof e&&r.cause.docsPath||r.docsPath,s=Er.getDocsUrl?.({...r,docsPath:n}),i=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...o?[`Details: ${o}`]:[],...Er.version?[`Version: ${Er.version}`]:[]].join(`
7
+ `);super(i,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=o,this.docsPath=n,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=t,this.version=Tr}walk(t){return Po(this,t)}}});var Ot,jt,Sr=E(()=>{oe();Ot=class extends b{constructor({max:t,min:r,signed:o,size:n,value:s}){super(`Number "${s}" is not in safe ${n?`${n*8}-bit ${o?"signed":"unsigned"} `:""}integer range ${t?`(${r} to ${t})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}},jt=class extends b{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}});function de(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}var Qe=E(()=>{});function ne(e){return de(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}var xt=E(()=>{Qe()});function gt(e,{dir:t="left"}={}){let r=typeof e=="string"?e.replace("0x",""):e,o=0;for(let n=0;n<r.length-1&&r[t==="left"?n:r.length-n-1].toString()==="0";n++)o++;return r=t==="left"?r.slice(o):r.slice(0,r.length-o),typeof e=="string"?(r.length===1&&t==="right"&&(r=`${r}0`),`0x${r.length%2===1?`0${r}`:r}`):r}var Bo=E(()=>{});var bt,yt,Ir=E(()=>{oe();bt=class extends b{constructor({offset:t,position:r,size:o}){super(`Slice ${r==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${o}).`,{name:"SliceOffsetOutOfBoundsError"})}},yt=class extends b{constructor({size:t,targetSize:r,type:o}){super(`${o.charAt(0).toUpperCase()}${o.slice(1).toLowerCase()} size (${t}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}});function Ae(e,{dir:t,size:r=32}={}){return typeof e=="string"?Bi(e,{dir:t,size:r}):$i(e,{dir:t,size:r})}function Bi(e,{dir:t,size:r=32}={}){if(r===null)return e;let o=e.replace("0x","");if(o.length>r*2)throw new yt({size:Math.ceil(o.length/2),targetSize:r,type:"hex"});return`0x${o[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function $i(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new yt({size:e.length,targetSize:r,type:"bytes"});let o=new Uint8Array(r);for(let n=0;n<r;n++){let s=t==="right";o[s?n:r-n-1]=e[s?n:e.length-n-1]}return o}var Ar=E(()=>{Ir()});function le(e,t={}){return typeof e=="number"||typeof e=="bigint"?_(e,t):typeof e=="string"?zi(e,t):typeof e=="boolean"?Ri(e,t):J(e,t)}function Ri(e,t={}){let r=`0x${Number(e)}`;return typeof t.size=="number"?(Pe(r,{size:t.size}),Ae(r,{size:t.size})):r}function J(e,t={}){let r="";for(let n=0;n<e.length;n++)r+=Li[e[n]];let o=`0x${r}`;return typeof t.size=="number"?(Pe(o,{size:t.size}),Ae(o,{dir:"right",size:t.size})):o}function _(e,t={}){let{signed:r,size:o}=t,n=BigInt(e),s;o?r?s=(1n<<BigInt(o)*8n-1n)-1n:s=2n**(BigInt(o)*8n)-1n:typeof e=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));let i=typeof s=="bigint"&&r?-s-1n:0;if(s&&n>s||n<i){let l=typeof e=="bigint"?"n":"";throw new Ot({max:s?`${s}${l}`:void 0,min:`${i}${l}`,signed:r,size:o,value:`${e}${l}`})}let a=`0x${(r&&n<0?(1n<<BigInt(o*8))+BigInt(n):n).toString(16)}`;return o?Ae(a,{size:o}):a}function zi(e,t={}){let r=Ui.encode(e);return J(r,t)}var Li,Ui,se=E(()=>{Sr();Ar();Me();Li=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));Ui=new TextEncoder});function Nt(e,t={}){return typeof e=="number"||typeof e=="bigint"?Oi(e,t):typeof e=="boolean"?Fi(e,t):de(e)?pe(e,t):Pr(e,t)}function Fi(e,t={}){let r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(Pe(r,{size:t.size}),Ae(r,{size:t.size})):r}function $o(e){if(e>=_e.zero&&e<=_e.nine)return e-_e.zero;if(e>=_e.A&&e<=_e.F)return e-(_e.A-10);if(e>=_e.a&&e<=_e.f)return e-(_e.a-10)}function pe(e,t={}){let r=e;t.size&&(Pe(r,{size:t.size}),r=Ae(r,{dir:"right",size:t.size}));let o=r.slice(2);o.length%2&&(o=`0${o}`);let n=o.length/2,s=new Uint8Array(n);for(let i=0,a=0;i<n;i++){let l=$o(o.charCodeAt(a++)),u=$o(o.charCodeAt(a++));if(l===void 0||u===void 0)throw new b(`Invalid byte sequence ("${o[a-2]}${o[a-1]}" in "${o}").`);s[i]=l*16+u}return s}function Oi(e,t){let r=_(e,t);return pe(r)}function Pr(e,t={}){let r=Hi.encode(e);return typeof t.size=="number"?(Pe(r,{size:t.size}),Ae(r,{dir:"right",size:t.size})):r}var Hi,_e,Be=E(()=>{oe();Qe();Ar();Me();se();Hi=new TextEncoder;_e={zero:48,nine:57,A:65,F:70,a:97,f:102}});function Pe(e,{size:t}){if(ne(e)>t)throw new jt({givenSize:ne(e),maxSize:t})}function De(e,t={}){let{signed:r}=t;t.size&&Pe(e,{size:t.size});let o=BigInt(e);if(!r)return o;let n=(e.length-2)/2,s=(1n<<BigInt(n)*8n-1n)-1n;return o<=s?o:o-BigInt(`0x${"f".padStart(n*2,"f")}`)-1n}function Ge(e,t={}){return Number(De(e,t))}var Me=E(()=>{Sr();xt()});function et(e,t){return({exclude:r,format:o})=>({exclude:r,format:(n,s)=>{let i=t(n,s);if(r)for(let a of r)delete i[a];return{...i,...o(n,s)}},type:e})}var Mt=E(()=>{});var Pf,Bf,$f,Lf,Rf,Uf,zf,Hf,Ff,Of,jf,Nf,Mf,Df,Gf,qf,Vf,Kf,Wf,Xf,Jf,Zf,Yf,Qf,em,tm,rm,om,nm,sm,im,am,cm,lm,pm,um,fm,mm,dm,hm,xm,gm,bm,ym,vm,wm,_m,Cm,km,Tm,Em,Sm,Im,Am,Pm,Bm,$m,Lm,Rm,Um,zm,Hm,Fm,Om,jm,Nm,Mm,Dm,Gm,qm,Vm,Km,Wm,Xm,Jm,Zm,Ym,Qm,ed,td,rd,od,nd,sd,id,ad,cd,ld,pd,ud,fd,md,dd,hd,xd,Dt,Ho=E(()=>{Pf=2n**(8n-1n)-1n,Bf=2n**(16n-1n)-1n,$f=2n**(24n-1n)-1n,Lf=2n**(32n-1n)-1n,Rf=2n**(40n-1n)-1n,Uf=2n**(48n-1n)-1n,zf=2n**(56n-1n)-1n,Hf=2n**(64n-1n)-1n,Ff=2n**(72n-1n)-1n,Of=2n**(80n-1n)-1n,jf=2n**(88n-1n)-1n,Nf=2n**(96n-1n)-1n,Mf=2n**(104n-1n)-1n,Df=2n**(112n-1n)-1n,Gf=2n**(120n-1n)-1n,qf=2n**(128n-1n)-1n,Vf=2n**(136n-1n)-1n,Kf=2n**(144n-1n)-1n,Wf=2n**(152n-1n)-1n,Xf=2n**(160n-1n)-1n,Jf=2n**(168n-1n)-1n,Zf=2n**(176n-1n)-1n,Yf=2n**(184n-1n)-1n,Qf=2n**(192n-1n)-1n,em=2n**(200n-1n)-1n,tm=2n**(208n-1n)-1n,rm=2n**(216n-1n)-1n,om=2n**(224n-1n)-1n,nm=2n**(232n-1n)-1n,sm=2n**(240n-1n)-1n,im=2n**(248n-1n)-1n,am=2n**(256n-1n)-1n,cm=-(2n**(8n-1n)),lm=-(2n**(16n-1n)),pm=-(2n**(24n-1n)),um=-(2n**(32n-1n)),fm=-(2n**(40n-1n)),mm=-(2n**(48n-1n)),dm=-(2n**(56n-1n)),hm=-(2n**(64n-1n)),xm=-(2n**(72n-1n)),gm=-(2n**(80n-1n)),bm=-(2n**(88n-1n)),ym=-(2n**(96n-1n)),vm=-(2n**(104n-1n)),wm=-(2n**(112n-1n)),_m=-(2n**(120n-1n)),Cm=-(2n**(128n-1n)),km=-(2n**(136n-1n)),Tm=-(2n**(144n-1n)),Em=-(2n**(152n-1n)),Sm=-(2n**(160n-1n)),Im=-(2n**(168n-1n)),Am=-(2n**(176n-1n)),Pm=-(2n**(184n-1n)),Bm=-(2n**(192n-1n)),$m=-(2n**(200n-1n)),Lm=-(2n**(208n-1n)),Rm=-(2n**(216n-1n)),Um=-(2n**(224n-1n)),zm=-(2n**(232n-1n)),Hm=-(2n**(240n-1n)),Fm=-(2n**(248n-1n)),Om=-(2n**(256n-1n)),jm=2n**8n-1n,Nm=2n**16n-1n,Mm=2n**24n-1n,Dm=2n**32n-1n,Gm=2n**40n-1n,qm=2n**48n-1n,Vm=2n**56n-1n,Km=2n**64n-1n,Wm=2n**72n-1n,Xm=2n**80n-1n,Jm=2n**88n-1n,Zm=2n**96n-1n,Ym=2n**104n-1n,Qm=2n**112n-1n,ed=2n**120n-1n,td=2n**128n-1n,rd=2n**136n-1n,od=2n**144n-1n,nd=2n**152n-1n,sd=2n**160n-1n,id=2n**168n-1n,ad=2n**176n-1n,cd=2n**184n-1n,ld=2n**192n-1n,pd=2n**200n-1n,ud=2n**208n-1n,fd=2n**216n-1n,md=2n**224n-1n,dd=2n**232n-1n,hd=2n**240n-1n,xd=2n**248n-1n,Dt=2n**256n-1n});function qe(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}var $r=E(()=>{});var wt,Gt,qt,Fo=E(()=>{oe();wt=class extends b{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}},Gt=class extends b{constructor({length:t,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}},qt=class extends b{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}});function Vt(e,{recursiveReadLimit:t=8192}={}){let r=Object.create(Gi);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}var Gi,Lr=E(()=>{Fo();Gi={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new qt({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Gt({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new wt({offset:e});let t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new wt({offset:e});let t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){let t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){let r=t??this.position;return this.assertPosition(r+e-1),this.bytes.subarray(r,r+e)},inspectUint8(e){let t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){let t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){let t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){let t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,e&255),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();let e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();let r=this.inspectBytes(e);return this.position+=t??e,r},readUint8(){this.assertReadLimit(),this._touch();let e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();let e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();let e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();let e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){let t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;let e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}}});var No,Mo=E(()=>{No={ether:-9,wei:9}});function Do(e,t){let r=e.toString(),o=r.startsWith("-");o&&(r=r.slice(1)),r=r.padStart(t,"0");let[n,s]=[r.slice(0,r.length-t),r.slice(r.length-t)];return s=s.replace(/(0+)$/,""),`${o?"-":""}${n||"0"}${s?`.${s}`:""}`}var Go=E(()=>{});function _t(e,t="wei"){return Do(e,No[t])}var qo=E(()=>{Mo();Go()});function Ki(e){let t=Object.entries(e).map(([o,n])=>n===void 0||n===!1?null:[o,n]).filter(Boolean),r=t.reduce((o,[n])=>Math.max(o,n.length),0);return t.map(([o,n])=>` ${`${o}:`.padEnd(r+1)} ${n}`).join(`
8
+ `)}var Kt,Wt,Xt,Jt=E(()=>{oe();Kt=class extends b{constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}},Wt=class extends b{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Ki(t),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}},Xt=class extends b{constructor({storageKey:t}){super(`Size for storage key "${t}" is invalid. Expected 32 bytes. Got ${Math.floor((t.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}});function Wi(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Rr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ve(e,...t){if(!Wi(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function ot(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Qt(e,t){Ve(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Ko(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function $e(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function er(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ue(e,t){return e<<32-t|e>>>t}function Ji(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Zi(e){for(let t=0;t<e.length;t++)e[t]=Ji(e[t]);return e}function Yi(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Ct(e){return typeof e=="string"&&(e=Yi(e)),Ve(e),e}function tr(e){let t=o=>e().update(Ct(o)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}var Xi,Ur,rt,rr=E(()=>{Xi=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;Ur=Xi?e=>e:Zi;rt=class{}});function ea(e,t=!1){return t?{h:Number(e&nr),l:Number(e>>Jo&nr)}:{h:Number(e>>Jo&nr)|0,l:Number(e&nr)|0}}function Zo(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=ea(e[s],t);[o[s],n[s]]=[i,a]}return[o,n]}var nr,Jo,Yo,Qo,en,tn,rn=E(()=>{nr=BigInt(4294967295),Jo=BigInt(32);Yo=(e,t,r)=>e<<r|t>>>32-r,Qo=(e,t,r)=>t<<r|e>>>32-r,en=(e,t,r)=>t<<r-32|e>>>64-r,tn=(e,t,r)=>e<<r-32|t>>>64-r});var ie,lr=E(()=>{oe();ie=class extends b{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}});var Ke,un=E(()=>{oe();Ke=class extends b{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}});var pr,We,zr,Hr,Fr,Or,jr,Nr,Mr,Dr,kt,fn=E(()=>{qo();oe();pr=class extends b{constructor({cause:t,message:r}={}){let o=r?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${o?`with reason: ${o}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"})}};Object.defineProperty(pr,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(pr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});We=class extends b{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${_t(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}};Object.defineProperty(We,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});zr=class extends b{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${_t(r)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}};Object.defineProperty(zr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});Hr=class extends b{constructor({cause:t,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}is higher than the next one expected.`,{cause:t,name:"NonceTooHighError"})}};Object.defineProperty(Hr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});Fr=class extends b{constructor({cause:t,nonce:r}={}){super([`Nonce provided for the transaction ${r?`(${r}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
9
+ `),{cause:t,name:"NonceTooLowError"})}};Object.defineProperty(Fr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});Or=class extends b{constructor({cause:t,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}exceeds the maximum allowed nonce.`,{cause:t,name:"NonceMaxValueError"})}};Object.defineProperty(Or,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});jr=class extends b{constructor({cause:t}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
10
+ `),{cause:t,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}};Object.defineProperty(jr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});Nr=class extends b{constructor({cause:t,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:t,name:"IntrinsicGasTooHighError"})}};Object.defineProperty(Nr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});Mr=class extends b{constructor({cause:t,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction is too low.`,{cause:t,name:"IntrinsicGasTooLowError"})}};Object.defineProperty(Mr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});Dr=class extends b{constructor({cause:t}){super("The transaction type is not supported for this chain.",{cause:t,name:"TransactionTypeNotSupportedError"})}};Object.defineProperty(Dr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});kt=class extends b{constructor({cause:t,maxPriorityFeePerGas:r,maxFeePerGas:o}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${_t(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${o?` = ${_t(o)} gwei`:""}).`].join(`
11
+ `),{cause:t,name:"TipAboveFeeCapError"})}};Object.defineProperty(kt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/})});var st,Gr=E(()=>{st=class extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){let r=super.get(t);return super.has(t)&&r!==void 0&&(this.delete(t),super.set(t,r)),r}set(t,r){if(super.set(t,r),this.maxSize&&this.size>this.maxSize){let o=this.keys().next().value;o&&this.delete(o)}return this}}});function ua(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let i=0;i<10;i++)r[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){let a=(i+8)%10,l=(i+2)%10,u=r[l],f=r[l+1],p=mn(u,f,1)^r[a],d=dn(u,f,1)^r[a+1];for(let h=0;h<50;h+=10)e[i+h]^=p,e[i+h+1]^=d}let n=e[2],s=e[3];for(let i=0;i<24;i++){let a=xn[i],l=mn(n,s,a),u=dn(n,s,a),f=hn[i];n=e[f],s=e[f+1],e[f]=l,e[f+1]=u}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)r[a]=e[i+a];for(let a=0;a<10;a++)e[i+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=la[o],e[1]^=pa[o]}$e(r)}var na,Tt,sa,ia,aa,ca,hn,xn,gn,bn,la,pa,mn,dn,qr,fa,yn,vn=E(()=>{rn();rr();na=BigInt(0),Tt=BigInt(1),sa=BigInt(2),ia=BigInt(7),aa=BigInt(256),ca=BigInt(113),hn=[],xn=[],gn=[];for(let e=0,t=Tt,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],hn.push(2*(5*o+r)),xn.push((e+1)*(e+2)/2%64);let n=na;for(let s=0;s<7;s++)t=(t<<Tt^(t>>ia)*ca)%aa,t&sa&&(n^=Tt<<(Tt<<BigInt(s))-Tt);gn.push(n)}bn=Zo(gn,!0),la=bn[0],pa=bn[1],mn=(e,t,r)=>r>32?en(e,t,r):Yo(e,t,r),dn=(e,t,r)=>r>32?tn(e,t,r):Qo(e,t,r);qr=class e extends rt{constructor(t,r,o,n=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=r,this.outputLen=o,this.enableXOF=n,this.rounds=s,Rr(o),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Ko(this.state)}clone(){return this._cloneInto()}keccak(){Ur(this.state32),ua(this.state32,this.rounds),Ur(this.state32),this.posOut=0,this.pos=0}update(t){ot(this),t=Ct(t),Ve(t);let{blockLen:r,state:o}=this,n=t.length;for(let s=0;s<n;){let i=Math.min(r-this.pos,n-s);for(let a=0;a<i;a++)o[this.pos++]^=t[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:r,pos:o,blockLen:n}=this;t[o]^=r,(r&128)!==0&&o===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){ot(this,!1),Ve(t),this.finish();let r=this.state,{blockLen:o}=this;for(let n=0,s=t.length;n<s;){this.posOut>=o&&this.keccak();let i=Math.min(o-this.posOut,s-n);t.set(r.subarray(this.posOut,this.posOut+i),n),this.posOut+=i,n+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Rr(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Qt(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,$e(this.state)}_cloneInto(t){let{blockLen:r,suffix:o,outputLen:n,rounds:s,enableXOF:i}=this;return t||(t=new e(r,o,n,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=o,t.outputLen=n,t.enableXOF=i,t.destroyed=this.destroyed,t}},fa=(e,t,r)=>tr(()=>new qr(t,e,r)),yn=fa(1,136,256/8)});function wn(e,t){let r=t||"hex",o=yn(de(e,{strict:!1})?Nt(e):e);return r==="bytes"?o:le(o)}var _n=E(()=>{vn();Qe();Be();se()});function Cn(e,t){if(Vr.has(`${e}.${t}`))return Vr.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),o=wn(Pr(r),"bytes"),n=(t?r.substring(`${t}0x`.length):r).split("");for(let i=0;i<40;i+=2)o[i>>1]>>4>=8&&n[i]&&(n[i]=n[i].toUpperCase()),(o[i>>1]&15)>=8&&n[i+1]&&(n[i+1]=n[i+1].toUpperCase());let s=`0x${n.join("")}`;return Vr.set(`${e}.${t}`,s),s}var Vr,kn=E(()=>{Be();_n();Gr();Vr=new st(8192)});function he(e,t){let{strict:r=!0}=t??{},o=`${e}.${r}`;if(Kr.has(o))return Kr.get(o);let n=ma.test(e)?e.toLowerCase()===e?!0:r?Cn(e)===e:!0:!1;return Kr.set(o,n),n}var ma,Kr,ur=E(()=>{Gr();kn();ma=/^0x[a-fA-F0-9]{40}$/,Kr=new st(8192)});function Tn(e,t,r,{strict:o}={}){return de(e,{strict:!1})?ha(e,t,r,{strict:o}):da(e,t,r,{strict:o})}function En(e,t){if(typeof t=="number"&&t>0&&t>ne(e)-1)throw new bt({offset:t,position:"start",size:ne(e)})}function Sn(e,t,r){if(typeof t=="number"&&typeof r=="number"&&ne(e)!==r-t)throw new bt({offset:r,position:"end",size:ne(e)})}function da(e,t,r,{strict:o}={}){En(e,t);let n=e.slice(t,r);return o&&Sn(n,t,r),n}function ha(e,t,r,{strict:o}={}){En(e,t);let n=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return o&&Sn(n,t,r),n}var In=E(()=>{Ir();Qe();xt()});var Zr=W(At=>{"use strict";var Ea=At&&At.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(At,"__esModule",{value:!0});At.encryptEnvVars=Aa;var Xr=we("@noble/curves/ed25519"),Jr=Ea(we("crypto"));function Sa(e){var t,r;return e=e.startsWith("0x")?e.slice(2):e,new Uint8Array((r=(t=e.match(/.{1,2}/g))===null||t===void 0?void 0:t.map(o=>parseInt(o,16)))!==null&&r!==void 0?r:[])}function Ia(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Aa(e,t){let r=JSON.stringify({env:e}),o=Xr.x25519.utils.randomPrivateKey(),n=Xr.x25519.getPublicKey(o),s=Sa(t),i=Xr.x25519.getSharedSecret(o,s),a=await Jr.default.subtle.importKey("raw",i,{name:"AES-GCM",length:256},!0,["encrypt"]),l=Jr.default.getRandomValues(new Uint8Array(12)),u=await Jr.default.subtle.encrypt({name:"AES-GCM",iv:l},a,new TextEncoder().encode(r)),f=new Uint8Array(n.length+l.length+u.byteLength);return f.set(n),f.set(l,n.length),f.set(new Uint8Array(u),n.length+l.length),Ia(f)}});var Fn=W(Pt=>{"use strict";var Pa=Pt&&Pt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Pt,"__esModule",{value:!0});Pt.getComposeHash=Ra;var Ba=Pa(we("crypto"));function Yr(e){return e==null?e:Array.isArray(e)?e.map(Yr):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let o=e[r];return t[r]=Yr(o),t},{}):e}function $a(e){let t={...e};return t.runner==="bash"&&"docker_compose_file"in t?delete t.docker_compose_file:t.runner==="docker-compose"&&"bash_script"in t&&delete t.bash_script,"pre_launch_script"in t&&!t.pre_launch_script&&delete t.pre_launch_script,t}function La(e){let t=Yr(e);return JSON.stringify(t,(r,o)=>typeof o=="number"&&(isNaN(o)||!isFinite(o))?null:o)}function Ra(e,t=!1){t&&(e=$a(e));let r=La(e);return Ba.default.createHash("sha256").update(r,"utf8").digest("hex")}});var is=W(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.toBig=y.shrSL=y.shrSH=y.rotrSL=y.rotrSH=y.rotrBL=y.rotrBH=y.rotr32L=y.rotr32H=y.rotlSL=y.rotlSH=y.rotlBL=y.rotlBH=y.add5L=y.add5H=y.add4L=y.add4H=y.add3L=y.add3H=void 0;y.add=Qn;y.fromBig=eo;y.split=On;var hr=BigInt(2**32-1),Qr=BigInt(32);function eo(e,t=!1){return t?{h:Number(e&hr),l:Number(e>>Qr&hr)}:{h:Number(e>>Qr&hr)|0,l:Number(e&hr)|0}}function On(e,t=!1){let r=e.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=eo(e[s],t);[o[s],n[s]]=[i,a]}return[o,n]}var jn=(e,t)=>BigInt(e>>>0)<<Qr|BigInt(t>>>0);y.toBig=jn;var Nn=(e,t,r)=>e>>>r;y.shrSH=Nn;var Mn=(e,t,r)=>e<<32-r|t>>>r;y.shrSL=Mn;var Dn=(e,t,r)=>e>>>r|t<<32-r;y.rotrSH=Dn;var Gn=(e,t,r)=>e<<32-r|t>>>r;y.rotrSL=Gn;var qn=(e,t,r)=>e<<64-r|t>>>r-32;y.rotrBH=qn;var Vn=(e,t,r)=>e>>>r-32|t<<64-r;y.rotrBL=Vn;var Kn=(e,t)=>t;y.rotr32H=Kn;var Wn=(e,t)=>e;y.rotr32L=Wn;var Xn=(e,t,r)=>e<<r|t>>>32-r;y.rotlSH=Xn;var Jn=(e,t,r)=>t<<r|e>>>32-r;y.rotlSL=Jn;var Zn=(e,t,r)=>t<<r-32|e>>>64-r;y.rotlBH=Zn;var Yn=(e,t,r)=>e<<r-32|t>>>64-r;y.rotlBL=Yn;function Qn(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/2**32|0)|0,l:n|0}}var es=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);y.add3L=es;var ts=(e,t,r,o)=>t+r+o+(e/2**32|0)|0;y.add3H=ts;var rs=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0);y.add4L=rs;var os=(e,t,r,o,n)=>t+r+o+n+(e/2**32|0)|0;y.add4H=os;var ns=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0);y.add5L=ns;var ss=(e,t,r,o,n,s)=>t+r+o+n+s+(e/2**32|0)|0;y.add5H=ss;var Ua={fromBig:eo,split:On,toBig:jn,shrSH:Nn,shrSL:Mn,rotrSH:Dn,rotrSL:Gn,rotrBH:qn,rotrBL:Vn,rotr32H:Kn,rotr32L:Wn,rotlSH:Xn,rotlSL:Jn,rotlBH:Zn,rotlBL:Yn,add:Qn,add3L:es,add3H:ts,add4L:rs,add4H:os,add5H:ss,add5L:ns};y.default=Ua});var as=W(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0});xr.crypto=void 0;var Re=we("crypto");xr.crypto=Re&&typeof Re=="object"&&"webcrypto"in Re?Re.webcrypto:Re&&typeof Re=="object"&&"randomBytes"in Re?Re:void 0});var hs=W(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.wrapXOFConstructorWithOpts=x.wrapConstructorWithOpts=x.wrapConstructor=x.Hash=x.nextTick=x.swap32IfBE=x.byteSwapIfBE=x.swap8IfBE=x.isLE=void 0;x.isBytes=ls;x.anumber=to;x.abytes=at;x.ahash=za;x.aexists=Ha;x.aoutput=Fa;x.u8=Oa;x.u32=ja;x.clean=Na;x.createView=Ma;x.rotr=Da;x.rotl=Ga;x.byteSwap=oo;x.byteSwap32=ps;x.bytesToHex=Va;x.hexToBytes=Ka;x.asyncLoop=Xa;x.utf8ToBytes=no;x.bytesToUtf8=Ja;x.toBytes=gr;x.kdfInputToBytes=Za;x.concatBytes=Ya;x.checkOpts=Qa;x.createHasher=fs;x.createOptHasher=ms;x.createXOFer=ds;x.randomBytes=ec;var it=as();function ls(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function to(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function at(e,...t){if(!ls(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function za(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");to(e.outputLen),to(e.blockLen)}function Ha(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Fa(e,t){at(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Oa(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function ja(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Na(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ma(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Da(e,t){return e<<32-t|e>>>t}function Ga(e,t){return e<<t|e>>>32-t>>>0}x.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function oo(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}x.swap8IfBE=x.isLE?e=>e:e=>oo(e);x.byteSwapIfBE=x.swap8IfBE;function ps(e){for(let t=0;t<e.length;t++)e[t]=oo(e[t]);return e}x.swap32IfBE=x.isLE?e=>e:ps;var us=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",qa=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Va(e){if(at(e),us)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=qa[e[r]];return t}var Te={_0:48,_9:57,A:65,F:70,a:97,f:102};function cs(e){if(e>=Te._0&&e<=Te._9)return e-Te._0;if(e>=Te.A&&e<=Te.F)return e-(Te.A-10);if(e>=Te.a&&e<=Te.f)return e-(Te.a-10)}function Ka(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(us)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let o=new Uint8Array(r);for(let n=0,s=0;n<r;n++,s+=2){let i=cs(e.charCodeAt(s)),a=cs(e.charCodeAt(s+1));if(i===void 0||a===void 0){let l=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+s)}o[n]=i*16+a}return o}var Wa=async()=>{};x.nextTick=Wa;async function Xa(e,t,r){let o=Date.now();for(let n=0;n<e;n++){r(n);let s=Date.now()-o;s>=0&&s<t||(await(0,x.nextTick)(),o+=s)}}function no(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Ja(e){return new TextDecoder().decode(e)}function gr(e){return typeof e=="string"&&(e=no(e)),at(e),e}function Za(e){return typeof e=="string"&&(e=no(e)),at(e),e}function Ya(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];at(n),t+=n.length}let r=new Uint8Array(t);for(let o=0,n=0;o<e.length;o++){let s=e[o];r.set(s,n),n+=s.length}return r}function Qa(e,t){if(t!==void 0&&{}.toString.call(t)!=="[object Object]")throw new Error("options should be object or undefined");return Object.assign(e,t)}var ro=class{};x.Hash=ro;function fs(e){let t=o=>e().update(gr(o)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function ms(e){let t=(o,n)=>e(n).update(gr(o)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=o=>e(o),t}function ds(e){let t=(o,n)=>e(n).update(gr(o)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=o=>e(o),t}x.wrapConstructor=fs;x.wrapConstructorWithOpts=ms;x.wrapXOFConstructorWithOpts=ds;function ec(e=32){if(it.crypto&&typeof it.crypto.getRandomValues=="function")return it.crypto.getRandomValues(new Uint8Array(e));if(it.crypto&&typeof it.crypto.randomBytes=="function")return Uint8Array.from(it.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}});var ks=W(A=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0});A.shake256=A.shake128=A.keccak_512=A.keccak_384=A.keccak_256=A.keccak_224=A.sha3_512=A.sha3_384=A.sha3_256=A.sha3_224=A.Keccak=void 0;A.keccakP=_s;var $t=is(),M=hs(),tc=BigInt(0),Bt=BigInt(1),rc=BigInt(2),oc=BigInt(7),nc=BigInt(256),sc=BigInt(113),bs=[],ys=[],vs=[];for(let e=0,t=Bt,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],bs.push(2*(5*o+r)),ys.push((e+1)*(e+2)/2%64);let n=tc;for(let s=0;s<7;s++)t=(t<<Bt^(t>>oc)*sc)%nc,t&rc&&(n^=Bt<<(Bt<<BigInt(s))-Bt);vs.push(n)}var ws=(0,$t.split)(vs,!0),ic=ws[0],ac=ws[1],xs=(e,t,r)=>r>32?(0,$t.rotlBH)(e,t,r):(0,$t.rotlSH)(e,t,r),gs=(e,t,r)=>r>32?(0,$t.rotlBL)(e,t,r):(0,$t.rotlSL)(e,t,r);function _s(e,t=24){let r=new Uint32Array(10);for(let o=24-t;o<24;o++){for(let i=0;i<10;i++)r[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){let a=(i+8)%10,l=(i+2)%10,u=r[l],f=r[l+1],p=xs(u,f,1)^r[a],d=gs(u,f,1)^r[a+1];for(let h=0;h<50;h+=10)e[i+h]^=p,e[i+h+1]^=d}let n=e[2],s=e[3];for(let i=0;i<24;i++){let a=ys[i],l=xs(n,s,a),u=gs(n,s,a),f=bs[i];n=e[f],s=e[f+1],e[f]=l,e[f+1]=u}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)r[a]=e[i+a];for(let a=0;a<10;a++)e[i+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=ic[o],e[1]^=ac[o]}(0,M.clean)(r)}var Lt=class e extends M.Hash{constructor(t,r,o,n=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=r,this.outputLen=o,this.enableXOF=n,this.rounds=s,(0,M.anumber)(o),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=(0,M.u32)(this.state)}clone(){return this._cloneInto()}keccak(){(0,M.swap32IfBE)(this.state32),_s(this.state32,this.rounds),(0,M.swap32IfBE)(this.state32),this.posOut=0,this.pos=0}update(t){(0,M.aexists)(this),t=(0,M.toBytes)(t),(0,M.abytes)(t);let{blockLen:r,state:o}=this,n=t.length;for(let s=0;s<n;){let i=Math.min(r-this.pos,n-s);for(let a=0;a<i;a++)o[this.pos++]^=t[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:t,suffix:r,pos:o,blockLen:n}=this;t[o]^=r,(r&128)!==0&&o===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){(0,M.aexists)(this,!1),(0,M.abytes)(t),this.finish();let r=this.state,{blockLen:o}=this;for(let n=0,s=t.length;n<s;){this.posOut>=o&&this.keccak();let i=Math.min(o-this.posOut,s-n);t.set(r.subarray(this.posOut,this.posOut+i),n),this.posOut+=i,n+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return(0,M.anumber)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,M.aoutput)(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,(0,M.clean)(this.state)}_cloneInto(t){let{blockLen:r,suffix:o,outputLen:n,rounds:s,enableXOF:i}=this;return t||(t=new e(r,o,n,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=o,t.outputLen=n,t.enableXOF=i,t.destroyed=this.destroyed,t}};A.Keccak=Lt;var Ue=(e,t,r)=>(0,M.createHasher)(()=>new Lt(t,e,r));A.sha3_224=Ue(6,144,224/8);A.sha3_256=Ue(6,136,256/8);A.sha3_384=Ue(6,104,384/8);A.sha3_512=Ue(6,72,512/8);A.keccak_224=Ue(1,144,224/8);A.keccak_256=Ue(1,136,256/8);A.keccak_384=Ue(1,104,384/8);A.keccak_512=Ue(1,72,512/8);var Cs=(e,t,r)=>(0,M.createXOFer)((o={})=>new Lt(t,e,o.dkLen===void 0?r:o.dkLen,!0));A.shake128=Cs(31,168,128/8);A.shake256=Cs(31,136,256/8)});var Ts=W(so=>{"use strict";Object.defineProperty(so,"__esModule",{value:!0});so.verifyEnvEncryptPublicKey=pc;var cc=ks(),lc=we("@noble/curves/secp256k1");function pc(e,t,r){if(t.length!==65)return null;let o=Buffer.from("dstack-env-encrypt-pubkey","utf8"),n=r;r.startsWith("0x")&&(n=r.slice(2));let s=Buffer.from(n,"hex"),i=Buffer.from(":","utf8"),a=Buffer.concat([o,i,s,Buffer.from(e)]),l=(0,cc.keccak_256)(a);try{let u=t.slice(0,32),f=t.slice(32,64),p=t[64],d=new Uint8Array(64);d.set(u,0),d.set(f,32);let h=lc.secp256k1.Signature.fromCompact(d).addRecoveryBit(p).recoverPublicKey(l);return"0x"+Buffer.from(h.toRawBytes(!0)).toString("hex")}catch(u){return console.error("signature verification failed:",u),null}}});var Ps=ht(So(),1);import{ofetch as uc}from"ofetch";function Io(e){return{all:e=e||new Map,on:function(t,r){var o=e.get(t);o?o.push(r):e.set(t,[r])},off:function(t,r){var o=e.get(t);o&&(r?o.splice(o.indexOf(r)>>>0,1):e.set(t,[]))},emit:function(t,r){var o=e.get(t);o&&o.slice().map(function(n){n(r)}),(o=e.get("*"))&&o.slice().map(function(n){n(t,r)})}}}import{z as F}from"zod";import{z as ze}from"zod";import{z as w}from"zod";import{z as He}from"zod";function Ne(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}Mt();Me();Mt();var Br={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function vt(e,t){let r={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?Ge(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?Ge(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Br[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(r.authorizationList=ji(e.authorizationList)),r.yParity=(()=>{if(e.yParity)return Number(e.yParity);if(typeof r.v=="bigint"){if(r.v===0n||r.v===27n)return 0;if(r.v===1n||r.v===28n)return 1;if(r.v>=35n)return r.v%2n===0n?1:0}})(),r.type==="legacy"&&(delete r.accessList,delete r.maxFeePerBlobGas,delete r.maxFeePerGas,delete r.maxPriorityFeePerGas,delete r.yParity),r.type==="eip2930"&&(delete r.maxFeePerBlobGas,delete r.maxFeePerGas,delete r.maxPriorityFeePerGas),r.type==="eip1559"&&delete r.maxFeePerBlobGas,r}var Lo=et("transaction",vt);function ji(e){return e.map(t=>({address:t.address,chainId:Number(t.chainId),nonce:Number(t.nonce),r:t.r,s:t.s,yParity:Number(t.yParity)}))}function Ni(e,t){let r=(e.transactions??[]).map(o=>typeof o=="string"?o:vt(o));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:r,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}var Ro=et("block",Ni);function Uo(e,{args:t,eventName:r}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...r?{args:t,eventName:r}:{}}}Me();Mt();var Mi={"0x0":"reverted","0x1":"success"};function Di(e,t){let r={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map(o=>Uo(o)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Ge(e.transactionIndex):null,status:e.status?Mi[e.status]:null,type:e.type?Br[e.type]||e.type:null};return e.blobGasPrice&&(r.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(r.blobGasUsed=BigInt(e.blobGasUsed)),r}var zo=et("transactionReceipt",Di);oe();Lr();Be();se();function Ce(e,t="hex"){let r=Oo(e),o=Vt(new Uint8Array(r.length));return r.encode(o),t==="hex"?J(o.bytes):o.bytes}function Oo(e){return Array.isArray(e)?qi(e.map(t=>Oo(t))):Vi(e)}function qi(e){let t=e.reduce((n,s)=>n+s.length,0),r=jo(t);return{length:t<=55?1+t:1+r+t,encode(n){t<=55?n.pushByte(192+t):(n.pushByte(247+r),r===1?n.pushUint8(t):r===2?n.pushUint16(t):r===3?n.pushUint24(t):n.pushUint32(t));for(let{encode:s}of e)s(n)}}}function Vi(e){let t=typeof e=="string"?pe(e):e,r=jo(t.length);return{length:t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+r+t.length,encode(n){t.length===1&&t[0]<128?n.pushBytes(t):t.length<=55?(n.pushByte(128+t.length),n.pushBytes(t)):(n.pushByte(183+r),r===1?n.pushUint8(t.length):r===2?n.pushUint16(t.length):r===3?n.pushUint24(t.length):n.pushUint32(t.length),n.pushBytes(t))}}}function jo(e){if(e<2**8)return 1;if(e<2**16)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new b("Length is too large.")}Jt();se();function Vo(e){if(!e||e.length===0)return[];let t=[];for(let r of e){let{chainId:o,nonce:n,...s}=r,i=r.address;t.push([o?le(o):"0x",i,n?le(n):"0x",...tt({},s)])}return t}Be();se();function Zt(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),o=typeof e.blobs[0]=="string"?e.blobs.map(s=>pe(s)):e.blobs,n=[];for(let s of o)n.push(Uint8Array.from(t.blobToKzgCommitment(s)));return r==="bytes"?n:n.map(s=>J(s))}Be();se();function Yt(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),o=typeof e.blobs[0]=="string"?e.blobs.map(i=>pe(i)):e.blobs,n=typeof e.commitments[0]=="string"?e.commitments.map(i=>pe(i)):e.commitments,s=[];for(let i=0;i<o.length;i++){let a=o[i],l=n[i];s.push(Uint8Array.from(t.computeBlobKzgProof(a,l)))}return r==="bytes"?s:s.map(i=>J(i))}se();rr();function Qi(e,t,r,o){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,o);let n=BigInt(32),s=BigInt(4294967295),i=Number(r>>n&s),a=Number(r&s),l=o?4:0,u=o?0:4;e.setUint32(t+l,i,o),e.setUint32(t+u,a,o)}function Wo(e,t,r){return e&t^~e&r}function Xo(e,t,r){return e&t^e&r^t&r}var or=class extends rt{constructor(t,r,o,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(t),this.view=er(this.buffer)}update(t){ot(this),t=Ct(t),Ve(t);let{view:r,buffer:o,blockLen:n}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(n-this.pos,s-i);if(a===n){let l=er(t);for(;n<=s-i;i+=n)this.process(l,i);continue}o.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ot(this),Qt(t,this),this.finished=!0;let{buffer:r,view:o,blockLen:n,isLE:s}=this,{pos:i}=this;r[i++]=128,$e(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let p=i;p<n;p++)r[p]=0;Qi(o,n-8,BigInt(this.length*8),s),this.process(o,0);let a=er(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=l/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<u;p++)a.setUint32(4*p,f[p],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let o=t.slice(0,r);return this.destroy(),o}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:o,length:n,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=n,t.pos=a,n%r&&t.buffer.set(o),t}clone(){return this._cloneInto()}},ke=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);rr();var ta=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Le=new Uint32Array(64),sr=class extends or{constructor(t=32){super(64,t,8,!1),this.A=ke[0]|0,this.B=ke[1]|0,this.C=ke[2]|0,this.D=ke[3]|0,this.E=ke[4]|0,this.F=ke[5]|0,this.G=ke[6]|0,this.H=ke[7]|0}get(){let{A:t,B:r,C:o,D:n,E:s,F:i,G:a,H:l}=this;return[t,r,o,n,s,i,a,l]}set(t,r,o,n,s,i,a,l){this.A=t|0,this.B=r|0,this.C=o|0,this.D=n|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=l|0}process(t,r){for(let p=0;p<16;p++,r+=4)Le[p]=t.getUint32(r,!1);for(let p=16;p<64;p++){let d=Le[p-15],h=Le[p-2],I=ue(d,7)^ue(d,18)^d>>>3,T=ue(h,17)^ue(h,19)^h>>>10;Le[p]=T+Le[p-7]+I+Le[p-16]|0}let{A:o,B:n,C:s,D:i,E:a,F:l,G:u,H:f}=this;for(let p=0;p<64;p++){let d=ue(a,6)^ue(a,11)^ue(a,25),h=f+d+Wo(a,l,u)+ta[p]+Le[p]|0,T=(ue(o,2)^ue(o,13)^ue(o,22))+Xo(o,n,s)|0;f=u,u=l,l=a,a=i+h|0,i=s,s=n,n=o,o=h+T|0}o=o+this.A|0,n=n+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,l=l+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(o,n,s,i,a,l,u,f)}roundClean(){$e(Le)}destroy(){this.set(0,0,0,0,0,0,0,0),$e(this.buffer)}};var on=tr(()=>new sr);var nn=on;Qe();Be();se();function sn(e,t){let r=t||"hex",o=nn(de(e,{strict:!1})?Nt(e):e);return r==="bytes"?o:le(o)}function an(e){let{commitment:t,version:r=1}=e,o=e.to??(typeof t=="string"?"hex":"bytes"),n=sn(t,"bytes");return n.set([r],0),o==="bytes"?n:J(n)}function cn(e){let{commitments:t,version:r}=e,o=e.to??(typeof t[0]=="string"?"hex":"bytes"),n=[];for(let s of t)n.push(an({commitment:s,to:o,version:r}));return n}oe();var ir=class extends b{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}},nt=class extends b{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}},ar=class extends b{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}},cr=class extends b{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${1}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}};Lr();xt();Be();se();function ln(e){let t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?pe(e.data):e.data,o=ne(r);if(!o)throw new nt;if(o>761855)throw new ir({maxSize:761855,size:o});let n=[],s=!0,i=0;for(;s;){let a=Vt(new Uint8Array(131072)),l=0;for(;l<4096;){let u=r.slice(i,i+31);if(a.pushByte(0),a.pushBytes(u),u.length<31){a.pushByte(128),s=!1;break}l++,i+=31}n.push(a)}return t==="bytes"?n.map(a=>a.bytes):n.map(a=>J(a.bytes))}function pn(e){let{data:t,kzg:r,to:o}=e,n=e.blobs??ln({data:t,to:o}),s=e.commitments??Zt({blobs:n,kzg:r,to:o}),i=e.proofs??Yt({blobs:n,commitments:s,kzg:r,to:o}),a=[];for(let l=0;l<n.length;l++)a.push({blob:n[l],commitment:s[l],proof:i[l]});return a}$r();Bo();se();Ho();lr();oe();un();fn();ur();xt();In();Me();function An(e){let{authorizationList:t}=e;if(t)for(let r of t){let{chainId:o}=r,n=r.address;if(!he(n))throw new ie({address:n});if(o<0)throw new Ke({chainId:o})}fr(e)}function Pn(e){let{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new nt;for(let r of t){let o=ne(r),n=Ge(Tn(r,0,1));if(o!==32)throw new ar({hash:r,size:o});if(n!==1)throw new cr({hash:r,version:n})}}fr(e)}function fr(e){let{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:o,to:n}=e;if(t<=0)throw new Ke({chainId:t});if(n&&!he(n))throw new ie({address:n});if(o&&o>Dt)throw new We({maxFeePerGas:o});if(r&&o&&r>o)throw new kt({maxFeePerGas:o,maxPriorityFeePerGas:r})}function Bn(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:o,maxFeePerGas:n,to:s}=e;if(t<=0)throw new Ke({chainId:t});if(s&&!he(s))throw new ie({address:s});if(r||n)throw new b("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(o&&o>Dt)throw new We({maxFeePerGas:o})}function $n(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:o,maxFeePerGas:n,to:s}=e;if(s&&!he(s))throw new ie({address:s});if(typeof t<"u"&&t<=0)throw new Ke({chainId:t});if(r||n)throw new b("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(o&&o>Dt)throw new We({maxFeePerGas:o})}Jt();function Ln(e){if(e.type)return e.type;if(typeof e.authorizationList<"u")return"eip7702";if(typeof e.blobs<"u"||typeof e.blobVersionedHashes<"u"||typeof e.maxFeePerBlobGas<"u"||typeof e.sidecars<"u")return"eip4844";if(typeof e.maxFeePerGas<"u"||typeof e.maxPriorityFeePerGas<"u")return"eip1559";if(typeof e.gasPrice<"u")return typeof e.accessList<"u"?"eip2930":"legacy";throw new Wt({transaction:e})}lr();Jt();ur();function Et(e){if(!e||e.length===0)return[];let t=[];for(let r=0;r<e.length;r++){let{address:o,storageKeys:n}=e[r];for(let s=0;s<n.length;s++)if(n[s].length-2!==64)throw new Xt({storageKey:n[s]});if(!he(o,{strict:!1}))throw new ie({address:o});t.push([o,n])}return t}function Rn(e,t){let r=Ln(e);return r==="eip1559"?ba(e,t):r==="eip2930"?ya(e,t):r==="eip4844"?ga(e,t):r==="eip7702"?xa(e,t):va(e,t)}function xa(e,t){let{authorizationList:r,chainId:o,gas:n,nonce:s,to:i,value:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:f,data:p}=e;An(e);let d=Et(f),h=Vo(r);return qe(["0x04",Ce([_(o),s?_(s):"0x",u?_(u):"0x",l?_(l):"0x",n?_(n):"0x",i??"0x",a?_(a):"0x",p??"0x",d,h,...tt(e,t)])])}function ga(e,t){let{chainId:r,gas:o,nonce:n,to:s,value:i,maxFeePerBlobGas:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:f,data:p}=e;Pn(e);let d=e.blobVersionedHashes,h=e.sidecars;if(e.blobs&&(typeof d>"u"||typeof h>"u")){let O=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(te=>J(te)),Q=e.kzg,ce=Zt({blobs:O,kzg:Q});if(typeof d>"u"&&(d=cn({commitments:ce})),typeof h>"u"){let te=Yt({blobs:O,commitments:ce,kzg:Q});h=pn({blobs:O,commitments:ce,proofs:te})}}let I=Et(f),T=[_(r),n?_(n):"0x",u?_(u):"0x",l?_(l):"0x",o?_(o):"0x",s??"0x",i?_(i):"0x",p??"0x",I,a?_(a):"0x",d??[],...tt(e,t)],P=[],V=[],K=[];if(h)for(let O=0;O<h.length;O++){let{blob:Q,commitment:ce,proof:te}=h[O];P.push(Q),V.push(ce),K.push(te)}return qe(["0x03",h?Ce([T,P,V,K]):Ce(T)])}function ba(e,t){let{chainId:r,gas:o,nonce:n,to:s,value:i,maxFeePerGas:a,maxPriorityFeePerGas:l,accessList:u,data:f}=e;fr(e);let p=Et(u),d=[_(r),n?_(n):"0x",l?_(l):"0x",a?_(a):"0x",o?_(o):"0x",s??"0x",i?_(i):"0x",f??"0x",p,...tt(e,t)];return qe(["0x02",Ce(d)])}function ya(e,t){let{chainId:r,gas:o,data:n,nonce:s,to:i,value:a,accessList:l,gasPrice:u}=e;Bn(e);let f=Et(l),p=[_(r),s?_(s):"0x",u?_(u):"0x",o?_(o):"0x",i??"0x",a?_(a):"0x",n??"0x",f,...tt(e,t)];return qe(["0x01",Ce(p)])}function va(e,t){let{chainId:r=0,gas:o,data:n,nonce:s,to:i,value:a,gasPrice:l}=e;$n(e);let u=[s?_(s):"0x",l?_(l):"0x",o?_(o):"0x",i??"0x",a?_(a):"0x",n??"0x"];if(t){let f=(()=>{if(t.v>=35n)return(t.v-35n)/2n>0?t.v:27n+(t.v===35n?0n:1n);if(r>0)return BigInt(r*2)+BigInt(35n+t.v-27n);let h=27n+(t.v===27n?0n:1n);if(t.v!==h)throw new Kt({v:t.v});return h})(),p=gt(t.r),d=gt(t.s);u=[...u,_(f),p==="0x00"?"0x":p,d==="0x00"?"0x":d]}else r>0&&(u=[...u,_(r),"0x","0x"]);return Ce(u)}function tt(e,t){let r=t??e,{v:o,yParity:n}=r;if(typeof r.r>"u")return[];if(typeof r.s>"u")return[];if(typeof o>"u"&&typeof n>"u")return[];let s=gt(r.r),i=gt(r.s);return[typeof n=="number"?n?_(1):"0x":o===0n?"0x":o===1n?_(1):o===27n?"0x":_(1),s==="0x00"?"0x":s,i==="0x00"?"0x":i]}var Un={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};Me();var zn={block:Ro({format(e){return{transactions:e.transactions?.map(r=>{if(typeof r=="string")return r;let o=vt(r);return o.typeHex==="0x7e"&&(o.isSystemTx=r.isSystemTx,o.mint=r.mint?De(r.mint):void 0,o.sourceHash=r.sourceHash,o.type="deposit"),o}),stateRoot:e.stateRoot}}}),transaction:Lo({format(e){let t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?De(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:zo({format(e){return{l1GasPrice:e.l1GasPrice?De(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?De(e.l1GasUsed):null,l1Fee:e.l1Fee?De(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};lr();ur();$r();se();function wa(e,t){return Ca(e)?_a(e):Rn(e,t)}var Hn={transaction:wa};function _a(e){ka(e);let{sourceHash:t,data:r,from:o,gas:n,isSystemTx:s,mint:i,to:a,value:l}=e,u=[t,o,a??"0x",i?le(i):"0x",l?le(l):"0x",n?le(n):"0x",s?"0x1":"0x",r??"0x"];return qe(["0x7e",Ce(u)])}function Ca(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function ka(e){let{from:t,to:r}=e;if(t&&!he(t))throw new ie({address:t});if(r&&!he(r))throw new ie({address:r})}var Wr={blockTime:2e3,contracts:Un,formatters:zn,serializers:Hn};var mr=Ne({id:31337,name:"Anvil",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["http://127.0.0.1:8545"],webSocket:["ws://127.0.0.1:8545"]}}});var St=1,It=Ne({...Wr,id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://basescan.org",apiUrl:"https://api.basescan.org/api"}},contracts:{...Wr.contracts,disputeGameFactory:{[St]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[St]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[St]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[St]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:St}),Ta=Ne({...It,experimental_preconfirmationTime:200,rpcUrls:{default:{http:["https://mainnet-preconf.base.org"]}}});var dr=Ne({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:12e3,rpcUrls:{default:{http:["https://eth.merkle.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensUniversalResolver:{address:"0xeeeeeeee14d718c2b47d9923deab1335e144eeee",blockCreated:23085558},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}});import{z as L}from"zod";import{z as ee}from"zod";import{z as m}from"zod";import{z as lt}from"zod";import{z as ae}from"zod";import{z as v}from"zod";import{z as C}from"zod";import{z as G}from"zod";import hl from"crypto";import{z as be}from"zod";import{z as fe}from"zod";import{z as j}from"zod";import{z as Z}from"zod";import{z as Y}from"zod";import{z as Kl}from"zod";import{z as Ss}from"zod";import{z as ye}from"zod";import{z as ft}from"zod";import{z as Xe}from"zod";import{z as wp}from"zod";import{z as Tp}from"zod";import{z as S}from"zod";import{z as ge}from"zod";import{z as jp}from"zod";import{z as $}from"zod";import{z as g}from"zod";import{z as ut}from"zod";import{z as Is}from"zod";import{z as D}from"zod";import{z as Gs}from"zod";import{z as xe}from"zod";import{z as U}from"zod";var tg=ht(Zr(),1);import{z as B}from"zod";var Cu=ht(Zr(),1),ku=ht(Fn(),1),Tu=ht(Ts(),1);import{z as pt}from"zod";var fc=F.object({detail:F.union([F.string(),F.array(F.object({msg:F.string(),type:F.string().optional(),ctx:F.record(F.unknown()).optional(),loc:F.array(F.union([F.string(),F.number()])).optional(),input:F.unknown().optional()}).passthrough()),F.record(F.unknown())]).optional(),type:F.string().optional(),code:F.string().optional()}),ve=class extends Error{constructor(e,t){super(e),this.name=this.constructor.name,this.status=t.status,this.statusText=t.statusText,this.detail=t.detail,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},io=class br extends ve{constructor(t,r){super(t,{status:r?.status??0,statusText:r?.statusText??"Unknown Error",detail:r?.detail||t}),this.name="RequestError",this.isRequestError=!0,this.data=r?.data,this.request=r?.request,this.response=r?.response,this.code=r?.code,this.type=r?.type}static fromFetchError(t){let r=fc.safeParse(t.data);return r.success?new br(t.message,{status:t.status??void 0,statusText:t.statusText??void 0,data:t.data,request:t.request??void 0,response:t.response??void 0,detail:r.data.detail,code:r.data.code??void 0,type:r.data.type??void 0}):new br(t.message,{status:t.status??void 0,statusText:t.statusText??void 0,data:t.data,request:t.request??void 0,response:t.response??void 0,detail:t.data?.detail||"Unknown API error",code:t.status?.toString()??void 0})}static fromError(t,r){return new br(t.message,{request:r??void 0,detail:t.message})}},mc=class extends ve{constructor(e,t){super(e,t),this.isValidationError=!0,this.validationErrors=t.validationErrors}},dc=class extends ve{constructor(){super(...arguments),this.isAuthError=!0}},Bs=class extends ve{constructor(){super(...arguments),this.isBusinessError=!0}},hc=class extends ve{constructor(){super(...arguments),this.isServerError=!0}},xc=class extends ve{constructor(){super(...arguments),this.isUnknownError=!0}};function gc(e){if(!e||!Array.isArray(e))return"unknown";let t=e.filter(r=>typeof r=="string"?!["body","query","path","header"].includes(r):!0);return t.length>0?t.join("."):"unknown"}function $s(e){if(!Array.isArray(e))return{errors:[],message:typeof e=="string"?e:"Validation error"};let t=e.map((n,s)=>{let i=gc(n.loc),a=i;return i==="unknown"&&n.type&&(a=n.type==="missing"?"required field":n.type),{field:a,message:n.msg,type:n.type,context:n.ctx}}),r=t.length,o=r===1?`Validation failed: ${t[0].message}`:`Validation failed (${r} issue${r>1?"s":""})`;return{errors:t,message:o}}function bc(e){return e===422?"validation":e===401||e===403?"auth":e>=400&&e<500?"business":e>=500?"server":"unknown"}function yc(e,t,r){if(e===422&&Array.isArray(t)){let{message:o}=$s(t);return o}if(typeof t=="string")return t;if(t&&typeof t=="object"&&"message"in t){let o=t.message;if(typeof o=="string")return o}return r}function vc(e){let t=e.status??0,r=e.statusText??"Unknown Error",o=e.detail,n=_c(o);if(n)return new wc(n.message,{status:t,statusText:r,detail:o,errorCode:n.error_code,structuredDetails:n.details,suggestions:n.suggestions,links:n.links});let s=bc(t),i=yc(t,o,e.message),a={status:t,statusText:r,detail:o};if(s==="validation"&&Array.isArray(o)){let{errors:l}=$s(o);return new mc(i,{...a,validationErrors:l})}return s==="auth"?new dc(i,a):s==="business"?new Bs(i,a):s==="server"?new hc(i,a):new xc(i,a)}var wc=class extends Bs{constructor(e,t){super(e,t),this.isResourceError=!0,this.errorCode=t.errorCode,this.structuredDetails=t.structuredDetails,this.suggestions=t.suggestions,this.links=t.links}};function _c(e){if(!e||typeof e!="object")return null;let t=e;return t.error_code&&typeof t.error_code=="string"&&t.message&&typeof t.message=="string"?{error_code:t.error_code,message:t.message,details:t.details,suggestions:t.suggestions,links:t.links}:null}var ao=["2025-05-31","2025-10-28"],ct=(0,Ps.default)("phala::api-client");function Cc(e){return Object.entries(e).map(([t,r])=>` -H "${t}: ${r}"`).join(`
12
+ `)}function kc(e){return e?` -d '${(typeof e=="string"?e:JSON.stringify(e,null,2)).replace(/'/g,"\\'")}'`:""}function Es(e,t,r,o){let n=[];r.forEach((a,l)=>{n.push(`${l}: ${a}`)});let s=n.join(`
13
13
  `),i=typeof o=="string"?o:JSON.stringify(o,null,2);return[`< HTTP/1.1 ${e} ${t}`,s?`< ${s.replace(/\n/g,`
14
14
  < `)}`:"","",i].filter(Boolean).join(`
15
- `)}var Cc=class{constructor(e={}){this.emitter=So();let t={...e,apiKey:e.apiKey||process?.env?.PHALA_CLOUD_API_KEY,baseURL:e.baseURL||process?.env?.PHALA_CLOUD_API_PREFIX||"https://cloud-api.phala.network/api/v1"},r=t.version&&ao.includes(t.version)?t.version:ao[ao.length-1];this.config=t;let{apiKey:o,baseURL:n,timeout:s,headers:i,useCookieAuth:a,onResponseError:l,...u}=t,f={"X-Phala-Version":r,"Content-Type":"application/json"};i&&typeof i=="object"&&Object.entries(i).forEach(([p,d])=>{typeof d=="string"&&(f[p]=d)}),!a&&o&&(f["X-API-Key"]=o),this.fetchInstance=lc.create({baseURL:n,timeout:s||3e4,headers:f,...a?{credentials:"include"}:{},...u,onRequest({request:p,options:d}){if(lt.enabled){let h=d.method||"GET",I=typeof p=="string"?p:p.url,T=I.startsWith("http")?I:`${n}${I}`,P={};d.headers&&typeof d.headers=="object"&&Object.entries(d.headers).forEach(([K,O])=>{typeof O=="string"&&(P[K]=O)});let V=[`> curl -X ${h} "${T}"`,wc(P),d.body?_c(d.body):""].filter(Boolean).join(`
16
- `);lt(`
15
+ `)}var Tc=class{constructor(e={}){this.emitter=Io();let t={...e,apiKey:e.apiKey||process?.env?.PHALA_CLOUD_API_KEY,baseURL:e.baseURL||process?.env?.PHALA_CLOUD_API_PREFIX||"https://cloud-api.phala.network/api/v1"},r=t.version&&ao.includes(t.version)?t.version:ao[ao.length-1];this.config=t;let{apiKey:o,baseURL:n,timeout:s,headers:i,useCookieAuth:a,onResponseError:l,...u}=t,f={"X-Phala-Version":r,"Content-Type":"application/json"};i&&typeof i=="object"&&Object.entries(i).forEach(([p,d])=>{typeof d=="string"&&(f[p]=d)}),!a&&o&&(f["X-API-Key"]=o),this.fetchInstance=uc.create({baseURL:n,timeout:s||3e4,headers:f,...a?{credentials:"include"}:{},...u,onRequest({request:p,options:d}){if(ct.enabled){let h=d.method||"GET",I=typeof p=="string"?p:p.url,T=I.startsWith("http")?I:`${n}${I}`,P={};d.headers&&typeof d.headers=="object"&&Object.entries(d.headers).forEach(([K,O])=>{typeof O=="string"&&(P[K]=O)});let V=[`> curl -X ${h} "${T}"`,Cc(P),d.body?kc(d.body):""].filter(Boolean).join(`
16
+ `);ct(`
17
17
  === REQUEST ===
18
18
  %s
19
- `,V)}},onResponse({request:p,response:d,options:h}){if(lt.enabled){let I=h.method||"GET",T=typeof p=="string"?p:p.url;lt(`
19
+ `,V)}},onResponse({request:p,response:d,options:h}){if(ct.enabled){let I=h.method||"GET",T=typeof p=="string"?p:p.url;ct(`
20
20
  === RESPONSE [%s %s] (%dms) ===
21
21
  %s
22
- `,I,T,d.headers.get("x-response-time")||"?",Ts(d.status,d.statusText,d.headers,d._data))}},onResponseError:({request:p,response:d,options:h})=>{if(console.warn(`HTTP ${d.status}: ${d.url}`),lt.enabled){let I=h.method||"GET",T=typeof p=="string"?p:p.url;lt(`
22
+ `,I,T,d.headers.get("x-response-time")||"?",Es(d.status,d.statusText,d.headers,d._data))}},onResponseError:({request:p,response:d,options:h})=>{if(console.warn(`HTTP ${d.status}: ${d.url}`),ct.enabled){let I=h.method||"GET",T=typeof p=="string"?p:p.url;ct(`
23
23
  === ERROR RESPONSE [%s %s] ===
24
24
  %s
25
- `,I,T,Ts(d.status,d.statusText,d.headers,d._data))}l&&l({request:p,response:d,options:h})}})}get raw(){return this.fetchInstance}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}once(e,t){let r=o=>{t(o),this.emitter.off(e,r)};this.emitter.on(e,r)}async get(e,t){try{return await this.fetchInstance(e,{...t,method:"GET"})}catch(r){let o=this.convertToRequestError(r);throw this.emitError(o)}}async post(e,t,r){try{return await this.fetchInstance(e,{...r,method:"POST",body:t})}catch(o){let n=this.convertToRequestError(o);throw this.emitError(n)}}async put(e,t,r){try{return await this.fetchInstance(e,{...r,method:"PUT",body:t})}catch(o){let n=this.convertToRequestError(o);throw this.emitError(n)}}async patch(e,t,r){try{return await this.fetchInstance(e,{...r,method:"PATCH",body:t})}catch(o){let n=this.convertToRequestError(o);throw this.emitError(n)}}async delete(e,t){try{return await this.fetchInstance(e,{...t,method:"DELETE"})}catch(r){let o=this.convertToRequestError(r);throw this.emitError(o)}}convertToRequestError(e){return e&&typeof e=="object"&&"data"in e?io.fromFetchError(e):e instanceof Error?io.fromError(e):new io("Unknown error occurred",{detail:"Unknown error occurred"})}emitError(e){let t=bc(e);return this.emitter.emit("error",t),t}async safeRequest(e){try{return{success:!0,data:await e()}}catch(t){if(t instanceof ve)return{success:!1,error:t};let r=this.convertToRequestError(t);return this.emitError(r),{success:!1,error:r}}}async safeGet(e,t){return this.safeRequest(()=>this.get(e,t))}async safePost(e,t,r){return this.safeRequest(()=>this.post(e,t,r))}async safePut(e,t,r){return this.safeRequest(()=>this.put(e,t,r))}async safePatch(e,t,r){return this.safeRequest(()=>this.patch(e,t,r))}async safeDelete(e,t){return this.safeRequest(()=>this.delete(e,t))}extend(e){let t=typeof e=="function"?e(this):e,r=Object.create(this);for(let[o,n]of Object.entries(t))typeof n=="function"&&(r[o]=(...s)=>n(this,...s));return r}};function kc(e={}){return new Cc(e)}function Ls(e){if(e?.schema!==void 0&&e?.schema!==!1&&(typeof e.schema!="object"||e.schema===null||!("parse"in e.schema)||typeof e.schema.parse!="function"))throw new Error("Invalid schema: must be a Zod schema object, false, or undefined")}function $s(e){if(e?.schema!==void 0&&e?.schema!==!1&&(typeof e.schema!="object"||e.schema===null||!("parse"in e.schema)||typeof e.schema.parse!="function"))return{success:!1,error:{name:"ZodError",message:"Invalid schema: must be a Zod schema object, false, or undefined",issues:[{code:"invalid_type",expected:"object",received:typeof e.schema,path:["schema"],message:"Invalid schema: must be a Zod schema object, false, or undefined"}]}}}function Rs(e,t){function r(i,a){return o(i,a)}async function o(i,a){Ls(a);let l=await t(i);return a?.schema===!1?l:(a?.schema||e).parse(l)}function n(i,a){return s(i,a)}async function s(i,a){let l=$s(a);if(l)return l;let u=await(async()=>{try{return{success:!0,data:await t(i)}}catch(p){return p&&typeof p=="object"&&"status"in p?{success:!1,error:p}:p&&typeof p=="object"&&"issues"in p?{success:!1,error:p}:{success:!1,error:{name:"Error",message:p instanceof Error?p.message:String(p)}}}})();return u.success?a?.schema===!1?{success:!0,data:u.data}:(a?.schema||e).safeParse(u.data):u}return{action:r,safeAction:n}}function k(e,t){function r(i,...a){let[l,u]=a;return o(i,l,u)}async function o(i,a,l){Ls(l);let u=await t(i,a);return l?.schema===!1?u:(l?.schema||e).parse(u)}function n(i,...a){let[l,u]=a;return s(i,l,u)}async function s(i,a,l){let u=$s(l);if(u)return u;let f=await(async()=>{try{return{success:!0,data:await t(i,a)}}catch(d){return d&&typeof d=="object"&&"status"in d?{success:!1,error:d}:d&&typeof d=="object"&&"issues"in d?{success:!1,error:d}:{success:!1,error:{name:"Error",message:d instanceof Error?d.message:String(d)}}}})();return f.success?l?.schema===!1?{success:!0,data:f.data}:(l?.schema||e).safeParse(f.data):f}return{action:r,safeAction:n}}var Tc=ze.object({username:ze.string(),email:ze.string(),credits:ze.number(),granted_credits:ze.number(),avatar:ze.string(),team_name:ze.string(),team_tier:ze.string()}).passthrough(),{action:Ec,safeAction:Sc}=Rs(Tc,async e=>await e.get("/auth/me")),Ic={[hr.id]:hr,[At.id]:At,[dr.id]:dr},Ac=Fe.object({id:Fe.string(),slug:Fe.string().nullable(),url:Fe.string(),version:Fe.string(),chain_id:Fe.number().nullable(),kms_contract_address:Fe.string().nullable().transform(e=>e),gateway_app_id:Fe.string().nullable().transform(e=>e)}).passthrough(),Ee=Ac.transform(e=>{if(e.chain_id!=null){let t=Ic[e.chain_id];if(t)return{...e,chain:t}}return e}),Pc=w.object({name:w.string(),is_dev:w.boolean(),version:w.union([w.tuple([w.number(),w.number(),w.number()]),w.tuple([w.number(),w.number(),w.number(),w.number()])]),os_image_hash:w.string().nullable().optional()}).passthrough(),Bc=w.object({teepod_id:w.number(),name:w.string(),listed:w.boolean(),resource_score:w.number(),remaining_vcpu:w.number(),remaining_memory:w.number(),remaining_cvm_slots:w.number(),images:w.array(Pc),support_onchain_kms:w.boolean().optional(),fmspc:w.string().nullable().optional(),device_id:w.string().nullable().optional(),region_identifier:w.string().nullable().optional(),default_kms:w.string().nullable().optional(),kms_list:w.array(w.string()).default([])}).passthrough(),Lc=w.object({max_instances:w.number().nullable().optional(),max_vcpu:w.number().nullable().optional(),max_memory:w.number().nullable().optional(),max_disk:w.number().nullable().optional()}).passthrough(),$c=w.object({tier:w.string(),capacity:Lc,nodes:w.array(Bc),kms_list:w.array(Ee)}).passthrough(),{action:Rc,safeAction:Uc}=Rs($c,async e=>await e.get("/teepods/available")),Us=$.object({id:$.string(),name:$.string(),description:$.string(),vcpu:$.number(),memory_mb:$.number(),hourly_rate:$.string(),requires_gpu:$.boolean(),default_disk_size_gb:$.number().default(20),family:$.string().nullable()}).passthrough(),zc=$.object({name:$.string(),items:$.array(Us),total:$.number()}).strict(),Fc=$.object({result:$.array(zc)}).strict(),Hc=$.object({items:$.array(Us),total:$.number(),family:$.string()}).strict(),Oc=$.object({family:$.string()}).strict(),{action:jc,safeAction:Nc}=k(Fc,async e=>await e.get("/instance-types")),{action:Gc,safeAction:Dc}=k(Hc,async(e,t)=>{let r=Oc.parse(t);return await e.get(`/instance-types/${r.family}`)}),zs=ee.object({id:ee.string(),name:ee.string(),slug:ee.string().nullable(),tier:ee.string(),role:ee.string(),created_at:ee.string()}).passthrough(),Mc=ee.object({has_more:ee.boolean(),next_cursor:ee.string().nullable(),total:ee.number().nullable()}).passthrough(),qc=ee.object({data:ee.array(zs),pagination:Mc}).passthrough(),{action:Vc,safeAction:Kc}=k(qc,async(e,t)=>{let r=new URLSearchParams;t?.cursor&&r.append("cursor",t.cursor),t?.limit&&r.append("limit",t.limit.toString());let o=r.toString()?`/workspaces?${r.toString()}`:"/workspaces";return await e.get(o)}),{action:Wc,safeAction:Xc}=k(zs,async(e,t)=>await e.get(`/workspaces/${t}`)),Jc=m.object({id:m.string(),name:m.string(),status:m.string(),uptime:m.string(),app_url:m.string().nullable(),app_id:m.string(),instance_id:m.string().nullable(),configuration:m.any().optional(),exited_at:m.string().nullable(),boot_progress:m.string().nullable(),boot_error:m.string().nullable(),shutdown_progress:m.string().nullable(),image_version:m.string().nullable()}),Zc=m.object({id:m.number(),username:m.string()}),lo=m.object({id:m.number(),name:m.string(),region_identifier:m.string().nullable().optional()}),Fs=m.object({app:m.string(),instance:m.string()}),Yc=m.object({hosted:Jc,name:m.string(),managed_user:Zc.nullable(),node:lo.nullable(),listed:m.boolean().default(!1),status:m.string(),in_progress:m.boolean().default(!1),dapp_dashboard_url:m.string().nullable(),syslog_endpoint:m.string().nullable(),allow_upgrade:m.boolean().default(!1),project_id:m.string().nullable(),project_type:m.string().nullable(),billing_period:m.string().nullable(),kms_info:Ee.nullable(),vcpu:m.number().nullable(),memory:m.number().nullable(),disk_size:m.number().nullable(),gateway_domain:m.string().nullable(),public_urls:m.array(Fs)}),Hs=m.object({id:m.number(),name:m.string(),status:m.string(),in_progress:m.boolean().optional().default(!1),teepod_id:m.number().nullable(),teepod:lo.optional().nullable(),app_id:m.string(),vm_uuid:m.string().nullable(),instance_id:m.string().nullable(),vcpu:m.number(),memory:m.number(),disk_size:m.number(),base_image:m.string().nullable(),encrypted_env_pubkey:m.string().nullable(),listed:m.boolean().optional().default(!1),project_id:m.string().optional().nullable(),project_type:m.string().optional().nullable(),public_sysinfo:m.boolean().optional().default(!1),public_logs:m.boolean().optional().default(!1),dapp_dashboard_url:m.string().optional().nullable(),syslog_endpoint:m.string().optional().nullable(),kms_info:Ee.optional().nullable(),contract_address:m.string().optional().nullable(),deployer_address:m.string().optional().nullable(),scheduled_delete_at:m.string().optional().nullable(),public_urls:m.array(Fs).optional().default([]),gateway_domain:m.string().optional().nullable()}),vr=m.object({id:m.number(),name:m.string(),status:m.string(),teepod_id:m.number(),teepod:lo.optional().nullable(),user_id:m.number().optional().nullable(),app_id:m.string(),vm_uuid:m.string().nullable(),instance_id:m.string().nullable(),app_url:m.string().optional().nullable(),base_image:m.string().nullable(),vcpu:m.number(),memory:m.number(),disk_size:m.number(),manifest_version:m.number().optional().nullable(),version:m.string().optional().nullable(),runner:m.string().optional().nullable(),docker_compose_file:m.string().optional().nullable(),features:m.array(m.string()).optional().nullable(),created_at:m.string(),encrypted_env_pubkey:m.string().nullable()}),He=Rt.object({id:Rt.string().optional(),uuid:Rt.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i,"Invalid UUID format").optional(),app_id:Rt.string().optional(),instance_id:Rt.string().optional()}),Oe=e=>e.refine(t=>{let r=t;return!!(r.id||r.uuid||r.app_id||r.instance_id)},{message:"One of id, uuid, app_id, or instance_id must be provided"}),Qc=Oe(He),R=Qc.transform(e=>{let t;if(e.id)t=e.id;else if(e.uuid)t=e.uuid;else if(e.app_id)t=e.app_id;else if(e.instance_id)t=e.instance_id;else throw new Error("No valid identifier provided");let r=/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i,o=/^[0-9a-f]{40}$/i,n;return r.test(t)?n=t.replace(/-/g,""):o.test(t)?n=`app_${t}`:n=t,{cvmId:n}}),el=R,{action:tl,safeAction:mt}=k(Hs,async(e,t)=>{let{cvmId:r}=el.parse(t);return await e.get(`/cvms/${r}`)}),rl=ae.object({page:ae.number().int().min(1).optional(),page_size:ae.number().int().min(1).optional(),node_id:ae.number().int().min(1).optional(),teepod_id:ae.number().int().min(1).optional(),user_id:ae.string().optional()}).strict(),ol=ae.object({items:ae.array(Yc),total:ae.number(),page:ae.number(),page_size:ae.number(),pages:ae.number()}).strict(),{action:nl,safeAction:wr}=k(ol,async(e,t)=>{let r=rl.parse(t??{});return await e.get("/cvms/paginated",{params:r})}),sl=v.object({app_id:v.string().nullable().optional(),app_env_encrypt_pubkey:v.string().nullable().optional(),compose_hash:v.string(),fmspc:v.string().nullable().optional(),device_id:v.string().nullable().optional(),os_image_hash:v.string().nullable().optional(),instance_type:v.string().nullable().optional(),teepod_id:v.number().nullable().optional(),node_id:v.number().nullable().optional(),kms_id:v.string().nullable().optional()}).passthrough().transform(e=>{if("teepod_id"in e&&e.teepod_id!==void 0){let{teepod_id:t,...r}=e;return{...r,node_id:t}}return e}),il=v.object({node_id:v.number().optional(),teepod_id:v.number().optional(),region:v.string().optional(),name:v.string(),instance_type:v.string().default("tdx.small"),image:v.string().optional(),vcpu:v.number().optional(),memory:v.number().optional(),disk_size:v.number().optional(),compose_file:v.object({allowed_envs:v.array(v.string()).optional(),pre_launch_script:v.string().optional(),docker_compose_file:v.string().optional(),name:v.string().optional().default(""),kms_enabled:v.boolean().optional(),public_logs:v.boolean().optional(),public_sysinfo:v.boolean().optional(),gateway_enabled:v.boolean().optional(),tproxy_enabled:v.boolean().optional()}),listed:v.boolean().optional(),kms_id:v.string().optional(),kms:v.enum(["PHALA","ETHEREUM","BASE"]).optional(),kms_contract:v.string().optional(),env_keys:v.array(v.string()).optional(),nonce:v.number().optional(),app_id:v.string().optional()}).passthrough();function al(e){if(!e.compose_file)return e;let t={...e.compose_file};return typeof t.gateway_enabled=="boolean"&&typeof t.tproxy_enabled=="boolean"?delete t.tproxy_enabled:typeof t.tproxy_enabled=="boolean"&&typeof t.gateway_enabled>"u"&&(t.gateway_enabled=t.tproxy_enabled,delete t.tproxy_enabled,(typeof window<"u"?window.console:globalThis.console)&&console.warn("[phala/cloud] tproxy_enabled is deprecated, please use gateway_enabled instead. See docs for migration.")),{...e,compose_file:t}}var{action:cl,safeAction:ll}=k(sl,async(e,t)=>{let r=il.parse(t),o=al(r),n={...o};return typeof o.node_id=="number"?(n={...o,teepod_id:o.node_id},delete n.node_id):typeof o.teepod_id=="number"&&console.warn("[phala/cloud] teepod_id is deprecated, please use node_id instead."),await e.post("/cvms/provision",n)}),pl=C.object({id:C.number(),name:C.string(),status:C.string(),teepod_id:C.number(),teepod:C.object({id:C.number(),name:C.string()}).nullable(),user_id:C.number().nullable(),app_id:C.string().nullable(),vm_uuid:C.string().nullable(),instance_id:C.string().nullable(),app_url:C.string().nullable(),base_image:C.string().nullable(),vcpu:C.number(),memory:C.number(),disk_size:C.number(),manifest_version:C.number().nullable(),version:C.string().nullable(),runner:C.string().nullable(),docker_compose_file:C.string().nullable(),features:C.array(C.string()).nullable(),created_at:C.string(),encrypted_env_pubkey:C.string().nullable().optional(),app_auth_contract_address:C.string().nullable().optional(),deployer_address:C.string().nullable().optional()}).passthrough(),Sx=C.object({encrypted_env:C.string().optional().nullable(),app_id:C.string(),compose_hash:C.string(),kms_id:C.string().optional(),contract_address:C.string().optional(),deployer_address:C.string().optional(),env_keys:C.array(C.string()).optional().nullable()}).passthrough(),{action:ul,safeAction:fl}=k(pl,async(e,t)=>await e.post("/cvms",t)),Os=M.object({allowed_envs:M.array(M.string()).optional(),docker_compose_file:M.string(),features:M.array(M.string()).optional(),name:M.string().optional(),manifest_version:M.number().optional(),kms_enabled:M.boolean().optional(),public_logs:M.boolean().optional(),public_sysinfo:M.boolean().optional(),tproxy_enabled:M.boolean().optional(),pre_launch_script:M.string().optional(),env_pubkey:M.string().optional(),salt:M.string().optional().nullable()}).passthrough();function co(e){return e==null?e:Array.isArray(e)?e.map(co):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let o=e[r];return t[r]=co(o),t},{}):e}function js(e){let t={...e};return t.runner==="bash"&&"docker_compose_file"in t?delete t.docker_compose_file:t.runner==="docker-compose"&&"bash_script"in t&&delete t.bash_script,"pre_launch_script"in t&&!t.pre_launch_script&&delete t.pre_launch_script,t}function Ns(e){let t=co(e),r=JSON.stringify(t,null,4);return r=r.replace(/": /g,'":'),r}function dl(e){let t=js(e),r=Ns(t);return ml.createHash("sha256").update(r,"utf8").digest("hex")}function hl(e){let t=e;return{...e,getHash:()=>dl(t),toString:()=>Ns(js(t))}}var xl=Os.transform(e=>hl(e)),gl=R,{action:bl,safeAction:po}=k(xl,async(e,t)=>{let{cvmId:r}=gl.parse(t);return await e.get(`/cvms/${r}/compose_file`)}),yl=be.object({id:be.string().optional(),uuid:be.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),app_id:be.string().refine(e=>!e.startsWith("app_")&&e.length===40,"app_id should be 40 characters without prefix").transform(e=>e.startsWith("app_")?e:`app_${e}`).optional(),instance_id:be.string().refine(e=>!e.startsWith("instance_")&&e.length===40,"instance_id should be 40 characters without prefix").transform(e=>e.startsWith("instance_")?e:`instance_${e}`).optional(),app_compose:Os,update_env_vars:be.boolean().optional().nullable()}).refine(e=>!!(e.id||e.uuid||e.app_id||e.instance_id),"One of id, uuid, app_id, or instance_id must be provided").transform(e=>({cvmId:e.id||e.uuid||e.app_id||e.instance_id,request:{...e.app_compose,update_env_vars:e.update_env_vars},_raw:e})),vl=be.object({app_id:be.string().nullable(),device_id:be.string().nullable(),compose_hash:be.string(),kms_info:Ee.nullable().optional()}).passthrough(),{action:wl,safeAction:_l}=k(vl,async(e,t)=>{let r=yl.parse(t);return await e.post(`/cvms/${r.cvmId}/compose_file/provision`,r.request)}),Cl=fe.object({id:fe.string().optional(),uuid:fe.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),app_id:fe.string().refine(e=>!e.startsWith("app_")&&e.length===40,"app_id should be 40 characters without prefix").transform(e=>e.startsWith("app_")?e:`app_${e}`).optional(),instance_id:fe.string().refine(e=>!e.startsWith("instance_")&&e.length===40,"instance_id should be 40 characters without prefix").transform(e=>e.startsWith("instance_")?e:`instance_${e}`).optional(),compose_hash:fe.string().min(1,"Compose hash is required"),encrypted_env:fe.string().optional(),env_keys:fe.array(fe.string()).optional(),update_env_vars:fe.boolean().optional().nullable()}).refine(e=>!!(e.id||e.uuid||e.app_id||e.instance_id),"One of id, uuid, app_id, or instance_id must be provided").transform(e=>({cvmId:e.id||e.uuid||e.app_id||e.instance_id,compose_hash:e.compose_hash,encrypted_env:e.encrypted_env,env_keys:e.env_keys,update_env_vars:!!e.update_env_vars,_raw:e})),kl=fe.any().transform(()=>{}),{action:Tl,safeAction:El}=k(kl,async(e,t)=>{let r=Cl.parse(t);return await e.patch(`/cvms/${r.cvmId}/compose_file`,{compose_hash:r.compose_hash,encrypted_env:r.encrypted_env,env_keys:r.env_keys})}),Sl=Oe(He.extend({encrypted_env:j.string().describe("Encrypted environment variables (hex string)"),env_keys:j.array(j.string()).optional().describe("List of allowed environment variable keys"),compose_hash:j.string().optional().describe("Compose hash for verification (Phase 2, required when env_keys changes)"),transaction_hash:j.string().optional().describe("On-chain transaction hash for verification (Phase 2, required when env_keys changes)")})).transform(e=>{let{cvmId:t}=R.parse(e);return{cvmId:t,request:{encrypted_env:e.encrypted_env,env_keys:e.env_keys,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),Il=j.object({status:j.literal("in_progress"),message:j.string(),correlation_id:j.string(),allowed_envs_changed:j.boolean()}),Al=j.object({status:j.literal("precondition_required"),message:j.string(),compose_hash:j.string(),app_id:j.string(),device_id:j.string(),kms_info:Ee}),Pl=j.union([Il,Al]),{action:Bl,safeAction:Ll}=k(Pl,async(e,t)=>{let r=Sl.parse(t);try{return await e.patch(`/cvms/${r.cvmId}/envs`,r.request)}catch(o){if(o instanceof ve&&o.status===465){let n=o.detail;if(n&&typeof n=="object"){let s=n;return{status:"precondition_required",message:s.message||"Compose hash verification required",compose_hash:s.compose_hash,app_id:s.app_id,device_id:s.device_id,kms_info:s.kms_info}}}throw o}}),$l=Oe(He.extend({docker_compose_file:Z.string().describe("Docker Compose YAML content"),compose_hash:Z.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:Z.string().optional().describe("On-chain transaction hash for verification (Phase 2, contract-owned KMS only)")})).transform(e=>{let{cvmId:t}=R.parse(e);return{cvmId:t,request:{docker_compose_file:e.docker_compose_file,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),Rl=Z.object({status:Z.literal("in_progress"),message:Z.string(),correlation_id:Z.string()}),Ul=Z.object({status:Z.literal("precondition_required"),message:Z.string(),compose_hash:Z.string(),app_id:Z.string(),device_id:Z.string(),kms_info:Ee}),zl=Z.union([Rl,Ul]),{action:Fl,safeAction:Hl}=k(zl,async(e,t)=>{let r=$l.parse(t),o={"Content-Type":"text/yaml"};r.request.compose_hash&&(o["X-Compose-Hash"]=r.request.compose_hash),r.request.transaction_hash&&(o["X-Transaction-Hash"]=r.request.transaction_hash);try{return await e.patch(`/cvms/${r.cvmId}/docker-compose`,r.request.docker_compose_file,{headers:o})}catch(n){if(n instanceof ve&&n.status===465){let s=n.detail;if(s&&typeof s=="object"){let i=s;return{status:"precondition_required",message:i.message||"Compose hash verification required",compose_hash:i.compose_hash,app_id:i.app_id,device_id:i.device_id,kms_info:i.kms_info}}}throw n}}),Ol=Oe(He.extend({pre_launch_script:Y.string().describe("Pre-launch script content (shell script)"),compose_hash:Y.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:Y.string().optional().describe("On-chain transaction hash for verification (Phase 2, contract-owned KMS only)")})).transform(e=>{let{cvmId:t}=R.parse(e);return{cvmId:t,request:{pre_launch_script:e.pre_launch_script,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),jl=Y.object({status:Y.literal("in_progress"),message:Y.string(),correlation_id:Y.string()}),Nl=Y.object({status:Y.literal("precondition_required"),message:Y.string(),compose_hash:Y.string(),app_id:Y.string(),device_id:Y.string(),kms_info:Ee}),Gl=Y.union([jl,Nl]),{action:Dl,safeAction:Ml}=k(Gl,async(e,t)=>{let r=Ol.parse(t),o={"Content-Type":"text/plain"};r.request.compose_hash&&(o["X-Compose-Hash"]=r.request.compose_hash),r.request.transaction_hash&&(o["X-Transaction-Hash"]=r.request.transaction_hash);try{return await e.patch(`/cvms/${r.cvmId}/pre-launch-script`,r.request.pre_launch_script,{headers:o})}catch(n){if(n instanceof ve&&n.status===465){let s=n.detail;if(s&&typeof s=="object"){let i=s;return{status:"precondition_required",message:i.message||"Compose hash verification required",compose_hash:i.compose_hash,app_id:i.app_id,device_id:i.device_id,kms_info:i.kms_info}}}throw n}}),Vl=R,{action:Kl,safeAction:Wl}=k(ql.string(),async(e,t)=>{let{cvmId:r}=Vl.parse(t);return await e.get(`/cvms/${r}/pre-launch-script`)}),Xl=Es.object({kms_id:Es.string().min(1,"KMS ID is required")}),{action:Jl,safeAction:Zl}=k(Ee,async(e,t)=>{let r=Xl.parse(t);return await e.get(`/kms/${r.kms_id}`)}),Yl=ye.object({page:ye.number().int().min(1).optional(),page_size:ye.number().int().min(1).optional(),is_onchain:ye.boolean().optional()}).strict(),Ql=ye.object({items:ye.array(Ee),total:ye.number(),page:ye.number(),page_size:ye.number(),pages:ye.number()}).strict(),{action:ep,safeAction:tp}=k(Ql,async(e,t)=>{let r=Yl.parse(t??{});return await e.get("/kms",{params:r})}),rp=ft.object({kms:ft.string().min(1,"KMS ID or slug is required"),app_id:ft.string().refine(e=>e.length===40||e.startsWith("0x")&&e.length===42,"App ID must be exactly 40 characters or 42 characters with 0x prefix")}).strict(),op=ft.object({public_key:ft.string(),signature:ft.string()}).strict(),{action:np,safeAction:sp}=k(op,async(e,t)=>{let r=rp.parse(t);return await e.get(`/kms/${r.kms}/pubkey/${r.app_id}`)}),ip=Je.object({counts:Je.number().int().min(1).max(20).optional().default(1)}).strict(),ap=Je.object({app_ids:Je.array(Je.object({app_id:Je.string(),nonce:Je.number().int().min(0)}))}).strict(),{action:cp,safeAction:lp}=k(ap,async(e,t)=>{let r=ip.parse(t??{}),o=new URLSearchParams;return o.append("counts",r.counts.toString()),await e.get(`/kms/phala/next_app_id?${o.toString()}`)}),pp=R,{action:up,safeAction:fp}=k(vr,async(e,t)=>{let{cvmId:r}=pp.parse(t);return await e.post(`/cvms/${r}/start`)}),mp=R,{action:dp,safeAction:hp}=k(vr,async(e,t)=>{let{cvmId:r}=mp.parse(t);return await e.post(`/cvms/${r}/stop`)}),xp=R,{action:gp,safeAction:bp}=k(vr,async(e,t)=>{let{cvmId:r}=xp.parse(t);return await e.post(`/cvms/${r}/shutdown`)}),vp=Oe(He.extend({force:yp.boolean().optional()})),{action:wp,safeAction:_p}=k(vr,async(e,t)=>{let r=vp.parse(t),{cvmId:o}=R.parse(r),{force:n=!1}=r;return await e.post(`/cvms/${o}/restart`,{force:n})}),kp=R,{action:Tp,safeAction:Ep}=k(Cp.void(),async(e,t)=>{let{cvmId:r}=kp.parse(t);await e.delete(`/cvms/${r}`)}),Sp=S.object({name:S.string(),mount_point:S.string(),total_size:S.number(),free_size:S.number()}),Ip=S.object({os_name:S.string(),os_version:S.string(),kernel_version:S.string(),cpu_model:S.string(),num_cpus:S.number(),total_memory:S.number(),available_memory:S.number(),used_memory:S.number(),free_memory:S.number(),total_swap:S.number(),used_swap:S.number(),free_swap:S.number(),uptime:S.number(),loadavg_one:S.number(),loadavg_five:S.number(),loadavg_fifteen:S.number(),disks:S.array(Sp)}),Ap=S.object({is_online:S.boolean(),is_public:S.boolean().default(!1),error:S.string().nullable(),sysinfo:Ip.nullable(),status:S.string().nullable(),in_progress:S.boolean().default(!1),boot_progress:S.string().nullable(),boot_error:S.string().nullable()}),Pp=R,{action:Bp,safeAction:Lp}=k(Ap,async(e,t)=>{let{cvmId:r}=Pp.parse(t);return await e.get(`/cvms/${r}/stats`)}),$p=ge.object({app:ge.string(),instance:ge.string()}),Rp=ge.object({is_online:ge.boolean(),is_public:ge.boolean().default(!0),error:ge.string().nullable(),internal_ip:ge.string().nullable(),latest_handshake:ge.string().nullable(),public_urls:ge.array($p).nullable()}),Up=R,{action:zp,safeAction:Fp}=k(Rp,async(e,t)=>{let{cvmId:r}=Up.parse(t);return await e.get(`/cvms/${r}/network`)}),Op=R,{action:jp,safeAction:Np}=k(Hp.string(),async(e,t)=>{let{cvmId:r}=Op.parse(t);return await e.get(`/cvms/${r}/docker-compose.yml`)}),Gp=L.object({id:L.string(),names:L.array(L.string()),image:L.string(),image_id:L.string(),command:L.string().nullable().optional(),created:L.number(),state:L.string(),status:L.string(),log_endpoint:L.string().nullable()}),Dp=L.object({is_online:L.boolean(),is_public:L.boolean().default(!0),error:L.string().nullable(),docker_compose_file:L.string().nullable(),manifest_version:L.number().nullable(),version:L.string().nullable(),runner:L.string().nullable(),features:L.array(L.string()).nullable(),containers:L.array(Gp).nullable()}),Mp=R,{action:qp,safeAction:Vp}=k(Dp,async(e,t)=>{let{cvmId:r}=Mp.parse(t);return await e.get(`/cvms/${r}/composition`)}),Kp=b.object({common_name:b.string().nullable(),organization:b.string().nullable(),country:b.string().nullable(),state:b.string().nullable(),locality:b.string().nullable()}),Wp=b.object({common_name:b.string().nullable(),organization:b.string().nullable(),country:b.string().nullable()}),Xp=b.object({subject:Kp,issuer:Wp,serial_number:b.string(),not_before:b.string(),not_after:b.string(),version:b.string(),fingerprint:b.string(),signature_algorithm:b.string(),sans:b.array(b.string()).nullable(),is_ca:b.boolean(),position_in_chain:b.number().nullable(),quote:b.string().nullable(),app_id:b.string().nullable().optional(),cert_usage:b.string().nullable().optional()}),Jp=b.object({imr:b.number(),event_type:b.number(),digest:b.string(),event:b.string(),event_payload:b.string()}),Zp=b.object({mrtd:b.string(),rootfs_hash:b.string().nullable().optional(),rtmr0:b.string(),rtmr1:b.string(),rtmr2:b.string(),rtmr3:b.string(),event_log:b.array(Jp),app_compose:b.string()}),Yp=b.object({name:b.string().nullable(),is_online:b.boolean(),is_public:b.boolean().default(!0),error:b.string().nullable(),app_certificates:b.array(Xp).nullable(),tcb_info:Zp.nullable(),compose_file:b.string().nullable()}),Qp=R,{action:eu,safeAction:tu}=k(Yp,async(e,t)=>{let{cvmId:r}=Qp.parse(t);return await e.get(`/cvms/${r}/attestation`)}),ru=Oe(He.extend({vcpu:ut.number().optional(),memory:ut.number().optional(),disk_size:ut.number().optional(),instance_type:ut.string().optional(),allow_restart:ut.boolean().optional()})),{action:ou,safeAction:nu}=k(ut.void(),async(e,t)=>{let r=ru.parse(t),{cvmId:o}=R.parse(r),{...n}=r;await e.patch(`/cvms/${o}/resources`,n)}),su=Oe(He.extend({public_sysinfo:Ss.boolean(),public_logs:Ss.boolean()})),{action:iu,safeAction:au}=k(Hs,async(e,t)=>{let r=su.parse(t),{cvmId:o}=R.parse(r),{public_sysinfo:n,public_logs:s}=r;return await e.patch(`/cvms/${o}/visibility`,{public_sysinfo:n,public_logs:s})}),Is=D.object({name:D.string(),os_image_hash:D.string().nullable(),is_current:D.boolean()}),cu=D.object({version:D.union([D.tuple([D.number(),D.number(),D.number(),D.number()]),D.tuple([D.number(),D.number(),D.number()])]),prod:Is.nullable(),dev:Is.nullable()}),lu=D.array(cu),pu=R,{action:uu,safeAction:fu}=k(lu,async(e,t)=>{let{cvmId:r}=pu.parse(t);return await e.get(`/cvms/${r}/available-os-images`)}),mu=Oe(He.extend({os_image_name:Gs.string().min(1,"OS image name is required")})),{action:du,safeAction:hu}=k(Gs.void(),async(e,t)=>{let r=mu.parse(t),{cvmId:o}=R.parse(r),{os_image_name:n}=r;await e.patch(`/cvms/${o}/os-image`,{os_image_name:n})}),xu=xe.object({id:xe.string().optional(),instance_id:xe.string().optional(),name:xe.string(),status:xe.string(),uptime:xe.string().optional(),exited_at:xe.string().optional(),boot_progress:xe.string().optional(),boot_error:xe.string().optional(),shutdown_progress:xe.string().optional()}),gu=R,{action:bu,safeAction:yu}=k(xu,async(e,t)=>{let{cvmId:r}=gu.parse(t);return await e.get(`/cvms/${r}/state`)});function Ds(e={}){let t=kc(e),r={getCurrentUser:Ec,safeGetCurrentUser:Sc,getAvailableNodes:Rc,safeGetAvailableNodes:Uc,listAllInstanceTypeFamilies:jc,safeListAllInstanceTypeFamilies:Nc,listFamilyInstanceTypes:Gc,safeListFamilyInstanceTypes:Dc,listWorkspaces:Vc,safeListWorkspaces:Kc,getWorkspace:Wc,safeGetWorkspace:Xc,getCvmInfo:tl,safeGetCvmInfo:mt,getCvmList:nl,safeGetCvmList:wr,provisionCvm:cl,safeProvisionCvm:ll,commitCvmProvision:ul,safeCommitCvmProvision:fl,getCvmComposeFile:bl,safeGetCvmComposeFile:po,provisionCvmComposeFileUpdate:wl,safeProvisionCvmComposeFileUpdate:_l,commitCvmComposeFileUpdate:Tl,safeCommitCvmComposeFileUpdate:El,updateCvmEnvs:Bl,safeUpdateCvmEnvs:Ll,updateDockerCompose:Fl,safeUpdateDockerCompose:Hl,updatePreLaunchScript:Dl,safeUpdatePreLaunchScript:Ml,getCvmPreLaunchScript:Kl,safeGetCvmPreLaunchScript:Wl,startCvm:up,safeStartCvm:fp,stopCvm:dp,safeStopCvm:hp,shutdownCvm:gp,safeShutdownCvm:bp,restartCvm:wp,safeRestartCvm:_p,deleteCvm:Tp,safeDeleteCvm:Ep,getCvmStats:Bp,safeGetCvmStats:Lp,getCvmNetwork:zp,safeGetCvmNetwork:Fp,getCvmDockerCompose:jp,safeGetCvmDockerCompose:Np,getCvmContainersStats:qp,safeGetCvmContainersStats:Vp,getCvmAttestation:eu,safeGetCvmAttestation:tu,updateCvmResources:ou,safeUpdateCvmResources:nu,updateCvmVisibility:iu,safeUpdateCvmVisibility:au,getAvailableOsImages:uu,safeGetAvailableOsImages:fu,updateOsImage:du,safeUpdateOsImage:hu,getKmsInfo:Jl,safeGetKmsInfo:Zl,getKmsList:ep,safeGetKmsList:tp,getAppEnvEncryptPubKey:np,safeGetAppEnvEncryptPubKey:sp,nextAppIds:cp,safeNextAppIds:lp,getCvmState:bu,safeGetCvmState:yu};return t.extend(r)}var vu=U.object({chain:U.unknown().optional(),rpcUrl:U.string().optional(),kmsContractAddress:U.string(),privateKey:U.string().optional(),walletClient:U.unknown().optional(),publicClient:U.unknown().optional(),allowAnyDevice:U.boolean().optional().default(!1),deviceId:U.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),composeHash:U.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),disableUpgrades:U.boolean().optional().default(!1),skipPrerequisiteChecks:U.boolean().optional().default(!1),minBalance:U.string().optional()}).passthrough(),tg=vu.refine(e=>{let t=!!e.privateKey,r=!!e.walletClient;return t!==r},{message:"Either 'privateKey' or 'walletClient' must be provided, but not both",path:["privateKey","walletClient"]}).refine(e=>{let t=!!e.publicClient,r=!!e.walletClient,o=!!e.chain;return t&&r?!0:o},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),rg=U.object({appId:U.string(),appAuthAddress:U.string(),deployer:U.string(),transactionHash:U.string(),blockNumber:U.bigint().optional(),gasUsed:U.bigint().optional()}).passthrough();var ng=B.object({chain:B.unknown().optional(),rpcUrl:B.string().optional(),appId:B.string(),composeHash:B.string(),privateKey:B.string().optional(),walletClient:B.unknown().optional(),publicClient:B.unknown().optional(),skipPrerequisiteChecks:B.boolean().optional().default(!1),minBalance:B.string().optional(),timeout:B.number().optional().default(12e4),retryOptions:B.unknown().optional(),signal:B.unknown().optional(),onTransactionStateChange:B.function().optional(),onTransactionSubmitted:B.function().optional(),onTransactionConfirmed:B.function().optional()}).passthrough().refine(e=>{let t=!!e.privateKey,r=!!e.walletClient;return t!==r},{message:"Either 'privateKey' or 'walletClient' must be provided, but not both",path:["privateKey","walletClient"]}).refine(e=>{let t=!!e.publicClient,r=!!e.walletClient,o=!!e.chain;return t&&r?!0:o},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),sg=B.object({composeHash:B.string(),appId:B.string(),transactionHash:B.string(),blockNumber:B.bigint().optional(),gasUsed:B.bigint().optional()}).passthrough();var ag=pt.object({target:pt.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),interval:pt.number().min(5).max(30).default(5).describe("Polling interval in seconds"),timeout:pt.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),maxRetries:pt.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),retryDelay:pt.number().min(0).default(5e3).describe("Delay between retries in milliseconds")});import Ks from"node:crypto";import qs from"node:fs";import dt from"node:os";import uo from"node:path";import q from"chalk";import Tu from"ora";var ku=!1;function me(){return ku}function Eu(e,t){let r=e.split(/\s+/),o=[],n="";for(let s of r){let i=n.length===0?s:`${n} ${s}`;i.length<=t?n=i:(n.length>0&&o.push(n),n=s)}return n.length>0&&o.push(n),o}function Su(e,t){if(e.length<=t)return[e];let r=[],o=0;for(;o<e.length;)r.push(e.slice(o,o+t)),o+=t;return r}function Ms(e,t){let r=[];for(let o of e.split(`
26
- `)){if(o.length<=t){r.push(o);continue}if(o.indexOf(" ")===-1){r.push(...Su(o,t));continue}let n=Eu(o,t);r.push(...n)}if(r.length===0){let o=e.trim();r.push(o)}return r}var Se={error:(e,...t)=>{me()||(process.stderr.write(`${q.red("\u2717")} ${q.red(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
25
+ `,I,T,Es(d.status,d.statusText,d.headers,d._data))}l&&l({request:p,response:d,options:h})}})}get raw(){return this.fetchInstance}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}once(e,t){let r=o=>{t(o),this.emitter.off(e,r)};this.emitter.on(e,r)}async get(e,t){try{return await this.fetchInstance(e,{...t,method:"GET"})}catch(r){let o=this.convertToRequestError(r);throw this.emitError(o)}}async post(e,t,r){try{return await this.fetchInstance(e,{...r,method:"POST",body:t})}catch(o){let n=this.convertToRequestError(o);throw this.emitError(n)}}async put(e,t,r){try{return await this.fetchInstance(e,{...r,method:"PUT",body:t})}catch(o){let n=this.convertToRequestError(o);throw this.emitError(n)}}async patch(e,t,r){try{return await this.fetchInstance(e,{...r,method:"PATCH",body:t})}catch(o){let n=this.convertToRequestError(o);throw this.emitError(n)}}async delete(e,t){try{return await this.fetchInstance(e,{...t,method:"DELETE"})}catch(r){let o=this.convertToRequestError(r);throw this.emitError(o)}}convertToRequestError(e){return e&&typeof e=="object"&&"data"in e?io.fromFetchError(e):e instanceof Error?io.fromError(e):new io("Unknown error occurred",{detail:"Unknown error occurred"})}emitError(e){let t=vc(e);return this.emitter.emit("error",t),t}async safeRequest(e){try{return{success:!0,data:await e()}}catch(t){if(t instanceof ve)return{success:!1,error:t};let r=this.convertToRequestError(t);return this.emitError(r),{success:!1,error:r}}}async safeGet(e,t){return this.safeRequest(()=>this.get(e,t))}async safePost(e,t,r){return this.safeRequest(()=>this.post(e,t,r))}async safePut(e,t,r){return this.safeRequest(()=>this.put(e,t,r))}async safePatch(e,t,r){return this.safeRequest(()=>this.patch(e,t,r))}async safeDelete(e,t){return this.safeRequest(()=>this.delete(e,t))}extend(e){let t=typeof e=="function"?e(this):e,r=Object.create(this);for(let[o,n]of Object.entries(t))typeof n=="function"&&(r[o]=(...s)=>n(this,...s));return r}};function Ec(e={}){return new Tc(e)}function Ls(e){if(e?.schema!==void 0&&e?.schema!==!1&&(typeof e.schema!="object"||e.schema===null||!("parse"in e.schema)||typeof e.schema.parse!="function"))throw new Error("Invalid schema: must be a Zod schema object, false, or undefined")}function Rs(e){if(e?.schema!==void 0&&e?.schema!==!1&&(typeof e.schema!="object"||e.schema===null||!("parse"in e.schema)||typeof e.schema.parse!="function"))return{success:!1,error:{name:"ZodError",message:"Invalid schema: must be a Zod schema object, false, or undefined",issues:[{code:"invalid_type",expected:"object",received:typeof e.schema,path:["schema"],message:"Invalid schema: must be a Zod schema object, false, or undefined"}]}}}function Us(e,t){function r(i,a){return o(i,a)}async function o(i,a){Ls(a);let l=await t(i);return a?.schema===!1?l:(a?.schema||e).parse(l)}function n(i,a){return s(i,a)}async function s(i,a){let l=Rs(a);if(l)return l;let u=await(async()=>{try{return{success:!0,data:await t(i)}}catch(p){return p&&typeof p=="object"&&"status"in p?{success:!1,error:p}:p&&typeof p=="object"&&"issues"in p?{success:!1,error:p}:{success:!1,error:{name:"Error",message:p instanceof Error?p.message:String(p)}}}})();return u.success?a?.schema===!1?{success:!0,data:u.data}:(a?.schema||e).safeParse(u.data):u}return{action:r,safeAction:n}}function k(e,t){function r(i,...a){let[l,u]=a;return o(i,l,u)}async function o(i,a,l){Ls(l);let u=await t(i,a);return l?.schema===!1?u:(l?.schema||e).parse(u)}function n(i,...a){let[l,u]=a;return s(i,l,u)}async function s(i,a,l){let u=Rs(l);if(u)return u;let f=await(async()=>{try{return{success:!0,data:await t(i,a)}}catch(d){return d&&typeof d=="object"&&"status"in d?{success:!1,error:d}:d&&typeof d=="object"&&"issues"in d?{success:!1,error:d}:{success:!1,error:{name:"Error",message:d instanceof Error?d.message:String(d)}}}})();return f.success?l?.schema===!1?{success:!0,data:f.data}:(l?.schema||e).safeParse(f.data):f}return{action:r,safeAction:n}}var Sc=ze.object({username:ze.string(),email:ze.string(),credits:ze.number(),granted_credits:ze.number(),avatar:ze.string(),team_name:ze.string(),team_tier:ze.string()}).passthrough(),{action:Ic,safeAction:Ac}=Us(Sc,async e=>await e.get("/auth/me")),Pc={[dr.id]:dr,[It.id]:It,[mr.id]:mr},Bc=He.object({id:He.string(),slug:He.string().nullable(),url:He.string(),version:He.string(),chain_id:He.number().nullable(),kms_contract_address:He.string().nullable().transform(e=>e),gateway_app_id:He.string().nullable().transform(e=>e)}).passthrough(),Ee=Bc.transform(e=>{if(e.chain_id!=null){let t=Pc[e.chain_id];if(t)return{...e,chain:t}}return e}),$c=w.object({name:w.string(),is_dev:w.boolean(),version:w.union([w.tuple([w.number(),w.number(),w.number()]),w.tuple([w.number(),w.number(),w.number(),w.number()])]),os_image_hash:w.string().nullable().optional()}).passthrough(),Lc=w.object({teepod_id:w.number(),name:w.string(),listed:w.boolean(),resource_score:w.number(),remaining_vcpu:w.number(),remaining_memory:w.number(),remaining_cvm_slots:w.number(),images:w.array($c),support_onchain_kms:w.boolean().optional(),fmspc:w.string().nullable().optional(),device_id:w.string().nullable().optional(),region_identifier:w.string().nullable().optional(),default_kms:w.string().nullable().optional(),kms_list:w.array(w.string()).default([])}).passthrough(),Rc=w.object({max_instances:w.number().nullable().optional(),max_vcpu:w.number().nullable().optional(),max_memory:w.number().nullable().optional(),max_disk:w.number().nullable().optional()}).passthrough(),Uc=w.object({tier:w.string(),capacity:Rc,nodes:w.array(Lc),kms_list:w.array(Ee)}).passthrough(),{action:zc,safeAction:Hc}=Us(Uc,async e=>await e.get("/teepods/available")),zs=L.object({id:L.string(),name:L.string(),description:L.string(),vcpu:L.number(),memory_mb:L.number(),hourly_rate:L.string(),requires_gpu:L.boolean(),default_disk_size_gb:L.number().default(20),family:L.string().nullable()}).passthrough(),Fc=L.object({name:L.string(),items:L.array(zs),total:L.number()}).strict(),Oc=L.object({result:L.array(Fc)}).strict(),jc=L.object({items:L.array(zs),total:L.number(),family:L.string()}).strict(),Nc=L.object({family:L.string()}).strict(),{action:Mc,safeAction:Dc}=k(Oc,async e=>await e.get("/instance-types")),{action:Gc,safeAction:qc}=k(jc,async(e,t)=>{let r=Nc.parse(t);return await e.get(`/instance-types/${r.family}`)}),Hs=ee.object({id:ee.string(),name:ee.string(),slug:ee.string().nullable(),tier:ee.string(),role:ee.string(),created_at:ee.string()}).passthrough(),Vc=ee.object({has_more:ee.boolean(),next_cursor:ee.string().nullable(),total:ee.number().nullable()}).passthrough(),Kc=ee.object({data:ee.array(Hs),pagination:Vc}).passthrough(),{action:Wc,safeAction:Xc}=k(Kc,async(e,t)=>{let r=new URLSearchParams;t?.cursor&&r.append("cursor",t.cursor),t?.limit&&r.append("limit",t.limit.toString());let o=r.toString()?`/workspaces?${r.toString()}`:"/workspaces";return await e.get(o)}),{action:Jc,safeAction:Zc}=k(Hs,async(e,t)=>await e.get(`/workspaces/${t}`)),Yc=m.object({id:m.string(),name:m.string(),status:m.string(),uptime:m.string(),app_url:m.string().nullable(),app_id:m.string(),instance_id:m.string().nullable(),configuration:m.any().optional(),exited_at:m.string().nullable(),boot_progress:m.string().nullable(),boot_error:m.string().nullable(),shutdown_progress:m.string().nullable(),image_version:m.string().nullable()}),Qc=m.object({id:m.number(),username:m.string()}),po=m.object({id:m.number(),name:m.string(),region_identifier:m.string().nullable().optional()}),Fs=m.object({app:m.string(),instance:m.string()}),el=m.object({hosted:Yc,name:m.string(),managed_user:Qc.nullable(),node:po.nullable(),listed:m.boolean().default(!1),status:m.string(),in_progress:m.boolean().default(!1),dapp_dashboard_url:m.string().nullable(),syslog_endpoint:m.string().nullable(),allow_upgrade:m.boolean().default(!1),project_id:m.string().nullable(),project_type:m.string().nullable(),billing_period:m.string().nullable(),kms_info:Ee.nullable(),vcpu:m.number().nullable(),memory:m.number().nullable(),disk_size:m.number().nullable(),gateway_domain:m.string().nullable(),public_urls:m.array(Fs)}),Os=m.object({id:m.number(),name:m.string(),status:m.string(),in_progress:m.boolean().optional().default(!1),teepod_id:m.number().nullable(),teepod:po.optional().nullable(),app_id:m.string(),vm_uuid:m.string().nullable(),instance_id:m.string().nullable(),vcpu:m.number(),memory:m.number(),disk_size:m.number(),base_image:m.string().nullable(),encrypted_env_pubkey:m.string().nullable(),listed:m.boolean().optional().default(!1),project_id:m.string().optional().nullable(),project_type:m.string().optional().nullable(),public_sysinfo:m.boolean().optional().default(!1),public_logs:m.boolean().optional().default(!1),dapp_dashboard_url:m.string().optional().nullable(),syslog_endpoint:m.string().optional().nullable(),kms_info:Ee.optional().nullable(),contract_address:m.string().optional().nullable(),deployer_address:m.string().optional().nullable(),scheduled_delete_at:m.string().optional().nullable(),public_urls:m.array(Fs).optional().default([]),gateway_domain:m.string().optional().nullable()}),yr=m.object({id:m.number(),name:m.string(),status:m.string(),teepod_id:m.number(),teepod:po.optional().nullable(),user_id:m.number().optional().nullable(),app_id:m.string(),vm_uuid:m.string().nullable(),instance_id:m.string().nullable(),app_url:m.string().optional().nullable(),base_image:m.string().nullable(),vcpu:m.number(),memory:m.number(),disk_size:m.number(),manifest_version:m.number().optional().nullable(),version:m.string().optional().nullable(),runner:m.string().optional().nullable(),docker_compose_file:m.string().optional().nullable(),features:m.array(m.string()).optional().nullable(),created_at:m.string(),encrypted_env_pubkey:m.string().nullable()});function js(e){return typeof e!="string"||e.length<5||e.length>63?!1:/^[a-zA-Z](?!.*--)([a-zA-Z0-9-]*[a-zA-Z0-9])?$/.test(e)}var Fe=lt.object({id:lt.string().optional(),uuid:lt.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i,"Invalid UUID format").optional(),app_id:lt.string().optional(),instance_id:lt.string().optional(),name:lt.string().refine(js,{message:"Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens"}).optional()}),Oe=e=>e.refine(t=>{let r=t;return!!(r.id||r.uuid||r.app_id||r.instance_id||r.name)},{message:"One of id, uuid, app_id, instance_id, or name must be provided"}),tl=Oe(Fe),R=tl.transform(e=>{let t;if(e.id)t=e.id;else if(e.uuid)t=e.uuid;else if(e.app_id)t=e.app_id;else if(e.instance_id)t=e.instance_id;else{if(e.name)return{cvmId:e.name};throw new Error("No valid identifier provided")}let r=/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i,o=/^[0-9a-f]{40}$/i,n;return r.test(t)?n=t.replace(/-/g,""):o.test(t)?n=`app_${t}`:n=t,{cvmId:n}}),rl=R,{action:ol,safeAction:mt}=k(Os,async(e,t)=>{let{cvmId:r}=rl.parse(t);return await e.get(`/cvms/${r}`)}),nl=ae.object({page:ae.number().int().min(1).optional(),page_size:ae.number().int().min(1).optional(),node_id:ae.number().int().min(1).optional(),teepod_id:ae.number().int().min(1).optional(),user_id:ae.string().optional()}).strict(),sl=ae.object({items:ae.array(el),total:ae.number(),page:ae.number(),page_size:ae.number(),pages:ae.number()}).strict(),{action:il,safeAction:vr}=k(sl,async(e,t)=>{let r=nl.parse(t??{});return await e.get("/cvms/paginated",{params:r})}),al=v.object({app_id:v.string().nullable().optional(),app_env_encrypt_pubkey:v.string().nullable().optional(),compose_hash:v.string(),fmspc:v.string().nullable().optional(),device_id:v.string().nullable().optional(),os_image_hash:v.string().nullable().optional(),instance_type:v.string().nullable().optional(),teepod_id:v.number().nullable().optional(),node_id:v.number().nullable().optional(),kms_id:v.string().nullable().optional()}).passthrough().transform(e=>{if("teepod_id"in e&&e.teepod_id!==void 0){let{teepod_id:t,...r}=e;return{...r,node_id:t}}return e}),co="Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens",cl=v.object({node_id:v.number().optional(),teepod_id:v.number().optional(),region:v.string().optional(),name:v.string().min(5,co).max(63,co).refine(e=>js(e),co),instance_type:v.string().default("tdx.small"),image:v.string().optional(),vcpu:v.number().optional(),memory:v.number().optional(),disk_size:v.number().optional(),compose_file:v.object({allowed_envs:v.array(v.string()).optional(),pre_launch_script:v.string().optional(),docker_compose_file:v.string().optional(),name:v.string().optional().default(""),kms_enabled:v.boolean().optional(),public_logs:v.boolean().optional(),public_sysinfo:v.boolean().optional(),gateway_enabled:v.boolean().optional(),tproxy_enabled:v.boolean().optional()}),listed:v.boolean().optional(),kms_id:v.string().optional(),kms:v.enum(["PHALA","ETHEREUM","BASE"]).optional(),kms_contract:v.string().optional(),env_keys:v.array(v.string()).optional(),nonce:v.number().optional(),app_id:v.string().optional()}).passthrough();function ll(e){if(!e.compose_file)return e;let t={...e.compose_file};return typeof t.gateway_enabled=="boolean"&&typeof t.tproxy_enabled=="boolean"?delete t.tproxy_enabled:typeof t.tproxy_enabled=="boolean"&&typeof t.gateway_enabled>"u"&&(t.gateway_enabled=t.tproxy_enabled,delete t.tproxy_enabled,(typeof window<"u"?window.console:globalThis.console)&&console.warn("[phala/cloud] tproxy_enabled is deprecated, please use gateway_enabled instead. See docs for migration.")),{...e,compose_file:t}}var{action:pl,safeAction:ul}=k(al,async(e,t)=>{let r=cl.parse(t),o=ll(r),n={...o};return typeof o.node_id=="number"?(n={...o,teepod_id:o.node_id},delete n.node_id):typeof o.teepod_id=="number"&&console.warn("[phala/cloud] teepod_id is deprecated, please use node_id instead."),await e.post("/cvms/provision",n)}),fl=C.object({id:C.number(),name:C.string(),status:C.string(),teepod_id:C.number(),teepod:C.object({id:C.number(),name:C.string()}).nullable(),user_id:C.number().nullable(),app_id:C.string().nullable(),vm_uuid:C.string().nullable(),instance_id:C.string().nullable(),app_url:C.string().nullable(),base_image:C.string().nullable(),vcpu:C.number(),memory:C.number(),disk_size:C.number(),manifest_version:C.number().nullable(),version:C.string().nullable(),runner:C.string().nullable(),docker_compose_file:C.string().nullable(),features:C.array(C.string()).nullable(),created_at:C.string(),encrypted_env_pubkey:C.string().nullable().optional(),app_auth_contract_address:C.string().nullable().optional(),deployer_address:C.string().nullable().optional()}).passthrough(),Ax=C.object({encrypted_env:C.string().optional().nullable(),app_id:C.string(),compose_hash:C.string(),kms_id:C.string().optional(),contract_address:C.string().optional(),deployer_address:C.string().optional(),env_keys:C.array(C.string()).optional().nullable()}).passthrough(),{action:ml,safeAction:dl}=k(fl,async(e,t)=>await e.post("/cvms",t)),Ns=G.object({allowed_envs:G.array(G.string()).optional(),docker_compose_file:G.string(),features:G.array(G.string()).optional(),name:G.string().optional(),manifest_version:G.number().optional(),kms_enabled:G.boolean().optional(),public_logs:G.boolean().optional(),public_sysinfo:G.boolean().optional(),tproxy_enabled:G.boolean().optional(),pre_launch_script:G.string().optional(),env_pubkey:G.string().optional(),salt:G.string().optional().nullable()}).passthrough();function lo(e){return e==null?e:Array.isArray(e)?e.map(lo):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let o=e[r];return t[r]=lo(o),t},{}):e}function Ms(e){let t={...e};return t.runner==="bash"&&"docker_compose_file"in t?delete t.docker_compose_file:t.runner==="docker-compose"&&"bash_script"in t&&delete t.bash_script,"pre_launch_script"in t&&!t.pre_launch_script&&delete t.pre_launch_script,t}function Ds(e){let t=lo(e),r=JSON.stringify(t,null,4);return r=r.replace(/": /g,'":'),r}function xl(e){let t=Ms(e),r=Ds(t);return hl.createHash("sha256").update(r,"utf8").digest("hex")}function gl(e){let t=e;return{...e,getHash:()=>xl(t),toString:()=>Ds(Ms(t))}}var bl=Ns.transform(e=>gl(e)),yl=R,{action:vl,safeAction:uo}=k(bl,async(e,t)=>{let{cvmId:r}=yl.parse(t);return await e.get(`/cvms/${r}/compose_file`)}),wl=be.object({id:be.string().optional(),uuid:be.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),app_id:be.string().refine(e=>!e.startsWith("app_")&&e.length===40,"app_id should be 40 characters without prefix").transform(e=>e.startsWith("app_")?e:`app_${e}`).optional(),instance_id:be.string().refine(e=>!e.startsWith("instance_")&&e.length===40,"instance_id should be 40 characters without prefix").transform(e=>e.startsWith("instance_")?e:`instance_${e}`).optional(),app_compose:Ns,update_env_vars:be.boolean().optional().nullable()}).refine(e=>!!(e.id||e.uuid||e.app_id||e.instance_id),"One of id, uuid, app_id, or instance_id must be provided").transform(e=>({cvmId:e.id||e.uuid||e.app_id||e.instance_id,request:{...e.app_compose,update_env_vars:e.update_env_vars},_raw:e})),_l=be.object({app_id:be.string().nullable(),device_id:be.string().nullable(),compose_hash:be.string(),kms_info:Ee.nullable().optional()}).passthrough(),{action:Cl,safeAction:kl}=k(_l,async(e,t)=>{let r=wl.parse(t);return await e.post(`/cvms/${r.cvmId}/compose_file/provision`,r.request)}),Tl=fe.object({id:fe.string().optional(),uuid:fe.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),app_id:fe.string().refine(e=>!e.startsWith("app_")&&e.length===40,"app_id should be 40 characters without prefix").transform(e=>e.startsWith("app_")?e:`app_${e}`).optional(),instance_id:fe.string().refine(e=>!e.startsWith("instance_")&&e.length===40,"instance_id should be 40 characters without prefix").transform(e=>e.startsWith("instance_")?e:`instance_${e}`).optional(),compose_hash:fe.string().min(1,"Compose hash is required"),encrypted_env:fe.string().optional(),env_keys:fe.array(fe.string()).optional(),update_env_vars:fe.boolean().optional().nullable()}).refine(e=>!!(e.id||e.uuid||e.app_id||e.instance_id),"One of id, uuid, app_id, or instance_id must be provided").transform(e=>({cvmId:e.id||e.uuid||e.app_id||e.instance_id,compose_hash:e.compose_hash,encrypted_env:e.encrypted_env,env_keys:e.env_keys,update_env_vars:!!e.update_env_vars,_raw:e})),El=fe.any().transform(()=>{}),{action:Sl,safeAction:Il}=k(El,async(e,t)=>{let r=Tl.parse(t);return await e.patch(`/cvms/${r.cvmId}/compose_file`,{compose_hash:r.compose_hash,encrypted_env:r.encrypted_env,env_keys:r.env_keys})}),Al=Oe(Fe.extend({encrypted_env:j.string().describe("Encrypted environment variables (hex string)"),env_keys:j.array(j.string()).optional().describe("List of allowed environment variable keys"),compose_hash:j.string().optional().describe("Compose hash for verification (Phase 2, required when env_keys changes)"),transaction_hash:j.string().optional().describe("On-chain transaction hash for verification (Phase 2, required when env_keys changes)")})).transform(e=>{let{cvmId:t}=R.parse(e);return{cvmId:t,request:{encrypted_env:e.encrypted_env,env_keys:e.env_keys,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),Pl=j.object({status:j.literal("in_progress"),message:j.string(),correlation_id:j.string(),allowed_envs_changed:j.boolean()}),Bl=j.object({status:j.literal("precondition_required"),message:j.string(),compose_hash:j.string(),app_id:j.string(),device_id:j.string(),kms_info:Ee}),$l=j.union([Pl,Bl]),{action:Ll,safeAction:Rl}=k($l,async(e,t)=>{let r=Al.parse(t);try{return await e.patch(`/cvms/${r.cvmId}/envs`,r.request)}catch(o){if(o instanceof ve&&o.status===465){let n=o.detail;if(n&&typeof n=="object"){let s=n;return{status:"precondition_required",message:s.message||"Compose hash verification required",compose_hash:s.compose_hash,app_id:s.app_id,device_id:s.device_id,kms_info:s.kms_info}}}throw o}}),Ul=Oe(Fe.extend({docker_compose_file:Z.string().describe("Docker Compose YAML content"),compose_hash:Z.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:Z.string().optional().describe("On-chain transaction hash for verification (Phase 2, contract-owned KMS only)")})).transform(e=>{let{cvmId:t}=R.parse(e);return{cvmId:t,request:{docker_compose_file:e.docker_compose_file,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),zl=Z.object({status:Z.literal("in_progress"),message:Z.string(),correlation_id:Z.string()}),Hl=Z.object({status:Z.literal("precondition_required"),message:Z.string(),compose_hash:Z.string(),app_id:Z.string(),device_id:Z.string(),kms_info:Ee}),Fl=Z.union([zl,Hl]),{action:Ol,safeAction:jl}=k(Fl,async(e,t)=>{let r=Ul.parse(t),o={"Content-Type":"text/yaml"};r.request.compose_hash&&(o["X-Compose-Hash"]=r.request.compose_hash),r.request.transaction_hash&&(o["X-Transaction-Hash"]=r.request.transaction_hash);try{return await e.patch(`/cvms/${r.cvmId}/docker-compose`,r.request.docker_compose_file,{headers:o})}catch(n){if(n instanceof ve&&n.status===465){let s=n.detail;if(s&&typeof s=="object"){let i=s;return{status:"precondition_required",message:i.message||"Compose hash verification required",compose_hash:i.compose_hash,app_id:i.app_id,device_id:i.device_id,kms_info:i.kms_info}}}throw n}}),Nl=Oe(Fe.extend({pre_launch_script:Y.string().describe("Pre-launch script content (shell script)"),compose_hash:Y.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:Y.string().optional().describe("On-chain transaction hash for verification (Phase 2, contract-owned KMS only)")})).transform(e=>{let{cvmId:t}=R.parse(e);return{cvmId:t,request:{pre_launch_script:e.pre_launch_script,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),Ml=Y.object({status:Y.literal("in_progress"),message:Y.string(),correlation_id:Y.string()}),Dl=Y.object({status:Y.literal("precondition_required"),message:Y.string(),compose_hash:Y.string(),app_id:Y.string(),device_id:Y.string(),kms_info:Ee}),Gl=Y.union([Ml,Dl]),{action:ql,safeAction:Vl}=k(Gl,async(e,t)=>{let r=Nl.parse(t),o={"Content-Type":"text/plain"};r.request.compose_hash&&(o["X-Compose-Hash"]=r.request.compose_hash),r.request.transaction_hash&&(o["X-Transaction-Hash"]=r.request.transaction_hash);try{return await e.patch(`/cvms/${r.cvmId}/pre-launch-script`,r.request.pre_launch_script,{headers:o})}catch(n){if(n instanceof ve&&n.status===465){let s=n.detail;if(s&&typeof s=="object"){let i=s;return{status:"precondition_required",message:i.message||"Compose hash verification required",compose_hash:i.compose_hash,app_id:i.app_id,device_id:i.device_id,kms_info:i.kms_info}}}throw n}}),Wl=R,{action:Xl,safeAction:Jl}=k(Kl.string(),async(e,t)=>{let{cvmId:r}=Wl.parse(t);return await e.get(`/cvms/${r}/pre-launch-script`)}),Zl=Ss.object({kms_id:Ss.string().min(1,"KMS ID is required")}),{action:Yl,safeAction:Ql}=k(Ee,async(e,t)=>{let r=Zl.parse(t);return await e.get(`/kms/${r.kms_id}`)}),ep=ye.object({page:ye.number().int().min(1).optional(),page_size:ye.number().int().min(1).optional(),is_onchain:ye.boolean().optional()}).strict(),tp=ye.object({items:ye.array(Ee),total:ye.number(),page:ye.number(),page_size:ye.number(),pages:ye.number()}).strict(),{action:rp,safeAction:op}=k(tp,async(e,t)=>{let r=ep.parse(t??{});return await e.get("/kms",{params:r})}),np=ft.object({kms:ft.string().min(1,"KMS ID or slug is required"),app_id:ft.string().refine(e=>e.length===40||e.startsWith("0x")&&e.length===42,"App ID must be exactly 40 characters or 42 characters with 0x prefix")}).strict(),sp=ft.object({public_key:ft.string(),signature:ft.string()}).strict(),{action:ip,safeAction:ap}=k(sp,async(e,t)=>{let r=np.parse(t);return await e.get(`/kms/${r.kms}/pubkey/${r.app_id}`)}),cp=Xe.object({counts:Xe.number().int().min(1).max(20).optional().default(1)}).strict(),lp=Xe.object({app_ids:Xe.array(Xe.object({app_id:Xe.string(),nonce:Xe.number().int().min(0)}))}).strict(),{action:pp,safeAction:up}=k(lp,async(e,t)=>{let r=cp.parse(t??{}),o=new URLSearchParams;return o.append("counts",r.counts.toString()),await e.get(`/kms/phala/next_app_id?${o.toString()}`)}),fp=R,{action:mp,safeAction:dp}=k(yr,async(e,t)=>{let{cvmId:r}=fp.parse(t);return await e.post(`/cvms/${r}/start`)}),hp=R,{action:xp,safeAction:gp}=k(yr,async(e,t)=>{let{cvmId:r}=hp.parse(t);return await e.post(`/cvms/${r}/stop`)}),bp=R,{action:yp,safeAction:vp}=k(yr,async(e,t)=>{let{cvmId:r}=bp.parse(t);return await e.post(`/cvms/${r}/shutdown`)}),_p=Oe(Fe.extend({force:wp.boolean().optional()})),{action:Cp,safeAction:kp}=k(yr,async(e,t)=>{let r=_p.parse(t),{cvmId:o}=R.parse(r),{force:n=!1}=r;return await e.post(`/cvms/${o}/restart`,{force:n})}),Ep=R,{action:Sp,safeAction:Ip}=k(Tp.void(),async(e,t)=>{let{cvmId:r}=Ep.parse(t);await e.delete(`/cvms/${r}`)}),Ap=S.object({name:S.string(),mount_point:S.string(),total_size:S.number(),free_size:S.number()}),Pp=S.object({os_name:S.string(),os_version:S.string(),kernel_version:S.string(),cpu_model:S.string(),num_cpus:S.number(),total_memory:S.number(),available_memory:S.number(),used_memory:S.number(),free_memory:S.number(),total_swap:S.number(),used_swap:S.number(),free_swap:S.number(),uptime:S.number(),loadavg_one:S.number(),loadavg_five:S.number(),loadavg_fifteen:S.number(),disks:S.array(Ap)}),Bp=S.object({is_online:S.boolean(),is_public:S.boolean().default(!1),error:S.string().nullable(),sysinfo:Pp.nullable(),status:S.string().nullable(),in_progress:S.boolean().default(!1),boot_progress:S.string().nullable(),boot_error:S.string().nullable()}),$p=R,{action:Lp,safeAction:Rp}=k(Bp,async(e,t)=>{let{cvmId:r}=$p.parse(t);return await e.get(`/cvms/${r}/stats`)}),Up=ge.object({app:ge.string(),instance:ge.string()}),zp=ge.object({is_online:ge.boolean(),is_public:ge.boolean().default(!0),error:ge.string().nullable(),internal_ip:ge.string().nullable(),latest_handshake:ge.string().nullable(),public_urls:ge.array(Up).nullable()}),Hp=R,{action:Fp,safeAction:Op}=k(zp,async(e,t)=>{let{cvmId:r}=Hp.parse(t);return await e.get(`/cvms/${r}/network`)}),Np=R,{action:Mp,safeAction:Dp}=k(jp.string(),async(e,t)=>{let{cvmId:r}=Np.parse(t);return await e.get(`/cvms/${r}/docker-compose.yml`)}),Gp=$.object({id:$.string(),names:$.array($.string()),image:$.string(),image_id:$.string(),command:$.string().nullable().optional(),created:$.number(),state:$.string(),status:$.string(),log_endpoint:$.string().nullable()}),qp=$.object({is_online:$.boolean(),is_public:$.boolean().default(!0),error:$.string().nullable(),docker_compose_file:$.string().nullable(),manifest_version:$.number().nullable(),version:$.string().nullable(),runner:$.string().nullable(),features:$.array($.string()).nullable(),containers:$.array(Gp).nullable()}),Vp=R,{action:Kp,safeAction:Wp}=k(qp,async(e,t)=>{let{cvmId:r}=Vp.parse(t);return await e.get(`/cvms/${r}/composition`)}),Xp=g.object({common_name:g.string().nullable(),organization:g.string().nullable(),country:g.string().nullable(),state:g.string().nullable(),locality:g.string().nullable()}),Jp=g.object({common_name:g.string().nullable(),organization:g.string().nullable(),country:g.string().nullable()}),Zp=g.object({subject:Xp,issuer:Jp,serial_number:g.string(),not_before:g.string(),not_after:g.string(),version:g.string(),fingerprint:g.string(),signature_algorithm:g.string(),sans:g.array(g.string()).nullable(),is_ca:g.boolean(),position_in_chain:g.number().nullable(),quote:g.string().nullable(),app_id:g.string().nullable().optional(),cert_usage:g.string().nullable().optional()}),Yp=g.object({imr:g.number(),event_type:g.number(),digest:g.string(),event:g.string(),event_payload:g.string()}),Qp=g.object({mrtd:g.string(),rootfs_hash:g.string().nullable().optional(),rtmr0:g.string(),rtmr1:g.string(),rtmr2:g.string(),rtmr3:g.string(),event_log:g.array(Yp),app_compose:g.string()}),eu=g.object({name:g.string().nullable(),is_online:g.boolean(),is_public:g.boolean().default(!0),error:g.string().nullable(),app_certificates:g.array(Zp).nullable(),tcb_info:Qp.nullable(),compose_file:g.string().nullable()}),tu=R,{action:ru,safeAction:ou}=k(eu,async(e,t)=>{let{cvmId:r}=tu.parse(t);return await e.get(`/cvms/${r}/attestation`)}),nu=Oe(Fe.extend({vcpu:ut.number().optional(),memory:ut.number().optional(),disk_size:ut.number().optional(),instance_type:ut.string().optional(),allow_restart:ut.boolean().optional()})),{action:su,safeAction:iu}=k(ut.void(),async(e,t)=>{let r=nu.parse(t),{cvmId:o}=R.parse(r),{...n}=r;await e.patch(`/cvms/${o}/resources`,n)}),au=Oe(Fe.extend({public_sysinfo:Is.boolean(),public_logs:Is.boolean()})),{action:cu,safeAction:lu}=k(Os,async(e,t)=>{let r=au.parse(t),{cvmId:o}=R.parse(r),{public_sysinfo:n,public_logs:s}=r;return await e.patch(`/cvms/${o}/visibility`,{public_sysinfo:n,public_logs:s})}),As=D.object({name:D.string(),os_image_hash:D.string().nullable(),is_current:D.boolean()}),pu=D.object({version:D.union([D.tuple([D.number(),D.number(),D.number(),D.number()]),D.tuple([D.number(),D.number(),D.number()])]),prod:As.nullable(),dev:As.nullable()}),uu=D.array(pu),fu=R,{action:mu,safeAction:du}=k(uu,async(e,t)=>{let{cvmId:r}=fu.parse(t);return await e.get(`/cvms/${r}/available-os-images`)}),hu=Oe(Fe.extend({os_image_name:Gs.string().min(1,"OS image name is required")})),{action:xu,safeAction:gu}=k(Gs.void(),async(e,t)=>{let r=hu.parse(t),{cvmId:o}=R.parse(r),{os_image_name:n}=r;await e.patch(`/cvms/${o}/os-image`,{os_image_name:n})}),bu=xe.object({id:xe.string().optional(),instance_id:xe.string().optional(),name:xe.string(),status:xe.string(),uptime:xe.string().optional(),exited_at:xe.string().optional(),boot_progress:xe.string().optional(),boot_error:xe.string().optional(),shutdown_progress:xe.string().optional()}),yu=R,{action:vu,safeAction:wu}=k(bu,async(e,t)=>{let{cvmId:r}=yu.parse(t);return await e.get(`/cvms/${r}/state`)});function qs(e={}){let t=Ec(e),r={getCurrentUser:Ic,safeGetCurrentUser:Ac,getAvailableNodes:zc,safeGetAvailableNodes:Hc,listAllInstanceTypeFamilies:Mc,safeListAllInstanceTypeFamilies:Dc,listFamilyInstanceTypes:Gc,safeListFamilyInstanceTypes:qc,listWorkspaces:Wc,safeListWorkspaces:Xc,getWorkspace:Jc,safeGetWorkspace:Zc,getCvmInfo:ol,safeGetCvmInfo:mt,getCvmList:il,safeGetCvmList:vr,provisionCvm:pl,safeProvisionCvm:ul,commitCvmProvision:ml,safeCommitCvmProvision:dl,getCvmComposeFile:vl,safeGetCvmComposeFile:uo,provisionCvmComposeFileUpdate:Cl,safeProvisionCvmComposeFileUpdate:kl,commitCvmComposeFileUpdate:Sl,safeCommitCvmComposeFileUpdate:Il,updateCvmEnvs:Ll,safeUpdateCvmEnvs:Rl,updateDockerCompose:Ol,safeUpdateDockerCompose:jl,updatePreLaunchScript:ql,safeUpdatePreLaunchScript:Vl,getCvmPreLaunchScript:Xl,safeGetCvmPreLaunchScript:Jl,startCvm:mp,safeStartCvm:dp,stopCvm:xp,safeStopCvm:gp,shutdownCvm:yp,safeShutdownCvm:vp,restartCvm:Cp,safeRestartCvm:kp,deleteCvm:Sp,safeDeleteCvm:Ip,getCvmStats:Lp,safeGetCvmStats:Rp,getCvmNetwork:Fp,safeGetCvmNetwork:Op,getCvmDockerCompose:Mp,safeGetCvmDockerCompose:Dp,getCvmContainersStats:Kp,safeGetCvmContainersStats:Wp,getCvmAttestation:ru,safeGetCvmAttestation:ou,updateCvmResources:su,safeUpdateCvmResources:iu,updateCvmVisibility:cu,safeUpdateCvmVisibility:lu,getAvailableOsImages:mu,safeGetAvailableOsImages:du,updateOsImage:xu,safeUpdateOsImage:gu,getKmsInfo:Yl,safeGetKmsInfo:Ql,getKmsList:rp,safeGetKmsList:op,getAppEnvEncryptPubKey:ip,safeGetAppEnvEncryptPubKey:ap,nextAppIds:pp,safeNextAppIds:up,getCvmState:vu,safeGetCvmState:wu};return t.extend(r)}var _u=U.object({chain:U.unknown().optional(),rpcUrl:U.string().optional(),kmsContractAddress:U.string(),privateKey:U.string().optional(),walletClient:U.unknown().optional(),publicClient:U.unknown().optional(),allowAnyDevice:U.boolean().optional().default(!1),deviceId:U.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),composeHash:U.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),disableUpgrades:U.boolean().optional().default(!1),skipPrerequisiteChecks:U.boolean().optional().default(!1),minBalance:U.string().optional()}).passthrough(),og=_u.refine(e=>{let t=!!e.privateKey,r=!!e.walletClient;return t!==r},{message:"Either 'privateKey' or 'walletClient' must be provided, but not both",path:["privateKey","walletClient"]}).refine(e=>{let t=!!e.publicClient,r=!!e.walletClient,o=!!e.chain;return t&&r?!0:o},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),ng=U.object({appId:U.string(),appAuthAddress:U.string(),deployer:U.string(),transactionHash:U.string(),blockNumber:U.bigint().optional(),gasUsed:U.bigint().optional()}).passthrough();var ig=B.object({chain:B.unknown().optional(),rpcUrl:B.string().optional(),appId:B.string(),composeHash:B.string(),privateKey:B.string().optional(),walletClient:B.unknown().optional(),publicClient:B.unknown().optional(),skipPrerequisiteChecks:B.boolean().optional().default(!1),minBalance:B.string().optional(),timeout:B.number().optional().default(12e4),retryOptions:B.unknown().optional(),signal:B.unknown().optional(),onTransactionStateChange:B.function().optional(),onTransactionSubmitted:B.function().optional(),onTransactionConfirmed:B.function().optional()}).passthrough().refine(e=>{let t=!!e.privateKey,r=!!e.walletClient;return t!==r},{message:"Either 'privateKey' or 'walletClient' must be provided, but not both",path:["privateKey","walletClient"]}).refine(e=>{let t=!!e.publicClient,r=!!e.walletClient,o=!!e.chain;return t&&r?!0:o},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),ag=B.object({composeHash:B.string(),appId:B.string(),transactionHash:B.string(),blockNumber:B.bigint().optional(),gasUsed:B.bigint().optional()}).passthrough();var lg=pt.object({target:pt.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),interval:pt.number().min(5).max(30).default(5).describe("Polling interval in seconds"),timeout:pt.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),maxRetries:pt.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),retryDelay:pt.number().min(0).default(5e3).describe("Delay between retries in milliseconds")});import Xs from"crypto";import Ks from"fs";import dt from"os";import fo from"path";import q from"chalk";import Su from"ora";var Eu=!1;function me(){return Eu}function Iu(e,t){let r=e.split(/\s+/),o=[],n="";for(let s of r){let i=n.length===0?s:`${n} ${s}`;i.length<=t?n=i:(n.length>0&&o.push(n),n=s)}return n.length>0&&o.push(n),o}function Au(e,t){if(e.length<=t)return[e];let r=[],o=0;for(;o<e.length;)r.push(e.slice(o,o+t)),o+=t;return r}function Vs(e,t){let r=[];for(let o of e.split(`
26
+ `)){if(o.length<=t){r.push(o);continue}if(o.indexOf(" ")===-1){r.push(...Au(o,t));continue}let n=Iu(o,t);r.push(...n)}if(r.length===0){let o=e.trim();r.push(o)}return r}var Se={error:(e,...t)=>{me()||(process.stderr.write(`${q.red("\u2717")} ${q.red(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
27
27
  `))},warn:(e,...t)=>{me()||(process.stderr.write(`${q.yellow("\u26A0")} ${q.yellow(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
28
28
  `))},info:(e,...t)=>{me()||(process.stderr.write(`${q.blue("\u2139")} ${q.blue(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
29
29
  `))},success:(e,...t)=>{me()||(process.stderr.write(`${q.green("\u2713")} ${q.green(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
30
30
  `))},debug:(e,...t)=>{me()||process.env.DEBUG&&(process.stderr.write(`${q.gray("\u{1F50D}")} ${q.gray(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
31
- `))},table:(e,t)=>{if(!me()){if(e.length===0){console.log(q.yellow("No data to display"));return}if(t){let r;typeof t[0]=="string"?r=t.map(i=>({key:i,header:i})):r=t;let o={};for(let i of r){let a=i.header||String(i.key);o[String(i.key)]=a.length}for(let i of e)for(let a of r){let l=String(typeof a.key=="string"&&!(a.key in i)?"":i[String(a.key)]??"");o[String(a.key)]=Math.max(o[String(a.key)],l.length)}let n=[];for(let i of r){let a=i.header||String(i.key);n.push(q.bold(a.padEnd(o[String(i.key)])))}console.log(n.join(" "));let s=[];for(let i of r)s.push("-".repeat(o[String(i.key)]));console.log(s.join(" "));for(let i of e){let a=[];for(let l of r){let u=String(typeof l.key=="string"&&!(l.key in i)?"":i[String(l.key)]??"");a.push(u.padEnd(o[String(l.key)]))}console.log(a.join(" "))}}else{let r=e[0],o=Object.keys(r),n={};for(let a of o)n[a]=a.length;for(let a of e)for(let l of o){let u=String(a[l]??"");n[l]=Math.max(n[l],u.length)}let s=[];for(let a of o)s.push(q.bold(a.padEnd(n[a])));console.log(s.join(" "));let i=[];for(let a of o)i.push("-".repeat(n[a]));console.log(i.join(" "));for(let a of e){let l=[];for(let u of o){let f=String(a[u]??"");l.push(f.padEnd(n[u]))}console.log(l.join(" "))}}}},keyValueTable:(e,t)=>{if(me())return;let{borderStyle:r="single",keyColor:o=q.blue,valueColor:n=q.white,maxWidth:s=process.stdout.columns||80}=t||{},a={single:{topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502",cross:"\u253C",leftT:"\u251C",rightT:"\u2524"},double:{topLeft:"\u2554",topRight:"\u2557",bottomLeft:"\u255A",bottomRight:"\u255D",horizontal:"\u2550",vertical:"\u2551",cross:"\u256C",leftT:"\u2560",rightT:"\u2563"},rounded:{topLeft:"\u256D",topRight:"\u256E",bottomLeft:"\u2570",bottomRight:"\u256F",horizontal:"\u2500",vertical:"\u2502",cross:"\u253C",leftT:"\u251C",rightT:"\u2524"},bold:{topLeft:"\u250F",topRight:"\u2513",bottomLeft:"\u2517",bottomRight:"\u251B",horizontal:"\u2501",vertical:"\u2503",cross:"\u254B",leftT:"\u2523",rightT:"\u252B"},none:{topLeft:"",topRight:"",bottomLeft:"",bottomRight:"",horizontal:"",vertical:"",cross:"",leftT:"",rightT:""}}[r],l=0,u=0;for(let[I,T]of Object.entries(e)){l=Math.max(l,I.length);let P=String(T??"");u=Math.max(u,P.length)}let f=4,p=1,d=s-f-p;if(l+u>d){let I=l/(l+u);l=Math.floor(d*I),u=d-l}let h=l+u+f+p;r!=="none"&&console.log(a.topLeft+a.horizontal.repeat(h-2)+a.topRight);for(let[I,T]of Object.entries(e)){let P=I,V=String(T??""),K=Ms(P,l),O=Ms(V,u),Q=Math.max(K.length,O.length);for(;K.length<Q;)K.push("");for(;O.length<Q;)O.push("");for(let ce=0;ce<Q;ce++){let te=K[ce].padEnd(l),Ut=O[ce].padEnd(u);console.log(r!=="none"?`${a.vertical} ${o(te)} ${a.vertical} ${n(Ut)} ${a.vertical}`:`${o(te)} : ${n(Ut)}`)}}r!=="none"&&console.log(a.bottomLeft+a.horizontal.repeat(h-2)+a.bottomRight)},break:()=>{me()||process.stderr.write(`
32
- `)},startSpinner:e=>{if(me())return{stop:()=>{}};let t=Tu(e).start();return{stop:(r=!0,o)=>{o&&(t.text=o),r?t.succeed():t.fail()}}},logDetailedError(e,t){if(me())return;let r=t?`[${t}] `:"",o=s=>s!==null&&typeof s=="object"&&"isRequestError"in s&&s.isRequestError===!0&&"status"in s&&"message"in s&&"data"in s,n=s=>s!==null&&typeof s=="object"&&"issues"in s&&Array.isArray(s.issues);if(o(e)){process.stderr.write(`${r}HTTP ${e.status}: ${e.message}
31
+ `))},table:(e,t)=>{if(!me()){if(e.length===0){console.log(q.yellow("No data to display"));return}if(t){let r;typeof t[0]=="string"?r=t.map(i=>({key:i,header:i})):r=t;let o={};for(let i of r){let a=i.header||String(i.key);o[String(i.key)]=a.length}for(let i of e)for(let a of r){let l=String(typeof a.key=="string"&&!(a.key in i)?"":i[String(a.key)]??"");o[String(a.key)]=Math.max(o[String(a.key)],l.length)}let n=[];for(let i of r){let a=i.header||String(i.key);n.push(q.bold(a.padEnd(o[String(i.key)])))}console.log(n.join(" "));let s=[];for(let i of r)s.push("-".repeat(o[String(i.key)]));console.log(s.join(" "));for(let i of e){let a=[];for(let l of r){let u=String(typeof l.key=="string"&&!(l.key in i)?"":i[String(l.key)]??"");a.push(u.padEnd(o[String(l.key)]))}console.log(a.join(" "))}}else{let r=e[0],o=Object.keys(r),n={};for(let a of o)n[a]=a.length;for(let a of e)for(let l of o){let u=String(a[l]??"");n[l]=Math.max(n[l],u.length)}let s=[];for(let a of o)s.push(q.bold(a.padEnd(n[a])));console.log(s.join(" "));let i=[];for(let a of o)i.push("-".repeat(n[a]));console.log(i.join(" "));for(let a of e){let l=[];for(let u of o){let f=String(a[u]??"");l.push(f.padEnd(n[u]))}console.log(l.join(" "))}}}},keyValueTable:(e,t)=>{if(me())return;let{borderStyle:r="single",keyColor:o=q.blue,valueColor:n=q.white,maxWidth:s=process.stdout.columns||80}=t||{},a={single:{topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502",cross:"\u253C",leftT:"\u251C",rightT:"\u2524"},double:{topLeft:"\u2554",topRight:"\u2557",bottomLeft:"\u255A",bottomRight:"\u255D",horizontal:"\u2550",vertical:"\u2551",cross:"\u256C",leftT:"\u2560",rightT:"\u2563"},rounded:{topLeft:"\u256D",topRight:"\u256E",bottomLeft:"\u2570",bottomRight:"\u256F",horizontal:"\u2500",vertical:"\u2502",cross:"\u253C",leftT:"\u251C",rightT:"\u2524"},bold:{topLeft:"\u250F",topRight:"\u2513",bottomLeft:"\u2517",bottomRight:"\u251B",horizontal:"\u2501",vertical:"\u2503",cross:"\u254B",leftT:"\u2523",rightT:"\u252B"},none:{topLeft:"",topRight:"",bottomLeft:"",bottomRight:"",horizontal:"",vertical:"",cross:"",leftT:"",rightT:""}}[r],l=0,u=0;for(let[I,T]of Object.entries(e)){l=Math.max(l,I.length);let P=String(T??"");u=Math.max(u,P.length)}let f=4,p=1,d=s-f-p;if(l+u>d){let I=l/(l+u);l=Math.floor(d*I),u=d-l}let h=l+u+f+p;r!=="none"&&console.log(a.topLeft+a.horizontal.repeat(h-2)+a.topRight);for(let[I,T]of Object.entries(e)){let P=I,V=String(T??""),K=Vs(P,l),O=Vs(V,u),Q=Math.max(K.length,O.length);for(;K.length<Q;)K.push("");for(;O.length<Q;)O.push("");for(let ce=0;ce<Q;ce++){let te=K[ce].padEnd(l),Rt=O[ce].padEnd(u);console.log(r!=="none"?`${a.vertical} ${o(te)} ${a.vertical} ${n(Rt)} ${a.vertical}`:`${o(te)} : ${n(Rt)}`)}}r!=="none"&&console.log(a.bottomLeft+a.horizontal.repeat(h-2)+a.bottomRight)},break:()=>{me()||process.stderr.write(`
32
+ `)},startSpinner:e=>{if(me())return{stop:()=>{}};let t=Su(e).start();return{stop:(r=!0,o)=>{o&&(t.text=o),r?t.succeed():t.fail()}}},logDetailedError(e,t){if(me())return;let r=t?`[${t}] `:"",o=s=>s!==null&&typeof s=="object"&&"isRequestError"in s&&s.isRequestError===!0&&"status"in s&&"message"in s&&"data"in s,n=s=>s!==null&&typeof s=="object"&&"issues"in s&&Array.isArray(s.issues);if(o(e)){process.stderr.write(`${r}HTTP ${e.status}: ${e.message}
33
33
  `),e.data!==void 0&&e.data!==null&&process.stderr.write(`${JSON.stringify(e.data,null,2)}
34
34
  `);return}if(n(e)){process.stderr.write(`${r}Validation error: ${JSON.stringify(e.issues)}
35
35
  `);return}e instanceof Error?process.stderr.write(`${r}${e.message}
36
36
  `):process.stderr.write(`${r}${String(e)}
37
- `)}};var Ws=uo.join(dt.homedir(),".phala-cloud"),Vs=uo.join(Ws,"api-key"),Ag=uo.join(Ws,"docker-credentials.json");function Iu(){let e=[dt.hostname(),dt.platform(),dt.arch(),dt.cpus()[0]?.model||"",dt.userInfo().username],t=Ks.createHash("sha256");return t.update(e.join("|")),t.digest()}function Au(e){try{let t=Iu(),r=e.split(":");if(r.length!==2)throw new Error("Invalid encrypted format");let o=Buffer.from(r[0],"hex"),n=r[1],s=Ks.createDecipheriv("aes-256-cbc",t.slice(0,32),o),i=s.update(n,"hex","utf8");return i+=s.final("utf8"),i}catch(t){throw Se.error("Decryption failed:",t),new Error("Failed to decrypt data")}}function Xs(){try{if(process.env.PHALA_CLOUD_API_KEY)return process.env.PHALA_CLOUD_API_KEY;if(qs.existsSync(Vs)){let e=qs.readFileSync(Vs,"utf8").trim();return Au(e)}return null}catch(e){return Se.error("Failed to read API key:",e),null}}async function N(){let e=Xs();return Ds({apiKey:e})}import{z as c}from"zod";var Pu=c.object({password:c.string(),registry:c.string().nullable(),username:c.string()}),Ug=c.object({docker_compose_file:c.string(),docker_config:Pu.optional().nullable(),features:c.array(c.string()),kms_enabled:c.boolean(),manifest_version:c.number(),name:c.string(),public_logs:c.boolean(),public_sysinfo:c.boolean(),runner:c.string().optional(),salt:c.string().nullable().optional(),tproxy_enabled:c.boolean(),version:c.string().optional()}).passthrough(),Js=c.object({id:c.number(),name:c.string(),status:c.string(),teepod_id:c.number().nullable(),teepod:c.object({id:c.number(),name:c.string()}).nullable(),user_id:c.number().nullable(),app_id:c.string(),vm_uuid:c.string().nullable(),instance_id:c.string().nullable(),app_url:c.string().nullable(),base_image:c.string().nullable(),vcpu:c.number(),memory:c.number(),disk_size:c.number(),manifest_version:c.number().nullable(),version:c.string().nullable(),runner:c.string().nullable(),docker_compose_file:c.string().nullable(),features:c.array(c.string()).nullable(),created_at:c.string(),encrypted_env_pubkey:c.string().nullable()}),zg=c.object({key:c.string(),value:c.string()}),Zs=c.object({is_online:c.boolean(),is_public:c.boolean(),error:c.string().nullable(),internal_ip:c.string(),latest_handshake:c.string(),public_urls:c.array(c.object({app:c.string(),instance:c.string()}))}),Ys=c.object({id:c.number(),name:c.string(),status:c.string(),teepod_id:c.number(),teepod:c.object({id:c.number(),name:c.string()}),user_id:c.number().nullable(),app_id:c.string(),vm_uuid:c.string().nullable(),instance_id:c.string().nullable(),app_url:c.string().nullable(),base_image:c.string().nullable(),vcpu:c.number(),memory:c.number(),disk_size:c.number(),manifest_version:c.number().nullable(),version:c.string().nullable(),runner:c.string().nullable(),docker_compose_file:c.string().nullable(),features:c.array(c.string()).nullable(),created_at:c.string(),encrypted_env_pubkey:c.string().nullable()}),Qs=c.object({is_online:c.boolean(),is_public:c.boolean(),error:c.string().nullable(),app_certificates:c.array(c.object({subject:c.object({common_name:c.string().nullable(),organization:c.string().nullable(),country:c.string().nullable(),state:c.string().nullable().optional(),locality:c.string().nullable().optional()}),issuer:c.object({common_name:c.string().nullable(),organization:c.string().nullable(),country:c.string().nullable()}),serial_number:c.string(),not_before:c.string(),not_after:c.string(),version:c.string(),fingerprint:c.string(),signature_algorithm:c.string(),sans:c.string().nullable(),is_ca:c.boolean(),position_in_chain:c.number(),quote:c.string().nullable()})).nullable(),tcb_info:c.object({mrtd:c.string(),rootfs_hash:c.string(),rtmr0:c.string(),rtmr1:c.string(),rtmr2:c.string(),rtmr3:c.string(),event_log:c.array(c.object({imr:c.number(),event_type:c.number(),digest:c.string(),event:c.string(),event_payload:c.string()}))}).nullable(),compose_file:c.string().nullable()}),Bu=c.object({name:c.string(),description:c.string().optional(),version:c.array(c.number()).optional(),is_dev:c.boolean().optional(),os_image_hash:c.string().nullable().optional(),rootfs_hash:c.string().optional(),shared_ro:c.boolean().optional(),cmdline:c.string().optional(),kernel:c.string().optional(),initrd:c.string().optional(),hda:c.string().nullable().optional(),rootfs:c.string().optional(),bios:c.string().optional()}),Fg=c.object({teepod_id:c.number().nullable(),id:c.number().optional(),name:c.string(),listed:c.boolean().optional(),resource_score:c.number().optional(),remaining_vcpu:c.number().optional(),remaining_memory:c.number().optional(),remaining_cvm_slots:c.number().optional(),images:c.array(Bu).optional(),region_identifier:c.string().optional(),dedicated_for_team_id:c.number().nullable().optional(),support_onchain_kms:c.boolean().optional(),fmspc:c.string().nullable().optional(),device_id:c.string().nullable().optional()});import Lu from"inquirer";async function Mg(e){let t=await N(),r=await wr(t);if(!r.success)throw new Error(`Failed to fetch CVMs: ${r.error.message}`);let o=e.replace(/^app_/,""),i=r.data.items.find(l=>l.hosted?.app_id===o);if(!i)throw new Error(`CVM with App ID app_${o} not found`);return Se.success(`CVM with App ID app_${o} detected`),i.hosted?.app_id||""}async function qg(e){let t=await N(),r=e.replace(/^app_/,""),o=await mt(t,{app_id:r});if(!o.success)throw new Error(o.error.message);return o.data}async function Vg(e){let t=await N(),r=await po(t,{id:e});if(!r.success)throw new Error(r.error.message);return r.data}async function Kg(e){let t=await N(),r=e.replace(/^app_/,""),o=await t.get(`cvms/app_${r}/network`);return Zs.parse(o)}async function Wg(e){let t=await N(),r=e.replace(/^app_/,""),o=await t.post(`cvms/app_${r}/start`);return(await mt(t,{app_id:r})).data}async function Xg(e){let t=await N(),r=e.replace(/^app_/,"");return await t.post(`cvms/app_${r}/stop`),(await mt(t,{app_id:r})).data}async function Jg(e){let t=await N(),r=e.replace(/^app_/,"");return await t.post(`cvms/app_${r}/restart`),(await mt(t,{app_id:r})).data}async function Zg(e){let t=await N(),r=e.replace(/^app_/,"");return await t.delete(`cvms/app_${r}`),!0}async function Yg(){let e=Se.startSpinner("Fetching available CVMs"),t=await N(),r=await wr(t);if(e.stop(!0),!r.success){Se.error(`Failed to fetch CVMs: ${r.error.message}`);return}let n=r.data.items;if(!n||n.length===0){Se.info("No CVMs found for your account");return}let s=n.map(a=>{let l=a,u=l.hosted?.app_id||l.hosted?.id,f=l.name||l.hosted?.name,p=l.status||l.hosted?.status;return{name:`${f||"Unnamed"} (${u}) - Status: ${p||"Unknown"}`,value:u}}),{selectedCvm:i}=await Lu.prompt([{type:"list",name:"selectedCvm",message:"Select a CVM:",choices:s}]);return i}async function Qg(e){let t=await N(),r=e.replace(/^app_/,""),o=await t.get(`cvms/app_${r}/attestation`);try{return Qs.parse(o)}catch(n){return Se.debug(`Validation error: ${n instanceof Error?n.message:String(n)}`),{is_online:!!o?.is_online,is_public:!!o?.is_public,error:typeof o?.error=="string"?o.error:null,app_certificates:Array.isArray(o?.app_certificates)?o.app_certificates:null,tcb_info:o?.tcb_info||null,compose_file:typeof o?.compose_file=="string"?o.compose_file:null}}}async function eb(e,t){let r=await N(),o=e.replace(/^app_/,""),n=await r.post(`cvms/app_${o}/replicas`,t);return Ys.parse(n)}async function tb(e,t,r,o,n){let s=await N(),i=e.replace(/^app_/,""),a={};if(t!==void 0&&(a.vcpu=t),r!==void 0&&(a.memory=r),o!==void 0&&(a.disk_size=o),n!==void 0&&(a.allow_restart=n),Object.keys(a).length===0)throw new Error("At least one resource parameter must be provided");return await s.patch(`cvms/app_${i}/resources`,a),!0}async function rb(e){return await(await N()).post("cvms/pubkey/from_cvm_configuration",e)}async function ob(e){let r=await(await N()).post("cvms/from_cvm_configuration",e);return Js.parse(r)}async function nb(e,t){let r=await N(),o=e.replace(/^app_/,"");return await r.put(`cvms/app_${o}/compose`,t)}async function sb(e=!1){let t=await N(),r="teepods/available";return e&&(r+="?v03x_only=1"),await t.get(r)}export{Mg as checkCvmExists,Ug as composeFileSchema,ob as createCvm,Qs as cvmAttestationResponseSchema,Zg as deleteCvm,Pu as dockerConfigSchema,zg as encryptedEnvItemSchema,Qg as getCvmAttestation,qg as getCvmByAppId,Vg as getCvmComposeConfig,Kg as getCvmNetwork,Zs as getCvmNetworkResponseSchema,rb as getPubkeyFromCvm,sb as getTeepods,Bu as imageSchema,Js as postCvmResponseSchema,eb as replicateCvm,Ys as replicateCvmResponseSchema,tb as resizeCvm,Jg as restartCvm,Yg as selectCvm,Wg as startCvm,Xg as stopCvm,Fg as teepodSchema,nb as upgradeCvm};
37
+ `)}};var Js=fo.join(dt.homedir(),".phala-cloud"),Ws=fo.join(Js,"api-key"),Bg=fo.join(Js,"docker-credentials.json");function Pu(){let e=[dt.hostname(),dt.platform(),dt.arch(),dt.cpus()[0]?.model||"",dt.userInfo().username],t=Xs.createHash("sha256");return t.update(e.join("|")),t.digest()}function Bu(e){try{let t=Pu(),r=e.split(":");if(r.length!==2)throw new Error("Invalid encrypted format");let o=Buffer.from(r[0],"hex"),n=r[1],s=Xs.createDecipheriv("aes-256-cbc",t.slice(0,32),o),i=s.update(n,"hex","utf8");return i+=s.final("utf8"),i}catch(t){throw Se.error("Decryption failed:",t),new Error("Failed to decrypt data")}}function Zs(){try{if(process.env.PHALA_CLOUD_API_KEY)return process.env.PHALA_CLOUD_API_KEY;if(Ks.existsSync(Ws)){let e=Ks.readFileSync(Ws,"utf8").trim();return Bu(e)}return null}catch(e){return Se.error("Failed to read API key:",e),null}}async function N(){let e=Zs();return qs({apiKey:e})}import{z as c}from"zod";var $u=c.object({password:c.string(),registry:c.string().nullable(),username:c.string()}),Hg=c.object({docker_compose_file:c.string(),docker_config:$u.optional().nullable(),features:c.array(c.string()),kms_enabled:c.boolean(),manifest_version:c.number(),name:c.string(),public_logs:c.boolean(),public_sysinfo:c.boolean(),runner:c.string().optional(),salt:c.string().nullable().optional(),tproxy_enabled:c.boolean(),version:c.string().optional()}).passthrough(),Ys=c.object({id:c.number(),name:c.string(),status:c.string(),teepod_id:c.number().nullable(),teepod:c.object({id:c.number(),name:c.string()}).nullable(),user_id:c.number().nullable(),app_id:c.string(),vm_uuid:c.string().nullable(),instance_id:c.string().nullable(),app_url:c.string().nullable(),base_image:c.string().nullable(),vcpu:c.number(),memory:c.number(),disk_size:c.number(),manifest_version:c.number().nullable(),version:c.string().nullable(),runner:c.string().nullable(),docker_compose_file:c.string().nullable(),features:c.array(c.string()).nullable(),created_at:c.string(),encrypted_env_pubkey:c.string().nullable()}),Fg=c.object({key:c.string(),value:c.string()}),Qs=c.object({is_online:c.boolean(),is_public:c.boolean(),error:c.string().nullable(),internal_ip:c.string(),latest_handshake:c.string(),public_urls:c.array(c.object({app:c.string(),instance:c.string()}))}),ei=c.object({id:c.number(),name:c.string(),status:c.string(),teepod_id:c.number(),teepod:c.object({id:c.number(),name:c.string()}),user_id:c.number().nullable(),app_id:c.string(),vm_uuid:c.string().nullable(),instance_id:c.string().nullable(),app_url:c.string().nullable(),base_image:c.string().nullable(),vcpu:c.number(),memory:c.number(),disk_size:c.number(),manifest_version:c.number().nullable(),version:c.string().nullable(),runner:c.string().nullable(),docker_compose_file:c.string().nullable(),features:c.array(c.string()).nullable(),created_at:c.string(),encrypted_env_pubkey:c.string().nullable()}),ti=c.object({is_online:c.boolean(),is_public:c.boolean(),error:c.string().nullable(),app_certificates:c.array(c.object({subject:c.object({common_name:c.string().nullable(),organization:c.string().nullable(),country:c.string().nullable(),state:c.string().nullable().optional(),locality:c.string().nullable().optional()}),issuer:c.object({common_name:c.string().nullable(),organization:c.string().nullable(),country:c.string().nullable()}),serial_number:c.string(),not_before:c.string(),not_after:c.string(),version:c.string(),fingerprint:c.string(),signature_algorithm:c.string(),sans:c.string().nullable(),is_ca:c.boolean(),position_in_chain:c.number(),quote:c.string().nullable()})).nullable(),tcb_info:c.object({mrtd:c.string(),rootfs_hash:c.string(),rtmr0:c.string(),rtmr1:c.string(),rtmr2:c.string(),rtmr3:c.string(),event_log:c.array(c.object({imr:c.number(),event_type:c.number(),digest:c.string(),event:c.string(),event_payload:c.string()}))}).nullable(),compose_file:c.string().nullable()}),Lu=c.object({name:c.string(),description:c.string().optional(),version:c.array(c.number()).optional(),is_dev:c.boolean().optional(),os_image_hash:c.string().nullable().optional(),rootfs_hash:c.string().optional(),shared_ro:c.boolean().optional(),cmdline:c.string().optional(),kernel:c.string().optional(),initrd:c.string().optional(),hda:c.string().nullable().optional(),rootfs:c.string().optional(),bios:c.string().optional()}),Og=c.object({teepod_id:c.number().nullable(),id:c.number().optional(),name:c.string(),listed:c.boolean().optional(),resource_score:c.number().optional(),remaining_vcpu:c.number().optional(),remaining_memory:c.number().optional(),remaining_cvm_slots:c.number().optional(),images:c.array(Lu).optional(),region_identifier:c.string().optional(),dedicated_for_team_id:c.number().nullable().optional(),support_onchain_kms:c.boolean().optional(),fmspc:c.string().nullable().optional(),device_id:c.string().nullable().optional()});import Ru from"inquirer";async function Vg(e){let t=await N(),r=await vr(t);if(!r.success)throw new Error(`Failed to fetch CVMs: ${r.error.message}`);let o=e.replace(/^app_/,""),i=r.data.items.find(l=>l.hosted?.app_id===o);if(!i)throw new Error(`CVM with App ID app_${o} not found`);return Se.success(`CVM with App ID app_${o} detected`),i.hosted?.app_id||""}async function Kg(e){let t=await N(),r=e.replace(/^app_/,""),o=await mt(t,{app_id:r});if(!o.success)throw new Error(o.error.message);return o.data}async function Wg(e){let t=await N(),r=await uo(t,{id:e});if(!r.success)throw new Error(r.error.message);return r.data}async function Xg(e){let t=await N(),r=e.replace(/^app_/,""),o=await t.get(`cvms/app_${r}/network`);return Qs.parse(o)}async function Jg(e){let t=await N(),r=e.replace(/^app_/,""),o=await t.post(`cvms/app_${r}/start`);return(await mt(t,{app_id:r})).data}async function Zg(e){let t=await N(),r=e.replace(/^app_/,"");return await t.post(`cvms/app_${r}/stop`),(await mt(t,{app_id:r})).data}async function Yg(e){let t=await N(),r=e.replace(/^app_/,"");return await t.post(`cvms/app_${r}/restart`),(await mt(t,{app_id:r})).data}async function Qg(e){let t=await N(),r=e.replace(/^app_/,"");return await t.delete(`cvms/app_${r}`),!0}async function eb(){let e=Se.startSpinner("Fetching available CVMs"),t=await N(),r=await vr(t);if(e.stop(!0),!r.success){Se.error(`Failed to fetch CVMs: ${r.error.message}`);return}let n=r.data.items;if(!n||n.length===0){Se.info("No CVMs found for your account");return}let s=n.map(a=>{let l=a,u=l.hosted?.app_id||l.hosted?.id,f=l.name||l.hosted?.name,p=l.status||l.hosted?.status;return{name:`${f||"Unnamed"} (${u}) - Status: ${p||"Unknown"}`,value:u}}),{selectedCvm:i}=await Ru.prompt([{type:"list",name:"selectedCvm",message:"Select a CVM:",choices:s}]);return i}async function tb(e){let t=await N(),r=e.replace(/^app_/,""),o=await t.get(`cvms/app_${r}/attestation`);try{return ti.parse(o)}catch(n){return Se.debug(`Validation error: ${n instanceof Error?n.message:String(n)}`),{is_online:!!o?.is_online,is_public:!!o?.is_public,error:typeof o?.error=="string"?o.error:null,app_certificates:Array.isArray(o?.app_certificates)?o.app_certificates:null,tcb_info:o?.tcb_info||null,compose_file:typeof o?.compose_file=="string"?o.compose_file:null}}}async function rb(e,t){let r=await N(),o=e.replace(/^app_/,""),n=await r.post(`cvms/app_${o}/replicas`,t);return ei.parse(n)}async function ob(e,t,r,o,n){let s=await N(),i=e.replace(/^app_/,""),a={};if(t!==void 0&&(a.vcpu=t),r!==void 0&&(a.memory=r),o!==void 0&&(a.disk_size=o),n!==void 0&&(a.allow_restart=n),Object.keys(a).length===0)throw new Error("At least one resource parameter must be provided");return await s.patch(`cvms/app_${i}/resources`,a),!0}async function nb(e){return await(await N()).post("cvms/pubkey/from_cvm_configuration",e)}async function sb(e){let r=await(await N()).post("cvms/from_cvm_configuration",e);return Ys.parse(r)}async function ib(e,t){let r=await N(),o=e.replace(/^app_/,"");return await r.put(`cvms/app_${o}/compose`,t)}async function ab(e=!1){let t=await N(),r="teepods/available";return e&&(r+="?v03x_only=1"),await t.get(r)}export{Vg as checkCvmExists,Hg as composeFileSchema,sb as createCvm,ti as cvmAttestationResponseSchema,Qg as deleteCvm,$u as dockerConfigSchema,Fg as encryptedEnvItemSchema,tb as getCvmAttestation,Kg as getCvmByAppId,Wg as getCvmComposeConfig,Xg as getCvmNetwork,Qs as getCvmNetworkResponseSchema,nb as getPubkeyFromCvm,ab as getTeepods,Lu as imageSchema,Ys as postCvmResponseSchema,rb as replicateCvm,ei as replicateCvmResponseSchema,ob as resizeCvm,Yg as restartCvm,eb as selectCvm,Jg as startCvm,Zg as stopCvm,Og as teepodSchema,ib as upgradeCvm};
38
38
  /*! Bundled license information:
39
39
 
40
40
  @noble/hashes/esm/utils.js:
41
- (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
42
-
43
41
  @noble/hashes/utils.js:
44
42
  (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
45
43
  */