@coboot/headless 0.2.2-rc.6 → 0.2.2-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -21
- package/cli.mjs +33 -12
- package/daemon.mjs +21 -3
- package/entry.mjs +359 -352
- package/launcher.mjs +21 -3
- package/package.json +2 -1
- package/updater.mjs +6 -0
package/cli.mjs
CHANGED
|
@@ -1,16 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
2
|
+
import { createRequire as __runtimeCreateRequire } from "node:module"; const require = __runtimeCreateRequire(import.meta.url);
|
|
3
|
+
var kr=Object.defineProperty;var tc=Object.getOwnPropertyDescriptor;var rc=Object.getOwnPropertyNames;var nc=Object.prototype.hasOwnProperty;var v=(t,e)=>()=>(t&&(e=t(t=0)),e);var oc=(t,e)=>{for(var r in e)kr(t,r,{get:e[r],enumerable:!0})},ic=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of rc(e))!nc.call(t,i)&&i!==r&&kr(t,i,{get:()=>e[i],enumerable:!(n=tc(e,i))||n.enumerable});return t};var ac=t=>ic(kr({},"__esModule",{value:!0}),t);var fc,Ve,jr=v(()=>{"use strict";fc=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},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)}})(),Ve=(function(t){fc(e,t);function e(r,n,i){var o=t.call(this,r)||this;return o.name="OTLPExporterError",o.data=i,o.code=n,o}return e})(Error)});var j,$r=v(()=>{"use strict";j="1.9.1"});function hc(t){let e=new Set([t]),r=new Set,n=t.match(fo);if(!n)return()=>!1;let i={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(i.prerelease!=null)return function(l){return l===t};function o(c){return r.add(c),!1}function s(c){return e.add(c),!0}return function(l){if(e.has(l))return!0;if(r.has(l))return!1;let a=l.match(fo);if(!a)return o(l);let u={major:+a[1],minor:+a[2],patch:+a[3],prerelease:a[4]};return u.prerelease!=null||i.major!==u.major?o(l):i.major===0?i.minor===u.minor&&i.patch<=u.patch?s(l):o(l):i.minor<=u.minor?s(l):o(l)}}var fo,po,_o=v(()=>{"use strict";$r();fo=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;po=hc(j)});function ge(t,e,r,n=!1){var i;let o=Fe[He]=(i=Fe[He])!==null&&i!==void 0?i:{version:j};if(!n&&o[t]){let s=new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${t}`);return r.error(s.stack||s.message),!1}if(o.version!==j){let s=new Error(`@opentelemetry/api: Registration of version v${o.version} for ${t} does not match previously registered API v${j}`);return r.error(s.stack||s.message),!1}return o[t]=e,r.debug(`@opentelemetry/api: Registered a global for ${t} v${j}.`),!0}function $(t){var e,r;let n=(e=Fe[He])===null||e===void 0?void 0:e.version;if(!(!n||!po(n)))return(r=Fe[He])===null||r===void 0?void 0:r[t]}function ve(t,e){e.debug(`@opentelemetry/api: Unregistering a global for ${t} v${j}.`);let r=Fe[He];r&&delete r[t]}var Ec,He,Fe,je=v(()=>{"use strict";$r();_o();Ec=j.split(".")[0],He=Symbol.for(`opentelemetry.js.api.${Ec}`),Fe=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{}});function $e(t,e,r){let n=$("diag");if(n)return n[t](e,...r)}var wt,mo=v(()=>{"use strict";je();wt=class{constructor(e){this._namespace=e.namespace||"DiagComponentLogger"}debug(...e){return $e("debug",this._namespace,e)}error(...e){return $e("error",this._namespace,e)}info(...e){return $e("info",this._namespace,e)}warn(...e){return $e("warn",this._namespace,e)}verbose(...e){return $e("verbose",this._namespace,e)}}});var S,bt=v(()=>{"use strict";(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"})(S||(S={}))});function ho(t,e){t<S.NONE?t=S.NONE:t>S.ALL&&(t=S.ALL),e=e||{};function r(n,i){let o=e[n];return typeof o=="function"&&t>=i?o.bind(e):function(){}}return{error:r("error",S.ERROR),warn:r("warn",S.WARN),info:r("info",S.INFO),debug:r("debug",S.DEBUG),verbose:r("verbose",S.VERBOSE)}}var Eo=v(()=>{"use strict";bt()});var gc,M,Ke=v(()=>{"use strict";mo();Eo();bt();je();gc="diag",M=class t{static instance(){return this._instance||(this._instance=new t),this._instance}constructor(){function e(i){return function(...o){let s=$("diag");if(s)return s[i](...o)}}let r=this,n=(i,o={logLevel:S.INFO})=>{var s,c,l;if(i===r){let f=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((s=f.stack)!==null&&s!==void 0?s:f.message),!1}typeof o=="number"&&(o={logLevel:o});let a=$("diag"),u=ho((c=o.logLevel)!==null&&c!==void 0?c:S.INFO,i);if(a&&!o.suppressOverrideMessage){let f=(l=new Error().stack)!==null&&l!==void 0?l:"<failed to generate stacktrace>";a.warn(`Current logger will be overwritten from ${f}`),u.warn(`Current logger will overwrite one already registered from ${f}`)}return ge("diag",u,r,!0)};r.setLogger=n,r.disable=()=>{ve(gc,r)},r.createComponentLogger=i=>new wt(i),r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}}});var go,vo=v(()=>{"use strict";go=Symbol("BaggageEntryMetadata")});function Kr(t){return typeof t!="string"&&(vc.error(`Cannot create baggage metadata from unknown type: ${typeof t}`),t=""),{__TYPE__:go,toString(){return t}}}var vc,To=v(()=>{"use strict";Ke();vo();vc=M.instance()});function We(t){return Symbol.for(t)}var Wr,Yr,Pt=v(()=>{"use strict";Wr=class t{constructor(e){let r=this;r._currentContext=e?new Map(e):new Map,r.getValue=n=>r._currentContext.get(n),r.setValue=(n,i)=>{let o=new t(r._currentContext);return o._currentContext.set(n,i),o},r.deleteValue=n=>{let i=new t(r._currentContext);return i._currentContext.delete(n),i}}},Yr=new Wr});function rn(){return Tc}var Xr,Te,zr,Jr,Zr,qr,Ye,Qr,en,tn,Tc,Sc,yc,Ac,Oc,Rc,xc,Lc,So=v(()=>{"use strict";Xr=class{constructor(){}createGauge(e,r){return yc}createHistogram(e,r){return Ac}createCounter(e,r){return Sc}createUpDownCounter(e,r){return Oc}createObservableGauge(e,r){return xc}createObservableCounter(e,r){return Rc}createObservableUpDownCounter(e,r){return Lc}addBatchObservableCallback(e,r){}removeBatchObservableCallback(e){}},Te=class{},zr=class extends Te{add(e,r){}},Jr=class extends Te{add(e,r){}},Zr=class extends Te{record(e,r){}},qr=class extends Te{record(e,r){}},Ye=class{addCallback(e){}removeCallback(e){}},Qr=class extends Ye{},en=class extends Ye{},tn=class extends Ye{},Tc=new Xr,Sc=new zr,yc=new Zr,Ac=new qr,Oc=new Jr,Rc=new Qr,xc=new en,Lc=new tn});var L,yo=v(()=>{"use strict";(function(t){t[t.INT=0]="INT",t[t.DOUBLE=1]="DOUBLE"})(L||(L={}))});var Mt,Ao=v(()=>{"use strict";Pt();Mt=class{active(){return Yr}with(e,r,n,...i){return r.call(n,...i)}bind(e,r){return r}enable(){return this}disable(){return this}}});var nn,wc,z,It=v(()=>{"use strict";Ao();je();Ke();nn="context",wc=new Mt,z=class t{constructor(){}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalContextManager(e){return ge(nn,e,M.instance())}active(){return this._getContextManager().active()}with(e,r,n,...i){return this._getContextManager().with(e,r,n,...i)}bind(e,r){return this._getContextManager().bind(e,r)}_getContextManager(){return $(nn)||wc}disable(){this._getContextManager().disable(),ve(nn,M.instance())}}});var oe,on=v(()=>{"use strict";(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(oe||(oe={}))});var an,sn,Oo,cn=v(()=>{"use strict";on();an="0000000000000000",sn="00000000000000000000000000000000",Oo={traceId:sn,spanId:an,traceFlags:oe.NONE}});var V,Nt=v(()=>{"use strict";cn();V=class{constructor(e=Oo){this._spanContext=e}spanContext(){return this._spanContext}setAttribute(e,r){return this}setAttributes(e){return this}addEvent(e,r){return this}addLink(e){return this}addLinks(e){return this}setStatus(e){return this}updateName(e){return this}end(e){}isRecording(){return!1}recordException(e,r){}}});function Ct(t){return t.getValue(un)||void 0}function Ro(){return Ct(z.getInstance().active())}function Xe(t,e){return t.setValue(un,e)}function xo(t){return t.deleteValue(un)}function Lo(t,e){return Xe(t,new V(e))}function Ut(t){var e;return(e=Ct(t))===null||e===void 0?void 0:e.spanContext()}var un,ln=v(()=>{"use strict";Pt();Nt();It();un=We("OpenTelemetry Context Key SPAN")});function wo(t,e){if(typeof t!="string"||t.length!==e)return!1;let r=0;for(let n=0;n<t.length;n+=4)r+=(Dt[t.charCodeAt(n)]|0)+(Dt[t.charCodeAt(n+1)]|0)+(Dt[t.charCodeAt(n+2)]|0)+(Dt[t.charCodeAt(n+3)]|0);return r===e}function bo(t){return wo(t,32)&&t!==sn}function Po(t){return wo(t,16)&&t!==an}function ie(t){return bo(t.traceId)&&Po(t.spanId)}function Mo(t){return new V(t)}var Dt,Bt=v(()=>{"use strict";cn();Nt();Dt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1])});function bc(t){return t!==null&&typeof t=="object"&&"spanId"in t&&typeof t.spanId=="string"&&"traceId"in t&&typeof t.traceId=="string"&&"traceFlags"in t&&typeof t.traceFlags=="number"}var fn,Se,pn=v(()=>{"use strict";It();ln();Nt();Bt();fn=z.getInstance(),Se=class{startSpan(e,r,n=fn.active()){if(!!r?.root)return new V;let o=n&&Ut(n);return bc(o)&&ie(o)?new V(o):new V}startActiveSpan(e,r,n,i){let o,s,c;if(arguments.length<2)return;arguments.length===2?c=r:arguments.length===3?(o=r,c=n):(o=r,s=n,c=i);let l=s??fn.active(),a=this.startSpan(e,o,l),u=Xe(l,a);return fn.with(u,c,void 0,a)}}});var Pc,Gt,Io=v(()=>{"use strict";pn();Pc=new Se,Gt=class{constructor(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}startSpan(e,r,n){return this._getTracer().startSpan(e,r,n)}startActiveSpan(e,r,n,i){let o=this._getTracer();return Reflect.apply(o.startActiveSpan,o,arguments)}_getTracer(){if(this._delegate)return this._delegate;let e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):Pc}}});var Vt,No=v(()=>{"use strict";pn();Vt=class{getTracer(e,r,n){return new Se}}});var Mc,ze,Co=v(()=>{"use strict";Io();No();Mc=new Vt,ze=class{getTracer(e,r,n){var i;return(i=this.getDelegateTracer(e,r,n))!==null&&i!==void 0?i:new Gt(this,e,r,n)}getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Mc}setDelegate(e){this._delegate=e}getDelegateTracer(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getTracer(e,r,n)}}});var I,Uo=v(()=>{"use strict";It();I=z.getInstance()});var p,Do=v(()=>{"use strict";Ke();p=M.instance()});var _n,kt,Bo=v(()=>{"use strict";je();Co();Bt();ln();Ke();_n="trace",kt=class t{constructor(){this._proxyTracerProvider=new ze,this.wrapSpanContext=Mo,this.isSpanContextValid=ie,this.deleteSpan=xo,this.getSpan=Ct,this.getActiveSpan=Ro,this.getSpanContext=Ut,this.setSpan=Xe,this.setSpanContext=Lo}static getInstance(){return this._instance||(this._instance=new t),this._instance}setGlobalTracerProvider(e){let r=ge(_n,this._proxyTracerProvider,M.instance());return r&&this._proxyTracerProvider.setDelegate(e),r}getTracerProvider(){return $(_n)||this._proxyTracerProvider}getTracer(e,r){return this.getTracerProvider().getTracer(e,r)}disable(){ve(_n,M.instance()),this._proxyTracerProvider=new ze}}});var ae,Go=v(()=>{"use strict";Bo();ae=kt.getInstance()});var g=v(()=>{"use strict";To();Pt();bt();So();yo();on();Bt();Uo();Do();Go()});function Ca(t){var e=[429,502,503,504];return e.includes(t)}function Ua(t){if(t!=null){var e=Number.parseInt(t,10);if(Number.isInteger(e))return e>0?e*1e3:-1;var r=new Date(t).getTime()-Date.now();return r>=0?r:0}}var Da=v(()=>{"use strict"});var Va={};oc(Va,{compressAndSend:()=>Ga,createHttpAgent:()=>Kl,sendWithHttp:()=>jl});import*as Rr from"http";import*as xr from"https";import*as Ba from"zlib";import{Readable as Fl}from"stream";function jl(t,e,r,n,i){var o=new URL(t.url),s=Number(process.versions.node.split(".")[0]),c={hostname:o.hostname,port:o.port,path:o.pathname,method:"POST",headers:jn({},t.headers()),agent:e},l=o.protocol==="http:"?Rr.request:xr.request,a=l(c,function(f){var d=[];f.on("data",function(T){return d.push(T)}),f.on("end",function(){if(f.statusCode&&f.statusCode<299)n({status:"success",data:Buffer.concat(d)});else if(f.statusCode&&Ca(f.statusCode))n({status:"retryable",retryInMillis:Ua(f.headers["retry-after"])});else{var T=new Ve(f.statusMessage,f.statusCode,Buffer.concat(d).toString());n({status:"failure",error:T})}})});a.setTimeout(i,function(){a.destroy(),n({status:"failure",error:new Error("Request Timeout")})}),a.on("error",function(f){n({status:"failure",error:f})});var u=s>=14?"close":"abort";a.on(u,function(){n({status:"failure",error:new Error("Request timed out")})}),Ga(a,t.compression,r,function(f){n({status:"failure",error:f})})}function Ga(t,e,r,n){var i=$l(r);e==="gzip"&&(t.setHeader("Content-Encoding","gzip"),i=i.on("error",n).pipe(Ba.createGzip()).on("error",n)),i.pipe(t).on("error",n)}function $l(t){var e=new Fl;return e.push(t),e.push(null),e}function Kl(t,e){var r=new URL(t),n=r.protocol==="http:"?Rr.Agent:xr.Agent;return new n(e)}var jn,ka=v(()=>{"use strict";Da();jr();jn=function(){return jn=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},jn.apply(this,arguments)}});import Hf from"fs";import xs from"os";import Ff from"path";import{StringDecoder as jf}from"string_decoder";var sc=/\b(authorization|proxy-authorization|cookie|set-cookie)\s*:\s*[^\r\n]*/gi,cc=/\b(bearer|basic)\s+[A-Z0-9._~+/=-]+/gi,uc=/\b(authorization|proxy[-_]authorization|cookie|set[-_]cookie|credential[-_]grant|taihu[-_]auth[-_]grant|app[-_]publish[-_]grant|access[-_]token|refresh[-_]token|id[-_]token|token|api[-_]?key|password|secret)\b["']?\s*[:=]\s*(?:"[^"]*"|'[^']*'|[^\s,;&]+)/gi;function At(t){return(t instanceof Error?`${t.name}: ${t.message}`:String(t??"")).replace(sc,"$1: [redacted]").replace(cc,"$1 [redacted]").replace(uc,"$1=[redacted]").replace(/\s+/g," ").trim().slice(0,2e3)}function oo(t,e,r,n){let i=At(r),o=Object.fromEntries(Object.entries(n).map(([s,c])=>[s,At(c)]));if(Object.keys(o).length===0){t[e](i);return}t[e](i,o)}var Ue;(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TRACE=1]="TRACE",t[t.TRACE2=2]="TRACE2",t[t.TRACE3=3]="TRACE3",t[t.TRACE4=4]="TRACE4",t[t.DEBUG=5]="DEBUG",t[t.DEBUG2=6]="DEBUG2",t[t.DEBUG3=7]="DEBUG3",t[t.DEBUG4=8]="DEBUG4",t[t.INFO=9]="INFO",t[t.INFO2=10]="INFO2",t[t.INFO3=11]="INFO3",t[t.INFO4=12]="INFO4",t[t.WARN=13]="WARN",t[t.WARN2=14]="WARN2",t[t.WARN3=15]="WARN3",t[t.WARN4=16]="WARN4",t[t.ERROR=17]="ERROR",t[t.ERROR2=18]="ERROR2",t[t.ERROR3=19]="ERROR3",t[t.ERROR4=20]="ERROR4",t[t.FATAL=21]="FATAL",t[t.FATAL2=22]="FATAL2",t[t.FATAL3=23]="FATAL3",t[t.FATAL4=24]="FATAL4"})(Ue||(Ue={}));var Ot=(function(){function t(){}return t.prototype.emit=function(e){},t})();var De=new Ot;var lc=(function(){function t(){}return t.prototype.getLogger=function(e,r,n){return new Ot},t})();var Rt=new lc;var io=(function(){function t(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}return t.prototype.emit=function(e){this._getLogger().emit(e)},t.prototype._getLogger=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateLogger(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):De},t})();var Hr=(function(){function t(){}return t.prototype.getLogger=function(e,r,n){var i;return(i=this.getDelegateLogger(e,r,n))!==null&&i!==void 0?i:new io(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Rt},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateLogger=function(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getLogger(e,r,n)},t})();var xt=typeof globalThis=="object"?globalThis:global;var Be=Symbol.for("io.opentelemetry.js.api.logs"),Ee=xt;function ao(t,e,r){return function(n){return n===t?e:r}}var Fr=1;var so=(function(){function t(){this._proxyLoggerProvider=new Hr}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalLoggerProvider=function(e){return Ee[Be]?this.getLoggerProvider():(Ee[Be]=ao(Fr,e,Rt),this._proxyLoggerProvider.setDelegate(e),e)},t.prototype.getLoggerProvider=function(){var e,r;return(r=(e=Ee[Be])===null||e===void 0?void 0:e.call(Ee,Fr))!==null&&r!==void 0?r:this._proxyLoggerProvider},t.prototype.getLogger=function(e,r,n){return this.getLoggerProvider().getLogger(e,r,n)},t.prototype.disable=function(){delete Ee[Be],this._proxyLoggerProvider=new Hr},t})();var R_=so.getInstance();var Ge=(function(){function t(e){this._delegate=e}return t.prototype.export=function(e,r){this._delegate.export(e,r)},t.prototype.forceFlush=function(){return this._delegate.forceFlush()},t.prototype.shutdown=function(){return this._delegate.shutdown()},t})();function pc(t){if(!Number.isNaN(t)&&Number.isFinite(t)&&t>0)return t;throw new Error("Configuration: timeoutMillis is invalid, expected number greater than 0 (actual: '"+t+"')")}function Lt(t){if(t!=null)return function(){return t}}function co(t,e,r){var n,i,o,s,c,l;return{timeoutMillis:pc((i=(n=t.timeoutMillis)!==null&&n!==void 0?n:e.timeoutMillis)!==null&&i!==void 0?i:r.timeoutMillis),concurrencyLimit:(s=(o=t.concurrencyLimit)!==null&&o!==void 0?o:e.concurrencyLimit)!==null&&s!==void 0?s:r.concurrencyLimit,compression:(l=(c=t.compression)!==null&&c!==void 0?c:e.compression)!==null&&l!==void 0?l:r.compression}}function uo(){return{timeoutMillis:1e4,concurrencyLimit:30,compression:"none"}}var ke;(function(t){t.NONE="none",t.GZIP="gzip"})(ke||(ke={}));var _c=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{a(n.next(u))}catch(f){s(f)}}function l(u){try{a(n.throw(u))}catch(f){s(f)}}function a(u){u.done?o(u.value):i(u.value).then(c,l)}a((n=n.apply(t,e||[])).next())})},dc=function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(a){return function(u){return l([a,u])}}function l(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}o[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},mc=(function(){function t(e){this._sendingPromises=[],this._concurrencyLimit=e}return t.prototype.pushPromise=function(e){var r=this;if(this.hasReachedLimit())throw new Error("Concurrency Limit reached");this._sendingPromises.push(e);var n=function(){var i=r._sendingPromises.indexOf(e);r._sendingPromises.splice(i,1)};e.then(n,n)},t.prototype.hasReachedLimit=function(){return this._sendingPromises.length>=this._concurrencyLimit},t.prototype.awaitAll=function(){return _c(this,void 0,void 0,function(){return dc(this,function(e){switch(e.label){case 0:return[4,Promise.all(this._sendingPromises)];case 1:return e.sent(),[2]}})})},t})();function lo(t){return new mc(t.concurrencyLimit)}g();var Ic=We("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function Vo(t){return t.setValue(Ic,!0)}var ko="=",Ht=";",dn=",";var Ho=8192;g();var Nc=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o};function Fo(t){return t.reduce(function(e,r){var n=""+e+(e!==""?dn:"")+r;return n.length>Ho?e:n},"")}function jo(t){return t.getAllEntries().map(function(e){var r=Nc(e,2),n=r[0],i=r[1],o=encodeURIComponent(n)+"="+encodeURIComponent(i.value);return i.metadata!==void 0&&(o+=Ht+i.metadata.toString()),o})}function mn(t){var e=t.split(Ht);if(!(e.length<=0)){var r=e.shift();if(r){var n=r.indexOf(ko);if(!(n<=0)){var i=decodeURIComponent(r.substring(0,n).trim()),o=decodeURIComponent(r.substring(n+1).trim()),s;return e.length>0&&(s=Kr(e.join(Ht))),{key:i,value:o,metadata:s}}}}}function $o(t){return typeof t!="string"||t.length===0?{}:t.split(dn).map(function(e){return mn(e)}).filter(function(e){return e!==void 0&&e.value.length>0}).reduce(function(e,r){return e[r.key]=r.value,e},{})}var Cc=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.")};function Ft(t){return t==null?!0:Array.isArray(t)?Uc(t):Ko(t)}function Uc(t){var e,r,n;try{for(var i=Cc(t),o=i.next();!o.done;o=i.next()){var s=o.value;if(s!=null){if(!n){if(Ko(s)){n=typeof s;continue}return!1}if(typeof s!==n)return!1}}}catch(c){e={error:c}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return!0}function Ko(t){switch(typeof t){case"number":case"boolean":case"string":return!0}return!1}g();function Wo(){return function(t){p.error(Dc(t))}}function Dc(t){return typeof t=="string"?t:JSON.stringify(Bc(t))}function Bc(t){for(var e={},r=t;r!==null;)Object.getOwnPropertyNames(r).forEach(function(n){if(!e[n]){var i=r[n];i&&(e[n]=String(i))}}),r=Object.getPrototypeOf(r);return e}var Gc=Wo();function K(t){try{Gc(t)}catch{}}g();var jt;(function(t){t.AlwaysOff="always_off",t.AlwaysOn="always_on",t.ParentBasedAlwaysOff="parentbased_always_off",t.ParentBasedAlwaysOn="parentbased_always_on",t.ParentBasedTraceIdRatio="parentbased_traceidratio",t.TraceIdRatio="traceidratio"})(jt||(jt={}));var Vc=",",kc=["OTEL_SDK_DISABLED"];function Hc(t){return kc.indexOf(t)>-1}var Fc=["OTEL_BSP_EXPORT_TIMEOUT","OTEL_BSP_MAX_EXPORT_BATCH_SIZE","OTEL_BSP_MAX_QUEUE_SIZE","OTEL_BSP_SCHEDULE_DELAY","OTEL_BLRP_EXPORT_TIMEOUT","OTEL_BLRP_MAX_EXPORT_BATCH_SIZE","OTEL_BLRP_MAX_QUEUE_SIZE","OTEL_BLRP_SCHEDULE_DELAY","OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT","OTEL_ATTRIBUTE_COUNT_LIMIT","OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT","OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT","OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT","OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT","OTEL_SPAN_EVENT_COUNT_LIMIT","OTEL_SPAN_LINK_COUNT_LIMIT","OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT","OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT","OTEL_EXPORTER_OTLP_TIMEOUT","OTEL_EXPORTER_OTLP_TRACES_TIMEOUT","OTEL_EXPORTER_OTLP_METRICS_TIMEOUT","OTEL_EXPORTER_OTLP_LOGS_TIMEOUT","OTEL_EXPORTER_JAEGER_AGENT_PORT"];function jc(t){return Fc.indexOf(t)>-1}var $c=["OTEL_NO_PATCH_MODULES","OTEL_PROPAGATORS","OTEL_SEMCONV_STABILITY_OPT_IN"];function Kc(t){return $c.indexOf(t)>-1}var ye=1/0,Ae=128,Yo=128,Xo=128,$t={OTEL_SDK_DISABLED:!1,CONTAINER_NAME:"",ECS_CONTAINER_METADATA_URI_V4:"",ECS_CONTAINER_METADATA_URI:"",HOSTNAME:"",KUBERNETES_SERVICE_HOST:"",NAMESPACE:"",OTEL_BSP_EXPORT_TIMEOUT:3e4,OTEL_BSP_MAX_EXPORT_BATCH_SIZE:512,OTEL_BSP_MAX_QUEUE_SIZE:2048,OTEL_BSP_SCHEDULE_DELAY:5e3,OTEL_BLRP_EXPORT_TIMEOUT:3e4,OTEL_BLRP_MAX_EXPORT_BATCH_SIZE:512,OTEL_BLRP_MAX_QUEUE_SIZE:2048,OTEL_BLRP_SCHEDULE_DELAY:5e3,OTEL_EXPORTER_JAEGER_AGENT_HOST:"",OTEL_EXPORTER_JAEGER_AGENT_PORT:6832,OTEL_EXPORTER_JAEGER_ENDPOINT:"",OTEL_EXPORTER_JAEGER_PASSWORD:"",OTEL_EXPORTER_JAEGER_USER:"",OTEL_EXPORTER_OTLP_ENDPOINT:"",OTEL_EXPORTER_OTLP_TRACES_ENDPOINT:"",OTEL_EXPORTER_OTLP_METRICS_ENDPOINT:"",OTEL_EXPORTER_OTLP_LOGS_ENDPOINT:"",OTEL_EXPORTER_OTLP_HEADERS:"",OTEL_EXPORTER_OTLP_TRACES_HEADERS:"",OTEL_EXPORTER_OTLP_METRICS_HEADERS:"",OTEL_EXPORTER_OTLP_LOGS_HEADERS:"",OTEL_EXPORTER_OTLP_TIMEOUT:1e4,OTEL_EXPORTER_OTLP_TRACES_TIMEOUT:1e4,OTEL_EXPORTER_OTLP_METRICS_TIMEOUT:1e4,OTEL_EXPORTER_OTLP_LOGS_TIMEOUT:1e4,OTEL_EXPORTER_ZIPKIN_ENDPOINT:"http://localhost:9411/api/v2/spans",OTEL_LOG_LEVEL:S.INFO,OTEL_NO_PATCH_MODULES:[],OTEL_PROPAGATORS:["tracecontext","baggage"],OTEL_RESOURCE_ATTRIBUTES:"",OTEL_SERVICE_NAME:"",OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT:ye,OTEL_ATTRIBUTE_COUNT_LIMIT:Ae,OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT:ye,OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT:Ae,OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT:ye,OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT:Ae,OTEL_SPAN_EVENT_COUNT_LIMIT:128,OTEL_SPAN_LINK_COUNT_LIMIT:128,OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT:Yo,OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT:Xo,OTEL_TRACES_EXPORTER:"",OTEL_TRACES_SAMPLER:jt.ParentBasedAlwaysOn,OTEL_TRACES_SAMPLER_ARG:"",OTEL_LOGS_EXPORTER:"",OTEL_EXPORTER_OTLP_INSECURE:"",OTEL_EXPORTER_OTLP_TRACES_INSECURE:"",OTEL_EXPORTER_OTLP_METRICS_INSECURE:"",OTEL_EXPORTER_OTLP_LOGS_INSECURE:"",OTEL_EXPORTER_OTLP_CERTIFICATE:"",OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE:"",OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE:"",OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE:"",OTEL_EXPORTER_OTLP_COMPRESSION:"",OTEL_EXPORTER_OTLP_TRACES_COMPRESSION:"",OTEL_EXPORTER_OTLP_METRICS_COMPRESSION:"",OTEL_EXPORTER_OTLP_LOGS_COMPRESSION:"",OTEL_EXPORTER_OTLP_CLIENT_KEY:"",OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY:"",OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEY:"",OTEL_EXPORTER_OTLP_LOGS_CLIENT_KEY:"",OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE:"",OTEL_EXPORTER_OTLP_TRACES_CLIENT_CERTIFICATE:"",OTEL_EXPORTER_OTLP_METRICS_CLIENT_CERTIFICATE:"",OTEL_EXPORTER_OTLP_LOGS_CLIENT_CERTIFICATE:"",OTEL_EXPORTER_OTLP_PROTOCOL:"http/protobuf",OTEL_EXPORTER_OTLP_TRACES_PROTOCOL:"http/protobuf",OTEL_EXPORTER_OTLP_METRICS_PROTOCOL:"http/protobuf",OTEL_EXPORTER_OTLP_LOGS_PROTOCOL:"http/protobuf",OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE:"cumulative",OTEL_SEMCONV_STABILITY_OPT_IN:[]};function Wc(t,e,r){if(!(typeof r[t]>"u")){var n=String(r[t]);e[t]=n.toLowerCase()==="true"}}function Yc(t,e,r,n,i){if(n===void 0&&(n=-1/0),i===void 0&&(i=1/0),typeof r[t]<"u"){var o=Number(r[t]);isNaN(o)||(o<n?e[t]=n:o>i?e[t]=i:e[t]=o)}}function Xc(t,e,r,n){n===void 0&&(n=Vc);var i=r[t];typeof i=="string"&&(e[t]=i.split(n).map(function(o){return o.trim()}))}var zc={ALL:S.ALL,VERBOSE:S.VERBOSE,DEBUG:S.DEBUG,INFO:S.INFO,WARN:S.WARN,ERROR:S.ERROR,NONE:S.NONE};function Jc(t,e,r){var n=r[t];if(typeof n=="string"){var i=zc[n.toUpperCase()];i!=null&&(e[t]=i)}}function Kt(t){var e={};for(var r in $t){var n=r;switch(n){case"OTEL_LOG_LEVEL":Jc(n,e,t);break;default:if(Hc(n))Wc(n,e,t);else if(jc(n))Yc(n,e,t);else if(Kc(n))Xc(n,e,t);else{var i=t[n];typeof i<"u"&&i!==null&&(e[n]=String(i))}}}return e}function k(){var t=Kt(process.env);return Object.assign({},$t,t)}function Ze(){return Kt(process.env)}function zo(t){return t>=48&&t<=57?t-48:t>=97&&t<=102?t-87:t-55}function qe(t){for(var e=new Uint8Array(t.length/2),r=0,n=0;n<t.length;n+=2){var i=zo(t.charCodeAt(n)),o=zo(t.charCodeAt(n+1));e[r++]=i<<4|o}return e}import{performance as Zc}from"perf_hooks";var se=Zc;var Jo="1.30.1";var qc="process.runtime.name";var Qc="service.name";var eu="telemetry.sdk.name",tu="telemetry.sdk.language",ru="telemetry.sdk.version";var Zo=qc;var qo=Qc;var Qe=eu,et=tu,tt=ru;var nu="nodejs";var Qo=nu;var Oe,ce=(Oe={},Oe[Qe]="opentelemetry",Oe[Zo]="node",Oe[et]=Qo,Oe[tt]=Jo,Oe);function ue(t){t.unref()}var su=9,cu=6,uu=Math.pow(10,cu),hn=Math.pow(10,su);function U(t){var e=t/1e3,r=Math.trunc(e),n=Math.round(t%1e3*uu);return[r,n]}function En(){var t=se.timeOrigin;if(typeof t!="number"){var e=se;t=e.timing&&e.timing.fetchStart}return t}function ei(t){var e=U(En()),r=U(typeof t=="number"?t:se.now());return ri(e,r)}function Wt(t){if(ti(t))return t;if(typeof t=="number")return t<En()?ei(t):U(t);if(t instanceof Date)return U(t.getTime());throw TypeError("Invalid input type")}function gn(t){return t[0]*hn+t[1]}function J(t){return t[0]*1e6+t[1]/1e3}function ti(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="number"&&typeof t[1]=="number"}function ri(t,e){var r=[t[0]+e[0],t[1]+e[1]];return r[1]>=hn&&(r[1]-=hn,r[0]+=1),r}var x;(function(t){t[t.SUCCESS=0]="SUCCESS",t[t.FAILED=1]="FAILED"})(x||(x={}));var lu="[object Object]",fu="[object Null]",pu="[object Undefined]",_u=Function.prototype,ni=_u.toString,du=ni.call(Object),mu=hu(Object.getPrototypeOf,Object),oi=Object.prototype,ii=oi.hasOwnProperty,le=Symbol?Symbol.toStringTag:void 0,ai=oi.toString;function hu(t,e){return function(r){return t(e(r))}}function vn(t){if(!Eu(t)||gu(t)!==lu)return!1;var e=mu(t);if(e===null)return!0;var r=ii.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&ni.call(r)===du}function Eu(t){return t!=null&&typeof t=="object"}function gu(t){return t==null?t===void 0?pu:fu:le&&le in Object(t)?vu(t):Tu(t)}function vu(t){var e=ii.call(t,le),r=t[le],n=!1;try{t[le]=void 0,n=!0}catch{}var i=ai.call(t);return n&&(e?t[le]=r:delete t[le]),i}function Tu(t){return ai.call(t)}var Su=20;function Sn(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var r=t.shift(),n=new WeakMap;t.length>0;)r=ci(r,t.shift(),0,n);return r}function Tn(t){return Xt(t)?t.slice():t}function ci(t,e,r,n){r===void 0&&(r=0);var i;if(!(r>Su)){if(r++,Yt(t)||Yt(e)||ui(e))i=Tn(e);else if(Xt(t)){if(i=t.slice(),Xt(e))for(var o=0,s=e.length;o<s;o++)i.push(Tn(e[o]));else if(rt(e))for(var c=Object.keys(e),o=0,s=c.length;o<s;o++){var l=c[o];i[l]=Tn(e[l])}}else if(rt(t))if(rt(e)){if(!yu(t,e))return e;i=Object.assign({},t);for(var c=Object.keys(e),o=0,s=c.length;o<s;o++){var l=c[o],a=e[l];if(Yt(a))typeof a>"u"?delete i[l]:i[l]=a;else{var u=i[l],f=a;if(si(t,l,n)||si(e,l,n))delete i[l];else{if(rt(u)&&rt(f)){var d=n.get(u)||[],T=n.get(f)||[];d.push({obj:t,key:l}),T.push({obj:e,key:l}),n.set(u,d),n.set(f,T)}i[l]=ci(i[l],a,r,n)}}}}else i=e;return i}}function si(t,e,r){for(var n=r.get(t[e])||[],i=0,o=n.length;i<o;i++){var s=n[i];if(s.key===e&&s.obj===t)return!0}return!1}function Xt(t){return Array.isArray(t)}function ui(t){return typeof t=="function"}function rt(t){return!Yt(t)&&!Xt(t)&&!ui(t)&&typeof t=="object"}function Yt(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t>"u"||t instanceof Date||t instanceof RegExp||t===null}function yu(t,e){return!(!vn(t)||!vn(e))}var Au=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},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)}})(),li=(function(t){Au(e,t);function e(r){var n=t.call(this,r)||this;return Object.setPrototypeOf(n,e.prototype),n}return e})(Error);function nt(t,e){var r,n=new Promise(function(o,s){r=setTimeout(function(){s(new li("Operation timed out."))},e)});return Promise.race([t,n]).then(function(i){return clearTimeout(r),i},function(i){throw clearTimeout(r),i})}var fi=(function(){function t(){var e=this;this._promise=new Promise(function(r,n){e._resolve=r,e._reject=n})}return Object.defineProperty(t.prototype,"promise",{get:function(){return this._promise},enumerable:!1,configurable:!0}),t.prototype.resolve=function(e){this._resolve(e)},t.prototype.reject=function(e){this._reject(e)},t})();var Ou=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},Ru=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))},ot=(function(){function t(e,r){this._callback=e,this._that=r,this._isCalled=!1,this._deferred=new fi}return Object.defineProperty(t.prototype,"isCalled",{get:function(){return this._isCalled},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"promise",{get:function(){return this._deferred.promise},enumerable:!1,configurable:!0}),t.prototype.call=function(){for(var e,r=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];if(!this._isCalled){this._isCalled=!0;try{Promise.resolve((e=this._callback).call.apply(e,Ru([this._that],Ou(n),!1))).then(function(o){return r._deferred.resolve(o)},function(o){return r._deferred.reject(o)})}catch(o){this._deferred.reject(o)}}return this._deferred.promise},t})();g();function pi(t,e){return new Promise(function(r){I.with(Vo(I.active()),function(){t.export(e,function(n){r(n)})})})}var it={getKeyPairs:jo,serializeKeyPairs:Fo,parseKeyPairsIntoRecord:$o,parsePairKeyValue:mn},zt={_export:pi};jr();g();function xu(t){return Object.prototype.hasOwnProperty.call(t,"partialSuccess")}function _i(){return{handleResponse:function(t){t==null||!xu(t)||t.partialSuccess==null||Object.keys(t.partialSuccess).length===0||p.warn("Received Partial Success response:",JSON.stringify(t.partialSuccess))}}}g();var Lu=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{a(n.next(u))}catch(f){s(f)}}function l(u){try{a(n.throw(u))}catch(f){s(f)}}function a(u){u.done?o(u.value):i(u.value).then(c,l)}a((n=n.apply(t,e||[])).next())})},wu=function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(a){return function(u){return l([a,u])}}function l(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}o[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},bu=(function(){function t(e,r,n,i,o){this._transport=e,this._serializer=r,this._responseHandler=n,this._promiseQueue=i,this._timeout=o,this._diagLogger=p.createComponentLogger({namespace:"OTLPExportDelegate"})}return t.prototype.export=function(e,r){var n=this;if(this._diagLogger.debug("items to be sent",e),this._promiseQueue.hasReachedLimit()){r({code:x.FAILED,error:new Error("Concurrent export limit reached")});return}var i=this._serializer.serializeRequest(e);if(i==null){r({code:x.FAILED,error:new Error("Nothing to send")});return}this._promiseQueue.pushPromise(this._transport.send(i,this._timeout).then(function(o){if(o.status==="success"){if(o.data!=null)try{n._responseHandler.handleResponse(n._serializer.deserializeResponse(o.data))}catch(s){n._diagLogger.warn("Export succeeded but could not deserialize response - is the response specification compliant?",s,o.data)}r({code:x.SUCCESS});return}else if(o.status==="failure"&&o.error){r({code:x.FAILED,error:o.error});return}else o.status==="retryable"?r({code:x.FAILED,error:new Ve("Export failed with retryable status")}):r({code:x.FAILED,error:new Ve("Export failed with unknown error")})},function(o){return r({code:x.FAILED,error:o})}))},t.prototype.forceFlush=function(){return this._promiseQueue.awaitAll()},t.prototype.shutdown=function(){return Lu(this,void 0,void 0,function(){return wu(this,function(e){switch(e.label){case 0:return this._diagLogger.debug("shutdown started"),[4,this.forceFlush()];case 1:return e.sent(),this._transport.shutdown(),[2]}})})},t})();function di(t,e){return new bu(t.transport,t.serializer,_i(),t.promiseHandler,e.timeout)}function hi(t){var e=BigInt(1e9);return BigInt(t[0])*e+BigInt(t[1])}function Pu(t){var e=Number(BigInt.asUintN(32,t)),r=Number(BigInt.asUintN(32,t>>BigInt(32)));return{low:e,high:r}}function Ei(t){var e=hi(t);return Pu(e)}function Mu(t){var e=hi(t);return e.toString()}var Iu=typeof BigInt<"u"?Mu:gn;function mi(t){return t}function gi(t){if(t!==void 0)return qe(t)}var Nu={encodeHrTime:Ei,encodeSpanContext:qe,encodeOptionalSpanContext:gi};function Jt(t){var e,r;if(t===void 0)return Nu;var n=(e=t.useLongBits)!==null&&e!==void 0?e:!0,i=(r=t.useHex)!==null&&r!==void 0?r:!1;return{encodeHrTime:n?Ei:Iu,encodeSpanContext:i?mi:qe,encodeOptionalSpanContext:i?mi:gi}}var Cu=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o};function Zt(t){return{attributes:at(t.attributes),droppedAttributesCount:0}}function qt(t){return{name:t.name,version:t.version}}function at(t){return Object.keys(t).map(function(e){return Qt(e,t[e])})}function Qt(t,e){return{key:t,value:er(e)}}function er(t){var e=typeof t;return e==="string"?{stringValue:t}:e==="number"?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:e==="boolean"?{boolValue:t}:t instanceof Uint8Array?{bytesValue:t}:Array.isArray(t)?{arrayValue:{values:t.map(er)}}:e==="object"&&t!=null?{kvlistValue:{values:Object.entries(t).map(function(r){var n=Cu(r,2),i=n[0],o=n[1];return Qt(i,o)})}}:{}}var Uu=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.")},vi=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o};function Ti(t,e){var r=Jt(e);return{resourceLogs:Bu(t,r)}}function Du(t){var e,r,n=new Map;try{for(var i=Uu(t),o=i.next();!o.done;o=i.next()){var s=o.value,c=s.resource,l=s.instrumentationScope,a=l.name,u=l.version,f=u===void 0?"":u,d=l.schemaUrl,T=d===void 0?"":d,C=n.get(c);C||(C=new Map,n.set(c,C));var ne=a+"@"+f+":"+T,he=C.get(ne);he||(he=[],C.set(ne,he)),he.push(s)}}catch(yt){e={error:yt}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return n}function Bu(t,e){var r=Du(t);return Array.from(r,function(n){var i=vi(n,2),o=i[0],s=i[1];return{resource:Zt(o),scopeLogs:Array.from(s,function(c){var l=vi(c,2),a=l[1];return{scope:qt(a[0].instrumentationScope),logRecords:a.map(function(u){return Gu(u,e)}),schemaUrl:a[0].instrumentationScope.schemaUrl}}),schemaUrl:void 0}})}function Gu(t,e){var r,n,i;return{timeUnixNano:e.encodeHrTime(t.hrTime),observedTimeUnixNano:e.encodeHrTime(t.hrTimeObserved),severityNumber:t.severityNumber,severityText:t.severityText,body:er(t.body),attributes:Vu(t.attributes),droppedAttributesCount:t.droppedAttributesCount,flags:(r=t.spanContext)===null||r===void 0?void 0:r.traceFlags,traceId:e.encodeOptionalSpanContext((n=t.spanContext)===null||n===void 0?void 0:n.traceId),spanId:e.encodeOptionalSpanContext((i=t.spanContext)===null||i===void 0?void 0:i.spanId)}}function Vu(t){return Object.keys(t).map(function(e){return Qt(e,t[e])})}g();var R;(function(t){t[t.DELTA=0]="DELTA",t[t.CUMULATIVE=1]="CUMULATIVE"})(R||(R={}));var w;(function(t){t[t.HISTOGRAM=0]="HISTOGRAM",t[t.EXPONENTIAL_HISTOGRAM=1]="EXPONENTIAL_HISTOGRAM",t[t.GAUGE=2]="GAUGE",t[t.SUM=3]="SUM"})(w||(w={}));g();var ku=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},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)}})(),Si=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{a(n.next(u))}catch(f){s(f)}}function l(u){try{a(n.throw(u))}catch(f){s(f)}}function a(u){u.done?o(u.value):i(u.value).then(c,l)}a((n=n.apply(t,e||[])).next())})},yi=function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(a){return function(u){return l([a,u])}}function l(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}o[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},Hu=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},Fu=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))},ju=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.")};function Ai(t){return t!=null}function tr(t){var e=Object.keys(t);return e.length===0?"":(e=e.sort(),JSON.stringify(e.map(function(r){return[r,t[r]]})))}function Oi(t){var e,r;return t.name+":"+((e=t.version)!==null&&e!==void 0?e:"")+":"+((r=t.schemaUrl)!==null&&r!==void 0?r:"")}var yn=(function(t){ku(e,t);function e(r){var n=t.call(this,r)||this;return Object.setPrototypeOf(n,e.prototype),n}return e})(Error);function Z(t,e){var r,n=new Promise(function(o,s){r=setTimeout(function(){s(new yn("Operation timed out."))},e)});return Promise.race([t,n]).then(function(i){return clearTimeout(r),i},function(i){throw clearTimeout(r),i})}function Ri(t){return Si(this,void 0,void 0,function(){var e=this;return yi(this,function(r){return[2,Promise.all(t.map(function(n){return Si(e,void 0,void 0,function(){var i,o;return yi(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,n];case 1:return i=s.sent(),[2,{status:"fulfilled",value:i}];case 2:return o=s.sent(),[2,{status:"rejected",reason:o}];case 3:return[2]}})})}))]})})}function xi(t){return t.status==="rejected"}function An(t,e){var r=[];return t.forEach(function(n){r.push.apply(r,Fu([],Hu(e(n)),!1))}),r}function Li(t,e){var r,n;if(t.size!==e.size)return!1;try{for(var i=ju(t),o=i.next();!o.done;o=i.next()){var s=o.value;if(!e.has(s))return!1}}catch(c){r={error:c}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return!0}function wi(t,e){for(var r=0,n=t.length-1,i=t.length;n>=r;){var o=r+Math.trunc((n-r)/2);t[o]<e?r=o+1:(i=o,n=o-1)}return i}function bi(t,e){return t.toLowerCase()===e.toLowerCase()}g();var N;(function(t){t[t.DROP=0]="DROP",t[t.SUM=1]="SUM",t[t.LAST_VALUE=2]="LAST_VALUE",t[t.HISTOGRAM=3]="HISTOGRAM",t[t.EXPONENTIAL_HISTOGRAM=4]="EXPONENTIAL_HISTOGRAM"})(N||(N={}));var On=(function(){function t(){this.kind=N.DROP}return t.prototype.createAccumulation=function(){},t.prototype.merge=function(e,r){},t.prototype.diff=function(e,r){},t.prototype.toMetricData=function(e,r,n,i){},t})();g();var _;(function(t){t.COUNTER="COUNTER",t.GAUGE="GAUGE",t.HISTOGRAM="HISTOGRAM",t.UP_DOWN_COUNTER="UP_DOWN_COUNTER",t.OBSERVABLE_COUNTER="OBSERVABLE_COUNTER",t.OBSERVABLE_GAUGE="OBSERVABLE_GAUGE",t.OBSERVABLE_UP_DOWN_COUNTER="OBSERVABLE_UP_DOWN_COUNTER"})(_||(_={}));function H(t,e,r){var n,i,o,s;return Ku(t)||p.warn('Invalid metric name: "'+t+'". The metric name should be a ASCII string with a length no greater than 255 characters.'),{name:t,type:e,description:(n=r?.description)!==null&&n!==void 0?n:"",unit:(i=r?.unit)!==null&&i!==void 0?i:"",valueType:(o=r?.valueType)!==null&&o!==void 0?o:L.DOUBLE,advice:(s=r?.advice)!==null&&s!==void 0?s:{}}}function Pi(t,e){var r,n;return{name:(r=t.name)!==null&&r!==void 0?r:e.name,description:(n=t.description)!==null&&n!==void 0?n:e.description,type:e.type,unit:e.unit,valueType:e.valueType,advice:e.advice}}function Mi(t,e){return bi(t.name,e.name)&&t.unit===e.unit&&t.type===e.type&&t.valueType===e.valueType}var $u=/^[a-z][a-z0-9_.\-/]{0,254}$/i;function Ku(t){return t.match($u)!=null}var Wu=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o};function Yu(t){var e=t.map(function(){return 0});return e.push(0),{buckets:{boundaries:t,counts:e},sum:0,count:0,hasMinMax:!1,min:1/0,max:-1/0}}var rr=(function(){function t(e,r,n,i){n===void 0&&(n=!0),i===void 0&&(i=Yu(r)),this.startTime=e,this._boundaries=r,this._recordMinMax=n,this._current=i}return t.prototype.record=function(e){if(!Number.isNaN(e)){this._current.count+=1,this._current.sum+=e,this._recordMinMax&&(this._current.min=Math.min(e,this._current.min),this._current.max=Math.max(e,this._current.max),this._current.hasMinMax=!0);var r=wi(this._boundaries,e);this._current.buckets.counts[r]+=1}},t.prototype.setStartTime=function(e){this.startTime=e},t.prototype.toPointValue=function(){return this._current},t})();var nr=(function(){function t(e,r){this._boundaries=e,this._recordMinMax=r,this.kind=N.HISTOGRAM}return t.prototype.createAccumulation=function(e){return new rr(e,this._boundaries,this._recordMinMax)},t.prototype.merge=function(e,r){for(var n=e.toPointValue(),i=r.toPointValue(),o=n.buckets.counts,s=i.buckets.counts,c=new Array(o.length),l=0;l<o.length;l++)c[l]=o[l]+s[l];var a=1/0,u=-1/0;return this._recordMinMax&&(n.hasMinMax&&i.hasMinMax?(a=Math.min(n.min,i.min),u=Math.max(n.max,i.max)):n.hasMinMax?(a=n.min,u=n.max):i.hasMinMax&&(a=i.min,u=i.max)),new rr(e.startTime,n.buckets.boundaries,this._recordMinMax,{buckets:{boundaries:n.buckets.boundaries,counts:c},count:n.count+i.count,sum:n.sum+i.sum,hasMinMax:this._recordMinMax&&(n.hasMinMax||i.hasMinMax),min:a,max:u})},t.prototype.diff=function(e,r){for(var n=e.toPointValue(),i=r.toPointValue(),o=n.buckets.counts,s=i.buckets.counts,c=new Array(o.length),l=0;l<o.length;l++)c[l]=s[l]-o[l];return new rr(r.startTime,n.buckets.boundaries,this._recordMinMax,{buckets:{boundaries:n.buckets.boundaries,counts:c},count:i.count-n.count,sum:i.sum-n.sum,hasMinMax:!1,min:1/0,max:-1/0})},t.prototype.toMetricData=function(e,r,n,i){return{descriptor:e,aggregationTemporality:r,dataPointType:w.HISTOGRAM,dataPoints:n.map(function(o){var s=Wu(o,2),c=s[0],l=s[1],a=l.toPointValue(),u=e.type===_.GAUGE||e.type===_.UP_DOWN_COUNTER||e.type===_.OBSERVABLE_GAUGE||e.type===_.OBSERVABLE_UP_DOWN_COUNTER;return{attributes:c,startTime:l.startTime,endTime:i,value:{min:a.hasMinMax?a.min:void 0,max:a.hasMinMax?a.max:void 0,sum:u?void 0:a.sum,buckets:a.buckets,count:a.count}}})}},t})();g();var Rn=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},xn=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))},Ln=(function(){function t(e,r,n,i){e===void 0&&(e=new Xu),r===void 0&&(r=0),n===void 0&&(n=0),i===void 0&&(i=0),this.backing=e,this.indexBase=r,this.indexStart=n,this.indexEnd=i}return Object.defineProperty(t.prototype,"offset",{get:function(){return this.indexStart},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this.backing.length===0||this.indexEnd===this.indexStart&&this.at(0)===0?0:this.indexEnd-this.indexStart+1},enumerable:!1,configurable:!0}),t.prototype.counts=function(){var e=this;return Array.from({length:this.length},function(r,n){return e.at(n)})},t.prototype.at=function(e){var r=this.indexBase-this.indexStart;return e<r&&(e+=this.backing.length),e-=r,this.backing.countAt(e)},t.prototype.incrementBucket=function(e,r){this.backing.increment(e,r)},t.prototype.decrementBucket=function(e,r){this.backing.decrement(e,r)},t.prototype.trim=function(){for(var e=0;e<this.length;e++)if(this.at(e)!==0){this.indexStart+=e;break}else if(e===this.length-1){this.indexStart=this.indexEnd=this.indexBase=0;return}for(var e=this.length-1;e>=0;e--)if(this.at(e)!==0){this.indexEnd-=this.length-e-1;break}this._rotate()},t.prototype.downscale=function(e){this._rotate();for(var r=1+this.indexEnd-this.indexStart,n=1<<e,i=0,o=0,s=this.indexStart;s<=this.indexEnd;){var c=s%n;c<0&&(c+=n);for(var l=c;l<n&&i<r;l++)this._relocateBucket(o,i),i++,s++;o++}this.indexStart>>=e,this.indexEnd>>=e,this.indexBase=this.indexStart},t.prototype.clone=function(){return new t(this.backing.clone(),this.indexBase,this.indexStart,this.indexEnd)},t.prototype._rotate=function(){var e=this.indexBase-this.indexStart;e!==0&&(e>0?(this.backing.reverse(0,this.backing.length),this.backing.reverse(0,e),this.backing.reverse(e,this.backing.length)):(this.backing.reverse(0,this.backing.length),this.backing.reverse(0,this.backing.length+e)),this.indexBase=this.indexStart)},t.prototype._relocateBucket=function(e,r){e!==r&&this.incrementBucket(e,this.backing.emptyBucket(r))},t})();var Xu=(function(){function t(e){e===void 0&&(e=[0]),this._counts=e}return Object.defineProperty(t.prototype,"length",{get:function(){return this._counts.length},enumerable:!1,configurable:!0}),t.prototype.countAt=function(e){return this._counts[e]},t.prototype.growTo=function(e,r,n){var i=new Array(e).fill(0);i.splice.apply(i,xn([n,this._counts.length-r],Rn(this._counts.slice(r)),!1)),i.splice.apply(i,xn([0,r],Rn(this._counts.slice(0,r)),!1)),this._counts=i},t.prototype.reverse=function(e,r){for(var n=Math.floor((e+r)/2)-e,i=0;i<n;i++){var o=this._counts[e+i];this._counts[e+i]=this._counts[r-i-1],this._counts[r-i-1]=o}},t.prototype.emptyBucket=function(e){var r=this._counts[e];return this._counts[e]=0,r},t.prototype.increment=function(e,r){this._counts[e]+=r},t.prototype.decrement=function(e,r){this._counts[e]>=r?this._counts[e]-=r:this._counts[e]=0},t.prototype.clone=function(){return new t(xn([],Rn(this._counts),!1))},t})();var Ii=52,zu=2146435072,Ju=1048575,wn=1023,or=-wn+1,ir=wn,st=Math.pow(2,-1022);function ar(t){var e=new DataView(new ArrayBuffer(8));e.setFloat64(0,t);var r=e.getUint32(0),n=(r&zu)>>20;return n-wn}function sr(t){var e=new DataView(new ArrayBuffer(8));e.setFloat64(0,t);var r=e.getUint32(0),n=e.getUint32(4),i=(r&Ju)*Math.pow(2,32);return i+n}function ct(t,e){return t===0||t===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY||Number.isNaN(t)?t:t*Math.pow(2,e)}function Ci(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t}var Zu=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},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)}})(),q=(function(t){Zu(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e})(Error);var Di=(function(){function t(e){this._shift=-e}return t.prototype.mapToIndex=function(e){if(e<st)return this._minNormalLowerBoundaryIndex();var r=ar(e),n=this._rightShift(sr(e)-1,Ii);return r+n>>this._shift},t.prototype.lowerBoundary=function(e){var r=this._minNormalLowerBoundaryIndex();if(e<r)throw new q("underflow: "+e+" is < minimum lower boundary: "+r);var n=this._maxNormalLowerBoundaryIndex();if(e>n)throw new q("overflow: "+e+" is > maximum lower boundary: "+n);return ct(1,e<<this._shift)},Object.defineProperty(t.prototype,"scale",{get:function(){return this._shift===0?0:-this._shift},enumerable:!1,configurable:!0}),t.prototype._minNormalLowerBoundaryIndex=function(){var e=or>>this._shift;return this._shift<2&&e--,e},t.prototype._maxNormalLowerBoundaryIndex=function(){return ir>>this._shift},t.prototype._rightShift=function(e,r){return Math.floor(e*Math.pow(2,-r))},t})();var Bi=(function(){function t(e){this._scale=e,this._scaleFactor=ct(Math.LOG2E,e),this._inverseFactor=ct(Math.LN2,-e)}return t.prototype.mapToIndex=function(e){if(e<=st)return this._minNormalLowerBoundaryIndex()-1;if(sr(e)===0){var r=ar(e);return(r<<this._scale)-1}var n=Math.floor(Math.log(e)*this._scaleFactor),i=this._maxNormalLowerBoundaryIndex();return n>=i?i:n},t.prototype.lowerBoundary=function(e){var r=this._maxNormalLowerBoundaryIndex();if(e>=r){if(e===r)return 2*Math.exp((e-(1<<this._scale))/this._scaleFactor);throw new q("overflow: "+e+" is > maximum lower boundary: "+r)}var n=this._minNormalLowerBoundaryIndex();if(e<=n){if(e===n)return st;if(e===n-1)return Math.exp((e+(1<<this._scale))/this._scaleFactor)/2;throw new q("overflow: "+e+" is < minimum lower boundary: "+n)}return Math.exp(e*this._inverseFactor)},Object.defineProperty(t.prototype,"scale",{get:function(){return this._scale},enumerable:!1,configurable:!0}),t.prototype._minNormalLowerBoundaryIndex=function(){return or<<this._scale},t.prototype._maxNormalLowerBoundaryIndex=function(){return(ir+1<<this._scale)-1},t})();var Gi=-10,Vi=20,qu=Array.from({length:31},function(t,e){return e>10?new Bi(e-10):new Di(e-10)});function bn(t){if(t>Vi||t<Gi)throw new q("expected scale >= "+Gi+" && <= "+Vi+", got: "+t);return qu[t+10]}var Qu=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},cr=(function(){function t(e,r){this.low=e,this.high=r}return t.combine=function(e,r){return new t(Math.min(e.low,r.low),Math.max(e.high,r.high))},t})(),el=20,tl=160,Pn=2,ki=(function(){function t(e,r,n,i,o,s,c,l,a,u,f){e===void 0&&(e=e),r===void 0&&(r=tl),n===void 0&&(n=!0),i===void 0&&(i=0),o===void 0&&(o=0),s===void 0&&(s=0),c===void 0&&(c=Number.POSITIVE_INFINITY),l===void 0&&(l=Number.NEGATIVE_INFINITY),a===void 0&&(a=new Ln),u===void 0&&(u=new Ln),f===void 0&&(f=bn(el)),this.startTime=e,this._maxSize=r,this._recordMinMax=n,this._sum=i,this._count=o,this._zeroCount=s,this._min=c,this._max=l,this._positive=a,this._negative=u,this._mapping=f,this._maxSize<Pn&&(p.warn("Exponential Histogram Max Size set to "+this._maxSize+", changing to the minimum size of: "+Pn),this._maxSize=Pn)}return t.prototype.record=function(e){this.updateByIncrement(e,1)},t.prototype.setStartTime=function(e){this.startTime=e},t.prototype.toPointValue=function(){return{hasMinMax:this._recordMinMax,min:this.min,max:this.max,sum:this.sum,positive:{offset:this.positive.offset,bucketCounts:this.positive.counts()},negative:{offset:this.negative.offset,bucketCounts:this.negative.counts()},count:this.count,scale:this.scale,zeroCount:this.zeroCount}},Object.defineProperty(t.prototype,"sum",{get:function(){return this._sum},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"min",{get:function(){return this._min},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"max",{get:function(){return this._max},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zeroCount",{get:function(){return this._zeroCount},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scale",{get:function(){return this._count===this._zeroCount?0:this._mapping.scale},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"positive",{get:function(){return this._positive},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"negative",{get:function(){return this._negative},enumerable:!1,configurable:!0}),t.prototype.updateByIncrement=function(e,r){if(!Number.isNaN(e)){if(e>this._max&&(this._max=e),e<this._min&&(this._min=e),this._count+=r,e===0){this._zeroCount+=r;return}this._sum+=e*r,e>0?this._updateBuckets(this._positive,e,r):this._updateBuckets(this._negative,-e,r)}},t.prototype.merge=function(e){this._count===0?(this._min=e.min,this._max=e.max):e.count!==0&&(e.min<this.min&&(this._min=e.min),e.max>this.max&&(this._max=e.max)),this.startTime=e.startTime,this._sum+=e.sum,this._count+=e.count,this._zeroCount+=e.zeroCount;var r=this._minScale(e);this._downscale(this.scale-r),this._mergeBuckets(this.positive,e,e.positive,r),this._mergeBuckets(this.negative,e,e.negative,r)},t.prototype.diff=function(e){this._min=1/0,this._max=-1/0,this._sum-=e.sum,this._count-=e.count,this._zeroCount-=e.zeroCount;var r=this._minScale(e);this._downscale(this.scale-r),this._diffBuckets(this.positive,e,e.positive,r),this._diffBuckets(this.negative,e,e.negative,r)},t.prototype.clone=function(){return new t(this.startTime,this._maxSize,this._recordMinMax,this._sum,this._count,this._zeroCount,this._min,this._max,this.positive.clone(),this.negative.clone(),this._mapping)},t.prototype._updateBuckets=function(e,r,n){var i=this._mapping.mapToIndex(r),o=!1,s=0,c=0;if(e.length===0?(e.indexStart=i,e.indexEnd=e.indexStart,e.indexBase=e.indexStart):i<e.indexStart&&e.indexEnd-i>=this._maxSize?(o=!0,c=i,s=e.indexEnd):i>e.indexEnd&&i-e.indexStart>=this._maxSize&&(o=!0,c=e.indexStart,s=i),o){var l=this._changeScale(s,c);this._downscale(l),i=this._mapping.mapToIndex(r)}this._incrementIndexBy(e,i,n)},t.prototype._incrementIndexBy=function(e,r,n){if(n!==0){if(e.length===0&&(e.indexStart=e.indexEnd=e.indexBase=r),r<e.indexStart){var i=e.indexEnd-r;i>=e.backing.length&&this._grow(e,i+1),e.indexStart=r}else if(r>e.indexEnd){var i=r-e.indexStart;i>=e.backing.length&&this._grow(e,i+1),e.indexEnd=r}var o=r-e.indexBase;o<0&&(o+=e.backing.length),e.incrementBucket(o,n)}},t.prototype._grow=function(e,r){var n=e.backing.length,i=e.indexBase-e.indexStart,o=n-i,s=Ci(r);s>this._maxSize&&(s=this._maxSize);var c=s-i;e.backing.growTo(s,o,c)},t.prototype._changeScale=function(e,r){for(var n=0;e-r>=this._maxSize;)e>>=1,r>>=1,n++;return n},t.prototype._downscale=function(e){if(e!==0){if(e<0)throw new Error("impossible change of scale: "+this.scale);var r=this._mapping.scale-e;this._positive.downscale(e),this._negative.downscale(e),this._mapping=bn(r)}},t.prototype._minScale=function(e){var r=Math.min(this.scale,e.scale),n=cr.combine(this._highLowAtScale(this.positive,this.scale,r),this._highLowAtScale(e.positive,e.scale,r)),i=cr.combine(this._highLowAtScale(this.negative,this.scale,r),this._highLowAtScale(e.negative,e.scale,r));return Math.min(r-this._changeScale(n.high,n.low),r-this._changeScale(i.high,i.low))},t.prototype._highLowAtScale=function(e,r,n){if(e.length===0)return new cr(0,-1);var i=r-n;return new cr(e.indexStart>>i,e.indexEnd>>i)},t.prototype._mergeBuckets=function(e,r,n,i){for(var o=n.offset,s=r.scale-i,c=0;c<n.length;c++)this._incrementIndexBy(e,o+c>>s,n.at(c))},t.prototype._diffBuckets=function(e,r,n,i){for(var o=n.offset,s=r.scale-i,c=0;c<n.length;c++){var l=o+c>>s,a=l-e.indexBase;a<0&&(a+=e.backing.length),e.decrementBucket(a,n.at(c))}e.trim()},t})();var Mn=(function(){function t(e,r){this._maxSize=e,this._recordMinMax=r,this.kind=N.EXPONENTIAL_HISTOGRAM}return t.prototype.createAccumulation=function(e){return new ki(e,this._maxSize,this._recordMinMax)},t.prototype.merge=function(e,r){var n=r.clone();return n.merge(e),n},t.prototype.diff=function(e,r){var n=r.clone();return n.diff(e),n},t.prototype.toMetricData=function(e,r,n,i){return{descriptor:e,aggregationTemporality:r,dataPointType:w.EXPONENTIAL_HISTOGRAM,dataPoints:n.map(function(o){var s=Qu(o,2),c=s[0],l=s[1],a=l.toPointValue(),u=e.type===_.GAUGE||e.type===_.UP_DOWN_COUNTER||e.type===_.OBSERVABLE_GAUGE||e.type===_.OBSERVABLE_UP_DOWN_COUNTER;return{attributes:c,startTime:l.startTime,endTime:i,value:{min:a.hasMinMax?a.min:void 0,max:a.hasMinMax?a.max:void 0,sum:u?void 0:a.sum,positive:{offset:a.positive.offset,bucketCounts:a.positive.bucketCounts},negative:{offset:a.negative.offset,bucketCounts:a.negative.bucketCounts},count:a.count,scale:a.scale,zeroCount:a.zeroCount}}})}},t})();var rl=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},ur=(function(){function t(e,r,n){r===void 0&&(r=0),n===void 0&&(n=[0,0]),this.startTime=e,this._current=r,this.sampleTime=n}return t.prototype.record=function(e){this._current=e,this.sampleTime=U(Date.now())},t.prototype.setStartTime=function(e){this.startTime=e},t.prototype.toPointValue=function(){return this._current},t})();var In=(function(){function t(){this.kind=N.LAST_VALUE}return t.prototype.createAccumulation=function(e){return new ur(e)},t.prototype.merge=function(e,r){var n=J(r.sampleTime)>=J(e.sampleTime)?r:e;return new ur(e.startTime,n.toPointValue(),n.sampleTime)},t.prototype.diff=function(e,r){var n=J(r.sampleTime)>=J(e.sampleTime)?r:e;return new ur(r.startTime,n.toPointValue(),n.sampleTime)},t.prototype.toMetricData=function(e,r,n,i){return{descriptor:e,aggregationTemporality:r,dataPointType:w.GAUGE,dataPoints:n.map(function(o){var s=rl(o,2),c=s[0],l=s[1];return{attributes:c,startTime:l.startTime,endTime:i,value:l.toPointValue()}})}},t})();var nl=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},Re=(function(){function t(e,r,n,i){n===void 0&&(n=0),i===void 0&&(i=!1),this.startTime=e,this.monotonic=r,this._current=n,this.reset=i}return t.prototype.record=function(e){this.monotonic&&e<0||(this._current+=e)},t.prototype.setStartTime=function(e){this.startTime=e},t.prototype.toPointValue=function(){return this._current},t})();var lr=(function(){function t(e){this.monotonic=e,this.kind=N.SUM}return t.prototype.createAccumulation=function(e){return new Re(e,this.monotonic)},t.prototype.merge=function(e,r){var n=e.toPointValue(),i=r.toPointValue();return r.reset?new Re(r.startTime,this.monotonic,i,r.reset):new Re(e.startTime,this.monotonic,n+i)},t.prototype.diff=function(e,r){var n=e.toPointValue(),i=r.toPointValue();return this.monotonic&&n>i?new Re(r.startTime,this.monotonic,i,!0):new Re(r.startTime,this.monotonic,i-n)},t.prototype.toMetricData=function(e,r,n,i){return{descriptor:e,aggregationTemporality:r,dataPointType:w.SUM,dataPoints:n.map(function(o){var s=nl(o,2),c=s[0],l=s[1];return{attributes:c,startTime:l.startTime,endTime:i,value:l.toPointValue()}}),isMonotonic:this.monotonic}},t})();var fe=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},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)}})(),b=(function(){function t(){}return t.Drop=function(){return Yi},t.Sum=function(){return Xi},t.LastValue=function(){return zi},t.Histogram=function(){return Ji},t.ExponentialHistogram=function(){return ol},t.Default=function(){return il},t})();var Hi=(function(t){fe(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.createAggregator=function(r){return e.DEFAULT_INSTANCE},e.DEFAULT_INSTANCE=new On,e})(b);var ut=(function(t){fe(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.createAggregator=function(r){switch(r.type){case _.COUNTER:case _.OBSERVABLE_COUNTER:case _.HISTOGRAM:return e.MONOTONIC_INSTANCE;default:return e.NON_MONOTONIC_INSTANCE}},e.MONOTONIC_INSTANCE=new lr(!0),e.NON_MONOTONIC_INSTANCE=new lr(!1),e})(b);var Fi=(function(t){fe(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.createAggregator=function(r){return e.DEFAULT_INSTANCE},e.DEFAULT_INSTANCE=new In,e})(b);var ji=(function(t){fe(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.createAggregator=function(r){return e.DEFAULT_INSTANCE},e.DEFAULT_INSTANCE=new nr([0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4],!0),e})(b);var $i=(function(t){fe(e,t);function e(r,n){n===void 0&&(n=!0);var i=t.call(this)||this;if(i._recordMinMax=n,r==null)throw new Error("ExplicitBucketHistogramAggregation should be created with explicit boundaries, if a single bucket histogram is required, please pass an empty array");r=r.concat(),r=r.sort(function(c,l){return c-l});var o=r.lastIndexOf(-1/0),s=r.indexOf(1/0);return s===-1&&(s=void 0),i._boundaries=r.slice(o+1,s),i}return e.prototype.createAggregator=function(r){return new nr(this._boundaries,this._recordMinMax)},e})(b);var Ki=(function(t){fe(e,t);function e(r,n){r===void 0&&(r=160),n===void 0&&(n=!0);var i=t.call(this)||this;return i._maxSize=r,i._recordMinMax=n,i}return e.prototype.createAggregator=function(r){return new Mn(this._maxSize,this._recordMinMax)},e})(b);var Wi=(function(t){fe(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype._resolve=function(r){switch(r.type){case _.COUNTER:case _.UP_DOWN_COUNTER:case _.OBSERVABLE_COUNTER:case _.OBSERVABLE_UP_DOWN_COUNTER:return Xi;case _.GAUGE:case _.OBSERVABLE_GAUGE:return zi;case _.HISTOGRAM:return r.advice.explicitBucketBoundaries?new $i(r.advice.explicitBucketBoundaries):Ji}return p.warn("Unable to recognize instrument type: "+r.type),Yi},e.prototype.createAggregator=function(r){return this._resolve(r).createAggregator(r)},e})(b);var Yi=new Hi,Xi=new ut,zi=new Fi,Ji=new ji,ol=new Ki,il=new Wi;var Zi=function(t){return b.Default()},qi=function(t){return R.CUMULATIVE};var Nn=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{a(n.next(u))}catch(f){s(f)}}function l(u){try{a(n.throw(u))}catch(f){s(f)}}function a(u){u.done?o(u.value):i(u.value).then(c,l)}a((n=n.apply(t,e||[])).next())})},Cn=function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(a){return function(u){return l([a,u])}}function l(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}o[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},Qi=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},al=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))},ea=(function(){function t(e){var r,n,i;this._shutdown=!1,this._aggregationSelector=(r=e?.aggregationSelector)!==null&&r!==void 0?r:Zi,this._aggregationTemporalitySelector=(n=e?.aggregationTemporalitySelector)!==null&&n!==void 0?n:qi,this._metricProducers=(i=e?.metricProducers)!==null&&i!==void 0?i:[],this._cardinalitySelector=e?.cardinalitySelector}return t.prototype.setMetricProducer=function(e){if(this._sdkMetricProducer)throw new Error("MetricReader can not be bound to a MeterProvider again.");this._sdkMetricProducer=e,this.onInitialized()},t.prototype.selectAggregation=function(e){return this._aggregationSelector(e)},t.prototype.selectAggregationTemporality=function(e){return this._aggregationTemporalitySelector(e)},t.prototype.selectCardinalityLimit=function(e){return this._cardinalitySelector?this._cardinalitySelector(e):2e3},t.prototype.onInitialized=function(){},t.prototype.collect=function(e){return Nn(this,void 0,void 0,function(){var r,n,i,o,s,c;return Cn(this,function(l){switch(l.label){case 0:if(this._sdkMetricProducer===void 0)throw new Error("MetricReader is not bound to a MetricProducer");if(this._shutdown)throw new Error("MetricReader is shutdown");return[4,Promise.all(al([this._sdkMetricProducer.collect({timeoutMillis:e?.timeoutMillis})],Qi(this._metricProducers.map(function(a){return a.collect({timeoutMillis:e?.timeoutMillis})})),!1))];case 1:return r=Qi.apply(void 0,[l.sent()]),n=r[0],i=r.slice(1),o=n.errors.concat(An(i,function(a){return a.errors})),s=n.resourceMetrics.resource,c=n.resourceMetrics.scopeMetrics.concat(An(i,function(a){return a.resourceMetrics.scopeMetrics})),[2,{resourceMetrics:{resource:s,scopeMetrics:c},errors:o}]}})})},t.prototype.shutdown=function(e){return Nn(this,void 0,void 0,function(){return Cn(this,function(r){switch(r.label){case 0:return this._shutdown?(p.error("Cannot call shutdown twice."),[2]):e?.timeoutMillis!=null?[3,2]:[4,this.onShutdown()];case 1:return r.sent(),[3,4];case 2:return[4,Z(this.onShutdown(),e.timeoutMillis)];case 3:r.sent(),r.label=4;case 4:return this._shutdown=!0,[2]}})})},t.prototype.forceFlush=function(e){return Nn(this,void 0,void 0,function(){return Cn(this,function(r){switch(r.label){case 0:return this._shutdown?(p.warn("Cannot forceFlush on already shutdown MetricReader."),[2]):e?.timeoutMillis!=null?[3,2]:[4,this.onForceFlush()];case 1:return r.sent(),[2];case 2:return[4,Z(this.onForceFlush(),e.timeoutMillis)];case 3:return r.sent(),[2]}})})},t})();g();var sl=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},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)}})(),fr=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{a(n.next(u))}catch(f){s(f)}}function l(u){try{a(n.throw(u))}catch(f){s(f)}}function a(u){u.done?o(u.value):i(u.value).then(c,l)}a((n=n.apply(t,e||[])).next())})},pr=function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(a){return function(u){return l([a,u])}}function l(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}o[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},cl=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},ul=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))},Un=(function(t){sl(e,t);function e(r){var n,i,o,s,c=t.call(this,{aggregationSelector:(n=r.exporter.selectAggregation)===null||n===void 0?void 0:n.bind(r.exporter),aggregationTemporalitySelector:(i=r.exporter.selectAggregationTemporality)===null||i===void 0?void 0:i.bind(r.exporter),metricProducers:r.metricProducers})||this;if(r.exportIntervalMillis!==void 0&&r.exportIntervalMillis<=0)throw Error("exportIntervalMillis must be greater than 0");if(r.exportTimeoutMillis!==void 0&&r.exportTimeoutMillis<=0)throw Error("exportTimeoutMillis must be greater than 0");if(r.exportTimeoutMillis!==void 0&&r.exportIntervalMillis!==void 0&&r.exportIntervalMillis<r.exportTimeoutMillis)throw Error("exportIntervalMillis must be greater than or equal to exportTimeoutMillis");return c._exportInterval=(o=r.exportIntervalMillis)!==null&&o!==void 0?o:6e4,c._exportTimeout=(s=r.exportTimeoutMillis)!==null&&s!==void 0?s:3e4,c._exporter=r.exporter,c}return e.prototype._runOnce=function(){return fr(this,void 0,void 0,function(){var r;return pr(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,Z(this._doRun(),this._exportTimeout)];case 1:return n.sent(),[3,3];case 2:return r=n.sent(),r instanceof yn?(p.error("Export took longer than %s milliseconds and timed out.",this._exportTimeout),[2]):(K(r),[3,3]);case 3:return[2]}})})},e.prototype._doRun=function(){var r,n;return fr(this,void 0,void 0,function(){var i,o,s,c,l,a;return pr(this,function(u){switch(u.label){case 0:return[4,this.collect({timeoutMillis:this._exportTimeout})];case 1:if(i=u.sent(),o=i.resourceMetrics,s=i.errors,s.length>0&&(a=p).error.apply(a,ul(["PeriodicExportingMetricReader: metrics collection errors"],cl(s),!1)),!o.resource.asyncAttributesPending)return[3,5];u.label=2;case 2:return u.trys.push([2,4,,5]),[4,(n=(r=o.resource).waitForAsyncAttributes)===null||n===void 0?void 0:n.call(r)];case 3:return u.sent(),[3,5];case 4:return c=u.sent(),p.debug("Error while resolving async portion of resource: ",c),K(c),[3,5];case 5:return o.scopeMetrics.length===0?[2]:[4,zt._export(this._exporter,o)];case 6:if(l=u.sent(),l.code!==x.SUCCESS)throw new Error("PeriodicExportingMetricReader: metrics export failed (error "+l.error+")");return[2]}})})},e.prototype.onInitialized=function(){var r=this;this._interval=setInterval(function(){r._runOnce()},this._exportInterval),ue(this._interval)},e.prototype.onForceFlush=function(){return fr(this,void 0,void 0,function(){return pr(this,function(r){switch(r.label){case 0:return[4,this._runOnce()];case 1:return r.sent(),[4,this._exporter.forceFlush()];case 2:return r.sent(),[2]}})})},e.prototype.onShutdown=function(){return fr(this,void 0,void 0,function(){return pr(this,function(r){switch(r.label){case 0:return this._interval&&clearInterval(this._interval),[4,this.onForceFlush()];case 1:return r.sent(),[4,this._exporter.shutdown()];case 2:return r.sent(),[2]}})})},e})(ea);g();g();function _r(){return"unknown_service:"+process.argv0}var Q=function(){return Q=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},Q.apply(this,arguments)},ll=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{a(n.next(u))}catch(f){s(f)}}function l(u){try{a(n.throw(u))}catch(f){s(f)}}function a(u){u.done?o(u.value):i(u.value).then(c,l)}a((n=n.apply(t,e||[])).next())})},fl=function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(a){return function(u){return l([a,u])}}function l(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}o[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},pl=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},D=(function(){function t(e,r){var n=this,i;this._attributes=e,this.asyncAttributesPending=r!=null,this._syncAttributes=(i=this._attributes)!==null&&i!==void 0?i:{},this._asyncAttributesPromise=r?.then(function(o){return n._attributes=Object.assign({},n._attributes,o),n.asyncAttributesPending=!1,o},function(o){return p.debug("a resource's async attributes promise rejected: %s",o),n.asyncAttributesPending=!1,{}})}return t.empty=function(){return t.EMPTY},t.default=function(){var e;return new t((e={},e[qo]=_r(),e[et]=ce[et],e[Qe]=ce[Qe],e[tt]=ce[tt],e))},Object.defineProperty(t.prototype,"attributes",{get:function(){var e;return this.asyncAttributesPending&&p.error("Accessing resource attributes before async attributes settled"),(e=this._attributes)!==null&&e!==void 0?e:{}},enumerable:!1,configurable:!0}),t.prototype.waitForAsyncAttributes=function(){return ll(this,void 0,void 0,function(){return fl(this,function(e){switch(e.label){case 0:return this.asyncAttributesPending?[4,this._asyncAttributesPromise]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})},t.prototype.merge=function(e){var r=this,n;if(!e)return this;var i=Q(Q({},this._syncAttributes),(n=e._syncAttributes)!==null&&n!==void 0?n:e.attributes);if(!this._asyncAttributesPromise&&!e._asyncAttributesPromise)return new t(i);var o=Promise.all([this._asyncAttributesPromise,e._asyncAttributesPromise]).then(function(s){var c,l=pl(s,2),a=l[0],u=l[1];return Q(Q(Q(Q({},r._syncAttributes),a),(c=e._syncAttributes)!==null&&c!==void 0?c:e.attributes),u)});return new t(i,o)},t.EMPTY=new t({}),t})();var ta=(function(){function t(){this._registeredViews=[]}return t.prototype.addView=function(e){this._registeredViews.push(e)},t.prototype.findViews=function(e,r){var n=this,i=this._registeredViews.filter(function(o){return n._matchInstrument(o.instrumentSelector,e)&&n._matchMeter(o.meterSelector,r)});return i},t.prototype._matchInstrument=function(e,r){return(e.getType()===void 0||r.type===e.getType())&&e.getNameFilter().match(r.name)&&e.getUnitFilter().match(r.unit)},t.prototype._matchMeter=function(e,r){return e.getNameFilter().match(r.name)&&(r.version===void 0||e.getVersionFilter().match(r.version))&&(r.schemaUrl===void 0||e.getSchemaUrlFilter().match(r.schemaUrl))},t})();g();var pe=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},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)}})(),dr=(function(){function t(e,r){this._writableMetricStorage=e,this._descriptor=r}return t.prototype._record=function(e,r,n){if(r===void 0&&(r={}),n===void 0&&(n=I.active()),typeof e!="number"){p.warn("non-number value provided to metric "+this._descriptor.name+": "+e);return}this._descriptor.valueType===L.INT&&!Number.isInteger(e)&&(p.warn("INT value type cannot accept a floating-point value for "+this._descriptor.name+", ignoring the fractional digits."),e=Math.trunc(e),!Number.isInteger(e))||this._writableMetricStorage.record(e,r,n,U(Date.now()))},t})();var ra=(function(t){pe(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.add=function(r,n,i){this._record(r,n,i)},e})(dr);var na=(function(t){pe(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.add=function(r,n,i){if(r<0){p.warn("negative value provided to counter "+this._descriptor.name+": "+r);return}this._record(r,n,i)},e})(dr);var oa=(function(t){pe(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.record=function(r,n,i){this._record(r,n,i)},e})(dr);var ia=(function(t){pe(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.record=function(r,n,i){if(r<0){p.warn("negative value provided to histogram "+this._descriptor.name+": "+r);return}this._record(r,n,i)},e})(dr);var mr=(function(){function t(e,r,n){this._observableRegistry=n,this._descriptor=e,this._metricStorages=r}return t.prototype.addCallback=function(e){this._observableRegistry.addCallback(e,this)},t.prototype.removeCallback=function(e){this._observableRegistry.removeCallback(e,this)},t})();var aa=(function(t){pe(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e})(mr);var sa=(function(t){pe(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e})(mr);var ca=(function(t){pe(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e})(mr);function lt(t){return t instanceof mr}var ua=(function(){function t(e){this._meterSharedState=e}return t.prototype.createGauge=function(e,r){var n=H(e,_.GAUGE,r),i=this._meterSharedState.registerMetricStorage(n);return new oa(i,n)},t.prototype.createHistogram=function(e,r){var n=H(e,_.HISTOGRAM,r),i=this._meterSharedState.registerMetricStorage(n);return new ia(i,n)},t.prototype.createCounter=function(e,r){var n=H(e,_.COUNTER,r),i=this._meterSharedState.registerMetricStorage(n);return new na(i,n)},t.prototype.createUpDownCounter=function(e,r){var n=H(e,_.UP_DOWN_COUNTER,r),i=this._meterSharedState.registerMetricStorage(n);return new ra(i,n)},t.prototype.createObservableGauge=function(e,r){var n=H(e,_.OBSERVABLE_GAUGE,r),i=this._meterSharedState.registerAsyncMetricStorage(n);return new sa(n,i,this._meterSharedState.observableRegistry)},t.prototype.createObservableCounter=function(e,r){var n=H(e,_.OBSERVABLE_COUNTER,r),i=this._meterSharedState.registerAsyncMetricStorage(n);return new aa(n,i,this._meterSharedState.observableRegistry)},t.prototype.createObservableUpDownCounter=function(e,r){var n=H(e,_.OBSERVABLE_UP_DOWN_COUNTER,r),i=this._meterSharedState.registerAsyncMetricStorage(n);return new ca(n,i,this._meterSharedState.observableRegistry)},t.prototype.addBatchObservableCallback=function(e,r){this._meterSharedState.observableRegistry.addBatchCallback(e,r)},t.prototype.removeBatchObservableCallback=function(e,r){this._meterSharedState.observableRegistry.removeBatchCallback(e,r)},t})();var hr=(function(){function t(e){this._instrumentDescriptor=e}return t.prototype.getInstrumentDescriptor=function(){return this._instrumentDescriptor},t.prototype.updateDescription=function(e){this._instrumentDescriptor=H(this._instrumentDescriptor.name,this._instrumentDescriptor.type,{description:e,valueType:this._instrumentDescriptor.valueType,unit:this._instrumentDescriptor.unit,advice:this._instrumentDescriptor.advice})},t})();var _l=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},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)}})(),la=function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(a){return function(u){return l([a,u])}}function l(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}o[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},dl=(function(){function t(e){this._hash=e,this._valueMap=new Map,this._keyMap=new Map}return t.prototype.get=function(e,r){return r??(r=this._hash(e)),this._valueMap.get(r)},t.prototype.getOrDefault=function(e,r){var n=this._hash(e);if(this._valueMap.has(n))return this._valueMap.get(n);var i=r();return this._keyMap.has(n)||this._keyMap.set(n,e),this._valueMap.set(n,i),i},t.prototype.set=function(e,r,n){n??(n=this._hash(e)),this._keyMap.has(n)||this._keyMap.set(n,e),this._valueMap.set(n,r)},t.prototype.has=function(e,r){return r??(r=this._hash(e)),this._valueMap.has(r)},t.prototype.keys=function(){var e,r;return la(this,function(n){switch(n.label){case 0:e=this._keyMap.entries(),r=e.next(),n.label=1;case 1:return r.done===!0?[3,3]:[4,[r.value[1],r.value[0]]];case 2:return n.sent(),r=e.next(),[3,1];case 3:return[2]}})},t.prototype.entries=function(){var e,r;return la(this,function(n){switch(n.label){case 0:e=this._valueMap.entries(),r=e.next(),n.label=1;case 1:return r.done===!0?[3,3]:[4,[this._keyMap.get(r.value[0]),r.value[1],r.value[0]]];case 2:return n.sent(),r=e.next(),[3,1];case 3:return[2]}})},Object.defineProperty(t.prototype,"size",{get:function(){return this._valueMap.size},enumerable:!1,configurable:!0}),t})();var B=(function(t){_l(e,t);function e(){return t.call(this,tr)||this}return e})(dl);var ml=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},Er=(function(){function t(e,r){this._aggregator=e,this._activeCollectionStorage=new B,this._cumulativeMemoStorage=new B,this._overflowAttributes={"otel.metric.overflow":!0},this._cardinalityLimit=(r??2e3)-1,this._overflowHashCode=tr(this._overflowAttributes)}return t.prototype.record=function(e,r,n,i){var o=this,s=this._activeCollectionStorage.get(r);if(!s){if(this._activeCollectionStorage.size>=this._cardinalityLimit){var c=this._activeCollectionStorage.getOrDefault(this._overflowAttributes,function(){return o._aggregator.createAccumulation(i)});c?.record(e);return}s=this._aggregator.createAccumulation(i),this._activeCollectionStorage.set(r,s)}s?.record(e)},t.prototype.batchCumulate=function(e,r){var n=this;Array.from(e.entries()).forEach(function(i){var o=ml(i,3),s=o[0],c=o[1],l=o[2],a=n._aggregator.createAccumulation(r);a?.record(c);var u=a;if(n._cumulativeMemoStorage.has(s,l)){var f=n._cumulativeMemoStorage.get(s,l);u=n._aggregator.diff(f,a)}else if(n._cumulativeMemoStorage.size>=n._cardinalityLimit&&(s=n._overflowAttributes,l=n._overflowHashCode,n._cumulativeMemoStorage.has(s,l))){var f=n._cumulativeMemoStorage.get(s,l);u=n._aggregator.diff(f,a)}if(n._activeCollectionStorage.has(s,l)){var d=n._activeCollectionStorage.get(s,l);u=n._aggregator.merge(d,u)}n._cumulativeMemoStorage.set(s,a,l),n._activeCollectionStorage.set(s,u,l)})},t.prototype.collect=function(){var e=this._activeCollectionStorage;return this._activeCollectionStorage=new B,e},t})();var Dn=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.")},fa=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},gr=(function(){function t(e,r){var n=this;this._aggregator=e,this._unreportedAccumulations=new Map,this._reportHistory=new Map,r.forEach(function(i){n._unreportedAccumulations.set(i,[])})}return t.prototype.buildMetrics=function(e,r,n,i){this._stashAccumulations(n);var o=this._getMergedUnreportedAccumulations(e),s=o,c;if(this._reportHistory.has(e)){var l=this._reportHistory.get(e),a=l.collectionTime;c=l.aggregationTemporality,c===R.CUMULATIVE?s=t.merge(l.accumulations,o,this._aggregator):s=t.calibrateStartTime(l.accumulations,o,a)}else c=e.selectAggregationTemporality(r.type);this._reportHistory.set(e,{accumulations:s,collectionTime:i,aggregationTemporality:c});var u=hl(s);if(u.length!==0)return this._aggregator.toMetricData(r,c,u,i)},t.prototype._stashAccumulations=function(e){var r,n,i=this._unreportedAccumulations.keys();try{for(var o=Dn(i),s=o.next();!s.done;s=o.next()){var c=s.value,l=this._unreportedAccumulations.get(c);l===void 0&&(l=[],this._unreportedAccumulations.set(c,l)),l.push(e)}}catch(a){r={error:a}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}},t.prototype._getMergedUnreportedAccumulations=function(e){var r,n,i=new B,o=this._unreportedAccumulations.get(e);if(this._unreportedAccumulations.set(e,[]),o===void 0)return i;try{for(var s=Dn(o),c=s.next();!c.done;c=s.next()){var l=c.value;i=t.merge(i,l,this._aggregator)}}catch(a){r={error:a}}finally{try{c&&!c.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return i},t.merge=function(e,r,n){for(var i=e,o=r.entries(),s=o.next();s.done!==!0;){var c=fa(s.value,3),l=c[0],a=c[1],u=c[2];if(e.has(l,u)){var f=e.get(l,u),d=n.merge(f,a);i.set(l,d,u)}else i.set(l,a,u);s=o.next()}return i},t.calibrateStartTime=function(e,r,n){var i,o;try{for(var s=Dn(e.keys()),c=s.next();!c.done;c=s.next()){var l=fa(c.value,2),a=l[0],u=l[1],f=r.get(a,u);f?.setStartTime(n)}}catch(d){i={error:d}}finally{try{c&&!c.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}return r},t})();function hl(t){return Array.from(t.entries())}var El=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},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)}})(),gl=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},pa=(function(t){El(e,t);function e(r,n,i,o,s){var c=t.call(this,r)||this;return c._attributesProcessor=i,c._aggregationCardinalityLimit=s,c._deltaMetricStorage=new Er(n,c._aggregationCardinalityLimit),c._temporalMetricStorage=new gr(n,o),c}return e.prototype.record=function(r,n){var i=this,o=new B;Array.from(r.entries()).forEach(function(s){var c=gl(s,2),l=c[0],a=c[1];o.set(i._attributesProcessor.process(l),a)}),this._deltaMetricStorage.batchCumulate(o,n)},e.prototype.collect=function(r,n){var i=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(r,this._instrumentDescriptor,i,n)},e})(hr);g();function Bn(t,e){var r="";return t.unit!==e.unit&&(r+=" - Unit '"+t.unit+"' does not match '"+e.unit+`'
|
|
4
|
+
`),t.type!==e.type&&(r+=" - Type '"+t.type+"' does not match '"+e.type+`'
|
|
5
|
+
`),t.valueType!==e.valueType&&(r+=" - Value Type '"+t.valueType+"' does not match '"+e.valueType+`'
|
|
6
|
+
`),t.description!==e.description&&(r+=" - Description '"+t.description+"' does not match '"+e.description+`'
|
|
7
|
+
`),r}function vl(t,e){return" - use valueType '"+t.valueType+"' on instrument creation or use an instrument name other than '"+e.name+"'"}function Tl(t,e){return" - use unit '"+t.unit+"' on instrument creation or use an instrument name other than '"+e.name+"'"}function Sl(t,e){var r={name:e.name,type:e.type,unit:e.unit},n=JSON.stringify(r);return" - create a new view with a name other than '"+t.name+"' and InstrumentSelector '"+n+"'"}function yl(t,e){var r={name:e.name,type:e.type,unit:e.unit},n=JSON.stringify(r);return" - create a new view with a name other than '"+t.name+"' and InstrumentSelector '"+n+`'
|
|
8
|
+
- OR - create a new view with the name `+t.name+" and description '"+t.description+"' and InstrumentSelector "+n+`
|
|
9
|
+
- OR - create a new view with the name `+e.name+" and description '"+t.description+"' and InstrumentSelector "+n}function Gn(t,e){return t.valueType!==e.valueType?vl(t,e):t.unit!==e.unit?Tl(t,e):t.type!==e.type?Sl(t,e):t.description!==e.description?yl(t,e):""}var Vn=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.")},_a=(function(){function t(){this._sharedRegistry=new Map,this._perCollectorRegistry=new Map}return t.create=function(){return new t},t.prototype.getStorages=function(e){var r,n,i,o,s=[];try{for(var c=Vn(this._sharedRegistry.values()),l=c.next();!l.done;l=c.next()){var a=l.value;s=s.concat(a)}}catch(T){r={error:T}}finally{try{l&&!l.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}var u=this._perCollectorRegistry.get(e);if(u!=null)try{for(var f=Vn(u.values()),d=f.next();!d.done;d=f.next()){var a=d.value;s=s.concat(a)}}catch(T){i={error:T}}finally{try{d&&!d.done&&(o=f.return)&&o.call(f)}finally{if(i)throw i.error}}return s},t.prototype.register=function(e){this._registerStorage(e,this._sharedRegistry)},t.prototype.registerForCollector=function(e,r){var n=this._perCollectorRegistry.get(e);n==null&&(n=new Map,this._perCollectorRegistry.set(e,n)),this._registerStorage(r,n)},t.prototype.findOrUpdateCompatibleStorage=function(e){var r=this._sharedRegistry.get(e.name);return r===void 0?null:this._findOrUpdateCompatibleStorage(e,r)},t.prototype.findOrUpdateCompatibleCollectorStorage=function(e,r){var n=this._perCollectorRegistry.get(e);if(n===void 0)return null;var i=n.get(r.name);return i===void 0?null:this._findOrUpdateCompatibleStorage(r,i)},t.prototype._registerStorage=function(e,r){var n=e.getInstrumentDescriptor(),i=r.get(n.name);if(i===void 0){r.set(n.name,[e]);return}i.push(e)},t.prototype._findOrUpdateCompatibleStorage=function(e,r){var n,i,o=null;try{for(var s=Vn(r),c=s.next();!c.done;c=s.next()){var l=c.value,a=l.getInstrumentDescriptor();Mi(a,e)?(a.description!==e.description&&(e.description.length>a.description.length&&l.updateDescription(e.description),p.warn("A view or instrument with the name ",e.name,` has already been registered, but has a different description and is incompatible with another registered view.
|
|
10
|
+
`,`Details:
|
|
11
|
+
`,Bn(a,e),`The longer description will be used.
|
|
12
|
+
To resolve the conflict:`,Gn(a,e))),o=l):p.warn("A view or instrument with the name ",e.name,` has already been registered and is incompatible with another registered view.
|
|
13
|
+
`,`Details:
|
|
14
|
+
`,Bn(a,e),`To resolve the conflict:
|
|
15
|
+
`,Gn(a,e))}}catch(u){n={error:u}}finally{try{c&&!c.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}return o},t})();var da=(function(){function t(e){this._backingStorages=e}return t.prototype.record=function(e,r,n,i){this._backingStorages.forEach(function(o){o.record(e,r,n,i)})},t})();g();g();var ma=(function(){function t(e,r){this._instrumentName=e,this._valueType=r,this._buffer=new B}return t.prototype.observe=function(e,r){if(r===void 0&&(r={}),typeof e!="number"){p.warn("non-number value provided to metric "+this._instrumentName+": "+e);return}this._valueType===L.INT&&!Number.isInteger(e)&&(p.warn("INT value type cannot accept a floating-point value for "+this._instrumentName+", ignoring the fractional digits."),e=Math.trunc(e),!Number.isInteger(e))||this._buffer.set(r,e)},t})();var ha=(function(){function t(){this._buffer=new Map}return t.prototype.observe=function(e,r,n){if(n===void 0&&(n={}),!!lt(e)){var i=this._buffer.get(e);if(i==null&&(i=new B,this._buffer.set(e,i)),typeof r!="number"){p.warn("non-number value provided to metric "+e._descriptor.name+": "+r);return}e._descriptor.valueType===L.INT&&!Number.isInteger(r)&&(p.warn("INT value type cannot accept a floating-point value for "+e._descriptor.name+", ignoring the fractional digits."),r=Math.trunc(r),!Number.isInteger(r))||i.set(n,r)}},t})();var kn=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{a(n.next(u))}catch(f){s(f)}}function l(u){try{a(n.throw(u))}catch(f){s(f)}}function a(u){u.done?o(u.value):i(u.value).then(c,l)}a((n=n.apply(t,e||[])).next())})},Hn=function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(a){return function(u){return l([a,u])}}function l(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}o[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},Ea=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},ga=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))},va=(function(){function t(){this._callbacks=[],this._batchCallbacks=[]}return t.prototype.addCallback=function(e,r){var n=this._findCallback(e,r);n>=0||this._callbacks.push({callback:e,instrument:r})},t.prototype.removeCallback=function(e,r){var n=this._findCallback(e,r);n<0||this._callbacks.splice(n,1)},t.prototype.addBatchCallback=function(e,r){var n=new Set(r.filter(lt));if(n.size===0){p.error("BatchObservableCallback is not associated with valid instruments",r);return}var i=this._findBatchCallback(e,n);i>=0||this._batchCallbacks.push({callback:e,instruments:n})},t.prototype.removeBatchCallback=function(e,r){var n=new Set(r.filter(lt)),i=this._findBatchCallback(e,n);i<0||this._batchCallbacks.splice(i,1)},t.prototype.observe=function(e,r){return kn(this,void 0,void 0,function(){var n,i,o,s;return Hn(this,function(c){switch(c.label){case 0:return n=this._observeCallbacks(e,r),i=this._observeBatchCallbacks(e,r),[4,Ri(ga(ga([],Ea(n),!1),Ea(i),!1))];case 1:return o=c.sent(),s=o.filter(xi).map(function(l){return l.reason}),[2,s]}})})},t.prototype._observeCallbacks=function(e,r){var n=this;return this._callbacks.map(function(i){var o=i.callback,s=i.instrument;return kn(n,void 0,void 0,function(){var c,l;return Hn(this,function(a){switch(a.label){case 0:return c=new ma(s._descriptor.name,s._descriptor.valueType),l=Promise.resolve(o(c)),r!=null&&(l=Z(l,r)),[4,l];case 1:return a.sent(),s._metricStorages.forEach(function(u){u.record(c._buffer,e)}),[2]}})})})},t.prototype._observeBatchCallbacks=function(e,r){var n=this;return this._batchCallbacks.map(function(i){var o=i.callback,s=i.instruments;return kn(n,void 0,void 0,function(){var c,l;return Hn(this,function(a){switch(a.label){case 0:return c=new ha,l=Promise.resolve(o(c)),r!=null&&(l=Z(l,r)),[4,l];case 1:return a.sent(),s.forEach(function(u){var f=c._buffer.get(u);f!=null&&u._metricStorages.forEach(function(d){d.record(f,e)})}),[2]}})})})},t.prototype._findCallback=function(e,r){return this._callbacks.findIndex(function(n){return n.callback===e&&n.instrument===r})},t.prototype._findBatchCallback=function(e,r){return this._batchCallbacks.findIndex(function(n){return n.callback===e&&Li(n.instruments,r)})},t})();var Al=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},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)}})(),Ta=(function(t){Al(e,t);function e(r,n,i,o,s){var c=t.call(this,r)||this;return c._attributesProcessor=i,c._aggregationCardinalityLimit=s,c._deltaMetricStorage=new Er(n,c._aggregationCardinalityLimit),c._temporalMetricStorage=new gr(n,o),c}return e.prototype.record=function(r,n,i,o){n=this._attributesProcessor.process(n,i),this._deltaMetricStorage.record(r,n,i,o)},e.prototype.collect=function(r,n){var i=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(r,this._instrumentDescriptor,i,n)},e})(hr);var Sa=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},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)}})(),xe=(function(){function t(){}return t.Noop=function(){return Rl},t})();var Ol=(function(t){Sa(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.process=function(r,n){return r},e})(xe);var ya=(function(t){Sa(e,t);function e(r){var n=t.call(this)||this;return n._allowedAttributeNames=r,n}return e.prototype.process=function(r,n){var i=this,o={};return Object.keys(r).filter(function(s){return i._allowedAttributeNames.includes(s)}).forEach(function(s){return o[s]=r[s]}),o},e})(xe);var Rl=new Ol;var xl=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{a(n.next(u))}catch(f){s(f)}}function l(u){try{a(n.throw(u))}catch(f){s(f)}}function a(u){u.done?o(u.value):i(u.value).then(c,l)}a((n=n.apply(t,e||[])).next())})},Ll=function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(a){return function(u){return l([a,u])}}function l(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}o[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},wl=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},Aa=(function(){function t(e,r){this._meterProviderSharedState=e,this._instrumentationScope=r,this.metricStorageRegistry=new _a,this.observableRegistry=new va,this.meter=new ua(this)}return t.prototype.registerMetricStorage=function(e){var r=this._registerMetricStorage(e,Ta);return r.length===1?r[0]:new da(r)},t.prototype.registerAsyncMetricStorage=function(e){var r=this._registerMetricStorage(e,pa);return r},t.prototype.collect=function(e,r,n){return xl(this,void 0,void 0,function(){var i,o,s;return Ll(this,function(c){switch(c.label){case 0:return[4,this.observableRegistry.observe(r,n?.timeoutMillis)];case 1:return i=c.sent(),o=this.metricStorageRegistry.getStorages(e),o.length===0?[2,null]:(s=o.map(function(l){return l.collect(e,r)}).filter(Ai),s.length===0?[2,{errors:i}]:[2,{scopeMetrics:{scope:this._instrumentationScope,metrics:s},errors:i}])}})})},t.prototype._registerMetricStorage=function(e,r){var n=this,i=this._meterProviderSharedState.viewRegistry.findViews(e,this._instrumentationScope),o=i.map(function(l){var a=Pi(l,e),u=n.metricStorageRegistry.findOrUpdateCompatibleStorage(a);if(u!=null)return u;var f=l.aggregation.createAggregator(a),d=new r(a,f,l.attributesProcessor,n._meterProviderSharedState.metricCollectors,l.aggregationCardinalityLimit);return n.metricStorageRegistry.register(d),d});if(o.length===0){var s=this._meterProviderSharedState.selectAggregations(e.type),c=s.map(function(l){var a=wl(l,2),u=a[0],f=a[1],d=n.metricStorageRegistry.findOrUpdateCompatibleCollectorStorage(u,e);if(d!=null)return d;var T=f.createAggregator(e),C=u.selectCardinalityLimit(e.type),ne=new r(e,T,xe.Noop(),[u],C);return n.metricStorageRegistry.registerForCollector(u,ne),ne});o=o.concat(c)}return o},t})();var bl=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.")},Oa=(function(){function t(e){this.resource=e,this.viewRegistry=new ta,this.metricCollectors=[],this.meterSharedStates=new Map}return t.prototype.getMeterSharedState=function(e){var r=Oi(e),n=this.meterSharedStates.get(r);return n==null&&(n=new Aa(this,e),this.meterSharedStates.set(r,n)),n},t.prototype.selectAggregations=function(e){var r,n,i=[];try{for(var o=bl(this.metricCollectors),s=o.next();!s.done;s=o.next()){var c=s.value;i.push([c,c.selectAggregation(e)])}}catch(l){r={error:l}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i},t})();var vr=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{a(n.next(u))}catch(f){s(f)}}function l(u){try{a(n.throw(u))}catch(f){s(f)}}function a(u){u.done?o(u.value):i(u.value).then(c,l)}a((n=n.apply(t,e||[])).next())})},Tr=function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(a){return function(u){return l([a,u])}}function l(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}o[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},Pl=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},Ml=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,o;n<i;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))},Ra=(function(){function t(e,r){this._sharedState=e,this._metricReader=r}return t.prototype.collect=function(e){return vr(this,void 0,void 0,function(){var r,n,i,o,s=this;return Tr(this,function(c){switch(c.label){case 0:return r=U(Date.now()),n=[],i=[],o=Array.from(this._sharedState.meterSharedStates.values()).map(function(l){return vr(s,void 0,void 0,function(){var a;return Tr(this,function(u){switch(u.label){case 0:return[4,l.collect(this,r,e)];case 1:return a=u.sent(),a?.scopeMetrics!=null&&n.push(a.scopeMetrics),a?.errors!=null&&i.push.apply(i,Ml([],Pl(a.errors),!1)),[2]}})})}),[4,Promise.all(o)];case 1:return c.sent(),[2,{resourceMetrics:{resource:this._sharedState.resource,scopeMetrics:n},errors:i}]}})})},t.prototype.forceFlush=function(e){return vr(this,void 0,void 0,function(){return Tr(this,function(r){switch(r.label){case 0:return[4,this._metricReader.forceFlush(e)];case 1:return r.sent(),[2]}})})},t.prototype.shutdown=function(e){return vr(this,void 0,void 0,function(){return Tr(this,function(r){switch(r.label){case 0:return[4,this._metricReader.shutdown(e)];case 1:return r.sent(),[2]}})})},t.prototype.selectAggregationTemporality=function(e){return this._metricReader.selectAggregationTemporality(e)},t.prototype.selectAggregation=function(e){return this._metricReader.selectAggregation(e)},t.prototype.selectCardinalityLimit=function(e){var r,n,i;return(i=(n=(r=this._metricReader).selectCardinalityLimit)===null||n===void 0?void 0:n.call(r,e))!==null&&i!==void 0?i:2e3},t})();var xa=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{a(n.next(u))}catch(f){s(f)}}function l(u){try{a(n.throw(u))}catch(f){s(f)}}function a(u){u.done?o(u.value):i(u.value).then(c,l)}a((n=n.apply(t,e||[])).next())})},La=function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(a){return function(u){return l([a,u])}}function l(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}o[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},wa=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.")};function Il(t,e){var r=e??D.empty();return t?D.default().merge(r):r}var Fn=(function(){function t(e){var r,n,i,o,s;if(this._shutdown=!1,this._sharedState=new Oa(Il((s=e?.mergeResourceWithDefaults)!==null&&s!==void 0?s:!0,e?.resource)),e?.views!=null&&e.views.length>0)try{for(var c=wa(e.views),l=c.next();!l.done;l=c.next()){var a=l.value;this._sharedState.viewRegistry.addView(a)}}catch(T){r={error:T}}finally{try{l&&!l.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}if(e?.readers!=null&&e.readers.length>0)try{for(var u=wa(e.readers),f=u.next();!f.done;f=u.next()){var d=f.value;this.addMetricReader(d)}}catch(T){i={error:T}}finally{try{f&&!f.done&&(o=u.return)&&o.call(u)}finally{if(i)throw i.error}}}return t.prototype.getMeter=function(e,r,n){return r===void 0&&(r=""),n===void 0&&(n={}),this._shutdown?(p.warn("A shutdown MeterProvider cannot provide a Meter"),rn()):this._sharedState.getMeterSharedState({name:e,version:r,schemaUrl:n.schemaUrl}).meter},t.prototype.addMetricReader=function(e){var r=new Ra(this._sharedState,e);e.setMetricProducer(r),this._sharedState.metricCollectors.push(r)},t.prototype.shutdown=function(e){return xa(this,void 0,void 0,function(){return La(this,function(r){switch(r.label){case 0:return this._shutdown?(p.warn("shutdown may only be called once per MeterProvider"),[2]):(this._shutdown=!0,[4,Promise.all(this._sharedState.metricCollectors.map(function(n){return n.shutdown(e)}))]);case 1:return r.sent(),[2]}})})},t.prototype.forceFlush=function(e){return xa(this,void 0,void 0,function(){return La(this,function(r){switch(r.label){case 0:return this._shutdown?(p.warn("invalid attempt to force flush after MeterProvider shutdown"),[2]):[4,Promise.all(this._sharedState.metricCollectors.map(function(n){return n.forceFlush(e)}))];case 1:return r.sent(),[2]}})})},t})();var Nl=/[\^$\\.+?()[\]{}|]/g,Sr=(function(){function t(e){e==="*"?(this._matchAll=!0,this._regexp=/.*/):(this._matchAll=!1,this._regexp=new RegExp(t.escapePattern(e)))}return t.prototype.match=function(e){return this._matchAll?!0:this._regexp.test(e)},t.escapePattern=function(e){return"^"+e.replace(Nl,"\\$&").replace("*",".*")+"$"},t.hasWildcard=function(e){return e.includes("*")},t})();var Le=(function(){function t(e){this._matchAll=e===void 0,this._pattern=e}return t.prototype.match=function(e){return!!(this._matchAll||e===this._pattern)},t})();var ba=(function(){function t(e){var r;this._nameFilter=new Sr((r=e?.name)!==null&&r!==void 0?r:"*"),this._type=e?.type,this._unitFilter=new Le(e?.unit)}return t.prototype.getType=function(){return this._type},t.prototype.getNameFilter=function(){return this._nameFilter},t.prototype.getUnitFilter=function(){return this._unitFilter},t})();var Pa=(function(){function t(e){this._nameFilter=new Le(e?.name),this._versionFilter=new Le(e?.version),this._schemaUrlFilter=new Le(e?.schemaUrl)}return t.prototype.getNameFilter=function(){return this._nameFilter},t.prototype.getVersionFilter=function(){return this._versionFilter},t.prototype.getSchemaUrlFilter=function(){return this._schemaUrlFilter},t})();function Cl(t){return t.instrumentName==null&&t.instrumentType==null&&t.instrumentUnit==null&&t.meterName==null&&t.meterVersion==null&&t.meterSchemaUrl==null}var yr=(function(){function t(e){var r;if(Cl(e))throw new Error("Cannot create view with no selector arguments supplied");if(e.name!=null&&(e?.instrumentName==null||Sr.hasWildcard(e.instrumentName)))throw new Error("Views with a specified name must be declared with an instrument selector that selects at most one instrument per meter.");e.attributeKeys!=null?this.attributesProcessor=new ya(e.attributeKeys):this.attributesProcessor=xe.Noop(),this.name=e.name,this.description=e.description,this.aggregation=(r=e.aggregation)!==null&&r!==void 0?r:b.Default(),this.instrumentSelector=new ba({name:e.instrumentName,type:e.instrumentType,unit:e.instrumentUnit}),this.meterSelector=new Pa({name:e.meterName,version:e.meterVersion,schemaUrl:e.meterSchemaUrl}),this.aggregationCardinalityLimit=e.aggregationCardinalityLimit}return t})();function Ul(t,e){var r=Jt(e);return{resource:Zt(t.resource),schemaUrl:void 0,scopeMetrics:Dl(t.scopeMetrics,r)}}function Dl(t,e){return Array.from(t.map(function(r){return{scope:qt(r.scope),metrics:r.metrics.map(function(n){return Bl(n,e)}),schemaUrl:r.scope.schemaUrl}}))}function Bl(t,e){var r={name:t.descriptor.name,description:t.descriptor.description,unit:t.descriptor.unit},n=Hl(t.aggregationTemporality);switch(t.dataPointType){case w.SUM:r.sum={aggregationTemporality:n,isMonotonic:t.isMonotonic,dataPoints:Ma(t,e)};break;case w.GAUGE:r.gauge={dataPoints:Ma(t,e)};break;case w.HISTOGRAM:r.histogram={aggregationTemporality:n,dataPoints:Vl(t,e)};break;case w.EXPONENTIAL_HISTOGRAM:r.exponentialHistogram={aggregationTemporality:n,dataPoints:kl(t,e)};break}return r}function Gl(t,e,r){var n={attributes:at(t.attributes),startTimeUnixNano:r.encodeHrTime(t.startTime),timeUnixNano:r.encodeHrTime(t.endTime)};switch(e){case L.INT:n.asInt=t.value;break;case L.DOUBLE:n.asDouble=t.value;break}return n}function Ma(t,e){return t.dataPoints.map(function(r){return Gl(r,t.descriptor.valueType,e)})}function Vl(t,e){return t.dataPoints.map(function(r){var n=r.value;return{attributes:at(r.attributes),bucketCounts:n.buckets.counts,explicitBounds:n.buckets.boundaries,count:n.count,sum:n.sum,min:n.min,max:n.max,startTimeUnixNano:e.encodeHrTime(r.startTime),timeUnixNano:e.encodeHrTime(r.endTime)}})}function kl(t,e){return t.dataPoints.map(function(r){var n=r.value;return{attributes:at(r.attributes),count:n.count,min:n.min,max:n.max,sum:n.sum,positive:{offset:n.positive.offset,bucketCounts:n.positive.bucketCounts},negative:{offset:n.negative.offset,bucketCounts:n.negative.bucketCounts},scale:n.scale,zeroCount:n.zeroCount,startTimeUnixNano:e.encodeHrTime(r.startTime),timeUnixNano:e.encodeHrTime(r.endTime)}})}function Hl(t){switch(t){case R.DELTA:return 1;case R.CUMULATIVE:return 2}}function Ia(t,e){return{resourceMetrics:t.map(function(r){return Ul(r,e)})}}var Ar={serializeRequest:function(t){var e=Ti(t,{useHex:!0,useLongBits:!1}),r=new TextEncoder;return r.encode(JSON.stringify(e))},deserializeResponse:function(t){var e=new TextDecoder;return JSON.parse(e.decode(t))}};var Or={serializeRequest:function(t){var e=Ia([t],{useLongBits:!1}),r=new TextEncoder;return r.encode(JSON.stringify(e))},deserializeResponse:function(t){var e=new TextDecoder;return JSON.parse(e.decode(t))}};var Na="0.57.2";var Wl=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{a(n.next(u))}catch(f){s(f)}}function l(u){try{a(n.throw(u))}catch(f){s(f)}}function a(u){u.done?o(u.value):i(u.value).then(c,l)}a((n=n.apply(t,e||[])).next())})},Yl=function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(a){return function(u){return l([a,u])}}function l(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}o[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},Xl=(function(){function t(e){this._parameters=e,this._send=null,this._agent=null}return t.prototype.send=function(e,r){return Wl(this,void 0,void 0,function(){var n,i,o,s=this;return Yl(this,function(c){return this._send==null&&(n=(ka(),ac(Va)),i=n.sendWithHttp,o=n.createHttpAgent,this._agent=o(this._parameters.url,this._parameters.agentOptions),this._send=i),[2,new Promise(function(l){var a;(a=s._send)===null||a===void 0||a.call(s,s._parameters,s._agent,e,function(u){l(u)},r)})]})})},t.prototype.shutdown=function(){},t})();function Ha(t){return new Xl(t)}var zl=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{a(n.next(u))}catch(f){s(f)}}function l(u){try{a(n.throw(u))}catch(f){s(f)}}function a(u){u.done?o(u.value):i(u.value).then(c,l)}a((n=n.apply(t,e||[])).next())})},Jl=function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(a){return function(u){return l([a,u])}}function l(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}o[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},Zl=5,ql=1e3,Ql=5e3,ef=1.5,Fa=.2;function tf(){return Math.random()*(2*Fa)-Fa}var rf=(function(){function t(e){this._transport=e}return t.prototype.retry=function(e,r,n){var i=this;return new Promise(function(o,s){setTimeout(function(){i._transport.send(e,r).then(o,s)},n)})},t.prototype.send=function(e,r){var n;return zl(this,void 0,void 0,function(){var i,o,s,c,l,a,u;return Jl(this,function(f){switch(f.label){case 0:return i=Date.now()+r,[4,this._transport.send(e,r)];case 1:o=f.sent(),s=Zl,c=ql,f.label=2;case 2:return o.status==="retryable"&&s>0?(s--,l=Math.max(Math.min(c,Ql)+tf(),0),c=c*ef,a=(n=o.retryInMillis)!==null&&n!==void 0?n:l,u=i-Date.now(),a>u?[2,o]:[4,this.retry(e,u,a)]):[3,4];case 3:return o=f.sent(),[3,2];case 4:return[2,o]}})})},t.prototype.shutdown=function(){return this._transport.shutdown()},t})();function ja(t){return new rf(t.transport)}function ft(t,e){return di({transport:ja({transport:Ha(t)}),serializer:e,promiseHandler:lo(t)},{timeout:t.timeoutMillis})}g();function $a(t){var e,r=(e=process.env[t])===null||e===void 0?void 0:e.trim();if(r!=null&&r!==""){var n=Number(r);if(!Number.isNaN(n)&&Number.isFinite(n)&&n>0)return n;p.warn("Configuration: "+t+" is invalid, expected number greater than 0 (actual: "+r+")")}}function nf(t){var e=$a("OTEL_EXPORTER_OTLP_"+t+"_TIMEOUT"),r=$a("OTEL_EXPORTER_OTLP_TIMEOUT");return e??r}function Ka(t){var e,r=(e=process.env[t])===null||e===void 0?void 0:e.trim();if(r!==""){if(r==null||r==="none"||r==="gzip")return r;p.warn("Configuration: "+t+" is invalid, expected 'none' or 'gzip' (actual: '"+r+"')")}}function of(t){var e=Ka("OTEL_EXPORTER_OTLP_"+t+"_COMPRESSION"),r=Ka("OTEL_EXPORTER_OTLP_COMPRESSION");return e??r}function Wa(t){return{timeoutMillis:nf(t),compression:of(t)}}g();var af=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o};function Ya(t){return function(){var e,r={};return Object.entries((e=t?.())!==null&&e!==void 0?e:{}).forEach(function(n){var i=af(n,2),o=i[0],s=i[1];typeof s<"u"?r[o]=String(s):p.warn('Header "'+o+'" has invalid value ('+s+") and will be ignored")}),r}}var _e=function(){return _e=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},_e.apply(this,arguments)};function sf(t,e,r){var n=_e({},r()),i={};return function(){return e!=null&&Object.assign(i,e()),t!=null&&Object.assign(i,t()),Object.assign(i,n)}}function cf(t){if(t!=null)try{return new URL(t),t}catch{throw new Error("Configuration: Could not parse user-provided export URL: '"+t+"'")}}function Xa(t,e,r){var n,i,o,s;return _e(_e({},co(t,e,r)),{headers:sf(Ya(t.headers),e.headers,r.headers),url:(i=(n=cf(t.url))!==null&&n!==void 0?n:e.url)!==null&&i!==void 0?i:r.url,agentOptions:(s=(o=t.agentOptions)!==null&&o!==void 0?o:e.agentOptions)!==null&&s!==void 0?s:r.agentOptions})}function za(t,e){return _e(_e({},uo()),{headers:function(){return t},url:"http://localhost:4318/"+e,agentOptions:{keepAlive:!0}})}g();var Lr=function(){return Lr=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},Lr.apply(this,arguments)};function uf(t){var e,r,n=(e=process.env["OTEL_EXPORTER_OTLP_"+t+"_HEADERS"])===null||e===void 0?void 0:e.trim(),i=(r=process.env.OTEL_EXPORTER_OTLP_HEADERS)===null||r===void 0?void 0:r.trim(),o=it.parseKeyPairsIntoRecord(n),s=it.parseKeyPairsIntoRecord(i);if(!(Object.keys(o).length===0&&Object.keys(s).length===0))return Object.assign({},it.parseKeyPairsIntoRecord(i),it.parseKeyPairsIntoRecord(n))}function lf(t){try{var e=new URL(t);return e.toString()}catch{p.warn("Configuration: Could not parse environment-provided export URL: '"+t+"', falling back to undefined");return}}function ff(t,e){try{new URL(t)}catch{p.warn("Configuration: Could not parse environment-provided export URL: '"+t+"', falling back to undefined");return}t.endsWith("/")||(t=t+"/"),t+=e;try{new URL(t)}catch{p.warn("Configuration: Provided URL appended with '"+e+"' is not a valid URL, using 'undefined' instead of '"+t+"'");return}return t}function pf(t){var e,r=(e=process.env.OTEL_EXPORTER_OTLP_ENDPOINT)===null||e===void 0?void 0:e.trim();if(!(r==null||r===""))return ff(r,t)}function _f(t){var e,r=(e=process.env["OTEL_EXPORTER_OTLP_"+t+"_ENDPOINT"])===null||e===void 0?void 0:e.trim();if(!(r==null||r===""))return lf(r)}function Ja(t,e){var r;return Lr(Lr({},Wa(t)),{url:(r=_f(t))!==null&&r!==void 0?r:pf(e),headers:Lt(uf(t))})}g();function df(t){return t?.keepAlive!=null&&(t.httpAgentOptions!=null?t.httpAgentOptions.keepAlive==null&&(t.httpAgentOptions.keepAlive=t.keepAlive):t.httpAgentOptions={keepAlive:t.keepAlive}),t.httpAgentOptions}function pt(t,e,r,n){return t.metadata&&p.warn("Metadata cannot be set when using http"),Xa({url:t.url,headers:Lt(t.headers),concurrencyLimit:t.concurrencyLimit,timeoutMillis:t.timeoutMillis,compression:t.compression,agentOptions:df(t)},Ja(e,r),za(n,r))}var mf=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},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)}})(),_t=(function(t){mf(e,t);function e(r){return r===void 0&&(r={}),t.call(this,ft(pt(r,"LOGS","v1/logs",{"User-Agent":"OTel-OTLP-Exporter-JavaScript/"+Na,"Content-Type":"application/json"}),Ar))||this}return e})(Ge);g();g();g();g();var hf=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.")},Ef=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return o},Za=(function(){function t(e,r,n){this.attributes={},this.totalAttributesCount=0,this._isReadonly=!1;var i=n.timestamp,o=n.observedTimestamp,s=n.severityNumber,c=n.severityText,l=n.body,a=n.attributes,u=a===void 0?{}:a,f=n.context,d=Date.now();if(this.hrTime=Wt(i??d),this.hrTimeObserved=Wt(o??d),f){var T=ae.getSpanContext(f);T&&ie(T)&&(this.spanContext=T)}this.severityNumber=s,this.severityText=c,this.body=l,this.resource=e.resource,this.instrumentationScope=r,this._logRecordLimits=e.logRecordLimits,this.setAttributes(u)}return Object.defineProperty(t.prototype,"severityText",{get:function(){return this._severityText},set:function(e){this._isLogRecordReadonly()||(this._severityText=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"severityNumber",{get:function(){return this._severityNumber},set:function(e){this._isLogRecordReadonly()||(this._severityNumber=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"body",{get:function(){return this._body},set:function(e){this._isLogRecordReadonly()||(this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"droppedAttributesCount",{get:function(){return this.totalAttributesCount-Object.keys(this.attributes).length},enumerable:!1,configurable:!0}),t.prototype.setAttribute=function(e,r){return this._isLogRecordReadonly()?this:r===null?this:e.length===0?(p.warn("Invalid attribute key: "+e),this):!Ft(r)&&!(typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length>0)?(p.warn("Invalid attribute value set for key: "+e),this):(this.totalAttributesCount+=1,Object.keys(this.attributes).length>=this._logRecordLimits.attributeCountLimit&&!Object.prototype.hasOwnProperty.call(this.attributes,e)?(this.droppedAttributesCount===1&&p.warn("Dropping extra attributes."),this):(Ft(r)?this.attributes[e]=this._truncateToSize(r):this.attributes[e]=r,this))},t.prototype.setAttributes=function(e){var r,n;try{for(var i=hf(Object.entries(e)),o=i.next();!o.done;o=i.next()){var s=Ef(o.value,2),c=s[0],l=s[1];this.setAttribute(c,l)}}catch(a){r={error:a}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return this},t.prototype.setBody=function(e){return this.body=e,this},t.prototype.setSeverityNumber=function(e){return this.severityNumber=e,this},t.prototype.setSeverityText=function(e){return this.severityText=e,this},t.prototype._makeReadonly=function(){this._isReadonly=!0},t.prototype._truncateToSize=function(e){var r=this,n=this._logRecordLimits.attributeValueLengthLimit;return n<=0?(p.warn("Attribute value limit must be positive, got "+n),e):typeof e=="string"?this._truncateToLimitUtil(e,n):Array.isArray(e)?e.map(function(i){return typeof i=="string"?r._truncateToLimitUtil(i,n):i}):e},t.prototype._truncateToLimitUtil=function(e,r){return e.length<=r?e:e.substring(0,r)},t.prototype._isLogRecordReadonly=function(){return this._isReadonly&&p.warn("Can not execute the operation on emitted log record"),this._isReadonly},t})();var $n=function(){return $n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},$n.apply(this,arguments)},qa=(function(){function t(e,r){this.instrumentationScope=e,this._sharedState=r}return t.prototype.emit=function(e){var r=e.context||I.active(),n=new Za(this._sharedState,this.instrumentationScope,$n({context:r},e));this._sharedState.activeProcessor.onEmit(n,r),n._makeReadonly()},t})();function Qa(){return{forceFlushTimeoutMillis:3e4,logRecordLimits:{attributeValueLengthLimit:k().OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT,attributeCountLimit:k().OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT},includeTraceContext:!0,mergeResourceWithDefaults:!0}}function es(t){var e,r,n,i,o,s,c=Ze();return{attributeCountLimit:(n=(r=(e=t.attributeCountLimit)!==null&&e!==void 0?e:c.OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT)!==null&&r!==void 0?r:c.OTEL_ATTRIBUTE_COUNT_LIMIT)!==null&&n!==void 0?n:Ae,attributeValueLengthLimit:(s=(o=(i=t.attributeValueLengthLimit)!==null&&i!==void 0?i:c.OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT)!==null&&o!==void 0?o:c.OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT)!==null&&s!==void 0?s:ye}}var ts=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{a(n.next(u))}catch(f){s(f)}}function l(u){try{a(n.throw(u))}catch(f){s(f)}}function a(u){u.done?o(u.value):i(u.value).then(c,l)}a((n=n.apply(t,e||[])).next())})},rs=function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(a){return function(u){return l([a,u])}}function l(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}o[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},ns=(function(){function t(e,r){this.processors=e,this.forceFlushTimeoutMillis=r}return t.prototype.forceFlush=function(){return ts(this,void 0,void 0,function(){var e;return rs(this,function(r){switch(r.label){case 0:return e=this.forceFlushTimeoutMillis,[4,Promise.all(this.processors.map(function(n){return nt(n.forceFlush(),e)}))];case 1:return r.sent(),[2]}})})},t.prototype.onEmit=function(e,r){this.processors.forEach(function(n){return n.onEmit(e,r)})},t.prototype.shutdown=function(){return ts(this,void 0,void 0,function(){return rs(this,function(e){switch(e.label){case 0:return[4,Promise.all(this.processors.map(function(r){return r.shutdown()}))];case 1:return e.sent(),[2]}})})},t})();var os=(function(){function t(){}return t.prototype.forceFlush=function(){return Promise.resolve()},t.prototype.onEmit=function(e,r){},t.prototype.shutdown=function(){return Promise.resolve()},t})();var is=(function(){function t(e,r,n){this.resource=e,this.forceFlushTimeoutMillis=r,this.logRecordLimits=n,this.loggers=new Map,this.registeredLogRecordProcessors=[],this.activeProcessor=new os}return t})();var gf="unknown";function vf(t,e){var r=e??D.empty();return t?D.default().merge(r):r}var Kn=(function(){function t(e){e===void 0&&(e={});var r=Sn({},Qa(),e),n=vf(r.mergeResourceWithDefaults,e.resource);this._sharedState=new is(n,r.forceFlushTimeoutMillis,es(r.logRecordLimits)),this._shutdownOnce=new ot(this._shutdown,this)}return t.prototype.getLogger=function(e,r,n){if(this._shutdownOnce.isCalled)return p.warn("A shutdown LoggerProvider cannot provide a Logger"),De;e||p.warn("Logger requested without instrumentation scope name.");var i=e||gf,o=i+"@"+(r||"")+":"+(n?.schemaUrl||"");return this._sharedState.loggers.has(o)||this._sharedState.loggers.set(o,new qa({name:i,version:r,schemaUrl:n?.schemaUrl},this._sharedState)),this._sharedState.loggers.get(o)},t.prototype.addLogRecordProcessor=function(e){this._sharedState.registeredLogRecordProcessors.length===0&&this._sharedState.activeProcessor.shutdown().catch(function(r){return p.error("Error while trying to shutdown current log record processor",r)}),this._sharedState.registeredLogRecordProcessors.push(e),this._sharedState.activeProcessor=new ns(this._sharedState.registeredLogRecordProcessors,this._sharedState.forceFlushTimeoutMillis)},t.prototype.forceFlush=function(){return this._shutdownOnce.isCalled?(p.warn("invalid attempt to force flush after LoggerProvider shutdown"),this._shutdownOnce.promise):this._sharedState.activeProcessor.forceFlush()},t.prototype.shutdown=function(){return this._shutdownOnce.isCalled?(p.warn("shutdown may only be called once per LoggerProvider"),this._shutdownOnce.promise):this._shutdownOnce.call()},t.prototype._shutdown=function(){return this._sharedState.activeProcessor.shutdown()},t})();var Tf=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.")},Wn=(function(){function t(){}return t.prototype.export=function(e,r){this._sendLogRecords(e,r)},t.prototype.shutdown=function(){return Promise.resolve()},t.prototype._exportInfo=function(e){var r,n,i;return{resource:{attributes:e.resource.attributes},instrumentationScope:e.instrumentationScope,timestamp:J(e.hrTime),traceId:(r=e.spanContext)===null||r===void 0?void 0:r.traceId,spanId:(n=e.spanContext)===null||n===void 0?void 0:n.spanId,traceFlags:(i=e.spanContext)===null||i===void 0?void 0:i.traceFlags,severityText:e.severityText,severityNumber:e.severityNumber,body:e.body,attributes:e.attributes}},t.prototype._sendLogRecords=function(e,r){var n,i;try{for(var o=Tf(e),s=o.next();!s.done;s=o.next()){var c=s.value;console.dir(this._exportInfo(c),{depth:3})}}catch(l){n={error:l}}finally{try{s&&!s.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}r?.({code:x.SUCCESS})},t})();g();var Sf=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{a(n.next(u))}catch(f){s(f)}}function l(u){try{a(n.throw(u))}catch(f){s(f)}}function a(u){u.done?o(u.value):i(u.value).then(c,l)}a((n=n.apply(t,e||[])).next())})},yf=function(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(a){return function(u){return l([a,u])}}function l(a){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}o[2]&&r.ops.pop(),r.trys.pop();continue}a=e.call(t,r)}catch(u){a=[6,u],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},as=(function(){function t(e,r){var n,i,o,s;this._exporter=e,this._finishedLogRecords=[];var c=k();this._maxExportBatchSize=(n=r?.maxExportBatchSize)!==null&&n!==void 0?n:c.OTEL_BLRP_MAX_EXPORT_BATCH_SIZE,this._maxQueueSize=(i=r?.maxQueueSize)!==null&&i!==void 0?i:c.OTEL_BLRP_MAX_QUEUE_SIZE,this._scheduledDelayMillis=(o=r?.scheduledDelayMillis)!==null&&o!==void 0?o:c.OTEL_BLRP_SCHEDULE_DELAY,this._exportTimeoutMillis=(s=r?.exportTimeoutMillis)!==null&&s!==void 0?s:c.OTEL_BLRP_EXPORT_TIMEOUT,this._shutdownOnce=new ot(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(p.warn("BatchLogRecordProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize"),this._maxExportBatchSize=this._maxQueueSize)}return t.prototype.onEmit=function(e){this._shutdownOnce.isCalled||this._addToBuffer(e)},t.prototype.forceFlush=function(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()},t.prototype.shutdown=function(){return this._shutdownOnce.call()},t.prototype._shutdown=function(){return Sf(this,void 0,void 0,function(){return yf(this,function(e){switch(e.label){case 0:return this.onShutdown(),[4,this._flushAll()];case 1:return e.sent(),[4,this._exporter.shutdown()];case 2:return e.sent(),[2]}})})},t.prototype._addToBuffer=function(e){this._finishedLogRecords.length>=this._maxQueueSize||(this._finishedLogRecords.push(e),this._maybeStartTimer())},t.prototype._flushAll=function(){var e=this;return new Promise(function(r,n){for(var i=[],o=Math.ceil(e._finishedLogRecords.length/e._maxExportBatchSize),s=0;s<o;s++)i.push(e._flushOneBatch());Promise.all(i).then(function(){r()}).catch(n)})},t.prototype._flushOneBatch=function(){var e=this;return this._clearTimer(),this._finishedLogRecords.length===0?Promise.resolve():new Promise(function(r,n){nt(e._export(e._finishedLogRecords.splice(0,e._maxExportBatchSize)),e._exportTimeoutMillis).then(function(){return r()}).catch(n)})},t.prototype._maybeStartTimer=function(){var e=this;this._timer===void 0&&(this._timer=setTimeout(function(){e._flushOneBatch().then(function(){e._finishedLogRecords.length>0&&(e._clearTimer(),e._maybeStartTimer())}).catch(function(r){K(r)})},this._scheduledDelayMillis),ue(this._timer))},t.prototype._clearTimer=function(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)},t.prototype._export=function(e){var r=this,n=function(){return zt._export(r._exporter,e).then(function(o){var s;o.code!==x.SUCCESS&&K((s=o.error)!==null&&s!==void 0?s:new Error("BatchLogRecordProcessor: log record export failed (status "+o+")"))}).catch(K)},i=e.map(function(o){return o.resource}).filter(function(o){return o.asyncAttributesPending});return i.length===0?n():Promise.all(i.map(function(o){var s;return(s=o.waitForAsyncAttributes)===null||s===void 0?void 0:s.call(o)})).then(n,K)},t})();var Af=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},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)}})(),we=(function(t){Af(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.onShutdown=function(){},e})(as);var dt={TARGET:"target",NAMESPACE:"namespace",ENV_NAME:"envname",HOST_IP:"net.host.ip",HOST_NAME:"net.host.name",HOST_PORT:"net.host.port",CONTAINER_NAME:"container.name",SET_NAME:"set.name",SERVICE_NAME:"service.name",SERVER_OWNER:"server.owner",TENANT_ID:"tps.tenant.id",CMDB_ID:"cmdb.module.id",LANGUAGE:"telemetry.sdk.language",SDK_NAME:"telemetry.sdk.name",SDK_VERSION:"telemetry.sdk.version"};var ss;(function(t){t.ClientStartedTotal="rpc_client_started_total",t.ClientHandledTotal="rpc_client_handled_total",t.ClientHandledSeconds="rpc_client_handled_seconds",t.ServerStartedTotal="rpc_server_started_total",t.ServerHandledTotal="rpc_server_handled_total",t.ServerHandledSeconds="rpc_server_handled_seconds"})(ss||(ss={}));var cs;(function(t){t.ProcessCpuUsage="process_cpu_usage",t.ProcessResidentMemoryUsage="process_resident_memory_usage",t.ProcessNetworkInBytes="process_network_in_bytes",t.ProcessNetworkOutBytes="process_network_out_bytes",t.ProcessBlockReadBytes="process_block_read_bytes",t.ProcessBlockWriteBytes="process_block_write_bytes",t.ProcessContainerNum="process_container_num",t.ProcessGpuUsage="process_gpu_usage",t.ProcessVideoMemoryUsage="process_video_memory_usage",t.ProcessDiskUsage="process_disk_usage",t.ProcessTcpNum="process_tcp_num",t.ProcessUdpNum="process_udp_num",t.ProcessMaxFds="process_max_fds",t.ProcessOpenFds="process_open_fds",t.ProcessPidNum="process_pid_num",t.ProcessDiskFree="process_disk_free",t.ProcessDiskUsed="process_disk_used",t.ProcessDiskUsedFraction="process_disk_used_fraction",t.ProcessCpuCores="process_cpu_cores"})(cs||(cs={}));var O;(function(t){t.CallerService="caller_service",t.CallerMethod="caller_method",t.CallerConSetid="caller_con_setid",t.CallerServer="caller_server",t.CalleeServer="callee_server",t.CalleeService="callee_service",t.CalleeMethod="callee_method",t.CalleeConSetid="callee_con_setid",t.CallerGroup="caller_group",t.CodeType="code_type",t.Code="code",t.UserExt1="user_ext1",t.UserExt2="user_ext2",t.UserExt3="user_ext3",t.CalleeIp="callee_ip",t.CalleeContainer="callee_container",t.CallerIp="caller_ip",t.CallerContainer="caller_container"})(O||(O={}));var us;(function(t){t.clientMetrics="client_metrics",t.serverMetrics="server_metrics"})(us||(us={}));var P;(function(t){t.Target="target",t.EnvName="env_name",t.Namespace="namespace",t.ServiceName="service_name",t.ContainerName="container_name",t.Instance="instance",t.Version="version",t.ConSetid="con_setid"})(P||(P={}));var G;(function(t){t.Development="Development",t.Production="Production"})(G||(G={}));var ee;(function(t){t.Formal="formal",t.Test="test"})(ee||(ee={}));var wr;(function(t){t.Webjs="webjs",t.Nodejs="nodejs"})(wr||(wr={}));var ls="galileo";g();var Of="https://galileotelemetry.tencent.com/v1/metrics";var fs="https://galileotelemetry.tencent.com/v1/logs";var Rf="https://galileotelemetry.tencent.com/v1/metrics";var xf="https://sg.tgalileo.com/v1/metrics";var Lf="http://galileotelemetry.tencent.com:80/v1/metrics";var wf=t=>{try{let e=new URL(t).hostname.toLowerCase();if(e==="galileotelemetry.tencent.com")return"mainland-public";if(e==="sg.tgalileo.com"||e.endsWith(".sg.tgalileo.com"))return"singapore-public";if(e==="galileotelemetry.tencent.com"||e==="galileotelemetry.tencent.com"||e==="galileotelemetry.tencent.com"||e==="galileotelemetry.tencent.com")return"singapore-intranet"}catch{}return"mainland-intranet"};var ps=t=>{switch(wf(t)){case"mainland-public":return Rf;case"singapore-public":return xf;case"singapore-intranet":return Lf;default:return Of}},be="0.3.12",_s="NodeStats",bf=[O.UserExt1,O.UserExt2,O.UserExt3];var Pf={[O.CallerService]:"",[O.CallerMethod]:"",[O.CallerConSetid]:"",[O.CallerServer]:"",[O.CallerGroup]:"",[O.CallerIp]:"",[O.CallerContainer]:"",[O.CalleeService]:"",[O.CalleeMethod]:"",[O.CalleeConSetid]:"",[O.CalleeServer]:"",[O.CalleeIp]:"",[O.CalleeContainer]:""};g();var mt;(function(t){t[t.DELTA=0]="DELTA",t[t.CUMULATIVE=1]="CUMULATIVE",t[t.LOWMEMORY=2]="LOWMEMORY"})(mt||(mt={}));g();var Mf=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},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)}})(),Yn=function(){return R.CUMULATIVE},ds=function(t){switch(t){case _.COUNTER:case _.OBSERVABLE_COUNTER:case _.GAUGE:case _.HISTOGRAM:case _.OBSERVABLE_GAUGE:return R.DELTA;case _.UP_DOWN_COUNTER:case _.OBSERVABLE_UP_DOWN_COUNTER:return R.CUMULATIVE}},ms=function(t){switch(t){case _.COUNTER:case _.HISTOGRAM:return R.DELTA;case _.GAUGE:case _.UP_DOWN_COUNTER:case _.OBSERVABLE_UP_DOWN_COUNTER:case _.OBSERVABLE_COUNTER:case _.OBSERVABLE_GAUGE:return R.CUMULATIVE}};function If(){var t=k(),e=t.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE.trim().toLowerCase();return e==="cumulative"?Yn:e==="delta"?ds:e==="lowmemory"?ms:(p.warn("OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE is set to '"+t.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE+"', but only 'cumulative' and 'delta' are allowed. Using default ('cumulative') instead."),Yn)}function Nf(t){return t!=null?t===mt.DELTA?ds:t===mt.LOWMEMORY?ms:Yn:If()}function Cf(t){return t?.aggregationPreference?t.aggregationPreference:function(e){return b.Default()}}var hs=(function(t){Mf(e,t);function e(r,n){var i=t.call(this,r)||this;return i._aggregationSelector=Cf(n),i._aggregationTemporalitySelector=Nf(n?.temporalityPreference),i}return e.prototype.selectAggregation=function(r){return this._aggregationSelector(r)},e.prototype.selectAggregationTemporality=function(r){return this._aggregationTemporalitySelector(r)},e})(Ge);var Es="0.57.2";var Uf=(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])},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)}})(),br=function(){return br=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},br.apply(this,arguments)},Df={"User-Agent":"OTel-OTLP-Exporter-JavaScript/"+Es},ht=(function(t){Uf(e,t);function e(r){return t.call(this,ft(pt(r??{},"METRICS","v1/metrics",br(br({},Df),{"Content-Type":"application/json"})),Or),r)||this}return e})(hs);var gs=t=>{let r=[new Un({exporter:new ht({temporalityPreference:R.DELTA,url:t.addr,concurrencyLimit:30,compression:ke.GZIP}),exportIntervalMillis:3e4,exportTimeoutMillis:2e4})],n=[new yr({instrumentName:"node_instrument_start",aggregation:new ut,instrumentType:_.COUNTER}),new yr({instrumentName:"node_instrument_end",aggregation:new ut,instrumentType:_.COUNTER})];return new Fn({resource:t.resource,views:n,readers:r})};var Ts=(t,e,r)=>gs({resource:new D({[P.Target]:"PCG-123.galileo.otp",[P.ServiceName]:"galileo.otp",[P.Namespace]:G.Production,[P.EnvName]:t===G.Production?ee.Formal:e,[P.Version]:be,[P.Instance]:"",[P.ContainerName]:"",[P.ConSetid]:""}),addr:r});var vs=function(){let t=new WeakSet;return function(e,r){if(r instanceof Error)return`Error.message: ${r.message}
|
|
16
|
+
Error.stack: ${r.stack}`;if(typeof r=="object"&&r!==null){if(t.has(r))return`[Circular ${e||"root"}]`;t.add(r)}return r}},Ss=function(t){if(typeof t=="string")return t;try{return t instanceof Error?(JSON.stringify(t,vs())||"undefined").replace(/"/gim,""):JSON.stringify(t,vs())||"undefined"}catch(e){return`error happen when aegis stringify:
|
|
17
|
+
${e?.message}
|
|
18
|
+
${e?.stack}`}};var ys=()=>{var t;let e=ae.getSpan(I.active());return((t=e?.spanContext())===null||t===void 0?void 0:t.traceFlags)===oe.SAMPLED};var Et;(function(t){t.trace="trace",t.debug="debug",t.info="info",t.warn="warn",t.error="error"})(Et||(Et={}));var Pe;(function(t){t[t.trace=1]="trace",t[t.debug=5]="debug",t[t.info=9]="info",t[t.warn=13]="warn",t[t.error=17]="error"})(Pe||(Pe={}));function Bf(t){if(!t)return Et.trace;if(typeof t=="string"){let e=t.toLowerCase();return Object.values(Et).includes(e)?e:Et.trace}return t}var Pr=class{constructor(e){var r;this.getResource=yt=>{let{platform:ec,serverName:no}=this;return new D({[P.Target]:`${ec}.${no}`,[P.Namespace]:yt,[dt.SERVICE_NAME]:`${no}`,[dt.SDK_NAME]:ls,[dt.LANGUAGE]:wr.Nodejs,[dt.SDK_VERSION]:be})};let{env:n=ee.Test,namespace:i,app:o,server:s,attributes:c={},platform:l,logCollectorAddr:a=fs,enableLocalConsole:u=!1,enableConsole:f=!1,level:d,mustLogTraced:T=!1}=e,C=i===G.Production?ee.Formal:n,ne=ps(a);this.platform=l,this.serverName=`${o}.${s}`,this.enableLocalConsole=u,this.enableConsole=f,this.mustLogTraced=T;let he=(r=process.env)===null||r===void 0?void 0:r.GALILEO_LOG_LEVEL;if(this.currentLevel=Bf(d||he),!this.serverName)throw new Error("app and server are required");this.initLogRecorder(C,c),this.logger=this.initLogger(i,C,a),this.selfMeter=Ts(i,C,ne).getMeter(_s,""),this.selfAttributes={SdkTarget:`${l}.${this.serverName}`,TargetNameSpace:i,ReportType:"log",Protocol:"",Kind:"",Status:""},this.nodeInstrumentStartCounter=this.selfMeter.createCounter("node_instrument_start",{valueType:L.INT}),this.nodeInstrumentEndCounter=this.selfMeter.createCounter("node_instrument_end",{valueType:L.INT});try{this.enableConsole&&this.overrideConsole()}catch{}}initLogRecorder(e,r){this.logRecorder={severityNumber:Ue.INFO,severityText:"info",body:"",attributes:{...r,server:this.serverName,env:e},instrumentationScope:{name:"default",version:be}}}updateLogRecorderAttributes(e){if(!e)throw new Error("attributes is required");this.logRecorder.attributes={...this.logRecorder.attributes,...e}}initLogger(e,r,n){let i=this.getResource(e),o=new Kn({resource:i}),s={url:n,headers:{"Content-Type":"application/json"},concurrencyLimit:30},c=new _t(s),l=new we(c);return o.addLogRecordProcessor(l),this.enableLocalConsole&&e!==G.Production&&r!==ee.Formal&&o.addLogRecordProcessor(new we(new Wn)),o.getLogger("default",be)}emit(e){this.logger.emit(e)}overrideConsole(){let e=console,r=this;["log","info","error","warn","debug","trace"].forEach(i=>{let o=e[i];console[i]=function(...s){try{let c=new Error().stack,l="";if(c){let a=c.split(`
|
|
19
|
+
`);a.length>2&&(l=a[2].trim())}if(l.includes("trpc-config-env"))return;if(!l.includes("galileo-node-sdk")){let a=s.map(u=>typeof u=="string"?u:Ss(u)).join(" ");i==="log"?r.method("info",`[Console.log] ${a}`):r.method(i,`[Console.${i}] ${a}`)}}catch{}o.apply(e,s)}})}shouldLog(e){return Pe[e]>=Pe[this.currentLevel]}method(e,r,n){var i,o;this.nodeInstrumentStartCounter.add(1,{...this.selfAttributes});let s=e;if(!(s in Pe))throw new Error(`method [${s}] not found`);if(!(this.mustLogTraced&&ys())&&!this.shouldLog(s))return;let l=n&&!(!((i=Object.values(n))===null||i===void 0)&&i.some(T=>typeof T!="string")),a={},u=ae.getSpan(I.active()),f=(o=u?.attributes)===null||o===void 0?void 0:o["http.user_agent"];f&&(a.user_agent=f);let d={...this.logRecorder,attributes:{...this.logRecorder.attributes,...a,...l?n:{}},severityNumber:Pe[s],severityText:s,body:r};this.nodeInstrumentEndCounter.add(1,{...this.selfAttributes,Status:"success"}),this.emit(d)}info(e,r){this.method("info",e,r)}error(e,r){this.method("error",e,r)}debug(e,r){this.method("debug",e,r)}trace(e,r){this.method("trace",e,r)}warn(e,r){this.method("warn",e,r)}sampledInfo(e,r){this.method("info",e,r)}};var Gf=!0,Vf={siboot:"",coboot:"https://galileotelemetry.tencent.com"};function As(t,e,r={platform:t==="coboot"?"ElectronApp":"Electron",app:t,server:"app_main"}){let n=Vf[t];return{...r,namespace:e?G.Production:G.Development,env:e?"formal":"test",metricsCollectorAddr:`${n}/v1/metrics`,traceCollectorAddr:`${n}/v1/traces`,logCollectorAddr:`${n}/v1/logs`,enableRemoteConfig:!1}}function Os(t){return new Pr(t)}var Xn=(t,e)=>t[e]?.trim()||void 0;function kf(t,e=process.env){return{platform:Xn(e,"CU_HEADLESS_GALILEO_PLATFORM")||(t==="coboot"?"ElectronApp":"Electron"),app:Xn(e,"CU_HEADLESS_GALILEO_APP")||t,server:Xn(e,"CU_HEADLESS_GALILEO_SERVER")||"app_main"}}function Rs(t,e,r=process.env){return{...As(t,e,kf(t,r)),enableHTTP:!1,enableTRPC:!1,enableFetch:!1,traceConfig:{enable:!1,processor:{sampler:{fraction:0,enableRandomSample:!1,enableParentSample:!1},enableTraceBody:!1}}}}var Ls=16384,$f=15100,Kf=/(?:^|\s)(event|level|run_id|daemon_pid|pid|start_count|retry_ms|duration_ms|stopping|exit_signal|job_id|type|version|from_version|target_version|phase|exit_code)=([^\s]+)/g;function ws(t){return At(t.replace(/https?:\/\/[^\s"'<>]+/gi,e=>{try{let r=new URL(e);return r.username="",r.password="",r.search="",r.hash="",r.toString()}catch{return"[redacted-url]"}}).replace(/\b(signature|sign|HEADLESS_DEVICE_TOKEN)\s*[:=]\s*[^\s,;]+/gi,"$1=[redacted]"))}function Wf(t){return/^\S+ \[daemon\] /.test(t)||t.startsWith("[daemon]")?"daemon":/^\S+ \[anydev-update\] /.test(t)?"update":"startup"}function Yf(t){if(!t.SIBOOT_BASE_DIR)return t.APP_VERSION||"unknown";try{return JSON.parse(Hf.readFileSync(Ff.join(t.SIBOOT_BASE_DIR,"current/manifest.json"),"utf8")).version||t.APP_VERSION||"unknown"}catch{return t.APP_VERSION||"unknown"}}function Xf(t,e,r,n){let i={clientType:r.CLIENT_TYPE||"anydev",hostname:r.HOSTNAME||xs.hostname(),device_id:r.HOSTNAME||xs.hostname(),uid:r.CLIENT_UID||r.ANY_USERNAME||"",log_source:n,stream:e,version:Yf(r)};for(let s of t.matchAll(Kf))i[s[1]]=s[2];return{level:i.level==="error"||e==="stderr"||i.level!=="info"&&/\b(failed|error|missing|job_failed)\b/i.test(t)?"error":"info",body:ws(t),attributes:Object.fromEntries(Object.entries(i).map(([s,c])=>[s,ws(c)]))}}var Mr=class{constructor(e){this.env=e;let r=Rs("coboot",!(e.BACKEND_URL||"").includes("testsite"),{});this.logger=Os({...r,enableConsole:!1,enableLocalConsole:!1})}logger;lastRecordAt=0;closing;record(e,r,n=Wf(e)){if(!e.trim()||this.closing)return;let i=Xf(e,r,this.env,n);oo(this.logger,i.level,i.body,i.attributes),this.lastRecordAt=Date.now()}close(){let e=this.lastRecordAt?Math.max(0,$f-(Date.now()-this.lastRecordAt)):0;return this.closing??=new Promise(r=>setTimeout(r,e)),this.closing}};function bs(t){let e=new jf("utf8"),r="",n=!1,i=o=>{for(let s of o.split(/(?<=\n)/))n||(r+=s,r.length>Ls&&(r=r.slice(0,Ls),n=!0)),s.endsWith(`
|
|
20
|
+
`)&&(t(r.trimEnd()),r="",n=!1)};return{write:o=>i(e.write(o)),end:()=>{i(e.end()),r&&t(r),r=""}}}function Ps(t){if(process.env.ANYDEV_LOG_CAPTURED==="1"||t==="startup"&&process.argv.slice(2).includes("logs"))return()=>Promise.resolve();let e=new Mr(process.env),r=["stdout","stderr"].map(o=>{let s=process[o],c=s.write.bind(s),l=bs(a=>e.record(a,o,t));return s.write=(a,u,f)=>(l.write(typeof a=="string"?Buffer.from(a,typeof u=="string"?u:void 0):Buffer.from(a)),typeof u=="function"?c(a,u):c(a,u,f)),{lines:l,stream:s,original:c}}),n,i=()=>{if(!n){for(let{lines:o,stream:s,original:c}of r)s.write=c,o.end();n=e.close()}return n};return process.once("beforeExit",()=>{i()}),i}import{execFileSync as Up,spawn as Xs}from"child_process";import y from"fs";import $s from"os";import E from"path";import{fileURLToPath as Dp}from"url";var zf=new Set(["help","install-browser","start","stop","restart","update","status","logs"]);function Ms(t="siboot-headless",e="/data/siboot",r=!1,n="SIBOOT_DATA_ROOT"){let i=r?` ${t} install-browser
|
|
3
21
|
`:"";console.log(`Usage:
|
|
4
|
-
${
|
|
5
|
-
${
|
|
6
|
-
${
|
|
22
|
+
${t} <device-token>
|
|
23
|
+
${t} --force-enroll <device-token>
|
|
24
|
+
${i} ${t} start|stop|restart|update|status|logs
|
|
7
25
|
|
|
8
26
|
Environment:
|
|
9
|
-
|
|
10
|
-
${r.join(`
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
`)
|
|
14
|
-
`))}async function
|
|
15
|
-
`))
|
|
16
|
-
`,256)}function y(e,r){Ne(e,r);let t=c.join(e.scripts,"daemon.mjs");l.existsSync(t)||g(c.join(r,"daemon.mjs"),t,320)}function We(e,r,t={platform:process.platform,arch:process.arch}){let n=O(e,r,t);return y(r,n.releaseDir),n}var ee=Je(import.meta.url),re={siboot:"/data/siboot",coboot:"/data/coboot"},Ge=15e3,z=7e3,Xe=73,Z=20,Ye=["BACKEND_URL","WS_URL","SIBOOT_URL","MCP_CREDENTIAL_API_BASE_URL","SKILL_CREDENTIAL_API_BASE_URL"],Ke=["HEADLESS_BWRAP_EXECUTABLE","HEADLESS_BWRAP_LOADER","HEADLESS_BWRAP_LIBRARY_DIR"];function ze(e,r){let t=e||re[r],n=i.resolve(t);if(!i.isAbsolute(t)||n===i.parse(n).root)throw new Error(`SIBOOT_DATA_ROOT must be a non-root absolute path: ${e}`);return n}function Ze(e=process.env.SIBOOT_DATA_ROOT,r="siboot"){if(!(r in re))throw new Error(`unsupported headless edition: ${r}`);let t=ze(e,r),n=i.join(t,".siboot");return{edition:r,root:t,home:n,releases:i.join(n,"releases"),current:i.join(n,"current"),scripts:i.join(n,"scripts"),run:i.join(n,"run"),logs:i.join(n,"logs"),workspace:i.join(t,"workspace"),credential:i.join(n,"headless-device-credential.json"),authSession:i.join(n,"headless-auth-session.json")}}function qe(e,r){return`npx -y '${e}@${r}' install-browser`}function R(e){try{let r=Number.parseInt(m.readFileSync(e,"utf8").trim(),10);return Number.isInteger(r)&&r>0?r:null}catch{return null}}function S(e,r=process.platform==="linux"?"/proc":""){if(!e)return!1;try{process.kill(e,0)}catch{return!1}if(!r)return!0;try{let t=m.readFileSync(i.join(r,String(e),"stat"),"utf8"),n=t.lastIndexOf(") ")+2;return n<2||t[n]!=="Z"}catch{return!0}}function ne(e,r){let t="";try{t=m.readFileSync(`/proc/${e}/cmdline`,"utf8").replaceAll("\0"," ").trim()}catch{}if(!t)try{t=Ve("ps",["-ww","-p",String(e),"-o","command="],{encoding:"utf8"}).trim()}catch{return!1}return r.some(n=>[n,F(n)].some(o=>t.includes(o)))}var k=e=>new Promise(r=>setTimeout(r,e));function T(e=process.versions.node){let r=Number.parseInt(String(e).split(".")[0],10);if(!Number.isInteger(r)||r<Z)throw new Error(`Node.js >=${Z} is required; current version is ${e}`)}async function q(e,r,t){let n=R(e);if(!S(n)){try{m.unlinkSync(e)}catch{}return!1}if(!ne(n,r))throw new Error(`refusing to stop unrelated process from stale ${i.basename(e)}: ${n}`);process.kill(n,"SIGTERM");let o=Date.now()+z;for(;Date.now()<o&&S(n);)await k(100);if(S(n))throw new Error(`${t} did not stop within ${z/1e3} seconds: ${n}`);return R(e)===n&&m.rmSync(e,{force:!0}),!0}async function b(e){let r=await q(i.join(e.run,"daemon.pid"),[i.join(e.current,"daemon.mjs"),i.join(e.scripts,"daemon.mjs")],"daemon"),t=await q(i.join(e.run,"node.pid"),[i.join(e.current,"entry.mjs")],"client");return r||t}function Qe(e,r,t=process.env){let n={...t,CU_EDITION:e.edition,NO_ELECTRON:"1",CLIENT_TYPE:"anydev",SIBOOT_BASE_DIR:e.home,SIBOOT_DATA_ROOT:e.root,HEADLESS_DATA_DIR:e.root,SIBOOT_DATA_DIR:e.root,HEADLESS_DEVICE_CREDENTIAL_PATH:e.credential,HEADLESS_AUTH_SESSION_PATH:e.authSession,HEADLESS_DEVICE_REQUIRE_AUTH:"1",HEADLESS_PREWARM_DEFAULT_SESSION:"0",WORKSPACE:e.workspace,ANYDEV_UPDATE_ENABLED:"0"};r?n.HEADLESS_DEVICE_TOKEN=r:delete n.HEADLESS_DEVICE_TOKEN,delete n.CLIENT_UID,delete n.HEADLESS_DEVICE_FORCE_ENROLL;for(let o of Ke)delete n[o];if(e.edition==="coboot"){let o=i.join(e.current,"native");n.HEADLESS_BWRAP_EXECUTABLE=i.join(o,"bwrap"),n.HEADLESS_BWRAP_LOADER=i.join(o,"ld-musl"),n.HEADLESS_BWRAP_LIBRARY_DIR=i.join(o,"lib"),n.HEADLESS_BROWSER_RUNTIME="system-or-guided-install",n.PLAYWRIGHT_BROWSERS_PATH=P(e.home,t)}else delete n.HEADLESS_BROWSER_RUNTIME,delete n.HEADLESS_BROWSER_INSTALL_COMMAND;if(n.HEADLESS_ALLOW_ENDPOINT_OVERRIDE!=="1")for(let o of Ye)delete n[o];return n}async function er(e,r=Ge){let t=Date.now()+r,n=!1;for(;Date.now()<t;){let o=R(i.join(e.run,"daemon.pid"));if(!S(o))throw new Error("daemon exited during client startup");let s=null;try{s=JSON.parse(m.readFileSync(i.join(e.run,"status.json"),"utf8"))}catch{}if(s?.client_ready===!0&&S(s.client_pid))return;if(s?.client_exit_code!=null&&!s?.client_pid){if(s.client_exit_code===Xe){n=!0,await k(100);continue}throw new Error(`client exited during startup with code ${s.client_exit_code}`)}await k(100)}throw n?new Error("another Headless Driver still holds the machine lock after startup retries"):new Error(`client did not become ready within ${r}ms`)}function I(e,r=""){let t=e.edition==="coboot"?"coboot-headless":"siboot-headless";if(!m.existsSync(e.credential)&&!r)throw new Error(`device credential is missing; run ${t} <device-token> first`);let n=m.existsSync(i.join(e.current,"daemon.mjs"))?i.join(e.current,"daemon.mjs"):i.join(e.scripts,"daemon.mjs"),o=m.existsSync(i.join(e.current,"entry.mjs")),s=m.existsSync(n);if(!o||!s)throw new Error(`runtime is not installed (entry=${o}, daemon=${s}); run ${t} <device-token> first`);return n}async function A(e,r="",t=process.env){C(e);let n=I(e,r),o=m.existsSync(e.credential)?"":r,s=i.join(e.logs,"daemon",`${new Date().toISOString().slice(0,10)}.log`),a=m.openSync(s,"a",384);Q(process.execPath,[n],{detached:!0,env:Qe(e,o,t),stdio:["ignore",a,a]}).unref(),m.closeSync(a),await k(500);let u=R(i.join(e.run,"daemon.pid"));if(!S(u))throw new Error(`daemon failed to start; check ${s}`);return await er(e),{pid:u,logFile:s}}function L(e){try{let r=JSON.parse(m.readFileSync(i.join(e.current,"manifest.json"),"utf8"));return typeof r.version=="string"?r.version:null}catch{return null}}async function rr(e,r={}){return T(r.nodeVersion),I(e),await b(e),A(e,"",r.baseEnv||process.env)}async function te(e,r,t={}){T(t.nodeVersion);let n=t.token||"";if(!m.existsSync(r.credential)&&!n){let d=r.edition==="coboot"?"coboot-headless":"siboot-headless";throw new Error(`device credential is missing; run ${d} <device-token> first`)}let o=j(r),s=L(r),a=O(e,r,t.runtime||{platform:process.platform,arch:process.arch});await b(r),y(r,a.releaseDir);try{let d=await A(r,n,t.baseEnv||process.env);return{previousVersion:s,installed:a,started:d}}catch(d){if(await b(r).catch(()=>{}),!o)throw d;y(r,o);try{await A(r,"",t.baseEnv||process.env)}catch(u){throw new AggregateError([d,u],`headless update failed and the previous runtime could not be restarted: ${u instanceof Error?u.message:String(u)}`)}throw new Error(`headless update failed; restored ${s||"the previous version"}`,{cause:d})}}async function nr(e,r,t,n={}){return oe(r)?se(e,r,t,n):{...await te(e,r,{...n,token:t}),identityReplaced:!1}}async function tr(e,r,t={}){return I(r),te(e,r,t)}function or(e){let r=R(i.join(e.run,"daemon.pid")),t=null;try{t=JSON.parse(m.readFileSync(i.join(e.run,"status.json"),"utf8"))}catch{}console.log(JSON.stringify({running:S(r),pid:r,current:m.existsSync(e.current),status:t},null,2))}async function sr(e){let r=i.join(e.logs,"daemon",`${new Date().toISOString().slice(0,10)}.log`);if(!m.existsSync(r))throw new Error(`log file not found: ${r}`);let t=Q("tail",["-n","100","-f",r],{stdio:"inherit"});await new Promise((n,o)=>{t.once("error",o),t.once("exit",s=>s===0?n():o(new Error(`tail exited ${s}`)))})}function v(e,r=e.version){let t={...process.env};return e.browserRuntime&&(t.HEADLESS_BROWSER_INSTALL_COMMAND=qe(e.packageName,r)),t}function oe(e){return m.existsSync(e.credential)||m.existsSync(e.authSession)}async function se(e,r,t,n={}){T(n.nodeVersion);let o=x(e),s=oe(r),a=j(r),d=L(r),u=O(e,r,n.runtime||{platform:process.platform,arch:process.arch});await b(r);try{return await K(r,async()=>{y(r,u.releaseDir);let f=await A(r,t,n.baseEnv||v(o));return{installed:u,started:f,identityReplaced:s}},()=>b(r))}catch(f){if(!a)throw f;y(r,a);try{await A(r,"",v(o,d||o.version))}catch(p){throw new AggregateError([f,p],`force enrollment failed and the previous runtime could not be restarted: ${p instanceof Error?p.message:String(p)}`)}throw f}}async function ir(){let e=H(process.argv.slice(2)),r=i.basename(process.argv[1]||"siboot-headless"),t=i.dirname(ee),n=x(t),o=Ze(process.env.SIBOOT_DATA_ROOT,n.edition);if(e.command==="help")return M(r,o.root,!!n.browserRuntime);if(e.command==="install-browser"){if(!n.browserRuntime)throw new Error("install-browser is available in the Coboot headless npm package only");return G(t,o)}let s=n.edition==="coboot"?"Coboot":"Siboot";if(e.command==="status")return or(o);if(e.command==="logs")return sr(o);if(e.command==="stop"){let f=await b(o);console.log(f?`${s} Headless stopped`:`${s} Headless is not running`);return}if(e.command==="start"){T(),I(o);let f=R(i.join(o.run,"daemon.pid")),p=[i.join(o.current,"daemon.mjs"),i.join(o.scripts,"daemon.mjs")];if(S(f)&&ne(f,p)){console.log(`${s} Headless is already running (pid=${f})`);return}await b(o);let $=await A(o,"",v(n,L(o)||n.version));console.log(`${s} Headless started in background (pid=${$.pid})`),console.log(`Logs: ${$.logFile}`);return}if(e.command==="restart"){let f=await rr(o,{baseEnv:v(n,L(o)||n.version)});console.log(`${s} Headless restarted in background (pid=${f.pid})`),console.log(`Logs: ${f.logFile}`);return}if(e.command==="update"){let{previousVersion:f,installed:p,started:$}=await tr(t,o,{baseEnv:v(n)});console.log(`${s} Headless updated ${f||"unknown"} -> ${p.version} (pid=${$.pid})`),console.log(`Logs: ${$.logFile}`);return}let{installed:a,started:d,identityReplaced:u}=e.forceEnroll?await se(t,o,e.token):await nr(t,o,e.token||"",{baseEnv:v(n)});console.log(`${s} Headless ${a.version} started in background (pid=${d.pid})`),u?console.log("Existing device credential replaced by new enrollment"):e.forceEnroll&&console.log("Device credential created by force enrollment"),console.log(`Logs: ${d.logFile}`)}function F(e){try{return m.realpathSync(e)}catch{return i.resolve(e)}}process.argv[1]&&F(process.argv[1])===F(ee)&&ir().catch(e=>{let r=i.basename(process.argv[1]||"headless-client");console.error(`${r}: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1});export{T as assertSupportedNodeVersion,Qe as createDaemonEnv,nr as installAndStartHeadlessRuntime,We as installHeadlessRuntime,S as isRunning,H as parseHeadlessCliArgs,x as readPackageMetadata,Ze as resolveHeadlessLayout,rr as restartHeadlessRuntime,A as startHeadlessRuntime,b as stopHeadlessRuntime,tr as updateHeadlessRuntime,I as validateHeadlessRuntimeStart};
|
|
27
|
+
${n} Persistent data root (default: ${e})${n==="COBOOT_DATA_ROOT"?`
|
|
28
|
+
--workspace-dir <absolute-directory> Default Agent working directory (persisted)`:""}`)}function Ir(t,e="siboot"){let r=t.indexOf("--workspace-dir");if(r!==-1){if(e!=="coboot")throw new Error("--workspace-dir is available in Coboot only");let i=t[r+1];if(!i||i.startsWith("--"))throw new Error("--workspace-dir requires a directory");let o=[...t.slice(0,r),...t.slice(r+2)];if(o.includes("--workspace-dir"))throw new Error("--workspace-dir may be specified only once");let s=Ir(o,e);if(!["install","start","restart","update"].includes(s.command))throw new Error("--workspace-dir requires install, start, restart or update");return{...s,workspaceDir:i}}let n=t[0]?.trim()||"";if(!n||n==="--help"||n==="-h"||n==="help")return{command:"help"};if(n==="--force-enroll"){let i=t[1]?.trim()||"";if(!i||t.length!==2)throw new Error("--force-enroll requires one device token");return{command:"install",token:i,forceEnroll:!0}}return zf.has(n)?{command:n}:{command:"install",token:n}}import{execFileSync as Cs}from"child_process";import{createRequire as Jf}from"module";import te from"fs";import Zf from"os";import F from"path";var qf=["/usr/local/bin/google-chrome","/usr/local/bin/chromium","/usr/local/bin/chromium-browser","/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/usr/bin/chromium","/usr/bin/chromium-browser"],Qf="https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm",ep="https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb",tp=[/error while loading shared libraries:\s*([^\s:]+)/gi,/([A-Za-z0-9_.+-]+\.so(?:\.[0-9A-Za-z.]+)?):\s*cannot open shared object file/gi,/Missing libraries:\s*([^]*?)(?:\n\s*\n|$)/gi],rp=[/error while loading shared libraries:/i,/cannot open shared object file/i,/host system is missing dependencies/i,/missing libraries:/i];function Zn(t,e=process.env){let r=e.PLAYWRIGHT_BROWSERS_PATH?.trim();return r||F.join(t,"browsers")}function Jn(t){try{return te.accessSync(t,te.constants.X_OK),!0}catch{return!1}}function Nr(t){for(let e of(process.env.PATH||"").split(F.delimiter)){if(!e)continue;let r=F.join(e,t);if(Jn(r))return r}return null}function Is(){let t=process.env.HEADLESS_BROWSER_EXECUTABLE?.trim();if(t&&Jn(t))return t;for(let e of qf)if(Jn(e))return e;return Nr("google-chrome")||Nr("google-chrome-stable")||Nr("chromium")}function np(t){return rp.some(e=>e.test(t))}function op(t){let e=new Set;for(let r of tp){r.lastIndex=0;for(let n of t.matchAll(r))for(let i of n[1].split(/[\s,]+/)){let o=i.trim().replace(/[.,:;]+$/,"");/\.so(?:\.[0-9A-Za-z.]+)?$/.test(o)&&e.add(o)}}return[...e]}function ip(t={arch:process.arch},e=Nr){let r=t.arch==="x64";if(e("apt-get"))return[{command:"apt-get",args:["update"],optional:!0},{attempts:[{command:"apt-get",args:["install","-y","--no-install-recommends","chromium"]},{command:"apt-get",args:["install","-y","--no-install-recommends","chromium-browser"]},...r?[{download:ep,command:"apt-get",args:["install","-y","--no-install-recommends"]}]:[]]}];if(e("apk"))return[{attempts:[{command:"apk",args:["add","--no-cache","chromium"]},{command:"apk",args:["add","--no-cache","--repository=https://dl-cdn.alpinelinux.org/alpine/edge/community","chromium"]}]}];let n=e("dnf")?"dnf":e("yum")?"yum":"";if(n){let i=[{command:n,args:["install","-y","--setopt=install_weak_deps=False","chromium"]}];return r&&i.push({command:n,args:["install","-y","--setopt=install_weak_deps=False",Qf]}),[{attempts:i}]}throw new Error("unsupported Linux package manager; install system Chrome/Chromium manually and set HEADLESS_BROWSER_EXECUTABLE")}async function ap(t){let e=te.mkdtempSync(F.join(Zf.tmpdir(),"coboot-browser-")),r=F.join(e,F.basename(new URL(t).pathname)||"browser-package");console.log(`Downloading: ${t}`);let n=await fetch(t);if(!n.ok)throw new Error(`download failed with HTTP ${n.status}: ${t}`);return te.writeFileSync(r,Buffer.from(await n.arrayBuffer())),{file:r,directory:e}}async function Ns(t){let e=t.download?await ap(t.download):null,r=e?[...t.args,e.file]:t.args;try{console.log(`Running: ${t.command} ${r.join(" ")}`),Cs(t.command,r,{stdio:"inherit",env:{...process.env,DEBIAN_FRONTEND:"noninteractive"}})}finally{e&&te.rmSync(e.directory,{recursive:!0,force:!0})}}function gt(t){return t instanceof Error?t.message:String(t)}async function sp(){for(let t of ip()){if(!t.attempts){try{await Ns(t)}catch(n){if(!t.optional)throw n;console.warn(`Skipping optional step ${t.command}: ${gt(n)}`)}continue}let e=[],r=!1;for(let n of t.attempts)try{await Ns(n),r=!0;break}catch(i){let o=n.download||n.args[n.args.length-1];e.push(`${o}: ${gt(i)}`),console.warn(`Browser package candidate failed (${o}); trying the next one`)}if(!r)throw new Error(`no browser package could be installed:
|
|
29
|
+
${e.join(`
|
|
30
|
+
`)}`)}}function Us(t){let e=F.join(t,"browser-runtime","playwright-core"),r=Jf(F.join(t,"package.json"));return{driverRoot:e,driver:r(e)}}async function cp(t,e){let{driverRoot:r,driver:n}=Us(t),i=F.join(r,"cli.js"),o=process.env.PLAYWRIGHT_BROWSERS_PATH;try{te.mkdirSync(o,{recursive:!0,mode:448})}catch(s){throw new Error(`\u65E0\u6CD5\u521B\u5EFA\u6D4F\u89C8\u5668\u76EE\u5F55\uFF08${e}\uFF09: ${s?.code||"write failed"}
|
|
31
|
+
\u8BF7\u786E\u8BA4\u5F53\u524D\u7528\u6237\u5BF9\u8BE5\u76EE\u5F55\u6709\u5199\u6743\u9650\uFF0C\u6216\u7528\u8BE5\u76EE\u5F55\u7684\u5C5E\u4E3B\u8D26\u53F7\u91CD\u65B0\u6267\u884C\u3002`)}return console.log(`Downloading Chromium into ${e}`),Cs(process.execPath,[i,"install","chromium","--no-shell"],{stdio:"inherit"}),n.chromium.executablePath()}async function up(t,e){let{driver:r}=Us(t),n=await r.chromium.launch({executablePath:e,headless:!0,args:["--no-sandbox","--disable-gpu","--disable-dev-shm-usage"]});try{let i=await n.newPage();if(await i.setContent("<title>Headless browser ready</title>"),await i.title()!=="Headless browser ready")throw new Error("browser smoke test returned wrong title");return n.version()}finally{await n.close()}}function lp(t,e){let r=op(e),n=r.length?`\u7F3A\u5C11\u7CFB\u7EDF\u52A8\u6001\u5E93: ${r.join(", ")}`:"\u7F3A\u5C11\u7CFB\u7EDF\u4F9D\u8D56\u5E93";return new Error([`${t} \u65E0\u6CD5\u542F\u52A8\uFF0C${n}\u3002`,"\u8865\u9F50\u7CFB\u7EDF\u4F9D\u8D56\u9700\u8981 root \u6743\u9650\uFF0C\u8BF7\u7528 sudo \u91CD\u65B0\u6267\u884C\u540C\u4E00\u6761 install-browser \u547D\u4EE4\uFF0C\u6216\u8BA9\u7BA1\u7406\u5458\u5B89\u88C5\u4E0A\u8FF0\u5E93\u3002",`\u539F\u59CB\u9519\u8BEF: ${e}`].join(`
|
|
32
|
+
`))}async function zn(t,e){console.log(`Browser executable: ${e}`);try{let r=await up(t,e);return console.log(`Browser smoke test passed: ${r}`),{executablePath:e,version:r}}catch(r){let n=gt(r);throw np(n)?lp(e,n):r}}function fp(t){try{let e=F.join(t.run,"daemon.pid"),r=Number.parseInt(te.readFileSync(e,"utf8").trim(),10);return!Number.isInteger(r)||r<=0?null:te.statSync(`/proc/${r}`).uid}catch{return null}}function pp(t,e){let r=fp(t),n=process.getuid?.();r===null||n===void 0||r===n||console.warn([`\u6CE8\u610F: daemon \u6B63\u4EE5 uid=${r} \u8FD0\u884C\uFF0C\u800C\u6D4F\u89C8\u5668\u88C5\u5728 uid=${n} \u540D\u4E0B\u7684${e}\u3002`,"daemon \u53EF\u80FD\u65E0\u6743\u8BFB\u53D6\u8BE5\u76EE\u5F55\u3002\u8BF7\u6539\u7528 daemon \u6240\u5C5E\u8D26\u53F7\u91CD\u65B0\u6267\u884C\u672C\u547D\u4EE4\uFF0C","\u6216\u4EE5 root \u6267\u884C\u8BA9\u5305\u7BA1\u7406\u5668\u628A\u6D4F\u89C8\u5668\u88C5\u5230\u7CFB\u7EDF\u8DEF\u5F84\u3002"].join(`
|
|
33
|
+
`))}async function Ds(t,e){if(process.platform!=="linux")throw new Error("install-browser currently supports Linux only");let r=process.env.PLAYWRIGHT_BROWSERS_PATH?.trim()?process.env.PLAYWRIGHT_BROWSERS_PATH.trim():`\u6570\u636E\u6839 ${e.root} \u4E0B\u7684\u6D4F\u89C8\u5668\u76EE\u5F55`,n=Zn(e.home);process.env.PLAYWRIGHT_BROWSERS_PATH=n;let i=Is();if(i)try{return await zn(t,i)}catch(c){console.warn(`Existing browser failed the smoke test: ${gt(c)}`)}if(process.getuid?.()===0)try{await sp();let c=Is();if(c)return await zn(t,c);console.warn("\u5305\u7BA1\u7406\u5668\u6267\u884C\u5B8C\u6210\u4F46\u6CA1\u6709\u627E\u5230\u6D4F\u89C8\u5668\uFF0C\u56DE\u9000\u5230\u4E0B\u8F7D\u5B89\u88C5")}catch(c){console.warn(`\u7CFB\u7EDF\u5305\u7BA1\u7406\u5668\u5B89\u88C5\u5931\u8D25\uFF0C\u56DE\u9000\u5230\u4E0B\u8F7D\u5B89\u88C5: ${gt(c)}`)}let o=await cp(t,r),s=await zn(t,o);return console.log(`\u6D4F\u89C8\u5668\u5DF2\u88C5\u5165${r}\uFF0Cdaemon \u542F\u52A8\u65F6\u4F1A\u6307\u5411\u540C\u4E00\u76EE\u5F55\uFF0C\u65E0\u9700\u8BBE\u7F6E\u73AF\u5883\u53D8\u91CF\u3002`),pp(e,r),i&&console.warn([`\u6CE8\u610F: ${i} \u4ECD\u7136\u5B58\u5728\u4E14\u4F1A\u88AB\u4F18\u5148\u4F7F\u7528\uFF0C\u4F46\u5B83\u65E0\u6CD5\u542F\u52A8\u3002`,`\u8BF7\u7528 HEADLESS_BROWSER_EXECUTABLE=${o} \u91CD\u65B0\u542F\u52A8 daemon\uFF0C\u6216\u4EE5 root \u4FEE\u590D\u8BE5\u7CFB\u7EDF\u6D4F\u89C8\u5668\u3002`].join(`
|
|
34
|
+
`)),s}import re from"fs";var _p=t=>new Promise(e=>setTimeout(e,t));function Bs(t){if(!Number.isInteger(t)||t<=0)return!1;try{return process.kill(t,0),!0}catch{return!1}}function Gs(t){try{return JSON.parse(re.readFileSync(t,"utf8"))}catch{return null}}function dp(t){let e=Gs(t);return!!(e?.deviceId?.trim()&&e?.credentialId?.trim()&&e?.ownerUid?.trim()&&e?.deviceName?.trim()&&e?.deviceType>0&&e?.publicKey?.trim()&&e?.privateKeyPem?.trim())}function mp(t){return[t.credential,t.authSession]}function hp(t){for(let e of t.entries){try{re.unlinkSync(e.file)}catch{}e.existed&&re.renameSync(e.backup,e.file)}}function Ep(t){let e=`${process.pid}-${Date.now()}`,r=mp(t).map(i=>({file:i,backup:`${i}.force-enroll-${e}.bak`,existed:re.existsSync(i)})),n=[];try{for(let i of r)i.existed&&(re.renameSync(i.file,i.backup),n.push(i))}catch(i){for(let o of n.reverse())re.renameSync(o.backup,o.file);throw i}return{entries:r}}function gp(t){for(let e of t.entries)e.existed&&re.unlinkSync(e.backup)}function vp(t){hp(t)}async function Tp(t,e){let r=Date.now()+e,n=0;for(;Date.now()<r;){let i=Gs(`${t.run}/status.json`);if(dp(t.credential)&&i?.client_ready===!0&&Bs(i.client_pid)){if(n||=Date.now(),Date.now()-n>=1e3)return}else n=0;let o=Number.parseInt(re.readFileSync(`${t.run}/daemon.pid`,"utf8"),10);if(i?.client_exit_code!=null&&!i?.client_pid)throw new Error(`client exited during force enrollment with code ${i.client_exit_code}`);if(o&&!Bs(o))throw new Error("daemon exited during force enrollment");await _p(100)}throw new Error(`force enrollment did not become ready within ${e}ms`)}async function Vs(t,e,r,n={}){let i=Ep(t);try{let o=await e();return await Tp(t,n.timeoutMs||15e3),gp(i),o}catch(o){await r().catch(()=>{});try{vp(i)}catch(s){throw new AggregateError([o,s],"force enrollment and rollback failed")}throw o}}import W from"fs";import Sp from"os";import A from"path";var Me={siboot:"SIBOOT_DATA_ROOT",coboot:"COBOOT_DATA_ROOT"};function vt(t,e){if(typeof t!="string"||!A.isAbsolute(t)||A.resolve(t)===A.parse(t).root)throw new Error(`${e} must be a non-root absolute path`);return A.resolve(t)}function Qn(t=process.env){let e=t.XDG_DATA_HOME?.trim()||A.join(t.HOME||Sp.homedir(),".local","share");return A.join(vt(e,"XDG_DATA_HOME or HOME"),"coboot-headless")}function Cr(t,e=process.env){let r=e.SIBOOT_DATA_ROOT?.trim()||"";if(t!=="coboot")return r;let n=e.COBOOT_DATA_ROOT?.trim()||"";if(r&&r!==n)throw new Error(`SIBOOT_DATA_ROOT is not a Coboot installation setting; use COBOOT_DATA_ROOT=${r} instead`);return n}function qn(t,e="siboot",r=process.env){if(!(e in Me))throw new Error(`unsupported headless edition: ${e}`);let n=e==="coboot"?Qn(r):"/data/siboot",i=vt(t||n,Me[e]),o=A.join(i,`.${e}`);return{edition:e,root:i,home:o,releases:A.join(o,"releases"),current:A.join(o,"current"),scripts:A.join(o,"scripts"),run:A.join(o,"run"),logs:A.join(o,"logs"),workspace:A.join(i,"workspace"),credential:A.join(o,"headless-device-credential.json"),authSession:A.join(o,"headless-auth-session.json"),updateState:A.join(o,"run","runtime-update-state.json"),updateLock:A.join(o,"run","runtime-update.lock"),updater:A.join(o,"scripts","updater.mjs")}}function ks(t=process.env){return A.join(Qn(t),"installation.json")}function Hs(t=process.env){let e=ks(t),r;try{r=W.readFileSync(e,"utf8")}catch(n){if(n.code==="ENOENT")return null;throw n}try{let n=JSON.parse(r);if(n.schemaVersion!==1)throw new Error("unsupported schemaVersion");return{dataRoot:vt(n.dataRoot,"recorded dataRoot"),workingDirectory:n.workingDirectory===null?null:vt(n.workingDirectory,"recorded workingDirectory")}}catch(n){throw new Error(`invalid Coboot installation record at ${e}; repair the record before continuing`,{cause:n})}}function Fs(t,e=process.env,r={}){let n=Cr(t,e);if(t!=="coboot")return qn(n,t,e);let i=Hs(e),o=n||i?.dataRoot||Qn(e),s=qn(o,t,e),c=i?.dataRoot===s.root?i.workingDirectory:null;return s.workingDirectory=r.workspaceDir===void 0?c:vt(r.workspaceDir,"--workspace-dir"),s}function yp(t){if(!(t.edition!=="coboot"||!t.workingDirectory)){if(!W.statSync(t.workingDirectory).isDirectory())throw new Error("--workspace-dir must refer to an existing directory");W.accessSync(t.workingDirectory,W.constants.R_OK|W.constants.X_OK)}}function eo(t,e=process.env){if(t.edition!=="coboot")return;let r=Hs(e);if(r&&r.dataRoot!==t.root)throw new Error("cannot switch a registered Coboot installation to another data root; keep the recorded COBOOT_DATA_ROOT");yp(t)}function js(t,e=process.env){if(t.edition!=="coboot")return;eo(t,e);let r=ks(e);W.mkdirSync(A.dirname(r),{recursive:!0,mode:448});let n=`${r}.${process.pid}.tmp`,i=!1;try{W.writeFileSync(n,JSON.stringify({schemaVersion:1,dataRoot:t.root,workingDirectory:t.workingDirectory||null})+`
|
|
35
|
+
`,{mode:384,flag:"wx"}),i=!0,W.renameSync(n,r)}finally{i&&W.rmSync(n,{force:!0})}}import{createHash as Ap}from"crypto";import h from"fs";import m from"path";var Op=new Set(["siboot","coboot"]);function to(t){for(let e of[t.home,t.releases,t.scripts,t.run,t.workspace,m.join(t.logs,"daemon"),m.join(t.logs,"client"),m.join(t.logs,"update")])h.mkdirSync(e,{recursive:!0,mode:448})}function Tt(t){let e=JSON.parse(h.readFileSync(m.join(t,"package.json"),"utf8")),r=String(e.name||"").trim();if(!/^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/i.test(r))throw new Error("package name is missing or invalid");let n=String(e.version||"").trim();if(!n||!/^[0-9A-Za-z._-]+$/.test(n))throw new Error("package version is missing or invalid");let i=String(e.headlessEdition||"").trim();if(!Op.has(i))throw new Error("package headlessEdition must be siboot or coboot");let o=e.headlessLinuxSandbox??null;Rp(i,o);let s=e.headlessBrowserRuntime??null;return xp(i,s),{packageName:r,version:n,edition:i,linuxSandbox:o,browserRuntime:s}}function Rp(t,e){if(t==="siboot"&&e)throw new Error("Siboot package must not include Linux sandbox metadata");if(t==="coboot"&&(e?.backend!=="bubblewrap"||!Array.isArray(e.architectures)||e.architectures.length===0))throw new Error("Coboot package is missing bundled Linux sandbox metadata")}function xp(t,e){if(t==="siboot"&&e)throw new Error("Siboot package must not include guided browser runtime metadata");if(t==="coboot"&&(e?.driver!=="playwright-core"||!/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(e.driverVersion||"")||e?.browser!=="system-or-guided-install"))throw new Error("Coboot package is missing valid guided browser runtime metadata")}function Lp(t,e){let r=m.relative(t.home,e),n=`${t.current}.next-${process.pid}`;h.rmSync(n,{force:!0}),h.symlinkSync(r,n),h.renameSync(n,t.current)}function Ur(t){try{let e=h.readlinkSync(t.current);return m.resolve(m.dirname(t.current),e)}catch{try{return h.realpathSync(t.current)}catch{return null}}}function Y(t,e,r){let n=`${e}.next-${process.pid}`;h.copyFileSync(t,n),h.chmodSync(n,r),h.renameSync(n,e)}function wp(t,e,r){let n=`${t}.next-${process.pid}`;h.writeFileSync(n,e,{mode:r}),h.renameSync(n,t)}function bp(t){return Ap("sha256").update(h.readFileSync(t)).digest("hex")}function Pp(t,e){if(!h.existsSync(t)||bp(t)!==e)throw new Error(`bundled Linux sandbox file failed integrity check: ${m.basename(t)}`)}function Mp(t,e,r,n){if(!r)return null;if(n.platform!=="linux")throw new Error(`Coboot Headless bundled sandbox supports Linux only: ${n.platform}`);if(!r.architectures.includes(n.arch))throw new Error(`Coboot Headless does not include Linux sandbox for arch: ${n.arch}`);let i=m.join(t,"native",`linux-${n.arch}`),o=m.join(i,"manifest.json");if(!h.existsSync(o))throw new Error(`package is missing Linux sandbox bundle for arch: ${n.arch}`);let s=JSON.parse(h.readFileSync(o,"utf8"));if(s.backend!==r.backend||s.backendVersion!==r.backendVersion||s.arch!==n.arch)throw new Error("bundled Linux sandbox manifest does not match package metadata");let c={bwrap:m.join(i,"bwrap"),loader:m.join(i,"ld-musl"),libcap:m.join(i,"lib","libcap.so.2")};for(let[a,u]of Object.entries(c))Pp(u,s.files?.[a]);let l=m.join(e,"native");return h.mkdirSync(m.join(l,"lib"),{recursive:!0,mode:448}),Y(c.bwrap,m.join(l,"bwrap"),320),Y(c.loader,m.join(l,"ld-musl"),320),Y(c.libcap,m.join(l,"lib","libcap.so.2"),256),Y(o,m.join(l,"manifest.json"),256),{backend:s.backend,version:s.backendVersion,arch:s.arch,bundled:!0}}function Ip(t,e,r){let n=m.join(t,"browser-runtime","playwright-core"),i=m.join(n,"package.json");if(!h.existsSync(i))throw new Error("package is missing bundled playwright-core");let o=JSON.parse(h.readFileSync(i,"utf8"));if(o.name!==r.driver||o.version!==r.driverVersion)throw new Error("bundled playwright-core does not match package metadata");let s=m.join(e,"node_modules","playwright-core"),c=`${s}.next-${process.pid}`;return h.rmSync(c,{recursive:!0,force:!0}),h.mkdirSync(m.dirname(s),{recursive:!0,mode:448}),h.cpSync(n,c,{recursive:!0}),h.rmSync(s,{recursive:!0,force:!0}),h.renameSync(c,s),r}function Dr(t,e,r={platform:process.platform,arch:process.arch}){to(e);let{packageName:n,version:i,edition:o,linuxSandbox:s,browserRuntime:c}=Tt(t);if(o!==e.edition)throw new Error(`package edition ${o} does not match runtime layout ${e.edition}`);let l=m.join(e.releases,i);if(Ur(e)===l)return{version:i,releaseDir:l,reused:!0};let a=m.join(e.releases,`.staging-${i}-${process.pid}`);h.rmSync(a,{recursive:!0,force:!0}),h.mkdirSync(a,{recursive:!0,mode:448});try{Np(t,a,{packageName:n,version:i,edition:o,linuxSandbox:s,browserRuntime:c},r),h.rmSync(l,{recursive:!0,force:!0}),h.renameSync(a,l)}catch(u){throw h.rmSync(a,{recursive:!0,force:!0}),u}return{version:i,releaseDir:l,reused:!1}}function Np(t,e,r,n){let i=m.join(t,"entry.mjs"),o=m.join(t,"daemon.mjs");if(!h.existsSync(i)||!h.existsSync(o))throw new Error("package is missing entry.mjs or daemon.mjs");Y(i,m.join(e,"entry.mjs"),320),Y(o,m.join(e,"daemon.mjs"),320);let s=m.join(t,"updater.mjs");h.existsSync(s)&&Y(s,m.join(e,"updater.mjs"),320);let c=Mp(t,e,r.linuxSandbox,n),l=r.browserRuntime?Ip(t,e,r.browserRuntime):"disabled";wp(m.join(e,"manifest.json"),`${JSON.stringify({type:"headless-npm-daemon",packageName:r.packageName,version:r.version,edition:r.edition,browserRuntime:l,linuxSandbox:c},null,2)}
|
|
36
|
+
`,256)}function Ie(t,e){Lp(t,e);let r=m.join(t.scripts,"daemon.mjs");h.existsSync(r)||Y(m.join(e,"daemon.mjs"),r,320);let n=m.join(e,"updater.mjs");h.existsSync(n)?Y(n,t.updater,320):h.rmSync(t.updater,{force:!0})}function Cp(t,e,r={platform:process.platform,arch:process.arch}){let n=Dr(t,e,r);return Ie(e,n.releaseDir),n}var Fy=Ps(process.argv[2]==="update"?"update":"startup"),zs=Dp(import.meta.url),Bp=15e3,Ks=25e3,Gp=73,Ws=20,Vp=new Set(["status","logs","stop"]),kp=["BACKEND_URL","WS_URL","SIBOOT_URL","MCP_CREDENTIAL_API_BASE_URL","SKILL_CREDENTIAL_API_BASE_URL"],Hp=["HEADLESS_BWRAP_EXECUTABLE","HEADLESS_BWRAP_LOADER","HEADLESS_BWRAP_LIBRARY_DIR"];function Fp(t,e,r){return`${e?`${Me[t.edition]}=${e} `:""}npx -y ${t.packageName} ${r}`}function jp(t,e){try{return y.statSync(t).uid===e}catch{return!1}}function $p(t,e,r){return jp(t.root,r)?` sudo chown -R ${e} ${t.root}`:` sudo mkdir -p ${t.root} && sudo chown ${e} ${t.root}`}function Kp(t,e={}){let r=E.join(t.home,`.write-probe-${process.pid}`);try{y.mkdirSync(t.home,{recursive:!0,mode:448}),y.writeFileSync(r,"",{mode:384}),y.rmSync(r,{force:!0})}catch(n){let i=e.userName||$s.userInfo().username,o=e.uid??process.getuid?.(),s=Me[t.edition],c=e.suggestedRoot||E.join($s.homedir(),`${t.edition}-data`),l=n?.code||"write failed";throw t.edition==="coboot"?new Error(`data root ${t.root} is not writable by user ${i} (${l}). Choose a writable absolute application data directory with COBOOT_DATA_ROOT; do not use the project working directory as the credential directory.`,{cause:n}):new Error([`data root ${t.root} is not writable by user ${i} (${l}).`,"Rerunning with sudo keeps the CLI and runtime as root; it does not hand the directory to this user.","Or ask an administrator to prepare it once:",$p(t,i,o),"or choose another writable absolute path and rerun this command:",` export ${s}=${c}`,`${s} is not persisted; status/logs/restart/update/stop must use the same value.`].join(`
|
|
37
|
+
`))}}function Wp(t,e){return`npx -y '${t}@${e}' install-browser`}function de(t){try{let e=Number.parseInt(y.readFileSync(t,"utf8").trim(),10);return Number.isInteger(e)&&e>0?e:null}catch{return null}}function X(t,e=process.platform==="linux"?"/proc":""){if(!t)return!1;try{process.kill(t,0)}catch{return!1}if(!e)return!0;try{let r=y.readFileSync(E.join(e,String(t),"stat"),"utf8"),n=r.lastIndexOf(") ")+2;return n<2||r[n]!=="Z"}catch{return!0}}function Js(t,e){let r="";try{r=y.readFileSync(`/proc/${t}/cmdline`,"utf8").replaceAll("\0"," ").trim()}catch{}if(!r)try{r=Up("ps",["-ww","-p",String(t),"-o","command="],{encoding:"utf8"}).trim()}catch{return!1}return e.some(n=>[n,ro(n)].some(i=>r.includes(i)))}var Br=t=>new Promise(e=>setTimeout(e,t));function Vr(t=process.versions.node){let e=Number.parseInt(String(t).split(".")[0],10);if(!Number.isInteger(e)||e<Ws)throw new Error(`Node.js >=${Ws} is required; current version is ${t}`)}async function Ys(t,e,r){let n=de(t);if(!X(n)){try{y.unlinkSync(t)}catch{}return!1}if(!Js(n,e))throw new Error(`refusing to stop unrelated process from stale ${E.basename(t)}: ${n}`);process.kill(n,"SIGTERM");let i=Date.now()+Ks;for(;Date.now()<i&&X(n);)await Br(100);if(X(n))throw new Error(`${r} did not stop within ${Ks/1e3} seconds: ${n}`);return de(t)===n&&y.rmSync(t,{force:!0}),!0}async function me(t){let e=await Ys(E.join(t.run,"daemon.pid"),[E.join(t.current,"daemon.mjs"),E.join(t.scripts,"daemon.mjs")],"daemon"),r=await Ys(E.join(t.run,"node.pid"),[E.join(t.current,"entry.mjs")],"client");return e||r}function Yp(t,e,r=process.env){let n={...r,CU_EDITION:t.edition,NO_ELECTRON:"1",CLIENT_TYPE:"anydev",SIBOOT_BASE_DIR:t.home,SIBOOT_DATA_ROOT:t.root,HEADLESS_DATA_DIR:t.root,SIBOOT_DATA_DIR:t.root,HEADLESS_DEVICE_CREDENTIAL_PATH:t.credential,HEADLESS_AUTH_SESSION_PATH:t.authSession,HEADLESS_DEVICE_REQUIRE_AUTH:"1",HEADLESS_PREWARM_DEFAULT_SESSION:"0",WORKSPACE:t.workspace,ANYDEV_UPDATE_ENABLED:"0"};e?n.HEADLESS_DEVICE_TOKEN=e:delete n.HEADLESS_DEVICE_TOKEN,delete n.CLIENT_UID,delete n.HEADLESS_DEVICE_FORCE_ENROLL;for(let i of Hp)delete n[i];if(t.edition==="coboot"){n.HEADLESS_NPM_UPDATER_PATH=t.updater,n.COBOOT_DATA_ROOT=t.root,n.HEADLESS_LOG_DIR=t.logs,t.workingDirectory?n.COBOOT_HEADLESS_WORKING_DIRECTORY=t.workingDirectory:delete n.COBOOT_HEADLESS_WORKING_DIRECTORY;let i=E.join(t.current,"native");n.HEADLESS_BWRAP_EXECUTABLE=E.join(i,"bwrap"),n.HEADLESS_BWRAP_LOADER=E.join(i,"ld-musl"),n.HEADLESS_BWRAP_LIBRARY_DIR=E.join(i,"lib"),n.HEADLESS_BROWSER_RUNTIME="system-or-guided-install",n.PLAYWRIGHT_BROWSERS_PATH=Zn(t.home,r)}else delete n.HEADLESS_NPM_UPDATER_PATH,delete n.COBOOT_HEADLESS_WORKING_DIRECTORY,delete n.HEADLESS_BROWSER_RUNTIME,delete n.HEADLESS_BROWSER_INSTALL_COMMAND;if(n.HEADLESS_ALLOW_ENDPOINT_OVERRIDE!=="1")for(let i of kp)delete n[i];return n}async function Xp(t,e=Bp){let r=Date.now()+e,n=!1;for(;Date.now()<r;){let i=de(E.join(t.run,"daemon.pid"));if(!X(i))throw new Error("daemon exited during client startup");let o=null;try{o=JSON.parse(y.readFileSync(E.join(t.run,"status.json"),"utf8"))}catch{}if(o?.client_ready===!0&&X(o.client_pid))return;if(o?.client_exit_code!=null&&!o?.client_pid){if(o.client_exit_code===Gp){n=!0,await Br(100);continue}throw new Error(`client exited during startup with code ${o.client_exit_code}`)}await Br(100)}throw n?new Error("another Headless Driver still holds the machine lock after startup retries"):new Error(`client did not become ready within ${e}ms`)}function St(t,e=""){let r=t.edition==="coboot"?"coboot-headless":"siboot-headless";if(!y.existsSync(t.credential)&&!e)throw new Error(`device credential is missing; run ${r} <device-token> first`);let n=y.existsSync(E.join(t.current,"daemon.mjs"))?E.join(t.current,"daemon.mjs"):E.join(t.scripts,"daemon.mjs"),i=y.existsSync(E.join(t.current,"entry.mjs")),o=y.existsSync(n);if(!i||!o)throw new Error(`runtime is not installed (entry=${i}, daemon=${o}); run ${r} <device-token> first`);return n}async function Ce(t,e="",r=process.env){to(t);let n=St(t,e),i=y.existsSync(t.credential)?"":e,o=E.join(t.logs,"daemon",`${new Date().toISOString().slice(0,10)}.log`),s=y.openSync(o,"a",384);Xs(process.execPath,[n],{detached:!0,env:Yp(t,i,r),stdio:["ignore",s,s]}).unref(),y.closeSync(s),await Br(500);let l=de(E.join(t.run,"daemon.pid"));if(!X(l))throw new Error("daemon failed to start; inspect the daemon log with the logs command");return await Xp(t),{pid:l,logFile:o}}function Gr(t){try{let e=JSON.parse(y.readFileSync(E.join(t.current,"manifest.json"),"utf8"));return typeof e.version=="string"?e.version:null}catch{return null}}async function zp(t,e={}){return Vr(e.nodeVersion),St(t),await me(t),Ce(t,"",e.baseEnv||process.env)}async function Zs(t,e,r={}){Vr(r.nodeVersion);let n=r.token||"";if(!y.existsSync(e.credential)&&!n){let l=e.edition==="coboot"?"coboot-headless":"siboot-headless";throw new Error(`device credential is missing; run ${l} <device-token> first`)}let i=Ur(e),o=Gr(e);console.log("[headless-runtime] event=runtime_replace phase=preparing");let s=Dr(t,e,r.runtime||{platform:process.platform,arch:process.arch}),c=l=>console.log(`[headless-runtime] event=runtime_replace phase=${l} from_version=${o||"unknown"} target_version=${s.version}`);c("stopping"),await me(e),Ie(e,s.releaseDir),c("activated");try{let l=await Ce(e,n,r.baseEnv||process.env);return c("completed"),{previousVersion:o,installed:s,started:l}}catch(l){if(c("rolling_back"),await me(e).catch(()=>{}),!i)throw l;Ie(e,i);try{await Ce(e,"",r.baseEnv||process.env)}catch(a){throw c("rollback_failed"),new AggregateError([l,a],`headless update failed and the previous runtime could not be restarted: ${a instanceof Error?a.message:String(a)}`)}throw c("rolled_back"),new Error(`headless update failed; restored ${o||"the previous version"}`,{cause:l})}}async function Jp(t,e,r,n={}){return qs(e)?Qs(t,e,r,n):{...await Zs(t,e,{...n,token:r}),identityReplaced:!1}}async function Zp(t,e,r={}){return St(e),Zs(t,e,r)}function qp(t){let e=de(E.join(t.run,"daemon.pid")),r=null;try{r=JSON.parse(y.readFileSync(E.join(t.run,"status.json"),"utf8"))}catch{}r&&typeof r=="object"&&delete r.current_dir,console.log(JSON.stringify({running:X(e),pid:e,current:y.existsSync(t.current),status:r,...t.edition==="coboot"?{dataRoot:t.root,workingDirectory:t.workingDirectory||null}:{}},null,2))}async function Qp(t){let e=E.join(t.logs,"daemon",`${new Date().toISOString().slice(0,10)}.log`);if(!y.existsSync(e))throw new Error(`no daemon log for today under ${t.root}`);let r=Xs("tail",["-n","100","-f",e],{stdio:"inherit"});await new Promise((n,i)=>{r.once("error",i),r.once("exit",o=>o===0?n():i(new Error(`tail exited ${o}`)))})}function Ne(t,e=t.version){let r={...process.env};return r.HEADLESS_NPM_PACKAGE_NAME=t.packageName,r.HEADLESS_NPM_PACKAGE_VERSION=e,t.browserRuntime&&(r.HEADLESS_BROWSER_INSTALL_COMMAND=Wp(t.packageName,e)),r}function qs(t){return y.existsSync(t.credential)||y.existsSync(t.authSession)}async function Qs(t,e,r,n={}){Vr(n.nodeVersion);let i=Tt(t),o=qs(e),s=Ur(e),c=Gr(e),l=Dr(t,e,n.runtime||{platform:process.platform,arch:process.arch});await me(e);try{return await Vs(e,async()=>{Ie(e,l.releaseDir);let a=await Ce(e,r,n.baseEnv||Ne(i));return{installed:l,started:a,identityReplaced:o}},()=>me(e))}catch(a){if(!s)throw a;Ie(e,s);try{await Ce(e,"",Ne(i,c||i.version))}catch(u){throw new AggregateError([a,u],`force enrollment failed and the previous runtime could not be restarted: ${u instanceof Error?u.message:String(u)}`)}throw a}}async function e_(){let t=E.basename(process.argv[1]||"siboot-headless"),e=E.dirname(zs),r=Tt(e),n=Ir(process.argv.slice(2),r.edition),i=Fs(r.edition,process.env,n),o=r.edition==="coboot"?i.root:Cr(r.edition),s=Fp(r,o,"logs");if(n.command==="help")return Ms(t,i.root,!!r.browserRuntime,Me[r.edition]);if(!Vp.has(n.command)){if(r.edition==="coboot"){if(["start","restart","update"].includes(n.command)&&St(i),n.command==="start"&&n.workspaceDir&&X(de(E.join(i.run,"daemon.pid"))))throw new Error("use restart --workspace-dir to change the working directory of a running installation");eo(i)}Kp(i),js(i)}if(n.command==="install-browser"){if(!r.browserRuntime)throw new Error("install-browser is available in the Coboot headless npm package only");return Ds(e,i)}let c=r.edition==="coboot"?"Coboot":"Siboot";if(n.command==="status")return qp(i);if(n.command==="logs")return Qp(i);if(n.command==="stop"){let f=await me(i);console.log(f?`${c} Headless stopped`:`${c} Headless is not running`);return}if(n.command==="start"){Vr(),St(i);let f=de(E.join(i.run,"daemon.pid")),d=[E.join(i.current,"daemon.mjs"),E.join(i.scripts,"daemon.mjs")];if(X(f)&&Js(f,d)){console.log(`${c} Headless is already running (pid=${f})`);return}await me(i);let T=await Ce(i,"",Ne(r,Gr(i)||r.version));console.log(`${c} Headless started in background (pid=${T.pid})`),console.log(`Logs: ${s}`);return}if(n.command==="restart"){let f=await zp(i,{baseEnv:Ne(r,Gr(i)||r.version)});console.log(`${c} Headless restarted in background (pid=${f.pid})`),console.log(`Logs: ${s}`);return}if(n.command==="update"){let{previousVersion:f,installed:d,started:T}=await Zp(e,i,{baseEnv:Ne(r)});console.log(`${c} Headless updated ${f||"unknown"} -> ${d.version} (pid=${T.pid})`),console.log(`Logs: ${s}`);return}let{installed:l,started:a,identityReplaced:u}=n.forceEnroll?await Qs(e,i,n.token):await Jp(e,i,n.token||"",{baseEnv:Ne(r)});console.log(`${c} Headless ${l.version} started in background (pid=${a.pid})`),u?console.log("Existing device credential replaced by new enrollment"):n.forceEnroll&&console.log("Device credential created by force enrollment"),console.log(`Logs: ${s}`)}function ro(t){try{return y.realpathSync(t)}catch{return E.resolve(t)}}process.argv[1]&&ro(process.argv[1])===ro(zs)&&e_().catch(t=>{let e=E.basename(process.argv[1]||"headless-client");console.error(`${e}: ${t instanceof Error?t.message:String(t)}`),process.exitCode=1});export{Kp as assertHeadlessDataRootWritable,Vr as assertSupportedNodeVersion,Yp as createDaemonEnv,Jp as installAndStartHeadlessRuntime,Cp as installHeadlessRuntime,X as isRunning,Ir as parseHeadlessCliArgs,Tt as readPackageMetadata,Cr as resolveHeadlessDataRootSetting,qn as resolveHeadlessLayout,zp as restartHeadlessRuntime,Ce as startHeadlessRuntime,me as stopHeadlessRuntime,Zp as updateHeadlessRuntime,St as validateHeadlessRuntimeStart};
|