@blueking/open-telemetry 0.0.16 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bk-rum.global.js +2 -2
- package/dist/bk-rum.global.js.map +1 -1
- package/dist/core/config.d.ts +2 -0
- package/dist/core/metric.d.ts +2 -0
- package/dist/core/sdk.d.ts +4 -0
- package/dist/core/signal.d.ts +3 -0
- package/dist/core/telemetry-attributes.d.ts +1 -0
- package/dist/core/throttle.d.ts +2 -2
- package/dist/index.js +525 -456
- package/dist/index.js.map +1 -1
- package/dist/plugins/blank-screen.d.ts +4 -0
- package/dist/plugins/common.d.ts +1 -0
- package/dist/plugins/csp-violation.d.ts +1 -1
- package/dist/plugins/long-task.d.ts +4 -0
- package/dist/plugins/request-body.d.ts +2 -1
- package/dist/plugins/resource.d.ts +4 -0
- package/dist/plugins/web-vitals.d.ts +2 -0
- package/package.json +1 -1
- package/skills/bk-rum-otele/references/data-model.md +1 -1
- package/skills/bk-rum-otele/references/plugins.md +1 -1
- package/skills/bk-rum-otele/references/telemetry-reference.md +12 -10
package/dist/bk-rum.global.js
CHANGED
|
@@ -8,5 +8,5 @@ var BkOpenTelemetry=(function(){var e=Object.defineProperty,t=(e,t)=>()=>(e&&(t=
|
|
|
8
8
|
To resolve the conflict:`,zo(t,e))),n=r):P.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
|
`,Po(t,e),`To resolve the conflict:
|
|
11
|
-
`,zo(t,e))}return n}};L();var Vo=class{constructor(e){I(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)}};L();var Ho=class{constructor(e,t){I(this,`_buffer`,new ko),I(this,`_instrumentName`,void 0),I(this,`_valueType`,void 0),this._instrumentName=e,this._valueType=t}observe(e,t={}){if(typeof e!=`number`){P.warn(`non-number value provided to metric ${this._instrumentName}: ${e}`);return}this._valueType===pe.INT&&!Number.isInteger(e)&&(P.warn(`INT value type cannot accept a floating-point value for ${this._instrumentName}, ignoring the fractional digits.`),e=Math.trunc(e),!Number.isInteger(e))||this._buffer.set(t,e)}},Uo=class{constructor(){I(this,`_buffer`,new Map)}observe(e,t,n={}){if(!To(e))return;let r=this._buffer.get(e);if(r==null&&(r=new ko,this._buffer.set(e,r)),typeof t!=`number`){P.warn(`non-number value provided to metric ${e._descriptor.name}: ${t}`);return}e._descriptor.valueType===pe.INT&&!Number.isInteger(t)&&(P.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)}};L();var Wo=class{constructor(){I(this,`_callbacks`,[]),I(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(To));if(n.size===0){P.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(To)),r=this._findBatchCallback(e,n);r<0||this._batchCallbacks.splice(r,1)}observe(e,t){var n=this;return W(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=W(function*({callback:n,instrument:r}){let i=new Ho(r._descriptor.name,r._descriptor.valueType),a=Promise.resolve(n(i));t!=null&&(a=Zi(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=W(function*({callback:n,instruments:r}){let i=new Uo,a=Promise.resolve(n(i));t!=null&&(a=Zi(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&&Qi(n.instruments,t))}};L();var Go=class extends Do{constructor(e,t,n,r,i){super(e),I(this,`_aggregationCardinalityLimit`,void 0),I(this,`_deltaMetricStorage`,void 0),I(this,`_temporalMetricStorage`,void 0),I(this,`_attributesProcessor`,void 0),this._aggregationCardinalityLimit=i,this._deltaMetricStorage=new Ao(t,this._aggregationCardinalityLimit),this._temporalMetricStorage=new jo(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)}};L();var Ko=class{process(e,t){return e}},qo=class{constructor(e){I(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 Jo(){return Xo}function Yo(e){return new qo(e)}var Xo=new Ko;L();var Zo=class{constructor(e,t){I(this,`metricStorageRegistry`,new Bo),I(this,`observableRegistry`,new Wo),I(this,`meter`,void 0),I(this,`_meterProviderSharedState`,void 0),I(this,`_instrumentationScope`,void 0),this.meter=new Eo(this),this._meterProviderSharedState=e,this._instrumentationScope=t}registerMetricStorage(e){let t=this._registerMetricStorage(e,Go);return t.length===1?t[0]:new Vo(t)}registerAsyncMetricStorage(e){return this._registerMetricStorage(e,No)}collect(e,t,n){var r=this;return W(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=fo(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,Jo(),[n],o);return this.metricStorageRegistry.registerForCollector(n,s),s});n=n.concat(r)}return n}};L();var Qo=class{constructor(e){I(this,`viewRegistry`,new lo),I(this,`metricCollectors`,[]),I(this,`meterSharedStates`,new Map),I(this,`resource`,void 0),this.resource=e}getMeterSharedState(e){let t=Yi(e),n=this.meterSharedStates.get(t);return n==null&&(n=new Zo(this,e),this.meterSharedStates.set(t,n)),n}selectAggregations(e){let t=[];for(let n of this.metricCollectors)t.push([n,Ja(n.selectAggregation(e))]);return t}};L();var $o=class{constructor(e,t){I(this,`_sharedState`,void 0),I(this,`_metricReader`,void 0),this._sharedState=e,this._metricReader=t}collect(e){var t=this;return W(function*(){let n=hr(Date.now()),r=[],i=[],a=Array.from(t._sharedState.meterSharedStates.values()).map(function(){var a=W(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 W(function*(){yield t._metricReader.forceFlush(e)})()}shutdown(e){var t=this;return W(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}};L();var es=/[\^$\\.+?()[\]{}|]/g,ts=class e{constructor(t){I(this,`_matchAll`,void 0),I(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(es,`\\$&`).replace(`*`,`.*`)}$`}static hasWildcard(e){return e.includes(`*`)}},ns=class{constructor(e){I(this,`_matchAll`,void 0),I(this,`_pattern`,void 0),this._matchAll=e===void 0,this._pattern=e}match(e){return!!(this._matchAll||e===this._pattern)}};L();var rs=class{constructor(e){var t;I(this,`_nameFilter`,void 0),I(this,`_type`,void 0),I(this,`_unitFilter`,void 0),this._nameFilter=new ts((t=e==null?void 0:e.name)==null?`*`:t),this._type=e==null?void 0:e.type,this._unitFilter=new ns(e==null?void 0:e.unit)}getType(){return this._type}getNameFilter(){return this._nameFilter}getUnitFilter(){return this._unitFilter}};L();var is=class{constructor(e){I(this,`_nameFilter`,void 0),I(this,`_versionFilter`,void 0),I(this,`_schemaUrlFilter`,void 0),this._nameFilter=new ns(e==null?void 0:e.name),this._versionFilter=new ns(e==null?void 0:e.version),this._schemaUrlFilter=new ns(e==null?void 0:e.schemaUrl)}getNameFilter(){return this._nameFilter}getVersionFilter(){return this._versionFilter}getSchemaUrlFilter(){return this._schemaUrlFilter}};L();function as(e){return e.instrumentName==null&&e.instrumentType==null&&e.instrumentUnit==null&&e.meterName==null&&e.meterVersion==null&&e.meterSchemaUrl==null}function os(e){if(as(e))throw Error(`Cannot create view with no selector arguments supplied`);if(e.name!=null&&((e==null?void 0:e.instrumentName)==null||ts.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 ss=class{constructor(e){var t;I(this,`name`,void 0),I(this,`description`,void 0),I(this,`aggregation`,void 0),I(this,`attributesProcessor`,void 0),I(this,`instrumentSelector`,void 0),I(this,`meterSelector`,void 0),I(this,`aggregationCardinalityLimit`,void 0),os(e),e.attributesProcessors==null?this.attributesProcessor=Jo():this.attributesProcessor=Yo(e.attributesProcessors),this.name=e.name,this.description=e.description,this.aggregation=Ja((t=e.aggregation)==null?{type:qa.DEFAULT}:t),this.instrumentSelector=new rs({name:e.instrumentName,type:e.instrumentType,unit:e.instrumentUnit}),this.meterSelector=new is({name:e.meterName,version:e.meterVersion,schemaUrl:e.meterSchemaUrl}),this.aggregationCardinalityLimit=e.aggregationCardinalityLimit}};L();var cs=class{constructor(e){var t;if(I(this,`_sharedState`,void 0),I(this,`_shutdown`,!1),this._sharedState=new Qo((t=e==null?void 0:e.resource)==null?ao():t),(e==null?void 0:e.views)!=null&&e.views.length>0)for(let t of e.views)this._sharedState.viewRegistry.addView(new ss(t));if((e==null?void 0:e.readers)!=null&&e.readers.length>0)for(let t of e.readers){let e=new $o(this._sharedState,t);t.setMetricProducer(e),this._sharedState.metricCollectors.push(e)}}getMeter(e,t=``,n={}){return this._shutdown?(P.warn(`A shutdown MeterProvider cannot provide a Meter`),fe()):this._sharedState.getMeterSharedState({name:e,version:t,schemaUrl:n.schemaUrl}).meter}shutdown(e){var t=this;return W(function*(){if(t._shutdown){P.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 W(function*(){if(t._shutdown){P.warn(`invalid attempt to force flush after MeterProvider shutdown`);return}yield Promise.all(t._sharedState.metricCollectors.map(t=>t.forceFlush(e)))})()}},ls;(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`})(ls||(ls={}));function us(e,t){let n={attributes:fs(e.attributes,t),droppedAttributesCount:0},r=e.schemaUrl;return r&&r!==``&&(n.schemaUrl=r),n}function ds(e){return{name:e.name,version:e.version}}function fs(e,t){return Object.keys(e).map(n=>ps(n,e[n],t))}function ps(e,t,n){return{key:e,value:ms(t,n)}}function ms(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]=ms(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:ms(e[n[i]],t)};return{kvlistValue:{values:r}}}return{}}function hs(e,t){let n=us(e.resource,t);return{resource:n,schemaUrl:n.schemaUrl,scopeMetrics:gs(e.scopeMetrics,t)}}function gs(e,t){return Array.from(e.map(e=>({scope:ds(e.scope),metrics:e.metrics.map(e=>_s(e,t)),schemaUrl:e.scope.schemaUrl})))}function _s(e,t){let n={name:e.descriptor.name,description:e.descriptor.description,unit:e.descriptor.unit},r=Ss(e.aggregationTemporality);switch(e.dataPointType){case qi.SUM:n.sum={aggregationTemporality:r,isMonotonic:e.isMonotonic,dataPoints:ys(e,t)};break;case qi.GAUGE:n.gauge={dataPoints:ys(e,t)};break;case qi.HISTOGRAM:n.histogram={aggregationTemporality:r,dataPoints:bs(e,t)};break;case qi.EXPONENTIAL_HISTOGRAM:n.exponentialHistogram={aggregationTemporality:r,dataPoints:xs(e,t)};break}return n}function vs(e,t,n){let r={attributes:fs(e.attributes,n),startTimeUnixNano:n.encodeHrTime(e.startTime),timeUnixNano:n.encodeHrTime(e.endTime)};switch(t){case pe.INT:r.asInt=e.value;break;case pe.DOUBLE:r.asDouble=e.value;break}return r}function ys(e,t){return e.dataPoints.map(n=>vs(n,e.descriptor.valueType,t))}function bs(e,t){return e.dataPoints.map(e=>{let n=e.value;return{attributes:fs(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 xs(e,t){return e.dataPoints.map(e=>{let n=e.value;return{attributes:fs(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 Ss(e){switch(e){case Ki.DELTA:return ls.AGGREGATION_TEMPORALITY_DELTA;case Ki.CUMULATIVE:return ls.AGGREGATION_TEMPORALITY_CUMULATIVE}}function Cs(e,t){return{resourceMetrics:e.map(e=>hs(e,t))}}function ws(e){let t=BigInt(1e9);return BigInt(Math.trunc(e[0]))*t+BigInt(Math.trunc(e[1]))}function Ts(e){return ws(e).toString()}var Es=typeof BigInt<`u`?Ts:yr;function Ds(e){return e}var Os={encodeHrTime:Es,encodeSpanContext:Ds,encodeOptionalSpanContext:Ds,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 ks(e,t){return{resourceLogs:js(e,t)}}function As(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 js(e,t){let n=As(e);return Array.from(n,([e,n])=>{let r=us(e,t);return{resource:r,scopeLogs:Array.from(n,([,e])=>({scope:ds(e[0].instrumentationScope),logRecords:e.map(e=>Ms(e,t)),schemaUrl:e[0].instrumentationScope.schemaUrl})),schemaUrl:r.schemaUrl}})}function Ms(e,t){var n,r,i;return{timeUnixNano:t.encodeHrTime(e.hrTime),observedTimeUnixNano:t.encodeHrTime(e.hrTimeObserved),severityNumber:Ns(e.severityNumber),severityText:e.severityText,body:ms(e.body,t),eventName:e.eventName,attributes:Ps(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 Ns(e){return e}function Ps(e,t){return Object.keys(e).map(n=>ps(n,e[n],t))}var Fs={serializeRequest:e=>{let t=ks(e,Os);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 P.warn(`Failed to parse logs export response: ${e.message}. Returning empty response`),{}}}},Is={serializeRequest:e=>{let t=Cs([e],Os);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 P.warn(`Failed to parse metrics export response: ${e.message}. Returning empty response`),{}}}},Ls=256,Rs=512;function zs(e,t){let n=e&255|Ls;return t&&(n|=Rs),n}function Bs(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:fs(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(e=>Hs(e,t)),droppedEventsCount:e.droppedEventsCount,status:{code:s.code,message:s.message},links:e.links.map(e=>Vs(e,t)),droppedLinksCount:e.droppedLinksCount,flags:zs(o.traceFlags,(a=e.parentSpanContext)==null?void 0:a.isRemote)}}function Vs(e,t){var n;return{attributes:e.attributes?fs(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:zs(e.context.traceFlags,e.context.isRemote)}}function Hs(e,t){return{attributes:e.attributes?fs(e.attributes,t):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function Us(e,t){return{resourceSpans:Gs(e,t)}}function Ws(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 Gs(e,t){let n=Ws(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=>Bs(e,t));o.push({scope:ds(e[0].instrumentationScope),spans:n,schemaUrl:e[0].instrumentationScope.schemaUrl})}c=s.next()}let l=us(e,t),u={resource:l,scopeSpans:o,schemaUrl:l.schemaUrl};r.push(u),a=i.next()}return r}var Ks={serializeRequest:e=>{let t=Us(e,Os);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 P.warn(`Failed to parse trace export response: ${e.message}. Returning empty response`),{}}}};L();var qs=5,Js=1e3,Ys=5e3,Xs=1.5,Zs=.2;function Qs(){return 2*Zs*Math.random()-Zs}var $s=class{constructor(e){I(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 W(function*(){let r=qs,i=Js,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+Qs()),Ys),0);i*=Xs;let c=(s=o.retryInMillis)==null?t:s,l=a-Date.now();if(c>l)return P.info(`Export retry time ${Math.round(c)}ms exceeds remaining timeout ${Math.round(l)}ms, not retrying further.`),o;P.verbose(`Scheduling export retry in ${Math.round(c)}ms`),o=yield n.retry(e,l,c)}return o.status===`success`?P.verbose(`Export succeeded after ${qs-r} retry attempts.`):o.status===`retryable`?P.info(`Export failed after maximum retry attempts (${qs}).`):P.info(`Export failed with non-retryable error: ${o.error}`),o})()}shutdown(){return this._transport.shutdown()}};function ec(e){return new $s(e.transport)}function tc(e){return e===429||e===502||e===503||e===504}function nc(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}L();var rc=60*1024,ic=9,ac=0,oc=0,sc=class{constructor(e){I(this,`_parameters`,void 0),this._parameters=e}send(e,t){var n=this;return W(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=ac+o>rc,c=!s&&!(oc>=ic);if(c)ac+=o,oc++;else{let e=s?`size limit`:`count limit`;P.debug(`keepalive disabled: ${(o/1024).toFixed(1)}KB payload, ${oc} 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?(P.debug(`export response success (status: ${i.status})`),{status:`success`}):tc(i.status)?(P.warn(`export response retryable (status: ${i.status})`),{status:`retryable`,retryInMillis:nc(i.headers.get(`Retry-After`))}):(P.error(`export response failure (status: ${i.status})`),{status:`failure`,error:Error(`Fetch request failed with non-retryable status ${i.status}`)})}catch(e){return lc(e)?(P.warn(`export request retryable (network error: ${e})`),{status:`retryable`,error:Error(`Fetch request encountered a network error`,{cause:e})}):(P.error(`export request failure (error: ${e})`),{status:`failure`,error:Error(`Fetch request errored`,{cause:e})})}finally{clearTimeout(i),c&&(ac-=o,oc--)}})()}shutdown(){}};function cc(e){return new sc(e)}function lc(e){return e instanceof TypeError&&!e.cause}function uc(e,t){return Fi(e,t,ec({transport:cc(e)}))}function dc(e){let t={};return Object.entries(e==null?{}:e).forEach(([e,n])=>{n===void 0?P.warn(`Header "${e}" has invalid value (${n}) and will be ignored`):t[e]=String(n)}),t}q();function fc(e,t,n){return W(function*(){let r=K({},yield n()),i={};return t!=null&&Object.assign(i,yield t()),e!=null&&Object.assign(i,dc(yield e())),Object.assign(i,r)})}function pc(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 mc(e,t,n){var r,i;return K(K({},Di(e,t,n)),{},{headers:fc(e.headers,t.headers,n.headers),url:(r=(i=pc(e.url))==null?t.url:i)==null?n.url:r})}function hc(e,t){return K(K({},Oi()),{},{headers:function(){var t=W(function*(){return e});return function(){return t.apply(this,arguments)}}(),url:`http://localhost:4318/`+t})}function gc(e){return typeof e.headers==`function`?e.headers:Ei(e.headers)}function _c(e,t,n){return mc({url:e.url,timeoutMillis:e.timeoutMillis,headers:gc(e),concurrencyLimit:e.concurrencyLimit},{},hc(n,t))}function vc(e,t,n,r){return uc(_c(e,n,r),t)}var yc=class extends Si{constructor(e={}){super(vc(e,Fs,`v1/logs`,{"Content-Type":`application/json`}))}},bc;(function(e){e[e.DELTA=0]=`DELTA`,e[e.CUMULATIVE=1]=`CUMULATIVE`,e[e.LOWMEMORY=2]=`LOWMEMORY`})(bc||(bc={})),L();var xc=()=>Ki.CUMULATIVE,Sc=e=>{switch(e){case G.COUNTER:case G.OBSERVABLE_COUNTER:case G.GAUGE:case G.HISTOGRAM:case G.OBSERVABLE_GAUGE:return Ki.DELTA;case G.UP_DOWN_COUNTER:case G.OBSERVABLE_UP_DOWN_COUNTER:return Ki.CUMULATIVE}},Cc=e=>{switch(e){case G.COUNTER:case G.HISTOGRAM:return Ki.DELTA;case G.GAUGE:case G.UP_DOWN_COUNTER:case G.OBSERVABLE_UP_DOWN_COUNTER:case G.OBSERVABLE_COUNTER:case G.OBSERVABLE_GAUGE:return Ki.CUMULATIVE}};function wc(){var e;let t=((e=void 0)==null?`cumulative`:e).toLowerCase();return t===`cumulative`?xc:t===`delta`?Sc:t===`lowmemory`?Cc:(P.warn(`OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE is set to '${t}', but only 'cumulative' and 'delta' are allowed. Using default ('cumulative') instead.`),xc)}function Tc(e){return e==null?wc():e===bc.DELTA?Sc:e===bc.LOWMEMORY?Cc:xc}var Ec=Object.freeze({type:qa.DEFAULT});function Dc(e){var t;return(t=e==null?void 0:e.aggregationPreference)==null?(()=>Ec):t}var Oc=class extends Si{constructor(e,t){super(e),I(this,`_aggregationTemporalitySelector`,void 0),I(this,`_aggregationSelector`,void 0),this._aggregationSelector=Dc(t),this._aggregationTemporalitySelector=Tc(t==null?void 0:t.temporalityPreference)}selectAggregation(e){return this._aggregationSelector(e)}selectAggregationTemporality(e){return this._aggregationTemporalitySelector(e)}},kc=class extends Oc{constructor(e){super(vc(e==null?{}:e,Is,`v1/metrics`,{"Content-Type":`application/json`}),e)}},Ac=class extends Si{constructor(e={}){super(vc(e,Ks,`v1/traces`,{"Content-Type":`application/json`}))}};function jc(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 Mc(e){e.forEach(e=>e.disable())}function Nc(e){var t,n;let r=e.tracerProvider||F.getTracerProvider(),i=e.meterProvider||qe.getMeterProvider(),a=e.loggerProvider||Gi.getLoggerProvider(),o=(t=(n=e.instrumentations)==null?void 0:n.flat())==null?[]:t;return jc(o,r,i,a),()=>{Mc(o)}}function Pc(e){return Fc(e,new WeakSet)}function Fc(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=>Fc(e,t));let n=e;return n.constructor!==Object&&n.constructor!==void 0?!1:Object.values(n).every(e=>Fc(e,t))}return!1}L();var Ic=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){I(this,`hrTime`,void 0),I(this,`hrTimeObserved`,void 0),I(this,`spanContext`,void 0),I(this,`resource`,void 0),I(this,`instrumentationScope`,void 0),I(this,`attributes`,{}),I(this,`_severityText`,void 0),I(this,`_severityNumber`,void 0),I(this,`_body`,void 0),I(this,`_eventName`,void 0),I(this,`_attributesCount`,0),I(this,`_droppedAttributesCount`,0),I(this,`_isReadonly`,!1),I(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=_r(r==null?f:r),this.hrTimeObserved=_r(i==null?f:i),d){let e=F.getSpanContext(d);e&&Ne(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 P.warn(`Invalid attribute key: ${e}`),this;if(!Pc(t))return P.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&&P.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 P.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(tr,String(e)),t=!0;else if(e&&typeof e==`object`){let n=e;n.code?(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(rr,n.code.toString()),t=!0):n.name&&(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(rr,n.name),t=!0),n.message&&(Object.hasOwn(this.attributes,`exception.message`)||this.setAttribute(tr,n.message),t=!0),n.stack&&(Object.hasOwn(this.attributes,`exception.stacktrace`)||this.setAttribute(nr,n.stack),t=!0)}t||P.warn(`Failed to record an exception ${e}`)}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_isLogRecordReadonly(){return this._isReadonly&&P.warn(`Can not execute the operation on emitted log record`),this._isReadonly}};L(),q();var Lc=class{constructor(e,t){I(this,`instrumentationScope`,void 0),I(this,`_sharedState`,void 0),I(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||N.active(),i=(t=e.severityNumber)==null?Ii.UNSPECIFIED:t;if(i!==Ii.UNSPECIFIED&&i<n.minimumSeverity)return;if(n.traceBased){let e=F.getSpanContext(r);if(e&&Ne(e)&&(e.traceFlags&M.SAMPLED)!==M.SAMPLED)return}let a=new Ic(this._sharedState,this.instrumentationScope,K({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!==Ii.UNSPECIFIED&&n<t.minimumSeverity)return!1;let r=(e==null?void 0:e.context)||N.active();if(t.traceBased){let e=F.getSpanContext(r);if(e&&Ne(e)&&(e.traceFlags&M.SAMPLED)!==M.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}},Rc=class{forceFlush(){return Promise.resolve()}onEmit(e,t){}shutdown(){return Promise.resolve()}enabled(e){return!1}};L();var zc=class{constructor(e,t){I(this,`processors`,void 0),I(this,`forceFlushTimeoutMillis`,void 0),this.processors=e,this.forceFlushTimeoutMillis=t}forceFlush(){var e=this;return W(function*(){let t=e.forceFlushTimeoutMillis;yield Promise.all(e.processors.map(e=>_i(e.forceFlush(),t)))})()}onEmit(e,t){this.processors.forEach(n=>n.onEmit(e,t))}shutdown(){var e=this;return W(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 Bc(e){return`${e.name}@${e.version||``}:${e.schemaUrl||``}`}var Vc=`otel.sdk.log.created`;L();var Hc=class{constructor(e){I(this,`createdLogs`,void 0),this.createdLogs=e.createCounter(Vc,{unit:`{log_record}`,description:`The number of logs submitted to enabled SDK Loggers.`})}emitLog(){this.createdLogs.add(1)}},Uc=`0.217.0`;q(),L();var Wc={disabled:!1,minimumSeverity:Ii.UNSPECIFIED,traceBased:!1},Gc=()=>K({},Wc),Kc=class{constructor(e,t,n,r,i,a){I(this,`loggers`,new Map),I(this,`activeProcessor`,void 0),I(this,`registeredLogRecordProcessors`,[]),I(this,`resource`,void 0),I(this,`forceFlushTimeoutMillis`,void 0),I(this,`logRecordLimits`,void 0),I(this,`processors`,void 0),I(this,`loggerMetrics`,void 0),I(this,`_loggerConfigurator`,void 0),I(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 zc(this.registeredLogRecordProcessors,this.forceFlushTimeoutMillis)):this.activeProcessor=new Rc,this._loggerConfigurator=i==null?Gc:i;let o=a?a.getMeter(`@opentelemetry/sdk-logs`,Uc):fe();this.loggerMetrics=new Hc(o)}getLoggerConfig(e){let t=Bc(e),n=this._loggerConfigs.get(t);return n||(n=this._loggerConfigurator(e),this._loggerConfigs.set(t,n),n)}};L();var qc=class{constructor(e={}){var t,n,r,i,a,o,s,c;I(this,`_shutdownOnce`,void 0),I(this,`_sharedState`,void 0);let l={resource:(t=e.resource)==null?ao():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?Gc:s,processors:(c=e.processors)==null?[]:c,meterProvider:e.meterProvider};this._sharedState=new Kc(l.resource,l.forceFlushTimeoutMillis,l.logRecordLimits,l.processors,l.loggerConfigurator,l.meterProvider),this._shutdownOnce=new yi(this._shutdown,this)}getLogger(e,t,n){if(this._shutdownOnce.isCalled)return P.warn(`A shutdown LoggerProvider cannot provide a Logger`),Ri;e||P.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 Lc({name:r,version:t,schemaUrl:n==null?void 0:n.schemaUrl},this._sharedState)),this._sharedState.loggers.get(i)}forceFlush(){return this._shutdownOnce.isCalled?(P.warn(`invalid attempt to force flush after LoggerProvider shutdown`),this._shutdownOnce.promise):this._sharedState.activeProcessor.forceFlush()}shutdown(){return this._shutdownOnce.isCalled?(P.warn(`shutdown may only be called once per LoggerProvider`),this._shutdownOnce.promise):this._shutdownOnce.call()}_shutdown(){return this._sharedState.activeProcessor.shutdown()}};L();function Jc(e){return Yc.apply(this,arguments)}function Yc(){return Yc=W(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))}),Yc.apply(this,arguments)}var Xc=class{constructor(e,t,n){I(this,`_exportCompleted`,void 0),I(this,`_exportScheduledPromise`,void 0),I(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 W(function*(){try{yield Jc(t),yield N.with(In(N.active()),W(function*(){return r._exportWithTimeout(e,t,n)}))}catch(e){$n(e),r._exportScheduledResolve()}})()}_exportWithTimeout(e,t,n){var r=this;return W(function*(){return new Promise((i,a)=>{let o=setTimeout(()=>{a(Error(`Timeout`))},n);e.export(t,e=>{if(clearTimeout(o),e.code===U.SUCCESS)i();else{var t;a((t=e.error)==null?Error(`BatchLogRecordProcessor: log record export failed`):t)}}),r._exportScheduledResolve()})})()}},Zc=class{constructor(e,t){var n,r,i,a;I(this,`_maxExportBatchSize`,void 0),I(this,`_maxQueueSize`,void 0),I(this,`_scheduledDelayMillis`,void 0),I(this,`_exportTimeoutMillis`,void 0),I(this,`_exporter`,void 0),I(this,`_currentExport`,null),I(this,`_finishedLogRecords`,[]),I(this,`_timer`,void 0),I(this,`_shutdownOnce`,void 0),I(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 yi(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(P.warn(`BatchLogRecordProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize)}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 W(function*(){e.onShutdown(),yield e._flushAll(),yield e._exporter.shutdown()})()}_flushAll(){var e=this;return W(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 Xc(e._exporter,n,e._exportTimeoutMillis);e._currentExport=r;try{yield r.exportScheduled,yield e._exporter.forceFlush(),yield r.exportCompleted}catch(e){$n(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 Xc(this._exporter,e,this._exportTimeoutMillis);this._currentExport=t,t.exportCompleted.then(()=>{this._currentExport=null,this._maybeStartTimer()}).catch(e=>{this._currentExport=null,$n(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)}};L();var Qc=class extends Zc{constructor(e,t){super(e,t),I(this,`_visibilityChangeListener`,void 0),I(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))}},$c=`exception`;L();var el=class{constructor(e){var t,n;I(this,`_spanContext`,void 0),I(this,`kind`,void 0),I(this,`parentSpanContext`,void 0),I(this,`attributes`,{}),I(this,`links`,[]),I(this,`events`,[]),I(this,`startTime`,void 0),I(this,`resource`,void 0),I(this,`instrumentationScope`,void 0),I(this,`_droppedAttributesCount`,0),I(this,`_droppedEventsCount`,0),I(this,`_droppedLinksCount`,0),I(this,`_attributesCount`,0),I(this,`name`,void 0),I(this,`status`,{code:We.UNSET}),I(this,`endTime`,[0,0]),I(this,`_ended`,!1),I(this,`_duration`,[-1,-1]),I(this,`_spanProcessor`,void 0),I(this,`_spanLimits`,void 0),I(this,`_attributeValueLengthLimit`,void 0),I(this,`_recordEndMetrics`,void 0),I(this,`_performanceStartTime`,void 0),I(this,`_performanceOffset`,void 0),I(this,`_startTimeProvided`,void 0);let r=Date.now();if(this._spanContext=e.spanContext,this._performanceStartTime=dr.now(),this._performanceOffset=r-(this._performanceStartTime+dr.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 P.warn(`Invalid attribute key: ${e}`),this;if(!Kn(t))return P.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 P.warn(`No events allowed.`),this._droppedEventsCount++,this;r!==void 0&&this.events.length>=r&&(this._droppedEventsCount===0&&P.debug(`Dropping extra events.`),this.events.shift(),this._droppedEventsCount++),Cr(t)&&(Cr(n)||(n=t),t=void 0);let i=Wn(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&&P.debug(`Dropping extra links.`),this.links.shift(),this._droppedLinksCount++);let{attributePerLinkCountLimit:n}=this._spanLimits,r=Wn(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===We.UNSET||this.status.code===We.OK)return this;let t={code:e.code};return e.code===We.ERROR&&(typeof e.message==`string`?t.message=e.message:e.message!=null&&P.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()){P.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=vr(this.startTime,this.endTime),this._duration[0]<0&&(P.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&&P.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._droppedLinksCount>0&&P.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<=dr.now())return gr(e+this._performanceOffset);if(typeof e==`number`)return hr(e);if(e instanceof Date)return hr(e.getTime());if(Sr(e))return e;if(this._startTimeProvided)return hr(Date.now());let t=dr.now()-this._performanceStartTime;return wr(this.startTime,hr(t))}isRecording(){return this._ended===!1}recordException(e,t){let n={};typeof e==`string`?n[tr]=e:e&&(e.code?n[rr]=e.code.toString():e.name&&(n[rr]=e.name),e.message&&(n[tr]=e.message),e.stack&&(n[nr]=e.stack)),n[`exception.type`]||n[`exception.message`]?this.addEvent($c,n,t):P.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}}`);P.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?(P.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}},J;(function(e){e[e.NOT_RECORD=0]=`NOT_RECORD`,e[e.RECORD=1]=`RECORD`,e[e.RECORD_AND_SAMPLED=2]=`RECORD_AND_SAMPLED`})(J||(J={}));var tl=class{shouldSample(){return{decision:J.NOT_RECORD}}toString(){return`AlwaysOffSampler`}},nl=class{shouldSample(){return{decision:J.RECORD_AND_SAMPLED}}toString(){return`AlwaysOnSampler`}};L();var rl=class{constructor(e){var t,n,r,i;I(this,`_root`,void 0),I(this,`_remoteParentSampled`,void 0),I(this,`_remoteParentNotSampled`,void 0),I(this,`_localParentSampled`,void 0),I(this,`_localParentNotSampled`,void 0),this._root=e.root,this._root||($n(Error(`ParentBasedSampler must have a root sampler configured`)),this._root=new nl),this._remoteParentSampled=(t=e.remoteParentSampled)==null?new nl:t,this._remoteParentNotSampled=(n=e.remoteParentNotSampled)==null?new tl:n,this._localParentSampled=(r=e.localParentSampled)==null?new nl:r,this._localParentNotSampled=(i=e.localParentNotSampled)==null?new tl:i}shouldSample(e,t,n,r,i,a){let o=F.getSpanContext(e);return!o||!Ne(o)?this._root.shouldSample(e,t,n,r,i,a):o.isRemote?o.traceFlags&M.SAMPLED?this._remoteParentSampled.shouldSample(e,t,n,r,i,a):this._remoteParentNotSampled.shouldSample(e,t,n,r,i,a):o.traceFlags&M.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()}}`}};L();var il=class{constructor(e=0){I(this,`_ratio`,void 0),I(this,`_upperBound`,void 0),this._ratio=this._normalize(e),this._upperBound=Math.floor(this._ratio*4294967295)}shouldSample(e,t){return{decision:je(t)&&this._accumulate(t)<this._upperBound?J.RECORD_AND_SAMPLED:J.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}},al;(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`})(al||(al={}));var ol=1;function sl(){var e,t,n,r,i,a,o,s;return{sampler:cl(),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 cl(){var e;let t=(e=void 0)==null?al.ParentBasedAlwaysOn:e;switch(t){case al.AlwaysOn:return new nl;case al.AlwaysOff:return new tl;case al.ParentBasedAlwaysOn:return new rl({root:new nl});case al.ParentBasedAlwaysOff:return new rl({root:new tl});case al.TraceIdRatio:return new il(ll());case al.ParentBasedTraceIdRatio:return new rl({root:new il(ll())});default:return P.error(`OTEL_TRACES_SAMPLER value "${t}" invalid, defaulting to "${al.ParentBasedAlwaysOn}".`),new rl({root:new nl})}}function ll(){return P.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${ol}.`),ol}var ul=1/0;function dl(e){let t={sampler:cl()},n=sl(),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 fl(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?ul:s,Object.assign({},e,{spanLimits:p})}L();var pl=class{constructor(e,t){var n,r,i,a;I(this,`_maxExportBatchSize`,void 0),I(this,`_maxQueueSize`,void 0),I(this,`_scheduledDelayMillis`,void 0),I(this,`_exportTimeoutMillis`,void 0),I(this,`_exporter`,void 0),I(this,`_isExporting`,!1),I(this,`_finishedSpans`,[]),I(this,`_timer`,void 0),I(this,`_shutdownOnce`,void 0),I(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 yi(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(P.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&M.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&&P.debug(`maxQueueSize reached, dropping spans`),this._droppedSpansCount++;return}this._droppedSpansCount>0&&(P.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);N.with(In(N.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===U.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=>{$n(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,$n(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)}};L();var ml=class extends pl{constructor(e,t){super(e,t),I(this,`_visibilityChangeListener`,void 0),I(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=>{$n(e)})},this._pageHideListener=()=>{this.forceFlush().catch(e=>{$n(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))}},hl=16,gl=8,_l=new Uint8Array(hl),vl=new Uint8Array(gl),yl=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function bl(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 xl(e){let t=``;for(let n=0;n<e.length;n++)t+=yl[e[n]];return t}var Sl=class{generateTraceId(){return bl(_l),xl(_l)}generateSpanId(){return bl(vl),xl(vl)}},Cl=`otel.span.parent.origin`,wl=`otel.span.sampling_result`,Tl=`otel.sdk.span.live`,El=`otel.sdk.span.started`;L();var Dl=class{constructor(e){I(this,`startedSpans`,void 0),I(this,`liveSpans`,void 0),this.startedSpans=e.createCounter(El,{unit:`{span}`,description:`The number of created spans.`}),this.liveSpans=e.createUpDownCounter(Tl,{unit:`{span}`,description:`The number of currently live spans.`})}startSpan(e,t){let n=kl(t);if(this.startedSpans.add(1,{[Cl]:Ol(e),[wl]:n}),t===J.NOT_RECORD)return()=>{};let r={[wl]:n};return this.liveSpans.add(1,r),()=>{this.liveSpans.add(-1,r)}}};function Ol(e){return e?e.isRemote?`remote`:`local`:`none`}function kl(e){switch(e){case J.RECORD_AND_SAMPLED:return`RECORD_AND_SAMPLE`;case J.RECORD:return`RECORD_ONLY`;case J.NOT_RECORD:return`DROP`}}var Al=`2.7.1`;L();var jl=class{constructor(e,t,n,r){I(this,`_sampler`,void 0),I(this,`_generalLimits`,void 0),I(this,`_spanLimits`,void 0),I(this,`_idGenerator`,void 0),I(this,`instrumentationScope`,void 0),I(this,`_resource`,void 0),I(this,`_spanProcessor`,void 0),I(this,`_tracerMetrics`,void 0);let i=dl(t);this._sampler=i.sampler,this._generalLimits=i.generalLimits,this._spanLimits=i.spanLimits,this._idGenerator=t.idGenerator||new Sl,this._resource=n,this._spanProcessor=r,this.instrumentationScope=e;let a=i.meterProvider?i.meterProvider.getMeter(`@opentelemetry/sdk-trace`,Al):fe();this._tracerMetrics=new Dl(a)}startSpan(e,t={},n=N.active()){var r,i,a;t.root&&(n=F.deleteSpan(n));let o=F.getSpan(n);if(Ln(n))return P.debug(`Instrumentation suppressed, returning Noop Span`),F.wrapSpanContext(be);let s=o==null?void 0:o.spanContext(),c=this._idGenerator.generateSpanId(),l,u,d;!s||!F.isSpanContextValid(s)?u=this._idGenerator.generateTraceId():(u=s.traceId,d=s.traceState,l=s);let f=(r=t.kind)==null?Ue.INTERNAL:r,p=((i=t.links)==null?[]:i).map(e=>({context:e.context,attributes:Wn(e.attributes)})),m=Wn(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===He.RECORD_AND_SAMPLED?M.SAMPLED:M.NONE,v={traceId:u,spanId:c,traceFlags:_,traceState:d};if(h.decision===He.NOT_RECORD)return P.debug(`Recording is off, propagating context in a non-recording span`),F.wrapSpanContext(v);let y=Wn(Object.assign(m,h.attributes));return new el({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?N.active():i,l=this.startSpan(e,a,c),u=F.setSpan(c,l);return N.with(u,s,void 0,l)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}};L();var Ml=class{constructor(e){I(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=>{$n(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)})}};L();var Nl;(function(e){e[e.resolved=0]=`resolved`,e[e.timeout=1]=`timeout`,e[e.error=2]=`error`,e[e.unresolved=3]=`unresolved`})(Nl||(Nl={}));var Pl=class{constructor(e={}){var t,n;I(this,`_config`,void 0),I(this,`_tracers`,new Map),I(this,`_resource`,void 0),I(this,`_activeSpanProcessor`,void 0);let r=si({},sl(),fl(e));this._resource=(t=r.resource)==null?ao():t,this._config=Object.assign({},r,{resource:this._resource});let i=[];(n=e.spanProcessors)!=null&&n.length&&i.push(...e.spanProcessors),this._activeSpanProcessor=new Ml(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 jl({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=Nl.timeout},e);t.forceFlush().then(()=>{clearTimeout(i),r!==Nl.timeout&&(r=Nl.resolved,n(r))}).catch(e=>{clearTimeout(i),r=Nl.error,n(e)})}));return new Promise((e,n)=>{Promise.all(t).then(t=>{let r=t.filter(e=>e!==Nl.resolved);r.length>0?n(r):e()}).catch(e=>n([e]))})}shutdown(){return this._activeSpanProcessor.shutdown()}};L();var Fl=class{constructor(e){I(this,`_exporter`,void 0),I(this,`_shutdownOnce`,void 0),I(this,`_pendingExports`,void 0),this._exporter=e,this._shutdownOnce=new yi(this._shutdown,this),this._pendingExports=new Set}forceFlush(){var e=this;return W(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&M.SAMPLED)===0)return;let t=this._doExport(e).catch(e=>$n(e));this._pendingExports.add(t),t.finally(()=>this._pendingExports.delete(t))}_doExport(e){var t=this;return W(function*(){if(e.resource.asyncAttributesPending){var n,r;yield(n=(r=e.resource).waitForAsyncAttributes)==null?void 0:n.call(r)}let i=yield xi._export(t._exporter,[e]);if(i.code!==U.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()}};L();var Il=class{constructor(){I(this,`_enabled`,!1),I(this,`_currentContext`,T)}_bindFunction(e=T,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=T,this._enabled=!1,this}enable(){return this._enabled?this:(this._enabled=!0,this._currentContext=T,this)}with(e,t,n,...r){let i=this._currentContext;this._currentContext=e||T;try{return t.call(n,...r)}finally{this._currentContext=i}}};function Ll(e){if(e!==null){if(e===void 0){let e=new Il;e.enable(),N.setGlobalContextManager(e);return}e.enable(),N.setGlobalContextManager(e)}}function Rl(e){if(e!==null){if(e===void 0){nt.setGlobalPropagator(new Tr({propagators:[new Wr,new Un]}));return}nt.setGlobalPropagator(e)}}var zl=class extends Pl{constructor(e={}){super(e)}register(e={}){F.setGlobalTracerProvider(this),Rl(e.propagator),Ll(e.contextManager)}},Bl=e=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`,Vl=()=>typeof window>`u`?`http://localhost`:window.location.origin,Hl=e=>{try{return new URL(e,Vl()).href}catch(t){return e}},Ul=e=>e.length>1?e.replace(/\/+$/,``):e,Wl=(e,t)=>{let n=e=>Ul(e.replace(/[?#].*$/,``));return n(e)===n(t)},Gl=(e,t)=>{let n=Hl(t);return[e.transport.traces,e.transport.metrics,e.transport.logs].filter(e=>e!==!1).some(e=>Wl(n,Hl(e.endpoint)))},Kl=(e,t)=>Gl(e,t),ql=(e,t)=>typeof e==`function`?e(t):typeof e==`string`?t.includes(e):(e.lastIndex=0,e.test(t)),Jl=(e,t)=>(Array.isArray(e)?e:e?[e]:[]).some(e=>ql(e,t)),Yl=e=>typeof e.tracking.request==`object`?e.tracking.request:void 0,Xl=(e,t)=>{var n;return Kl(e,t)||Jl((n=Yl(e))==null?void 0:n.excludedUrls,Hl(t))},Zl=(e,t)=>{var n;return e.transport.traces!==!1&&Jl((n=Yl(e))==null?void 0:n.allowedTracingUrls,Hl(t))},Y={actionErrorCount:`action.error.count`,actionFrustrationCount:`action.frustration.count`,actionFrustrationType:`action.frustration.type`,actionId:`action.id`,actionLoadingTime:`action.loading_time`,actionLongTaskCount:`action.long_task.count`,actionName:`action.name`,actionResourceCount:`action.resource.count`,actionTargetName:`action.target.name`,actionTargetTag:`action.target.tag`,actionType:`action.type`,deploymentEnvironmentName:`deployment.environment.name`,browserName:`browser.name`,browserVersion:`browser.version`,cacheHit:`resource.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`,longTaskBlockingDuration:`long_task.blocking_duration`,longTaskCulprit:`long_task.culprit`,longTaskDuration:`long_task.duration`,longTaskEntryType:`long_task.entry_type`,longTaskId:`long_task.id`,longTaskIsFrozenFrame:`long_task.is_frozen_frame`,longTaskScriptCount:`long_task.script.count`,longTaskStartTime:`long_task.start_time`,networkEffectiveType:`network.effective_type`,nextHopProtocol:`resource.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`,targetValue:`target_value`,traceScene:`trace_scene`,transferSize:`transfer_size`,userId:`user.id`,vitalMetric:`vital.metric`,vitalRating:`vital.rating`,vitalValue:`vital.value`,viewDomComplete:`view.dom_complete`,viewDomContentLoaded:`view.dom_content_loaded`,viewDomInteractive:`view.dom_interactive`,viewFirstByte:`view.first_byte`,viewId:`view.id`,viewLoadEvent:`view.load_event`,viewLoadingTime:`view.loading_time`,viewLoadingType:`view.loading_type`,viewName:`view.name`,viewUrl:`view.url`,viewUrlPathGroup:`view.url_path_group`};q();var X={abort:`abort`,error:`error`,success:`success`,timeout:`timeout`,warning:`warning`},Z={action:`action`,custom:`custom`,document:`document`,error:`error`,longtask:`longtask`,resource:`resource`,route:`route`,vital:`vital`},Ql=e=>e<100?`<100ms`:e<500?`100~500ms`:e<2e3?`500ms~2s`:`>2s`,$l=e=>`${Math.trunc(e/100)}xx`,eu=e=>e===408||e===504?X.timeout:typeof e==`number`&&e>=400?X.error:X.success,tu=e=>e===408||e===504?`network_timeout`:typeof e!=`number`||e<400?`none`:e>=500?`http_5xx`:`http_4xx`,nu=e=>e===`good`?X.success:X.warning,ru=(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}}},Q=({duration:e,errorType:t=`none`,eventLabel:n,result:r=X.success,spanSubtype:i,spanType:a,targetLabel:o,targetValue:s,traceScene:c})=>K(K(K(K(K({[Y.spanType]:a,[Y.spanSubtype]:i,[Y.result]:r,[Y.errorType]:t},e===void 0?{}:{[Y.durationBucket]:Ql(e)}),n===void 0?{}:{[Y.eventLabel]:n}),o===void 0?{}:{[Y.targetLabel]:o}),s===void 0?{}:{[Y.targetValue]:s}),c===void 0?{}:{[Y.traceScene]:c}),iu=({duration:e,initiatorType:t=`other`,method:n,networkError:r=!1,responseStatus:i,transferSize:a,url:o,urlPathTemplate:s})=>{var c;let l=ru(o,s),u=t===`fetch`||t===`xhr`,d=r?X.error:typeof i==`number`?eu(i):X.success,f=n==null?void 0:n.toUpperCase();return K(K(K(K(K(K(K({},Q({duration:e,errorType:r?`network`:typeof i==`number`?tu(i):`none`,eventLabel:u?`请求资源`:`静态资源`,result:d,spanSubtype:t,spanType:Z.resource,targetLabel:(c=l.label)==null?o:c,targetValue:u?i:a})),l.domain?{[Y.targetDomain]:l.domain}:{}),l.pathTemplate?{[Y.targetPathTemplate]:l.pathTemplate}:{}),{},{"resource.type":t,"resource.url":o},e===void 0?{}:{"resource.duration":e}),f?{"http.request.method":f,"resource.method":f}:{}),typeof a==`number`?{"resource.size":a}:{}),typeof i==`number`?K({"http.response.status_code":i,"resource.status_code":i},i>0?{[Y.statusClass]:$l(i)}:{}):{})};q();var au=100,ou=100,su=1e3,cu=100,lu=1e4,uu=`data-bk-action-name`,du=100,fu=10,pu=e=>e.replace(/\s+/g,` `).trim().slice(0,du),mu=e=>{var t;if(e.parentElement)return e.parentElement;let n=(t=e.getRootNode)==null?void 0:t.call(e);return typeof ShadowRoot<`u`&&n instanceof ShadowRoot?n.host:null},hu=(e,t)=>{let n=e;for(;n;){let e=n.getAttribute(t);if(e)return pu(e);n=mu(n)}},gu=e=>{var t;return e.isContentEditable?``:pu((t=e.textContent)==null?``:t)},_u=e=>{var t,n;let r=e,i=(t=r.labels)==null?void 0:t[0];if(i){let e=gu(i);if(e)return e}let a=e.tagName.toLowerCase(),o=(n=e.getAttribute(`type`))==null?void 0:n.toLowerCase();if(a===`input`&&[`button`,`reset`,`submit`].includes(o==null?``:o)){var s;let e=pu((s=r.value)==null?``:s);if(e)return e}if(a===`button`||a===`label`||e.getAttribute(`role`)===`button`){let t=gu(e);if(t)return t}for(let t of[`aria-label`,`alt`,`name`,`title`,`placeholder`]){var c;let n=pu((c=e.getAttribute(t))==null?``:c);if(n)return n}},vu=(e,t=uu,n=!1)=>{let r=hu(e,t);if(r)return r;if(!n)return e.tagName.toLowerCase();let i=e,a=0;for(;i&&a<=fu;){let e=i.tagName.toLowerCase();if(e===`body`||e===`html`||e===`head`)break;let t=_u(i);if(t)return t;if(e===`form`)break;i=mu(i),a+=1}for(i=e,a=0;i&&a<=fu;){let e=i.tagName.toLowerCase();if(e===`body`||e===`html`||e===`head`)break;let t=gu(i);if(t)return t;if(e===`form`)break;i=mu(i),a+=1}return e.tagName.toLowerCase()},yu=e=>{var t;let n=(t=e.composedPath)==null?void 0:t.call(e)[0];return n instanceof Element?n:e.target instanceof Element?e.target:void 0},bu=e=>{let t=e.timeStamp;return!Number.isFinite(t)||t<=0?Date.now():t>0xe8d4a51000?t:typeof performance>`u`?Date.now():performance.timeOrigin+t},xu=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>0?e:t,Su=e=>{let t=e;if(t.tagName.toLowerCase()===`label`&&t.hasAttribute(`for`)){var n;t=document.getElementById((n=t.getAttribute(`for`))==null?``:n)}for(;t;){let e=t.tagName.toLowerCase();if(t.hasAttribute(`contenteditable`)||e===`canvas`||e===`select`||e===`textarea`||e===`a`&&t.hasAttribute(`href`))return!0;if(e===`input`){var r,i;return![`button`,`checkbox`,`radio`,`range`,`reset`,`submit`].includes((r=(i=t.getAttribute(`type`))==null?void 0:i.toLowerCase())==null?`text`:r)}t=mu(t)}return!1},Cu=(e={})=>{let t=[],n=new Map,r=new Set,i=e.actionNameAttribute||uu,a=xu(e.maxDuration,lu),o=[],s,c=()=>{s==null||s.setRuntimeAttributes({[Y.actionId]:n.size?[...n.keys()]:void 0})},l=e=>!e.hadActivity&&!e.userActivity.input&&!e.userActivity.scroll&&!e.userActivity.selection&&!Su(e.target),u=e=>{var t;if(!r.delete(e)||!s||!e.completed||e.discardedByRage)return;clearTimeout(e.reportTimer),e.counts.error&&e.frustrations.add(`error_click`),((t=e.rageSources)==null?[e]:t).some(l)&&e.frustrations.add(`dead_click`);let n=[`rage_click`,`dead_click`,`error_click`].filter(t=>e.frustrations.has(t)),{endTime:i,hasLoadingTime:a}=e.completed,o=Math.max(0,i-e.startTime),c=e.counts.error>0||n.length>0,u=s.startSpan(`action.click`,K(K(K(K(K({},s.config.hooks.getPageAttributes()),Q({duration:a?o:void 0,errorType:e.counts.error?`js`:n.length?`frustration`:`none`,eventLabel:`用户操作`,result:c?X.warning:X.success,spanSubtype:`click`,spanType:Z.action,targetLabel:e.targetName,targetValue:a?o:void 0,traceScene:`user_action`})),e.runtimeAttributes),{},{[Y.actionId]:e.id,[Y.actionType]:`click`,[Y.actionName]:`Click on ${e.targetName}`,[Y.actionTargetName]:e.targetName,[Y.actionTargetTag]:e.targetTag,[Y.actionResourceCount]:e.counts.resource,[Y.actionErrorCount]:e.counts.error,[Y.actionLongTaskCount]:e.counts.longTask,[Y.actionFrustrationCount]:n.length},n.length?{[Y.actionFrustrationType]:n}:{}),a?{[Y.actionLoadingTime]:o}:{}),{startTime:e.startTime});u.setAttributes(K(K({},e.runtimeAttributes),{},{[Y.actionId]:e.id})),u.end(a?i:e.startTime)},d=(e,t,i)=>{if(!n.delete(e.id)||!s)return;clearTimeout(e.validationTimer),clearTimeout(e.quietTimer),clearTimeout(e.maxDurationTimer),c(),e.completed={endTime:t,hasLoadingTime:i},r.add(e);let a=Math.max(0,e.startTime+su-Date.now());e.reportTimer=setTimeout(()=>u(e),a)},f=()=>{[...r].forEach(u)},p=e=>{if(clearTimeout(e.quietTimer),!e.hadActivity||e.pendingRequests.size)return;let t=Math.max(0,e.lastActivityTime+ou-Date.now());e.quietTimer=setTimeout(()=>d(e,e.lastActivityTime,!0),t)},m=(e,t)=>{e.hadActivity=!0,e.lastActivityTime=Math.max(e.lastActivityTime,t),p(e)},h=(e,t)=>t>=e.startTime&&t<=e.startTime+a,g=e=>{for(let i of n.values()){if(e.type===`request_start`){var t;if(e.url&&Jl(s==null||(t=s.config.view)==null?void 0:t.excludedActivityUrls,e.url)||!h(i,e.time))continue;i.pendingRequests.add(e.id),m(i,e.time);continue}if(e.type===`request_end`){if(!i.pendingRequests.delete(e.id))continue;i.counts.resource+=1,m(i,e.time);continue}if(e.type===`long_task`||e.type===`resource`){var r;if(e.type===`resource`&&e.url&&Jl(s==null||(r=s.config.view)==null?void 0:r.excludedActivityUrls,e.url)||e.startTime>i.startTime+a||(e.type===`resource`?e.startTime<i.startTime:e.endTime<i.startTime))continue;i.counts[e.type===`long_task`?`longTask`:`resource`]+=1,m(i,e.endTime);continue}if(e.type===`dom_mutation`||e.type===`window_open`){h(i,e.time)&&m(i,e.time);continue}e.type===`error`&&h(i,e.time)&&(i.counts.error+=1,m(i,e.time))}},_=(e=Date.now())=>{[...n.values()].forEach(t=>d(t,e,t.hadActivity))},v=(e,t)=>{let n=`clientX`in t&&typeof t.clientX==`number`?t.clientX:0,r=`clientY`in t&&typeof t.clientY==`number`?t.clientY:0;o=o.filter(t=>e.startTime-t.action.startTime<=su);let i=o.at(-1),a=o.some(e=>e.action.userActivity.scroll||e.action.userActivity.selection),s=(i==null?void 0:i.target)===e.target&&Math.hypot(i.x-n,i.y-r)<=cu;if((a||i&&!s)&&(o=[]),o.push({action:e,target:e.target,x:n,y:r}),o.length>=3&&e.startTime-o[o.length-3].action.startTime<=su){let t=o.slice(-3).map(e=>e.action);t.slice(0,-1).forEach(e=>{e.discardedByRage=!0}),e.frustrations.add(`rage_click`),e.rageSources=t,o=[]}};return{name:`action`,init(l){if(typeof window>`u`||typeof document>`u`)return;s=l;let u={capture:!0,passive:!0},p=t=>{if(`button`in t&&typeof t.button==`number`&&t.button!==0)return;let r=yu(t);if(!r)return;let o=bu(t),s=Bl(`action`),u={counts:{error:0,longTask:0,resource:0},frustrations:new Set,hadActivity:!1,id:s,lastActivityTime:o,maxDurationTimer:setTimeout(()=>d(u,o+a,!0),a),pendingRequests:new Set,runtimeAttributes:l.getRuntimeAttributes(),startTime:o,target:r,targetName:vu(r,i,e.nameCollection===`text`),targetTag:r.tagName.toLowerCase(),userActivity:{input:!1,scroll:!1,selection:!1},validationTimer:setTimeout(()=>{u.hadActivity||d(u,u.startTime,!1)},au)};n.set(s,u),v(u,t),c()};window.addEventListener(`click`,p,u),t.push(()=>window.removeEventListener(`click`,p,u));let m=l.onActivity(g),h=l.onSessionLifecycle(e=>{e.type===`expired`&&(_(e.expiredAt),f())});t.push(m,h);let y=()=>{document.visibilityState===`hidden`&&(_(),f())},b=()=>{_(),f()};window.addEventListener(`pagehide`,b),document.addEventListener(`visibilitychange`,y),t.push(()=>window.removeEventListener(`pagehide`,b),()=>document.removeEventListener(`visibilitychange`,y));let x=e=>{new Set([...n.values(),...r,...o.map(e=>e.action)]).forEach(t=>{if(t.userActivity[e]=!0,e!==`input`&&t.frustrations.delete(`rage_click`)){var n;(n=t.rageSources)==null||n.slice(0,-1).forEach(e=>{e.discardedByRage=!1}),t.rageSources=void 0}})},S=()=>x(`input`),C=()=>x(`scroll`),w=()=>x(`selection`);window.addEventListener(`input`,S,u),window.addEventListener(`scroll`,C,u),document.addEventListener(`selectionchange`,w,u),t.push(()=>window.removeEventListener(`input`,S,u),()=>window.removeEventListener(`scroll`,C,u),()=>document.removeEventListener(`selectionchange`,w,u))},shutdown(){for(_(),f();t.length;){var e;(e=t.pop())==null||e()}o=[],s=void 0}}},wu=e=>{let t=e.type===`characterData`?e.target.parentElement:e.target;return t instanceof Element&&!!t.closest(`[data-bk-excluded-activity-mutations]`)},Tu=()=>{let e,t=[];return{name:`activity`,init(n){if(typeof document<`u`&&typeof MutationObserver<`u`&&(e=new MutationObserver(e=>{e.length&&!e.every(wu)&&n.notifyActivity({time:Date.now(),type:`dom_mutation`})}),e.observe(document,{attributes:!0,characterData:!0,childList:!0,subtree:!0})),!(typeof window>`u`)&&typeof window.open==`function`){let e=window.open,r=((...t)=>(n.notifyActivity({time:Date.now(),type:`window_open`}),Reflect.apply(e,window,t)));window.open=r,t.push(()=>{window.open===r&&(window.open=e)})}},shutdown(){var n;for(e==null||e.disconnect(),e=void 0;t.length;)(n=t.pop())==null||n()}}},Eu=(e,t)=>!!(t&&Jl(e.config.view.excludedActivityUrls,t)),Du=(e,t,n)=>{let r=new Set,i=!1,a=!1,o=t,s,c=e=>{i||(i=!0,clearTimeout(f),clearTimeout(s),d(),n(e))},l=()=>{clearTimeout(s),!(!a||r.size)&&(s=setTimeout(()=>c({endTime:o,hadActivity:!0}),Math.max(0,o+100-Date.now())))},u=e=>{a=!0,o=Math.max(o,e),l()},d=e.onActivity(n=>{if(!(n.type===`error`||n.type===`long_task`)){if(n.type===`request_start`){if(n.time<t||Eu(e,n.url))return;r.add(n.id),u(n.time);return}if(n.type===`request_end`){if(!r.delete(n.id))return;u(n.time);return}if(n.type===`resource`){if(n.endTime<t||Eu(e,n.url))return;u(n.endTime);return}n.time>=t&&u(n.time)}}),f=setTimeout(()=>{a||c({hadActivity:!1})},100);return()=>{i||(i=!0,clearTimeout(f),clearTimeout(s),d())}},$=`bk.rum.sampled`,Ou=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t=Math.imul(t^e.charCodeAt(n),16777619);return t+=t<<13,t^=t>>>7,t+=t<<3,t^=t>>>17,t+=t<<5,(t>>>0)/4294967296},ku=({application:e,session:t},n)=>t.sampleRate<=0?!1:t.sampleRate>=1?!0:Ou(`${e.name}\0${n}`)<t.sampleRate;function Au(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 ju(e,t){if(e==null)return{};var n,r,i=Au(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}q();var Mu=e=>typeof e==`string`&&e.length>0?e:void 0,Nu=e=>{let t=Mu(e);return t?{[Y.viewUrlPathGroup]:t}:{}},Pu=e=>K(K({},Nu(e[Y.viewUrlPathGroup])),{},{[$]:e[$]===!0});q();var Fu=1e3,Iu=200,Lu=`body`,Ru=.8,zu=[`[data-loading="true"]`,`[aria-busy="true"]`,`.loading`,`.is-loading`,`.spinner`,`.skeleton`,`.bk-loading`],Bu=[[.2,.2],[.5,.2],[.8,.2],[.2,.5],[.5,.5],[.8,.5],[.2,.8],[.5,.8],[.8,.8]],Vu=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>=0?e:t,Hu=(e,t)=>typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.min(1,e)):t,Uu=e=>{if(!e)return``;let t=e.tagName.toLowerCase();return e.id?`${t}#${e.id}`:t},Wu=(e,t)=>t.some(t=>{try{return e.matches(t)||!!e.closest(t)}catch(e){return!1}}),Gu=e=>{if(typeof getComputedStyle!=`function`)return!0;let t=getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`&&Number(t.opacity||1)>0},Ku=(e,t)=>{if(typeof document.elementsFromPoint==`function`)return document.elementsFromPoint(e,t);let n=document.elementFromPoint(e,t);return n?[n]:[]},qu=(e,t)=>{let n=document.querySelector(e);if(!n)return{centerElement:Uu(Ku(window.innerWidth/2,window.innerHeight/2)[0]),emptyCount:Bu.length,ignoredCount:0,reason:`missing_root`,rootFound:!1,score:1,validCount:Bu.length};let r=0,i=0,a=``;for(let[e,o]of Bu){let s=Ku(window.innerWidth*e,window.innerHeight*o);if(e===.5&&o===.5&&(a=Uu(s[0])),s.some(e=>Wu(e,t))){i+=1;continue}s.some(e=>e!==n&&e!==document.body&&e!==document.documentElement&&n.contains(e)&&Gu(e))||(r+=1)}let o=Bu.length-i;return{centerElement:a,emptyCount:r,ignoredCount:i,reason:`empty_viewport`,rootFound:!0,score:o?r/o:0,validCount:o}},Ju=(e={})=>{var t;let n=Vu(e.checkDelay,Fu),r=Vu(e.confirmationDelay,Iu),i=e.rootSelector||Lu,a=Hu(e.threshold,Ru),o=[...zu,...(t=e.ignoreSelectors)==null?[]:t],s,c,l,u,d=()=>{},f;return{name:`blank-screen`,init(e){if(typeof window>`u`||typeof document>`u`)return;let t=e.meter.createCounter(`browser.blank_screen.count`,{description:`Number of confirmed blank screens`}),p=()=>{clearTimeout(u),u=void 0},m=(n,r)=>{s!==n||c===n||(c=n,t.add(1,e.applyRedact(K(K(K({},e.config.hooks.getMetricAttributes()),Pu(e.getRuntimeAttributes())),{},{"blank_screen.reason":r.reason,"blank_screen.root_selector":i}))),e.startSpan(`browser.blank_screen`,K(K({},Q({errorType:`blank_screen`,eventLabel:`白屏`,result:X.error,spanSubtype:r.reason,spanType:Z.error,targetLabel:i,targetValue:r.score})),{},{"blank_screen.center_element":r.centerElement,"blank_screen.empty_ratio":r.score,"blank_screen.empty_sample_count":r.emptyCount,"blank_screen.ignored_sample_count":r.ignoredCount,"blank_screen.reason":r.reason,"blank_screen.root_found":r.rootFound,"blank_screen.root_selector":i,"blank_screen.sample_count":Bu.length,"blank_screen.valid_sample_count":r.validCount})).end())},h=t=>{if(s!==t||c===t||document.visibilityState===`hidden`)return;let n;try{n=qu(i,o)}catch(t){var l;e.config.debug&&((l=globalThis.console)==null||l.warn(`[bk-ot][blank-screen] detection failed:`,t));return}!n.validCount||n.score<a||(u=setTimeout(()=>{if(s!==t||document.visibilityState===`hidden`)return;let n;try{n=qu(i,o)}catch(t){var r;e.config.debug&&((r=globalThis.console)==null||r.warn(`[bk-ot][blank-screen] confirmation failed:`,t));return}n.validCount&&n.score>=a&&m(t,n)},r))},g=e=>{p(),document.visibilityState!==`hidden`&&(u=setTimeout(()=>h(e),n))};d=e.onViewChange(t=>{if(t.id!==s&&(p(),l==null||l(),l=void 0,s=t.id,c=void 0,t.id)){let n=t.id;l=Du(e,Date.now(),()=>{l=void 0,g(n)})}});let _=()=>{document.visibilityState===`hidden`?p():s&&c!==s&&g(s)};document.addEventListener(`visibilitychange`,_),f=()=>document.removeEventListener(`visibilitychange`,_)},shutdown(){clearTimeout(u),u=void 0,d(),l==null||l(),l=void 0,f==null||f(),f=void 0,s=void 0,c=void 0}}};q(),ut();var Yu=[`http.url`,`url.full`],Xu=`bk.rum.request.discard`,Zu=e=>{for(let n of Yu){var t;let r=(t=e.attributes)==null?void 0:t[n];if(typeof r==`string`)return r}},Qu=e=>{let t=e==null?void 0:e[Y.sessionId];return typeof t==`string`&&t.length>0},$u=e=>{let t=e==null?void 0:e[Y.viewId];return typeof t==`string`&&t.length>0},ed=e=>(e==null?void 0:e[`bk.rum.sampled`])===!0&&Qu(e)&&$u(e),td=class{constructor(e,t){this.inner=e,this.config=t}enabled(e){var t,n,r;return(t=(n=(r=this.inner).enabled)==null?void 0:n.call(r,e))==null?!0:t}forceFlush(){return this.inner.forceFlush()}onEmit(e,t){var n;let r=e.body===`session.start`||e.body===`session.rotate`;if(ed(e.attributes)||r&&((n=e.attributes)==null?void 0:n[`bk.rum.sampled`])===!0&&Qu(e.attributes)){delete e.attributes[$];try{var i,a,o,s,c;if(((i=this.config)==null||(o=(a=i.hooks).beforeSend)==null?void 0:o.call(a,{attributes:e.attributes,name:(s=e.eventName)==null?String((c=e.body)==null?``:c):s,signal:`log`}))===!1)return}catch(e){var l,u;(l=this.config)!=null&&l.debug&&((u=globalThis.console)==null||u.warn(`[bk-ot] tracking.beforeSend failed:`,e))}this.inner.onEmit(e,t)}}shutdown(){return this.inner.shutdown()}},nd=class{constructor(e,t,n){this.inner=e,this.config=t,this.getRuntimeAttributes=n}forceFlush(){return this.inner.forceFlush()}onEnd(e){let t=Zu(e);if(!(e.attributes[`bk.rum.request.discard`]===!0||t&&Gl(this.config,t)||!ed(e.attributes))){delete e.attributes[$];try{var n,r;if(((n=this.config.hooks)==null||(r=n.beforeSend)==null?void 0:r.call(n,{attributes:e.attributes,name:e.name,signal:`span`}))===!1)return}catch(e){var i;this.config.debug&&((i=globalThis.console)==null||i.warn(`[bk-ot] tracking.beforeSend failed:`,e))}this.inner.onEnd(e)}}onStart(e,t){var n;let r=(n=e.attributes)==null?{}:n,i={};for(let[e,t]of Object.entries(this.getRuntimeAttributes()))r[e]===void 0&&t!==void 0&&(i[e]=t);e.setAttributes(i),this.inner.onStart(e,t)}shutdown(){return this.inner.shutdown()}},rd=e=>K(K({},e),{},{dataPoints:e.dataPoints.filter(e=>e.attributes[$]===!0).map(e=>{let t=e.attributes,{[$]:n}=t,r=ju(t,[$].map(lt));return K(K({},e),{},{attributes:r})})}),id=class{constructor(e){this.inner=e}export(e,t){let n=K(K({},e),{},{scopeMetrics:e.scopeMetrics.map(e=>K(K({},e),{},{metrics:e.metrics.map(rd).filter(e=>e.dataPoints.length>0)})).filter(e=>e.metrics.length>0)});if(n.scopeMetrics.length===0){t({code:U.SUCCESS});return}this.inner.export(n,t)}forceFlush(){return this.inner.forceFlush()}selectAggregationTemporality(e){var t,n,r;return(t=(n=(r=this.inner).selectAggregationTemporality)==null?void 0:n.call(r,e))==null?Ki.CUMULATIVE:t}shutdown(){return this.inner.shutdown()}},ad=100,od=200,sd=[],cd=e=>e.replace(/#.*$/,``),ld=e=>{let t=sd.indexOf(e);t>=0&&sd.splice(t,1),e.timer!==void 0&&clearTimeout(e.timer)},ud=(e,t)=>{let n=e.callback;ld(e),e.callback=void 0,n==null||n(t)},dd=e=>{let t=performance.timeOrigin+e.startTime,n=sd.filter(n=>!n.entry&&cd(n.url)===cd(e.name)&&t>=n.startTime-50).sort((e,n)=>Math.abs(e.startTime-t)-Math.abs(n.startTime-t))[0];n&&(n.entry=e,n.callback&&ud(n,e))},fd=(e,t=Date.now())=>{let n={startTime:t,url:e};return sd.push(n),sd.length>ad&&ud(sd[0]),{cancel:()=>ud(n),complete:e=>{if(n.callback=e,n.entry){ud(n,n.entry);return}n.timer=setTimeout(()=>ud(n),od)}}};q();var pd=10*1024,md=[/^text\//i,/json/i,`application/x-www-form-urlencoded`,`application/graphql`],hd=e=>typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):pd,gd=(e,t,n)=>e?t.some(t=>typeof t==`string`?e.toLowerCase().includes(t.toLowerCase()):(t.lastIndex=0,t.test(e))):n,_d=e=>{try{var t;return e?(t=new Headers(e).get(`content-type`))==null?void 0:t:void 0}catch(e){return}},vd=function(){var e=W(function*(e,t){let n=e.getReader(),r=new TextDecoder,i=``;try{for(;i.length<=t;){let{done:e,value:t}=yield n.read();if(e){i+=r.decode();break}i+=r.decode(t,{stream:!0})}i.length>t&&(yield n.cancel().catch(()=>void 0))}finally{n.releaseLock()}return i});return function(t,n){return e.apply(this,arguments)}}(),yd=function(){var e=W(function*(e,t){if(typeof e==`string`)return e;if(typeof URLSearchParams<`u`&&e instanceof URLSearchParams)return e.toString();if(typeof Blob<`u`&&e instanceof Blob)return vd(e.stream(),t)});return function(t,n){return e.apply(this,arguments)}}(),bd=function(){var e=W(function*(e,t){if(typeof Request<`u`&&e instanceof Request){var n;let r=(n=e.headers.get(`content-type`))==null?void 0:n,i=e.clone();return{contentType:r,text:i.body?yield vd(i.body,t):``}}return{contentType:_d(e.headers),text:yield yd(e.body,t)}});return function(t,n){return e.apply(this,arguments)}}(),xd=e=>{if(typeof Request>`u`||!(e instanceof Request))return e;try{return e.clone()}catch(e){return}},Sd=function(){var e=W(function*(e,t){var n;if(!e)return{};let r=(n=e.headers.get(`content-type`))==null?void 0:n,i=e.clone();return{contentType:r,text:i.body?yield vd(i.body,t):``}});return function(t,n){return e.apply(this,arguments)}}(),Cd=e=>{var t;let n=(t=e.getResponseHeader(`content-type`))==null?void 0:t;return e.responseType===``||e.responseType===`text`?{contentType:n,text:e.responseText}:e.responseType===`json`?{contentType:n,text:JSON.stringify(e.response)}:{contentType:n}},wd=(e,t,n,r,i)=>{if(i===void 0)return;let a=hd(e.maxSize),o=i.length>a,s={body:i.slice(0,a*2),contentType:r,kind:n,method:t.resource.method,statusCode:t.resource.statusCode,truncated:o,type:t.resource.type,url:t.resource.url},c=e.redact(s);if(c!==void 0)return{body:c.slice(0,a),contentType:r,truncated:o||c.length>a}},Td=function(){var e=W(function*({bodyConfig:e,domainContext:t,event:n,fetchRequest:r,runtimeContext:i,span:a}){var o,s;let c=n.resource.statusCode,l=c===void 0||c===0||c>=400;if(((o=e.capture)==null?`errors`:o)===`errors`&&!l)return;let u=hd(e.maxSize)*2,d=(s=e.allowedContentTypes)==null?md:s,f={},p={};try{t.type===`fetch`?[f,p]=yield Promise.all([bd(r==null?t.request:r,u),Sd(t.response,u)]):(f={text:yield yd(t.requestBody,u)},p=Cd(t.xhr))}catch(e){return}let m,h;try{m=gd(f.contentType,d,!0)?wd(e,n,`request`,f.contentType,f.text):void 0,h=gd(p.contentType,d,!1)?wd(e,n,`response`,p.contentType,p.text):void 0}catch(e){return}if(!m&&!h)return;let g=a.spanContext();i.emitLog({attributes:K(K(K({},n.attributes),{},{"span.id":g.spanId,"trace.id":g.traceId},m?{"request.body":m.body,"request.body.content_type":m.contentType,"request.body.truncated":m.truncated}:{}),h?{"response.body":h.body,"response.body.content_type":h.contentType,"response.body.truncated":h.truncated}:{}),body:`browser.request.body`,context:F.setSpan(N.active(),a),eventName:`browser.request.body`,severityNumber:l?Ii.ERROR:Ii.INFO,severityText:l?`ERROR`:`INFO`})});return function(t){return e.apply(this,arguments)}}();q();var Ed=e=>e.deliveryType===`cache`||e.transferSize===0&&e.decodedBodySize>0?!0:void 0,Dd=(...e)=>e.every((t,n)=>n===0||e[n-1]<=t),Od=(e,t,n,r,i)=>{Dd(n,r,i)&&(e[`resource.${t}.start`]=r-n,e[`resource.${t}.duration`]=i-r)},kd=e=>{let t={},n=[e.startTime,e.fetchStart,e.domainLookupStart,e.domainLookupEnd,e.connectStart,e.connectEnd,e.requestStart,e.responseStart,e.responseEnd];return!n.every(Number.isFinite)||!Dd(...n)?t:(Od(t,`first_byte`,e.startTime,e.requestStart,e.responseStart),Od(t,`download`,e.startTime,e.responseStart,e.responseEnd),e.workerStart>0&&e.workerStart<e.fetchStart&&Od(t,`worker`,e.startTime,e.workerStart,e.fetchStart),e.fetchStart<e.domainLookupEnd&&Od(t,`dns`,e.startTime,e.domainLookupStart,e.domainLookupEnd),e.fetchStart<e.connectEnd&&(Od(t,`connect`,e.startTime,e.connectStart,e.connectEnd),e.connectStart<=e.secureConnectionStart&&e.secureConnectionStart<=e.connectEnd&&Od(t,`ssl`,e.startTime,e.secureConnectionStart,e.connectEnd)),e.redirectEnd>e.startTime&&Dd(e.startTime,e.redirectStart,e.redirectEnd,e.fetchStart)&&Od(t,`redirect`,e.startTime,e.redirectStart,e.redirectEnd),t)},Ad=e=>e.duration===0&&e.responseEnd>e.startTime?e.responseEnd-e.startTime:e.duration,jd=e=>{let t=typeof e.deliveryType==`string`?e.deliveryType||`other`:void 0;return K(K(K(K({[Y.transferSize]:e.transferSize,[Y.cacheHit]:Ed(e),[Y.nextHopProtocol]:e.nextHopProtocol},kd(e)),t?{"resource.delivery_type":t}:{}),e.renderBlockingStatus?{"resource.render_blocking_status":e.renderBlockingStatus}:{}),{},{"resource.encoded_body_size":e.encodedBodySize,"resource.decoded_body_size":e.decodedBodySize})},Md=(e=!0)=>{let t;return{name:`resource`,init(n){var r;if(typeof PerformanceObserver>`u`||!((r=PerformanceObserver.supportedEntryTypes)!=null&&r.includes(`resource`)))return;let i=t=>{if(!t.name||Kl(n.config,t.name))return;if(t.initiatorType===`fetch`||t.initiatorType===`xmlhttprequest`){dd(t);return}if(t.duration<0)return;let r=n.config.hooks.redactUrl(t.name),i=Ad(t),a=performance.timeOrigin+t.startTime,o=a+i;e&&n.startSpan(`browser.resource`,K(K(K({},n.config.hooks.getPageAttributes()),iu({duration:i,initiatorType:t.initiatorType||`other`,responseStatus:t.responseStatus,transferSize:t.transferSize,url:r,urlPathTemplate:n.config.hooks.getViewPathGroup(t.name)})),{},{"url.full":r,initiator_type:t.initiatorType||`other`},jd(t)),{startTime:a}).end(o),n.notifyActivity({endTime:o,startTime:a,type:`resource`,url:t.name})};try{t=new PerformanceObserver(e=>{for(let t of e.getEntries())i(t)}),t.observe({type:`resource`,buffered:!0})}catch(e){t=void 0}},shutdown(){t==null||t.disconnect(),t=void 0}}};q();var Nd=e=>typeof e.config.tracking.request==`object`?e.config.tracking.request:void 0,Pd=e=>{if(e.type===`xhr`)return e.xhr.status;if(e.response)return e.response.status;if(typeof e.error==`object`&&e.error&&`status`in e.error){let t=e.error.status;return typeof t==`number`?t:void 0}},Fd=e=>typeof e==`string`||e instanceof URL?Hl(String(e)):Hl(e.url),Id=(e,t)=>{var n;return((n=t==null?void 0:t.method)==null?typeof Request<`u`&&e instanceof Request?e.method:`GET`:n).toUpperCase()},Ld=(e,t)=>typeof Request<`u`&&e instanceof Request?e:t==null?{}:t,Rd=(e,t,n)=>{var r;let i=typeof Request<`u`&&e instanceof Request?e.headers:void 0,a=new Headers((r=t==null?void 0:t.headers)==null?i:r);return nt.inject(F.setSpan(N.active(),n),a,{set:(e,t,n)=>e.set(t,n)}),K(K({},t),{},{headers:a})},zd=(e,t)=>{let n={};nt.inject(F.setSpan(N.active(),t),n);for(let[t,r]of Object.entries(n))e.setRequestHeader(t,r)},Bd=(e,t)=>Kl(e.config,t)||Jl(e.config.view.excludedActivityUrls,t),Vd=(e,t)=>{if(Bd(e,t))return()=>{};let n=Bl(`request`);e.notifyActivity({id:n,time:Date.now(),type:`request_start`,url:t});let r=!1;return()=>{r||(r=!0,e.notifyActivity({id:n,time:Date.now(),type:`request_end`}))}},Hd=(e,t)=>e.config.transport.traces===!1?{cancel(){},complete(e){e()}}:fd(t),Ud=(e,t,n)=>{var r;return e.startSpan(`browser.resource`,K(K(K({},e.config.hooks.getPageAttributes()),iu({initiatorType:t,method:n.method,url:(r=n.url)==null?``:r,urlPathTemplate:n.url?e.config.hooks.getViewPathGroup(n.url):void 0})),n.url?{"resource.url":e.config.hooks.redactUrl(n.url)}:{}),{kind:Ue.CLIENT})},Wd=(e,t,n,r,i={},a)=>{var o;let s=i.url,c=s?e.config.hooks.redactUrl(s):void 0,l=Pd(r),u=i.method,d={attributes:K(K(K({},e.config.hooks.getPageAttributes()),iu({initiatorType:n,method:u,networkError:r.type===`fetch`?!r.response:r.xhr.status===0,responseStatus:l,url:c==null?``:c,urlPathTemplate:s?e.config.hooks.getViewPathGroup(s):void 0})),c?{"resource.url":c,"url.full":c}:{}),resource:{method:u,statusCode:l,type:n,url:c},type:`resource`},f=!0;try{var p,m;f=(p=Nd(e))==null||(m=p.beforeSend)==null?void 0:m.call(p,d,r)}catch(t){var h;e.config.debug&&((h=globalThis.console)==null||h.warn(`[bk-ot] request.beforeSend failed:`,t))}if(t.setAttributes(e.applyRedact(d.attributes)),f===!1){t.setAttribute(Xu,!0);return}((l==null?0:l)>=400||l===0||r.type===`fetch`&&r.error)&&t.setStatus({code:We.ERROR});let g=e.config.transport.logs===!1||(o=Nd(e))==null?void 0:o.body;g&&Td({bodyConfig:g,domainContext:r,event:d,fetchRequest:a,runtimeContext:e,span:t})},Gd=e=>{let t=[],n=new Set;return{name:`request`,enabled:e!==!1,init(e){if(!(typeof window>`u`)){if(typeof window.fetch==`function`){let r=window.fetch,i=function(){var t=W(function*(t,i){var a;let o=Fd(t);if(Xl(e.config,o))return r.call(this,t,i);let s={method:Id(t,i),url:o},c=Ud(e,`fetch`,s),l=Hd(e,o),u=Vd(e,o),d=Ld(t,i),f=e.config.transport.logs!==!1&&(a=Nd(e))!=null&&a.body?xd(d):void 0,p=Zl(e.config,o)?Rd(t,i,c):i,m=!1,h=t=>{m||(m=!0,n.delete(g),t&&c.setAttributes(e.applyRedact(jd(t))),c.end())},g=()=>{l.cancel(),h()};n.add(g);try{let n=yield r.call(this,t,p);return Wd(e,c,`fetch`,{request:d,response:n,type:`fetch`},s,f),l.complete(h),n}catch(t){throw Wd(e,c,`fetch`,{error:t,request:d,type:`fetch`},s,f),t instanceof Error&&c.recordException(t),l.complete(h),t}finally{u()}});return function(e,n){return t.apply(this,arguments)}}();window.fetch=i,t.push(()=>{window.fetch===i&&(window.fetch=r)})}if(typeof XMLHttpRequest<`u`){let r=new WeakMap,i=XMLHttpRequest.prototype.open,a=XMLHttpRequest.prototype.send,o=function(e,t,n=!0,a,o){return r.set(this,{method:e.toUpperCase(),url:Hl(String(t))}),i.call(this,e,String(t),n,a,o)},s=function(t){var i;let o=(i=r.get(this))==null?{}:i;if(!o.url||Xl(e.config,o.url))return a.call(this,t);let s=Ud(e,`xhr`,o),c=Hd(e,o.url),l=Vd(e,o.url);Zl(e.config,o.url)&&zd(this,s);let u=!1,d=()=>{c.cancel(),!u&&(u=!0,n.delete(d),l(),s.end())};n.add(d);let f=()=>{u||(Wd(e,s,`xhr`,{requestBody:t,type:`xhr`,xhr:this},o),l(),c.complete(t=>{u||(u=!0,n.delete(d),t&&s.setAttributes(e.applyRedact(jd(t))),s.end())}))};this.addEventListener(`loadend`,f,{once:!0});try{return a.call(this,t)}catch(e){throw e instanceof Error&&s.recordException(e),f(),e}};XMLHttpRequest.prototype.open=o,XMLHttpRequest.prototype.send=s,t.push(()=>{XMLHttpRequest.prototype.open===o&&(XMLHttpRequest.prototype.open=i),XMLHttpRequest.prototype.send===s&&(XMLHttpRequest.prototype.send=a)})}}},shutdown(){var e;for(let e of[...n])e();for(;t.length;)(e=t.pop())==null||e()}}},Kd=e=>{let t=5381;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);return(t>>>0).toString(36)},qd=(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})}}};q();var Jd=6e4,Yd=5,Xd=/^https?:|^\/\//i,Zd=(e,t)=>{if(t)return Xd.test(t)?e(t):t},Qd=()=>{let e;return{name:`csp-violation`,init(t){if(typeof window>`u`||typeof document>`u`)return;let n=qd(Jd,Yd),r=e=>{let r=Kd(`${e.violatedDirective}|${e.blockedURI}|${e.sourceFile}|${e.lineNumber}`),i=n.allow(r);if(!i.allowed)return;let a=Zd(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`,K(K(K({},t.config.hooks.getPageAttributes()),Q({errorType:`csp`,eventLabel:`CSP 错误`,result:X.error,spanSubtype:`csp`,spanType:Z.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,[Y.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}}};q();var $d=`BK_RUM_DEVICE_ID`,ef=250,tf=()=>navigator.connection,nf=()=>navigator.userAgentData,rf=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}},af=(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`},of=e=>{let t=null;try{t=window.localStorage.getItem(e)}catch(e){}if(t)return t;let n=Bl(`device`);try{window.localStorage.setItem(e,n)}catch(e){}return n},sf=()=>{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}},cf=()=>{let e=tf();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}:{}},lf=()=>{if(typeof navigator>`u`)return{};let e=nf(),t=navigator.userAgent,n=rf(t),r=af(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,[Y.browserName]:n.name,[Y.browserVersion]:n.version,[Y.deviceType]:i,[Y.osName]:r}},uf=(e,t)=>{let n;return()=>{n!==void 0&&window.clearTimeout(n),n=window.setTimeout(()=>{n=void 0,e()},t)}},df=(e={})=>{let t=[];return{name:`device`,init(n){var r;let i=(r=e.storageKey)==null?`${$d}_${Kd(n.config.application.name)}`:r,a=typeof window>`u`||e.persistentId!==!0?Bl(`device`):of(i);if(n.setRuntimeAttributes(K(K(K({"device.id":a},lf()),sf()),cf())),typeof window>`u`)return;let o=uf(()=>{n.setRuntimeAttributes(sf())},ef);window.addEventListener(`resize`,o),window.addEventListener(`orientationchange`,o),t.push(()=>window.removeEventListener(`resize`,o),()=>window.removeEventListener(`orientationchange`,o));let s=tf();if(s&&typeof s.addEventListener==`function`){let e=()=>{n.setRuntimeAttributes(cf())};s.addEventListener(`change`,e),t.push(()=>{var t;(t=s.removeEventListener)==null||t.call(s,`change`,e)})}},shutdown(){for(;t.length;){var e;(e=t.pop())==null||e()}}}};q();var ff=6e4,pf=5,mf=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>0?e:t,hf=e=>{if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch(t){return String(e)}},gf=e=>{var t;return e instanceof Error?(t=e.stack)==null?``:t:``},_f=e=>e.slice(0,80),vf=e=>{var t,n;return(t=(n=e.split(`
|
|
12
|
-
`).find(e=>e.trim().startsWith(`at `)))==null?void 0:n.trim())==null?``:t},yf=e=>e===`unhandledrejection`?`promise`:e===`resource`?`resource_load`:`js`,bf=({context:e,error:t,exceptionType:n,extra:r={},source:i,spanName:a,throttle:o})=>{let s=hf(t),c=gf(t),l=Kd(`${i}|${s}|${c.slice(0,256)}`),u=o.allow(l);if(!u.allowed)return;e.notifyActivity({time:Date.now(),type:`error`});let d=t instanceof Error?t:{message:s,name:n==null?i:n},f=K(K(K(K({},e.config.hooks.getPageAttributes()),e.config.hooks.getErrorAttributes()),Q({errorType:yf(i),eventLabel:`错误`,result:X.error,spanSubtype:yf(i),spanType:Z.error,targetLabel:t instanceof Error?t.name:n==null?i:n})),{},{"exception.message":s,[Y.exceptionMessageShort]:_f(s),"exception.stacktrace":c,[Y.exceptionStackTopFrame]:vf(c),"exception.type":t instanceof Error?t.name:n==null?i:n,[Y.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:We.ERROR,message:s}),p.end()},xf=(e={})=>{let t=[],n=mf(e.windowMs,ff),r=mf(e.maxPerWindow,pf);return{name:`error`,init(e){if(typeof window>`u`)return;let i=qd(n,r),a=t=>{var n;let r=!t.error&&!t.filename&&t.message===`Script error.`;bf({context:e,throttle:i,spanName:`browser.error`,source:`window.error`,error:(n=t.error)==null?t.message:n,extra:K({"code.filepath":t.filename,"code.lineno":t.lineno,"code.column":t.colno},r?{"error.cross_origin":!0}:{})})},o=t=>{bf({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||``;bf({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()}}}};q();var Sf=50,Cf=100,wf=700,Tf=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>=0?e:t,Ef=e=>Number.isFinite(e)?e:void 0,Df=(e,t)=>{var n;let r=(n=e.attribution)==null?void 0:n[0];return r!=null&&r.containerSrc?t(r.containerSrc):(r==null?void 0:r.containerName)||(r==null?void 0:r.name)||e.name||`unknown`},Of=(e,t)=>({"long_task.script.duration":e.duration,"long_task.script.execution_start":e.executionStart,"long_task.script.forced_style_and_layout_duration":e.forcedStyleAndLayoutDuration,"long_task.script.invoker":e.invoker,"long_task.script.invoker_type":e.invokerType,"long_task.script.pause_duration":e.pauseDuration,"long_task.script.source_char_position":e.sourceCharPosition,"long_task.script.source_function_name":e.sourceFunctionName,"long_task.script.source_url":e.sourceURL?t(e.sourceURL):``,"long_task.script.start_time":e.startTime,"long_task.script.window_attribution":e.windowAttribution}),kf=(e={})=>{let t=Tf(e.threshold,Sf),n=Math.max(t,Tf(e.warningThreshold,Cf)),r,i,a=[];return{name:`long-task`,init(e){var o;if(typeof PerformanceObserver>`u`||typeof performance>`u`)return;let s=(o=PerformanceObserver.supportedEntryTypes)==null?[]:o,c=s.includes(`long-animation-frame`)?`long-animation-frame`:s.includes(`longtask`)?`longtask`:void 0;if(!c)return;let l=e.meter.createCounter(`browser.long_task.count`,{description:`Number of long tasks and long animation frames`}),u=e.meter.createHistogram(`browser.long_task.duration`,{description:`Duration of long tasks and long animation frames`,unit:`ms`}),d=e.meter.createHistogram(`browser.long_task.blocking_duration`,{description:`Blocking duration of long animation frames`,unit:`ms`}),f=r=>{var i,a,o;if(!Number.isFinite(r.duration)||r.duration<t)return;let s=r.entryType===`long-animation-frame`,c=s?r:void 0,f=(i=c==null?void 0:c.scripts)==null?[]:i,p=f.reduce((e,t)=>!e||t.duration>e.duration?t:e,void 0),m=Bl(`long-task`),h=performance.timeOrigin+r.startTime,g=h+r.duration,_=r.duration>=n?X.warning:X.success,v=s?`long-animation-frame`:`long-task`,y=p!=null&&p.sourceURL?e.config.hooks.redactUrl(p.sourceURL):void 0,b=s?void 0:Df(r,e.config.hooks.redactUrl),x=y||(p==null?void 0:p.sourceFunctionName)||b||`unknown`,S=e.startSpan(`browser.long_task`,K(K(K(K(K(K(K(K({},e.config.hooks.getPageAttributes()),Q({duration:r.duration,errorType:_===X.warning?`main_thread_blocked`:`none`,eventLabel:s?`长动画帧`:`长任务`,result:_,spanSubtype:v,spanType:Z.longtask,targetLabel:x,targetValue:(a=c==null?void 0:c.blockingDuration)==null?r.duration:a})),{},{[Y.longTaskBlockingDuration]:(o=c==null?void 0:c.blockingDuration)==null?r.duration:o,[Y.longTaskDuration]:r.duration,[Y.longTaskEntryType]:v,[Y.longTaskId]:m,[Y.longTaskIsFrozenFrame]:r.duration>=wf,[Y.longTaskScriptCount]:f.length},b?{[Y.longTaskCulprit]:b}:{}),p?{[Y.longTaskCulprit]:x,"long_task.culprit.duration":p.duration,"long_task.culprit.forced_style_and_layout_duration":p.forcedStyleAndLayoutDuration,"long_task.culprit.function_name":p.sourceFunctionName,"long_task.culprit.invoker_type":p.invokerType}:{}),Ef(c==null?void 0:c.firstUIEventTimestamp)===void 0?{}:{"long_task.first_ui_event_timestamp":c.firstUIEventTimestamp}),Ef(c==null?void 0:c.renderStart)===void 0?{}:{"long_task.render_start":c.renderStart}),Ef(c==null?void 0:c.styleAndLayoutStart)===void 0?{}:{"long_task.style_and_layout_start":c.styleAndLayoutStart}),c?{[Y.longTaskStartTime]:c.startTime}:{}),{startTime:h});f.forEach(t=>{S.addEvent(`long_task.script`,e.applyRedact(Of(t,e.config.hooks.redactUrl)),performance.timeOrigin+t.startTime)}),S.end(g),e.notifyActivity({endTime:g,startTime:h,type:`long_task`});let C=e.applyRedact(K(K(K({},e.config.hooks.getMetricAttributes()),Pu(e.getRuntimeAttributes())),{},{[Y.longTaskEntryType]:v}));l.add(1,C),u.record(r.duration,C),c&&d.record(c.blockingDuration,C)},p=e=>e.forEach(e=>f(e));try{let e=!0;r=new PerformanceObserver(t=>{let n=t.getEntries();e?(a.push(...n),i||(i=setTimeout(()=>{let e=a;a=[],i=void 0,p(e)}))):p(n)}),r.observe({type:c,buffered:!0}),e=!1}catch(e){r=void 0}},shutdown(){r==null||r.disconnect(),r=void 0,clearTimeout(i),i=void 0,a=[]}}},Af=new Set,jf=``,Mf,Nf,Pf=!1,Ff=()=>typeof location>`u`?``:location.href,If=(e,t)=>{let n=Ff();jf=n;let r={fromUrl:t,source:e,toUrl:n};for(let e of Array.from(Af))e(r)},Lf=()=>{If(`popstate`,jf||Ff())},Rf=()=>{If(`hashchange`,jf||Ff())},zf=()=>{Pf||typeof window>`u`||typeof history>`u`||(Pf=!0,jf=Ff(),Mf=history.pushState,Nf=history.replaceState,history.pushState=function(e,t,n){let r=jf||Ff(),i=Mf==null?void 0:Mf.apply(this,[e,t,n]);return If(`pushState`,r),i},history.replaceState=function(e,t,n){let r=jf||Ff(),i=Nf==null?void 0:Nf.apply(this,[e,t,n]);return If(`replaceState`,r),i},window.addEventListener(`popstate`,Lf),window.addEventListener(`hashchange`,Rf))},Bf=()=>{!Pf||typeof window>`u`||typeof history>`u`||(Mf&&(history.pushState=Mf),Nf&&(history.replaceState=Nf),window.removeEventListener(`popstate`,Lf),window.removeEventListener(`hashchange`,Rf),Mf=void 0,Nf=void 0,Pf=!1,jf=``)},Vf=e=>typeof window>`u`||typeof history>`u`?()=>{}:(zf(),Af.add(e),()=>{Af.delete(e),Af.size===0&&Bf()});q();var Hf=[`span`,`stopLoadingTime`],Uf=new Set([...Object.values(Y),$]),Wf=()=>typeof location>`u`?``:location.href,Gf=()=>{if(typeof performance>`u`)return{};let e=performance.getEntriesByType(`navigation`)[0];if(!e)return{};let t={},n=(e,n)=>{Number.isFinite(n)&&n>0&&(t[e]=n)};return n(Y.viewFirstByte,e.responseStart),n(Y.viewDomInteractive,e.domInteractive),n(Y.viewDomContentLoaded,e.domContentLoadedEventEnd),n(Y.viewDomComplete,e.domComplete),n(Y.viewLoadEvent,e.loadEventEnd),t},Kf=e=>{let t=e.indexOf(`?`);return t<0?e:e.slice(0,t)},qf=e=>{let t=e.slice(1);if(!t||typeof document>`u`||typeof document.getElementById!=`function`)return!1;try{return!!document.getElementById(decodeURIComponent(t))}catch(e){return!!document.getElementById(t)}},Jf=(e,t)=>{try{let n=typeof location>`u`?`http://localhost`:location.href,r=new URL(e,n),i=new URL(t,n);return r.pathname!==i.pathname||!qf(i.hash)&&Kf(r.hash)!==Kf(i.hash)}catch(n){return e!==t}},Yf=()=>{let e=[];return{name:`page-view`,init(t){if(typeof window>`u`)return;let n,r,i=t.config.view.loadingTime?t.meter.createHistogram(`browser.view.loading_time`,{description:`Time from view start until network and DOM activity become idle`,unit:`ms`}):void 0,a=(e=Date.now())=>t.setView({},e),o=(e,n,r=Date.now(),i)=>{e.documentVersion+=1,t.emitLog({attributes:K(K(K(K(K({},t.config.hooks.getPageAttributes()),e.attributes),e.snapshotAttributes),{},{"event.type":`view`,"view.document_version":e.documentVersion,"view.duration":Math.max(0,r-e.startedAt),"view.is_active":n!==`final`,"view.snapshot.type":n},i?{"view.end_reason":i}:{}),e.loadingTime===void 0?{}:{[Y.viewLoadingTime]:e.loadingTime,"view.loading_time.source":e.loadingTimeSource}),body:`browser.view`,eventName:`browser.view`,severityNumber:Ii.INFO,severityText:`INFO`,timestamp:r})},s=(e,r=!0,s=Date.now())=>{var c;if(!n){r&&a(s);return}let l=K({},n);(c=n.stopLoadingTime)==null||c.call(n),n.loadingTime!==void 0&&(i==null||i.record(n.loadingTime,t.applyRedact(K(K(K({},t.config.hooks.getMetricAttributes()),Pu(t.getRuntimeAttributes())),{},{"view.loading_type":n.loadingType})))),o(n,`final`,s,e),n.span.setAttribute(`view.end_reason`,e),n.span.end(s),n=void 0,r&&a(s);let{span:u,stopLoadingTime:d}=l;return ju(l,Hf)},c=(e,t,r)=>{if(n!==e||!Number.isFinite(t)||t<0)return;let i=K(K({},e.loadingType===`initial_load`?Gf():{}),{},{[Y.viewLoadingTime]:t,"view.loading_time.source":r});e.span.setAttributes(i),Object.assign(e.snapshotAttributes,i),e.loadingTime=t,e.loadingTimeSource=r,o(e,`update`)},l=e=>{if(!t.config.view.loadingTime||document.visibilityState===`hidden`)return;let r=!1,i,a=e.loadingType!==`initial_load`,o,s,l=!1,u,d=()=>{var t;if(l||!r||!a||n!==e)return;let s=[i,o].filter(e=>e!==void 0);s.length&&c(e,Math.max(...s),`auto`),(t=e.stopLoadingTime)==null||t.call(e),e.stopLoadingTime=void 0},f=()=>{var t,n;let r=(t=(n=performance).getEntriesByType)==null?void 0:t.call(n,`navigation`)[0];return r!=null&&r.loadEventEnd?(o=Math.max(0,performance.timeOrigin+r.loadEventEnd-e.startedAt),a=!0,!0):!1};if(!a&&!f()){let t=()=>{setTimeout(()=>{n===e&&(f(),a=!0,d())})};window.addEventListener(`load`,t,{once:!0}),s=()=>window.removeEventListener(`load`,t)}let p=Du(t,e.startedAt,t=>{r=!0,t.hadActivity&&(i=Math.max(0,t.endTime-e.startedAt)),d()}),m=()=>{var t;document.visibilityState===`hidden`&&(l=!0,(t=e.stopLoadingTime)==null||t.call(e),e.stopLoadingTime=void 0)};document.addEventListener(`visibilitychange`,m),u=()=>document.removeEventListener(`visibilitychange`,m),e.stopLoadingTime=()=>{p(),s==null||s(),s=void 0,u==null||u(),u=void 0},d()},u=e=>{let n=t.applyRedact(e==null?{}:e);return Object.fromEntries(Object.entries(n).filter(([e,t])=>t!==void 0&&!Uf.has(e)))},d=(e,r,i,a=(e=>(e=n==null?void 0:n.rawUrl)==null?``:e)())=>{var c,d;if(!t.isSessionActive())return;let f=(c=e.url)==null?Wf():c,p=t.config.hooks.getViewPathGroup(f),m=(d=e.name)==null?p:d,h=u(e.attributes);s(r,!1);let g=Bl(`view`),_=t.config.hooks.redactUrl(f),v=t.config.hooks.redactUrl(a),y=i===`initial_load`,b=y&&typeof performance<`u`?performance.timeOrigin:Date.now(),x=y?Gf():{};t.setView({attributes:h,id:g,loadingType:i,name:m,startedAt:b,url:_,urlPathGroup:p},b);let S=K(K(K(K(K({},h),t.config.hooks.getPageAttributes()),x),Q({errorType:`none`,eventLabel:y?`文档加载`:`路由切换`,spanSubtype:y?`navigate`:r,spanType:y?Z.document:Z.route,targetLabel:p,traceScene:y?`page_load`:`route_change`})),{},{[Y.viewId]:g,[Y.viewName]:m,[Y.viewUrl]:_,[Y.viewUrlPathGroup]:p,[Y.viewLoadingType]:i,"url.previous":v,"event.source":r},y?{"document.referrer":t.config.hooks.redactUrl(document.referrer||``)}:{});n={attributes:h,documentVersion:0,id:g,loadingType:i,name:m,rawUrl:f,snapshotAttributes:S,span:t.startSpan(`browser.view`,S,{startTime:b}),startedAt:b,url:_,urlPathGroup:p},o(n,`create`,b),l(n)},f=t.onViewCommand(e=>{if(e.type===`start`){d(e.options,`manual`,n?`route_change`:`initial_load`);return}if(n){if(e.type===`set_loading_time`){var r;(r=n.stopLoadingTime)==null||r.call(n),n.stopLoadingTime=void 0,c(n,Math.max(0,e.time-n.startedAt),`manual`);return}n.name=e.name,n.span.setAttribute(Y.viewName,e.name),n.snapshotAttributes[Y.viewName]=e.name,t.setView({attributes:n.attributes,id:n.id,loadingType:n.loadingType,name:n.name,startedAt:n.startedAt,url:n.url,urlPathGroup:n.urlPathGroup}),o(n,`update`)}}),p=()=>{};t.config.view.tracking===`auto`&&(n||d({},`load`,`initial_load`),p=Vf(e=>{Jf(e.fromUrl,e.toUrl)&&d({},e.source,`route_change`,e.fromUrl)}));let m=e=>{e.persisted||s(`pagehide`)},h=e=>{e.persisted&&t.config.view.tracking===`auto`&&d({},`bfCache`,`bf_cache`,n==null?void 0:n.rawUrl)},g=t.onSessionLifecycle(e=>{if(e.type===`expired`){r=s(`session_expired`,!0,e.expiredAt);return}r&&(d({attributes:r.attributes,name:r.name,url:r.rawUrl},`sessionRenewal`,`session_renewal`,r.rawUrl),r=void 0)});window.addEventListener(`pagehide`,m),window.addEventListener(`pageshow`,h),e.push(p,g,f,()=>window.removeEventListener(`pagehide`,m),()=>window.removeEventListener(`pageshow`,h),()=>s(`shutdown`))},shutdown(){for(;e.length;){var t;(t=e.pop())==null||t()}}}};q();var Xf=5e3,Zf=e=>typeof e==`number`&&Number.isFinite(e)&&e>0,Qf=(e,t,n,r)=>({expiresAt:Math.min(t+n,t+r),id:e,startedAt:t,status:`active`}),$f=(e,t,n)=>{if(t>=e.startedAt+n)return`maxLifetime`;if(t>=e.expiresAt)return`inactivity`},ep=(e,t,n,r)=>K(K({},e),{},{expiresAt:Math.min(t+n,e.startedAt+r)}),tp=(e,t,n)=>{if(!e)return null;try{let r=JSON.parse(e);if(r.status===`active`&&typeof r.id==`string`&&r.id.length>0&&Zf(r.startedAt)&&r.startedAt<=t+Xf&&Zf(r.expiresAt)&&r.expiresAt>=r.startedAt&&r.expiresAt<=r.startedAt+n||r.status===`expired`&&typeof r.previousId==`string`&&r.previousId.length>0&&(r.reason===`inactivity`||r.reason===`maxLifetime`)&&Zf(r.expiredAt)&&r.expiredAt<=t+Xf)return r}catch(e){}return null};q();var np=900*1e3,rp=14400*1e3,ip=1e3,ap=6e4,op=[`click`,`keydown`,`scroll`,`touchstart`],sp=new Map,cp=e=>{let t=typeof window<`u`,n=()=>{var n;if(t)try{return window.localStorage.getItem(e)}catch(e){t=!1}return(n=sp.get(e))==null?null:n};return n(),{isLocalStorage:()=>t,read:n,write:n=>{let r=JSON.stringify(n);if(sp.set(e,r),t)try{window.localStorage.setItem(e,r)}catch(e){t=!1}}}},lp=(e,t)=>{let n=``;try{n=new URL(e).host}catch(t){n=e}return`bk_ot_session__${Kd(`${t}\0${n||`default`}`)}`},up=(e,t)=>{t.reason&&e.emitLog({severityNumber:Ii.INFO,severityText:`INFO`,body:t.reason===`init`?`session.start`:`session.rotate`,attributes:K(K({},e.config.hooks.getPageAttributes()),{},{[Y.sessionHasReplay]:!1,[Y.sessionId]:t.record.id,[Y.sessionStartTime]:t.record.startedAt,"session.rotate.reason":t.reason},t.previousId?{"session.previous_id":t.previousId}:{})})},dp=(e={})=>{let t=[];return{name:`session`,init(n){var r;if(typeof window>`u`||typeof document>`u`){n.setRuntimeAttributes({[Y.sessionHasReplay]:!1,[Y.sessionId]:Bl(`session`)});return}let i=(r=e.storageKey)==null?lp(n.config.transport.endpoint,n.config.application.name):r,a=cp(i),o=typeof performance<`u`&&Number.isFinite(performance.timeOrigin)?performance.timeOrigin:Date.now(),s,c,l=(e=Date.now())=>tp(a.read(),e,rp),u=()=>{c!==void 0&&(clearTimeout(c),c=void 0)},d=(e,t=Date.now())=>{let r=s;r&&(n.notifySessionLifecycle({expiredAt:t,id:r,reason:e,type:`expired`}),u(),s=void 0,n.setRuntimeAttributes({[Y.sessionHasReplay]:void 0,[Y.sessionId]:void 0},t),n.flush())},f=()=>{let e=Date.now(),t=l(e);if(!t){d(`external`,e);return}if(t.status===`expired`){d(t.reason,t.expiredAt);return}if(t.id!==s){d(`external`,e);return}let n=$f(t,e,rp);if(!n){p(t);return}let r={expiredAt:e,previousId:t.id,reason:n,status:`expired`};a.write(r),d(n,e)},p=e=>{u();let t=Math.min(e.expiresAt,e.startedAt+rp);c=setTimeout(f,Math.max(0,t-Date.now()))},m=(e,t)=>{let r=e.id!==s;s=e.id,n.setRuntimeAttributes({[Y.sessionHasReplay]:!1,[Y.sessionId]:e.id},Math.min(e.startedAt,o)),p(e),r&&t&&n.notifySessionLifecycle({id:e.id,previousId:t.previousId,reason:t.reason,startedAt:e.startedAt,type:`renewed`})},h=(e=!1)=>{let t=Date.now(),r=l(t);if((r==null?void 0:r.status)===`active`&&!$f(r,t,rp)){let e=ep(r,t,np,rp);a.write(e),m(e,s?void 0:{reason:`shared`});return}let i=(r==null?void 0:r.status)===`expired`?r.previousId:r==null?void 0:r.id,o=(r==null?void 0:r.status)===`expired`?r.reason:r?$f(r,t,rp):e?`init`:void 0,c=Qf(Bl(`session`),t,np,rp);a.write(c),m(c,{previousId:i,reason:o==null?`init`:o}),up(n,{previousId:i,reason:o==null?`init`:o,record:c})},g=()=>{if(!s)return;let e=Date.now(),t=l(e);if((t==null?void 0:t.status)!==`active`||t.id!==s||$f(t,e,rp)){f();return}let n=ep(t,e,np,rp);a.write(n),m(n)};h(!0);let _=0,v=()=>{let e=Date.now();e-_<ip||(_=e,h())},y={capture:!0,passive:!0};op.forEach(e=>window.addEventListener(e,v,y)),t.push(()=>{op.forEach(e=>window.removeEventListener(e,v,y))});let b=()=>{document.visibilityState===`visible`&&g()};document.addEventListener(`visibilitychange`,b);let x=window.setInterval(b,ap);t.push(()=>{document.removeEventListener(`visibilitychange`,b),window.clearInterval(x)});let S=e=>{if(!a.isLocalStorage()||e.storageArea!==window.localStorage||e.key!==i)return;let t=Date.now(),n=tp(e.newValue,t,rp);if((n==null?void 0:n.status)===`active`&&n.id===s&&!$f(n,t,rp)){p(n);return}d((n==null?void 0:n.status)===`expired`?n.reason:`external`,(n==null?void 0:n.status)===`expired`?n.expiredAt:t)};window.addEventListener(`storage`,S),t.push(()=>window.removeEventListener(`storage`,S)),t.push(u)},shutdown(){for(var e;t.length;)(e=t.pop())==null||e()}}},fp=n({CLSThresholds:()=>Lp,FCPThresholds:()=>Fp,INPThresholds:()=>Zp,LCPThresholds:()=>em,TTFBThresholds:()=>nm,onCLS:()=>zp,onFCP:()=>Bp,onINP:()=>Qp,onLCP:()=>tm,onTTFB:()=>im});function pp(e,t){return yp.get(e)||yp.set(e,new t),yp.get(e)}var mp,hp,gp,_p,vp,yp,bp,xp,Sp,Cp,wp,Tp,Ep,Dp,Op,kp,Ap,jp,Mp,Np,Pp,Fp,Ip,Lp,Rp,zp,Bp,Vp,Hp,Up,Wp,Gp,Kp,qp,Jp,Yp,Xp,Zp,Qp,$p,em,tm,nm,rm,im,am=t((()=>{L(),q(),mp=class{constructor(){I(this,`t`,void 0),I(this,`o`,0),I(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)}},hp=()=>{let e=performance.getEntriesByType(`navigation`)[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},gp=e=>{if(document.readyState===`loading`)return`loading`;let t=hp();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(/^#/,``)},vp=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},yp=new WeakMap,bp=-1,xp=()=>bp,Sp=e=>{addEventListener(`pageshow`,t=>{t.persisted&&(bp=t.timeStamp,e(t))},!0)},Cp=(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)))}},wp=e=>{requestAnimationFrame(()=>requestAnimationFrame(e))},Tp=()=>{var e,t;return(e=(t=hp())==null?void 0:t.activationStart)==null?0:e},Ep=(e,t=-1)=>{let n=hp(),r=`navigate`;return xp()>=0?r=`back-forward-cache`:n&&(document.prerendering||Tp()>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}},Dp=(e,t,n={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){let r=new PerformanceObserver(e=>{queueMicrotask(()=>{t(e.getEntries())})});return r.observe(K({type:e,buffered:!0},n)),r}}catch(e){}},Op=e=>{let t=!1;return()=>{t||(e(),t=!0)}},kp=-1,Ap=new Set,jp=()=>document.visibilityState!==`hidden`||document.prerendering?1/0:0,Mp=e=>{if(document.visibilityState===`hidden`){if(e.type===`visibilitychange`)for(let e of Ap)e();isFinite(kp)||(kp=e.type===`visibilitychange`?e.timeStamp:0,removeEventListener(`prerenderingchange`,Mp,!0))}},Np=()=>{if(kp<0){var e;let t=Tp(),n=document.prerendering||(e=globalThis.performance.getEntriesByType(`visibility-state`).find(e=>e.name===`hidden`&&e.startTime>=t))==null?void 0:e.startTime;kp=n==null?jp():n,addEventListener(`visibilitychange`,Mp,!0),addEventListener(`prerenderingchange`,Mp,!0),Sp(()=>{setTimeout(()=>{kp=jp()})})}return{get firstHiddenTime(){return kp},onHidden(e){Ap.add(e)}}},Pp=e=>{document.prerendering?addEventListener(`prerenderingchange`,e,!0):e()},Fp=[1800,3e3],Ip=(e,t={})=>{Pp(()=>{let n=Np(),r,i=Ep(`FCP`),a=Dp(`paint`,e=>{for(let t of e)t.name===`first-contentful-paint`&&(a.disconnect(),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-Tp(),0),i.entries.push(t),r(!0)))});a&&(r=Cp(e,i,Fp,t.reportAllChanges),Sp(n=>{i=Ep(`FCP`),r=Cp(e,i,Fp,t.reportAllChanges),wp(()=>{i.value=performance.now()-n.timeStamp,r(!0)})}))})},Lp=[.1,.25],Rp=e=>e.find(e=>{var t;return((t=e.node)==null?void 0:t.nodeType)===1})||e[0],zp=(e,t={})=>{let n=pp(t=Object.assign({},t),mp),r=new WeakMap;n.t=e=>{var n;if(!(e==null||(n=e.sources)==null)&&n.length){let n=Rp(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?vp(o):i;r.set(n,e)}}},((e,t={})=>{let n=Np();Ip(Op(()=>{let r,i=Ep(`CLS`,0),a=pp(t,mp),o=e=>{for(let t of e)a.u(t);a.o>i.value&&(i.value=a.o,i.entries=a.i,r())},s=Dp(`layout-shift`,o);s&&(r=Cp(e,i,Lp,t.reportAllChanges),n.onHidden(()=>{o(s.takeRecords()),r(!0)}),Sp(()=>{a.o=0,i=Ep(`CLS`,0),r=Cp(e,i,Lp,t.reportAllChanges),wp(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=Rp(i.sources);e&&(t={largestShiftTarget:r.get(e),largestShiftTime:i.startTime,largestShiftValue:i.value,largestShiftSource:e,largestShiftEntry:i,loadState:gp(i.startTime)})}}return Object.assign(e,{attribution:t})})(t))},t)},Bp=(e,t={})=>{Ip(t=>{e((e=>{let t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:gp(xp())};if(e.entries.length){let n=hp(),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:gp(e.entries[0].startTime),navigationEntry:n,fcpEntry:r}}}return Object.assign(e,{attribution:t})})(t))},t)},Vp=0,Hp=1/0,Up=0,Wp=e=>{for(let t of e)t.interactionId&&(Hp=Math.min(Hp,t.interactionId),Up=Math.max(Up,t.interactionId),Vp=Up?(Up-Hp)/7+1:0)},Kp=()=>{var e;return Gp?Vp:(e=performance.interactionCount)==null?0:e},qp=()=>{`interactionCount`in performance||Gp||(Gp=Dp(`event`,Wp,{durationThreshold:0}))},Jp=0,Yp=class{constructor(){I(this,`l`,[]),I(this,`h`,new Map),I(this,`m`,void 0),I(this,`p`,void 0)}v(){Jp=Kp(),this.l.length=0,this.h.clear()}M(){let e=Math.min(this.l.length-1,Math.floor((Kp()-Jp)/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)}}},Xp=e=>{let t=globalThis.requestIdleCallback||setTimeout,n=globalThis.cancelIdleCallback||clearTimeout;if(document.visibilityState===`hidden`)e();else{let r=Op(e),i=-1,a=()=>{n(i),r()};addEventListener(`visibilitychange`,a,{once:!0,capture:!0}),i=t(()=>{removeEventListener(`visibilitychange`,a,{capture:!0}),r()})}},Zp=[200,500],Qp=(e,t={})=>{let n=pp(t=Object.assign({},t),Yp),r=[],i=[],a=0,o=new WeakMap,s=new WeakMap,c=!1,l=()=>{c||(Xp(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?vp(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:gp(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})};Dp(`long-animation-frame`,e=>{r=r.concat(e),l()}),((e,t={})=>{if(!globalThis.PerformanceEventTiming||!(`interactionId`in PerformanceEventTiming.prototype))return;let n=Np();Pp(()=>{var r;qp();let i,a=Ep(`INP`),o=pp(t,Yp),s=e=>{Xp(()=>{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=Dp(`event`,s,{durationThreshold:(r=t.durationThreshold)==null?40:r});i=Cp(e,a,Zp,t.reportAllChanges),c&&(c.observe({type:`first-input`,buffered:!0}),n.onHidden(()=>{s(c.takeRecords()),i(!0)}),Sp(()=>{o.v(),a=Ep(`INP`),i=Cp(e,a,Zp,t.reportAllChanges)}))})})(t=>{e(f(t))},t)},$p=class{constructor(){I(this,`m`,void 0)}u(e){var t;(t=this.m)==null||t.call(this,e)}},em=[2500,4e3],tm=(e,t={})=>{let n=pp(t=Object.assign({},t),$p),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?vp(n):i;r.set(e,o)}else e.id&&r.set(e,`#${e.id}`)},((e,t={})=>{Pp(()=>{let n=Np(),r,i=Ep(`LCP`),a=pp(t,$p),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-Tp(),0),i.entries=[t],r())},s=Dp(`largest-contentful-paint`,o);if(s){r=Cp(e,i,em,t.reportAllChanges);let n=Op(()=>{o(s.takeRecords()),s.disconnect(),r(!0)}),a=e=>{e.isTrusted&&(Xp(n),removeEventListener(e.type,a,{capture:!0}))};for(let e of[`keydown`,`click`,`visibilitychange`])addEventListener(e,a,{capture:!0});Sp(n=>{i=Ep(`LCP`),r=Cp(e,i,em,t.reportAllChanges),wp(()=>{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=hp();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=K(K({},t),{},{timeToFirstByte:r,resourceLoadDelay:o-r,resourceLoadDuration:s-o,elementRenderDelay:e.value-s,navigationEntry:a})}}return Object.assign(e,{attribution:t})})(t))},t)},nm=[800,1800],rm=e=>{document.prerendering?Pp(()=>rm(e)):document.readyState===`complete`?setTimeout(e):addEventListener(`load`,()=>rm(e),!0)},im=(e,t={})=>{((e,t={})=>{let n=Ep(`TTFB`),r=Cp(e,n,nm,t.reportAllChanges);rm(()=>{let i=hp();i&&(n.value=Math.max(i.responseStart-Tp(),0),n.entries=[i],r(!0),Sp(()=>{n=Ep(`TTFB`,0),r=Cp(e,n,nm,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)}}));q();var om=`unknown`,sm=10,cm=6e4,lm=5e3,um=1e3,dm=e=>e?e.replace(/_/g,`-`):om,fm=()=>{if(typeof performance>`u`)return om;let e=performance.getEntriesByType(`navigation`)[0];return dm(e==null?void 0:e.type)},pm=(e,t)=>{let[n,r]=e===`CLS`?[.1,.25]:[200,500];return t<=n?`good`:t<=r?`needs-improvement`:`poor`},mm=e=>{var t,n,r;if(!(typeof Element>`u`||!(e instanceof Element)))return(t=(n=(r=e.getAttribute(`data-bk-action-name`))==null?e.getAttribute(`aria-label`):r)==null?e.getAttribute(`name`):n)==null?e.tagName.toLowerCase():t},hm=()=>{if(typeof performance>`u`)return;let e=performance.interactionCount;return typeof e==`number`&&Number.isFinite(e)?e:void 0},gm=(e,t)=>{var n,r;let i=(n=t.value)==null?0:n;if(!(t.hadRecentInput||!Number.isFinite(i))){if(e.clsWindowStart===void 0||t.startTime-((r=e.clsWindowEnd)==null?t.startTime:r)>=um||t.startTime-e.clsWindowStart>=lm){var a;e.clsWindowStart=t.startTime,e.clsWindowValue=i,e.clsWindowLargestShiftValue=i,e.clsWindowLargestShiftTarget=mm((a=t.sources)==null||(a=a[0])==null?void 0:a.node)}else if(e.clsWindowValue+=i,i>e.clsWindowLargestShiftValue){var o;e.clsWindowLargestShiftValue=i,e.clsWindowLargestShiftTarget=mm((o=t.sources)==null||(o=o[0])==null?void 0:o.node)}e.clsWindowEnd=t.startTime,e.clsWindowValue>e.cls&&(e.cls=Math.round(e.clsWindowValue*1e4)/1e4,e.largestShiftValue=e.clsWindowLargestShiftValue,e.largestShiftTarget=e.clsWindowLargestShiftTarget)}},_m=(e,t)=>{var n,r;if(!t.interactionId||!Number.isFinite(t.duration))return;e.interactionIdMin=Math.min(e.interactionIdMin,t.interactionId),e.interactionIdMax=Math.max(e.interactionIdMax,t.interactionId);let i=(n=t.processingStart)==null?t.startTime:n,a=(r=t.processingEnd)==null?i:r,o={duration:Math.min(t.duration,cm),inputDelay:Math.max(0,i-t.startTime),interactionId:t.interactionId,interactionTarget:mm(t.target),interactionType:t.name,presentationDelay:Math.max(0,t.startTime+t.duration-a),processingDuration:Math.max(0,a-i)},s=e.inpCandidates.findIndex(e=>e.interactionId===t.interactionId);s>=0?o.duration>e.inpCandidates[s].duration&&(e.inpCandidates[s]=o):e.inpCandidates.push(o),e.inpCandidates.sort((e,t)=>t.duration-e.duration).splice(sm)},vm=e=>{let t=hm(),n=t!==void 0&&e.interactionCountAtStart!==void 0?Math.max(0,t-e.interactionCountAtStart):e.interactionIdMin===1/0?0:(e.interactionIdMax-e.interactionIdMin)/7+1;if(e.inpCandidates.length)return e.inpCandidates[Math.min(e.inpCandidates.length-1,Math.floor(n/50))]},ym=(e,t)=>{var n;return{"rum.navigation.type":(n=e.navigationType)==null?t:n,[Y.vitalMetric]:e.name.toLowerCase(),[Y.vitalRating]:e.rating}},bm=(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},xm=()=>{let e,t=!1;return{name:`web-vitals`,init(n){return W(function*(){if(typeof window>`u`)return;let r;try{r=yield Promise.resolve().then(()=>(am(),fp))}catch(e){if(n.config.debug){var i;(i=globalThis.console)==null||i.warn(`[bk-ot] web-vitals load failed:`,e)}return}if(t)return;let{onFCP:a,onLCP:o,onTTFB:s}=r,c=fm(),l=n.meter.createHistogram(`browser.web_vital.cls`,{unit:`1`,description:`Cumulative Layout Shift`}),u=n.meter.createHistogram(`browser.web_vital.duration`,{unit:`ms`,description:`Web Vitals duration metrics, including FCP, INP, LCP and TTFB`}),d=(e,t,r)=>{let i=e.name.toLowerCase();n.startSpan(`browser.web_vital`,K(K(K(K(K({},n.config.hooks.getPageAttributes()),t),ym(e,c)),Q({duration:e.name===`CLS`?void 0:e.value,errorType:e.rating===`good`?`none`:`slow`,eventLabel:`Web 指标`,result:nu(e.rating),spanSubtype:i,spanType:Z.vital,targetLabel:i,targetValue:e.value})),{},{[Y.vitalMetric]:i,[Y.vitalValue]:e.value,[Y.vitalRating]:e.rating,"vital.id":e.id},bm(e,n.config.hooks.redactUrl)),r===void 0?void 0:{contextTime:r}).end()},f=e=>{if(t||!Number.isFinite(e.value))return;let r=e.entries[0],i=r&&typeof performance<`u`?performance.timeOrigin+r.startTime:void 0,a=i===void 0?n.getRuntimeAttributes():n.getRuntimeAttributesAt(i);u.record(e.value,n.applyRedact(K(K(K({},n.config.hooks.getMetricAttributes()),Pu(a)),ym(e,c)))),d(e,a,i)},p,m,h,g=(e,t,r)=>{let i=n.applyRedact(K(K(K({},n.config.hooks.getMetricAttributes()),Pu(t)),ym(e,c)));e.name===`CLS`?l.record(e.value,i):u.record(e.value,i),d(e,t,r)},_=()=>{let e=p;if(!e)return;g({attribution:{largestShiftTarget:e.largestShiftTarget,largestShiftValue:e.largestShiftValue},entries:[],id:Bl(`vital`),name:`CLS`,navigationType:c,rating:pm(`CLS`,e.cls),value:e.cls},e.runtimeAttributes,e.startedAt);let t=vm(e);t&&g({attribution:{inputDelay:t.inputDelay,interactionTarget:t.interactionTarget,interactionType:t.interactionType,presentationDelay:t.presentationDelay,processingDuration:t.processingDuration},entries:[],id:Bl(`vital`),name:`INP`,navigationType:c,rating:pm(`INP`,t.duration),value:t.duration},e.runtimeAttributes,e.startedAt)},v=n.onViewChange(e=>{var t;_(),p=e.id?{cls:0,clsWindowLargestShiftValue:0,clsWindowValue:0,interactionCountAtStart:hm(),interactionIdMax:0,interactionIdMin:1/0,inpCandidates:[],largestShiftValue:0,runtimeAttributes:n.getRuntimeAttributes(),startedAt:(t=e.startedAt)==null?Date.now():t}:void 0});if(typeof PerformanceObserver<`u`){var y,b;(y=PerformanceObserver.supportedEntryTypes)!=null&&y.includes(`layout-shift`)&&(h=new PerformanceObserver(e=>{if(p)for(let t of e.getEntries())performance.timeOrigin+t.startTime<p.startedAt||gm(p,t)}),h.observe({buffered:!0,type:`layout-shift`})),(b=PerformanceObserver.supportedEntryTypes)!=null&&b.includes(`event`)&&(m=new PerformanceObserver(e=>{if(p)for(let t of e.getEntries())performance.timeOrigin+t.startTime<p.startedAt||!t.interactionId||!Number.isFinite(t.duration)||_m(p,t)}),m.observe({buffered:!0,durationThreshold:40,type:`event`}))}a(f),o(f),s(f),e=()=>{_(),p=void 0,v(),h==null||h.disconnect(),m==null||m.disconnect()}})()},shutdown(){t=!0,e==null||e(),e=void 0}}};q();var Sm=64*1024,Cm=6e4,wm=5,Tm=e=>e==null?0:typeof e==`string`?e.length>Sm||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,Em=(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}},Dm=(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}=Em(u,a.config.hooks.redactUrl),p=a.applyRedact(K(K(K({},a.config.hooks.getMetricAttributes()),Pu(a.getRuntimeAttributes())),d)),m=(n=f[`server.address`])==null?f[`url.full`]:n,h=a.startSpan(`websocket.connect`,K(K(K({},f),Q({errorType:`none`,eventLabel:`WebSocket`,spanSubtype:`websocket`,spanType:Z.custom,targetLabel:m})),f[`server.address`]?{[Y.targetDomain]:f[`server.address`]}:{})),g=performance.now(),_=!1,v=e=>{if(_)return;_=!0;let t=performance.now()-g;e===`error`&&h.setStatus({code:We.ERROR,message:`websocket connect failed`}),h.setAttributes(Q({duration:t,errorType:e===`error`?`network`:`none`,eventLabel:`WebSocket`,result:e===`error`?X.error:X.success,spanSubtype:`websocket`,spanType:Z.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=K(K({},p),{},{"websocket.direction":`in`});l.add(1,t),r.add(Tm(e.data),t)}),e.addEventListener(`error`,()=>{if(c())return;let e=_?`runtime`:`connect`;o.add(1,K(K({},p),{},{"websocket.error.phase":e})),v(`error`);let t=s.allow(`ws:error:${u}`);t.allowed&&a.emitLog({severityNumber:Ii.ERROR,severityText:`ERROR`,body:`websocket.error`,attributes:K(K(K({},f),Q({errorType:`network`,eventLabel:`WebSocket 错误`,result:X.error,spanSubtype:`websocket`,spanType:Z.custom,targetLabel:m})),{},{"websocket.error.phase":e,"websocket.error.window_count":t.count})})}),e.addEventListener(`close`,e=>{c()||(_||v(`error`),a.emitLog({severityNumber:Ii.INFO,severityText:`INFO`,body:`websocket.close`,attributes:K(K(K({},f),Q({errorType:e.wasClean?`none`:`network`,eventLabel:`WebSocket 关闭`,result:e.wasClean?X.success:X.warning,spanSubtype:`websocket`,spanType:Z.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=K(K({},p),{},{"websocket.direction":`out`});l.add(1,t),r.add(Tm(e),t)}return y(e)}},Om=()=>{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=qd(Cm,wm),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||Kl(r.config,f)||Dm(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}}};L();var km=class{constructor(){I(this,`listeners`,new Set),I(this,`notify`,e=>{this.listeners.forEach(t=>t(e))}),I(this,`subscribe`,e=>(this.listeners.add(e),()=>this.listeners.delete(e)))}};q();var Am=60*1e3,jm=e=>e.trim().replace(/\/+$/,``),Mm={traces:`rum`,metrics:`metrics`,logs:`logs`},Nm=(e,t)=>`${jm(e==null?``:e)}/v1/${Mm[t]}`,Pm=(e,t)=>{var n,r,i;let a=(n=e.signals)==null?void 0:n[t];if(a===!1)return!1;let o=a==null?void 0:a.endpoint,s=e.token||e.headers||a!=null&&a.headers?K(K(K({},e.token?{Authorization:`Bearer ${e.token}`}:{}),(r=e.headers)==null?{}:r),(i=a==null?void 0:a.headers)==null?{}:i):void 0;return{concurrencyLimit:a==null?void 0:a.concurrencyLimit,endpoint:o?jm(o):Nm(e.endpoint,t),headers:s,timeoutMillis:a==null?void 0:a.timeoutMillis}},Fm=e=>typeof e!=`number`||!Number.isFinite(e)?1:Math.max(0,Math.min(1,e)),Im=e=>e,Lm=e=>{try{let t=new URL(e,typeof location>`u`?`http://localhost`:location.href);return t.username=``,t.password=``,t.search=``,t.hash=``,t.href}catch(t){return e.replace(/[?#].*$/,``)}},Rm=e=>{try{return new URL(e,typeof location>`u`?`http://localhost`:location.href).pathname||`/`}catch(t){return e||`/`}},zm=e=>{var t;return{environment:(t=e.environment)==null?`production`:t,name:e.name,version:e.version}},Bm=e=>K(K({[Y.deploymentEnvironmentName]:e.environment,"rum.provider":`blueking`,"rum.schema.version":`1`,[Y.serviceName]:e.name},e.version?{[Y.serviceVersion]:e.version}:{}),{},{"telemetry.sdk.language":`webjs`,"telemetry.sdk.name":`@blueking/open-telemetry`}),Vm=e=>{var t,n;let r=Pm(e,`traces`),i=Pm(e,`metrics`),a=Pm(e,`logs`);return{endpoint:jm((t=e.endpoint)==null?``:t)||((n=[r,i,a].find(e=>e!==!1))==null?void 0:n.endpoint)||``,traces:r,metrics:i,logs:a}},Hm=e=>{if(!e)throw Error(`[bk-ot] transport is required.`);let t=[`traces`,`metrics`,`logs`].filter(t=>{var n;return((n=e.signals)==null?void 0:n[t])!==!1});if(!t.length)throw Error(`[bk-ot] at least one transport signal must be enabled.`);for(let i of t){var n,r;let t=(n=e.signals)==null?void 0:n[i],a=t?t.endpoint:void 0;if(!(a!=null&&a.trim())&&!((r=e.endpoint)!=null&&r.trim()))throw Error(`[bk-ot] transport.signals.${i}.endpoint or transport.endpoint is required.`)}},Um=e=>{var t,n,r,i,a,o,s,c,l,u,d,f,p;return{beforeSend:(t=e.tracking)==null?void 0:t.beforeSend,getPageAttributes:(n=(r=e.context)==null||(r=r.attributes)==null?void 0:r.page)==null?(()=>({"rum.page.host":typeof window>`u`?``:window.location.host,"rum.page.path":typeof window>`u`?``:window.location.pathname})):n,getMetricAttributes:(i=(a=e.context)==null||(a=a.attributes)==null?void 0:a.metric)==null?(()=>({})):i,getErrorAttributes:(o=(s=e.context)==null||(s=s.attributes)==null?void 0:s.error)==null?(()=>({})):o,getCustomAttributes:(c=(l=e.context)==null||(l=l.attributes)==null?void 0:l.custom)==null?(()=>({})):c,getViewPathGroup:t=>{var n,r,i,a;return(n=typeof((r=e.tracking)==null?void 0:r.view)==`object`?(i=(a=e.tracking.view).getPathGroup)==null?void 0:i.call(a,t):void 0)==null?Rm(t):n},redactAttributes:(u=(d=e.privacy)==null?void 0:d.redactAttributes)==null?Im:u,redactUrl:(f=(p=e.privacy)==null?void 0:p.redactUrl)==null?Lm:f}},Wm=e=>{var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v;if(!(!((t=e.application)==null||(t=t.name)==null)&&t.trim()))throw Error(`[bk-ot] application.name is required.`);Hm(e.transport);let y=zm(e.application),b=typeof((n=e.tracking)==null?void 0:n.view)==`object`?e.tracking.view:void 0,x=(r=e.transport.signals)==null?void 0:r.traces,S=(i=e.transport.signals)==null?void 0:i.metrics;return{application:y,autoStart:(a=e.autoStart)==null?!0:a,debug:(o=e.debug)==null?!1:o,enabled:(s=e.enabled)==null?!0:s,extensions:{instrumentations:[...(c=(l=e.extensions)==null?void 0:l.instrumentations)==null?[]:c],plugins:[...(u=(d=e.extensions)==null?void 0:d.plugins)==null?[]:u]},hooks:Um(e),metricIntervalMillis:S?(f=S.intervalMillis)==null?Am:f:Am,resourceAttributes:Bm(y),session:K(K({},e.session),{},{sampleRate:Fm((p=e.session)==null?void 0:p.sampleRate)}),spanBatch:x?x.batch:void 0,spanProcessor:x?(m=x.processor)==null?`batch`:m:`batch`,tracking:(h=e.tracking)==null?{}:h,trackingConsent:(g=(_=e.privacy)==null?void 0:_.trackingConsent)==null?`granted`:g,transport:Vm(e.transport),user:(v=e.context)==null?void 0:v.user,view:{excludedActivityUrls:b==null?void 0:b.excludedActivityUrls,loadingTime:(b==null?void 0:b.loadingTime)!==!1,tracking:(b==null?void 0:b.tracking)===`manual`?`manual`:`auto`}}};L();var Gm=(e,t)=>typeof e.enabled==`function`?e.enabled(t):e.enabled!==!1,Km=class{constructor(e){I(this,`plugins`,void 0),I(this,`startedPlugins`,[]),this.plugins=e}flush(){var e=this;return W(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 W(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 W(function*(){for(let r of t.plugins)if(Gm(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)}}})()}};L(),q();var qm=new Set([...Object.values(Y),$]),Jm=class{constructor(e={},t){I(this,`actionHistory`,[]),I(this,`attributes`,{}),I(this,`queuedViewCommands`,[]),I(this,`recordAssociation`,(e,t,n,r)=>{let i=e.at(-1);if(i&&i.endedAt===void 0&&(i.endedAt=Math.max(i.startedAt,n)),r){let r={};for(let e of t){let t=this.attributes[e];t!==void 0&&(r[e]=t)}e.push({attributes:r,startedAt:n})}e.length>100&&e.splice(0,e.length-100)}),I(this,`sessionHistory`,[]),I(this,`sessionLifecycleListeners`,new Set),I(this,`setOptionalAttribute`,(e,t)=>{if(t===void 0){delete this.attributes[e];return}this.attributes[e]=t}),I(this,`user`,{}),I(this,`view`,{}),I(this,`viewAttributeKeys`,new Set),I(this,`viewChangeListeners`,new Set),I(this,`viewCommandListeners`,new Set),I(this,`viewHistory`,[]),I(this,`viewScopedAttributeKeys`,new Set),I(this,`dispatchViewCommand`,e=>{if(this.viewCommandListeners.size===0){this.queuedViewCommands.push(e);return}this.viewCommandListeners.forEach(t=>t(e))}),I(this,`getAttributes`,()=>K({},this.attributes)),I(this,`getAttributesAt`,e=>{if(!Number.isFinite(e))return this.getAttributes();let t=this.getAttributes(),n=(n,r)=>{for(let e of r)delete t[e];let i=[...n].reverse().find(t=>t.startedAt<=e&&(t.endedAt===void 0||e<t.endedAt));i&&Object.assign(t,i.attributes)};return n(this.sessionHistory,[Y.sessionId,Y.sessionHasReplay,$]),n(this.viewHistory,this.viewScopedAttributeKeys),n(this.actionHistory,[Y.actionId]),t}),I(this,`getUser`,()=>K({},this.user)),I(this,`getView`,()=>K({},this.view)),I(this,`isSessionActive`,()=>typeof this.attributes[Y.sessionId]==`string`),I(this,`isViewActive`,()=>typeof this.attributes[Y.viewId]==`string`),I(this,`notifySessionLifecycle`,e=>{this.sessionLifecycleListeners.forEach(t=>t(e))}),I(this,`onSessionLifecycle`,e=>(this.sessionLifecycleListeners.add(e),()=>this.sessionLifecycleListeners.delete(e))),I(this,`onViewChange`,e=>(this.viewChangeListeners.add(e),this.view.id&&e(this.getView()),()=>this.viewChangeListeners.delete(e))),I(this,`onViewCommand`,e=>{for(this.viewCommandListeners.add(e);this.queuedViewCommands.length;)e(this.queuedViewCommands.shift());return()=>this.viewCommandListeners.delete(e)}),I(this,`setAttributes`,(e,t=Date.now())=>{for(let[t,n]of Object.entries(e)){if(n===void 0){delete this.attributes[t];continue}this.attributes[t]=n}if(Y.sessionId in e&&this.recordAssociation(this.sessionHistory,[Y.sessionId,Y.sessionHasReplay,$],t,typeof this.attributes[Y.sessionId]==`string`),Y.actionId in e){let e=this.attributes[Y.actionId];this.recordAssociation(this.actionHistory,[Y.actionId],t,Array.isArray(e)?e.length>0:typeof e==`string`)}}),I(this,`setUser`,e=>{if(this.user=K(K({},this.user),e),`id`in e){if(e.id===void 0){delete this.attributes[Y.userId];return}this.attributes[Y.userId]=e.id}}),I(this,`setView`,(e,t=(t=>(t=e.startedAt)==null?Date.now():t)())=>{var n;this.viewAttributeKeys.forEach(e=>delete this.attributes[e]),this.viewAttributeKeys.clear();let r={};for(let[t,i]of Object.entries((n=e.attributes)==null?{}:n))i===void 0||qm.has(t)||(r[t]=i,this.attributes[t]=i,this.viewAttributeKeys.add(t),this.viewScopedAttributeKeys.add(t));this.view=K(K({},e),{},{attributes:r}),this.setOptionalAttribute(Y.viewId,e.id),this.setOptionalAttribute(Y.viewUrl,e.url),this.setOptionalAttribute(Y.viewUrlPathGroup,e.urlPathGroup),this.setOptionalAttribute(Y.viewLoadingType,e.loadingType),this.setOptionalAttribute(Y.viewName,e.name),[Y.viewId,Y.viewUrl,Y.viewUrlPathGroup,Y.viewLoadingType,Y.viewName].forEach(e=>this.viewScopedAttributeKeys.add(e)),this.recordAssociation(this.viewHistory,this.viewScopedAttributeKeys,t,typeof e.id==`string`&&e.id.length>0),this.viewChangeListeners.forEach(e=>e(this.getView()))}),this.setAttributes(e),t&&this.setUser(t)}};L(),q();var Ym=e=>({url:e.endpoint,headers:e.headers,concurrencyLimit:e.concurrencyLimit,timeoutMillis:e.timeoutMillis}),Xm=`bk-rum`,Zm=class{constructor(e){this.isSampled=e}shouldSample(){return{decision:this.isSampled()?J.RECORD_AND_SAMPLED:J.NOT_RECORD}}toString(){return`RumSessionSampler`}},Qm,$m=()=>{if(Qm)Qm.users+=1;else{let e=new ft().enable(),t=N.setGlobalContextManager(e);t||e.disable(),Qm={contextManager:t?e:void 0,ownsContext:t,ownsPropagator:nt.setGlobalPropagator(new Wr),users:1}}let e=!1;return()=>{e||!Qm||(e=!0,--Qm.users,!(Qm.users>0)&&(Qm.ownsContext&&N.disable(),Qm.ownsPropagator&&nt.disable(),Qm=void 0))}},eh=(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,th=e=>[Gd(e.tracking.request)],nh=e=>[dp(e.session),...ah(e.tracking.device,!0,df),Tu(),Yf(),Md(rh(e.tracking.resource,!0))],rh=(e,t)=>e===void 0?t:e!==!1,ih=e=>typeof e==`object`&&e?e:void 0,ah=(e,t,n)=>rh(e,t)?[n(ih(e))]:[],oh=e=>[...ah(e.error,!0,xf),...ah(e.webVitals,!0,xm),...ah(e.blankScreen,!0,Ju),...ah(e.action,!0,Cu),...ah(e.websocket,!1,Om),...ah(e.longTask,!1,kf),...ah(e.cspViolation,!1,Qd)],sh=class{assertBeforeStart(e){if(this.phase!==`idle`)throw Error(`[bk-ot] ${e}() must be called before start(); set autoStart: false before registration.`)}createPluginContext(){return{applyRedact:this.applyRedact,config:this.config,emitLog:this.emitLog,flush:this.flush,getRuntimeAttributes:this.getRuntimeAttributes,getRuntimeAttributesAt:this.getRuntimeAttributesAt,isSampled:this.isSampled,isSessionActive:this.isSessionActive,isViewActive:this.isViewActive,logger:this.logger,meter:this.meter,notifySessionLifecycle:this.notifySessionLifecycle,notifyActivity:this.activityObserver.notify,onActivity:this.activityObserver.subscribe,onSessionLifecycle:this.onSessionLifecycle,onViewCommand:this.runtimeContext.onViewCommand,onViewChange:this.runtimeContext.onViewChange,registerInstrumentations:this.registerInstrumentations,setRuntimeAttributes:this.setRuntimeAttributes,setUser:this.setUser,setView:this.runtimeContext.setView,startSpan:this.startSpan,tracer:this.tracer}}createPluginManager(){var e;return new Km([...nh(this.config),...th(this.config),...oh(this.config.tracking),...(e=this.config.extensions.plugins)==null?[]:e])}constructor(e){var t=this;I(this,`activityObserver`,new km),I(this,`flushProviders`,W(function*(){yield t.tracerProvider.forceFlush(),yield t.meterProvider.forceFlush(),yield t.loggerProvider.forceFlush()})),I(this,`loggerProvider`,void 0),I(this,`meterProvider`,void 0),I(this,`phase`,`idle`),I(this,`pluginManager`,void 0),I(this,`registeredInstrumentations`,void 0),I(this,`releaseOtelGlobals`,void 0),I(this,`runtimeContext`,void 0),I(this,`sampled`,!1),I(this,`startCollection`,W(function*(){if(t.pluginManager||!t.config.enabled||t.config.trackingConsent!==`granted`)return;t.config.transport.traces!==!1&&(t.releaseOtelGlobals=$m());let e=t.createPluginManager();t.pluginManager=e;try{var n;yield e.start(t.createPluginContext()),t.registerInstrumentations((n=t.config.extensions.instrumentations)==null?[]:n)}catch(n){var r,i,a;for(yield e.shutdown(),t.pluginManager=void 0;t.registeredInstrumentations.length;)(r=t.registeredInstrumentations.pop())==null||(i=r.disable)==null||i.call(r);throw(a=t.releaseOtelGlobals)==null||a.call(t),t.releaseOtelGlobals=void 0,n}})),I(this,`stopCollection`,function(){var e=W(function*(e){var n,r,i;let a=t.pluginManager;if(a){for(yield a.shutdown(),t.pluginManager=void 0;t.registeredInstrumentations.length;)(n=t.registeredInstrumentations.pop())==null||(r=n.disable)==null||r.call(n);t.setRuntimeAttributes({[Y.sessionHasReplay]:void 0,[Y.sessionId]:void 0}),e&&(yield t.flushProviders()),(i=t.releaseOtelGlobals)==null||i.call(t),t.releaseOtelGlobals=void 0}});return function(t){return e.apply(this,arguments)}}()),I(this,`teardownCallbacks`,[]),I(this,`tracerProvider`,void 0),I(this,`applyRedact`,e=>this.config.hooks.redactAttributes(e)),I(this,`config`,void 0),I(this,`emitLog`,e=>{var t;let n=e.timestamp?br(_r(e.timestamp)):void 0,r=K(K({},e),{},{attributes:this.applyRedact(K(K({},n===void 0?this.getRuntimeAttributes():this.getRuntimeAttributesAt(n)),(t=e.attributes)==null?{}:t))});this.logger.emit(r)}),I(this,`flush`,W(function*(){var e;yield(e=t.pluginManager)==null?void 0:e.flush(),yield t.flushProviders()})),I(this,`getRuntimeAttributes`,()=>this.runtimeContext.getAttributes()),I(this,`getRuntimeAttributesAt`,e=>this.runtimeContext.getAttributesAt(e)),I(this,`isSampled`,()=>this.sampled),I(this,`isSessionActive`,()=>this.runtimeContext.isSessionActive()),I(this,`isViewActive`,()=>this.runtimeContext.isViewActive()),I(this,`logger`,void 0),I(this,`meter`,void 0),I(this,`notifySessionLifecycle`,e=>{this.runtimeContext.notifySessionLifecycle(e)}),I(this,`onSessionLifecycle`,e=>this.runtimeContext.onSessionLifecycle(e)),I(this,`registerInstrumentations`,e=>{e.length&&(Nc({instrumentations:e,meterProvider:this.meterProvider,tracerProvider:this.tracerProvider}),this.registeredInstrumentations.push(...e))}),I(this,`reportAction`,({attributes:e={},name:t})=>{if(!this.isSampled())return;let n=Bl(`action`);this.startSpan(`action.custom`,K(K(K(K({},this.config.hooks.getPageAttributes()),e),Q({errorType:`none`,eventLabel:`用户操作`,spanSubtype:`custom`,spanType:Z.action,targetLabel:t,traceScene:`user_action`})),{},{[Y.actionId]:n,[Y.actionName]:t,[Y.actionType]:`custom`})).end()}),I(this,`reportCustomEvent`,({attributes:e={},error:t,name:n})=>{if(!this.isSampled()){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}`,K(K(K(K(K({},this.config.hooks.getPageAttributes()),this.config.hooks.getCustomAttributes()),Q({errorType:t?`custom`:`none`,eventLabel:`自定义事件`,result:t?X.error:X.success,spanSubtype:n,spanType:Z.custom,targetLabel:n})),e),{},{"rum.custom.name":n}));t&&(i.recordException(t),i.setStatus({code:We.ERROR,message:t.message})),i.end()}),I(this,`setRuntimeAttributes`,(e,t)=>{let n=K({},e);if(Y.sessionId in e){let t=e[Y.sessionId];this.sampled=this.config.enabled&&typeof t==`string`&&t.length>0?ku(this.config,t):!1,n[$]=this.sampled}this.runtimeContext.setAttributes(n,t)}),I(this,`setTrackingConsent`,function(){var e=W(function*(e){t.config.trackingConsent!==e&&(t.config.trackingConsent=e,t.phase===`started`&&(e===`granted`?yield t.startCollection():yield t.stopCollection(!0)))});return function(t){return e.apply(this,arguments)}}()),I(this,`setUser`,e=>{this.runtimeContext.setUser(e)}),I(this,`setViewLoadingTime`,()=>{this.isSampled()&&this.runtimeContext.dispatchViewCommand({time:Date.now(),type:`set_loading_time`})}),I(this,`setViewName`,e=>{this.isSampled()&&this.runtimeContext.dispatchViewCommand({name:e,type:`set_name`})}),I(this,`shutdown`,W(function*(){if(t.phase!==`stopped`){for(yield t.stopCollection(!1),yield t.flushProviders();t.teardownCallbacks.length;){var e;(e=t.teardownCallbacks.pop())==null||e()}yield t.tracerProvider.shutdown(),yield t.meterProvider.shutdown(),yield t.loggerProvider.shutdown(),t.phase=`stopped`}})),I(this,`start`,W(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`;try{if(yield t.startCollection(),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(n){for(;t.teardownCallbacks.length;){var e;(e=t.teardownCallbacks.pop())==null||e()}throw yield t.stopCollection(!1),t.phase=`idle`,n}t.phase=`started`}})),I(this,`startSpan`,(e,t={},n)=>{var r,i;let a=(r=n==null?void 0:n.contextTime)==null?typeof(n==null?void 0:n.startTime)==`number`?n.startTime:void 0:r,o=a===void 0?this.getRuntimeAttributes():this.runtimeContext.getAttributesAt(a);return this.tracer.startSpan(e,{kind:(i=n==null?void 0:n.kind)==null?Ue.INTERNAL:i,startTime:n==null?void 0:n.startTime,attributes:this.applyRedact(K(K({},o),t))})}),I(this,`startView`,(e={})=>{this.isSampled()&&this.runtimeContext.dispatchViewCommand({options:e,type:`start`})}),I(this,`tracer`,void 0),I(this,`use`,e=>{var t;return this.assertBeforeStart(`use`),(t=this.config.extensions.plugins)==null||t.push(e),this}),I(this,`useInstrumentation`,e=>{var t;return this.assertBeforeStart(`useInstrumentation`),this.config.enabled&&((t=this.config.extensions.instrumentations)==null||t.push(e)),this}),this.config=Wm(e),this.runtimeContext=new Jm({[$]:!1},this.config.user);let n=io(this.config.resourceAttributes),r=(()=>{if(this.config.transport.traces===!1)return[];let e=eh(new Ac(Ym(this.config.transport.traces)),`traces`,this.config.debug);return[new nd(this.config.spanProcessor===`simple`?new Fl(e):new ml(e,this.config.spanBatch),this.config,()=>this.applyRedact(K(K({},this.runtimeContext.getAttributes()),this.config.hooks.getPageAttributes())))]})(),i=this.config.transport.metrics===!1?[]:[new $a({exporter:new id(eh(new kc(K(K({},Ym(this.config.transport.metrics)),{},{temporalityPreference:bc.DELTA})),`metrics`,this.config.debug)),exportIntervalMillis:this.config.metricIntervalMillis})],a=this.config.transport.logs===!1?[]:[new td(new Qc(eh(new yc(Ym(this.config.transport.logs)),`logs`,this.config.debug)),this.config)];this.tracerProvider=new zl({resource:n,sampler:new Zm(()=>this.config.transport.traces!==!1&&this.isSampled()),spanProcessors:r}),this.meterProvider=new cs({resource:n,readers:i}),this.loggerProvider=new qc({resource:n,processors:a}),this.tracer=this.tracerProvider.getTracer(Xm),this.meter=this.meterProvider.getMeter(Xm),this.logger=this.loggerProvider.getLogger(Xm),this.registeredInstrumentations=[],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:sh}),sh})();
|
|
11
|
+
`,zo(t,e))}return n}};L();var Vo=class{constructor(e){I(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)}};L();var Ho=class{constructor(e,t){I(this,`_buffer`,new ko),I(this,`_instrumentName`,void 0),I(this,`_valueType`,void 0),this._instrumentName=e,this._valueType=t}observe(e,t={}){if(typeof e!=`number`){P.warn(`non-number value provided to metric ${this._instrumentName}: ${e}`);return}this._valueType===pe.INT&&!Number.isInteger(e)&&(P.warn(`INT value type cannot accept a floating-point value for ${this._instrumentName}, ignoring the fractional digits.`),e=Math.trunc(e),!Number.isInteger(e))||this._buffer.set(t,e)}},Uo=class{constructor(){I(this,`_buffer`,new Map)}observe(e,t,n={}){if(!To(e))return;let r=this._buffer.get(e);if(r==null&&(r=new ko,this._buffer.set(e,r)),typeof t!=`number`){P.warn(`non-number value provided to metric ${e._descriptor.name}: ${t}`);return}e._descriptor.valueType===pe.INT&&!Number.isInteger(t)&&(P.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)}};L();var Wo=class{constructor(){I(this,`_callbacks`,[]),I(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(To));if(n.size===0){P.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(To)),r=this._findBatchCallback(e,n);r<0||this._batchCallbacks.splice(r,1)}observe(e,t){var n=this;return W(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=W(function*({callback:n,instrument:r}){let i=new Ho(r._descriptor.name,r._descriptor.valueType),a=Promise.resolve(n(i));t!=null&&(a=Zi(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=W(function*({callback:n,instruments:r}){let i=new Uo,a=Promise.resolve(n(i));t!=null&&(a=Zi(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&&Qi(n.instruments,t))}};L();var Go=class extends Do{constructor(e,t,n,r,i){super(e),I(this,`_aggregationCardinalityLimit`,void 0),I(this,`_deltaMetricStorage`,void 0),I(this,`_temporalMetricStorage`,void 0),I(this,`_attributesProcessor`,void 0),this._aggregationCardinalityLimit=i,this._deltaMetricStorage=new Ao(t,this._aggregationCardinalityLimit),this._temporalMetricStorage=new jo(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)}};L();var Ko=class{process(e,t){return e}},qo=class{constructor(e){I(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 Jo(){return Xo}function Yo(e){return new qo(e)}var Xo=new Ko;L();var Zo=class{constructor(e,t){I(this,`metricStorageRegistry`,new Bo),I(this,`observableRegistry`,new Wo),I(this,`meter`,void 0),I(this,`_meterProviderSharedState`,void 0),I(this,`_instrumentationScope`,void 0),this.meter=new Eo(this),this._meterProviderSharedState=e,this._instrumentationScope=t}registerMetricStorage(e){let t=this._registerMetricStorage(e,Go);return t.length===1?t[0]:new Vo(t)}registerAsyncMetricStorage(e){return this._registerMetricStorage(e,No)}collect(e,t,n){var r=this;return W(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=fo(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,Jo(),[n],o);return this.metricStorageRegistry.registerForCollector(n,s),s});n=n.concat(r)}return n}};L();var Qo=class{constructor(e){I(this,`viewRegistry`,new lo),I(this,`metricCollectors`,[]),I(this,`meterSharedStates`,new Map),I(this,`resource`,void 0),this.resource=e}getMeterSharedState(e){let t=Yi(e),n=this.meterSharedStates.get(t);return n==null&&(n=new Zo(this,e),this.meterSharedStates.set(t,n)),n}selectAggregations(e){let t=[];for(let n of this.metricCollectors)t.push([n,Ja(n.selectAggregation(e))]);return t}};L();var $o=class{constructor(e,t){I(this,`_sharedState`,void 0),I(this,`_metricReader`,void 0),this._sharedState=e,this._metricReader=t}collect(e){var t=this;return W(function*(){let n=hr(Date.now()),r=[],i=[],a=Array.from(t._sharedState.meterSharedStates.values()).map(function(){var a=W(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 W(function*(){yield t._metricReader.forceFlush(e)})()}shutdown(e){var t=this;return W(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}};L();var es=/[\^$\\.+?()[\]{}|]/g,ts=class e{constructor(t){I(this,`_matchAll`,void 0),I(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(es,`\\$&`).replace(`*`,`.*`)}$`}static hasWildcard(e){return e.includes(`*`)}},ns=class{constructor(e){I(this,`_matchAll`,void 0),I(this,`_pattern`,void 0),this._matchAll=e===void 0,this._pattern=e}match(e){return!!(this._matchAll||e===this._pattern)}};L();var rs=class{constructor(e){var t;I(this,`_nameFilter`,void 0),I(this,`_type`,void 0),I(this,`_unitFilter`,void 0),this._nameFilter=new ts((t=e==null?void 0:e.name)==null?`*`:t),this._type=e==null?void 0:e.type,this._unitFilter=new ns(e==null?void 0:e.unit)}getType(){return this._type}getNameFilter(){return this._nameFilter}getUnitFilter(){return this._unitFilter}};L();var is=class{constructor(e){I(this,`_nameFilter`,void 0),I(this,`_versionFilter`,void 0),I(this,`_schemaUrlFilter`,void 0),this._nameFilter=new ns(e==null?void 0:e.name),this._versionFilter=new ns(e==null?void 0:e.version),this._schemaUrlFilter=new ns(e==null?void 0:e.schemaUrl)}getNameFilter(){return this._nameFilter}getVersionFilter(){return this._versionFilter}getSchemaUrlFilter(){return this._schemaUrlFilter}};L();function as(e){return e.instrumentName==null&&e.instrumentType==null&&e.instrumentUnit==null&&e.meterName==null&&e.meterVersion==null&&e.meterSchemaUrl==null}function os(e){if(as(e))throw Error(`Cannot create view with no selector arguments supplied`);if(e.name!=null&&((e==null?void 0:e.instrumentName)==null||ts.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 ss=class{constructor(e){var t;I(this,`name`,void 0),I(this,`description`,void 0),I(this,`aggregation`,void 0),I(this,`attributesProcessor`,void 0),I(this,`instrumentSelector`,void 0),I(this,`meterSelector`,void 0),I(this,`aggregationCardinalityLimit`,void 0),os(e),e.attributesProcessors==null?this.attributesProcessor=Jo():this.attributesProcessor=Yo(e.attributesProcessors),this.name=e.name,this.description=e.description,this.aggregation=Ja((t=e.aggregation)==null?{type:qa.DEFAULT}:t),this.instrumentSelector=new rs({name:e.instrumentName,type:e.instrumentType,unit:e.instrumentUnit}),this.meterSelector=new is({name:e.meterName,version:e.meterVersion,schemaUrl:e.meterSchemaUrl}),this.aggregationCardinalityLimit=e.aggregationCardinalityLimit}};L();var cs=class{constructor(e){var t;if(I(this,`_sharedState`,void 0),I(this,`_shutdown`,!1),this._sharedState=new Qo((t=e==null?void 0:e.resource)==null?ao():t),(e==null?void 0:e.views)!=null&&e.views.length>0)for(let t of e.views)this._sharedState.viewRegistry.addView(new ss(t));if((e==null?void 0:e.readers)!=null&&e.readers.length>0)for(let t of e.readers){let e=new $o(this._sharedState,t);t.setMetricProducer(e),this._sharedState.metricCollectors.push(e)}}getMeter(e,t=``,n={}){return this._shutdown?(P.warn(`A shutdown MeterProvider cannot provide a Meter`),fe()):this._sharedState.getMeterSharedState({name:e,version:t,schemaUrl:n.schemaUrl}).meter}shutdown(e){var t=this;return W(function*(){if(t._shutdown){P.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 W(function*(){if(t._shutdown){P.warn(`invalid attempt to force flush after MeterProvider shutdown`);return}yield Promise.all(t._sharedState.metricCollectors.map(t=>t.forceFlush(e)))})()}},ls;(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`})(ls||(ls={}));function us(e,t){let n={attributes:fs(e.attributes,t),droppedAttributesCount:0},r=e.schemaUrl;return r&&r!==``&&(n.schemaUrl=r),n}function ds(e){return{name:e.name,version:e.version}}function fs(e,t){return Object.keys(e).map(n=>ps(n,e[n],t))}function ps(e,t,n){return{key:e,value:ms(t,n)}}function ms(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]=ms(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:ms(e[n[i]],t)};return{kvlistValue:{values:r}}}return{}}function hs(e,t){let n=us(e.resource,t);return{resource:n,schemaUrl:n.schemaUrl,scopeMetrics:gs(e.scopeMetrics,t)}}function gs(e,t){return Array.from(e.map(e=>({scope:ds(e.scope),metrics:e.metrics.map(e=>_s(e,t)),schemaUrl:e.scope.schemaUrl})))}function _s(e,t){let n={name:e.descriptor.name,description:e.descriptor.description,unit:e.descriptor.unit},r=Ss(e.aggregationTemporality);switch(e.dataPointType){case qi.SUM:n.sum={aggregationTemporality:r,isMonotonic:e.isMonotonic,dataPoints:ys(e,t)};break;case qi.GAUGE:n.gauge={dataPoints:ys(e,t)};break;case qi.HISTOGRAM:n.histogram={aggregationTemporality:r,dataPoints:bs(e,t)};break;case qi.EXPONENTIAL_HISTOGRAM:n.exponentialHistogram={aggregationTemporality:r,dataPoints:xs(e,t)};break}return n}function vs(e,t,n){let r={attributes:fs(e.attributes,n),startTimeUnixNano:n.encodeHrTime(e.startTime),timeUnixNano:n.encodeHrTime(e.endTime)};switch(t){case pe.INT:r.asInt=e.value;break;case pe.DOUBLE:r.asDouble=e.value;break}return r}function ys(e,t){return e.dataPoints.map(n=>vs(n,e.descriptor.valueType,t))}function bs(e,t){return e.dataPoints.map(e=>{let n=e.value;return{attributes:fs(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 xs(e,t){return e.dataPoints.map(e=>{let n=e.value;return{attributes:fs(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 Ss(e){switch(e){case Ki.DELTA:return ls.AGGREGATION_TEMPORALITY_DELTA;case Ki.CUMULATIVE:return ls.AGGREGATION_TEMPORALITY_CUMULATIVE}}function Cs(e,t){return{resourceMetrics:e.map(e=>hs(e,t))}}function ws(e){let t=BigInt(1e9);return BigInt(Math.trunc(e[0]))*t+BigInt(Math.trunc(e[1]))}function Ts(e){return ws(e).toString()}var Es=typeof BigInt<`u`?Ts:yr;function Ds(e){return e}var Os={encodeHrTime:Es,encodeSpanContext:Ds,encodeOptionalSpanContext:Ds,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 ks(e,t){return{resourceLogs:js(e,t)}}function As(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 js(e,t){let n=As(e);return Array.from(n,([e,n])=>{let r=us(e,t);return{resource:r,scopeLogs:Array.from(n,([,e])=>({scope:ds(e[0].instrumentationScope),logRecords:e.map(e=>Ms(e,t)),schemaUrl:e[0].instrumentationScope.schemaUrl})),schemaUrl:r.schemaUrl}})}function Ms(e,t){var n,r,i;return{timeUnixNano:t.encodeHrTime(e.hrTime),observedTimeUnixNano:t.encodeHrTime(e.hrTimeObserved),severityNumber:Ns(e.severityNumber),severityText:e.severityText,body:ms(e.body,t),eventName:e.eventName,attributes:Ps(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 Ns(e){return e}function Ps(e,t){return Object.keys(e).map(n=>ps(n,e[n],t))}var Fs={serializeRequest:e=>{let t=ks(e,Os);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 P.warn(`Failed to parse logs export response: ${e.message}. Returning empty response`),{}}}},Is={serializeRequest:e=>{let t=Cs([e],Os);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 P.warn(`Failed to parse metrics export response: ${e.message}. Returning empty response`),{}}}},Ls=256,Rs=512;function zs(e,t){let n=e&255|Ls;return t&&(n|=Rs),n}function Bs(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:fs(e.attributes,t),droppedAttributesCount:e.droppedAttributesCount,events:e.events.map(e=>Hs(e,t)),droppedEventsCount:e.droppedEventsCount,status:{code:s.code,message:s.message},links:e.links.map(e=>Vs(e,t)),droppedLinksCount:e.droppedLinksCount,flags:zs(o.traceFlags,(a=e.parentSpanContext)==null?void 0:a.isRemote)}}function Vs(e,t){var n;return{attributes:e.attributes?fs(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:zs(e.context.traceFlags,e.context.isRemote)}}function Hs(e,t){return{attributes:e.attributes?fs(e.attributes,t):[],name:e.name,timeUnixNano:t.encodeHrTime(e.time),droppedAttributesCount:e.droppedAttributesCount||0}}function Us(e,t){return{resourceSpans:Gs(e,t)}}function Ws(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 Gs(e,t){let n=Ws(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=>Bs(e,t));o.push({scope:ds(e[0].instrumentationScope),spans:n,schemaUrl:e[0].instrumentationScope.schemaUrl})}c=s.next()}let l=us(e,t),u={resource:l,scopeSpans:o,schemaUrl:l.schemaUrl};r.push(u),a=i.next()}return r}var Ks={serializeRequest:e=>{let t=Us(e,Os);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 P.warn(`Failed to parse trace export response: ${e.message}. Returning empty response`),{}}}};L();var qs=5,Js=1e3,Ys=5e3,Xs=1.5,Zs=.2;function Qs(){return 2*Zs*Math.random()-Zs}var $s=class{constructor(e){I(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 W(function*(){let r=qs,i=Js,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+Qs()),Ys),0);i*=Xs;let c=(s=o.retryInMillis)==null?t:s,l=a-Date.now();if(c>l)return P.info(`Export retry time ${Math.round(c)}ms exceeds remaining timeout ${Math.round(l)}ms, not retrying further.`),o;P.verbose(`Scheduling export retry in ${Math.round(c)}ms`),o=yield n.retry(e,l,c)}return o.status===`success`?P.verbose(`Export succeeded after ${qs-r} retry attempts.`):o.status===`retryable`?P.info(`Export failed after maximum retry attempts (${qs}).`):P.info(`Export failed with non-retryable error: ${o.error}`),o})()}shutdown(){return this._transport.shutdown()}};function ec(e){return new $s(e.transport)}function tc(e){return e===429||e===502||e===503||e===504}function nc(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}L();var rc=60*1024,ic=9,ac=0,oc=0,sc=class{constructor(e){I(this,`_parameters`,void 0),this._parameters=e}send(e,t){var n=this;return W(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=ac+o>rc,c=!s&&!(oc>=ic);if(c)ac+=o,oc++;else{let e=s?`size limit`:`count limit`;P.debug(`keepalive disabled: ${(o/1024).toFixed(1)}KB payload, ${oc} 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?(P.debug(`export response success (status: ${i.status})`),{status:`success`}):tc(i.status)?(P.warn(`export response retryable (status: ${i.status})`),{status:`retryable`,retryInMillis:nc(i.headers.get(`Retry-After`))}):(P.error(`export response failure (status: ${i.status})`),{status:`failure`,error:Error(`Fetch request failed with non-retryable status ${i.status}`)})}catch(e){return lc(e)?(P.warn(`export request retryable (network error: ${e})`),{status:`retryable`,error:Error(`Fetch request encountered a network error`,{cause:e})}):(P.error(`export request failure (error: ${e})`),{status:`failure`,error:Error(`Fetch request errored`,{cause:e})})}finally{clearTimeout(i),c&&(ac-=o,oc--)}})()}shutdown(){}};function cc(e){return new sc(e)}function lc(e){return e instanceof TypeError&&!e.cause}function uc(e,t){return Fi(e,t,ec({transport:cc(e)}))}function dc(e){let t={};return Object.entries(e==null?{}:e).forEach(([e,n])=>{n===void 0?P.warn(`Header "${e}" has invalid value (${n}) and will be ignored`):t[e]=String(n)}),t}q();function fc(e,t,n){return W(function*(){let r=K({},yield n()),i={};return t!=null&&Object.assign(i,yield t()),e!=null&&Object.assign(i,dc(yield e())),Object.assign(i,r)})}function pc(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 mc(e,t,n){var r,i;return K(K({},Di(e,t,n)),{},{headers:fc(e.headers,t.headers,n.headers),url:(r=(i=pc(e.url))==null?t.url:i)==null?n.url:r})}function hc(e,t){return K(K({},Oi()),{},{headers:function(){var t=W(function*(){return e});return function(){return t.apply(this,arguments)}}(),url:`http://localhost:4318/`+t})}function gc(e){return typeof e.headers==`function`?e.headers:Ei(e.headers)}function _c(e,t,n){return mc({url:e.url,timeoutMillis:e.timeoutMillis,headers:gc(e),concurrencyLimit:e.concurrencyLimit},{},hc(n,t))}function vc(e,t,n,r){return uc(_c(e,n,r),t)}var yc=class extends Si{constructor(e={}){super(vc(e,Fs,`v1/logs`,{"Content-Type":`application/json`}))}},bc;(function(e){e[e.DELTA=0]=`DELTA`,e[e.CUMULATIVE=1]=`CUMULATIVE`,e[e.LOWMEMORY=2]=`LOWMEMORY`})(bc||(bc={})),L();var xc=()=>Ki.CUMULATIVE,Sc=e=>{switch(e){case G.COUNTER:case G.OBSERVABLE_COUNTER:case G.GAUGE:case G.HISTOGRAM:case G.OBSERVABLE_GAUGE:return Ki.DELTA;case G.UP_DOWN_COUNTER:case G.OBSERVABLE_UP_DOWN_COUNTER:return Ki.CUMULATIVE}},Cc=e=>{switch(e){case G.COUNTER:case G.HISTOGRAM:return Ki.DELTA;case G.GAUGE:case G.UP_DOWN_COUNTER:case G.OBSERVABLE_UP_DOWN_COUNTER:case G.OBSERVABLE_COUNTER:case G.OBSERVABLE_GAUGE:return Ki.CUMULATIVE}};function wc(){var e;let t=((e=void 0)==null?`cumulative`:e).toLowerCase();return t===`cumulative`?xc:t===`delta`?Sc:t===`lowmemory`?Cc:(P.warn(`OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE is set to '${t}', but only 'cumulative' and 'delta' are allowed. Using default ('cumulative') instead.`),xc)}function Tc(e){return e==null?wc():e===bc.DELTA?Sc:e===bc.LOWMEMORY?Cc:xc}var Ec=Object.freeze({type:qa.DEFAULT});function Dc(e){var t;return(t=e==null?void 0:e.aggregationPreference)==null?(()=>Ec):t}var Oc=class extends Si{constructor(e,t){super(e),I(this,`_aggregationTemporalitySelector`,void 0),I(this,`_aggregationSelector`,void 0),this._aggregationSelector=Dc(t),this._aggregationTemporalitySelector=Tc(t==null?void 0:t.temporalityPreference)}selectAggregation(e){return this._aggregationSelector(e)}selectAggregationTemporality(e){return this._aggregationTemporalitySelector(e)}},kc=class extends Oc{constructor(e){super(vc(e==null?{}:e,Is,`v1/metrics`,{"Content-Type":`application/json`}),e)}},Ac=class extends Si{constructor(e={}){super(vc(e,Ks,`v1/traces`,{"Content-Type":`application/json`}))}};function jc(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 Mc(e){e.forEach(e=>e.disable())}function Nc(e){var t,n;let r=e.tracerProvider||F.getTracerProvider(),i=e.meterProvider||qe.getMeterProvider(),a=e.loggerProvider||Gi.getLoggerProvider(),o=(t=(n=e.instrumentations)==null?void 0:n.flat())==null?[]:t;return jc(o,r,i,a),()=>{Mc(o)}}function Pc(e){return Fc(e,new WeakSet)}function Fc(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=>Fc(e,t));let n=e;return n.constructor!==Object&&n.constructor!==void 0?!1:Object.values(n).every(e=>Fc(e,t))}return!1}L();var Ic=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){I(this,`hrTime`,void 0),I(this,`hrTimeObserved`,void 0),I(this,`spanContext`,void 0),I(this,`resource`,void 0),I(this,`instrumentationScope`,void 0),I(this,`attributes`,{}),I(this,`_severityText`,void 0),I(this,`_severityNumber`,void 0),I(this,`_body`,void 0),I(this,`_eventName`,void 0),I(this,`_attributesCount`,0),I(this,`_droppedAttributesCount`,0),I(this,`_isReadonly`,!1),I(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=_r(r==null?f:r),this.hrTimeObserved=_r(i==null?f:i),d){let e=F.getSpanContext(d);e&&Ne(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 P.warn(`Invalid attribute key: ${e}`),this;if(!Pc(t))return P.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&&P.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 P.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(tr,String(e)),t=!0;else if(e&&typeof e==`object`){let n=e;n.code?(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(rr,n.code.toString()),t=!0):n.name&&(Object.hasOwn(this.attributes,`exception.type`)||this.setAttribute(rr,n.name),t=!0),n.message&&(Object.hasOwn(this.attributes,`exception.message`)||this.setAttribute(tr,n.message),t=!0),n.stack&&(Object.hasOwn(this.attributes,`exception.stacktrace`)||this.setAttribute(nr,n.stack),t=!0)}t||P.warn(`Failed to record an exception ${e}`)}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_isLogRecordReadonly(){return this._isReadonly&&P.warn(`Can not execute the operation on emitted log record`),this._isReadonly}};L(),q();var Lc=class{constructor(e,t){I(this,`instrumentationScope`,void 0),I(this,`_sharedState`,void 0),I(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||N.active(),i=(t=e.severityNumber)==null?Ii.UNSPECIFIED:t;if(i!==Ii.UNSPECIFIED&&i<n.minimumSeverity)return;if(n.traceBased){let e=F.getSpanContext(r);if(e&&Ne(e)&&(e.traceFlags&M.SAMPLED)!==M.SAMPLED)return}let a=new Ic(this._sharedState,this.instrumentationScope,K({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!==Ii.UNSPECIFIED&&n<t.minimumSeverity)return!1;let r=(e==null?void 0:e.context)||N.active();if(t.traceBased){let e=F.getSpanContext(r);if(e&&Ne(e)&&(e.traceFlags&M.SAMPLED)!==M.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}},Rc=class{forceFlush(){return Promise.resolve()}onEmit(e,t){}shutdown(){return Promise.resolve()}enabled(e){return!1}};L();var zc=class{constructor(e,t){I(this,`processors`,void 0),I(this,`forceFlushTimeoutMillis`,void 0),this.processors=e,this.forceFlushTimeoutMillis=t}forceFlush(){var e=this;return W(function*(){let t=e.forceFlushTimeoutMillis;yield Promise.all(e.processors.map(e=>_i(e.forceFlush(),t)))})()}onEmit(e,t){this.processors.forEach(n=>n.onEmit(e,t))}shutdown(){var e=this;return W(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 Bc(e){return`${e.name}@${e.version||``}:${e.schemaUrl||``}`}var Vc=`otel.sdk.log.created`;L();var Hc=class{constructor(e){I(this,`createdLogs`,void 0),this.createdLogs=e.createCounter(Vc,{unit:`{log_record}`,description:`The number of logs submitted to enabled SDK Loggers.`})}emitLog(){this.createdLogs.add(1)}},Uc=`0.217.0`;q(),L();var Wc={disabled:!1,minimumSeverity:Ii.UNSPECIFIED,traceBased:!1},Gc=()=>K({},Wc),Kc=class{constructor(e,t,n,r,i,a){I(this,`loggers`,new Map),I(this,`activeProcessor`,void 0),I(this,`registeredLogRecordProcessors`,[]),I(this,`resource`,void 0),I(this,`forceFlushTimeoutMillis`,void 0),I(this,`logRecordLimits`,void 0),I(this,`processors`,void 0),I(this,`loggerMetrics`,void 0),I(this,`_loggerConfigurator`,void 0),I(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 zc(this.registeredLogRecordProcessors,this.forceFlushTimeoutMillis)):this.activeProcessor=new Rc,this._loggerConfigurator=i==null?Gc:i;let o=a?a.getMeter(`@opentelemetry/sdk-logs`,Uc):fe();this.loggerMetrics=new Hc(o)}getLoggerConfig(e){let t=Bc(e),n=this._loggerConfigs.get(t);return n||(n=this._loggerConfigurator(e),this._loggerConfigs.set(t,n),n)}};L();var qc=class{constructor(e={}){var t,n,r,i,a,o,s,c;I(this,`_shutdownOnce`,void 0),I(this,`_sharedState`,void 0);let l={resource:(t=e.resource)==null?ao():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?Gc:s,processors:(c=e.processors)==null?[]:c,meterProvider:e.meterProvider};this._sharedState=new Kc(l.resource,l.forceFlushTimeoutMillis,l.logRecordLimits,l.processors,l.loggerConfigurator,l.meterProvider),this._shutdownOnce=new yi(this._shutdown,this)}getLogger(e,t,n){if(this._shutdownOnce.isCalled)return P.warn(`A shutdown LoggerProvider cannot provide a Logger`),Ri;e||P.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 Lc({name:r,version:t,schemaUrl:n==null?void 0:n.schemaUrl},this._sharedState)),this._sharedState.loggers.get(i)}forceFlush(){return this._shutdownOnce.isCalled?(P.warn(`invalid attempt to force flush after LoggerProvider shutdown`),this._shutdownOnce.promise):this._sharedState.activeProcessor.forceFlush()}shutdown(){return this._shutdownOnce.isCalled?(P.warn(`shutdown may only be called once per LoggerProvider`),this._shutdownOnce.promise):this._shutdownOnce.call()}_shutdown(){return this._sharedState.activeProcessor.shutdown()}};L();function Jc(e){return Yc.apply(this,arguments)}function Yc(){return Yc=W(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))}),Yc.apply(this,arguments)}var Xc=class{constructor(e,t,n){I(this,`_exportCompleted`,void 0),I(this,`_exportScheduledPromise`,void 0),I(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 W(function*(){try{yield Jc(t),yield N.with(In(N.active()),W(function*(){return r._exportWithTimeout(e,t,n)}))}catch(e){$n(e),r._exportScheduledResolve()}})()}_exportWithTimeout(e,t,n){var r=this;return W(function*(){return new Promise((i,a)=>{let o=setTimeout(()=>{a(Error(`Timeout`))},n);e.export(t,e=>{if(clearTimeout(o),e.code===U.SUCCESS)i();else{var t;a((t=e.error)==null?Error(`BatchLogRecordProcessor: log record export failed`):t)}}),r._exportScheduledResolve()})})()}},Zc=class{constructor(e,t){var n,r,i,a;I(this,`_maxExportBatchSize`,void 0),I(this,`_maxQueueSize`,void 0),I(this,`_scheduledDelayMillis`,void 0),I(this,`_exportTimeoutMillis`,void 0),I(this,`_exporter`,void 0),I(this,`_currentExport`,null),I(this,`_finishedLogRecords`,[]),I(this,`_timer`,void 0),I(this,`_shutdownOnce`,void 0),I(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 yi(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(P.warn(`BatchLogRecordProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize`),this._maxExportBatchSize=this._maxQueueSize)}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 W(function*(){e.onShutdown(),yield e._flushAll(),yield e._exporter.shutdown()})()}_flushAll(){var e=this;return W(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 Xc(e._exporter,n,e._exportTimeoutMillis);e._currentExport=r;try{yield r.exportScheduled,yield e._exporter.forceFlush(),yield r.exportCompleted}catch(e){$n(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 Xc(this._exporter,e,this._exportTimeoutMillis);this._currentExport=t,t.exportCompleted.then(()=>{this._currentExport=null,this._maybeStartTimer()}).catch(e=>{this._currentExport=null,$n(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)}};L();var Qc=class extends Zc{constructor(e,t){super(e,t),I(this,`_visibilityChangeListener`,void 0),I(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))}},$c=`exception`;L();var el=class{constructor(e){var t,n;I(this,`_spanContext`,void 0),I(this,`kind`,void 0),I(this,`parentSpanContext`,void 0),I(this,`attributes`,{}),I(this,`links`,[]),I(this,`events`,[]),I(this,`startTime`,void 0),I(this,`resource`,void 0),I(this,`instrumentationScope`,void 0),I(this,`_droppedAttributesCount`,0),I(this,`_droppedEventsCount`,0),I(this,`_droppedLinksCount`,0),I(this,`_attributesCount`,0),I(this,`name`,void 0),I(this,`status`,{code:We.UNSET}),I(this,`endTime`,[0,0]),I(this,`_ended`,!1),I(this,`_duration`,[-1,-1]),I(this,`_spanProcessor`,void 0),I(this,`_spanLimits`,void 0),I(this,`_attributeValueLengthLimit`,void 0),I(this,`_recordEndMetrics`,void 0),I(this,`_performanceStartTime`,void 0),I(this,`_performanceOffset`,void 0),I(this,`_startTimeProvided`,void 0);let r=Date.now();if(this._spanContext=e.spanContext,this._performanceStartTime=dr.now(),this._performanceOffset=r-(this._performanceStartTime+dr.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 P.warn(`Invalid attribute key: ${e}`),this;if(!Kn(t))return P.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 P.warn(`No events allowed.`),this._droppedEventsCount++,this;r!==void 0&&this.events.length>=r&&(this._droppedEventsCount===0&&P.debug(`Dropping extra events.`),this.events.shift(),this._droppedEventsCount++),Cr(t)&&(Cr(n)||(n=t),t=void 0);let i=Wn(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&&P.debug(`Dropping extra links.`),this.links.shift(),this._droppedLinksCount++);let{attributePerLinkCountLimit:n}=this._spanLimits,r=Wn(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===We.UNSET||this.status.code===We.OK)return this;let t={code:e.code};return e.code===We.ERROR&&(typeof e.message==`string`?t.message=e.message:e.message!=null&&P.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()){P.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=vr(this.startTime,this.endTime),this._duration[0]<0&&(P.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&&P.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`),this._droppedLinksCount>0&&P.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<=dr.now())return gr(e+this._performanceOffset);if(typeof e==`number`)return hr(e);if(e instanceof Date)return hr(e.getTime());if(Sr(e))return e;if(this._startTimeProvided)return hr(Date.now());let t=dr.now()-this._performanceStartTime;return wr(this.startTime,hr(t))}isRecording(){return this._ended===!1}recordException(e,t){let n={};typeof e==`string`?n[tr]=e:e&&(e.code?n[rr]=e.code.toString():e.name&&(n[rr]=e.name),e.message&&(n[tr]=e.message),e.stack&&(n[nr]=e.stack)),n[`exception.type`]||n[`exception.message`]?this.addEvent($c,n,t):P.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}}`);P.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?(P.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}},tl;(function(e){e[e.NOT_RECORD=0]=`NOT_RECORD`,e[e.RECORD=1]=`RECORD`,e[e.RECORD_AND_SAMPLED=2]=`RECORD_AND_SAMPLED`})(tl||(tl={}));var nl=class{shouldSample(){return{decision:tl.NOT_RECORD}}toString(){return`AlwaysOffSampler`}},rl=class{shouldSample(){return{decision:tl.RECORD_AND_SAMPLED}}toString(){return`AlwaysOnSampler`}};L();var il=class{constructor(e){var t,n,r,i;I(this,`_root`,void 0),I(this,`_remoteParentSampled`,void 0),I(this,`_remoteParentNotSampled`,void 0),I(this,`_localParentSampled`,void 0),I(this,`_localParentNotSampled`,void 0),this._root=e.root,this._root||($n(Error(`ParentBasedSampler must have a root sampler configured`)),this._root=new rl),this._remoteParentSampled=(t=e.remoteParentSampled)==null?new rl:t,this._remoteParentNotSampled=(n=e.remoteParentNotSampled)==null?new nl:n,this._localParentSampled=(r=e.localParentSampled)==null?new rl:r,this._localParentNotSampled=(i=e.localParentNotSampled)==null?new nl:i}shouldSample(e,t,n,r,i,a){let o=F.getSpanContext(e);return!o||!Ne(o)?this._root.shouldSample(e,t,n,r,i,a):o.isRemote?o.traceFlags&M.SAMPLED?this._remoteParentSampled.shouldSample(e,t,n,r,i,a):this._remoteParentNotSampled.shouldSample(e,t,n,r,i,a):o.traceFlags&M.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()}}`}};L();var al=class{constructor(e=0){I(this,`_ratio`,void 0),I(this,`_upperBound`,void 0),this._ratio=this._normalize(e),this._upperBound=Math.floor(this._ratio*4294967295)}shouldSample(e,t){return{decision:je(t)&&this._accumulate(t)<this._upperBound?tl.RECORD_AND_SAMPLED:tl.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}},ol;(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`})(ol||(ol={}));var sl=1;function cl(){var e,t,n,r,i,a,o,s;return{sampler:ll(),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 ll(){var e;let t=(e=void 0)==null?ol.ParentBasedAlwaysOn:e;switch(t){case ol.AlwaysOn:return new rl;case ol.AlwaysOff:return new nl;case ol.ParentBasedAlwaysOn:return new il({root:new rl});case ol.ParentBasedAlwaysOff:return new il({root:new nl});case ol.TraceIdRatio:return new al(ul());case ol.ParentBasedTraceIdRatio:return new il({root:new al(ul())});default:return P.error(`OTEL_TRACES_SAMPLER value "${t}" invalid, defaulting to "${ol.ParentBasedAlwaysOn}".`),new il({root:new rl})}}function ul(){return P.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${sl}.`),sl}var dl=1/0;function fl(e){let t={sampler:ll()},n=cl(),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 pl(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?dl:s,Object.assign({},e,{spanLimits:p})}L();var ml=class{constructor(e,t){var n,r,i,a;I(this,`_maxExportBatchSize`,void 0),I(this,`_maxQueueSize`,void 0),I(this,`_scheduledDelayMillis`,void 0),I(this,`_exportTimeoutMillis`,void 0),I(this,`_exporter`,void 0),I(this,`_isExporting`,!1),I(this,`_finishedSpans`,[]),I(this,`_timer`,void 0),I(this,`_shutdownOnce`,void 0),I(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 yi(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(P.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&M.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&&P.debug(`maxQueueSize reached, dropping spans`),this._droppedSpansCount++;return}this._droppedSpansCount>0&&(P.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);N.with(In(N.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===U.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=>{$n(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,$n(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)}};L();var hl=class extends ml{constructor(e,t){super(e,t),I(this,`_visibilityChangeListener`,void 0),I(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=>{$n(e)})},this._pageHideListener=()=>{this.forceFlush().catch(e=>{$n(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))}},gl=16,_l=8,vl=new Uint8Array(gl),yl=new Uint8Array(_l),bl=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function xl(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 Sl(e){let t=``;for(let n=0;n<e.length;n++)t+=bl[e[n]];return t}var Cl=class{generateTraceId(){return xl(vl),Sl(vl)}generateSpanId(){return xl(yl),Sl(yl)}},wl=`otel.span.parent.origin`,Tl=`otel.span.sampling_result`,El=`otel.sdk.span.live`,Dl=`otel.sdk.span.started`;L();var Ol=class{constructor(e){I(this,`startedSpans`,void 0),I(this,`liveSpans`,void 0),this.startedSpans=e.createCounter(Dl,{unit:`{span}`,description:`The number of created spans.`}),this.liveSpans=e.createUpDownCounter(El,{unit:`{span}`,description:`The number of currently live spans.`})}startSpan(e,t){let n=Al(t);if(this.startedSpans.add(1,{[wl]:kl(e),[Tl]:n}),t===tl.NOT_RECORD)return()=>{};let r={[Tl]:n};return this.liveSpans.add(1,r),()=>{this.liveSpans.add(-1,r)}}};function kl(e){return e?e.isRemote?`remote`:`local`:`none`}function Al(e){switch(e){case tl.RECORD_AND_SAMPLED:return`RECORD_AND_SAMPLE`;case tl.RECORD:return`RECORD_ONLY`;case tl.NOT_RECORD:return`DROP`}}var jl=`2.7.1`;L();var Ml=class{constructor(e,t,n,r){I(this,`_sampler`,void 0),I(this,`_generalLimits`,void 0),I(this,`_spanLimits`,void 0),I(this,`_idGenerator`,void 0),I(this,`instrumentationScope`,void 0),I(this,`_resource`,void 0),I(this,`_spanProcessor`,void 0),I(this,`_tracerMetrics`,void 0);let i=fl(t);this._sampler=i.sampler,this._generalLimits=i.generalLimits,this._spanLimits=i.spanLimits,this._idGenerator=t.idGenerator||new Cl,this._resource=n,this._spanProcessor=r,this.instrumentationScope=e;let a=i.meterProvider?i.meterProvider.getMeter(`@opentelemetry/sdk-trace`,jl):fe();this._tracerMetrics=new Ol(a)}startSpan(e,t={},n=N.active()){var r,i,a;t.root&&(n=F.deleteSpan(n));let o=F.getSpan(n);if(Ln(n))return P.debug(`Instrumentation suppressed, returning Noop Span`),F.wrapSpanContext(be);let s=o==null?void 0:o.spanContext(),c=this._idGenerator.generateSpanId(),l,u,d;!s||!F.isSpanContextValid(s)?u=this._idGenerator.generateTraceId():(u=s.traceId,d=s.traceState,l=s);let f=(r=t.kind)==null?Ue.INTERNAL:r,p=((i=t.links)==null?[]:i).map(e=>({context:e.context,attributes:Wn(e.attributes)})),m=Wn(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===He.RECORD_AND_SAMPLED?M.SAMPLED:M.NONE,v={traceId:u,spanId:c,traceFlags:_,traceState:d};if(h.decision===He.NOT_RECORD)return P.debug(`Recording is off, propagating context in a non-recording span`),F.wrapSpanContext(v);let y=Wn(Object.assign(m,h.attributes));return new el({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?N.active():i,l=this.startSpan(e,a,c),u=F.setSpan(c,l);return N.with(u,s,void 0,l)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}};L();var Nl=class{constructor(e){I(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=>{$n(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)})}};L();var Pl;(function(e){e[e.resolved=0]=`resolved`,e[e.timeout=1]=`timeout`,e[e.error=2]=`error`,e[e.unresolved=3]=`unresolved`})(Pl||(Pl={}));var Fl=class{constructor(e={}){var t,n;I(this,`_config`,void 0),I(this,`_tracers`,new Map),I(this,`_resource`,void 0),I(this,`_activeSpanProcessor`,void 0);let r=si({},cl(),pl(e));this._resource=(t=r.resource)==null?ao():t,this._config=Object.assign({},r,{resource:this._resource});let i=[];(n=e.spanProcessors)!=null&&n.length&&i.push(...e.spanProcessors),this._activeSpanProcessor=new Nl(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 Ml({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=Pl.timeout},e);t.forceFlush().then(()=>{clearTimeout(i),r!==Pl.timeout&&(r=Pl.resolved,n(r))}).catch(e=>{clearTimeout(i),r=Pl.error,n(e)})}));return new Promise((e,n)=>{Promise.all(t).then(t=>{let r=t.filter(e=>e!==Pl.resolved);r.length>0?n(r):e()}).catch(e=>n([e]))})}shutdown(){return this._activeSpanProcessor.shutdown()}};L();var Il=class{constructor(e){I(this,`_exporter`,void 0),I(this,`_shutdownOnce`,void 0),I(this,`_pendingExports`,void 0),this._exporter=e,this._shutdownOnce=new yi(this._shutdown,this),this._pendingExports=new Set}forceFlush(){var e=this;return W(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&M.SAMPLED)===0)return;let t=this._doExport(e).catch(e=>$n(e));this._pendingExports.add(t),t.finally(()=>this._pendingExports.delete(t))}_doExport(e){var t=this;return W(function*(){if(e.resource.asyncAttributesPending){var n,r;yield(n=(r=e.resource).waitForAsyncAttributes)==null?void 0:n.call(r)}let i=yield xi._export(t._exporter,[e]);if(i.code!==U.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()}};L();var Ll=class{constructor(){I(this,`_enabled`,!1),I(this,`_currentContext`,T)}_bindFunction(e=T,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=T,this._enabled=!1,this}enable(){return this._enabled?this:(this._enabled=!0,this._currentContext=T,this)}with(e,t,n,...r){let i=this._currentContext;this._currentContext=e||T;try{return t.call(n,...r)}finally{this._currentContext=i}}};function Rl(e){if(e!==null){if(e===void 0){let e=new Ll;e.enable(),N.setGlobalContextManager(e);return}e.enable(),N.setGlobalContextManager(e)}}function zl(e){if(e!==null){if(e===void 0){nt.setGlobalPropagator(new Tr({propagators:[new Wr,new Un]}));return}nt.setGlobalPropagator(e)}}var Bl=class extends Fl{constructor(e={}){super(e)}register(e={}){F.setGlobalTracerProvider(this),zl(e.propagator),Rl(e.contextManager)}},Vl=e=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`,J=(e,t)=>e.isSampled()&&e.config.transport[t]!==!1,Hl=()=>typeof window>`u`?`http://localhost`:window.location.origin,Ul=e=>{try{return new URL(e,Hl()).href}catch(t){return e}},Wl=e=>e.length>1?e.replace(/\/+$/,``):e,Gl=(e,t)=>{let n=e=>Wl(e.replace(/[?#].*$/,``));return n(e)===n(t)},Kl=(e,t)=>{let n=Ul(t);return[e.transport.traces,e.transport.metrics,e.transport.logs].filter(e=>e!==!1).some(e=>Gl(n,Ul(e.endpoint)))},ql=(e,t)=>Kl(e,t),Jl=(e,t)=>typeof e==`function`?e(t):typeof e==`string`?t.includes(e):(e.lastIndex=0,e.test(t)),Yl=(e,t)=>(Array.isArray(e)?e:e?[e]:[]).some(e=>Jl(e,t)),Xl=e=>typeof e.tracking.request==`object`?e.tracking.request:void 0,Zl=(e,t)=>{var n;return ql(e,t)||Yl((n=Xl(e))==null?void 0:n.excludedUrls,Ul(t))},Ql=(e,t)=>{var n;return e.transport.traces!==!1&&Yl((n=Xl(e))==null?void 0:n.allowedTracingUrls,Ul(t))},Y={actionErrorCount:`action.error.count`,actionFrustrationCount:`action.frustration.count`,actionFrustrationType:`action.frustration.type`,actionId:`action.id`,actionLoadingTime:`action.loading_time`,actionLongTaskCount:`action.long_task.count`,actionName:`action.name`,actionResourceCount:`action.resource.count`,actionTargetName:`action.target.name`,actionTargetTag:`action.target.tag`,actionType:`action.type`,deploymentEnvironmentName:`deployment.environment.name`,browserName:`browser.name`,browserVersion:`browser.version`,cacheHit:`resource.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`,longTaskBlockingDuration:`long_task.blocking_duration`,longTaskCulprit:`long_task.culprit`,longTaskDuration:`long_task.duration`,longTaskEntryType:`long_task.entry_type`,longTaskId:`long_task.id`,longTaskIsFrozenFrame:`long_task.is_frozen_frame`,longTaskScriptCount:`long_task.script.count`,longTaskStartTime:`long_task.start_time`,networkEffectiveType:`network.effective_type`,nextHopProtocol:`resource.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`,targetValue:`target_value`,traceScene:`trace_scene`,transferSize:`transfer_size`,userId:`user.id`,vitalMetric:`vital.metric`,vitalRating:`vital.rating`,vitalValue:`vital.value`,viewDomComplete:`view.dom_complete`,viewDomContentLoaded:`view.dom_content_loaded`,viewDomInteractive:`view.dom_interactive`,viewFirstByte:`view.first_byte`,viewId:`view.id`,viewLoadEvent:`view.load_event`,viewLoadingTime:`view.loading_time`,viewLoadingType:`view.loading_type`,viewName:`view.name`,viewUrl:`view.url`,viewUrlPathGroup:`view.url_path_group`};q();var X={abort:`abort`,error:`error`,success:`success`,timeout:`timeout`,warning:`warning`},Z={action:`action`,custom:`custom`,document:`document`,error:`error`,longtask:`longtask`,resource:`resource`,route:`route`,vital:`vital`},$l=e=>e<100?`<100ms`:e<500?`100~500ms`:e<2e3?`500ms~2s`:`>2s`,eu=e=>`${Math.trunc(e/100)}xx`,tu=e=>e===408||e===504?X.timeout:typeof e==`number`&&e>=400?X.error:X.success,nu=e=>e===408||e===504?`network_timeout`:typeof e!=`number`||e<400?`none`:e>=500?`http_5xx`:`http_4xx`,ru=e=>e===`good`?X.success:X.warning,iu=(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}}},Q=({duration:e,errorType:t=`none`,eventLabel:n,result:r=X.success,spanSubtype:i,spanType:a,targetLabel:o,targetValue:s,traceScene:c})=>K(K(K(K(K({[Y.spanType]:a,[Y.spanSubtype]:i,[Y.result]:r,[Y.errorType]:t},e===void 0?{}:{[Y.durationBucket]:$l(e)}),n===void 0?{}:{[Y.eventLabel]:n}),o===void 0?{}:{[Y.targetLabel]:o}),s===void 0?{}:{[Y.targetValue]:s}),c===void 0?{}:{[Y.traceScene]:c}),au=({duration:e,initiatorType:t=`other`,method:n,networkError:r=!1,responseStatus:i,transferSize:a,url:o,urlPathTemplate:s})=>{var c;let l=iu(o,s),u=t===`fetch`||t===`xhr`,d=r?X.error:typeof i==`number`?tu(i):X.success,f=n==null?void 0:n.toUpperCase();return K(K(K(K(K(K(K({},Q({duration:e,errorType:r?`network`:typeof i==`number`?nu(i):`none`,eventLabel:u?`请求资源`:`静态资源`,result:d,spanSubtype:t,spanType:Z.resource,targetLabel:(c=l.label)==null?o:c,targetValue:u?i:a})),l.domain?{[Y.targetDomain]:l.domain}:{}),l.pathTemplate?{[Y.targetPathTemplate]:l.pathTemplate}:{}),{},{"resource.type":t,"resource.url":o},e===void 0?{}:{"resource.duration":e}),f?{"http.request.method":f,"resource.method":f}:{}),typeof a==`number`?{"resource.size":a}:{}),typeof i==`number`?K({"http.response.status_code":i,"resource.status_code":i},i>0?{[Y.statusClass]:eu(i)}:{}):{})};q();var ou=100,su=100,cu=1e3,lu=100,uu=1e4,du=`data-bk-action-name`,fu=100,pu=10,mu=e=>e.replace(/\s+/g,` `).trim().slice(0,fu),hu=e=>{var t;if(e.parentElement)return e.parentElement;let n=(t=e.getRootNode)==null?void 0:t.call(e);return typeof ShadowRoot<`u`&&n instanceof ShadowRoot?n.host:null},gu=(e,t)=>{let n=e;for(;n;){let e=n.getAttribute(t);if(e)return mu(e);n=hu(n)}},_u=e=>{var t;return e.isContentEditable?``:mu((t=e.textContent)==null?``:t)},vu=e=>{var t,n;let r=e,i=(t=r.labels)==null?void 0:t[0];if(i){let e=_u(i);if(e)return e}let a=e.tagName.toLowerCase(),o=(n=e.getAttribute(`type`))==null?void 0:n.toLowerCase();if(a===`input`&&[`button`,`reset`,`submit`].includes(o==null?``:o)){var s;let e=mu((s=r.value)==null?``:s);if(e)return e}if(a===`button`||a===`label`||e.getAttribute(`role`)===`button`){let t=_u(e);if(t)return t}for(let t of[`aria-label`,`alt`,`name`,`title`,`placeholder`]){var c;let n=mu((c=e.getAttribute(t))==null?``:c);if(n)return n}},yu=(e,t=du,n=!1)=>{let r=gu(e,t);if(r)return r;if(!n)return e.tagName.toLowerCase();let i=e,a=0;for(;i&&a<=pu;){let e=i.tagName.toLowerCase();if(e===`body`||e===`html`||e===`head`)break;let t=vu(i);if(t)return t;if(e===`form`)break;i=hu(i),a+=1}for(i=e,a=0;i&&a<=pu;){let e=i.tagName.toLowerCase();if(e===`body`||e===`html`||e===`head`)break;let t=_u(i);if(t)return t;if(e===`form`)break;i=hu(i),a+=1}return e.tagName.toLowerCase()},bu=e=>{var t;let n=(t=e.composedPath)==null?void 0:t.call(e)[0];return n instanceof Element?n:e.target instanceof Element?e.target:void 0},xu=e=>{let t=e.timeStamp;return!Number.isFinite(t)||t<=0?Date.now():t>0xe8d4a51000?t:typeof performance>`u`?Date.now():performance.timeOrigin+t},Su=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>0?e:t,Cu=e=>{let t=e;if(t.tagName.toLowerCase()===`label`&&t.hasAttribute(`for`)){var n;t=document.getElementById((n=t.getAttribute(`for`))==null?``:n)}for(;t;){let e=t.tagName.toLowerCase();if(t.hasAttribute(`contenteditable`)||e===`canvas`||e===`select`||e===`textarea`||e===`a`&&t.hasAttribute(`href`))return!0;if(e===`input`){var r,i;return![`button`,`checkbox`,`radio`,`range`,`reset`,`submit`].includes((r=(i=t.getAttribute(`type`))==null?void 0:i.toLowerCase())==null?`text`:r)}t=hu(t)}return!1},wu=(e={})=>{let t=[],n=new Map,r=new Set,i=e.actionNameAttribute||du,a=Su(e.maxDuration,uu),o=[],s,c=()=>{s==null||s.setRuntimeAttributes({[Y.actionId]:n.size?[...n.keys()]:void 0})},l=e=>!e.hadActivity&&!e.userActivity.input&&!e.userActivity.scroll&&!e.userActivity.selection&&!Cu(e.target),u=e=>{var t;if(!r.delete(e)||!s||!e.completed||e.discardedByRage)return;clearTimeout(e.reportTimer),e.counts.error&&e.frustrations.add(`error_click`),((t=e.rageSources)==null?[e]:t).some(l)&&e.frustrations.add(`dead_click`);let n=[`rage_click`,`dead_click`,`error_click`].filter(t=>e.frustrations.has(t)),{endTime:i,hasLoadingTime:a}=e.completed,o=Math.max(0,i-e.startTime),c=e.counts.error>0||n.length>0;s.startSpan(`action.click`,K(K(K(K(K({},s.config.hooks.getPageAttributes()),Q({duration:a?o:void 0,errorType:e.counts.error?`js`:n.length?`frustration`:`none`,eventLabel:`用户操作`,result:c?X.warning:X.success,spanSubtype:`click`,spanType:Z.action,targetLabel:e.targetName,targetValue:a?o:void 0,traceScene:`user_action`})),e.runtimeAttributes),{},{[Y.actionId]:e.id,[Y.actionType]:`click`,[Y.actionName]:`Click on ${e.targetName}`,[Y.actionTargetName]:e.targetName,[Y.actionTargetTag]:e.targetTag,[Y.actionResourceCount]:e.counts.resource,[Y.actionErrorCount]:e.counts.error,[Y.actionLongTaskCount]:e.counts.longTask,[Y.actionFrustrationCount]:n.length},n.length?{[Y.actionFrustrationType]:n}:{}),a?{[Y.actionLoadingTime]:o}:{}),{startTime:e.startTime}).end(a?i:e.startTime)},d=(e,t,i)=>{if(!n.delete(e.id)||!s)return;clearTimeout(e.validationTimer),clearTimeout(e.quietTimer),clearTimeout(e.maxDurationTimer),c(),e.completed={endTime:t,hasLoadingTime:i},r.add(e);let a=Math.max(0,e.startTime+cu-Date.now());e.reportTimer=setTimeout(()=>u(e),a)},f=()=>{[...r].forEach(u)},p=e=>{if(clearTimeout(e.quietTimer),!e.hadActivity||e.pendingRequests.size)return;let t=Math.max(0,e.lastActivityTime+su-Date.now());e.quietTimer=setTimeout(()=>d(e,e.lastActivityTime,!0),t)},m=(e,t)=>{e.hadActivity=!0,e.lastActivityTime=Math.max(e.lastActivityTime,t),p(e)},h=(e,t)=>t>=e.startTime&&t<=e.startTime+a,g=e=>{for(let i of n.values()){if(e.type===`request_start`){var t;if(e.url&&Yl(s==null||(t=s.config.view)==null?void 0:t.excludedActivityUrls,e.url)||!h(i,e.time))continue;i.pendingRequests.add(e.id),m(i,e.time);continue}if(e.type===`request_end`){if(!i.pendingRequests.delete(e.id))continue;i.counts.resource+=1,m(i,e.time);continue}if(e.type===`long_task`||e.type===`resource`){var r;if(e.type===`resource`&&e.url&&Yl(s==null||(r=s.config.view)==null?void 0:r.excludedActivityUrls,e.url)||e.startTime>i.startTime+a||(e.type===`resource`?e.startTime<i.startTime:e.endTime<i.startTime))continue;i.counts[e.type===`long_task`?`longTask`:`resource`]+=1,m(i,e.endTime);continue}if(e.type===`dom_mutation`||e.type===`window_open`){h(i,e.time)&&m(i,e.time);continue}e.type===`error`&&h(i,e.time)&&(i.counts.error+=1,m(i,e.time))}},_=(e=Date.now())=>{[...n.values()].forEach(t=>d(t,e,t.hadActivity))},v=(e,t)=>{let n=`clientX`in t&&typeof t.clientX==`number`?t.clientX:0,r=`clientY`in t&&typeof t.clientY==`number`?t.clientY:0;o=o.filter(t=>e.startTime-t.action.startTime<=cu);let i=o.at(-1),a=o.some(e=>e.action.userActivity.scroll||e.action.userActivity.selection),s=(i==null?void 0:i.target)===e.target&&Math.hypot(i.x-n,i.y-r)<=lu;if((a||i&&!s)&&(o=[]),o.push({action:e,target:e.target,x:n,y:r}),o.length>=3&&e.startTime-o[o.length-3].action.startTime<=cu){let t=o.slice(-3).map(e=>e.action);t.slice(0,-1).forEach(e=>{e.discardedByRage=!0}),e.frustrations.add(`rage_click`),e.rageSources=t,o=[]}};return{name:`action`,init(l){if(typeof window>`u`||typeof document>`u`)return;s=l;let u={capture:!0,passive:!0},p=t=>{if(!J(l,`traces`)||`button`in t&&typeof t.button==`number`&&t.button!==0)return;let r=bu(t);if(!r)return;let o=xu(t),s=Vl(`action`),u={counts:{error:0,longTask:0,resource:0},frustrations:new Set,hadActivity:!1,id:s,lastActivityTime:o,maxDurationTimer:setTimeout(()=>d(u,o+a,!0),a),pendingRequests:new Set,runtimeAttributes:l.getRuntimeAttributes(),startTime:o,target:r,targetName:yu(r,i,e.nameCollection===`text`),targetTag:r.tagName.toLowerCase(),userActivity:{input:!1,scroll:!1,selection:!1},validationTimer:setTimeout(()=>{u.hadActivity||d(u,u.startTime,!1)},ou)};n.set(s,u),v(u,t),c()};window.addEventListener(`click`,p,u),t.push(()=>window.removeEventListener(`click`,p,u));let m=l.onActivity(g),h=l.onSessionLifecycle(e=>{e.type===`expired`&&(_(e.expiredAt),f())});t.push(m,h);let y=()=>{document.visibilityState===`hidden`&&(_(),f())},b=()=>{_(),f()};window.addEventListener(`pagehide`,b),document.addEventListener(`visibilitychange`,y),t.push(()=>window.removeEventListener(`pagehide`,b),()=>document.removeEventListener(`visibilitychange`,y));let x=e=>{new Set([...n.values(),...r,...o.map(e=>e.action)]).forEach(t=>{if(t.userActivity[e]=!0,e!==`input`&&t.frustrations.delete(`rage_click`)){var n;(n=t.rageSources)==null||n.slice(0,-1).forEach(e=>{e.discardedByRage=!1}),t.rageSources=void 0}})},S=()=>x(`input`),C=()=>x(`scroll`),w=()=>x(`selection`);window.addEventListener(`input`,S,u),window.addEventListener(`scroll`,C,u),document.addEventListener(`selectionchange`,w,u),t.push(()=>window.removeEventListener(`input`,S,u),()=>window.removeEventListener(`scroll`,C,u),()=>document.removeEventListener(`selectionchange`,w,u))},shutdown(){for(_(),f();t.length;){var e;(e=t.pop())==null||e()}o=[],s=void 0}}},Tu=e=>{let t=e.type===`characterData`?e.target.parentElement:e.target;return t instanceof Element&&!!t.closest(`[data-bk-excluded-activity-mutations]`)},Eu=()=>{let e,t=[];return{name:`activity`,init(n){if(typeof document<`u`&&typeof MutationObserver<`u`&&(e=new MutationObserver(e=>{e.length&&!e.every(Tu)&&n.notifyActivity({time:Date.now(),type:`dom_mutation`})}),e.observe(document,{attributes:!0,characterData:!0,childList:!0,subtree:!0})),!(typeof window>`u`)&&typeof window.open==`function`){let e=window.open,r=((...t)=>(n.notifyActivity({time:Date.now(),type:`window_open`}),Reflect.apply(e,window,t)));window.open=r,t.push(()=>{window.open===r&&(window.open=e)})}},shutdown(){var n;for(e==null||e.disconnect(),e=void 0;t.length;)(n=t.pop())==null||n()}}},Du=(e,t)=>!!(t&&Yl(e.config.view.excludedActivityUrls,t)),Ou=(e,t,n)=>{let r=new Set,i=!1,a=!1,o=t,s,c=e=>{i||(i=!0,clearTimeout(f),clearTimeout(s),d(),n(e))},l=()=>{clearTimeout(s),!(!a||r.size)&&(s=setTimeout(()=>c({endTime:o,hadActivity:!0}),Math.max(0,o+100-Date.now())))},u=e=>{a=!0,o=Math.max(o,e),l()},d=e.onActivity(n=>{if(!(n.type===`error`||n.type===`long_task`)){if(n.type===`request_start`){if(n.time<t||Du(e,n.url))return;r.add(n.id),u(n.time);return}if(n.type===`request_end`){if(!r.delete(n.id))return;u(n.time);return}if(n.type===`resource`){if(n.endTime<t||Du(e,n.url))return;u(n.endTime);return}n.time>=t&&u(n.time)}}),f=setTimeout(()=>{a||c({hadActivity:!1})},100);return()=>{i||(i=!0,clearTimeout(f),clearTimeout(s),d())}},$=`bk.rum.sampled`,ku=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t=Math.imul(t^e.charCodeAt(n),16777619);return t+=t<<13,t^=t>>>7,t+=t<<3,t^=t>>>17,t+=t<<5,(t>>>0)/4294967296},Au=({application:e,session:t},n)=>t.sampleRate<=0?!1:t.sampleRate>=1?!0:ku(`${e.name}\0${n}`)<t.sampleRate;function ju(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 Mu(e,t){if(e==null)return{};var n,r,i=ju(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}q();var Nu=/^(?:\d+|[0-9a-f]{8}-[0-9a-f-]{27,}|[0-9a-f]{16,})$/i,Pu=e=>e.split(/[?#]/,1)[0].split(`/`).map(e=>Nu.test(e)?`:id`:e).join(`/`),Fu=e=>typeof e==`string`&&e.length>0?Pu(e):void 0,Iu=e=>{let t=Fu(e);return t?{[Y.viewUrlPathGroup]:t}:{}},Lu=e=>K(K({},Iu(e[Y.viewUrlPathGroup])),{},{[$]:e[$]===!0});q();var Ru=1e3,zu=200,Bu=`body`,Vu=.8,Hu=[`[data-loading="true"]`,`[aria-busy="true"]`,`.loading`,`.is-loading`,`.spinner`,`.skeleton`,`.bk-loading`],Uu=[[.2,.2],[.5,.2],[.8,.2],[.2,.5],[.5,.5],[.8,.5],[.2,.8],[.5,.8],[.8,.8]],Wu=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>=0?e:t,Gu=(e,t)=>typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.min(1,e)):t,Ku=e=>{if(!e)return``;let t=e.tagName.toLowerCase();return e.id?`${t}#${e.id}`:t},qu=(e,t)=>t.some(t=>{try{return e.matches(t)||!!e.closest(t)}catch(e){return!1}}),Ju=e=>{if(typeof getComputedStyle!=`function`)return!0;let t=getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`&&Number(t.opacity||1)>0},Yu=(e,t)=>{if(typeof document.elementsFromPoint==`function`)return document.elementsFromPoint(e,t);let n=document.elementFromPoint(e,t);return n?[n]:[]},Xu=(e,t)=>{let n=document.querySelector(e);if(!n)return{centerElement:Ku(Yu(window.innerWidth/2,window.innerHeight/2)[0]),emptyCount:Uu.length,ignoredCount:0,reason:`missing_root`,rootFound:!1,score:1,validCount:Uu.length};let r=0,i=0,a=``;for(let[e,o]of Uu){let s=Yu(window.innerWidth*e,window.innerHeight*o);if(e===.5&&o===.5&&(a=Ku(s[0])),s.some(e=>qu(e,t))){i+=1;continue}s.some(e=>e!==n&&e!==document.body&&e!==document.documentElement&&n.contains(e)&&Ju(e))||(r+=1)}let o=Uu.length-i;return{centerElement:a,emptyCount:r,ignoredCount:i,reason:`empty_viewport`,rootFound:!0,score:o?r/o:0,validCount:o}},Zu=(e={})=>{var t;let n=Wu(e.checkDelay,Ru),r=Wu(e.confirmationDelay,zu),i=e.rootSelector||Bu,a=Gu(e.threshold,Vu),o=[...Hu,...(t=e.ignoreSelectors)==null?[]:t],s,c,l,u,d=()=>{},f;return{name:`blank-screen`,init(e){if(typeof window>`u`||typeof document>`u`)return;let t=e.meter.createCounter(`browser.blank_screen.count`,{description:`Number of confirmed blank screens`}),p=()=>{clearTimeout(u),u=void 0},m=(n,r)=>{if(s!==n||c===n)return;let a=J(e,`metrics`),o=J(e,`traces`);!a&&!o||(c=n,a&&t.add(1,e.applyRedact(K(K(K({},e.config.hooks.getMetricAttributes()),Lu(e.getRuntimeAttributes())),{},{"blank_screen.reason":r.reason,"blank_screen.root_selector":i}))),o&&e.startSpan(`browser.blank_screen`,K(K({},Q({errorType:`blank_screen`,eventLabel:`白屏`,result:X.error,spanSubtype:r.reason,spanType:Z.error,targetLabel:i,targetValue:r.score})),{},{"blank_screen.center_element":r.centerElement,"blank_screen.empty_ratio":r.score,"blank_screen.empty_sample_count":r.emptyCount,"blank_screen.ignored_sample_count":r.ignoredCount,"blank_screen.reason":r.reason,"blank_screen.root_found":r.rootFound,"blank_screen.root_selector":i,"blank_screen.sample_count":Uu.length,"blank_screen.valid_sample_count":r.validCount})).end())},h=t=>{if(s!==t||c===t||document.visibilityState===`hidden`)return;let n;try{n=Xu(i,o)}catch(t){var l;e.config.debug&&((l=globalThis.console)==null||l.warn(`[bk-ot][blank-screen] detection failed:`,t));return}!n.validCount||n.score<a||(u=setTimeout(()=>{if(s!==t||document.visibilityState===`hidden`)return;let n;try{n=Xu(i,o)}catch(t){var r;e.config.debug&&((r=globalThis.console)==null||r.warn(`[bk-ot][blank-screen] confirmation failed:`,t));return}n.validCount&&n.score>=a&&m(t,n)},r))},g=t=>{p(),!(document.visibilityState===`hidden`||!J(e,`metrics`)&&!J(e,`traces`))&&(u=setTimeout(()=>h(t),n))};d=e.onViewChange(t=>{if(t.id!==s&&(p(),l==null||l(),l=void 0,s=t.id,c=void 0,t.id)){let n=t.id;l=Ou(e,Date.now(),()=>{l=void 0,g(n)})}});let _=()=>{document.visibilityState===`hidden`?p():s&&c!==s&&g(s)};document.addEventListener(`visibilitychange`,_),f=()=>document.removeEventListener(`visibilitychange`,_)},shutdown(){clearTimeout(u),u=void 0,d(),l==null||l(),l=void 0,f==null||f(),f=void 0,s=void 0,c=void 0}}};q(),ut();var Qu=[`http.url`,`url.full`],$u=`bk.rum.request.discard`,ed=e=>{for(let n of Qu){var t;let r=(t=e.attributes)==null?void 0:t[n];if(typeof r==`string`)return r}},td=e=>{let t=e==null?void 0:e[Y.sessionId];return typeof t==`string`&&t.length>0},nd=e=>{let t=e==null?void 0:e[Y.viewId];return typeof t==`string`&&t.length>0},rd=e=>(e==null?void 0:e[`bk.rum.sampled`])===!0&&td(e)&&nd(e),id=class{constructor(e,t){this.inner=e,this.config=t}enabled(e){var t,n,r;return(t=(n=(r=this.inner).enabled)==null?void 0:n.call(r,e))==null?!0:t}forceFlush(){return this.inner.forceFlush()}onEmit(e,t){var n;let r=e.body===`session.start`||e.body===`session.rotate`;if(rd(e.attributes)||r&&((n=e.attributes)==null?void 0:n[`bk.rum.sampled`])===!0&&td(e.attributes)){delete e.attributes[$];try{var i,a,o,s,c;if(((i=this.config)==null||(o=(a=i.hooks).beforeSend)==null?void 0:o.call(a,{attributes:e.attributes,name:(s=e.eventName)==null?String((c=e.body)==null?``:c):s,signal:`log`}))===!1)return}catch(e){var l,u;(l=this.config)!=null&&l.debug&&((u=globalThis.console)==null||u.warn(`[bk-ot] tracking.beforeSend failed:`,e))}this.inner.onEmit(e,t)}}shutdown(){return this.inner.shutdown()}},ad=class{constructor(e,t,n){this.inner=e,this.config=t,this.getRuntimeAttributes=n}forceFlush(){return this.inner.forceFlush()}onEnd(e){let t=ed(e);if(!(e.attributes[`bk.rum.request.discard`]===!0||t&&Kl(this.config,t)||!rd(e.attributes))){delete e.attributes[$];try{var n,r;if(((n=this.config.hooks)==null||(r=n.beforeSend)==null?void 0:r.call(n,{attributes:e.attributes,name:e.name,signal:`span`}))===!1)return}catch(e){var i;this.config.debug&&((i=globalThis.console)==null||i.warn(`[bk-ot] tracking.beforeSend failed:`,e))}this.inner.onEnd(e)}}onStart(e,t){var n;let r=(n=e.attributes)==null?{}:n,i={};for(let[e,t]of Object.entries(this.getRuntimeAttributes()))r[e]===void 0&&t!==void 0&&(i[e]=t);e.setAttributes(i),this.inner.onStart(e,t)}shutdown(){return this.inner.shutdown()}},od=e=>K(K({},e),{},{dataPoints:e.dataPoints.filter(e=>e.attributes[$]===!0).map(e=>{let t=e.attributes,{[$]:n}=t,r=Mu(t,[$].map(lt));return K(K({},e),{},{attributes:r})})}),sd=class{constructor(e){this.inner=e}export(e,t){let n=K(K({},e),{},{scopeMetrics:e.scopeMetrics.map(e=>K(K({},e),{},{metrics:e.metrics.map(od).filter(e=>e.dataPoints.length>0)})).filter(e=>e.metrics.length>0)});if(n.scopeMetrics.length===0){t({code:U.SUCCESS});return}this.inner.export(n,t)}forceFlush(){return this.inner.forceFlush()}selectAggregationTemporality(e){var t,n,r;return(t=(n=(r=this.inner).selectAggregationTemporality)==null?void 0:n.call(r,e))==null?Ki.CUMULATIVE:t}shutdown(){return this.inner.shutdown()}},cd=100,ld=200,ud=[],dd=e=>e.replace(/#.*$/,``),fd=e=>{let t=ud.indexOf(e);t>=0&&ud.splice(t,1),e.timer!==void 0&&clearTimeout(e.timer)},pd=(e,t)=>{let n=e.callback;fd(e),e.callback=void 0,n==null||n(t)},md=e=>{let t=performance.timeOrigin+e.startTime,n=ud.filter(n=>!n.entry&&dd(n.url)===dd(e.name)&&t>=n.startTime-50).sort((e,n)=>Math.abs(e.startTime-t)-Math.abs(n.startTime-t))[0];n&&(n.entry=e,n.callback&&pd(n,e))},hd=(e,t=Date.now())=>{let n={startTime:t,url:e};return ud.push(n),ud.length>cd&&pd(ud[0]),{cancel:()=>pd(n),complete:e=>{if(n.callback=e,n.entry){pd(n,n.entry);return}n.timer=setTimeout(()=>pd(n),ld)}}};q();var gd=10*1024,_d=[/^text\//i,/json/i,`application/x-www-form-urlencoded`,`application/graphql`],vd=e=>typeof e==`number`&&Number.isFinite(e)&&e>0?Math.floor(e):gd,yd=(e,t,n)=>e?t.some(t=>typeof t==`string`?e.toLowerCase().includes(t.toLowerCase()):(t.lastIndex=0,t.test(e))):n,bd=e=>{try{var t;return e?(t=new Headers(e).get(`content-type`))==null?void 0:t:void 0}catch(e){return}},xd=function(){var e=W(function*(e,t){let n=e.getReader(),r=new TextDecoder,i=``;try{for(;i.length<=t;){let{done:e,value:t}=yield n.read();if(e){i+=r.decode();break}i+=r.decode(t,{stream:!0})}i.length>t&&(yield n.cancel().catch(()=>void 0))}finally{n.releaseLock()}return i});return function(t,n){return e.apply(this,arguments)}}(),Sd=function(){var e=W(function*(e,t){if(typeof e==`string`)return e;if(typeof URLSearchParams<`u`&&e instanceof URLSearchParams)return e.toString();if(typeof Blob<`u`&&e instanceof Blob)return xd(e.stream(),t)});return function(t,n){return e.apply(this,arguments)}}(),Cd=function(){var e=W(function*(e,t){if(typeof Request<`u`&&e instanceof Request){var n;let r=(n=e.headers.get(`content-type`))==null?void 0:n,i=e.clone();return{contentType:r,text:i.body?yield xd(i.body,t):``}}return{contentType:bd(e.headers),text:yield Sd(e.body,t)}});return function(t,n){return e.apply(this,arguments)}}(),wd=e=>{if(typeof Request>`u`||!(e instanceof Request))return e;try{return e.clone()}catch(e){return}},Td=function(){var e=W(function*(e,t){var n;if(!e)return{};let r=(n=e.headers.get(`content-type`))==null?void 0:n,i=e.clone();return{contentType:r,text:i.body?yield xd(i.body,t):``}});return function(t,n){return e.apply(this,arguments)}}(),Ed=e=>{var t;let n=(t=e.getResponseHeader(`content-type`))==null?void 0:t;return e.responseType===``||e.responseType===`text`?{contentType:n,text:e.responseText}:e.responseType===`json`?{contentType:n,text:JSON.stringify(e.response)}:{contentType:n}},Dd=(e,t,n,r,i)=>{if(i===void 0)return;let a=vd(e.maxSize),o=i.length>a,s={body:i.slice(0,a*2),contentType:r,kind:n,method:t.resource.method,statusCode:t.resource.statusCode,truncated:o,type:t.resource.type,url:t.resource.url},c=e.redact(s);if(c!==void 0)return{body:c.slice(0,a),contentType:r,truncated:o||c.length>a}},Od=function(){var e=W(function*({bodyConfig:e,domainContext:t,event:n,fetchRequest:r,occurredAt:i,runtimeContext:a,span:o}){var s,c;let l=n.resource.statusCode,u=l===void 0||l===0||l>=400;if(((s=e.capture)==null?`errors`:s)===`errors`&&!u)return;let d=vd(e.maxSize)*2,f=(c=e.allowedContentTypes)==null?_d:c,p={},m={};try{t.type===`fetch`?[p,m]=yield Promise.all([Cd(r==null?t.request:r,d),Td(t.response,d)]):(p={text:yield Sd(t.requestBody,d)},m=Ed(t.xhr))}catch(e){return}let h,g;try{h=yd(p.contentType,f,!0)?Dd(e,n,`request`,p.contentType,p.text):void 0,g=yd(m.contentType,f,!1)?Dd(e,n,`response`,m.contentType,m.text):void 0}catch(e){return}!h&&!g||a.emitLog({attributes:K(K(K({},n.attributes),h?{"request.body":h.body,"request.body.content_type":h.contentType,"request.body.truncated":h.truncated}:{}),g?{"response.body":g.body,"response.body.content_type":g.contentType,"response.body.truncated":g.truncated}:{}),body:`browser.request.body`,context:F.setSpan(N.active(),o),eventName:`browser.request.body`,severityNumber:u?Ii.ERROR:Ii.INFO,severityText:u?`ERROR`:`INFO`,timestamp:i})});return function(t){return e.apply(this,arguments)}}();q();var kd=e=>e.deliveryType===`cache`||e.transferSize===0&&e.decodedBodySize>0?!0:void 0,Ad=(...e)=>e.every((t,n)=>n===0||e[n-1]<=t),jd=(e,t,n,r,i)=>{Ad(n,r,i)&&(e[`resource.${t}.start`]=r-n,e[`resource.${t}.duration`]=i-r)},Md=e=>{let t={},n=[e.startTime,e.fetchStart,e.domainLookupStart,e.domainLookupEnd,e.connectStart,e.connectEnd,e.requestStart,e.responseStart,e.responseEnd];return!n.every(Number.isFinite)||!Ad(...n)?t:(jd(t,`first_byte`,e.startTime,e.requestStart,e.responseStart),jd(t,`download`,e.startTime,e.responseStart,e.responseEnd),e.workerStart>0&&e.workerStart<e.fetchStart&&jd(t,`worker`,e.startTime,e.workerStart,e.fetchStart),e.fetchStart<e.domainLookupEnd&&jd(t,`dns`,e.startTime,e.domainLookupStart,e.domainLookupEnd),e.fetchStart<e.connectEnd&&(jd(t,`connect`,e.startTime,e.connectStart,e.connectEnd),e.connectStart<=e.secureConnectionStart&&e.secureConnectionStart<=e.connectEnd&&jd(t,`ssl`,e.startTime,e.secureConnectionStart,e.connectEnd)),e.redirectEnd>e.startTime&&Ad(e.startTime,e.redirectStart,e.redirectEnd,e.fetchStart)&&jd(t,`redirect`,e.startTime,e.redirectStart,e.redirectEnd),t)},Nd=e=>e.duration===0&&e.responseEnd>e.startTime?e.responseEnd-e.startTime:e.duration,Pd=e=>{let t=typeof e.deliveryType==`string`?e.deliveryType||`other`:void 0;return K(K(K(K({[Y.transferSize]:e.transferSize,[Y.cacheHit]:kd(e),[Y.nextHopProtocol]:e.nextHopProtocol},Md(e)),t?{"resource.delivery_type":t}:{}),e.renderBlockingStatus?{"resource.render_blocking_status":e.renderBlockingStatus}:{}),{},{"resource.encoded_body_size":e.encodedBodySize,"resource.decoded_body_size":e.decodedBodySize})},Fd=(e=!0)=>{let t;return{name:`resource`,init(n){var r;if(typeof PerformanceObserver>`u`||!((r=PerformanceObserver.supportedEntryTypes)!=null&&r.includes(`resource`)))return;let i=t=>{if(!n.isSampled()||!t.name||ql(n.config,t.name))return;if(t.initiatorType===`fetch`||t.initiatorType===`xmlhttprequest`){md(t);return}if(t.duration<0)return;let r=n.config.hooks.redactUrl(t.name),i=Nd(t),a=performance.timeOrigin+t.startTime,o=a+i;e&&J(n,`traces`)&&n.startSpan(`browser.resource`,K(K(K({},n.config.hooks.getPageAttributes()),au({duration:i,initiatorType:t.initiatorType||`other`,responseStatus:t.responseStatus,transferSize:t.transferSize,url:r,urlPathTemplate:n.config.hooks.getViewPathGroup(t.name)})),{},{"url.full":r,initiator_type:t.initiatorType||`other`},Pd(t)),{startTime:a}).end(o),n.notifyActivity({endTime:o,startTime:a,type:`resource`,url:t.name})};try{t=new PerformanceObserver(e=>{for(let t of e.getEntries())i(t)}),t.observe({type:`resource`,buffered:!0})}catch(e){t=void 0}},shutdown(){t==null||t.disconnect(),t=void 0}}};q();var Id=e=>typeof e.config.tracking.request==`object`?e.config.tracking.request:void 0,Ld=e=>{if(e.type===`xhr`)return e.xhr.status;if(e.response)return e.response.status;if(typeof e.error==`object`&&e.error&&`status`in e.error){let t=e.error.status;return typeof t==`number`?t:void 0}},Rd=e=>typeof e==`string`||e instanceof URL?Ul(String(e)):Ul(e.url),zd=(e,t)=>{var n;return((n=t==null?void 0:t.method)==null?typeof Request<`u`&&e instanceof Request?e.method:`GET`:n).toUpperCase()},Bd=(e,t)=>typeof Request<`u`&&e instanceof Request?e:t==null?{}:t,Vd=(e,t,n)=>{var r;let i=typeof Request<`u`&&e instanceof Request?e.headers:void 0,a=new Headers((r=t==null?void 0:t.headers)==null?i:r);return nt.inject(F.setSpan(N.active(),n),a,{set:(e,t,n)=>e.set(t,n)}),K(K({},t),{},{headers:a})},Hd=(e,t)=>{let n={};nt.inject(F.setSpan(N.active(),t),n);for(let[t,r]of Object.entries(n))e.setRequestHeader(t,r)},Ud=(e,t)=>ql(e.config,t)||Yl(e.config.view.excludedActivityUrls,t),Wd=(e,t)=>{if(Ud(e,t))return()=>{};let n=Vl(`request`);e.notifyActivity({id:n,time:Date.now(),type:`request_start`,url:t});let r=!1;return()=>{r||(r=!0,e.notifyActivity({id:n,time:Date.now(),type:`request_end`}))}},Gd=(e,t)=>e.config.transport.traces===!1||!e.isSampled()?{cancel(){},complete(e){e()}}:hd(t),Kd=(e,t,n)=>{var r;return e.startSpan(`browser.resource`,K(K(K({},e.config.hooks.getPageAttributes()),au({initiatorType:t,method:n.method,url:(r=n.url)==null?``:r,urlPathTemplate:n.url?e.config.hooks.getViewPathGroup(n.url):void 0})),n.url?{"resource.url":e.config.hooks.redactUrl(n.url)}:{}),{kind:Ue.CLIENT})},qd=(e,t,n,r,i={},a)=>{var o;let s=i.url,c=s?e.config.hooks.redactUrl(s):void 0,l=Ld(r),u=i.method,d={attributes:K(K(K({},e.config.hooks.getPageAttributes()),au({initiatorType:n,method:u,networkError:r.type===`fetch`?!r.response:r.xhr.status===0,responseStatus:l,url:c==null?``:c,urlPathTemplate:s?e.config.hooks.getViewPathGroup(s):void 0})),c?{"resource.url":c,"url.full":c}:{}),resource:{method:u,statusCode:l,type:n,url:c},type:`resource`},f=!0;try{var p,m;f=(p=Id(e))==null||(m=p.beforeSend)==null?void 0:m.call(p,d,r)}catch(t){var h;e.config.debug&&((h=globalThis.console)==null||h.warn(`[bk-ot] request.beforeSend failed:`,t))}if(t.setAttributes(e.applyRedact(d.attributes)),f===!1){t.setAttribute($u,!0);return}((l==null?0:l)>=400||l===0||r.type===`fetch`&&r.error)&&t.setStatus({code:We.ERROR});let g=e.config.transport.logs===!1||(o=Id(e))==null?void 0:o.body;g&&Od({bodyConfig:g,domainContext:r,event:d,fetchRequest:a,occurredAt:i.startedAt,runtimeContext:e,span:t})},Jd=e=>{let t=[],n=new Set;return{name:`request`,enabled:e!==!1,init(e){if(!(typeof window>`u`)){if(typeof window.fetch==`function`){let r=window.fetch,i=function(){var t=W(function*(t,i){var a;let o=Rd(t);if(!e.isSampled()||Zl(e.config,o))return r.call(this,t,i);let s={method:zd(t,i),startedAt:Date.now(),url:o},c=Kd(e,`fetch`,s),l=Gd(e,o),u=Wd(e,o),d=Bd(t,i),f=e.config.transport.logs!==!1&&(a=Id(e))!=null&&a.body?wd(d):void 0,p=Ql(e.config,o)?Vd(t,i,c):i,m=!1,h=t=>{m||(m=!0,n.delete(g),t&&c.setAttributes(e.applyRedact(Pd(t))),c.end())},g=()=>{l.cancel(),h()};n.add(g);try{let n=yield r.call(this,t,p);return qd(e,c,`fetch`,{request:d,response:n,type:`fetch`},s,f),l.complete(h),n}catch(t){throw qd(e,c,`fetch`,{error:t,request:d,type:`fetch`},s,f),t instanceof Error&&c.recordException(t),l.complete(h),t}finally{u()}});return function(e,n){return t.apply(this,arguments)}}();window.fetch=i,t.push(()=>{window.fetch===i&&(window.fetch=r)})}if(typeof XMLHttpRequest<`u`){let r=new WeakMap,i=XMLHttpRequest.prototype.open,a=XMLHttpRequest.prototype.send,o=function(e,t,n=!0,a,o){return r.set(this,{method:e.toUpperCase(),url:Ul(String(t))}),i.call(this,e,String(t),n,a,o)},s=function(t){var i;let o=(i=r.get(this))==null?{}:i;if(!e.isSampled()||!o.url||Zl(e.config,o.url))return a.call(this,t);o.startedAt=Date.now();let s=Kd(e,`xhr`,o),c=Gd(e,o.url),l=Wd(e,o.url);Ql(e.config,o.url)&&Hd(this,s);let u=!1,d=()=>{c.cancel(),!u&&(u=!0,n.delete(d),l(),s.end())};n.add(d);let f=()=>{u||(qd(e,s,`xhr`,{requestBody:t,type:`xhr`,xhr:this},o),l(),c.complete(t=>{u||(u=!0,n.delete(d),t&&s.setAttributes(e.applyRedact(Pd(t))),s.end())}))};this.addEventListener(`loadend`,f,{once:!0});try{return a.call(this,t)}catch(e){throw e instanceof Error&&s.recordException(e),f(),e}};XMLHttpRequest.prototype.open=o,XMLHttpRequest.prototype.send=s,t.push(()=>{XMLHttpRequest.prototype.open===o&&(XMLHttpRequest.prototype.open=i),XMLHttpRequest.prototype.send===s&&(XMLHttpRequest.prototype.send=a)})}}},shutdown(){var e;for(let e of[...n])e();for(;t.length;)(e=t.pop())==null||e()}}},Yd=e=>{let t=5381;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);return(t>>>0).toString(36)},Xd=(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})}}};q();var Zd=6e4,Qd=5,$d=/^https?:|^\/\//i,ef=(e,t)=>{if(t)return $d.test(t)?e(t):t},tf=()=>{let e;return{name:`csp-violation`,init(t){if(typeof window>`u`||typeof document>`u`)return;let n=Xd(Zd,Qd),r=t.meter.createCounter(`browser.csp_violation.count`,{description:`Total number of CSP violations before span throttling`}),i=e=>{let i=J(t,`metrics`),a=J(t,`traces`);if(!i&&!a||(i&&r.add(1,t.applyRedact(K(K(K({},t.config.hooks.getMetricAttributes()),Lu(t.getRuntimeAttributes())),{},{"csp.disposition":e.disposition,"csp.effective_directive":e.effectiveDirective}))),!a))return;let o=Yd(`${e.violatedDirective}|${e.blockedURI}|${e.sourceFile}|${e.lineNumber}`),s=n.allow(o);if(!s.allowed)return;let c=ef(t.config.hooks.redactUrl,e.blockedURI),l=e.sourceFile?t.config.hooks.redactUrl(e.sourceFile):void 0,u=s.count===1;t.startSpan(`csp.violation`,K(K(K({},t.config.hooks.getPageAttributes()),Q({errorType:`csp`,eventLabel:`CSP 错误`,result:X.error,spanSubtype:`csp`,spanType:Z.error,targetLabel:c==null?e.effectiveDirective:c,targetValue:e.statusCode})),{},{"csp.blocked_uri":c,"csp.violated_directive":e.violatedDirective,"csp.effective_directive":e.effectiveDirective,"csp.disposition":e.disposition,"csp.source_file":l,"csp.line_number":e.lineNumber,"csp.column_number":e.columnNumber,"csp.status_code":e.statusCode,"csp.fingerprint":o,"csp.window_occurrence_index":s.count,[Y.exceptionFingerprint]:o,"error.source":`csp`},u?{"csp.original_policy":e.originalPolicy}:{})).end()};document.addEventListener(`securitypolicyviolation`,i),e=()=>document.removeEventListener(`securitypolicyviolation`,i)},shutdown(){e==null||e(),e=void 0}}};q();var nf=`BK_RUM_DEVICE_ID`,rf=250,af=()=>navigator.connection,of=()=>navigator.userAgentData,sf=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}},cf=(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`},lf=e=>{let t=null;try{t=window.localStorage.getItem(e)}catch(e){}if(t)return t;let n=Vl(`device`);try{window.localStorage.setItem(e,n)}catch(e){}return n},uf=()=>{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}},df=()=>{let e=af();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}:{}},ff=()=>{if(typeof navigator>`u`)return{};let e=of(),t=navigator.userAgent,n=sf(t),r=cf(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,[Y.browserName]:n.name,[Y.browserVersion]:n.version,[Y.deviceType]:i,[Y.osName]:r}},pf=(e,t)=>{let n;return()=>{n!==void 0&&window.clearTimeout(n),n=window.setTimeout(()=>{n=void 0,e()},t)}},mf=(e={})=>{let t=[];return{name:`device`,init(n){var r;let i=(r=e.storageKey)==null?`${nf}_${Yd(n.config.application.name)}`:r,a=typeof window>`u`||e.persistentId!==!0?Vl(`device`):lf(i);if(n.setRuntimeAttributes(K(K(K({"device.id":a},ff()),uf()),df())),typeof window>`u`)return;let o=pf(()=>{n.setRuntimeAttributes(uf())},rf);window.addEventListener(`resize`,o),window.addEventListener(`orientationchange`,o),t.push(()=>window.removeEventListener(`resize`,o),()=>window.removeEventListener(`orientationchange`,o));let s=af();if(s&&typeof s.addEventListener==`function`){let e=()=>{n.setRuntimeAttributes(df())};s.addEventListener(`change`,e),t.push(()=>{var t;(t=s.removeEventListener)==null||t.call(s,`change`,e)})}},shutdown(){for(;t.length;){var e;(e=t.pop())==null||e()}}}};q();var hf=6e4,gf=5,_f=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>0?e:t,vf=e=>{if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch(t){return String(e)}},yf=e=>{var t;return e instanceof Error?(t=e.stack)==null?``:t:``},bf=e=>e.slice(0,80),xf=e=>{var t,n;return(t=(n=e.split(`
|
|
12
|
+
`).find(e=>e.trim().startsWith(`at `)))==null?void 0:n.trim())==null?``:t},Sf=e=>e===`unhandledrejection`?`promise`:e===`resource`?`resource_load`:`js`,Cf=({context:e,counter:t,error:n,exceptionType:r,extra:i={},source:a,spanName:o,throttle:s})=>{let c=J(e,`metrics`),l=J(e,`traces`);if(!c&&!l)return;let u=vf(n),d=yf(n),f=Yd(`${a}|${u}|${d.slice(0,256)}`);if(c&&t.add(1,e.applyRedact(K(K(K({},e.config.hooks.getMetricAttributes()),Lu(e.getRuntimeAttributes())),{},{"error.source":a,"error.subtype":Sf(a)}))),!l)return;e.notifyActivity({time:Date.now(),type:`error`});let p=s.allow(f);if(!p.allowed)return;let m=n instanceof Error?n:{message:u,name:r==null?a:r},h=K(K(K(K({},e.config.hooks.getPageAttributes()),e.config.hooks.getErrorAttributes()),Q({errorType:Sf(a),eventLabel:`错误`,result:X.error,spanSubtype:Sf(a),spanType:Z.error,targetLabel:n instanceof Error?n.name:r==null?a:r})),{},{[Y.exceptionMessageShort]:bf(u),[Y.exceptionStackTopFrame]:xf(d),[Y.exceptionFingerprint]:f,"error.handled":!1,"error.source":a,"error.window_occurrence_index":p.count},i),g=e.startSpan(o,h);g.recordException(m),g.setStatus({code:We.ERROR,message:u}),g.end()},wf=(e={})=>{let t=[],n=_f(e.windowMs,hf),r=_f(e.maxPerWindow,gf);return{name:`error`,init(e){if(typeof window>`u`)return;let i=Xd(n,r),a=e.meter.createCounter(`browser.error.count`,{description:`Total number of browser errors before span throttling`}),o=t=>{var n;let r=!t.error&&!t.filename&&t.message===`Script error.`;Cf({context:e,counter:a,throttle:i,spanName:`browser.error`,source:`window.error`,error:(n=t.error)==null?t.message:n,extra:K({"code.filepath":t.filename,"code.lineno":t.lineno,"code.column":t.colno},r?{"error.cross_origin":!0}:{})})},s=t=>{Cf({context:e,counter:a,throttle:i,spanName:`browser.unhandledrejection`,source:`unhandledrejection`,error:t.reason,exceptionType:t.reason instanceof Error?t.reason.name:`UnhandledRejection`})},c=t=>{if(t instanceof ErrorEvent)return;let n=t.target;if(!(n instanceof Element))return;let r=n,o=r.src||r.href||n.currentSrc||``;Cf({context:e,counter:a,throttle:i,spanName:`browser.resource_error`,source:`resource`,error:Error(`Resource load failed: ${n.tagName.toLowerCase()} ${o}`),exceptionType:`ResourceError`,extra:{"url.full":e.config.hooks.redactUrl(o),"html.tag":n.tagName}})};window.addEventListener(`error`,o),window.addEventListener(`unhandledrejection`,s),window.addEventListener(`error`,c,!0),t.push(()=>window.removeEventListener(`error`,o),()=>window.removeEventListener(`unhandledrejection`,s),()=>window.removeEventListener(`error`,c,!0))},shutdown(){for(;t.length;){var e;(e=t.pop())==null||e()}}}},Tf=[0,.01,.025,.05,.075,.1,.15,.25,.5,1],Ef=[0,50,100,200,300,500,800,1e3,1500,2e3,2500,4e3,5e3,1e4];q();var Df=50,Of=100,kf=700,Af=(e,t)=>typeof e==`number`&&Number.isFinite(e)&&e>=0?e:t,jf=e=>Number.isFinite(e)?e:void 0,Mf=(e,t)=>{var n;let r=(n=e.attribution)==null?void 0:n[0];return r!=null&&r.containerSrc?t(r.containerSrc):(r==null?void 0:r.containerName)||(r==null?void 0:r.name)||e.name||`unknown`},Nf=(e,t)=>({"long_task.script.duration":e.duration,"long_task.script.execution_start":e.executionStart,"long_task.script.forced_style_and_layout_duration":e.forcedStyleAndLayoutDuration,"long_task.script.invoker":e.invoker,"long_task.script.invoker_type":e.invokerType,"long_task.script.pause_duration":e.pauseDuration,"long_task.script.source_char_position":e.sourceCharPosition,"long_task.script.source_function_name":e.sourceFunctionName,"long_task.script.source_url":e.sourceURL?t(e.sourceURL):``,"long_task.script.start_time":e.startTime,"long_task.script.window_attribution":e.windowAttribution}),Pf=(e={})=>{let t=Af(e.threshold,Df),n=Math.max(t,Af(e.warningThreshold,Of)),r,i,a=[];return{name:`long-task`,init(e){var o;if(typeof PerformanceObserver>`u`||typeof performance>`u`)return;let s=(o=PerformanceObserver.supportedEntryTypes)==null?[]:o,c=s.includes(`long-animation-frame`)?`long-animation-frame`:s.includes(`longtask`)?`longtask`:void 0;if(!c)return;let l=e.meter.createCounter(`browser.long_task.count`,{description:`Number of long tasks and long animation frames`}),u=e.meter.createHistogram(`browser.long_task.duration`,{description:`Duration of long tasks and long animation frames`,unit:`ms`,advice:{explicitBucketBoundaries:Ef}}),d=e.meter.createHistogram(`browser.long_task.blocking_duration`,{description:`Blocking duration of long animation frames`,unit:`ms`,advice:{explicitBucketBoundaries:Ef}}),f=r=>{var i;let a=J(e,`metrics`),o=J(e,`traces`);if(!a&&!o||!Number.isFinite(r.duration)||r.duration<t)return;let s=r.entryType===`long-animation-frame`,c=s?r:void 0,f=(i=c==null?void 0:c.scripts)==null?[]:i,p=f.reduce((e,t)=>!e||t.duration>e.duration?t:e,void 0),m=Vl(`long-task`),h=performance.timeOrigin+r.startTime,g=h+r.duration,_=r.duration>=n?X.warning:X.success,v=s?`long-animation-frame`:`long-task`,y=p!=null&&p.sourceURL?e.config.hooks.redactUrl(p.sourceURL):void 0,b=s?void 0:Mf(r,e.config.hooks.redactUrl),x=y||(p==null?void 0:p.sourceFunctionName)||b||`unknown`;if(o){var S,C;let t=e.startSpan(`browser.long_task`,K(K(K(K(K(K(K(K({},e.config.hooks.getPageAttributes()),Q({duration:r.duration,errorType:_===X.warning?`main_thread_blocked`:`none`,eventLabel:s?`长动画帧`:`长任务`,result:_,spanSubtype:v,spanType:Z.longtask,targetLabel:x,targetValue:(S=c==null?void 0:c.blockingDuration)==null?r.duration:S})),{},{[Y.longTaskBlockingDuration]:(C=c==null?void 0:c.blockingDuration)==null?r.duration:C,[Y.longTaskDuration]:r.duration,[Y.longTaskEntryType]:v,[Y.longTaskId]:m,[Y.longTaskIsFrozenFrame]:r.duration>=kf,[Y.longTaskScriptCount]:f.length},b?{[Y.longTaskCulprit]:b}:{}),p?{[Y.longTaskCulprit]:x,"long_task.culprit.duration":p.duration,"long_task.culprit.forced_style_and_layout_duration":p.forcedStyleAndLayoutDuration,"long_task.culprit.function_name":p.sourceFunctionName,"long_task.culprit.invoker_type":p.invokerType}:{}),jf(c==null?void 0:c.firstUIEventTimestamp)===void 0?{}:{"long_task.first_ui_event_timestamp":c.firstUIEventTimestamp}),jf(c==null?void 0:c.renderStart)===void 0?{}:{"long_task.render_start":c.renderStart}),jf(c==null?void 0:c.styleAndLayoutStart)===void 0?{}:{"long_task.style_and_layout_start":c.styleAndLayoutStart}),c?{[Y.longTaskStartTime]:c.startTime}:{}),{startTime:h});f.forEach(n=>{t.addEvent(`long_task.script`,e.applyRedact(Nf(n,e.config.hooks.redactUrl)),performance.timeOrigin+n.startTime)}),t.end(g),e.notifyActivity({endTime:g,startTime:h,type:`long_task`})}if(a){let t=e.applyRedact(K(K(K({},e.config.hooks.getMetricAttributes()),Lu(e.getRuntimeAttributesAt(h))),{},{[Y.longTaskEntryType]:v}));l.add(1,t),u.record(r.duration,t),c&&d.record(c.blockingDuration,t)}},p=e=>e.forEach(e=>f(e));try{let e=!0;r=new PerformanceObserver(t=>{let n=t.getEntries();e?(a.push(...n),i||(i=setTimeout(()=>{let e=a;a=[],i=void 0,p(e)}))):p(n)}),r.observe({type:c,buffered:!0}),e=!1}catch(e){r=void 0}},shutdown(){r==null||r.disconnect(),r=void 0,clearTimeout(i),i=void 0,a=[]}}},Ff=new Set,If=``,Lf,Rf,zf=!1,Bf=()=>typeof location>`u`?``:location.href,Vf=(e,t)=>{let n=Bf();If=n;let r={fromUrl:t,source:e,toUrl:n};for(let e of Array.from(Ff))e(r)},Hf=()=>{Vf(`popstate`,If||Bf())},Uf=()=>{Vf(`hashchange`,If||Bf())},Wf=()=>{zf||typeof window>`u`||typeof history>`u`||(zf=!0,If=Bf(),Lf=history.pushState,Rf=history.replaceState,history.pushState=function(e,t,n){let r=If||Bf(),i=Lf==null?void 0:Lf.apply(this,[e,t,n]);return Vf(`pushState`,r),i},history.replaceState=function(e,t,n){let r=If||Bf(),i=Rf==null?void 0:Rf.apply(this,[e,t,n]);return Vf(`replaceState`,r),i},window.addEventListener(`popstate`,Hf),window.addEventListener(`hashchange`,Uf))},Gf=()=>{!zf||typeof window>`u`||typeof history>`u`||(Lf&&(history.pushState=Lf),Rf&&(history.replaceState=Rf),window.removeEventListener(`popstate`,Hf),window.removeEventListener(`hashchange`,Uf),Lf=void 0,Rf=void 0,zf=!1,If=``)},Kf=e=>typeof window>`u`||typeof history>`u`?()=>{}:(Wf(),Ff.add(e),()=>{Ff.delete(e),Ff.size===0&&Gf()});q();var qf=[`span`,`stopLoadingTime`],Jf=new Set([...Object.values(Y),$]),Yf=()=>typeof location>`u`?``:location.href,Xf=()=>{if(typeof performance>`u`)return{};let e=performance.getEntriesByType(`navigation`)[0];if(!e)return{};let t={},n=(e,n)=>{Number.isFinite(n)&&n>0&&(t[e]=n)};return n(Y.viewFirstByte,e.responseStart),n(Y.viewDomInteractive,e.domInteractive),n(Y.viewDomContentLoaded,e.domContentLoadedEventEnd),n(Y.viewDomComplete,e.domComplete),n(Y.viewLoadEvent,e.loadEventEnd),t},Zf=e=>{let t=e.indexOf(`?`);return t<0?e:e.slice(0,t)},Qf=e=>{let t=e.slice(1);if(!t||typeof document>`u`||typeof document.getElementById!=`function`)return!1;try{return!!document.getElementById(decodeURIComponent(t))}catch(e){return!!document.getElementById(t)}},$f=(e,t)=>{try{let n=typeof location>`u`?`http://localhost`:location.href,r=new URL(e,n),i=new URL(t,n);return r.pathname!==i.pathname||!Qf(i.hash)&&Zf(r.hash)!==Zf(i.hash)}catch(n){return e!==t}},ep=()=>{let e=[];return{name:`page-view`,init(t){if(typeof window>`u`)return;let n,r,i=t.config.view.loadingTime?t.meter.createHistogram(`browser.view.loading_time`,{description:`Time from view start until network and DOM activity become idle`,unit:`ms`,advice:{explicitBucketBoundaries:Ef}}):void 0,a=(e=Date.now())=>t.setView({},e),o=(e,n,r=Date.now(),i)=>{J(t,`logs`)&&(e.documentVersion+=1,t.emitLog({attributes:K(K(K(K(K({},t.config.hooks.getPageAttributes()),e.attributes),e.snapshotAttributes),{},{"event.type":`view`,"view.document_version":e.documentVersion,"view.duration":Math.max(0,r-e.startedAt),"view.is_active":n!==`final`,"view.snapshot.type":n},i?{"view.end_reason":i}:{}),e.loadingTime===void 0?{}:{[Y.viewLoadingTime]:e.loadingTime,"view.loading_time.source":e.loadingTimeSource}),body:`browser.view`,eventName:`browser.view`,severityNumber:Ii.INFO,severityText:`INFO`,timestamp:r}))},s=(e,r=!0,s=Date.now())=>{var c;if(!n){r&&a(s);return}let l=K({},n);(c=n.stopLoadingTime)==null||c.call(n),n.loadingTime!==void 0&&J(t,`metrics`)&&(i==null||i.record(n.loadingTime,t.applyRedact(K(K(K({},t.config.hooks.getMetricAttributes()),Lu(t.getRuntimeAttributes())),{},{"view.loading_type":n.loadingType})))),o(n,`final`,s,e),n.span.setAttribute(`view.end_reason`,e),n.span.end(s),n=void 0,r&&a(s);let{span:u,stopLoadingTime:d}=l;return Mu(l,qf)},c=(e,t,r)=>{if(n!==e||!Number.isFinite(t)||t<0)return;let i=K(K({},e.loadingType===`initial_load`?Xf():{}),{},{[Y.viewLoadingTime]:t,"view.loading_time.source":r});e.span.setAttributes(i),Object.assign(e.snapshotAttributes,i),e.loadingTime=t,e.loadingTimeSource=r,o(e,`update`)},l=e=>{if(!t.config.view.loadingTime||document.visibilityState===`hidden`)return;let r=!1,i,a=e.loadingType!==`initial_load`,o,s,l=!1,u,d=()=>{var t;if(l||!r||!a||n!==e)return;let s=[i,o].filter(e=>e!==void 0);s.length&&c(e,Math.max(...s),`auto`),(t=e.stopLoadingTime)==null||t.call(e),e.stopLoadingTime=void 0},f=()=>{var t,n;let r=(t=(n=performance).getEntriesByType)==null?void 0:t.call(n,`navigation`)[0];return r!=null&&r.loadEventEnd?(o=Math.max(0,performance.timeOrigin+r.loadEventEnd-e.startedAt),a=!0,!0):!1};if(!a&&!f()){let t=()=>{setTimeout(()=>{n===e&&(f(),a=!0,d())})};window.addEventListener(`load`,t,{once:!0}),s=()=>window.removeEventListener(`load`,t)}let p=Ou(t,e.startedAt,t=>{r=!0,t.hadActivity&&(i=Math.max(0,t.endTime-e.startedAt)),d()}),m=()=>{var t;document.visibilityState===`hidden`&&(l=!0,(t=e.stopLoadingTime)==null||t.call(e),e.stopLoadingTime=void 0)};document.addEventListener(`visibilitychange`,m),u=()=>document.removeEventListener(`visibilitychange`,m),e.stopLoadingTime=()=>{p(),s==null||s(),s=void 0,u==null||u(),u=void 0},d()},u=e=>{let n=t.applyRedact(e==null?{}:e);return Object.fromEntries(Object.entries(n).filter(([e,t])=>t!==void 0&&!Jf.has(e)))},d=(e,r,i,a=(e=>(e=n==null?void 0:n.rawUrl)==null?``:e)())=>{var c,d;if(!t.isSessionActive())return;let f=(c=e.url)==null?Yf():c,p=t.config.hooks.getViewPathGroup(f),m=(d=e.name)==null?p:d,h=u(e.attributes);s(r,!1);let g=Vl(`view`),_=t.config.hooks.redactUrl(f),v=t.config.hooks.redactUrl(a),y=i===`initial_load`,b=y&&typeof performance<`u`?performance.timeOrigin:Date.now(),x=y?Xf():{};t.setView({attributes:h,id:g,loadingType:i,name:m,startedAt:b,url:_,urlPathGroup:p},b);let S=K(K(K(K(K({},h),t.config.hooks.getPageAttributes()),x),Q({errorType:`none`,eventLabel:y?`文档加载`:`路由切换`,spanSubtype:y?`navigate`:r,spanType:y?Z.document:Z.route,targetLabel:p,traceScene:y?`page_load`:`route_change`})),{},{[Y.viewId]:g,[Y.viewName]:m,[Y.viewUrl]:_,[Y.viewUrlPathGroup]:p,[Y.viewLoadingType]:i,"url.previous":v,"event.source":r},y?{"document.referrer":t.config.hooks.redactUrl(document.referrer||``)}:{});n={attributes:h,documentVersion:0,id:g,loadingType:i,name:m,rawUrl:f,snapshotAttributes:S,span:t.startSpan(`browser.view`,S,{startTime:b}),startedAt:b,url:_,urlPathGroup:p},o(n,`create`,b),l(n)},f=t.onViewCommand(e=>{if(e.type===`start`){d(e.options,`manual`,n?`route_change`:`initial_load`);return}if(n){if(e.type===`set_loading_time`){var r;(r=n.stopLoadingTime)==null||r.call(n),n.stopLoadingTime=void 0,c(n,Math.max(0,e.time-n.startedAt),`manual`);return}n.name!==e.name&&(n.name=e.name,n.span.setAttribute(Y.viewName,e.name),n.snapshotAttributes[Y.viewName]=e.name,t.setView({attributes:n.attributes,id:n.id,loadingType:n.loadingType,name:n.name,startedAt:n.startedAt,url:n.url,urlPathGroup:n.urlPathGroup}),o(n,`update`))}}),p=()=>{};t.config.view.tracking===`auto`&&(n||d({},`load`,`initial_load`),p=Kf(e=>{$f(e.fromUrl,e.toUrl)&&d({},e.source,`route_change`,e.fromUrl)}));let m=e=>{e.persisted||s(`pagehide`)},h=e=>{e.persisted&&t.config.view.tracking===`auto`&&d({},`bfCache`,`bf_cache`,n==null?void 0:n.rawUrl)},g=t.onSessionLifecycle(e=>{if(e.type===`expired`){r=s(`session_expired`,!0,e.expiredAt);return}r&&(d({attributes:r.attributes,name:r.name,url:r.rawUrl},`sessionRenewal`,`session_renewal`,r.rawUrl),r=void 0)});window.addEventListener(`pagehide`,m),window.addEventListener(`pageshow`,h),e.push(p,g,f,()=>window.removeEventListener(`pagehide`,m),()=>window.removeEventListener(`pageshow`,h),()=>s(`shutdown`))},shutdown(){for(;e.length;){var t;(t=e.pop())==null||t()}}}};q();var tp=5e3,np=e=>typeof e==`number`&&Number.isFinite(e)&&e>0,rp=(e,t,n,r)=>({expiresAt:Math.min(t+n,t+r),id:e,startedAt:t,status:`active`}),ip=(e,t,n)=>{if(t>=e.startedAt+n)return`maxLifetime`;if(t>=e.expiresAt)return`inactivity`},ap=(e,t,n,r)=>K(K({},e),{},{expiresAt:Math.min(t+n,e.startedAt+r)}),op=(e,t,n)=>{if(!e)return null;try{let r=JSON.parse(e);if(r.status===`active`&&typeof r.id==`string`&&r.id.length>0&&np(r.startedAt)&&r.startedAt<=t+tp&&np(r.expiresAt)&&r.expiresAt>=r.startedAt&&r.expiresAt<=r.startedAt+n||r.status===`expired`&&typeof r.previousId==`string`&&r.previousId.length>0&&(r.reason===`inactivity`||r.reason===`maxLifetime`)&&np(r.expiredAt)&&r.expiredAt<=t+tp)return r}catch(e){}return null};q();var sp=900*1e3,cp=14400*1e3,lp=1e3,up=6e4,dp=[`click`,`keydown`,`scroll`,`touchstart`],fp=new Map,pp=e=>{let t=typeof window<`u`,n=()=>{var n;if(t)try{return window.localStorage.getItem(e)}catch(e){t=!1}return(n=fp.get(e))==null?null:n};return n(),{isLocalStorage:()=>t,read:n,write:n=>{let r=JSON.stringify(n);if(fp.set(e,r),t)try{window.localStorage.setItem(e,r)}catch(e){t=!1}}}},mp=(e,t)=>{let n=``;try{n=new URL(e).host}catch(t){n=e}return`bk_ot_session__${Yd(`${t}\0${n||`default`}`)}`},hp=(e,t)=>{t.reason&&e.emitLog({severityNumber:Ii.INFO,severityText:`INFO`,body:t.reason===`init`?`session.start`:`session.rotate`,attributes:K(K({},e.config.hooks.getPageAttributes()),{},{[Y.sessionHasReplay]:!1,[Y.sessionId]:t.record.id,[Y.sessionStartTime]:t.record.startedAt,"session.rotate.reason":t.reason},t.previousId?{"session.previous_id":t.previousId}:{})})},gp=(e={})=>{let t=[];return{name:`session`,init(n){var r;if(typeof window>`u`||typeof document>`u`){n.setRuntimeAttributes({[Y.sessionHasReplay]:!1,[Y.sessionId]:Vl(`session`)});return}let i=(r=e.storageKey)==null?mp(n.config.transport.endpoint,n.config.application.name):r,a=pp(i),o=typeof performance<`u`&&Number.isFinite(performance.timeOrigin)?performance.timeOrigin:Date.now(),s,c,l=(e=Date.now())=>op(a.read(),e,cp),u=()=>{c!==void 0&&(clearTimeout(c),c=void 0)},d=(e,t=Date.now())=>{let r=s;r&&(n.notifySessionLifecycle({expiredAt:t,id:r,reason:e,type:`expired`}),u(),s=void 0,n.setRuntimeAttributes({[Y.sessionHasReplay]:void 0,[Y.sessionId]:void 0},t),n.flush())},f=()=>{let e=Date.now(),t=l(e);if(!t){d(`external`,e);return}if(t.status===`expired`){d(t.reason,t.expiredAt);return}if(t.id!==s){d(`external`,e);return}let n=ip(t,e,cp);if(!n){p(t);return}let r={expiredAt:e,previousId:t.id,reason:n,status:`expired`};a.write(r),d(n,e)},p=e=>{u();let t=Math.min(e.expiresAt,e.startedAt+cp);c=setTimeout(f,Math.max(0,t-Date.now()))},m=(e,t)=>{let r=e.id!==s;s=e.id,n.setRuntimeAttributes({[Y.sessionHasReplay]:!1,[Y.sessionId]:e.id},Math.min(e.startedAt,o)),p(e),r&&t&&n.notifySessionLifecycle({id:e.id,previousId:t.previousId,reason:t.reason,startedAt:e.startedAt,type:`renewed`})},h=(e=!1)=>{let t=Date.now(),r=l(t);if((r==null?void 0:r.status)===`active`&&!ip(r,t,cp)){let e=ap(r,t,sp,cp);a.write(e),m(e,s?void 0:{reason:`shared`});return}let i=(r==null?void 0:r.status)===`expired`?r.previousId:r==null?void 0:r.id,o=(r==null?void 0:r.status)===`expired`?r.reason:r?ip(r,t,cp):e?`init`:void 0,c=rp(Vl(`session`),t,sp,cp);a.write(c),m(c,{previousId:i,reason:o==null?`init`:o}),hp(n,{previousId:i,reason:o==null?`init`:o,record:c})},g=()=>{if(!s)return;let e=Date.now(),t=l(e);if((t==null?void 0:t.status)!==`active`||t.id!==s||ip(t,e,cp)){f();return}let n=ap(t,e,sp,cp);a.write(n),m(n)};h(!0);let _=0,v=()=>{let e=Date.now();e-_<lp||(_=e,h())},y={capture:!0,passive:!0};dp.forEach(e=>window.addEventListener(e,v,y)),t.push(()=>{dp.forEach(e=>window.removeEventListener(e,v,y))});let b=()=>{document.visibilityState===`visible`&&g()};document.addEventListener(`visibilitychange`,b);let x=window.setInterval(b,up);t.push(()=>{document.removeEventListener(`visibilitychange`,b),window.clearInterval(x)});let S=e=>{if(!a.isLocalStorage()||e.storageArea!==window.localStorage||e.key!==i)return;let t=Date.now(),n=op(e.newValue,t,cp);if((n==null?void 0:n.status)===`active`&&n.id===s&&!ip(n,t,cp)){p(n);return}d((n==null?void 0:n.status)===`expired`?n.reason:`external`,(n==null?void 0:n.status)===`expired`?n.expiredAt:t)};window.addEventListener(`storage`,S),t.push(()=>window.removeEventListener(`storage`,S)),t.push(u)},shutdown(){for(var e;t.length;)(e=t.pop())==null||e()}}},_p=n({CLSThresholds:()=>Hp,FCPThresholds:()=>Bp,INPThresholds:()=>nm,LCPThresholds:()=>am,TTFBThresholds:()=>sm,onCLS:()=>Wp,onFCP:()=>Gp,onINP:()=>rm,onLCP:()=>om,onTTFB:()=>lm});function vp(e,t){return wp.get(e)||wp.set(e,new t),wp.get(e)}var yp,bp,xp,Sp,Cp,wp,Tp,Ep,Dp,Op,kp,Ap,jp,Mp,Np,Pp,Fp,Ip,Lp,Rp,zp,Bp,Vp,Hp,Up,Wp,Gp,Kp,qp,Jp,Yp,Xp,Zp,Qp,$p,em,tm,nm,rm,im,am,om,sm,cm,lm,um=t((()=>{L(),q(),yp=class{constructor(){I(this,`t`,void 0),I(this,`o`,0),I(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)}},bp=()=>{let e=performance.getEntriesByType(`navigation`)[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},xp=e=>{if(document.readyState===`loading`)return`loading`;let t=bp();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`},Sp=e=>{let t=e.nodeName;return e.nodeType===1?t.toLowerCase():t.toUpperCase().replace(/^#/,``)},Cp=e=>{let t=``;try{for(;(e==null?void 0:e.nodeType)!==9;){let n=e,r=n.id?`#`+n.id:[Sp(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},wp=new WeakMap,Tp=-1,Ep=()=>Tp,Dp=e=>{addEventListener(`pageshow`,t=>{t.persisted&&(Tp=t.timeStamp,e(t))},!0)},Op=(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)))}},kp=e=>{requestAnimationFrame(()=>requestAnimationFrame(e))},Ap=()=>{var e,t;return(e=(t=bp())==null?void 0:t.activationStart)==null?0:e},jp=(e,t=-1)=>{let n=bp(),r=`navigate`;return Ep()>=0?r=`back-forward-cache`:n&&(document.prerendering||Ap()>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}},Mp=(e,t,n={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){let r=new PerformanceObserver(e=>{queueMicrotask(()=>{t(e.getEntries())})});return r.observe(K({type:e,buffered:!0},n)),r}}catch(e){}},Np=e=>{let t=!1;return()=>{t||(e(),t=!0)}},Pp=-1,Fp=new Set,Ip=()=>document.visibilityState!==`hidden`||document.prerendering?1/0:0,Lp=e=>{if(document.visibilityState===`hidden`){if(e.type===`visibilitychange`)for(let e of Fp)e();isFinite(Pp)||(Pp=e.type===`visibilitychange`?e.timeStamp:0,removeEventListener(`prerenderingchange`,Lp,!0))}},Rp=()=>{if(Pp<0){var e;let t=Ap(),n=document.prerendering||(e=globalThis.performance.getEntriesByType(`visibility-state`).find(e=>e.name===`hidden`&&e.startTime>=t))==null?void 0:e.startTime;Pp=n==null?Ip():n,addEventListener(`visibilitychange`,Lp,!0),addEventListener(`prerenderingchange`,Lp,!0),Dp(()=>{setTimeout(()=>{Pp=Ip()})})}return{get firstHiddenTime(){return Pp},onHidden(e){Fp.add(e)}}},zp=e=>{document.prerendering?addEventListener(`prerenderingchange`,e,!0):e()},Bp=[1800,3e3],Vp=(e,t={})=>{zp(()=>{let n=Rp(),r,i=jp(`FCP`),a=Mp(`paint`,e=>{for(let t of e)t.name===`first-contentful-paint`&&(a.disconnect(),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-Ap(),0),i.entries.push(t),r(!0)))});a&&(r=Op(e,i,Bp,t.reportAllChanges),Dp(n=>{i=jp(`FCP`),r=Op(e,i,Bp,t.reportAllChanges),kp(()=>{i.value=performance.now()-n.timeStamp,r(!0)})}))})},Hp=[.1,.25],Up=e=>e.find(e=>{var t;return((t=e.node)==null?void 0:t.nodeType)===1})||e[0],Wp=(e,t={})=>{let n=vp(t=Object.assign({},t),yp),r=new WeakMap;n.t=e=>{var n;if(!(e==null||(n=e.sources)==null)&&n.length){let n=Up(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?Cp(o):i;r.set(n,e)}}},((e,t={})=>{let n=Rp();Vp(Np(()=>{let r,i=jp(`CLS`,0),a=vp(t,yp),o=e=>{for(let t of e)a.u(t);a.o>i.value&&(i.value=a.o,i.entries=a.i,r())},s=Mp(`layout-shift`,o);s&&(r=Op(e,i,Hp,t.reportAllChanges),n.onHidden(()=>{o(s.takeRecords()),r(!0)}),Dp(()=>{a.o=0,i=jp(`CLS`,0),r=Op(e,i,Hp,t.reportAllChanges),kp(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=Up(i.sources);e&&(t={largestShiftTarget:r.get(e),largestShiftTime:i.startTime,largestShiftValue:i.value,largestShiftSource:e,largestShiftEntry:i,loadState:xp(i.startTime)})}}return Object.assign(e,{attribution:t})})(t))},t)},Gp=(e,t={})=>{Vp(t=>{e((e=>{let t={timeToFirstByte:0,firstByteToFCP:e.value,loadState:xp(Ep())};if(e.entries.length){let n=bp(),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:xp(e.entries[0].startTime),navigationEntry:n,fcpEntry:r}}}return Object.assign(e,{attribution:t})})(t))},t)},Kp=0,qp=1/0,Jp=0,Yp=e=>{for(let t of e)t.interactionId&&(qp=Math.min(qp,t.interactionId),Jp=Math.max(Jp,t.interactionId),Kp=Jp?(Jp-qp)/7+1:0)},Zp=()=>{var e;return Xp?Kp:(e=performance.interactionCount)==null?0:e},Qp=()=>{`interactionCount`in performance||Xp||(Xp=Mp(`event`,Yp,{durationThreshold:0}))},$p=0,em=class{constructor(){I(this,`l`,[]),I(this,`h`,new Map),I(this,`m`,void 0),I(this,`p`,void 0)}v(){$p=Zp(),this.l.length=0,this.h.clear()}M(){let e=Math.min(this.l.length-1,Math.floor((Zp()-$p)/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)}}},tm=e=>{let t=globalThis.requestIdleCallback||setTimeout,n=globalThis.cancelIdleCallback||clearTimeout;if(document.visibilityState===`hidden`)e();else{let r=Np(e),i=-1,a=()=>{n(i),r()};addEventListener(`visibilitychange`,a,{once:!0,capture:!0}),i=t(()=>{removeEventListener(`visibilitychange`,a,{capture:!0}),r()})}},nm=[200,500],rm=(e,t={})=>{let n=vp(t=Object.assign({},t),em),r=[],i=[],a=0,o=new WeakMap,s=new WeakMap,c=!1,l=()=>{c||(tm(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?Cp(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:xp(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})};Mp(`long-animation-frame`,e=>{r=r.concat(e),l()}),((e,t={})=>{if(!globalThis.PerformanceEventTiming||!(`interactionId`in PerformanceEventTiming.prototype))return;let n=Rp();zp(()=>{var r;Qp();let i,a=jp(`INP`),o=vp(t,em),s=e=>{tm(()=>{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=Mp(`event`,s,{durationThreshold:(r=t.durationThreshold)==null?40:r});i=Op(e,a,nm,t.reportAllChanges),c&&(c.observe({type:`first-input`,buffered:!0}),n.onHidden(()=>{s(c.takeRecords()),i(!0)}),Dp(()=>{o.v(),a=jp(`INP`),i=Op(e,a,nm,t.reportAllChanges)}))})})(t=>{e(f(t))},t)},im=class{constructor(){I(this,`m`,void 0)}u(e){var t;(t=this.m)==null||t.call(this,e)}},am=[2500,4e3],om=(e,t={})=>{let n=vp(t=Object.assign({},t),im),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?Cp(n):i;r.set(e,o)}else e.id&&r.set(e,`#${e.id}`)},((e,t={})=>{zp(()=>{let n=Rp(),r,i=jp(`LCP`),a=vp(t,im),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-Ap(),0),i.entries=[t],r())},s=Mp(`largest-contentful-paint`,o);if(s){r=Op(e,i,am,t.reportAllChanges);let n=Np(()=>{o(s.takeRecords()),s.disconnect(),r(!0)}),a=e=>{e.isTrusted&&(tm(n),removeEventListener(e.type,a,{capture:!0}))};for(let e of[`keydown`,`click`,`visibilitychange`])addEventListener(e,a,{capture:!0});Dp(n=>{i=jp(`LCP`),r=Op(e,i,am,t.reportAllChanges),kp(()=>{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=bp();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=K(K({},t),{},{timeToFirstByte:r,resourceLoadDelay:o-r,resourceLoadDuration:s-o,elementRenderDelay:e.value-s,navigationEntry:a})}}return Object.assign(e,{attribution:t})})(t))},t)},sm=[800,1800],cm=e=>{document.prerendering?zp(()=>cm(e)):document.readyState===`complete`?setTimeout(e):addEventListener(`load`,()=>cm(e),!0)},lm=(e,t={})=>{((e,t={})=>{let n=jp(`TTFB`),r=Op(e,n,sm,t.reportAllChanges);cm(()=>{let i=bp();i&&(n.value=Math.max(i.responseStart-Ap(),0),n.entries=[i],r(!0),Dp(()=>{n=jp(`TTFB`,0),r=Op(e,n,sm,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)}}));q();var dm=`unknown`,fm=10,pm=6e4,mm=5e3,hm=1e3,gm=(e,t)=>!!t&&e===t,_m=e=>e?e.replace(/_/g,`-`):dm,vm=()=>{if(typeof performance>`u`)return dm;let e=performance.getEntriesByType(`navigation`)[0];return _m(e==null?void 0:e.type)},ym=(e,t)=>{let[n,r]=e===`CLS`?[.1,.25]:[200,500];return t<=n?`good`:t<=r?`needs-improvement`:`poor`},bm=e=>{var t,n,r;if(!(typeof Element>`u`||!(e instanceof Element)))return(t=(n=(r=e.getAttribute(`data-bk-action-name`))==null?e.getAttribute(`aria-label`):r)==null?e.getAttribute(`name`):n)==null?e.tagName.toLowerCase():t},xm=()=>{if(typeof performance>`u`)return;let e=performance.interactionCount;return typeof e==`number`&&Number.isFinite(e)?e:void 0},Sm=(e,t)=>{var n,r;let i=(n=t.value)==null?0:n;if(!(t.hadRecentInput||!Number.isFinite(i))){if(e.clsWindowStart===void 0||t.startTime-((r=e.clsWindowEnd)==null?t.startTime:r)>=hm||t.startTime-e.clsWindowStart>=mm){var a;e.clsWindowStart=t.startTime,e.clsWindowValue=i,e.clsWindowLargestShiftValue=i,e.clsWindowLargestShiftTarget=bm((a=t.sources)==null||(a=a[0])==null?void 0:a.node)}else if(e.clsWindowValue+=i,i>e.clsWindowLargestShiftValue){var o;e.clsWindowLargestShiftValue=i,e.clsWindowLargestShiftTarget=bm((o=t.sources)==null||(o=o[0])==null?void 0:o.node)}e.clsWindowEnd=t.startTime,e.clsWindowValue>e.cls&&(e.cls=Math.round(e.clsWindowValue*1e4)/1e4,e.largestShiftValue=e.clsWindowLargestShiftValue,e.largestShiftTarget=e.clsWindowLargestShiftTarget)}},Cm=(e,t)=>{var n,r;if(!t.interactionId||!Number.isFinite(t.duration))return;e.interactionIdMin=Math.min(e.interactionIdMin,t.interactionId),e.interactionIdMax=Math.max(e.interactionIdMax,t.interactionId);let i=(n=t.processingStart)==null?t.startTime:n,a=(r=t.processingEnd)==null?i:r,o={duration:Math.min(t.duration,pm),inputDelay:Math.max(0,i-t.startTime),interactionId:t.interactionId,interactionTarget:bm(t.target),interactionType:t.name,presentationDelay:Math.max(0,t.startTime+t.duration-a),processingDuration:Math.max(0,a-i)},s=e.inpCandidates.findIndex(e=>e.interactionId===t.interactionId);s>=0?o.duration>e.inpCandidates[s].duration&&(e.inpCandidates[s]=o):e.inpCandidates.push(o),e.inpCandidates.sort((e,t)=>t.duration-e.duration).splice(fm)},wm=e=>{let t=xm(),n=t!==void 0&&e.interactionCountAtStart!==void 0?Math.max(0,t-e.interactionCountAtStart):e.interactionIdMin===1/0?0:(e.interactionIdMax-e.interactionIdMin)/7+1;if(e.inpCandidates.length)return e.inpCandidates[Math.min(e.inpCandidates.length-1,Math.floor(n/50))]},Tm=(e,t)=>{var n;return{"rum.navigation.type":(n=e.navigationType)==null?t:n,[Y.vitalMetric]:e.name.toLowerCase(),[Y.vitalRating]:e.rating}},Em=(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},Dm=()=>{let e,t=!1;return{name:`web-vitals`,init(n){return W(function*(){if(typeof window>`u`)return;let r;try{r=yield Promise.resolve().then(()=>(um(),_p))}catch(e){if(n.config.debug){var i;(i=globalThis.console)==null||i.warn(`[bk-ot] web-vitals load failed:`,e)}return}if(t)return;let{onFCP:a,onLCP:o,onTTFB:s}=r,c=vm(),l=n.meter.createHistogram(`browser.web_vital.cls`,{unit:`1`,description:`Cumulative Layout Shift`,advice:{explicitBucketBoundaries:Tf}}),u=n.meter.createHistogram(`browser.web_vital.duration`,{unit:`ms`,description:`Web Vitals duration metrics, including FCP, INP, LCP and TTFB`,advice:{explicitBucketBoundaries:Ef}}),d=(e,t,r)=>{if(!J(n,`traces`))return;let i=e.name.toLowerCase();n.startSpan(`browser.web_vital`,K(K(K(K(K({},n.config.hooks.getPageAttributes()),t),Tm(e,c)),Q({duration:e.name===`CLS`?void 0:e.value,errorType:e.rating===`good`?`none`:`slow`,eventLabel:`Web 指标`,result:ru(e.rating),spanSubtype:i,spanType:Z.vital,targetLabel:i,targetValue:e.value})),{},{[Y.vitalMetric]:i,[Y.vitalValue]:e.value,[Y.vitalRating]:e.rating,"vital.id":e.id},Em(e,n.config.hooks.redactUrl)),r===void 0?void 0:{contextTime:r}).end()},f=e=>{if(t||!Number.isFinite(e.value)||!J(n,`metrics`)&&!J(n,`traces`))return;let r=e.entries[0],i=r&&typeof performance<`u`?performance.timeOrigin+r.startTime:void 0,a=i===void 0?n.getRuntimeAttributes():n.getRuntimeAttributesAt(i);J(n,`metrics`)&&u.record(e.value,n.applyRedact(K(K(K({},n.config.hooks.getMetricAttributes()),Lu(a)),Tm(e,c)))),d(e,a,i)},p,m,h,g=(e,t,r)=>{if(J(n,`metrics`)){let r=n.applyRedact(K(K(K({},n.config.hooks.getMetricAttributes()),Lu(t)),Tm(e,c)));e.name===`CLS`?l.record(e.value,r):u.record(e.value,r)}d(e,t,r)},_=()=>{let e=p;if(!e||!J(n,`metrics`)&&!J(n,`traces`))return;g({attribution:{largestShiftTarget:e.largestShiftTarget,largestShiftValue:e.largestShiftValue},entries:[],id:Vl(`vital`),name:`CLS`,navigationType:c,rating:ym(`CLS`,e.cls),value:e.cls},e.runtimeAttributes,e.startedAt);let t=wm(e);t&&g({attribution:{inputDelay:t.inputDelay,interactionTarget:t.interactionTarget,interactionType:t.interactionType,presentationDelay:t.presentationDelay,processingDuration:t.processingDuration},entries:[],id:Vl(`vital`),name:`INP`,navigationType:c,rating:ym(`INP`,t.duration),value:t.duration},e.runtimeAttributes,e.startedAt)},v=n.onViewChange(e=>{var t;let r=p;if(r&&gm(r.id,e.id)){r.runtimeAttributes=K(K({},r.runtimeAttributes),{},{[Y.viewId]:e.id,[Y.viewName]:e.name,[Y.viewUrl]:e.url,[Y.viewUrlPathGroup]:e.urlPathGroup});return}_(),p=e.id?{cls:0,clsWindowLargestShiftValue:0,clsWindowValue:0,interactionCountAtStart:xm(),interactionIdMax:0,interactionIdMin:1/0,inpCandidates:[],id:e.id,largestShiftValue:0,runtimeAttributes:n.getRuntimeAttributes(),startedAt:(t=e.startedAt)==null?Date.now():t}:void 0});if(typeof PerformanceObserver<`u`){var y,b;(y=PerformanceObserver.supportedEntryTypes)!=null&&y.includes(`layout-shift`)&&(h=new PerformanceObserver(e=>{if(p)for(let t of e.getEntries())performance.timeOrigin+t.startTime<p.startedAt||Sm(p,t)}),h.observe({buffered:!0,type:`layout-shift`})),(b=PerformanceObserver.supportedEntryTypes)!=null&&b.includes(`event`)&&(m=new PerformanceObserver(e=>{if(p)for(let t of e.getEntries())performance.timeOrigin+t.startTime<p.startedAt||!t.interactionId||!Number.isFinite(t.duration)||Cm(p,t)}),m.observe({buffered:!0,durationThreshold:40,type:`event`}))}a(f),o(f),s(f),e=()=>{_(),p=void 0,v(),h==null||h.disconnect(),m==null||m.disconnect()}})()},shutdown(){t=!0,e==null||e(),e=void 0}}};q();var Om=64*1024,km=6e4,Am=5,jm=e=>e==null?0:typeof e==`string`?e.length>Om||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,Mm=(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}},Nm=(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}=Mm(u,a.config.hooks.redactUrl),p=a.config.hooks.getMetricAttributes(),m=()=>a.applyRedact(K(K(K({},p),Lu(a.getRuntimeAttributes())),d)),h=(n=f[`server.address`])==null?f[`url.full`]:n,g=a.startSpan(`websocket.connect`,K(K(K({},f),Q({errorType:`none`,eventLabel:`WebSocket`,spanSubtype:`websocket`,spanType:Z.custom,targetLabel:h})),f[`server.address`]?{[Y.targetDomain]:f[`server.address`]}:{})),_=performance.now(),v=!1,y=e=>{if(v)return;v=!0;let t=performance.now()-_;e===`error`&&g.setStatus({code:We.ERROR,message:`websocket connect failed`}),g.setAttributes(Q({duration:t,errorType:e===`error`?`network`:`none`,eventLabel:`WebSocket`,result:e===`error`?X.error:X.success,spanSubtype:`websocket`,spanType:Z.custom,targetLabel:h,targetValue:t})),g.end(),e===`opened`&&!c()&&J(a,`metrics`)&&i.record(t,m())};e.addEventListener(`open`,()=>{c()||y(`opened`)}),e.addEventListener(`message`,e=>{if(c()||!J(a,`metrics`))return;let t=K(K({},m()),{},{"websocket.direction":`in`});l.add(1,t),r.add(jm(e.data),t)}),e.addEventListener(`error`,()=>{if(c())return;let e=v?`runtime`:`connect`;if(J(a,`metrics`)&&o.add(1,K(K({},m()),{},{"websocket.error.phase":e})),y(`error`),!J(a,`logs`))return;let t=s.allow(`ws:error:${u}`);t.allowed&&a.emitLog({severityNumber:Ii.ERROR,severityText:`ERROR`,body:`websocket.error`,attributes:K(K(K({},f),Q({errorType:`network`,eventLabel:`WebSocket 错误`,result:X.error,spanSubtype:`websocket`,spanType:Z.custom,targetLabel:h})),{},{"websocket.error.phase":e,"websocket.error.window_occurrence_index":t.count})})}),e.addEventListener(`close`,e=>{c()||(v||y(`error`),J(a,`logs`)&&a.emitLog({severityNumber:Ii.INFO,severityText:`INFO`,body:`websocket.close`,attributes:K(K(K({},f),Q({errorType:e.wasClean?`none`:`network`,eventLabel:`WebSocket 关闭`,result:e.wasClean?X.success:X.warning,spanSubtype:`websocket`,spanType:Z.custom,targetLabel:h,targetValue:e.code})),{},{"websocket.close.code":e.code,"websocket.close.reason":e.reason,"websocket.close.was_clean":e.wasClean})}))});let b=e.send.bind(e);e.send=e=>{if(!c()&&J(a,`metrics`)){let t=K(K({},m()),{},{"websocket.direction":`out`});l.add(1,t),r.add(jm(e),t)}return b(e)}},Pm=()=>{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)`,advice:{explicitBucketBoundaries:Ef}}),l=Xd(km,Am),u=()=>n;t=new Proxy(i,{construct(e,t,i){let d=Reflect.construct(e,t,i);if(n||!r.isSampled())return d;let f=t[0]==null?``:String(t[0]);return!f||ql(r.config,f)||Nm(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}}};L();var Fm=class{constructor(){I(this,`listeners`,new Set),I(this,`notify`,e=>{this.listeners.forEach(t=>t(e))}),I(this,`subscribe`,e=>(this.listeners.add(e),()=>this.listeners.delete(e)))}};q();var Im=60*1e3,Lm=e=>e.trim().replace(/\/+$/,``),Rm={traces:`rum`,metrics:`metrics`,logs:`logs`},zm=(e,t)=>`${Lm(e==null?``:e)}/v1/${Rm[t]}`,Bm=(e,t)=>{var n,r,i;let a=(n=e.signals)==null?void 0:n[t];if(a===!1)return!1;let o=a==null?void 0:a.endpoint,s=e.token||e.headers||a!=null&&a.headers?K(K(K({},e.token?{Authorization:`Bearer ${e.token}`}:{}),(r=e.headers)==null?{}:r),(i=a==null?void 0:a.headers)==null?{}:i):void 0;return{concurrencyLimit:a==null?void 0:a.concurrencyLimit,endpoint:o?Lm(o):zm(e.endpoint,t),headers:s,timeoutMillis:a==null?void 0:a.timeoutMillis}},Vm=e=>typeof e!=`number`||!Number.isFinite(e)?1:Math.max(0,Math.min(1,e)),Hm=e=>e,Um=e=>{try{let t=new URL(e,typeof location>`u`?`http://localhost`:location.href);return t.username=``,t.password=``,t.search=``,t.hash=``,t.href}catch(t){return e.replace(/[?#].*$/,``)}},Wm=e=>{try{return new URL(e,typeof location>`u`?`http://localhost`:location.href).pathname||`/`}catch(t){return e||`/`}},Gm=e=>{var t;return{environment:(t=e.environment)==null?`production`:t,name:e.name,version:e.version}},Km=e=>K(K({[Y.deploymentEnvironmentName]:e.environment,"rum.provider":`blueking`,"rum.schema.version":`1`,[Y.serviceName]:e.name},e.version?{[Y.serviceVersion]:e.version}:{}),{},{"telemetry.sdk.language":`webjs`,"telemetry.sdk.name":`@blueking/open-telemetry`}),qm=e=>{var t,n;let r=Bm(e,`traces`),i=Bm(e,`metrics`),a=Bm(e,`logs`);return{endpoint:Lm((t=e.endpoint)==null?``:t)||((n=[r,i,a].find(e=>e!==!1))==null?void 0:n.endpoint)||``,traces:r,metrics:i,logs:a}},Jm=e=>{if(!e)throw Error(`[bk-ot] transport is required.`);let t=[`traces`,`metrics`,`logs`].filter(t=>{var n;return((n=e.signals)==null?void 0:n[t])!==!1});if(!t.length)throw Error(`[bk-ot] at least one transport signal must be enabled.`);for(let i of t){var n,r;let t=(n=e.signals)==null?void 0:n[i],a=t?t.endpoint:void 0;if(!(a!=null&&a.trim())&&!((r=e.endpoint)!=null&&r.trim()))throw Error(`[bk-ot] transport.signals.${i}.endpoint or transport.endpoint is required.`)}},Ym=e=>{var t,n,r,i,a,o,s,c,l,u,d,f,p;return{beforeSend:(t=e.tracking)==null?void 0:t.beforeSend,getPageAttributes:(n=(r=e.context)==null||(r=r.attributes)==null?void 0:r.page)==null?(()=>({"rum.page.host":typeof window>`u`?``:window.location.host,"rum.page.path":typeof window>`u`?``:window.location.pathname})):n,getMetricAttributes:(i=(a=e.context)==null||(a=a.attributes)==null?void 0:a.metric)==null?(()=>({})):i,getErrorAttributes:(o=(s=e.context)==null||(s=s.attributes)==null?void 0:s.error)==null?(()=>({})):o,getCustomAttributes:(c=(l=e.context)==null||(l=l.attributes)==null?void 0:l.custom)==null?(()=>({})):c,getViewPathGroup:t=>{var n,r,i,a;return(n=typeof((r=e.tracking)==null?void 0:r.view)==`object`?(i=(a=e.tracking.view).getPathGroup)==null?void 0:i.call(a,t):void 0)==null?Wm(t):n},redactAttributes:(u=(d=e.privacy)==null?void 0:d.redactAttributes)==null?Hm:u,redactUrl:(f=(p=e.privacy)==null?void 0:p.redactUrl)==null?Um:f}},Xm=e=>{var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v;if(!(!((t=e.application)==null||(t=t.name)==null)&&t.trim()))throw Error(`[bk-ot] application.name is required.`);Jm(e.transport);let y=Gm(e.application),b=typeof((n=e.tracking)==null?void 0:n.view)==`object`?e.tracking.view:void 0,x=(r=e.transport.signals)==null?void 0:r.traces,S=(i=e.transport.signals)==null?void 0:i.metrics;return{application:y,autoStart:(a=e.autoStart)==null?!0:a,debug:(o=e.debug)==null?!1:o,enabled:(s=e.enabled)==null?!0:s,extensions:{instrumentations:[...(c=(l=e.extensions)==null?void 0:l.instrumentations)==null?[]:c],plugins:[...(u=(d=e.extensions)==null?void 0:d.plugins)==null?[]:u]},hooks:Ym(e),metricIntervalMillis:S?(f=S.intervalMillis)==null?Im:f:Im,resourceAttributes:Km(y),session:K(K({},e.session),{},{sampleRate:Vm((p=e.session)==null?void 0:p.sampleRate)}),spanBatch:x?x.batch:void 0,spanProcessor:x?(m=x.processor)==null?`batch`:m:`batch`,tracking:(h=e.tracking)==null?{}:h,trackingConsent:(g=(_=e.privacy)==null?void 0:_.trackingConsent)==null?`granted`:g,transport:qm(e.transport),user:(v=e.context)==null?void 0:v.user,view:{excludedActivityUrls:b==null?void 0:b.excludedActivityUrls,loadingTime:(b==null?void 0:b.loadingTime)!==!1,tracking:(b==null?void 0:b.tracking)===`manual`?`manual`:`auto`}}};L();var Zm=(e,t)=>typeof e.enabled==`function`?e.enabled(t):e.enabled!==!1,Qm=class{constructor(e){I(this,`plugins`,void 0),I(this,`startedPlugins`,[]),this.plugins=e}flush(){var e=this;return W(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 W(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 W(function*(){for(let r of t.plugins)if(Zm(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)}}})()}};L(),q();var $m=new Set([...Object.values(Y),$]),eh=class{constructor(e={},t){I(this,`actionHistory`,[]),I(this,`attributes`,{}),I(this,`queuedViewCommands`,[]),I(this,`recordAssociation`,(e,t,n,r)=>{let i=e.at(-1);if(i&&i.endedAt===void 0&&(i.endedAt=Math.max(i.startedAt,n)),r){let r={};for(let e of t){let t=this.attributes[e];t!==void 0&&(r[e]=t)}e.push({attributes:r,startedAt:n})}e.length>100&&e.splice(0,e.length-100)}),I(this,`sessionHistory`,[]),I(this,`sessionLifecycleListeners`,new Set),I(this,`setOptionalAttribute`,(e,t)=>{if(t===void 0){delete this.attributes[e];return}this.attributes[e]=t}),I(this,`user`,{}),I(this,`view`,{}),I(this,`viewAttributeKeys`,new Set),I(this,`viewChangeListeners`,new Set),I(this,`viewCommandListeners`,new Set),I(this,`viewHistory`,[]),I(this,`viewScopedAttributeKeys`,new Set),I(this,`dispatchViewCommand`,e=>{if(this.viewCommandListeners.size===0){this.queuedViewCommands.push(e);return}this.viewCommandListeners.forEach(t=>t(e))}),I(this,`getAttributes`,()=>K({},this.attributes)),I(this,`getAttributesAt`,e=>{if(!Number.isFinite(e))return this.getAttributes();let t=this.getAttributes(),n=(n,r)=>{for(let e of r)delete t[e];let i=[...n].reverse().find(t=>t.startedAt<=e&&(t.endedAt===void 0||e<t.endedAt));i&&Object.assign(t,i.attributes)};return n(this.sessionHistory,[Y.sessionId,Y.sessionHasReplay,$]),n(this.viewHistory,this.viewScopedAttributeKeys),n(this.actionHistory,[Y.actionId]),t}),I(this,`getUser`,()=>K({},this.user)),I(this,`getView`,()=>K({},this.view)),I(this,`isSessionActive`,()=>typeof this.attributes[Y.sessionId]==`string`),I(this,`isViewActive`,()=>typeof this.attributes[Y.viewId]==`string`),I(this,`notifySessionLifecycle`,e=>{this.sessionLifecycleListeners.forEach(t=>t(e))}),I(this,`onSessionLifecycle`,e=>(this.sessionLifecycleListeners.add(e),()=>this.sessionLifecycleListeners.delete(e))),I(this,`onViewChange`,e=>(this.viewChangeListeners.add(e),this.view.id&&e(this.getView()),()=>this.viewChangeListeners.delete(e))),I(this,`onViewCommand`,e=>{for(this.viewCommandListeners.add(e);this.queuedViewCommands.length;)e(this.queuedViewCommands.shift());return()=>this.viewCommandListeners.delete(e)}),I(this,`setAttributes`,(e,t=Date.now())=>{for(let[t,n]of Object.entries(e)){if(n===void 0){delete this.attributes[t];continue}this.attributes[t]=n}if(Y.sessionId in e&&this.recordAssociation(this.sessionHistory,[Y.sessionId,Y.sessionHasReplay,$],t,typeof this.attributes[Y.sessionId]==`string`),Y.actionId in e){let e=this.attributes[Y.actionId];this.recordAssociation(this.actionHistory,[Y.actionId],t,Array.isArray(e)?e.length>0:typeof e==`string`)}}),I(this,`setUser`,e=>{if(this.user=K(K({},this.user),e),`id`in e){if(e.id===void 0){delete this.attributes[Y.userId];return}this.attributes[Y.userId]=e.id}}),I(this,`setView`,(e,t=(t=>(t=e.startedAt)==null?Date.now():t)())=>{var n;this.viewAttributeKeys.forEach(e=>delete this.attributes[e]),this.viewAttributeKeys.clear();let r={};for(let[t,i]of Object.entries((n=e.attributes)==null?{}:n))i===void 0||$m.has(t)||(r[t]=i,this.attributes[t]=i,this.viewAttributeKeys.add(t),this.viewScopedAttributeKeys.add(t));this.view=K(K({},e),{},{attributes:r}),this.setOptionalAttribute(Y.viewId,e.id),this.setOptionalAttribute(Y.viewUrl,e.url),this.setOptionalAttribute(Y.viewUrlPathGroup,e.urlPathGroup),this.setOptionalAttribute(Y.viewLoadingType,e.loadingType),this.setOptionalAttribute(Y.viewName,e.name),[Y.viewId,Y.viewUrl,Y.viewUrlPathGroup,Y.viewLoadingType,Y.viewName].forEach(e=>this.viewScopedAttributeKeys.add(e)),this.recordAssociation(this.viewHistory,this.viewScopedAttributeKeys,t,typeof e.id==`string`&&e.id.length>0),this.viewChangeListeners.forEach(e=>e(this.getView()))}),this.setAttributes(e),t&&this.setUser(t)}};L(),q();var th=e=>({url:e.endpoint,headers:e.headers,concurrencyLimit:e.concurrencyLimit,timeoutMillis:e.timeoutMillis}),nh=`bk-rum`,rh=class{constructor(e){this.isSampled=e}shouldSample(){return{decision:this.isSampled()?tl.RECORD_AND_SAMPLED:tl.NOT_RECORD}}toString(){return`RumSessionSampler`}},ih,ah=()=>{if(ih)ih.users+=1;else{let e=new ft().enable(),t=N.setGlobalContextManager(e);t||e.disable(),ih={contextManager:t?e:void 0,ownsContext:t,ownsPropagator:nt.setGlobalPropagator(new Wr),users:1}}let e=!1;return()=>{e||!ih||(e=!0,--ih.users,!(ih.users>0)&&(ih.ownsContext&&N.disable(),ih.ownsPropagator&&nt.disable(),ih=void 0))}},oh=(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,sh=e=>[Jd(e.tracking.request)],ch=e=>[gp(e.session),...dh(e.tracking.device,!0,mf),Eu(),ep(),Fd(lh(e.tracking.resource,!0))],lh=(e,t)=>e===void 0?t:e!==!1,uh=e=>typeof e==`object`&&e?e:void 0,dh=(e,t,n)=>lh(e,t)?[n(uh(e))]:[],fh=e=>[...dh(e.error,!0,wf),...dh(e.webVitals,!0,Dm),...dh(e.blankScreen,!0,Zu),...dh(e.action,!0,wu),...dh(e.websocket,!1,Pm),...dh(e.longTask,!1,Pf),...dh(e.cspViolation,!1,tf)],ph=class{assertBeforeStart(e){if(this.phase!==`idle`)throw Error(`[bk-ot] ${e}() must be called before start(); set autoStart: false before registration.`)}createPluginContext(){return{applyRedact:this.applyRedact,config:this.config,emitLog:this.emitLog,flush:this.flush,getRuntimeAttributes:this.getRuntimeAttributes,getRuntimeAttributesAt:this.getRuntimeAttributesAt,isSampled:this.isSampled,isSessionActive:this.isSessionActive,isViewActive:this.isViewActive,logger:this.logger,meter:this.meter,notifySessionLifecycle:this.notifySessionLifecycle,notifyActivity:this.activityObserver.notify,onActivity:this.activityObserver.subscribe,onSessionLifecycle:this.onSessionLifecycle,onViewCommand:this.runtimeContext.onViewCommand,onViewChange:this.runtimeContext.onViewChange,registerInstrumentations:this.registerInstrumentations,setRuntimeAttributes:this.setRuntimeAttributes,setUser:this.setUser,setView:this.runtimeContext.setView,startSpan:this.startSpan,tracer:this.tracer}}createPluginManager(){var e;return new Qm([...ch(this.config),...sh(this.config),...fh(this.config.tracking),...(e=this.config.extensions.plugins)==null?[]:e])}constructor(e){var t=this;I(this,`activityObserver`,new Fm),I(this,`flushProviders`,W(function*(){yield t.tracerProvider.forceFlush(),yield t.meterProvider.forceFlush(),yield t.loggerProvider.forceFlush()})),I(this,`loggerProvider`,void 0),I(this,`meterProvider`,void 0),I(this,`phase`,`idle`),I(this,`pluginManager`,void 0),I(this,`registeredInstrumentations`,void 0),I(this,`releaseOtelGlobals`,void 0),I(this,`runtimeContext`,void 0),I(this,`sampled`,!1),I(this,`startCollection`,W(function*(){if(t.pluginManager||!t.config.enabled||t.config.trackingConsent!==`granted`)return;t.config.transport.traces!==!1&&(t.releaseOtelGlobals=ah());let e=t.createPluginManager();t.pluginManager=e;try{var n;yield e.start(t.createPluginContext()),t.registerInstrumentations((n=t.config.extensions.instrumentations)==null?[]:n)}catch(n){var r,i,a;for(yield e.shutdown(),t.pluginManager=void 0;t.registeredInstrumentations.length;)(r=t.registeredInstrumentations.pop())==null||(i=r.disable)==null||i.call(r);throw(a=t.releaseOtelGlobals)==null||a.call(t),t.releaseOtelGlobals=void 0,n}})),I(this,`stopCollection`,function(){var e=W(function*(e){var n,r,i;let a=t.pluginManager;if(a){for(yield a.shutdown(),t.pluginManager=void 0;t.registeredInstrumentations.length;)(n=t.registeredInstrumentations.pop())==null||(r=n.disable)==null||r.call(n);t.setRuntimeAttributes({[Y.sessionHasReplay]:void 0,[Y.sessionId]:void 0}),e&&(yield t.flushProviders()),(i=t.releaseOtelGlobals)==null||i.call(t),t.releaseOtelGlobals=void 0}});return function(t){return e.apply(this,arguments)}}()),I(this,`teardownCallbacks`,[]),I(this,`tracerProvider`,void 0),I(this,`applyRedact`,e=>this.config.hooks.redactAttributes(e)),I(this,`config`,void 0),I(this,`emitLog`,e=>{var t;if(!this.isSampled()||this.config.transport.logs===!1)return;let n=e.timestamp?br(_r(e.timestamp)):void 0,r=K(K({},e),{},{attributes:this.applyRedact(K(K({},n===void 0?this.getRuntimeAttributes():this.getRuntimeAttributesAt(n)),(t=e.attributes)==null?{}:t))});this.logger.emit(r)}),I(this,`flush`,W(function*(){var e;yield(e=t.pluginManager)==null?void 0:e.flush(),yield t.flushProviders()})),I(this,`getRuntimeAttributes`,()=>this.runtimeContext.getAttributes()),I(this,`getRuntimeAttributesAt`,e=>this.runtimeContext.getAttributesAt(e)),I(this,`isSampled`,()=>this.sampled),I(this,`isSessionActive`,()=>this.runtimeContext.isSessionActive()),I(this,`isViewActive`,()=>this.runtimeContext.isViewActive()),I(this,`logger`,void 0),I(this,`meter`,void 0),I(this,`notifySessionLifecycle`,e=>{this.runtimeContext.notifySessionLifecycle(e)}),I(this,`onSessionLifecycle`,e=>this.runtimeContext.onSessionLifecycle(e)),I(this,`registerInstrumentations`,e=>{e.length&&(Nc({instrumentations:e,meterProvider:this.meterProvider,tracerProvider:this.tracerProvider}),this.registeredInstrumentations.push(...e))}),I(this,`reportAction`,({attributes:e={},name:t})=>{if(!this.isSampled()||this.config.transport.traces===!1)return;let n=Vl(`action`);this.startSpan(`action.custom`,K(K(K(K({},this.config.hooks.getPageAttributes()),e),Q({errorType:`none`,eventLabel:`用户操作`,spanSubtype:`custom`,spanType:Z.action,targetLabel:t,traceScene:`user_action`})),{},{[Y.actionId]:n,[Y.actionName]:t,[Y.actionType]:`custom`})).end()}),I(this,`reportCustomEvent`,({attributes:e={},error:t,name:n})=>{if(!this.isSampled()||this.config.transport.traces===!1){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}`,K(K(K(K(K({},this.config.hooks.getPageAttributes()),this.config.hooks.getCustomAttributes()),Q({errorType:t?`custom`:`none`,eventLabel:`自定义事件`,result:t?X.error:X.success,spanSubtype:n,spanType:Z.custom,targetLabel:n})),e),{},{"rum.custom.name":n}));t&&(i.recordException(t),i.setStatus({code:We.ERROR,message:t.message})),i.end()}),I(this,`setRuntimeAttributes`,(e,t)=>{let n=K({},e);if(Y.sessionId in e){let t=e[Y.sessionId];this.sampled=this.config.enabled&&typeof t==`string`&&t.length>0?Au(this.config,t):!1,n[$]=this.sampled}this.runtimeContext.setAttributes(n,t)}),I(this,`setTrackingConsent`,function(){var e=W(function*(e){t.config.trackingConsent!==e&&(t.config.trackingConsent=e,t.phase===`started`&&(e===`granted`?yield t.startCollection():yield t.stopCollection(!0)))});return function(t){return e.apply(this,arguments)}}()),I(this,`setUser`,e=>{this.runtimeContext.setUser(e)}),I(this,`setViewLoadingTime`,()=>{this.isSampled()&&this.runtimeContext.dispatchViewCommand({time:Date.now(),type:`set_loading_time`})}),I(this,`setViewName`,e=>{this.isSampled()&&this.runtimeContext.dispatchViewCommand({name:e,type:`set_name`})}),I(this,`shutdown`,W(function*(){if(t.phase!==`stopped`){for(yield t.stopCollection(!1),yield t.flushProviders();t.teardownCallbacks.length;){var e;(e=t.teardownCallbacks.pop())==null||e()}yield t.tracerProvider.shutdown(),yield t.meterProvider.shutdown(),yield t.loggerProvider.shutdown(),t.phase=`stopped`}})),I(this,`start`,W(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`;try{if(yield t.startCollection(),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(n){for(;t.teardownCallbacks.length;){var e;(e=t.teardownCallbacks.pop())==null||e()}throw yield t.stopCollection(!1),t.phase=`idle`,n}t.phase=`started`}})),I(this,`startSpan`,(e,t={},n)=>{var r,i;if(!this.isSampled()||this.config.transport.traces===!1)return this.tracer.startSpan(e);let a=(r=n==null?void 0:n.contextTime)==null?typeof(n==null?void 0:n.startTime)==`number`?n.startTime:void 0:r,o=a===void 0?this.getRuntimeAttributes():this.runtimeContext.getAttributesAt(a);return this.tracer.startSpan(e,{kind:(i=n==null?void 0:n.kind)==null?Ue.INTERNAL:i,startTime:n==null?void 0:n.startTime,attributes:this.applyRedact(K(K({},o),t))})}),I(this,`startView`,(e={})=>{this.isSampled()&&this.runtimeContext.dispatchViewCommand({options:e,type:`start`})}),I(this,`tracer`,void 0),I(this,`use`,e=>{var t;return this.assertBeforeStart(`use`),(t=this.config.extensions.plugins)==null||t.push(e),this}),I(this,`useInstrumentation`,e=>{var t;return this.assertBeforeStart(`useInstrumentation`),this.config.enabled&&((t=this.config.extensions.instrumentations)==null||t.push(e)),this}),this.config=Xm(e),this.runtimeContext=new eh({[$]:!1},this.config.user);let n=io(this.config.resourceAttributes),r=(()=>{if(this.config.transport.traces===!1)return[];let e=oh(new Ac(th(this.config.transport.traces)),`traces`,this.config.debug);return[new ad(this.config.spanProcessor===`simple`?new Il(e):new hl(e,this.config.spanBatch),this.config,()=>this.applyRedact(K(K({},this.runtimeContext.getAttributes()),this.config.hooks.getPageAttributes())))]})(),i=this.config.transport.metrics===!1?[]:[new $a({exporter:new sd(oh(new kc(K(K({},th(this.config.transport.metrics)),{},{temporalityPreference:bc.DELTA})),`metrics`,this.config.debug)),exportIntervalMillis:this.config.metricIntervalMillis})],a=this.config.transport.logs===!1?[]:[new id(new Qc(oh(new yc(th(this.config.transport.logs)),`logs`,this.config.debug)),this.config)];this.tracerProvider=new Bl({resource:n,sampler:new rh(()=>this.config.transport.traces!==!1&&this.isSampled()),spanProcessors:r}),this.meterProvider=new cs({resource:n,readers:i}),this.loggerProvider=new qc({resource:n,processors:a}),this.tracer=this.tracerProvider.getTracer(nh),this.meter=this.meterProvider.getMeter(nh),this.logger=this.loggerProvider.getLogger(nh),this.registeredInstrumentations=[],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:ph}),ph})();
|