@blueking/open-telemetry 0.0.9 → 0.0.11

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.
@@ -8,5 +8,5 @@ var BkOpenTelemetry=(function(){var e=Object.defineProperty,t=(e,t)=>()=>(e&&(t=
8
8
  To resolve the conflict:`,zc(t,e))),n=r):j.warn(`A view or instrument with the name `,e.name,` has already been registered and is incompatible with another registered view.
9
9
  `,`Details:
10
10
  `,Pc(t,e),`To resolve the conflict:
11
- `,zc(t,e))}return n}};F();var Vc=class{constructor(e){P(this,`_backingStorages`,void 0),this._backingStorages=e}record(e,t,n,r){let i=this._backingStorages;for(let a=0;a<i.length;a++)i[a].record(e,t,n,r)}};N(),F();var Hc=class{constructor(e,t){P(this,`_buffer`,new kc),P(this,`_instrumentName`,void 0),P(this,`_valueType`,void 0),this._instrumentName=e,this._valueType=t}observe(e,t={}){if(typeof e!=`number`){j.warn(`non-number value provided to metric ${this._instrumentName}: ${e}`);return}this._valueType===ke.INT&&!Number.isInteger(e)&&(j.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(t,e)}},Uc=class{constructor(){P(this,`_buffer`,new Map)}observe(e,t,n={}){if(!Tc(e))return;let r=this._buffer.get(e);if(r==null&&(r=new kc,this._buffer.set(e,r)),typeof t!=`number`){j.warn(`non-number value provided to metric ${e._descriptor.name}: ${t}`);return}e._descriptor.valueType===ke.INT&&!Number.isInteger(t)&&(j.warn(`INT value type cannot accept a floating-point value for ${e._descriptor.name}, ignoring the fractional digits.`),t=Math.trunc(t),!Number.isInteger(t))||r.set(n,t)}};N(),F(),H();var Wc=class{constructor(){P(this,`_callbacks`,[]),P(this,`_batchCallbacks`,[])}addCallback(e,t){this._findCallback(e,t)>=0||this._callbacks.push({callback:e,instrument:t})}removeCallback(e,t){let n=this._findCallback(e,t);n<0||this._callbacks.splice(n,1)}addBatchCallback(e,t){let n=new Set(t.filter(Tc));if(n.size===0){j.error(`BatchObservableCallback is not associated with valid instruments`,t);return}this._findBatchCallback(e,n)>=0||this._batchCallbacks.push({callback:e,instruments:n})}removeBatchCallback(e,t){let n=new Set(t.filter(Tc)),r=this._findBatchCallback(e,n);r<0||this._batchCallbacks.splice(r,1)}observe(e,t){var n=this;return V(function*(){let r=n._observeCallbacks(e,t),i=n._observeBatchCallbacks(e,t);return(yield Promise.allSettled([...r,...i])).filter(e=>e.status===`rejected`).map(e=>e.reason)})()}_observeCallbacks(e,t){return this._callbacks.map(function(){var n=V(function*({callback:n,instrument:r}){let i=new Hc(r._descriptor.name,r._descriptor.valueType),a=Promise.resolve(n(i));t!=null&&(a=Jo(a,t)),yield a,r._metricStorages.forEach(t=>{t.record(i._buffer,e)})});return function(e){return n.apply(this,arguments)}}())}_observeBatchCallbacks(e,t){return this._batchCallbacks.map(function(){var n=V(function*({callback:n,instruments:r}){let i=new Uc,a=Promise.resolve(n(i));t!=null&&(a=Jo(a,t)),yield a,r.forEach(t=>{let n=i._buffer.get(t);n!=null&&t._metricStorages.forEach(t=>{t.record(n,e)})})});return function(e){return n.apply(this,arguments)}}())}_findCallback(e,t){return this._callbacks.findIndex(n=>n.callback===e&&n.instrument===t)}_findBatchCallback(e,t){return this._batchCallbacks.findIndex(n=>n.callback===e&&Yo(n.instruments,t))}};F();var Gc=class extends Dc{constructor(e,t,n,r,i){super(e),P(this,`_aggregationCardinalityLimit`,void 0),P(this,`_deltaMetricStorage`,void 0),P(this,`_temporalMetricStorage`,void 0),P(this,`_attributesProcessor`,void 0),this._aggregationCardinalityLimit=i,this._deltaMetricStorage=new Ac(t,this._aggregationCardinalityLimit),this._temporalMetricStorage=new jc(t,r),this._attributesProcessor=n}record(e,t,n,r){t=this._attributesProcessor.process(t,n),this._deltaMetricStorage.record(e,t,n,r)}collect(e,t){let n=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(e,this._instrumentDescriptor,n,t)}};F();var Kc=class{process(e,t){return e}},qc=class{constructor(e){P(this,`_processors`,void 0),this._processors=e}process(e,t){let n=e;for(let e of this._processors)n=e.process(n,t);return n}};function Jc(){return Xc}function Yc(e){return new qc(e)}var Xc=new Kc;F(),H();var Zc=class{constructor(e,t){P(this,`metricStorageRegistry`,new Bc),P(this,`observableRegistry`,new Wc),P(this,`meter`,void 0),P(this,`_meterProviderSharedState`,void 0),P(this,`_instrumentationScope`,void 0),this.meter=new Ec(this),this._meterProviderSharedState=e,this._instrumentationScope=t}registerMetricStorage(e){let t=this._registerMetricStorage(e,Gc);return t.length===1?t[0]:new Vc(t)}registerAsyncMetricStorage(e){return this._registerMetricStorage(e,Nc)}collect(e,t,n){var r=this;return V(function*(){let i=yield r.observableRegistry.observe(t,n==null?void 0:n.timeoutMillis),a=r.metricStorageRegistry.getStorages(e);if(a.length===0)return null;let o=[];return a.forEach(n=>{let r=n.collect(e,t);r!=null&&o.push(r)}),o.length===0?{errors:i}:{scopeMetrics:{scope:r._instrumentationScope,metrics:o},errors:i}})()}_registerMetricStorage(e,t){let n=this._meterProviderSharedState.viewRegistry.findViews(e,this._instrumentationScope).map(n=>{let r=fc(n,e),i=this.metricStorageRegistry.findOrUpdateCompatibleStorage(r);if(i!=null)return i;let a=new t(r,n.aggregation.createAggregator(r),n.attributesProcessor,this._meterProviderSharedState.metricCollectors,n.aggregationCardinalityLimit);return this.metricStorageRegistry.register(a),a});if(n.length===0){let r=this._meterProviderSharedState.selectAggregations(e.type).map(([n,r])=>{let i=this.metricStorageRegistry.findOrUpdateCompatibleCollectorStorage(n,e);if(i!=null)return i;let a=r.createAggregator(e),o=n.selectCardinalityLimit(e.type),s=new t(e,a,Jc(),[n],o);return this.metricStorageRegistry.registerForCollector(n,s),s});n=n.concat(r)}return n}};F();var Qc=class{constructor(e){P(this,`viewRegistry`,new uc),P(this,`metricCollectors`,[]),P(this,`meterSharedStates`,new Map),P(this,`resource`,void 0),this.resource=e}getMeterSharedState(e){let t=Ko(e),n=this.meterSharedStates.get(t);return n==null&&(n=new Zc(this,e),this.meterSharedStates.set(t,n)),n}selectAggregations(e){let t=[];for(let n of this.metricCollectors)t.push([n,Gs(n.selectAggregation(e))]);return t}};B(),F(),H();var $c=class{constructor(e,t){P(this,`_sharedState`,void 0),P(this,`_metricReader`,void 0),this._sharedState=e,this._metricReader=t}collect(e){var t=this;return V(function*(){let n=ra(Date.now()),r=[],i=[],a=Array.from(t._sharedState.meterSharedStates.values()).map(function(){var a=V(function*(a){let o=yield a.collect(t,n,e);(o==null?void 0:o.scopeMetrics)!=null&&r.push(o.scopeMetrics),(o==null?void 0:o.errors)!=null&&i.push(...o.errors)});return function(e){return a.apply(this,arguments)}}());return yield Promise.all(a),{resourceMetrics:{resource:t._sharedState.resource,scopeMetrics:r},errors:i}})()}forceFlush(e){var t=this;return V(function*(){yield t._metricReader.forceFlush(e)})()}shutdown(e){var t=this;return V(function*(){yield t._metricReader.shutdown(e)})()}selectAggregationTemporality(e){return this._metricReader.selectAggregationTemporality(e)}selectAggregation(e){return this._metricReader.selectAggregation(e)}selectCardinalityLimit(e){var t,n,r;return(t=(n=(r=this._metricReader).selectCardinalityLimit)==null?void 0:n.call(r,e))==null?2e3:t}};F();var el=/[\^$\\.+?()[\]{}|]/g,tl=class e{constructor(t){P(this,`_matchAll`,void 0),P(this,`_regexp`,void 0),t===`*`?(this._matchAll=!0,this._regexp=/.*/):(this._matchAll=!1,this._regexp=new RegExp(e.escapePattern(t)))}match(e){return this._matchAll?!0:this._regexp.test(e)}static escapePattern(e){return`^${e.replace(el,`\\$&`).replace(`*`,`.*`)}$`}static hasWildcard(e){return e.includes(`*`)}},nl=class{constructor(e){P(this,`_matchAll`,void 0),P(this,`_pattern`,void 0),this._matchAll=e===void 0,this._pattern=e}match(e){return!!(this._matchAll||e===this._pattern)}};F();var rl=class{constructor(e){var t;P(this,`_nameFilter`,void 0),P(this,`_type`,void 0),P(this,`_unitFilter`,void 0),this._nameFilter=new tl((t=e==null?void 0:e.name)==null?`*`:t),this._type=e==null?void 0:e.type,this._unitFilter=new nl(e==null?void 0:e.unit)}getType(){return this._type}getNameFilter(){return this._nameFilter}getUnitFilter(){return this._unitFilter}};F();var il=class{constructor(e){P(this,`_nameFilter`,void 0),P(this,`_versionFilter`,void 0),P(this,`_schemaUrlFilter`,void 0),this._nameFilter=new nl(e==null?void 0:e.name),this._versionFilter=new nl(e==null?void 0:e.version),this._schemaUrlFilter=new nl(e==null?void 0:e.schemaUrl)}getNameFilter(){return this._nameFilter}getVersionFilter(){return this._versionFilter}getSchemaUrlFilter(){return this._schemaUrlFilter}};F();function al(e){return e.instrumentName==null&&e.instrumentType==null&&e.instrumentUnit==null&&e.meterName==null&&e.meterVersion==null&&e.meterSchemaUrl==null}function ol(e){if(al(e))throw Error(`Cannot create view with no selector arguments supplied`);if(e.name!=null&&((e==null?void 0:e.instrumentName)==null||tl.hasWildcard(e.instrumentName)))throw Error(`Views with a specified name must be declared with an instrument selector that selects at most one instrument per meter.`)}var sl=class{constructor(e){var t;P(this,`name`,void 0),P(this,`description`,void 0),P(this,`aggregation`,void 0),P(this,`attributesProcessor`,void 0),P(this,`instrumentSelector`,void 0),P(this,`meterSelector`,void 0),P(this,`aggregationCardinalityLimit`,void 0),ol(e),e.attributesProcessors==null?this.attributesProcessor=Jc():this.attributesProcessor=Yc(e.attributesProcessors),this.name=e.name,this.description=e.description,this.aggregation=Gs((t=e.aggregation)==null?{type:Ws.DEFAULT}:t),this.instrumentSelector=new rl({name:e.instrumentName,type:e.instrumentType,unit:e.instrumentUnit}),this.meterSelector=new il({name:e.meterName,version:e.meterVersion,schemaUrl:e.meterSchemaUrl}),this.aggregationCardinalityLimit=e.aggregationCardinalityLimit}};N(),lc(),F(),H();var cl=class{constructor(e){var t;if(P(this,`_sharedState`,void 0),P(this,`_shutdown`,!1),this._sharedState=new Qc((t=e==null?void 0:e.resource)==null?rc():t),(e==null?void 0:e.views)!=null&&e.views.length>0)for(let t of e.views)this._sharedState.viewRegistry.addView(new sl(t));if((e==null?void 0:e.readers)!=null&&e.readers.length>0)for(let t of e.readers){let e=new $c(this._sharedState,t);t.setMetricProducer(e),this._sharedState.metricCollectors.push(e)}}getMeter(e,t=``,n={}){return this._shutdown?(j.warn(`A shutdown MeterProvider cannot provide a Meter`),le()):this._sharedState.getMeterSharedState({name:e,version:t,schemaUrl:n.schemaUrl}).meter}shutdown(e){var t=this;return V(function*(){if(t._shutdown){j.warn(`shutdown may only be called once per MeterProvider`);return}t._shutdown=!0,yield Promise.all(t._sharedState.metricCollectors.map(t=>t.shutdown(e)))})()}forceFlush(e){var t=this;return V(function*(){if(t._shutdown){j.warn(`invalid attempt to force flush after MeterProvider shutdown`);return}yield Promise.all(t._sharedState.metricCollectors.map(t=>t.forceFlush(e)))})()}},ll;(function(e){e[e.AGGREGATION_TEMPORALITY_UNSPECIFIED=0]=`AGGREGATION_TEMPORALITY_UNSPECIFIED`,e[e.AGGREGATION_TEMPORALITY_DELTA=1]=`AGGREGATION_TEMPORALITY_DELTA`,e[e.AGGREGATION_TEMPORALITY_CUMULATIVE=2]=`AGGREGATION_TEMPORALITY_CUMULATIVE`})(ll||(ll={}));function ul(e,t){let n={attributes:fl(e.attributes,t),droppedAttributesCount:0},r=e.schemaUrl;return r&&r!==``&&(n.schemaUrl=r),n}function dl(e){return{name:e.name,version:e.version}}function fl(e,t){return Object.keys(e).map(n=>pl(n,e[n],t))}function pl(e,t,n){return{key:e,value:ml(t,n)}}function ml(e,t){let n=typeof e;if(n===`string`)return{stringValue:e};if(n===`number`)return Number.isInteger(e)?{intValue:e}:{doubleValue:e};if(n===`boolean`)return{boolValue:e};if(e instanceof Uint8Array)return{bytesValue:t.encodeUint8Array(e)};if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=ml(e[r],t);return{arrayValue:{values:n}}}if(n===`object`&&e!=null){let n=Object.keys(e),r=Array(n.length);for(let i=0;i<n.length;i++)r[i]={key:n[i],value:ml(e[n[i]],t)};return{kvlistValue:{values:r}}}return{}}N();function hl(e,t){let n=ul(e.resource,t);return{resource:n,schemaUrl:n.schemaUrl,scopeMetrics:gl(e.scopeMetrics,t)}}function gl(e,t){return Array.from(e.map(e=>({scope:dl(e.scope),metrics:e.metrics.map(e=>_l(e,t)),schemaUrl:e.scope.schemaUrl})))}function _l(e,t){let n={name:e.descriptor.name,description:e.descriptor.description,unit:e.descriptor.unit},r=Sl(e.aggregationTemporality);switch(e.dataPointType){case Wo.SUM:n.sum={aggregationTemporality:r,isMonotonic:e.isMonotonic,dataPoints:yl(e,t)};break;case Wo.GAUGE:n.gauge={dataPoints:yl(e,t)};break;case Wo.HISTOGRAM:n.histogram={aggregationTemporality:r,dataPoints:bl(e,t)};break;case Wo.EXPONENTIAL_HISTOGRAM:n.exponentialHistogram={aggregationTemporality:r,dataPoints:xl(e,t)};break}return n}function vl(e,t,n){let r={attributes:fl(e.attributes,n),startTimeUnixNano:n.encodeHrTime(e.startTime),timeUnixNano:n.encodeHrTime(e.endTime)};switch(t){case ke.INT:r.asInt=e.value;break;case ke.DOUBLE:r.asDouble=e.value;break}return r}function yl(e,t){return e.dataPoints.map(n=>vl(n,e.descriptor.valueType,t))}function bl(e,t){return e.dataPoints.map(e=>{let n=e.value;return{attributes:fl(e.attributes,t),bucketCounts:n.buckets.counts,explicitBounds:n.buckets.boundaries,count:n.count,sum:n.sum,min:n.min,max:n.max,startTimeUnixNano:t.encodeHrTime(e.startTime),timeUnixNano:t.encodeHrTime(e.endTime)}})}function xl(e,t){return e.dataPoints.map(e=>{let n=e.value;return{attributes:fl(e.attributes,t),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:t.encodeHrTime(e.startTime),timeUnixNano:t.encodeHrTime(e.endTime)}})}function Sl(e){switch(e){case Uo.DELTA:return ll.AGGREGATION_TEMPORALITY_DELTA;case Uo.CUMULATIVE:return ll.AGGREGATION_TEMPORALITY_CUMULATIVE}}function Cl(e,t){return{resourceMetrics:e.map(e=>hl(e,t))}}B();function wl(e){let t=BigInt(1e9);return BigInt(Math.trunc(e[0]))*t+BigInt(Math.trunc(e[1]))}function Tl(e){return wl(e).toString()}var El=typeof BigInt<`u`?Tl:sa;function Dl(e){return e}var Ol={encodeHrTime:El,encodeSpanContext:Dl,encodeOptionalSpanContext:Dl,encodeUint8Array:e=>{if(typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let t=Array(e.length);for(let n=0;n<e.length;n++)t[n]=String.fromCharCode(e[n]);return btoa(t.join(``))}};function kl(e,t){return{resourceLogs:jl(e,t)}}function Al(e){let t=new Map;for(let n of e){let{resource:e,instrumentationScope:{name:r,version:i=``,schemaUrl:a=``}}=n,o=t.get(e);o||(o=new Map,t.set(e,o));let s=`${r}@${i}:${a}`,c=o.get(s);c||(c=[],o.set(s,c)),c.push(n)}return t}function jl(e,t){let n=Al(e);return Array.from(n,([e,n])=>{let r=ul(e,t);return{resource:r,scopeLogs:Array.from(n,([,e])=>({scope:dl(e[0].instrumentationScope),logRecords:e.map(e=>Ml(e,t)),schemaUrl:e[0].instrumentationScope.schemaUrl})),schemaUrl:r.schemaUrl}})}function Ml(e,t){var n,r,i;return{timeUnixNano:t.encodeHrTime(e.hrTime),observedTimeUnixNano:t.encodeHrTime(e.hrTimeObserved),severityNumber:Nl(e.severityNumber),severityText:e.severityText,body:ml(e.body,t),eventName:e.eventName,attributes:Pl(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,flags:(n=e.spanContext)==null?void 0:n.traceFlags,traceId:t.encodeOptionalSpanContext((r=e.spanContext)==null?void 0:r.traceId),spanId:t.encodeOptionalSpanContext((i=e.spanContext)==null?void 0:i.spanId)}}function Nl(e){return e}function Pl(e,t){return Object.keys(e).map(n=>pl(n,e[n],t))}N();var Fl={serializeRequest:e=>{let t=kl(e,Ol);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(e){return j.warn(`Failed to parse logs export response: ${e.message}. Returning empty response`),{}}}};N();var Il={serializeRequest:e=>{let t=Cl([e],Ol);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(e){return j.warn(`Failed to parse metrics export response: ${e.message}. Returning empty response`),{}}}},Ll=256,Rl=512;function zl(e,t){let n=e&255|Ll;return t&&(n|=Rl),n}function Bl(e,t){var n,r,i,a;let o=e.spanContext(),s=e.status,c=(n=e.parentSpanContext)!=null&&n.spanId?t.encodeSpanContext((r=e.parentSpanContext)==null?void 0:r.spanId):void 0;return{traceId:t.encodeSpanContext(o.traceId),spanId:t.encodeSpanContext(o.spanId),parentSpanId:c,traceState:(i=o.traceState)==null?void 0:i.serialize(),name:e.name,kind:e.kind==null?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:fl(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(e=>Hl(e,t)),droppedEventsCount:e.droppedEventsCount,status:{code:s.code,message:s.message},links:e.links.map(e=>Vl(e,t)),droppedLinksCount:e.droppedLinksCount,flags:zl(o.traceFlags,(a=e.parentSpanContext)==null?void 0:a.isRemote)}}function Vl(e,t){var n;return{attributes:e.attributes?fl(e.attributes,t):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:(n=e.context.traceState)==null?void 0:n.serialize(),droppedAttributesCount:e.droppedAttributesCount||0,flags:zl(e.context.traceFlags,e.context.isRemote)}}function Hl(e,t){return{attributes:e.attributes?fl(e.attributes,t):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function Ul(e,t){return{resourceSpans:Gl(e,t)}}function Wl(e){let t=new Map;for(let n of e){let e=t.get(n.resource);e||(e=new Map,t.set(n.resource,e));let r=`${n.instrumentationScope.name}@${n.instrumentationScope.version||``}:${n.instrumentationScope.schemaUrl||``}`,i=e.get(r);i||(i=[],e.set(r,i)),i.push(n)}return t}function Gl(e,t){let n=Wl(e),r=[],i=n.entries(),a=i.next();for(;!a.done;){let[e,n]=a.value,o=[],s=n.values(),c=s.next();for(;!c.done;){let e=c.value;if(e.length>0){let n=e.map(e=>Bl(e,t));o.push({scope:dl(e[0].instrumentationScope),spans:n,schemaUrl:e[0].instrumentationScope.schemaUrl})}c=s.next()}let l=ul(e,t),u={resource:l,scopeSpans:o,schemaUrl:l.schemaUrl};r.push(u),a=i.next()}return r}N();var Kl={serializeRequest:e=>{let t=Ul(e,Ol);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(e){return j.warn(`Failed to parse trace export response: ${e.message}. Returning empty response`),{}}}};N(),F(),H();var ql=5,Jl=1e3,Yl=5e3,Xl=1.5,Zl=.2;function Ql(){return 2*Zl*Math.random()-Zl}var $l=class{constructor(e){P(this,`_transport`,void 0),this._transport=e}retry(e,t,n){return new Promise((r,i)=>{setTimeout(()=>{this._transport.send(e,t).then(r,i)},n)})}send(e,t){var n=this;return V(function*(){let r=ql,i=Jl,a=Date.now()+t,o=yield n._transport.send(e,t);for(;o.status===`retryable`&&r>0;){var s;r--;let t=Math.max(Math.min(i*(1+Ql()),Yl),0);i*=Xl;let c=(s=o.retryInMillis)==null?t:s,l=a-Date.now();if(c>l)return j.info(`Export retry time ${Math.round(c)}ms exceeds remaining timeout ${Math.round(l)}ms, not retrying further.`),o;j.verbose(`Scheduling export retry in ${Math.round(c)}ms`),o=yield n.retry(e,l,c)}return o.status===`success`?j.verbose(`Export succeeded after ${ql-r} retry attempts.`):o.status===`retryable`?j.info(`Export failed after maximum retry attempts (${ql}).`):j.info(`Export failed with non-retryable error: ${o.error}`),o})()}shutdown(){return this._transport.shutdown()}};function eu(e){return new $l(e.transport)}function tu(e){return e===429||e===502||e===503||e===504}function nu(e){if(e==null)return;let t=Number.parseInt(e,10);if(Number.isInteger(t))return t>0?t*1e3:-1;let n=new Date(e).getTime()-Date.now();return n>=0?n:0}N(),F(),H();var ru=60*1024,iu=9,au=0,ou=0,su=class{constructor(e){P(this,`_parameters`,void 0),this._parameters=e}send(e,t){var n=this;return V(function*(){let r=new AbortController,i=setTimeout(()=>r.abort(),t),a=globalThis.fetch;typeof a.__original==`function`&&(a=a.__original);let o=e.byteLength,s=au+o>ru,c=!s&&!(ou>=iu);if(c)au+=o,ou++;else{let e=s?`size limit`:`count limit`;j.debug(`keepalive disabled: ${(o/1024).toFixed(1)}KB payload, ${ou} pending (${e})`)}try{let t=new URL(n._parameters.url),i=yield a(t.href,{method:`POST`,headers:yield n._parameters.headers(),body:e,signal:r.signal,keepalive:c,mode:globalThis.location?globalThis.location.origin===t.origin?`same-origin`:`cors`:`no-cors`});return i.status>=200&&i.status<=299?(j.debug(`export response success (status: ${i.status})`),{status:`success`}):tu(i.status)?(j.warn(`export response retryable (status: ${i.status})`),{status:`retryable`,retryInMillis:nu(i.headers.get(`Retry-After`))}):(j.error(`export response failure (status: ${i.status})`),{status:`failure`,error:Error(`Fetch request failed with non-retryable status ${i.status}`)})}catch(e){return lu(e)?(j.warn(`export request retryable (network error: ${e})`),{status:`retryable`,error:Error(`Fetch request encountered a network error`,{cause:e})}):(j.error(`export request failure (error: ${e})`),{status:`failure`,error:Error(`Fetch request errored`,{cause:e})})}finally{clearTimeout(i),c&&(au-=o,ou--)}})()}shutdown(){}};function cu(e){return new su(e)}function lu(e){return e instanceof TypeError&&!e.cause}function uu(e,t){return Ho(e,t,eu({transport:cu(e)}))}N();function du(e){let t={};return Object.entries(e==null?{}:e).forEach(([e,n])=>{n===void 0?j.warn(`Header "${e}" has invalid value (${n}) and will be ignored`):t[e]=String(n)}),t}G(),H();function fu(e,t,n){return V(function*(){let r=W({},yield n()),i={};return t!=null&&Object.assign(i,yield t()),e!=null&&Object.assign(i,du(yield e())),Object.assign(i,r)})}function pu(e){if(e!=null)try{var t;let n=(t=globalThis.location)==null?void 0:t.href;return new URL(e,n).href}catch(t){throw Error(`Configuration: Could not parse user-provided export URL: '${e}'`)}}function mu(e,t,n){var r,i;return W(W({},Po(e,t,n)),{},{headers:fu(e.headers,t.headers,n.headers),url:(r=(i=pu(e.url))==null?t.url:i)==null?n.url:r})}function hu(e,t){return W(W({},Fo()),{},{headers:function(){var t=V(function*(){return e});return function(){return t.apply(this,arguments)}}(),url:`http://localhost:4318/`+t})}function gu(e){return typeof e.headers==`function`?e.headers:No(e.headers)}function _u(e,t,n){return mu({url:e.url,timeoutMillis:e.timeoutMillis,headers:gu(e),concurrencyLimit:e.concurrencyLimit},{},hu(n,t))}function vu(e,t,n,r){return uu(_u(e,n,r),t)}var yu=class extends ko{constructor(e={}){super(vu(e,Fl,`v1/logs`,{"Content-Type":`application/json`}))}},bu;(function(e){e[e.DELTA=0]=`DELTA`,e[e.CUMULATIVE=1]=`CUMULATIVE`,e[e.LOWMEMORY=2]=`LOWMEMORY`})(bu||(bu={})),B(),N(),F();var xu=()=>Uo.CUMULATIVE,Su=e=>{switch(e){case U.COUNTER:case U.OBSERVABLE_COUNTER:case U.GAUGE:case U.HISTOGRAM:case U.OBSERVABLE_GAUGE:return Uo.DELTA;case U.UP_DOWN_COUNTER:case U.OBSERVABLE_UP_DOWN_COUNTER:return Uo.CUMULATIVE}},Cu=e=>{switch(e){case U.COUNTER:case U.HISTOGRAM:return Uo.DELTA;case U.GAUGE:case U.UP_DOWN_COUNTER:case U.OBSERVABLE_UP_DOWN_COUNTER:case U.OBSERVABLE_COUNTER:case U.OBSERVABLE_GAUGE:return Uo.CUMULATIVE}};function wu(){var e;let t=((e=void 0)==null?`cumulative`:e).toLowerCase();return t===`cumulative`?xu:t===`delta`?Su:t===`lowmemory`?Cu:(j.warn(`OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE is set to '${t}', but only 'cumulative' and 'delta' are allowed. Using default ('cumulative') instead.`),xu)}function Tu(e){return e==null?wu():e===bu.DELTA?Su:e===bu.LOWMEMORY?Cu:xu}var Eu=Object.freeze({type:Ws.DEFAULT});function Du(e){var t;return(t=e==null?void 0:e.aggregationPreference)==null?(()=>Eu):t}var Ou=class extends ko{constructor(e,t){super(e),P(this,`_aggregationTemporalitySelector`,void 0),P(this,`_aggregationSelector`,void 0),this._aggregationSelector=Du(t),this._aggregationTemporalitySelector=Tu(t==null?void 0:t.temporalityPreference)}selectAggregation(e){return this._aggregationSelector(e)}selectAggregationTemporality(e){return this._aggregationTemporalitySelector(e)}},ku=class extends Ou{constructor(e){super(vu(e==null?{}:e,Il,`v1/metrics`,{"Content-Type":`application/json`}),e)}},Au=class extends ko{constructor(e={}){super(vu(e,Kl,`v1/traces`,{"Content-Type":`application/json`}))}};function ju(e,t,n,r){for(let i=0,a=e.length;i<a;i++){let a=e[i];t&&a.setTracerProvider(t),n&&a.setMeterProvider(n),r&&a.setLoggerProvider&&a.setLoggerProvider(r),a.getConfig().enabled||a.enable()}}function Mu(e){e.forEach(e=>e.disable())}var Nu=t((()=>{}));function Pu(e){var t,n;let r=e.tracerProvider||M.getTracerProvider(),i=e.meterProvider||Pt.getMeterProvider(),a=e.loggerProvider||yn.getLoggerProvider(),o=(t=(n=e.instrumentations)==null?void 0:n.flat())==null?[]:t;return ju(o,r,i,a),()=>{Mu(o)}}var Fu=t((()=>{N(),Nu()}));function Iu(e,t,n){let r=!!e[t]&&Object.prototype.propertyIsEnumerable.call(e,t);Object.defineProperty(e,t,{configurable:!0,enumerable:r,writable:!0,value:n})}function Lu(e){e&&e.logger&&(typeof e.logger==`function`?K=e.logger:K(`new logger isn't a function, not replacing`))}var K,Ru,zu,Bu,Vu,Hu=t((()=>{K=console.error.bind(console),Ru=(e,t,n)=>{if(!e||!e[t]){K(`no original function `+String(t)+` to wrap`);return}if(!n){K(`no wrapper function`),K(Error().stack);return}let r=e[t];if(typeof r!=`function`||typeof n!=`function`){K(`original object and wrapper must be functions`);return}let i=n(r,t);return Iu(i,`__original`,r),Iu(i,`__unwrap`,()=>{e[t]===i&&Iu(e,t,r)}),Iu(i,`__wrapped`,!0),Iu(e,t,i),i},zu=(e,t,n)=>{if(e)Array.isArray(e)||(e=[e]);else{K(`must provide one or more modules to patch`),K(Error().stack);return}if(!(t&&Array.isArray(t))){K(`must provide one or more functions to wrap on modules`);return}e.forEach(e=>{t.forEach(t=>{Ru(e,t,n)})})},Bu=(e,t)=>{if(!e||!e[t]){K(`no function to unwrap.`),K(Error().stack);return}let n=e[t];if(!n.__unwrap)K(`no original to unwrap to -- has `+String(t)+` already been unwrapped?`);else{n.__unwrap();return}},Vu=(e,t)=>{if(e)Array.isArray(e)||(e=[e]);else{K(`must provide one or more modules to patch`),K(Error().stack);return}if(!(t&&Array.isArray(t))){K(`must provide one or more functions to unwrap on modules`);return}e.forEach(e=>{t.forEach(t=>{Bu(e,t)})})},Lu.wrap=Ru,Lu.massWrap=zu,Lu.unwrap=Bu,Lu.massUnwrap=Vu})),Uu,Wu=t((()=>{N(),bn(),Hu(),F(),G(),Uu=class{constructor(e,t,n){P(this,`_config`,{}),P(this,`_tracer`,void 0),P(this,`_meter`,void 0),P(this,`_logger`,void 0),P(this,`_diag`,void 0),P(this,`instrumentationName`,void 0),P(this,`instrumentationVersion`,void 0),P(this,`_wrap`,Ru),P(this,`_unwrap`,Bu),P(this,`_massWrap`,zu),P(this,`_massUnwrap`,Vu),this.instrumentationName=e,this.instrumentationVersion=t,this.setConfig(n),this._diag=j.createComponentLogger({namespace:e}),this._tracer=M.getTracer(e,t),this._meter=Pt.getMeter(e,t),this._logger=yn.getLogger(e,t),this._updateMetricInstruments()}get meter(){return this._meter}setMeterProvider(e){this._meter=e.getMeter(this.instrumentationName,this.instrumentationVersion),this._updateMetricInstruments()}get logger(){return this._logger}setLoggerProvider(e){this._logger=e.getLogger(this.instrumentationName,this.instrumentationVersion)}getModuleDefinitions(){var e;let t=(e=this.init())==null?[]:e;return Array.isArray(t)?t:[t]}_updateMetricInstruments(){}getConfig(){return this._config}setConfig(e){this._config=W({enabled:!0},e)}setTracerProvider(e){this._tracer=e.getTracer(this.instrumentationName,this.instrumentationVersion)}get tracer(){return this._tracer}_runSpanCustomizationHook(e,t,n,r){if(e)try{e(n,r)}catch(e){this._diag.error(`Error running span customization hook due to exception in handler`,{triggerName:t},e)}}}})),Gu,Ku=t((()=>{Wu(),Gu=class extends Uu{constructor(e,t,n){super(e,t,n),this._config.enabled&&this.enable()}}})),qu=t((()=>{Ku(),N()}));function Ju(e,t,n){let r,i;try{i=e()}catch(e){r=e}finally{if(t(r,i),r&&!n)throw r;return i}}var Yu=t((()=>{}));function Xu(e,t){let n=q.OLD,r=t==null?void 0:t.split(`,`).map(e=>e.trim()).filter(e=>e!==``);for(let t of r==null?[]:r)if(t.toLowerCase()===e+`/dup`){n=q.DUPLICATE;break}else t.toLowerCase()===e&&(n=q.STABLE);return n}var q,Zu=t((()=>{(function(e){e[e.STABLE=1]=`STABLE`,e[e.OLD=2]=`OLD`,e[e.DUPLICATE=3]=`DUPLICATE`})(q||(q={}))})),Qu=t((()=>{Fu(),qu(),F(),Yu(),Zu()}));function $u(e){return ed(e,new WeakSet)}function ed(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e instanceof Uint8Array)return!0;if(typeof e==`object`){if(t.has(e))return!1;if(t.add(e),Array.isArray(e))return e.every(e=>ed(e,t));let n=e;return n.constructor!==Object&&n.constructor!==void 0?!1:Object.values(n).every(e=>ed(e,t))}return!1}N(),B(),Zi(),F();var td=class{set severityText(e){this._isLogRecordReadonly()||(this._severityText=e)}get severityText(){return this._severityText}set severityNumber(e){this._isLogRecordReadonly()||(this._severityNumber=e)}get severityNumber(){return this._severityNumber}set body(e){this._isLogRecordReadonly()||(this._body=e)}get body(){return this._body}get eventName(){return this._eventName}set eventName(e){this._isLogRecordReadonly()||(this._eventName=e)}get droppedAttributesCount(){return this._droppedAttributesCount}constructor(e,t,n){P(this,`hrTime`,void 0),P(this,`hrTimeObserved`,void 0),P(this,`spanContext`,void 0),P(this,`resource`,void 0),P(this,`instrumentationScope`,void 0),P(this,`attributes`,{}),P(this,`_severityText`,void 0),P(this,`_severityNumber`,void 0),P(this,`_body`,void 0),P(this,`_eventName`,void 0),P(this,`_attributesCount`,0),P(this,`_droppedAttributesCount`,0),P(this,`_isReadonly`,!1),P(this,`_logRecordLimits`,void 0);let{timestamp:r,observedTimestamp:i,eventName:a,severityNumber:o,severityText:s,body:c,attributes:l={},exception:u,context:d}=n,f=Date.now();if(this.hrTime=aa(r==null?f:r),this.hrTimeObserved=aa(i==null?f:i),d){let e=M.getSpanContext(d);e&&it(e)&&(this.spanContext=e)}this.severityNumber=o,this.severityText=s,this.body=c,this.resource=e.resource,this.instrumentationScope=t,this._logRecordLimits=e.logRecordLimits,this._eventName=a,this.setAttributes(l),u!=null&&this._setException(u)}setAttribute(e,t){if(this._isLogRecordReadonly())return this;if(e.length===0)return j.warn(`Invalid attribute key: ${e}`),this;if(!$u(t))return j.warn(`Invalid attribute value set for key: ${e}`),this;let n=!Object.prototype.hasOwnProperty.call(this.attributes,e);return n&&this._attributesCount>=this._logRecordLimits.attributeCountLimit?(this._droppedAttributesCount++,this._droppedAttributesCount===1&&j.warn(`Dropping extra attributes.`),this):(this.attributes[e]=this._truncateToSize(t),n&&this._attributesCount++,this)}setAttributes(e){for(let[t,n]of Object.entries(e))this.setAttribute(t,n);return this}setBody(e){return this.body=e,this}setEventName(e){return this.eventName=e,this}setSeverityNumber(e){return this.severityNumber=e,this}setSeverityText(e){return this.severityText=e,this}_makeReadonly(){this._isReadonly=!0}_truncateToSize(e){let t=this._logRecordLimits.attributeValueLengthLimit;if(t<=0)return j.warn(`Attribute value limit must be positive, got ${t}`),e;if(e==null)return e;if(typeof e==`string`)return this._truncateToLimitUtil(e,t);if(e instanceof Uint8Array)return e;if(Array.isArray(e))return e.map(e=>this._truncateToSize(e));if(typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=this._truncateToSize(r);return t}return e}_setException(e){let t=!1;if(typeof e==`string`||typeof e==`number`)Object.hasOwn(this.attributes,`exception.message`)||this.setAttribute(Ni,String(e)),t=!0;else if(e&&typeof e==`object`){let n=e;n.code?(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(Fi,n.code.toString()),t=!0):n.name&&(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(Fi,n.name),t=!0),n.message&&(Object.hasOwn(this.attributes,`exception.message`)||this.setAttribute(Ni,n.message),t=!0),n.stack&&(Object.hasOwn(this.attributes,`exception.stacktrace`)||this.setAttribute(Pi,n.stack),t=!0)}t||j.warn(`Failed to record an exception ${e}`)}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_isLogRecordReadonly(){return this._isReadonly&&j.warn(`Can not execute the operation on emitted log record`),this._isReadonly}};bn(),N(),F(),G();var nd=class{constructor(e,t){P(this,`instrumentationScope`,void 0),P(this,`_sharedState`,void 0),P(this,`_loggerConfig`,void 0),this.instrumentationScope=e,this._sharedState=t,this._loggerConfig=this._sharedState.getLoggerConfig(this.instrumentationScope)}emit(e){var t;let n=this._loggerConfig,r=e.context||A.active(),i=(t=e.severityNumber)==null?en.UNSPECIFIED:t;if(i!==en.UNSPECIFIED&&i<n.minimumSeverity)return;if(n.traceBased){let e=M.getSpanContext(r);if(e&&it(e)&&(e.traceFlags&k.SAMPLED)!==k.SAMPLED)return}let a=new td(this._sharedState,this.instrumentationScope,W({context:r},e));this._sharedState.loggerMetrics.emitLog(),this._sharedState.activeProcessor.onEmit(a,r),a._makeReadonly()}enabled(e){let t=this._loggerConfig;if(t.disabled)return!1;let n=e==null?void 0:e.severityNumber;if(typeof n==`number`&&n!==en.UNSPECIFIED&&n<t.minimumSeverity)return!1;let r=(e==null?void 0:e.context)||A.active();if(t.traceBased){let e=M.getSpanContext(r);if(e&&it(e)&&(e.traceFlags&k.SAMPLED)!==k.SAMPLED)return!1}let i={context:r,instrumentationScope:this.instrumentationScope,severityNumber:e==null?void 0:e.severityNumber,eventName:e==null?void 0:e.eventName};for(let e of this._sharedState.processors)if(!e.enabled||e.enabled(i))return!0;return!1}},rd=class{forceFlush(){return Promise.resolve()}onEmit(e,t){}shutdown(){return Promise.resolve()}enabled(e){return!1}};B(),F(),H();var id=class{constructor(e,t){P(this,`processors`,void 0),P(this,`forceFlushTimeoutMillis`,void 0),this.processors=e,this.forceFlushTimeoutMillis=t}forceFlush(){var e=this;return V(function*(){let t=e.forceFlushTimeoutMillis;yield Promise.all(e.processors.map(e=>go(e.forceFlush(),t)))})()}onEmit(e,t){this.processors.forEach(n=>n.onEmit(e,t))}shutdown(){var e=this;return V(function*(){yield Promise.all(e.processors.map(e=>e.shutdown()))})()}enabled(e){for(let t of this.processors)if(!t.enabled||t.enabled(e))return!0;return!1}};function ad(e){return`${e.name}@${e.version||``}:${e.schemaUrl||``}`}var od=`otel.sdk.log.created`;F();var sd=class{constructor(e){P(this,`createdLogs`,void 0),this.createdLogs=e.createCounter(od,{unit:`{log_record}`,description:`The number of logs submitted to enabled SDK Loggers.`})}emitLog(){this.createdLogs.add(1)}},cd=`0.217.0`;N(),bn(),G(),F();var ld={disabled:!1,minimumSeverity:en.UNSPECIFIED,traceBased:!1},ud=()=>W({},ld),dd=class{constructor(e,t,n,r,i,a){P(this,`loggers`,new Map),P(this,`activeProcessor`,void 0),P(this,`registeredLogRecordProcessors`,[]),P(this,`resource`,void 0),P(this,`forceFlushTimeoutMillis`,void 0),P(this,`logRecordLimits`,void 0),P(this,`processors`,void 0),P(this,`loggerMetrics`,void 0),P(this,`_loggerConfigurator`,void 0),P(this,`_loggerConfigs`,new Map),this.resource=e,this.forceFlushTimeoutMillis=t,this.logRecordLimits=n,this.processors=r,r.length>0?(this.registeredLogRecordProcessors=r,this.activeProcessor=new id(this.registeredLogRecordProcessors,this.forceFlushTimeoutMillis)):this.activeProcessor=new rd,this._loggerConfigurator=i==null?ud:i;let o=a?a.getMeter(`@opentelemetry/sdk-logs`,cd):le();this.loggerMetrics=new sd(o)}getLoggerConfig(e){let t=ad(e),n=this._loggerConfigs.get(t);return n||(n=this._loggerConfigurator(e),this._loggerConfigs.set(t,n),n)}};N(),bn(),lc(),B(),F();var fd=class{constructor(e={}){var t,n,r,i,a,o,s,c;P(this,`_shutdownOnce`,void 0),P(this,`_sharedState`,void 0);let l={resource:(t=e.resource)==null?rc():t,forceFlushTimeoutMillis:(n=e.forceFlushTimeoutMillis)==null?3e4:n,logRecordLimits:{attributeCountLimit:(r=(i=e.logRecordLimits)==null?void 0:i.attributeCountLimit)==null?128:r,attributeValueLengthLimit:(a=(o=e.logRecordLimits)==null?void 0:o.attributeValueLengthLimit)==null?1/0:a},loggerConfigurator:(s=e.loggerConfigurator)==null?ud:s,processors:(c=e.processors)==null?[]:c,meterProvider:e.meterProvider};this._sharedState=new dd(l.resource,l.forceFlushTimeoutMillis,l.logRecordLimits,l.processors,l.loggerConfigurator,l.meterProvider),this._shutdownOnce=new wo(this._shutdown,this)}getLogger(e,t,n){if(this._shutdownOnce.isCalled)return j.warn(`A shutdown LoggerProvider cannot provide a Logger`),rn;e||j.warn(`Logger requested without instrumentation scope name.`);let r=e||`unknown`,i=`${r}@${t||``}:${(n==null?void 0:n.schemaUrl)||``}`;return this._sharedState.loggers.has(i)||this._sharedState.loggers.set(i,new nd({name:r,version:t,schemaUrl:n==null?void 0:n.schemaUrl},this._sharedState)),this._sharedState.loggers.get(i)}forceFlush(){return this._shutdownOnce.isCalled?(j.warn(`invalid attempt to force flush after LoggerProvider shutdown`),this._shutdownOnce.promise):this._sharedState.activeProcessor.forceFlush()}shutdown(){return this._shutdownOnce.isCalled?(j.warn(`shutdown may only be called once per LoggerProvider`),this._shutdownOnce.promise):this._shutdownOnce.call()}_shutdown(){return this._sharedState.activeProcessor.shutdown()}};N(),B(),H(),F();function pd(e){return md.apply(this,arguments)}function md(){return md=V(function*(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];r.resource.asyncAttributesPending&&r.resource.waitForAsyncAttributes&&t.push(r.resource.waitForAsyncAttributes())}t!=null&&t.length>0&&(yield Promise.all(t))}),md.apply(this,arguments)}var hd=class{constructor(e,t,n){P(this,`_exportCompleted`,void 0),P(this,`_exportScheduledPromise`,void 0),P(this,`_exportScheduledResolve`,void 0),this._exportScheduledPromise=new Promise(e=>{this._exportScheduledResolve=e}),this._exportCompleted=this._executeExport(e,t,n)}get exportCompleted(){return this._exportCompleted}get exportScheduled(){return this._exportScheduledPromise}_executeExport(e,t,n){var r=this;return V(function*(){try{yield pd(t),yield A.with($r(A.active()),V(function*(){return r._exportWithTimeout(e,t,n)}))}catch(e){Si(e),r._exportScheduledResolve()}})()}_exportWithTimeout(e,t,n){var r=this;return V(function*(){return new Promise((i,a)=>{let o=setTimeout(()=>{a(Error(`Timeout`))},n);e.export(t,e=>{if(clearTimeout(o),e.code===ga.SUCCESS)i();else{var t;a((t=e.error)==null?Error(`BatchLogRecordProcessor: log record export failed`):t)}}),r._exportScheduledResolve()})})()}},gd=class{constructor(e,t){var n,r,i,a;P(this,`_maxExportBatchSize`,void 0),P(this,`_maxQueueSize`,void 0),P(this,`_scheduledDelayMillis`,void 0),P(this,`_exportTimeoutMillis`,void 0),P(this,`_exporter`,void 0),P(this,`_currentExport`,null),P(this,`_finishedLogRecords`,[]),P(this,`_timer`,void 0),P(this,`_shutdownOnce`,void 0),P(this,`_flushing`,!1),this._exporter=e,this._maxExportBatchSize=(n=t==null?void 0:t.maxExportBatchSize)==null?512:n,this._maxQueueSize=(r=t==null?void 0:t.maxQueueSize)==null?2048:r,this._scheduledDelayMillis=(i=t==null?void 0:t.scheduledDelayMillis)==null?5e3:i,this._exportTimeoutMillis=(a=t==null?void 0:t.exportTimeoutMillis)==null?3e4:a,this._shutdownOnce=new wo(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(j.warn(`BatchLogRecordProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize)}onEmit(e){this._shutdownOnce.isCalled||this._addToBuffer(e)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}_addToBuffer(e){this._finishedLogRecords.length>=this._maxQueueSize||(this._finishedLogRecords.push(e),this._maybeStartTimer())}shutdown(){return this._shutdownOnce.call()}_shutdown(){var e=this;return V(function*(){e.onShutdown(),yield e._flushAll(),yield e._exporter.shutdown()})()}_flushAll(){var e=this;return V(function*(){if(e._flushing)return;e._flushing=!0;let t=e._finishedLogRecords;for(e._finishedLogRecords=[],e._clearTimer(),e._currentExport!==null&&(yield e._exporter.forceFlush(),yield e._currentExport.exportCompleted,e._currentExport=null);t.length>0;){let n;t.length<=e._maxExportBatchSize?(n=t,t=[]):n=t.splice(0,e._maxExportBatchSize);let r=new hd(e._exporter,n,e._exportTimeoutMillis);e._currentExport=r;try{yield r.exportScheduled,yield e._exporter.forceFlush(),yield r.exportCompleted}catch(e){Si(e)}finally{e._currentExport=null}}e._flushing=!1,e._maybeStartTimer()})()}_extractBatch(){if(this._finishedLogRecords.length===0)return null;if(this._finishedLogRecords.length<=this._maxExportBatchSize){let e=this._finishedLogRecords;return this._finishedLogRecords=[],e}else return this._finishedLogRecords.splice(0,this._maxExportBatchSize)}_exportOneBatch(){this._clearTimer();let e=this._extractBatch();if(e===null)return;let t=new hd(this._exporter,e,this._exportTimeoutMillis);this._currentExport=t,t.exportCompleted.then(()=>{this._currentExport=null,this._maybeStartTimer()}).catch(e=>{this._currentExport=null,Si(e),this._maybeStartTimer()})}_maybeStartTimer(){if(!this._shutdownOnce.isCalled&&!this._flushing&&this._finishedLogRecords.length!==0&&this._currentExport===null){if(this._finishedLogRecords.length>=this._maxExportBatchSize){this._exportOneBatch();return}this._timer===void 0&&(this._timer=setTimeout(()=>{this._timer=void 0,this._exportOneBatch()},this._scheduledDelayMillis),typeof this._timer!=`number`&&this._timer.unref())}}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}};F();var _d=class extends gd{constructor(e,t){super(e,t),P(this,`_visibilityChangeListener`,void 0),P(this,`_pageHideListener`,void 0),this._onInit(t)}onShutdown(){typeof document>`u`||(this._visibilityChangeListener&&document.removeEventListener(`visibilitychange`,this._visibilityChangeListener),this._pageHideListener&&document.removeEventListener(`pagehide`,this._pageHideListener))}_onInit(e){(e==null?void 0:e.disableAutoFlushOnDocumentHide)===!0||typeof document>`u`||(this._visibilityChangeListener=()=>{document.visibilityState===`hidden`&&this.forceFlush()},this._pageHideListener=()=>{this.forceFlush()},document.addEventListener(`visibilitychange`,this._visibilityChangeListener),document.addEventListener(`pagehide`,this._pageHideListener))}},vd,yd=t((()=>{vd=`exception`})),bd,xd=t((()=>{N(),B(),Zi(),yd(),F(),bd=class{constructor(e){var t,n;P(this,`_spanContext`,void 0),P(this,`kind`,void 0),P(this,`parentSpanContext`,void 0),P(this,`attributes`,{}),P(this,`links`,[]),P(this,`events`,[]),P(this,`startTime`,void 0),P(this,`resource`,void 0),P(this,`instrumentationScope`,void 0),P(this,`_droppedAttributesCount`,0),P(this,`_droppedEventsCount`,0),P(this,`_droppedLinksCount`,0),P(this,`_attributesCount`,0),P(this,`name`,void 0),P(this,`status`,{code:wt.UNSET}),P(this,`endTime`,[0,0]),P(this,`_ended`,!1),P(this,`_duration`,[-1,-1]),P(this,`_spanProcessor`,void 0),P(this,`_spanLimits`,void 0),P(this,`_attributeValueLengthLimit`,void 0),P(this,`_recordEndMetrics`,void 0),P(this,`_performanceStartTime`,void 0),P(this,`_performanceOffset`,void 0),P(this,`_startTimeProvided`,void 0);let r=Date.now();if(this._spanContext=e.spanContext,this._performanceStartTime=z.now(),this._performanceOffset=r-(this._performanceStartTime+z.timeOrigin),this._startTimeProvided=e.startTime!=null,this._spanLimits=e.spanLimits,this._attributeValueLengthLimit=(t=this._spanLimits.attributeValueLengthLimit)==null?0:t,this._spanProcessor=e.spanProcessor,this.name=e.name,this.parentSpanContext=e.parentSpanContext,this.kind=e.kind,e.links)for(let t of e.links)this.addLink(t);this.startTime=this._getTime((n=e.startTime)==null?r:n),this.resource=e.resource,this.instrumentationScope=e.scope,this._recordEndMetrics=e.recordEndMetrics,e.attributes!=null&&this.setAttributes(e.attributes),this._spanProcessor.onStart(this,e.context)}spanContext(){return this._spanContext}setAttribute(e,t){if(t==null||this._isSpanEnded())return this;if(e.length===0)return j.warn(`Invalid attribute key: ${e}`),this;if(!mi(t))return j.warn(`Invalid attribute value set for key: ${e}`),this;let{attributeCountLimit:n}=this._spanLimits,r=!Object.prototype.hasOwnProperty.call(this.attributes,e);return n!==void 0&&this._attributesCount>=n&&r?(this._droppedAttributesCount++,this):(this.attributes[e]=this._truncateToSize(t),r&&this._attributesCount++,this)}setAttributes(e){for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.setAttribute(t,e[t]);return this}addEvent(e,t,n){if(this._isSpanEnded())return this;let{eventCountLimit:r}=this._spanLimits;if(r===0)return j.warn(`No events allowed.`),this._droppedEventsCount++,this;r!==void 0&&this.events.length>=r&&(this._droppedEventsCount===0&&j.debug(`Dropping extra events.`),this.events.shift(),this._droppedEventsCount++),ua(t)&&(ua(n)||(n=t),t=void 0);let i=fi(t),{attributePerEventCountLimit:a}=this._spanLimits,o={},s=0,c=0;for(let e in i){if(!Object.prototype.hasOwnProperty.call(i,e))continue;let t=i[e];if(a!==void 0&&c>=a){s++;continue}o[e]=this._truncateToSize(t),c++}return this.events.push({name:e,attributes:o,time:this._getTime(n),droppedAttributesCount:s}),this}addLink(e){if(this._isSpanEnded())return this;let{linkCountLimit:t}=this._spanLimits;if(t===0)return this._droppedLinksCount++,this;t!==void 0&&this.links.length>=t&&(this._droppedLinksCount===0&&j.debug(`Dropping extra links.`),this.links.shift(),this._droppedLinksCount++);let{attributePerLinkCountLimit:n}=this._spanLimits,r=fi(e.attributes),i={},a=0,o=0;for(let e in r){if(!Object.prototype.hasOwnProperty.call(r,e))continue;let t=r[e];if(n!==void 0&&o>=n){a++;continue}i[e]=this._truncateToSize(t),o++}let s={context:e.context};return o>0&&(s.attributes=i),a>0&&(s.droppedAttributesCount=a),this.links.push(s),this}addLinks(e){for(let t of e)this.addLink(t);return this}setStatus(e){if(this._isSpanEnded()||e.code===wt.UNSET||this.status.code===wt.OK)return this;let t={code:e.code};return e.code===wt.ERROR&&(typeof e.message==`string`?t.message=e.message:e.message!=null&&j.warn(`Dropping invalid status.message of type '${typeof e.message}', expected 'string'`)),this.status=t,this}updateName(e){return this._isSpanEnded()||(this.name=e),this}end(e){var t;if(this._isSpanEnded()){j.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`);return}this.endTime=this._getTime(e),this._duration=oa(this.startTime,this.endTime),this._duration[0]<0&&(j.warn(`Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.`,this.startTime,this.endTime),this.endTime=this.startTime.slice(),this._duration=[0,0]),this._droppedEventsCount>0&&j.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._droppedLinksCount>0&&j.warn(`Dropped ${this._droppedLinksCount} links because linkCountLimit reached`),this._spanProcessor.onEnding&&this._spanProcessor.onEnding(this),(t=this._recordEndMetrics)==null||t.call(this),this._ended=!0,this._spanProcessor.onEnd(this)}_getTime(e){if(typeof e==`number`&&e<=z.now())return ia(e+this._performanceOffset);if(typeof e==`number`)return ra(e);if(e instanceof Date)return ra(e.getTime());if(la(e))return e;if(this._startTimeProvided)return ra(Date.now());let t=z.now()-this._performanceStartTime;return da(this.startTime,ra(t))}isRecording(){return this._ended===!1}recordException(e,t){let n={};typeof e==`string`?n[Ni]=e:e&&(e.code?n[Fi]=e.code.toString():e.name&&(n[Fi]=e.name),e.message&&(n[Ni]=e.message),e.stack&&(n[Pi]=e.stack)),n[`exception.type`]||n[`exception.message`]?this.addEvent(vd,n,t):j.warn(`Failed to record an exception ${e}`)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}_isSpanEnded(){if(this._ended){let e=Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);j.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,e)}return this._ended}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_truncateToSize(e){let t=this._attributeValueLengthLimit;return t<=0?(j.warn(`Attribute value limit must be positive, got ${t}`),e):typeof e==`string`?this._truncateToLimitUtil(e,t):Array.isArray(e)?e.map(e=>typeof e==`string`?this._truncateToLimitUtil(e,t):e):e}}})),Sd,Cd=t((()=>{(function(e){e[e.NOT_RECORD=0]=`NOT_RECORD`,e[e.RECORD=1]=`RECORD`,e[e.RECORD_AND_SAMPLED=2]=`RECORD_AND_SAMPLED`})(Sd||(Sd={}))})),wd,Td=t((()=>{Cd(),wd=class{shouldSample(){return{decision:Sd.NOT_RECORD}}toString(){return`AlwaysOffSampler`}}})),Ed,Dd=t((()=>{Cd(),Ed=class{shouldSample(){return{decision:Sd.RECORD_AND_SAMPLED}}toString(){return`AlwaysOnSampler`}}})),Od,kd=t((()=>{N(),B(),Td(),Dd(),F(),Od=class{constructor(e){var t,n,r,i;P(this,`_root`,void 0),P(this,`_remoteParentSampled`,void 0),P(this,`_remoteParentNotSampled`,void 0),P(this,`_localParentSampled`,void 0),P(this,`_localParentNotSampled`,void 0),this._root=e.root,this._root||(Si(Error(`ParentBasedSampler must have a root sampler configured`)),this._root=new Ed),this._remoteParentSampled=(t=e.remoteParentSampled)==null?new Ed:t,this._remoteParentNotSampled=(n=e.remoteParentNotSampled)==null?new wd:n,this._localParentSampled=(r=e.localParentSampled)==null?new Ed:r,this._localParentNotSampled=(i=e.localParentNotSampled)==null?new wd:i}shouldSample(e,t,n,r,i,a){let o=M.getSpanContext(e);return!o||!it(o)?this._root.shouldSample(e,t,n,r,i,a):o.isRemote?o.traceFlags&k.SAMPLED?this._remoteParentSampled.shouldSample(e,t,n,r,i,a):this._remoteParentNotSampled.shouldSample(e,t,n,r,i,a):o.traceFlags&k.SAMPLED?this._localParentSampled.shouldSample(e,t,n,r,i,a):this._localParentNotSampled.shouldSample(e,t,n,r,i,a)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}}})),Ad,jd=t((()=>{N(),Cd(),F(),Ad=class{constructor(e=0){P(this,`_ratio`,void 0),P(this,`_upperBound`,void 0),this._ratio=this._normalize(e),this._upperBound=Math.floor(this._ratio*4294967295)}shouldSample(e,t){return{decision:nt(t)&&this._accumulate(t)<this._upperBound?Sd.RECORD_AND_SAMPLED:Sd.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(e){return typeof e!=`number`||isNaN(e)?0:e>=1?1:e<=0?0:e}_accumulate(e){let t=0;for(let n=0;n<32;n+=8){let r=0;for(let t=0;t<8;t++){let i=e.charCodeAt(n+t),a=i<58?i-48:i<71?i-55:i-87;r=r<<4|a}t=(t^r)>>>0}return t}}}));function Md(){var e,t,n,r,i,a,o,s;return{sampler:Nd(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:(e=void 0)==null?1/0:e,attributeCountLimit:(t=void 0)==null?128:t},spanLimits:{attributeValueLengthLimit:(n=void 0)==null?1/0:n,attributeCountLimit:(r=void 0)==null?128:r,linkCountLimit:(i=void 0)==null?128:i,eventCountLimit:(a=void 0)==null?128:a,attributePerEventCountLimit:(o=void 0)==null?128:o,attributePerLinkCountLimit:(s=void 0)==null?128:s}}}function Nd(){var e;let t=(e=void 0)==null?Fd.ParentBasedAlwaysOn:e;switch(t){case Fd.AlwaysOn:return new Ed;case Fd.AlwaysOff:return new wd;case Fd.ParentBasedAlwaysOn:return new Od({root:new Ed});case Fd.ParentBasedAlwaysOff:return new Od({root:new wd});case Fd.TraceIdRatio:return new Ad(Pd());case Fd.ParentBasedTraceIdRatio:return new Od({root:new Ad(Pd())});default:return j.error(`OTEL_TRACES_SAMPLER value "${t}" invalid, defaulting to "${Fd.ParentBasedAlwaysOn}".`),new Od({root:new Ed})}}function Pd(){return j.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${Id}.`),Id}var Fd,Id,Ld=t((()=>{N(),B(),Td(),Dd(),kd(),jd(),(function(e){e.AlwaysOff=`always_off`,e.AlwaysOn=`always_on`,e.ParentBasedAlwaysOff=`parentbased_always_off`,e.ParentBasedAlwaysOn=`parentbased_always_on`,e.ParentBasedTraceIdRatio=`parentbased_traceidratio`,e.TraceIdRatio=`traceidratio`})(Fd||(Fd={})),Id=1}));function Rd(e){let t={sampler:Nd()},n=Md(),r=Object.assign({},n,t,e);return r.generalLimits=Object.assign({},n.generalLimits,e.generalLimits||{}),r.spanLimits=Object.assign({},n.spanLimits,e.spanLimits||{}),r}function zd(e){var t,n,r,i,a,o,s,c,l,u,d,f;let p=Object.assign({},e.spanLimits);return p.attributeCountLimit=(t=(n=(r=(i=(a=e.spanLimits)==null?void 0:a.attributeCountLimit)==null?(o=e.generalLimits)==null?void 0:o.attributeCountLimit:i)==null?void 0:r)==null?void 0:n)==null?128:t,p.attributeValueLengthLimit=(s=(c=(l=(u=(d=e.spanLimits)==null?void 0:d.attributeValueLengthLimit)==null?(f=e.generalLimits)==null?void 0:f.attributeValueLengthLimit:u)==null?void 0:l)==null?void 0:c)==null?Bd:s,Object.assign({},e,{spanLimits:p})}var Bd,Vd=t((()=>{Ld(),B(),Bd=1/0})),Hd,Ud=t((()=>{N(),B(),F(),Hd=class{constructor(e,t){var n,r,i,a;P(this,`_maxExportBatchSize`,void 0),P(this,`_maxQueueSize`,void 0),P(this,`_scheduledDelayMillis`,void 0),P(this,`_exportTimeoutMillis`,void 0),P(this,`_exporter`,void 0),P(this,`_isExporting`,!1),P(this,`_finishedSpans`,[]),P(this,`_timer`,void 0),P(this,`_shutdownOnce`,void 0),P(this,`_droppedSpansCount`,0),this._exporter=e,this._maxExportBatchSize=typeof(t==null?void 0:t.maxExportBatchSize)==`number`?t.maxExportBatchSize:(n=void 0)==null?512:n,this._maxQueueSize=typeof(t==null?void 0:t.maxQueueSize)==`number`?t.maxQueueSize:(r=void 0)==null?2048:r,this._scheduledDelayMillis=typeof(t==null?void 0:t.scheduledDelayMillis)==`number`?t.scheduledDelayMillis:(i=void 0)==null?5e3:i,this._exportTimeoutMillis=typeof(t==null?void 0:t.exportTimeoutMillis)==`number`?t.exportTimeoutMillis:(a=void 0)==null?3e4:a,this._shutdownOnce=new wo(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(j.warn(`BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}onStart(e,t){}onEnd(e){this._shutdownOnce.isCalled||(e.spanContext().traceFlags&k.SAMPLED)!==0&&this._addToBuffer(e)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return Promise.resolve().then(()=>this.onShutdown()).then(()=>this._flushAll()).then(()=>this._exporter.shutdown())}_addToBuffer(e){if(this._finishedSpans.length>=this._maxQueueSize){this._droppedSpansCount===0&&j.debug(`maxQueueSize reached, dropping spans`),this._droppedSpansCount++;return}this._droppedSpansCount>0&&(j.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`),this._droppedSpansCount=0),this._finishedSpans.push(e),this._maybeStartTimer()}_flushAll(){return new Promise((e,t)=>{let n=[],r=Math.ceil(this._finishedSpans.length/this._maxExportBatchSize);for(let e=0,t=r;e<t;e++)n.push(this._flushOneBatch());Promise.all(n).then(()=>{e()}).catch(t)})}_flushOneBatch(){return this._clearTimer(),this._finishedSpans.length===0?Promise.resolve():new Promise((e,t)=>{let n=setTimeout(()=>{t(Error(`Timeout`))},this._exportTimeoutMillis);A.with($r(A.active()),()=>{let r;this._finishedSpans.length<=this._maxExportBatchSize?(r=this._finishedSpans,this._finishedSpans=[]):r=this._finishedSpans.splice(0,this._maxExportBatchSize);let i=()=>this._exporter.export(r,r=>{if(clearTimeout(n),r.code===ga.SUCCESS)e();else{var i;t((i=r.error)==null?Error(`BatchSpanProcessor: span export failed`):i)}}),a=null;for(let e=0,t=r.length;e<t;e++){let t=r[e];t.resource.asyncAttributesPending&&t.resource.waitForAsyncAttributes&&(a!=null||(a=[]),a.push(t.resource.waitForAsyncAttributes()))}a===null?i():Promise.all(a).then(i,e=>{Si(e),t(e)})})})}_maybeStartTimer(){if(this._isExporting)return;let e=()=>{this._isExporting=!0,this._flushOneBatch().finally(()=>{this._isExporting=!1,this._finishedSpans.length>0&&(this._clearTimer(),this._maybeStartTimer())}).catch(e=>{this._isExporting=!1,Si(e)})};if(this._finishedSpans.length>=this._maxExportBatchSize)return e();this._timer===void 0&&(this._timer=setTimeout(()=>e(),this._scheduledDelayMillis),typeof this._timer!=`number`&&this._timer.unref())}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}}})),Wd,Gd=t((()=>{Ud(),B(),F(),Wd=class extends Hd{constructor(e,t){super(e,t),P(this,`_visibilityChangeListener`,void 0),P(this,`_pageHideListener`,void 0),this.onInit(t)}onInit(e){(e==null?void 0:e.disableAutoFlushOnDocumentHide)!==!0&&typeof document<`u`&&(this._visibilityChangeListener=()=>{document.visibilityState===`hidden`&&this.forceFlush().catch(e=>{Si(e)})},this._pageHideListener=()=>{this.forceFlush().catch(e=>{Si(e)})},document.addEventListener(`visibilitychange`,this._visibilityChangeListener),document.addEventListener(`pagehide`,this._pageHideListener))}onShutdown(){typeof document<`u`&&(this._visibilityChangeListener&&document.removeEventListener(`visibilitychange`,this._visibilityChangeListener),this._pageHideListener&&document.removeEventListener(`pagehide`,this._pageHideListener))}}}));function Kd(e){for(let t=0;t<e.length;t++)e[t]=Math.random()*256>>>0;for(let t=0;t<e.length;t++)if(e[t]>0)return;e[e.length-1]=1}function qd(e){let t=``;for(let n=0;n<e.length;n++)t+=Qd[e[n]];return t}var Jd,Yd,Xd,Zd,Qd,$d,ef=t((()=>{Jd=16,Yd=8,Xd=new Uint8Array(Jd),Zd=new Uint8Array(Yd),Qd=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`)),$d=class{generateTraceId(){return Kd(Xd),qd(Xd)}generateSpanId(){return Kd(Zd),qd(Zd)}}})),tf=t((()=>{Gd(),ef()})),nf,rf,af,of,sf=t((()=>{nf=`otel.span.parent.origin`,rf=`otel.span.sampling_result`,af=`otel.sdk.span.live`,of=`otel.sdk.span.started`}));function cf(e){return e?e.isRemote?`remote`:`local`:`none`}function lf(e){switch(e){case Sd.RECORD_AND_SAMPLED:return`RECORD_AND_SAMPLE`;case Sd.RECORD:return`RECORD_ONLY`;case Sd.NOT_RECORD:return`DROP`}}var uf,df=t((()=>{Cd(),sf(),F(),uf=class{constructor(e){P(this,`startedSpans`,void 0),P(this,`liveSpans`,void 0),this.startedSpans=e.createCounter(of,{unit:`{span}`,description:`The number of created spans.`}),this.liveSpans=e.createUpDownCounter(af,{unit:`{span}`,description:`The number of currently live spans.`})}startSpan(e,t){let n=lf(t);if(this.startedSpans.add(1,{[nf]:cf(e),[rf]:n}),t===Sd.NOT_RECORD)return()=>{};let r={[rf]:n};return this.liveSpans.add(1,r),()=>{this.liveSpans.add(-1,r)}}}})),ff,pf=t((()=>{ff=`2.7.1`})),mf,hf=t((()=>{N(),B(),xd(),Vd(),tf(),df(),pf(),F(),mf=class{constructor(e,t,n,r){P(this,`_sampler`,void 0),P(this,`_generalLimits`,void 0),P(this,`_spanLimits`,void 0),P(this,`_idGenerator`,void 0),P(this,`instrumentationScope`,void 0),P(this,`_resource`,void 0),P(this,`_spanProcessor`,void 0),P(this,`_tracerMetrics`,void 0);let i=Rd(t);this._sampler=i.sampler,this._generalLimits=i.generalLimits,this._spanLimits=i.spanLimits,this._idGenerator=t.idGenerator||new $d,this._resource=n,this._spanProcessor=r,this.instrumentationScope=e;let a=i.meterProvider?i.meterProvider.getMeter(`@opentelemetry/sdk-trace`,ff):le();this._tracerMetrics=new uf(a)}startSpan(e,t={},n=A.active()){var r,i,a;t.root&&(n=M.deleteSpan(n));let o=M.getSpan(n);if(ei(n))return j.debug(`Instrumentation suppressed, returning Noop Span`),M.wrapSpanContext(Ue);let s=o==null?void 0:o.spanContext(),c=this._idGenerator.generateSpanId(),l,u,d;!s||!M.isSpanContextValid(s)?u=this._idGenerator.generateTraceId():(u=s.traceId,d=s.traceState,l=s);let f=(r=t.kind)==null?St.INTERNAL:r,p=((i=t.links)==null?[]:i).map(e=>({context:e.context,attributes:fi(e.attributes)})),m=fi(t.attributes),h=this._sampler.shouldSample(n,u,e,f,m,p),g=this._tracerMetrics.startSpan(s,h.decision);d=(a=h.traceState)==null?d:a;let _=h.decision===bt.RECORD_AND_SAMPLED?k.SAMPLED:k.NONE,v={traceId:u,spanId:c,traceFlags:_,traceState:d};if(h.decision===bt.NOT_RECORD)return j.debug(`Recording is off, propagating context in a non-recording span`),M.wrapSpanContext(v);let y=fi(Object.assign(m,h.attributes));return new bd({resource:this._resource,scope:this.instrumentationScope,context:n,spanContext:v,name:e,kind:f,links:p,parentSpanContext:l,attributes:y,startTime:t.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits,recordEndMetrics:g})}startActiveSpan(e,t,n,r){var i;let a,o,s;if(arguments.length<2)return;arguments.length===2?s=t:arguments.length===3?(a=t,s=n):(a=t,o=n,s=r);let c=(i=o)==null?A.active():i,l=this.startSpan(e,a,c),u=M.setSpan(c,l);return A.with(u,s,void 0,l)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}}})),gf,_f=t((()=>{B(),F(),gf=class{constructor(e){P(this,`_spanProcessors`,void 0),this._spanProcessors=e}forceFlush(){let e=[];for(let t of this._spanProcessors)e.push(t.forceFlush());return new Promise(t=>{Promise.all(e).then(()=>{t()}).catch(e=>{Si(e||Error(`MultiSpanProcessor: forceFlush failed`)),t()})})}onStart(e,t){for(let n of this._spanProcessors)n.onStart(e,t)}onEnding(e){for(let t of this._spanProcessors)t.onEnding&&t.onEnding(e)}onEnd(e){for(let t of this._spanProcessors)t.onEnd(e)}shutdown(){let e=[];for(let t of this._spanProcessors)e.push(t.shutdown());return new Promise((t,n)=>{Promise.all(e).then(()=>{t()},n)})}}})),vf,yf,bf=t((()=>{B(),lc(),hf(),Ld(),_f(),Vd(),F(),(function(e){e[e.resolved=0]=`resolved`,e[e.timeout=1]=`timeout`,e[e.error=2]=`error`,e[e.unresolved=3]=`unresolved`})(vf||(vf={})),yf=class{constructor(e={}){var t,n;P(this,`_config`,void 0),P(this,`_tracers`,new Map),P(this,`_resource`,void 0),P(this,`_activeSpanProcessor`,void 0);let r=io({},Md(),zd(e));this._resource=(t=r.resource)==null?rc():t,this._config=Object.assign({},r,{resource:this._resource});let i=[];(n=e.spanProcessors)!=null&&n.length&&i.push(...e.spanProcessors),this._activeSpanProcessor=new gf(i)}getTracer(e,t,n){let r=`${e}@${t||``}:${(n==null?void 0:n.schemaUrl)||``}`;return this._tracers.has(r)||this._tracers.set(r,new mf({name:e,version:t,schemaUrl:n==null?void 0:n.schemaUrl},this._config,this._resource,this._activeSpanProcessor)),this._tracers.get(r)}forceFlush(){let e=this._config.forceFlushTimeoutMillis,t=this._activeSpanProcessor._spanProcessors.map(t=>new Promise(n=>{let r,i=setTimeout(()=>{n(Error(`Span processor did not completed within timeout period of ${e} ms`)),r=vf.timeout},e);t.forceFlush().then(()=>{clearTimeout(i),r!==vf.timeout&&(r=vf.resolved,n(r))}).catch(e=>{clearTimeout(i),r=vf.error,n(e)})}));return new Promise((e,n)=>{Promise.all(t).then(t=>{let r=t.filter(e=>e!==vf.resolved);r.length>0?n(r):e()}).catch(e=>n([e]))})}shutdown(){return this._activeSpanProcessor.shutdown()}}})),xf,Sf=t((()=>{N(),B(),F(),H(),xf=class{constructor(e){P(this,`_exporter`,void 0),P(this,`_shutdownOnce`,void 0),P(this,`_pendingExports`,void 0),this._exporter=e,this._shutdownOnce=new wo(this._shutdown,this),this._pendingExports=new Set}forceFlush(){var e=this;return V(function*(){yield Promise.all(Array.from(e._pendingExports)),e._exporter.forceFlush&&(yield e._exporter.forceFlush())})()}onStart(e,t){}onEnd(e){if(this._shutdownOnce.isCalled||(e.spanContext().traceFlags&k.SAMPLED)===0)return;let t=this._doExport(e).catch(e=>Si(e));this._pendingExports.add(t),t.finally(()=>this._pendingExports.delete(t))}_doExport(e){var t=this;return V(function*(){if(e.resource.asyncAttributesPending){var n,r;yield(n=(r=e.resource).waitForAsyncAttributes)==null?void 0:n.call(r)}let i=yield Oo._export(t._exporter,[e]);if(i.code!==ga.SUCCESS){var a;throw(a=i.error)==null?Error(`SimpleSpanProcessor: span export failed (status ${i})`):a}})()}shutdown(){return this._shutdownOnce.call()}_shutdown(){return this._exporter.shutdown()}}})),Cf=t((()=>{bf(),tf(),B(),F(),Sf(),Td(),Dd(),kd(),jd(),Cd()})),wf,Tf=t((()=>{N(),F(),wf=class{constructor(){P(this,`_enabled`,!1),P(this,`_currentContext`,O)}_bindFunction(e=O,t){let n=this,r=function(...r){return n.with(e,()=>t.apply(this,r))};return Object.defineProperty(r,`length`,{enumerable:!1,configurable:!0,writable:!1,value:t.length}),r}active(){return this._currentContext}bind(e,t){return e===void 0&&(e=this.active()),typeof t==`function`?this._bindFunction(e,t):t}disable(){return this._currentContext=O,this._enabled=!1,this}enable(){return this._enabled?this:(this._enabled=!0,this._currentContext=O,this)}with(e,t,n,...r){let i=this._currentContext;this._currentContext=e||O;try{return t.call(n,...r)}finally{this._currentContext=i}}}}));function Ef(e){if(e!==null){if(e===void 0){let e=new wf;e.enable(),A.setGlobalContextManager(e);return}e.enable(),A.setGlobalContextManager(e)}}function Df(e){if(e!==null){if(e===void 0){Jt.setGlobalPropagator(new va({propagators:[new Ba,new ui]}));return}Jt.setGlobalPropagator(e)}}var Of,kf=t((()=>{Cf(),Tf(),N(),B(),Of=class extends yf{constructor(e={}){super(e)}register(e={}){M.setGlobalTracerProvider(this),Df(e.propagator),Ef(e.contextManager)}}})),J,Af=t((()=>{(function(e){e.CONNECT_END=`connectEnd`,e.CONNECT_START=`connectStart`,e.DECODED_BODY_SIZE=`decodedBodySize`,e.DOM_COMPLETE=`domComplete`,e.DOM_CONTENT_LOADED_EVENT_END=`domContentLoadedEventEnd`,e.DOM_CONTENT_LOADED_EVENT_START=`domContentLoadedEventStart`,e.DOM_INTERACTIVE=`domInteractive`,e.DOMAIN_LOOKUP_END=`domainLookupEnd`,e.DOMAIN_LOOKUP_START=`domainLookupStart`,e.ENCODED_BODY_SIZE=`encodedBodySize`,e.FETCH_START=`fetchStart`,e.LOAD_EVENT_END=`loadEventEnd`,e.LOAD_EVENT_START=`loadEventStart`,e.NAVIGATION_START=`navigationStart`,e.REDIRECT_END=`redirectEnd`,e.REDIRECT_START=`redirectStart`,e.REQUEST_START=`requestStart`,e.RESPONSE_END=`responseEnd`,e.RESPONSE_START=`responseStart`,e.SECURE_CONNECTION_START=`secureConnectionStart`,e.START_TIME=`startTime`,e.UNLOAD_EVENT_END=`unloadEventEnd`,e.UNLOAD_EVENT_START=`unloadEventStart`})(J||(J={}))})),jf,Mf,Nf=t((()=>{jf=`http.response_content_length`,Mf=`http.response_content_length_uncompressed`}));function Pf(){return qf||(qf=document.createElement(`a`)),qf}function Ff(e,t){return t in e}function Y(e,t,n,r=!0){if(Ff(n,t)&&typeof n[t]==`number`&&!(r&&n[t]===0))return e.addEvent(t,n[t])}function If(e,t,n=!1,r,i){if(r===void 0&&(r=t[J.START_TIME]!==0),n||(Y(e,J.FETCH_START,t,r),Y(e,J.DOMAIN_LOOKUP_START,t,r),Y(e,J.DOMAIN_LOOKUP_END,t,r),Y(e,J.CONNECT_START,t,r),Y(e,J.SECURE_CONNECTION_START,t,r),Y(e,J.CONNECT_END,t,r),Y(e,J.REQUEST_START,t,r),Y(e,J.RESPONSE_START,t,r),Y(e,J.RESPONSE_END,t,r)),!i){let n=t[J.ENCODED_BODY_SIZE];n!==void 0&&e.setAttribute(jf,n);let r=t[J.DECODED_BODY_SIZE];r!==void 0&&n!==r&&e.setAttribute(Mf,r)}}function Lf(e){return e.slice().sort((e,t)=>{let n=e[J.FETCH_START],r=t[J.FETCH_START];return n>r?1:n<r?-1:0})}function Rf(){return typeof location<`u`?location.origin:void 0}function zf(e,t,n,r,i=new WeakSet,a){let o=Hf(e);e=o.toString();let s=Vf(e,t,n,r,i,a);if(s.length===0)return{mainRequest:void 0};if(s.length===1)return{mainRequest:s[0]};let c=Lf(s);if(o.origin!==Rf()&&c.length>1){let e=c[0],t=Bf(c,e[J.RESPONSE_END],n),r=e[J.RESPONSE_END];return t[J.FETCH_START]<r&&(t=e,e=void 0),{corsPreFlightRequest:e,mainRequest:t}}else return{mainRequest:s[0]}}function Bf(e,t,n){let r=sa(n),i=sa(aa(t)),a=e[1],o,s=e.length;for(let t=1;t<s;t++){let n=e[t],s=sa(aa(n[J.FETCH_START])),c=r-sa(aa(n[J.RESPONSE_END]));s>=i&&(!o||c<o)&&(o=c,a=n)}return a}function Vf(e,t,n,r,i,a){let o=sa(t),s=sa(n),c=r.filter(t=>{let n=sa(aa(t[J.FETCH_START])),r=sa(aa(t[J.RESPONSE_END]));return t.initiatorType.toLowerCase()===(a||`xmlhttprequest`)&&t.name===e&&n>=o&&r<=s});return c.length>0&&(c=c.filter(e=>!i.has(e))),c}function Hf(e){if(typeof URL==`function`)return new URL(e,typeof document<`u`?document.baseURI:typeof location<`u`?location.href:void 0);let t=Pf();return t.href=e,t}function Uf(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return`/`;let n=Gf(e,t);if(t&&n.indexOf(`@id`)>0)return n;let r=``;return e.parentNode&&(r+=Uf(e.parentNode,t)),r+=n,r}function Wf(e){if(!e.parentNode)return 0;let t=[e.nodeType];e.nodeType===Node.CDATA_SECTION_NODE&&t.push(Node.TEXT_NODE);let n=Array.from(e.parentNode.childNodes);return n=n.filter(n=>{let r=n.localName;return t.indexOf(n.nodeType)>=0&&r===e.localName}),n.length>=1?n.indexOf(e)+1:0}function Gf(e,t){let n=e.nodeType,r=Wf(e),i=``;if(n===Node.ELEMENT_NODE){let n=e.getAttribute(`id`);if(t&&n)return`//*[@id="${n}"]`;i=e.localName}else if(n===Node.TEXT_NODE||n===Node.CDATA_SECTION_NODE)i=`text()`;else if(n===Node.COMMENT_NODE)i=`comment()`;else return``;return i&&r>1?`/${i}[${r}]`:`/${i}`}function Kf(e,t){let n=t||[];return(typeof n==`string`||n instanceof RegExp)&&(n=[n]),Hf(e).origin===Rf()?!0:n.some(t=>yo(e,t))}var qf,Jf=t((()=>{Af(),B(),Nf()})),Yf=t((()=>{kf(),Tf(),Af(),Jf(),Cf()}));Qu(),Yf();var X={actionType:`action.type`,deploymentEnvironmentName:`deployment.environment.name`,browserName:`browser_name`,browserVersion:`browser_version`,cacheHit:`cache_hit`,deviceType:`device_type`,durationBucket:`duration_bucket`,errorType:`error_type`,eventLabel:`event_label`,exceptionFingerprint:`exception.fingerprint`,exceptionMessageShort:`exception.message_short`,exceptionStackTopFrame:`exception.stack_top_frame`,longtaskAttributionScript:`longtask.attribution_script`,longtaskBlockingDuration:`longtask.blocking_duration`,networkEffectiveType:`network.effective_type`,nextHopProtocol:`next_hop_protocol`,result:`result`,serviceName:`service.name`,serviceVersion:`service.version`,osName:`os_name`,sessionHasReplay:`session.has_replay`,sessionId:`session.id`,sessionStartTime:`session.start_time`,spanSubtype:`span_subtype`,spanType:`span_type`,statusClass:`status_class`,targetDomain:`target_domain`,targetLabel:`target_label`,targetPathTemplate:`target_path_template`,targetTag:`target.tag`,targetTextShort:`target.text_short`,targetValue:`target_value`,traceScene:`trace_scene`,transferSize:`transfer_size`,userId:`user.id`,vitalMetric:`vital.metric`,vitalRating:`vital.rating`,vitalValue:`vital.value`,viewId:`view.id`,viewLoadingType:`view.loading_type`,viewUrl:`view.url`,viewUrlPathGroup:`view.url_path_group`};G();var Z={abort:`abort`,error:`error`,success:`success`,timeout:`timeout`,warning:`warning`},Q={action:`action`,custom:`custom`,document:`document`,error:`error`,http:`http`,longtask:`longtask`,resource:`resource`,route:`route`,vital:`vital`},Xf=e=>e<100?`<100ms`:e<500?`100~500ms`:e<2e3?`500ms~2s`:`>2s`,Zf=e=>`${Math.trunc(e/100)}xx`,Qf=e=>e===408||e===504?Z.timeout:typeof e==`number`&&e>=400?Z.error:Z.success,$f=e=>e===408||e===504?`network_timeout`:typeof e!=`number`||e<400?`none`:e>=500?`http_5xx`:`http_4xx`,ep=e=>e===`good`?Z.success:Z.warning,tp=(e,t)=>{if(!e)return{};try{let n=new URL(e,typeof location>`u`?`http://localhost`:location.href),r=t==null?n.pathname:t;return{domain:n.host,label:`${n.host}${r}`,pathTemplate:r}}catch(n){return{label:e,pathTemplate:t==null?e:t}}},$=({duration:e,errorType:t=`none`,eventLabel:n,result:r=Z.success,spanSubtype:i,spanType:a,targetLabel:o,targetValue:s,traceScene:c})=>W(W(W(W(W({[X.spanType]:a,[X.spanSubtype]:i,[X.result]:r,[X.errorType]:t},e===void 0?{}:{[X.durationBucket]:Xf(e)}),n===void 0?{}:{[X.eventLabel]:n}),o===void 0?{}:{[X.targetLabel]:o}),s===void 0?{}:{[X.targetValue]:s}),c===void 0?{}:{[X.traceScene]:c}),np=({duration:e,method:t,statusCode:n,subtype:r,url:i,urlPathTemplate:a})=>{let o=tp(i,a);return W(W(W(W(W({},$({duration:e,errorType:$f(n),eventLabel:`API 调用`,result:Qf(n),spanSubtype:r,spanType:Q.http,targetLabel:o.label,targetValue:n})),t?{"http.request.method":t.toUpperCase()}:{}),o.domain?{[X.targetDomain]:o.domain}:{}),o.pathTemplate?{[X.targetPathTemplate]:o.pathTemplate}:{}),typeof n==`number`?{"http.response.status_code":n,[X.statusClass]:Zf(n)}:{})},rp=({duration:e,initiatorType:t=`other`,responseStatus:n,transferSize:r,url:i,urlPathTemplate:a})=>{var o;let s=tp(i,a),c=typeof n==`number`?Qf(n):Z.success;return W(W(W(W({},$({duration:e,errorType:typeof n==`number`?$f(n):`none`,eventLabel:`静态资源`,result:c,spanSubtype:t,spanType:Q.resource,targetLabel:(o=s.label)==null?i:o,targetValue:r})),s.domain?{[X.targetDomain]:s.domain}:{}),s.pathTemplate?{[X.targetPathTemplate]:s.pathTemplate}:{}),typeof n==`number`?{"http.response.status_code":n,[X.statusClass]:Zf(n)}:{})};G();var ip=[`click`,`submit`,`keydown`],ap=e=>e instanceof Element?e:void 0,op=e=>{var t;if(!e)return;let n=((t=e.textContent)==null?void 0:t.trim())||e.getAttribute(`aria-label`)||e.getAttribute(`title`)||``;return n?n.slice(0,32):void 0},sp=(e={})=>{var t;let n=[],r=(t=e.eventNames)==null?ip:t;return{name:`action`,init(e){if(typeof window>`u`)return;let t={capture:!0,passive:!0},i=t=>{var n;let r=ap(t.target),i=op(r),a=r==null?void 0:r.tagName.toLowerCase();e.startSpan(`action.${t.type}`,W(W(W(W({},e.config.hooks.getPageAttributes()),$({errorType:`none`,eventLabel:`用户操作`,spanSubtype:t.type,spanType:Q.action,targetLabel:(n=i==null?a:i)==null?t.type:n})),{},{[X.actionType]:t.type},i?{[X.targetTextShort]:i}:{}),a?{[X.targetTag]:a}:{})).end()};for(let e of r)window.addEventListener(e,i,t),n.push(()=>window.removeEventListener(e,i,t))},shutdown(){for(;n.length;){var e;(e=n.pop())==null||e()}}}};G();var cp=`body`,lp=3e3,up=.8,dp=[`[data-loading="true"]`,`[aria-busy="true"]`,`.loading`,`.is-loading`,`.spinner`,`.skeleton`,`.bk-loading`],fp=[[.5,.5],[.25,.25],[.75,.25],[.25,.75],[.75,.75]],pp=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>=0?e:t,mp=(e,t)=>typeof e!=`number`||!Number.isFinite(e)?t:Math.max(0,Math.min(1,e)),hp=e=>{if(!e)return``;let t=e.tagName.toLowerCase();return e.id?`${t}#${e.id}`:t},gp=(e,t)=>e?t.some(t=>{try{return e.matches(t)||!!e.closest(t)}catch(e){return!1}}):!1,_p=e=>{if(typeof document>`u`)return()=>{};if(document.readyState===`complete`||document.readyState===`interactive`)return e(),()=>{};let t=()=>{document.removeEventListener(`DOMContentLoaded`,t),e()};return document.addEventListener(`DOMContentLoaded`,t),()=>document.removeEventListener(`DOMContentLoaded`,t)},vp=(e={})=>{var t,n;let r,i,a=!1,o={checkDelay:pp(e.checkDelay,lp),ignoreSelectors:(t=e.ignoreSelectors)==null?[]:t,rootSelector:(n=e.rootSelector)==null?cp:n,threshold:mp(e.threshold,up)};return{name:`blank-screen`,init(e){if(typeof window>`u`||typeof document>`u`)return;let{checkDelay:t,rootSelector:n,threshold:s}=o,c=[...dp,...o.ignoreSelectors],l=e.meter.createCounter(`browser.blank_screen.count`,{description:`Number of suspected blank screen detections`}),u=()=>{try{var t,r;let i=document.querySelector(n),a=0,o=0;for(let[e,t]of fp){let n=document.elementFromPoint(window.innerWidth*e,window.innerHeight*t);if(gp(n,c)){o+=1;continue}(n===i||n===document.body||n===document.documentElement)&&(a+=1)}let u=fp.length-o;if(u===0)return;let d=a/u,f=d>=s,p=hp(document.elementFromPoint(window.innerWidth/2,window.innerHeight/2)),m=W(W({},$({errorType:f?`blank_screen`:`none`,eventLabel:`白屏`,result:f?Z.error:Z.success,spanSubtype:`blank_screen`,spanType:Q.error,targetLabel:n,targetValue:d})),{},{"blank_screen.score":d,"blank_screen.threshold":s,"blank_screen.root":n,"blank_screen.detected":f,"blank_screen.sample_total":fp.length,"blank_screen.sample_valid":u,"blank_screen.sample_loading":o,"blank_screen.center_element":p,"blank_screen.dom_node_count":(t=(r=document.body)==null?void 0:r.getElementsByTagName(`*`).length)==null?0:t});f&&(l.add(1,e.applyRedact({"blank_screen.root":n})),e.startSpan(`browser.blank_screen`,m).end())}catch(t){if(e.config.debug){var i;(i=globalThis.console)==null||i.warn(`[bk-ot][blank-screen] detection failed:`,t)}}};i=_p(()=>{a||(r=window.setTimeout(u,t))})},shutdown(){a=!0,i==null||i(),i=void 0,r!==void 0&&typeof window<`u`&&(window.clearTimeout(r),r=void 0)}}},yp=()=>typeof window>`u`?`http://localhost`:window.location.origin,bp=e=>{try{return new URL(e,yp()).href}catch(t){return e}},xp=e=>e.length>1?e.replace(/\/+$/,``):e,Sp=(e,t)=>{let n=e=>xp(e.replace(/[?#].*$/,``));return n(e)===n(t)},Cp=e=>{try{return new URL(e,yp()).origin===yp()}catch(e){return!1}},wp=(e,t)=>{let n=bp(t);return[e.transport.traces.endpoint,e.transport.metrics.endpoint,e.transport.logs.endpoint].some(e=>Sp(n,bp(e)))},Tp=(e,t)=>wp(e,t),Ep=(e,t)=>Cp(t),Dp,Op=t((()=>{(function(e){e.DOCUMENT_LOAD=`documentLoad`,e.DOCUMENT_FETCH=`documentFetch`,e.RESOURCE_FETCH=`resourceFetch`})(Dp||(Dp={}))})),kp,Ap,jp=t((()=>{kp=`0.62.0`,Ap=`@opentelemetry/instrumentation-document-load`})),Mp,Np,Pp=t((()=>{Mp=`http.url`,Np=`http.user_agent`})),Fp,Ip=t((()=>{(function(e){e.FIRST_PAINT=`firstPaint`,e.FIRST_CONTENTFUL_PAINT=`firstContentfulPaint`})(Fp||(Fp={}))})),Lp,Rp,zp,Bp=t((()=>{B(),Ip(),Lp=()=>{var e;let t={},n=(e=z.getEntriesByType)==null?void 0:e.call(z,`navigation`)[0];if(n)Object.values(J).forEach(e=>{if(Ff(n,e)){let r=n[e];typeof r==`number`&&(t[e]=r)}});else{let e=z.timing;e&&Object.values(J).forEach(n=>{if(Ff(e,n)){let r=e[n];typeof r==`number`&&(t[n]=r)}})}return t},Rp={"first-paint":Fp.FIRST_PAINT,"first-contentful-paint":Fp.FIRST_CONTENTFUL_PAINT},zp=e=>{var t;let n=(t=z.getEntriesByType)==null?void 0:t.call(z,`paint`);n&&n.forEach(({name:t,startTime:n})=>{Ff(Rp,t)&&e.addEvent(Rp[t],n)})}})),Vp,Hp=t((()=>{N(),B(),Yf(),Zi(),Op(),jp(),Pp(),Bp(),F(),Vp=class extends Gu{constructor(e={}){super(Ap,kp,e),P(this,`component`,`document-load`),P(this,`version`,`1`),P(this,`moduleName`,this.component),P(this,`_semconvStability`,void 0),this._semconvStability=Xu(`http`,e==null?void 0:e.semconvStabilityOptIn)}init(){}_onDocumentLoaded(){window.setTimeout(()=>{this._collectPerformance()})}_addResourcesSpans(e){var t;let n=(t=z.getEntriesByType)==null?void 0:t.call(z,`resource`);n&&n.forEach(t=>{this._initResourceSpan(t,e)})}_collectPerformance(){let e=Array.from(document.getElementsByTagName(`meta`)).find(e=>e.getAttribute(`name`)===Ia),t=Lp(),n=e&&e.content||``;A.with(Jt.extract(O,{traceparent:n}),()=>{var e;let n=this._startSpan(Dp.DOCUMENT_LOAD,J.FETCH_START,t);n&&(A.with(M.setSpan(A.active(),n),()=>{let e=this._startSpan(Dp.DOCUMENT_FETCH,J.FETCH_START,t);e&&(this._semconvStability&q.OLD&&e.setAttribute(Mp,location.href),this._semconvStability&q.STABLE&&e.setAttribute(Ki,location.href),A.with(M.setSpan(A.active(),e),()=>{var n;let r=!(this._semconvStability&q.OLD);If(e,t,this.getConfig().ignoreNetworkEvents,void 0,r),this._addCustomAttributesOnSpan(e,(n=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:n.documentFetch),this._endSpan(e,J.RESPONSE_END,t)}))}),this._semconvStability&q.OLD&&(n.setAttribute(Mp,location.href),n.setAttribute(Np,navigator.userAgent)),this._semconvStability&q.STABLE&&(n.setAttribute(Ki,location.href),n.setAttribute(qi,navigator.userAgent)),this._addResourcesSpans(n),this.getConfig().ignoreNetworkEvents||(Y(n,J.FETCH_START,t),Y(n,J.UNLOAD_EVENT_START,t),Y(n,J.UNLOAD_EVENT_END,t),Y(n,J.DOM_INTERACTIVE,t),Y(n,J.DOM_CONTENT_LOADED_EVENT_START,t),Y(n,J.DOM_CONTENT_LOADED_EVENT_END,t),Y(n,J.DOM_COMPLETE,t),Y(n,J.LOAD_EVENT_START,t),Y(n,J.LOAD_EVENT_END,t)),this.getConfig().ignorePerformancePaintEvents||zp(n),this._addCustomAttributesOnSpan(n,(e=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:e.documentLoad),this._endSpan(n,J.LOAD_EVENT_END,t))})}_endSpan(e,t,n){e&&(Ff(n,t)?e.end(n[t]):e.end())}_initResourceSpan(e,t){let n=this._startSpan(Dp.RESOURCE_FETCH,J.FETCH_START,e,t);if(n){var r;this._semconvStability&q.OLD&&n.setAttribute(Mp,e.name),this._semconvStability&q.STABLE&&n.setAttribute(Ki,e.name);let t=!(this._semconvStability&q.OLD);If(n,e,this.getConfig().ignoreNetworkEvents,void 0,t),this._addCustomAttributesOnResourceSpan(n,e,(r=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:r.resourceFetch),this._endSpan(n,J.RESPONSE_END,e)}}_startSpan(e,t,n,r){if(Ff(n,t)&&typeof n[t]==`number`)return this.tracer.startSpan(e,{startTime:n[t]},r?M.setSpan(A.active(),r):void 0)}_waitForPageLoad(){window.document.readyState===`complete`?this._onDocumentLoaded():(this._onDocumentLoaded=this._onDocumentLoaded.bind(this),window.addEventListener(`load`,this._onDocumentLoaded))}_addCustomAttributesOnSpan(e,t){t&&Ju(()=>t(e),e=>{e&&this._diag.error(`addCustomAttributesOnSpan`,e)},!0)}_addCustomAttributesOnResourceSpan(e,t,n){n&&Ju(()=>n(e,t),e=>{e&&this._diag.error(`addCustomAttributesOnResourceSpan`,e)},!0)}enable(){window.removeEventListener(`load`,this._onDocumentLoaded),this._waitForPageLoad()}disable(){window.removeEventListener(`load`,this._onDocumentLoaded)}}})),Up=n({AttributeNames:()=>Dp,DocumentLoadInstrumentation:()=>Vp}),Wp=t((()=>{Hp(),Op()})),Gp,Kp=t((()=>{(function(e){e.COMPONENT=`component`,e.HTTP_STATUS_TEXT=`http.status_text`})(Gp||(Gp={}))})),qp,Jp,Yp,Xp,Zp,Qp,$p,em,tm=t((()=>{qp=`http.host`,Jp=`http.method`,Yp=`http.request.body.size`,Xp=`http.request_content_length_uncompressed`,Zp=`http.scheme`,Qp=`http.status_code`,$p=`http.url`,em=`http.user_agent`}));function nm(...e){if(e[0]instanceof URL||typeof e[0]==`string`){let t=e[1];if(!(t!=null&&t.body))return Promise.resolve();if(t.body instanceof ReadableStream){let{body:e,length:n}=rm(t.body);return t.body=e,n}else return Promise.resolve(am(t.body))}else{let t=e[0];return t!=null&&t.body?t.clone().text().then(e=>om(e)):Promise.resolve()}}function rm(e){if(!e.pipeThrough)return dm.warn(`Platform has ReadableStream but not pipeThrough!`),{body:e,length:Promise.resolve(void 0)};let t=0,n,r=new Promise(e=>{n=e}),i=new TransformStream({start(){},transform(e,n){return V(function*(){let r=yield e;t+=r.byteLength,n.enqueue(e)})()},flush(){n(t)}});return{body:e.pipeThrough(i),length:r}}function im(e){return typeof Document<`u`&&e instanceof Document}function am(e){if(im(e))return new XMLSerializer().serializeToString(document).length;if(typeof e==`string`)return om(e);if(e instanceof Blob)return e.size;if(e instanceof FormData)return sm(e);if(e instanceof URLSearchParams)return om(e.toString());if(e.byteLength!==void 0)return e.byteLength;dm.warn(`unknown body type`)}function om(e){return fm.encode(e).byteLength}function sm(e){let t=0;for(let[n,r]of e.entries())t+=n.length,r instanceof Blob?t+=r.size:t+=r.length;return t}function cm(e){let t=lm(),n=e.toUpperCase();return n in t?n:`_OTHER`}function lm(){return mm===void 0&&(mm=pm),mm}function um(e){let t=Number(e.port||hm[e.protocol]);if(t&&!isNaN(t))return t}var dm,fm,pm,mm,hm,gm=t((()=>{N(),B(),H(),dm=j.createComponentLogger({namespace:`@opentelemetry/opentelemetry-instrumentation-fetch/utils`}),fm=new TextEncoder,pm={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0},hm={"https:":`443`,"http:":`80`}})),_m,vm=t((()=>{_m=`0.217.0`})),ym,bm,xm,Sm=t((()=>{N(),Qu(),B(),Yf(),Kp(),tm(),Zi(),gm(),vm(),F(),ym=300,bm=typeof PerformanceObserver<`u`,xm=class extends Gu{constructor(e={}){super(`@opentelemetry/instrumentation-fetch`,_m,e),P(this,`component`,`fetch`),P(this,`version`,_m),P(this,`moduleName`,this.component),P(this,`_usedResources`,new WeakSet),P(this,`_tasksCount`,0),P(this,`_semconvStability`,void 0),this._semconvStability=Xu(`http`,e==null?void 0:e.semconvStabilityOptIn)}init(){}_addChildSpan(e,t){let n=this.tracer.startSpan(`CORS Preflight`,{startTime:t[J.FETCH_START]},M.setSpan(A.active(),e)),r=!(this._semconvStability&q.OLD);If(n,t,this.getConfig().ignoreNetworkEvents,void 0,r),n.end(t[J.RESPONSE_END])}_addFinalSpanAttributes(e,t){let n=Hf(t.url);if(this._semconvStability&q.OLD&&(e.setAttribute(Qp,t.status),t.statusText!=null&&e.setAttribute(Gp.HTTP_STATUS_TEXT,t.statusText),e.setAttribute(qp,n.host),e.setAttribute(Zp,n.protocol.replace(`:`,``)),typeof navigator<`u`&&e.setAttribute(em,navigator.userAgent)),this._semconvStability&q.STABLE){e.setAttribute(Ri,t.status),e.setAttribute(zi,n.hostname);let r=um(n);r&&e.setAttribute(Bi,r)}}_addHeaders(e,t){if(!Kf(t,this.getConfig().propagateTraceHeaderCorsUrls)){let e={};Jt.inject(A.active(),e),Object.keys(e).length>0&&this._diag.debug(`headers inject skipped due to CORS policy`);return}if(e instanceof Request)Jt.inject(A.active(),e.headers,{set:(e,t,n)=>e.set(t,typeof n==`string`?n:String(n))});else{let t=new Headers(e.headers);Jt.inject(A.active(),t,{set:(e,t,n)=>e.set(t,typeof n==`string`?n:String(n))}),e.headers=t}}_clearResources(){this._tasksCount===0&&this.getConfig().clearTimingResources&&(performance.clearResourceTimings(),this._usedResources=new WeakSet)}_createSpan(e,t={}){if(bo(e,this.getConfig().ignoreUrls)){this._diag.debug(`ignoring span as url matches ignored url`);return}let n=``,r={};if(this._semconvStability&q.OLD){let i=(t.method||`GET`).toUpperCase();n=`HTTP ${i}`,r[Gp.COMPONENT]=this.moduleName,r[Jp]=i,r[$p]=e}if(this._semconvStability&q.STABLE){let i=t.method,a=cm(t.method||`GET`);n||(n=a),r[Ii]=a,a!==i&&(r[Li]=i),r[Ki]=e}return this.tracer.startSpan(n,{kind:St.CLIENT,attributes:r})}_findResourceAndAddNetworkEvents(e,t,n){let r=t.entries;if(!r.length){if(!performance.getEntriesByType)return;r=performance.getEntriesByType(`resource`)}let i=zf(t.spanUrl,t.startTime,n,r,this._usedResources,`fetch`);if(i.mainRequest){let t=i.mainRequest;this._markResourceAsUsed(t);let n=i.corsPreFlightRequest;n&&(this._addChildSpan(e,n),this._markResourceAsUsed(n));let r=!(this._semconvStability&q.OLD);If(e,t,this.getConfig().ignoreNetworkEvents,void 0,r)}}_markResourceAsUsed(e){this._usedResources.add(e)}_endSpan(e,t,n){let r=ra(Date.now()),i=ia();this._addFinalSpanAttributes(e,n),this._semconvStability&q.STABLE&&n.status>=400&&(e.setStatus({code:wt.ERROR}),e.setAttribute(Mi,String(n.status))),setTimeout(()=>{var n;(n=t.observer)==null||n.disconnect(),this._findResourceAndAddNetworkEvents(e,t,i),this._tasksCount--,this._clearResources(),e.end(r)},ym)}_patchConstructor(){return e=>{let t=this;return function(...n){if(!t._isEnabled)return e.apply(this,n);let r=this,i=Hf(n[0]instanceof Request?n[0].url:String(n[0])).href,a;a=n[0]instanceof Request?n[1]==null?n[0]:new Request(n[0],n[1]):n[1]||{};let o=t._createSpan(i,a);if(!o)return e.apply(this,n);let s=t._prepareSpanData(i);t.getConfig().measureRequestSize&&nm(...n).then(e=>{e&&(t._semconvStability&q.OLD&&o.setAttribute(Xp,e),t._semconvStability&q.STABLE&&o.setAttribute(Yp,e))}).catch(e=>{t._diag.warn(`getFetchBodyLength`,e)});function c(e,n){t._applyAttributesAfterFetch(e,a,n),t._endSpan(e,s,{status:n.status||0,statusText:n.message,url:i})}function l(e,n){t._applyAttributesAfterFetch(e,a,n),n.status>=200&&n.status<400?t._endSpan(e,s,n):t._endSpan(e,s,{status:n.status,statusText:n.statusText,url:i})}function u(e,n){try{let t=n.clone().body;if(t){let r=t.getReader(),i=()=>{r.read().then(({done:t})=>{t?l(e,n):i()},t=>{c(e,t)})};i()}else l(e,n)}catch(n){t._diag.error(`Failed to read fetch response body`,n),t._endSpan(e,s,{status:0,url:i})}return n}function d(e,n){try{c(e,n)}catch(r){t._diag.error(`Failed to end span on fetch error`,r),t._endSpan(e,s,{status:n.status||0,url:i})}throw n}return A.with(M.setSpan(A.active(),o),()=>(t._callRequestHook(o,a),t._addHeaders(a,i),t._tasksCount++,e.apply(r,a instanceof Request?[a]:[i,a]).then(u.bind(r,o),d.bind(r,o))))}}}_applyAttributesAfterFetch(e,t,n){let r=this.getConfig().applyCustomAttributesOnSpan;r&&Ju(()=>r(e,t,n),e=>{e&&this._diag.error(`applyCustomAttributesOnSpan`,e)},!0)}_callRequestHook(e,t){let n=this.getConfig().requestHook;n&&Ju(()=>n(e,t),e=>{e&&this._diag.error(`requestHook`,e)},!0)}_prepareSpanData(e){let t=ia(),n=[];if(typeof PerformanceObserver!=`function`)return{entries:n,startTime:t,spanUrl:e};let r=new PerformanceObserver(t=>{t.getEntries().forEach(t=>{t.initiatorType===`fetch`&&t.name===e&&n.push(t)})});return r.observe({entryTypes:[`resource`]}),{entries:n,observer:r,startTime:t,spanUrl:e}}enable(){if(!bm){this._diag.warn(`this instrumentation is intended for web usage only, it does not instrument server-side fetch()`);return}if(!this._isEnabled){if(this._isFetchPatched){this._diag.debug(`fetch constructor already patched`),this._isEnabled=!0;return}try{this._wrap(globalThis,`fetch`,this._patchConstructor()),this._isFetchPatched=!0,this._isEnabled=!0}catch(e){this._diag.warn(`Failed to patch globalThis.fetch; instrumentation will not be enabled. Another script may have locked globalThis.fetch via Object.defineProperty.`,e)}}}disable(){bm&&this._isEnabled&&(this._isEnabled=!1,this._usedResources=new WeakSet)}}})),Cm=n({FetchInstrumentation:()=>xm}),wm=t((()=>{Sm()})),Tm,Em,Dm,Om,km,Am,jm,Mm,Nm=t((()=>{Tm=`http.host`,Em=`http.method`,Dm=`http.request.body.size`,Om=`http.request_content_length_uncompressed`,km=`http.scheme`,Am=`http.status_code`,jm=`http.url`,Mm=`http.user_agent`})),Pm,Fm=t((()=>{(function(e){e.METHOD_OPEN=`open`,e.METHOD_SEND=`send`,e.EVENT_ABORT=`abort`,e.EVENT_ERROR=`error`,e.EVENT_LOAD=`loaded`,e.EVENT_TIMEOUT=`timeout`})(Pm||(Pm={}))}));function Im(e){return typeof Document<`u`&&e instanceof Document}function Lm(e){if(Im(e))return new XMLSerializer().serializeToString(document).length;if(typeof e==`string`)return Rm(e);if(e instanceof Blob)return e.size;if(e instanceof FormData)return zm(e);if(e instanceof URLSearchParams)return Rm(e.toString());if(e.byteLength!==void 0)return e.byteLength;Um.warn(`unknown body type`)}function Rm(e){return Wm.encode(e).byteLength}function zm(e){let t=0;for(let[n,r]of e.entries())t+=n.length,r instanceof Blob?t+=r.size:t+=r.length;return t}function Bm(e){let t=Vm(),n=e.toUpperCase();return n in t?n:`_OTHER`}function Vm(){return Km===void 0&&(Km=Gm),Km}function Hm(e){let t=Number(e.port||qm[e.protocol]);if(t&&!isNaN(t))return t}var Um,Wm,Gm,Km,qm,Jm=t((()=>{N(),B(),Um=j.createComponentLogger({namespace:`@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils`}),Wm=new TextEncoder,Gm={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0},qm={"https:":`443`,"http:":`80`}})),Ym,Xm=t((()=>{Ym=`0.217.0`})),Zm,Qm=t((()=>{(function(e){e.HTTP_STATUS_TEXT=`http.status_text`})(Zm||(Zm={}))})),$m,eh,th=t((()=>{N(),Qu(),B(),Yf(),Zi(),Nm(),Fm(),Jm(),Xm(),Qm(),F(),$m=300,eh=class extends Gu{constructor(e={}){super(`@opentelemetry/instrumentation-xml-http-request`,Ym,e),P(this,`component`,`xml-http-request`),P(this,`version`,Ym),P(this,`moduleName`,this.component),P(this,`_tasksCount`,0),P(this,`_xhrMem`,new WeakMap),P(this,`_usedResources`,new WeakSet),P(this,`_semconvStability`,void 0),this._semconvStability=Xu(`http`,e==null?void 0:e.semconvStabilityOptIn)}init(){}_addHeaders(e,t){let n=Hf(t).href;if(!Kf(n,this.getConfig().propagateTraceHeaderCorsUrls)){let e={};Jt.inject(A.active(),e),Object.keys(e).length>0&&this._diag.debug(`headers inject skipped due to CORS policy`);return}let r={};Jt.inject(A.active(),r),Object.keys(r).forEach(t=>{e.setRequestHeader(t,String(r[t]))})}_addChildSpan(e,t){A.with(M.setSpan(A.active(),e),()=>{let e=this.tracer.startSpan(`CORS Preflight`,{startTime:t[J.FETCH_START]}),n=!(this._semconvStability&q.OLD);If(e,t,this.getConfig().ignoreNetworkEvents,void 0,n),e.end(t[J.RESPONSE_END])})}_addFinalSpanAttributes(e,t,n){if(this._semconvStability&q.OLD){if(t.status!==void 0&&e.setAttribute(Am,t.status),t.statusText!==void 0&&e.setAttribute(Zm.HTTP_STATUS_TEXT,t.statusText),typeof n==`string`){let t=Hf(n);e.setAttribute(Tm,t.host),e.setAttribute(km,t.protocol.replace(`:`,``))}e.setAttribute(Mm,navigator.userAgent)}this._semconvStability&q.STABLE&&t.status&&e.setAttribute(Ri,t.status)}_applyAttributesAfterXHR(e,t){let n=this.getConfig().applyCustomAttributesOnSpan;typeof n==`function`&&Ju(()=>n(e,t),e=>{e&&this._diag.error(`applyCustomAttributesOnSpan`,e)},!0)}_addResourceObserver(e,t){let n=this._xhrMem.get(e);!n||typeof PerformanceObserver!=`function`||typeof PerformanceResourceTiming!=`function`||(n.createdResources={observer:new PerformanceObserver(e=>{let r=e.getEntries(),i=Hf(t);r.forEach(e=>{e.initiatorType===`xmlhttprequest`&&e.name===i.href&&n.createdResources&&n.createdResources.entries.push(e)})}),entries:[]},n.createdResources.observer.observe({entryTypes:[`resource`]}))}_clearResources(){this._tasksCount===0&&this.getConfig().clearTimingResources&&(z.clearResourceTimings(),this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}_findResourceAndAddNetworkEvents(e,t,n,r,i){if(!n||!r||!i||!e.createdResources)return;let a=e.createdResources.entries;(!a||!a.length)&&(a=z.getEntriesByType(`resource`));let o=zf(Hf(n).href,r,i,a,this._usedResources);if(o.mainRequest){let e=o.mainRequest;this._markResourceAsUsed(e);let n=o.corsPreFlightRequest;n&&(this._addChildSpan(t,n),this._markResourceAsUsed(n));let r=!(this._semconvStability&q.OLD);If(t,e,this.getConfig().ignoreNetworkEvents,void 0,r)}}_cleanPreviousSpanInformation(e){let t=this._xhrMem.get(e);if(t){let n=t.callbackToRemoveEvents;n&&n(),this._xhrMem.delete(e)}}_createSpan(e,t,n){let r=Hf(t);if(bo(r.href,this.getConfig().ignoreUrls)){this._diag.debug(`ignoring span as url matches ignored url`);return}let i=``,a={};if(this._semconvStability&q.OLD&&(i=n.toUpperCase(),a[Em]=n,a[jm]=r.toString()),this._semconvStability&q.STABLE){let e=n,t=Bm(n);i||(i=t),a[Ii]=t,t!==e&&(a[Li]=e),a[Ki]=r.toString(),a[zi]=r.hostname;let o=Hm(r);o&&(a[Bi]=o)}let o=this.tracer.startSpan(i,{kind:St.CLIENT,attributes:a});return o.addEvent(Pm.METHOD_OPEN),this._cleanPreviousSpanInformation(e),this._xhrMem.set(e,{span:o,spanUrl:t}),o}_markResourceAsUsed(e){this._usedResources.add(e)}_patchOpen(){return e=>{let t=this;return function(...n){if(!t._isEnabled)return e.apply(this,n);let r=n[0],i=n[1];return t._createSpan(this,i,r),e.apply(this,n)}}}_patchSend(){let e=this;function t(t,n,r,i){let a=n.callbackToRemoveEvents;typeof a==`function`&&a();let{span:o,spanUrl:s,sendStartTime:c}=n;o&&(e._findResourceAndAddNetworkEvents(n,o,s,c,r),o.addEvent(t,i),e._addFinalSpanAttributes(o,n,s),o.end(i),e._tasksCount--),e._clearResources()}function n(n,r,i,a){let o=e._xhrMem.get(r);if(!o)return;if(o.status=r.status,o.statusText=r.statusText,e._xhrMem.delete(r),o.span){let t=o.span;e._applyAttributesAfterXHR(t,r),e._semconvStability&q.STABLE&&(i?a&&(t.setStatus({code:wt.ERROR,message:a}),t.setAttribute(Mi,a)):o.status&&o.status>=400&&(t.setStatus({code:wt.ERROR}),t.setAttribute(Mi,String(o.status))))}let s=ia(),c=Date.now();setTimeout(()=>{t(n,o,s,c)},$m)}function r(){n(Pm.EVENT_ERROR,this,!0,`error`)}function i(){n(Pm.EVENT_ABORT,this,!1)}function a(){n(Pm.EVENT_TIMEOUT,this,!0,`timeout`)}function o(){this.status<299?n(Pm.EVENT_LOAD,this,!1):n(Pm.EVENT_ERROR,this,!1)}function s(t){t.removeEventListener(`abort`,i),t.removeEventListener(`error`,r),t.removeEventListener(`load`,o),t.removeEventListener(`timeout`,a);let n=e._xhrMem.get(t);n&&(n.callbackToRemoveEvents=void 0)}return t=>function(...n){if(!e._isEnabled)return t.apply(this,n);let c=e._xhrMem.get(this);if(!c)return t.apply(this,n);let l=c.span,u=c.spanUrl;if(l&&u){if(e.getConfig().measureRequestSize&&n!=null&&n[0]){let t=n[0],r=Lm(t);r!==void 0&&(e._semconvStability&q.OLD&&l.setAttribute(Om,r),e._semconvStability&q.STABLE&&l.setAttribute(Dm,r))}A.with(M.setSpan(A.active(),l),()=>{e._tasksCount++,c.sendStartTime=ia(),l.addEvent(Pm.METHOD_SEND),this.addEventListener(`abort`,i),this.addEventListener(`error`,r),this.addEventListener(`load`,o),this.addEventListener(`timeout`,a),c.callbackToRemoveEvents=()=>{s(this),c.createdResources&&c.createdResources.observer.disconnect()},e._addHeaders(this,u),e._addResourceObserver(this,u)})}return t.apply(this,n)}}enable(){if(!this._isEnabled){if(this._isXhrPatched){this._diag.debug(`reactivating existing patch on`,this.moduleName,this.version),this._isEnabled=!0;return}try{this._diag.debug(`applying patch to`,this.moduleName,this.version),this._wrap(XMLHttpRequest.prototype,`open`,this._patchOpen()),this._wrap(XMLHttpRequest.prototype,`send`,this._patchSend()),this._isXhrPatched=!0,this._isEnabled=!0}catch(e){this._unwrap(XMLHttpRequest.prototype,`open`),this._unwrap(XMLHttpRequest.prototype,`send`),this._diag.warn(`Failed to patch globalThis.XMLHttpRequest; instrumentation will not be enabled. Another script may have locked globalThis.XMLHttpRequest via Object.defineProperty.`,e)}}}disable(){this._isEnabled&&(this._isEnabled=!1,this._tasksCount=0,this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}}})),nh=n({XMLHttpRequestInstrumentation:()=>eh}),rh=t((()=>{th()})),ih,ah=t((()=>{(function(e){e.EVENT_TYPE=`event_type`,e.TARGET_ELEMENT=`target_element`,e.TARGET_XPATH=`target_xpath`,e.HTTP_URL=`http.url`})(ih||(ih={}))})),oh,sh,ch=t((()=>{oh=`0.61.0`,sh=`@opentelemetry/instrumentation-user-interaction`}));function lh(){return!1}var uh,dh,fh,ph,mh=t((()=>{Qu(),N(),B(),Yf(),ah(),ch(),F(),uh=`OT_ZONE_CONTEXT`,dh=`Navigation:`,fh=[`click`],ph=class extends Gu{constructor(e={}){var t;super(sh,oh,e),P(this,`version`,oh),P(this,`moduleName`,`user-interaction`),P(this,`_spansData`,new WeakMap),P(this,`_wrappedListeners`,new WeakMap),P(this,`_eventsSpanMap`,new WeakMap),P(this,`_eventNames`,void 0),P(this,`_shouldPreventSpanCreation`,void 0),this._eventNames=new Set((t=e==null?void 0:e.eventNames)==null?fh:t),this._shouldPreventSpanCreation=typeof(e==null?void 0:e.shouldPreventSpanCreation)==`function`?e.shouldPreventSpanCreation:lh}init(){}_checkForTimeout(e,t){let n=this._spansData.get(t);n&&(e.source===`setTimeout`?n.hrTimeLastTimeout=ia():e.source!==`Promise.then`&&e.source!==`setTimeout`&&(n.hrTimeLastTimeout=void 0))}_allowEventName(e){return this._eventNames.has(e)}_createSpan(e,t,n){if(!this._isEnabled||!(e instanceof HTMLElement)||!e.getAttribute||e.hasAttribute(`disabled`)||!this._allowEventName(t))return;let r=Uf(e,!0);try{let i=this.tracer.startSpan(t,{attributes:{[ih.EVENT_TYPE]:t,[ih.TARGET_ELEMENT]:e.tagName,[ih.TARGET_XPATH]:r,[ih.HTTP_URL]:window.location.href}},n?M.setSpan(A.active(),n):void 0);return this._shouldPreventSpanCreation(t,e,i)===!0?void 0:(this._spansData.set(i,{taskCount:0}),i)}catch(e){this._diag.error(`failed to start create new user interaction span`,e)}}_decrementTask(e){let t=this._spansData.get(e);t&&(t.taskCount--,t.taskCount===0&&this._tryToEndSpan(e,t.hrTimeLastTimeout))}_getCurrentSpan(e){let t=e.get(uh);return t&&M.getSpan(t)}_incrementTask(e){let t=this._spansData.get(e);t&&t.taskCount++}addPatchedListener(e,t,n,r){let i=this._wrappedListeners.get(n);i||(i=new Map,this._wrappedListeners.set(n,i));let a=i.get(t);return a||(a=new Map,i.set(t,a)),a.has(e)?!1:(a.set(e,r),!0)}removePatchedListener(e,t,n){let r=this._wrappedListeners.get(n);if(!r)return;let i=r.get(t);if(!i)return;let a=i.get(e);return a&&(i.delete(e),i.size===0&&(r.delete(t),r.size===0&&this._wrappedListeners.delete(n))),a}_invokeListener(e,t,n){return typeof e==`function`?e.apply(t,n):e.handleEvent(n[0])}_patchAddEventListener(){let e=this;return t=>function(n,r,i){if(!r)return t.call(this,n,r,i);let a=i&&typeof i==`object`&&i.once,o=function(...t){let i,o=t[0],s=o==null?void 0:o.target;o&&(i=e._eventsSpanMap.get(o)),a&&e.removePatchedListener(this,n,r);let c=e._createSpan(s,n,i);return c?(o&&e._eventsSpanMap.set(o,c),A.with(M.setSpan(A.active(),c),()=>{let n=e._invokeListener(r,this,t);return c.end(),n})):e._invokeListener(r,this,t)};if(e.addPatchedListener(this,n,r,o))return t.call(this,n,o,i)}}_patchRemoveEventListener(){let e=this;return t=>function(n,r,i){let a=e.removePatchedListener(this,n,r);return a?t.call(this,n,a,i):t.call(this,n,r,i)}}_getPatchableEventTargets(){return window.EventTarget?[EventTarget.prototype]:[Node.prototype,Window.prototype]}_patchHistoryApi(){this._isEnabled&&(this._wrap(history,`replaceState`,this._patchHistoryMethod()),this._wrap(history,`pushState`,this._patchHistoryMethod()),this._wrap(history,`back`,this._patchHistoryMethod()),this._wrap(history,`forward`,this._patchHistoryMethod()),this._wrap(history,`go`,this._patchHistoryMethod()))}_patchHistoryMethod(){let e=this;return t=>function(...n){if(!e._isEnabled)return t.apply(this,n);let r=`${location.pathname}${location.hash}${location.search}`,i=t.apply(this,n),a=`${location.pathname}${location.hash}${location.search}`;return r!==a&&e._updateInteractionName(a),i}}_updateInteractionName(e){let t=M.getSpan(A.active());t&&typeof t.updateName==`function`&&t.updateName(`${dh} ${e}`)}_patchZoneCancelTask(){let e=this;return t=>function(n){let r=Zone.current,i=e._getCurrentSpan(r);return i&&e._shouldCountTask(n,r)&&e._decrementTask(i),t.call(this,n)}}_patchZoneScheduleTask(){let e=this;return t=>function(n){let r=Zone.current,i=e._getCurrentSpan(r);return i&&e._shouldCountTask(n,r)&&(e._incrementTask(i),e._checkForTimeout(n,i)),t.call(this,n)}}_patchZoneRunTask(){let e=this;return t=>function(n,r,i){let a=Array.isArray(i)&&i[0]instanceof Event?i[0]:void 0,o=a==null?void 0:a.target,s,c=this;if(o){if(s=e._createSpan(o,n.eventName),s)return e._incrementTask(s),c.run(()=>{try{return A.with(M.setSpan(A.active(),s),()=>{let e=Zone.current;return n._zone=e,t.call(e,n,r,i)})}finally{e._decrementTask(s)}})}else s=e._getCurrentSpan(c);try{return t.call(c,n,r,i)}finally{s&&e._shouldCountTask(n,c)&&e._decrementTask(s)}}}_shouldCountTask(e,t){if(e._zone&&(t=e._zone),!t||!e.data||e.data.isPeriodic)return!1;let n=this._getCurrentSpan(t);return!n||!this._spansData.get(n)?!1:e.type===`macroTask`||e.type===`microTask`}_tryToEndSpan(e,t){e&&this._spansData.get(e)&&(e.end(t),this._spansData.delete(e))}enable(){if(this._isEnabled||(this._isEnabled=!0,typeof this._zonePatched==`boolean`))return;let e=this._getZoneWithPrototype();this._diag.debug(`applying patch to`,this.moduleName,this.version,`zone:`,!!e),e?(this._zonePatched=!0,this._wrap(e.prototype,`runTask`,this._patchZoneRunTask()),this._wrap(e.prototype,`scheduleTask`,this._patchZoneScheduleTask()),this._wrap(e.prototype,`cancelTask`,this._patchZoneCancelTask())):(this._zonePatched=!1,this._getPatchableEventTargets().forEach(e=>{this._wrap(e,`addEventListener`,this._patchAddEventListener()),this._wrap(e,`removeEventListener`,this._patchRemoveEventListener())})),this._patchHistoryApi()}disable(){this._isEnabled&&(this._isEnabled=!1)}_getZoneWithPrototype(){return window.Zone}}})),hh=n({AttributeNames:()=>ih,UserInteractionInstrumentation:()=>ph}),gh=t((()=>{mh(),ah()}));Qu(),G(),H();var _h=[`http.url`,`url.full`],vh=[`http.status_code`,`http.response.status_code`],yh=[`http.method`,`http.request.method`],bh=e=>({test:e}),xh=(e,t,n)=>{var r;t.setAttributes(e.applyRedact(e.config.hooks.getPageAttributes()));let i;for(let n of _h){var a;let r=(a=t.attributes)==null?void 0:a[n];if(typeof r==`string`){let a=e.applyRedact({[n]:e.config.hooks.redactUrl(r)})[n];typeof a==`string`&&(i=a,t.setAttribute(n,a))}}let o=vh.map(e=>{var n;return(n=t.attributes)==null?void 0:n[e]}).find(e=>typeof e==`number`),s=yh.map(e=>{var n;return(n=t.attributes)==null?void 0:n[e]}).find(e=>typeof e==`string`),c=(r=i)==null?_h.map(e=>{var n;return(n=t.attributes)==null?void 0:n[e]}).find(e=>typeof e==`string`):r;t.setAttributes(e.applyRedact(np({method:s,statusCode:o,subtype:n,url:c,urlPathTemplate:c?e.config.hooks.getViewPathGroup(c):void 0})))},Sh=(e,t,n)=>{t.setAttributes(e.applyRedact(W(W({},e.config.hooks.getPageAttributes()),$({errorType:`none`,eventLabel:`文档加载`,spanSubtype:n,spanType:Q.document,targetLabel:e.config.hooks.getViewPathGroup(typeof location>`u`?``:location.href),traceScene:`page_load`}))))},Ch=(e,t,n)=>{let r=e.config.hooks.redactUrl(n.name);t.setAttributes(e.applyRedact(W(W(W({},e.config.hooks.getPageAttributes()),rp({duration:n.duration,initiatorType:n.initiatorType||`other`,responseStatus:n.responseStatus,transferSize:n.transferSize,url:r,urlPathTemplate:e.config.hooks.getViewPathGroup(n.name)})),{},{"url.full":r})))},wh=(e={})=>{var t,n,r,i;let a=[],o={documentLoad:(t=e.documentLoad)==null?!0:t,fetch:(n=e.fetch)==null?!0:n,xhr:(r=e.xhr)==null?!0:r,userInteraction:(i=e.userInteraction)==null?!0:i};return{name:`official-instrumentations`,enabled:!!(o.documentLoad||o.fetch||o.xhr||o.userInteraction),init(e){return V(function*(){let t=[bh(t=>Tp(e.config,t))],n=[bh(t=>Ep(e.config,t))],[r,i,s,c]=yield Promise.all([o.documentLoad?Promise.resolve().then(()=>(Wp(),Up)):Promise.resolve(null),o.fetch?Promise.resolve().then(()=>(wm(),Cm)):Promise.resolve(null),o.xhr?Promise.resolve().then(()=>(rh(),nh)):Promise.resolve(null),o.userInteraction?Promise.resolve().then(()=>(gh(),hh)):Promise.resolve(null)]);if(r&&a.push(new r.DocumentLoadInstrumentation({semconvStabilityOptIn:`http`,applyCustomAttributesOnSpan:{documentLoad:t=>Sh(e,t,`navigate`),documentFetch:t=>Sh(e,t,`document_fetch`),resourceFetch:(t,n)=>Ch(e,t,n)}})),i&&a.push(new i.FetchInstrumentation({applyCustomAttributesOnSpan:t=>xh(e,t,`fetch`),ignoreUrls:t,propagateTraceHeaderCorsUrls:n,semconvStabilityOptIn:`http`,ignoreNetworkEvents:!1})),s&&a.push(new s.XMLHttpRequestInstrumentation({applyCustomAttributesOnSpan:t=>xh(e,t,`xhr`),ignoreUrls:t,propagateTraceHeaderCorsUrls:n,semconvStabilityOptIn:`http`,ignoreNetworkEvents:!1})),c){let e=o.userInteraction!==null&&typeof o.userInteraction==`object`?{eventNames:o.userInteraction.eventNames}:void 0;a.push(new c.UserInteractionInstrumentation(e))}Pu({instrumentations:a})})()},shutdown(){for(;a.length;){var e,t;(e=a.pop())==null||(t=e.disable)==null||t.call(e)}}}},Th=e=>{let t=5381;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);return(t>>>0).toString(36)},Eh=(e,t)=>{let n=new Map,r=0,i=t=>{if(!(t-r<e)){r=t;for(let[r,i]of n)t-i.windowStart>e&&n.delete(r)}};return{allow(r){let a=Date.now();i(a);let o=n.get(r);return!o||a-o.windowStart>e?(n.set(r,{count:1,windowStart:a}),{allowed:!0,count:1}):(o.count+=1,{allowed:o.count<=t,count:o.count})}}};G();var Dh=6e4,Oh=5,kh=/^https?:|^\/\//i,Ah=(e,t)=>{if(t)return kh.test(t)?e(t):t},jh=()=>{let e;return{name:`csp-violation`,init(t){if(typeof window>`u`||typeof document>`u`)return;let n=Eh(Dh,Oh),r=e=>{let r=Th(`${e.violatedDirective}|${e.blockedURI}|${e.sourceFile}|${e.lineNumber}`),i=n.allow(r);if(!i.allowed)return;let a=Ah(t.config.hooks.redactUrl,e.blockedURI),o=e.sourceFile?t.config.hooks.redactUrl(e.sourceFile):void 0,s=i.count===1;t.startSpan(`csp.violation`,W(W(W({},t.config.hooks.getPageAttributes()),$({errorType:`csp`,eventLabel:`CSP 错误`,result:Z.error,spanSubtype:`csp`,spanType:Q.error,targetLabel:a==null?e.effectiveDirective:a,targetValue:e.statusCode})),{},{"csp.blocked_uri":a,"csp.violated_directive":e.violatedDirective,"csp.effective_directive":e.effectiveDirective,"csp.disposition":e.disposition,"csp.source_file":o,"csp.line_number":e.lineNumber,"csp.column_number":e.columnNumber,"csp.status_code":e.statusCode,"csp.fingerprint":r,"csp.window_count":i.count,[X.exceptionFingerprint]:r,"error.source":`csp`},s?{"csp.original_policy":e.originalPolicy}:{})).end()};document.addEventListener(`securitypolicyviolation`,r),e=()=>document.removeEventListener(`securitypolicyviolation`,r)},shutdown(){e==null||e(),e=void 0}}},Mh=e=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;G();var Nh=`BK_RUM_DEVICE_ID`,Ph=250,Fh=()=>navigator.connection,Ih=()=>navigator.userAgentData,Lh=e=>{for(let[t,n]of[[`Edge`,/Edg\/([\d.]+)/],[`Chrome`,/Chrome\/([\d.]+)/],[`Firefox`,/Firefox\/([\d.]+)/],[`Safari`,/Version\/([\d.]+).*Safari/]]){let r=e.match(n);if(r!=null&&r[1])return{name:t,version:r[1].split(`.`)[0]}}return{name:`Other`,version:void 0}},Rh=(e,t)=>{let n=`${t==null?``:t} ${e}`;return/iphone|ipad|ipod/i.test(n)?`iOS`:/android/i.test(n)?`Android`:/mac/i.test(n)?`macOS`:/win/i.test(n)?`Windows`:/linux/i.test(n)?`Linux`:`Other`},zh=e=>{let t=null;try{t=window.localStorage.getItem(e)}catch(e){}if(t)return t;let n=Mh(`device`);try{window.localStorage.setItem(e,n)}catch(e){}return n},Bh=()=>{var e,t;return typeof window>`u`?{}:{"browser.viewport.width":window.innerWidth,"browser.viewport.height":window.innerHeight,"browser.screen.width":(e=window.screen)==null?void 0:e.width,"browser.screen.height":(t=window.screen)==null?void 0:t.height}},Vh=()=>{let e=Fh();return e?{"network.effective_type":e.effectiveType,"network.connection_type":e.type,"network.downlink":e.downlink,"network.rtt":e.rtt,"network.save_data":e.saveData}:{}},Hh=()=>{if(typeof navigator>`u`)return{};let e=Ih(),t=navigator.userAgent,n=Lh(t),r=Rh(t,e==null?void 0:e.platform),i=e!=null&&e.mobile||/mobi|android|iphone|ipad|ipod/i.test(t)?`mobile`:`desktop`;return{"device.memory":navigator.deviceMemory,"device.cpu_cores":navigator.hardwareConcurrency,"device.platform":e==null?void 0:e.platform,"device.mobile":e==null?void 0:e.mobile,[X.browserName]:n.name,[X.browserVersion]:n.version,[X.deviceType]:i,[X.osName]:r,"user_agent.name":n.name,"user_agent.version":n.version,"user_agent.os.name":r}},Uh=(e,t)=>{let n;return()=>{n!==void 0&&window.clearTimeout(n),n=window.setTimeout(()=>{n=void 0,e()},t)}},Wh=(e={})=>{var t;let n=[],r=(t=e.storageKey)==null?Nh:t;return{name:`device`,init(e){let t=typeof window>`u`?Mh(`device`):zh(r);if(e.setRuntimeAttributes(W(W(W({"device.id":t},Hh()),Bh()),Vh())),typeof window>`u`)return;let i=Uh(()=>{e.setRuntimeAttributes(Bh())},Ph);window.addEventListener(`resize`,i),window.addEventListener(`orientationchange`,i),n.push(()=>window.removeEventListener(`resize`,i),()=>window.removeEventListener(`orientationchange`,i));let a=Fh();if(a&&typeof a.addEventListener==`function`){let t=()=>{e.setRuntimeAttributes(Vh())};a.addEventListener(`change`,t),n.push(()=>{var e;(e=a.removeEventListener)==null||e.call(a,`change`,t)})}},shutdown(){for(;n.length;){var e;(e=n.pop())==null||e()}}}};N(),G();var Gh=6e4,Kh=5,qh=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>0?e:t,Jh=e=>{if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch(t){return String(e)}},Yh=e=>{var t;return e instanceof Error?(t=e.stack)==null?``:t:``},Xh=e=>e.slice(0,80),Zh=e=>{var t,n;return(t=(n=e.split(`
12
- `).find(e=>e.trim().startsWith(`at `)))==null?void 0:n.trim())==null?``:t},Qh=e=>e===`unhandledrejection`?`promise`:e===`resource`?`resource_load`:`js`,$h=({context:e,error:t,exceptionType:n,extra:r={},source:i,spanName:a,throttle:o})=>{let s=Jh(t),c=Yh(t),l=Th(`${i}|${s}|${c.slice(0,256)}`),u=o.allow(l);if(!u.allowed)return;let d=t instanceof Error?t:{message:s,name:n==null?i:n},f=W(W(W(W({},e.config.hooks.getPageAttributes()),e.config.hooks.getErrorAttributes()),$({errorType:Qh(i),eventLabel:`错误`,result:Z.error,spanSubtype:Qh(i),spanType:Q.error,targetLabel:t instanceof Error?t.name:n==null?i:n})),{},{"exception.message":s,[X.exceptionMessageShort]:Xh(s),"exception.stacktrace":c,[X.exceptionStackTopFrame]:Zh(c),"exception.type":t instanceof Error?t.name:n==null?i:n,[X.exceptionFingerprint]:l,"error.handled":!1,"error.source":i,"error.window_count":u.count},r),p=e.startSpan(a,f);p.recordException(d),p.setStatus({code:wt.ERROR,message:s}),p.end()},eg=(e={})=>{let t=[],n=qh(e.windowMs,Gh),r=qh(e.maxPerWindow,Kh);return{name:`error`,init(e){if(typeof window>`u`)return;let i=Eh(n,r),a=t=>{var n;let r=!t.error&&!t.filename&&t.message===`Script error.`;$h({context:e,throttle:i,spanName:`browser.error`,source:`window.error`,error:(n=t.error)==null?t.message:n,extra:W({"code.filepath":t.filename,"code.lineno":t.lineno,"code.column":t.colno},r?{"error.cross_origin":!0}:{})})},o=t=>{$h({context:e,throttle:i,spanName:`browser.unhandledrejection`,source:`unhandledrejection`,error:t.reason,exceptionType:t.reason instanceof Error?t.reason.name:`UnhandledRejection`})},s=t=>{if(t instanceof ErrorEvent)return;let n=t.target;if(!(n instanceof Element))return;let r=n,a=r.src||r.href||n.currentSrc||``;$h({context:e,throttle:i,spanName:`browser.resource_error`,source:`resource`,error:Error(`Resource load failed: ${n.tagName.toLowerCase()} ${a}`),exceptionType:`ResourceError`,extra:{"url.full":e.config.hooks.redactUrl(a),"html.tag":n.tagName}})};window.addEventListener(`error`,a),window.addEventListener(`unhandledrejection`,o),window.addEventListener(`error`,s,!0),t.push(()=>window.removeEventListener(`error`,a),()=>window.removeEventListener(`unhandledrejection`,o),()=>window.removeEventListener(`error`,s,!0))},shutdown(){for(;t.length;){var e;(e=t.pop())==null||e()}}}};bn(),H(),G();var tg=10*1024,ng=10,rg=e=>e.body,ig=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>0?e:t,ag=new WeakMap,og=(e,t)=>e.length<=t?{body:e,truncated:!1}:{body:e.slice(0,t),truncated:!0},sg=(e,t)=>{if(!e)return;if(e instanceof Headers)return e.get(t)||void 0;let n=t.toLowerCase();if(Array.isArray(e)){var r;return(r=e.find(([e])=>e.toLowerCase()===n))==null?void 0:r[1]}let i=Object.keys(e).find(e=>e.toLowerCase()===n);return i?e[i]:void 0},cg=e=>{let t={};return e.forEach((e,n)=>{t[n]=e instanceof File?`[File name=${e.name} type=${e.type||`unknown`} size=${e.size}]`:e}),JSON.stringify(t)},lg=function(){var e=V(function*(e){return e==null?``:typeof e==`string`?e:e instanceof URLSearchParams?e.toString():e instanceof FormData?cg(e):e instanceof Blob?e.text():e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new TextDecoder().decode(e):e instanceof Document?new XMLSerializer().serializeToString(e):String(e)});return function(t){return e.apply(this,arguments)}}(),ug=function(){var e=V(function*(e,t,n){let r=yield lg(e);if(r)return W(W({},og(r,t)),{},{contentType:n})});return function(t,n,r){return e.apply(this,arguments)}}(),dg=function(){var e=V(function*(e,t,n){try{return yield ug(e,t,n)}catch(e){return}});return function(t,n,r){return e.apply(this,arguments)}}(),fg=e=>e instanceof Request?e.url:String(e),pg=(e,t)=>t!=null&&t.method?t.method:e instanceof Request?e.method:`GET`,mg=(e,t,n)=>t!=null&&t.body?()=>dg(t.body,n,sg(t.headers,`content-type`)):(e instanceof Request,()=>Promise.resolve(void 0)),hg=function(){var e=V(function*(e,t){try{let n=e.headers.get(`content-type`)||void 0,r=e.headers.get(`content-length`);if(r){let e=Number(r);if(Number.isFinite(e)&&e>t*ng)return{body:``,contentType:n,truncated:!0}}let i=e.clone();return dg(i.body?yield i.text():``,t,n)}catch(e){return}});return function(t,n){return e.apply(this,arguments)}}(),gg=(e,t)=>{if(e.responseType===``||e.responseType===`text`)return W(W({},og(e.responseText||``,t)),{},{contentType:e.getResponseHeader(`content-type`)||void 0});if(e.responseType===`json`)return W(W({},og(JSON.stringify(e.response),t)),{},{contentType:e.getResponseHeader(`content-type`)||void 0})},_g=(e,t,n)=>{if(n)return e.redact(W(W({},t),{},{body:n.body,truncated:n.truncated}))},vg=({config:e,context:t,duration:n,error:r,method:i,request:a,response:o,status:s,subtype:c,url:l})=>{let u=!!r||typeof s==`number`&&s>=400,d=i.toUpperCase(),f=u?_g(e,{contentType:a==null?void 0:a.contentType,method:d,status:s,type:`request`,url:l},a):void 0,p=u?_g(e,{contentType:o==null?void 0:o.contentType,method:d,status:s,type:`response`,url:l},o):void 0,m=W(W(W({},t.config.hooks.getPageAttributes()),np({duration:n,method:d,statusCode:s,subtype:c,url:t.config.hooks.redactUrl(l),urlPathTemplate:t.config.hooks.getViewPathGroup(l)})),{},{"http.duration":n,"http.request.method":d,"url.full":t.config.hooks.redactUrl(l)});if(typeof s==`number`&&(m[`http.response.status_code`]=s),f!=null&&(m[`http.request.body`]=f),p!=null&&(m[`http.response.body`]=p),u){var h,g;m[`http_body.request.truncated`]=(h=a==null?void 0:a.truncated)==null?!1:h,m[`http_body.response.truncated`]=(g=o==null?void 0:o.truncated)==null?!1:g}if(r instanceof Error){var _;m[`exception.message`]=r.message,m[`exception.type`]=r.name,m[`exception.stacktrace`]=(_=r.stack)==null?``:_}t.emitLog({severityNumber:u?en.ERROR:en.INFO,severityText:u?`ERROR`:`INFO`,body:u?`HTTP request completed with error`:`HTTP request completed`,attributes:m})},yg=(e={})=>{var t;let n=[],r={maxBodySize:ig(e.maxBodySize,tg),redact:(t=e.redact)==null?rg:t};return{name:`http-body`,init(e){if(typeof window>`u`)return;let{maxBodySize:t}=r,i=window.fetch;if(typeof i==`function`){let a=function(){var n=V(function*(n,a){let o=fg(n);if(Tp(e.config,o))return i(n,a);let s=pg(n,a),c=mg(n,a,t),l=performance.now();try{let u=yield i(n,a),d=performance.now()-l,f=u.status>=400;return vg({config:r,context:e,duration:d,method:s,request:f?yield c():void 0,response:f?yield hg(u,t):void 0,status:u.status,subtype:`fetch`,url:o}),u}catch(t){let n=yield c();throw vg({config:r,context:e,duration:performance.now()-l,error:t,method:s,request:n,subtype:`fetch`,url:o}),t}});return function(e,t){return n.apply(this,arguments)}}();window.fetch=a,n.push(()=>{window.fetch===a&&(window.fetch=i)})}let a=XMLHttpRequest.prototype.open,o=XMLHttpRequest.prototype.send,s=XMLHttpRequest.prototype.setRequestHeader,c=function(e,t,...n){var r;return ag.set(this,{method:e,startTime:performance.now(),url:String(t)}),a.call(this,e,t,(r=n[0])==null?!0:r,n[1],n[2])},l=function(e,t){let n=ag.get(this);if(n){var r;let i=e.toLowerCase(),a=(r=n.requestHeaders)==null?{}:r,o=a[i];a[i]=o?`${o}, ${t}`:t,n.requestHeaders=a}return s.call(this,e,t)},u=function(n){var i=this;let a=ag.get(this);if(a){var s;a.requestBody=n,a.requestContentType=(s=a.requestHeaders)==null?void 0:s[`content-type`]}return this.addEventListener(`abort`,()=>{let e=ag.get(this);e&&(e.aborted=!0)},{once:!0}),this.addEventListener(`error`,()=>{let e=ag.get(this);e&&(e.networkError=!0)},{once:!0}),this.addEventListener(`loadend`,()=>{V(function*(){let n=ag.get(i);if(!n||Tp(e.config,n.url)||n.aborted)return;let a=n.networkError||i.status>=400,o=a?gg(i,t):void 0,s=a?yield dg(n.requestBody,t,n.requestContentType):void 0;vg({config:r,context:e,duration:performance.now()-n.startTime,error:n.networkError?Error(`XHR network error`):void 0,method:n.method,request:s,response:o,status:i.status,subtype:`xhr`,url:n.url})})()},{once:!0}),o.call(this,n)};XMLHttpRequest.prototype.open=c,XMLHttpRequest.prototype.setRequestHeader=l,XMLHttpRequest.prototype.send=u,n.push(()=>{XMLHttpRequest.prototype.open===c&&(XMLHttpRequest.prototype.open=a),XMLHttpRequest.prototype.setRequestHeader===l&&(XMLHttpRequest.prototype.setRequestHeader=s),XMLHttpRequest.prototype.send===u&&(XMLHttpRequest.prototype.send=o)})},shutdown(){for(;n.length;){var e;(e=n.pop())==null||e()}}}};G();var bg=50,xg=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>=0?e:t,Sg=(e={})=>{let t,n=xg(e.threshold,bg);return{name:`long-task`,init(e){var r;if(typeof PerformanceObserver>`u`||!((r=PerformanceObserver.supportedEntryTypes)!=null&&r.includes(`longtask`)))return;let i=e.meter.createCounter(`browser.long_task.count`,{description:`Number of long tasks observed (duration >= threshold)`}),a=e.meter.createHistogram(`browser.long_task.duration`,{unit:`ms`,description:`Duration of long tasks`});try{t=new PerformanceObserver(t=>{let r=e.applyRedact(W(W({},e.config.hooks.getPageAttributes()),e.config.hooks.getMetricAttributes()));for(let h of t.getEntries()){var o,s,c,l,u,d,f,p,m;if(h.duration<n)continue;let t=(o=h.attribution)==null?void 0:o[0],g=W(W({},r),{},{[X.longtaskAttributionScript]:(s=(c=t==null?void 0:t.containerSrc)==null?t==null?void 0:t.name:c)==null?`unknown`:s}),_=h.duration>100?Z.warning:Z.success;e.startSpan(`browser.long_task`,W(W(W({},r),$({duration:h.duration,errorType:_===Z.warning?`longtask_blocking`:`none`,eventLabel:`长任务`,result:_,spanSubtype:(l=t==null?void 0:t.name)==null?`unknown`:l,spanType:Q.longtask,targetLabel:(u=(d=(f=t==null?void 0:t.containerSrc)==null?t==null?void 0:t.containerName:f)==null?t==null?void 0:t.name:d)==null?`unknown`:u,targetValue:h.duration})),{},{[X.longtaskBlockingDuration]:h.duration,[X.longtaskAttributionScript]:(p=(m=t==null?void 0:t.containerSrc)==null?t==null?void 0:t.name:m)==null?`unknown`:p}),{startTime:performance.timeOrigin+h.startTime}).end(performance.timeOrigin+h.startTime+h.duration),i.add(1,g),a.record(h.duration,g)}}),t.observe({type:`longtask`,buffered:!0})}catch(e){t=void 0}},shutdown(){t==null||t.disconnect(),t=void 0}}},Cg=new Set,wg=``,Tg,Eg,Dg=!1,Og=()=>typeof location>`u`?``:location.href,kg=(e,t)=>{let n=Og();wg=n;let r={fromUrl:t,source:e,toUrl:n};for(let e of Array.from(Cg))e(r)},Ag=()=>{kg(`popstate`,wg||Og())},jg=()=>{kg(`hashchange`,wg||Og())},Mg=()=>{Dg||typeof window>`u`||typeof history>`u`||(Dg=!0,wg=Og(),Tg=history.pushState,Eg=history.replaceState,history.pushState=function(e,t,n){let r=wg||Og(),i=Tg==null?void 0:Tg.apply(this,[e,t,n]);return kg(`pushState`,r),i},history.replaceState=function(e,t,n){let r=wg||Og(),i=Eg==null?void 0:Eg.apply(this,[e,t,n]);return kg(`replaceState`,r),i},window.addEventListener(`popstate`,Ag),window.addEventListener(`hashchange`,jg))},Ng=()=>{!Dg||typeof window>`u`||typeof history>`u`||(Tg&&(history.pushState=Tg),Eg&&(history.replaceState=Eg),window.removeEventListener(`popstate`,Ag),window.removeEventListener(`hashchange`,jg),Tg=void 0,Eg=void 0,Dg=!1,wg=``)},Pg=e=>typeof window>`u`||typeof history>`u`?()=>{}:(Mg(),Cg.add(e),()=>{Cg.delete(e),Cg.size===0&&Ng()});G();var Fg=()=>typeof location>`u`?``:location.href,Ig=()=>{let e=[];return{name:`page-view`,init(t){if(typeof window>`u`)return;let n=``,r,i=(e,i=n)=>{let a=Fg();if(a===n)return;r==null||r.setAttribute(`view.end_reason`,e),r==null||r.end(),n=a;let o=Mh(`view`),s=t.config.hooks.getViewPathGroup(a),c=e===`load`?`initial_load`:`route_change`,l=t.config.hooks.redactUrl(a),u=t.config.hooks.redactUrl(i);t.setView({id:o,loadingType:c,url:l,urlPathGroup:s});let d=e===`load`,f=W(W(W({},t.config.hooks.getPageAttributes()),$({errorType:`none`,eventLabel:d?`文档加载`:`路由切换`,spanSubtype:d?`navigate`:e,spanType:d?Q.document:Q.route,targetLabel:s,traceScene:d?`page_load`:`route_change`})),{},{[X.viewId]:o,[X.viewUrl]:l,[X.viewUrlPathGroup]:s,[X.viewLoadingType]:c,"url.previous":u,"event.source":e},d?{"document.referrer":t.config.hooks.redactUrl(document.referrer||``)}:{});r=t.startSpan(`browser.view`,f),t.startSpan(`browser.page_view`,W({},f)).end()},a=Pg(e=>{i(e.source,e.fromUrl)});i(`load`);let o=()=>{r==null||r.setAttribute(`view.end_reason`,`shutdown`),r==null||r.end(),r=void 0};window.addEventListener(`pagehide`,o),e.push(a,()=>window.removeEventListener(`pagehide`,o),o)},shutdown(){for(;e.length;){var t;(t=e.pop())==null||t()}}}};G();var Lg=e=>e.transferSize===0&&e.decodedBodySize>0?!0:void 0,Rg=()=>{let e,t=new Set;return{name:`resource`,init(n){var r;if(typeof PerformanceObserver>`u`||!((r=PerformanceObserver.supportedEntryTypes)!=null&&r.includes(`resource`)))return;let i=e=>{if(!e.name||Tp(n.config,e.name))return;let r=`${e.name}|${e.startTime}`;if(t.has(r))return;t.add(r);let i=n.config.hooks.redactUrl(e.name),a=e.duration;n.startSpan(`browser.resource`,W(W(W({},n.config.hooks.getPageAttributes()),rp({duration:a,initiatorType:e.initiatorType||`other`,responseStatus:e.responseStatus,transferSize:e.transferSize,url:i,urlPathTemplate:n.config.hooks.getViewPathGroup(e.name)})),{},{"url.full":i,[X.transferSize]:e.transferSize,[X.cacheHit]:Lg(e),[X.nextHopProtocol]:e.nextHopProtocol,initiator_type:e.initiatorType||`other`,"resource.encoded_body_size":e.encodedBodySize,"resource.decoded_body_size":e.decodedBodySize}),{startTime:performance.timeOrigin+e.startTime}).end(performance.timeOrigin+e.startTime+a)};try{e=new PerformanceObserver(e=>{for(let t of e.getEntries())i(t)}),e.observe({type:`resource`,buffered:!0})}catch(t){e=void 0}},shutdown(){e==null||e.disconnect(),e=void 0,t.clear()}}};G();var zg=()=>{let e=[],t=!1;return{name:`route-timing`,init(n){if(typeof window>`u`||typeof history>`u`)return;let r=n.meter.createHistogram(`browser.route_change.duration`,{unit:`ms`,description:`Estimated SPA route change duration (route start to next idle)`}),i=(e,i,a)=>{if(t)return;let o=performance.now(),s=performance.timeOrigin+o,c=()=>{if(t||typeof document<`u`&&document.visibilityState===`hidden`)return;let c=performance.now()-o,l=c>500?Z.warning:Z.success,u=n.applyRedact(W(W(W({},n.config.hooks.getPageAttributes()),n.config.hooks.getMetricAttributes()),{},{"route.change.source":e}));r.record(c,u),n.startSpan(`browser.route_change`,W(W(W({},u),$({duration:c,errorType:l===Z.warning?`slow`:`none`,eventLabel:`路由切换`,result:l,spanSubtype:e,spanType:Q.route,targetLabel:n.config.hooks.getViewPathGroup(a),targetValue:c,traceScene:`route_change`})),{},{"url.full":n.config.hooks.redactUrl(a),"url.previous":n.config.hooks.redactUrl(i)}),{startTime:s}).end()};requestAnimationFrame(()=>requestAnimationFrame(()=>setTimeout(c,0)))},a=Pg(e=>{e.fromUrl!==e.toUrl&&i(e.source,e.fromUrl,e.toUrl)});e.push(a)},shutdown(){for(t=!0;e.length;){var n;(n=e.pop())==null||n()}}}};bn(),G();var Bg=1800*1e3,Vg=1440*60*1e3,Hg=6e4,Ug=5e3,Wg=[`click`,`keydown`,`scroll`,`mousemove`,`touchstart`],Gg=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>0?e:t,Kg=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>0&&e<=t+Ug,qg=(e,t)=>{if(!e)return null;try{let n=JSON.parse(e);if(typeof(n==null?void 0:n.id)==`string`&&Kg(n.ts,t)&&Kg(n.startedAt,t))return n}catch(e){}return null},Jg=(e,t)=>{if(typeof window>`u`)return null;let n=null;try{n=window.localStorage.getItem(e)}catch(e){}let r=qg(n,t);if(r)return r;try{n=window.sessionStorage.getItem(e)}catch(e){}return r=qg(n,t),r},Yg=(e,t)=>{if(typeof window>`u`)return;let n=JSON.stringify(t);try{window.sessionStorage.setItem(e,n)}catch(e){}try{window.localStorage.setItem(e,n)}catch(e){}},Xg=(e,t,n)=>{let r=Date.now(),i=Jg(e,r);if(i){let a=r-i.ts>=t,o=r-i.startedAt>=n;if(!a&&!o){let t=W(W({},i),{},{ts:r});return Yg(e,t),{id:t.id,rotated:!1}}let s=a?`inactivity`:`maxLifetime`,c={id:Mh(`session`),startedAt:r,ts:r};return Yg(e,c),{id:c.id,prevId:i.id,reason:s,rotated:!0}}let a={id:Mh(`session`),startedAt:r,ts:r};return Yg(e,a),{id:a.id,reason:`init`,rotated:!0}},Zg=e=>{let t=``;try{t=new URL(e).host}catch(n){t=e}return`bk_ot_session__${Th(t||`default`)}`},Qg=(e,t)=>{if(!t.rotated||!t.reason)return;let n=Date.now();e.emitLog({severityNumber:en.INFO,severityText:`INFO`,body:t.reason===`init`?`session.start`:`session.rotate`,attributes:W(W({},e.config.hooks.getPageAttributes()),{},{[X.sessionHasReplay]:!1,[X.sessionId]:t.id,[X.sessionStartTime]:n,"session.rotate.reason":t.reason},t.prevId?{"session.previous_id":t.prevId}:{})})},$g=(e={})=>{let t=[],n=Gg(e.inactivityMs,Bg),r=Gg(e.maxLifetimeMs,Vg);return{name:`session`,init(i){var a;let o=(a=e.storageKey)==null?Zg(i.config.transport.endpoint):a,s=``,c=()=>{if(typeof window>`u`){s||(s=Mh(`session`),i.setRuntimeAttributes({[X.sessionHasReplay]:!1,[X.sessionId]:s}));return}let e=Xg(o,n,r);i.setRuntimeAttributes({[X.sessionHasReplay]:!1,[X.sessionId]:e.id}),e.id!==s&&(s=e.id,Qg(i,e))};if(c(),typeof window>`u`||typeof document>`u`)return;let l=Date.now(),u=()=>{let e=Date.now();e-l<Hg||(l=e,c())},d={capture:!0,passive:!0};Wg.forEach(e=>{window.addEventListener(e,u,d)}),t.push(()=>{Wg.forEach(e=>{window.removeEventListener(e,u,d)})});let f=()=>{document.visibilityState===`visible`&&c()};document.addEventListener(`visibilitychange`,f),t.push(()=>document.removeEventListener(`visibilitychange`,f));let p=e=>{if(e.storageArea!==window.localStorage||e.key!==o||!e.newValue)return;let t=Date.now(),n=qg(e.newValue,t);if(!(!n||n.id===s)){s=n.id;try{window.sessionStorage.setItem(o,e.newValue)}catch(e){}i.setRuntimeAttributes({[X.sessionId]:n.id})}};window.addEventListener(`storage`,p),t.push(()=>window.removeEventListener(`storage`,p))},shutdown(){for(;t.length;){var e;(e=t.pop())==null||e()}}}},e_=n({CLSThresholds:()=>T_,FCPThresholds:()=>C_,INPThresholds:()=>z_,LCPThresholds:()=>H_,TTFBThresholds:()=>W_,onCLS:()=>D_,onFCP:()=>O_,onINP:()=>B_,onLCP:()=>U_,onTTFB:()=>K_});function t_(e,t){return s_.get(e)||s_.set(e,new t),s_.get(e)}var n_,r_,i_,a_,o_,s_,c_,l_,u_,d_,f_,p_,m_,h_,g_,__,v_,y_,b_,x_,S_,C_,w_,T_,E_,D_,O_,k_,A_,j_,M_,N_,P_,F_,I_,L_,R_,z_,B_,V_,H_,U_,W_,G_,K_,q_=t((()=>{F(),G(),n_=class{constructor(){P(this,`t`,void 0),P(this,`o`,0),P(this,`i`,[])}u(e){var t;if(e.hadRecentInput)return;let n=this.i[0],r=this.i.at(-1);this.o&&n&&r&&e.startTime-r.startTime<1e3&&e.startTime-n.startTime<5e3?(this.o+=e.value,this.i.push(e)):(this.o=e.value,this.i=[e]),(t=this.t)==null||t.call(this,e)}},r_=()=>{let e=performance.getEntriesByType(`navigation`)[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},i_=e=>{if(document.readyState===`loading`)return`loading`;let t=r_();if(t){if(e<t.domInteractive)return`loading`;if(t.domContentLoadedEventStart===0||e<t.domContentLoadedEventStart)return`dom-interactive`;if(t.domComplete===0||e<t.domComplete)return`dom-content-loaded`}return`complete`},a_=e=>{let t=e.nodeName;return e.nodeType===1?t.toLowerCase():t.toUpperCase().replace(/^#/,``)},o_=e=>{let t=``;try{for(;(e==null?void 0:e.nodeType)!==9;){let n=e,r=n.id?`#`+n.id:[a_(n),...Array.from(n.classList).sort()].join(`.`);if(t.length+r.length>99)return t||r;if(t=t?r+`>`+t:r,n.id)break;e=n.parentNode}}catch(e){}return t},s_=new WeakMap,c_=-1,l_=()=>c_,u_=e=>{addEventListener(`pageshow`,t=>{t.persisted&&(c_=t.timeStamp,e(t))},!0)},d_=(e,t,n,r)=>{let i,a;return o=>{var s;t.value>=0&&(o||r)&&(a=t.value-((s=i)==null?0:s),(a||i===void 0)&&(i=t.value,t.delta=a,t.rating=((e,t)=>e>t[1]?`poor`:e>t[0]?`needs-improvement`:`good`)(t.value,n),e(t)))}},f_=e=>{requestAnimationFrame(()=>requestAnimationFrame(e))},p_=()=>{var e,t;return(e=(t=r_())==null?void 0:t.activationStart)==null?0:e},m_=(e,t=-1)=>{let n=r_(),r=`navigate`;return l_()>=0?r=`back-forward-cache`:n&&(document.prerendering||p_()>0?r=`prerender`:document.wasDiscarded?r=`restore`:n.type&&(r=n.type.replace(/_/g,`-`))),{name:e,value:t,rating:`good`,delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+0xe8d4a51000}`,navigationType:r}},h_=(e,t,n={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){let r=new PerformanceObserver(e=>{queueMicrotask(()=>{t(e.getEntries())})});return r.observe(W({type:e,buffered:!0},n)),r}}catch(e){}},g_=e=>{let t=!1;return()=>{t||(e(),t=!0)}},__=-1,v_=new Set,y_=()=>document.visibilityState!==`hidden`||document.prerendering?1/0:0,b_=e=>{if(document.visibilityState===`hidden`){if(e.type===`visibilitychange`)for(let e of v_)e();isFinite(__)||(__=e.type===`visibilitychange`?e.timeStamp:0,removeEventListener(`prerenderingchange`,b_,!0))}},x_=()=>{if(__<0){var e;let t=p_(),n=document.prerendering||(e=globalThis.performance.getEntriesByType(`visibility-state`).find(e=>e.name===`hidden`&&e.startTime>=t))==null?void 0:e.startTime;__=n==null?y_():n,addEventListener(`visibilitychange`,b_,!0),addEventListener(`prerenderingchange`,b_,!0),u_(()=>{setTimeout(()=>{__=y_()})})}return{get firstHiddenTime(){return __},onHidden(e){v_.add(e)}}},S_=e=>{document.prerendering?addEventListener(`prerenderingchange`,e,!0):e()},C_=[1800,3e3],w_=(e,t={})=>{S_(()=>{let n=x_(),r,i=m_(`FCP`),a=h_(`paint`,e=>{for(let t of e)t.name===`first-contentful-paint`&&(a.disconnect(),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-p_(),0),i.entries.push(t),r(!0)))});a&&(r=d_(e,i,C_,t.reportAllChanges),u_(n=>{i=m_(`FCP`),r=d_(e,i,C_,t.reportAllChanges),f_(()=>{i.value=performance.now()-n.timeStamp,r(!0)})}))})},T_=[.1,.25],E_=e=>e.find(e=>{var t;return((t=e.node)==null?void 0:t.nodeType)===1})||e[0],D_=(e,t={})=>{let n=t_(t=Object.assign({},t),n_),r=new WeakMap;n.t=e=>{var n;if(!(e==null||(n=e.sources)==null)&&n.length){let n=E_(e.sources),o=n==null?void 0:n.node;if(o){var i,a;let e=(i=(a=t.generateTarget)==null?void 0:a.call(t,o))==null?o_(o):i;r.set(n,e)}}},((e,t={})=>{let n=x_();w_(g_(()=>{let r,i=m_(`CLS`,0),a=t_(t,n_),o=e=>{for(let t of e)a.u(t);a.o>i.value&&(i.value=a.o,i.entries=a.i,r())},s=h_(`layout-shift`,o);s&&(r=d_(e,i,T_,t.reportAllChanges),n.onHidden(()=>{o(s.takeRecords()),r(!0)}),u_(()=>{a.o=0,i=m_(`CLS`,0),r=d_(e,i,T_,t.reportAllChanges),f_(r)}),setTimeout(r))}))})(t=>{e((e=>{let t={};if(e.entries.length){var n;let i=e.entries.reduce((e,t)=>e.value>t.value?e:t);if(!(i==null||(n=i.sources)==null)&&n.length){let e=E_(i.sources);e&&(t={largestShiftTarget:r.get(e),largestShiftTime:i.startTime,largestShiftValue:i.value,largestShiftSource:e,largestShiftEntry:i,loadState:i_(i.startTime)})}}return Object.assign(e,{attribution:t})})(t))},t)},O_=(e,t={})=>{w_(t=>{e((e=>{let t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:i_(l_())};if(e.entries.length){let n=r_(),r=e.entries.at(-1);if(n){let i=n.activationStart||0,a=Math.max(0,n.responseStart-i);t={timeToFirstByte:a,firstByteToFCP:e.value-a,loadState:i_(e.entries[0].startTime),navigationEntry:n,fcpEntry:r}}}return Object.assign(e,{attribution:t})})(t))},t)},k_=0,A_=1/0,j_=0,M_=e=>{for(let t of e)t.interactionId&&(A_=Math.min(A_,t.interactionId),j_=Math.max(j_,t.interactionId),k_=j_?(j_-A_)/7+1:0)},P_=()=>{var e;return N_?k_:(e=performance.interactionCount)==null?0:e},F_=()=>{`interactionCount`in performance||N_||(N_=h_(`event`,M_,{durationThreshold:0}))},I_=0,L_=class{constructor(){P(this,`l`,[]),P(this,`h`,new Map),P(this,`m`,void 0),P(this,`p`,void 0)}v(){I_=P_(),this.l.length=0,this.h.clear()}M(){let e=Math.min(this.l.length-1,Math.floor((P_()-I_)/50));return this.l[e]}u(e){var t;if((t=this.m)==null||t.call(this,e),!e.interactionId&&e.entryType!==`first-input`)return;let n=this.l.at(-1),r=this.h.get(e.interactionId);if(r||this.l.length<10||e.duration>n.T){var i;if(r?e.duration>r.T?(r.entries=[e],r.T=e.duration):e.duration===r.T&&e.startTime===r.entries[0].startTime&&r.entries.push(e):(r={id:e.interactionId,entries:[e],T:e.duration},this.h.set(r.id,r),this.l.push(r)),this.l.sort((e,t)=>t.T-e.T),this.l.length>10){let e=this.l.splice(10);for(let t of e)this.h.delete(t.id)}(i=this.p)==null||i.call(this,r)}}},R_=e=>{let t=globalThis.requestIdleCallback||setTimeout,n=globalThis.cancelIdleCallback||clearTimeout;if(document.visibilityState===`hidden`)e();else{let r=g_(e),i=-1,a=()=>{n(i),r()};addEventListener(`visibilitychange`,a,{once:!0,capture:!0}),i=t(()=>{removeEventListener(`visibilitychange`,a,{capture:!0}),r()})}},z_=[200,500],B_=(e,t={})=>{let n=t_(t=Object.assign({},t),L_),r=[],i=[],a=0,o=new WeakMap,s=new WeakMap,c=!1,l=()=>{c||(R_(u),c=!0)},u=()=>{let e=new Set(n.l.map(e=>o.get(e.entries[0]))),t=i.length-10;i=i.filter((n,r)=>r>=t||e.has(n));let s=new Set;for(let e of i){let t=d(e.startTime,e.processingEnd);for(let e of t)s.add(e)}r=r.filter(e=>e.startTime>a||s.has(e)),c=!1};n.m=e=>{let n=e.startTime+e.duration,r;a=Math.max(a,e.processingEnd);for(let a=i.length-1;a>=0;a--){let o=i[a];if(Math.abs(n-o.renderTime)<=8){r=o,r.startTime=Math.min(e.startTime,r.startTime),r.processingStart=Math.min(e.processingStart,r.processingStart),r.processingEnd=Math.max(e.processingEnd,r.processingEnd),!1!==t.includeProcessedEventEntries&&r.entries.push(e);break}}r||(r={startTime:e.startTime,processingStart:e.processingStart,processingEnd:e.processingEnd,renderTime:n,entries:!1===t.includeProcessedEventEntries?[]:[e]},i.push(r)),(e.interactionId||e.entryType===`first-input`)&&o.set(e,r),l()},n.p=e=>{if(!s.get(e)){let i=e.entries[0].target;if(i){var n,r;let a=(n=(r=t.generateTarget)==null?void 0:r.call(t,i))==null?o_(i):n;s.set(e,a)}}};let d=(e,t)=>{let n=[];for(let i of r)if(!(i.startTime+i.duration<e)){if(i.startTime>t)break;n.push(i)}return n},f=e=>{let t=e.entries[0],r=o.get(t),i=t.processingStart,a=Math.max(t.startTime+t.duration,i),c=Math.min(r.processingEnd,a),l=r.entries.sort((e,t)=>e.processingStart-t.processingStart),u=d(t.startTime,c),f=n.h.get(t.interactionId),p={interactionTarget:s.get(f),interactionType:t.name.startsWith(`key`)?`keyboard`:`pointer`,interactionTime:t.startTime,nextPaintTime:a,processedEventEntries:l,longAnimationFrameEntries:u,inputDelay:i-t.startTime,processingDuration:c-i,presentationDelay:a-c,loadState:i_(t.startTime),longestScript:void 0,totalScriptDuration:void 0,totalStyleAndLayoutDuration:void 0,totalPaintDuration:void 0,totalUnattributedDuration:void 0};return(e=>{var t;if(!((t=e.longAnimationFrameEntries)!=null&&t.length))return;let n=e.interactionTime,r=e.inputDelay,i=e.processingDuration,a,o,s=0,c=0,l=0,u=0;for(let t of e.longAnimationFrameEntries){c=c+t.startTime+t.duration-t.styleAndLayoutStart;for(let e of t.scripts){let t=e.startTime+e.duration;if(t<n)continue;let l=t-Math.max(n,e.startTime),d=e.duration?l/e.duration*e.forcedStyleAndLayoutDuration:0;s+=l-d,c+=d,l>u&&(o=e.startTime<n+r?`input-delay`:e.startTime>=n+r+i?`presentation-delay`:`processing-duration`,a=e,u=l)}}let d=e.longAnimationFrameEntries.at(-1),f=d?d.startTime+d.duration:0;f>=n+r+i&&(l=e.nextPaintTime-f),a&&o&&(e.longestScript={entry:a,subpart:o,intersectingDuration:u}),e.totalScriptDuration=s,e.totalStyleAndLayoutDuration=c,e.totalPaintDuration=l,e.totalUnattributedDuration=e.nextPaintTime-n-s-c-l})(p),Object.assign(e,{attribution:p})};h_(`long-animation-frame`,e=>{r=r.concat(e),l()}),((e,t={})=>{if(!globalThis.PerformanceEventTiming||!(`interactionId`in PerformanceEventTiming.prototype))return;let n=x_();S_(()=>{var r;F_();let i,a=m_(`INP`),o=t_(t,L_),s=e=>{R_(()=>{for(let t of e)o.u(t);let t=o.M();t&&t.T!==a.value&&(a.value=t.T,a.entries=t.entries,i())})},c=h_(`event`,s,{durationThreshold:(r=t.durationThreshold)==null?40:r});i=d_(e,a,z_,t.reportAllChanges),c&&(c.observe({type:`first-input`,buffered:!0}),n.onHidden(()=>{s(c.takeRecords()),i(!0)}),u_(()=>{o.v(),a=m_(`INP`),i=d_(e,a,z_,t.reportAllChanges)}))})})(t=>{e(f(t))},t)},V_=class{constructor(){P(this,`m`,void 0)}u(e){var t;(t=this.m)==null||t.call(this,e)}},H_=[2500,4e3],U_=(e,t={})=>{let n=t_(t=Object.assign({},t),V_),r=new WeakMap;n.m=e=>{let n=e.element;if(n){var i,a;let o=(i=(a=t.generateTarget)==null?void 0:a.call(t,n))==null?o_(n):i;r.set(e,o)}else e.id&&r.set(e,`#${e.id}`)},((e,t={})=>{S_(()=>{let n=x_(),r,i=m_(`LCP`),a=t_(t,V_),o=e=>{t.reportAllChanges||(e=e.slice(-1));for(let t of e)a.u(t),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-p_(),0),i.entries=[t],r())},s=h_(`largest-contentful-paint`,o);if(s){r=d_(e,i,H_,t.reportAllChanges);let n=g_(()=>{o(s.takeRecords()),s.disconnect(),r(!0)}),a=e=>{e.isTrusted&&(R_(n),removeEventListener(e.type,a,{capture:!0}))};for(let e of[`keydown`,`click`,`visibilitychange`])addEventListener(e,a,{capture:!0});u_(n=>{i=m_(`LCP`),r=d_(e,i,H_,t.reportAllChanges),f_(()=>{i.value=performance.now()-n.timeStamp,r(!0)})})}})})(t=>{e((e=>{let t={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:e.value};if(e.entries.length){let n=e.entries.at(-1),i=n.url&&performance.getEntriesByType(`resource`).find(e=>e.name===n.url);t.target=r.get(n),t.lcpEntry=n,n.url&&(t.url=n.url),i&&(t.lcpResourceEntry=i);let a=r_();if(a){let n=a.activationStart||0,r=Math.max(0,a.responseStart-n),o=Math.max(r,i?(i.requestStart||i.startTime)-n:0),s=Math.min(e.value,Math.max(o,i?i.responseEnd-n:0));t=W(W({},t),{},{timeToFirstByte:r,resourceLoadDelay:o-r,resourceLoadDuration:s-o,elementRenderDelay:e.value-s,navigationEntry:a})}}return Object.assign(e,{attribution:t})})(t))},t)},W_=[800,1800],G_=e=>{document.prerendering?S_(()=>G_(e)):document.readyState===`complete`?setTimeout(e):addEventListener(`load`,()=>G_(e),!0)},K_=(e,t={})=>{((e,t={})=>{let n=m_(`TTFB`),r=d_(e,n,W_,t.reportAllChanges);G_(()=>{let i=r_();i&&(n.value=Math.max(i.responseStart-p_(),0),n.entries=[i],r(!0),u_(()=>{n=m_(`TTFB`,0),r=d_(e,n,W_,t.reportAllChanges),r(!0)}))})})(t=>{e((e=>{let t={waitingDuration:0,cacheDuration:0,dnsDuration:0,connectionDuration:0,requestDuration:0};if(e.entries.length){let n=e.entries[0],r=n.activationStart||0,i=Math.max((n.workerStart||n.fetchStart)-r,0),a=Math.max(n.domainLookupStart-r,0),o=Math.max(n.connectStart-r,0),s=Math.max(n.connectEnd-r,0);t={waitingDuration:i,cacheDuration:a-i,dnsDuration:o-a,connectionDuration:s-o,requestDuration:e.value-s,navigationEntry:n}}return Object.assign(e,{attribution:t})})(t))},t)}}));G(),H();var J_=`unknown`,Y_=e=>e?e.replace(/_/g,`-`):J_,X_=()=>{if(typeof performance>`u`)return J_;let e=performance.getEntriesByType(`navigation`)[0];return Y_(e==null?void 0:e.type)},Z_=(e,t)=>{var n;return{"rum.navigation.type":(n=e.navigationType)==null?t:n,[X.vitalMetric]:e.name.toLowerCase(),[X.vitalRating]:e.rating}},Q_=(e,t)=>{var n;let r=(n=e.attribution)==null?{}:n,i={},a=e=>r[e],o=(e,t,n)=>{t!=null&&(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)&&(i[e]=typeof t==`string`&&n?n(t):t)};switch(e.name){case`LCP`:o(`vital.lcp.url`,a(`url`),t),o(`vital.lcp.target`,a(`target`)),o(`vital.lcp.element_render_delay`,a(`elementRenderDelay`)),o(`vital.lcp.resource_load_duration`,a(`resourceLoadDuration`)),o(`vital.lcp.time_to_first_byte`,a(`timeToFirstByte`));break;case`CLS`:o(`vital.cls.largest_shift_target`,a(`largestShiftTarget`)),o(`vital.cls.largest_shift_value`,a(`largestShiftValue`)),o(`vital.cls.load_state`,a(`loadState`));break;case`INP`:o(`vital.inp.interaction_target`,a(`interactionTarget`)),o(`vital.inp.interaction_type`,a(`interactionType`)),o(`vital.inp.input_delay`,a(`inputDelay`)),o(`vital.inp.processing_duration`,a(`processingDuration`)),o(`vital.inp.presentation_delay`,a(`presentationDelay`));break;case`FCP`:o(`vital.fcp.time_to_first_byte`,a(`timeToFirstByte`)),o(`vital.fcp.load_state`,a(`loadState`));break;case`TTFB`:o(`vital.ttfb.waiting_duration`,a(`waitingDuration`)),o(`vital.ttfb.dns_duration`,a(`dnsDuration`)),o(`vital.ttfb.connection_duration`,a(`connectionDuration`)),o(`vital.ttfb.request_duration`,a(`requestDuration`));break;default:break}return i},$_=()=>{let e=!1;return{name:`web-vitals`,init(t){return V(function*(){if(typeof window>`u`)return;let n;try{n=yield Promise.resolve().then(()=>(q_(),e_))}catch(e){if(t.config.debug){var r;(r=globalThis.console)==null||r.warn(`[bk-ot] web-vitals load failed:`,e)}return}if(e)return;let{onCLS:i,onFCP:a,onINP:o,onLCP:s,onTTFB:c}=n,l=X_(),u=t.meter.createHistogram(`browser.web_vital.cls`,{unit:`1`,description:`Cumulative Layout Shift`}),d=t.meter.createHistogram(`browser.web_vital.duration`,{unit:`ms`,description:`Web Vitals duration metrics, including FCP, INP, LCP and TTFB`}),f=e=>{let n=e.name.toLowerCase();t.startSpan(`browser.web_vital`,W(W(W(W(W({},t.config.hooks.getPageAttributes()),t.config.hooks.getMetricAttributes()),Z_(e,l)),$({duration:e.name===`CLS`?void 0:e.value,errorType:e.rating===`good`?`none`:`slow`,eventLabel:`Web 指标`,result:ep(e.rating),spanSubtype:n,spanType:Q.vital,targetLabel:n,targetValue:e.value})),{},{[X.vitalMetric]:n,[X.vitalValue]:e.value,[X.vitalRating]:e.rating,"vital.id":e.id},Q_(e,t.config.hooks.redactUrl))).end()},p=n=>{e||!Number.isFinite(n.value)||(d.record(n.value,t.applyRedact(W(W(W({},t.config.hooks.getPageAttributes()),t.config.hooks.getMetricAttributes()),Z_(n,l)))),f(n))};i(n=>{e||!Number.isFinite(n.value)||(u.record(n.value,t.applyRedact(W(W(W({},t.config.hooks.getPageAttributes()),t.config.hooks.getMetricAttributes()),Z_(n,l)))),f(n))}),a(p),o(p),s(p),c(p)})()},shutdown(){e=!0}}};N(),bn(),G();var ev=64*1024,tv=6e4,nv=5,rv=e=>e==null?0:typeof e==`string`?e.length>ev||typeof TextEncoder>`u`?e.length:new TextEncoder().encode(e).byteLength:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:typeof Blob<`u`&&e instanceof Blob?e.size:0,iv=(e,t)=>{let n={"network.protocol.name":`websocket`,"url.full":t(e)},r={"network.protocol.name":`websocket`};try{let t=new URL(e,typeof location>`u`?`http://localhost`:location.href);n[`server.address`]=t.host,n[`url.scheme`]=t.protocol.replace(`:`,``),r[`server.address`]=t.host,r[`url.scheme`]=n[`url.scheme`]}catch(e){}return{metricAttributes:r,spanAttributes:n}},av=(e,t)=>{var n;let{bytesCounter:r,connectDurationHistogram:i,context:a,errorCounter:o,errorThrottle:s,isDisposed:c,messageCounter:l,url:u}=t,{metricAttributes:d,spanAttributes:f}=iv(u,a.config.hooks.redactUrl),p=(n=f[`server.address`])==null?f[`url.full`]:n,m=a.startSpan(`websocket.connect`,W(W(W({},f),$({errorType:`none`,eventLabel:`WebSocket`,spanSubtype:`websocket`,spanType:Q.custom,targetLabel:p})),f[`server.address`]?{[X.targetDomain]:f[`server.address`]}:{})),h=performance.now(),g=!1,_=e=>{if(g)return;g=!0;let t=performance.now()-h;e===`error`&&m.setStatus({code:wt.ERROR,message:`websocket connect failed`}),m.setAttributes($({duration:t,errorType:e===`error`?`network`:`none`,eventLabel:`WebSocket`,result:e===`error`?Z.error:Z.success,spanSubtype:`websocket`,spanType:Q.custom,targetLabel:p,targetValue:t})),m.end(),e===`opened`&&!c()&&i.record(t,d)};e.addEventListener(`open`,()=>{c()||_(`opened`)}),e.addEventListener(`message`,e=>{if(c())return;let t=W(W({},d),{},{"websocket.direction":`in`});l.add(1,t),r.add(rv(e.data),t)}),e.addEventListener(`error`,()=>{if(c())return;let e=g?`runtime`:`connect`;o.add(1,W(W({},d),{},{"websocket.error.phase":e})),_(`error`);let t=s.allow(`ws:error:${u}`);t.allowed&&a.emitLog({severityNumber:en.ERROR,severityText:`ERROR`,body:`websocket.error`,attributes:W(W(W({},f),$({errorType:`network`,eventLabel:`WebSocket 错误`,result:Z.error,spanSubtype:`websocket`,spanType:Q.custom,targetLabel:p})),{},{"websocket.error.phase":e,"websocket.error.window_count":t.count})})}),e.addEventListener(`close`,e=>{c()||(g||_(`error`),a.emitLog({severityNumber:en.INFO,severityText:`INFO`,body:`websocket.close`,attributes:W(W(W({},f),$({errorType:e.wasClean?`none`:`network`,eventLabel:`WebSocket 关闭`,result:e.wasClean?Z.success:Z.warning,spanSubtype:`websocket`,spanType:Q.custom,targetLabel:p,targetValue:e.code})),{},{"websocket.close.code":e.code,"websocket.close.reason":e.reason,"websocket.close.was_clean":e.wasClean})}))});let v=e.send.bind(e);e.send=e=>{if(!c()){let t=W(W({},d),{},{"websocket.direction":`out`});l.add(1,t),r.add(rv(e),t)}return v(e)}},ov=()=>{let e,t,n=!1;return{name:`websocket`,init(r){if(typeof window>`u`||window.WebSocket===void 0)return;let i=window.WebSocket;e=i;let a=r.meter.createCounter(`browser.websocket.message.count`,{description:`Total number of WebSocket messages observed`}),o=r.meter.createCounter(`browser.websocket.message.bytes`,{unit:`By`,description:`Total bytes transferred over WebSocket (best-effort)`}),s=r.meter.createCounter(`browser.websocket.error.count`,{description:`Total number of WebSocket error events`}),c=r.meter.createHistogram(`browser.websocket.connect.duration`,{unit:`ms`,description:`WebSocket connection establishment duration (only successful connects)`}),l=Eh(tv,nv),u=()=>n;t=new Proxy(i,{construct(e,t,i){let d=Reflect.construct(e,t,i);if(n)return d;let f=t[0]==null?``:String(t[0]);return!f||Tp(r.config,f)||av(d,{bytesCounter:o,connectDurationHistogram:c,context:r,errorCounter:s,errorThrottle:l,isDisposed:u,messageCounter:a,url:f}),d}}),window.WebSocket=t},shutdown(){n=!0,typeof window<`u`&&e&&window.WebSocket===t&&(window.WebSocket=e),t=void 0,e=void 0}}};G();var sv=`http://localhost:4318`,cv=60*1e3,lv=`unknown_service`,uv=e=>e.replace(/\/+$/,``),dv=(e,t)=>{let n=uv(e||sv);return n.endsWith(`/v1/${t}`)?n:n.endsWith(`/v1`)?`${n}/${t}`:`${n}/v1/${t}`},fv=(e,t)=>{var n,r,i,a,o;let s=e==null||(n=e.signals)==null?void 0:n[t],c=e==null||(r=e.signals)==null||(r=r.endpoints)==null?void 0:r[t],l=e!=null&&e.token||e!=null&&e.headers||s!=null&&s.headers?W(W(W({},e!=null&&e.token?{Authorization:`Bearer ${e.token}`}:{}),(i=e==null?void 0:e.headers)==null?{}:i),(a=s==null?void 0:s.headers)==null?{}:a):void 0;return{concurrencyLimit:s==null?void 0:s.concurrencyLimit,endpoint:c?uv(c):dv((o=s==null?void 0:s.endpoint)==null?e==null?void 0:e.endpoint:o,t),headers:l,timeoutMillis:s==null?void 0:s.timeoutMillis}},pv=e=>typeof e!=`number`||!Number.isFinite(e)?1:Math.max(0,Math.min(1,e)),mv=e=>e,hv=e=>e,gv=e=>{try{return new URL(e,typeof location>`u`?`http://localhost`:location.href).pathname||`/`}catch(t){return e||`/`}},_v=e=>{var t,n;return{environment:(t=e==null?void 0:e.environment)==null?`production`:t,name:(n=e==null?void 0:e.name)==null?lv:n,version:e==null?void 0:e.version}},vv=e=>W(W({[X.deploymentEnvironmentName]:e.environment,"rum.provider":`blueking`,[X.serviceName]:e.name},e.version?{[X.serviceVersion]:e.version}:{}),{},{"telemetry.sdk.language":`webjs`}),yv=e=>({endpoint:uv((e==null?void 0:e.endpoint)||sv),traces:fv(e,`traces`),metrics:fv(e,`metrics`),logs:fv(e,`logs`)}),bv=e=>({rate:pv(e==null?void 0:e.rate)}),xv=e=>{var t,n,r,i,a,o,s,c,l,u,d,f;return{getPageAttributes:(t=(n=e.attributes)==null?void 0:n.page)==null?(()=>({"rum.page.host":typeof window>`u`?``:window.location.host,"rum.page.path":typeof window>`u`?``:window.location.pathname})):t,getMetricAttributes:(r=(i=e.attributes)==null?void 0:i.metric)==null?(()=>({})):r,getErrorAttributes:(a=(o=e.attributes)==null?void 0:o.error)==null?(()=>({})):a,getCustomAttributes:(s=(c=e.attributes)==null?void 0:c.custom)==null?(()=>({})):s,getViewPathGroup:t=>{var n,r,i;return(n=(r=e.route)==null||(i=r.getPathGroup)==null?void 0:i.call(r,t))==null?gv(t):n},redactAttributes:(l=(u=e.privacy)==null?void 0:u.redactAttributes)==null?mv:l,redactUrl:(d=(f=e.privacy)==null?void 0:f.redactUrl)==null?hv:d}},Sv=e=>{var t,n,r,i,a,o;let s=_v(e.app);return{app:s,autoStart:(t=e.autoStart)==null?!0:t,debug:(n=e.debug)==null?!1:n,enabled:(r=e.enabled)==null?!0:r,hooks:xv(e),instrumentations:(i=e.instrumentations)==null?{}:i,metricIntervalMillis:cv,plugins:(a=e.plugins)==null?{}:a,resourceAttributes:vv(s),sampling:bv(e.sampling),spanBatch:e.spanBatch,spanProcessor:(o=e.spanProcessor)==null?`batch`:o,transport:yv(e.transport),user:e.user}};F(),H();var Cv=(e,t)=>typeof e.enabled==`function`?e.enabled(t):e.enabled!==!1,wv=class{constructor(e){P(this,`plugins`,void 0),P(this,`startedPlugins`,[]),this.plugins=e}flush(){var e=this;return V(function*(){yield Promise.all(e.startedPlugins.map(e=>Promise.resolve().then(()=>{var t;return(t=e.flush)==null?void 0:t.call(e)})))})()}shutdown(){var e=this;return V(function*(){let t=[...e.startedPlugins].reverse();for(let e of t){var n;yield(n=e.shutdown)==null?void 0:n.call(e)}e.startedPlugins=[]})()}start(e){var t=this;return V(function*(){for(let r of t.plugins)if(Cv(r,e.config))try{yield r.init(e),t.startedPlugins.push(r)}catch(t){if(e.config.debug){var n;(n=globalThis.console)==null||n.warn(`[bk-ot] plugin "${r.name}" init failed:`,t)}}})()}},Tv=[`http.url`,`url.full`],Ev=e=>{for(let n of Tv){var t;let r=(t=e.attributes)==null?void 0:t[n];if(typeof r==`string`)return r}},Dv=class{constructor(e,t){this.inner=e,this.config=t}forceFlush(){return this.inner.forceFlush()}onEnd(e){let t=Ev(e);t&&wp(this.config,t)||this.inner.onEnd(e)}onStart(e,t){this.inner.onStart(e,t)}shutdown(){return this.inner.shutdown()}};F(),G();var Ov=class{constructor(e={},t){P(this,`attributes`,{}),P(this,`setOptionalAttribute`,(e,t)=>{if(t===void 0){delete this.attributes[e];return}this.attributes[e]=t}),P(this,`user`,{}),P(this,`view`,{}),P(this,`getAttributes`,()=>W({},this.attributes)),P(this,`getUser`,()=>W({},this.user)),P(this,`getView`,()=>W({},this.view)),P(this,`setAttributes`,e=>{for(let[t,n]of Object.entries(e)){if(n===void 0){delete this.attributes[t];continue}this.attributes[t]=n}}),P(this,`setUser`,e=>{if(this.user=W(W({},this.user),e),`id`in e){if(e.id===void 0){delete this.attributes[X.userId];return}this.attributes[X.userId]=e.id}}),P(this,`setView`,e=>{this.view=W(W({},this.view),e),this.setOptionalAttribute(X.viewId,e.id),this.setOptionalAttribute(X.viewUrl,e.url),this.setOptionalAttribute(X.viewUrlPathGroup,e.urlPathGroup),this.setOptionalAttribute(X.viewLoadingType,e.loadingType)}),this.setAttributes(e),t&&this.setUser(t)}},kv=`BK_RUM_SAMPLING`,Av=new Map,jv=e=>Av.get(e),Mv=(e,t)=>(Av.set(e,t),t),Nv=({sampling:e})=>{if(e.rate<=0)return!1;if(e.rate>=1)return!0;try{let t=sessionStorage.getItem(kv);if(t)return t===`1`;let n=Math.random()<e.rate;return sessionStorage.setItem(kv,n?`1`:`0`),Mv(kv,n),n}catch(t){let n=jv(kv);return typeof n==`boolean`?n:Mv(kv,Math.random()<e.rate)}};N(),bn(),B(),Qu(),lc(),Cf(),Yf(),F(),G(),H();var Pv=e=>({url:e.endpoint,headers:e.headers,concurrencyLimit:e.concurrencyLimit,timeoutMillis:e.timeoutMillis}),Fv=`bk-rum`,Iv=(e,t,n)=>n?new Proxy(e,{get(e,n,r){if(n===`export`)return(n,r)=>{var i;return(i=globalThis.console)==null||i.log(`[bk-ot][${t}]`,n),e.export(n,r)};let i=Reflect.get(e,n,r);return typeof i==`function`?i.bind(e):i}}):e,Lv=e=>[wh(e.instrumentations)],Rv=(e,t)=>e===void 0?t:e!==!1,zv=e=>typeof e==`object`&&e?e:void 0,Bv=(e,t,n)=>Rv(e,t)?[n(zv(e))]:[],Vv=e=>[...Bv(e.device,!0,Wh),...Bv(e.session,!0,$g),...Bv(e.pageView,!0,Ig),...Bv(e.httpBody,!1,yg),...Bv(e.error,!0,eg),...Bv(e.webVitals,!0,$_),...Bv(e.resource,!0,Rg),...Bv(e.blankScreen,!0,vp),...Bv(e.action,!1,sp),...Bv(e.websocket,!1,ov),...Bv(e.longTask,!1,Sg),...Bv(e.cspViolation,!1,jh),...Bv(e.routeTiming,!1,zg)],Hv=class{assertBeforeStart(e){if(this.phase!==`idle`)throw Error(`[bk-ot] ${e}() must be called before start(); set autoStart: false before registration.`)}constructor(e){var t=this,n,r;P(this,`loggerProvider`,void 0),P(this,`meterProvider`,void 0),P(this,`phase`,`idle`),P(this,`pluginManager`,void 0),P(this,`plugins`,void 0),P(this,`registeredInstrumentations`,void 0),P(this,`runtimeContext`,void 0),P(this,`sampled`,void 0),P(this,`teardownCallbacks`,[]),P(this,`tracerProvider`,void 0),P(this,`applyRedact`,e=>this.config.hooks.redactAttributes(e)),P(this,`config`,void 0),P(this,`emitLog`,e=>{var t;let n=W(W({},e),{},{attributes:this.applyRedact(W(W({},this.getRuntimeAttributes()),(t=e.attributes)==null?{}:t))});this.logger.emit(n)}),P(this,`flush`,V(function*(){yield t.pluginManager.flush(),yield t.tracerProvider.forceFlush(),yield t.meterProvider.forceFlush(),yield t.loggerProvider.forceFlush()})),P(this,`getRuntimeAttributes`,()=>this.runtimeContext.getAttributes()),P(this,`logger`,void 0),P(this,`meter`,void 0),P(this,`reportAction`,({attributes:e={},targetTag:t,targetText:n,type:r})=>{var i;if(!this.sampled)return;let a=n==null?void 0:n.slice(0,32);this.startSpan(`action.${r}`,W(W(W(W(W({},this.config.hooks.getPageAttributes()),$({errorType:`none`,eventLabel:`用户操作`,spanSubtype:r,spanType:Q.action,targetLabel:(i=a==null?t:a)==null?r:i})),{},{[X.actionType]:r},a?{[X.targetTextShort]:a}:{}),t?{[X.targetTag]:t}:{}),e)).end()}),P(this,`reportCustomEvent`,({attributes:e={},error:t,name:n})=>{if(!this.sampled){if(this.config.debug){var r;(r=globalThis.console)==null||r.warn(`[bk-ot] custom event dropped (not sampled):`,n)}return}let i=this.startSpan(`custom.${n}`,W(W(W(W(W({},this.config.hooks.getPageAttributes()),this.config.hooks.getCustomAttributes()),$({errorType:t?`custom`:`none`,eventLabel:`自定义事件`,result:t?Z.error:Z.success,spanSubtype:n,spanType:Q.custom,targetLabel:n})),e),{},{"rum.custom.name":n}));t&&(i.recordException(t),i.setStatus({code:wt.ERROR,message:t.message})),i.end()}),P(this,`setRuntimeAttributes`,e=>{this.runtimeContext.setAttributes(e)}),P(this,`setUser`,e=>{this.runtimeContext.setUser(e)}),P(this,`setView`,e=>{this.runtimeContext.setView(e)}),P(this,`shutdown`,V(function*(){if(t.phase!==`stopped`){for(yield t.flush();t.teardownCallbacks.length;){var e;(e=t.teardownCallbacks.pop())==null||e()}for(yield t.pluginManager.shutdown();t.registeredInstrumentations.length;){var n,r;(n=t.registeredInstrumentations.pop())==null||(r=n.disable)==null||r.call(n)}yield t.tracerProvider.shutdown(),yield t.meterProvider.shutdown(),yield t.loggerProvider.shutdown(),M.disable(),Pt.disable(),A.disable(),t.phase=`stopped`}})),P(this,`start`,V(function*(){if(!(t.phase===`started`||t.phase===`starting`)){if(t.phase===`stopped`)throw Error(`[bk-ot] instance has been shut down and cannot be restarted; create a new instance instead.`);if(!t.config.enabled){t.phase=`started`;return}t.phase=`starting`,Jt.setGlobalPropagator(new Ba),t.tracerProvider.register({contextManager:new kn}),Pt.setGlobalMeterProvider(t.meterProvider),yn.setGlobalLoggerProvider(t.loggerProvider);try{if(t.registeredInstrumentations.length&&Pu({instrumentations:t.registeredInstrumentations,meterProvider:t.meterProvider,tracerProvider:t.tracerProvider}),yield t.pluginManager.start(t),typeof window<`u`&&typeof document<`u`){let e=()=>{t.flush()},n=()=>{document.visibilityState===`hidden`&&t.flush()};window.addEventListener(`pagehide`,e),document.addEventListener(`visibilitychange`,n),t.teardownCallbacks.push(()=>window.removeEventListener(`pagehide`,e),()=>document.removeEventListener(`visibilitychange`,n))}}catch(r){for(;t.teardownCallbacks.length;){var e;(e=t.teardownCallbacks.pop())==null||e()}yield t.pluginManager.shutdown();for(let e of t.registeredInstrumentations){var n;(n=e.disable)==null||n.call(e)}throw M.disable(),Pt.disable(),A.disable(),t.phase=`idle`,r}t.phase=`started`}})),P(this,`startSpan`,(e,t={},n)=>this.tracer.startSpan(e,{kind:St.INTERNAL,startTime:n==null?void 0:n.startTime,attributes:this.applyRedact(W(W({},this.getRuntimeAttributes()),t))})),P(this,`tracer`,void 0),P(this,`use`,e=>(this.assertBeforeStart(`use`),this.sampled&&this.plugins.push(e),this)),P(this,`useInstrumentation`,e=>(this.assertBeforeStart(`useInstrumentation`),this.config.enabled&&this.registeredInstrumentations.push(e),this)),this.config=Sv(e),this.sampled=this.config.enabled&&Nv(this.config);let i=nc(this.config.resourceAttributes),a=Iv(new Au(Pv(this.config.transport.traces)),`traces`,this.config.debug),o=Iv(new ku(Pv(this.config.transport.metrics)),`metrics`,this.config.debug),s=Iv(new yu(Pv(this.config.transport.logs)),`logs`,this.config.debug),c=new Dv(this.config.spanProcessor===`simple`?new xf(a):new Wd(a,this.config.spanBatch),this.config),l=new Xs({exporter:o,exportIntervalMillis:this.config.metricIntervalMillis}),u=new _d(s);this.tracerProvider=new Of({resource:i,sampler:new Od({root:new Ad(+!!this.sampled)}),spanProcessors:[c]}),this.meterProvider=new cl({resource:i,readers:[l]}),this.loggerProvider=new fd({resource:i,processors:[u]}),this.tracer=this.tracerProvider.getTracer(Fv),this.meter=this.meterProvider.getMeter(Fv),this.logger=this.loggerProvider.getLogger(Fv),this.runtimeContext=new Ov({"rum.sampled":this.sampled},this.config.user),this.registeredInstrumentations=this.config.enabled?[...(n=this.config.instrumentations.custom)==null?[]:n]:[],this.plugins=[...this.config.enabled?Lv(this.config):[],...this.sampled?[...Vv(this.config.plugins),...(r=this.config.plugins.custom)==null?[]:r]:[]],this.pluginManager=new wv(this.plugins),this.config.autoStart&&this.start().catch(e=>{var t;(t=globalThis.console)==null||t.warn(`[bk-ot] auto start failed:`,e)})}};return typeof window<`u`&&Object.assign(window,{BkOpenTelemetry:Hv}),Hv})();
11
+ `,zc(t,e))}return n}};F();var Vc=class{constructor(e){P(this,`_backingStorages`,void 0),this._backingStorages=e}record(e,t,n,r){let i=this._backingStorages;for(let a=0;a<i.length;a++)i[a].record(e,t,n,r)}};N(),F();var Hc=class{constructor(e,t){P(this,`_buffer`,new kc),P(this,`_instrumentName`,void 0),P(this,`_valueType`,void 0),this._instrumentName=e,this._valueType=t}observe(e,t={}){if(typeof e!=`number`){j.warn(`non-number value provided to metric ${this._instrumentName}: ${e}`);return}this._valueType===ke.INT&&!Number.isInteger(e)&&(j.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(t,e)}},Uc=class{constructor(){P(this,`_buffer`,new Map)}observe(e,t,n={}){if(!Tc(e))return;let r=this._buffer.get(e);if(r==null&&(r=new kc,this._buffer.set(e,r)),typeof t!=`number`){j.warn(`non-number value provided to metric ${e._descriptor.name}: ${t}`);return}e._descriptor.valueType===ke.INT&&!Number.isInteger(t)&&(j.warn(`INT value type cannot accept a floating-point value for ${e._descriptor.name}, ignoring the fractional digits.`),t=Math.trunc(t),!Number.isInteger(t))||r.set(n,t)}};N(),F(),H();var Wc=class{constructor(){P(this,`_callbacks`,[]),P(this,`_batchCallbacks`,[])}addCallback(e,t){this._findCallback(e,t)>=0||this._callbacks.push({callback:e,instrument:t})}removeCallback(e,t){let n=this._findCallback(e,t);n<0||this._callbacks.splice(n,1)}addBatchCallback(e,t){let n=new Set(t.filter(Tc));if(n.size===0){j.error(`BatchObservableCallback is not associated with valid instruments`,t);return}this._findBatchCallback(e,n)>=0||this._batchCallbacks.push({callback:e,instruments:n})}removeBatchCallback(e,t){let n=new Set(t.filter(Tc)),r=this._findBatchCallback(e,n);r<0||this._batchCallbacks.splice(r,1)}observe(e,t){var n=this;return V(function*(){let r=n._observeCallbacks(e,t),i=n._observeBatchCallbacks(e,t);return(yield Promise.allSettled([...r,...i])).filter(e=>e.status===`rejected`).map(e=>e.reason)})()}_observeCallbacks(e,t){return this._callbacks.map(function(){var n=V(function*({callback:n,instrument:r}){let i=new Hc(r._descriptor.name,r._descriptor.valueType),a=Promise.resolve(n(i));t!=null&&(a=Jo(a,t)),yield a,r._metricStorages.forEach(t=>{t.record(i._buffer,e)})});return function(e){return n.apply(this,arguments)}}())}_observeBatchCallbacks(e,t){return this._batchCallbacks.map(function(){var n=V(function*({callback:n,instruments:r}){let i=new Uc,a=Promise.resolve(n(i));t!=null&&(a=Jo(a,t)),yield a,r.forEach(t=>{let n=i._buffer.get(t);n!=null&&t._metricStorages.forEach(t=>{t.record(n,e)})})});return function(e){return n.apply(this,arguments)}}())}_findCallback(e,t){return this._callbacks.findIndex(n=>n.callback===e&&n.instrument===t)}_findBatchCallback(e,t){return this._batchCallbacks.findIndex(n=>n.callback===e&&Yo(n.instruments,t))}};F();var Gc=class extends Dc{constructor(e,t,n,r,i){super(e),P(this,`_aggregationCardinalityLimit`,void 0),P(this,`_deltaMetricStorage`,void 0),P(this,`_temporalMetricStorage`,void 0),P(this,`_attributesProcessor`,void 0),this._aggregationCardinalityLimit=i,this._deltaMetricStorage=new Ac(t,this._aggregationCardinalityLimit),this._temporalMetricStorage=new jc(t,r),this._attributesProcessor=n}record(e,t,n,r){t=this._attributesProcessor.process(t,n),this._deltaMetricStorage.record(e,t,n,r)}collect(e,t){let n=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(e,this._instrumentDescriptor,n,t)}};F();var Kc=class{process(e,t){return e}},qc=class{constructor(e){P(this,`_processors`,void 0),this._processors=e}process(e,t){let n=e;for(let e of this._processors)n=e.process(n,t);return n}};function Jc(){return Xc}function Yc(e){return new qc(e)}var Xc=new Kc;F(),H();var Zc=class{constructor(e,t){P(this,`metricStorageRegistry`,new Bc),P(this,`observableRegistry`,new Wc),P(this,`meter`,void 0),P(this,`_meterProviderSharedState`,void 0),P(this,`_instrumentationScope`,void 0),this.meter=new Ec(this),this._meterProviderSharedState=e,this._instrumentationScope=t}registerMetricStorage(e){let t=this._registerMetricStorage(e,Gc);return t.length===1?t[0]:new Vc(t)}registerAsyncMetricStorage(e){return this._registerMetricStorage(e,Nc)}collect(e,t,n){var r=this;return V(function*(){let i=yield r.observableRegistry.observe(t,n==null?void 0:n.timeoutMillis),a=r.metricStorageRegistry.getStorages(e);if(a.length===0)return null;let o=[];return a.forEach(n=>{let r=n.collect(e,t);r!=null&&o.push(r)}),o.length===0?{errors:i}:{scopeMetrics:{scope:r._instrumentationScope,metrics:o},errors:i}})()}_registerMetricStorage(e,t){let n=this._meterProviderSharedState.viewRegistry.findViews(e,this._instrumentationScope).map(n=>{let r=fc(n,e),i=this.metricStorageRegistry.findOrUpdateCompatibleStorage(r);if(i!=null)return i;let a=new t(r,n.aggregation.createAggregator(r),n.attributesProcessor,this._meterProviderSharedState.metricCollectors,n.aggregationCardinalityLimit);return this.metricStorageRegistry.register(a),a});if(n.length===0){let r=this._meterProviderSharedState.selectAggregations(e.type).map(([n,r])=>{let i=this.metricStorageRegistry.findOrUpdateCompatibleCollectorStorage(n,e);if(i!=null)return i;let a=r.createAggregator(e),o=n.selectCardinalityLimit(e.type),s=new t(e,a,Jc(),[n],o);return this.metricStorageRegistry.registerForCollector(n,s),s});n=n.concat(r)}return n}};F();var Qc=class{constructor(e){P(this,`viewRegistry`,new uc),P(this,`metricCollectors`,[]),P(this,`meterSharedStates`,new Map),P(this,`resource`,void 0),this.resource=e}getMeterSharedState(e){let t=Ko(e),n=this.meterSharedStates.get(t);return n==null&&(n=new Zc(this,e),this.meterSharedStates.set(t,n)),n}selectAggregations(e){let t=[];for(let n of this.metricCollectors)t.push([n,Gs(n.selectAggregation(e))]);return t}};B(),F(),H();var $c=class{constructor(e,t){P(this,`_sharedState`,void 0),P(this,`_metricReader`,void 0),this._sharedState=e,this._metricReader=t}collect(e){var t=this;return V(function*(){let n=ra(Date.now()),r=[],i=[],a=Array.from(t._sharedState.meterSharedStates.values()).map(function(){var a=V(function*(a){let o=yield a.collect(t,n,e);(o==null?void 0:o.scopeMetrics)!=null&&r.push(o.scopeMetrics),(o==null?void 0:o.errors)!=null&&i.push(...o.errors)});return function(e){return a.apply(this,arguments)}}());return yield Promise.all(a),{resourceMetrics:{resource:t._sharedState.resource,scopeMetrics:r},errors:i}})()}forceFlush(e){var t=this;return V(function*(){yield t._metricReader.forceFlush(e)})()}shutdown(e){var t=this;return V(function*(){yield t._metricReader.shutdown(e)})()}selectAggregationTemporality(e){return this._metricReader.selectAggregationTemporality(e)}selectAggregation(e){return this._metricReader.selectAggregation(e)}selectCardinalityLimit(e){var t,n,r;return(t=(n=(r=this._metricReader).selectCardinalityLimit)==null?void 0:n.call(r,e))==null?2e3:t}};F();var el=/[\^$\\.+?()[\]{}|]/g,tl=class e{constructor(t){P(this,`_matchAll`,void 0),P(this,`_regexp`,void 0),t===`*`?(this._matchAll=!0,this._regexp=/.*/):(this._matchAll=!1,this._regexp=new RegExp(e.escapePattern(t)))}match(e){return this._matchAll?!0:this._regexp.test(e)}static escapePattern(e){return`^${e.replace(el,`\\$&`).replace(`*`,`.*`)}$`}static hasWildcard(e){return e.includes(`*`)}},nl=class{constructor(e){P(this,`_matchAll`,void 0),P(this,`_pattern`,void 0),this._matchAll=e===void 0,this._pattern=e}match(e){return!!(this._matchAll||e===this._pattern)}};F();var rl=class{constructor(e){var t;P(this,`_nameFilter`,void 0),P(this,`_type`,void 0),P(this,`_unitFilter`,void 0),this._nameFilter=new tl((t=e==null?void 0:e.name)==null?`*`:t),this._type=e==null?void 0:e.type,this._unitFilter=new nl(e==null?void 0:e.unit)}getType(){return this._type}getNameFilter(){return this._nameFilter}getUnitFilter(){return this._unitFilter}};F();var il=class{constructor(e){P(this,`_nameFilter`,void 0),P(this,`_versionFilter`,void 0),P(this,`_schemaUrlFilter`,void 0),this._nameFilter=new nl(e==null?void 0:e.name),this._versionFilter=new nl(e==null?void 0:e.version),this._schemaUrlFilter=new nl(e==null?void 0:e.schemaUrl)}getNameFilter(){return this._nameFilter}getVersionFilter(){return this._versionFilter}getSchemaUrlFilter(){return this._schemaUrlFilter}};F();function al(e){return e.instrumentName==null&&e.instrumentType==null&&e.instrumentUnit==null&&e.meterName==null&&e.meterVersion==null&&e.meterSchemaUrl==null}function ol(e){if(al(e))throw Error(`Cannot create view with no selector arguments supplied`);if(e.name!=null&&((e==null?void 0:e.instrumentName)==null||tl.hasWildcard(e.instrumentName)))throw Error(`Views with a specified name must be declared with an instrument selector that selects at most one instrument per meter.`)}var sl=class{constructor(e){var t;P(this,`name`,void 0),P(this,`description`,void 0),P(this,`aggregation`,void 0),P(this,`attributesProcessor`,void 0),P(this,`instrumentSelector`,void 0),P(this,`meterSelector`,void 0),P(this,`aggregationCardinalityLimit`,void 0),ol(e),e.attributesProcessors==null?this.attributesProcessor=Jc():this.attributesProcessor=Yc(e.attributesProcessors),this.name=e.name,this.description=e.description,this.aggregation=Gs((t=e.aggregation)==null?{type:Ws.DEFAULT}:t),this.instrumentSelector=new rl({name:e.instrumentName,type:e.instrumentType,unit:e.instrumentUnit}),this.meterSelector=new il({name:e.meterName,version:e.meterVersion,schemaUrl:e.meterSchemaUrl}),this.aggregationCardinalityLimit=e.aggregationCardinalityLimit}};N(),lc(),F(),H();var cl=class{constructor(e){var t;if(P(this,`_sharedState`,void 0),P(this,`_shutdown`,!1),this._sharedState=new Qc((t=e==null?void 0:e.resource)==null?rc():t),(e==null?void 0:e.views)!=null&&e.views.length>0)for(let t of e.views)this._sharedState.viewRegistry.addView(new sl(t));if((e==null?void 0:e.readers)!=null&&e.readers.length>0)for(let t of e.readers){let e=new $c(this._sharedState,t);t.setMetricProducer(e),this._sharedState.metricCollectors.push(e)}}getMeter(e,t=``,n={}){return this._shutdown?(j.warn(`A shutdown MeterProvider cannot provide a Meter`),le()):this._sharedState.getMeterSharedState({name:e,version:t,schemaUrl:n.schemaUrl}).meter}shutdown(e){var t=this;return V(function*(){if(t._shutdown){j.warn(`shutdown may only be called once per MeterProvider`);return}t._shutdown=!0,yield Promise.all(t._sharedState.metricCollectors.map(t=>t.shutdown(e)))})()}forceFlush(e){var t=this;return V(function*(){if(t._shutdown){j.warn(`invalid attempt to force flush after MeterProvider shutdown`);return}yield Promise.all(t._sharedState.metricCollectors.map(t=>t.forceFlush(e)))})()}},ll;(function(e){e[e.AGGREGATION_TEMPORALITY_UNSPECIFIED=0]=`AGGREGATION_TEMPORALITY_UNSPECIFIED`,e[e.AGGREGATION_TEMPORALITY_DELTA=1]=`AGGREGATION_TEMPORALITY_DELTA`,e[e.AGGREGATION_TEMPORALITY_CUMULATIVE=2]=`AGGREGATION_TEMPORALITY_CUMULATIVE`})(ll||(ll={}));function ul(e,t){let n={attributes:fl(e.attributes,t),droppedAttributesCount:0},r=e.schemaUrl;return r&&r!==``&&(n.schemaUrl=r),n}function dl(e){return{name:e.name,version:e.version}}function fl(e,t){return Object.keys(e).map(n=>pl(n,e[n],t))}function pl(e,t,n){return{key:e,value:ml(t,n)}}function ml(e,t){let n=typeof e;if(n===`string`)return{stringValue:e};if(n===`number`)return Number.isInteger(e)?{intValue:e}:{doubleValue:e};if(n===`boolean`)return{boolValue:e};if(e instanceof Uint8Array)return{bytesValue:t.encodeUint8Array(e)};if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=ml(e[r],t);return{arrayValue:{values:n}}}if(n===`object`&&e!=null){let n=Object.keys(e),r=Array(n.length);for(let i=0;i<n.length;i++)r[i]={key:n[i],value:ml(e[n[i]],t)};return{kvlistValue:{values:r}}}return{}}N();function hl(e,t){let n=ul(e.resource,t);return{resource:n,schemaUrl:n.schemaUrl,scopeMetrics:gl(e.scopeMetrics,t)}}function gl(e,t){return Array.from(e.map(e=>({scope:dl(e.scope),metrics:e.metrics.map(e=>_l(e,t)),schemaUrl:e.scope.schemaUrl})))}function _l(e,t){let n={name:e.descriptor.name,description:e.descriptor.description,unit:e.descriptor.unit},r=Sl(e.aggregationTemporality);switch(e.dataPointType){case Wo.SUM:n.sum={aggregationTemporality:r,isMonotonic:e.isMonotonic,dataPoints:yl(e,t)};break;case Wo.GAUGE:n.gauge={dataPoints:yl(e,t)};break;case Wo.HISTOGRAM:n.histogram={aggregationTemporality:r,dataPoints:bl(e,t)};break;case Wo.EXPONENTIAL_HISTOGRAM:n.exponentialHistogram={aggregationTemporality:r,dataPoints:xl(e,t)};break}return n}function vl(e,t,n){let r={attributes:fl(e.attributes,n),startTimeUnixNano:n.encodeHrTime(e.startTime),timeUnixNano:n.encodeHrTime(e.endTime)};switch(t){case ke.INT:r.asInt=e.value;break;case ke.DOUBLE:r.asDouble=e.value;break}return r}function yl(e,t){return e.dataPoints.map(n=>vl(n,e.descriptor.valueType,t))}function bl(e,t){return e.dataPoints.map(e=>{let n=e.value;return{attributes:fl(e.attributes,t),bucketCounts:n.buckets.counts,explicitBounds:n.buckets.boundaries,count:n.count,sum:n.sum,min:n.min,max:n.max,startTimeUnixNano:t.encodeHrTime(e.startTime),timeUnixNano:t.encodeHrTime(e.endTime)}})}function xl(e,t){return e.dataPoints.map(e=>{let n=e.value;return{attributes:fl(e.attributes,t),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:t.encodeHrTime(e.startTime),timeUnixNano:t.encodeHrTime(e.endTime)}})}function Sl(e){switch(e){case Uo.DELTA:return ll.AGGREGATION_TEMPORALITY_DELTA;case Uo.CUMULATIVE:return ll.AGGREGATION_TEMPORALITY_CUMULATIVE}}function Cl(e,t){return{resourceMetrics:e.map(e=>hl(e,t))}}B();function wl(e){let t=BigInt(1e9);return BigInt(Math.trunc(e[0]))*t+BigInt(Math.trunc(e[1]))}function Tl(e){return wl(e).toString()}var El=typeof BigInt<`u`?Tl:sa;function Dl(e){return e}var Ol={encodeHrTime:El,encodeSpanContext:Dl,encodeOptionalSpanContext:Dl,encodeUint8Array:e=>{if(typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let t=Array(e.length);for(let n=0;n<e.length;n++)t[n]=String.fromCharCode(e[n]);return btoa(t.join(``))}};function kl(e,t){return{resourceLogs:jl(e,t)}}function Al(e){let t=new Map;for(let n of e){let{resource:e,instrumentationScope:{name:r,version:i=``,schemaUrl:a=``}}=n,o=t.get(e);o||(o=new Map,t.set(e,o));let s=`${r}@${i}:${a}`,c=o.get(s);c||(c=[],o.set(s,c)),c.push(n)}return t}function jl(e,t){let n=Al(e);return Array.from(n,([e,n])=>{let r=ul(e,t);return{resource:r,scopeLogs:Array.from(n,([,e])=>({scope:dl(e[0].instrumentationScope),logRecords:e.map(e=>Ml(e,t)),schemaUrl:e[0].instrumentationScope.schemaUrl})),schemaUrl:r.schemaUrl}})}function Ml(e,t){var n,r,i;return{timeUnixNano:t.encodeHrTime(e.hrTime),observedTimeUnixNano:t.encodeHrTime(e.hrTimeObserved),severityNumber:Nl(e.severityNumber),severityText:e.severityText,body:ml(e.body,t),eventName:e.eventName,attributes:Pl(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,flags:(n=e.spanContext)==null?void 0:n.traceFlags,traceId:t.encodeOptionalSpanContext((r=e.spanContext)==null?void 0:r.traceId),spanId:t.encodeOptionalSpanContext((i=e.spanContext)==null?void 0:i.spanId)}}function Nl(e){return e}function Pl(e,t){return Object.keys(e).map(n=>pl(n,e[n],t))}N();var Fl={serializeRequest:e=>{let t=kl(e,Ol);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(e){return j.warn(`Failed to parse logs export response: ${e.message}. Returning empty response`),{}}}};N();var Il={serializeRequest:e=>{let t=Cl([e],Ol);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(e){return j.warn(`Failed to parse metrics export response: ${e.message}. Returning empty response`),{}}}},Ll=256,Rl=512;function zl(e,t){let n=e&255|Ll;return t&&(n|=Rl),n}function Bl(e,t){var n,r,i,a;let o=e.spanContext(),s=e.status,c=(n=e.parentSpanContext)!=null&&n.spanId?t.encodeSpanContext((r=e.parentSpanContext)==null?void 0:r.spanId):void 0;return{traceId:t.encodeSpanContext(o.traceId),spanId:t.encodeSpanContext(o.spanId),parentSpanId:c,traceState:(i=o.traceState)==null?void 0:i.serialize(),name:e.name,kind:e.kind==null?0:e.kind+1,startTimeUnixNano:t.encodeHrTime(e.startTime),endTimeUnixNano:t.encodeHrTime(e.endTime),attributes:fl(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(e=>Hl(e,t)),droppedEventsCount:e.droppedEventsCount,status:{code:s.code,message:s.message},links:e.links.map(e=>Vl(e,t)),droppedLinksCount:e.droppedLinksCount,flags:zl(o.traceFlags,(a=e.parentSpanContext)==null?void 0:a.isRemote)}}function Vl(e,t){var n;return{attributes:e.attributes?fl(e.attributes,t):[],spanId:t.encodeSpanContext(e.context.spanId),traceId:t.encodeSpanContext(e.context.traceId),traceState:(n=e.context.traceState)==null?void 0:n.serialize(),droppedAttributesCount:e.droppedAttributesCount||0,flags:zl(e.context.traceFlags,e.context.isRemote)}}function Hl(e,t){return{attributes:e.attributes?fl(e.attributes,t):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function Ul(e,t){return{resourceSpans:Gl(e,t)}}function Wl(e){let t=new Map;for(let n of e){let e=t.get(n.resource);e||(e=new Map,t.set(n.resource,e));let r=`${n.instrumentationScope.name}@${n.instrumentationScope.version||``}:${n.instrumentationScope.schemaUrl||``}`,i=e.get(r);i||(i=[],e.set(r,i)),i.push(n)}return t}function Gl(e,t){let n=Wl(e),r=[],i=n.entries(),a=i.next();for(;!a.done;){let[e,n]=a.value,o=[],s=n.values(),c=s.next();for(;!c.done;){let e=c.value;if(e.length>0){let n=e.map(e=>Bl(e,t));o.push({scope:dl(e[0].instrumentationScope),spans:n,schemaUrl:e[0].instrumentationScope.schemaUrl})}c=s.next()}let l=ul(e,t),u={resource:l,scopeSpans:o,schemaUrl:l.schemaUrl};r.push(u),a=i.next()}return r}N();var Kl={serializeRequest:e=>{let t=Ul(e,Ol);return new TextEncoder().encode(JSON.stringify(t))},deserializeResponse:e=>{if(e.length===0)return{};let t=new TextDecoder;try{return JSON.parse(t.decode(e))}catch(e){return j.warn(`Failed to parse trace export response: ${e.message}. Returning empty response`),{}}}};N(),F(),H();var ql=5,Jl=1e3,Yl=5e3,Xl=1.5,Zl=.2;function Ql(){return 2*Zl*Math.random()-Zl}var $l=class{constructor(e){P(this,`_transport`,void 0),this._transport=e}retry(e,t,n){return new Promise((r,i)=>{setTimeout(()=>{this._transport.send(e,t).then(r,i)},n)})}send(e,t){var n=this;return V(function*(){let r=ql,i=Jl,a=Date.now()+t,o=yield n._transport.send(e,t);for(;o.status===`retryable`&&r>0;){var s;r--;let t=Math.max(Math.min(i*(1+Ql()),Yl),0);i*=Xl;let c=(s=o.retryInMillis)==null?t:s,l=a-Date.now();if(c>l)return j.info(`Export retry time ${Math.round(c)}ms exceeds remaining timeout ${Math.round(l)}ms, not retrying further.`),o;j.verbose(`Scheduling export retry in ${Math.round(c)}ms`),o=yield n.retry(e,l,c)}return o.status===`success`?j.verbose(`Export succeeded after ${ql-r} retry attempts.`):o.status===`retryable`?j.info(`Export failed after maximum retry attempts (${ql}).`):j.info(`Export failed with non-retryable error: ${o.error}`),o})()}shutdown(){return this._transport.shutdown()}};function eu(e){return new $l(e.transport)}function tu(e){return e===429||e===502||e===503||e===504}function nu(e){if(e==null)return;let t=Number.parseInt(e,10);if(Number.isInteger(t))return t>0?t*1e3:-1;let n=new Date(e).getTime()-Date.now();return n>=0?n:0}N(),F(),H();var ru=60*1024,iu=9,au=0,ou=0,su=class{constructor(e){P(this,`_parameters`,void 0),this._parameters=e}send(e,t){var n=this;return V(function*(){let r=new AbortController,i=setTimeout(()=>r.abort(),t),a=globalThis.fetch;typeof a.__original==`function`&&(a=a.__original);let o=e.byteLength,s=au+o>ru,c=!s&&!(ou>=iu);if(c)au+=o,ou++;else{let e=s?`size limit`:`count limit`;j.debug(`keepalive disabled: ${(o/1024).toFixed(1)}KB payload, ${ou} pending (${e})`)}try{let t=new URL(n._parameters.url),i=yield a(t.href,{method:`POST`,headers:yield n._parameters.headers(),body:e,signal:r.signal,keepalive:c,mode:globalThis.location?globalThis.location.origin===t.origin?`same-origin`:`cors`:`no-cors`});return i.status>=200&&i.status<=299?(j.debug(`export response success (status: ${i.status})`),{status:`success`}):tu(i.status)?(j.warn(`export response retryable (status: ${i.status})`),{status:`retryable`,retryInMillis:nu(i.headers.get(`Retry-After`))}):(j.error(`export response failure (status: ${i.status})`),{status:`failure`,error:Error(`Fetch request failed with non-retryable status ${i.status}`)})}catch(e){return lu(e)?(j.warn(`export request retryable (network error: ${e})`),{status:`retryable`,error:Error(`Fetch request encountered a network error`,{cause:e})}):(j.error(`export request failure (error: ${e})`),{status:`failure`,error:Error(`Fetch request errored`,{cause:e})})}finally{clearTimeout(i),c&&(au-=o,ou--)}})()}shutdown(){}};function cu(e){return new su(e)}function lu(e){return e instanceof TypeError&&!e.cause}function uu(e,t){return Ho(e,t,eu({transport:cu(e)}))}N();function du(e){let t={};return Object.entries(e==null?{}:e).forEach(([e,n])=>{n===void 0?j.warn(`Header "${e}" has invalid value (${n}) and will be ignored`):t[e]=String(n)}),t}G(),H();function fu(e,t,n){return V(function*(){let r=W({},yield n()),i={};return t!=null&&Object.assign(i,yield t()),e!=null&&Object.assign(i,du(yield e())),Object.assign(i,r)})}function pu(e){if(e!=null)try{var t;let n=(t=globalThis.location)==null?void 0:t.href;return new URL(e,n).href}catch(t){throw Error(`Configuration: Could not parse user-provided export URL: '${e}'`)}}function mu(e,t,n){var r,i;return W(W({},Po(e,t,n)),{},{headers:fu(e.headers,t.headers,n.headers),url:(r=(i=pu(e.url))==null?t.url:i)==null?n.url:r})}function hu(e,t){return W(W({},Fo()),{},{headers:function(){var t=V(function*(){return e});return function(){return t.apply(this,arguments)}}(),url:`http://localhost:4318/`+t})}function gu(e){return typeof e.headers==`function`?e.headers:No(e.headers)}function _u(e,t,n){return mu({url:e.url,timeoutMillis:e.timeoutMillis,headers:gu(e),concurrencyLimit:e.concurrencyLimit},{},hu(n,t))}function vu(e,t,n,r){return uu(_u(e,n,r),t)}var yu=class extends ko{constructor(e={}){super(vu(e,Fl,`v1/logs`,{"Content-Type":`application/json`}))}},bu;(function(e){e[e.DELTA=0]=`DELTA`,e[e.CUMULATIVE=1]=`CUMULATIVE`,e[e.LOWMEMORY=2]=`LOWMEMORY`})(bu||(bu={})),B(),N(),F();var xu=()=>Uo.CUMULATIVE,Su=e=>{switch(e){case U.COUNTER:case U.OBSERVABLE_COUNTER:case U.GAUGE:case U.HISTOGRAM:case U.OBSERVABLE_GAUGE:return Uo.DELTA;case U.UP_DOWN_COUNTER:case U.OBSERVABLE_UP_DOWN_COUNTER:return Uo.CUMULATIVE}},Cu=e=>{switch(e){case U.COUNTER:case U.HISTOGRAM:return Uo.DELTA;case U.GAUGE:case U.UP_DOWN_COUNTER:case U.OBSERVABLE_UP_DOWN_COUNTER:case U.OBSERVABLE_COUNTER:case U.OBSERVABLE_GAUGE:return Uo.CUMULATIVE}};function wu(){var e;let t=((e=void 0)==null?`cumulative`:e).toLowerCase();return t===`cumulative`?xu:t===`delta`?Su:t===`lowmemory`?Cu:(j.warn(`OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE is set to '${t}', but only 'cumulative' and 'delta' are allowed. Using default ('cumulative') instead.`),xu)}function Tu(e){return e==null?wu():e===bu.DELTA?Su:e===bu.LOWMEMORY?Cu:xu}var Eu=Object.freeze({type:Ws.DEFAULT});function Du(e){var t;return(t=e==null?void 0:e.aggregationPreference)==null?(()=>Eu):t}var Ou=class extends ko{constructor(e,t){super(e),P(this,`_aggregationTemporalitySelector`,void 0),P(this,`_aggregationSelector`,void 0),this._aggregationSelector=Du(t),this._aggregationTemporalitySelector=Tu(t==null?void 0:t.temporalityPreference)}selectAggregation(e){return this._aggregationSelector(e)}selectAggregationTemporality(e){return this._aggregationTemporalitySelector(e)}},ku=class extends Ou{constructor(e){super(vu(e==null?{}:e,Il,`v1/metrics`,{"Content-Type":`application/json`}),e)}},Au=class extends ko{constructor(e={}){super(vu(e,Kl,`v1/traces`,{"Content-Type":`application/json`}))}};function ju(e,t,n,r){for(let i=0,a=e.length;i<a;i++){let a=e[i];t&&a.setTracerProvider(t),n&&a.setMeterProvider(n),r&&a.setLoggerProvider&&a.setLoggerProvider(r),a.getConfig().enabled||a.enable()}}function Mu(e){e.forEach(e=>e.disable())}var Nu=t((()=>{}));function Pu(e){var t,n;let r=e.tracerProvider||M.getTracerProvider(),i=e.meterProvider||Pt.getMeterProvider(),a=e.loggerProvider||yn.getLoggerProvider(),o=(t=(n=e.instrumentations)==null?void 0:n.flat())==null?[]:t;return ju(o,r,i,a),()=>{Mu(o)}}var Fu=t((()=>{N(),Nu()}));function Iu(e,t,n){let r=!!e[t]&&Object.prototype.propertyIsEnumerable.call(e,t);Object.defineProperty(e,t,{configurable:!0,enumerable:r,writable:!0,value:n})}function Lu(e){e&&e.logger&&(typeof e.logger==`function`?K=e.logger:K(`new logger isn't a function, not replacing`))}var K,Ru,zu,Bu,Vu,Hu=t((()=>{K=console.error.bind(console),Ru=(e,t,n)=>{if(!e||!e[t]){K(`no original function `+String(t)+` to wrap`);return}if(!n){K(`no wrapper function`),K(Error().stack);return}let r=e[t];if(typeof r!=`function`||typeof n!=`function`){K(`original object and wrapper must be functions`);return}let i=n(r,t);return Iu(i,`__original`,r),Iu(i,`__unwrap`,()=>{e[t]===i&&Iu(e,t,r)}),Iu(i,`__wrapped`,!0),Iu(e,t,i),i},zu=(e,t,n)=>{if(e)Array.isArray(e)||(e=[e]);else{K(`must provide one or more modules to patch`),K(Error().stack);return}if(!(t&&Array.isArray(t))){K(`must provide one or more functions to wrap on modules`);return}e.forEach(e=>{t.forEach(t=>{Ru(e,t,n)})})},Bu=(e,t)=>{if(!e||!e[t]){K(`no function to unwrap.`),K(Error().stack);return}let n=e[t];if(!n.__unwrap)K(`no original to unwrap to -- has `+String(t)+` already been unwrapped?`);else{n.__unwrap();return}},Vu=(e,t)=>{if(e)Array.isArray(e)||(e=[e]);else{K(`must provide one or more modules to patch`),K(Error().stack);return}if(!(t&&Array.isArray(t))){K(`must provide one or more functions to unwrap on modules`);return}e.forEach(e=>{t.forEach(t=>{Bu(e,t)})})},Lu.wrap=Ru,Lu.massWrap=zu,Lu.unwrap=Bu,Lu.massUnwrap=Vu})),Uu,Wu=t((()=>{N(),bn(),Hu(),F(),G(),Uu=class{constructor(e,t,n){P(this,`_config`,{}),P(this,`_tracer`,void 0),P(this,`_meter`,void 0),P(this,`_logger`,void 0),P(this,`_diag`,void 0),P(this,`instrumentationName`,void 0),P(this,`instrumentationVersion`,void 0),P(this,`_wrap`,Ru),P(this,`_unwrap`,Bu),P(this,`_massWrap`,zu),P(this,`_massUnwrap`,Vu),this.instrumentationName=e,this.instrumentationVersion=t,this.setConfig(n),this._diag=j.createComponentLogger({namespace:e}),this._tracer=M.getTracer(e,t),this._meter=Pt.getMeter(e,t),this._logger=yn.getLogger(e,t),this._updateMetricInstruments()}get meter(){return this._meter}setMeterProvider(e){this._meter=e.getMeter(this.instrumentationName,this.instrumentationVersion),this._updateMetricInstruments()}get logger(){return this._logger}setLoggerProvider(e){this._logger=e.getLogger(this.instrumentationName,this.instrumentationVersion)}getModuleDefinitions(){var e;let t=(e=this.init())==null?[]:e;return Array.isArray(t)?t:[t]}_updateMetricInstruments(){}getConfig(){return this._config}setConfig(e){this._config=W({enabled:!0},e)}setTracerProvider(e){this._tracer=e.getTracer(this.instrumentationName,this.instrumentationVersion)}get tracer(){return this._tracer}_runSpanCustomizationHook(e,t,n,r){if(e)try{e(n,r)}catch(e){this._diag.error(`Error running span customization hook due to exception in handler`,{triggerName:t},e)}}}})),Gu,Ku=t((()=>{Wu(),Gu=class extends Uu{constructor(e,t,n){super(e,t,n),this._config.enabled&&this.enable()}}})),qu=t((()=>{Ku(),N()}));function Ju(e,t,n){let r,i;try{i=e()}catch(e){r=e}finally{if(t(r,i),r&&!n)throw r;return i}}var Yu=t((()=>{}));function Xu(e,t){let n=q.OLD,r=t==null?void 0:t.split(`,`).map(e=>e.trim()).filter(e=>e!==``);for(let t of r==null?[]:r)if(t.toLowerCase()===e+`/dup`){n=q.DUPLICATE;break}else t.toLowerCase()===e&&(n=q.STABLE);return n}var q,Zu=t((()=>{(function(e){e[e.STABLE=1]=`STABLE`,e[e.OLD=2]=`OLD`,e[e.DUPLICATE=3]=`DUPLICATE`})(q||(q={}))})),Qu=t((()=>{Fu(),qu(),F(),Yu(),Zu()}));function $u(e){return ed(e,new WeakSet)}function ed(e,t){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||e instanceof Uint8Array)return!0;if(typeof e==`object`){if(t.has(e))return!1;if(t.add(e),Array.isArray(e))return e.every(e=>ed(e,t));let n=e;return n.constructor!==Object&&n.constructor!==void 0?!1:Object.values(n).every(e=>ed(e,t))}return!1}N(),B(),Zi(),F();var td=class{set severityText(e){this._isLogRecordReadonly()||(this._severityText=e)}get severityText(){return this._severityText}set severityNumber(e){this._isLogRecordReadonly()||(this._severityNumber=e)}get severityNumber(){return this._severityNumber}set body(e){this._isLogRecordReadonly()||(this._body=e)}get body(){return this._body}get eventName(){return this._eventName}set eventName(e){this._isLogRecordReadonly()||(this._eventName=e)}get droppedAttributesCount(){return this._droppedAttributesCount}constructor(e,t,n){P(this,`hrTime`,void 0),P(this,`hrTimeObserved`,void 0),P(this,`spanContext`,void 0),P(this,`resource`,void 0),P(this,`instrumentationScope`,void 0),P(this,`attributes`,{}),P(this,`_severityText`,void 0),P(this,`_severityNumber`,void 0),P(this,`_body`,void 0),P(this,`_eventName`,void 0),P(this,`_attributesCount`,0),P(this,`_droppedAttributesCount`,0),P(this,`_isReadonly`,!1),P(this,`_logRecordLimits`,void 0);let{timestamp:r,observedTimestamp:i,eventName:a,severityNumber:o,severityText:s,body:c,attributes:l={},exception:u,context:d}=n,f=Date.now();if(this.hrTime=aa(r==null?f:r),this.hrTimeObserved=aa(i==null?f:i),d){let e=M.getSpanContext(d);e&&it(e)&&(this.spanContext=e)}this.severityNumber=o,this.severityText=s,this.body=c,this.resource=e.resource,this.instrumentationScope=t,this._logRecordLimits=e.logRecordLimits,this._eventName=a,this.setAttributes(l),u!=null&&this._setException(u)}setAttribute(e,t){if(this._isLogRecordReadonly())return this;if(e.length===0)return j.warn(`Invalid attribute key: ${e}`),this;if(!$u(t))return j.warn(`Invalid attribute value set for key: ${e}`),this;let n=!Object.prototype.hasOwnProperty.call(this.attributes,e);return n&&this._attributesCount>=this._logRecordLimits.attributeCountLimit?(this._droppedAttributesCount++,this._droppedAttributesCount===1&&j.warn(`Dropping extra attributes.`),this):(this.attributes[e]=this._truncateToSize(t),n&&this._attributesCount++,this)}setAttributes(e){for(let[t,n]of Object.entries(e))this.setAttribute(t,n);return this}setBody(e){return this.body=e,this}setEventName(e){return this.eventName=e,this}setSeverityNumber(e){return this.severityNumber=e,this}setSeverityText(e){return this.severityText=e,this}_makeReadonly(){this._isReadonly=!0}_truncateToSize(e){let t=this._logRecordLimits.attributeValueLengthLimit;if(t<=0)return j.warn(`Attribute value limit must be positive, got ${t}`),e;if(e==null)return e;if(typeof e==`string`)return this._truncateToLimitUtil(e,t);if(e instanceof Uint8Array)return e;if(Array.isArray(e))return e.map(e=>this._truncateToSize(e));if(typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=this._truncateToSize(r);return t}return e}_setException(e){let t=!1;if(typeof e==`string`||typeof e==`number`)Object.hasOwn(this.attributes,`exception.message`)||this.setAttribute(Ni,String(e)),t=!0;else if(e&&typeof e==`object`){let n=e;n.code?(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(Fi,n.code.toString()),t=!0):n.name&&(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(Fi,n.name),t=!0),n.message&&(Object.hasOwn(this.attributes,`exception.message`)||this.setAttribute(Ni,n.message),t=!0),n.stack&&(Object.hasOwn(this.attributes,`exception.stacktrace`)||this.setAttribute(Pi,n.stack),t=!0)}t||j.warn(`Failed to record an exception ${e}`)}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_isLogRecordReadonly(){return this._isReadonly&&j.warn(`Can not execute the operation on emitted log record`),this._isReadonly}};bn(),N(),F(),G();var nd=class{constructor(e,t){P(this,`instrumentationScope`,void 0),P(this,`_sharedState`,void 0),P(this,`_loggerConfig`,void 0),this.instrumentationScope=e,this._sharedState=t,this._loggerConfig=this._sharedState.getLoggerConfig(this.instrumentationScope)}emit(e){var t;let n=this._loggerConfig,r=e.context||A.active(),i=(t=e.severityNumber)==null?en.UNSPECIFIED:t;if(i!==en.UNSPECIFIED&&i<n.minimumSeverity)return;if(n.traceBased){let e=M.getSpanContext(r);if(e&&it(e)&&(e.traceFlags&k.SAMPLED)!==k.SAMPLED)return}let a=new td(this._sharedState,this.instrumentationScope,W({context:r},e));this._sharedState.loggerMetrics.emitLog(),this._sharedState.activeProcessor.onEmit(a,r),a._makeReadonly()}enabled(e){let t=this._loggerConfig;if(t.disabled)return!1;let n=e==null?void 0:e.severityNumber;if(typeof n==`number`&&n!==en.UNSPECIFIED&&n<t.minimumSeverity)return!1;let r=(e==null?void 0:e.context)||A.active();if(t.traceBased){let e=M.getSpanContext(r);if(e&&it(e)&&(e.traceFlags&k.SAMPLED)!==k.SAMPLED)return!1}let i={context:r,instrumentationScope:this.instrumentationScope,severityNumber:e==null?void 0:e.severityNumber,eventName:e==null?void 0:e.eventName};for(let e of this._sharedState.processors)if(!e.enabled||e.enabled(i))return!0;return!1}},rd=class{forceFlush(){return Promise.resolve()}onEmit(e,t){}shutdown(){return Promise.resolve()}enabled(e){return!1}};B(),F(),H();var id=class{constructor(e,t){P(this,`processors`,void 0),P(this,`forceFlushTimeoutMillis`,void 0),this.processors=e,this.forceFlushTimeoutMillis=t}forceFlush(){var e=this;return V(function*(){let t=e.forceFlushTimeoutMillis;yield Promise.all(e.processors.map(e=>go(e.forceFlush(),t)))})()}onEmit(e,t){this.processors.forEach(n=>n.onEmit(e,t))}shutdown(){var e=this;return V(function*(){yield Promise.all(e.processors.map(e=>e.shutdown()))})()}enabled(e){for(let t of this.processors)if(!t.enabled||t.enabled(e))return!0;return!1}};function ad(e){return`${e.name}@${e.version||``}:${e.schemaUrl||``}`}var od=`otel.sdk.log.created`;F();var sd=class{constructor(e){P(this,`createdLogs`,void 0),this.createdLogs=e.createCounter(od,{unit:`{log_record}`,description:`The number of logs submitted to enabled SDK Loggers.`})}emitLog(){this.createdLogs.add(1)}},cd=`0.217.0`;N(),bn(),G(),F();var ld={disabled:!1,minimumSeverity:en.UNSPECIFIED,traceBased:!1},ud=()=>W({},ld),dd=class{constructor(e,t,n,r,i,a){P(this,`loggers`,new Map),P(this,`activeProcessor`,void 0),P(this,`registeredLogRecordProcessors`,[]),P(this,`resource`,void 0),P(this,`forceFlushTimeoutMillis`,void 0),P(this,`logRecordLimits`,void 0),P(this,`processors`,void 0),P(this,`loggerMetrics`,void 0),P(this,`_loggerConfigurator`,void 0),P(this,`_loggerConfigs`,new Map),this.resource=e,this.forceFlushTimeoutMillis=t,this.logRecordLimits=n,this.processors=r,r.length>0?(this.registeredLogRecordProcessors=r,this.activeProcessor=new id(this.registeredLogRecordProcessors,this.forceFlushTimeoutMillis)):this.activeProcessor=new rd,this._loggerConfigurator=i==null?ud:i;let o=a?a.getMeter(`@opentelemetry/sdk-logs`,cd):le();this.loggerMetrics=new sd(o)}getLoggerConfig(e){let t=ad(e),n=this._loggerConfigs.get(t);return n||(n=this._loggerConfigurator(e),this._loggerConfigs.set(t,n),n)}};N(),bn(),lc(),B(),F();var fd=class{constructor(e={}){var t,n,r,i,a,o,s,c;P(this,`_shutdownOnce`,void 0),P(this,`_sharedState`,void 0);let l={resource:(t=e.resource)==null?rc():t,forceFlushTimeoutMillis:(n=e.forceFlushTimeoutMillis)==null?3e4:n,logRecordLimits:{attributeCountLimit:(r=(i=e.logRecordLimits)==null?void 0:i.attributeCountLimit)==null?128:r,attributeValueLengthLimit:(a=(o=e.logRecordLimits)==null?void 0:o.attributeValueLengthLimit)==null?1/0:a},loggerConfigurator:(s=e.loggerConfigurator)==null?ud:s,processors:(c=e.processors)==null?[]:c,meterProvider:e.meterProvider};this._sharedState=new dd(l.resource,l.forceFlushTimeoutMillis,l.logRecordLimits,l.processors,l.loggerConfigurator,l.meterProvider),this._shutdownOnce=new wo(this._shutdown,this)}getLogger(e,t,n){if(this._shutdownOnce.isCalled)return j.warn(`A shutdown LoggerProvider cannot provide a Logger`),rn;e||j.warn(`Logger requested without instrumentation scope name.`);let r=e||`unknown`,i=`${r}@${t||``}:${(n==null?void 0:n.schemaUrl)||``}`;return this._sharedState.loggers.has(i)||this._sharedState.loggers.set(i,new nd({name:r,version:t,schemaUrl:n==null?void 0:n.schemaUrl},this._sharedState)),this._sharedState.loggers.get(i)}forceFlush(){return this._shutdownOnce.isCalled?(j.warn(`invalid attempt to force flush after LoggerProvider shutdown`),this._shutdownOnce.promise):this._sharedState.activeProcessor.forceFlush()}shutdown(){return this._shutdownOnce.isCalled?(j.warn(`shutdown may only be called once per LoggerProvider`),this._shutdownOnce.promise):this._shutdownOnce.call()}_shutdown(){return this._sharedState.activeProcessor.shutdown()}};N(),B(),H(),F();function pd(e){return md.apply(this,arguments)}function md(){return md=V(function*(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];r.resource.asyncAttributesPending&&r.resource.waitForAsyncAttributes&&t.push(r.resource.waitForAsyncAttributes())}t!=null&&t.length>0&&(yield Promise.all(t))}),md.apply(this,arguments)}var hd=class{constructor(e,t,n){P(this,`_exportCompleted`,void 0),P(this,`_exportScheduledPromise`,void 0),P(this,`_exportScheduledResolve`,void 0),this._exportScheduledPromise=new Promise(e=>{this._exportScheduledResolve=e}),this._exportCompleted=this._executeExport(e,t,n)}get exportCompleted(){return this._exportCompleted}get exportScheduled(){return this._exportScheduledPromise}_executeExport(e,t,n){var r=this;return V(function*(){try{yield pd(t),yield A.with($r(A.active()),V(function*(){return r._exportWithTimeout(e,t,n)}))}catch(e){Si(e),r._exportScheduledResolve()}})()}_exportWithTimeout(e,t,n){var r=this;return V(function*(){return new Promise((i,a)=>{let o=setTimeout(()=>{a(Error(`Timeout`))},n);e.export(t,e=>{if(clearTimeout(o),e.code===ga.SUCCESS)i();else{var t;a((t=e.error)==null?Error(`BatchLogRecordProcessor: log record export failed`):t)}}),r._exportScheduledResolve()})})()}},gd=class{constructor(e,t){var n,r,i,a;P(this,`_maxExportBatchSize`,void 0),P(this,`_maxQueueSize`,void 0),P(this,`_scheduledDelayMillis`,void 0),P(this,`_exportTimeoutMillis`,void 0),P(this,`_exporter`,void 0),P(this,`_currentExport`,null),P(this,`_finishedLogRecords`,[]),P(this,`_timer`,void 0),P(this,`_shutdownOnce`,void 0),P(this,`_flushing`,!1),this._exporter=e,this._maxExportBatchSize=(n=t==null?void 0:t.maxExportBatchSize)==null?512:n,this._maxQueueSize=(r=t==null?void 0:t.maxQueueSize)==null?2048:r,this._scheduledDelayMillis=(i=t==null?void 0:t.scheduledDelayMillis)==null?5e3:i,this._exportTimeoutMillis=(a=t==null?void 0:t.exportTimeoutMillis)==null?3e4:a,this._shutdownOnce=new wo(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(j.warn(`BatchLogRecordProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize)}onEmit(e){this._shutdownOnce.isCalled||this._addToBuffer(e)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}_addToBuffer(e){this._finishedLogRecords.length>=this._maxQueueSize||(this._finishedLogRecords.push(e),this._maybeStartTimer())}shutdown(){return this._shutdownOnce.call()}_shutdown(){var e=this;return V(function*(){e.onShutdown(),yield e._flushAll(),yield e._exporter.shutdown()})()}_flushAll(){var e=this;return V(function*(){if(e._flushing)return;e._flushing=!0;let t=e._finishedLogRecords;for(e._finishedLogRecords=[],e._clearTimer(),e._currentExport!==null&&(yield e._exporter.forceFlush(),yield e._currentExport.exportCompleted,e._currentExport=null);t.length>0;){let n;t.length<=e._maxExportBatchSize?(n=t,t=[]):n=t.splice(0,e._maxExportBatchSize);let r=new hd(e._exporter,n,e._exportTimeoutMillis);e._currentExport=r;try{yield r.exportScheduled,yield e._exporter.forceFlush(),yield r.exportCompleted}catch(e){Si(e)}finally{e._currentExport=null}}e._flushing=!1,e._maybeStartTimer()})()}_extractBatch(){if(this._finishedLogRecords.length===0)return null;if(this._finishedLogRecords.length<=this._maxExportBatchSize){let e=this._finishedLogRecords;return this._finishedLogRecords=[],e}else return this._finishedLogRecords.splice(0,this._maxExportBatchSize)}_exportOneBatch(){this._clearTimer();let e=this._extractBatch();if(e===null)return;let t=new hd(this._exporter,e,this._exportTimeoutMillis);this._currentExport=t,t.exportCompleted.then(()=>{this._currentExport=null,this._maybeStartTimer()}).catch(e=>{this._currentExport=null,Si(e),this._maybeStartTimer()})}_maybeStartTimer(){if(!this._shutdownOnce.isCalled&&!this._flushing&&this._finishedLogRecords.length!==0&&this._currentExport===null){if(this._finishedLogRecords.length>=this._maxExportBatchSize){this._exportOneBatch();return}this._timer===void 0&&(this._timer=setTimeout(()=>{this._timer=void 0,this._exportOneBatch()},this._scheduledDelayMillis),typeof this._timer!=`number`&&this._timer.unref())}}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}};F();var _d=class extends gd{constructor(e,t){super(e,t),P(this,`_visibilityChangeListener`,void 0),P(this,`_pageHideListener`,void 0),this._onInit(t)}onShutdown(){typeof document>`u`||(this._visibilityChangeListener&&document.removeEventListener(`visibilitychange`,this._visibilityChangeListener),this._pageHideListener&&document.removeEventListener(`pagehide`,this._pageHideListener))}_onInit(e){(e==null?void 0:e.disableAutoFlushOnDocumentHide)===!0||typeof document>`u`||(this._visibilityChangeListener=()=>{document.visibilityState===`hidden`&&this.forceFlush()},this._pageHideListener=()=>{this.forceFlush()},document.addEventListener(`visibilitychange`,this._visibilityChangeListener),document.addEventListener(`pagehide`,this._pageHideListener))}},vd,yd=t((()=>{vd=`exception`})),bd,xd=t((()=>{N(),B(),Zi(),yd(),F(),bd=class{constructor(e){var t,n;P(this,`_spanContext`,void 0),P(this,`kind`,void 0),P(this,`parentSpanContext`,void 0),P(this,`attributes`,{}),P(this,`links`,[]),P(this,`events`,[]),P(this,`startTime`,void 0),P(this,`resource`,void 0),P(this,`instrumentationScope`,void 0),P(this,`_droppedAttributesCount`,0),P(this,`_droppedEventsCount`,0),P(this,`_droppedLinksCount`,0),P(this,`_attributesCount`,0),P(this,`name`,void 0),P(this,`status`,{code:wt.UNSET}),P(this,`endTime`,[0,0]),P(this,`_ended`,!1),P(this,`_duration`,[-1,-1]),P(this,`_spanProcessor`,void 0),P(this,`_spanLimits`,void 0),P(this,`_attributeValueLengthLimit`,void 0),P(this,`_recordEndMetrics`,void 0),P(this,`_performanceStartTime`,void 0),P(this,`_performanceOffset`,void 0),P(this,`_startTimeProvided`,void 0);let r=Date.now();if(this._spanContext=e.spanContext,this._performanceStartTime=z.now(),this._performanceOffset=r-(this._performanceStartTime+z.timeOrigin),this._startTimeProvided=e.startTime!=null,this._spanLimits=e.spanLimits,this._attributeValueLengthLimit=(t=this._spanLimits.attributeValueLengthLimit)==null?0:t,this._spanProcessor=e.spanProcessor,this.name=e.name,this.parentSpanContext=e.parentSpanContext,this.kind=e.kind,e.links)for(let t of e.links)this.addLink(t);this.startTime=this._getTime((n=e.startTime)==null?r:n),this.resource=e.resource,this.instrumentationScope=e.scope,this._recordEndMetrics=e.recordEndMetrics,e.attributes!=null&&this.setAttributes(e.attributes),this._spanProcessor.onStart(this,e.context)}spanContext(){return this._spanContext}setAttribute(e,t){if(t==null||this._isSpanEnded())return this;if(e.length===0)return j.warn(`Invalid attribute key: ${e}`),this;if(!mi(t))return j.warn(`Invalid attribute value set for key: ${e}`),this;let{attributeCountLimit:n}=this._spanLimits,r=!Object.prototype.hasOwnProperty.call(this.attributes,e);return n!==void 0&&this._attributesCount>=n&&r?(this._droppedAttributesCount++,this):(this.attributes[e]=this._truncateToSize(t),r&&this._attributesCount++,this)}setAttributes(e){for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.setAttribute(t,e[t]);return this}addEvent(e,t,n){if(this._isSpanEnded())return this;let{eventCountLimit:r}=this._spanLimits;if(r===0)return j.warn(`No events allowed.`),this._droppedEventsCount++,this;r!==void 0&&this.events.length>=r&&(this._droppedEventsCount===0&&j.debug(`Dropping extra events.`),this.events.shift(),this._droppedEventsCount++),ua(t)&&(ua(n)||(n=t),t=void 0);let i=fi(t),{attributePerEventCountLimit:a}=this._spanLimits,o={},s=0,c=0;for(let e in i){if(!Object.prototype.hasOwnProperty.call(i,e))continue;let t=i[e];if(a!==void 0&&c>=a){s++;continue}o[e]=this._truncateToSize(t),c++}return this.events.push({name:e,attributes:o,time:this._getTime(n),droppedAttributesCount:s}),this}addLink(e){if(this._isSpanEnded())return this;let{linkCountLimit:t}=this._spanLimits;if(t===0)return this._droppedLinksCount++,this;t!==void 0&&this.links.length>=t&&(this._droppedLinksCount===0&&j.debug(`Dropping extra links.`),this.links.shift(),this._droppedLinksCount++);let{attributePerLinkCountLimit:n}=this._spanLimits,r=fi(e.attributes),i={},a=0,o=0;for(let e in r){if(!Object.prototype.hasOwnProperty.call(r,e))continue;let t=r[e];if(n!==void 0&&o>=n){a++;continue}i[e]=this._truncateToSize(t),o++}let s={context:e.context};return o>0&&(s.attributes=i),a>0&&(s.droppedAttributesCount=a),this.links.push(s),this}addLinks(e){for(let t of e)this.addLink(t);return this}setStatus(e){if(this._isSpanEnded()||e.code===wt.UNSET||this.status.code===wt.OK)return this;let t={code:e.code};return e.code===wt.ERROR&&(typeof e.message==`string`?t.message=e.message:e.message!=null&&j.warn(`Dropping invalid status.message of type '${typeof e.message}', expected 'string'`)),this.status=t,this}updateName(e){return this._isSpanEnded()||(this.name=e),this}end(e){var t;if(this._isSpanEnded()){j.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`);return}this.endTime=this._getTime(e),this._duration=oa(this.startTime,this.endTime),this._duration[0]<0&&(j.warn(`Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.`,this.startTime,this.endTime),this.endTime=this.startTime.slice(),this._duration=[0,0]),this._droppedEventsCount>0&&j.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._droppedLinksCount>0&&j.warn(`Dropped ${this._droppedLinksCount} links because linkCountLimit reached`),this._spanProcessor.onEnding&&this._spanProcessor.onEnding(this),(t=this._recordEndMetrics)==null||t.call(this),this._ended=!0,this._spanProcessor.onEnd(this)}_getTime(e){if(typeof e==`number`&&e<=z.now())return ia(e+this._performanceOffset);if(typeof e==`number`)return ra(e);if(e instanceof Date)return ra(e.getTime());if(la(e))return e;if(this._startTimeProvided)return ra(Date.now());let t=z.now()-this._performanceStartTime;return da(this.startTime,ra(t))}isRecording(){return this._ended===!1}recordException(e,t){let n={};typeof e==`string`?n[Ni]=e:e&&(e.code?n[Fi]=e.code.toString():e.name&&(n[Fi]=e.name),e.message&&(n[Ni]=e.message),e.stack&&(n[Pi]=e.stack)),n[`exception.type`]||n[`exception.message`]?this.addEvent(vd,n,t):j.warn(`Failed to record an exception ${e}`)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}_isSpanEnded(){if(this._ended){let e=Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);j.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,e)}return this._ended}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_truncateToSize(e){let t=this._attributeValueLengthLimit;return t<=0?(j.warn(`Attribute value limit must be positive, got ${t}`),e):typeof e==`string`?this._truncateToLimitUtil(e,t):Array.isArray(e)?e.map(e=>typeof e==`string`?this._truncateToLimitUtil(e,t):e):e}}})),Sd,Cd=t((()=>{(function(e){e[e.NOT_RECORD=0]=`NOT_RECORD`,e[e.RECORD=1]=`RECORD`,e[e.RECORD_AND_SAMPLED=2]=`RECORD_AND_SAMPLED`})(Sd||(Sd={}))})),wd,Td=t((()=>{Cd(),wd=class{shouldSample(){return{decision:Sd.NOT_RECORD}}toString(){return`AlwaysOffSampler`}}})),Ed,Dd=t((()=>{Cd(),Ed=class{shouldSample(){return{decision:Sd.RECORD_AND_SAMPLED}}toString(){return`AlwaysOnSampler`}}})),Od,kd=t((()=>{N(),B(),Td(),Dd(),F(),Od=class{constructor(e){var t,n,r,i;P(this,`_root`,void 0),P(this,`_remoteParentSampled`,void 0),P(this,`_remoteParentNotSampled`,void 0),P(this,`_localParentSampled`,void 0),P(this,`_localParentNotSampled`,void 0),this._root=e.root,this._root||(Si(Error(`ParentBasedSampler must have a root sampler configured`)),this._root=new Ed),this._remoteParentSampled=(t=e.remoteParentSampled)==null?new Ed:t,this._remoteParentNotSampled=(n=e.remoteParentNotSampled)==null?new wd:n,this._localParentSampled=(r=e.localParentSampled)==null?new Ed:r,this._localParentNotSampled=(i=e.localParentNotSampled)==null?new wd:i}shouldSample(e,t,n,r,i,a){let o=M.getSpanContext(e);return!o||!it(o)?this._root.shouldSample(e,t,n,r,i,a):o.isRemote?o.traceFlags&k.SAMPLED?this._remoteParentSampled.shouldSample(e,t,n,r,i,a):this._remoteParentNotSampled.shouldSample(e,t,n,r,i,a):o.traceFlags&k.SAMPLED?this._localParentSampled.shouldSample(e,t,n,r,i,a):this._localParentNotSampled.shouldSample(e,t,n,r,i,a)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}}})),Ad,jd=t((()=>{N(),Cd(),F(),Ad=class{constructor(e=0){P(this,`_ratio`,void 0),P(this,`_upperBound`,void 0),this._ratio=this._normalize(e),this._upperBound=Math.floor(this._ratio*4294967295)}shouldSample(e,t){return{decision:nt(t)&&this._accumulate(t)<this._upperBound?Sd.RECORD_AND_SAMPLED:Sd.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(e){return typeof e!=`number`||isNaN(e)?0:e>=1?1:e<=0?0:e}_accumulate(e){let t=0;for(let n=0;n<32;n+=8){let r=0;for(let t=0;t<8;t++){let i=e.charCodeAt(n+t),a=i<58?i-48:i<71?i-55:i-87;r=r<<4|a}t=(t^r)>>>0}return t}}}));function Md(){var e,t,n,r,i,a,o,s;return{sampler:Nd(),forceFlushTimeoutMillis:3e4,generalLimits:{attributeValueLengthLimit:(e=void 0)==null?1/0:e,attributeCountLimit:(t=void 0)==null?128:t},spanLimits:{attributeValueLengthLimit:(n=void 0)==null?1/0:n,attributeCountLimit:(r=void 0)==null?128:r,linkCountLimit:(i=void 0)==null?128:i,eventCountLimit:(a=void 0)==null?128:a,attributePerEventCountLimit:(o=void 0)==null?128:o,attributePerLinkCountLimit:(s=void 0)==null?128:s}}}function Nd(){var e;let t=(e=void 0)==null?Fd.ParentBasedAlwaysOn:e;switch(t){case Fd.AlwaysOn:return new Ed;case Fd.AlwaysOff:return new wd;case Fd.ParentBasedAlwaysOn:return new Od({root:new Ed});case Fd.ParentBasedAlwaysOff:return new Od({root:new wd});case Fd.TraceIdRatio:return new Ad(Pd());case Fd.ParentBasedTraceIdRatio:return new Od({root:new Ad(Pd())});default:return j.error(`OTEL_TRACES_SAMPLER value "${t}" invalid, defaulting to "${Fd.ParentBasedAlwaysOn}".`),new Od({root:new Ed})}}function Pd(){return j.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${Id}.`),Id}var Fd,Id,Ld=t((()=>{N(),B(),Td(),Dd(),kd(),jd(),(function(e){e.AlwaysOff=`always_off`,e.AlwaysOn=`always_on`,e.ParentBasedAlwaysOff=`parentbased_always_off`,e.ParentBasedAlwaysOn=`parentbased_always_on`,e.ParentBasedTraceIdRatio=`parentbased_traceidratio`,e.TraceIdRatio=`traceidratio`})(Fd||(Fd={})),Id=1}));function Rd(e){let t={sampler:Nd()},n=Md(),r=Object.assign({},n,t,e);return r.generalLimits=Object.assign({},n.generalLimits,e.generalLimits||{}),r.spanLimits=Object.assign({},n.spanLimits,e.spanLimits||{}),r}function zd(e){var t,n,r,i,a,o,s,c,l,u,d,f;let p=Object.assign({},e.spanLimits);return p.attributeCountLimit=(t=(n=(r=(i=(a=e.spanLimits)==null?void 0:a.attributeCountLimit)==null?(o=e.generalLimits)==null?void 0:o.attributeCountLimit:i)==null?void 0:r)==null?void 0:n)==null?128:t,p.attributeValueLengthLimit=(s=(c=(l=(u=(d=e.spanLimits)==null?void 0:d.attributeValueLengthLimit)==null?(f=e.generalLimits)==null?void 0:f.attributeValueLengthLimit:u)==null?void 0:l)==null?void 0:c)==null?Bd:s,Object.assign({},e,{spanLimits:p})}var Bd,Vd=t((()=>{Ld(),B(),Bd=1/0})),Hd,Ud=t((()=>{N(),B(),F(),Hd=class{constructor(e,t){var n,r,i,a;P(this,`_maxExportBatchSize`,void 0),P(this,`_maxQueueSize`,void 0),P(this,`_scheduledDelayMillis`,void 0),P(this,`_exportTimeoutMillis`,void 0),P(this,`_exporter`,void 0),P(this,`_isExporting`,!1),P(this,`_finishedSpans`,[]),P(this,`_timer`,void 0),P(this,`_shutdownOnce`,void 0),P(this,`_droppedSpansCount`,0),this._exporter=e,this._maxExportBatchSize=typeof(t==null?void 0:t.maxExportBatchSize)==`number`?t.maxExportBatchSize:(n=void 0)==null?512:n,this._maxQueueSize=typeof(t==null?void 0:t.maxQueueSize)==`number`?t.maxQueueSize:(r=void 0)==null?2048:r,this._scheduledDelayMillis=typeof(t==null?void 0:t.scheduledDelayMillis)==`number`?t.scheduledDelayMillis:(i=void 0)==null?5e3:i,this._exportTimeoutMillis=typeof(t==null?void 0:t.exportTimeoutMillis)==`number`?t.exportTimeoutMillis:(a=void 0)==null?3e4:a,this._shutdownOnce=new wo(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(j.warn(`BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}onStart(e,t){}onEnd(e){this._shutdownOnce.isCalled||(e.spanContext().traceFlags&k.SAMPLED)!==0&&this._addToBuffer(e)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return Promise.resolve().then(()=>this.onShutdown()).then(()=>this._flushAll()).then(()=>this._exporter.shutdown())}_addToBuffer(e){if(this._finishedSpans.length>=this._maxQueueSize){this._droppedSpansCount===0&&j.debug(`maxQueueSize reached, dropping spans`),this._droppedSpansCount++;return}this._droppedSpansCount>0&&(j.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`),this._droppedSpansCount=0),this._finishedSpans.push(e),this._maybeStartTimer()}_flushAll(){return new Promise((e,t)=>{let n=[],r=Math.ceil(this._finishedSpans.length/this._maxExportBatchSize);for(let e=0,t=r;e<t;e++)n.push(this._flushOneBatch());Promise.all(n).then(()=>{e()}).catch(t)})}_flushOneBatch(){return this._clearTimer(),this._finishedSpans.length===0?Promise.resolve():new Promise((e,t)=>{let n=setTimeout(()=>{t(Error(`Timeout`))},this._exportTimeoutMillis);A.with($r(A.active()),()=>{let r;this._finishedSpans.length<=this._maxExportBatchSize?(r=this._finishedSpans,this._finishedSpans=[]):r=this._finishedSpans.splice(0,this._maxExportBatchSize);let i=()=>this._exporter.export(r,r=>{if(clearTimeout(n),r.code===ga.SUCCESS)e();else{var i;t((i=r.error)==null?Error(`BatchSpanProcessor: span export failed`):i)}}),a=null;for(let e=0,t=r.length;e<t;e++){let t=r[e];t.resource.asyncAttributesPending&&t.resource.waitForAsyncAttributes&&(a!=null||(a=[]),a.push(t.resource.waitForAsyncAttributes()))}a===null?i():Promise.all(a).then(i,e=>{Si(e),t(e)})})})}_maybeStartTimer(){if(this._isExporting)return;let e=()=>{this._isExporting=!0,this._flushOneBatch().finally(()=>{this._isExporting=!1,this._finishedSpans.length>0&&(this._clearTimer(),this._maybeStartTimer())}).catch(e=>{this._isExporting=!1,Si(e)})};if(this._finishedSpans.length>=this._maxExportBatchSize)return e();this._timer===void 0&&(this._timer=setTimeout(()=>e(),this._scheduledDelayMillis),typeof this._timer!=`number`&&this._timer.unref())}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}}})),Wd,Gd=t((()=>{Ud(),B(),F(),Wd=class extends Hd{constructor(e,t){super(e,t),P(this,`_visibilityChangeListener`,void 0),P(this,`_pageHideListener`,void 0),this.onInit(t)}onInit(e){(e==null?void 0:e.disableAutoFlushOnDocumentHide)!==!0&&typeof document<`u`&&(this._visibilityChangeListener=()=>{document.visibilityState===`hidden`&&this.forceFlush().catch(e=>{Si(e)})},this._pageHideListener=()=>{this.forceFlush().catch(e=>{Si(e)})},document.addEventListener(`visibilitychange`,this._visibilityChangeListener),document.addEventListener(`pagehide`,this._pageHideListener))}onShutdown(){typeof document<`u`&&(this._visibilityChangeListener&&document.removeEventListener(`visibilitychange`,this._visibilityChangeListener),this._pageHideListener&&document.removeEventListener(`pagehide`,this._pageHideListener))}}}));function Kd(e){for(let t=0;t<e.length;t++)e[t]=Math.random()*256>>>0;for(let t=0;t<e.length;t++)if(e[t]>0)return;e[e.length-1]=1}function qd(e){let t=``;for(let n=0;n<e.length;n++)t+=Qd[e[n]];return t}var Jd,Yd,Xd,Zd,Qd,$d,ef=t((()=>{Jd=16,Yd=8,Xd=new Uint8Array(Jd),Zd=new Uint8Array(Yd),Qd=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`)),$d=class{generateTraceId(){return Kd(Xd),qd(Xd)}generateSpanId(){return Kd(Zd),qd(Zd)}}})),tf=t((()=>{Gd(),ef()})),nf,rf,af,of,sf=t((()=>{nf=`otel.span.parent.origin`,rf=`otel.span.sampling_result`,af=`otel.sdk.span.live`,of=`otel.sdk.span.started`}));function cf(e){return e?e.isRemote?`remote`:`local`:`none`}function lf(e){switch(e){case Sd.RECORD_AND_SAMPLED:return`RECORD_AND_SAMPLE`;case Sd.RECORD:return`RECORD_ONLY`;case Sd.NOT_RECORD:return`DROP`}}var uf,df=t((()=>{Cd(),sf(),F(),uf=class{constructor(e){P(this,`startedSpans`,void 0),P(this,`liveSpans`,void 0),this.startedSpans=e.createCounter(of,{unit:`{span}`,description:`The number of created spans.`}),this.liveSpans=e.createUpDownCounter(af,{unit:`{span}`,description:`The number of currently live spans.`})}startSpan(e,t){let n=lf(t);if(this.startedSpans.add(1,{[nf]:cf(e),[rf]:n}),t===Sd.NOT_RECORD)return()=>{};let r={[rf]:n};return this.liveSpans.add(1,r),()=>{this.liveSpans.add(-1,r)}}}})),ff,pf=t((()=>{ff=`2.7.1`})),mf,hf=t((()=>{N(),B(),xd(),Vd(),tf(),df(),pf(),F(),mf=class{constructor(e,t,n,r){P(this,`_sampler`,void 0),P(this,`_generalLimits`,void 0),P(this,`_spanLimits`,void 0),P(this,`_idGenerator`,void 0),P(this,`instrumentationScope`,void 0),P(this,`_resource`,void 0),P(this,`_spanProcessor`,void 0),P(this,`_tracerMetrics`,void 0);let i=Rd(t);this._sampler=i.sampler,this._generalLimits=i.generalLimits,this._spanLimits=i.spanLimits,this._idGenerator=t.idGenerator||new $d,this._resource=n,this._spanProcessor=r,this.instrumentationScope=e;let a=i.meterProvider?i.meterProvider.getMeter(`@opentelemetry/sdk-trace`,ff):le();this._tracerMetrics=new uf(a)}startSpan(e,t={},n=A.active()){var r,i,a;t.root&&(n=M.deleteSpan(n));let o=M.getSpan(n);if(ei(n))return j.debug(`Instrumentation suppressed, returning Noop Span`),M.wrapSpanContext(Ue);let s=o==null?void 0:o.spanContext(),c=this._idGenerator.generateSpanId(),l,u,d;!s||!M.isSpanContextValid(s)?u=this._idGenerator.generateTraceId():(u=s.traceId,d=s.traceState,l=s);let f=(r=t.kind)==null?St.INTERNAL:r,p=((i=t.links)==null?[]:i).map(e=>({context:e.context,attributes:fi(e.attributes)})),m=fi(t.attributes),h=this._sampler.shouldSample(n,u,e,f,m,p),g=this._tracerMetrics.startSpan(s,h.decision);d=(a=h.traceState)==null?d:a;let _=h.decision===bt.RECORD_AND_SAMPLED?k.SAMPLED:k.NONE,v={traceId:u,spanId:c,traceFlags:_,traceState:d};if(h.decision===bt.NOT_RECORD)return j.debug(`Recording is off, propagating context in a non-recording span`),M.wrapSpanContext(v);let y=fi(Object.assign(m,h.attributes));return new bd({resource:this._resource,scope:this.instrumentationScope,context:n,spanContext:v,name:e,kind:f,links:p,parentSpanContext:l,attributes:y,startTime:t.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits,recordEndMetrics:g})}startActiveSpan(e,t,n,r){var i;let a,o,s;if(arguments.length<2)return;arguments.length===2?s=t:arguments.length===3?(a=t,s=n):(a=t,o=n,s=r);let c=(i=o)==null?A.active():i,l=this.startSpan(e,a,c),u=M.setSpan(c,l);return A.with(u,s,void 0,l)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}}})),gf,_f=t((()=>{B(),F(),gf=class{constructor(e){P(this,`_spanProcessors`,void 0),this._spanProcessors=e}forceFlush(){let e=[];for(let t of this._spanProcessors)e.push(t.forceFlush());return new Promise(t=>{Promise.all(e).then(()=>{t()}).catch(e=>{Si(e||Error(`MultiSpanProcessor: forceFlush failed`)),t()})})}onStart(e,t){for(let n of this._spanProcessors)n.onStart(e,t)}onEnding(e){for(let t of this._spanProcessors)t.onEnding&&t.onEnding(e)}onEnd(e){for(let t of this._spanProcessors)t.onEnd(e)}shutdown(){let e=[];for(let t of this._spanProcessors)e.push(t.shutdown());return new Promise((t,n)=>{Promise.all(e).then(()=>{t()},n)})}}})),vf,yf,bf=t((()=>{B(),lc(),hf(),Ld(),_f(),Vd(),F(),(function(e){e[e.resolved=0]=`resolved`,e[e.timeout=1]=`timeout`,e[e.error=2]=`error`,e[e.unresolved=3]=`unresolved`})(vf||(vf={})),yf=class{constructor(e={}){var t,n;P(this,`_config`,void 0),P(this,`_tracers`,new Map),P(this,`_resource`,void 0),P(this,`_activeSpanProcessor`,void 0);let r=io({},Md(),zd(e));this._resource=(t=r.resource)==null?rc():t,this._config=Object.assign({},r,{resource:this._resource});let i=[];(n=e.spanProcessors)!=null&&n.length&&i.push(...e.spanProcessors),this._activeSpanProcessor=new gf(i)}getTracer(e,t,n){let r=`${e}@${t||``}:${(n==null?void 0:n.schemaUrl)||``}`;return this._tracers.has(r)||this._tracers.set(r,new mf({name:e,version:t,schemaUrl:n==null?void 0:n.schemaUrl},this._config,this._resource,this._activeSpanProcessor)),this._tracers.get(r)}forceFlush(){let e=this._config.forceFlushTimeoutMillis,t=this._activeSpanProcessor._spanProcessors.map(t=>new Promise(n=>{let r,i=setTimeout(()=>{n(Error(`Span processor did not completed within timeout period of ${e} ms`)),r=vf.timeout},e);t.forceFlush().then(()=>{clearTimeout(i),r!==vf.timeout&&(r=vf.resolved,n(r))}).catch(e=>{clearTimeout(i),r=vf.error,n(e)})}));return new Promise((e,n)=>{Promise.all(t).then(t=>{let r=t.filter(e=>e!==vf.resolved);r.length>0?n(r):e()}).catch(e=>n([e]))})}shutdown(){return this._activeSpanProcessor.shutdown()}}})),xf,Sf=t((()=>{N(),B(),F(),H(),xf=class{constructor(e){P(this,`_exporter`,void 0),P(this,`_shutdownOnce`,void 0),P(this,`_pendingExports`,void 0),this._exporter=e,this._shutdownOnce=new wo(this._shutdown,this),this._pendingExports=new Set}forceFlush(){var e=this;return V(function*(){yield Promise.all(Array.from(e._pendingExports)),e._exporter.forceFlush&&(yield e._exporter.forceFlush())})()}onStart(e,t){}onEnd(e){if(this._shutdownOnce.isCalled||(e.spanContext().traceFlags&k.SAMPLED)===0)return;let t=this._doExport(e).catch(e=>Si(e));this._pendingExports.add(t),t.finally(()=>this._pendingExports.delete(t))}_doExport(e){var t=this;return V(function*(){if(e.resource.asyncAttributesPending){var n,r;yield(n=(r=e.resource).waitForAsyncAttributes)==null?void 0:n.call(r)}let i=yield Oo._export(t._exporter,[e]);if(i.code!==ga.SUCCESS){var a;throw(a=i.error)==null?Error(`SimpleSpanProcessor: span export failed (status ${i})`):a}})()}shutdown(){return this._shutdownOnce.call()}_shutdown(){return this._exporter.shutdown()}}})),Cf=t((()=>{bf(),tf(),B(),F(),Sf(),Td(),Dd(),kd(),jd(),Cd()})),wf,Tf=t((()=>{N(),F(),wf=class{constructor(){P(this,`_enabled`,!1),P(this,`_currentContext`,O)}_bindFunction(e=O,t){let n=this,r=function(...r){return n.with(e,()=>t.apply(this,r))};return Object.defineProperty(r,`length`,{enumerable:!1,configurable:!0,writable:!1,value:t.length}),r}active(){return this._currentContext}bind(e,t){return e===void 0&&(e=this.active()),typeof t==`function`?this._bindFunction(e,t):t}disable(){return this._currentContext=O,this._enabled=!1,this}enable(){return this._enabled?this:(this._enabled=!0,this._currentContext=O,this)}with(e,t,n,...r){let i=this._currentContext;this._currentContext=e||O;try{return t.call(n,...r)}finally{this._currentContext=i}}}}));function Ef(e){if(e!==null){if(e===void 0){let e=new wf;e.enable(),A.setGlobalContextManager(e);return}e.enable(),A.setGlobalContextManager(e)}}function Df(e){if(e!==null){if(e===void 0){Jt.setGlobalPropagator(new va({propagators:[new Ba,new ui]}));return}Jt.setGlobalPropagator(e)}}var Of,kf=t((()=>{Cf(),Tf(),N(),B(),Of=class extends yf{constructor(e={}){super(e)}register(e={}){M.setGlobalTracerProvider(this),Df(e.propagator),Ef(e.contextManager)}}})),J,Af=t((()=>{(function(e){e.CONNECT_END=`connectEnd`,e.CONNECT_START=`connectStart`,e.DECODED_BODY_SIZE=`decodedBodySize`,e.DOM_COMPLETE=`domComplete`,e.DOM_CONTENT_LOADED_EVENT_END=`domContentLoadedEventEnd`,e.DOM_CONTENT_LOADED_EVENT_START=`domContentLoadedEventStart`,e.DOM_INTERACTIVE=`domInteractive`,e.DOMAIN_LOOKUP_END=`domainLookupEnd`,e.DOMAIN_LOOKUP_START=`domainLookupStart`,e.ENCODED_BODY_SIZE=`encodedBodySize`,e.FETCH_START=`fetchStart`,e.LOAD_EVENT_END=`loadEventEnd`,e.LOAD_EVENT_START=`loadEventStart`,e.NAVIGATION_START=`navigationStart`,e.REDIRECT_END=`redirectEnd`,e.REDIRECT_START=`redirectStart`,e.REQUEST_START=`requestStart`,e.RESPONSE_END=`responseEnd`,e.RESPONSE_START=`responseStart`,e.SECURE_CONNECTION_START=`secureConnectionStart`,e.START_TIME=`startTime`,e.UNLOAD_EVENT_END=`unloadEventEnd`,e.UNLOAD_EVENT_START=`unloadEventStart`})(J||(J={}))})),jf,Mf,Nf=t((()=>{jf=`http.response_content_length`,Mf=`http.response_content_length_uncompressed`}));function Pf(){return qf||(qf=document.createElement(`a`)),qf}function Ff(e,t){return t in e}function Y(e,t,n,r=!0){if(Ff(n,t)&&typeof n[t]==`number`&&!(r&&n[t]===0))return e.addEvent(t,n[t])}function If(e,t,n=!1,r,i){if(r===void 0&&(r=t[J.START_TIME]!==0),n||(Y(e,J.FETCH_START,t,r),Y(e,J.DOMAIN_LOOKUP_START,t,r),Y(e,J.DOMAIN_LOOKUP_END,t,r),Y(e,J.CONNECT_START,t,r),Y(e,J.SECURE_CONNECTION_START,t,r),Y(e,J.CONNECT_END,t,r),Y(e,J.REQUEST_START,t,r),Y(e,J.RESPONSE_START,t,r),Y(e,J.RESPONSE_END,t,r)),!i){let n=t[J.ENCODED_BODY_SIZE];n!==void 0&&e.setAttribute(jf,n);let r=t[J.DECODED_BODY_SIZE];r!==void 0&&n!==r&&e.setAttribute(Mf,r)}}function Lf(e){return e.slice().sort((e,t)=>{let n=e[J.FETCH_START],r=t[J.FETCH_START];return n>r?1:n<r?-1:0})}function Rf(){return typeof location<`u`?location.origin:void 0}function zf(e,t,n,r,i=new WeakSet,a){let o=Hf(e);e=o.toString();let s=Vf(e,t,n,r,i,a);if(s.length===0)return{mainRequest:void 0};if(s.length===1)return{mainRequest:s[0]};let c=Lf(s);if(o.origin!==Rf()&&c.length>1){let e=c[0],t=Bf(c,e[J.RESPONSE_END],n),r=e[J.RESPONSE_END];return t[J.FETCH_START]<r&&(t=e,e=void 0),{corsPreFlightRequest:e,mainRequest:t}}else return{mainRequest:s[0]}}function Bf(e,t,n){let r=sa(n),i=sa(aa(t)),a=e[1],o,s=e.length;for(let t=1;t<s;t++){let n=e[t],s=sa(aa(n[J.FETCH_START])),c=r-sa(aa(n[J.RESPONSE_END]));s>=i&&(!o||c<o)&&(o=c,a=n)}return a}function Vf(e,t,n,r,i,a){let o=sa(t),s=sa(n),c=r.filter(t=>{let n=sa(aa(t[J.FETCH_START])),r=sa(aa(t[J.RESPONSE_END]));return t.initiatorType.toLowerCase()===(a||`xmlhttprequest`)&&t.name===e&&n>=o&&r<=s});return c.length>0&&(c=c.filter(e=>!i.has(e))),c}function Hf(e){if(typeof URL==`function`)return new URL(e,typeof document<`u`?document.baseURI:typeof location<`u`?location.href:void 0);let t=Pf();return t.href=e,t}function Uf(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return`/`;let n=Gf(e,t);if(t&&n.indexOf(`@id`)>0)return n;let r=``;return e.parentNode&&(r+=Uf(e.parentNode,t)),r+=n,r}function Wf(e){if(!e.parentNode)return 0;let t=[e.nodeType];e.nodeType===Node.CDATA_SECTION_NODE&&t.push(Node.TEXT_NODE);let n=Array.from(e.parentNode.childNodes);return n=n.filter(n=>{let r=n.localName;return t.indexOf(n.nodeType)>=0&&r===e.localName}),n.length>=1?n.indexOf(e)+1:0}function Gf(e,t){let n=e.nodeType,r=Wf(e),i=``;if(n===Node.ELEMENT_NODE){let n=e.getAttribute(`id`);if(t&&n)return`//*[@id="${n}"]`;i=e.localName}else if(n===Node.TEXT_NODE||n===Node.CDATA_SECTION_NODE)i=`text()`;else if(n===Node.COMMENT_NODE)i=`comment()`;else return``;return i&&r>1?`/${i}[${r}]`:`/${i}`}function Kf(e,t){let n=t||[];return(typeof n==`string`||n instanceof RegExp)&&(n=[n]),Hf(e).origin===Rf()?!0:n.some(t=>yo(e,t))}var qf,Jf=t((()=>{Af(),B(),Nf()})),Yf=t((()=>{kf(),Tf(),Af(),Jf(),Cf()}));Qu(),Yf();var X={actionType:`action.type`,deploymentEnvironmentName:`deployment.environment.name`,browserName:`browser_name`,browserVersion:`browser_version`,cacheHit:`cache_hit`,deviceType:`device_type`,durationBucket:`duration_bucket`,errorType:`error_type`,eventLabel:`event_label`,exceptionFingerprint:`exception.fingerprint`,exceptionMessageShort:`exception.message_short`,exceptionStackTopFrame:`exception.stack_top_frame`,longtaskAttributionScript:`longtask.attribution_script`,longtaskBlockingDuration:`longtask.blocking_duration`,networkEffectiveType:`network.effective_type`,nextHopProtocol:`next_hop_protocol`,result:`result`,serviceName:`service.name`,serviceVersion:`service.version`,osName:`os_name`,sessionHasReplay:`session.has_replay`,sessionId:`session.id`,sessionStartTime:`session.start_time`,spanSubtype:`span_subtype`,spanType:`span_type`,statusClass:`status_class`,targetDomain:`target_domain`,targetLabel:`target_label`,targetPathTemplate:`target_path_template`,targetTag:`target.tag`,targetTextShort:`target.text_short`,targetValue:`target_value`,traceScene:`trace_scene`,transferSize:`transfer_size`,userId:`user.id`,vitalMetric:`vital.metric`,vitalRating:`vital.rating`,vitalValue:`vital.value`,viewId:`view.id`,viewLoadingType:`view.loading_type`,viewUrl:`view.url`,viewUrlPathGroup:`view.url_path_group`};G();var Z={abort:`abort`,error:`error`,success:`success`,timeout:`timeout`,warning:`warning`},Q={action:`action`,custom:`custom`,document:`document`,error:`error`,http:`http`,longtask:`longtask`,resource:`resource`,route:`route`,vital:`vital`},Xf=e=>e<100?`<100ms`:e<500?`100~500ms`:e<2e3?`500ms~2s`:`>2s`,Zf=e=>`${Math.trunc(e/100)}xx`,Qf=e=>e===408||e===504?Z.timeout:typeof e==`number`&&e>=400?Z.error:Z.success,$f=e=>e===408||e===504?`network_timeout`:typeof e!=`number`||e<400?`none`:e>=500?`http_5xx`:`http_4xx`,ep=e=>e===`good`?Z.success:Z.warning,tp=(e,t)=>{if(!e)return{};try{let n=new URL(e,typeof location>`u`?`http://localhost`:location.href),r=t==null?n.pathname:t;return{domain:n.host,label:`${n.host}${r}`,pathTemplate:r}}catch(n){return{label:e,pathTemplate:t==null?e:t}}},$=({duration:e,errorType:t=`none`,eventLabel:n,result:r=Z.success,spanSubtype:i,spanType:a,targetLabel:o,targetValue:s,traceScene:c})=>W(W(W(W(W({[X.spanType]:a,[X.spanSubtype]:i,[X.result]:r,[X.errorType]:t},e===void 0?{}:{[X.durationBucket]:Xf(e)}),n===void 0?{}:{[X.eventLabel]:n}),o===void 0?{}:{[X.targetLabel]:o}),s===void 0?{}:{[X.targetValue]:s}),c===void 0?{}:{[X.traceScene]:c}),np=({duration:e,method:t,statusCode:n,subtype:r,url:i,urlPathTemplate:a})=>{let o=tp(i,a);return W(W(W(W(W({},$({duration:e,errorType:$f(n),eventLabel:`API 调用`,result:Qf(n),spanSubtype:r,spanType:Q.http,targetLabel:o.label,targetValue:n})),t?{"http.request.method":t.toUpperCase()}:{}),o.domain?{[X.targetDomain]:o.domain}:{}),o.pathTemplate?{[X.targetPathTemplate]:o.pathTemplate}:{}),typeof n==`number`?{"http.response.status_code":n,[X.statusClass]:Zf(n)}:{})},rp=({duration:e,initiatorType:t=`other`,responseStatus:n,transferSize:r,url:i,urlPathTemplate:a})=>{var o;let s=tp(i,a),c=typeof n==`number`?Qf(n):Z.success;return W(W(W(W({},$({duration:e,errorType:typeof n==`number`?$f(n):`none`,eventLabel:`静态资源`,result:c,spanSubtype:t,spanType:Q.resource,targetLabel:(o=s.label)==null?i:o,targetValue:r})),s.domain?{[X.targetDomain]:s.domain}:{}),s.pathTemplate?{[X.targetPathTemplate]:s.pathTemplate}:{}),typeof n==`number`?{"http.response.status_code":n,[X.statusClass]:Zf(n)}:{})};G();var ip=[`click`,`submit`,`keydown`],ap=e=>e instanceof Element?e:void 0,op=e=>{var t;if(!e)return;let n=((t=e.textContent)==null?void 0:t.trim())||e.getAttribute(`aria-label`)||e.getAttribute(`title`)||``;return n?n.slice(0,32):void 0},sp=(e={})=>{var t;let n=[],r=(t=e.eventNames)==null?ip:t;return{name:`action`,init(e){if(typeof window>`u`)return;let t={capture:!0,passive:!0},i=t=>{var n;let r=ap(t.target),i=op(r),a=r==null?void 0:r.tagName.toLowerCase();e.startSpan(`action.${t.type}`,W(W(W(W({},e.config.hooks.getPageAttributes()),$({errorType:`none`,eventLabel:`用户操作`,spanSubtype:t.type,spanType:Q.action,targetLabel:(n=i==null?a:i)==null?t.type:n})),{},{[X.actionType]:t.type},i?{[X.targetTextShort]:i}:{}),a?{[X.targetTag]:a}:{})).end()};for(let e of r)window.addEventListener(e,i,t),n.push(()=>window.removeEventListener(e,i,t))},shutdown(){for(;n.length;){var e;(e=n.pop())==null||e()}}}};function cp(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function lp(e,t){if(e==null)return{};var n,r,i=cp(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}Dn(),G();var up=e=>typeof e==`string`&&e.length>0?e:void 0,dp=e=>{let t=up(e);return t?{[X.viewUrlPathGroup]:t}:{}},fp=e=>dp(e[X.viewUrlPathGroup]),pp=(e,t)=>{var n;let r=X.viewUrlPathGroup,{[r]:i}=e;return W(W({},lp(e,[r].map(En))),dp((n=up(i))==null?t:n))};G();var mp=`body`,hp=3e3,gp=.8,_p=[`[data-loading="true"]`,`[aria-busy="true"]`,`.loading`,`.is-loading`,`.spinner`,`.skeleton`,`.bk-loading`],vp=[[.5,.5],[.25,.25],[.75,.25],[.25,.75],[.75,.75]],yp=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>=0?e:t,bp=(e,t)=>typeof e!=`number`||!Number.isFinite(e)?t:Math.max(0,Math.min(1,e)),xp=e=>{if(!e)return``;let t=e.tagName.toLowerCase();return e.id?`${t}#${e.id}`:t},Sp=(e,t)=>e?t.some(t=>{try{return e.matches(t)||!!e.closest(t)}catch(e){return!1}}):!1,Cp=e=>{if(typeof document>`u`)return()=>{};if(document.readyState===`complete`||document.readyState===`interactive`)return e(),()=>{};let t=()=>{document.removeEventListener(`DOMContentLoaded`,t),e()};return document.addEventListener(`DOMContentLoaded`,t),()=>document.removeEventListener(`DOMContentLoaded`,t)},wp=(e={})=>{var t,n;let r,i,a=!1,o={checkDelay:yp(e.checkDelay,hp),ignoreSelectors:(t=e.ignoreSelectors)==null?[]:t,rootSelector:(n=e.rootSelector)==null?mp:n,threshold:bp(e.threshold,gp)};return{name:`blank-screen`,init(e){if(typeof window>`u`||typeof document>`u`)return;let{checkDelay:t,rootSelector:n,threshold:s}=o,c=[..._p,...o.ignoreSelectors],l=e.meter.createCounter(`browser.blank_screen.count`,{description:`Number of suspected blank screen detections`}),u=()=>{try{var t,r;let i=document.querySelector(n),a=0,o=0;for(let[e,t]of vp){let n=document.elementFromPoint(window.innerWidth*e,window.innerHeight*t);if(Sp(n,c)){o+=1;continue}(n===i||n===document.body||n===document.documentElement)&&(a+=1)}let u=vp.length-o;if(u===0)return;let d=a/u,f=d>=s,p=xp(document.elementFromPoint(window.innerWidth/2,window.innerHeight/2)),m=W(W({},$({errorType:f?`blank_screen`:`none`,eventLabel:`白屏`,result:f?Z.error:Z.success,spanSubtype:`blank_screen`,spanType:Q.error,targetLabel:n,targetValue:d})),{},{"blank_screen.score":d,"blank_screen.threshold":s,"blank_screen.root":n,"blank_screen.detected":f,"blank_screen.sample_total":vp.length,"blank_screen.sample_valid":u,"blank_screen.sample_loading":o,"blank_screen.center_element":p,"blank_screen.dom_node_count":(t=(r=document.body)==null?void 0:r.getElementsByTagName(`*`).length)==null?0:t});f&&(l.add(1,e.applyRedact(W(W(W({},e.config.hooks.getMetricAttributes()),fp(e.getRuntimeAttributes())),{},{"blank_screen.root":n}))),e.startSpan(`browser.blank_screen`,m).end())}catch(t){if(e.config.debug){var i;(i=globalThis.console)==null||i.warn(`[bk-ot][blank-screen] detection failed:`,t)}}};i=Cp(()=>{a||(r=window.setTimeout(u,t))})},shutdown(){a=!0,i==null||i(),i=void 0,r!==void 0&&typeof window<`u`&&(window.clearTimeout(r),r=void 0)}}},Tp=()=>typeof window>`u`?`http://localhost`:window.location.origin,Ep=e=>{try{return new URL(e,Tp()).href}catch(t){return e}},Dp=e=>e.length>1?e.replace(/\/+$/,``):e,Op=(e,t)=>{let n=e=>Dp(e.replace(/[?#].*$/,``));return n(e)===n(t)},kp=e=>{try{return new URL(e,Tp()).origin===Tp()}catch(e){return!1}},Ap=(e,t)=>{let n=Ep(t);return[e.transport.traces.endpoint,e.transport.metrics.endpoint,e.transport.logs.endpoint].some(e=>Op(n,Ep(e)))},jp=(e,t)=>Ap(e,t),Mp=(e,t)=>e===`all`?!0:typeof e==`function`?e(t):(Array.isArray(e)?e:[e]).some(e=>typeof e==`string`?t.includes(e):e.test(t)),Np=(e,t)=>{if(kp(t))return!0;let n=e.instrumentations.propagateTraceHeaderUrls;return n?Mp(n,Ep(t)):!1},Pp,Fp=t((()=>{(function(e){e.DOCUMENT_LOAD=`documentLoad`,e.DOCUMENT_FETCH=`documentFetch`,e.RESOURCE_FETCH=`resourceFetch`})(Pp||(Pp={}))})),Ip,Lp,Rp=t((()=>{Ip=`0.62.0`,Lp=`@opentelemetry/instrumentation-document-load`})),zp,Bp,Vp=t((()=>{zp=`http.url`,Bp=`http.user_agent`})),Hp,Up=t((()=>{(function(e){e.FIRST_PAINT=`firstPaint`,e.FIRST_CONTENTFUL_PAINT=`firstContentfulPaint`})(Hp||(Hp={}))})),Wp,Gp,Kp,qp=t((()=>{B(),Up(),Wp=()=>{var e;let t={},n=(e=z.getEntriesByType)==null?void 0:e.call(z,`navigation`)[0];if(n)Object.values(J).forEach(e=>{if(Ff(n,e)){let r=n[e];typeof r==`number`&&(t[e]=r)}});else{let e=z.timing;e&&Object.values(J).forEach(n=>{if(Ff(e,n)){let r=e[n];typeof r==`number`&&(t[n]=r)}})}return t},Gp={"first-paint":Hp.FIRST_PAINT,"first-contentful-paint":Hp.FIRST_CONTENTFUL_PAINT},Kp=e=>{var t;let n=(t=z.getEntriesByType)==null?void 0:t.call(z,`paint`);n&&n.forEach(({name:t,startTime:n})=>{Ff(Gp,t)&&e.addEvent(Gp[t],n)})}})),Jp,Yp=t((()=>{N(),B(),Yf(),Zi(),Fp(),Rp(),Vp(),qp(),F(),Jp=class extends Gu{constructor(e={}){super(Lp,Ip,e),P(this,`component`,`document-load`),P(this,`version`,`1`),P(this,`moduleName`,this.component),P(this,`_semconvStability`,void 0),this._semconvStability=Xu(`http`,e==null?void 0:e.semconvStabilityOptIn)}init(){}_onDocumentLoaded(){window.setTimeout(()=>{this._collectPerformance()})}_addResourcesSpans(e){var t;let n=(t=z.getEntriesByType)==null?void 0:t.call(z,`resource`);n&&n.forEach(t=>{this._initResourceSpan(t,e)})}_collectPerformance(){let e=Array.from(document.getElementsByTagName(`meta`)).find(e=>e.getAttribute(`name`)===Ia),t=Wp(),n=e&&e.content||``;A.with(Jt.extract(O,{traceparent:n}),()=>{var e;let n=this._startSpan(Pp.DOCUMENT_LOAD,J.FETCH_START,t);n&&(A.with(M.setSpan(A.active(),n),()=>{let e=this._startSpan(Pp.DOCUMENT_FETCH,J.FETCH_START,t);e&&(this._semconvStability&q.OLD&&e.setAttribute(zp,location.href),this._semconvStability&q.STABLE&&e.setAttribute(Ki,location.href),A.with(M.setSpan(A.active(),e),()=>{var n;let r=!(this._semconvStability&q.OLD);If(e,t,this.getConfig().ignoreNetworkEvents,void 0,r),this._addCustomAttributesOnSpan(e,(n=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:n.documentFetch),this._endSpan(e,J.RESPONSE_END,t)}))}),this._semconvStability&q.OLD&&(n.setAttribute(zp,location.href),n.setAttribute(Bp,navigator.userAgent)),this._semconvStability&q.STABLE&&(n.setAttribute(Ki,location.href),n.setAttribute(qi,navigator.userAgent)),this._addResourcesSpans(n),this.getConfig().ignoreNetworkEvents||(Y(n,J.FETCH_START,t),Y(n,J.UNLOAD_EVENT_START,t),Y(n,J.UNLOAD_EVENT_END,t),Y(n,J.DOM_INTERACTIVE,t),Y(n,J.DOM_CONTENT_LOADED_EVENT_START,t),Y(n,J.DOM_CONTENT_LOADED_EVENT_END,t),Y(n,J.DOM_COMPLETE,t),Y(n,J.LOAD_EVENT_START,t),Y(n,J.LOAD_EVENT_END,t)),this.getConfig().ignorePerformancePaintEvents||Kp(n),this._addCustomAttributesOnSpan(n,(e=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:e.documentLoad),this._endSpan(n,J.LOAD_EVENT_END,t))})}_endSpan(e,t,n){e&&(Ff(n,t)?e.end(n[t]):e.end())}_initResourceSpan(e,t){let n=this._startSpan(Pp.RESOURCE_FETCH,J.FETCH_START,e,t);if(n){var r;this._semconvStability&q.OLD&&n.setAttribute(zp,e.name),this._semconvStability&q.STABLE&&n.setAttribute(Ki,e.name);let t=!(this._semconvStability&q.OLD);If(n,e,this.getConfig().ignoreNetworkEvents,void 0,t),this._addCustomAttributesOnResourceSpan(n,e,(r=this.getConfig().applyCustomAttributesOnSpan)==null?void 0:r.resourceFetch),this._endSpan(n,J.RESPONSE_END,e)}}_startSpan(e,t,n,r){if(Ff(n,t)&&typeof n[t]==`number`)return this.tracer.startSpan(e,{startTime:n[t]},r?M.setSpan(A.active(),r):void 0)}_waitForPageLoad(){window.document.readyState===`complete`?this._onDocumentLoaded():(this._onDocumentLoaded=this._onDocumentLoaded.bind(this),window.addEventListener(`load`,this._onDocumentLoaded))}_addCustomAttributesOnSpan(e,t){t&&Ju(()=>t(e),e=>{e&&this._diag.error(`addCustomAttributesOnSpan`,e)},!0)}_addCustomAttributesOnResourceSpan(e,t,n){n&&Ju(()=>n(e,t),e=>{e&&this._diag.error(`addCustomAttributesOnResourceSpan`,e)},!0)}enable(){window.removeEventListener(`load`,this._onDocumentLoaded),this._waitForPageLoad()}disable(){window.removeEventListener(`load`,this._onDocumentLoaded)}}})),Xp=n({AttributeNames:()=>Pp,DocumentLoadInstrumentation:()=>Jp}),Zp=t((()=>{Yp(),Fp()})),Qp,$p=t((()=>{(function(e){e.COMPONENT=`component`,e.HTTP_STATUS_TEXT=`http.status_text`})(Qp||(Qp={}))})),em,tm,nm,rm,im,am,om,sm,cm=t((()=>{em=`http.host`,tm=`http.method`,nm=`http.request.body.size`,rm=`http.request_content_length_uncompressed`,im=`http.scheme`,am=`http.status_code`,om=`http.url`,sm=`http.user_agent`}));function lm(...e){if(e[0]instanceof URL||typeof e[0]==`string`){let t=e[1];if(!(t!=null&&t.body))return Promise.resolve();if(t.body instanceof ReadableStream){let{body:e,length:n}=um(t.body);return t.body=e,n}else return Promise.resolve(fm(t.body))}else{let t=e[0];return t!=null&&t.body?t.clone().text().then(e=>pm(e)):Promise.resolve()}}function um(e){if(!e.pipeThrough)return vm.warn(`Platform has ReadableStream but not pipeThrough!`),{body:e,length:Promise.resolve(void 0)};let t=0,n,r=new Promise(e=>{n=e}),i=new TransformStream({start(){},transform(e,n){return V(function*(){let r=yield e;t+=r.byteLength,n.enqueue(e)})()},flush(){n(t)}});return{body:e.pipeThrough(i),length:r}}function dm(e){return typeof Document<`u`&&e instanceof Document}function fm(e){if(dm(e))return new XMLSerializer().serializeToString(document).length;if(typeof e==`string`)return pm(e);if(e instanceof Blob)return e.size;if(e instanceof FormData)return mm(e);if(e instanceof URLSearchParams)return pm(e.toString());if(e.byteLength!==void 0)return e.byteLength;vm.warn(`unknown body type`)}function pm(e){return ym.encode(e).byteLength}function mm(e){let t=0;for(let[n,r]of e.entries())t+=n.length,r instanceof Blob?t+=r.size:t+=r.length;return t}function hm(e){let t=gm(),n=e.toUpperCase();return n in t?n:`_OTHER`}function gm(){return xm===void 0&&(xm=bm),xm}function _m(e){let t=Number(e.port||Sm[e.protocol]);if(t&&!isNaN(t))return t}var vm,ym,bm,xm,Sm,Cm=t((()=>{N(),B(),H(),vm=j.createComponentLogger({namespace:`@opentelemetry/opentelemetry-instrumentation-fetch/utils`}),ym=new TextEncoder,bm={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0},Sm={"https:":`443`,"http:":`80`}})),wm,Tm=t((()=>{wm=`0.217.0`})),Em,Dm,Om,km=t((()=>{N(),Qu(),B(),Yf(),$p(),cm(),Zi(),Cm(),Tm(),F(),Em=300,Dm=typeof PerformanceObserver<`u`,Om=class extends Gu{constructor(e={}){super(`@opentelemetry/instrumentation-fetch`,wm,e),P(this,`component`,`fetch`),P(this,`version`,wm),P(this,`moduleName`,this.component),P(this,`_usedResources`,new WeakSet),P(this,`_tasksCount`,0),P(this,`_semconvStability`,void 0),this._semconvStability=Xu(`http`,e==null?void 0:e.semconvStabilityOptIn)}init(){}_addChildSpan(e,t){let n=this.tracer.startSpan(`CORS Preflight`,{startTime:t[J.FETCH_START]},M.setSpan(A.active(),e)),r=!(this._semconvStability&q.OLD);If(n,t,this.getConfig().ignoreNetworkEvents,void 0,r),n.end(t[J.RESPONSE_END])}_addFinalSpanAttributes(e,t){let n=Hf(t.url);if(this._semconvStability&q.OLD&&(e.setAttribute(am,t.status),t.statusText!=null&&e.setAttribute(Qp.HTTP_STATUS_TEXT,t.statusText),e.setAttribute(em,n.host),e.setAttribute(im,n.protocol.replace(`:`,``)),typeof navigator<`u`&&e.setAttribute(sm,navigator.userAgent)),this._semconvStability&q.STABLE){e.setAttribute(Ri,t.status),e.setAttribute(zi,n.hostname);let r=_m(n);r&&e.setAttribute(Bi,r)}}_addHeaders(e,t){if(!Kf(t,this.getConfig().propagateTraceHeaderCorsUrls)){let e={};Jt.inject(A.active(),e),Object.keys(e).length>0&&this._diag.debug(`headers inject skipped due to CORS policy`);return}if(e instanceof Request)Jt.inject(A.active(),e.headers,{set:(e,t,n)=>e.set(t,typeof n==`string`?n:String(n))});else{let t=new Headers(e.headers);Jt.inject(A.active(),t,{set:(e,t,n)=>e.set(t,typeof n==`string`?n:String(n))}),e.headers=t}}_clearResources(){this._tasksCount===0&&this.getConfig().clearTimingResources&&(performance.clearResourceTimings(),this._usedResources=new WeakSet)}_createSpan(e,t={}){if(bo(e,this.getConfig().ignoreUrls)){this._diag.debug(`ignoring span as url matches ignored url`);return}let n=``,r={};if(this._semconvStability&q.OLD){let i=(t.method||`GET`).toUpperCase();n=`HTTP ${i}`,r[Qp.COMPONENT]=this.moduleName,r[tm]=i,r[om]=e}if(this._semconvStability&q.STABLE){let i=t.method,a=hm(t.method||`GET`);n||(n=a),r[Ii]=a,a!==i&&(r[Li]=i),r[Ki]=e}return this.tracer.startSpan(n,{kind:St.CLIENT,attributes:r})}_findResourceAndAddNetworkEvents(e,t,n){let r=t.entries;if(!r.length){if(!performance.getEntriesByType)return;r=performance.getEntriesByType(`resource`)}let i=zf(t.spanUrl,t.startTime,n,r,this._usedResources,`fetch`);if(i.mainRequest){let t=i.mainRequest;this._markResourceAsUsed(t);let n=i.corsPreFlightRequest;n&&(this._addChildSpan(e,n),this._markResourceAsUsed(n));let r=!(this._semconvStability&q.OLD);If(e,t,this.getConfig().ignoreNetworkEvents,void 0,r)}}_markResourceAsUsed(e){this._usedResources.add(e)}_endSpan(e,t,n){let r=ra(Date.now()),i=ia();this._addFinalSpanAttributes(e,n),this._semconvStability&q.STABLE&&n.status>=400&&(e.setStatus({code:wt.ERROR}),e.setAttribute(Mi,String(n.status))),setTimeout(()=>{var n;(n=t.observer)==null||n.disconnect(),this._findResourceAndAddNetworkEvents(e,t,i),this._tasksCount--,this._clearResources(),e.end(r)},Em)}_patchConstructor(){return e=>{let t=this;return function(...n){if(!t._isEnabled)return e.apply(this,n);let r=this,i=Hf(n[0]instanceof Request?n[0].url:String(n[0])).href,a;a=n[0]instanceof Request?n[1]==null?n[0]:new Request(n[0],n[1]):n[1]||{};let o=t._createSpan(i,a);if(!o)return e.apply(this,n);let s=t._prepareSpanData(i);t.getConfig().measureRequestSize&&lm(...n).then(e=>{e&&(t._semconvStability&q.OLD&&o.setAttribute(rm,e),t._semconvStability&q.STABLE&&o.setAttribute(nm,e))}).catch(e=>{t._diag.warn(`getFetchBodyLength`,e)});function c(e,n){t._applyAttributesAfterFetch(e,a,n),t._endSpan(e,s,{status:n.status||0,statusText:n.message,url:i})}function l(e,n){t._applyAttributesAfterFetch(e,a,n),n.status>=200&&n.status<400?t._endSpan(e,s,n):t._endSpan(e,s,{status:n.status,statusText:n.statusText,url:i})}function u(e,n){try{let t=n.clone().body;if(t){let r=t.getReader(),i=()=>{r.read().then(({done:t})=>{t?l(e,n):i()},t=>{c(e,t)})};i()}else l(e,n)}catch(n){t._diag.error(`Failed to read fetch response body`,n),t._endSpan(e,s,{status:0,url:i})}return n}function d(e,n){try{c(e,n)}catch(r){t._diag.error(`Failed to end span on fetch error`,r),t._endSpan(e,s,{status:n.status||0,url:i})}throw n}return A.with(M.setSpan(A.active(),o),()=>(t._callRequestHook(o,a),t._addHeaders(a,i),t._tasksCount++,e.apply(r,a instanceof Request?[a]:[i,a]).then(u.bind(r,o),d.bind(r,o))))}}}_applyAttributesAfterFetch(e,t,n){let r=this.getConfig().applyCustomAttributesOnSpan;r&&Ju(()=>r(e,t,n),e=>{e&&this._diag.error(`applyCustomAttributesOnSpan`,e)},!0)}_callRequestHook(e,t){let n=this.getConfig().requestHook;n&&Ju(()=>n(e,t),e=>{e&&this._diag.error(`requestHook`,e)},!0)}_prepareSpanData(e){let t=ia(),n=[];if(typeof PerformanceObserver!=`function`)return{entries:n,startTime:t,spanUrl:e};let r=new PerformanceObserver(t=>{t.getEntries().forEach(t=>{t.initiatorType===`fetch`&&t.name===e&&n.push(t)})});return r.observe({entryTypes:[`resource`]}),{entries:n,observer:r,startTime:t,spanUrl:e}}enable(){if(!Dm){this._diag.warn(`this instrumentation is intended for web usage only, it does not instrument server-side fetch()`);return}if(!this._isEnabled){if(this._isFetchPatched){this._diag.debug(`fetch constructor already patched`),this._isEnabled=!0;return}try{this._wrap(globalThis,`fetch`,this._patchConstructor()),this._isFetchPatched=!0,this._isEnabled=!0}catch(e){this._diag.warn(`Failed to patch globalThis.fetch; instrumentation will not be enabled. Another script may have locked globalThis.fetch via Object.defineProperty.`,e)}}}disable(){Dm&&this._isEnabled&&(this._isEnabled=!1,this._usedResources=new WeakSet)}}})),Am=n({FetchInstrumentation:()=>Om}),jm=t((()=>{km()})),Mm,Nm,Pm,Fm,Im,Lm,Rm,zm,Bm=t((()=>{Mm=`http.host`,Nm=`http.method`,Pm=`http.request.body.size`,Fm=`http.request_content_length_uncompressed`,Im=`http.scheme`,Lm=`http.status_code`,Rm=`http.url`,zm=`http.user_agent`})),Vm,Hm=t((()=>{(function(e){e.METHOD_OPEN=`open`,e.METHOD_SEND=`send`,e.EVENT_ABORT=`abort`,e.EVENT_ERROR=`error`,e.EVENT_LOAD=`loaded`,e.EVENT_TIMEOUT=`timeout`})(Vm||(Vm={}))}));function Um(e){return typeof Document<`u`&&e instanceof Document}function Wm(e){if(Um(e))return new XMLSerializer().serializeToString(document).length;if(typeof e==`string`)return Gm(e);if(e instanceof Blob)return e.size;if(e instanceof FormData)return Km(e);if(e instanceof URLSearchParams)return Gm(e.toString());if(e.byteLength!==void 0)return e.byteLength;Xm.warn(`unknown body type`)}function Gm(e){return Zm.encode(e).byteLength}function Km(e){let t=0;for(let[n,r]of e.entries())t+=n.length,r instanceof Blob?t+=r.size:t+=r.length;return t}function qm(e){let t=Jm(),n=e.toUpperCase();return n in t?n:`_OTHER`}function Jm(){return $m===void 0&&($m=Qm),$m}function Ym(e){let t=Number(e.port||eh[e.protocol]);if(t&&!isNaN(t))return t}var Xm,Zm,Qm,$m,eh,th=t((()=>{N(),B(),Xm=j.createComponentLogger({namespace:`@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils`}),Zm=new TextEncoder,Qm={CONNECT:!0,DELETE:!0,GET:!0,HEAD:!0,OPTIONS:!0,PATCH:!0,POST:!0,PUT:!0,TRACE:!0,QUERY:!0},eh={"https:":`443`,"http:":`80`}})),nh,rh=t((()=>{nh=`0.217.0`})),ih,ah=t((()=>{(function(e){e.HTTP_STATUS_TEXT=`http.status_text`})(ih||(ih={}))})),oh,sh,ch=t((()=>{N(),Qu(),B(),Yf(),Zi(),Bm(),Hm(),th(),rh(),ah(),F(),oh=300,sh=class extends Gu{constructor(e={}){super(`@opentelemetry/instrumentation-xml-http-request`,nh,e),P(this,`component`,`xml-http-request`),P(this,`version`,nh),P(this,`moduleName`,this.component),P(this,`_tasksCount`,0),P(this,`_xhrMem`,new WeakMap),P(this,`_usedResources`,new WeakSet),P(this,`_semconvStability`,void 0),this._semconvStability=Xu(`http`,e==null?void 0:e.semconvStabilityOptIn)}init(){}_addHeaders(e,t){let n=Hf(t).href;if(!Kf(n,this.getConfig().propagateTraceHeaderCorsUrls)){let e={};Jt.inject(A.active(),e),Object.keys(e).length>0&&this._diag.debug(`headers inject skipped due to CORS policy`);return}let r={};Jt.inject(A.active(),r),Object.keys(r).forEach(t=>{e.setRequestHeader(t,String(r[t]))})}_addChildSpan(e,t){A.with(M.setSpan(A.active(),e),()=>{let e=this.tracer.startSpan(`CORS Preflight`,{startTime:t[J.FETCH_START]}),n=!(this._semconvStability&q.OLD);If(e,t,this.getConfig().ignoreNetworkEvents,void 0,n),e.end(t[J.RESPONSE_END])})}_addFinalSpanAttributes(e,t,n){if(this._semconvStability&q.OLD){if(t.status!==void 0&&e.setAttribute(Lm,t.status),t.statusText!==void 0&&e.setAttribute(ih.HTTP_STATUS_TEXT,t.statusText),typeof n==`string`){let t=Hf(n);e.setAttribute(Mm,t.host),e.setAttribute(Im,t.protocol.replace(`:`,``))}e.setAttribute(zm,navigator.userAgent)}this._semconvStability&q.STABLE&&t.status&&e.setAttribute(Ri,t.status)}_applyAttributesAfterXHR(e,t){let n=this.getConfig().applyCustomAttributesOnSpan;typeof n==`function`&&Ju(()=>n(e,t),e=>{e&&this._diag.error(`applyCustomAttributesOnSpan`,e)},!0)}_addResourceObserver(e,t){let n=this._xhrMem.get(e);!n||typeof PerformanceObserver!=`function`||typeof PerformanceResourceTiming!=`function`||(n.createdResources={observer:new PerformanceObserver(e=>{let r=e.getEntries(),i=Hf(t);r.forEach(e=>{e.initiatorType===`xmlhttprequest`&&e.name===i.href&&n.createdResources&&n.createdResources.entries.push(e)})}),entries:[]},n.createdResources.observer.observe({entryTypes:[`resource`]}))}_clearResources(){this._tasksCount===0&&this.getConfig().clearTimingResources&&(z.clearResourceTimings(),this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}_findResourceAndAddNetworkEvents(e,t,n,r,i){if(!n||!r||!i||!e.createdResources)return;let a=e.createdResources.entries;(!a||!a.length)&&(a=z.getEntriesByType(`resource`));let o=zf(Hf(n).href,r,i,a,this._usedResources);if(o.mainRequest){let e=o.mainRequest;this._markResourceAsUsed(e);let n=o.corsPreFlightRequest;n&&(this._addChildSpan(t,n),this._markResourceAsUsed(n));let r=!(this._semconvStability&q.OLD);If(t,e,this.getConfig().ignoreNetworkEvents,void 0,r)}}_cleanPreviousSpanInformation(e){let t=this._xhrMem.get(e);if(t){let n=t.callbackToRemoveEvents;n&&n(),this._xhrMem.delete(e)}}_createSpan(e,t,n){let r=Hf(t);if(bo(r.href,this.getConfig().ignoreUrls)){this._diag.debug(`ignoring span as url matches ignored url`);return}let i=``,a={};if(this._semconvStability&q.OLD&&(i=n.toUpperCase(),a[Nm]=n,a[Rm]=r.toString()),this._semconvStability&q.STABLE){let e=n,t=qm(n);i||(i=t),a[Ii]=t,t!==e&&(a[Li]=e),a[Ki]=r.toString(),a[zi]=r.hostname;let o=Ym(r);o&&(a[Bi]=o)}let o=this.tracer.startSpan(i,{kind:St.CLIENT,attributes:a});return o.addEvent(Vm.METHOD_OPEN),this._cleanPreviousSpanInformation(e),this._xhrMem.set(e,{span:o,spanUrl:t}),o}_markResourceAsUsed(e){this._usedResources.add(e)}_patchOpen(){return e=>{let t=this;return function(...n){if(!t._isEnabled)return e.apply(this,n);let r=n[0],i=n[1];return t._createSpan(this,i,r),e.apply(this,n)}}}_patchSend(){let e=this;function t(t,n,r,i){let a=n.callbackToRemoveEvents;typeof a==`function`&&a();let{span:o,spanUrl:s,sendStartTime:c}=n;o&&(e._findResourceAndAddNetworkEvents(n,o,s,c,r),o.addEvent(t,i),e._addFinalSpanAttributes(o,n,s),o.end(i),e._tasksCount--),e._clearResources()}function n(n,r,i,a){let o=e._xhrMem.get(r);if(!o)return;if(o.status=r.status,o.statusText=r.statusText,e._xhrMem.delete(r),o.span){let t=o.span;e._applyAttributesAfterXHR(t,r),e._semconvStability&q.STABLE&&(i?a&&(t.setStatus({code:wt.ERROR,message:a}),t.setAttribute(Mi,a)):o.status&&o.status>=400&&(t.setStatus({code:wt.ERROR}),t.setAttribute(Mi,String(o.status))))}let s=ia(),c=Date.now();setTimeout(()=>{t(n,o,s,c)},oh)}function r(){n(Vm.EVENT_ERROR,this,!0,`error`)}function i(){n(Vm.EVENT_ABORT,this,!1)}function a(){n(Vm.EVENT_TIMEOUT,this,!0,`timeout`)}function o(){this.status<299?n(Vm.EVENT_LOAD,this,!1):n(Vm.EVENT_ERROR,this,!1)}function s(t){t.removeEventListener(`abort`,i),t.removeEventListener(`error`,r),t.removeEventListener(`load`,o),t.removeEventListener(`timeout`,a);let n=e._xhrMem.get(t);n&&(n.callbackToRemoveEvents=void 0)}return t=>function(...n){if(!e._isEnabled)return t.apply(this,n);let c=e._xhrMem.get(this);if(!c)return t.apply(this,n);let l=c.span,u=c.spanUrl;if(l&&u){if(e.getConfig().measureRequestSize&&n!=null&&n[0]){let t=n[0],r=Wm(t);r!==void 0&&(e._semconvStability&q.OLD&&l.setAttribute(Fm,r),e._semconvStability&q.STABLE&&l.setAttribute(Pm,r))}A.with(M.setSpan(A.active(),l),()=>{e._tasksCount++,c.sendStartTime=ia(),l.addEvent(Vm.METHOD_SEND),this.addEventListener(`abort`,i),this.addEventListener(`error`,r),this.addEventListener(`load`,o),this.addEventListener(`timeout`,a),c.callbackToRemoveEvents=()=>{s(this),c.createdResources&&c.createdResources.observer.disconnect()},e._addHeaders(this,u),e._addResourceObserver(this,u)})}return t.apply(this,n)}}enable(){if(!this._isEnabled){if(this._isXhrPatched){this._diag.debug(`reactivating existing patch on`,this.moduleName,this.version),this._isEnabled=!0;return}try{this._diag.debug(`applying patch to`,this.moduleName,this.version),this._wrap(XMLHttpRequest.prototype,`open`,this._patchOpen()),this._wrap(XMLHttpRequest.prototype,`send`,this._patchSend()),this._isXhrPatched=!0,this._isEnabled=!0}catch(e){this._unwrap(XMLHttpRequest.prototype,`open`),this._unwrap(XMLHttpRequest.prototype,`send`),this._diag.warn(`Failed to patch globalThis.XMLHttpRequest; instrumentation will not be enabled. Another script may have locked globalThis.XMLHttpRequest via Object.defineProperty.`,e)}}}disable(){this._isEnabled&&(this._isEnabled=!1,this._tasksCount=0,this._xhrMem=new WeakMap,this._usedResources=new WeakSet)}}})),lh=n({XMLHttpRequestInstrumentation:()=>sh}),uh=t((()=>{ch()})),dh,fh=t((()=>{(function(e){e.EVENT_TYPE=`event_type`,e.TARGET_ELEMENT=`target_element`,e.TARGET_XPATH=`target_xpath`,e.HTTP_URL=`http.url`})(dh||(dh={}))})),ph,mh,hh=t((()=>{ph=`0.61.0`,mh=`@opentelemetry/instrumentation-user-interaction`}));function gh(){return!1}var _h,vh,yh,bh,xh=t((()=>{Qu(),N(),B(),Yf(),fh(),hh(),F(),_h=`OT_ZONE_CONTEXT`,vh=`Navigation:`,yh=[`click`],bh=class extends Gu{constructor(e={}){var t;super(mh,ph,e),P(this,`version`,ph),P(this,`moduleName`,`user-interaction`),P(this,`_spansData`,new WeakMap),P(this,`_wrappedListeners`,new WeakMap),P(this,`_eventsSpanMap`,new WeakMap),P(this,`_eventNames`,void 0),P(this,`_shouldPreventSpanCreation`,void 0),this._eventNames=new Set((t=e==null?void 0:e.eventNames)==null?yh:t),this._shouldPreventSpanCreation=typeof(e==null?void 0:e.shouldPreventSpanCreation)==`function`?e.shouldPreventSpanCreation:gh}init(){}_checkForTimeout(e,t){let n=this._spansData.get(t);n&&(e.source===`setTimeout`?n.hrTimeLastTimeout=ia():e.source!==`Promise.then`&&e.source!==`setTimeout`&&(n.hrTimeLastTimeout=void 0))}_allowEventName(e){return this._eventNames.has(e)}_createSpan(e,t,n){if(!this._isEnabled||!(e instanceof HTMLElement)||!e.getAttribute||e.hasAttribute(`disabled`)||!this._allowEventName(t))return;let r=Uf(e,!0);try{let i=this.tracer.startSpan(t,{attributes:{[dh.EVENT_TYPE]:t,[dh.TARGET_ELEMENT]:e.tagName,[dh.TARGET_XPATH]:r,[dh.HTTP_URL]:window.location.href}},n?M.setSpan(A.active(),n):void 0);return this._shouldPreventSpanCreation(t,e,i)===!0?void 0:(this._spansData.set(i,{taskCount:0}),i)}catch(e){this._diag.error(`failed to start create new user interaction span`,e)}}_decrementTask(e){let t=this._spansData.get(e);t&&(t.taskCount--,t.taskCount===0&&this._tryToEndSpan(e,t.hrTimeLastTimeout))}_getCurrentSpan(e){let t=e.get(_h);return t&&M.getSpan(t)}_incrementTask(e){let t=this._spansData.get(e);t&&t.taskCount++}addPatchedListener(e,t,n,r){let i=this._wrappedListeners.get(n);i||(i=new Map,this._wrappedListeners.set(n,i));let a=i.get(t);return a||(a=new Map,i.set(t,a)),a.has(e)?!1:(a.set(e,r),!0)}removePatchedListener(e,t,n){let r=this._wrappedListeners.get(n);if(!r)return;let i=r.get(t);if(!i)return;let a=i.get(e);return a&&(i.delete(e),i.size===0&&(r.delete(t),r.size===0&&this._wrappedListeners.delete(n))),a}_invokeListener(e,t,n){return typeof e==`function`?e.apply(t,n):e.handleEvent(n[0])}_patchAddEventListener(){let e=this;return t=>function(n,r,i){if(!r)return t.call(this,n,r,i);let a=i&&typeof i==`object`&&i.once,o=function(...t){let i,o=t[0],s=o==null?void 0:o.target;o&&(i=e._eventsSpanMap.get(o)),a&&e.removePatchedListener(this,n,r);let c=e._createSpan(s,n,i);return c?(o&&e._eventsSpanMap.set(o,c),A.with(M.setSpan(A.active(),c),()=>{let n=e._invokeListener(r,this,t);return c.end(),n})):e._invokeListener(r,this,t)};if(e.addPatchedListener(this,n,r,o))return t.call(this,n,o,i)}}_patchRemoveEventListener(){let e=this;return t=>function(n,r,i){let a=e.removePatchedListener(this,n,r);return a?t.call(this,n,a,i):t.call(this,n,r,i)}}_getPatchableEventTargets(){return window.EventTarget?[EventTarget.prototype]:[Node.prototype,Window.prototype]}_patchHistoryApi(){this._isEnabled&&(this._wrap(history,`replaceState`,this._patchHistoryMethod()),this._wrap(history,`pushState`,this._patchHistoryMethod()),this._wrap(history,`back`,this._patchHistoryMethod()),this._wrap(history,`forward`,this._patchHistoryMethod()),this._wrap(history,`go`,this._patchHistoryMethod()))}_patchHistoryMethod(){let e=this;return t=>function(...n){if(!e._isEnabled)return t.apply(this,n);let r=`${location.pathname}${location.hash}${location.search}`,i=t.apply(this,n),a=`${location.pathname}${location.hash}${location.search}`;return r!==a&&e._updateInteractionName(a),i}}_updateInteractionName(e){let t=M.getSpan(A.active());t&&typeof t.updateName==`function`&&t.updateName(`${vh} ${e}`)}_patchZoneCancelTask(){let e=this;return t=>function(n){let r=Zone.current,i=e._getCurrentSpan(r);return i&&e._shouldCountTask(n,r)&&e._decrementTask(i),t.call(this,n)}}_patchZoneScheduleTask(){let e=this;return t=>function(n){let r=Zone.current,i=e._getCurrentSpan(r);return i&&e._shouldCountTask(n,r)&&(e._incrementTask(i),e._checkForTimeout(n,i)),t.call(this,n)}}_patchZoneRunTask(){let e=this;return t=>function(n,r,i){let a=Array.isArray(i)&&i[0]instanceof Event?i[0]:void 0,o=a==null?void 0:a.target,s,c=this;if(o){if(s=e._createSpan(o,n.eventName),s)return e._incrementTask(s),c.run(()=>{try{return A.with(M.setSpan(A.active(),s),()=>{let e=Zone.current;return n._zone=e,t.call(e,n,r,i)})}finally{e._decrementTask(s)}})}else s=e._getCurrentSpan(c);try{return t.call(c,n,r,i)}finally{s&&e._shouldCountTask(n,c)&&e._decrementTask(s)}}}_shouldCountTask(e,t){if(e._zone&&(t=e._zone),!t||!e.data||e.data.isPeriodic)return!1;let n=this._getCurrentSpan(t);return!n||!this._spansData.get(n)?!1:e.type===`macroTask`||e.type===`microTask`}_tryToEndSpan(e,t){e&&this._spansData.get(e)&&(e.end(t),this._spansData.delete(e))}enable(){if(this._isEnabled||(this._isEnabled=!0,typeof this._zonePatched==`boolean`))return;let e=this._getZoneWithPrototype();this._diag.debug(`applying patch to`,this.moduleName,this.version,`zone:`,!!e),e?(this._zonePatched=!0,this._wrap(e.prototype,`runTask`,this._patchZoneRunTask()),this._wrap(e.prototype,`scheduleTask`,this._patchZoneScheduleTask()),this._wrap(e.prototype,`cancelTask`,this._patchZoneCancelTask())):(this._zonePatched=!1,this._getPatchableEventTargets().forEach(e=>{this._wrap(e,`addEventListener`,this._patchAddEventListener()),this._wrap(e,`removeEventListener`,this._patchRemoveEventListener())})),this._patchHistoryApi()}disable(){this._isEnabled&&(this._isEnabled=!1)}_getZoneWithPrototype(){return window.Zone}}})),Sh=n({AttributeNames:()=>dh,UserInteractionInstrumentation:()=>bh}),Ch=t((()=>{xh(),fh()}));Qu(),G(),H();var wh=[`http.url`,`url.full`],Th=[`http.status_code`,`http.response.status_code`],Eh=[`http.method`,`http.request.method`],Dh=e=>({test:e}),Oh=e=>typeof location>`u`?void 0:e.config.hooks.getViewPathGroup(location.href),kh=(e,t,n)=>{var r;t.setAttributes(e.applyRedact(W(W({},pp(e.getRuntimeAttributes(),Oh(e))),e.config.hooks.getPageAttributes())));let i;for(let n of wh){var a;let r=(a=t.attributes)==null?void 0:a[n];if(typeof r==`string`){let a=e.applyRedact({[n]:e.config.hooks.redactUrl(r)})[n];typeof a==`string`&&(i=a,t.setAttribute(n,a))}}let o=Th.map(e=>{var n;return(n=t.attributes)==null?void 0:n[e]}).find(e=>typeof e==`number`),s=Eh.map(e=>{var n;return(n=t.attributes)==null?void 0:n[e]}).find(e=>typeof e==`string`),c=(r=i)==null?wh.map(e=>{var n;return(n=t.attributes)==null?void 0:n[e]}).find(e=>typeof e==`string`):r;t.setAttributes(e.applyRedact(np({method:s,statusCode:o,subtype:n,url:c,urlPathTemplate:c?e.config.hooks.getViewPathGroup(c):void 0})))},Ah=(e,t,n)=>{let r=Oh(e);t.setAttributes(e.applyRedact(W(W(W({},pp(e.getRuntimeAttributes(),r)),e.config.hooks.getPageAttributes()),$({errorType:`none`,eventLabel:`文档加载`,spanSubtype:n,spanType:Q.document,targetLabel:r,traceScene:`page_load`}))))},jh=(e,t,n)=>{let r=e.config.hooks.redactUrl(n.name);t.setAttributes(e.applyRedact(W(W(W(W({},pp(e.getRuntimeAttributes(),Oh(e))),e.config.hooks.getPageAttributes()),rp({duration:n.duration,initiatorType:n.initiatorType||`other`,responseStatus:n.responseStatus,transferSize:n.transferSize,url:r,urlPathTemplate:e.config.hooks.getViewPathGroup(n.name)})),{},{"url.full":r})))},Mh=(e={})=>{var t,n,r,i;let a=[],o={documentLoad:(t=e.documentLoad)==null?!0:t,fetch:(n=e.fetch)==null?!0:n,xhr:(r=e.xhr)==null?!0:r,userInteraction:(i=e.userInteraction)==null?!0:i};return{name:`official-instrumentations`,enabled:!!(o.documentLoad||o.fetch||o.xhr||o.userInteraction),init(e){return V(function*(){let t=[Dh(t=>jp(e.config,t))],n=[Dh(t=>Np(e.config,t))],[r,i,s,c]=yield Promise.all([o.documentLoad?Promise.resolve().then(()=>(Zp(),Xp)):Promise.resolve(null),o.fetch?Promise.resolve().then(()=>(jm(),Am)):Promise.resolve(null),o.xhr?Promise.resolve().then(()=>(uh(),lh)):Promise.resolve(null),o.userInteraction?Promise.resolve().then(()=>(Ch(),Sh)):Promise.resolve(null)]);if(r&&a.push(new r.DocumentLoadInstrumentation({semconvStabilityOptIn:`http`,applyCustomAttributesOnSpan:{documentLoad:t=>Ah(e,t,`navigate`),documentFetch:t=>Ah(e,t,`document_fetch`),resourceFetch:(t,n)=>jh(e,t,n)}})),i&&a.push(new i.FetchInstrumentation({applyCustomAttributesOnSpan:t=>kh(e,t,`fetch`),ignoreUrls:t,propagateTraceHeaderCorsUrls:n,semconvStabilityOptIn:`http`,ignoreNetworkEvents:!1})),s&&a.push(new s.XMLHttpRequestInstrumentation({applyCustomAttributesOnSpan:t=>kh(e,t,`xhr`),ignoreUrls:t,propagateTraceHeaderCorsUrls:n,semconvStabilityOptIn:`http`,ignoreNetworkEvents:!1})),c){let e=o.userInteraction!==null&&typeof o.userInteraction==`object`?{eventNames:o.userInteraction.eventNames}:void 0;a.push(new c.UserInteractionInstrumentation(e))}Pu({instrumentations:a})})()},shutdown(){for(;a.length;){var e,t;(e=a.pop())==null||(t=e.disable)==null||t.call(e)}}}},Nh=e=>{let t=5381;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);return(t>>>0).toString(36)},Ph=(e,t)=>{let n=new Map,r=0,i=t=>{if(!(t-r<e)){r=t;for(let[r,i]of n)t-i.windowStart>e&&n.delete(r)}};return{allow(r){let a=Date.now();i(a);let o=n.get(r);return!o||a-o.windowStart>e?(n.set(r,{count:1,windowStart:a}),{allowed:!0,count:1}):(o.count+=1,{allowed:o.count<=t,count:o.count})}}};G();var Fh=6e4,Ih=5,Lh=/^https?:|^\/\//i,Rh=(e,t)=>{if(t)return Lh.test(t)?e(t):t},zh=()=>{let e;return{name:`csp-violation`,init(t){if(typeof window>`u`||typeof document>`u`)return;let n=Ph(Fh,Ih),r=e=>{let r=Nh(`${e.violatedDirective}|${e.blockedURI}|${e.sourceFile}|${e.lineNumber}`),i=n.allow(r);if(!i.allowed)return;let a=Rh(t.config.hooks.redactUrl,e.blockedURI),o=e.sourceFile?t.config.hooks.redactUrl(e.sourceFile):void 0,s=i.count===1;t.startSpan(`csp.violation`,W(W(W({},t.config.hooks.getPageAttributes()),$({errorType:`csp`,eventLabel:`CSP 错误`,result:Z.error,spanSubtype:`csp`,spanType:Q.error,targetLabel:a==null?e.effectiveDirective:a,targetValue:e.statusCode})),{},{"csp.blocked_uri":a,"csp.violated_directive":e.violatedDirective,"csp.effective_directive":e.effectiveDirective,"csp.disposition":e.disposition,"csp.source_file":o,"csp.line_number":e.lineNumber,"csp.column_number":e.columnNumber,"csp.status_code":e.statusCode,"csp.fingerprint":r,"csp.window_count":i.count,[X.exceptionFingerprint]:r,"error.source":`csp`},s?{"csp.original_policy":e.originalPolicy}:{})).end()};document.addEventListener(`securitypolicyviolation`,r),e=()=>document.removeEventListener(`securitypolicyviolation`,r)},shutdown(){e==null||e(),e=void 0}}},Bh=e=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;G();var Vh=`BK_RUM_DEVICE_ID`,Hh=250,Uh=()=>navigator.connection,Wh=()=>navigator.userAgentData,Gh=e=>{for(let[t,n]of[[`Edge`,/Edg\/([\d.]+)/],[`Chrome`,/Chrome\/([\d.]+)/],[`Firefox`,/Firefox\/([\d.]+)/],[`Safari`,/Version\/([\d.]+).*Safari/]]){let r=e.match(n);if(r!=null&&r[1])return{name:t,version:r[1].split(`.`)[0]}}return{name:`Other`,version:void 0}},Kh=(e,t)=>{let n=`${t==null?``:t} ${e}`;return/iphone|ipad|ipod/i.test(n)?`iOS`:/android/i.test(n)?`Android`:/mac/i.test(n)?`macOS`:/win/i.test(n)?`Windows`:/linux/i.test(n)?`Linux`:`Other`},qh=e=>{let t=null;try{t=window.localStorage.getItem(e)}catch(e){}if(t)return t;let n=Bh(`device`);try{window.localStorage.setItem(e,n)}catch(e){}return n},Jh=()=>{var e,t;return typeof window>`u`?{}:{"browser.viewport.width":window.innerWidth,"browser.viewport.height":window.innerHeight,"browser.screen.width":(e=window.screen)==null?void 0:e.width,"browser.screen.height":(t=window.screen)==null?void 0:t.height}},Yh=()=>{let e=Uh();return e?{"network.effective_type":e.effectiveType,"network.connection_type":e.type,"network.downlink":e.downlink,"network.rtt":e.rtt,"network.save_data":e.saveData}:{}},Xh=()=>{if(typeof navigator>`u`)return{};let e=Wh(),t=navigator.userAgent,n=Gh(t),r=Kh(t,e==null?void 0:e.platform),i=e!=null&&e.mobile||/mobi|android|iphone|ipad|ipod/i.test(t)?`mobile`:`desktop`;return{"device.memory":navigator.deviceMemory,"device.cpu_cores":navigator.hardwareConcurrency,"device.platform":e==null?void 0:e.platform,"device.mobile":e==null?void 0:e.mobile,[X.browserName]:n.name,[X.browserVersion]:n.version,[X.deviceType]:i,[X.osName]:r,"user_agent.name":n.name,"user_agent.version":n.version,"user_agent.os.name":r}},Zh=(e,t)=>{let n;return()=>{n!==void 0&&window.clearTimeout(n),n=window.setTimeout(()=>{n=void 0,e()},t)}},Qh=(e={})=>{var t;let n=[],r=(t=e.storageKey)==null?Vh:t;return{name:`device`,init(e){let t=typeof window>`u`?Bh(`device`):qh(r);if(e.setRuntimeAttributes(W(W(W({"device.id":t},Xh()),Jh()),Yh())),typeof window>`u`)return;let i=Zh(()=>{e.setRuntimeAttributes(Jh())},Hh);window.addEventListener(`resize`,i),window.addEventListener(`orientationchange`,i),n.push(()=>window.removeEventListener(`resize`,i),()=>window.removeEventListener(`orientationchange`,i));let a=Uh();if(a&&typeof a.addEventListener==`function`){let t=()=>{e.setRuntimeAttributes(Yh())};a.addEventListener(`change`,t),n.push(()=>{var e;(e=a.removeEventListener)==null||e.call(a,`change`,t)})}},shutdown(){for(;n.length;){var e;(e=n.pop())==null||e()}}}};N(),G();var $h=6e4,eg=5,tg=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>0?e:t,ng=e=>{if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch(t){return String(e)}},rg=e=>{var t;return e instanceof Error?(t=e.stack)==null?``:t:``},ig=e=>e.slice(0,80),ag=e=>{var t,n;return(t=(n=e.split(`
12
+ `).find(e=>e.trim().startsWith(`at `)))==null?void 0:n.trim())==null?``:t},og=e=>e===`unhandledrejection`?`promise`:e===`resource`?`resource_load`:`js`,sg=({context:e,error:t,exceptionType:n,extra:r={},source:i,spanName:a,throttle:o})=>{let s=ng(t),c=rg(t),l=Nh(`${i}|${s}|${c.slice(0,256)}`),u=o.allow(l);if(!u.allowed)return;let d=t instanceof Error?t:{message:s,name:n==null?i:n},f=W(W(W(W({},e.config.hooks.getPageAttributes()),e.config.hooks.getErrorAttributes()),$({errorType:og(i),eventLabel:`错误`,result:Z.error,spanSubtype:og(i),spanType:Q.error,targetLabel:t instanceof Error?t.name:n==null?i:n})),{},{"exception.message":s,[X.exceptionMessageShort]:ig(s),"exception.stacktrace":c,[X.exceptionStackTopFrame]:ag(c),"exception.type":t instanceof Error?t.name:n==null?i:n,[X.exceptionFingerprint]:l,"error.handled":!1,"error.source":i,"error.window_count":u.count},r),p=e.startSpan(a,f);p.recordException(d),p.setStatus({code:wt.ERROR,message:s}),p.end()},cg=(e={})=>{let t=[],n=tg(e.windowMs,$h),r=tg(e.maxPerWindow,eg);return{name:`error`,init(e){if(typeof window>`u`)return;let i=Ph(n,r),a=t=>{var n;let r=!t.error&&!t.filename&&t.message===`Script error.`;sg({context:e,throttle:i,spanName:`browser.error`,source:`window.error`,error:(n=t.error)==null?t.message:n,extra:W({"code.filepath":t.filename,"code.lineno":t.lineno,"code.column":t.colno},r?{"error.cross_origin":!0}:{})})},o=t=>{sg({context:e,throttle:i,spanName:`browser.unhandledrejection`,source:`unhandledrejection`,error:t.reason,exceptionType:t.reason instanceof Error?t.reason.name:`UnhandledRejection`})},s=t=>{if(t instanceof ErrorEvent)return;let n=t.target;if(!(n instanceof Element))return;let r=n,a=r.src||r.href||n.currentSrc||``;sg({context:e,throttle:i,spanName:`browser.resource_error`,source:`resource`,error:Error(`Resource load failed: ${n.tagName.toLowerCase()} ${a}`),exceptionType:`ResourceError`,extra:{"url.full":e.config.hooks.redactUrl(a),"html.tag":n.tagName}})};window.addEventListener(`error`,a),window.addEventListener(`unhandledrejection`,o),window.addEventListener(`error`,s,!0),t.push(()=>window.removeEventListener(`error`,a),()=>window.removeEventListener(`unhandledrejection`,o),()=>window.removeEventListener(`error`,s,!0))},shutdown(){for(;t.length;){var e;(e=t.pop())==null||e()}}}};bn(),H(),G();var lg=10*1024,ug=10,dg=e=>e.body,fg=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>0?e:t,pg=new WeakMap,mg=(e,t)=>e.length<=t?{body:e,truncated:!1}:{body:e.slice(0,t),truncated:!0},hg=(e,t)=>{if(!e)return;if(e instanceof Headers)return e.get(t)||void 0;let n=t.toLowerCase();if(Array.isArray(e)){var r;return(r=e.find(([e])=>e.toLowerCase()===n))==null?void 0:r[1]}let i=Object.keys(e).find(e=>e.toLowerCase()===n);return i?e[i]:void 0},gg=e=>{let t={};return e.forEach((e,n)=>{t[n]=e instanceof File?`[File name=${e.name} type=${e.type||`unknown`} size=${e.size}]`:e}),JSON.stringify(t)},_g=function(){var e=V(function*(e){return e==null?``:typeof e==`string`?e:e instanceof URLSearchParams?e.toString():e instanceof FormData?gg(e):e instanceof Blob?e.text():e instanceof ArrayBuffer||ArrayBuffer.isView(e)?new TextDecoder().decode(e):e instanceof Document?new XMLSerializer().serializeToString(e):String(e)});return function(t){return e.apply(this,arguments)}}(),vg=function(){var e=V(function*(e,t,n){let r=yield _g(e);if(r)return W(W({},mg(r,t)),{},{contentType:n})});return function(t,n,r){return e.apply(this,arguments)}}(),yg=function(){var e=V(function*(e,t,n){try{return yield vg(e,t,n)}catch(e){return}});return function(t,n,r){return e.apply(this,arguments)}}(),bg=e=>e instanceof Request?e.url:String(e),xg=(e,t)=>t!=null&&t.method?t.method:e instanceof Request?e.method:`GET`,Sg=(e,t,n)=>t!=null&&t.body?()=>yg(t.body,n,hg(t.headers,`content-type`)):(e instanceof Request,()=>Promise.resolve(void 0)),Cg=function(){var e=V(function*(e,t){try{let n=e.headers.get(`content-type`)||void 0,r=e.headers.get(`content-length`);if(r){let e=Number(r);if(Number.isFinite(e)&&e>t*ug)return{body:``,contentType:n,truncated:!0}}let i=e.clone();return yg(i.body?yield i.text():``,t,n)}catch(e){return}});return function(t,n){return e.apply(this,arguments)}}(),wg=(e,t)=>{if(e.responseType===``||e.responseType===`text`)return W(W({},mg(e.responseText||``,t)),{},{contentType:e.getResponseHeader(`content-type`)||void 0});if(e.responseType===`json`)return W(W({},mg(JSON.stringify(e.response),t)),{},{contentType:e.getResponseHeader(`content-type`)||void 0})},Tg=(e,t,n)=>{if(n)return e.redact(W(W({},t),{},{body:n.body,truncated:n.truncated}))},Eg=({config:e,context:t,duration:n,error:r,method:i,request:a,response:o,status:s,subtype:c,url:l})=>{let u=!!r||typeof s==`number`&&s>=400,d=i.toUpperCase(),f=u?Tg(e,{contentType:a==null?void 0:a.contentType,method:d,status:s,type:`request`,url:l},a):void 0,p=u?Tg(e,{contentType:o==null?void 0:o.contentType,method:d,status:s,type:`response`,url:l},o):void 0,m=W(W(W({},t.config.hooks.getPageAttributes()),np({duration:n,method:d,statusCode:s,subtype:c,url:t.config.hooks.redactUrl(l),urlPathTemplate:t.config.hooks.getViewPathGroup(l)})),{},{"http.duration":n,"http.request.method":d,"url.full":t.config.hooks.redactUrl(l)});if(typeof s==`number`&&(m[`http.response.status_code`]=s),f!=null&&(m[`http.request.body`]=f),p!=null&&(m[`http.response.body`]=p),u){var h,g;m[`http_body.request.truncated`]=(h=a==null?void 0:a.truncated)==null?!1:h,m[`http_body.response.truncated`]=(g=o==null?void 0:o.truncated)==null?!1:g}if(r instanceof Error){var _;m[`exception.message`]=r.message,m[`exception.type`]=r.name,m[`exception.stacktrace`]=(_=r.stack)==null?``:_}t.emitLog({severityNumber:u?en.ERROR:en.INFO,severityText:u?`ERROR`:`INFO`,body:u?`HTTP request completed with error`:`HTTP request completed`,attributes:m})},Dg=(e={})=>{var t;let n=[],r={maxBodySize:fg(e.maxBodySize,lg),redact:(t=e.redact)==null?dg:t};return{name:`http-body`,init(e){if(typeof window>`u`)return;let{maxBodySize:t}=r,i=window.fetch;if(typeof i==`function`){let a=function(){var n=V(function*(n,a){let o=bg(n);if(jp(e.config,o))return i(n,a);let s=xg(n,a),c=Sg(n,a,t),l=performance.now();try{let u=yield i(n,a),d=performance.now()-l,f=u.status>=400;return Eg({config:r,context:e,duration:d,method:s,request:f?yield c():void 0,response:f?yield Cg(u,t):void 0,status:u.status,subtype:`fetch`,url:o}),u}catch(t){let n=yield c();throw Eg({config:r,context:e,duration:performance.now()-l,error:t,method:s,request:n,subtype:`fetch`,url:o}),t}});return function(e,t){return n.apply(this,arguments)}}();window.fetch=a,n.push(()=>{window.fetch===a&&(window.fetch=i)})}let a=XMLHttpRequest.prototype.open,o=XMLHttpRequest.prototype.send,s=XMLHttpRequest.prototype.setRequestHeader,c=function(e,t,...n){var r;return pg.set(this,{method:e,startTime:performance.now(),url:String(t)}),a.call(this,e,t,(r=n[0])==null?!0:r,n[1],n[2])},l=function(e,t){let n=pg.get(this);if(n){var r;let i=e.toLowerCase(),a=(r=n.requestHeaders)==null?{}:r,o=a[i];a[i]=o?`${o}, ${t}`:t,n.requestHeaders=a}return s.call(this,e,t)},u=function(n){var i=this;let a=pg.get(this);if(a){var s;a.requestBody=n,a.requestContentType=(s=a.requestHeaders)==null?void 0:s[`content-type`]}return this.addEventListener(`abort`,()=>{let e=pg.get(this);e&&(e.aborted=!0)},{once:!0}),this.addEventListener(`error`,()=>{let e=pg.get(this);e&&(e.networkError=!0)},{once:!0}),this.addEventListener(`loadend`,()=>{V(function*(){let n=pg.get(i);if(!n||jp(e.config,n.url)||n.aborted)return;let a=n.networkError||i.status>=400,o=a?wg(i,t):void 0,s=a?yield yg(n.requestBody,t,n.requestContentType):void 0;Eg({config:r,context:e,duration:performance.now()-n.startTime,error:n.networkError?Error(`XHR network error`):void 0,method:n.method,request:s,response:o,status:i.status,subtype:`xhr`,url:n.url})})()},{once:!0}),o.call(this,n)};XMLHttpRequest.prototype.open=c,XMLHttpRequest.prototype.setRequestHeader=l,XMLHttpRequest.prototype.send=u,n.push(()=>{XMLHttpRequest.prototype.open===c&&(XMLHttpRequest.prototype.open=a),XMLHttpRequest.prototype.setRequestHeader===l&&(XMLHttpRequest.prototype.setRequestHeader=s),XMLHttpRequest.prototype.send===u&&(XMLHttpRequest.prototype.send=o)})},shutdown(){for(;n.length;){var e;(e=n.pop())==null||e()}}}};G();var Og=50,kg=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>=0?e:t,Ag=(e={})=>{let t,n=kg(e.threshold,Og);return{name:`long-task`,init(e){var r;if(typeof PerformanceObserver>`u`||!((r=PerformanceObserver.supportedEntryTypes)!=null&&r.includes(`longtask`)))return;let i=e.meter.createCounter(`browser.long_task.count`,{description:`Number of long tasks observed (duration >= threshold)`}),a=e.meter.createHistogram(`browser.long_task.duration`,{unit:`ms`,description:`Duration of long tasks`});try{t=new PerformanceObserver(t=>{let r=e.applyRedact(W(W(W({},e.config.hooks.getPageAttributes()),e.config.hooks.getMetricAttributes()),fp(e.getRuntimeAttributes())));for(let h of t.getEntries()){var o,s,c,l,u,d,f,p,m;if(h.duration<n)continue;let t=(o=h.attribution)==null?void 0:o[0],g=W(W({},r),{},{[X.longtaskAttributionScript]:(s=(c=t==null?void 0:t.containerSrc)==null?t==null?void 0:t.name:c)==null?`unknown`:s}),_=h.duration>100?Z.warning:Z.success;e.startSpan(`browser.long_task`,W(W(W({},r),$({duration:h.duration,errorType:_===Z.warning?`longtask_blocking`:`none`,eventLabel:`长任务`,result:_,spanSubtype:(l=t==null?void 0:t.name)==null?`unknown`:l,spanType:Q.longtask,targetLabel:(u=(d=(f=t==null?void 0:t.containerSrc)==null?t==null?void 0:t.containerName:f)==null?t==null?void 0:t.name:d)==null?`unknown`:u,targetValue:h.duration})),{},{[X.longtaskBlockingDuration]:h.duration,[X.longtaskAttributionScript]:(p=(m=t==null?void 0:t.containerSrc)==null?t==null?void 0:t.name:m)==null?`unknown`:p}),{startTime:performance.timeOrigin+h.startTime}).end(performance.timeOrigin+h.startTime+h.duration),i.add(1,g),a.record(h.duration,g)}}),t.observe({type:`longtask`,buffered:!0})}catch(e){t=void 0}},shutdown(){t==null||t.disconnect(),t=void 0}}},jg=new Set,Mg=``,Ng,Pg,Fg=!1,Ig=()=>typeof location>`u`?``:location.href,Lg=(e,t)=>{let n=Ig();Mg=n;let r={fromUrl:t,source:e,toUrl:n};for(let e of Array.from(jg))e(r)},Rg=()=>{Lg(`popstate`,Mg||Ig())},zg=()=>{Lg(`hashchange`,Mg||Ig())},Bg=()=>{Fg||typeof window>`u`||typeof history>`u`||(Fg=!0,Mg=Ig(),Ng=history.pushState,Pg=history.replaceState,history.pushState=function(e,t,n){let r=Mg||Ig(),i=Ng==null?void 0:Ng.apply(this,[e,t,n]);return Lg(`pushState`,r),i},history.replaceState=function(e,t,n){let r=Mg||Ig(),i=Pg==null?void 0:Pg.apply(this,[e,t,n]);return Lg(`replaceState`,r),i},window.addEventListener(`popstate`,Rg),window.addEventListener(`hashchange`,zg))},Vg=()=>{!Fg||typeof window>`u`||typeof history>`u`||(Ng&&(history.pushState=Ng),Pg&&(history.replaceState=Pg),window.removeEventListener(`popstate`,Rg),window.removeEventListener(`hashchange`,zg),Ng=void 0,Pg=void 0,Fg=!1,Mg=``)},Hg=e=>typeof window>`u`||typeof history>`u`?()=>{}:(Bg(),jg.add(e),()=>{jg.delete(e),jg.size===0&&Vg()});G();var Ug=()=>typeof location>`u`?``:location.href,Wg=()=>{let e=[];return{name:`page-view`,init(t){if(typeof window>`u`)return;let n=``,r,i=(e,i=n)=>{let a=Ug();if(a===n)return;r==null||r.setAttribute(`view.end_reason`,e),r==null||r.end(),n=a;let o=Bh(`view`),s=t.config.hooks.getViewPathGroup(a),c=e===`load`?`initial_load`:`route_change`,l=t.config.hooks.redactUrl(a),u=t.config.hooks.redactUrl(i);t.setView({id:o,loadingType:c,url:l,urlPathGroup:s});let d=e===`load`,f=W(W(W({},t.config.hooks.getPageAttributes()),$({errorType:`none`,eventLabel:d?`文档加载`:`路由切换`,spanSubtype:d?`navigate`:e,spanType:d?Q.document:Q.route,targetLabel:s,traceScene:d?`page_load`:`route_change`})),{},{[X.viewId]:o,[X.viewUrl]:l,[X.viewUrlPathGroup]:s,[X.viewLoadingType]:c,"url.previous":u,"event.source":e},d?{"document.referrer":t.config.hooks.redactUrl(document.referrer||``)}:{});r=t.startSpan(`browser.view`,f),t.startSpan(`browser.page_view`,W({},f)).end()},a=Hg(e=>{i(e.source,e.fromUrl)});i(`load`);let o=()=>{r==null||r.setAttribute(`view.end_reason`,`shutdown`),r==null||r.end(),r=void 0};window.addEventListener(`pagehide`,o),e.push(a,()=>window.removeEventListener(`pagehide`,o),o)},shutdown(){for(;e.length;){var t;(t=e.pop())==null||t()}}}};G();var Gg=e=>e.transferSize===0&&e.decodedBodySize>0?!0:void 0,Kg=()=>{let e,t=new Set;return{name:`resource`,init(n){var r;if(typeof PerformanceObserver>`u`||!((r=PerformanceObserver.supportedEntryTypes)!=null&&r.includes(`resource`)))return;let i=e=>{if(!e.name||jp(n.config,e.name))return;let r=`${e.name}|${e.startTime}`;if(t.has(r))return;t.add(r);let i=n.config.hooks.redactUrl(e.name),a=e.duration;n.startSpan(`browser.resource`,W(W(W({},n.config.hooks.getPageAttributes()),rp({duration:a,initiatorType:e.initiatorType||`other`,responseStatus:e.responseStatus,transferSize:e.transferSize,url:i,urlPathTemplate:n.config.hooks.getViewPathGroup(e.name)})),{},{"url.full":i,[X.transferSize]:e.transferSize,[X.cacheHit]:Gg(e),[X.nextHopProtocol]:e.nextHopProtocol,initiator_type:e.initiatorType||`other`,"resource.encoded_body_size":e.encodedBodySize,"resource.decoded_body_size":e.decodedBodySize}),{startTime:performance.timeOrigin+e.startTime}).end(performance.timeOrigin+e.startTime+a)};try{e=new PerformanceObserver(e=>{for(let t of e.getEntries())i(t)}),e.observe({type:`resource`,buffered:!0})}catch(t){e=void 0}},shutdown(){e==null||e.disconnect(),e=void 0,t.clear()}}};G();var qg=()=>{let e=[],t=!1;return{name:`route-timing`,init(n){if(typeof window>`u`||typeof history>`u`)return;let r=n.meter.createHistogram(`browser.route_change.duration`,{unit:`ms`,description:`Estimated SPA route change duration (route start to next idle)`}),i=(e,i,a)=>{if(t)return;let o=performance.now(),s=performance.timeOrigin+o,c=()=>{if(t||typeof document<`u`&&document.visibilityState===`hidden`)return;let c=performance.now()-o,l=c>500?Z.warning:Z.success,u=n.applyRedact(W(W(W(W({},n.config.hooks.getPageAttributes()),n.config.hooks.getMetricAttributes()),fp(n.getRuntimeAttributes())),{},{"route.change.source":e}));r.record(c,u),n.startSpan(`browser.route_change`,W(W(W({},u),$({duration:c,errorType:l===Z.warning?`slow`:`none`,eventLabel:`路由切换`,result:l,spanSubtype:e,spanType:Q.route,targetLabel:n.config.hooks.getViewPathGroup(a),targetValue:c,traceScene:`route_change`})),{},{"url.full":n.config.hooks.redactUrl(a),"url.previous":n.config.hooks.redactUrl(i)}),{startTime:s}).end()};requestAnimationFrame(()=>requestAnimationFrame(()=>setTimeout(c,0)))},a=Hg(e=>{e.fromUrl!==e.toUrl&&i(e.source,e.fromUrl,e.toUrl)});e.push(a)},shutdown(){for(t=!0;e.length;){var n;(n=e.pop())==null||n()}}}};bn(),G();var Jg=1800*1e3,Yg=1440*60*1e3,Xg=6e4,Zg=5e3,Qg=[`click`,`keydown`,`scroll`,`mousemove`,`touchstart`],$g=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>0?e:t,e_=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>0&&e<=t+Zg,t_=(e,t)=>{if(!e)return null;try{let n=JSON.parse(e);if(typeof(n==null?void 0:n.id)==`string`&&e_(n.ts,t)&&e_(n.startedAt,t))return n}catch(e){}return null},n_=(e,t)=>{if(typeof window>`u`)return null;let n=null;try{n=window.localStorage.getItem(e)}catch(e){}let r=t_(n,t);if(r)return r;try{n=window.sessionStorage.getItem(e)}catch(e){}return r=t_(n,t),r},r_=(e,t)=>{if(typeof window>`u`)return;let n=JSON.stringify(t);try{window.sessionStorage.setItem(e,n)}catch(e){}try{window.localStorage.setItem(e,n)}catch(e){}},i_=(e,t,n)=>{let r=Date.now(),i=n_(e,r);if(i){let a=r-i.ts>=t,o=r-i.startedAt>=n;if(!a&&!o){let t=W(W({},i),{},{ts:r});return r_(e,t),{id:t.id,rotated:!1}}let s=a?`inactivity`:`maxLifetime`,c={id:Bh(`session`),startedAt:r,ts:r};return r_(e,c),{id:c.id,prevId:i.id,reason:s,rotated:!0}}let a={id:Bh(`session`),startedAt:r,ts:r};return r_(e,a),{id:a.id,reason:`init`,rotated:!0}},a_=e=>{let t=``;try{t=new URL(e).host}catch(n){t=e}return`bk_ot_session__${Nh(t||`default`)}`},o_=(e,t)=>{if(!t.rotated||!t.reason)return;let n=Date.now();e.emitLog({severityNumber:en.INFO,severityText:`INFO`,body:t.reason===`init`?`session.start`:`session.rotate`,attributes:W(W({},e.config.hooks.getPageAttributes()),{},{[X.sessionHasReplay]:!1,[X.sessionId]:t.id,[X.sessionStartTime]:n,"session.rotate.reason":t.reason},t.prevId?{"session.previous_id":t.prevId}:{})})},s_=(e={})=>{let t=[],n=$g(e.inactivityMs,Jg),r=$g(e.maxLifetimeMs,Yg);return{name:`session`,init(i){var a;let o=(a=e.storageKey)==null?a_(i.config.transport.endpoint):a,s=``,c=()=>{if(typeof window>`u`){s||(s=Bh(`session`),i.setRuntimeAttributes({[X.sessionHasReplay]:!1,[X.sessionId]:s}));return}let e=i_(o,n,r);i.setRuntimeAttributes({[X.sessionHasReplay]:!1,[X.sessionId]:e.id}),e.id!==s&&(s=e.id,o_(i,e))};if(c(),typeof window>`u`||typeof document>`u`)return;let l=Date.now(),u=()=>{let e=Date.now();e-l<Xg||(l=e,c())},d={capture:!0,passive:!0};Qg.forEach(e=>{window.addEventListener(e,u,d)}),t.push(()=>{Qg.forEach(e=>{window.removeEventListener(e,u,d)})});let f=()=>{document.visibilityState===`visible`&&c()};document.addEventListener(`visibilitychange`,f),t.push(()=>document.removeEventListener(`visibilitychange`,f));let p=e=>{if(e.storageArea!==window.localStorage||e.key!==o||!e.newValue)return;let t=Date.now(),n=t_(e.newValue,t);if(!(!n||n.id===s)){s=n.id;try{window.sessionStorage.setItem(o,e.newValue)}catch(e){}i.setRuntimeAttributes({[X.sessionId]:n.id})}};window.addEventListener(`storage`,p),t.push(()=>window.removeEventListener(`storage`,p))},shutdown(){for(;t.length;){var e;(e=t.pop())==null||e()}}}},c_=n({CLSThresholds:()=>N_,FCPThresholds:()=>j_,INPThresholds:()=>q_,LCPThresholds:()=>X_,TTFBThresholds:()=>Q_,onCLS:()=>F_,onFCP:()=>I_,onINP:()=>J_,onLCP:()=>Z_,onTTFB:()=>ev});function l_(e,t){return h_.get(e)||h_.set(e,new t),h_.get(e)}var u_,d_,f_,p_,m_,h_,g_,__,v_,y_,b_,x_,S_,C_,w_,T_,E_,D_,O_,k_,A_,j_,M_,N_,P_,F_,I_,L_,R_,z_,B_,V_,H_,U_,W_,G_,K_,q_,J_,Y_,X_,Z_,Q_,$_,ev,tv=t((()=>{F(),G(),u_=class{constructor(){P(this,`t`,void 0),P(this,`o`,0),P(this,`i`,[])}u(e){var t;if(e.hadRecentInput)return;let n=this.i[0],r=this.i.at(-1);this.o&&n&&r&&e.startTime-r.startTime<1e3&&e.startTime-n.startTime<5e3?(this.o+=e.value,this.i.push(e)):(this.o=e.value,this.i=[e]),(t=this.t)==null||t.call(this,e)}},d_=()=>{let e=performance.getEntriesByType(`navigation`)[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},f_=e=>{if(document.readyState===`loading`)return`loading`;let t=d_();if(t){if(e<t.domInteractive)return`loading`;if(t.domContentLoadedEventStart===0||e<t.domContentLoadedEventStart)return`dom-interactive`;if(t.domComplete===0||e<t.domComplete)return`dom-content-loaded`}return`complete`},p_=e=>{let t=e.nodeName;return e.nodeType===1?t.toLowerCase():t.toUpperCase().replace(/^#/,``)},m_=e=>{let t=``;try{for(;(e==null?void 0:e.nodeType)!==9;){let n=e,r=n.id?`#`+n.id:[p_(n),...Array.from(n.classList).sort()].join(`.`);if(t.length+r.length>99)return t||r;if(t=t?r+`>`+t:r,n.id)break;e=n.parentNode}}catch(e){}return t},h_=new WeakMap,g_=-1,__=()=>g_,v_=e=>{addEventListener(`pageshow`,t=>{t.persisted&&(g_=t.timeStamp,e(t))},!0)},y_=(e,t,n,r)=>{let i,a;return o=>{var s;t.value>=0&&(o||r)&&(a=t.value-((s=i)==null?0:s),(a||i===void 0)&&(i=t.value,t.delta=a,t.rating=((e,t)=>e>t[1]?`poor`:e>t[0]?`needs-improvement`:`good`)(t.value,n),e(t)))}},b_=e=>{requestAnimationFrame(()=>requestAnimationFrame(e))},x_=()=>{var e,t;return(e=(t=d_())==null?void 0:t.activationStart)==null?0:e},S_=(e,t=-1)=>{let n=d_(),r=`navigate`;return __()>=0?r=`back-forward-cache`:n&&(document.prerendering||x_()>0?r=`prerender`:document.wasDiscarded?r=`restore`:n.type&&(r=n.type.replace(/_/g,`-`))),{name:e,value:t,rating:`good`,delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+0xe8d4a51000}`,navigationType:r}},C_=(e,t,n={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){let r=new PerformanceObserver(e=>{queueMicrotask(()=>{t(e.getEntries())})});return r.observe(W({type:e,buffered:!0},n)),r}}catch(e){}},w_=e=>{let t=!1;return()=>{t||(e(),t=!0)}},T_=-1,E_=new Set,D_=()=>document.visibilityState!==`hidden`||document.prerendering?1/0:0,O_=e=>{if(document.visibilityState===`hidden`){if(e.type===`visibilitychange`)for(let e of E_)e();isFinite(T_)||(T_=e.type===`visibilitychange`?e.timeStamp:0,removeEventListener(`prerenderingchange`,O_,!0))}},k_=()=>{if(T_<0){var e;let t=x_(),n=document.prerendering||(e=globalThis.performance.getEntriesByType(`visibility-state`).find(e=>e.name===`hidden`&&e.startTime>=t))==null?void 0:e.startTime;T_=n==null?D_():n,addEventListener(`visibilitychange`,O_,!0),addEventListener(`prerenderingchange`,O_,!0),v_(()=>{setTimeout(()=>{T_=D_()})})}return{get firstHiddenTime(){return T_},onHidden(e){E_.add(e)}}},A_=e=>{document.prerendering?addEventListener(`prerenderingchange`,e,!0):e()},j_=[1800,3e3],M_=(e,t={})=>{A_(()=>{let n=k_(),r,i=S_(`FCP`),a=C_(`paint`,e=>{for(let t of e)t.name===`first-contentful-paint`&&(a.disconnect(),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-x_(),0),i.entries.push(t),r(!0)))});a&&(r=y_(e,i,j_,t.reportAllChanges),v_(n=>{i=S_(`FCP`),r=y_(e,i,j_,t.reportAllChanges),b_(()=>{i.value=performance.now()-n.timeStamp,r(!0)})}))})},N_=[.1,.25],P_=e=>e.find(e=>{var t;return((t=e.node)==null?void 0:t.nodeType)===1})||e[0],F_=(e,t={})=>{let n=l_(t=Object.assign({},t),u_),r=new WeakMap;n.t=e=>{var n;if(!(e==null||(n=e.sources)==null)&&n.length){let n=P_(e.sources),o=n==null?void 0:n.node;if(o){var i,a;let e=(i=(a=t.generateTarget)==null?void 0:a.call(t,o))==null?m_(o):i;r.set(n,e)}}},((e,t={})=>{let n=k_();M_(w_(()=>{let r,i=S_(`CLS`,0),a=l_(t,u_),o=e=>{for(let t of e)a.u(t);a.o>i.value&&(i.value=a.o,i.entries=a.i,r())},s=C_(`layout-shift`,o);s&&(r=y_(e,i,N_,t.reportAllChanges),n.onHidden(()=>{o(s.takeRecords()),r(!0)}),v_(()=>{a.o=0,i=S_(`CLS`,0),r=y_(e,i,N_,t.reportAllChanges),b_(r)}),setTimeout(r))}))})(t=>{e((e=>{let t={};if(e.entries.length){var n;let i=e.entries.reduce((e,t)=>e.value>t.value?e:t);if(!(i==null||(n=i.sources)==null)&&n.length){let e=P_(i.sources);e&&(t={largestShiftTarget:r.get(e),largestShiftTime:i.startTime,largestShiftValue:i.value,largestShiftSource:e,largestShiftEntry:i,loadState:f_(i.startTime)})}}return Object.assign(e,{attribution:t})})(t))},t)},I_=(e,t={})=>{M_(t=>{e((e=>{let t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:f_(__())};if(e.entries.length){let n=d_(),r=e.entries.at(-1);if(n){let i=n.activationStart||0,a=Math.max(0,n.responseStart-i);t={timeToFirstByte:a,firstByteToFCP:e.value-a,loadState:f_(e.entries[0].startTime),navigationEntry:n,fcpEntry:r}}}return Object.assign(e,{attribution:t})})(t))},t)},L_=0,R_=1/0,z_=0,B_=e=>{for(let t of e)t.interactionId&&(R_=Math.min(R_,t.interactionId),z_=Math.max(z_,t.interactionId),L_=z_?(z_-R_)/7+1:0)},H_=()=>{var e;return V_?L_:(e=performance.interactionCount)==null?0:e},U_=()=>{`interactionCount`in performance||V_||(V_=C_(`event`,B_,{durationThreshold:0}))},W_=0,G_=class{constructor(){P(this,`l`,[]),P(this,`h`,new Map),P(this,`m`,void 0),P(this,`p`,void 0)}v(){W_=H_(),this.l.length=0,this.h.clear()}M(){let e=Math.min(this.l.length-1,Math.floor((H_()-W_)/50));return this.l[e]}u(e){var t;if((t=this.m)==null||t.call(this,e),!e.interactionId&&e.entryType!==`first-input`)return;let n=this.l.at(-1),r=this.h.get(e.interactionId);if(r||this.l.length<10||e.duration>n.T){var i;if(r?e.duration>r.T?(r.entries=[e],r.T=e.duration):e.duration===r.T&&e.startTime===r.entries[0].startTime&&r.entries.push(e):(r={id:e.interactionId,entries:[e],T:e.duration},this.h.set(r.id,r),this.l.push(r)),this.l.sort((e,t)=>t.T-e.T),this.l.length>10){let e=this.l.splice(10);for(let t of e)this.h.delete(t.id)}(i=this.p)==null||i.call(this,r)}}},K_=e=>{let t=globalThis.requestIdleCallback||setTimeout,n=globalThis.cancelIdleCallback||clearTimeout;if(document.visibilityState===`hidden`)e();else{let r=w_(e),i=-1,a=()=>{n(i),r()};addEventListener(`visibilitychange`,a,{once:!0,capture:!0}),i=t(()=>{removeEventListener(`visibilitychange`,a,{capture:!0}),r()})}},q_=[200,500],J_=(e,t={})=>{let n=l_(t=Object.assign({},t),G_),r=[],i=[],a=0,o=new WeakMap,s=new WeakMap,c=!1,l=()=>{c||(K_(u),c=!0)},u=()=>{let e=new Set(n.l.map(e=>o.get(e.entries[0]))),t=i.length-10;i=i.filter((n,r)=>r>=t||e.has(n));let s=new Set;for(let e of i){let t=d(e.startTime,e.processingEnd);for(let e of t)s.add(e)}r=r.filter(e=>e.startTime>a||s.has(e)),c=!1};n.m=e=>{let n=e.startTime+e.duration,r;a=Math.max(a,e.processingEnd);for(let a=i.length-1;a>=0;a--){let o=i[a];if(Math.abs(n-o.renderTime)<=8){r=o,r.startTime=Math.min(e.startTime,r.startTime),r.processingStart=Math.min(e.processingStart,r.processingStart),r.processingEnd=Math.max(e.processingEnd,r.processingEnd),!1!==t.includeProcessedEventEntries&&r.entries.push(e);break}}r||(r={startTime:e.startTime,processingStart:e.processingStart,processingEnd:e.processingEnd,renderTime:n,entries:!1===t.includeProcessedEventEntries?[]:[e]},i.push(r)),(e.interactionId||e.entryType===`first-input`)&&o.set(e,r),l()},n.p=e=>{if(!s.get(e)){let i=e.entries[0].target;if(i){var n,r;let a=(n=(r=t.generateTarget)==null?void 0:r.call(t,i))==null?m_(i):n;s.set(e,a)}}};let d=(e,t)=>{let n=[];for(let i of r)if(!(i.startTime+i.duration<e)){if(i.startTime>t)break;n.push(i)}return n},f=e=>{let t=e.entries[0],r=o.get(t),i=t.processingStart,a=Math.max(t.startTime+t.duration,i),c=Math.min(r.processingEnd,a),l=r.entries.sort((e,t)=>e.processingStart-t.processingStart),u=d(t.startTime,c),f=n.h.get(t.interactionId),p={interactionTarget:s.get(f),interactionType:t.name.startsWith(`key`)?`keyboard`:`pointer`,interactionTime:t.startTime,nextPaintTime:a,processedEventEntries:l,longAnimationFrameEntries:u,inputDelay:i-t.startTime,processingDuration:c-i,presentationDelay:a-c,loadState:f_(t.startTime),longestScript:void 0,totalScriptDuration:void 0,totalStyleAndLayoutDuration:void 0,totalPaintDuration:void 0,totalUnattributedDuration:void 0};return(e=>{var t;if(!((t=e.longAnimationFrameEntries)!=null&&t.length))return;let n=e.interactionTime,r=e.inputDelay,i=e.processingDuration,a,o,s=0,c=0,l=0,u=0;for(let t of e.longAnimationFrameEntries){c=c+t.startTime+t.duration-t.styleAndLayoutStart;for(let e of t.scripts){let t=e.startTime+e.duration;if(t<n)continue;let l=t-Math.max(n,e.startTime),d=e.duration?l/e.duration*e.forcedStyleAndLayoutDuration:0;s+=l-d,c+=d,l>u&&(o=e.startTime<n+r?`input-delay`:e.startTime>=n+r+i?`presentation-delay`:`processing-duration`,a=e,u=l)}}let d=e.longAnimationFrameEntries.at(-1),f=d?d.startTime+d.duration:0;f>=n+r+i&&(l=e.nextPaintTime-f),a&&o&&(e.longestScript={entry:a,subpart:o,intersectingDuration:u}),e.totalScriptDuration=s,e.totalStyleAndLayoutDuration=c,e.totalPaintDuration=l,e.totalUnattributedDuration=e.nextPaintTime-n-s-c-l})(p),Object.assign(e,{attribution:p})};C_(`long-animation-frame`,e=>{r=r.concat(e),l()}),((e,t={})=>{if(!globalThis.PerformanceEventTiming||!(`interactionId`in PerformanceEventTiming.prototype))return;let n=k_();A_(()=>{var r;U_();let i,a=S_(`INP`),o=l_(t,G_),s=e=>{K_(()=>{for(let t of e)o.u(t);let t=o.M();t&&t.T!==a.value&&(a.value=t.T,a.entries=t.entries,i())})},c=C_(`event`,s,{durationThreshold:(r=t.durationThreshold)==null?40:r});i=y_(e,a,q_,t.reportAllChanges),c&&(c.observe({type:`first-input`,buffered:!0}),n.onHidden(()=>{s(c.takeRecords()),i(!0)}),v_(()=>{o.v(),a=S_(`INP`),i=y_(e,a,q_,t.reportAllChanges)}))})})(t=>{e(f(t))},t)},Y_=class{constructor(){P(this,`m`,void 0)}u(e){var t;(t=this.m)==null||t.call(this,e)}},X_=[2500,4e3],Z_=(e,t={})=>{let n=l_(t=Object.assign({},t),Y_),r=new WeakMap;n.m=e=>{let n=e.element;if(n){var i,a;let o=(i=(a=t.generateTarget)==null?void 0:a.call(t,n))==null?m_(n):i;r.set(e,o)}else e.id&&r.set(e,`#${e.id}`)},((e,t={})=>{A_(()=>{let n=k_(),r,i=S_(`LCP`),a=l_(t,Y_),o=e=>{t.reportAllChanges||(e=e.slice(-1));for(let t of e)a.u(t),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-x_(),0),i.entries=[t],r())},s=C_(`largest-contentful-paint`,o);if(s){r=y_(e,i,X_,t.reportAllChanges);let n=w_(()=>{o(s.takeRecords()),s.disconnect(),r(!0)}),a=e=>{e.isTrusted&&(K_(n),removeEventListener(e.type,a,{capture:!0}))};for(let e of[`keydown`,`click`,`visibilitychange`])addEventListener(e,a,{capture:!0});v_(n=>{i=S_(`LCP`),r=y_(e,i,X_,t.reportAllChanges),b_(()=>{i.value=performance.now()-n.timeStamp,r(!0)})})}})})(t=>{e((e=>{let t={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:e.value};if(e.entries.length){let n=e.entries.at(-1),i=n.url&&performance.getEntriesByType(`resource`).find(e=>e.name===n.url);t.target=r.get(n),t.lcpEntry=n,n.url&&(t.url=n.url),i&&(t.lcpResourceEntry=i);let a=d_();if(a){let n=a.activationStart||0,r=Math.max(0,a.responseStart-n),o=Math.max(r,i?(i.requestStart||i.startTime)-n:0),s=Math.min(e.value,Math.max(o,i?i.responseEnd-n:0));t=W(W({},t),{},{timeToFirstByte:r,resourceLoadDelay:o-r,resourceLoadDuration:s-o,elementRenderDelay:e.value-s,navigationEntry:a})}}return Object.assign(e,{attribution:t})})(t))},t)},Q_=[800,1800],$_=e=>{document.prerendering?A_(()=>$_(e)):document.readyState===`complete`?setTimeout(e):addEventListener(`load`,()=>$_(e),!0)},ev=(e,t={})=>{((e,t={})=>{let n=S_(`TTFB`),r=y_(e,n,Q_,t.reportAllChanges);$_(()=>{let i=d_();i&&(n.value=Math.max(i.responseStart-x_(),0),n.entries=[i],r(!0),v_(()=>{n=S_(`TTFB`,0),r=y_(e,n,Q_,t.reportAllChanges),r(!0)}))})})(t=>{e((e=>{let t={waitingDuration:0,cacheDuration:0,dnsDuration:0,connectionDuration:0,requestDuration:0};if(e.entries.length){let n=e.entries[0],r=n.activationStart||0,i=Math.max((n.workerStart||n.fetchStart)-r,0),a=Math.max(n.domainLookupStart-r,0),o=Math.max(n.connectStart-r,0),s=Math.max(n.connectEnd-r,0);t={waitingDuration:i,cacheDuration:a-i,dnsDuration:o-a,connectionDuration:s-o,requestDuration:e.value-s,navigationEntry:n}}return Object.assign(e,{attribution:t})})(t))},t)}}));G(),H();var nv=`unknown`,rv=e=>e?e.replace(/_/g,`-`):nv,iv=()=>{if(typeof performance>`u`)return nv;let e=performance.getEntriesByType(`navigation`)[0];return rv(e==null?void 0:e.type)},av=(e,t)=>{var n;return{"rum.navigation.type":(n=e.navigationType)==null?t:n,[X.vitalMetric]:e.name.toLowerCase(),[X.vitalRating]:e.rating}},ov=(e,t)=>{var n;let r=(n=e.attribution)==null?{}:n,i={},a=e=>r[e],o=(e,t,n)=>{t!=null&&(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)&&(i[e]=typeof t==`string`&&n?n(t):t)};switch(e.name){case`LCP`:o(`vital.lcp.url`,a(`url`),t),o(`vital.lcp.target`,a(`target`)),o(`vital.lcp.element_render_delay`,a(`elementRenderDelay`)),o(`vital.lcp.resource_load_duration`,a(`resourceLoadDuration`)),o(`vital.lcp.time_to_first_byte`,a(`timeToFirstByte`));break;case`CLS`:o(`vital.cls.largest_shift_target`,a(`largestShiftTarget`)),o(`vital.cls.largest_shift_value`,a(`largestShiftValue`)),o(`vital.cls.load_state`,a(`loadState`));break;case`INP`:o(`vital.inp.interaction_target`,a(`interactionTarget`)),o(`vital.inp.interaction_type`,a(`interactionType`)),o(`vital.inp.input_delay`,a(`inputDelay`)),o(`vital.inp.processing_duration`,a(`processingDuration`)),o(`vital.inp.presentation_delay`,a(`presentationDelay`));break;case`FCP`:o(`vital.fcp.time_to_first_byte`,a(`timeToFirstByte`)),o(`vital.fcp.load_state`,a(`loadState`));break;case`TTFB`:o(`vital.ttfb.waiting_duration`,a(`waitingDuration`)),o(`vital.ttfb.dns_duration`,a(`dnsDuration`)),o(`vital.ttfb.connection_duration`,a(`connectionDuration`)),o(`vital.ttfb.request_duration`,a(`requestDuration`));break;default:break}return i},sv=()=>{let e=!1;return{name:`web-vitals`,init(t){return V(function*(){if(typeof window>`u`)return;let n;try{n=yield Promise.resolve().then(()=>(tv(),c_))}catch(e){if(t.config.debug){var r;(r=globalThis.console)==null||r.warn(`[bk-ot] web-vitals load failed:`,e)}return}if(e)return;let{onCLS:i,onFCP:a,onINP:o,onLCP:s,onTTFB:c}=n,l=iv(),u=t.meter.createHistogram(`browser.web_vital.cls`,{unit:`1`,description:`Cumulative Layout Shift`}),d=t.meter.createHistogram(`browser.web_vital.duration`,{unit:`ms`,description:`Web Vitals duration metrics, including FCP, INP, LCP and TTFB`}),f=e=>{let n=e.name.toLowerCase();t.startSpan(`browser.web_vital`,W(W(W(W(W({},t.config.hooks.getPageAttributes()),t.config.hooks.getMetricAttributes()),av(e,l)),$({duration:e.name===`CLS`?void 0:e.value,errorType:e.rating===`good`?`none`:`slow`,eventLabel:`Web 指标`,result:ep(e.rating),spanSubtype:n,spanType:Q.vital,targetLabel:n,targetValue:e.value})),{},{[X.vitalMetric]:n,[X.vitalValue]:e.value,[X.vitalRating]:e.rating,"vital.id":e.id},ov(e,t.config.hooks.redactUrl))).end()},p=n=>{e||!Number.isFinite(n.value)||(d.record(n.value,t.applyRedact(W(W(W(W({},t.config.hooks.getPageAttributes()),t.config.hooks.getMetricAttributes()),fp(t.getRuntimeAttributes())),av(n,l)))),f(n))};i(n=>{e||!Number.isFinite(n.value)||(u.record(n.value,t.applyRedact(W(W(W(W({},t.config.hooks.getPageAttributes()),t.config.hooks.getMetricAttributes()),fp(t.getRuntimeAttributes())),av(n,l)))),f(n))}),a(p),o(p),s(p),c(p)})()},shutdown(){e=!0}}};N(),bn(),G();var cv=64*1024,lv=6e4,uv=5,dv=e=>e==null?0:typeof e==`string`?e.length>cv||typeof TextEncoder>`u`?e.length:new TextEncoder().encode(e).byteLength:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:typeof Blob<`u`&&e instanceof Blob?e.size:0,fv=(e,t)=>{let n={"network.protocol.name":`websocket`,"url.full":t(e)},r={"network.protocol.name":`websocket`};try{let t=new URL(e,typeof location>`u`?`http://localhost`:location.href);n[`server.address`]=t.host,n[`url.scheme`]=t.protocol.replace(`:`,``),r[`server.address`]=t.host,r[`url.scheme`]=n[`url.scheme`]}catch(e){}return{metricAttributes:r,spanAttributes:n}},pv=(e,t)=>{var n;let{bytesCounter:r,connectDurationHistogram:i,context:a,errorCounter:o,errorThrottle:s,isDisposed:c,messageCounter:l,url:u}=t,{metricAttributes:d,spanAttributes:f}=fv(u,a.config.hooks.redactUrl),p=a.applyRedact(W(W({},a.config.hooks.getMetricAttributes()),d)),m=(n=f[`server.address`])==null?f[`url.full`]:n,h=a.startSpan(`websocket.connect`,W(W(W({},f),$({errorType:`none`,eventLabel:`WebSocket`,spanSubtype:`websocket`,spanType:Q.custom,targetLabel:m})),f[`server.address`]?{[X.targetDomain]:f[`server.address`]}:{})),g=performance.now(),_=!1,v=e=>{if(_)return;_=!0;let t=performance.now()-g;e===`error`&&h.setStatus({code:wt.ERROR,message:`websocket connect failed`}),h.setAttributes($({duration:t,errorType:e===`error`?`network`:`none`,eventLabel:`WebSocket`,result:e===`error`?Z.error:Z.success,spanSubtype:`websocket`,spanType:Q.custom,targetLabel:m,targetValue:t})),h.end(),e===`opened`&&!c()&&i.record(t,p)};e.addEventListener(`open`,()=>{c()||v(`opened`)}),e.addEventListener(`message`,e=>{if(c())return;let t=W(W({},p),{},{"websocket.direction":`in`});l.add(1,t),r.add(dv(e.data),t)}),e.addEventListener(`error`,()=>{if(c())return;let e=_?`runtime`:`connect`;o.add(1,W(W({},p),{},{"websocket.error.phase":e})),v(`error`);let t=s.allow(`ws:error:${u}`);t.allowed&&a.emitLog({severityNumber:en.ERROR,severityText:`ERROR`,body:`websocket.error`,attributes:W(W(W({},f),$({errorType:`network`,eventLabel:`WebSocket 错误`,result:Z.error,spanSubtype:`websocket`,spanType:Q.custom,targetLabel:m})),{},{"websocket.error.phase":e,"websocket.error.window_count":t.count})})}),e.addEventListener(`close`,e=>{c()||(_||v(`error`),a.emitLog({severityNumber:en.INFO,severityText:`INFO`,body:`websocket.close`,attributes:W(W(W({},f),$({errorType:e.wasClean?`none`:`network`,eventLabel:`WebSocket 关闭`,result:e.wasClean?Z.success:Z.warning,spanSubtype:`websocket`,spanType:Q.custom,targetLabel:m,targetValue:e.code})),{},{"websocket.close.code":e.code,"websocket.close.reason":e.reason,"websocket.close.was_clean":e.wasClean})}))});let y=e.send.bind(e);e.send=e=>{if(!c()){let t=W(W({},p),{},{"websocket.direction":`out`});l.add(1,t),r.add(dv(e),t)}return y(e)}},mv=()=>{let e,t,n=!1;return{name:`websocket`,init(r){if(typeof window>`u`||window.WebSocket===void 0)return;let i=window.WebSocket;e=i;let a=r.meter.createCounter(`browser.websocket.message.count`,{description:`Total number of WebSocket messages observed`}),o=r.meter.createCounter(`browser.websocket.message.bytes`,{unit:`By`,description:`Total bytes transferred over WebSocket (best-effort)`}),s=r.meter.createCounter(`browser.websocket.error.count`,{description:`Total number of WebSocket error events`}),c=r.meter.createHistogram(`browser.websocket.connect.duration`,{unit:`ms`,description:`WebSocket connection establishment duration (only successful connects)`}),l=Ph(lv,uv),u=()=>n;t=new Proxy(i,{construct(e,t,i){let d=Reflect.construct(e,t,i);if(n)return d;let f=t[0]==null?``:String(t[0]);return!f||jp(r.config,f)||pv(d,{bytesCounter:o,connectDurationHistogram:c,context:r,errorCounter:s,errorThrottle:l,isDisposed:u,messageCounter:a,url:f}),d}}),window.WebSocket=t},shutdown(){n=!0,typeof window<`u`&&e&&window.WebSocket===t&&(window.WebSocket=e),t=void 0,e=void 0}}};G();var hv=`http://localhost:4318`,gv=60*1e3,_v=`unknown_service`,vv=e=>e.replace(/\/+$/,``),yv=(e,t)=>{let n=vv(e||hv);return n.endsWith(`/v1/${t}`)?n:n.endsWith(`/v1`)?`${n}/${t}`:`${n}/v1/${t}`},bv=(e,t)=>{var n,r,i,a,o;let s=e==null||(n=e.signals)==null?void 0:n[t],c=e==null||(r=e.signals)==null||(r=r.endpoints)==null?void 0:r[t],l=e!=null&&e.token||e!=null&&e.headers||s!=null&&s.headers?W(W(W({},e!=null&&e.token?{Authorization:`Bearer ${e.token}`}:{}),(i=e==null?void 0:e.headers)==null?{}:i),(a=s==null?void 0:s.headers)==null?{}:a):void 0;return{concurrencyLimit:s==null?void 0:s.concurrencyLimit,endpoint:c?vv(c):yv((o=s==null?void 0:s.endpoint)==null?e==null?void 0:e.endpoint:o,t),headers:l,timeoutMillis:s==null?void 0:s.timeoutMillis}},xv=e=>typeof e!=`number`||!Number.isFinite(e)?1:Math.max(0,Math.min(1,e)),Sv=e=>e,Cv=e=>e,wv=e=>{try{return new URL(e,typeof location>`u`?`http://localhost`:location.href).pathname||`/`}catch(t){return e||`/`}},Tv=e=>{var t,n;return{environment:(t=e==null?void 0:e.environment)==null?`production`:t,name:(n=e==null?void 0:e.name)==null?_v:n,version:e==null?void 0:e.version}},Ev=e=>W(W({[X.deploymentEnvironmentName]:e.environment,"rum.provider":`blueking`,[X.serviceName]:e.name},e.version?{[X.serviceVersion]:e.version}:{}),{},{"telemetry.sdk.language":`webjs`}),Dv=e=>({endpoint:vv((e==null?void 0:e.endpoint)||hv),traces:bv(e,`traces`),metrics:bv(e,`metrics`),logs:bv(e,`logs`)}),Ov=e=>({rate:xv(e==null?void 0:e.rate)}),kv=e=>{var t,n,r,i,a,o,s,c,l,u,d,f;return{getPageAttributes:(t=(n=e.attributes)==null?void 0:n.page)==null?(()=>({"rum.page.host":typeof window>`u`?``:window.location.host,"rum.page.path":typeof window>`u`?``:window.location.pathname})):t,getMetricAttributes:(r=(i=e.attributes)==null?void 0:i.metric)==null?(()=>({})):r,getErrorAttributes:(a=(o=e.attributes)==null?void 0:o.error)==null?(()=>({})):a,getCustomAttributes:(s=(c=e.attributes)==null?void 0:c.custom)==null?(()=>({})):s,getViewPathGroup:t=>{var n,r,i;return(n=(r=e.route)==null||(i=r.getPathGroup)==null?void 0:i.call(r,t))==null?wv(t):n},redactAttributes:(l=(u=e.privacy)==null?void 0:u.redactAttributes)==null?Sv:l,redactUrl:(d=(f=e.privacy)==null?void 0:f.redactUrl)==null?Cv:d}},Av=e=>{var t,n,r,i,a,o;let s=Tv(e.app);return{app:s,autoStart:(t=e.autoStart)==null?!0:t,debug:(n=e.debug)==null?!1:n,enabled:(r=e.enabled)==null?!0:r,hooks:kv(e),instrumentations:(i=e.instrumentations)==null?{}:i,metricIntervalMillis:gv,plugins:(a=e.plugins)==null?{}:a,resourceAttributes:Ev(s),sampling:Ov(e.sampling),spanBatch:e.spanBatch,spanProcessor:(o=e.spanProcessor)==null?`batch`:o,transport:Dv(e.transport),user:e.user}};F(),H();var jv=(e,t)=>typeof e.enabled==`function`?e.enabled(t):e.enabled!==!1,Mv=class{constructor(e){P(this,`plugins`,void 0),P(this,`startedPlugins`,[]),this.plugins=e}flush(){var e=this;return V(function*(){yield Promise.all(e.startedPlugins.map(e=>Promise.resolve().then(()=>{var t;return(t=e.flush)==null?void 0:t.call(e)})))})()}shutdown(){var e=this;return V(function*(){let t=[...e.startedPlugins].reverse();for(let e of t){var n;yield(n=e.shutdown)==null?void 0:n.call(e)}e.startedPlugins=[]})()}start(e){var t=this;return V(function*(){for(let r of t.plugins)if(jv(r,e.config))try{yield r.init(e),t.startedPlugins.push(r)}catch(t){if(e.config.debug){var n;(n=globalThis.console)==null||n.warn(`[bk-ot] plugin "${r.name}" init failed:`,t)}}})()}},Nv=[`http.url`,`url.full`],Pv=e=>{for(let n of Nv){var t;let r=(t=e.attributes)==null?void 0:t[n];if(typeof r==`string`)return r}},Fv=class{constructor(e,t){this.inner=e,this.config=t}forceFlush(){return this.inner.forceFlush()}onEnd(e){let t=Pv(e);t&&Ap(this.config,t)||this.inner.onEnd(e)}onStart(e,t){this.inner.onStart(e,t)}shutdown(){return this.inner.shutdown()}};F(),G();var Iv=class{constructor(e={},t){P(this,`attributes`,{}),P(this,`setOptionalAttribute`,(e,t)=>{if(t===void 0){delete this.attributes[e];return}this.attributes[e]=t}),P(this,`user`,{}),P(this,`view`,{}),P(this,`getAttributes`,()=>W({},this.attributes)),P(this,`getUser`,()=>W({},this.user)),P(this,`getView`,()=>W({},this.view)),P(this,`setAttributes`,e=>{for(let[t,n]of Object.entries(e)){if(n===void 0){delete this.attributes[t];continue}this.attributes[t]=n}}),P(this,`setUser`,e=>{if(this.user=W(W({},this.user),e),`id`in e){if(e.id===void 0){delete this.attributes[X.userId];return}this.attributes[X.userId]=e.id}}),P(this,`setView`,e=>{this.view=W(W({},this.view),e),this.setOptionalAttribute(X.viewId,e.id),this.setOptionalAttribute(X.viewUrl,e.url),this.setOptionalAttribute(X.viewUrlPathGroup,e.urlPathGroup),this.setOptionalAttribute(X.viewLoadingType,e.loadingType)}),this.setAttributes(e),t&&this.setUser(t)}},Lv=`BK_RUM_SAMPLING`,Rv=new Map,zv=e=>Rv.get(e),Bv=(e,t)=>(Rv.set(e,t),t),Vv=({sampling:e})=>{if(e.rate<=0)return!1;if(e.rate>=1)return!0;try{let t=sessionStorage.getItem(Lv);if(t)return t===`1`;let n=Math.random()<e.rate;return sessionStorage.setItem(Lv,n?`1`:`0`),Bv(Lv,n),n}catch(t){let n=zv(Lv);return typeof n==`boolean`?n:Bv(Lv,Math.random()<e.rate)}};N(),bn(),B(),Qu(),lc(),Cf(),Yf(),F(),G(),H();var Hv=e=>({url:e.endpoint,headers:e.headers,concurrencyLimit:e.concurrencyLimit,timeoutMillis:e.timeoutMillis}),Uv=`bk-rum`,Wv=(e,t,n)=>n?new Proxy(e,{get(e,n,r){if(n===`export`)return(n,r)=>{var i;return(i=globalThis.console)==null||i.log(`[bk-ot][${t}]`,n),e.export(n,r)};let i=Reflect.get(e,n,r);return typeof i==`function`?i.bind(e):i}}):e,Gv=e=>[Mh(e.instrumentations)],Kv=(e,t)=>e===void 0?t:e!==!1,qv=e=>typeof e==`object`&&e?e:void 0,Jv=(e,t,n)=>Kv(e,t)?[n(qv(e))]:[],Yv=e=>[...Jv(e.device,!0,Qh),...Jv(e.session,!0,s_),...Jv(e.pageView,!0,Wg),...Jv(e.httpBody,!1,Dg),...Jv(e.error,!0,cg),...Jv(e.webVitals,!0,sv),...Jv(e.resource,!0,Kg),...Jv(e.blankScreen,!0,wp),...Jv(e.action,!1,sp),...Jv(e.websocket,!1,mv),...Jv(e.longTask,!1,Ag),...Jv(e.cspViolation,!1,zh),...Jv(e.routeTiming,!1,qg)],Xv=class{assertBeforeStart(e){if(this.phase!==`idle`)throw Error(`[bk-ot] ${e}() must be called before start(); set autoStart: false before registration.`)}constructor(e){var t=this,n,r;P(this,`loggerProvider`,void 0),P(this,`meterProvider`,void 0),P(this,`phase`,`idle`),P(this,`pluginManager`,void 0),P(this,`plugins`,void 0),P(this,`registeredInstrumentations`,void 0),P(this,`runtimeContext`,void 0),P(this,`sampled`,void 0),P(this,`teardownCallbacks`,[]),P(this,`tracerProvider`,void 0),P(this,`applyRedact`,e=>this.config.hooks.redactAttributes(e)),P(this,`config`,void 0),P(this,`emitLog`,e=>{var t;let n=W(W({},e),{},{attributes:this.applyRedact(W(W({},this.getRuntimeAttributes()),(t=e.attributes)==null?{}:t))});this.logger.emit(n)}),P(this,`flush`,V(function*(){yield t.pluginManager.flush(),yield t.tracerProvider.forceFlush(),yield t.meterProvider.forceFlush(),yield t.loggerProvider.forceFlush()})),P(this,`getRuntimeAttributes`,()=>this.runtimeContext.getAttributes()),P(this,`logger`,void 0),P(this,`meter`,void 0),P(this,`reportAction`,({attributes:e={},targetTag:t,targetText:n,type:r})=>{var i;if(!this.sampled)return;let a=n==null?void 0:n.slice(0,32);this.startSpan(`action.${r}`,W(W(W(W(W({},this.config.hooks.getPageAttributes()),$({errorType:`none`,eventLabel:`用户操作`,spanSubtype:r,spanType:Q.action,targetLabel:(i=a==null?t:a)==null?r:i})),{},{[X.actionType]:r},a?{[X.targetTextShort]:a}:{}),t?{[X.targetTag]:t}:{}),e)).end()}),P(this,`reportCustomEvent`,({attributes:e={},error:t,name:n})=>{if(!this.sampled){if(this.config.debug){var r;(r=globalThis.console)==null||r.warn(`[bk-ot] custom event dropped (not sampled):`,n)}return}let i=this.startSpan(`custom.${n}`,W(W(W(W(W({},this.config.hooks.getPageAttributes()),this.config.hooks.getCustomAttributes()),$({errorType:t?`custom`:`none`,eventLabel:`自定义事件`,result:t?Z.error:Z.success,spanSubtype:n,spanType:Q.custom,targetLabel:n})),e),{},{"rum.custom.name":n}));t&&(i.recordException(t),i.setStatus({code:wt.ERROR,message:t.message})),i.end()}),P(this,`setRuntimeAttributes`,e=>{this.runtimeContext.setAttributes(e)}),P(this,`setUser`,e=>{this.runtimeContext.setUser(e)}),P(this,`setView`,e=>{this.runtimeContext.setView(e)}),P(this,`shutdown`,V(function*(){if(t.phase!==`stopped`){for(yield t.flush();t.teardownCallbacks.length;){var e;(e=t.teardownCallbacks.pop())==null||e()}for(yield t.pluginManager.shutdown();t.registeredInstrumentations.length;){var n,r;(n=t.registeredInstrumentations.pop())==null||(r=n.disable)==null||r.call(n)}yield t.tracerProvider.shutdown(),yield t.meterProvider.shutdown(),yield t.loggerProvider.shutdown(),M.disable(),Pt.disable(),A.disable(),t.phase=`stopped`}})),P(this,`start`,V(function*(){if(!(t.phase===`started`||t.phase===`starting`)){if(t.phase===`stopped`)throw Error(`[bk-ot] instance has been shut down and cannot be restarted; create a new instance instead.`);if(!t.config.enabled){t.phase=`started`;return}t.phase=`starting`,Jt.setGlobalPropagator(new Ba),t.tracerProvider.register({contextManager:new kn}),Pt.setGlobalMeterProvider(t.meterProvider),yn.setGlobalLoggerProvider(t.loggerProvider);try{if(t.registeredInstrumentations.length&&Pu({instrumentations:t.registeredInstrumentations,meterProvider:t.meterProvider,tracerProvider:t.tracerProvider}),yield t.pluginManager.start(t),typeof window<`u`&&typeof document<`u`){let e=()=>{t.flush()},n=()=>{document.visibilityState===`hidden`&&t.flush()};window.addEventListener(`pagehide`,e),document.addEventListener(`visibilitychange`,n),t.teardownCallbacks.push(()=>window.removeEventListener(`pagehide`,e),()=>document.removeEventListener(`visibilitychange`,n))}}catch(r){for(;t.teardownCallbacks.length;){var e;(e=t.teardownCallbacks.pop())==null||e()}yield t.pluginManager.shutdown();for(let e of t.registeredInstrumentations){var n;(n=e.disable)==null||n.call(e)}throw M.disable(),Pt.disable(),A.disable(),t.phase=`idle`,r}t.phase=`started`}})),P(this,`startSpan`,(e,t={},n)=>this.tracer.startSpan(e,{kind:St.INTERNAL,startTime:n==null?void 0:n.startTime,attributes:this.applyRedact(W(W({},this.getRuntimeAttributes()),t))})),P(this,`tracer`,void 0),P(this,`use`,e=>(this.assertBeforeStart(`use`),this.sampled&&this.plugins.push(e),this)),P(this,`useInstrumentation`,e=>(this.assertBeforeStart(`useInstrumentation`),this.config.enabled&&this.registeredInstrumentations.push(e),this)),this.config=Av(e),this.sampled=this.config.enabled&&Vv(this.config);let i=nc(this.config.resourceAttributes),a=Wv(new Au(Hv(this.config.transport.traces)),`traces`,this.config.debug),o=Wv(new ku(Hv(this.config.transport.metrics)),`metrics`,this.config.debug),s=Wv(new yu(Hv(this.config.transport.logs)),`logs`,this.config.debug),c=new Fv(this.config.spanProcessor===`simple`?new xf(a):new Wd(a,this.config.spanBatch),this.config),l=new Xs({exporter:o,exportIntervalMillis:this.config.metricIntervalMillis}),u=new _d(s);this.tracerProvider=new Of({resource:i,sampler:new Od({root:new Ad(+!!this.sampled)}),spanProcessors:[c]}),this.meterProvider=new cl({resource:i,readers:[l]}),this.loggerProvider=new fd({resource:i,processors:[u]}),this.tracer=this.tracerProvider.getTracer(Uv),this.meter=this.meterProvider.getMeter(Uv),this.logger=this.loggerProvider.getLogger(Uv),this.runtimeContext=new Iv({"rum.sampled":this.sampled},this.config.user),this.registeredInstrumentations=this.config.enabled?[...(n=this.config.instrumentations.custom)==null?[]:n]:[],this.plugins=[...this.config.enabled?Gv(this.config):[],...this.sampled?[...Yv(this.config.plugins),...(r=this.config.plugins.custom)==null?[]:r]:[]],this.pluginManager=new Mv(this.plugins),this.config.autoStart&&this.start().catch(e=>{var t;(t=globalThis.console)==null||t.warn(`[bk-ot] auto start failed:`,e)})}};return typeof window<`u`&&Object.assign(window,{BkOpenTelemetry:Xv}),Xv})();