{"version":3,"file":"BatchSpanProcessor.cjs","names":["BatchSpanProcessorBase"],"sources":["../../../../src/platform/browser/export/BatchSpanProcessor.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { BatchSpanProcessorBase } from '../../../export/BatchSpanProcessorBase';\nimport type { BatchSpanProcessorOptions } from '../../../types';\nimport { globalErrorHandler } from '@opentelemetry/core';\n\nexport class BatchSpanProcessor extends BatchSpanProcessorBase<BatchSpanProcessorOptions> {\n  private _visibilityChangeListener?: () => void;\n\n  constructor(options: BatchSpanProcessorOptions) {\n    super(options);\n    this.onInit(options);\n  }\n\n  private onInit(options: BatchSpanProcessorOptions): void {\n    if (\n      options.disableAutoFlushOnDocumentHide !== true &&\n      typeof document !== 'undefined'\n    ) {\n      this._visibilityChangeListener = () => {\n        if (document.visibilityState === 'hidden') {\n          this.forceFlush().catch(error => {\n            globalErrorHandler(error);\n          });\n        }\n      };\n      document.addEventListener(\n        'visibilitychange',\n        this._visibilityChangeListener\n      );\n    }\n  }\n\n  protected onShutdown(): void {\n    if (typeof document !== 'undefined') {\n      if (this._visibilityChangeListener) {\n        document.removeEventListener(\n          'visibilitychange',\n          this._visibilityChangeListener\n        );\n      }\n    }\n  }\n}\n"],"mappings":";;;AASA,IAAa,qBAAb,cAAwCA,+BAAAA,uBAAkD;CACxF;CAEA,YAAY,SAAoC;EAC9C,MAAM,OAAO;EACb,KAAK,OAAO,OAAO;CACrB;CAEA,OAAe,SAA0C;EACvD,IACE,QAAQ,mCAAmC,QAC3C,OAAO,aAAa,aACpB;GACA,KAAK,kCAAkC;IACrC,IAAI,SAAS,oBAAoB,UAC/B,KAAK,WAAW,CAAC,CAAC,OAAM,UAAS;KAC/B,CAAA,GAAA,oBAAA,mBAAA,CAAmB,KAAK;IAC1B,CAAC;GAEL;GACA,SAAS,iBACP,oBACA,KAAK,yBACP;EACF;CACF;CAEA,aAA6B;EAC3B,IAAI,OAAO,aAAa,aAClB;OAAA,KAAK,2BACP,SAAS,oBACP,oBACA,KAAK,yBACP;EAAA;CAGN;AACF"}