UNPKG

modified-dicom-pacs

Version:

A modified version of DICOM PACS implementation

1 lines 90.3 kB
"use strict";(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([[473],{52454:(e,t,n)=>{n.d(t,{A:()=>d});var o=n(92136),i=n(44753),a=n(28062),r=n(48428),s=n(21009),c=n(38296),l=n(54177);class u extends a.A{constructor(e,t){super(e,t),this.mouseMoveCallback=(e,t)=>{if(!t)return!1;const{element:n,currentPoints:o}=e.detail,i=o.canvas;let a=!1;for(const e of t){if((0,r.isAnnotationLocked)(e)||!(0,s.isAnnotationVisible)(e.annotationUID))continue;const{data:t}=e,o=t.handles?t.handles.activeHandleIndex:void 0,c=this._imagePointNearToolOrHandle(n,e,i,6),l=c&&!e.highlighted,u=!c&&e.highlighted;l||u?(e.highlighted=!e.highlighted,a=!0):t.handles&&t.handles.activeHandleIndex!==o&&(a=!0)}return a},e.configuration?.getTextLines&&(this.configuration.getTextLines=e.configuration.getTextLines),e.configuration?.statsCalculator&&(this.configuration.statsCalculator=e.configuration.statsCalculator)}static createAnnotation(...e){let t={annotationUID:null,highlighted:!0,invalidated:!0,metadata:{toolName:this.toolName},data:{text:"",handles:{points:new Array,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}},label:""}};for(const n of e)t=o.utilities.deepMerge(t,n);return t}static createAnnotationForViewport(e,...t){return this.createAnnotation({metadata:e.getViewReference()},...t)}static createAndAddAnnotation(e,...t){const n=this.createAnnotationForViewport(e,...t);(0,c.addAnnotation)(n,e.element),(0,l.XF)(n,e.element)}getHandleNearImagePoint(e,t,n,a){const r=(0,o.getEnabledElement)(e),{viewport:s}=r,{data:c}=t,{isCanvasAnnotation:l}=c,{points:u,textBox:d}=c.handles;if(d){const{worldBoundingBox:e}=d;if(e){const t={topLeft:s.worldToCanvas(e.topLeft),topRight:s.worldToCanvas(e.topRight),bottomLeft:s.worldToCanvas(e.bottomLeft),bottomRight:s.worldToCanvas(e.bottomRight)};if(n[0]>=t.topLeft[0]&&n[0]<=t.bottomRight[0]&&n[1]>=t.topLeft[1]&&n[1]<=t.bottomRight[1])return c.handles.activeHandleIndex=null,d}}for(let e=0;e<u?.length;e++){const t=u[e],o=l?t.slice(0,2):s.worldToCanvas(t);if(!0===i.Zc.distance(n,o)<a)return c.handles.activeHandleIndex=e,t}c.handles.activeHandleIndex=null}getLinkedTextBoxStyle(e,t){return{visibility:this.getStyle("textBoxVisibility",e,t),fontFamily:this.getStyle("textBoxFontFamily",e,t),fontSize:this.getStyle("textBoxFontSize",e,t),color:this.getStyle("textBoxColor",e,t),shadow:this.getStyle("textBoxShadow",e,t),background:this.getStyle("textBoxBackground",e,t),lineWidth:this.getStyle("textBoxLinkLineWidth",e,t),lineDash:this.getStyle("textBoxLinkLineDash",e,t)}}isSuvScaled(e,t,n){if(e instanceof o.BaseVolumeViewport){const e=o.utilities.getVolumeId(t),n=o.cache.getVolume(e);return void 0!==n.scaling?.PT}const i=n&&o.metaData.get("scalingModule",n);return"number"==typeof i?.suvbw}getAnnotationStyle(e){const{annotation:t,styleSpecifier:n}=e,o=e=>this.getStyle(e,n,t),{annotationUID:i}=t,a=(0,s.isAnnotationVisible)(i),c=(0,r.isAnnotationLocked)(t),l=o("lineWidth"),u=o("lineDash"),d=o("color");return{visibility:a,locked:c,color:d,lineWidth:l,lineDash:u,lineOpacity:1,fillColor:d,fillOpacity:0,shadow:o("shadow"),textbox:this.getLinkedTextBoxStyle(n,t)}}_imagePointNearToolOrHandle(e,t,n,o){if(this.getHandleNearImagePoint(e,t,n,o))return!0;return!!this.isPointNearTool(e,t,n,o,"mouse")||void 0}}u.toolName="AnnotationTool";const d=u},44350:(e,t,n)=>{n.d(t,{A:()=>a,J:()=>i});const o={renderOutline:!0,outlineWidthActive:3,outlineWidthInactive:2,activeSegmentOutlineWidthDelta:0,renderFill:!0,renderFillInactive:!0,fillAlpha:.7,fillAlphaInactive:.65,outlineOpacity:1,outlineOpacityInactive:.85};function i(e){return e&&"boolean"==typeof e.renderOutline&&"number"==typeof e.outlineWidthActive&&"number"==typeof e.outlineWidthInactive&&"number"==typeof e.activeSegmentOutlineWidthDelta&&"boolean"==typeof e.renderFill&&"boolean"==typeof e.renderFillInactive&&"number"==typeof e.fillAlpha&&"number"==typeof e.fillAlphaInactive&&"number"==typeof e.outlineOpacity&&"number"==typeof e.outlineOpacityInactive}const a=function(){return o}},41209:(e,t,n)=>{n.d(t,{A:()=>a});var o=n(92136),i=n(28117);class a{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 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 o=this.framesToString(t);return e.replace(this.frameRangeExtractor,`${n[1]}${o}`)}static setFrameRange(e,t,n){const{referencedImageId:a}=e.metadata;e.metadata.referencedImageId=this.framesToImageId(a,t);const r={...n,annotation:e};(0,o.triggerEvent)(o.eventTarget,i.A.ANNOTATION_MODIFIED,r)}static getFrameRange(e){return this.imageIdToFrames(e.metadata.referencedImageId)}}},42290:(e,t,n)=>{n.d(t,{A:()=>o});const o=function(e,t){const n=e.findIndex((([e,t])=>e===t));if(-1===n)throw new Error("3D bounding boxes not supported in an oblique plane");return e[n][0]-=t,e[n][1]+=t,e}},14471:(e,t,n)=>{n.d(t,{C:()=>s,g:()=>r});var o=n(92136);const{EPSILON:i}=o.CONSTANTS;function a(e,t,n=!1){let o=1/0,a=n?-1/0:0,r=1/0,s=n?-1/0:0,c=1/0,l=n?-1/0:0;const u=3===e[0]?.length;for(let t=0;t<e.length;t++){const n=e[t];o=Math.min(n[0],o),a=Math.max(n[0],a),r=Math.min(n[1],r),s=Math.max(n[1],s),u&&(c=Math.min(n[2]??c,c),l=Math.max(n[2]??l,l))}return t?(o=Math.max(n?t[0]+i:0,o),a=Math.min(n?t[0]-i:t[0]-1,a),r=Math.max(n?t[1]+i:0,r),s=Math.min(n?t[1]-i:t[1]-1,s),u&&3===t.length&&(c=Math.max(n?t[2]+i:0,c),l=Math.min(n?t[2]-i:t[2]-1,l))):n||(o=Math.max(0,o),a=Math.min(1/0,a),r=Math.max(0,r),s=Math.min(1/0,s),u&&(c=Math.max(0,c),l=Math.min(1/0,l))),u?[[o,a],[r,s],[c,l]]:[[o,a],[r,s],null]}function r(e,t){return a(e,t,!1)}function s(e,t){return a(e,t,!0)}},15306:(e,t,n)=>{n.r(t),n.d(t,{extend2DBoundingBoxInViewAxis:()=>o.A,getBoundingBoxAroundShape:()=>i.g,getBoundingBoxAroundShapeIJK:()=>i.g,getBoundingBoxAroundShapeWorld:()=>i.C});var o=n(42290),i=n(14471)},17167:(e,t,n)=>{n.d(t,{A:()=>a});var o=n(92136);const{calibratedPixelSpacingMetadataProvider:i}=o.utilities;function a(e,t,n){"number"==typeof n&&(n={type:o.Enums.CalibrationTypes.USER,scale:n}),i.add(e,n);t.getStackViewports().forEach((t=>{t.getImageIds().includes(e)&&t.calibrateSpacing(e)}))}},60001:(e,t,n)=>{n.r(t),n.d(t,{Events:()=>r,addToolState:()=>c,getToolState:()=>l,playClip:()=>h,stopClip:()=>p});var o,i=n(44753),a=n(92136);!function(e){e.CLIP_STOPPED="CORNERSTONE_CINE_TOOL_STOPPED",e.CLIP_STARTED="CORNERSTONE_CINE_TOOL_STARTED"}(o||(o={}));const r=o,s={};function c(e,t){const n=(0,a.getEnabledElement)(e),{viewportId:o}=n;s[o]=t}function l(e){const t=(0,a.getEnabledElement)(e),{viewportId:n}=t;return s[n]}var u=n(21783);const{ViewportStatus:d}=a.Enums,{triggerEvent:g}=a.utilities,m=!0,f=new Map;function h(e,t){let n,o;if(void 0===e)throw new Error("playClip: element must not be undefined");const s=(0,a.getEnabledElement)(e);if(!s)throw new Error("playClip: element must be a valid Cornerstone enabled element");t||(t={}),t.dynamicCineEnabled=t.dynamicCineEnabled??!0;const{viewport:h}=s,p=w(h),E=function(e,t){if(e instanceof a.StackViewport)return function(e,t){const n=e.getImageIds();return{get numScrollSteps(){return n.length},get currentStepIndex(){return e.getTargetImageIdIndex()},get frameTimeVectorEnabled(){return!0},waitForRenderedCount:0,scroll(n){this.waitForRenderedCount<=t&&e.viewportStatus!==d.RENDERED?this.waitForRenderedCount++:(this.waitForRenderedCount=0,(0,u.A)(e,{delta:n,debounceLoading:m}))}}}(e,t.waitForRendered??30);if(e instanceof a.VolumeViewport){const n=w(e);return t.dynamicCineEnabled&&n?.isDynamicVolume()?function(e){return{get numScrollSteps(){return e.numTimePoints},get currentStepIndex(){return e.timePointIndex},get frameTimeVectorEnabled(){return!1},scroll(t){e.timePointIndex+=t}}}(n):function(e,t){const{volumeId:n}=t,o={viewPlaneNormal:i.eR.create(),scrollInfo:null},r=()=>{const t=e.getCamera();if(!o.scrollInfo||!i.eR.equals(t.viewPlaneNormal,o.viewPlaneNormal)){const i=a.utilities.getVolumeViewportScrollInfo(e,n);o.viewPlaneNormal=t.viewPlaneNormal,o.scrollInfo=i}return o.scrollInfo};return{get numScrollSteps(){return r().numScrollSteps},get currentStepIndex(){return r().currentStepIndex},get frameTimeVectorEnabled(){const n=e.getCamera(),o=t.direction.slice(6,9).map((e=>-e)),a=i.eR.dot(o,n.viewPlaneNormal);return i.Fd.equals(a,1)},scroll(t){r().currentStepIndex+=t,(0,u.A)(e,{delta:t})}}}(e,n)}throw new Error("Unknown viewport type")}(h,t);let A=l(e);const S=t.dynamicCineEnabled&&p?.isDynamicVolume();if(S&&I(e),A?v(e,{stopDynamicCine:!S,viewportId:h.id}):(A={intervalId:void 0,framesPerSecond:30,lastFrameTimeStamp:void 0,ignoreFrameTimeVector:!1,usingFrameTimeVector:!1,frameTimeVector:t.frameTimeVector??void 0,speed:t.frameTimeVectorSpeedMultiplier??1,reverse:t.reverse??!1,loop:t.loop??!0},c(e,A)),A.dynamicCineEnabled=t.dynamicCineEnabled,(t.framesPerSecond<0||t.framesPerSecond>0)&&(A.framesPerSecond=Number(t.framesPerSecond),A.reverse=A.framesPerSecond<0,A.ignoreFrameTimeVector=!0),!0!==A.ignoreFrameTimeVector&&A.frameTimeVector&&A.frameTimeVector.length===E.numScrollSteps&&E.frameTimeVectorEnabled){const{timeouts:e,isTimeVarying:t}=function(e,t){let n,o,i,a=0;const r=e.length,s=[];let c=!1;("number"!=typeof t||t<=0)&&(t=1);for(n=1;n<r;n++)i=Number(e[n])/t|0,s.push(i),1===n?o=i:i!==o&&(c=!0),a+=i;s.length>0&&(i=c?a/s.length|0:s[0],s.push(i));return{timeouts:s,isTimeVarying:c}}(A.frameTimeVector,A.speed);n=e,o=t}const R=()=>{const{numScrollSteps:t,currentStepIndex:n}=E;let o=n+(A.reverse?-1:1);const i=o<0||o>=t;if(!A.loop&&i){v(e,{stopDynamicCine:!S,viewportId:h.id});const t={element:e};return void g(e,r.CLIP_STOPPED,t)}o>=t?o=0:o<0&&(o=t-1);const a=o-n;a&&E.scroll(a)};S&&f.set(p.volumeId,e),n&&n.length>0&&o?(A.usingFrameTimeVector=!0,A.intervalId=window.setTimeout((function e(){A.intervalId=window.setTimeout(e,n[E.currentStepIndex]),R()}),0)):(A.usingFrameTimeVector=!1,A.intervalId=window.setInterval(R,1e3/Math.abs(A.framesPerSecond)));const M={element:e};g(e,r.CLIP_STARTED,M)}function p(e,t={}){v(e,{stopDynamicCine:!0,...t})}function v(e,t={stopDynamicCine:!0,viewportId:void 0}){const{stopDynamicCine:n,viewportId:o}=t,i=(0,a.getEnabledElement)(e);let r;if(i){const{viewport:e}=i;r=l(e.element)}else{if(!o)return;r=function(e){return s[e]}(o)}r&&function(e){const t=e.intervalId;void 0!==t&&(e.intervalId=void 0,e.usingFrameTimeVector?clearTimeout(t):clearInterval(t))}(r),n&&i?.viewport instanceof a.BaseVolumeViewport&&I(e)}function I(e){const{viewport:t}=(0,a.getEnabledElement)(e),n=w(t);if(n?.isDynamicVolume()){const t=f.get(n.volumeId);f.delete(n.volumeId),t&&t!==e&&p(t)}}function w(e){const t=function(e){return e.getActors().map((e=>a.cache.getVolume(e.uid))).filter((e=>!!e))}(e);return t.find((e=>e.isDynamicVolume()))??t[0]}},88484:(e,t,n)=>{function o(e,t,n){return Math.min(Math.max(t,e),n)}n.d(t,{Ay:()=>i});const i=o},32415:(e,t,n)=>{n.d(t,{V:()=>i});var o=n(30322);function i(e){if(e.parentAnnotationUID)return;if(!e.data.segmentation)throw new Error("addContourSegmentationAnnotation: annotation does not have a segmentation data");const{segmentationId:t,segmentIndex:n}=e.data.segmentation,i=(0,o.getSegmentation)(t);i.representationData.CONTOUR||(i.representationData.CONTOUR={annotationUIDsMap:new Map});const{annotationUIDsMap:a}=i.representationData.CONTOUR;let r=a.get(n);r||(r=new Set,a.set(n,r)),a.set(n,r.add(e.annotationUID))}},3030:(e,t,n)=>{function o(e,t){const{segmentation:n}=e.data,{segmentation:o}=t.data;return n.segmentationId===o.segmentationId&&n.segmentIndex===o.segmentIndex}n.d(t,{A:()=>o})},84354:(e,t,n)=>{function o(e){return!!e.data?.segmentation}n.d(t,{A:()=>o})},78170:(e,t,n)=>{n.d(t,{M:()=>i});var o=n(63421);function i(e){if(!e.data.segmentation)throw new Error("removeContourSegmentationAnnotation: annotation does not have a segmentation data");const{segmentationId:t,segmentIndex:n}=e.data.segmentation,i=o.state.getSegmentation(t),{annotationUIDsMap:a}=i?.representationData.CONTOUR||{},r=a?.get(n);r&&(r.delete(e.annotationUID),r.size||a.delete(n))}},93712:(e,t,n)=>{n.d(t,{A:()=>a});var o=n(69405);class i{constructor(){}static{this.TOOL_NAMES={}}static convert(e,t,n){!function(e){if(!e?.data)throw new Error("Tool data is empty");if(!e.metadata||e.metadata.referenceImageId)throw new Error("Tool data is not associated with any imageId")}(e);const{toolName:o}=e.metadata,a=i.TOOL_NAMES[o];if(!a)throw new Error(`Unknown tool type: ${o}, cannot convert to RTSSReport`);const r=a.getContourSequence(e,n);return{ReferencedROINumber:t+1,ROIDisplayColor:[Math.floor(255*Math.random()),Math.floor(255*Math.random()),Math.floor(255*Math.random())],ContourSequence:r}}static register(e){i.TOOL_NAMES[e.toolName]=e}}i.register(o.A);const a=i},14633:(e,t,n)=>{n.d(t,{A:()=>i});var o=n(44753);function i(e,t){const{viewPlaneNormal:n}=e.metadata,{viewPlaneNormal:i}=t.metadata,a=o.eR.dot(n,i);if(!o.Fd.equals(1,Math.abs(a)))return!1;const{polyline:r}=e.data.contour,{polyline:s}=t.data.contour,c=o.eR.dot(n,r[0]),l=o.eR.dot(n,s[0]);return o.Fd.equals(c,l)}},53891:(e,t,n)=>{n.d(t,{A:()=>o});const o=function(e,t){let n=0;for(let t=0;t<e.length-1;t++){const o=e[t],i=e[t+1];n+=Math.sqrt(Math.pow(i[0]-o[0],2)+Math.pow(i[1]-o[1],2))}if(t){const t=e[0],o=e[e.length-1];n+=Math.sqrt(Math.pow(o[0]-t[0],2)+Math.pow(o[1]-t[1],2))}return n}},11716:(e,t,n)=>{function o(e,t,n){let i=-1;if(t.forEach(((t,n)=>{i>=0||t.a==e.b&&(i=n)})),i>=0){const e=t[i];return t.splice(i,1),n.push(e.b),n[0]==e.b?{remainingLines:t,contourPoints:n,type:"CLOSED_PLANAR"}:o(e,t,n)}return{remainingLines:t,contourPoints:n,type:"OPEN_PLANAR"}}function i(e){if(0==e.length)return[];const t=[],n=e.shift();t.push(n.a),t.push(n.b);const a=o(n,e,t);if(0==a.remainingLines.length)return[{type:a.type,contourPoints:a.contourPoints}];{const e=i(a.remainingLines);return e.push({type:a.type,contourPoints:a.contourPoints}),e}}function a(e){return i(e)}n.d(t,{Ay:()=>r,d1:()=>a});const r={findContours:i,findContoursFromReducedSet:a}},92806:(e,t,n)=>{n.d(t,{A:()=>i});const o=(e,t)=>{const n=e[0],o=e[1];let i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){const r=t[e][0],s=t[e][1],c=t[a][0],l=t[a][1];s>o!=l>o&&n<(c-r)*(o-s)/(l-s)+r&&(i=!i)}return i};const i={processContourHoles:function(e,t,n=!0){const i=e.filter((e=>"CLOSED_PLANAR"!==e.type)),a=e.filter((e=>"CLOSED_PLANAR"===e.type)),r=[];let s=[];return a.forEach(((e,n)=>{const i=[];a.forEach(((a,r)=>{n!=r&&function(e,t,n){const i=[];e.contourPoints.forEach((e=>{i.push([n[e][0],n[e][1]])}));let a=0;return t.contourPoints.forEach((e=>{o([n[e][0],n[e][1]],i)||a++})),0===a}(e,a,t)&&i.push(r)})),i.length>0?r.push({contour:e,holes:i}):s.push(n)})),n&&(r.forEach((e=>{e.contour.type="CLOSEDPLANAR_XOR",i.push(e.contour),e.holes.forEach((e=>{a[e].type="CLOSEDPLANAR_XOR",i.push(a[e]),s=s.filter((t=>t!==e))}))})),s.forEach((e=>{i.push(a[e])}))),i}}},84045:(e,t,n)=>{n.d(t,{A:()=>r});var o=n(92136),i=n(44753);const{isEqual:a}=o.utilities;function r(e,t){const{polyline:n}=e.data.contour,{points:o}=e.data.handles,{length:r}=o;if(t===r)return n.length;if(t<0&&(t=(t+r)%r),0===t)return 0;const s=o[t],c=n.findIndex((e=>a(s,e)));if(-1!==c)return c;let l=1/0;return n.reduce(((e,t,n)=>{const o=i.eR.squaredDistance(t,s);return o<l?(l=o,n):e}),-1)}},36392:(e,t,n)=>{n.d(t,{d:()=>d});var o=n(92136),i=n(52754),a=n(45128),r=n(51250),s=n(75534),c=n(11716),l=n(83946);const{Labelmap:u}=l.A;function d({segmentations:e}){const{representationData:t,segments:n=[0,1]}=e,{volumeId:l}=t[u],d=o.cache.getVolume(l);if(!d)return void console.warn(`No volume found for ${l}`);const m=d.dimensions[2],f=d.imageData.getPointData().getScalars().getData(),h=d.dimensions[0]*d.dimensions[1];for(let e=0;e<m;e++)for(let t=0;t<d.dimensions[1];t++){const n=t*d.dimensions[0]+e*h;f[n]=0,f[n+d.dimensions[0]-1]=0}const p=[],{FrameOfReferenceUID:v}=d.metadata,I=n.length;for(let e=0;e<I;e++){const t=n[e];if(!t)continue;const o=[],l=a.Ay.newInstance({name:"Scalars",numberOfComponents:1,size:h*m,dataType:"Uint8Array"}),{containedSegmentIndices:u}=t;for(let t=0;t<m;t++){if(g(t,f,h,e))continue;const n=t*h;try{for(let t=0;t<h;t++){const o=f[t+n];o===e||u?.has(o)?l.setValue(t+n,1):l.setValue(t,0)}const a=i.Ay.newInstance({slice:t}),g=r.Ay.newInstance();g.shallowCopy(d.imageData),g.getPointData().setScalars(l),a.setInputData(g);const m=[1];a.setContourValues(m),a.setMergePoints(!1);const p=a.getOutputData(),I=(0,s.getDeduplicatedVTKPolyDataPoints)(p);if(I.points?.length){const e=(0,c.d1)(I.lines);o.push({contours:e,polyData:I,FrameNumber:t+1,sliceIndex:t,FrameOfReferenceUID:v})}}catch(e){console.warn(t),console.warn(e)}}const I={FrameOfReferenceUID:v},w={label:t.label,color:t.color,metadata:I,sliceContours:o};p.push(w)}return p}function g(e,t,n,o){const i=e*n,a=i+n;for(let e=i;e<a;e++)if(t[e]===o)return!1;return!0}},88267:(e,t,n)=>{n.d(t,{A:()=>i});var o=n(98043);function i(e,t){const n=(0,o.A)(e),i=[];return n.forEach((e=>{const n=e.length,o=new Array(n);for(let i=0;i<n;i++)o[i]=t.worldToCanvas(e[i]);i.push(o)})),i}},98043:(e,t,n)=>{n.d(t,{A:()=>i});var o=n(95778);function i(e){return(e.childAnnotationUIDs??[]).map((e=>(0,o.gw)(e).data.contour.polyline))}},19866:(e,t,n)=>{function o(e,t=!1){const n=e.getPoints(),o=e.getLines(),i=new Array(n.getNumberOfPoints()).fill(0).map(((e,t)=>n.getPoint(t).slice())),a=new Array(o.getNumberOfCells()).fill(0).map(((e,t)=>{const n=o.getCell(3*t).slice();return{a:n[0],b:n[1]}}));if(t)return{points:i,lines:a};const r=[];for(const[e,t]of i.entries()){const n=r.findIndex((e=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]));if(n>=0)a.map((t=>(t.a===e&&(t.a=n),t.b===e&&(t.b=n),t)));else{const n=r.length;r.push(t),a.map((t=>(t.a===e&&(t.a=n),t.b===e&&(t.b=n),t)))}}return{points:r,lines:a.filter((e=>e.a!==e.b))}}n.d(t,{v:()=>o})},65864:(e,t,n)=>{n.d(t,{A:()=>i});var o=n(33836);function i(e,t){o.A.acceptAutoGenerated(e,t)}},69115:(e,t,n)=>{n.r(t),n.d(t,{InterpolationManager:()=>o.A});var o=n(33836)},89111:(e,t,n)=>{n.d(t,{A:()=>r});var o=n(92136),i=n(73047),a=n(95778);function r(e,t,n,r){const{canvasToWorld:s}=n,{data:c}=e,{targetWindingDirection:l}=t;let{points:u}=t;r?.decimate?.enabled&&(u=i.polyline.decimate(t.points,r?.decimate?.epsilon));let{closed:d}=t;const g=u.length,m=new Array(g),f=i.polyline.getWindingDirection(u),h=(0,a.Ay)(e);if(void 0===d){let e=!1;if(u.length>3){const t=i.point.distanceToPointSquared(u[0],u[g-1]);e=o.utilities.isEqual(0,t)}d=e}let p=h?-1*h.data.contour.windingDirection:l;void 0===p?p=f:p!==f&&u.reverse();for(let e=0;e<g;e++)m[e]=s(u[e]);c.contour.polyline=m,c.contour.closed=d,c.contour.windingDirection=p,(0,a.zH)(e)}},64857:(e,t,n)=>{n.d(t,{A:()=>i});var o=n(11857);const i=function(e,t,n){let i,a,r,s,c,l,u=0,d=!1,g=!1,m=!0;const f=!t&&0!==t&&"function"==typeof window.requestAnimationFrame;if("function"!=typeof e)throw new TypeError("Expected a function");function h(t){const n=i,o=a;return i=a=void 0,u=t,s=e.apply(o,n),s}function p(e,t){return f?window.requestAnimationFrame(e):setTimeout(e,t)}function v(e){const n=e-l;return void 0===l||n>=t||n<0||g&&e-u>=r}function I(){const e=Date.now();if(v(e))return w(e);c=p(I,function(e){const n=e-u,o=t-(e-l);return g?Math.min(o,r-n):o}(e))}function w(e){return c=void 0,m&&i?h(e):(i=a=void 0,s)}function E(...e){const n=Date.now(),o=v(n);if(i=e,a=this,l=n,o){if(void 0===c)return function(e){return u=e,c=p(I,t),d?h(e):s}(l);if(g)return c=p(I,t),h(l)}return void 0===c&&(c=p(I,t)),s}return t=Number(t)||0,(0,o.A)(n)&&(d=Boolean(n.leading),g="maxWait"in n,r=g?Math.max(Number(n.maxWait)||0,t):r,m="trailing"in n?Boolean(n.trailing):m),E.cancel=function(){void 0!==c&&function(e){if(f)return window.cancelAnimationFrame(e);clearTimeout(e)}(c),u=0,i=l=a=c=void 0},E.flush=function(){return void 0===c?s:w(Date.now())},E.pending=function(){return void 0!==c},E}},10910:(e,t,n)=>{function o(e){const t=function(e){const t=[e[0],e[1]].sort(r),n=[e[0],e[1]].sort(s),o=t[t.length-1],i=n[0],a=n[n.length-1];return{top:i,bottom:a,right:o};function r(e,t){return e[0]<t[0]?-1:1}function s(e,t){return e[1]<t[1]?-1:1}}(e),n=(t.top[1]+t.bottom[1])/2;return[t.right[0],n]}n.r(t),n.d(t,{getTextBoxCoordsCanvas:()=>o})},16390:(e,t,n)=>{n.r(t),n.d(t,{generateImageFromTimeData:()=>s,getDataInTime:()=>r});var o=n(92136),i=n(77071),a=n(75403);const r=function(e,t){const n=t.frameNumbers||[...Array(e.numTimePoints).keys()];if(!t.maskVolumeId&&!t.imageCoordinate)throw new Error("You should provide either maskVolumeId or imageCoordinate");if(t.maskVolumeId&&t.imageCoordinate)throw new Error("You can only use one of maskVolumeId or imageCoordinate");if(t.maskVolumeId){const r=o.cache.getVolume(t.maskVolumeId),[s,c]=function(e,t,n){const{imageData:o}=n,r=n.getScalarData(),s=r.length,c=[];c.length=s;const l=[],u=n.dimensions;let d=0;for(let e=0,t=r.length;e<t;e++)0!==r[e]&&(l.push([e%u[0],Math.floor(e/u[0]%u[1]),Math.floor(e/(u[0]*u[1]))]),c[d++]=e);c.length=d;const g=t.getScalarDataArrays(),m=[],f=g[0].length===s&&JSON.stringify(t.spacing)===JSON.stringify(n.spacing);if(f){for(let t=0;t<c.length;t++){const n=[];e.forEach((e=>{const o=g[e];n.push(o[c[t]])})),m.push(n)}return[m,l]}const h=({pointLPS:n,value:o,pointIJK:r})=>{if(0===o)return;const s=(0,i.Q5)(t.imageData,t.dimensions,t.spacing,n);let c=0;const u=new Map;e.forEach((e=>u.set(e,0)));const d=({index:t})=>{for(let n=0;n<e.length;n++){const o=g[n][t],i=e[n];u.set(i,u.get(i)+o)}c++};(0,a.A)(t.imageData,(()=>!0),d,s);const f=[];u.forEach((e=>{f.push(e/c)})),l.push(r),m.push(f)};return(0,a.A)(o,(()=>!0),h),[m,l]}(n,e,r);return[s,c]}if(t.imageCoordinate){const i=function(e,t,n){const{dimensions:i,imageData:a}=n,r=a.worldToIndex(t);if(r[0]=Math.floor(r[0]),r[1]=Math.floor(r[1]),r[2]=Math.floor(r[2]),!o.utilities.indexWithinDimensions(r,i))throw new Error("outside bounds");const s=i[0],c=i[0]*i[1],l=n.getScalarDataArrays(),u=[];return e.forEach((e=>{const t=l[e],n=r[2]*c+r[1]*s+r[0];u.push(t[n])})),u}(n,t.imageCoordinate,e);return i}};const s=function(e,t,n){const i=n||[...Array(e.numTimePoints).keys()],a=i.length;if(i.length<=1)throw new Error("Please provide two or more time points");const r=e.getScalarDataArrays(),s=r[0].length,c=new Float32Array(s);if(t===o.Enums.DynamicOperatorType.SUM){for(let e=0;e<a;e++){const t=r[i[e]];for(let e=0;e<s;e++)c[e]+=t[e]}return c}if(t===o.Enums.DynamicOperatorType.SUBTRACT){if(i.length>2)throw new Error("Please provide only 2 time points for subtraction.");for(let e=0;e<s;e++)c[e]+=r[i[0]][e]-r[i[1]][e];return c}if(t===o.Enums.DynamicOperatorType.AVERAGE){for(let e=0;e<a;e++){const t=r[i[e]];for(let e=0;e<s;e++)c[e]+=t[e]}for(let e=0;e<s;e++)c[e]=c[e]/a;return c}}},66429:(e,t,n)=>{n.d(t,{S:()=>r,s:()=>s});var o=n(92136),i=n(38296),a=n(52610);function r(e,t,n=5){const i=(0,o.getEnabledElement)(e);if(!i)throw new Error("getAnnotationNearPoint: enabledElement not found");return s(i,t,n)}function s(e,t,n){const{renderingEngineId:o,viewportId:i}=e,r=a.getToolGroupForViewport(i,o);if(!r)return null;const{_toolInstances:s}=r;for(const o in s){const i=c(s[o],e,t,n);if(i)return i}return null}function c(e,t,n,o){const{viewport:a}=t,r=(0,i.getAnnotations)(e.constructor.toolName,a?.element),s=a?.getCurrentImageId?.();if(r?.length){const{element:i}=t.viewport;for(const t of r){const a=t.metadata?.referencedImageId;if(!(s&&a&&s!==a||!e.isPointNearTool)&&(e.isPointNearTool(i,t,n,o,"")||e.getHandleNearImagePoint(i,t,n,o)))return t}}return null}},24592:(e,t,n)=>{n.d(t,{CQ:()=>m,Op:()=>d,Xw:()=>g});var o=n(92136);const{CalibrationTypes:i}=o.Enums,a="px",r=[1],s=["3,3"],c=["4,3"],l={3:"cm",4:"seconds"},u="²",d=(e,t)=>{const{calibration:n,hasPixelSpacing:c}=e;let l=c?"mm":a,d=l+u,g=1,m="";if(!n||!n.type&&!n.sequenceOfUltrasoundRegions)return{units:l,areaUnits:d,scale:g};if(n.type===i.UNCALIBRATED)return{units:a,areaUnits:a+u,scale:g};if(n.sequenceOfUltrasoundRegions){let e,i;if(Array.isArray(t)&&2===t.length)[e,i]=t;else if("function"==typeof t){const n=t();e=n[0],i=n[1]}let c=n.sequenceOfUltrasoundRegions.filter((t=>e[0]>=t.regionLocationMinX0&&e[0]<=t.regionLocationMaxX1&&e[1]>=t.regionLocationMinY0&&e[1]<=t.regionLocationMaxY1&&i[0]>=t.regionLocationMinX0&&i[0]<=t.regionLocationMaxX1&&i[1]>=t.regionLocationMinY0&&i[1]<=t.regionLocationMaxY1));if(!c?.length)return{units:l,areaUnits:d,scale:g};if(c=c.filter((e=>r.includes(e.regionDataType)&&s.includes(`${e.physicalUnitsXDirection},${e.physicalUnitsYDirection}`))),!c.length)return{units:a,areaUnits:a+u,scale:g};const f=c[0],h=Math.abs(f.physicalDeltaX),p=Math.abs(f.physicalDeltaY);if(!o.utilities.isEqual(h,p,.001))return{units:a,areaUnits:a+u,scale:g};g=1/(10*h),m="US Region",l="mm",d="mm²"}else n.scale&&(g=n.scale);return[i.ERMF,i.USER,i.ERROR,i.PROJECTION].includes(n?.type)&&(m=n.type),{units:l+(m?` ${m}`:""),areaUnits:d+(m?` ${m}`:""),scale:g}},g=(e,t)=>{const[n]=t,{calibration:o}=e;let i=["raw"],a=[null],s="";if(!o||!o.type&&!o.sequenceOfUltrasoundRegions)return{units:i,values:a};if(o.sequenceOfUltrasoundRegions){const e=o.sequenceOfUltrasoundRegions.filter((e=>r.includes(e.regionDataType)&&c.includes(`${e.physicalUnitsXDirection},${e.physicalUnitsYDirection}`)));if(!e?.length)return{units:i,values:a};const t=e.find((e=>n[0]>=e.regionLocationMinX0&&n[0]<=e.regionLocationMaxX1&&n[1]>=e.regionLocationMinY0&&n[1]<=e.regionLocationMaxY1));if(!t)return{units:i,values:a};const{referencePixelX0:u=0,referencePixelY0:d=0}=t,{physicalDeltaX:g,physicalDeltaY:m}=t,f=(n[1]-t.regionLocationMinY0-d)*m;s="US Region",a=[(n[0]-t.regionLocationMinX0-u)*g,f],i=[l[t.physicalUnitsXDirection],l[t.physicalUnitsYDirection]]}return{units:i,values:a,calibrationType:s}},m=e=>e.calibration?.aspect||1},96760:(e,t,n)=>{n.d(t,{R:()=>s});var o=n(92136),i=n(44753),a=n(15306);const{transformWorldToIndex:r}=o.utilities;function s(e,t,n){const[o,s]=e,c=i.eR.fromValues((o[0]+s[0])/2,(o[1]+s[1])/2,(o[2]+s[2])/2),l=i.eR.distance(o,s)/2;if(!n)throw new Error("viewport is required in order to calculate the sphere bounds");const{boundsIJK:u,topLeftWorld:d,bottomRightWorld:g}=function(e,t,n,o,s){const[c,l]=n,u=e.getDimensions(),d=t.getCamera(),g=i.eR.fromValues(d.viewUp[0],d.viewUp[1],d.viewUp[2]),m=i.eR.fromValues(d.viewPlaneNormal[0],d.viewPlaneNormal[1],d.viewPlaneNormal[2]),f=i.eR.create();i.eR.cross(f,g,m);const h=i.eR.create(),p=i.eR.create();i.eR.scaleAndAdd(h,l,m,s),i.eR.scaleAndAdd(p,c,m,-s),i.eR.scaleAndAdd(h,h,f,-s),i.eR.scaleAndAdd(p,p,f,s);const v=r(e,h),I=r(e,p),w=n.map((t=>r(e,t))),E=(0,a.getBoundingBoxAroundShapeIJK)([v,I,...w],u);return{boundsIJK:E,topLeftWorld:h,bottomRightWorld:p}}(t,n,e,0,l);return{boundsIJK:u,centerWorld:c,radiusWorld:l,topLeftWorld:d,bottomRightWorld:g}}},39490:(e,t,n)=>{n.d(t,{A:()=>i});var o=n(65903);function i(e){const t=(0,o.A)(e);return t.length?t[0]:void 0}},11857:(e,t,n)=>{n.d(t,{A:()=>o});const o=function(e){const t=typeof e;return null!==e&&("object"===t||"function"===t)}},27924:(e,t,n)=>{function o(e,t){return e.minX<=t.maxX&&e.maxX>=t.minX&&e.minY<=t.maxY&&e.maxY>=t.minY}function i(e,t){const n=e.maxX-e.minX,o=e.maxY-e.minY,i=[n,o],a=[e.minX+n/2,e.minY+o/2],r=[Math.abs(t[0]-a[0]),Math.abs(t[1]-a[1])],s=r[0]-.5*i[0],c=r[1]-.5*i[1];if(s>0&&c>0)return s*s+c*c;const l=Math.max(s,0)+Math.max(c,0);return l*l}function a(e,t){return Math.sqrt(i(e,t))}n.r(t),n.d(t,{distanceToPoint:()=>a,distanceToPointSquared:()=>i,intersectAABB:()=>o})},83112:(e,t,n)=>{n.r(t),n.d(t,{BasicStatsCalculator:()=>i,Calculator:()=>o});const o=class{};class i extends o{static{this.max=[-1/0]}static{this.sum=[0]}static{this.sumSquares=[0]}static{this.squaredDiffSum=[0]}static{this.count=0}static{this.statsCallback=({value:e})=>{Array.isArray(e)&&e.length>1&&1===this.max.length&&(this.max.push(this.max[0],this.max[0]),this.sum.push(this.sum[0],this.sum[0]),this.sumSquares.push(this.sumSquares[0],this.sumSquares[0]),this.squaredDiffSum.push(this.squaredDiffSum[0],this.squaredDiffSum[0]));const t=Array.isArray(e)?e:[e];this.count+=1,this.max.forEach(((e,n)=>this.max[n]=Math.max(e,t[n]))),this.sum.map(((e,n)=>this.sum[n]+=t[n])),this.sumSquares.map(((e,n)=>this.sumSquares[n]+=t[n]**2)),this.squaredDiffSum.map(((e,n)=>this.squaredDiffSum[n]+=Math.pow(t[n]-this.sum[n]/this.count,2)))}}static{this.getStatistics=()=>{const e=this.sum.map((e=>e/this.count)),t=this.squaredDiffSum.map((e=>Math.sqrt(e/this.count))),n=this.sumSquares.map(((t,n)=>Math.sqrt(this.sumSquares[n]/this.count-e[n]**2))),o={max:{name:"max",label:"Max Pixel",value:a(this.max),unit:null},mean:{name:"mean",label:"Mean Pixel",value:a(e),unit:null},stdDev:{name:"stdDev",label:"Standard Deviation",value:a(t),unit:null},stdDevWithSumSquare:{name:"stdDevWithSumSquare",value:a(n),unit:null},count:{name:"count",label:"Pixel Count",value:this.count,unit:null},array:[]};return o.array.push(o.max,o.mean,o.stdDev,o.stdDevWithSumSquare,o.count),this.max=[-1/0],this.sum=[0],this.sumSquares=[0],this.squaredDiffSum=[0],this.count=0,o}}}function a(e){return 1===e.length?e[0]:e}},2264:(e,t,n)=>{function o(e,t,n={}){return n.precalculated||i(e,n),n.precalculated(t)}n.r(t),n.d(t,{getCanvasEllipseCorners:()=>a,pointInEllipse:()=>o,precalculatePointInEllipse:()=>i});const i=(e,t={})=>{const{xRadius:n,yRadius:o,zRadius:i}=e;void 0!==t.invXRadiusSq&&void 0!==t.invYRadiusSq&&void 0!==t.invZRadiusSq||(t.invXRadiusSq=0!==n?1/n**2:0,t.invYRadiusSq=0!==o?1/o**2:0,t.invZRadiusSq=0!==i?1/i**2:0);const{invXRadiusSq:a,invYRadiusSq:r,invZRadiusSq:s}=t,{center:c}=e,[l,u,d]=c;return t.precalculated=e=>{const t=e[0]-l;let n=t*t*a;if(n>1)return!1;const o=e[1]-u;if(n+=o*o*r,n>1)return!1;const i=e[2]-d;return n+=i*i*s,n<=1},t};function a(e){const[t,n,o,i]=e;return[[o[0],n[1]],[i[0],t[1]]]}},21954:(e,t,n)=>{n.r(t),n.d(t,{distanceToPoint:()=>r,distanceToPointSquared:()=>a,distanceToPointSquaredInfo:()=>i,intersectLine:()=>c,isPointOnLineSegment:()=>u});var o=n(73047);function i(e,t,n){let i;const a=o.point.distanceToPointSquared(e,t);if(e[0]===t[0]&&e[1]===t[1]&&(i=e),!i){const o=((n[0]-e[0])*(t[0]-e[0])+(n[1]-e[1])*(t[1]-e[1]))/a;i=o<0?e:o>1?t:[e[0]+o*(t[0]-e[0]),e[1]+o*(t[1]-e[1])]}return{point:[...i],distanceSquared:o.point.distanceToPointSquared(n,i)}}function a(e,t,n){return i(e,t,n).distanceSquared}function r(e,t,n){if(2!==e.length||2!==t.length||2!==n.length)throw Error("lineStart, lineEnd, and point should have 2 elements of [x, y]");return Math.sqrt(a(e,t,n))}function s(e){return"number"==typeof e?e?e<0?-1:1:e==e?0:NaN:NaN}function c(e,t,n,o){const[i,a]=e,[r,c]=t,[l,u]=n,[d,g]=o,m=c-a,f=i-r,h=r*a-i*c,p=m*l+f*u+h,v=m*d+f*g+h;if(0!==p&&0!==v&&s(p)===s(v))return;const I=g-u,w=l-d,E=d*u-l*g,A=I*i+w*a+E,S=I*r+w*c+E;if(0!==A&&0!==S&&s(A)===s(S))return;const R=m*w-I*f;let M;M=f*E-w*h;const T=M/R;M=I*h-m*E;return[T,M/R]}const l=.01;function u(e,t,n){const o=e[0]<=t[0]?e[0]:t[0],i=e[0]>=t[0]?e[0]:t[0],a=e[1]<=t[1]?e[1]:t[1],r=e[1]>=t[1]?e[1]:t[1];if(!(n[0]>=o-l&&n[0]<=i+l&&n[1]>=a-l&&n[1]<=r+l))return!1;const s=(t[1]-e[1])*(n[0]-t[0])-(t[0]-e[0])*(n[1]-t[1]);return(s>=0?s:-s)<=l}},38566:(e,t,n)=>{n.d(t,{A:()=>i});var o=n(14257);function i(e,t){return Math.sqrt((0,o.A)(e,t))}},14257:(e,t,n)=>{function o(e,t){if(e.length!==t.length)throw Error("Both points should have the same dimensionality");const[n,o,i=0]=e,[a,r,s=0]=t,c=a-n,l=r-o,u=s-i;return c*c+l*l+u*u}n.d(t,{A:()=>o})},49131:(e,t,n)=>{function o(e,t){const[n,o]=e,[i,a]=t;return[2*i-n,2*a-o]}n.d(t,{A:()=>o})},56634:(e,t,n)=>{n.r(t),n.d(t,{addCanvasPointsToArray:()=>F,containsPoint:()=>r,containsPoints:()=>s,decimate:()=>L,getAABB:()=>c.A,getArea:()=>l,getClosestLineSegmentIntersection:()=>_,getFirstLineSegmentIntersectionIndexes:()=>P,getLineSegmentIntersectionsCoordinates:()=>O,getLineSegmentIntersectionsIndexes:()=>I,getNormal2:()=>m,getNormal3:()=>g,getSignedArea:()=>u,getSubPixelSpacingAndXYDirections:()=>q,getWindingDirection:()=>d,intersectPolyline:()=>C,isClosed:()=>a,isPointInsidePolyline3D:()=>j,mergePolylines:()=>y,pointCanProjectOnLine:()=>B,pointsAreWithinCloseContourProximity:()=>U,projectTo2D:()=>G,subtractPolylines:()=>D});var o=n(44753),i=n(73047);function a(e){if(e.length<3)return!1;const t=e.length,n=e[0],a=e[t-1],r=i.point.distanceToPointSquared(n,a);return o.Fd.equals(0,r)}function r(e,t,n={closed:void 0}){if(e.length<3)return!1;const o=e.length;let i=0;const{closed:s,holes:c}=n;if(c?.length)for(const e of c)if(r(e,t))return!1;const l=!(void 0===s?a(e):s),u=e.length-(l?1:2);for(let n=0;n<=u;n++){const a=e[n],r=e[n===o-1?0:n+1],s=a[0]>=r[0]?a[0]:r[0],c=a[1]>=r[1]?a[1]:r[1],l=a[1]<=r[1]?a[1]:r[1];if(t[0]<=s&&t[1]>=l&&t[1]<c){let e=a[0]===r[0];if(!e){const n=(t[1]-a[1])*(r[0]-a[0])/(r[1]-a[1])+a[0];e=t[0]<=n}i+=e?1:0}}return!!(i%2)}function s(e,t){for(let n=0,o=t.length;n<o;n++)if(!r(e,t[n]))return!1;return!0}var c=n(86970);function l(e){const t=e.length;let n=0,o=t-1;for(let i=0;i<t;i++)n+=(e[o][0]+e[i][0])*(e[o][1]-e[i][1]),o=i;return Math.abs(n/2)}function u(e){if(e.length<3)return 0;const t=e[0];let n=0;for(let o=0,i=e.length;o<i;o++){const a=e[o],r=e[o===i-1?0:o+1],s=a[0]-t[0],c=a[1]-t[1],l=r[0]-t[0];n+=s*(r[1]-t[1])-c*l}return n*=.5,n}function d(e){return u(e)>=0?1:-1}function g(e){const t=function(e){const t=o.eR.create(),n=e[0];for(let o=0,i=e.length;o<i;o++){const a=e[o],r=e[o===i-1?0:o+1],s=a[0]-n[0],c=a[1]-n[1],l=a[2]-n[2],u=r[0]-n[0],d=r[1]-n[1],g=r[2]-n[2];t[0]+=c*g-l*d,t[1]+=l*u-s*g,t[2]+=s*d-c*u}return o.eR.scale(t,t,.5),t}(e);return o.eR.normalize(t,t)}function m(e){const t=u(e);return[0,0,t/Math.abs(t)]}var f=n(14846);function h(e,t,n,o){let i=!1;const a=e[0]<t[0]?e[0]:t[0],r=e[1]<t[1]?e[1]:t[1],s=e[0]>t[0]?e[0]:t[0],c=e[1]>t[1]?e[1]:t[1],l=n[0]<o[0]?n[0]:o[0],u=n[1]<o[1]?n[1]:o[1],d=n[0]>o[0]?n[0]:o[0],g=n[1]>o[1]?n[1]:o[1];if(a>d||s<l||r>g||c<u)return!1;const m=[p(e,t,n),p(e,t,o),p(n,o,e),p(n,o,t)];return m[0]!==m[1]&&m[2]!==m[3]||((0===m[0]&&v(e,n,t)||0===m[1]&&v(e,o,t)||0===m[2]&&v(n,e,o)||0===m[3]&&v(n,t,o))&&(i=!0),i)}function p(e,t,n){const o=(t[1]-e[1])*(n[0]-t[0])-(t[0]-e[0])*(n[1]-t[1]);return 0===o?0:o>0?1:2}function v(e,t,n){return t[0]<=Math.max(e[0],n[0])&&t[0]>=Math.min(e[0],n[0])&&t[1]<=Math.max(e[1],n[1])&&t[1]>=Math.min(e[1],n[1])}function I(e,t,n,o=!0){const i=[],a=e.length,r=a-(o?1:2);for(let o=0;o<=r;o++){const r=o===a-1?0:o+1;h(t,n,e[o],e[r])&&i.push([o,r])}return i}var w=n(21954);const E=.01;function A(e,t,n,o){const i=[t[0]-e[0],t[1]-e[1]],a=[o[0]-n[0],o[1]-n[1]],r=a[1]*i[0]-a[0]*i[1];if((r>=0?r:-r)<E){const i=[e[0]<t[0]?e[0]:t[0],e[0]>t[0]?e[0]:t[0],e[1]<t[1]?e[1]:t[1],e[1]>t[1]?e[1]:t[1]],a=[n[0]<o[0]?n[0]:o[0],n[0]>o[0]?n[0]:o[0],n[1]<o[1]?n[1]:o[1],n[1]>o[1]?n[1]:o[1]];if(!(i[0]<=a[1]&&i[1]>=a[0]&&i[2]<=a[3]&&i[3]>=a[2]))return;if(!(w.isPointOnLineSegment(e,t,n)||w.isPointOnLineSegment(e,t,o)||w.isPointOnLineSegment(n,o,e)))return;return[.5*((i[0]>a[0]?i[0]:a[0])+(i[1]<a[1]?i[1]:a[1])),.5*((i[2]>a[2]?i[2]:a[2])+(i[3]<a[3]?i[3]:a[3]))]}let s=e[1]-n[1],c=e[0]-n[0];const l=i[0]*s-i[1]*c;s=(a[0]*s-a[1]*c)/r,c=l/r;return[e[0]+s*i[0],e[1]+s*i[1]]}var S,R,M;function T(e){for(let t=0,n=e.length;t<n;t++){const o=e[t];o.next||(o.next=e[t===n-1?0:t+1])}}function b(e,t){const n=[],o=[],i=new Map;let a=r(t,e[0])?M.Exiting:M.Entering;for(let o=0,s=e.length;o<s;o++){const c=e[o],l=r(t,c),u={type:S.Vertex,coordinates:c,position:l?R.Inside:R.Outside,visited:!1,next:null};n.push(u);const d=e[o===s-1?0:o+1],g=I(t,c,d).map((e=>{const n=e[0],o=t[e[0]],i=t[e[1]],a=A(c,d,o,i);return{sourceLineSegmentId:n,coordinate:a,targetStartPointDistSquared:f.distanceToPointSquared(c,a)}}));g.sort(((e,t)=>e.targetStartPointDistSquared-t.targetStartPointDistSquared)),g.forEach((e=>{const{sourceLineSegmentId:t,coordinate:o}=e,r={type:S.Intersection,coordinates:o,position:R.Edge,direction:a,visited:!1,next:null},s={...r,direction:M.Unknown,cloned:!0};a===M.Entering?r.next=s:s.next=r;let c=i.get(t);c||(c=[],i.set(t,c)),n.push(r),c.push(s),a*=-1}))}for(let e=0,n=t.length;e<n;e++){const n=e,a=t[e],r={type:S.Vertex,coordinates:a,visited:!1,next:null};o.push(r);const s=i.get(n);s?.length&&s.map((e=>({intersectionPoint:e,lineSegStartDistSquared:f.distanceToPointSquared(a,e.coordinates)}))).sort(((e,t)=>e.lineSegStartDistSquared-t.lineSegStartDistSquared)).map((({intersectionPoint:e})=>e)).forEach((e=>o.push(e)))}return T(n),T(o),{targetPolylinePoints:n,sourcePolylinePoints:o}}function x(e){for(let t=0,n=e.length;t<n;t++){const n=e[t];if(!n.visited&&n.position===R.Outside)return n}}function y(e,t){const n=m(e),i=m(t),a=o.eR.dot(i,n);o.Fd.equals(1,a)||(t=t.slice().reverse());const{targetPolylinePoints:r}=b(e,t),s=x(r);if(!s)return e.slice();const c=[s.coordinates];let l=s.next;for(;l!==s;)l.type===S.Intersection&&l.cloned||c.push(l.coordinates),l=l.next;return c}function D(e,t){const n=m(e),i=m(t),a=o.eR.dot(i,n);o.Fd.equals(-1,a)||(t=t.slice().reverse());const{targetPolylinePoints:r}=b(e,t);let s=null;const c=[];for(;s=x(r);){const e=[s.coordinates];let t=s.next;for(s.visited=!0;t!==s;)t.visited=!0,t.type===S.Intersection&&t.cloned||e.push(t.coordinates),t=t.next;c.push(e)}return c}function P(e,t,n,o=!0){let i,a;o?(a=e.length-1,i=0):(a=0,i=1);for(let o=i;o<e.length;o++){if(h(t,n,e[a],e[o]))return[a,o];a=o}}function C(e,t){for(let n=0,o=e.length;n<o;n++){const i=P(t,e[n],e[n===o-1?0:n+1]);if(2===i?.length)return!0}return!1}!function(e){e[e.Vertex=0]="Vertex",e[e.Intersection=1]="Intersection"}(S||(S={})),function(e){e[e.Outside=-1]="Outside",e[e.Edge=0]="Edge",e[e.Inside=1]="Inside"}(R||(R={})),function(e){e[e.Exiting=-1]="Exiting",e[e.Unknown=0]="Unknown",e[e.Entering=1]="Entering"}(M||(M={}));const V=.1;function L(e,t=V){const n=e.length;if(n<3)return e;const o=t*t,i=[[0,n-1]],a=new Array(n).fill(!1);let r=2;for(a[0]=!0,a[n-1]=!0;i.length;){const[t,n]=i.pop();if(n-t==1)continue;const s=e[t],c=e[n];let l=-1/0,u=-1;for(let o=t+1;o<n;o++){const t=e[o],n=w.distanceToPointSquared(s,c,t);n>l&&(l=n,u=o)}l<o||(a[u]=!0,r++,i.push([u,n]),i.push([t,u]))}const s=new Array(r);for(let t=0,o=0;t<n;t++)a[t]&&(s[o++]=e[t]);return s}function O(e,t,n,o=!0){const i=[],a=I(e,t,n,o);for(let o=0;o<a.length;o++){const r=A(t,n,e[a[o][0]],e[a[o][1]]);i.push(r)}return i}function _(e,t,n,i=!0){let a,r;i?(r=e.length-1,a=0):(r=0,a=1);const s=[];for(let o=a;o<e.length;o++){const i=e[r],a=e[o];h(t,n,i,a)&&s.push([r,o]),r=o}if(0===s.length)return;const c=[];s.forEach((n=>{const i=[e[n[0]],e[n[1]]],a=[(i[0][0]+i[1][0])/2,(i[0][1]+i[1][1])/2];c.push(o.Zc.distance(a,t))}));const l=Math.min(...c);return{segment:s[c.indexOf(l)],distance:l}}var N=n(92136);const k=.001,q=(e,t)=>{let n,i,a;if(e instanceof N.StackViewport){const t=e.getImageData();i=t.direction.slice(0,3),a=t.direction.slice(3,6),n=t.spacing}else{const t=e.getImageData(),{direction:r,spacing:s}=t,{viewPlaneNormal:c,viewUp:l}=e.getCamera(),u=r.slice(0,3),d=r.slice(3,6),g=r.slice(6,9),m=o.eR.create();o.eR.cross(m,l,c);const f=Math.abs(o.eR.dot(m,u)),h=Math.abs(o.eR.dot(m,d)),p=Math.abs(o.eR.dot(m,g));let v;if(Math.abs(1-f)<k)v=s[0],i=u;else if(Math.abs(1-h)<k)v=s[1],i=d;else{if(!(Math.abs(1-p)<k))throw new Error("No support yet for oblique plane planar contours");v=s[2],i=g}const I=Math.abs(o.eR.dot(l,u)),w=Math.abs(o.eR.dot(l,d)),E=Math.abs(o.eR.dot(l,g));let A;if(Math.abs(1-I)<k)A=s[0],a=u;else if(Math.abs(1-w)<k)A=s[1],a=d;else{if(!(Math.abs(1-E)<k))throw new Error("No support yet for oblique plane planar contours");A=s[2],a=g}n=[v,A]}return{spacing:[n[0]/t,n[1]/t],xDir:i,yDir:a}},U=(e,t,n)=>o.Zc.dist(e,t)<n,F=(e,t,n,i)=>{const{xDir:a,yDir:r,spacing:s}=i,c=(0,N.getEnabledElement)(e),{viewport:l}=c;if(!t.length)return t.push(n),console.log(">>>>> !canvasPoints. :: RETURN"),1;const u=l.canvasToWorld(t[t.length-1]),d=l.canvasToWorld(n),g=o.eR.create();o.eR.subtract(g,d,u);const m=Math.abs(o.eR.dot(g,a)),f=Math.abs(o.eR.dot(g,r)),h=Math.max(Math.floor(m/s[0]),Math.floor(f/s[0]));if(h>1){const e=t[t.length-1],i=o.Zc.dist(e,n),a=o.Zc.create();o.Zc.subtract(a,n,e),o.Zc.set(a,a[0]/i,a[1]/i);const r=i/h;for(let n=1;n<=h;n++)t.push([e[0]+r*a[0]*n,e[1]+r*a[1]*n])}else t.push(n);return h},B=(e,t,n,i)=>{const a=[e[0]-t[0],e[1]-t[1]],r=[n[0]-t[0],n[1]-t[1]],s=a[0]*r[0]+a[1]*r[1];if(s<0)return!1;const c=Math.sqrt(r[0]*r[0]+r[1]*r[1]);if(0===c)return!1;const l=s/c,u=[r[0]/c,r[1]/c],d=[u[0]*l,u[1]*l],g=[t[0]+d[0],t[1]+d[1]];return!(o.Zc.distance(e,g)>i)&&!(o.Zc.distance(t,g)>o.Zc.distance(t,n))},W=1e-6;function G(e){let t;const n=N.utilities.getRandomSampleFromArray(e,50);for(let e=0;e<3;e++)if(n.every(((t,n,o)=>Math.abs(t[e]-o[0][e])<W))){t=e;break}if(void 0===t)throw new Error("Cannot find a shared dimension index for polyline, probably oblique plane");const o=[],i=(t+1)%3,a=(t+2)%3;for(let t=0;t<e.length;t++)o.push([e[t][i],e[t][a]]);return{sharedDimensionIndex:t,projectedPolyline:o}}function j(e,t,n={}){const{sharedDimensionIndex:o,projectedPolyline:i}=G(t),{holes:a}=n,s=[];if(a)for(let e=0;e<a.length;e++){const t=a[e],n=[];for(let e=0;e<t.length;e++)n.push([t[e][(o+1)%3],t[e][(o+2)%3]]);s.push(n)}return r(i,[e[(o+1)%3],e[(o+2)%3]],{holes:s})}},23345:(e,t,n)=>{n.r(t),n.d(t,{distanceToPoint:()=>i});var o=n(21954);function i(e,t){if(4!==e.length||2!==t.length)throw Error("rectangle:[left, top, width, height] or point: [x,y] not defined correctly");const[n,i,a,r]=e;let s=655535;const c=function(e,t,n,o){return{top:[[e,t],[e+n,t]],right:[[e+n,t],[e+n,t+o]],bottom:[[e+n,t+o],[e,t+o]],left:[[e,t+o],[e,t]]}}(n,i,a,r);return Object.keys(c).forEach((e=>{const[n,i]=c[e],a=o.distanceToPoint(n,i,t);a<s&&(s=a)})),s}},19096:(e,t,n)=>{function o(e,t){const{center:n,radius:o}=e,i=e.radius2||o*o;return(t[0]-n[0])*(t[0]-n[0])+(t[1]-n[1])*(t[1]-n[1])+(t[2]-n[2])*(t[2]-n[2])<=i}n.d(t,{d:()=>o})},73100:(e,t,n)=>{n.r(t),n.d(t,{findClosestPoint:()=>o.A,liangBarksyClip:()=>i.A});var o=n(87658),i=n(86981)},86981:(e,t,n)=>{n.d(t,{A:()=>s});const o=1e-6,i=1,a=0;function r(e,t,n){const[i,a]=n;if(Math.abs(t)<o)return e<0;const r=e/t;if(t>0){if(r>a)return 0;r>i&&(n[0]=r)}else{if(r<i)return 0;r<a&&(n[1]=r)}return 1}function s(e,t,n,s,c){const[l,u]=e,[d,g]=t,m=d-l,f=g-u;if(void 0===s||void 0===c?(s=e,c=t):(s[0]=e[0],s[1]=e[1],c[0]=t[0],c[1]=t[1]),Math.abs(m)<o&&Math.abs(f)<o&&l>=n[0]&&l<=n[2]&&u>=n[1]&&u<=n[3])return i;const h=[0,1];if(r(n[0]-l,m,h)&&r(l-n[2],-m,h)&&r(n[1]-u,f,h)&&r(u-n[3],-f,h)){const[e,t]=h;return t<1&&(c[0]=l+t*m,c[1]=u+t*f),e>0&&(s[0]+=e*m,s[1]+=e*f),i}return a}},80393:(e,t,n)=>{function o(e){let t="";const n=e[0]<0?"R":"L",o=e[1]<0?"A":"P",i=e[2]<0?"F":"H",a=[Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2])],r=1e-4;for(let e=0;e<3;e++)if(a[0]>r&&a[0]>a[1]&&a[0]>a[2])t+=n,a[0]=0;else if(a[1]>r&&a[1]>a[0]&&a[1]>a[2])t+=o,a[1]=0;else if(a[2]>r&&a[2]>a[0]&&a[2]>a[1])t+=i,a[2]=0;else if(a[0]>r&&a[1]>r&&a[0]===a[1])t+=n+o,a[0]=0,a[1]=0;else if(a[0]>r&&a[2]>r&&a[0]===a[2])t+=n+i,a[0]=0,a[2]=0;else{if(!(a[1]>r&&a[2]>r&&a[1]===a[2]))break;t+=o+i,a[1]=0,a[2]=0}return t}n.d(t,{A:()=>o})},39365:(e,t,n)=>{function o(e){let t=e.replace("H","f");return t=t.replace("F","h"),t=t.replace("R","l"),t=t.replace("L","r"),t=t.replace("A","p"),t=t.replace("P","a"),t=t.toUpperCase(),t}n.d(t,{A:()=>o})},84797:(e,t,n)=>{n.r(t),n.d(t,{default:()=>c,filterAnnotationsForDisplay:()=>a.A,filterAnnotationsWithinSlice:()=>o.A,getPointInLineOfSightWithCriteria:()=>r.A,getWorldWidthAndHeightFromCorners:()=>i.A,isPlaneIntersectingAABB:()=>s.Y});var o=n(17926),i=n(78609),a=n(65826),r=n(3895),s=n(99706);const c={filterAnnotationsWithinSlice:o.A,getWorldWidthAndHeightFromCorners:i.A,filterAnnotationsForDisplay:a.A,getPointInLineOfSightWithCriteria:r.A,isPlaneIntersectingAABB:s.Y}},44074:(e,t,n)=>{n.r(t),n.d(t,{default:()=>i,smoothAnnotation:()=>o.A});var o=n(14659);const i={smoothAnnotation:o.A}},75403:(e,t,n)=>{n.d(t,{A:()=>i});var o=n(44753);function i(e,t,n,i){let a,r,s,c,l,u,d;const{numComps:g}=e;d=e.getScalarData?e.getScalarData():e.getPointData().getScalars().getData();const m=e.getDimensions();i?[[a,r],[s,c],[l,u]]=i:(a=0,r=m[0],s=0,c=m[1],l=0,u=m[2]);const f=o.eR.fromValues(a,s,l),h=e.getDirection(),p=h.slice(0,3),v=h.slice(3,6),I=h.slice(6,9),w=e.getSpacing(),[E,A,S]=w,R=e.indexToWorld(f),M=o.eR.fromValues(p[0]*E,p[1]*E,p[2]*E),T=o.eR.fromValues(v[0]*A,v[1]*A,v[2]*A),b=o.eR.fromValues(I[0]*S,I[1]*S,I[2]*S),x=g||d.length/m[2]/m[1]/m[0],y=m[0]*x,D=m[1]*y,P=[],C=o.eR.clone(R);for(let e=l;e<=u;e++){const i=o.eR.clone(C);for(let i=s;i<=c;i++){const s=o.eR.clone(C);for(let s=a;s<=r;s++){const a=[s,i,e];if(t(C,a)){const t=e*D+i*y+s*x;let o;o=x>2?[d[t],d[t+1],d[t+2]]:d[t],P.push({value:o,index:t,pointIJK:a,pointLPS:C.slice()}),n&&n({value:o,index:t,pointIJK:a,pointLPS:C})}o.eR.add(C,C,M)}o.eR.copy(C,s),o.eR.add(C,C,T)}o.eR.copy(C,i),o.eR.add(C,C,b)}return P}},5093:(e,t,n)=>{n.d(t,{A:()=>l});var o=n(92136),i=n(44753),a=n(19096),r=n(75403),s=n(15306);const{transformWorldToIndex:c}=o.utilities;function l(e,t,n,o){const{boundsIJK:l,centerWorld:u,radiusWorld:d}=function(e,t,n){const[o,a]=e,r=i.eR.fromValues((o[0]+a[0])/2,(o[1]+a[1])/2,(o[2]+a[2])/2),l=i.eR.distance(o,a)/2;let u;if(!n){const e=c(t,r),n=t.getSpacing(),o=Math.min(...n),i=Math.ceil(l/o);return u=[[e[0]-i,e[0]+i],[e[1]-i,e[1]+i],[e[2]-i,e[2]+i]],{boundsIJK:u,centerWorld:r,radiusWorld:l}}return u=function(e,t,n,o,a){const[r,l]=n,u=e.getDimensions(),d=t.getCamera(),g=i.eR.fromValues(d.viewUp[0],d.viewUp[1],d.viewUp[2]),m=i.eR.fromValues(d.viewPlaneNormal[0],d.viewPlaneNormal[1],d.viewPlaneNormal[2]),f=i.eR.create();i.eR.cross(f,g,m);const h=i.eR.create(),p=i.eR.create();i.eR.scaleAndAdd(h,l,m,a),i.eR.scaleAndAdd(p,r,m,-a),i.eR.scaleAndAdd(h,h,f,-a),i.eR.scaleAndAdd(p,p,f,a);const v=[c(e,h),c(e,p)],I=(0,s.getBoundingBoxAroundShape)(v,u);return I}(t,n,e,0,l),{boundsIJK:u,centerWorld:r,radiusWorld:l}}(t,e,o),g={center:u,radius:d};(0,r.A)(e,(e=>(0,a.d)(g,e)),n,l)}},60438:(e,t,n)=>{function o(e,t=5){return parseFloat(e[0]).toFixed(t)+","+parseFloat(e[1]).toFixed(t)+","+parseFloat(e[2]).toFixed(t)+","}n.d(t,{l:()=>o})},46514:(e,t,n)=>{n.r(t),n.d(t,{getPoint:()=>i,getPolyDataPointIndexes:()=>a,getPolyDataPoints:()=>r});var o=n(44753);function i(e,t){const n=3*t;if(n<e.length)return o.eR.fromValues(e[n],e[n+1],e[n+2])}function a(e){const t=e.getLines().getData();let n=0;const o=new Map;for(;n<t.length;){const e=t[n++],i=[];for(let o=0;o<e;o++)i.push(t[n+o]);o.set(i[0],i),n+=e}const i=[],a=e=>{for(const[t,n]of e.entries())if(void 0!==n)return t;return-1};let r=a(o);for(;-1!==r;){const e=[r];for(;o.has(r);){const t=o.get(r)[1];o.has(t)&&e.push(t),o.delete(r),r=t}i.push(e),r=a(o)}return i.length?i:void 0}function r(e){const t=a(e);if(!t)return;const n=e.getPoints().getData();return t.map((e=>e.map((e=>i(n,e)))))}},89786:(e,t,n)=>{n.d(t,{A:()=>r});var o=n(92136),i=n(14471),a=n(42290);const r=function(e,t,n={}){const r=[];return e.forEach((e=>{const{data:s}=e,{points:c}=s.handles,{imageData:l,dimensions:u}=t;let d=c;if(s.cachedStats?.projectionPoints){const{projectionPoints:e}=s.cachedStats;d=[].concat(...e)}const g=d.map((e=>o.utilities.transformWorldToIndex(l,e)));let m=(0,i.g)(g,u);n.numSlicesToProject&&!s.cachedStats?.projectionPoints&&(m=(0,a.A)(m,n.numSlicesToProject)),r.push(m)})),1===r.length?r[0]:r.reduce(((e,t)=>({iMin:Math.min(e.iMin,t.iMin),jMin:Math.min(e.jMin,t.jMin),kMin:Math.min(e.kMin,t.kMin),iMax:Math.max(e.iMax,t.iMax),jMax:Math.max(e.jMax,t.jMax),kMax:Math.max(e.kMax,t.kMax)})),{iMin:1/0,jMin:1/0,kMin:1/0,iMax:-1/0,jMax:-1/0,kMax:-1/0})}},15874:(e,t,n)=>{n.r(t),n.d(t,{getBoundsIJKFromRectangleAnnotations:()=>o.A,isAxisAlignedRectangle:()=>i.l});var o=n(89786),i=n(81952)},81952:(e,t,n)=>{n.d(t,{l:()=>s});var o=n(44753),i=n(92136);const{isEqual:a}=i.utilities,r=[o.eR.fromValues(1,0,0),o.eR.fromValues(0,1,0),o.eR.fromValues(0,0,1)];function s(e){const t=o.eR.subtract(o.eR.create(),e[0],e[1]),n=o.eR.subtract(o.eR.create(),e[0],e[2]);return[...c(t,r),...c(n,r)].every((e=>a(e,0)||a(e,90)||a(e,180)||a(e,270)))}function c(e,t){return t.map((t=>180*o.eR.angle(e,t)/Math.PI))}},21783:(e,t,n)=>{n.d(t,{A:()=>i});var o=n(92136);function i(e,t){if(!(0,o.getEnabledElement)(e.element))throw new Error("Scroll::Viewport is not enabled (it might be disabled)");if(e instanceof o.StackViewport&&0===e.getImageIds().length)throw new Error("Scroll::Stack Viewport has no images");const{type:n}=e,{volumeId:i,delta:a,scrollSlabs:r}=t;if(e instanceof o.StackViewport)e.scroll(a,t.debounceLoading,t.loop);else if(e instanceof o.VolumeViewport)!function(e,t,n,i=!1){const a=i,{numScrollSteps:r,currentStepIndex:s,sliceRangeInfo:c}=o.utilities.getVolumeViewportScrollInfo(e,t,a);if(!c)return;const{sliceRange:l,spacingInNormalDirection:u,camera:d}=c,{focalPoint:g,viewPlaneNormal:m,position:f}=d,{newFocalPoint:h,newPosition:p}=o.utilities.snapFocalPointToSlice(g,f,l,m,u,n);e.setCamera({focalPoint:h,position:p}),e.render();const v=s+n,I={volumeId:t,viewport:e,delta:n,desiredStepIndex:v,currentStepIndex:s,numScrollSteps:r,currentImageId:e.getCurrentImageId()};(v>r||v<0)&&e.getCurrentImageId()?o.utilities.triggerEvent(o.eventTarget,o.EVENTS.VOLUME_SCROLL_OUT_OF_BOUNDS,I):o.utilities.triggerEvent(o.eventTarget,o.EVENTS.VOLUME_VIEWPORT_SCROLL,I)}(e,i,a,r);else{if(!(e instanceof o.VideoViewport))throw new Error(`Not implemented for Viewport Type: ${n}`);e.scroll(a)}}},33836:(e,t,n)=>{n.d(t,{A:()=>m});var o=n(92136),i=n(45238),a=n(23237),r=n(7727),s=n(20629),c=n(42111),l=n(39490),u=n(32415);const{uuidv4:d}=o.utilities,g=[c.A.HandlesUpdated,c.A.InterpolationUpdated];class m{static{this.toolNames=[]}static addTool(e){this.toolNames.includes(e)||this.toolNames.push(e)}static acceptAutoGenerated(e,t={}){const{toolNames:n,segmentationId:o,segmentIndex:a,sliceIndex:r}=t;for(const t of n||m.toolNames){const n=i.state.getAnnotations(t,e);if(n?.length)for(const e of n){const{interpolationUID:t,data:n,autoGenerated:i,metadata:s}=e;t&&(e.interpolationCompleted=!0),i&&(a&&a!==n.segmentation.segmentIndex||void 0!==r&&s&&r!==s.sliceIndex||o&&o!==n.segmentation.segmentationId||((0,u.V)(e),e.autoGenerated=!1))}}}static{this.handleAnnotationCompleted=e=>{const t=e.detail.annotation;if(!t?