run-sdk
Version:
A platform to build apps and tokens on Bitcoin
1 lines • 313 kB
JavaScript
module.exports=function(t){var n={};function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"u",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.u)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)e.d(r,o,function(n){return t[n]}.bind(null,o));return r},e.n=function(t){var n=t&&t.u?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=60)}([function(t,n,e){const{InternalError,TimeoutError}=e(11),{h:r}=e(4),o=new WeakSet,i=new WeakSet,s=new WeakSet,a=["toString","upgrade","sync","destroy","auth","load","init"],c=["sync","interactive"],u=["interactive"],h=[...a,"deps"],f=[...c,"init"],l=[...u,"init"];function d(t){return r((()=>{switch(typeof t){case"string":return`"${t.length>20?t.slice(0,20)+"…":t}"`;case"object":{if(!t)return"null";if(!t.constructor.name)return"[anonymous object]";const Jig=e(7),Berry=e(13);return`[${t instanceof Jig?"jig":t instanceof Berry?"berry":"object"} ${t.constructor.name}]`}case"function":{let n=null;const Code=e(1);if(t instanceof Code)n=Code.prototype.toString.apply(t);else{n="function"==typeof t.toString&&!t.toString.toString().startsWith("class")?t.toString():Function.prototype.toString.apply(t)}if(/^\(/.test(n)||/^function\s*\(/.test(n)||/^[a-zA-Z0-9_$]+\s*=>/.test(n))return"[anonymous function]";return/^class\s*{/.test(n)?"[anonymous class]":t.name}case"undefined":return"undefined";default:return t.toString()}}))}function p(t){return"object"==typeof t&&!!t&&2===v(t)}function b(t){return Array.isArray(t)&&3===v(t)}function y(t){const n=e(5),r=n.g;return(t instanceof n._.Set||t instanceof r.Set)&&3===v(t)}function w(t){const n=e(5),r=n.g;return(t instanceof n._.Map||t instanceof r.Map)&&3===v(t)}function g(t){const n=e(5),r=n.g;return(t instanceof n._.Uint8Array||t instanceof r.Uint8Array)&&4===v(t)}function _(t){if("object"!=typeof t||!t)return!1;const Code=e(1);if(!(t.constructor instanceof Code))return!1;if(t instanceof e(7))return!1;return!(t instanceof e(13))}function m(t){const n=e(5);return!!n.O.has(t)||!!n.P.has(t)}function O(t){if(void 0===t)return!0;if("boolean"==typeof t)return!0;if("number"==typeof t)return!0;if("string"==typeof t)return!0;if(null===t)return!0;if(m(t))return!1;if(p(t))return!0;if(b(t))return!0;if(y(t))return!0;if(w(t))return!0;if(g(t))return!0;if(_(t))return!0;return t instanceof e(3)}const P=/^class\s*{/,E=/^class\s+(extends)?\s+\S+\s*{/,x=/^function\s*\(/;function v(t){if(!t)return 0;let n=0;do{n++,t=Object.getPrototypeOf(t)}while(t);return n}function $(t,n="limit"){if(null===t)return Number.MAX_VALUE;if(-1===t)return Number.MAX_VALUE;if(t===1/0)return Number.MAX_VALUE;if("number"!=typeof t||t<0)throw new Error(`Invalid ${n}: ${d(t)}`);return t}t.exports={v:o,$:i,S:s,A:["encryption","blockhash","blocktime","blockheight","latest","recent","mustBeLatest","mustBeRecent","checkForUpdates","recover","replicate","makeBackup","restricts","delegate","consume","eject","armored","armoured"],k:a,j:c,I:u,R:h,N:f,C:l,F:function(){const t=e(30);if(!t.U)throw new Error("Run instance not active");return t.U},D:function(t,n){if(!t)throw new InternalError(n||"assert failed")},M:function(t){return t.startsWith("main")?"mainnet":"testnet"},L:function(t){if("function"!=typeof t)return;const n=e(5),Code=e(1),r=n.g.Object,o=n._.Object,i=Object.getPrototypeOf(t);return i!==o.getPrototypeOf(o)&&i!==r.getPrototypeOf(r)&&i!==Code.prototype?i:void 0},H:function(t){const n=t.match(/^\s*class\s+[a-zA-Z0-9_$]+\s+extends\s+([a-zA-Z0-9_$]+)\s*{/);return n&&n[1]},G:function(t,B){for(;t;)if((t=Object.getPrototypeOf(t))===B)return!0;return!1},J:d,K:p,V:b,Y:y,W:w,q:g,X:_,Z:function(t){return void 0!==t},tt:function(t){return 0===t&&1/t==-1/0},nt:m,et:function(t){const{rt:n}=e(14);let o=!0;try{r((()=>n(t,(t=>{o=o&&O(t)}))))}catch(t){}return o},ot:O,it:function(t){if("function"!=typeof t)return!1;if(!t.name)return!0;const n=t.toString();return!n.startsWith("class")&&!n.startsWith("function")||(P.test(n)||E.test(n)||x.test(n))},st:v,at:function(t,n){if(!t||"function"!=typeof t&&"object"!=typeof t)return;const e=Object.getOwnPropertyDescriptor(t,n);return e&&e.value},ct:function(t,n){return!(!t||"function"!=typeof t&&"object"!=typeof t)&&("string"==typeof n?Object.getOwnPropertyNames(t).includes(n):"symbol"==typeof n?Object.getOwnPropertySymbols(t).includes(n):void 0)},ut:function(t,n,r){let o=Object.getOwnPropertyDescriptor(t,n);(!o||o.get||o.set)&&(o={configurable:!0,enumerable:!0,writable:!0}),o.value=r;const{ht:i}=e(17);i(t,n,o)},ft:function(t,n,e){Object.defineProperty(t,n,{get:e,configurable:!0,enumerable:!0})},lt:function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t)).filter((n=>Object.getOwnPropertyDescriptor(t,n).get))},dt:function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t)).filter((t=>"constructor"!==t)).filter((n=>"function"==typeof Object.getOwnPropertyDescriptor(t,n).value))},bt:$,yt:class{constructor(t,n,e){this.wt=new Date,this.gt=t,this._t=n,this.Ot=e}Pt(){if(new Date-this.wt>$(this._t,"timeout")){const t=this.Ot?` (${this.Ot})`:"";throw new TimeoutError(`${this.gt} timeout${t})`)}}},Et:function(t,n){let e=0;return t.forEach(((r,o)=>{n(r,o,t)&&(t[e++]=r)})),t.length=e,t}}},function(t,n,e){class CodeDeps{static get xt(){return e(22)}static get vt(){return e(9)}static get $t(){return e(2)}static get St(){return e(0)}static get At(){return e(10)}static get h(){return e(4).h}static get kt(){return e(51)}static get jt(){return"Code"}static get It(){return e(27)}}class Code{constructor(){throw new Error("Cannot instantiate Code")}toString(){const t=CodeDeps.vt,n=CodeDeps.h,{D:e}=CodeDeps.St,r=t.Tt(this);if(!r)return n((()=>this.toString()));const o=r.Rt,i=r.Nt;return e(i),r.Ct?i.startsWith("class")?`class ${o.name} { [native code] }`:`function ${o.name}() { [native code] }`:i}sync(t={}){const n=CodeDeps.vt,e=CodeDeps.$t,r=CodeDeps.kt,o=CodeDeps.jt,{J:i}=CodeDeps.St,s=CodeDeps.It,a=CodeDeps.At.Ft;if(e.Ut&&e.Dt(o,"Sync",i(this)),s.Bt)throw new Error("sync disabled during atomic update");if(a.Mt.length)throw new Error("sync cannot be called internally");const c=n.Tt(this);if(!c)throw new Error("sync unavailable");if(!c.Ct)return r(this,t).then((()=>this))}upgrade(t){return CodeDeps.vt.Lt(this,t),this}auth(){const t=CodeDeps.xt,n=CodeDeps.vt,{J:e}=CodeDeps.St,r=CodeDeps.At,o=CodeDeps.$t,i=CodeDeps.jt;o.Ut&&o.Dt(i,"Auth",e(this));const s=n.Tt(this);if(!s)throw new Error("auth unavailable on non-jigs");if(s.Ct)throw new Error("auth unavailable on native jigs");if(r.Ft.Gt.Ht(this))throw new Error("auth unavailable on new jigs");return t.Jt(this),this}destroy(){const t=CodeDeps.xt,n=CodeDeps.vt,e=CodeDeps.$t,{J:r}=CodeDeps.St,o=CodeDeps.jt;e.Ut&&e.Dt(o,"Destroy",r(this));const i=n.Tt(this);if(!i||i.Ct)throw new Error("destroy unavailable");return t.Kt(this),this}[Symbol.hasInstance](t){const n=CodeDeps.vt,e=CodeDeps.h;if("object"!=typeof t||!t)return!1;const r=n.Vt(this);return!!r&&e((()=>{let n=Object.getPrototypeOf(t);for(;n;){if(n.constructor.origin&&n.constructor.origin===r.origin)return!0;n=Object.getPrototypeOf(n)}return!1}))}static[Symbol.hasInstance](t){return CodeDeps.St.$.has(t)}}Code.deps={CodeDeps},Code.sealed=!0,Code.toString();const r=CodeDeps.vt.Yt();CodeDeps.vt.Tt(r).Wt(Code,!1),t.exports=r},function(t,n){const e={zt:null,qt(...t){this.Qt("info",...t)},Xt(...t){this.Qt("warn",...t)},Zt(...t){this.Qt("error",...t)},Dt(...t){this.Qt("debug",...t)},get tn(){return!!this.zt&&!!this.zt.info&&"function"==typeof this.zt.info},get nn(){return!!this.zt&&!!this.zt.warn&&"function"==typeof this.zt.warn},get en(){return!!this.zt&&!!this.zt.error&&"function"==typeof this.zt.error},get Ut(){return!!this.zt&&!!this.zt.debug&&"function"==typeof this.zt.debug},Qt(t,n,...e){this.zt&&this.zt[t]&&"function"==typeof this.zt[t]&&this.zt[t]((new Date).toISOString(),t.toUpperCase(),`[${n}]`,...e)}};t.exports=e},function(t,n,e){class CreationDeps{static get vt(){return e(9)}static get St(){return e(0)}}class Creation{static[Symbol.hasInstance](t){const{v:n,$:e,S:r}=CreationDeps.St;return!!n.has(t)||(!!e.has(t)||!!r.has(t))}}Creation.deps={CreationDeps},Creation.sealed=!0,Creation.toString();const r=CreationDeps.vt.Yt();CreationDeps.vt.Tt(r).Wt(Creation,!1),t.exports=r},function(t,n){let e=!1;t.exports={h:function(t){const n=e;try{return e=!0,t()}finally{e=n}},rn:function(){return e}}},function(module,exports,__webpack_require__){const DeterministicRealm=__webpack_require__(47),{ft:_defineGetter}=__webpack_require__(0),Source=__webpack_require__(24),Log=__webpack_require__(2),TAG="Sandbox";class Sandbox{constructor(){this.sn=[],Log.Ut&&Log.Dt(TAG,"Creating deterministic realm"),this.an=new DeterministicRealm,this.cn=new WeakSet;const compartment=this.an.makeCompartment();this.g=compartment.evaluate(_getIntrinsicsSrc),this._=eval(_getIntrinsicsSrc),this.P=new Set(Object.entries(this.g).map((([t,n])=>n))),this.O=new Set(Object.entries(this._).map((([t,n])=>n)))}un(t,n,e=!1,r=!1){let o=t.toString();if(process.env.COVER&&(e||this.sn.includes(t.name))){if(!this.cn.has(t)){return[t,"undefined"!=typeof global?global:window]}o=Source.hn(o)}const i=Source.fn(o,t),s=r?Source.ln(i):i;return this.dn(s,n)}dn(t,n={}){const e=this.an.makeCompartment();Object.assign(e.global,this.g,n);const r=t.startsWith("class")?"AnonymousClass":"anonymousFunction",o=`const ${r}=${t};${r}`;"Math"in n||_defineGetter(e.global,"Math",(()=>{throw new ReferenceError("Math is not defined\n\nHint: Math is disabled because it is non-deterministic.")})),"Date"in n||_defineGetter(e.global,"Date",(()=>{throw new ReferenceError("Date is not defined\n\nHint: Date is disabled because it is non-deterministic.")}));const i=e.evaluate(o);return"function"==typeof i&&this.cn.add(i),[i,e.global]}}const _intrinsicNames=["console","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","Object","Function","Boolean","Symbol","Error","EvalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError","Number","BigInt","Math","Date","String","RegExp","Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","Map","Set","WeakMap","WeakSet","ArrayBuffer","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"];let _getIntrinsicsSrc="const x = {}\n";_intrinsicNames.forEach((t=>{_getIntrinsicsSrc+=`x.${t} = typeof ${t} !== 'undefined' ? ${t} : undefined\n`})),_getIntrinsicsSrc+="x",module.exports=new Sandbox},function(t,n){t.exports=require("bsv")},function(t,n,e){class JigDeps{static get xt(){return e(22)}static get pn(){return e(8)}static get bn(){return e(1)}static get yn(){return e(14)}static get vt(){return e(9)}static get wn(){return e(16)}static get $t(){return e(2)}static get gn(){return e(20)}static get St(){return e(0)}static get _n(){return e(7)}static get At(){return e(10)}static get mn(){return e(23)}static get On(){return e(5)}static get h(){return e(4).h}static get kt(){return e(51)}static get It(){return e(27)}static get jt(){return"Jig"}}class Jig{constructor(...t){const n=JigDeps.xt,e=JigDeps.pn,Code=JigDeps.bn,r=JigDeps.vt,o=JigDeps.yn.Pn,i=JigDeps.St.v,s=JigDeps.gn,a=JigDeps._n,c=JigDeps.At,u=JigDeps.mn,h=JigDeps.On.g,f=JigDeps.h,l=c.Ft;if(this.constructor===a)throw new Error("Jig must be extended");if(!(this.constructor instanceof Code))return l.En((()=>{const n=r.xn(this.constructor);return r.Tt(n).vn(),new n(...t)}));r.Tt(this.constructor).vn(),e.$n(this);const d=l.Mt,p=d.length&&d[d.length-1];p&&(this.owner=f((()=>o(p.owner,h))));const b=new s(this,u.Sn(!1));i.add(b);const y=!p||l.An(p,!0);return n.kn(this.constructor,b,t,y),b}init(){}sync(t={}){const n=JigDeps.$t,e=JigDeps.jt,r=JigDeps.kt,o=JigDeps.St.J,i=JigDeps._n,s=JigDeps.At.Ft;if(JigDeps.It.Bt)throw new Error("sync disabled during atomic update");if(n.Ut&&n.Dt(e,"Sync",o(this)),!(this instanceof i))throw new Error("sync unavailable");if(s.Mt.length)throw new Error("sync cannot be called internally");return r(this,t).then((()=>this))}destroy(){const t=JigDeps.$t,n=JigDeps.jt,e=JigDeps.St.J,r=JigDeps._n,o=JigDeps.xt;if(t.Ut&&t.Dt(n,"Destroy",e(this)),!(this instanceof r))throw new Error("destroy unavailable");return o.Kt(this),this}auth(){const t=JigDeps.$t,n=JigDeps.jt,e=JigDeps.St.J,r=JigDeps._n,o=JigDeps.xt,i=JigDeps.At;if(t.Ut&&t.Dt(n,"Auth",e(this)),!(this instanceof r))throw new Error("auth unavailable on native jigs");if(i.Ft.Gt.Ht(this))throw new Error("auth unavailable on new jigs");return o.Jt(this),this}toString(){return`[jig ${this.constructor.name}]`}static load(t){const{F:n,J:e,G:r}=JigDeps.St,o=JigDeps.wn,i=JigDeps._n,s=JigDeps.At.Ft;if(JigDeps.It.Bt)throw new Error("load disabled during atomic update");if(this!==i&&!r(this,i))throw new Error("load unavailable");if(s.Mt.length)throw new Error("load cannot be called internally");return(async()=>{const r=await o(t,void 0,n());if(r instanceof this)return r;throw new Error(`Cannot load ${t}\n\n${e(r)} not an instance of ${e(this)}`)})()}static[Symbol.hasInstance](t){if(!JigDeps.St.v.has(t))return!1;if(this===JigDeps._n)return!0;const n=JigDeps.vt.Vt(this);return!!n&&JigDeps.h((()=>{let e=Object.getPrototypeOf(t);for(;e;){if(e.constructor.origin===n.origin)return!0;e=Object.getPrototypeOf(e)}return!1}))}}Jig.deps={JigDeps},Jig.sealed=!1,Jig.toString();const r=JigDeps.vt.Yt();JigDeps.vt.Tt(r).Wt(Jig,!1),t.exports=r},function(t,n,e){const r=e(6),{J:o,ut:i,Z:s,D:a,F:c}=e(0),{h:u}=e(4),{jn:h}=e(15),f=/^(?<protocol>error):\/\/(?<error>.*)/s,l=/^(?<protocol>native):\/\/(?<native>[a-zA-Z0-9_$]+)/s,d=/^(?<protocol>record):\/\/(?<record>[a-f0-9]{64})_(?:o(?<vout>[0-9]+)|(?:d(?<vdel>[0-9]+)))$/,p=/^(?<txid>[a-f0-9]{64})?_(?:(?:o(?<vout>[0-9]+))|(?:d(?<vdel>[0-9]+)))$/s,b=/^(?<txid>[a-f0-9]{64})_(?:(?:o(?<vout>[0-9]+))|(?:d(?<vdel>[0-9]+)))(?:\?berry=(?<berry>[a-zA-Z0-9\-_.!~*'()%]*)(&hash=(?<hash>[a-f0-9]{64}))?(&version=(?<version>[1-9][0-9]*))?)?$/s,y=["location","origin","nonce"],w=["owner","satoshis"],g=y.concat(w),_="error://Undeployed";t.exports={In:function(t){if("string"!=typeof t)throw new Error(`Location is not a string: ${o(t)}`);const n=t.match(p)||t.match(b)||t.match(d)||t.match(f)||t.match(l);if(n){const e={},r=n.groups;return"record"===r.protocol&&(e.Tn=r.record),"error"===r.protocol&&(e.Zt=r.error),"native"===r.protocol&&(e.Ct=r.native),s(r.txid)&&(e.Rn=r.txid),s(r.vout)&&(e.Nn=parseInt(r.vout)),s(r.vdel)&&(e.Cn=parseInt(r.vdel)),s(r.berry)&&(e.Fn=decodeURIComponent(r.berry)),s(r.hash)&&(e._hash=r.hash),s(r.version)&&(e.jn=h(parseInt(r.version))),t===_&&(e.Un=!0),e}throw new Error(`Bad location: ${o(t)}`)},Dn:function(t){if(a("object"==typeof t&&t),s(t.Zt))return`error://${t.Zt}`;if(s(t.Ct))return`native://${t.Ct}`;let n="";s(t.Tn)&&(n=`record://${t.Tn}`),s(t.Rn)&&(n=t.Rn);let e="";s(t.Nn)&&(e=`_o${t.Nn}`),s(t.Cn)&&(e=`_d${t.Cn}`);const r=[];return s(t.Fn)&&(r.push(`berry=${encodeURIComponent(t.Fn)}`),s(t._hash)&&r.push(`hash=${t._hash}`),s(t.jn)&&r.push(`version=${t.jn}`)),`${n}${e}${r.length?`?${r.join("&")}`:""}`},Bn:function(t){if(Number.isInteger(t)&&t>=1)return t;throw new Error(`Invalid nonce: ${o(t)}`)},Mn:function(t,n=!1,i){const CommonLock=e(41);if("string"==typeof t){try{const n=new r.PublicKey(t,{network:i}),e=i?"testnet"===i:void 0;return new CommonLock(n.toAddress().toString(),e)}catch(t){}try{const n=new CommonLock(t,i?"testnet"===i:"mainnet"!==i&&void 0);return n.script(),n}catch(t){}}const{Lock:s}=e(52);if(t instanceof s)return t;if(null===t&&n)return null;throw new Error(`Invalid owner: ${o(t)}`)},Ln:function(t,n){if("number"!=typeof t)throw new Error("satoshis must be a number");if(!Number.isInteger(t))throw new Error("satoshis must be an integer");if(t<0)throw new Error("satoshis must be non-negative");let e=null;try{e=c()}catch(t){}const r=n?Number.MAX_SAFE_INTEGER:e?e.Hn:1e8;if(t>r)throw new Error(`satoshis must be <= ${r}`);return t},$n:function(t){u((()=>{i(t,"location",_),i(t,"origin",_),i(t,"nonce",0),i(t,"owner",undefined),i(t,"satoshis",undefined)}))},Gn:y,Jn:w,Kn:g,Vn:_,Yn:0}},function(t,n,e){const{J:r,F:o,L:i,it:s,Z:a,$:c,K:u,ct:h,ut:f,D:l,G:d,A:p,k:b,j:y}=e(0),w=e(25),{Wn:g}=e(31),_=e(48),m=e(2),{Pn:O,rt:P}=e(14),E=e(8),{h:x}=e(4),{Kn:v,In:$,Bn:S,Mn:A,Ln:k}=E,j=e(23),I=e(5),T=e(26),{ArgumentError}=e(11),R=e(24),N=I.g,C="Editor",F=new WeakMap,U={},D=new Map,M={};class L{zn(t,n){this.qn=void 0,this.Rt=n,this.Qn=t,this.Xn=void 0,this.Nt=void 0,this.Zn=!1,this.te=!1,this.ne=!1,this.ee="";try{this.ee=o().re.network}catch(t){}this.Ct=void 0,this.oe=!1}ie(t,n=!0,o=[],i){const Code=e(1);if(m.Ut&&m.Dt(C,"Install",r(t)),this.Zn)return l(t===this.qn||t===this.Qn),this.ae();l(!this.Ct);const s=_.ce(this.Rt);U[this.ee]=U[this.ee]||new Map,U[this.ee].delete(this.qn),n&&U[this.ee].set(t,this.Qn);try{this.ue(t,n,o),this.he(),this.fe(this.te?s:null),this.qn=t,this.Xn=t.name,this.Nt=i||R.le(this.Rt.toString(),this.Xn),this.ne=n,this.Zn=!1,this.te=!0,this.Ct=!1,this.oe=!1,h(t,"presets")&&h(t.presets,this.ee)&&h(t.presets[this.ee],"location")&&(x((()=>P(this.Qn,(t=>{if(t instanceof Code&&t!==this.Qn&&$(t.location).Un)throw new ArgumentError(`${r(t)} must have presets`)})))),this.de(this.qn.presets[this.ee]))}catch(n){throw U[this.ee].delete(t),this.local&&U[this.ee].set(this.qn,this.Qn),_.pe(this.Rt,s),n}}be(){if(this.Ct)throw new Error("Cannot uninstall native code");this.te&&(U[this.ee].delete(this.qn),this.te=!1),this.Zn&&(D.delete(this.qn),this.Zn=!1),this.qn&&(v.forEach((t=>{delete this.qn[t]})),delete this.qn.presets),h(this.qn,Symbol.hasInstance)&&delete this.qn[Symbol.hasInstance],this.qn=void 0,this.ne=!1}ye(t){if(this.Zn)return;let n=!0;try{o()}catch(t){n=!1}if(n)this.ie(t);else{if(m.Ut&&m.Dt(C,"Preinstall",r(t)),this.te||this.Ct)throw new Error(`Cannot preinstall ${r(t)}`);D.set(t,this.Qn);try{this.ue(t,!0),this.qn=t,this.Xn=t.name,this.Nt=R.le(this.Rt.toString(),this.Xn),this.ne=!0,this.Zn=!0,this.te=!1,this.Ct=!1,this.oe=!1}catch(n){throw D.delete(t),n}}}ae(){if(this.Zn){m.Ut&&m.Dt(C,"Postinstall",r(this.qn)),this.ee=o().re.network;try{D.delete(this.qn),U[this.ee]=U[this.ee]||new Map,U[this.ee].set(this.qn,this.Qn),this.he(),this.fe(),this.Zn=!1,this.te=!0;const Code=e(1),t=t=>{t instanceof Code&&L.Tt(t).ae()};x((()=>P(this.Qn,t)))}catch(t){throw D.set(this.qn,this.Qn),U[this.ee].delete(this.qn),this.ee="",t}}}ue(t,n=!1,o=[]){const i=n?q(this.Qn,t,n,o)[0]:t,Jig=e(7),Berry=e(13);let s=null;if(d(t,Jig))s=j.we();else{const n=t.toString().startsWith("class");s=j.ge(n)}if(T.me(this.Qn)._e=s,this.te){if(d(this.qn,Jig)!==d(t,Jig))throw new Error("Cannot change jigs to sidekicks, or vice versa")}if(this.te&&d(this.qn,Berry))throw new Error(`Cannot upgrade from berry class: ${r(this.qn)}`);if(this.te&&d(t,Berry))throw new Error(`Cannot upgrade to berry class: ${r(t)}`);Z(i,this.Qn),tt(t),_.pe(this.Rt,i)}he(){x((()=>{if(h(this.Qn,"presets")){const t=this.Qn.presets[this.ee];Object.getOwnPropertyNames(t||{}).forEach((n=>f(this.Qn,n,t[n]))),delete this.Qn.presets}}))}fe(t){x((()=>{t?v.forEach((n=>f(this.Qn,n,t[n]))):h(this.Qn,"location")||E.$n(this.Qn)}))}Wt(t,n=!1){m.Ut&&m.Dt(C,"Install native",r(t)),l(void 0===this.Ct),l(!i(t)),l(!(t.name in M));const[e,o]=I.un(t,{},!0,!1);Object.assign(o,t.deps);const s=t.sealed,c=t.upgradable,u=t.interactive;process.env.COVER&&Object.keys(e).forEach((t=>{delete e[t]})),a(s)&&f(e,"sealed",s),a(c)&&f(e,"upgradable",c),a(u)&&f(e,"interactive",u),Z(e,this.Qn),_.pe(this.Rt,e),e.origin=`native://${t.name}`,e.location=`native://${t.name}`,e.nonce=0,e.owner=null,e.satoshis=0,M[t.name]=this.Qn,T.me(this.Qn)._e=j.Oe(),this.qn=t,this.Xn=t.name,this.Nt=R.le(this.Rt.toString(),this.Xn),this.Zn=!1,this.te=!0,this.ne=!0,this.Ct=!0,this.oe=n}vn(){m.tn&&m.qt(C,"Deploy",r(this.Qn)),this.Ct||(this.ae(),nt(this.Qn))}de(t){if(!this.ne)return;const n=this.qn;h(n,"presets")||f(n,"presets",{}),h(n.presets,this.ee)||f(n.presets,this.ee,{}),x((()=>{v.forEach((e=>{const r=n.presets[this.ee];h(r,e)||f(r,e,t[e]),h(n,e)||f(n,e,t[e])}))}))}Pe(){return{Qn:this.Qn,qn:this.qn,Xn:this.Xn,Nt:this.Nt,Ee:_.ce(this.Rt)}}xe(t){l(this.Qn===t.Qn),this.qn=t.qn,this.Xn=t.Xn,this.Nt=t.Nt,_.pe(this.Rt,t.Ee)}}function H(t,n=!0,r=[]){l(!rt(t));const o=new _,i=new L,s=new(e(20))(o);return _.ve(o,s),i.zn(s,o),F.set(s,i),c.add(s),t&&i.ie(t,n,r),r.push(s),s}function G(t,n=!0,e=[]){return rt(t)||H(t,n,e)}function J(t){const Jig=e(7),Berry=e(13);if("function"!=typeof t)throw new ArgumentError(`Only functions and classes are supported: ${r(t)}`);if(z(t),d(t,Jig)&&function(t){const n=Object.getOwnPropertyNames(t.prototype),r=p.find((t=>n.includes(t)))||y.find((t=>n.includes(t)))||v.find((t=>n.includes(t)));if(r)throw new ArgumentError(`Must not have any reserved jig words: ${r}`);const Jig=e(7),o=[];let i=t;for(;i!==Jig;)o.push(i),i=Object.getPrototypeOf(i);const s=/\s+constructor\s*\(/;if(o.some((t=>s.test(t.toString()))))throw new Error("Jig must use init() instead of constructor()")}(t),d(t,Berry)&&function(t){const n=Object.getOwnPropertyNames(t.prototype),r=p.find((t=>n.includes(t)))||v.find((t=>n.includes(t)));if(r)throw new ArgumentError(`Must not have any reserved berry words: ${r}`);const Berry=e(13),o=[];let i=t;for(;i!==Berry;)o.push(i),i=Object.getPrototypeOf(i);const s=/\s+constructor\s*\(/;if(o.some((t=>s.test(t.toString()))))throw new Error("Berry must use init() instead of constructor()")}(t),t.prototype&&t.prototype.constructor!==t)throw new ArgumentError(`Prototypal inheritance not supported: ${r(t)}`);if(s(t))throw new ArgumentError(`Anonymous types not supported: ${r(t)}`);if(-1!==t.toString().indexOf("[native code]"))throw new ArgumentError(`Cannot install intrinsic: ${r(t)}`);!function(t){x((()=>{if(Object.getOwnPropertySymbols(t).length||Object.getOwnPropertySymbols(t.prototype).length)throw new Error("Symbol methods not supported")}))}(t),function(t){const n=t=>{if("get"in t||"set"in t)throw new Error("Getters and setters not supported")};x((()=>{Object.getOwnPropertyNames(t).map((n=>Object.getOwnPropertyDescriptor(t,n))).forEach((t=>n(t))),Object.getOwnPropertyNames(t.prototype).map((n=>Object.getOwnPropertyDescriptor(t.prototype,n))).forEach((t=>n(t)))}))}(t)}function K(t){h(t,"sealed")&&V(t.sealed),h(t,"upgradable")&&Y(t.upgradable),h(t,"interactive")&&W(t.interactive)}function V(t){if(!0!==t&&!1!==t&&"owner"!==t)throw new ArgumentError(`Invalid sealed option: ${t}`)}function Y(t){if(!0!==t&&!1!==t)throw new ArgumentError(`Invalid upgradable option: ${t}`)}function W(t){if(!0!==t&&!1!==t)throw new ArgumentError(`Invalid interactive option: ${t}`)}function z(t){const n=Object.getOwnPropertyNames(t),e=p.find((t=>n.includes(t)))||b.find((t=>n.includes(t)));if(e)throw new ArgumentError(`Must not have any reserved words: ${e}`)}function q(t,n,o=!1,s){J(n),function(t,n){if(!n.te)return;if(n.Ct)throw new Error("Cannot upgrade native code");if(t instanceof e(1))throw new ArgumentError("Cannot upgrade to a code jig");if(h(t,"presets")){const e=t.presets[n.ee],r=t=>{if(t in e)throw new Error("Preset bindings not supported for upgrades")};E.Kn.forEach((t=>r(t)))}if(x((()=>n.Qn.origin))===E.Vn)throw new Error("Cannot upgrade undeployed code")}(n,F.get(t));const c=i(n),l=c&&G(c,o,s);if(l){if(!0===l.sealed)throw new ArgumentError(`${r(l)} is sealed`);L.Tt(l).ae()}const d=new Set([t]);let p=i(n);for(;p;){if(d.has(p))throw new Error("Cannot extend the self");d.add(t),p=i(p)}!function(t,n){if(h(t,"deps")){if(!u(t.deps))throw new ArgumentError("deps must be a basic object");if(n){const e=t.deps[n.name],r=rt(e);if(e&&!w.$e(r,n))throw new ArgumentError("Parent dependency mismatch")}if(t.name in t.deps)throw new ArgumentError("Illegal dependency")}}(n,l),function(t){if(!h(t,"presets"))return;const n=t.presets;if(!u(n))throw new ArgumentError("presets must be a basic object");for(const e of Object.keys(n)){const o=n[e];if(!u(o))throw new ArgumentError(`Presets for ${e} network must be an object`);const i=v.some((t=>a(o[t]))),s=v.find((t=>!a(o[t])));if(i&&s)throw new ArgumentError(`${e} presets not fully defined: ${s} missing`);if(i){const n=$(o.location);if(!n.Rn||!a(n.Nn)&&!a(n.Cn)||a(n.Fn))throw new ArgumentError(`Bad location: ${r(t)}`);const e=$(o.origin);if(!e.Rn||!a(e.Nn)&&!a(e.Cn)||a(e.Fn))throw new ArgumentError(`Bad origin: ${r(t)}`);if(S(o.nonce),A(o.owner,!0),k(o.satoshis),o.nonce>1&&o.origin===o.location)throw new ArgumentError(`Bad nonce or location: ${r(t)}`)}if("deps"in o)throw new ArgumentError(`${e} presets must not contain deps`);if("presets"in o)throw new ArgumentError(`${e} presets must not contain presets`);z(o),K(o)}}(n),K(n),function(t){const n=Object.getOwnPropertyNames(t),e=v.find((t=>n.includes(t)));if(e)throw new ArgumentError(`Must not have any bindings: ${e}`)}(n);const b={};l&&(b[l.name]=l);const[y,_]=I.un(n,b,!1,!0);Object.defineProperty(y,"name",{value:n.name,configurable:!0});const m=Object.assign({},n),P=O(m,N,(t=>"function"==typeof t?G(t,o,s):void 0));return g(P),"deps"in P||(P.deps=new N.Object),l&&(P.deps[l.name]=l),Object.keys(P.deps||{}).forEach((n=>{Object.defineProperty(_,n,{get:()=>t.deps[n],set:e=>{t.deps[n]=e},configurable:!0,enumerable:!0})})),f(_,n.name,t),P.deps=Q(t,_,P.deps),Object.keys(P).forEach((t=>f(y,t,P[t]))),X(_),[y,_]}function Q(t,n,e){return new N.Proxy(e,{defineProperty:(e,r,o)=>{const i=Reflect.defineProperty(e,r,o);return Object.defineProperty(n,r,{get:()=>t.deps[r],set:n=>{t.deps[r]=n},configurable:!0,enumerable:!0}),i},deleteProperty:(t,e)=>{const r=Reflect.deleteProperty(t,e);return Reflect.deleteProperty(n,e),"caller"===e&&X(n),r},set:(e,r,o,i)=>{f(e,r,o);return Object.defineProperty(n,r,{get:()=>t.deps[r],set:n=>{t.deps[r]=n},configurable:!0,enumerable:!0}),!0}})}function X(t){if("caller"in t)return;const n=e(10);Object.defineProperty(t,"caller",{get:()=>n.Ft.Se(),set:()=>{throw new Error("Cannot set caller")},configurable:!0,enumerable:!0})}function Z(t,n){Object.getOwnPropertyNames(t.prototype).concat(Object.getOwnPropertySymbols(t.prototype)).filter((t=>"constructor"!==t)).forEach((r=>{const o=e(20),i=j.Ae(n,!0);t.prototype[r]=new o(t.prototype[r],i)}))}function tt(t){const Jig=e(7),Berry=e(13);if(!d(t,Jig)&&!d(t,Berry)&&!h(t,Symbol.hasInstance)){const n={configurable:!0,enumerable:!0,writable:!1},Code=e(1);n.value=Code.prototype[Symbol.hasInstance],Object.defineProperty(t,Symbol.hasInstance,n)}}function nt(...t){const n=e(22),r=new Set;t.forEach((t=>{const n=F.get(t);l(!n.Ct);et(t=rt(t)).forEach((t=>r.add(t)))})),r.size&&n.vn([...r])}function et(t,n=new Set){const Code=e(1);if(l(t instanceof Code),n.has(t))return;L.Tt(t).ae();const r=x((()=>t.location)),{Un:o}=$(r);if(!o)return n;const s=i(t);s&&et(s,n),n.add(t);const a=x((()=>Object.assign({},t))),Creation=e(3);return x((()=>P(a,(t=>(t instanceof Code&&et(t,n),!(t instanceof Creation)))))),n}function rt(t){if(F.has(t))return t;if(D.has(t))return D.get(t);let n="";try{n=o().re.network}catch(t){}const e=U[n];if(!e)return;if(e.has(t))return e.get(t);const r=h(t,"presets")&&h(t.presets,n)&&t.presets[n].location;if(r)for(const t of e.values())if(x((()=>t.location))===r)return t}L.Yt=H,L.xn=G,L.Lt=function(t,n,o=!0,i){const s=e(10),a=e(34),c=e(22);if(m.Ut&&m.Dt(C,"Upgrade",r(t),"to",r(n)),s.Ft.Mt.length)throw new Error("upgrade unavailable");const u=L.Tt(t);if(!u||u.Ct)throw new Error("upgrade unavailable");if(!x((()=>!h(t,"upgradable")||t.upgradable)))throw new Error(`${r(t)} is non-upgradable`);const f=new a(t);try{const e=[];u.ie(n,o,e,i),s.Ft.En((()=>{e.length&&nt(...e),c.ke(t,f)}))}catch(t){throw f.je(t),t}},L.Vt=rt,L.Ie=function(t){const n=M[t];if(n){if(F.get(n).oe)throw new Error(`${t} is internal to RUN and cannot be deployed`);return n}},L.Te=function(){let t="";try{t=o().re.network}catch(t){}function n(t,n){I.sn.includes(n.name)||(v.forEach((t=>{delete n[t]})),delete n[Symbol.hasInstance])}m.tn&&m.qt(C,"Deactivate",t,"bindings"),U[t]&&x((()=>U[t].forEach(n)))},L.Re=function(){let t="";try{t=o().re.network}catch(t){}function n(n,e){h(e,"presets")&&h(e.presets,t)?v.forEach((n=>f(e,n,e.presets[t][n]))):I.sn.includes(e.name)||E.$n(e),tt(e)}m.tn&&m.qt(C,"Activate",t,"bindings"),Array.from(D.values()).forEach((t=>L.Tt(t).ae())),U[t]&&x((()=>U[t].forEach(n)))},L.Ne=q,L.Ce=Q,L.ye=function(t){const n=rt(t);if(n)return n;const e=L.Yt();return L.Tt(e).ye(t),e},L.Tt=t=>F.get(t),L.Fe=V,L.Ue=Y,L.De=W,L.Be=F,t.exports=L},function(t,n,e){const r=e(6),{crypto:o}=r,{D:i,J:s,F:a,Z:c}=e(0),u=e(25),{In:h,Dn:f,Vn:l}=e(8),{h:d}=e(4),p=e(34),b=e(2),y=e(26),{rt:w}=e(14),g="Record";class _{constructor(){this.Me=o.Random.getRandomBuffer(32).toString("hex"),this.Le=0,this.He=[],this.Mt=[],this.Zt=null,this.Gt=new u,this.Ge=new u,this.Je=new u,this.Ke=new u,this.Ve=new u,this.Ye=new u,this.We=new u,this.ze=new u,this.qe=new u,this.Qe=[],this.Xe=new Map,this.Ze=!0,this.tr=!1,this.nr=!1,this.er=null}rr(){i(!this.nr),b.Ut&&b.Dt(g,"Begin"),this.Le++}ir(){i(this.Le),b.Ut&&b.Dt(g,"End"),this.Le--,this.Le||!this.Ze||this.nr||this.sr()}ar(t){const Creation=e(3);i(!this.nr),i(t instanceof Creation),b.Ut&&b.Dt(g,`Push ${s(t)}`),this.Mt.push(t)}cr(){i(this.Mt.length);const t=this.Mt.pop();b.Ut&&b.Dt(g,`Pop ${s(t)}`)}ur(t){if(i(!this.Mt.length),b.Ut&&b.Dt(g,`Action ${t}`),this.He.push(t),this.hr(),!this.tr){const t=this.lr();this.ze.dr((n=>t.pr("update",n))),this.Ke.dr((n=>t.pr("update",n)))}!this.Le&&this.Ze&&this.sr()}hr(){!function(t,n){t.We=new u;for(const n of t.Je)t.We.br(n);for(const n of t.Ve)t.We.br(n);for(const n of t.Ke)t.We.br(n);for(const n of t.Gt)t.We.yr(n);t.ze=new u;for(const n of t.We)t.ze.br(n);for(const n of t.Gt)t.ze.br(n);for(const n of t.Ke)t.ze.yr(n);t.qe=new u;for(const n of t.Ge)t.qe.br(n);for(const n of t.We)t.qe.yr(n);for(const n of t.ze)t.qe.yr(n);for(const n of t.Ke)t.qe.yr(n)}(this),function(t){const n=n=>{const e=h(n.origin);return e.Un||e.Tn===t.Me};d((()=>{t.ze.dr(((e,r)=>{e.location=f({Tn:t.Me,Nn:r}),n(e)&&(e.origin=e.location),e.nonce=t.Xe.get(e).wr.nonce+1})),t.Ke.dr(((e,r)=>{e.location=f({Tn:t.Me,Cn:r}),n(e)&&(e.origin=e.location),e.nonce=t.Xe.get(e).wr.nonce+1}))}))}(this)}gr(t){i(!this.nr),this.Ye.Ht(t)||(b.Ut&&b.Dt(g,`Unbind ${s(t)}`),this.Ye.br(t))}sr(){i(!this.nr);const t=e(35);if(b.Ut&&b.Dt(g,"Commit"),this.Me===_.Ft.Me&&(i(!_.Ft.Le),_.Ft=new _),!this.He.length)return b.nn&&b.Xt(g,"No actions found"),i(!this.Gt._r),i(!this.Je._r),i(!this.Ke._r),void i(!this.Ve._r);if(!this.He.length||this.Gt._r||this.Je._r||this.Ke._r||this.Ve._r){this.mr();try{return new t(this)}catch(t){throw this.je(t),t}}}mr(){const Code=e(1),Creation=e(3),t=this.ze.Or().concat(this.Ke.Or()).concat(this.qe.Or()).map((t=>t instanceof Code?t:t.constructor));t.filter((t=>!1===t.interactive)).forEach((n=>{const e=new Set([n]);d((()=>w(n,(t=>{t instanceof Creation&&e.add(t)}))));const r=t.find((t=>!e.has(t)));if(r)throw new Error(`${n.name} is not permitted to interact with ${r.name}`)}))}Pr(t){if(this.Er(t,"create"),i(!this.nr),this.Gt.Ht(t))return void this.vr();b.Ut&&b.Dt(g,"Create",s(t));const Code=e(1),Jig=e(7);i(t instanceof Code||t instanceof Jig);const n=d((()=>h(t.origin).Ct));i(!c(n)),i(!this.Je.Ht(t)),i(!this.Ke.Ht(t)),i(!this.Ve.Ht(t)),i(!this.Ye.Ht(t)),this.Gt.br(t),this.$r(t,!1,"create"),this.Sr(t),this.vr(t)}_read(t){if(i(!this.nr),this.Ge.Ht(t))return;b.Ut&&b.Dt(g,"Read",s(t));const Creation=e(3);i(t instanceof Creation),this.Ge.br(t),this.$r(t,!0,"read"),this.Sr(t,void 0,!0)}Ar(t,n){if(this.Er(t,"update"),i(!this.nr),this.Je.Ht(t))return this.kr(t,"update"),void this.vr(t);b.Ut&&b.Dt(g,"Update",s(t));const Code=e(1),Jig=e(7);i(t instanceof Code||t instanceof Jig);const r=d((()=>t.origin===l));i(!r||this.Gt.Ht(t));const o=d((()=>h(t.origin).Ct));i(!c(o)),this.kr(t,"update"),this.Je.br(t),this.$r(t,!1,"update"),this.Sr(t,n),this.vr(t)}yr(t){if(this.Er(t,"delete"),i(!this.nr),this.Ke.Ht(t))return this.kr(t,"delete"),void this.vr(t);b.Ut&&b.Dt(g,"Delete",s(t));const Code=e(1),Jig=e(7);i(t instanceof Code||t instanceof Jig);const n=d((()=>h(t.origin).Ct));i(!c(n)),this.kr(t,"delete"),this.Ke.br(t),this.$r(t,!1,"delete"),this.Sr(t),this.vr(t),d((()=>{t.owner=null,t.satoshis=0}))}Jt(t,n){if(this.Er(t,"auth"),i(!this.nr),this.Ve.Ht(t))return this.kr(t,"auth",!n),void(n||this.vr(t));b.Ut&&b.Dt(g,"Auth",s(t));const Code=e(1),Jig=e(7);i(t instanceof Code||t instanceof Jig),i(!this.Gt.Ht(t)),this.kr(t,"auth",!n),this.Ve.br(t),this.$r(t,!1,"auth"),this.Sr(t),this.vr(t)}vr(t){i(!this.nr),this.Mt.filter((n=>t!==n)).filter((t=>!!t)).filter((t=>!this.Gt.Ht(t))).forEach((t=>this.Jt(t,!0)))}kr(t,n,e){if(this.An(t,e)){const e=this.Ke.Ht(t)?`${s(t)} deleted`:`${s(t)} has an unbound owner or satoshis value`;throw new Error(`${n} disabled: ${e}`)}}An(t,n){return this.Ye.Ht(t)||n&&y.me(t).jr()}Er(t,n){if(!this.Mt.length)return;const Berry=e(13),r=this.Mt.some((t=>t instanceof Berry));if(r)throw new Error(`Cannot ${n} ${s(t)} in berry`)}Sr(t,n,e){const r=this.lr().Ir,o=e||!r,i=this.Xe.get(t);if(i)return!o&&i.Tr&&i.Rr(),void(e||(i.Nr=!0));const s=n||new p(t,o,e);this.Xe.set(t,s)}$r(t,n,r){i(!this.nr);const o=d((()=>t.location)),a=h(o);if(c(a.Tn)){if(a.Tn===this.Me)return;const o=e(35).Cr(a.Tn);if(!o&&!n)throw new Error(`Cannot ${r} ${s(t)}: open transaction`);!o||this.Qe.includes(o)||o.Fr||this.Qe.push(o)}}je(t){if(this.nr)return;b.Ut&&b.Dt(g,"Rollback"),this.Xe.forEach((n=>n.je(t))),this.Me===_.Ft.Me&&(_.Ft=new _);const n=this.lr();this.ze.dr((t=>n.pr("update",t))),this.Ke.dr((t=>n.pr("update",t))),this.nr=!0}Se(){return this.Mt.length<2?null:this.Mt[this.Mt.length-2]}En(t){try{this.rr();const n=t();return this.ir(),n}catch(t){throw this.je(t),t}}lr(){const t=a();if(this.er){if(t!==this.er)throw new Error("Different Run instances must not be used to produce a single update")}else this.er=t;return this.er}}_.Ft=new _,t.exports=_},function(t,n){class ArgumentError extends Error{constructor(t="Unknown reason"){super(t),this.name=this.constructor.name}}class ClientModeError extends Error{constructor(t,n){super(`Cannot load ${t}\n\n${`Only cached ${n}s may be loaded in client mode`}`),this.data=t,this.type=n,this.name=this.constructor.name}}class ExecutionError extends Error{constructor(t){super(t),this.name=this.constructor.name}}class InternalError extends Error{constructor(t){super(t),this.name=this.constructor.name}}class NotImplementedError extends Error{constructor(t){super(t),this.name=this.constructor.name}}class TimeoutError extends Error{constructor(t){super(t),this.name=this.constructor.name}}class TrustError extends Error{constructor(t,n){super(`Cannot load untrusted code${n?" via "+n:""}: ${t}\n\nHint: Trust this txid using run.trust(txid) if you know it is safe`),this.txid=t,this.from=n,this.name=this.constructor.name}}t.exports={ArgumentError,ClientModeError,ExecutionError,InternalError,NotImplementedError,TimeoutError,TrustError}},function(t,n,e){const r=e(6),{Script:o,Transaction:i}=r,{Interpreter:s}=o,{Input:a}=i,{ECDSA:c,Signature:u}=r.crypto,{BufferReader:h,BufferWriter:f}=r.encoding,{BN:l}=r.deps.bnjs,d=new Map;async function p(t,n,e,r,o){const i=t.inputs[e];async function s(n){const e=new f;if(void 0===n){if(t._hashOutputsAll)return t._hashOutputsAll;t.outputs.forEach((t=>{t.toBufferWriter(e)}))}else t.outputs[n].toBufferWriter(e);const r=e.toBuffer(),o=await y(r);return void 0===n&&(t._hashOutputsAll=o),o}let a=Buffer.alloc(32),c=Buffer.alloc(32),l=Buffer.alloc(32);n&u.SIGHASH_ANYONECANPAY||(a=await async function(){if(t._hashPrevouts)return t._hashPrevouts;const n=new f;t.inputs.forEach((t=>{n.writeReverse(t.prevTxId),n.writeUInt32LE(t.outputIndex)}));const e=n.toBuffer();return t._hashPrevouts=await y(e),t._hashPrevouts}()),n&u.SIGHASH_ANYONECANPAY||(31&n)===u.SIGHASH_SINGLE||(31&n)===u.SIGHASH_NONE||(c=await async function(){if(t._hashSequence)return t._hashSequence;const n=new f;t.inputs.forEach((t=>{n.writeUInt32LE(t.sequenceNumber)}));const e=n.toBuffer();return t._hashSequence=await y(e),t._hashSequence}()),(31&n)!==u.SIGHASH_SINGLE&&(31&n)!==u.SIGHASH_NONE?l=await s():(31&n)===u.SIGHASH_SINGLE&&e<t.outputs.length&&(l=await s(e));const d=new f;d.writeInt32LE(t.version),d.write(a),d.write(c),d.writeReverse(i.prevTxId),d.writeUInt32LE(i.outputIndex),d.writeVarintNum(r.toBuffer().length),d.write(r.toBuffer()),d.writeUInt64LEBN(o),d.writeUInt32LE(i.sequenceNumber),d.write(l),d.writeUInt32LE(t.nLockTime),d.writeUInt32LE(n>>>0);const p=d.toBuffer(),b=await y(p);return new h(b).readReverse()}async function b(t){const sha256=e(30).Ur,n=await sha256(t);return r.deps.Buffer.from(n)}async function y(t){const n=await b(t);return await b(n)}t.exports={Dr:function(t){if(t.Br)return;t.Br=!0,i.FEE_PER_KB=50,i.DUST_AMOUNT=1;const n=i.prototype.sign;i.prototype.sign=function(...t){const e=a.prototype.isValidSignature;a.prototype.isValidSignature=()=>!0;const r=n.call(this,...t);return a.prototype.isValidSignature=e,r},a.prototype.clearSignatures=()=>{},a.prototype.getSignatures=()=>[],a.prototype.isFullySigned=function(){return!!this.script.toBuffer().length},i.prototype.isFullySigned=function(){return!this.inputs.some((t=>!t.isFullySigned()))},i.prototype.isValidSignature=function(t){const n=new s,e=t.inputIndex,r=this.inputs[e],o=s.SCRIPT_VERIFY_STRICTENC|s.SCRIPT_VERIFY_DERSIG|s.SCRIPT_VERIFY_LOW_S|s.SCRIPT_VERIFY_NULLDUMMY|s.SCRIPT_VERIFY_SIGPUSHONLY|s.SCRIPT_ENABLE_MONOLITH_OPCODES|s.SCRIPT_ENABLE_MAGNETIC_OPCODES|s.SCRIPT_ENABLE_SIGHASH_FORKID;return n.verify(r.script,r.output.script,this,e,o,r.output.satoshisBN)}},Mr:function(t,n){return 1},Lr:async function(t){const n=d.get(t);if(n)return d.delete(t),d.set(t,n),n;const e=(await b(new r.Script(t).toBuffer())).reverse().toString("hex");if(d.set(t,e),d.size>100){const t=d.keys().next().value;d.delete(t)}return e},Hr:p,Gr:async function(t,n,e,r,o,i=u.SIGHASH_ALL){i|=u.SIGHASH_FORKID;const s=new l(r),a=await p(t,i,n,e,s),h=c.sign(a,o,"little"),f=Buffer.from(h.toDER());return Buffer.concat([f,Buffer.from([255&i])]).toString("hex")},Ur:b,Jr:function(t){const n=r.deps.Buffer.from(t),e=r.crypto.Hash.sha256(n);return new Uint8Array(e)}}},function(t,n,e){class BerryDeps{static get xt(){return e(22)}static get pn(){return e(8)}static get vt(){return e(9)}static get wn(){return e(16)}static get gn(){return e(20)}static get St(){return e(0)}static get Kr(){return e(13)}static get At(){return e(10)}static get mn(){return e(23)}static get h(){return e(4).h}static get It(){return e(27)}}class Berry{constructor(...t){const n=BerryDeps.xt,e=BerryDeps.St.S,r=BerryDeps.Kr,o=BerryDeps.gn,i=BerryDeps.wn.Vr,s=BerryDeps.mn,{Vn:a}=BerryDeps.pn;if(this.constructor===r)throw new Error("Berry must be extended");i(this.constructor),this.location=a,this.origin=a,this.nonce=0,this.owner=null,this.satoshis=0;const c=s.Yr(!1),u=new o(this,c);return e.add(u),c.Wr=!1,n.zr(this.constructor,u,t),c.Wr=!0,u}static[Symbol.hasInstance](t){if(!BerryDeps.St.S.has(t))return!1;if(this===BerryDeps.Kr)return!0;const n=BerryDeps.vt.Vt(this);return!!n&&BerryDeps.h((()=>{let e=Object.getPrototypeOf(t);for(;e;){if(e.constructor.location===n.location)return!0;e=Object.getPrototypeOf(e)}return!1}))}static async pluck(t,n,e){return new this}static load(t){const{F:n,J:e,G:r}=BerryDeps.St,o=BerryDeps.wn,i=BerryDeps.Kr,s=BerryDeps.At.Ft;if(BerryDeps.It.Bt)throw new Error("load disabled during atomic update");if(this!==i&&!r(this,i))throw new Error("load unavailable");if(s.Mt.length)throw new Error("load cannot be called internally");const a=n(),c=o(t,this===i?void 0:this,a);return(async()=>{const n=await c;if(n instanceof this)return n;throw new Error(`Cannot load ${t}\n\n${e(n)} not an instance of ${e(this)}`)})()}init(...t){}}Berry.deps={BerryDeps},Berry.sealed=!1,Berry.toString();const r=BerryDeps.vt.Yt();BerryDeps.vt.Tt(r).Wt(Berry,!1),t.exports=r},function(t,n,e){const{V:r,K:o,J:i,Y:s,W:a,q:c,X:u,ut:h,D:f}=e(0),{qr:l}=e(17),d=e(25),p=e(5),b=p._,y=p.g,w=p.O,g=p.P,_=b.Object,m=y.Object;t.exports={rt:function t(n,e,r=new Set){if("function"!=typeof n&&"object"!=typeof n||!n)return void e(n);if(r.has(n))return;if(r.add(n),!1===e(n))return;if(n instanceof b.Set||n instanceof y.Set)for(const o of n)t(o,e,r);if(n instanceof b.Map||n instanceof y.Map)for(const[o,i]of n)t(o,e,r),t(i,e,r);l(n).forEach((o=>{t(n[o],e,r)})),"object"!=typeof n||w.has(n.constructor)||g.has(n.constructor)||t(n.constructor,e,r);const o=Object.getPrototypeOf(n);"function"==typeof n&&o!==_.getPrototypeOf(_)&&o!==m.getPrototypeOf(m)&&t(o,e,r)},Qr:function t(n,r,o=new Map){if("function"!=typeof n&&"object"!=typeof n||!n)return n;if(o.has(n))return o.get(n);let i=!0;const s=r(n,(t=>{i=t}))||n;if(o.set(n,s),"function"!=typeof s&&"object"!=typeof s||!s||!i)return s;const a=e(5),Code=e(1),c=a._,u=a.g,d=a.O,p=a.P,b=c.Object,y=u.Object;if(s instanceof c.Set||s instanceof u.Set){const n=Array.from(s);for(let e=0;e<n.length;e++)n[e]=t(n[e],r,o);s.clear(),n.forEach((t=>s.add(t)))}if(s instanceof c.Map||s instanceof u.Map){const n=Array.from(s);for(let e=0;e<n.length;e++)n[e][0]=t(n[e][0],r,o),n[e][1]=t(n[e][1],r,o);s.clear(),n.forEach((t=>s.set(t[0],t[1])))}if(l(s).forEach((n=>{const e=s[n],i=t(e,r,o);e!==i&&h(s,n,i)})),"object"==typeof s&&!d.has(s.constructor)&&!p.has(s.constructor)){const n=t(s.constructor,r,o);Object.getPrototypeOf(s)!==n.prototype&&Object.setPrototypeOf(s,n.prototype)}const w=Object.getPrototypeOf(s);if("function"==typeof s&&w!==b.getPrototypeOf(b)&&w!==y.getPrototypeOf(y)){const n=t(w,r,o);if(w!==n){f(s!==n),Object.setPrototypeOf(s,n);const t=s instanceof Code?Object.getPrototypeOf(s.prototype):s.prototype;Object.setPrototypeOf(t,n.prototype)}}return s},Pn:function t(n,f,d,p=new Map){if("symbol"==typeof n)throw new Error(`Cannot clone: ${i(n)}`);if("function"!=typeof n&&"object"!=typeof n||!n)return n;if(p.has(n))return p.get(n);if(d){const t=d(n);if(t)return p.set(n,t),t}const b=e(5),Creation=e(3),y=b._,w=b.O,g=b.P;if(f=f||y,n instanceof Creation)return n;if("function"==typeof n)throw new Error(`Cannot clone non-code function: ${i(n)}`);if(w.has(n)||g.has(n))throw new Error(`Cannot clone intrinsic: ${i(n)}`);let _=null;if(r(n)&&(_=new f.Array),o(n)&&(_=new f.Object),c(n))return new f.Uint8Array(f.Array.from(n));s(n)&&(_=new f.Set),a(n)&&(_=new f.Map);let m=!1;if(_||(m=!0,_=new f.Object),!_)throw new Error(`Cannot clone: ${i(n)}`);if(p.set(n,_),_ instanceof f.Set)for(const e of n){const n=t(e,f,d,p);_.add(n)}if(_ instanceof f.Map)for(const e of n){const n=t(e[0],f,d,p),r=t(e[1],f,d,p);_.set(n,r)}if(l(n).forEach((e=>{if("symbol"==typeof e)throw new Error(`Cannot clone: ${i(e)}`);h(_,e,t(n[e],f,d,p))})),!w.has(n.constructor)&&!g.has(n.constructor)){const e=t(n.constructor,f,d,p);Object.setPrototypeOf(_,e.prototype)}if(m&&!u(_))throw new Error(`Cannot clone: ${i(n)}`);return _},Xr:function t(n,i,u={}){if(typeof n!=typeof i)return!1;if("number"==typeof n&&isNaN(n)&&isNaN(i))return!0;const Creation=e(3);if(n instanceof Creation)return d.$e(n,i);if("object"!=typeof n||!n||!i)return n===i;const h=Object.getOwnPropertyNames(n),f=Object.getOwnPropertyNames(i),l=Object.getOwnPropertyDescriptors(n),p=Object.getOwnPropertyDescriptors(i),b=h.filter((t=>l[t].enumerable)),y=f.filter((t=>p[t].enumerable));if(b.length!==y.length)return!1;if(u.Zr)for(let e=0;e<b.length;e++){const r=b[e],o=y[e];if(r!==o)return!1;if(!t(n[r],i[o]))return!1}else{if(b.some((t=>!y.includes(t))))return!1;if(b.some((e=>!t(n[e],i[e],u))))return!1}if(o(n))return!!o(i);if(r(n))return!!r(i);if(s(n))return!!s(i)&&(n.size===i.size&&!!t(Array.from(n.entries()),Array.from(i.entries())));if(a(n))return!!a(i)&&(n.size===i.size&&!!t(Array.from(n.entries()),Array.from(i.entries())));if(c(n))return!!c(i);throw new Error(`Unsupported: ${n}`)}}},function(t,n){t.exports={no:5,jn:function(t){if(5!==t)throw new Error(`Unsupported version: ${t}`);return t},eo:function(t){const n="string"==typeof t&&2===t.length&&parseInt(t,16);if(5===n)return 5;throw new Error(`Unsupported RUN transaction version: ${t}${n>5?"\n\nHint: Upgrade your Run SDK to load this transaction":""}`)},ro:function(t){if("04"===t)return 5;throw new Error(`Unsupported state version: ${t}`)},oo:function(t){if(5===t)return"05";throw new Error(`Unsupported protocol version: ${t}`)},io:function(t){if(5===t)return"04";throw new Error(`Unsupported protocol version: ${t}`)}}},function(t,n,e){const r=e(6),{Transaction:o}=r,i=e(2),{D:s,G:a,J:c,yt:u,Z:h}=e(0),{so:f}=e(17),{In:l,Dn:d,Vn:p}=e(8),{h:b}=e(4),y=e(5),{ArgumentError,ClientModeError,TrustError}=e(11),{no:w}=e(15),{Ur:g}=e(12),{ao:_}=e(32),{ExecutionError}=e(11),Code=e(1),m=e(9),O=y.g,P=y._,E="Load",x=new Map;let v=[],$=0,S=null;class A{constructor(){this.co=new Map,this.uo=new Map,this.ho=[]}}async function k(t,n,r,o,f,p=!0){s(r),o=o||new A,f=f||new u("load",r._t,t);try{if(f.Pt(),!n){const n=o.co.get(t);if(n)return n}const s=async function(t,n,r,o,s){s.Pt(),n?i.tn&&i.qt(E,"Load",t,"with",c(n)):i.tn&&i.qt(E,"Load",t);const u=new Date;try{if(n)return await async function(t,n,r,o,i){i.Pt();const Berry=e(13);if(!a(n,Berry))throw new ArgumentError("Berry class must extend from Berry");if("string"!=typeof t)throw new ArgumentError("Berry path must be a string");const B=m.xn(n);if(b((()=>l(B.location))).Rn){const n={Fn:t,jn:w},s=Object.assign(l(B.location),n),a=d(s),c=`${a.includes("?")?"berry":"jig"}://${a}`,u={all:!0,tx:!r.fo.has("state")},h=r.lo&&await r.lo.pull(c,u);if(h){const t=e(42),n=await t(a,h,void 0,r,o,i);return o.ho.push(n.do),n.po}}return I(t,null,w,B,r,o,i)}(t,n,r,o,s);const f=l(t);if(h(f.Zt)||h(f.Tn))throw new ArgumentError(`Bad location: ${t}`);if(h(f.Ct))return function(t,n){n.Pt();const{Ct:e}=l(t),r=m.Ie(e);if(!r)throw new ArgumentError(`Native code not found: ${e}`);if(m.Tt(r).oe)throw new ArgumentError(`${c(r)} cannot be a dependency`);return r}(t,s);if(!f.Rn)throw new ArgumentError(`Bad location: ${t}`);return h(f.Fn)?await async function(t,n,r,o){const i=async()=>{o.Pt();const i=l(t),s=i.Rn+(h(i.Nn)?`_o${i.Nn}`:`'_d${i.Cn}`),a=i.Fn,c=i._hash,u=i.jn||w,f=d({Rn:i.Rn,Cn:i.Cn,Nn:i.Nn,Fn:a,jn:u}),p=`${t.includes("?")?"berry":"jig"}://${f}`,b={all:!0,tx:!n.fo.has("state")},y=n.lo&&await n.lo.pull(p,b);if(y){const i=e(42),s=await i(t,y,c,n,r,o);return r.ho.push(s.do),s.po}return I(a,c,u,await k(s,null,n,new A,o),n,r,o)};return await T(t,i,n,r,o)}(t,r,o,s):await j(t,r,o,s)}finally{i.Ut&&i.Dt(E,"Load (end): "+(new Date-u)+"ms")}}(t,n,r,o,f);n||o.co.set(t,s);const u=await s;if(p)for(;o.ho.length;){const t=o.ho;o.ho=[],await Promise.all(t)}return u}catch(t){throw $&&(S=S||t),t}}async function j(t,n,r,i){return await T(t,(async()=>{i.Pt();const s=`${t.includes("?")?"berry":"jig"}://${t}`,a={all:!0,tx:!n.fo.has("state")},c=n.lo&&await n.lo.pull(s,a);return c?async function(t,n,r,i,s){const{Rn:a,Nn:c,Cn:u}=l(t);let h=null;if(!r.fo.has("state")){const n=await r.bo(a),e=new o(n),i=_(e),s="number"==typeof c&&c>i.vrun&&c<i.out.length+i.vrun+1,f="number"==typeof u&&u>=0&&u<i.del.length;if(!s&&!f)throw new ArgumentError(`Not a jig: ${t}`);h=s?i.out[c-i.vrun-1]:i.del[u]}const f=e(42),d=await f(t,n,h,r,i,s);return i.ho.push(d.do),d.po}(t,c,n,r,i):async function(t,n,r,i){if(i.Pt(),n.yo)throw new ClientModeError(t,"jig");const{Rn:s,Nn:a,Cn:c}=l(t),u=await n.bo(s),h=new o(u);let f=null;try{f=_(h)}catch(t){throw new ExecutionError(t.message)}let d=null;if(r.uo.has(s))d=await r.uo.get(s);else{if(x.has(s))return await x.get(s),await j(t,n,r,i);try{const t=e(33),o=t(h,s,f,n,!0,null,i,!1);r.uo.set(s,o),x.set(s,o),d=await o}finally{r.uo.delete(s),x.delete(s)}}const p=d.Tn;if(p.ze.dr((t=>n.pr("load",t))),p.Ke.dr((t=>n.pr("load",t))),"number"==typeof a&&a>f.vrun&&a<p.ze._r+f.vrun+1)return p.ze.Or()[a-f.vrun-1];if("number"==typeof c&&c>=0&&c<p.Ke._r)return p.Ke.Or()[c];throw new ArgumentError(`Jig not found: ${t}`)}(t,n,r,i)}),n,r,i)}async function I(t,n,o,B,a,u,h){h.Pt(),s(B instanceof Code),i.tn&&i.qt(E,"Pluck",c(B),t);const w={f:a.bo.bind(a),se:t=>{S=S||t}},[_]=y.dn("async function(txid) {\n try {\n return await f(txid)\n } catch (e) {\n se(e)\n throw e\n }\n }",w);Object.freeze(_);try{const i=!!b((()=>l(B.location))).Rn;let s=p;if(i&&(s=d(Object.assign(l(B.location),{Fn:t,jn:o}))),v.push(B),$++,S)throw S;const u=B.pluck(t,_);if(!(u instanceof O.Promise||u instanceof P.Promise))throw new Error("pluck method must be async");const h=await u;if(!h||h.constructor!==B)throw new Error(`Berry must be an instance of ${c(B)}`);if(i){b((()=>{h.location=h.origin=s}));const{wo:t}=e(50),i=t(h,o),c=f(i),u=new r.deps.Buffer(c,"utf8"),p=(await g(u)).toString("hex");if(n&&n!==p)throw new Error("Berry state mismatch");const y=d(Object.assign({_hash:p},l(s)));b((()=>{h.location=h.origin=y}));const w=`berry://${s}`;await a._o.set(w,i)}if(S)throw S;return h}catch(t){throw S=S||t,t}finally{0==--$&&(v=[],S=null)}}async function T(t,n,e,r,o){let s;try{s=await e.lo.pull(`ban://${t}`)}catch(n){i.nn&&i.Xt(E,`Failure to get from cache ban://${t}\n\n${n.toString()}`)}let a="object"==typeof s&&s;if(a){const n=s.untrusted&&await e.mo(s.untrusted),r=a.reason.includes("Cannot convert undefined or null to object");if(n||r){try{await e._o.set(`ban://${t}`,!1)}catch(n){i.nn&&i.Xt(E,`Failure to unban from cache ${t}\n\n${n.toString()}`)}a=!1}}if(a){if(s.untrusted)throw new Error(s.reason);const n=`Hint: If you wish to unban this location: await run.cache.set('ban://${t}', false)`;throw new Error(`Failed to load banned location: ${t}\n\nReason: ${s.reason}\n\n${n}`)}try{return await n(t)}catch(n){if(n instanceof ExecutionError||n instanceof TrustError)try{const r=