@sentio/sdk-bundle 2.41.3 → 2.41.4-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/aptos/builtin/0x1.js +1 -1
- package/lib/aptos/builtin/0x3.js +1 -1
- package/lib/aptos/builtin/index.js +1 -1
- package/lib/aptos/ext/index.js +1 -1
- package/lib/aptos/index.js +1 -1
- package/lib/{chunk-W6WR24QE.js → chunk-6A55BPSR.js} +2 -2
- package/lib/{chunk-3NB64JZP.js → chunk-BFNY6LBJ.js} +2 -2
- package/lib/{chunk-6FED5COB.js → chunk-BU43YFHA.js} +2 -2
- package/lib/{chunk-4AM4A5YI.js → chunk-E6J4FNZM.js} +2 -2
- package/lib/{chunk-WEP3H77U.js → chunk-Q5FQHFLO.js} +2 -2
- package/lib/{chunk-EVQTZUIB.js → chunk-RW2I6GQV.js} +2 -2
- package/lib/chunk-XDCOG5SL.js +16 -0
- package/lib/chunk-XDCOG5SL.js.map +1 -0
- package/lib/{chunk-YOQOYZZT.js → chunk-YNKEJBSZ.js} +2 -2
- package/lib/sui/builtin/0x1.js +1 -1
- package/lib/sui/builtin/0x2.js +1 -1
- package/lib/sui/builtin/0x3.js +1 -1
- package/lib/sui/builtin/index.js +1 -1
- package/lib/sui/ext/index.js +1 -1
- package/lib/sui/index.js +1 -1
- package/lib/testing/index.js +1 -1
- package/lib/utils/block.d.ts +3 -0
- package/lib/utils/block.d.ts.map +1 -0
- package/lib/utils/block.test.d.ts +2 -0
- package/lib/utils/block.test.d.ts.map +1 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +1 -1
- package/package.json +2 -2
- package/src/utils/block.ts +44 -0
- package/src/utils/index.ts +1 -0
- package/lib/chunk-6NKFKKM4.js +0 -16
- package/lib/chunk-6NKFKKM4.js.map +0 -1
- /package/lib/{chunk-W6WR24QE.js.map → chunk-6A55BPSR.js.map} +0 -0
- /package/lib/{chunk-3NB64JZP.js.map → chunk-BFNY6LBJ.js.map} +0 -0
- /package/lib/{chunk-6FED5COB.js.map → chunk-BU43YFHA.js.map} +0 -0
- /package/lib/{chunk-4AM4A5YI.js.map → chunk-E6J4FNZM.js.map} +0 -0
- /package/lib/{chunk-WEP3H77U.js.map → chunk-Q5FQHFLO.js.map} +0 -0
- /package/lib/{chunk-EVQTZUIB.js.map → chunk-RW2I6GQV.js.map} +0 -0
- /package/lib/{chunk-YOQOYZZT.js.map → chunk-YNKEJBSZ.js.map} +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createRequire as createRequireSdkShim } from 'module'; const require = createRequireSdkShim(import.meta.url);
|
|
2
|
+
import{c as Xn}from"./chunk-2QA4TUBF.js";import{e as Kn}from"./chunk-GREJR3T2.js";import{U as Qn,_ as Yn,a as ir,i as Hn}from"./chunk-KGC37I7H.js";import{a as nl}from"./chunk-7HVQTJAO.js";import{Cc as tr,Dc as rr,Ec as nr,Fc as rl,_c as Wn,b as tl,c as $n,k as H,mc as dt}from"./chunk-URRJSGRQ.js";import{a as k,b as _,c as v,d as Gn,e as Ge,f as ht,h as Jn,i as jn,j as er}from"./chunk-LLHU72AA.js";var Y=v(Q=>{"use strict";Q.getValueAsString=function(e){return Number.isNaN(e)?"Nan":Number.isFinite(e)?`${e}`:e<0?"-Inf":"+Inf"};Q.removeLabels=function(e,r,n){let i=hr(r,n);delete e[i]};Q.setValue=function(e,r,n){let i=hr(n);return e[i]={value:typeof r=="number"?r:0,labels:n||{}},e};Q.setValueDelta=function(e,r,n,i=""){let s=typeof r=="number"?r:0;return e[i]?e[i].value+=s:e[i]={value:s,labels:n},e};Q.getLabels=function(t,e){if(typeof e[0]=="object")return e[0];if(t.length!==e.length)throw new Error("Invalid number of arguments");let r={};for(let n=0;n<t.length;n++)r[t[n]]=e[n];return r};function Bi(t,e){if(t.length===0)return"";let r="";for(let n=0;n<t.length;n++){let i=t[n],s=e[i];s!==void 0&&(r+=`${i}:${s},`)}return r}function hr(t,e){if(e)return Bi(e,t);let r=Object.keys(t);return r.length>1&&r.sort(),Bi(r,t)}Q.hashObject=hr;Q.isObject=function(e){return e!==null&&typeof e=="object"};Q.nowTimestamp=function(){return Date.now()/1e3};var fr=class extends Map{add(e,r){this.has(e)?this.get(e).push(r):this.set(e,[r])}};Q.Grouper=fr});var Pe=v((Nh,mr)=>{"use strict";var{getValueAsString:qi}=Y(),U=class{static get PROMETHEUS_CONTENT_TYPE(){return"text/plain; version=0.0.4; charset=utf-8"}static get OPENMETRICS_CONTENT_TYPE(){return"application/openmetrics-text; version=1.0.0; charset=utf-8"}constructor(e=U.PROMETHEUS_CONTENT_TYPE){if(this._metrics={},this._collectors=[],this._defaultLabels={},e!==U.PROMETHEUS_CONTENT_TYPE&&e!==U.OPENMETRICS_CONTENT_TYPE)throw new TypeError(`Content type ${e} is unsupported`);this._contentType=e}getMetricsAsArray(){return Object.values(this._metrics)}async getMetricsAsString(e){let r=typeof e.getForPromString=="function"?await e.getForPromString():await e.get(),n=pr(r.name),i=`# HELP ${n} ${pr(r.help)}`,s=`# TYPE ${n} ${r.type}`,o=[i,s],a=Object.keys(this._defaultLabels).length>0?this._defaultLabels:null,l=this.contentType===U.OPENMETRICS_CONTENT_TYPE;for(let c of r.values||[]){let{metricName:u=n,labels:f={}}=c,{sharedLabels:h={}}=c;l&&r.type==="counter"&&(u=`${u}_total`),a&&(f={...f,...a,...f});let p=dr(f,h),b=yl(h),d=[...p,b].filter(Boolean),C=d.length?`{${d.join(",")}}`:"",m=`${u}${C} ${qi(c.value)}`,{exemplar:y}=c;if(y&&l){let S=dr(y.labelSet);m+=` # {${S.join(",")}} ${qi(y.value)} ${y.timestamp}`}o.push(m)}return o.join(`
|
|
3
|
+
`)}async metrics(){let e=this.contentType===U.OPENMETRICS_CONTENT_TYPE,r=this.getMetricsAsArray().map(i=>(e&&i.type==="counter"&&(i.name=Sl(i.name)),this.getMetricsAsString(i))),n=await Promise.all(r);return e?`${n.join(`
|
|
4
|
+
`)}
|
|
5
|
+
# EOF
|
|
6
|
+
`:`${n.join(`
|
|
7
|
+
|
|
8
|
+
`)}
|
|
9
|
+
`}registerMetric(e){if(this._metrics[e.name]&&this._metrics[e.name]!==e)throw new Error(`A metric with the name ${e.name} has already been registered.`);this._metrics[e.name]=e}clear(){this._metrics={},this._defaultLabels={}}async getMetricsAsJSON(){let e=[],r=Object.keys(this._defaultLabels),n=[];for(let s of this.getMetricsAsArray())n.push(s.get());let i=await Promise.all(n);for(let s of i){if(s.values&&r.length>0)for(let o of s.values){o.labels=Object.assign({},o.labels);for(let a of r)o.labels[a]=o.labels[a]||this._defaultLabels[a]}e.push(s)}return e}removeSingleMetric(e){delete this._metrics[e]}getSingleMetricAsString(e){return this.getMetricsAsString(this._metrics[e])}getSingleMetric(e){return this._metrics[e]}setDefaultLabels(e){this._defaultLabels=e}resetMetrics(){for(let e in this._metrics)this._metrics[e].reset()}get contentType(){return this._contentType}setContentType(e){if(e===U.OPENMETRICS_CONTENT_TYPE||e===U.PROMETHEUS_CONTENT_TYPE)this._contentType=e;else throw new Error(`Content type ${e} is unsupported`)}static merge(e){let r=e[0].contentType;for(let s of e)if(s.contentType!==r)throw new Error("Registers can only be merged if they have the same content type");let n=new U(r);return e.reduce((s,o)=>s.concat(o.getMetricsAsArray()),[]).forEach(n.registerMetric,n),n}};function dr(t,e){let{hasOwnProperty:r}=Object.prototype,n=[];for(let[i,s]of Object.entries(t))(!e||!r.call(e,i))&&n.push(`${i}="${vl(s)}"`);return n}var Ui=new WeakMap;function yl(t){let e=Ui.get(t);if(e)return e;let n=dr(t).join(",");return Ui.set(t,n),n}function vl(t){return typeof t!="string"?t:pr(t).replace(/"/g,'\\"')}function pr(t){return t.replace(/\\/g,"\\\\").replace(/\n/g,"\\n")}function Sl(t){return t.replace(/_total$/,"")}mr.exports=U;mr.exports.globalRegistry=new U});var pe=v(Et=>{"use strict";var El=k("util"),Nl=/^[a-zA-Z_:][a-zA-Z0-9_:]*$/,wl=/^[a-zA-Z_][a-zA-Z0-9_]*$/;Et.validateMetricName=function(t){return Nl.test(t)};Et.validateLabelName=function(t=[]){return t.every(e=>wl.test(e))};Et.validateLabel=function(e,r){for(let n in r)if(!e.includes(n))throw new Error(`Added label "${n}" is not included in initial labelset: ${El.inspect(e)}`)}});var je=v((Oh,Vi)=>{"use strict";var _r=Pe(),{isObject:Ol}=Y(),{validateMetricName:Tl,validateLabelName:xl}=pe(),gr=class{constructor(e,r={}){if(!Ol(e))throw new TypeError("constructor expected a config object");if(Object.assign(this,{labelNames:[],registers:[_r.globalRegistry],aggregator:"sum",enableExemplars:!1},r,e),this.registers||(this.registers=[_r.globalRegistry]),!this.help)throw new Error("Missing mandatory help parameter");if(!this.name)throw new Error("Missing mandatory name parameter");if(!Tl(this.name))throw new Error("Invalid metric name");if(!xl(this.labelNames))throw new Error("Invalid label name");if(this.collect&&typeof this.collect!="function")throw new Error('Optional "collect" parameter must be a function');this.labelNames?this.sortedLabelNames=[...this.labelNames].sort():this.sortedLabelNames=[],this.reset();for(let n of this.registers){if(this.enableExemplars&&n.contentType===_r.PROMETHEUS_CONTENT_TYPE)throw new TypeError("Exemplars are supported only on OpenMetrics registries");n.registerMetric(this)}}reset(){}};Vi.exports={Metric:gr}});var yr=v((Th,Fi)=>{"use strict";var br=class{constructor(e={},r=null){this.labelSet=e,this.value=r}validateExemplarLabelSet(e){let r="";for(let[n,i]of Object.entries(e))r+=`${n}${i}`;if(r.length>128)throw new RangeError("Label set size must be smaller than 128 UTF-8 chars")}};Fi.exports=br});var Sr=v((xh,$i)=>{"use strict";var Cl=k("util"),{hashObject:Il,isObject:zi,getLabels:Gi,removeLabels:Al,nowTimestamp:Pl}=Y(),{validateLabel:Ji}=pe(),{Metric:Rl}=je(),Ml=yr(),vr=class extends Rl{constructor(e){super(e),this.type="counter",this.defaultLabels={},this.defaultValue=1,this.defaultExemplarLabelSet={},e.enableExemplars?(this.enableExemplars=!0,this.inc=this.incWithExemplar):this.inc=this.incWithoutExemplar}incWithoutExemplar(e,r){let n="";if(zi(e)?(n=Il(e,this.sortedLabelNames),Ji(this.labelNames,e)):(r=e,e={}),r&&!Number.isFinite(r))throw new TypeError(`Value is not a valid number: ${Cl.format(r)}`);if(r<0)throw new Error("It is not possible to decrease a counter");return r==null&&(r=1),ji(this.hashMap,r,e,n),{labelHash:n}}incWithExemplar({labels:e=this.defaultLabels,value:r=this.defaultValue,exemplarLabels:n=this.defaultExemplarLabelSet}={}){let i=this.incWithoutExemplar(e,r);this.updateExemplar(n,r,i.labelHash)}updateExemplar(e,r,n){e!==this.defaultExemplarLabelSet&&(zi(this.hashMap[n].exemplar)||(this.hashMap[n].exemplar=new Ml),this.hashMap[n].exemplar.validateExemplarLabelSet(e),this.hashMap[n].exemplar.labelSet=e,this.hashMap[n].exemplar.value=r||1,this.hashMap[n].exemplar.timestamp=Pl())}reset(){this.hashMap={},this.labelNames.length===0&&ji(this.hashMap,0)}async get(){if(this.collect){let e=this.collect();e instanceof Promise&&await e}return{help:this.help,name:this.name,type:this.type,values:Object.values(this.hashMap),aggregator:this.aggregator}}labels(...e){let r=Gi(this.labelNames,e)||{};return{inc:this.inc.bind(this,r)}}remove(...e){let r=Gi(this.labelNames,e)||{};return Ji(this.labelNames,r),Al.call(this,this.hashMap,r,this.sortedLabelNames)}};function ji(t,e,r={},n=""){return t[n]?t[n].value+=e:t[n]={value:e,labels:r},t}$i.exports=vr});var q=v((Ch,Zi)=>{"use strict";var Qi=k("util"),{setValue:Yi,setValueDelta:kl,getLabels:Wi,hashObject:Xi,isObject:Ki,removeLabels:Ll}=Y(),{validateLabel:Nt}=pe(),{Metric:Dl}=je(),wr=class extends Dl{constructor(e){super(e),this.type="gauge"}set(e,r){r=Nr(e,r),e=Er(e),Bl(this,e,r)}reset(){this.hashMap={},this.labelNames.length===0&&Yi(this.hashMap,0,{})}inc(e,r){r=Nr(e,r),e=Er(e),r===void 0&&(r=1),Hi(this,e,r)}dec(e,r){r=Nr(e,r),e=Er(e),r===void 0&&(r=1),Hi(this,e,-r)}setToCurrentTime(e){let r=Date.now()/1e3;e===void 0?this.set(r):this.set(e,r)}startTimer(e){let r=process.hrtime();return n=>{let i=process.hrtime(r),s=i[0]+i[1]/1e9;return this.set(Object.assign({},e,n),s),s}}async get(){if(this.collect){let e=this.collect();e instanceof Promise&&await e}return{help:this.help,name:this.name,type:this.type,values:Object.values(this.hashMap),aggregator:this.aggregator}}_getValue(e){let r=Xi(e||{},this.sortedLabelNames);return this.hashMap[r]?this.hashMap[r].value:0}labels(...e){let r=Wi(this.labelNames,e);return Nt(this.labelNames,r),{inc:this.inc.bind(this,r),dec:this.dec.bind(this,r),set:this.set.bind(this,r),setToCurrentTime:this.setToCurrentTime.bind(this,r),startTimer:this.startTimer.bind(this,r)}}remove(...e){let r=Wi(this.labelNames,e);Nt(this.labelNames,r),Ll.call(this,this.hashMap,r,this.sortedLabelNames)}};function Bl(t,e,r){if(typeof r!="number")throw new TypeError(`Value is not a valid number: ${Qi.format(r)}`);Nt(t.labelNames,e),Yi(t.hashMap,r,e)}function Hi(t,e,r){if(typeof r!="number")throw new TypeError(`Delta is not a valid number: ${Qi.format(r)}`);Nt(t.labelNames,e);let n=Xi(e,t.sortedLabelNames);kl(t.hashMap,r,e,n)}function Er(t){return Ki(t)?t:{}}function Nr(t,e){return Ki(t)?e:t}Zi.exports=wr});var Ir=v((Ih,is)=>{"use strict";var ql=k("util"),{getLabels:es,hashObject:wt,isObject:rs,removeLabels:Ul,nowTimestamp:Vl}=Y(),{validateLabel:Tr}=pe(),{Metric:Fl}=je(),zl=yr(),xr=class extends Fl{constructor(e){super(e,{buckets:[.005,.01,.025,.05,.1,.25,.5,1,2.5,5,10]}),this.type="histogram",this.defaultLabels={},this.defaultExemplarLabelSet={},this.enableExemplars=!1;for(let r of this.labelNames)if(r==="le")throw new Error("le is a reserved label keyword");this.upperBounds=this.buckets,this.bucketValues=this.upperBounds.reduce((r,n)=>(r[n]=0,r),{}),e.enableExemplars?(this.enableExemplars=!0,this.bucketExemplars=this.upperBounds.reduce((r,n)=>(r[n]=null,r),{}),Object.freeze(this.bucketExemplars),this.observe=this.observeWithExemplar):this.observe=this.observeWithoutExemplar,Object.freeze(this.bucketValues),Object.freeze(this.upperBounds),this.labelNames.length===0&&(this.hashMap={[wt({})]:Cr({},this.bucketValues,this.bucketExemplars)})}observeWithoutExemplar(e,r){Or.call(this,e===0?0:e||{})(r)}observeWithExemplar({labels:e=this.defaultLabels,value:r,exemplarLabels:n=this.defaultExemplarLabelSet}={}){Or.call(this,e===0?0:e||{})(r),this.updateExemplar(e,r,n)}updateExemplar(e,r,n){if(Object.keys(n).length===0)return;let i=wt(e,this.sortedLabelNames),s=ns(this.upperBounds,r),{bucketExemplars:o}=this.hashMap[i],a=o[s];rs(a)||(a=new zl,o[s]=a),a.validateExemplarLabelSet(n),a.labelSet=n,a.value=r,a.timestamp=Vl()}async get(){let e=await this.getForPromString();return e.values=e.values.map(Wl),e}async getForPromString(){if(this.collect){let n=this.collect();n instanceof Promise&&await n}let r=Object.values(this.hashMap).map(jl(this)).reduce($l(this),[]);return{name:this.name,help:this.help,type:this.type,values:r,aggregator:this.aggregator}}reset(){this.hashMap={}}zero(e){let r=wt(e,this.sortedLabelNames);this.hashMap[r]=Cr(e,this.bucketValues,this.bucketExemplars)}startTimer(e,r){return this.enableExemplars?Gl.call(this,e,r)():ts.call(this,e)()}labels(...e){let r=es(this.labelNames,e);return Tr(this.labelNames,r),{observe:Or.call(this,r),startTimer:ts.call(this,r)}}remove(...e){let r=es(this.labelNames,e);Tr(this.labelNames,r),Ul.call(this,this.hashMap,r,this.sortedLabelNames)}};function ts(t){return()=>{let e=process.hrtime();return r=>{let n=process.hrtime(e),i=n[0]+n[1]/1e9;return this.observe(Object.assign({},t,r),i),i}}}function Gl(t,e){return()=>{let r=process.hrtime();return(n,i)=>{let s=process.hrtime(r),o=s[0]+s[1]/1e9;return this.observe({labels:Object.assign({},t,n),value:o,exemplarLabels:Object.assign({},e,i)}),o}}}function Ot(t,e,r,n,i={}){return{labels:t,sharedLabels:i,value:e,metricName:r,exemplar:n}}function ns(t,e){for(let r=0;r<t.length;r++){let n=t[r];if(e<=n)return n}return-1}function Or(t){return e=>{let r=Jl(t,e);if(Tr(this.labelNames,r.labels),!Number.isFinite(r.value))throw new TypeError(`Value is not a valid number: ${ql.format(r.value)}`);let n=wt(r.labels,this.sortedLabelNames),i=this.hashMap[n];i||(i=Cr(r.labels,this.bucketValues,this.bucketExemplars));let s=ns(this.upperBounds,r.value);i.sum+=r.value,i.count+=1,Object.prototype.hasOwnProperty.call(i.bucketValues,s)&&(i.bucketValues[s]+=1),this.hashMap[n]=i}}function Cr(t,e,r){let n={labels:t,bucketValues:{...e},sum:0,count:0};return r&&(n.bucketExemplars={...r}),n}function Jl(t,e){return rs(t)?{labels:t,value:e}:{value:t,labels:{}}}function jl(t){let e=`${t.name}_bucket`;return r=>{let n=0;return{buckets:t.upperBounds.map(s=>(n+=r.bucketValues[s],Ot({le:s},n,e,r.bucketExemplars?r.bucketExemplars[s]:null,r.labels))),data:r}}}function $l(t){return(e,r)=>{e.push(...r.buckets);let n={le:"+Inf"};return e.push(Ot(n,r.data.count,`${t.name}_bucket`,r.data.bucketExemplars?r.data.bucketExemplars[-1]:null,r.data.labels),Ot({},r.data.sum,`${t.name}_sum`,void 0,r.data.labels),Ot({},r.data.count,`${t.name}_count`,void 0,r.data.labels)),e}}function Wl(t){let{sharedLabels:e,labels:r,...n}=t;for(let i of Object.keys(e))r[i]=e[i];return n.labels=r,n}is.exports=xr});var Ar=v((Ah,ss)=>{function J(){}J.prototype.clear=function(){this._root=null,this.size=0};J.prototype.find=function(t){for(var e=this._root;e!==null;){var r=this._comparator(t,e.data);if(r===0)return e.data;e=e.get_child(r>0)}return null};J.prototype.findIter=function(t){for(var e=this._root,r=this.iterator();e!==null;){var n=this._comparator(t,e.data);if(n===0)return r._cursor=e,r;r._ancestors.push(e),e=e.get_child(n>0)}return null};J.prototype.lowerBound=function(t){for(var e=this._root,r=this.iterator(),n=this._comparator;e!==null;){var i=n(t,e.data);if(i===0)return r._cursor=e,r;r._ancestors.push(e),e=e.get_child(i>0)}for(var s=r._ancestors.length-1;s>=0;--s)if(e=r._ancestors[s],n(t,e.data)<0)return r._cursor=e,r._ancestors.length=s,r;return r._ancestors.length=0,r};J.prototype.upperBound=function(t){for(var e=this.lowerBound(t),r=this._comparator;e.data()!==null&&r(e.data(),t)===0;)e.next();return e};J.prototype.min=function(){var t=this._root;if(t===null)return null;for(;t.left!==null;)t=t.left;return t.data};J.prototype.max=function(){var t=this._root;if(t===null)return null;for(;t.right!==null;)t=t.right;return t.data};J.prototype.iterator=function(){return new Re(this)};J.prototype.each=function(t){for(var e=this.iterator(),r;(r=e.next())!==null;)if(t(r)===!1)return};J.prototype.reach=function(t){for(var e=this.iterator(),r;(r=e.prev())!==null;)if(t(r)===!1)return};function Re(t){this._tree=t,this._ancestors=[],this._cursor=null}Re.prototype.data=function(){return this._cursor!==null?this._cursor.data:null};Re.prototype.next=function(){if(this._cursor===null){var t=this._tree._root;t!==null&&this._minNode(t)}else if(this._cursor.right===null){var e;do if(e=this._cursor,this._ancestors.length)this._cursor=this._ancestors.pop();else{this._cursor=null;break}while(this._cursor.right===e)}else this._ancestors.push(this._cursor),this._minNode(this._cursor.right);return this._cursor!==null?this._cursor.data:null};Re.prototype.prev=function(){if(this._cursor===null){var t=this._tree._root;t!==null&&this._maxNode(t)}else if(this._cursor.left===null){var e;do if(e=this._cursor,this._ancestors.length)this._cursor=this._ancestors.pop();else{this._cursor=null;break}while(this._cursor.left===e)}else this._ancestors.push(this._cursor),this._maxNode(this._cursor.left);return this._cursor!==null?this._cursor.data:null};Re.prototype._minNode=function(t){for(;t.left!==null;)this._ancestors.push(t),t=t.left;this._cursor=t};Re.prototype._maxNode=function(t){for(;t.right!==null;)this._ancestors.push(t),t=t.right;this._cursor=t};ss.exports=J});var ls=v((Ph,as)=>{var Hl=Ar();function Me(t){this.data=t,this.left=null,this.right=null,this.red=!0}Me.prototype.get_child=function(t){return t?this.right:this.left};Me.prototype.set_child=function(t,e){t?this.right=e:this.left=e};function Tt(t){this._root=null,this._comparator=t,this.size=0}Tt.prototype=new Hl;Tt.prototype.insert=function(t){var e=!1;if(this._root===null)this._root=new Me(t),e=!0,this.size++;else{var r=new Me(void 0),n=0,i=0,s=null,o=r,a=null,l=this._root;for(o.right=this._root;;){if(l===null?(l=new Me(t),a.set_child(n,l),e=!0,this.size++):F(l.left)&&F(l.right)&&(l.red=!0,l.left.red=!1,l.right.red=!1),F(l)&&F(a)){var c=o.right===s;l===a.get_child(i)?o.set_child(c,$e(s,!i)):o.set_child(c,os(s,!i))}var u=this._comparator(l.data,t);if(u===0)break;i=n,n=u<0,s!==null&&(o=s),s=a,a=l,l=l.get_child(n)}this._root=r.right}return this._root.red=!1,e};Tt.prototype.remove=function(t){if(this._root===null)return!1;var e=new Me(void 0),r=e;r.right=this._root;for(var n=null,i=null,s=null,o=1;r.get_child(o)!==null;){var a=o;i=n,n=r,r=r.get_child(o);var l=this._comparator(t,r.data);if(o=l>0,l===0&&(s=r),!F(r)&&!F(r.get_child(o))){if(F(r.get_child(!o))){var c=$e(r,o);n.set_child(a,c),n=c}else if(!F(r.get_child(!o))){var u=n.get_child(!a);if(u!==null)if(!F(u.get_child(!a))&&!F(u.get_child(a)))n.red=!1,u.red=!0,r.red=!0;else{var f=i.right===n;F(u.get_child(a))?i.set_child(f,os(n,a)):F(u.get_child(!a))&&i.set_child(f,$e(n,a));var h=i.get_child(f);h.red=!0,r.red=!0,h.left.red=!1,h.right.red=!1}}}}return s!==null&&(s.data=r.data,n.set_child(n.right===r,r.get_child(r.left===null)),this.size--),this._root=e.right,this._root!==null&&(this._root.red=!1),s!==null};function F(t){return t!==null&&t.red}function $e(t,e){var r=t.get_child(!e);return t.set_child(!e,r.get_child(e)),r.set_child(e,t),t.red=!0,r.red=!1,r}function os(t,e){return t.set_child(!e,$e(t.get_child(!e),!e)),$e(t,e)}as.exports=Tt});var us=v((Rh,cs)=>{var Ql=Ar();function We(t){this.data=t,this.left=null,this.right=null}We.prototype.get_child=function(t){return t?this.right:this.left};We.prototype.set_child=function(t,e){t?this.right=e:this.left=e};function xt(t){this._root=null,this._comparator=t,this.size=0}xt.prototype=new Ql;xt.prototype.insert=function(t){if(this._root===null)return this._root=new We(t),this.size++,!0;for(var e=0,r=null,n=this._root;;){if(n===null)return n=new We(t),r.set_child(e,n),ret=!0,this.size++,!0;if(this._comparator(n.data,t)===0)return!1;e=this._comparator(n.data,t)<0,r=n,n=n.get_child(e)}};xt.prototype.remove=function(t){if(this._root===null)return!1;var e=new We(void 0),r=e;r.right=this._root;for(var n=null,i=null,s=1;r.get_child(s)!==null;){n=r,r=r.get_child(s);var o=this._comparator(t,r.data);s=o>0,o===0&&(i=r)}return i!==null?(i.data=r.data,n.set_child(n.right===r,r.get_child(r.left===null)),this._root=e.right,this.size--,!0):!1};cs.exports=xt});var hs=v((Mh,fs)=>{fs.exports={RBTree:ls(),BinTree:us()}});var ms=v((kh,ps)=>{var Yl=hs().RBTree;function P(t,e,r){this.discrete=t===!1,this.delta=t||.01,this.K=e===void 0?25:e,this.CX=r===void 0?1.1:r,this.centroids=new Yl(ds),this.nreset=0,this.reset()}P.prototype.reset=function(){this.centroids.clear(),this.n=0,this.nreset+=1,this.last_cumulate=0};P.prototype.size=function(){return this.centroids.size};P.prototype.toArray=function(t){var e=[];return t?(this._cumulate(!0),this.centroids.each(function(r){e.push(r)})):this.centroids.each(function(r){e.push({mean:r.mean,n:r.n})}),e};P.prototype.summary=function(){var t=this.discrete?"exact ":"approximating ",e=[t+this.n+" samples using "+this.size()+" centroids","min = "+this.percentile(0),"Q1 = "+this.percentile(.25),"Q2 = "+this.percentile(.5),"Q3 = "+this.percentile(.75),"max = "+this.percentile(1)];return e.join(`
|
|
10
|
+
`)};function ds(t,e){return t.mean>e.mean?1:t.mean<e.mean?-1:0}function Xl(t,e){return t.mean_cumn-e.mean_cumn}P.prototype.push=function(t,e){e=e||1,t=Array.isArray(t)?t:[t];for(var r=0;r<t.length;r++)this._digest(t[r],e)};P.prototype.push_centroid=function(t){t=Array.isArray(t)?t:[t];for(var e=0;e<t.length;e++)this._digest(t[e].mean,t[e].n)};P.prototype._cumulate=function(t){if(!(this.n===this.last_cumulate||!t&&this.CX&&this.CX>this.n/this.last_cumulate)){var e=0;this.centroids.each(function(r){r.mean_cumn=e+r.n/2,e=r.cumn=e+r.n}),this.n=this.last_cumulate=e}};P.prototype.find_nearest=function(t){if(this.size()===0)return null;var e=this.centroids.lowerBound({mean:t}),r=e.data()===null?e.prev():e.data();if(r.mean===t||this.discrete)return r;var n=e.prev();return n&&Math.abs(n.mean-t)<Math.abs(r.mean-t)?n:r};P.prototype._new_centroid=function(t,e,r){var n={mean:t,n:e,cumn:r};return this.centroids.insert(n),this.n+=e,n};P.prototype._addweight=function(t,e,r){e!==t.mean&&(t.mean+=r*(e-t.mean)/(t.n+r)),t.cumn+=r,t.mean_cumn+=r/2,t.n+=r,this.n+=r};P.prototype._digest=function(t,e){var r=this.centroids.min(),n=this.centroids.max(),i=this.find_nearest(t);if(i&&i.mean===t)this._addweight(i,t,e);else if(i===r)this._new_centroid(t,e,0);else if(i===n)this._new_centroid(t,e,this.n);else if(this.discrete)this._new_centroid(t,e,i.cumn);else{var s=i.mean_cumn/this.n,o=Math.floor(4*this.n*this.delta*s*(1-s));o-i.n>=e?this._addweight(i,t,e):this._new_centroid(t,e,i.cumn)}this._cumulate(!1),!this.discrete&&this.K&&this.size()>this.K/this.delta&&this.compress()};P.prototype.bound_mean=function(t){var e=this.centroids.upperBound({mean:t}),r=e.prev(),n=r.mean===t?r:e.next();return[r,n]};P.prototype.p_rank=function(t){var e=Array.isArray(t)?t:[t],r=e.map(this._p_rank,this);return Array.isArray(t)?r:r[0]};P.prototype._p_rank=function(t){if(this.size()!==0){{if(t<this.centroids.min().mean)return 0;if(t>this.centroids.max().mean)return 1}this._cumulate(!0);var e=this.bound_mean(t),r=e[0],n=e[1];if(this.discrete)return r.cumn/this.n;var i=r.mean_cumn;return r!==n&&(i+=(t-r.mean)*(n.mean_cumn-r.mean_cumn)/(n.mean-r.mean)),i/this.n}};P.prototype.bound_mean_cumn=function(t){this.centroids._comparator=Xl;var e=this.centroids.upperBound({mean_cumn:t});this.centroids._comparator=ds;var r=e.prev(),n=r&&r.mean_cumn===t?r:e.next();return[r,n]};P.prototype.percentile=function(t){var e=Array.isArray(t)?t:[t],r=e.map(this._percentile,this);return Array.isArray(t)?r:r[0]};P.prototype._percentile=function(t){if(this.size()!==0){this._cumulate(!0);var e=this.n*t,r=this.bound_mean_cumn(e),n=r[0],i=r[1];return i===n||n===null||i===null?(n||i).mean:this.discrete?e<=n.cumn?n.mean:i.mean:n.mean+(e-n.mean_cumn)*(i.mean-n.mean)/(i.mean_cumn-n.mean_cumn)}};function Kl(t){var e=Math.floor(Math.random()*t.length);return t.splice(e,1)[0]}P.prototype.compress=function(){if(!this.compressing){var t=this.toArray();for(this.reset(),this.compressing=!0;t.length>0;)this.push_centroid(Kl(t));this._cumulate(!0),this.compressing=!1}};function ae(t){this.config=t||{},this.mode=this.config.mode||"auto",P.call(this,this.mode==="cont"?t.delta:!1),this.digest_ratio=this.config.ratio||.9,this.digest_thresh=this.config.thresh||1e3,this.n_unique=0}ae.prototype=Object.create(P.prototype);ae.prototype.constructor=ae;ae.prototype.push=function(t){P.prototype.push.call(this,t),this.check_continuous()};ae.prototype._new_centroid=function(t,e,r){this.n_unique+=1,P.prototype._new_centroid.call(this,t,e,r)};ae.prototype._addweight=function(t,e,r){t.n===1&&(this.n_unique-=1),P.prototype._addweight.call(this,t,e,r)};ae.prototype.check_continuous=function(){return this.mode!=="auto"||this.size()<this.digest_thresh?!1:this.n_unique/this.size()>this.digest_ratio?(this.mode="cont",this.discrete=!1,this.delta=this.config.delta||.01,this.compress(),!0):!1};ps.exports={TDigest:P,Digest:ae}});var bs=v((Lh,gs)=>{"use strict";var{TDigest:_s}=ms(),Rr=class{constructor(e,r){this.maxAgeSeconds=e||0,this.ageBuckets=r||0,this.shouldRotate=e&&r,this.ringBuffer=Array(r).fill(new _s),this.currentBuffer=0,this.lastRotateTimestampMillis=Date.now(),this.durationBetweenRotatesMillis=e*1e3/r||1/0}size(){return Pr.call(this).size()}percentile(e){return Pr.call(this).percentile(e)}push(e){Pr.call(this),this.ringBuffer.forEach(r=>{r.push(e)})}reset(){this.ringBuffer.forEach(e=>{e.reset()})}compress(){this.ringBuffer.forEach(e=>{e.compress()})}};function Pr(){let t=Date.now()-this.lastRotateTimestampMillis;for(;t>this.durationBetweenRotatesMillis&&this.shouldRotate;)this.ringBuffer[this.currentBuffer]=new _s,++this.currentBuffer>=this.ringBuffer.length&&(this.currentBuffer=0),t-=this.durationBetweenRotatesMillis,this.lastRotateTimestampMillis+=this.durationBetweenRotatesMillis;return this.ringBuffer[this.currentBuffer]}gs.exports=Rr});var Os=v((Dh,ws)=>{"use strict";var Zl=k("util"),{getLabels:ys,hashObject:Es,removeLabels:ec}=Y(),{validateLabel:Mr}=pe(),{Metric:tc}=je(),Ns=bs(),rc=1e3,kr=class extends tc{constructor(e){super(e,{percentiles:[.01,.05,.5,.9,.95,.99,.999],compressCount:rc,hashMap:{}}),this.type="summary";for(let r of this.labelNames)if(r==="quantile")throw new Error("quantile is a reserved label keyword");this.labelNames.length===0&&(this.hashMap={[Es({})]:{labels:{},td:new Ns(this.maxAgeSeconds,this.ageBuckets),count:0,sum:0}})}observe(e,r){Ss.call(this,e===0?0:e||{})(r)}async get(){if(this.collect){let n=this.collect();n instanceof Promise&&await n}let e=Object.keys(this.hashMap),r=[];return e.forEach(n=>{let i=this.hashMap[n];i&&(this.pruneAgedBuckets&&i.td.size()===0?delete this.hashMap[n]:(nc(i,this.percentiles).forEach(s=>{r.push(s)}),r.push(sc(i,this)),r.push(ic(i,this))))}),{name:this.name,help:this.help,type:this.type,values:r,aggregator:this.aggregator}}reset(){Object.values(this.hashMap).forEach(r=>{r.td.reset(),r.count=0,r.sum=0})}startTimer(e){return vs.call(this,e)()}labels(...e){let r=ys(this.labelNames,e);return Mr(this.labelNames,r),{observe:Ss.call(this,r),startTimer:vs.call(this,r)}}remove(...e){let r=ys(this.labelNames,e);Mr(this.labelNames,r),ec.call(this,this.hashMap,r,this.sortedLabelNames)}};function nc(t,e){return t.td.compress(),e.map(r=>{let n=t.td.percentile(r);return{labels:Object.assign({quantile:r},t.labels),value:n||0}})}function ic(t,e){return{metricName:`${e.name}_count`,labels:t.labels,value:t.count}}function sc(t,e){return{metricName:`${e.name}_sum`,labels:t.labels,value:t.sum}}function vs(t){return()=>{let e=process.hrtime();return r=>{let n=process.hrtime(e),i=n[0]+n[1]/1e9;return this.observe(Object.assign({},t,r),i),i}}}function Ss(t){return e=>{let r=oc(t,e);if(Mr(this.labelNames,t),!Number.isFinite(r.value))throw new TypeError(`Value is not a valid number: ${Zl.format(r.value)}`);let n=Es(r.labels,this.sortedLabelNames),i=this.hashMap[n];i||(i={labels:r.labels,td:new Ns(this.maxAgeSeconds,this.ageBuckets),count:0,sum:0}),i.td.push(r.value),i.count++,i.count%this.compressCount===0&&i.td.compress(),i.sum+=r.value,this.hashMap[n]=i}}function oc(t,e){return e===void 0?{value:t,labels:{}}:{labels:t,value:e}}ws.exports=kr});var xs=v((Bh,Ts)=>{"use strict";var Lr=k("url"),ac=k("http"),lc=k("https"),{gzipSync:cc}=k("zlib"),{globalRegistry:uc}=Pe(),Br=class{constructor(e,r,n){n||(n=uc),this.registry=n,this.gatewayUrl=e;let{requireJobName:i,...s}={requireJobName:!0,...r};this.requireJobName=i,this.requestOptions=s}pushAdd(e={}){if(this.requireJobName&&!e.jobName)throw new Error("Missing jobName parameter");return Dr.call(this,"POST",e.jobName,e.groupings)}push(e={}){if(this.requireJobName&&!e.jobName)throw new Error("Missing jobName parameter");return Dr.call(this,"PUT",e.jobName,e.groupings)}delete(e={}){if(this.requireJobName&&!e.jobName)throw new Error("Missing jobName parameter");return Dr.call(this,"DELETE",e.jobName,e.groupings)}};async function Dr(t,e,r){let n=Lr.parse(this.gatewayUrl),i=n.pathname&&n.pathname!=="/"?n.pathname:"",s=e?`/job/${encodeURIComponent(e)}${fc(r)}`:"",o=`${i}/metrics${s}`,a=Lr.resolve(this.gatewayUrl,o),l=Lr.parse(a),c=hc(l.href)?lc:ac,u=Object.assign(l,this.requestOptions,{method:t});return new Promise((f,h)=>{t==="DELETE"&&u.headers&&delete u.headers["Content-Encoding"];let p=c.request(u,b=>{let d="";b.setEncoding("utf8"),b.on("data",C=>{d+=C}),b.on("end",()=>{b.statusCode>=400?h(new Error(`push failed with status ${b.statusCode}, ${d}`)):f({resp:b,body:d})})});p.on("error",b=>{h(b)}),p.on("timeout",()=>{p.destroy(new Error("Pushgateway request timed out"))}),t!=="DELETE"?this.registry.metrics().then(b=>{u.headers&&u.headers["Content-Encoding"]==="gzip"&&(b=cc(b)),p.write(b),p.end()}).catch(b=>{h(b)}):p.end()})}function fc(t){return t?Object.keys(t).map(e=>`/${encodeURIComponent(e)}/${encodeURIComponent(t[e])}`).join(""):""}function hc(t){return t.search(/^https/)!==-1}Ts.exports=Br});var Ur=v(qr=>{"use strict";qr.linearBuckets=(t,e,r)=>{if(r<1)throw new Error("Linear buckets needs a positive count");let n=new Array(r);for(let i=0;i<r;i++)n[i]=t+i*e;return n};qr.exponentialBuckets=(t,e,r)=>{if(t<=0)throw new Error("Exponential buckets needs a positive start");if(r<1)throw new Error("Exponential buckets needs a positive count");if(e<=1)throw new Error("Exponential buckets needs a factor greater than 1");let n=new Array(r);for(let i=0;i<r;i++)n[i]=t,t*=e;return n}});var Cs,Is=_(()=>{Cs=typeof globalThis=="object"?globalThis:global});var As=_(()=>{Is()});var Ps=_(()=>{As()});var re,Vr=_(()=>{re="1.9.0"});function dc(t){var e=new Set([t]),r=new Set,n=t.match(Rs);if(!n)return function(){return!1};var i={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(i.prerelease!=null)return function(l){return l===t};function s(a){return r.add(a),!1}function o(a){return e.add(a),!0}return function(l){if(e.has(l))return!0;if(r.has(l))return!1;var c=l.match(Rs);if(!c)return s(l);var u={major:+c[1],minor:+c[2],patch:+c[3],prerelease:c[4]};return u.prerelease!=null||i.major!==u.major?s(l):i.major===0?i.minor===u.minor&&i.patch<=u.patch?o(l):s(l):i.minor<=u.minor?o(l):s(l)}}var Rs,Ms,ks=_(()=>{Vr();Rs=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;Ms=dc(re)});function X(t,e,r,n){var i;n===void 0&&(n=!1);var s=Qe[He]=(i=Qe[He])!==null&&i!==void 0?i:{version:re};if(!n&&s[t]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(o.stack||o.message),!1}if(s.version!==re){var o=new Error("@opentelemetry/api: Registration of version v"+s.version+" for "+t+" does not match previously registered API v"+re);return r.error(o.stack||o.message),!1}return s[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+re+"."),!0}function V(t){var e,r,n=(e=Qe[He])===null||e===void 0?void 0:e.version;if(!(!n||!Ms(n)))return(r=Qe[He])===null||r===void 0?void 0:r[t]}function K(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+re+".");var r=Qe[He];r&&delete r[t]}var pc,He,Qe,me=_(()=>{Ps();Vr();ks();pc=re.split(".")[0],He=Symbol.for("opentelemetry.js.api."+pc),Qe=Cs});function Ye(t,e,r){var n=V("diag");if(n)return r.unshift(e),n[t].apply(n,_c([],mc(r),!1))}var mc,_c,Ls,Ds=_(()=>{me();mc=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},_c=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},Ls=function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Ye("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Ye("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Ye("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Ye("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Ye("verbose",this._namespace,e)},t}()});var L,Ct=_(()=>{(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(L||(L={}))});function Bs(t,e){t<L.NONE?t=L.NONE:t>L.ALL&&(t=L.ALL),e=e||{};function r(n,i){var s=e[n];return typeof s=="function"&&t>=i?s.bind(e):function(){}}return{error:r("error",L.ERROR),warn:r("warn",L.WARN),info:r("info",L.INFO),debug:r("debug",L.DEBUG),verbose:r("verbose",L.VERBOSE)}}var qs=_(()=>{Ct()});var gc,bc,yc,B,_e=_(()=>{Ds();qs();Ct();me();gc=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},bc=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},yc="diag",B=function(){function t(){function e(i){return function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];var a=V("diag");if(a)return a[i].apply(a,bc([],gc(s),!1))}}var r=this,n=function(i,s){var o,a,l;if(s===void 0&&(s={logLevel:L.INFO}),i===r){var c=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((o=c.stack)!==null&&o!==void 0?o:c.message),!1}typeof s=="number"&&(s={logLevel:s});var u=V("diag"),f=Bs((a=s.logLevel)!==null&&a!==void 0?a:L.INFO,i);if(u&&!s.suppressOverrideMessage){var h=(l=new Error().stack)!==null&&l!==void 0?l:"<failed to generate stacktrace>";u.warn("Current logger will be overwritten from "+h),f.warn("Current logger will overwrite one already registered from "+h)}return X("diag",f,r,!0)};r.setLogger=n,r.disable=function(){K(yc,r)},r.createComponentLogger=function(i){return new Ls(i)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t}()});var vc,Sc,Us,Vs=_(()=>{vc=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},Sc=function(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Us=function(){function t(e){this._entries=e?new Map(e):new Map}return t.prototype.getEntry=function(e){var r=this._entries.get(e);if(r)return Object.assign({},r)},t.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var r=vc(e,2),n=r[0],i=r[1];return[n,i]})},t.prototype.setEntry=function(e,r){var n=new t(this._entries);return n._entries.set(e,r),n},t.prototype.removeEntry=function(e){var r=new t(this._entries);return r._entries.delete(e),r},t.prototype.removeEntries=function(){for(var e,r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var s=new t(this._entries);try{for(var o=Sc(n),a=o.next();!a.done;a=o.next()){var l=a.value;s._entries.delete(l)}}catch(c){e={error:c}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return s},t.prototype.clear=function(){return new t},t}()});var Fs,zs=_(()=>{Fs=Symbol("BaggageEntryMetadata")});function Gs(t){return t===void 0&&(t={}),new Us(new Map(Object.entries(t)))}function Js(t){return typeof t!="string"&&(Ec.error("Cannot create baggage metadata from unknown type: "+typeof t),t=""),{__TYPE__:Fs,toString:function(){return t}}}var Ec,Fr=_(()=>{_e();Vs();zs();Ec=B.instance()});function ke(t){return Symbol.for(t)}var Nc,It,Xe=_(()=>{Nc=function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,i){var s=new t(r._currentContext);return s._currentContext.set(n,i),s},r.deleteValue=function(n){var i=new t(r._currentContext);return i._currentContext.delete(n),i}}return t}(),It=new Nc});var zr,js,$s=_(()=>{zr=[{n:"error",c:"error"},{n:"warn",c:"warn"},{n:"info",c:"info"},{n:"debug",c:"debug"},{n:"verbose",c:"trace"}],js=function(){function t(){function e(n){return function(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];if(console){var o=console[n];if(typeof o!="function"&&(o=console.log),typeof o=="function")return o.apply(console,i)}}}for(var r=0;r<zr.length;r++)this[zr[r].n]=e(zr[r].c)}return t}()});function Ws(){return Jr}var ge,wc,At,Oc,Tc,xc,Cc,Gr,Ic,Ac,Pc,Jr,Rc,Mc,kc,Lc,Dc,Bc,qc,jr=_(()=>{ge=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},t(e,r)};return function(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),wc=function(){function t(){}return t.prototype.createGauge=function(e,r){return Mc},t.prototype.createHistogram=function(e,r){return kc},t.prototype.createCounter=function(e,r){return Rc},t.prototype.createUpDownCounter=function(e,r){return Lc},t.prototype.createObservableGauge=function(e,r){return Bc},t.prototype.createObservableCounter=function(e,r){return Dc},t.prototype.createObservableUpDownCounter=function(e,r){return qc},t.prototype.addBatchObservableCallback=function(e,r){},t.prototype.removeBatchObservableCallback=function(e){},t}(),At=function(){function t(){}return t}(),Oc=function(t){ge(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.add=function(r,n){},e}(At),Tc=function(t){ge(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.add=function(r,n){},e}(At),xc=function(t){ge(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.record=function(r,n){},e}(At),Cc=function(t){ge(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.record=function(r,n){},e}(At),Gr=function(){function t(){}return t.prototype.addCallback=function(e){},t.prototype.removeCallback=function(e){},t}(),Ic=function(t){ge(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Gr),Ac=function(t){ge(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Gr),Pc=function(t){ge(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e}(Gr),Jr=new wc,Rc=new Oc,Mc=new xc,kc=new Cc,Lc=new Tc,Dc=new Ic,Bc=new Ac,qc=new Pc});var Pt,Hs=_(()=>{(function(t){t[t.INT=0]="INT",t[t.DOUBLE=1]="DOUBLE"})(Pt||(Pt={}))});var Rt,Mt,$r=_(()=>{Rt={get:function(t,e){if(t!=null)return t[e]},keys:function(t){return t==null?[]:Object.keys(t)}},Mt={set:function(t,e,r){t!=null&&(t[e]=r)}}});var Uc,Vc,Qs,Ys=_(()=>{Xe();Uc=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},Vc=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},Qs=function(){function t(){}return t.prototype.active=function(){return It},t.prototype.with=function(e,r,n){for(var i=[],s=3;s<arguments.length;s++)i[s-3]=arguments[s];return r.call.apply(r,Vc([n],Uc(i),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t}()});var Fc,zc,Wr,Gc,le,Ke=_(()=>{Ys();me();_e();Fc=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s},zc=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},Wr="context",Gc=new Qs,le=function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return X(Wr,e,B.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var i,s=[],o=3;o<arguments.length;o++)s[o-3]=arguments[o];return(i=this._getContextManager()).with.apply(i,zc([e,r,n],Fc(s),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return V(Wr)||Gc},t.prototype.disable=function(){this._getContextManager().disable(),K(Wr,B.instance())},t}()});var Le,Hr=_(()=>{(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(Le||(Le={}))});var Ze,et,kt,Lt=_(()=>{Hr();Ze="0000000000000000",et="00000000000000000000000000000000",kt={traceId:et,spanId:Ze,traceFlags:Le.NONE}});var ce,Dt=_(()=>{Lt();ce=function(){function t(e){e===void 0&&(e=kt),this._spanContext=e}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(e,r){return this},t.prototype.setAttributes=function(e){return this},t.prototype.addEvent=function(e,r){return this},t.prototype.addLink=function(e){return this},t.prototype.addLinks=function(e){return this},t.prototype.setStatus=function(e){return this},t.prototype.updateName=function(e){return this},t.prototype.end=function(e){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(e,r){},t}()});function Bt(t){return t.getValue(Qr)||void 0}function Xs(){return Bt(le.getInstance().active())}function tt(t,e){return t.setValue(Qr,e)}function Ks(t){return t.deleteValue(Qr)}function Zs(t,e){return tt(t,new ce(e))}function qt(t){var e;return(e=Bt(t))===null||e===void 0?void 0:e.spanContext()}var Qr,Yr=_(()=>{Xe();Dt();Ke();Qr=ke("OpenTelemetry Context Key SPAN")});function Xr(t){return Jc.test(t)&&t!==et}function Kr(t){return jc.test(t)&&t!==Ze}function De(t){return Xr(t.traceId)&&Kr(t.spanId)}function eo(t){return new ce(t)}var Jc,jc,Ut=_(()=>{Lt();Dt();Jc=/^([0-9a-f]{32})$/i,jc=/^[0-9a-f]{16}$/i});function $c(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var Zr,Vt,en=_(()=>{Ke();Yr();Dt();Ut();Zr=le.getInstance(),Vt=function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=Zr.active());var i=!!r?.root;if(i)return new ce;var s=n&&qt(n);return $c(s)&&De(s)?new ce(s):new ce},t.prototype.startActiveSpan=function(e,r,n,i){var s,o,a;if(!(arguments.length<2)){arguments.length===2?a=r:arguments.length===3?(s=r,a=n):(s=r,o=n,a=i);var l=o??Zr.active(),c=this.startSpan(e,s,l),u=tt(l,c);return Zr.with(u,a,void 0,c)}},t}()});var Wc,Ft,tn=_(()=>{en();Wc=new Vt,Ft=function(){function t(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}return t.prototype.startSpan=function(e,r,n){return this._getTracer().startSpan(e,r,n)},t.prototype.startActiveSpan=function(e,r,n,i){var s=this._getTracer();return Reflect.apply(s.startActiveSpan,s,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):Wc},t}()});var to,ro=_(()=>{en();to=function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new Vt},t}()});var Hc,rt,rn=_(()=>{tn();ro();Hc=new to,rt=function(){function t(){}return t.prototype.getTracer=function(e,r,n){var i;return(i=this.getDelegateTracer(e,r,n))!==null&&i!==void 0?i:new Ft(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Hc},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateTracer=function(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getTracer(e,r,n)},t}()});var zt,no=_(()=>{(function(t){t[t.NOT_RECORD=0]="NOT_RECORD",t[t.RECORD=1]="RECORD",t[t.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"})(zt||(zt={}))});var Gt,io=_(()=>{(function(t){t[t.INTERNAL=0]="INTERNAL",t[t.SERVER=1]="SERVER",t[t.CLIENT=2]="CLIENT",t[t.PRODUCER=3]="PRODUCER",t[t.CONSUMER=4]="CONSUMER"})(Gt||(Gt={}))});var Jt,so=_(()=>{(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(Jt||(Jt={}))});function oo(t){return Xc.test(t)}function ao(t){return Kc.test(t)&&!Zc.test(t)}var nn,Qc,Yc,Xc,Kc,Zc,lo=_(()=>{nn="[_0-9a-z-*/]",Qc="[a-z]"+nn+"{0,255}",Yc="[a-z0-9]"+nn+"{0,240}@[a-z]"+nn+"{0,13}",Xc=new RegExp("^(?:"+Qc+"|"+Yc+")$"),Kc=/^[ -~]{0,255}[!-~]$/,Zc=/,|=/});var co,eu,uo,fo,ho,po=_(()=>{lo();co=32,eu=512,uo=",",fo="=",ho=function(){function t(e){this._internalState=new Map,e&&this._parse(e)}return t.prototype.set=function(e,r){var n=this._clone();return n._internalState.has(e)&&n._internalState.delete(e),n._internalState.set(e,r),n},t.prototype.unset=function(e){var r=this._clone();return r._internalState.delete(e),r},t.prototype.get=function(e){return this._internalState.get(e)},t.prototype.serialize=function(){var e=this;return this._keys().reduce(function(r,n){return r.push(n+fo+e.get(n)),r},[]).join(uo)},t.prototype._parse=function(e){e.length>eu||(this._internalState=e.split(uo).reverse().reduce(function(r,n){var i=n.trim(),s=i.indexOf(fo);if(s!==-1){var o=i.slice(0,s),a=i.slice(s+1,n.length);oo(o)&&ao(a)&&r.set(o,a)}return r},new Map),this._internalState.size>co&&(this._internalState=new Map(Array.from(this._internalState.entries()).reverse().slice(0,co))))},t.prototype._keys=function(){return Array.from(this._internalState.keys()).reverse()},t.prototype._clone=function(){var e=new t;return e._internalState=new Map(this._internalState),e},t}()});function mo(t){return new ho(t)}var _o=_(()=>{po()});var sn,go=_(()=>{Ke();sn=le.getInstance()});var on,bo=_(()=>{_e();on=B.instance()});var tu,yo,vo=_(()=>{jr();tu=function(){function t(){}return t.prototype.getMeter=function(e,r,n){return Jr},t}(),yo=new tu});var an,So,Eo=_(()=>{vo();me();_e();an="metrics",So=function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalMeterProvider=function(e){return X(an,e,B.instance())},t.prototype.getMeterProvider=function(){return V(an)||yo},t.prototype.getMeter=function(e,r,n){return this.getMeterProvider().getMeter(e,r,n)},t.prototype.disable=function(){K(an,B.instance())},t}()});var ln,No=_(()=>{Eo();ln=So.getInstance()});var wo,Oo=_(()=>{wo=function(){function t(){}return t.prototype.inject=function(e,r){},t.prototype.extract=function(e,r){return e},t.prototype.fields=function(){return[]},t}()});function un(t){return t.getValue(cn)||void 0}function To(){return un(le.getInstance().active())}function xo(t,e){return t.setValue(cn,e)}function Co(t){return t.deleteValue(cn)}var cn,Io=_(()=>{Ke();Xe();cn=ke("OpenTelemetry Baggage Key")});var fn,ru,Ao,Po=_(()=>{me();Oo();$r();Io();Fr();_e();fn="propagation",ru=new wo,Ao=function(){function t(){this.createBaggage=Gs,this.getBaggage=un,this.getActiveBaggage=To,this.setBaggage=xo,this.deleteBaggage=Co}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalPropagator=function(e){return X(fn,e,B.instance())},t.prototype.inject=function(e,r,n){return n===void 0&&(n=Mt),this._getGlobalPropagator().inject(e,r,n)},t.prototype.extract=function(e,r,n){return n===void 0&&(n=Rt),this._getGlobalPropagator().extract(e,r,n)},t.prototype.fields=function(){return this._getGlobalPropagator().fields()},t.prototype.disable=function(){K(fn,B.instance())},t.prototype._getGlobalPropagator=function(){return V(fn)||ru},t}()});var hn,Ro=_(()=>{Po();hn=Ao.getInstance()});var dn,Mo,ko=_(()=>{me();rn();Ut();Yr();_e();dn="trace",Mo=function(){function t(){this._proxyTracerProvider=new rt,this.wrapSpanContext=eo,this.isSpanContextValid=De,this.deleteSpan=Ks,this.getSpan=Bt,this.getActiveSpan=Xs,this.getSpanContext=qt,this.setSpan=tt,this.setSpanContext=Zs}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=X(dn,this._proxyTracerProvider,B.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return V(dn)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){K(dn,B.instance()),this._proxyTracerProvider=new rt},t}()});var pn,Lo=_(()=>{ko();pn=Mo.getInstance()});var Do={};Gn(Do,{DiagConsoleLogger:()=>js,DiagLogLevel:()=>L,INVALID_SPANID:()=>Ze,INVALID_SPAN_CONTEXT:()=>kt,INVALID_TRACEID:()=>et,ProxyTracer:()=>Ft,ProxyTracerProvider:()=>rt,ROOT_CONTEXT:()=>It,SamplingDecision:()=>zt,SpanKind:()=>Gt,SpanStatusCode:()=>Jt,TraceFlags:()=>Le,ValueType:()=>Pt,baggageEntryMetadataFromString:()=>Js,context:()=>sn,createContextKey:()=>ke,createNoopMeter:()=>Ws,createTraceState:()=>mo,default:()=>nu,defaultTextMapGetter:()=>Rt,defaultTextMapSetter:()=>Mt,diag:()=>on,isSpanContextValid:()=>De,isValidSpanId:()=>Kr,isValidTraceId:()=>Xr,metrics:()=>ln,propagation:()=>hn,trace:()=>pn});var nu,Bo=_(()=>{Fr();Xe();$s();Ct();jr();Hs();$r();tn();rn();no();io();so();Hr();_o();Ut();Lt();go();bo();No();Ro();Lo();nu={context:sn,diag:on,metrics:ln,propagation:hn,trace:pn}});var zo=v((rm,_n)=>{"use strict";var qo=(Bo(),ht(Do)),mn=Sr(),Uo="process_cpu_user_seconds_total",Vo="process_cpu_system_seconds_total",Fo="process_cpu_seconds_total";_n.exports=(t,e={})=>{let r=t?[t]:void 0,n=e.prefix?e.prefix:"",i=e.labels?e.labels:{},s=e.enableExemplars?e.enableExemplars:!1,o=Object.keys(i),a=process.cpuUsage(),l=new mn({name:n+Uo,help:"Total user CPU time spent in seconds.",enableExemplars:s,registers:r,labelNames:o,collect(){let f=process.cpuUsage(),h=f.user-a.user,p=f.system-a.system;if(a=f,this.enableExemplars){let b={},d=qo.trace.getSpan(qo.context.active());d&&(b={traceId:d.spanContext().traceId,spanId:d.spanContext().spanId}),l.inc({labels:i,value:h/1e6,exemplarLabels:b}),c.inc({labels:i,value:p/1e6,exemplarLabels:b}),u.inc({labels:i,value:(h+p)/1e6,exemplarLabels:b})}else l.inc(i,h/1e6),c.inc(i,p/1e6),u.inc(i,(h+p)/1e6)}}),c=new mn({name:n+Vo,help:"Total system CPU time spent in seconds.",enableExemplars:s,registers:r,labelNames:o}),u=new mn({name:n+Fo,help:"Total user and system CPU time spent in seconds.",enableExemplars:s,registers:r,labelNames:o})};_n.exports.metricNames=[Uo,Vo,Fo]});var Jo=v((nm,gn)=>{"use strict";var iu=q(),su=Math.round(Date.now()/1e3-process.uptime()),Go="process_start_time_seconds";gn.exports=(t,e={})=>{let r=e.prefix?e.prefix:"",n=e.labels?e.labels:{},i=Object.keys(n);new iu({name:r+Go,help:"Start time of the process since unix epoch in seconds.",registers:t?[t]:void 0,labelNames:i,aggregator:"omit",collect(){this.set(n,su)}})};gn.exports.metricNames=[Go]});var Ho=v((im,yn)=>{"use strict";var bn=q(),ou=k("fs"),au=["VmSize","VmRSS","VmData"],jo="process_resident_memory_bytes",$o="process_virtual_memory_bytes",Wo="process_heap_bytes";function lu(t){return t.split(`
|
|
11
|
+
`).reduce((e,r)=>{if(!au.some(s=>r.startsWith(s)))return e;let n=r.split(":"),i=n[1].trim();return i=i.substr(0,i.length-3),i=Number(i)*1024,e[n[0]]=i,e},{})}yn.exports=(t,e={})=>{let r=t?[t]:void 0,n=e.prefix?e.prefix:"",i=e.labels?e.labels:{},s=Object.keys(i),o=new bn({name:n+jo,help:"Resident memory size in bytes.",registers:r,labelNames:s,collect(){try{let c=ou.readFileSync("/proc/self/status","utf8"),u=lu(c);o.set(i,u.VmRSS),a.set(i,u.VmSize),l.set(i,u.VmData)}catch{}}}),a=new bn({name:n+$o,help:"Virtual memory size in bytes.",registers:r,labelNames:s}),l=new bn({name:n+Wo,help:"Process heap size in bytes.",registers:r,labelNames:s})};yn.exports.metricNames=[jo,$o,Wo]});var vn=v((sm,Qo)=>{"use strict";function cu(){try{return process.memoryUsage()}catch{return}}Qo.exports=cu});var Ko=v((om,Sn)=>{"use strict";var uu=q(),Yo=Ho(),fu=vn(),Xo="process_resident_memory_bytes";function hu(t,e={}){let r=e.prefix?e.prefix:"",n=e.labels?e.labels:{},i=Object.keys(n);new uu({name:r+Xo,help:"Resident memory size in bytes.",registers:t?[t]:void 0,labelNames:i,collect(){let s=fu();s&&this.set(n,s.rss)}})}Sn.exports=(t,e)=>process.platform==="linux"?Yo(t,e):hu(t,e);Sn.exports.metricNames=process.platform==="linux"?Yo.metricNames:[Xo]});var ea=v((am,En)=>{"use strict";var du=q(),pu=k("fs"),mu=k("process"),Zo="process_open_fds";En.exports=(t,e={})=>{if(mu.platform!=="linux")return;let r=e.prefix?e.prefix:"",n=e.labels?e.labels:{},i=Object.keys(n);new du({name:r+Zo,help:"Number of open file descriptors.",registers:t?[t]:void 0,labelNames:i,collect(){try{let s=pu.readdirSync("/proc/self/fd");this.set(n,s.length-1)}catch{}}})};En.exports.metricNames=[Zo]});var ra=v((lm,Nn)=>{"use strict";var _u=q(),gu=k("fs"),ta="process_max_fds",nt;Nn.exports=(t,e={})=>{if(nt===void 0)try{let o=gu.readFileSync("/proc/self/limits","utf8").split(`
|
|
12
|
+
`);for(let a of o)if(a.startsWith("Max open files")){let l=a.split(/ +/);nt=Number(l[1]);break}}catch{return}if(nt===void 0)return;let r=e.prefix?e.prefix:"",n=e.labels?e.labels:{},i=Object.keys(n);new _u({name:r+ta,help:"Maximum number of open file descriptors.",registers:t?[t]:void 0,labelNames:i,collect(){nt!==void 0&&this.set(n,nt)}})};Nn.exports.metricNames=[ta]});var ha=v((cm,wn)=>{"use strict";var ue=q(),jt;try{jt=k("perf_hooks")}catch{}var ia="nodejs_eventloop_lag_seconds",sa="nodejs_eventloop_lag_min_seconds",oa="nodejs_eventloop_lag_max_seconds",aa="nodejs_eventloop_lag_mean_seconds",la="nodejs_eventloop_lag_stddev_seconds",ca="nodejs_eventloop_lag_p50_seconds",ua="nodejs_eventloop_lag_p90_seconds",fa="nodejs_eventloop_lag_p99_seconds";function na(t,e,r){let n=process.hrtime(t),s=(n[0]*1e9+n[1])/1e9;e.set(r,s)}wn.exports=(t,e={})=>{let r=e.prefix?e.prefix:"",n=e.labels?e.labels:{},i=Object.keys(n),s=t?[t]:void 0,o=()=>{let d=process.hrtime();setImmediate(na,d,a,n)};if(jt&&jt.monitorEventLoopDelay)try{let d=jt.monitorEventLoopDelay({resolution:e.eventLoopMonitoringPrecision});d.enable(),o=()=>{let C=process.hrtime();setImmediate(na,C,a,n),l.set(n,d.min/1e9),c.set(n,d.max/1e9),u.set(n,d.mean/1e9),f.set(n,d.stddev/1e9),h.set(n,d.percentile(50)/1e9),p.set(n,d.percentile(90)/1e9),b.set(n,d.percentile(99)/1e9),d.reset()}}catch(d){if(d.code==="ERR_NOT_IMPLEMENTED")return;throw d}let a=new ue({name:r+ia,help:"Lag of event loop in seconds.",registers:s,labelNames:i,aggregator:"average",collect:o}),l=new ue({name:r+sa,help:"The minimum recorded event loop delay.",registers:s,labelNames:i,aggregator:"min"}),c=new ue({name:r+oa,help:"The maximum recorded event loop delay.",registers:s,labelNames:i,aggregator:"max"}),u=new ue({name:r+aa,help:"The mean of the recorded event loop delays.",registers:s,labelNames:i,aggregator:"average"}),f=new ue({name:r+la,help:"The standard deviation of the recorded event loop delays.",registers:s,labelNames:i,aggregator:"average"}),h=new ue({name:r+ca,help:"The 50th percentile of the recorded event loop delays.",registers:s,labelNames:i,aggregator:"average"}),p=new ue({name:r+ua,help:"The 90th percentile of the recorded event loop delays.",registers:s,labelNames:i,aggregator:"average"}),b=new ue({name:r+fa,help:"The 99th percentile of the recorded event loop delays.",registers:s,labelNames:i,aggregator:"average"})};wn.exports.metricNames=[ia,sa,oa,aa,la,ca,ua,fa]});var Be=v((um,da)=>{"use strict";function bu(t){let e={};for(let r=0;r<t.length;r++){let n=t[r];!n||typeof n.constructor>"u"||(Object.hasOwnProperty.call(e,n.constructor.name)?e[n.constructor.name]+=1:e[n.constructor.name]=1)}return e}function yu(t,e,r){t.reset();for(let n in e)t.set(Object.assign({type:n},r||{}),e[n])}da.exports={aggregateByObjectName:bu,updateMetrics:yu}});var ga=v((fm,On)=>{"use strict";var{aggregateByObjectName:vu}=Be(),{updateMetrics:Su}=Be(),pa=q(),ma="nodejs_active_handles",_a="nodejs_active_handles_total";On.exports=(t,e={})=>{if(typeof process._getActiveHandles!="function")return;let r=t?[t]:void 0,n=e.prefix?e.prefix:"",i=e.labels?e.labels:{},s=Object.keys(i);new pa({name:n+ma,help:"Number of active libuv handles grouped by handle type. Every handle type is C++ class name.",labelNames:["type",...s],registers:r,collect(){let o=process._getActiveHandles();Su(this,vu(o),i)}}),new pa({name:n+_a,help:"Total number of active handles.",registers:r,labelNames:s,collect(){let o=process._getActiveHandles();this.set(i,o.length)}})};On.exports.metricNames=[ma,_a]});var Sa=v((hm,Tn)=>{"use strict";var ba=q(),{aggregateByObjectName:Eu}=Be(),{updateMetrics:Nu}=Be(),ya="nodejs_active_requests",va="nodejs_active_requests_total";Tn.exports=(t,e={})=>{if(typeof process._getActiveRequests!="function")return;let r=e.prefix?e.prefix:"",n=e.labels?e.labels:{},i=Object.keys(n);new ba({name:r+ya,help:"Number of active libuv requests grouped by request type. Every request type is C++ class name.",labelNames:["type",...i],registers:t?[t]:void 0,collect(){let s=process._getActiveRequests();Nu(this,Eu(s),n)}}),new ba({name:r+va,help:"Total number of active requests.",registers:t?[t]:void 0,labelNames:i,collect(){let s=process._getActiveRequests();this.set(n,s.length)}})};Tn.exports.metricNames=[ya,va]});var Oa=v((dm,xn)=>{"use strict";var Ea=q(),{updateMetrics:wu}=Be(),Na="nodejs_active_resources",wa="nodejs_active_resources_total";xn.exports=(t,e={})=>{if(typeof process.getActiveResourcesInfo!="function")return;let r=e.prefix?e.prefix:"",n=e.labels?e.labels:{},i=Object.keys(n);new Ea({name:r+Na,help:"Number of active resources that are currently keeping the event loop alive, grouped by async resource type.",labelNames:["type",...i],registers:t?[t]:void 0,collect(){let s=process.getActiveResourcesInfo(),o={};for(let a=0;a<s.length;a++){let l=s[a];Object.hasOwn(o,l)?o[l]+=1:o[l]=1}wu(this,o,n)}}),new Ea({name:r+wa,help:"Total number of active resources.",registers:t?[t]:void 0,labelNames:i,collect(){let s=process.getActiveResourcesInfo();this.set(n,s.length)}})};xn.exports.metricNames=[Na,wa]});var Ia=v((pm,In)=>{"use strict";var Cn=q(),Ou=vn(),Ta="nodejs_heap_size_total_bytes",xa="nodejs_heap_size_used_bytes",Ca="nodejs_external_memory_bytes";In.exports=(t,e={})=>{if(typeof process.memoryUsage!="function")return;let r=e.labels?e.labels:{},n=Object.keys(r),i=t?[t]:void 0,s=e.prefix?e.prefix:"",o=()=>{let u=Ou();u&&(a.set(r,u.heapTotal),l.set(r,u.heapUsed),u.external!==void 0&&c.set(r,u.external))},a=new Cn({name:s+Ta,help:"Process heap size from Node.js in bytes.",registers:i,labelNames:n,collect:o}),l=new Cn({name:s+xa,help:"Process heap size used from Node.js in bytes.",registers:i,labelNames:n}),c=new Cn({name:s+Ca,help:"Node.js external memory size in bytes.",registers:i,labelNames:n})};In.exports.metricNames=[Ta,xa,Ca]});var Ra=v((mm,Pn)=>{"use strict";var Tu=q(),Aa=k("v8"),Pa=["total","used","available"],An={};Pa.forEach(t=>{An[t]=`nodejs_heap_space_size_${t}_bytes`});Pn.exports=(t,e={})=>{try{Aa.getHeapSpaceStatistics()}catch(a){if(a.code==="ERR_NOT_IMPLEMENTED")return;throw a}let r=t?[t]:void 0,n=e.prefix?e.prefix:"",i=e.labels?e.labels:{},s=["space",...Object.keys(i)],o={};Pa.forEach(a=>{o[a]=new Tu({name:n+An[a],help:`Process heap space size ${a} from Node.js in bytes.`,labelNames:s,registers:r})}),o.total.collect=()=>{for(let a of Aa.getHeapSpaceStatistics()){let l=a.space_name.substr(0,a.space_name.indexOf("_space"));o.total.set({space:l,...i},a.space_size),o.used.set({space:l,...i},a.space_used_size),o.available.set({space:l,...i},a.space_available_size)}}};Pn.exports.metricNames=Object.values(An)});var La=v((_m,Mn)=>{"use strict";var xu=q(),Ma=process.version,Rn=Ma.slice(1).split(".").map(Number),ka="nodejs_version_info";Mn.exports=(t,e={})=>{let r=e.prefix?e.prefix:"",n=e.labels?e.labels:{},i=Object.keys(n);new xu({name:r+ka,help:"Node.js version info.",labelNames:["version","major","minor","patch",...i],registers:t?[t]:void 0,aggregator:"first",collect(){this.labels(Ma,Rn[0],Rn[1],Rn[2],...Object.values(n)).set(1)}})};Mn.exports.metricNames=[ka]});var Ba=v((gm,kn)=>{"use strict";var Cu=Ir(),ne;try{ne=k("perf_hooks")}catch{}var Da="nodejs_gc_duration_seconds",Iu=[.001,.01,.1,1,2,5],qe=[];ne&&ne.constants&&(qe[ne.constants.NODE_PERFORMANCE_GC_MAJOR]="major",qe[ne.constants.NODE_PERFORMANCE_GC_MINOR]="minor",qe[ne.constants.NODE_PERFORMANCE_GC_INCREMENTAL]="incremental",qe[ne.constants.NODE_PERFORMANCE_GC_WEAKCB]="weakcb");kn.exports=(t,e={})=>{if(!ne)return;let r=e.prefix?e.prefix:"",n=e.labels?e.labels:{},i=Object.keys(n),s=e.gcDurationBuckets?e.gcDurationBuckets:Iu,o=new Cu({name:r+Da,help:"Garbage collection duration by kind, one of major, minor, incremental or weakcb.",labelNames:["kind",...i],enableExemplars:!1,buckets:s,registers:t?[t]:void 0});new ne.PerformanceObserver(l=>{let c=l.getEntries()[0],u=c.detail?qe[c.detail.kind]:qe[c.kind];o.observe(Object.assign({kind:u},n),c.duration/1e3)}).observe({entryTypes:["gc"]})};kn.exports.metricNames=[Da]});var Ua=v((bm,Ln)=>{"use strict";var{isObject:Au}=Y(),Pu=zo(),Ru=Jo(),Mu=Ko(),ku=ea(),Lu=ra(),Du=ha(),Bu=ga(),qu=Sa(),Uu=Oa(),Vu=Ia(),Fu=Ra(),zu=La(),Gu=Ba(),qa={processCpuTotal:Pu,processStartTime:Ru,osMemoryHeap:Mu,processOpenFileDescriptors:ku,processMaxFileDescriptors:Lu,eventLoopLag:Du,...typeof process.getActiveResourcesInfo=="function"?{processResources:Uu}:{},processHandles:Bu,processRequests:qu,heapSizeAndUsed:Vu,heapSpacesSizeAndUsed:Fu,version:zu,gc:Gu},Ju=Object.keys(qa);Ln.exports=function(e){if(e!=null&&!Au(e))throw new TypeError("config must be null, undefined, or an object");e={eventLoopMonitoringPrecision:10,...e};for(let r of Object.values(qa))r(e.register,e)};Ln.exports.metricsList=Ju});var Bn=v(Dn=>{"use strict";var{Grouper:ju,hashObject:$u}=Y();function Ue(t){return e=>{if(e.length===0)return;let r={help:e[0].help,name:e[0].name,type:e[0].type,values:[],aggregator:e[0].aggregator},n=new ju;return e.forEach(i=>{i.values.forEach(s=>{let o=$u(s.labels);n.add(`${s.metricName}_${o}`,s)})}),n.forEach(i=>{if(i.length===0)return;let s={value:t(i),labels:i[0].labels};i[0].metricName&&(s.metricName=i[0].metricName),r.values.push(s)}),r}}Dn.AggregatorFactory=Ue;Dn.aggregators={sum:Ue(t=>t.reduce((e,r)=>e+r.value,0)),first:Ue(t=>t[0].value),omit:()=>{},average:Ue(t=>t.reduce((e,r)=>e+r.value,0)/t.length),min:Ue(t=>t.reduce((e,r)=>Math.min(e,r.value),1/0)),max:Ue(t=>t.reduce((e,r)=>Math.max(e,r.value),-1/0))}});var Ja=v((vm,Ga)=>{"use strict";var Ve=Pe(),{Grouper:Wu}=Y(),{aggregators:Hu}=Bn(),be=()=>{let t=k("cluster");return be=()=>t,t},Fa="prom-client:getMetricsReq",qn="prom-client:getMetricsRes",za=[Ve.globalRegistry],Qu=0,Va=!1,Un=new Map,$t=class extends Ve{constructor(e=Ve.PROMETHEUS_CONTENT_TYPE){super(e),Yu()}clusterMetrics(){let e=Qu++;return new Promise((r,n)=>{let i=!1;function s(l,c){i||(i=!0,l?n(l):r(c))}let o={responses:[],pending:0,done:s,errorTimeout:setTimeout(()=>{let l=new Error("Operation timed out.");o.done(l)},5e3)};Un.set(e,o);let a={type:Fa,requestId:e};for(let l in be().workers)be().workers[l].isConnected()&&(be().workers[l].send(a),o.pending++);o.pending===0&&(clearTimeout(o.errorTimeout),process.nextTick(()=>s(null,"")))})}get contentType(){return super.contentType}static aggregate(e,r=Ve.PROMETHEUS_CONTENT_TYPE){let n=new Ve,i=new Wu;return n.setContentType(r),e.forEach(s=>{s.forEach(o=>{i.add(o.name,o)})}),i.forEach(s=>{let o=s[0].aggregator,a=Hu[o];if(typeof a!="function")throw new Error(`'${o}' is not a defined aggregator.`);let l=a(s);if(l){let c=Object.assign({get:()=>l},l);n.registerMetric(c)}}),n}static setRegistries(e){Array.isArray(e)||(e=[e]),e.forEach(r=>{if(!(r instanceof Ve))throw new TypeError(`Expected Registry, got ${typeof r}`)}),za=e}};function Yu(){Va||(Va=!0,be().isMaster&&be().on("message",(t,e)=>{if(e.type===qn){let r=Un.get(e.requestId);if(e.error){r.done(new Error(e.error));return}if(e.metrics.forEach(n=>r.responses.push(n)),r.pending--,r.pending===0){Un.delete(e.requestId),clearTimeout(r.errorTimeout);let i=$t.aggregate(r.responses).metrics();r.done(null,i)}}}),be().isWorker&&process.on("message",t=>{t.type===Fa&&Promise.all(za.map(e=>e.getMetricsAsJSON())).then(e=>{process.send({type:qn,requestId:t.requestId,metrics:e})}).catch(e=>{process.send({type:qn,requestId:t.requestId,error:e.message})})}))}Ga.exports=$t});var it=v(R=>{"use strict";R.register=Pe().globalRegistry;R.Registry=Pe();Object.defineProperty(R,"contentType",{configurable:!1,enumerable:!0,get(){return R.register.contentType},set(t){R.register.setContentType(t)}});R.prometheusContentType=R.Registry.PROMETHEUS_CONTENT_TYPE;R.openMetricsContentType=R.Registry.OPENMETRICS_CONTENT_TYPE;R.validateMetricName=pe().validateMetricName;R.Counter=Sr();R.Gauge=q();R.Histogram=Ir();R.Summary=Os();R.Pushgateway=xs();R.linearBuckets=Ur().linearBuckets;R.exponentialBuckets=Ur().exponentialBuckets;R.collectDefaultMetrics=Ua();R.aggregators=Bn().aggregators;R.AggregatorRegistry=Ja()});var Ht=v(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.registry=void 0;var Xu=it();Wt.registry=new Xu.Registry});var Qt=v(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.incrementStreamMessagesCounter=x.getLabels=x.labelNamesWithCode=x.labelNames=x.latencySecondsBuckets=x.codeLabel=x.pathLabel=x.methodLabel=x.serviceLabel=x.typeLabel=void 0;var Ku=it();x.typeLabel="grpc_type";x.serviceLabel="grpc_service";x.methodLabel="grpc_method";x.pathLabel="grpc_path";x.codeLabel="grpc_code";x.latencySecondsBuckets=(0,Ku.exponentialBuckets)(.001,4,12);x.labelNames=[x.typeLabel,x.serviceLabel,x.methodLabel,x.pathLabel];x.labelNamesWithCode=[...x.labelNames,x.codeLabel];function Zu(t){let e=t.requestStream?t.responseStream?"bidi_stream":"client_stream":t.responseStream?"server_stream":"unary",{path:r}=t,[n,i]=r.split("/").slice(1);return{[x.typeLabel]:e,[x.serviceLabel]:n,[x.methodLabel]:i,[x.pathLabel]:r}}x.getLabels=Zu;async function*ef(t,e){for await(let r of t)e.inc(),yield r}x.incrementStreamMessagesCounter=ef});var ja=v(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.prometheusServerMiddleware=void 0;var tf=(nr(),ht(rr)),ye=tr(),st=it(),j=Qt(),ot=Ht(),rf=new st.Counter({registers:[ot.registry],name:"grpc_server_started_total",help:"Total number of RPCs started on the server.",labelNames:j.labelNames}),nf=new st.Counter({registers:[ot.registry],name:"grpc_server_handled_total",help:"Total number of RPCs completed on the server, regardless of success or failure.",labelNames:j.labelNamesWithCode}),sf=new st.Counter({registers:[ot.registry],name:"grpc_server_msg_received_total",help:"Total number of RPC stream messages received by the server.",labelNames:j.labelNames}),of=new st.Counter({registers:[ot.registry],name:"grpc_server_msg_sent_total",help:"Total number of gRPC stream messages sent by the server.",labelNames:j.labelNames}),af=new st.Histogram({registers:[ot.registry],name:"grpc_server_handling_seconds",help:"Histogram of response latency (seconds) of gRPC that had been application-level handled by the server.",labelNames:j.labelNamesWithCode,buckets:j.latencySecondsBuckets});function lf(t){let e=t?.serverStartedMetric||rf,r=t?.serverHandledMetric||nf,n=t?.serverStreamMsgReceivedMetric||sf,i=t?.serverStreamMsgSentMetric||of,s=t?.serverHandlingSecondsMetric||af;return async function*(a,l){let c=(0,j.getLabels)(a.method);e.inc(c);let u=s.startTimer(c),f=!1,h=ye.Status.OK;try{let p;if(a.requestStream?p=(0,j.incrementStreamMessagesCounter)(a.request,n.labels(c)):p=a.request,a.responseStream){yield*(0,j.incrementStreamMessagesCounter)(a.next(p,l),i.labels(c)),f=!0;return}else{let b=yield*a.next(p,l);return f=!0,b}}catch(p){throw f=!0,p instanceof ye.ServerError?h=p.code:(0,tf.isAbortError)(p)?h=ye.Status.CANCELLED:h=ye.Status.UNKNOWN,p}finally{f||(h=ye.Status.CANCELLED),u({[j.codeLabel]:ye.Status[h]}),r.inc({...c,[j.codeLabel]:ye.Status[h]})}}}Yt.prometheusServerMiddleware=lf});var $a=v(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.prometheusClientMiddleware=void 0;var cf=(nr(),ht(rr)),ve=tr(),at=it(),$=Qt(),lt=Ht(),uf=new at.Counter({registers:[lt.registry],name:"grpc_client_started_total",help:"Total number of RPCs started on the client.",labelNames:$.labelNames}),ff=new at.Counter({registers:[lt.registry],name:"grpc_client_handled_total",help:"Total number of RPCs completed on the client, regardless of success or failure.",labelNames:$.labelNamesWithCode}),hf=new at.Counter({registers:[lt.registry],name:"grpc_client_msg_received_total",help:"Total number of RPC stream messages received by the client.",labelNames:$.labelNames}),df=new at.Counter({registers:[lt.registry],name:"grpc_client_msg_sent_total",help:"Total number of gRPC stream messages sent by the client.",labelNames:$.labelNames}),pf=new at.Histogram({registers:[lt.registry],name:"grpc_client_handling_seconds",help:"Histogram of response latency (seconds) of the gRPC until it is finished by the application.",labelNames:$.labelNamesWithCode,buckets:$.latencySecondsBuckets});function mf(t){let e=t?.clientStartedMetric||uf,r=t?.clientHandledMetric||ff,n=t?.clientStreamMsgReceivedMetric||hf,i=t?.clientStreamMsgSentMetric||df,s=t?.clientHandlingSecondsMetric||pf;return async function*(a,l){let c=(0,$.getLabels)(a.method);e.inc(c);let u=s.startTimer(c),f=!1,h=ve.Status.OK;try{let p;if(a.requestStream?p=(0,$.incrementStreamMessagesCounter)(a.request,i.labels(c)):p=a.request,a.responseStream){yield*(0,$.incrementStreamMessagesCounter)(a.next(p,l),n.labels(c)),f=!0;return}else{let b=yield*a.next(p,l);return f=!0,b}}catch(p){throw f=!0,p instanceof ve.ClientError?h=p.code:(0,cf.isAbortError)(p)?h=ve.Status.CANCELLED:h=ve.Status.UNKNOWN,p}finally{f||(h=ve.Status.CANCELLED),u({[$.codeLabel]:ve.Status[h]}),r.inc({...c,[$.codeLabel]:ve.Status[h]})}}}Xt.prometheusClientMiddleware=mf});var Ha=v(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});z.labelNamesWithCode=z.labelNames=z.prometheusClientMiddleware=z.prometheusServerMiddleware=z.registry=void 0;var _f=Ht();Object.defineProperty(z,"registry",{enumerable:!0,get:function(){return _f.registry}});var gf=ja();Object.defineProperty(z,"prometheusServerMiddleware",{enumerable:!0,get:function(){return gf.prometheusServerMiddleware}});var bf=$a();Object.defineProperty(z,"prometheusClientMiddleware",{enumerable:!0,get:function(){return bf.prometheusClientMiddleware}});var Wa=Qt();Object.defineProperty(z,"labelNames",{enumerable:!0,get:function(){return Wa.labelNames}});Object.defineProperty(z,"labelNamesWithCode",{enumerable:!0,get:function(){return Wa.labelNamesWithCode}})});var Ya=v(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});Kt.retryMiddleware=void 0;var Qa=(nr(),ht(rr)),ct=tr(),yf=[ct.Status.UNKNOWN,ct.Status.INTERNAL,ct.Status.UNAVAILABLE,ct.Status.CANCELLED],vf=async function*(e,r){var n;let{idempotencyLevel:i}=e.method.options,s=i==="IDEMPOTENT"||i==="NO_SIDE_EFFECTS",{retry:o=s,retryBaseDelayMs:a=1e3,retryMaxDelayMs:l=3e4,retryMaxAttempts:c=1,onRetryableError:u,retryableStatuses:f=yf,...h}=r;if(e.requestStream||e.responseStream||!o)return yield*e.next(e.request,h);let p=(n=r.signal)!==null&&n!==void 0?n:new AbortController().signal;for(let b=0;;b++)try{return yield*e.next(e.request,h)}catch(d){if((0,Qa.rethrowAbortError)(d),b>=c||!(d instanceof ct.ClientError)||!f.includes(d.code))throw d;let C=Math.min(l,Math.pow(2,b)*a),m=Math.round(C*(1+Math.random())/2);u?.(d,b,m),await(0,Qa.delay)(p,m)}};Kt.retryMiddleware=vf});async function pt(t,e){let r=await t.getBlock(e);if(!r)throw new Error(`Block ${e} not found.`);return r}async function Tf(t,e,r){let n=Math.floor(e.getTime()/1e3),i=await pt(t,"latest"),a=(await pt(t,r!==void 0?r:0)).number,l=i.number;for(;a<=l;){let u=Math.floor((a+l)/2),f=await pt(t,u);if(f.timestamp===n)return f.number;f.timestamp<n?a=u+1:l=u-1}return(await pt(t,l)).number}function Cf(t){let e=BigInt(0);for(let r=0;r<t.length;r++)e=e*BigInt(256)+BigInt(t[r]);return e}var si={};Gn(si,{NATIVE_ETH:()=>sl,getER20NormalizedAmount:()=>al,getERC20TokenInfo:()=>ii});var Ne=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ei=new Set,sr=typeof process=="object"&&process?process:{},ti=(t,e,r,n)=>{typeof sr.emitWarning=="function"?sr.emitWarning(t,e,r,n):console.error(`[${r}] ${e}: ${t}`)},_t=globalThis.AbortController,Zn=globalThis.AbortSignal;if(typeof _t>"u"){Zn=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(n,i){this._onabort.push(i)}},_t=class{constructor(){e()}signal=new Zn;abort(n){if(!this.signal.aborted){this.signal.reason=n,this.signal.aborted=!0;for(let i of this.signal._onabort)i(n);this.signal.onabort?.(n)}}};let t=sr.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{t&&(t=!1,ti("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}var il=t=>!ei.has(t),Rf=Symbol("type"),se=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),ri=t=>se(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?Oe:null:null,Oe=class extends Array{constructor(e){super(e),this.fill(0)}},Te,we=class{heap;length;static create(e){let r=ri(e);if(!r)return[];er(we,Te,!0);let n=new we(e,r);return er(we,Te,!1),n}constructor(e,r){if(!Jn(we,Te))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},mt=we;Te=new WeakMap,jn(mt,Te,!1);var oe=class{#p;#u;#m;#_;#A;#P;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#i;#g;#n;#r;#e;#l;#f;#a;#s;#b;#o;#y;#v;#h;#S;#T;#c;static unsafeExposeInternals(e){return{starts:e.#v,ttls:e.#h,sizes:e.#y,keyMap:e.#n,keyList:e.#r,valList:e.#e,next:e.#l,prev:e.#f,get head(){return e.#a},get tail(){return e.#s},free:e.#b,isBackgroundFetch:r=>e.#t(r),backgroundFetch:(r,n,i,s)=>e.#k(r,n,i,s),moveToTail:r=>e.#I(r),indexes:r=>e.#E(r),rindexes:r=>e.#N(r),isStale:r=>e.#d(r)}}get max(){return this.#p}get maxSize(){return this.#u}get calculatedSize(){return this.#g}get size(){return this.#i}get fetchMethod(){return this.#A}get memoMethod(){return this.#P}get dispose(){return this.#m}get disposeAfter(){return this.#_}constructor(e){let{max:r=0,ttl:n,ttlResolution:i=1,ttlAutopurge:s,updateAgeOnGet:o,updateAgeOnHas:a,allowStale:l,dispose:c,disposeAfter:u,noDisposeOnSet:f,noUpdateTTL:h,maxSize:p=0,maxEntrySize:b=0,sizeCalculation:d,fetchMethod:C,memoMethod:m,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:S,allowStaleOnFetchRejection:T,allowStaleOnFetchAbort:A,ignoreFetchAbort:Z}=e;if(r!==0&&!se(r))throw new TypeError("max option must be a nonnegative integer");let W=r?ri(r):Array;if(!W)throw new Error("invalid max value: "+r);if(this.#p=r,this.#u=p,this.maxEntrySize=b||this.#u,this.sizeCalculation=d,this.sizeCalculation){if(!this.#u&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(m!==void 0&&typeof m!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#P=m,C!==void 0&&typeof C!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#A=C,this.#T=!!C,this.#n=new Map,this.#r=new Array(r).fill(void 0),this.#e=new Array(r).fill(void 0),this.#l=new W(r),this.#f=new W(r),this.#a=0,this.#s=0,this.#b=mt.create(r),this.#i=0,this.#g=0,typeof c=="function"&&(this.#m=c),typeof u=="function"?(this.#_=u,this.#o=[]):(this.#_=void 0,this.#o=void 0),this.#S=!!this.#m,this.#c=!!this.#_,this.noDisposeOnSet=!!f,this.noUpdateTTL=!!h,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!T,this.allowStaleOnFetchAbort=!!A,this.ignoreFetchAbort=!!Z,this.maxEntrySize!==0){if(this.#u!==0&&!se(this.#u))throw new TypeError("maxSize must be a positive integer if specified");if(!se(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#F()}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!S,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!a,this.ttlResolution=se(i)||i===0?i:1,this.ttlAutopurge=!!s,this.ttl=n||0,this.ttl){if(!se(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#L()}if(this.#p===0&&this.ttl===0&&this.#u===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#p&&!this.#u){let ee="LRU_CACHE_UNBOUNDED";il(ee)&&(ei.add(ee),ti("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",ee,oe))}}getRemainingTTL(e){return this.#n.has(e)?1/0:0}#L(){let e=new Oe(this.#p),r=new Oe(this.#p);this.#h=e,this.#v=r,this.#D=(s,o,a=Ne.now())=>{if(r[s]=o!==0?a:0,e[s]=o,o!==0&&this.ttlAutopurge){let l=setTimeout(()=>{this.#d(s)&&this.#w(this.#r[s],"expire")},o+1);l.unref&&l.unref()}},this.#x=s=>{r[s]=e[s]!==0?Ne.now():0},this.#O=(s,o)=>{if(e[o]){let a=e[o],l=r[o];if(!a||!l)return;s.ttl=a,s.start=l,s.now=n||i();let c=s.now-l;s.remainingTTL=a-c}};let n=0,i=()=>{let s=Ne.now();if(this.ttlResolution>0){n=s;let o=setTimeout(()=>n=0,this.ttlResolution);o.unref&&o.unref()}return s};this.getRemainingTTL=s=>{let o=this.#n.get(s);if(o===void 0)return 0;let a=e[o],l=r[o];if(!a||!l)return 1/0;let c=(n||i())-l;return a-c},this.#d=s=>{let o=r[s],a=e[s];return!!a&&!!o&&(n||i())-o>a}}#x=()=>{};#O=()=>{};#D=()=>{};#d=()=>!1;#F(){let e=new Oe(this.#p);this.#g=0,this.#y=e,this.#C=r=>{this.#g-=e[r],e[r]=0},this.#B=(r,n,i,s)=>{if(this.#t(n))return 0;if(!se(i))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(i=s(n,r),!se(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#R=(r,n,i)=>{if(e[r]=n,this.#u){let s=this.#u-e[r];for(;this.#g>s;)this.#M(!0)}this.#g+=e[r],i&&(i.entrySize=n,i.totalCalculatedSize=this.#g)}}#C=e=>{};#R=(e,r,n)=>{};#B=(e,r,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#E({allowStale:e=this.allowStale}={}){if(this.#i)for(let r=this.#s;!(!this.#q(r)||((e||!this.#d(r))&&(yield r),r===this.#a));)r=this.#f[r]}*#N({allowStale:e=this.allowStale}={}){if(this.#i)for(let r=this.#a;!(!this.#q(r)||((e||!this.#d(r))&&(yield r),r===this.#s));)r=this.#l[r]}#q(e){return e!==void 0&&this.#n.get(this.#r[e])===e}*entries(){for(let e of this.#E())this.#e[e]!==void 0&&this.#r[e]!==void 0&&!this.#t(this.#e[e])&&(yield[this.#r[e],this.#e[e]])}*rentries(){for(let e of this.#N())this.#e[e]!==void 0&&this.#r[e]!==void 0&&!this.#t(this.#e[e])&&(yield[this.#r[e],this.#e[e]])}*keys(){for(let e of this.#E()){let r=this.#r[e];r!==void 0&&!this.#t(this.#e[e])&&(yield r)}}*rkeys(){for(let e of this.#N()){let r=this.#r[e];r!==void 0&&!this.#t(this.#e[e])&&(yield r)}}*values(){for(let e of this.#E())this.#e[e]!==void 0&&!this.#t(this.#e[e])&&(yield this.#e[e])}*rvalues(){for(let e of this.#N())this.#e[e]!==void 0&&!this.#t(this.#e[e])&&(yield this.#e[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,r={}){for(let n of this.#E()){let i=this.#e[n],s=this.#t(i)?i.__staleWhileFetching:i;if(s!==void 0&&e(s,this.#r[n],this))return this.get(this.#r[n],r)}}forEach(e,r=this){for(let n of this.#E()){let i=this.#e[n],s=this.#t(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(r,s,this.#r[n],this)}}rforEach(e,r=this){for(let n of this.#N()){let i=this.#e[n],s=this.#t(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(r,s,this.#r[n],this)}}purgeStale(){let e=!1;for(let r of this.#N({allowStale:!0}))this.#d(r)&&(this.#w(this.#r[r],"expire"),e=!0);return e}info(e){let r=this.#n.get(e);if(r===void 0)return;let n=this.#e[r],i=this.#t(n)?n.__staleWhileFetching:n;if(i===void 0)return;let s={value:i};if(this.#h&&this.#v){let o=this.#h[r],a=this.#v[r];if(o&&a){let l=o-(Ne.now()-a);s.ttl=l,s.start=Date.now()}}return this.#y&&(s.size=this.#y[r]),s}dump(){let e=[];for(let r of this.#E({allowStale:!0})){let n=this.#r[r],i=this.#e[r],s=this.#t(i)?i.__staleWhileFetching:i;if(s===void 0||n===void 0)continue;let o={value:s};if(this.#h&&this.#v){o.ttl=this.#h[r];let a=Ne.now()-this.#v[r];o.start=Math.floor(Date.now()-a)}this.#y&&(o.size=this.#y[r]),e.unshift([n,o])}return e}load(e){this.clear();for(let[r,n]of e){if(n.start){let i=Date.now()-n.start;n.start=Ne.now()-i}this.set(r,n.value,n)}}set(e,r,n={}){if(r===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:s,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:l}=n,{noUpdateTTL:c=this.noUpdateTTL}=n,u=this.#B(e,r,n.size||0,a);if(this.maxEntrySize&&u>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=!0),this.#w(e,"set"),this;let f=this.#i===0?void 0:this.#n.get(e);if(f===void 0)f=this.#i===0?this.#s:this.#b.length!==0?this.#b.pop():this.#i===this.#p?this.#M(!1):this.#i,this.#r[f]=e,this.#e[f]=r,this.#n.set(e,f),this.#l[this.#s]=f,this.#f[f]=this.#s,this.#s=f,this.#i++,this.#R(f,u,l),l&&(l.set="add"),c=!1;else{this.#I(f);let h=this.#e[f];if(r!==h){if(this.#T&&this.#t(h)){h.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=h;p!==void 0&&!o&&(this.#S&&this.#m?.(p,e,"set"),this.#c&&this.#o?.push([p,e,"set"]))}else o||(this.#S&&this.#m?.(h,e,"set"),this.#c&&this.#o?.push([h,e,"set"]));if(this.#C(f),this.#R(f,u,l),this.#e[f]=r,l){l.set="replace";let p=h&&this.#t(h)?h.__staleWhileFetching:h;p!==void 0&&(l.oldValue=p)}}else l&&(l.set="update")}if(i!==0&&!this.#h&&this.#L(),this.#h&&(c||this.#D(f,i,s),l&&this.#O(l,f)),!o&&this.#c&&this.#o){let h=this.#o,p;for(;p=h?.shift();)this.#_?.(...p)}return this}pop(){try{for(;this.#i;){let e=this.#e[this.#a];if(this.#M(!0),this.#t(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#c&&this.#o){let e=this.#o,r;for(;r=e?.shift();)this.#_?.(...r)}}}#M(e){let r=this.#a,n=this.#r[r],i=this.#e[r];return this.#T&&this.#t(i)?i.__abortController.abort(new Error("evicted")):(this.#S||this.#c)&&(this.#S&&this.#m?.(i,n,"evict"),this.#c&&this.#o?.push([i,n,"evict"])),this.#C(r),e&&(this.#r[r]=void 0,this.#e[r]=void 0,this.#b.push(r)),this.#i===1?(this.#a=this.#s=0,this.#b.length=0):this.#a=this.#l[r],this.#n.delete(n),this.#i--,r}has(e,r={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=r,s=this.#n.get(e);if(s!==void 0){let o=this.#e[s];if(this.#t(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#d(s))i&&(i.has="stale",this.#O(i,s));else return n&&this.#x(s),i&&(i.has="hit",this.#O(i,s)),!0}else i&&(i.has="miss");return!1}peek(e,r={}){let{allowStale:n=this.allowStale}=r,i=this.#n.get(e);if(i===void 0||!n&&this.#d(i))return;let s=this.#e[i];return this.#t(s)?s.__staleWhileFetching:s}#k(e,r,n,i){let s=r===void 0?void 0:this.#e[r];if(this.#t(s))return s;let o=new _t,{signal:a}=n;a?.addEventListener("abort",()=>o.abort(a.reason),{signal:o.signal});let l={signal:o.signal,options:n,context:i},c=(d,C=!1)=>{let{aborted:m}=o.signal,y=n.ignoreFetchAbort&&d!==void 0;if(n.status&&(m&&!C?(n.status.fetchAborted=!0,n.status.fetchError=o.signal.reason,y&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),m&&!y&&!C)return f(o.signal.reason);let S=p;return this.#e[r]===p&&(d===void 0?S.__staleWhileFetching?this.#e[r]=S.__staleWhileFetching:this.#w(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(e,d,l.options))),d},u=d=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=d),f(d)),f=d=>{let{aborted:C}=o.signal,m=C&&n.allowStaleOnFetchAbort,y=m||n.allowStaleOnFetchRejection,S=y||n.noDeleteOnFetchRejection,T=p;if(this.#e[r]===p&&(!S||T.__staleWhileFetching===void 0?this.#w(e,"fetch"):m||(this.#e[r]=T.__staleWhileFetching)),y)return n.status&&T.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),T.__staleWhileFetching;if(T.__returned===T)throw d},h=(d,C)=>{let m=this.#A?.(e,s,l);m&&m instanceof Promise&&m.then(y=>d(y===void 0?void 0:y),C),o.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(d(void 0),n.allowStaleOnFetchAbort&&(d=y=>c(y,!0)))})};n.status&&(n.status.fetchDispatched=!0);let p=new Promise(h).then(c,u),b=Object.assign(p,{__abortController:o,__staleWhileFetching:s,__returned:void 0});return r===void 0?(this.set(e,b,{...l.options,status:void 0}),r=this.#n.get(e)):this.#e[r]=b,b}#t(e){if(!this.#T)return!1;let r=e;return!!r&&r instanceof Promise&&r.hasOwnProperty("__staleWhileFetching")&&r.__abortController instanceof _t}async fetch(e,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:l=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:f=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:h=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:b=this.allowStaleOnFetchAbort,context:d,forceRefresh:C=!1,status:m,signal:y}=r;if(!this.#T)return m&&(m.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:s,status:m});let S={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:s,ttl:o,noDisposeOnSet:a,size:l,sizeCalculation:c,noUpdateTTL:u,noDeleteOnFetchRejection:f,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:b,ignoreFetchAbort:p,status:m,signal:y},T=this.#n.get(e);if(T===void 0){m&&(m.fetch="miss");let A=this.#k(e,T,S,d);return A.__returned=A}else{let A=this.#e[T];if(this.#t(A)){let ut=n&&A.__staleWhileFetching!==void 0;return m&&(m.fetch="inflight",ut&&(m.returnedStale=!0)),ut?A.__staleWhileFetching:A.__returned=A}let Z=this.#d(T);if(!C&&!Z)return m&&(m.fetch="hit"),this.#I(T),i&&this.#x(T),m&&this.#O(m,T),A;let W=this.#k(e,T,S,d),ze=W.__staleWhileFetching!==void 0&&n;return m&&(m.fetch=Z?"stale":"refresh",ze&&Z&&(m.returnedStale=!0)),ze?W.__staleWhileFetching:W.__returned=W}}async forceFetch(e,r={}){let n=await this.fetch(e,r);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,r={}){let n=this.#P;if(!n)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:s,...o}=r,a=this.get(e,o);if(!s&&a!==void 0)return a;let l=n(e,a,{options:o,context:i});return this.set(e,l,o),l}get(e,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:o}=r,a=this.#n.get(e);if(a!==void 0){let l=this.#e[a],c=this.#t(l);return o&&this.#O(o,a),this.#d(a)?(o&&(o.get="stale"),c?(o&&n&&l.__staleWhileFetching!==void 0&&(o.returnedStale=!0),n?l.__staleWhileFetching:void 0):(s||this.#w(e,"expire"),o&&n&&(o.returnedStale=!0),n?l:void 0)):(o&&(o.get="hit"),c?l.__staleWhileFetching:(this.#I(a),i&&this.#x(a),l))}else o&&(o.get="miss")}#U(e,r){this.#f[r]=e,this.#l[e]=r}#I(e){e!==this.#s&&(e===this.#a?this.#a=this.#l[e]:this.#U(this.#f[e],this.#l[e]),this.#U(this.#s,e),this.#s=e)}delete(e){return this.#w(e,"delete")}#w(e,r){let n=!1;if(this.#i!==0){let i=this.#n.get(e);if(i!==void 0)if(n=!0,this.#i===1)this.#V(r);else{this.#C(i);let s=this.#e[i];if(this.#t(s)?s.__abortController.abort(new Error("deleted")):(this.#S||this.#c)&&(this.#S&&this.#m?.(s,e,r),this.#c&&this.#o?.push([s,e,r])),this.#n.delete(e),this.#r[i]=void 0,this.#e[i]=void 0,i===this.#s)this.#s=this.#f[i];else if(i===this.#a)this.#a=this.#l[i];else{let o=this.#f[i];this.#l[o]=this.#l[i];let a=this.#l[i];this.#f[a]=this.#f[i]}this.#i--,this.#b.push(i)}}if(this.#c&&this.#o?.length){let i=this.#o,s;for(;s=i?.shift();)this.#_?.(...s)}return n}clear(){return this.#V("delete")}#V(e){for(let r of this.#N({allowStale:!0})){let n=this.#e[r];if(this.#t(n))n.__abortController.abort(new Error("deleted"));else{let i=this.#r[r];this.#S&&this.#m?.(n,i,e),this.#c&&this.#o?.push([n,i,e])}}if(this.#n.clear(),this.#e.fill(void 0),this.#r.fill(void 0),this.#h&&this.#v&&(this.#h.fill(0),this.#v.fill(0)),this.#y&&this.#y.fill(0),this.#a=0,this.#s=0,this.#b.length=0,this.#g=0,this.#i=0,this.#c&&this.#o){let r=this.#o,n;for(;n=r?.shift();)this.#_?.(...n)}}};var sl={symbol:"ETH",decimal:18,name:"Native ETH"},ni=new oe({max:1e4,ttl:1e3*60*60});async function ol(t,e,r){return{symbol:await t,name:await e,decimal:Number(await r)}}async function ii(t,e){let r;t instanceof Wn?r=t.getChainId():r=t||Qn.EthChainId.ETHEREUM;let n=r+e,i=ni.get(n);if(i)return i;let s=Yn(r,e),o=Xn(r,e),a="";try{a=await s.name()}catch{a=ir(await o.name())}let l="";try{l=await s.symbol()}catch{l=ir(await o.symbol())}let c=await s.decimals(),u=ol(l,a,c);return ni.set(n,u),u}async function al(t,e,r){let n=await ii(t,e);return dt(r,n.decimal)}import hi from"fs";var N=class extends Error{constructor(e,r,n,...i){Array.isArray(r)&&(r=r.join(" ").trim()),super(r),Error.captureStackTrace!==void 0&&Error.captureStackTrace(this,N),this.code=e;for(let s of i)for(let o in s){let a=s[o];this[o]=Buffer.isBuffer(a)?a.toString(n.encoding):a==null?a:JSON.parse(JSON.stringify(a))}}};var oi=function(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)};var gt=function(t){let e=[];for(let r=0,n=t.length;r<n;r++){let i=t[r];if(i==null||i===!1)e[r]={disabled:!0};else if(typeof i=="string")e[r]={name:i};else if(oi(i)){if(typeof i.name!="string")throw new N("CSV_OPTION_COLUMNS_MISSING_NAME",["Option columns missing name:",`property "name" is required at position ${r}`,"when column is an object literal"]);e[r]=i}else throw new N("CSV_INVALID_COLUMN_DEFINITION",["Invalid column definition:","expect a string or a literal object,",`got ${JSON.stringify(i)} at position ${r}`])}return e};var or=class{constructor(e=100){this.size=e,this.length=0,this.buf=Buffer.allocUnsafe(e)}prepend(e){if(Buffer.isBuffer(e)){let r=this.length+e.length;if(r>=this.size&&(this.resize(),r>=this.size))throw Error("INVALID_BUFFER_STATE");let n=this.buf;this.buf=Buffer.allocUnsafe(this.size),e.copy(this.buf,0),n.copy(this.buf,e.length),this.length+=e.length}else{let r=this.length++;r===this.size&&this.resize();let n=this.clone();this.buf[0]=e,n.copy(this.buf,1,0,r)}}append(e){let r=this.length++;r===this.size&&this.resize(),this.buf[r]=e}clone(){return Buffer.from(this.buf.slice(0,this.length))}resize(){let e=this.length;this.size=this.size*2;let r=Buffer.allocUnsafe(this.size);this.buf.copy(r,0,0,e),this.buf=r}toString(e){return e?this.buf.slice(0,this.length).toString(e):Uint8Array.prototype.slice.call(this.buf.slice(0,this.length))}toJSON(){return this.toString("utf8")}reset(){this.length=0}},ar=or;var ll=12,cl=13,ul=10,fl=32,hl=9,ai=function(t){return{bomSkipped:!1,bufBytesStart:0,castField:t.cast_function,commenting:!1,error:void 0,enabled:t.from_line===1,escaping:!1,escapeIsQuote:Buffer.isBuffer(t.escape)&&Buffer.isBuffer(t.quote)&&Buffer.compare(t.escape,t.quote)===0,expectedRecordLength:Array.isArray(t.columns)?t.columns.length:void 0,field:new ar(20),firstLineToHeaders:t.cast_first_line_to_header,needMoreDataSize:Math.max(t.comment!==null?t.comment.length:0,...t.delimiter.map(e=>e.length),t.quote!==null?t.quote.length:0),previousBuf:void 0,quoting:!1,stop:!1,rawBuffer:new ar(100),record:[],recordHasError:!1,record_length:0,recordDelimiterMaxLength:t.record_delimiter.length===0?0:Math.max(...t.record_delimiter.map(e=>e.length)),trimChars:[Buffer.from(" ",t.encoding)[0],Buffer.from(" ",t.encoding)[0]],wasQuoting:!1,wasRowDelimiter:!1,timchars:[Buffer.from(Buffer.from([cl],"utf8").toString(),t.encoding),Buffer.from(Buffer.from([ul],"utf8").toString(),t.encoding),Buffer.from(Buffer.from([ll],"utf8").toString(),t.encoding),Buffer.from(Buffer.from([fl],"utf8").toString(),t.encoding),Buffer.from(Buffer.from([hl],"utf8").toString(),t.encoding)]}};var li=function(t){return t.replace(/([A-Z])/g,function(e,r){return"_"+r.toLowerCase()})};var lr=function(t){let e={};for(let n in t)e[li(n)]=t[n];if(e.encoding===void 0||e.encoding===!0)e.encoding="utf8";else if(e.encoding===null||e.encoding===!1)e.encoding=null;else if(typeof e.encoding!="string"&&e.encoding!==null)throw new N("CSV_INVALID_OPTION_ENCODING",["Invalid option encoding:","encoding must be a string or null to return a buffer,",`got ${JSON.stringify(e.encoding)}`],e);if(e.bom===void 0||e.bom===null||e.bom===!1)e.bom=!1;else if(e.bom!==!0)throw new N("CSV_INVALID_OPTION_BOM",["Invalid option bom:","bom must be true,",`got ${JSON.stringify(e.bom)}`],e);if(e.cast_function=null,e.cast===void 0||e.cast===null||e.cast===!1||e.cast==="")e.cast=void 0;else if(typeof e.cast=="function")e.cast_function=e.cast,e.cast=!0;else if(e.cast!==!0)throw new N("CSV_INVALID_OPTION_CAST",["Invalid option cast:","cast must be true or a function,",`got ${JSON.stringify(e.cast)}`],e);if(e.cast_date===void 0||e.cast_date===null||e.cast_date===!1||e.cast_date==="")e.cast_date=!1;else if(e.cast_date===!0)e.cast_date=function(n){let i=Date.parse(n);return isNaN(i)?n:new Date(i)};else if(typeof e.cast_date!="function")throw new N("CSV_INVALID_OPTION_CAST_DATE",["Invalid option cast_date:","cast_date must be true or a function,",`got ${JSON.stringify(e.cast_date)}`],e);if(e.cast_first_line_to_header=null,e.columns===!0)e.cast_first_line_to_header=void 0;else if(typeof e.columns=="function")e.cast_first_line_to_header=e.columns,e.columns=!0;else if(Array.isArray(e.columns))e.columns=gt(e.columns);else if(e.columns===void 0||e.columns===null||e.columns===!1)e.columns=!1;else throw new N("CSV_INVALID_OPTION_COLUMNS",["Invalid option columns:","expect an array, a function or true,",`got ${JSON.stringify(e.columns)}`],e);if(e.group_columns_by_name===void 0||e.group_columns_by_name===null||e.group_columns_by_name===!1)e.group_columns_by_name=!1;else{if(e.group_columns_by_name!==!0)throw new N("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","expect an boolean,",`got ${JSON.stringify(e.group_columns_by_name)}`],e);if(e.columns===!1)throw new N("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","the `columns` mode must be activated."],e)}if(e.comment===void 0||e.comment===null||e.comment===!1||e.comment==="")e.comment=null;else if(typeof e.comment=="string"&&(e.comment=Buffer.from(e.comment,e.encoding)),!Buffer.isBuffer(e.comment))throw new N("CSV_INVALID_OPTION_COMMENT",["Invalid option comment:","comment must be a buffer or a string,",`got ${JSON.stringify(e.comment)}`],e);if(e.comment_no_infix===void 0||e.comment_no_infix===null||e.comment_no_infix===!1)e.comment_no_infix=!1;else if(e.comment_no_infix!==!0)throw new N("CSV_INVALID_OPTION_COMMENT",["Invalid option comment_no_infix:","value must be a boolean,",`got ${JSON.stringify(e.comment_no_infix)}`],e);let r=JSON.stringify(e.delimiter);if(Array.isArray(e.delimiter)||(e.delimiter=[e.delimiter]),e.delimiter.length===0)throw new N("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${r}`],e);if(e.delimiter=e.delimiter.map(function(n){if(n==null||n===!1)return Buffer.from(",",e.encoding);if(typeof n=="string"&&(n=Buffer.from(n,e.encoding)),!Buffer.isBuffer(n)||n.length===0)throw new N("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${r}`],e);return n}),e.escape===void 0||e.escape===!0?e.escape=Buffer.from('"',e.encoding):typeof e.escape=="string"?e.escape=Buffer.from(e.escape,e.encoding):(e.escape===null||e.escape===!1)&&(e.escape=null),e.escape!==null&&!Buffer.isBuffer(e.escape))throw new Error(`Invalid Option: escape must be a buffer, a string or a boolean, got ${JSON.stringify(e.escape)}`);if(e.from===void 0||e.from===null)e.from=1;else if(typeof e.from=="string"&&/\d+/.test(e.from)&&(e.from=parseInt(e.from)),Number.isInteger(e.from)){if(e.from<0)throw new Error(`Invalid Option: from must be a positive integer, got ${JSON.stringify(t.from)}`)}else throw new Error(`Invalid Option: from must be an integer, got ${JSON.stringify(e.from)}`);if(e.from_line===void 0||e.from_line===null)e.from_line=1;else if(typeof e.from_line=="string"&&/\d+/.test(e.from_line)&&(e.from_line=parseInt(e.from_line)),Number.isInteger(e.from_line)){if(e.from_line<=0)throw new Error(`Invalid Option: from_line must be a positive integer greater than 0, got ${JSON.stringify(t.from_line)}`)}else throw new Error(`Invalid Option: from_line must be an integer, got ${JSON.stringify(t.from_line)}`);if(e.ignore_last_delimiters===void 0||e.ignore_last_delimiters===null)e.ignore_last_delimiters=!1;else if(typeof e.ignore_last_delimiters=="number")e.ignore_last_delimiters=Math.floor(e.ignore_last_delimiters),e.ignore_last_delimiters===0&&(e.ignore_last_delimiters=!1);else if(typeof e.ignore_last_delimiters!="boolean")throw new N("CSV_INVALID_OPTION_IGNORE_LAST_DELIMITERS",["Invalid option `ignore_last_delimiters`:","the value must be a boolean value or an integer,",`got ${JSON.stringify(e.ignore_last_delimiters)}`],e);if(e.ignore_last_delimiters===!0&&e.columns===!1)throw new N("CSV_IGNORE_LAST_DELIMITERS_REQUIRES_COLUMNS",["The option `ignore_last_delimiters`","requires the activation of the `columns` option"],e);if(e.info===void 0||e.info===null||e.info===!1)e.info=!1;else if(e.info!==!0)throw new Error(`Invalid Option: info must be true, got ${JSON.stringify(e.info)}`);if(e.max_record_size===void 0||e.max_record_size===null||e.max_record_size===!1)e.max_record_size=0;else if(!(Number.isInteger(e.max_record_size)&&e.max_record_size>=0))if(typeof e.max_record_size=="string"&&/\d+/.test(e.max_record_size))e.max_record_size=parseInt(e.max_record_size);else throw new Error(`Invalid Option: max_record_size must be a positive integer, got ${JSON.stringify(e.max_record_size)}`);if(e.objname===void 0||e.objname===null||e.objname===!1)e.objname=void 0;else if(Buffer.isBuffer(e.objname)){if(e.objname.length===0)throw new Error("Invalid Option: objname must be a non empty buffer");e.encoding===null||(e.objname=e.objname.toString(e.encoding))}else if(typeof e.objname=="string"){if(e.objname.length===0)throw new Error("Invalid Option: objname must be a non empty string")}else if(typeof e.objname!="number")throw new Error(`Invalid Option: objname must be a string or a buffer, got ${e.objname}`);if(e.objname!==void 0){if(typeof e.objname=="number"){if(e.columns!==!1)throw Error("Invalid Option: objname index cannot be combined with columns or be defined as a field")}else if(e.columns===!1)throw Error("Invalid Option: objname field must be combined with columns or be defined as an index")}if(e.on_record===void 0||e.on_record===null)e.on_record=void 0;else if(typeof e.on_record!="function")throw new N("CSV_INVALID_OPTION_ON_RECORD",["Invalid option `on_record`:","expect a function,",`got ${JSON.stringify(e.on_record)}`],e);if(e.on_skip!==void 0&&e.on_skip!==null&&typeof e.on_skip!="function")throw new Error(`Invalid Option: on_skip must be a function, got ${JSON.stringify(e.on_skip)}`);if(e.quote===null||e.quote===!1||e.quote==="")e.quote=null;else if(e.quote===void 0||e.quote===!0?e.quote=Buffer.from('"',e.encoding):typeof e.quote=="string"&&(e.quote=Buffer.from(e.quote,e.encoding)),!Buffer.isBuffer(e.quote))throw new Error(`Invalid Option: quote must be a buffer or a string, got ${JSON.stringify(e.quote)}`);if(e.raw===void 0||e.raw===null||e.raw===!1)e.raw=!1;else if(e.raw!==!0)throw new Error(`Invalid Option: raw must be true, got ${JSON.stringify(e.raw)}`);if(e.record_delimiter===void 0)e.record_delimiter=[];else if(typeof e.record_delimiter=="string"||Buffer.isBuffer(e.record_delimiter)){if(e.record_delimiter.length===0)throw new N("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer,",`got ${JSON.stringify(e.record_delimiter)}`],e);e.record_delimiter=[e.record_delimiter]}else if(!Array.isArray(e.record_delimiter))throw new N("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer,",`got ${JSON.stringify(e.record_delimiter)}`],e);if(e.record_delimiter=e.record_delimiter.map(function(n,i){if(typeof n!="string"&&!Buffer.isBuffer(n))throw new N("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer",`at index ${i},`,`got ${JSON.stringify(n)}`],e);if(n.length===0)throw new N("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer",`at index ${i},`,`got ${JSON.stringify(n)}`],e);return typeof n=="string"&&(n=Buffer.from(n,e.encoding)),n}),typeof e.relax_column_count!="boolean")if(e.relax_column_count===void 0||e.relax_column_count===null)e.relax_column_count=!1;else throw new Error(`Invalid Option: relax_column_count must be a boolean, got ${JSON.stringify(e.relax_column_count)}`);if(typeof e.relax_column_count_less!="boolean")if(e.relax_column_count_less===void 0||e.relax_column_count_less===null)e.relax_column_count_less=!1;else throw new Error(`Invalid Option: relax_column_count_less must be a boolean, got ${JSON.stringify(e.relax_column_count_less)}`);if(typeof e.relax_column_count_more!="boolean")if(e.relax_column_count_more===void 0||e.relax_column_count_more===null)e.relax_column_count_more=!1;else throw new Error(`Invalid Option: relax_column_count_more must be a boolean, got ${JSON.stringify(e.relax_column_count_more)}`);if(typeof e.relax_quotes!="boolean")if(e.relax_quotes===void 0||e.relax_quotes===null)e.relax_quotes=!1;else throw new Error(`Invalid Option: relax_quotes must be a boolean, got ${JSON.stringify(e.relax_quotes)}`);if(typeof e.skip_empty_lines!="boolean")if(e.skip_empty_lines===void 0||e.skip_empty_lines===null)e.skip_empty_lines=!1;else throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(e.skip_empty_lines)}`);if(typeof e.skip_records_with_empty_values!="boolean")if(e.skip_records_with_empty_values===void 0||e.skip_records_with_empty_values===null)e.skip_records_with_empty_values=!1;else throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(e.skip_records_with_empty_values)}`);if(typeof e.skip_records_with_error!="boolean")if(e.skip_records_with_error===void 0||e.skip_records_with_error===null)e.skip_records_with_error=!1;else throw new Error(`Invalid Option: skip_records_with_error must be a boolean, got ${JSON.stringify(e.skip_records_with_error)}`);if(e.rtrim===void 0||e.rtrim===null||e.rtrim===!1)e.rtrim=!1;else if(e.rtrim!==!0)throw new Error(`Invalid Option: rtrim must be a boolean, got ${JSON.stringify(e.rtrim)}`);if(e.ltrim===void 0||e.ltrim===null||e.ltrim===!1)e.ltrim=!1;else if(e.ltrim!==!0)throw new Error(`Invalid Option: ltrim must be a boolean, got ${JSON.stringify(e.ltrim)}`);if(e.trim===void 0||e.trim===null||e.trim===!1)e.trim=!1;else if(e.trim!==!0)throw new Error(`Invalid Option: trim must be a boolean, got ${JSON.stringify(e.trim)}`);if(e.trim===!0&&t.ltrim!==!1?e.ltrim=!0:e.ltrim!==!0&&(e.ltrim=!1),e.trim===!0&&t.rtrim!==!1?e.rtrim=!0:e.rtrim!==!0&&(e.rtrim=!1),e.to===void 0||e.to===null)e.to=-1;else if(typeof e.to=="string"&&/\d+/.test(e.to)&&(e.to=parseInt(e.to)),Number.isInteger(e.to)){if(e.to<=0)throw new Error(`Invalid Option: to must be a positive integer greater than 0, got ${JSON.stringify(t.to)}`)}else throw new Error(`Invalid Option: to must be an integer, got ${JSON.stringify(t.to)}`);if(e.to_line===void 0||e.to_line===null)e.to_line=-1;else if(typeof e.to_line=="string"&&/\d+/.test(e.to_line)&&(e.to_line=parseInt(e.to_line)),Number.isInteger(e.to_line)){if(e.to_line<=0)throw new Error(`Invalid Option: to_line must be a positive integer greater than 0, got ${JSON.stringify(t.to_line)}`)}else throw new Error(`Invalid Option: to_line must be an integer, got ${JSON.stringify(t.to_line)}`);return e};var ci=function(t){return t.every(e=>e==null||e.toString&&e.toString().trim()==="")},dl=13,pl=10,xe={utf8:Buffer.from([239,187,191]),utf16le:Buffer.from([255,254])},ui=function(t={}){let e={bytes:0,comment_lines:0,empty_lines:0,invalid_field_length:0,lines:1,records:0},r=lr(t);return{info:e,original_options:t,options:r,state:ai(r),__needMoreData:function(n,i,s){if(s)return!1;let{encoding:o,escape:a,quote:l}=this.options,{quoting:c,needMoreDataSize:u,recordDelimiterMaxLength:f}=this.state,h=i-n-1,p=Math.max(u,f===0?Buffer.from(`\r
|
|
13
|
+
`,o).length:f,c?(a===null?0:a.length)+l.length:0,c?l.length+f:0);return h<p},parse:function(n,i,s,o){let{bom:a,comment_no_infix:l,encoding:c,from_line:u,ltrim:f,max_record_size:h,raw:p,relax_quotes:b,rtrim:d,skip_empty_lines:C,to:m,to_line:y}=this.options,{comment:S,escape:T,quote:A,record_delimiter:Z}=this.options,{bomSkipped:W,previousBuf:ee,rawBuffer:ze,escapeIsQuote:ut}=this.state,I;if(ee===void 0)if(n===void 0){o();return}else I=n;else ee!==void 0&&n===void 0?I=ee:I=Buffer.concat([ee,n]);if(W===!1)if(a===!1)this.state.bomSkipped=!0;else if(I.length<3){if(i===!1){this.state.previousBuf=I;return}}else{for(let M in xe)if(xe[M].compare(I,0,xe[M].length)===0){let ie=xe[M].length;this.state.bufBytesStart+=ie,I=I.slice(ie),this.options=lr({...this.original_options,encoding:M}),{comment:S,escape:T,quote:A}=this.options;break}this.state.bomSkipped=!0}let Zt=I.length,E;for(E=0;E<Zt&&!this.__needMoreData(E,Zt,i);E++){if(this.state.wasRowDelimiter===!0&&(this.info.lines++,this.state.wasRowDelimiter=!1),y!==-1&&this.info.lines>y){this.state.stop=!0,o();return}this.state.quoting===!1&&Z.length===0&&this.__autoDiscoverRecordDelimiter(I,E)&&(Z=this.options.record_delimiter);let M=I[E];if(p===!0&&ze.append(M),(M===dl||M===pl)&&this.state.wasRowDelimiter===!1&&(this.state.wasRowDelimiter=!0),this.state.escaping===!0)this.state.escaping=!1;else{if(T!==null&&this.state.quoting===!0&&this.__isEscape(I,E,M)&&E+T.length<Zt)if(ut){if(this.__isQuote(I,E+T.length)){this.state.escaping=!0,E+=T.length-1;continue}}else{this.state.escaping=!0,E+=T.length-1;continue}if(this.state.commenting===!1&&this.__isQuote(I,E))if(this.state.quoting===!0){let D=I[E+A.length],fe=d&&this.__isCharTrimable(I,E+A.length),te=S!==null&&this.__compareBytes(S,I,E+A.length,D),he=this.__isDelimiter(I,E+A.length,D),ft=Z.length===0?this.__autoDiscoverRecordDelimiter(I,E+A.length):this.__isRecordDelimiter(D,I,E+A.length);if(T!==null&&this.__isEscape(I,E,M)&&this.__isQuote(I,E+T.length))E+=T.length-1;else if(!D||he||ft||te||fe){this.state.quoting=!1,this.state.wasQuoting=!0,E+=A.length-1;continue}else if(b===!1){let zn=this.__error(new N("CSV_INVALID_CLOSING_QUOTE",["Invalid Closing Quote:",`got "${String.fromCharCode(D)}"`,`at line ${this.info.lines}`,"instead of delimiter, record delimiter, trimable character","(if activated) or comment"],this.options,this.__infoField()));if(zn!==void 0)return zn}else this.state.quoting=!1,this.state.wasQuoting=!0,this.state.field.prepend(A),E+=A.length-1}else if(this.state.field.length!==0){if(b===!1){let D=this.__infoField(),fe=Object.keys(xe).map(he=>xe[he].equals(this.state.field.toString())?he:!1).filter(Boolean)[0],te=this.__error(new N("INVALID_OPENING_QUOTE",["Invalid Opening Quote:",`a quote is found on field ${JSON.stringify(D.column)} at line ${D.lines}, value is ${JSON.stringify(this.state.field.toString(c))}`,fe?`(${fe} bom)`:void 0],this.options,D,{field:this.state.field}));if(te!==void 0)return te}}else{this.state.quoting=!0,E+=A.length-1;continue}if(this.state.quoting===!1){let D=this.__isRecordDelimiter(M,I,E);if(D!==0){if(this.state.commenting&&this.state.wasQuoting===!1&&this.state.record.length===0&&this.state.field.length===0)this.info.comment_lines++;else{if(this.state.enabled===!1&&this.info.lines+(this.state.wasRowDelimiter===!0?1:0)>=u){this.state.enabled=!0,this.__resetField(),this.__resetRecord(),E+=D-1;continue}if(C===!0&&this.state.wasQuoting===!1&&this.state.record.length===0&&this.state.field.length===0){this.info.empty_lines++,E+=D-1;continue}this.info.bytes=this.state.bufBytesStart+E;let he=this.__onField();if(he!==void 0)return he;this.info.bytes=this.state.bufBytesStart+E+D;let ft=this.__onRecord(s);if(ft!==void 0)return ft;if(m!==-1&&this.info.records>=m){this.state.stop=!0,o();return}}this.state.commenting=!1,E+=D-1;continue}if(this.state.commenting)continue;if(S!==null&&(l===!1||this.state.record.length===0&&this.state.field.length===0)&&this.__compareBytes(S,I,E,M)!==0){this.state.commenting=!0;continue}let fe=this.__isDelimiter(I,E,M);if(fe!==0){this.info.bytes=this.state.bufBytesStart+E;let te=this.__onField();if(te!==void 0)return te;E+=fe-1;continue}}}if(this.state.commenting===!1&&h!==0&&this.state.record_length+this.state.field.length>h)return this.__error(new N("CSV_MAX_RECORD_SIZE",["Max Record Size:","record exceed the maximum number of tolerated bytes",`of ${h}`,`at line ${this.info.lines}`],this.options,this.__infoField()));let ie=f===!1||this.state.quoting===!0||this.state.field.length!==0||!this.__isCharTrimable(I,E),el=d===!1||this.state.wasQuoting===!1;if(ie===!0&&el===!0)this.state.field.append(M);else{if(d===!0&&!this.__isCharTrimable(I,E))return this.__error(new N("CSV_NON_TRIMABLE_CHAR_AFTER_CLOSING_QUOTE",["Invalid Closing Quote:","found non trimable byte after quote",`at line ${this.info.lines}`],this.options,this.__infoField()));ie===!1&&(E+=this.__isCharTrimable(I,E)-1);continue}}if(i===!0)if(this.state.quoting===!0){let M=this.__error(new N("CSV_QUOTE_NOT_CLOSED",["Quote Not Closed:",`the parsing is finished with an opening quote at line ${this.info.lines}`],this.options,this.__infoField()));if(M!==void 0)return M}else if(this.state.wasQuoting===!0||this.state.record.length!==0||this.state.field.length!==0){this.info.bytes=this.state.bufBytesStart+E;let M=this.__onField();if(M!==void 0)return M;let ie=this.__onRecord(s);if(ie!==void 0)return ie}else this.state.wasRowDelimiter===!0?this.info.empty_lines++:this.state.commenting===!0&&this.info.comment_lines++;else this.state.bufBytesStart+=E,this.state.previousBuf=I.slice(E);this.state.wasRowDelimiter===!0&&(this.info.lines++,this.state.wasRowDelimiter=!1)},__onRecord:function(n){let{columns:i,group_columns_by_name:s,encoding:o,info:a,from:l,relax_column_count:c,relax_column_count_less:u,relax_column_count_more:f,raw:h,skip_records_with_empty_values:p}=this.options,{enabled:b,record:d}=this.state;if(b===!1)return this.__resetRecord();let C=d.length;if(i===!0){if(p===!0&&ci(d)){this.__resetRecord();return}return this.__firstLineToColumns(d)}if(i===!1&&this.info.records===0&&(this.state.expectedRecordLength=C),C!==this.state.expectedRecordLength){let m=i===!1?new N("CSV_RECORD_INCONSISTENT_FIELDS_LENGTH",["Invalid Record Length:",`expect ${this.state.expectedRecordLength},`,`got ${C} on line ${this.info.lines}`],this.options,this.__infoField(),{record:d}):new N("CSV_RECORD_INCONSISTENT_COLUMNS",["Invalid Record Length:",`columns length is ${i.length},`,`got ${C} on line ${this.info.lines}`],this.options,this.__infoField(),{record:d});if(c===!0||u===!0&&C<this.state.expectedRecordLength||f===!0&&C>this.state.expectedRecordLength)this.info.invalid_field_length++,this.state.error=m;else{let y=this.__error(m);if(y)return y}}if(p===!0&&ci(d)){this.__resetRecord();return}if(this.state.recordHasError===!0){this.__resetRecord(),this.state.recordHasError=!1;return}if(this.info.records++,l===1||this.info.records>=l){let{objname:m}=this.options;if(i!==!1){let y={};for(let S=0,T=d.length;S<T;S++)i[S]===void 0||i[S].disabled||(s===!0&&y[i[S].name]!==void 0?Array.isArray(y[i[S].name])?y[i[S].name]=y[i[S].name].concat(d[S]):y[i[S].name]=[y[i[S].name],d[S]]:y[i[S].name]=d[S]);if(h===!0||a===!0){let S=Object.assign({record:y},h===!0?{raw:this.state.rawBuffer.toString(o)}:{},a===!0?{info:this.__infoRecord()}:{}),T=this.__push(m===void 0?S:[y[m],S],n);if(T)return T}else{let S=this.__push(m===void 0?y:[y[m],y],n);if(S)return S}}else if(h===!0||a===!0){let y=Object.assign({record:d},h===!0?{raw:this.state.rawBuffer.toString(o)}:{},a===!0?{info:this.__infoRecord()}:{}),S=this.__push(m===void 0?y:[d[m],y],n);if(S)return S}else{let y=this.__push(m===void 0?d:[d[m],d],n);if(y)return y}}this.__resetRecord()},__firstLineToColumns:function(n){let{firstLineToHeaders:i}=this.state;try{let s=i===void 0?n:i.call(null,n);if(!Array.isArray(s))return this.__error(new N("CSV_INVALID_COLUMN_MAPPING",["Invalid Column Mapping:","expect an array from column function,",`got ${JSON.stringify(s)}`],this.options,this.__infoField(),{headers:s}));let o=gt(s);this.state.expectedRecordLength=o.length,this.options.columns=o,this.__resetRecord();return}catch(s){return s}},__resetRecord:function(){this.options.raw===!0&&this.state.rawBuffer.reset(),this.state.error=void 0,this.state.record=[],this.state.record_length=0},__onField:function(){let{cast:n,encoding:i,rtrim:s,max_record_size:o}=this.options,{enabled:a,wasQuoting:l}=this.state;if(a===!1)return this.__resetField();let c=this.state.field.toString(i);if(s===!0&&l===!1&&(c=c.trimRight()),n===!0){let[u,f]=this.__cast(c);if(u!==void 0)return u;c=f}this.state.record.push(c),o!==0&&typeof c=="string"&&(this.state.record_length+=c.length),this.__resetField()},__resetField:function(){this.state.field.reset(),this.state.wasQuoting=!1},__push:function(n,i){let{on_record:s}=this.options;if(s!==void 0){let o=this.__infoRecord();try{n=s.call(null,n,o)}catch(a){return a}if(n==null)return}i(n)},__cast:function(n){let{columns:i,relax_column_count:s}=this.options;if(Array.isArray(i)===!0&&s&&this.options.columns.length<=this.state.record.length)return[void 0,void 0];if(this.state.castField!==null)try{let a=this.__infoField();return[void 0,this.state.castField.call(null,n,a)]}catch(a){return[a]}if(this.__isFloat(n))return[void 0,parseFloat(n)];if(this.options.cast_date!==!1){let a=this.__infoField();return[void 0,this.options.cast_date.call(null,n,a)]}return[void 0,n]},__isCharTrimable:function(n,i){return((o,a)=>{let{timchars:l}=this.state;e:for(let c=0;c<l.length;c++){let u=l[c];for(let f=0;f<u.length;f++)if(u[f]!==o[a+f])continue e;return u.length}return 0})(n,i)},__isFloat:function(n){return n-parseFloat(n)+1>=0},__compareBytes:function(n,i,s,o){if(n[0]!==o)return 0;let a=n.length;for(let l=1;l<a;l++)if(n[l]!==i[s+l])return 0;return a},__isDelimiter:function(n,i,s){let{delimiter:o,ignore_last_delimiters:a}=this.options;if(a===!0&&this.state.record.length===this.options.columns.length-1)return 0;if(a!==!1&&typeof a=="number"&&this.state.record.length===a-1)return 0;e:for(let l=0;l<o.length;l++){let c=o[l];if(c[0]===s){for(let u=1;u<c.length;u++)if(c[u]!==n[i+u])continue e;return c.length}}return 0},__isRecordDelimiter:function(n,i,s){let{record_delimiter:o}=this.options,a=o.length;e:for(let l=0;l<a;l++){let c=o[l],u=c.length;if(c[0]===n){for(let f=1;f<u;f++)if(c[f]!==i[s+f])continue e;return c.length}}return 0},__isEscape:function(n,i,s){let{escape:o}=this.options;if(o===null)return!1;let a=o.length;if(o[0]===s){for(let l=0;l<a;l++)if(o[l]!==n[i+l])return!1;return!0}return!1},__isQuote:function(n,i){let{quote:s}=this.options;if(s===null)return!1;let o=s.length;for(let a=0;a<o;a++)if(s[a]!==n[i+a])return!1;return!0},__autoDiscoverRecordDelimiter:function(n,i){let{encoding:s}=this.options,o=[Buffer.from(`\r
|
|
14
|
+
`,s),Buffer.from(`
|
|
15
|
+
`,s),Buffer.from("\r",s)];e:for(let a=0;a<o.length;a++){let l=o[a].length;for(let c=0;c<l;c++)if(o[a][c]!==n[i+c])continue e;return this.options.record_delimiter.push(o[a]),this.state.recordDelimiterMaxLength=o[a].length,o[a].length}return 0},__error:function(n){let{encoding:i,raw:s,skip_records_with_error:o}=this.options,a=typeof n=="string"?new Error(n):n;if(o){this.state.recordHasError=!0,this.options.on_skip!==void 0&&this.options.on_skip(a,s?this.state.rawBuffer.toString(i):void 0);return}else return a},__infoDataSet:function(){return{...this.info,columns:this.options.columns}},__infoRecord:function(){let{columns:n,raw:i,encoding:s}=this.options;return{...this.__infoDataSet(),error:this.state.error,header:n===!0,index:this.state.record.length,raw:i?this.state.rawBuffer.toString(s):void 0}},__infoField:function(){let{columns:n}=this.options,i=Array.isArray(n);return{...this.__infoRecord(),column:i===!0?n.length>this.state.record.length?n[this.state.record.length].name:null:this.state.record.length,quoting:this.state.wasQuoting}}}};var fi=function(t,e={}){typeof t=="string"&&(t=Buffer.from(t));let r=e&&e.objname?{}:[],n=ui(e),i=l=>{n.options.objname===void 0?r.push(l):r[l[0]]=l[1]},s=()=>{},o=n.parse(t,!1,i,s);if(o!==void 0)throw o;let a=n.parse(void 0,!0,i,s);if(a!==void 0)throw a;return r};var cr=Ge(nl(),1);import{createRequire as ml}from"module";import bt from"path";var _l=(n=>(n[n.USD=0]="USD",n[n.ETH=1]="ETH",n[n.BTC=2]="BTC",n))(_l||{});function gl(t){let r=ml(import.meta.url).resolve(t),n=bt.dirname(r);for(;!hi.existsSync(bt.join(n,"package.json"));)n=bt.dirname(n);return n}var yt=class{USD_ORACLE_MAP=new Map;ETH_ORACLE_MAP=new Map;BTC_ORACLE_MAP=new Map;ASSETS_INFOS=new Map;chainId;constructor(e,r){this.chainId=r;let n=gl("@sentio/sdk"),i=bt.join(n,"src","utils",e),s=hi.readFileSync(i,{encoding:"utf-8"}),a=fi(s,{delimiter:",",columns:["Pair","Asset","Type","Address"],skip_empty_lines:!0});for(let l of a){let c=l.Pair.split("/"),u=c[0].trim().toLowerCase(),f=c[1].trim().toLowerCase(),h=l.Address.toLowerCase();f==="usd"?this.USD_ORACLE_MAP.set(u,h):f==="eth"?this.ETH_ORACLE_MAP.set(u,h):f=="btc"?this.BTC_ORACLE_MAP.set(u,h):console.error("wrong asset record:"+JSON.stringify(l))}}async getPrice(e,r="latest",n=0){let i=this.USD_ORACLE_MAP;switch(n){case 1:i=this.ETH_ORACLE_MAP;break;case 2:i=this.BTC_ORACLE_MAP;break;default:}e=e.trim().toLowerCase();let s=i.get(e);if(!s)return{error:"No price feed found for asset"};let o=Kn(this.chainId,s);try{let a=await o.latestAnswer({blockTag:r}),l=this.ASSETS_INFOS.get(e);return l||(l=Number(await o.decimals()),this.ASSETS_INFOS.set(e,l)),{price:dt(a,l).toNumber()}}catch(a){return{error:"Price query error for "+e+" failed at "+s+" at chain "+this.chainId+". Details: "+a.toString()}}}},_h=new yt("chainlink-oracles.csv",cr.EthChainId.ETHEREUM),gh=new yt("chainlink-oracles-sepolia.csv",cr.EthChainId.SEPOLIA);var g=Ge(tl(),1);function di(){return{symbol:void 0,address:void 0}}var O={encode(t,e=g.default.Writer.create()){return t.symbol!==void 0&&e.uint32(18).string(t.symbol),t.address!==void 0&&Ce.encode(t.address,e.uint32(26).fork()).ldelim(),e},decode(t,e){let r=t instanceof g.default.Reader?t:g.default.Reader.create(t),n=e===void 0?r.len:r.pos+e,i=di();for(;r.pos<n;){let s=r.uint32();switch(s>>>3){case 2:if(s!==18)break;i.symbol=r.string();continue;case 3:if(s!==26)break;i.address=Ce.decode(r,r.uint32());continue}if((s&7)===4||s===0)break;r.skipType(s&7)}return i},fromJSON(t){return{symbol:w(t.symbol)?globalThis.String(t.symbol):void 0,address:w(t.address)?Ce.fromJSON(t.address):void 0}},toJSON(t){let e={};return t.symbol!==void 0&&(e.symbol=t.symbol),t.address!==void 0&&(e.address=Ce.toJSON(t.address)),e},create(t){return O.fromPartial(t??{})},fromPartial(t){let e=di();return e.symbol=t.symbol??void 0,e.address=t.address!==void 0&&t.address!==null?Ce.fromPartial(t.address):void 0,e}};function pi(){return{address:"",chain:""}}var Ce={encode(t,e=g.default.Writer.create()){return t.address!==""&&e.uint32(10).string(t.address),t.chain!==""&&e.uint32(18).string(t.chain),e},decode(t,e){let r=t instanceof g.default.Reader?t:g.default.Reader.create(t),n=e===void 0?r.len:r.pos+e,i=pi();for(;r.pos<n;){let s=r.uint32();switch(s>>>3){case 1:if(s!==10)break;i.address=r.string();continue;case 2:if(s!==18)break;i.chain=r.string();continue}if((s&7)===4||s===0)break;r.skipType(s&7)}return i},fromJSON(t){return{address:w(t.address)?globalThis.String(t.address):"",chain:w(t.chain)?globalThis.String(t.chain):""}},toJSON(t){let e={};return t.address!==""&&(e.address=t.address),t.chain!==""&&(e.chain=t.chain),e},create(t){return Ce.fromPartial(t??{})},fromPartial(t){let e=pi();return e.address=t.address??"",e.chain=t.chain??"",e}};function mi(){return{timestamp:void 0,coinId:void 0,source:""}}var Ci={encode(t,e=g.default.Writer.create()){return t.timestamp!==void 0&&H.encode(vt(t.timestamp),e.uint32(10).fork()).ldelim(),t.coinId!==void 0&&O.encode(t.coinId,e.uint32(18).fork()).ldelim(),t.source!==""&&e.uint32(26).string(t.source),e},decode(t,e){let r=t instanceof g.default.Reader?t:g.default.Reader.create(t),n=e===void 0?r.len:r.pos+e,i=mi();for(;r.pos<n;){let s=r.uint32();switch(s>>>3){case 1:if(s!==10)break;i.timestamp=Je(H.decode(r,r.uint32()));continue;case 2:if(s!==18)break;i.coinId=O.decode(r,r.uint32());continue;case 3:if(s!==26)break;i.source=r.string();continue}if((s&7)===4||s===0)break;r.skipType(s&7)}return i},fromJSON(t){return{timestamp:w(t.timestamp)?St(t.timestamp):void 0,coinId:w(t.coinId)?O.fromJSON(t.coinId):void 0,source:w(t.source)?globalThis.String(t.source):""}},toJSON(t){let e={};return t.timestamp!==void 0&&(e.timestamp=t.timestamp.toISOString()),t.coinId!==void 0&&(e.coinId=O.toJSON(t.coinId)),t.source!==""&&(e.source=t.source),e},create(t){return Ci.fromPartial(t??{})},fromPartial(t){let e=mi();return e.timestamp=t.timestamp??void 0,e.coinId=t.coinId!==void 0&&t.coinId!==null?O.fromPartial(t.coinId):void 0,e.source=t.source??"",e}};function _i(){return{price:0,timestamp:void 0}}var de={encode(t,e=g.default.Writer.create()){return t.price!==0&&e.uint32(9).double(t.price),t.timestamp!==void 0&&H.encode(vt(t.timestamp),e.uint32(18).fork()).ldelim(),e},decode(t,e){let r=t instanceof g.default.Reader?t:g.default.Reader.create(t),n=e===void 0?r.len:r.pos+e,i=_i();for(;r.pos<n;){let s=r.uint32();switch(s>>>3){case 1:if(s!==9)break;i.price=r.double();continue;case 2:if(s!==18)break;i.timestamp=Je(H.decode(r,r.uint32()));continue}if((s&7)===4||s===0)break;r.skipType(s&7)}return i},fromJSON(t){return{price:w(t.price)?globalThis.Number(t.price):0,timestamp:w(t.timestamp)?St(t.timestamp):void 0}},toJSON(t){let e={};return t.price!==0&&(e.price=t.price),t.timestamp!==void 0&&(e.timestamp=t.timestamp.toISOString()),e},create(t){return de.fromPartial(t??{})},fromPartial(t){let e=_i();return e.price=t.price??0,e.timestamp=t.timestamp??void 0,e}};function gi(){return{timestamps:[],coinIds:[]}}var Ii={encode(t,e=g.default.Writer.create()){for(let r of t.timestamps)H.encode(vt(r),e.uint32(10).fork()).ldelim();for(let r of t.coinIds)O.encode(r,e.uint32(18).fork()).ldelim();return e},decode(t,e){let r=t instanceof g.default.Reader?t:g.default.Reader.create(t),n=e===void 0?r.len:r.pos+e,i=gi();for(;r.pos<n;){let s=r.uint32();switch(s>>>3){case 1:if(s!==10)break;i.timestamps.push(Je(H.decode(r,r.uint32())));continue;case 2:if(s!==18)break;i.coinIds.push(O.decode(r,r.uint32()));continue}if((s&7)===4||s===0)break;r.skipType(s&7)}return i},fromJSON(t){return{timestamps:globalThis.Array.isArray(t?.timestamps)?t.timestamps.map(e=>St(e)):[],coinIds:globalThis.Array.isArray(t?.coinIds)?t.coinIds.map(e=>O.fromJSON(e)):[]}},toJSON(t){let e={};return t.timestamps?.length&&(e.timestamps=t.timestamps.map(r=>r.toISOString())),t.coinIds?.length&&(e.coinIds=t.coinIds.map(r=>O.toJSON(r))),e},create(t){return Ii.fromPartial(t??{})},fromPartial(t){let e=gi();return e.timestamps=t.timestamps?.map(r=>r)||[],e.coinIds=t.coinIds?.map(r=>O.fromPartial(r))||[],e}};function bi(){return{prices:[]}}var Ai={encode(t,e=g.default.Writer.create()){for(let r of t.prices)Ie.encode(r,e.uint32(10).fork()).ldelim();return e},decode(t,e){let r=t instanceof g.default.Reader?t:g.default.Reader.create(t),n=e===void 0?r.len:r.pos+e,i=bi();for(;r.pos<n;){let s=r.uint32();switch(s>>>3){case 1:if(s!==10)break;i.prices.push(Ie.decode(r,r.uint32()));continue}if((s&7)===4||s===0)break;r.skipType(s&7)}return i},fromJSON(t){return{prices:globalThis.Array.isArray(t?.prices)?t.prices.map(e=>Ie.fromJSON(e)):[]}},toJSON(t){let e={};return t.prices?.length&&(e.prices=t.prices.map(r=>Ie.toJSON(r))),e},create(t){return Ai.fromPartial(t??{})},fromPartial(t){let e=bi();return e.prices=t.prices?.map(r=>Ie.fromPartial(r))||[],e}};function yi(){return{coinId:void 0,price:void 0,error:void 0}}var Ie={encode(t,e=g.default.Writer.create()){return t.coinId!==void 0&&O.encode(t.coinId,e.uint32(10).fork()).ldelim(),t.price!==void 0&&Ae.encode(t.price,e.uint32(18).fork()).ldelim(),t.error!==void 0&&e.uint32(26).string(t.error),e},decode(t,e){let r=t instanceof g.default.Reader?t:g.default.Reader.create(t),n=e===void 0?r.len:r.pos+e,i=yi();for(;r.pos<n;){let s=r.uint32();switch(s>>>3){case 1:if(s!==10)break;i.coinId=O.decode(r,r.uint32());continue;case 2:if(s!==18)break;i.price=Ae.decode(r,r.uint32());continue;case 3:if(s!==26)break;i.error=r.string();continue}if((s&7)===4||s===0)break;r.skipType(s&7)}return i},fromJSON(t){return{coinId:w(t.coinId)?O.fromJSON(t.coinId):void 0,price:w(t.price)?Ae.fromJSON(t.price):void 0,error:w(t.error)?globalThis.String(t.error):void 0}},toJSON(t){let e={};return t.coinId!==void 0&&(e.coinId=O.toJSON(t.coinId)),t.price!==void 0&&(e.price=Ae.toJSON(t.price)),t.error!==void 0&&(e.error=t.error),e},create(t){return Ie.fromPartial(t??{})},fromPartial(t){let e=yi();return e.coinId=t.coinId!==void 0&&t.coinId!==null?O.fromPartial(t.coinId):void 0,e.price=t.price!==void 0&&t.price!==null?Ae.fromPartial(t.price):void 0,e.error=t.error??void 0,e}};function vi(){return{results:[]}}var Ae={encode(t,e=g.default.Writer.create()){for(let r of t.results)de.encode(r,e.uint32(10).fork()).ldelim();return e},decode(t,e){let r=t instanceof g.default.Reader?t:g.default.Reader.create(t),n=e===void 0?r.len:r.pos+e,i=vi();for(;r.pos<n;){let s=r.uint32();switch(s>>>3){case 1:if(s!==10)break;i.results.push(de.decode(r,r.uint32()));continue}if((s&7)===4||s===0)break;r.skipType(s&7)}return i},fromJSON(t){return{results:globalThis.Array.isArray(t?.results)?t.results.map(e=>de.fromJSON(e)):[]}},toJSON(t){let e={};return t.results?.length&&(e.results=t.results.map(r=>de.toJSON(r))),e},create(t){return Ae.fromPartial(t??{})},fromPartial(t){let e=vi();return e.results=t.results?.map(r=>de.fromPartial(r))||[],e}};function Si(){return{limit:0,offset:0,searchQuery:"",chain:""}}var Pi={encode(t,e=g.default.Writer.create()){return t.limit!==0&&e.uint32(8).int32(t.limit),t.offset!==0&&e.uint32(16).int32(t.offset),t.searchQuery!==""&&e.uint32(26).string(t.searchQuery),t.chain!==""&&e.uint32(34).string(t.chain),e},decode(t,e){let r=t instanceof g.default.Reader?t:g.default.Reader.create(t),n=e===void 0?r.len:r.pos+e,i=Si();for(;r.pos<n;){let s=r.uint32();switch(s>>>3){case 1:if(s!==8)break;i.limit=r.int32();continue;case 2:if(s!==16)break;i.offset=r.int32();continue;case 3:if(s!==26)break;i.searchQuery=r.string();continue;case 4:if(s!==34)break;i.chain=r.string();continue}if((s&7)===4||s===0)break;r.skipType(s&7)}return i},fromJSON(t){return{limit:w(t.limit)?globalThis.Number(t.limit):0,offset:w(t.offset)?globalThis.Number(t.offset):0,searchQuery:w(t.searchQuery)?globalThis.String(t.searchQuery):"",chain:w(t.chain)?globalThis.String(t.chain):""}},toJSON(t){let e={};return t.limit!==0&&(e.limit=Math.round(t.limit)),t.offset!==0&&(e.offset=Math.round(t.offset)),t.searchQuery!==""&&(e.searchQuery=t.searchQuery),t.chain!==""&&(e.chain=t.chain),e},create(t){return Pi.fromPartial(t??{})},fromPartial(t){let e=Si();return e.limit=t.limit??0,e.offset=t.offset??0,e.searchQuery=t.searchQuery??"",e.chain=t.chain??"",e}};function Ei(){return{coins:[],coinAddressesInChain:{}}}var Ri={encode(t,e=g.default.Writer.create()){for(let r of t.coins)O.encode(r,e.uint32(10).fork()).ldelim();return Object.entries(t.coinAddressesInChain).forEach(([r,n])=>{ur.encode({key:r,value:n},e.uint32(18).fork()).ldelim()}),e},decode(t,e){let r=t instanceof g.default.Reader?t:g.default.Reader.create(t),n=e===void 0?r.len:r.pos+e,i=Ei();for(;r.pos<n;){let s=r.uint32();switch(s>>>3){case 1:if(s!==10)break;i.coins.push(O.decode(r,r.uint32()));continue;case 2:if(s!==18)break;let o=ur.decode(r,r.uint32());o.value!==void 0&&(i.coinAddressesInChain[o.key]=o.value);continue}if((s&7)===4||s===0)break;r.skipType(s&7)}return i},fromJSON(t){return{coins:globalThis.Array.isArray(t?.coins)?t.coins.map(e=>O.fromJSON(e)):[],coinAddressesInChain:bl(t.coinAddressesInChain)?Object.entries(t.coinAddressesInChain).reduce((e,[r,n])=>(e[r]=O.fromJSON(n),e),{}):{}}},toJSON(t){let e={};if(t.coins?.length&&(e.coins=t.coins.map(r=>O.toJSON(r))),t.coinAddressesInChain){let r=Object.entries(t.coinAddressesInChain);r.length>0&&(e.coinAddressesInChain={},r.forEach(([n,i])=>{e.coinAddressesInChain[n]=O.toJSON(i)}))}return e},create(t){return Ri.fromPartial(t??{})},fromPartial(t){let e=Ei();return e.coins=t.coins?.map(r=>O.fromPartial(r))||[],e.coinAddressesInChain=Object.entries(t.coinAddressesInChain??{}).reduce((r,[n,i])=>(i!==void 0&&(r[n]=O.fromPartial(i)),r),{}),e}};function Ni(){return{key:"",value:void 0}}var ur={encode(t,e=g.default.Writer.create()){return t.key!==""&&e.uint32(10).string(t.key),t.value!==void 0&&O.encode(t.value,e.uint32(18).fork()).ldelim(),e},decode(t,e){let r=t instanceof g.default.Reader?t:g.default.Reader.create(t),n=e===void 0?r.len:r.pos+e,i=Ni();for(;r.pos<n;){let s=r.uint32();switch(s>>>3){case 1:if(s!==10)break;i.key=r.string();continue;case 2:if(s!==18)break;i.value=O.decode(r,r.uint32());continue}if((s&7)===4||s===0)break;r.skipType(s&7)}return i},fromJSON(t){return{key:w(t.key)?globalThis.String(t.key):"",value:w(t.value)?O.fromJSON(t.value):void 0}},toJSON(t){let e={};return t.key!==""&&(e.key=t.key),t.value!==void 0&&(e.value=O.toJSON(t.value)),e},create(t){return ur.fromPartial(t??{})},fromPartial(t){let e=Ni();return e.key=t.key??"",e.value=t.value!==void 0&&t.value!==null?O.fromPartial(t.value):void 0,e}};function wi(){return{prices:[],latestPrice:void 0}}var Mi={encode(t,e=g.default.Writer.create()){for(let r of t.prices)G.encode(r,e.uint32(10).fork()).ldelim();return t.latestPrice!==void 0&&G.encode(t.latestPrice,e.uint32(18).fork()).ldelim(),e},decode(t,e){let r=t instanceof g.default.Reader?t:g.default.Reader.create(t),n=e===void 0?r.len:r.pos+e,i=wi();for(;r.pos<n;){let s=r.uint32();switch(s>>>3){case 1:if(s!==10)break;i.prices.push(G.decode(r,r.uint32()));continue;case 2:if(s!==18)break;i.latestPrice=G.decode(r,r.uint32());continue}if((s&7)===4||s===0)break;r.skipType(s&7)}return i},fromJSON(t){return{prices:globalThis.Array.isArray(t?.prices)?t.prices.map(e=>G.fromJSON(e)):[],latestPrice:w(t.latestPrice)?G.fromJSON(t.latestPrice):void 0}},toJSON(t){let e={};return t.prices?.length&&(e.prices=t.prices.map(r=>G.toJSON(r))),t.latestPrice!==void 0&&(e.latestPrice=G.toJSON(t.latestPrice)),e},create(t){return Mi.fromPartial(t??{})},fromPartial(t){let e=wi();return e.prices=t.prices?.map(r=>G.fromPartial(r))||[],e.latestPrice=t.latestPrice!==void 0&&t.latestPrice!==null?G.fromPartial(t.latestPrice):void 0,e}};function Oi(){return{coinId:void 0,price:0,timestamp:void 0}}var G={encode(t,e=g.default.Writer.create()){return t.coinId!==void 0&&O.encode(t.coinId,e.uint32(10).fork()).ldelim(),t.price!==0&&e.uint32(17).double(t.price),t.timestamp!==void 0&&H.encode(vt(t.timestamp),e.uint32(26).fork()).ldelim(),e},decode(t,e){let r=t instanceof g.default.Reader?t:g.default.Reader.create(t),n=e===void 0?r.len:r.pos+e,i=Oi();for(;r.pos<n;){let s=r.uint32();switch(s>>>3){case 1:if(s!==10)break;i.coinId=O.decode(r,r.uint32());continue;case 2:if(s!==17)break;i.price=r.double();continue;case 3:if(s!==26)break;i.timestamp=Je(H.decode(r,r.uint32()));continue}if((s&7)===4||s===0)break;r.skipType(s&7)}return i},fromJSON(t){return{coinId:w(t.coinId)?O.fromJSON(t.coinId):void 0,price:w(t.price)?globalThis.Number(t.price):0,timestamp:w(t.timestamp)?St(t.timestamp):void 0}},toJSON(t){let e={};return t.coinId!==void 0&&(e.coinId=O.toJSON(t.coinId)),t.price!==0&&(e.price=t.price),t.timestamp!==void 0&&(e.timestamp=t.timestamp.toISOString()),e},create(t){return G.fromPartial(t??{})},fromPartial(t){let e=Oi();return e.coinId=t.coinId!==void 0&&t.coinId!==null?O.fromPartial(t.coinId):void 0,e.price=t.price??0,e.timestamp=t.timestamp??void 0,e}};function Ti(){return{name:"",symbol:"",chain:"",address:"",coingeckoId:"",decimals:0,logoUrl:"",projectUrl:"",accountAddress:"",moduleName:"",structName:""}}var ki={encode(t,e=g.default.Writer.create()){return t.name!==""&&e.uint32(10).string(t.name),t.symbol!==""&&e.uint32(18).string(t.symbol),t.chain!==""&&e.uint32(26).string(t.chain),t.address!==""&&e.uint32(34).string(t.address),t.coingeckoId!==""&&e.uint32(42).string(t.coingeckoId),t.decimals!==0&&e.uint32(48).uint32(t.decimals),t.logoUrl!==""&&e.uint32(58).string(t.logoUrl),t.projectUrl!==""&&e.uint32(66).string(t.projectUrl),t.accountAddress!==""&&e.uint32(74).string(t.accountAddress),t.moduleName!==""&&e.uint32(82).string(t.moduleName),t.structName!==""&&e.uint32(90).string(t.structName),e},decode(t,e){let r=t instanceof g.default.Reader?t:g.default.Reader.create(t),n=e===void 0?r.len:r.pos+e,i=Ti();for(;r.pos<n;){let s=r.uint32();switch(s>>>3){case 1:if(s!==10)break;i.name=r.string();continue;case 2:if(s!==18)break;i.symbol=r.string();continue;case 3:if(s!==26)break;i.chain=r.string();continue;case 4:if(s!==34)break;i.address=r.string();continue;case 5:if(s!==42)break;i.coingeckoId=r.string();continue;case 6:if(s!==48)break;i.decimals=r.uint32();continue;case 7:if(s!==58)break;i.logoUrl=r.string();continue;case 8:if(s!==66)break;i.projectUrl=r.string();continue;case 9:if(s!==74)break;i.accountAddress=r.string();continue;case 10:if(s!==82)break;i.moduleName=r.string();continue;case 11:if(s!==90)break;i.structName=r.string();continue}if((s&7)===4||s===0)break;r.skipType(s&7)}return i},fromJSON(t){return{name:w(t.name)?globalThis.String(t.name):"",symbol:w(t.symbol)?globalThis.String(t.symbol):"",chain:w(t.chain)?globalThis.String(t.chain):"",address:w(t.address)?globalThis.String(t.address):"",coingeckoId:w(t.coingeckoId)?globalThis.String(t.coingeckoId):"",decimals:w(t.decimals)?globalThis.Number(t.decimals):0,logoUrl:w(t.logoUrl)?globalThis.String(t.logoUrl):"",projectUrl:w(t.projectUrl)?globalThis.String(t.projectUrl):"",accountAddress:w(t.accountAddress)?globalThis.String(t.accountAddress):"",moduleName:w(t.moduleName)?globalThis.String(t.moduleName):"",structName:w(t.structName)?globalThis.String(t.structName):""}},toJSON(t){let e={};return t.name!==""&&(e.name=t.name),t.symbol!==""&&(e.symbol=t.symbol),t.chain!==""&&(e.chain=t.chain),t.address!==""&&(e.address=t.address),t.coingeckoId!==""&&(e.coingeckoId=t.coingeckoId),t.decimals!==0&&(e.decimals=Math.round(t.decimals)),t.logoUrl!==""&&(e.logoUrl=t.logoUrl),t.projectUrl!==""&&(e.projectUrl=t.projectUrl),t.accountAddress!==""&&(e.accountAddress=t.accountAddress),t.moduleName!==""&&(e.moduleName=t.moduleName),t.structName!==""&&(e.structName=t.structName),e},create(t){return ki.fromPartial(t??{})},fromPartial(t){let e=Ti();return e.name=t.name??"",e.symbol=t.symbol??"",e.chain=t.chain??"",e.address=t.address??"",e.coingeckoId=t.coingeckoId??"",e.decimals=t.decimals??0,e.logoUrl=t.logoUrl??"",e.projectUrl=t.projectUrl??"",e.accountAddress=t.accountAddress??"",e.moduleName=t.moduleName??"",e.structName=t.structName??"",e}};function xi(){return{symbol:"",message:""}}var Li={encode(t,e=g.default.Writer.create()){return t.symbol!==""&&e.uint32(10).string(t.symbol),t.message!==""&&e.uint32(18).string(t.message),e},decode(t,e){let r=t instanceof g.default.Reader?t:g.default.Reader.create(t),n=e===void 0?r.len:r.pos+e,i=xi();for(;r.pos<n;){let s=r.uint32();switch(s>>>3){case 1:if(s!==10)break;i.symbol=r.string();continue;case 2:if(s!==18)break;i.message=r.string();continue}if((s&7)===4||s===0)break;r.skipType(s&7)}return i},fromJSON(t){return{symbol:w(t.symbol)?globalThis.String(t.symbol):"",message:w(t.message)?globalThis.String(t.message):""}},toJSON(t){let e={};return t.symbol!==""&&(e.symbol=t.symbol),t.message!==""&&(e.message=t.message),e},create(t){return Li.fromPartial(t??{})},fromPartial(t){let e=xi();return e.symbol=t.symbol??"",e.message=t.message??"",e}},Di={name:"PriceService",fullName:"price_service.PriceService",methods:{getPrice:{name:"GetPrice",requestType:Ci,requestStream:!1,responseType:de,responseStream:!1,options:{_unknownFields:{578365826:[new Uint8Array([16,18,14,47,97,112,105,47,118,49,47,112,114,105,99,101,115])]}}},batchGetPrices:{name:"BatchGetPrices",requestType:Ii,requestStream:!1,responseType:Ai,responseStream:!1,options:{_unknownFields:{578365826:[new Uint8Array([22,18,20,47,97,112,105,47,118,49,47,112,114,105,99,101,115,47,98,97,116,99,104])]}}},listCoins:{name:"ListCoins",requestType:Pi,requestStream:!1,responseType:Ri,responseStream:!1,options:{_unknownFields:{578365826:[new Uint8Array([22,18,20,47,97,112,105,47,118,49,47,112,114,105,99,101,115,47,99,111,105,110,115])]}}},checkLatestPrice:{name:"CheckLatestPrice",requestType:$n,requestStream:!1,responseType:Mi,responseStream:!1,options:{_unknownFields:{578365826:[new Uint8Array([29,18,27,47,97,112,105,47,118,49,47,112,114,105,99,101,115,47,99,104,101,99,107,95,108,97,116,101,115,116])]}}},backfillCoin:{name:"BackfillCoin",requestType:ki,requestStream:!1,responseType:Li,responseStream:!1,options:{_unknownFields:{578365826:[new Uint8Array([28,34,23,47,97,112,105,47,118,49,47,112,114,105,99,101,115,47,98,97,99,107,102,105,108,108,58,1,42])]}}}}};function vt(t){let e=BigInt(Math.trunc(t.getTime()/1e3)),r=t.getTime()%1e3*1e6;return{seconds:e,nanos:r}}function Je(t){let e=(globalThis.Number(t.seconds.toString())||0)*1e3;return e+=(t.nanos||0)/1e6,new globalThis.Date(e)}function St(t){return t instanceof globalThis.Date?t:typeof t=="string"?new globalThis.Date(t):Je(H.fromJSON(t))}function bl(t){return typeof t=="object"&&t!==null}function w(t){return t!=null}var Ee=Ge(rl(),1),Xa=Ge(Ha(),1),Ka=Ge(Ya(),1);import{Endpoints as Sf}from"@sentio/runtime";function Fn(t){t||(t=Sf.INSTANCE.priceFeedAPI);let e=(0,Ee.createChannel)(t);return(0,Ee.createClientFactory)().use((0,Xa.prometheusClientMiddleware)()).use(Ka.retryMiddleware).create(Di,e)}var Se=new oe({max:1e5,ttl:1e3*60*60}),Fe;async function Za(t,e,r){return Fe||(Fe=Fn()),Ef(Fe,t,e,r)}async function Ef(t,e,r,n){let i=Vn(e),s=Vn(new Date),o;r.symbol?o=`${r.symbol}-${i}`:o=`${r.address?.address}-${r.address?.chain}-${i}`;let a=Se.get(o);return a||(a=t.getPrice({timestamp:e,coinId:r},{retry:!0,retryMaxAttempts:5}).then(c=>{if(c.timestamp)if(Vn(c.timestamp)===s)Se.delete(o);else{let h=Math.abs(c.timestamp.getTime()-e.getTime())/(1e3*60*60*24),p=n?.toleranceInDays||2;if(h>p){Se.delete(o);return}}else Se.delete(o);return c.price}).catch(c=>{if(setTimeout(()=>{Se.delete(o)},1e3),c.code===Ee.Status.NOT_FOUND||c.code===Ee.Status.UNKNOWN){console.error("price not found for ",JSON.stringify(r)," at ",i);return}throw Se.delete(o),c}),Se.set(o,a),a)}async function Nf(t,e,r,n){return Za(r,{address:{chain:t,address:e}},n)}async function wf(t,e,r){return Za(e,{symbol:t},r)}function Vn(t){return[t.getUTCDate(),t.getUTCMonth()+1,t.getUTCFullYear()].join("-")}async function Of(t){Fe||(Fe=Fn());let e=await Fe.listCoins({chain:t,limit:1e3});return Object.entries(e.coinAddressesInChain).map(([r,n])=>(n.symbol=r,n))}async function Lm(t,e=!1){try{return await t}catch(r){if(r instanceof Hn||r.code==="CALL_EXCEPTION"||r.code==="BAD_DATA"){e&&console.error("eth call exception, return undefined",r);return}throw r}}export{Ya as a,Ha as b,Tf as c,Cf as d,si as e,_l as f,gl as g,_h as h,gh as i,Fn as j,Nf as k,wf as l,Of as m,Lm as n};
|
|
16
|
+
//# sourceMappingURL=chunk-XDCOG5SL.js.map
|