phala 1.1.8 → 1.1.9
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/README.md +91 -784
- package/dist/api/index.d.ts +10 -1
- package/dist/api/index.js +29 -29
- package/dist/index.js +169 -168
- package/package.json +1 -9
package/dist/api/index.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
import { createRequire } from 'module';const require = createRequire(import.meta.url);
|
|
2
|
-
var
|
|
2
|
+
var Pi=Object.create;var Rn=Object.defineProperty;var Li=Object.getOwnPropertyDescriptor;var $i=Object.getOwnPropertyNames;var Bi=Object.getPrototypeOf,zi=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 ue=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ri=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $i(t))!zi.call(e,o)&&o!==r&&Rn(e,o,{get:()=>t[o],enumerable:!(n=Li(t,o))||n.enumerable});return e};var kt=(e,t,r)=>(r=e!=null?Pi(Bi(e)):{},Ri(t||!e||!e.__esModule?Rn(r,"default",{value:e,enumerable:!0}):r,e));var Un=ue((rm,jn)=>{var ot=1e3,st=ot*60,it=st*60,We=it*24,ji=We*7,Ui=We*365.25;jn.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return Fi(e);if(r==="number"&&isFinite(e))return t.long?Oi(e):Hi(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Fi(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*Ui;case"weeks":case"week":case"w":return r*ji;case"days":case"day":case"d":return r*We;case"hours":case"hour":case"hrs":case"hr":case"h":return r*it;case"minutes":case"minute":case"mins":case"min":case"m":return r*st;case"seconds":case"second":case"secs":case"sec":case"s":return r*ot;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function Hi(e){var t=Math.abs(e);return t>=We?Math.round(e/We)+"d":t>=it?Math.round(e/it)+"h":t>=st?Math.round(e/st)+"m":t>=ot?Math.round(e/ot)+"s":e+"ms"}function Oi(e){var t=Math.abs(e);return t>=We?qt(e,t,We,"day"):t>=it?qt(e,t,it,"hour"):t>=st?qt(e,t,st,"minute"):t>=ot?qt(e,t,ot,"second"):e+" ms"}function qt(e,t,r,n){var o=t>=r*1.5;return Math.round(e/r)+" "+n+(o?"s":"")}});var jr=ue((nm,Fn)=>{function Ni(e){r.debug=r,r.default=r,r.coerce=l,r.disable=i,r.enable=o,r.enabled=a,r.humanize=Un(),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(...B){if(!P.enabled)return;let G=P,J=Number(new Date),V=J-(f||J);G.diff=V,G.prev=f,G.curr=J,f=J,B[0]=r.coerce(B[0]),typeof B[0]!="string"&&B.unshift("%O");let Z=0;B[0]=B[0].replace(/%([a-zA-Z%])/g,(le,Dt)=>{if(le==="%%")return"%";Z++;let zn=r.formatters[Dt];if(typeof zn=="function"){let Ai=B[Z];le=zn.call(G,Ai),B.splice(Z,1),Z--}return le}),r.formatArgs.call(G,B),(G.log||r.log).apply(G,B)}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:B=>{h=B}}),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}Fn.exports=Ni});var Hn=ue((ne,Mt)=>{ne.formatArgs=Di;ne.save=qi;ne.load=Mi;ne.useColors=Gi;ne.storage=Vi();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 Gi(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Di(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Mt.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 qi(e){try{e?ne.storage.setItem("debug",e):ne.storage.removeItem("debug")}catch{}}function Mi(){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 Vi(){try{return localStorage}catch{}}Mt.exports=jr()(ne);var{formatters:Ki}=Mt.exports;Ki.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Nn=ue((D,Kt)=>{var Wi=Re("tty"),Vt=Re("util");D.init=ta;D.log=Yi;D.formatArgs=Ji;D.save=Qi;D.load=ea;D.useColors=Xi;D.destroy=Vt.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=Re("supports-color");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 Xi(){return"colors"in D.inspectOpts?!!D.inspectOpts.colors:Wi.isatty(process.stderr.fd)}function Ji(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+"+
|
|
5
|
-
`)}function
|
|
6
|
-
`).map(t=>t.trim()).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
|
|
9
|
-
`),{cause:t,name:"NonceTooLowError"})}};Object.defineProperty(
|
|
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(
|
|
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
|
|
4
|
+
`+s),e.push(o+"m+"+Kt.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=Zi()+t+" "+e[0]}function Zi(){return D.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Yi(...e){return process.stderr.write(Vt.formatWithOptions(D.inspectOpts,...e)+`
|
|
5
|
+
`)}function Qi(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function ea(){return process.env.DEBUG}function ta(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]]}Kt.exports=jr()(D);var{formatters:On}=Kt.exports;On.o=function(e){return this.inspectOpts.colors=this.useColors,Vt.inspect(e,this.inspectOpts).split(`
|
|
6
|
+
`).map(t=>t.trim()).join(" ")};On.O=function(e){return this.inspectOpts.colors=this.useColors,Vt.inspect(e,this.inspectOpts)}});var Gn=ue((om,Ur)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Ur.exports=Hn():Ur.exports=Nn()});var Fr,qn=L(()=>{Fr="2.38.6"});function Mn(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?Mn(e.cause,t):t?null:e}var Hr,v,pe=L(()=>{qn();Hr={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${Fr}`},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=Hr.getDocsUrl?.({...r,docsPath:o}),i=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...n?[`Details: ${n}`]:[],...Hr.version?[`Version: ${Hr.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=Fr}walk(t){return Mn(this,t)}}});var Wt,Xt,Or=L(()=>{pe();Wt=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"})}},Xt=class extends v{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}});function we(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}var at=L(()=>{});function fe(e){return we(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}var St=L(()=>{at()});function Et(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 Vn=L(()=>{});var Tt,It,Nr=L(()=>{pe();Tt=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"})}},It=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 je(e,{dir:t,size:r=32}={}){return typeof e=="string"?ra(e,{dir:t,size:r}):na(e,{dir:t,size:r})}function ra(e,{dir:t,size:r=32}={}){if(r===null)return e;let n=e.replace("0x","");if(n.length>r*2)throw new It({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function na(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new It({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 Gr=L(()=>{Nr()});function he(e,t={}){return typeof e=="number"||typeof e=="bigint"?S(e,t):typeof e=="string"?aa(e,t):typeof e=="boolean"?sa(e,t):oe(e,t)}function sa(e,t={}){let r=`0x${Number(e)}`;return typeof t.size=="number"?(Ue(r,{size:t.size}),je(r,{size:t.size})):r}function oe(e,t={}){let r="";for(let o=0;o<e.length;o++)r+=oa[e[o]];let n=`0x${r}`;return typeof t.size=="number"?(Ue(n,{size:t.size}),je(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 Wt({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?je(a,{size:n}):a}function aa(e,t={}){let r=ia.encode(e);return oe(r,t)}var oa,ia,me=L(()=>{Or();Gr();Je();oa=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));ia=new TextEncoder});function Jt(e,t={}){return typeof e=="number"||typeof e=="bigint"?ua(e,t):typeof e=="boolean"?la(e,t):we(e)?ge(e,t):Dr(e,t)}function la(e,t={}){let r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(Ue(r,{size:t.size}),je(r,{size:t.size})):r}function Kn(e){if(e>=Le.zero&&e<=Le.nine)return e-Le.zero;if(e>=Le.A&&e<=Le.F)return e-(Le.A-10);if(e>=Le.a&&e<=Le.f)return e-(Le.a-10)}function ge(e,t={}){let r=e;t.size&&(Ue(r,{size:t.size}),r=je(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=Kn(n.charCodeAt(a++)),u=Kn(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 ua(e,t){let r=S(e,t);return ge(r)}function Dr(e,t={}){let r=ca.encode(e);return typeof t.size=="number"?(Ue(r,{size:t.size}),je(r,{dir:"right",size:t.size})):r}var ca,Le,Fe=L(()=>{pe();at();Gr();Je();me();ca=new TextEncoder;Le={zero:48,nine:57,A:65,F:70,a:97,f:102}});function Ue(e,{size:t}){if(fe(e)>t)throw new Xt({givenSize:fe(e),maxSize:t})}function Ze(e,t={}){let{signed:r}=t;t.size&&Ue(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 Ye(e,t={}){return Number(Ze(e,t))}var Je=L(()=>{Or();St()});function ct(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 Zt=L(()=>{});var Km,Wm,Xm,Jm,Zm,Ym,Qm,ed,td,rd,nd,od,sd,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,Bd,zd,Rd,jd,Ud,Fd,Hd,Od,Nd,Gd,Dd,qd,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,Bh,Yt,Yn=L(()=>{Km=2n**(8n-1n)-1n,Wm=2n**(16n-1n)-1n,Xm=2n**(24n-1n)-1n,Jm=2n**(32n-1n)-1n,Zm=2n**(40n-1n)-1n,Ym=2n**(48n-1n)-1n,Qm=2n**(56n-1n)-1n,ed=2n**(64n-1n)-1n,td=2n**(72n-1n)-1n,rd=2n**(80n-1n)-1n,nd=2n**(88n-1n)-1n,od=2n**(96n-1n)-1n,sd=2n**(104n-1n)-1n,id=2n**(112n-1n)-1n,ad=2n**(120n-1n)-1n,cd=2n**(128n-1n)-1n,ld=2n**(136n-1n)-1n,ud=2n**(144n-1n)-1n,pd=2n**(152n-1n)-1n,fd=2n**(160n-1n)-1n,md=2n**(168n-1n)-1n,dd=2n**(176n-1n)-1n,hd=2n**(184n-1n)-1n,gd=2n**(192n-1n)-1n,xd=2n**(200n-1n)-1n,bd=2n**(208n-1n)-1n,yd=2n**(216n-1n)-1n,vd=2n**(224n-1n)-1n,wd=2n**(232n-1n)-1n,_d=2n**(240n-1n)-1n,Cd=2n**(248n-1n)-1n,kd=2n**(256n-1n)-1n,Sd=-(2n**(8n-1n)),Ed=-(2n**(16n-1n)),Td=-(2n**(24n-1n)),Id=-(2n**(32n-1n)),Ad=-(2n**(40n-1n)),Pd=-(2n**(48n-1n)),Ld=-(2n**(56n-1n)),$d=-(2n**(64n-1n)),Bd=-(2n**(72n-1n)),zd=-(2n**(80n-1n)),Rd=-(2n**(88n-1n)),jd=-(2n**(96n-1n)),Ud=-(2n**(104n-1n)),Fd=-(2n**(112n-1n)),Hd=-(2n**(120n-1n)),Od=-(2n**(128n-1n)),Nd=-(2n**(136n-1n)),Gd=-(2n**(144n-1n)),Dd=-(2n**(152n-1n)),qd=-(2n**(160n-1n)),Md=-(2n**(168n-1n)),Vd=-(2n**(176n-1n)),Kd=-(2n**(184n-1n)),Wd=-(2n**(192n-1n)),Xd=-(2n**(200n-1n)),Jd=-(2n**(208n-1n)),Zd=-(2n**(216n-1n)),Yd=-(2n**(224n-1n)),Qd=-(2n**(232n-1n)),eh=-(2n**(240n-1n)),th=-(2n**(248n-1n)),rh=-(2n**(256n-1n)),nh=2n**8n-1n,oh=2n**16n-1n,sh=2n**24n-1n,ih=2n**32n-1n,ah=2n**40n-1n,ch=2n**48n-1n,lh=2n**56n-1n,uh=2n**64n-1n,ph=2n**72n-1n,fh=2n**80n-1n,mh=2n**88n-1n,dh=2n**96n-1n,hh=2n**104n-1n,gh=2n**112n-1n,xh=2n**120n-1n,bh=2n**128n-1n,yh=2n**136n-1n,vh=2n**144n-1n,wh=2n**152n-1n,_h=2n**160n-1n,Ch=2n**168n-1n,kh=2n**176n-1n,Sh=2n**184n-1n,Eh=2n**192n-1n,Th=2n**200n-1n,Ih=2n**208n-1n,Ah=2n**216n-1n,Ph=2n**224n-1n,Lh=2n**232n-1n,$h=2n**240n-1n,Bh=2n**248n-1n,Yt=2n**256n-1n});function Qe(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}var Mr=L(()=>{});var Pt,Qt,er,Qn=L(()=>{pe();Pt=class extends v{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}},Qt=class extends v{constructor({length:t,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}},er=class extends v{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}});function tr(e,{recursiveReadLimit:t=8192}={}){let r=Object.create(ha);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}var ha,Vr=L(()=>{Qn();ha={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 er({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new Qt({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new Pt({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 Pt({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 ro,no=L(()=>{ro={ether:-9,wei:9}});function oo(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 so=L(()=>{});function Lt(e,t="wei"){return oo(e,ro[t])}var io=L(()=>{no();so()});function ba(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 rr,nr,or,sr=L(()=>{pe();rr=class extends v{constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}},nr=class extends v{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",ba(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"})}},or=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 ya(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Kr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function et(e,...t){if(!ya(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 pt(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 cr(e,t){et(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function co(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function He(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function lr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function xe(e,t){return e<<32-t|e>>>t}function wa(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]=wa(e[t]);return e}function Ca(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function $t(e){return typeof e=="string"&&(e=Ca(e)),et(e),e}function ur(e){let t=n=>e().update($t(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}var va,Wr,ut,pr=L(()=>{va=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;Wr=va?e=>e:_a;ut=class{}});function Sa(e,t=!1){return t?{h:Number(e&mr),l:Number(e>>po&mr)}:{h:Number(e>>po&mr)|0,l:Number(e&mr)|0}}function fo(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}=Sa(e[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var mr,po,mo,ho,go,xo,bo=L(()=>{mr=BigInt(4294967295),po=BigInt(32);mo=(e,t,r)=>e<<r|t>>>32-r,ho=(e,t,r)=>t<<r|e>>>32-r,go=(e,t,r)=>t<<r-32|e>>>64-r,xo=(e,t,r)=>e<<r-32|t>>>64-r});var de,br=L(()=>{pe();de=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 tt,Eo=L(()=>{pe();tt=class extends v{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}});var yr,rt,Xr,Jr,Zr,Yr,Qr,en,tn,rn,Bt,To=L(()=>{io();pe();yr=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(yr,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(yr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});rt=class extends v{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${Lt(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}};Object.defineProperty(rt,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});Xr=class extends v{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${Lt(r)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}};Object.defineProperty(Xr,"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/});Jr=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(Jr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});Zr=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(Zr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});Yr=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(Yr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});Qr=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(Qr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});en=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(en,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});tn=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(tn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});rn=class extends v{constructor({cause:t}){super("The transaction type is not supported for this chain.",{cause:t,name:"TransactionTypeNotSupportedError"})}};Object.defineProperty(rn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});Bt=class extends v{constructor({cause:t,maxPriorityFeePerGas:r,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${Lt(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${Lt(n)} gwei`:""}).`].join(`
|
|
11
|
+
`),{cause:t,name:"TipAboveFeeCapError"})}};Object.defineProperty(Bt,"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 mt,nn=L(()=>{mt=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 ja(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=Io(u,p,1)^r[a],h=Ao(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=Lo[i],l=Io(o,s,a),u=Ao(o,s,a),p=Po[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]^=za[n],e[1]^=Ra[n]}He(r)}var Aa,zt,Pa,La,$a,Ba,Po,Lo,$o,Bo,za,Ra,Io,Ao,on,Ua,zo,Ro=L(()=>{bo();pr();Aa=BigInt(0),zt=BigInt(1),Pa=BigInt(2),La=BigInt(7),$a=BigInt(256),Ba=BigInt(113),Po=[],Lo=[],$o=[];for(let e=0,t=zt,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],Po.push(2*(5*n+r)),Lo.push((e+1)*(e+2)/2%64);let o=Aa;for(let s=0;s<7;s++)t=(t<<zt^(t>>La)*Ba)%$a,t&Pa&&(o^=zt<<(zt<<BigInt(s))-zt);$o.push(o)}Bo=fo($o,!0),za=Bo[0],Ra=Bo[1],Io=(e,t,r)=>r>32?go(e,t,r):mo(e,t,r),Ao=(e,t,r)=>r>32?xo(e,t,r):ho(e,t,r);on=class e extends ut{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,Kr(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=co(this.state)}clone(){return this._cloneInto()}keccak(){Wr(this.state32),ja(this.state32,this.rounds),Wr(this.state32),this.posOut=0,this.pos=0}update(t){pt(this),t=$t(t),et(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){pt(this,!1),et(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 Kr(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(cr(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,He(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}},Ua=(e,t,r)=>ur(()=>new on(t,e,r)),zo=Ua(1,136,256/8)});function jo(e,t){let r=t||"hex",n=zo(we(e,{strict:!1})?Jt(e):e);return r==="bytes"?n:he(n)}var Uo=L(()=>{Ro();at();Fe();me()});function Fo(e,t){if(sn.has(`${e}.${t}`))return sn.get(`${e}.${t}`);let r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),n=jo(Dr(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 sn.set(`${e}.${t}`,s),s}var sn,Ho=L(()=>{Fe();Uo();nn();sn=new mt(8192)});function _e(e,t){let{strict:r=!0}=t??{},n=`${e}.${r}`;if(an.has(n))return an.get(n);let o=Fa.test(e)?e.toLowerCase()===e?!0:r?Fo(e)===e:!0:!1;return an.set(n,o),o}var Fa,an,vr=L(()=>{nn();Ho();Fa=/^0x[a-fA-F0-9]{40}$/,an=new mt(8192)});function Oo(e,t,r,{strict:n}={}){return we(e,{strict:!1})?Oa(e,t,r,{strict:n}):Ha(e,t,r,{strict:n})}function No(e,t){if(typeof t=="number"&&t>0&&t>fe(e)-1)throw new Tt({offset:t,position:"start",size:fe(e)})}function Go(e,t,r){if(typeof t=="number"&&typeof r=="number"&&fe(e)!==r-t)throw new Tt({offset:r,position:"end",size:fe(e)})}function Ha(e,t,r,{strict:n}={}){No(e,t);let o=e.slice(t,r);return n&&Go(o,t,r),o}function Oa(e,t,r,{strict:n}={}){No(e,t);let o=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return n&&Go(o,t,r),o}var Do=L(()=>{Nr();at();St()});var pn=ue(Ft=>{"use strict";var Za=Ft&&Ft.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ft,"__esModule",{value:!0});Ft.encryptEnvVars=ec;var ln=Re("@noble/curves/ed25519"),un=Za(Re("crypto"));function Ya(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 Qa(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function ec(e,t){let r=JSON.stringify({env:e}),n=ln.x25519.utils.randomPrivateKey(),o=ln.x25519.getPublicKey(n),s=Ya(t),i=ln.x25519.getSharedSecret(n,s),a=await un.default.subtle.importKey("raw",i,{name:"AES-GCM",length:256},!0,["encrypt"]),l=un.default.getRandomValues(new Uint8Array(12)),u=await un.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),Qa(p)}});var Qo=ue(Ht=>{"use strict";var tc=Ht&&Ht.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ht,"__esModule",{value:!0});Ht.getComposeHash=sc;var rc=tc(Re("crypto"));function fn(e){return e==null?e:Array.isArray(e)?e.map(fn):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let n=e[r];return t[r]=fn(n),t},{}):e}function nc(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 oc(e){let t=fn(e);return JSON.stringify(t,(r,n)=>typeof n=="number"&&(isNaN(n)||!isFinite(n))?null:n)}function sc(e,t=!1){t&&(e=nc(e));let r=oc(e);return rc.default.createHash("sha256").update(r,"utf8").digest("hex")}});var ws=ue(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=ds;w.fromBig=dn;w.split=es;var kr=BigInt(2**32-1),mn=BigInt(32);function dn(e,t=!1){return t?{h:Number(e&kr),l:Number(e>>mn&kr)}:{h:Number(e>>mn&kr)|0,l:Number(e&kr)|0}}function es(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}=dn(e[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var ts=(e,t)=>BigInt(e>>>0)<<mn|BigInt(t>>>0);w.toBig=ts;var rs=(e,t,r)=>e>>>r;w.shrSH=rs;var ns=(e,t,r)=>e<<32-r|t>>>r;w.shrSL=ns;var os=(e,t,r)=>e>>>r|t<<32-r;w.rotrSH=os;var ss=(e,t,r)=>e<<32-r|t>>>r;w.rotrSL=ss;var is=(e,t,r)=>e<<64-r|t>>>r-32;w.rotrBH=is;var as=(e,t,r)=>e>>>r-32|t<<64-r;w.rotrBL=as;var cs=(e,t)=>t;w.rotr32H=cs;var ls=(e,t)=>e;w.rotr32L=ls;var us=(e,t,r)=>e<<r|t>>>32-r;w.rotlSH=us;var ps=(e,t,r)=>t<<r|e>>>32-r;w.rotlSL=ps;var fs=(e,t,r)=>t<<r-32|e>>>64-r;w.rotlBH=fs;var ms=(e,t,r)=>e<<r-32|t>>>64-r;w.rotlBL=ms;function ds(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var hs=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);w.add3L=hs;var gs=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;w.add3H=gs;var xs=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);w.add4L=xs;var bs=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0;w.add4H=bs;var ys=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0);w.add5L=ys;var vs=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;w.add5H=vs;var ic={fromBig:dn,split:es,toBig:ts,shrSH:rs,shrSL:ns,rotrSH:os,rotrSL:ss,rotrBH:is,rotrBL:as,rotr32H:cs,rotr32L:ls,rotlSH:us,rotlSL:ps,rotlBH:fs,rotlBL:ms,add:ds,add3L:hs,add3H:gs,add4L:xs,add4H:bs,add5H:vs,add5L:ys};w.default=ic});var _s=ue(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.crypto=void 0;var Ne=Re("crypto");Sr.crypto=Ne&&typeof Ne=="object"&&"webcrypto"in Ne?Ne.webcrypto:Ne&&typeof Ne=="object"&&"randomBytes"in Ne?Ne:void 0});var Ps=ue(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=ks;b.anumber=hn;b.abytes=ht;b.ahash=ac;b.aexists=cc;b.aoutput=lc;b.u8=uc;b.u32=pc;b.clean=fc;b.createView=mc;b.rotr=dc;b.rotl=hc;b.byteSwap=xn;b.byteSwap32=Ss;b.bytesToHex=xc;b.hexToBytes=bc;b.asyncLoop=vc;b.utf8ToBytes=bn;b.bytesToUtf8=wc;b.toBytes=Er;b.kdfInputToBytes=_c;b.concatBytes=Cc;b.checkOpts=kc;b.createHasher=Ts;b.createOptHasher=Is;b.createXOFer=As;b.randomBytes=Sc;var dt=_s();function ks(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function hn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ht(e,...t){if(!ks(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 ac(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");hn(e.outputLen),hn(e.blockLen)}function cc(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 lc(e,t){ht(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function uc(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function pc(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function fc(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function mc(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function dc(e,t){return e<<32-t|e>>>t}function hc(e,t){return e<<t|e>>>32-t>>>0}b.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function xn(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}b.swap8IfBE=b.isLE?e=>e:e=>xn(e);b.byteSwapIfBE=b.swap8IfBE;function Ss(e){for(let t=0;t<e.length;t++)e[t]=xn(e[t]);return e}b.swap32IfBE=b.isLE?e=>e:Ss;var Es=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",gc=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function xc(e){if(ht(e),Es)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=gc[e[r]];return t}var ze={_0:48,_9:57,A:65,F:70,a:97,f:102};function Cs(e){if(e>=ze._0&&e<=ze._9)return e-ze._0;if(e>=ze.A&&e<=ze.F)return e-(ze.A-10);if(e>=ze.a&&e<=ze.f)return e-(ze.a-10)}function bc(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Es)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=Cs(e.charCodeAt(s)),a=Cs(e.charCodeAt(s+1));if(i===void 0||a===void 0){let l=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+s)}n[o]=i*16+a}return n}var yc=async()=>{};b.nextTick=yc;async function vc(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 bn(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function wc(e){return new TextDecoder().decode(e)}function Er(e){return typeof e=="string"&&(e=bn(e)),ht(e),e}function _c(e){return typeof e=="string"&&(e=bn(e)),ht(e),e}function Cc(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];ht(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 kc(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 gn=class{};b.Hash=gn;function Ts(e){let t=n=>e().update(Er(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Is(e){let t=(n,o)=>e(o).update(Er(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}function As(e){let t=(n,o)=>e(o).update(Er(n)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=n=>e(n),t}b.wrapConstructor=Ts;b.wrapConstructorWithOpts=Is;b.wrapXOFConstructorWithOpts=As;function Sc(e=32){if(dt.crypto&&typeof dt.crypto.getRandomValues=="function")return dt.crypto.getRandomValues(new Uint8Array(e));if(dt.crypto&&typeof dt.crypto.randomBytes=="function")return Uint8Array.from(dt.crypto.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}});var Hs=ue(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.shake256=R.shake128=R.keccak_512=R.keccak_384=R.keccak_256=R.keccak_224=R.sha3_512=R.sha3_384=R.sha3_256=R.sha3_224=R.Keccak=void 0;R.keccakP=Us;var Nt=ws(),K=Ps(),Ec=BigInt(0),Ot=BigInt(1),Tc=BigInt(2),Ic=BigInt(7),Ac=BigInt(256),Pc=BigInt(113),Bs=[],zs=[],Rs=[];for(let e=0,t=Ot,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],Bs.push(2*(5*n+r)),zs.push((e+1)*(e+2)/2%64);let o=Ec;for(let s=0;s<7;s++)t=(t<<Ot^(t>>Ic)*Pc)%Ac,t&Tc&&(o^=Ot<<(Ot<<BigInt(s))-Ot);Rs.push(o)}var js=(0,Nt.split)(Rs,!0),Lc=js[0],$c=js[1],Ls=(e,t,r)=>r>32?(0,Nt.rotlBH)(e,t,r):(0,Nt.rotlSH)(e,t,r),$s=(e,t,r)=>r>32?(0,Nt.rotlBL)(e,t,r):(0,Nt.rotlSL)(e,t,r);function Us(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=Ls(u,p,1)^r[a],h=$s(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=zs[i],l=Ls(o,s,a),u=$s(o,s,a),p=Bs[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]^=Lc[n],e[1]^=$c[n]}(0,K.clean)(r)}var Gt=class e extends K.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,K.anumber)(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=(0,K.u32)(this.state)}clone(){return this._cloneInto()}keccak(){(0,K.swap32IfBE)(this.state32),Us(this.state32,this.rounds),(0,K.swap32IfBE)(this.state32),this.posOut=0,this.pos=0}update(t){(0,K.aexists)(this),t=(0,K.toBytes)(t),(0,K.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,K.aexists)(this,!1),(0,K.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,K.anumber)(t),this.xofInto(new Uint8Array(t))}digestInto(t){if((0,K.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,K.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}};R.Keccak=Gt;var Ge=(e,t,r)=>(0,K.createHasher)(()=>new Gt(t,e,r));R.sha3_224=Ge(6,144,224/8);R.sha3_256=Ge(6,136,256/8);R.sha3_384=Ge(6,104,384/8);R.sha3_512=Ge(6,72,512/8);R.keccak_224=Ge(1,144,224/8);R.keccak_256=Ge(1,136,256/8);R.keccak_384=Ge(1,104,384/8);R.keccak_512=Ge(1,72,512/8);var Fs=(e,t,r)=>(0,K.createXOFer)((n={})=>new Gt(t,e,n.dkLen===void 0?r:n.dkLen,!0));R.shake128=Fs(31,168,128/8);R.shake256=Fs(31,136,256/8)});var Os=ue(yn=>{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});yn.verifyEnvEncryptPublicKey=Rc;var Bc=Hs(),zc=Re("@noble/curves/secp256k1");function Rc(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,Bc.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=zc.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 Ws=kt(Gn(),1);import{ofetch as jc}from"ofetch";function Dn(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 q}from"zod";import{z as j}from"zod";import{z as De}from"zod";import{z as k}from"zod";import{z as qe}from"zod";function Xe(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}Zt();Je();Zt();var qr={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function At(e,t){let r={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?Ye(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?Ye(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?qr[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=pa(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 Wn=ct("transaction",At);function pa(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 fa(e,t){let r=(e.transactions??[]).map(n=>typeof n=="string"?n:At(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 Xn=ct("block",fa);function Jn(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}:{}}}Je();Zt();var ma={"0x0":"reverted","0x1":"success"};function da(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=>Jn(n)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Ye(e.transactionIndex):null,status:e.status?ma[e.status]:null,type:e.type?qr[e.type]||e.type:null};return e.blobGasPrice&&(r.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(r.blobGasUsed=BigInt(e.blobGasUsed)),r}var Zn=ct("transactionReceipt",da);pe();Vr();Fe();me();function $e(e,t="hex"){let r=eo(e),n=tr(new Uint8Array(r.length));return r.encode(n),t==="hex"?oe(n.bytes):n.bytes}function eo(e){return Array.isArray(e)?ga(e.map(t=>eo(t))):xa(e)}function ga(e){let t=e.reduce((o,s)=>o+s.length,0),r=to(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 xa(e){let t=typeof e=="string"?ge(e):e,r=to(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 to(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.")}sr();me();function ao(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?he(n):"0x",i,o?he(o):"0x",...lt({},s)])}return t}Fe();me();function ir(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=>ge(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))}Fe();me();function ar(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=>ge(i)):e.blobs,o=typeof e.commitments[0]=="string"?e.commitments.map(i=>ge(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))}me();pr();function ka(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 lo(e,t,r){return e&t^~e&r}function uo(e,t,r){return e&t^e&r^t&r}var fr=class extends ut{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=lr(this.buffer)}update(t){pt(this),t=$t(t),et(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=lr(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){pt(this),cr(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,He(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let f=i;f<o;f++)r[f]=0;ka(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=lr(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()}},Be=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);pr();var Ea=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]),Oe=new Uint32Array(64),dr=class extends fr{constructor(t=32){super(64,t,8,!1),this.A=Be[0]|0,this.B=Be[1]|0,this.C=Be[2]|0,this.D=Be[3]|0,this.E=Be[4]|0,this.F=Be[5]|0,this.G=Be[6]|0,this.H=Be[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)Oe[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let h=Oe[f-15],g=Oe[f-2],_=xe(h,7)^xe(h,18)^h>>>3,P=xe(g,17)^xe(g,19)^g>>>10;Oe[f]=P+Oe[f-7]+_+Oe[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=xe(a,6)^xe(a,11)^xe(a,25),g=p+h+lo(a,l,u)+Ea[f]+Oe[f]|0,P=(xe(n,2)^xe(n,13)^xe(n,22))+uo(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(){He(Oe)}destroy(){this.set(0,0,0,0,0,0,0,0),He(this.buffer)}};var yo=ur(()=>new dr);var vo=yo;at();Fe();me();function wo(e,t){let r=t||"hex",n=vo(we(e,{strict:!1})?Jt(e):e);return r==="bytes"?n:he(n)}function _o(e){let{commitment:t,version:r=1}=e,n=e.to??(typeof t=="string"?"hex":"bytes"),o=wo(t,"bytes");return o.set([r],0),n==="bytes"?o:oe(o)}function Co(e){let{commitments:t,version:r}=e,n=e.to??(typeof t[0]=="string"?"hex":"bytes"),o=[];for(let s of t)o.push(_o({commitment:s,to:n,version:r}));return o}pe();var hr=class extends v{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}},ft=class extends v{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}},gr=class extends v{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}},xr=class extends v{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${1}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}};Vr();St();Fe();me();function ko(e){let t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?ge(e.data):e.data,n=fe(r);if(!n)throw new ft;if(n>761855)throw new hr({maxSize:761855,size:n});let o=[],s=!0,i=0;for(;s;){let a=tr(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 So(e){let{data:t,kzg:r,to:n}=e,o=e.blobs??ko({data:t,to:n}),s=e.commitments??ir({blobs:o,kzg:r,to:n}),i=e.proofs??ar({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}Mr();Vn();me();Yn();br();pe();Eo();To();vr();St();Do();Je();function qo(e){let{authorizationList:t}=e;if(t)for(let r of t){let{chainId:n}=r,o=r.address;if(!_e(o))throw new de({address:o});if(n<0)throw new tt({chainId:n})}wr(e)}function Mo(e){let{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new ft;for(let r of t){let n=fe(r),o=Ye(Oo(r,0,1));if(n!==32)throw new gr({hash:r,size:n});if(o!==1)throw new xr({hash:r,version:o})}}wr(e)}function wr(e){let{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:n,to:o}=e;if(t<=0)throw new tt({chainId:t});if(o&&!_e(o))throw new de({address:o});if(n&&n>Yt)throw new rt({maxFeePerGas:n});if(r&&n&&r>n)throw new Bt({maxFeePerGas:n,maxPriorityFeePerGas:r})}function Vo(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:o,to:s}=e;if(t<=0)throw new tt({chainId:t});if(s&&!_e(s))throw new de({address:s});if(r||o)throw new v("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(n&&n>Yt)throw new rt({maxFeePerGas:n})}function Ko(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:o,to:s}=e;if(s&&!_e(s))throw new de({address:s});if(typeof t<"u"&&t<=0)throw new tt({chainId:t});if(r||o)throw new v("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(n&&n>Yt)throw new rt({maxFeePerGas:n})}sr();function Wo(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 nr({transaction:e})}br();sr();vr();function Rt(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 or({storageKey:o[s]});if(!_e(n,{strict:!1}))throw new de({address:n});t.push([n,o])}return t}function Xo(e,t){let r=Wo(e);return r==="eip1559"?Da(e,t):r==="eip2930"?qa(e,t):r==="eip4844"?Ga(e,t):r==="eip7702"?Na(e,t):Ma(e,t)}function Na(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=Rt(p),g=ao(r);return Qe(["0x04",$e([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,...lt(e,t)])])}function Ga(e,t){let{chainId:r,gas:n,nonce:o,to:s,value:i,maxFeePerBlobGas:a,maxFeePerGas:l,maxPriorityFeePerGas:u,accessList:p,data:f}=e;Mo(e);let h=e.blobVersionedHashes,g=e.sidecars;if(e.blobs&&(typeof h>"u"||typeof g>"u")){let V=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(le=>oe(le)),Z=e.kzg,re=ir({blobs:V,kzg:Z});if(typeof h>"u"&&(h=Co({commitments:re})),typeof g>"u"){let le=ar({blobs:V,commitments:re,kzg:Z});g=So({blobs:V,commitments:re,proofs:le})}}let _=Rt(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??[],...lt(e,t)],B=[],G=[],J=[];if(g)for(let V=0;V<g.length;V++){let{blob:Z,commitment:re,proof:le}=g[V];B.push(Z),G.push(re),J.push(le)}return Qe(["0x03",g?$e([P,B,G,J]):$e(P)])}function Da(e,t){let{chainId:r,gas:n,nonce:o,to:s,value:i,maxFeePerGas:a,maxPriorityFeePerGas:l,accessList:u,data:p}=e;wr(e);let f=Rt(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,...lt(e,t)];return Qe(["0x02",$e(h)])}function qa(e,t){let{chainId:r,gas:n,data:o,nonce:s,to:i,value:a,accessList:l,gasPrice:u}=e;Vo(e);let p=Rt(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,...lt(e,t)];return Qe(["0x01",$e(f)])}function Ma(e,t){let{chainId:r=0,gas:n,data:o,nonce:s,to:i,value:a,gasPrice:l}=e;Ko(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 rr({v:t.v});return g})(),f=Et(t.r),h=Et(t.s);u=[...u,S(p),f==="0x00"?"0x":f,h==="0x00"?"0x":h]}else r>0&&(u=[...u,S(r),"0x","0x"]);return $e(u)}function lt(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=Et(r.r),i=Et(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 Jo={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};Je();var Zo={block:Xn({format(e){return{transactions:e.transactions?.map(r=>{if(typeof r=="string")return r;let n=At(r);return n.typeHex==="0x7e"&&(n.isSystemTx=r.isSystemTx,n.mint=r.mint?Ze(r.mint):void 0,n.sourceHash=r.sourceHash,n.type="deposit"),n}),stateRoot:e.stateRoot}}}),transaction:Wn({format(e){let t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?Ze(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:Zn({format(e){return{l1GasPrice:e.l1GasPrice?Ze(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?Ze(e.l1GasUsed):null,l1Fee:e.l1Fee?Ze(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};br();vr();Mr();me();function Va(e,t){return Wa(e)?Ka(e):Xo(e,t)}var Yo={transaction:Va};function Ka(e){Xa(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?he(i):"0x",l?he(l):"0x",o?he(o):"0x",s?"0x1":"0x",r??"0x"];return Qe(["0x7e",$e(u)])}function Wa(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function Xa(e){let{from:t,to:r}=e;if(t&&!_e(t))throw new de({address:t});if(r&&!_e(r))throw new de({address:r})}var cn={blockTime:2e3,contracts:Jo,formatters:Zo,serializers:Yo};var _r=Xe({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 jt=1,Ut=Xe({...cn,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:{...cn.contracts,disputeGameFactory:{[jt]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[jt]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[jt]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[jt]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:jt}),Ja=Xe({...Ut,experimental_preconfirmationTime:200,rpcUrls:{default:{http:["https://mainnet-preconf.base.org"]}}});var Cr=Xe({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 O}from"zod";import{z as se}from"zod";import{z as m}from"zod";import{z as d}from"zod";import{z as xt}from"zod";import{z as bt}from"zod";import{z as C}from"zod";import{z as W}from"zod";import{z as E}from"zod";import tu from"crypto";import{z as Se}from"zod";import{z as be}from"zod";import{z as M}from"zod";import{z as ie}from"zod";import{z as ae}from"zod";import{z as Bu}from"zod";import{z as Ds}from"zod";import{z as Ee}from"zod";import{z as Ct}from"zod";import{z as nt}from"zod";import{z}from"zod";import{z as ap}from"zod";import{z as pp}from"zod";import{z as $}from"zod";import{z as ke}from"zod";import{z as Ep}from"zod";import{z as H}from"zod";import{z as y}from"zod";import{z as wt}from"zod";import{z as _n}from"zod";import{z as X}from"zod";import{z as mi}from"zod";import{z as Ce}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 Ib=kt(pn(),1);import{z as F}from"zod";var Ef=kt(pn(),1),Tf=kt(Qo(),1),If=kt(Os(),1);import{z as yt}from"zod";import{z as ye}from"zod";import{z as vt}from"zod";import{z as Q}from"zod";import{z as ce}from"zod";import{z as Vs}from"zod";import{z as Ks}from"zod";import{z as Tr}from"zod";import{z as Ir}from"zod";import{z as Y}from"zod";var Uc=q.object({detail:q.union([q.string(),q.array(q.object({msg:q.string(),type:q.string().optional(),ctx:q.record(q.unknown()).optional(),loc:q.array(q.union([q.string(),q.number()])).optional(),input:q.unknown().optional()}).passthrough()),q.record(q.unknown())]).optional(),type:q.string().optional(),code:q.string().optional()}),Te=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)}},vn=class Ar extends Te{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=Uc.safeParse(t.data);return r.success?new Ar(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 Ar(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 Ar(t.message,{request:r??void 0,detail:t.message})}},Fc=class extends Te{constructor(e,t){super(e,t),this.isValidationError=!0,this.validationErrors=t.validationErrors}},Hc=class extends Te{constructor(){super(...arguments),this.isAuthError=!0}},Xs=class extends Te{constructor(){super(...arguments),this.isBusinessError=!0}},Oc=class extends Te{constructor(){super(...arguments),this.isServerError=!0}},Nc=class extends Te{constructor(){super(...arguments),this.isUnknownError=!0}};function Gc(e){if(!e||!Array.isArray(e))return"unknown";let t=e.filter(r=>typeof r=="string"?!["body","query","path","header"].includes(r):!0);return t.length>0?t.join("."):"unknown"}function Js(e){if(!Array.isArray(e))return{errors:[],message:typeof e=="string"?e:"Validation error"};let t=e.map((o,s)=>{let i=Gc(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 Dc(e){return e===422?"validation":e===401||e===403?"auth":e>=400&&e<500?"business":e>=500?"server":"unknown"}function qc(e,t,r){if(e===422&&Array.isArray(t)){let{message:n}=Js(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 Mc(e){let t=e.status??0,r=e.statusText??"Unknown Error",n=e.detail,o=Kc(n);if(o)return new Vc(o.message,{status:t,statusText:r,detail:n,errorCode:o.error_code,structuredDetails:o.details,suggestions:o.suggestions,links:o.links});let s=Dc(t),i=qc(t,n,e.message),a={status:t,statusText:r,detail:n};if(s==="validation"&&Array.isArray(n)){let{errors:l}=Js(n);return new Fc(i,{...a,validationErrors:l})}return s==="auth"?new Hc(i,a):s==="business"?new Xs(i,a):s==="server"?new Oc(i,a):new Nc(i,a)}var Vc=class extends Xs{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 Kc(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 kn=["2025-10-28","2026-01-21"],Wc="2026-01-21",gt=(0,Ws.default)("phala::api-client");function Xc(e){return Object.entries(e).map(([t,r])=>` -H "${t}: ${r}"`).join(`
|
|
12
|
+
`)}function Jc(e){return e?` -d '${(typeof e=="string"?e:JSON.stringify(e,null,2)).replace(/'/g,"\\'")}'`:""}function Ns(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
|
|
16
|
-
`);
|
|
15
|
+
`)}var Zc=class Zs{constructor(t={}){this.emitter=Dn();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&&kn.includes(t.version)?t.version:Wc;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=jc.create({baseURL:i,timeout:a||3e4,headers:h,...u?{credentials:"include"}:{},...f,onRequest({request:g,options:_}){if(gt.enabled){let P=_.method||"GET",B=typeof g=="string"?g:g.url,G=B.startsWith("http")?B:`${i}${B}`,J={};_.headers&&typeof _.headers=="object"&&Object.entries(_.headers).forEach(([Z,re])=>{typeof re=="string"&&(J[Z]=re)});let V=[`> curl -X ${P} "${G}"`,Xc(J),_.body?Jc(_.body):""].filter(Boolean).join(`
|
|
16
|
+
`);gt(`
|
|
17
17
|
=== REQUEST ===
|
|
18
18
|
%s
|
|
19
|
-
`,
|
|
19
|
+
`,V)}},onResponse({request:g,response:_,options:P}){if(gt.enabled){let B=P.method||"GET",G=typeof g=="string"?g:g.url;gt(`
|
|
20
20
|
=== RESPONSE [%s %s] (%dms) ===
|
|
21
21
|
%s
|
|
22
|
-
`,
|
|
22
|
+
`,B,G,_.headers.get("x-response-time")||"?",Ns(_.status,_.statusText,_.headers,_._data))}},onResponseError:({request:g,response:_,options:P})=>{if(gt.enabled){console.warn(`HTTP ${_.status}: ${_.url}`);let B=P.method||"GET",G=typeof g=="string"?g:g.url;gt(`
|
|
23
23
|
=== ERROR RESPONSE [%s %s] ===
|
|
24
24
|
%s
|
|
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(
|
|
27
|
-
`))},warn:(e,...t)=>{
|
|
28
|
-
`))},info:(e,...t)=>{
|
|
29
|
-
`))},success:(e,...t)=>{
|
|
30
|
-
`))},debug:(e,...t)=>{
|
|
31
|
-
`))},table:(e,t)=>{if(!
|
|
32
|
-
`)},startSpinner:e=>{if(
|
|
25
|
+
`,B,G,Ns(_.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?vn.fromFetchError(t):t instanceof Error?vn.fromError(t):new vn("Unknown error occurred",{detail:"Unknown error occurred"})}emitError(t){let r=Mc(t);return this.emitter.emit("error",r),r}async safeRequest(t){try{return{success:!0,data:await t()}}catch(r){if(r instanceof Te)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 Zs({...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 Yc(e={}){return new Zc(e)}var Qc=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(),el=j.object({id:j.string(),name:j.string(),slug:j.string().nullable(),tier:j.string(),role:j.string(),avatar:j.string().nullable().optional()}).passthrough(),tl=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(),rl=j.object({user:Qc,workspace:el,credits:tl}).passthrough(),nl=De.object({username:De.string(),email:De.string(),credits:De.number(),granted_credits:De.number(),avatar:De.string(),team_name:De.string(),team_tier:De.string()}).passthrough();function ol(e){return e==="2025-10-28"?nl:rl}async function Ys(e,t){let r=await e.get("/auth/me");return t?.schema===!1?r:(t?.schema||ol(e.config.version)).parse(r)}async function sl(e,t){try{return{success:!0,data:await Ys(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 il={[Cr.id]:Cr,[Ut.id]:Ut,[_r.id]:_r},al=qe.object({id:qe.string(),slug:qe.string().nullable(),url:qe.string(),version:qe.string(),chain_id:qe.number().nullable(),kms_contract_address:qe.string().nullable().transform(e=>e),gateway_app_id:qe.string().nullable().transform(e=>e)}).passthrough(),Ie=al.transform(e=>{if(e.chain_id!=null){let t=il[e.chain_id];if(t)return{...e,chain:t}}return e});function Qs(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 ei(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 cl(e,t){function r(i,a){return n(i,a)}async function n(i,a){Qs(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=ei(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){Qs(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=ei(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 ll=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(),ul=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(ll),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(),pl=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(),fl=k.object({tier:k.string(),capacity:pl,nodes:k.array(ul),kms_list:k.array(Ie)}).passthrough(),{action:ml,safeAction:dl}=cl(fl,async e=>await e.get("/teepods/available")),ti=O.object({id:O.string(),name:O.string(),description:O.string(),vcpu:O.number(),memory_mb:O.number(),hourly_rate:O.string(),requires_gpu:O.boolean(),default_disk_size_gb:O.number().default(20),family:O.string().nullable()}).passthrough(),hl=O.object({name:O.string(),items:O.array(ti),total:O.number()}).strict(),gl=O.object({result:O.array(hl)}).strict(),xl=O.object({items:O.array(ti),total:O.number(),family:O.string()}).strict(),bl=O.object({family:O.string()}).strict(),{action:yl,safeAction:vl}=T(gl,async e=>await e.get("/instance-types")),{action:wl,safeAction:_l}=T(xl,async(e,t)=>{let r=bl.parse(t);return await e.get(`/instance-types/${r.family}`)}),ri=se.object({id:se.string(),name:se.string(),slug:se.string().nullable(),tier:se.string(),role:se.string(),is_default:se.boolean(),created_at:se.string()}).passthrough(),Cl=se.object({has_more:se.boolean(),next_cursor:se.string().nullable(),total:se.number().nullable()}).passthrough(),kl=se.object({data:se.array(ri),pagination:Cl}).passthrough(),{action:Sl,safeAction:El}=T(kl,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:Tl,safeAction:Il}=T(ri,async(e,t)=>await e.get(`/workspaces/${t}`)),Al=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()}),Pl=m.object({id:m.number(),username:m.string()}),ni=m.object({id:m.number(),name:m.string(),region_identifier:m.string().nullable().optional()}),Sn=m.object({vcpu:m.number(),memory:m.number(),disk_size:m.number(),gpu_count:m.number().default(0)}),En=m.object({app:m.string(),instance:m.string()}),Ll=m.object({hosted:Al,name:m.string(),managed_user:Pl.nullable(),node:ni.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:Ie.nullable(),vcpu:m.number().nullable(),memory:m.number().nullable(),disk_size:m.number().nullable(),gateway_domain:m.string().nullable(),public_urls:m.array(En),machine_info:Sn.nullable().optional(),updated_at:m.string().nullable().optional()}),oi=m.object({id:m.number(),name:m.string(),status:m.string(),in_progress:m.boolean().optional().default(!1),teepod_id:m.number().nullable(),teepod:ni.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:Ie.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(En).optional().default([]),gateway_domain:m.string().optional().nullable(),machine_info:Sn.optional().nullable(),updated_at:m.string().optional().nullable()}),$l=m.object({items:m.array(Ll),total:m.number(),page:m.number(),page_size:m.number(),pages:m.number()}),Bl=d.enum(["skip","hourly","monthly"]),zl=d.enum(["phala","ethereum","base","legacy"]),Tn=d.object({object_type:d.literal("user"),id:d.string().nullable().optional(),username:d.string().nullable().optional(),avatar_url:d.string().nullable().optional()}),In=d.object({object_type:d.literal("workspace"),id:d.string(),name:d.string(),slug:d.string().nullable().optional(),avatar_url:d.string().nullable().optional()}),Rl=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:Bl.nullable().optional()}),jl=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()}),Ul=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()}),Fl=d.object({target:d.string().nullable().optional(),started_at:d.string().nullable().optional(),correlation_id:d.string().nullable().optional()}),Hl=d.object({base_domain:d.string().nullable().optional(),cname:d.string().nullable().optional()}),si=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 Pr=d.object({id:d.string(),name:d.string(),app_id:d.string().nullable().optional(),vm_uuid:d.string().nullable().optional(),resource:Rl,node_info:si.nullable().optional(),os:jl.nullable().optional(),kms_type:zl.nullable().optional(),kms_info:Ul.nullable().optional(),status:d.string(),progress:Fl.nullable().optional(),compose_hash:d.string().nullable().optional(),gateway:Hl,services:d.array(d.record(d.any())).optional().default([]),endpoints:d.array(En).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:In.nullable().optional(),creator:Tn.nullable().optional()}),Ol=Pr.extend({compose_file:d.union([d.record(d.any()),d.string()]).nullable().optional()}),Nl=d.object({items:d.array(Pr),total:d.number(),page:d.number(),page_size:d.number(),pages:d.number()});function ii(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 Ae=xt.object({id:xt.string().optional(),uuid:xt.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:xt.string().optional(),instance_id:xt.string().optional(),name:xt.string().refine(ii,{message:"Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens"}).optional()}),Me=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"}),Gl=Me(Ae),U=Gl.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}}),Dl=U;function ql(e){return e==="2025-10-28"?oi:Ol}async function ai(e,t){let{cvmId:r}=Dl.parse(t),n=await e.get(`/cvms/${r}`);return ql(e.config.version).parse(n)}async function Lr(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 Ml=bt.object({page:bt.number().int().min(1).optional(),page_size:bt.number().int().min(1).optional(),node_id:bt.number().int().min(1).optional(),teepod_id:bt.number().int().min(1).optional(),user_id:bt.string().optional()}).strict();function Vl(e){return e==="2025-10-28"?$l:Nl}async function ci(e,t){let r=Ml.parse(t??{}),n=await e.get("/cvms/paginated",{params:r});return Vl(e.config.version).parse(n)}async function An(e,t){try{return{success:!0,data:await ci(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 Gs=200*1024;function li(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>Gs){let a=Gs/1024,l=Math.ceil(i/1024);r.addIssue({code:W.ZodIssueCode.custom,message:`Combined size of docker_compose_file and pre_launch_script must not exceed ${a}KB (current: ${l}KB)`})}}var ui=W.object({allowed_envs:W.array(W.string()).optional(),docker_compose_file:W.string(),features:W.array(W.string()).optional(),name:W.string().optional(),manifest_version:W.number().optional(),kms_enabled:W.boolean().optional(),public_logs:W.boolean().optional(),public_sysinfo:W.boolean().optional(),tproxy_enabled:W.boolean().optional(),pre_launch_script:W.string().optional(),env_pubkey:W.string().optional(),salt:W.string().optional().nullable()}).passthrough().superRefine((e,t)=>{li(e.docker_compose_file,e.pre_launch_script,t)}),Kl=C.object({app_id:C.string().nullable().optional(),app_env_encrypt_pubkey:C.string().nullable().optional(),compose_hash:C.string(),kms_info:Ie.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}),wn="Name must be 5-63 characters, start with letter, and contain only letters/numbers/hyphens",Wl=C.object({node_id:C.number().optional(),teepod_id:C.number().optional(),region:C.string().optional(),name:C.string().min(5,wn).max(63,wn).refine(e=>ii(e),wn),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)=>{li(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 Xl(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:Jl,safeAction:Zl}=T(Kl,async(e,t)=>{let r=Wl.parse(t),n=Xl(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)}),Yl=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(),Xx=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:Ql,safeAction:eu}=T(Yl,async(e,t)=>await e.post("/cvms",t));function Cn(e){return e==null?e:Array.isArray(e)?e.map(Cn):e&&typeof e=="object"&&e.constructor===Object?Object.keys(e).sort().reduce((t,r)=>{let n=e[r];return t[r]=Cn(n),t},{}):e}function pi(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 fi(e){let t=Cn(e),r=JSON.stringify(t,null,4);return r=r.replace(/": /g,'":'),r}function ru(e){let t=pi(e),r=fi(t);return tu.createHash("sha256").update(r,"utf8").digest("hex")}function nu(e){let t=e;return{...e,getHash:()=>ru(t),toString:()=>fi(pi(t))}}var ou=ui.transform(e=>nu(e)),su=U,{action:iu,safeAction:Pn}=T(ou,async(e,t)=>{let{cvmId:r}=su.parse(t);return await e.get(`/cvms/${r}/compose_file`)}),au=Se.object({id:Se.string().optional(),uuid:Se.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:Se.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:Se.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:ui,update_env_vars:Se.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})),cu=Se.object({app_id:Se.string().nullable(),device_id:Se.string().nullable(),compose_hash:Se.string(),kms_info:Ie.nullable().optional()}).passthrough(),{action:lu,safeAction:uu}=T(cu,async(e,t)=>{let r=au.parse(t);return await e.post(`/cvms/${r.cvmId}/compose_file/provision`,r.request)}),pu=be.object({id:be.string().optional(),uuid:be.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),app_id:be.string().refine(e=>!e.startsWith("app_")&&e.length===40,"app_id should be 40 characters without prefix").transform(e=>e.startsWith("app_")?e:`app_${e}`).optional(),instance_id:be.string().refine(e=>!e.startsWith("instance_")&&e.length===40,"instance_id should be 40 characters without prefix").transform(e=>e.startsWith("instance_")?e:`instance_${e}`).optional(),compose_hash:be.string().min(1,"Compose hash is required"),encrypted_env:be.string().optional(),env_keys:be.array(be.string()).optional(),update_env_vars:be.boolean().optional().nullable()}).refine(e=>!!(e.id||e.uuid||e.app_id||e.instance_id),"One of id, uuid, app_id, or instance_id must be provided").transform(e=>({cvmId:e.id||e.uuid||e.app_id||e.instance_id,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})),fu=be.any().transform(()=>{}),{action:mu,safeAction:du}=T(fu,async(e,t)=>{let r=pu.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})}),hu=Me(Ae.extend({encrypted_env:M.string().describe("Encrypted environment variables (hex string)"),env_keys:M.array(M.string()).optional().describe("List of allowed environment variable keys"),compose_hash:M.string().optional().describe("Compose hash for verification (Phase 2, required when env_keys changes)"),transaction_hash:M.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}}),gu=M.object({status:M.literal("in_progress"),message:M.string(),correlation_id:M.string(),allowed_envs_changed:M.boolean()}),xu=M.object({status:M.literal("precondition_required"),message:M.string(),compose_hash:M.string(),app_id:M.string(),device_id:M.string(),kms_info:Ie}),bu=M.union([gu,xu]),{action:yu,safeAction:vu}=T(bu,async(e,t)=>{let r=hu.parse(t);try{return await e.patch(`/cvms/${r.cvmId}/envs`,r.request)}catch(n){if(n instanceof Te&&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}}),wu=Me(Ae.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}}),_u=ie.object({status:ie.literal("in_progress"),message:ie.string(),correlation_id:ie.string()}),Cu=ie.object({status:ie.literal("precondition_required"),message:ie.string(),compose_hash:ie.string(),app_id:ie.string(),device_id:ie.string(),kms_info:Ie}),ku=ie.union([_u,Cu]),{action:Su,safeAction:Eu}=T(ku,async(e,t)=>{let r=wu.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 Te&&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}}),Tu=Me(Ae.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}}),Iu=ae.object({status:ae.literal("in_progress"),message:ae.string(),correlation_id:ae.string()}),Au=ae.object({status:ae.literal("precondition_required"),message:ae.string(),compose_hash:ae.string(),app_id:ae.string(),device_id:ae.string(),kms_info:Ie}),Pu=ae.union([Iu,Au]),{action:Lu,safeAction:$u}=T(Pu,async(e,t)=>{let r=Tu.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 Te&&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}}),zu=U,{action:Ru,safeAction:ju}=T(Bu.string(),async(e,t)=>{let{cvmId:r}=zu.parse(t);return await e.get(`/cvms/${r}/pre-launch-script`)}),Uu=Ds.object({kms_id:Ds.string().min(1,"KMS ID is required")}),{action:Fu,safeAction:Hu}=T(Ie,async(e,t)=>{let r=Uu.parse(t);return await e.get(`/kms/${r.kms_id}`)}),Ou=Ee.object({page:Ee.number().int().min(1).optional(),page_size:Ee.number().int().min(1).optional(),is_onchain:Ee.boolean().optional()}).strict(),Nu=Ee.object({items:Ee.array(Ie),total:Ee.number(),page:Ee.number(),page_size:Ee.number(),pages:Ee.number()}).strict(),{action:Gu,safeAction:Du}=T(Nu,async(e,t)=>{let r=Ou.parse(t??{});return await e.get("/kms",{params:r})}),qu=Ct.object({kms:Ct.string().min(1,"KMS ID or slug is required"),app_id:Ct.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(),Mu=Ct.object({public_key:Ct.string(),signature:Ct.string()}).strict(),{action:Vu,safeAction:Ku}=T(Mu,async(e,t)=>{let r=qu.parse(t);return await e.get(`/kms/${r.kms}/pubkey/${r.app_id}`)}),Wu=nt.object({counts:nt.number().int().min(1).max(20).optional().default(1)}).strict(),Xu=nt.object({app_ids:nt.array(nt.object({app_id:nt.string(),nonce:nt.number().int().min(0)}))}).strict(),{action:Ju,safeAction:Zu}=T(Xu,async(e,t)=>{let r=Wu.parse(t??{}),n=new URLSearchParams;return n.append("counts",r.counts.toString()),await e.get(`/kms/phala/next_app_id?${n.toString()}`)}),$r=z.object({id:z.number(),name:z.string(),status:z.string(),teepod_id:z.number(),teepod:z.object({id:z.number(),name:z.string(),region_identifier:z.string().nullable().optional()}).optional().nullable(),user_id:z.number().optional().nullable(),app_id:z.string(),vm_uuid:z.string().nullable(),instance_id:z.string().nullable(),app_url:z.string().optional().nullable(),base_image:z.string().nullable(),vcpu:z.number(),memory:z.number(),disk_size:z.number(),manifest_version:z.number().optional().nullable(),version:z.string().optional().nullable(),runner:z.string().optional().nullable(),docker_compose_file:z.string().optional().nullable(),features:z.array(z.string()).optional().nullable(),created_at:z.string(),encrypted_env_pubkey:z.string().nullable()}),Yu=U,{action:Qu,safeAction:ep}=T($r,async(e,t)=>{let{cvmId:r}=Yu.parse(t);return await e.post(`/cvms/${r}/start`)}),tp=U,{action:rp,safeAction:np}=T($r,async(e,t)=>{let{cvmId:r}=tp.parse(t);return await e.post(`/cvms/${r}/stop`)}),op=U,{action:sp,safeAction:ip}=T($r,async(e,t)=>{let{cvmId:r}=op.parse(t);return await e.post(`/cvms/${r}/shutdown`)}),cp=Me(Ae.extend({force:ap.boolean().optional()})),{action:lp,safeAction:up}=T($r,async(e,t)=>{let r=cp.parse(t),{cvmId:n}=U.parse(r),{force:o=!1}=r;return await e.post(`/cvms/${n}/restart`,{force:o})}),fp=U,{action:mp,safeAction:dp}=T(pp.void(),async(e,t)=>{let{cvmId:r}=fp.parse(t);await e.delete(`/cvms/${r}`)}),hp=$.object({name:$.string(),mount_point:$.string(),total_size:$.number(),free_size:$.number()}),gp=$.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(hp)}),xp=$.object({is_online:$.boolean(),is_public:$.boolean().default(!1),error:$.string().nullable(),sysinfo:gp.nullable(),status:$.string().nullable(),in_progress:$.boolean().default(!1),boot_progress:$.string().nullable(),boot_error:$.string().nullable()}),bp=U,{action:yp,safeAction:vp}=T(xp,async(e,t)=>{let{cvmId:r}=bp.parse(t);return await e.get(`/cvms/${r}/stats`)}),wp=ke.object({app:ke.string(),instance:ke.string()}),_p=ke.object({is_online:ke.boolean(),is_public:ke.boolean().default(!0),error:ke.string().nullable(),internal_ip:ke.string().nullable(),latest_handshake:ke.string().nullable(),public_urls:ke.array(wp).nullable()}),Cp=U,{action:kp,safeAction:Sp}=T(_p,async(e,t)=>{let{cvmId:r}=Cp.parse(t);return await e.get(`/cvms/${r}/network`)}),Tp=U,{action:Ip,safeAction:Ap}=T(Ep.string(),async(e,t)=>{let{cvmId:r}=Tp.parse(t);return await e.get(`/cvms/${r}/docker-compose.yml`)}),Pp=H.object({id:H.string(),names:H.array(H.string()),image:H.string(),image_id:H.string(),command:H.string().nullable().optional(),created:H.number(),state:H.string(),status:H.string(),log_endpoint:H.string().nullable()}),Lp=H.object({is_online:H.boolean(),is_public:H.boolean().default(!0),error:H.string().nullable(),docker_compose_file:H.string().nullable(),manifest_version:H.number().nullable(),version:H.string().nullable(),runner:H.string().nullable(),features:H.array(H.string()).nullable(),containers:H.array(Pp).nullable()}),$p=U,{action:Bp,safeAction:zp}=T(Lp,async(e,t)=>{let{cvmId:r}=$p.parse(t);return await e.get(`/cvms/${r}/composition`)}),Rp=y.object({common_name:y.string().nullable(),organization:y.string().nullable(),country:y.string().nullable(),state:y.string().nullable(),locality:y.string().nullable()}),jp=y.object({common_name:y.string().nullable(),organization:y.string().nullable(),country:y.string().nullable()}),Up=y.object({subject:Rp,issuer:jp,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()}),Fp=y.object({imr:y.number(),event_type:y.number(),digest:y.string(),event:y.string(),event_payload:y.string()}),Hp=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(Fp),app_compose:y.string()}),Op=y.object({name:y.string().nullable(),is_online:y.boolean(),is_public:y.boolean().default(!0),error:y.string().nullable(),app_certificates:y.array(Up).nullable(),tcb_info:Hp.nullable(),compose_file:y.string().nullable()}),Np=U,{action:Gp,safeAction:Dp}=T(Op,async(e,t)=>{let{cvmId:r}=Np.parse(t);return await e.get(`/cvms/${r}/attestation`)}),qp=Me(Ae.extend({vcpu:wt.number().optional(),memory:wt.number().optional(),disk_size:wt.number().optional(),instance_type:wt.string().optional(),allow_restart:wt.boolean().optional()})),{action:Mp,safeAction:Vp}=T(wt.void(),async(e,t)=>{let r=qp.parse(t),{cvmId:n}=U.parse(r),{...o}=r;await e.patch(`/cvms/${n}/resources`,o)}),Kp=Me(Ae.extend({public_sysinfo:_n.boolean(),public_logs:_n.boolean(),public_tcbinfo:_n.boolean().optional()})),{action:Wp,safeAction:Xp}=T(oi,async(e,t)=>{let r=Kp.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=X.object({name:X.string(),os_image_hash:X.string().nullable(),is_current:X.boolean()}),Jp=X.object({version:X.union([X.tuple([X.number(),X.number(),X.number(),X.number()]),X.tuple([X.number(),X.number(),X.number()])]),prod:qs.nullable(),dev:qs.nullable()}),Zp=X.array(Jp),Yp=U,{action:Qp,safeAction:ef}=T(Zp,async(e,t)=>{let{cvmId:r}=Yp.parse(t);return await e.get(`/cvms/${r}/available-os-images`)}),tf=Me(Ae.extend({os_image_name:mi.string().min(1,"OS image name is required")})),{action:rf,safeAction:nf}=T(mi.void(),async(e,t)=>{let r=tf.parse(t),{cvmId:n}=U.parse(r),{os_image_name:o}=r;await e.patch(`/cvms/${n}/os-image`,{os_image_name:o})}),of=Ce.object({id:Ce.string().optional(),instance_id:Ce.string().optional(),name:Ce.string(),status:Ce.string(),uptime:Ce.string().optional(),exited_at:Ce.string().optional(),boot_progress:Ce.string().optional(),boot_error:Ce.string().optional(),shutdown_progress:Ce.string().optional()}),sf=U,{action:af,safeAction:cf}=T(of,async(e,t)=>{let{cvmId:r}=sf.parse(t);return await e.get(`/cvms/${r}/state`)});function di(e={}){let t=Yc(e),r={getCurrentUser:Ys,safeGetCurrentUser:sl,getAvailableNodes:ml,safeGetAvailableNodes:dl,listAllInstanceTypeFamilies:yl,safeListAllInstanceTypeFamilies:vl,listFamilyInstanceTypes:wl,safeListFamilyInstanceTypes:_l,listWorkspaces:Sl,safeListWorkspaces:El,getWorkspace:Tl,safeGetWorkspace:Il,getCvmInfo:ai,safeGetCvmInfo:Lr,getCvmList:ci,safeGetCvmList:An,provisionCvm:Jl,safeProvisionCvm:Zl,commitCvmProvision:Ql,safeCommitCvmProvision:eu,getCvmComposeFile:iu,safeGetCvmComposeFile:Pn,provisionCvmComposeFileUpdate:lu,safeProvisionCvmComposeFileUpdate:uu,commitCvmComposeFileUpdate:mu,safeCommitCvmComposeFileUpdate:du,updateCvmEnvs:yu,safeUpdateCvmEnvs:vu,updateDockerCompose:Su,safeUpdateDockerCompose:Eu,updatePreLaunchScript:Lu,safeUpdatePreLaunchScript:$u,getCvmPreLaunchScript:Ru,safeGetCvmPreLaunchScript:ju,startCvm:Qu,safeStartCvm:ep,stopCvm:rp,safeStopCvm:np,shutdownCvm:sp,safeShutdownCvm:ip,restartCvm:lp,safeRestartCvm:up,deleteCvm:mp,safeDeleteCvm:dp,getCvmStats:yp,safeGetCvmStats:vp,getCvmNetwork:kp,safeGetCvmNetwork:Sp,getCvmDockerCompose:Ip,safeGetCvmDockerCompose:Ap,getCvmContainersStats:Bp,safeGetCvmContainersStats:zp,getCvmAttestation:Gp,safeGetCvmAttestation:Dp,updateCvmResources:Mp,safeUpdateCvmResources:Vp,updateCvmVisibility:Wp,safeUpdateCvmVisibility:Xp,getAvailableOsImages:Qp,safeGetAvailableOsImages:ef,updateOsImage:rf,safeUpdateOsImage:nf,getKmsInfo:Fu,safeGetKmsInfo:Hu,getKmsList:Gu,safeGetKmsList:Du,getAppEnvEncryptPubKey:Vu,safeGetAppEnvEncryptPubKey:Ku,nextAppIds:Ju,safeNextAppIds:Zu,getCvmState:af,safeGetCvmState:cf};return t.extend(r)}var Ms=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:Sn.nullable().optional(),updated_at:x.string().nullable().optional()}),lf=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()}),uf=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:lf.nullable().optional(),current_cvm:Ms.nullable().optional(),cvms:x.array(Ms).default([]),cvm_count:x.number().int().default(0)}),pf=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()}),ff=x.union([uf,pf]),wb=x.object({dstack_apps:x.array(ff),page:x.number().int(),page_size:x.number().int(),total:x.number().int(),total_pages:x.number().int()}),mf=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:Pr.nullable().optional(),cvms:A.array(Pr).default([]),cvm_count:A.number().int().default(0)}),df=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()}),hf=A.union([mf,df]),Cb=A.object({dstack_apps:A.array(hf),page:A.number().int(),page_size:A.number().int(),total:A.number().int(),total_pages:A.number().int()}),hi=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()}),gf=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:Tn.nullable().optional(),cvm:hi.nullable().optional(),workspace:In.nullable().optional()}),Sb=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:Tn.nullable().optional(),cvm:hi.nullable().optional(),workspace:In.nullable().optional()}),Eb=I.object({revisions:I.array(gf),total:I.number().int(),page:I.number().int(),page_size:I.number().int(),total_pages:I.number().int()});var xf=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(),Pb=xf.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"]}),Lb=N.object({appId:N.string(),appAuthAddress:N.string(),deployer:N.string(),transactionHash:N.string(),blockNumber:N.bigint().optional(),gasUsed:N.bigint().optional()}).passthrough();var Bb=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"]}),zb=F.object({composeHash:F.string(),appId:F.string(),transactionHash:F.string(),blockNumber:F.bigint().optional(),gasUsed:F.bigint().optional()}).passthrough();var bf=si;var yf=yt.object({items:yt.array(bf),total:yt.number(),page:yt.number(),page_size:yt.number(),pages:yt.number()}).passthrough(),{action:jb,safeAction:Ub}=T(yf,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)}),_t=ye.object({limit:ye.number(),remaining:ye.number()}).passthrough(),vf=ye.object({vm_slots:_t,vcpu:_t,memory_mb:_t,disk_gb:_t}).passthrough(),wf=ye.object({gpus:_t,in_use:ye.number(),misconfigured:ye.number()}).passthrough(),_f=ye.object({team_slug:ye.string(),tier:ye.string(),quotas:vf,reserved_nodes:_t,reserved_gpu:wf,as_of:ye.string()}).passthrough(),{action:Hb,safeAction:Ob}=T(_f,async(e,t)=>await e.get(`/workspaces/${t.teamSlug}/quotas`)),Gb=vt.object({target:vt.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),interval:vt.number().min(5).max(30).default(5).describe("Polling interval in seconds"),timeout:vt.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),maxRetries:vt.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),retryDelay:vt.number().min(0).default(5e3).describe("Delay between retries in milliseconds")});var Cf=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()}),kf=Q.record(Q.string(),Cf),Sf=Q.object({vmUuids:Q.array(Q.string())}),{action:qb,safeAction:Mb}=T(kf,async(e,t)=>{let{vmUuids:r}=Sf.parse(t);return await e.post("/status/batch",{vm_uuids:r})}),Kb=ce.object({page:ce.number().int().min(1).optional(),page_size:ce.number().int().min(1).max(100).optional(),search:ce.string().optional(),status:ce.array(ce.string()).optional(),listed:ce.boolean().optional(),base_image:ce.string().optional(),instance_type:ce.string().optional(),kms_slug:ce.string().optional(),kms_type:ce.string().optional(),node:ce.string().optional(),region:ce.string().optional()}).strict();var Xb=Vs.object({appId:Vs.string().min(1)}).strict();var Zb=Ks.object({appId:Ks.string().min(1)}).strict();var Qb=Tr.object({appId:Tr.string().min(1),page:Tr.number().int().min(1).optional(),page_size:Tr.number().int().min(1).max(1e3).optional()}).strict();var ty=Ir.object({appId:Ir.string().min(1),revisionId:Ir.string().min(1),rawComposeFile:Ir.boolean().optional()}).strict();var ny=Y.object({statuses:Y.array(Y.string()),image_versions:Y.array(Y.string()),instance_types:Y.array(Y.string()),kms_slugs:Y.array(Y.string()),kms_types:Y.array(Y.string()),regions:Y.array(Y.string()),nodes:Y.array(Y.string())});import Bf from"path";import Ln from"fs-extra";import zf from"@iarna/toml";import{z as Pe}from"zod";import ee from"chalk";import Pf from"ora";var Af=!1;function ve(){return Af}function Lf(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 $f(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 gi(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(...$f(n,t));continue}let o=Lf(n,t);r.push(...o)}if(r.length===0){let n=e.trim();r.push(n)}return r}var Ve={error:(e,...t)=>{ve()||(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)=>{ve()||(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)=>{ve()||(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)=>{ve()||(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)=>{ve()||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(!ve()){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(ve())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[_,P]of Object.entries(e)){l=Math.max(l,_.length);let B=String(P??"");u=Math.max(u,B.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 B=_,G=String(P??""),J=gi(B,l),V=gi(G,u),Z=Math.max(J.length,V.length);for(;J.length<Z;)J.push("");for(;V.length<Z;)V.push("");for(let re=0;re<Z;re++){let le=J[re].padEnd(l),Dt=V[re].padEnd(u);console.log(r!=="none"?`${a.vertical} ${n(le)} ${a.vertical} ${o(Dt)} ${a.vertical}`:`${n(le)} : ${o(Dt)}`)}}r!=="none"&&console.log(a.bottomLeft+a.horizontal.repeat(g-2)+a.bottomRight)},break:()=>{ve()||process.stderr.write(`
|
|
32
|
+
`)},startSpinner:e=>{if(ve())return{stop:()=>{}};let t=Pf(e).start();return{stop:(r=!0,n)=>{n&&(t.text=n),r?t.succeed():t.fail()}}},logDetailedError(e,t){if(ve())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
|
|
38
|
-
Run 'phala init' to create one.`);try{let t=
|
|
37
|
+
`)}};var Rf=Ae.extend({profile:Pe.string().optional(),api_version:Pe.enum(kn).optional(),gateway_domain:Pe.string().optional(),gateway_port:Pe.number().int().positive().optional(),compose_file:Pe.string().optional(),env_file:Pe.string().optional(),public_logs:Pe.boolean().optional(),public_sysinfo:Pe.boolean().optional(),listed:Pe.boolean().optional()}),$n="phala.toml";function xi(){return Bf.join(process.cwd(),$n)}function jf(){return Ln.existsSync(xi())}function Uf(){let e=xi();if(!Ln.existsSync(e))throw new Error(`Project configuration file not found: ${$n}
|
|
38
|
+
Run 'phala init' to create one.`);try{let t=Ln.readFileSync(e,"utf8"),r=zf.parse(t),n=Rf.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 Pe.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 ${
|
|
41
|
-
`})}return r}function
|
|
42
|
-
`)}return r}async function
|
|
40
|
+
${r}`)}throw new Error(`Failed to parse ${$n}: ${t instanceof Error?t.message:String(t)}`)}}function bi(){return jf()?Uf():{}}import yi from"fs";import Ff from"os";import wi from"path";var vi="https://cloud-api.phala.com/api/v1";function Hf(){let e=process.env.PHALA_CLOUD_DIR;return typeof e=="string"&&e.trim().length>0?e:wi.join(Ff.homedir(),".phala-cloud")}function Of(){return wi.join(Hf(),"credentials.json")}function Br(e){return typeof e=="string"&&e.trim().length>0}function Nf(e){let t=e.trim();return t.length===0?"default":t}function Gf(){try{let e=Of();if(!yi.existsSync(e))return null;let t=yi.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 Ve.error("Failed to read credentials file:",e),null}}function _i(e){let t=Gf(),r=Nf(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:vi)??vi,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 Df="2026-01-21";function qf(){return{env:process.env,projectConfig:bi()}}function Mf(e,t){let r=e??qf();return _i({env:r.env,apiToken:t?.apiToken,profile:t?.profile,projectProfile:r.projectConfig.profile})}async function te(e,t){let r=Mf(e,t);return di({apiKey:r.apiKey??void 0,baseURL:r.baseURL,version:Df})}import{z as c}from"zod";var Vf=c.object({password:c.string(),registry:c.string().nullable(),username:c.string()}),jy=c.object({docker_compose_file:c.string(),docker_config:Vf.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(),Ci=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()}),Uy=c.object({key:c.string(),value:c.string()}),ki=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()}))}),Si=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()}),Ei=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()}),Kf=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()}),Fy=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(Kf).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 Wf from"inquirer";async function My(e){let t=await te(),r=e.replace(/^app_/,""),n=await Lr(t,{app_id:r});if(!n.success)throw new Error(n.error.message);return n.data}async function Vy(e){let t=await te(),r=await Pn(t,{id:e});if(!r.success)throw new Error(r.error.message);return r.data}async function Ky(e){let t=await te(),r=e.replace(/^app_/,""),n=await t.get(`cvms/app_${r}/network`);return ki.parse(n)}async function Wy(){let e=Ve.startSpinner("Fetching available CVMs"),t=await te(),r=await An(t);if(e.stop(!0),!r.success){Ve.error(`Failed to fetch CVMs: ${r.error.message}`);return}let o=r.data.items;if(!o||o.length===0){Ve.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 Wf.prompt([{type:"list",name:"selectedCvm",message:"Select a CVM:",choices:s}]);return i}async function Xy(e){let t=await te(),r=e.replace(/^app_/,""),n=await t.get(`cvms/app_${r}/attestation`);try{return Ei.parse(n)}catch(o){return Ve.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 Jy(e,t){let r=await te(),n=e.replace(/^app_/,""),o=await r.post(`cvms/app_${n}/replicas`,t);return Si.parse(o)}async function Zy(e,t,r,n,o){let s=await te(),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 Yy(e){return await(await te()).post("cvms/pubkey/from_cvm_configuration",e)}async function Qy(e){let r=await(await te()).post("cvms/from_cvm_configuration",e);return Ci.parse(r)}async function ev(e,t){let r=await te(),n=e.replace(/^app_/,"");return await r.put(`cvms/app_${n}/compose`,t)}async function tv(e=!1){let t=await te(),r="teepods/available";return e&&(r+="?v03x_only=1"),await t.get(r)}function Ke(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 Ti(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 Xf(e){return!e||/\s/.test(e)||e.length%4!==0?!1:/^[A-Za-z0-9+/]+={0,2}$/.test(e)}function Jf(e){if(!Xf(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:Jf(r.message)}}catch{return null}}function Zf(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 Yf(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 Qf(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}
|
|
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
|
|
45
|
+
`)}}s==="structured"&&o.trim()?i(o):s==="raw"&&o&&t(o)}async function em(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}
|
|
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
|
|
48
|
+
`)}}s==="structured"&&o.trim()?i(o):s==="raw"&&o&&t({channel:"stdout",message:o})}async function Bn(e,t){let n=await(await te()).get(`cvms/${e}`,{headers:{"X-Phala-Version":"2025-10-28"}});if(!n.syslog_endpoint)throw new Error(`No syslog endpoint available for CVM '${e}'`);return`${n.syslog_endpoint}&ch=${t}`}async function Ii(e){return Bn(e,"serial")}async function Rr(e,t,r=!0){let o=await(await te()).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 rv(e,t={}){let r=await Ii(e),n=Ke(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 nv(e,t={}){let r=await Rr(e,t.container,t.matchContainerIdPrefix??!0),n=t.text??!0,o=t.bare??!0,s=Ke(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("{")?Yf(a):a}async function ov(e,t={}){let r=await Rr(e,t.container,t.matchContainerIdPrefix??!0),n=Ke(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("{")?Zf(s):[{channel:"stdout",message:s}]}async function sv(e,t,r={},n){let o=await Rr(e,r.container,r.matchContainerIdPrefix??!0),s=Ke(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 em(i,t)}async function iv(e,t,r={},n){let o=await Ii(e),s=Ke(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 Ti(i,t)}async function av(e,t,r={},n){let o=await Rr(e,r.container,r.matchContainerIdPrefix??!0),s=r.text??!0,i=r.bare??!0,a=Ke(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 Qf(l,t)}async function cv(e,t,r={}){let n=await Bn(e,t),o=Ke(n,r),s=await fetch(o);if(!s.ok)throw new Error(`Failed to fetch CVM ${t} logs: ${s.status} ${s.statusText}`);return s.text()}async function lv(e,t,r,n={},o){let s=await Bn(e,t),i=Ke(s,{...n,follow:!0}),a=await fetch(i,{signal:o});if(!a.ok)throw new Error(`Failed to stream CVM ${t} logs: ${a.status} ${a.statusText}`);await Ti(a,r)}async function uv(e){let t=await te(),r=e.replace(/^app_/,""),n=await Lr(t,{app_id:r});if(!n.success)throw new Error(n.error.message);return n.data.status}export{jy as composeFileSchema,Qy as createCvm,Ei as cvmAttestationResponseSchema,Vf as dockerConfigSchema,Uy as encryptedEnvItemSchema,nv as fetchContainerLogs,ov as fetchContainerLogsEntries,cv as fetchCvmChannelLogs,rv as fetchSerialLogs,Xy as getCvmAttestation,My as getCvmByAppId,Vy as getCvmComposeConfig,Bn as getCvmLogEndpoint,Ky as getCvmNetwork,ki as getCvmNetworkResponseSchema,uv as getCvmStatus,Yy as getPubkeyFromCvm,tv as getTeepods,Kf as imageSchema,Ci as postCvmResponseSchema,Jy as replicateCvm,Si as replicateCvmResponseSchema,Zy as resizeCvm,Wy as selectCvm,av as streamContainerLogs,sv as streamContainerLogsEntries,lv as streamCvmChannelLogs,iv as streamSerialLogs,Fy as teepodSchema,ev as upgradeCvm};
|
|
49
49
|
/*! Bundled license information:
|
|
50
50
|
|
|
51
51
|
@noble/hashes/esm/utils.js:
|