UNPKG

dicomweb-proxy

Version:

A proxy to translate between dicomweb and dimse

1 lines 532 kB
(self.webpackChunk=self.webpackChunk||[]).push([[6066,9977],{5057:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});var i=n(53586),a=n(48080),o=n(92885),s=n(71209);function r(e,t){const n=e.image;if(!e.canvas||!e.image)return;const r=(0,i.A)();if(n.stats={lastGetPixelDataTime:-1,lastStoredPixelDataToCanvasImageDataTime:-1,lastPutImageDataTime:-1,lastRenderTime:-1,lastLutGenerateTime:-1},n){let i=n.render;i||(i=e.viewport.colormap?s.l:n.color?a.f:o.j),i(e,t)}const l=(0,i.A)()-r;n.stats.lastRenderTime=l,e.invalid=!1,e.needsRedraw=!1}},7808:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(45354);function a(e,t){const n=new i.d;if(!e.viewport.displayedArea)return n;n.translate(e.canvas.width/2,e.canvas.height/2);const a=e.viewport.rotation;0!==a&&n.rotate(a*Math.PI/180);let o=e.viewport.scale,s=e.viewport.scale;const r=e.viewport.displayedArea.brhc.x-(e.viewport.displayedArea.tlhc.x-1),l=e.viewport.displayedArea.brhc.y-(e.viewport.displayedArea.tlhc.y-1);if("NONE"===e.viewport.displayedArea.presentationSizeMode)e.image.rowPixelSpacing<e.image.columnPixelSpacing?o*=e.image.columnPixelSpacing/e.image.rowPixelSpacing:e.image.columnPixelSpacing<e.image.rowPixelSpacing&&(s*=e.image.rowPixelSpacing/e.image.columnPixelSpacing);else if(o=e.viewport.displayedArea.columnPixelSpacing,s=e.viewport.displayedArea.rowPixelSpacing,"SCALE TO FIT"===e.viewport.displayedArea.presentationSizeMode){const t=e.canvas.height/(l*s),n=e.canvas.width/(r*o);o=s=Math.min(n,t),e.viewport.displayedArea.rowPixelSpacing<e.viewport.displayedArea.columnPixelSpacing?o*=e.viewport.displayedArea.columnPixelSpacing/e.viewport.displayedArea.rowPixelSpacing:e.viewport.displayedArea.columnPixelSpacing<e.viewport.displayedArea.rowPixelSpacing&&(s*=e.viewport.displayedArea.rowPixelSpacing/e.viewport.displayedArea.columnPixelSpacing)}return n.scale(o,s),0!==a&&n.rotate(-a*Math.PI/180),n.translate(e.viewport.translation.x,e.viewport.translation.y),0!==a&&n.rotate(a*Math.PI/180),void 0!==t&&n.scale(t,t),e.viewport.hflip&&n.scale(-1,1),e.viewport.vflip&&n.scale(1,-1),n.translate(-r/2,-l/2),n}},36931:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var i=n(12132),a=n(57162);function o(e,t,n,o){if(void 0===e)throw new Error("getDefaultViewport: parameter canvas must not be undefined");if(void 0===t)return(0,i.A)();const s=(0,a.A)(e,t,0).scaleFactor;let r;return"PT"===n&&t.isPreScaled?r={windowWidth:5,windowCenter:2.5}:void 0!==t.windowWidth&&void 0!==t.windowCenter&&(r={windowWidth:Array.isArray(t.windowWidth)?t.windowWidth[0]:t.windowWidth,windowCenter:Array.isArray(t.windowCenter)?t.windowCenter[0]:t.windowCenter}),{scale:s,translation:{x:0,y:0},voi:r,invert:t.invert,pixelReplication:!1,rotation:0,hflip:!1,vflip:!1,modalityLUT:t.modalityLUT,modality:n,voiLUT:t.voiLUT,colormap:void 0!==o?o:t.colormap,displayedArea:{tlhc:{x:1,y:1},brhc:{x:t.columns,y:t.rows},rowPixelSpacing:void 0===t.rowPixelSpacing?1:t.rowPixelSpacing,columnPixelSpacing:void 0===t.columnPixelSpacing?1:t.columnPixelSpacing,presentationSizeMode:"NONE"}}}},50584:(e,t,n)=>{"use strict";n.d(t,{QV:()=>i.A});n(49038);var i=n(86252);n(90808),n(29625),n(50180),n(1271)},71851:(e,t,n)=>{"use strict";n.d(t,{BlendModes:()=>l.A,CalibrationTypes:()=>u.A,Events:()=>a.A,GenerateImageType:()=>i,GeometryType:()=>c.A,ImageQualityStatus:()=>v.A,InterpolationType:()=>r.A,MeshType:()=>h.A,MetadataModules:()=>f.A,OrientationAxis:()=>d.A,RequestType:()=>o.A,VOILUTFunctionType:()=>g.A,VideoEnums:()=>p,ViewportStatus:()=>m.A,ViewportType:()=>s.A});var i,a=n(32643),o=n(43213),s=n(41864),r=n(29310),l=n(63591),d=n(18735),c=n(91346),h=(n(86066),n(32731)),g=n(82501),u=(n(91369),n(38059)),m=n(1814),v=n(77474),p=n(13545),f=n(69850);!function(e){e.SUM="SUM",e.SUBTRACT="SUBTRACT",e.AVERAGE="AVERAGE"}(i||(i={}));n(6796)},15327:(e,t,n)=>{"use strict";n.d(t,{BaseVolumeViewport:()=>d.A,CONSTANTS:()=>a,EPSILON:()=>r.p8,Enums:()=>i,ImageVolume:()=>u.QV,Settings:()=>_,StackViewport:()=>c.A,VolumeViewport:()=>l.A,addImageSlicesToViewports:()=>R.ge,addVolumesToViewports:()=>R.x,cache:()=>m.Ay,convertMapperToNotSharedMapper:()=>s.h,createVolumeActor:()=>o.A,eventTarget:()=>h.A,getEnabledElement:()=>p.Ay,getEnabledElementByIds:()=>p.b1,getEnabledElementByViewportId:()=>p.yj,getEnabledElements:()=>p.zb,getRenderingEngine:()=>g.lD,getRenderingEngines:()=>g.qO,getWebWorkerManager:()=>w.G_,imageLoadPoolManager:()=>v.A,imageLoader:()=>y,metaData:()=>f,triggerEvent:()=>P.A,utilities:()=>x,volumeLoader:()=>M});var i=n(71851),a=n(19325),o=(n(56706),n(61640)),s=n(92099),r=n(30135),l=n(94155),d=(n(40893),n(46347)),c=n(58165),h=(n(32501),n(81466),n(10056),n(10364)),g=n(39536),u=n(50584),m=n(49038),v=(n(91073),n(51159)),p=n(86846),f=n(74876),w=n(26896);const E=Symbol("DefaultSettings"),I=Symbol("RuntimeSettings"),C=Symbol("ObjectSettingsMap"),b=Symbol("Dictionary");class _{constructor(e){const t=Object.create(e instanceof _&&b in e?e[b]:null);Object.seal(Object.defineProperty(this,b,{value:t}))}set(e,t){return S(this[b],e,t,null)}get(e){return function(e,t){return e[t]}(this[b],e)}unset(e){return function(e,t){if(t.endsWith(".")){let n=0;const i=t,a=i.slice(0,-1),o=0===a.length;for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(o||t.startsWith(i)||t===a)&&(delete e[t],++n);return n>0}return delete e[t]}(this[b],e+"")}forEach(e){T(this[b],e)}extend(){return new _(this)}import(e){D(e)&&Object.keys(e).forEach((t=>{S(this[b],t,e[t],null)}))}dump(){const e={};return T(this[b],((t,n)=>{void 0!==n&&A(e,t,n)})),e}static assert(e){return e instanceof _?e:_.getRuntimeSettings()}static getDefaultSettings(e=null){let t=_[E];if(t instanceof _||(t=new _,_[E]=t),e){const n={};return t.forEach((i=>{if(i.startsWith(e)){const a=i.split(`${e}.`)[1];n[a]=t.get(i)}})),n}return t}static getRuntimeSettings(){let e=_[I];return e instanceof _||(e=new _(_.getDefaultSettings()),_[I]=e),e}static getObjectSettings(e,t){let n=null;if(e instanceof _)n=e;else if("object"==typeof e&&null!==e){let i=_[C];i instanceof WeakMap||(i=new WeakMap,_[C]=i),n=i.get(e),n instanceof _||(n=new _(_.assert(_.getObjectSettings(t))),i.set(e,n))}return n}static extendRuntimeSettings(){return _.getRuntimeSettings().extend()}}function T(e,t){for(const n in e)t(n,e[n])}function S(e,t,n,i){return!!function(e){let t,n,i;if("string"!=typeof e||(t=e.length-1)<0)return!1;i=-1;for(;(n=e.indexOf(".",i+1))>=0;){if(n-i<2||n===t)return!1;i=n}return!0}(t)&&(D(n)?function(e,t,n,i){let a;if(i.has(n))return S(e,t,null,i);i.add(n),a=0;for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&(S(e,0===o.length?t:`${t}.${o}`,n[o],i)||++a);return i.delete(n),0===a}(e,t,n,i instanceof WeakSet?i:new WeakSet):(e[t]=n,!0))}function D(e){if("object"==typeof e&&null!==e){const t=Object.getPrototypeOf(e);if(t===Object.prototype||null===t)return!0}return!1}function A(e,t,n){const i=t.indexOf(".");if(i>=0){const a=t.slice(0,i);let o=e[a];if("object"!=typeof o||null===o){const t=o;o={},void 0!==t&&(o[""]=t),e[a]=o}A(o,t.slice(i+1,t.length),n)}else e[t]=n}_.getDefaultSettings().set("useCursors",!0);var M=n(87142),y=n(80068),x=(n(89926),n(36822),n(10297)),P=n(69372),R=(n(55500),n(55509),n(56074),n(40661))},80068:(e,t,n)=>{"use strict";n.r(t),n.d(t,{cancelLoadAll:()=>D,cancelLoadImage:()=>T,cancelLoadImages:()=>S,createAndCacheDerivedImage:()=>C,createAndCacheDerivedImages:()=>b,createAndCacheDerivedLabelmapImage:()=>P,createAndCacheDerivedLabelmapImages:()=>x,createAndCacheLocalImage:()=>_,loadAndCacheImage:()=>E,loadAndCacheImages:()=>I,loadImage:()=>w,registerImageLoader:()=>A,registerUnknownImageLoader:()=>M,unregisterAllImageLoaders:()=>y});var i=n(49038),a=n(32643),o=n(10364),s=n(27119),r=n(99576),l=n(69372),d=n(80221),c=n(24623),h=n(51159),g=n(74876),u=n(6796);const m={};let v;function p(e,t){const n=i.Ay.getImageLoadObject(e);if(n)return f(n.promise,e),n;const a=e.split(":")[0],o=m[a]||v;if(!o)throw new Error(`loadImageFromImageLoader: No image loader found for scheme '${a}'`);const s=o(e,t);return f(s.promise,e),s}function f(e,t){Promise.resolve(e).then((e=>{!function(e){if(!e.voxelManager){const{width:t,height:n,numberOfComponents:i}=e,a=c.A.createImageVoxelManager({scalarData:e.getPixelData(),width:t,height:n,numberOfComponents:i});e.voxelManager=a,e.getPixelData=()=>a.getScalarData(),delete e.imageFrame.pixelData}}(e),(0,l.A)(o.A,a.A.IMAGE_LOADED,{image:e})})).catch((e=>{const n={imageId:t,error:e};(0,l.A)(o.A,a.A.IMAGE_LOAD_FAILED,n)}))}function w(e,t={priority:0,requestType:"prefetch"}){if(void 0===e)throw new Error("loadImage: parameter imageId must not be undefined");return p(e,t).promise}function E(e,t={priority:0,requestType:"prefetch"}){if(void 0===e)throw new Error("loadAndCacheImage: parameter imageId must not be undefined");const n=p(e,t);return i.Ay.getImageLoadObject(e)||i.Ay.putImageLoadObject(e,n),n.promise}function I(e,t={priority:0,requestType:"prefetch"}){if(!e||0===e.length)throw new Error("loadAndCacheImages: parameter imageIds must be list of image Ids");return e.map((e=>E(e,t)))}function C(e,t={}){if(void 0===e)throw new Error("createAndCacheDerivedImage: parameter imageId must not be undefined");void 0===t.imageId&&(t.imageId=`derived:${(0,d.A)()}`);const{imageId:n,skipCreateBuffer:a,onCacheAdd:o,voxelRepresentation:l}=t,c=g.get("imagePlaneModule",e),h=c.rows*c.columns,{TypedArrayConstructor:u}=(0,r.h)(t.targetBuffer?.type,h),m=new u(a?1:h),v=n,p=g.get("imagePlaneModule",e);s.A.add(v,{type:"imagePlaneModule",metadata:p});const f=g.get("generalSeriesModule",e);s.A.add(v,{type:"generalSeriesModule",metadata:f}),s.A.add(v,{type:"generalImageModule",metadata:{instanceNumber:t.instanceNumber}});const w=g.get("imagePixelModule",e);s.A.add(v,{type:"imagePixelModule",metadata:{...w,bitsAllocated:8,bitsStored:8,highBit:7,samplesPerPixel:1,pixelRepresentation:0}});const E=_(n,{scalarData:m,onCacheAdd:o,skipCreateBuffer:a,targetBuffer:{type:m.constructor.name},voxelRepresentation:l,dimensions:[c.columns,c.rows],spacing:[c.columnPixelSpacing,c.rowPixelSpacing],origin:c.imagePositionPatient,direction:c.imageOrientationPatient,frameOfReferenceUID:c.frameOfReferenceUID,referencedImageId:e});return E.referencedImageId=e,i.Ay.getImageLoadObject(n)||i.Ay.putImageSync(n,E),E}function b(e,t={}){if(0===e.length)throw new Error("createAndCacheDerivedImages: parameter imageIds must be list of image Ids");const n=[];return e.map(((e,i)=>{const a={imageId:t?.getDerivedImageId?.(e)||`derived:${(0,d.A)()}`,...t};return n.push(a.imageId),C(e,{...a,instanceNumber:i+1})}))}function _(e,t){const{scalarData:n,origin:a,direction:o,targetBuffer:l,skipCreateBuffer:d,onCacheAdd:h,frameOfReferenceUID:g,voxelRepresentation:m,referencedImageId:v}=t,p=t.dimensions,f=t.spacing;if(!p||!f)throw new Error("createAndCacheLocalImage: dimensions and spacing are required");const w=p[0],E=p[1],I=f[0],C=f[1],b={frameOfReferenceUID:g,rows:E,columns:w,imageOrientationPatient:o??[1,0,0,0,1,0],rowCosines:o?o.slice(0,3):[1,0,0],columnCosines:o?o.slice(3,6):[0,1,0],imagePositionPatient:a??[0,0,0],pixelSpacing:[C,I],rowPixelSpacing:C,columnPixelSpacing:I},_=w*E,T=n.length/_;let S,D,A,M;if(n){if(!(n instanceof Uint8Array||n instanceof Float32Array||n instanceof Uint16Array||n instanceof Int16Array))throw new Error("createAndCacheLocalImage: scalarData must be of type Uint8Array, Uint16Array, Int16Array or Float32Array");S=n}else if(!d){const{TypedArrayConstructor:e}=(0,r.h)(l?.type,_);S=new e(_)}if(S instanceof Uint8Array)D=8,A=8,M=7;else if(S instanceof Uint16Array)D=16,A=16,M=15;else if(S instanceof Int16Array)D=16,A=16,M=15;else{if(!(S instanceof Float32Array))throw new Error("Unsupported scalarData type");D=32,A=32,M=31}const y={samplesPerPixel:1,photometricInterpretation:S.length>p[0]*p[1]?"RGB":"MONOCHROME2",rows:E,columns:w,bitsAllocated:D,bitsStored:A,highBit:M},x={imagePlaneModule:b,imagePixelModule:y};["imagePlaneModule","imagePixelModule"].forEach((t=>{s.A.add(e,{type:t,metadata:x[t]||{}})}));const P=e,R=m===u.A.RLE&&c.A.createRLEImageVoxelManager({dimensions:p,id:P})||c.A.createImageVoxelManager({height:E,width:w,numberOfComponents:T,scalarData:S,id:P});let L=S[0],U=S[0];for(let e=1;e<S.length;e++)S[e]<L&&(L=S[e]),S[e]>U&&(U=S[e]);const O={imageId:e,intercept:0,windowCenter:0,windowWidth:0,color:"RGB"===y.photometricInterpretation,numberOfComponents:y.samplesPerPixel,dataType:l?.type,slope:1,minPixelValue:L,maxPixelValue:U,rows:y.rows,columns:y.columns,getCanvas:void 0,height:y.rows,width:y.columns,rgba:void 0,columnPixelSpacing:b.columnPixelSpacing,rowPixelSpacing:b.rowPixelSpacing,FrameOfReferenceUID:b.frameOfReferenceUID,invert:!1,getPixelData:()=>R.getScalarData(),voxelManager:R,sizeInBytes:n.byteLength,referencedImageId:v};return h?.(O),i.Ay.putImageSync(O.imageId,O),O}function T(e){h.A.filterRequests((({additionalDetails:t})=>!t.imageId||t.imageId!==e));const t=i.Ay.getImageLoadObject(e);t&&t.cancelFn()}function S(e){e.forEach((e=>{T(e)}))}function D(){const e=h.A.getRequestPool();Object.keys(e).forEach((t=>{const n=e[t];Object.keys(n).forEach((e=>{const t=n[e].pop();if(!t)return;const a=t.additionalDetails,{imageId:o,volumeId:s}=a;let r;o?r=i.Ay.getImageLoadObject(o):s&&(r=i.Ay.getVolumeLoadObject(s)),r&&r.cancel()})),h.A.clearRequestStack(t)}))}function A(e,t){m[e]=t}function M(e){const t=v;return v=e,t}function y(){Object.keys(m).forEach((e=>delete m[e])),v=void 0}function x(e,t={}){return b(e,{...t,targetBuffer:{type:"Uint8Array"}})}function P(e,t={}){return C(e,{...t,targetBuffer:{type:"Uint8Array"}})}},56750:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});class i{static{this.frameRangeExtractor=/(\/frames\/|[&?]frameNumber=)([^/&?]*)/i}static imageIdToFrames(e){const t=e.match(this.frameRangeExtractor);if(!t||!t[2])return null;const n=t[2].split("-").map((e=>Number(e)));return 1===n.length?n[0]:n}static imageIdToFrameEnd(e){const t=this.imageIdToFrames(e);return Array.isArray(t)?t[1]:t}static imageIdToFrameStart(e){const t=this.imageIdToFrames(e);return Array.isArray(t)?t[0]:t}static framesToString(e){return Array.isArray(e)?`${e[0]}-${e[1]}`:String(e)}static framesToImageId(e,t){const n=e.match(this.frameRangeExtractor);if(!n||!n[2])return null;const i=this.framesToString(t);return e.replace(this.frameRangeExtractor,`${n[1]}${i}`)}}},13876:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});class i{constructor(e={}){this._dimensions=3,this._length=0,this._byteSize=4,this.growSize=128;const{initialSize:t=1024,dimensions:n=3,growSize:i=128}=e,a=t*n;this.growSize=i,this.array=new ArrayBuffer(a*this._byteSize),this.data=new Float32Array(this.array),this._dimensions=n}forEach(e){for(let t=0;t<this._length;t++)e(this.getPoint(t),t)}get length(){return this._length}get dimensions(){return this._dimensions}get dimensionLength(){return this._length*this._dimensions}getPoint(e){if(e<0&&(e+=this._length),e<0||e>=this._length)return;const t=this._dimensions*e;return this.data.subarray(t,t+this._dimensions)}getPointArray(e){const t=[];if(e<0&&(e+=this._length),e<0||e>=this._length)return;const n=this._dimensions*e;for(let e=0;e<this._dimensions;e++)t.push(this.data[e+n]);return t}grow(e=1,t=this.growSize){if(this.dimensionLength+e*this._dimensions<=this.data.length)return;const n=this.data.length+t,i=new ArrayBuffer(n*this._dimensions*this._byteSize),a=new Float32Array(i);a.set(this.data),this.data=a,this.array=i}reverse(){const e=Math.floor(this._length/2);for(let t=0;t<e;t++){const e=t*this._dimensions,n=(this._length-1-t)*this._dimensions;for(let t=0;t<this._dimensions;t++){const i=this.data[e+t];this.data[e+t]=this.data[n+t],this.data[n+t]=i}}}getTypedArray(){return this.data}push(e){this.grow(1);const t=this.length*this._dimensions;for(let n=0;n<this._dimensions;n++)this.data[n+t]=e[n];this._length++}map(e){const t=[];for(let n=0;n<this._length;n++)t.push(e(this.getPoint(n),n));return t}get points(){return this.map((e=>e))}toXYZ(){const e={x:[],y:[]};this._dimensions>=3&&(e.z=[]);const{x:t,y:n,z:i}=e;return this.forEach((e=>{t.push(e[0]),n.push(e[1]),i&&i.push(e[2])})),e}static fromXYZ({x:e,y:t,z:n}){const a=i.create3(e.length);let o=0;for(let i=0;i<e.length;i++)a.data[o++]=e[i],a.data[o++]=t[i],a.data[o++]=n?n[i]:0;return a._length=e.length,a}subselect(e=10,t=0){const n=new i({initialSize:e,dimensions:this._dimensions});for(let i=0;i<e;i++){const a=(t+Math.floor(this.length*i/e))%this.length;n.push(this.getPoint(a))}return n}static create3(e=128,t){e=Math.max(e,t?.length||0);const n=new i({initialSize:e,dimensions:3});return t&&t.forEach((e=>n.push(e))),n}static create2(e=128){return new i({initialSize:e,dimensions:2})}}},22191:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});class i{constructor(e){this.name=e||"unknown"}static as(e){if(e.iterator)return e.iterator;const t=new i("as iterator");return e.then((e=>{try{t.add(e,!0)}catch(e){t.reject(e)}}),(e=>{t.reject(e)})),t}add(e,t=!1){this.nextValue=e,this.done||=t,this.waiting&&(this.waiting.resolve(e),this.waiting=void 0)}resolve(){this.done=!0,this.waiting&&(this.waiting.resolve(this.nextValue),this.waiting=void 0)}reject(e){this.rejectReason=e,this.waiting?.reject(e)}getRecent(){if(this.rejectReason)throw this.rejectReason;return this.nextValue}async*[Symbol.asyncIterator](){for(;!this.done;){if(this.rejectReason)throw this.rejectReason;if(void 0!==this.nextValue&&(yield this.nextValue,this.done))break;this.waiting||(this.waiting={},this.waiting.promise=new Promise(((e,t)=>{this.waiting.resolve=e,this.waiting.reject=t}))),await this.waiting.promise}yield this.nextValue}async forEach(e,t){let n=0;try{for await(const i of this){const{done:a}=this;try{await e(i,a,n),n++}catch(e){if(!a){console.warn("Caught exception in intermediate value",e);continue}if(!t)throw e;t(e,a)}}}catch(e){if(!t)throw e;t(e,!0)}}generate(e,t){return e(this,this.reject.bind(this)).then((()=>{this.done||this.resolve()}),(e=>{this.reject(e),t?t(e):console.warn("Couldn't process because",e)}))}async nextPromise(){for await(const e of this)if(e)return e;return this.nextValue}async donePromise(){for await(const e of this);return this.nextValue}getNextPromise(){const e=this.nextPromise();return e.iterator=this,e}getDonePromise(){const e=this.donePromise();return e.iterator=this,e}}},67645:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const i=[[0,-1,0],[0,1,0],[0,0,-1],[0,0,1]],a=[[0,-1,0],[0,1,0]],o=[[0,-1,0],[0,1,0],[0,0,-1]],s=[[0,-1,0],[0,1,0],[0,0,1]];class r{static copyMap(e,t){for(const[n,i]of t.rows)e.rows.set(n,structuredClone(i))}constructor(e,t,n=1){this.rows=new Map,this.height=1,this.width=1,this.depth=1,this.jMultiple=1,this.kMultiple=1,this.numComps=1,this.pixelDataConstructor=Uint8Array,this.updateScalarData=function(e){e.fill(0);this.forEach(((t,n,i)=>{const{start:a,end:o,value:s}=n;for(let n=a;n<o;n++)e[t+n]=s}))},this.get=e=>{const t=e%this.jMultiple,n=(e-t)/this.jMultiple,i=this.getRLE(t,n);return i?.value??this.defaultValue},this.getRun=(e,t)=>{const n=e+t*this.height;return this.rows.get(n)},this.set=(e,t)=>{if(void 0===t)return;const n=e%this.width,i=(e-n)/this.width,a=this.rows.get(i);if(!a)return void this.rows.set(i,[{start:n,end:n+1,value:t}]);const o=this.findIndex(a,n),s=a[o],r=a[o-1];if(!s)return r&&r.value===t&&r.end===n?void r.end++:void(a[o]={start:n,end:n+1,value:t});const{start:l,end:d,value:c}=s;if(t===c&&n>=l)return;const h={start:n,end:n+1,value:t},g=n>l,u=g?o+1:o,m=g?s:r;let v=g?a[o+1]:s;if(m?.value===t&&m?.end===n)return m.end++,void(v?.value===t&&v.start===n+1?(m.end=v.end,a.splice(o,1)):v?.start===n&&(v.start++,v.start===v.end&&(a.splice(o,1),v=a[o],v?.start===n+1&&v.value===t&&(m.end=v.end,a.splice(o,1)))));if(v?.value===t&&v.start===n+1)return v.start--,void(m?.end>n&&(m.end=n,m.end===m.start&&a.splice(o,1)));if(v?.start!==n||v.end!==n+1)n===v?.start&&v.start++,g&&d>n+1?a.splice(u,0,h,{start:n+1,end:m.end,value:m.value}):a.splice(u,0,h),m?.end>n&&(m.end=n);else{v.value=t;const e=a[o+1];e?.start==n+1&&e.value===t&&(a.splice(o+1,1),v.end=e.end)}},this.width=e,this.height=t,this.depth=n,this.jMultiple=e,this.kMultiple=this.jMultiple*t}static{this.getScalarData=function(e=Uint8ClampedArray){const t=new e(this.frameSize);return this.map.updateScalarData(t),t}}toIJK(e){const t=e%this.jMultiple;return[t,(e-t)/this.jMultiple%this.height,Math.floor(e/this.kMultiple)]}toIndex([e,t,n]){return e+n*this.kMultiple+t*this.jMultiple}getRLE(e,t,n=0){const i=this.rows.get(t+n*this.height);if(!i)return;const a=i[this.findIndex(i,e)];return e>=a?.start?a:void 0}has(e){const t=e%this.jMultiple,n=(e-t)/this.jMultiple,i=this.getRLE(t,n);return void 0!==i?.value}delete(e){const t=e%this.width,n=(e-t)/this.width,i=this.rows.get(n);if(!i)return;const a=this.findIndex(i,t),o=i[a];if(!o||o.start>t)return;if(o.end===t+1)return o.end--,void(o.start>=o.end&&(i.splice(a,1),i.length||this.rows.delete(n)));if(o.start===t)return void o.start++;const s={value:o.value,start:t+1,end:o.end};o.end=t,i.splice(a+1,0,s)}findIndex(e,t){for(let n=0;n<e.length;n++){const{end:i}=e[n];if(t<i)return n}return e.length}forEach(e,t){const n=t?.rowModified;for(const[t,i]of this.rows){const a=n?[...i]:i;for(const n of a)e(t*this.width,n,i)}}forEachRow(e){for(const[t,n]of this.rows)e(t*this.width,n)}clear(){this.rows.clear()}keys(){return[...this.rows.keys()]}getPixelData(e=0,t){t?t.fill(0):t=new this.pixelDataConstructor(this.width*this.height*this.numComps);const{width:n,height:i,numComps:a}=this;for(let o=0;o<i;o++){const i=this.getRun(o,e);if(i)if(1===a)for(const e of i){const i=o*n,{start:a,end:s,value:r}=e;for(let e=a;e<s;e++)t[i+e]=r}else for(const e of i){const i=o*n*a,{start:s,end:r,value:l}=e;for(let e=s;e<r;e+=a)for(let n=0;n<a;n++)t[i+e+n]=l[n]}}return t}floodFill(e,t,n,i,a){const o=this.getRLE(e,t,n);if(!o)throw new Error(`Initial point ${e},${t},${n} isn't in the RLE`);const s=[[o,t,n]],r=o.value;if(r===i)throw new Error(`source (${r}) and destination (${i}) are identical`);return this.flood(s,r,i,a)}flood(e,t,n,i){let a=0;const{planar:o=!0,diagonals:s=!0,singlePlane:r=!1}=i||{},l={planar:o,diagonals:s,singlePlane:r};for(;e.length;){const i=e.pop(),[o]=i;if(o.value!==t)continue;o.value=n,a+=o.end-o.start;const s=this.findAdjacents(i,l).filter((e=>e&&e[0].value===t));e.push(...s)}return a}fillFrom(e,t){for(let n=t[2][0];n<=t[2][1];n++)for(let i=t[1][0];i<=t[1][1];i++){let a,o;for(let s=t[0][0];s<=t[0][1];s++){const t=e(s,i,n);void 0!==t?(o||(o=[],this.rows.set(i+n*this.height,o)),a&&a.value!==t&&(a=void 0),a||(a={start:s,end:s,value:t},o.push(a)),a.end++):a=void 0}}}findAdjacents(e,{diagonals:t=!0,planar:n=!0,singlePlane:r=!1}){const[l,d,c,h]=e,{start:g,end:u}=l,m=g>0&&this.getRLE(g-1,d,c),v=u<this.width&&this.getRLE(u,d,c),p=t?[g>0?g-1:g,u<this.width?u+1:u]:[g,u],f=[];m&&f.push([m,d,c]),v&&f.push([v,d,c]);for(const e of h||(r?a:i)){const[,t,l]=e,g=t+d,u=l+c;if(g<0||g>=this.height)continue;if(u<0||u>=this.depth)continue;const m=this.getRun(g,u);if(m)for(const e of m){const t=h||r&&a||n&&l>0&&s||n&&l<0&&o||i;e.end<=p[0]||e.start>=p[1]||f.push([e,g,u,t])}}return f}}},98039:(e,t,n)=>{"use strict";function i(e){return a(e,"vtkVolume")||a(e,"vtkImageSlice")}function a(e,t){const n="isA"in e?e:e.actor;return!!n&&!!n.isA(t)}n.d(t,{N:()=>a,e:()=>i})},96833:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var i=n(33739),a=n(99341);function o(e,t){const n=t.colorTransfer.split(" ").splice(1).map(parseFloat),{shiftRange:o}=function(e){let t=1/0,n=-1/0;for(let i=0;i<e.length;i+=4)t=Math.min(t,e[i]),n=Math.max(n,e[i]);const i=(n-t)/2;return{shiftRange:[-i,i],min:t,max:n}}(n),s=o[0],r=o[1]-o[0],l=i.Ay.newInstance(),d=[];for(let e=0;e<n.length;e+=4){let t=n[e];const i=n[e+1],a=n[e+2],o=n[e+3];t=(t-s)/r,d.push([t,i,a,o])}!function(e,t,n){const i=t[1]-t[0],a=e.map((([e,n,a,o])=>[e*i+t[0],n,a,o]));n.removeAllPoints(),a.forEach((([e,t,i,a])=>n.addRGBPoint(e,t,i,a)))}(d,o,l),e.getProperty().setRGBTransferFunction(0,l);const c=t.scalarOpacity.split(" ").splice(1).map(parseFloat),h=a.Ay.newInstance(),g=[];for(let e=0;e<c.length;e+=2){let t=c[e];const n=c[e+1];t=(t-s)/r,g.push([t,n])}!function(e,t,n){const i=t[1]-t[0],a=e.map((([e,n])=>[e*i+t[0],n]));n.removeAllPoints(),a.forEach((([e,t])=>n.addPoint(e,t)))}(g,o,h);const u=e.getProperty();u.setScalarOpacity(0,h);const[m,v,p,f]=t.gradientOpacity.split(" ").splice(1).map(parseFloat);u.setUseGradientOpacity(0,!0),u.setGradientOpacityMinimumValue(0,m),u.setGradientOpacityMinimumOpacity(0,v),u.setGradientOpacityMaximumValue(0,p),u.setGradientOpacityMaximumOpacity(0,f),"1"===t.interpolation&&u.setInterpolationTypeToFastLinear(),u.setShade("1"===t.shade);const w=parseFloat(t.ambient),E=parseFloat(t.diffuse),I=parseFloat(t.specular),C=parseFloat(t.specularPower);u.setAmbient(w),u.setDiffuse(E),u.setSpecular(I),u.setSpecularPower(C)}},91979:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var i=n(39536),a=n(24724);const o=e=>{const t=function(e){const t=(0,i.qO)(),n=[];return t.forEach((t=>{const i=(0,a.A)(e);i.length&&n.push({renderingEngine:t,viewportIds:i.map((e=>e.id))})})),n}(e);t?.length&&t.forEach((({renderingEngine:e,viewportIds:t})=>{e.hasBeenDestroyed||e.renderViewports(t)}))}},89131:(e,t,n)=>{"use strict";n.d(t,{KP:()=>s,SJ:()=>o});var i=n(74876),a=n(71851);function o(e){const t={...i.get(a.MetadataModules.IMAGE_PLANE,e)};return t.columnPixelSpacing||(t.columnPixelSpacing=1),t.rowPixelSpacing||(t.rowPixelSpacing=1),t.columnCosines||(t.columnCosines=[0,1,0]),t.rowCosines||(t.rowCosines=[1,0,0]),t.imagePositionPatient||(t.imagePositionPatient=[0,0,0]),t.imageOrientationPatient||(t.imageOrientationPatient=new Float32Array([1,0,0,0,1,0])),t}function s(e){const t=e.imageId,{pixelRepresentation:n,bitsAllocated:s,bitsStored:r,highBit:l,photometricInterpretation:d,samplesPerPixel:c}=i.get("imagePixelModule",t),{windowWidth:h,windowCenter:g,voiLUTFunction:u}=e,{modality:m}=i.get("generalSeriesModule",t),v=i.get("scalingModule",t),p=i.get(a.MetadataModules.CALIBRATION,t),f=function(e){return Object.values(a.VOILUTFunctionType).includes(e)?e:a.VOILUTFunctionType.LINEAR}(u);return{calibration:p,scalingFactor:v,voiLUTFunction:f,modality:m,imagePlaneModule:o(t),imagePixelModule:{bitsAllocated:s,bitsStored:r,samplesPerPixel:c,highBit:l,photometricInterpretation:d,pixelRepresentation:n,windowWidth:h,windowCenter:g,modality:m,voiLUTFunction:f}}}},42384:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});var i=n(3823),a=n(74876),o=n(26896);function s(e){const{imagePositionPatient:t,imageOrientationPatient:n}=a.get("imagePlaneModule",e[0]),s=i.eR.fromValues(n[0],n[1],n[2]),r=i.eR.fromValues(n[3],n[4],n[5]),l=i.eR.create();i.eR.cross(l,s,r);const d=i.eR.fromValues(t[0],t[1],t[2]);let c;function h(e){const{imagePositionPatient:t}=a.get("imagePlaneModule",e),n=i.eR.create(),o=i.eR.fromValues(t[0],t[1],t[2]);return i.eR.sub(n,d,o),i.eR.dot(n,l)}if("wadouri"===e[0].split(":")[0]){const t=[e[0],e[Math.floor(e.length/2)]],n=(h(t[0]),h(t[1]),a.get("imagePlaneModule",t[1]));if(!n)throw new Error("Incomplete metadata required for volume construction.");const o=i.eR.create(),s=i.eR.fromValues(n.imagePositionPatient[0],n.imagePositionPatient[1],n.imagePositionPatient[2]);i.eR.sub(o,d,s);const r=i.eR.dot(o,l);c=Math.abs(r)/Math.floor(e.length/2)}else{const t=e.map((e=>({distance:h(e),imageId:e})));t.sort(((e,t)=>t.distance-e.distance));const n=t.length;c=Math.abs(t[n-1].distance-t[0].distance)/(n-1)}const{sliceThickness:g,spacingBetweenSlices:u}=a.get("imagePlaneModule",e[0]),{strictZSpacingForVolumeViewport:m}=(0,o.D0)().rendering;return 0!==c&&!isNaN(c)||m||(u?(console.debug("Could not calculate spacing. Using spacingBetweenSlices"),c=u):g?(console.debug("Could not calculate spacing and no spacingBetweenSlices. Using sliceThickness"),c=g):(console.debug("Could not calculate spacing. The VolumeViewport visualization is compromised. Setting spacing to 1 to render"),c=1)),c}},84061:(e,t,n)=>{"use strict";function i(e,t,n){return Math.max(t,Math.min(n,e))}n.d(t,{A:()=>i,q:()=>i})},13859:(e,t,n)=>{"use strict";n.r(t),n.d(t,{findMatchingColormap:()=>c,getColormap:()=>l,getColormapNames:()=>d,registerColormap:()=>r});var i=n(660),a=n(74638),o=n(98039);const s=new Map;function r(e){e.name=e.name||e.Name,s.set(e.name,e)}function l(e){return s.get(e)}function d(){return Array.from(s.keys())}function c(e,t){const n=i.A.rgbPresetNames.map((e=>i.A.getPresetByName(e))),s=d().map((e=>l(e))),r=n.concat(s).find((t=>{const{RGBPoints:n}=t;if(n.length!==e.length)return!1;for(let t=0;t<n.length;t+=4)if(!(0,a.Ay)(n.slice(t+1,t+4),e.slice(t+1,t+4)))return!1;return!0}));if(!r)return null;const c=[];if((0,o.N)(t,"vtkVolume")){const e=t.getProperty().getScalarOpacity(0).getDataPointer();if(!e)return{name:r.Name};for(let t=0;t<e.length;t+=2)c.push({value:e[t],opacity:e[t+1]})}return{name:r.Name,opacity:c}}},74657:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(33739);function a(e){const t=i.Ay.newInstance();let n=0,a=1024;return void 0!==e.lower&&void 0!==e.upper&&(n=e.lower,a=e.upper),t.addRGBPoint(n,0,0,0),t.addRGBPoint(a,1,1,1),t}},40256:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});var i=n(33739),a=n(42008),o=n(68136),s=n(58977);function r(e,t=1024){const{windowWidth:n,windowCenter:r}=o.toWindowLevel(e.lower,e.upper),l=Array.from({length:t},((e,n)=>(n+1)/(t+2))).flatMap((e=>[(0,s.i)(e,r,n),e,e,e,.5,0])),d=i.Ay.newInstance();return d.buildFunctionFromArray(a.Ay.newInstance({values:l,numberOfComponents:6})),d}},63470:(e,t,n)=>{"use strict";function i(e,t,n=0){const i=[];for(let a=n;a<e.length;a+=t)i.push(a);return i}n.d(t,{A:()=>i})},99949:(e,t,n)=>{"use strict";function i(e){if(null===e||"object"!=typeof e)return e;if("function"==typeof e)return e;if("function"==typeof structuredClone)return e;if(Array.isArray(e))return e.map(i);{const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=i(e[n]));return t}}n.d(t,{G:()=>i})},20286:(e,t,n)=>{"use strict";function i(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return(t>>>0).toString(36)}n.d(t,{A:()=>i})},88619:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});var i=n(3823),a=n(74876),o=n(85008),s=n(19325);function r(e,t,n,r){const{direction:l,spacing:d,imageIds:c}=e,{ignoreSpacing:h=!1}=r||{};if(!c?.length)return;const g=l.slice(6,9),u=i.eR.dot(g,n);if(Math.abs(u)<1-s.EPSILON)return void console.debug("View plane normal is not parallel to the image scan axis. Unable to find closest imageId.");let m,v;if(!h){m=(0,o.A)({direction:l,spacing:d},n)/2}let p=1/0;for(let e=0;e<c.length;e++){const o=c[e],s=a.get("imagePlaneModule",o);if(!s?.imagePositionPatient){console.warn(`Missing imagePositionPatient for imageId: ${o}`);continue}const{imagePositionPatient:r}=s,l=i.eR.create();i.eR.sub(l,t,r);const d=Math.abs(i.eR.dot(l,n));h?d<p&&(p=d,v=o):d<m&&d<p&&(p=d,v=o)}return void 0===v&&console.debug("No imageId found within the specified criteria (half spacing or absolute closest)."),v}},53932:(e,t,n)=>{"use strict";n.d(t,{T:()=>s});var i=n(3823),a=n(19325),o=n(89131);function s(e){const{imagePlaneModule:t,imagePixelModule:n,voiLUTFunction:s,modality:r,scalingFactor:l,calibration:d}=(0,o.KP)(e);let{rowCosines:c,columnCosines:h}=t;null!=c&&null!=h||(c=[1,0,0],h=[0,1,0]);const g=i.eR.fromValues(c[0],c[1],c[2]),u=i.eR.fromValues(h[0],h[1],h[2]),m=i.eR.create();i.eR.cross(m,g,u);let v=t.imagePositionPatient;null==v&&(v=[0,0,0]);const p=t.columnPixelSpacing||e.columnPixelSpacing,f=t.rowPixelSpacing||e.rowPixelSpacing,w=e.columns,E=e.rows,I=a.EPSILON;return{numberOfComponents:e.numberOfComponents||function(e){let t=1;("RGB"===e||e.includes("YBR")||"PALETTE COLOR"===e)&&(t=3);return t}(n.photometricInterpretation),origin:v,direction:[...g,...u,...m],dimensions:[w,E,1],spacing:[p,f,I],numVoxels:w*E*1,imagePlaneModule:t,imagePixelModule:n,bitsAllocated:n.bitsAllocated,voiLUTFunction:s,modality:r,scalingFactor:l,calibration:d,scanAxisNormal:m}}},47476:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var i=n(20537),a=n(65292);const o=function(e){const t=e.getCamera(),{spacingInNormalDirection:n,imageVolume:o}=(0,a.A)(e,t);if(!o)return;const{viewPlaneNormal:s,focalPoint:r}=t,l=e.getActors().find((e=>e.referencedId===o.volumeId||e.uid===o.volumeId));l||console.warn("No actor found for with actorUID of",o.volumeId);const d=l.actor,c=(0,i.A)(d,s,r),{min:h,max:g,current:u}=c,m=Math.round((g-h)/n)+1;let v=(u-h)/(g-h)*m;return v=Math.floor(v),v>m-1?v=m-1:v<0&&(v=0),{numberOfSlices:m,imageIndex:v}}},32173:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(74876);function a(e){const t=i.get("modalityLutModule",e)||{},n=i.get("generalSeriesModule",e)||{},{modality:a}=n,o={rescaleSlope:t.rescaleSlope||1,rescaleIntercept:t.rescaleIntercept??0,modality:a},s=i.get("scalingModule",e)||{};return{...o,..."PT"===a&&{suvbw:s.suvbw,suvbsa:s.suvbsa,suvlbm:s.suvlbm}}}},20537:(e,t,n)=>{"use strict";n.d(t,{A:()=>c});var i=n(89265),a=n(15105),o=n(19325);const s=o.EPSILON*o.EPSILON,r=e=>Math.abs(Math.abs(e)-1)<s,l=(e,t)=>r(e[t])||r(e[t+1])||r(e[t+2]),d=e=>l(e,0)&&l(e,3)&&l(e,6);function c(e,t,n){const o=e.getMapper().getInputData();let s;const r=o.getDirection();if(d(r))s=(0,a.A)(e);else{const[e,t,n]=o.getDimensions();s=[[0,0,0],[e-1,0,0],[0,t-1,0],[e-1,t-1,0],[0,0,n-1],[e-1,0,n-1],[0,t-1,n-1],[e-1,t-1,n-1]].map((e=>o.indexToWorld(e)))}const l=i.A.buildFromDegree().identity().rotateFromDirections(t,[1,0,0]);s.forEach((e=>l.apply(e)));const c=[...n];l.apply(c);const h=c[0];let g=1/0,u=-1/0;for(let e=0;e<8;e++){const t=s[e][0];t>u&&(u=t),t<g&&(g=t)}return{min:g,max:u,current:h,actor:e,viewPlaneNormal:t,focalPoint:n}}},85008:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(3823);function a(e,t){const{direction:n,spacing:a}=e,o=n.slice(0,3),s=n.slice(3,6),r=n.slice(6,9),l=[i.eR.dot(o,t),i.eR.dot(s,t),i.eR.dot(r,t)],d=i.eR.create();i.eR.set(d,l[0]*a[0],l[1]*a[1],l[2]*a[2]);return i.eR.length(d)}},65292:(e,t,n)=>{"use strict";n.d(t,{A:()=>c});var i=n(49038),a=n(19325),o=n(85008),s=n(87142),r=n(12437);const l=1+a.EPSILON,d=e=>!!(0,s.getVolumeLoaderSchemes)().find((t=>{return n=e.volumeId,(i=t)===n.substring(0,Math.min(n.length,i.length));var n,i}));function c(e,t,n,a=!1){const{viewPlaneNormal:o}=t,s=e.getActors();if(!s.length)return{spacingInNormalDirection:null,imageVolume:null,actorUID:null};const c=s.map((e=>{const t=e.referencedId??e.uid;return i.Ay.getVolume(t)})).filter((e=>!!e));if(n){const t=(0,r.A)(n),i=c.findIndex((e=>t.includes(e.volumeId))),l=c[i],{uid:d}=s[i];return{imageVolume:l,spacingInNormalDirection:h(l,o,e,a),actorUID:d}}if(!c.length)return{spacingInNormalDirection:null,imageVolume:null,actorUID:null};const g={spacingInNormalDirection:1/0,imageVolume:null,actorUID:null},u=c.find(d);for(let t=0;t<c.length;t++){const n=c[t];if(u&&!d(n))continue;const i=h(n,o,e);i*l<g.spacingInNormalDirection&&(g.spacingInNormalDirection=i,g.imageVolume=n,g.actorUID=s[t].uid)}return g}function h(e,t,n,i=!1){const{slabThickness:a}=n.getProperties();let s=a;return a&&i||(s=(0,o.A)(e,t)),s}},24724:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(39536);const a=function(e){const t=(0,i.qO)(),n=[];return t.forEach((t=>{const i=t.getVolumeViewports().filter((t=>t.hasVolumeId(e)));n.push(...i)})),n}},70210:(e,t,n)=>{"use strict";function i(e){let t=[];const[n,i]=e.getRange();e.getTable(n,i,1024,t),t=t.filter(((e,t)=>t%3==0));const a=[...Array(1024).keys()].map(((e,t)=>n+(i-n)/1023*t)),o=t[256],s=Math.log((1-o)/o),r=a[256],l=t[768],d=Math.log((1-l)/l),c=a[768],h=Math.round(4*(c-r)/(s-d)),g=Math.round(r+h*s/4);return[Math.round(g-h/2),Math.round(g+h/2)]}n.d(t,{A:()=>i})},15105:(e,t,n)=>{"use strict";function i(e){const t=e.getMapper().getInputData(),n=t.extentToBounds(t.getExtent());return[[n[0],n[2],n[4]],[n[0],n[2],n[5]],[n[0],n[3],n[4]],[n[0],n[3],n[5]],[n[1],n[2],n[4]],[n[1],n[2],n[5]],[n[1],n[3],n[4]],[n[1],n[3],n[5]]]}n.d(t,{A:()=>i})},12437:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});const i=e=>{const t="volumeId:",n=e.includes(t)?e.substring(9):e,i=n.indexOf("sliceIndex=");return-1===i?n:n.substring(0,i-1)}},4031:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var i=n(20537),a=n(65292);const o=function(e,t,n=!1){const o=e.getCamera(),{focalPoint:s,viewPlaneNormal:r}=o,{spacingInNormalDirection:l,actorUID:d}=(0,a.A)(e,o,t,n);if(!d)throw new Error(`Could not find image volume with id ${t} in the viewport`);const c=e.getActor(d);if(!c)return console.warn("No actor found for with actorUID of",d),null;const h=c.actor;return{sliceRange:(0,i.A)(h,r,s),spacingInNormalDirection:l,camera:o}}},61375:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var i=n(4031);const a=function(e,t,n=!1){const{sliceRange:a,spacingInNormalDirection:o,camera:s}=(0,i.A)(e,t,n),{min:r,max:l,current:d}=a,c=Math.round((l-r)/o),h=(d-r)/(l-r)*c;return{numScrollSteps:c,currentStepIndex:Math.round(h),sliceRangeInfo:{sliceRange:a,spacingInNormalDirection:o,camera:s}}}},30169:(e,t,n)=>{"use strict";n.d(t,{a:()=>i});const i=e=>Object.values(e).some((e=>"number"==typeof e&&!Number.isInteger(e)))},38883:(e,t,n)=>{"use strict";function i(e){return Array.isArray(e)?e.some((e=>Number.isNaN(e))):Number.isNaN(e)}n.d(t,{A:()=>i})},39537:(e,t,n)=>{"use strict";function i(e){const t=e.indexOf(":");return e.substring(t+1)}n.d(t,{A:()=>i})},17791:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});var i=n(74876);const a=new Map,o="imageRetrieveConfiguration",s={IMAGE_RETRIEVE_CONFIGURATION:o,clear:()=>{a.clear()},add:(e,t)=>{a.set(e,t)},clone:()=>new Map(a),restore:e=>{a.clear(),e.forEach(((e,t)=>{a.set(t,e)}))},get:(e,...t)=>{if(e===o)return t.map((e=>a.get(e))).find((e=>void 0!==e))}};(0,i.addProvider)(s.get.bind(s));const r=s},10297:(e,t,n)=>{"use strict";n.r(t),n.d(t,{FrameRange:()=>ut.A,HistoryMemo:()=>a,PointsManager:()=>Se.A,ProgressiveIterator:()=>ke.A,RLEVoxelMap:()=>Ze.A,VoxelManager:()=>Ke.A,actorIsA:()=>he.N,applyPreset:()=>Te.A,autoLoad:()=>At.A,buildMetadata:()=>pt.KP,calculateNeighborhoodStats:()=>Vt,calculateSpacingBetweenImageIds:()=>kt.A,calculateViewportsSpatialRegistration:()=>Ie,calibratedPixelSpacingMetadataProvider:()=>T,clamp:()=>S.A,clip:()=>Pt,color:()=>s,colormap:()=>rt,convertStackToVolumeViewport:()=>$e,convertToGrayscale:()=>Qe,convertVolumeToStackViewport:()=>qe,createLinearRGBTransferFunction:()=>g.A,createSigmoidRGBTransferFunction:()=>c.A,createSubVolume:()=>Ut,decimate:()=>Ne.A,deepClone:()=>yt.G,deepEqual:()=>gt,deepMerge:()=>De.A,eventListener:()=>i,fnv1aHash:()=>mt.A,generateVolumePropsFromImageIds:()=>Fe.D,genericMetadataProvider:()=>Le.A,getBufferConfiguration:()=>He.h,getClosestImageId:()=>M.A,getClosestStackImageIndexForPoint:()=>me,getCurrentVolumeViewportSlice:()=>pe,getDynamicVolumeInfo:()=>Dt,getImageDataMetadata:()=>vt.T,getImageLegacy:()=>xe,getImageSliceDataForVolumeViewport:()=>ce.A,getMinMax:()=>p,getPixelSpacingInformation:()=>Bt,getRandomSampleFromArray:()=>tt,getRuntimeId:()=>C,getScalingParameters:()=>Ae.A,getSliceRange:()=>le.A,getSpacingInNormalDirection:()=>y.A,getTargetVolumeAndSpacingInNormalDir:()=>x.A,getViewportImageCornersInWorld:()=>Ce,getViewportImageIds:()=>et,getViewportModality:()=>Ht,getViewportsWithImageURI:()=>ge,getViewportsWithVolumeId:()=>O.A,getVoiFromSigmoidRGBTransferFunction:()=>h.A,getVolumeActorCorners:()=>P.A,getVolumeDirectionVectors:()=>Ot,getVolumeId:()=>it.A,getVolumeSliceRangeInfo:()=>se.A,getVolumeViewportScrollInfo:()=>re.A,getVolumeViewportsContainingSameVolumes:()=>U,hasFloatScalingParameters:()=>at.a,hasNaNValues:()=>_e.A,imageIdToURI:()=>b.A,imageRetrieveMetadataProvider:()=>Ve.A,imageToWorldCoords:()=>oe,indexWithinDimensions:()=>R,invertRgbTransferFunction:()=>d.A,isEqual:()=>D.n4,isEqualAbs:()=>D.Ph,isEqualNegative:()=>D.WC,isImageActor:()=>he.e,isOpposite:()=>A,isPTPrescaledWithSUV:()=>$,isValidVolume:()=>Ue,isVideoTransferSyntax:()=>Be,jumpToSlice:()=>Lt,loadImageToCanvas:()=>J,logger:()=>Nt,makeVolumeMetadata:()=>Re.A,planar:()=>ue,pointInShapeCallback:()=>ot.ii,renderToCanvasCPU:()=>Y,renderToCanvasGPU:()=>j,roundNumber:()=>Je,roundToPrecision:()=>Xe,scaleArray:()=>Mt,scaleRgbTransferFunction:()=>u,scroll:()=>Rt,snapFocalPointToSlice:()=>de.A,sortImageIdsAndGetSpacing:()=>Pe.A,spatialRegistrationMetadataProvider:()=>Ee,splitImageIdsBy4DTags:()=>St,transferFunctionUtils:()=>lt,transformIndexToWorld:()=>N.A,transformWorldToIndex:()=>k.A,transformWorldToIndexContinuous:()=>k.p,triggerEvent:()=>m.A,updateVTKImageDataWithCornerstoneImage:()=>Oe.J,uuidv4:()=>v.A,windowLevel:()=>st,worldToImageCoords:()=>ae});var i={};n.r(i),n.d(i,{MultiTargetEventListenerManager:()=>l,TargetEventListeners:()=>r});var a={};n.r(a),n.d(a,{DefaultHistoryMemo:()=>ie,HistoryMemo:()=>ne});var o,s={};n.r(s),n.d(s,{hexToRgb:()=>ht,rgbToHex:()=>ct}),function(e){e[e.None=0]="None",e[e.Capture=1]="Capture",e[e.Bubble=2]="Bubble"}(o||(o={}));class r{constructor(e){this._eventListeners=new Map,this._children=new Map,this._target=e}get isEmpty(){return 0===this._eventListeners.size&&0===this._children.size}addEventListener(e,t,n){const i=e.indexOf(".");if(-1!==i){const a=e.substring(0,i);let o=this._children.get(a);o||(o=new r(this._target),this._children.set(a,o)),e=e.substring(i+1),o.addEventListener(e,t,n)}else this._addEventListener(e,t,n)}removeEventListener(e,t,n){const i=e.indexOf(".");if(-1!==i){const a=e.substring(0,i),o=this._children.get(a);if(!o)return;e=e.substring(i+1),o.removeEventListener(e,t,n),o.isEmpty&&this._children.delete(a)}else this._removeEventListener(e,t,n)}reset(){Array.from(this._children.entries()).forEach((([e,t])=>{if(t.reset(),!t.isEmpty)throw new Error("Child is not empty and cannot be removed");this._children.delete(e)})),this._unregisterAllEvents()}_addEventListener(e,t,n){let i=this._eventListeners.get(e);i||(i=new Map,this._eventListeners.set(e,i));const a=n?.capture??!1?o.Capture:o.Bubble,s=i.get(t)??o.None;s&a?console.warn("A listener is already registered for this phase"):(i.set(t,s|a),this._target.addEventListener(e,t,n))}_removeEventListener(e,t,n){const i=n?.capture??!1?o.Capture:o.Bubble,a=this._eventListeners.get(e);if(!a)return;(t?[t]:Array.from(a.keys())).forEach((t=>{const s=a.get(t)??o.None;if(!!!(s&i))return;this._target.removeEventListener(e,t,n);const r=s^i;r===o.None?a.delete(t):a.set(t,r)})),a.size||this._eventListeners.delete(e)}_unregisterAllListeners(e,t){Array.from(t.entries()).forEach((([t,n])=>{for(let i=o.Capture;n;i<<=1){if(!(n&i))continue;const a=i===o.Capture;this.removeEventListener(e,t,{capture:a}),n^=i}}))}_unregisterAllEvents(){Array.from(this._eventListeners.entries()).forEach((([e,t])=>{this._unregisterAllListeners(e,t)}))}}class l{constructor(){this._targetsEventListeners=new Map}addEventListener(e,t,n,i){let a=this._targetsEventListeners.get(e);a||(a=new r(e),this._targetsEventListeners.set(e,a)),a.addEventListener(t,n,i)}removeEventListener(e,t,n,i){const a=this._targetsEventListeners.get(e);a&&(a.removeEventListener(t,n,i),a.isEmpty&&this._targetsEventListeners.delete(e))}reset(){Array.from(this._targetsEventListeners.entries()).forEach((([e,t])=>{t.reset(),this._targetsEventListeners.delete(e)}))}}var d=n(50134),c=n(40256),h=n(70210),g=n(74657);function u(e,t){const n=e.getSize();for(let i=0;i<n;i++){const n=[];e.getNodeValue(i,n),n[1]=n[1]*t,n[2]=n[2]*t,n[3]=n[3]*t,e.setNodeValue(i,n)}}var m=n(69372),v=n(80221);function p(e){let t,n=e[0],i=e[0];const a=e.length;for(let o=1;o<a;o++)t=e[o],n=Math.min(n,t),i=Math.max(i,t);return{min:n,max:i}}const f=Symbol("LastRuntimeId"),w={},E=4294967295,I="-";function C(e,t,n){return function(e,t,n){let i=e[t];i instanceof Array||(i=[0],Object.defineProperty(e,t,{value:i}));for(let e=!0,t=0;e&&t<i.length;++t){let a=0|i[t];a<n?(e=!1,a+=1):(a=0,t+1===i.length&&i.push(0)),i[t]=a}return i}(null!==e&&"object"==typeof e?e:w,f,("number"==typeof n&&n>0?n:E)>>>0).join("string"==typeof t?t:I)}var b=n(39537);const _={},T={add:(e,t)=>{const n=(0,b.A)(e);_[n]=t},get:(e,t)=>{if("calibratedPixelSpacing"===e){const e=(0,b.A)(t);return _[e]}}};var S=n(84061),D=n(74638);function A(e,t,n=1e-5){return Math.abs(e[0]+t[0])<n&&Math.abs(e[1]+t[1])<n&&Math.abs(e[2]+t[2])<n}var M=n(88619),y=n(85008),x=n(65292),P=n(15105);function R(e,t){return!(e[0]<0||e[0]>=t[0]||e[1]<0||e[1]>=t[1]||e[2]<0||e[2]>=t[2])}var L=n(39536);const U=function(e,t){let n;n=t?[(0,L.lD)(t)]:(0,L.qO)();const i=[];return n.forEach((t=>{const n=e.getActors(),a=t.getVolumeViewports();for(const e of a){const t=e.getActors();if(t.length!==n.length)continue;n.every((({uid:e})=>t.find((t=>e===t.uid))))&&i.push(e)}})),i};var O=n(24724),k=n(38669),N=n(94741),V=n(80068),W=n(74876),B=n(71851),H=n(51159),F=n(3823),G=n(30135),z=n(56706);const $=e=>e.preScale.scaled&&e.preScale.scalingParameters.suvbw;function j(e,t,n=void 0,i="_thumbnails",a={displayArea:{imageArea:[1,1]}}){if(!(e&&e instanceof HTMLCanvasElement))throw new Error("canvas element is required");const o=!t.imageId,s=!o&&t,r=o&&t,l=`renderGPUViewport-${s.imageId||r.volumeId}`,d=document.createElement("div"),c=window.devicePixelRatio||1;a.displayArea||(a.displayArea={imageArea:[1,1]});const h=e.width,g=e.height;d.style.width=`${h/c+G.p8}px`,d.style.height=`${g/c+G.p8}px`,d.style.visibility="hidden",d.style.position="absolute",document.body.appendChild(d);const u=l.split(":").join("-");d.setAttribute("viewport-id-for-remove",u);const m=(0,G.Ay)(d),v=(0,L.lD)(i)||new z.Ay(i);let p=v.getViewport(l);if(!p){const e={viewportId:l,type:o?B.ViewportType.ORTHOGRAPHIC:B.ViewportType.STACK,element:d,defaultOptions:{...a,suppressEvents:!0}};v.enableElement(e),p=v.getViewport(l)}return new Promise((i=>{let h=!1,{viewReference:g}=a;const f=t=>{if(h)return;if(g){const e=g;return g=null,p.setViewReference(e),void p.render()}e.getContext("2d").drawImage(m,0,0,m.width,m.height,0,0,e.width,e.height);const n=p.canvasToWorld([0,0]),a=p.canvasToWorld([m.width/c,0]),o=p.canvasToWorld([0,m.height/c]),s=F.eR.sub([0,0,0],p.canvasToWorld([1/c,0]),n),r=F.eR.sub([0,0,0],p.canvasToWorld([0,1/c]),n);h=!0,d.removeEventListener(B.Events.IMAGE_RENDERED,f),setTimeout((()=>{v.disableElement(l);document.querySelectorAll(`[viewport-id-for-remove="${u}"]`).forEach((e=>{e.remove()}))}),0),i({origin:n,bottomLeft:o,topRight:a,thicknessMm:1,rightVector:s,downVector:r})};d.addEventListener(B.Events.IMAGE_RENDERED,f),o?p.setVolumes([r],!1,!0):p.renderImageObject(t),p.resetCamera(),"PT"!==n||$(s)||p.setProperties({voiRange:{lower:s.minPixelValue,upper:s.maxPixelValue}}),p.render()}))}var q=n(36931),K=n(7808),Z=n(5057);function Y(e,t,n,i,a){if(t.volumeId)throw new Error("Unsupported volume rendering for CPU");const o=t,s={canvas:e,viewport:(0,q.A)(e,o,n),image:o,renderingTools:{}};s.transform=(0,K.A)(s);return new Promise(((e,t)=>{(0,Z.A)(s,true),e(null)}))}var X=n(49038);function J(e){const{canvas:t,imageId:n,viewReference:i,requestType:a=B.RequestType.Thumbnail,priority:o=-5,renderingEngineId:s="_thumbnails",useCPURendering:r=!1,thumbnail:l=!1,imageAspect:d=!1,viewportOptions:c}=e,h=i?.volumeId,g=h&&!n,u=i&&c?{...c,viewReference:i}:c,m=r?Y:j;return new Promise(((e,i)=>{function c(n,a){const{modality:o}=W.get("generalSeriesModule",a)||{},c=!g&&n,h=g&&n;c&&(c.isPreScaled=c.isPreScaled||c.preScale?.scaled),l&&(t.height=256,t.width=256),d&&c&&(t.width=c&&t.height*c.width/c.height),t.style.width=t.width/devicePixelRatio+"px",t.style.height=t.height/devicePixelRatio+"px",h&&r&&i(new Error("CPU rendering of volume not supported")),m(t,n,o,s,u).then(e)}function v(e,t){console.error(e,t),i(e)}const p={useRGBA:!!r,requestType:a};if(h){const e=X.Ay.getVolume(h);e||i(new Error(`Volume id ${h} not found in cache`));c(e,e.imageIds[0])}else H.A.addRequest(function(e,t,n){return(0,V.loadAndCacheImage)(e,n).then((t=>{c.call(this,t,e)}),(t=>{v.call(this,t,e)}))}.bind(null,n,null,p),a,{imageId:n},o)}))}var Q=n(10364);const ee="CORNERSTONE_TOOLS_HISTORY_UNDO",te="CORNERSTONE_TOOLS_HISTORY_REDO";class ne{constructor(e="Tools",t=50){this.position=-1,this.redoAvailable=0,this.undoAvailable=0,this.ring=new Array,this.label=e,this._size=t}get size(){return this._size}set size(e){this.ring=new Array(e),this._size=e,this.position=-1,this.redoAvailable=0,this.undoAvailable=0}undo(e=1){for(;e>0&&this.undoAvailable>0;){const t=this.ring[this.position];t.restoreMemo(!0),t.id&&Q.A.dispatchEvent(new CustomEvent(ee,{detail:{isUndo:!0,id:t.id,operationType:t.operationType||"annotation",memo:t}})),e--,this.redoAvailable++,this.undoAvailable--,this.position=(this.position-1+this.size)%this.size}}undoIf(e){return!!(this.undoAvailable>0&&e(this.ring[this.position]))&&(this.undo(),!0)}redo(e=1){for(;e>0&&this.redoAvailable>0;){const t=(this.position+1)%this.size,n=this.ring[t];n.restoreMemo(!1),n.id&&Q.A.dispatchEvent(new CustomEvent(te,{detail:{isUndo:!1,id:n.id,operationType:n.operationType||"annotation",memo:n}})),e--,this.position=t,this.undoAvailable++,this.redoAvailable--}}push(e){if(!e)return;const t=e.restoreMemo?e:e.createMemo?.();return t?(this.redoAvailable=0,this.undoAvailable<this._size&&this.undoAvailable++,this.position=(this.position+1)%this._size,this.ring[this.position]=t,t):void 0}}const ie=new ne;const ae=function(e,t){const n=(0,W.get)("imagePlaneModule",e);if(!n)throw new Error(`No imagePlaneModule found for imageId: ${e}`);const{columnCosines:i,rowCosines:a,imagePositionPatient:o}=n;let{columnPixelSpacing:s,rowPixelSpacing:r}=n;s||=1,r||=1;const l=F.eR.create();F.eR.scaleAndAdd(l,o,i,-s/2),F.eR.scaleAndAdd(l,l,a,-r/2);const d=F.eR.create();return F.eR.sub(d,t,l),[F.eR.dot(d,a)/r,F.eR.dot(d,i)/s]};function oe(e,t){const n=(0,W.get)("imagePlaneModule",e);if(!n)throw new Error(`No imagePlaneModule found for imageId: ${e}`);const{columnCosines:i,rowCosines:a,imagePositionPatient:o}=n;let{columnPixelSpacing:s,rowPixelSpacing:r}=n;s||=1,r||=1;const l=F.eR.create();return F.eR.scaleAndAdd(l,o,a,r*(t[0]-.5)),F.eR.scaleAndAdd(l,l,i,s*(t[1]-.5)),Array.from(l)}var se=n(4031),re=n(61375),le=n(20537),de=n(80500),ce=n(47476),he=n(98039);function ge(e){const t=(0,L.qO)(),n=[];return t.forEach((t=>{t.getViewports().forEach((t=>{t.hasImageURI(e)&&n.push(t)}))})),n}var ue=n(52268);function me(e,t){const n=function(e,t){const n=t.getImageIds(),i=t.getCurrentImageIdIndex();if(0===n.length)return null;const a=t=>{const n=function(e){const t=W.get("imagePlaneModule",e);if(!(t&&t.rowCosines instanceof Array&&3===t.rowCosines.length&&t.columnCosines instanceof Array&&3===t.columnCosines.length&&t.i