phala 1.1.6 → 1.1.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,51 +1,51 @@
1
1
  import { createRequire } from 'module';const require = createRequire(import.meta.url);
2
- var Bi=Object.create;var Un=Object.defineProperty;var zi=Object.getOwnPropertyDescriptor;var ji=Object.getOwnPropertyNames;var Ui=Object.getPrototypeOf,Fi=Object.prototype.hasOwnProperty;var Re=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var P=(e,t)=>()=>(e&&(t=e(e=0)),t);var re=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Oi=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ji(t))!Fi.call(e,o)&&o!==r&&Un(e,o,{get:()=>t[o],enumerable:!(n=zi(t,o))||n.enumerable});return e};var Tt=(e,t,r)=>(r=e!=null?Bi(Ui(e)):{},Oi(t||!e||!e.__esModule?Un(r,"default",{value:e,enumerable:!0}):r,e));var On=re((lm,Fn)=>{var it=1e3,at=it*60,ct=at*60,Je=ct*24,Hi=Je*7,Ni=Je*365.25;Fn.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return Gi(e);if(r==="number"&&isFinite(e))return t.long?Di(e):qi(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Gi(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]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*Ni;case"weeks":case"week":case"w":return r*Hi;case"days":case"day":case"d":return r*Je;case"hours":case"hour":case"hrs":case"hr":case"h":return r*ct;case"minutes":case"minute":case"mins":case"min":case"m":return r*at;case"seconds":case"second":case"secs":case"sec":case"s":return r*it;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function qi(e){var t=Math.abs(e);return t>=Je?Math.round(e/Je)+"d":t>=ct?Math.round(e/ct)+"h":t>=at?Math.round(e/at)+"m":t>=it?Math.round(e/it)+"s":e+"ms"}function Di(e){var t=Math.abs(e);return t>=Je?Vt(e,t,Je,"day"):t>=ct?Vt(e,t,ct,"hour"):t>=at?Vt(e,t,at,"minute"):t>=it?Vt(e,t,it,"second"):e+" ms"}function Vt(e,t,r,n){var o=t>=r*1.5;return Math.round(e/r)+" "+n+(o?"s":"")}});var Ur=re((um,Hn)=>{function Mi(e){r.debug=r,r.default=r,r.coerce=l,r.disable=i,r.enable=o,r.enabled=a,r.humanize=On(),r.destroy=u,Object.keys(e).forEach(p=>{r[p]=e[p]}),r.names=[],r.skips=[],r.formatters={};function t(p){let f=0;for(let h=0;h<p.length;h++)f=(f<<5)-f+p.charCodeAt(h),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=t;function r(p){let f,h=null,g,_;function I(...R){if(!I.enabled)return;let G=I,J=Number(new Date),K=J-(f||J);G.diff=K,G.prev=f,G.curr=J,f=J,R[0]=r.coerce(R[0]),typeof R[0]!="string"&&R.unshift("%O");let Z=0;R[0]=R[0].replace(/%([a-zA-Z%])/g,(pe,Mt)=>{if(pe==="%%")return"%";Z++;let jn=r.formatters[Mt];if(typeof jn=="function"){let Ri=R[Z];pe=jn.call(G,Ri),R.splice(Z,1),Z--}return pe}),r.formatArgs.call(G,R),(G.log||r.log).apply(G,R)}return I.namespace=p,I.useColors=r.useColors(),I.color=r.selectColor(p),I.extend=n,I.destroy=r.destroy,Object.defineProperty(I,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(g!==r.namespaces&&(g=r.namespaces,_=r.enabled(p)),_),set:R=>{h=R}}),typeof r.init=="function"&&r.init(I),I}function n(p,f){let h=r(this.namespace+(typeof f>"u"?":":f)+p);return h.log=this.log,h}function o(p){r.save(p),r.namespaces=p,r.names=[],r.skips=[];let f=(typeof p=="string"?p:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let h of f)h[0]==="-"?r.skips.push(h.slice(1)):r.names.push(h)}function s(p,f){let h=0,g=0,_=-1,I=0;for(;h<p.length;)if(g<f.length&&(f[g]===p[h]||f[g]==="*"))f[g]==="*"?(_=g,I=h,g++):(h++,g++);else if(_!==-1)g=_+1,I++,h=I;else return!1;for(;g<f.length&&f[g]==="*";)g++;return g===f.length}function i(){let p=[...r.names,...r.skips.map(f=>"-"+f)].join(",");return r.enable(""),p}function a(p){for(let f of r.skips)if(s(p,f))return!1;for(let f of r.names)if(s(p,f))return!0;return!1}function l(p){return p instanceof Error?p.stack||p.message:p}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}Hn.exports=Mi});var Nn=re((ne,Kt)=>{ne.formatArgs=Ki;ne.save=Wi;ne.load=Xi;ne.useColors=Vi;ne.storage=Ji();ne.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`."))}})();ne.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 Vi(){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 Ki(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Kt.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}ne.log=console.debug||console.log||(()=>{});function Wi(e){try{e?ne.storage.setItem("debug",e):ne.storage.removeItem("debug")}catch{}}function Xi(){let e;try{e=ne.storage.getItem("debug")||ne.storage.getItem("DEBUG")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function Ji(){try{return localStorage}catch{}}Kt.exports=Ur()(ne);var{formatters:Zi}=Kt.exports;Zi.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var qn=re((pm,Gn)=>{"use strict";Gn.exports=(e,t=process.argv)=>{let r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),o=t.indexOf("--");return n!==-1&&(o===-1||n<o)}});var Vn=re((fm,Mn)=>{"use strict";var Yi=Re("os"),Dn=Re("tty"),fe=qn(),{env:q}=process,Fe;fe("no-color")||fe("no-colors")||fe("color=false")||fe("color=never")?Fe=0:(fe("color")||fe("colors")||fe("color=true")||fe("color=always"))&&(Fe=1);"FORCE_COLOR"in q&&(q.FORCE_COLOR==="true"?Fe=1:q.FORCE_COLOR==="false"?Fe=0:Fe=q.FORCE_COLOR.length===0?1:Math.min(parseInt(q.FORCE_COLOR,10),3));function Fr(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Or(e,t){if(Fe===0)return 0;if(fe("color=16m")||fe("color=full")||fe("color=truecolor"))return 3;if(fe("color=256"))return 2;if(e&&!t&&Fe===void 0)return 0;let r=Fe||0;if(q.TERM==="dumb")return r;if(process.platform==="win32"){let n=Yi.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in q)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in q)||q.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in q)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(q.TEAMCITY_VERSION)?1:0;if(q.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in q){let n=parseInt((q.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(q.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(q.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(q.TERM)||"COLORTERM"in q?1:r}function Qi(e){let t=Or(e,e&&e.isTTY);return Fr(t)}Mn.exports={supportsColor:Qi,stdout:Fr(Or(!0,Dn.isatty(1))),stderr:Fr(Or(!0,Dn.isatty(2)))}});var Wn=re((D,Xt)=>{var ea=Re("tty"),Wt=Re("util");D.init=aa;D.log=oa;D.formatArgs=ra;D.save=sa;D.load=ia;D.useColors=ta;D.destroy=Wt.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");D.colors=[6,2,3,4,5,1];try{let e=Vn();e&&(e.stderr||e).level>=2&&(D.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{}D.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let r=t.substring(6).toLowerCase().replace(/_([a-z])/g,(o,s)=>s.toUpperCase()),n=process.env[t];return/^(yes|on|true|enabled)$/i.test(n)?n=!0:/^(no|off|false|disabled)$/i.test(n)?n=!1:n==="null"?n=null:n=Number(n),e[r]=n,e},{});function ta(){return"colors"in D.inspectOpts?!!D.inspectOpts.colors:ea.isatty(process.stderr.fd)}function ra(e){let{namespace:t,useColors:r}=this;if(r){let n=this.color,o="\x1B[3"+(n<8?n:"8;5;"+n),s=` ${o};1m${t} \x1B[0m`;e[0]=s+e[0].split(`
2
+ var Fi=Object.create;var On=Object.defineProperty;var Oi=Object.getOwnPropertyDescriptor;var Hi=Object.getOwnPropertyNames;var Ni=Object.getPrototypeOf,Gi=Object.prototype.hasOwnProperty;var Re=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var L=(e,t)=>()=>(e&&(t=e(e=0)),t);var ne=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var qi=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Hi(t))!Gi.call(e,o)&&o!==r&&On(e,o,{get:()=>t[o],enumerable:!(n=Oi(t,o))||n.enumerable});return e};var Tt=(e,t,r)=>(r=e!=null?Fi(Ni(e)):{},qi(t||!e||!e.__esModule?On(r,"default",{value:e,enumerable:!0}):r,e));var Nn=ne((mm,Hn)=>{var it=1e3,at=it*60,ct=at*60,Je=ct*24,Di=Je*7,Mi=Je*365.25;Hn.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return Vi(e);if(r==="number"&&isFinite(e))return t.long?Wi(e):Ki(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Vi(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]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*Mi;case"weeks":case"week":case"w":return r*Di;case"days":case"day":case"d":return r*Je;case"hours":case"hour":case"hrs":case"hr":case"h":return r*ct;case"minutes":case"minute":case"mins":case"min":case"m":return r*at;case"seconds":case"second":case"secs":case"sec":case"s":return r*it;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function Ki(e){var t=Math.abs(e);return t>=Je?Math.round(e/Je)+"d":t>=ct?Math.round(e/ct)+"h":t>=at?Math.round(e/at)+"m":t>=it?Math.round(e/it)+"s":e+"ms"}function Wi(e){var t=Math.abs(e);return t>=Je?Kt(e,t,Je,"day"):t>=ct?Kt(e,t,ct,"hour"):t>=at?Kt(e,t,at,"minute"):t>=it?Kt(e,t,it,"second"):e+" ms"}function Kt(e,t,r,n){var o=t>=r*1.5;return Math.round(e/r)+" "+n+(o?"s":"")}});var Fr=ne((dm,Gn)=>{function Xi(e){r.debug=r,r.default=r,r.coerce=l,r.disable=i,r.enable=o,r.enabled=a,r.humanize=Nn(),r.destroy=u,Object.keys(e).forEach(p=>{r[p]=e[p]}),r.names=[],r.skips=[],r.formatters={};function t(p){let f=0;for(let h=0;h<p.length;h++)f=(f<<5)-f+p.charCodeAt(h),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=t;function r(p){let f,h=null,g,_;function P(...R){if(!P.enabled)return;let G=P,Z=Number(new Date),K=Z-(f||Z);G.diff=K,G.prev=f,G.curr=Z,f=Z,R[0]=r.coerce(R[0]),typeof R[0]!="string"&&R.unshift("%O");let Y=0;R[0]=R[0].replace(/%([a-zA-Z%])/g,(pe,Vt)=>{if(pe==="%%")return"%";Y++;let Fn=r.formatters[Vt];if(typeof Fn=="function"){let Ui=R[Y];pe=Fn.call(G,Ui),R.splice(Y,1),Y--}return pe}),r.formatArgs.call(G,R),(G.log||r.log).apply(G,R)}return P.namespace=p,P.useColors=r.useColors(),P.color=r.selectColor(p),P.extend=n,P.destroy=r.destroy,Object.defineProperty(P,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(g!==r.namespaces&&(g=r.namespaces,_=r.enabled(p)),_),set:R=>{h=R}}),typeof r.init=="function"&&r.init(P),P}function n(p,f){let h=r(this.namespace+(typeof f>"u"?":":f)+p);return h.log=this.log,h}function o(p){r.save(p),r.namespaces=p,r.names=[],r.skips=[];let f=(typeof p=="string"?p:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let h of f)h[0]==="-"?r.skips.push(h.slice(1)):r.names.push(h)}function s(p,f){let h=0,g=0,_=-1,P=0;for(;h<p.length;)if(g<f.length&&(f[g]===p[h]||f[g]==="*"))f[g]==="*"?(_=g,P=h,g++):(h++,g++);else if(_!==-1)g=_+1,P++,h=P;else return!1;for(;g<f.length&&f[g]==="*";)g++;return g===f.length}function i(){let p=[...r.names,...r.skips.map(f=>"-"+f)].join(",");return r.enable(""),p}function a(p){for(let f of r.skips)if(s(p,f))return!1;for(let f of r.names)if(s(p,f))return!0;return!1}function l(p){return p instanceof Error?p.stack||p.message:p}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}Gn.exports=Xi});var qn=ne((oe,Wt)=>{oe.formatArgs=Zi;oe.save=Yi;oe.load=Qi;oe.useColors=Ji;oe.storage=ea();oe.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`."))}})();oe.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 Ji(){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 Zi(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Wt.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}oe.log=console.debug||console.log||(()=>{});function Yi(e){try{e?oe.storage.setItem("debug",e):oe.storage.removeItem("debug")}catch{}}function Qi(){let e;try{e=oe.storage.getItem("debug")||oe.storage.getItem("DEBUG")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function ea(){try{return localStorage}catch{}}Wt.exports=Fr()(oe);var{formatters:ta}=Wt.exports;ta.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Mn=ne((hm,Dn)=>{"use strict";Dn.exports=(e,t=process.argv)=>{let r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),o=t.indexOf("--");return n!==-1&&(o===-1||n<o)}});var Wn=ne((gm,Kn)=>{"use strict";var ra=Re("os"),Vn=Re("tty"),fe=Mn(),{env:q}=process,Fe;fe("no-color")||fe("no-colors")||fe("color=false")||fe("color=never")?Fe=0:(fe("color")||fe("colors")||fe("color=true")||fe("color=always"))&&(Fe=1);"FORCE_COLOR"in q&&(q.FORCE_COLOR==="true"?Fe=1:q.FORCE_COLOR==="false"?Fe=0:Fe=q.FORCE_COLOR.length===0?1:Math.min(parseInt(q.FORCE_COLOR,10),3));function Or(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Hr(e,t){if(Fe===0)return 0;if(fe("color=16m")||fe("color=full")||fe("color=truecolor"))return 3;if(fe("color=256"))return 2;if(e&&!t&&Fe===void 0)return 0;let r=Fe||0;if(q.TERM==="dumb")return r;if(process.platform==="win32"){let n=ra.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in q)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in q)||q.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in q)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(q.TEAMCITY_VERSION)?1:0;if(q.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in q){let n=parseInt((q.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(q.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(q.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(q.TERM)||"COLORTERM"in q?1:r}function na(e){let t=Hr(e,e&&e.isTTY);return Or(t)}Kn.exports={supportsColor:na,stdout:Or(Hr(!0,Vn.isatty(1))),stderr:Or(Hr(!0,Vn.isatty(2)))}});var Jn=ne((D,Jt)=>{var oa=Re("tty"),Xt=Re("util");D.init=pa;D.log=ca;D.formatArgs=ia;D.save=la;D.load=ua;D.useColors=sa;D.destroy=Xt.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");D.colors=[6,2,3,4,5,1];try{let e=Wn();e&&(e.stderr||e).level>=2&&(D.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{}D.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let r=t.substring(6).toLowerCase().replace(/_([a-z])/g,(o,s)=>s.toUpperCase()),n=process.env[t];return/^(yes|on|true|enabled)$/i.test(n)?n=!0:/^(no|off|false|disabled)$/i.test(n)?n=!1:n==="null"?n=null:n=Number(n),e[r]=n,e},{});function sa(){return"colors"in D.inspectOpts?!!D.inspectOpts.colors:oa.isatty(process.stderr.fd)}function ia(e){let{namespace:t,useColors:r}=this;if(r){let n=this.color,o="\x1B[3"+(n<8?n:"8;5;"+n),s=` ${o};1m${t} \x1B[0m`;e[0]=s+e[0].split(`
3
3
  `).join(`
4
- `+s),e.push(o+"m+"+Xt.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=na()+t+" "+e[0]}function na(){return D.inspectOpts.hideDate?"":new Date().toISOString()+" "}function oa(...e){return process.stderr.write(Wt.formatWithOptions(D.inspectOpts,...e)+`
5
- `)}function sa(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function ia(){return process.env.DEBUG}function aa(e){e.inspectOpts={};let t=Object.keys(D.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=D.inspectOpts[t[r]]}Xt.exports=Ur()(D);var{formatters:Kn}=Xt.exports;Kn.o=function(e){return this.inspectOpts.colors=this.useColors,Wt.inspect(e,this.inspectOpts).split(`
6
- `).map(t=>t.trim()).join(" ")};Kn.O=function(e){return this.inspectOpts.colors=this.useColors,Wt.inspect(e,this.inspectOpts)}});var Xn=re((mm,Hr)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Hr.exports=Nn():Hr.exports=Wn()});var Nr,Zn=P(()=>{Nr="2.38.6"});function Yn(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?Yn(e.cause,t):t?null:e}var Gr,v,me=P(()=>{Zn();Gr={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${Nr}`},v=class e extends Error{constructor(t,r={}){let n=r.cause instanceof e?r.cause.details:r.cause?.message?r.cause.message:r.details,o=r.cause instanceof e&&r.cause.docsPath||r.docsPath,s=Gr.getDocsUrl?.({...r,docsPath:o}),i=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...n?[`Details: ${n}`]:[],...Gr.version?[`Version: ${Gr.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=n,this.docsPath=o,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=t,this.version=Nr}walk(t){return Yn(this,t)}}});var Jt,Zt,qr=P(()=>{me();Jt=class extends v{constructor({max:t,min:r,signed:n,size:o,value:s}){super(`Number "${s}" is not in safe ${o?`${o*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${t?`(${r} to ${t})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}},Zt=class extends v{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}});function Ce(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}var lt=P(()=>{});function de(e){return Ce(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}var Et=P(()=>{lt()});function It(e,{dir:t="left"}={}){let r=typeof e=="string"?e.replace("0x",""):e,n=0;for(let o=0;o<r.length-1&&r[t==="left"?o:r.length-o-1].toString()==="0";o++)n++;return r=t==="left"?r.slice(n):r.slice(0,r.length-n),typeof e=="string"?(r.length===1&&t==="right"&&(r=`${r}0`),`0x${r.length%2===1?`0${r}`:r}`):r}var Qn=P(()=>{});var At,Pt,Dr=P(()=>{me();At=class extends v{constructor({offset:t,position:r,size:n}){super(`Slice ${r==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}},Pt=class extends v{constructor({size:t,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}});function Oe(e,{dir:t,size:r=32}={}){return typeof e=="string"?ca(e,{dir:t,size:r}):la(e,{dir:t,size:r})}function ca(e,{dir:t,size:r=32}={}){if(r===null)return e;let n=e.replace("0x","");if(n.length>r*2)throw new Pt({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function la(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new Pt({size:e.length,targetSize:r,type:"bytes"});let n=new Uint8Array(r);for(let o=0;o<r;o++){let s=t==="right";n[s?o:r-o-1]=e[s?o:e.length-o-1]}return n}var Mr=P(()=>{Dr()});function xe(e,t={}){return typeof e=="number"||typeof e=="bigint"?S(e,t):typeof e=="string"?ma(e,t):typeof e=="boolean"?pa(e,t):oe(e,t)}function pa(e,t={}){let r=`0x${Number(e)}`;return typeof t.size=="number"?(He(r,{size:t.size}),Oe(r,{size:t.size})):r}function oe(e,t={}){let r="";for(let o=0;o<e.length;o++)r+=ua[e[o]];let n=`0x${r}`;return typeof t.size=="number"?(He(n,{size:t.size}),Oe(n,{dir:"right",size:t.size})):n}function S(e,t={}){let{signed:r,size:n}=t,o=BigInt(e),s;n?r?s=(1n<<BigInt(n)*8n-1n)-1n:s=2n**(BigInt(n)*8n)-1n:typeof e=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));let i=typeof s=="bigint"&&r?-s-1n:0;if(s&&o>s||o<i){let l=typeof e=="bigint"?"n":"";throw new Jt({max:s?`${s}${l}`:void 0,min:`${i}${l}`,signed:r,size:n,value:`${e}${l}`})}let a=`0x${(r&&o<0?(1n<<BigInt(n*8))+BigInt(o):o).toString(16)}`;return n?Oe(a,{size:n}):a}function ma(e,t={}){let r=fa.encode(e);return oe(r,t)}var ua,fa,he=P(()=>{qr();Mr();Ye();ua=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));fa=new TextEncoder});function Yt(e,t={}){return typeof e=="number"||typeof e=="bigint"?ga(e,t):typeof e=="boolean"?ha(e,t):Ce(e)?be(e,t):Vr(e,t)}function ha(e,t={}){let r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(He(r,{size:t.size}),Oe(r,{size:t.size})):r}function eo(e){if(e>=Be.zero&&e<=Be.nine)return e-Be.zero;if(e>=Be.A&&e<=Be.F)return e-(Be.A-10);if(e>=Be.a&&e<=Be.f)return e-(Be.a-10)}function be(e,t={}){let r=e;t.size&&(He(r,{size:t.size}),r=Oe(r,{dir:"right",size:t.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);let o=n.length/2,s=new Uint8Array(o);for(let i=0,a=0;i<o;i++){let l=eo(n.charCodeAt(a++)),u=eo(n.charCodeAt(a++));if(l===void 0||u===void 0)throw new v(`Invalid byte sequence ("${n[a-2]}${n[a-1]}" in "${n}").`);s[i]=l*16+u}return s}function ga(e,t){let r=S(e,t);return be(r)}function Vr(e,t={}){let r=da.encode(e);return typeof t.size=="number"?(He(r,{size:t.size}),Oe(r,{dir:"right",size:t.size})):r}var da,Be,Ne=P(()=>{me();lt();Mr();Ye();he();da=new TextEncoder;Be={zero:48,nine:57,A:65,F:70,a:97,f:102}});function He(e,{size:t}){if(de(e)>t)throw new Zt({givenSize:de(e),maxSize:t})}function Qe(e,t={}){let{signed:r}=t;t.size&&He(e,{size:t.size});let n=BigInt(e);if(!r)return n;let o=(e.length-2)/2,s=(1n<<BigInt(o)*8n-1n)-1n;return n<=s?n:n-BigInt(`0x${"f".padStart(o*2,"f")}`)-1n}function et(e,t={}){return Number(Qe(e,t))}var Ye=P(()=>{qr();Et()});function ut(e,t){return({exclude:r,format:n})=>({exclude:r,format:(o,s)=>{let i=t(o,s);if(r)for(let a of r)delete i[a];return{...i,...n(o,s)}},type:e})}var Qt=P(()=>{});var rd,nd,od,sd,id,ad,cd,ld,ud,pd,fd,md,dd,hd,gd,xd,bd,yd,vd,wd,_d,Cd,kd,Sd,Td,Ed,Id,Ad,Pd,Ld,$d,Rd,Bd,zd,jd,Ud,Fd,Od,Hd,Nd,Gd,qd,Dd,Md,Vd,Kd,Wd,Xd,Jd,Zd,Yd,Qd,eh,th,rh,nh,oh,sh,ih,ah,ch,lh,uh,ph,fh,mh,dh,hh,gh,xh,bh,yh,vh,wh,_h,Ch,kh,Sh,Th,Eh,Ih,Ah,Ph,Lh,$h,Rh,Bh,zh,jh,Uh,Fh,Oh,Hh,Nh,Gh,er,so=P(()=>{rd=2n**(8n-1n)-1n,nd=2n**(16n-1n)-1n,od=2n**(24n-1n)-1n,sd=2n**(32n-1n)-1n,id=2n**(40n-1n)-1n,ad=2n**(48n-1n)-1n,cd=2n**(56n-1n)-1n,ld=2n**(64n-1n)-1n,ud=2n**(72n-1n)-1n,pd=2n**(80n-1n)-1n,fd=2n**(88n-1n)-1n,md=2n**(96n-1n)-1n,dd=2n**(104n-1n)-1n,hd=2n**(112n-1n)-1n,gd=2n**(120n-1n)-1n,xd=2n**(128n-1n)-1n,bd=2n**(136n-1n)-1n,yd=2n**(144n-1n)-1n,vd=2n**(152n-1n)-1n,wd=2n**(160n-1n)-1n,_d=2n**(168n-1n)-1n,Cd=2n**(176n-1n)-1n,kd=2n**(184n-1n)-1n,Sd=2n**(192n-1n)-1n,Td=2n**(200n-1n)-1n,Ed=2n**(208n-1n)-1n,Id=2n**(216n-1n)-1n,Ad=2n**(224n-1n)-1n,Pd=2n**(232n-1n)-1n,Ld=2n**(240n-1n)-1n,$d=2n**(248n-1n)-1n,Rd=2n**(256n-1n)-1n,Bd=-(2n**(8n-1n)),zd=-(2n**(16n-1n)),jd=-(2n**(24n-1n)),Ud=-(2n**(32n-1n)),Fd=-(2n**(40n-1n)),Od=-(2n**(48n-1n)),Hd=-(2n**(56n-1n)),Nd=-(2n**(64n-1n)),Gd=-(2n**(72n-1n)),qd=-(2n**(80n-1n)),Dd=-(2n**(88n-1n)),Md=-(2n**(96n-1n)),Vd=-(2n**(104n-1n)),Kd=-(2n**(112n-1n)),Wd=-(2n**(120n-1n)),Xd=-(2n**(128n-1n)),Jd=-(2n**(136n-1n)),Zd=-(2n**(144n-1n)),Yd=-(2n**(152n-1n)),Qd=-(2n**(160n-1n)),eh=-(2n**(168n-1n)),th=-(2n**(176n-1n)),rh=-(2n**(184n-1n)),nh=-(2n**(192n-1n)),oh=-(2n**(200n-1n)),sh=-(2n**(208n-1n)),ih=-(2n**(216n-1n)),ah=-(2n**(224n-1n)),ch=-(2n**(232n-1n)),lh=-(2n**(240n-1n)),uh=-(2n**(248n-1n)),ph=-(2n**(256n-1n)),fh=2n**8n-1n,mh=2n**16n-1n,dh=2n**24n-1n,hh=2n**32n-1n,gh=2n**40n-1n,xh=2n**48n-1n,bh=2n**56n-1n,yh=2n**64n-1n,vh=2n**72n-1n,wh=2n**80n-1n,_h=2n**88n-1n,Ch=2n**96n-1n,kh=2n**104n-1n,Sh=2n**112n-1n,Th=2n**120n-1n,Eh=2n**128n-1n,Ih=2n**136n-1n,Ah=2n**144n-1n,Ph=2n**152n-1n,Lh=2n**160n-1n,$h=2n**168n-1n,Rh=2n**176n-1n,Bh=2n**184n-1n,zh=2n**192n-1n,jh=2n**200n-1n,Uh=2n**208n-1n,Fh=2n**216n-1n,Oh=2n**224n-1n,Hh=2n**232n-1n,Nh=2n**240n-1n,Gh=2n**248n-1n,er=2n**256n-1n});function tt(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}var Wr=P(()=>{});var $t,tr,rr,io=P(()=>{me();$t=class extends v{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}},tr=class extends v{constructor({length:t,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}},rr=class extends v{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}});function nr(e,{recursiveReadLimit:t=8192}={}){let r=Object.create(wa);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}var wa,Xr=P(()=>{io();wa={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 rr({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new tr({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new $t({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 $t({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 lo,uo=P(()=>{lo={ether:-9,wei:9}});function po(e,t){let r=e.toString(),n=r.startsWith("-");n&&(r=r.slice(1)),r=r.padStart(t,"0");let[o,s]=[r.slice(0,r.length-t),r.slice(r.length-t)];return s=s.replace(/(0+)$/,""),`${n?"-":""}${o||"0"}${s?`.${s}`:""}`}var fo=P(()=>{});function Rt(e,t="wei"){return po(e,lo[t])}var mo=P(()=>{uo();fo()});function ka(e){let t=Object.entries(e).map(([n,o])=>o===void 0||o===!1?null:[n,o]).filter(Boolean),r=t.reduce((n,[o])=>Math.max(n,o.length),0);return t.map(([n,o])=>` ${`${n}:`.padEnd(r+1)} ${o}`).join(`
8
- `)}var or,sr,ir,ar=P(()=>{me();or=class extends v{constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}},sr=class extends v{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",ka(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"})}},ir=class extends v{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 Sa(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Jr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function rt(e,...t){if(!Sa(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 mt(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 ur(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 go(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ge(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function pr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ye(e,t){return e<<32-t|e>>>t}function Ea(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Ia(e){for(let t=0;t<e.length;t++)e[t]=Ea(e[t]);return e}function Aa(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Bt(e){return typeof e=="string"&&(e=Aa(e)),rt(e),e}function fr(e){let t=n=>e().update(Bt(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}var Ta,Zr,ft,mr=P(()=>{Ta=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;Zr=Ta?e=>e:Ia;ft=class{}});function La(e,t=!1){return t?{h:Number(e&hr),l:Number(e>>yo&hr)}:{h:Number(e>>yo&hr)|0,l:Number(e&hr)|0}}function vo(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=La(e[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var hr,yo,wo,_o,Co,ko,So=P(()=>{hr=BigInt(4294967295),yo=BigInt(32);wo=(e,t,r)=>e<<r|t>>>32-r,_o=(e,t,r)=>t<<r|e>>>32-r,Co=(e,t,r)=>t<<r-32|e>>>64-r,ko=(e,t,r)=>e<<r-32|t>>>64-r});var ge,vr=P(()=>{me();ge=class extends v{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 nt,Ro=P(()=>{me();nt=class extends v{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}});var wr,ot,Yr,Qr,en,tn,rn,nn,on,sn,zt,Bo=P(()=>{mo();me();wr=class extends v{constructor({cause:t,message:r}={}){let n=r?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${n?`with reason: ${n}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"})}};Object.defineProperty(wr,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(wr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});ot=class extends v{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${Rt(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}};Object.defineProperty(ot,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});Yr=class extends v{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${Rt(r)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}};Object.defineProperty(Yr,"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/});Qr=class extends v{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(Qr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});en=class extends v{constructor({cause:t,nonce:r}={}){super([`Nonce provided for the transaction ${r?`(${r}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
9
- `),{cause:t,name:"NonceTooLowError"})}};Object.defineProperty(en,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});tn=class extends v{constructor({cause:t,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}exceeds the maximum allowed nonce.`,{cause:t,name:"NonceMaxValueError"})}};Object.defineProperty(tn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});rn=class extends v{constructor({cause:t}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
10
- `),{cause:t,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}};Object.defineProperty(rn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});nn=class extends v{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(nn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});on=class extends v{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(on,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});sn=class extends v{constructor({cause:t}){super("The transaction type is not supported for this chain.",{cause:t,name:"TransactionTypeNotSupportedError"})}};Object.defineProperty(sn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});zt=class extends v{constructor({cause:t,maxPriorityFeePerGas:r,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${Rt(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${Rt(n)} gwei`:""}).`].join(`
11
- `),{cause:t,name:"TipAboveFeeCapError"})}};Object.defineProperty(zt,"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 ht,an=P(()=>{ht=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 n=this.keys().next().value;n&&this.delete(n)}return this}}});function Ga(e,t=24){let r=new Uint32Array(10);for(let n=24-t;n<24;n++){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],p=r[l+1],f=zo(u,p,1)^r[a],h=jo(u,p,1)^r[a+1];for(let g=0;g<50;g+=10)e[i+g]^=f,e[i+g+1]^=h}let o=e[2],s=e[3];for(let i=0;i<24;i++){let a=Fo[i],l=zo(o,s,a),u=jo(o,s,a),p=Uo[i];o=e[p],s=e[p+1],e[p]=l,e[p+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]^=Ha[n],e[1]^=Na[n]}Ge(r)}var za,jt,ja,Ua,Fa,Oa,Uo,Fo,Oo,Ho,Ha,Na,zo,jo,cn,qa,No,Go=P(()=>{So();mr();za=BigInt(0),jt=BigInt(1),ja=BigInt(2),Ua=BigInt(7),Fa=BigInt(256),Oa=BigInt(113),Uo=[],Fo=[],Oo=[];for(let e=0,t=jt,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],Uo.push(2*(5*n+r)),Fo.push((e+1)*(e+2)/2%64);let o=za;for(let s=0;s<7;s++)t=(t<<jt^(t>>Ua)*Oa)%Fa,t&ja&&(o^=jt<<(jt<<BigInt(s))-jt);Oo.push(o)}Ho=vo(Oo,!0),Ha=Ho[0],Na=Ho[1],zo=(e,t,r)=>r>32?Co(e,t,r):wo(e,t,r),jo=(e,t,r)=>r>32?ko(e,t,r):_o(e,t,r);cn=class e extends ft{constructor(t,r,n,o=!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=n,this.enableXOF=o,this.rounds=s,Jr(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=go(this.state)}clone(){return this._cloneInto()}keccak(){Zr(this.state32),Ga(this.state32,this.rounds),Zr(this.state32),this.posOut=0,this.pos=0}update(t){mt(this),t=Bt(t),rt(t);let{blockLen:r,state:n}=this,o=t.length;for(let s=0;s<o;){let i=Math.min(r-this.pos,o-s);for(let a=0;a<i;a++)n[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:n,blockLen:o}=this;t[n]^=r,(r&128)!==0&&n===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){mt(this,!1),rt(t),this.finish();let r=this.state,{blockLen:n}=this;for(let o=0,s=t.length;o<s;){this.posOut>=n&&this.keccak();let i=Math.min(n-this.posOut,s-o);t.set(r.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=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 Jr(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(ur(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,Ge(this.state)}_cloneInto(t){let{blockLen:r,suffix:n,outputLen:o,rounds:s,enableXOF:i}=this;return t||(t=new e(r,n,o,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=n,t.outputLen=o,t.enableXOF=i,t.destroyed=this.destroyed,t}},qa=(e,t,r)=>fr(()=>new cn(t,e,r)),No=qa(1,136,256/8)});function qo(e,t){let r=t||"hex",n=No(Ce(e,{strict:!1})?Yt(e):e);return r==="bytes"?n:xe(n)}var Do=P(()=>{Go();lt();Ne();he()});function Mo(e,t){if(ln.has(`${e}.${t}`))return ln.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),n=qo(Vr(r),"bytes"),o=(t?r.substring(`${t}0x`.length):r).split("");for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&o[i]&&(o[i]=o[i].toUpperCase()),(n[i>>1]&15)>=8&&o[i+1]&&(o[i+1]=o[i+1].toUpperCase());let s=`0x${o.join("")}`;return ln.set(`${e}.${t}`,s),s}var ln,Vo=P(()=>{Ne();Do();an();ln=new ht(8192)});function ke(e,t){let{strict:r=!0}=t??{},n=`${e}.${r}`;if(un.has(n))return un.get(n);let o=Da.test(e)?e.toLowerCase()===e?!0:r?Mo(e)===e:!0:!1;return un.set(n,o),o}var Da,un,_r=P(()=>{an();Vo();Da=/^0x[a-fA-F0-9]{40}$/,un=new ht(8192)});function Ko(e,t,r,{strict:n}={}){return Ce(e,{strict:!1})?Va(e,t,r,{strict:n}):Ma(e,t,r,{strict:n})}function Wo(e,t){if(typeof t=="number"&&t>0&&t>de(e)-1)throw new At({offset:t,position:"start",size:de(e)})}function Xo(e,t,r){if(typeof t=="number"&&typeof r=="number"&&de(e)!==r-t)throw new At({offset:r,position:"end",size:de(e)})}function Ma(e,t,r,{strict:n}={}){Wo(e,t);let o=e.slice(t,r);return n&&Xo(o,t,r),o}function Va(e,t,r,{strict:n}={}){Wo(e,t);let o=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return n&&Xo(o,t,r),o}var Jo=P(()=>{Dr();lt();Et()});var dn=re(Ht=>{"use strict";var nc=Ht&&Ht.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ht,"__esModule",{value:!0});Ht.encryptEnvVars=ic;var fn=Re("@noble/curves/ed25519"),mn=nc(Re("crypto"));function oc(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(n=>parseInt(n,16)))!==null&&r!==void 0?r:[])}function sc(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function ic(e,t){let r=JSON.stringify({env:e}),n=fn.x25519.utils.randomPrivateKey(),o=fn.x25519.getPublicKey(n),s=oc(t),i=fn.x25519.getSharedSecret(n,s),a=await mn.default.subtle.importKey("raw",i,{name:"AES-GCM",length:256},!0,["encrypt"]),l=mn.default.getRandomValues(new Uint8Array(12)),u=await mn.default.subtle.encrypt({name:"AES-GCM",iv:l},a,new TextEncoder().encode(r)),p=new Uint8Array(o.length+l.length+u.byteLength);return p.set(o),p.set(l,o.length),p.set(new Uint8Array(u),o.length+l.length),sc(p)}});var is=re(Nt=>{"use strict";var ac=Nt&&Nt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Nt,"__esModule",{value:!0});Nt.getComposeHash=pc;var cc=ac(Re("crypto"));function hn(e){return e==null?e:Array.isArray(e)?e.map(hn):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let n=e[r];return t[r]=hn(n),t},{}):e}function lc(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 uc(e){let t=hn(e);return JSON.stringify(t,(r,n)=>typeof n=="number"&&(isNaN(n)||!isFinite(n))?null:n)}function pc(e,t=!1){t&&(e=lc(e));let r=uc(e);return cc.default.createHash("sha256").update(r,"utf8").digest("hex")}});var Is=re(w=>{"use strict";Object.defineProperty(w,"__esModule",{value:!0});w.toBig=w.shrSL=w.shrSH=w.rotrSL=w.rotrSH=w.rotrBL=w.rotrBH=w.rotr32L=w.rotr32H=w.rotlSL=w.rotlSH=w.rotlBL=w.rotlBH=w.add5L=w.add5H=w.add4L=w.add4H=w.add3L=w.add3H=void 0;w.add=ws;w.fromBig=xn;w.split=as;var Tr=BigInt(2**32-1),gn=BigInt(32);function xn(e,t=!1){return t?{h:Number(e&Tr),l:Number(e>>gn&Tr)}:{h:Number(e>>gn&Tr)|0,l:Number(e&Tr)|0}}function as(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=xn(e[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var cs=(e,t)=>BigInt(e>>>0)<<gn|BigInt(t>>>0);w.toBig=cs;var ls=(e,t,r)=>e>>>r;w.shrSH=ls;var us=(e,t,r)=>e<<32-r|t>>>r;w.shrSL=us;var ps=(e,t,r)=>e>>>r|t<<32-r;w.rotrSH=ps;var fs=(e,t,r)=>e<<32-r|t>>>r;w.rotrSL=fs;var ms=(e,t,r)=>e<<64-r|t>>>r-32;w.rotrBH=ms;var ds=(e,t,r)=>e>>>r-32|t<<64-r;w.rotrBL=ds;var hs=(e,t)=>t;w.rotr32H=hs;var gs=(e,t)=>e;w.rotr32L=gs;var xs=(e,t,r)=>e<<r|t>>>32-r;w.rotlSH=xs;var bs=(e,t,r)=>t<<r|e>>>32-r;w.rotlSL=bs;var ys=(e,t,r)=>t<<r-32|e>>>64-r;w.rotlBH=ys;var vs=(e,t,r)=>e<<r-32|t>>>64-r;w.rotlBL=vs;function ws(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var _s=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);w.add3L=_s;var Cs=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;w.add3H=Cs;var ks=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);w.add4L=ks;var Ss=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0;w.add4H=Ss;var Ts=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0);w.add5L=Ts;var Es=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;w.add5H=Es;var fc={fromBig:xn,split:as,toBig:cs,shrSH:ls,shrSL:us,rotrSH:ps,rotrSL:fs,rotrBH:ms,rotrBL:ds,rotr32H:hs,rotr32L:gs,rotlSH:xs,rotlSL:bs,rotlBH:ys,rotlBL:vs,add:ws,add3L:_s,add3H:Cs,add4L:ks,add4H:Ss,add5H:Es,add5L:Ts};w.default=fc});var As=re(Er=>{"use strict";Object.defineProperty(Er,"__esModule",{value:!0});Er.crypto=void 0;var De=Re("crypto");Er.crypto=De&&typeof De=="object"&&"webcrypto"in De?De.webcrypto:De&&typeof De=="object"&&"randomBytes"in De?De:void 0});var Us=re(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.wrapXOFConstructorWithOpts=x.wrapConstructorWithOpts=x.wrapConstructor=x.Hash=x.nextTick=x.swap32IfBE=x.byteSwapIfBE=x.swap8IfBE=x.isLE=void 0;x.isBytes=Ls;x.anumber=bn;x.abytes=xt;x.ahash=mc;x.aexists=dc;x.aoutput=hc;x.u8=gc;x.u32=xc;x.clean=bc;x.createView=yc;x.rotr=vc;x.rotl=wc;x.byteSwap=vn;x.byteSwap32=$s;x.bytesToHex=Cc;x.hexToBytes=kc;x.asyncLoop=Tc;x.utf8ToBytes=wn;x.bytesToUtf8=Ec;x.toBytes=Ir;x.kdfInputToBytes=Ic;x.concatBytes=Ac;x.checkOpts=Pc;x.createHasher=Bs;x.createOptHasher=zs;x.createXOFer=js;x.randomBytes=Lc;var gt=As();function Ls(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function bn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function xt(e,...t){if(!Ls(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function mc(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");bn(e.outputLen),bn(e.blockLen)}function dc(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 hc(e,t){xt(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function gc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function xc(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function bc(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function yc(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function vc(e,t){return e<<32-t|e>>>t}function wc(e,t){return e<<t|e>>>32-t>>>0}x.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function vn(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}x.swap8IfBE=x.isLE?e=>e:e=>vn(e);x.byteSwapIfBE=x.swap8IfBE;function $s(e){for(let t=0;t<e.length;t++)e[t]=vn(e[t]);return e}x.swap32IfBE=x.isLE?e=>e:$s;var Rs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",_c=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Cc(e){if(xt(e),Rs)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=_c[e[r]];return t}var Ue={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ps(e){if(e>=Ue._0&&e<=Ue._9)return e-Ue._0;if(e>=Ue.A&&e<=Ue.F)return e-(Ue.A-10);if(e>=Ue.a&&e<=Ue.f)return e-(Ue.a-10)}function kc(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Rs)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 n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=Ps(e.charCodeAt(s)),a=Ps(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)}n[o]=i*16+a}return n}var Sc=async()=>{};x.nextTick=Sc;async function Tc(e,t,r){let n=Date.now();for(let o=0;o<e;o++){r(o);let s=Date.now()-n;s>=0&&s<t||(await(0,x.nextTick)(),n+=s)}}function wn(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Ec(e){return new TextDecoder().decode(e)}function Ir(e){return typeof e=="string"&&(e=wn(e)),xt(e),e}function Ic(e){return typeof e=="string"&&(e=wn(e)),xt(e),e}function Ac(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];xt(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}function Pc(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 yn=class{};x.Hash=yn;function Bs(e){let t=n=>e().update(Ir(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function zs(e){let t=(n,o)=>e(o).update(Ir(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}function js(e){let t=(n,o)=>e(o).update(Ir(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}x.wrapConstructor=Bs;x.wrapConstructorWithOpts=zs;x.wrapXOFConstructorWithOpts=js;function Lc(e=32){if(gt.crypto&&typeof gt.crypto.getRandomValues=="function")return gt.crypto.getRandomValues(new Uint8Array(e));if(gt.crypto&&typeof gt.crypto.randomBytes=="function")return Uint8Array.from(gt.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}});var Vs=re(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});z.shake256=z.shake128=z.keccak_512=z.keccak_384=z.keccak_256=z.keccak_224=z.sha3_512=z.sha3_384=z.sha3_256=z.sha3_224=z.Keccak=void 0;z.keccakP=Ds;var qt=Is(),W=Us(),$c=BigInt(0),Gt=BigInt(1),Rc=BigInt(2),Bc=BigInt(7),zc=BigInt(256),jc=BigInt(113),Hs=[],Ns=[],Gs=[];for(let e=0,t=Gt,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],Hs.push(2*(5*n+r)),Ns.push((e+1)*(e+2)/2%64);let o=$c;for(let s=0;s<7;s++)t=(t<<Gt^(t>>Bc)*jc)%zc,t&Rc&&(o^=Gt<<(Gt<<BigInt(s))-Gt);Gs.push(o)}var qs=(0,qt.split)(Gs,!0),Uc=qs[0],Fc=qs[1],Fs=(e,t,r)=>r>32?(0,qt.rotlBH)(e,t,r):(0,qt.rotlSH)(e,t,r),Os=(e,t,r)=>r>32?(0,qt.rotlBL)(e,t,r):(0,qt.rotlSL)(e,t,r);function Ds(e,t=24){let r=new Uint32Array(10);for(let n=24-t;n<24;n++){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],p=r[l+1],f=Fs(u,p,1)^r[a],h=Os(u,p,1)^r[a+1];for(let g=0;g<50;g+=10)e[i+g]^=f,e[i+g+1]^=h}let o=e[2],s=e[3];for(let i=0;i<24;i++){let a=Ns[i],l=Fs(o,s,a),u=Os(o,s,a),p=Hs[i];o=e[p],s=e[p+1],e[p]=l,e[p+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]^=Uc[n],e[1]^=Fc[n]}(0,W.clean)(r)}var Dt=class e extends W.Hash{constructor(t,r,n,o=!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=n,this.enableXOF=o,this.rounds=s,(0,W.anumber)(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=(0,W.u32)(this.state)}clone(){return this._cloneInto()}keccak(){(0,W.swap32IfBE)(this.state32),Ds(this.state32,this.rounds),(0,W.swap32IfBE)(this.state32),this.posOut=0,this.pos=0}update(t){(0,W.aexists)(this),t=(0,W.toBytes)(t),(0,W.abytes)(t);let{blockLen:r,state:n}=this,o=t.length;for(let s=0;s<o;){let i=Math.min(r-this.pos,o-s);for(let a=0;a<i;a++)n[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:n,blockLen:o}=this;t[n]^=r,(r&128)!==0&&n===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){(0,W.aexists)(this,!1),(0,W.abytes)(t),this.finish();let r=this.state,{blockLen:n}=this;for(let o=0,s=t.length;o<s;){this.posOut>=n&&this.keccak();let i=Math.min(n-this.posOut,s-o);t.set(r.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=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,W.anumber)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,W.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,W.clean)(this.state)}_cloneInto(t){let{blockLen:r,suffix:n,outputLen:o,rounds:s,enableXOF:i}=this;return t||(t=new e(r,n,o,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=n,t.outputLen=o,t.enableXOF=i,t.destroyed=this.destroyed,t}};z.Keccak=Dt;var Me=(e,t,r)=>(0,W.createHasher)(()=>new Dt(t,e,r));z.sha3_224=Me(6,144,224/8);z.sha3_256=Me(6,136,256/8);z.sha3_384=Me(6,104,384/8);z.sha3_512=Me(6,72,512/8);z.keccak_224=Me(1,144,224/8);z.keccak_256=Me(1,136,256/8);z.keccak_384=Me(1,104,384/8);z.keccak_512=Me(1,72,512/8);var Ms=(e,t,r)=>(0,W.createXOFer)((n={})=>new Dt(t,e,n.dkLen===void 0?r:n.dkLen,!0));z.shake128=Ms(31,168,128/8);z.shake256=Ms(31,136,256/8)});var Ks=re(_n=>{"use strict";Object.defineProperty(_n,"__esModule",{value:!0});_n.verifyEnvEncryptPublicKey=Nc;var Oc=Vs(),Hc=Re("@noble/curves/secp256k1");function Nc(e,t,r){if(t.length!==65)return null;let n=Buffer.from("dstack-env-encrypt-pubkey","utf8"),o=r;r.startsWith("0x")&&(o=r.slice(2));let s=Buffer.from(o,"hex"),i=Buffer.from(":","utf8"),a=Buffer.concat([n,i,s,Buffer.from(e)]),l=(0,Oc.keccak_256)(a);try{let u=t.slice(0,32),p=t.slice(32,64),f=t[64],h=new Uint8Array(64);h.set(u,0),h.set(p,32);let g=Hc.secp256k1.Signature.fromCompact(h).addRecoveryBit(f).recoverPublicKey(l);return"0x"+Buffer.from(g.toRawBytes(!0)).toString("hex")}catch(u){return console.error("signature verification failed:",u),null}}});var ti=Tt(Xn(),1);import{ofetch as Gc}from"ofetch";function Jn(e){return{all:e=e||new Map,on:function(t,r){var n=e.get(t);n?n.push(r):e.set(t,[r])},off:function(t,r){var n=e.get(t);n&&(r?n.splice(n.indexOf(r)>>>0,1):e.set(t,[]))},emit:function(t,r){var n=e.get(t);n&&n.slice().map(function(o){o(r)}),(n=e.get("*"))&&n.slice().map(function(o){o(t,r)})}}}import{z as M}from"zod";import{z as j}from"zod";import{z as Ve}from"zod";import{z as k}from"zod";import{z as Ke}from"zod";function Ze(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}Qt();Ye();Qt();var Kr={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function Lt(e,t){let r={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?et(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?et(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Kr[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=xa(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 to=ut("transaction",Lt);function xa(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 ba(e,t){let r=(e.transactions??[]).map(n=>typeof n=="string"?n:Lt(n));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:r,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}var ro=ut("block",ba);function no(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}:{}}}Ye();Qt();var ya={"0x0":"reverted","0x1":"success"};function va(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(n=>no(n)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?et(e.transactionIndex):null,status:e.status?ya[e.status]:null,type:e.type?Kr[e.type]||e.type:null};return e.blobGasPrice&&(r.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(r.blobGasUsed=BigInt(e.blobGasUsed)),r}var oo=ut("transactionReceipt",va);me();Xr();Ne();he();function ze(e,t="hex"){let r=ao(e),n=nr(new Uint8Array(r.length));return r.encode(n),t==="hex"?oe(n.bytes):n.bytes}function ao(e){return Array.isArray(e)?_a(e.map(t=>ao(t))):Ca(e)}function _a(e){let t=e.reduce((o,s)=>o+s.length,0),r=co(t);return{length:t<=55?1+t:1+r+t,encode(o){t<=55?o.pushByte(192+t):(o.pushByte(247+r),r===1?o.pushUint8(t):r===2?o.pushUint16(t):r===3?o.pushUint24(t):o.pushUint32(t));for(let{encode:s}of e)s(o)}}}function Ca(e){let t=typeof e=="string"?be(e):e,r=co(t.length);return{length:t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+r+t.length,encode(o){t.length===1&&t[0]<128?o.pushBytes(t):t.length<=55?(o.pushByte(128+t.length),o.pushBytes(t)):(o.pushByte(183+r),r===1?o.pushUint8(t.length):r===2?o.pushUint16(t.length):r===3?o.pushUint24(t.length):o.pushUint32(t.length),o.pushBytes(t))}}}function co(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 v("Length is too large.")}ar();he();function ho(e){if(!e||e.length===0)return[];let t=[];for(let r of e){let{chainId:n,nonce:o,...s}=r,i=r.address;t.push([n?xe(n):"0x",i,o?xe(o):"0x",...pt({},s)])}return t}Ne();he();function cr(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(s=>be(s)):e.blobs,o=[];for(let s of n)o.push(Uint8Array.from(t.blobToKzgCommitment(s)));return r==="bytes"?o:o.map(s=>oe(s))}Ne();he();function lr(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(i=>be(i)):e.blobs,o=typeof e.commitments[0]=="string"?e.commitments.map(i=>be(i)):e.commitments,s=[];for(let i=0;i<n.length;i++){let a=n[i],l=o[i];s.push(Uint8Array.from(t.computeBlobKzgProof(a,l)))}return r==="bytes"?s:s.map(i=>oe(i))}he();mr();function Pa(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(r>>o&s),a=Number(r&s),l=n?4:0,u=n?0:4;e.setUint32(t+l,i,n),e.setUint32(t+u,a,n)}function xo(e,t,r){return e&t^~e&r}function bo(e,t,r){return e&t^e&r^t&r}var dr=class extends ft{constructor(t,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=pr(this.buffer)}update(t){mt(this),t=Bt(t),rt(t);let{view:r,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let l=pr(t);for(;o<=s-i;i+=o)this.process(l,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){mt(this),ur(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,Ge(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let f=i;f<o;f++)r[f]=0;Pa(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=pr(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=l/4,p=this.get();if(u>p.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)a.setUint32(4*f,p[f],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=a,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},je=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);mr();var $a=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]),qe=new Uint32Array(64),gr=class extends dr{constructor(t=32){super(64,t,8,!1),this.A=je[0]|0,this.B=je[1]|0,this.C=je[2]|0,this.D=je[3]|0,this.E=je[4]|0,this.F=je[5]|0,this.G=je[6]|0,this.H=je[7]|0}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:a,H:l}=this;return[t,r,n,o,s,i,a,l]}set(t,r,n,o,s,i,a,l){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=l|0}process(t,r){for(let f=0;f<16;f++,r+=4)qe[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let h=qe[f-15],g=qe[f-2],_=ye(h,7)^ye(h,18)^h>>>3,I=ye(g,17)^ye(g,19)^g>>>10;qe[f]=I+qe[f-7]+_+qe[f-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:l,G:u,H:p}=this;for(let f=0;f<64;f++){let h=ye(a,6)^ye(a,11)^ye(a,25),g=p+h+xo(a,l,u)+$a[f]+qe[f]|0,I=(ye(n,2)^ye(n,13)^ye(n,22))+bo(n,o,s)|0;p=u,u=l,l=a,a=i+g|0,i=s,s=o,o=n,n=g+I|0}n=n+this.A|0,o=o+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,p=p+this.H|0,this.set(n,o,s,i,a,l,u,p)}roundClean(){Ge(qe)}destroy(){this.set(0,0,0,0,0,0,0,0),Ge(this.buffer)}};var To=fr(()=>new gr);var Eo=To;lt();Ne();he();function Io(e,t){let r=t||"hex",n=Eo(Ce(e,{strict:!1})?Yt(e):e);return r==="bytes"?n:xe(n)}function Ao(e){let{commitment:t,version:r=1}=e,n=e.to??(typeof t=="string"?"hex":"bytes"),o=Io(t,"bytes");return o.set([r],0),n==="bytes"?o:oe(o)}function Po(e){let{commitments:t,version:r}=e,n=e.to??(typeof t[0]=="string"?"hex":"bytes"),o=[];for(let s of t)o.push(Ao({commitment:s,to:n,version:r}));return o}me();var xr=class extends v{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}},dt=class extends v{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}},br=class extends v{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}},yr=class extends v{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${1}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}};Xr();Et();Ne();he();function Lo(e){let t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?be(e.data):e.data,n=de(r);if(!n)throw new dt;if(n>761855)throw new xr({maxSize:761855,size:n});let o=[],s=!0,i=0;for(;s;){let a=nr(new Uint8Array(131072)),l=0;for(;l<4096;){let u=r.slice(i,i+31);if(a.pushByte(0),a.pushBytes(u),u.length<31){a.pushByte(128),s=!1;break}l++,i+=31}o.push(a)}return t==="bytes"?o.map(a=>a.bytes):o.map(a=>oe(a.bytes))}function $o(e){let{data:t,kzg:r,to:n}=e,o=e.blobs??Lo({data:t,to:n}),s=e.commitments??cr({blobs:o,kzg:r,to:n}),i=e.proofs??lr({blobs:o,commitments:s,kzg:r,to:n}),a=[];for(let l=0;l<o.length;l++)a.push({blob:o[l],commitment:s[l],proof:i[l]});return a}Wr();Qn();he();so();vr();me();Ro();Bo();_r();Et();Jo();Ye();function Zo(e){let{authorizationList:t}=e;if(t)for(let r of t){let{chainId:n}=r,o=r.address;if(!ke(o))throw new ge({address:o});if(n<0)throw new nt({chainId:n})}Cr(e)}function Yo(e){let{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new dt;for(let r of t){let n=de(r),o=et(Ko(r,0,1));if(n!==32)throw new br({hash:r,size:n});if(o!==1)throw new yr({hash:r,version:o})}}Cr(e)}function Cr(e){let{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:n,to:o}=e;if(t<=0)throw new nt({chainId:t});if(o&&!ke(o))throw new ge({address:o});if(n&&n>er)throw new ot({maxFeePerGas:n});if(r&&n&&r>n)throw new zt({maxFeePerGas:n,maxPriorityFeePerGas:r})}function Qo(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:o,to:s}=e;if(t<=0)throw new nt({chainId:t});if(s&&!ke(s))throw new ge({address:s});if(r||o)throw new v("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(n&&n>er)throw new ot({maxFeePerGas:n})}function es(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:o,to:s}=e;if(s&&!ke(s))throw new ge({address:s});if(typeof t<"u"&&t<=0)throw new nt({chainId:t});if(r||o)throw new v("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(n&&n>er)throw new ot({maxFeePerGas:n})}ar();function ts(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 sr({transaction:e})}vr();ar();_r();function Ut(e){if(!e||e.length===0)return[];let t=[];for(let r=0;r<e.length;r++){let{address:n,storageKeys:o}=e[r];for(let s=0;s<o.length;s++)if(o[s].length-2!==64)throw new ir({storageKey:o[s]});if(!ke(n,{strict:!1}))throw new ge({address:n});t.push([n,o])}return t}function rs(e,t){let r=ts(e);return r==="eip1559"?Xa(e,t):r==="eip2930"?Ja(e,t):r==="eip4844"?Wa(e,t):r==="eip7702"?Ka(e,t):Za(e,t)}function Ka(e,t){let{authorizationList:r,chainId:n,gas:o,nonce:s,to:i,value:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:p,data:f}=e;Zo(e);let h=Ut(p),g=ho(r);return tt(["0x04",ze([S(n),s?S(s):"0x",u?S(u):"0x",l?S(l):"0x",o?S(o):"0x",i??"0x",a?S(a):"0x",f??"0x",h,g,...pt(e,t)])])}function Wa(e,t){let{chainId:r,gas:n,nonce:o,to:s,value:i,maxFeePerBlobGas:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:p,data:f}=e;Yo(e);let h=e.blobVersionedHashes,g=e.sidecars;if(e.blobs&&(typeof h>"u"||typeof g>"u")){let K=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(pe=>oe(pe)),Z=e.kzg,te=cr({blobs:K,kzg:Z});if(typeof h>"u"&&(h=Po({commitments:te})),typeof g>"u"){let pe=lr({blobs:K,commitments:te,kzg:Z});g=$o({blobs:K,commitments:te,proofs:pe})}}let _=Ut(p),I=[S(r),o?S(o):"0x",u?S(u):"0x",l?S(l):"0x",n?S(n):"0x",s??"0x",i?S(i):"0x",f??"0x",_,a?S(a):"0x",h??[],...pt(e,t)],R=[],G=[],J=[];if(g)for(let K=0;K<g.length;K++){let{blob:Z,commitment:te,proof:pe}=g[K];R.push(Z),G.push(te),J.push(pe)}return tt(["0x03",g?ze([I,R,G,J]):ze(I)])}function Xa(e,t){let{chainId:r,gas:n,nonce:o,to:s,value:i,maxFeePerGas:a,maxPriorityFeePerGas:l,accessList:u,data:p}=e;Cr(e);let f=Ut(u),h=[S(r),o?S(o):"0x",l?S(l):"0x",a?S(a):"0x",n?S(n):"0x",s??"0x",i?S(i):"0x",p??"0x",f,...pt(e,t)];return tt(["0x02",ze(h)])}function Ja(e,t){let{chainId:r,gas:n,data:o,nonce:s,to:i,value:a,accessList:l,gasPrice:u}=e;Qo(e);let p=Ut(l),f=[S(r),s?S(s):"0x",u?S(u):"0x",n?S(n):"0x",i??"0x",a?S(a):"0x",o??"0x",p,...pt(e,t)];return tt(["0x01",ze(f)])}function Za(e,t){let{chainId:r=0,gas:n,data:o,nonce:s,to:i,value:a,gasPrice:l}=e;es(e);let u=[s?S(s):"0x",l?S(l):"0x",n?S(n):"0x",i??"0x",a?S(a):"0x",o??"0x"];if(t){let p=(()=>{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 g=27n+(t.v===27n?0n:1n);if(t.v!==g)throw new or({v:t.v});return g})(),f=It(t.r),h=It(t.s);u=[...u,S(p),f==="0x00"?"0x":f,h==="0x00"?"0x":h]}else r>0&&(u=[...u,S(r),"0x","0x"]);return ze(u)}function pt(e,t){let r=t??e,{v:n,yParity:o}=r;if(typeof r.r>"u")return[];if(typeof r.s>"u")return[];if(typeof n>"u"&&typeof o>"u")return[];let s=It(r.r),i=It(r.s);return[typeof o=="number"?o?S(1):"0x":n===0n?"0x":n===1n?S(1):n===27n?"0x":S(1),s==="0x00"?"0x":s,i==="0x00"?"0x":i]}var ns={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};Ye();var os={block:ro({format(e){return{transactions:e.transactions?.map(r=>{if(typeof r=="string")return r;let n=Lt(r);return n.typeHex==="0x7e"&&(n.isSystemTx=r.isSystemTx,n.mint=r.mint?Qe(r.mint):void 0,n.sourceHash=r.sourceHash,n.type="deposit"),n}),stateRoot:e.stateRoot}}}),transaction:to({format(e){let t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?Qe(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:oo({format(e){return{l1GasPrice:e.l1GasPrice?Qe(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?Qe(e.l1GasUsed):null,l1Fee:e.l1Fee?Qe(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};vr();_r();Wr();he();function Ya(e,t){return ec(e)?Qa(e):rs(e,t)}var ss={transaction:Ya};function Qa(e){tc(e);let{sourceHash:t,data:r,from:n,gas:o,isSystemTx:s,mint:i,to:a,value:l}=e,u=[t,n,a??"0x",i?xe(i):"0x",l?xe(l):"0x",o?xe(o):"0x",s?"0x1":"0x",r??"0x"];return tt(["0x7e",ze(u)])}function ec(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function tc(e){let{from:t,to:r}=e;if(t&&!ke(t))throw new ge({address:t});if(r&&!ke(r))throw new ge({address:r})}var pn={blockTime:2e3,contracts:ns,formatters:os,serializers:ss};var kr=Ze({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 Ft=1,Ot=Ze({...pn,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:{...pn.contracts,disputeGameFactory:{[Ft]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[Ft]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[Ft]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[Ft]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:Ft}),rc=Ze({...Ot,experimental_preconfirmationTime:200,rpcUrls:{default:{http:["https://mainnet-preconf.base.org"]}}});var Sr=Ze({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 H}from"zod";import{z as ue}from"zod";import{z as m}from"zod";import{z as d}from"zod";import{z as yt}from"zod";import{z as vt}from"zod";import{z as C}from"zod";import{z as T}from"zod";import{z as Y}from"zod";import cu from"crypto";import{z as Ee}from"zod";import{z as ve}from"zod";import{z as V}from"zod";import{z as ie}from"zod";import{z as ae}from"zod";import{z as Hu}from"zod";import{z as Xs}from"zod";import{z as Ie}from"zod";import{z as kt}from"zod";import{z as st}from"zod";import{z as B}from"zod";import{z as dp}from"zod";import{z as bp}from"zod";import{z as L}from"zod";import{z as Te}from"zod";import{z as Rp}from"zod";import{z as O}from"zod";import{z as y}from"zod";import{z as _t}from"zod";import{z as Js}from"zod";import{z as X}from"zod";import{z as bi}from"zod";import{z as Se}from"zod";import{z as b}from"zod";import{z as $}from"zod";import{z as A}from"zod";import{z as N}from"zod";var Ub=Tt(dn(),1);import{z as F}from"zod";var $f=Tt(dn(),1),Rf=Tt(is(),1),Bf=Tt(Ks(),1);import{z as se}from"zod";import{z as we}from"zod";import{z as wt}from"zod";import{z as Q}from"zod";import{z as le}from"zod";import{z as Qs}from"zod";import{z as ei}from"zod";import{z as Ar}from"zod";import{z as Pr}from"zod";var qc=M.object({detail:M.union([M.string(),M.array(M.object({msg:M.string(),type:M.string().optional(),ctx:M.record(M.unknown()).optional(),loc:M.array(M.union([M.string(),M.number()])).optional(),input:M.unknown().optional()}).passthrough()),M.record(M.unknown())]).optional(),type:M.string().optional(),code:M.string().optional()}),Ae=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)}},Cn=class Lr extends Ae{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=qc.safeParse(t.data);return r.success?new Lr(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 Lr(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 Lr(t.message,{request:r??void 0,detail:t.message})}},Dc=class extends Ae{constructor(e,t){super(e,t),this.isValidationError=!0,this.validationErrors=t.validationErrors}},Mc=class extends Ae{constructor(){super(...arguments),this.isAuthError=!0}},ri=class extends Ae{constructor(){super(...arguments),this.isBusinessError=!0}},Vc=class extends Ae{constructor(){super(...arguments),this.isServerError=!0}},Kc=class extends Ae{constructor(){super(...arguments),this.isUnknownError=!0}};function Wc(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 ni(e){if(!Array.isArray(e))return{errors:[],message:typeof e=="string"?e:"Validation error"};let t=e.map((o,s)=>{let i=Wc(o.loc),a=i;return i==="unknown"&&o.type&&(a=o.type==="missing"?"required field":o.type),{field:a,message:o.msg,type:o.type,context:o.ctx}}),r=t.length,n=r===1?`Validation failed: ${t[0].message}`:`Validation failed (${r} issue${r>1?"s":""})`;return{errors:t,message:n}}function Xc(e){return e===422?"validation":e===401||e===403?"auth":e>=400&&e<500?"business":e>=500?"server":"unknown"}function Jc(e,t,r){if(e===422&&Array.isArray(t)){let{message:n}=ni(t);return n}if(typeof t=="string")return t;if(t&&typeof t=="object"&&"message"in t){let n=t.message;if(typeof n=="string")return n}return r}function Zc(e){let t=e.status??0,r=e.statusText??"Unknown Error",n=e.detail,o=Qc(n);if(o)return new Yc(o.message,{status:t,statusText:r,detail:n,errorCode:o.error_code,structuredDetails:o.details,suggestions:o.suggestions,links:o.links});let s=Xc(t),i=Jc(t,n,e.message),a={status:t,statusText:r,detail:n};if(s==="validation"&&Array.isArray(n)){let{errors:l}=ni(n);return new Dc(i,{...a,validationErrors:l})}return s==="auth"?new Mc(i,a):s==="business"?new ri(i,a):s==="server"?new Vc(i,a):new Kc(i,a)}var Yc=class extends ri{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 Qc(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 Tn=["2025-10-28","2026-01-21"],el="2026-01-21",bt=(0,ti.default)("phala::api-client");function tl(e){return Object.entries(e).map(([t,r])=>` -H "${t}: ${r}"`).join(`
12
- `)}function rl(e){return e?` -d '${(typeof e=="string"?e:JSON.stringify(e,null,2)).replace(/'/g,"\\'")}'`:""}function Ws(e,t,r,n){let o=[];r.forEach((a,l)=>{o.push(`${l}: ${a}`)});let s=o.join(`
4
+ `+s),e.push(o+"m+"+Jt.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=aa()+t+" "+e[0]}function aa(){return D.inspectOpts.hideDate?"":new Date().toISOString()+" "}function ca(...e){return process.stderr.write(Xt.formatWithOptions(D.inspectOpts,...e)+`
5
+ `)}function la(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function ua(){return process.env.DEBUG}function pa(e){e.inspectOpts={};let t=Object.keys(D.inspectOpts);for(let r=0;r<t.length;r++)e.inspectOpts[t[r]]=D.inspectOpts[t[r]]}Jt.exports=Fr()(D);var{formatters:Xn}=Jt.exports;Xn.o=function(e){return this.inspectOpts.colors=this.useColors,Xt.inspect(e,this.inspectOpts).split(`
6
+ `).map(t=>t.trim()).join(" ")};Xn.O=function(e){return this.inspectOpts.colors=this.useColors,Xt.inspect(e,this.inspectOpts)}});var Zn=ne((xm,Nr)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Nr.exports=qn():Nr.exports=Jn()});var Gr,Qn=L(()=>{Gr="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 qr,v,me=L(()=>{Qn();qr={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${Gr}`},v=class e extends Error{constructor(t,r={}){let n=r.cause instanceof e?r.cause.details:r.cause?.message?r.cause.message:r.details,o=r.cause instanceof e&&r.cause.docsPath||r.docsPath,s=qr.getDocsUrl?.({...r,docsPath:o}),i=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...n?[`Details: ${n}`]:[],...qr.version?[`Version: ${qr.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=n,this.docsPath=o,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=t,this.version=Gr}walk(t){return eo(this,t)}}});var Zt,Yt,Dr=L(()=>{me();Zt=class extends v{constructor({max:t,min:r,signed:n,size:o,value:s}){super(`Number "${s}" is not in safe ${o?`${o*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${t?`(${r} to ${t})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}},Yt=class extends v{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}});function Ce(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}var lt=L(()=>{});function de(e){return Ce(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}var It=L(()=>{lt()});function At(e,{dir:t="left"}={}){let r=typeof e=="string"?e.replace("0x",""):e,n=0;for(let o=0;o<r.length-1&&r[t==="left"?o:r.length-o-1].toString()==="0";o++)n++;return r=t==="left"?r.slice(n):r.slice(0,r.length-n),typeof e=="string"?(r.length===1&&t==="right"&&(r=`${r}0`),`0x${r.length%2===1?`0${r}`:r}`):r}var to=L(()=>{});var Pt,Lt,Mr=L(()=>{me();Pt=class extends v{constructor({offset:t,position:r,size:n}){super(`Slice ${r==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}},Lt=class extends v{constructor({size:t,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}});function Oe(e,{dir:t,size:r=32}={}){return typeof e=="string"?fa(e,{dir:t,size:r}):ma(e,{dir:t,size:r})}function fa(e,{dir:t,size:r=32}={}){if(r===null)return e;let n=e.replace("0x","");if(n.length>r*2)throw new Lt({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function ma(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new Lt({size:e.length,targetSize:r,type:"bytes"});let n=new Uint8Array(r);for(let o=0;o<r;o++){let s=t==="right";n[s?o:r-o-1]=e[s?o:e.length-o-1]}return n}var Vr=L(()=>{Mr()});function xe(e,t={}){return typeof e=="number"||typeof e=="bigint"?S(e,t):typeof e=="string"?xa(e,t):typeof e=="boolean"?ha(e,t):se(e,t)}function ha(e,t={}){let r=`0x${Number(e)}`;return typeof t.size=="number"?(He(r,{size:t.size}),Oe(r,{size:t.size})):r}function se(e,t={}){let r="";for(let o=0;o<e.length;o++)r+=da[e[o]];let n=`0x${r}`;return typeof t.size=="number"?(He(n,{size:t.size}),Oe(n,{dir:"right",size:t.size})):n}function S(e,t={}){let{signed:r,size:n}=t,o=BigInt(e),s;n?r?s=(1n<<BigInt(n)*8n-1n)-1n:s=2n**(BigInt(n)*8n)-1n:typeof e=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));let i=typeof s=="bigint"&&r?-s-1n:0;if(s&&o>s||o<i){let l=typeof e=="bigint"?"n":"";throw new Zt({max:s?`${s}${l}`:void 0,min:`${i}${l}`,signed:r,size:n,value:`${e}${l}`})}let a=`0x${(r&&o<0?(1n<<BigInt(n*8))+BigInt(o):o).toString(16)}`;return n?Oe(a,{size:n}):a}function xa(e,t={}){let r=ga.encode(e);return se(r,t)}var da,ga,he=L(()=>{Dr();Vr();Ye();da=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));ga=new TextEncoder});function Qt(e,t={}){return typeof e=="number"||typeof e=="bigint"?va(e,t):typeof e=="boolean"?ya(e,t):Ce(e)?be(e,t):Kr(e,t)}function ya(e,t={}){let r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(He(r,{size:t.size}),Oe(r,{size:t.size})):r}function ro(e){if(e>=Be.zero&&e<=Be.nine)return e-Be.zero;if(e>=Be.A&&e<=Be.F)return e-(Be.A-10);if(e>=Be.a&&e<=Be.f)return e-(Be.a-10)}function be(e,t={}){let r=e;t.size&&(He(r,{size:t.size}),r=Oe(r,{dir:"right",size:t.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);let o=n.length/2,s=new Uint8Array(o);for(let i=0,a=0;i<o;i++){let l=ro(n.charCodeAt(a++)),u=ro(n.charCodeAt(a++));if(l===void 0||u===void 0)throw new v(`Invalid byte sequence ("${n[a-2]}${n[a-1]}" in "${n}").`);s[i]=l*16+u}return s}function va(e,t){let r=S(e,t);return be(r)}function Kr(e,t={}){let r=ba.encode(e);return typeof t.size=="number"?(He(r,{size:t.size}),Oe(r,{dir:"right",size:t.size})):r}var ba,Be,Ne=L(()=>{me();lt();Vr();Ye();he();ba=new TextEncoder;Be={zero:48,nine:57,A:65,F:70,a:97,f:102}});function He(e,{size:t}){if(de(e)>t)throw new Yt({givenSize:de(e),maxSize:t})}function Qe(e,t={}){let{signed:r}=t;t.size&&He(e,{size:t.size});let n=BigInt(e);if(!r)return n;let o=(e.length-2)/2,s=(1n<<BigInt(o)*8n-1n)-1n;return n<=s?n:n-BigInt(`0x${"f".padStart(o*2,"f")}`)-1n}function et(e,t={}){return Number(Qe(e,t))}var Ye=L(()=>{Dr();It()});function ut(e,t){return({exclude:r,format:n})=>({exclude:r,format:(o,s)=>{let i=t(o,s);if(r)for(let a of r)delete i[a];return{...i,...n(o,s)}},type:e})}var er=L(()=>{});var id,ad,cd,ld,ud,pd,fd,md,dd,hd,gd,xd,bd,yd,vd,wd,_d,Cd,kd,Sd,Ed,Td,Id,Ad,Pd,Ld,$d,Rd,Bd,zd,jd,Ud,Fd,Od,Hd,Nd,Gd,qd,Dd,Md,Vd,Kd,Wd,Xd,Jd,Zd,Yd,Qd,eh,th,rh,nh,oh,sh,ih,ah,ch,lh,uh,ph,fh,mh,dh,hh,gh,xh,bh,yh,vh,wh,_h,Ch,kh,Sh,Eh,Th,Ih,Ah,Ph,Lh,$h,Rh,Bh,zh,jh,Uh,Fh,Oh,Hh,Nh,Gh,qh,Dh,Mh,Vh,tr,ao=L(()=>{id=2n**(8n-1n)-1n,ad=2n**(16n-1n)-1n,cd=2n**(24n-1n)-1n,ld=2n**(32n-1n)-1n,ud=2n**(40n-1n)-1n,pd=2n**(48n-1n)-1n,fd=2n**(56n-1n)-1n,md=2n**(64n-1n)-1n,dd=2n**(72n-1n)-1n,hd=2n**(80n-1n)-1n,gd=2n**(88n-1n)-1n,xd=2n**(96n-1n)-1n,bd=2n**(104n-1n)-1n,yd=2n**(112n-1n)-1n,vd=2n**(120n-1n)-1n,wd=2n**(128n-1n)-1n,_d=2n**(136n-1n)-1n,Cd=2n**(144n-1n)-1n,kd=2n**(152n-1n)-1n,Sd=2n**(160n-1n)-1n,Ed=2n**(168n-1n)-1n,Td=2n**(176n-1n)-1n,Id=2n**(184n-1n)-1n,Ad=2n**(192n-1n)-1n,Pd=2n**(200n-1n)-1n,Ld=2n**(208n-1n)-1n,$d=2n**(216n-1n)-1n,Rd=2n**(224n-1n)-1n,Bd=2n**(232n-1n)-1n,zd=2n**(240n-1n)-1n,jd=2n**(248n-1n)-1n,Ud=2n**(256n-1n)-1n,Fd=-(2n**(8n-1n)),Od=-(2n**(16n-1n)),Hd=-(2n**(24n-1n)),Nd=-(2n**(32n-1n)),Gd=-(2n**(40n-1n)),qd=-(2n**(48n-1n)),Dd=-(2n**(56n-1n)),Md=-(2n**(64n-1n)),Vd=-(2n**(72n-1n)),Kd=-(2n**(80n-1n)),Wd=-(2n**(88n-1n)),Xd=-(2n**(96n-1n)),Jd=-(2n**(104n-1n)),Zd=-(2n**(112n-1n)),Yd=-(2n**(120n-1n)),Qd=-(2n**(128n-1n)),eh=-(2n**(136n-1n)),th=-(2n**(144n-1n)),rh=-(2n**(152n-1n)),nh=-(2n**(160n-1n)),oh=-(2n**(168n-1n)),sh=-(2n**(176n-1n)),ih=-(2n**(184n-1n)),ah=-(2n**(192n-1n)),ch=-(2n**(200n-1n)),lh=-(2n**(208n-1n)),uh=-(2n**(216n-1n)),ph=-(2n**(224n-1n)),fh=-(2n**(232n-1n)),mh=-(2n**(240n-1n)),dh=-(2n**(248n-1n)),hh=-(2n**(256n-1n)),gh=2n**8n-1n,xh=2n**16n-1n,bh=2n**24n-1n,yh=2n**32n-1n,vh=2n**40n-1n,wh=2n**48n-1n,_h=2n**56n-1n,Ch=2n**64n-1n,kh=2n**72n-1n,Sh=2n**80n-1n,Eh=2n**88n-1n,Th=2n**96n-1n,Ih=2n**104n-1n,Ah=2n**112n-1n,Ph=2n**120n-1n,Lh=2n**128n-1n,$h=2n**136n-1n,Rh=2n**144n-1n,Bh=2n**152n-1n,zh=2n**160n-1n,jh=2n**168n-1n,Uh=2n**176n-1n,Fh=2n**184n-1n,Oh=2n**192n-1n,Hh=2n**200n-1n,Nh=2n**208n-1n,Gh=2n**216n-1n,qh=2n**224n-1n,Dh=2n**232n-1n,Mh=2n**240n-1n,Vh=2n**248n-1n,tr=2n**256n-1n});function tt(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}var Xr=L(()=>{});var Rt,rr,nr,co=L(()=>{me();Rt=class extends v{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}},rr=class extends v{constructor({length:t,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}},nr=class extends v{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}});function or(e,{recursiveReadLimit:t=8192}={}){let r=Object.create(Sa);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}var Sa,Jr=L(()=>{co();Sa={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 nr({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new rr({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new Rt({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 Rt({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 po,fo=L(()=>{po={ether:-9,wei:9}});function mo(e,t){let r=e.toString(),n=r.startsWith("-");n&&(r=r.slice(1)),r=r.padStart(t,"0");let[o,s]=[r.slice(0,r.length-t),r.slice(r.length-t)];return s=s.replace(/(0+)$/,""),`${n?"-":""}${o||"0"}${s?`.${s}`:""}`}var ho=L(()=>{});function Bt(e,t="wei"){return mo(e,po[t])}var go=L(()=>{fo();ho()});function Ia(e){let t=Object.entries(e).map(([n,o])=>o===void 0||o===!1?null:[n,o]).filter(Boolean),r=t.reduce((n,[o])=>Math.max(n,o.length),0);return t.map(([n,o])=>` ${`${n}:`.padEnd(r+1)} ${o}`).join(`
8
+ `)}var sr,ir,ar,cr=L(()=>{me();sr=class extends v{constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}},ir=class extends v{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Ia(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"})}},ar=class extends v{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 Aa(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Zr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function rt(e,...t){if(!Aa(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 mt(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 pr(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 bo(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ge(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function fr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ye(e,t){return e<<32-t|e>>>t}function La(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function $a(e){for(let t=0;t<e.length;t++)e[t]=La(e[t]);return e}function Ra(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function zt(e){return typeof e=="string"&&(e=Ra(e)),rt(e),e}function mr(e){let t=n=>e().update(zt(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}var Pa,Yr,ft,dr=L(()=>{Pa=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;Yr=Pa?e=>e:$a;ft=class{}});function za(e,t=!1){return t?{h:Number(e&gr),l:Number(e>>wo&gr)}:{h:Number(e>>wo&gr)|0,l:Number(e&gr)|0}}function _o(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=za(e[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var gr,wo,Co,ko,So,Eo,To=L(()=>{gr=BigInt(4294967295),wo=BigInt(32);Co=(e,t,r)=>e<<r|t>>>32-r,ko=(e,t,r)=>t<<r|e>>>32-r,So=(e,t,r)=>t<<r-32|e>>>64-r,Eo=(e,t,r)=>e<<r-32|t>>>64-r});var ge,wr=L(()=>{me();ge=class extends v{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 nt,zo=L(()=>{me();nt=class extends v{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}});var _r,ot,Qr,en,tn,rn,nn,on,sn,an,jt,jo=L(()=>{go();me();_r=class extends v{constructor({cause:t,message:r}={}){let n=r?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${n?`with reason: ${n}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"})}};Object.defineProperty(_r,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(_r,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});ot=class extends v{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(ot,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});Qr=class extends v{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(Qr,"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/});en=class extends v{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(en,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});tn=class extends v{constructor({cause:t,nonce:r}={}){super([`Nonce provided for the transaction ${r?`(${r}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
9
+ `),{cause:t,name:"NonceTooLowError"})}};Object.defineProperty(tn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});rn=class extends v{constructor({cause:t,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}exceeds the maximum allowed nonce.`,{cause:t,name:"NonceMaxValueError"})}};Object.defineProperty(rn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});nn=class extends v{constructor({cause:t}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
10
+ `),{cause:t,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}};Object.defineProperty(nn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});on=class extends v{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(on,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});sn=class extends v{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(sn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});an=class extends v{constructor({cause:t}){super("The transaction type is not supported for this chain.",{cause:t,name:"TransactionTypeNotSupportedError"})}};Object.defineProperty(an,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});jt=class extends v{constructor({cause:t,maxPriorityFeePerGas:r,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${Bt(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${Bt(n)} gwei`:""}).`].join(`
11
+ `),{cause:t,name:"TipAboveFeeCapError"})}};Object.defineProperty(jt,"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 ht,cn=L(()=>{ht=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 n=this.keys().next().value;n&&this.delete(n)}return this}}});function Va(e,t=24){let r=new Uint32Array(10);for(let n=24-t;n<24;n++){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],p=r[l+1],f=Uo(u,p,1)^r[a],h=Fo(u,p,1)^r[a+1];for(let g=0;g<50;g+=10)e[i+g]^=f,e[i+g+1]^=h}let o=e[2],s=e[3];for(let i=0;i<24;i++){let a=Ho[i],l=Uo(o,s,a),u=Fo(o,s,a),p=Oo[i];o=e[p],s=e[p+1],e[p]=l,e[p+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]^=Da[n],e[1]^=Ma[n]}Ge(r)}var Oa,Ut,Ha,Na,Ga,qa,Oo,Ho,No,Go,Da,Ma,Uo,Fo,ln,Ka,qo,Do=L(()=>{To();dr();Oa=BigInt(0),Ut=BigInt(1),Ha=BigInt(2),Na=BigInt(7),Ga=BigInt(256),qa=BigInt(113),Oo=[],Ho=[],No=[];for(let e=0,t=Ut,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],Oo.push(2*(5*n+r)),Ho.push((e+1)*(e+2)/2%64);let o=Oa;for(let s=0;s<7;s++)t=(t<<Ut^(t>>Na)*qa)%Ga,t&Ha&&(o^=Ut<<(Ut<<BigInt(s))-Ut);No.push(o)}Go=_o(No,!0),Da=Go[0],Ma=Go[1],Uo=(e,t,r)=>r>32?So(e,t,r):Co(e,t,r),Fo=(e,t,r)=>r>32?Eo(e,t,r):ko(e,t,r);ln=class e extends ft{constructor(t,r,n,o=!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=n,this.enableXOF=o,this.rounds=s,Zr(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=bo(this.state)}clone(){return this._cloneInto()}keccak(){Yr(this.state32),Va(this.state32,this.rounds),Yr(this.state32),this.posOut=0,this.pos=0}update(t){mt(this),t=zt(t),rt(t);let{blockLen:r,state:n}=this,o=t.length;for(let s=0;s<o;){let i=Math.min(r-this.pos,o-s);for(let a=0;a<i;a++)n[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:n,blockLen:o}=this;t[n]^=r,(r&128)!==0&&n===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){mt(this,!1),rt(t),this.finish();let r=this.state,{blockLen:n}=this;for(let o=0,s=t.length;o<s;){this.posOut>=n&&this.keccak();let i=Math.min(n-this.posOut,s-o);t.set(r.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=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 Zr(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(pr(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,Ge(this.state)}_cloneInto(t){let{blockLen:r,suffix:n,outputLen:o,rounds:s,enableXOF:i}=this;return t||(t=new e(r,n,o,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=n,t.outputLen=o,t.enableXOF=i,t.destroyed=this.destroyed,t}},Ka=(e,t,r)=>mr(()=>new ln(t,e,r)),qo=Ka(1,136,256/8)});function Mo(e,t){let r=t||"hex",n=qo(Ce(e,{strict:!1})?Qt(e):e);return r==="bytes"?n:xe(n)}var Vo=L(()=>{Do();lt();Ne();he()});function Ko(e,t){if(un.has(`${e}.${t}`))return un.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),n=Mo(Kr(r),"bytes"),o=(t?r.substring(`${t}0x`.length):r).split("");for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&o[i]&&(o[i]=o[i].toUpperCase()),(n[i>>1]&15)>=8&&o[i+1]&&(o[i+1]=o[i+1].toUpperCase());let s=`0x${o.join("")}`;return un.set(`${e}.${t}`,s),s}var un,Wo=L(()=>{Ne();Vo();cn();un=new ht(8192)});function ke(e,t){let{strict:r=!0}=t??{},n=`${e}.${r}`;if(pn.has(n))return pn.get(n);let o=Wa.test(e)?e.toLowerCase()===e?!0:r?Ko(e)===e:!0:!1;return pn.set(n,o),o}var Wa,pn,Cr=L(()=>{cn();Wo();Wa=/^0x[a-fA-F0-9]{40}$/,pn=new ht(8192)});function Xo(e,t,r,{strict:n}={}){return Ce(e,{strict:!1})?Ja(e,t,r,{strict:n}):Xa(e,t,r,{strict:n})}function Jo(e,t){if(typeof t=="number"&&t>0&&t>de(e)-1)throw new Pt({offset:t,position:"start",size:de(e)})}function Zo(e,t,r){if(typeof t=="number"&&typeof r=="number"&&de(e)!==r-t)throw new Pt({offset:r,position:"end",size:de(e)})}function Xa(e,t,r,{strict:n}={}){Jo(e,t);let o=e.slice(t,r);return n&&Zo(o,t,r),o}function Ja(e,t,r,{strict:n}={}){Jo(e,t);let o=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return n&&Zo(o,t,r),o}var Yo=L(()=>{Mr();lt();It()});var hn=ne(Nt=>{"use strict";var ac=Nt&&Nt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Nt,"__esModule",{value:!0});Nt.encryptEnvVars=uc;var mn=Re("@noble/curves/ed25519"),dn=ac(Re("crypto"));function cc(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(n=>parseInt(n,16)))!==null&&r!==void 0?r:[])}function lc(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function uc(e,t){let r=JSON.stringify({env:e}),n=mn.x25519.utils.randomPrivateKey(),o=mn.x25519.getPublicKey(n),s=cc(t),i=mn.x25519.getSharedSecret(n,s),a=await dn.default.subtle.importKey("raw",i,{name:"AES-GCM",length:256},!0,["encrypt"]),l=dn.default.getRandomValues(new Uint8Array(12)),u=await dn.default.subtle.encrypt({name:"AES-GCM",iv:l},a,new TextEncoder().encode(r)),p=new Uint8Array(o.length+l.length+u.byteLength);return p.set(o),p.set(l,o.length),p.set(new Uint8Array(u),o.length+l.length),lc(p)}});var cs=ne(Gt=>{"use strict";var pc=Gt&&Gt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Gt,"__esModule",{value:!0});Gt.getComposeHash=hc;var fc=pc(Re("crypto"));function gn(e){return e==null?e:Array.isArray(e)?e.map(gn):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let n=e[r];return t[r]=gn(n),t},{}):e}function mc(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 dc(e){let t=gn(e);return JSON.stringify(t,(r,n)=>typeof n=="number"&&(isNaN(n)||!isFinite(n))?null:n)}function hc(e,t=!1){t&&(e=mc(e));let r=dc(e);return fc.default.createHash("sha256").update(r,"utf8").digest("hex")}});var Ps=ne(w=>{"use strict";Object.defineProperty(w,"__esModule",{value:!0});w.toBig=w.shrSL=w.shrSH=w.rotrSL=w.rotrSH=w.rotrBL=w.rotrBH=w.rotr32L=w.rotr32H=w.rotlSL=w.rotlSH=w.rotlBL=w.rotlBH=w.add5L=w.add5H=w.add4L=w.add4H=w.add3L=w.add3H=void 0;w.add=Cs;w.fromBig=bn;w.split=ls;var Tr=BigInt(2**32-1),xn=BigInt(32);function bn(e,t=!1){return t?{h:Number(e&Tr),l:Number(e>>xn&Tr)}:{h:Number(e>>xn&Tr)|0,l:Number(e&Tr)|0}}function ls(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=bn(e[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var us=(e,t)=>BigInt(e>>>0)<<xn|BigInt(t>>>0);w.toBig=us;var ps=(e,t,r)=>e>>>r;w.shrSH=ps;var fs=(e,t,r)=>e<<32-r|t>>>r;w.shrSL=fs;var ms=(e,t,r)=>e>>>r|t<<32-r;w.rotrSH=ms;var ds=(e,t,r)=>e<<32-r|t>>>r;w.rotrSL=ds;var hs=(e,t,r)=>e<<64-r|t>>>r-32;w.rotrBH=hs;var gs=(e,t,r)=>e>>>r-32|t<<64-r;w.rotrBL=gs;var xs=(e,t)=>t;w.rotr32H=xs;var bs=(e,t)=>e;w.rotr32L=bs;var ys=(e,t,r)=>e<<r|t>>>32-r;w.rotlSH=ys;var vs=(e,t,r)=>t<<r|e>>>32-r;w.rotlSL=vs;var ws=(e,t,r)=>t<<r-32|e>>>64-r;w.rotlBH=ws;var _s=(e,t,r)=>e<<r-32|t>>>64-r;w.rotlBL=_s;function Cs(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var ks=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);w.add3L=ks;var Ss=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;w.add3H=Ss;var Es=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);w.add4L=Es;var Ts=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0;w.add4H=Ts;var Is=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0);w.add5L=Is;var As=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;w.add5H=As;var gc={fromBig:bn,split:ls,toBig:us,shrSH:ps,shrSL:fs,rotrSH:ms,rotrSL:ds,rotrBH:hs,rotrBL:gs,rotr32H:xs,rotr32L:bs,rotlSH:ys,rotlSL:vs,rotlBH:ws,rotlBL:_s,add:Cs,add3L:ks,add3H:Ss,add4L:Es,add4H:Ts,add5H:As,add5L:Is};w.default=gc});var Ls=ne(Ir=>{"use strict";Object.defineProperty(Ir,"__esModule",{value:!0});Ir.crypto=void 0;var De=Re("crypto");Ir.crypto=De&&typeof De=="object"&&"webcrypto"in De?De.webcrypto:De&&typeof De=="object"&&"randomBytes"in De?De:void 0});var Os=ne(b=>{"use strict";Object.defineProperty(b,"__esModule",{value:!0});b.wrapXOFConstructorWithOpts=b.wrapConstructorWithOpts=b.wrapConstructor=b.Hash=b.nextTick=b.swap32IfBE=b.byteSwapIfBE=b.swap8IfBE=b.isLE=void 0;b.isBytes=Rs;b.anumber=yn;b.abytes=xt;b.ahash=xc;b.aexists=bc;b.aoutput=yc;b.u8=vc;b.u32=wc;b.clean=_c;b.createView=Cc;b.rotr=kc;b.rotl=Sc;b.byteSwap=wn;b.byteSwap32=Bs;b.bytesToHex=Tc;b.hexToBytes=Ic;b.asyncLoop=Pc;b.utf8ToBytes=_n;b.bytesToUtf8=Lc;b.toBytes=Ar;b.kdfInputToBytes=$c;b.concatBytes=Rc;b.checkOpts=Bc;b.createHasher=js;b.createOptHasher=Us;b.createXOFer=Fs;b.randomBytes=zc;var gt=Ls();function Rs(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function yn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function xt(e,...t){if(!Rs(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 xc(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");yn(e.outputLen),yn(e.blockLen)}function bc(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 yc(e,t){xt(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function vc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function wc(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function _c(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Cc(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function kc(e,t){return e<<32-t|e>>>t}function Sc(e,t){return e<<t|e>>>32-t>>>0}b.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function wn(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}b.swap8IfBE=b.isLE?e=>e:e=>wn(e);b.byteSwapIfBE=b.swap8IfBE;function Bs(e){for(let t=0;t<e.length;t++)e[t]=wn(e[t]);return e}b.swap32IfBE=b.isLE?e=>e:Bs;var zs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Ec=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Tc(e){if(xt(e),zs)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Ec[e[r]];return t}var Ue={_0:48,_9:57,A:65,F:70,a:97,f:102};function $s(e){if(e>=Ue._0&&e<=Ue._9)return e-Ue._0;if(e>=Ue.A&&e<=Ue.F)return e-(Ue.A-10);if(e>=Ue.a&&e<=Ue.f)return e-(Ue.a-10)}function Ic(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(zs)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 n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=$s(e.charCodeAt(s)),a=$s(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)}n[o]=i*16+a}return n}var Ac=async()=>{};b.nextTick=Ac;async function Pc(e,t,r){let n=Date.now();for(let o=0;o<e;o++){r(o);let s=Date.now()-n;s>=0&&s<t||(await(0,b.nextTick)(),n+=s)}}function _n(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Lc(e){return new TextDecoder().decode(e)}function Ar(e){return typeof e=="string"&&(e=_n(e)),xt(e),e}function $c(e){return typeof e=="string"&&(e=_n(e)),xt(e),e}function Rc(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];xt(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}function Bc(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 vn=class{};b.Hash=vn;function js(e){let t=n=>e().update(Ar(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Us(e){let t=(n,o)=>e(o).update(Ar(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}function Fs(e){let t=(n,o)=>e(o).update(Ar(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}b.wrapConstructor=js;b.wrapConstructorWithOpts=Us;b.wrapXOFConstructorWithOpts=Fs;function zc(e=32){if(gt.crypto&&typeof gt.crypto.getRandomValues=="function")return gt.crypto.getRandomValues(new Uint8Array(e));if(gt.crypto&&typeof gt.crypto.randomBytes=="function")return Uint8Array.from(gt.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}});var Ws=ne(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});z.shake256=z.shake128=z.keccak_512=z.keccak_384=z.keccak_256=z.keccak_224=z.sha3_512=z.sha3_384=z.sha3_256=z.sha3_224=z.Keccak=void 0;z.keccakP=Vs;var Dt=Ps(),W=Os(),jc=BigInt(0),qt=BigInt(1),Uc=BigInt(2),Fc=BigInt(7),Oc=BigInt(256),Hc=BigInt(113),Gs=[],qs=[],Ds=[];for(let e=0,t=qt,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],Gs.push(2*(5*n+r)),qs.push((e+1)*(e+2)/2%64);let o=jc;for(let s=0;s<7;s++)t=(t<<qt^(t>>Fc)*Hc)%Oc,t&Uc&&(o^=qt<<(qt<<BigInt(s))-qt);Ds.push(o)}var Ms=(0,Dt.split)(Ds,!0),Nc=Ms[0],Gc=Ms[1],Hs=(e,t,r)=>r>32?(0,Dt.rotlBH)(e,t,r):(0,Dt.rotlSH)(e,t,r),Ns=(e,t,r)=>r>32?(0,Dt.rotlBL)(e,t,r):(0,Dt.rotlSL)(e,t,r);function Vs(e,t=24){let r=new Uint32Array(10);for(let n=24-t;n<24;n++){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],p=r[l+1],f=Hs(u,p,1)^r[a],h=Ns(u,p,1)^r[a+1];for(let g=0;g<50;g+=10)e[i+g]^=f,e[i+g+1]^=h}let o=e[2],s=e[3];for(let i=0;i<24;i++){let a=qs[i],l=Hs(o,s,a),u=Ns(o,s,a),p=Gs[i];o=e[p],s=e[p+1],e[p]=l,e[p+1]=u}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)r[a]=e[i+a];for(let a=0;a<10;a++)e[i+a]^=~r[(a+2)%10]&r[(a+4)%10]}e[0]^=Nc[n],e[1]^=Gc[n]}(0,W.clean)(r)}var Mt=class e extends W.Hash{constructor(t,r,n,o=!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=n,this.enableXOF=o,this.rounds=s,(0,W.anumber)(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=(0,W.u32)(this.state)}clone(){return this._cloneInto()}keccak(){(0,W.swap32IfBE)(this.state32),Vs(this.state32,this.rounds),(0,W.swap32IfBE)(this.state32),this.posOut=0,this.pos=0}update(t){(0,W.aexists)(this),t=(0,W.toBytes)(t),(0,W.abytes)(t);let{blockLen:r,state:n}=this,o=t.length;for(let s=0;s<o;){let i=Math.min(r-this.pos,o-s);for(let a=0;a<i;a++)n[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:n,blockLen:o}=this;t[n]^=r,(r&128)!==0&&n===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){(0,W.aexists)(this,!1),(0,W.abytes)(t),this.finish();let r=this.state,{blockLen:n}=this;for(let o=0,s=t.length;o<s;){this.posOut>=n&&this.keccak();let i=Math.min(n-this.posOut,s-o);t.set(r.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=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,W.anumber)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,W.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,W.clean)(this.state)}_cloneInto(t){let{blockLen:r,suffix:n,outputLen:o,rounds:s,enableXOF:i}=this;return t||(t=new e(r,n,o,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=n,t.outputLen=o,t.enableXOF=i,t.destroyed=this.destroyed,t}};z.Keccak=Mt;var Me=(e,t,r)=>(0,W.createHasher)(()=>new Mt(t,e,r));z.sha3_224=Me(6,144,224/8);z.sha3_256=Me(6,136,256/8);z.sha3_384=Me(6,104,384/8);z.sha3_512=Me(6,72,512/8);z.keccak_224=Me(1,144,224/8);z.keccak_256=Me(1,136,256/8);z.keccak_384=Me(1,104,384/8);z.keccak_512=Me(1,72,512/8);var Ks=(e,t,r)=>(0,W.createXOFer)((n={})=>new Mt(t,e,n.dkLen===void 0?r:n.dkLen,!0));z.shake128=Ks(31,168,128/8);z.shake256=Ks(31,136,256/8)});var Xs=ne(Cn=>{"use strict";Object.defineProperty(Cn,"__esModule",{value:!0});Cn.verifyEnvEncryptPublicKey=Mc;var qc=Ws(),Dc=Re("@noble/curves/secp256k1");function Mc(e,t,r){if(t.length!==65)return null;let n=Buffer.from("dstack-env-encrypt-pubkey","utf8"),o=r;r.startsWith("0x")&&(o=r.slice(2));let s=Buffer.from(o,"hex"),i=Buffer.from(":","utf8"),a=Buffer.concat([n,i,s,Buffer.from(e)]),l=(0,qc.keccak_256)(a);try{let u=t.slice(0,32),p=t.slice(32,64),f=t[64],h=new Uint8Array(64);h.set(u,0),h.set(p,32);let g=Dc.secp256k1.Signature.fromCompact(h).addRecoveryBit(f).recoverPublicKey(l);return"0x"+Buffer.from(g.toRawBytes(!0)).toString("hex")}catch(u){return console.error("signature verification failed:",u),null}}});var ni=Tt(Zn(),1);import{ofetch as Vc}from"ofetch";function Yn(e){return{all:e=e||new Map,on:function(t,r){var n=e.get(t);n?n.push(r):e.set(t,[r])},off:function(t,r){var n=e.get(t);n&&(r?n.splice(n.indexOf(r)>>>0,1):e.set(t,[]))},emit:function(t,r){var n=e.get(t);n&&n.slice().map(function(o){o(r)}),(n=e.get("*"))&&n.slice().map(function(o){o(t,r)})}}}import{z as M}from"zod";import{z as j}from"zod";import{z as Ve}from"zod";import{z as k}from"zod";import{z as Ke}from"zod";function Ze(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}er();Ye();er();var Wr={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function $t(e,t){let r={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?et(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?et(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Wr[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=wa(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 no=ut("transaction",$t);function wa(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 _a(e,t){let r=(e.transactions??[]).map(n=>typeof n=="string"?n:$t(n));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 oo=ut("block",_a);function so(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}:{}}}Ye();er();var Ca={"0x0":"reverted","0x1":"success"};function ka(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(n=>so(n)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?et(e.transactionIndex):null,status:e.status?Ca[e.status]:null,type:e.type?Wr[e.type]||e.type:null};return e.blobGasPrice&&(r.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(r.blobGasUsed=BigInt(e.blobGasUsed)),r}var io=ut("transactionReceipt",ka);me();Jr();Ne();he();function ze(e,t="hex"){let r=lo(e),n=or(new Uint8Array(r.length));return r.encode(n),t==="hex"?se(n.bytes):n.bytes}function lo(e){return Array.isArray(e)?Ea(e.map(t=>lo(t))):Ta(e)}function Ea(e){let t=e.reduce((o,s)=>o+s.length,0),r=uo(t);return{length:t<=55?1+t:1+r+t,encode(o){t<=55?o.pushByte(192+t):(o.pushByte(247+r),r===1?o.pushUint8(t):r===2?o.pushUint16(t):r===3?o.pushUint24(t):o.pushUint32(t));for(let{encode:s}of e)s(o)}}}function Ta(e){let t=typeof e=="string"?be(e):e,r=uo(t.length);return{length:t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+r+t.length,encode(o){t.length===1&&t[0]<128?o.pushBytes(t):t.length<=55?(o.pushByte(128+t.length),o.pushBytes(t)):(o.pushByte(183+r),r===1?o.pushUint8(t.length):r===2?o.pushUint16(t.length):r===3?o.pushUint24(t.length):o.pushUint32(t.length),o.pushBytes(t))}}}function uo(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 v("Length is too large.")}cr();he();function xo(e){if(!e||e.length===0)return[];let t=[];for(let r of e){let{chainId:n,nonce:o,...s}=r,i=r.address;t.push([n?xe(n):"0x",i,o?xe(o):"0x",...pt({},s)])}return t}Ne();he();function lr(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(s=>be(s)):e.blobs,o=[];for(let s of n)o.push(Uint8Array.from(t.blobToKzgCommitment(s)));return r==="bytes"?o:o.map(s=>se(s))}Ne();he();function ur(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(i=>be(i)):e.blobs,o=typeof e.commitments[0]=="string"?e.commitments.map(i=>be(i)):e.commitments,s=[];for(let i=0;i<n.length;i++){let a=n[i],l=o[i];s.push(Uint8Array.from(t.computeBlobKzgProof(a,l)))}return r==="bytes"?s:s.map(i=>se(i))}he();dr();function Ba(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(r>>o&s),a=Number(r&s),l=n?4:0,u=n?0:4;e.setUint32(t+l,i,n),e.setUint32(t+u,a,n)}function yo(e,t,r){return e&t^~e&r}function vo(e,t,r){return e&t^e&r^t&r}var hr=class extends ft{constructor(t,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=fr(this.buffer)}update(t){mt(this),t=zt(t),rt(t);let{view:r,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let l=fr(t);for(;o<=s-i;i+=o)this.process(l,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){mt(this),pr(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,Ge(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let f=i;f<o;f++)r[f]=0;Ba(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=fr(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=l/4,p=this.get();if(u>p.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)a.setUint32(4*f,p[f],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=a,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},je=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);dr();var ja=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]),qe=new Uint32Array(64),xr=class extends hr{constructor(t=32){super(64,t,8,!1),this.A=je[0]|0,this.B=je[1]|0,this.C=je[2]|0,this.D=je[3]|0,this.E=je[4]|0,this.F=je[5]|0,this.G=je[6]|0,this.H=je[7]|0}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:a,H:l}=this;return[t,r,n,o,s,i,a,l]}set(t,r,n,o,s,i,a,l){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=l|0}process(t,r){for(let f=0;f<16;f++,r+=4)qe[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let h=qe[f-15],g=qe[f-2],_=ye(h,7)^ye(h,18)^h>>>3,P=ye(g,17)^ye(g,19)^g>>>10;qe[f]=P+qe[f-7]+_+qe[f-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:l,G:u,H:p}=this;for(let f=0;f<64;f++){let h=ye(a,6)^ye(a,11)^ye(a,25),g=p+h+yo(a,l,u)+ja[f]+qe[f]|0,P=(ye(n,2)^ye(n,13)^ye(n,22))+vo(n,o,s)|0;p=u,u=l,l=a,a=i+g|0,i=s,s=o,o=n,n=g+P|0}n=n+this.A|0,o=o+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,p=p+this.H|0,this.set(n,o,s,i,a,l,u,p)}roundClean(){Ge(qe)}destroy(){this.set(0,0,0,0,0,0,0,0),Ge(this.buffer)}};var Io=mr(()=>new xr);var Ao=Io;lt();Ne();he();function Po(e,t){let r=t||"hex",n=Ao(Ce(e,{strict:!1})?Qt(e):e);return r==="bytes"?n:xe(n)}function Lo(e){let{commitment:t,version:r=1}=e,n=e.to??(typeof t=="string"?"hex":"bytes"),o=Po(t,"bytes");return o.set([r],0),n==="bytes"?o:se(o)}function $o(e){let{commitments:t,version:r}=e,n=e.to??(typeof t[0]=="string"?"hex":"bytes"),o=[];for(let s of t)o.push(Lo({commitment:s,to:n,version:r}));return o}me();var br=class extends v{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}},dt=class extends v{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}},yr=class extends v{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}},vr=class extends v{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${1}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}};Jr();It();Ne();he();function Ro(e){let t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?be(e.data):e.data,n=de(r);if(!n)throw new dt;if(n>761855)throw new br({maxSize:761855,size:n});let o=[],s=!0,i=0;for(;s;){let a=or(new Uint8Array(131072)),l=0;for(;l<4096;){let u=r.slice(i,i+31);if(a.pushByte(0),a.pushBytes(u),u.length<31){a.pushByte(128),s=!1;break}l++,i+=31}o.push(a)}return t==="bytes"?o.map(a=>a.bytes):o.map(a=>se(a.bytes))}function Bo(e){let{data:t,kzg:r,to:n}=e,o=e.blobs??Ro({data:t,to:n}),s=e.commitments??lr({blobs:o,kzg:r,to:n}),i=e.proofs??ur({blobs:o,commitments:s,kzg:r,to:n}),a=[];for(let l=0;l<o.length;l++)a.push({blob:o[l],commitment:s[l],proof:i[l]});return a}Xr();to();he();ao();wr();me();zo();jo();Cr();It();Yo();Ye();function Qo(e){let{authorizationList:t}=e;if(t)for(let r of t){let{chainId:n}=r,o=r.address;if(!ke(o))throw new ge({address:o});if(n<0)throw new nt({chainId:n})}kr(e)}function es(e){let{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new dt;for(let r of t){let n=de(r),o=et(Xo(r,0,1));if(n!==32)throw new yr({hash:r,size:n});if(o!==1)throw new vr({hash:r,version:o})}}kr(e)}function kr(e){let{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:n,to:o}=e;if(t<=0)throw new nt({chainId:t});if(o&&!ke(o))throw new ge({address:o});if(n&&n>tr)throw new ot({maxFeePerGas:n});if(r&&n&&r>n)throw new jt({maxFeePerGas:n,maxPriorityFeePerGas:r})}function ts(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:o,to:s}=e;if(t<=0)throw new nt({chainId:t});if(s&&!ke(s))throw new ge({address:s});if(r||o)throw new v("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(n&&n>tr)throw new ot({maxFeePerGas:n})}function rs(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:o,to:s}=e;if(s&&!ke(s))throw new ge({address:s});if(typeof t<"u"&&t<=0)throw new nt({chainId:t});if(r||o)throw new v("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(n&&n>tr)throw new ot({maxFeePerGas:n})}cr();function ns(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 ir({transaction:e})}wr();cr();Cr();function Ft(e){if(!e||e.length===0)return[];let t=[];for(let r=0;r<e.length;r++){let{address:n,storageKeys:o}=e[r];for(let s=0;s<o.length;s++)if(o[s].length-2!==64)throw new ar({storageKey:o[s]});if(!ke(n,{strict:!1}))throw new ge({address:n});t.push([n,o])}return t}function os(e,t){let r=ns(e);return r==="eip1559"?Qa(e,t):r==="eip2930"?ec(e,t):r==="eip4844"?Ya(e,t):r==="eip7702"?Za(e,t):tc(e,t)}function Za(e,t){let{authorizationList:r,chainId:n,gas:o,nonce:s,to:i,value:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:p,data:f}=e;Qo(e);let h=Ft(p),g=xo(r);return tt(["0x04",ze([S(n),s?S(s):"0x",u?S(u):"0x",l?S(l):"0x",o?S(o):"0x",i??"0x",a?S(a):"0x",f??"0x",h,g,...pt(e,t)])])}function Ya(e,t){let{chainId:r,gas:n,nonce:o,to:s,value:i,maxFeePerBlobGas:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:p,data:f}=e;es(e);let h=e.blobVersionedHashes,g=e.sidecars;if(e.blobs&&(typeof h>"u"||typeof g>"u")){let K=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(pe=>se(pe)),Y=e.kzg,re=lr({blobs:K,kzg:Y});if(typeof h>"u"&&(h=$o({commitments:re})),typeof g>"u"){let pe=ur({blobs:K,commitments:re,kzg:Y});g=Bo({blobs:K,commitments:re,proofs:pe})}}let _=Ft(p),P=[S(r),o?S(o):"0x",u?S(u):"0x",l?S(l):"0x",n?S(n):"0x",s??"0x",i?S(i):"0x",f??"0x",_,a?S(a):"0x",h??[],...pt(e,t)],R=[],G=[],Z=[];if(g)for(let K=0;K<g.length;K++){let{blob:Y,commitment:re,proof:pe}=g[K];R.push(Y),G.push(re),Z.push(pe)}return tt(["0x03",g?ze([P,R,G,Z]):ze(P)])}function Qa(e,t){let{chainId:r,gas:n,nonce:o,to:s,value:i,maxFeePerGas:a,maxPriorityFeePerGas:l,accessList:u,data:p}=e;kr(e);let f=Ft(u),h=[S(r),o?S(o):"0x",l?S(l):"0x",a?S(a):"0x",n?S(n):"0x",s??"0x",i?S(i):"0x",p??"0x",f,...pt(e,t)];return tt(["0x02",ze(h)])}function ec(e,t){let{chainId:r,gas:n,data:o,nonce:s,to:i,value:a,accessList:l,gasPrice:u}=e;ts(e);let p=Ft(l),f=[S(r),s?S(s):"0x",u?S(u):"0x",n?S(n):"0x",i??"0x",a?S(a):"0x",o??"0x",p,...pt(e,t)];return tt(["0x01",ze(f)])}function tc(e,t){let{chainId:r=0,gas:n,data:o,nonce:s,to:i,value:a,gasPrice:l}=e;rs(e);let u=[s?S(s):"0x",l?S(l):"0x",n?S(n):"0x",i??"0x",a?S(a):"0x",o??"0x"];if(t){let p=(()=>{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 g=27n+(t.v===27n?0n:1n);if(t.v!==g)throw new sr({v:t.v});return g})(),f=At(t.r),h=At(t.s);u=[...u,S(p),f==="0x00"?"0x":f,h==="0x00"?"0x":h]}else r>0&&(u=[...u,S(r),"0x","0x"]);return ze(u)}function pt(e,t){let r=t??e,{v:n,yParity:o}=r;if(typeof r.r>"u")return[];if(typeof r.s>"u")return[];if(typeof n>"u"&&typeof o>"u")return[];let s=At(r.r),i=At(r.s);return[typeof o=="number"?o?S(1):"0x":n===0n?"0x":n===1n?S(1):n===27n?"0x":S(1),s==="0x00"?"0x":s,i==="0x00"?"0x":i]}var ss={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};Ye();var is={block:oo({format(e){return{transactions:e.transactions?.map(r=>{if(typeof r=="string")return r;let n=$t(r);return n.typeHex==="0x7e"&&(n.isSystemTx=r.isSystemTx,n.mint=r.mint?Qe(r.mint):void 0,n.sourceHash=r.sourceHash,n.type="deposit"),n}),stateRoot:e.stateRoot}}}),transaction:no({format(e){let t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?Qe(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:io({format(e){return{l1GasPrice:e.l1GasPrice?Qe(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?Qe(e.l1GasUsed):null,l1Fee:e.l1Fee?Qe(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};wr();Cr();Xr();he();function rc(e,t){return oc(e)?nc(e):os(e,t)}var as={transaction:rc};function nc(e){sc(e);let{sourceHash:t,data:r,from:n,gas:o,isSystemTx:s,mint:i,to:a,value:l}=e,u=[t,n,a??"0x",i?xe(i):"0x",l?xe(l):"0x",o?xe(o):"0x",s?"0x1":"0x",r??"0x"];return tt(["0x7e",ze(u)])}function oc(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function sc(e){let{from:t,to:r}=e;if(t&&!ke(t))throw new ge({address:t});if(r&&!ke(r))throw new ge({address:r})}var fn={blockTime:2e3,contracts:ss,formatters:is,serializers:as};var Sr=Ze({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 Ot=1,Ht=Ze({...fn,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:{...fn.contracts,disputeGameFactory:{[Ot]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[Ot]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[Ot]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[Ot]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:Ot}),ic=Ze({...Ht,experimental_preconfirmationTime:200,rpcUrls:{default:{http:["https://mainnet-preconf.base.org"]}}});var Er=Ze({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 H}from"zod";import{z as ie}from"zod";import{z as m}from"zod";import{z as d}from"zod";import{z as yt}from"zod";import{z as vt}from"zod";import{z as C}from"zod";import{z as X}from"zod";import{z as E}from"zod";import pu from"crypto";import{z as Te}from"zod";import{z as ve}from"zod";import{z as V}from"zod";import{z as ae}from"zod";import{z as ce}from"zod";import{z as qu}from"zod";import{z as Ys}from"zod";import{z as Ie}from"zod";import{z as St}from"zod";import{z as st}from"zod";import{z as B}from"zod";import{z as xp}from"zod";import{z as wp}from"zod";import{z as $}from"zod";import{z as Ee}from"zod";import{z as jp}from"zod";import{z as O}from"zod";import{z as y}from"zod";import{z as Ct}from"zod";import{z as En}from"zod";import{z as J}from"zod";import{z as _i}from"zod";import{z as Se}from"zod";import{z as x}from"zod";import{z as A}from"zod";import{z as I}from"zod";import{z as N}from"zod";var Nb=Tt(hn(),1);import{z as F}from"zod";var jf=Tt(hn(),1),Uf=Tt(cs(),1),Ff=Tt(Xs(),1);import{z as wt}from"zod";import{z as we}from"zod";import{z as _t}from"zod";import{z as ee}from"zod";import{z as ue}from"zod";import{z as ti}from"zod";import{z as ri}from"zod";import{z as Pr}from"zod";import{z as Lr}from"zod";import{z as Q}from"zod";var Kc=M.object({detail:M.union([M.string(),M.array(M.object({msg:M.string(),type:M.string().optional(),ctx:M.record(M.unknown()).optional(),loc:M.array(M.union([M.string(),M.number()])).optional(),input:M.unknown().optional()}).passthrough()),M.record(M.unknown())]).optional(),type:M.string().optional(),code:M.string().optional()}),Ae=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)}},kn=class $r extends Ae{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=Kc.safeParse(t.data);return r.success?new $r(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 $r(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 $r(t.message,{request:r??void 0,detail:t.message})}},Wc=class extends Ae{constructor(e,t){super(e,t),this.isValidationError=!0,this.validationErrors=t.validationErrors}},Xc=class extends Ae{constructor(){super(...arguments),this.isAuthError=!0}},oi=class extends Ae{constructor(){super(...arguments),this.isBusinessError=!0}},Jc=class extends Ae{constructor(){super(...arguments),this.isServerError=!0}},Zc=class extends Ae{constructor(){super(...arguments),this.isUnknownError=!0}};function Yc(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 si(e){if(!Array.isArray(e))return{errors:[],message:typeof e=="string"?e:"Validation error"};let t=e.map((o,s)=>{let i=Yc(o.loc),a=i;return i==="unknown"&&o.type&&(a=o.type==="missing"?"required field":o.type),{field:a,message:o.msg,type:o.type,context:o.ctx}}),r=t.length,n=r===1?`Validation failed: ${t[0].message}`:`Validation failed (${r} issue${r>1?"s":""})`;return{errors:t,message:n}}function Qc(e){return e===422?"validation":e===401||e===403?"auth":e>=400&&e<500?"business":e>=500?"server":"unknown"}function el(e,t,r){if(e===422&&Array.isArray(t)){let{message:n}=si(t);return n}if(typeof t=="string")return t;if(t&&typeof t=="object"&&"message"in t){let n=t.message;if(typeof n=="string")return n}return r}function tl(e){let t=e.status??0,r=e.statusText??"Unknown Error",n=e.detail,o=nl(n);if(o)return new rl(o.message,{status:t,statusText:r,detail:n,errorCode:o.error_code,structuredDetails:o.details,suggestions:o.suggestions,links:o.links});let s=Qc(t),i=el(t,n,e.message),a={status:t,statusText:r,detail:n};if(s==="validation"&&Array.isArray(n)){let{errors:l}=si(n);return new Wc(i,{...a,validationErrors:l})}return s==="auth"?new Xc(i,a):s==="business"?new oi(i,a):s==="server"?new Jc(i,a):new Zc(i,a)}var rl=class extends oi{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 nl(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 In=["2025-10-28","2026-01-21"],ol="2026-01-21",bt=(0,ni.default)("phala::api-client");function sl(e){return Object.entries(e).map(([t,r])=>` -H "${t}: ${r}"`).join(`
12
+ `)}function il(e){return e?` -d '${(typeof e=="string"?e:JSON.stringify(e,null,2)).replace(/'/g,"\\'")}'`:""}function Js(e,t,r,n){let o=[];r.forEach((a,l)=>{o.push(`${l}: ${a}`)});let s=o.join(`
13
13
  `),i=typeof n=="string"?n:JSON.stringify(n,null,2);return[`< HTTP/1.1 ${e} ${t}`,s?`< ${s.replace(/\n/g,`
14
14
  < `)}`:"","",i].filter(Boolean).join(`
15
- `)}var nl=class oi{constructor(t={}){this.emitter=Jn();let r=t.apiKey||process?.env?.PHALA_CLOUD_API_KEY,n=t.baseURL||process?.env?.PHALA_CLOUD_API_PREFIX||"https://cloud-api.phala.network/api/v1",o=t.version&&Tn.includes(t.version)?t.version:el;this.config={...t,apiKey:r,baseURL:n,version:o};let{apiKey:s,baseURL:i,timeout:a,headers:l,useCookieAuth:u,onResponseError:p,...f}=this.config,h={"X-Phala-Version":o,"Content-Type":"application/json"};l&&typeof l=="object"&&Object.entries(l).forEach(([g,_])=>{typeof _=="string"&&(h[g]=_)}),!u&&s&&(h["X-API-Key"]=s),this.fetchInstance=Gc.create({baseURL:i,timeout:a||3e4,headers:h,...u?{credentials:"include"}:{},...f,onRequest({request:g,options:_}){if(bt.enabled){let I=_.method||"GET",R=typeof g=="string"?g:g.url,G=R.startsWith("http")?R:`${i}${R}`,J={};_.headers&&typeof _.headers=="object"&&Object.entries(_.headers).forEach(([Z,te])=>{typeof te=="string"&&(J[Z]=te)});let K=[`> curl -X ${I} "${G}"`,tl(J),_.body?rl(_.body):""].filter(Boolean).join(`
15
+ `)}var al=class ii{constructor(t={}){this.emitter=Yn();let r=t.apiKey||process?.env?.PHALA_CLOUD_API_KEY,n=t.baseURL||process?.env?.PHALA_CLOUD_API_PREFIX||"https://cloud-api.phala.com/api/v1",o=t.version&&In.includes(t.version)?t.version:ol;this.config={...t,apiKey:r,baseURL:n,version:o};let{apiKey:s,baseURL:i,timeout:a,headers:l,useCookieAuth:u,onResponseError:p,...f}=this.config,h={"X-Phala-Version":o,"Content-Type":"application/json"};l&&typeof l=="object"&&Object.entries(l).forEach(([g,_])=>{typeof _=="string"&&(h[g]=_)}),!u&&s&&(h["X-API-Key"]=s),this.fetchInstance=Vc.create({baseURL:i,timeout:a||3e4,headers:h,...u?{credentials:"include"}:{},...f,onRequest({request:g,options:_}){if(bt.enabled){let P=_.method||"GET",R=typeof g=="string"?g:g.url,G=R.startsWith("http")?R:`${i}${R}`,Z={};_.headers&&typeof _.headers=="object"&&Object.entries(_.headers).forEach(([Y,re])=>{typeof re=="string"&&(Z[Y]=re)});let K=[`> curl -X ${P} "${G}"`,sl(Z),_.body?il(_.body):""].filter(Boolean).join(`
16
16
  `);bt(`
17
17
  === REQUEST ===
18
18
  %s
19
- `,K)}},onResponse({request:g,response:_,options:I}){if(bt.enabled){let R=I.method||"GET",G=typeof g=="string"?g:g.url;bt(`
19
+ `,K)}},onResponse({request:g,response:_,options:P}){if(bt.enabled){let R=P.method||"GET",G=typeof g=="string"?g:g.url;bt(`
20
20
  === RESPONSE [%s %s] (%dms) ===
21
21
  %s
22
- `,R,G,_.headers.get("x-response-time")||"?",Ws(_.status,_.statusText,_.headers,_._data))}},onResponseError:({request:g,response:_,options:I})=>{if(bt.enabled){console.warn(`HTTP ${_.status}: ${_.url}`);let R=I.method||"GET",G=typeof g=="string"?g:g.url;bt(`
22
+ `,R,G,_.headers.get("x-response-time")||"?",Js(_.status,_.statusText,_.headers,_._data))}},onResponseError:({request:g,response:_,options:P})=>{if(bt.enabled){console.warn(`HTTP ${_.status}: ${_.url}`);let R=P.method||"GET",G=typeof g=="string"?g:g.url;bt(`
23
23
  === ERROR RESPONSE [%s %s] ===
24
24
  %s
25
- `,R,G,Ws(_.status,_.statusText,_.headers,_._data))}p&&p({request:g,response:_,options:I})}})}get raw(){return this.fetchInstance}on(t,r){this.emitter.on(t,r)}off(t,r){this.emitter.off(t,r)}once(t,r){let n=o=>{r(o),this.emitter.off(t,n)};this.emitter.on(t,n)}async request(t,r){try{let n=r?.method||"GET";return await this.fetchInstance(t,{...r,method:n})}catch(n){let o=this.convertToRequestError(n);throw this.emitError(o)}}async requestFull(t,r){try{let n=r?.method||"GET",o=await this.fetchInstance.raw(t,{...r,method:n,ignoreResponseError:!0});return{status:o.status,statusText:o.statusText,headers:o.headers,data:o._data,ok:o.ok}}catch(n){let o=this.convertToRequestError(n);throw this.emitError(o)}}async get(t,r){try{return await this.fetchInstance(t,{...r,method:"GET"})}catch(n){let o=this.convertToRequestError(n);throw this.emitError(o)}}async post(t,r,n){try{return await this.fetchInstance(t,{...n,method:"POST",body:r})}catch(o){let s=this.convertToRequestError(o);throw this.emitError(s)}}async put(t,r,n){try{return await this.fetchInstance(t,{...n,method:"PUT",body:r})}catch(o){let s=this.convertToRequestError(o);throw this.emitError(s)}}async patch(t,r,n){try{return await this.fetchInstance(t,{...n,method:"PATCH",body:r})}catch(o){let s=this.convertToRequestError(o);throw this.emitError(s)}}async delete(t,r){try{return await this.fetchInstance(t,{...r,method:"DELETE"})}catch(n){let o=this.convertToRequestError(n);throw this.emitError(o)}}convertToRequestError(t){return t&&typeof t=="object"&&"data"in t?Cn.fromFetchError(t):t instanceof Error?Cn.fromError(t):new Cn("Unknown error occurred",{detail:"Unknown error occurred"})}emitError(t){let r=Zc(t);return this.emitter.emit("error",r),r}async safeRequest(t){try{return{success:!0,data:await t()}}catch(r){if(r instanceof Ae)return{success:!1,error:r};let n=this.convertToRequestError(r);return this.emitError(n),{success:!1,error:n}}}async safeGet(t,r){return this.safeRequest(()=>this.get(t,r))}async safePost(t,r,n){return this.safeRequest(()=>this.post(t,r,n))}async safePut(t,r,n){return this.safeRequest(()=>this.put(t,r,n))}async safePatch(t,r,n){return this.safeRequest(()=>this.patch(t,r,n))}async safeDelete(t,r){return this.safeRequest(()=>this.delete(t,r))}async safeRequestMethod(t,r){return this.safeRequest(()=>this.request(t,r))}async safeRequestFull(t,r){return this.safeRequest(()=>this.requestFull(t,r))}withVersion(t){return new oi({...this.config,version:t})}extend(t){let r=typeof t=="function"?t(this):t,n=Object.create(this);for(let[o,s]of Object.entries(r))typeof s=="function"&&(n[o]=(...i)=>s(this,...i));return n}};function ol(e={}){return new nl(e)}var sl=j.object({username:j.string(),email:j.string(),role:j.enum(["admin","user"]),avatar:j.string(),email_verified:j.boolean(),totp_enabled:j.boolean(),has_backup_codes:j.boolean(),flag_has_password:j.boolean()}).passthrough(),il=j.object({id:j.string(),name:j.string(),slug:j.string().nullable(),tier:j.string(),role:j.string(),avatar:j.string().nullable().optional()}).passthrough(),al=j.object({balance:j.string().or(j.number()),granted_balance:j.string().or(j.number()),is_post_paid:j.boolean(),outstanding_amount:j.string().or(j.number()).nullable()}).passthrough(),cl=j.object({user:sl,workspace:il,credits:al}).passthrough(),ll=Ve.object({username:Ve.string(),email:Ve.string(),credits:Ve.number(),granted_credits:Ve.number(),avatar:Ve.string(),team_name:Ve.string(),team_tier:Ve.string()}).passthrough();function ul(e){return e==="2025-10-28"?ll:cl}async function si(e,t){let r=await e.get("/auth/me");return t?.schema===!1?r:(t?.schema||ul(e.config.version)).parse(r)}async function pl(e,t){try{return{success:!0,data:await si(e,t)}}catch(r){return r&&typeof r=="object"&&("status"in r||"issues"in r)?{success:!1,error:r}:{success:!1,error:{name:"Error",message:r instanceof Error?r.message:String(r)}}}}var fl={[Sr.id]:Sr,[Ot.id]:Ot,[kr.id]:kr},ml=Ke.object({id:Ke.string(),slug:Ke.string().nullable(),url:Ke.string(),version:Ke.string(),chain_id:Ke.number().nullable(),kms_contract_address:Ke.string().nullable().transform(e=>e),gateway_app_id:Ke.string().nullable().transform(e=>e)}).passthrough(),Pe=ml.transform(e=>{if(e.chain_id!=null){let t=fl[e.chain_id];if(t)return{...e,chain:t}}return e});function ii(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 ai(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 dl(e,t){function r(i,a){return n(i,a)}async function n(i,a){ii(a);let l=await t(i);return a?.schema===!1?l:(a?.schema||e).parse(l)}function o(i,a){return s(i,a)}async function s(i,a){let l=ai(a);if(l)return l;let u=await(async()=>{try{return{success:!0,data:await t(i)}}catch(f){return f&&typeof f=="object"&&"status"in f?{success:!1,error:f}:f&&typeof f=="object"&&"issues"in f?{success:!1,error:f}:{success:!1,error:{name:"Error",message:f instanceof Error?f.message:String(f)}}}})();return u.success?a?.schema===!1?{success:!0,data:u.data}:(a?.schema||e).safeParse(u.data):u}return{action:r,safeAction:o}}function E(e,t){function r(i,...a){let[l,u]=a;return n(i,l,u)}async function n(i,a,l){ii(l);let u=await t(i,a);return l?.schema===!1?u:(l?.schema||e).parse(u)}function o(i,...a){let[l,u]=a;return s(i,l,u)}async function s(i,a,l){let u=ai(l);if(u)return u;let p=await(async()=>{try{return{success:!0,data:await t(i,a)}}catch(h){return h&&typeof h=="object"&&"status"in h?{success:!1,error:h}:h&&typeof h=="object"&&"issues"in h?{success:!1,error:h}:{success:!1,error:{name:"Error",message:h instanceof Error?h.message:String(h)}}}})();return p.success?l?.schema===!1?{success:!0,data:p.data}:(l?.schema||e).safeParse(p.data):p}return{action:r,safeAction:o}}var hl=k.object({name:k.string(),is_dev:k.boolean(),version:k.union([k.tuple([k.number(),k.number(),k.number()]),k.tuple([k.number(),k.number(),k.number(),k.number()])]),os_image_hash:k.string().nullable().optional()}).passthrough(),gl=k.object({teepod_id:k.number(),name:k.string(),listed:k.boolean(),resource_score:k.number(),remaining_vcpu:k.number(),remaining_memory:k.number(),remaining_cvm_slots:k.number(),images:k.array(hl),support_onchain_kms:k.boolean().optional(),fmspc:k.string().nullable().optional(),device_id:k.string().nullable().optional(),region_identifier:k.string().nullable().optional(),default_kms:k.string().nullable().optional(),kms_list:k.array(k.string()).default([])}).passthrough(),xl=k.object({max_instances:k.number().nullable().optional(),max_vcpu:k.number().nullable().optional(),max_memory:k.number().nullable().optional(),max_disk:k.number().nullable().optional()}).passthrough(),bl=k.object({tier:k.string(),capacity:xl,nodes:k.array(gl),kms_list:k.array(Pe)}).passthrough(),{action:yl,safeAction:vl}=dl(bl,async e=>await e.get("/teepods/available")),ci=H.object({id:H.string(),name:H.string(),description:H.string(),vcpu:H.number(),memory_mb:H.number(),hourly_rate:H.string(),requires_gpu:H.boolean(),default_disk_size_gb:H.number().default(20),family:H.string().nullable()}).passthrough(),wl=H.object({name:H.string(),items:H.array(ci),total:H.number()}).strict(),_l=H.object({result:H.array(wl)}).strict(),Cl=H.object({items:H.array(ci),total:H.number(),family:H.string()}).strict(),kl=H.object({family:H.string()}).strict(),{action:Sl,safeAction:Tl}=E(_l,async e=>await e.get("/instance-types")),{action:El,safeAction:Il}=E(Cl,async(e,t)=>{let r=kl.parse(t);return await e.get(`/instance-types/${r.family}`)}),li=ue.object({id:ue.string(),name:ue.string(),slug:ue.string().nullable(),tier:ue.string(),role:ue.string(),created_at:ue.string()}).passthrough(),Al=ue.object({has_more:ue.boolean(),next_cursor:ue.string().nullable(),total:ue.number().nullable()}).passthrough(),Pl=ue.object({data:ue.array(li),pagination:Al}).passthrough(),{action:Ll,safeAction:$l}=E(Pl,async(e,t)=>{let r=new URLSearchParams;t?.cursor&&r.append("cursor",t.cursor),t?.limit&&r.append("limit",t.limit.toString());let n=r.toString()?`/workspaces?${r.toString()}`:"/workspaces";return await e.get(n)}),{action:Rl,safeAction:Bl}=E(li,async(e,t)=>await e.get(`/workspaces/${t}`)),zl=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()}),jl=m.object({id:m.number(),username:m.string()}),ui=m.object({id:m.number(),name:m.string(),region_identifier:m.string().nullable().optional()}),En=m.object({vcpu:m.number(),memory:m.number(),disk_size:m.number(),gpu_count:m.number().default(0)}),In=m.object({app:m.string(),instance:m.string()}),Ul=m.object({hosted:zl,name:m.string(),managed_user:jl.nullable(),node:ui.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:Pe.nullable(),vcpu:m.number().nullable(),memory:m.number().nullable(),disk_size:m.number().nullable(),gateway_domain:m.string().nullable(),public_urls:m.array(In),machine_info:En.nullable().optional(),updated_at:m.string().nullable().optional()}),pi=m.object({id:m.number(),name:m.string(),status:m.string(),in_progress:m.boolean().optional().default(!1),teepod_id:m.number().nullable(),teepod:ui.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(),instance_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:Pe.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(In).optional().default([]),gateway_domain:m.string().optional().nullable(),machine_info:En.optional().nullable(),updated_at:m.string().optional().nullable()}),Fl=m.object({items:m.array(Ul),total:m.number(),page:m.number(),page_size:m.number(),pages:m.number()}),Ol=d.enum(["skip","hourly","monthly"]),Hl=d.enum(["phala","ethereum","base","legacy"]),An=d.object({object_type:d.literal("user"),id:d.string().nullable().optional(),username:d.string().nullable().optional(),avatar_url:d.string().nullable().optional()}),Pn=d.object({object_type:d.literal("workspace"),id:d.string(),name:d.string(),slug:d.string().nullable().optional(),avatar_url:d.string().nullable().optional()}),Nl=d.object({instance_type:d.string().nullable().optional(),vcpu:d.number().int().nullable().optional(),memory_in_gb:d.number().nullable().optional(),disk_in_gb:d.number().int().nullable().optional(),gpus:d.number().int().nullable().optional(),compute_billing_price:d.string().nullable().optional(),billing_period:Ol.nullable().optional()}),Gl=d.object({name:d.string().nullable().optional(),version:d.string().nullable().optional(),is_dev:d.boolean().nullable().optional(),os_image_hash:d.string().nullable().optional()}),ql=d.object({chain_id:d.number().int().nullable().optional(),dstack_kms_address:d.string().nullable().optional(),dstack_app_address:d.string().nullable().optional(),deployer_address:d.string().nullable().optional(),rpc_endpoint:d.string().nullable().optional(),encrypted_env_pubkey:d.string().nullable().optional()}),Dl=d.object({target:d.string().nullable().optional(),started_at:d.string().nullable().optional(),correlation_id:d.string().nullable().optional()}),Ml=d.object({base_domain:d.string().nullable().optional(),cname:d.string().nullable().optional()}),Vl=d.object({name:d.string().nullable().optional(),region:d.string().nullable().optional(),device_id:d.string().nullable().optional(),ppid:d.string().nullable().optional(),status:d.string().nullable().optional(),version:d.string().nullable().optional()}),$r=d.object({id:d.string(),name:d.string(),app_id:d.string().nullable().optional(),vm_uuid:d.string().nullable().optional(),resource:Nl,node_info:Vl.nullable().optional(),os:Gl.nullable().optional(),kms_type:Hl.nullable().optional(),kms_info:ql.nullable().optional(),status:d.string(),progress:Dl.nullable().optional(),compose_hash:d.string().nullable().optional(),gateway:Ml,services:d.array(d.record(d.any())).optional().default([]),endpoints:d.array(In).nullable().optional(),public_logs:d.boolean().optional(),public_sysinfo:d.boolean().optional(),public_tcbinfo:d.boolean().optional(),gateway_enabled:d.boolean().optional(),secure_time:d.boolean().optional(),storage_fs:d.string().optional(),workspace:Pn.nullable().optional(),creator:An.nullable().optional()}),Kl=$r.extend({compose_file:d.union([d.record(d.any()),d.string()]).nullable().optional()}),Wl=d.object({items:d.array($r),total:d.number(),page:d.number(),page_size:d.number(),pages:d.number()});function fi(e){return typeof e!="string"||e.length<5||e.length>63?!1:/^[a-zA-Z](?!.*--)([a-zA-Z0-9-]*[a-zA-Z0-9])?$/.test(e)}var Le=yt.object({id:yt.string().optional(),uuid:yt.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:yt.string().optional(),instance_id:yt.string().optional(),name:yt.string().refine(fi,{message:"Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens"}).optional()}),We=e=>e.refine(t=>{let r=t;return!!(r.id||r.uuid||r.app_id||r.instance_id||r.name)},{message:"One of id, uuid, app_id, instance_id, or name must be provided"}),Xl=We(Le),U=Xl.transform(e=>{let t;if(e.id)t=e.id;else if(e.uuid)t=e.uuid;else if(e.app_id)t=e.app_id;else if(e.instance_id)t=e.instance_id;else{if(e.name)return{cvmId:e.name};throw new Error("No valid identifier provided")}let r=/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i,n=/^[0-9a-f]{40}$/i,o;return r.test(t)?o=t.replace(/-/g,""):n.test(t)?o=`app_${t}`:o=t,{cvmId:o}}),Jl=U;function Zl(e){return e==="2025-10-28"?pi:Kl}async function mi(e,t){let{cvmId:r}=Jl.parse(t),n=await e.get(`/cvms/${r}`);return Zl(e.config.version).parse(n)}async function Ln(e,t){try{return{success:!0,data:await mi(e,t)}}catch(r){return r&&typeof r=="object"&&("status"in r||"issues"in r)?{success:!1,error:r}:{success:!1,error:{name:"Error",message:r instanceof Error?r.message:String(r)}}}}var Yl=vt.object({page:vt.number().int().min(1).optional(),page_size:vt.number().int().min(1).optional(),node_id:vt.number().int().min(1).optional(),teepod_id:vt.number().int().min(1).optional(),user_id:vt.string().optional()}).strict();function Ql(e){return e==="2025-10-28"?Fl:Wl}async function di(e,t){let r=Yl.parse(t??{}),n=await e.get("/cvms/paginated",{params:r});return Ql(e.config.version).parse(n)}async function $n(e,t){try{return{success:!0,data:await di(e,t)}}catch(r){return r&&typeof r=="object"&&("status"in r||"issues"in r)?{success:!1,error:r}:{success:!1,error:{name:"Error",message:r instanceof Error?r.message:String(r)}}}}var eu=C.object({app_id:C.string().nullable().optional(),app_env_encrypt_pubkey:C.string().nullable().optional(),compose_hash:C.string(),kms_info:Pe.nullable().optional(),fmspc:C.string().nullable().optional(),device_id:C.string().nullable().optional(),os_image_hash:C.string().nullable().optional(),instance_type:C.string().nullable().optional(),teepod_id:C.number().nullable().optional(),node_id:C.number().nullable().optional(),kms_id:C.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}),kn="Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens",tu=C.object({node_id:C.number().optional(),teepod_id:C.number().optional(),region:C.string().optional(),name:C.string().min(5,kn).max(63,kn).refine(e=>fi(e),kn),instance_type:C.string().optional(),image:C.string().optional(),vcpu:C.number().optional(),memory:C.number().optional(),disk_size:C.number().optional(),compose_file:C.object({allowed_envs:C.array(C.string()).optional(),pre_launch_script:C.string().optional(),docker_compose_file:C.string().optional(),name:C.string().optional().default(""),kms_enabled:C.boolean().optional(),public_logs:C.boolean().optional(),public_sysinfo:C.boolean().optional(),gateway_enabled:C.boolean().optional(),tproxy_enabled:C.boolean().optional()}),listed:C.boolean().optional(),kms_id:C.string().optional(),kms:C.enum(["PHALA","ETHEREUM","BASE"]).optional(),kms_contract:C.string().optional(),env_keys:C.array(C.string()).optional(),nonce:C.number().optional(),app_id:C.string().optional()}).passthrough().transform(e=>!e.instance_type&&!e.vcpu&&!e.memory?{...e,instance_type:"tdx.small"}:e);function ru(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:nu,safeAction:ou}=E(eu,async(e,t)=>{let r=tu.parse(t),n=ru(r),o={...n};return typeof n.node_id=="number"?(o={...n,teepod_id:n.node_id},delete o.node_id):typeof n.teepod_id=="number"&&console.warn("[phala/cloud] teepod_id is deprecated, please use node_id instead."),await e.post("/cvms/provision",o)}),su=T.object({id:T.number(),name:T.string(),status:T.string(),teepod_id:T.number(),teepod:T.object({id:T.number(),name:T.string()}).nullable(),user_id:T.number().nullable(),app_id:T.string().nullable(),vm_uuid:T.string().nullable(),instance_id:T.string().nullable(),app_url:T.string().nullable().default(null),base_image:T.string().nullable(),vcpu:T.number(),memory:T.number(),disk_size:T.number(),manifest_version:T.number().nullable().default(2),version:T.string().nullable().default("1.0.0"),runner:T.string().nullable().default("docker-compose"),docker_compose_file:T.string().nullable(),features:T.array(T.string()).nullable().default(["kms","tproxy-net"]),created_at:T.string(),encrypted_env_pubkey:T.string().nullable().optional(),app_auth_contract_address:T.string().nullable().optional(),deployer_address:T.string().nullable().optional()}).passthrough(),nb=T.object({encrypted_env:T.string().optional().nullable(),app_id:T.string(),compose_hash:T.string(),kms_id:T.string().optional(),contract_address:T.string().optional(),deployer_address:T.string().optional(),env_keys:T.array(T.string()).optional().nullable()}).passthrough(),{action:iu,safeAction:au}=E(su,async(e,t)=>await e.post("/cvms",t)),hi=Y.object({allowed_envs:Y.array(Y.string()).optional(),docker_compose_file:Y.string(),features:Y.array(Y.string()).optional(),name:Y.string().optional(),manifest_version:Y.number().optional(),kms_enabled:Y.boolean().optional(),public_logs:Y.boolean().optional(),public_sysinfo:Y.boolean().optional(),tproxy_enabled:Y.boolean().optional(),pre_launch_script:Y.string().optional(),env_pubkey:Y.string().optional(),salt:Y.string().optional().nullable()}).passthrough();function Sn(e){return e==null?e:Array.isArray(e)?e.map(Sn):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let n=e[r];return t[r]=Sn(n),t},{}):e}function gi(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 xi(e){let t=Sn(e),r=JSON.stringify(t,null,4);return r=r.replace(/": /g,'":'),r}function lu(e){let t=gi(e),r=xi(t);return cu.createHash("sha256").update(r,"utf8").digest("hex")}function uu(e){let t=e;return{...e,getHash:()=>lu(t),toString:()=>xi(gi(t))}}var pu=hi.transform(e=>uu(e)),fu=U,{action:mu,safeAction:Rn}=E(pu,async(e,t)=>{let{cvmId:r}=fu.parse(t);return await e.get(`/cvms/${r}/compose_file`)}),du=Ee.object({id:Ee.string().optional(),uuid:Ee.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:Ee.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:Ee.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:hi,update_env_vars:Ee.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})),hu=Ee.object({app_id:Ee.string().nullable(),device_id:Ee.string().nullable(),compose_hash:Ee.string(),kms_info:Pe.nullable().optional()}).passthrough(),{action:gu,safeAction:xu}=E(hu,async(e,t)=>{let r=du.parse(t);return await e.post(`/cvms/${r.cvmId}/compose_file/provision`,r.request)}),bu=ve.object({id:ve.string().optional(),uuid:ve.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:ve.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:ve.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:ve.string().min(1,"Compose hash is required"),encrypted_env:ve.string().optional(),env_keys:ve.array(ve.string()).optional(),update_env_vars:ve.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??void 0,_raw:e})),yu=ve.any().transform(()=>{}),{action:vu,safeAction:wu}=E(yu,async(e,t)=>{let r=bu.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,update_env_vars:r.update_env_vars})}),_u=We(Le.extend({encrypted_env:V.string().describe("Encrypted environment variables (hex string)"),env_keys:V.array(V.string()).optional().describe("List of allowed environment variable keys"),compose_hash:V.string().optional().describe("Compose hash for verification (Phase 2, required when env_keys changes)"),transaction_hash:V.string().optional().describe("On-chain transaction hash for verification (Phase 2, required when env_keys changes)")})).transform(e=>{let{cvmId:t}=U.parse(e);return{cvmId:t,request:{encrypted_env:e.encrypted_env,env_keys:e.env_keys,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),Cu=V.object({status:V.literal("in_progress"),message:V.string(),correlation_id:V.string(),allowed_envs_changed:V.boolean()}),ku=V.object({status:V.literal("precondition_required"),message:V.string(),compose_hash:V.string(),app_id:V.string(),device_id:V.string(),kms_info:Pe}),Su=V.union([Cu,ku]),{action:Tu,safeAction:Eu}=E(Su,async(e,t)=>{let r=_u.parse(t);try{return await e.patch(`/cvms/${r.cvmId}/envs`,r.request)}catch(n){if(n instanceof Ae&&n.status===465){let o=n.detail;if(o&&typeof o=="object"){let s=o;return{status:"precondition_required",message:s.message||"Compose hash verification required",compose_hash:s.compose_hash,app_id:s.app_id,device_id:s.device_id,kms_info:s.kms_info}}}throw n}}),Iu=We(Le.extend({docker_compose_file:ie.string().describe("Docker Compose YAML content"),compose_hash:ie.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:ie.string().optional().describe("On-chain transaction hash for verification (Phase 2, contract-owned KMS only)")})).transform(e=>{let{cvmId:t}=U.parse(e);return{cvmId:t,request:{docker_compose_file:e.docker_compose_file,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),Au=ie.object({status:ie.literal("in_progress"),message:ie.string(),correlation_id:ie.string()}),Pu=ie.object({status:ie.literal("precondition_required"),message:ie.string(),compose_hash:ie.string(),app_id:ie.string(),device_id:ie.string(),kms_info:Pe}),Lu=ie.union([Au,Pu]),{action:$u,safeAction:Ru}=E(Lu,async(e,t)=>{let r=Iu.parse(t),n={"Content-Type":"text/yaml"};r.request.compose_hash&&(n["X-Compose-Hash"]=r.request.compose_hash),r.request.transaction_hash&&(n["X-Transaction-Hash"]=r.request.transaction_hash);try{return await e.patch(`/cvms/${r.cvmId}/docker-compose`,r.request.docker_compose_file,{headers:n})}catch(o){if(o instanceof Ae&&o.status===465){let s=o.detail;if(s&&typeof s=="object"){let i=s;return{status:"precondition_required",message:i.message||"Compose hash verification required",compose_hash:i.compose_hash,app_id:i.app_id,device_id:i.device_id,kms_info:i.kms_info}}}throw o}}),Bu=We(Le.extend({pre_launch_script:ae.string().describe("Pre-launch script content (shell script)"),compose_hash:ae.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:ae.string().optional().describe("On-chain transaction hash for verification (Phase 2, contract-owned KMS only)")})).transform(e=>{let{cvmId:t}=U.parse(e);return{cvmId:t,request:{pre_launch_script:e.pre_launch_script,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),zu=ae.object({status:ae.literal("in_progress"),message:ae.string(),correlation_id:ae.string()}),ju=ae.object({status:ae.literal("precondition_required"),message:ae.string(),compose_hash:ae.string(),app_id:ae.string(),device_id:ae.string(),kms_info:Pe}),Uu=ae.union([zu,ju]),{action:Fu,safeAction:Ou}=E(Uu,async(e,t)=>{let r=Bu.parse(t),n={"Content-Type":"text/plain"};r.request.compose_hash&&(n["X-Compose-Hash"]=r.request.compose_hash),r.request.transaction_hash&&(n["X-Transaction-Hash"]=r.request.transaction_hash);try{return await e.patch(`/cvms/${r.cvmId}/pre-launch-script`,r.request.pre_launch_script,{headers:n})}catch(o){if(o instanceof Ae&&o.status===465){let s=o.detail;if(s&&typeof s=="object"){let i=s;return{status:"precondition_required",message:i.message||"Compose hash verification required",compose_hash:i.compose_hash,app_id:i.app_id,device_id:i.device_id,kms_info:i.kms_info}}}throw o}}),Nu=U,{action:Gu,safeAction:qu}=E(Hu.string(),async(e,t)=>{let{cvmId:r}=Nu.parse(t);return await e.get(`/cvms/${r}/pre-launch-script`)}),Du=Xs.object({kms_id:Xs.string().min(1,"KMS ID is required")}),{action:Mu,safeAction:Vu}=E(Pe,async(e,t)=>{let r=Du.parse(t);return await e.get(`/kms/${r.kms_id}`)}),Ku=Ie.object({page:Ie.number().int().min(1).optional(),page_size:Ie.number().int().min(1).optional(),is_onchain:Ie.boolean().optional()}).strict(),Wu=Ie.object({items:Ie.array(Pe),total:Ie.number(),page:Ie.number(),page_size:Ie.number(),pages:Ie.number()}).strict(),{action:Xu,safeAction:Ju}=E(Wu,async(e,t)=>{let r=Ku.parse(t??{});return await e.get("/kms",{params:r})}),Zu=kt.object({kms:kt.string().min(1,"KMS ID or slug is required"),app_id:kt.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(),Yu=kt.object({public_key:kt.string(),signature:kt.string()}).strict(),{action:Qu,safeAction:ep}=E(Yu,async(e,t)=>{let r=Zu.parse(t);return await e.get(`/kms/${r.kms}/pubkey/${r.app_id}`)}),tp=st.object({counts:st.number().int().min(1).max(20).optional().default(1)}).strict(),rp=st.object({app_ids:st.array(st.object({app_id:st.string(),nonce:st.number().int().min(0)}))}).strict(),{action:np,safeAction:op}=E(rp,async(e,t)=>{let r=tp.parse(t??{}),n=new URLSearchParams;return n.append("counts",r.counts.toString()),await e.get(`/kms/phala/next_app_id?${n.toString()}`)}),Rr=B.object({id:B.number(),name:B.string(),status:B.string(),teepod_id:B.number(),teepod:B.object({id:B.number(),name:B.string(),region_identifier:B.string().nullable().optional()}).optional().nullable(),user_id:B.number().optional().nullable(),app_id:B.string(),vm_uuid:B.string().nullable(),instance_id:B.string().nullable(),app_url:B.string().optional().nullable(),base_image:B.string().nullable(),vcpu:B.number(),memory:B.number(),disk_size:B.number(),manifest_version:B.number().optional().nullable(),version:B.string().optional().nullable(),runner:B.string().optional().nullable(),docker_compose_file:B.string().optional().nullable(),features:B.array(B.string()).optional().nullable(),created_at:B.string(),encrypted_env_pubkey:B.string().nullable()}),sp=U,{action:ip,safeAction:ap}=E(Rr,async(e,t)=>{let{cvmId:r}=sp.parse(t);return await e.post(`/cvms/${r}/start`)}),cp=U,{action:lp,safeAction:up}=E(Rr,async(e,t)=>{let{cvmId:r}=cp.parse(t);return await e.post(`/cvms/${r}/stop`)}),pp=U,{action:fp,safeAction:mp}=E(Rr,async(e,t)=>{let{cvmId:r}=pp.parse(t);return await e.post(`/cvms/${r}/shutdown`)}),hp=We(Le.extend({force:dp.boolean().optional()})),{action:gp,safeAction:xp}=E(Rr,async(e,t)=>{let r=hp.parse(t),{cvmId:n}=U.parse(r),{force:o=!1}=r;return await e.post(`/cvms/${n}/restart`,{force:o})}),yp=U,{action:vp,safeAction:wp}=E(bp.void(),async(e,t)=>{let{cvmId:r}=yp.parse(t);await e.delete(`/cvms/${r}`)}),_p=L.object({name:L.string(),mount_point:L.string(),total_size:L.number(),free_size:L.number()}),Cp=L.object({os_name:L.string(),os_version:L.string(),kernel_version:L.string(),cpu_model:L.string(),num_cpus:L.number(),total_memory:L.number(),available_memory:L.number(),used_memory:L.number(),free_memory:L.number(),total_swap:L.number(),used_swap:L.number(),free_swap:L.number(),uptime:L.number(),loadavg_one:L.number(),loadavg_five:L.number(),loadavg_fifteen:L.number(),disks:L.array(_p)}),kp=L.object({is_online:L.boolean(),is_public:L.boolean().default(!1),error:L.string().nullable(),sysinfo:Cp.nullable(),status:L.string().nullable(),in_progress:L.boolean().default(!1),boot_progress:L.string().nullable(),boot_error:L.string().nullable()}),Sp=U,{action:Tp,safeAction:Ep}=E(kp,async(e,t)=>{let{cvmId:r}=Sp.parse(t);return await e.get(`/cvms/${r}/stats`)}),Ip=Te.object({app:Te.string(),instance:Te.string()}),Ap=Te.object({is_online:Te.boolean(),is_public:Te.boolean().default(!0),error:Te.string().nullable(),internal_ip:Te.string().nullable(),latest_handshake:Te.string().nullable(),public_urls:Te.array(Ip).nullable()}),Pp=U,{action:Lp,safeAction:$p}=E(Ap,async(e,t)=>{let{cvmId:r}=Pp.parse(t);return await e.get(`/cvms/${r}/network`)}),Bp=U,{action:zp,safeAction:jp}=E(Rp.string(),async(e,t)=>{let{cvmId:r}=Bp.parse(t);return await e.get(`/cvms/${r}/docker-compose.yml`)}),Up=O.object({id:O.string(),names:O.array(O.string()),image:O.string(),image_id:O.string(),command:O.string().nullable().optional(),created:O.number(),state:O.string(),status:O.string(),log_endpoint:O.string().nullable()}),Fp=O.object({is_online:O.boolean(),is_public:O.boolean().default(!0),error:O.string().nullable(),docker_compose_file:O.string().nullable(),manifest_version:O.number().nullable(),version:O.string().nullable(),runner:O.string().nullable(),features:O.array(O.string()).nullable(),containers:O.array(Up).nullable()}),Op=U,{action:Hp,safeAction:Np}=E(Fp,async(e,t)=>{let{cvmId:r}=Op.parse(t);return await e.get(`/cvms/${r}/composition`)}),Gp=y.object({common_name:y.string().nullable(),organization:y.string().nullable(),country:y.string().nullable(),state:y.string().nullable(),locality:y.string().nullable()}),qp=y.object({common_name:y.string().nullable(),organization:y.string().nullable(),country:y.string().nullable()}),Dp=y.object({subject:Gp,issuer:qp,serial_number:y.string(),not_before:y.string(),not_after:y.string(),version:y.string(),fingerprint:y.string(),signature_algorithm:y.string(),sans:y.array(y.string()).nullable(),is_ca:y.boolean(),position_in_chain:y.number().nullable(),quote:y.string().nullable(),app_id:y.string().nullable().optional(),cert_usage:y.string().nullable().optional()}),Mp=y.object({imr:y.number(),event_type:y.number(),digest:y.string(),event:y.string(),event_payload:y.string()}),Vp=y.object({mrtd:y.string(),rootfs_hash:y.string().nullable().optional(),rtmr0:y.string(),rtmr1:y.string(),rtmr2:y.string(),rtmr3:y.string(),event_log:y.array(Mp),app_compose:y.string()}),Kp=y.object({name:y.string().nullable(),is_online:y.boolean(),is_public:y.boolean().default(!0),error:y.string().nullable(),app_certificates:y.array(Dp).nullable(),tcb_info:Vp.nullable(),compose_file:y.string().nullable()}),Wp=U,{action:Xp,safeAction:Jp}=E(Kp,async(e,t)=>{let{cvmId:r}=Wp.parse(t);return await e.get(`/cvms/${r}/attestation`)}),Zp=We(Le.extend({vcpu:_t.number().optional(),memory:_t.number().optional(),disk_size:_t.number().optional(),instance_type:_t.string().optional(),allow_restart:_t.boolean().optional()})),{action:Yp,safeAction:Qp}=E(_t.void(),async(e,t)=>{let r=Zp.parse(t),{cvmId:n}=U.parse(r),{...o}=r;await e.patch(`/cvms/${n}/resources`,o)}),ef=We(Le.extend({public_sysinfo:Js.boolean(),public_logs:Js.boolean()})),{action:tf,safeAction:rf}=E(pi,async(e,t)=>{let r=ef.parse(t),{cvmId:n}=U.parse(r),{public_sysinfo:o,public_logs:s}=r;return await e.patch(`/cvms/${n}/visibility`,{public_sysinfo:o,public_logs:s})}),Zs=X.object({name:X.string(),os_image_hash:X.string().nullable(),is_current:X.boolean()}),nf=X.object({version:X.union([X.tuple([X.number(),X.number(),X.number(),X.number()]),X.tuple([X.number(),X.number(),X.number()])]),prod:Zs.nullable(),dev:Zs.nullable()}),of=X.array(nf),sf=U,{action:af,safeAction:cf}=E(of,async(e,t)=>{let{cvmId:r}=sf.parse(t);return await e.get(`/cvms/${r}/available-os-images`)}),lf=We(Le.extend({os_image_name:bi.string().min(1,"OS image name is required")})),{action:uf,safeAction:pf}=E(bi.void(),async(e,t)=>{let r=lf.parse(t),{cvmId:n}=U.parse(r),{os_image_name:o}=r;await e.patch(`/cvms/${n}/os-image`,{os_image_name:o})}),ff=Se.object({id:Se.string().optional(),instance_id:Se.string().optional(),name:Se.string(),status:Se.string(),uptime:Se.string().optional(),exited_at:Se.string().optional(),boot_progress:Se.string().optional(),boot_error:Se.string().optional(),shutdown_progress:Se.string().optional()}),mf=U,{action:df,safeAction:hf}=E(ff,async(e,t)=>{let{cvmId:r}=mf.parse(t);return await e.get(`/cvms/${r}/state`)});function yi(e={}){let t=ol(e),r={getCurrentUser:si,safeGetCurrentUser:pl,getAvailableNodes:yl,safeGetAvailableNodes:vl,listAllInstanceTypeFamilies:Sl,safeListAllInstanceTypeFamilies:Tl,listFamilyInstanceTypes:El,safeListFamilyInstanceTypes:Il,listWorkspaces:Ll,safeListWorkspaces:$l,getWorkspace:Rl,safeGetWorkspace:Bl,getCvmInfo:mi,safeGetCvmInfo:Ln,getCvmList:di,safeGetCvmList:$n,provisionCvm:nu,safeProvisionCvm:ou,commitCvmProvision:iu,safeCommitCvmProvision:au,getCvmComposeFile:mu,safeGetCvmComposeFile:Rn,provisionCvmComposeFileUpdate:gu,safeProvisionCvmComposeFileUpdate:xu,commitCvmComposeFileUpdate:vu,safeCommitCvmComposeFileUpdate:wu,updateCvmEnvs:Tu,safeUpdateCvmEnvs:Eu,updateDockerCompose:$u,safeUpdateDockerCompose:Ru,updatePreLaunchScript:Fu,safeUpdatePreLaunchScript:Ou,getCvmPreLaunchScript:Gu,safeGetCvmPreLaunchScript:qu,startCvm:ip,safeStartCvm:ap,stopCvm:lp,safeStopCvm:up,shutdownCvm:fp,safeShutdownCvm:mp,restartCvm:gp,safeRestartCvm:xp,deleteCvm:vp,safeDeleteCvm:wp,getCvmStats:Tp,safeGetCvmStats:Ep,getCvmNetwork:Lp,safeGetCvmNetwork:$p,getCvmDockerCompose:zp,safeGetCvmDockerCompose:jp,getCvmContainersStats:Hp,safeGetCvmContainersStats:Np,getCvmAttestation:Xp,safeGetCvmAttestation:Jp,updateCvmResources:Yp,safeUpdateCvmResources:Qp,updateCvmVisibility:tf,safeUpdateCvmVisibility:rf,getAvailableOsImages:af,safeGetAvailableOsImages:cf,updateOsImage:uf,safeUpdateOsImage:pf,getKmsInfo:Mu,safeGetKmsInfo:Vu,getKmsList:Xu,safeGetKmsList:Ju,getAppEnvEncryptPubKey:Qu,safeGetAppEnvEncryptPubKey:ep,nextAppIds:np,safeNextAppIds:op,getCvmState:df,safeGetCvmState:hf};return t.extend(r)}var Ys=b.object({vm_uuid:b.string().nullable(),app_id:b.string(),name:b.string().default(""),status:b.string(),vcpu:b.number().int(),memory:b.number().int(),disk_size:b.number().int(),teepod_id:b.number().int(),teepod_name:b.string(),region_identifier:b.string().nullable().optional(),kms_type:b.string().nullable().optional(),instance_type:b.string().nullable().optional(),listed:b.boolean().nullable().optional(),base_image:b.string().nullable().optional(),kms_slug:b.string().nullable().optional(),kms_id:b.string().nullable().optional(),instance_id:b.string().nullable().optional(),machine_info:En.nullable().optional(),updated_at:b.string().nullable().optional()}),gf=b.object({id:b.string(),name:b.string(),app_id:b.string(),app_provision_type:b.string().nullable().optional(),app_icon_url:b.string().nullable().optional(),created_at:b.string(),kms_type:b.string(),current_cvm:Ys.nullable().optional(),cvms:b.array(Ys).default([]),cvm_count:b.number().int().default(0)}),xf=b.object({id:b.null().optional(),app_id:b.string(),name:b.null().optional(),app_provision_type:b.null().optional(),app_icon_url:b.null().optional(),created_at:b.null().optional(),kms_type:b.null().optional(),current_cvm:b.null().optional(),cvms:b.null().optional(),cvm_count:b.null().optional()}),bf=b.union([gf,xf]),Pb=b.object({dstack_apps:b.array(bf),page:b.number().int(),page_size:b.number().int(),total:b.number().int(),total_pages:b.number().int()}),yf=$.object({id:$.string(),name:$.string(),app_id:$.string(),app_provision_type:$.string().nullable().optional(),app_icon_url:$.string().nullable().optional(),created_at:$.string(),kms_type:$.string(),current_cvm:$r.nullable().optional(),cvms:$.array($r).default([]),cvm_count:$.number().int().default(0)}),vf=$.object({id:$.null().optional(),app_id:$.string(),name:$.null().optional(),app_provision_type:$.null().optional(),app_icon_url:$.null().optional(),created_at:$.null().optional(),kms_type:$.null().optional(),current_cvm:$.null().optional(),cvms:$.null().optional(),cvm_count:$.null().optional()}),wf=$.union([yf,vf]),$b=$.object({dstack_apps:$.array(wf),page:$.number().int(),page_size:$.number().int(),total:$.number().int(),total_pages:$.number().int()}),vi=A.object({object_type:A.literal("cvm"),id:A.string().nullable().optional(),name:A.string().nullable().optional(),app_id:A.string().nullable().optional(),vm_uuid:A.string().nullable().optional()}),_f=A.object({app_id:A.string(),vm_uuid:A.string(),compose_hash:A.string(),created_at:A.string(),trace_id:A.string().nullable().optional(),operation_type:A.string(),triggered_by:An.nullable().optional(),cvm:vi.nullable().optional(),workspace:Pn.nullable().optional()}),Bb=A.object({app_id:A.string(),vm_uuid:A.string(),compose_hash:A.string(),compose_file:A.union([A.record(A.any()),A.string()]).nullable().optional(),encrypted_env:A.string(),user_config:A.string(),created_at:A.string(),trace_id:A.string().nullable().optional(),operation_type:A.string(),triggered_by:An.nullable().optional(),cvm:vi.nullable().optional(),workspace:Pn.nullable().optional()}),zb=A.object({revisions:A.array(_f),total:A.number().int(),page:A.number().int(),page_size:A.number().int(),total_pages:A.number().int()});var Cf=N.object({chain:N.unknown().optional(),rpcUrl:N.string().optional(),kmsContractAddress:N.string(),privateKey:N.string().optional(),walletClient:N.unknown().optional(),publicClient:N.unknown().optional(),allowAnyDevice:N.boolean().optional().default(!1),deviceId:N.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),composeHash:N.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),disableUpgrades:N.boolean().optional().default(!1),skipPrerequisiteChecks:N.boolean().optional().default(!1),minBalance:N.string().optional()}).passthrough(),Ob=Cf.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,n=!!e.chain;return t&&r?!0:n},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),Hb=N.object({appId:N.string(),appAuthAddress:N.string(),deployer:N.string(),transactionHash:N.string(),blockNumber:N.bigint().optional(),gasUsed:N.bigint().optional()}).passthrough();var Gb=F.object({chain:F.unknown().optional(),rpcUrl:F.string().optional(),appId:F.string(),composeHash:F.string(),privateKey:F.string().optional(),walletClient:F.unknown().optional(),publicClient:F.unknown().optional(),skipPrerequisiteChecks:F.boolean().optional().default(!1),minBalance:F.string().optional(),timeout:F.number().optional().default(12e4),retryOptions:F.unknown().optional(),signal:F.unknown().optional(),onTransactionStateChange:F.function().optional(),onTransactionSubmitted:F.function().optional(),onTransactionConfirmed:F.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,n=!!e.chain;return t&&r?!0:n},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),qb=F.object({composeHash:F.string(),appId:F.string(),transactionHash:F.string(),blockNumber:F.bigint().optional(),gasUsed:F.bigint().optional()}).passthrough();var kf=se.object({id:se.number().nullable(),name:se.string().nullable(),region:se.string().nullable(),device_id:se.string().nullable(),ppid:se.string().nullable(),status:se.string().nullable(),version:se.string().nullable()}).passthrough(),Sf=se.object({items:se.array(kf),total:se.number(),page:se.number(),page_size:se.number(),pages:se.number()}).passthrough(),{action:Mb,safeAction:Vb}=E(Sf,async(e,t)=>{let{teamSlug:r,page:n,pageSize:o}=t,s=new URLSearchParams;n!==void 0&&s.append("page",n.toString()),o!==void 0&&s.append("page_size",o.toString());let i=s.toString()?`/workspaces/${r}/nodes?${s.toString()}`:`/workspaces/${r}/nodes`;return await e.get(i)}),Ct=we.object({limit:we.number(),remaining:we.number()}).passthrough(),Tf=we.object({vm_slots:Ct,vcpu:Ct,memory_mb:Ct,disk_gb:Ct}).passthrough(),Ef=we.object({gpus:Ct,in_use:we.number(),misconfigured:we.number()}).passthrough(),If=we.object({team_slug:we.string(),tier:we.string(),quotas:Tf,reserved_nodes:Ct,reserved_gpu:Ef,as_of:we.string()}).passthrough(),{action:Wb,safeAction:Xb}=E(If,async(e,t)=>await e.get(`/workspaces/${t.teamSlug}/quotas`)),Zb=wt.object({target:wt.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),interval:wt.number().min(5).max(30).default(5).describe("Polling interval in seconds"),timeout:wt.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),maxRetries:wt.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),retryDelay:wt.number().min(0).default(5e3).describe("Delay between retries in milliseconds")});var Af=Q.object({vm_uuid:Q.string(),status:Q.string(),uptime:Q.string().nullable().optional(),in_progress:Q.boolean(),boot_progress:Q.string().nullable().optional(),boot_error:Q.string().nullable().optional(),operation_type:Q.string().nullable().optional(),operation_started_at:Q.string().nullable().optional(),correlation_id:Q.string().nullable().optional()}),Pf=Q.record(Q.string(),Af),Lf=Q.object({vmUuids:Q.array(Q.string())}),{action:Qb,safeAction:ey}=E(Pf,async(e,t)=>{let{vmUuids:r}=Lf.parse(t);return await e.post("/status/batch",{vm_uuids:r})}),ry=le.object({page:le.number().int().min(1).optional(),page_size:le.number().int().min(1).max(100).optional(),search:le.string().optional(),status:le.array(le.string()).optional(),listed:le.boolean().optional(),base_image:le.string().optional(),instance_type:le.string().optional(),kms_slug:le.string().optional(),kms_type:le.string().optional(),teepod_name:le.string().optional(),region:le.string().optional()}).strict();var oy=Qs.object({appId:Qs.string().min(1)}).strict();var iy=ei.object({appId:ei.string().min(1)}).strict();var cy=Ar.object({appId:Ar.string().min(1),page:Ar.number().int().min(1).optional(),page_size:Ar.number().int().min(1).max(1e3).optional()}).strict();var uy=Pr.object({appId:Pr.string().min(1),composeHash:Pr.string().min(1),rawComposeFile:Pr.boolean().optional()}).strict();import Of from"path";import Bn from"fs-extra";import Hf from"@iarna/toml";import{z as $e}from"zod";import ee from"chalk";import jf from"ora";var zf=!1;function _e(){return zf}function Uf(e,t){let r=e.split(/\s+/),n=[],o="";for(let s of r){let i=o.length===0?s:`${o} ${s}`;i.length<=t?o=i:(o.length>0&&n.push(o),o=s)}return o.length>0&&n.push(o),n}function Ff(e,t){if(e.length<=t)return[e];let r=[],n=0;for(;n<e.length;)r.push(e.slice(n,n+t)),n+=t;return r}function wi(e,t){let r=[];for(let n of e.split(`
26
- `)){if(n.length<=t){r.push(n);continue}if(n.indexOf(" ")===-1){r.push(...Ff(n,t));continue}let o=Uf(n,t);r.push(...o)}if(r.length===0){let n=e.trim();r.push(n)}return r}var Xe={error:(e,...t)=>{_e()||(process.stderr.write(`${ee.red("\u2717")} ${ee.red(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
27
- `))},warn:(e,...t)=>{_e()||(process.stderr.write(`${ee.yellow("\u26A0")} ${ee.yellow(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
28
- `))},info:(e,...t)=>{_e()||(process.stderr.write(`${ee.blue("\u2139")} ${ee.blue(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
29
- `))},success:(e,...t)=>{_e()||(process.stderr.write(`${ee.green("\u2713")} ${ee.green(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
30
- `))},debug:(e,...t)=>{_e()||process.env.DEBUG&&(process.stderr.write(`${ee.gray("\u{1F50D}")} ${ee.gray(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
31
- `))},table:(e,t)=>{if(!_e()){if(e.length===0){console.log(ee.yellow("No data to display"));return}if(t){let r;typeof t[0]=="string"?r=t.map(i=>({key:i,header:i})):r=t;let n={};for(let i of r){let a=i.header||String(i.key);n[String(i.key)]=a.length}for(let i of e)for(let a of r){let l=String(typeof a.key=="string"&&!(a.key in i)?"":i[String(a.key)]??"");n[String(a.key)]=Math.max(n[String(a.key)],l.length)}let o=[];for(let i of r){let a=i.header||String(i.key);o.push(ee.bold(a.padEnd(n[String(i.key)])))}console.log(o.join(" "));let s=[];for(let i of r)s.push("-".repeat(n[String(i.key)]));console.log(s.join(" "));for(let i of e){let a=[];for(let l of r){let u=String(typeof l.key=="string"&&!(l.key in i)?"":i[String(l.key)]??"");a.push(u.padEnd(n[String(l.key)]))}console.log(a.join(" "))}}else{let r=e[0],n=Object.keys(r),o={};for(let a of n)o[a]=a.length;for(let a of e)for(let l of n){let u=String(a[l]??"");o[l]=Math.max(o[l],u.length)}let s=[];for(let a of n)s.push(ee.bold(a.padEnd(o[a])));console.log(s.join(" "));let i=[];for(let a of n)i.push("-".repeat(o[a]));console.log(i.join(" "));for(let a of e){let l=[];for(let u of n){let p=String(a[u]??"");l.push(p.padEnd(o[u]))}console.log(l.join(" "))}}}},keyValueTable:(e,t)=>{if(_e())return;let{borderStyle:r="single",keyColor:n=ee.blue,valueColor:o=ee.white,maxWidth:s=process.stdout.columns||80}=t||{},a={single:{topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502",cross:"\u253C",leftT:"\u251C",rightT:"\u2524"},double:{topLeft:"\u2554",topRight:"\u2557",bottomLeft:"\u255A",bottomRight:"\u255D",horizontal:"\u2550",vertical:"\u2551",cross:"\u256C",leftT:"\u2560",rightT:"\u2563"},rounded:{topLeft:"\u256D",topRight:"\u256E",bottomLeft:"\u2570",bottomRight:"\u256F",horizontal:"\u2500",vertical:"\u2502",cross:"\u253C",leftT:"\u251C",rightT:"\u2524"},bold:{topLeft:"\u250F",topRight:"\u2513",bottomLeft:"\u2517",bottomRight:"\u251B",horizontal:"\u2501",vertical:"\u2503",cross:"\u254B",leftT:"\u2523",rightT:"\u252B"},none:{topLeft:"",topRight:"",bottomLeft:"",bottomRight:"",horizontal:"",vertical:"",cross:"",leftT:"",rightT:""}}[r],l=0,u=0;for(let[_,I]of Object.entries(e)){l=Math.max(l,_.length);let R=String(I??"");u=Math.max(u,R.length)}let p=4,f=1,h=s-p-f;if(l+u>h){let _=l/(l+u);l=Math.floor(h*_),u=h-l}let g=l+u+p+f;r!=="none"&&console.log(a.topLeft+a.horizontal.repeat(g-2)+a.topRight);for(let[_,I]of Object.entries(e)){let R=_,G=String(I??""),J=wi(R,l),K=wi(G,u),Z=Math.max(J.length,K.length);for(;J.length<Z;)J.push("");for(;K.length<Z;)K.push("");for(let te=0;te<Z;te++){let pe=J[te].padEnd(l),Mt=K[te].padEnd(u);console.log(r!=="none"?`${a.vertical} ${n(pe)} ${a.vertical} ${o(Mt)} ${a.vertical}`:`${n(pe)} : ${o(Mt)}`)}}r!=="none"&&console.log(a.bottomLeft+a.horizontal.repeat(g-2)+a.bottomRight)},break:()=>{_e()||process.stderr.write(`
32
- `)},startSpinner:e=>{if(_e())return{stop:()=>{}};let t=jf(e).start();return{stop:(r=!0,n)=>{n&&(t.text=n),r?t.succeed():t.fail()}}},logDetailedError(e,t){if(_e())return;let r=t?`[${t}] `:"",n=s=>s!==null&&typeof s=="object"&&"isRequestError"in s&&s.isRequestError===!0&&"status"in s&&"message"in s&&"data"in s,o=s=>s!==null&&typeof s=="object"&&"issues"in s&&Array.isArray(s.issues);if(n(e)){process.stderr.write(`${r}HTTP ${e.status}: ${e.message}
25
+ `,R,G,Js(_.status,_.statusText,_.headers,_._data))}p&&p({request:g,response:_,options:P})}})}get raw(){return this.fetchInstance}on(t,r){this.emitter.on(t,r)}off(t,r){this.emitter.off(t,r)}once(t,r){let n=o=>{r(o),this.emitter.off(t,n)};this.emitter.on(t,n)}async request(t,r){try{let n=r?.method||"GET";return await this.fetchInstance(t,{...r,method:n})}catch(n){let o=this.convertToRequestError(n);throw this.emitError(o)}}async requestFull(t,r){try{let n=r?.method||"GET",o=await this.fetchInstance.raw(t,{...r,method:n,ignoreResponseError:!0});return{status:o.status,statusText:o.statusText,headers:o.headers,data:o._data,ok:o.ok}}catch(n){let o=this.convertToRequestError(n);throw this.emitError(o)}}async get(t,r){try{return await this.fetchInstance(t,{...r,method:"GET"})}catch(n){let o=this.convertToRequestError(n);throw this.emitError(o)}}async post(t,r,n){try{return await this.fetchInstance(t,{...n,method:"POST",body:r})}catch(o){let s=this.convertToRequestError(o);throw this.emitError(s)}}async put(t,r,n){try{return await this.fetchInstance(t,{...n,method:"PUT",body:r})}catch(o){let s=this.convertToRequestError(o);throw this.emitError(s)}}async patch(t,r,n){try{return await this.fetchInstance(t,{...n,method:"PATCH",body:r})}catch(o){let s=this.convertToRequestError(o);throw this.emitError(s)}}async delete(t,r){try{return await this.fetchInstance(t,{...r,method:"DELETE"})}catch(n){let o=this.convertToRequestError(n);throw this.emitError(o)}}convertToRequestError(t){return t&&typeof t=="object"&&"data"in t?kn.fromFetchError(t):t instanceof Error?kn.fromError(t):new kn("Unknown error occurred",{detail:"Unknown error occurred"})}emitError(t){let r=tl(t);return this.emitter.emit("error",r),r}async safeRequest(t){try{return{success:!0,data:await t()}}catch(r){if(r instanceof Ae)return{success:!1,error:r};let n=this.convertToRequestError(r);return this.emitError(n),{success:!1,error:n}}}async safeGet(t,r){return this.safeRequest(()=>this.get(t,r))}async safePost(t,r,n){return this.safeRequest(()=>this.post(t,r,n))}async safePut(t,r,n){return this.safeRequest(()=>this.put(t,r,n))}async safePatch(t,r,n){return this.safeRequest(()=>this.patch(t,r,n))}async safeDelete(t,r){return this.safeRequest(()=>this.delete(t,r))}async safeRequestMethod(t,r){return this.safeRequest(()=>this.request(t,r))}async safeRequestFull(t,r){return this.safeRequest(()=>this.requestFull(t,r))}withVersion(t){return new ii({...this.config,version:t})}extend(t){let r=typeof t=="function"?t(this):t,n=Object.create(this);for(let[o,s]of Object.entries(r))typeof s=="function"&&(n[o]=(...i)=>s(this,...i));return n}};function cl(e={}){return new al(e)}var ll=j.object({username:j.string(),email:j.string(),role:j.enum(["admin","user"]),avatar:j.string(),email_verified:j.boolean(),totp_enabled:j.boolean(),has_backup_codes:j.boolean(),flag_has_password:j.boolean()}).passthrough(),ul=j.object({id:j.string(),name:j.string(),slug:j.string().nullable(),tier:j.string(),role:j.string(),avatar:j.string().nullable().optional()}).passthrough(),pl=j.object({balance:j.string().or(j.number()),granted_balance:j.string().or(j.number()),is_post_paid:j.boolean(),outstanding_amount:j.string().or(j.number()).nullable()}).passthrough(),fl=j.object({user:ll,workspace:ul,credits:pl}).passthrough(),ml=Ve.object({username:Ve.string(),email:Ve.string(),credits:Ve.number(),granted_credits:Ve.number(),avatar:Ve.string(),team_name:Ve.string(),team_tier:Ve.string()}).passthrough();function dl(e){return e==="2025-10-28"?ml:fl}async function ai(e,t){let r=await e.get("/auth/me");return t?.schema===!1?r:(t?.schema||dl(e.config.version)).parse(r)}async function hl(e,t){try{return{success:!0,data:await ai(e,t)}}catch(r){return r&&typeof r=="object"&&("status"in r||"issues"in r)?{success:!1,error:r}:{success:!1,error:{name:"Error",message:r instanceof Error?r.message:String(r)}}}}var gl={[Er.id]:Er,[Ht.id]:Ht,[Sr.id]:Sr},xl=Ke.object({id:Ke.string(),slug:Ke.string().nullable(),url:Ke.string(),version:Ke.string(),chain_id:Ke.number().nullable(),kms_contract_address:Ke.string().nullable().transform(e=>e),gateway_app_id:Ke.string().nullable().transform(e=>e)}).passthrough(),Pe=xl.transform(e=>{if(e.chain_id!=null){let t=gl[e.chain_id];if(t)return{...e,chain:t}}return e});function ci(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 li(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 bl(e,t){function r(i,a){return n(i,a)}async function n(i,a){ci(a);let l=await t(i);return a?.schema===!1?l:(a?.schema||e).parse(l)}function o(i,a){return s(i,a)}async function s(i,a){let l=li(a);if(l)return l;let u=await(async()=>{try{return{success:!0,data:await t(i)}}catch(f){return f&&typeof f=="object"&&"status"in f?{success:!1,error:f}:f&&typeof f=="object"&&"issues"in f?{success:!1,error:f}:{success:!1,error:{name:"Error",message:f instanceof Error?f.message:String(f)}}}})();return u.success?a?.schema===!1?{success:!0,data:u.data}:(a?.schema||e).safeParse(u.data):u}return{action:r,safeAction:o}}function T(e,t){function r(i,...a){let[l,u]=a;return n(i,l,u)}async function n(i,a,l){ci(l);let u=await t(i,a);return l?.schema===!1?u:(l?.schema||e).parse(u)}function o(i,...a){let[l,u]=a;return s(i,l,u)}async function s(i,a,l){let u=li(l);if(u)return u;let p=await(async()=>{try{return{success:!0,data:await t(i,a)}}catch(h){return h&&typeof h=="object"&&"status"in h?{success:!1,error:h}:h&&typeof h=="object"&&"issues"in h?{success:!1,error:h}:{success:!1,error:{name:"Error",message:h instanceof Error?h.message:String(h)}}}})();return p.success?l?.schema===!1?{success:!0,data:p.data}:(l?.schema||e).safeParse(p.data):p}return{action:r,safeAction:o}}var yl=k.object({name:k.string(),is_dev:k.boolean(),version:k.union([k.tuple([k.number(),k.number(),k.number()]),k.tuple([k.number(),k.number(),k.number(),k.number()])]),os_image_hash:k.string().nullable().optional()}).passthrough(),vl=k.object({teepod_id:k.number(),name:k.string(),listed:k.boolean(),resource_score:k.number(),remaining_vcpu:k.number(),remaining_memory:k.number(),remaining_cvm_slots:k.number(),images:k.array(yl),support_onchain_kms:k.boolean().optional(),fmspc:k.string().nullable().optional(),device_id:k.string().nullable().optional(),region_identifier:k.string().nullable().optional(),default_kms:k.string().nullable().optional(),kms_list:k.array(k.string()).default([])}).passthrough(),wl=k.object({max_instances:k.number().nullable().optional(),max_vcpu:k.number().nullable().optional(),max_memory:k.number().nullable().optional(),max_disk:k.number().nullable().optional()}).passthrough(),_l=k.object({tier:k.string(),capacity:wl,nodes:k.array(vl),kms_list:k.array(Pe)}).passthrough(),{action:Cl,safeAction:kl}=bl(_l,async e=>await e.get("/teepods/available")),ui=H.object({id:H.string(),name:H.string(),description:H.string(),vcpu:H.number(),memory_mb:H.number(),hourly_rate:H.string(),requires_gpu:H.boolean(),default_disk_size_gb:H.number().default(20),family:H.string().nullable()}).passthrough(),Sl=H.object({name:H.string(),items:H.array(ui),total:H.number()}).strict(),El=H.object({result:H.array(Sl)}).strict(),Tl=H.object({items:H.array(ui),total:H.number(),family:H.string()}).strict(),Il=H.object({family:H.string()}).strict(),{action:Al,safeAction:Pl}=T(El,async e=>await e.get("/instance-types")),{action:Ll,safeAction:$l}=T(Tl,async(e,t)=>{let r=Il.parse(t);return await e.get(`/instance-types/${r.family}`)}),pi=ie.object({id:ie.string(),name:ie.string(),slug:ie.string().nullable(),tier:ie.string(),role:ie.string(),is_default:ie.boolean(),created_at:ie.string()}).passthrough(),Rl=ie.object({has_more:ie.boolean(),next_cursor:ie.string().nullable(),total:ie.number().nullable()}).passthrough(),Bl=ie.object({data:ie.array(pi),pagination:Rl}).passthrough(),{action:zl,safeAction:jl}=T(Bl,async(e,t)=>{let r=new URLSearchParams;t?.cursor&&r.append("cursor",t.cursor),t?.limit&&r.append("limit",t.limit.toString());let n=r.toString()?`/workspaces?${r.toString()}`:"/workspaces";return await e.get(n)}),{action:Ul,safeAction:Fl}=T(pi,async(e,t)=>await e.get(`/workspaces/${t}`)),Ol=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()}),Hl=m.object({id:m.number(),username:m.string()}),fi=m.object({id:m.number(),name:m.string(),region_identifier:m.string().nullable().optional()}),An=m.object({vcpu:m.number(),memory:m.number(),disk_size:m.number(),gpu_count:m.number().default(0)}),Pn=m.object({app:m.string(),instance:m.string()}),Nl=m.object({hosted:Ol,name:m.string(),managed_user:Hl.nullable(),node:fi.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:Pe.nullable(),vcpu:m.number().nullable(),memory:m.number().nullable(),disk_size:m.number().nullable(),gateway_domain:m.string().nullable(),public_urls:m.array(Pn),machine_info:An.nullable().optional(),updated_at:m.string().nullable().optional()}),mi=m.object({id:m.number(),name:m.string(),status:m.string(),in_progress:m.boolean().optional().default(!1),teepod_id:m.number().nullable(),teepod:fi.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(),instance_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:Pe.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(Pn).optional().default([]),gateway_domain:m.string().optional().nullable(),machine_info:An.optional().nullable(),updated_at:m.string().optional().nullable()}),Gl=m.object({items:m.array(Nl),total:m.number(),page:m.number(),page_size:m.number(),pages:m.number()}),ql=d.enum(["skip","hourly","monthly"]),Dl=d.enum(["phala","ethereum","base","legacy"]),Ln=d.object({object_type:d.literal("user"),id:d.string().nullable().optional(),username:d.string().nullable().optional(),avatar_url:d.string().nullable().optional()}),$n=d.object({object_type:d.literal("workspace"),id:d.string(),name:d.string(),slug:d.string().nullable().optional(),avatar_url:d.string().nullable().optional()}),Ml=d.object({instance_type:d.string().nullable().optional(),vcpu:d.number().int().nullable().optional(),memory_in_gb:d.number().nullable().optional(),disk_in_gb:d.number().int().nullable().optional(),gpus:d.number().int().nullable().optional(),compute_billing_price:d.string().nullable().optional(),billing_period:ql.nullable().optional()}),Vl=d.object({name:d.string().nullable().optional(),version:d.string().nullable().optional(),is_dev:d.boolean().nullable().optional(),os_image_hash:d.string().nullable().optional()}),Kl=d.object({chain_id:d.number().int().nullable().optional(),dstack_kms_address:d.string().nullable().optional(),dstack_app_address:d.string().nullable().optional(),deployer_address:d.string().nullable().optional(),rpc_endpoint:d.string().nullable().optional(),encrypted_env_pubkey:d.string().nullable().optional()}),Wl=d.object({target:d.string().nullable().optional(),started_at:d.string().nullable().optional(),correlation_id:d.string().nullable().optional()}),Xl=d.object({base_domain:d.string().nullable().optional(),cname:d.string().nullable().optional()}),di=d.object({object_type:d.literal("node"),id:d.number().int().nullable().optional(),name:d.string().nullable().optional(),region:d.string().nullable().optional(),device_id:d.string().nullable().optional(),ppid:d.string().nullable().optional(),status:d.string().nullable().optional(),version:d.string().nullable().optional()});var Rr=d.object({id:d.string(),name:d.string(),app_id:d.string().nullable().optional(),vm_uuid:d.string().nullable().optional(),resource:Ml,node_info:di.nullable().optional(),os:Vl.nullable().optional(),kms_type:Dl.nullable().optional(),kms_info:Kl.nullable().optional(),status:d.string(),progress:Wl.nullable().optional(),compose_hash:d.string().nullable().optional(),gateway:Xl,services:d.array(d.record(d.any())).optional().default([]),endpoints:d.array(Pn).nullable().optional(),public_logs:d.boolean().optional(),public_sysinfo:d.boolean().optional(),public_tcbinfo:d.boolean().optional(),gateway_enabled:d.boolean().optional(),secure_time:d.boolean().optional(),storage_fs:d.string().optional(),workspace:$n.nullable().optional(),creator:Ln.nullable().optional()}),Jl=Rr.extend({compose_file:d.union([d.record(d.any()),d.string()]).nullable().optional()}),Zl=d.object({items:d.array(Rr),total:d.number(),page:d.number(),page_size:d.number(),pages:d.number()});function hi(e){return typeof e!="string"||e.length<5||e.length>63?!1:/^[a-zA-Z](?!.*--)([a-zA-Z0-9-]*[a-zA-Z0-9])?$/.test(e)}var Le=yt.object({id:yt.string().optional(),uuid:yt.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:yt.string().optional(),instance_id:yt.string().optional(),name:yt.string().refine(hi,{message:"Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens"}).optional()}),We=e=>e.refine(t=>{let r=t;return!!(r.id||r.uuid||r.app_id||r.instance_id||r.name)},{message:"One of id, uuid, app_id, instance_id, or name must be provided"}),Yl=We(Le),U=Yl.transform(e=>{let t;if(e.id)t=e.id;else if(e.uuid)t=e.uuid;else if(e.app_id)t=e.app_id;else if(e.instance_id)t=e.instance_id;else{if(e.name)return{cvmId:e.name};throw new Error("No valid identifier provided")}let r=/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i,n=/^[0-9a-f]{40}$/i,o;return r.test(t)?o=t.replace(/-/g,""):n.test(t)?o=`app_${t}`:o=t,{cvmId:o}}),Ql=U;function eu(e){return e==="2025-10-28"?mi:Jl}async function gi(e,t){let{cvmId:r}=Ql.parse(t),n=await e.get(`/cvms/${r}`);return eu(e.config.version).parse(n)}async function Rn(e,t){try{return{success:!0,data:await gi(e,t)}}catch(r){return r&&typeof r=="object"&&("status"in r||"issues"in r)?{success:!1,error:r}:{success:!1,error:{name:"Error",message:r instanceof Error?r.message:String(r)}}}}var tu=vt.object({page:vt.number().int().min(1).optional(),page_size:vt.number().int().min(1).optional(),node_id:vt.number().int().min(1).optional(),teepod_id:vt.number().int().min(1).optional(),user_id:vt.string().optional()}).strict();function ru(e){return e==="2025-10-28"?Gl:Zl}async function xi(e,t){let r=tu.parse(t??{}),n=await e.get("/cvms/paginated",{params:r});return ru(e.config.version).parse(n)}async function Bn(e,t){try{return{success:!0,data:await xi(e,t)}}catch(r){return r&&typeof r=="object"&&("status"in r||"issues"in r)?{success:!1,error:r}:{success:!1,error:{name:"Error",message:r instanceof Error?r.message:String(r)}}}}var Zs=200*1024;function bi(e,t,r){let n=new TextEncoder,o=e?n.encode(e).byteLength:0,s=t?n.encode(t).byteLength:0,i=o+s;if(i>Zs){let a=Zs/1024,l=Math.ceil(i/1024);r.addIssue({code:X.ZodIssueCode.custom,message:`Combined size of docker_compose_file and pre_launch_script must not exceed ${a}KB (current: ${l}KB)`})}}var yi=X.object({allowed_envs:X.array(X.string()).optional(),docker_compose_file:X.string(),features:X.array(X.string()).optional(),name:X.string().optional(),manifest_version:X.number().optional(),kms_enabled:X.boolean().optional(),public_logs:X.boolean().optional(),public_sysinfo:X.boolean().optional(),tproxy_enabled:X.boolean().optional(),pre_launch_script:X.string().optional(),env_pubkey:X.string().optional(),salt:X.string().optional().nullable()}).passthrough().superRefine((e,t)=>{bi(e.docker_compose_file,e.pre_launch_script,t)}),nu=C.object({app_id:C.string().nullable().optional(),app_env_encrypt_pubkey:C.string().nullable().optional(),compose_hash:C.string(),kms_info:Pe.nullable().optional(),fmspc:C.string().nullable().optional(),device_id:C.string().nullable().optional(),os_image_hash:C.string().nullable().optional(),instance_type:C.string().nullable().optional(),teepod_id:C.number().nullable().optional(),node_id:C.number().nullable().optional(),kms_id:C.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}),Sn="Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens",ou=C.object({node_id:C.number().optional(),teepod_id:C.number().optional(),region:C.string().optional(),name:C.string().min(5,Sn).max(63,Sn).refine(e=>hi(e),Sn),instance_type:C.string().optional(),image:C.string().optional(),vcpu:C.number().optional(),memory:C.number().optional(),disk_size:C.number().optional(),compose_file:C.object({allowed_envs:C.array(C.string()).optional(),pre_launch_script:C.string().optional(),docker_compose_file:C.string().optional(),name:C.string().optional().default(""),kms_enabled:C.boolean().optional(),public_logs:C.boolean().optional(),public_sysinfo:C.boolean().optional(),gateway_enabled:C.boolean().optional(),tproxy_enabled:C.boolean().optional()}).superRefine((e,t)=>{bi(e.docker_compose_file,e.pre_launch_script,t)}),listed:C.boolean().optional(),kms_id:C.string().optional(),kms:C.enum(["PHALA","ETHEREUM","BASE"]).optional(),kms_contract:C.string().optional(),env_keys:C.array(C.string()).optional(),nonce:C.number().optional(),app_id:C.string().optional()}).passthrough().transform(e=>!e.instance_type&&!e.vcpu&&!e.memory?{...e,instance_type:"tdx.small"}:e);function su(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:iu,safeAction:au}=T(nu,async(e,t)=>{let r=ou.parse(t),n=su(r),o={...n};return typeof n.node_id=="number"?(o={...n,teepod_id:n.node_id},delete o.node_id):typeof n.teepod_id=="number"&&console.warn("[phala/cloud] teepod_id is deprecated, please use node_id instead."),await e.post("/cvms/provision",o)}),cu=E.object({id:E.number(),name:E.string(),status:E.string(),teepod_id:E.number(),teepod:E.object({id:E.number(),name:E.string()}).nullable(),user_id:E.number().nullable(),app_id:E.string().nullable(),vm_uuid:E.string().nullable(),instance_id:E.string().nullable(),app_url:E.string().nullable().default(null),base_image:E.string().nullable(),vcpu:E.number(),memory:E.number(),disk_size:E.number(),manifest_version:E.number().nullable().default(2),version:E.string().nullable().default("1.0.0"),runner:E.string().nullable().default("docker-compose"),docker_compose_file:E.string().nullable(),features:E.array(E.string()).nullable().default(["kms","tproxy-net"]),created_at:E.string(),encrypted_env_pubkey:E.string().nullable().optional(),app_auth_contract_address:E.string().nullable().optional(),deployer_address:E.string().nullable().optional()}).passthrough(),cb=E.object({encrypted_env:E.string().optional().nullable(),app_id:E.string(),compose_hash:E.string(),kms_id:E.string().optional(),contract_address:E.string().optional(),deployer_address:E.string().optional(),env_keys:E.array(E.string()).optional().nullable()}).passthrough(),{action:lu,safeAction:uu}=T(cu,async(e,t)=>await e.post("/cvms",t));function Tn(e){return e==null?e:Array.isArray(e)?e.map(Tn):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let n=e[r];return t[r]=Tn(n),t},{}):e}function vi(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 wi(e){let t=Tn(e),r=JSON.stringify(t,null,4);return r=r.replace(/": /g,'":'),r}function fu(e){let t=vi(e),r=wi(t);return pu.createHash("sha256").update(r,"utf8").digest("hex")}function mu(e){let t=e;return{...e,getHash:()=>fu(t),toString:()=>wi(vi(t))}}var du=yi.transform(e=>mu(e)),hu=U,{action:gu,safeAction:zn}=T(du,async(e,t)=>{let{cvmId:r}=hu.parse(t);return await e.get(`/cvms/${r}/compose_file`)}),xu=Te.object({id:Te.string().optional(),uuid:Te.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:Te.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:Te.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:yi,update_env_vars:Te.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})),bu=Te.object({app_id:Te.string().nullable(),device_id:Te.string().nullable(),compose_hash:Te.string(),kms_info:Pe.nullable().optional()}).passthrough(),{action:yu,safeAction:vu}=T(bu,async(e,t)=>{let r=xu.parse(t);return await e.post(`/cvms/${r.cvmId}/compose_file/provision`,r.request)}),wu=ve.object({id:ve.string().optional(),uuid:ve.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:ve.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:ve.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:ve.string().min(1,"Compose hash is required"),encrypted_env:ve.string().optional(),env_keys:ve.array(ve.string()).optional(),update_env_vars:ve.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??void 0,_raw:e})),_u=ve.any().transform(()=>{}),{action:Cu,safeAction:ku}=T(_u,async(e,t)=>{let r=wu.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,update_env_vars:r.update_env_vars})}),Su=We(Le.extend({encrypted_env:V.string().describe("Encrypted environment variables (hex string)"),env_keys:V.array(V.string()).optional().describe("List of allowed environment variable keys"),compose_hash:V.string().optional().describe("Compose hash for verification (Phase 2, required when env_keys changes)"),transaction_hash:V.string().optional().describe("On-chain transaction hash for verification (Phase 2, required when env_keys changes)")})).transform(e=>{let{cvmId:t}=U.parse(e);return{cvmId:t,request:{encrypted_env:e.encrypted_env,env_keys:e.env_keys,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),Eu=V.object({status:V.literal("in_progress"),message:V.string(),correlation_id:V.string(),allowed_envs_changed:V.boolean()}),Tu=V.object({status:V.literal("precondition_required"),message:V.string(),compose_hash:V.string(),app_id:V.string(),device_id:V.string(),kms_info:Pe}),Iu=V.union([Eu,Tu]),{action:Au,safeAction:Pu}=T(Iu,async(e,t)=>{let r=Su.parse(t);try{return await e.patch(`/cvms/${r.cvmId}/envs`,r.request)}catch(n){if(n instanceof Ae&&n.status===465){let o=n.detail;if(o&&typeof o=="object"){let s=o;return{status:"precondition_required",message:s.message||"Compose hash verification required",compose_hash:s.compose_hash,app_id:s.app_id,device_id:s.device_id,kms_info:s.kms_info}}}throw n}}),Lu=We(Le.extend({docker_compose_file:ae.string().describe("Docker Compose YAML content"),compose_hash:ae.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:ae.string().optional().describe("On-chain transaction hash for verification (Phase 2, contract-owned KMS only)")})).transform(e=>{let{cvmId:t}=U.parse(e);return{cvmId:t,request:{docker_compose_file:e.docker_compose_file,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),$u=ae.object({status:ae.literal("in_progress"),message:ae.string(),correlation_id:ae.string()}),Ru=ae.object({status:ae.literal("precondition_required"),message:ae.string(),compose_hash:ae.string(),app_id:ae.string(),device_id:ae.string(),kms_info:Pe}),Bu=ae.union([$u,Ru]),{action:zu,safeAction:ju}=T(Bu,async(e,t)=>{let r=Lu.parse(t),n={"Content-Type":"text/yaml"};r.request.compose_hash&&(n["X-Compose-Hash"]=r.request.compose_hash),r.request.transaction_hash&&(n["X-Transaction-Hash"]=r.request.transaction_hash);try{return await e.patch(`/cvms/${r.cvmId}/docker-compose`,r.request.docker_compose_file,{headers:n})}catch(o){if(o instanceof Ae&&o.status===465){let s=o.detail;if(s&&typeof s=="object"){let i=s;return{status:"precondition_required",message:i.message||"Compose hash verification required",compose_hash:i.compose_hash,app_id:i.app_id,device_id:i.device_id,kms_info:i.kms_info}}}throw o}}),Uu=We(Le.extend({pre_launch_script:ce.string().describe("Pre-launch script content (shell script)"),compose_hash:ce.string().optional().describe("Compose hash for verification (Phase 2, contract-owned KMS only)"),transaction_hash:ce.string().optional().describe("On-chain transaction hash for verification (Phase 2, contract-owned KMS only)")})).transform(e=>{let{cvmId:t}=U.parse(e);return{cvmId:t,request:{pre_launch_script:e.pre_launch_script,compose_hash:e.compose_hash,transaction_hash:e.transaction_hash},_raw:e}}),Fu=ce.object({status:ce.literal("in_progress"),message:ce.string(),correlation_id:ce.string()}),Ou=ce.object({status:ce.literal("precondition_required"),message:ce.string(),compose_hash:ce.string(),app_id:ce.string(),device_id:ce.string(),kms_info:Pe}),Hu=ce.union([Fu,Ou]),{action:Nu,safeAction:Gu}=T(Hu,async(e,t)=>{let r=Uu.parse(t),n={"Content-Type":"text/plain"};r.request.compose_hash&&(n["X-Compose-Hash"]=r.request.compose_hash),r.request.transaction_hash&&(n["X-Transaction-Hash"]=r.request.transaction_hash);try{return await e.patch(`/cvms/${r.cvmId}/pre-launch-script`,r.request.pre_launch_script,{headers:n})}catch(o){if(o instanceof Ae&&o.status===465){let s=o.detail;if(s&&typeof s=="object"){let i=s;return{status:"precondition_required",message:i.message||"Compose hash verification required",compose_hash:i.compose_hash,app_id:i.app_id,device_id:i.device_id,kms_info:i.kms_info}}}throw o}}),Du=U,{action:Mu,safeAction:Vu}=T(qu.string(),async(e,t)=>{let{cvmId:r}=Du.parse(t);return await e.get(`/cvms/${r}/pre-launch-script`)}),Ku=Ys.object({kms_id:Ys.string().min(1,"KMS ID is required")}),{action:Wu,safeAction:Xu}=T(Pe,async(e,t)=>{let r=Ku.parse(t);return await e.get(`/kms/${r.kms_id}`)}),Ju=Ie.object({page:Ie.number().int().min(1).optional(),page_size:Ie.number().int().min(1).optional(),is_onchain:Ie.boolean().optional()}).strict(),Zu=Ie.object({items:Ie.array(Pe),total:Ie.number(),page:Ie.number(),page_size:Ie.number(),pages:Ie.number()}).strict(),{action:Yu,safeAction:Qu}=T(Zu,async(e,t)=>{let r=Ju.parse(t??{});return await e.get("/kms",{params:r})}),ep=St.object({kms:St.string().min(1,"KMS ID or slug is required"),app_id:St.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(),tp=St.object({public_key:St.string(),signature:St.string()}).strict(),{action:rp,safeAction:np}=T(tp,async(e,t)=>{let r=ep.parse(t);return await e.get(`/kms/${r.kms}/pubkey/${r.app_id}`)}),op=st.object({counts:st.number().int().min(1).max(20).optional().default(1)}).strict(),sp=st.object({app_ids:st.array(st.object({app_id:st.string(),nonce:st.number().int().min(0)}))}).strict(),{action:ip,safeAction:ap}=T(sp,async(e,t)=>{let r=op.parse(t??{}),n=new URLSearchParams;return n.append("counts",r.counts.toString()),await e.get(`/kms/phala/next_app_id?${n.toString()}`)}),Br=B.object({id:B.number(),name:B.string(),status:B.string(),teepod_id:B.number(),teepod:B.object({id:B.number(),name:B.string(),region_identifier:B.string().nullable().optional()}).optional().nullable(),user_id:B.number().optional().nullable(),app_id:B.string(),vm_uuid:B.string().nullable(),instance_id:B.string().nullable(),app_url:B.string().optional().nullable(),base_image:B.string().nullable(),vcpu:B.number(),memory:B.number(),disk_size:B.number(),manifest_version:B.number().optional().nullable(),version:B.string().optional().nullable(),runner:B.string().optional().nullable(),docker_compose_file:B.string().optional().nullable(),features:B.array(B.string()).optional().nullable(),created_at:B.string(),encrypted_env_pubkey:B.string().nullable()}),cp=U,{action:lp,safeAction:up}=T(Br,async(e,t)=>{let{cvmId:r}=cp.parse(t);return await e.post(`/cvms/${r}/start`)}),pp=U,{action:fp,safeAction:mp}=T(Br,async(e,t)=>{let{cvmId:r}=pp.parse(t);return await e.post(`/cvms/${r}/stop`)}),dp=U,{action:hp,safeAction:gp}=T(Br,async(e,t)=>{let{cvmId:r}=dp.parse(t);return await e.post(`/cvms/${r}/shutdown`)}),bp=We(Le.extend({force:xp.boolean().optional()})),{action:yp,safeAction:vp}=T(Br,async(e,t)=>{let r=bp.parse(t),{cvmId:n}=U.parse(r),{force:o=!1}=r;return await e.post(`/cvms/${n}/restart`,{force:o})}),_p=U,{action:Cp,safeAction:kp}=T(wp.void(),async(e,t)=>{let{cvmId:r}=_p.parse(t);await e.delete(`/cvms/${r}`)}),Sp=$.object({name:$.string(),mount_point:$.string(),total_size:$.number(),free_size:$.number()}),Ep=$.object({os_name:$.string(),os_version:$.string(),kernel_version:$.string(),cpu_model:$.string(),num_cpus:$.number(),total_memory:$.number(),available_memory:$.number(),used_memory:$.number(),free_memory:$.number(),total_swap:$.number(),used_swap:$.number(),free_swap:$.number(),uptime:$.number(),loadavg_one:$.number(),loadavg_five:$.number(),loadavg_fifteen:$.number(),disks:$.array(Sp)}),Tp=$.object({is_online:$.boolean(),is_public:$.boolean().default(!1),error:$.string().nullable(),sysinfo:Ep.nullable(),status:$.string().nullable(),in_progress:$.boolean().default(!1),boot_progress:$.string().nullable(),boot_error:$.string().nullable()}),Ip=U,{action:Ap,safeAction:Pp}=T(Tp,async(e,t)=>{let{cvmId:r}=Ip.parse(t);return await e.get(`/cvms/${r}/stats`)}),Lp=Ee.object({app:Ee.string(),instance:Ee.string()}),$p=Ee.object({is_online:Ee.boolean(),is_public:Ee.boolean().default(!0),error:Ee.string().nullable(),internal_ip:Ee.string().nullable(),latest_handshake:Ee.string().nullable(),public_urls:Ee.array(Lp).nullable()}),Rp=U,{action:Bp,safeAction:zp}=T($p,async(e,t)=>{let{cvmId:r}=Rp.parse(t);return await e.get(`/cvms/${r}/network`)}),Up=U,{action:Fp,safeAction:Op}=T(jp.string(),async(e,t)=>{let{cvmId:r}=Up.parse(t);return await e.get(`/cvms/${r}/docker-compose.yml`)}),Hp=O.object({id:O.string(),names:O.array(O.string()),image:O.string(),image_id:O.string(),command:O.string().nullable().optional(),created:O.number(),state:O.string(),status:O.string(),log_endpoint:O.string().nullable()}),Np=O.object({is_online:O.boolean(),is_public:O.boolean().default(!0),error:O.string().nullable(),docker_compose_file:O.string().nullable(),manifest_version:O.number().nullable(),version:O.string().nullable(),runner:O.string().nullable(),features:O.array(O.string()).nullable(),containers:O.array(Hp).nullable()}),Gp=U,{action:qp,safeAction:Dp}=T(Np,async(e,t)=>{let{cvmId:r}=Gp.parse(t);return await e.get(`/cvms/${r}/composition`)}),Mp=y.object({common_name:y.string().nullable(),organization:y.string().nullable(),country:y.string().nullable(),state:y.string().nullable(),locality:y.string().nullable()}),Vp=y.object({common_name:y.string().nullable(),organization:y.string().nullable(),country:y.string().nullable()}),Kp=y.object({subject:Mp,issuer:Vp,serial_number:y.string(),not_before:y.string(),not_after:y.string(),version:y.string(),fingerprint:y.string(),signature_algorithm:y.string(),sans:y.array(y.string()).nullable(),is_ca:y.boolean(),position_in_chain:y.number().nullable(),quote:y.string().nullable(),app_id:y.string().nullable().optional(),cert_usage:y.string().nullable().optional()}),Wp=y.object({imr:y.number(),event_type:y.number(),digest:y.string(),event:y.string(),event_payload:y.string()}),Xp=y.object({mrtd:y.string(),rootfs_hash:y.string().nullable().optional(),rtmr0:y.string(),rtmr1:y.string(),rtmr2:y.string(),rtmr3:y.string(),event_log:y.array(Wp),app_compose:y.string()}),Jp=y.object({name:y.string().nullable(),is_online:y.boolean(),is_public:y.boolean().default(!0),error:y.string().nullable(),app_certificates:y.array(Kp).nullable(),tcb_info:Xp.nullable(),compose_file:y.string().nullable()}),Zp=U,{action:Yp,safeAction:Qp}=T(Jp,async(e,t)=>{let{cvmId:r}=Zp.parse(t);return await e.get(`/cvms/${r}/attestation`)}),ef=We(Le.extend({vcpu:Ct.number().optional(),memory:Ct.number().optional(),disk_size:Ct.number().optional(),instance_type:Ct.string().optional(),allow_restart:Ct.boolean().optional()})),{action:tf,safeAction:rf}=T(Ct.void(),async(e,t)=>{let r=ef.parse(t),{cvmId:n}=U.parse(r),{...o}=r;await e.patch(`/cvms/${n}/resources`,o)}),nf=We(Le.extend({public_sysinfo:En.boolean(),public_logs:En.boolean(),public_tcbinfo:En.boolean().optional()})),{action:of,safeAction:sf}=T(mi,async(e,t)=>{let r=nf.parse(t),{cvmId:n}=U.parse(r),{public_sysinfo:o,public_logs:s,public_tcbinfo:i}=r;return await e.patch(`/cvms/${n}/visibility`,{public_sysinfo:o,public_logs:s,public_tcbinfo:i})}),Qs=J.object({name:J.string(),os_image_hash:J.string().nullable(),is_current:J.boolean()}),af=J.object({version:J.union([J.tuple([J.number(),J.number(),J.number(),J.number()]),J.tuple([J.number(),J.number(),J.number()])]),prod:Qs.nullable(),dev:Qs.nullable()}),cf=J.array(af),lf=U,{action:uf,safeAction:pf}=T(cf,async(e,t)=>{let{cvmId:r}=lf.parse(t);return await e.get(`/cvms/${r}/available-os-images`)}),ff=We(Le.extend({os_image_name:_i.string().min(1,"OS image name is required")})),{action:mf,safeAction:df}=T(_i.void(),async(e,t)=>{let r=ff.parse(t),{cvmId:n}=U.parse(r),{os_image_name:o}=r;await e.patch(`/cvms/${n}/os-image`,{os_image_name:o})}),hf=Se.object({id:Se.string().optional(),instance_id:Se.string().optional(),name:Se.string(),status:Se.string(),uptime:Se.string().optional(),exited_at:Se.string().optional(),boot_progress:Se.string().optional(),boot_error:Se.string().optional(),shutdown_progress:Se.string().optional()}),gf=U,{action:xf,safeAction:bf}=T(hf,async(e,t)=>{let{cvmId:r}=gf.parse(t);return await e.get(`/cvms/${r}/state`)});function Ci(e={}){let t=cl(e),r={getCurrentUser:ai,safeGetCurrentUser:hl,getAvailableNodes:Cl,safeGetAvailableNodes:kl,listAllInstanceTypeFamilies:Al,safeListAllInstanceTypeFamilies:Pl,listFamilyInstanceTypes:Ll,safeListFamilyInstanceTypes:$l,listWorkspaces:zl,safeListWorkspaces:jl,getWorkspace:Ul,safeGetWorkspace:Fl,getCvmInfo:gi,safeGetCvmInfo:Rn,getCvmList:xi,safeGetCvmList:Bn,provisionCvm:iu,safeProvisionCvm:au,commitCvmProvision:lu,safeCommitCvmProvision:uu,getCvmComposeFile:gu,safeGetCvmComposeFile:zn,provisionCvmComposeFileUpdate:yu,safeProvisionCvmComposeFileUpdate:vu,commitCvmComposeFileUpdate:Cu,safeCommitCvmComposeFileUpdate:ku,updateCvmEnvs:Au,safeUpdateCvmEnvs:Pu,updateDockerCompose:zu,safeUpdateDockerCompose:ju,updatePreLaunchScript:Nu,safeUpdatePreLaunchScript:Gu,getCvmPreLaunchScript:Mu,safeGetCvmPreLaunchScript:Vu,startCvm:lp,safeStartCvm:up,stopCvm:fp,safeStopCvm:mp,shutdownCvm:hp,safeShutdownCvm:gp,restartCvm:yp,safeRestartCvm:vp,deleteCvm:Cp,safeDeleteCvm:kp,getCvmStats:Ap,safeGetCvmStats:Pp,getCvmNetwork:Bp,safeGetCvmNetwork:zp,getCvmDockerCompose:Fp,safeGetCvmDockerCompose:Op,getCvmContainersStats:qp,safeGetCvmContainersStats:Dp,getCvmAttestation:Yp,safeGetCvmAttestation:Qp,updateCvmResources:tf,safeUpdateCvmResources:rf,updateCvmVisibility:of,safeUpdateCvmVisibility:sf,getAvailableOsImages:uf,safeGetAvailableOsImages:pf,updateOsImage:mf,safeUpdateOsImage:df,getKmsInfo:Wu,safeGetKmsInfo:Xu,getKmsList:Yu,safeGetKmsList:Qu,getAppEnvEncryptPubKey:rp,safeGetAppEnvEncryptPubKey:np,nextAppIds:ip,safeNextAppIds:ap,getCvmState:xf,safeGetCvmState:bf};return t.extend(r)}var ei=x.object({vm_uuid:x.string().nullable(),app_id:x.string(),name:x.string().default(""),status:x.string(),vcpu:x.number().int(),memory:x.number().int(),disk_size:x.number().int(),teepod_id:x.number().int(),teepod_name:x.string(),region_identifier:x.string().nullable().optional(),kms_type:x.string().nullable().optional(),instance_type:x.string().nullable().optional(),listed:x.boolean().nullable().optional(),base_image:x.string().nullable().optional(),kms_slug:x.string().nullable().optional(),kms_id:x.string().nullable().optional(),instance_id:x.string().nullable().optional(),machine_info:An.nullable().optional(),updated_at:x.string().nullable().optional()}),yf=x.object({display_name:x.string().nullable().optional(),avatar_url:x.string().nullable().optional(),description:x.string().nullable().optional(),custom_domain:x.string().nullable().optional()}),vf=x.object({id:x.string(),name:x.string(),app_id:x.string(),app_provision_type:x.string().nullable().optional(),app_icon_url:x.string().nullable().optional(),created_at:x.string(),kms_type:x.string(),profile:yf.nullable().optional(),current_cvm:ei.nullable().optional(),cvms:x.array(ei).default([]),cvm_count:x.number().int().default(0)}),wf=x.object({id:x.null().optional(),app_id:x.string(),name:x.null().optional(),app_provision_type:x.null().optional(),app_icon_url:x.null().optional(),created_at:x.null().optional(),kms_type:x.null().optional(),current_cvm:x.null().optional(),cvms:x.null().optional(),cvm_count:x.null().optional()}),_f=x.union([vf,wf]),Bb=x.object({dstack_apps:x.array(_f),page:x.number().int(),page_size:x.number().int(),total:x.number().int(),total_pages:x.number().int()}),Cf=A.object({id:A.string(),name:A.string(),app_id:A.string(),app_provision_type:A.string().nullable().optional(),app_icon_url:A.string().nullable().optional(),created_at:A.string(),kms_type:A.string(),profile:A.object({display_name:A.string().nullable().optional(),avatar_url:A.string().nullable().optional(),description:A.string().nullable().optional(),custom_domain:A.string().nullable().optional()}).nullable().optional(),current_cvm:Rr.nullable().optional(),cvms:A.array(Rr).default([]),cvm_count:A.number().int().default(0)}),kf=A.object({id:A.null().optional(),app_id:A.string(),name:A.null().optional(),app_provision_type:A.null().optional(),app_icon_url:A.null().optional(),created_at:A.null().optional(),kms_type:A.null().optional(),current_cvm:A.null().optional(),cvms:A.null().optional(),cvm_count:A.null().optional()}),Sf=A.union([Cf,kf]),jb=A.object({dstack_apps:A.array(Sf),page:A.number().int(),page_size:A.number().int(),total:A.number().int(),total_pages:A.number().int()}),ki=I.object({object_type:I.literal("cvm"),id:I.string().nullable().optional(),name:I.string().nullable().optional(),app_id:I.string().nullable().optional(),vm_uuid:I.string().nullable().optional()}),Ef=I.object({revision_id:I.string(),app_id:I.string(),vm_uuid:I.string(),compose_hash:I.string(),created_at:I.string(),trace_id:I.string().nullable().optional(),operation_type:I.string(),triggered_by:Ln.nullable().optional(),cvm:ki.nullable().optional(),workspace:$n.nullable().optional()}),Fb=I.object({revision_id:I.string(),app_id:I.string(),vm_uuid:I.string(),compose_hash:I.string(),compose_file:I.union([I.record(I.any()),I.string()]).nullable().optional(),encrypted_env:I.string(),user_config:I.string(),created_at:I.string(),trace_id:I.string().nullable().optional(),operation_type:I.string(),triggered_by:Ln.nullable().optional(),cvm:ki.nullable().optional(),workspace:$n.nullable().optional()}),Ob=I.object({revisions:I.array(Ef),total:I.number().int(),page:I.number().int(),page_size:I.number().int(),total_pages:I.number().int()});var Tf=N.object({chain:N.unknown().optional(),rpcUrl:N.string().optional(),kmsContractAddress:N.string(),privateKey:N.string().optional(),walletClient:N.unknown().optional(),publicClient:N.unknown().optional(),allowAnyDevice:N.boolean().optional().default(!1),deviceId:N.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),composeHash:N.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),disableUpgrades:N.boolean().optional().default(!1),skipPrerequisiteChecks:N.boolean().optional().default(!1),minBalance:N.string().optional()}).passthrough(),qb=Tf.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,n=!!e.chain;return t&&r?!0:n},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),Db=N.object({appId:N.string(),appAuthAddress:N.string(),deployer:N.string(),transactionHash:N.string(),blockNumber:N.bigint().optional(),gasUsed:N.bigint().optional()}).passthrough();var Vb=F.object({chain:F.unknown().optional(),rpcUrl:F.string().optional(),appId:F.string(),composeHash:F.string(),privateKey:F.string().optional(),walletClient:F.unknown().optional(),publicClient:F.unknown().optional(),skipPrerequisiteChecks:F.boolean().optional().default(!1),minBalance:F.string().optional(),timeout:F.number().optional().default(12e4),retryOptions:F.unknown().optional(),signal:F.unknown().optional(),onTransactionStateChange:F.function().optional(),onTransactionSubmitted:F.function().optional(),onTransactionConfirmed:F.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,n=!!e.chain;return t&&r?!0:n},{message:"Chain is required when publicClient or walletClient is not provided",path:["chain"]}),Kb=F.object({composeHash:F.string(),appId:F.string(),transactionHash:F.string(),blockNumber:F.bigint().optional(),gasUsed:F.bigint().optional()}).passthrough();var If=di;var Af=wt.object({items:wt.array(If),total:wt.number(),page:wt.number(),page_size:wt.number(),pages:wt.number()}).passthrough(),{action:Xb,safeAction:Jb}=T(Af,async(e,t)=>{let{teamSlug:r,page:n,pageSize:o}=t,s=new URLSearchParams;n!==void 0&&s.append("page",n.toString()),o!==void 0&&s.append("page_size",o.toString());let i=s.toString()?`/workspaces/${r}/nodes?${s.toString()}`:`/workspaces/${r}/nodes`;return await e.get(i)}),kt=we.object({limit:we.number(),remaining:we.number()}).passthrough(),Pf=we.object({vm_slots:kt,vcpu:kt,memory_mb:kt,disk_gb:kt}).passthrough(),Lf=we.object({gpus:kt,in_use:we.number(),misconfigured:we.number()}).passthrough(),$f=we.object({team_slug:we.string(),tier:we.string(),quotas:Pf,reserved_nodes:kt,reserved_gpu:Lf,as_of:we.string()}).passthrough(),{action:Yb,safeAction:Qb}=T($f,async(e,t)=>await e.get(`/workspaces/${t.teamSlug}/quotas`)),ty=_t.object({target:_t.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),interval:_t.number().min(5).max(30).default(5).describe("Polling interval in seconds"),timeout:_t.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),maxRetries:_t.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),retryDelay:_t.number().min(0).default(5e3).describe("Delay between retries in milliseconds")});var Rf=ee.object({vm_uuid:ee.string(),status:ee.string(),uptime:ee.string().nullable().optional(),in_progress:ee.boolean(),boot_progress:ee.string().nullable().optional(),boot_error:ee.string().nullable().optional(),operation_type:ee.string().nullable().optional(),operation_started_at:ee.string().nullable().optional(),correlation_id:ee.string().nullable().optional()}),Bf=ee.record(ee.string(),Rf),zf=ee.object({vmUuids:ee.array(ee.string())}),{action:ny,safeAction:oy}=T(Bf,async(e,t)=>{let{vmUuids:r}=zf.parse(t);return await e.post("/status/batch",{vm_uuids:r})}),iy=ue.object({page:ue.number().int().min(1).optional(),page_size:ue.number().int().min(1).max(100).optional(),search:ue.string().optional(),status:ue.array(ue.string()).optional(),listed:ue.boolean().optional(),base_image:ue.string().optional(),instance_type:ue.string().optional(),kms_slug:ue.string().optional(),kms_type:ue.string().optional(),node:ue.string().optional(),region:ue.string().optional()}).strict();var cy=ti.object({appId:ti.string().min(1)}).strict();var uy=ri.object({appId:ri.string().min(1)}).strict();var fy=Pr.object({appId:Pr.string().min(1),page:Pr.number().int().min(1).optional(),page_size:Pr.number().int().min(1).max(1e3).optional()}).strict();var dy=Lr.object({appId:Lr.string().min(1),revisionId:Lr.string().min(1),rawComposeFile:Lr.boolean().optional()}).strict();var gy=Q.object({statuses:Q.array(Q.string()),image_versions:Q.array(Q.string()),instance_types:Q.array(Q.string()),kms_slugs:Q.array(Q.string()),kms_types:Q.array(Q.string()),regions:Q.array(Q.string()),nodes:Q.array(Q.string())});import qf from"path";import jn from"fs-extra";import Df from"@iarna/toml";import{z as $e}from"zod";import te from"chalk";import Hf from"ora";var Of=!1;function _e(){return Of}function Nf(e,t){let r=e.split(/\s+/),n=[],o="";for(let s of r){let i=o.length===0?s:`${o} ${s}`;i.length<=t?o=i:(o.length>0&&n.push(o),o=s)}return o.length>0&&n.push(o),n}function Gf(e,t){if(e.length<=t)return[e];let r=[],n=0;for(;n<e.length;)r.push(e.slice(n,n+t)),n+=t;return r}function Si(e,t){let r=[];for(let n of e.split(`
26
+ `)){if(n.length<=t){r.push(n);continue}if(n.indexOf(" ")===-1){r.push(...Gf(n,t));continue}let o=Nf(n,t);r.push(...o)}if(r.length===0){let n=e.trim();r.push(n)}return r}var Xe={error:(e,...t)=>{_e()||(process.stderr.write(`${te.red("\u2717")} ${te.red(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
27
+ `))},warn:(e,...t)=>{_e()||(process.stderr.write(`${te.yellow("\u26A0")} ${te.yellow(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
28
+ `))},info:(e,...t)=>{_e()||(process.stderr.write(`${te.blue("\u2139")} ${te.blue(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
29
+ `))},success:(e,...t)=>{_e()||(process.stderr.write(`${te.green("\u2713")} ${te.green(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
30
+ `))},debug:(e,...t)=>{_e()||process.env.DEBUG&&(process.stderr.write(`${te.gray("\u{1F50D}")} ${te.gray(e)}`),t.length>0&&process.stderr.write(` ${t.map(String).join(" ")}`),process.stderr.write(`
31
+ `))},table:(e,t)=>{if(!_e()){if(e.length===0){console.log(te.yellow("No data to display"));return}if(t){let r;typeof t[0]=="string"?r=t.map(i=>({key:i,header:i})):r=t;let n={};for(let i of r){let a=i.header||String(i.key);n[String(i.key)]=a.length}for(let i of e)for(let a of r){let l=String(typeof a.key=="string"&&!(a.key in i)?"":i[String(a.key)]??"");n[String(a.key)]=Math.max(n[String(a.key)],l.length)}let o=[];for(let i of r){let a=i.header||String(i.key);o.push(te.bold(a.padEnd(n[String(i.key)])))}console.log(o.join(" "));let s=[];for(let i of r)s.push("-".repeat(n[String(i.key)]));console.log(s.join(" "));for(let i of e){let a=[];for(let l of r){let u=String(typeof l.key=="string"&&!(l.key in i)?"":i[String(l.key)]??"");a.push(u.padEnd(n[String(l.key)]))}console.log(a.join(" "))}}else{let r=e[0],n=Object.keys(r),o={};for(let a of n)o[a]=a.length;for(let a of e)for(let l of n){let u=String(a[l]??"");o[l]=Math.max(o[l],u.length)}let s=[];for(let a of n)s.push(te.bold(a.padEnd(o[a])));console.log(s.join(" "));let i=[];for(let a of n)i.push("-".repeat(o[a]));console.log(i.join(" "));for(let a of e){let l=[];for(let u of n){let p=String(a[u]??"");l.push(p.padEnd(o[u]))}console.log(l.join(" "))}}}},keyValueTable:(e,t)=>{if(_e())return;let{borderStyle:r="single",keyColor:n=te.blue,valueColor:o=te.white,maxWidth:s=process.stdout.columns||80}=t||{},a={single:{topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502",cross:"\u253C",leftT:"\u251C",rightT:"\u2524"},double:{topLeft:"\u2554",topRight:"\u2557",bottomLeft:"\u255A",bottomRight:"\u255D",horizontal:"\u2550",vertical:"\u2551",cross:"\u256C",leftT:"\u2560",rightT:"\u2563"},rounded:{topLeft:"\u256D",topRight:"\u256E",bottomLeft:"\u2570",bottomRight:"\u256F",horizontal:"\u2500",vertical:"\u2502",cross:"\u253C",leftT:"\u251C",rightT:"\u2524"},bold:{topLeft:"\u250F",topRight:"\u2513",bottomLeft:"\u2517",bottomRight:"\u251B",horizontal:"\u2501",vertical:"\u2503",cross:"\u254B",leftT:"\u2523",rightT:"\u252B"},none:{topLeft:"",topRight:"",bottomLeft:"",bottomRight:"",horizontal:"",vertical:"",cross:"",leftT:"",rightT:""}}[r],l=0,u=0;for(let[_,P]of Object.entries(e)){l=Math.max(l,_.length);let R=String(P??"");u=Math.max(u,R.length)}let p=4,f=1,h=s-p-f;if(l+u>h){let _=l/(l+u);l=Math.floor(h*_),u=h-l}let g=l+u+p+f;r!=="none"&&console.log(a.topLeft+a.horizontal.repeat(g-2)+a.topRight);for(let[_,P]of Object.entries(e)){let R=_,G=String(P??""),Z=Si(R,l),K=Si(G,u),Y=Math.max(Z.length,K.length);for(;Z.length<Y;)Z.push("");for(;K.length<Y;)K.push("");for(let re=0;re<Y;re++){let pe=Z[re].padEnd(l),Vt=K[re].padEnd(u);console.log(r!=="none"?`${a.vertical} ${n(pe)} ${a.vertical} ${o(Vt)} ${a.vertical}`:`${n(pe)} : ${o(Vt)}`)}}r!=="none"&&console.log(a.bottomLeft+a.horizontal.repeat(g-2)+a.bottomRight)},break:()=>{_e()||process.stderr.write(`
32
+ `)},startSpinner:e=>{if(_e())return{stop:()=>{}};let t=Hf(e).start();return{stop:(r=!0,n)=>{n&&(t.text=n),r?t.succeed():t.fail()}}},logDetailedError(e,t){if(_e())return;let r=t?`[${t}] `:"",n=s=>s!==null&&typeof s=="object"&&"isRequestError"in s&&s.isRequestError===!0&&"status"in s&&"message"in s&&"data"in s,o=s=>s!==null&&typeof s=="object"&&"issues"in s&&Array.isArray(s.issues);if(n(e)){process.stderr.write(`${r}HTTP ${e.status}: ${e.message}
33
33
  `),e.data!==void 0&&e.data!==null&&process.stderr.write(`${JSON.stringify(e.data,null,2)}
34
34
  `);return}if(o(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 Nf=Le.extend({profile:$e.string().optional(),api_version:$e.enum(Tn).optional(),gateway_domain:$e.string().optional(),gateway_port:$e.number().int().positive().optional(),compose_file:$e.string().optional(),env_file:$e.string().optional(),public_logs:$e.boolean().optional(),public_sysinfo:$e.boolean().optional(),listed:$e.boolean().optional()}),zn="phala.toml";function _i(){return Of.join(process.cwd(),zn)}function Gf(){return Bn.existsSync(_i())}function qf(){let e=_i();if(!Bn.existsSync(e))throw new Error(`Project configuration file not found: ${zn}
38
- Run 'phala init' to create one.`);try{let t=Bn.readFileSync(e,"utf8"),r=Hf.parse(t),n=Nf.parse(r);if(n.id||n.uuid||n.app_id||n.instance_id||n.name){let{cvmId:o}=U.parse(n);return{...n,cvm_id:o}}return n}catch(t){if(t instanceof $e.ZodError){let r=t.issues.map(n=>` - ${n.path.join(".")}: ${n.message}`).join(`
37
+ `)}};var Mf=Le.extend({profile:$e.string().optional(),api_version:$e.enum(In).optional(),gateway_domain:$e.string().optional(),gateway_port:$e.number().int().positive().optional(),compose_file:$e.string().optional(),env_file:$e.string().optional(),public_logs:$e.boolean().optional(),public_sysinfo:$e.boolean().optional(),listed:$e.boolean().optional()}),Un="phala.toml";function Ei(){return qf.join(process.cwd(),Un)}function Vf(){return jn.existsSync(Ei())}function Kf(){let e=Ei();if(!jn.existsSync(e))throw new Error(`Project configuration file not found: ${Un}
38
+ Run 'phala init' to create one.`);try{let t=jn.readFileSync(e,"utf8"),r=Df.parse(t),n=Mf.parse(r);if(n.id||n.uuid||n.app_id||n.instance_id||n.name){let{cvmId:o}=U.parse(n);return{...n,cvm_id:o}}return n}catch(t){if(t instanceof $e.ZodError){let r=t.issues.map(n=>` - ${n.path.join(".")}: ${n.message}`).join(`
39
39
  `);throw new Error(`Invalid project configuration:
40
- ${r}`)}throw new Error(`Failed to parse ${zn}: ${t instanceof Error?t.message:String(t)}`)}}function Ci(){return Gf()?qf():{}}import ki from"fs";import Df from"os";import Ti from"path";var Si="https://cloud-api.phala.network/api/v1";function Mf(){let e=process.env.PHALA_CLOUD_DIR;return typeof e=="string"&&e.trim().length>0?e:Ti.join(Df.homedir(),".phala-cloud")}function Vf(){return Ti.join(Mf(),"credentials.json")}function Br(e){return typeof e=="string"&&e.trim().length>0}function Kf(e){let t=e.trim();return t.length===0?"default":t}function Wf(){try{let e=Vf();if(!ki.existsSync(e))return null;let t=ki.readFileSync(e,"utf8"),r=JSON.parse(t);if(!r||typeof r!="object")return null;let n=r;return n.schema_version!==1||!Br(n.current_profile)||!n.profiles||typeof n.profiles!="object"?null:n}catch(e){return Xe.error("Failed to read credentials file:",e),null}}function Ei(e){let t=Wf(),r=Kf(e.profile||e.projectProfile||t?.current_profile||"default"),n=e.env.PHALA_CLOUD_API_PREFIX,o=t?.profiles?.[r]?.api_prefix,s=(n&&n.trim().length>0?n:o&&o.trim().length>0?o:Si)??Si,i=n?"env":o?"file":"default";if(Br(e.apiToken))return{apiKey:e.apiToken,baseURL:s,profileName:r,tokenSource:"flag",apiPrefixSource:i};if(Br(e.env.PHALA_CLOUD_API_KEY))return{apiKey:e.env.PHALA_CLOUD_API_KEY,baseURL:s,profileName:r,tokenSource:"env",apiPrefixSource:i};let a=t?.profiles?.[r]?.token;return Br(a)?{apiKey:a,baseURL:s,profileName:r,tokenSource:"file",apiPrefixSource:i}:{apiKey:null,baseURL:s,profileName:r,tokenSource:"none",apiPrefixSource:i}}var Xf="2026-01-21";function Jf(){return{env:process.env,projectConfig:Ci()}}function Zf(e,t){let r=e??Jf();return Ei({env:r.env,apiToken:t?.apiToken,profile:t?.profile,projectProfile:r.projectConfig.profile})}async function ce(e,t){let r=Zf(e,t);return yi({apiKey:r.apiKey??void 0,baseURL:r.baseURL,version:Xf})}import{z as c}from"zod";var Yf=c.object({password:c.string(),registry:c.string().nullable(),username:c.string()}),qy=c.object({docker_compose_file:c.string(),docker_config:Yf.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(),Ii=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()}),Dy=c.object({key:c.string(),value:c.string()}),Ai=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()}))}),Pi=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()}),Li=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()}),Qf=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()}),My=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(Qf).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 em from"inquirer";async function Yy(e){let t=await ce(),r=e.replace(/^app_/,""),n=await Ln(t,{app_id:r});if(!n.success)throw new Error(n.error.message);return n.data}async function Qy(e){let t=await ce(),r=await Rn(t,{id:e});if(!r.success)throw new Error(r.error.message);return r.data}async function ev(e){let t=await ce(),r=e.replace(/^app_/,""),n=await t.get(`cvms/app_${r}/network`);return Ai.parse(n)}async function tv(){let e=Xe.startSpinner("Fetching available CVMs"),t=await ce(),r=await $n(t);if(e.stop(!0),!r.success){Xe.error(`Failed to fetch CVMs: ${r.error.message}`);return}let o=r.data.items;if(!o||o.length===0){Xe.info("No CVMs found for your account");return}let s=o.map(a=>{let l=a,u=l.hosted?.app_id||l.hosted?.id,p=l.name||l.hosted?.name,f=l.status||l.hosted?.status;return{name:`${p||"Unnamed"} (${u}) - Status: ${f||"Unknown"}`,value:u}}),{selectedCvm:i}=await em.prompt([{type:"list",name:"selectedCvm",message:"Select a CVM:",choices:s}]);return i}async function rv(e){let t=await ce(),r=e.replace(/^app_/,""),n=await t.get(`cvms/app_${r}/attestation`);try{return Li.parse(n)}catch(o){return Xe.debug(`Validation error: ${o instanceof Error?o.message:String(o)}`),{is_online:!!n?.is_online,is_public:!!n?.is_public,error:typeof n?.error=="string"?n.error:null,app_certificates:Array.isArray(n?.app_certificates)?n.app_certificates:null,tcb_info:n?.tcb_info||null,compose_file:typeof n?.compose_file=="string"?n.compose_file:null}}}async function nv(e,t){let r=await ce(),n=e.replace(/^app_/,""),o=await r.post(`cvms/app_${n}/replicas`,t);return Pi.parse(o)}async function ov(e,t,r,n,o){let s=await ce(),i=e.replace(/^app_/,""),a={};if(t!==void 0&&(a.vcpu=t),r!==void 0&&(a.memory=r),n!==void 0&&(a.disk_size=n),o!==void 0&&(a.allow_restart=o),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 sv(e){return await(await ce()).post("cvms/pubkey/from_cvm_configuration",e)}async function iv(e){let r=await(await ce()).post("cvms/from_cvm_configuration",e);return Ii.parse(r)}async function av(e,t){let r=await ce(),n=e.replace(/^app_/,"");return await r.put(`cvms/app_${n}/compose`,t)}async function cv(e=!1){let t=await ce(),r="teepods/available";return e&&(r+="?v03x_only=1"),await t.get(r)}function St(e,t){let r=[];t.since&&r.push(`since=${encodeURIComponent(t.since)}`),t.until&&r.push(`until=${encodeURIComponent(t.until)}`),t.follow&&r.push("follow"),t.text&&r.push("text"),t.bare&&r.push("bare"),t.tail!==void 0&&(r.push(`tail=${t.tail}`),r.push(`lines=${t.tail}`)),t.timestamps&&r.push("timestamps"),(t.ansi??!0)&&r.push("ansi");let n=e.includes("?")?"&":"?";return e+n+r.join("&")}async function tm(e,t){let r=e.body?.getReader();if(!r)throw new Error("No response body available for streaming");let n=new TextDecoder;for(;;){let{done:o,value:s}=await r.read();if(o)break;t(n.decode(s,{stream:!0}))}}function rm(e){return!e||/\s/.test(e)||e.length%4!==0?!1:/^[A-Za-z0-9+/]+={0,2}$/.test(e)}function nm(e){if(!rm(e))return e;try{return Buffer.from(e,"base64").toString("utf-8")}catch{return e}}function zr(e){let t=e.trim();if(!t)return null;try{let r=JSON.parse(t);return typeof r.message!="string"?null:{channel:r.channel==="stderr"?"stderr":"stdout",message:nm(r.message)}}catch{return null}}function om(e){let t=e.split(/\r?\n/),r=[];for(let n of t){if(!n.trim())continue;let o=zr(n);if(o){r.push(o);continue}r.push({channel:"stdout",message:`${n}
41
- `})}return r}function sm(e){let t=e.split(/\r?\n/),r="";for(let n of t){let o=zr(n);if(o){r+=o.message;continue}n.trim()&&(r+=`${n}
42
- `)}return r}async function im(e,t){let r=e.body?.getReader();if(!r)throw new Error("No response body available for streaming");let n=new TextDecoder,o="",s="unknown",i=a=>{let l=zr(a);if(l){t(l.message);return}a.trim()&&t(`${a}
40
+ ${r}`)}throw new Error(`Failed to parse ${Un}: ${t instanceof Error?t.message:String(t)}`)}}function Ti(){return Vf()?Kf():{}}import Ii from"fs";import Wf from"os";import Pi from"path";var Ai="https://cloud-api.phala.com/api/v1";function Xf(){let e=process.env.PHALA_CLOUD_DIR;return typeof e=="string"&&e.trim().length>0?e:Pi.join(Wf.homedir(),".phala-cloud")}function Jf(){return Pi.join(Xf(),"credentials.json")}function zr(e){return typeof e=="string"&&e.trim().length>0}function Zf(e){let t=e.trim();return t.length===0?"default":t}function Yf(){try{let e=Jf();if(!Ii.existsSync(e))return null;let t=Ii.readFileSync(e,"utf8"),r=JSON.parse(t);if(!r||typeof r!="object")return null;let n=r;return n.schema_version!==1||!zr(n.current_profile)||!n.profiles||typeof n.profiles!="object"?null:n}catch(e){return Xe.error("Failed to read credentials file:",e),null}}function Li(e){let t=Yf(),r=Zf(e.profile||e.projectProfile||t?.current_profile||"default"),n=e.env.PHALA_CLOUD_API_PREFIX,o=t?.profiles?.[r]?.api_prefix,s=(n&&n.trim().length>0?n:o&&o.trim().length>0?o:Ai)??Ai,i=n?"env":o?"file":"default";if(zr(e.apiToken))return{apiKey:e.apiToken,baseURL:s,profileName:r,tokenSource:"flag",apiPrefixSource:i};if(zr(e.env.PHALA_CLOUD_API_KEY))return{apiKey:e.env.PHALA_CLOUD_API_KEY,baseURL:s,profileName:r,tokenSource:"env",apiPrefixSource:i};let a=t?.profiles?.[r]?.token;return zr(a)?{apiKey:a,baseURL:s,profileName:r,tokenSource:"file",apiPrefixSource:i}:{apiKey:null,baseURL:s,profileName:r,tokenSource:"none",apiPrefixSource:i}}var Qf="2026-01-21";function em(){return{env:process.env,projectConfig:Ti()}}function tm(e,t){let r=e??em();return Li({env:r.env,apiToken:t?.apiToken,profile:t?.profile,projectProfile:r.projectConfig.profile})}async function le(e,t){let r=tm(e,t);return Ci({apiKey:r.apiKey??void 0,baseURL:r.baseURL,version:Qf})}import{z as c}from"zod";var rm=c.object({password:c.string(),registry:c.string().nullable(),username:c.string()}),Xy=c.object({docker_compose_file:c.string(),docker_config:rm.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(),$i=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()}),Jy=c.object({key:c.string(),value:c.string()}),Ri=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()}))}),Bi=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()}),zi=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()}),nm=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()}),Zy=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(nm).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 om from"inquirer";async function ov(e){let t=await le(),r=e.replace(/^app_/,""),n=await Rn(t,{app_id:r});if(!n.success)throw new Error(n.error.message);return n.data}async function sv(e){let t=await le(),r=await zn(t,{id:e});if(!r.success)throw new Error(r.error.message);return r.data}async function iv(e){let t=await le(),r=e.replace(/^app_/,""),n=await t.get(`cvms/app_${r}/network`);return Ri.parse(n)}async function av(){let e=Xe.startSpinner("Fetching available CVMs"),t=await le(),r=await Bn(t);if(e.stop(!0),!r.success){Xe.error(`Failed to fetch CVMs: ${r.error.message}`);return}let o=r.data.items;if(!o||o.length===0){Xe.info("No CVMs found for your account");return}let s=o.map(a=>{let l=a,u=l.hosted?.app_id||l.hosted?.id,p=l.name||l.hosted?.name,f=l.status||l.hosted?.status;return{name:`${p||"Unnamed"} (${u}) - Status: ${f||"Unknown"}`,value:u}}),{selectedCvm:i}=await om.prompt([{type:"list",name:"selectedCvm",message:"Select a CVM:",choices:s}]);return i}async function cv(e){let t=await le(),r=e.replace(/^app_/,""),n=await t.get(`cvms/app_${r}/attestation`);try{return zi.parse(n)}catch(o){return Xe.debug(`Validation error: ${o instanceof Error?o.message:String(o)}`),{is_online:!!n?.is_online,is_public:!!n?.is_public,error:typeof n?.error=="string"?n.error:null,app_certificates:Array.isArray(n?.app_certificates)?n.app_certificates:null,tcb_info:n?.tcb_info||null,compose_file:typeof n?.compose_file=="string"?n.compose_file:null}}}async function lv(e,t){let r=await le(),n=e.replace(/^app_/,""),o=await r.post(`cvms/app_${n}/replicas`,t);return Bi.parse(o)}async function uv(e,t,r,n,o){let s=await le(),i=e.replace(/^app_/,""),a={};if(t!==void 0&&(a.vcpu=t),r!==void 0&&(a.memory=r),n!==void 0&&(a.disk_size=n),o!==void 0&&(a.allow_restart=o),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 pv(e){return await(await le()).post("cvms/pubkey/from_cvm_configuration",e)}async function fv(e){let r=await(await le()).post("cvms/from_cvm_configuration",e);return $i.parse(r)}async function mv(e,t){let r=await le(),n=e.replace(/^app_/,"");return await r.put(`cvms/app_${n}/compose`,t)}async function dv(e=!1){let t=await le(),r="teepods/available";return e&&(r+="?v03x_only=1"),await t.get(r)}function Et(e,t){let r=[];t.since&&r.push(`since=${encodeURIComponent(t.since)}`),t.until&&r.push(`until=${encodeURIComponent(t.until)}`),t.follow&&r.push("follow"),t.text&&r.push("text"),t.bare&&r.push("bare"),t.tail!==void 0&&(r.push(`tail=${t.tail}`),r.push(`lines=${t.tail}`)),t.timestamps&&r.push("timestamps"),(t.ansi??!0)&&r.push("ansi");let n=e.includes("?")?"&":"?";return e+n+r.join("&")}async function sm(e,t){let r=e.body?.getReader();if(!r)throw new Error("No response body available for streaming");let n=new TextDecoder;for(;;){let{done:o,value:s}=await r.read();if(o)break;t(n.decode(s,{stream:!0}))}}function im(e){return!e||/\s/.test(e)||e.length%4!==0?!1:/^[A-Za-z0-9+/]+={0,2}$/.test(e)}function am(e){if(!im(e))return e;try{return Buffer.from(e,"base64").toString("utf-8")}catch{return e}}function jr(e){let t=e.trim();if(!t)return null;try{let r=JSON.parse(t);return typeof r.message!="string"?null:{channel:r.channel==="stderr"?"stderr":"stdout",message:am(r.message)}}catch{return null}}function cm(e){let t=e.split(/\r?\n/),r=[];for(let n of t){if(!n.trim())continue;let o=jr(n);if(o){r.push(o);continue}r.push({channel:"stdout",message:`${n}
41
+ `})}return r}function lm(e){let t=e.split(/\r?\n/),r="";for(let n of t){let o=jr(n);if(o){r+=o.message;continue}n.trim()&&(r+=`${n}
42
+ `)}return r}async function um(e,t){let r=e.body?.getReader();if(!r)throw new Error("No response body available for streaming");let n=new TextDecoder,o="",s="unknown",i=a=>{let l=jr(a);if(l){t(l.message);return}a.trim()&&t(`${a}
43
43
  `)};for(;;){let{done:a,value:l}=await r.read();if(a)break;let u=n.decode(l,{stream:!0});if(s==="raw"){t(u);continue}if(o+=u,s==="unknown")if(o.trimStart().startsWith("{"))s="structured";else{s="raw",t(o),o="";continue}let p=o.indexOf(`
44
44
  `);for(;p>=0;){let f=o.slice(0,p);o=o.slice(p+1),i(f),p=o.indexOf(`
45
- `)}}s==="structured"&&o.trim()?i(o):s==="raw"&&o&&t(o)}async function am(e,t){let r=e.body?.getReader();if(!r)throw new Error("No response body available for streaming");let n=new TextDecoder,o="",s="unknown",i=a=>{let l=zr(a);if(l){t(l);return}a.trim()&&t({channel:"stdout",message:`${a}
45
+ `)}}s==="structured"&&o.trim()?i(o):s==="raw"&&o&&t(o)}async function pm(e,t){let r=e.body?.getReader();if(!r)throw new Error("No response body available for streaming");let n=new TextDecoder,o="",s="unknown",i=a=>{let l=jr(a);if(l){t(l);return}a.trim()&&t({channel:"stdout",message:`${a}
46
46
  `})};for(;;){let{done:a,value:l}=await r.read();if(a)break;let u=n.decode(l,{stream:!0});if(s==="raw"){t({channel:"stdout",message:u});continue}if(o+=u,s==="unknown")if(o.trimStart().startsWith("{"))s="structured";else{s="raw",t({channel:"stdout",message:o}),o="";continue}let p=o.indexOf(`
47
47
  `);for(;p>=0;){let f=o.slice(0,p);o=o.slice(p+1),i(f),p=o.indexOf(`
48
- `)}}s==="structured"&&o.trim()?i(o):s==="raw"&&o&&t({channel:"stdout",message:o})}async function $i(e){let r=await(await ce()).get(`cvms/${e}`,{headers:{"X-Phala-Version":"2025-10-28"}});if(!r.syslog_endpoint)throw new Error(`No syslog endpoint available for CVM '${e}'`);return`${r.syslog_endpoint}&ch=serial`}async function jr(e,t,r=!0){let o=await(await ce()).get(`cvms/${e}/composition`);if(!o.containers?.length)throw new Error(`No containers found for CVM '${e}'`);let s=o.containers;if(t&&(s=s.filter(a=>a.names.some(u=>u===t||u===`/${t}`)?!0:r?a.id.startsWith(t):!1),!s.length))throw new Error(`Container '${t}' not found in CVM '${e}'`);let i=s.find(a=>a.log_endpoint);if(!i?.log_endpoint)throw new Error(`No log endpoints available for CVM '${e}'`);return i.log_endpoint}async function lv(e,t={}){let r=await $i(e),n=St(r,t),o=await fetch(n);if(!o.ok)throw new Error(`Failed to fetch serial logs: ${o.status} ${o.statusText}`);return o.text()}async function uv(e,t={}){let r=await jr(e,t.container,t.matchContainerIdPrefix??!0),n=t.text??!0,o=t.bare??!0,s=St(r,{...t,text:n,bare:o}),i=await fetch(s);if(!i.ok)throw new Error(`Failed to fetch container logs: ${i.status} ${i.statusText}`);let a=await i.text();return a.trimStart().startsWith("{")?sm(a):a}async function pv(e,t={}){let r=await jr(e,t.container,t.matchContainerIdPrefix??!0),n=St(r,{...t,text:!1,bare:!1}),o=await fetch(n);if(!o.ok)throw new Error(`Failed to fetch container logs: ${o.status} ${o.statusText}`);let s=await o.text();return s.trimStart().startsWith("{")?om(s):[{channel:"stdout",message:s}]}async function fv(e,t,r={},n){let o=await jr(e,r.container,r.matchContainerIdPrefix??!0),s=St(o,{...r,follow:!0,text:!1,bare:!1}),i=await fetch(s,{signal:n});if(!i.ok)throw new Error(`Failed to stream container logs: ${i.status} ${i.statusText}`);await am(i,t)}async function mv(e,t,r={},n){let o=await $i(e),s=St(o,{...r,follow:!0}),i=await fetch(s,{signal:n});if(!i.ok)throw new Error(`Failed to stream serial logs: ${i.status} ${i.statusText}`);await tm(i,t)}async function dv(e,t,r={},n){let o=await jr(e,r.container,r.matchContainerIdPrefix??!0),s=r.text??!0,i=r.bare??!0,a=St(o,{...r,follow:!0,text:s,bare:i}),l=await fetch(a,{signal:n});if(!l.ok)throw new Error(`Failed to stream container logs: ${l.status} ${l.statusText}`);await im(l,t)}export{qy as composeFileSchema,iv as createCvm,Li as cvmAttestationResponseSchema,Yf as dockerConfigSchema,Dy as encryptedEnvItemSchema,uv as fetchContainerLogs,pv as fetchContainerLogsEntries,lv as fetchSerialLogs,rv as getCvmAttestation,Yy as getCvmByAppId,Qy as getCvmComposeConfig,ev as getCvmNetwork,Ai as getCvmNetworkResponseSchema,sv as getPubkeyFromCvm,cv as getTeepods,Qf as imageSchema,Ii as postCvmResponseSchema,nv as replicateCvm,Pi as replicateCvmResponseSchema,ov as resizeCvm,tv as selectCvm,dv as streamContainerLogs,fv as streamContainerLogsEntries,mv as streamSerialLogs,My as teepodSchema,av as upgradeCvm};
48
+ `)}}s==="structured"&&o.trim()?i(o):s==="raw"&&o&&t({channel:"stdout",message:o})}async function ji(e){let r=await(await le()).get(`cvms/${e}`,{headers:{"X-Phala-Version":"2025-10-28"}});if(!r.syslog_endpoint)throw new Error(`No syslog endpoint available for CVM '${e}'`);return`${r.syslog_endpoint}&ch=serial`}async function Ur(e,t,r=!0){let o=await(await le()).get(`cvms/${e}/composition`);if(!o.containers?.length)throw new Error(`No containers found for CVM '${e}'`);let s=o.containers;if(t&&(s=s.filter(a=>a.names.some(u=>u===t||u===`/${t}`)?!0:r?a.id.startsWith(t):!1),!s.length))throw new Error(`Container '${t}' not found in CVM '${e}'`);let i=s.find(a=>a.log_endpoint);if(!i?.log_endpoint)throw new Error(`No log endpoints available for CVM '${e}'`);return i.log_endpoint}async function hv(e,t={}){let r=await ji(e),n=Et(r,t),o=await fetch(n);if(!o.ok)throw new Error(`Failed to fetch serial logs: ${o.status} ${o.statusText}`);return o.text()}async function gv(e,t={}){let r=await Ur(e,t.container,t.matchContainerIdPrefix??!0),n=t.text??!0,o=t.bare??!0,s=Et(r,{...t,text:n,bare:o}),i=await fetch(s);if(!i.ok)throw new Error(`Failed to fetch container logs: ${i.status} ${i.statusText}`);let a=await i.text();return a.trimStart().startsWith("{")?lm(a):a}async function xv(e,t={}){let r=await Ur(e,t.container,t.matchContainerIdPrefix??!0),n=Et(r,{...t,text:!1,bare:!1}),o=await fetch(n);if(!o.ok)throw new Error(`Failed to fetch container logs: ${o.status} ${o.statusText}`);let s=await o.text();return s.trimStart().startsWith("{")?cm(s):[{channel:"stdout",message:s}]}async function bv(e,t,r={},n){let o=await Ur(e,r.container,r.matchContainerIdPrefix??!0),s=Et(o,{...r,follow:!0,text:!1,bare:!1}),i=await fetch(s,{signal:n});if(!i.ok)throw new Error(`Failed to stream container logs: ${i.status} ${i.statusText}`);await pm(i,t)}async function yv(e,t,r={},n){let o=await ji(e),s=Et(o,{...r,follow:!0}),i=await fetch(s,{signal:n});if(!i.ok)throw new Error(`Failed to stream serial logs: ${i.status} ${i.statusText}`);await sm(i,t)}async function vv(e,t,r={},n){let o=await Ur(e,r.container,r.matchContainerIdPrefix??!0),s=r.text??!0,i=r.bare??!0,a=Et(o,{...r,follow:!0,text:s,bare:i}),l=await fetch(a,{signal:n});if(!l.ok)throw new Error(`Failed to stream container logs: ${l.status} ${l.statusText}`);await um(l,t)}export{Xy as composeFileSchema,fv as createCvm,zi as cvmAttestationResponseSchema,rm as dockerConfigSchema,Jy as encryptedEnvItemSchema,gv as fetchContainerLogs,xv as fetchContainerLogsEntries,hv as fetchSerialLogs,cv as getCvmAttestation,ov as getCvmByAppId,sv as getCvmComposeConfig,iv as getCvmNetwork,Ri as getCvmNetworkResponseSchema,pv as getPubkeyFromCvm,dv as getTeepods,nm as imageSchema,$i as postCvmResponseSchema,lv as replicateCvm,Bi as replicateCvmResponseSchema,uv as resizeCvm,av as selectCvm,vv as streamContainerLogs,bv as streamContainerLogsEntries,yv as streamSerialLogs,Zy as teepodSchema,mv as upgradeCvm};
49
49
  /*! Bundled license information:
50
50
 
51
51
  @noble/hashes/esm/utils.js: