/
run.browser.min.js
10 lines (10 loc) · 329 KB
/
run.browser.min.js
1
2
3
4
5
6
7
8
9
10
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("bsv")):"function"==typeof define&&define.amd?define(["bsv"],n):"object"==typeof exports?exports.Run=n(require("bsv")):t.Run=n(t.bsv)}(window,(function(__WEBPACK_EXTERNAL_MODULE__6__){return 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=63)}([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===x(t)}function b(t){return Array.isArray(t)&&3===x(t)}function w(t){const n=e(5),r=n.g;return(t instanceof n._.Set||t instanceof r.Set)&&3===x(t)}function y(t){const n=e(5),r=n.g;return(t instanceof n._.Map||t instanceof r.Map)&&3===x(t)}function g(t){const n=e(5),r=n.g;return(t instanceof n._.Uint8Array||t instanceof r.Uint8Array)&&4===x(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(w(t))return!0;if(y(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*{/,v=/^function\s*\(/;function x(t){if(!t)return 0;let n=0;do{n++,t=Object.getPrototypeOf(t)}while(t);return n}function A(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(43);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:w,W:y,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)||v.test(n))},st:x,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:A,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>A(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(54)}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__){(function(process,global){const DeterministicRealm=__webpack_require__(50),{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,void 0!==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}).call(this,__webpack_require__(30),__webpack_require__(42))},function(t,n){t.exports=__WEBPACK_EXTERNAL_MODULE__6__},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(54)}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 w=!p||l.An(p,!0);return n.kn(this.constructor,b,t,w),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,w=["location","origin","nonce"],y=["owner","satoshis"],g=w.concat(y),_="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(44);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(55);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:w,Jn:y,Kn:g,Vn:_,Yn:0}},function(t,n,e){(function(n){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:w}=e(0),y=e(25),{Wn:g}=e(32),_=e(51),m=e(2),{Pn:O,rt:P}=e(14),E=e(8),{h:v}=e(4),{Kn:x,In:A,Bn:$,Mn:S,Ln:k}=E,j=e(23),T=e(5),I=e(26),{ArgumentError}=e(11),R=e(24),N=T.g,C="Editor",U=new WeakMap,F={},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);F[this.ee]=F[this.ee]||new Map,F[this.ee].delete(this.qn),n&&F[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")&&(v((()=>P(this.Qn,(t=>{if(t instanceof Code&&t!==this.Qn&&A(t.location).Un)throw new ArgumentError(`${r(t)} must have presets`)})))),this.de(this.qn.presets[this.ee]))}catch(n){throw F[this.ee].delete(t),this.local&&F[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&&(F[this.ee].delete(this.qn),this.te=!1),this.Zn&&(D.delete(this.qn),this.Zn=!1),this.qn&&(x.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),F[this.ee]=F[this.ee]||new Map,F[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()};v((()=>P(this.Qn,t)))}catch(t){throw D.set(this.qn,this.Qn),F[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(I.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(){v((()=>{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){v((()=>{t?x.forEach((n=>f(this.Qn,n,t[n]))):h(this.Qn,"location")||E.$n(this.Qn)}))}Wt(t,e=!1){m.Ut&&m.Dt(C,"Install native",r(t)),l(void 0===this.Ct),l(!i(t)),l(!(t.name in M));const[o,s]=T.un(t,{},!0,!1);Object.assign(s,t.deps);const c=t.sealed,u=t.upgradable,h=t.interactive;n.env.COVER&&Object.keys(o).forEach((t=>{delete o[t]})),a(c)&&f(o,"sealed",c),a(u)&&f(o,"upgradable",u),a(h)&&f(o,"interactive",h),Z(o,this.Qn),_.pe(this.Rt,o),o.origin=`native://${t.name}`,o.location=`native://${t.name}`,o.nonce=0,o.owner=null,o.satoshis=0,M[t.name]=this.Qn,I.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=e}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,{}),v((()=>{x.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),U.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)))||w.find((t=>n.includes(t)))||x.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)))||x.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){v((()=>{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")};v((()=>{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(v((()=>n.Qn.origin))===E.Vn)throw new Error("Cannot upgrade undeployed code")}(n,U.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&&!y.$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=x.some((t=>a(o[t]))),s=x.find((t=>!a(o[t])));if(i&&s)throw new ArgumentError(`${e} presets not fully defined: ${s} missing`);if(i){const n=A(o.location);if(!n.Rn||!a(n.Nn)&&!a(n.Cn)||a(n.Fn))throw new ArgumentError(`Bad location: ${r(t)}`);const e=A(o.origin);if(!e.Rn||!a(e.Nn)&&!a(e.Cn)||a(e.Fn))throw new ArgumentError(`Bad origin: ${r(t)}`);if($(o.nonce),S(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=x.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[w,_]=T.un(n,b,!1,!0);Object.defineProperty(w,"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(w,t,P[t]))),X(_),[w,_]}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=U.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=v((()=>t.location)),{Un:o}=A(r);if(!o)return n;const s=i(t);s&&et(s,n),n.add(t);const a=v((()=>Object.assign({},t))),Creation=e(3);return v((()=>P(a,(t=>(t instanceof Code&&et(t,n),!(t instanceof Creation)))))),n}function rt(t){if(U.has(t))return t;if(D.has(t))return D.get(t);let n="";try{n=o().re.network}catch(t){}const e=F[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(v((()=>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(36),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(!v((()=>!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(U.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){T.sn.includes(n.name)||(x.forEach((t=>{delete n[t]})),delete n[Symbol.hasInstance])}m.tn&&m.qt(C,"Deactivate",t,"bindings"),F[t]&&v((()=>F[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)?x.forEach((n=>f(e,n,e.presets[t][n]))):T.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())),F[t]&&v((()=>F[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=>U.get(t),L.Fe=V,L.Ue=Y,L.De=W,L.Be=U,t.exports=L}).call(this,e(30))},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(36),b=e(2),w=e(26),{rt:y}=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(37);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((()=>y(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&&w.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(37).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){(function(n){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,e,r,o,i){const s=t.inputs[r];async function a(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 w(r);return void 0===n&&(t._hashOutputsAll=o),o}let c=n.alloc(32),l=n.alloc(32),d=n.alloc(32);e&u.SIGHASH_ANYONECANPAY||(c=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 w(e),t._hashPrevouts}()),e&u.SIGHASH_ANYONECANPAY||(31&e)===u.SIGHASH_SINGLE||(31&e)===u.SIGHASH_NONE||(l=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 w(e),t._hashSequence}()),(31&e)!==u.SIGHASH_SINGLE&&(31&e)!==u.SIGHASH_NONE?d=await a():(31&e)===u.SIGHASH_SINGLE&&r<t.outputs.length&&(d=await a(r));const p=new f;p.writeInt32LE(t.version),p.write(c),p.write(l),p.writeReverse(s.prevTxId),p.writeUInt32LE(s.outputIndex),p.writeVarintNum(o.toBuffer().length),p.write(o.toBuffer()),p.writeUInt64LEBN(i),p.writeUInt32LE(s.sequenceNumber),p.write(d),p.writeUInt32LE(t.nLockTime),p.writeUInt32LE(e>>>0);const b=p.toBuffer(),y=await w(b);return new h(y).readReverse()}async function b(t){const sha256=e(43).Ur,n=await sha256(t);return r.deps.Buffer.from(n)}async function w(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,e,r,o,i,s=u.SIGHASH_ALL){s|=u.SIGHASH_FORKID;const a=new l(o),h=await p(t,s,e,r,a),f=c.sign(h,i,"little"),d=n.from(f.toDER());return n.concat([d,n.from([255&s])]).toString("hex")},Ur:b,Jr:function(t){const n=r.deps.Buffer.from(t),e=r.crypto.Hash.sha256(n);return new Uint8Array(e)}}}).call(this,e(33).Buffer)},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._,w=p.g,y=p.O,g=p.P,_=b.Object,m=w.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 w.Set)for(const o of n)t(o,e,r);if(n instanceof b.Map||n instanceof w.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||y.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,w=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 y=Object.getPrototypeOf(s);if("function"==typeof s&&y!==b.getPrototypeOf(b)&&y!==w.getPrototypeOf(w)){const n=t(y,r,o);if(y!==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),w=b._,y=b.O,g=b.P;if(f=f||w,n instanceof Creation)return n;if("function"==typeof n)throw new Error(`Cannot clone non-code function: ${i(n)}`);if(y.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))})),!y.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)),w=f.filter((t=>p[t].enumerable));if(b.length!==w.length)return!1;if(u.Zr)for(let e=0;e<b.length;e++){const r=b[e],o=w[e];if(r!==o)return!1;if(!t(n[r],i[o]))return!1}else{if(b.some((t=>!w.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),w=e(5),{ArgumentError,ClientModeError,TrustError}=e(11),{no:y}=e(15),{Ur:g}=e(12),{ao:_}=e(34),{ExecutionError}=e(11),Code=e(1),m=e(9),O=w.g,P=w._,E="Load",v=new Map;let x=[],A=0,$=null;class S{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 S,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:y},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(45),n=await t(a,h,void 0,r,o,i);return o.ho.push(n.do),n.po}}return T(t,null,y,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||y,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")},w=n.lo&&await n.lo.pull(p,b);if(w){const i=e(45),s=await i(t,w,c,n,r,o);return r.ho.push(s.do),s.po}return T(a,c,u,await k(s,null,n,new S,o),n,r,o)};return await I(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 A&&($=$||t),t}}async function j(t,n,r,i){return await I(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(45),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(v.has(s))return await v.get(s),await j(t,n,r,i);try{const t=e(35),o=t(h,s,f,n,!0,null,i,!1);r.uo.set(s,o),v.set(s,o),d=await o}finally{r.uo.delete(s),v.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 T(t,n,o,B,a,u,h){h.Pt(),s(B instanceof Code),i.tn&&i.qt(E,"Pluck",c(B),t);const y={f:a.bo.bind(a),se:t=>{$=$||t}},[_]=w.dn("async function(txid) {\n try {\n return await f(txid)\n } catch (e) {\n se(e)\n throw e\n }\n }",y);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}))),x.push(B),A++,$)throw $;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(53),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 w=d(Object.assign({_hash:p},l(s)));b((()=>{h.location=h.origin=w}));const y=`berry://${s}`;await a._o.set(y,i)}if($)throw $;return h}catch(t){throw $=$||t,t}finally{0==--A&&(x=[],$=null)}}async function I(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={reason:n.toString()};n instanceof TrustError&&(r.untrusted=n.txid),await e._o.set(`ban://${t}`,r)}catch(n){i.nn&&i.Xt(E,`Swallowing failure to cache set ban://${t}`,n.toString())}throw n}}k.Oo=S,k.Vr=function(B){const t=x.indexOf(B);if(-1===t)throw new Error("Must only create berry from its berry class");x.splice(t,1)},t.exports=k},function(t,n,e){const{q:r}=e(0);function o(t,n,e,r,o){"number"==typeof e&&(e=Array(e+1).join(" ")),"string"!=typeof e&&(e="");const i=new Set;return function t(s,a,c,u){const h=e?"\n"+new Array(u+1).join(e):"",f=e?": ":":";if(c&&"function"==typeof c.toJSON&&(c=c.toJSON()),void 0===(c=n?n.call(s,a,c):c))return;if("object"!=typeof c||null===c)return o(c);if(i.has(c))throw new TypeError("Converting circular structure to JSON");let l;if(i.add(c),Array.isArray(c)){const n=[];for(let r=0;r<c.length;r++){const i=t(c,r,c[r],u+1)||o(null);n.push(h+e+i)}l="["+n.join(",")+(n.length?h:"")+"]"}else{let n=Object.keys(c);r&&(n=n.sort(r));const i=[];for(let r=0;r<n.length;r++){const s=n[r],a=t(c,s,c[s],u+1);if(!a)continue;const l=o(s)+f+a;i.push(h+e+l)}l="{"+i.join(",")+(i.length?h:"")+"}"}return i.delete(c),l}({"":t},"",t,0)}function i(t,n){if(typeof t!=typeof n)return"symbol"==typeof t?1:-1;"symbol"==typeof t&&(t=t.toString()),"symbol"==typeof n&&(n=n.toString());const e=parseInt(t),r=parseInt(n),o=e.toString()===t,i=r.toString()===n;return o&&!i?-1:i&&!o?1:o&&i?e-r:t<n?-1:n<t?1:0}t.exports={Po:function(t){const n=(t,n)=>{if(t===n)return 0;if(void 0===t)return 1;if(void 0===n)return-1;const e=null===t?"null":t.toString(),r=null===n?"null":n.toString();return e<r?-1:e>r?1:0},e=Array.prototype.sort;Array.prototype.sort=function(t=n){const r=new Map;return this.forEach(((t,n)=>r.set(t,n))),e.call(this,((n,e)=>{const o=t(n,e);return 0!==o?o:r.get(n)-r.get(e)}))},delete String.prototype.localeCompare;const r=Object.keys;Object.keys=function(t){const n=r(t),e=Object.getOwnPropertyNames(t);return n.sort(((t,n)=>e.indexOf(t)-e.indexOf(n)))},Object.values=function(t){return Object.keys(t).map((n=>t[n]))},Object.entries=function(t){return Object.keys(t).map((n=>[n,t[n]]))};const o=Reflect.getOwnPropertyDescriptor;Reflect.getOwnPropertyDescriptor=Object.getOwnPropertyDescriptor=function(t,n){const e=o(t,n);return e&&"string"==typeof n&&t instanceof Uint8Array&&(e.configurable=!0),e};const i=Reflect.defineProperty;Reflect.defineProperty=Object.defineProperty=function(t,n,e){return e&&"string"==typeof n&&t instanceof Uint8Array&&e.writable&&e.enumerable&&e.configurable?(Reflect.set(t,n,e.value),t):i(t,n,e)};const s=JSON.stringify;JSON.stringify=(n,e,r)=>t(n,e,r,null,s);const a=Function.prototype.toString;Function.prototype.toString=function t(){if(this===Array.prototype.sort)return"function sort() { [native code ] }";if(this===Object.keys)return"function keys() { [native code ] }";if(this===Object.values)return"function values() { [native code ] }";if(this===Object.entries)return"function entries() { [native code ] }";if(this===JSON.stringify)return"function stringify() { [native code ] }";if(this===t)return"function toString() { [native code ] }";if(this===Object.getOwnPropertyDescriptor)return"function getOwnPropertyDescriptor() { [native code ] }";if(this===Reflect.getOwnPropertyDescriptor)return"function getOwnPropertyDescriptor() { [native code ] }";if(this===Object.defineProperty)return"function defineProperty() { [native code ] }";if(this===Reflect.defineProperty)return"function defineProperty() { [native code ] }";const n=a.call(this),e=n.match(/^([a-zA-Z0-9_$]+)\s*\(/);return e&&"function"!==e[1]?`function ${n}`:n}},Eo:["Date","Math","eval","XMLHttpRequest","FileReader","WebSocket","setTimeout","setInterval"],xo:o,so:(t,n,e)=>o(t,n,e,i,JSON.stringify),qr:function(t){return Object.keys(t).sort(i)},vo:i,ht:function(t,n,e){return e&&"string"==typeof n&&r(t)&&e.writable&&e.enumerable&&e.configurable?(Reflect.set(t,n,e.value),t):Reflect.defineProperty(t,n,e)}}},function(t,n,e){(function(n){const{J:r,K:o,V:i,Y:s,W:a,q:c,Z:u,tt:h}=e(0),{qr:f}=e(17),l=e(5),d=l.P,p=l.O,b=new Set(["constructor","prototype"]),w=new Set;"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split("").forEach((t=>w.add(t)));const y=(t,n)=>{throw new Error(`Cannot encode ${r(t)}\n\n${n}`)},g=(t,n)=>{throw new Error(`Cannot decode ${r(JSON.stringify(t))}\n\n${n}`)};function _(t,n,e,o,i){switch(typeof t){case"undefined":return function(t){const n=new t.Object;return n.$und=1,n}(o);case"string":case"boolean":return t;case"number":return function(t,n){if(isNaN(t)||!isFinite(t)||h(t)){const e=new n.Object;return isNaN(t)&&(e.$nan=1),t===1/0&&(e.$inf=1),t===-1/0&&(e.$ninf=1),h(t)&&(e.$n0=1),e}return t}(t,o);case"symbol":break;case"object":case"function":return m(t,n,e,o,i)}y(t,`Unsupported type ${r(typeof t)}`)}function m(t,u,h,l,w){if(!t)return null;if(h.has(t)){const n=new l.Object;return n.$dup=l.Array.from(h.get(t)),n}if(h.set(t,u),(d.has(t)||p.has(t))&&y(t,"Unsupported intrinsic"),o(t))return function(t,n,e,o,i){const s=f(t).some((t=>t.startsWith("$"))),a=new o.Object;let c=a,u=n;s&&(a.$obj=new o.Object,c=a.$obj,u=n.concat(["$obj"]));return f(t).forEach((n=>{b.has(n)&&y(t,`Reserved key: ${r(n)}`);const s=u.concat([n.toString()]);c[n]=_(t[n],s,e,o,i)})),a}(t,u,h,l,w);if(i(t))return function(t,n,e,o,i){const s=f(t);if(s.length===t.length){const r=new o.Array;return s.forEach((s=>{const a=n.concat([s.toString()]),c=_(t[s],a,e,o,i);r.push(c)})),r}{const a=new o.Object,c=new o.Object,u=n.concat(["$arr"]);return s.forEach((n=>{b.has(n)&&y(t,`Reserved key: ${r(n)}`);const s=u.concat([n.toString()]);c[n]=_(t[n],s,e,o,i)})),a.$arr=c,a}}(t,u,h,l,w);if(s(t))return function(t,n,e,o,i){const s=new o.Object;s.$set=new o.Array;let a=0;const c=n.concat(["$set"]);for(const n of t){const t=_(n,c.concat([a.toString()]),e,o,i);s.$set.push(t),a++}if(f(t).length){s.props=new o.Object;const a=n.concat(["props"]);f(t).forEach((n=>{b.has(n)&&y(t,`Reserved key: ${r(n)}`);const c=a.concat([n.toString()]);s.props[n]=_(t[n],c,e,o,i)}))}return s}(t,u,h,l,w);if(a(t))return function(t,n,e,o,i){const s=new o.Object;s.$map=new o.Array;let a=0;const c=n.concat(["$map"]);for(const[n,r]of t){const t=new o.Array;t.push(_(n,c.concat([a.toString(),"0"]),e,o,i)),t.push(_(r,c.concat([a.toString(),"1"]),e,o,i)),s.$map.push(t),a++}if(f(t).length){s.props=new o.Object;const a=n.concat(["props"]);f(t).forEach((n=>{b.has(n)&&y(t,`Reserved key: ${r(n)}`);const c=a.concat([n.toString()]);s.props[n]=_(t[n],c,e,o,i)}))}return s}(t,u,h,l,w);if(c(t))return function(t,e,r,o,i){f(t).length!==t.length&&y(t,"Uint8Arrays must not contain props");const s=new o.Object,a=n.from(new Uint8Array(t));return s.$ui8a=a.toString("base64"),s}(t,0,0,l);if(w){const Creation=e(3);if(t instanceof Creation)return function(t,n,e,r,o){const i=new r.Object;return i.$jig=o(t),i}(t,0,0,l,w);if(Object.getPrototypeOf(t).constructor instanceof Creation)return function(t,n,e,o,i){const s=new o.Object,a=Object.assign({},t),c=n.concat(["$arb"]),u=n.concat(["T"]);return Object.keys(a).forEach((n=>{b.has(n)&&y(t,`Reserved key: ${r(n)}`)})),s.$arb=_(a,c,e,o,i),s.T=_(Object.getPrototypeOf(t).constructor,u,e,o,i),s}(t,u,h,l,w)}y(t,"Unsupported object")}function O(t,n,e,o,i){switch(typeof t){case"string":case"boolean":return t;case"number":return function(t){!isNaN(t)&&isFinite(t)||g(t,`Unsupported number ${r(t)}`);return h(t)?0:t}(t);case"object":case"function":return P(t,n,e,o,i)}g(t,`Unsupported type ${r(typeof t)}`)}function P(t,e,s,a,c){if(!t)return null;if(o(t)){let h;if(Object.keys(t).forEach((n=>{n.startsWith("$")&&(h&&g(t,"Multiple $ keys"),h=n)})),"$und"===h&&1===t.$und)return;if("$n0"===h&&1===t.$n0)return-0;if("$nan"===h&&1===t.$nan)return NaN;if("$inf"===h&&1===t.$inf)return 1/0;if("$ninf"===h&&1===t.$ninf)return-1/0;if(!h)return function(t,n,e,o,i){const s=new o.Object;return e.set(t,s),f(t).forEach((a=>{b.has(a)&&g(s,`Reserved key: ${r(a)}`),s[a]=O(t[a],n,e,o,i)})),s}(t,e,s,a,c);if("$obj"===h)return function(t,n,e,i,s){const a=t.$obj;o(a)&&a||g(t,"Invalid $obj");const c=new i.Object;return e.set(t,c),f(a).forEach((t=>{b.has(t)&&g(c,`Reserved key: ${r(t)}`),c[t]=O(a[t],n,e,i,s)})),c}(t,e,s,a,c);if("$arr"===h)return function(t,n,e,i,s){o(t.$arr)&&t.$arr||g(t,"Invalid $arr");const a=new i.Array;e.set(t,a);const c=t.$arr;return f(c).forEach((t=>{b.has(t)&&g(a,`Reserved key: ${r(t)}`),a[t]=O(c[t],n,e,i,s)})),a}(t,e,s,a,c);if("$dup"===h)return function(t,n,e,r,o){const s=t.$dup;i(s)||g(t,"Invalid $dup");let a=n;for(let n=0;n<s.length;n++){const e=s[n];e in a||g(t,"Invalid dup path"),a=a[e]}e.has(a)||g(t,"Invalid dup path");const c=e.get(a);return e.set(t,c),c}(t,e,s);if("$set"===h)return function(t,n,e,s,a){i(t.$set)||g(t,"Invalid $set");u(t.props)&&!o(t.props)&&g(t,"Invalid $set props");const c=new s.Set;e.set(t,c);for(const r of t.$set)c.add(O(r,n,e,s,a));const h=t.props;h&&f(h).forEach((t=>{b.has(t)&&g(c,`Reserved key: ${r(t)}`),c[t]=O(h[t],n,e,s,a)}));return c}(t,e,s,a,c);if("$map"===h)return function(t,n,e,s,a){i(t.$map)||g(t,"Invalid $map");u(t.props)&&!o(t.props)&&g(t,"Invalid $map props");const c=new s.Map;e.set(t,c);for(const r of t.$map){i(r)&&2===r.length||g(t);const o=O(r[0],n,e,s,a),u=O(r[1],n,e,s,a);c.set(o,u)}const h=t.props;h&&f(h).forEach((t=>{b.has(t)&&g(c,`Reserved key: ${r(t)}`),c[t]=O(h[t],n,e,s,a)}));return c}(t,e,s,a,c);if("$ui8a"===h)return function(t,e,r,o,i){"string"!=typeof t.$ui8a&&g(t,"Invalid $ui8a");t.$ui8a.split("").some((t=>!w.has(t)))&&g(t,"Invalid $ui8a base64");const s=n.from(t.$ui8a,"base64"),a=new o.Uint8Array(s);return r.set(a,a),a}(t,0,s,a)}if(i(t))return function(t,n,e,r,o){const i=new r.Array;e.set(t,i);for(const s of t)i.push(O(s,n,e,r,o));return i}(t,e,s,a,c);if(c){if(o(t)&&u(t.$jig))return function(t,n,e,r,o){const i=o(t.$jig);i||g(t,"Not a jig");return e.set(t,i),i}(t,0,s,0,c);if(o(t)&&u(t.$arb)&&u(t.T))return function(t,n,e,r,i){const s=new r.Object;e.set(t,s);const a=O(t.$arb,n,e,r,i);o(a)||g(t,"Invalid $arb");Object.assign(s,a);const c=O(t.T,n,e,r,i);c||g(t,"Not code");return Object.setPrototypeOf(s,c.prototype),s}(t,e,s,a,c)}g(t,`Unsupported object ${r(t)}`)}t.exports={$o:function(t,n={}){return _(t,[],n.So||new Map,n.g||l._,n.Ao)},ko:function(t,n={}){return O(t,t,new Map,n.g||l._,n.jo)}}}).call(this,e(33).Buffer)},function(t,n,e){(function(n){const r=e(2),{TimeoutError}=e(11),{bt:o}=e(0),i="Request",s={},a={};class RequestError extends Error{constructor(t,n,e,r,o){super(`${n} ${e}\n\n${r} ${o}\n\n${t}`),this.reason=t,this.status=n,this.statusText=e,this.method=r,this.url=o,this.name=this.constructor.name}}async function c(t,n={}){const e=`${(n=Object.assign({},c.defaults,n)).method} ${t}`;const o="GET"===n.method&&n.dedup?f:(t,n,e)=>e(),d="GET"===n.method&&n.cache?l:(t,n,e,r)=>r();return await o(s,e,(async()=>await d(a,e,n.cache,(async()=>await(async t=>n.response?n.response(await t()):await t())((async()=>await h(n.retries,e,(async()=>await async function(){r.tn&&r.qt(i,e);let o=null;try{o=await u(t,n.method,n.body,n.timeout,n.headers)}catch(e){throw e.message+=`\n\n${n.method} ${t}`,e}const{data:s,status:a,statusText:c}=o;if(a>=200&&a<300)return s;const h=s&&s.message?s.message.message||s.message:s,f=s&&s.name&&h?`${s.name}: ${h}`:s&&s.name||h;throw new RequestError(f,a,c,n.method,t)}()))))))))}let u=null;async function h(t,n,e){for(let o=0;o<=t;o++)try{return await e()}catch(e){if(o===t)throw e;r.nn&&r.Xt(e.toString()),r.tn&&r.qt(i,n,`(Retry ${o+1}/${t})`)}}async function f(t,n,e){const r=t[n];if(r)return new Promise(((t,n)=>r.push({resolve:t,reject:n})));const o=t[n]=[];try{const r=await e();return o.forEach((t=>t.resolve(r))),r}catch(t){throw o.forEach((n=>n.reject(t))),t}finally{delete t[n]}}async function l(t,n,e,r){const o=Date.now();for(const n of Object.keys(t))o>t[n].expires&&delete t[n];const i=t[n];if(i&&o<i.expires){if(i.error)throw i.error;return i.result}if(!e)return await r();try{const i=await r();return t[n]={expires:o+e,result:i},i}catch(r){throw t[n]={expires:o+e,error:r},r}}u=async function(t,e,r,i,s){const{AbortController:a,fetch:c}=window;s=Object.assign({},s);const u=new a;s.accept="application/json";r&&!s["content-type"]&&(s["content-type"]="application/json",r=JSON.stringify(r));const h={method:e,body:r,headers:s,signal:u.signal};let f=!1;const l=setTimeout((()=>{f=!0,u.abort()}),o(i,"timeout"));try{const e=await c(t,h);let r=null;const o=e.headers.get("content-type");return o&&o.includes("application/json")?r=await e.json():o&&o.includes("application/octet-stream")?(r=await e.arrayBuffer(),r=n.from(r)):r=await e.text(),{data:r,status:e.status,statusText:e.statusText}}catch(t){if(f)throw new TimeoutError(`Request timed out after ${i}ms`);throw t}finally{clearTimeout(l)}},c.defaults={},c.defaults.method="GET",c.defaults.body=void 0,c.defaults.headers={},c.defaults.timeout=3e4,c.defaults.retries=2,c.defaults.dedup=!0,c.defaults.cache=0,c.Io=RequestError,c.To=h,c.Ro=f,c._o=l,t.exports=c}).call(this,e(33).Buffer)},function(t,n,e){const{rn:r,h:o}=e(4),{D:i,J:s,ct:a,ut:c,et:u,ot:h,A:f,k:l,j:d,I:p,R:b,N:w,C:y,at:g,Y:_,W:m,Z:O,q:P}=e(0),{vo:E,ht:v}=e(17),{In:x,Mn:A,Ln:$,Gn:S,Jn:k}=e(8),{Pn:j,rt:T,Qr:I}=e(14),R=e(5),N=R.g,C=R._,U=e(26),{Wn:F}=e(32),D=e(23),M=e(9),L=()=>e(10).Ft,H=()=>L().Mt;let G;let J=null;class K{constructor(t,n=new D){return i(!U.No(t)),this.Co=new U(t,this),this._e=n,this.Fo=n.Fo||this.Co,n.Fo||(this.Uo=new WeakMap),this.Co}Do(t,n,r){return this.Bo()?Reflect.apply(t,n,r):this.Mo((()=>{this.Lo();const a=this._e;a.Ho&&(n=void 0),this.Go()&&L()._read(this.Fo);let c=U.me(n),u=c&&c._e,h=!c||!u.Jo||!a.Ko;a.Vo&&h&&"function"==typeof n&&(n=M.xn(n),c=U.me(n),u=c&&c._e,h=!c||!u.Jo||!a.Ko);const Berry=e(13);n instanceof Berry&&"init"===t.name&&(h=!1);const f=c&&c._e.Yo;if(f&&f.includes(t.name))throw new Error(`${t.name} disabled`);if(a.Ko&&!c)throw new Error(`Cannot call ${t.name} on ${s(n)}`);if(h)return Reflect.apply(t,n,r);const l=!c.Wo();return L().En((()=>{H().length||(r=z(n,r)),H().length&&W(r),c.zo(t.name,"call");const a=l?o((()=>j(r,N))):r;let u=null;const h=J;try{!l&&J||(J={qo:new Set,gr:!1,Fo:n});const f=()=>{const r=function(t,n){if(!t)return n;const Creation=e(3);if(!(t instanceof Creation))return null;const r=U.No(n).name;if("function"!=typeof t[r])return null;if(t[r]===n)return n;const i=U.me(n).Fo,s=o((()=>i.origin)),a=o((()=>i.nonce)),c=U.me(t).Qo(r),u=o((()=>c.origin)),h=o((()=>c.nonce));if(u===s){if(h<a)throw new Error("Method time travel");return t[r]}const f=L().Mt;if(!(f.length>=2&&f[f.length-2]===t))return null;let l=Object.getPrototypeOf(t);for(;l;){const t=g(l,r);if(t===n)return t;const e="function"==typeof l?l:l.constructor;if(t&&o((()=>e.origin===s)))return o((()=>{if(e.nonce<a)throw new Error("Method time travel")})),t;l=Object.getPrototypeOf(l)}return null}(n,this.Co);if(!r)throw new Error(`Cannot call ${t.name} on ${s(n)}`);const i=U.No(r),h=U.me(r).Fo;this.Go()&&L()._read(h),u=Reflect.apply(i,n,a);if(u instanceof N.Promise||u instanceof C.Promise)throw new Error("async methods not supported");W(u),u=c.Xo(u,l),l&&c.Zo()},d=!c._e.ti||!c._e.ti.includes(t.name);if(e(22).ni(n,t.name,r,f,d),l){const Creation=e(3);o((()=>T(U.No(n),(t=>{if(t instanceof Creation)return!1;i(!U.No(t))}))))}return u}finally{J=h}}))}))}ei(t,n,e){return this.Bo()?Reflect.construct(t,n,e):this.Mo((()=>(this.Lo(),this.Go()&&L()._read(this.Fo),Reflect.construct(t,n,e))))}ri(t,n,e){return this.Bo()?v(t,n,e):this.Mo((()=>(this.Lo(),this.oi(n,e.value,"define"),Y(e,!0),this.ii()&&L().Ar(this.Fo),e.value=this.si(e.value),this.ai(n)&&(J.gr=!0),v(t,n,e))))}ci(t,n){return this.Bo()?Reflect.deleteProperty(t,n):this.Mo((()=>(this.Lo(),this.oi(n,void 0,"delete"),this.ii()&&L().Ar(this.Fo),Reflect.deleteProperty(t,n))))}Tt(t,n,r){return this.Bo()?Reflect.get(t,n,r):this.Mo((()=>{this.Lo();const i=n===Symbol.hasInstance&&t[Symbol.hasInstance]!==N.Function.prototype[Symbol.hasInstance]&&t[Symbol.hasInstance]!==C.Function.prototype[Symbol.hasInstance];if(this.ui(n)&&!i)return s=n,o((()=>Object.getPrototypeOf(e(1).prototype)[s]));var s;if(this.hi(n))return Reflect.get(t,n,r);const a=this.Fi(n)||this.ai(n),c=r!==this.Co;if(a&&c)return;if(this.Go()&&L()._read(this.Fo),this.fi(n))return Reflect.get(t,n,r);this.li(n,"get");let u=Reflect.get(t,n,r);if(!u)return u;const h=this.Qo(n);return h&&(u=U.me(h).di(u)),u}))}pi(t,n){return this.Bo()?Reflect.getOwnPropertyDescriptor(t,n):this.Mo((()=>{if(this.Lo(),this.hi(n))return;if(this.Go()&&L()._read(this.Fo),this.fi(n))return Reflect.getOwnPropertyDescriptor(t,n);this.li(n,"get descriptor for");const e=Reflect.getOwnPropertyDescriptor(t,n);return e?(e.value=this.di(e.value),e):e}))}bi(t){return this.Bo()?Reflect.getPrototypeOf(t):this.Mo((()=>(this.Lo(),this.Go()&&L()._read(this.Fo),Reflect.getPrototypeOf(t))))}Ht(t,n){return this.Bo()?Reflect.has(t,n):this.Mo((()=>(this.Lo(),this.Go()&&L()._read(this.Fo),!!this.yi(n)||(this.zo(n,"check"),this.wi(n,"check"),Reflect.has(t,n)))))}gi(t){return this.Bo()?Reflect.isExtensible(t):this.Mo((()=>(this.Lo(),!0)))}_i(t){return this.Bo()?Reflect.ownKeys(t):this.Mo((()=>{this.Lo(),this.Go()&&L()._read(this.Fo);let n=Reflect.ownKeys(t);return n=n.sort(E),n=n.filter((t=>this.mi(t))),n}))}Oi(t){return this.Bo()?Reflect.preventExtensions(t):this.Mo((()=>{throw this.Lo(),new Error("preventExtensions disabled")}))}Pi(t,n,e,r){return this.Bo()?(c(t,n,e),!0):this.Mo((()=>(this.Lo(),r!==this.Co?(c(r,n,e),!0):(this.oi(n,e,"set"),this.ii()&&L().Ar(this.Fo),e=this.si(e),this.ai(n)&&(J.gr=!0),o((()=>c(t,n,e))),!0))))}Ei(t,n){return this.Bo()?Reflect.setPrototypeOf(t,n):this.Mo((()=>{throw this.Lo(),new Error("setPrototypeOf disabled")}))}xi(){if(!this.Bo())return this.Mo((()=>{this.Lo(),this.Go()&&L()._read(this.Fo)}))}vi(t){return this.Bo()?t:this.Mo((()=>(this.Lo(),this.di(t))))}$i(t){return this.Bo()?t:this.Mo((()=>(this.Lo(),W(t),t=this.si(t))))}Si(){if(!this.Bo())return this.Mo((()=>{this.Lo(),this.Go()&&L()._read(this.Fo)}))}Ai(){if(!this.Bo())return this.Mo((()=>{this.Lo(),this.ii()&&L().Ar(this.Fo),this.ki("update",s(this.Fo))}))}Mo(t){const n=L();try{const e=t();if(n.Zt)throw n.Zt;return e}catch(t){throw n.Mt.length&&!n.Zt&&(n.Zt=t),t}}Lo(){const t=U.No(this.Fo);if(!a(t,"location"))return;const{Zt:n,Un:e}=x(t.location);if(n&&!e)throw new Error(n)}oi(t,n,e){if("__proto__"===t)throw new Error(`${e} __proto__ disabled`);if("symbol"==typeof t)throw new Error(`Cannot ${e} symbol property`);if(this.yi(t))throw new Error(`Cannot ${e} ${t}: reserved`);this.ji(t,n,e),this.Ii(t,n,e),this.Ti(t,n,e),this.wi(t,e),this.zo(t,e),this.ki(e,t),W(n)}ki(t,n){if(this._e.Wr)throw new Error(`Cannot ${t} ${n}: immutable`);if(this.Ri(),L().Ye.Ht(this.Fo))throw new Error(`Cannot ${t} ${n}: unbound`)}li(t,n){this.Ni(t),this.Ci(t),this.zo(t,n),this.wi(t,n)}fi(t){return"function"==typeof this.Co&&"prototype"===t||("constructor"===t||"symbol"==typeof t)}Ni(t){if(this.Fi(t))try{const n=U.No(this.Co);if("location"===t||"origin"===t||"nonce"===t){const e=Reflect.get(n,t),r=x("nonce"===t?n.location:e);if(O(r.Un))throw new Error("Hint: Sync the jig to deploy it");if(O(r.Zt))throw new Error(`A previous error occurred\n\n${r.Zt}`);if(O(r.Ct))return;if(!O(r.Rn))throw new Error("Hint: Sync the jig to assign it in a transaction");if(O(r.Fn)&&!O(r._hash))throw new Error}}catch(n){throw new Error(`Cannot read ${t}${n.message?"\n\n"+n.message:""}`)}}Ci(t){if(this.ai(t))try{const n=U.No(this.Co);if("owner"===t||"satoshis"===t){const e=Reflect.get(n,t);if(void 0===e)throw new Error("Hint: Sync the jig to bind it in a transaction");const r=!0;"owner"===t&&A(e,r);const o=!0;"satoshis"===t&&$(e,o)}}catch(n){throw new Error(`Cannot read ${t}\n\n${n.message}`)}}Ii(t,n,e){if(this.Fi(t))throw new Error(`Cannot ${e} ${t}`)}Ti(t,n,e){if(!this.ai(t))return;if("delete"===e)throw new Error(`Cannot ${e} ${t}`);if(this.Ui())throw new Error(`Cannot ${e} ${t}`);"owner"===t&&A(n,!1),"satoshis"===t&&$(n)}ji(t,n,e){this._e.Di&&("sealed"===t&&"delete"!==e&&M.Fe(n),"upgradable"===t&&"delete"!==e&&M.Ue(n),"interactive"===t&&"delete"!==e&&M.De(n))}wi(t,n){if(!this._e.Bi)return;const e=()=>{const e=`Cannot ${n} ${"symbol"==typeof t?t.toString():t}: reserved`;throw new Error(e)};f.includes(t)&&e(),this._e.Mi&&d.includes(t)&&e(),this._e.Di&&l.includes(t)&&e(),this._e.Li&&p.includes(t)&&e()}zo(t,n){const e="call"===n,r=e?"method":"property";if(!this.mi(t,e))throw new Error(`Cannot ${n} private ${r} ${t}`)}mi(t,n=!1){if(!this._e.Hi)return!0;if("string"!=typeof t||!t.startsWith("_"))return!0;if("__proto__"===t)return!0;const Jig=e(7),Berry=e(13),r=H();if(!r.length)return!n;const o=r[r.length-1];return"function"==typeof this.Fo?o===this.Fo||o.constructor===this.Fo:(i(this.Fo instanceof Jig||this.Fo instanceof Berry),o.constructor===this.Fo.constructor||o===this.Fo.constructor)}Ri(){if(this._e.Gi&&!this.Wo())throw new Error(`Attempt to update ${s(this.Fo)} outside of a method`)}di(t){if(V(t))return t;return t instanceof e(3)||this.Ji(t)?t:this.Ki(t)}Xo(t,n,e=new Set){if(V(t))return t;if(e.has(t))return t;if(U.No(t))return t;const r=this.Ji(t);if(!r){e.add(t);const r=t=>this.Xo(t,n,e);return o((()=>function(t,n){if(Object.keys(t).forEach((e=>{c(t,e,n(t[e]))})),_(t)){const e=Array.from(t.values());t.clear(),e.forEach((e=>t.add(n(e))))}if(m(t)){const e=Array.from(t.entries());t.clear(),e.forEach((([e,r])=>t.set(n(e),n(r))))}}(t,r))),t}return!n&&r?t:this.Ki(t)}Ki(t){if(V(t))return t;if(U.No(t))return t;const n=this.Vi();if(n.has(t))return n.get(t);const e="function"==typeof t,r=D.Ae(this.Fo,e),o=new K(t,r);return n.set(t,o),o}si(t){if(V(t))return t;if(t instanceof e(3))return t;const n=U.me(t),r=U.No(t)||t;return n?n._e.Fo===this.Fo?r:j(n.Co,N):(H().length&&J.qo&&J.qo.add(r),r)}Qo(t){let n=this.Fo,r=this.Co;for(;!a(r,t);){r=Object.getPrototypeOf(r),i(r),n="object"==typeof r?r.constructor:r;n instanceof e(3)||(n=null),n&&this.Go()&&U.me(n).Go()&&L()._read(n)}return n}Zo(){i(J),I(J.qo,((t,n)=>{if(!h(t))throw new Error(`Not serializable: ${s(t)}`);if(V(t))return;if(t instanceof e(3))return void n(!1);!function(t){o((()=>{if(Object.getOwnPropertySymbols(t).length)throw new Error("Symbol properties not supported");const n=[];(t instanceof N.Array||t instanceof C.Array)&&n.push("length");const e=!P(t);Object.getOwnPropertyNames(t).filter((t=>!n.includes(t))).map((n=>Object.getOwnPropertyDescriptor(t,n))).forEach((t=>Y(t,e)))}))}(t);const r=U.me(t);if(!r)return void n(!0);const i=U.No(t);return n(!1),r._e.Fo===this.Fo?i:j(r.Co,N)})),this.Ui()&&(J.gr=!0),J.gr&&L().gr(this.Fo)}Ji(t){if(!J)return!1;if(U.No(t))return!1;const n=L().Mt;if(!(n.length&&n[n.length-1]===this.Fo))return!1;if(J.qo.has(t))return!0;let e=!1;return T(J.qo,(n=>!e&&(!U.No(n)&&(n===t?(e=!0,!1):void 0)))),e&&J.qo.add(t),e}Bo(){return this._e.rn&&r()}ui(t){return this._e.Di&&function(){if(!G){const t=o((()=>Object.getPrototypeOf(e(1).prototype)));G=Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}return G}().includes(t)}yi(t){return this.Yi(t)||this.Wi(t)||this.zi(t)}Yi(t){return this._e.Di&&b.includes(t)}Wi(t){return this._e.Mi&&w.includes(t)}zi(t){return this._e.Li&&y.includes(t)}hi(t){return this.Yi(t)&&l.includes(t)||this.Wi(t)&&d.includes(t)||this.zi(t)&&p.includes(t)}Go(){return this._e.qi&&H().length}ii(){return this._e.Qi&&H().length}Fi(t){return this._e.Xi&&S.includes(t)}ai(t){return this._e.Zi&&k.includes(t)}Wo(){const t=H();return t.length&&t[t.length-1]===this.Fo}Vi(){return U.me(this.Fo).Uo}Ui(){const t=U.No(this.Fo);return null===t.owner&&0===t.satoshis}jr(){return J&&J.Fo===this.Fo&&J.gr}}function V(t){return["undefined","boolean","number","string","symbol"].includes(typeof t)||null===t}function Y(t,n=!0){if(!("value"in t))throw new Error("Descriptor must have a value");if("get"in t)throw new Error("Getters are not supported");if("set"in t)throw new Error("Getters are not supported");if(n&&!t.configurable)throw new Error("Descriptor must be configurable");if(!t.writable)throw new Error("Descriptor must be writable");if(!t.enumerable)throw new Error("Descriptor must be enumerable")}function W(t){if(!u(t))throw new Error(`Not serializable: ${s(t)}`)}function z(t,n){const Code=e(1);t instanceof Code&&M.Tt(t).vn();const Creation=e(3),r=j(n,N,(t=>{if("function"==typeof t&&!(t instanceof Creation)){const n=M.xn(t);return M.Tt(n).vn(),n}t instanceof Code&&M.Tt(t).vn()}));return F([t,r],[t]),r}K.ts=z,t.exports=K},function(t,n,e){const r=e(6),o=e(16),{D:i,J:s,M:a,yt:c,Z:u}=e(0),{so:h}=e(17),{Ur:f}=e(12),{Pn:l,rt:d}=e(14),p=e(2),b=e(18),{Mr:w}=e(12),{In:y,Mn:g}=e(8),{h:_}=e(4),m=e(52),O=e(5).ns,{oo:P}=e(15),E=e(9),v=e(10),x=e(25),{Transaction:A,Script:$}=r,S="Publish",k=new m,j=new m;async function T(t){try{p.Ut&&p.Dt(S,"Publish",t.Tn.Me);const n=new Date,e=t.er,o=t.Tn;t.es()||t.rs(!0);const i=new c("publish",e._t);await R(t),i.Pt();const a=await N(t);i.Pt(),await I(t,i),i.Pt(),C(t);const u=U(o),h=await F(t,i);i.Pt();const f=await M(t,h),l=L(o,u),d=H(t,f,l,u),b=r.Transaction.FEE_PER_KB,w=G(t,d,a,b);await J(e,o,h,d,w,i),i.Pt();const y=await j.os((async()=>{const n=await V(w,t,b);i.Pt();let r=null;try{r=await q(n,t,b),i.Pt(),Q(r,o,w)}catch(t){try{await z(n,e.ss)}catch(t){p.en&&p.Zt(S,t)}throw t}let a=null;try{a=await X(t,r,i)}catch(t){try{await z(n,e.ss)}catch(t){p.en&&p.Zt(S,t)}throw t}if("string"!=typeof a||64!==a.length)throw new Error(`Invalid txid: ${s(a)}`);return i.Pt(),a}));i.Pt(),K(t,y),await tt(t,h,y),i.Pt();(d.exec.some((t=>"DEPLOY"===t.op))||d.exec.some((t=>"UPGRADE"===t.op)))&&e.fo.add(y),t.cs(),p.Ut&&p.Dt(S,"Publish (end): "+(new Date-n)+"ms")}catch(n){t.us(n)}}async function I(t,n){const e=await t.hs(),r=t.Tn;for(const t of r.qe){const n=r.Xe.get(t);if(!(n.wr.origin in e))continue;const o=e[n.wr.origin][1];if(n.wr.nonce<o)throw new Error(`Time travel for ${s(t)}`)}}async function R(t){const Creation=e(3),n=t.Tn;async function r(){const e=[];for(let r=0;r<n.Gt._r;r++){const o=n.Gt.Or()[r],i=void 0===t.fs.get(o).wr.owner&&await t.er.Mn.nextOwner();e.push(i)}return e}function o(n){d(n,(n=>{if(n instanceof Creation)return t.Tn._read(n),!1}))}p.Ut&&p.Dt(S,"Assign owners"),await k.os((async()=>{const e=await r(),i=[],s=v.Ft;try{v.Ft=t.Tn,t.Tn.Ze=!1;for(const t of e){if(!t){i.push(t);continue}const n=l(t,O,(t=>{if("function"!=typeof t)return;const n=E.xn(t);return E.Tt(n).vn(),n}));i.push(n)}}finally{v.Ft=s}o(i),t.ls(),i.forEach(((e,r)=>{if(!e)return;const o=n.Gt.Or()[r];t.fs.get(o).wr.owner=e}));const a=await r(),c=[];for(const t of a){if(!t){c.push(t);continue}const n=l(t,O,(t=>{if("function"!=typeof t)return;return E.xn(t)}));c.push(n)}c.forEach(((e,r)=>{if(!e)return;const o=n.Gt.Or()[r];t.fs.get(o).wr.owner=e})),o(c),t.Tn.hr()})),await t.ds()}async function N(t){const n=a(t.er.re.network),e=[],r=v.Ft;try{v.Ft=t.Tn,t.Tn.ze.dr((r=>{try{t.Tn.ar(r);const o=t.fs.get(r).wr.owner,i=g(o,false,n).script();e.push(i)}finally{t.Tn.cr()}})),t.Tn.hr()}finally{v.Ft=r}return await t.ds(),e}function C(t){const n=t.Tn;n.ze.dr((n=>{const e=t.fs.get(n).wr;e.satoshis=e.satoshis||0,_((()=>{u(n.owner)||(n.owner=e.owner),u(n.satoshis)||(n.satoshis=e.satoshis)}))})),n.Ke.dr((t=>{_((()=>{i(null===t.owner),i(0===t.satoshis)}))}))}function U(t){const n=new x;for(const e of t.We)n.br(e);for(const e of t.qe)n.br(e);for(const e of t.Gt)n.br(e);return n.Or()}async function F(t,n){if(t.ps)return t.ps;const{bs:r}=e(53),o=new Map,i=t.Tn,s=[],a=new Map,c=new Map;i.ze.dr(((t,n)=>{s.push(t),a.set(t,n)})),i.Ke.dr(((t,n)=>{s.push(t),c.set(t,n)}));for(const e of s){const i=await r(e,t,a,c,n);o.set(e,i)}return t.ps=o,o}async function D(t){const n=h(t),e=r.deps.Buffer.from(n,"utf8");return(await f(e)).toString("hex")}async function M(t,n){if(t.ys)return t.ys;const e=new Map,r=[];for(const[t,o]of n){if(e.has(t))continue;const n=await D(o).then((n=>e.set(t,n)));r.push(n)}return await Promise.all(r),t.ys=e,e}function L(t,n){const e={Ao:t=>{const e=n.indexOf(t);return i(e>=0),e}};return t.He.map((t=>({op:t.op(),data:b.$o(t.data(),e)})))}function H(t,n,e,r){const o=t.Tn,s=o.ze.Or().map((t=>n.get(t))),a=o.Ke.Or().map((t=>n.get(t))),c={Ao:t=>{const n=r.indexOf(t);return i(n>=0),n}},u=o.Gt.Or().map((n=>t.fs.get(n).wr.owner)).map((t=>b.$o(t,c))),h=o.qe.Or().map((t=>o.Xe.get(t).wr.location)),f={app:t.ws,version:t.jn,base:t.gs.toString("hex"),vrun:t.gs.outputs.length,in:o.We._r,ref:h,out:s,del:a,cre:u,exec:e};return p.Ut&&p.Dt(S,"Metadata",JSON.stringify(f,0,2)),f}function G(t,n,e,o){p.Ut&&p.Dt(S,"Create partial tx");const i=new A(t.gs.toString("hex")),s=r.deps.Buffer,c=s.from("run","utf8"),u=P(n.version),h=s.from(u,"hex"),f=s.from(n.app,"utf8"),l=Object.assign({},n);delete l.app,delete l.version,delete l.vrun,delete l.base;const d=s.from(JSON.stringify(l),"utf8"),b=$.buildSafeDataOut([c,h,f,d]),_=new A.Output({script:b,satoshis:0});i.addOutput(_);const m=a(t.er.re.network),O=t.Tn;return O.We.dr((t=>{const n=O.Xe.get(t),e=n.wr.location,{Rn:r,Nn:o}=y(e),s=n.wr.satoshis,a=n.wr.owner,c=g(a,false,m).script(),u={txid:r,vout:o,script:$.fromHex(c),satoshis:s};i.from(u)})),O.ze.dr(((n,r)=>{const s=t.fs.get(n),a=e[r].length/2,c=Math.max(s.wr.satoshis,w(a,o)),u=$.fromHex(e[r]);i.addOutput(new A.Output({script:u,satoshis:c})),r++})),i}async function J(t,n,r,o,i,s){if(t._s){p.tn&&p.qt(S,"Preverify");const a=new Date;try{const a=e(35),{Os:c}=a,u="0000000000000000000000000000000000000000000000000000000000000000",h=!1,f=null,l=new c(n,r);await a(i,u,o,t,h,f,s,l)}catch(t){throw p.en&&p.Zt(S,t),new Error(`Pre-verification failed: ${t.message}`)}p.Ut&&p.Dt(S,"Preverify (end): "+(new Date-a)+"ms")}}function K(t,n){const Code=e(1),r=t.Tn;r.ze.dr(((e,r)=>{const o=t.gs.outputs.length+1+r,i=t.fs.get(e),s=`${n}_o${o}`;i.wr.origin.startsWith("record://")&&(i.wr.origin=s),i.wr.location=s,_((()=>{e.origin.startsWith("record://")&&(e.origin=s),t.Ps(e)||(e.location=s)})),e instanceof Code&&E.Tt(e).de(i.wr)})),r.Ke.dr(((e,r)=>{const o=t.fs.get(e),i=`${n}_d${r}`;o.wr.origin.startsWith("record://")&&(o.wr.origin=i),o.wr.location=i,_((()=>{e.origin.startsWith("record://")&&(e.origin=i),e.location=i})),e instanceof Code&&E.Tt(e).de(o.wr)}))}async function V(t,n,e){const o=r.deps.Buffer,i=Y(n.Tn),s=await W(t,n.er),a=i.map((t=>o.alloc(t.domain()))),c=[...Array(i.length).keys()].filter((n=>!t.inputs[n].script.toBuffer().length));c.forEach((n=>t.inputs[n].setScript(a[n])));const u=t.toString("hex"),h=await n.er.ss.pay(u,s);let f=null;try{if("string"!=typeof h)throw new Error;f=new A(h)}catch(t){throw new Error(`Invalid raw transaction returned by purse: ${h}`)}if(t.version!==f.version||t.nLockTime!==f.nLockTime||t.inputs.length>f.inputs.length||t.inputs.some(((t,n)=>f.inputs[n].prevTxId.toString("hex")!==t.prevTxId.toString("hex")))||t.inputs.some(((t,n)=>f.inputs[n].outputIndex!==t.outputIndex))||t.inputs.some(((t,n)=>f.inputs[n].sequenceNumber!==t.sequenceNumber))||t.outputs.length>f.outputs.length||t.outputs.some(((t,n)=>f.outputs[n].script.toHex()!==t.script.toHex()))||t.outputs.some(((t,n)=>f.outputs[n].satoshis!==t.satoshis)))throw new Error("Purse illegally modified tx during payment");return c.forEach((t=>f.inputs[t].setScript(""))),f}function Y(t){return t.We.Or().map((n=>t.Xe.get(n))).map((t=>t.wr.owner)).map((t=>g(t)))}async function W(t,n){const e=t.inputs,o=e.map((t=>t.prevTxId.toString("hex"))),i=(await Promise.all(o.map((t=>n.bo(t))))).map((t=>new r.Transaction(t))),s=e.map(((t,n)=>i[n].outputs[t.outputIndex])),a=s.map((t=>t.script.toHex())),c=s.map((t=>t.satoshis));return a.map(((t,n)=>({script:t,satoshis:c[n]})))}async function z(t,n){p.tn&&p.qt(S,"Cancelling payment"),"function"==typeof n.cancel&&await n.cancel(t.toString("hex"))}async function q(t,n,e){const r=Y(n.Tn),o=await W(t,n.er),i=t.toString("hex"),s=await n.er.Mn.sign(i,o,r);let a=null;try{if("string"!=typeof s)throw new Error;a=new A(s)}catch(t){throw new Error(`Invalid raw transaction returned by owner: ${s}`)}if(t.version!==a.version||t.nLockTime!==a.nLockTime||t.inputs.length>a.inputs.length||t.inputs.some(((t,n)=>a.inputs[n].prevTxId.toString("hex")!==t.prevTxId.toString("hex")))||t.inputs.some(((t,n)=>a.inputs[n].outputIndex!==t.outputIndex))||t.inputs.some(((t,n)=>a.inputs[n].sequenceNumber!==t.sequenceNumber))||t.outputs.length>a.outputs.length||t.outputs.some(((t,n)=>a.outputs[n].script.toHex()!==t.script.toHex()))||t.outputs.some(((t,n)=>a.outputs[n].satoshis!==t.satoshis)))throw new Error("Owner illegally modified tx during payment");return a}function Q(t,n,e){n.We.dr(((e,r)=>{if(t.inputs[r].isFullySigned())return;const o=n.Xe.get(e),i=`${`origin: ${o.wr.origin}`}\n${`location: ${o.wr.location}`}\n${`owner: ${o.wr.owner}`}`,a=t.inputs[r].script.toBuffer().length?"Bad signature":"Missing signature";throw new Error(`${a} for ${s(e)}\n\n${i}`)}));for(let n=0;n<e.inputs.length;n++)if(e.inputs[n].prevTxId.toString("hex")!==t.inputs[n].prevTxId.toString("hex")||e.inputs[n].outputIndex!==t.inputs[n].outputIndex)throw new Error(`Transaction input ${n} changed`);for(let n=0;n<e.outputs.length;n++)if(e.outputs[n].script.toHex()!==t.outputs[n].script.toHex())throw new Error(`Transaction output ${n} changed`)}async function X(t,n,e){let r=null;if("function"==typeof t.er.ss.broadcast)try{await t.er.ss.broadcast(n.toString("hex"))}catch(r){throw await Z(r,t,n,e)}try{r=await t.er.re.broadcast(n.toString("hex"))}catch(r){throw await Z(r,t,n,e)}return"function"==typeof t.er.lo.broadcast&&await t.er.lo.broadcast(n.toString("hex")),r}async function Z(t,n,r,i){const s=t.toString();let a=`Broadcast failed: ${t.message}`;if(-1!==s.indexOf("tx has no inputs")||-1!==s.indexOf("insufficient priority")){a=`${a}\n\n${"Hint: Is the purse funded to pay for this transaction?"}`}if(-1!==s.indexOf("Missing inputs")||-1!==s.indexOf("txn-mempool-conflict"))for(const s of r.inputs)try{const r=s.prevTxId.toString("hex"),c=s.outputIndex,u=`${r}_o${c}`,h=await n.er.Es(r,c);if(!h)continue;let f="Payment";try{const t=await o(u,void 0,n.er,void 0,i);f=t instanceof e(1)?t.name:t.toString()}catch(t){}a=`${a}\n\n${f} was spent in another transaction\n`,a=`${a}\nLocation: ${u}`,a=`${a}\nSpending Tx: ${h}`}catch(t){}return new Error(a)}async function tt(t,n,e){const r=[],o=t.Tn;o.ze.dr(((o,s)=>{const a=n.get(o);i(a);const c=t.gs.outputs.length+1+s,u=`jig://${e}_o${c}`;r.push(t.er._o.set(u,a))})),o.Ke.dr(((o,s)=>{const a=n.get(o);i(a);const c=`jig://${e}_d${s}`;r.push(t.er._o.set(c,a))})),await Promise.all(r)}T.xs=I,T.vs=R,T.$s=N,T.Ss=C,T.As=U,T.ks=F,T.js=M,T.Is=L,T.Ts=H,T.Rs=G,T._s=J,T.Ns=j,T.Cs=V,T.Fs=z,T.Us=q,T.Ds=Q,T.Bs=X,T.Ms=K,T.Ls=tt,t.exports=T},function(t,n,e){const{ts:r}=e(20),{Kn:o,In:i}=e(8),{D:s,J:a,L:c,ct:u,Z:h}=e(0),{rt:f,Pn:l}=e(14),{NotImplementedError}=e(11),{h:d}=e(4),p=e(2),b=e(26),w="Action";class y{constructor(t){this.Fo=t}toString(){return`${this.constructor.name}`}op(){throw new NotImplementedError}data(){throw new NotImplementedError}}class g extends y{constructor(){super(null),this.Hs=[],this.Gs=[]}toString(){return`Deploy (count: ${this.Hs.length})`}op(){return"DEPLOY"}data(){s(this.Hs.length===this.Gs.length);const t=[];for(let n=0;n<this.Hs.length;n++){const e=this.Hs[n],r=this.Gs[n];t.push(e),t.push(r)}return t}}class _ extends y{constructor(t,n,e){super(t),this.Nt=n,this.wr=e}toString(){return`Upgrade ${a(this.Fo)}`}op(){return"UPGRADE"}data(){const t=[];return t.push(this.Fo),t.push(this.Nt),t.push(this.wr),t}}class m extends y{constructor(t,n,e){super(t),this.gt=n,this.Js=e}toString(){return`Call ${a(this.Fo)} ${this.gt}`}op(){return"CALL"}data(){const t=[];return t.push(this.Fo),t.push(this.gt),t.push(this.Js),t}}class O extends y{constructor(t,n,e){super(n),this.Ks=t,this.Js=e}toString(){return`New ${a(this.Fo)}`}op(){return"NEW"}data(){const t=[];return t.push(this.Ks),t.push(this.Js),t}}function P(t,n){const r=e(9),o=e(10).Ft,i=c(t);if(!i)return;P(i,n);if(r.Tt(i).Ct)return;const s=u(i,"sealed")?i.sealed:"owner";switch(s){case"owner":o.Gt.Ht(i)||o.Jt(i);break;case!0:throw new Error(`Cannot ${n}: ${a(i)} is sealed`);case!1:break;default:throw new Error(`Invalid sealed option: ${s}`)}}function E(t){const Creation=e(3),n=e(10).Ft;d((()=>f(t,(t=>{if(t instanceof Creation)return n._read(t),!1}))))}t.exports={xt:y,Vs:g,Ys:_,Ws:m,zs:O,vn:function(t){const Code=e(1),n=e(10).Ft;s(t.length),s(t.every((t=>t instanceof Code))),p.Ut&&p.Dt(w,"Deploy",t.map((t=>a(t))).join(", ")),n.En((()=>{t.forEach((t=>n.Pr(t))),t.forEach((t=>P(t,"deploy"))),t.forEach((t=>n.gr(t)));const e=new g;for(const n of t){const t=n.toString(),r=d((()=>l(Object.assign({},n))));E(r),o.forEach((t=>delete r[t])),s(!r.presets),e.Hs.push(t),e.Gs.push(r)}n.ur(e)}))},ke:function(t,n){const Code=e(1),r=e(10).Ft;if(s(t instanceof Code),p.Ut&&p.Dt(w,"Upgrade",a(t)),h(i(d((()=>t.location))).Cn))throw new Error("Cannot upgrade destroyed jig");r.En((()=>{P(t,"upgrade");const e=t.toString(),i=d((()=>l(Object.assign({},t))));E(i),o.forEach((t=>delete i[t])),s(!i.presets);const a=new _(t,e,i);r.Ar(t,n),r.ur(a)}))},Kt:function(t){const n=e(10),Code=e(1),Jig=e(7),r=n.Ft;s(t instanceof Code||t instanceof Jig),p.tn&&p.qt(w,"Destroy",a(t)),h(i(d((()=>t.location))).Cn)||r.En((()=>{r.yr(t);if(!r.Mt.length){const n=new m(t,"destroy",[]);r.ur(n)}}))},Jt:function(t){const n=e(10).Ft,Code=e(1),Jig=e(7);if(s(t instanceof Code||t instanceof Jig),p.tn&&p.qt(w,"Auth",a(t)),h(i(d((()=>t.location))).Cn))throw new Error("Cannot auth destroyed jigs");n.En((()=>{n.Jt(t);if(!n.Mt.length){const e=new m(t,"auth",[]);n.ur(e)}}))},ni:function(t,n,r,o,i=!0){const s=e(10).Ft;p.tn&&p.qt(w,"Call",a(t),n),s.En((()=>{E(r),s.ar(t),o(),s.cr();if(!s.Mt.length&&i){const e=new m(t,n,r);s.ur(e)}}))},kn:function(t,n,o,i){const Jig=e(7),s=e(10).Ft;p.tn&&p.qt(w,"New",a(t)),s.En((()=>{let e=t;for(;e!==Jig;)s._read(e),e=Object.getPrototypeOf(e);const a=r(n,o);E(a),s.Pr(n);if(void 0!==n.init(...a))throw new Error("init must not return a value");i&&s.gr(n),b.me(n)._e.Yo.push("init");if(!s.Mt.length){const e=new O(t,n,a);s.ur(e)}}))},zr:function(t,n,o){const Berry=e(13),i=e(10).Ft;if(p.tn&&p.qt(w,"Pluck",a(t)),i.Ze=!1,i.En((()=>{let e=t;for(;e!==Berry;)i._read(e),e=Object.getPrototypeOf(e);const s=r(n,o);E(s);if(void 0!==n.init(...s))throw new Error("init must not return a value");b.me(n)._e.Yo.push("init")})),i.He.length)throw new Error("Not actions allowed during pluck");i.je()}}},function(t,n,e){const{D:r}=e(0),o=e(26),{no:i}=e(15);class s{constructor(){this.Fo=void 0,this.rn=!0,this.Xi=!1,this.Zi=!1,this.Bi=!1,this.Di=!1,this.Mi=!1,this.Li=!1,this.Hi=!1,this.Wr=!1,this.qi=!1,this.Qi=!1,this.Ko=!1,this.Jo=!1,this.Gi=!1,this.Ho=!1,this.ti=[],this.Yo=[],this.Vo=!1,this.jn=i}static we(){const t=new s;return t.Fo=void 0,t.rn=!0,t.Xi=!0,t.Zi=!0,t.Bi=!0,t.Di=!0,t.Mi=!1,t.Li=!1,t.Hi=!0,t.Wr=!1,t.qi=!0,t.Qi=!0,t.Ko=!0,t.Jo=!0,t.Gi=!0,t.Ho=!1,t.Yo=[],t.ti=[],t.Vo=!0,t}static ge(t){const n=new s;return n.Fo=void 0,n.rn=!0,n.Xi=!0,n.Zi=!0,n.Bi=!0,n.Di=!0,n.Mi=!1,n.Li=!1,n.Hi=!1,n.Wr=!0,n.qi=!0,n.Qi=!1,n.Ko=!1,n.Jo=!1,n.Gi=!1,n.Ho=!t,n.Yo=[],n.ti=[],n.Vo=!1,n}static Oe(){const t=new s;return t.Fo=void 0,t.rn=!0,t.Xi=!0,t.Zi=!0,t.Bi=!1,t.Di=!0,t.Mi=!1,t.Li=!1,t.Hi=!1,t.Wr=!0,t.qi=!1,t.Qi=!1,t.Ko=!1,t.Jo=!1,t.Gi=!0,t.Ho=!1,t.Yo=[],t.ti=[],t.Vo=!1,t}static Sn(t){const n=new s;return n.Fo=void 0,n.rn=!0,n.Xi=!0,n.Zi=!0,n.Bi=!0,n.Di=!1,n.Mi=!0,n.Li=!1,n.Hi=!0,n.Wr=!1,n.qi=!0,n.Qi=!0,n.Ko=!0,n.Jo=!0,n.Gi=!0,n.Ho=!1,n.Yo=t?["init"]:[],n.ti=["init"],n.Vo=!1,n}static Yr(t){const n=new s;return n.Fo=void 0,n.rn=!0,n.Xi=!0,n.Zi=!0,n.Bi=!0,n.Di=!1,n.Mi=!1,n.Li=!0,n.Hi=!1,n.Wr=!0,n.qi=!0,n.Qi=!1,n.Ko=!1,n.Jo=!1,n.Gi=!1,n.Ho=!1,n.Yo=t?["init"]:[],n.ti=["init"],n.Vo=!1,n}static Ae(t,n){const e=o.me(t);r(e);const i=e._e,a=new s;return a.Fo=t,a.rn=i.rn,a.Xi=!1,a.Zi=!1,a.Bi=!1,a.Di=!1,a.Mi=!1,a.Li=!1,a.Hi=i.Hi,a.Wr=i.Wr||n,a.qi=i.qi,a.Qi=i.Qi,a.Ko=i.Ko,a.Jo=!1,a.Gi=i.Gi,a.Ho=i.Ho,a.Yo=[],a.ti=[],a.Vo=i.Vo,a}}t.exports=s},function(t,n,e){(function(n){const r=/^\s*function\s+[a-zA-Z0-9$_]+\s*\(.*?{(.*)}\s*$/s,o=/^\s*class\s+[a-zA-Z0-9$_]+\s*{(.*)}\s*$/s,i=/^\s*class\s+[a-zA-Z0-9$_]+\s+extends\s+[a-zA-Z0-9$_]+\s*{(.*)}\s*$/s,s=/^(function\s+)([a-zA-Z0-9$_]+)(\s*)\((.*)$/s,a=/^(class\s+)([a-zA-Z0-9$_]+)(\s*){(.*)$/s,c=/^(class\s+)([a-zA-Z0-9$_]+)(\s*)extends(.*)$/s,u=/^\s*class\s+[a-zA-Z0-9_$]+\s+extends\s+[a-zA-Z0-9_.$]+\s*{/s,h=/^([a-zA-Z0-9_$]+)\s*\(/s,f=/(cov_[a-zA-Z0-9]+\(\).[a-zA-Z0-9\[\]]+\+\+,?)/g;t.exports={fn:function(t,n){const e=Object.getPrototypeOf(n);if(e.prototype)return t.replace(u,`class ${n.name} extends ${e.name} {`);const r=t.match(h);return r&&"function"!==r[1]?`function ${t}`:t},ln:function(t){const n=t.match(s);if(n)return`${n[1]}${n[3]}(${n[4]}`;const e=t.match(a);if(e)return`${e[1]}${e[3]}{${e[4]}`;const r=t.match(c);if(r)return`${r[1]}${r[3]}extends${r[4]}`;throw new Error(`Bad source code: ${t}`)},le:function(t,n){if(e(5).sn.includes(n))return t;const r=t.match(/^(function\s)(.*)/s);if(r)return`${r[1]}${n}${r[2]}`;const o=t.match(/^(class\s)(.*)/s);if(o)return`${o[1]}${n}${o[2]}`;throw new Error(`Bad source code: ${t}`)},hn:function(t){return n.env.COVER?t.replace(f,""):t},Pt:function(t){const n=t.match(r)||t.match(o)||t.match(i);if(!n)throw new Error(`Bad source code: ${t}`);let e=n[1];const s=(t,n,e)=>t.split(n).join(e);e=s(e,/\/\/.*?([\n\r])/s,"\n"),e=s(e,/\/\*.*?\*\//s,""),e=s(e,/(?:`(?:(?:\\`)|[^`])*?`)|(?:"(?:(?:\\")|[^"])*?")|(?:'(?:(?:\\')|[^'])*?')/s,"''");let a=0;for(let n=0;n<e.length;n++)if("{"===e[n]&&a++,"}"===e[n]&&a--,a<0)throw new Error(`Multiple definitions not permitted: ${t}`)}}}).call(this,e(30))},function(t,n,e){const{h:r}=e(4),{D:o,J:i}=e(0);class s{constructor(){this.qs=new Set,this.Qs=new Map,this.Xs=null}br(t){if(this.qs.has(t))return;const Creation=e(3);o(t instanceof Creation);const n=r((()=>t.origin));if(n.startsWith("error://")||n.startsWith("record://"))return this.qs.add(t),void(this.Xs=null);const s=this.Qs.get(n);if(s){const n=r((()=>t.location)),e=r((()=>s.location));if(n!==e){const r=`${i(t)}: ${n}`,o=`${i(s)}: ${e}`;throw new Error(`Inconsistent worldview\n\n${r}\n${o}`)}}else this.qs.add(t),this.Qs.set(n,t),this.Xs=null}yr(t){if(this.qs.has(t)){const n=r((()=>t.origin));this.Qs.delete(n),this.qs.delete(t),this.Xs=null}const Creation=e(3);o(t instanceof Creation);const n=r((()=>t.origin));if(n.startsWith("error://")||n.startsWith("record://"))return;const s=this.Qs.get(n);if(!s)return;const a=r((()=>t.location)),c=r((()=>s.location));if(a!==c){const n=`${i(t)}: ${a}`,e=`${i(s)}: ${c}`;throw new Error(`Inconsistent worldview\n\n${n}\n${e}`)}this.qs.delete(s),this.Qs.delete(n),this.Xs=null}Ht(t){if(this.qs.has(t))return!0;const Creation=e(3);if(!(t instanceof Creation))return!1;const n=r((()=>t.origin));if(n.startsWith("error://")||n.startsWith("record://"))return!1;const o=this.Qs.get(n);if(!o)return!1;const s=r((()=>t.location)),a=r((()=>o.location));if(s!==a){const n=`${i(t)}: ${s}`,e=`${i(o)}: ${a}`;throw new Error(`Inconsistent worldview\n\n${n}\n${e}`)}return!0}Tt(t){if(this.qs.has(t))return t;const Creation=e(3);if(!(t instanceof Creation))return;const n=r((()=>t.origin));if(n.startsWith("error://")||n.startsWith("record://"))return;const o=this.Qs.get(n);if(!o)return;const s=r((()=>t.location)),a=r((()=>o.location));if(s!==a){const n=`${i(t)}: ${s}`,e=`${i(o)}: ${a}`;throw new Error(`Inconsistent worldview\n\n${n}\n${e}`)}return o}dr(t){let n=0;for(const e of this.qs)t(e,n++)}Or(){return this.Xs=this.Xs||Array.from(this.qs),this.Xs}get _r(){return this.qs.size}[Symbol.iterator](){return this.qs[Symbol.iterator]()}static $e(t,n){const Creation=e(3);if(!(t instanceof Creation))return!1;if(!(n instanceof Creation))return!1;if(t===n)return!0;const{In:o}=e(8);return r((()=>{if(o(t.origin).Zt)return!1;if(o(n.origin).Zt)return!1;if(t.origin!==n.origin)return!1;if(t.location!==n.location){const e=`${i(t)}: ${t.location}`,r=`${i(n)}: ${n.location}`;throw new Error(`Inconsistent worldview\n\n${e}\n${r}`)}return!0}))}}t.exports=s},function(t,n,e){const{Y:r,W:o,q:i,lt:s,dt:a,D:c}=e(0),u=e(5),h=u.g,f=new WeakMap,l=new WeakMap,d=new WeakMap,p=new WeakMap,b=s(Set.prototype),w=s(Map.prototype),y=s(Uint8Array.prototype).concat(s(Object.getPrototypeOf(Uint8Array.prototype))),g=a(Set.prototype),_=a(Map.prototype),m=a(Uint8Array.prototype).concat(a(Object.getPrototypeOf(Uint8Array.prototype))),O=["add","clear","copyWithin","delete","fill","reverse","set","sort"],P=["entries","every","filter","find","findIndex","forEach","get","has","includes","indexOf","join","keys","lastIndexOf","map","reduce","reduceRight","slice","some","subarray","toLocaleString","toString","values",Symbol.iterator];class E{constructor(t,n){const e=new h.Proxy(t,this);return f.set(e,t),l.set(t,n),l.set(e,n),d.set(e,this),this.Zs=n,this.ta=t,this.na=r(t),this.ea=o(t),this.ra=i(t),e}apply(t,n,e){return this.Zs.Do?this.Zs.Do(this.ta,n,e):Reflect.apply(this.ta,n,e)}construct(t,n,e){return this.Zs.ei?this.Zs.ei(this.ta,n,e):Reflect.construct(this.ta,n,e)}defineProperty(t,n,e){return this.Zs.ri?this.Zs.ri(this.ta,n,e):Reflect.defineProperty(this.ta,n,e)}deleteProperty(t,n){return this.Zs.ci?this.Zs.ci(this.ta,n):Reflect.deleteProperty(this.ta,n)}getOwnPropertyDescriptor(t,n){return this.Zs.pi?this.Zs.pi(this.ta,n):Reflect.getOwnPropertyDescriptor(this.ta,n)}getPrototypeOf(t){return this.Zs.bi?this.Zs.bi(this.ta):Reflect.getPrototypeOf(this.ta)}has(t,n){return this.Zs.Ht?this.Zs.Ht(this.ta,n):Reflect.has(this.ta,n)}isExtensible(t){return this.Zs.gi?this.Zs.gi(this.ta):Reflect.isExtensible(this.ta)}ownKeys(t){return this.Zs._i?this.Zs._i(this.ta):Reflect.ownKeys(this.ta)}preventExtensions(t){return this.Zs.Oi?this.Zs.Oi(this.ta):Reflect.preventExtensions(this.ta)}set(t,n,e,r){return this.Zs.Pi?this.Zs.Pi(this.ta,n,e,r):Reflect.set(this.ta,n,e,r)}setPrototypeOf(t,n){return this.Zs.Ei?this.Zs.Ei(this.ta,n):Reflect.setPrototypeOf(this.ta,n)}get(t,n,e){if(this.na&&b.includes(n)||this.ea&&w.includes(n)||this.ra&&y.includes(n))return this.Zs.xi&&this.Zs.xi(),Reflect.get(this.ta,n,this.ta);if(this.na&&g.includes(n)||this.ea&&_.includes(n)||this.ra&&m.includes(n)){const t=Reflect.get(this.ta,n,e);if(this.Zs.xi&&this.Zs.xi(),p.has(t))return p.get(t);const r=new v(this.na,this.ea,this.ra,n),o=new Proxy(t,r);return p.set(t,o),o}return this.Zs.Tt?this.Zs.Tt(this.ta,n,e):Reflect.get(this.ta,n,e)}static me(t){return l.get(t)}static No(t){return f.get(t)}static oa(t,n){const e=f.get(t),r=l.get(t),o=d.get(t);c(e),o.ta=n,l.delete(e),l.set(n,r),f.set(t,n)}}class v{constructor(t,n,e,r){this.na=t,this.ea=n,this.q=e,this.ia=r,this._read=P.includes(r),this.Ar=O.includes(r),this.sa=t&&["add"].includes(r)||n&&["set"].includes(r)||e&&["copyWithin","fill","reverse","sort"].includes(r),this.aa=t&&["entries","values",Symbol.iterator].includes(r)||n&&["entries","keys","values",Symbol.iterator].includes(r),this.ca=this.aa&&"entries"===r,this.ua=n&&"get"===r,this.ha=t&&["add","delete","has"].includes(r)||n&&["delete","get","has","set"].includes(r),this.fa=n&&"set"===r,this.la=t&&"forEach"===r||n&&"forEach"===r}apply(t,n,e){const r=E.me(n);r&&(r.Si&&this._read&&r.Si(),r.Ai&&this.Ar&&r.Ai()),this.la&&(e[0]=t=>r&&r.vi&&t?r.vi(t):t),this.ha&&e[0]&&r&&r.$i&&(e[0]=r.$i(e[0])),this.fa&&e[1]&&r&&r.$i&&(e[1]=r.$i(e[1]));const o=E.No(n)||n,i=Reflect.apply(t,o,e);return this.sa?n:this.ua?r&&r.vi&&i?r.vi(i):i:this.aa?new A(i,r,this.ca):i}}class x{constructor(t,n,e){this.da=t,this.Zs=n,this.pa=e}next(){const t=this.da.next(),n={};if(n.done=t.done,n.value=t.value,this.Zs&&this.Zs.vi)if(this.pa&&n.value){const t=n.value[0]?this.Zs.vi(n.value[0]):n.value[0],e=n.value[1]?this.Zs.vi(n.value[1]):n.value[1];n.value=[t,e]}else n.value=n.value?this.Zs.vi(n.value):n.value;return n}[Symbol.iterator](){return this}}const A=u.un(x,{},!0,!1)[0];t.exports=E},function(t,n,e){const r=e(6),o=e(10),i=e(35),s=e(2),{D:a,J:c,yt:u,F:h}=e(0),{ao:f}=e(34),{ArgumentError}=e(11),l="Transaction";class d{constructor(){this.Tn=new o,this.Tn.tr=!1,this.Tn.Ze=!1,this.gs=new r.Transaction,this.sr=null,this.ba=null,this.Rn=null,this.ya=null,this.wa=null,this.ga=null,this._a=null,this.ma=null,this.Oa=null,this.Fr=!1,this.Pa=!1}set base(t){const n=new r.Transaction(t);if(n.inputs.length)throw new Error("Only custom outputs are supported in base transactions");this.gs=n}get base(){return this.gs.toString("hex")}get outputs(){return[...this.Tn.ze]}get deletes(){return[...this.Tn.Ke]}update(t){if("function"!=typeof t)throw new ArgumentError("Invalid callback");if(s.tn&&s.qt(l,"Update"),d.Bt)throw new Error("update disabled during atomic update");if(this._a)throw new Error("update disabled during export");if(this.ma)throw new Error("update disabled during publish");if(this.wa)throw new Error("update disabled during pay");if(this.ga)throw new Error("update disabled during sign");if(this.ya)throw new Error("update disabled during build");if(this.Oa)throw new Error("update disabled during cache");if(this.Fr)throw new Error("update disabled once published");if(this.Pa)throw new Error("update disabled once cached");this.sr=null,this.ba=null,this.Rn=null;const n=o.Ft;try{o.Ft=this.Tn,o.Ft.rr();let e=null;try{d.Bt=!0,e=t()}finally{d.Bt=!1}if(e instanceof Promise)throw new Error("async transactions not supported");return o.Ft.ir(),e}catch(t){throw this.rollback(),t}finally{o.Ft=n}}pay(){if(d.Bt)throw new Error("pay disabled during atomic update");if(this.ga)throw new Error("pay disabled during sign");if(this._a)throw new Error("pay disabled during export");if(this.ma)throw new Error("pay disabled during publish");if(this.wa)return this.wa;if(this.ya)throw new Error("pay disabled during build");if(this.Oa)throw new Error("pay disabled during cache");if(this.Fr)throw new Error("pay disabled once published");if(this.Pa)throw new Error("pay disabled once cached");const t=h(),n=new u("pay",t._t),o=async()=>{const{Ns:t,Cs:o}=e(21);await t.os((async()=>{const t=r.Transaction.FEE_PER_KB;this.ba=await o(this.ba,this.sr,t),this.Rn=null,n.Pt()}))};return this.wa=this.Ea(n,!1).then((()=>o())),this.wa.then((()=>{this.wa=null})).catch((t=>{throw this.wa=null,t})),this.wa}sign(){if(d.Bt)throw new Error("sign disabled during atomic update");if(this.wa)throw new Error("sign disabled during pay");if(this._a)throw new Error("sign disabled during export");if(this.ma)throw new Error("sign disabled during publish");if(this.ga)return this.ga;if(this.ya)throw new Error("sign disabled during build");if(this.Oa)throw new Error("sign disabled during cache");if(this.Fr)throw new Error("sign disabled once published");if(this.Pa)throw new Error("sign disabled once cached");const t=h(),n=new u("sign",t._t),o=async()=>{const{Ns:t,Us:o}=e(21);await t.os((async()=>{const t=r.Transaction.FEE_PER_KB;this.ba=await o(this.ba,this.sr,t),this.Rn=null,n.Pt()}))};return this.ga=this.Ea(n,!1).then((()=>o())),this.ga.then((()=>{this.ga=null})).catch((t=>{throw this.ga=null,t})),this.ga}cache(){s.tn&&s.qt(l,"Cache");const t=new Date;if(d.Bt)throw new Error("cache disabled during atomic update");if(this.wa)throw new Error("cache disabled during pay");if(this.ga)throw new Error("cache disabled during sign");if(this._a)throw new Error("cache disabled during export");if(this.ma)throw new Error("cache disabled during publish");if(this.ya)throw new Error("cache disabled during build");if(this.Oa)return this.Oa;if(this.Pa)return!0;const n=h(),r=new u("cache",n._t),o=async()=>{const{Ls:t,Ms:n}=e(21);this.Rn=this.Rn||this.ba.hash,await t(this.sr,this.sr.ps,this.Rn),r.Pt(),n(this.sr,this.Rn)};this.Oa=this.Ea(r,!1).then((()=>o()));return this.Oa.then((()=>{s.Ut&&s.Dt(l,"Cache (end): "+(new Date-t)+"ms"),this.Pa=!0,this.Oa=null})).catch((t=>{throw this.Oa=null,t})),this.Oa}publish(t={}){s.tn&&s.qt(l,"Publish");const n=new Date;if(d.Bt)throw new Error("publish disabled during atomic update");if(this.wa)throw new Error("publish disabled during pay");if(this.ga)throw new Error("publish disabled during sign");if(this._a)throw new Error("publish disabled during export");if(this.ma)return this.ma;if(this.Fr)return!0;if(this.ya)throw new Error("publish disabled during build");if(this.Oa)throw new Error("publish disabled during cache");if(void 0!==t.pay&&"boolean"!=typeof t.pay)throw new ArgumentError(`Invalid pay: ${c(t.pay)}`);if(void 0!==t.sign&&"boolean"!=typeof t.sign)throw new ArgumentError(`Invalid sign: ${c(t.sign)}`);const e=void 0===t.pay||t.pay,r=void 0===t.sign||t.sign;if(this.Pa&&e)throw new Error("pay disabled once cached");if(this.Pa&&r)throw new Error("sign disabled once cached");const o=h(),i=new u("publish",o._t);this.ma=this.Ea(i,!0).then((()=>this.xa(e,r,i)));return this.ma=this.ma.then((()=>{s.Ut&&s.Dt(l,"Publish (end): "+(new Date-n)+"ms"),this.Fr=!0,this.ma=null})).catch((t=>{throw this.ma=null,t})),this.ma=this.ma.then((()=>this.Rn)),this.ma}export(t={}){s.tn&&s.qt(l,"Export");const n=new Date;if(d.Bt)throw new Error("export disabled during atomic update");if(this.wa)throw new Error("export disabled during pay");if(this.ga)throw new Error("export disabled during sign");if(this.ma)throw new Error("export disabled during publish");if(this.Oa)throw new Error("export disabled during cache");if(this._a)return this._a;if(void 0!==t.pay&&"boolean"!=typeof t.pay)throw new ArgumentError(`Invalid pay: ${c(t.pay)}`);if(void 0!==t.sign&&"boolean"!=typeof t.sign)throw new ArgumentError(`Invalid sign: ${c(t.sign)}`);const e=void 0===t.pay||t.pay,r=void 0===t.sign||t.sign;if(this.Pa&&e)throw new Error("pay disabled once cached");if(this.Pa&&r)throw new Error("sign disabled once cached");if(this.Fr&&e)throw new Error("pay disabled once published");if(this.Fr&&r)throw new Error("sign disabled once published");const o=h(),i=new u("export",o._t);this._a=this.Ea(i,!1).then((()=>this.va(e,r,i)));return this._a.then((t=>(s.Ut&&s.Dt(l,"Export (end): "+(new Date-n)+"ms"),this._a=null,t))).catch((t=>{throw this._a=null,t})),this._a}rollback(){if(s.tn&&s.qt(l,"Rollback"),d.Bt)throw new Error("rollback disabled during atomic update");if(this._a)throw new Error("rollback disabled during export");if(this.ma)throw new Error("rollback disabled during publish");if(this.wa)throw new Error("rollback disabled during pay");if(this.ga)throw new Error("rollback disabled during sign");if(this.ya)throw new Error("rollback disabled during build");if(this.Oa)throw new Error("rollback disabled during cache");if(this.Fr)throw new Error("rollback disabled once published");this.Tn.je(),this.Tn=new o,this.Tn.tr=!1,this.Tn.Ze=!1}static async $a(t,n,e){s.tn&&s.qt(l,"Replay");const r=f(t),o=await i(t,n,r,e,!1,null,undefined,!1),a=new d;return a.Tn=o.Tn,a.sr=o,a.ba=t,a.Rn=n,a}Ea(t,n){if(this.sr&&this.ba)return n&&this.sr.rs(!0),Promise.resolve();if(a(!this.sr&&!this.ba),this.ya)return this.ya;const e=this.Tn.sr();if(!e)throw new Error("Nothing to commit");return e.gs=this.gs,n&&e.rs(!0),this.ya=this.Sa(e,t),this.ya.then((t=>(this.ya=null,t))).catch((t=>{throw this.ya=null,t})),this.ya}async Sa(t,n){try{await t.ds();const o=t.Tn;a(!o.Qe.length);const{xs:i,vs:s,$s:c,Ss:u,As:h,ks:f,js:l,Is:d,Ts:p,Rs:b,_s:w}=e(21);await s(t),n.Pt();const y=await c(t);n.Pt(),await i(t,n),n.Pt(),u(t);const g=h(o),_=await f(t,n);n.Pt();const m=await l(t,_),O=p(t,m,d(o,g),g),P=b(t,O,y,r.Transaction.FEE_PER_KB);await w(t.er,o,_,O,P,n),n.Pt(),this.sr=t,this.ba=P,this.Rn=null}catch(n){throw t.es()&&t.us(n),n}}async xa(t,n,o){const{ks:i,Ns:a,Cs:u,Fs:h,Us:f,Ds:d,Bs:p,Ms:b,Ls:w}=e(21);this.sr.es()||this.sr.rs(!0);try{const e=this.sr.Tn,y=await i(this.sr,o);o.Pt(),this.Rn=await a.os((async()=>{const i=this.ba,a=r.Transaction.FEE_PER_KB,b=t?await u(i,this.sr,a):i;o.Pt();let w=null;try{w=n?await f(b,this.sr,a):b,o.Pt(),d(w,e,i)}catch(t){try{await h(b,this.sr.er.ss)}catch(t){s.en&&s.Zt(l,t)}throw t}let y=null;try{y=await p(this.sr,w,o)}catch(t){try{await h(b,this.sr.er.ss)}catch(t){s.en&&s.Zt(l,t)}throw t}if("string"!=typeof y||64!==y.length)throw new Error(`Invalid txid: ${c(y)}`);return o.Pt(),y})),o.Pt(),b(this.sr,this.Rn),await w(this.sr,y,this.Rn),o.Pt();(e.He.some((t=>"DEPLOY"===t.op()))||e.He.some((t=>"UPGRADE"===t.op())))&&this.sr.er.fo.add(this.Rn),this.sr.cs()}catch(t){throw this.sr.us(t),t}}async va(t,n,o){const{Ns:i,Cs:a,Fs:c,Us:u}=e(21),h=await i.os((async()=>{const e=this.ba,i=r.Transaction.FEE_PER_KB,h=t?await a(e,this.sr,i):e;o.Pt();let f=null;try{f=n?await u(h,this.sr,i):h,o.Pt()}catch(t){try{await c(h,this.sr.er.ss)}catch(t){s.en&&s.Zt(l,t)}throw t}return f}));return o.Pt(),h.toString("hex")}}d.Bt=!1,t.exports=d},function(t,n,e){(function(n){function e(t,n){const e=3&t.length,r=t.length-e;let o=n;const i=3432918353,s=461845907;let a=0,c=0,u=0;for(;a<r;)u=255&t.charCodeAt(a)|(255&t.charCodeAt(++a))<<8|(255&t.charCodeAt(++a))<<16|(255&t.charCodeAt(++a))<<24,++a,u=(65535&u)*i+(((u>>>16)*i&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(65535&u)*s+(((u>>>16)*s&65535)<<16)&4294967295,o^=u,o=o<<13|o>>>19,c=5*(65535&o)+((5*(o>>>16)&65535)<<16)&4294967295,o=27492+(65535&c)+((58964+(c>>>16)&65535)<<16);switch(u=0,e){case 3:u^=(255&t.charCodeAt(a+2))<<16;case 2:u^=(255&t.charCodeAt(a+1))<<8;case 1:u^=255&t.charCodeAt(a),u=(65535&u)*i+(((u>>>16)*i&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(65535&u)*s+(((u>>>16)*s&65535)<<16)&4294967295,o^=u}return o^=t.length,o^=o>>>16,o=2246822507*(65535&o)+((2246822507*(o>>>16)&65535)<<16)&4294967295,o^=o>>>13,o=3266489909*(65535&o)+((3266489909*(o>>>16)&65535)<<16)&4294967295,o^=o>>>16,o>>>0}t.exports={create:function(t=960,n=7){if("number"!=typeof t||!Number.isInteger(t)||t<=0)throw new Error("invalid size: "+t);if(t%8!=0)throw new Error("size must be a multiple of 8: "+t);if("number"!=typeof n||!Number.isInteger(n)||n<=0)throw new Error("invalid numHashes: "+n);return{buckets:new Array(t).fill(0),numHashes:n}},add:function(t,n){if("string"!=typeof n)throw new Error("invalid key: "+n);if(!this.possiblyHas(t,n))for(let r=1;r<=t.numHashes;r++){const o=e(n,r)%t.buckets.length;t.buckets[o]++}},remove:function(t,n){if("string"!=typeof n)throw new Error("invalid key: "+n);const r=[];for(let o=1;o<=t.numHashes;o++){const i=e(n,o)%t.buckets.length;if(!t.buckets[i])return!1;r.push(i)}return r.forEach((n=>t.buckets[n]--)),!0},possiblyHas:function(t,n){for(let r=1;r<=t.numHashes;r++){const o=e(n,r)%t.buckets.length;if(!t.buckets[o])return!1}return!0},toBase64:function(t){const e=t.buckets,r=new Array(1+e.length/8);r[0]=t.numHashes;for(let t=0,n=1;t<e.length;t+=8,n++)r[n]=(e[t+0]>0)<<7|(e[t+1]>0)<<6|(e[t+2]>0)<<5|(e[t+3]>0)<<4|(e[t+4]>0)<<3|(e[t+5]>0)<<2|(e[t+6]>0)<<1|(e[t+7]>0)<<0;return n.from(r).toString("base64")},fromBase64:function(t){const e=n.from(t,"base64"),r=e[0],o=new Array(8*(e.length-1));for(let t=1,n=0;t<e.length;t++,n+=8)o[n+0]=e[t]>>7&1,o[n+1]=e[t]>>6&1,o[n+2]=e[t]>>5&1,o[n+3]=e[t]>>4&1,o[n+4]=e[t]>>3&1,o[n+5]=e[t]>>2&1,o[n+6]=e[t]>>1&1,o[n+7]=e[t]>>0&1;return{numHashes:r,buckets:o}}}}).call(this,e(33).Buffer)},function(t,n,e){(function(n){const r=e(6);function o(){return n&&n.version}function i(){return"undefined"!=typeof window&&window.document&&window.navigator}function s(){if("string"!=typeof r.version||!r.version.startsWith("v1.")){throw new Error(`Run requires version 1.x of the bsv library\n\n${"Hint: Please install bsv version 1.5.4 or install the Run SDK from NPM"}`)}}function a(){if(!o())return;const t=Number(n.version.match(/^v(\d+\.\d+)/)[1]);if(t<10)throw new Error("Run is supported only on Node 10 and above");if(t>=17)throw new Error("Run is supported only on Node 16 and below")}function c(){if(!i())return;const t=window.navigator.userAgent;if(-1!==t.indexOf("MSIE")||-1!==t.indexOf("Trident"))throw new Error("Run is not supported on Internet Explorer. Please upgrade to Edge.");if(/iP(hone|od|ad)/.test(navigator.platform)){var n=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);if([parseInt(n[1],10),parseInt(n[2],10),parseInt(n[3]||0,10)][0]<13)throw new Error("Run is not supported on this iOS version. Please upgrade to iOS 13 or above.")}}t.exports={ka:o,Aa:i,Pt:function(){s(),a(),c()},Sc:s,Ac:a,kc:c}}).call(this,e(30))},function(t,n){var e,r,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(t){if(e===setTimeout)return setTimeout(t,0);if((e===i||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(n){try{return e.call(null,t,0)}catch(n){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:i}catch(t){e=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(t){r=s}}();var c,u=[],h=!1,f=-1;function l(){h&&c&&(h=!1,c.length?u=c.concat(u):f=-1,u.length&&d())}function d(){if(!h){var t=a(l);h=!0;for(var n=u.length;n;){for(c=u,u=[];++f<n;)c&&c[f].run();f=-1,n=u.length}c=null,h=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(n){try{return r.call(null,t)}catch(n){return r.call(this,t)}}}(t)}}function p(t,n){this.fun=t,this.array=n}function b(){}o.nextTick=function(t){var n=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)n[e-1]=arguments[e];u.push(new p(t,n)),1!==u.length||h||a(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=b,o.addListener=b,o.once=b,o.off=b,o.removeListener=b,o.removeAllListeners=b,o.emit=b,o.prependListener=b,o.prependOnceListener=b,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(t,n,e){const r=e(6),{PrivateKey:o,PublicKey:i,Address:s}=r,a=e(43),{Blockchain:c,Cache:u,Lock:h,Logger:f,Owner:l,Purse:d,State:p}=e(55),Jig=e(7),Berry=e(13),Code=e(1),b=e(9),w=e(37),y=e(16),Creation=e(3),CommonLock=e(44),g=e(27),{Wn:_}=e(32),m=e(5),O=e(2),{J:P,bt:E}=e(0),{Aa:v,ka:x}=e(29),A=e(19),{ArgumentError}=e(11),{ao:$,ja:S}=e(34),BrowserCache=e(69),DiskCache=e(70),k=e(56),Inventory=e(71),LocalCache=e(39),LocalOwner=e(57),LocalPurse=e(74),LocalState=e(75),Mockchain=e(76),NodeCache=e(77),PayServer=e(78),RunConnect=e(62),RunDB=e(79),StateServer=e(80),Viewer=e(81),WhatsOnChain=e(82),BlockchainWrapper=e(41),CacheWrapper=e(38),OwnerWrapper=e(46),PurseWrapper=e(49),StateWrapper=e(40),j="Run";class T{constructor(t={}){O.tn&&O.qt(j,"Create"),U(t),U(T.defaults);const n=Object.keys(t);this.Ia=F(t.api,n.includes("api"),t.blockchain||T.defaults.blockchain,t.network||T.defaults.network),this.Ta=D(t.apiKey,n.includes("apiKey")),this.Ra=L(t.autofund,n.includes("autofund")),this.Dt=V(t.debug,n.includes("debug")),this.zt=W(t.logger,n.includes("logger")),this.Na=q(t.networkRetries,n.includes("networkRetries")),this.Ca=Q(t.networkTimeout,n.includes("networkTimeout"));const e=z(t.network,n.includes("network")),r=it(t.wallet,n.includes("wallet"));this.er=new a,this.er.Hn=H(t.backingLimit,n.includes("backingLimit")),this.er.yo=K(t.client,n.includes("client")),this.er._o=J(t.cache,n.includes("cache"),e),this.er.re=G(t.blockchain,n.includes("blockchain"),this.Ia,this.Ta,e),this.er.lo=et(t.state,n.includes("state"),e,this.Ia,this.Ta),this.er.ss=tt(t.purse,n.includes("purse"),this.er.re,r),this.er.ws=M(t.app,n.includes("app")),this.er.Mn=X(t.owner,n.includes("owner"),this.er.re,r),this.er._t=rt(t.timeout,n.includes("timeout")),this.er.fo=ot(t.trust,n.includes("trust")),this.er._s=Z(t.preverify,n.includes("preverify")),this.er.Ir=nt(t.rollbacks,n.includes("rollbacks")),C(this),this.Fa=Y(t.inventory,n.includes("inventory")),N(this),this.activate()}get api(){return this.Ia}get apiKey(){return this.Ta}get app(){return this.er.ws}get autofund(){return this.Ra}get backingLimit(){return this.er.Hn}get blockchain(){return this.er.re}get cache(){return this.er._o}get client(){return this.er.yo}get debug(){return this.Dt}get inventory(){return this.Fa}get logger(){return this.zt}get network(){return this.blockchain.network}get networkRetries(){return this.Na}get networkTimeout(){return this.Ca}get owner(){return this.er.Mn}get preverify(){return this.er._s}get purse(){return this.er.ss}get rollbacks(){return this.er.Ir}get timeout(){return this.er._t}get state(){return this.er.lo}get wallet(){return this.er.ss===this.er.Mn?this.er.ss:void 0}set api(t){t=F(t,!0),this.er.re=G(void 0,!1,t,this.Ta,this.network),this.er.lo=et(void 0,!1,this.blockchain.network,t,this.Ta),C(this),this.Ia=t}set apiKey(t){t=D(t,!0),this.er.re=G(void 0,!1,this.Ia,t,this.network),this.er.lo=et(void 0,!1,this.blockchain.network,this.Ia,t),C(this),this.Ta=t}set app(t){this.er.ws=M(t,!0)}set autofund(t){this.Ra=L(t,!0),N(this)}set backingLimit(t){t=H(t,!0),this.er.Hn=t}set blockchain(t){this.er.re=G(t,!0),this.Ia=void 0,this.Ta=void 0,this.er.ss instanceof LocalPurse&&(this.er.ss.blockchain=this.er.re),C(this),N(this)}set cache(t){this.er._o=J(t,!0,this.network),C(this)}set client(t){this.er.yo=K(t,!0)}set debug(t){this.Dt=V(t,!0),at(this)}set inventory(t){this.Fa&&this.Fa.detach(this),this.Fa=Y(t,!0),this.Fa&&this.Fa.attach(this)}set logger(t){this.zt=W(t,!0),at(this)}set network(t){z(t,!0),this.er.re=G(void 0,!1,this.Ia,this.Ta,t),this.er.lo=et(void 0,!1,t,this.Ia,this.Ta),C(this)}set networkRetries(t){this.Na=q(t,!0),I(this)&&(A.defaults.retries=this.Na)}set networkTimeout(t){this.Ca=Q(t,!0),I(this)&&(A.defaults.timeout=this.Ca)}set owner(t){const n=X(t,!0,this.er.re,null);n!==this.er.Mn&&(this.er.Mn=n,C(this),this.Fa&&this.Fa.detach(this),this.Fa=new Inventory,this.Fa.attach(this))}set preverify(t){this.er._s=Z(t,!0)}set purse(t){this.er.ss=tt(t,!0,this.blockchain,null),C(this)}set rollbacks(t){this.er.Ir=nt(t,!0)}set state(t){this.er.lo=et(t,!0,this.network,this.api,this.apiKey),C(this)}set timeout(t){this.er._t=rt(t,!0)}set wallet(t){it(t,!0),this.purse=t,this.owner=t}load(t,n={}){if(R(this),g.Bt)throw new Error("load disabled during atomic update");return n.trust&&this.trust(t.slice(0,64)),y(t,void 0,this.er)}sync(){if(g.Bt)throw new Error("sync all disabled during atomic update");return w.Ua()}deploy(t){R(this);const n=ct(t);return b.Tt(n).vn(),n}transaction(t){R(this);const n=new g,e=n.update(t);return n.publish(),e}import(t,n={}){if(g.Bt)throw new Error("import disabled during atomic update");const e=new r.Transaction(t),o=n.txid||e.hash;return n.trust&&this.trust(o),g.$a(e,o,this.er)}trust(t){if(t instanceof Array)t.forEach((t=>this.trust(t)));else{if(O.tn&&O.qt(j,"Trust",t),!st(t))throw new ArgumentError(`Not trustable: ${P(t)}`);"cache"===t&&(t="state"),this.er.fo.add(t)}}on(t,n){if(!a.Da.includes(t))throw new ArgumentError(`Invalid event: ${P(t)}`);if("function"!=typeof n)throw new ArgumentError(`Invalid listener: ${P(E)}`);this.er.Ba.some((e=>e.Ma===t&&e.La===n))||this.er.Ba.push({Ma:t,La:n})}off(t,n){if(!a.Da.includes(t))throw new ArgumentError(`Invalid event: ${P(t)}`);if("function"!=typeof n)throw new ArgumentError(`Invalid listener: ${P(n)}`);this.er.Ba=this.er.Ba.filter((e=>!(e=>e.Ma===t&&e.La===n)(e)))}activate(){if(O.tn&&O.qt(j,"Activate"),g.Bt)throw new Error("activate disabled during atomic update");return T.instance=this,this.Fa&&this.Fa.attach(this),this.er.Re(),this.logger=this.zt,this.debug=this.Dt,this.networkRetries=this.Na,this.networkTimeout=this.Ca,this}deactivate(){if(O.tn&&O.qt(j,"Deactivate"),g.Bt)throw new Error("deactivate disabled during atomic update");return T.instance=null,this.Fa&&this.Fa.detach(this),this.er.Te(),this}}function I(t){return a.U===t.er}function R(t){if(a.U!==t.er){throw new Error(`This Run instance is not active\n\n${"Hint: Call run.activate() on this instance first"}`)}}function N(t){t.blockchain instanceof Mockchain&&t.purse instanceof LocalPurse&&t.autofund&&t.blockchain.fund(t.purse.bsvAddress,1e10)}function C(t){t.er.re instanceof BlockchainWrapper&&(t.er.re.cache=t.er._o),t.er.lo instanceof StateWrapper&&(t.er.lo.cache=t.er._o),t.er.ss instanceof PurseWrapper&&(t.er.ss.blockchain=t.er.re)}function U(t){if(t.blockchain&&void 0!==t.api&&t.blockchain.api!==t.api)throw new Error(`Blockchain mismatch with "${t.api}" api`);if(t.blockchain&&void 0!==t.apiKey&&t.blockchain.apiKey!==t.apiKey)throw new Error(`Blockchain mismatch with "${t.apiKey}" apiKey`);if(t.blockchain&&void 0!==t.network&&t.blockchain.network!==t.network)throw new Error(`Blockchain mismatch with "${t.network}" network`)}function F(t,n,e,r){if("run"===t||"whatsonchain"===t)return t;if("mattercloud"===t)throw new Error("MatterCloud API is no longer supported");if(void 0!==t||n)throw new Error(`Invalid api: ${P(t)}`);if("string"==typeof T.defaults.api)return F(T.defaults.api,!0,void 0,r);if(void 0===e){if("main"===r||"test"===r)return"run";if("stn"===r)return"whatsonchain"}}function D(t,n){if("string"==typeof t)return t;if(void 0===t&&!n)return T.defaults.apiKey;throw new Error(`Invalid apiKey: ${P(t)}`)}function M(t,n){if("string"==typeof t)return t;if(void 0===t&&!n)return M(T.defaults.app,!0);throw new Error(`Invalid app: ${P(t)}`)}function L(t,n){if("boolean"==typeof t)return t;if(void 0===t&&!n)return L(T.defaults.autofund,!0);throw new Error(`Invalid autofund: ${P(t)}`)}function H(t,n){if(t>=0)return t;if(void 0===t&&!n)return H(T.defaults.backingLimit,!0);throw new Error(`Invalid backingLimit: ${P(t)}`)}function G(t,n,e,r,o,i){if(t instanceof c)return t;const s=a.U&&a.U.re;if(void 0===t&&!n)switch(o){case"mock":if(void 0!==e)throw new Error(`"mock" network is not compatible with the "${e}" api`);return s instanceof Mockchain?s:new Mockchain;case"main":case"test":case"stn":{if((s instanceof RunConnect||s instanceof WhatsOnChain)&&s.api===e&&s.apiKey===r&&s.network===o)return s;const t={apiKey:r,network:o};switch(typeof e){case"string":switch(e){case"run":return new RunConnect(t);case"whatsonchain":return new WhatsOnChain(t)}break;case"undefined":return"stn"===o?new WhatsOnChain(t):new RunConnect(t);default:throw new Error(`Invalid api: ${P(e)}`)}}break;default:return G(T.defaults.blockchain,!0)}throw new Error(`Invalid blockchain: ${P(t)}`)}function J(t,n,e){if(t instanceof u)return t;if(void 0===t&&!n){const t=a.U&&a.U._o,n=a.U&&a.U.re,r=n&&n.network;return t&&r===e?t:T.defaults.cache instanceof u?T.defaults.cache:v()?new BrowserCache:x()?new NodeCache:new LocalCache}if(t instanceof RunDB){throw new Error(`${"The RunDB plugin is now a state provider, not a cache"}\n\n${"Hint: Try run.state = new RunDB()"}`)}throw new Error(`Invalid cache: ${P(t)}`)}function K(t,n){if("boolean"==typeof t)return t;if(void 0===t&&!n)return K(T.defaults.client,!0);throw new Error(`Invalid client: ${P(t)}`)}function V(t,n){if("boolean"==typeof t)return t;if(void 0===t&&!n)return V(T.defaults.debug,!0);throw new Error(`Invalid debug: ${P(t)}`)}function Y(t,n){if(t instanceof Inventory)return t;if(n)throw new Error(`Invalid inventory: ${P(t)}`);return new Inventory}function W(t,n){if(t instanceof f)return t;if(null===t)return null;if(void 0===t&&!n)return T.defaults.logger;throw new Error(`Invalid logger: ${P(t)}`)}function z(t,n){if("mock"===t||"main"===t||"test"===t||"stn"===t)return t;if(void 0===t&&!n)return T.defaults.network;throw new Error(`Invalid network: ${P(t)}`)}function q(t,n){if(t>=0&&Number.isSafeInteger(t))return t;if(void 0===t&&!n)return q(T.defaults.networkRetries,!0);throw new Error(`Invalid network retries: ${P(t)}`)}function Q(t,n){if("number"==typeof t&&t>=0&&!Number.isNaN(t))return t;if(void 0===t&&!n)return Q(T.defaults.networkTimeout,!0);throw new Error(`Invalid network timeout: ${P(t)}`)}function X(t,n,e,r){if(r){if(t&&n&&t!==r)throw new Error("Cannot set different owner and wallet");return r}if(t instanceof l)return t;if(void 0===t&&!n){if(T.defaults.owner instanceof l)return T.defaults.owner;if("string"==typeof T.defaults.owner||T.defaults.owner instanceof o)try{return new LocalOwner(T.defaults.owner,e.network)}catch(t){}return new LocalOwner(void 0,e.network)}if("string"==typeof t||t instanceof o)try{return new LocalOwner(t,e.network)}catch(t){}if("string"==typeof t||t instanceof i||t instanceof s)try{return new Viewer(t.toString(),e.network)}catch(t){}if("object"==typeof t)try{return new Viewer(t)}catch(t){}throw new Error(`Invalid owner: ${P(t)}`)}function Z(t,n){if("boolean"==typeof t)return t;if(void 0===t&&!n)return Z(T.defaults.preverify,!0);throw new Error(`Invalid preverify: ${P(t)}`)}function tt(t,n,e,r){if(r){if(t&&n&&t!==r)throw new Error("Cannot set different purse and wallet");return r}if(t instanceof d)return t;if(void 0===t&&!n){if(T.defaults.purse instanceof d)return T.defaults.purse;if("string"==typeof T.defaults.purse||T.defaults.purse instanceof o)try{return new LocalPurse({privkey:T.defaults.purse,blockchain:e})}catch(t){}return new LocalPurse({blockchain:e})}if("string"==typeof t||t instanceof o)try{return new LocalPurse({privkey:t,blockchain:e})}catch(t){}throw new Error(`Invalid purse: ${P(t)}`)}function nt(t,n){if("boolean"==typeof t)return t;if(void 0===t&&!n)return nt(T.defaults.rollbacks,!0);throw new Error(`Invalid rollbacks: ${P(t)}`)}function et(t,n,e,r,o){if(t instanceof p)return t;if(void 0===t&&!n){const t=a.U&&a.U.lo,n=a.U&&a.U.re,i=n&&n.network,s=t&&t.api,c=t&&t.apiKey;return t&&i===e&&s===r&&c===o?t:T.defaults.state instanceof p?T.defaults.state:"main"===e||"test"===e?new StateServer({apiKey:o="run"===r?o:void 0}):new LocalState}throw new Error(`Invalid state: ${P(t)}`)}function rt(t,n){if("number"==typeof t&&t>=0&&!Number.isNaN(t))return t;if(void 0===t&&!n)return T.defaults.timeout;throw new Error(`Invalid timeout: ${P(t)}`)}function ot(t,n){let e=[];if("string"==typeof t){if(!st(t))throw new Error(`Not trustable: ${P(t)}`);"cache"===t&&(t="state"),e.push(t)}else if(Array.isArray(t)){for(const n of t)if(!st(n))throw new Error(`Not trustable: ${P(n)}`);e=e.concat(t.map((t=>"cache"===t?"state":t)))}else{if(void 0!==t||n)throw new Error(`Not trustable: ${P(t)}`);{const t=a.U&&a.U.fo;t?e=e.concat(Array.from(t)):T.defaults.trust&&(e=e.concat(Array.from(ot(T.defaults.trust,!0))))}}return new Set(e.concat(["61e1265acb3d93f1bf24a593d70b2a6b1c650ec1df90ddece8d6954ae3cdd915","49145693676af7567ebe20671c5cb01369ac788c20f3b1c804f624a1eda18f3f","284ce17fd34c0f41835435b03eed149c4e0479361f40132312b4001093bb158f","6fe169894d313b44bd54154f88e1f78634c7f5a23863d1713342526b86a39b8b","5332c013476cd2a2c18710a01188695bc27a5ef1748a51d4a5910feb1111dab4","81bcef29b0e4ed745f3422c0b764a33c76d0368af2d2e7dd139db8e00ee3d8a6","71fba386341b932380ec5bfedc3a40bce43d4974decdc94c419a94a8ce5dfc23","780ab8919cb89323707338070323c24ce42cdec2f57d749bd7aceef6635e7a4d","90a3ece416f696731430efac9657d28071cc437ebfff5fb1eaf710fe4b3c8d4e","727e7b423b7ee40c0b5be87fba7fa5673ea2d20a74259040a7295d9c32a90011","3b7ef411185bbe3d01caeadbe6f115b0103a546c4ef0ac7474aa6fbb71aff208","b17a9af70ab0f46809f908b2e900e395ba40996000bf4f00e3b27a1e93280cf1","72a61eb990ffdb6b38e5f955e194fed5ff6b014f75ac6823539ce5613aea0be8","312985bd960ae4c59856b3089b04017ede66506ea181333eec7c9bb88b11c490","05f67252e696160a7c0099ae8d1ec23c39592378773b3a5a55f16bd1286e7dcb","d792d10294a0d9b05a30049f187a1704ced14840ecf41d00663d79c695f86633","318d2a009e29cb3a202b2a167773341dcd39809b967889a7e306d504cc266faf","5a8d4b4da7c5f27a39adac3a9256a7e15e03a7266c81ac8369a3b634560e7814","d7273b6790a4dec4aa116661aff0ec35381794e552807014ca6a536f4454976d","d6170025a62248d8df6dc14e3806e68b8df3d804c800c7bfb23b0b4232862505","ce8629aa37a1777d6aa64d0d33cd739fd4e231dc85cfe2f9368473ab09078b78","ca1818540d2865c5b6a53e06650eafadc10b478703aa7cf324145f848fec629b","1de3951603784df7c872519c096445a415d9b0d3dce7bbe3b7a36ca82cf1a91c","367b4980287f8abae5ee4b0c538232164d5b2463068067ec1e510c91114bced2","1f0abf8d94477b1cb57629d861376616f6e1d7b78aba23a19da3e6169caf489e","8b9380d445b6fe01ec7230d8363febddc99feee6064d969ae8f98fdb25e1393f","03e21aa8fcf08fa6985029ad2e697a2309962527700246d47d891add3cfce3ac","5435ae2760dc35f4329501c61c42e24f6a744861c22f8e0f04735637c20ce987","b44a203acd6215d2d24b33a41f730e9acf2591c4ae27ecafc8d88ef83da9ddea","424abf066be56b9dd5203ed81cf1f536375351d29726d664507fdc30eb589988","f97d4ac2a3d6f5ed09fad4a4f341619dc5a3773d9844ff95c99c5d4f8388de2f","63e0e1268d8ab021d1c578afb8eaa0828ccbba431ffffd9309d04b78ebeb6e56","03320f1244e509bb421e6f1ff724bf1156182890c3768cfa4ea127a78f9913d2","4a1929527605577a6b30710e6001b9379400421d8089d34bb0404dd558529417","0bdf33a334a60909f4c8dab345500cbb313fbfd50b1d98120227eae092b81c39","7d14c868fe39439edffe6982b669e7b4d3eb2729eee7c262ec2494ee3e310e99","33e78fa7c43b6d7a60c271d783295fa180b7e9fce07d41ff1b52686936b3e6ae","d476fd7309a0eeb8b92d715e35c6e273ad63c0025ff6cca927bd0f0b64ed88ff","24cde3638a444c8ad397536127833878ffdfe1b04d5595489bd294e50d77105a","bfa5180e601e92af23d80782bf625b102ac110105a392e376fe7607e4e87dc8d","c0a79e8afb7cabe5f25bdaa398683d6dfe68a2912b29fe948ed130d14e3a2380","3f9de452f0c3c96be737d42aa0941b27412211976688967adb3174ee18b04c64"]))}function it(t,n){if(void 0===t&&!n)return t;if("object"!=typeof t||null===t)throw new Error(`Invalid wallet: ${P(t)}`);if(!(t instanceof l))throw new Error("wallet does not implement the Owner API");if(!(t instanceof d))throw new Error("wallet does not implement the Purse API");return t}function st(t){return"*"===t||("cache"===t||("state"===t||"string"==typeof t&&(64===t.length&&/[a-fA-F0-9]+/.test(t))))}function at(t){if(!I(t))return;const n={};t.zt&&t.zt.info&&(n.info=t.zt.info.bind(t.zt)),t.zt&&t.zt.warn&&(n.warn=t.zt.warn.bind(t.zt)),t.zt&&t.zt.error&&(n.error=t.zt.error.bind(t.zt)),t.zt&&t.zt.debug&&t.Dt&&(n.debug=t.zt.debug.bind(t.zt)),O.zt=n}function ct(t){const n=b.Vt(t)||b.Yt(),e=b.Tt(n);return T.instance?e.te||e.ie(t):e.ye(t),n}T.instance=null,T.defaults={},T.defaults.api=void 0,T.defaults.apiKey=void 0,T.defaults.app="",T.defaults.autofund=!0,T.defaults.backingLimit=1e8,T.defaults.blockchain=void 0,T.defaults.cache=void 0,T.defaults.client=!1,T.defaults.debug=!1,T.defaults.inventory=void 0,T.defaults.logger={warn:console.warn,error:console.error},T.defaults.network="main",T.defaults.networkRetries=2,T.defaults.networkTimeout=1e4,T.defaults.owner=void 0,T.defaults.preverify=!0,T.defaults.purse=void 0,T.defaults.rollbacks=!0,T.defaults.state=void 0,T.defaults.timeout=3e4,T.defaults.trust=[],T.configure=(t,n)=>{T.defaults=Object.assign({},T.defaults),t.APP&&(T.defaults.app=t.APP),n=n||t.NETWORK||T.defaults.network,T.defaults.network=n,"debug"===t.LOGGER?(T.defaults.logger=console,T.defaults.debug=!0):t.LOGGER&&JSON.parse(t.LOGGER)?(T.defaults.logger=console,T.defaults.debug=!1):t.LOGGER&&!JSON.parse(t.LOGGER)&&(T.defaults.logger={}),O.zt=T.defaults.logger;const e=t.PURSE||t[`PURSE_${n.toUpperCase()}`];void 0!==e&&(T.defaults.purse=e);const r=t.OWNER||t[`OWNER_${n.toUpperCase()}`];void 0!==r&&(T.defaults.owner=r),void 0!==t.API&&(T.defaults.api=t.API);const o=t.APIKEY||t[`APIKEY_${(T.defaults.api||"").toUpperCase()}`];void 0!==o&&(T.defaults.apiKey=o)},T.cover=t=>{m.sn.includes(t)||m.sn.push(t)},T.Berry=Berry,T.Code=Code,T.Jig=Jig,T.Creation=Creation,T.Transaction=g,T.plugins={},T.plugins.BrowserCache=BrowserCache,T.plugins.DiskCache=DiskCache,T.plugins.IndexedDbCache=k,T.plugins.Inventory=Inventory,T.plugins.LocalCache=LocalCache,T.plugins.LocalOwner=LocalOwner,T.plugins.LocalPurse=LocalPurse,T.plugins.LocalState=LocalState,T.plugins.Mockchain=Mockchain,T.plugins.NodeCache=NodeCache,T.plugins.PayServer=PayServer,T.plugins.RunConnect=RunConnect,T.plugins.RunDB=RunDB,T.plugins.StateServer=StateServer,T.plugins.Viewer=Viewer,T.plugins.WhatsOnChain=WhatsOnChain,T.plugins.BlockchainWrapper=BlockchainWrapper,T.plugins.CacheWrapper=CacheWrapper,T.plugins.OwnerWrapper=OwnerWrapper,T.plugins.PurseWrapper=PurseWrapper,T.plugins.StateWrapper=StateWrapper,T.extra=e(47),T.rn=e(4).rn,T.pn=e(8),T.Ha=e(12),T.Ga=e(25),T.yn=e(14),T.Ja=e(17),T.Ka=e(50),T.Va=e(51),T.Be=e(9).Be,T.Ya=e(29),T.Wa=e(18),T.$t=e(2),T.gn=e(20),T.St=e(0),T.za=e(26),T.qa=e(61),T.At=e(10),T.Qa=e(19),T.A=e(0).A,T.k=e(0).k,T.j=e(0).j,T.mn=e(23),T.On=m,T.Xa=e(52),T.Hr=e(12).Hr,T.Za=e(36),T.tc=e(24),T.nc=e(28),T.h=e(4).h,T.jn=e(15),T.api={},T.api.Blockchain=c,T.api.Logger=f,T.api.Purse=d,T.api.Cache=u,T.api.Lock=h,T.api.Owner=l,T.api.State=p,T.errors=e(11),T.errors.RequestError=e(19).Io,T.util={},T.util.CommonLock=CommonLock,T.util.deps=t=>{if("string"!=typeof t||!t.length)throw new Error(`Invalid transaction: ${P(t)}`);return S(new r.Transaction(t))},T.util.metadata=t=>{if("string"!=typeof t||!t.length)throw new Error(`Invalid transaction: ${P(t)}`);return $(new r.Transaction(t))},T.util.recreateJigsFromStates=e(48),T.util.install=ct,T.util.unify=function(...t){if(!t.length)throw new ArgumentError("No creations to unify");if(t.some((t=>!(t instanceof Creation))))throw new ArgumentError("Must only unify creations");_(t,t)},T.util.uninstall=function(t){const n=b.Vt(t);if(!n)return;b.Tt(n).be()},Object.defineProperty(T.util,"sha256",{get:()=>a.Ur,set:t=>{if("function"!=typeof t)throw new Error(`'Invalid sha256: ${P(t)}`);a.Ur=t},configurable:!0,enumerable:!0}),T.functions=e(83),T.version="0.6.41",T.protocol=e(15).no,T.bsv=r,t.exports=T},function(t,n,e){const{J:r,D:o,ct:i}=e(0),{rt:s,Qr:a}=e(14),{h:c}=e(4);let u=!0;t.exports={rc:function(t,n,i){return c((()=>{const u=t.concat(n),h={};u.forEach((t=>{const n=h[t.origin];if(n){const e=`1st location: ${t.location}`,o=`2nd location: ${n.location}`,i=`Inconsistent reference: ${r(t)}\n\n${e}\n${o}`;throw new Error(i)}h[t.origin]=t}));const f={},l=new Set,d=new Map;u.forEach((t=>{f[t.origin]=t}));const Creation=e(3);c((()=>s(u,(t=>{if(t instanceof Creation){l.add(t);const n=t.origin,e=h[n];if(e&&t.nonce>e.nonce){const n=`1st location: ${t.location}`,o=`2nd location: ${e.location}`;throw new Error(`Time travel: ${r(t)}\n\n${n}\n${o}`)}const o=f[n];(!o||t.nonce>o.nonce)&&(f[n]=t)}})))),i&&(f[i.origin]=i),a(i,((t,n)=>{if(t!==i&&t instanceof Creation)return n(!1),f[t.origin]}));for(const n of l){const e=new Map;a(n,((t,r)=>{if(t!==n&&t instanceof Creation){const n=f[t.origin];return t!==n&&e.set(n,t),o(n),r(!1),n}})),t.includes(n)||d.set(n,e)}const p={};return Object.entries(f).forEach((([t,n])=>{p[t]=[n.location,n.nonce]})),{oc:p,ic:d}}))},sc:function(t){c((()=>{for(const[n,r]of t.entries()){const Creation=e(3);a(n,((t,e)=>{if(t!==n&&t instanceof Creation)return e(!1),r.get(t)||t}))}}))},Wn:function(t,n=[]){const Creation=e(3);if(!u)return;const h=t=>c((()=>!i(t,"origin")||t.origin.startsWith("error://")?t:t.origin));return c((()=>{const e=new Map;return n.forEach((t=>{o(t instanceof Creation);const n=h(t);if(!(!e.has(n)||e.get(n).nonce===t.nonce)){const o=c((()=>`There are conflicting jigs for ${t.origin}, nonces ${e.get(n).nonce}, ${t.nonce}`));throw new Error(`Cannot unify inconsistent ${r(t)}\n\n${o}`)}e.set(n,t)})),c((()=>s(t,(t=>{if(t instanceof Creation){const o=h(t),i=e.get(o)||t;if(e.has(o)||e.set(o,t),t.nonce>i.nonce){if(n.includes(i)){const n=`1st location: ${t.location}`,e=`2nd location: ${i.location}`;throw new Error(`Cannot unify inconsistent ${r(t)}\n\n${n}\n${e}`)}e.set(o,t)}}})))),a(t,(t=>{if(t instanceof Creation)return e.get(h(t))}))}))},ac:function(t){u=t}}},function(t,n,e){"use strict";(function(t){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/
var r=e(65),o=e(66),i=e(67);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,n){if(s()<n)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(n)).__proto__=c.prototype:(null===t&&(t=new c(n)),t.length=n),t}function c(t,n,e){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(t,n,e);if("number"==typeof t){if("string"==typeof n)throw new Error("If encoding is specified then the first argument must be a string");return f(this,t)}return u(this,t,n,e)}function u(t,n,e,r){if("number"==typeof n)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&n instanceof ArrayBuffer?function(t,n,e,r){if(n.byteLength,e<0||n.byteLength<e)throw new RangeError("'offset' is out of bounds");if(n.byteLength<e+(r||0))throw new RangeError("'length' is out of bounds");n=void 0===e&&void 0===r?new Uint8Array(n):void 0===r?new Uint8Array(n,e):new Uint8Array(n,e,r);c.TYPED_ARRAY_SUPPORT?(t=n).__proto__=c.prototype:t=l(t,n);return t}(t,n,e,r):"string"==typeof n?function(t,n,e){"string"==typeof e&&""!==e||(e="utf8");if(!c.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var r=0|p(n,e),o=(t=a(t,r)).write(n,e);o!==r&&(t=t.slice(0,o));return t}(t,n,e):function(t,n){if(c.isBuffer(n)){var e=0|d(n.length);return 0===(t=a(t,e)).length||n.copy(t,0,0,e),t}if(n){if("undefined"!=typeof ArrayBuffer&&n.buffer instanceof ArrayBuffer||"length"in n)return"number"!=typeof n.length||(r=n.length)!=r?a(t,0):l(t,n);if("Buffer"===n.type&&i(n.data))return l(t,n.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,n)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function f(t,n){if(h(n),t=a(t,n<0?0:0|d(n)),!c.TYPED_ARRAY_SUPPORT)for(var e=0;e<n;++e)t[e]=0;return t}function l(t,n){var e=n.length<0?0:0|d(n.length);t=a(t,e);for(var r=0;r<e;r+=1)t[r]=255&n[r];return t}function d(t){if(t>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function p(t,n){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var e=t.length;if(0===e)return 0;for(var r=!1;;)switch(n){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return G(t).length;default:if(r)return H(t).length;n=(""+n).toLowerCase(),r=!0}}function b(t,n,e){var r=!1;if((void 0===n||n<0)&&(n=0),n>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(n>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return j(this,n,e);case"utf8":case"utf-8":return A(this,n,e);case"ascii":return S(this,n,e);case"latin1":case"binary":return k(this,n,e);case"base64":return x(this,n,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,n,e);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function w(t,n,e){var r=t[n];t[n]=t[e],t[e]=r}function y(t,n,e,r,o){if(0===t.length)return-1;if("string"==typeof e?(r=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof n&&(n=c.from(n,r)),c.isBuffer(n))return 0===n.length?-1:g(t,n,e,r,o);if("number"==typeof n)return n&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,n,e):Uint8Array.prototype.lastIndexOf.call(t,n,e):g(t,[n],e,r,o);throw new TypeError("val must be string, number or Buffer")}function g(t,n,e,r,o){var i,s=1,a=t.length,c=n.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||n.length<2)return-1;s=2,a/=2,c/=2,e/=2}function u(t,n){return 1===s?t[n]:t.readUInt16BE(n*s)}if(o){var h=-1;for(i=e;i<a;i++)if(u(t,i)===u(n,-1===h?0:i-h)){if(-1===h&&(h=i),i-h+1===c)return h*s}else-1!==h&&(i-=i-h),h=-1}else for(e+c>a&&(e=a-c),i=e;i>=0;i--){for(var f=!0,l=0;l<c;l++)if(u(t,i+l)!==u(n,l)){f=!1;break}if(f)return i}return-1}function _(t,n,e,r){e=Number(e)||0;var o=t.length-e;r?(r=Number(r))>o&&(r=o):r=o;var i=n.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(n.substr(2*s,2),16);if(isNaN(a))return s;t[e+s]=a}return s}function m(t,n,e,r){return J(H(n,t.length-e),t,e,r)}function O(t,n,e,r){return J(function(t){for(var n=[],e=0;e<t.length;++e)n.push(255&t.charCodeAt(e));return n}(n),t,e,r)}function P(t,n,e,r){return O(t,n,e,r)}function E(t,n,e,r){return J(G(n),t,e,r)}function v(t,n,e,r){return J(function(t,n){for(var e,r,o,i=[],s=0;s<t.length&&!((n-=2)<0);++s)r=(e=t.charCodeAt(s))>>8,o=e%256,i.push(o),i.push(r);return i}(n,t.length-e),t,e,r)}function x(t,n,e){return 0===n&&e===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(n,e))}function A(t,n,e){e=Math.min(t.length,e);for(var r=[],o=n;o<e;){var i,s,a,c,u=t[o],h=null,f=u>239?4:u>223?3:u>191?2:1;if(o+f<=e)switch(f){case 1:u<128&&(h=u);break;case 2:128==(192&(i=t[o+1]))&&(c=(31&u)<<6|63&i)>127&&(h=c);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(c=(15&u)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(h=c);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(h=c)}null===h?(h=65533,f=1):h>65535&&(h-=65536,r.push(h>>>10&1023|55296),h=56320|1023&h),r.push(h),o+=f}return function(t){var n=t.length;if(n<=$)return String.fromCharCode.apply(String,t);var e="",r=0;for(;r<n;)e+=String.fromCharCode.apply(String,t.slice(r,r+=$));return e}(r)}n.Buffer=c,n.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},n.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),n.kMaxLength=s(),c.poolSize=8192,c.ou=function(t){return t.__proto__=c.prototype,t},c.from=function(t,n,e){return u(null,t,n,e)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(t,n,e){return function(t,n,e,r){return h(n),n<=0?a(t,n):void 0!==e?"string"==typeof r?a(t,n).fill(e,r):a(t,n).fill(e):a(t,n)}(null,t,n,e)},c.allocUnsafe=function(t){return f(null,t)},c.allocUnsafeSlow=function(t){return f(null,t)},c.isBuffer=function(t){return!(null==t||!t.iu)},c.compare=function(t,n){if(!c.isBuffer(t)||!c.isBuffer(n))throw new TypeError("Arguments must be Buffers");if(t===n)return 0;for(var e=t.length,r=n.length,o=0,i=Math.min(e,r);o<i;++o)if(t[o]!==n[o]){e=t[o],r=n[o];break}return e<r?-1:r<e?1:0},c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(t,n){if(!i(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);var e;if(void 0===n)for(n=0,e=0;e<t.length;++e)n+=t[e].length;var r=c.allocUnsafe(n),o=0;for(e=0;e<t.length;++e){var s=t[e];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,o),o+=s.length}return r},c.byteLength=p,c.prototype.iu=!0,c.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var n=0;n<t;n+=2)w(this,n,n+1);return this},c.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var n=0;n<t;n+=4)w(this,n,n+3),w(this,n+1,n+2);return this},c.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var n=0;n<t;n+=8)w(this,n,n+7),w(this,n+1,n+6),w(this,n+2,n+5),w(this,n+3,n+4);return this},c.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?A(this,0,t):b.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",e=n.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),"<Buffer "+t+">"},c.prototype.compare=function(t,n,e,r,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===n&&(n=0),void 0===e&&(e=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),n<0||e>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&n>=e)return 0;if(r>=o)return-1;if(n>=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(e>>>=0)-(n>>>=0),a=Math.min(i,s),u=this.slice(r,o),h=t.slice(n,e),f=0;f<a;++f)if(u[f]!==h[f]){i=u[f],s=h[f];break}return i<s?-1:s<i?1:0},c.prototype.includes=function(t,n,e){return-1!==this.indexOf(t,n,e)},c.prototype.indexOf=function(t,n,e){return y(this,t,n,e,!0)},c.prototype.lastIndexOf=function(t,n,e){return y(this,t,n,e,!1)},c.prototype.write=function(t,n,e,r){if(void 0===n)r="utf8",e=this.length,n=0;else if(void 0===e&&"string"==typeof n)r=n,e=this.length,n=0;else{if(!isFinite(n))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");n|=0,isFinite(e)?(e|=0,void 0===r&&(r="utf8")):(r=e,e=void 0)}var o=this.length-n;if((void 0===e||e>o)&&(e=o),t.length>0&&(e<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return _(this,t,n,e);case"utf8":case"utf-8":return m(this,t,n,e);case"ascii":return O(this,t,n,e);case"latin1":case"binary":return P(this,t,n,e);case"base64":return E(this,t,n,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,t,n,e);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this.Or||this,0)}};var $=4096;function S(t,n,e){var r="";e=Math.min(t.length,e);for(var o=n;o<e;++o)r+=String.fromCharCode(127&t[o]);return r}function k(t,n,e){var r="";e=Math.min(t.length,e);for(var o=n;o<e;++o)r+=String.fromCharCode(t[o]);return r}function j(t,n,e){var r=t.length;(!n||n<0)&&(n=0),(!e||e<0||e>r)&&(e=r);for(var o="",i=n;i<e;++i)o+=L(t[i]);return o}function T(t,n,e){for(var r=t.slice(n,e),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function I(t,n,e){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+n>e)throw new RangeError("Trying to access beyond buffer length")}function R(t,n,e,r,o,i){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>o||n<i)throw new RangeError('"value" argument is out of bounds');if(e+r>t.length)throw new RangeError("Index out of range")}function N(t,n,e,r){n<0&&(n=65535+n+1);for(var o=0,i=Math.min(t.length-e,2);o<i;++o)t[e+o]=(n&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function C(t,n,e,r){n<0&&(n=4294967295+n+1);for(var o=0,i=Math.min(t.length-e,4);o<i;++o)t[e+o]=n>>>8*(r?o:3-o)&255}function U(t,n,e,r,o,i){if(e+r>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function F(t,n,e,r,i){return i||U(t,0,e,4),o.write(t,n,e,r,23,4),e+4}function D(t,n,e,r,i){return i||U(t,0,e,8),o.write(t,n,e,r,52,8),e+8}c.prototype.slice=function(t,n){var e,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(n=void 0===n?r:~~n)<0?(n+=r)<0&&(n=0):n>r&&(n=r),n<t&&(n=t),c.TYPED_ARRAY_SUPPORT)(e=this.subarray(t,n)).__proto__=c.prototype;else{var o=n-t;e=new c(o,void 0);for(var i=0;i<o;++i)e[i]=this[i+t]}return e},c.prototype.readUIntLE=function(t,n,e){t|=0,n|=0,e||I(t,n,this.length);for(var r=this[t],o=1,i=0;++i<n&&(o*=256);)r+=this[t+i]*o;return r},c.prototype.readUIntBE=function(t,n,e){t|=0,n|=0,e||I(t,n,this.length);for(var r=this[t+--n],o=1;n>0&&(o*=256);)r+=this[t+--n]*o;return r},c.prototype.readUInt8=function(t,n){return n||I(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,n){return n||I(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,n){return n||I(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,n){return n||I(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,n){return n||I(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,n,e){t|=0,n|=0,e||I(t,n,this.length);for(var r=this[t],o=1,i=0;++i<n&&(o*=256);)r+=this[t+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*n)),r},c.prototype.readIntBE=function(t,n,e){t|=0,n|=0,e||I(t,n,this.length);for(var r=n,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*n)),i},c.prototype.readInt8=function(t,n){return n||I(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,n){n||I(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt16BE=function(t,n){n||I(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},c.prototype.readInt32LE=function(t,n){return n||I(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,n){return n||I(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,n){return n||I(t,4,this.length),o.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,n){return n||I(t,4,this.length),o.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,n){return n||I(t,8,this.length),o.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,n){return n||I(t,8,this.length),o.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,n,e,r){(t=+t,n|=0,e|=0,r)||R(this,t,n,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[n]=255&t;++i<e&&(o*=256);)this[n+i]=t/o&255;return n+e},c.prototype.writeUIntBE=function(t,n,e,r){(t=+t,n|=0,e|=0,r)||R(this,t,n,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[n+o]=255&t;--o>=0&&(i*=256);)this[n+o]=t/i&255;return n+e},c.prototype.writeUInt8=function(t,n,e){return t=+t,n|=0,e||R(this,t,n,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[n]=255&t,n+1},c.prototype.writeUInt16LE=function(t,n,e){return t=+t,n|=0,e||R(this,t,n,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):N(this,t,n,!0),n+2},c.prototype.writeUInt16BE=function(t,n,e){return t=+t,n|=0,e||R(this,t,n,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):N(this,t,n,!1),n+2},c.prototype.writeUInt32LE=function(t,n,e){return t=+t,n|=0,e||R(this,t,n,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[n+3]=t>>>24,this[n+2]=t>>>16,this[n+1]=t>>>8,this[n]=255&t):C(this,t,n,!0),n+4},c.prototype.writeUInt32BE=function(t,n,e){return t=+t,n|=0,e||R(this,t,n,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=255&t):C(this,t,n,!1),n+4},c.prototype.writeIntLE=function(t,n,e,r){if(t=+t,n|=0,!r){var o=Math.pow(2,8*e-1);R(this,t,n,e,o-1,-o)}var i=0,s=1,a=0;for(this[n]=255&t;++i<e&&(s*=256);)t<0&&0===a&&0!==this[n+i-1]&&(a=1),this[n+i]=(t/s>>0)-a&255;return n+e},c.prototype.writeIntBE=function(t,n,e,r){if(t=+t,n|=0,!r){var o=Math.pow(2,8*e-1);R(this,t,n,e,o-1,-o)}var i=e-1,s=1,a=0;for(this[n+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[n+i+1]&&(a=1),this[n+i]=(t/s>>0)-a&255;return n+e},c.prototype.writeInt8=function(t,n,e){return t=+t,n|=0,e||R(this,t,n,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[n]=255&t,n+1},c.prototype.writeInt16LE=function(t,n,e){return t=+t,n|=0,e||R(this,t,n,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8):N(this,t,n,!0),n+2},c.prototype.writeInt16BE=function(t,n,e){return t=+t,n|=0,e||R(this,t,n,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[n]=t>>>8,this[n+1]=255&t):N(this,t,n,!1),n+2},c.prototype.writeInt32LE=function(t,n,e){return t=+t,n|=0,e||R(this,t,n,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[n]=255&t,this[n+1]=t>>>8,this[n+2]=t>>>16,this[n+3]=t>>>24):C(this,t,n,!0),n+4},c.prototype.writeInt32BE=function(t,n,e){return t=+t,n|=0,e||R(this,t,n,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=255&t):C(this,t,n,!1),n+4},c.prototype.writeFloatLE=function(t,n,e){return F(this,t,n,!0,e)},c.prototype.writeFloatBE=function(t,n,e){return F(this,t,n,!1,e)},c.prototype.writeDoubleLE=function(t,n,e){return D(this,t,n,!0,e)},c.prototype.writeDoubleBE=function(t,n,e){return D(this,t,n,!1,e)},c.prototype.copy=function(t,n,e,r){if(e||(e=0),r||0===r||(r=this.length),n>=t.length&&(n=t.length),n||(n=0),r>0&&r<e&&(r=e),r===e)return 0;if(0===t.length||0===this.length)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(e<0||e>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-n<r-e&&(r=t.length-n+e);var o,i=r-e;if(this===t&&e<n&&n<r)for(o=i-1;o>=0;--o)t[o+n]=this[o+e];else if(i<1e3||!c.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+n]=this[o+e];else Uint8Array.prototype.set.call(t,this.subarray(e,e+i),n);return i},c.prototype.fill=function(t,n,e,r){if("string"==typeof t){if("string"==typeof n?(r=n,n=0,e=this.length):"string"==typeof e&&(r=e,e=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!c.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof t&&(t&=255);if(n<0||this.length<n||this.length<e)throw new RangeError("Out of range index");if(e<=n)return this;var i;if(n>>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=n;i<e;++i)this[i]=t;else{var s=c.isBuffer(t)?t:H(new c(t,r).toString()),a=s.length;for(i=0;i<e-n;++i)this[i+n]=s[i%a]}return this};var M=/[^+\/0-9A-Za-z-_]/g;function L(t){return t<16?"0"+t.toString(16):t.toString(16)}function H(t,n){var e;n=n||1/0;for(var r=t.length,o=null,i=[],s=0;s<r;++s){if((e=t.charCodeAt(s))>55295&&e<57344){if(!o){if(e>56319){(n-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(n-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(n-=3)>-1&&i.push(239,191,189),o=e;continue}e=65536+(o-55296<<10|e-56320)}else o&&(n-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((n-=1)<0)break;i.push(e)}else if(e<2048){if((n-=2)<0)break;i.push(e>>6|192,63&e|128)}else if(e<65536){if((n-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((n-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function G(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function J(t,n,e,r){for(var o=0;o<r&&!(o+e>=n.length||o>=t.length);++o)n[o+e]=t[o];return o}}).call(this,e(42))},function(t,n,e){const r=e(6),{In:o}=e(8);function i(t){const{eo:n}=e(15),o="Not a RUN transaction: invalid OP_RETURN protocol",i="Not a RUN transaction: invalid RUN metadata";if(!t.outputs.length)throw new Error(o);let s=null;const a=new r.Transaction;for(let n=0;n<t.outputs.length;n++){s=t.outputs[n].script.chunks;if(!(6!==s.length||0!==s[0].opcodenum||106!==s[1].opcodenum||"run"!==s[2].buf.toString()))break;a.addOutput(t.outputs[n]),s=null}if(!s)throw new Error(o);const c=n(s[3].buf.toString("hex")),u=s[4].buf?s[4].buf.toString():"";try{const t=s[5].buf.toString("utf8"),n=JSON.parse(t);if(6!==Object.keys(n).length||"number"!=typeof n.in||!Array.isArray(n.ref)||!Array.isArray(n.out)||!Array.isArray(n.del)||!Array.isArray(n.cre)||!Array.isArray(n.exec)||n.ref.some((t=>"string"!=typeof t))||n.out.some((t=>"string"!=typeof t))||n.del.some((t=>"string"!=typeof t))||n.exec.some((t=>"object"!=typeof t)))throw new Error(i);return n.app=u,n.version=c,n.base=a.toString("hex"),n.vrun=a.outputs.length,n}catch(t){throw new Error(i)}}t.exports={ao:i,ja:function(t){const n=i(t),e=new Set;for(let r=0;r<n.in;r++){const n=t.inputs[r].prevTxId.toString("hex");e.add(n)}for(const t of n.ref){if(t.startsWith("native://"))continue;const n=t.slice(0,64);e.add(n);if(t.includes("?berry=")){const n=o(t);let r=n.Fn;if(r.length>64)try{r=JSON.parse(n.Fn).txid}catch(t){}64===r.length&&e.add(r)}}return Array.from(e)}}},function(t,n,e){const r=e(6),{J:o,yt:i}=e(0),{so:s}=e(17),a=e(2),c=e(16),u=e(10),{rc:h,sc:f,ac:l}=e(32),{h:d}=e(4),p=e(18),b=e(5),{As:w,Ss:y,ks:g,js:_,$s:m,Is:O,Ts:P,Rs:E,Ms:v,Ls:x}=e(21),A=e(25),{TrustError,ExecutionError}=e(11),$="Replay";async function S(t,n,S,k,j,T,I,R){const N=e(68);a.tn&&a.qt($,"Replay",n);const C=new Date;(I=I||new i("replay",k._t,n)).Pt();if(!R&&(S.exec.some((t=>"DEPLOY"===t.op))||S.exec.some((t=>"UPGRADE"===t.op)))&&!await k.mo(n,"replay"))throw new TrustError(n,"replay");let U=[],F=[];const D=new c.Oo;for(let n=0;n<S.in;n++){const e=t.inputs[n];if(!e)throw new Error(`Jig input missing for _i${n}`);const r=e.prevTxId.toString("hex"),o=e.outputIndex,i=c(`${r}_o${o}`,void 0,k,D,I);U.push(i)}for(let t=0;t<S.ref.length;t++){const n=S.ref[t],e=c(n,void 0,k,D,I);F.push(e)}if(U=await Promise.all(U),F=await Promise.all(F),T&&!U.some((t=>t.location===T.location)))throw new Error(`${o(T)} not found in the transaction\n\ntxid: ${n}\njig: ${T.location}`);const M=new u;M.tr=!0,M.Ze=!1;const L=u.Ft;l(!1);const H=k.Hn;k.Hn=Number.MAX_SAFE_INTEGER;let G=null,J=null;try{const t=h(U,F,T);G=t.oc,J=t.ic,T&&(U[U.findIndex((t=>t.location===T.location))]=T),U.forEach((t=>M.Ar(t))),F.forEach((t=>M._read(t))),u.Ft=M;for(const t of S.exec){const{op:n,data:e}=t;if(2!==Object.keys(t).length)throw new Error("Invalid exec");if("string"!=typeof n)throw new Error(`Invalid op: ${n}`);if("object"!=typeof e||!e)throw new Error(`Invalid data: ${e}`);const r=new A;for(const t of U)r.br(t);for(const t of F)r.br(t);for(const t of M.Gt)r.br(t);N(n,e,r.Or())}}catch(t){throw M.je(t),new ExecutionError(t.message)}finally{u.Ft=L,k.Hn=H,l(!0)}let K=null,V=null;try{if(K=M.sr(),!K)throw new Error("Invalid metadata: no commit generated");K.ws=S.app,K.jn=S.version,K.gs=new r.Transaction(S.base),K.oc=G,V=await async function(t,n,e,r,o,i){a.Ut&&a.Dt($,"Verify",e);const c=new Date,u=t.Tn,h=w(u);!function(t,n,e){const r={g:b.g,jo:t=>e[t]},o=n.cre.map((t=>p.ko(t,r)));if(t.Tn.Gt._r!==n.cre.length)throw new Error("Invalid number of cre entries");for(let n=0;n<o.length;n++){const e=o[n],r=t.Tn.Gt.Or()[n],i=t.fs.get(r);d((()=>{r.owner=e})),i.wr.owner=e}}(t,r,h);const f=await m(t);y(t);const l=await g(t,o);o.Pt();const v=await _(t,l),x=O(u,h),A=P(t,v,x,h),S=E(t,A,f,0);s(A)!==s(r)&&function(t,n,e,r,o){a.en&&a.Zt($,"Expected metadata:",JSON.stringify(t,0,3));a.en&&a.Zt($,"Actual metadata:",JSON.stringify(n,0,3));function i(t,n,e,o){if(t===n)return;const i=r.get(e);o?(a.Zt($,"Expected state:",JSON.stringify(o,0,3)),a.Zt($,"Actual state:",JSON.stringify(i,0,3))):a.Zt($,"State mismatch:",JSON.stringify(i,0,3))}a.en&&(t.out.length===n.out.length?t.out.forEach(((t,r)=>{i(t,n.out[r],e.ze.Or()[r],o&&o.cc(r))})):a.Zt($,`Expected ${t.out.length} outputs but actual was ${n.out.length}`),t.del.length===n.del.length?t.del.forEach(((t,r)=>{i(t,n.del[r],e.Ke.Or()[r],o&&o.yr(r))})):a.Zt($,`Expected ${t.del.length} deletes but actual was ${n.del.length}`));throw new Error("Metadata mismatch\n\nHint: See logs")}(r,A,u,l,i);for(let t=0;t<A.in;t++){const e=n.inputs[t],r=S.inputs[t];if(e.prevTxId.toString("hex")!==r.prevTxId.toString("hex"))throw new Error(`Txid mismatch on input ${t}`);if(e.outputIndex!==r.outputIndex)throw new Error(`Vout mismatch on input ${t}`)}for(let t=0;t<A.out.length;t++){const e=n.outputs[t+A.vrun+1],r=S.outputs[t+A.vrun+1];if(!e)throw new Error(`Jig output missing for _o${t+A.vrun+1}`);if(e.script.toString("hex")!==r.script.toString("hex"))throw new Error(`Script mismatch on output ${t+A.vrun+1}`);if(e.satoshis<r.satoshis){const n=`Hint: Transaction has ${e.satoshis} but expected ${r.satoshis}`;throw new Error(`Satoshis mismatch on output ${t+A.vrun+1}\n\n${n}`)}}a.Ut&&a.Dt($,"Verify (end): "+(new Date-c)+"ms");return l}(K,t,n,S,I,R)}catch(t){throw new ExecutionError(t.message)}return j&&(v(K,n),await x(K,V,n),I.Pt()),f(J),a.Ut&&a.Dt($,"Replay (end): "+(new Date-C)+"ms"),K}S.Os=class{constructor(t,n){this.Tn=t,this.ps=n}cc(t){return this.ps.get(this.Tn.ze.Or()[t])}yr(t){return this.ps.get(this.Tn.Ke.Or()[t])}},t.exports=S},function(t,n,e){const{J:r,ut:o}=e(0),{Pn:i}=e(14),{h:s}=e(4),{Vn:a,Dn:c}=e(8),u=e(5).g,h=e(2);t.exports=class{constructor(t,n,e){if(h.Ut&&h.Dt("Snapshot","Snapshot",r(t),n?"(bindings only)":""),this.Fo=t,this.Tr=n,this.Nr=!e,n){const n=this.wr={};s((()=>{n.location=t.location,n.origin=t.origin,n.nonce=t.nonce,n.owner=i(t.owner,u),n.satoshis=t.satoshis}))}else this.Rr()}Rr(){const t=this.Fo;this.Tr=!1,this.Nr=!0;const Jig=e(7),Code=e(1),Berry=e(13),n=e(9);if(t instanceof Jig)this.uc="jig";else if(t instanceof Code)this.uc=n.Tt(t).Ct?"native":"code";else{if(!(t instanceof Berry))throw new Error(`Not a creation: ${r(t)}`);this.uc="berry"}if(s((()=>{const n=Object.assign({},t),e=i(n,u);this.wr=e})),"jig"!==this.uc&&"berry"!==this.uc||(this.hc=s((()=>t.constructor))),"code"===this.uc){const e=n.Tt(t);this.Nt=e.Nt,this.fc=e.Pe()}}je(t){if("native"!==this.uc&&this.Nr)return s((()=>{if(this.Tr)if(t){const n=c({Zt:`A previous error occurred\n\n${t}`});o(this.Fo,"location",n)}else o(this.Fo,"location",a);else{if("code"===this.uc){e(9).Tt(this.Fo).xe(this.fc)}if(Object.keys(this.Fo).forEach((t=>{delete this.Fo[t]})),Object.keys(this.wr).forEach((t=>{o(this.Fo,t,this.wr[t])})),t){const Jig=e(7),Code=e(1);if((this.Fo instanceof Jig||this.Fo instanceof Code)&&this.wr.location===a){const n=c({Zt:`Deploy failed\n\n${t}`});o(this.Fo,"origin",n),o(this.Fo,"location",n)}}}}))}}},function(t,n,e){const r=e(6),{D:o,Z:i}=e(0),{h:s}=e(4),{rt:a}=e(14),{Kn:c,Dn:u}=e(8),h=e(36),f=e(2),l=e(21),{no:d}=e(15),p="Commit",b=new Map;class w{constructor(t){f.Ut&&f.Dt(p,"Create",t.Me),o(t.He.length),o(t.We._r||t.ze._r||t.Ke._r),this.Tn=t,this.er=t.er,this.ws=this.er.ws,this.jn=d,this.gs=new r.Transaction,this.lc=[],this.fs=new Map,this.ls(),this.oc=null,this.dc=[],this.bc=[],this.Fr=!1,this.Tn.Ze&&(this.rs(!0),this.ds().then((()=>l(this)))),this.Tn.tr||(this.Tn.ze.dr((t=>this.er.pr("update",t))),this.Tn.Ke.dr((t=>this.er.pr("update",t)))),this.states=null,this.stateHashes=null}ls(){const t=t=>{if(!this.fs.has(t)){const n=new h(t);this.fs.set(t,n)}};this.Tn.ze.dr((n=>t(n))),this.Tn.Ke.dr((n=>t(n)))}rs(t){t?(o(!this.Fr),o(!b.has(this.Tn.Me)),b.set(this.Tn.Me,this)):(b.delete(this.Tn.Me),o(!this.bc.length),o(!this.lc.length))}es(){return b.has(this.Tn.Me)}async ds(){const t=this.Tn;t.Qe=t.Qe.filter((t=>!t.Fr)),t.Qe.length&&(t.Qe.filter((t=>!t.lc.includes(this))).forEach((t=>t.lc.push(this))),await new Promise(((t,n)=>this.dc.push({resolve:t,reject:n}))))}async yc(){o(this.es()),await new Promise(((t,n)=>this.bc.push({resolve:t,reject:n})))}wc(t){const n=this.Tn;for(const[e,r]of t.fs){const t=n.We.Tt(e)||n.qe.Tt(e);if(!t)continue;const o=n.Xe.get(t);o&&c.forEach((t=>{o.wr[t]=r.wr[t]}));const a=this.fs.get(t);if(a){const t=a.wr;a.wr.origin=r.wr.origin,i(t.owner)||(t.owner=r.wr.owner),i(t.satoshis)||(t.satoshis=r.wr.satoshis)}s((()=>{t.origin=r.wr.origin,i(t.owner)||(t.owner=r.wr.owner),i(t.satoshis)||(t.satoshis=r.wr.satoshis)}))}n.Qe=n.Qe.filter((n=>n!==t)),n.Qe.length||(this.dc.forEach((t=>t.resolve())),this.dc=[])}Ps(t){return this.lc.some((n=>n.Tn.We.Ht(t)))}async hs(t){if(this.oc)return this.oc;const n=e(16),r=new n.Oo,o=this.Tn,i=o.We.Or().concat(o.qe.Or()).map((t=>o.Xe.get(t).wr.location)),s=await Promise.all(i.map((e=>n(e,void 0,this.er,r,t))));return this.oc=w.gc(s,t),this.oc}static async gc(t,n){f.Ut&&f.Dt(p,"Build refmap");const Creation=e(3),r={};return s((()=>a(t,(n=>{if(n instanceof Creation)return s((()=>{(!(n.origin in r)||r[n.origin][1]<=n.nonce)&&(r[n.origin]=[n.location,n.nonce])})),t.includes(n)})))),r}cs(){this.Fr=!0,this.bc.forEach((t=>t.resolve())),this.bc=[],this.lc.forEach((t=>t.wc(this)));const t=t=>{this.Ps(t)||this.er.pr("publish",t)};this.Tn.ze.dr((n=>t(n))),this.Tn.Ke.dr((n=>t(n))),this.lc=[],this.rs(!1)}us(t){o(t);const n=this.Tn;this.Fr=!1,this.lc.forEach((n=>n.us(t))),this.lc=[];const e=t&&0===this.bc.length;if(f.en&&f.Zt(p,e?"Unhandled":"",t),this.Tn.je(t),e){const e=u({Zt:`Unhandled ${t}`});s((()=>{n.ze.dr((t=>{t.location=e})),n.Ke.dr((t=>{t.location=e}))}))}n.tr||(n.ze.dr((t=>this.er.pr("update",t))),n.Ke.dr((t=>this.er.pr("update",t)))),t&&(this.bc.forEach((n=>n.reject(t))),this.bc=[]),this.rs(!1)}}w.Cr=t=>b.get(t),w.Ua=async()=>{const t=[];for(const n of b.values())t.push(n.yc());return Promise.all(t)},t.exports=w},function(t,n,e){const r=e(2),o=e(28),{Xr:i}=e(14),{J:s,K:a,V:c}=e(0),u=["jig","berry","tx"];class CacheWrapper{constructor(t=this){this.tag="Object"===t.constructor.name?"Cache":t.constructor.name,this.unwrappedCache=t,this.unwrappedGet=t.get,this.unwrappedSet=t.set,this.setWrappingEnabled(!0)}setWrappingEnabled(t){t?(this.get=CacheWrapper.prototype.wrappedGet,this.set=CacheWrapper.prototype.wrappedSet):(this.get=this.unwrappedGet,this.set=this.unwrappedSet)}async wrappedGet(t){if("string"!=typeof t||!t.length)throw new Error(`Invalid key: ${s(t)}`);r.tn&&r.qt(this.tag,"Get",t);const n=new Date,e=await this.unwrappedGet.call(this.unwrappedCache,t);if(r.Ut&&r.Dt(this.tag,"Get (end): "+(new Date-n)+"ms"),r.Ut&&r.Dt(this.tag,"Value:",JSON.stringify(e,0,3)),void 0!==e&&!h(e))throw new Error(`Invalid value retrieved for ${t}: ${e}`);return e}async wrappedSet(t,n){if("string"!=typeof t||!t.length)throw new Error(`Invalid key: ${s(t)}`);if(!h(n))throw new Error(`Cannot cache ${s(n)}`);if(u.includes(t.split("://")[0])){const e=await this.unwrappedGet.call(this.unwrappedCache,t);if(void 0!==e&&!i(n,e)){r.en&&r.Zt(this.tag,"Expected:",JSON.stringify(e,0,3)),r.en&&r.Zt(this.tag,"Actual:",JSON.stringify(n,0,3));throw new Error(`Attempt to set different values for the same key: ${t}\n\n${"This is an internal Run bug. Please report it to the library developers."}`)}}r.tn&&r.qt(this.tag,"Set",t),r.Ut&&r.Dt(this.tag,"Value:",JSON.stringify(n,0,3));const e=new Date,a=await this.unwrappedSet.call(this.unwrappedCache,t,n);if(r.Ut&&r.Dt(this.tag,"Set (end): "+(new Date-e)+"ms"),t.startsWith("jig://")&&"code"===n.kind){const n=await this.unwrappedGet.call(this.unwrappedCache,"config://code-filter")||o.create();o.add(n,t),await this.unwrappedSet.call(this.unwrappedCache,"config://code-filter",n)}return a}}function h(t){switch(typeof t){case"undefined":return!1;case"boolean":return!0;case"number":return Number.isFinite(t);case"string":return!0;case"object":return null===t||(a(t)?!Object.keys(t).some((n=>!h(t[n]))):!!c(t)&&(t.length===Object.keys(t).length&&!Object.keys(t).some((n=>!h(t[n])))));case"function":case"symbol":return!1}}t.exports=CacheWrapper},function(t,n,e){const r=e(2),{J:o,bt:i}=e(0),s=e(28),CacheWrapper=e(38);class LocalCache extends CacheWrapper{constructor(t={}){super(),this._c=new Map,this.mc=0,this.Oc=1e3*a(t.maxSizeMB)*1e3}get maxSizeMB(){return this.Oc/1e3/1e3}set maxSizeMB(t){this.Oc=1e3*a(t)*1e3,this.Pc()}get sizeBytes(){return this.mc}async get(t){const n=this._c.has(t),e=this._c.get(t);if(n)return this._c.delete(t),this._c.set(t,e),e}async set(t,n){const e=this._c.has(t);this._c.delete(t),this._c.set(t,n),e||(this.mc+=LocalCache.Ec(t),this.mc+=LocalCache.Ec(n),this.Pc())}clear(){r.Ut&&r.Dt("LocalCache","Clear"),this._c.clear(),this.mc=0}Pc(){if(!(this.mc<=i(this.Oc)))for(this.xc("config://code-filter"),this.xc("config://recent-broadcasts");this.mc>i(this.Oc);){const t=this._c.keys().next().value,n=this._c.get(t);if(t.startsWith("jig://")&&"code"===n.kind){const n=this._c.get("config://code-filter");n&&(s.remove(n,t),this._c.set("config://code-filter",n))}this._c.delete(t),this.mc-=LocalCache.Ec(t),this.mc-=LocalCache.Ec(n)}}static Ec(t){switch(typeof t){case"undefined":throw new Error("Cannot cache undefined");case"boolean":return 5;case"number":if(Number.isFinite(t))return 9;throw new Error(`Cannot cache number: ${o(t)}`);case"string":return 2*t.length+1;case"object":{if(!t)return 5;const n=Object.keys(t);let e=1+4*n.length;return n.forEach((n=>{e+=LocalCache.Ec(n),e+=LocalCache.Ec(t[n])})),e}case"function":throw new Error(`Cannot cache function: ${o(t)}`);case"symbol":throw new Error(`Cannot cache symbol: ${o(t)}`)}}xc(t){const n=this._c.get(t);void 0!==n&&(this._c.delete(t),this._c.set(t,n))}}function a(t){if(void 0===t)return 10;if("number"==typeof t&&!Number.isNaN(t)&&t>=0)return t;throw new Error(`Invalid maxSizeMB: ${o(t)}`)}t.exports=LocalCache},function(t,n,e){const r=e(6),{J:o}=e(0),i=e(2),s=e(28),LocalCache=e(39);class StateWrapper{constructor(t=this,n=new LocalCache){this.tag="Object"===t.constructor.name?"State":t.constructor.name,this.cache=n,this.unwrappedState=t,this.unwrappedPull=t.pull,this.unwrappedBroadcast=t.broadcast,this.unwrappedLocations=t.locations,this.setWrappingEnabled(!0)}setWrappingEnabled(t){t?(this.pull=StateWrapper.prototype.wrappedPull,this.broadcast=this.unwrappedBroadcast&&StateWrapper.prototype.wrappedBroadcast,this.locations=this.unwrappedLocations&&StateWrapper.prototype.wrappedLocations):(this.pull=this.unwrappedPull,this.broadcast=this.unwrappedBroadcast,this.locations=this.unwrappedLocations)}async wrappedPull(t,n){if("string"!=typeof t||!t.length)throw new Error(`Invalid key: ${o(t)}`);if(void 0!==n&&("object"!=typeof n||!n))throw new Error(`Invalid options: ${o(n)}`);n=n||{};const e=this.cache&&await this.cache.get(t);if(void 0!==e)return e;if(!n.filter){const t=await this.cache.get("config://code-filter");t&&(n.filter=s.toBase64(t))}i.tn&&i.qt(this.tag,"Pull",t,o(n));const r=new Date,a=await this.unwrappedPull.call(this.unwrappedState,t,n);return i.Ut&&i.Dt(this.tag,"Pull (end): "+(new Date-r)+"ms"),a&&this.cache&&await this.cache.set(t,a),a}async wrappedLocations(t){if("string"==typeof t)try{t=r.Script.fromAddress(t).toHex()}catch(n){try{t=new r.Script(t).toHex()}catch(n){throw new Error(`Invalid script: ${o(t)}`)}}else if(t instanceof r.Address)t=r.Script.fromAddress(t).toHex();else{if(!(t instanceof r.Script))throw new Error(`Invalid script: ${o(t)}`);t=t.toHex()}i.tn&&i.qt(this.tag,"Locations",t);const n=new Date;let e=await this.unwrappedLocations.call(this.unwrappedState,t);if(i.Ut&&i.Dt(this.tag,"Trusted (end): "+(new Date-n)+"ms"),!Array.isArray(e)||e.some((t=>"string"!=typeof t)))throw new Error(`Received invalid locations: ${o(e)}`);const s=new Set;return e=e.filter((t=>s.has(t)?(i.nn&&i.Xt(this.tag,"Duplicate utxo returned from server:",t),!1):(s.add(t),!0))),e}async wrappedBroadcast(t){if("string"!=typeof t||!t.length)throw new Error(`Invalid rawtx: ${o(t)}`);i.tn&&i.qt(this.tag,"Broadcast");const n=new Date;await this.unwrappedBroadcast.call(this.unwrappedState,t),i.Ut&&i.Dt(this.tag,"Broadcast (end): "+(new Date-n)+"ms")}}t.exports=StateWrapper},function(t,n,e){const r=e(6),o=e(61),i=e(2),LocalCache=e(39),{J:s,ft:a}=e(0),c=/^(?:[a-fA-F0-9][a-fA-F0-9])*$/;class BlockchainWrapper{constructor(t=this,n=new LocalCache){this.tag="Object"===t.constructor.name?"Blockchain":t.constructor.name,this.cache=n,this.unwrappedBlockchain=t,this.unwrappedBroadcast=t.broadcast,this.unwrappedFetch=t.fetch,this.unwrappedUtxos=t.utxos,this.unwrappedSpends=t.spends,this.unwrappedTime=t.time,this!==this.unwrappedBlockchain&&a(this,"network",(()=>this.unwrappedBlockchain.network)),this.setWrappingEnabled(!0)}setWrappingEnabled(t){t?(this.broadcast=BlockchainWrapper.prototype.wrappedBroadcast,this.fetch=BlockchainWrapper.prototype.wrappedFetch,this.utxos=BlockchainWrapper.prototype.wrappedUtxos,this.spends=BlockchainWrapper.prototype.wrappedSpends,this.time=BlockchainWrapper.prototype.wrappedTime):(this.broadcast=this.unwrappedBroadcast,this.fetch=this.unwrappedFetch,this.utxos=this.unwrappedUtxos,this.spends=this.unwrappedSpends,this.time=this.unwrappedTime)}async wrappedBroadcast(t){let n=null;try{n=new r.Transaction(t)}catch(t){throw new Error(`Invalid transaction: ${s(t.toString())}`)}if(t="string"==typeof t?t:n.toString(),0===n.inputs.length)throw new Error("tx has no inputs");if(0===n.outputs.length)throw new Error("tx has no outputs");try{if(!0!==n.verify())throw new Error(n.verify())}catch(t){throw t.message.includes("duplicate input")?new Error("bad-txns-inputs-duplicate"):t}if(this.cache){const n=await this.cache.get("config://recent-broadcasts"),e=n&&n.find((n=>n.rawtx===t));if(e)return i.tn&&i.qt(this.tag,"Already broadcasted",e.txid),e.txid}i.tn&&i.qt(this.tag,"Broadcast",n.hash);const e=new Date,a=await this.unwrappedBroadcast.call(this.unwrappedBlockchain,t);i.Ut&&i.Dt(this.tag,"Broadcast (end): "+(new Date-e)+"ms");if("string"!=typeof a||64!==a.length||!c.test(a))throw new Error(`Invalid response txid: ${a}`);if(i.Ut&&n.hash!==a)throw new Error(`Txid response mismatch: ${a}`);if(this.cache){const e=[];if(void 0===await this.cache.get(`time://${a}`)){const t=this.cache.set(`time://${a}`,Date.now());t instanceof Promise&&t.catch((t=>{})),e.push(t)}for(const t of n.inputs){const n=`${t.prevTxId.toString("hex")}_o${t.outputIndex}`;e.push(this.cache.set(`spend://${n}`,a))}e.push(this.cache.set(`tx://${a}`,t)),e.push(o.vc(this.cache,n,a)),await Promise.all(e)}return a}async wrappedFetch(t){if("string"!=typeof t||64!==t.length||!c.test(t))throw new Error(`Invalid txid: ${s(t)}`);const n=this.cache?await this.cache.get(`tx://${t}`):void 0;if(void 0!==n)return n;i.tn&&i.qt(this.tag,"Fetch",t);const e=new Date,o=await this.unwrappedFetch.call(this.unwrappedBlockchain,t);if(i.Ut&&i.Dt(this.tag,"Fetch (end): "+(new Date-e)+"ms"),"string"!=typeof o||!o.length||!c.test(o))throw new Error(`Invalid rawtx fetched for ${t}: ${o}`);if(i.Ut&&new r.Transaction(o).hash!==t)throw new Error(`Transaction fetch mismatch for ${t}`);if(this.cache){const n=[];n.push(this.cache.set(`tx://${t}`,o));new r.Transaction(o).inputs.forEach((e=>{const r=`${e.prevTxId.toString("hex")}_o${e.outputIndex}`;n.push(this.cache.set(`spend://${r}`,t))})),await Promise.all(n)}return o}async wrappedUtxos(t){if("string"==typeof t)try{t=r.Script.fromAddress(t).toHex()}catch(n){try{t=new r.Script(t).toHex()}catch(n){throw new Error(`Invalid script: ${s(t)}`)}}else if(t instanceof r.Address)t=r.Script.fromAddress(t).toHex();else{if(!(t instanceof r.Script))throw new Error(`Invalid script: ${s(t)}`);t=t.toHex()}i.tn&&i.qt(this.tag,"Utxos",t);const n=new Date;let e=await this.unwrappedUtxos.call(this.unwrappedBlockchain,t);if(i.Ut&&i.Dt(this.tag,"Utxos (end): "+(new Date-n)+"ms"),!Array.isArray(e)||e.some((t=>"string"!=typeof t.txid||(64!==t.txid.length||(!c.test(t.txid)||("number"!=typeof t.vout||(!Number.isInteger(t.vout)||(t.vout<0||("string"!=typeof t.script||(!c.test(t.script)||("number"!=typeof t.satoshis||(!Number.isInteger(t.satoshis)||(t.satoshis<0||void 0)))))))))))))throw new Error(`Received invalid utxos: ${s(e)}`);const a=new Set;return e=e.filter((t=>{const n=`${t.txid}_o${t.vout}`;return a.has(n)?(i.nn&&i.Xt(this.tag,"Duplicate utxo returned from server:",n),!1):(a.add(n),!0)})),this.cache&&await o.$c(this.cache,e,t),e}async wrappedSpends(t,n){if("string"!=typeof t||64!==t.length||!c.test(t))try{const e=t.split("_o");t=e[0],n=parseInt(e[1]);if("string"!=typeof t||64!==t.length||!c.test(t))throw new Error}catch(n){throw new Error(`Invalid txid: ${s(t)}`)}if("number"!=typeof n||!Number.isInteger(n)||n<0)throw new Error(`Invalid vout: ${s(n)}`);const e=this.cache?await this.cache.get(`spend://${t}_o${n}`):void 0;if(void 0!==e)return e;i.tn&&i.qt(this.tag,`Spends ${t}_o${n}`);const r=new Date,o=await this.unwrappedSpends.call(this.unwrappedBlockchain,t,n);if(i.Ut&&i.Dt(this.tag,"Spends (end): "+(new Date-r)+"ms"),null!==o&&("string"!=typeof o||64!==o.length||!c.test(o)))throw new Error(`Invalid spend txid fetched for ${t}_o${n}: ${o}`);return o&&this.cache&&await this.cache.set(`spend://${t}_o${n}`,o),o}async wrappedTime(t){if("string"!=typeof t||64!==t.length||!c.test(t))throw new Error(`Invalid txid: ${s(t)}`);const n=this.cache?await this.cache.get(`time://${t}`):void 0;if(void 0!==n)return n;i.tn&&i.qt(this.tag,"Time",t);const e=new Date,r=await this.unwrappedTime.call(this.unwrappedBlockchain,t);if(i.Ut&&i.Dt(this.tag,"Time (end): "+(new Date-e)+"ms"),"number"!=typeof r||r<0)throw new Error(`Invalid time fetched for ${t}: ${r}`);return this.cache&&await this.cache.set(`time://${t}`,r),r}}t.exports=BlockchainWrapper},function(t,n){var e;e=function(){return this}();try{e=e||new Function("return this")()}catch(t){"object"==typeof window&&(e=window)}t.exports=e},function(t,n,e){const r=e(6),{D:o,M:i}=e(0),s=e(9),{Jr:a}=e(12),{ClientModeError}=e(11),c=["load","sync","publish","update"];class u{constructor(){this.re=void 0,this.lo=void 0,this._o=void 0,this.Mn=void 0,this.ss=void 0,this.ws=void 0,this.Ba=[],this.Hn=1e8,this._t=1e4,this.fo=new Set,this._s=!0,this.yo=!1,this.Ir=!1}Re(){u.U!==this&&(u.U&&u.U.Te(),u.U=this,r.Networks.defaultNetwork=r.Networks[i(this.re.network)],s.Re())}Te(){u.U&&(s.Te(),u.U=null)}pr(t,n){o(c.includes(t)),this.Ba.filter((n=>n.Ma===t)).forEach((e=>e.La(t,n)))}async mo(t,n){return this.fo.has("*")||this.fo.has(t)||"state"===n&&this.fo.has("state")||await this.lo.pull(`trust://${t}`)}async bo(t){const n=await this.lo.pull(`tx://${t}`);if(void 0!==n)return n;if(this.yo)throw new ClientModeError(t,"transaction");return await this.re.fetch(t)}async Es(t,n){const e=await this.lo.pull(`spend://${t}_o${n}`);return void 0!==e?e:this.yo?void 0:await this.re.spends(t,n)}async ec(t){const n=await this.lo.pull(`time://${t}`);return void 0!==n?n:this.yo?void 0:await this.re.time(t)}}u.U=null,u.Ur=a,u.Da=c,t.exports=u},function(t,n,e){const r=e(9);class CommonLock{constructor(t,n){this.address=t,this.testnet=n}script(){if("string"!=typeof this.address)throw new Error(`Address is not a string: ${this.address}`);const t=[],n=[];let e,r,o;const i=this.address;for(let s=0;s<i.length;s++){if(e=0,r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".indexOf(i[s]),r<0)throw new Error(`Invalid character in address: ${i}\n\nDetails: i=${s}, c=${i[s]}`);for(r||n.length^s||n.push(0);e in t||r;)o=t[e],o=o?58*o+r:r,r=o>>8,t[e]=o%256,e++}for(;e--;)n.push(t[e]);if(n.length<6)throw new Error(`Address too short: ${i}`);if(0!==n[0]&&111!==n[0])throw new Error(`Address may only be a P2PKH type: ${i}`);if(!0===this.testnet&&0===n[0]||!1===this.testnet&&111===n[0])throw new Error("Invalid network");return[118,169,20,...n.slice(1,n.length-4),136,172].map((t=>t.toString("16"))).map((t=>1===t.length?"0"+t:t)).join("")}domain(){return 108}}CommonLock.sealed=!0,CommonLock.toString();const o=r.Yt();r.Tt(o).Wt(CommonLock,!0),t.exports=o},function(t,n,e){const r=e(6),o=e(2),{D:i,H:s,ut:a,v:c,S:u,J:h}=e(0),{so:f}=e(17),{In:l,Dn:d}=e(8),{h:p}=e(4),{Ur:b}=e(12),w=e(9),y=e(20),g=e(23),_=e(18),m=e(5),{ro:O}=e(15),{TrustError}=e(11);class P{constructor(t,n){i(n instanceof Promise),this.po=t,this.do=n}}t.exports=async function(t,n,i,E,v,x){o.tn&&o.qt("Recreate","Recreate",t),O(n.version);let A=null;if("berry"===n.kind||i&&!E.fo.has("state")){const e=f(n),o=new r.deps.Buffer(e,"utf8");if(A=(await b(o)).toString("hex"),i&&A!==i){const e=`Cannot recreate ${t} from an incorrect state`,r=`State: ${JSON.stringify(n)}`;throw new Error(`${e}\n\n${r}\n\n${"Hint: Is the cache corrupted or returning wrong values?"}`)}}const $=new Map,S={g:m.g,jo:t=>($.set(t,null),(t=>{class n{}return n.location=t,n})(t))},k=_.ko(n.props,S);switch(n.cls&&_.ko(n.cls,S),n.kind){case"code":{const r=t.split("_")[0];return async function(t,n,r,o,i,c,u){const h={},f=n.origin.startsWith("_")?o:n.origin.slice(0,64);try{if(!await i.mo(f,"state"))throw new TrustError(f,"state")}catch(t){if(!await i.mo(o,"state"))throw new TrustError(o,"state")}const b=s(t.src);if(b){const t=n.deps[b].location,s=d(Object.assign({Rn:o},l(t))),a=e(16),f=await a(s,void 0,i,c,u,!1);r.set(t,f),h[b]=f}const y=w.Yt(),g=m.dn(t.src,h)[0],[O,E]=w.Ne(y,g),v=!1;w.Tt(y).ie(O,v);const x=async()=>{for(const t of r.keys()){if(r.get(t))continue;const n=d(Object.assign({Rn:o},l(t))),s=e(16),a=await s(n,void 0,i,c,u,!1);r.set(t,a)}const n={g:m.g,jo:t=>{const n=r.get(t),e=d(Object.assign({Rn:o},l(t)));if(!n)throw new Error(`Jig not loaded: ${e}`);return n}},s=_.ko(t.props,n);p((()=>{Object.keys(y).forEach((t=>{delete y[t]})),Object.keys(s).forEach((t=>a(y,t,s[t])))})),p((()=>{y.location=d(Object.assign({Rn:o},l(y.location))),y.origin=d(Object.assign({Rn:o},l(y.origin)))})),p((()=>{const t=w.Ce(y,E,y.deps);a(y,"deps",t),Object.keys(s.deps||{}).forEach((t=>{y.deps[t]=s.deps[t]}))})),i.pr("load",y)},A=x();return new P(y,A)}(n,k,$,r,E,v,x)}case"jig":{const r=t.split("_")[0];return async function(t,n,r,o,i,s,u){const h=!0,f=g.Sn(h),b=new y(n,f);async function w(){for(const t of r.keys()){if(r.get(t))continue;const n=d(Object.assign({Rn:o},l(t))),a=e(16),c=await a(n,void 0,i,s,u,!1);r.set(t,c)}const n=r.get(t.cls.$jig);p((()=>Object.setPrototypeOf(b,n.prototype)));const c={g:m.g,jo:t=>{const n=r.get(t),e=d(Object.assign({Rn:o},l(t)));if(!n)throw new Error(`Jig not loaded: ${e}`);return n}},h=_.ko(t.props,c);p((()=>{Object.keys(h).forEach((t=>{a(b,t,h[t])}))})),p((()=>{b.location=d(Object.assign({Rn:o},l(b.location))),b.origin=d(Object.assign({Rn:o},l(b.origin)))})),i.pr("load",b)}c.add(b);const O=w();return new P(b,O)}(n,k,$,r,E,v,x)}case"berry":return async function(t,n,r,o,i,s,c){const h=!0,f=g.Yr(h),b=new y(n,f);async function w(){for(const t of r.keys()){if(r.get(t))continue;const n=d(Object.assign({_hash:o},l(t))),a=e(16),u=await a(n,void 0,i,s,c,!1);r.set(t,u)}const B=r.get(t.cls.$jig);p((()=>Object.setPrototypeOf(b,B.prototype)));const n={g:m.g,jo:t=>{const n=r.get(t),e=d(Object.assign({_hash:o},l(t)));if(!n)throw new Error(`Jig not loaded: ${e}`);return n}},u=_.ko(t.props,n);p((()=>{Object.keys(u).forEach((t=>{a(b,t,u[t])}))})),p((()=>{b.location=d(Object.assign({_hash:o},l(b.location))),b.origin=d(Object.assign({_hash:o},l(b.origin)))})),i.pr("load",b)}u.add(b);const O=w();return new P(b,O)}(n,k,$,A,E,v,x);default:{const e=`Cannot recreate ${t} from an invalid state`,r=`Invalid jig kind: ${h(n.kind)}`;throw new Error(`${e}\n\n${r}`)}}}},function(t,n,e){const r=e(2),o=/^(?:[a-fA-F0-9][a-fA-F0-9])*$/;class OwnerWrapper{constructor(t=this){this.tag="Object"===t.constructor.name?"Owner":t.constructor.name,this.unwrappedOwner=t,this.unwrappedNextOwner=t.nextOwner,this.unwrappedSign=t.sign,this.setWrappingEnabled(!0)}setWrappingEnabled(t){t?(this.nextOwner=OwnerWrapper.prototype.wrappedNextOwner,this.sign=OwnerWrapper.prototype.wrappedSign):(this.nextOwner=this.unwrappedNextOwner,this.sign=this.unwrappedSign)}async wrappedNextOwner(){r.tn&&r.qt(this.tag,"Next owner");const t=new Date,n=await this.unwrappedNextOwner.call(this.unwrappedOwner);return r.Ut&&r.Dt(this.tag,"Next owner (end): "+(new Date-t)+"ms"),n}async wrappedSign(t,n,e){if(n=n||[],e=e||[],"string"!=typeof t||!o.test(t))throw new Error(`Invalid tx to sign: ${t}`);r.tn&&r.qt(this.tag,"Sign");const i=new Date,s=await this.unwrappedSign.call(this.unwrappedOwner,t,n,e);if(r.Ut&&r.Dt(this.tag,"Sign (end): "+(new Date-i)+"ms"),"string"!=typeof s||!o.test(s))throw new Error(`Invalid signed tx: ${s}`);return s}}t.exports=OwnerWrapper},function(t,n,e){const r=e(48),o=e(72),i=e(73),s=r(o),a=r(i),c={asm:s["284ce17fd34c0f41835435b03eed149c4e0479361f40132312b4001093bb158f_o1"],B:s["05f67252e696160a7c0099ae8d1ec23c39592378773b3a5a55f16bd1286e7dcb_o3"],Base58:s["81bcef29b0e4ed745f3422c0b764a33c76d0368af2d2e7dd139db8e00ee3d8a6_o1"],expect:s["71fba386341b932380ec5bfedc3a40bce43d4974decdc94c419a94a8ce5dfc23_o1"],Group:s["780ab8919cb89323707338070323c24ce42cdec2f57d749bd7aceef6635e7a4d_o1"],Hex:s["727e7b423b7ee40c0b5be87fba7fa5673ea2d20a74259040a7295d9c32a90011_o1"],NFT:s.b2f52f369d6ac4210585e0d173020106bd338197f136e02bc4d1fb2af3ef789f_o1,sha256:s["3b7ef411185bbe3d01caeadbe6f115b0103a546c4ef0ac7474aa6fbb71aff208_o1"],Token:s["72a61eb990ffdb6b38e5f955e194fed5ff6b014f75ac6823539ce5613aea0be8_o1"],Token10:s.b17a9af70ab0f46809f908b2e900e395ba40996000bf4f00e3b27a1e93280cf1_o1,Token20:s["72a61eb990ffdb6b38e5f955e194fed5ff6b014f75ac6823539ce5613aea0be8_o1"],Tx:s["05f67252e696160a7c0099ae8d1ec23c39592378773b3a5a55f16bd1286e7dcb_o1"],txo:s["05f67252e696160a7c0099ae8d1ec23c39592378773b3a5a55f16bd1286e7dcb_o2"]},u={asm:a["03e21aa8fcf08fa6985029ad2e697a2309962527700246d47d891add3cfce3ac_o1"],B:a.d476fd7309a0eeb8b92d715e35c6e273ad63c0025ff6cca927bd0f0b64ed88ff_o3,Base58:a["424abf066be56b9dd5203ed81cf1f536375351d29726d664507fdc30eb589988_o1"],expect:a.f97d4ac2a3d6f5ed09fad4a4f341619dc5a3773d9844ff95c99c5d4f8388de2f_o1,Group:a["63e0e1268d8ab021d1c578afb8eaa0828ccbba431ffffd9309d04b78ebeb6e56_o1"],Hex:a["1f0abf8d94477b1cb57629d861376616f6e1d7b78aba23a19da3e6169caf489e_o2"],NFT:a["8554b58e95bbd7a1899b54ca1318cc3ce140c6cd7ed64789dcaf5ea5dcfdb1f1_o1"],sha256:a["4a1929527605577a6b30710e6001b9379400421d8089d34bb0404dd558529417_o1"],Token:a["7d14c868fe39439edffe6982b669e7b4d3eb2729eee7c262ec2494ee3e310e99_o1"],Token10:a["0bdf33a334a60909f4c8dab345500cbb313fbfd50b1d98120227eae092b81c39_o1"],Token20:a["7d14c868fe39439edffe6982b669e7b4d3eb2729eee7c262ec2494ee3e310e99_o1"],Tx:a.d476fd7309a0eeb8b92d715e35c6e273ad63c0025ff6cca927bd0f0b64ed88ff_o1,txo:a.d476fd7309a0eeb8b92d715e35c6e273ad63c0025ff6cca927bd0f0b64ed88ff_o2};c.states=o,u.states=i,t.exports.main={},t.exports.test={},Object.assign(t.exports.main,c),Object.assign(t.exports.test,u),Object.assign(t.exports,c)},function(t,n,e){const r=e(58),o=e(59),i=e(60),{In:s}=e(8);t.exports=function(t){const n={},e={};for(const[o,a]of Object.entries(t)){if(!o.startsWith("jig://")&&!o.startsWith("berry://"))continue;const t=o.split("://")[1];s(t),i(a),e[t]=o,n[t]=r(t,a)}for(const[r,i]of Object.entries(n))o(i,r,t[e[r]],n);return n}},function(t,n,e){const r=e(6),o=e(2),{J:i}=e(0),s=/^(?:[a-fA-F0-9][a-fA-F0-9])*$/;class PurseWrapper{constructor(t=this,n=null){this.tag="Object"===t.constructor.name?"Purse":t.constructor.name,this.blockchain=n,this.unwrappedPurse=t,this.unwrappedPay=t.pay,this.unwrappedBroadcast=t.broadcast,this.unwrappedCancel=t.cancel,this.setWrappingEnabled(!0)}setWrappingEnabled(t){t?(this.pay=PurseWrapper.prototype.wrappedPay,this.broadcast=this.unwrappedBroadcast&&PurseWrapper.prototype.wrappedBroadcast,this.cancel=this.unwrappedCancel&&PurseWrapper.prototype.wrappedCancel):(this.pay=this.unwrappedPay,this.broadcast=this.unwrappedBroadcast,this.cancel=this.unwrappedCancel)}async wrappedPay(t,n){t instanceof r.Transaction&&(t=t.toString());const e=()=>{throw new Error(`Invalid tx to pay: ${i(t)}`)};"string"==typeof t&&s.test(t)||e();try{new r.Transaction(t)}catch(t){e()}void 0===n&&(n=[]);if(!Array.isArray(n)||n.some((t=>"string"!=typeof t.script))||n.some((t=>"number"!=typeof t.satoshis)))throw new Error(`Invalid parents: ${i(n)}`);o.tn&&o.qt(this.tag,"Pay");const a=new Date,c=await this.unwrappedPay.call(this.unwrappedPurse,t,n);if(o.Ut&&o.Dt(this.tag,"Pay (end): "+(new Date-a)+"ms"),"string"!=typeof c||!s.test(c))throw new Error(`Invalid paid tx: ${c}`);return c}async wrappedBroadcast(t){const n=()=>{throw new Error(`Invalid tx to broadcast: ${i(t)}`)};"string"==typeof t&&s.test(t)||n();try{new r.Transaction(t)}catch(t){n()}o.tn&&o.qt(this.tag,"Broadcast");const e=new Date,a=await this.unwrappedBroadcast.call(this.unwrappedPurse,t);return o.Ut&&o.Dt(this.tag,"Broadcast (end): "+(new Date-e)+"ms"),a}async wrappedCancel(t){const n=()=>{throw new Error(`Invalid tx to cancel: ${i(t)}`)};"string"==typeof t&&s.test(t)||n();try{new r.Transaction(t)}catch(t){n()}o.tn&&o.qt(this.tag,"Cancel");const e=new Date,a=await this.unwrappedCancel.call(this.unwrappedPurse,t);return o.Ut&&o.Dt(this.tag,"Cancel (end): "+(new Date-e)+"ms"),a}}t.exports=PurseWrapper},function(t,n,e){const r=e(64),{Po:o,Eo:i,xo:s}=e(17),{h:a}=e(4),{hn:c}=e(24);t.exports=class{constructor(){const t=`var n=${c(s.toString())};var m=${c(o.toString())};m(n);`,n=`(()=>{\n ${r};\n ${t};\n SES.lockdown();\n var C = this.Compartment;\n delete this.SES;\n delete this.Compartment;\n return C\n })()`;{const t=document.createElement("iframe");t.style||(t.style={}),t.style.display="none",document.documentElement.appendChild(t),this.iframeEval=t.contentWindow.eval,this.Compartment=this.iframeEval(n)}this.globalOverrides={},i.forEach((t=>{this.globalOverrides[t]=void 0}));const e=this.jc();e.global.c=console,e.global.s=a,this.globalOverrides.console=e.evaluate("\n const o = { }\n Object.keys(c).forEach(name => {\n o[name] = (...args) => s(() => c[name](...args))\n })\n o\n ")}makeCompartment(){const t=this.jc();Object.assign(t.global,this.globalOverrides);return{evaluate:n=>(this.Ic(n),t.evaluate(n)),global:new Proxy({},{set:(n,e,r)=>(n[e]=t.global[e]=r,!0),deleteProperty:(n,e)=>(delete n[e],e in this.globalOverrides?t.global[e]=this.globalOverrides[e]:delete t.global[e],!0),defineProperty:(n,e,r)=>(Object.defineProperty(n,e,r),Object.defineProperty(t.global,e,r),!0)})}}jc(){return new this.Compartment}Ic(t){if(/for\s*\([^)]+\s+in\s+\S+\)/g.test(t))throw new Error("for-in loops are not supported")}}},function(t,n,e){const r=e(5),{J:o}=e(0),{rn:i}=e(4),{ArgumentError}=e(11),s=r.g,a=new WeakMap;function c(t){const n=a.get(t);if(!n)throw new ArgumentError(`Not a dynamic type: ${o(t)}`);return n}function u(){const t=a.get(this),n=t?t.Ee:this;return s.Function.prototype.toString.apply(n)}class h{constructor(){const t=r.dn("function dynamic() {}")[0],n=n=>{delete t.prototype[n]};Object.getOwnPropertyNames(t.prototype).forEach(n),Object.getOwnPropertySymbols(t.prototype).forEach(n);const e={},o=new l,i=new Proxy(e,o),s=Object.getPrototypeOf(t.prototype);Object.setPrototypeOf(e,s),Object.setPrototypeOf(t.prototype,i),Object.freeze(t.prototype);const c=new f;o.zn(i,c);const u=new Proxy(t,c);return c.zn(t,e,u),a.set(u,c),u}static ce(t){return c(t).Ee}static pe(t,n){c(t).pe(n)}static Tc(t){return c(t).Rc}static ve(t,n){c(t).ve(n)}}class f{zn(t,n,e){this.Nc=t,this.Ee=t,this.Rc=e,this.Co=e,this.Cc=n}apply(t,n,e){return Reflect.apply(this.Ee,n,e)}construct(t,n,e){let r=e;try{r=h.Tc(e)}catch(t){}return Reflect.construct(this.Ee,n,r)}defineProperty(t,n,e){if("prototype"===n)throw new Error("Cannot define prototype");if("toString"===n)throw new Error("Cannot define toString");if(!e.configurable)throw new Error("Cannot define nonconfigurable property");return Reflect.defineProperty(this.Ee,n,e),!0}deleteProperty(t,n){if("prototype"===n)throw new Error("Cannot delete prototype");if("toString"===n)throw new Error("Cannot delete toString");return Reflect.deleteProperty(this.Ee,n),!0}get(t,n,e){return"prototype"===n?this.Nc.prototype:"toString"===n?u:Reflect.get(this.Ee,n,e)}getPrototypeOf(t){return Reflect.getPrototypeOf(this.Ee)}getOwnPropertyDescriptor(t,n){if("prototype"===n)return Object.getOwnPropertyDescriptor(this.Nc,n);const e=Reflect.getOwnPropertyDescriptor(this.Ee,n);if(!e)return e;const r=Reflect.getOwnPropertyDescriptor(t,n);return r&&!r.configurable||(e.configurable=!0),e}has(t,n){return Reflect.has(this.Ee,n)}isExtensible(t){return Reflect.isExtensible(this.Nc)}ownKeys(t){return Reflect.ownKeys(this.Ee)}preventExtensions(t){return Object.preventExtensions(this.Nc),Object.preventExtensions(this.Ee),!0}set(t,n,e,r){if("prototype"===n)throw new Error("Cannot set prototype");if("toString"===n)throw new Error("Cannot set toString");return Reflect.set(this.Ee,n,e),!0}setPrototypeOf(t,n){return Reflect.setPrototypeOf(this.Ee,n),!0}pe(t){if("function"!=typeof t)throw new ArgumentError(`Inner type must be a function type: ${o(t)}`);let n=t;for(;n&&n!==Function.prototype&&n!==s.Function.prototype;){if(Object.getOwnPropertyNames(n).includes("toString"))throw new ArgumentError(`toString is a reserved property: ${t}`);n=Reflect.getPrototypeOf(n)}Reflect.isExtensible(this.Nc)&&Reflect.isExtensible(t)||(Reflect.preventExtensions(this.Nc),Reflect.preventExtensions(t));const e=this.Ee===this.Nc||t===this.Nc,r=this.Ee.toString().startsWith("class"),i=t.toString().startsWith("class");if(!e&&r!==i)throw new ArgumentError(`Classes can only be changed to classes and functions to functions: ${o(t)}`);const a=t=>{delete this.Cc[t]};Object.getOwnPropertyNames(this.Cc).forEach(a),Object.getOwnPropertySymbols(this.Cc).forEach(a);const c=Reflect.getPrototypeOf(t.prototype);Reflect.setPrototypeOf(this.Cc,c);Object.getOwnPropertyNames(t.prototype).concat(Object.getOwnPropertySymbols(t.prototype)).forEach((n=>{const e=Reflect.getOwnPropertyDescriptor(t.prototype,n);Reflect.defineProperty(this.Cc,n,e)})),this.Cc.constructor=this.Rc,this.Ee=t}ve(t){this.Rc!==this.Co&&a.delete(this.Rc),a.set(t,this),this.Rc=t,this.Cc.constructor=t}}class l{zn(t,n){this.Co=t,this.Fc=n}defineProperty(t,n,e){throw new Error("defineProperty disabled")}deleteProperty(t,n){throw new Error("deleteProperty disabled")}preventExtensions(){throw new Error("preventExtensions disabled")}set(t,n,e,r){if(r===this.Co)throw new Error("Cannot set property");const o=Reflect.getPrototypeOf(r);try{return Reflect.setPrototypeOf(r,Reflect.getPrototypeOf(Object)),r[n]=e,!0}catch(t){throw new Error("Cannot set property")}finally{Reflect.setPrototypeOf(r,o)}}setPrototypeOf(t,n){if(!i())throw new Error("setPrototypeOf disabled");return Reflect.setPrototypeOf(t,n),Reflect.setPrototypeOf(this.Fc.Ee.prototype,n),!0}}t.exports=h},function(t,n){t.exports=class{constructor(){this.tasks=[]}async os(t){return new Promise(((n,e)=>{this.tasks.push({func:t,reject:e,resolve:n}),1===this.tasks.length&&this.Uc()}))}async Uc(){const t=this.tasks[0];try{const n=t.func();t.resolve(n instanceof Promise?await n:n)}catch(n){t.reject(n)}finally{this.tasks.shift(),this.tasks.length&&this.Uc()}}}},function(t,n,e){const r=e(2),{D:o,J:i,Z:s}=e(0),{In:a}=e(8),{h:c}=e(4),{io:u}=e(15),h=e(18);t.exports={bs:async function(t,n,e,a,f){r.Ut&&r.Dt("Capture","Capture",i(t));const l=n.Tn,d=n.fs.get(t);o(d);const p=await n.hs(f);f.Pt();const b={Ao:t=>{const r=e.get(t);if(s(r))return`_o${n.gs.outputs.length+1+r}`;const i=a.get(t);if(s(i))return`_d${i}`;const u=l.qe.Tt(t);if(u)return l.Xe.get(u).wr.location;const h=c((()=>t.origin));if(h.startsWith("native://"))return h;const f=p[h]&&p[h][0];return o(f),f}},w={};d.hc&&(w.cls=h.$o(d.hc,b)),w.kind=d.uc;const y=Object.assign({},d.wr),g=e.get(t),_=a.get(t),m=s(g)?`_o${n.gs.outputs.length+1+g}`:`_d${_}`;return y.location=m,o(!y.origin.startsWith("record://")||y.origin.startsWith(`record://${l.Me}`)),y.origin.startsWith(`record://${l.Me}`)&&(y.origin=m),w.props=h.$o(y,b),d.Nt&&(w.src=d.Nt),w.version=u(n.jn),w},wo:function(t,n){const e={Ao:t=>{const n=c((()=>t.location)),e=a(n);return o(s(e.Rn)&&!s(e.Tn)&&!s(e.Zt)),n}},r={};r.cls=h.$o(t.constructor,e),r.kind="berry";const i=c((()=>Object.assign({},t)));return r.props=h.$o(i,e),r.version=u(n),r}}},function(t,n,e){const r=e(6),{D:o,J:i,yt:s,Z:a,F:c}=e(0),u=e(2),{rt:h,Qr:f}=e(14),{h:l}=e(4),{In:d}=e(8),{ao:p}=e(34),b="Sync";t.exports=async function(t,n={}){const Jig=e(7),Code=e(1),w=e(9);if(e(27).Bt)throw new Error("sync disabled in atomic update");o(t instanceof Jig||t instanceof Code);const y=c();n._t=n._t||new s("sync",y._t),n.Dc=n.Dc||new Map,u.tn&&u.qt(b,"Sync",i(t));const g=new Date;if(n.Dc.has(t))return;t instanceof Code&&l((()=>d(t.location))).Un&&w.Tt(t).vn();let _=!1,m=null;const O=async function(){try{_=await async function(t,n,r){const o=e(37);let s=!1;for(;;){const e=l((()=>t.location)),r=d(e);if(a(r.Zt))throw new Error(`Cannot sync\n\n${r.Zt}`);if(!a(r.Tn))break;u.Ut&&u.Dt(b,`Waiting to publish ${i(t)}`),s=!0;const c=o.Cr(r.Tn);if(!c)throw new Error(`Cannot sync ${i(t)}: transaction in progress`);u.Ut&&u.Dt(b,"Sync",c.Tn.Me),await c.yc(),n._t.Pt()}return r.pr("sync",t),s}(t,n,y)}catch(t){m=t}n._t.Pt();try{_||await async function(t,n,s){if(!1===n.forward)return;let c=l((()=>t.location)),h=d(c);for(;n._t.Pt(),!a(h.Cn);){if(a(h.Tn))throw new Error(`Cannot sync ${i(t)}: transaction in progress`);o(a(h.Rn)&&a(h.Nn));const f=await s.Es(h.Rn,h.Nn);if(!f)break;n._t.Pt(),u.tn&&u.qt(b,"Forward syncing to",f);const w=await s.bo(f);n._t.Pt();const y=new r.Transaction(w);let g=null;try{g=p(y)}catch(t){u.en&&u.Zt(b,t);break}const _=e(35),m=!0,O=t,P=!1;await _(y,f,g,s,m,O,n._t,P),n._t.Pt(),c=l((()=>t.location)),h=d(c)}s.pr("sync",t)}(t,n,y)}catch(t){m=m||t}return n._t.Pt(),t}();n.Dc.set(t,O),n.Dc.set(l((()=>t.origin)),O),await O;try{await async function(t,n,r){if(!1===n.inner)return;if(void 0===n.inner&&r)return;u.Ut&&u.Dt(b,"Inner sync");const Jig=e(7),Code=e(1),o=new Set;l((()=>h(t,(n=>n===t||(n instanceof Jig||n instanceof Code?(o.add(n),!1):void 0)))));const i=[],s=new Map;for(const t of o){const e=n.Dc.get(t)||n.Dc.get(l((()=>t.origin)));!1!==n.forward&&e?s.set(t,e):i.push(t.sync(n))}await Promise.all(i);for(const t of s.keys())s.set(t,await s.get(t));n._t.Pt(),!1!==n.forward&&l((()=>f(t,(t=>s.get(t)))))}(t,n,_)}catch(t){if(!m)throw t}if(n._t.Pt(),m)throw m;u.Ut&&u.Dt(b,"Sync (end): "+(new Date-g)+"ms")}},function(t,n,e){const{NotImplementedError}=e(11);class r{get network(){throw new NotImplementedError}async broadcast(t){throw new NotImplementedError}async fetch(t){throw new NotImplementedError}async utxos(t){throw new NotImplementedError}async time(t){throw new NotImplementedError}async spends(t,n){throw new NotImplementedError}static[Symbol.hasInstance](t){return("object"==typeof t||"function"==typeof t)&&(!!t&&("string"==typeof t.network&&("function"==typeof t.broadcast&&("function"==typeof t.fetch&&("function"==typeof t.utxos&&("function"==typeof t.time&&"function"==typeof t.spends))))))}}class o{async get(t){throw new NotImplementedError}async set(t,n){throw new NotImplementedError}static[Symbol.hasInstance](t){return("object"==typeof t||"function"==typeof t)&&(!!t&&("function"==typeof t.get&&"function"==typeof t.set))}}class i{script(){throw new NotImplementedError}domain(){throw new NotImplementedError}static[Symbol.hasInstance](t){if("object"!=typeof t||!t)return!1;if("function"!=typeof t.constructor.prototype.script)return!1;if(Object.getOwnPropertyNames(t).includes("script"))return!1;const n=t.script();if(n.length%2!=0)return!1;const e="01234567890abcdefABCDEF".split("");if(n.split("").some((t=>!e.includes(t))))return!1;return"function"==typeof t.constructor.prototype.domain&&(!Object.getOwnPropertyNames(t).includes("domain")&&(!!Number.isSafeInteger(t.domain())&&!(t.domain()<0)))}}class s{info(...t){}debug(...t){}warn(...t){}error(...t){}static[Symbol.hasInstance](t){return!Array.isArray(t)&&(("object"==typeof t||"function"==typeof t)&&!!t)}}class a{async sign(t,n,e){throw new NotImplementedError}async nextOwner(){throw new NotImplementedError}static[Symbol.hasInstance](t){return("object"==typeof t||"function"==typeof t)&&(!!t&&("function"==typeof t.sign&&("function"==typeof t.nextOwner||"function"==typeof t.owner)))}}class c{async pay(t,n){throw new NotImplementedError}async broadcast(t){throw new NotImplementedError}async cancel(t){throw new NotImplementedError}static[Symbol.hasInstance](t){return("object"==typeof t||"function"==typeof t)&&(!!t&&"function"==typeof t.pay)}}class u{async pull(t,n){throw new NotImplementedError}async locations(t){throw new NotImplementedError}async broadcast(t){throw new NotImplementedError}static[Symbol.hasInstance](t){return("object"==typeof t||"function"==typeof t)&&(!!t&&"function"==typeof t.pull)}}t.exports={Blockchain:r,Cache:o,Lock:i,Logger:s,Owner:a,Purse:c,State:u}},function(t,n,e){{const CacheWrapper=e(38),{Aa:n}=e(29),r="run-browser-cache",o=1,i="run-objects";class s extends CacheWrapper{constructor(t={}){if(super(),!n()||void 0===window.indexedDB)throw new Error("Your browser doesn't support IndexedDB");let e,s;this.Xn=void 0!==t.dbName?t.dbName:r,this.jn=void 0!==t.dbVersion?t.dbVersion:o,this.su=void 0!==t.dbStore?t.dbStore:i,this.au=new Promise(((t,n)=>{e=t,s=n}));const a=window.indexedDB.open(this.Xn,this.jn);a.onsuccess=()=>e(a.result),a.onerror=()=>s(new Error(`Cannot access database: ${a.error.message}`)),a.onblocked=()=>s(new Error("Upgrade not supported")),a.onupgradeneeded=t=>{if(0!==t.oldVersion)return void s(new Error("Upgrade not supported"));a.result.createObjectStore(this.su)}}async set(t,n){const e=(await this.au).transaction(this.su,"readwrite").objectStore(this.su);return new Promise(((r,o)=>{const i=e.put(n,t);i.onsuccess=()=>r(i.result),i.onerror=()=>r(i.error)}))}async get(t){const n=(await this.au).transaction(this.su,"readonly").objectStore(this.su);return new Promise(((e,r)=>{const o=n.get(t);o.onsuccess=()=>e(o.result),o.onerror=()=>e(o.error)}))}}t.exports=s}},function(t,n,e){const r=e(6),{PrivateKey:o,Script:i,Transaction:s}=r,{M:a,J:c}=e(0),{Gr:u,Hr:h}=e(12),OwnerWrapper=e(46);class LocalOwner extends OwnerWrapper{constructor(t,n){super();const r=(n=n||e(31).instance&&e(31).instance.blockchain.network)&&a(n);if(void 0!==t&&"string"!=typeof t&&!(t instanceof o))throw new Error(`Invalid private key: ${c(t)}`);if(r&&t&&t instanceof o&&t.network.name!==r)throw new Error("Private key network mismatch");try{this.bsvPrivateKey=new o(t,r)}catch(n){throw new Error(`Invalid private key: ${c(t)}\n\n${n}`)}if(t&&this.bsvPrivateKey.toString()!==t.toString())throw new Error(`Invalid private key: ${c(t)}`);this.bsvPublicKey=this.bsvPrivateKey.publicKey,this.bsvAddress=this.bsvPublicKey.toAddress(),this.privkey=this.bsvPrivateKey.toString(),this.pubkey=this.bsvPublicKey.toString(),this.address=this.bsvAddress.toString()}async sign(t,n,o){const CommonLock=e(44),a=e(47).main.Group,c=e(47).test.Group,h=new s(t);n.forEach(((t,n)=>{t&&(h.inputs[n].output=new s.Output({satoshis:t.satoshis,script:new i(t.script)}))}));for(let t=0;t<h.inputs.length;t++){const e=o[t]instanceof CommonLock,s=h.inputs[t].output&&h.inputs[t].output.script.isPublicKeyHashOut()&&h.inputs[t].output.script.toAddress().toString()===this.address;if(e||s){const e=new i(n[t].script);if(e.toAddress().toString()!==this.address)continue;const r=await u(h,t,e,n[t].satoshis,this.bsvPrivateKey),o=i.fromASM(`${r} ${this.pubkey}`);h.inputs[t].setScript(o)}if((o[t]instanceof a||o[t]instanceof c)&&o[t].pubkeys.includes(this.pubkey)&&h.inputs[t].script.chunks.length<=o[t].required){const e=h.inputs[t].script.chunks.slice(1).map((t=>t.buf.toString("hex"))),s={script:new r.Script(n[t].script),satoshis:n[t].satoshis},a=await f(h,t,s,e,o[t].pubkeys);if(a.includes(this.pubkey))continue;const c=new i(n[t].script),l=await u(h,t,c,n[t].satoshis,this.bsvPrivateKey),d=o[t].pubkeys.map((t=>{const n=a.indexOf(t);return-1!==n?e[n]:t===this.pubkey?l:null})).filter((t=>null!==t)),p=i.fromASM(`OP_0 ${d.join(" ")}`);h.inputs[t].setScript(p)}}return h.toString("hex")}async nextOwner(){return this.address}}async function f(t,n,e,o,i){const s=r.crypto.Signature.SIGHASH_ALL|r.crypto.Signature.SIGHASH_FORKID,a=new r.crypto.BN(e.satoshis),c=await h(t,s,n,e.script,a),u=i.map((t=>new r.PublicKey(t))),f=o.map((t=>{const n=t.slice(0,t.length-2),e=r.deps.Buffer.from(n,"hex"),o=r.crypto.Signature.fromDER(e);return u.findIndex((t=>r.crypto.ECDSA.verify(c,o,t,"little")))})),l=f.findIndex((t=>-1===t));if(-1!==l)throw new Error(`Bad signature at index ${l}`);return f.map((t=>i[t]))}LocalOwner.Mc=f,t.exports=LocalOwner},function(t,n,e){const{v:r,S:o}=e(0),i=e(9),s=e(23),a=e(20),c=e(5),{h:u}=e(4);t.exports=function(t,n){switch(n.kind){case"code":return function(t,n){const e=i.Yt();return u((()=>{e.location=t})),e}(t);case"jig":return function(t,n){const e=!0,o=new c.g.Object,i=s.Sn(e),u=new a(o,i);return r.add(u),u}();case"berry":return function(t,n){const e=!0,r=new c.g.Object,i=s.Yr(e),u=new a(r,i);o.add(u)}();default:throw new Error(`Unknown kind: ${n.kind}`)}}},function(t,n,e){const r=e(9),o=e(18),i=e(5),{H:s,ut:a}=e(0),{In:c,Dn:u}=e(8),{h}=e(4);t.exports=function(t,n,e,f){switch(e.kind){case"code":!function(t,n,e,f){const l=n.split("_")[0],d=o.ko(e.props,{g:i.g,jo:t=>{const n=c(t);if(n.Ct){const t=r.Ie(n.Ct);if(!t)throw new Error(`Native code not found: ${n.Ct}`);return t}const e=u(Object.assign({Rn:l},n));if(!(e in f))throw new Error(`Missing ref: ${e}`);return f[e]}}),p={},b=s(e.src);if(b){const t=d.deps[b].location,n=c(t);let e=null;if(n.Ct)e=r.Ie(n.Ct);else{const t=u(Object.assign({Rn:l},n));e=f[t]}if(!e)throw new Error(`Missing parent: ${t}`);p[b]=e}const w=i.dn(e.src,p)[0],[y,g]=r.Ne(t,w),_=!1;r.Tt(t).ie(y,_),h((()=>{Object.keys(t).forEach((n=>{delete t[n]})),Object.keys(d).forEach((n=>a(t,n,d[n])))})),h((()=>{t.location=u(Object.assign({Rn:l},c(t.location))),t.origin=u(Object.assign({Rn:l},c(t.origin)))})),h((()=>{const n=r.Ce(t,g,t.deps);a(t,"deps",n),Object.keys(d.deps||{}).forEach((n=>{t.deps[n]=d.deps[n]}))}))}(t,n,e,f);break;case"jig":!function(t,n,e,s){const f=n.split("_")[0],l=o.ko(e.props,{g:i.g,jo:t=>{const e=c(t);if(e.Ct){const t=r.Ie(e.Ct);if(!t)throw new Error(`Native code not found: ${e.Ct}`);return t}const o=u(Object.assign({Rn:f},e));if(!(o in s))throw new Error(`Missing ref: ${n}`);return s[o]}}),d=s[e.cls.$jig];if(!d)throw new Error(`Missing ref: ${e.cls.$jig}`);h((()=>Object.setPrototypeOf(t,d.prototype))),h((()=>{Object.keys(l).forEach((n=>{a(t,n,l[n])}))})),h((()=>{t.location=u(Object.assign({Rn:f},c(t.location))),t.origin=u(Object.assign({Rn:f},c(t.origin)))}))}(t,n,e,f);break;case"berry":!function(t,n,e,s){const f=n.split("_")[0],l=o.ko(e.props,{g:i.g,jo:t=>{const e=c(t);if(e.Ct){const t=r.Ie(e.Ct);if(!t)throw new Error(`Native code not found: ${e.Ct}`);return t}const o=u(Object.assign({Rn:f},e));if(!(o in s))throw new Error(`Missing ref: ${n}`);return s[o]}}),B=s[e.cls.$jig];if(!B)throw new Error(`Missing ref: ${e.cls.$jig}`);h((()=>Object.setPrototypeOf(t,B.prototype))),h((()=>{Object.keys(l).forEach((n=>{a(t,n,l[n])}))}))}(t,n,e,f);break;default:throw new Error(`Unknown kind: ${e.kind}`)}}},function(t,n,e){const{ro:r}=e(15);t.exports=function(t){r(t.version)}},function(t,n,e){const{Et:r}=e(0),o="config://recent-broadcasts";function i(t,n,e){const r=n.inputs.map((t=>({txid:t.prevTxId.toString("hex"),vout:t.outputIndex}))),o=n.outputs.map(((t,n)=>{const r=t.script.toHex(),o=t.satoshis;return{txid:e,vout:n,script:r,satoshis:o}})),i={rawtx:n.toString(),txid:e,time:Date.now(),inputs:r,outputs:o};t.push(i)}function s(t,n,e){t.forEach((t=>{t.outputs.forEach((t=>{t.script===e&&(n.some((n=>n.txid===t.txid&&n.vout===t.vout))||n.push(t))}))})),r(n,(n=>!t.some((t=>t.inputs.some((t=>t.txid===n.txid&&t.vout===n.vout))))))}function a(t,n=1e4){r(t,(t=>Date.now()-t.time<n))}t.exports={vc:async function(t,n,e,r=1e4){const s=await t.get(o)||[];a(s,r),i(s,n,e),await t.set(o,s)},$c:async function(t,n,e,r=1e4){const i=await t.get(o);i&&(a(i,r),s(i,n,e))},br:i,Lc:s,Hc:a}},function(t,n,e){const{Lr:r}=e(12),o=e(19),BlockchainWrapper=e(41),{Io:i}=o;t.exports=class extends BlockchainWrapper{constructor(t={}){super(),this.api="run",this.network=function(t){if(void 0===t)return"main";if("string"!=typeof t)throw new Error(`Invalid network: ${t}`);if("main"!==t&&"test"!==t)throw new Error(`RunConnect API does not support the "${t}" network`);return t}(t.network),this.request=o,this.host="https://api.run.network"}async broadcast(t){const n=`${this.host}/v1/${this.network}/tx`,e={method:"POST",body:{rawtx:t}};return await this.request(n,e)}async fetch(t){const n=`${this.host}/v1/${this.network}/rawtx/${t}`;return(await this.request(n)).toString("hex")}async utxos(t){const n=await r(t),e=`${this.host}/v1/${this.network}/utxos/${n}`;return await this.request(e,{cache:1e3})}async time(t){const n=`${this.host}/v1/${this.network}/tx/${t}`,e=await this.request(n,{cache:1e3});if(this.cache){const n=[];n.push(this.cache.set(`tx://${t}`,e.hex)),e.vout.forEach(((e,r)=>{e.spentTxId&&n.push(this.cache.set(`spend://${t}_o${r}`,e.spentTxId))})),await Promise.all(n)}return 1e3*e.time||Date.now()}async spends(t,n){try{const e=`${this.host}/v1/${this.network}/spends/${t}_o${n}`;return(await this.request(e)).spentTxId}catch(t){if(t instanceof i&&404===t.status)return null;throw t}}}},function(t,n,e){(function(n){e(29).Pt();const r=e(6),o=e(31),{Dr:i}=e(12),{ft:s}=e(0);n.Jig=o.Jig,n.Berry=o.Berry,s(n,"Token",(()=>o.extra.Token)),i(r),t.exports=o}).call(this,e(42))},function(t){t.exports=JSON.parse('"!function(t,o){\\"object\\"==typeof exports&&\\"undefined\\"!=typeof module?o(exports):\\"function\\"==typeof define&&define.amd?define([\\"exports\\"],o):o((t=t||self).SES={})}(this,(function(t){\\"use strict\\";function o(t,o){if(!t)throw new TypeError(o)}const{getPrototypeOf:r}=Object;const{getOwnPropertyDescriptor:e,getPrototypeOf:n}=Object;function a(t){return n(t).constructor}const i=[\\"Array\\",\\"ArrayBuffer\\",\\"ArrayBufferPrototype\\",\\"ArrayIteratorPrototype\\",\\"ArrayPrototype\\",\\"AsyncFunction\\",\\"AsyncFunctionPrototype\\",\\"AsyncGenerator\\",\\"AsyncGeneratorFunction\\",\\"AsyncGeneratorPrototype\\",\\"AsyncIteratorPrototype\\",\\"Atomics\\",\\"BigInt\\",\\"BigIntPrototype\\",\\"BigInt64Array\\",\\"BigInt64ArrayPrototype\\",\\"BigUint64Array\\",\\"BigUint64ArrayPrototype\\",\\"Boolean\\",\\"BooleanPrototype\\",\\"DataView\\",\\"DataViewPrototype\\",\\"Date\\",\\"DatePrototype\\",\\"decodeURI\\",\\"decodeURIComponent\\",\\"encodeURI\\",\\"encodeURIComponent\\",\\"Error\\",\\"ErrorPrototype\\",\\"eval\\",\\"EvalError\\",\\"EvalErrorPrototype\\",\\"Float32Array\\",\\"Float32ArrayPrototype\\",\\"Float64Array\\",\\"Float64ArrayPrototype\\",\\"Function\\",\\"FunctionPrototype\\",\\"Generator\\",\\"GeneratorFunction\\",\\"GeneratorPrototype\\",\\"Int8Array\\",\\"Int8ArrayPrototype\\",\\"Int16Array\\",\\"Int16ArrayPrototype\\",\\"Int32Array\\",\\"Int32ArrayPrototype\\",\\"isFinite\\",\\"isNaN\\",\\"IteratorPrototype\\",\\"JSON\\",\\"Map\\",\\"MapIteratorPrototype\\",\\"MapPrototype\\",\\"Math\\",\\"Number\\",\\"NumberPrototype\\",\\"Object\\",\\"ObjectPrototype\\",\\"parseFloat\\",\\"parseInt\\",\\"Promise\\",\\"PromisePrototype\\",\\"Proxy\\",\\"RangeError\\",\\"RangeErrorPrototype\\",\\"ReferenceError\\",\\"ReferenceErrorPrototype\\",\\"Reflect\\",\\"RegExp\\",\\"RegExpPrototype\\",\\"RegExpStringIteratorPrototype\\",\\"Set\\",\\"SetIteratorPrototype\\",\\"SetPrototype\\",\\"SharedArrayBuffer\\",\\"SharedArrayBufferPrototype\\",\\"String\\",\\"StringIteratorPrototype\\",\\"StringPrototype\\",\\"Symbol\\",\\"SymbolPrototype\\",\\"SyntaxError\\",\\"SyntaxErrorPrototype\\",\\"ThrowTypeError\\",\\"TypedArray\\",\\"TypedArrayPrototype\\",\\"TypeError\\",\\"TypeErrorPrototype\\",\\"Uint8Array\\",\\"Uint8ArrayPrototype\\",\\"Uint8ClampedArray\\",\\"Uint8ClampedArrayPrototype\\",\\"Uint16Array\\",\\"Uint16ArrayPrototype\\",\\"Uint32Array\\",\\"Uint32ArrayPrototype\\",\\"URIError\\",\\"URIErrorPrototype\\",\\"WeakMap\\",\\"WeakMapPrototype\\",\\"WeakSet\\",\\"WeakSetPrototype\\",\\"escape\\",\\"unescape\\",\\"FunctionPrototypeConstructor\\",\\"Compartment\\",\\"CompartmentPrototype\\",\\"harden\\"],{getOwnPropertyDescriptor:c}=Object;function p(t,r){const e=c(t,r);return o(!(\\"get\\"in e||\\"set\\"in e),`unexpected accessor on global property: ${r}`),e.value}const{apply:s}=Reflect,y=(t=>(o,...r)=>s(t,o,r))(Object.prototype.hasOwnProperty);function l(){const t={__proto__:null},c=function(){const t=Function.prototype.constructor,o=typeof Symbol&&Symbol.iterator||\\"@@iterator\\",r=typeof Symbol&&Symbol.matchAll||\\"@@matchAll\\",i=e(arguments,\\"callee\\").get,c=(new String)[o](),p=n(c);let s=null,y=null;r in new RegExp&&(s=(new RegExp)[r](),y=n(s));const l=(new Array)[o](),u=n(l),g=n(Float32Array),f=(new Map)[o](),P=n(f),b=(new Set)[o](),m=n(b),d=n(u);function*h(){}const A=a(h),E=A.prototype;async function*S(){}const _=a(S),w=_.prototype,I=w.prototype,F=n(I);async function T(){}const v=a(T),O={FunctionPrototypeConstructor:t,ArrayIteratorPrototype:u,AsyncFunction:v,AsyncGenerator:w,AsyncGeneratorFunction:_,AsyncGeneratorPrototype:I,AsyncIteratorPrototype:F,Generator:E,GeneratorFunction:A,IteratorPrototype:d,MapIteratorPrototype:P,RegExpStringIteratorPrototype:y,SetIteratorPrototype:m,StringIteratorPrototype:p,ThrowTypeError:i,TypedArray:g};return O}();!function(t){const{FunctionPrototypeConstructor:e,ArrayIteratorPrototype:n,AsyncFunction:a,AsyncGenerator:i,AsyncGeneratorFunction:c,AsyncGeneratorPrototype:p,AsyncIteratorPrototype:s,Generator:y,GeneratorFunction:l,IteratorPrototype:u,MapIteratorPrototype:g,RegExpStringIteratorPrototype:f,SetIteratorPrototype:P,StringIteratorPrototype:b,ThrowTypeError:m,TypedArray:d}=t;o(r(m)===Function.prototype,\\"ThrowTypeError.__proto__ should be Function.prototype\\"),o(r(b)===u,\\"StringIteratorPrototype.__proto__ should be IteratorPrototype\\"),f&&o(r(f)===u,\\"RegExpStringIteratorPrototype.__proto__ should be IteratorPrototype\\"),o(r(d)===Function.prototype,\\"TypedArray.__proto__ should be Function.prototype\\"),o(r(g)===u,\\"MapIteratorPrototype.__proto__ should be IteratorPrototype\\"),o(r(P)===u,\\"SetIteratorPrototype.__proto__ should be IteratorPrototype\\"),o(r(u)===Object.prototype,\\"IteratorPrototype.__proto__ should be Object.prototype\\"),o(r(s)===Object.prototype,\\"AsyncIteratorPrototype.__proto__ should be Object.prototype\\"),o(r(n)===u,\\"AsyncIteratorPrototype.__proto__ should be IteratorPrototype\\"),o(r(l)===e,\\"GeneratorFunction.__proto__ should be Function\\"),o(\\"GeneratorFunction\\"===l.name,\'GeneratorFunction.name should be \\"GeneratorFunction\\"\'),o(r(y)===Function.prototype,\\"Generator.__proto__ should be Function.prototype\\"),o(r(c)===e,\\"AsyncGeneratorFunction.__proto__ should be Function\\"),o(\\"AsyncGeneratorFunction\\"===c.name,\'AsyncGeneratorFunction.name should be \\"AsyncGeneratorFunction\\"\'),o(r(i)===Function.prototype,\\"AsyncGenerator.__proto__ should be Function.prototype\\"),o(r(p)===s,\\"AsyncGeneratorPrototype.__proto__ should be AsyncIteratorPrototype\\"),o(r(a)===e,\\"AsyncFunction.__proto__ should be Function\\"),o(\\"AsyncFunction\\"===a.name,\'AsyncFunction.name should be \\"AsyncFunction\\"\')}(c);for(const o of i){if(y(c,o)){t[o]=c[o];continue}if(y(globalThis,o)){t[o]=p(globalThis,o);continue}if(o.endsWith(\\"Prototype\\")){const r=o.slice(0,-\\"Prototype\\".length);if(y(c,r)){const e=c[r];t[o]=e.prototype;continue}if(y(globalThis,r)){const e=p(globalThis,r);t[o]=e.prototype;continue}}}return function(t){Object.keys(t).forEach(o=>{if(void 0===t[o])throw new TypeError(`Malformed intrinsic: ${o}`)})}(t),t}const u={\\"**proto**\\":\\"FunctionPrototype\\",length:\\"number\\",name:\\"string\\"},g=u,f={get:g,set:\\"undefined\\"};function P(t){return{\\"**proto**\\":\\"Error\\",prototype:t,length:\\"number\\",name:\\"string\\"}}function b(t){return{\\"**proto**\\":\\"ErrorPrototype\\",constructor:t,message:\\"string\\",name:\\"string\\",toString:g}}function m(t){return{\\"**proto**\\":\\"TypedArray\\",length:\\"number\\",name:\\"string\\",BYTES_PER_ELEMENT:\\"number\\",prototype:t}}function d(t){return{\\"**proto**\\":\\"TypedArrayPrototype\\",BYTES_PER_ELEMENT:\\"number\\",constructor:t}}var h=function(t){return(typeof Symbol&&Symbol.matchAll||\\"@@matchAll\\")in new RegExp||delete t.RegExpStringIteratorPrototype,t}({\\"**proto**\\":null,ThrowTypeError:g,Infinity:\\"number\\",NaN:\\"number\\",undefined:\\"undefined\\",eval:g,isFinite:g,isNaN:g,parseFloat:g,parseInt:g,decodeURI:g,decodeURIComponent:g,encodeURI:g,encodeURIComponent:g,Object:{\\"**proto**\\":\\"FunctionPrototype\\",assign:g,create:g,defineProperties:g,defineProperty:g,entries:g,freeze:g,fromEntries:g,getOwnPropertyDescriptor:g,getOwnPropertyDescriptors:g,getOwnPropertyNames:g,getOwnPropertySymbols:g,getPrototypeOf:g,is:g,isExtensible:g,isFrozen:g,isSealed:g,keys:g,preventExtensions:g,prototype:\\"ObjectPrototype\\",seal:g,setPrototypeOf:g,values:g},ObjectPrototype:{\\"**proto**\\":null,constructor:\\"Object\\",hasOwnProperty:g,isPrototypeOf:g,propertyIsEnumerable:g,toLocaleString:g,toString:g,valueOf:g,__defineGetter__:g,__defineSetter__:g,__lookupGetter__:g,__lookupSetter__:g},Function:{\\"**proto**\\":\\"FunctionPrototype\\",length:\\"number\\",prototype:\\"FunctionPrototype\\"},FunctionPrototype:{length:\\"number\\",name:\\"string\\",apply:g,bind:g,call:g,constructor:\\"FunctionPrototypeConstructor\\",toString:g,\\"@@hasInstance\\":g},Boolean:{\\"**proto**\\":\\"FunctionPrototype\\",prototype:\\"BooleanPrototype\\"},BooleanPrototype:{constructor:\\"Boolean\\",toString:g,valueOf:g},Symbol:{\\"**proto**\\":\\"FunctionPrototype\\",asyncIterator:\\"symbol\\",for:g,hasInstance:\\"symbol\\",isConcatSpreadable:\\"symbol\\",iterator:\\"symbol\\",keyFor:g,match:\\"symbol\\",matchAll:\\"symbol\\",prototype:\\"SymbolPrototype\\",replace:\\"symbol\\",search:\\"symbol\\",species:\\"symbol\\",split:\\"symbol\\",toPrimitive:\\"symbol\\",toStringTag:\\"symbol\\",unscopables:\\"symbol\\"},SymbolPrototype:{constructor:\\"Symbol\\",description:f,toString:g,valueOf:g,\\"@@toPrimitive\\":g,\\"@@toStringTag\\":\\"string\\"},Error:{\\"**proto**\\":\\"FunctionPrototype\\",prototype:\\"ErrorPrototype\\",captureStackTrace:g,stackTraceLimit:\\"number\\"},ErrorPrototype:{constructor:\\"Error\\",message:\\"string\\",name:\\"string\\",toString:g},EvalError:P(\\"EvalErrorPrototype\\"),RangeError:P(\\"RangeErrorPrototype\\"),ReferenceError:P(\\"ReferenceErrorPrototype\\"),SyntaxError:P(\\"SyntaxErrorPrototype\\"),TypeError:P(\\"TypeErrorPrototype\\"),URIError:P(\\"URIErrorPrototype\\"),EvalErrorPrototype:b(\\"EvalError\\"),RangeErrorPrototype:b(\\"RangeError\\"),ReferenceErrorPrototype:b(\\"ReferenceError\\"),SyntaxErrorPrototype:b(\\"SyntaxError\\"),TypeErrorPrototype:b(\\"TypeError\\"),URIErrorPrototype:b(\\"URIError\\"),Number:{\\"**proto**\\":\\"FunctionPrototype\\",EPSILON:\\"number\\",isFinite:g,isInteger:g,isNaN:g,isSafeInteger:g,MAX_SAFE_INTEGER:\\"number\\",MAX_VALUE:\\"number\\",MIN_SAFE_INTEGER:\\"number\\",MIN_VALUE:\\"number\\",NaN:\\"number\\",NEGATIVE_INFINITY:\\"number\\",parseFloat:g,parseInt:g,POSITIVE_INFINITY:\\"number\\",prototype:\\"NumberPrototype\\"},NumberPrototype:{constructor:\\"Number\\",toExponential:g,toFixed:g,toLocaleString:g,toPrecision:g,toString:g,valueOf:g},BigInt:{\\"**proto**\\":\\"FunctionPrototype\\",asIntN:g,asUintN:g,prototype:\\"BigIntPrototype\\"},BigIntPrototype:{constructor:\\"BigInt\\",toLocaleString:g,toString:g,valueOf:g,\\"@@toStringTag\\":\\"string\\"},Math:{E:\\"number\\",LN10:\\"number\\",LN2:\\"number\\",LOG10E:\\"number\\",LOG2E:\\"number\\",PI:\\"number\\",SQRT1_2:\\"number\\",SQRT2:\\"number\\",\\"@@toStringTag\\":\\"string\\",abs:g,acos:g,acosh:g,asin:g,asinh:g,atan:g,atanh:g,atan2:g,cbrt:g,ceil:g,clz32:g,cos:g,cosh:g,exp:g,expm1:g,floor:g,fround:g,hypot:g,imul:g,log:g,log1p:g,log10:g,log2:g,max:g,min:g,pow:g,random:g,round:g,sign:g,sin:g,sinh:g,sqrt:g,tan:g,tanh:g,trunc:g},Date:{\\"**proto**\\":\\"FunctionPrototype\\",now:g,parse:g,prototype:\\"DatePrototype\\",UTC:g},DatePrototype:{constructor:\\"Date\\",getDate:g,getDay:g,getFullYear:g,getHours:g,getMilliseconds:g,getMinutes:g,getMonth:g,getSeconds:g,getTime:g,getTimezoneOffset:g,getUTCDate:g,getUTCDay:g,getUTCFullYear:g,getUTCHours:g,getUTCMilliseconds:g,getUTCMinutes:g,getUTCMonth:g,getUTCSeconds:g,setDate:g,setFullYear:g,setHours:g,setMilliseconds:g,setMinutes:g,setMonth:g,setSeconds:g,setTime:g,setUTCDate:g,setUTCFullYear:g,setUTCHours:g,setUTCMilliseconds:g,setUTCMinutes:g,setUTCMonth:g,setUTCSeconds:g,toDateString:g,toISOString:g,toJSON:g,toLocaleDateString:g,toLocaleString:g,toLocaleTimeString:g,toString:g,toTimeString:g,toUTCString:g,valueOf:g,\\"@@toPrimitive\\":g,getYear:g,setYear:g,toGMTString:g},String:{\\"**proto**\\":\\"FunctionPrototype\\",fromCharCode:g,fromCodePoint:g,prototype:\\"StringPrototype\\",raw:g},StringPrototype:{length:\\"number\\",charAt:g,charCodeAt:g,codePointAt:g,concat:g,constructor:\\"String\\",endsWith:g,includes:g,indexOf:g,lastIndexOf:g,localeCompare:g,match:g,matchAll:g,normalize:g,padEnd:g,padStart:g,repeat:g,replace:g,search:g,slice:g,split:g,startsWith:g,substring:g,toLocaleLowerCase:g,toLocaleUpperCase:g,toLowerCase:g,toString:g,toUpperCase:g,trim:g,trimEnd:g,trimStart:g,valueOf:g,\\"@@iterator\\":g,substr:g,anchor:g,big:g,blink:g,bold:g,fixed:g,fontcolor:g,fontsize:g,italics:g,link:g,small:g,strike:g,sub:g,sup:g,trimLeft:g,trimRight:g},StringIteratorPrototype:{\\"**proto**\\":\\"IteratorPrototype\\",next:g,\\"@@toStringTag\\":\\"string\\"},RegExp:{\\"**proto**\\":\\"FunctionPrototype\\",prototype:\\"RegExpPrototype\\",\\"@@species\\":f},RegExpPrototype:{constructor:\\"RegExp\\",exec:g,dotAll:f,flags:f,global:f,ignoreCase:f,\\"@@match\\":g,\\"@@matchAll\\":g,multiline:f,\\"@@replace\\":g,\\"@@search\\":g,source:f,\\"@@split\\":g,sticky:f,test:g,toString:g,unicode:f,compile:!1},RegExpStringIteratorPrototype:{\\"**proto**\\":\\"IteratorPrototype\\",next:g,\\"@@toStringTag\\":\\"string\\"},Array:{\\"**proto**\\":\\"FunctionPrototype\\",from:g,isArray:g,of:g,prototype:\\"ArrayPrototype\\",\\"@@species\\":f},ArrayPrototype:{length:\\"number\\",concat:g,constructor:\\"Array\\",copyWithin:g,entries:g,every:g,fill:g,filter:g,find:g,findIndex:g,flat:g,flatMap:g,forEach:g,includes:g,indexOf:g,join:g,keys:g,lastIndexOf:g,map:g,pop:g,push:g,reduce:g,reduceRight:g,reverse:g,shift:g,slice:g,some:g,sort:g,splice:g,toLocaleString:g,toString:g,unshift:g,values:g,\\"@@iterator\\":g,\\"@@unscopables\\":{\\"**proto**\\":null,copyWithin:\\"boolean\\",entries:\\"boolean\\",fill:\\"boolean\\",find:\\"boolean\\",findIndex:\\"boolean\\",flat:\\"boolean\\",flatMap:\\"boolean\\",includes:\\"boolean\\",keys:\\"boolean\\",values:\\"boolean\\"}},ArrayIteratorPrototype:{\\"**proto**\\":\\"IteratorPrototype\\",next:g,\\"@@toStringTag\\":\\"string\\"},TypedArray:{\\"**proto**\\":\\"FunctionPrototype\\",from:g,of:g,prototype:\\"TypedArrayPrototype\\",\\"@@species\\":f},TypedArrayPrototype:{buffer:f,byteLength:f,byteOffset:f,constructor:\\"TypedArray\\",copyWithin:g,entries:g,every:g,fill:g,filter:g,find:g,findIndex:g,forEach:g,includes:g,indexOf:g,join:g,keys:g,lastIndexOf:g,length:f,map:g,reduce:g,reduceRight:g,reverse:g,set:g,slice:g,some:g,sort:g,subarray:g,toLocaleString:g,toString:g,values:g,\\"@@iterator\\":g,\\"@@toStringTag\\":f},BigInt64Array:m(\\"BigInt64ArrayPrototype\\"),BigUint64Array:m(\\"BigUint64ArrayPrototype\\"),Float32Array:m(\\"Float32ArrayPrototype\\"),Float64Array:m(\\"Float64ArrayPrototype\\"),Int16Array:m(\\"Int16ArrayPrototype\\"),Int32Array:m(\\"Int32ArrayPrototype\\"),Int8Array:m(\\"Int8ArrayPrototype\\"),Uint16Array:m(\\"Uint16ArrayPrototype\\"),Uint32Array:m(\\"Uint32ArrayPrototype\\"),Uint8Array:m(\\"Uint8ArrayPrototype\\"),Uint8ClampedArray:m(\\"Uint8ClampedArrayPrototype\\"),BigInt64ArrayPrototype:d(\\"BigInt64Array\\"),BigUint64ArrayPrototype:d(\\"BigUint64Array\\"),Float32ArrayPrototype:d(\\"Float32Array\\"),Float64ArrayPrototype:d(\\"Float64Array\\"),Int16ArrayPrototype:d(\\"Int16Array\\"),Int32ArrayPrototype:d(\\"Int32Array\\"),Int8ArrayPrototype:d(\\"Int8Array\\"),Uint16ArrayPrototype:d(\\"Uint16Array\\"),Uint32ArrayPrototype:d(\\"Uint32Array\\"),Uint8ArrayPrototype:d(\\"Uint8Array\\"),Uint8ClampedArrayPrototype:d(\\"Uint8ClampedArray\\"),Map:{\\"**proto**\\":\\"FunctionPrototype\\",\\"@@species\\":f,prototype:\\"MapPrototype\\"},MapPrototype:{clear:g,constructor:\\"Map\\",delete:g,entries:g,forEach:g,get:g,has:g,keys:g,set:g,size:f,values:g,\\"@@iterator\\":g,\\"@@toStringTag\\":\\"string\\"},MapIteratorPrototype:{\\"**proto**\\":\\"IteratorPrototype\\",next:g,\\"@@toStringTag\\":\\"string\\"},Set:{\\"**proto**\\":\\"FunctionPrototype\\",prototype:\\"SetPrototype\\",\\"@@species\\":f},SetPrototype:{add:g,clear:g,constructor:\\"Set\\",delete:g,entries:g,forEach:g,has:g,keys:g,size:f,values:g,\\"@@iterator\\":g,\\"@@toStringTag\\":\\"string\\"},SetIteratorPrototype:{\\"**proto**\\":\\"IteratorPrototype\\",next:g,\\"@@toStringTag\\":\\"string\\"},WeakMap:{\\"**proto**\\":\\"FunctionPrototype\\",prototype:\\"WeakMapPrototype\\"},WeakMapPrototype:{constructor:\\"WeakMap\\",delete:g,get:g,has:g,set:g,\\"@@toStringTag\\":\\"string\\"},WeakSet:{\\"**proto**\\":\\"FunctionPrototype\\",prototype:\\"WeakSetPrototype\\"},WeakSetPrototype:{add:g,constructor:\\"WeakSet\\",delete:g,has:g,\\"@@toStringTag\\":\\"string\\"},ArrayBuffer:{\\"**proto**\\":\\"FunctionPrototype\\",isView:g,prototype:\\"ArrayBufferPrototype\\",\\"@@species\\":f},ArrayBufferPrototype:{byteLength:f,constructor:\\"ArrayBuffer\\",slice:g,\\"@@toStringTag\\":\\"string\\"},SharedArrayBuffer:!1,DataView:{\\"**proto**\\":\\"FunctionPrototype\\",prototype:\\"DataViewPrototype\\"},DataViewPrototype:{buffer:f,byteLength:f,byteOffset:f,constructor:\\"DataView\\",getBigInt64:g,getBigUint64:g,getFloat32:g,getFloat64:g,getInt8:g,getInt16:g,getInt32:g,getUint8:g,getUint16:g,getUint32:g,setBigInt64:g,setBigUint64:g,setFloat32:g,setFloat64:g,setInt8:g,setInt16:g,setInt32:g,setUint8:g,setUint16:g,setUint32:g,\\"@@toStringTag\\":\\"string\\"},Atomics:!1,JSON:{parse:g,stringify:g,\\"@@toStringTag\\":\\"string\\"},IteratorPrototype:{\\"@@iterator\\":g},AsyncIteratorPrototype:{\\"@@asyncIterator\\":g},GeneratorFunction:{\\"**proto**\\":\\"FunctionPrototypeConstructor\\",name:\\"string\\",length:\\"number\\",prototype:\\"Generator\\"},Generator:{\\"**proto**\\":\\"FunctionPrototype\\",constructor:\\"GeneratorFunction\\",prototype:\\"GeneratorPrototype\\"},AsyncGeneratorFunction:{\\"**proto**\\":\\"FunctionPrototypeConstructor\\",name:\\"string\\",length:\\"number\\",prototype:\\"AsyncGenerator\\"},AsyncGenerator:{\\"**proto**\\":\\"FunctionPrototype\\",constructor:\\"AsyncGeneratorFunction\\",prototype:\\"AsyncGeneratorPrototype\\",\\"@@toStringTag\\":\\"string\\"},GeneratorPrototype:{\\"**proto**\\":\\"IteratorPrototype\\",constructor:\\"Generator\\",next:g,return:g,throw:g,\\"@@toStringTag\\":\\"string\\"},AsyncGeneratorPrototype:{\\"**proto**\\":\\"AsyncIteratorPrototype\\",constructor:\\"AsyncGenerator\\",next:g,return:g,throw:g,\\"@@toStringTag\\":\\"string\\"},Promise:{\\"**proto**\\":\\"FunctionPrototype\\",all:g,allSettled:g,prototype:\\"PromisePrototype\\",race:g,reject:g,resolve:g,\\"@@species\\":f},PromisePrototype:{catch:g,constructor:\\"Promise\\",finally:g,then:g,\\"@@toStringTag\\":\\"string\\"},AsyncFunction:{\\"**proto**\\":\\"FunctionPrototypeConstructor\\",name:\\"string\\",length:\\"number\\",prototype:\\"AsyncFunctionPrototype\\"},AsyncFunctionPrototype:{\\"**proto**\\":\\"FunctionPrototype\\",constructor:\\"AsyncFunction\\",\\"@@toStringTag\\":\\"string\\"},Reflect:{apply:g,construct:g,defineProperty:g,deleteProperty:g,get:g,getOwnPropertyDescriptor:g,getPrototypeOf:g,has:g,isExtensible:g,ownKeys:g,preventExtensions:g,set:g,setPrototypeOf:g},Proxy:{\\"**proto**\\":\\"FunctionPrototype\\",revocable:g},escape:g,unescape:g,FunctionPrototypeConstructor:{\\"**proto**\\":\\"FunctionPrototype\\",length:\\"number\\",prototype:\\"FunctionPrototype\\"},Compartment:{\\"**proto**\\":\\"FunctionPrototype\\",prototype:\\"CompartmentPrototype\\"},CompartmentPrototype:{constructor:\\"Compartment\\",evaluate:g,global:f},harden:g});const{getPrototypeOf:A,getOwnPropertyDescriptor:E}=Object,{apply:S,ownKeys:_}=Reflect,w=(t=>(o,...r)=>S(t,o,r))(Object.prototype.hasOwnProperty);function I(t,o){if(\\"string\\"==typeof o)return o;if(\\"symbol\\"==typeof o)return`@@${o.toString().slice(14,-1)}`;throw new TypeError(`Unexpected property name type ${t} ${o}`)}function F(t){const o=[\\"undefined\\",\\"boolean\\",\\"number\\",\\"string\\",\\"symbol\\"];function r(r,e,n,i){if(\\"object\\"==typeof i)return a(r,e,i),!0;if(!1===i)return!1;if(\\"string\\"==typeof i)if(\\"prototype\\"===n||\\"constructor\\"===n){if(w(t,i))return e===t[i]}else if(o.includes(i))return typeof e===i;throw new TypeError(`Unexpected whitelist permit ${r}`)}function e(t,o,e,n){const a=E(o,e);return w(a,\\"value\\")?r(t,a.value,e,n):r(`${t}<get>`,a.get,e,n.get)&&r(`${t}<set>`,a.set,e,n.set)}function n(t,o){return w(t,o)?t[o]:\\"FunctionPrototype\\"===t[\\"**proto**\\"]&&w(u,o)?u[o]:void 0}function a(o,r,a){!function(o,r,e){const n=A(r);if(null!==n||null!==e){if(void 0!==e&&\\"string\\"!=typeof e)throw new TypeError(`Malformed whitelist permit ${o}.__proto__`);if(n!==t[e||\\"ObjectPrototype\\"])throw new Error(`Unexpected intrinsic ${o}.__proto__`)}}(o,r,a[\\"**proto**\\"]);for(const t of _(r)){if(\\"__proto__\\"===t)continue;const i=I(o,t),c=`${o}.${i}`,p=n(a,i);if(!p||!e(c,r,t,p))try{delete r[t]}catch(t){}}}a(\\"intrinsics\\",t,h)}const{defineProperties:T,getOwnPropertyDescriptors:v}=Object;const{getOwnPropertyDescriptor:O}=Object;const{defineProperties:U,getOwnPropertyDescriptors:x,getOwnPropertyDescriptor:R}=Object;const C=!0;var M={ObjectPrototype:\\"*\\",ArrayPrototype:\\"*\\",FunctionPrototype:{constructor:C,bind:C,name:C,toString:C},ErrorPrototype:{constructor:C,message:C,name:C},PromisePrototype:{constructor:C},TypedArrayPrototype:\\"*\\",Generator:{constructor:C,name:C,toString:C},IteratorPrototype:\\"*\\"};const{defineProperties:j,getOwnPropertyNames:G,getOwnPropertyDescriptor:k,getOwnPropertyDescriptors:N}=Object,{ownKeys:$}=Reflect;function D(t){return null!==t&&\\"object\\"==typeof t}const{assign:B,freeze:L,defineProperties:W,getOwnPropertyDescriptor:V,getOwnPropertyNames:z,getPrototypeOf:Y,setPrototypeOf:J,prototype:H}=Object,{apply:K,get:Q,set:X}=Reflect,{isArray:q,prototype:Z}=Array,{revocable:tt}=Proxy,{prototype:ot}=RegExp,{prototype:rt}=String,{prototype:et}=WeakMap,nt=t=>(o,...r)=>K(t,o,r),at=nt(H.hasOwnProperty),it=(nt(Z.filter),nt(Z.join)),ct=(nt(Z.push),nt(Z.pop)),pt=nt(Z.includes),st=nt(ot.test),yt=(nt(rt.match),nt(rt.search)),lt=nt(rt.slice),ut=nt(rt.split),gt=(nt(et.get),nt(et.set),nt(et.has),t=>Q(Y(t),\\"constructor\\")),ft=L({__proto__:null});function Pt(t,o){const r=`please report internal shim error: ${t}`;throw console.error(r),o&&(console.error(`${o}`),console.error(`${o.stack}`)),TypeError(r)}function bt(t,o){t||Pt(o)}const mt=[\\"await\\",\\"break\\",\\"case\\",\\"catch\\",\\"class\\",\\"const\\",\\"continue\\",\\"debugger\\",\\"default\\",\\"delete\\",\\"do\\",\\"else\\",\\"export\\",\\"extends\\",\\"finally\\",\\"for\\",\\"function\\",\\"if\\",\\"import\\",\\"in\\",\\"instanceof\\",\\"new\\",\\"return\\",\\"super\\",\\"switch\\",\\"this\\",\\"throw\\",\\"try\\",\\"typeof\\",\\"var\\",\\"void\\",\\"while\\",\\"with\\",\\"yield\\",\\"let\\",\\"static\\",\\"enum\\",\\"implements\\",\\"package\\",\\"protected\\",\\"interface\\",\\"private\\",\\"public\\",\\"await\\",\\"null\\",\\"true\\",\\"false\\",\\"this\\",\\"arguments\\"],dt=new RegExp(\\"^[a-zA-Z_$][\\\\\\\\w$]*$\\");function ht(t){return\\"eval\\"!==t&&!pt(mt,t)&&st(dt,t)}function At(t,o){const r=V(t,o);return(!1===r.configurable&&!1===r.writable&&at(r,\\"value\\"))}const Et=new Proxy(ft,{get(t,o){Pt(`unexpected scope handler trap called: ${String(o)}`)}});function St(t,o){const r=yt(t,o);return r<0?-1:ut(lt(t,0,r),\\"\\\\n\\").length}const _t=new RegExp(\\"(?:\\\\x3c!--|--\\\\x3e)\\");const wt=new RegExp(\\"\\\\\\\\bimport\\\\\\\\s*(?:\\\\\\\\(|/[/*])\\");const It=new RegExp(\\"\\\\\\\\beval\\\\\\\\s*(?:\\\\\\\\(|/[/*])\\");const Ft={rewrite:t=>(function(t){const o=St(t,_t);if(o<0)return t;throw new SyntaxError(`possible html comment syntax rejected around line ${o}`)}(t.src),function(t){const o=St(t,wt);if(o<0)return t;throw new SyntaxError(`possible import expression rejected around line ${o}`)}(t.src),function(t){const o=St(t,It);if(o<0)return t;throw new SyntaxError(`possible direct eval expression rejected around line ${o}`)}(t.src),t)};function Tt(t,o=[]){const r=function(t){return 0===t.length?\\"\\":`const {${it(t,\\",\\")}} = this;`}(o);return t.intrinsics.Function(`\\\\n with (this) {\\\\n ${r}\\\\n return function() {\\\\n \'use strict\';\\\\n return eval(arguments[0]);\\\\n };\\\\n }\\\\n `)}function vt(t,o,r,e={},{localTransforms:n=[],globalTransforms:a=[],sloppyGlobalsMode:i=!1}={}){let c={src:o,endowments:e};c=function(t,o){for(const r of o)\\"function\\"==typeof r.rewrite&&(t=r.rewrite(t));return t}(c,[...n,...a,Ft]);const p=function(t,o,r={},{sloppyGlobalsMode:e=!1}={}){return{__proto__:Et,useUnsafeEvaluator:!1,get(e,n){if(\\"symbol\\"!=typeof n)return\\"eval\\"===n&&!0===this.useUnsafeEvaluator?(this.useUnsafeEvaluator=!1,t.intrinsics.eval):n in r?Q(r,n,o):Q(o,n)},set(t,e,n){if(e in r){return\\"value\\"in V(r,e)?X(r,e,n):X(r,e,n,o)}return X(o,e,n)},has:(t,n)=>!!(e||\\"eval\\"===n||n in r||n in o||n in globalThis),getPrototypeOf:()=>null}}(t,r,c.endowments,{sloppyGlobalsMode:i}),s=tt(ft,p),y=Tt(t,function(t,o={}){const r=z(t),e=z(o),n=e.filter(t=>ht(t)&&At(o,t));return[...r.filter(o=>!e.includes(o)&&ht(o)&&At(t,o)),...n]}(r,c.endowments)),l=K(y,s.proxy,[]);let u;p.useUnsafeEvaluator=!0;try{return K(l,r,[c.src])}catch(t){throw u=t,t}finally{!0===p.useUnsafeEvaluator&&(Pt(\\"handler did not revoke useUnsafeEvaluator\\",u),s.revoke())}}const Ot=(t,o,r={})=>{const e=e=>\\"string\\"!=typeof e?e:vt(t,e,o,{},r);return W(e,{toString:{value:()=>\\"function eval() { [native code] }\\",writable:!1,enumerable:!1,configurable:!0}}),bt(gt(e)!==Function,\\"eval constructor is Function\\"),bt(gt(e)!==t.intrinsics.Function,\\"eval contructions is %Function%\\"),e};function Ut(t,o,r={}){const e=function(e){const n=`${ct(arguments)||\\"\\"}`,a=`${it(arguments,\\",\\")}`;new t.intrinsics.Function(a,n);const i=`(function anonymous(${a}\\\\n) {\\\\n${n}\\\\n})`;return vt(t,i,o,{},r)};return W(e,{prototype:{value:t.intrinsics.Function.prototype,writable:!1,enumerable:!1,configurable:!1},toString:{value:()=>\\"function Function() { [native code] }\\",writable:!1,enumerable:!1,configurable:!0}}),bt(Y(Function)===Function.prototype),bt(Y(e)===Function.prototype),bt(gt(e)!==Function),bt(gt(e)!==t.intrinsics.Function),e}const xt=[\\"eval\\",\\"isFinite\\",\\"isNaN\\",\\"parseFloat\\",\\"parseInt\\",\\"decodeURI\\",\\"decodeURIComponent\\",\\"encodeURI\\",\\"encodeURIComponent\\",\\"Array\\",\\"ArrayBuffer\\",\\"Boolean\\",\\"DataView\\",\\"Date\\",\\"Error\\",\\"EvalError\\",\\"Float32Array\\",\\"Float64Array\\",\\"Function\\",\\"Int8Array\\",\\"Int16Array\\",\\"Int32Array\\",\\"Map\\",\\"Number\\",\\"Object\\",\\"Promise\\",\\"Proxy\\",\\"RangeError\\",\\"ReferenceError\\",\\"RegExp\\",\\"Set\\",\\"String\\",\\"Symbol\\",\\"SyntaxError\\",\\"TypeError\\",\\"Uint8Array\\",\\"Uint8ClampedArray\\",\\"Uint16Array\\",\\"Uint32Array\\",\\"URIError\\",\\"WeakMap\\",\\"WeakSet\\",\\"JSON\\",\\"Math\\",\\"Reflect\\",\\"escape\\",\\"unescape\\",\\"globalThis\\",\\"Compartment\\",\\"harden\\"];const{getOwnPropertyDescriptor:Rt}=Object,Ct=[\\"eval\\",\\"isFinite\\",\\"isNaN\\",\\"parseFloat\\",\\"parseInt\\",\\"decodeURI\\",\\"decodeURIComponent\\",\\"encodeURI\\",\\"encodeURIComponent\\",\\"Array\\",\\"ArrayBuffer\\",\\"Boolean\\",\\"DataView\\",\\"Date\\",\\"Error\\",\\"EvalError\\",\\"Float32Array\\",\\"Float64Array\\",\\"Function\\",\\"Int8Array\\",\\"Int16Array\\",\\"Int32Array\\",\\"Map\\",\\"Number\\",\\"Object\\",\\"Promise\\",\\"Proxy\\",\\"RangeError\\",\\"ReferenceError\\",\\"RegExp\\",\\"Set\\",\\"String\\",\\"Symbol\\",\\"SyntaxError\\",\\"TypeError\\",\\"Uint8Array\\",\\"Uint8ClampedArray\\",\\"Uint16Array\\",\\"Uint32Array\\",\\"URIError\\",\\"WeakMap\\",\\"WeakSet\\",\\"JSON\\",\\"Math\\",\\"Reflect\\",\\"escape\\",\\"unescape\\",\\"globalThis\\",\\"Compartment\\",\\"harden\\"];let Mt;function jt(){if(Mt)return Mt;const t=function(){const t={__proto__:null};for(const o of Ct){const r=Rt(globalThis,o);if(r){if(\\"get\\"in r||\\"set\\"in r)throw new TypeError(`Unexpected accessor on global property: ${o}`);t[o]=r.value}}return t}();return Mt={__proto__:null,intrinsics:t},L(Mt)}const Gt=new WeakMap;class kt{constructor(t,o,r={}){const{transforms:e=[]}=r,n=[...e],a=function(t,{globalTransforms:o}){const r={},e={Infinity:{value:1/0,enumerable:!1},NaN:{value:NaN,enumerable:!1},undefined:{value:void 0,enumerable:!1}};for(const n of xt){if(!at(t.intrinsics,n))continue;let a;switch(n){case\\"eval\\":a=Ot(t,r,{globalTransforms:o});break;case\\"Function\\":a=Ut(t,r,{globalTransforms:o});break;case\\"globalThis\\":a=r;break;default:a=t.intrinsics[n]}e[n]={value:a,configurable:!0,writable:!0,enumerable:!1}}return W(r,e),bt(r.eval!==t.intrinsics.eval,\\"eval on global object\\"),bt(r.Function!==t.intrinsics.Function,\\"Function on global object\\"),r}(jt(),{globalTransforms:n});B(a,t),Gt.set(this,{globalTransforms:n,globalObject:a})}get global(){return Gt.get(this).globalObject}evaluate(t,o={}){if(\\"string\\"!=typeof t)throw new TypeError(\\"first argument of evaluate() must be a string\\");const{endowments:r={},transforms:e=[],sloppyGlobalsMode:n=!1}=o,a=[...e],{globalTransforms:i,globalObject:c}=Gt.get(this);return vt(jt(),t,c,r,{globalTransforms:i,localTransforms:a,sloppyGlobalsMode:n})}toString(){return\\"[object Compartment]\\"}static toString(){return\\"function Compartment() { [shim code] }\\"}}let Nt;function $t(t,o){if(!t)throw new TypeError(o)}\\"object\\"!=typeof globalThis&&(Object.prototype.__defineGetter__(\\"__magic__\\",(function(){return this})),__magic__.globalThis=__magic__,delete Object.prototype.__magic__),t.lockdown=function(t={}){const{noTameDate:o=!1,noTameError:r=!1,noTameMath:e=!1,noTameRegExp:n=!1,registerOnly:a=!1,...i}=t,c=Object.keys(i);$t(0===c.length,`lockdown(): non supported option ${c.join(\\", \\")}`);const p={noTameDate:o,noTameError:r,noTameMath:e,noTameRegExp:n,registerOnly:a};if(Nt)return Object.keys(p).forEach(t=>{$t(p[t]===Nt[t],`lockdown(): cannot re-invoke with different option ${t}`)}),!1;Nt=p,function(){try{(0,Function.prototype.constructor)(\\"return 1\\")}catch(t){return}const{defineProperties:t,getPrototypeOf:o,setPrototypeOf:r}=Object;function e(e,n){let a;try{a=(0,eval)(n)}catch(t){if(t instanceof SyntaxError)return;throw t}const i=o(a),c=function(){throw new TypeError(\\"Not available\\")};t(c,{name:{value:e,writable:!1,enumerable:!1,configurable:!0},toString:{value:()=>`function ${e}() { [native code] }`,writable:!1,enumerable:!1,configurable:!0}}),t(i,{constructor:{value:c}}),t(c,{prototype:{value:i}}),c!==Function.prototype.constructor&&r(c,Function.prototype.constructor)}e(\\"Function\\",\\"(function(){})\\"),e(\\"GeneratorFunction\\",\\"(function*(){})\\"),e(\\"AsyncFunction\\",\\"(async function(){})\\"),e(\\"AsyncGeneratorFunction\\",\\"(async function*(){})\\")}(),o||function(){const t={now:()=>NaN};Date.now=t.now;const o={toLocaleString:()=>NaN};Date.prototype.toLocaleString=o.toLocaleString;const r=Date,e=function(){return void 0===new.target?\\"Invalid Date\\":arguments.length>0?Reflect.construct(r,arguments,new.target):Reflect.construct(r,[NaN],new.target)},n=v(r);T(e,n);const a=v(r.prototype);a.constructor.value=e,T(e.prototype,a),globalThis.Date=e;const i={toLocaleString(){throw new TypeError(\\"Object.prototype.toLocaleString is disabled\\")}};Object.prototype.toLocaleString=i.toLocaleString}(),r||function(){if(delete Error.captureStackTrace,O(Error,\\"captureStackTrace\\"))throw Error(\\"Cannot remove Error.captureStackTrace\\");if(delete Error.stackTraceLimit,O(Error,\\"stackTraceLimit\\"))throw Error(\\"Cannot remove Error.stackTraceLimit\\")}(),e||function(){const t={random(){throw TypeError(\\"Math.random() is disabled\\")}};Math.random=t.random}(),n||function(){delete RegExp.prototype.compile;const t=RegExp,o=function(){return Reflect.construct(t,arguments,new.target)},r=R(t,Symbol.species);U(o,Symbol.species,r);const e=x(t.prototype);e.constructor.value=o,U(o.prototype,e),globalThis.RegExp=o}();const s=function(t,o={}){const{freeze:r,getOwnPropertyDescriptors:e,getPrototypeOf:n}=Object,{ownKeys:a}=Reflect;let{fringeSet:i}=o;if(i){if(\\"function\\"!=typeof i.add||\\"function\\"!=typeof i.has)throw new TypeError(\\"options.fringeSet must have add() and has() methods\\");if(t)for(const o of t)i.add(o)}else i=new WeakSet(t);const c=o&&o.naivePrepareObject,{harden:p}={harden(t){const o=new Set,p=new Map,s=new WeakMap;function y(t,r){if(Object(t)!==t)return;const e=typeof t;if(\\"object\\"!==e&&\\"function\\"!==e)throw new TypeError(`Unexpected typeof: ${e}`);i.has(t)||o.has(t)||(o.add(t),s.set(t,r))}function l(t){c&&c(t),r(t);const o=n(t),i=e(t),l=s.get(t)||\\"unknown\\";null===o||p.has(o)||(p.set(o,l),s.set(o,`${l}.__proto__`)),a(i).forEach(t=>{const o=`${l}.${String(t)}`,r=i[t];\\"value\\"in r?y(r.value,`${o}`):(y(r.get,`${o}(get)`),y(r.set,`${o}(set)`))})}return y(t),o.forEach(l),p.forEach((t,r)=>{if(!o.has(r)&&!i.has(r)){let o;try{o=`prototype ${r} of ${t} is not already in the fringeSet`}catch(e){o=\\"a prototype of something is not already in the fringeset (and .toString failed)\\";try{console.log(o),console.log(\\"the prototype:\\",r),console.log(\\"of something:\\",t)}catch(t){}}throw new TypeError(o)}}),o.forEach(i.add,i),t}};return p}();Object.defineProperties(globalThis,{harden:{value:s,configurable:!0,writable:!0,enumerable:!1},Compartment:{value:kt,configurable:!0,writable:!0,enumerable:!1}});const y=l();F(y),function(){try{(0,Object.prototype.__lookupGetter__)(\\"x\\")}catch(t){return}const{defineProperty:t,defineProperties:o,getOwnPropertyDescriptor:r,getPrototypeOf:e,prototype:n}=Object;function a(t){if(null==t)throw new TypeError(\\"can\'t convert undefined or null to object\\");return Object(t)}function i(t){return\\"symbol\\"==typeof t?t:`${t}`}function c(t,o){if(\\"function\\"!=typeof t)throw TypeError(`invalid ${o} usage`);return t}o(n,{__defineGetter__:{value:function(o,r){const e=a(this);t(e,o,{get:c(r,\\"getter\\"),enumerable:!0,configurable:!0})}},__defineSetter__:{value:function(o,r){const e=a(this);t(e,o,{set:c(r,\\"setter\\"),enumerable:!0,configurable:!0})}},__lookupGetter__:{value:function(t){let o,n=a(this);for(t=i(t);n&&!(o=r(n,t));)n=e(n);return o&&o.get}},__lookupSetter__:{value:function(t){let o,n=a(this);for(t=i(t);n&&!(o=r(n,t));)n=e(n);return o&&o.set}}})}();const u=function(t){const o={};function r(t,r,e,n){if(\\"value\\"in n&&n.configurable){const{value:a}=n;o[t]=a,j(r,{[e]:{get:function(){return a},set:function(o){if(r===this)throw new TypeError(`Cannot assign to read only property \'${e}\' of \'${t}\'`);hasOwnProperty.call(this,e)?this[e]=o:j(this,{[e]:{value:o,writable:!0,enumerable:n.enumerable,configurable:n.configurable}})},enumerable:n.enumerable,configurable:n.configurable}})}}function e(t,o,e){const n=k(o,e);n&&r(t,o,e,n)}function n(t,o){const e=N(o);e&&$(e).forEach(n=>r(t,o,n,e[n]))}return function t(o,r,a){for(const i of G(a)){const c=k(r,i);if(!c||c.get||c.set)continue;const p=`${o}.${i}`,s=a[i];if(!0===s)e(p,r,i);else if(\\"*\\"===s)n(p,c.value);else{if(!D(s))throw new TypeError(`Unexpected override enablement plan ${p}`);t(p,c.value,s)}}}(\\"root\\",t,M),o}(y);return s(y,a),s(u,a),!0},Object.defineProperty(t,\\"__esModule\\",{value:!0})}));\\n"')},function(t,n,e){"use strict";n.byteLength=function(t){var n=u(t),e=n[0],r=n[1];return 3*(e+r)/4-r},n.toByteArray=function(t){var n,e,r=u(t),s=r[0],a=r[1],c=new i(function(t,n,e){return 3*(n+e)/4-e}(0,s,a)),h=0,f=a>0?s-4:s;for(e=0;e<f;e+=4)n=o[t.charCodeAt(e)]<<18|o[t.charCodeAt(e+1)]<<12|o[t.charCodeAt(e+2)]<<6|o[t.charCodeAt(e+3)],c[h++]=n>>16&255,c[h++]=n>>8&255,c[h++]=255&n;2===a&&(n=o[t.charCodeAt(e)]<<2|o[t.charCodeAt(e+1)]>>4,c[h++]=255&n);1===a&&(n=o[t.charCodeAt(e)]<<10|o[t.charCodeAt(e+1)]<<4|o[t.charCodeAt(e+2)]>>2,c[h++]=n>>8&255,c[h++]=255&n);return c},n.fromByteArray=function(t){for(var n,e=t.length,o=e%3,i=[],s=16383,a=0,c=e-o;a<c;a+=s)i.push(h(t,a,a+s>c?c:a+s));1===o?(n=t[e-1],i.push(r[n>>2]+r[n<<4&63]+"==")):2===o&&(n=(t[e-2]<<8)+t[e-1],i.push(r[n>>10]+r[n>>4&63]+r[n<<2&63]+"="));return i.join("")};for(var r=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)r[a]=s[a],o[s.charCodeAt(a)]=a;function u(t){var n=t.length;if(n%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=t.indexOf("=");return-1===e&&(e=n),[e,e===n?0:4-e%4]}function h(t,n,e){for(var o,i,s=[],a=n;a<e;a+=3)o=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(r[(i=o)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(t,n){
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
n.read=function(t,n,e,r,o){var i,s,a=8*o-r-1,c=(1<<a)-1,u=c>>1,h=-7,f=e?o-1:0,l=e?-1:1,d=t[n+f];for(f+=l,i=d&(1<<-h)-1,d>>=-h,h+=a;h>0;i=256*i+t[n+f],f+=l,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=r;h>0;s=256*s+t[n+f],f+=l,h-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),i-=u}return(d?-1:1)*s*Math.pow(2,i-r)},n.write=function(t,n,e,r,o,i){var s,a,c,u=8*i-o-1,h=(1<<u)-1,f=h>>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:i-1,p=r?1:-1,b=n<0||0===n&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(a=isNaN(n)?1:0,s=h):(s=Math.floor(Math.log(n)/Math.LN2),n*(c=Math.pow(2,-s))<1&&(s--,c*=2),(n+=s+f>=1?l/c:l*Math.pow(2,1-f))*c>=2&&(s++,c/=2),s+f>=h?(a=0,s=h):s+f>=1?(a=(n*c-1)*Math.pow(2,o),s+=f):(a=n*Math.pow(2,f-1)*Math.pow(2,o),s=0));o>=8;t[e+d]=255&a,d+=p,a/=256,o-=8);for(s=s<<o|a,u+=o;u>0;t[e+d]=255&s,d+=p,s/=256,u-=8);t[e+d-p]|=128*b}},function(t,n){var e={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==e.call(t)}},function(t,n,e){const r=e(2),o=e(18),i=e(5),{D:s,ut:a,J:c,G:u}=e(0),h=e(22);t.exports=function(t,n,f){switch(r.Ut&&r.Dt("Execute","Executing",t,JSON.stringify(n)),t){case"DEPLOY":return function(t,n){const r=e(9),c=e(24);s(t instanceof Array,"DEPLOY data must be an array"),s(t.length%2==0,"Invalid DEPLOY data length");const u=t.length/2,f=[];for(let t=0;t<u;t++)f.push(r.Yt());const l={g:i.g,jo:t=>{const e=n[t]||f[t-n.length];if(!e)throw new Error(`Invalid local jig reference: ${t}`);return e}},d=o.ko(t,l);for(let t=0;t<u;t++){const n=d[2*t+0],e=d[2*t+1];s("string"==typeof n,"DEPLOY src must be a string"),s("object"==typeof e&&!Array.isArray(e)&&e,"DEPLOY props must be an object"),c.Pt(n);const[o]=i.dn(n,e.deps);s("function"==typeof o,`DEPLOY src not supported: ${n}`),Object.keys(e).forEach((t=>{a(o,t,e[t])}));const u=f[t],h=!1,[l]=r.Ne(u,o,h);r.Tt(u).ie(l,h,[],n)}h.vn(f)}(n,f);case"UPGRADE":return function(t,n){const Code=e(1),r=e(9),c=e(24),u={g:i.g,jo:t=>n[t]},h=o.ko(t,u);s(Array.isArray(h),"UPGRADE data must be an array"),s(3===h.length,"Invalid UPGRADE data length"),s(h[0]instanceof Code,"Must only upgrade code"),s("string"==typeof h[1],"UPGRADE src must be a string"),s("object"==typeof h[2]&&!Array.isArray(h[2])&&h[2],"UPGRADE props must be an object");const[f,l,d]=h;c.Pt(l);const[p]=i.dn(l,d.deps);Object.keys(d).forEach((t=>{a(p,t,d[t])}));const[b]=r.Ne(f,p),w=!1;r.Lt(f,b,w,l)}(n,f);case"CALL":return function(t,n){const Code=e(1),Jig=e(7),r={g:i.g,jo:t=>n[t]},a=o.ko(t,r);s(3===a.length,"Invalid CALL data length"),s(a[0]instanceof Code&&(u(a[0],Jig)||"auth"===a[1]||"destroy"===a[1])||a[0]instanceof Jig,"Must only execute CALL on jigs or code"),s("string"==typeof a[1],"CALL method must be a string: "+a[1]),s(Array.isArray(a[2]),"CALL args must be an array"),s(a[0]instanceof Jig||"upgrade"!==a[1],"Cannot execute upgrade() with CALL");const[h,f,l]=a;if("function"!=typeof h[f])throw new Error(`Cannot call ${c(h)}.${f}()`);h[f](...l)}(n,f);case"NEW":return function(t,n){const Code=e(1),Jig=e(7),r={g:i.g,jo:t=>n[t]},a=o.ko(t,r);s(2===a.length,"Invalid NEW data length"),s(a[0]instanceof Code,"Must only execute NEW on code"),s(u(a[0],Jig),"Must only execute NEW on a jig class"),s(Array.isArray(a[1]),"NEW args must be an array");const[c,h]=a;new c(...h)}(n,f);default:throw new Error(`Unknown op: ${t}`)}}},function(t,n,e){{const CacheWrapper=e(38),LocalCache=e(39),n=e(56);class BrowserCache extends CacheWrapper{constructor(t={}){super(),this.localCache=new LocalCache({maxSizeMB:t.maxMemorySizeMB}),this.indexedDbCache=new n({dbName:t.dbName,dbStore:t.dbStore,dbVersion:t.dbVersion}),this.localCache.setWrappingEnabled(!1),this.indexedDbCache.setWrappingEnabled(!1)}get maxMemorySizeMB(){return this.localCache.maxSizeMB}set maxMemorySizeMB(t){this.localCache.maxSizeMB=t}async get(t){const n=await this.localCache.get(t);if(void 0!==n)return n;const e=await this.indexedDbCache.get(t);return void 0!==e?(await this.localCache.set(t,e),e):void 0}async set(t,n){return Promise.all([this.localCache.set(t,n),this.indexedDbCache.set(t,n)])}}t.exports=BrowserCache}},function(t,n,e){t.exports=null},function(t,n,e){const r=e(2),{Mn:o}=e(8),{J:i,yt:s}=e(0),{h:a}=e(4),{TimeoutError}=e(11),{Io:c}=e(19),LocalOwner=e(57),u="Inventory";t.exports=class{constructor(){this.La=(t,n)=>this.Gc(n),this.qs=[]}attach(t){this.detach(),r.Ut&&r.Dt(u,"Attach"),this.Jc=t,t.on("update",this.La),t.on("publish",this.La),t.on("sync",this.La),this.Kc=null,this.Ji=[],t.owner instanceof LocalOwner&&(this.Kc=o(t.owner.address))}detach(t){this.Jc&&(r.Ut&&r.Dt(u,"Detach"),this.Jc.off("update",this.La),this.Jc.off("publish",this.La),this.Jc.off("sync",this.La),this.Jc=null,this.Kc=null,this.Ji=null)}get jigs(){this.Vc();const Jig=e(7);return this.qs.filter((t=>t instanceof Jig))}get code(){this.Vc();const Code=e(1);return this.qs.filter((t=>t instanceof Code))}async sync(){if(r.tn&&r.qt(u,"Sync"),!this.Kc)try{if(!this.Jc||!this.Jc.er.Mn.nextOwner)throw new Error("Inventory cannot determine owner");const t=await this.Jc.er.Mn.nextOwner();this.Kc=o(t),r.Ut&&r.Dt(u,"Owner",t),this.Ji&&this.Ji.forEach((t=>this.Gc(t)))}finally{this.Ji=null}if(this.Kc)return this.kt||(this.kt=this.Yc().then((()=>{this.kt=null})).catch((t=>{throw this.kt=null,t}))),this.kt}async Yc(){let t;if("function"==typeof this.Jc.state.locations){const n=this.Kc.script();t=await this.Jc.state.locations(n)}else{const n=this.Kc.script();t=(await this.Jc.blockchain.utxos(n)).map((t=>`${t.txid}_o${t.vout}`))}const n=a((()=>this.qs.map((t=>t.location)))),o=e(16),i=new o.Oo,h=new s("inventory sync",this.Jc.er._t);for(const e of t){if(n.includes(e))continue;let t=null;try{t=await o(e,void 0,this.Jc.er,i,h)}catch(t){if(t instanceof TimeoutError)throw t;if(t instanceof c)throw t;r.nn&&r.Xt(u,`Failed to load ${e}\n\n${t.toString()}`);continue}this.Gc(t)}this.Vc()}Gc(t){!this.Kc&&this.Ji&&this.Ji.push(t);const n=this.qs.find((n=>this.Wc(n,t)));n&&a((()=>n.nonce>t.nonce))||(this.qs=this.qs.filter((t=>t!==n)),this.zc(t)?(!n&&r.tn&&r.qt(u,"Add",i(t)),this.qs.push(t)):n&&r.tn&&r.qt(u,"Remove",i(t)))}Wc(t,n){if(t===n)return!0;const e=a((()=>t.origin)),r=a((()=>n.origin));return!e.startsWith("error://")&&(!r.startsWith("error://")&&e===r)}zc(t){try{if(a((()=>t.location)).startsWith("error://"))return!1;const n=a((()=>t.owner));if(void 0===n)return!0;if(!this.Kc)return!1;const e=o(n).script();return e===this.Kc.script()}catch(t){return!1}}Vc(){this.qs=this.qs.filter((t=>!!this.zc(t)||(r.tn&&r.qt(u,"Remove",i(t)),!1)))}}},function(t){t.exports=JSON.parse('{"jig://05f67252e696160a7c0099ae8d1ec23c39592378773b3a5a55f16bd1286e7dcb_o2":{"kind":"code","props":{"deps":{"Hex":{"$jig":"727e7b423b7ee40c0b5be87fba7fa5673ea2d20a74259040a7295d9c32a90011_o1"},"Tx":{"$jig":"_o1"}},"location":"_o2","nonce":2,"origin":"312985bd960ae4c59856b3089b04017ede66506ea181333eec7c9bb88b11c490_o1","owner":"1PytriYokKN3GpKw84L4vvrGBwUvTYzCpx","satoshis":0},"src":"function txo (rawtx) {\\n const ret = { }\\n\\n function chunks (script) {\\n const b = Hex.stringToBytes(script)\\n let i = 0\\n\\n function u8 () { return b[i++] }\\n function u16 () { return u8() + u8() * 256 }\\n function u32 () { return u16() + u16() * 256 * 256 }\\n function buf (n) { const h = Hex.bytesToString(b.slice(i, i + n)); i += n; return h }\\n\\n const OP_PUSHDATA1 = 0x4c\\n const OP_PUSHDATA2 = 0x4d\\n const OP_PUSHDATA4 = 0x4e\\n\\n const chunks = []\\n while (i < b.length) {\\n const opcodenum = u8()\\n if (opcodenum > 0 && opcodenum < OP_PUSHDATA1) {\\n chunks.push({ buf: buf(opcodenum), len: opcodenum, opcodenum })\\n } else if (opcodenum === OP_PUSHDATA1) {\\n const len = u8()\\n chunks.push({ buf: buf(len), len, opcodenum })\\n } else if (opcodenum === OP_PUSHDATA2) {\\n const len = u16()\\n chunks.push({ buf: buf(len), len, opcodenum })\\n } else if (opcodenum === OP_PUSHDATA4) {\\n const len = u32()\\n chunks.push({ buf: buf(len), len, opcodenum })\\n } else {\\n chunks.push({ opcodenum })\\n }\\n }\\n return chunks\\n }\\n\\n // https://stackoverflow.com/questions/23190056/hex-to-base64-converter-for-javascript\\n function bytesToBase64 (arr) {\\n const abc = \'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\' // base64 alphabet\\n const bin = n => n.toString(2).padStart(8, 0) // convert num to 8-bit binary string\\n const l = arr.length\\n let result = \'\'\\n for (let i = 0; i <= (l - 1) / 3; i++) {\\n const c1 = i * 3 + 1 >= l // case when \\"=\\" is on end\\n const c2 = i * 3 + 2 >= l // case when \\"=\\" is on end\\n const chunk = bin(arr[3 * i]) + bin(c1 ? 0 : arr[3 * i + 1]) + bin(c2 ? 0 : arr[3 * i + 2])\\n const r = chunk.match(/.{1,6}/g).map((x, j) => j === 3 && c2 ? \'=\' : (j === 2 && c1 ? \'=\' : abc[+(\'0b\' + x)]))\\n result += r.join(\'\')\\n }\\n return result\\n }\\n\\n function xput (script, output) {\\n const ret = { }\\n chunks(script).forEach((c, n) => {\\n if (c.buf) {\\n ret[\'b\' + n] = bytesToBase64(Hex.stringToBytes(c.buf))\\n const enc = c.buf.replace(/[0-9a-f]{2}/g, \'%$&\')\\n if (output) try { ret[\'s\' + n] = decodeURIComponent(enc) } catch (e) { }\\n if (output) ret[\'h\' + n] = c.buf\\n } else {\\n ret[\'b\' + n] = { op: c.opcodenum }\\n }\\n })\\n return ret\\n }\\n\\n function input (txin, i) {\\n const ret = xput(txin.script)\\n ret.e = { h: txin.prevTxId, i: txin.outputIndex }\\n ret.i = i\\n ret.seq = txin.sequenceNumber\\n return ret\\n }\\n\\n function output (txout, i) {\\n const ret = xput(txout.script, true)\\n ret.e = { v: txout.satoshis, i }\\n ret.i = i\\n return ret\\n }\\n\\n const tx = new Tx(rawtx)\\n ret.in = tx.inputs.map(input)\\n ret.out = tx.outputs.map(output)\\n ret.lock = tx.nLockTime\\n return ret\\n}","version":"04"},"jig://727e7b423b7ee40c0b5be87fba7fa5673ea2d20a74259040a7295d9c32a90011_o1":{"kind":"code","props":{"deps":{},"location":"_o1","nonce":1,"origin":"_o1","owner":"1PytriYokKN3GpKw84L4vvrGBwUvTYzCpx","satoshis":0},"src":"class Hex {\\n static stringToBytes (s) {\\n if (typeof s !== \'string\' || s.length % 2 !== 0) {\\n throw new Error(`Bad hex: ${s}`)\\n }\\n\\n s = s.toLowerCase()\\n\\n const HEX_CHARS = \'0123456789abcdef\'.split(\'\')\\n const bytes = []\\n\\n for (let i = 0; i < s.length; i += 2) {\\n const high = HEX_CHARS.indexOf(s[i])\\n const low = HEX_CHARS.indexOf(s[i + 1])\\n\\n if (high === -1 || low === -1) {\\n throw new Error(`Bad hex: ${s}`)\\n }\\n\\n bytes.push(high * 16 + low)\\n }\\n\\n return bytes\\n }\\n\\n static bytesToString (b) {\\n if (!Array.isArray(b)) throw new Error(`Bad bytes: ${b}`)\\n\\n const validDigit = x => Number.isInteger(x) && x >= 0 && x < 256\\n b.forEach(x => { if (!validDigit(x)) throw new Error(`Bad digit: ${x}`) })\\n\\n return b\\n .map(x => x.toString(\'16\'))\\n .map(x => x.length === 1 ? \'0\' + x : x)\\n .join(\'\')\\n }\\n}","version":"04"},"jig://05f67252e696160a7c0099ae8d1ec23c39592378773b3a5a55f16bd1286e7dcb_o1":{"kind":"code","props":{"deps":{"Hex":{"$jig":"727e7b423b7ee40c0b5be87fba7fa5673ea2d20a74259040a7295d9c32a90011_o1"}},"location":"_o1","nonce":2,"origin":"312985bd960ae4c59856b3089b04017ede66506ea181333eec7c9bb88b11c490_o2","owner":"1PytriYokKN3GpKw84L4vvrGBwUvTYzCpx","satoshis":0},"src":"class Tx {\\n constructor (rawtx) {\\n const b = Hex.stringToBytes(rawtx)\\n let i = 0\\n\\n function u8 () { return b[i++] }\\n function u16 () { return u8() + u8() * 256 }\\n function u32 () { return u16() + u16() * 256 * 256 }\\n function u64 () { return u32() + u32() * 256 * 256 * 256 * 256 }\\n function varint () { const b0 = u8(); return b0 === 0xff ? u64() : b0 === 0xfe ? u32() : b0 === 0xfd ? u16() : b0 }\\n function txid () { const h = Hex.bytesToString(b.slice(i, i + 32).reverse()); i += 32; return h }\\n function script () { const n = varint(); const h = Hex.bytesToString(b.slice(i, i + n)); i += n; return h }\\n\\n this.version = u32()\\n\\n const nin = varint()\\n this.inputs = []\\n for (let vin = 0; vin < nin; vin++) {\\n this.inputs.push({\\n prevTxId: txid(),\\n outputIndex: u32(),\\n script: script(),\\n sequenceNumber: u32()\\n })\\n }\\n\\n const nout = varint()\\n this.outputs = []\\n for (let vout = 0; vout < nout; vout++) {\\n this.outputs.push({\\n satoshis: u64(),\\n script: script()\\n })\\n }\\n\\n this.nLockTime = u32()\\n }\\n}","version":"04"},"jig://72a61eb990ffdb6b38e5f955e194fed5ff6b014f75ac6823539ce5613aea0be8_o1":{"kind":"code","props":{"decimals":0,"deps":{"Jig":{"$jig":"native://Jig"}},"icon":{"emoji":null},"location":"_o1","nonce":1,"origin":"_o1","owner":"1PytriYokKN3GpKw84L4vvrGBwUvTYzCpx","satoshis":0,"sealed":false,"supply":0,"symbol":null,"version":"2.0"},"src":"class Token extends Jig {\\n init (amount, owner) {\\n this._checkAmount(amount)\\n\\n // The base Token class cannot be created on its own\\n const extended = this.constructor !== Token\\n if (!extended) throw new Error(\'Token must be extended\')\\n\\n // Make sure we are calling from ourself\\n const minting = caller === this.constructor\\n const sending = caller && caller.constructor === this.constructor\\n if (!minting && !sending) throw new Error(\'Must create token using mint()\')\\n\\n this.sender = sending ? caller.owner : null\\n this.amount = amount\\n if (owner) this.owner = owner\\n }\\n\\n static mint (amount, owner) {\\n this.supply += amount\\n return new this(amount, owner)\\n }\\n\\n send (to, amount = this.amount) {\\n this._checkAmount(amount)\\n\\n if (this.amount === amount) {\\n this.destroy()\\n } else if (this.amount > amount) {\\n this.amount -= amount\\n } else {\\n throw new Error(\'Not enough funds\')\\n }\\n\\n return new this.constructor(amount, to)\\n }\\n\\n combine (...tokens) {\\n // If no tokens to combine, nothing to do\\n if (!tokens.length) return this\\n\\n // Each token to combine must all be of this type\\n const all = tokens.concat(this)\\n if (all.some(token => token.constructor !== this.constructor)) {\\n throw new Error(\'Cannot combine different token classes\')\\n }\\n\\n // Check for duplicate tokens in the array\\n const countOf = token => all.reduce((count, next) => next === token ? count + 1 : count, 0)\\n if (all.some(token => countOf(token) > 1)) throw new Error(\'Cannot combine duplicate tokens\')\\n\\n // Destroy each token, absorbing it into this one\\n tokens.forEach(token => {\\n this.amount += token.amount\\n token.destroy()\\n })\\n\\n // There is no sender for combined tokens\\n this.sender = null\\n\\n // Make sure our new amount is within safe range\\n this._checkAmount(this.amount)\\n\\n return this\\n }\\n\\n destroy () {\\n super.destroy()\\n\\n this.amount = 0\\n this.sender = null\\n }\\n\\n _checkAmount (amount) {\\n if (typeof amount !== \'number\') throw new Error(\'amount is not a number\')\\n if (!Number.isInteger(amount)) throw new Error(\'amount must be an integer\')\\n if (amount <= 0) throw new Error(\'amount must be positive\')\\n if (amount > Number.MAX_SAFE_INTEGER) throw new Error(\'amount too large\')\\n }\\n}","version":"04"},"jig://b17a9af70ab0f46809f908b2e900e395ba40996000bf4f00e3b27a1e93280cf1_o1":{"kind":"code","props":{"decimals":0,"deps":{"Jig":{"$jig":"native://Jig"}},"icon":{"emoji":null},"location":"_o1","nonce":1,"origin":"_o1","owner":"1PytriYokKN3GpKw84L4vvrGBwUvTYzCpx","satoshis":0,"sealed":false,"supply":0,"symbol":null},"src":"class Token extends Jig {\\n init (...tokens) {\\n // The base Token class cannot be created on its own\\n if (Object.getPrototypeOf(this.constructor) === Jig) {\\n throw new Error(\'Token must be extended\')\\n }\\n\\n // Case: Mint\\n if (caller === this.constructor) {\\n this._checkAmount(caller.mintAmount)\\n this.amount = caller.mintAmount\\n this.sender = null\\n return\\n }\\n\\n // Case: Send\\n if (caller && caller.constructor === this.constructor) {\\n this._checkAmount(caller.sendAmount)\\n this.amount = caller.sendAmount\\n this.owner = caller.sendOwner\\n this.sender = caller.owner\\n return\\n }\\n\\n // Case: Combine\\n if (!Array.isArray(tokens) || tokens.length < 2) {\\n throw new Error(\'Invalid tokens to combine\')\\n }\\n\\n // Each token to combine must all be of this type\\n if (tokens.some(token => token.constructor !== this.constructor)) {\\n throw new Error(\'Cannot combine different token classes\')\\n }\\n\\n // Check for duplicate tokens in the array\\n const countOf = token => tokens.reduce((count, next) => next === token ? count + 1 : count, 0)\\n if (tokens.some(token => countOf(token) > 1)) throw new Error(\'Cannot combine duplicate tokens\')\\n\\n // Destroy each token, absorbing it into this one\\n this.amount = 0\\n tokens.forEach(token => {\\n this.amount += token.amount\\n token.destroy()\\n })\\n\\n // There is no sender for combined tokens\\n this.sender = null\\n\\n // Make sure our new amount is within safe range\\n this._checkAmount(this.amount)\\n }\\n\\n static mint (amount) {\\n this.mintAmount = amount\\n const token = new this()\\n delete this.mintAmount\\n this.supply += amount\\n return token\\n }\\n\\n destroy () {\\n super.destroy()\\n\\n this.amount = 0\\n this.sender = null\\n }\\n\\n send (to, amount = this.amount) {\\n this._checkAmount(amount)\\n\\n if (amount > this.amount) {\\n throw new Error(\'Not enough funds\')\\n }\\n\\n this.sendAmount = amount\\n this.sendOwner = to\\n const sent = new this.constructor()\\n delete this.sendAmount\\n delete this.sendOwner\\n\\n if (this.amount === amount) {\\n this.destroy()\\n } else {\\n this.amount -= amount\\n this.sender = null\\n }\\n\\n return sent\\n }\\n\\n _checkAmount (amount) {\\n if (typeof amount !== \'number\') throw new Error(\'amount is not a number\')\\n if (!Number.isInteger(amount)) throw new Error(\'amount must be an integer\')\\n if (amount <= 0) throw new Error(\'amount must be positive\')\\n if (amount > Number.MAX_SAFE_INTEGER) throw new Error(\'amount too large\')\\n }\\n}","version":"04"},"jig://3b7ef411185bbe3d01caeadbe6f115b0103a546c4ef0ac7474aa6fbb71aff208_o1":{"kind":"code","props":{"deps":{},"location":"_o1","nonce":1,"origin":"_o1","owner":"1PytriYokKN3GpKw84L4vvrGBwUvTYzCpx","satoshis":0},"src":"function sha256 (message) {\\n if (!Array.isArray(message)) throw new Error(`Invalid bytes: ${message}`)\\n\\n // Based off https://github.com/emn178/js-sha256/blob/master/src/sha256.js\\n\\n const EXTRA = [-2147483648, 8388608, 32768, 128]\\n const SHIFT = [24, 16, 8, 0]\\n const K = [\\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\\n ]\\n\\n const blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\\n\\n let h0 = 0x6a09e667\\n let h1 = 0xbb67ae85\\n let h2 = 0x3c6ef372\\n let h3 = 0xa54ff53a\\n let h4 = 0x510e527f\\n let h5 = 0x9b05688c\\n let h6 = 0x1f83d9ab\\n let h7 = 0x5be0cd19\\n\\n let block = 0\\n let start = 0\\n let bytes = 0\\n let hBytes = 0\\n let first = true\\n let hashed = false\\n let lastByteIndex = 0\\n\\n update()\\n finalize()\\n return digest()\\n\\n function update () {\\n let i\\n let index = 0\\n const length = message.length\\n\\n while (index < length) {\\n if (hashed) {\\n hashed = false\\n blocks[0] = block\\n blocks[16] = blocks[1] = blocks[2] = blocks[3] =\\n blocks[4] = blocks[5] = blocks[6] = blocks[7] =\\n blocks[8] = blocks[9] = blocks[10] = blocks[11] =\\n blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0\\n }\\n\\n for (i = start; index < length && i < 64; ++index) {\\n blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]\\n }\\n\\n lastByteIndex = i\\n bytes += i - start\\n if (i >= 64) {\\n block = blocks[16]\\n start = i - 64\\n hash()\\n hashed = true\\n } else {\\n start = i\\n }\\n }\\n\\n if (bytes > 4294967295) {\\n hBytes += bytes / 4294967296 << 0\\n bytes = bytes % 4294967296\\n }\\n }\\n\\n function finalize () {\\n blocks[16] = block\\n blocks[lastByteIndex >> 2] |= EXTRA[lastByteIndex & 3]\\n block = blocks[16]\\n if (lastByteIndex >= 56) {\\n if (!hashed) {\\n hash()\\n }\\n blocks[0] = block\\n blocks[16] = blocks[1] = blocks[2] = blocks[3] =\\n blocks[4] = blocks[5] = blocks[6] = blocks[7] =\\n blocks[8] = blocks[9] = blocks[10] = blocks[11] =\\n blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0\\n }\\n blocks[14] = hBytes << 3 | bytes >>> 29\\n blocks[15] = bytes << 3\\n hash()\\n }\\n\\n function hash () {\\n let a = h0\\n let b = h1\\n let c = h2\\n let d = h3\\n let e = h4\\n let f = h5\\n let g = h6\\n let h = h7\\n let j\\n let s0\\n let s1\\n let maj\\n let t1\\n let t2\\n let ch\\n let ab\\n let da\\n let cd\\n let bc\\n\\n for (j = 16; j < 64; ++j) {\\n t1 = blocks[j - 15]\\n s0 = ((t1 >>> 7) | (t1 << 25)) ^ ((t1 >>> 18) | (t1 << 14)) ^ (t1 >>> 3)\\n t1 = blocks[j - 2]\\n s1 = ((t1 >>> 17) | (t1 << 15)) ^ ((t1 >>> 19) | (t1 << 13)) ^ (t1 >>> 10)\\n blocks[j] = blocks[j - 16] + s0 + blocks[j - 7] + s1 << 0\\n }\\n\\n bc = b & c\\n for (j = 0; j < 64; j += 4) {\\n if (first) {\\n ab = 704751109\\n t1 = blocks[0] - 210244248\\n h = t1 - 1521486534 << 0\\n d = t1 + 143694565 << 0\\n first = false\\n } else {\\n s0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10))\\n s1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7))\\n ab = a & b\\n maj = ab ^ (a & c) ^ bc\\n ch = (e & f) ^ (~e & g)\\n t1 = h + s1 + ch + K[j] + blocks[j]\\n t2 = s0 + maj\\n h = d + t1 << 0\\n d = t1 + t2 << 0\\n }\\n s0 = ((d >>> 2) | (d << 30)) ^ ((d >>> 13) | (d << 19)) ^ ((d >>> 22) | (d << 10))\\n s1 = ((h >>> 6) | (h << 26)) ^ ((h >>> 11) | (h << 21)) ^ ((h >>> 25) | (h << 7))\\n da = d & a\\n maj = da ^ (d & b) ^ ab\\n ch = (h & e) ^ (~h & f)\\n t1 = g + s1 + ch + K[j + 1] + blocks[j + 1]\\n t2 = s0 + maj\\n g = c + t1 << 0\\n c = t1 + t2 << 0\\n s0 = ((c >>> 2) | (c << 30)) ^ ((c >>> 13) | (c << 19)) ^ ((c >>> 22) | (c << 10))\\n s1 = ((g >>> 6) | (g << 26)) ^ ((g >>> 11) | (g << 21)) ^ ((g >>> 25) | (g << 7))\\n cd = c & d\\n maj = cd ^ (c & a) ^ da\\n ch = (g & h) ^ (~g & e)\\n t1 = f + s1 + ch + K[j + 2] + blocks[j + 2]\\n t2 = s0 + maj\\n f = b + t1 << 0\\n b = t1 + t2 << 0\\n s0 = ((b >>> 2) | (b << 30)) ^ ((b >>> 13) | (b << 19)) ^ ((b >>> 22) | (b << 10))\\n s1 = ((f >>> 6) | (f << 26)) ^ ((f >>> 11) | (f << 21)) ^ ((f >>> 25) | (f << 7))\\n bc = b & c\\n maj = bc ^ (b & d) ^ cd\\n ch = (f & g) ^ (~f & h)\\n t1 = e + s1 + ch + K[j + 3] + blocks[j + 3]\\n t2 = s0 + maj\\n e = a + t1 << 0\\n a = t1 + t2 << 0\\n }\\n\\n h0 = h0 + a << 0\\n h1 = h1 + b << 0\\n h2 = h2 + c << 0\\n h3 = h3 + d << 0\\n h4 = h4 + e << 0\\n h5 = h5 + f << 0\\n h6 = h6 + g << 0\\n h7 = h7 + h << 0\\n }\\n\\n function digest () {\\n return [\\n (h0 >> 24) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 8) & 0xFF, h0 & 0xFF,\\n (h1 >> 24) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 8) & 0xFF, h1 & 0xFF,\\n (h2 >> 24) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 8) & 0xFF, h2 & 0xFF,\\n (h3 >> 24) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 8) & 0xFF, h3 & 0xFF,\\n (h4 >> 24) & 0xFF, (h4 >> 16) & 0xFF, (h4 >> 8) & 0xFF, h4 & 0xFF,\\n (h5 >> 24) & 0xFF, (h5 >> 16) & 0xFF, (h5 >> 8) & 0xFF, h5 & 0xFF,\\n (h6 >> 24) & 0xFF, (h6 >> 16) & 0xFF, (h6 >> 8) & 0xFF, h6 & 0xFF,\\n (h7 >> 24) & 0xFF, (h7 >> 16) & 0xFF, (h7 >> 8) & 0xFF, h7 & 0xFF\\n ]\\n }\\n}","version":"04"},"jig://b2f52f369d6ac4210585e0d173020106bd338197f136e02bc4d1fb2af3ef789f_o1":{"kind":"code","props":{"deps":{"Jig":{"$jig":"native://Jig"}},"location":"_o1","nonce":1,"origin":"_o1","owner":"1PytriYokKN3GpKw84L4vvrGBwUvTYzCpx","satoshis":0,"sealed":false,"supply":0,"total":0,"version":"1.0"},"src":"class NFT extends Jig {\\n init (owner, number, metadata) {\\n // The base NFT class cannot be created on its own\\n const extended = this.constructor !== NFT\\n if (!extended) throw new Error(\'NFT must be extended\')\\n\\n // Make sure we are calling from ourself\\n const minting = caller === this.constructor\\n if (!minting) throw new Error(\'Must create token using mint()\')\\n\\n if (owner) this.owner = owner\\n if (metadata) this.metadata = metadata\\n\\n if (number) {\\n this.number = number\\n this.no = number // relay compat\\n }\\n }\\n\\n static mint (owner, metadata) {\\n const max = this.maxSupply || this.max // relay compat\\n if (max && this.supply >= max) {\\n throw new Error(\'Maximum supply exceeded\')\\n }\\n\\n this.supply++\\n this.total++ // relay compat\\n\\n return new this(owner, this.supply, metadata)\\n }\\n\\n send (to) {\\n this.sender = this.owner\\n this.owner = to\\n }\\n}","version":"04"},"jig://780ab8919cb89323707338070323c24ce42cdec2f57d749bd7aceef6635e7a4d_o1":{"kind":"code","props":{"deps":{"Hex":{"$jig":"727e7b423b7ee40c0b5be87fba7fa5673ea2d20a74259040a7295d9c32a90011_o1"},"asm":{"$jig":"61e1265acb3d93f1bf24a593d70b2a6b1c650ec1df90ddece8d6954ae3cdd915_o1"}},"location":"_o1","nonce":2,"origin":"90a3ece416f696731430efac9657d28071cc437ebfff5fb1eaf710fe4b3c8d4e_o1","owner":"1PytriYokKN3GpKw84L4vvrGBwUvTYzCpx","satoshis":0,"sealed":false},"src":"class Group {\\n constructor (pubkeys, required) {\\n this.pubkeys = pubkeys\\n this.required = typeof required === \'undefined\' ? this.pubkeys.length : required\\n }\\n\\n script () {\\n // Check pubkeys\\n if (!Array.isArray(this.pubkeys)) throw new Error(\'pubkeys not an array\')\\n if (this.pubkeys.length < 1) throw new Error(\'pubkeys must have at least one entry\')\\n if (this.pubkeys.length > 16) throw new Error(\'No more than 16 pubkeys allowed\')\\n const set = new Set()\\n for (const pubkey of this.pubkeys) set.add(pubkey)\\n if (set.size !== this.pubkeys.length) throw new Error(\'pubkeys contains duplicates\')\\n this.pubkeys.forEach(pubkey => Hex.stringToBytes(pubkey))\\n\\n // Check m\\n const badRequired = typeof this.required !== \'number\' || !Number.isInteger(this.required) || this.required < 1\\n if (badRequired) throw new Error(\'required must be a non-negative integer\')\\n if (this.required > this.pubkeys.length) throw new Error(\'required must be <= the number of pubkeys\')\\n\\n // Create script\\n // ie. OP_2 <pk1> <pk2> <pk3> OP_3 OP_CHECKMULTISIG\\n return asm(`OP_${this.required} ${this.pubkeys.join(\' \')} OP_${this.pubkeys.length} OP_CHECKMULTISIG`)\\n }\\n\\n domain () {\\n return 1 + this.required * 74 // 1 (OP_0) + (1 + 73) * nsigs\\n }\\n\\n add (pubkey) {\\n if (!this.pubkeys.includes(pubkey)) {\\n this.pubkeys.push(pubkey)\\n }\\n }\\n }","version":"04"},"jig://61e1265acb3d93f1bf24a593d70b2a6b1c650ec1df90ddece8d6954ae3cdd915_o1":{"kind":"code","props":{"OP_CODES":{"OP_0":0,"OP_0NOTEQUAL":146,"OP_1":81,"OP_10":90,"OP_11":91,"OP_12":92,"OP_13":93,"OP_14":94,"OP_15":95,"OP_16":96,"OP_1ADD":139,"OP_1NEGATE":79,"OP_1SUB":140,"OP_2":82,"OP_2DROP":109,"OP_2DUP":110,"OP_2OVER":112,"OP_2ROT":113,"OP_2SWAP":114,"OP_3":83,"OP_3DUP":111,"OP_4":84,"OP_5":85,"OP_6":86,"OP_7":87,"OP_8":88,"OP_9":89,"OP_ABS":144,"OP_ADD":147,"OP_AND":132,"OP_BIN2NUM":129,"OP_BOOLAND":154,"OP_BOOLOR":155,"OP_CAT":126,"OP_CHECKMULTISIG":174,"OP_CHECKMULTISIGVERIFY":175,"OP_CHECKSIG":172,"OP_CHECKSIGVERIFY":173,"OP_CODESEPARATOR":171,"OP_DEPTH":116,"OP_DIV":150,"OP_DROP":117,"OP_DUP":118,"OP_ELSE":103,"OP_ENDIF":104,"OP_EQUAL":135,"OP_EQUALVERIFY":136,"OP_FALSE":0,"OP_FROMALTSTACK":108,"OP_GREATERTHAN":160,"OP_GREATERTHANOREQUAL":162,"OP_HASH160":169,"OP_HASH256":170,"OP_IF":99,"OP_IFDUP":115,"OP_INVALIDOPCODE":255,"OP_INVERT":131,"OP_LESSTHAN":159,"OP_LESSTHANOREQUAL":161,"OP_LSHIFT":152,"OP_MAX":164,"OP_MIN":163,"OP_MOD":151,"OP_MUL":149,"OP_NEGATE":143,"OP_NIP":119,"OP_NOP":97,"OP_NOP1":176,"OP_NOP10":185,"OP_NOP2":177,"OP_NOP3":178,"OP_NOP4":179,"OP_NOP5":180,"OP_NOP6":181,"OP_NOP7":182,"OP_NOP8":183,"OP_NOP9":184,"OP_NOT":145,"OP_NOTIF":100,"OP_NUM2BIN":128,"OP_NUMEQUAL":156,"OP_NUMEQUALVERIFY":157,"OP_NUMNOTEQUAL":158,"OP_OR":133,"OP_OVER":120,"OP_PICK":121,"OP_PUBKEY":254,"OP_PUBKEYHASH":253,"OP_PUSHDATA1":76,"OP_PUSHDATA2":77,"OP_PUSHDATA4":78,"OP_RETURN":106,"OP_RIPEMD160":166,"OP_ROLL":122,"OP_ROT":123,"OP_RSHIFT":153,"OP_SHA1":167,"OP_SHA256":168,"OP_SIZE":130,"OP_SPLIT":127,"OP_SUB":148,"OP_SWAP":124,"OP_TOALTSTACK":107,"OP_TRUE":81,"OP_TUCK":125,"OP_VERIFY":105,"OP_WITHIN":165,"OP_XOR":134},"deps":{"Hex":{"$jig":"727e7b423b7ee40c0b5be87fba7fa5673ea2d20a74259040a7295d9c32a90011_o1"}},"location":"_o1","nonce":1,"origin":"_o1","owner":"1PytriYokKN3GpKw84L4vvrGBwUvTYzCpx","satoshis":0},"src":"function asm (s) {\\n const parts = s.split(\' \')\\n let out = []\\n\\n for (const part of parts) {\\n // If one of our predefined op-codes\\n if (typeof asm.OP_CODES[part] !== \'undefined\') {\\n out.push(asm.OP_CODES[part])\\n continue\\n }\\n\\n // Hex data\\n const bytes = Hex.stringToBytes(part.length === 1 ? \'0\' + part : part)\\n\\n // OP_0\\n if (bytes[0] === 0) {\\n out.push(bytes[0]) // OP_0\\n continue\\n }\\n\\n // OP_1-OP_16\\n if (bytes.length === 1 && bytes[0] >= 1 && bytes[0] <= 16) {\\n out.push(bytes[0] + 0x50)\\n continue\\n }\\n\\n // OP_PUSH+[1-75] <bytes>\\n if (bytes.length <= 75) {\\n out = out.concat(bytes.length).concat(bytes)\\n continue\\n }\\n\\n // OP_PUSHDATA1 <len> <bytes>\\n if (bytes.length < 256) {\\n out = out.concat(asm.OP_CODES.OP_PUSHDATA1).concat([bytes.length]).concat(bytes)\\n continue\\n }\\n\\n const floor = x => parseInt(x.toString(), 10)\\n\\n // OP_PUSHDATA2 <len> <bytes>\\n if (bytes.length < 256 * 256) {\\n const len = [floor(bytes.length / 256), bytes.length % 256]\\n out = out.concat(asm.OP_CODES.OP_PUSHDATA2).concat(len).concat(bytes)\\n continue\\n }\\n\\n // OP_PUSHDATA4 <len> <bytes>\\n const len = [\\n floor(bytes.length / 256 / 256 / 256),\\n floor(bytes.length / 256 / 256) % 256,\\n floor(bytes.length / 256) % 256,\\n bytes.length % 256\\n ]\\n out = out.concat(asm.OP_CODES.OP_PUSHDATA4).concat(len).concat(bytes)\\n continue\\n }\\n\\n return Hex.bytesToString(out)\\n}","version":"04"},"jig://284ce17fd34c0f41835435b03eed149c4e0479361f40132312b4001093bb158f_o1":{"kind":"code","props":{"OP_CODES":{"OP_0":0,"OP_0NOTEQUAL":146,"OP_1":81,"OP_10":90,"OP_11":91,"OP_12":92,"OP_13":93,"OP_14":94,"OP_15":95,"OP_16":96,"OP_1ADD":139,"OP_1NEGATE":79,"OP_1SUB":140,"OP_2":82,"OP_2DROP":109,"OP_2DUP":110,"OP_2OVER":112,"OP_2ROT":113,"OP_2SWAP":114,"OP_3":83,"OP_3DUP":111,"OP_4":84,"OP_5":85,"OP_6":86,"OP_7":87,"OP_8":88,"OP_9":89,"OP_ABS":144,"OP_ADD":147,"OP_AND":132,"OP_BIN2NUM":129,"OP_BOOLAND":154,"OP_BOOLOR":155,"OP_CAT":126,"OP_CHECKMULTISIG":174,"OP_CHECKMULTISIGVERIFY":175,"OP_CHECKSIG":172,"OP_CHECKSIGVERIFY":173,"OP_CODESEPARATOR":171,"OP_DEPTH":116,"OP_DIV":150,"OP_DROP":117,"OP_DUP":118,"OP_ELSE":103,"OP_ENDIF":104,"OP_EQUAL":135,"OP_EQUALVERIFY":136,"OP_FALSE":0,"OP_FROMALTSTACK":108,"OP_GREATERTHAN":160,"OP_GREATERTHANOREQUAL":162,"OP_HASH160":169,"OP_HASH256":170,"OP_IF":99,"OP_IFDUP":115,"OP_INVALIDOPCODE":255,"OP_INVERT":131,"OP_LESSTHAN":159,"OP_LESSTHANOREQUAL":161,"OP_LSHIFT":152,"OP_MAX":164,"OP_MIN":163,"OP_MOD":151,"OP_MUL":149,"OP_NEGATE":143,"OP_NIP":119,"OP_NOP":97,"OP_NOP1":176,"OP_NOP10":185,"OP_NOP2":177,"OP_NOP3":178,"OP_NOP4":179,"OP_NOP5":180,"OP_NOP6":181,"OP_NOP7":182,"OP_NOP8":183,"OP_NOP9":184,"OP_NOT":145,"OP_NOTIF":100,"OP_NUM2BIN":128,"OP_NUMEQUAL":156,"OP_NUMEQUALVERIFY":157,"OP_NUMNOTEQUAL":158,"OP_OR":133,"OP_OVER":120,"OP_PICK":121,"OP_PUBKEY":254,"OP_PUBKEYHASH":253,"OP_PUSHDATA1":76,"OP_PUSHDATA2":77,"OP_PUSHDATA4":78,"OP_RETURN":106,"OP_RIPEMD160":166,"OP_ROLL":122,"OP_ROT":123,"OP_RSHIFT":153,"OP_SHA1":167,"OP_SHA256":168,"OP_SIZE":130,"OP_SPLIT":127,"OP_SUB":148,"OP_SWAP":124,"OP_TOALTSTACK":107,"OP_TRUE":81,"OP_TUCK":125,"OP_VERIFY":105,"OP_WITHIN":165,"OP_XOR":134},"deps":{"Hex":{"$jig":"727e7b423b7ee40c0b5be87fba7fa5673ea2d20a74259040a7295d9c32a90011_o1"}},"location":"_o1","nonce":3,"origin":"61e1265acb3d93f1bf24a593d70b2a6b1c650ec1df90ddece8d6954ae3cdd915_o1","owner":"1PytriYokKN3GpKw84L4vvrGBwUvTYzCpx","satoshis":0},"src":"function asm (s) {\\n const parts = s.split(\' \')\\n let out = []\\n\\n for (const part of parts) {\\n // If one of our predefined op-codes\\n if (typeof asm.OP_CODES[part] !== \'undefined\') {\\n out.push(asm.OP_CODES[part])\\n continue\\n }\\n\\n // Hex data\\n const bytes = Hex.stringToBytes(part.length === 1 ? \'0\' + part : part)\\n\\n // OP_0\\n if (bytes.length === 1 && bytes[0] === 0) {\\n out.push(bytes[0]) // OP_0\\n continue\\n }\\n\\n // OP_1-OP_16\\n if (bytes.length === 1 && bytes[0] >= 1 && bytes[0] <= 16) {\\n out.push(bytes[0] + 0x50)\\n continue\\n }\\n\\n // OP_PUSH+[1-75] <bytes>\\n if (bytes.length <= 75) {\\n out = out.concat(bytes.length).concat(bytes)\\n continue\\n }\\n\\n // OP_PUSHDATA1 <len> <bytes>\\n if (bytes.length < 256) {\\n out = out.concat(asm.OP_CODES.OP_PUSHDATA1).concat([bytes.length]).concat(bytes)\\n continue\\n }\\n\\n const floor = x => parseInt(x.toString(), 10)\\n\\n // OP_PUSHDATA2 <len> <bytes>\\n // len must be little endian\\n if (bytes.length < 256 * 256) {\\n const len = [bytes.length % 256, floor(bytes.length / 256)]\\n out = out.concat(asm.OP_CODES.OP_PUSHDATA2).concat(len).concat(bytes)\\n continue\\n }\\n\\n // OP_PUSHDATA4 <len> <bytes>\\n // len must be little endian\\n const len = [\\n bytes.length % 256,\\n floor(bytes.length / 256) % 256,\\n floor(bytes.length / 256 / 256) % 256,\\n floor(bytes.length / 256 / 256 / 256)\\n ]\\n out = out.concat(asm.OP_CODES.OP_PUSHDATA4).concat(len).concat(bytes)\\n continue\\n }\\n\\n return Hex.bytesToString(out)\\n}","version":"04"},"jig://71fba386341b932380ec5bfedc3a40bce43d4974decdc94c419a94a8ce5dfc23_o1":{"kind":"code","props":{"deps":{"Jig":{"$jig":"native://Jig"}},"location":"_o1","nonce":1,"origin":"_o1","owner":"1PytriYokKN3GpKw84L4vvrGBwUvTYzCpx","satoshis":0},"src":"function expect (subject) {\\n let negated = false\\n\\n const stringify = x => {\\n if (typeof x !== \'object\' || !x) return x\\n try { return JSON.stringify(x) } catch (e) { return x.toString() }\\n }\\n\\n function check (condition, conditionString, message) {\\n if (negated ? condition : !condition) {\\n throw new Error(message || `expected value${negated ? \' not\' : \'\'} to be ${conditionString} but was ${stringify(subject)}`)\\n }\\n }\\n\\n function deepEqual (a, b) {\\n if (a === b) return true\\n\\n if (typeof a !== typeof b) return false\\n\\n if (typeof a !== \'object\') return false\\n\\n if (a === null || b === null) return false\\n\\n if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false\\n\\n if (Object.keys(a).length !== Object.keys(b).length) return false\\n\\n if (!Object.keys(a).every(key => deepEqual(a[key], b[key]))) return false\\n\\n if (a instanceof Set) {\\n if (a.size !== b.size) return false\\n if (!deepEqual(Array.from(a.entries()), Array.from(b.entries()))) return false\\n }\\n\\n if (a instanceof Map) {\\n if (a.size !== b.size) return false\\n if (!deepEqual(Array.from(a.entries()), Array.from(b.entries()))) return false\\n }\\n\\n return true\\n }\\n\\n function extendsFrom (a, b) {\\n if (typeof a !== \'function\') return false\\n if (typeof b !== \'function\') return false\\n while (a) {\\n a = Object.getPrototypeOf(a)\\n if (a === b) return true\\n }\\n return false\\n }\\n\\n return {\\n get not () { negated = !negated; return this },\\n\\n toBe: (value, message) => check(subject === value, `${stringify(value)}`, message),\\n toEqual: (value, message) => check(deepEqual(subject, value), `equal to ${stringify(value)}`, message),\\n toBeInstanceOf: (Class, message) => check(subject && subject instanceof Class, `an instance of ${Class && Class.name}`, message),\\n\\n toBeDefined: message => check(typeof subject !== \'undefined\', \'defined\', message),\\n toBeNull: message => check(subject === null, \'null\', message),\\n\\n toBeNumber: message => check(typeof subject === \'number\', \'a number\', message),\\n toBeInteger: message => check(Number.isInteger(subject), \'an integer\', message),\\n toBeLessThan: (value, message) => check(subject < value && typeof subject === \'number\' && typeof value === \'number\', `less than ${value}`, message),\\n toBeLessThanOrEqualTo: (value, message) => check(subject <= value && typeof subject === \'number\' && typeof value === \'number\', `less than or equal to ${value}`, message),\\n toBeGreaterThan: (value, message) => check(subject > value && typeof subject === \'number\' && typeof value === \'number\', `greater than ${value}`, message),\\n toBeGreaterThanOrEqualTo: (value, message) => check(subject >= value && typeof subject === \'number\' && typeof value === \'number\', `greater than or equal to ${value}`, message),\\n\\n toBeBoolean: message => check(typeof subject === \'boolean\', \'a boolean\', message),\\n toBeString: message => check(typeof subject === \'string\', \'a string\', message),\\n toBeObject: message => check(subject && typeof subject === \'object\', \'an object\', message),\\n toBeArray: message => check(Array.isArray(subject), \'an array\', message),\\n toBeSet: message => check(subject instanceof Set, \'a set\', message),\\n toBeMap: message => check(subject instanceof Map, \'a map\', message),\\n toBeUint8Array: message => check(subject instanceof Uint8Array, \'a uint8array\', message),\\n\\n toBeClass: message => check(typeof subject === \'function\' && subject.toString().startsWith(\'class\'), \'a class\', message),\\n toBeFunction: message => check(typeof subject === \'function\' && !subject.toString().startsWith(\'class\'), \'a function\', message),\\n toBeJigClass: message => check(typeof subject === \'function\' && subject.toString().startsWith(\'class\') && extendsFrom(subject, Jig), \'a jig class\', message),\\n toExtendFrom: (Class, message) => check(extendsFrom(subject, Class), `an extension of ${Class && Class.name}`, message)\\n }\\n}","version":"04"},"jig://81bcef29b0e4ed745f3422c0b764a33c76d0368af2d2e7dd139db8e00ee3d8a6_o1":{"kind":"code","props":{"deps":{},"location":"_o1","nonce":1,"origin":"_o1","owner":"1PytriYokKN3GpKw84L4vvrGBwUvTYzCpx","satoshis":0},"src":"class Base58 {\\n static decode (s) {\\n // Based on https://gist.github.com/diafygi/90a3e80ca1c2793220e5/\\n if (typeof s !== \'string\') throw new Error(`Cannot decode: ${s}`)\\n const A = \'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\'\\n const d = [] // the array for storing the stream of decoded bytes\\n const b = [] // the result byte array that will be returned\\n let j // the iterator variable for the byte array (d)\\n let c // the carry amount variable that is used to overflow from the current byte to the next byte\\n let n // a temporary placeholder variable for the current byte\\n for (let i = 0; i < s.length; i++) {\\n j = 0 // reset the byte iterator\\n c = A.indexOf(s[i]) // set the initial carry amount equal to the current base58 digit\\n if (c < 0) throw new Error(`Invalid base58 character: ${s}\\\\n\\\\nDetails: i=${i}, c=${s[i]}`)\\n if (!(c || b.length ^ i)) b.push(0) // prepend the result array with a zero if the base58 digit is zero and non-zero characters haven\'t been seen yet (to ensure correct decode length)\\n while (j in d || c) { // start looping through the bytes until there are no more bytes and no carry amount\\n n = d[j] // set the placeholder for the current byte\\n n = n ? n * 58 + c : c // shift the current byte 58 units and add the carry amount (or just add the carry amount if this is a new byte)\\n c = n >> 8 // find the new carry amount (1-byte shift of current byte value)\\n d[j] = n % 256 // reset the current byte to the remainder (the carry amount will pass on the overflow)\\n j++ // iterate to the next byte\\n }\\n }\\n while (j--) { b.push(d[j]) } // since the byte array is backwards, loop through it in reverse order, and append\\n if (b.length < 5) throw new Error(`Base58 string too short: ${s}`)\\n // We assume the checksum and version are correct\\n return b.slice(1, b.length - 4)\\n }\\n}","version":"04"},"jig://05f67252e696160a7c0099ae8d1ec23c39592378773b3a5a55f16bd1286e7dcb_o3":{"kind":"code","props":{"deps":{"Berry":{"$jig":"native://Berry"},"txo":{"$jig":"_o2"}},"location":"_o3","metadata":{"author":"Run ▸ Extra","license":"MIT","website":"https://www.run.network"},"nonce":2,"origin":"5332c013476cd2a2c18710a01188695bc27a5ef1748a51d4a5910feb1111dab4_o1","owner":"1PytriYokKN3GpKw84L4vvrGBwUvTYzCpx","satoshis":0},"src":"class B extends Berry {\\n init (base64Data, mediaType, encoding, filename, metadata = {}) {\\n this.base64Data = base64Data\\n this.mediaType = mediaType\\n this.encoding = encoding\\n this.filename = filename\\n this.metadata = metadata\\n\\n if (mediaType === \'image/svg+xml\' || mediaType === \'image/png\') {\\n this.metadata.image = this\\n }\\n }\\n\\n static async pluck (path, fetch) {\\n const txid = path.length === 64 ? path : JSON.parse(path).txid\\n const metadata = path.length === 64 ? {} : JSON.parse(path).metadata\\n const data = txo(await fetch(txid))\\n const out = data.out.find(o => o.s2 === \'19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut\')\\n if (!out) throw new Error(`Cannot find B:// data in ${txid}`)\\n return new B(out.b3, out.s4, out.s5, out.s6, metadata)\\n }\\n\\n static async loadWithMetadata (txid, metadata) {\\n return this.load(JSON.stringify({ txid, metadata }))\\n }\\n}","version":"04"}}')},function(t){t.exports=JSON.parse('{"jig://d476fd7309a0eeb8b92d715e35c6e273ad63c0025ff6cca927bd0f0b64ed88ff_o2":{"kind":"code","props":{"deps":{"Hex":{"$jig":"1f0abf8d94477b1cb57629d861376616f6e1d7b78aba23a19da3e6169caf489e_o2"},"Tx":{"$jig":"_o1"}},"location":"_o2","nonce":2,"origin":"33e78fa7c43b6d7a60c271d783295fa180b7e9fce07d41ff1b52686936b3e6ae_o1","owner":"n3CiECgxW1pB1rGbYiX67e4U7AnS3MpJeE","satoshis":0},"src":"function txo (rawtx) {\\n const ret = { }\\n\\n function chunks (script) {\\n const b = Hex.stringToBytes(script)\\n let i = 0\\n\\n function u8 () { return b[i++] }\\n function u16 () { return u8() + u8() * 256 }\\n function u32 () { return u16() + u16() * 256 * 256 }\\n function buf (n) { const h = Hex.bytesToString(b.slice(i, i + n)); i += n; return h }\\n\\n const OP_PUSHDATA1 = 0x4c\\n const OP_PUSHDATA2 = 0x4d\\n const OP_PUSHDATA4 = 0x4e\\n\\n const chunks = []\\n while (i < b.length) {\\n const opcodenum = u8()\\n if (opcodenum > 0 && opcodenum < OP_PUSHDATA1) {\\n chunks.push({ buf: buf(opcodenum), len: opcodenum, opcodenum })\\n } else if (opcodenum === OP_PUSHDATA1) {\\n const len = u8()\\n chunks.push({ buf: buf(len), len, opcodenum })\\n } else if (opcodenum === OP_PUSHDATA2) {\\n const len = u16()\\n chunks.push({ buf: buf(len), len, opcodenum })\\n } else if (opcodenum === OP_PUSHDATA4) {\\n const len = u32()\\n chunks.push({ buf: buf(len), len, opcodenum })\\n } else {\\n chunks.push({ opcodenum })\\n }\\n }\\n return chunks\\n }\\n\\n // https://stackoverflow.com/questions/23190056/hex-to-base64-converter-for-javascript\\n function bytesToBase64 (arr) {\\n const abc = \'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\' // base64 alphabet\\n const bin = n => n.toString(2).padStart(8, 0) // convert num to 8-bit binary string\\n const l = arr.length\\n let result = \'\'\\n for (let i = 0; i <= (l - 1) / 3; i++) {\\n const c1 = i * 3 + 1 >= l // case when \\"=\\" is on end\\n const c2 = i * 3 + 2 >= l // case when \\"=\\" is on end\\n const chunk = bin(arr[3 * i]) + bin(c1 ? 0 : arr[3 * i + 1]) + bin(c2 ? 0 : arr[3 * i + 2])\\n const r = chunk.match(/.{1,6}/g).map((x, j) => j === 3 && c2 ? \'=\' : (j === 2 && c1 ? \'=\' : abc[+(\'0b\' + x)]))\\n result += r.join(\'\')\\n }\\n return result\\n }\\n\\n function xput (script, output) {\\n const ret = { }\\n chunks(script).forEach((c, n) => {\\n if (c.buf) {\\n ret[\'b\' + n] = bytesToBase64(Hex.stringToBytes(c.buf))\\n const enc = c.buf.replace(/[0-9a-f]{2}/g, \'%$&\')\\n if (output) try { ret[\'s\' + n] = decodeURIComponent(enc) } catch (e) { }\\n if (output) ret[\'h\' + n] = c.buf\\n } else {\\n ret[\'b\' + n] = { op: c.opcodenum }\\n }\\n })\\n return ret\\n }\\n\\n function input (txin, i) {\\n const ret = xput(txin.script)\\n ret.e = { h: txin.prevTxId, i: txin.outputIndex }\\n ret.i = i\\n ret.seq = txin.sequenceNumber\\n return ret\\n }\\n\\n function output (txout, i) {\\n const ret = xput(txout.script, true)\\n ret.e = { v: txout.satoshis, i }\\n ret.i = i\\n return ret\\n }\\n\\n const tx = new Tx(rawtx)\\n ret.in = tx.inputs.map(input)\\n ret.out = tx.outputs.map(output)\\n ret.lock = tx.nLockTime\\n return ret\\n}","version":"04"},"jig://1f0abf8d94477b1cb57629d861376616f6e1d7b78aba23a19da3e6169caf489e_o2":{"kind":"code","props":{"deps":{},"location":"_o2","nonce":1,"origin":"_o2","owner":"n3CiECgxW1pB1rGbYiX67e4U7AnS3MpJeE","satoshis":0},"src":"class Hex {\\n static stringToBytes (s) {\\n if (typeof s !== \'string\' || s.length % 2 !== 0) {\\n throw new Error(`Bad hex: ${s}`)\\n }\\n\\n s = s.toLowerCase()\\n\\n const HEX_CHARS = \'0123456789abcdef\'.split(\'\')\\n const bytes = []\\n\\n for (let i = 0; i < s.length; i += 2) {\\n const high = HEX_CHARS.indexOf(s[i])\\n const low = HEX_CHARS.indexOf(s[i + 1])\\n\\n if (high === -1 || low === -1) {\\n throw new Error(`Bad hex: ${s}`)\\n }\\n\\n bytes.push(high * 16 + low)\\n }\\n\\n return bytes\\n }\\n\\n static bytesToString (b) {\\n if (!Array.isArray(b)) throw new Error(`Bad bytes: ${b}`)\\n\\n const validDigit = x => Number.isInteger(x) && x >= 0 && x < 256\\n b.forEach(x => { if (!validDigit(x)) throw new Error(`Bad digit: ${x}`) })\\n\\n return b\\n .map(x => x.toString(\'16\'))\\n .map(x => x.length === 1 ? \'0\' + x : x)\\n .join(\'\')\\n }\\n}","version":"04"},"jig://d476fd7309a0eeb8b92d715e35c6e273ad63c0025ff6cca927bd0f0b64ed88ff_o1":{"kind":"code","props":{"deps":{"Hex":{"$jig":"1f0abf8d94477b1cb57629d861376616f6e1d7b78aba23a19da3e6169caf489e_o2"}},"location":"_o1","nonce":2,"origin":"33e78fa7c43b6d7a60c271d783295fa180b7e9fce07d41ff1b52686936b3e6ae_o2","owner":"n3CiECgxW1pB1rGbYiX67e4U7AnS3MpJeE","satoshis":0},"src":"class Tx {\\n constructor (rawtx) {\\n const b = Hex.stringToBytes(rawtx)\\n let i = 0\\n\\n function u8 () { return b[i++] }\\n function u16 () { return u8() + u8() * 256 }\\n function u32 () { return u16() + u16() * 256 * 256 }\\n function u64 () { return u32() + u32() * 256 * 256 * 256 * 256 }\\n function varint () { const b0 = u8(); return b0 === 0xff ? u64() : b0 === 0xfe ? u32() : b0 === 0xfd ? u16() : b0 }\\n function txid () { const h = Hex.bytesToString(b.slice(i, i + 32).reverse()); i += 32; return h }\\n function script () { const n = varint(); const h = Hex.bytesToString(b.slice(i, i + n)); i += n; return h }\\n\\n this.version = u32()\\n\\n const nin = varint()\\n this.inputs = []\\n for (let vin = 0; vin < nin; vin++) {\\n this.inputs.push({\\n prevTxId: txid(),\\n outputIndex: u32(),\\n script: script(),\\n sequenceNumber: u32()\\n })\\n }\\n\\n const nout = varint()\\n this.outputs = []\\n for (let vout = 0; vout < nout; vout++) {\\n this.outputs.push({\\n satoshis: u64(),\\n script: script()\\n })\\n }\\n\\n this.nLockTime = u32()\\n }\\n}","version":"04"},"jig://7d14c868fe39439edffe6982b669e7b4d3eb2729eee7c262ec2494ee3e310e99_o1":{"kind":"code","props":{"decimals":0,"deps":{"Jig":{"$jig":"native://Jig"}},"icon":{"emoji":null},"location":"_o1","nonce":1,"origin":"_o1","owner":"n3CiECgxW1pB1rGbYiX67e4U7AnS3MpJeE","satoshis":0,"sealed":false,"supply":0,"symbol":null,"version":"2.0"},"src":"class Token extends Jig {\\n init (amount, owner) {\\n this._checkAmount(amount)\\n\\n // The base Token class cannot be created on its own\\n const extended = this.constructor !== Token\\n if (!extended) throw new Error(\'Token must be extended\')\\n\\n // Make sure we are calling from ourself\\n const minting = caller === this.constructor\\n const sending = caller && caller.constructor === this.constructor\\n if (!minting && !sending) throw new Error(\'Must create token using mint()\')\\n\\n this.sender = sending ? caller.owner : null\\n this.amount = amount\\n if (owner) this.owner = owner\\n }\\n\\n static mint (amount, owner) {\\n this.supply += amount\\n return new this(amount, owner)\\n }\\n\\n send (to, amount = this.amount) {\\n this._checkAmount(amount)\\n\\n if (this.amount === amount) {\\n this.destroy()\\n } else if (this.amount > amount) {\\n this.amount -= amount\\n } else {\\n throw new Error(\'Not enough funds\')\\n }\\n\\n return new this.constructor(amount, to)\\n }\\n\\n combine (...tokens) {\\n // If no tokens to combine, nothing to do\\n if (!tokens.length) return this\\n\\n // Each token to combine must all be of this type\\n const all = tokens.concat(this)\\n if (all.some(token => token.constructor !== this.constructor)) {\\n throw new Error(\'Cannot combine different token classes\')\\n }\\n\\n // Check for duplicate tokens in the array\\n const countOf = token => all.reduce((count, next) => next === token ? count + 1 : count, 0)\\n if (all.some(token => countOf(token) > 1)) throw new Error(\'Cannot combine duplicate tokens\')\\n\\n // Destroy each token, absorbing it into this one\\n tokens.forEach(token => {\\n this.amount += token.amount\\n token.destroy()\\n })\\n\\n // There is no sender for combined tokens\\n this.sender = null\\n\\n // Make sure our new amount is within safe range\\n this._checkAmount(this.amount)\\n\\n return this\\n }\\n\\n destroy () {\\n super.destroy()\\n\\n this.amount = 0\\n this.sender = null\\n }\\n\\n _checkAmount (amount) {\\n if (typeof amount !== \'number\') throw new Error(\'amount is not a number\')\\n if (!Number.isInteger(amount)) throw new Error(\'amount must be an integer\')\\n if (amount <= 0) throw new Error(\'amount must be positive\')\\n if (amount > Number.MAX_SAFE_INTEGER) throw new Error(\'amount too large\')\\n }\\n}","version":"04"},"jig://0bdf33a334a60909f4c8dab345500cbb313fbfd50b1d98120227eae092b81c39_o1":{"kind":"code","props":{"decimals":0,"deps":{"Jig":{"$jig":"native://Jig"}},"icon":{"emoji":null},"location":"_o1","nonce":1,"origin":"_o1","owner":"n3CiECgxW1pB1rGbYiX67e4U7AnS3MpJeE","satoshis":0,"sealed":false,"supply":0,"symbol":null},"src":"class Token extends Jig {\\n init (...tokens) {\\n // The base Token class cannot be created on its own\\n if (Object.getPrototypeOf(this.constructor) === Jig) {\\n throw new Error(\'Token must be extended\')\\n }\\n\\n // Case: Mint\\n if (caller === this.constructor) {\\n this._checkAmount(caller.mintAmount)\\n this.amount = caller.mintAmount\\n this.sender = null\\n return\\n }\\n\\n // Case: Send\\n if (caller && caller.constructor === this.constructor) {\\n this._checkAmount(caller.sendAmount)\\n this.amount = caller.sendAmount\\n this.owner = caller.sendOwner\\n this.sender = caller.owner\\n return\\n }\\n\\n // Case: Combine\\n if (!Array.isArray(tokens) || tokens.length < 2) {\\n throw new Error(\'Invalid tokens to combine\')\\n }\\n\\n // Each token to combine must all be of this type\\n if (tokens.some(token => token.constructor !== this.constructor)) {\\n throw new Error(\'Cannot combine different token classes\')\\n }\\n\\n // Check for duplicate tokens in the array\\n const countOf = token => tokens.reduce((count, next) => next === token ? count + 1 : count, 0)\\n if (tokens.some(token => countOf(token) > 1)) throw new Error(\'Cannot combine duplicate tokens\')\\n\\n // Destroy each token, absorbing it into this one\\n this.amount = 0\\n tokens.forEach(token => {\\n this.amount += token.amount\\n token.destroy()\\n })\\n\\n // There is no sender for combined tokens\\n this.sender = null\\n\\n // Make sure our new amount is within safe range\\n this._checkAmount(this.amount)\\n }\\n\\n static mint (amount) {\\n this.mintAmount = amount\\n const token = new this()\\n delete this.mintAmount\\n this.supply += amount\\n return token\\n }\\n\\n destroy () {\\n super.destroy()\\n\\n this.amount = 0\\n this.sender = null\\n }\\n\\n send (to, amount = this.amount) {\\n this._checkAmount(amount)\\n\\n if (amount > this.amount) {\\n throw new Error(\'Not enough funds\')\\n }\\n\\n this.sendAmount = amount\\n this.sendOwner = to\\n const sent = new this.constructor()\\n delete this.sendAmount\\n delete this.sendOwner\\n\\n if (this.amount === amount) {\\n this.destroy()\\n } else {\\n this.amount -= amount\\n this.sender = null\\n }\\n\\n return sent\\n }\\n\\n _checkAmount (amount) {\\n if (typeof amount !== \'number\') throw new Error(\'amount is not a number\')\\n if (!Number.isInteger(amount)) throw new Error(\'amount must be an integer\')\\n if (amount <= 0) throw new Error(\'amount must be positive\')\\n if (amount > Number.MAX_SAFE_INTEGER) throw new Error(\'amount too large\')\\n }\\n}","version":"04"},"jig://4a1929527605577a6b30710e6001b9379400421d8089d34bb0404dd558529417_o1":{"kind":"code","props":{"deps":{},"location":"_o1","nonce":1,"origin":"_o1","owner":"n3CiECgxW1pB1rGbYiX67e4U7AnS3MpJeE","satoshis":0},"src":"function sha256 (message) {\\n if (!Array.isArray(message)) throw new Error(`Invalid bytes: ${message}`)\\n\\n // Based off https://github.com/emn178/js-sha256/blob/master/src/sha256.js\\n\\n const EXTRA = [-2147483648, 8388608, 32768, 128]\\n const SHIFT = [24, 16, 8, 0]\\n const K = [\\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\\n ]\\n\\n const blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\\n\\n let h0 = 0x6a09e667\\n let h1 = 0xbb67ae85\\n let h2 = 0x3c6ef372\\n let h3 = 0xa54ff53a\\n let h4 = 0x510e527f\\n let h5 = 0x9b05688c\\n let h6 = 0x1f83d9ab\\n let h7 = 0x5be0cd19\\n\\n let block = 0\\n let start = 0\\n let bytes = 0\\n let hBytes = 0\\n let first = true\\n let hashed = false\\n let lastByteIndex = 0\\n\\n update()\\n finalize()\\n return digest()\\n\\n function update () {\\n let i\\n let index = 0\\n const length = message.length\\n\\n while (index < length) {\\n if (hashed) {\\n hashed = false\\n blocks[0] = block\\n blocks[16] = blocks[1] = blocks[2] = blocks[3] =\\n blocks[4] = blocks[5] = blocks[6] = blocks[7] =\\n blocks[8] = blocks[9] = blocks[10] = blocks[11] =\\n blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0\\n }\\n\\n for (i = start; index < length && i < 64; ++index) {\\n blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]\\n }\\n\\n lastByteIndex = i\\n bytes += i - start\\n if (i >= 64) {\\n block = blocks[16]\\n start = i - 64\\n hash()\\n hashed = true\\n } else {\\n start = i\\n }\\n }\\n\\n if (bytes > 4294967295) {\\n hBytes += bytes / 4294967296 << 0\\n bytes = bytes % 4294967296\\n }\\n }\\n\\n function finalize () {\\n blocks[16] = block\\n blocks[lastByteIndex >> 2] |= EXTRA[lastByteIndex & 3]\\n block = blocks[16]\\n if (lastByteIndex >= 56) {\\n if (!hashed) {\\n hash()\\n }\\n blocks[0] = block\\n blocks[16] = blocks[1] = blocks[2] = blocks[3] =\\n blocks[4] = blocks[5] = blocks[6] = blocks[7] =\\n blocks[8] = blocks[9] = blocks[10] = blocks[11] =\\n blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0\\n }\\n blocks[14] = hBytes << 3 | bytes >>> 29\\n blocks[15] = bytes << 3\\n hash()\\n }\\n\\n function hash () {\\n let a = h0\\n let b = h1\\n let c = h2\\n let d = h3\\n let e = h4\\n let f = h5\\n let g = h6\\n let h = h7\\n let j\\n let s0\\n let s1\\n let maj\\n let t1\\n let t2\\n let ch\\n let ab\\n let da\\n let cd\\n let bc\\n\\n for (j = 16; j < 64; ++j) {\\n t1 = blocks[j - 15]\\n s0 = ((t1 >>> 7) | (t1 << 25)) ^ ((t1 >>> 18) | (t1 << 14)) ^ (t1 >>> 3)\\n t1 = blocks[j - 2]\\n s1 = ((t1 >>> 17) | (t1 << 15)) ^ ((t1 >>> 19) | (t1 << 13)) ^ (t1 >>> 10)\\n blocks[j] = blocks[j - 16] + s0 + blocks[j - 7] + s1 << 0\\n }\\n\\n bc = b & c\\n for (j = 0; j < 64; j += 4) {\\n if (first) {\\n ab = 704751109\\n t1 = blocks[0] - 210244248\\n h = t1 - 1521486534 << 0\\n d = t1 + 143694565 << 0\\n first = false\\n } else {\\n s0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10))\\n s1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7))\\n ab = a & b\\n maj = ab ^ (a & c) ^ bc\\n ch = (e & f) ^ (~e & g)\\n t1 = h + s1 + ch + K[j] + blocks[j]\\n t2 = s0 + maj\\n h = d + t1 << 0\\n d = t1 + t2 << 0\\n }\\n s0 = ((d >>> 2) | (d << 30)) ^ ((d >>> 13) | (d << 19)) ^ ((d >>> 22) | (d << 10))\\n s1 = ((h >>> 6) | (h << 26)) ^ ((h >>> 11) | (h << 21)) ^ ((h >>> 25) | (h << 7))\\n da = d & a\\n maj = da ^ (d & b) ^ ab\\n ch = (h & e) ^ (~h & f)\\n t1 = g + s1 + ch + K[j + 1] + blocks[j + 1]\\n t2 = s0 + maj\\n g = c + t1 << 0\\n c = t1 + t2 << 0\\n s0 = ((c >>> 2) | (c << 30)) ^ ((c >>> 13) | (c << 19)) ^ ((c >>> 22) | (c << 10))\\n s1 = ((g >>> 6) | (g << 26)) ^ ((g >>> 11) | (g << 21)) ^ ((g >>> 25) | (g << 7))\\n cd = c & d\\n maj = cd ^ (c & a) ^ da\\n ch = (g & h) ^ (~g & e)\\n t1 = f + s1 + ch + K[j + 2] + blocks[j + 2]\\n t2 = s0 + maj\\n f = b + t1 << 0\\n b = t1 + t2 << 0\\n s0 = ((b >>> 2) | (b << 30)) ^ ((b >>> 13) | (b << 19)) ^ ((b >>> 22) | (b << 10))\\n s1 = ((f >>> 6) | (f << 26)) ^ ((f >>> 11) | (f << 21)) ^ ((f >>> 25) | (f << 7))\\n bc = b & c\\n maj = bc ^ (b & d) ^ cd\\n ch = (f & g) ^ (~f & h)\\n t1 = e + s1 + ch + K[j + 3] + blocks[j + 3]\\n t2 = s0 + maj\\n e = a + t1 << 0\\n a = t1 + t2 << 0\\n }\\n\\n h0 = h0 + a << 0\\n h1 = h1 + b << 0\\n h2 = h2 + c << 0\\n h3 = h3 + d << 0\\n h4 = h4 + e << 0\\n h5 = h5 + f << 0\\n h6 = h6 + g << 0\\n h7 = h7 + h << 0\\n }\\n\\n function digest () {\\n return [\\n (h0 >> 24) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 8) & 0xFF, h0 & 0xFF,\\n (h1 >> 24) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 8) & 0xFF, h1 & 0xFF,\\n (h2 >> 24) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 8) & 0xFF, h2 & 0xFF,\\n (h3 >> 24) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 8) & 0xFF, h3 & 0xFF,\\n (h4 >> 24) & 0xFF, (h4 >> 16) & 0xFF, (h4 >> 8) & 0xFF, h4 & 0xFF,\\n (h5 >> 24) & 0xFF, (h5 >> 16) & 0xFF, (h5 >> 8) & 0xFF, h5 & 0xFF,\\n (h6 >> 24) & 0xFF, (h6 >> 16) & 0xFF, (h6 >> 8) & 0xFF, h6 & 0xFF,\\n (h7 >> 24) & 0xFF, (h7 >> 16) & 0xFF, (h7 >> 8) & 0xFF, h7 & 0xFF\\n ]\\n }\\n}","version":"04"},"jig://8554b58e95bbd7a1899b54ca1318cc3ce140c6cd7ed64789dcaf5ea5dcfdb1f1_o1":{"kind":"code","props":{"deps":{"Jig":{"$jig":"native://Jig"}},"location":"_o1","nonce":1,"origin":"_o1","owner":"n3CiECgxW1pB1rGbYiX67e4U7AnS3MpJeE","satoshis":0,"sealed":false,"supply":0,"total":0,"version":"1.0"},"src":"class NFT extends Jig {\\n init (owner, number, metadata) {\\n // The base NFT class cannot be created on its own\\n const extended = this.constructor !== NFT\\n if (!extended) throw new Error(\'NFT must be extended\')\\n\\n // Make sure we are calling from ourself\\n const minting = caller === this.constructor\\n if (!minting) throw new Error(\'Must create token using mint()\')\\n\\n if (owner) this.owner = owner\\n if (metadata) this.metadata = metadata\\n\\n if (number) {\\n this.number = number\\n this.no = number // relay compat\\n }\\n }\\n\\n static mint (owner, metadata) {\\n const max = this.maxSupply || this.max // relay compat\\n if (max && this.supply >= max) {\\n throw new Error(\'Maximum supply exceeded\')\\n }\\n\\n this.supply++\\n this.total++ // relay compat\\n\\n return new this(owner, this.supply, metadata)\\n }\\n\\n send (to) {\\n this.sender = this.owner\\n this.owner = to\\n }\\n}","version":"04"},"jig://63e0e1268d8ab021d1c578afb8eaa0828ccbba431ffffd9309d04b78ebeb6e56_o1":{"kind":"code","props":{"deps":{"Hex":{"$jig":"1f0abf8d94477b1cb57629d861376616f6e1d7b78aba23a19da3e6169caf489e_o2"},"asm":{"$jig":"1f0abf8d94477b1cb57629d861376616f6e1d7b78aba23a19da3e6169caf489e_o1"}},"location":"_o1","nonce":3,"origin":"03320f1244e509bb421e6f1ff724bf1156182890c3768cfa4ea127a78f9913d2_o1","owner":"n3CiECgxW1pB1rGbYiX67e4U7AnS3MpJeE","satoshis":0,"sealed":false},"src":"class Group {\\n constructor (pubkeys, required) {\\n this.pubkeys = pubkeys\\n this.required = typeof required === \'undefined\' ? this.pubkeys.length : required\\n }\\n\\n script () {\\n // Check pubkeys\\n if (!Array.isArray(this.pubkeys)) throw new Error(\'pubkeys not an array\')\\n if (this.pubkeys.length < 1) throw new Error(\'pubkeys must have at least one entry\')\\n if (this.pubkeys.length > 16) throw new Error(\'No more than 16 pubkeys allowed\')\\n const set = new Set()\\n for (const pubkey of this.pubkeys) set.add(pubkey)\\n if (set.size !== this.pubkeys.length) throw new Error(\'pubkeys contains duplicates\')\\n this.pubkeys.forEach(pubkey => Hex.stringToBytes(pubkey))\\n\\n // Check m\\n const badRequired = typeof this.required !== \'number\' || !Number.isInteger(this.required) || this.required < 1\\n if (badRequired) throw new Error(\'required must be a non-negative integer\')\\n if (this.required > this.pubkeys.length) throw new Error(\'required must be <= the number of pubkeys\')\\n\\n // Create script\\n // ie. OP_2 <pk1> <pk2> <pk3> OP_3 OP_CHECKMULTISIG\\n return asm(`OP_${this.required} ${this.pubkeys.join(\' \')} OP_${this.pubkeys.length} OP_CHECKMULTISIG`)\\n }\\n\\n domain () {\\n return 1 + this.required * 74 // 1 (OP_0) + (1 + 73) * nsigs\\n }\\n\\n add (pubkey) {\\n if (!this.pubkeys.includes(pubkey)) {\\n this.pubkeys.push(pubkey)\\n }\\n }\\n }","version":"04"},"jig://1f0abf8d94477b1cb57629d861376616f6e1d7b78aba23a19da3e6169caf489e_o1":{"kind":"code","props":{"OP_CODES":{"OP_0":0,"OP_0NOTEQUAL":146,"OP_1":81,"OP_10":90,"OP_11":91,"OP_12":92,"OP_13":93,"OP_14":94,"OP_15":95,"OP_16":96,"OP_1ADD":139,"OP_1NEGATE":79,"OP_1SUB":140,"OP_2":82,"OP_2DROP":109,"OP_2DUP":110,"OP_2OVER":112,"OP_2ROT":113,"OP_2SWAP":114,"OP_3":83,"OP_3DUP":111,"OP_4":84,"OP_5":85,"OP_6":86,"OP_7":87,"OP_8":88,"OP_9":89,"OP_ABS":144,"OP_ADD":147,"OP_AND":132,"OP_BIN2NUM":129,"OP_BOOLAND":154,"OP_BOOLOR":155,"OP_CAT":126,"OP_CHECKMULTISIG":174,"OP_CHECKMULTISIGVERIFY":175,"OP_CHECKSIG":172,"OP_CHECKSIGVERIFY":173,"OP_CODESEPARATOR":171,"OP_DEPTH":116,"OP_DIV":150,"OP_DROP":117,"OP_DUP":118,"OP_ELSE":103,"OP_ENDIF":104,"OP_EQUAL":135,"OP_EQUALVERIFY":136,"OP_FALSE":0,"OP_FROMALTSTACK":108,"OP_GREATERTHAN":160,"OP_GREATERTHANOREQUAL":162,"OP_HASH160":169,"OP_HASH256":170,"OP_IF":99,"OP_IFDUP":115,"OP_INVALIDOPCODE":255,"OP_INVERT":131,"OP_LESSTHAN":159,"OP_LESSTHANOREQUAL":161,"OP_LSHIFT":152,"OP_MAX":164,"OP_MIN":163,"OP_MOD":151,"OP_MUL":149,"OP_NEGATE":143,"OP_NIP":119,"OP_NOP":97,"OP_NOP1":176,"OP_NOP10":185,"OP_NOP2":177,"OP_NOP3":178,"OP_NOP4":179,"OP_NOP5":180,"OP_NOP6":181,"OP_NOP7":182,"OP_NOP8":183,"OP_NOP9":184,"OP_NOT":145,"OP_NOTIF":100,"OP_NUM2BIN":128,"OP_NUMEQUAL":156,"OP_NUMEQUALVERIFY":157,"OP_NUMNOTEQUAL":158,"OP_OR":133,"OP_OVER":120,"OP_PICK":121,"OP_PUBKEY":254,"OP_PUBKEYHASH":253,"OP_PUSHDATA1":76,"OP_PUSHDATA2":77,"OP_PUSHDATA4":78,"OP_RETURN":106,"OP_RIPEMD160":166,"OP_ROLL":122,"OP_ROT":123,"OP_RSHIFT":153,"OP_SHA1":167,"OP_SHA256":168,"OP_SIZE":130,"OP_SPLIT":127,"OP_SUB":148,"OP_SWAP":124,"OP_TOALTSTACK":107,"OP_TRUE":81,"OP_TUCK":125,"OP_VERIFY":105,"OP_WITHIN":165,"OP_XOR":134},"deps":{"Hex":{"$jig":"_o2"}},"location":"_o1","nonce":1,"origin":"_o1","owner":"n3CiECgxW1pB1rGbYiX67e4U7AnS3MpJeE","satoshis":0},"src":"function asm (s) {\\n const parts = s.split(\' \')\\n let out = []\\n\\n for (const part of parts) {\\n // If one of our predefined op-codes\\n if (typeof asm.OP_CODES[part] !== \'undefined\') {\\n out.push(asm.OP_CODES[part])\\n continue\\n }\\n\\n // Hex data\\n const bytes = Hex.stringToBytes(part.length === 1 ? \'0\' + part : part)\\n\\n // OP_0\\n if (bytes[0] === 0) {\\n out.push(bytes[0]) // OP_0\\n continue\\n }\\n\\n // OP_1-OP_16\\n if (bytes.length === 1 && bytes[0] >= 1 && bytes[0] <= 16) {\\n out.push(bytes[0] + 0x50)\\n continue\\n }\\n\\n // OP_PUSH+[1-75] <bytes>\\n if (bytes.length <= 75) {\\n out = out.concat(bytes.length).concat(bytes)\\n continue\\n }\\n\\n // OP_PUSHDATA1 <len> <bytes>\\n if (bytes.length < 256) {\\n out = out.concat(asm.OP_CODES.OP_PUSHDATA1).concat([bytes.length]).concat(bytes)\\n continue\\n }\\n\\n const floor = x => parseInt(x.toString(), 10)\\n\\n // OP_PUSHDATA2 <len> <bytes>\\n if (bytes.length < 256 * 256) {\\n const len = [floor(bytes.length / 256), bytes.length % 256]\\n out = out.concat(asm.OP_CODES.OP_PUSHDATA2).concat(len).concat(bytes)\\n continue\\n }\\n\\n // OP_PUSHDATA4 <len> <bytes>\\n const len = [\\n floor(bytes.length / 256 / 256 / 256),\\n floor(bytes.length / 256 / 256) % 256,\\n floor(bytes.length / 256) % 256,\\n bytes.length % 256\\n ]\\n out = out.concat(asm.OP_CODES.OP_PUSHDATA4).concat(len).concat(bytes)\\n continue\\n }\\n\\n return Hex.bytesToString(out)\\n}","version":"04"},"jig://03e21aa8fcf08fa6985029ad2e697a2309962527700246d47d891add3cfce3ac_o1":{"kind":"code","props":{"OP_CODES":{"OP_0":0,"OP_0NOTEQUAL":146,"OP_1":81,"OP_10":90,"OP_11":91,"OP_12":92,"OP_13":93,"OP_14":94,"OP_15":95,"OP_16":96,"OP_1ADD":139,"OP_1NEGATE":79,"OP_1SUB":140,"OP_2":82,"OP_2DROP":109,"OP_2DUP":110,"OP_2OVER":112,"OP_2ROT":113,"OP_2SWAP":114,"OP_3":83,"OP_3DUP":111,"OP_4":84,"OP_5":85,"OP_6":86,"OP_7":87,"OP_8":88,"OP_9":89,"OP_ABS":144,"OP_ADD":147,"OP_AND":132,"OP_BIN2NUM":129,"OP_BOOLAND":154,"OP_BOOLOR":155,"OP_CAT":126,"OP_CHECKMULTISIG":174,"OP_CHECKMULTISIGVERIFY":175,"OP_CHECKSIG":172,"OP_CHECKSIGVERIFY":173,"OP_CODESEPARATOR":171,"OP_DEPTH":116,"OP_DIV":150,"OP_DROP":117,"OP_DUP":118,"OP_ELSE":103,"OP_ENDIF":104,"OP_EQUAL":135,"OP_EQUALVERIFY":136,"OP_FALSE":0,"OP_FROMALTSTACK":108,"OP_GREATERTHAN":160,"OP_GREATERTHANOREQUAL":162,"OP_HASH160":169,"OP_HASH256":170,"OP_IF":99,"OP_IFDUP":115,"OP_INVALIDOPCODE":255,"OP_INVERT":131,"OP_LESSTHAN":159,"OP_LESSTHANOREQUAL":161,"OP_LSHIFT":152,"OP_MAX":164,"OP_MIN":163,"OP_MOD":151,"OP_MUL":149,"OP_NEGATE":143,"OP_NIP":119,"OP_NOP":97,"OP_NOP1":176,"OP_NOP10":185,"OP_NOP2":177,"OP_NOP3":178,"OP_NOP4":179,"OP_NOP5":180,"OP_NOP6":181,"OP_NOP7":182,"OP_NOP8":183,"OP_NOP9":184,"OP_NOT":145,"OP_NOTIF":100,"OP_NUM2BIN":128,"OP_NUMEQUAL":156,"OP_NUMEQUALVERIFY":157,"OP_NUMNOTEQUAL":158,"OP_OR":133,"OP_OVER":120,"OP_PICK":121,"OP_PUBKEY":254,"OP_PUBKEYHASH":253,"OP_PUSHDATA1":76,"OP_PUSHDATA2":77,"OP_PUSHDATA4":78,"OP_RETURN":106,"OP_RIPEMD160":166,"OP_ROLL":122,"OP_ROT":123,"OP_RSHIFT":153,"OP_SHA1":167,"OP_SHA256":168,"OP_SIZE":130,"OP_SPLIT":127,"OP_SUB":148,"OP_SWAP":124,"OP_TOALTSTACK":107,"OP_TRUE":81,"OP_TUCK":125,"OP_VERIFY":105,"OP_WITHIN":165,"OP_XOR":134},"deps":{"Hex":{"$jig":"1f0abf8d94477b1cb57629d861376616f6e1d7b78aba23a19da3e6169caf489e_o2"}},"location":"_o1","nonce":3,"origin":"1f0abf8d94477b1cb57629d861376616f6e1d7b78aba23a19da3e6169caf489e_o1","owner":"n3CiECgxW1pB1rGbYiX67e4U7AnS3MpJeE","satoshis":0},"src":"function asm (s) {\\n const parts = s.split(\' \')\\n let out = []\\n\\n for (const part of parts) {\\n // If one of our predefined op-codes\\n if (typeof asm.OP_CODES[part] !== \'undefined\') {\\n out.push(asm.OP_CODES[part])\\n continue\\n }\\n\\n // Hex data\\n const bytes = Hex.stringToBytes(part.length === 1 ? \'0\' + part : part)\\n\\n // OP_0\\n if (bytes.length === 1 && bytes[0] === 0) {\\n out.push(bytes[0]) // OP_0\\n continue\\n }\\n\\n // OP_1-OP_16\\n if (bytes.length === 1 && bytes[0] >= 1 && bytes[0] <= 16) {\\n out.push(bytes[0] + 0x50)\\n continue\\n }\\n\\n // OP_PUSH+[1-75] <bytes>\\n if (bytes.length <= 75) {\\n out = out.concat(bytes.length).concat(bytes)\\n continue\\n }\\n\\n // OP_PUSHDATA1 <len> <bytes>\\n if (bytes.length < 256) {\\n out = out.concat(asm.OP_CODES.OP_PUSHDATA1).concat([bytes.length]).concat(bytes)\\n continue\\n }\\n\\n const floor = x => parseInt(x.toString(), 10)\\n\\n // OP_PUSHDATA2 <len> <bytes>\\n // len must be little endian\\n if (bytes.length < 256 * 256) {\\n const len = [bytes.length % 256, floor(bytes.length / 256)]\\n out = out.concat(asm.OP_CODES.OP_PUSHDATA2).concat(len).concat(bytes)\\n continue\\n }\\n\\n // OP_PUSHDATA4 <len> <bytes>\\n // len must be little endian\\n const len = [\\n bytes.length % 256,\\n floor(bytes.length / 256) % 256,\\n floor(bytes.length / 256 / 256) % 256,\\n floor(bytes.length / 256 / 256 / 256)\\n ]\\n out = out.concat(asm.OP_CODES.OP_PUSHDATA4).concat(len).concat(bytes)\\n continue\\n }\\n\\n return Hex.bytesToString(out)\\n}","version":"04"},"jig://f97d4ac2a3d6f5ed09fad4a4f341619dc5a3773d9844ff95c99c5d4f8388de2f_o1":{"kind":"code","props":{"deps":{"Jig":{"$jig":"native://Jig"}},"location":"_o1","nonce":1,"origin":"_o1","owner":"n3CiECgxW1pB1rGbYiX67e4U7AnS3MpJeE","satoshis":0},"src":"function expect (subject) {\\n let negated = false\\n\\n const stringify = x => {\\n if (typeof x !== \'object\' || !x) return x\\n try { return JSON.stringify(x) } catch (e) { return x.toString() }\\n }\\n\\n function check (condition, conditionString, message) {\\n if (negated ? condition : !condition) {\\n throw new Error(message || `expected value${negated ? \' not\' : \'\'} to be ${conditionString} but was ${stringify(subject)}`)\\n }\\n }\\n\\n function deepEqual (a, b) {\\n if (a === b) return true\\n\\n if (typeof a !== typeof b) return false\\n\\n if (typeof a !== \'object\') return false\\n\\n if (a === null || b === null) return false\\n\\n if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false\\n\\n if (Object.keys(a).length !== Object.keys(b).length) return false\\n\\n if (!Object.keys(a).every(key => deepEqual(a[key], b[key]))) return false\\n\\n if (a instanceof Set) {\\n if (a.size !== b.size) return false\\n if (!deepEqual(Array.from(a.entries()), Array.from(b.entries()))) return false\\n }\\n\\n if (a instanceof Map) {\\n if (a.size !== b.size) return false\\n if (!deepEqual(Array.from(a.entries()), Array.from(b.entries()))) return false\\n }\\n\\n return true\\n }\\n\\n function extendsFrom (a, b) {\\n if (typeof a !== \'function\') return false\\n if (typeof b !== \'function\') return false\\n while (a) {\\n a = Object.getPrototypeOf(a)\\n if (a === b) return true\\n }\\n return false\\n }\\n\\n return {\\n get not () { negated = !negated; return this },\\n\\n toBe: (value, message) => check(subject === value, `${stringify(value)}`, message),\\n toEqual: (value, message) => check(deepEqual(subject, value), `equal to ${stringify(value)}`, message),\\n toBeInstanceOf: (Class, message) => check(subject && subject instanceof Class, `an instance of ${Class && Class.name}`, message),\\n\\n toBeDefined: message => check(typeof subject !== \'undefined\', \'defined\', message),\\n toBeNull: message => check(subject === null, \'null\', message),\\n\\n toBeNumber: message => check(typeof subject === \'number\', \'a number\', message),\\n toBeInteger: message => check(Number.isInteger(subject), \'an integer\', message),\\n toBeLessThan: (value, message) => check(subject < value && typeof subject === \'number\' && typeof value === \'number\', `less than ${value}`, message),\\n toBeLessThanOrEqualTo: (value, message) => check(subject <= value && typeof subject === \'number\' && typeof value === \'number\', `less than or equal to ${value}`, message),\\n toBeGreaterThan: (value, message) => check(subject > value && typeof subject === \'number\' && typeof value === \'number\', `greater than ${value}`, message),\\n toBeGreaterThanOrEqualTo: (value, message) => check(subject >= value && typeof subject === \'number\' && typeof value === \'number\', `greater than or equal to ${value}`, message),\\n\\n toBeBoolean: message => check(typeof subject === \'boolean\', \'a boolean\', message),\\n toBeString: message => check(typeof subject === \'string\', \'a string\', message),\\n toBeObject: message => check(subject && typeof subject === \'object\', \'an object\', message),\\n toBeArray: message => check(Array.isArray(subject), \'an array\', message),\\n toBeSet: message => check(subject instanceof Set, \'a set\', message),\\n toBeMap: message => check(subject instanceof Map, \'a map\', message),\\n toBeUint8Array: message => check(subject instanceof Uint8Array, \'a uint8array\', message),\\n\\n toBeClass: message => check(typeof subject === \'function\' && subject.toString().startsWith(\'class\'), \'a class\', message),\\n toBeFunction: message => check(typeof subject === \'function\' && !subject.toString().startsWith(\'class\'), \'a function\', message),\\n toBeJigClass: message => check(typeof subject === \'function\' && subject.toString().startsWith(\'class\') && extendsFrom(subject, Jig), \'a jig class\', message),\\n toExtendFrom: (Class, message) => check(extendsFrom(subject, Class), `an extension of ${Class && Class.name}`, message)\\n }\\n}","version":"04"},"jig://424abf066be56b9dd5203ed81cf1f536375351d29726d664507fdc30eb589988_o1":{"kind":"code","props":{"deps":{},"location":"_o1","nonce":1,"origin":"_o1","owner":"n3CiECgxW1pB1rGbYiX67e4U7AnS3MpJeE","satoshis":0},"src":"class Base58 {\\n static decode (s) {\\n // Based on https://gist.github.com/diafygi/90a3e80ca1c2793220e5/\\n if (typeof s !== \'string\') throw new Error(`Cannot decode: ${s}`)\\n const A = \'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\'\\n const d = [] // the array for storing the stream of decoded bytes\\n const b = [] // the result byte array that will be returned\\n let j // the iterator variable for the byte array (d)\\n let c // the carry amount variable that is used to overflow from the current byte to the next byte\\n let n // a temporary placeholder variable for the current byte\\n for (let i = 0; i < s.length; i++) {\\n j = 0 // reset the byte iterator\\n c = A.indexOf(s[i]) // set the initial carry amount equal to the current base58 digit\\n if (c < 0) throw new Error(`Invalid base58 character: ${s}\\\\n\\\\nDetails: i=${i}, c=${s[i]}`)\\n if (!(c || b.length ^ i)) b.push(0) // prepend the result array with a zero if the base58 digit is zero and non-zero characters haven\'t been seen yet (to ensure correct decode length)\\n while (j in d || c) { // start looping through the bytes until there are no more bytes and no carry amount\\n n = d[j] // set the placeholder for the current byte\\n n = n ? n * 58 + c : c // shift the current byte 58 units and add the carry amount (or just add the carry amount if this is a new byte)\\n c = n >> 8 // find the new carry amount (1-byte shift of current byte value)\\n d[j] = n % 256 // reset the current byte to the remainder (the carry amount will pass on the overflow)\\n j++ // iterate to the next byte\\n }\\n }\\n while (j--) { b.push(d[j]) } // since the byte array is backwards, loop through it in reverse order, and append\\n if (b.length < 5) throw new Error(`Base58 string too short: ${s}`)\\n // We assume the checksum and version are correct\\n return b.slice(1, b.length - 4)\\n }\\n}","version":"04"},"jig://d476fd7309a0eeb8b92d715e35c6e273ad63c0025ff6cca927bd0f0b64ed88ff_o3":{"kind":"code","props":{"deps":{"Berry":{"$jig":"native://Berry"},"txo":{"$jig":"_o2"}},"location":"_o3","metadata":{"author":"Run ▸ Extra","license":"MIT","website":"https://www.run.network"},"nonce":2,"origin":"b44a203acd6215d2d24b33a41f730e9acf2591c4ae27ecafc8d88ef83da9ddea_o1","owner":"n3CiECgxW1pB1rGbYiX67e4U7AnS3MpJeE","satoshis":0},"src":"class B extends Berry {\\n init (base64Data, mediaType, encoding, filename, metadata = {}) {\\n this.base64Data = base64Data\\n this.mediaType = mediaType\\n this.encoding = encoding\\n this.filename = filename\\n this.metadata = metadata\\n\\n if (mediaType === \'image/svg+xml\' || mediaType === \'image/png\') {\\n this.metadata.image = this\\n }\\n }\\n\\n static async pluck (path, fetch) {\\n const txid = path.length === 64 ? path : JSON.parse(path).txid\\n const metadata = path.length === 64 ? {} : JSON.parse(path).metadata\\n const data = txo(await fetch(txid))\\n const out = data.out.find(o => o.s2 === \'19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut\')\\n if (!out) throw new Error(`Cannot find B:// data in ${txid}`)\\n return new B(out.b3, out.s4, out.s5, out.s6, metadata)\\n }\\n\\n static async loadWithMetadata (txid, metadata) {\\n return this.load(JSON.stringify({ txid, metadata }))\\n }\\n}","version":"04"}}')},function(t,n,e){const r=e(6),{PrivateKey:o,Script:i,Transaction:s}=r,{M:a,J:c}=e(0),u=e(2),{Gr:h}=e(12),PurseWrapper=e(49),f="LocalPurse",l=34,d=149;function p(t){switch(typeof t){case"number":if(!Number.isInteger(t))throw new Error(`splits must be an integer: ${t}`);if(t<=0)throw new Error(`splits must be at least 1: ${t}`);return t;case"undefined":return 1;default:throw new Error(`Invalid splits: ${t}`)}}function b(t){switch(typeof t){case"number":if(!Number.isFinite(t))throw new Error(`feePerKb must be finite: ${t}`);if(t<0)throw new Error(`feePerKb must be non-negative: ${t}`);return t;case"undefined":return s.FEE_PER_KB;default:throw new Error(`Invalid feePerKb: ${t}`)}}function w(t,n){try{const r=e(31).util.metadata(t);return n>r.vrun&&n<r.out.length+r.vrun+1}catch(t){return!1}}t.exports=class extends PurseWrapper{constructor(t={}){if(super(void 0,function(t){switch(typeof t){case"undefined":throw new Error("blockchain is required");case"object":if(t&&t.network)return t}throw new Error(`Invalid blockchain: ${c(t)}`)}(t.blockchain)),this.qc=p(t.splits),this.Qc=b(t.feePerKb),this.bsvPrivateKey=new o(t.privkey,a(this.blockchain.network)),this.bsvAddress=this.bsvPrivateKey.toAddress(),this.bsvScript=i.fromAddress(this.bsvAddress),this.privkey=this.bsvPrivateKey.toString(),this.address=this.bsvAddress.toString(),this.script=this.bsvScript.toHex(),t.privkey&&this.bsvPrivateKey.toString()!==t.privkey.toString())throw new Error(`Invalid private key: ${c(t.privkey)}`);this.jigFilter=!0,this.cacheUtxos=!0,this.Xc=[],this.Zc=new Map}get splits(){return this.qc}set splits(t){this.qc=p(t)}get feePerKb(){return this.Qc}set feePerKb(t){this.Qc=b(t)}async pay(t,n){this.cacheUtxos&&this.Xc.length||(this.Xc=await this.blockchain.utxos(this.script),this.Zc.clear());const e=new r.Transaction(t),o=e.inputs.length,a=await async function(t,n,e,o,a,c,p,b,y){const g=s.DUST_AMOUNT;t.feePerKb(p);const _=p/1e3;n.forEach(((n,e)=>{n&&(t.inputs[e].output=new s.Output({satoshis:n.satoshis,script:new i(n.script)}))}));const m=[];t.inputs.forEach(((t,n)=>{t.script.toBuffer().length||(m.push(n),t.setScript(r.deps.Buffer.alloc(500)))}));const O=0===t.outputs.length?g:0,P=t._getInputAmount(),E=t._getOutputAmount();if(P-E-O>=t.toBuffer().length*_){u.Ut&&u.Dt(f,"Transaction already paid for. Skipping.");const n=Math.ceil((l+t.toBuffer().length)*_);return P-E>g+n&&(t._fee=n,t.change(c)),m.forEach((n=>t.inputs[n].setScript(""))),t}function v(t){for(let n=t.length-1;n>0;n--){const e=Math.floor(Math.random()*(n+1));[t[n],t[e]]=[t[e],t[n]]}return t}if(!(e=v(e)).length){throw new Error(`Not enough funds\n\n${`Hint: Have you funded the purse address ${c}?`}`)}const x=t.inputs.length;let A=t.toBuffer().length*_,$=A+E-P,S=0,k=1;A+=l*_,$+=l*_,$+=g;for(const n of e){const r=await o.fetch(n.txid);if(y&&w(r,n.vout))continue;t.from(n),$-=n.satoshis,S++,A+=d*_,$+=d*_;const i=b-e.length+S-k;for(let t=0;t<i;t++)A+=l*_,$+=l*_,$+=g,k++;if($<0)break}if(A=Math.ceil(A),$=Math.ceil($),$>0){throw new Error(`Not enough funds\n\n${`Required ${$} more satoshis`}`)}const j=k*g-$,T=Math.max(g,Math.floor(j/k));for(let n=0;n<k;n++)n===k-1?(t._fee=A,t.change(c)):t.to(c,T);for(let n=x;n<t.inputs.length;n++){const e=t.inputs[n].output,r=await h(t,n,e.script,e.satoshis,a),o=a.publicKey.toString(),s=i.fromASM(`${r} ${o}`);t.inputs[n].setScript(s)}const I=t._getInputAmount()-P,R=t._getOutputAmount()-E,N=I-R;u.Ut&&u.Dt(f,"Paid about",N,"satoshis");return m.forEach((n=>t.inputs[n].setScript(""))),t}(e,n,this.Xc,this.blockchain,this.bsvPrivateKey,this.bsvAddress,this.feePerKb,this.splits,this.jigFilter),c=a.toString();if(this.cacheUtxos){const t=[];for(let n=o;n<e.inputs.length;n++){const r=e.inputs[n],o=r.prevTxId.toString("hex"),i=r.outputIndex,s=this.Xc.findIndex((t=>t.txid===o&&t.vout===i)),a=this.Xc[s];this.Xc.splice(s,1),t.push(a)}this.Zc.set(c,t)}return c}async broadcast(t){if(await this.blockchain.broadcast(t),!this.cacheUtxos)return;const n=new r.Transaction(t),e=n.hash;n.outputs.forEach(((t,n)=>{t.script.toHex()===this.script&&this.Xc.push({txid:e,vout:n,script:this.script,satoshis:t.satoshis})})),this.Zc.delete(t)}async cancel(t){if(!this.cacheUtxos)return;const n=this.Zc.get(t);n&&n.forEach((t=>this.Xc.push(t))),this.Zc.delete(t)}async balance(){return(await this.utxos()).reduce(((t,n)=>t+n.satoshis),0)}async utxos(){this.cacheUtxos&&this.Xc.length||(this.Xc=await this.blockchain.utxos(this.script),this.Zc.clear());const t=await Promise.all(this.Xc.map((t=>this.blockchain.fetch(t.txid))));return this.Xc.filter(((n,e)=>!this.jigFilter||!w(t[e],n.vout)))}}},function(t,n,e){const StateWrapper=e(40);t.exports=class extends StateWrapper{async pull(){}}},function(t,n,e){const r=e(6),{Address:o,Script:i,Transaction:s}=r,a=e(2),{Lr:c}=e(12),{bt:u}=e(0),{sha256}=r.crypto.Hash,BlockchainWrapper=e(41),h="Mockchain";t.exports=class extends BlockchainWrapper{constructor(){super(),this.network="mock",this.mempoolChainLimit=1e3,this.tu=new Map,this.nu=new Map,this.Es=new Map,this.Xc=new Map,this.eu=new Map,this.ru=new Map}async broadcast(t){const n=new s(t),e=n.hash;if(this.tu.has(e))return a.nn&&a.Xt(h,"Already have transaction",e),e;n.inputs.forEach(((t,n)=>{const e=`${t.prevTxId.toString("hex")}_o${t.outputIndex}`,r=this.Xc.get(e);if(!r){const t=this.Es.get(e),n=this.ru.has(t);throw new Error(n?"txn-mempool-conflict":"Missing inputs")}t.output=new s.Output(r)}));if(n.inputs.reduce(((t,n)=>t+n.output.satoshis),0)<n.outputs.reduce(((t,n)=>t+n.satoshis),0))throw new Error("bad-txns-in-belowout");if(n.getFee()<n.toBuffer().length*s.FEE_PER_KB/1e3)throw new Error("insufficient priority");if(!0!==n.isFullySigned())throw new Error("mandatory-script-verify-flag-failed");for(let t=0;t<n.inputs.length;t++)if(!n.isValidSignature({inputIndex:t}))throw new Error("mandatory-script-verify-flag-failed");const o=n.inputs.map((t=>t.prevTxId.toString("hex"))).map((t=>this.ru.get(t)+1)).reduce(((t,n)=>Math.max(t,n)),0);if(o>u(this.mempoolChainLimit,"mempoolChainLimit")){throw new Error(`too-long-mempool-chain\n\n${"Hint: Use run.blockchain.block() to produce blocks on the mockchain."}`)}return this.tu.set(e,t),this.nu.set(e,Date.now()),this.ru.set(e,o),n.inputs.forEach(((t,n)=>{const o=t.prevTxId.toString("hex"),i=`${o}_o${t.outputIndex}`,s=this.tu.get(o),a=new r.Transaction(s).outputs[t.outputIndex],c=sha256(a.script.toBuffer()).reverse().toString("hex");this.Xc.delete(i),this.eu.get(c).delete(i),this.Es.set(i,e)})),n.outputs.forEach(((t,n)=>{const r=`${e}_o${n}`;this.Es.set(r,null);const o={txid:e,vout:n,script:t.script.toHex(),satoshis:t.satoshis};this.Xc.set(r,o);const i=sha256(t.script.toBuffer()).reverse().toString("hex"),s=this.eu.get(i)||new Set;s.add(r),this.eu.set(i,s)})),e}async fetch(t){const n=this.tu.get(t);if(!n)throw new Error(`No such mempool or blockchain transaction: ${t}`);return n}async utxos(t){const n=await c(t),e=this.eu.get(n);return e?Array.from(e).map((t=>this.Xc.get(t))):[]}async spends(t,n){const e=`${t}_o${n}`;return this.Es.get(e)||null}async time(t){const n=this.nu.get(t);if(!n)throw new Error(`No such mempool or blockchain transaction: ${t}`);return n}fund(t,n){a.tn&&a.qt(h,"Fund",t.toString(),"with",n);const e=Math.random().toString(),r=(new s).addData(e).to(new o(t,"testnet"),n),c=r.hash,u=r.toString("hex");this.tu.set(c,u),this.nu.set(c,Date.now()),this.ru.set(c,0);const f={txid:c,vout:1,script:r.outputs[1].script.toHex(),satoshis:r.outputs[1].satoshis},l=`${c}_o1`;this.Xc.set(l,f);const d=i.fromAddress(t),p=sha256(d.toBuffer()).reverse().toString("hex"),b=this.eu.get(p)||new Set;return b.add(l),this.eu.set(p,b),c}block(){a.Ut&&a.Dt(h,"Block"),this.ru.clear()}}},function(t,n,e){t.exports=null},function(t,n,e){const r=e(6),o=e(19),{J:i}=e(0),PurseWrapper=e(49),RunConnect=e(62);t.exports=class extends PurseWrapper{constructor(t){super();let n=null;try{n=new r.HDPublicKey(t)}catch(n){throw new Error(`Invalid API key: ${i(t)}`)}this.network="mainnet"===n.network.name||"livenet"===n.network.name?"main":"test",this.apiKey=t,this.timeout=5e3,this.request=o,this.host="https://api.run.network"}async pay(t,n){const e=`${this.host}/v1/${this.network}/pay`,r={method:"POST",body:{rawtx:t,parents:n,key:this.apiKey},timeout:this.timeout};return(await this.request(e,r)).rawtx}async broadcast(t){if(this.blockchain instanceof RunConnect&&this.network===this.blockchain.network)return void await this.blockchain.broadcast(t);const n=`${this.host}/v1/${this.network}/tx`,e={method:"POST",body:{rawtx:t},timeout:this.timeout};await this.request(n,e)}async cancel(t){}}},function(t,n,e){const{Lr:r}=e(12),o=e(19),StateWrapper=e(40);t.exports=class extends StateWrapper{constructor(t){super(),this.host=t,this.request=o}async pull(t,n){const[e,r]=t.split("://");let o,i=null;switch(e){case"jig":i=`${this.host}/jig/${r}`;break;case"berry":i=`${this.host}/berry/${encodeURIComponent(r)}`;break;case"trust":i=`${this.host}/trust/${r}`;break;case"ban":return;case"tx":i=`${this.host}/tx/${r}`;break;case"spend":i=`${this.host}/spends/${r}`;break;case"time":i=`${this.host}/time/${r}`;break;default:return}try{o=await this.request(i)}catch(t){if(404===t.status)return;throw t}if(n&&n.tx&&"jig"===e&&this.cache)try{const t=r.slice(0,64),n=`${this.host}/tx/${t}`,e=await this.request(n);await this.cache.set(`tx://${t}`,e)}catch(t){if(404!==t.status)throw t}return o}async locations(t){const n=await r(t),e=`${this.host}/unspent?scripthash=${n}`;return await this.request(e)}async broadcast(t){await this.request(`${this.host}/tx`,{method:"POST",body:t,headers:{"content-type":"text/plain"}})}}},function(t,n,e){const r=e(19),o=e(28),StateWrapper=e(40);t.exports=class extends StateWrapper{constructor(t={}){super(),this.network=function(t){if(void 0===t)return"main";if("string"!=typeof t)throw new Error(`Invalid network: ${t}`);if("main"!==t&&"test"!==t)throw new Error(`RunConnect API does not support the "${t}" network`);return t}(t.network),this.request=r,this.host="https://api.run.network"}async pull(t,n){let e={},r=null;const[i,s]=t.split("://");if("jig"===i||"berry"===i){try{const t=(n=n||{}).all?1:0,r=n.tx?1:0,i=n.filter||o.toBase64(o.create()),a=`${this.host}/v1/${this.network}/state/${encodeURIComponent(s)}?all=${t}&tx=${r}&filter=${i}`,c={cache:1e3};e=await this.request(a,c)}catch(t){e="object"==typeof t.reason?t.reason:{},404!==t.status&&(r=t)}if(this.cache&&await Promise.all(Object.entries(e).filter((([n,e])=>n!==t)).map((([t,n])=>this.cache.set(t,n)))),r)throw r;return e[t]}}}},function(t,n,e){const{J:r,M:o}=e(0),{Mn:i}=e(8),s=e(6),{Script:a}=s,c=e(2),OwnerWrapper=e(46);t.exports=class extends OwnerWrapper{constructor(t,n){super(),this.owner=t,this.script=a.fromHex(i(this.owner,!1,n&&o(n)).script())}async sign(t,n,e){return c.nn&&c.Xt("Viewer","Viewer cannot sign ",r(this.owner)),t}nextOwner(){return this.owner}}},function(t,n,e){const{Lr:r}=e(12),o=e(2),{NotImplementedError}=e(11),i=e(19),BlockchainWrapper=e(41),{Io:s}=i;t.exports=class extends BlockchainWrapper{constructor(t={}){super(),this.api="whatsonchain",this.apiKey=function(t){if(void 0===t||"string"==typeof t)return t;throw new Error(`Invalid API key: ${t}`)}(t.apiKey),this.network=function(t){if(void 0===t)return"main";if("string"!=typeof t)throw new Error(`Invalid network: ${t}`);if("main"!==t&&"test"!==t&&"stn"!==t)throw new Error(`WhatsOnChain API does not support the "${t}" network`);return t}(t.network),this.request=i}async broadcast(t){const n=`https://api.whatsonchain.com/v1/bsv/${this.network}/tx/raw`,e={method:"POST",body:{txhex:t},headers:this.apiKey?{"woc-api-key":this.apiKey}:{}};return await this.request(n,e)}async fetch(t){try{const n=`https://api.whatsonchain.com/v1/bsv/${this.network}/tx/${t}/hex`,e={headers:this.apiKey?{"woc-api-key":this.apiKey}:{},cache:1e3};return await this.request(n,e)}catch(t){throw t instanceof s&&(404===t.status||500===t.status)?new Error("No such mempool or blockchain transaction"):t}}async utxos(t){if("stn"===this.network)return o.nn&&o.Xt("WhatsOnChain","Utxos are not available on STN"),[];const n=await r(t),e=`https://api.whatsonchain.com/v1/bsv/${this.network}/script/${n}/unspent`,i=this.apiKey?{"woc-api-key":this.apiKey}:{};return(await this.request(e,{headers:i,cache:1e3})).map((n=>({txid:n.tx_hash,vout:n.tx_pos,satoshis:n.value,script:t})))}async time(t){try{const n=`https://api.whatsonchain.com/v1/bsv/${this.network}/tx/hash/${t}`,e={headers:this.apiKey?{"woc-api-key":this.apiKey}:{},cache:1e3};return 1e3*(await this.request(n,e)).time||Date.now()}catch(t){throw t instanceof s&&(404===t.status||500===t.status)?new Error("No such mempool or blockchain transaction"):t}}async spends(t,n){throw new NotImplementedError("WhatsOnChain API does not support spends")}}},function(t,n,e){t.exports={createJigShell:e(58),decodeJigJson:e(84),encodeJigJson:e(85),hydrateJigShell:e(59),recreateJigsFromStates:e(48),validateState:e(60)}},function(t,n,e){const r=e(18);t.exports=function(t,n){return r.ko(t,{jo:n})}},function(t,n,e){const r=e(18);t.exports=function(t,n){return r.$o(t,{Ao:n})}}])}));