@ohif/app 3.14.0-beta.71 → 3.14.0-beta.72

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.
Files changed (23) hide show
  1. package/dist/{1645.bundle.618a2886.js → 1645.bundle.1a86b10e.js} +11 -28
  2. package/dist/{1283.bundle.f2c2bb56.js → 213.bundle.6bbe580b.js} +4743 -390
  3. package/dist/{8199.bundle.25557805.js → 2894.bundle.770d3d9e.js} +1355 -567
  4. package/dist/{3386.bundle.61e687a7.js → 3386.bundle.bdaa8014.js} +14 -5
  5. package/dist/{3044.bundle.039294b9.js → 4500.bundle.79728db8.js} +25 -17
  6. package/dist/{2894.bundle.d612efb2.js → 513.bundle.9c0548cf.js} +1 -1
  7. package/dist/{5143.bundle.67167d39.js → 5143.bundle.1ddc3eb4.js} +66 -42
  8. package/dist/{5320.bundle.0c7b2cb7.js → 5320.bundle.43308cb4.js} +18 -27
  9. package/dist/{5989.bundle.f8096a4e.js → 5989.bundle.6da1ff18.js} +19 -28
  10. package/dist/{4018.bundle.48c288e5.js → 6847.bundle.7fd47a86.js} +32 -5
  11. package/dist/{7464.bundle.492c83ce.js → 7464.bundle.36e9c349.js} +1440 -597
  12. package/dist/{1724.bundle.59b20c59.js → 8699.bundle.c00d7ae1.js} +480 -87
  13. package/dist/{9187.bundle.237037e4.js → 9187.bundle.134a42b2.js} +2 -2
  14. package/dist/{9481.bundle.027aa5ca.js → 9481.bundle.65162f9d.js} +2 -2
  15. package/dist/{9620.bundle.67375c83.js → 9620.bundle.e098e167.js} +2 -2
  16. package/dist/{9892.bundle.8c1ccb0e.js → 9892.bundle.fe68e426.js} +3 -3
  17. package/dist/{app.bundle.7ff9e2bc.js → app.bundle.58791784.js} +25 -22
  18. package/dist/{compute.bundle.79a2d455.js → compute.bundle.09be4c13.js} +8 -8
  19. package/dist/index.html +1 -1
  20. package/dist/{interpolation.bundle.302d242b.js → interpolation.bundle.1eeebcfe.js} +5 -5
  21. package/dist/{polySeg.bundle.aaf002b1.js → polySeg.bundle.5bc24361.js} +8 -8
  22. package/dist/sw.js +1 -1
  23. package/package.json +6 -6
@@ -115422,7 +115422,13 @@ __webpack_require__.d(__webpack_exports__, {
115422
115422
  /* import */ var _Viewport_js__rspack_import_3 = __webpack_require__(68840);
115423
115423
  /* import */ var _helpers_index_js__rspack_import_4 = __webpack_require__(83582);
115424
115424
  /* import */ var _GenericViewport_genericViewportDisplaySetAccess_js__rspack_import_5 = __webpack_require__(95023);
115425
- /* import */ var _utilities_ECGUtilities_js__rspack_import_6 = __webpack_require__(24511);
115425
+ /* import */ var _GenericViewport_ECG_ecgWaveform_js__rspack_import_6 = __webpack_require__(59076);
115426
+ /* import */ var _GenericViewport_ECG_ecgGeometry_js__rspack_import_7 = __webpack_require__(62195);
115427
+ /* import */ var _GenericViewport_ECG_ecgTraceLayouts_js__rspack_import_8 = __webpack_require__(1571);
115428
+ /* import */ var _GenericViewport_ECG_ecgDrawing_js__rspack_import_9 = __webpack_require__(8413);
115429
+
115430
+
115431
+
115426
115432
 
115427
115433
 
115428
115434
 
@@ -115430,7 +115436,6 @@ __webpack_require__.d(__webpack_exports__, {
115430
115436
 
115431
115437
 
115432
115438
 
115433
- const ECG_AMPLITUDE_INDEX_SIZE = 65536;
115434
115439
  class ECGViewport extends _Viewport_js__rspack_import_3/* ["default"] */.A {
115435
115440
  constructor(props) {
115436
115441
  super({
@@ -115443,6 +115448,7 @@ class ECGViewport extends _Viewport_js__rspack_import_3/* ["default"] */.A {
115443
115448
  this.ecgWidth = 0;
115444
115449
  this.ecgHeight = 0;
115445
115450
  this.channelScale = 0;
115451
+ this.layouts = [];
115446
115452
  this.ecgCamera = {
115447
115453
  panWorld: [0, 0],
115448
115454
  parallelScale: 1,
@@ -115461,7 +115467,7 @@ class ECGViewport extends _Viewport_js__rspack_import_3/* ["default"] */.A {
115461
115467
  return true;
115462
115468
  };
115463
115469
  this.getFrameOfReferenceUID = () => {
115464
- return `ecg-viewport-${this.id}`;
115470
+ return (0,_GenericViewport_ECG_ecgWaveform_js__rspack_import_6/* .getECGFrameOfReferenceUID */.ZE)(this.imageId) ?? `ecg-viewport-${this.id}`;
115465
115471
  };
115466
115472
  this.resize = () => {
115467
115473
  const canvas = this.canvas;
@@ -115472,7 +115478,6 @@ class ECGViewport extends _Viewport_js__rspack_import_3/* ["default"] */.A {
115472
115478
  }
115473
115479
  if (this.waveformData) {
115474
115480
  this.computeChannelScale();
115475
- this.recalculateHeight();
115476
115481
  }
115477
115482
  this.refreshRenderValues();
115478
115483
  this.renderFrame();
@@ -115546,6 +115551,9 @@ class ECGViewport extends _Viewport_js__rspack_import_3/* ["default"] */.A {
115546
115551
  this.getImageIds = () => {
115547
115552
  return this.imageId ? [this.imageId] : [];
115548
115553
  };
115554
+ this.getCurrentMode = () => {
115555
+ return this.waveformData ? 'ecg' : 'empty';
115556
+ };
115549
115557
  this.scroll = () => {
115550
115558
  };
115551
115559
  this.customRenderViewportToCanvas = () => {
@@ -115560,7 +115568,7 @@ class ECGViewport extends _Viewport_js__rspack_import_3/* ["default"] */.A {
115560
115568
  const m = transform.getMatrix();
115561
115569
  const ctx = this.canvasContext;
115562
115570
  ctx.resetTransform();
115563
- ctx.fillStyle = _utilities_ECGUtilities_js__rspack_import_6.ECG_RENDERING_COLORS.background;
115571
+ ctx.fillStyle = _GenericViewport_ECG_ecgWaveform_js__rspack_import_6/* .ECG_RENDERING_COLORS.background */.gk.background;
115564
115572
  ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
115565
115573
  ctx.setTransform(m[0] / dpr, m[1] / dpr, m[2] / dpr, m[3] / dpr, m[4] / dpr, m[5] / dpr);
115566
115574
  const layouts = this.computeChannelLayouts();
@@ -115601,7 +115609,7 @@ class ECGViewport extends _Viewport_js__rspack_import_3/* ["default"] */.A {
115601
115609
  async setEcg(imageId) {
115602
115610
  this.clearDisplaySets();
115603
115611
  this.imageId = imageId;
115604
- const { waveform, calibration } = await (0,_utilities_ECGUtilities_js__rspack_import_6.loadECGWaveform)(imageId);
115612
+ const { waveform, calibration } = await (0,_GenericViewport_ECG_ecgWaveform_js__rspack_import_6/* .loadECGWaveform */.Dt)(imageId);
115605
115613
  this.channels = waveform.channels.map((channel) => ({
115606
115614
  ...channel,
115607
115615
  visible: true,
@@ -115612,10 +115620,9 @@ class ECGViewport extends _Viewport_js__rspack_import_3/* ["default"] */.A {
115612
115620
  multiplexGroupLabel: waveform.multiplexGroupLabel,
115613
115621
  };
115614
115622
  this.calibration = calibration;
115615
- this.ecgWidth = Math.ceil((this.waveformData.numberOfSamples * _utilities_ECGUtilities_js__rspack_import_6.ECG_SECONDS_WIDTH) /
115623
+ this.ecgWidth = Math.ceil((this.waveformData.numberOfSamples * (/* inlined export .ECG_SECONDS_WIDTH */150)) /
115616
115624
  this.waveformData.samplingFrequency);
115617
115625
  this.computeChannelScale();
115618
- this.recalculateHeight();
115619
115626
  this.refreshRenderValues();
115620
115627
  this.renderFrame();
115621
115628
  }
@@ -115629,7 +115636,6 @@ class ECGViewport extends _Viewport_js__rspack_import_3/* ["default"] */.A {
115629
115636
  if (index >= 0 && index < this.channels.length) {
115630
115637
  this.channels[index].visible = visible;
115631
115638
  this.computeChannelScale();
115632
- this.recalculateHeight();
115633
115639
  this.refreshRenderValues();
115634
115640
  this.renderFrame();
115635
115641
  }
@@ -115647,32 +115653,32 @@ class ECGViewport extends _Viewport_js__rspack_import_3/* ["default"] */.A {
115647
115653
  return { width: this.ecgWidth, height: this.ecgHeight };
115648
115654
  }
115649
115655
  computeChannelScale() {
115650
- const visibleChannels = (0,_utilities_ECGUtilities_js__rspack_import_6.getVisibleECGChannelsByFlag)(this.channels);
115651
- if (visibleChannels.length === 0 || this.ecgWidth === 0) {
115656
+ if (!this.waveformData || this.ecgWidth === 0) {
115652
115657
  this.channelScale = 0;
115658
+ this.layouts = [];
115653
115659
  return;
115654
115660
  }
115655
- let maxRange = 1;
115656
- for (const channel of visibleChannels) {
115657
- const range = channel.max - channel.min;
115658
- maxRange = Math.max(maxRange, range);
115659
- }
115661
+ const { numberOfSamples } = this.waveformData;
115660
115662
  const canvasAspect = this.canvas.offsetHeight && this.canvas.offsetWidth
115661
115663
  ? this.canvas.offsetHeight / this.canvas.offsetWidth
115662
115664
  : 2 / 3;
115663
- const targetTotalHeight = this.ecgWidth * canvasAspect;
115664
- const totalSpacing = _utilities_ECGUtilities_js__rspack_import_6.ECG_CHANNEL_SPACING * visibleChannels.length;
115665
- const heightPerChannel = (targetTotalHeight - totalSpacing) / visibleChannels.length;
115666
- this.channelScale = heightPerChannel / (maxRange * 1.25);
115667
- }
115668
- recalculateHeight() {
115669
- this.ecgHeight = (0,_utilities_ECGUtilities_js__rspack_import_6.computeECGHeight)((0,_utilities_ECGUtilities_js__rspack_import_6.getVisibleECGChannelsByFlag)(this.channels), this.channelScale);
115665
+ const cells = (0,_GenericViewport_ECG_ecgTraceLayouts_js__rspack_import_8/* .resolveECGTraceCells */._3)({
115666
+ definition: (0,_GenericViewport_ECG_ecgTraceLayouts_js__rspack_import_8/* .resolveECGTraceLayout */.Hw)('12x1', { channels: this.channels }),
115667
+ channels: this.channels,
115668
+ numberOfSamples,
115669
+ viewSampleWindow: [0, numberOfSamples],
115670
+ });
115671
+ const geometry = (0,_GenericViewport_ECG_ecgGeometry_js__rspack_import_7/* .computeECGTraceGeometry */.io)({
115672
+ cells,
115673
+ ecgWidth: this.ecgWidth,
115674
+ targetHeight: this.ecgWidth * canvasAspect,
115675
+ });
115676
+ this.channelScale = geometry.channelScale;
115677
+ this.ecgHeight = geometry.ecgHeight;
115678
+ this.layouts = geometry.layouts;
115670
115679
  }
115671
115680
  computeChannelLayouts() {
115672
- return (0,_utilities_ECGUtilities_js__rspack_import_6.computeECGChannelLayouts)({
115673
- visibleChannels: (0,_utilities_ECGUtilities_js__rspack_import_6.getVisibleECGChannelsByFlag)(this.channels),
115674
- channelScale: this.channelScale,
115675
- });
115681
+ return this.layouts;
115676
115682
  }
115677
115683
  setProperties(props) {
115678
115684
  if (props.visibleChannels !== undefined) {
@@ -115680,7 +115686,6 @@ class ECGViewport extends _Viewport_js__rspack_import_3/* ["default"] */.A {
115680
115686
  this.channels[i].visible = props.visibleChannels.includes(i);
115681
115687
  }
115682
115688
  this.computeChannelScale();
115683
- this.recalculateHeight();
115684
115689
  this.refreshRenderValues();
115685
115690
  this.renderFrame();
115686
115691
  }
@@ -115690,7 +115695,6 @@ class ECGViewport extends _Viewport_js__rspack_import_3/* ["default"] */.A {
115690
115695
  channel.visible = true;
115691
115696
  }
115692
115697
  this.computeChannelScale();
115693
- this.recalculateHeight();
115694
115698
  this.refreshRenderValues();
115695
115699
  this.renderFrame();
115696
115700
  }
@@ -115715,7 +115719,7 @@ class ECGViewport extends _Viewport_js__rspack_import_3/* ["default"] */.A {
115715
115719
  this.ecgCamera.panWorld[1] - panWorldDelta[1],
115716
115720
  ];
115717
115721
  }
115718
- this.canvasContext.fillStyle = _utilities_ECGUtilities_js__rspack_import_6.ECG_RENDERING_COLORS.background;
115722
+ this.canvasContext.fillStyle = _GenericViewport_ECG_ecgWaveform_js__rspack_import_6/* .ECG_RENDERING_COLORS.background */.gk.background;
115719
115723
  this.canvasContext.fillRect(0, 0, this.canvas.width, this.canvas.height);
115720
115724
  this.renderFrame();
115721
115725
  }
@@ -115739,6 +115743,14 @@ class ECGViewport extends _Viewport_js__rspack_import_3/* ["default"] */.A {
115739
115743
  const panWorld = this.ecgCamera.panWorld;
115740
115744
  return [panWorld[0], panWorld[1]];
115741
115745
  }
115746
+ getViewReference(specifier = {}) {
115747
+ const viewReference = super.getViewReference(specifier);
115748
+ const lead = specifier.points?.[0]?.[2];
115749
+ if (Number.isFinite(lead)) {
115750
+ viewReference.sliceIndex = Math.round(lead);
115751
+ }
115752
+ return viewReference;
115753
+ }
115742
115754
  getViewReferenceId(_specifier) {
115743
115755
  return `imageId:${this.imageId}`;
115744
115756
  }
@@ -115758,14 +115770,16 @@ class ECGViewport extends _Viewport_js__rspack_import_3/* ["default"] */.A {
115758
115770
  if (!this.ecgWidth || !this.ecgHeight) {
115759
115771
  return;
115760
115772
  }
115761
- let worldToCanvasRatio = this.canvas.offsetWidth / this.ecgWidth;
115762
- if (this.ecgHeight * worldToCanvasRatio > this.canvas.offsetHeight) {
115763
- worldToCanvasRatio = this.canvas.offsetHeight / this.ecgHeight;
115773
+ const canvasWidth = this.canvas.offsetWidth || this.canvas.width || this.ecgWidth;
115774
+ const canvasHeight = this.canvas.offsetHeight || this.canvas.height || this.ecgHeight;
115775
+ let worldToCanvasRatio = canvasWidth / this.ecgWidth;
115776
+ if (this.ecgHeight * worldToCanvasRatio > canvasHeight) {
115777
+ worldToCanvasRatio = canvasHeight / this.ecgHeight;
115764
115778
  }
115765
115779
  const drawWidth = Math.floor(this.ecgWidth * worldToCanvasRatio);
115766
115780
  const drawHeight = Math.floor(this.ecgHeight * worldToCanvasRatio);
115767
- const xOffsetCanvas = (this.canvas.offsetWidth - drawWidth) / 2;
115768
- const yOffsetCanvas = (this.canvas.offsetHeight - drawHeight) / 2;
115781
+ const xOffsetCanvas = (canvasWidth - drawWidth) / 2;
115782
+ const yOffsetCanvas = (canvasHeight - drawHeight) / 2;
115769
115783
  const xOffsetWorld = xOffsetCanvas / worldToCanvasRatio;
115770
115784
  const yOffsetWorld = yOffsetCanvas / worldToCanvasRatio;
115771
115785
  this.ecgCamera.panWorld = [xOffsetWorld, yOffsetWorld];
@@ -115796,22 +115810,17 @@ class ECGViewport extends _Viewport_js__rspack_import_3/* ["default"] */.A {
115796
115810
  return transform;
115797
115811
  }
115798
115812
  drawGrid(ctx) {
115799
- (0,_utilities_ECGUtilities_js__rspack_import_6.drawECGGrid)(ctx, {
115813
+ (0,_GenericViewport_ECG_ecgDrawing_js__rspack_import_9/* .drawECGGrid */.Ce)(ctx, {
115800
115814
  ecgWidth: this.ecgWidth,
115801
115815
  ecgHeight: this.ecgHeight,
115802
115816
  channelScale: this.channelScale,
115803
115817
  });
115804
115818
  }
115805
115819
  drawTraces(ctx, layouts) {
115806
- (0,_utilities_ECGUtilities_js__rspack_import_6.drawECGTraces)({
115807
- ctx,
115808
- layouts,
115809
- ecgWidth: this.ecgWidth,
115810
- channelScale: this.channelScale,
115811
- });
115820
+ (0,_GenericViewport_ECG_ecgDrawing_js__rspack_import_9/* .drawECGTraces */.aL)({ ctx, layouts });
115812
115821
  }
115813
115822
  drawLabels(ctx, layouts) {
115814
- (0,_utilities_ECGUtilities_js__rspack_import_6.drawECGLabels)(ctx, layouts, this.getWorldToCanvasRatio());
115823
+ (0,_GenericViewport_ECG_ecgDrawing_js__rspack_import_9/* .drawECGLabels */.z0)(ctx, layouts, this.getWorldToCanvasRatio());
115815
115824
  }
115816
115825
  getImageData() {
115817
115826
  if (!this.waveformData) {
@@ -115819,11 +115828,11 @@ class ECGViewport extends _Viewport_js__rspack_import_3/* ["default"] */.A {
115819
115828
  }
115820
115829
  const nSamples = this.waveformData.numberOfSamples;
115821
115830
  const nChannels = this.waveformData.numberOfChannels;
115822
- const dimensions = [nSamples, ECG_AMPLITUDE_INDEX_SIZE, nChannels];
115831
+ const dimensions = [nSamples, _GenericViewport_ECG_ecgWaveform_js__rspack_import_6/* .ECG_AMPLITUDE_INDEX_SIZE */.Fi, nChannels];
115823
115832
  const spacing = [1, 1, 1];
115824
115833
  const origin = [0, 0, 0];
115825
115834
  const direction = [1, 0, 0, 0, 1, 0, 0, 0, 1];
115826
- const amplitudeOffset = ECG_AMPLITUDE_INDEX_SIZE / 2;
115835
+ const amplitudeOffset = _GenericViewport_ECG_ecgWaveform_js__rspack_import_6/* .ECG_AMPLITUDE_INDEX_SIZE */.Fi / 2;
115827
115836
  const imageData = {
115828
115837
  getDirection: () => direction,
115829
115838
  getDimensions: () => dimensions,
@@ -115897,14 +115906,16 @@ __webpack_require__.d(__webpack_exports__, {
115897
115906
  },
115898
115907
  25499(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
115899
115908
  "use strict";
115900
- /* import */ var _utilities_ECGUtilities_js__rspack_import_0 = __webpack_require__(24511);
115909
+ /* import */ var _ecgWaveform_js__rspack_import_0 = __webpack_require__(59076);
115901
115910
  /* import */ var _genericViewportDisplaySetAccess_js__rspack_import_1 = __webpack_require__(95023);
115902
115911
 
115903
115912
 
115904
115913
  class DefaultECGDataProvider {
115905
- async load(dataId) {
115914
+ async load(dataId, options) {
115906
115915
  const sourceDataId = (0,_genericViewportDisplaySetAccess_js__rspack_import_1/* .getGenericViewportSourceDataId */._d)(dataId);
115907
- const { waveform } = await (0,_utilities_ECGUtilities_js__rspack_import_0.loadECGWaveform)(sourceDataId);
115916
+ const { waveform } = await (0,_ecgWaveform_js__rspack_import_0/* .loadECGWaveform */.Dt)(sourceDataId, {
115917
+ multiplexGroupIndex: options?.multiplexGroupIndex,
115918
+ });
115908
115919
  return {
115909
115920
  id: dataId,
115910
115921
  type: 'ecg',
@@ -115934,62 +115945,36 @@ var DefaultRenderPathResolver = __webpack_require__(65336);
115934
115945
  var enums = __webpack_require__(71088);
115935
115946
  // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/triggerEvent.js
115936
115947
  var triggerEvent = __webpack_require__(84444);
115937
- // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/ECGUtilities.js
115938
- var ECGUtilities = __webpack_require__(24511);
115939
- // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/GenericViewport/ECG/ecgViewportCamera.js
115940
- var ecgViewportCamera = __webpack_require__(93502);
115948
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/GenericViewport/ECG/ecgDrawing.js
115949
+ var ecgDrawing = __webpack_require__(8413);
115941
115950
  ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/GenericViewport/ECG/CanvasECGRenderPath.js
115942
115951
 
115943
115952
 
115944
115953
 
115945
-
115946
115954
  class CanvasECGRenderPath {
115947
- async addData(ctx, data, options) {
115948
- const waveform = data;
115955
+ async addData(ctx, _data, _options) {
115949
115956
  const rendering = {
115950
115957
  renderMode: 'signal2d',
115951
115958
  canvas: ctx.canvas,
115952
115959
  canvasContext: ctx.canvasContext,
115953
- metrics: {
115954
- ecgWidth: 1,
115955
- ecgHeight: 1,
115956
- channelScale: 1,
115957
- worldToCanvasRatio: 1,
115958
- xOffsetCanvas: 0,
115959
- yOffsetCanvas: 0,
115960
- },
115961
115960
  };
115962
115961
  return {
115963
115962
  rendering,
115964
- updateDataPresentation: (props) => {
115965
- this.updateDataPresentation(rendering, props);
115963
+ updateDataPresentation: () => {
115966
115964
  },
115967
- applyViewState: (camera) => {
115968
- this.applyViewState(rendering, camera);
115965
+ applyViewState: () => {
115969
115966
  },
115970
115967
  getFrameOfReferenceUID: () => {
115971
- return this.getFrameOfReferenceUID(ctx);
115968
+ return ctx.getResolvedView()?.getFrameOfReferenceUID();
115972
115969
  },
115973
115970
  render: () => {
115974
- this.render(ctx, rendering, waveform);
115971
+ drawFrame(ctx);
115975
115972
  },
115976
115973
  removeData: () => {
115977
115974
  this.removeData();
115978
115975
  },
115979
115976
  };
115980
115977
  }
115981
- updateDataPresentation(rendering, props) {
115982
- rendering.currentDataPresentation = props;
115983
- }
115984
- applyViewState(rendering, camera) {
115985
- rendering.currentCamera = camera;
115986
- }
115987
- getFrameOfReferenceUID(ctx) {
115988
- return `ecg-viewport-${ctx.viewportId}`;
115989
- }
115990
- render(ctx, rendering, waveform) {
115991
- drawFrame(ctx, rendering, waveform);
115992
- }
115993
115978
  removeData() {
115994
115979
  }
115995
115980
  }
@@ -116005,82 +115990,49 @@ class CanvasECGPath {
116005
115990
  return new CanvasECGRenderPath();
116006
115991
  }
116007
115992
  }
116008
- function getEffectiveTransform(metrics, camera, canvas) {
116009
- const mapping = (0,ecgViewportCamera/* .resolveECGCanvasMapping */.MY)({
116010
- metrics,
116011
- camera,
116012
- canvas,
116013
- });
116014
- return {
116015
- effectiveRatio: mapping.effectiveRatio,
116016
- xOffset: mapping.xOffset,
116017
- yOffset: mapping.yOffset,
116018
- };
116019
- }
116020
- function computeTimeWindow(waveform, camera) {
116021
- const durationMs = (waveform.numberOfSamples / waveform.samplingFrequency) * 1000;
116022
- const startMs = Math.max(0, Math.min(camera.timeRange[0], durationMs));
116023
- const requestedEnd = Math.max(startMs + 1, camera.timeRange[1]);
116024
- const endMs = Math.max(startMs + 1, Math.min(requestedEnd, durationMs));
116025
- const startIndex = Math.max(0, Math.min(waveform.numberOfSamples - 1, Math.floor((startMs / 1000) * waveform.samplingFrequency)));
116026
- const endIndex = Math.max(startIndex + 1, Math.min(waveform.numberOfSamples, Math.ceil((endMs / 1000) * waveform.samplingFrequency)));
116027
- return {
116028
- startMs,
116029
- endMs,
116030
- startIndex,
116031
- endIndex,
116032
- };
116033
- }
116034
- function drawFrame(ecgCtx, ecgRendering, waveform) {
116035
- const { canvas, canvasContext, currentCamera, currentDataPresentation } = ecgRendering;
116036
- if (!currentCamera) {
115993
+ function drawFrame(ecgCtx) {
115994
+ const { canvas, canvasContext } = ecgCtx;
115995
+ (0,ecgDrawing/* .ensureECGCanvasSize */.zf)(canvas);
115996
+ const resolvedView = ecgCtx.getResolvedView();
115997
+ if (!resolvedView) {
116037
115998
  return;
116038
115999
  }
116039
- const visibleChannels = (0,ECGUtilities.getVisibleECGChannels)(waveform.channels, currentDataPresentation?.visibleChannels);
116040
- (0,ECGUtilities.ensureECGCanvasSize)(canvas);
116041
- const metrics = (0,ECGUtilities.computeECGRenderMetrics)({
116042
- canvas,
116043
- visibleChannels,
116044
- windowMs: Math.max(1, currentCamera.timeRange[1] - currentCamera.timeRange[0]),
116045
- valueRange: currentCamera.valueRange,
116046
- });
116047
- const layouts = (0,ECGUtilities.computeECGChannelLayouts)({
116048
- visibleChannels,
116049
- channelScale: metrics.channelScale,
116050
- });
116051
- const timeWindow = computeTimeWindow(waveform, currentCamera);
116000
+ const viewState = resolvedView.state.viewState;
116001
+ const dataPresentation = resolvedView.state.dataPresentation;
116002
+ const metrics = resolvedView.metrics;
116003
+ const layouts = resolvedView.channelLayouts;
116004
+ const { effectiveRatio, xOffset, yOffset } = resolvedView.canvasTransform;
116052
116005
  const dpr = window.devicePixelRatio || 1;
116053
- ecgRendering.metrics = metrics;
116054
- const { effectiveRatio, xOffset, yOffset } = getEffectiveTransform(metrics, currentCamera, canvas);
116055
116006
  canvasContext.resetTransform();
116056
116007
  canvasContext.fillStyle = '#000000';
116057
116008
  canvasContext.fillRect(0, 0, canvas.width, canvas.height);
116058
- if (currentDataPresentation?.visible === false) {
116009
+ if (dataPresentation?.visible === false) {
116059
116010
  return;
116060
116011
  }
116061
- canvasContext.globalAlpha = currentDataPresentation?.opacity ?? 1;
116012
+ canvasContext.globalAlpha = dataPresentation?.opacity ?? 1;
116062
116013
  canvasContext.setTransform(effectiveRatio * dpr, 0, 0, effectiveRatio * dpr, xOffset * dpr, yOffset * dpr);
116063
- (0,ECGUtilities.drawECGGrid)(canvasContext, metrics, {
116064
- showGrid: currentDataPresentation?.showGrid,
116065
- });
116066
- (0,ECGUtilities.drawECGTraces)({
116014
+ (0,ecgDrawing/* .drawECGGrid */.Ce)(canvasContext, {
116015
+ ...metrics,
116016
+ sensitivityMmMv: viewState.sensitivityMmMv,
116017
+ showAmplitudeLabels: dataPresentation?.showAmplitudeLabels,
116018
+ }, {
116019
+ showGrid: dataPresentation?.showGrid,
116020
+ bounds: resolvedView.canvasBounds,
116021
+ }, layouts);
116022
+ (0,ecgDrawing/* .drawECGTraces */.aL)({
116067
116023
  ctx: canvasContext,
116068
116024
  layouts,
116069
- ecgWidth: metrics.ecgWidth,
116070
- channelScale: metrics.channelScale,
116071
- startIndex: timeWindow.startIndex,
116072
- endIndex: timeWindow.endIndex,
116073
- lineWidth: currentDataPresentation?.lineWidth,
116074
- amplitudeScale: currentDataPresentation?.amplitudeScale,
116025
+ lineWidth: dataPresentation?.lineWidth,
116026
+ amplitudeScale: resolvedView.amplitudeScale,
116075
116027
  });
116076
- (0,ECGUtilities.drawECGLabels)(canvasContext, layouts, metrics.worldToCanvasRatio);
116077
116028
  canvasContext.resetTransform();
116029
+ (0,ecgDrawing/* .drawECGCanvasLabels */.Rt)(canvasContext, layouts, resolvedView.canvasTransform, dpr);
116078
116030
  canvasContext.globalAlpha = 1;
116079
116031
  (0,triggerEvent/* ["default"] */.A)(ecgCtx.element, enums.Events.IMAGE_RENDERED, {
116080
116032
  element: ecgCtx.element,
116081
116033
  viewportId: ecgCtx.viewportId,
116082
116034
  renderingEngineId: ecgCtx.renderingEngineId,
116083
- rendering: ecgRendering,
116035
+ resolvedView,
116084
116036
  });
116085
116037
  }
116086
116038
 
@@ -116101,11 +116053,17 @@ function createECGRenderPathResolver(paths = createDefaultECGRenderPaths()) {
116101
116053
  /* import */ var _helpers_getOrCreateCanvas_js__rspack_import_0 = __webpack_require__(567);
116102
116054
  /* import */ var _GenericViewport_js__rspack_import_1 = __webpack_require__(13991);
116103
116055
  /* import */ var _enums_index_js__rspack_import_2 = __webpack_require__(71088);
116104
- /* import */ var _utilities_ECGUtilities_js__rspack_import_3 = __webpack_require__(24511);
116105
- /* import */ var _DefaultECGDataProvider_js__rspack_import_4 = __webpack_require__(25499);
116106
- /* import */ var _ECGRenderPathResolver_js__rspack_import_5 = __webpack_require__(92925);
116107
- /* import */ var _ecgViewportCamera_js__rspack_import_6 = __webpack_require__(93502);
116108
- /* import */ var _ECGResolvedView_js__rspack_import_7 = __webpack_require__(11750);
116056
+ /* import */ var _ecgWaveform_js__rspack_import_3 = __webpack_require__(59076);
116057
+ /* import */ var _genericViewportDisplaySetAccess_js__rspack_import_4 = __webpack_require__(95023);
116058
+ /* import */ var _utilities_imageIdToURI_js__rspack_import_5 = __webpack_require__(60465);
116059
+ /* import */ var _DefaultECGDataProvider_js__rspack_import_6 = __webpack_require__(25499);
116060
+ /* import */ var _ECGRenderPathResolver_js__rspack_import_7 = __webpack_require__(92925);
116061
+ /* import */ var _ecgTraceLayouts_js__rspack_import_8 = __webpack_require__(1571);
116062
+ /* import */ var _ecgViewportCamera_js__rspack_import_9 = __webpack_require__(93502);
116063
+ /* import */ var _ECGResolvedView_js__rspack_import_10 = __webpack_require__(11750);
116064
+
116065
+
116066
+
116109
116067
 
116110
116068
 
116111
116069
 
@@ -116114,7 +116072,6 @@ function createECGRenderPathResolver(paths = createDefaultECGRenderPaths()) {
116114
116072
 
116115
116073
 
116116
116074
 
116117
- const ECG_AMPLITUDE_INDEX_SIZE = 65536;
116118
116075
  class ECGViewport extends _GenericViewport_js__rspack_import_1/* ["default"] */.A {
116119
116076
  static get useCustomRenderingPipeline() {
116120
116077
  return true;
@@ -116128,9 +116085,9 @@ class ECGViewport extends _GenericViewport_js__rspack_import_1/* ["default"] */.
116128
116085
  this.renderingEngineId = args.renderingEngineId;
116129
116086
  this.canvas = (0,_helpers_getOrCreateCanvas_js__rspack_import_0/* ["default"] */.Ay)(this.element);
116130
116087
  this.canvasContext = this.canvas.getContext('2d');
116131
- this.dataProvider = args.dataProvider || new _DefaultECGDataProvider_js__rspack_import_4/* .DefaultECGDataProvider */.c();
116088
+ this.dataProvider = args.dataProvider || new _DefaultECGDataProvider_js__rspack_import_6/* .DefaultECGDataProvider */.c();
116132
116089
  this.renderPathResolver =
116133
- args.renderPathResolver || (0,_ECGRenderPathResolver_js__rspack_import_5/* .createECGRenderPathResolver */.X)();
116090
+ args.renderPathResolver || (0,_ECGRenderPathResolver_js__rspack_import_7/* .createECGRenderPathResolver */.X)();
116134
116091
  this.renderContext = {
116135
116092
  viewportId: this.id,
116136
116093
  type: 'ecg',
@@ -116138,10 +116095,12 @@ class ECGViewport extends _GenericViewport_js__rspack_import_1/* ["default"] */.
116138
116095
  element: this.element,
116139
116096
  canvas: this.canvas,
116140
116097
  canvasContext: this.canvasContext,
116098
+ getResolvedView: () => this.getResolvedView(),
116141
116099
  };
116142
- this.viewState = (0,_ecgViewportCamera_js__rspack_import_6/* .createDefaultECGViewState */.hl)({
116100
+ this.viewState = (0,_ecgViewportCamera_js__rspack_import_9/* .createDefaultECGViewState */.hl)({
116143
116101
  timeRange: [0, 1],
116144
116102
  valueRange: [-1, 1],
116103
+ traceLayout: args.defaultOptions?.traceLayout,
116145
116104
  });
116146
116105
  this.element.setAttribute('data-viewport-uid', this.id);
116147
116106
  this.element.setAttribute('data-rendering-engine-uid', this.renderingEngineId);
@@ -116149,38 +116108,82 @@ class ECGViewport extends _GenericViewport_js__rspack_import_1/* ["default"] */.
116149
116108
  }
116150
116109
  async setDisplaySets(...entries) {
116151
116110
  this.removeAllData();
116152
- for (const { displaySetId } of entries) {
116153
- const waveform = await this.loadWaveformData(displaySetId);
116111
+ for (const { displaySetId, options } of entries) {
116112
+ const waveform = await this.loadWaveformData(displaySetId, options);
116154
116113
  const durationMs = (waveform.numberOfSamples / waveform.samplingFrequency) * 1000;
116114
+ const { traceLayout, sweepSpeed, sensitivityMmMv, amplitudeScale } = this.viewState;
116155
116115
  this.setDefaultDataPresentation(displaySetId, {
116156
116116
  visible: true,
116157
116117
  opacity: 1,
116158
- visibleChannels: waveform.channels.map((_channel, index) => index),
116159
116118
  lineWidth: 1,
116160
- amplitudeScale: 1,
116161
116119
  showGrid: true,
116162
116120
  });
116163
- this.viewState = (0,_ecgViewportCamera_js__rspack_import_6/* .createDefaultECGViewState */.hl)({
116121
+ this.viewState = (0,_ecgViewportCamera_js__rspack_import_9/* .createDefaultECGViewState */.hl)({
116164
116122
  timeRange: [0, durationMs],
116165
- valueRange: (0,_utilities_ECGUtilities_js__rspack_import_3.getDefaultECGValueRange)(waveform),
116123
+ valueRange: (0,_ecgWaveform_js__rspack_import_3/* .getDefaultECGValueRange */.dz)(waveform),
116124
+ traceLayout,
116125
+ sweepSpeed,
116126
+ sensitivityMmMv,
116127
+ amplitudeScale,
116166
116128
  });
116129
+ warnIfAmplitudeScaleIgnored(this.viewState);
116167
116130
  await this.addLoadedData(displaySetId, waveform, {
116168
116131
  renderMode: 'signal2d',
116169
116132
  });
116170
116133
  }
116171
116134
  }
116135
+ getTraceLayoutNames() {
116136
+ const waveform = this.getWaveformData();
116137
+ return (0,_ecgTraceLayouts_js__rspack_import_8/* .getECGTraceLayoutNames */.JS)(waveform
116138
+ ? {
116139
+ channels: waveform.channels,
116140
+ numberOfSamples: waveform.numberOfSamples,
116141
+ samplingFrequency: waveform.samplingFrequency,
116142
+ }
116143
+ : undefined);
116144
+ }
116145
+ getSweepSpeed() {
116146
+ return this.viewState.sweepSpeed ?? (/* inlined export .ECG_DEFAULT_SWEEP_SPEED_MM_S */25);
116147
+ }
116148
+ setSweepSpeed(speed) {
116149
+ this.setViewState({ sweepSpeed: speed });
116150
+ }
116151
+ getSensitivity() {
116152
+ return this.viewState.sensitivityMmMv;
116153
+ }
116154
+ setSensitivity(sensitivity) {
116155
+ this.setViewState({ sensitivityMmMv: sensitivity });
116156
+ }
116172
116157
  getWaveformData() {
116173
116158
  return this.getWaveformBindingData() ?? null;
116174
116159
  }
116175
- getViewReference(_specifier = {}) {
116160
+ getCurrentMode() {
116161
+ return this.getWaveformData() ? 'ecg' : 'empty';
116162
+ }
116163
+ getViewReference(specifier = {}) {
116176
116164
  const dataId = this.getFirstBinding()?.data.id;
116165
+ const lead = specifier.points?.[0]?.[2];
116177
116166
  return {
116178
116167
  FrameOfReferenceUID: this.getFrameOfReferenceUID(),
116179
116168
  dataId,
116180
116169
  referencedImageId: this.getCurrentImageId(),
116181
- sliceIndex: 0,
116170
+ ...(Number.isFinite(lead) ? { sliceIndex: Math.round(lead) } : {}),
116182
116171
  };
116183
116172
  }
116173
+ isReferenceViewable(viewReference, options = {}) {
116174
+ if (!viewReference) {
116175
+ return false;
116176
+ }
116177
+ const { sliceIndex, ...recordReference } = viewReference;
116178
+ if (!super.isReferenceViewable(recordReference, options)) {
116179
+ return false;
116180
+ }
116181
+ if (typeof sliceIndex !== 'number') {
116182
+ return true;
116183
+ }
116184
+ const resolvedView = this.getResolvedView();
116185
+ return !resolvedView || !!resolvedView.findLayoutForZ(sliceIndex);
116186
+ }
116184
116187
  getViewReferenceId(_specifier = {}) {
116185
116188
  return `imageId:${this.getCurrentImageId()}`;
116186
116189
  }
@@ -116193,7 +116196,7 @@ class ECGViewport extends _GenericViewport_js__rspack_import_1/* ["default"] */.
116193
116196
  return (this.getResolvedView()?.zoom ?? Math.max(this.viewState.scale ?? 1, 0.001));
116194
116197
  }
116195
116198
  normalizeViewState(viewState) {
116196
- return (0,_ecgViewportCamera_js__rspack_import_6/* .normalizeECGViewState */.$3)(viewState);
116199
+ return (0,_ecgViewportCamera_js__rspack_import_9/* .normalizeECGViewState */.$3)(viewState);
116197
116200
  }
116198
116201
  getReferenceViewContexts() {
116199
116202
  const binding = this.getFirstBinding();
@@ -116205,7 +116208,7 @@ class ECGViewport extends _GenericViewport_js__rspack_import_1/* ["default"] */.
116205
116208
  dataId: binding.data.id,
116206
116209
  dataIds: [binding.data.id],
116207
116210
  frameOfReferenceUID: this.getFrameOfReferenceUID(),
116208
- imageIds: [binding.data.id],
116211
+ imageIds: this.getImageIds(),
116209
116212
  currentImageIdIndex: 0,
116210
116213
  },
116211
116214
  ];
@@ -116236,8 +116239,7 @@ class ECGViewport extends _GenericViewport_js__rspack_import_1/* ["default"] */.
116236
116239
  if (!waveform) {
116237
116240
  return [];
116238
116241
  }
116239
- const dataId = waveform.id;
116240
- const visibleChannels = new Set(this.getDisplaySetPresentation(dataId)?.visibleChannels ||
116242
+ const visibleChannels = new Set(this.viewState.visibleChannels ||
116241
116243
  waveform.channels.map((_channel, index) => index));
116242
116244
  return waveform.channels.map((channel, index) => ({
116243
116245
  name: channel.name,
@@ -116245,13 +116247,13 @@ class ECGViewport extends _GenericViewport_js__rspack_import_1/* ["default"] */.
116245
116247
  }));
116246
116248
  }
116247
116249
  getContentDimensions() {
116248
- const rendering = this.getCurrentRendering();
116249
- if (!rendering) {
116250
+ const resolvedView = this.getResolvedView();
116251
+ if (!resolvedView) {
116250
116252
  return { width: 0, height: 0 };
116251
116253
  }
116252
116254
  return {
116253
- width: rendering.metrics.ecgWidth,
116254
- height: rendering.metrics.ecgHeight,
116255
+ width: resolvedView.metrics.ecgWidth,
116256
+ height: resolvedView.metrics.ecgHeight,
116255
116257
  };
116256
116258
  }
116257
116259
  resize() {
@@ -116270,44 +116272,94 @@ class ECGViewport extends _GenericViewport_js__rspack_import_1/* ["default"] */.
116270
116272
  customRenderViewportToCanvas() {
116271
116273
  this.render();
116272
116274
  }
116273
- resetViewState() {
116274
- const previousCamera = this.getCameraForEvent();
116275
- this.viewState = (0,_ecgViewportCamera_js__rspack_import_6/* .createDefaultECGViewState */.hl)({
116276
- timeRange: this.viewState.timeRange,
116277
- valueRange: this.viewState.valueRange,
116278
- });
116279
- this.modified(previousCamera);
116275
+ resetViewState(options) {
116276
+ const { resetPan = true, resetZoom = true, resetTimeRange = false, } = options || {};
116277
+ const nextViewState = { scrollOffset: 0 };
116278
+ if (resetPan) {
116279
+ nextViewState.anchorWorld = undefined;
116280
+ nextViewState.anchorCanvas = [0.5, 0.5];
116281
+ }
116282
+ if (resetZoom) {
116283
+ nextViewState.scale = 1;
116284
+ nextViewState.scaleMode = 'fit';
116285
+ }
116286
+ if (resetTimeRange) {
116287
+ nextViewState.timeRange = [0, this.getDurationMs()];
116288
+ }
116289
+ this.setViewState(nextViewState);
116280
116290
  this.triggerCameraResetEvent();
116281
116291
  return true;
116282
116292
  }
116283
116293
  getRotation() {
116284
116294
  return 0;
116285
116295
  }
116286
- scroll() {
116296
+ async scroll(delta = 1) {
116297
+ const timeWindow = this.getResolvedView()?.timeWindow;
116298
+ if (timeWindow) {
116299
+ const windowMs = Math.max(1, timeWindow.endMs - timeWindow.startMs);
116300
+ this.scrollToTime(timeWindow.startMs + windowMs * delta);
116301
+ }
116302
+ return this.getCurrentImageId();
116303
+ }
116304
+ scrollToTime(timeMs) {
116305
+ const timeWindow = this.getResolvedView()?.timeWindow;
116306
+ const durationMs = this.getDurationMs();
116307
+ if (!timeWindow) {
116308
+ return;
116309
+ }
116310
+ const windowMs = Math.max(1, timeWindow.endMs - timeWindow.startMs);
116311
+ if (windowMs >= durationMs) {
116312
+ return;
116313
+ }
116314
+ const nextStart = Math.max(0, Math.min(timeMs, durationMs - windowMs));
116315
+ if (nextStart === timeWindow.startMs) {
116316
+ return;
116317
+ }
116318
+ this.setViewState({ timeRange: [nextStart, nextStart + windowMs] });
116319
+ }
116320
+ getDurationMs() {
116321
+ const waveform = this.getWaveformData();
116322
+ if (!waveform) {
116323
+ return 0;
116324
+ }
116325
+ return (waveform.numberOfSamples / waveform.samplingFrequency) * 1000;
116326
+ }
116327
+ getSourceDataId() {
116328
+ return this.getFirstBinding()?.data.id;
116287
116329
  }
116288
116330
  getCurrentImageId() {
116289
- const binding = this.getFirstBinding();
116290
- return binding?.data.id;
116331
+ const dataId = this.getSourceDataId();
116332
+ return dataId ? (0,_genericViewportDisplaySetAccess_js__rspack_import_4/* .getGenericViewportSourceDataId */._d)(dataId) : undefined;
116291
116333
  }
116292
116334
  getCurrentImageIdIndex() {
116293
116335
  return 0;
116294
116336
  }
116295
116337
  getImageIds() {
116296
- const binding = this.getFirstBinding();
116297
- return binding ? [binding.data.id] : [];
116338
+ const imageId = this.getCurrentImageId();
116339
+ return imageId ? [imageId] : [];
116340
+ }
116341
+ hasImageId(imageId) {
116342
+ return this.getImageIds().includes(imageId);
116343
+ }
116344
+ hasImageURI(imageURI) {
116345
+ const imageId = this.getCurrentImageId();
116346
+ return (!!imageId && (imageId === imageURI || (0,_utilities_imageIdToURI_js__rspack_import_5/* ["default"] */.A)(imageId) === imageURI));
116298
116347
  }
116299
116348
  getImageData() {
116300
116349
  const waveform = this.getWaveformBindingData();
116301
116350
  if (!waveform) {
116302
- return null;
116351
+ return undefined;
116303
116352
  }
116304
116353
  const nSamples = waveform.numberOfSamples;
116305
- const nChannels = waveform.channels.length;
116306
- const dimensions = [nSamples, ECG_AMPLITUDE_INDEX_SIZE, nChannels];
116354
+ const dimensions = [
116355
+ nSamples,
116356
+ _ecgWaveform_js__rspack_import_3/* .ECG_AMPLITUDE_INDEX_SIZE */.Fi,
116357
+ (/* inlined export .ECG_LEAD_COPY_STRIDE */1000) * (/* inlined export .ECG_LEAD_COPY_STRIDE */1000),
116358
+ ];
116307
116359
  const spacing = [1, 1, 1];
116308
116360
  const origin = [0, 0, 0];
116309
116361
  const direction = [1, 0, 0, 0, 1, 0, 0, 0, 1];
116310
- const amplitudeOffset = ECG_AMPLITUDE_INDEX_SIZE / 2;
116362
+ const amplitudeOffset = _ecgWaveform_js__rspack_import_3/* .ECG_AMPLITUDE_INDEX_SIZE */.Fi / 2;
116311
116363
  const scalarData = new Int16Array(0);
116312
116364
  const imageData = {
116313
116365
  getDirection: () => direction,
@@ -116329,20 +116381,16 @@ class ECGViewport extends _GenericViewport_js__rspack_import_1/* ["default"] */.
116329
116381
  imageData,
116330
116382
  scalarData,
116331
116383
  hasPixelSpacing: false,
116384
+ calibration: waveform.calibration,
116332
116385
  preScale: { scaled: false },
116333
- metadata: { Modality: 'ECG', FrameOfReferenceUID: '' },
116386
+ metadata: {
116387
+ Modality: 'ECG',
116388
+ FrameOfReferenceUID: this.getFrameOfReferenceUID(),
116389
+ },
116334
116390
  };
116335
116391
  }
116336
- setScaleAtCanvasPoint(scale, canvasPoint) {
116337
- const resolvedView = this.getResolvedView();
116338
- if (!resolvedView) {
116339
- this.setZoom(scale);
116340
- return;
116341
- }
116342
- this.applyResolvedViewState(resolvedView.withZoom(scale, canvasPoint).state.viewState);
116343
- }
116344
- async loadWaveformData(dataId) {
116345
- const waveform = await this.dataProvider.load(dataId);
116392
+ async loadWaveformData(dataId, options) {
116393
+ const waveform = await this.dataProvider.load(dataId, options);
116346
116394
  if (!isECGWaveformData(waveform)) {
116347
116395
  throw new Error(`[ECGViewport] Loaded data for ${dataId} is not a valid ECG waveform`);
116348
116396
  }
@@ -116355,25 +116403,16 @@ class ECGViewport extends _GenericViewport_js__rspack_import_1/* ["default"] */.
116355
116403
  }
116356
116404
  return binding.data;
116357
116405
  }
116358
- getCurrentRendering() {
116359
- const binding = this.getFirstBinding();
116360
- if (!binding || !isECGCanvasRendering(binding.rendering)) {
116361
- return;
116362
- }
116363
- return binding.rendering;
116364
- }
116365
116406
  getResolvedView() {
116366
116407
  const waveform = this.getWaveformBindingData();
116367
- const rendering = this.getCurrentRendering();
116368
- if (!waveform || !rendering) {
116408
+ if (!waveform) {
116369
116409
  return;
116370
116410
  }
116371
- return new _ECGResolvedView_js__rspack_import_7/* ["default"] */.A({
116411
+ return new _ECGResolvedView_js__rspack_import_10/* ["default"] */.A({
116372
116412
  viewState: this.viewState,
116373
116413
  canvas: this.canvas,
116374
116414
  dataPresentation: this.getDisplaySetPresentation(waveform.id),
116375
- frameOfReferenceUID: `ecg-viewport-${this.id}`,
116376
- metrics: rendering.metrics,
116415
+ frameOfReferenceUID: (0,_ecgWaveform_js__rspack_import_3/* .getECGFrameOfReferenceUID */.ZE)(this.getCurrentImageId()),
116377
116416
  waveform,
116378
116417
  });
116379
116418
  }
@@ -116392,11 +116431,201 @@ function isECGWaveformData(data) {
116392
116431
  typeof waveform.samplingFrequency === 'number' &&
116393
116432
  typeof waveform.numberOfChannels === 'number');
116394
116433
  }
116395
- function isECGCanvasRendering(rendering) {
116396
- return rendering.renderMode === 'signal2d';
116434
+ let warnedAmplitudeScale = false;
116435
+ function warnIfAmplitudeScaleIgnored(viewState) {
116436
+ const { amplitudeScale, sensitivityMmMv } = viewState;
116437
+ if (warnedAmplitudeScale ||
116438
+ !sensitivityMmMv ||
116439
+ amplitudeScale === undefined ||
116440
+ amplitudeScale === 1) {
116441
+ return;
116442
+ }
116443
+ warnedAmplitudeScale = true;
116444
+ console.warn(`[ECG] amplitudeScale ${amplitudeScale} has no effect with sensitivityMmMv ${sensitivityMmMv}`);
116397
116445
  }
116398
116446
 
116399
116447
 
116448
+ },
116449
+ 8413(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
116450
+ "use strict";
116451
+ /* import */ var _ecgWaveform_js__rspack_import_0 = __webpack_require__(59076);
116452
+
116453
+ function drawECGGrid(ctx, metrics, options, layouts) {
116454
+ if (options?.showGrid === false || metrics.channelScale <= 0) {
116455
+ return;
116456
+ }
116457
+ const { ecgWidth, ecgHeight, channelScale, sweepSpeed, sensitivityMmMv, showAmplitudeLabels = false, worldToCanvasRatio = 1, pxPerSecond, } = metrics;
116458
+ let minorH;
116459
+ let majorH;
116460
+ if (sensitivityMmMv != null && sensitivityMmMv > 0) {
116461
+ minorH = (/* inlined export .ECG_PX_PER_MM */3.779);
116462
+ majorH = (/* inlined export .ECG_PX_PER_MM */3.779) * 5;
116463
+ }
116464
+ else {
116465
+ const minLineSpacing = 8;
116466
+ let horizontalGridUnit = 100;
116467
+ while (horizontalGridUnit * channelScale < minLineSpacing) {
116468
+ horizontalGridUnit *= 2;
116469
+ }
116470
+ minorH = horizontalGridUnit * channelScale;
116471
+ majorH = minorH * 5;
116472
+ }
116473
+ const resolvedSweepSpeed = sweepSpeed != null && sweepSpeed > 0
116474
+ ? sweepSpeed
116475
+ : (/* inlined export .ECG_DEFAULT_SWEEP_SPEED_MM_S */25);
116476
+ const resolvedPxPerSecond = pxPerSecond != null && pxPerSecond > 0 ? pxPerSecond : (/* inlined export .ECG_SECONDS_WIDTH */150);
116477
+ const minorV = resolvedPxPerSecond / resolvedSweepSpeed;
116478
+ const majorV = minorV * 5;
116479
+ const { minX = 0, minY = 0, maxX = ecgWidth, maxY = ecgHeight, } = options?.bounds ?? {};
116480
+ const effectiveMinorH = minorH * worldToCanvasRatio;
116481
+ const effectiveMinorV = minorV * worldToCanvasRatio;
116482
+ if (effectiveMinorH >= 4 && effectiveMinorV >= 4) {
116483
+ ctx.strokeStyle = _ecgWaveform_js__rspack_import_0/* .ECG_RENDERING_COLORS.gridMinor */.gk.gridMinor;
116484
+ ctx.lineWidth = 0.5;
116485
+ ctx.beginPath();
116486
+ forEachGridLine(minY, maxY, minorH, (y, k) => {
116487
+ if (k % 5 !== 0) {
116488
+ ctx.moveTo(minX, y);
116489
+ ctx.lineTo(maxX, y);
116490
+ }
116491
+ });
116492
+ forEachGridLine(minX, maxX, minorV, (x, k) => {
116493
+ if (k % 5 !== 0) {
116494
+ ctx.moveTo(x, minY);
116495
+ ctx.lineTo(x, maxY);
116496
+ }
116497
+ });
116498
+ ctx.stroke();
116499
+ }
116500
+ ctx.strokeStyle = _ecgWaveform_js__rspack_import_0/* .ECG_RENDERING_COLORS.gridMajor */.gk.gridMajor;
116501
+ ctx.lineWidth = 1;
116502
+ ctx.beginPath();
116503
+ forEachGridLine(minY, maxY, majorH, (y) => {
116504
+ ctx.moveTo(minX, y);
116505
+ ctx.lineTo(maxX, y);
116506
+ });
116507
+ forEachGridLine(minX, maxX, majorV, (x) => {
116508
+ ctx.moveTo(x, minY);
116509
+ ctx.lineTo(x, maxY);
116510
+ });
116511
+ ctx.stroke();
116512
+ if (showAmplitudeLabels &&
116513
+ sensitivityMmMv != null &&
116514
+ sensitivityMmMv > 0 &&
116515
+ layouts) {
116516
+ ctx.fillStyle = _ecgWaveform_js__rspack_import_0/* .ECG_RENDERING_COLORS.label */.gk.label;
116517
+ const mvPerMajor = 5 / sensitivityMmMv;
116518
+ const fontSize = 10;
116519
+ ctx.font = `${fontSize}px monospace`;
116520
+ const firstColumnLayouts = layouts.filter((layout) => !layout.xOffset || layout.xOffset === 0);
116521
+ if (majorH >= fontSize + 4) {
116522
+ firstColumnLayouts.forEach((layout) => {
116523
+ const { baseline, itemHeight } = layout;
116524
+ const yPlus = baseline - majorH;
116525
+ const yMinus = baseline + majorH;
116526
+ if (yPlus >= baseline - itemHeight) {
116527
+ ctx.fillText(`+${mvPerMajor.toFixed(1)} mV`, 5, yPlus - 2);
116528
+ }
116529
+ if (yMinus <= baseline + itemHeight) {
116530
+ ctx.fillText(`-${mvPerMajor.toFixed(1)} mV`, 5, yMinus - 2);
116531
+ }
116532
+ });
116533
+ }
116534
+ }
116535
+ }
116536
+ function drawECGTraces(args) {
116537
+ const { ctx, layouts, lineWidth = 1, amplitudeScale = 1 } = args;
116538
+ layouts.forEach(({ channel, baseline, channelScale, xOffset, width, itemHeight, yOffset, startSample, endSample, }) => {
116539
+ const sampleCount = Math.max(1, endSample - startSample);
116540
+ const lastSample = Math.min(endSample, channel.data.length);
116541
+ ctx.strokeStyle = _ecgWaveform_js__rspack_import_0/* .ECG_RENDERING_COLORS.baseline */.gk.baseline;
116542
+ ctx.lineWidth = 2;
116543
+ ctx.beginPath();
116544
+ ctx.moveTo(xOffset, baseline);
116545
+ ctx.lineTo(xOffset + width, baseline);
116546
+ ctx.stroke();
116547
+ if (lastSample <= startSample) {
116548
+ return;
116549
+ }
116550
+ ctx.save?.();
116551
+ ctx.beginPath?.();
116552
+ ctx.rect?.(xOffset, yOffset - itemHeight * 2, width, itemHeight * 3);
116553
+ ctx.clip?.();
116554
+ ctx.strokeStyle = _ecgWaveform_js__rspack_import_0/* .ECG_RENDERING_COLORS.trace */.gk.trace;
116555
+ ctx.lineWidth = lineWidth;
116556
+ ctx.beginPath();
116557
+ const step = width / sampleCount;
116558
+ for (let index = startSample; index < lastSample; index++) {
116559
+ const x = xOffset + (index - startSample) * step;
116560
+ const y = baseline - channel.data[index] * channelScale * amplitudeScale;
116561
+ if (index === startSample) {
116562
+ ctx.moveTo(x, y);
116563
+ }
116564
+ else {
116565
+ ctx.lineTo(x, y);
116566
+ }
116567
+ }
116568
+ ctx.stroke();
116569
+ ctx.restore?.();
116570
+ });
116571
+ }
116572
+ function drawECGLabels(ctx, layouts, worldToCanvasRatio) {
116573
+ const fontSize = 14 / (worldToCanvasRatio || 1);
116574
+ layouts.forEach(({ label, itemHeight, yOffset, xOffset }) => {
116575
+ const labelY = yOffset - itemHeight + fontSize;
116576
+ ctx.font = `${fontSize}px monospace`;
116577
+ const textWidth = ctx.measureText(label).width;
116578
+ ctx.fillStyle = _ecgWaveform_js__rspack_import_0/* .ECG_RENDERING_COLORS.background */.gk.background;
116579
+ ctx.fillRect(xOffset + 5, labelY - fontSize, textWidth + 4, fontSize + 4);
116580
+ ctx.fillStyle = _ecgWaveform_js__rspack_import_0/* .ECG_RENDERING_COLORS.label */.gk.label;
116581
+ ctx.fillText(label, xOffset + 5, labelY);
116582
+ });
116583
+ }
116584
+ function drawECGCanvasLabels(ctx, layouts, transform, dpr = 1) {
116585
+ const fontSize = 12 * dpr;
116586
+ const { effectiveRatio, xOffset, yOffset } = transform;
116587
+ ctx.font = `${fontSize}px monospace`;
116588
+ layouts.forEach((layout) => {
116589
+ const x = (layout.xOffset * effectiveRatio + xOffset + 5) * dpr;
116590
+ const y = ((layout.yOffset - layout.itemHeight) * effectiveRatio + yOffset + 2) *
116591
+ dpr +
116592
+ fontSize;
116593
+ const textWidth = ctx.measureText(layout.label).width;
116594
+ ctx.fillStyle = _ecgWaveform_js__rspack_import_0/* .ECG_RENDERING_COLORS.background */.gk.background;
116595
+ ctx.fillRect(x, y - fontSize, textWidth + 4 * dpr, fontSize + 4 * dpr);
116596
+ ctx.fillStyle = _ecgWaveform_js__rspack_import_0/* .ECG_RENDERING_COLORS.label */.gk.label;
116597
+ ctx.fillText(layout.label, x, y);
116598
+ });
116599
+ }
116600
+ function forEachGridLine(min, max, step, draw) {
116601
+ if (!(step > 0)) {
116602
+ return;
116603
+ }
116604
+ for (let k = Math.ceil(min / step); k * step <= max; k++) {
116605
+ draw(k * step, Math.abs(k));
116606
+ }
116607
+ }
116608
+ function ensureECGCanvasSize(canvas) {
116609
+ const dpr = window.devicePixelRatio || 1;
116610
+ const width = Math.max(1, canvas.clientWidth || canvas.width || 1);
116611
+ const height = Math.max(1, canvas.clientHeight || canvas.height || 1);
116612
+ const nextWidth = Math.floor(width * dpr);
116613
+ const nextHeight = Math.floor(height * dpr);
116614
+ if (canvas.width !== nextWidth || canvas.height !== nextHeight) {
116615
+ canvas.width = nextWidth;
116616
+ canvas.height = nextHeight;
116617
+ }
116618
+ }
116619
+
116620
+ __webpack_require__.d(__webpack_exports__, {
116621
+ Ce: () => (drawECGGrid),
116622
+ Rt: () => (drawECGCanvasLabels),
116623
+ aL: () => (drawECGTraces),
116624
+ z0: () => (drawECGLabels),
116625
+ zf: () => (ensureECGCanvasSize)
116626
+ });
116627
+
116628
+
116400
116629
  },
116401
116630
  45687(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
116402
116631
  "use strict";
@@ -116425,98 +116654,309 @@ __webpack_require__.d(__webpack_exports__, {
116425
116654
 
116426
116655
 
116427
116656
  },
116428
- 93502(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
116657
+ 1571(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
116429
116658
  "use strict";
116430
- function createDefaultECGViewState(args) {
116659
+ /* import */ var _utilities_clamp_js__rspack_import_0 = __webpack_require__(20637);
116660
+
116661
+ const LEAD_II_CODES = new Set(['5.6.3-9-2', '2:2']);
116662
+ const GRID_MIN_LEADS = 8;
116663
+ const GRID_MIN_SECONDS = 5;
116664
+ const traceLayouts = new Map();
116665
+ const warnedNames = new Set();
116666
+ function registerECGTraceLayout(name, layout, options = {}) {
116667
+ if (traceLayouts.has(name)) {
116668
+ throw new Error(`ECG trace layout "${name}" is already registered`);
116669
+ }
116670
+ traceLayouts.set(name, {
116671
+ factory: typeof layout === 'function' ? layout : () => layout,
116672
+ supports: options.supports,
116673
+ });
116674
+ }
116675
+ function getECGTraceLayoutNames(context) {
116676
+ return Array.from(traceLayouts.entries())
116677
+ .filter(([, entry]) => !context || !entry.supports || entry.supports(context))
116678
+ .map(([name]) => name);
116679
+ }
116680
+ function getECGTraceLayout(traceLayout, context) {
116681
+ if (typeof traceLayout !== 'string') {
116682
+ return traceLayout;
116683
+ }
116684
+ return traceLayouts.get(traceLayout)?.factory(context);
116685
+ }
116686
+ function resolveDefaultECGTraceLayout(context) {
116687
+ const { channels, numberOfSamples = 0, samplingFrequency = 0 } = context;
116688
+ const isLong = !(numberOfSamples > 0 && samplingFrequency > 0) ||
116689
+ numberOfSamples / samplingFrequency >= GRID_MIN_SECONDS;
116690
+ return channels.length >= GRID_MIN_LEADS && isLong ? '3x4+1' : '12x1';
116691
+ }
116692
+ function resolveECGTraceLayout(traceLayout, context) {
116693
+ const defaultLayout = resolveDefaultECGTraceLayout(context);
116694
+ const definition = getECGTraceLayout(traceLayout ?? defaultLayout, context);
116695
+ if (definition) {
116696
+ return definition;
116697
+ }
116698
+ if (!warnedNames.has(traceLayout)) {
116699
+ warnedNames.add(traceLayout);
116700
+ console.warn(`[ECG] Unknown trace layout "${traceLayout}", using "${defaultLayout}"`);
116701
+ }
116702
+ return getECGTraceLayout(defaultLayout, context);
116703
+ }
116704
+ function hasViewTimeRegion(definition) {
116705
+ return definition.regions.some((region) => (region.time ?? 'view') === 'view');
116706
+ }
116707
+ const ECG_LEAD_COPY_STRIDE = 1000;
116708
+ const SINGLE_GROUP = { index: 0, count: 1 };
116709
+ function getECGLeadZ(channelIndex, copy, group = SINGLE_GROUP) {
116710
+ return (channelIndex + ECG_LEAD_COPY_STRIDE * (copy * group.count + group.index));
116711
+ }
116712
+ function findECGLayoutForZ(layouts, z, group = SINGLE_GROUP) {
116713
+ const exact = layouts.find((item) => item.leadIndex === z);
116714
+ if (exact) {
116715
+ return exact;
116716
+ }
116717
+ const k = Math.floor(z / ECG_LEAD_COPY_STRIDE);
116718
+ if (k < 0 || k % group.count !== group.index) {
116719
+ return;
116720
+ }
116721
+ const baseZ = getECGLeadZ(z % ECG_LEAD_COPY_STRIDE, 0, group);
116722
+ return layouts.find((item) => item.leadIndex === baseZ);
116723
+ }
116724
+ function resolveECGTraceCells(args) {
116725
+ const { definition, channels, numberOfSamples, viewSampleWindow, visibleChannels, group, } = args;
116726
+ const visible = visibleChannels ? new Set(visibleChannels) : undefined;
116727
+ const copies = new Map();
116728
+ const cells = [];
116729
+ definition.regions.forEach((region, regionIndex) => {
116730
+ const channelIndex = typeof region.lead === 'number'
116731
+ ? region.lead
116732
+ : findLeadByCode(channels, region.lead);
116733
+ const channel = channels[channelIndex];
116734
+ if (!channel) {
116735
+ return;
116736
+ }
116737
+ const copy = copies.get(channelIndex) ?? 0;
116738
+ copies.set(channelIndex, copy + 1);
116739
+ const leadIndex = getECGLeadZ(channelIndex, copy, group);
116740
+ const time = region.time ?? 'view';
116741
+ const [startSample, endSample] = time === 'view'
116742
+ ? viewSampleWindow
116743
+ : [
116744
+ Math.floor((0,_utilities_clamp_js__rspack_import_0/* ["default"] */.A)(time[0], 0, 1) * numberOfSamples),
116745
+ Math.floor((0,_utilities_clamp_js__rspack_import_0/* ["default"] */.A)(time[1], 0, 1) * numberOfSamples),
116746
+ ];
116747
+ cells.push({
116748
+ region,
116749
+ regionIndex,
116750
+ channel,
116751
+ channelIndex,
116752
+ leadIndex,
116753
+ visible: channel.data.length > 0 &&
116754
+ channel.visible !== false &&
116755
+ (!visible || visible.has(channelIndex)),
116756
+ startSample,
116757
+ endSample,
116758
+ label: region.label ?? channel.name,
116759
+ });
116760
+ });
116761
+ return cells;
116762
+ }
116763
+ function findLeadByCode(channels, lead) {
116764
+ const byCode = channels.findIndex((channel) => channel.code === lead);
116765
+ return byCode >= 0
116766
+ ? byCode
116767
+ : channels.findIndex((channel) => !channel.code && channel.name === lead);
116768
+ }
116769
+ function findLeadII(channels) {
116770
+ const byCode = channels.findIndex((channel) => LEAD_II_CODES.has(channel.code));
116771
+ if (byCode >= 0) {
116772
+ return byCode;
116773
+ }
116774
+ const byName = channels.findIndex((channel) => /\bii\b/.test((channel.name ?? '').toLowerCase()));
116775
+ if (byName >= 0) {
116776
+ return byName;
116777
+ }
116778
+ return channels.length > 1 ? 1 : 0;
116779
+ }
116780
+ function createRowsLayout({ channels, }) {
116781
+ const count = channels.length;
116431
116782
  return {
116432
- timeRange: [...args.timeRange],
116433
- valueRange: [...args.valueRange],
116434
- scrollOffset: 0,
116435
- anchorCanvas: [0.5, 0.5],
116436
- scale: 1,
116437
- scaleMode: 'fit',
116438
- rotation: 0,
116783
+ regions: channels.map((_channel, index) => ({
116784
+ lead: index,
116785
+ bounds: {
116786
+ minX: 0,
116787
+ maxX: 1,
116788
+ minY: index / count,
116789
+ maxY: (index + 1) / count,
116790
+ },
116791
+ time: 'view',
116792
+ })),
116439
116793
  };
116440
116794
  }
116441
- function normalizeECGViewState(camera) {
116442
- return {
116443
- timeRange: [...camera.timeRange],
116444
- valueRange: [...camera.valueRange],
116445
- ...(camera.scrollOffset !== undefined
116446
- ? { scrollOffset: camera.scrollOffset }
116447
- : {}),
116448
- anchorCanvas: cloneAnchorCanvas(camera.anchorCanvas ?? [0.5, 0.5]),
116449
- scale: Math.max(camera.scale ?? 1, 0.001),
116450
- scaleMode: 'fit',
116451
- rotation: 0,
116452
- ...(camera.anchorWorld
116453
- ? {
116454
- anchorWorld: clonePoint(camera.anchorWorld),
116455
- }
116456
- : {}),
116795
+ function createGridLayout(rowsPerColumn, nominalColumns, withRhythmStrip) {
116796
+ return ({ channels }) => {
116797
+ const columns = Math.max(nominalColumns, Math.ceil(channels.length / rowsPerColumn));
116798
+ const totalRows = rowsPerColumn + (withRhythmStrip ? 1 : 0);
116799
+ const regions = channels.map((_channel, index) => {
116800
+ const column = Math.floor(index / rowsPerColumn);
116801
+ const row = index % rowsPerColumn;
116802
+ return {
116803
+ lead: index,
116804
+ bounds: {
116805
+ minX: column / columns,
116806
+ maxX: (column + 1) / columns,
116807
+ minY: row / totalRows,
116808
+ maxY: (row + 1) / totalRows,
116809
+ },
116810
+ time: [column / columns, (column + 1) / columns],
116811
+ };
116812
+ });
116813
+ if (withRhythmStrip && channels.length) {
116814
+ regions.push({
116815
+ id: 'rhythm',
116816
+ lead: findLeadII(channels),
116817
+ bounds: { minX: 0, maxX: 1, minY: rowsPerColumn / totalRows, maxY: 1 },
116818
+ time: [0, 1],
116819
+ });
116820
+ }
116821
+ return { regions };
116457
116822
  };
116458
116823
  }
116459
- function resolveECGCanvasMapping(args) {
116460
- const { metrics, camera, canvas } = args;
116461
- const scale = Math.max(camera?.scale ?? 1, 0.001);
116462
- const effectiveRatio = metrics.worldToCanvasRatio * scale;
116463
- const drawWidth = metrics.ecgWidth * effectiveRatio;
116464
- const drawHeight = metrics.ecgHeight * effectiveRatio;
116465
- const centeredXOffset = (canvas.clientWidth - drawWidth) / 2;
116466
- const centeredYOffset = (canvas.clientHeight - drawHeight) / 2;
116467
- const anchorCanvas = cloneAnchorCanvas(camera?.anchorCanvas ?? [0.5, 0.5]);
116468
- const anchorWorld = clonePoint(camera?.anchorWorld) ??
116469
- [metrics.ecgWidth / 2, metrics.ecgHeight / 2];
116470
- const xOffset = canvas.clientWidth * anchorCanvas[0] - anchorWorld[0] * effectiveRatio;
116471
- const yOffset = canvas.clientHeight * anchorCanvas[1] - anchorWorld[1] * effectiveRatio;
116824
+ const supportsGrid = ({ channels }) => channels.length >= GRID_MIN_LEADS;
116825
+ registerECGTraceLayout('12x1', createRowsLayout);
116826
+ registerECGTraceLayout('6x2', createGridLayout(6, 2, false), {
116827
+ supports: supportsGrid,
116828
+ });
116829
+ registerECGTraceLayout('3x4', createGridLayout(3, 4, false), {
116830
+ supports: supportsGrid,
116831
+ });
116832
+ registerECGTraceLayout('3x4+1', createGridLayout(3, 4, true), {
116833
+ supports: supportsGrid,
116834
+ });
116835
+
116836
+ __webpack_require__.d(__webpack_exports__, {
116837
+ $s: () => (getECGTraceLayout),
116838
+ Gc: () => (registerECGTraceLayout),
116839
+ Hw: () => (resolveECGTraceLayout),
116840
+ JS: () => (getECGTraceLayoutNames),
116841
+ Qf: () => (resolveDefaultECGTraceLayout),
116842
+ _3: () => (resolveECGTraceCells),
116843
+ _f: () => (findECGLayoutForZ),
116844
+ xL: () => (hasViewTimeRegion)
116845
+ });
116846
+
116847
+
116848
+ },
116849
+ 59076(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
116850
+ "use strict";
116851
+ /* import */ var _cornerstonejs_metadata__rspack_import_0 = __webpack_require__(86049);
116852
+ /* import */ var _enums_index_js__rspack_import_1 = __webpack_require__(71088);
116853
+ /* import */ var _metaData_js__rspack_import_2 = __webpack_require__(52284);
116854
+
116855
+
116856
+
116857
+ const ECG_DEFAULT_SWEEP_SPEED_MM_S = 25;
116858
+ const ECG_CLINICAL_SWEEP_SPEEDS = [12.5, 25, 50];
116859
+ const ECG_CLINICAL_SENSITIVITIES = [2.5, 5, 10, 20];
116860
+ const ECG_PX_PER_MM = 3.779;
116861
+ const ECG_SECONDS_WIDTH = 150;
116862
+ const ECG_CHANNEL_SPACING = 5;
116863
+ const ECG_DEFAULT_MV_PER_UNIT = _cornerstonejs_metadata__rspack_import_0/* .utilities.ECG_DEFAULT_MV_PER_UNIT */.BF.Fc;
116864
+ const ECG_AMPLITUDE_INDEX_SIZE = _cornerstonejs_metadata__rspack_import_0/* .utilities.ECG_AMPLITUDE_INDEX_SIZE */.BF.Fi;
116865
+ const ECG_RENDERING_COLORS = {
116866
+ gridMajor: '#7f0000',
116867
+ gridMinor: '#3f0000',
116868
+ baseline: '#7f4c00',
116869
+ trace: '#ffffff',
116870
+ label: '#ffff00',
116871
+ background: '#000000',
116872
+ };
116873
+ function getECGChannelMvPerUnit(channel) {
116874
+ return Number.isFinite(channel.mvPerUnit) && channel.mvPerUnit > 0
116875
+ ? channel.mvPerUnit
116876
+ : ECG_DEFAULT_MV_PER_UNIT;
116877
+ }
116878
+ function getECGFrameOfReferenceUID(imageId) {
116879
+ if (!imageId) {
116880
+ return;
116881
+ }
116882
+ return (_metaData_js__rspack_import_2.get(_enums_index_js__rspack_import_1.MetadataModules.SOP_COMMON, imageId)?.sopInstanceUID ||
116883
+ `ecg:${imageId}`);
116884
+ }
116885
+ async function loadECGWaveform(dataId, options = {}) {
116886
+ const ecgModule = _metaData_js__rspack_import_2.getMetaData(_enums_index_js__rspack_import_1.MetadataModules.ECG, dataId, options);
116887
+ if (!ecgModule?.waveformData?.retrieveBulkData) {
116888
+ throw new Error(`[ECG] No ECG waveform data for ${dataId}`);
116889
+ }
116890
+ const { numberOfWaveformChannels: numberOfChannels, numberOfWaveformSamples: numberOfSamples, samplingFrequency, waveformBitsAllocated: bitsAllocated = 16, waveformSampleInterpretation: sampleInterpretation = 'SS', multiplexGroupLabel, multiplexGroupIndex = 0, totalMultiplexGroups: numberOfMultiplexGroups = 1, channelDefinitionSequence: channelDefinitions = [], } = ecgModule;
116891
+ const channelArrays = await ecgModule.waveformData.retrieveBulkData();
116892
+ const calibration = _metaData_js__rspack_import_2.getMetaData(_enums_index_js__rspack_import_1.MetadataModules.CALIBRATION, dataId, options);
116893
+ const channels = [];
116894
+ for (let index = 0; index < numberOfChannels; index++) {
116895
+ const channelDefinition = channelDefinitions[index] || {};
116896
+ const source = channelDefinition.channelSourceSequence;
116897
+ const data = channelArrays[index] || new Int16Array(0);
116898
+ const { min, max } = computeECGMinMax(data);
116899
+ channels.push({
116900
+ name: source?.codeMeaning || `Channel ${index + 1}`,
116901
+ code: source?.codeValue,
116902
+ data,
116903
+ min,
116904
+ max,
116905
+ mvPerUnit: getECGChannelMvPerUnit(channelDefinition),
116906
+ });
116907
+ }
116472
116908
  return {
116473
- anchorWorld,
116474
- anchorCanvas,
116475
- canvasHeight: canvas.clientHeight,
116476
- canvasWidth: canvas.clientWidth,
116477
- centeredXOffset,
116478
- centeredYOffset,
116479
- effectiveRatio,
116480
- xOffset,
116481
- yOffset,
116909
+ waveform: {
116910
+ channels,
116911
+ numberOfChannels,
116912
+ numberOfSamples,
116913
+ samplingFrequency,
116914
+ bitsAllocated,
116915
+ sampleInterpretation,
116916
+ multiplexGroupLabel,
116917
+ multiplexGroupIndex,
116918
+ numberOfMultiplexGroups,
116919
+ calibration,
116920
+ },
116921
+ calibration,
116482
116922
  };
116483
116923
  }
116484
- function getPanForECGCanvasMapping(mapping) {
116485
- return [
116486
- mapping.xOffset - mapping.centeredXOffset,
116487
- mapping.yOffset - mapping.centeredYOffset,
116488
- ];
116489
- }
116490
- function getAnchorWorldForPan(pan, mapping) {
116491
- return [
116492
- (mapping.canvasWidth * mapping.anchorCanvas[0] -
116493
- (mapping.centeredXOffset + pan[0])) /
116494
- mapping.effectiveRatio,
116495
- (mapping.canvasHeight * mapping.anchorCanvas[1] -
116496
- (mapping.centeredYOffset + pan[1])) /
116497
- mapping.effectiveRatio,
116498
- ];
116499
- }
116500
- function getAnchorWorldForCanvasPoint(canvasPoint, mapping) {
116501
- return [
116502
- (canvasPoint[0] - mapping.xOffset) / mapping.effectiveRatio,
116503
- (canvasPoint[1] - mapping.yOffset) / mapping.effectiveRatio,
116504
- ];
116505
- }
116506
- function clonePoint(point) {
116507
- return point ? [point[0], point[1]] : undefined;
116924
+ function computeECGMinMax(data) {
116925
+ let min = 0;
116926
+ let max = 0;
116927
+ for (let index = 0; index < data.length; index++) {
116928
+ if (data[index] < min) {
116929
+ min = data[index];
116930
+ }
116931
+ if (data[index] > max) {
116932
+ max = data[index];
116933
+ }
116934
+ }
116935
+ return { min, max };
116508
116936
  }
116509
- function cloneAnchorCanvas(anchorCanvas) {
116510
- return [anchorCanvas[0], anchorCanvas[1]];
116937
+ function getDefaultECGValueRange(waveform) {
116938
+ let min = 0;
116939
+ let max = 0;
116940
+ waveform.channels.forEach((channel) => {
116941
+ min = Math.min(min, channel.min);
116942
+ max = Math.max(max, channel.max);
116943
+ });
116944
+ if (min === max) {
116945
+ return [-1, 1];
116946
+ }
116947
+ return [min, max];
116511
116948
  }
116512
116949
 
116513
116950
  __webpack_require__.d(__webpack_exports__, {
116514
- $3: () => (normalizeECGViewState),
116515
- H3: () => (getAnchorWorldForCanvasPoint),
116516
- Kw: () => (getAnchorWorldForPan),
116517
- MY: () => (resolveECGCanvasMapping),
116518
- cP: () => (getPanForECGCanvasMapping),
116519
- hl: () => (createDefaultECGViewState)
116951
+ Dt: () => (loadECGWaveform),
116952
+ Dz: () => (getECGChannelMvPerUnit),
116953
+ ZE: () => (getECGFrameOfReferenceUID),
116954
+ dz: () => (getDefaultECGValueRange)
116955
+ }, {
116956
+ Fi: ECG_AMPLITUDE_INDEX_SIZE,
116957
+ Ii: ECG_CLINICAL_SWEEP_SPEEDS,
116958
+ M2: ECG_CLINICAL_SENSITIVITIES,
116959
+ gk: ECG_RENDERING_COLORS
116520
116960
  });
116521
116961
 
116522
116962
 
@@ -116526,7 +116966,10 @@ __webpack_require__.d(__webpack_exports__, {
116526
116966
  /* import */ var _ecgProjectionAdapter_js__rspack_import_0 = __webpack_require__(45687);
116527
116967
  /* import */ var _ECGRenderPathResolver_js__rspack_import_1 = __webpack_require__(92925);
116528
116968
  /* import */ var _DefaultECGDataProvider_js__rspack_import_2 = __webpack_require__(25499);
116529
- /* import */ var _ECGViewport_js__rspack_import_3 = __webpack_require__(80153);
116969
+ /* import */ var _ecgTraceLayouts_js__rspack_import_3 = __webpack_require__(1571);
116970
+ /* import */ var _ecgWaveform_js__rspack_import_4 = __webpack_require__(59076);
116971
+ /* import */ var _ECGViewport_js__rspack_import_5 = __webpack_require__(80153);
116972
+
116530
116973
 
116531
116974
 
116532
116975
 
@@ -116536,9 +116979,16 @@ const ecgProjection = {
116536
116979
  };
116537
116980
 
116538
116981
 
116982
+
116539
116983
  __webpack_require__.d(__webpack_exports__, {
116540
- Ay: () => (/* reexport safe */ _ECGViewport_js__rspack_import_3.A),
116984
+ $s: () => (/* reexport safe */ _ecgTraceLayouts_js__rspack_import_3.$s),
116985
+ Ay: () => (/* reexport safe */ _ECGViewport_js__rspack_import_5.A),
116986
+ Gc: () => (/* reexport safe */ _ecgTraceLayouts_js__rspack_import_3.Gc),
116987
+ Ii: () => (/* reexport safe */ _ecgWaveform_js__rspack_import_4.Ii),
116541
116988
  JG: () => (/* reexport safe */ _ECGRenderPathResolver_js__rspack_import_1.J),
116989
+ JS: () => (/* reexport safe */ _ecgTraceLayouts_js__rspack_import_3.JS),
116990
+ M2: () => (/* reexport safe */ _ecgWaveform_js__rspack_import_4.M2),
116991
+ Qf: () => (/* reexport safe */ _ecgTraceLayouts_js__rspack_import_3.Qf),
116542
116992
  Xy: () => (/* reexport safe */ _ECGRenderPathResolver_js__rspack_import_1.X),
116543
116993
  cs: () => (/* reexport safe */ _DefaultECGDataProvider_js__rspack_import_2.c)
116544
116994
  }, {
@@ -116570,6 +117020,8 @@ class GenericViewport {
116570
117020
  };
116571
117021
  this.id = args.id;
116572
117022
  this.element = args.element;
117023
+ this.canvasToWorld = this.canvasToWorld.bind(this);
117024
+ this.worldToCanvas = this.worldToCanvas.bind(this);
116573
117025
  }
116574
117026
  async setDisplaySets(...entries) {
116575
117027
  this.removeAllData();
@@ -120493,8 +120945,6 @@ class PlanarViewport extends _GenericViewport_js__rspack_import_15/* ["default"]
120493
120945
  this.sHeight = args.sHeight;
120494
120946
  this.defaultOptions = cloneViewportOptions(args.defaultOptions || {});
120495
120947
  this.options = cloneViewportOptions(this.defaultOptions);
120496
- this.canvasToWorld = this.canvasToWorld.bind(this);
120497
- this.worldToCanvas = this.worldToCanvas.bind(this);
120498
120948
  this.dataProvider = args.dataProvider || new _DefaultPlanarDataProvider_js__rspack_import_17/* .DefaultPlanarDataProvider */.x();
120499
120949
  this.renderPathResolver =
120500
120950
  args.renderPathResolver || (0,_PlanarRenderPathResolver_js__rspack_import_18/* .createPlanarRenderPathResolver */.I)();
@@ -125928,10 +126378,36 @@ __webpack_require__.d(__webpack_exports__, {
125928
126378
  },
125929
126379
  95023(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
125930
126380
  "use strict";
125931
- /* import */ var _utilities_genericViewportDisplaySetMetadataProvider_js__rspack_import_0 = __webpack_require__(51127);
126381
+ /* import */ var _cornerstonejs_metadata__rspack_import_0 = __webpack_require__(86049);
126382
+ /* import */ var _utilities_genericViewportDisplaySetMetadataProvider_js__rspack_import_1 = __webpack_require__(51127);
126383
+
125932
126384
 
125933
126385
  function getGenericViewportRegisteredDisplaySet(displaySetId) {
125934
- return _utilities_genericViewportDisplaySetMetadataProvider_js__rspack_import_0/* ["default"].get */.A.get(_utilities_genericViewportDisplaySetMetadataProvider_js__rspack_import_0/* ["default"].VIEWPORT_V2_DISPLAY_SET */.A.VIEWPORT_V2_DISPLAY_SET, displaySetId);
126386
+ return (_utilities_genericViewportDisplaySetMetadataProvider_js__rspack_import_1/* ["default"].get */.A.get(_utilities_genericViewportDisplaySetMetadataProvider_js__rspack_import_1/* ["default"].VIEWPORT_V2_DISPLAY_SET */.A.VIEWPORT_V2_DISPLAY_SET, displaySetId) ??
126387
+ getCachedDisplaySet(displaySetId));
126388
+ }
126389
+ function getCachedDisplaySet(displaySetId) {
126390
+ const displaySet = _cornerstonejs_metadata__rspack_import_0/* .metaData.getTyped */.wx.FE(_cornerstonejs_metadata__rspack_import_0/* .Enums.MetadataModules.DISPLAY_SET */.fX.nb.DISPLAY_SET, displaySetId);
126391
+ if (!isRecord(displaySet) ||
126392
+ (displaySet.displaySetId !== displaySetId &&
126393
+ displaySet.displaySetInstanceUID !== displaySetId)) {
126394
+ return;
126395
+ }
126396
+ const imageIds = isStringArray(displaySet.imageIds)
126397
+ ? [...displaySet.imageIds]
126398
+ : [];
126399
+ const underlyingImageIds = isStringArray(displaySet.underlyingImageIds)
126400
+ ? displaySet.underlyingImageIds
126401
+ : [];
126402
+ const instanceImageId = isRecord(displaySet.instance)
126403
+ ? displaySet.instance.imageId
126404
+ : undefined;
126405
+ const sourceDataId = (typeof instanceImageId === 'string' && instanceImageId) ||
126406
+ underlyingImageIds[0] ||
126407
+ imageIds[0];
126408
+ return sourceDataId
126409
+ ? { imageIds, sourceDataId, webClient: displaySet.webClient }
126410
+ : undefined;
125935
126411
  }
125936
126412
  function getGenericViewportImageDisplaySet(displaySetId) {
125937
126413
  const registered = getGenericViewportRegisteredDisplaySet(displaySetId);
@@ -125978,6 +126454,20 @@ function getGenericViewportWSIDisplaySet(displaySetId) {
125978
126454
  },
125979
126455
  };
125980
126456
  }
126457
+ if (isRecord(registered) &&
126458
+ typeof registered.sourceDataId === 'string' &&
126459
+ isStringArray(registered.imageIds) &&
126460
+ registered.imageIds.length) {
126461
+ const webClient = registered.webClient ??
126462
+ _cornerstonejs_metadata__rspack_import_0/* .metaData.get */.wx.Jt(_cornerstonejs_metadata__rspack_import_0/* .Enums.MetadataModules.WADO_WEB_CLIENT */.fX.nb.WADO_WEB_CLIENT, registered.imageIds[0]);
126463
+ if (isWSIClientLike(webClient)) {
126464
+ return {
126465
+ kind: 'wsi',
126466
+ imageIds: registered.imageIds,
126467
+ options: { webClient },
126468
+ };
126469
+ }
126470
+ }
125981
126471
  }
125982
126472
  function getGenericViewportSourceDataId(displaySetId) {
125983
126473
  const registered = getGenericViewportRegisteredDisplaySet(displaySetId);
@@ -125987,7 +126477,7 @@ function getGenericViewportSourceDataId(displaySetId) {
125987
126477
  if (isStringArray(registered) && registered[0]) {
125988
126478
  return registered[0];
125989
126479
  }
125990
- if (isGenericViewportSourceAliasDisplaySet(registered)) {
126480
+ if (isRecord(registered) && typeof registered.sourceDataId === 'string') {
125991
126481
  return registered.sourceDataId;
125992
126482
  }
125993
126483
  return displaySetId;
@@ -130856,53 +131346,89 @@ class WSIViewportLegacyAdapter extends WSI_WSIViewport/* ["default"] */.A {
130856
131346
  ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/GenericViewport/ECG/ECGViewportLegacyAdapter.js
130857
131347
 
130858
131348
 
131349
+ const LEGACY_VIEW_STATE_PROPERTIES = [
131350
+ 'visibleChannels',
131351
+ 'sweepSpeed',
131352
+ 'sensitivityMmMv',
131353
+ 'traceLayout',
131354
+ ];
130859
131355
  class ECGViewportLegacyAdapter extends ECG_ECGViewport/* ["default"] */.A {
130860
131356
  async setEcg(imageId) {
130861
131357
  await this.setDisplaySets({ displaySetId: imageId });
130862
131358
  }
131359
+ getNumberOfSlices() {
131360
+ return 1;
131361
+ }
131362
+ getCanvas() {
131363
+ return this.canvas;
131364
+ }
130863
131365
  setChannelVisibility(index, visible) {
130864
131366
  const waveform = this.getWaveformData();
130865
- const dataId = this.getFirstBinding()?.data.id;
130866
- if (!waveform || !dataId) {
131367
+ if (!waveform) {
130867
131368
  return;
130868
131369
  }
130869
- const current = this.getDisplaySetPresentation(dataId) || {};
130870
- const nextVisibleChannels = new Set(current.visibleChannels || waveform.channels.map((_channel, i) => i));
131370
+ const nextVisibleChannels = new Set(this.getViewState().visibleChannels ||
131371
+ waveform.channels.map((_channel, i) => i));
130871
131372
  if (visible) {
130872
131373
  nextVisibleChannels.add(index);
130873
131374
  }
130874
131375
  else {
130875
131376
  nextVisibleChannels.delete(index);
130876
131377
  }
130877
- this.setDisplaySetPresentation(dataId, {
131378
+ this.setViewState({
130878
131379
  visibleChannels: Array.from(nextVisibleChannels).sort((a, b) => a - b),
130879
131380
  });
130880
131381
  }
130881
- setProperties(props) {
131382
+ setProperties(props = {}) {
130882
131383
  const dataId = this.getFirstBinding()?.data.id;
130883
131384
  if (!dataId) {
130884
131385
  return;
130885
131386
  }
130886
- this.setDisplaySetPresentation(dataId, {
130887
- visibleChannels: props.visibleChannels,
131387
+ const viewStatePatch = {};
131388
+ LEGACY_VIEW_STATE_PROPERTIES.forEach((key) => {
131389
+ if (props[key] !== undefined) {
131390
+ viewStatePatch[key] = props[key];
131391
+ }
130888
131392
  });
131393
+ if (props.traceLayout === undefined && props.layoutType !== undefined) {
131394
+ viewStatePatch.traceLayout = props.layoutType;
131395
+ }
131396
+ if (Object.keys(viewStatePatch).length) {
131397
+ this.setViewState(viewStatePatch);
131398
+ }
131399
+ if (props.showAmplitudeLabels !== undefined) {
131400
+ this.setDisplaySetPresentation(dataId, {
131401
+ showAmplitudeLabels: props.showAmplitudeLabels,
131402
+ });
131403
+ }
130889
131404
  }
130890
131405
  getProperties() {
130891
131406
  const dataId = this.getFirstBinding()?.data.id;
131407
+ const presentation = dataId
131408
+ ? this.getDisplaySetPresentation(dataId)
131409
+ : undefined;
131410
+ const viewState = this.getViewState();
130892
131411
  return {
130893
- visibleChannels: dataId
130894
- ? this.getDisplaySetPresentation(dataId)?.visibleChannels
130895
- : undefined,
131412
+ visibleChannels: viewState.visibleChannels,
131413
+ sweepSpeed: viewState.sweepSpeed,
131414
+ sensitivityMmMv: viewState.sensitivityMmMv,
131415
+ showAmplitudeLabels: presentation?.showAmplitudeLabels,
131416
+ traceLayout: viewState.traceLayout,
130896
131417
  };
130897
131418
  }
130898
131419
  resetProperties() {
130899
- const waveform = this.getWaveformData();
130900
131420
  const dataId = this.getFirstBinding()?.data.id;
130901
- if (!waveform || !dataId) {
131421
+ if (!dataId) {
130902
131422
  return;
130903
131423
  }
131424
+ this.setViewState({
131425
+ visibleChannels: undefined,
131426
+ sweepSpeed: undefined,
131427
+ sensitivityMmMv: undefined,
131428
+ traceLayout: undefined,
131429
+ });
130904
131430
  this.setDisplaySetPresentation(dataId, {
130905
- visibleChannels: waveform.channels.map((_channel, index) => index),
131431
+ showAmplitudeLabels: undefined,
130906
131432
  });
130907
131433
  }
130908
131434
  getViewPresentation(selector) {
@@ -130919,8 +131445,61 @@ class ECGViewportLegacyAdapter extends ECG_ECGViewport/* ["default"] */.A {
130919
131445
  this.setViewState(nextViewState);
130920
131446
  }
130921
131447
  }
130922
- resetCamera() {
130923
- return this.resetViewState();
131448
+ resetCamera(options) {
131449
+ return this.resetViewState(options);
131450
+ }
131451
+ getCamera() {
131452
+ return {
131453
+ ...this.getViewState(),
131454
+ ...this.getCameraForEvent(),
131455
+ };
131456
+ }
131457
+ setCamera(cameraPatch) {
131458
+ if (cameraPatch.timeRange || cameraPatch.valueRange) {
131459
+ const nextViewState = {};
131460
+ if (cameraPatch.timeRange) {
131461
+ nextViewState.timeRange = cameraPatch.timeRange;
131462
+ }
131463
+ if (cameraPatch.valueRange) {
131464
+ nextViewState.valueRange = cameraPatch.valueRange;
131465
+ }
131466
+ this.setViewState(nextViewState);
131467
+ }
131468
+ if (cameraPatch.parallelScale !== undefined &&
131469
+ cameraPatch.parallelScale > 0) {
131470
+ const currentCamera = this.getCamera();
131471
+ if (currentCamera.parallelScale) {
131472
+ const ratio = currentCamera.parallelScale / cameraPatch.parallelScale;
131473
+ const currentZoom = this.getZoom();
131474
+ this.setZoom(currentZoom * ratio);
131475
+ }
131476
+ }
131477
+ else if (cameraPatch.scale !== undefined && cameraPatch.scale > 0) {
131478
+ this.setZoom(cameraPatch.scale);
131479
+ }
131480
+ if (cameraPatch.focalPoint) {
131481
+ this.setFocalPoint(cameraPatch.focalPoint);
131482
+ }
131483
+ }
131484
+ setFocalPoint(focalPoint) {
131485
+ const resolvedView = this.getResolvedView();
131486
+ if (!resolvedView) {
131487
+ return;
131488
+ }
131489
+ const z = Math.round(focalPoint[2]);
131490
+ if (!resolvedView.findLayoutForZ(z)) {
131491
+ return;
131492
+ }
131493
+ const targetCanvas = resolvedView.worldToCanvas(focalPoint);
131494
+ const canvasCenter = [
131495
+ this.canvas.clientWidth / 2,
131496
+ this.canvas.clientHeight / 2,
131497
+ ];
131498
+ const currentPan = this.getPan();
131499
+ this.setPan([
131500
+ currentPan[0] + (canvasCenter[0] - targetCanvas[0]),
131501
+ currentPan[1] + (canvasCenter[1] - targetCanvas[1]),
131502
+ ]);
130924
131503
  }
130925
131504
  }
130926
131505
  /* export default */ var ECG_ECGViewportLegacyAdapter = (ECGViewportLegacyAdapter);
@@ -134171,7 +134750,7 @@ var BlendModes;
134171
134750
  },
134172
134751
  85387(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
134173
134752
  "use strict";
134174
- /* import */ var _cornerstonejs_metadata__rspack_import_0 = __webpack_require__(76368);
134753
+ /* import */ var _cornerstonejs_metadata__rspack_import_0 = __webpack_require__(86049);
134175
134754
 
134176
134755
  const CalibrationTypes = _cornerstonejs_metadata__rspack_import_0/* .Enums.CalibrationTypes */.fX.ov;
134177
134756
  /* export default */ __webpack_exports__.A = (_cornerstonejs_metadata__rspack_import_0/* .Enums.CalibrationTypes */.fX.ov);
@@ -134328,7 +134907,7 @@ var MeshType;
134328
134907
  },
134329
134908
  10234(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
134330
134909
  "use strict";
134331
- /* import */ var _cornerstonejs_metadata__rspack_import_0 = __webpack_require__(76368);
134910
+ /* import */ var _cornerstonejs_metadata__rspack_import_0 = __webpack_require__(86049);
134332
134911
 
134333
134912
  /* export default */ __webpack_exports__.A = (_cornerstonejs_metadata__rspack_import_0/* .Enums.MetadataModules */.fX.nb);
134334
134913
 
@@ -134676,6 +135255,12 @@ const renderingEngineExportsV2 = {
134676
135255
  createECGRenderPathResolver: _RenderingEngine_GenericViewport_ECG_index_js__rspack_import_14/* .createECGRenderPathResolver */.Xy,
134677
135256
  DefaultECGDataProvider: _RenderingEngine_GenericViewport_ECG_index_js__rspack_import_14/* .DefaultECGDataProvider */.cs,
134678
135257
  ecgProjection: _RenderingEngine_GenericViewport_ECG_index_js__rspack_import_14/* .ecgProjection */.L0,
135258
+ registerECGTraceLayout: _RenderingEngine_GenericViewport_ECG_index_js__rspack_import_14/* .registerECGTraceLayout */.Gc,
135259
+ getECGTraceLayout: _RenderingEngine_GenericViewport_ECG_index_js__rspack_import_14/* .getECGTraceLayout */.$s,
135260
+ getECGTraceLayoutNames: _RenderingEngine_GenericViewport_ECG_index_js__rspack_import_14/* .getECGTraceLayoutNames */.JS,
135261
+ resolveDefaultECGTraceLayout: _RenderingEngine_GenericViewport_ECG_index_js__rspack_import_14/* .resolveDefaultECGTraceLayout */.Qf,
135262
+ ECG_CLINICAL_SWEEP_SPEEDS: _RenderingEngine_GenericViewport_ECG_index_js__rspack_import_14/* .ECG_CLINICAL_SWEEP_SPEEDS */.Ii,
135263
+ ECG_CLINICAL_SENSITIVITIES: _RenderingEngine_GenericViewport_ECG_index_js__rspack_import_14/* .ECG_CLINICAL_SENSITIVITIES */.M2,
134679
135264
  VideoGenericViewport: _RenderingEngine_GenericViewport_Video_index_js__rspack_import_15/* ["default"] */.Ay,
134680
135265
  createDefaultVideoRenderPaths: _RenderingEngine_GenericViewport_Video_index_js__rspack_import_15/* .createDefaultVideoRenderPaths */.jY,
134681
135266
  createVideoRenderPathResolver: _RenderingEngine_GenericViewport_Video_index_js__rspack_import_15/* .createVideoRenderPathResolver */.hW,
@@ -134714,6 +135299,8 @@ __webpack_require__.d(__webpack_exports__, {
134714
135299
  DefaultWSIDataProvider: () => (/* reexport safe */ _RenderingEngine_GenericViewport_WSI_index_js__rspack_import_18.qn),
134715
135300
  ECGGenericViewport: () => (/* reexport safe */ _RenderingEngine_GenericViewport_ECG_index_js__rspack_import_14.Ay),
134716
135301
  ECGViewport: () => (/* reexport safe */ _RenderingEngine_ECGViewport_js__rspack_import_12.A),
135302
+ ECG_CLINICAL_SENSITIVITIES: () => (/* reexport safe */ _RenderingEngine_GenericViewport_ECG_index_js__rspack_import_14.M2),
135303
+ ECG_CLINICAL_SWEEP_SPEEDS: () => (/* reexport safe */ _RenderingEngine_GenericViewport_ECG_index_js__rspack_import_14.Ii),
134717
135304
  EPSILON: () => (/* reexport safe */ (/* inlined export _RenderingEngine_helpers_getOrCreateCanvas_js__rspack_import_5 */0.0001)),
134718
135305
  EVENTS: () => (/* reexport safe */ _enums_index_js__rspack_import_0.Events),
134719
135306
  Enums: () => (/* reexport module object */ _enums_index_js__rspack_import_0),
@@ -134768,6 +135355,8 @@ __webpack_require__.d(__webpack_exports__, {
134768
135355
  eventTarget: () => (/* reexport safe */ _eventTarget_js__rspack_import_20.A),
134769
135356
  geometryLoader: () => (/* reexport module object */ _loaders_geometryLoader_js__rspack_import_34),
134770
135357
  getConfiguration: () => (/* reexport safe */ _init_js__rspack_import_29.D0),
135358
+ getECGTraceLayout: () => (/* reexport safe */ _RenderingEngine_GenericViewport_ECG_index_js__rspack_import_14.$s),
135359
+ getECGTraceLayoutNames: () => (/* reexport safe */ _RenderingEngine_GenericViewport_ECG_index_js__rspack_import_14.JS),
134771
135360
  getEffectiveRenderBackend: () => (/* reexport safe */ _init_js__rspack_import_29.cz),
134772
135361
  getEnabledElement: () => (/* reexport safe */ _getEnabledElement_js__rspack_import_27.Ay),
134773
135362
  getEnabledElementByIds: () => (/* reexport safe */ _getEnabledElement_js__rspack_import_27.b1),
@@ -134792,12 +135381,14 @@ __webpack_require__.d(__webpack_exports__, {
134792
135381
  metaData: () => (/* reexport module object */ _metaData_js__rspack_import_28),
134793
135382
  peerImport: () => (/* reexport safe */ _init_js__rspack_import_29.a),
134794
135383
  planarProjection: () => (/* reexport safe */ _RenderingEngine_GenericViewport_Planar_index_js__rspack_import_16.Sy),
135384
+ registerECGTraceLayout: () => (/* reexport safe */ _RenderingEngine_GenericViewport_ECG_index_js__rspack_import_14.Gc),
134795
135385
  registerImageLoader: () => (/* reexport safe */ _loaders_imageLoader_js__rspack_import_33.registerImageLoader),
134796
135386
  registerRenderBackend: () => (/* reexport safe */ _RenderingEngine_helpers_renderBackendRegistry_js__rspack_import_46.Up),
134797
135387
  registerViewportType: () => (/* reexport safe */ _RenderingEngine_helpers_viewportTypeToViewportClass_js__rspack_import_45.IE),
134798
135388
  requestPoolManager: () => (/* reexport safe */ _requestPool_imageLoadPoolManager_js__rspack_import_26.A),
134799
135389
  resetInitialization: () => (/* reexport safe */ _init_js__rspack_import_29.IB),
134800
135390
  resetUseCPURendering: () => (/* reexport safe */ _init_js__rspack_import_29.Xn),
135391
+ resolveDefaultECGTraceLayout: () => (/* reexport safe */ _RenderingEngine_GenericViewport_ECG_index_js__rspack_import_14.Qf),
134801
135392
  setCanvasCreator: () => (/* reexport safe */ _RenderingEngine_helpers_getOrCreateCanvas_js__rspack_import_5.vV),
134802
135393
  setConfiguration: () => (/* reexport safe */ _init_js__rspack_import_29.xN),
134803
135394
  setPreferSizeOverAccuracy: () => (/* reexport safe */ _init_js__rspack_import_29.zw),
@@ -134807,7 +135398,7 @@ __webpack_require__.d(__webpack_exports__, {
134807
135398
  triggerEvent: () => (/* reexport safe */ _utilities_triggerEvent_js__rspack_import_39.A),
134808
135399
  updateCanvasSizeAndAspectRatio: () => (/* reexport safe */ _RenderingEngine_helpers_getOrCreateCanvas_js__rspack_import_5.zV),
134809
135400
  utilities: () => (/* reexport module object */ _utilities_index_js__rspack_import_38),
134810
- version: () => (/* reexport safe */ (/* inlined export _version_js__rspack_import_21 */"5.12.0")),
135401
+ version: () => (/* reexport safe */ (/* inlined export _version_js__rspack_import_21 */"5.16.0")),
134811
135402
  videoProjection: () => (/* reexport safe */ _RenderingEngine_GenericViewport_Video_index_js__rspack_import_15.vL),
134812
135403
  viewportHasCanvasWorldTransform: () => (/* reexport safe */ _RenderingEngine_GenericViewport_index_js__rspack_import_13.z5),
134813
135404
  viewportHasFrameOfReferenceUID: () => (/* reexport safe */ _RenderingEngine_GenericViewport_index_js__rspack_import_13.IU),
@@ -137178,7 +137769,7 @@ __webpack_require__.d(__webpack_exports__, {
137178
137769
  52284(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
137179
137770
  "use strict";
137180
137771
  __webpack_require__.r(__webpack_exports__);
137181
- /* import */ var _cornerstonejs_metadata__rspack_import_0 = __webpack_require__(76368);
137772
+ /* import */ var _cornerstonejs_metadata__rspack_import_0 = __webpack_require__(86049);
137182
137773
 
137183
137774
  const { /* addProvider */Zi: addProvider, /* removeProvider */iw: removeProvider, /* removeAllProviders */SD: removeAllProviders, /* getMetaData */YA: getMetaData, /* getTyped */FE: getTyped, /* get */Jt: get, /* getNormalized */Y2: getNormalized, /* toUpperCamelTag */Qy: toUpperCamelTag, /* toLowerCamelTag */Hw: toLowerCamelTag, } = _cornerstonejs_metadata__rspack_import_0/* .metaData */.wx;
137184
137775
 
@@ -137912,6 +138503,7 @@ __webpack_require__.r(__webpack_exports__);
137912
138503
 
137913
138504
 
137914
138505
 
138506
+ const ECGUtilities = _ECGUtilities_js__rspack_import_78;
137915
138507
 
137916
138508
 
137917
138509
 
@@ -137958,7 +138550,6 @@ const getScalingDescriptor = (viewport, targetId) => (0,_getScalingDescriptor_js
137958
138550
 
137959
138551
 
137960
138552
  __webpack_require__.d(__webpack_exports__, {
137961
- ECGUtilities: () => (/* reexport module object */ _ECGUtilities_js__rspack_import_78),
137962
138553
  FrameRange: () => (/* reexport safe */ _FrameRange_js__rspack_import_87.A),
137963
138554
  HistoryMemo: () => (/* reexport module object */ _historyMemo_index_js__rspack_import_30),
137964
138555
  PointsManager: () => (/* reexport safe */ _PointsManager_js__rspack_import_49.A),
@@ -137970,6 +138561,7 @@ __webpack_require__.d(__webpack_exports__, {
137970
138561
  actorIsA: () => (/* reexport safe */ _actorCheck_js__rspack_import_40.N),
137971
138562
  applyPreset: () => (/* reexport safe */ _applyPreset_js__rspack_import_48.A),
137972
138563
  asArray: () => (/* reexport safe */ _asArray_js__rspack_import_115._),
138564
+ asArrayFirst: () => (/* reexport safe */ _asArray_js__rspack_import_115.m),
137973
138565
  autoLoad: () => (/* reexport safe */ _autoLoad_js__rspack_import_96.A),
137974
138566
  buildMetadata: () => (/* reexport safe */ _buildMetadata_js__rspack_import_90.KP),
137975
138567
  calculateNeighborhoodStats: () => (/* reexport safe */ _calculateNeighborhoodStats_js__rspack_import_109.c),
@@ -138104,6 +138696,7 @@ __webpack_require__.d(__webpack_exports__, {
138104
138696
  windowLevel: () => (/* reexport module object */ _windowLevel_js__rspack_import_82),
138105
138697
  worldToImageCoords: () => (/* reexport safe */ _worldToImageCoords_js__rspack_import_33.A)
138106
138698
  }, {
138699
+ ECGUtilities: ECGUtilities,
138107
138700
  getScalingDescriptor: getScalingDescriptor,
138108
138701
  getViewportModality: getViewportModality
138109
138702
  });
@@ -138494,7 +139087,7 @@ function resetRenderingCapabilities({ clearStorage = false, } = {}) {
138494
139087
  },
138495
139088
  6945() {
138496
139089
  "use strict";
138497
- const version = '5.12.0';
139090
+ const version = '5.16.0';
138498
139091
 
138499
139092
 
138500
139093
  },
@@ -139494,7 +140087,7 @@ function xhrRequest(url, imageId, defaultHeaders = {}, params = {}) {
139494
140087
  /* export default */ var internal_xhrRequest = (xhrRequest);
139495
140088
 
139496
140089
  // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/metadata/dist/esm/index.js + 29 modules
139497
- var dist_esm = __webpack_require__(76368);
140090
+ var dist_esm = __webpack_require__(86049);
139498
140091
  ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/dicom-image-loader/dist/esm/imageLoader/wadors/findIndexOfString.js
139499
140092
  function checkToken(token, data, dataOffset) {
139500
140093
  if (dataOffset + token.length > data.length) {
@@ -143542,19 +144135,20 @@ __webpack_require__.d(__webpack_exports__, {
143542
144135
 
143543
144136
 
143544
144137
  },
143545
- 76368(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
144138
+ 86049(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
143546
144139
  "use strict";
143547
144140
 
143548
144141
  // EXPORTS
143549
144142
  __webpack_require__.d(__webpack_exports__, {
143550
144143
  fX: () => (/* reexport */ enums),
144144
+ Tn: () => (/* reexport */ safeFunctions/* .hasNoValue */.Tn),
143551
144145
  m9: () => (/* reexport */ logging_namespaceObject),
143552
144146
  wx: () => (/* reexport */ metaData),
143553
144147
  F4: () => (/* reexport */ registerDefaultProviders),
143554
144148
  BF: () => (/* reexport */ utilities_namespaceObject)
143555
144149
  });
143556
144150
 
143557
- // UNUSED EXPORTS: BaseDisplaySet, ImageStackDisplaySet, buildSeriesInfo, calculateSUVScalingFactors, createDisplaySetFromGroup, defaultDisplaySetSplitRules, displaySet, getPreferredViewportType, getViewportTypesForGroup, getViewportTypesForRule, groupInstancesBySplitRules, isEcgInstance, isImageInstance, isVideoInstance, isWsiInstance, registerDisplaySetMetadata, registerDisplaySetProviders, resolveInstances, splitImageIdsBySplitRules, version
144151
+ // UNUSED EXPORTS: BaseDisplaySet, DEFAULT_SPLIT_RULE_PRIORITY_LIMIT, DISPLAY_SET_HANDLER_NAMES, ExpressionSyntaxError, ImageStackDisplaySet, MATCH_OPERATOR_NAMES, RuleCompileError, buildSeriesInfo, bulkAnnotationSopClassUids, calculateSUVScalingFactors, chartSopClassUids, collectIdentifiers, collectReads, compare, compareInstanceNumber, compareSOPInstanceUID, compileCondition, compileExpression, compileTemplate, compileValue, compiledDisplaySetRules, createDisplaySetFromGroup, createDisplaySetSplitRules, defaultDisplaySetSplitRules, defaultMetadataContext, displaySet, displaySetRules, ecgSopClassUids, encapsulatedDocumentSopClassUids, getContextValue, getMetadataContext, groupInstancesBySplitRules, imageSopClassUids, instancesSortCriteria, isAbsent, isEcgInstance, isEmpty, isImageInstance, isReconstructableInstances, isVideoInstance, isWsiInstance, longVideoMinFrames, longVideoSopClassUids, looseEquals, orderInstancesForRule, parametricMapSopClassUids, parseExpressionSource, registerDisplaySetMetadata, registerDisplaySetProviders, resolveInstances, resolveSplitRuleSet, rtStructureSetSopClassUids, segmentationSopClassUids, setMetadataContext, sortByInstanceNumber, sortInstancesCopy, splitImageIdsBySplitRules, structuredReportSopClassUids, version, videoSopClassUids, videoTransferSyntaxUids, wholeSlideSopClassUids
143558
144152
  // NAMESPACE OBJECT: ../../node_modules/@cornerstonejs/metadata/dist/esm/utilities/logging.js
143559
144153
  var logging_namespaceObject = {};
143560
144154
  __webpack_require__.r(logging_namespaceObject);
@@ -143566,7 +144160,10 @@ __webpack_require__.d(logging_namespaceObject, {
143566
144160
  var utilities_namespaceObject = {};
143567
144161
  __webpack_require__.r(utilities_namespaceObject);
143568
144162
  __webpack_require__.d(utilities_namespaceObject, {
144163
+ Fi: () => ((/* inlined export .ECG_AMPLITUDE_INDEX_SIZE */65536)),
144164
+ Fc: () => ((/* inlined export .ECG_DEFAULT_MV_PER_UNIT */0.001)),
143569
144165
  B$: () => (addDicomPart10Instance),
144166
+ Ts: () => (buildEcgCalibrationFromInstance),
143570
144167
  l3: () => (buildEcgModuleFromInstance),
143571
144168
  VD: () => (calculateRadiographicPixelSpacing),
143572
144169
  ZX: () => (calibratedPixelSpacingMetadataProvider/* ["default"] */.A),
@@ -143578,8 +144175,10 @@ __webpack_require__.d(utilities_namespaceObject, {
143578
144175
  nw: () => (getUriModule),
143579
144176
  FM: () => (handleMultiframe4D),
143580
144177
  YF: () => (imageIdToURI/* ["default"] */.A),
144178
+ n4: () => (isEqual/* .isEqual */.n4),
143581
144179
  AR: () => (isVideoTransferSyntax/* ["default"] */.A),
143582
144180
  Qy: () => (utilities_splitImageIdsBy4DTags),
144181
+ w7: () => (esm/* .toFiniteVector */.w7),
143583
144182
  Ro: () => (esm/* .toNumber */.Ro),
143584
144183
  Le: () => (isVideoTransferSyntax/* .videoUIDs */.L) });
143585
144184
 
@@ -143632,6 +144231,63 @@ function getSingleBufferFromArray(raw) {
143632
144231
  return out;
143633
144232
  }
143634
144233
 
144234
+ ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/metadata/dist/esm/utilities/decodeMultipartRelated.js
144235
+ const CRLF = [13, 10];
144236
+ const HEADER_END = [13, 10, 13, 10];
144237
+ const DASH_DASH = [45, 45];
144238
+ function decodeMultipartRelated(response, contentType) {
144239
+ const message = new Uint8Array(response);
144240
+ const boundary = getBoundaryFromContentType(contentType) ?? getBoundaryFromBody(message);
144241
+ if (!boundary) {
144242
+ return [response];
144243
+ }
144244
+ const delimiter = Array.from(new TextEncoder().encode(`--${boundary}`));
144245
+ const parts = [];
144246
+ let index = indexOf(message, delimiter, 0);
144247
+ while (index !== -1) {
144248
+ const afterDelimiter = index + delimiter.length;
144249
+ if (startsWith(message, DASH_DASH, afterDelimiter)) {
144250
+ break;
144251
+ }
144252
+ const headerEnd = indexOf(message, HEADER_END, afterDelimiter);
144253
+ if (headerEnd === -1) {
144254
+ break;
144255
+ }
144256
+ const dataStart = headerEnd + HEADER_END.length;
144257
+ const next = indexOf(message, [...CRLF, ...delimiter], dataStart);
144258
+ const dataEnd = next === -1 ? message.length : next;
144259
+ parts.push(response.slice(dataStart, dataEnd));
144260
+ index = next === -1 ? -1 : next + CRLF.length;
144261
+ }
144262
+ return parts.length ? parts : [response];
144263
+ }
144264
+ function getBoundaryFromContentType(contentType) {
144265
+ const match = contentType?.match(/boundary=(?:"([^"]+)"|([^\s;]+))/i);
144266
+ return match ? (match[1] ?? match[2]) : undefined;
144267
+ }
144268
+ function getBoundaryFromBody(message) {
144269
+ if (!startsWith(message, DASH_DASH, 0)) {
144270
+ return undefined;
144271
+ }
144272
+ const lineEnd = indexOf(message, CRLF, 0, 200);
144273
+ if (lineEnd <= DASH_DASH.length) {
144274
+ return undefined;
144275
+ }
144276
+ return new TextDecoder().decode(message.subarray(DASH_DASH.length, lineEnd));
144277
+ }
144278
+ function startsWith(message, token, at) {
144279
+ return token.every((byte, i) => message[at + i] === byte);
144280
+ }
144281
+ function indexOf(message, token, from, maxLength = message.length) {
144282
+ const end = Math.min(message.length, from + maxLength) - token.length;
144283
+ for (let i = from; i <= end; i++) {
144284
+ if (message[i] === token[0] && startsWith(message, token, i)) {
144285
+ return i;
144286
+ }
144287
+ }
144288
+ return -1;
144289
+ }
144290
+
143635
144291
  ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/metadata/dist/esm/utilities/definedAttributesOf.js
143636
144292
  function definedAttributesOf(source) {
143637
144293
  const result = {};
@@ -144049,159 +144705,41 @@ function splitImageIdsBy4DTags(imageIds) {
144049
144705
  'TemporalPositionIdentifier',
144050
144706
  'DiffusionBValue',
144051
144707
  'TriggerTime',
144052
- 'EchoTime',
144053
- 'EchoNumber',
144054
- 'PhilipsPrivateBValue',
144055
- 'SiemensPrivateBValue',
144056
- 'GEPrivateBValue',
144057
- 'PetFrameReferenceTime',
144058
- ];
144059
- const fncList2 = [
144060
- (imageId) => getTagValue(imageId, tags[0]),
144061
- (imageId) => getTagValue(imageId, tags[1]),
144062
- (imageId) => getTagValue(imageId, tags[2]),
144063
- (imageId) => getTagValue(imageId, tags[3]),
144064
- (imageId) => getTagValue(imageId, tags[4]),
144065
- getPhilipsPrivateBValue,
144066
- getSiemensPrivateBValue,
144067
- getGEPrivateBValue,
144068
- getPetFrameReferenceTime,
144069
- ];
144070
- for (let i = 0; i < fncList2.length; i++) {
144071
- const frame_groups = test4DTag(positionGroups, fncList2[i]);
144072
- if (frame_groups) {
144073
- const sortedKeys = Object.keys(frame_groups)
144074
- .map(Number.parseFloat)
144075
- .sort((a, b) => a - b);
144076
- const imageIdGroups = sortedKeys.map((key) => frame_groups[key].map((item) => item.imageId));
144077
- return { imageIdGroups, splittingTag: tags[i] };
144078
- }
144079
- }
144080
- return { imageIdGroups: [imageIds], splittingTag: null };
144081
- }
144082
- /* export default */ var utilities_splitImageIdsBy4DTags = (splitImageIdsBy4DTags);
144083
-
144084
-
144085
- // EXTERNAL MODULE: ../../node_modules/dcmjs/build/dcmjs.es.js
144086
- var dcmjs_es = __webpack_require__(85631);
144087
- // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/metadata/dist/esm/utilities/modules/index.js + 21 modules
144088
- var modules = __webpack_require__(42701);
144089
- ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/metadata/dist/esm/utilities/Tags.js
144090
-
144091
-
144092
-
144093
-
144094
- const Tags_cs3dLogger = esm/* .logging.metadataLog.getLogger */.m9.Um.getLogger('utilities.Tags');
144095
- const dicomDictionary = dcmjs_es/* ["default"].data.DicomMetaDictionary.dictionary */.Ay.data.DicomMetaDictionary.dictionary;
144096
- const nameMap = dcmjs_es/* ["default"].data.DicomMetaDictionary.nameMap */.Ay.data.DicomMetaDictionary.nameMap;
144097
-
144098
- function createTagEntry(hexTag, ...groups) {
144099
- return {
144100
- tag: hexTag,
144101
- groups,
144102
- xTag: null,
144103
- primaryGroup: null,
144104
- name: null,
144105
- lowerName: null,
144106
- vr: null,
144107
- vm: null,
144108
- };
144109
- }
144110
- function parseVm(vm) {
144111
- if (vm === undefined || vm === null) {
144112
- return null;
144113
- }
144114
- if (typeof vm === 'number') {
144115
- return vm;
144116
- }
144117
- const n = parseInt(vm, 10);
144118
- if (String(n) === vm) {
144119
- return n;
144120
- }
144121
- return 0;
144122
- }
144123
- function dictionaryLookup(hexTag) {
144124
- return dicomDictionary[hexTag.toUpperCase()];
144125
- }
144126
- function getTagCodeByName(name) {
144127
- return mapTagInfo.get(name)?.tag;
144128
- }
144129
- const mapModuleTags = new Map();
144130
- const mapTagInfo = new Map();
144131
- function addTag(name, value) {
144132
- if (name && value.name && name !== value.name) {
144133
- throw new Error(`Tag name provided and value don't match: ${name} !== ${value.name}`);
144134
- }
144135
- value.name ||= name;
144136
- value.lowerName ||= metaData/* .toLowerCamelTag */.Hw(name);
144137
- Tags[name] = value;
144138
- const { tag: hexTag } = value;
144139
- value.primaryGroup ||= value.groups?.[0];
144140
- const { groups } = value;
144141
- mapTagInfo.set(name, value);
144142
- if (hexTag) {
144143
- value.xTag = `x${hexTag.toLowerCase()}`;
144144
- value.tag = hexTag.toUpperCase();
144145
- mapTagInfo.set(value.xTag, value);
144146
- mapTagInfo.set(value.tag, value);
144147
- if (!value.vr) {
144148
- const dictEntry = dicomDictionary[value.tag];
144149
- if (dictEntry) {
144150
- value.vr = dictEntry.vr;
144151
- value.vm = parseVm(dictEntry.vm);
144152
- }
144153
- }
144154
- }
144155
- if (groups?.length) {
144156
- for (const group of groups) {
144157
- let moduleEntries = mapModuleTags.get(group);
144158
- if (!moduleEntries) {
144159
- moduleEntries = [value];
144160
- mapModuleTags.set(group, moduleEntries);
144161
- return;
144162
- }
144163
- const foundIndex = moduleEntries.findIndex((it) => it.name === name);
144164
- if (foundIndex === -1) {
144165
- moduleEntries.push(value);
144166
- }
144167
- else {
144168
- moduleEntries[foundIndex] = value;
144169
- }
144170
- }
144171
- }
144172
- }
144173
- function resolveHexFromKeyword(keyword) {
144174
- const entry = nameMap[keyword];
144175
- if (!entry) {
144176
- return undefined;
144177
- }
144178
- return entry.tag.substring(1, 5) + entry.tag.substring(6, 10);
144179
- }
144180
- const Tags = {};
144181
- const tagGroups = new Map();
144182
- for (const [moduleName, keywords] of modules/* .moduleDefinitions */.zh) {
144183
- for (const entry of keywords) {
144184
- const keyword = typeof entry === 'string' ? entry : entry[0];
144185
- const hexOverride = typeof entry === 'string' ? undefined : entry[1];
144186
- let data = tagGroups.get(keyword);
144187
- if (!data) {
144188
- const hex = hexOverride ?? resolveHexFromKeyword(keyword);
144189
- data = { hex, groups: [] };
144190
- tagGroups.set(keyword, data);
144191
- }
144192
- if (moduleName !== null) {
144193
- data.groups.push(moduleName);
144708
+ 'EchoTime',
144709
+ 'EchoNumber',
144710
+ 'PhilipsPrivateBValue',
144711
+ 'SiemensPrivateBValue',
144712
+ 'GEPrivateBValue',
144713
+ 'PetFrameReferenceTime',
144714
+ ];
144715
+ const fncList2 = [
144716
+ (imageId) => getTagValue(imageId, tags[0]),
144717
+ (imageId) => getTagValue(imageId, tags[1]),
144718
+ (imageId) => getTagValue(imageId, tags[2]),
144719
+ (imageId) => getTagValue(imageId, tags[3]),
144720
+ (imageId) => getTagValue(imageId, tags[4]),
144721
+ getPhilipsPrivateBValue,
144722
+ getSiemensPrivateBValue,
144723
+ getGEPrivateBValue,
144724
+ getPetFrameReferenceTime,
144725
+ ];
144726
+ for (let i = 0; i < fncList2.length; i++) {
144727
+ const frame_groups = test4DTag(positionGroups, fncList2[i]);
144728
+ if (frame_groups) {
144729
+ const sortedKeys = Object.keys(frame_groups)
144730
+ .map(Number.parseFloat)
144731
+ .sort((a, b) => a - b);
144732
+ const imageIdGroups = sortedKeys.map((key) => frame_groups[key].map((item) => item.imageId));
144733
+ return { imageIdGroups, splittingTag: tags[i] };
144194
144734
  }
144195
144735
  }
144736
+ return { imageIdGroups: [imageIds], splittingTag: null };
144196
144737
  }
144197
- for (const [keyword, { hex, groups }] of tagGroups) {
144198
- if (!hex) {
144199
- Tags_cs3dLogger.warn(`Tags: keyword "${keyword}" not found in dcmjs nameMap`);
144200
- continue;
144201
- }
144202
- addTag(keyword, createTagEntry(hex, ...groups));
144203
- }
144738
+ /* export default */ var utilities_splitImageIdsBy4DTags = (splitImageIdsBy4DTags);
144204
144739
 
144740
+
144741
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/metadata/dist/esm/utilities/Tags.js
144742
+ var Tags = __webpack_require__(40327);
144205
144743
  ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/metadata/dist/esm/utilities/dicomStream/MetaDataIterator.js
144206
144744
 
144207
144745
  class MetaDataIterator {
@@ -144219,8 +144757,8 @@ class MetaDataIterator {
144219
144757
  continue;
144220
144758
  }
144221
144759
  const vr = value.vr;
144222
- const tagData = mapTagInfo.get(key);
144223
- const dictEntry = !tagData ? dictionaryLookup(key) : undefined;
144760
+ const tagData = Tags/* .mapTagInfo.get */.fw.get(key);
144761
+ const dictEntry = !tagData ? (0,Tags/* .dictionaryLookup */.d1)(key) : undefined;
144224
144762
  const hasBulk = !value.Value &&
144225
144763
  (value.BulkDataURI ??
144226
144764
  value.InlineBinary);
@@ -144262,6 +144800,8 @@ class MetaDataIterator {
144262
144800
  }
144263
144801
  }
144264
144802
 
144803
+ // EXTERNAL MODULE: ../../node_modules/dcmjs/build/dcmjs.es.js
144804
+ var dcmjs_es = __webpack_require__(85631);
144265
144805
  ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/metadata/dist/esm/utilities/metadataProvider/makeArrayLike.js
144266
144806
  function makeArrayLike(obj) {
144267
144807
  if (obj === null || obj === undefined) {
@@ -144300,7 +144840,7 @@ function resolveSingleVm(tagData, dictEntry, tagInfo) {
144300
144840
  }
144301
144841
  const vm = tagInfo?.vm ?? dictEntry?.vm;
144302
144842
  if (vm !== undefined && vm !== null) {
144303
- const parsed = parseVm(vm);
144843
+ const parsed = (0,Tags/* .parseVm */.bF)(vm);
144304
144844
  if (parsed !== null) {
144305
144845
  return parsed === 1;
144306
144846
  }
@@ -144329,8 +144869,8 @@ class NaturalTagListener {
144329
144869
  return new DicomMetadataListener({}, new NaturalTagListener(options));
144330
144870
  }
144331
144871
  addTag(next, tag, tagInfo) {
144332
- const tagData = mapTagInfo.get(tag);
144333
- const dictEntry = !tagData ? dictionaryLookup(tag) : undefined;
144872
+ const tagData = Tags/* .mapTagInfo.get */.fw.get(tag);
144873
+ const dictEntry = !tagData ? (0,Tags/* .dictionaryLookup */.d1)(tag) : undefined;
144334
144874
  const name = tagInfo?.name || tagData?.[DEFAULT_NAME_KEY] || dictEntry?.name || tag;
144335
144875
  const singleVm = resolveSingleVm(tagData, dictEntry, tagInfo);
144336
144876
  next(tag, tagInfo);
@@ -144609,7 +145149,7 @@ function clearTagModules() {
144609
145149
  mapModules.clear();
144610
145150
  }
144611
145151
  function tagModules(module, dataLookupName = 'instance') {
144612
- if (!mapModuleTags.has(module)) {
145152
+ if (!Tags/* .mapModuleTags.has */.Mj.has(module)) {
144613
145153
  throw new Error(`No module found: ${module}`);
144614
145154
  }
144615
145155
  if (mapModules.has(module)) {
@@ -144622,7 +145162,7 @@ function tagModules(module, dataLookupName = 'instance') {
144622
145162
  (0,metaData/* .addTypedProvider */.bf)(module, dataLookup(dataLookupName), { priority: 25_000 });
144623
145163
  }
144624
145164
  const moduleProvider = (next, query, data, options) => {
144625
- const keys = mapModuleTags.get(module);
145165
+ const keys = Tags/* .mapModuleTags.get */.Mj.get(module);
144626
145166
  const destName = options?.destName || 'lowerName';
144627
145167
  if (!data) {
144628
145168
  return next(query, data, options);
@@ -144652,7 +145192,7 @@ function tagModules(module, dataLookupName = 'instance') {
144652
145192
  }
144653
145193
  const MODULE_PRIORITY = { priority: -1_000 };
144654
145194
  function registerTagModules() {
144655
- for (const module of mapModuleTags.keys()) {
145195
+ for (const module of Tags/* .mapModuleTags.keys */.Mj.keys()) {
144656
145196
  const providerFn = tagModules(module);
144657
145197
  if (providerFn) {
144658
145198
  (0,metaData/* .addTypedProvider */.bf)(module, providerFn, MODULE_PRIORITY);
@@ -145066,7 +145606,36 @@ var ecgModule = __webpack_require__(46620);
145066
145606
 
145067
145607
 
145068
145608
 
145609
+
145610
+
145069
145611
  const ecgFromInstance_cs3dLogger = esm/* .logging.metadataLog.getLogger */.m9.Um.getLogger('utilities.metadataProvider.ecgFromInstance');
145612
+ const ECG_DEFAULT_MV_PER_UNIT = 0.001;
145613
+ const MV_PER_SENSITIVITY_UNIT = {
145614
+ v: 1000,
145615
+ mv: 1,
145616
+ uv: 0.001,
145617
+ µv: 0.001,
145618
+ nv: 0.000001,
145619
+ };
145620
+ function getChannelMvPerUnit(channel) {
145621
+ const sensitivity = (0,esm/* .toFiniteFirst */.FL)(channel.ChannelSensitivity);
145622
+ if (sensitivity === undefined || sensitivity === 0) {
145623
+ return ECG_DEFAULT_MV_PER_UNIT;
145624
+ }
145625
+ const correction = (0,esm/* .toFiniteFirst */.FL)(channel.ChannelSensitivityCorrectionFactor) || 1;
145626
+ const unitsSeq = toArray(channel.ChannelSensitivityUnitsSequence);
145627
+ const unitCode = (unitsSeq[0]?.CodeValue ??
145628
+ unitsSeq[0]?.CodeMeaning ??
145629
+ '')
145630
+ .trim()
145631
+ .toLowerCase();
145632
+ const mvPerSensitivityUnit = MV_PER_SENSITIVITY_UNIT[unitCode];
145633
+ if (mvPerSensitivityUnit === undefined) {
145634
+ ecgFromInstance_cs3dLogger.warn(`[ecgFromInstance] Unknown ChannelSensitivityUnits "${unitCode}". Using ${ECG_DEFAULT_MV_PER_UNIT} mV for each unit.`);
145635
+ return ECG_DEFAULT_MV_PER_UNIT;
145636
+ }
145637
+ return sensitivity * correction * mvPerSensitivityUnit;
145638
+ }
145070
145639
  function base64ToUint8Array(base64) {
145071
145640
  const binaryString = atob(base64);
145072
145641
  const bytes = new Uint8Array(binaryString.length);
@@ -145076,7 +145645,9 @@ function base64ToUint8Array(base64) {
145076
145645
  return bytes;
145077
145646
  }
145078
145647
  function convertBuffer(dataSrc, numberOfChannels, numberOfSamples, bits, type) {
145079
- const data = new Uint8Array(dataSrc);
145648
+ const data = ArrayBuffer.isView(dataSrc)
145649
+ ? new Uint8Array(dataSrc.buffer, dataSrc.byteOffset, dataSrc.byteLength)
145650
+ : new Uint8Array(dataSrc);
145080
145651
  if (bits === 16 && type === 'SS') {
145081
145652
  const ret = [];
145082
145653
  const bytesPerSample = 2;
@@ -145099,52 +145670,10 @@ function convertBuffer(dataSrc, numberOfChannels, numberOfSamples, bits, type) {
145099
145670
  }
145100
145671
  return [];
145101
145672
  }
145102
- function multipartDecode(response) {
145103
- const message = new Uint8Array(response);
145104
- const separator = new TextEncoder().encode('\r\n\r\n');
145105
- let offset = 0;
145106
- const maxHeader = 1000;
145107
- let headerEnd = -1;
145108
- for (let i = 0; i < Math.min(message.length - separator.length, offset + maxHeader); i++) {
145109
- let found = true;
145110
- for (let j = 0; j < separator.length; j++) {
145111
- if (message[i + j] !== separator[j]) {
145112
- found = false;
145113
- break;
145114
- }
145115
- }
145116
- if (found) {
145117
- headerEnd = i;
145118
- break;
145119
- }
145120
- }
145121
- if (headerEnd === -1)
145122
- return [response];
145123
- const headerStr = new TextDecoder().decode(message.slice(0, headerEnd));
145124
- const boundaryMatch = headerStr.match(/boundary=([^\s;]+)/i);
145125
- const boundary = boundaryMatch
145126
- ? new TextEncoder().encode(`--${boundaryMatch[1].replace(/"/g, '').trim()}`)
145127
- : null;
145128
- if (!boundary)
145129
- return [response];
145130
- const dataStart = headerEnd + separator.length;
145131
- const components = [];
145132
- let idx = message.indexOf(boundary[0], dataStart);
145133
- while (idx !== -1) {
145134
- const nextSep = message.indexOf(separator[0], idx);
145135
- if (nextSep === -1)
145136
- break;
145137
- const partStart = nextSep + separator.length;
145138
- const nextBound = message.indexOf(boundary[0], partStart);
145139
- const partEnd = nextBound === -1 ? message.length : nextBound - 2;
145140
- if (partEnd > partStart) {
145141
- components.push(response.slice(partStart, partEnd));
145142
- }
145143
- if (nextBound === -1)
145144
- break;
145145
- idx = message.indexOf(boundary[0], nextBound + boundary.length);
145146
- }
145147
- return components.length > 0 ? components : [response];
145673
+ function isDecodedChannels(value, numberOfChannels, numberOfSamples) {
145674
+ return (Array.isArray(value) &&
145675
+ value.length === numberOfChannels &&
145676
+ value.every((channel) => channel instanceof Int16Array && channel.length === numberOfSamples));
145148
145677
  }
145149
145678
  function parseWadoRsImageId(imageId) {
145150
145679
  const uri = imageId.replace(/^wadors:/i, '');
@@ -145167,12 +145696,162 @@ function toArray(seq) {
145167
145696
  }
145168
145697
  return [seq];
145169
145698
  }
145170
- function buildEcgModuleFromInstance(instance, imageId) {
145699
+ const ECG_CODE_MAP = new Map([
145700
+ ['8867-4', 'ventricularHeartRate'],
145701
+ ['2:1', 'ventricularHeartRate'],
145702
+ ['8625-6', 'prInterval'],
145703
+ ['8633-0', 'qrsDuration'],
145704
+ ['8634-8', 'qtInterval'],
145705
+ ['8636-3', 'qtcInterval'],
145706
+ ['8637-1', 'rrInterval'],
145707
+ ['8626-4', 'pAxis'],
145708
+ ['8632-2', 'qrsAxis'],
145709
+ ['8638-9', 'tAxis'],
145710
+ ]);
145711
+ const ECG_MEANING_PATTERNS = [
145712
+ [
145713
+ /^(?!.*\batrial\b).*\b((ventricular\s+)?heart|ventricular)\s+rate\b|^hr$/i,
145714
+ 'ventricularHeartRate',
145715
+ ],
145716
+ [/(^|\b)p[- ]?r\s*(interval|int)\b|^p[- ]?r$/i, 'prInterval'],
145717
+ [/(^|\b)qrs\s*(duration|width|interval)\b|^qrs$/i, 'qrsDuration'],
145718
+ [/(^|\b)qtc(\s*(interval|calc|int))?\b|^qtc$/i, 'qtcInterval'],
145719
+ [/(^|\b)qt\s*(interval|int)\b|^qt$/i, 'qtInterval'],
145720
+ [/(^|\b)r[- ]?r\s*(interval|int)\b|^r[- ]?r$/i, 'rrInterval'],
145721
+ [/(^|\b)p(\s+wave)?\s+axis\b|axis\s+p\b/i, 'pAxis'],
145722
+ [/(^|\b)qrs\s+axis\b|axis\s+qrs\b/i, 'qrsAxis'],
145723
+ [/(^|\b)t(\s+wave)?\s+axis\b|axis\s+t\b/i, 'tAxis'],
145724
+ ];
145725
+ function matchEcgMetric(codeValue, codeMeaning) {
145726
+ if (codeValue && ECG_CODE_MAP.has(codeValue)) {
145727
+ return ECG_CODE_MAP.get(codeValue);
145728
+ }
145729
+ return codeMeaning
145730
+ ? ECG_MEANING_PATTERNS.find(([pattern]) => pattern.test(codeMeaning))?.[1]
145731
+ : undefined;
145732
+ }
145733
+ function firstText(raw) {
145734
+ const text = (0,esm/* .asArrayFirst */.mm)(raw)
145735
+ ?.toString()
145736
+ .trim();
145737
+ return text || undefined;
145738
+ }
145739
+ function codeText(item) {
145740
+ return firstText(item?.CodeMeaning) || firstText(item?.CodeValue);
145741
+ }
145742
+ function parseEcgAnnotations(instance) {
145743
+ const seq = toArray(instance.WaveformAnnotationSequence);
145744
+ if (!seq.length) {
145745
+ return undefined;
145746
+ }
145747
+ const annotations = {
145748
+ units: {},
145749
+ interpretations: [],
145750
+ all: [],
145751
+ };
145752
+ for (const item of seq) {
145753
+ if (!item) {
145754
+ continue;
145755
+ }
145756
+ const concept = toArray(item.ConceptNameCodeSequence)[0];
145757
+ const codeMeaning = firstText(concept?.CodeMeaning) ?? '';
145758
+ const codeValue = firstText(concept?.CodeValue) ?? '';
145759
+ const numericVal = (0,esm/* .toFiniteFirst */.FL)(item.NumericValue);
145760
+ const unitItem = toArray(item.MeasurementUnitsCodeSequence)[0];
145761
+ const unit = codeText(unitItem);
145762
+ const codedValue = codeText(toArray(item.ConceptCodeSequence)[0]);
145763
+ const textVal = firstText(item.UnformattedTextValue ?? item.TextValue) ?? codedValue;
145764
+ const channelPairs = [item.ReferencedWaveformChannels ?? []].flat();
145765
+ const isGlobal = item.TemporalRangeType === undefined &&
145766
+ item.ReferencedSamplePositions === undefined &&
145767
+ item.ReferencedTimeOffsets === undefined &&
145768
+ item.ReferencedDateTime === undefined &&
145769
+ channelPairs.every((value, index) => index % 2 === 0 || value === 0);
145770
+ if (codeMeaning || codeValue || numericVal !== undefined || textVal) {
145771
+ annotations.all.push({
145772
+ concept: codeMeaning || codeValue
145773
+ ? {
145774
+ codeMeaning,
145775
+ codeValue,
145776
+ codingSchemeDesignator: firstText(concept?.CodingSchemeDesignator) ?? '',
145777
+ }
145778
+ : undefined,
145779
+ numericValue: numericVal,
145780
+ unit,
145781
+ textValue: textVal,
145782
+ });
145783
+ }
145784
+ if (!isGlobal) {
145785
+ continue;
145786
+ }
145787
+ const metric = numericVal !== undefined
145788
+ ? matchEcgMetric(codeValue, codeMeaning)
145789
+ : undefined;
145790
+ if (metric) {
145791
+ if (annotations[metric] === undefined) {
145792
+ annotations[metric] = numericVal;
145793
+ annotations.units[metric] = firstText(unitItem?.CodeValue) || unit;
145794
+ }
145795
+ continue;
145796
+ }
145797
+ const finding = textVal || (numericVal === undefined ? codeMeaning : undefined);
145798
+ if (finding && !annotations.interpretations.includes(finding)) {
145799
+ annotations.interpretations.push(finding);
145800
+ }
145801
+ }
145802
+ if (annotations.ventricularHeartRate === undefined &&
145803
+ annotations.rrInterval !== undefined &&
145804
+ annotations.rrInterval > 0) {
145805
+ const rrUnit = annotations.units.rrInterval;
145806
+ const inSeconds = rrUnit === 's' || (rrUnit !== 'ms' && annotations.rrInterval < 5);
145807
+ const rrMs = annotations.rrInterval * (inSeconds ? 1000 : 1);
145808
+ annotations.ventricularHeartRate = Math.round(60000 / rrMs);
145809
+ annotations.units.ventricularHeartRate = '/min';
145810
+ }
145811
+ return annotations;
145812
+ }
145813
+ function getEcgMultiplexGroupIndex(options) {
145814
+ const index = options
145815
+ ?.multiplexGroupIndex;
145816
+ return Number.isInteger(index) && index >= 0
145817
+ ? index
145818
+ : undefined;
145819
+ }
145820
+ function findPrimaryWaveformGroup(groups, preferredIndex) {
145821
+ if (!groups.length) {
145822
+ throw new Error('[ecgFromInstance] WaveformSequence has no groups');
145823
+ }
145824
+ if (typeof preferredIndex === 'number' &&
145825
+ preferredIndex >= 0 &&
145826
+ preferredIndex < groups.length) {
145827
+ return { group: groups[preferredIndex], index: preferredIndex };
145828
+ }
145829
+ const rhythmIndex = groups.findIndex((g) => {
145830
+ const label = String(g.MultiplexGroupLabel || '').toUpperCase();
145831
+ return label.includes('RHYTHM') || label.includes('CONTINUOUS');
145832
+ });
145833
+ if (rhythmIndex >= 0) {
145834
+ return { group: groups[rhythmIndex], index: rhythmIndex };
145835
+ }
145836
+ let bestIndex = 0;
145837
+ let maxDuration = -1;
145838
+ groups.forEach((g, idx) => {
145839
+ const samples = Number(g.NumberOfWaveformSamples) || 0;
145840
+ const freq = Number(g.SamplingFrequency) || 1;
145841
+ const duration = freq > 0 ? samples / freq : samples;
145842
+ if (duration > maxDuration) {
145843
+ maxDuration = duration;
145844
+ bestIndex = idx;
145845
+ }
145846
+ });
145847
+ return { group: groups[bestIndex], index: bestIndex };
145848
+ }
145849
+ function buildEcgModuleFromInstance(instance, imageId, options = {}) {
145171
145850
  const raw = instance.WaveformSequence;
145172
145851
  const groups = toArray(raw);
145173
145852
  if (!groups.length)
145174
145853
  return null;
145175
- const group = groups[0];
145854
+ const { group, index: multiplexGroupIndex } = findPrimaryWaveformGroup(groups, options.multiplexGroupIndex);
145176
145855
  const numberOfChannels = group.NumberOfWaveformChannels ?? 0;
145177
145856
  const numberOfSamples = group.NumberOfWaveformSamples ?? 0;
145178
145857
  const samplingFrequency = group.SamplingFrequency ?? 1;
@@ -145184,36 +145863,44 @@ function buildEcgModuleFromInstance(instance, imageId) {
145184
145863
  const srcSeqArr = toArray(ch.ChannelSourceSequence);
145185
145864
  const srcSeq = srcSeqArr[0];
145186
145865
  const codeMeaning = srcSeq?.CodeMeaning ?? '';
145866
+ const codeValue = srcSeq?.CodeValue;
145867
+ const codingSchemeDesignator = srcSeq?.CodingSchemeDesignator;
145187
145868
  return {
145188
- channelSourceSequence: { codeMeaning },
145869
+ channelSourceSequence: { codeMeaning, codeValue, codingSchemeDesignator },
145870
+ mvPerUnit: getChannelMvPerUnit(ch),
145189
145871
  };
145190
145872
  });
145191
- let waveformDataRaw = (group.WaveformData ?? group.waveformData);
145192
- if (waveformDataRaw &&
145193
- typeof waveformDataRaw.length === 'number' &&
145194
- waveformDataRaw.length > 0) {
145873
+ let waveformDataRaw = group.WaveformData ?? group.waveformData;
145874
+ if (Array.isArray(waveformDataRaw) && waveformDataRaw.length > 0) {
145195
145875
  waveformDataRaw = waveformDataRaw[0];
145196
145876
  }
145197
145877
  const waveformData = waveformDataRaw ?? {};
145198
145878
  const { wadoRsRoot = undefined, studyUID = undefined } = imageId
145199
145879
  ? parseWadoRsImageId(imageId)
145200
145880
  : {};
145881
+ const toChannels = (value) => {
145882
+ if (isDecodedChannels(value, numberOfChannels, numberOfSamples)) {
145883
+ return value;
145884
+ }
145885
+ const bytes = getSingleBufferFromArray(value);
145886
+ return bytes
145887
+ ? convertBuffer(bytes, numberOfChannels, numberOfSamples, bitsAllocated, sampleInterpretation)
145888
+ : undefined;
145889
+ };
145201
145890
  const retrieveBulkData = async () => {
145202
- const wd = waveformData;
145203
- if (wd instanceof ArrayBuffer ||
145204
- (typeof ArrayBuffer !== 'undefined' &&
145205
- ArrayBuffer.isView &&
145206
- ArrayBuffer.isView(wd))) {
145207
- return convertBuffer(wd, numberOfChannels, numberOfSamples, bitsAllocated, sampleInterpretation);
145208
- }
145209
- if (waveformData.Value)
145210
- return waveformData.Value;
145891
+ const channels = toChannels(waveformData) ?? toChannels(waveformData.Value);
145892
+ if (channels) {
145893
+ return channels;
145894
+ }
145211
145895
  if (waveformData.InlineBinary) {
145212
145896
  const raw = base64ToUint8Array(waveformData.InlineBinary);
145213
145897
  return convertBuffer(raw, numberOfChannels, numberOfSamples, bitsAllocated, sampleInterpretation);
145214
145898
  }
145215
145899
  if (typeof waveformData.retrieveBulkData === 'function') {
145216
- return waveformData.retrieveBulkData();
145900
+ const retrieved = toChannels(await waveformData.retrieveBulkData());
145901
+ if (retrieved) {
145902
+ return retrieved;
145903
+ }
145217
145904
  }
145218
145905
  if (waveformData.BulkDataURI) {
145219
145906
  let url = waveformData.BulkDataURI;
@@ -145222,17 +145909,23 @@ function buildEcgModuleFromInstance(instance, imageId) {
145222
145909
  ? `${wadoRsRoot}/studies/${studyUID}/${url}`
145223
145910
  : `${wadoRsRoot}/${url}`;
145224
145911
  }
145225
- const response = await fetch(url);
145226
- const buffer = await response.arrayBuffer();
145227
- const contentType = response.headers.get('content-type') || '';
145228
- const decoded = contentType.includes('multipart')
145229
- ? multipartDecode(buffer)[0]
145230
- : buffer;
145231
- return convertBuffer(decoded, numberOfChannels, numberOfSamples, bitsAllocated, sampleInterpretation);
145232
- }
145233
- ecgFromInstance_cs3dLogger.warn('[ecgFromInstance] No waveform data source found. group keys:', Object.keys(group), 'waveformData keys:', Object.keys(waveformData));
145912
+ const response = await fetch(url, {
145913
+ headers: {
145914
+ Accept: 'multipart/related; type="application/octet-stream"',
145915
+ ...options.getHeaders?.(),
145916
+ },
145917
+ });
145918
+ if (!response.ok) {
145919
+ throw new Error(`[ecgFromInstance] Waveform bulkdata fetch failed: ${response.status}`);
145920
+ }
145921
+ const [part] = decodeMultipartRelated(await response.arrayBuffer(), response.headers.get('content-type') ?? undefined);
145922
+ return convertBuffer(part, numberOfChannels, numberOfSamples, bitsAllocated, sampleInterpretation);
145923
+ }
145924
+ const dataKeys = Object.keys(waveformData);
145925
+ ecgFromInstance_cs3dLogger.warn('[ecgFromInstance] No waveform data source found. waveformData keys:', dataKeys.slice(0, 10), `(${dataKeys.length} total)`);
145234
145926
  throw new Error('[ecgFromInstance] No waveform data source found');
145235
145927
  };
145928
+ const annotations = parseEcgAnnotations(instance);
145236
145929
  return {
145237
145930
  numberOfWaveformChannels: numberOfChannels,
145238
145931
  numberOfWaveformSamples: numberOfSamples,
@@ -145240,8 +145933,11 @@ function buildEcgModuleFromInstance(instance, imageId) {
145240
145933
  waveformBitsAllocated: bitsAllocated,
145241
145934
  waveformSampleInterpretation: sampleInterpretation,
145242
145935
  multiplexGroupLabel,
145936
+ multiplexGroupIndex,
145937
+ totalMultiplexGroups: groups.length,
145243
145938
  channelDefinitionSequence,
145244
145939
  waveformData: { retrieveBulkData },
145940
+ annotations,
145245
145941
  };
145246
145942
  }
145247
145943
  const ECG_FROM_INSTANCE_PRIORITY = 4_000;
@@ -145251,22 +145947,26 @@ const ecgFromInstanceProvider = (next, query, data, options) => {
145251
145947
  if (!hasWaveform) {
145252
145948
  return next(query, data, options);
145253
145949
  }
145254
- const result = buildEcgModuleFromInstance(instance, query);
145950
+ const result = buildEcgModuleFromInstance(instance, query, {
145951
+ multiplexGroupIndex: getEcgMultiplexGroupIndex(options),
145952
+ });
145255
145953
  return result ?? next(query, data, options);
145256
145954
  };
145257
145955
  const ECG_AMPLITUDE_INDEX_SIZE = 65536;
145258
- const ECG_AMPLITUDE_OFFSET = 32768;
145259
- const ecgCalibrationProvider = (next, query, data, options) => {
145260
- const instance = data;
145956
+ const ECG_AMPLITUDE_OFFSET = ECG_AMPLITUDE_INDEX_SIZE / 2;
145957
+ function buildEcgCalibrationFromInstance(instance, options) {
145261
145958
  const raw = instance?.WaveformSequence;
145262
145959
  const groups = toArray(raw);
145263
145960
  if (!groups.length)
145264
- return next(query, data, options);
145265
- const group = groups[0];
145961
+ return undefined;
145962
+ const { group } = findPrimaryWaveformGroup(groups, getEcgMultiplexGroupIndex(options));
145266
145963
  const numberOfWaveformSamples = group.NumberOfWaveformSamples ?? 0;
145267
145964
  const samplingFrequency = group.SamplingFrequency ?? 1;
145268
145965
  const physicalDeltaX = 1 / (samplingFrequency || 1);
145269
- const physicalDeltaY = 0.001;
145966
+ const firstChannel = toArray(group.ChannelDefinitionSequence)[0];
145967
+ const physicalDeltaY = firstChannel
145968
+ ? getChannelMvPerUnit(firstChannel)
145969
+ : ECG_DEFAULT_MV_PER_UNIT;
145270
145970
  return {
145271
145971
  sequenceOfUltrasoundRegions: [
145272
145972
  {
@@ -145284,7 +145984,8 @@ const ecgCalibrationProvider = (next, query, data, options) => {
145284
145984
  },
145285
145985
  ],
145286
145986
  };
145287
- };
145987
+ }
145988
+ const ecgCalibrationProvider = (next, query, data, options) => buildEcgCalibrationFromInstance(data, options) ?? next(query, data, options);
145288
145989
  function registerEcgFromInstanceProvider() {
145289
145990
  (0,metaData/* .addTypedProvider */.bf)(enums/* .MetadataModules.ECG */.nb.ECG, ecgFromInstanceProvider, {
145290
145991
  priority: ECG_FROM_INSTANCE_PRIORITY,
@@ -145463,8 +146164,8 @@ function registerScalingFromInstanceProvider() {
145463
146164
 
145464
146165
 
145465
146166
 
145466
- // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/metadata/dist/esm/displayset/index.js + 14 modules
145467
- var displayset = __webpack_require__(28270);
146167
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/metadata/dist/esm/displayset/index.js + 24 modules
146168
+ var displayset = __webpack_require__(94002);
145468
146169
  ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/metadata/dist/esm/utilities/index.js
145469
146170
 
145470
146171
 
@@ -145484,6 +146185,9 @@ var displayset = __webpack_require__(28270);
145484
146185
 
145485
146186
 
145486
146187
 
146188
+
146189
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/metadata/dist/esm/safeFunctions/index.js + 6 modules
146190
+ var safeFunctions = __webpack_require__(45992);
145487
146191
  ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/metadata/dist/esm/utilities/metadataProvider/compressedFrameData.js
145488
146192
 
145489
146193
 
@@ -145675,6 +146379,7 @@ function registerDefaultProviders() {
145675
146379
 
145676
146380
 
145677
146381
 
146382
+
145678
146383
  const { /* calculateSUVScalingFactors */C: calculateSUVScalingFactors } = calculate_suv_esm;
145679
146384
 
145680
146385
 
@@ -145888,6 +146593,151 @@ __webpack_require__.d(__webpack_exports__, {
145888
146593
  });
145889
146594
 
145890
146595
 
146596
+ },
146597
+ 40327(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
146598
+ "use strict";
146599
+ /* import */ var _metaData_js__rspack_import_0 = __webpack_require__(6482);
146600
+ /* import */ var dcmjs__rspack_import_1 = __webpack_require__(85631);
146601
+ /* import */ var _modules_index_js__rspack_import_2 = __webpack_require__(42701);
146602
+ /* import */ var _cornerstonejs_utils__rspack_import_3 = __webpack_require__(20325);
146603
+
146604
+
146605
+
146606
+
146607
+ const cs3dLogger = _cornerstonejs_utils__rspack_import_3/* .logging.metadataLog.getLogger */.m9.Um.getLogger('utilities.Tags');
146608
+ const dicomDictionary = dcmjs__rspack_import_1/* ["default"].data.DicomMetaDictionary.dictionary */.Ay.data.DicomMetaDictionary.dictionary;
146609
+ const nameMap = dcmjs__rspack_import_1/* ["default"].data.DicomMetaDictionary.nameMap */.Ay.data.DicomMetaDictionary.nameMap;
146610
+
146611
+ function createTagEntry(hexTag, ...groups) {
146612
+ return {
146613
+ tag: hexTag,
146614
+ groups,
146615
+ xTag: null,
146616
+ primaryGroup: null,
146617
+ name: null,
146618
+ lowerName: null,
146619
+ vr: null,
146620
+ vm: null,
146621
+ };
146622
+ }
146623
+ function parseVm(vm) {
146624
+ if (vm === undefined || vm === null) {
146625
+ return null;
146626
+ }
146627
+ if (typeof vm === 'number') {
146628
+ return vm;
146629
+ }
146630
+ const n = parseInt(vm, 10);
146631
+ if (String(n) === vm) {
146632
+ return n;
146633
+ }
146634
+ return 0;
146635
+ }
146636
+ function dictionaryLookup(hexTag) {
146637
+ return dicomDictionary[hexTag.toUpperCase()];
146638
+ }
146639
+ function getTagCodeByName(name) {
146640
+ return mapTagInfo.get(name)?.tag;
146641
+ }
146642
+ const mapModuleTags = new Map();
146643
+ const mapTagInfo = new Map();
146644
+ function addTag(name, value) {
146645
+ if (name && value.name && name !== value.name) {
146646
+ throw new Error(`Tag name provided and value don't match: ${name} !== ${value.name}`);
146647
+ }
146648
+ value.name ||= name;
146649
+ value.lowerName ||= _metaData_js__rspack_import_0/* .toLowerCamelTag */.Hw(name);
146650
+ Tags[name] = value;
146651
+ const { tag: hexTag } = value;
146652
+ value.primaryGroup ||= value.groups?.[0];
146653
+ const { groups } = value;
146654
+ mapTagInfo.set(name, value);
146655
+ if (hexTag) {
146656
+ value.xTag = `x${hexTag.toLowerCase()}`;
146657
+ value.tag = hexTag.toUpperCase();
146658
+ mapTagInfo.set(value.xTag, value);
146659
+ mapTagInfo.set(value.tag, value);
146660
+ if (!value.vr) {
146661
+ const dictEntry = dicomDictionary[value.tag];
146662
+ if (dictEntry) {
146663
+ value.vr = dictEntry.vr;
146664
+ value.vm = parseVm(dictEntry.vm);
146665
+ }
146666
+ }
146667
+ }
146668
+ if (groups?.length) {
146669
+ for (const group of groups) {
146670
+ let moduleEntries = mapModuleTags.get(group);
146671
+ if (!moduleEntries) {
146672
+ moduleEntries = [value];
146673
+ mapModuleTags.set(group, moduleEntries);
146674
+ return;
146675
+ }
146676
+ const foundIndex = moduleEntries.findIndex((it) => it.name === name);
146677
+ if (foundIndex === -1) {
146678
+ moduleEntries.push(value);
146679
+ }
146680
+ else {
146681
+ moduleEntries[foundIndex] = value;
146682
+ }
146683
+ }
146684
+ }
146685
+ }
146686
+ function resolveHexFromKeyword(keyword) {
146687
+ const entry = Object.prototype.hasOwnProperty.call(nameMap, keyword)
146688
+ ? nameMap[keyword]
146689
+ : undefined;
146690
+ if (!entry?.tag) {
146691
+ return undefined;
146692
+ }
146693
+ return entry.tag.substring(1, 5) + entry.tag.substring(6, 10);
146694
+ }
146695
+ let keywordsByLowerCase;
146696
+ function keywordIgnoringCase(name) {
146697
+ if (!keywordsByLowerCase) {
146698
+ keywordsByLowerCase = new Map();
146699
+ for (const keyword of Object.keys(nameMap)) {
146700
+ keywordsByLowerCase.set(keyword.toLowerCase(), keyword);
146701
+ }
146702
+ }
146703
+ return keywordsByLowerCase.get(name.toLowerCase());
146704
+ }
146705
+ const Tags = {};
146706
+ const tagGroups = new Map();
146707
+ for (const [moduleName, keywords] of _modules_index_js__rspack_import_2/* .moduleDefinitions */.zh) {
146708
+ for (const entry of keywords) {
146709
+ const keyword = typeof entry === 'string' ? entry : entry[0];
146710
+ const hexOverride = typeof entry === 'string' ? undefined : entry[1];
146711
+ let data = tagGroups.get(keyword);
146712
+ if (!data) {
146713
+ const hex = hexOverride ?? resolveHexFromKeyword(keyword);
146714
+ data = { hex, groups: [] };
146715
+ tagGroups.set(keyword, data);
146716
+ }
146717
+ if (moduleName !== null) {
146718
+ data.groups.push(moduleName);
146719
+ }
146720
+ }
146721
+ }
146722
+ for (const [keyword, { hex, groups }] of tagGroups) {
146723
+ if (!hex) {
146724
+ cs3dLogger.warn(`Tags: keyword "${keyword}" not found in dcmjs nameMap`);
146725
+ continue;
146726
+ }
146727
+ addTag(keyword, createTagEntry(hex, ...groups));
146728
+ }
146729
+
146730
+ __webpack_require__.d(__webpack_exports__, {
146731
+ PM: () => (resolveHexFromKeyword),
146732
+ bF: () => (parseVm),
146733
+ d1: () => (dictionaryLookup),
146734
+ jX: () => (keywordIgnoringCase)
146735
+ }, {
146736
+ Mj: mapModuleTags,
146737
+ fw: mapTagInfo
146738
+ });
146739
+
146740
+
145891
146741
  },
145892
146742
  52805(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
145893
146743
  "use strict";
@@ -146347,7 +147197,7 @@ __webpack_require__.d(__webpack_exports__, {
146347
147197
  /* import */ var _version_js__rspack_import_0 = __webpack_require__(88253);
146348
147198
  /* import */ var _utilities_index_js__rspack_import_1 = __webpack_require__(28102);
146349
147199
  /* import */ var _utilities_logging_index_js__rspack_import_2 = __webpack_require__(68272);
146350
- /* import */ var _utilities_object_index_js__rspack_import_3 = __webpack_require__(33430);
147200
+ /* import */ var _utilities_object_index_js__rspack_import_3 = __webpack_require__(24132);
146351
147201
  /* import */ var _utilities_math_index_js__rspack_import_4 = __webpack_require__(40937);
146352
147202
 
146353
147203
 
@@ -146357,13 +147207,16 @@ __webpack_require__.d(__webpack_exports__, {
146357
147207
 
146358
147208
  __webpack_require__.d(__webpack_exports__, {
146359
147209
  Et: () => (/* reexport safe */ _utilities_math_index_js__rspack_import_4.Et),
147210
+ FL: () => (/* reexport safe */ _utilities_math_index_js__rspack_import_4.FL),
146360
147211
  IQ: () => (/* reexport safe */ _utilities_math_index_js__rspack_import_4.IQ),
146361
147212
  Ph: () => (/* reexport safe */ _utilities_math_index_js__rspack_import_4.Ph),
146362
147213
  Ro: () => (/* reexport safe */ _utilities_math_index_js__rspack_import_4.Ro),
146363
147214
  WC: () => (/* reexport safe */ _utilities_math_index_js__rspack_import_4.WC),
146364
- _j: () => (/* reexport safe */ _utilities_object_index_js__rspack_import_3._),
147215
+ _j: () => (/* reexport safe */ _utilities_object_index_js__rspack_import_3._j),
146365
147216
  m9: () => (/* reexport module object */ _utilities_logging_index_js__rspack_import_2),
146366
- n4: () => (/* reexport safe */ _utilities_math_index_js__rspack_import_4.n4)
147217
+ mm: () => (/* reexport safe */ _utilities_object_index_js__rspack_import_3.mm),
147218
+ n4: () => (/* reexport safe */ _utilities_math_index_js__rspack_import_4.n4),
147219
+ w7: () => (/* reexport safe */ _utilities_math_index_js__rspack_import_4.w7)
146367
147220
  });
146368
147221
 
146369
147222
 
@@ -146379,17 +147232,21 @@ __webpack_require__.d(__webpack_exports__, {
146379
147232
 
146380
147233
  __webpack_require__.d(__webpack_exports__, {
146381
147234
  Et: () => (/* reexport safe */ _isEqual_js__rspack_import_1.Et),
147235
+ FL: () => (/* reexport safe */ _toNumber_js__rspack_import_0.FL),
146382
147236
  IQ: () => (/* reexport safe */ _toNumber_js__rspack_import_0.IQ),
146383
147237
  Ph: () => (/* reexport safe */ _isEqual_js__rspack_import_1.Ph),
146384
147238
  Ro: () => (/* reexport safe */ _toNumber_js__rspack_import_0.Ro),
146385
147239
  WC: () => (/* reexport safe */ _isEqual_js__rspack_import_1.WC),
146386
- n4: () => (/* reexport safe */ _isEqual_js__rspack_import_1.n4)
147240
+ n4: () => (/* reexport safe */ _isEqual_js__rspack_import_1.n4),
147241
+ w7: () => (/* reexport safe */ _toNumber_js__rspack_import_0.w7)
146387
147242
  });
146388
147243
 
146389
147244
 
146390
147245
  },
146391
147246
  15801(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
146392
147247
  "use strict";
147248
+ /* import */ var _object_asArray_js__rspack_import_0 = __webpack_require__(31389);
147249
+
146393
147250
  function isNumberLike(value) {
146394
147251
  return (typeof value === 'string' ||
146395
147252
  typeof value === 'number' ||
@@ -146403,21 +147260,30 @@ function isEntryWise(value) {
146403
147260
  return (Symbol.iterator in value ||
146404
147261
  typeof value.length === 'number');
146405
147262
  }
146406
- function toFiniteNumber(value, defaultValue) {
146407
- if (value === undefined || value === null) {
147263
+ function finiteOrDefault(value, defaultValue) {
147264
+ if (!isNumberLike(value) || String(value).trim() === '') {
146408
147265
  return defaultValue;
146409
147266
  }
146410
- if (isNumberLike(value)) {
146411
- const converted = Number(value);
146412
- return Number.isFinite(converted) ? converted : defaultValue;
147267
+ const converted = Number(value);
147268
+ return Number.isFinite(converted) ? converted : defaultValue;
147269
+ }
147270
+ function toFiniteNumber(value, defaultValue) {
147271
+ if (isNumberLike(value) || !isEntryWise(value)) {
147272
+ return finiteOrDefault(value, defaultValue);
146413
147273
  }
146414
- if (!isEntryWise(value)) {
146415
- return defaultValue;
147274
+ return Array.from(value, (entry) => finiteOrDefault(entry, defaultValue));
147275
+ }
147276
+ function toFiniteFirst(value, defaultValue) {
147277
+ return finiteOrDefault((0,_object_asArray_js__rspack_import_0/* .asArrayFirst */.mm)(value), defaultValue);
147278
+ }
147279
+ function toFiniteVector(value, length) {
147280
+ if (isNumberLike(value) || !isEntryWise(value)) {
147281
+ return undefined;
146416
147282
  }
146417
- return Array.from(value, (entry) => {
146418
- const converted = Number(entry);
146419
- return Number.isFinite(converted) ? converted : defaultValue;
146420
- });
147283
+ const numbers = Array.from(value, (entry) => finiteOrDefault(entry));
147284
+ return numbers.length === length && numbers.every((n) => n !== undefined)
147285
+ ? numbers
147286
+ : undefined;
146421
147287
  }
146422
147288
  function toNumber(val) {
146423
147289
  if (val === undefined || val === null) {
@@ -146437,35 +147303,12 @@ function toNumber(val) {
146437
147303
  /* unused export default */ var __rspack_default_export = ((/* unused pure expression or super */ null && (toNumber)));
146438
147304
 
146439
147305
  __webpack_require__.d(__webpack_exports__, {
147306
+ FL: () => (toFiniteFirst),
146440
147307
  IQ: () => (toFiniteNumber),
146441
- Ro: () => (toNumber)
146442
- });
146443
-
146444
-
146445
- },
146446
- 33430(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
146447
- "use strict";
146448
-
146449
- // EXPORTS
146450
- __webpack_require__.d(__webpack_exports__, {
146451
- _: () => (/* reexport */ asArray)
147308
+ Ro: () => (toNumber),
147309
+ w7: () => (toFiniteVector)
146452
147310
  });
146453
147311
 
146454
- // UNUSED EXPORTS: asArrayDefault
146455
-
146456
- ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/utils/dist/esm/utilities/object/asArray.js
146457
- function asArray(item) {
146458
- if (Array.isArray(item)) {
146459
- return item;
146460
- }
146461
- return [item];
146462
- }
146463
- /* export default */ var object_asArray = ((/* unused pure expression or super */ null && (asArray)));
146464
-
146465
- ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/utils/dist/esm/utilities/object/index.js
146466
-
146467
-
146468
-
146469
147312
 
146470
147313
  },
146471
147314
  61296(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {