phala 1.1.0-beta.7 → 1.1.0-beta.8

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,15 +1,15 @@
1
1
  import { createRequire } from 'module';const require = createRequire(import.meta.url);
2
- var Ys=Object.create;var po=Object.defineProperty;var Qs=Object.getOwnPropertyDescriptor;var ei=Object.getOwnPropertyNames;var ti=Object.getPrototypeOf,ri=Object.prototype.hasOwnProperty;var be=(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 T=(e,t)=>()=>(e&&(t=e(e=0)),t);var K=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var oi=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ei(t))!ri.call(e,n)&&n!==r&&po(e,n,{get:()=>t[n],enumerable:!(o=Qs(t,n))||o.enumerable});return e};var pt=(e,t,r)=>(r=e!=null?Ys(ti(e)):{},oi(t||!e||!e.__esModule?po(r,"default",{value:e,enumerable:!0}):r,e));var fo=K((lu,uo)=>{var qe=1e3,Ve=qe*60,Ke=Ve*60,$e=Ke*24,ni=$e*7,si=$e*365.25;uo.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return ii(e);if(r==="number"&&isFinite(e))return t.long?ci(e):ai(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function ii(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*si;case"weeks":case"week":case"w":return r*ni;case"days":case"day":case"d":return r*$e;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Ke;case"minutes":case"minute":case"mins":case"min":case"m":return r*Ve;case"seconds":case"second":case"secs":case"sec":case"s":return r*qe;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function ai(e){var t=Math.abs(e);return t>=$e?Math.round(e/$e)+"d":t>=Ke?Math.round(e/Ke)+"h":t>=Ve?Math.round(e/Ve)+"m":t>=qe?Math.round(e/qe)+"s":e+"ms"}function ci(e){var t=Math.abs(e);return t>=$e?$t(e,t,$e,"day"):t>=Ke?$t(e,t,Ke,"hour"):t>=Ve?$t(e,t,Ve,"minute"):t>=qe?$t(e,t,qe,"second"):e+" ms"}function $t(e,t,r,o){var n=t>=r*1.5;return Math.round(e/r)+" "+o+(n?"s":"")}});var yr=K((pu,mo)=>{function li(e){r.debug=r,r.default=r,r.coerce=l,r.disable=i,r.enable=n,r.enabled=a,r.humanize=fo(),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 k(...P){if(!k.enabled)return;let q=k,V=Number(new Date),H=V-(p||V);q.diff=H,q.prev=p,q.curr=V,p=V,P[0]=r.coerce(P[0]),typeof P[0]!="string"&&P.unshift("%O");let J=0;P[0]=P[0].replace(/%([a-zA-Z%])/g,(Y,Lt)=>{if(Y==="%%")return"%";J++;let lo=r.formatters[Lt];if(typeof lo=="function"){let Zs=P[J];Y=lo.call(q,Zs),P.splice(J,1),J--}return Y}),r.formatArgs.call(q,P),(q.log||r.log).apply(q,P)}return k.namespace=f,k.useColors=r.useColors(),k.color=r.selectColor(f),k.extend=o,k.destroy=r.destroy,Object.defineProperty(k,"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(k),k}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,k=0;for(;d<f.length;)if(h<p.length&&(p[h]===f[d]||p[h]==="*"))p[h]==="*"?(I=h,k=d,h++):(d++,h++);else if(I!==-1)h=I+1,k++,d=k;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}mo.exports=li});var ho=K((W,Rt)=>{W.formatArgs=ui;W.save=fi;W.load=mi;W.useColors=pi;W.storage=di();W.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`."))}})();W.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 pi(){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 ui(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Rt.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)}W.log=console.debug||console.log||(()=>{});function fi(e){try{e?W.storage.setItem("debug",e):W.storage.removeItem("debug")}catch{}}function mi(){let e;try{e=W.storage.getItem("debug")||W.storage.getItem("DEBUG")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function di(){try{return localStorage}catch{}}Rt.exports=yr()(W);var{formatters:hi}=Rt.exports;hi.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var bo=K((uu,xo)=>{"use strict";xo.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 wo=K((fu,yo)=>{"use strict";var xi=be("os"),go=be("tty"),Q=bo(),{env:U}=process,Ce;Q("no-color")||Q("no-colors")||Q("color=false")||Q("color=never")?Ce=0:(Q("color")||Q("colors")||Q("color=true")||Q("color=always"))&&(Ce=1);"FORCE_COLOR"in U&&(U.FORCE_COLOR==="true"?Ce=1:U.FORCE_COLOR==="false"?Ce=0:Ce=U.FORCE_COLOR.length===0?1:Math.min(parseInt(U.FORCE_COLOR,10),3));function wr(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function vr(e,t){if(Ce===0)return 0;if(Q("color=16m")||Q("color=full")||Q("color=truecolor"))return 3;if(Q("color=256"))return 2;if(e&&!t&&Ce===void 0)return 0;let r=Ce||0;if(U.TERM==="dumb")return r;if(process.platform==="win32"){let o=xi.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in U)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(o=>o in U)||U.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in U)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(U.TEAMCITY_VERSION)?1:0;if(U.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in U){let o=parseInt((U.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(U.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(U.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(U.TERM)||"COLORTERM"in U?1:r}function bi(e){let t=vr(e,e&&e.isTTY);return wr(t)}yo.exports={supportsColor:bi,stdout:wr(vr(!0,go.isatty(1))),stderr:wr(vr(!0,go.isatty(2)))}});var _o=K((F,Ft)=>{var gi=be("tty"),Ut=be("util");F.init=Ti;F.log=_i;F.formatArgs=wi;F.save=Ci;F.load=ki;F.useColors=yi;F.destroy=Ut.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=wo();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 yi(){return"colors"in F.inspectOpts?!!F.inspectOpts.colors:gi.isatty(process.stderr.fd)}function wi(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 Ys=Object.create;var po=Object.defineProperty;var Qs=Object.getOwnPropertyDescriptor;var ei=Object.getOwnPropertyNames;var ti=Object.getPrototypeOf,ri=Object.prototype.hasOwnProperty;var be=(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 T=(e,t)=>()=>(e&&(t=e(e=0)),t);var K=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var oi=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ei(t))!ri.call(e,n)&&n!==r&&po(e,n,{get:()=>t[n],enumerable:!(o=Qs(t,n))||o.enumerable});return e};var pt=(e,t,r)=>(r=e!=null?Ys(ti(e)):{},oi(t||!e||!e.__esModule?po(r,"default",{value:e,enumerable:!0}):r,e));var fo=K((lu,uo)=>{var qe=1e3,Ve=qe*60,Ke=Ve*60,$e=Ke*24,ni=$e*7,si=$e*365.25;uo.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return ii(e);if(r==="number"&&isFinite(e))return t.long?ci(e):ai(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function ii(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*si;case"weeks":case"week":case"w":return r*ni;case"days":case"day":case"d":return r*$e;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Ke;case"minutes":case"minute":case"mins":case"min":case"m":return r*Ve;case"seconds":case"second":case"secs":case"sec":case"s":return r*qe;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function ai(e){var t=Math.abs(e);return t>=$e?Math.round(e/$e)+"d":t>=Ke?Math.round(e/Ke)+"h":t>=Ve?Math.round(e/Ve)+"m":t>=qe?Math.round(e/qe)+"s":e+"ms"}function ci(e){var t=Math.abs(e);return t>=$e?$t(e,t,$e,"day"):t>=Ke?$t(e,t,Ke,"hour"):t>=Ve?$t(e,t,Ve,"minute"):t>=qe?$t(e,t,qe,"second"):e+" ms"}function $t(e,t,r,o){var n=t>=r*1.5;return Math.round(e/r)+" "+o+(n?"s":"")}});var yr=K((pu,mo)=>{function li(e){r.debug=r,r.default=r,r.coerce=l,r.disable=i,r.enable=n,r.enabled=a,r.humanize=fo(),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 k(...P){if(!k.enabled)return;let q=k,V=Number(new Date),H=V-(p||V);q.diff=H,q.prev=p,q.curr=V,p=V,P[0]=r.coerce(P[0]),typeof P[0]!="string"&&P.unshift("%O");let J=0;P[0]=P[0].replace(/%([a-zA-Z%])/g,(Y,Lt)=>{if(Y==="%%")return"%";J++;let lo=r.formatters[Lt];if(typeof lo=="function"){let Zs=P[J];Y=lo.call(q,Zs),P.splice(J,1),J--}return Y}),r.formatArgs.call(q,P),(q.log||r.log).apply(q,P)}return k.namespace=f,k.useColors=r.useColors(),k.color=r.selectColor(f),k.extend=o,k.destroy=r.destroy,Object.defineProperty(k,"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(k),k}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,k=0;for(;d<f.length;)if(h<p.length&&(p[h]===f[d]||p[h]==="*"))p[h]==="*"?(I=h,k=d,h++):(d++,h++);else if(I!==-1)h=I+1,k++,d=k;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}mo.exports=li});var ho=K((W,Rt)=>{W.formatArgs=ui;W.save=fi;W.load=mi;W.useColors=pi;W.storage=di();W.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`."))}})();W.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 pi(){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 ui(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Rt.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)}W.log=console.debug||console.log||(()=>{});function fi(e){try{e?W.storage.setItem("debug",e):W.storage.removeItem("debug")}catch{}}function mi(){let e;try{e=W.storage.getItem("debug")||W.storage.getItem("DEBUG")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function di(){try{return localStorage}catch{}}Rt.exports=yr()(W);var{formatters:hi}=Rt.exports;hi.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var bo=K((uu,xo)=>{"use strict";xo.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 wo=K((fu,yo)=>{"use strict";var xi=be("os"),go=be("tty"),Q=bo(),{env:U}=process,_e;Q("no-color")||Q("no-colors")||Q("color=false")||Q("color=never")?_e=0:(Q("color")||Q("colors")||Q("color=true")||Q("color=always"))&&(_e=1);"FORCE_COLOR"in U&&(U.FORCE_COLOR==="true"?_e=1:U.FORCE_COLOR==="false"?_e=0:_e=U.FORCE_COLOR.length===0?1:Math.min(parseInt(U.FORCE_COLOR,10),3));function wr(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function vr(e,t){if(_e===0)return 0;if(Q("color=16m")||Q("color=full")||Q("color=truecolor"))return 3;if(Q("color=256"))return 2;if(e&&!t&&_e===void 0)return 0;let r=_e||0;if(U.TERM==="dumb")return r;if(process.platform==="win32"){let o=xi.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in U)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(o=>o in U)||U.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in U)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(U.TEAMCITY_VERSION)?1:0;if(U.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in U){let o=parseInt((U.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(U.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(U.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(U.TERM)||"COLORTERM"in U?1:r}function bi(e){let t=vr(e,e&&e.isTTY);return wr(t)}yo.exports={supportsColor:bi,stdout:wr(vr(!0,go.isatty(1))),stderr:wr(vr(!0,go.isatty(2)))}});var Co=K((F,Ft)=>{var gi=be("tty"),Ut=be("util");F.init=Ti;F.log=Ci;F.formatArgs=wi;F.save=_i;F.load=ki;F.useColors=yi;F.destroy=Ut.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=wo();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 yi(){return"colors"in F.inspectOpts?!!F.inspectOpts.colors:gi.isatty(process.stderr.fd)}function wi(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+"+Ft.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=vi()+t+" "+e[0]}function vi(){return F.inspectOpts.hideDate?"":new Date().toISOString()+" "}function _i(...e){return process.stderr.write(Ut.formatWithOptions(F.inspectOpts,...e)+`
5
- `)}function Ci(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function ki(){return process.env.DEBUG}function Ti(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]]}Ft.exports=yr()(F);var{formatters:vo}=Ft.exports;vo.o=function(e){return this.inspectOpts.colors=this.useColors,Ut.inspect(e,this.inspectOpts).split(`
6
- `).map(t=>t.trim()).join(" ")};vo.O=function(e){return this.inspectOpts.colors=this.useColors,Ut.inspect(e,this.inspectOpts)}});var Co=K((mu,_r)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?_r.exports=ho():_r.exports=_o()});var Cr,To=T(()=>{Cr="2.38.6"});function Eo(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?Eo(e.cause,t):t?null:e}var kr,b,ee=T(()=>{To();kr={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${Cr}`},b=class extends Error{constructor(t,r={}){let o=(()=>r.cause instanceof b?r.cause.details:r.cause?.message?r.cause.message:r.details)(),n=(()=>r.cause instanceof b&&r.cause.docsPath||r.docsPath)(),s=kr.getDocsUrl?.({...r,docsPath:n}),i=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...o?[`Details: ${o}`]:[],...kr.version?[`Version: ${kr.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=Cr}walk(t){return Eo(this,t)}}});var zt,Ht,Tr=T(()=>{ee();zt=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"})}},Ht=class extends b{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}});function ue(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}var We=T(()=>{});function te(e){return ue(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}var ut=T(()=>{We()});function ft(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 So=T(()=>{});var mt,dt,Er=T(()=>{ee();mt=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"})}},dt=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 ke(e,{dir:t,size:r=32}={}){return typeof e=="string"?Ei(e,{dir:t,size:r}):Si(e,{dir:t,size:r})}function Ei(e,{dir:t,size:r=32}={}){if(r===null)return e;let o=e.replace("0x","");if(o.length>r*2)throw new dt({size:Math.ceil(o.length/2),targetSize:r,type:"hex"});return`0x${o[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function Si(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new dt({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 Sr=T(()=>{Er()});function ie(e,t={}){return typeof e=="number"||typeof e=="bigint"?_(e,t):typeof e=="string"?Bi(e,t):typeof e=="boolean"?Ai(e,t):X(e,t)}function Ai(e,t={}){let r=`0x${Number(e)}`;return typeof t.size=="number"?(Te(r,{size:t.size}),ke(r,{size:t.size})):r}function X(e,t={}){let r="";for(let n=0;n<e.length;n++)r+=Ii[e[n]];let o=`0x${r}`;return typeof t.size=="number"?(Te(o,{size:t.size}),ke(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 zt({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?ke(a,{size:o}):a}function Bi(e,t={}){let r=Pi.encode(e);return X(r,t)}var Ii,Pi,re=T(()=>{Tr();Sr();Ue();Ii=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));Pi=new TextEncoder});function Ot(e,t={}){return typeof e=="number"||typeof e=="bigint"?Ri(e,t):typeof e=="boolean"?$i(e,t):ue(e)?ae(e,t):Ir(e,t)}function $i(e,t={}){let r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(Te(r,{size:t.size}),ke(r,{size:t.size})):r}function Io(e){if(e>=ge.zero&&e<=ge.nine)return e-ge.zero;if(e>=ge.A&&e<=ge.F)return e-(ge.A-10);if(e>=ge.a&&e<=ge.f)return e-(ge.a-10)}function ae(e,t={}){let r=e;t.size&&(Te(r,{size:t.size}),r=ke(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=Io(o.charCodeAt(a++)),u=Io(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 Ri(e,t){let r=_(e,t);return ae(r)}function Ir(e,t={}){let r=Li.encode(e);return typeof t.size=="number"?(Te(r,{size:t.size}),ke(r,{dir:"right",size:t.size})):r}var Li,ge,Ee=T(()=>{ee();We();Sr();Ue();re();Li=new TextEncoder;ge={zero:48,nine:57,A:65,F:70,a:97,f:102}});function Te(e,{size:t}){if(te(e)>t)throw new Ht({givenSize:te(e),maxSize:t})}function Fe(e,t={}){let{signed:r}=t;t.size&&Te(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 ze(e,t={}){return Number(Fe(e,t))}var Ue=T(()=>{Tr();ut()});function Xe(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 jt=T(()=>{});var rf,of,nf,sf,af,cf,lf,pf,uf,ff,mf,df,hf,xf,bf,gf,yf,wf,vf,_f,Cf,kf,Tf,Ef,Sf,If,Af,Pf,Bf,Lf,$f,Rf,Uf,Ff,zf,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,bm,gm,ym,wm,vm,_m,Cm,km,Tm,Em,Sm,Im,Am,Pm,Bm,Lm,$m,Rm,Um,Fm,zm,Hm,Om,jm,Nm,Gm,Dm,Nt,$o=T(()=>{rf=2n**(8n-1n)-1n,of=2n**(16n-1n)-1n,nf=2n**(24n-1n)-1n,sf=2n**(32n-1n)-1n,af=2n**(40n-1n)-1n,cf=2n**(48n-1n)-1n,lf=2n**(56n-1n)-1n,pf=2n**(64n-1n)-1n,uf=2n**(72n-1n)-1n,ff=2n**(80n-1n)-1n,mf=2n**(88n-1n)-1n,df=2n**(96n-1n)-1n,hf=2n**(104n-1n)-1n,xf=2n**(112n-1n)-1n,bf=2n**(120n-1n)-1n,gf=2n**(128n-1n)-1n,yf=2n**(136n-1n)-1n,wf=2n**(144n-1n)-1n,vf=2n**(152n-1n)-1n,_f=2n**(160n-1n)-1n,Cf=2n**(168n-1n)-1n,kf=2n**(176n-1n)-1n,Tf=2n**(184n-1n)-1n,Ef=2n**(192n-1n)-1n,Sf=2n**(200n-1n)-1n,If=2n**(208n-1n)-1n,Af=2n**(216n-1n)-1n,Pf=2n**(224n-1n)-1n,Bf=2n**(232n-1n)-1n,Lf=2n**(240n-1n)-1n,$f=2n**(248n-1n)-1n,Rf=2n**(256n-1n)-1n,Uf=-(2n**(8n-1n)),Ff=-(2n**(16n-1n)),zf=-(2n**(24n-1n)),Hf=-(2n**(32n-1n)),Of=-(2n**(40n-1n)),jf=-(2n**(48n-1n)),Nf=-(2n**(56n-1n)),Gf=-(2n**(64n-1n)),Df=-(2n**(72n-1n)),Mf=-(2n**(80n-1n)),qf=-(2n**(88n-1n)),Vf=-(2n**(96n-1n)),Kf=-(2n**(104n-1n)),Wf=-(2n**(112n-1n)),Xf=-(2n**(120n-1n)),Jf=-(2n**(128n-1n)),Zf=-(2n**(136n-1n)),Yf=-(2n**(144n-1n)),Qf=-(2n**(152n-1n)),em=-(2n**(160n-1n)),tm=-(2n**(168n-1n)),rm=-(2n**(176n-1n)),om=-(2n**(184n-1n)),nm=-(2n**(192n-1n)),sm=-(2n**(200n-1n)),im=-(2n**(208n-1n)),am=-(2n**(216n-1n)),cm=-(2n**(224n-1n)),lm=-(2n**(232n-1n)),pm=-(2n**(240n-1n)),um=-(2n**(248n-1n)),fm=-(2n**(256n-1n)),mm=2n**8n-1n,dm=2n**16n-1n,hm=2n**24n-1n,xm=2n**32n-1n,bm=2n**40n-1n,gm=2n**48n-1n,ym=2n**56n-1n,wm=2n**64n-1n,vm=2n**72n-1n,_m=2n**80n-1n,Cm=2n**88n-1n,km=2n**96n-1n,Tm=2n**104n-1n,Em=2n**112n-1n,Sm=2n**120n-1n,Im=2n**128n-1n,Am=2n**136n-1n,Pm=2n**144n-1n,Bm=2n**152n-1n,Lm=2n**160n-1n,$m=2n**168n-1n,Rm=2n**176n-1n,Um=2n**184n-1n,Fm=2n**192n-1n,zm=2n**200n-1n,Hm=2n**208n-1n,Om=2n**216n-1n,jm=2n**224n-1n,Nm=2n**232n-1n,Gm=2n**240n-1n,Dm=2n**248n-1n,Nt=2n**256n-1n});function He(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}var Pr=T(()=>{});var xt,Gt,Dt,Ro=T(()=>{ee();xt=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"})}},Dt=class extends b{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}});function Mt(e,{recursiveReadLimit:t=8192}={}){let r=Object.create(Oi);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}var Oi,Br=T(()=>{Ro();Oi={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 Dt({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 xt({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 xt({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 zo,Ho=T(()=>{zo={ether:-9,wei:9}});function Oo(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 jo=T(()=>{});function bt(e,t="wei"){return Oo(e,zo[t])}var No=T(()=>{Ho();jo()});function Gi(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(`
4
+ `+s),e.push(n+"m+"+Ft.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=vi()+t+" "+e[0]}function vi(){return F.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Ci(...e){return process.stderr.write(Ut.formatWithOptions(F.inspectOpts,...e)+`
5
+ `)}function _i(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function ki(){return process.env.DEBUG}function Ti(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]]}Ft.exports=yr()(F);var{formatters:vo}=Ft.exports;vo.o=function(e){return this.inspectOpts.colors=this.useColors,Ut.inspect(e,this.inspectOpts).split(`
6
+ `).map(t=>t.trim()).join(" ")};vo.O=function(e){return this.inspectOpts.colors=this.useColors,Ut.inspect(e,this.inspectOpts)}});var _o=K((mu,Cr)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Cr.exports=ho():Cr.exports=Co()});var _r,To=T(()=>{_r="2.38.6"});function Eo(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?Eo(e.cause,t):t?null:e}var kr,b,ee=T(()=>{To();kr={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${_r}`},b=class extends Error{constructor(t,r={}){let o=(()=>r.cause instanceof b?r.cause.details:r.cause?.message?r.cause.message:r.details)(),n=(()=>r.cause instanceof b&&r.cause.docsPath||r.docsPath)(),s=kr.getDocsUrl?.({...r,docsPath:n}),i=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...o?[`Details: ${o}`]:[],...kr.version?[`Version: ${kr.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=_r}walk(t){return Eo(this,t)}}});var zt,Ht,Tr=T(()=>{ee();zt=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"})}},Ht=class extends b{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}});function ue(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}var We=T(()=>{});function te(e){return ue(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}var ut=T(()=>{We()});function ft(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 So=T(()=>{});var mt,dt,Er=T(()=>{ee();mt=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"})}},dt=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 ke(e,{dir:t,size:r=32}={}){return typeof e=="string"?Ei(e,{dir:t,size:r}):Si(e,{dir:t,size:r})}function Ei(e,{dir:t,size:r=32}={}){if(r===null)return e;let o=e.replace("0x","");if(o.length>r*2)throw new dt({size:Math.ceil(o.length/2),targetSize:r,type:"hex"});return`0x${o[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function Si(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new dt({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 Sr=T(()=>{Er()});function ie(e,t={}){return typeof e=="number"||typeof e=="bigint"?C(e,t):typeof e=="string"?Bi(e,t):typeof e=="boolean"?Ai(e,t):X(e,t)}function Ai(e,t={}){let r=`0x${Number(e)}`;return typeof t.size=="number"?(Te(r,{size:t.size}),ke(r,{size:t.size})):r}function X(e,t={}){let r="";for(let n=0;n<e.length;n++)r+=Ii[e[n]];let o=`0x${r}`;return typeof t.size=="number"?(Te(o,{size:t.size}),ke(o,{dir:"right",size:t.size})):o}function C(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 zt({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?ke(a,{size:o}):a}function Bi(e,t={}){let r=Pi.encode(e);return X(r,t)}var Ii,Pi,re=T(()=>{Tr();Sr();Ue();Ii=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));Pi=new TextEncoder});function Ot(e,t={}){return typeof e=="number"||typeof e=="bigint"?Ri(e,t):typeof e=="boolean"?$i(e,t):ue(e)?ae(e,t):Ir(e,t)}function $i(e,t={}){let r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(Te(r,{size:t.size}),ke(r,{size:t.size})):r}function Io(e){if(e>=ge.zero&&e<=ge.nine)return e-ge.zero;if(e>=ge.A&&e<=ge.F)return e-(ge.A-10);if(e>=ge.a&&e<=ge.f)return e-(ge.a-10)}function ae(e,t={}){let r=e;t.size&&(Te(r,{size:t.size}),r=ke(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=Io(o.charCodeAt(a++)),u=Io(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 Ri(e,t){let r=C(e,t);return ae(r)}function Ir(e,t={}){let r=Li.encode(e);return typeof t.size=="number"?(Te(r,{size:t.size}),ke(r,{dir:"right",size:t.size})):r}var Li,ge,Ee=T(()=>{ee();We();Sr();Ue();re();Li=new TextEncoder;ge={zero:48,nine:57,A:65,F:70,a:97,f:102}});function Te(e,{size:t}){if(te(e)>t)throw new Ht({givenSize:te(e),maxSize:t})}function Fe(e,t={}){let{signed:r}=t;t.size&&Te(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 ze(e,t={}){return Number(Fe(e,t))}var Ue=T(()=>{Tr();ut()});function Xe(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 jt=T(()=>{});var rf,of,nf,sf,af,cf,lf,pf,uf,ff,mf,df,hf,xf,bf,gf,yf,wf,vf,Cf,_f,kf,Tf,Ef,Sf,If,Af,Pf,Bf,Lf,$f,Rf,Uf,Ff,zf,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,bm,gm,ym,wm,vm,Cm,_m,km,Tm,Em,Sm,Im,Am,Pm,Bm,Lm,$m,Rm,Um,Fm,zm,Hm,Om,jm,Nm,Gm,Dm,Nt,$o=T(()=>{rf=2n**(8n-1n)-1n,of=2n**(16n-1n)-1n,nf=2n**(24n-1n)-1n,sf=2n**(32n-1n)-1n,af=2n**(40n-1n)-1n,cf=2n**(48n-1n)-1n,lf=2n**(56n-1n)-1n,pf=2n**(64n-1n)-1n,uf=2n**(72n-1n)-1n,ff=2n**(80n-1n)-1n,mf=2n**(88n-1n)-1n,df=2n**(96n-1n)-1n,hf=2n**(104n-1n)-1n,xf=2n**(112n-1n)-1n,bf=2n**(120n-1n)-1n,gf=2n**(128n-1n)-1n,yf=2n**(136n-1n)-1n,wf=2n**(144n-1n)-1n,vf=2n**(152n-1n)-1n,Cf=2n**(160n-1n)-1n,_f=2n**(168n-1n)-1n,kf=2n**(176n-1n)-1n,Tf=2n**(184n-1n)-1n,Ef=2n**(192n-1n)-1n,Sf=2n**(200n-1n)-1n,If=2n**(208n-1n)-1n,Af=2n**(216n-1n)-1n,Pf=2n**(224n-1n)-1n,Bf=2n**(232n-1n)-1n,Lf=2n**(240n-1n)-1n,$f=2n**(248n-1n)-1n,Rf=2n**(256n-1n)-1n,Uf=-(2n**(8n-1n)),Ff=-(2n**(16n-1n)),zf=-(2n**(24n-1n)),Hf=-(2n**(32n-1n)),Of=-(2n**(40n-1n)),jf=-(2n**(48n-1n)),Nf=-(2n**(56n-1n)),Gf=-(2n**(64n-1n)),Df=-(2n**(72n-1n)),Mf=-(2n**(80n-1n)),qf=-(2n**(88n-1n)),Vf=-(2n**(96n-1n)),Kf=-(2n**(104n-1n)),Wf=-(2n**(112n-1n)),Xf=-(2n**(120n-1n)),Jf=-(2n**(128n-1n)),Zf=-(2n**(136n-1n)),Yf=-(2n**(144n-1n)),Qf=-(2n**(152n-1n)),em=-(2n**(160n-1n)),tm=-(2n**(168n-1n)),rm=-(2n**(176n-1n)),om=-(2n**(184n-1n)),nm=-(2n**(192n-1n)),sm=-(2n**(200n-1n)),im=-(2n**(208n-1n)),am=-(2n**(216n-1n)),cm=-(2n**(224n-1n)),lm=-(2n**(232n-1n)),pm=-(2n**(240n-1n)),um=-(2n**(248n-1n)),fm=-(2n**(256n-1n)),mm=2n**8n-1n,dm=2n**16n-1n,hm=2n**24n-1n,xm=2n**32n-1n,bm=2n**40n-1n,gm=2n**48n-1n,ym=2n**56n-1n,wm=2n**64n-1n,vm=2n**72n-1n,Cm=2n**80n-1n,_m=2n**88n-1n,km=2n**96n-1n,Tm=2n**104n-1n,Em=2n**112n-1n,Sm=2n**120n-1n,Im=2n**128n-1n,Am=2n**136n-1n,Pm=2n**144n-1n,Bm=2n**152n-1n,Lm=2n**160n-1n,$m=2n**168n-1n,Rm=2n**176n-1n,Um=2n**184n-1n,Fm=2n**192n-1n,zm=2n**200n-1n,Hm=2n**208n-1n,Om=2n**216n-1n,jm=2n**224n-1n,Nm=2n**232n-1n,Gm=2n**240n-1n,Dm=2n**248n-1n,Nt=2n**256n-1n});function He(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}var Pr=T(()=>{});var xt,Gt,Dt,Ro=T(()=>{ee();xt=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"})}},Dt=class extends b{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}});function Mt(e,{recursiveReadLimit:t=8192}={}){let r=Object.create(Oi);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}var Oi,Br=T(()=>{Ro();Oi={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 Dt({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 xt({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 xt({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 zo,Ho=T(()=>{zo={ether:-9,wei:9}});function Oo(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 jo=T(()=>{});function bt(e,t="wei"){return Oo(e,zo[t])}var No=T(()=>{Ho();jo()});function Gi(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
8
  `)}var qt,Vt,Kt,Wt=T(()=>{ee();qt=class extends b{constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}},Vt=class extends b{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Gi(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"})}},Kt=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 Di(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Lr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Oe(e,...t){if(!Di(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 Ye(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 Zt(e,t){Oe(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Do(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Se(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Yt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ce(e,t){return e<<32-t|e>>>t}function qi(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Vi(e){for(let t=0;t<e.length;t++)e[t]=qi(e[t]);return e}function Ki(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function gt(e){return typeof e=="string"&&(e=Ki(e)),Oe(e),e}function Qt(e){let t=o=>e().update(gt(o)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}var Mi,$r,Ze,er=T(()=>{Mi=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();$r=Mi?e=>e:Vi;Ze=class{}});function Xi(e,t=!1){return t?{h:Number(e&rr),l:Number(e>>Vo&rr)}:{h:Number(e>>Vo&rr)|0,l:Number(e&rr)|0}}function Ko(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}=Xi(e[s],t);[o[s],n[s]]=[i,a]}return[o,n]}var rr,Vo,Wo,Xo,Jo,Zo,Yo=T(()=>{rr=BigInt(4294967295),Vo=BigInt(32);Wo=(e,t,r)=>e<<r|t>>>32-r,Xo=(e,t,r)=>t<<r|e>>>32-r,Jo=(e,t,r)=>t<<r-32|e>>>64-r,Zo=(e,t,r)=>e<<r-32|t>>>64-r});var oe,ar=T(()=>{ee();oe=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 je,an=T(()=>{ee();je=class extends b{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}});var cr,Ne,Rr,Ur,Fr,zr,Hr,Or,jr,Nr,yt,cn=T(()=>{No();ee();cr=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(cr,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(cr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});Ne=class extends b{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${bt(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}};Object.defineProperty(Ne,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});Rr=class extends b{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${bt(r)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}};Object.defineProperty(Rr,"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/});Ur=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(Ur,"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
9
  `),{cause:t,name:"NonceTooLowError"})}};Object.defineProperty(Fr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});zr=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(zr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});Hr=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
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(Hr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});Or=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(Or,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});jr=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(jr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});Nr=class extends b{constructor({cause:t}){super("The transaction type is not supported for this chain.",{cause:t,name:"TransactionTypeNotSupportedError"})}};Object.defineProperty(Nr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});yt=class extends b{constructor({cause:t,maxPriorityFeePerGas:r,maxFeePerGas:o}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${bt(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${o?` = ${bt(o)} gwei`:""}).`].join(`
11
- `),{cause:t,name:"TipAboveFeeCapError"})}};Object.defineProperty(yt,"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 et,Gr=T(()=>{et=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 ia(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=ln(u,f,1)^r[a],d=pn(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=fn[i],l=ln(n,s,a),u=pn(n,s,a),f=un[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]^=na[o],e[1]^=sa[o]}Se(r)}var Qi,wt,ea,ta,ra,oa,un,fn,mn,dn,na,sa,ln,pn,vt,aa,hn,xn=T(()=>{Yo();er();Qi=BigInt(0),wt=BigInt(1),ea=BigInt(2),ta=BigInt(7),ra=BigInt(256),oa=BigInt(113),un=[],fn=[],mn=[];for(let e=0,t=wt,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],un.push(2*(5*o+r)),fn.push((e+1)*(e+2)/2%64);let n=Qi;for(let s=0;s<7;s++)t=(t<<wt^(t>>ta)*oa)%ra,t&ea&&(n^=wt<<(wt<<BigInt(s))-wt);mn.push(n)}dn=Ko(mn,!0),na=dn[0],sa=dn[1],ln=(e,t,r)=>r>32?Jo(e,t,r):Wo(e,t,r),pn=(e,t,r)=>r>32?Zo(e,t,r):Xo(e,t,r);vt=class extends Ze{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,Lr(o),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Do(this.state)}clone(){return this._cloneInto()}keccak(){$r(this.state32),ia(this.state32,this.rounds),$r(this.state32),this.posOut=0,this.pos=0}update(t){Ye(this),t=gt(t),Oe(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){Ye(this,!1),Oe(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 Lr(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Zt(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,Se(this.state)}_cloneInto(t){let{blockLen:r,suffix:o,outputLen:n,rounds:s,enableXOF:i}=this;return t||(t=new vt(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}},aa=(e,t,r)=>Qt(()=>new vt(t,e,r)),hn=(()=>aa(1,136,256/8))()});function bn(e,t){let r=t||"hex",o=hn(ue(e,{strict:!1})?Ot(e):e);return r==="bytes"?o:ie(o)}var gn=T(()=>{xn();We();Ee();re()});function yn(e,t){if(Dr.has(`${e}.${t}`))return Dr.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),o=bn(Ir(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 Dr.set(`${e}.${t}`,s),s}var Dr,wn=T(()=>{Ee();gn();Gr();Dr=new et(8192)});function fe(e,t){let{strict:r=!0}=t??{},o=`${e}.${r}`;if(Mr.has(o))return Mr.get(o);let n=(()=>ca.test(e)?e.toLowerCase()===e?!0:r?yn(e)===e:!0:!1)();return Mr.set(o,n),n}var ca,Mr,lr=T(()=>{Gr();wn();ca=/^0x[a-fA-F0-9]{40}$/,Mr=new et(8192)});function vn(e,t,r,{strict:o}={}){return ue(e,{strict:!1})?pa(e,t,r,{strict:o}):la(e,t,r,{strict:o})}function _n(e,t){if(typeof t=="number"&&t>0&&t>te(e)-1)throw new mt({offset:t,position:"start",size:te(e)})}function Cn(e,t,r){if(typeof t=="number"&&typeof r=="number"&&te(e)!==r-t)throw new mt({offset:r,position:"end",size:te(e)})}function la(e,t,r,{strict:o}={}){_n(e,t);let n=e.slice(t,r);return o&&Cn(n,t,r),n}function pa(e,t,r,{strict:o}={}){_n(e,t);let n=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return o&&Cn(n,t,r),n}var kn=T(()=>{Er();We();ut()});var Wr=K(Tt=>{"use strict";var va=Tt&&Tt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Tt,"__esModule",{value:!0});Tt.encryptEnvVars=ka;var Vr=be("@noble/curves/ed25519"),Kr=va(be("crypto"));function _a(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 Ca(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function ka(e,t){let r=JSON.stringify({env:e}),o=Vr.x25519.utils.randomPrivateKey(),n=Vr.x25519.getPublicKey(o),s=_a(t),i=Vr.x25519.getSharedSecret(o,s),a=await Kr.default.subtle.importKey("raw",i,{name:"AES-GCM",length:256},!0,["encrypt"]),l=Kr.default.getRandomValues(new Uint8Array(12)),u=await Kr.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),Ca(f)}});var Rn=K(Et=>{"use strict";var Ta=Et&&Et.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Et,"__esModule",{value:!0});Et.getComposeHash=Aa;var Ea=Ta(be("crypto"));function Xr(e){return e==null?e:Array.isArray(e)?e.map(Xr):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let o=e[r];return t[r]=Xr(o),t},{}):e}function Sa(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 Ia(e){let t=Xr(e);return JSON.stringify(t,(r,o)=>typeof o=="number"&&(isNaN(o)||!isFinite(o))?null:o)}function Aa(e,t=!1){t&&(e=Sa(e));let r=Ia(e);return Ea.default.createHash("sha256").update(r,"utf8").digest("hex")}});var rs=K(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=Xn;y.fromBig=Zr;y.split=Un;var mr=BigInt(2**32-1),Jr=BigInt(32);function Zr(e,t=!1){return t?{h:Number(e&mr),l:Number(e>>Jr&mr)}:{h:Number(e>>Jr&mr)|0,l:Number(e&mr)|0}}function Un(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}=Zr(e[s],t);[o[s],n[s]]=[i,a]}return[o,n]}var Fn=(e,t)=>BigInt(e>>>0)<<Jr|BigInt(t>>>0);y.toBig=Fn;var zn=(e,t,r)=>e>>>r;y.shrSH=zn;var Hn=(e,t,r)=>e<<32-r|t>>>r;y.shrSL=Hn;var On=(e,t,r)=>e>>>r|t<<32-r;y.rotrSH=On;var jn=(e,t,r)=>e<<32-r|t>>>r;y.rotrSL=jn;var Nn=(e,t,r)=>e<<64-r|t>>>r-32;y.rotrBH=Nn;var Gn=(e,t,r)=>e>>>r-32|t<<64-r;y.rotrBL=Gn;var Dn=(e,t)=>t;y.rotr32H=Dn;var Mn=(e,t)=>e;y.rotr32L=Mn;var qn=(e,t,r)=>e<<r|t>>>32-r;y.rotlSH=qn;var Vn=(e,t,r)=>t<<r|e>>>32-r;y.rotlSL=Vn;var Kn=(e,t,r)=>t<<r-32|e>>>64-r;y.rotlBH=Kn;var Wn=(e,t,r)=>e<<r-32|t>>>64-r;y.rotlBL=Wn;function Xn(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/2**32|0)|0,l:n|0}}var Jn=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);y.add3L=Jn;var Zn=(e,t,r,o)=>t+r+o+(e/2**32|0)|0;y.add3H=Zn;var Yn=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0);y.add4L=Yn;var Qn=(e,t,r,o,n)=>t+r+o+n+(e/2**32|0)|0;y.add4H=Qn;var es=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0);y.add5L=es;var ts=(e,t,r,o,n,s)=>t+r+o+n+s+(e/2**32|0)|0;y.add5H=ts;var Pa={fromBig:Zr,split:Un,toBig:Fn,shrSH:zn,shrSL:Hn,rotrSH:On,rotrSL:jn,rotrBH:Nn,rotrBL:Gn,rotr32H:Dn,rotr32L:Mn,rotlSH:qn,rotlSL:Vn,rotlBH:Kn,rotlBL:Wn,add:Xn,add3L:Jn,add3H:Zn,add4L:Yn,add4H:Qn,add5H:ts,add5L:es};y.default=Pa});var os=K(dr=>{"use strict";Object.defineProperty(dr,"__esModule",{value:!0});dr.crypto=void 0;var Ae=be("node:crypto");dr.crypto=Ae&&typeof Ae=="object"&&"webcrypto"in Ae?Ae.webcrypto:Ae&&typeof Ae=="object"&&"randomBytes"in Ae?Ae:void 0});var us=K(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=ss;x.anumber=Yr;x.abytes=rt;x.ahash=Ba;x.aexists=La;x.aoutput=$a;x.u8=Ra;x.u32=Ua;x.clean=Fa;x.createView=za;x.rotr=Ha;x.rotl=Oa;x.byteSwap=eo;x.byteSwap32=is;x.bytesToHex=Na;x.hexToBytes=Ga;x.asyncLoop=Ma;x.utf8ToBytes=to;x.bytesToUtf8=qa;x.toBytes=hr;x.kdfInputToBytes=Va;x.concatBytes=Ka;x.checkOpts=Wa;x.createHasher=cs;x.createOptHasher=ls;x.createXOFer=ps;x.randomBytes=Xa;var tt=os();function ss(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Yr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function rt(e,...t){if(!ss(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 Ba(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Yr(e.outputLen),Yr(e.blockLen)}function La(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 $a(e,t){rt(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Ra(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Ua(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Fa(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function za(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ha(e,t){return e<<32-t|e>>>t}function Oa(e,t){return e<<t|e>>>32-t>>>0}x.isLE=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function eo(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}x.swap8IfBE=x.isLE?e=>e:e=>eo(e);x.byteSwapIfBE=x.swap8IfBE;function is(e){for(let t=0;t<e.length;t++)e[t]=eo(e[t]);return e}x.swap32IfBE=x.isLE?e=>e:is;var as=(()=>typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function")(),ja=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Na(e){if(rt(e),as)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=ja[e[r]];return t}var ve={_0:48,_9:57,A:65,F:70,a:97,f:102};function ns(e){if(e>=ve._0&&e<=ve._9)return e-ve._0;if(e>=ve.A&&e<=ve.F)return e-(ve.A-10);if(e>=ve.a&&e<=ve.f)return e-(ve.a-10)}function Ga(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(as)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=ns(e.charCodeAt(s)),a=ns(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 Da=async()=>{};x.nextTick=Da;async function Ma(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 to(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function qa(e){return new TextDecoder().decode(e)}function hr(e){return typeof e=="string"&&(e=to(e)),rt(e),e}function Va(e){return typeof e=="string"&&(e=to(e)),rt(e),e}function Ka(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];rt(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 Wa(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 Qr=class{};x.Hash=Qr;function cs(e){let t=o=>e().update(hr(o)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function ls(e){let t=(o,n)=>e(n).update(hr(o)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=o=>e(o),t}function ps(e){let t=(o,n)=>e(n).update(hr(o)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=o=>e(o),t}x.wrapConstructor=cs;x.wrapConstructorWithOpts=ls;x.wrapXOFConstructorWithOpts=ps;function Xa(e=32){if(tt.crypto&&typeof tt.crypto.getRandomValues=="function")return tt.crypto.getRandomValues(new Uint8Array(e));if(tt.crypto&&typeof tt.crypto.randomBytes=="function")return Uint8Array.from(tt.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}});var ws=K(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=gs;var It=rs(),N=us(),Ja=BigInt(0),St=BigInt(1),Za=BigInt(2),Ya=BigInt(7),Qa=BigInt(256),ec=BigInt(113),ds=[],hs=[],xs=[];for(let e=0,t=St,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],ds.push(2*(5*o+r)),hs.push((e+1)*(e+2)/2%64);let n=Ja;for(let s=0;s<7;s++)t=(t<<St^(t>>Ya)*ec)%Qa,t&Za&&(n^=St<<(St<<BigInt(s))-St);xs.push(n)}var bs=(0,It.split)(xs,!0),tc=bs[0],rc=bs[1],fs=(e,t,r)=>r>32?(0,It.rotlBH)(e,t,r):(0,It.rotlSH)(e,t,r),ms=(e,t,r)=>r>32?(0,It.rotlBL)(e,t,r):(0,It.rotlSL)(e,t,r);function gs(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=fs(u,f,1)^r[a],d=ms(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=hs[i],l=fs(n,s,a),u=ms(n,s,a),f=ds[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]^=tc[o],e[1]^=rc[o]}(0,N.clean)(r)}var Ge=class extends N.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,N.anumber)(o),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=(0,N.u32)(this.state)}clone(){return this._cloneInto()}keccak(){(0,N.swap32IfBE)(this.state32),gs(this.state32,this.rounds),(0,N.swap32IfBE)(this.state32),this.posOut=0,this.pos=0}update(t){(0,N.aexists)(this),t=(0,N.toBytes)(t),(0,N.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,N.aexists)(this,!1),(0,N.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,N.anumber)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,N.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,N.clean)(this.state)}_cloneInto(t){let{blockLen:r,suffix:o,outputLen:n,rounds:s,enableXOF:i}=this;return t||(t=new Ge(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=Ge;var Pe=(e,t,r)=>(0,N.createHasher)(()=>new Ge(t,e,r));A.sha3_224=(()=>Pe(6,144,224/8))();A.sha3_256=(()=>Pe(6,136,256/8))();A.sha3_384=(()=>Pe(6,104,384/8))();A.sha3_512=(()=>Pe(6,72,512/8))();A.keccak_224=(()=>Pe(1,144,224/8))();A.keccak_256=(()=>Pe(1,136,256/8))();A.keccak_384=(()=>Pe(1,104,384/8))();A.keccak_512=(()=>Pe(1,72,512/8))();var ys=(e,t,r)=>(0,N.createXOFer)((o={})=>new Ge(t,e,o.dkLen===void 0?r:o.dkLen,!0));A.shake128=(()=>ys(31,168,128/8))();A.shake256=(()=>ys(31,136,256/8))()});var vs=K(ro=>{"use strict";Object.defineProperty(ro,"__esModule",{value:!0});ro.verifyEnvEncryptPublicKey=sc;var oc=ws(),nc=be("@noble/curves/secp256k1");function sc(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,oc.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=nc.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 Es=pt(Co(),1);import{ofetch as ic}from"ofetch";function ko(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}from"zod";import{z as Be}from"zod";import{z as v}from"zod";import{z as Le}from"zod";function Re(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}jt();Ue();jt();var Ar={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function ht(e,t){let r={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?ze(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?ze(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Ar[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=Ui(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 Ao=Xe("transaction",ht);function Ui(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 Fi(e,t){let r=(e.transactions??[]).map(o=>typeof o=="string"?o:ht(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 Po=Xe("block",Fi);function Bo(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}:{}}}Ue();jt();var zi={"0x0":"reverted","0x1":"success"};function Hi(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=>Bo(o)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?ze(e.transactionIndex):null,status:e.status?zi[e.status]:null,type:e.type?Ar[e.type]||e.type:null};return e.blobGasPrice&&(r.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(r.blobGasUsed=BigInt(e.blobGasUsed)),r}var Lo=Xe("transactionReceipt",Hi);ee();Br();Ee();re();function ye(e,t="hex"){let r=Uo(e),o=Mt(new Uint8Array(r.length));return r.encode(o),t==="hex"?X(o.bytes):o.bytes}function Uo(e){return Array.isArray(e)?ji(e.map(t=>Uo(t))):Ni(e)}function ji(e){let t=e.reduce((n,s)=>n+s.length,0),r=Fo(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 Ni(e){let t=typeof e=="string"?ae(e):e,r=Fo(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 Fo(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.")}Wt();re();function Go(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?ie(o):"0x",i,n?ie(n):"0x",...Je({},s)])}return t}Ee();re();function Xt(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=>ae(s)):e.blobs,n=[];for(let s of o)n.push(Uint8Array.from(t.blobToKzgCommitment(s)));return r==="bytes"?n:n.map(s=>X(s))}Ee();re();function Jt(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=>ae(i)):e.blobs,n=typeof e.commitments[0]=="string"?e.commitments.map(i=>ae(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=>X(i))}re();er();function Wi(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 Mo(e,t,r){return e&t^~e&r}function qo(e,t,r){return e&t^e&r^t&r}var tr=class extends Ze{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=Yt(this.buffer)}update(t){Ye(this),t=gt(t),Oe(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=Yt(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){Ye(this),Zt(t,this),this.finished=!0;let{buffer:r,view:o,blockLen:n,isLE:s}=this,{pos:i}=this;r[i++]=128,Se(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let p=i;p<n;p++)r[p]=0;Wi(o,n-8,BigInt(this.length*8),s),this.process(o,0);let a=Yt(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()}},we=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);er();var Ji=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]),Ie=new Uint32Array(64),or=class extends tr{constructor(t=32){super(64,t,8,!1),this.A=we[0]|0,this.B=we[1]|0,this.C=we[2]|0,this.D=we[3]|0,this.E=we[4]|0,this.F=we[5]|0,this.G=we[6]|0,this.H=we[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)Ie[p]=t.getUint32(r,!1);for(let p=16;p<64;p++){let d=Ie[p-15],h=Ie[p-2],I=ce(d,7)^ce(d,18)^d>>>3,k=ce(h,17)^ce(h,19)^h>>>10;Ie[p]=k+Ie[p-7]+I+Ie[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=ce(a,6)^ce(a,11)^ce(a,25),h=f+d+Mo(a,l,u)+Ji[p]+Ie[p]|0,k=(ce(o,2)^ce(o,13)^ce(o,22))+qo(o,n,s)|0;f=u,u=l,l=a,a=i+h|0,i=s,s=n,n=o,o=h+k|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(){Se(Ie)}destroy(){this.set(0,0,0,0,0,0,0,0),Se(this.buffer)}};var Qo=Qt(()=>new or);var en=Qo;We();Ee();re();function tn(e,t){let r=t||"hex",o=en(ue(e,{strict:!1})?Ot(e):e);return r==="bytes"?o:ie(o)}function rn(e){let{commitment:t,version:r=1}=e,o=e.to??(typeof t=="string"?"hex":"bytes"),n=tn(t,"bytes");return n.set([r],0),o==="bytes"?n:X(n)}function on(e){let{commitments:t,version:r}=e,o=e.to??(typeof t[0]=="string"?"hex":"bytes"),n=[];for(let s of t)n.push(rn({commitment:s,to:o,version:r}));return n}ee();var nr=class extends b{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}},Qe=class extends b{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}},sr=class extends b{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}},ir=class extends b{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${1}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}};Br();ut();Ee();re();function nn(e){let t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?ae(e.data):e.data,o=te(r);if(!o)throw new Qe;if(o>761855)throw new nr({maxSize:761855,size:o});let n=[],s=!0,i=0;for(;s;){let a=Mt(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=>X(a.bytes))}function sn(e){let{data:t,kzg:r,to:o}=e,n=e.blobs??nn({data:t,to:o}),s=e.commitments??Xt({blobs:n,kzg:r,to:o}),i=e.proofs??Jt({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}Pr();So();re();$o();ar();ee();an();cn();lr();ut();kn();Ue();function Tn(e){let{authorizationList:t}=e;if(t)for(let r of t){let{chainId:o}=r,n=r.address;if(!fe(n))throw new oe({address:n});if(o<0)throw new je({chainId:o})}pr(e)}function En(e){let{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new Qe;for(let r of t){let o=te(r),n=ze(vn(r,0,1));if(o!==32)throw new sr({hash:r,size:o});if(n!==1)throw new ir({hash:r,version:n})}}pr(e)}function pr(e){let{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:o,to:n}=e;if(t<=0)throw new je({chainId:t});if(n&&!fe(n))throw new oe({address:n});if(o&&o>Nt)throw new Ne({maxFeePerGas:o});if(r&&o&&r>o)throw new yt({maxFeePerGas:o,maxPriorityFeePerGas:r})}function Sn(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:o,maxFeePerGas:n,to:s}=e;if(t<=0)throw new je({chainId:t});if(s&&!fe(s))throw new oe({address:s});if(r||n)throw new b("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(o&&o>Nt)throw new Ne({maxFeePerGas:o})}function In(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:o,maxFeePerGas:n,to:s}=e;if(s&&!fe(s))throw new oe({address:s});if(typeof t<"u"&&t<=0)throw new je({chainId:t});if(r||n)throw new b("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(o&&o>Nt)throw new Ne({maxFeePerGas:o})}Wt();function An(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 Vt({transaction:e})}ar();Wt();lr();function _t(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 Kt({storageKey:n[s]});if(!fe(o,{strict:!1}))throw new oe({address:o});t.push([o,n])}return t}function Pn(e,t){let r=An(e);return r==="eip1559"?ma(e,t):r==="eip2930"?da(e,t):r==="eip4844"?fa(e,t):r==="eip7702"?ua(e,t):ha(e,t)}function ua(e,t){let{authorizationList:r,chainId:o,gas:n,nonce:s,to:i,value:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:f,data:p}=e;Tn(e);let d=_t(f),h=Go(r);return He(["0x04",ye([_(o),s?_(s):"0x",u?_(u):"0x",l?_(l):"0x",n?_(n):"0x",i??"0x",a?_(a):"0x",p??"0x",d,h,...Je(e,t)])])}function fa(e,t){let{chainId:r,gas:o,nonce:n,to:s,value:i,maxFeePerBlobGas:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:f,data:p}=e;En(e);let d=e.blobVersionedHashes,h=e.sidecars;if(e.blobs&&(typeof d>"u"||typeof h>"u")){let H=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(Y=>X(Y)),J=e.kzg,se=Xt({blobs:H,kzg:J});if(typeof d>"u"&&(d=on({commitments:se})),typeof h>"u"){let Y=Jt({blobs:H,commitments:se,kzg:J});h=sn({blobs:H,commitments:se,proofs:Y})}}let I=_t(f),k=[_(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??[],...Je(e,t)],P=[],q=[],V=[];if(h)for(let H=0;H<h.length;H++){let{blob:J,commitment:se,proof:Y}=h[H];P.push(J),q.push(se),V.push(Y)}return He(["0x03",h?ye([k,P,q,V]):ye(k)])}function ma(e,t){let{chainId:r,gas:o,nonce:n,to:s,value:i,maxFeePerGas:a,maxPriorityFeePerGas:l,accessList:u,data:f}=e;pr(e);let p=_t(u),d=[_(r),n?_(n):"0x",l?_(l):"0x",a?_(a):"0x",o?_(o):"0x",s??"0x",i?_(i):"0x",f??"0x",p,...Je(e,t)];return He(["0x02",ye(d)])}function da(e,t){let{chainId:r,gas:o,data:n,nonce:s,to:i,value:a,accessList:l,gasPrice:u}=e;Sn(e);let f=_t(l),p=[_(r),s?_(s):"0x",u?_(u):"0x",o?_(o):"0x",i??"0x",a?_(a):"0x",n??"0x",f,...Je(e,t)];return He(["0x01",ye(p)])}function ha(e,t){let{chainId:r=0,gas:o,data:n,nonce:s,to:i,value:a,gasPrice:l}=e;In(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 qt({v:t.v});return h})(),p=ft(t.r),d=ft(t.s);u=[...u,_(f),p==="0x00"?"0x":p,d==="0x00"?"0x":d]}else r>0&&(u=[...u,_(r),"0x","0x"]);return ye(u)}function Je(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=ft(r.r),i=ft(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 Bn={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};Ue();var Ln={block:Po({format(e){return{transactions:e.transactions?.map(r=>{if(typeof r=="string")return r;let o=ht(r);return o.typeHex==="0x7e"&&(o.isSystemTx=r.isSystemTx,o.mint=r.mint?Fe(r.mint):void 0,o.sourceHash=r.sourceHash,o.type="deposit"),o}),stateRoot:e.stateRoot}}}),transaction:Ao({format(e){let t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?Fe(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:Lo({format(e){return{l1GasPrice:e.l1GasPrice?Fe(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?Fe(e.l1GasUsed):null,l1Fee:e.l1Fee?Fe(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};ar();lr();Pr();re();function xa(e,t){return ga(e)?ba(e):Pn(e,t)}var $n={transaction:xa};function ba(e){ya(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?ie(i):"0x",l?ie(l):"0x",n?ie(n):"0x",s?"0x1":"0x",r??"0x"];return He(["0x7e",ye(u)])}function ga(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function ya(e){let{from:t,to:r}=e;if(t&&!fe(t))throw new oe({address:t});if(r&&!fe(r))throw new oe({address:r})}var qr={blockTime:2e3,contracts:Bn,formatters:Ln,serializers:$n};var ur=Re({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 Ct=1,kt=Re({...qr,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:{...qr.contracts,disputeGameFactory:{[Ct]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[Ct]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[Ct]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[Ct]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:Ct}),wa=Re({...kt,experimental_preconfirmationTime:200,rpcUrls:{default:{http:["https://mainnet-preconf.base.org"]}}});var fr=Re({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 Z}from"zod";import{z as m}from"zod";import{z as At}from"zod";import{z as ne}from"zod";import{z as w}from"zod";import{z as C}from"zod";import{z as D}from"zod";import pl from"crypto";import{z as he}from"zod";import{z as le}from"zod";import{z as Cs}from"zod";import{z as xe}from"zod";import{z as it}from"zod";import{z as De}from"zod";import{z as Wl}from"zod";import{z as Yl}from"zod";import{z as E}from"zod";import{z as de}from"zod";import{z as mp}from"zod";import{z as L}from"zod";import{z as g}from"zod";import{z as st}from"zod";import{z as ks}from"zod";import{z as G}from"zod";import{z as Os}from"zod";import{z as me}from"zod";import{z as R}from"zod";var kx=pt(Wr(),1);import{z as B}from"zod";var Jp=pt(Wr(),1),Zp=pt(Rn(),1),Yp=pt(vs(),1);import{z as nt}from"zod";var ac=z.object({detail:z.union([z.string(),z.array(z.object({msg:z.string(),type:z.string().optional(),ctx:z.record(z.unknown()).optional(),loc:z.array(z.union([z.string(),z.number()])).optional(),input:z.unknown().optional()}).passthrough()),z.record(z.unknown())]).optional(),type:z.string().optional(),code:z.string().optional()}),Me=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)}},oo=class xr extends Me{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=ac.safeParse(t.data);return r.success?new xr(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 xr(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 xr(t.message,{request:r??void 0,detail:t.message})}},cc=class extends Me{constructor(e,t){super(e,t),this.isValidationError=!0,this.validationErrors=t.validationErrors}},lc=class extends Me{constructor(){super(...arguments),this.isAuthError=!0}},Ss=class extends Me{constructor(){super(...arguments),this.isBusinessError=!0}},pc=class extends Me{constructor(){super(...arguments),this.isServerError=!0}},uc=class extends Me{constructor(){super(...arguments),this.isUnknownError=!0}};function fc(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 Is(e){if(!Array.isArray(e))return{errors:[],message:typeof e=="string"?e:"Validation error"};let t=e.map((n,s)=>{let i=fc(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 mc(e){return e===422?"validation":e===401||e===403?"auth":e>=400&&e<500?"business":e>=500?"server":"unknown"}function dc(e,t,r){if(e===422&&Array.isArray(t)){let{message:o}=Is(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 hc(e){let t=e.status??0,r=e.statusText??"Unknown Error",o=e.detail,n=bc(o);if(n)return new xc(n.message,{status:t,statusText:r,detail:o,errorCode:n.error_code,structuredDetails:n.details,suggestions:n.suggestions,links:n.links});let s=mc(t),i=dc(t,o,e.message),a={status:t,statusText:r,detail:o};if(s==="validation"&&Array.isArray(o)){let{errors:l}=Is(o);return new cc(i,{...a,validationErrors:l})}return s==="auth"?new lc(i,a):s==="business"?new Ss(i,a):s==="server"?new pc(i,a):new uc(i,a)}var xc=class extends Ss{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 bc(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 no=["2025-05-31","2025-10-28"],ot=(0,Es.default)("phala::api-client");function gc(e){return Object.entries(e).map(([t,r])=>` -H "${t}: ${r}"`).join(`
12
- `)}function yc(e){return e?` -d '${(typeof e=="string"?e:JSON.stringify(e,null,2)).replace(/'/g,"\\'")}'`:""}function _s(e,t,r,o){let n=[];r.forEach((a,l)=>{n.push(`${l}: ${a}`)});let s=n.join(`
11
+ `),{cause:t,name:"TipAboveFeeCapError"})}};Object.defineProperty(yt,"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 et,Gr=T(()=>{et=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 ia(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=ln(u,f,1)^r[a],d=pn(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=fn[i],l=ln(n,s,a),u=pn(n,s,a),f=un[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]^=na[o],e[1]^=sa[o]}Se(r)}var Qi,wt,ea,ta,ra,oa,un,fn,mn,dn,na,sa,ln,pn,vt,aa,hn,xn=T(()=>{Yo();er();Qi=BigInt(0),wt=BigInt(1),ea=BigInt(2),ta=BigInt(7),ra=BigInt(256),oa=BigInt(113),un=[],fn=[],mn=[];for(let e=0,t=wt,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],un.push(2*(5*o+r)),fn.push((e+1)*(e+2)/2%64);let n=Qi;for(let s=0;s<7;s++)t=(t<<wt^(t>>ta)*oa)%ra,t&ea&&(n^=wt<<(wt<<BigInt(s))-wt);mn.push(n)}dn=Ko(mn,!0),na=dn[0],sa=dn[1],ln=(e,t,r)=>r>32?Jo(e,t,r):Wo(e,t,r),pn=(e,t,r)=>r>32?Zo(e,t,r):Xo(e,t,r);vt=class extends Ze{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,Lr(o),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Do(this.state)}clone(){return this._cloneInto()}keccak(){$r(this.state32),ia(this.state32,this.rounds),$r(this.state32),this.posOut=0,this.pos=0}update(t){Ye(this),t=gt(t),Oe(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){Ye(this,!1),Oe(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 Lr(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Zt(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,Se(this.state)}_cloneInto(t){let{blockLen:r,suffix:o,outputLen:n,rounds:s,enableXOF:i}=this;return t||(t=new vt(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}},aa=(e,t,r)=>Qt(()=>new vt(t,e,r)),hn=(()=>aa(1,136,256/8))()});function bn(e,t){let r=t||"hex",o=hn(ue(e,{strict:!1})?Ot(e):e);return r==="bytes"?o:ie(o)}var gn=T(()=>{xn();We();Ee();re()});function yn(e,t){if(Dr.has(`${e}.${t}`))return Dr.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),o=bn(Ir(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 Dr.set(`${e}.${t}`,s),s}var Dr,wn=T(()=>{Ee();gn();Gr();Dr=new et(8192)});function fe(e,t){let{strict:r=!0}=t??{},o=`${e}.${r}`;if(Mr.has(o))return Mr.get(o);let n=(()=>ca.test(e)?e.toLowerCase()===e?!0:r?yn(e)===e:!0:!1)();return Mr.set(o,n),n}var ca,Mr,lr=T(()=>{Gr();wn();ca=/^0x[a-fA-F0-9]{40}$/,Mr=new et(8192)});function vn(e,t,r,{strict:o}={}){return ue(e,{strict:!1})?pa(e,t,r,{strict:o}):la(e,t,r,{strict:o})}function Cn(e,t){if(typeof t=="number"&&t>0&&t>te(e)-1)throw new mt({offset:t,position:"start",size:te(e)})}function _n(e,t,r){if(typeof t=="number"&&typeof r=="number"&&te(e)!==r-t)throw new mt({offset:r,position:"end",size:te(e)})}function la(e,t,r,{strict:o}={}){Cn(e,t);let n=e.slice(t,r);return o&&_n(n,t,r),n}function pa(e,t,r,{strict:o}={}){Cn(e,t);let n=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return o&&_n(n,t,r),n}var kn=T(()=>{Er();We();ut()});var Wr=K(Tt=>{"use strict";var va=Tt&&Tt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Tt,"__esModule",{value:!0});Tt.encryptEnvVars=ka;var Vr=be("@noble/curves/ed25519"),Kr=va(be("crypto"));function Ca(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 _a(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function ka(e,t){let r=JSON.stringify({env:e}),o=Vr.x25519.utils.randomPrivateKey(),n=Vr.x25519.getPublicKey(o),s=Ca(t),i=Vr.x25519.getSharedSecret(o,s),a=await Kr.default.subtle.importKey("raw",i,{name:"AES-GCM",length:256},!0,["encrypt"]),l=Kr.default.getRandomValues(new Uint8Array(12)),u=await Kr.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),_a(f)}});var Rn=K(Et=>{"use strict";var Ta=Et&&Et.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Et,"__esModule",{value:!0});Et.getComposeHash=Aa;var Ea=Ta(be("crypto"));function Xr(e){return e==null?e:Array.isArray(e)?e.map(Xr):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let o=e[r];return t[r]=Xr(o),t},{}):e}function Sa(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 Ia(e){let t=Xr(e);return JSON.stringify(t,(r,o)=>typeof o=="number"&&(isNaN(o)||!isFinite(o))?null:o)}function Aa(e,t=!1){t&&(e=Sa(e));let r=Ia(e);return Ea.default.createHash("sha256").update(r,"utf8").digest("hex")}});var rs=K(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=Xn;y.fromBig=Zr;y.split=Un;var mr=BigInt(2**32-1),Jr=BigInt(32);function Zr(e,t=!1){return t?{h:Number(e&mr),l:Number(e>>Jr&mr)}:{h:Number(e>>Jr&mr)|0,l:Number(e&mr)|0}}function Un(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}=Zr(e[s],t);[o[s],n[s]]=[i,a]}return[o,n]}var Fn=(e,t)=>BigInt(e>>>0)<<Jr|BigInt(t>>>0);y.toBig=Fn;var zn=(e,t,r)=>e>>>r;y.shrSH=zn;var Hn=(e,t,r)=>e<<32-r|t>>>r;y.shrSL=Hn;var On=(e,t,r)=>e>>>r|t<<32-r;y.rotrSH=On;var jn=(e,t,r)=>e<<32-r|t>>>r;y.rotrSL=jn;var Nn=(e,t,r)=>e<<64-r|t>>>r-32;y.rotrBH=Nn;var Gn=(e,t,r)=>e>>>r-32|t<<64-r;y.rotrBL=Gn;var Dn=(e,t)=>t;y.rotr32H=Dn;var Mn=(e,t)=>e;y.rotr32L=Mn;var qn=(e,t,r)=>e<<r|t>>>32-r;y.rotlSH=qn;var Vn=(e,t,r)=>t<<r|e>>>32-r;y.rotlSL=Vn;var Kn=(e,t,r)=>t<<r-32|e>>>64-r;y.rotlBH=Kn;var Wn=(e,t,r)=>e<<r-32|t>>>64-r;y.rotlBL=Wn;function Xn(e,t,r,o){let n=(t>>>0)+(o>>>0);return{h:e+r+(n/2**32|0)|0,l:n|0}}var Jn=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);y.add3L=Jn;var Zn=(e,t,r,o)=>t+r+o+(e/2**32|0)|0;y.add3H=Zn;var Yn=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0);y.add4L=Yn;var Qn=(e,t,r,o,n)=>t+r+o+n+(e/2**32|0)|0;y.add4H=Qn;var es=(e,t,r,o,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0);y.add5L=es;var ts=(e,t,r,o,n,s)=>t+r+o+n+s+(e/2**32|0)|0;y.add5H=ts;var Pa={fromBig:Zr,split:Un,toBig:Fn,shrSH:zn,shrSL:Hn,rotrSH:On,rotrSL:jn,rotrBH:Nn,rotrBL:Gn,rotr32H:Dn,rotr32L:Mn,rotlSH:qn,rotlSL:Vn,rotlBH:Kn,rotlBL:Wn,add:Xn,add3L:Jn,add3H:Zn,add4L:Yn,add4H:Qn,add5H:ts,add5L:es};y.default=Pa});var os=K(dr=>{"use strict";Object.defineProperty(dr,"__esModule",{value:!0});dr.crypto=void 0;var Ae=be("node:crypto");dr.crypto=Ae&&typeof Ae=="object"&&"webcrypto"in Ae?Ae.webcrypto:Ae&&typeof Ae=="object"&&"randomBytes"in Ae?Ae:void 0});var us=K(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=ss;x.anumber=Yr;x.abytes=rt;x.ahash=Ba;x.aexists=La;x.aoutput=$a;x.u8=Ra;x.u32=Ua;x.clean=Fa;x.createView=za;x.rotr=Ha;x.rotl=Oa;x.byteSwap=eo;x.byteSwap32=is;x.bytesToHex=Na;x.hexToBytes=Ga;x.asyncLoop=Ma;x.utf8ToBytes=to;x.bytesToUtf8=qa;x.toBytes=hr;x.kdfInputToBytes=Va;x.concatBytes=Ka;x.checkOpts=Wa;x.createHasher=cs;x.createOptHasher=ls;x.createXOFer=ps;x.randomBytes=Xa;var tt=os();function ss(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Yr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function rt(e,...t){if(!ss(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 Ba(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Yr(e.outputLen),Yr(e.blockLen)}function La(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 $a(e,t){rt(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Ra(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Ua(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Fa(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function za(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ha(e,t){return e<<32-t|e>>>t}function Oa(e,t){return e<<t|e>>>32-t>>>0}x.isLE=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function eo(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}x.swap8IfBE=x.isLE?e=>e:e=>eo(e);x.byteSwapIfBE=x.swap8IfBE;function is(e){for(let t=0;t<e.length;t++)e[t]=eo(e[t]);return e}x.swap32IfBE=x.isLE?e=>e:is;var as=(()=>typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function")(),ja=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Na(e){if(rt(e),as)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=ja[e[r]];return t}var ve={_0:48,_9:57,A:65,F:70,a:97,f:102};function ns(e){if(e>=ve._0&&e<=ve._9)return e-ve._0;if(e>=ve.A&&e<=ve.F)return e-(ve.A-10);if(e>=ve.a&&e<=ve.f)return e-(ve.a-10)}function Ga(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(as)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=ns(e.charCodeAt(s)),a=ns(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 Da=async()=>{};x.nextTick=Da;async function Ma(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 to(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function qa(e){return new TextDecoder().decode(e)}function hr(e){return typeof e=="string"&&(e=to(e)),rt(e),e}function Va(e){return typeof e=="string"&&(e=to(e)),rt(e),e}function Ka(...e){let t=0;for(let o=0;o<e.length;o++){let n=e[o];rt(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 Wa(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 Qr=class{};x.Hash=Qr;function cs(e){let t=o=>e().update(hr(o)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function ls(e){let t=(o,n)=>e(n).update(hr(o)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=o=>e(o),t}function ps(e){let t=(o,n)=>e(n).update(hr(o)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=o=>e(o),t}x.wrapConstructor=cs;x.wrapConstructorWithOpts=ls;x.wrapXOFConstructorWithOpts=ps;function Xa(e=32){if(tt.crypto&&typeof tt.crypto.getRandomValues=="function")return tt.crypto.getRandomValues(new Uint8Array(e));if(tt.crypto&&typeof tt.crypto.randomBytes=="function")return Uint8Array.from(tt.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}});var ws=K(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=gs;var It=rs(),N=us(),Ja=BigInt(0),St=BigInt(1),Za=BigInt(2),Ya=BigInt(7),Qa=BigInt(256),ec=BigInt(113),ds=[],hs=[],xs=[];for(let e=0,t=St,r=1,o=0;e<24;e++){[r,o]=[o,(2*r+3*o)%5],ds.push(2*(5*o+r)),hs.push((e+1)*(e+2)/2%64);let n=Ja;for(let s=0;s<7;s++)t=(t<<St^(t>>Ya)*ec)%Qa,t&Za&&(n^=St<<(St<<BigInt(s))-St);xs.push(n)}var bs=(0,It.split)(xs,!0),tc=bs[0],rc=bs[1],fs=(e,t,r)=>r>32?(0,It.rotlBH)(e,t,r):(0,It.rotlSH)(e,t,r),ms=(e,t,r)=>r>32?(0,It.rotlBL)(e,t,r):(0,It.rotlSL)(e,t,r);function gs(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=fs(u,f,1)^r[a],d=ms(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=hs[i],l=fs(n,s,a),u=ms(n,s,a),f=ds[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]^=tc[o],e[1]^=rc[o]}(0,N.clean)(r)}var Ge=class extends N.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,N.anumber)(o),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=(0,N.u32)(this.state)}clone(){return this._cloneInto()}keccak(){(0,N.swap32IfBE)(this.state32),gs(this.state32,this.rounds),(0,N.swap32IfBE)(this.state32),this.posOut=0,this.pos=0}update(t){(0,N.aexists)(this),t=(0,N.toBytes)(t),(0,N.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,N.aexists)(this,!1),(0,N.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,N.anumber)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,N.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,N.clean)(this.state)}_cloneInto(t){let{blockLen:r,suffix:o,outputLen:n,rounds:s,enableXOF:i}=this;return t||(t=new Ge(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=Ge;var Pe=(e,t,r)=>(0,N.createHasher)(()=>new Ge(t,e,r));A.sha3_224=(()=>Pe(6,144,224/8))();A.sha3_256=(()=>Pe(6,136,256/8))();A.sha3_384=(()=>Pe(6,104,384/8))();A.sha3_512=(()=>Pe(6,72,512/8))();A.keccak_224=(()=>Pe(1,144,224/8))();A.keccak_256=(()=>Pe(1,136,256/8))();A.keccak_384=(()=>Pe(1,104,384/8))();A.keccak_512=(()=>Pe(1,72,512/8))();var ys=(e,t,r)=>(0,N.createXOFer)((o={})=>new Ge(t,e,o.dkLen===void 0?r:o.dkLen,!0));A.shake128=(()=>ys(31,168,128/8))();A.shake256=(()=>ys(31,136,256/8))()});var vs=K(ro=>{"use strict";Object.defineProperty(ro,"__esModule",{value:!0});ro.verifyEnvEncryptPublicKey=sc;var oc=ws(),nc=be("@noble/curves/secp256k1");function sc(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,oc.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=nc.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 Es=pt(_o(),1);import{ofetch as ic}from"ofetch";function ko(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}from"zod";import{z as Be}from"zod";import{z as v}from"zod";import{z as Le}from"zod";function Re(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}jt();Ue();jt();var Ar={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function ht(e,t){let r={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?ze(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?ze(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Ar[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=Ui(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 Ao=Xe("transaction",ht);function Ui(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 Fi(e,t){let r=(e.transactions??[]).map(o=>typeof o=="string"?o:ht(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 Po=Xe("block",Fi);function Bo(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}:{}}}Ue();jt();var zi={"0x0":"reverted","0x1":"success"};function Hi(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=>Bo(o)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?ze(e.transactionIndex):null,status:e.status?zi[e.status]:null,type:e.type?Ar[e.type]||e.type:null};return e.blobGasPrice&&(r.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(r.blobGasUsed=BigInt(e.blobGasUsed)),r}var Lo=Xe("transactionReceipt",Hi);ee();Br();Ee();re();function ye(e,t="hex"){let r=Uo(e),o=Mt(new Uint8Array(r.length));return r.encode(o),t==="hex"?X(o.bytes):o.bytes}function Uo(e){return Array.isArray(e)?ji(e.map(t=>Uo(t))):Ni(e)}function ji(e){let t=e.reduce((n,s)=>n+s.length,0),r=Fo(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 Ni(e){let t=typeof e=="string"?ae(e):e,r=Fo(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 Fo(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.")}Wt();re();function Go(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?ie(o):"0x",i,n?ie(n):"0x",...Je({},s)])}return t}Ee();re();function Xt(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=>ae(s)):e.blobs,n=[];for(let s of o)n.push(Uint8Array.from(t.blobToKzgCommitment(s)));return r==="bytes"?n:n.map(s=>X(s))}Ee();re();function Jt(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=>ae(i)):e.blobs,n=typeof e.commitments[0]=="string"?e.commitments.map(i=>ae(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=>X(i))}re();er();function Wi(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 Mo(e,t,r){return e&t^~e&r}function qo(e,t,r){return e&t^e&r^t&r}var tr=class extends Ze{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=Yt(this.buffer)}update(t){Ye(this),t=gt(t),Oe(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=Yt(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){Ye(this),Zt(t,this),this.finished=!0;let{buffer:r,view:o,blockLen:n,isLE:s}=this,{pos:i}=this;r[i++]=128,Se(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let p=i;p<n;p++)r[p]=0;Wi(o,n-8,BigInt(this.length*8),s),this.process(o,0);let a=Yt(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()}},we=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);er();var Ji=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]),Ie=new Uint32Array(64),or=class extends tr{constructor(t=32){super(64,t,8,!1),this.A=we[0]|0,this.B=we[1]|0,this.C=we[2]|0,this.D=we[3]|0,this.E=we[4]|0,this.F=we[5]|0,this.G=we[6]|0,this.H=we[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)Ie[p]=t.getUint32(r,!1);for(let p=16;p<64;p++){let d=Ie[p-15],h=Ie[p-2],I=ce(d,7)^ce(d,18)^d>>>3,k=ce(h,17)^ce(h,19)^h>>>10;Ie[p]=k+Ie[p-7]+I+Ie[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=ce(a,6)^ce(a,11)^ce(a,25),h=f+d+Mo(a,l,u)+Ji[p]+Ie[p]|0,k=(ce(o,2)^ce(o,13)^ce(o,22))+qo(o,n,s)|0;f=u,u=l,l=a,a=i+h|0,i=s,s=n,n=o,o=h+k|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(){Se(Ie)}destroy(){this.set(0,0,0,0,0,0,0,0),Se(this.buffer)}};var Qo=Qt(()=>new or);var en=Qo;We();Ee();re();function tn(e,t){let r=t||"hex",o=en(ue(e,{strict:!1})?Ot(e):e);return r==="bytes"?o:ie(o)}function rn(e){let{commitment:t,version:r=1}=e,o=e.to??(typeof t=="string"?"hex":"bytes"),n=tn(t,"bytes");return n.set([r],0),o==="bytes"?n:X(n)}function on(e){let{commitments:t,version:r}=e,o=e.to??(typeof t[0]=="string"?"hex":"bytes"),n=[];for(let s of t)n.push(rn({commitment:s,to:o,version:r}));return n}ee();var nr=class extends b{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}},Qe=class extends b{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}},sr=class extends b{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}},ir=class extends b{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${1}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}};Br();ut();Ee();re();function nn(e){let t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?ae(e.data):e.data,o=te(r);if(!o)throw new Qe;if(o>761855)throw new nr({maxSize:761855,size:o});let n=[],s=!0,i=0;for(;s;){let a=Mt(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=>X(a.bytes))}function sn(e){let{data:t,kzg:r,to:o}=e,n=e.blobs??nn({data:t,to:o}),s=e.commitments??Xt({blobs:n,kzg:r,to:o}),i=e.proofs??Jt({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}Pr();So();re();$o();ar();ee();an();cn();lr();ut();kn();Ue();function Tn(e){let{authorizationList:t}=e;if(t)for(let r of t){let{chainId:o}=r,n=r.address;if(!fe(n))throw new oe({address:n});if(o<0)throw new je({chainId:o})}pr(e)}function En(e){let{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new Qe;for(let r of t){let o=te(r),n=ze(vn(r,0,1));if(o!==32)throw new sr({hash:r,size:o});if(n!==1)throw new ir({hash:r,version:n})}}pr(e)}function pr(e){let{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:o,to:n}=e;if(t<=0)throw new je({chainId:t});if(n&&!fe(n))throw new oe({address:n});if(o&&o>Nt)throw new Ne({maxFeePerGas:o});if(r&&o&&r>o)throw new yt({maxFeePerGas:o,maxPriorityFeePerGas:r})}function Sn(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:o,maxFeePerGas:n,to:s}=e;if(t<=0)throw new je({chainId:t});if(s&&!fe(s))throw new oe({address:s});if(r||n)throw new b("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(o&&o>Nt)throw new Ne({maxFeePerGas:o})}function In(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:o,maxFeePerGas:n,to:s}=e;if(s&&!fe(s))throw new oe({address:s});if(typeof t<"u"&&t<=0)throw new je({chainId:t});if(r||n)throw new b("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(o&&o>Nt)throw new Ne({maxFeePerGas:o})}Wt();function An(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 Vt({transaction:e})}ar();Wt();lr();function Ct(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 Kt({storageKey:n[s]});if(!fe(o,{strict:!1}))throw new oe({address:o});t.push([o,n])}return t}function Pn(e,t){let r=An(e);return r==="eip1559"?ma(e,t):r==="eip2930"?da(e,t):r==="eip4844"?fa(e,t):r==="eip7702"?ua(e,t):ha(e,t)}function ua(e,t){let{authorizationList:r,chainId:o,gas:n,nonce:s,to:i,value:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:f,data:p}=e;Tn(e);let d=Ct(f),h=Go(r);return He(["0x04",ye([C(o),s?C(s):"0x",u?C(u):"0x",l?C(l):"0x",n?C(n):"0x",i??"0x",a?C(a):"0x",p??"0x",d,h,...Je(e,t)])])}function fa(e,t){let{chainId:r,gas:o,nonce:n,to:s,value:i,maxFeePerBlobGas:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:f,data:p}=e;En(e);let d=e.blobVersionedHashes,h=e.sidecars;if(e.blobs&&(typeof d>"u"||typeof h>"u")){let H=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(Y=>X(Y)),J=e.kzg,se=Xt({blobs:H,kzg:J});if(typeof d>"u"&&(d=on({commitments:se})),typeof h>"u"){let Y=Jt({blobs:H,commitments:se,kzg:J});h=sn({blobs:H,commitments:se,proofs:Y})}}let I=Ct(f),k=[C(r),n?C(n):"0x",u?C(u):"0x",l?C(l):"0x",o?C(o):"0x",s??"0x",i?C(i):"0x",p??"0x",I,a?C(a):"0x",d??[],...Je(e,t)],P=[],q=[],V=[];if(h)for(let H=0;H<h.length;H++){let{blob:J,commitment:se,proof:Y}=h[H];P.push(J),q.push(se),V.push(Y)}return He(["0x03",h?ye([k,P,q,V]):ye(k)])}function ma(e,t){let{chainId:r,gas:o,nonce:n,to:s,value:i,maxFeePerGas:a,maxPriorityFeePerGas:l,accessList:u,data:f}=e;pr(e);let p=Ct(u),d=[C(r),n?C(n):"0x",l?C(l):"0x",a?C(a):"0x",o?C(o):"0x",s??"0x",i?C(i):"0x",f??"0x",p,...Je(e,t)];return He(["0x02",ye(d)])}function da(e,t){let{chainId:r,gas:o,data:n,nonce:s,to:i,value:a,accessList:l,gasPrice:u}=e;Sn(e);let f=Ct(l),p=[C(r),s?C(s):"0x",u?C(u):"0x",o?C(o):"0x",i??"0x",a?C(a):"0x",n??"0x",f,...Je(e,t)];return He(["0x01",ye(p)])}function ha(e,t){let{chainId:r=0,gas:o,data:n,nonce:s,to:i,value:a,gasPrice:l}=e;In(e);let u=[s?C(s):"0x",l?C(l):"0x",o?C(o):"0x",i??"0x",a?C(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 qt({v:t.v});return h})(),p=ft(t.r),d=ft(t.s);u=[...u,C(f),p==="0x00"?"0x":p,d==="0x00"?"0x":d]}else r>0&&(u=[...u,C(r),"0x","0x"]);return ye(u)}function Je(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=ft(r.r),i=ft(r.s);return[(()=>typeof n=="number"?n?C(1):"0x":o===0n?"0x":o===1n?C(1):o===27n?"0x":C(1))(),s==="0x00"?"0x":s,i==="0x00"?"0x":i]}var Bn={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};Ue();var Ln={block:Po({format(e){return{transactions:e.transactions?.map(r=>{if(typeof r=="string")return r;let o=ht(r);return o.typeHex==="0x7e"&&(o.isSystemTx=r.isSystemTx,o.mint=r.mint?Fe(r.mint):void 0,o.sourceHash=r.sourceHash,o.type="deposit"),o}),stateRoot:e.stateRoot}}}),transaction:Ao({format(e){let t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?Fe(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:Lo({format(e){return{l1GasPrice:e.l1GasPrice?Fe(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?Fe(e.l1GasUsed):null,l1Fee:e.l1Fee?Fe(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};ar();lr();Pr();re();function xa(e,t){return ga(e)?ba(e):Pn(e,t)}var $n={transaction:xa};function ba(e){ya(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?ie(i):"0x",l?ie(l):"0x",n?ie(n):"0x",s?"0x1":"0x",r??"0x"];return He(["0x7e",ye(u)])}function ga(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function ya(e){let{from:t,to:r}=e;if(t&&!fe(t))throw new oe({address:t});if(r&&!fe(r))throw new oe({address:r})}var qr={blockTime:2e3,contracts:Bn,formatters:Ln,serializers:$n};var ur=Re({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 _t=1,kt=Re({...qr,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:{...qr.contracts,disputeGameFactory:{[_t]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[_t]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[_t]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[_t]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:_t}),wa=Re({...kt,experimental_preconfirmationTime:200,rpcUrls:{default:{http:["https://mainnet-preconf.base.org"]}}});var fr=Re({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 Z}from"zod";import{z as m}from"zod";import{z as At}from"zod";import{z as ne}from"zod";import{z as w}from"zod";import{z as _}from"zod";import{z as D}from"zod";import pl from"crypto";import{z as he}from"zod";import{z as le}from"zod";import{z as _s}from"zod";import{z as xe}from"zod";import{z as it}from"zod";import{z as De}from"zod";import{z as Wl}from"zod";import{z as Yl}from"zod";import{z as E}from"zod";import{z as de}from"zod";import{z as mp}from"zod";import{z as L}from"zod";import{z as g}from"zod";import{z as st}from"zod";import{z as ks}from"zod";import{z as G}from"zod";import{z as Os}from"zod";import{z as me}from"zod";import{z as R}from"zod";var kx=pt(Wr(),1);import{z as B}from"zod";var Jp=pt(Wr(),1),Zp=pt(Rn(),1),Yp=pt(vs(),1);import{z as nt}from"zod";var ac=z.object({detail:z.union([z.string(),z.array(z.object({msg:z.string(),type:z.string().optional(),ctx:z.record(z.unknown()).optional(),loc:z.array(z.union([z.string(),z.number()])).optional(),input:z.unknown().optional()}).passthrough()),z.record(z.unknown())]).optional(),type:z.string().optional(),code:z.string().optional()}),Me=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)}},oo=class xr extends Me{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=ac.safeParse(t.data);return r.success?new xr(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 xr(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 xr(t.message,{request:r??void 0,detail:t.message})}},cc=class extends Me{constructor(e,t){super(e,t),this.isValidationError=!0,this.validationErrors=t.validationErrors}},lc=class extends Me{constructor(){super(...arguments),this.isAuthError=!0}},Ss=class extends Me{constructor(){super(...arguments),this.isBusinessError=!0}},pc=class extends Me{constructor(){super(...arguments),this.isServerError=!0}},uc=class extends Me{constructor(){super(...arguments),this.isUnknownError=!0}};function fc(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 Is(e){if(!Array.isArray(e))return{errors:[],message:typeof e=="string"?e:"Validation error"};let t=e.map((n,s)=>{let i=fc(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 mc(e){return e===422?"validation":e===401||e===403?"auth":e>=400&&e<500?"business":e>=500?"server":"unknown"}function dc(e,t,r){if(e===422&&Array.isArray(t)){let{message:o}=Is(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 hc(e){let t=e.status??0,r=e.statusText??"Unknown Error",o=e.detail,n=bc(o);if(n)return new xc(n.message,{status:t,statusText:r,detail:o,errorCode:n.error_code,structuredDetails:n.details,suggestions:n.suggestions,links:n.links});let s=mc(t),i=dc(t,o,e.message),a={status:t,statusText:r,detail:o};if(s==="validation"&&Array.isArray(o)){let{errors:l}=Is(o);return new cc(i,{...a,validationErrors:l})}return s==="auth"?new lc(i,a):s==="business"?new Ss(i,a):s==="server"?new pc(i,a):new uc(i,a)}var xc=class extends Ss{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 bc(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 no=["2025-05-31","2025-10-28"],ot=(0,Es.default)("phala::api-client");function gc(e){return Object.entries(e).map(([t,r])=>` -H "${t}: ${r}"`).join(`
12
+ `)}function yc(e){return e?` -d '${(typeof e=="string"?e:JSON.stringify(e,null,2)).replace(/'/g,"\\'")}'`:""}function Cs(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
15
  `)}var wc=class{constructor(e={}){this.emitter=ko();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&&no.includes(t.version)?t.version:no[no.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=ic.create({baseURL:n,timeout:s||3e4,headers:f,...a?{credentials:"include"}:{},...u,onRequest({request:p,options:d}){if(ot.enabled){let h=d.method||"GET",I=typeof p=="string"?p:p.url,k=I.startsWith("http")?I:`${n}${I}`,P={};d.headers&&typeof d.headers=="object"&&Object.entries(d.headers).forEach(([V,H])=>{typeof H=="string"&&(P[V]=H)});let q=[`> curl -X ${h} "${k}"`,gc(P),d.body?yc(d.body):""].filter(Boolean).join(`
@@ -19,11 +19,11 @@ var Ys=Object.create;var po=Object.defineProperty;var Qs=Object.getOwnPropertyDe
19
19
  `,q)}},onResponse({request:p,response:d,options:h}){if(ot.enabled){let I=h.method||"GET",k=typeof p=="string"?p:p.url;ot(`
20
20
  === RESPONSE [%s %s] (%dms) ===
21
21
  %s
22
- `,I,k,d.headers.get("x-response-time")||"?",_s(d.status,d.statusText,d.headers,d._data))}},onResponseError:({request:p,response:d,options:h})=>{if(console.warn(`HTTP ${d.status}: ${d.url}`),ot.enabled){let I=h.method||"GET",k=typeof p=="string"?p:p.url;ot(`
22
+ `,I,k,d.headers.get("x-response-time")||"?",Cs(d.status,d.statusText,d.headers,d._data))}},onResponseError:({request:p,response:d,options:h})=>{if(console.warn(`HTTP ${d.status}: ${d.url}`),ot.enabled){let I=h.method||"GET",k=typeof p=="string"?p:p.url;ot(`
23
23
  === ERROR RESPONSE [%s %s] ===
24
24
  %s
25
- `,I,k,_s(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?oo.fromFetchError(e):e instanceof Error?oo.fromError(e):new oo("Unknown error occurred",{detail:"Unknown error occurred"})}emitError(e){let t=hc(e);return this.emitter.emit("error",t),t}async safeRequest(e){try{return{success:!0,data:await e()}}catch(t){if(t instanceof Me)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 vc(e={}){return new wc(e)}function As(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 Ps(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 Bs(e,t){function r(i,a){return o(i,a)}async function o(i,a){As(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=Ps(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 S(e,t){function r(i,...a){let[l,u]=a;return o(i,l,u)}async function o(i,a,l){As(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=Ps(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 _c=Be.object({username:Be.string(),email:Be.string(),credits:Be.number(),granted_credits:Be.number(),avatar:Be.string(),team_name:Be.string(),team_tier:Be.string()}).passthrough(),{action:Cc,safeAction:kc}=Bs(_c,async e=>await e.get("/auth/me")),Tc={[fr.id]:fr,[kt.id]:kt,[ur.id]:ur},Ec=Le.object({id:Le.string(),slug:Le.string().nullable(),url:Le.string(),version:Le.string(),chain_id:Le.number().nullable(),kms_contract_address:Le.string().nullable().transform(e=>e),gateway_app_id:Le.string().nullable().transform(e=>e)}).passthrough(),at=Ec.transform(e=>{if(e.chain_id!=null){let t=Tc[e.chain_id];if(t)return{...e,chain:t}}return e}),Sc=v.object({name:v.string(),is_dev:v.boolean(),version:v.union([v.tuple([v.number(),v.number(),v.number()]),v.tuple([v.number(),v.number(),v.number(),v.number()])]),os_image_hash:v.string().nullable().optional()}).passthrough(),Ic=v.object({teepod_id:v.number(),name:v.string(),listed:v.boolean(),resource_score:v.number(),remaining_vcpu:v.number(),remaining_memory:v.number(),remaining_cvm_slots:v.number(),images:v.array(Sc),support_onchain_kms:v.boolean().optional(),fmspc:v.string().nullable().optional(),device_id:v.string().nullable().optional(),region_identifier:v.string().nullable().optional(),default_kms:v.string().nullable().optional(),kms_list:v.array(v.string()).default([])}).passthrough(),Ac=v.object({max_instances:v.number().nullable().optional(),max_vcpu:v.number().nullable().optional(),max_memory:v.number().nullable().optional(),max_disk:v.number().nullable().optional()}).passthrough(),Pc=v.object({tier:v.string(),capacity:Ac,nodes:v.array(Ic),kms_list:v.array(at)}).passthrough(),{action:Bc,safeAction:Lc}=Bs(Pc,async e=>await e.get("/teepods/available")),Ls=$.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(),$c=$.object({name:$.string(),items:$.array(Ls),total:$.number()}).strict(),Rc=$.object({result:$.array($c)}).strict(),Uc=$.object({items:$.array(Ls),total:$.number(),family:$.string()}).strict(),Fc=$.object({family:$.string()}).strict(),{action:zc,safeAction:Hc}=S(Rc,async e=>await e.get("/instance-types")),{action:Oc,safeAction:jc}=S(Uc,async(e,t)=>{let r=Fc.parse(t);return await e.get(`/instance-types/${r.family}`)}),$s=Z.object({id:Z.string(),name:Z.string(),slug:Z.string().nullable(),tier:Z.string(),role:Z.string(),created_at:Z.string()}).passthrough(),Nc=Z.object({has_more:Z.boolean(),next_cursor:Z.string().nullable(),total:Z.number().nullable()}).passthrough(),Gc=Z.object({data:Z.array($s),pagination:Nc}).passthrough(),{action:Dc,safeAction:Mc}=S(Gc,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:qc,safeAction:Vc}=S($s,async(e,t)=>await e.get(`/workspaces/${t}`)),Kc=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()}),Wc=m.object({id:m.number(),username:m.string()}),io=m.object({id:m.number(),name:m.string(),region_identifier:m.string().nullable().optional()}),Rs=m.object({app:m.string(),instance:m.string()}),Xc=m.object({hosted:Kc,name:m.string(),managed_user:Wc.nullable(),node:io.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:at.nullable(),vcpu:m.number().nullable(),memory:m.number().nullable(),disk_size:m.number().nullable(),gateway_domain:m.string().nullable(),public_urls:m.array(Rs)}),Us=m.object({id:m.number(),name:m.string(),status:m.string(),in_progress:m.boolean().optional().default(!1),teepod_id:m.number().nullable(),teepod:io.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:at.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(Rs).optional().default([]),gateway_domain:m.string().optional().nullable()}),br=m.object({id:m.number(),name:m.string(),status:m.string(),teepod_id:m.number(),teepod:io.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()}),Pt=At.object({id:At.string().optional(),uuid:At.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:At.string().optional(),instance_id:At.string().optional()}),Bt=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"}),Jc=Bt(Pt),O=Jc.transform(e=>{let t;if(e.id)t=e.id;else if(e.uuid)t=e.uuid.replace(/-/g,"");else if(e.app_id)t=e.app_id.startsWith("app_")?e.app_id:`app_${e.app_id}`;else if(e.instance_id)t=e.instance_id.startsWith("instance_")?e.instance_id:`instance_${e.instance_id}`;else throw new Error("No valid identifier provided");return{cvmId:t}}),Zc=O,{action:Yc,safeAction:ct}=S(Us,async(e,t)=>{let{cvmId:r}=Zc.parse(t);return await e.get(`/cvms/${r}`)}),Qc=ne.object({page:ne.number().int().min(1).optional(),page_size:ne.number().int().min(1).optional(),node_id:ne.number().int().min(1).optional(),teepod_id:ne.number().int().min(1).optional(),user_id:ne.string().optional()}).strict(),el=ne.object({items:ne.array(Xc),total:ne.number(),page:ne.number(),page_size:ne.number(),pages:ne.number()}).strict(),{action:tl,safeAction:gr}=S(el,async(e,t)=>{let r=Qc.parse(t??{});return await e.get("/cvms/paginated",{params:r})}),rl=w.object({app_id:w.string().nullable().optional(),app_env_encrypt_pubkey:w.string().nullable().optional(),compose_hash:w.string(),fmspc:w.string().nullable().optional(),device_id:w.string().nullable().optional(),os_image_hash:w.string().nullable().optional(),instance_type:w.string().nullable().optional(),teepod_id:w.number().nullable().optional(),node_id:w.number().nullable().optional(),kms_id:w.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}),ol=w.object({node_id:w.number().optional(),teepod_id:w.number().optional(),region:w.string().optional(),name:w.string(),instance_type:w.string().default("tdx.small"),image:w.string().optional(),vcpu:w.number().optional(),memory:w.number().optional(),disk_size:w.number().optional(),compose_file:w.object({allowed_envs:w.array(w.string()).optional(),pre_launch_script:w.string().optional(),docker_compose_file:w.string().optional(),name:w.string().optional().default(""),kms_enabled:w.boolean().optional(),public_logs:w.boolean().optional(),public_sysinfo:w.boolean().optional(),gateway_enabled:w.boolean().optional(),tproxy_enabled:w.boolean().optional()}),listed:w.boolean().optional(),kms_id:w.string().optional(),kms:w.enum(["PHALA","ETHEREUM","BASE"]).optional(),kms_contract:w.string().optional(),env_keys:w.array(w.string()).optional(),nonce:w.number().optional(),app_id:w.string().optional()}).passthrough();function nl(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:sl,safeAction:il}=S(rl,async(e,t)=>{let r=ol.parse(t),o=nl(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)}),al=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(),rx=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:cl,safeAction:ll}=S(al,async(e,t)=>await e.post("/cvms",t)),Fs=D.object({allowed_envs:D.array(D.string()).optional(),docker_compose_file:D.string(),features:D.array(D.string()).optional(),name:D.string().optional(),manifest_version:D.number().optional(),kms_enabled:D.boolean().optional(),public_logs:D.boolean().optional(),public_sysinfo:D.boolean().optional(),tproxy_enabled:D.boolean().optional(),pre_launch_script:D.string().optional(),env_pubkey:D.string().optional(),salt:D.string().optional().nullable()}).passthrough();function so(e){return e==null?e:Array.isArray(e)?e.map(so):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let o=e[r];return t[r]=so(o),t},{}):e}function zs(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 Hs(e){let t=so(e),r=JSON.stringify(t,null,4);return r=r.replace(/": /g,'":'),r}function ul(e){let t=zs(e),r=Hs(t);return pl.createHash("sha256").update(r,"utf8").digest("hex")}function fl(e){let t=e;return{...e,getHash:()=>ul(t),toString:()=>Hs(zs(t))}}var ml=Fs.transform(e=>fl(e)),dl=O,{action:hl,safeAction:ao}=S(ml,async(e,t)=>{let{cvmId:r}=dl.parse(t);return await e.get(`/cvms/${r}/compose_file`)}),xl=he.object({id:he.string().optional(),uuid:he.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:he.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:he.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:Fs,update_env_vars:he.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})),bl=he.object({app_id:he.string().nullable(),device_id:he.string().nullable(),compose_hash:he.string(),kms_info:at.nullable().optional()}).passthrough(),{action:gl,safeAction:yl}=S(bl,async(e,t)=>{let r=xl.parse(t);return await e.post(`/cvms/${r.cvmId}/compose_file/provision`,r.request)}),wl=le.object({id:le.string().optional(),uuid:le.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:le.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:le.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:le.string().min(1,"Compose hash is required"),encrypted_env:le.string().optional(),env_keys:le.array(le.string()).optional(),update_env_vars:le.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})),vl=le.any().transform(()=>{}),{action:_l,safeAction:Cl}=S(vl,async(e,t)=>{let r=wl.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})}),kl=Cs.object({kms_id:Cs.string().min(1,"KMS ID is required")}),{action:Tl,safeAction:El}=S(at,async(e,t)=>{let r=kl.parse(t);return await e.get(`/kms/${r.kms_id}`)}),Sl=xe.object({page:xe.number().int().min(1).optional(),page_size:xe.number().int().min(1).optional(),is_onchain:xe.boolean().optional()}).strict(),Il=xe.object({items:xe.array(at),total:xe.number(),page:xe.number(),page_size:xe.number(),pages:xe.number()}).strict(),{action:Al,safeAction:Pl}=S(Il,async(e,t)=>{let r=Sl.parse(t??{});return await e.get("/kms",{params:r})}),Bl=it.object({kms:it.string().min(1,"KMS ID or slug is required"),app_id:it.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(),Ll=it.object({public_key:it.string(),signature:it.string()}).strict(),{action:$l,safeAction:Rl}=S(Ll,async(e,t)=>{let r=Bl.parse(t);return await e.get(`/kms/${r.kms}/pubkey/${r.app_id}`)}),Ul=De.object({counts:De.number().int().min(1).max(20).optional().default(1)}).strict(),Fl=De.object({app_ids:De.array(De.object({app_id:De.string(),nonce:De.number().int().min(0)}))}).strict(),{action:zl,safeAction:Hl}=S(Fl,async(e,t)=>{let r=Ul.parse(t??{}),o=new URLSearchParams;return o.append("counts",r.counts.toString()),await e.get(`/kms/phala/next_app_id?${o.toString()}`)}),Ol=O,{action:jl,safeAction:Nl}=S(br,async(e,t)=>{let{cvmId:r}=Ol.parse(t);return await e.post(`/cvms/${r}/start`)}),Gl=O,{action:Dl,safeAction:Ml}=S(br,async(e,t)=>{let{cvmId:r}=Gl.parse(t);return await e.post(`/cvms/${r}/stop`)}),ql=O,{action:Vl,safeAction:Kl}=S(br,async(e,t)=>{let{cvmId:r}=ql.parse(t);return await e.post(`/cvms/${r}/shutdown`)}),Xl=Bt(Pt.extend({force:Wl.boolean().optional()})),{action:Jl,safeAction:Zl}=S(br,async(e,t)=>{let r=Xl.parse(t),{cvmId:o}=O.parse(r),{force:n=!1}=r;return await e.post(`/cvms/${o}/restart`,{force:n})}),Ql=O,{action:ep,safeAction:tp}=S(Yl.void(),async(e,t)=>{let{cvmId:r}=Ql.parse(t);await e.delete(`/cvms/${r}`)}),rp=E.object({name:E.string(),mount_point:E.string(),total_size:E.number(),free_size:E.number()}),op=E.object({os_name:E.string(),os_version:E.string(),kernel_version:E.string(),cpu_model:E.string(),num_cpus:E.number(),total_memory:E.number(),available_memory:E.number(),used_memory:E.number(),free_memory:E.number(),total_swap:E.number(),used_swap:E.number(),free_swap:E.number(),uptime:E.number(),loadavg_one:E.number(),loadavg_five:E.number(),loadavg_fifteen:E.number(),disks:E.array(rp)}),np=E.object({is_online:E.boolean(),is_public:E.boolean().default(!1),error:E.string().nullable(),sysinfo:op.nullable(),status:E.string().nullable(),in_progress:E.boolean().default(!1),boot_progress:E.string().nullable(),boot_error:E.string().nullable()}),sp=O,{action:ip,safeAction:ap}=S(np,async(e,t)=>{let{cvmId:r}=sp.parse(t);return await e.get(`/cvms/${r}/stats`)}),cp=de.object({app:de.string(),instance:de.string()}),lp=de.object({is_online:de.boolean(),is_public:de.boolean().default(!0),error:de.string().nullable(),internal_ip:de.string().nullable(),latest_handshake:de.string().nullable(),public_urls:de.array(cp).nullable()}),pp=O,{action:up,safeAction:fp}=S(lp,async(e,t)=>{let{cvmId:r}=pp.parse(t);return await e.get(`/cvms/${r}/network`)}),dp=O,{action:hp,safeAction:xp}=S(mp.string(),async(e,t)=>{let{cvmId:r}=dp.parse(t);return await e.get(`/cvms/${r}/docker-compose.yml`)}),bp=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()}),gp=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(bp).nullable()}),yp=O,{action:wp,safeAction:vp}=S(gp,async(e,t)=>{let{cvmId:r}=yp.parse(t);return await e.get(`/cvms/${r}/composition`)}),_p=g.object({common_name:g.string().nullable(),organization:g.string().nullable(),country:g.string().nullable(),state:g.string().nullable(),locality:g.string().nullable()}),Cp=g.object({common_name:g.string().nullable(),organization:g.string().nullable(),country:g.string().nullable()}),kp=g.object({subject:_p,issuer:Cp,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()}),Tp=g.object({imr:g.number(),event_type:g.number(),digest:g.string(),event:g.string(),event_payload:g.string()}),Ep=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(Tp),app_compose:g.string()}),Sp=g.object({name:g.string().nullable(),is_online:g.boolean(),is_public:g.boolean().default(!0),error:g.string().nullable(),app_certificates:g.array(kp).nullable(),tcb_info:Ep.nullable(),compose_file:g.string().nullable()}),Ip=O,{action:Ap,safeAction:Pp}=S(Sp,async(e,t)=>{let{cvmId:r}=Ip.parse(t);return await e.get(`/cvms/${r}/attestation`)}),Bp=Bt(Pt.extend({vcpu:st.number().optional(),memory:st.number().optional(),disk_size:st.number().optional(),instance_type:st.string().optional(),allow_restart:st.boolean().optional()})),{action:Lp,safeAction:$p}=S(st.void(),async(e,t)=>{let r=Bp.parse(t),{cvmId:o}=O.parse(r),{...n}=r;await e.patch(`/cvms/${o}/resources`,n)}),Rp=Bt(Pt.extend({public_sysinfo:ks.boolean(),public_logs:ks.boolean()})),{action:Up,safeAction:Fp}=S(Us,async(e,t)=>{let r=Rp.parse(t),{cvmId:o}=O.parse(r),{public_sysinfo:n,public_logs:s}=r;return await e.patch(`/cvms/${o}/visibility`,{public_sysinfo:n,public_logs:s})}),Ts=G.object({name:G.string(),os_image_hash:G.string().nullable(),is_current:G.boolean()}),zp=G.object({version:G.union([G.tuple([G.number(),G.number(),G.number(),G.number()]),G.tuple([G.number(),G.number(),G.number()])]),prod:Ts.nullable(),dev:Ts.nullable()}),Hp=G.array(zp),Op=O,{action:jp,safeAction:Np}=S(Hp,async(e,t)=>{let{cvmId:r}=Op.parse(t);return await e.get(`/cvms/${r}/available-os-images`)}),Gp=Bt(Pt.extend({os_image_name:Os.string().min(1,"OS image name is required")})),{action:Dp,safeAction:Mp}=S(Os.void(),async(e,t)=>{let r=Gp.parse(t),{cvmId:o}=O.parse(r),{os_image_name:n}=r;await e.patch(`/cvms/${o}/os-image`,{os_image_name:n})}),qp=me.object({id:me.string().optional(),instance_id:me.string().optional(),name:me.string(),status:me.string(),uptime:me.string().optional(),exited_at:me.string().optional(),boot_progress:me.string().optional(),boot_error:me.string().optional(),shutdown_progress:me.string().optional()}),Vp=O,{action:Kp,safeAction:Wp}=S(qp,async(e,t)=>{let{cvmId:r}=Vp.parse(t);return await e.get(`/cvms/${r}/state`)});function js(e={}){let t=vc(e),r={getCurrentUser:Cc,safeGetCurrentUser:kc,getAvailableNodes:Bc,safeGetAvailableNodes:Lc,listAllInstanceTypeFamilies:zc,safeListAllInstanceTypeFamilies:Hc,listFamilyInstanceTypes:Oc,safeListFamilyInstanceTypes:jc,listWorkspaces:Dc,safeListWorkspaces:Mc,getWorkspace:qc,safeGetWorkspace:Vc,getCvmInfo:Yc,safeGetCvmInfo:ct,getCvmList:tl,safeGetCvmList:gr,provisionCvm:sl,safeProvisionCvm:il,commitCvmProvision:cl,safeCommitCvmProvision:ll,getCvmComposeFile:hl,safeGetCvmComposeFile:ao,provisionCvmComposeFileUpdate:gl,safeProvisionCvmComposeFileUpdate:yl,commitCvmComposeFileUpdate:_l,safeCommitCvmComposeFileUpdate:Cl,startCvm:jl,safeStartCvm:Nl,stopCvm:Dl,safeStopCvm:Ml,shutdownCvm:Vl,safeShutdownCvm:Kl,restartCvm:Jl,safeRestartCvm:Zl,deleteCvm:ep,safeDeleteCvm:tp,getCvmStats:ip,safeGetCvmStats:ap,getCvmNetwork:up,safeGetCvmNetwork:fp,getCvmDockerCompose:hp,safeGetCvmDockerCompose:xp,getCvmContainersStats:wp,safeGetCvmContainersStats:vp,getCvmAttestation:Ap,safeGetCvmAttestation:Pp,updateCvmResources:Lp,safeUpdateCvmResources:$p,updateCvmVisibility:Up,safeUpdateCvmVisibility:Fp,getAvailableOsImages:jp,safeGetAvailableOsImages:Np,updateOsImage:Dp,safeUpdateOsImage:Mp,getKmsInfo:Tl,safeGetKmsInfo:El,getKmsList:Al,safeGetKmsList:Pl,getAppEnvEncryptPubKey:$l,safeGetAppEnvEncryptPubKey:Rl,nextAppIds:zl,safeNextAppIds:Hl,getCvmState:Kp,safeGetCvmState:Wp};return t.extend(r)}var Xp=R.object({chain:R.unknown().optional(),rpcUrl:R.string().optional(),kmsContractAddress:R.string(),privateKey:R.string().optional(),walletClient:R.unknown().optional(),publicClient:R.unknown().optional(),allowAnyDevice:R.boolean().optional().default(!1),deviceId:R.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),composeHash:R.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),disableUpgrades:R.boolean().optional().default(!1),skipPrerequisiteChecks:R.boolean().optional().default(!1),minBalance:R.string().optional()}).passthrough(),Ex=Xp.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"]}),Sx=R.object({appId:R.string(),appAuthAddress:R.string(),deployer:R.string(),transactionHash:R.string(),blockNumber:R.bigint().optional(),gasUsed:R.bigint().optional()}).passthrough();var Ax=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"]}),Px=B.object({composeHash:B.string(),appId:B.string(),transactionHash:B.string(),blockNumber:B.bigint().optional(),gasUsed:B.bigint().optional()}).passthrough();var Lx=nt.object({target:nt.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),interval:nt.number().min(5).max(30).default(5).describe("Polling interval in seconds"),timeout:nt.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),maxRetries:nt.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),retryDelay:nt.number().min(0).default(5e3).describe("Delay between retries in milliseconds")});import Ms from"node:crypto";import Gs from"node:fs";import lt from"node:os";import co from"node:path";import M from"chalk";import eu from"ora";var Qp=!1;function pe(){return Qp}function tu(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 ru(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 Ns(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(...ru(o,t));continue}let n=tu(o,t);r.push(...n)}if(r.length===0){let o=e.trim();r.push(o)}return r}var _e={error:(e,...t)=>{pe()||(process.stderr.write(`${M.red("\u2717")} ${M.red(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
25
+ `,I,k,Cs(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?oo.fromFetchError(e):e instanceof Error?oo.fromError(e):new oo("Unknown error occurred",{detail:"Unknown error occurred"})}emitError(e){let t=hc(e);return this.emitter.emit("error",t),t}async safeRequest(e){try{return{success:!0,data:await e()}}catch(t){if(t instanceof Me)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 vc(e={}){return new wc(e)}function As(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 Ps(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 Bs(e,t){function r(i,a){return o(i,a)}async function o(i,a){As(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=Ps(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 S(e,t){function r(i,...a){let[l,u]=a;return o(i,l,u)}async function o(i,a,l){As(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=Ps(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 Cc=Be.object({username:Be.string(),email:Be.string(),credits:Be.number(),granted_credits:Be.number(),avatar:Be.string(),team_name:Be.string(),team_tier:Be.string()}).passthrough(),{action:_c,safeAction:kc}=Bs(Cc,async e=>await e.get("/auth/me")),Tc={[fr.id]:fr,[kt.id]:kt,[ur.id]:ur},Ec=Le.object({id:Le.string(),slug:Le.string().nullable(),url:Le.string(),version:Le.string(),chain_id:Le.number().nullable(),kms_contract_address:Le.string().nullable().transform(e=>e),gateway_app_id:Le.string().nullable().transform(e=>e)}).passthrough(),at=Ec.transform(e=>{if(e.chain_id!=null){let t=Tc[e.chain_id];if(t)return{...e,chain:t}}return e}),Sc=v.object({name:v.string(),is_dev:v.boolean(),version:v.union([v.tuple([v.number(),v.number(),v.number()]),v.tuple([v.number(),v.number(),v.number(),v.number()])]),os_image_hash:v.string().nullable().optional()}).passthrough(),Ic=v.object({teepod_id:v.number(),name:v.string(),listed:v.boolean(),resource_score:v.number(),remaining_vcpu:v.number(),remaining_memory:v.number(),remaining_cvm_slots:v.number(),images:v.array(Sc),support_onchain_kms:v.boolean().optional(),fmspc:v.string().nullable().optional(),device_id:v.string().nullable().optional(),region_identifier:v.string().nullable().optional(),default_kms:v.string().nullable().optional(),kms_list:v.array(v.string()).default([])}).passthrough(),Ac=v.object({max_instances:v.number().nullable().optional(),max_vcpu:v.number().nullable().optional(),max_memory:v.number().nullable().optional(),max_disk:v.number().nullable().optional()}).passthrough(),Pc=v.object({tier:v.string(),capacity:Ac,nodes:v.array(Ic),kms_list:v.array(at)}).passthrough(),{action:Bc,safeAction:Lc}=Bs(Pc,async e=>await e.get("/teepods/available")),Ls=$.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(),$c=$.object({name:$.string(),items:$.array(Ls),total:$.number()}).strict(),Rc=$.object({result:$.array($c)}).strict(),Uc=$.object({items:$.array(Ls),total:$.number(),family:$.string()}).strict(),Fc=$.object({family:$.string()}).strict(),{action:zc,safeAction:Hc}=S(Rc,async e=>await e.get("/instance-types")),{action:Oc,safeAction:jc}=S(Uc,async(e,t)=>{let r=Fc.parse(t);return await e.get(`/instance-types/${r.family}`)}),$s=Z.object({id:Z.string(),name:Z.string(),slug:Z.string().nullable(),tier:Z.string(),role:Z.string(),created_at:Z.string()}).passthrough(),Nc=Z.object({has_more:Z.boolean(),next_cursor:Z.string().nullable(),total:Z.number().nullable()}).passthrough(),Gc=Z.object({data:Z.array($s),pagination:Nc}).passthrough(),{action:Dc,safeAction:Mc}=S(Gc,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:qc,safeAction:Vc}=S($s,async(e,t)=>await e.get(`/workspaces/${t}`)),Kc=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()}),Wc=m.object({id:m.number(),username:m.string()}),io=m.object({id:m.number(),name:m.string(),region_identifier:m.string().nullable().optional()}),Rs=m.object({app:m.string(),instance:m.string()}),Xc=m.object({hosted:Kc,name:m.string(),managed_user:Wc.nullable(),node:io.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:at.nullable(),vcpu:m.number().nullable(),memory:m.number().nullable(),disk_size:m.number().nullable(),gateway_domain:m.string().nullable(),public_urls:m.array(Rs)}),Us=m.object({id:m.number(),name:m.string(),status:m.string(),in_progress:m.boolean().optional().default(!1),teepod_id:m.number().nullable(),teepod:io.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:at.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(Rs).optional().default([]),gateway_domain:m.string().optional().nullable()}),br=m.object({id:m.number(),name:m.string(),status:m.string(),teepod_id:m.number(),teepod:io.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()}),Pt=At.object({id:At.string().optional(),uuid:At.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:At.string().optional(),instance_id:At.string().optional()}),Bt=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"}),Jc=Bt(Pt),O=Jc.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}}),Zc=O,{action:Yc,safeAction:ct}=S(Us,async(e,t)=>{let{cvmId:r}=Zc.parse(t);return await e.get(`/cvms/${r}`)}),Qc=ne.object({page:ne.number().int().min(1).optional(),page_size:ne.number().int().min(1).optional(),node_id:ne.number().int().min(1).optional(),teepod_id:ne.number().int().min(1).optional(),user_id:ne.string().optional()}).strict(),el=ne.object({items:ne.array(Xc),total:ne.number(),page:ne.number(),page_size:ne.number(),pages:ne.number()}).strict(),{action:tl,safeAction:gr}=S(el,async(e,t)=>{let r=Qc.parse(t??{});return await e.get("/cvms/paginated",{params:r})}),rl=w.object({app_id:w.string().nullable().optional(),app_env_encrypt_pubkey:w.string().nullable().optional(),compose_hash:w.string(),fmspc:w.string().nullable().optional(),device_id:w.string().nullable().optional(),os_image_hash:w.string().nullable().optional(),instance_type:w.string().nullable().optional(),teepod_id:w.number().nullable().optional(),node_id:w.number().nullable().optional(),kms_id:w.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}),ol=w.object({node_id:w.number().optional(),teepod_id:w.number().optional(),region:w.string().optional(),name:w.string(),instance_type:w.string().default("tdx.small"),image:w.string().optional(),vcpu:w.number().optional(),memory:w.number().optional(),disk_size:w.number().optional(),compose_file:w.object({allowed_envs:w.array(w.string()).optional(),pre_launch_script:w.string().optional(),docker_compose_file:w.string().optional(),name:w.string().optional().default(""),kms_enabled:w.boolean().optional(),public_logs:w.boolean().optional(),public_sysinfo:w.boolean().optional(),gateway_enabled:w.boolean().optional(),tproxy_enabled:w.boolean().optional()}),listed:w.boolean().optional(),kms_id:w.string().optional(),kms:w.enum(["PHALA","ETHEREUM","BASE"]).optional(),kms_contract:w.string().optional(),env_keys:w.array(w.string()).optional(),nonce:w.number().optional(),app_id:w.string().optional()}).passthrough();function nl(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:sl,safeAction:il}=S(rl,async(e,t)=>{let r=ol.parse(t),o=nl(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)}),al=_.object({id:_.number(),name:_.string(),status:_.string(),teepod_id:_.number(),teepod:_.object({id:_.number(),name:_.string()}).nullable(),user_id:_.number().nullable(),app_id:_.string().nullable(),vm_uuid:_.string().nullable(),instance_id:_.string().nullable(),app_url:_.string().nullable(),base_image:_.string().nullable(),vcpu:_.number(),memory:_.number(),disk_size:_.number(),manifest_version:_.number().nullable(),version:_.string().nullable(),runner:_.string().nullable(),docker_compose_file:_.string().nullable(),features:_.array(_.string()).nullable(),created_at:_.string(),encrypted_env_pubkey:_.string().nullable().optional(),app_auth_contract_address:_.string().nullable().optional(),deployer_address:_.string().nullable().optional()}).passthrough(),rx=_.object({encrypted_env:_.string().optional().nullable(),app_id:_.string(),compose_hash:_.string(),kms_id:_.string().optional(),contract_address:_.string().optional(),deployer_address:_.string().optional(),env_keys:_.array(_.string()).optional().nullable()}).passthrough(),{action:cl,safeAction:ll}=S(al,async(e,t)=>await e.post("/cvms",t)),Fs=D.object({allowed_envs:D.array(D.string()).optional(),docker_compose_file:D.string(),features:D.array(D.string()).optional(),name:D.string().optional(),manifest_version:D.number().optional(),kms_enabled:D.boolean().optional(),public_logs:D.boolean().optional(),public_sysinfo:D.boolean().optional(),tproxy_enabled:D.boolean().optional(),pre_launch_script:D.string().optional(),env_pubkey:D.string().optional(),salt:D.string().optional().nullable()}).passthrough();function so(e){return e==null?e:Array.isArray(e)?e.map(so):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let o=e[r];return t[r]=so(o),t},{}):e}function zs(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 Hs(e){let t=so(e),r=JSON.stringify(t,null,4);return r=r.replace(/": /g,'":'),r}function ul(e){let t=zs(e),r=Hs(t);return pl.createHash("sha256").update(r,"utf8").digest("hex")}function fl(e){let t=e;return{...e,getHash:()=>ul(t),toString:()=>Hs(zs(t))}}var ml=Fs.transform(e=>fl(e)),dl=O,{action:hl,safeAction:ao}=S(ml,async(e,t)=>{let{cvmId:r}=dl.parse(t);return await e.get(`/cvms/${r}/compose_file`)}),xl=he.object({id:he.string().optional(),uuid:he.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:he.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:he.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:Fs,update_env_vars:he.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})),bl=he.object({app_id:he.string().nullable(),device_id:he.string().nullable(),compose_hash:he.string(),kms_info:at.nullable().optional()}).passthrough(),{action:gl,safeAction:yl}=S(bl,async(e,t)=>{let r=xl.parse(t);return await e.post(`/cvms/${r.cvmId}/compose_file/provision`,r.request)}),wl=le.object({id:le.string().optional(),uuid:le.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:le.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:le.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:le.string().min(1,"Compose hash is required"),encrypted_env:le.string().optional(),env_keys:le.array(le.string()).optional(),update_env_vars:le.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})),vl=le.any().transform(()=>{}),{action:Cl,safeAction:_l}=S(vl,async(e,t)=>{let r=wl.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})}),kl=_s.object({kms_id:_s.string().min(1,"KMS ID is required")}),{action:Tl,safeAction:El}=S(at,async(e,t)=>{let r=kl.parse(t);return await e.get(`/kms/${r.kms_id}`)}),Sl=xe.object({page:xe.number().int().min(1).optional(),page_size:xe.number().int().min(1).optional(),is_onchain:xe.boolean().optional()}).strict(),Il=xe.object({items:xe.array(at),total:xe.number(),page:xe.number(),page_size:xe.number(),pages:xe.number()}).strict(),{action:Al,safeAction:Pl}=S(Il,async(e,t)=>{let r=Sl.parse(t??{});return await e.get("/kms",{params:r})}),Bl=it.object({kms:it.string().min(1,"KMS ID or slug is required"),app_id:it.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(),Ll=it.object({public_key:it.string(),signature:it.string()}).strict(),{action:$l,safeAction:Rl}=S(Ll,async(e,t)=>{let r=Bl.parse(t);return await e.get(`/kms/${r.kms}/pubkey/${r.app_id}`)}),Ul=De.object({counts:De.number().int().min(1).max(20).optional().default(1)}).strict(),Fl=De.object({app_ids:De.array(De.object({app_id:De.string(),nonce:De.number().int().min(0)}))}).strict(),{action:zl,safeAction:Hl}=S(Fl,async(e,t)=>{let r=Ul.parse(t??{}),o=new URLSearchParams;return o.append("counts",r.counts.toString()),await e.get(`/kms/phala/next_app_id?${o.toString()}`)}),Ol=O,{action:jl,safeAction:Nl}=S(br,async(e,t)=>{let{cvmId:r}=Ol.parse(t);return await e.post(`/cvms/${r}/start`)}),Gl=O,{action:Dl,safeAction:Ml}=S(br,async(e,t)=>{let{cvmId:r}=Gl.parse(t);return await e.post(`/cvms/${r}/stop`)}),ql=O,{action:Vl,safeAction:Kl}=S(br,async(e,t)=>{let{cvmId:r}=ql.parse(t);return await e.post(`/cvms/${r}/shutdown`)}),Xl=Bt(Pt.extend({force:Wl.boolean().optional()})),{action:Jl,safeAction:Zl}=S(br,async(e,t)=>{let r=Xl.parse(t),{cvmId:o}=O.parse(r),{force:n=!1}=r;return await e.post(`/cvms/${o}/restart`,{force:n})}),Ql=O,{action:ep,safeAction:tp}=S(Yl.void(),async(e,t)=>{let{cvmId:r}=Ql.parse(t);await e.delete(`/cvms/${r}`)}),rp=E.object({name:E.string(),mount_point:E.string(),total_size:E.number(),free_size:E.number()}),op=E.object({os_name:E.string(),os_version:E.string(),kernel_version:E.string(),cpu_model:E.string(),num_cpus:E.number(),total_memory:E.number(),available_memory:E.number(),used_memory:E.number(),free_memory:E.number(),total_swap:E.number(),used_swap:E.number(),free_swap:E.number(),uptime:E.number(),loadavg_one:E.number(),loadavg_five:E.number(),loadavg_fifteen:E.number(),disks:E.array(rp)}),np=E.object({is_online:E.boolean(),is_public:E.boolean().default(!1),error:E.string().nullable(),sysinfo:op.nullable(),status:E.string().nullable(),in_progress:E.boolean().default(!1),boot_progress:E.string().nullable(),boot_error:E.string().nullable()}),sp=O,{action:ip,safeAction:ap}=S(np,async(e,t)=>{let{cvmId:r}=sp.parse(t);return await e.get(`/cvms/${r}/stats`)}),cp=de.object({app:de.string(),instance:de.string()}),lp=de.object({is_online:de.boolean(),is_public:de.boolean().default(!0),error:de.string().nullable(),internal_ip:de.string().nullable(),latest_handshake:de.string().nullable(),public_urls:de.array(cp).nullable()}),pp=O,{action:up,safeAction:fp}=S(lp,async(e,t)=>{let{cvmId:r}=pp.parse(t);return await e.get(`/cvms/${r}/network`)}),dp=O,{action:hp,safeAction:xp}=S(mp.string(),async(e,t)=>{let{cvmId:r}=dp.parse(t);return await e.get(`/cvms/${r}/docker-compose.yml`)}),bp=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()}),gp=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(bp).nullable()}),yp=O,{action:wp,safeAction:vp}=S(gp,async(e,t)=>{let{cvmId:r}=yp.parse(t);return await e.get(`/cvms/${r}/composition`)}),Cp=g.object({common_name:g.string().nullable(),organization:g.string().nullable(),country:g.string().nullable(),state:g.string().nullable(),locality:g.string().nullable()}),_p=g.object({common_name:g.string().nullable(),organization:g.string().nullable(),country:g.string().nullable()}),kp=g.object({subject:Cp,issuer:_p,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()}),Tp=g.object({imr:g.number(),event_type:g.number(),digest:g.string(),event:g.string(),event_payload:g.string()}),Ep=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(Tp),app_compose:g.string()}),Sp=g.object({name:g.string().nullable(),is_online:g.boolean(),is_public:g.boolean().default(!0),error:g.string().nullable(),app_certificates:g.array(kp).nullable(),tcb_info:Ep.nullable(),compose_file:g.string().nullable()}),Ip=O,{action:Ap,safeAction:Pp}=S(Sp,async(e,t)=>{let{cvmId:r}=Ip.parse(t);return await e.get(`/cvms/${r}/attestation`)}),Bp=Bt(Pt.extend({vcpu:st.number().optional(),memory:st.number().optional(),disk_size:st.number().optional(),instance_type:st.string().optional(),allow_restart:st.boolean().optional()})),{action:Lp,safeAction:$p}=S(st.void(),async(e,t)=>{let r=Bp.parse(t),{cvmId:o}=O.parse(r),{...n}=r;await e.patch(`/cvms/${o}/resources`,n)}),Rp=Bt(Pt.extend({public_sysinfo:ks.boolean(),public_logs:ks.boolean()})),{action:Up,safeAction:Fp}=S(Us,async(e,t)=>{let r=Rp.parse(t),{cvmId:o}=O.parse(r),{public_sysinfo:n,public_logs:s}=r;return await e.patch(`/cvms/${o}/visibility`,{public_sysinfo:n,public_logs:s})}),Ts=G.object({name:G.string(),os_image_hash:G.string().nullable(),is_current:G.boolean()}),zp=G.object({version:G.union([G.tuple([G.number(),G.number(),G.number(),G.number()]),G.tuple([G.number(),G.number(),G.number()])]),prod:Ts.nullable(),dev:Ts.nullable()}),Hp=G.array(zp),Op=O,{action:jp,safeAction:Np}=S(Hp,async(e,t)=>{let{cvmId:r}=Op.parse(t);return await e.get(`/cvms/${r}/available-os-images`)}),Gp=Bt(Pt.extend({os_image_name:Os.string().min(1,"OS image name is required")})),{action:Dp,safeAction:Mp}=S(Os.void(),async(e,t)=>{let r=Gp.parse(t),{cvmId:o}=O.parse(r),{os_image_name:n}=r;await e.patch(`/cvms/${o}/os-image`,{os_image_name:n})}),qp=me.object({id:me.string().optional(),instance_id:me.string().optional(),name:me.string(),status:me.string(),uptime:me.string().optional(),exited_at:me.string().optional(),boot_progress:me.string().optional(),boot_error:me.string().optional(),shutdown_progress:me.string().optional()}),Vp=O,{action:Kp,safeAction:Wp}=S(qp,async(e,t)=>{let{cvmId:r}=Vp.parse(t);return await e.get(`/cvms/${r}/state`)});function js(e={}){let t=vc(e),r={getCurrentUser:_c,safeGetCurrentUser:kc,getAvailableNodes:Bc,safeGetAvailableNodes:Lc,listAllInstanceTypeFamilies:zc,safeListAllInstanceTypeFamilies:Hc,listFamilyInstanceTypes:Oc,safeListFamilyInstanceTypes:jc,listWorkspaces:Dc,safeListWorkspaces:Mc,getWorkspace:qc,safeGetWorkspace:Vc,getCvmInfo:Yc,safeGetCvmInfo:ct,getCvmList:tl,safeGetCvmList:gr,provisionCvm:sl,safeProvisionCvm:il,commitCvmProvision:cl,safeCommitCvmProvision:ll,getCvmComposeFile:hl,safeGetCvmComposeFile:ao,provisionCvmComposeFileUpdate:gl,safeProvisionCvmComposeFileUpdate:yl,commitCvmComposeFileUpdate:Cl,safeCommitCvmComposeFileUpdate:_l,startCvm:jl,safeStartCvm:Nl,stopCvm:Dl,safeStopCvm:Ml,shutdownCvm:Vl,safeShutdownCvm:Kl,restartCvm:Jl,safeRestartCvm:Zl,deleteCvm:ep,safeDeleteCvm:tp,getCvmStats:ip,safeGetCvmStats:ap,getCvmNetwork:up,safeGetCvmNetwork:fp,getCvmDockerCompose:hp,safeGetCvmDockerCompose:xp,getCvmContainersStats:wp,safeGetCvmContainersStats:vp,getCvmAttestation:Ap,safeGetCvmAttestation:Pp,updateCvmResources:Lp,safeUpdateCvmResources:$p,updateCvmVisibility:Up,safeUpdateCvmVisibility:Fp,getAvailableOsImages:jp,safeGetAvailableOsImages:Np,updateOsImage:Dp,safeUpdateOsImage:Mp,getKmsInfo:Tl,safeGetKmsInfo:El,getKmsList:Al,safeGetKmsList:Pl,getAppEnvEncryptPubKey:$l,safeGetAppEnvEncryptPubKey:Rl,nextAppIds:zl,safeNextAppIds:Hl,getCvmState:Kp,safeGetCvmState:Wp};return t.extend(r)}var Xp=R.object({chain:R.unknown().optional(),rpcUrl:R.string().optional(),kmsContractAddress:R.string(),privateKey:R.string().optional(),walletClient:R.unknown().optional(),publicClient:R.unknown().optional(),allowAnyDevice:R.boolean().optional().default(!1),deviceId:R.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),composeHash:R.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),disableUpgrades:R.boolean().optional().default(!1),skipPrerequisiteChecks:R.boolean().optional().default(!1),minBalance:R.string().optional()}).passthrough(),Ex=Xp.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"]}),Sx=R.object({appId:R.string(),appAuthAddress:R.string(),deployer:R.string(),transactionHash:R.string(),blockNumber:R.bigint().optional(),gasUsed:R.bigint().optional()}).passthrough();var Ax=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"]}),Px=B.object({composeHash:B.string(),appId:B.string(),transactionHash:B.string(),blockNumber:B.bigint().optional(),gasUsed:B.bigint().optional()}).passthrough();var Lx=nt.object({target:nt.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),interval:nt.number().min(5).max(30).default(5).describe("Polling interval in seconds"),timeout:nt.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),maxRetries:nt.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),retryDelay:nt.number().min(0).default(5e3).describe("Delay between retries in milliseconds")});import Ms from"node:crypto";import Gs from"node:fs";import lt from"node:os";import co from"node:path";import M from"chalk";import eu from"ora";var Qp=!1;function pe(){return Qp}function tu(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 ru(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 Ns(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(...ru(o,t));continue}let n=tu(o,t);r.push(...n)}if(r.length===0){let o=e.trim();r.push(o)}return r}var Ce={error:(e,...t)=>{pe()||(process.stderr.write(`${M.red("\u2717")} ${M.red(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
27
27
  `))},warn:(e,...t)=>{pe()||(process.stderr.write(`${M.yellow("\u26A0")} ${M.yellow(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
28
28
  `))},info:(e,...t)=>{pe()||(process.stderr.write(`${M.blue("\u2139")} ${M.blue(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
29
29
  `))},success:(e,...t)=>{pe()||(process.stderr.write(`${M.green("\u2713")} ${M.green(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
@@ -34,7 +34,7 @@ var Ys=Object.create;var po=Object.defineProperty;var Qs=Object.getOwnPropertyDe
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 qs=co.join(lt.homedir(),".phala-cloud"),Ds=co.join(qs,"api-key"),eb=co.join(qs,"docker-credentials.json");function ou(){let e=[lt.hostname(),lt.platform(),lt.arch(),lt.cpus()[0]?.model||"",lt.userInfo().username],t=Ms.createHash("sha256");return t.update(e.join("|")),t.digest()}function nu(e){try{let t=ou(),r=e.split(":");if(r.length!==2)throw new Error("Invalid encrypted format");let o=Buffer.from(r[0],"hex"),n=r[1],s=Ms.createDecipheriv("aes-256-cbc",t.slice(0,32),o),i=s.update(n,"hex","utf8");return i+=s.final("utf8"),i}catch(t){throw _e.error("Decryption failed:",t),new Error("Failed to decrypt data")}}function Vs(){try{if(process.env.PHALA_CLOUD_API_KEY)return process.env.PHALA_CLOUD_API_KEY;if(Gs.existsSync(Ds)){let e=Gs.readFileSync(Ds,"utf8").trim();return nu(e)}return null}catch(e){return _e.error("Failed to read API key:",e),null}}async function j(){let e=Vs();return js({apiKey:e})}import{z as c}from"zod";var su=c.object({password:c.string(),registry:c.string().nullable(),username:c.string()}),ib=c.object({docker_compose_file:c.string(),docker_config:su.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(),Ks=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()}),ab=c.object({key:c.string(),value:c.string()}),Ws=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()}))}),Xs=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()}),Js=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()}),iu=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()}),cb=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(iu).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 au from"inquirer";async function hb(e){let t=await j(),r=await gr(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 _e.success(`CVM with App ID app_${o} detected`),i.hosted?.app_id||""}async function xb(e){let t=await j(),r=e.replace(/^app_/,""),o=await ct(t,{app_id:r});if(!o.success)throw new Error(o.error.message);return o.data}async function bb(e){let t=await j(),r=await ao(t,{id:e});if(!r.success)throw new Error(r.error.message);return r.data}async function gb(e){let t=await j(),r=e.replace(/^app_/,""),o=await t.get(`cvms/app_${r}/network`);return Ws.parse(o)}async function yb(e){let t=await j(),r=e.replace(/^app_/,""),o=await t.post(`cvms/app_${r}/start`);return(await ct(t,{app_id:r})).data}async function wb(e){let t=await j(),r=e.replace(/^app_/,"");return await t.post(`cvms/app_${r}/stop`),(await ct(t,{app_id:r})).data}async function vb(e){let t=await j(),r=e.replace(/^app_/,"");return await t.post(`cvms/app_${r}/restart`),(await ct(t,{app_id:r})).data}async function _b(e){let t=await j(),r=e.replace(/^app_/,"");return await t.delete(`cvms/app_${r}`),!0}async function Cb(){let e=_e.startSpinner("Fetching available CVMs"),t=await j(),r=await gr(t);if(e.stop(!0),!r.success){_e.error(`Failed to fetch CVMs: ${r.error.message}`);return}let n=r.data.items;if(!n||n.length===0){_e.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 au.prompt([{type:"list",name:"selectedCvm",message:"Select a CVM:",choices:s}]);return i}async function kb(e){let t=await j(),r=e.replace(/^app_/,""),o=await t.get(`cvms/app_${r}/attestation`);try{return Js.parse(o)}catch(n){return _e.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 Tb(e,t){let r=await j(),o=e.replace(/^app_/,""),n=await r.post(`cvms/app_${o}/replicas`,t);return Xs.parse(n)}async function Eb(e,t,r,o,n){let s=await j(),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 Sb(e){return await(await j()).post("cvms/pubkey/from_cvm_configuration",e)}async function Ib(e){let r=await(await j()).post("cvms/from_cvm_configuration",e);return Ks.parse(r)}async function Ab(e,t){let r=await j(),o=e.replace(/^app_/,"");return await r.put(`cvms/app_${o}/compose`,t)}async function Pb(e=!1){let t=await j(),r="teepods/available";return e&&(r+="?v03x_only=1"),await t.get(r)}export{hb as checkCvmExists,ib as composeFileSchema,Ib as createCvm,Js as cvmAttestationResponseSchema,_b as deleteCvm,su as dockerConfigSchema,ab as encryptedEnvItemSchema,kb as getCvmAttestation,xb as getCvmByAppId,bb as getCvmComposeConfig,gb as getCvmNetwork,Ws as getCvmNetworkResponseSchema,Sb as getPubkeyFromCvm,Pb as getTeepods,iu as imageSchema,Ks as postCvmResponseSchema,Tb as replicateCvm,Xs as replicateCvmResponseSchema,Eb as resizeCvm,vb as restartCvm,Cb as selectCvm,yb as startCvm,wb as stopCvm,cb as teepodSchema,Ab as upgradeCvm};
37
+ `)}};var qs=co.join(lt.homedir(),".phala-cloud"),Ds=co.join(qs,"api-key"),eb=co.join(qs,"docker-credentials.json");function ou(){let e=[lt.hostname(),lt.platform(),lt.arch(),lt.cpus()[0]?.model||"",lt.userInfo().username],t=Ms.createHash("sha256");return t.update(e.join("|")),t.digest()}function nu(e){try{let t=ou(),r=e.split(":");if(r.length!==2)throw new Error("Invalid encrypted format");let o=Buffer.from(r[0],"hex"),n=r[1],s=Ms.createDecipheriv("aes-256-cbc",t.slice(0,32),o),i=s.update(n,"hex","utf8");return i+=s.final("utf8"),i}catch(t){throw Ce.error("Decryption failed:",t),new Error("Failed to decrypt data")}}function Vs(){try{if(process.env.PHALA_CLOUD_API_KEY)return process.env.PHALA_CLOUD_API_KEY;if(Gs.existsSync(Ds)){let e=Gs.readFileSync(Ds,"utf8").trim();return nu(e)}return null}catch(e){return Ce.error("Failed to read API key:",e),null}}async function j(){let e=Vs();return js({apiKey:e})}import{z as c}from"zod";var su=c.object({password:c.string(),registry:c.string().nullable(),username:c.string()}),ib=c.object({docker_compose_file:c.string(),docker_config:su.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(),Ks=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()}),ab=c.object({key:c.string(),value:c.string()}),Ws=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()}))}),Xs=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()}),Js=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()}),iu=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()}),cb=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(iu).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 au from"inquirer";async function hb(e){let t=await j(),r=await gr(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 Ce.success(`CVM with App ID app_${o} detected`),i.hosted?.app_id||""}async function xb(e){let t=await j(),r=e.replace(/^app_/,""),o=await ct(t,{app_id:r});if(!o.success)throw new Error(o.error.message);return o.data}async function bb(e){let t=await j(),r=await ao(t,{id:e});if(!r.success)throw new Error(r.error.message);return r.data}async function gb(e){let t=await j(),r=e.replace(/^app_/,""),o=await t.get(`cvms/app_${r}/network`);return Ws.parse(o)}async function yb(e){let t=await j(),r=e.replace(/^app_/,""),o=await t.post(`cvms/app_${r}/start`);return(await ct(t,{app_id:r})).data}async function wb(e){let t=await j(),r=e.replace(/^app_/,"");return await t.post(`cvms/app_${r}/stop`),(await ct(t,{app_id:r})).data}async function vb(e){let t=await j(),r=e.replace(/^app_/,"");return await t.post(`cvms/app_${r}/restart`),(await ct(t,{app_id:r})).data}async function Cb(e){let t=await j(),r=e.replace(/^app_/,"");return await t.delete(`cvms/app_${r}`),!0}async function _b(){let e=Ce.startSpinner("Fetching available CVMs"),t=await j(),r=await gr(t);if(e.stop(!0),!r.success){Ce.error(`Failed to fetch CVMs: ${r.error.message}`);return}let n=r.data.items;if(!n||n.length===0){Ce.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 au.prompt([{type:"list",name:"selectedCvm",message:"Select a CVM:",choices:s}]);return i}async function kb(e){let t=await j(),r=e.replace(/^app_/,""),o=await t.get(`cvms/app_${r}/attestation`);try{return Js.parse(o)}catch(n){return Ce.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 Tb(e,t){let r=await j(),o=e.replace(/^app_/,""),n=await r.post(`cvms/app_${o}/replicas`,t);return Xs.parse(n)}async function Eb(e,t,r,o,n){let s=await j(),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 Sb(e){return await(await j()).post("cvms/pubkey/from_cvm_configuration",e)}async function Ib(e){let r=await(await j()).post("cvms/from_cvm_configuration",e);return Ks.parse(r)}async function Ab(e,t){let r=await j(),o=e.replace(/^app_/,"");return await r.put(`cvms/app_${o}/compose`,t)}async function Pb(e=!1){let t=await j(),r="teepods/available";return e&&(r+="?v03x_only=1"),await t.get(r)}export{hb as checkCvmExists,ib as composeFileSchema,Ib as createCvm,Js as cvmAttestationResponseSchema,Cb as deleteCvm,su as dockerConfigSchema,ab as encryptedEnvItemSchema,kb as getCvmAttestation,xb as getCvmByAppId,bb as getCvmComposeConfig,gb as getCvmNetwork,Ws as getCvmNetworkResponseSchema,Sb as getPubkeyFromCvm,Pb as getTeepods,iu as imageSchema,Ks as postCvmResponseSchema,Tb as replicateCvm,Xs as replicateCvmResponseSchema,Eb as resizeCvm,vb as restartCvm,_b as selectCvm,yb as startCvm,wb as stopCvm,cb as teepodSchema,Ab as upgradeCvm};
38
38
  /*! Bundled license information:
39
39
 
40
40
  @noble/hashes/esm/utils.js: