@fnndsc/argus 0.16.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{t as T,E as R,e as M,B as We,v as Ae,a as ne,b as F,s as ke,c as Fe,f as oe,cw as ue,c8 as Ne,bW as P,aK as z,cx as fe,aJ as Y,ag as se,V as G,cy as ge,cz as D,cA as Ue,cB as Ge,cC as Be,bL as He,at as O,aO as ze,bi as B,cD as me,bN as je,cE as he,bt as $e,b_ as qe,cF as ie,cG as E,cH as H,cI as J,cJ as L,cK as re,cL as Je,cM as Ke,cN as Ze,bC as pe,am as Q,b8 as ee,cO as Xe,cP as Ye,ai as Qe,ar as we,bm as te,i as Ie,L as Ve,bK as Se,cQ as be,bA as Z,bG as et,bc as ve,bz as N,cR as ae,cS as Ee,bP as ye,cT as tt,cr as nt,K as ot,cU as st,cV as it,c1 as rt,cW as at,cX as ct,bf as lt,cY as dt,cZ as ut,c_ as ft,c$ as gt,bp as mt,d0 as ht,d1 as pt,d2 as wt,d3 as It,d4 as Vt,d5 as St,d6 as bt,d7 as vt,bg as Et,d8 as yt,av as Rt,d9 as Ct,da as Pt,H as Tt,b7 as xt,bk as Mt,db as Dt,dc as Ot,J as _t,dd as Lt,bo as Wt,de as At,df as kt,bq as Ft,dg as Nt,bs as Ut,dh as Gt,bR as Bt,di as Ht,dj as zt,bF as jt,bj as $t,dk as qt,bh as Jt,bn as Kt,dl as Zt,dm as Xt,dn as Yt,dp as Qt,dq as en,dr as tn,ds as nn,dt as on,bl as sn,bZ as rn,du as an,bT as cn,dv as ln,bS as dn,bv as un,br as fn,ct as gn,dw as mn,dx as hn,bI as pn,dy as wn,M as In,dz as Vn,dA as Sn,bw as bn,dB as vn,bD as En,bJ as yn,dC as Rn,dD as Cn,bM as Pn,dE as Tn,dF as xn,dG as Mn,bY as Dn}from"./Settings-BVnfxRPh.js";import"./Texture-C99vHuBO.js";import"./cornerstoneEngine-CGEzAsx7.js";function On(e){return!!(e&&typeof e.setVolumes=="function"&&typeof e.addVolumes=="function")}async function _n(e,t,n,o=!1,i=!1){const s=n.map(r=>{const a=e.getViewport(r);if(!a)throw new Error(`Viewport with Id ${r} does not exist`);if(!On(a))throw new Error("setVolumesForViewports only supports viewports that implement setVolumes");return a});await Promise.all(s.map(r=>r.setVolumes(t,o,i)))}function Ln(e,t,n=0){const o=e.getOpenGLRenderWindow?.()?.getCanvas?.();o&&(o.addEventListener("webglcontextlost",()=>{console.warn(`CornerstoneRender: WebGL context lost (renderingEngine=${t}, context=${n})`),T(M,R.WEBGL_CONTEXT_LOST,{renderingEngineId:t,contextIndex:n})}),o.addEventListener("webglcontextrestored",()=>{T(M,R.WEBGL_CONTEXT_RESTORED,{renderingEngineId:t,contextIndex:n})}))}class Wn extends We{constructor(t){super(t),this._renderFlaggedViewports=()=>{this._throwIfDestroyed(),this.offscreenMultiRenderWindow&&this.performVtkDrawCall();const n=this._getViewportsAsArray(),o=[];for(let i=0;i<n.length;i++){const s=n[i];if(this._needsRender.has(s.id)){const r=this.renderViewportUsingCustomOrVtkPipeline(s);if(o.push(r),s.setRendered(),this._needsRender.delete(s.id),this._needsRender.size===0)break}}this._animationFrameSet=!1,this._animationFrameHandle=null,o.forEach(i=>{i?.element&&T(i.element,R.IMAGE_RENDERED,i)})},this.useCPURendering||this.ensureOffscreenResources()}ensureOffscreenResources(){this.offscreenMultiRenderWindow||(this.offscreenMultiRenderWindow=Ae.newInstance(),this.offScreenCanvasContainer=document.createElement("div"),this.offscreenMultiRenderWindow.setContainer(this.offScreenCanvasContainer),Ln(this.offscreenMultiRenderWindow,this.id))}enableVTKjsDrivenViewport(t){this.ensureOffscreenResources();const o=this._getViewportsAsArray().filter(l=>ne(l.type)===!1),i=o.map(l=>l.canvas),s=F(t.element);i.push(s);const{offScreenCanvasWidth:r,offScreenCanvasHeight:a}=this._resizeOffScreenCanvas(i),c=this._resize(o,r,a),d={...t,canvas:s};this.addVtkjsDrivenViewport(d,{offScreenCanvasWidth:r,offScreenCanvasHeight:a,xOffset:c})}addVtkjsDrivenViewport(t,n){this.ensureOffscreenResources();const{element:o,canvas:i,viewportId:s,type:r,defaultOptions:a}=t;o.tabIndex=-1,ke(o);const{offScreenCanvasWidth:c,offScreenCanvasHeight:d,xOffset:l}=n,{sxStartDisplayCoords:u,syStartDisplayCoords:f,sxEndDisplayCoords:m,syEndDisplayCoords:w,sx:V,sy:h,sWidth:g,sHeight:b}=this._getViewportCoordsOnOffScreenCanvas(t,c,d,l);this.offscreenMultiRenderWindow.addRenderer({viewport:[u,f,m,w],id:s,background:a.background?a.background:[0,0,0]});const S={id:s,element:o,renderingEngineId:this.id,type:r,canvas:i,sx:V,sy:h,sWidth:g,sHeight:b,defaultOptions:a||{}},v=Fe(t);if(!v)throw new Error(`Viewport Type ${r} is not supported`);const p=new v(S);p.requestedType=t.requestedType??r,this._viewports.set(s,p);const y={element:o,viewportId:s,renderingEngineId:this.id};p.suppressEvents||T(M,R.ELEMENT_ENABLED,y)}setVtkjsDrivenViewports(t){if(t.length){const n=t.map(r=>F(r.element));n.forEach(r=>{const a=window.devicePixelRatio||1,c=r.getBoundingClientRect();r.width=c.width*a,r.height=c.height*a});const{offScreenCanvasWidth:o,offScreenCanvasHeight:i}=this._resizeOffScreenCanvas(n);let s=0;for(let r=0;r<t.length;r++){const a=t[r],c=n[r],d={...a,canvas:c};this.addVtkjsDrivenViewport(d,{offScreenCanvasWidth:o,offScreenCanvasHeight:i,xOffset:s}),s+=c.width}}}_resizeVTKViewports(t,n=!0,o=!0){const i=t.map(s=>F(s.element));if(i.forEach(s=>{const r=window.devicePixelRatio||1;s.width=s.clientWidth*r,s.height=s.clientHeight*r}),i.length){const{offScreenCanvasWidth:s,offScreenCanvasHeight:r}=this._resizeOffScreenCanvas(i);this._resize(t,s,r)}t.forEach(s=>{const r=s.getCamera(),a=s.getRotation(),{flipHorizontal:c}=r,d=s;d.resetViewStateForResize?d.resetViewStateForResize():d.resetCameraForResize();const l=s.getDisplayArea();n&&(l?(c&&s.setCamera({flipHorizontal:c}),a&&s.setViewPresentation({rotation:a})):s.setCamera(r))}),o&&this.render()}performVtkDrawCall(){const{offscreenMultiRenderWindow:t}=this,n=t.getRenderWindow(),o=t.getRenderers();if(o.length){for(let i=0;i<o.length;i++){const{renderer:s,id:r}=o[i],a=r.split("::")[0];this._needsRender.has(a)?s.setDraw(!0):s.setDraw(!1)}n.render();for(let i=0;i<o.length;i++)o[i].renderer.setDraw(!1)}}renderViewportUsingCustomOrVtkPipeline(t){let n;if(t.sWidth<oe||t.sHeight<oe){console.warn("Viewport is too small",t.sWidth,t.sHeight);return}if(ne(t.type)===!0)n=t.customRenderViewportToCanvas();else{if(!this.offscreenMultiRenderWindow)throw new Error("GPU not available, and using a viewport with no custom render pipeline.");const{offscreenMultiRenderWindow:o}=this,r=o.getOpenGLRenderWindow().get3DContext().canvas;n=this._renderViewportFromVtkCanvasToOnscreenCanvas(t,r)}return n}_renderViewportFromVtkCanvasToOnscreenCanvas(t,n){const{element:o,canvas:i,sx:s,sy:r,sWidth:a,sHeight:c,id:d,renderingEngineId:l,suppressEvents:u}=t,{width:f,height:m}=i;return i.getContext("2d").drawImage(n,s,r,a,c,0,0,f,m),{element:o,suppressEvents:u,viewportId:d,renderingEngineId:l,viewportStatus:t.viewportStatus}}_resizeOffScreenCanvas(t){const{offScreenCanvasContainer:n,offscreenMultiRenderWindow:o}=this,i=Math.max(...t.map(r=>r.height));let s=0;return t.forEach(r=>{s+=r.width}),n.width=s,n.height=i,o.resize(),{offScreenCanvasWidth:s,offScreenCanvasHeight:i}}_resize(t,n,o){let i=0;for(let s=0;s<t.length;s++){const r=t[s],{sxStartDisplayCoords:a,syStartDisplayCoords:c,sxEndDisplayCoords:d,syEndDisplayCoords:l,sx:u,sy:f,sWidth:m,sHeight:w}=this._getViewportCoordsOnOffScreenCanvas(r,n,o,i);i+=r.canvas.width,r.sx=u,r.sy=f,r.sWidth=m,r.sHeight=w,this.offscreenMultiRenderWindow.getRenderer(r.id).setViewport(a,c,d,l)}return i}_getViewportCoordsOnOffScreenCanvas(t,n,o,i){const{canvas:s}=t,{width:r,height:a}=s,c=i,d=0,l=c/n,u=d+(o-a)/o,f=r/n,m=a/o;return{sxStartDisplayCoords:l,syStartDisplayCoords:u,sxEndDisplayCoords:l+f,syEndDisplayCoords:u+m,sx:c,sy:d,sWidth:r,sHeight:a}}}function No(e){return!!(e&&typeof e.canvasToWorld=="function"&&typeof e.worldToCanvas=="function")}function Uo(e){return!!(e&&typeof e.getZoom=="function"&&typeof e.setZoom=="function")}function Go(e){return!!(e&&typeof e.getPan=="function"&&typeof e.setPan=="function")}function An(e){return!!(e&&typeof e.getFrameOfReferenceUID=="function")}class kn{constructor(){this._targetsEventListeners=new Map}addEventListener(t,n,o,i){let s=this._targetsEventListeners.get(t);s||(s=new ue(t),this._targetsEventListeners.set(t,s)),s.addEventListener(n,o,i)}removeEventListener(t,n,o,i){const s=this._targetsEventListeners.get(t);s&&(s.removeEventListener(n,o,i),s.isEmpty&&this._targetsEventListeners.delete(t))}reset(){Array.from(this._targetsEventListeners.entries()).forEach(([t,n])=>{n.reset(),this._targetsEventListeners.delete(t)})}}const Fn=Object.freeze(Object.defineProperty({__proto__:null,MultiTargetEventListenerManager:kn,TargetEventListeners:ue},Symbol.toStringTag,{value:"Module"}));function Nn(e,t){const n=e.getSize();for(let o=0;o<n;o++){const i=[];e.getNodeValue(o,i),i[1]=i[1]*t,i[2]=i[2]*t,i[3]=i[3]*t,e.setNodeValue(o,i)}}const Un=Symbol("LastRuntimeId"),Gn={},Bn=4294967295,Hn="-";function zn(e,t,n){return jn(e!==null&&typeof e=="object"?e:Gn,Un,(typeof n=="number"&&n>0?n:Bn)>>>0).join(typeof t=="string"?t:Hn)}function jn(e,t,n){let o=e[t];o instanceof Array||(o=[0],Object.defineProperty(e,t,{value:o}));for(let i=!0,s=0;i&&s<o.length;++s){let r=o[s]|0;r<n?(i=!1,r=r+1):(r=0,s+1===o.length&&o.push(0)),o[s]=r}return o}const $n=Ne;function qn(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}function Jn(e,t){return!(e[0]<0||e[0]>=t[0]||e[1]<0||e[1]>=t[1]||e[2]<0||e[2]>=t[2])}function Kn(e,t){return!(e[0]<-P||e[0]>=t[0]+P||e[1]<-P||e[1]>=t[1]+P||e[2]<-P||e[2]>=t[2]+P)}function Zn(e,t){let n;t?n=[Y(t)]:n=z();const o=[];return n.forEach(i=>{const s=e.getActors(),r=i.getViewports().filter(fe);for(const a of r){const c=a.getActors();if(c.length!==s.length)continue;s.every(({uid:l})=>c.find(u=>l===u.uid))&&o.push(a)}}),o}function Re(e,t,n=void 0,o="_thumbnails",i={displayArea:{imageArea:[1,1]}}){if(!e||!(e instanceof HTMLCanvasElement))throw new Error("canvas element is required");const s=!t.imageId,r=!s&&t,a=s&&t,d=`renderGPUViewport-${r.imageId||a.volumeId}`,l=document.createElement("div"),u=window.devicePixelRatio||1;i.displayArea||(i.displayArea={imageArea:[1,1]});const f=e.width,m=e.height;l.style.width=`${f/u+se}px`,l.style.height=`${m/u+se}px`,l.style.visibility="hidden",l.style.position="absolute",document.body.appendChild(l);const w=d.split(":").join("-");l.setAttribute("viewport-id-for-remove",w);const V=F(l),h=Y(o)||new Wn(o);let g=h.getViewport(d);if(!g){const b={viewportId:d,type:s?G.ORTHOGRAPHIC:G.STACK,element:l,defaultOptions:{...i,suppressEvents:!0}};h.enableElement(b),g=h.getViewport(d)}return new Promise(b=>{let S=!1,{viewReference:v}=i;const p=y=>{if(S)return;if(v){const A=v;v=null,g.setViewReference(A),g.render();return}e.getContext("2d").drawImage(V,0,0,V.width,V.height,0,0,e.width,e.height);const I=g.canvasToWorld([0,0]),C=g.canvasToWorld([V.width/u,0]),$=g.canvasToWorld([0,V.height/u]),_=D([0,0,0],g.canvasToWorld([1/u,0]),I),W=D([0,0,0],g.canvasToWorld([0,1/u]),I),q=1;S=!0,l.removeEventListener(R.IMAGE_RENDERED,p),setTimeout(()=>{h.disableElement(d),document.querySelectorAll(`[viewport-id-for-remove="${w}"]`).forEach(Le=>{Le.remove()})},0),b({origin:I,bottomLeft:$,topRight:C,thicknessMm:q,rightVector:_,downVector:W})};l.addEventListener(R.IMAGE_RENDERED,p),s?g.setVolumes([a],!1,!0):g.renderImageObject(t),g.resetCamera(),n==="PT"&&!ge(r)&&g.setProperties({voiRange:{lower:r.minPixelValue,upper:r.maxPixelValue}}),g.render()})}function Ce(e,t,n,o,i){if(t.volumeId)throw new Error("Unsupported volume rendering for CPU");const r=t,a=Ue(e,r,n),c={canvas:e,viewport:a,image:r,renderingTools:{}};c.transform=Ge(c);const d=!0;return new Promise((l,u)=>{Be(c,d),l(null)})}function Xn(e){const{canvas:t,imageId:n,viewReference:o,requestType:i=He.Thumbnail,priority:s=-5,renderingEngineId:r="_thumbnails",useCPURendering:a=!1,thumbnail:c=!1,imageAspect:d=!1,viewportOptions:l}=e,u=o?.volumeId,f=u&&!n,m=o&&l?{...l,viewReference:o}:l,w=a?Ce:Re;return new Promise((V,h)=>{function g(p,y){const{modality:x}=B(me.GENERAL_SERIES,y)||{},I=!f&&p,C=f&&p;I&&(I.isPreScaled=I.isPreScaled||I.preScale?.scaled),c&&(t.height=256,t.width=256),d&&I&&(t.width=I&&t.height*I.width/I.height),t.style.width=`${t.width/devicePixelRatio}px`,t.style.height=`${t.height/devicePixelRatio}px`,C&&a&&h(new Error("CPU rendering of volume not supported")),w(t,p,x,r,m).then(V)}function b(p,y){console.error(p,y),h(p)}function S(p,y,x){return je(p,x).then(I=>{g.call(this,I,p)},I=>{b.call(this,I,p)})}const v={useRGBA:!!a,requestType:i};if(u){const p=O.getVolume(u);p||h(new Error(`Volume id ${u} not found in cache`));const y=p.imageIds[0];g(p,y)}else ze.addRequest(S.bind(null,n,null,v),i,{imageId:n},s)})}function Yn(e){const t=z(),n=[];return t.forEach(o=>{o.getViewports().filter(he).forEach(s=>{s.hasImageURI(e)&&n.push(s)})}),n}function Qn(e,t){const n=eo(e,t);return n?n.index:null}function eo(e,t){const n=t.getImageIds(),o=t.getCurrentImageIdIndex();if(n.length===0)return null;const i=c=>{const d=to(c);if(!d)return null;const l=$e(d.planeNormal,d.imagePositionPatient);return qe(l,e)},s={distance:i(n[o])??1/0,index:o},r=n.slice(o+1);for(let c=0;c<r.length;c++){const d=r[c],l=i(d);if(l!==null)if(l<=s.distance)s.distance=l,s.index=c+o+1;else break}const a=n.slice(0,o);for(let c=a.length-1;c>=0;c--){const d=a[c],l=i(d);if(!(l===null||l===s.distance))if(l<s.distance)s.distance=l,s.index=c;else break}return s.distance===1/0?null:s}function to(e){const t=B(me.IMAGE_PLANE,e);if(!t||!(t.rowCosines instanceof Array&&t.rowCosines.length===3)||!(t.columnCosines instanceof Array&&t.columnCosines.length===3)||!(t.imagePositionPatient instanceof Array&&t.imagePositionPatient.length===3))return null;const{rowCosines:n,columnCosines:o,imagePositionPatient:i}=t,s=ie(E(),...n),r=ie(E(),...o),a=H(E(),s,r);return{rowCosines:n,columnCosines:o,imagePositionPatient:i,planeNormal:a}}function no(e){const{width:t,height:n}=e.getCanvas(),{sliceToIndexMatrix:o,indexToSliceMatrix:i}=e.getSliceViewInfo(),s=J(e,[0,0]),r=J(e,[t-1,0]),a=J(e,[0,n-1]),c=D(E(),r,s),d=D(E(),a,s),l=H(E(),c,d);L(c,c),L(d,d),L(l,l);const u=Math.max(Math.abs(c[0]),Math.abs(c[1]),Math.abs(c[2])),f=Math.max(Math.abs(d[0]),Math.abs(d[1]),Math.abs(d[2]));if(!re(1,u)||!re(1,f))throw new Error("getCurrentVolumeViewportSlice is not available for rotate/oblique viewports");const{voxelManager:m}=e.getImageData(),w=e.getSliceViewInfo(),V=m.getSliceData(w);return{width:w.width,height:w.height,scalarData:V,sliceToIndexMatrix:o,indexToSliceMatrix:i}}const oo=.05;function so(e,t){const n=e.getSliceIndex(),o=t.getSliceIndex(),i=B("imagePlaneModule",n.toString()),s=B("imagePlaneModule",o.toString());if(!i||!s){console.log("Viewport spatial registration requires image plane module");return}const{imageOrientationPatient:r}=s;if(!i.imageOrientationPatient.every((f,m)=>Math.abs(f-r[m])<oo)){console.log("Viewport spatial registration only supported for same orientation (hence translation only) for now",i?.imageOrientationPatient,s?.imageOrientationPatient);return}const c=i.imagePositionPatient,d=s.imagePositionPatient,l=Je(E(),c,d),u=Ke(Ze(),l);pe.add([e.id,t.id],u)}function io(e){const{imageData:t,dimensions:n}=e.getImageData()||{};if(!t||!n)return[];const{canvas:o}=e,i=window.devicePixelRatio,s=[0,0],r=[o.width/i,0],a=[o.width/i,o.height/i],c=[0,o.height/i],d=e.canvasToWorld(s),l=e.canvasToWorld(r),u=e.canvasToWorld(a),f=e.canvasToWorld(c),m=t.worldToIndex(d),w=t.worldToIndex(l),V=t.worldToIndex(u),h=t.worldToIndex(f);return ro({dimensions:n,imageData:t,topLeftImage:m,topRightImage:w,bottomRightImage:V,bottomLeftImage:h,topLeftWorld:d,topRightWorld:l,bottomRightWorld:u,bottomLeftWorld:f})}function ro({dimensions:e,imageData:t,topLeftImage:n,topRightImage:o,bottomRightImage:i,bottomLeftImage:s,topLeftWorld:r,topRightWorld:a,bottomRightWorld:c,bottomLeftWorld:d}){const l=k(n,e)?r:t.indexToWorld([0,0,0]),u=k(o,e)?a:t.indexToWorld([e[0]-1,0,0]),f=k(i,e)?c:t.indexToWorld([e[0]-1,e[1]-1,0]),m=k(s,e)?d:t.indexToWorld([0,e[1]-1,0]);return[l,u,m,f]}function k(e,t){return e[0]>0||e[0]<t[0]-1||e[1]>0||e[1]<t[1]-1||e[2]>0||e[2]<t[2]-1}function j(e){if(!e)return;const{viewportUid:t,renderingEngineUid:n}=e.dataset;return Pe(t,n)}function Pe(e,t){if(!t||!e)return;const n=Y(t);if(!n||n.hasBeenDestroyed)return;const o=n.getViewport(e);if(!o)return;const i=An(o)?o.getFrameOfReferenceUID():void 0;return{viewport:o,renderingEngine:n,viewportId:e,renderingEngineId:t,FrameOfReferenceUID:i}}function Bo(e){const t=z();for(let n=0;n<t.length;n++){const o=t[n];if(o.getViewport(e))return Pe(e,o.id)}}function Ho(){const e=[];return z().forEach(n=>{n.getViewports().forEach(({element:i})=>{e.push(j(i))})}),e}function ao(e){const t=j(e);if(!t)return;const{viewport:n}=t;if(!(n instanceof Q))throw new Error(`An image can only be fetched for a stack viewport and not for a viewport of type: ${n.type}`);return n.getCornerstoneImage()}async function co({viewport:e,options:t={}}){const n=e.getRenderingEngine();let o=t.volumeId||`${ee()}`;o.split(":").length===0&&(o=`${Xe()}:${o}`);const{id:i,element:s}=e,r=t.viewportId||i,a=e.getImageIds(),c=e.getViewPresentation(),d=e.getViewReference();n.enableElement({viewportId:r,type:G.ORTHOGRAPHIC,element:s,defaultOptions:{background:t.background,orientation:t.orientation}}),(await Ye(o,{imageIds:a})).load();const u=n.getViewport(r);await _n(n,[{volumeId:o}],[r]);const f=()=>{u.render(),s.removeEventListener(R.VOLUME_VIEWPORT_NEW_VOLUME,f)};return s.addEventListener(R.VOLUME_VIEWPORT_NEW_VOLUME,f),u.setViewPresentation(c),u.setViewReference(d),u.render(),u}async function lo({viewport:e,options:t}){const n=e,{id:o,element:i}=n,s=e.getRenderingEngine(),{background:r}=t,a=t.viewportId||o,c=O.getVolume(n.getVolumeId());if(!(c instanceof Qe))throw new Error("Currently, you cannot decache a volume that is not an ImageVolume. So, unfortunately, volumes such as nifti (which are basic Volume, without imageIds) cannot be decached.");const d={viewportId:a,type:G.STACK,element:i,defaultOptions:{background:r}},l=n.getViewReference();s.enableElement(d);const u=s.getViewport(a);return await u.setStack(c.imageIds),u.setViewReference(l),u.render(),u}function Te(e,t=2){if(Array.isArray(e))return e.map(i=>Te(i,t)).join(", ");if(e==null||e==="")return"NaN";e=Number(e);const n=Math.abs(e);if(n<1e-4)return`${e}`;const o=n>=100?t-2:n>=10?t-1:n>=1?t:n>=.1?t+1:n>=.01?t+2:n>=.001?t+3:t+4;return e.toFixed(o)}function uo(e){return Math.round(e/P)*P}function fo(e,t,n){const o=e.length===t*n*4,i=e.length===t*n*3;if(o||i){const s=new Float32Array(t*n);let r=0,a=0;const c=o?4:3;for(let d=0;d<t;d++)for(let l=0;l<n;l++){const u=e[r],f=e[r+1],m=e[r+2];s[a]=(u+f+m)/3,r+=c,a++}return s}else return e}function go(e){if(e instanceof we)return O.getVolume(e.getVolumeId()).imageIds;if(e.getImageIds)return e.getImageIds()}function mo(e,t){const n=[...e];return t>=n.length?(ce(n),n):(ce(n),n.slice(0,t))}function ce(e){for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}}function K(e){const t=e.toString(16);return t.length==1?"0"+t:t}function ho(e,t,n){return"#"+K(e)+K(t)+K(n)}function po(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}const wo=Object.freeze(Object.defineProperty({__proto__:null,hexToRgb:po,rgbToHex:ho},Symbol.toStringTag,{value:"Module"}));function Io(e,t){if(e===t)return!0;if(e==null||t==null)return!1;try{return JSON.stringify(e)===JSON.stringify(t)}catch(n){return console.debug("Error in JSON.stringify during deep comparison:",n),e===t}}function xe(e,t){const n=e,o=n.getActors?.()??[];return(t?o.find(s=>s.referencedId===t)??o.find(s=>s.referencedId?.endsWith(`:${t}`)):void 0)?.referencedId??(t?te(t):void 0)??n.getDefaultActor?.()?.referencedId}function Me(e,t,n){if(!n)throw new Error("getVolume is required, use the utilities export instead");if(Ie(e)){const o=xe(e,t),i=o?n(o):void 0,s=e.getImageData?.();return{modality:i?.metadata?.Modality??s?.metadata?.Modality,isPreScaled:le(i?.scaling)}}if(typeof e.setVolumes=="function"){const i=t?te(t):e.getVolumeId(),s=i?n(i):void 0;return{modality:s?.metadata?.Modality,isPreScaled:le(s?.scaling)}}if(typeof e.setStack=="function"){const o=e,{preScale:i}=o.getImageData()||{};return{modality:o.modality,isPreScaled:!!i?.scaled}}}function le(e){return!!e&&Object.keys(e).length>0}function Vo(e,t,n){const o=Me(e,t,n);if(!o)throw new Error("Invalid viewport type");return o.modality}function So(e){const{imageIdGroups:t,splittingTag:n}=Ve(e);return{isDynamicVolume:t.length>1,timePoints:t,splittingTag:n}}function bo(e,t){const n=e.length,{rescaleSlope:o,rescaleIntercept:i,suvbw:s}=t;if(t.modality==="PT"&&typeof s=="number")for(let r=0;r<n;r++)e[r]=s*(e[r]*o+i);else for(let r=0;r<n;r++)e[r]=e[r]*o+i;return e}function De(e,t,n){return Math.min(Math.max(t,e),n)}function Oe(e,t){if(!j(e.element))throw new Error("Scroll::Viewport is not enabled (it might be disabled)");if(e instanceof Q&&e.getImageIds().length===0)throw new Error("Scroll::Stack Viewport has no images");const{volumeId:o,delta:i,scrollSlabs:s}=t;if(e instanceof we)vo(e,o,i,s);else{if(typeof e.getCurrentImageIdIndex!="function"||typeof e.scroll!="function")return;const r=e.getCurrentImageIdIndex();if(r+i>e.getImageIds().length-1||r+i<0){const a={imageIdIndex:r,direction:i};T(M,R.STACK_SCROLL_OUT_OF_BOUNDS,a)}e.scroll(i,t.debounceLoading,t.loop)}}function vo(e,t,n,o=!1){const i=o,{numScrollSteps:s,currentStepIndex:r,sliceRangeInfo:a}=Se(e,t,i);if(s===0||!a)return;const{sliceRange:c,spacingInNormalDirection:d,camera:l}=a,{focalPoint:u,viewPlaneNormal:f,position:m}=l,{newFocalPoint:w,newPosition:V}=be(u,m,c,f,d,n);e.setCamera({focalPoint:w,position:V}),e.render();const h=r+n,g={volumeId:t,viewport:e,delta:n,desiredStepIndex:h,currentStepIndex:r,numScrollSteps:s,currentImageId:e.getCurrentImageId()};(h>s||h<0)&&e.getCurrentImageId()?T(M,R.VOLUME_VIEWPORT_SCROLL_OUT_OF_BOUNDS,g):T(M,R.VOLUME_VIEWPORT_SCROLL,g)}async function Eo(e,t={}){const{imageIndex:n,debounceLoading:o,volumeId:i}=t,s=j(e);if(!s)throw new Error("Element has been disabled");const{viewport:r}=s,{imageIndex:a,numberOfSlices:c}=yo(r,o),l=Ro(c,n)-a;Oe(r,{delta:l,debounceLoading:o,volumeId:i})}function yo(e,t){return e instanceof Q?{numberOfSlices:e.getImageIds().length,imageIndex:t?e.getTargetImageIdIndex():e.getCurrentImageIdIndex()}:{numberOfSlices:e.getNumberOfSlices(),imageIndex:e.getSliceIndex()}}function Ro(e,t){const n=e-1;return De(t,0,n)}function Co(e,t,n={}){const o=O.getVolume(e);if(!o)throw new Error(`Referenced volume with id ${e} does not exist.`);const{metadata:i,spacing:s,direction:r,dimensions:a}=o,{minX:c,maxX:d,minY:l,maxY:u,minZ:f,maxZ:m}=t,w=[Math.min(c,d),Math.min(l,u),Math.min(f,m)],V=Z(o.imageData,w),h=[Math.abs(d-c)+1,Math.abs(u-l)+1,Math.abs(m-f)+1],{targetBuffer:g}=n,b={metadata:i,dimensions:h,spacing:s,origin:V,direction:r,targetBuffer:g,scalarData:g?.type==="Float32Array"?new Float32Array(h[0]*h[1]*h[2]):void 0},S=et(ee(),b),v=S.voxelManager.getCompleteScalarDataArray(),p=h[0]*h[1],y=a[0]*a[1],x=o.voxelManager.getCompleteScalarDataArray();for(let I=0;I<h[2];I++)for(let C=0;C<h[1];C++){const $=Z(S.imageData,[0,C,I]),_=ve(o.imageData,$),W=_[2]*y+_[1]*a[0]+_[0],q=x.slice(W,W+h[0]),A=I*p+C*h[0];v.set(q,A)}return S.voxelManager.setCompleteScalarDataArray(v),S}function Po(e,t){const{viewUp:n,viewPlaneNormal:o}=t,i=N(e,[0,0,0]),s=ae(E(),n),r=ae(E(),o),a=H(E(),s,r),c=D(E(),N(e,s),i),d=D(E(),N(e,r),i);L(c,c),L(d,d);const l=H(E(),c,d);return{worldVecRowDir:a,worldVecColDir:s,worldVecSliceDir:r,ijkVecRowDir:l,ijkVecColDir:c,ijkVecSliceDir:d}}function To(e,t,n,o){const[i,s,r]=t,a=i*s;let c=0,d=0,l=0;const[u,f,m]=n.map(Math.round);for(let g=m-o;g<=m+o;g++)if(!(g<0||g>=r)){for(let b=f-o;b<=f+o;b++)if(!(b<0||b>=s))for(let S=u-o;S<=u+o;S++){if(S<0||S>=i)continue;const v=g*a+b*i+S,p=e[v];c+=p,d+=p*p,l++}}if(l===0){const g=m*a+f*i+u;return g>=0&&g<e.length?{mean:e[g],stdDev:0,count:1}:{mean:0,stdDev:0,count:0}}const w=c/l,V=d/l-w*w,h=Math.sqrt(Math.max(0,V));return{mean:w,stdDev:h,count:l}}const de=1e-6;function xo(e,t){const{lower:n,upper:o}=t.voiRange,i=o-n,s=t.VOILUTFunction,r=a=>t.invert===!0?1-a:a;if(s===Ee.SAMPLED_SIGMOID||s==="SIGMOID"){const{windowCenter:a,windowWidth:c}=ye(n,o),d=Math.max(Math.abs(c),1e-12);return r(1/(1+Math.exp(-4*(e-a)/d)))}return i===0||!Number.isFinite(i)?r(0):r(U((e-n)/i))}function X(e,t){const{lower:n,upper:o}=t.voiRange,i=t.VOILUTFunction,s=t.invert===!0?U(1-U(e)):U(e);if(i===Ee.SAMPLED_SIGMOID||i==="SIGMOID"){const{windowCenter:a,windowWidth:c}=ye(n,o),d=_e(s,de,1-de);return tt(d,a,c)}const r=o-n;return r===0||!Number.isFinite(r)?n:n+s*r}function Mo(e,t,n){const o=Math.min(e,t),i=Math.max(e,t),s=X(o,n),r=X(i,n);return{rawMin:Math.min(s,r),rawMax:Math.max(s,r)}}function U(e){return Number.isFinite(e)?_e(e,0,1):0}function _e(e,t,n){return Math.min(n,Math.max(t,e))}const{getPixelSpacingInformation:Do,calculateRadiographicPixelSpacing:Oo,getERMF:_o}=nt,Lo=(e,t)=>Vo(e,t,O.getVolume),Wo=(e,t)=>Me(e,t,O.getVolume),zo=Object.freeze(Object.defineProperty({__proto__:null,ECGUtilities:ft,FrameRange:gt,HistoryMemo:mt,PointsManager:at,ProgressiveIterator:it,RLEVoxelMap:st,VideoUtilities:ht,VoxelManager:ot,WSIUtilities:pt,actorIsA:wt,applyPreset:It,asArray:Vt,autoLoad:St,buildMetadata:bt,calculateNeighborhoodStats:To,calculateRadiographicPixelSpacing:Oo,calculateSpacingBetweenImageIds:vt,calculateViewportsSpatialRegistration:so,calibratedPixelSpacingMetadataProvider:$n,clamp:ut,clip:De,clonePoint3:Et,color:wo,colormap:yt,convertColorArrayToRgbString:Rt,convertStackToVolumeViewport:co,convertToGrayscale:fo,convertVolumeToStackViewport:lo,createLinearRGBTransferFunction:Ct,createSigmoidRGBTransferFunction:Pt,createSubVolume:Co,decimate:Tt,deepClone:xt,deepEqual:Io,deepMerge:Mt,eventListener:Fn,fnv1aHash:Dt,generateFrameImageId:Ot,generateVolumePropsFromImageIds:_t,genericMetadataProvider:Lt,genericViewportDisplaySetMetadataProvider:Wt,getAcquisitionPlaneOrientation:At,getBufferConfiguration:kt,getClosestImageId:Ft,getClosestStackImageIndexForPoint:Qn,getCubeSizeInView:Nt,getCurrentVolumeViewportSlice:no,getDynamicVolumeInfo:So,getERMF:_o,getImageDataMetadata:Ut,getImageLegacy:ao,getImageSliceDataForVolumeViewport:Gt,getMinMax:Bt,getNormalizedAspectRatio:dt,getPixelSpacingInformation:Do,getRandomSampleFromArray:mo,getRuntimeId:zn,getScalingDescriptor:Wo,getScalingParameters:Ht,getSliceRange:zt,getSpacingInNormalDirection:jt,getTargetVolumeAndSpacingInNormalDir:$t,getVOIRangeFromWindowLevel:qt,getViewportContentMode:Jt,getViewportImageCornersInWorld:io,getViewportImageIds:go,getViewportModality:Lo,getViewportsWithImageURI:Yn,getViewportsWithVolumeId:Kt,getVoiFromSigmoidRGBTransferFunction:Zt,getVolumeActorCorners:Xt,getVolumeDirectionVectors:Po,getVolumeId:te,getVolumeSliceRangeInfo:Yt,getVolumeViewReferenceId:Qt,getVolumeViewportScrollInfo:Se,getVolumeViewportsContainingSameVolumes:Zn,handleMultiframe4D:en,hasFloatScalingParameters:tn,hasNaNValues:nn,hasOwn:on,imageIdToURI:sn,imageRetrieveMetadataProvider:ct,imageToWorldCoords:rn,indexAlmostWithinDimensions:Kn,indexWithinDimensions:Jn,invertRgbTransferFunction:an,isEqual:lt,isEqualAbs:cn,isEqualNegative:ln,isGenericViewport:Ie,isImageActor:dn,isNumber:un,isOpposite:qn,isPTPrescaledWithSUV:ge,isValidVolume:fn,isVideoTransferSyntax:gn,jumpToSlice:Eo,loadImageToCanvas:Xn,logger:rt,makeVolumeMetadata:mn,mapMappedBandToRawRange:Mo,mapScalarToViewportVoiIntensity:xo,mapViewportVoiIntensityToScalar:X,planar:hn,pointInShapeCallback:pn,renderToCanvasCPU:Ce,renderToCanvasGPU:Re,resolveGenericViewportVolumeId:xe,rotateToViewCoordinates:wn,roundNumber:Te,roundToPrecision:uo,scaleArray:bo,scaleRgbTransferFunction:Nn,scroll:Oe,snapFocalPointToSlice:be,sortImageIdsAndGetSpacing:In,spatialRegistrationMetadataProvider:pe,splitImageIdsBy4DTags:Ve,transferFunctionUtils:Vn,transformIndexToWorld:Z,transformWorldToIndex:ve,transformWorldToIndexContinuous:N,triggerEvent:T,updatePlaneRestriction:Sn,updateVTKImageDataWithCornerstoneImage:bn,uuidv4:ee,viewportIsInStackMode:vn,viewportIsInVolumeMode:En,viewportSupportsDisplaySetPresentation:yn,viewportSupportsImageSlices:he,viewportSupportsStackCalibration:Rn,viewportSupportsStackCompatibility:Cn,viewportSupportsVolumeActors:fe,viewportSupportsVolumeCompatibility:Pn,viewportSupportsVolumeId:Tn,viewportSupportsVolumeURI:xn,windowLevel:Mn,worldToImageCoords:Dn},Symbol.toStringTag,{value:"Module"}));export{Oe as A,no as B,De as C,qn as D,io as E,fo as F,On as G,kn as M,Wn as T,Ln as a,Pe as b,Bo as c,Ho as d,An as e,Go as f,j as g,Uo as h,zn as i,Io as j,mo as k,Wo as l,Yn as m,Kn as n,Qn as o,so as p,Eo as q,Te as r,_n as s,Jn as t,zo as u,No as v,uo as w,Po as x,Co as y,To as z};
1
+ import{t as T,E as R,e as M,B as We,v as Ae,a as ne,b as F,s as ke,c as Fe,f as oe,cw as ue,c8 as Ne,bW as P,aK as z,cx as fe,aJ as Y,ag as se,V as G,cy as ge,cz as D,cA as Ue,cB as Ge,cC as Be,bL as He,at as O,aO as ze,bi as B,cD as me,bN as je,cE as he,bt as $e,b_ as qe,cF as ie,cG as E,cH as H,cI as J,cJ as L,cK as re,cL as Je,cM as Ke,cN as Ze,bC as pe,am as Q,b8 as ee,cO as Xe,cP as Ye,ai as Qe,ar as we,bm as te,i as Ie,L as Ve,bK as Se,cQ as be,bA as Z,bG as et,bc as ve,bz as N,cR as ae,cS as Ee,bP as ye,cT as tt,cr as nt,K as ot,cU as st,cV as it,c1 as rt,cW as at,cX as ct,bf as lt,cY as dt,cZ as ut,c_ as ft,c$ as gt,bp as mt,d0 as ht,d1 as pt,d2 as wt,d3 as It,d4 as Vt,d5 as St,d6 as bt,d7 as vt,bg as Et,d8 as yt,av as Rt,d9 as Ct,da as Pt,H as Tt,b7 as xt,bk as Mt,db as Dt,dc as Ot,J as _t,dd as Lt,bo as Wt,de as At,df as kt,bq as Ft,dg as Nt,bs as Ut,dh as Gt,bR as Bt,di as Ht,dj as zt,bF as jt,bj as $t,dk as qt,bh as Jt,bn as Kt,dl as Zt,dm as Xt,dn as Yt,dp as Qt,dq as en,dr as tn,ds as nn,dt as on,bl as sn,bZ as rn,du as an,bT as cn,dv as ln,bS as dn,bv as un,br as fn,ct as gn,dw as mn,dx as hn,bI as pn,dy as wn,M as In,dz as Vn,dA as Sn,bw as bn,dB as vn,bD as En,bJ as yn,dC as Rn,dD as Cn,bM as Pn,dE as Tn,dF as xn,dG as Mn,bY as Dn}from"./Settings-CpJHgU8P.js";import"./Texture-BFywN4BL.js";import"./cornerstoneEngine-DgoPMn1N.js";function On(e){return!!(e&&typeof e.setVolumes=="function"&&typeof e.addVolumes=="function")}async function _n(e,t,n,o=!1,i=!1){const s=n.map(r=>{const a=e.getViewport(r);if(!a)throw new Error(`Viewport with Id ${r} does not exist`);if(!On(a))throw new Error("setVolumesForViewports only supports viewports that implement setVolumes");return a});await Promise.all(s.map(r=>r.setVolumes(t,o,i)))}function Ln(e,t,n=0){const o=e.getOpenGLRenderWindow?.()?.getCanvas?.();o&&(o.addEventListener("webglcontextlost",()=>{console.warn(`CornerstoneRender: WebGL context lost (renderingEngine=${t}, context=${n})`),T(M,R.WEBGL_CONTEXT_LOST,{renderingEngineId:t,contextIndex:n})}),o.addEventListener("webglcontextrestored",()=>{T(M,R.WEBGL_CONTEXT_RESTORED,{renderingEngineId:t,contextIndex:n})}))}class Wn extends We{constructor(t){super(t),this._renderFlaggedViewports=()=>{this._throwIfDestroyed(),this.offscreenMultiRenderWindow&&this.performVtkDrawCall();const n=this._getViewportsAsArray(),o=[];for(let i=0;i<n.length;i++){const s=n[i];if(this._needsRender.has(s.id)){const r=this.renderViewportUsingCustomOrVtkPipeline(s);if(o.push(r),s.setRendered(),this._needsRender.delete(s.id),this._needsRender.size===0)break}}this._animationFrameSet=!1,this._animationFrameHandle=null,o.forEach(i=>{i?.element&&T(i.element,R.IMAGE_RENDERED,i)})},this.useCPURendering||this.ensureOffscreenResources()}ensureOffscreenResources(){this.offscreenMultiRenderWindow||(this.offscreenMultiRenderWindow=Ae.newInstance(),this.offScreenCanvasContainer=document.createElement("div"),this.offscreenMultiRenderWindow.setContainer(this.offScreenCanvasContainer),Ln(this.offscreenMultiRenderWindow,this.id))}enableVTKjsDrivenViewport(t){this.ensureOffscreenResources();const o=this._getViewportsAsArray().filter(l=>ne(l.type)===!1),i=o.map(l=>l.canvas),s=F(t.element);i.push(s);const{offScreenCanvasWidth:r,offScreenCanvasHeight:a}=this._resizeOffScreenCanvas(i),c=this._resize(o,r,a),d={...t,canvas:s};this.addVtkjsDrivenViewport(d,{offScreenCanvasWidth:r,offScreenCanvasHeight:a,xOffset:c})}addVtkjsDrivenViewport(t,n){this.ensureOffscreenResources();const{element:o,canvas:i,viewportId:s,type:r,defaultOptions:a}=t;o.tabIndex=-1,ke(o);const{offScreenCanvasWidth:c,offScreenCanvasHeight:d,xOffset:l}=n,{sxStartDisplayCoords:u,syStartDisplayCoords:f,sxEndDisplayCoords:m,syEndDisplayCoords:w,sx:V,sy:h,sWidth:g,sHeight:b}=this._getViewportCoordsOnOffScreenCanvas(t,c,d,l);this.offscreenMultiRenderWindow.addRenderer({viewport:[u,f,m,w],id:s,background:a.background?a.background:[0,0,0]});const S={id:s,element:o,renderingEngineId:this.id,type:r,canvas:i,sx:V,sy:h,sWidth:g,sHeight:b,defaultOptions:a||{}},v=Fe(t);if(!v)throw new Error(`Viewport Type ${r} is not supported`);const p=new v(S);p.requestedType=t.requestedType??r,this._viewports.set(s,p);const y={element:o,viewportId:s,renderingEngineId:this.id};p.suppressEvents||T(M,R.ELEMENT_ENABLED,y)}setVtkjsDrivenViewports(t){if(t.length){const n=t.map(r=>F(r.element));n.forEach(r=>{const a=window.devicePixelRatio||1,c=r.getBoundingClientRect();r.width=c.width*a,r.height=c.height*a});const{offScreenCanvasWidth:o,offScreenCanvasHeight:i}=this._resizeOffScreenCanvas(n);let s=0;for(let r=0;r<t.length;r++){const a=t[r],c=n[r],d={...a,canvas:c};this.addVtkjsDrivenViewport(d,{offScreenCanvasWidth:o,offScreenCanvasHeight:i,xOffset:s}),s+=c.width}}}_resizeVTKViewports(t,n=!0,o=!0){const i=t.map(s=>F(s.element));if(i.forEach(s=>{const r=window.devicePixelRatio||1;s.width=s.clientWidth*r,s.height=s.clientHeight*r}),i.length){const{offScreenCanvasWidth:s,offScreenCanvasHeight:r}=this._resizeOffScreenCanvas(i);this._resize(t,s,r)}t.forEach(s=>{const r=s.getCamera(),a=s.getRotation(),{flipHorizontal:c}=r,d=s;d.resetViewStateForResize?d.resetViewStateForResize():d.resetCameraForResize();const l=s.getDisplayArea();n&&(l?(c&&s.setCamera({flipHorizontal:c}),a&&s.setViewPresentation({rotation:a})):s.setCamera(r))}),o&&this.render()}performVtkDrawCall(){const{offscreenMultiRenderWindow:t}=this,n=t.getRenderWindow(),o=t.getRenderers();if(o.length){for(let i=0;i<o.length;i++){const{renderer:s,id:r}=o[i],a=r.split("::")[0];this._needsRender.has(a)?s.setDraw(!0):s.setDraw(!1)}n.render();for(let i=0;i<o.length;i++)o[i].renderer.setDraw(!1)}}renderViewportUsingCustomOrVtkPipeline(t){let n;if(t.sWidth<oe||t.sHeight<oe){console.warn("Viewport is too small",t.sWidth,t.sHeight);return}if(ne(t.type)===!0)n=t.customRenderViewportToCanvas();else{if(!this.offscreenMultiRenderWindow)throw new Error("GPU not available, and using a viewport with no custom render pipeline.");const{offscreenMultiRenderWindow:o}=this,r=o.getOpenGLRenderWindow().get3DContext().canvas;n=this._renderViewportFromVtkCanvasToOnscreenCanvas(t,r)}return n}_renderViewportFromVtkCanvasToOnscreenCanvas(t,n){const{element:o,canvas:i,sx:s,sy:r,sWidth:a,sHeight:c,id:d,renderingEngineId:l,suppressEvents:u}=t,{width:f,height:m}=i;return i.getContext("2d").drawImage(n,s,r,a,c,0,0,f,m),{element:o,suppressEvents:u,viewportId:d,renderingEngineId:l,viewportStatus:t.viewportStatus}}_resizeOffScreenCanvas(t){const{offScreenCanvasContainer:n,offscreenMultiRenderWindow:o}=this,i=Math.max(...t.map(r=>r.height));let s=0;return t.forEach(r=>{s+=r.width}),n.width=s,n.height=i,o.resize(),{offScreenCanvasWidth:s,offScreenCanvasHeight:i}}_resize(t,n,o){let i=0;for(let s=0;s<t.length;s++){const r=t[s],{sxStartDisplayCoords:a,syStartDisplayCoords:c,sxEndDisplayCoords:d,syEndDisplayCoords:l,sx:u,sy:f,sWidth:m,sHeight:w}=this._getViewportCoordsOnOffScreenCanvas(r,n,o,i);i+=r.canvas.width,r.sx=u,r.sy=f,r.sWidth=m,r.sHeight=w,this.offscreenMultiRenderWindow.getRenderer(r.id).setViewport(a,c,d,l)}return i}_getViewportCoordsOnOffScreenCanvas(t,n,o,i){const{canvas:s}=t,{width:r,height:a}=s,c=i,d=0,l=c/n,u=d+(o-a)/o,f=r/n,m=a/o;return{sxStartDisplayCoords:l,syStartDisplayCoords:u,sxEndDisplayCoords:l+f,syEndDisplayCoords:u+m,sx:c,sy:d,sWidth:r,sHeight:a}}}function No(e){return!!(e&&typeof e.canvasToWorld=="function"&&typeof e.worldToCanvas=="function")}function Uo(e){return!!(e&&typeof e.getZoom=="function"&&typeof e.setZoom=="function")}function Go(e){return!!(e&&typeof e.getPan=="function"&&typeof e.setPan=="function")}function An(e){return!!(e&&typeof e.getFrameOfReferenceUID=="function")}class kn{constructor(){this._targetsEventListeners=new Map}addEventListener(t,n,o,i){let s=this._targetsEventListeners.get(t);s||(s=new ue(t),this._targetsEventListeners.set(t,s)),s.addEventListener(n,o,i)}removeEventListener(t,n,o,i){const s=this._targetsEventListeners.get(t);s&&(s.removeEventListener(n,o,i),s.isEmpty&&this._targetsEventListeners.delete(t))}reset(){Array.from(this._targetsEventListeners.entries()).forEach(([t,n])=>{n.reset(),this._targetsEventListeners.delete(t)})}}const Fn=Object.freeze(Object.defineProperty({__proto__:null,MultiTargetEventListenerManager:kn,TargetEventListeners:ue},Symbol.toStringTag,{value:"Module"}));function Nn(e,t){const n=e.getSize();for(let o=0;o<n;o++){const i=[];e.getNodeValue(o,i),i[1]=i[1]*t,i[2]=i[2]*t,i[3]=i[3]*t,e.setNodeValue(o,i)}}const Un=Symbol("LastRuntimeId"),Gn={},Bn=4294967295,Hn="-";function zn(e,t,n){return jn(e!==null&&typeof e=="object"?e:Gn,Un,(typeof n=="number"&&n>0?n:Bn)>>>0).join(typeof t=="string"?t:Hn)}function jn(e,t,n){let o=e[t];o instanceof Array||(o=[0],Object.defineProperty(e,t,{value:o}));for(let i=!0,s=0;i&&s<o.length;++s){let r=o[s]|0;r<n?(i=!1,r=r+1):(r=0,s+1===o.length&&o.push(0)),o[s]=r}return o}const $n=Ne;function qn(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}function Jn(e,t){return!(e[0]<0||e[0]>=t[0]||e[1]<0||e[1]>=t[1]||e[2]<0||e[2]>=t[2])}function Kn(e,t){return!(e[0]<-P||e[0]>=t[0]+P||e[1]<-P||e[1]>=t[1]+P||e[2]<-P||e[2]>=t[2]+P)}function Zn(e,t){let n;t?n=[Y(t)]:n=z();const o=[];return n.forEach(i=>{const s=e.getActors(),r=i.getViewports().filter(fe);for(const a of r){const c=a.getActors();if(c.length!==s.length)continue;s.every(({uid:l})=>c.find(u=>l===u.uid))&&o.push(a)}}),o}function Re(e,t,n=void 0,o="_thumbnails",i={displayArea:{imageArea:[1,1]}}){if(!e||!(e instanceof HTMLCanvasElement))throw new Error("canvas element is required");const s=!t.imageId,r=!s&&t,a=s&&t,d=`renderGPUViewport-${r.imageId||a.volumeId}`,l=document.createElement("div"),u=window.devicePixelRatio||1;i.displayArea||(i.displayArea={imageArea:[1,1]});const f=e.width,m=e.height;l.style.width=`${f/u+se}px`,l.style.height=`${m/u+se}px`,l.style.visibility="hidden",l.style.position="absolute",document.body.appendChild(l);const w=d.split(":").join("-");l.setAttribute("viewport-id-for-remove",w);const V=F(l),h=Y(o)||new Wn(o);let g=h.getViewport(d);if(!g){const b={viewportId:d,type:s?G.ORTHOGRAPHIC:G.STACK,element:l,defaultOptions:{...i,suppressEvents:!0}};h.enableElement(b),g=h.getViewport(d)}return new Promise(b=>{let S=!1,{viewReference:v}=i;const p=y=>{if(S)return;if(v){const A=v;v=null,g.setViewReference(A),g.render();return}e.getContext("2d").drawImage(V,0,0,V.width,V.height,0,0,e.width,e.height);const I=g.canvasToWorld([0,0]),C=g.canvasToWorld([V.width/u,0]),$=g.canvasToWorld([0,V.height/u]),_=D([0,0,0],g.canvasToWorld([1/u,0]),I),W=D([0,0,0],g.canvasToWorld([0,1/u]),I),q=1;S=!0,l.removeEventListener(R.IMAGE_RENDERED,p),setTimeout(()=>{h.disableElement(d),document.querySelectorAll(`[viewport-id-for-remove="${w}"]`).forEach(Le=>{Le.remove()})},0),b({origin:I,bottomLeft:$,topRight:C,thicknessMm:q,rightVector:_,downVector:W})};l.addEventListener(R.IMAGE_RENDERED,p),s?g.setVolumes([a],!1,!0):g.renderImageObject(t),g.resetCamera(),n==="PT"&&!ge(r)&&g.setProperties({voiRange:{lower:r.minPixelValue,upper:r.maxPixelValue}}),g.render()})}function Ce(e,t,n,o,i){if(t.volumeId)throw new Error("Unsupported volume rendering for CPU");const r=t,a=Ue(e,r,n),c={canvas:e,viewport:a,image:r,renderingTools:{}};c.transform=Ge(c);const d=!0;return new Promise((l,u)=>{Be(c,d),l(null)})}function Xn(e){const{canvas:t,imageId:n,viewReference:o,requestType:i=He.Thumbnail,priority:s=-5,renderingEngineId:r="_thumbnails",useCPURendering:a=!1,thumbnail:c=!1,imageAspect:d=!1,viewportOptions:l}=e,u=o?.volumeId,f=u&&!n,m=o&&l?{...l,viewReference:o}:l,w=a?Ce:Re;return new Promise((V,h)=>{function g(p,y){const{modality:x}=B(me.GENERAL_SERIES,y)||{},I=!f&&p,C=f&&p;I&&(I.isPreScaled=I.isPreScaled||I.preScale?.scaled),c&&(t.height=256,t.width=256),d&&I&&(t.width=I&&t.height*I.width/I.height),t.style.width=`${t.width/devicePixelRatio}px`,t.style.height=`${t.height/devicePixelRatio}px`,C&&a&&h(new Error("CPU rendering of volume not supported")),w(t,p,x,r,m).then(V)}function b(p,y){console.error(p,y),h(p)}function S(p,y,x){return je(p,x).then(I=>{g.call(this,I,p)},I=>{b.call(this,I,p)})}const v={useRGBA:!!a,requestType:i};if(u){const p=O.getVolume(u);p||h(new Error(`Volume id ${u} not found in cache`));const y=p.imageIds[0];g(p,y)}else ze.addRequest(S.bind(null,n,null,v),i,{imageId:n},s)})}function Yn(e){const t=z(),n=[];return t.forEach(o=>{o.getViewports().filter(he).forEach(s=>{s.hasImageURI(e)&&n.push(s)})}),n}function Qn(e,t){const n=eo(e,t);return n?n.index:null}function eo(e,t){const n=t.getImageIds(),o=t.getCurrentImageIdIndex();if(n.length===0)return null;const i=c=>{const d=to(c);if(!d)return null;const l=$e(d.planeNormal,d.imagePositionPatient);return qe(l,e)},s={distance:i(n[o])??1/0,index:o},r=n.slice(o+1);for(let c=0;c<r.length;c++){const d=r[c],l=i(d);if(l!==null)if(l<=s.distance)s.distance=l,s.index=c+o+1;else break}const a=n.slice(0,o);for(let c=a.length-1;c>=0;c--){const d=a[c],l=i(d);if(!(l===null||l===s.distance))if(l<s.distance)s.distance=l,s.index=c;else break}return s.distance===1/0?null:s}function to(e){const t=B(me.IMAGE_PLANE,e);if(!t||!(t.rowCosines instanceof Array&&t.rowCosines.length===3)||!(t.columnCosines instanceof Array&&t.columnCosines.length===3)||!(t.imagePositionPatient instanceof Array&&t.imagePositionPatient.length===3))return null;const{rowCosines:n,columnCosines:o,imagePositionPatient:i}=t,s=ie(E(),...n),r=ie(E(),...o),a=H(E(),s,r);return{rowCosines:n,columnCosines:o,imagePositionPatient:i,planeNormal:a}}function no(e){const{width:t,height:n}=e.getCanvas(),{sliceToIndexMatrix:o,indexToSliceMatrix:i}=e.getSliceViewInfo(),s=J(e,[0,0]),r=J(e,[t-1,0]),a=J(e,[0,n-1]),c=D(E(),r,s),d=D(E(),a,s),l=H(E(),c,d);L(c,c),L(d,d),L(l,l);const u=Math.max(Math.abs(c[0]),Math.abs(c[1]),Math.abs(c[2])),f=Math.max(Math.abs(d[0]),Math.abs(d[1]),Math.abs(d[2]));if(!re(1,u)||!re(1,f))throw new Error("getCurrentVolumeViewportSlice is not available for rotate/oblique viewports");const{voxelManager:m}=e.getImageData(),w=e.getSliceViewInfo(),V=m.getSliceData(w);return{width:w.width,height:w.height,scalarData:V,sliceToIndexMatrix:o,indexToSliceMatrix:i}}const oo=.05;function so(e,t){const n=e.getSliceIndex(),o=t.getSliceIndex(),i=B("imagePlaneModule",n.toString()),s=B("imagePlaneModule",o.toString());if(!i||!s){console.log("Viewport spatial registration requires image plane module");return}const{imageOrientationPatient:r}=s;if(!i.imageOrientationPatient.every((f,m)=>Math.abs(f-r[m])<oo)){console.log("Viewport spatial registration only supported for same orientation (hence translation only) for now",i?.imageOrientationPatient,s?.imageOrientationPatient);return}const c=i.imagePositionPatient,d=s.imagePositionPatient,l=Je(E(),c,d),u=Ke(Ze(),l);pe.add([e.id,t.id],u)}function io(e){const{imageData:t,dimensions:n}=e.getImageData()||{};if(!t||!n)return[];const{canvas:o}=e,i=window.devicePixelRatio,s=[0,0],r=[o.width/i,0],a=[o.width/i,o.height/i],c=[0,o.height/i],d=e.canvasToWorld(s),l=e.canvasToWorld(r),u=e.canvasToWorld(a),f=e.canvasToWorld(c),m=t.worldToIndex(d),w=t.worldToIndex(l),V=t.worldToIndex(u),h=t.worldToIndex(f);return ro({dimensions:n,imageData:t,topLeftImage:m,topRightImage:w,bottomRightImage:V,bottomLeftImage:h,topLeftWorld:d,topRightWorld:l,bottomRightWorld:u,bottomLeftWorld:f})}function ro({dimensions:e,imageData:t,topLeftImage:n,topRightImage:o,bottomRightImage:i,bottomLeftImage:s,topLeftWorld:r,topRightWorld:a,bottomRightWorld:c,bottomLeftWorld:d}){const l=k(n,e)?r:t.indexToWorld([0,0,0]),u=k(o,e)?a:t.indexToWorld([e[0]-1,0,0]),f=k(i,e)?c:t.indexToWorld([e[0]-1,e[1]-1,0]),m=k(s,e)?d:t.indexToWorld([0,e[1]-1,0]);return[l,u,m,f]}function k(e,t){return e[0]>0||e[0]<t[0]-1||e[1]>0||e[1]<t[1]-1||e[2]>0||e[2]<t[2]-1}function j(e){if(!e)return;const{viewportUid:t,renderingEngineUid:n}=e.dataset;return Pe(t,n)}function Pe(e,t){if(!t||!e)return;const n=Y(t);if(!n||n.hasBeenDestroyed)return;const o=n.getViewport(e);if(!o)return;const i=An(o)?o.getFrameOfReferenceUID():void 0;return{viewport:o,renderingEngine:n,viewportId:e,renderingEngineId:t,FrameOfReferenceUID:i}}function Bo(e){const t=z();for(let n=0;n<t.length;n++){const o=t[n];if(o.getViewport(e))return Pe(e,o.id)}}function Ho(){const e=[];return z().forEach(n=>{n.getViewports().forEach(({element:i})=>{e.push(j(i))})}),e}function ao(e){const t=j(e);if(!t)return;const{viewport:n}=t;if(!(n instanceof Q))throw new Error(`An image can only be fetched for a stack viewport and not for a viewport of type: ${n.type}`);return n.getCornerstoneImage()}async function co({viewport:e,options:t={}}){const n=e.getRenderingEngine();let o=t.volumeId||`${ee()}`;o.split(":").length===0&&(o=`${Xe()}:${o}`);const{id:i,element:s}=e,r=t.viewportId||i,a=e.getImageIds(),c=e.getViewPresentation(),d=e.getViewReference();n.enableElement({viewportId:r,type:G.ORTHOGRAPHIC,element:s,defaultOptions:{background:t.background,orientation:t.orientation}}),(await Ye(o,{imageIds:a})).load();const u=n.getViewport(r);await _n(n,[{volumeId:o}],[r]);const f=()=>{u.render(),s.removeEventListener(R.VOLUME_VIEWPORT_NEW_VOLUME,f)};return s.addEventListener(R.VOLUME_VIEWPORT_NEW_VOLUME,f),u.setViewPresentation(c),u.setViewReference(d),u.render(),u}async function lo({viewport:e,options:t}){const n=e,{id:o,element:i}=n,s=e.getRenderingEngine(),{background:r}=t,a=t.viewportId||o,c=O.getVolume(n.getVolumeId());if(!(c instanceof Qe))throw new Error("Currently, you cannot decache a volume that is not an ImageVolume. So, unfortunately, volumes such as nifti (which are basic Volume, without imageIds) cannot be decached.");const d={viewportId:a,type:G.STACK,element:i,defaultOptions:{background:r}},l=n.getViewReference();s.enableElement(d);const u=s.getViewport(a);return await u.setStack(c.imageIds),u.setViewReference(l),u.render(),u}function Te(e,t=2){if(Array.isArray(e))return e.map(i=>Te(i,t)).join(", ");if(e==null||e==="")return"NaN";e=Number(e);const n=Math.abs(e);if(n<1e-4)return`${e}`;const o=n>=100?t-2:n>=10?t-1:n>=1?t:n>=.1?t+1:n>=.01?t+2:n>=.001?t+3:t+4;return e.toFixed(o)}function uo(e){return Math.round(e/P)*P}function fo(e,t,n){const o=e.length===t*n*4,i=e.length===t*n*3;if(o||i){const s=new Float32Array(t*n);let r=0,a=0;const c=o?4:3;for(let d=0;d<t;d++)for(let l=0;l<n;l++){const u=e[r],f=e[r+1],m=e[r+2];s[a]=(u+f+m)/3,r+=c,a++}return s}else return e}function go(e){if(e instanceof we)return O.getVolume(e.getVolumeId()).imageIds;if(e.getImageIds)return e.getImageIds()}function mo(e,t){const n=[...e];return t>=n.length?(ce(n),n):(ce(n),n.slice(0,t))}function ce(e){for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}}function K(e){const t=e.toString(16);return t.length==1?"0"+t:t}function ho(e,t,n){return"#"+K(e)+K(t)+K(n)}function po(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}const wo=Object.freeze(Object.defineProperty({__proto__:null,hexToRgb:po,rgbToHex:ho},Symbol.toStringTag,{value:"Module"}));function Io(e,t){if(e===t)return!0;if(e==null||t==null)return!1;try{return JSON.stringify(e)===JSON.stringify(t)}catch(n){return console.debug("Error in JSON.stringify during deep comparison:",n),e===t}}function xe(e,t){const n=e,o=n.getActors?.()??[];return(t?o.find(s=>s.referencedId===t)??o.find(s=>s.referencedId?.endsWith(`:${t}`)):void 0)?.referencedId??(t?te(t):void 0)??n.getDefaultActor?.()?.referencedId}function Me(e,t,n){if(!n)throw new Error("getVolume is required, use the utilities export instead");if(Ie(e)){const o=xe(e,t),i=o?n(o):void 0,s=e.getImageData?.();return{modality:i?.metadata?.Modality??s?.metadata?.Modality,isPreScaled:le(i?.scaling)}}if(typeof e.setVolumes=="function"){const i=t?te(t):e.getVolumeId(),s=i?n(i):void 0;return{modality:s?.metadata?.Modality,isPreScaled:le(s?.scaling)}}if(typeof e.setStack=="function"){const o=e,{preScale:i}=o.getImageData()||{};return{modality:o.modality,isPreScaled:!!i?.scaled}}}function le(e){return!!e&&Object.keys(e).length>0}function Vo(e,t,n){const o=Me(e,t,n);if(!o)throw new Error("Invalid viewport type");return o.modality}function So(e){const{imageIdGroups:t,splittingTag:n}=Ve(e);return{isDynamicVolume:t.length>1,timePoints:t,splittingTag:n}}function bo(e,t){const n=e.length,{rescaleSlope:o,rescaleIntercept:i,suvbw:s}=t;if(t.modality==="PT"&&typeof s=="number")for(let r=0;r<n;r++)e[r]=s*(e[r]*o+i);else for(let r=0;r<n;r++)e[r]=e[r]*o+i;return e}function De(e,t,n){return Math.min(Math.max(t,e),n)}function Oe(e,t){if(!j(e.element))throw new Error("Scroll::Viewport is not enabled (it might be disabled)");if(e instanceof Q&&e.getImageIds().length===0)throw new Error("Scroll::Stack Viewport has no images");const{volumeId:o,delta:i,scrollSlabs:s}=t;if(e instanceof we)vo(e,o,i,s);else{if(typeof e.getCurrentImageIdIndex!="function"||typeof e.scroll!="function")return;const r=e.getCurrentImageIdIndex();if(r+i>e.getImageIds().length-1||r+i<0){const a={imageIdIndex:r,direction:i};T(M,R.STACK_SCROLL_OUT_OF_BOUNDS,a)}e.scroll(i,t.debounceLoading,t.loop)}}function vo(e,t,n,o=!1){const i=o,{numScrollSteps:s,currentStepIndex:r,sliceRangeInfo:a}=Se(e,t,i);if(s===0||!a)return;const{sliceRange:c,spacingInNormalDirection:d,camera:l}=a,{focalPoint:u,viewPlaneNormal:f,position:m}=l,{newFocalPoint:w,newPosition:V}=be(u,m,c,f,d,n);e.setCamera({focalPoint:w,position:V}),e.render();const h=r+n,g={volumeId:t,viewport:e,delta:n,desiredStepIndex:h,currentStepIndex:r,numScrollSteps:s,currentImageId:e.getCurrentImageId()};(h>s||h<0)&&e.getCurrentImageId()?T(M,R.VOLUME_VIEWPORT_SCROLL_OUT_OF_BOUNDS,g):T(M,R.VOLUME_VIEWPORT_SCROLL,g)}async function Eo(e,t={}){const{imageIndex:n,debounceLoading:o,volumeId:i}=t,s=j(e);if(!s)throw new Error("Element has been disabled");const{viewport:r}=s,{imageIndex:a,numberOfSlices:c}=yo(r,o),l=Ro(c,n)-a;Oe(r,{delta:l,debounceLoading:o,volumeId:i})}function yo(e,t){return e instanceof Q?{numberOfSlices:e.getImageIds().length,imageIndex:t?e.getTargetImageIdIndex():e.getCurrentImageIdIndex()}:{numberOfSlices:e.getNumberOfSlices(),imageIndex:e.getSliceIndex()}}function Ro(e,t){const n=e-1;return De(t,0,n)}function Co(e,t,n={}){const o=O.getVolume(e);if(!o)throw new Error(`Referenced volume with id ${e} does not exist.`);const{metadata:i,spacing:s,direction:r,dimensions:a}=o,{minX:c,maxX:d,minY:l,maxY:u,minZ:f,maxZ:m}=t,w=[Math.min(c,d),Math.min(l,u),Math.min(f,m)],V=Z(o.imageData,w),h=[Math.abs(d-c)+1,Math.abs(u-l)+1,Math.abs(m-f)+1],{targetBuffer:g}=n,b={metadata:i,dimensions:h,spacing:s,origin:V,direction:r,targetBuffer:g,scalarData:g?.type==="Float32Array"?new Float32Array(h[0]*h[1]*h[2]):void 0},S=et(ee(),b),v=S.voxelManager.getCompleteScalarDataArray(),p=h[0]*h[1],y=a[0]*a[1],x=o.voxelManager.getCompleteScalarDataArray();for(let I=0;I<h[2];I++)for(let C=0;C<h[1];C++){const $=Z(S.imageData,[0,C,I]),_=ve(o.imageData,$),W=_[2]*y+_[1]*a[0]+_[0],q=x.slice(W,W+h[0]),A=I*p+C*h[0];v.set(q,A)}return S.voxelManager.setCompleteScalarDataArray(v),S}function Po(e,t){const{viewUp:n,viewPlaneNormal:o}=t,i=N(e,[0,0,0]),s=ae(E(),n),r=ae(E(),o),a=H(E(),s,r),c=D(E(),N(e,s),i),d=D(E(),N(e,r),i);L(c,c),L(d,d);const l=H(E(),c,d);return{worldVecRowDir:a,worldVecColDir:s,worldVecSliceDir:r,ijkVecRowDir:l,ijkVecColDir:c,ijkVecSliceDir:d}}function To(e,t,n,o){const[i,s,r]=t,a=i*s;let c=0,d=0,l=0;const[u,f,m]=n.map(Math.round);for(let g=m-o;g<=m+o;g++)if(!(g<0||g>=r)){for(let b=f-o;b<=f+o;b++)if(!(b<0||b>=s))for(let S=u-o;S<=u+o;S++){if(S<0||S>=i)continue;const v=g*a+b*i+S,p=e[v];c+=p,d+=p*p,l++}}if(l===0){const g=m*a+f*i+u;return g>=0&&g<e.length?{mean:e[g],stdDev:0,count:1}:{mean:0,stdDev:0,count:0}}const w=c/l,V=d/l-w*w,h=Math.sqrt(Math.max(0,V));return{mean:w,stdDev:h,count:l}}const de=1e-6;function xo(e,t){const{lower:n,upper:o}=t.voiRange,i=o-n,s=t.VOILUTFunction,r=a=>t.invert===!0?1-a:a;if(s===Ee.SAMPLED_SIGMOID||s==="SIGMOID"){const{windowCenter:a,windowWidth:c}=ye(n,o),d=Math.max(Math.abs(c),1e-12);return r(1/(1+Math.exp(-4*(e-a)/d)))}return i===0||!Number.isFinite(i)?r(0):r(U((e-n)/i))}function X(e,t){const{lower:n,upper:o}=t.voiRange,i=t.VOILUTFunction,s=t.invert===!0?U(1-U(e)):U(e);if(i===Ee.SAMPLED_SIGMOID||i==="SIGMOID"){const{windowCenter:a,windowWidth:c}=ye(n,o),d=_e(s,de,1-de);return tt(d,a,c)}const r=o-n;return r===0||!Number.isFinite(r)?n:n+s*r}function Mo(e,t,n){const o=Math.min(e,t),i=Math.max(e,t),s=X(o,n),r=X(i,n);return{rawMin:Math.min(s,r),rawMax:Math.max(s,r)}}function U(e){return Number.isFinite(e)?_e(e,0,1):0}function _e(e,t,n){return Math.min(n,Math.max(t,e))}const{getPixelSpacingInformation:Do,calculateRadiographicPixelSpacing:Oo,getERMF:_o}=nt,Lo=(e,t)=>Vo(e,t,O.getVolume),Wo=(e,t)=>Me(e,t,O.getVolume),zo=Object.freeze(Object.defineProperty({__proto__:null,ECGUtilities:ft,FrameRange:gt,HistoryMemo:mt,PointsManager:at,ProgressiveIterator:it,RLEVoxelMap:st,VideoUtilities:ht,VoxelManager:ot,WSIUtilities:pt,actorIsA:wt,applyPreset:It,asArray:Vt,autoLoad:St,buildMetadata:bt,calculateNeighborhoodStats:To,calculateRadiographicPixelSpacing:Oo,calculateSpacingBetweenImageIds:vt,calculateViewportsSpatialRegistration:so,calibratedPixelSpacingMetadataProvider:$n,clamp:ut,clip:De,clonePoint3:Et,color:wo,colormap:yt,convertColorArrayToRgbString:Rt,convertStackToVolumeViewport:co,convertToGrayscale:fo,convertVolumeToStackViewport:lo,createLinearRGBTransferFunction:Ct,createSigmoidRGBTransferFunction:Pt,createSubVolume:Co,decimate:Tt,deepClone:xt,deepEqual:Io,deepMerge:Mt,eventListener:Fn,fnv1aHash:Dt,generateFrameImageId:Ot,generateVolumePropsFromImageIds:_t,genericMetadataProvider:Lt,genericViewportDisplaySetMetadataProvider:Wt,getAcquisitionPlaneOrientation:At,getBufferConfiguration:kt,getClosestImageId:Ft,getClosestStackImageIndexForPoint:Qn,getCubeSizeInView:Nt,getCurrentVolumeViewportSlice:no,getDynamicVolumeInfo:So,getERMF:_o,getImageDataMetadata:Ut,getImageLegacy:ao,getImageSliceDataForVolumeViewport:Gt,getMinMax:Bt,getNormalizedAspectRatio:dt,getPixelSpacingInformation:Do,getRandomSampleFromArray:mo,getRuntimeId:zn,getScalingDescriptor:Wo,getScalingParameters:Ht,getSliceRange:zt,getSpacingInNormalDirection:jt,getTargetVolumeAndSpacingInNormalDir:$t,getVOIRangeFromWindowLevel:qt,getViewportContentMode:Jt,getViewportImageCornersInWorld:io,getViewportImageIds:go,getViewportModality:Lo,getViewportsWithImageURI:Yn,getViewportsWithVolumeId:Kt,getVoiFromSigmoidRGBTransferFunction:Zt,getVolumeActorCorners:Xt,getVolumeDirectionVectors:Po,getVolumeId:te,getVolumeSliceRangeInfo:Yt,getVolumeViewReferenceId:Qt,getVolumeViewportScrollInfo:Se,getVolumeViewportsContainingSameVolumes:Zn,handleMultiframe4D:en,hasFloatScalingParameters:tn,hasNaNValues:nn,hasOwn:on,imageIdToURI:sn,imageRetrieveMetadataProvider:ct,imageToWorldCoords:rn,indexAlmostWithinDimensions:Kn,indexWithinDimensions:Jn,invertRgbTransferFunction:an,isEqual:lt,isEqualAbs:cn,isEqualNegative:ln,isGenericViewport:Ie,isImageActor:dn,isNumber:un,isOpposite:qn,isPTPrescaledWithSUV:ge,isValidVolume:fn,isVideoTransferSyntax:gn,jumpToSlice:Eo,loadImageToCanvas:Xn,logger:rt,makeVolumeMetadata:mn,mapMappedBandToRawRange:Mo,mapScalarToViewportVoiIntensity:xo,mapViewportVoiIntensityToScalar:X,planar:hn,pointInShapeCallback:pn,renderToCanvasCPU:Ce,renderToCanvasGPU:Re,resolveGenericViewportVolumeId:xe,rotateToViewCoordinates:wn,roundNumber:Te,roundToPrecision:uo,scaleArray:bo,scaleRgbTransferFunction:Nn,scroll:Oe,snapFocalPointToSlice:be,sortImageIdsAndGetSpacing:In,spatialRegistrationMetadataProvider:pe,splitImageIdsBy4DTags:Ve,transferFunctionUtils:Vn,transformIndexToWorld:Z,transformWorldToIndex:ve,transformWorldToIndexContinuous:N,triggerEvent:T,updatePlaneRestriction:Sn,updateVTKImageDataWithCornerstoneImage:bn,uuidv4:ee,viewportIsInStackMode:vn,viewportIsInVolumeMode:En,viewportSupportsDisplaySetPresentation:yn,viewportSupportsImageSlices:he,viewportSupportsStackCalibration:Rn,viewportSupportsStackCompatibility:Cn,viewportSupportsVolumeActors:fe,viewportSupportsVolumeCompatibility:Pn,viewportSupportsVolumeId:Tn,viewportSupportsVolumeURI:xn,windowLevel:Mn,worldToImageCoords:Dn},Symbol.toStringTag,{value:"Module"}));export{Oe as A,no as B,De as C,qn as D,io as E,fo as F,On as G,kn as M,Wn as T,Ln as a,Pe as b,Bo as c,Ho as d,An as e,Go as f,j as g,Uo as h,zn as i,Io as j,mo as k,Wo as l,Yn as m,Kn as n,Qn as o,so as p,Eo as q,Te as r,_n as s,Jn as t,zo as u,No as v,uo as w,Po as x,Co as y,To as z};
@@ -1 +1 @@
1
- import{v as H,B as U,t as E,E as M,g as L,a as W,b as S,u as G,s as $,V as q,c as Z,e as y,i as F,d as k,f as v,R as O,h as J,j as K,k as Y,l as Q,m as X,n as ee,o as te,p as ne,r as se,q as oe,w as ie,x as ae,y as re,z as de,A as ce,C as le,D as ge,F as me,G as he,I as ue,H as pe,J as N,S as xe,K as j,L as we,M as fe,N as Ie,O as Ve,P as Ce,Q as Pe,W as De,T as Re,U as Se,X as ve,Y as Ee,Z as Me,_ as _e,$ as Ge,a0 as ye,a1 as be,a2 as ze,a3 as Te,a4 as We,a5 as Fe,a6 as ke,a7 as Oe,a8 as Ae,a9 as Le,aa as Ne,ab as je}from"./Settings-BVnfxRPh.js";import{ac as xt,ad as wt,ae as ft,af as It,ag as Vt,ah as Ct,ai as Pt,aj as Dt,ak as Rt,al as St,am as vt,an as Et,ao as Mt,ap as _t,aq as Gt,ar as yt,as as bt,at as zt,au as Tt,av as Wt,aw as Ft,ax as kt,ay as Ot,az as At,aA as Lt,aB as Nt,aC as jt,aD as Bt,aE as Ht,aF as Ut,aG as $t,aH as qt,aI as Zt,aJ as Jt,aK as Kt,aL as Yt,aM as Qt,aN as Xt,aO as en,aP as tn,aQ as nn,aR as sn,aS as on,aT as an,aU as rn,aV as dn,aW as cn,aX as ln,aY as gn,aZ as mn,aO as hn,a_ as un,a$ as pn,b0 as xn,b1 as wn,b2 as fn,b3 as In,b4 as Vn,b5 as Cn,b6 as Pn}from"./Settings-BVnfxRPh.js";import{a as Be,T as He}from"./index-CmFTTf9P.js";import{g as Rn,b as Sn,c as vn,d as En,s as Mn,u as _n,v as Gn,e as yn,f as bn,h as zn}from"./index-CmFTTf9P.js";import"./cornerstoneEngine-CGEzAsx7.js";import"./Texture-C99vHuBO.js";import{a as Wn}from"./addVolumesToViewports-42A0OSZO.js";import"./dcmjs.es-DfWkgqfk.js";import"./index-Dtsm0q-Z.js";import"./_commonjsHelpers-CE1G-McA.js";function rt(l,e,t){for(const n of t){const o=l.getViewport(n);if(!o)throw new Error(`Viewport with Id ${n} does not exist`);if(!o.addImages){console.warn(`Viewport with Id ${n} does not have addImages. Cannot add image segmentation to this viewport.`);return}}t.forEach(n=>{l.getViewport(n).addImages(e)})}class Ue{constructor(e,t=""){this.contexts=[],this.offScreenCanvasContainers=[],this.viewportToContext=new Map,this.viewportSizes=new Map,this.contextMaxSizes=new Map;for(let n=0;n<e;n++){const o=H.newInstance(),s=document.createElement("div");o.setContainer(s),Be(o,t,n),this.contexts.push(o),this.offScreenCanvasContainers.push(s)}}getContextByIndex(e){return e>=0&&e<this.contexts.length?{context:this.contexts[e],container:this.offScreenCanvasContainers[e]}:null}assignViewportToContext(e,t){this.viewportToContext.set(e,t)}getContextIndexForViewport(e){return this.viewportToContext.get(e)}getAllContexts(){return this.contexts}getContextCount(){return this.contexts.length}updateViewportSize(e,t,n){const o=this.viewportToContext.get(e);if(o===void 0)return!1;this.viewportSizes.set(e,{width:t,height:n});const s=this.contextMaxSizes.get(o),i=this.calculateMaxSizeForContext(o);return this.contextMaxSizes.set(o,i),!s||s.width!==i.width||s.height!==i.height}getMaxSizeForContext(e){return this.contextMaxSizes.get(e)}calculateMaxSizeForContext(e){let t=0,n=0;return this.viewportToContext.forEach((o,s)=>{if(o===e){const i=this.viewportSizes.get(s);i&&(t=Math.max(t,i.width),n=Math.max(n,i.height))}}),{width:t,height:n}}removeViewport(e){const t=this.viewportToContext.get(e);if(this.viewportToContext.delete(e),this.viewportSizes.delete(e),t!==void 0){const n=this.calculateMaxSizeForContext(t);this.contextMaxSizes.set(t,n)}}destroy(){this.contexts.forEach(e=>{e.delete()}),this.contexts=[],this.offScreenCanvasContainers=[],this.viewportToContext.clear(),this.viewportSizes.clear(),this.contextMaxSizes.clear()}}class A extends U{constructor(e){super(e),this._renderFlaggedViewports=()=>{this._throwIfDestroyed();const n=this._getViewportsAsArray().filter(s=>this._needsRender.has(s.id));if(n.length===0){this._animationFrameSet=!1,this._animationFrameHandle=null;return}const o=n.map(s=>{const i=this.renderViewportUsingCustomOrVtkPipeline(s);return s.setRendered(),this._needsRender.delete(s.id),i});this._animationFrameSet=!1,this._animationFrameHandle=null,o.forEach(s=>{s?.element&&E(s.element,M.IMAGE_RENDERED,s)})},this.useCPURendering||this.ensureContextPool()}ensureContextPool(){if(!this.contextPool){const{rendering:e}=L(),{webGlContextCount:t}=e;this.contextPool=new Ue(t,this.id)}return this.contextPool}enableVTKjsDrivenViewport(e){const o=this._getViewportsAsArray().filter(a=>W(a.type)===!1).map(a=>a.canvas),s=S(e.element);G(s),o.push(s);const i={...e,canvas:s};this.addVtkjsDrivenViewport(i)}addVtkjsDrivenViewport(e){const t=this.ensureContextPool(),{element:n,canvas:o,viewportId:s,type:i,defaultOptions:a}=e;n.tabIndex=-1,$(n);let r=0;if(i===q.STACK){const u=t.getAllContexts();r=this._viewports.size%u.length}t.assignViewportToContext(s,r),t.updateViewportSize(s,o.width,o.height);const d=t.getContextByIndex(r),{context:g,container:m}=d,p=t.getMaxSizeForContext(r);m.width=p.width,m.height=p.height,g.resize(),g.addRenderer({viewport:[0,0,1,1],id:s,background:a.background?a.background:[0,0,0]});const x={id:s,element:n,renderingEngineId:this.id,type:i,canvas:o,sx:0,sy:0,sWidth:o.width,sHeight:o.height,defaultOptions:a||{}},f=Z(e);if(!f)throw new Error(`Viewport Type ${i} is not supported`);const h=new f(x);h.requestedType=e.requestedType??i,this._viewports.set(s,h);const c={element:n,viewportId:s,renderingEngineId:this.id};h.suppressEvents||E(y,M.ELEMENT_ENABLED,c)}setVtkjsDrivenViewports(e){if(e.length){const t=e.map(n=>S(n.element));t.forEach(n=>G(n));for(let n=0;n<e.length;n++){const o=e[n],s=t[n],i={...o,canvas:s};this.addVtkjsDrivenViewport(i)}}}_getDisplayedSize(e){const t=window.devicePixelRatio||1,n=F(e)?e.element:S(e.element);return{displayedWidth:Math.round(n.clientWidth*t),displayedHeight:Math.round(n.clientHeight*t)}}_resizeVTKViewports(e,t=!0,n=!0){const o=[];for(const s of e){const i=S(s.element),{displayedWidth:a,displayedHeight:r}=this._getDisplayedSize(s);if(a===0||r===0)continue;const d=i.width,g=i.height;a===d&&r===g||o.push(s)}if(o.length!==0){for(const s of o){const{displayedWidth:i,displayedHeight:a}=this._getDisplayedSize(s),r=Math.max(v,i),d=Math.max(v,a);s.sWidth=r,s.sHeight=d}this._animationFrameSet||(e.length&&this._resize(e),e.forEach(s=>{if(s.resize?.(),F(s))return;const i=s.getCamera(),a=s.getRotation?.()??0,{flipHorizontal:r}=i,d=s;d.resetViewStateForResize?d.resetViewStateForResize():d.resetCameraForResize?.();const g=s.getDisplayArea();t&&(g?(r&&s.setCamera({flipHorizontal:r}),a&&s.setViewPresentation({rotation:a})):s.setCamera(i))}),n&&this.render())}}renderViewportUsingCustomOrVtkPipeline(e){if(k(e))return e.customRenderViewportToCanvas();if(!this.contextPool)throw new Error("GPU not available, and using a viewport with no custom render pipeline.");const t=this.contextPool.getContextIndexForViewport(e.id),n=this.contextPool.getContextByIndex(t),{context:o,container:s}=n;return this._renderViewportWithContext(e,o,s)}_renderViewportWithContext(e,t,n){if(e.canvas.clientWidth===0||e.canvas.clientHeight===0)return;if(e.sWidth<v||e.sHeight<v){console.warn("Viewport is too small",e.sWidth,e.sHeight);return}if(k(e))return e.customRenderViewportToCanvas();if(!this.contextPool)throw new Error("GPU not available, and using a viewport with no custom render pipeline.");t.getRenderer(e.id)||t.addRenderer({viewport:[0,0,1,1],id:e.id,background:e.defaultOptions?.background||[0,0,0]});const o=t.getRenderWindow(),s=o.getViews()[0],i=s.getRenderPasses(),a=this.getViewportRenderPasses(e.id);a&&s.setRenderPasses(a),this._resizeOffScreenCanvasForViewport(e,n,t);const r=t.getRenderer(e.id),d=this.contextPool.getContextIndexForViewport(e.id),g=this.contextPool.getMaxSizeForContext(d),m=e.sWidth,p=e.sHeight,x=Math.min(1,m/g.width),f=Math.min(1,p/g.height);r.setViewport(0,0,x,f);const h=t.getRenderers();h.forEach(({renderer:w,id:V})=>{const _=V.split("::")[0];w.setDraw(_===e.id)});const c=this.getWidgetRenderers();c.forEach((w,V)=>{V.setDraw(w===e.id)}),o.render(),h.forEach(({renderer:w})=>w.setDraw(!1)),c.forEach((w,V)=>{V.setDraw(!1)}),i&&s.setRenderPasses(i);const I=t.getOpenGLRenderWindow().get3DContext().canvas;return this._copyToOnscreenCanvas(e,I)}_renderViewportFromVtkCanvasToOnscreenCanvas(e,t){return this._copyToOnscreenCanvas(e,t)}_resizeOffScreenCanvasForViewport(e,t,n){const o=this.contextPool.getContextIndexForViewport(e.id);if(o===void 0||!this.contextPool.updateViewportSize(e.id,e.sWidth,e.sHeight))return;const i=this.contextPool.getMaxSizeForContext(o);t.width===i.width&&t.height===i.height||(t.width=i.width,t.height=i.height,n.resize())}_copyToOnscreenCanvas(e,t){const{element:n,canvas:o,id:s,renderingEngineId:i,suppressEvents:a}=e,r=e.sWidth,d=e.sHeight;G(o,{width:r,height:d});const g=o.getContext("2d"),m=this.contextPool.getContextIndexForViewport(s),x=this.contextPool.getMaxSizeForContext(m).height-d;return g.drawImage(t,0,x,r,d,0,0,r,d),{element:n,suppressEvents:a,viewportId:s,renderingEngineId:i,viewportStatus:e.viewportStatus}}_resize(e){const t=new Set;for(const n of e){n.sx=0,n.sy=0;const o=this.contextPool.getContextIndexForViewport(n.id);this.contextPool.updateViewportSize(n.id,n.sWidth,n.sHeight)&&t.add(o);const i=this.contextPool.getContextByIndex(o),{context:a}=i,r=a.getRenderer(n.id),d=this.contextPool.getMaxSizeForContext(o),g=Math.min(1,n.sWidth/d.width),m=Math.min(1,n.sHeight/d.height);r.setViewport(0,0,g,m)}t.forEach(n=>{const o=this.contextPool.getContextByIndex(n);if(o){const{context:s,container:i}=o,a=this.contextPool.getMaxSizeForContext(n);i.width=a.width,i.height=a.height,s.resize()}})}getWidgetRenderers(){const e=this._getViewportsAsArray(),t=new Map;return e.forEach(n=>{(n.getWidgets?n.getWidgets():[]).forEach(s=>{const i=s.getRenderer?s.getRenderer():null;i&&t.set(i,n.id)})}),t}getViewportRenderPasses(e){const t=this.getViewport(e);return t?.getRenderPasses?t.getRenderPasses():null}getRenderer(e){const t=this.contextPool?.getContextIndexForViewport(e);if(t===void 0||!this.contextPool)return;const n=this.contextPool.getContextByIndex(t);if(!n)return;const{context:o}=n;return o.getRenderer(e)}disableElement(e){const t=this.getViewport(e);if(t&&(super.disableElement(e),!W(t.type)&&this.contextPool)){const n=this.contextPool.getContextIndexForViewport(e);if(n!==void 0){const o=this.contextPool.getContextByIndex(n);if(o){const{context:s}=o;s.removeRenderer(e)}}this.contextPool.removeViewport(e)}}destroy(){super.destroy(),this.contextPool&&this.contextPool.destroy()}getOffscreenMultiRenderWindow(e){if(!this.contextPool)throw new Error("Offscreen multi render window is not available.");const t=this.contextPool.getContextIndexForViewport(e);if(t===void 0)throw new Error(`Offscreen multi render window is not available for viewport ${e}.`);const n=this.contextPool.getContextByIndex(t);if(!n)throw new Error(`Offscreen multi render window is not available for viewport ${e}.`);return n.context}}class dt{constructor(e){const n=L()?.rendering?.renderingEngineMode;switch(n){case O.Tiled:this._implementation=new He(e);break;case O.ContextPool:this._implementation=new A(e);break;default:console.warn(`RenderingEngine: Unknown rendering engine mode "${n}". Defaulting to Next rendering engine.`),this._implementation=new A(e);break}}get id(){return this._implementation.id}disableViewport(e){return this._implementation.disableElement(e)}enableElement(e){return this._implementation.enableElement(e)}disableElement(e){return this._implementation.disableElement(e)}setViewports(e){return this._implementation.setViewports(e)}resize(e=!0,t=!0){return this._implementation.resize(e,t)}getViewport(e){return this._implementation.getViewport(e)}getViewports(){return this._implementation.getViewports()}getRenderer(e){return this._implementation.getRenderer(e)}fillCanvasWithBackgroundColor(e,t){return this._implementation.fillCanvasWithBackgroundColor(e,t)}render(){return this._implementation.render()}renderViewports(e){return this._implementation.renderViewports(e)}renderViewport(e){return this._implementation.renderViewport(e)}destroy(){return this._implementation.destroy()}getOffscreenMultiRenderWindow(e){return this._implementation.getOffscreenMultiRenderWindow(e)}}const $e={adapter:K,getSnapshot:J},qe={adapter:Q,getSnapshot:Y},Ze={adapter:de,getSnapshot:re,getZoom:ae,getScale:ie,getPan:oe,resolveICamera:se,derivePresentation:ne,applyToRenderer:te,createImageSliceBasis:ee,createVolumeSliceBasis:X},Je={adapter:le,getSnapshot:ce},Ke={adapter:me,getSnapshot:ge},ct="5.8.2";class Ye extends he{constructor(e,t){super(e,t),this._dimensionGroupNumber=1,this._loadedDimensionGroups=new Set,this._getImageIdRequests=(s,i)=>this.getImageIdsRequests(s,i),this.getImageLoadRequests=s=>{const i=this.getImageIdsToLoad();return this._getImageIdRequests(i,s)};const{imageIdGroups:n,splittingTag:o}=e;this._splittingTag=o,this._imageIdGroups=n,this.numDimensionGroups=this._imageIdGroups.length}_getImageIdsToLoad(){const e=this._imageIdGroups,t=this._dimensionGroupNumber-1,n=[...e[t]];let o=t-1,s=t+1;for(;o>=0||s<e.length;)o>=0&&n.push(...e[o--]),s<e.length&&n.push(...e[s++]);return n}getImageIdsToLoad(){return this._getImageIdsToLoad()}get dimensionGroupNumber(){return this._dimensionGroupNumber}set dimensionGroupNumber(e){this._dimensionGroupNumber!==e&&(this._dimensionGroupNumber=e,this.voxelManager.setDimensionGroupNumber(e),this.invalidateVolume(!0),E(y,M.DYNAMIC_VOLUME_DIMENSION_GROUP_CHANGED,{volumeId:this.volumeId,dimensionGroupNumber:e,numDimensionGroups:this.numDimensionGroups,imageIdGroupIndex:e-1,numImageIdGroups:this.numDimensionGroups,splittingTag:this.splittingTag}))}scroll(e){const t=this._dimensionGroupNumber+e;t<1?this.dimensionGroupNumber=this.numDimensionGroups:t>this.numDimensionGroups?this.dimensionGroupNumber=1:this.dimensionGroupNumber=t}getCurrentDimensionGroupImageIds(){return this._imageIdGroups[this._dimensionGroupNumber-1]}flatImageIdIndexToDimensionGroupNumber(e){return Math.floor(e/this._imageIdGroups[0].length)+1}flatImageIdIndexToImageIdIndex(e){return e%this._imageIdGroups[0].length}get splittingTag(){return this._splittingTag}isDimensionGroupLoaded(e){return this._loadedDimensionGroups.has(e)}markDimensionGroupAsLoaded(e){this._loadedDimensionGroups.add(e),E(y,M.DYNAMIC_VOLUME_DIMENSION_GROUP_LOADED,{volumeId:this.volumeId,dimensionGroupNumber:e})}checkDimensionGroupCompletion(e){const t=this.flatImageIdIndexToDimensionGroupNumber(e);this._imageIdGroups[t-1].every(s=>{const i=this.getImageIdIndex(s);return this.cachedFrames[i]===ue.FULL_RESOLUTION})&&!this.isDimensionGroupLoaded(t)&&this.markDimensionGroupAsLoaded(t)}}function Qe(l,e,t){return e.reduce((n,o)=>o.apply(n,t),l)}const Xe={name:"InPlaneDecimationModifier",apply(l,e){const[t=1,n=t]=e.options.ijkDecimation??[],o=Math.max(1,Math.floor(t)),s=Math.max(1,Math.floor(n));if(o===1&&s===1)return l;const[i,a]=l.dimensions,r=Math.max(1,Math.floor(i/o)),d=Math.max(1,Math.floor(a/s)),g=[r,d,l.dimensions[2]],m=[l.spacing[0]*o,l.spacing[1]*s,l.spacing[2]],p={...l.metadata,Columns:r,Rows:d,PixelSpacing:[m[1],m[0]]};return{...l,dimensions:g,spacing:m,metadata:p}}};function lt(l,e){if(!e||!e.imageIds||!e.imageIds.length)throw new Error("ImageIds must be provided to create a streaming image volume ");const[t=1,n=t,o=1]=e.ijkDecimation??[],s=Math.max(1,Math.floor(t)),i=n>1?Math.max(1,Math.floor(n)):s,a=Math.max(1,Math.floor(o)),r=s>1||i>1,d={ijkDecimation:[s,i,a]},g=[Xe];function m(c,u){return u===1?c:`${c}#decimation=${u}`}const p=Math.floor(e.imageIds.length/a),x=a>1&&e.imageIds.length<=p+1;if(a>1&&!x){const c=pe(e.imageIds,a),u=Array.isArray(c)&&c.length&&typeof c[0]=="number"?c.map(P=>e.imageIds[P]):c;e.imageIds=u}s>1&&(e.imageIds=e.imageIds.map(c=>m(c,s)));async function f(){const c=N(e.imageIds,l),u={volumeId:l,imageIds:e.imageIds,options:d},P=Qe(c,g,u),{dimensions:I,spacing:R,origin:w,direction:V,metadata:_,imageIds:b,dataType:B,numberOfComponents:z}=P,C=new xe({volumeId:l,metadata:_,dimensions:I,spacing:R,origin:w,direction:V,imageIds:b,dataType:B,numberOfComponents:z},{imageIds:b,loadStatus:{loaded:!1,loading:!1,cancelled:!1,cachedFrames:[],callbacks:[]}});if(r){const D=C.imageData;D&&(D.setDimensions(C.dimensions),D.setSpacing(C.spacing),D.modified());const T=j.createImageVolumeVoxelManager({dimensions:C.dimensions,imageIds:C.imageIds,numberOfComponents:z});C.voxelManager=T,D&&D.set({voxelManager:T})}return C}const h=f();return{promise:h,decache:()=>{h.then(c=>{c.destroy(),c=null})},cancel:()=>{h.then(c=>{c.cancelLoading()})}}}function gt(l,e){if(!e||!e.imageIds||!e.imageIds.length)throw new Error("ImageIds must be provided to create a 4D streaming image volume");const{imageIds:t}=e,{splittingTag:n,imageIdGroups:o}=we(t),s=Math.floor(o.length/2),i=N(o[s],l),{metadata:a,dimensions:r,spacing:d,direction:g,sizeInBytes:m,origin:p,numberOfComponents:x,dataType:f}=i,h=g.slice(6,9),c=o.map(R=>fe(R,h).sortedImageIds),u=c.flat(),P=j.createScalarDynamicVolumeVoxelManager({dimensions:r,imageIdGroups:c,dimensionGroupNumber:1,numberOfComponents:x});let I=new Ye({volumeId:l,metadata:a,dimensions:r,spacing:d,origin:p,direction:g,sizeInBytes:m,imageIds:u,imageIdGroups:c,splittingTag:n,voxelManager:P,numberOfComponents:x,dataType:f},{imageIds:u,loadStatus:{loaded:!1,loading:!1,cancelled:!1,cachedFrames:[],callbacks:[]}});return{promise:Promise.resolve(I),decache:()=>{I.destroy(),I=null},cancel:()=>{I.cancelLoading()}}}const mt={GenericViewport:je,DefaultRenderPathResolver:Ne,defaultRenderPathResolver:Le,ECGGenericViewport:Ae,createDefaultECGRenderPaths:Oe,createECGRenderPathResolver:ke,DefaultECGDataProvider:Fe,ecgProjection:$e,VideoGenericViewport:We,createDefaultVideoRenderPaths:Te,createVideoRenderPathResolver:ze,DefaultVideoDataProvider:be,videoProjection:qe,PlanarViewport:ye,createDefaultPlanarRenderPaths:Ge,createPlanarRenderPathResolver:_e,DefaultPlanarDataProvider:Me,planarProjection:Ze,VolumeViewport3D:Ee,createDefaultVolume3DRenderPaths:ve,createVolume3DRenderPathResolver:Se,DefaultVolume3DDataProvider:Re,volume3DProjection:Je,WSIGenericViewport:De,createDefaultWSIRenderPaths:Pe,createWSIRenderPathResolver:Ce,DefaultWSIDataProvider:Ve,wsiProjection:Ke},ht=Ie;export{xt as ActorRenderMode,U as BaseRenderingEngine,wt as BaseVolumeViewport,ft as CONSTANTS,A as ContextPoolRenderingEngine,Fe as DefaultECGDataProvider,Me as DefaultPlanarDataProvider,Ne as DefaultRenderPathResolver,be as DefaultVideoDataProvider,Re as DefaultVolume3DDataProvider,Ve as DefaultWSIDataProvider,Ae as ECGGenericViewport,It as ECGViewport,Vt as EPSILON,M as EVENTS,Ct as Enums,je as GenericViewport,Ee as GenericVolumeViewport3D,Pt as ImageVolume,ht as LegacyVolumeViewport3D,ye as PlanarViewport,Dt as ProgressiveRetrieveImages,Rt as RenderBackends,dt as RenderingEngine,St as Settings,vt as StackViewport,Ye as StreamingDynamicImageVolume,xe as StreamingImageVolume,Et as Surface,He as TiledRenderingEngine,We as VideoGenericViewport,Mt as VideoViewport,_t as Viewport,Gt as ViewportProjectionService,yt as VolumeViewport,Ie as VolumeViewport3D,De as WSIGenericViewport,bt as WSIViewport,rt as addImageSlicesToViewports,Wn as addVolumesToViewports,zt as cache,Tt as canRenderFloatTextures,Wt as convertColorArrayToRgbString,Ft as convertMapperToNotSharedMapper,kt as cornerstoneMeshLoader,gt as cornerstoneStreamingDynamicImageVolumeLoader,Ot as cornerstoneStreamingImageVolumeLoader,At as createCanvas,Oe as createDefaultECGRenderPaths,Ge as createDefaultPlanarRenderPaths,Te as createDefaultVideoRenderPaths,ve as createDefaultVolume3DRenderPaths,Pe as createDefaultWSIRenderPaths,ke as createECGRenderPathResolver,_e as createPlanarRenderPathResolver,ze as createVideoRenderPathResolver,Lt as createViewportElement,Se as createVolume3DRenderPathResolver,Nt as createVolumeActor,jt as createVolumeMapper,Ce as createWSIRenderPathResolver,lt as decimatedVolumeLoader,Le as defaultRenderPathResolver,Bt as detectRenderingCapabilities,$e as ecgProjection,y as eventTarget,Ht as geometryLoader,L as getConfiguration,Ut as getEffectiveRenderBackend,Rn as getEnabledElement,Sn as getEnabledElementByIds,vn as getEnabledElementByViewportId,En as getEnabledElements,S as getOrCreateCanvas,$t as getProjectionScaleMatrix,qt as getRenderBackend,Zt as getRenderingCapabilities,Jt as getRenderingEngine,Kt as getRenderingEngines,Yt as getShouldUseCPURendering,Qt as getUseGenericViewport,Xt as getWebWorkerManager,en as imageLoadPoolManager,tn as imageLoader,nn as imageRetrievalPoolManager,sn as init,on as isCornerstoneInitialized,an as isRegisteredRenderBackend,rn as isRegisteredViewportType,dn as metaData,cn as peerImport,Ze as planarProjection,ln as registerImageLoader,gn as registerRenderBackend,mn as registerViewportType,mt as renderingEngineExportsV2,hn as requestPoolManager,un as resetInitialization,pn as resetUseCPURendering,xn as setCanvasCreator,wn as setConfiguration,fn as setPreferSizeOverAccuracy,In as setRenderBackend,Vn as setUseCPURendering,Mn as setVolumesForViewports,E as triggerEvent,G as updateCanvasSizeAndAspectRatio,_n as utilities,ct as version,qe as videoProjection,Gn as viewportHasCanvasWorldTransform,yn as viewportHasFrameOfReferenceUID,bn as viewportHasPan,zn as viewportHasZoom,Cn as viewportProjection,Je as volume3DProjection,Pn as volumeLoader,Ke as wsiProjection};
1
+ import{v as H,B as U,t as E,E as M,g as L,a as W,b as S,u as G,s as $,V as q,c as Z,e as y,i as F,d as k,f as v,R as O,h as J,j as K,k as Y,l as Q,m as X,n as ee,o as te,p as ne,r as se,q as oe,w as ie,x as ae,y as re,z as de,A as ce,C as le,D as ge,F as me,G as he,I as ue,H as pe,J as N,S as xe,K as j,L as we,M as fe,N as Ie,O as Ve,P as Ce,Q as Pe,W as De,T as Re,U as Se,X as ve,Y as Ee,Z as Me,_ as _e,$ as Ge,a0 as ye,a1 as be,a2 as ze,a3 as Te,a4 as We,a5 as Fe,a6 as ke,a7 as Oe,a8 as Ae,a9 as Le,aa as Ne,ab as je}from"./Settings-CpJHgU8P.js";import{ac as xt,ad as wt,ae as ft,af as It,ag as Vt,ah as Ct,ai as Pt,aj as Dt,ak as Rt,al as St,am as vt,an as Et,ao as Mt,ap as _t,aq as Gt,ar as yt,as as bt,at as zt,au as Tt,av as Wt,aw as Ft,ax as kt,ay as Ot,az as At,aA as Lt,aB as Nt,aC as jt,aD as Bt,aE as Ht,aF as Ut,aG as $t,aH as qt,aI as Zt,aJ as Jt,aK as Kt,aL as Yt,aM as Qt,aN as Xt,aO as en,aP as tn,aQ as nn,aR as sn,aS as on,aT as an,aU as rn,aV as dn,aW as cn,aX as ln,aY as gn,aZ as mn,aO as hn,a_ as un,a$ as pn,b0 as xn,b1 as wn,b2 as fn,b3 as In,b4 as Vn,b5 as Cn,b6 as Pn}from"./Settings-CpJHgU8P.js";import{a as Be,T as He}from"./index-CokKuJob.js";import{g as Rn,b as Sn,c as vn,d as En,s as Mn,u as _n,v as Gn,e as yn,f as bn,h as zn}from"./index-CokKuJob.js";import"./cornerstoneEngine-DgoPMn1N.js";import"./Texture-BFywN4BL.js";import{a as Wn}from"./addVolumesToViewports-CKWYzwhw.js";import"./dcmjs.es-DfWkgqfk.js";import"./index-Bm3uV1GS.js";import"./_commonjsHelpers-CE1G-McA.js";function rt(l,e,t){for(const n of t){const o=l.getViewport(n);if(!o)throw new Error(`Viewport with Id ${n} does not exist`);if(!o.addImages){console.warn(`Viewport with Id ${n} does not have addImages. Cannot add image segmentation to this viewport.`);return}}t.forEach(n=>{l.getViewport(n).addImages(e)})}class Ue{constructor(e,t=""){this.contexts=[],this.offScreenCanvasContainers=[],this.viewportToContext=new Map,this.viewportSizes=new Map,this.contextMaxSizes=new Map;for(let n=0;n<e;n++){const o=H.newInstance(),s=document.createElement("div");o.setContainer(s),Be(o,t,n),this.contexts.push(o),this.offScreenCanvasContainers.push(s)}}getContextByIndex(e){return e>=0&&e<this.contexts.length?{context:this.contexts[e],container:this.offScreenCanvasContainers[e]}:null}assignViewportToContext(e,t){this.viewportToContext.set(e,t)}getContextIndexForViewport(e){return this.viewportToContext.get(e)}getAllContexts(){return this.contexts}getContextCount(){return this.contexts.length}updateViewportSize(e,t,n){const o=this.viewportToContext.get(e);if(o===void 0)return!1;this.viewportSizes.set(e,{width:t,height:n});const s=this.contextMaxSizes.get(o),i=this.calculateMaxSizeForContext(o);return this.contextMaxSizes.set(o,i),!s||s.width!==i.width||s.height!==i.height}getMaxSizeForContext(e){return this.contextMaxSizes.get(e)}calculateMaxSizeForContext(e){let t=0,n=0;return this.viewportToContext.forEach((o,s)=>{if(o===e){const i=this.viewportSizes.get(s);i&&(t=Math.max(t,i.width),n=Math.max(n,i.height))}}),{width:t,height:n}}removeViewport(e){const t=this.viewportToContext.get(e);if(this.viewportToContext.delete(e),this.viewportSizes.delete(e),t!==void 0){const n=this.calculateMaxSizeForContext(t);this.contextMaxSizes.set(t,n)}}destroy(){this.contexts.forEach(e=>{e.delete()}),this.contexts=[],this.offScreenCanvasContainers=[],this.viewportToContext.clear(),this.viewportSizes.clear(),this.contextMaxSizes.clear()}}class A extends U{constructor(e){super(e),this._renderFlaggedViewports=()=>{this._throwIfDestroyed();const n=this._getViewportsAsArray().filter(s=>this._needsRender.has(s.id));if(n.length===0){this._animationFrameSet=!1,this._animationFrameHandle=null;return}const o=n.map(s=>{const i=this.renderViewportUsingCustomOrVtkPipeline(s);return s.setRendered(),this._needsRender.delete(s.id),i});this._animationFrameSet=!1,this._animationFrameHandle=null,o.forEach(s=>{s?.element&&E(s.element,M.IMAGE_RENDERED,s)})},this.useCPURendering||this.ensureContextPool()}ensureContextPool(){if(!this.contextPool){const{rendering:e}=L(),{webGlContextCount:t}=e;this.contextPool=new Ue(t,this.id)}return this.contextPool}enableVTKjsDrivenViewport(e){const o=this._getViewportsAsArray().filter(a=>W(a.type)===!1).map(a=>a.canvas),s=S(e.element);G(s),o.push(s);const i={...e,canvas:s};this.addVtkjsDrivenViewport(i)}addVtkjsDrivenViewport(e){const t=this.ensureContextPool(),{element:n,canvas:o,viewportId:s,type:i,defaultOptions:a}=e;n.tabIndex=-1,$(n);let r=0;if(i===q.STACK){const u=t.getAllContexts();r=this._viewports.size%u.length}t.assignViewportToContext(s,r),t.updateViewportSize(s,o.width,o.height);const d=t.getContextByIndex(r),{context:g,container:m}=d,p=t.getMaxSizeForContext(r);m.width=p.width,m.height=p.height,g.resize(),g.addRenderer({viewport:[0,0,1,1],id:s,background:a.background?a.background:[0,0,0]});const x={id:s,element:n,renderingEngineId:this.id,type:i,canvas:o,sx:0,sy:0,sWidth:o.width,sHeight:o.height,defaultOptions:a||{}},f=Z(e);if(!f)throw new Error(`Viewport Type ${i} is not supported`);const h=new f(x);h.requestedType=e.requestedType??i,this._viewports.set(s,h);const c={element:n,viewportId:s,renderingEngineId:this.id};h.suppressEvents||E(y,M.ELEMENT_ENABLED,c)}setVtkjsDrivenViewports(e){if(e.length){const t=e.map(n=>S(n.element));t.forEach(n=>G(n));for(let n=0;n<e.length;n++){const o=e[n],s=t[n],i={...o,canvas:s};this.addVtkjsDrivenViewport(i)}}}_getDisplayedSize(e){const t=window.devicePixelRatio||1,n=F(e)?e.element:S(e.element);return{displayedWidth:Math.round(n.clientWidth*t),displayedHeight:Math.round(n.clientHeight*t)}}_resizeVTKViewports(e,t=!0,n=!0){const o=[];for(const s of e){const i=S(s.element),{displayedWidth:a,displayedHeight:r}=this._getDisplayedSize(s);if(a===0||r===0)continue;const d=i.width,g=i.height;a===d&&r===g||o.push(s)}if(o.length!==0){for(const s of o){const{displayedWidth:i,displayedHeight:a}=this._getDisplayedSize(s),r=Math.max(v,i),d=Math.max(v,a);s.sWidth=r,s.sHeight=d}this._animationFrameSet||(e.length&&this._resize(e),e.forEach(s=>{if(s.resize?.(),F(s))return;const i=s.getCamera(),a=s.getRotation?.()??0,{flipHorizontal:r}=i,d=s;d.resetViewStateForResize?d.resetViewStateForResize():d.resetCameraForResize?.();const g=s.getDisplayArea();t&&(g?(r&&s.setCamera({flipHorizontal:r}),a&&s.setViewPresentation({rotation:a})):s.setCamera(i))}),n&&this.render())}}renderViewportUsingCustomOrVtkPipeline(e){if(k(e))return e.customRenderViewportToCanvas();if(!this.contextPool)throw new Error("GPU not available, and using a viewport with no custom render pipeline.");const t=this.contextPool.getContextIndexForViewport(e.id),n=this.contextPool.getContextByIndex(t),{context:o,container:s}=n;return this._renderViewportWithContext(e,o,s)}_renderViewportWithContext(e,t,n){if(e.canvas.clientWidth===0||e.canvas.clientHeight===0)return;if(e.sWidth<v||e.sHeight<v){console.warn("Viewport is too small",e.sWidth,e.sHeight);return}if(k(e))return e.customRenderViewportToCanvas();if(!this.contextPool)throw new Error("GPU not available, and using a viewport with no custom render pipeline.");t.getRenderer(e.id)||t.addRenderer({viewport:[0,0,1,1],id:e.id,background:e.defaultOptions?.background||[0,0,0]});const o=t.getRenderWindow(),s=o.getViews()[0],i=s.getRenderPasses(),a=this.getViewportRenderPasses(e.id);a&&s.setRenderPasses(a),this._resizeOffScreenCanvasForViewport(e,n,t);const r=t.getRenderer(e.id),d=this.contextPool.getContextIndexForViewport(e.id),g=this.contextPool.getMaxSizeForContext(d),m=e.sWidth,p=e.sHeight,x=Math.min(1,m/g.width),f=Math.min(1,p/g.height);r.setViewport(0,0,x,f);const h=t.getRenderers();h.forEach(({renderer:w,id:V})=>{const _=V.split("::")[0];w.setDraw(_===e.id)});const c=this.getWidgetRenderers();c.forEach((w,V)=>{V.setDraw(w===e.id)}),o.render(),h.forEach(({renderer:w})=>w.setDraw(!1)),c.forEach((w,V)=>{V.setDraw(!1)}),i&&s.setRenderPasses(i);const I=t.getOpenGLRenderWindow().get3DContext().canvas;return this._copyToOnscreenCanvas(e,I)}_renderViewportFromVtkCanvasToOnscreenCanvas(e,t){return this._copyToOnscreenCanvas(e,t)}_resizeOffScreenCanvasForViewport(e,t,n){const o=this.contextPool.getContextIndexForViewport(e.id);if(o===void 0||!this.contextPool.updateViewportSize(e.id,e.sWidth,e.sHeight))return;const i=this.contextPool.getMaxSizeForContext(o);t.width===i.width&&t.height===i.height||(t.width=i.width,t.height=i.height,n.resize())}_copyToOnscreenCanvas(e,t){const{element:n,canvas:o,id:s,renderingEngineId:i,suppressEvents:a}=e,r=e.sWidth,d=e.sHeight;G(o,{width:r,height:d});const g=o.getContext("2d"),m=this.contextPool.getContextIndexForViewport(s),x=this.contextPool.getMaxSizeForContext(m).height-d;return g.drawImage(t,0,x,r,d,0,0,r,d),{element:n,suppressEvents:a,viewportId:s,renderingEngineId:i,viewportStatus:e.viewportStatus}}_resize(e){const t=new Set;for(const n of e){n.sx=0,n.sy=0;const o=this.contextPool.getContextIndexForViewport(n.id);this.contextPool.updateViewportSize(n.id,n.sWidth,n.sHeight)&&t.add(o);const i=this.contextPool.getContextByIndex(o),{context:a}=i,r=a.getRenderer(n.id),d=this.contextPool.getMaxSizeForContext(o),g=Math.min(1,n.sWidth/d.width),m=Math.min(1,n.sHeight/d.height);r.setViewport(0,0,g,m)}t.forEach(n=>{const o=this.contextPool.getContextByIndex(n);if(o){const{context:s,container:i}=o,a=this.contextPool.getMaxSizeForContext(n);i.width=a.width,i.height=a.height,s.resize()}})}getWidgetRenderers(){const e=this._getViewportsAsArray(),t=new Map;return e.forEach(n=>{(n.getWidgets?n.getWidgets():[]).forEach(s=>{const i=s.getRenderer?s.getRenderer():null;i&&t.set(i,n.id)})}),t}getViewportRenderPasses(e){const t=this.getViewport(e);return t?.getRenderPasses?t.getRenderPasses():null}getRenderer(e){const t=this.contextPool?.getContextIndexForViewport(e);if(t===void 0||!this.contextPool)return;const n=this.contextPool.getContextByIndex(t);if(!n)return;const{context:o}=n;return o.getRenderer(e)}disableElement(e){const t=this.getViewport(e);if(t&&(super.disableElement(e),!W(t.type)&&this.contextPool)){const n=this.contextPool.getContextIndexForViewport(e);if(n!==void 0){const o=this.contextPool.getContextByIndex(n);if(o){const{context:s}=o;s.removeRenderer(e)}}this.contextPool.removeViewport(e)}}destroy(){super.destroy(),this.contextPool&&this.contextPool.destroy()}getOffscreenMultiRenderWindow(e){if(!this.contextPool)throw new Error("Offscreen multi render window is not available.");const t=this.contextPool.getContextIndexForViewport(e);if(t===void 0)throw new Error(`Offscreen multi render window is not available for viewport ${e}.`);const n=this.contextPool.getContextByIndex(t);if(!n)throw new Error(`Offscreen multi render window is not available for viewport ${e}.`);return n.context}}class dt{constructor(e){const n=L()?.rendering?.renderingEngineMode;switch(n){case O.Tiled:this._implementation=new He(e);break;case O.ContextPool:this._implementation=new A(e);break;default:console.warn(`RenderingEngine: Unknown rendering engine mode "${n}". Defaulting to Next rendering engine.`),this._implementation=new A(e);break}}get id(){return this._implementation.id}disableViewport(e){return this._implementation.disableElement(e)}enableElement(e){return this._implementation.enableElement(e)}disableElement(e){return this._implementation.disableElement(e)}setViewports(e){return this._implementation.setViewports(e)}resize(e=!0,t=!0){return this._implementation.resize(e,t)}getViewport(e){return this._implementation.getViewport(e)}getViewports(){return this._implementation.getViewports()}getRenderer(e){return this._implementation.getRenderer(e)}fillCanvasWithBackgroundColor(e,t){return this._implementation.fillCanvasWithBackgroundColor(e,t)}render(){return this._implementation.render()}renderViewports(e){return this._implementation.renderViewports(e)}renderViewport(e){return this._implementation.renderViewport(e)}destroy(){return this._implementation.destroy()}getOffscreenMultiRenderWindow(e){return this._implementation.getOffscreenMultiRenderWindow(e)}}const $e={adapter:K,getSnapshot:J},qe={adapter:Q,getSnapshot:Y},Ze={adapter:de,getSnapshot:re,getZoom:ae,getScale:ie,getPan:oe,resolveICamera:se,derivePresentation:ne,applyToRenderer:te,createImageSliceBasis:ee,createVolumeSliceBasis:X},Je={adapter:le,getSnapshot:ce},Ke={adapter:me,getSnapshot:ge},ct="5.8.2";class Ye extends he{constructor(e,t){super(e,t),this._dimensionGroupNumber=1,this._loadedDimensionGroups=new Set,this._getImageIdRequests=(s,i)=>this.getImageIdsRequests(s,i),this.getImageLoadRequests=s=>{const i=this.getImageIdsToLoad();return this._getImageIdRequests(i,s)};const{imageIdGroups:n,splittingTag:o}=e;this._splittingTag=o,this._imageIdGroups=n,this.numDimensionGroups=this._imageIdGroups.length}_getImageIdsToLoad(){const e=this._imageIdGroups,t=this._dimensionGroupNumber-1,n=[...e[t]];let o=t-1,s=t+1;for(;o>=0||s<e.length;)o>=0&&n.push(...e[o--]),s<e.length&&n.push(...e[s++]);return n}getImageIdsToLoad(){return this._getImageIdsToLoad()}get dimensionGroupNumber(){return this._dimensionGroupNumber}set dimensionGroupNumber(e){this._dimensionGroupNumber!==e&&(this._dimensionGroupNumber=e,this.voxelManager.setDimensionGroupNumber(e),this.invalidateVolume(!0),E(y,M.DYNAMIC_VOLUME_DIMENSION_GROUP_CHANGED,{volumeId:this.volumeId,dimensionGroupNumber:e,numDimensionGroups:this.numDimensionGroups,imageIdGroupIndex:e-1,numImageIdGroups:this.numDimensionGroups,splittingTag:this.splittingTag}))}scroll(e){const t=this._dimensionGroupNumber+e;t<1?this.dimensionGroupNumber=this.numDimensionGroups:t>this.numDimensionGroups?this.dimensionGroupNumber=1:this.dimensionGroupNumber=t}getCurrentDimensionGroupImageIds(){return this._imageIdGroups[this._dimensionGroupNumber-1]}flatImageIdIndexToDimensionGroupNumber(e){return Math.floor(e/this._imageIdGroups[0].length)+1}flatImageIdIndexToImageIdIndex(e){return e%this._imageIdGroups[0].length}get splittingTag(){return this._splittingTag}isDimensionGroupLoaded(e){return this._loadedDimensionGroups.has(e)}markDimensionGroupAsLoaded(e){this._loadedDimensionGroups.add(e),E(y,M.DYNAMIC_VOLUME_DIMENSION_GROUP_LOADED,{volumeId:this.volumeId,dimensionGroupNumber:e})}checkDimensionGroupCompletion(e){const t=this.flatImageIdIndexToDimensionGroupNumber(e);this._imageIdGroups[t-1].every(s=>{const i=this.getImageIdIndex(s);return this.cachedFrames[i]===ue.FULL_RESOLUTION})&&!this.isDimensionGroupLoaded(t)&&this.markDimensionGroupAsLoaded(t)}}function Qe(l,e,t){return e.reduce((n,o)=>o.apply(n,t),l)}const Xe={name:"InPlaneDecimationModifier",apply(l,e){const[t=1,n=t]=e.options.ijkDecimation??[],o=Math.max(1,Math.floor(t)),s=Math.max(1,Math.floor(n));if(o===1&&s===1)return l;const[i,a]=l.dimensions,r=Math.max(1,Math.floor(i/o)),d=Math.max(1,Math.floor(a/s)),g=[r,d,l.dimensions[2]],m=[l.spacing[0]*o,l.spacing[1]*s,l.spacing[2]],p={...l.metadata,Columns:r,Rows:d,PixelSpacing:[m[1],m[0]]};return{...l,dimensions:g,spacing:m,metadata:p}}};function lt(l,e){if(!e||!e.imageIds||!e.imageIds.length)throw new Error("ImageIds must be provided to create a streaming image volume ");const[t=1,n=t,o=1]=e.ijkDecimation??[],s=Math.max(1,Math.floor(t)),i=n>1?Math.max(1,Math.floor(n)):s,a=Math.max(1,Math.floor(o)),r=s>1||i>1,d={ijkDecimation:[s,i,a]},g=[Xe];function m(c,u){return u===1?c:`${c}#decimation=${u}`}const p=Math.floor(e.imageIds.length/a),x=a>1&&e.imageIds.length<=p+1;if(a>1&&!x){const c=pe(e.imageIds,a),u=Array.isArray(c)&&c.length&&typeof c[0]=="number"?c.map(P=>e.imageIds[P]):c;e.imageIds=u}s>1&&(e.imageIds=e.imageIds.map(c=>m(c,s)));async function f(){const c=N(e.imageIds,l),u={volumeId:l,imageIds:e.imageIds,options:d},P=Qe(c,g,u),{dimensions:I,spacing:R,origin:w,direction:V,metadata:_,imageIds:b,dataType:B,numberOfComponents:z}=P,C=new xe({volumeId:l,metadata:_,dimensions:I,spacing:R,origin:w,direction:V,imageIds:b,dataType:B,numberOfComponents:z},{imageIds:b,loadStatus:{loaded:!1,loading:!1,cancelled:!1,cachedFrames:[],callbacks:[]}});if(r){const D=C.imageData;D&&(D.setDimensions(C.dimensions),D.setSpacing(C.spacing),D.modified());const T=j.createImageVolumeVoxelManager({dimensions:C.dimensions,imageIds:C.imageIds,numberOfComponents:z});C.voxelManager=T,D&&D.set({voxelManager:T})}return C}const h=f();return{promise:h,decache:()=>{h.then(c=>{c.destroy(),c=null})},cancel:()=>{h.then(c=>{c.cancelLoading()})}}}function gt(l,e){if(!e||!e.imageIds||!e.imageIds.length)throw new Error("ImageIds must be provided to create a 4D streaming image volume");const{imageIds:t}=e,{splittingTag:n,imageIdGroups:o}=we(t),s=Math.floor(o.length/2),i=N(o[s],l),{metadata:a,dimensions:r,spacing:d,direction:g,sizeInBytes:m,origin:p,numberOfComponents:x,dataType:f}=i,h=g.slice(6,9),c=o.map(R=>fe(R,h).sortedImageIds),u=c.flat(),P=j.createScalarDynamicVolumeVoxelManager({dimensions:r,imageIdGroups:c,dimensionGroupNumber:1,numberOfComponents:x});let I=new Ye({volumeId:l,metadata:a,dimensions:r,spacing:d,origin:p,direction:g,sizeInBytes:m,imageIds:u,imageIdGroups:c,splittingTag:n,voxelManager:P,numberOfComponents:x,dataType:f},{imageIds:u,loadStatus:{loaded:!1,loading:!1,cancelled:!1,cachedFrames:[],callbacks:[]}});return{promise:Promise.resolve(I),decache:()=>{I.destroy(),I=null},cancel:()=>{I.cancelLoading()}}}const mt={GenericViewport:je,DefaultRenderPathResolver:Ne,defaultRenderPathResolver:Le,ECGGenericViewport:Ae,createDefaultECGRenderPaths:Oe,createECGRenderPathResolver:ke,DefaultECGDataProvider:Fe,ecgProjection:$e,VideoGenericViewport:We,createDefaultVideoRenderPaths:Te,createVideoRenderPathResolver:ze,DefaultVideoDataProvider:be,videoProjection:qe,PlanarViewport:ye,createDefaultPlanarRenderPaths:Ge,createPlanarRenderPathResolver:_e,DefaultPlanarDataProvider:Me,planarProjection:Ze,VolumeViewport3D:Ee,createDefaultVolume3DRenderPaths:ve,createVolume3DRenderPathResolver:Se,DefaultVolume3DDataProvider:Re,volume3DProjection:Je,WSIGenericViewport:De,createDefaultWSIRenderPaths:Pe,createWSIRenderPathResolver:Ce,DefaultWSIDataProvider:Ve,wsiProjection:Ke},ht=Ie;export{xt as ActorRenderMode,U as BaseRenderingEngine,wt as BaseVolumeViewport,ft as CONSTANTS,A as ContextPoolRenderingEngine,Fe as DefaultECGDataProvider,Me as DefaultPlanarDataProvider,Ne as DefaultRenderPathResolver,be as DefaultVideoDataProvider,Re as DefaultVolume3DDataProvider,Ve as DefaultWSIDataProvider,Ae as ECGGenericViewport,It as ECGViewport,Vt as EPSILON,M as EVENTS,Ct as Enums,je as GenericViewport,Ee as GenericVolumeViewport3D,Pt as ImageVolume,ht as LegacyVolumeViewport3D,ye as PlanarViewport,Dt as ProgressiveRetrieveImages,Rt as RenderBackends,dt as RenderingEngine,St as Settings,vt as StackViewport,Ye as StreamingDynamicImageVolume,xe as StreamingImageVolume,Et as Surface,He as TiledRenderingEngine,We as VideoGenericViewport,Mt as VideoViewport,_t as Viewport,Gt as ViewportProjectionService,yt as VolumeViewport,Ie as VolumeViewport3D,De as WSIGenericViewport,bt as WSIViewport,rt as addImageSlicesToViewports,Wn as addVolumesToViewports,zt as cache,Tt as canRenderFloatTextures,Wt as convertColorArrayToRgbString,Ft as convertMapperToNotSharedMapper,kt as cornerstoneMeshLoader,gt as cornerstoneStreamingDynamicImageVolumeLoader,Ot as cornerstoneStreamingImageVolumeLoader,At as createCanvas,Oe as createDefaultECGRenderPaths,Ge as createDefaultPlanarRenderPaths,Te as createDefaultVideoRenderPaths,ve as createDefaultVolume3DRenderPaths,Pe as createDefaultWSIRenderPaths,ke as createECGRenderPathResolver,_e as createPlanarRenderPathResolver,ze as createVideoRenderPathResolver,Lt as createViewportElement,Se as createVolume3DRenderPathResolver,Nt as createVolumeActor,jt as createVolumeMapper,Ce as createWSIRenderPathResolver,lt as decimatedVolumeLoader,Le as defaultRenderPathResolver,Bt as detectRenderingCapabilities,$e as ecgProjection,y as eventTarget,Ht as geometryLoader,L as getConfiguration,Ut as getEffectiveRenderBackend,Rn as getEnabledElement,Sn as getEnabledElementByIds,vn as getEnabledElementByViewportId,En as getEnabledElements,S as getOrCreateCanvas,$t as getProjectionScaleMatrix,qt as getRenderBackend,Zt as getRenderingCapabilities,Jt as getRenderingEngine,Kt as getRenderingEngines,Yt as getShouldUseCPURendering,Qt as getUseGenericViewport,Xt as getWebWorkerManager,en as imageLoadPoolManager,tn as imageLoader,nn as imageRetrievalPoolManager,sn as init,on as isCornerstoneInitialized,an as isRegisteredRenderBackend,rn as isRegisteredViewportType,dn as metaData,cn as peerImport,Ze as planarProjection,ln as registerImageLoader,gn as registerRenderBackend,mn as registerViewportType,mt as renderingEngineExportsV2,hn as requestPoolManager,un as resetInitialization,pn as resetUseCPURendering,xn as setCanvasCreator,wn as setConfiguration,fn as setPreferSizeOverAccuracy,In as setRenderBackend,Vn as setUseCPURendering,Mn as setVolumesForViewports,E as triggerEvent,G as updateCanvasSizeAndAspectRatio,_n as utilities,ct as version,qe as videoProjection,Gn as viewportHasCanvasWorldTransform,yn as viewportHasFrameOfReferenceUID,bn as viewportHasPan,zn as viewportHasZoom,Cn as viewportProjection,Je as volume3DProjection,Pn as volumeLoader,Ke as wsiProjection};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./blosc-CrUiACa7.js","./chunk-INHXZS53-D3tQiqtZ.js","./lz4-B_Exjfmr.js","./zstd-u5eweWyS.js"])))=>i.map(i=>d[i]);
2
- import{g as va}from"./_commonjsHelpers-CE1G-McA.js";import{_ as Mi}from"./index-Dtsm0q-Z.js";var _t=1e-6,Ae=typeof Float32Array<"u"?Float32Array:Array;function qi(){var t=new Ae(9);return Ae!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function wa(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}function He(t,e,i,r,s,n,a,o,l){var c=new Ae(9);return c[0]=t,c[1]=e,c[2]=i,c[3]=r,c[4]=s,c[5]=n,c[6]=a,c[7]=o,c[8]=l,c}function ya(t,e){var i=e[0],r=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=h*a-o*c,f=-h*n+o*l,u=c*n-a*l,m=i*d+r*f+s*u;return m?(m=1/m,t[0]=d*m,t[1]=(-h*r+s*c)*m,t[2]=(o*r-s*a)*m,t[3]=f*m,t[4]=(h*i-s*l)*m,t[5]=(-o*i+s*n)*m,t[6]=u*m,t[7]=(-c*i+r*l)*m,t[8]=(a*i-r*n)*m,t):null}function Hs(t,e,i){var r=e[0],s=e[1],n=e[2],a=e[3],o=e[4],l=e[5],c=e[6],h=e[7],d=e[8],f=i[0],u=i[1],m=i[2],p=i[3],g=i[4],x=i[5],A=i[6],y=i[7],v=i[8];return t[0]=f*r+u*a+m*c,t[1]=f*s+u*o+m*h,t[2]=f*n+u*l+m*d,t[3]=p*r+g*a+x*c,t[4]=p*s+g*o+x*h,t[5]=p*n+g*l+x*d,t[6]=A*r+y*a+v*c,t[7]=A*s+y*o+v*h,t[8]=A*n+y*l+v*d,t}function J(){var t=new Ae(16);return Ae!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function de(t){var e=new Ae(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function ba(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Ee(t,e,i,r,s,n,a,o,l,c,h,d,f,u,m,p){var g=new Ae(16);return g[0]=t,g[1]=e,g[2]=i,g[3]=r,g[4]=s,g[5]=n,g[6]=a,g[7]=o,g[8]=l,g[9]=c,g[10]=h,g[11]=d,g[12]=f,g[13]=u,g[14]=m,g[15]=p,g}function qs(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Te(t,e){if(t===e){var i=e[1],r=e[2],s=e[3],n=e[6],a=e[7],o=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=i,t[6]=e[9],t[7]=e[13],t[8]=r,t[9]=n,t[11]=e[14],t[12]=s,t[13]=a,t[14]=o}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Se(t,e){var i=e[0],r=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=e[9],f=e[10],u=e[11],m=e[12],p=e[13],g=e[14],x=e[15],A=i*o-r*a,y=i*l-s*a,v=i*c-n*a,b=r*l-s*o,w=r*c-n*o,C=s*c-n*l,M=h*p-d*m,T=h*g-f*m,E=h*x-u*m,I=d*g-f*p,S=d*x-u*p,U=f*x-u*g,B=A*U-y*S+v*I+b*E-w*T+C*M;return B?(B=1/B,t[0]=(o*U-l*S+c*I)*B,t[1]=(s*S-r*U-n*I)*B,t[2]=(p*C-g*w+x*b)*B,t[3]=(f*w-d*C-u*b)*B,t[4]=(l*E-a*U-c*T)*B,t[5]=(i*U-s*E+n*T)*B,t[6]=(g*v-m*C-x*y)*B,t[7]=(h*C-f*v+u*y)*B,t[8]=(a*S-o*E+c*M)*B,t[9]=(r*E-i*S-n*M)*B,t[10]=(m*w-p*v+x*A)*B,t[11]=(d*v-h*w-u*A)*B,t[12]=(o*T-a*I-l*M)*B,t[13]=(i*I-r*T+s*M)*B,t[14]=(p*y-m*b-g*A)*B,t[15]=(h*b-d*y+f*A)*B,t):null}function Ye(t,e,i){var r=e[0],s=e[1],n=e[2],a=e[3],o=e[4],l=e[5],c=e[6],h=e[7],d=e[8],f=e[9],u=e[10],m=e[11],p=e[12],g=e[13],x=e[14],A=e[15],y=i[0],v=i[1],b=i[2],w=i[3];return t[0]=y*r+v*o+b*d+w*p,t[1]=y*s+v*l+b*f+w*g,t[2]=y*n+v*c+b*u+w*x,t[3]=y*a+v*h+b*m+w*A,y=i[4],v=i[5],b=i[6],w=i[7],t[4]=y*r+v*o+b*d+w*p,t[5]=y*s+v*l+b*f+w*g,t[6]=y*n+v*c+b*u+w*x,t[7]=y*a+v*h+b*m+w*A,y=i[8],v=i[9],b=i[10],w=i[11],t[8]=y*r+v*o+b*d+w*p,t[9]=y*s+v*l+b*f+w*g,t[10]=y*n+v*c+b*u+w*x,t[11]=y*a+v*h+b*m+w*A,y=i[12],v=i[13],b=i[14],w=i[15],t[12]=y*r+v*o+b*d+w*p,t[13]=y*s+v*l+b*f+w*g,t[14]=y*n+v*c+b*u+w*x,t[15]=y*a+v*h+b*m+w*A,t}function tt(t,e,i){var r=i[0],s=i[1],n=i[2],a,o,l,c,h,d,f,u,m,p,g,x;return e===t?(t[12]=e[0]*r+e[4]*s+e[8]*n+e[12],t[13]=e[1]*r+e[5]*s+e[9]*n+e[13],t[14]=e[2]*r+e[6]*s+e[10]*n+e[14],t[15]=e[3]*r+e[7]*s+e[11]*n+e[15]):(a=e[0],o=e[1],l=e[2],c=e[3],h=e[4],d=e[5],f=e[6],u=e[7],m=e[8],p=e[9],g=e[10],x=e[11],t[0]=a,t[1]=o,t[2]=l,t[3]=c,t[4]=h,t[5]=d,t[6]=f,t[7]=u,t[8]=m,t[9]=p,t[10]=g,t[11]=x,t[12]=a*r+h*s+m*n+e[12],t[13]=o*r+d*s+p*n+e[13],t[14]=l*r+f*s+g*n+e[14],t[15]=c*r+u*s+x*n+e[15]),t}function fr(t,e,i){var r=i[0],s=i[1],n=i[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Ut(t,e,i){var r=Math.sin(i),s=Math.cos(i),n=e[4],a=e[5],o=e[6],l=e[7],c=e[8],h=e[9],d=e[10],f=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=n*s+c*r,t[5]=a*s+h*r,t[6]=o*s+d*r,t[7]=l*s+f*r,t[8]=c*s-n*r,t[9]=h*s-a*r,t[10]=d*s-o*r,t[11]=f*s-l*r,t}function Ca(t,e,i){var r=Math.sin(i),s=Math.cos(i),n=e[0],a=e[1],o=e[2],l=e[3],c=e[8],h=e[9],d=e[10],f=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*s-c*r,t[1]=a*s-h*r,t[2]=o*s-d*r,t[3]=l*s-f*r,t[8]=n*r+c*s,t[9]=a*r+h*s,t[10]=o*r+d*s,t[11]=l*r+f*s,t}function Rt(t,e,i){var r=Math.sin(i),s=Math.cos(i),n=e[0],a=e[1],o=e[2],l=e[3],c=e[4],h=e[5],d=e[6],f=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*s+c*r,t[1]=a*s+h*r,t[2]=o*s+d*r,t[3]=l*s+f*r,t[4]=c*s-n*r,t[5]=h*s-a*r,t[6]=d*s-o*r,t[7]=f*s-l*r,t}function Ma(t,e,i){var r=i[0],s=i[1],n=i[2],a=Math.sqrt(r*r+s*s+n*n),o,l,c;return a<_t?null:(a=1/a,r*=a,s*=a,n*=a,o=Math.sin(e),l=Math.cos(e),c=1-l,t[0]=r*r*c+l,t[1]=s*r*c+n*o,t[2]=n*r*c-s*o,t[3]=0,t[4]=r*s*c-n*o,t[5]=s*s*c+l,t[6]=n*s*c+r*o,t[7]=0,t[8]=r*n*c+s*o,t[9]=s*n*c-r*o,t[10]=n*n*c+l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function Da(t,e,i,r,s,n,a){var o=1/(e-i),l=1/(r-s),c=1/(n-a);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+i)*o,t[13]=(s+r)*l,t[14]=(a+n)*c,t[15]=1,t}var hi=Da;function Ta(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12]*i,t[13]=e[13]*i,t[14]=e[14]*i,t[15]=e[15]*i,t}var Qs=Ye;function se(){var t=new Ae(3);return Ae!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Ve(t){var e=new Ae(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Qe(t){var e=t[0],i=t[1],r=t[2];return Math.sqrt(e*e+i*i+r*r)}function k(t,e,i){var r=new Ae(3);return r[0]=t,r[1]=e,r[2]=i,r}function Hr(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function it(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}function ne(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function ur(t,e,i){return t[0]=Math.min(e[0],i[0]),t[1]=Math.min(e[1],i[1]),t[2]=Math.min(e[2],i[2]),t}function mr(t,e,i){return t[0]=Math.max(e[0],i[0]),t[1]=Math.max(e[1],i[1]),t[2]=Math.max(e[2],i[2]),t}function Sa(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function Ea(t,e){var i=e[0]-t[0],r=e[1]-t[1],s=e[2]-t[2];return Math.sqrt(i*i+r*r+s*s)}function Ia(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function Ie(t,e){var i=e[0],r=e[1],s=e[2],n=i*i+r*r+s*s;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function Fa(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Jt(t,e,i){var r=e[0],s=e[1],n=e[2],a=i[0],o=i[1],l=i[2];return t[0]=s*l-n*o,t[1]=n*a-r*l,t[2]=r*o-s*a,t}function Ba(t,e,i,r){var s=e[0],n=e[1],a=e[2];return t[0]=s+r*(i[0]-s),t[1]=n+r*(i[1]-n),t[2]=a+r*(i[2]-a),t}function qr(t,e,i){var r=e[0],s=e[1],n=e[2];return t[0]=r*i[0]+s*i[3]+n*i[6],t[1]=r*i[1]+s*i[4]+n*i[7],t[2]=r*i[2]+s*i[5]+n*i[8],t}function Di(t,e){var i=t[0],r=t[1],s=t[2],n=e[0],a=e[1],o=e[2],l=Math.sqrt((i*i+r*r+s*s)*(n*n+a*a+o*o)),c=l&&Fa(t,e)/l;return Math.acos(Math.min(Math.max(c,-1),1))}function Ua(t,e){var i=t[0],r=t[1],s=t[2],n=e[0],a=e[1],o=e[2];return Math.abs(i-n)<=_t*Math.max(1,Math.abs(i),Math.abs(n))&&Math.abs(r-a)<=_t*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(s-o)<=_t*Math.max(1,Math.abs(s),Math.abs(o))}var Qr=ne,Vt=Qe;(function(){var t=se();return function(e,i,r,s,n,a){var o,l;for(i||(i=3),r||(r=0),s?l=Math.min(s*i+r,e.length):l=e.length,o=r;o<l;o+=i)t[0]=e[o],t[1]=e[o+1],t[2]=e[o+2],n(t,t,a),e[o]=t[0],e[o+1]=t[1],e[o+2]=t[2];return e}})();function Xe(){var t=new Ae(4);return Ae!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function ze(t){var e=new Ae(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function ae(t,e,i,r){var s=new Ae(4);return s[0]=t,s[1]=e,s[2]=i,s[3]=r,s}function Zr(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t[3]=e[3]+i[3],t}function Ra(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t[3]=e[3]-i[3],t}function Va(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t}function ve(t,e,i){var r=e[0],s=e[1],n=e[2],a=e[3];return t[0]=i[0]*r+i[4]*s+i[8]*n+i[12]*a,t[1]=i[1]*r+i[5]*s+i[9]*n+i[13]*a,t[2]=i[2]*r+i[6]*s+i[10]*n+i[14]*a,t[3]=i[3]*r+i[7]*s+i[11]*n+i[15]*a,t}var Pa=Ra;(function(){var t=Xe();return function(e,i,r,s,n,a){var o,l;for(i||(i=4),r||(r=0),s?l=Math.min(s*i+r,e.length):l=e.length,o=r;o<l;o+=i)t[0]=e[o],t[1]=e[o+1],t[2]=e[o+2],t[3]=e[o+3],n(t,t,a),e[o]=t[0],e[o+1]=t[1],e[o+2]=t[2],e[o+3]=t[3];return e}})();function Na(){var t=new Ae(2);return Ae!=Float32Array&&(t[0]=0,t[1]=0),t}function La(t,e){var i=new Ae(2);return i[0]=t,i[1]=e,i}(function(){var t=Na();return function(e,i,r,s,n,a){var o,l;for(i||(i=2),r||(r=0),s?l=Math.min(s*i+r,e.length):l=e.length,o=r;o<l;o+=i)t[0]=e[o],t[1]=e[o+1],n(t,t,a),e[o]=t[0],e[o+1]=t[1];return e}})();var et=256,$t=[],Yt;for(;et--;)$t[et]=(et+256).toString(16).substring(1);function di(){var t=0,e,i="";if(!Yt||et+16>256){for(Yt=Array(t=256);t--;)Yt[t]=256*Math.random()|0;t=et=0}for(;t<16;t++)e=Yt[et+t],t==6?i+=$t[e&15|64]:t==8?i+=$t[e&63|128]:i+=$t[e],t&1&&t>1&&t<11&&(i+="-");return et++,i}var Ti,jr;function ka(){return jr||(jr=1,Ti=function(e,i){var r=e.length;if(e===i)return!0;if(r!==i.length)return!1;for(var s=0;s<r;s++)if(e[s]!==i[s])return!1;return!0}),Ti}var Oa=ka();const za=va(Oa);var ge=Uint8Array,ut=Uint16Array,Ga=Int32Array,Zs=new ge([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),js=new ge([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ya=new ge([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),_s=function(t,e){for(var i=new ut(31),r=0;r<31;++r)i[r]=e+=1<<t[r-1];for(var s=new Ga(i[30]),r=1;r<30;++r)for(var n=i[r];n<i[r+1];++n)s[n]=n-i[r]<<5|r;return{b:i,r:s}},Js=_s(Zs,2),$s=Js.b,Xa=Js.r;$s[28]=258,Xa[258]=28;var Wa=_s(js,0),Ka=Wa.b,Qi=new ut(32768);for(var oe=0;oe<32768;++oe){var We=(oe&43690)>>1|(oe&21845)<<1;We=(We&52428)>>2|(We&13107)<<2,We=(We&61680)>>4|(We&3855)<<4,Qi[oe]=((We&65280)>>8|(We&255)<<8)>>1}var Ft=(function(t,e,i){for(var r=t.length,s=0,n=new ut(e);s<r;++s)t[s]&&++n[t[s]-1];var a=new ut(e);for(s=1;s<e;++s)a[s]=a[s-1]+n[s-1]<<1;var o;if(i){o=new ut(1<<e);var l=15-e;for(s=0;s<r;++s)if(t[s])for(var c=s<<4|t[s],h=e-t[s],d=a[t[s]-1]++<<h,f=d|(1<<h)-1;d<=f;++d)o[Qi[d]>>l]=c}else for(o=new ut(r),s=0;s<r;++s)t[s]&&(o[s]=Qi[a[t[s]-1]++]>>15-t[s]);return o}),Pt=new ge(288);for(var oe=0;oe<144;++oe)Pt[oe]=8;for(var oe=144;oe<256;++oe)Pt[oe]=9;for(var oe=256;oe<280;++oe)Pt[oe]=7;for(var oe=280;oe<288;++oe)Pt[oe]=8;var en=new ge(32);for(var oe=0;oe<32;++oe)en[oe]=5;var Ha=Ft(Pt,9,1),qa=Ft(en,5,1),Si=function(t){for(var e=t[0],i=1;i<t.length;++i)t[i]>e&&(e=t[i]);return e},Be=function(t,e,i){var r=e/8|0;return(t[r]|t[r+1]<<8)>>(e&7)&i},Ei=function(t,e){var i=e/8|0;return(t[i]|t[i+1]<<8|t[i+2]<<16)>>(e&7)},tn=function(t){return(t+7)/8|0},ei=function(t,e,i){return(e==null||e<0)&&(e=0),(i==null||i>t.length)&&(i=t.length),new ge(t.subarray(e,i))},Qa=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ye=function(t,e,i){var r=new Error(e||Qa[t]);if(r.code=t,Error.captureStackTrace&&Error.captureStackTrace(r,ye),!i)throw r;return r},Ai=function(t,e,i,r){var s=t.length,n=0;if(!s||e.f&&!e.l)return i||new ge(0);var a=!i,o=a||e.i!=2,l=e.i;a&&(i=new ge(s*3));var c=function(at){var _e=i.length;if(at>_e){var Fe=new ge(Math.max(_e*2,at));Fe.set(i),i=Fe}},h=e.f||0,d=e.p||0,f=e.b||0,u=e.l,m=e.d,p=e.m,g=e.n,x=s*8;do{if(!u){h=Be(t,d,1);var A=Be(t,d+1,3);if(d+=3,A)if(A==1)u=Ha,m=qa,p=9,g=5;else if(A==2){var w=Be(t,d,31)+257,C=Be(t,d+10,15)+4,M=w+Be(t,d+5,31)+1;d+=14;for(var T=new ge(M),E=new ge(19),I=0;I<C;++I)E[Ya[I]]=Be(t,d+I*3,7);d+=C*3;for(var S=Si(E),U=(1<<S)-1,B=Ft(E,S,1),I=0;I<M;){var V=B[Be(t,d,U)];d+=V&15;var y=V>>4;if(y<16)T[I++]=y;else{var R=0,P=0;for(y==16?(P=3+Be(t,d,3),d+=2,R=T[I-1]):y==17?(P=3+Be(t,d,7),d+=3):y==18&&(P=11+Be(t,d,127),d+=7);P--;)T[I++]=R}}var L=T.subarray(0,w),N=T.subarray(w);p=Si(L),g=Si(N),u=Ft(L,p,1),m=Ft(N,g,1)}else ye(1);else{var y=tn(d)+4,v=t[y-4]|t[y-3]<<8,b=y+v;if(b>s){l&&ye(0);break}o&&c(f+v),i.set(t.subarray(y,b),f),e.b=f+=v,e.p=d=b*8,e.f=h;continue}if(d>x){l&&ye(0);break}}o&&c(f+131072);for(var Y=(1<<p)-1,_=(1<<g)-1,z=d;;z=d){var R=u[Ei(t,d)&Y],W=R>>4;if(d+=R&15,d>x){l&&ye(0);break}if(R||ye(2),W<256)i[f++]=W;else if(W==256){z=d,u=null;break}else{var K=W-254;if(W>264){var I=W-257,Z=Zs[I];K=Be(t,d,(1<<Z)-1)+$s[I],d+=Z}var q=m[Ei(t,d)&_],te=q>>4;q||ye(3),d+=q&15;var N=Ka[te];if(te>3){var Z=js[te];N+=Ei(t,d)&(1<<Z)-1,d+=Z}if(d>x){l&&ye(0);break}o&&c(f+131072);var ue=f+K;if(f<N){var le=n-N,je=Math.min(N,ue);for(le+f<0&&ye(3);f<je;++f)i[f]=r[le+f]}for(;f<ue;++f)i[f]=i[f-N]}}e.l=u,e.p=z,e.b=f,e.f=h,u&&(h=1,e.m=p,e.d=m,e.n=g)}while(!h);return f!=i.length&&a?ei(i,0,f):i.subarray(0,f)},Za=new ge(0),rn=function(t){(t[0]!=31||t[1]!=139||t[2]!=8)&&ye(6,"invalid gzip data");var e=t[3],i=10;e&4&&(i+=(t[10]|t[11]<<8)+2);for(var r=(e>>3&1)+(e>>4&1);r>0;r-=!t[i++]);return i+(e&2)},ja=function(t){var e=t.length;return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0},_a=function(t,e){return((t[0]&15)!=8||t[0]>>4>7||(t[0]<<8|t[1])%31)&&ye(6,"invalid zlib data"),(t[1]>>5&1)==1&&ye(6,"invalid zlib data: "+(t[1]&32?"need":"unexpected")+" dictionary"),(t[1]>>3&4)+2},Xt=(function(){function t(e,i){typeof e=="function"&&(i=e,e={}),this.ondata=i;var r=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:r?r.length:0},this.o=new ge(32768),this.p=new ge(0),r&&this.o.set(r)}return t.prototype.e=function(e){if(this.ondata||ye(5),this.d&&ye(4),!this.p.length)this.p=e;else if(e.length){var i=new ge(this.p.length+e.length);i.set(this.p),i.set(e,this.p.length),this.p=i}},t.prototype.c=function(e){this.s.i=+(this.d=e||!1);var i=this.s.b,r=Ai(this.p,this.s,this.o);this.ondata(ei(r,i,this.s.b),this.d),this.o=ei(r,this.s.b-32768),this.s.b=this.o.length,this.p=ei(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(e,i){this.e(e),this.c(i)},t})();function Ja(t,e){return Ai(t,{i:2},e,e)}var $a=(function(){function t(e,i){this.v=1,this.r=0,Xt.call(this,e,i)}return t.prototype.push=function(e,i){if(Xt.prototype.e.call(this,e),this.r+=e.length,this.v){var r=this.p.subarray(this.v-1),s=r.length>3?rn(r):4;if(s>r.length){if(!i)return}else this.v>1&&this.onmember&&this.onmember(this.r-r.length);this.p=r.subarray(s),this.v=0}Xt.prototype.c.call(this,0),this.s.f&&!this.s.l?(this.v=tn(this.s.p)+9,this.s={i:0},this.o=new ge(0),this.push(new ge(0),i)):i&&Xt.prototype.c.call(this,i)},t})();function eo(t,e){var i=rn(t);return i+8>t.length&&ye(6,"invalid gzip data"),Ai(t.subarray(i,-8),{i:2},new ge(ja(t)),e)}function to(t,e){return Ai(t.subarray(_a(t),-4),{i:2},e,e)}function io(t,e){return t[0]==31&&t[1]==139&&t[2]==8?eo(t,e):(t[0]&15)!=8||t[0]>>4>7||(t[0]<<8|t[1])%31?Ja(t,e):to(t,e)}var ro=typeof TextDecoder<"u"&&new TextDecoder,so=0;try{ro.decode(Za,{stream:!0}),so=1}catch{}class sn{esize;ecode;edata;littleEndian;constructor(e,i,r,s){if(e%16!=0)throw new Error("This does not appear to be a NIFTI extension");this.esize=e,this.ecode=i,this.edata=r,this.littleEndian=s}toArrayBuffer(){let e=new Uint8Array(this.esize),i=new Uint8Array(this.edata);e.set(i,8);let r=new DataView(e.buffer);return r.setInt32(0,this.esize,this.littleEndian),r.setInt32(4,this.ecode,this.littleEndian),e.buffer}}class O{static crcTable=null;static GUNZIP_MAGIC_COOKIE1=31;static GUNZIP_MAGIC_COOKIE2=139;static getStringAt(e,i,r){var s="",n,a;for(n=i;n<r;n+=1)a=e.getUint8(n),a!==0&&(s+=String.fromCharCode(a));return s}static getByteAt=function(e,i){return e.getUint8(i)};static getShortAt=function(e,i,r){return e.getInt16(i,r)};static getIntAt(e,i,r){return e.getInt32(i,r)}static getFloatAt(e,i,r){return e.getFloat32(i,r)}static getDoubleAt(e,i,r){return e.getFloat64(i,r)}static getInt64At(e,i,r){const s=e.getUint32(i,r),n=e.getInt32(i+4,r);let a;return r?a=n*2**32+s:a=s*2**32+n,n<0&&(a+=-1*2**32*2**32),a}static getUint64At(e,i,r){const s=e.getUint32(i+(r?0:4),r),n=e.getUint32(i+(r?4:0),r);return r?n*2**32+s:s*2**32+n}static getExtensionsAt(e,i,r,s){let n=[],a=i;for(;a<s;){let o=r,l=O.getIntAt(e,a,r);if(!l)break;if(l+a>s&&(o=!o,l=O.getIntAt(e,a,o),l+a>s))throw new Error("This does not appear to be a valid NIFTI extension");if(l%16!=0)throw new Error("This does not appear to be a NIFTI extension");let c=O.getIntAt(e,a+4,o),h=e.buffer.slice(a+8,a+l),d=new sn(l,c,h,o);n.push(d),a+=l}return n}static toArrayBuffer(e){var i,r,s;for(i=new ArrayBuffer(e.length),r=new Uint8Array(i),s=0;s<e.length;s+=1)r[s]=e[s];return i}static isString(e){return typeof e=="string"||e instanceof String}static formatNumber(e,i=void 0){let r;return O.isString(e)?r=Number(e):r=e,i?r=r.toPrecision(5):r=r.toPrecision(7),parseFloat(r)}static makeCRCTable(){let e,i=[];for(var r=0;r<256;r++){e=r;for(var s=0;s<8;s++)e=e&1?3988292384^e>>>1:e>>>1;i[r]=e}return i}static crc32(e){O.crcTable||(O.crcTable=O.makeCRCTable());const i=O.crcTable;let r=-1;for(var s=0;s<e.byteLength;s++)r=r>>>8^i[(r^e.getUint8(s))&255];return(r^-1)>>>0}}class G{littleEndian=!1;dim_info=0;dims=[];intent_p1=0;intent_p2=0;intent_p3=0;intent_code=0;datatypeCode=0;numBitsPerVoxel=0;slice_start=0;slice_end=0;slice_code=0;pixDims=[];vox_offset=0;scl_slope=1;scl_inter=0;xyzt_units=0;cal_max=0;cal_min=0;slice_duration=0;toffset=0;description="";aux_file="";intent_name="";qform_code=0;sform_code=0;quatern_a=0;quatern_b=0;quatern_c=0;quatern_d=0;qoffset_x=0;qoffset_y=0;qoffset_z=0;affine=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];qfac=1;quatern_R;magic="0";isHDR=!1;extensionFlag=[0,0,0,0];extensionSize=0;extensionCode=0;extensions=[];static TYPE_NONE=0;static TYPE_BINARY=1;static TYPE_UINT8=2;static TYPE_INT16=4;static TYPE_INT32=8;static TYPE_FLOAT32=16;static TYPE_COMPLEX64=32;static TYPE_FLOAT64=64;static TYPE_RGB24=128;static TYPE_INT8=256;static TYPE_UINT16=512;static TYPE_UINT32=768;static TYPE_INT64=1024;static TYPE_UINT64=1280;static TYPE_FLOAT128=1536;static TYPE_COMPLEX128=1792;static TYPE_COMPLEX256=2048;static XFORM_UNKNOWN=0;static XFORM_SCANNER_ANAT=1;static XFORM_ALIGNED_ANAT=2;static XFORM_TALAIRACH=3;static XFORM_MNI_152=4;static SPATIAL_UNITS_MASK=7;static TEMPORAL_UNITS_MASK=56;static UNITS_UNKNOWN=0;static UNITS_METER=1;static UNITS_MM=2;static UNITS_MICRON=3;static UNITS_SEC=8;static UNITS_MSEC=16;static UNITS_USEC=24;static UNITS_HZ=32;static UNITS_PPM=40;static UNITS_RADS=48;static MAGIC_COOKIE=348;static STANDARD_HEADER_SIZE=348;static MAGIC_NUMBER_LOCATION=344;static MAGIC_NUMBER=[110,43,49];static MAGIC_NUMBER2=[110,105,49];static EXTENSION_HEADER_SIZE=8;readHeader(e){var i=new DataView(e),r=O.getIntAt(i,0,this.littleEndian),s,n,a,o;if(r!==G.MAGIC_COOKIE&&(this.littleEndian=!0,r=O.getIntAt(i,0,this.littleEndian)),r!==G.MAGIC_COOKIE)throw new Error("This does not appear to be a NIFTI file!");for(this.dim_info=O.getByteAt(i,39),s=0;s<8;s+=1)o=40+s*2,this.dims[s]=O.getShortAt(i,o,this.littleEndian);for(this.intent_p1=O.getFloatAt(i,56,this.littleEndian),this.intent_p2=O.getFloatAt(i,60,this.littleEndian),this.intent_p3=O.getFloatAt(i,64,this.littleEndian),this.intent_code=O.getShortAt(i,68,this.littleEndian),this.datatypeCode=O.getShortAt(i,70,this.littleEndian),this.numBitsPerVoxel=O.getShortAt(i,72,this.littleEndian),this.slice_start=O.getShortAt(i,74,this.littleEndian),s=0;s<8;s+=1)o=76+s*4,this.pixDims[s]=O.getFloatAt(i,o,this.littleEndian);if(this.vox_offset=O.getFloatAt(i,108,this.littleEndian),this.scl_slope=O.getFloatAt(i,112,this.littleEndian),this.scl_inter=O.getFloatAt(i,116,this.littleEndian),this.slice_end=O.getShortAt(i,120,this.littleEndian),this.slice_code=O.getByteAt(i,122),this.xyzt_units=O.getByteAt(i,123),this.cal_max=O.getFloatAt(i,124,this.littleEndian),this.cal_min=O.getFloatAt(i,128,this.littleEndian),this.slice_duration=O.getFloatAt(i,132,this.littleEndian),this.toffset=O.getFloatAt(i,136,this.littleEndian),this.description=O.getStringAt(i,148,228),this.aux_file=O.getStringAt(i,228,252),this.qform_code=O.getShortAt(i,252,this.littleEndian),this.sform_code=O.getShortAt(i,254,this.littleEndian),this.quatern_b=O.getFloatAt(i,256,this.littleEndian),this.quatern_c=O.getFloatAt(i,260,this.littleEndian),this.quatern_d=O.getFloatAt(i,264,this.littleEndian),this.quatern_a=Math.sqrt(1-(Math.pow(this.quatern_b,2)+Math.pow(this.quatern_c,2)+Math.pow(this.quatern_d,2))),this.qoffset_x=O.getFloatAt(i,268,this.littleEndian),this.qoffset_y=O.getFloatAt(i,272,this.littleEndian),this.qoffset_z=O.getFloatAt(i,276,this.littleEndian),this.qform_code<1&&this.sform_code<1&&(this.affine[0][0]=this.pixDims[1],this.affine[1][1]=this.pixDims[2],this.affine[2][2]=this.pixDims[3]),this.qform_code>0&&this.sform_code<this.qform_code){const l=this.quatern_a,c=this.quatern_b,h=this.quatern_c,d=this.quatern_d;for(this.qfac=this.pixDims[0]===0?1:this.pixDims[0],this.quatern_R=[[l*l+c*c-h*h-d*d,2*c*h-2*l*d,2*c*d+2*l*h],[2*c*h+2*l*d,l*l+h*h-c*c-d*d,2*h*d-2*l*c],[2*c*d-2*l*h,2*h*d+2*l*c,l*l+d*d-h*h-c*c]],n=0;n<3;n+=1)for(a=0;a<3;a+=1)this.affine[n][a]=this.quatern_R[n][a]*this.pixDims[a+1],a===2&&(this.affine[n][a]*=this.qfac);this.affine[0][3]=this.qoffset_x,this.affine[1][3]=this.qoffset_y,this.affine[2][3]=this.qoffset_z}else if(this.sform_code>0)for(n=0;n<3;n+=1)for(a=0;a<4;a+=1)o=280+(n*4+a)*4,this.affine[n][a]=O.getFloatAt(i,o,this.littleEndian);if(this.affine[3][0]=0,this.affine[3][1]=0,this.affine[3][2]=0,this.affine[3][3]=1,this.intent_name=O.getStringAt(i,328,344),this.magic=O.getStringAt(i,344,348),this.isHDR=this.magic===String.fromCharCode.apply(null,G.MAGIC_NUMBER2),i.byteLength>G.MAGIC_COOKIE){this.extensionFlag[0]=O.getByteAt(i,348),this.extensionFlag[1]=O.getByteAt(i,349),this.extensionFlag[2]=O.getByteAt(i,350),this.extensionFlag[3]=O.getByteAt(i,351);let l=!0;!this.isHDR&&this.vox_offset<=352&&(l=!1),i.byteLength<=368&&(l=!1),l&&this.extensionFlag[0]&&(this.extensions=O.getExtensionsAt(i,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode)}}toFormattedString(){var e=O.formatNumber,i="";return i+="Dim Info = "+this.dim_info+`
2
+ import{g as va}from"./_commonjsHelpers-CE1G-McA.js";import{_ as Mi}from"./index-Bm3uV1GS.js";var _t=1e-6,Ae=typeof Float32Array<"u"?Float32Array:Array;function qi(){var t=new Ae(9);return Ae!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function wa(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}function He(t,e,i,r,s,n,a,o,l){var c=new Ae(9);return c[0]=t,c[1]=e,c[2]=i,c[3]=r,c[4]=s,c[5]=n,c[6]=a,c[7]=o,c[8]=l,c}function ya(t,e){var i=e[0],r=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=h*a-o*c,f=-h*n+o*l,u=c*n-a*l,m=i*d+r*f+s*u;return m?(m=1/m,t[0]=d*m,t[1]=(-h*r+s*c)*m,t[2]=(o*r-s*a)*m,t[3]=f*m,t[4]=(h*i-s*l)*m,t[5]=(-o*i+s*n)*m,t[6]=u*m,t[7]=(-c*i+r*l)*m,t[8]=(a*i-r*n)*m,t):null}function Hs(t,e,i){var r=e[0],s=e[1],n=e[2],a=e[3],o=e[4],l=e[5],c=e[6],h=e[7],d=e[8],f=i[0],u=i[1],m=i[2],p=i[3],g=i[4],x=i[5],A=i[6],y=i[7],v=i[8];return t[0]=f*r+u*a+m*c,t[1]=f*s+u*o+m*h,t[2]=f*n+u*l+m*d,t[3]=p*r+g*a+x*c,t[4]=p*s+g*o+x*h,t[5]=p*n+g*l+x*d,t[6]=A*r+y*a+v*c,t[7]=A*s+y*o+v*h,t[8]=A*n+y*l+v*d,t}function J(){var t=new Ae(16);return Ae!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function de(t){var e=new Ae(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function ba(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Ee(t,e,i,r,s,n,a,o,l,c,h,d,f,u,m,p){var g=new Ae(16);return g[0]=t,g[1]=e,g[2]=i,g[3]=r,g[4]=s,g[5]=n,g[6]=a,g[7]=o,g[8]=l,g[9]=c,g[10]=h,g[11]=d,g[12]=f,g[13]=u,g[14]=m,g[15]=p,g}function qs(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Te(t,e){if(t===e){var i=e[1],r=e[2],s=e[3],n=e[6],a=e[7],o=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=i,t[6]=e[9],t[7]=e[13],t[8]=r,t[9]=n,t[11]=e[14],t[12]=s,t[13]=a,t[14]=o}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Se(t,e){var i=e[0],r=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=e[9],f=e[10],u=e[11],m=e[12],p=e[13],g=e[14],x=e[15],A=i*o-r*a,y=i*l-s*a,v=i*c-n*a,b=r*l-s*o,w=r*c-n*o,C=s*c-n*l,M=h*p-d*m,T=h*g-f*m,E=h*x-u*m,I=d*g-f*p,S=d*x-u*p,U=f*x-u*g,B=A*U-y*S+v*I+b*E-w*T+C*M;return B?(B=1/B,t[0]=(o*U-l*S+c*I)*B,t[1]=(s*S-r*U-n*I)*B,t[2]=(p*C-g*w+x*b)*B,t[3]=(f*w-d*C-u*b)*B,t[4]=(l*E-a*U-c*T)*B,t[5]=(i*U-s*E+n*T)*B,t[6]=(g*v-m*C-x*y)*B,t[7]=(h*C-f*v+u*y)*B,t[8]=(a*S-o*E+c*M)*B,t[9]=(r*E-i*S-n*M)*B,t[10]=(m*w-p*v+x*A)*B,t[11]=(d*v-h*w-u*A)*B,t[12]=(o*T-a*I-l*M)*B,t[13]=(i*I-r*T+s*M)*B,t[14]=(p*y-m*b-g*A)*B,t[15]=(h*b-d*y+f*A)*B,t):null}function Ye(t,e,i){var r=e[0],s=e[1],n=e[2],a=e[3],o=e[4],l=e[5],c=e[6],h=e[7],d=e[8],f=e[9],u=e[10],m=e[11],p=e[12],g=e[13],x=e[14],A=e[15],y=i[0],v=i[1],b=i[2],w=i[3];return t[0]=y*r+v*o+b*d+w*p,t[1]=y*s+v*l+b*f+w*g,t[2]=y*n+v*c+b*u+w*x,t[3]=y*a+v*h+b*m+w*A,y=i[4],v=i[5],b=i[6],w=i[7],t[4]=y*r+v*o+b*d+w*p,t[5]=y*s+v*l+b*f+w*g,t[6]=y*n+v*c+b*u+w*x,t[7]=y*a+v*h+b*m+w*A,y=i[8],v=i[9],b=i[10],w=i[11],t[8]=y*r+v*o+b*d+w*p,t[9]=y*s+v*l+b*f+w*g,t[10]=y*n+v*c+b*u+w*x,t[11]=y*a+v*h+b*m+w*A,y=i[12],v=i[13],b=i[14],w=i[15],t[12]=y*r+v*o+b*d+w*p,t[13]=y*s+v*l+b*f+w*g,t[14]=y*n+v*c+b*u+w*x,t[15]=y*a+v*h+b*m+w*A,t}function tt(t,e,i){var r=i[0],s=i[1],n=i[2],a,o,l,c,h,d,f,u,m,p,g,x;return e===t?(t[12]=e[0]*r+e[4]*s+e[8]*n+e[12],t[13]=e[1]*r+e[5]*s+e[9]*n+e[13],t[14]=e[2]*r+e[6]*s+e[10]*n+e[14],t[15]=e[3]*r+e[7]*s+e[11]*n+e[15]):(a=e[0],o=e[1],l=e[2],c=e[3],h=e[4],d=e[5],f=e[6],u=e[7],m=e[8],p=e[9],g=e[10],x=e[11],t[0]=a,t[1]=o,t[2]=l,t[3]=c,t[4]=h,t[5]=d,t[6]=f,t[7]=u,t[8]=m,t[9]=p,t[10]=g,t[11]=x,t[12]=a*r+h*s+m*n+e[12],t[13]=o*r+d*s+p*n+e[13],t[14]=l*r+f*s+g*n+e[14],t[15]=c*r+u*s+x*n+e[15]),t}function fr(t,e,i){var r=i[0],s=i[1],n=i[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Ut(t,e,i){var r=Math.sin(i),s=Math.cos(i),n=e[4],a=e[5],o=e[6],l=e[7],c=e[8],h=e[9],d=e[10],f=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=n*s+c*r,t[5]=a*s+h*r,t[6]=o*s+d*r,t[7]=l*s+f*r,t[8]=c*s-n*r,t[9]=h*s-a*r,t[10]=d*s-o*r,t[11]=f*s-l*r,t}function Ca(t,e,i){var r=Math.sin(i),s=Math.cos(i),n=e[0],a=e[1],o=e[2],l=e[3],c=e[8],h=e[9],d=e[10],f=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*s-c*r,t[1]=a*s-h*r,t[2]=o*s-d*r,t[3]=l*s-f*r,t[8]=n*r+c*s,t[9]=a*r+h*s,t[10]=o*r+d*s,t[11]=l*r+f*s,t}function Rt(t,e,i){var r=Math.sin(i),s=Math.cos(i),n=e[0],a=e[1],o=e[2],l=e[3],c=e[4],h=e[5],d=e[6],f=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*s+c*r,t[1]=a*s+h*r,t[2]=o*s+d*r,t[3]=l*s+f*r,t[4]=c*s-n*r,t[5]=h*s-a*r,t[6]=d*s-o*r,t[7]=f*s-l*r,t}function Ma(t,e,i){var r=i[0],s=i[1],n=i[2],a=Math.sqrt(r*r+s*s+n*n),o,l,c;return a<_t?null:(a=1/a,r*=a,s*=a,n*=a,o=Math.sin(e),l=Math.cos(e),c=1-l,t[0]=r*r*c+l,t[1]=s*r*c+n*o,t[2]=n*r*c-s*o,t[3]=0,t[4]=r*s*c-n*o,t[5]=s*s*c+l,t[6]=n*s*c+r*o,t[7]=0,t[8]=r*n*c+s*o,t[9]=s*n*c-r*o,t[10]=n*n*c+l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function Da(t,e,i,r,s,n,a){var o=1/(e-i),l=1/(r-s),c=1/(n-a);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+i)*o,t[13]=(s+r)*l,t[14]=(a+n)*c,t[15]=1,t}var hi=Da;function Ta(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12]*i,t[13]=e[13]*i,t[14]=e[14]*i,t[15]=e[15]*i,t}var Qs=Ye;function se(){var t=new Ae(3);return Ae!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Ve(t){var e=new Ae(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Qe(t){var e=t[0],i=t[1],r=t[2];return Math.sqrt(e*e+i*i+r*r)}function k(t,e,i){var r=new Ae(3);return r[0]=t,r[1]=e,r[2]=i,r}function Hr(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function it(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}function ne(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function ur(t,e,i){return t[0]=Math.min(e[0],i[0]),t[1]=Math.min(e[1],i[1]),t[2]=Math.min(e[2],i[2]),t}function mr(t,e,i){return t[0]=Math.max(e[0],i[0]),t[1]=Math.max(e[1],i[1]),t[2]=Math.max(e[2],i[2]),t}function Sa(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function Ea(t,e){var i=e[0]-t[0],r=e[1]-t[1],s=e[2]-t[2];return Math.sqrt(i*i+r*r+s*s)}function Ia(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function Ie(t,e){var i=e[0],r=e[1],s=e[2],n=i*i+r*r+s*s;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function Fa(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Jt(t,e,i){var r=e[0],s=e[1],n=e[2],a=i[0],o=i[1],l=i[2];return t[0]=s*l-n*o,t[1]=n*a-r*l,t[2]=r*o-s*a,t}function Ba(t,e,i,r){var s=e[0],n=e[1],a=e[2];return t[0]=s+r*(i[0]-s),t[1]=n+r*(i[1]-n),t[2]=a+r*(i[2]-a),t}function qr(t,e,i){var r=e[0],s=e[1],n=e[2];return t[0]=r*i[0]+s*i[3]+n*i[6],t[1]=r*i[1]+s*i[4]+n*i[7],t[2]=r*i[2]+s*i[5]+n*i[8],t}function Di(t,e){var i=t[0],r=t[1],s=t[2],n=e[0],a=e[1],o=e[2],l=Math.sqrt((i*i+r*r+s*s)*(n*n+a*a+o*o)),c=l&&Fa(t,e)/l;return Math.acos(Math.min(Math.max(c,-1),1))}function Ua(t,e){var i=t[0],r=t[1],s=t[2],n=e[0],a=e[1],o=e[2];return Math.abs(i-n)<=_t*Math.max(1,Math.abs(i),Math.abs(n))&&Math.abs(r-a)<=_t*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(s-o)<=_t*Math.max(1,Math.abs(s),Math.abs(o))}var Qr=ne,Vt=Qe;(function(){var t=se();return function(e,i,r,s,n,a){var o,l;for(i||(i=3),r||(r=0),s?l=Math.min(s*i+r,e.length):l=e.length,o=r;o<l;o+=i)t[0]=e[o],t[1]=e[o+1],t[2]=e[o+2],n(t,t,a),e[o]=t[0],e[o+1]=t[1],e[o+2]=t[2];return e}})();function Xe(){var t=new Ae(4);return Ae!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function ze(t){var e=new Ae(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function ae(t,e,i,r){var s=new Ae(4);return s[0]=t,s[1]=e,s[2]=i,s[3]=r,s}function Zr(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t[3]=e[3]+i[3],t}function Ra(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t[3]=e[3]-i[3],t}function Va(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t}function ve(t,e,i){var r=e[0],s=e[1],n=e[2],a=e[3];return t[0]=i[0]*r+i[4]*s+i[8]*n+i[12]*a,t[1]=i[1]*r+i[5]*s+i[9]*n+i[13]*a,t[2]=i[2]*r+i[6]*s+i[10]*n+i[14]*a,t[3]=i[3]*r+i[7]*s+i[11]*n+i[15]*a,t}var Pa=Ra;(function(){var t=Xe();return function(e,i,r,s,n,a){var o,l;for(i||(i=4),r||(r=0),s?l=Math.min(s*i+r,e.length):l=e.length,o=r;o<l;o+=i)t[0]=e[o],t[1]=e[o+1],t[2]=e[o+2],t[3]=e[o+3],n(t,t,a),e[o]=t[0],e[o+1]=t[1],e[o+2]=t[2],e[o+3]=t[3];return e}})();function Na(){var t=new Ae(2);return Ae!=Float32Array&&(t[0]=0,t[1]=0),t}function La(t,e){var i=new Ae(2);return i[0]=t,i[1]=e,i}(function(){var t=Na();return function(e,i,r,s,n,a){var o,l;for(i||(i=2),r||(r=0),s?l=Math.min(s*i+r,e.length):l=e.length,o=r;o<l;o+=i)t[0]=e[o],t[1]=e[o+1],n(t,t,a),e[o]=t[0],e[o+1]=t[1];return e}})();var et=256,$t=[],Yt;for(;et--;)$t[et]=(et+256).toString(16).substring(1);function di(){var t=0,e,i="";if(!Yt||et+16>256){for(Yt=Array(t=256);t--;)Yt[t]=256*Math.random()|0;t=et=0}for(;t<16;t++)e=Yt[et+t],t==6?i+=$t[e&15|64]:t==8?i+=$t[e&63|128]:i+=$t[e],t&1&&t>1&&t<11&&(i+="-");return et++,i}var Ti,jr;function ka(){return jr||(jr=1,Ti=function(e,i){var r=e.length;if(e===i)return!0;if(r!==i.length)return!1;for(var s=0;s<r;s++)if(e[s]!==i[s])return!1;return!0}),Ti}var Oa=ka();const za=va(Oa);var ge=Uint8Array,ut=Uint16Array,Ga=Int32Array,Zs=new ge([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),js=new ge([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ya=new ge([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),_s=function(t,e){for(var i=new ut(31),r=0;r<31;++r)i[r]=e+=1<<t[r-1];for(var s=new Ga(i[30]),r=1;r<30;++r)for(var n=i[r];n<i[r+1];++n)s[n]=n-i[r]<<5|r;return{b:i,r:s}},Js=_s(Zs,2),$s=Js.b,Xa=Js.r;$s[28]=258,Xa[258]=28;var Wa=_s(js,0),Ka=Wa.b,Qi=new ut(32768);for(var oe=0;oe<32768;++oe){var We=(oe&43690)>>1|(oe&21845)<<1;We=(We&52428)>>2|(We&13107)<<2,We=(We&61680)>>4|(We&3855)<<4,Qi[oe]=((We&65280)>>8|(We&255)<<8)>>1}var Ft=(function(t,e,i){for(var r=t.length,s=0,n=new ut(e);s<r;++s)t[s]&&++n[t[s]-1];var a=new ut(e);for(s=1;s<e;++s)a[s]=a[s-1]+n[s-1]<<1;var o;if(i){o=new ut(1<<e);var l=15-e;for(s=0;s<r;++s)if(t[s])for(var c=s<<4|t[s],h=e-t[s],d=a[t[s]-1]++<<h,f=d|(1<<h)-1;d<=f;++d)o[Qi[d]>>l]=c}else for(o=new ut(r),s=0;s<r;++s)t[s]&&(o[s]=Qi[a[t[s]-1]++]>>15-t[s]);return o}),Pt=new ge(288);for(var oe=0;oe<144;++oe)Pt[oe]=8;for(var oe=144;oe<256;++oe)Pt[oe]=9;for(var oe=256;oe<280;++oe)Pt[oe]=7;for(var oe=280;oe<288;++oe)Pt[oe]=8;var en=new ge(32);for(var oe=0;oe<32;++oe)en[oe]=5;var Ha=Ft(Pt,9,1),qa=Ft(en,5,1),Si=function(t){for(var e=t[0],i=1;i<t.length;++i)t[i]>e&&(e=t[i]);return e},Be=function(t,e,i){var r=e/8|0;return(t[r]|t[r+1]<<8)>>(e&7)&i},Ei=function(t,e){var i=e/8|0;return(t[i]|t[i+1]<<8|t[i+2]<<16)>>(e&7)},tn=function(t){return(t+7)/8|0},ei=function(t,e,i){return(e==null||e<0)&&(e=0),(i==null||i>t.length)&&(i=t.length),new ge(t.subarray(e,i))},Qa=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ye=function(t,e,i){var r=new Error(e||Qa[t]);if(r.code=t,Error.captureStackTrace&&Error.captureStackTrace(r,ye),!i)throw r;return r},Ai=function(t,e,i,r){var s=t.length,n=0;if(!s||e.f&&!e.l)return i||new ge(0);var a=!i,o=a||e.i!=2,l=e.i;a&&(i=new ge(s*3));var c=function(at){var _e=i.length;if(at>_e){var Fe=new ge(Math.max(_e*2,at));Fe.set(i),i=Fe}},h=e.f||0,d=e.p||0,f=e.b||0,u=e.l,m=e.d,p=e.m,g=e.n,x=s*8;do{if(!u){h=Be(t,d,1);var A=Be(t,d+1,3);if(d+=3,A)if(A==1)u=Ha,m=qa,p=9,g=5;else if(A==2){var w=Be(t,d,31)+257,C=Be(t,d+10,15)+4,M=w+Be(t,d+5,31)+1;d+=14;for(var T=new ge(M),E=new ge(19),I=0;I<C;++I)E[Ya[I]]=Be(t,d+I*3,7);d+=C*3;for(var S=Si(E),U=(1<<S)-1,B=Ft(E,S,1),I=0;I<M;){var V=B[Be(t,d,U)];d+=V&15;var y=V>>4;if(y<16)T[I++]=y;else{var R=0,P=0;for(y==16?(P=3+Be(t,d,3),d+=2,R=T[I-1]):y==17?(P=3+Be(t,d,7),d+=3):y==18&&(P=11+Be(t,d,127),d+=7);P--;)T[I++]=R}}var L=T.subarray(0,w),N=T.subarray(w);p=Si(L),g=Si(N),u=Ft(L,p,1),m=Ft(N,g,1)}else ye(1);else{var y=tn(d)+4,v=t[y-4]|t[y-3]<<8,b=y+v;if(b>s){l&&ye(0);break}o&&c(f+v),i.set(t.subarray(y,b),f),e.b=f+=v,e.p=d=b*8,e.f=h;continue}if(d>x){l&&ye(0);break}}o&&c(f+131072);for(var Y=(1<<p)-1,_=(1<<g)-1,z=d;;z=d){var R=u[Ei(t,d)&Y],W=R>>4;if(d+=R&15,d>x){l&&ye(0);break}if(R||ye(2),W<256)i[f++]=W;else if(W==256){z=d,u=null;break}else{var K=W-254;if(W>264){var I=W-257,Z=Zs[I];K=Be(t,d,(1<<Z)-1)+$s[I],d+=Z}var q=m[Ei(t,d)&_],te=q>>4;q||ye(3),d+=q&15;var N=Ka[te];if(te>3){var Z=js[te];N+=Ei(t,d)&(1<<Z)-1,d+=Z}if(d>x){l&&ye(0);break}o&&c(f+131072);var ue=f+K;if(f<N){var le=n-N,je=Math.min(N,ue);for(le+f<0&&ye(3);f<je;++f)i[f]=r[le+f]}for(;f<ue;++f)i[f]=i[f-N]}}e.l=u,e.p=z,e.b=f,e.f=h,u&&(h=1,e.m=p,e.d=m,e.n=g)}while(!h);return f!=i.length&&a?ei(i,0,f):i.subarray(0,f)},Za=new ge(0),rn=function(t){(t[0]!=31||t[1]!=139||t[2]!=8)&&ye(6,"invalid gzip data");var e=t[3],i=10;e&4&&(i+=(t[10]|t[11]<<8)+2);for(var r=(e>>3&1)+(e>>4&1);r>0;r-=!t[i++]);return i+(e&2)},ja=function(t){var e=t.length;return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0},_a=function(t,e){return((t[0]&15)!=8||t[0]>>4>7||(t[0]<<8|t[1])%31)&&ye(6,"invalid zlib data"),(t[1]>>5&1)==1&&ye(6,"invalid zlib data: "+(t[1]&32?"need":"unexpected")+" dictionary"),(t[1]>>3&4)+2},Xt=(function(){function t(e,i){typeof e=="function"&&(i=e,e={}),this.ondata=i;var r=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:r?r.length:0},this.o=new ge(32768),this.p=new ge(0),r&&this.o.set(r)}return t.prototype.e=function(e){if(this.ondata||ye(5),this.d&&ye(4),!this.p.length)this.p=e;else if(e.length){var i=new ge(this.p.length+e.length);i.set(this.p),i.set(e,this.p.length),this.p=i}},t.prototype.c=function(e){this.s.i=+(this.d=e||!1);var i=this.s.b,r=Ai(this.p,this.s,this.o);this.ondata(ei(r,i,this.s.b),this.d),this.o=ei(r,this.s.b-32768),this.s.b=this.o.length,this.p=ei(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(e,i){this.e(e),this.c(i)},t})();function Ja(t,e){return Ai(t,{i:2},e,e)}var $a=(function(){function t(e,i){this.v=1,this.r=0,Xt.call(this,e,i)}return t.prototype.push=function(e,i){if(Xt.prototype.e.call(this,e),this.r+=e.length,this.v){var r=this.p.subarray(this.v-1),s=r.length>3?rn(r):4;if(s>r.length){if(!i)return}else this.v>1&&this.onmember&&this.onmember(this.r-r.length);this.p=r.subarray(s),this.v=0}Xt.prototype.c.call(this,0),this.s.f&&!this.s.l?(this.v=tn(this.s.p)+9,this.s={i:0},this.o=new ge(0),this.push(new ge(0),i)):i&&Xt.prototype.c.call(this,i)},t})();function eo(t,e){var i=rn(t);return i+8>t.length&&ye(6,"invalid gzip data"),Ai(t.subarray(i,-8),{i:2},new ge(ja(t)),e)}function to(t,e){return Ai(t.subarray(_a(t),-4),{i:2},e,e)}function io(t,e){return t[0]==31&&t[1]==139&&t[2]==8?eo(t,e):(t[0]&15)!=8||t[0]>>4>7||(t[0]<<8|t[1])%31?Ja(t,e):to(t,e)}var ro=typeof TextDecoder<"u"&&new TextDecoder,so=0;try{ro.decode(Za,{stream:!0}),so=1}catch{}class sn{esize;ecode;edata;littleEndian;constructor(e,i,r,s){if(e%16!=0)throw new Error("This does not appear to be a NIFTI extension");this.esize=e,this.ecode=i,this.edata=r,this.littleEndian=s}toArrayBuffer(){let e=new Uint8Array(this.esize),i=new Uint8Array(this.edata);e.set(i,8);let r=new DataView(e.buffer);return r.setInt32(0,this.esize,this.littleEndian),r.setInt32(4,this.ecode,this.littleEndian),e.buffer}}class O{static crcTable=null;static GUNZIP_MAGIC_COOKIE1=31;static GUNZIP_MAGIC_COOKIE2=139;static getStringAt(e,i,r){var s="",n,a;for(n=i;n<r;n+=1)a=e.getUint8(n),a!==0&&(s+=String.fromCharCode(a));return s}static getByteAt=function(e,i){return e.getUint8(i)};static getShortAt=function(e,i,r){return e.getInt16(i,r)};static getIntAt(e,i,r){return e.getInt32(i,r)}static getFloatAt(e,i,r){return e.getFloat32(i,r)}static getDoubleAt(e,i,r){return e.getFloat64(i,r)}static getInt64At(e,i,r){const s=e.getUint32(i,r),n=e.getInt32(i+4,r);let a;return r?a=n*2**32+s:a=s*2**32+n,n<0&&(a+=-1*2**32*2**32),a}static getUint64At(e,i,r){const s=e.getUint32(i+(r?0:4),r),n=e.getUint32(i+(r?4:0),r);return r?n*2**32+s:s*2**32+n}static getExtensionsAt(e,i,r,s){let n=[],a=i;for(;a<s;){let o=r,l=O.getIntAt(e,a,r);if(!l)break;if(l+a>s&&(o=!o,l=O.getIntAt(e,a,o),l+a>s))throw new Error("This does not appear to be a valid NIFTI extension");if(l%16!=0)throw new Error("This does not appear to be a NIFTI extension");let c=O.getIntAt(e,a+4,o),h=e.buffer.slice(a+8,a+l),d=new sn(l,c,h,o);n.push(d),a+=l}return n}static toArrayBuffer(e){var i,r,s;for(i=new ArrayBuffer(e.length),r=new Uint8Array(i),s=0;s<e.length;s+=1)r[s]=e[s];return i}static isString(e){return typeof e=="string"||e instanceof String}static formatNumber(e,i=void 0){let r;return O.isString(e)?r=Number(e):r=e,i?r=r.toPrecision(5):r=r.toPrecision(7),parseFloat(r)}static makeCRCTable(){let e,i=[];for(var r=0;r<256;r++){e=r;for(var s=0;s<8;s++)e=e&1?3988292384^e>>>1:e>>>1;i[r]=e}return i}static crc32(e){O.crcTable||(O.crcTable=O.makeCRCTable());const i=O.crcTable;let r=-1;for(var s=0;s<e.byteLength;s++)r=r>>>8^i[(r^e.getUint8(s))&255];return(r^-1)>>>0}}class G{littleEndian=!1;dim_info=0;dims=[];intent_p1=0;intent_p2=0;intent_p3=0;intent_code=0;datatypeCode=0;numBitsPerVoxel=0;slice_start=0;slice_end=0;slice_code=0;pixDims=[];vox_offset=0;scl_slope=1;scl_inter=0;xyzt_units=0;cal_max=0;cal_min=0;slice_duration=0;toffset=0;description="";aux_file="";intent_name="";qform_code=0;sform_code=0;quatern_a=0;quatern_b=0;quatern_c=0;quatern_d=0;qoffset_x=0;qoffset_y=0;qoffset_z=0;affine=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];qfac=1;quatern_R;magic="0";isHDR=!1;extensionFlag=[0,0,0,0];extensionSize=0;extensionCode=0;extensions=[];static TYPE_NONE=0;static TYPE_BINARY=1;static TYPE_UINT8=2;static TYPE_INT16=4;static TYPE_INT32=8;static TYPE_FLOAT32=16;static TYPE_COMPLEX64=32;static TYPE_FLOAT64=64;static TYPE_RGB24=128;static TYPE_INT8=256;static TYPE_UINT16=512;static TYPE_UINT32=768;static TYPE_INT64=1024;static TYPE_UINT64=1280;static TYPE_FLOAT128=1536;static TYPE_COMPLEX128=1792;static TYPE_COMPLEX256=2048;static XFORM_UNKNOWN=0;static XFORM_SCANNER_ANAT=1;static XFORM_ALIGNED_ANAT=2;static XFORM_TALAIRACH=3;static XFORM_MNI_152=4;static SPATIAL_UNITS_MASK=7;static TEMPORAL_UNITS_MASK=56;static UNITS_UNKNOWN=0;static UNITS_METER=1;static UNITS_MM=2;static UNITS_MICRON=3;static UNITS_SEC=8;static UNITS_MSEC=16;static UNITS_USEC=24;static UNITS_HZ=32;static UNITS_PPM=40;static UNITS_RADS=48;static MAGIC_COOKIE=348;static STANDARD_HEADER_SIZE=348;static MAGIC_NUMBER_LOCATION=344;static MAGIC_NUMBER=[110,43,49];static MAGIC_NUMBER2=[110,105,49];static EXTENSION_HEADER_SIZE=8;readHeader(e){var i=new DataView(e),r=O.getIntAt(i,0,this.littleEndian),s,n,a,o;if(r!==G.MAGIC_COOKIE&&(this.littleEndian=!0,r=O.getIntAt(i,0,this.littleEndian)),r!==G.MAGIC_COOKIE)throw new Error("This does not appear to be a NIFTI file!");for(this.dim_info=O.getByteAt(i,39),s=0;s<8;s+=1)o=40+s*2,this.dims[s]=O.getShortAt(i,o,this.littleEndian);for(this.intent_p1=O.getFloatAt(i,56,this.littleEndian),this.intent_p2=O.getFloatAt(i,60,this.littleEndian),this.intent_p3=O.getFloatAt(i,64,this.littleEndian),this.intent_code=O.getShortAt(i,68,this.littleEndian),this.datatypeCode=O.getShortAt(i,70,this.littleEndian),this.numBitsPerVoxel=O.getShortAt(i,72,this.littleEndian),this.slice_start=O.getShortAt(i,74,this.littleEndian),s=0;s<8;s+=1)o=76+s*4,this.pixDims[s]=O.getFloatAt(i,o,this.littleEndian);if(this.vox_offset=O.getFloatAt(i,108,this.littleEndian),this.scl_slope=O.getFloatAt(i,112,this.littleEndian),this.scl_inter=O.getFloatAt(i,116,this.littleEndian),this.slice_end=O.getShortAt(i,120,this.littleEndian),this.slice_code=O.getByteAt(i,122),this.xyzt_units=O.getByteAt(i,123),this.cal_max=O.getFloatAt(i,124,this.littleEndian),this.cal_min=O.getFloatAt(i,128,this.littleEndian),this.slice_duration=O.getFloatAt(i,132,this.littleEndian),this.toffset=O.getFloatAt(i,136,this.littleEndian),this.description=O.getStringAt(i,148,228),this.aux_file=O.getStringAt(i,228,252),this.qform_code=O.getShortAt(i,252,this.littleEndian),this.sform_code=O.getShortAt(i,254,this.littleEndian),this.quatern_b=O.getFloatAt(i,256,this.littleEndian),this.quatern_c=O.getFloatAt(i,260,this.littleEndian),this.quatern_d=O.getFloatAt(i,264,this.littleEndian),this.quatern_a=Math.sqrt(1-(Math.pow(this.quatern_b,2)+Math.pow(this.quatern_c,2)+Math.pow(this.quatern_d,2))),this.qoffset_x=O.getFloatAt(i,268,this.littleEndian),this.qoffset_y=O.getFloatAt(i,272,this.littleEndian),this.qoffset_z=O.getFloatAt(i,276,this.littleEndian),this.qform_code<1&&this.sform_code<1&&(this.affine[0][0]=this.pixDims[1],this.affine[1][1]=this.pixDims[2],this.affine[2][2]=this.pixDims[3]),this.qform_code>0&&this.sform_code<this.qform_code){const l=this.quatern_a,c=this.quatern_b,h=this.quatern_c,d=this.quatern_d;for(this.qfac=this.pixDims[0]===0?1:this.pixDims[0],this.quatern_R=[[l*l+c*c-h*h-d*d,2*c*h-2*l*d,2*c*d+2*l*h],[2*c*h+2*l*d,l*l+h*h-c*c-d*d,2*h*d-2*l*c],[2*c*d-2*l*h,2*h*d+2*l*c,l*l+d*d-h*h-c*c]],n=0;n<3;n+=1)for(a=0;a<3;a+=1)this.affine[n][a]=this.quatern_R[n][a]*this.pixDims[a+1],a===2&&(this.affine[n][a]*=this.qfac);this.affine[0][3]=this.qoffset_x,this.affine[1][3]=this.qoffset_y,this.affine[2][3]=this.qoffset_z}else if(this.sform_code>0)for(n=0;n<3;n+=1)for(a=0;a<4;a+=1)o=280+(n*4+a)*4,this.affine[n][a]=O.getFloatAt(i,o,this.littleEndian);if(this.affine[3][0]=0,this.affine[3][1]=0,this.affine[3][2]=0,this.affine[3][3]=1,this.intent_name=O.getStringAt(i,328,344),this.magic=O.getStringAt(i,344,348),this.isHDR=this.magic===String.fromCharCode.apply(null,G.MAGIC_NUMBER2),i.byteLength>G.MAGIC_COOKIE){this.extensionFlag[0]=O.getByteAt(i,348),this.extensionFlag[1]=O.getByteAt(i,349),this.extensionFlag[2]=O.getByteAt(i,350),this.extensionFlag[3]=O.getByteAt(i,351);let l=!0;!this.isHDR&&this.vox_offset<=352&&(l=!1),i.byteLength<=368&&(l=!1),l&&this.extensionFlag[0]&&(this.extensions=O.getExtensionsAt(i,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode)}}toFormattedString(){var e=O.formatNumber,i="";return i+="Dim Info = "+this.dim_info+`
3
3
  `,i+="Image Dimensions (1-8): "+this.dims[0]+", "+this.dims[1]+", "+this.dims[2]+", "+this.dims[3]+", "+this.dims[4]+", "+this.dims[5]+", "+this.dims[6]+", "+this.dims[7]+`
4
4
  `,i+="Intent Parameters (1-3): "+this.intent_p1+", "+this.intent_p2+", "+this.intent_p3+`
5
5
  `,i+="Intent Code = "+this.intent_code+`
@@ -1,4 +1,4 @@
1
- import{b7 as Re,t as Rt,e as Z,al as mv,aJ as Ne,aK as Vi,b8 as Se,at as Q,b9 as jr,ba as pv,ac as We,V as so,ar as Xe,bb as Gn,ad as pn,am as Pn,ae as Qo,bc as wn,bd as Xr,be as vv,ah as Ea,bf as ve,i as ie,bg as vc,bh as Iv,bi as rn,bj as bh,bk as Hn,bl as eo,bm as Fi,bn as _h,bo as yh,bp as Nl,bq as qr,E as yt,aN as Es,br as Ss,bs as wv,bt as $o,bu as IC,bv as Fn,bw as wC,bx as EC,by as SC,bz as CC,bA as Yc,bB as bC,aw as _C,b5 as Kc,bC as yC,bD as Ev,bE as xC,bF as xh,bG as Sv,bH as PC,bI as DC,aL as Eg,K as kl,bJ as Sa,ao as Cv,bK as TC,bL as MC,bM as AC,aO as fr,bN as bv,bO as Ud,bP as _v,bQ as Ph,bR as Dh,bS as LC,bT as OC,av as RC,g as NC,bU as po,bV as kC,bW as UC,bX as Zc,bY as Sg,bZ as VC,b_ as Vd,ag as Ks,af as FC,b$ as Cg,J as GC,ai as HC,c0 as WC,c1 as Th,c2 as BC,c3 as zC}from"./Settings-BVnfxRPh.js";import{D as _n,I as Mh,M as Vt,m as Lt,P as Di,a as ku,V as bg,B as di,b as $C,s as jC,d as _g,n as tr,c as XC,t as qC,i as YC,e as yg,f as KC,g as ZC,h as Bc,j as JC}from"./cornerstoneEngine-CGEzAsx7.js";import{C as yv,P as Ah,I as QC,a as tb,b as Vo,c as la,M as Oo,A as vo,d as Ul,R as xv,T as Pv,t as Jc,e as er,f as xg,Q as eb,g as nb,h as ob,L as ib}from"./Texture-C99vHuBO.js";import{i as sb,b as ae,g as N,j as ab,c as le,u as oe,k as Dv,l as Lh,m as Uu,f as gr,h as Zs,n as rb,d as cb,o as Oh,r as de,p as lb,q as Tv,t as gn,w as is,x as Rh,y as Mv,z as db,A as da,M as ub,B as Av,C as Pg,D as Fa,E as Vu,F as hb}from"./index-CmFTTf9P.js";import{c as Ic,g as fb}from"./_commonjsHelpers-CE1G-McA.js";import{A as Kn,E as Js,c as B,f as Ot,d as xt,a as Me,l as mr,n as Wt,e as pr,s as bn,b as Oe,g as tn,h as mn,i as ee,j as Yr,k as gb,m as ke,t as Un,o as Ue,p as Lv,q as Fu,r as yn,u as Ov,v as ho,w as Rv,x as Nv,y as mb,z as pb,B as vb,C as Dg,D as Ib,F as wb,G as Eb}from"./throttle-CjIII7Yf.js";import{a as Sb}from"./addVolumesToViewports-42A0OSZO.js";import"./dcmjs.es-DfWkgqfk.js";import"./index-Dtsm0q-Z.js";function Cb(i,t){let n;if(t===void 0)for(const e of i)e!=null&&(n>e||n===void 0&&e>=e)&&(n=e);else{let e=-1;for(let o of i)(o=t(o,++e,i))!=null&&(n>o||n===void 0&&o>=o)&&(n=o)}return n}function bb(i){if(!(s=i.length))return[];for(var t=-1,n=Cb(i,_b),e=new Array(n);++t<n;)for(var o=-1,s,a=e[t]=new Array(s);++o<s;)a[o]=i[o][t];return e}function _b(i){return i.length}function Tg(){return bb(arguments)}function yb(i,t,n,e,o){var s=i*i,a=s*i;return((1-3*i+3*s-a)*t+(4-6*s+3*a)*n+(1+3*i+3*s-3*a)*e+a*o)/6}function Fd(i){var t=i.length-1;return function(n){var e=n<=0?n=0:n>=1?(n=1,t-1):Math.floor(n*t),o=i[e],s=i[e+1],a=e>0?i[e-1]:2*o-s,r=e<t-1?i[e+2]:2*s-o;return yb((n-e/t)*t,a,o,s,r)}}function Ga(i,t){for(var n=new Array(t),e=0;e<t;++e)n[e]=i(e/(t-1));return n}var Fo;(function(i){i[i.Primary=1]="Primary",i[i.Secondary=2]="Secondary",i[i.Primary_And_Secondary=3]="Primary_And_Secondary",i[i.Auxiliary=4]="Auxiliary",i[i.Primary_And_Auxiliary=5]="Primary_And_Auxiliary",i[i.Secondary_And_Auxiliary=6]="Secondary_And_Auxiliary",i[i.Primary_And_Secondary_And_Auxiliary=7]="Primary_And_Secondary_And_Auxiliary",i[i.Fourth_Button=8]="Fourth_Button",i[i.Fifth_Button=16]="Fifth_Button",i[i.Wheel=524288]="Wheel",i[i.Wheel_Primary=524289]="Wheel_Primary"})(Fo||(Fo={}));var vn;(function(i){i[i.Shift=16]="Shift",i[i.Ctrl=17]="Ctrl",i[i.Alt=18]="Alt",i[i.Meta=91]="Meta",i[i.ShiftCtrl=1617]="ShiftCtrl",i[i.ShiftAlt=1618]="ShiftAlt",i[i.ShiftMeta=1691]="ShiftMeta",i[i.CtrlAlt=1718]="CtrlAlt",i[i.CtrlMeta=1791]="CtrlMeta",i[i.AltMeta=1891]="AltMeta"})(vn||(vn={}));var se;(function(i){i.Active="Active",i.Passive="Passive",i.Enabled="Enabled",i.Disabled="Disabled"})(se||(se={}));var To;(function(i){i.Default="",i.Highlighted="Highlighted",i.Selected="Selected",i.Locked="Locked",i.AutoGenerated="AutoGenerated"})(To||(To={}));var E;(function(i){i.TOOL_ACTIVATED="CORNERSTONE_TOOLS_TOOL_ACTIVATED",i.TOOLGROUP_VIEWPORT_ADDED="CORNERSTONE_TOOLS_TOOLGROUP_VIEWPORT_ADDED",i.TOOLGROUP_VIEWPORT_REMOVED="CORNERSTONE_TOOLS_TOOLGROUP_VIEWPORT_REMOVED",i.TOOL_MODE_CHANGED="CORNERSTONE_TOOLS_TOOL_MODE_CHANGED",i.CROSSHAIR_TOOL_CENTER_CHANGED="CORNERSTONE_TOOLS_CROSSHAIR_TOOL_CENTER_CHANGED",i.WORLD_CROSSHAIR_POINT_CHANGED="CORNERSTONE_TOOLS_WORLD_CROSSHAIR_POINT_CHANGED",i.WORLD_CROSSHAIR_POINT_CLEARED="CORNERSTONE_TOOLS_WORLD_CROSSHAIR_POINT_CLEARED",i.WORLD_CROSSHAIR_JUMPED_TO_POINT="CORNERSTONE_TOOLS_WORLD_CROSSHAIR_JUMPED_TO_POINT",i.SLICE_INTERSECTION_LINE_SELECTED="CORNERSTONE_TOOLS_SLICE_INTERSECTION_LINE_SELECTED",i.SLICE_INTERSECTION_MANIPULATION_STARTED="CORNERSTONE_TOOLS_SLICE_INTERSECTION_MANIPULATION_STARTED",i.SLICE_INTERSECTION_MANIPULATION_ENDED="CORNERSTONE_TOOLS_SLICE_INTERSECTION_MANIPULATION_ENDED",i.SLICE_INTERSECTION_SLAB_THICKNESS_CHANGED="CORNERSTONE_TOOLS_SLICE_INTERSECTION_SLAB_THICKNESS_CHANGED",i.VOLUMECROPPINGCONTROL_TOOL_CHANGED="CORNERSTONE_TOOLS_VOLUMECROPPINGCONTROL_TOOL_CHANGED",i.VOLUMECROPPING_TOOL_CHANGED="CORNERSTONE_TOOLS_VOLUMECROPPING_TOOL_CHANGED",i.STACK_PREFETCH_COMPLETE="CORNERSTONE_TOOLS_STACK_PREFETCH_COMPLETE",i.ANNOTATION_ADDED="CORNERSTONE_TOOLS_ANNOTATION_ADDED",i.ANNOTATION_COMPLETED="CORNERSTONE_TOOLS_ANNOTATION_COMPLETED",i.ANNOTATION_MODIFIED="CORNERSTONE_TOOLS_ANNOTATION_MODIFIED",i.ANNOTATION_REMOVED="CORNERSTONE_TOOLS_ANNOTATION_REMOVED",i.ANNOTATION_SELECTION_CHANGE="CORNERSTONE_TOOLS_ANNOTATION_SELECTION_CHANGE",i.ANNOTATION_LOCK_CHANGE="CORNERSTONE_TOOLS_ANNOTATION_LOCK_CHANGE",i.ANNOTATION_VISIBILITY_CHANGE="CORNERSTONE_TOOLS_ANNOTATION_VISIBILITY_CHANGE",i.ANNOTATION_RENDERED="CORNERSTONE_TOOLS_ANNOTATION_RENDERED",i.ANNOTATION_CUT_MERGE_PROCESS_COMPLETED="CORNERSTONE_TOOLS_ANNOTATION_CUT_MERGE_PROCESS_COMPLETED",i.ANNOTATION_INTERPOLATION_PROCESS_COMPLETED="CORNERSTONE_TOOLS_ANNOTATION_INTERPOLATION_PROCESS_COMPLETED",i.INTERPOLATED_ANNOTATIONS_REMOVED="CORNERSTONE_TOOLS_INTERPOLATED_ANNOTATIONS_REMOVED",i.SEGMENTATION_MODIFIED="CORNERSTONE_TOOLS_SEGMENTATION_MODIFIED",i.SEGMENTATION_RENDERED="CORNERSTONE_TOOLS_SEGMENTATION_RENDERED",i.SEGMENTATION_REPRESENTATION_ADDED="CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_ADDED",i.SEGMENTATION_ADDED="CORNERSTONE_TOOLS_SEGMENTATION_ADDED",i.SEGMENTATION_REPRESENTATION_MODIFIED="CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_MODIFIED",i.SEGMENTATION_REMOVED="CORNERSTONE_TOOLS_SEGMENTATION_REMOVED",i.SEGMENTATION_REPRESENTATION_REMOVED="CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_REMOVED",i.SEGMENTATION_DATA_MODIFIED="CORNERSTONE_TOOLS_SEGMENTATION_DATA_MODIFIED",i.HISTORY_UNDO="CORNERSTONE_TOOLS_HISTORY_UNDO",i.HISTORY_REDO="CORNERSTONE_TOOLS_HISTORY_REDO",i.KEY_DOWN="CORNERSTONE_TOOLS_KEY_DOWN",i.KEY_UP="CORNERSTONE_TOOLS_KEY_UP",i.MOUSE_DOWN="CORNERSTONE_TOOLS_MOUSE_DOWN",i.MOUSE_UP="CORNERSTONE_TOOLS_MOUSE_UP",i.MOUSE_DOWN_ACTIVATE="CORNERSTONE_TOOLS_MOUSE_DOWN_ACTIVATE",i.MOUSE_DRAG="CORNERSTONE_TOOLS_MOUSE_DRAG",i.MOUSE_MOVE="CORNERSTONE_TOOLS_MOUSE_MOVE",i.MOUSE_CLICK="CORNERSTONE_TOOLS_MOUSE_CLICK",i.MOUSE_DOUBLE_CLICK="CORNERSTONE_TOOLS_MOUSE_DOUBLE_CLICK",i.MOUSE_WHEEL="CORNERSTONE_TOOLS_MOUSE_WHEEL",i.TOUCH_START="CORNERSTONE_TOOLS_TOUCH_START",i.TOUCH_START_ACTIVATE="CORNERSTONE_TOOLS_TOUCH_START_ACTIVATE",i.TOUCH_PRESS="CORNERSTONE_TOOLS_TOUCH_PRESS",i.TOUCH_DRAG="CORNERSTONE_TOOLS_TOUCH_DRAG",i.TOUCH_END="CORNERSTONE_TOOLS_TOUCH_END",i.TOUCH_TAP="CORNERSTONE_TOOLS_TAP",i.TOUCH_SWIPE="CORNERSTONE_TOOLS_SWIPE"})(E||(E={}));var St;(function(i){i.Labelmap="Labelmap",i.Contour="Contour",i.Surface="Surface"})(St||(St={}));var ss;(function(i){i.UP="UP",i.DOWN="DOWN",i.LEFT="LEFT",i.RIGHT="RIGHT"})(ss||(ss={}));var dt;(function(i){i.CalculateCursorGeometry="calculateCursorGeometry",i.RenderCursor="renderCursor",i.OnInteractionStart="onInteractionStart",i.OnInteractionEnd="onInteractionEnd",i.Preview="preview",i.RejectPreview="rejectPreview",i.AcceptPreview="acceptPreview",i.Fill="fill",i.Interpolate="interpolate",i.StrategyFunction="strategyFunction",i.CreateIsInThreshold="createIsInThreshold",i.Initialize="initialize",i.INTERNAL_setValue="setValue",i.AddPreview="addPreview",i.ComputeInnerCircleRadius="computeInnerCircleRadius",i.GetStatistics="getStatistics",i.EnsureImageVolumeFor3DManipulation="ensureImageVolumeFor3DManipulation",i.EnsureSegmentationVolumeFor3DManipulation="ensureSegmentationVolumeFor3DManipulation"})(dt||(dt={}));var Bt;(function(i){i.Interaction="Interaction",i.HandlesUpdated="HandlesUpdated",i.StatsUpdated="StatsUpdated",i.InitialSetup="InitialSetup",i.Completed="Completed",i.InterpolationUpdated="InterpolationUpdated",i.History="History",i.MetadataReferenceModified="MetadataReferenceModified",i.LabelChange="LabelChange"})(Bt||(Bt={}));var no;(function(i){i.POLYSEG_CONTOUR_TO_LABELMAP="Converting Contour to Labelmap",i.POLYSEG_SURFACE_TO_LABELMAP="Converting Surfaces to Labelmap",i.POLYSEG_CONTOUR_TO_SURFACE="Converting Contour to Surface",i.POLYSEG_LABELMAP_TO_SURFACE="Converting Labelmap to Surface",i.SURFACE_CLIPPING="Clipping Surfaces",i.COMPUTE_STATISTICS="Computing Statistics",i.INTERPOLATE_LABELMAP="Interpolating Labelmap",i.COMPUTE_LARGEST_BIDIRECTIONAL="Computing Largest Bidirectional",i.GENERATE_CONTOUR_SETS="Generating Contour Sets"})(no||(no={}));var Io;(function(i){i.Linear="Linear",i.Area="Area",i.Volume="Volume",i.Pixel="Pixel"})(Io||(Io={}));const yG=Object.freeze(Object.defineProperty({__proto__:null,AnnotationStyleStates:To,ChangeTypes:Bt,Events:E,get KeyboardBindings(){return vn},get MeasurementType(){return Io},get MouseBindings(){return Fo},SegmentationRepresentations:St,StrategyCallbacks:dt,get Swipe(){return ss},ToolModes:se,WorkerTypes:no},Symbol.toStringTag,{value:"Module"}));let Vl={};function xb(){Vl={}}const Mg={isInteractingWithTool:!1,isMultiPartToolActive:!1,tools:{},toolGroups:[],synchronizers:[],svgNodeCache:Vl,enabledElements:[],handleRadius:6};let $={isInteractingWithTool:!1,isMultiPartToolActive:!1,tools:{},toolGroups:[],synchronizers:[],svgNodeCache:Vl,enabledElements:[],handleRadius:6};function Pb(){xb(),$={...Re({...Mg,svgNodeCache:{}}),svgNodeCache:{...Mg.svgNodeCache}}}var Gd,Ag;function Db(){if(Ag)return Gd;Ag=1;var i="Expected a function",t="__lodash_hash_undefined__",n="[object Function]",e="[object GeneratorFunction]",o="[object Symbol]",s=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/,r=/^\./,c=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,l=/[\\^$.*+?()[\]{}|]/g,d=/\\(\\)?/g,u=/^\[object .+?Constructor\]$/,h=typeof Ic=="object"&&Ic&&Ic.Object===Object&&Ic,f=typeof self=="object"&&self&&self.Object===Object&&self,g=h||f||Function("return this")();function m(G,et){return G?.[et]}function p(G){var et=!1;if(G!=null&&typeof G.toString!="function")try{et=!!(G+"")}catch{}return et}var v=Array.prototype,I=Function.prototype,w=Object.prototype,C=g["__core-js_shared__"],S=(function(){var G=/[^.]+$/.exec(C&&C.keys&&C.keys.IE_PROTO||"");return G?"Symbol(src)_1."+G:""})(),b=I.toString,_=w.hasOwnProperty,y=w.toString,D=RegExp("^"+b.call(_).replace(l,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),T=g.Symbol,P=v.splice,x=Ht(g,"Map"),M=Ht(Object,"create"),L=T?T.prototype:void 0,R=L?L.toString:void 0;function U(G){var et=-1,at=G?G.length:0;for(this.clear();++et<at;){var jt=G[et];this.set(jt[0],jt[1])}}function W(){this.__data__=M?M(null):{}}function K(G){return this.has(G)&&delete this.__data__[G]}function j(G){var et=this.__data__;if(M){var at=et[G];return at===t?void 0:at}return _.call(et,G)?et[G]:void 0}function F(G){var et=this.__data__;return M?et[G]!==void 0:_.call(et,G)}function z(G,et){var at=this.__data__;return at[G]=M&&et===void 0?t:et,this}U.prototype.clear=W,U.prototype.delete=K,U.prototype.get=j,U.prototype.has=F,U.prototype.set=z;function q(G){var et=-1,at=G?G.length:0;for(this.clear();++et<at;){var jt=G[et];this.set(jt[0],jt[1])}}function J(){this.__data__=[]}function it(G){var et=this.__data__,at=te(et,G);if(at<0)return!1;var jt=et.length-1;return at==jt?et.pop():P.call(et,at,1),!0}function tt(G){var et=this.__data__,at=te(et,G);return at<0?void 0:et[at][1]}function ot(G){return te(this.__data__,G)>-1}function nt(G,et){var at=this.__data__,jt=te(at,G);return jt<0?at.push([G,et]):at[jt][1]=et,this}q.prototype.clear=J,q.prototype.delete=it,q.prototype.get=tt,q.prototype.has=ot,q.prototype.set=nt;function lt(G){var et=-1,at=G?G.length:0;for(this.clear();++et<at;){var jt=G[et];this.set(jt[0],jt[1])}}function rt(){this.__data__={hash:new U,map:new(x||q),string:new U}}function ut(G){return Ut(this,G).delete(G)}function Tt(G){return Ut(this,G).get(G)}function kt(G){return Ut(this,G).has(G)}function Pt(G,et){return Ut(this,G).set(G,et),this}lt.prototype.clear=rt,lt.prototype.delete=ut,lt.prototype.get=Tt,lt.prototype.has=kt,lt.prototype.set=Pt;function te(G,et){for(var at=G.length;at--;)if(Bo(G[at][0],et))return at;return-1}function Ie(G,et){et=Jt(et,G)?[et]:ce(et);for(var at=0,jt=et.length;G!=null&&at<jt;)G=G[Ve(et[at++])];return at&&at==jt?G:void 0}function re(G){if(!lo(G)||De(G))return!1;var et=yi(G)||p(G)?D:u;return et.test(Wo(G))}function Zt(G){if(typeof G=="string")return G;if(oi(G))return R?R.call(G):"";var et=G+"";return et=="0"&&1/G==-1/0?"-0":et}function ce(G){return co(G)?G:ln(G)}function Ut(G,et){var at=G.__data__;return Pe(et)?at[typeof et=="string"?"string":"hash"]:at.map}function Ht(G,et){var at=m(G,et);return re(at)?at:void 0}function Jt(G,et){if(co(G))return!1;var at=typeof G;return at=="number"||at=="symbol"||at=="boolean"||G==null||oi(G)?!0:a.test(G)||!s.test(G)||et!=null&&G in Object(et)}function Pe(G){var et=typeof G;return et=="string"||et=="number"||et=="symbol"||et=="boolean"?G!=="__proto__":G===null}function De(G){return!!S&&S in G}var ln=jn(function(G){G=st(G);var et=[];return r.test(G)&&et.push(""),G.replace(c,function(at,jt,je,dn){et.push(je?dn.replace(d,"$1"):jt||at)}),et});function Ve(G){if(typeof G=="string"||oi(G))return G;var et=G+"";return et=="0"&&1/G==-1/0?"-0":et}function Wo(G){if(G!=null){try{return b.call(G)}catch{}try{return G+""}catch{}}return""}function jn(G,et){if(typeof G!="function"||et&&typeof et!="function")throw new TypeError(i);var at=function(){var jt=arguments,je=et?et.apply(this,jt):jt[0],dn=at.cache;if(dn.has(je))return dn.get(je);var yo=G.apply(this,jt);return at.cache=dn.set(je,yo),yo};return at.cache=new(jn.Cache||lt),at}jn.Cache=lt;function Bo(G,et){return G===et||G!==G&&et!==et}var co=Array.isArray;function yi(G){var et=lo(G)?y.call(G):"";return et==n||et==e}function lo(G){var et=typeof G;return!!G&&(et=="object"||et=="function")}function xi(G){return!!G&&typeof G=="object"}function oi(G){return typeof G=="symbol"||xi(G)&&y.call(G)==o}function st(G){return G==null?"":Zt(G)}function Mt(G,et,at){var jt=G==null?void 0:Ie(G,et);return jt===void 0?at:jt}return Gd=Mt,Gd}var Tb=Db();const Mb=fb(Tb),Lg=Symbol("DefinedCursors"),kv=new Set(["alias","all-scroll","auto","cell","col-resize","context-menu","copy","crosshair","default","e-resize","ew-resize","grab","grabbing","help","move","ne-resize","nesw-resize","no-drop","none","not-allowed","n-resize","ns-resize","nw-resize","nwse-resize","pointer","progress","row-resize","se-resize","s-resize","sw-resize","text","vertical-text","wait","w-resize","zoom-in","zoom-out"]);class An{constructor(t,n){this.name=t+"",this.fallback=n}getName(){return this.name+""}addFallbackStyleProperty(t){const{fallback:n}=this;return n instanceof An?`${t}, ${n.getStyleProperty()}`:t+""}getStyleProperty(){return this.addFallbackStyleProperty(this.name)+""}static getDefinedCursor(t){const n=Og(An,Lg);let e=n.get(t);if(e instanceof An)return e;if(kv.has(t))return e=new An(t),n.set(t,e),e}static setDefinedCursor(t,n){return n instanceof An?(Og(An,Lg).set(t,n),!0):!1}}function Og(i,t){let n=i[t];return n instanceof Map||(n=new Map,Object.defineProperty(i,t,{value:n})),n}const Ab=kv.values(),Lb="image-cursor";class vr extends An{constructor(t,n,e,o,s){super(o||vr.getUniqueInstanceName(Lb),s),this.url=t,this.x=Number(n)||0,this.y=Number(e)||0}getStyleProperty(){const{url:t,x:n,y:e}=this;let o=`url('${t}')`;return n>=0&&e>=0&&(n>0||e>0)&&(o+=` ${n} ${e}`),this.addFallbackStyleProperty(o)}static getUniqueInstanceName(t){return`${t}-${sb(vr)}`}}const he={iconContent:"",iconSize:16,viewBox:{x:16,y:16},mousePoint:{x:8,y:8},mousePointerGroupString:`
1
+ import{b7 as Re,t as Rt,e as Z,al as mv,aJ as Ne,aK as Vi,b8 as Se,at as Q,b9 as jr,ba as pv,ac as We,V as so,ar as Xe,bb as Gn,ad as pn,am as Pn,ae as Qo,bc as wn,bd as Xr,be as vv,ah as Ea,bf as ve,i as ie,bg as vc,bh as Iv,bi as rn,bj as bh,bk as Hn,bl as eo,bm as Fi,bn as _h,bo as yh,bp as Nl,bq as qr,E as yt,aN as Es,br as Ss,bs as wv,bt as $o,bu as IC,bv as Fn,bw as wC,bx as EC,by as SC,bz as CC,bA as Yc,bB as bC,aw as _C,b5 as Kc,bC as yC,bD as Ev,bE as xC,bF as xh,bG as Sv,bH as PC,bI as DC,aL as Eg,K as kl,bJ as Sa,ao as Cv,bK as TC,bL as MC,bM as AC,aO as fr,bN as bv,bO as Ud,bP as _v,bQ as Ph,bR as Dh,bS as LC,bT as OC,av as RC,g as NC,bU as po,bV as kC,bW as UC,bX as Zc,bY as Sg,bZ as VC,b_ as Vd,ag as Ks,af as FC,b$ as Cg,J as GC,ai as HC,c0 as WC,c1 as Th,c2 as BC,c3 as zC}from"./Settings-CpJHgU8P.js";import{D as _n,I as Mh,M as Vt,m as Lt,P as Di,a as ku,V as bg,B as di,b as $C,s as jC,d as _g,n as tr,c as XC,t as qC,i as YC,e as yg,f as KC,g as ZC,h as Bc,j as JC}from"./cornerstoneEngine-DgoPMn1N.js";import{C as yv,P as Ah,I as QC,a as tb,b as Vo,c as la,M as Oo,A as vo,d as Ul,R as xv,T as Pv,t as Jc,e as er,f as xg,Q as eb,g as nb,h as ob,L as ib}from"./Texture-BFywN4BL.js";import{i as sb,b as ae,g as N,j as ab,c as le,u as oe,k as Dv,l as Lh,m as Uu,f as gr,h as Zs,n as rb,d as cb,o as Oh,r as de,p as lb,q as Tv,t as gn,w as is,x as Rh,y as Mv,z as db,A as da,M as ub,B as Av,C as Pg,D as Fa,E as Vu,F as hb}from"./index-CokKuJob.js";import{c as Ic,g as fb}from"./_commonjsHelpers-CE1G-McA.js";import{A as Kn,E as Js,c as B,f as Ot,d as xt,a as Me,l as mr,n as Wt,e as pr,s as bn,b as Oe,g as tn,h as mn,i as ee,j as Yr,k as gb,m as ke,t as Un,o as Ue,p as Lv,q as Fu,r as yn,u as Ov,v as ho,w as Rv,x as Nv,y as mb,z as pb,B as vb,C as Dg,D as Ib,F as wb,G as Eb}from"./throttle-CjIII7Yf.js";import{a as Sb}from"./addVolumesToViewports-CKWYzwhw.js";import"./dcmjs.es-DfWkgqfk.js";import"./index-Bm3uV1GS.js";function Cb(i,t){let n;if(t===void 0)for(const e of i)e!=null&&(n>e||n===void 0&&e>=e)&&(n=e);else{let e=-1;for(let o of i)(o=t(o,++e,i))!=null&&(n>o||n===void 0&&o>=o)&&(n=o)}return n}function bb(i){if(!(s=i.length))return[];for(var t=-1,n=Cb(i,_b),e=new Array(n);++t<n;)for(var o=-1,s,a=e[t]=new Array(s);++o<s;)a[o]=i[o][t];return e}function _b(i){return i.length}function Tg(){return bb(arguments)}function yb(i,t,n,e,o){var s=i*i,a=s*i;return((1-3*i+3*s-a)*t+(4-6*s+3*a)*n+(1+3*i+3*s-3*a)*e+a*o)/6}function Fd(i){var t=i.length-1;return function(n){var e=n<=0?n=0:n>=1?(n=1,t-1):Math.floor(n*t),o=i[e],s=i[e+1],a=e>0?i[e-1]:2*o-s,r=e<t-1?i[e+2]:2*s-o;return yb((n-e/t)*t,a,o,s,r)}}function Ga(i,t){for(var n=new Array(t),e=0;e<t;++e)n[e]=i(e/(t-1));return n}var Fo;(function(i){i[i.Primary=1]="Primary",i[i.Secondary=2]="Secondary",i[i.Primary_And_Secondary=3]="Primary_And_Secondary",i[i.Auxiliary=4]="Auxiliary",i[i.Primary_And_Auxiliary=5]="Primary_And_Auxiliary",i[i.Secondary_And_Auxiliary=6]="Secondary_And_Auxiliary",i[i.Primary_And_Secondary_And_Auxiliary=7]="Primary_And_Secondary_And_Auxiliary",i[i.Fourth_Button=8]="Fourth_Button",i[i.Fifth_Button=16]="Fifth_Button",i[i.Wheel=524288]="Wheel",i[i.Wheel_Primary=524289]="Wheel_Primary"})(Fo||(Fo={}));var vn;(function(i){i[i.Shift=16]="Shift",i[i.Ctrl=17]="Ctrl",i[i.Alt=18]="Alt",i[i.Meta=91]="Meta",i[i.ShiftCtrl=1617]="ShiftCtrl",i[i.ShiftAlt=1618]="ShiftAlt",i[i.ShiftMeta=1691]="ShiftMeta",i[i.CtrlAlt=1718]="CtrlAlt",i[i.CtrlMeta=1791]="CtrlMeta",i[i.AltMeta=1891]="AltMeta"})(vn||(vn={}));var se;(function(i){i.Active="Active",i.Passive="Passive",i.Enabled="Enabled",i.Disabled="Disabled"})(se||(se={}));var To;(function(i){i.Default="",i.Highlighted="Highlighted",i.Selected="Selected",i.Locked="Locked",i.AutoGenerated="AutoGenerated"})(To||(To={}));var E;(function(i){i.TOOL_ACTIVATED="CORNERSTONE_TOOLS_TOOL_ACTIVATED",i.TOOLGROUP_VIEWPORT_ADDED="CORNERSTONE_TOOLS_TOOLGROUP_VIEWPORT_ADDED",i.TOOLGROUP_VIEWPORT_REMOVED="CORNERSTONE_TOOLS_TOOLGROUP_VIEWPORT_REMOVED",i.TOOL_MODE_CHANGED="CORNERSTONE_TOOLS_TOOL_MODE_CHANGED",i.CROSSHAIR_TOOL_CENTER_CHANGED="CORNERSTONE_TOOLS_CROSSHAIR_TOOL_CENTER_CHANGED",i.WORLD_CROSSHAIR_POINT_CHANGED="CORNERSTONE_TOOLS_WORLD_CROSSHAIR_POINT_CHANGED",i.WORLD_CROSSHAIR_POINT_CLEARED="CORNERSTONE_TOOLS_WORLD_CROSSHAIR_POINT_CLEARED",i.WORLD_CROSSHAIR_JUMPED_TO_POINT="CORNERSTONE_TOOLS_WORLD_CROSSHAIR_JUMPED_TO_POINT",i.SLICE_INTERSECTION_LINE_SELECTED="CORNERSTONE_TOOLS_SLICE_INTERSECTION_LINE_SELECTED",i.SLICE_INTERSECTION_MANIPULATION_STARTED="CORNERSTONE_TOOLS_SLICE_INTERSECTION_MANIPULATION_STARTED",i.SLICE_INTERSECTION_MANIPULATION_ENDED="CORNERSTONE_TOOLS_SLICE_INTERSECTION_MANIPULATION_ENDED",i.SLICE_INTERSECTION_SLAB_THICKNESS_CHANGED="CORNERSTONE_TOOLS_SLICE_INTERSECTION_SLAB_THICKNESS_CHANGED",i.VOLUMECROPPINGCONTROL_TOOL_CHANGED="CORNERSTONE_TOOLS_VOLUMECROPPINGCONTROL_TOOL_CHANGED",i.VOLUMECROPPING_TOOL_CHANGED="CORNERSTONE_TOOLS_VOLUMECROPPING_TOOL_CHANGED",i.STACK_PREFETCH_COMPLETE="CORNERSTONE_TOOLS_STACK_PREFETCH_COMPLETE",i.ANNOTATION_ADDED="CORNERSTONE_TOOLS_ANNOTATION_ADDED",i.ANNOTATION_COMPLETED="CORNERSTONE_TOOLS_ANNOTATION_COMPLETED",i.ANNOTATION_MODIFIED="CORNERSTONE_TOOLS_ANNOTATION_MODIFIED",i.ANNOTATION_REMOVED="CORNERSTONE_TOOLS_ANNOTATION_REMOVED",i.ANNOTATION_SELECTION_CHANGE="CORNERSTONE_TOOLS_ANNOTATION_SELECTION_CHANGE",i.ANNOTATION_LOCK_CHANGE="CORNERSTONE_TOOLS_ANNOTATION_LOCK_CHANGE",i.ANNOTATION_VISIBILITY_CHANGE="CORNERSTONE_TOOLS_ANNOTATION_VISIBILITY_CHANGE",i.ANNOTATION_RENDERED="CORNERSTONE_TOOLS_ANNOTATION_RENDERED",i.ANNOTATION_CUT_MERGE_PROCESS_COMPLETED="CORNERSTONE_TOOLS_ANNOTATION_CUT_MERGE_PROCESS_COMPLETED",i.ANNOTATION_INTERPOLATION_PROCESS_COMPLETED="CORNERSTONE_TOOLS_ANNOTATION_INTERPOLATION_PROCESS_COMPLETED",i.INTERPOLATED_ANNOTATIONS_REMOVED="CORNERSTONE_TOOLS_INTERPOLATED_ANNOTATIONS_REMOVED",i.SEGMENTATION_MODIFIED="CORNERSTONE_TOOLS_SEGMENTATION_MODIFIED",i.SEGMENTATION_RENDERED="CORNERSTONE_TOOLS_SEGMENTATION_RENDERED",i.SEGMENTATION_REPRESENTATION_ADDED="CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_ADDED",i.SEGMENTATION_ADDED="CORNERSTONE_TOOLS_SEGMENTATION_ADDED",i.SEGMENTATION_REPRESENTATION_MODIFIED="CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_MODIFIED",i.SEGMENTATION_REMOVED="CORNERSTONE_TOOLS_SEGMENTATION_REMOVED",i.SEGMENTATION_REPRESENTATION_REMOVED="CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_REMOVED",i.SEGMENTATION_DATA_MODIFIED="CORNERSTONE_TOOLS_SEGMENTATION_DATA_MODIFIED",i.HISTORY_UNDO="CORNERSTONE_TOOLS_HISTORY_UNDO",i.HISTORY_REDO="CORNERSTONE_TOOLS_HISTORY_REDO",i.KEY_DOWN="CORNERSTONE_TOOLS_KEY_DOWN",i.KEY_UP="CORNERSTONE_TOOLS_KEY_UP",i.MOUSE_DOWN="CORNERSTONE_TOOLS_MOUSE_DOWN",i.MOUSE_UP="CORNERSTONE_TOOLS_MOUSE_UP",i.MOUSE_DOWN_ACTIVATE="CORNERSTONE_TOOLS_MOUSE_DOWN_ACTIVATE",i.MOUSE_DRAG="CORNERSTONE_TOOLS_MOUSE_DRAG",i.MOUSE_MOVE="CORNERSTONE_TOOLS_MOUSE_MOVE",i.MOUSE_CLICK="CORNERSTONE_TOOLS_MOUSE_CLICK",i.MOUSE_DOUBLE_CLICK="CORNERSTONE_TOOLS_MOUSE_DOUBLE_CLICK",i.MOUSE_WHEEL="CORNERSTONE_TOOLS_MOUSE_WHEEL",i.TOUCH_START="CORNERSTONE_TOOLS_TOUCH_START",i.TOUCH_START_ACTIVATE="CORNERSTONE_TOOLS_TOUCH_START_ACTIVATE",i.TOUCH_PRESS="CORNERSTONE_TOOLS_TOUCH_PRESS",i.TOUCH_DRAG="CORNERSTONE_TOOLS_TOUCH_DRAG",i.TOUCH_END="CORNERSTONE_TOOLS_TOUCH_END",i.TOUCH_TAP="CORNERSTONE_TOOLS_TAP",i.TOUCH_SWIPE="CORNERSTONE_TOOLS_SWIPE"})(E||(E={}));var St;(function(i){i.Labelmap="Labelmap",i.Contour="Contour",i.Surface="Surface"})(St||(St={}));var ss;(function(i){i.UP="UP",i.DOWN="DOWN",i.LEFT="LEFT",i.RIGHT="RIGHT"})(ss||(ss={}));var dt;(function(i){i.CalculateCursorGeometry="calculateCursorGeometry",i.RenderCursor="renderCursor",i.OnInteractionStart="onInteractionStart",i.OnInteractionEnd="onInteractionEnd",i.Preview="preview",i.RejectPreview="rejectPreview",i.AcceptPreview="acceptPreview",i.Fill="fill",i.Interpolate="interpolate",i.StrategyFunction="strategyFunction",i.CreateIsInThreshold="createIsInThreshold",i.Initialize="initialize",i.INTERNAL_setValue="setValue",i.AddPreview="addPreview",i.ComputeInnerCircleRadius="computeInnerCircleRadius",i.GetStatistics="getStatistics",i.EnsureImageVolumeFor3DManipulation="ensureImageVolumeFor3DManipulation",i.EnsureSegmentationVolumeFor3DManipulation="ensureSegmentationVolumeFor3DManipulation"})(dt||(dt={}));var Bt;(function(i){i.Interaction="Interaction",i.HandlesUpdated="HandlesUpdated",i.StatsUpdated="StatsUpdated",i.InitialSetup="InitialSetup",i.Completed="Completed",i.InterpolationUpdated="InterpolationUpdated",i.History="History",i.MetadataReferenceModified="MetadataReferenceModified",i.LabelChange="LabelChange"})(Bt||(Bt={}));var no;(function(i){i.POLYSEG_CONTOUR_TO_LABELMAP="Converting Contour to Labelmap",i.POLYSEG_SURFACE_TO_LABELMAP="Converting Surfaces to Labelmap",i.POLYSEG_CONTOUR_TO_SURFACE="Converting Contour to Surface",i.POLYSEG_LABELMAP_TO_SURFACE="Converting Labelmap to Surface",i.SURFACE_CLIPPING="Clipping Surfaces",i.COMPUTE_STATISTICS="Computing Statistics",i.INTERPOLATE_LABELMAP="Interpolating Labelmap",i.COMPUTE_LARGEST_BIDIRECTIONAL="Computing Largest Bidirectional",i.GENERATE_CONTOUR_SETS="Generating Contour Sets"})(no||(no={}));var Io;(function(i){i.Linear="Linear",i.Area="Area",i.Volume="Volume",i.Pixel="Pixel"})(Io||(Io={}));const yG=Object.freeze(Object.defineProperty({__proto__:null,AnnotationStyleStates:To,ChangeTypes:Bt,Events:E,get KeyboardBindings(){return vn},get MeasurementType(){return Io},get MouseBindings(){return Fo},SegmentationRepresentations:St,StrategyCallbacks:dt,get Swipe(){return ss},ToolModes:se,WorkerTypes:no},Symbol.toStringTag,{value:"Module"}));let Vl={};function xb(){Vl={}}const Mg={isInteractingWithTool:!1,isMultiPartToolActive:!1,tools:{},toolGroups:[],synchronizers:[],svgNodeCache:Vl,enabledElements:[],handleRadius:6};let $={isInteractingWithTool:!1,isMultiPartToolActive:!1,tools:{},toolGroups:[],synchronizers:[],svgNodeCache:Vl,enabledElements:[],handleRadius:6};function Pb(){xb(),$={...Re({...Mg,svgNodeCache:{}}),svgNodeCache:{...Mg.svgNodeCache}}}var Gd,Ag;function Db(){if(Ag)return Gd;Ag=1;var i="Expected a function",t="__lodash_hash_undefined__",n="[object Function]",e="[object GeneratorFunction]",o="[object Symbol]",s=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/,r=/^\./,c=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,l=/[\\^$.*+?()[\]{}|]/g,d=/\\(\\)?/g,u=/^\[object .+?Constructor\]$/,h=typeof Ic=="object"&&Ic&&Ic.Object===Object&&Ic,f=typeof self=="object"&&self&&self.Object===Object&&self,g=h||f||Function("return this")();function m(G,et){return G?.[et]}function p(G){var et=!1;if(G!=null&&typeof G.toString!="function")try{et=!!(G+"")}catch{}return et}var v=Array.prototype,I=Function.prototype,w=Object.prototype,C=g["__core-js_shared__"],S=(function(){var G=/[^.]+$/.exec(C&&C.keys&&C.keys.IE_PROTO||"");return G?"Symbol(src)_1."+G:""})(),b=I.toString,_=w.hasOwnProperty,y=w.toString,D=RegExp("^"+b.call(_).replace(l,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),T=g.Symbol,P=v.splice,x=Ht(g,"Map"),M=Ht(Object,"create"),L=T?T.prototype:void 0,R=L?L.toString:void 0;function U(G){var et=-1,at=G?G.length:0;for(this.clear();++et<at;){var jt=G[et];this.set(jt[0],jt[1])}}function W(){this.__data__=M?M(null):{}}function K(G){return this.has(G)&&delete this.__data__[G]}function j(G){var et=this.__data__;if(M){var at=et[G];return at===t?void 0:at}return _.call(et,G)?et[G]:void 0}function F(G){var et=this.__data__;return M?et[G]!==void 0:_.call(et,G)}function z(G,et){var at=this.__data__;return at[G]=M&&et===void 0?t:et,this}U.prototype.clear=W,U.prototype.delete=K,U.prototype.get=j,U.prototype.has=F,U.prototype.set=z;function q(G){var et=-1,at=G?G.length:0;for(this.clear();++et<at;){var jt=G[et];this.set(jt[0],jt[1])}}function J(){this.__data__=[]}function it(G){var et=this.__data__,at=te(et,G);if(at<0)return!1;var jt=et.length-1;return at==jt?et.pop():P.call(et,at,1),!0}function tt(G){var et=this.__data__,at=te(et,G);return at<0?void 0:et[at][1]}function ot(G){return te(this.__data__,G)>-1}function nt(G,et){var at=this.__data__,jt=te(at,G);return jt<0?at.push([G,et]):at[jt][1]=et,this}q.prototype.clear=J,q.prototype.delete=it,q.prototype.get=tt,q.prototype.has=ot,q.prototype.set=nt;function lt(G){var et=-1,at=G?G.length:0;for(this.clear();++et<at;){var jt=G[et];this.set(jt[0],jt[1])}}function rt(){this.__data__={hash:new U,map:new(x||q),string:new U}}function ut(G){return Ut(this,G).delete(G)}function Tt(G){return Ut(this,G).get(G)}function kt(G){return Ut(this,G).has(G)}function Pt(G,et){return Ut(this,G).set(G,et),this}lt.prototype.clear=rt,lt.prototype.delete=ut,lt.prototype.get=Tt,lt.prototype.has=kt,lt.prototype.set=Pt;function te(G,et){for(var at=G.length;at--;)if(Bo(G[at][0],et))return at;return-1}function Ie(G,et){et=Jt(et,G)?[et]:ce(et);for(var at=0,jt=et.length;G!=null&&at<jt;)G=G[Ve(et[at++])];return at&&at==jt?G:void 0}function re(G){if(!lo(G)||De(G))return!1;var et=yi(G)||p(G)?D:u;return et.test(Wo(G))}function Zt(G){if(typeof G=="string")return G;if(oi(G))return R?R.call(G):"";var et=G+"";return et=="0"&&1/G==-1/0?"-0":et}function ce(G){return co(G)?G:ln(G)}function Ut(G,et){var at=G.__data__;return Pe(et)?at[typeof et=="string"?"string":"hash"]:at.map}function Ht(G,et){var at=m(G,et);return re(at)?at:void 0}function Jt(G,et){if(co(G))return!1;var at=typeof G;return at=="number"||at=="symbol"||at=="boolean"||G==null||oi(G)?!0:a.test(G)||!s.test(G)||et!=null&&G in Object(et)}function Pe(G){var et=typeof G;return et=="string"||et=="number"||et=="symbol"||et=="boolean"?G!=="__proto__":G===null}function De(G){return!!S&&S in G}var ln=jn(function(G){G=st(G);var et=[];return r.test(G)&&et.push(""),G.replace(c,function(at,jt,je,dn){et.push(je?dn.replace(d,"$1"):jt||at)}),et});function Ve(G){if(typeof G=="string"||oi(G))return G;var et=G+"";return et=="0"&&1/G==-1/0?"-0":et}function Wo(G){if(G!=null){try{return b.call(G)}catch{}try{return G+""}catch{}}return""}function jn(G,et){if(typeof G!="function"||et&&typeof et!="function")throw new TypeError(i);var at=function(){var jt=arguments,je=et?et.apply(this,jt):jt[0],dn=at.cache;if(dn.has(je))return dn.get(je);var yo=G.apply(this,jt);return at.cache=dn.set(je,yo),yo};return at.cache=new(jn.Cache||lt),at}jn.Cache=lt;function Bo(G,et){return G===et||G!==G&&et!==et}var co=Array.isArray;function yi(G){var et=lo(G)?y.call(G):"";return et==n||et==e}function lo(G){var et=typeof G;return!!G&&(et=="object"||et=="function")}function xi(G){return!!G&&typeof G=="object"}function oi(G){return typeof G=="symbol"||xi(G)&&y.call(G)==o}function st(G){return G==null?"":Zt(G)}function Mt(G,et,at){var jt=G==null?void 0:Ie(G,et);return jt===void 0?at:jt}return Gd=Mt,Gd}var Tb=Db();const Mb=fb(Tb),Lg=Symbol("DefinedCursors"),kv=new Set(["alias","all-scroll","auto","cell","col-resize","context-menu","copy","crosshair","default","e-resize","ew-resize","grab","grabbing","help","move","ne-resize","nesw-resize","no-drop","none","not-allowed","n-resize","ns-resize","nw-resize","nwse-resize","pointer","progress","row-resize","se-resize","s-resize","sw-resize","text","vertical-text","wait","w-resize","zoom-in","zoom-out"]);class An{constructor(t,n){this.name=t+"",this.fallback=n}getName(){return this.name+""}addFallbackStyleProperty(t){const{fallback:n}=this;return n instanceof An?`${t}, ${n.getStyleProperty()}`:t+""}getStyleProperty(){return this.addFallbackStyleProperty(this.name)+""}static getDefinedCursor(t){const n=Og(An,Lg);let e=n.get(t);if(e instanceof An)return e;if(kv.has(t))return e=new An(t),n.set(t,e),e}static setDefinedCursor(t,n){return n instanceof An?(Og(An,Lg).set(t,n),!0):!1}}function Og(i,t){let n=i[t];return n instanceof Map||(n=new Map,Object.defineProperty(i,t,{value:n})),n}const Ab=kv.values(),Lb="image-cursor";class vr extends An{constructor(t,n,e,o,s){super(o||vr.getUniqueInstanceName(Lb),s),this.url=t,this.x=Number(n)||0,this.y=Number(e)||0}getStyleProperty(){const{url:t,x:n,y:e}=this;let o=`url('${t}')`;return n>=0&&e>=0&&(n>0||e>0)&&(o+=` ${n} ${e}`),this.addFallbackStyleProperty(o)}static getUniqueInstanceName(t){return`${t}-${sb(vr)}`}}const he={iconContent:"",iconSize:16,viewBox:{x:16,y:16},mousePoint:{x:8,y:8},mousePointerGroupString:`
2
2
  <path stroke="{{color}}" d="M8 16L8 0"></path>
3
3
  <path stroke="{{color}}" d="M16 8L0 8"></path>
4
4
  `},Xn={x:127,y:60},As=`
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-DfeCnMQa.js","./_commonjsHelpers-CE1G-McA.js","./index-Bm3uV1GS.js","./index-CIblWv2u.css"])))=>i.map(i=>d[i]);
2
+ import{_ as h,b as u,I as c}from"./index-Bm3uV1GS.js";const d={gray:"gray",hot:"hot",jet:"jet",cool:"cool"},m={wl:"contrast",pan:"pan",length:"measurement",angle:"angle"};class _{name="niivue";host;path;nv=null;module=null;layout="mpr";tool="wl";colormap="gray";slice=0;slices=0;refused=0;disposed=!1;constructor(s,t){this.host=s,this.path=t}async open(s){const t=document.createElement("canvas");t.className="image-canvas",s.appendChild(t),this.host.readout_set("LOADING"),this.host.progress_set({label:"READING VOLUME",done:0,total:0});const e=performance.now();if(this.module=await h(()=>import("./index-DfeCnMQa.js"),__vite__mapDeps([0,1,2,3]),import.meta.url),this.disposed)return;const i=new this.module.Niivue({isResizeCanvas:!0,logLevel:"error",dragAndDropEnabled:!1,crosshairWidth:.4,crosshairWidthUnit:"percent"});i.onLocationChange=o=>{const r=o,l=r.vox?.[2];l!==void 0&&(this.slice=l+1),this.host.readout_set(`${this.slices>0?`SLICE ${this.slice} OF ${this.slices} · `:""}${r.string??""}`)},await i.attachToCanvas(t);const n=this.path.split("/").pop()??"volume.nii.gz";try{await i.loadVolumes([{url:u(this.host.source.url_of(this.path),location.href),name:n}])}catch(o){this.refused=1,this.host.progress_set(null),this.host.readout_set("REFUSED 1 OF 1"),this.host.note(`image: ${this.path}: ${o instanceof Error?o.message:String(o)}`);return}if(this.host.progress_set(null),this.disposed)return;this.nv=i;const a=i.volumes[0]?.dims;this.slices=a?.[3]??0,i.setSliceType(i.sliceTypeMultiplanar),this.layout="mpr",this.host.readout_set(`${this.slices} SLICES`),this.host.note(`image: ${n} drawn in ${Math.round(performance.now()-e)} ms`),this.host.regard(this.path)}async layout_set(s){return s==="slab"||this.nv===null?!1:(this.nv.setSliceType(s==="single"?this.nv.sliceTypeAxial:s==="mpr"?this.nv.sliceTypeMultiplanar:this.nv.sliceTypeRender),this.layout=s,this.host.readout_set(`${this.slices} SLICES`),!0)}slice_set(s){if(this.nv===null||this.slices===0)return!1;const t=Math.max(1,Math.min(s,this.slices)),e=this.slice>0?this.slice:Math.ceil(this.slices/2);return this.nv.moveCrosshairInVox(0,0,t-e),this.slice=t,!0}wl_set(s,t){const e=this.nv?.volumes[0];return this.nv===null||e===void 0?!1:(e.cal_min=s,e.cal_max=t,this.nv.updateGLVolume(),!0)}colormap_set(s){const t=this.nv?.volumes[0];return this.nv===null||t?.id===void 0?!1:(this.colormap=s,this.nv.setColormap(t.id,d[s]),!0)}toolsOffered_get(){return c}ghost_set(s){return!1}tool_set(s){const t=m[s];return this.nv===null||t===void 0?!1:(this.nv.setDragMode(t),this.tool=s,!0)}annotations_export(){return Promise.resolve(null)}annotations_import(){return Promise.resolve(0)}async slices_fill(){return this.nv!==null}state_get(){return{engine:"niivue",layout:this.layout,slice:this.slice,slices:this.slices,tool:this.tool,primaryTool:this.tool,refused:this.refused,annotations:0,filled:this.nv!==null,colormap:this.colormap}}dispose(){this.disposed=!0,this.nv=null}}export{_ as NiivueEngine};
@@ -1,4 +1,4 @@
1
- import{m as v,as as _e,R as gt,K as Pe,L as Ge,W as ke,N as Le,k as de,E as j,t as ft,i as Me,x as ce,F as vt,Z as ht,h as St,D as dt,al as Tt,c as wt,at as yt,d as Ve,au as Ct,y as ue,ak as le,av as We,j as pe}from"./cornerstoneEngine-CGEzAsx7.js";import{ae as ze,am as De,an as ae,K as D,k as Q,al as W,D as se,U as Ne,X as Be,B as b,J as xt,E as Et,ak as Rt,$ as $e,a2 as _t,Z as Mt,b as Vt,_ as Ke,ao as Dt,ap as He,aq as Bt,ar as Te,as as mt,z as Ot,at as Ut,au as Ft,av as re,ad as Pt,R as Gt,aw as I,ah as kt,ai as Lt,C as Wt,P as zt,I as Nt,a as $t}from"./Texture-C99vHuBO.js";import"./index-Dtsm0q-Z.js";import"./_commonjsHelpers-CE1G-McA.js";function Kt(t){return t}function ye(t){if(t===null||t==="null")return null;if(t==="true")return!0;if(t==="false")return!1;if(!(t===void 0||t==="undefined"))return t[0]==="["&&t[t.length-1]==="]"?t.substring(1,t.length-1).split(",").map(e=>ye(e.trim())):t===""||Number.isNaN(Number(t))?t:Number(t)}function Ht(t=!0,e=window.location.search){const a={},s=t?ye:Kt;return new URLSearchParams(e).forEach((n,r)=>{r&&(a[r]=n?s(n):!0)}),a}var bt={toNativeType:ye,extractURLParameters:Ht},It={IS_START:0,IS_NONE:0,IS_ROTATE:1,IS_PAN:2,IS_SPIN:3,IS_DOLLY:4,IS_CAMERA_POSE:11,IS_WINDOW_LEVEL:1024,IS_SLICE:1025},Ce={States:It},{vtkErrorMacro:jt,VOID:Qt}=v;function Yt(t,e,a,s){return t.getRenderWindow().getViews()[0].worldToDisplay(e,a,s,t)}function Xt(t,e,a,s){return t.getRenderWindow().getViews()[0].displayToWorld(e,a,s,t)}var Zt={computeWorldToDisplay:Yt,computeDisplayToWorld:Xt};function Jt(t,e){e.classHierarchy.push("vtkInteractorObserver");const a={...t};function s(){for(;e.subscribedEvents.length;)e.subscribedEvents.pop().unsubscribe()}function n(){ze.handledEvents.forEach(r=>{t[`handle${r}`]&&e.subscribedEvents.push(e._interactor[`on${r}`](o=>e.processEvents?t[`handle${r}`](o):Qt,e.priority))})}t.setInteractor=r=>{r!==e._interactor&&(s(),e._interactor=r,r&&e.enabled&&n(),t.modified())},t.setEnabled=r=>{r!==e.enabled&&(s(),r&&(e._interactor?n():jt(`
1
+ import{m as v,as as _e,R as gt,K as Pe,L as Ge,W as ke,N as Le,k as de,E as j,t as ft,i as Me,x as ce,F as vt,Z as ht,h as St,D as dt,al as Tt,c as wt,at as yt,d as Ve,au as Ct,y as ue,ak as le,av as We,j as pe}from"./cornerstoneEngine-DgoPMn1N.js";import{ae as ze,am as De,an as ae,K as D,k as Q,al as W,D as se,U as Ne,X as Be,B as b,J as xt,E as Et,ak as Rt,$ as $e,a2 as _t,Z as Mt,b as Vt,_ as Ke,ao as Dt,ap as He,aq as Bt,ar as Te,as as mt,z as Ot,at as Ut,au as Ft,av as re,ad as Pt,R as Gt,aw as I,ah as kt,ai as Lt,C as Wt,P as zt,I as Nt,a as $t}from"./Texture-BFywN4BL.js";import"./index-Bm3uV1GS.js";import"./_commonjsHelpers-CE1G-McA.js";function Kt(t){return t}function ye(t){if(t===null||t==="null")return null;if(t==="true")return!0;if(t==="false")return!1;if(!(t===void 0||t==="undefined"))return t[0]==="["&&t[t.length-1]==="]"?t.substring(1,t.length-1).split(",").map(e=>ye(e.trim())):t===""||Number.isNaN(Number(t))?t:Number(t)}function Ht(t=!0,e=window.location.search){const a={},s=t?ye:Kt;return new URLSearchParams(e).forEach((n,r)=>{r&&(a[r]=n?s(n):!0)}),a}var bt={toNativeType:ye,extractURLParameters:Ht},It={IS_START:0,IS_NONE:0,IS_ROTATE:1,IS_PAN:2,IS_SPIN:3,IS_DOLLY:4,IS_CAMERA_POSE:11,IS_WINDOW_LEVEL:1024,IS_SLICE:1025},Ce={States:It},{vtkErrorMacro:jt,VOID:Qt}=v;function Yt(t,e,a,s){return t.getRenderWindow().getViews()[0].worldToDisplay(e,a,s,t)}function Xt(t,e,a,s){return t.getRenderWindow().getViews()[0].displayToWorld(e,a,s,t)}var Zt={computeWorldToDisplay:Yt,computeDisplayToWorld:Xt};function Jt(t,e){e.classHierarchy.push("vtkInteractorObserver");const a={...t};function s(){for(;e.subscribedEvents.length;)e.subscribedEvents.pop().unsubscribe()}function n(){ze.handledEvents.forEach(r=>{t[`handle${r}`]&&e.subscribedEvents.push(e._interactor[`on${r}`](o=>e.processEvents?t[`handle${r}`](o):Qt,e.priority))})}t.setInteractor=r=>{r!==e._interactor&&(s(),e._interactor=r,r&&e.enabled&&n(),t.modified())},t.setEnabled=r=>{r!==e.enabled&&(s(),r&&(e._interactor?n():jt(`
2
2
  The interactor must be set before subscribing to events
3
3
  `)),e.enabled=r,t.modified())},t.computeDisplayToWorld=(r,o,i,u)=>r?e._interactor.getView().displayToWorld(o,i,u,r):null,t.computeWorldToDisplay=(r,o,i,u)=>r?e._interactor.getView().worldToDisplay(o,i,u,r):null,t.setPriority=r=>{a.setPriority(r)&&e._interactor&&(s(),n())}}var qt={enabled:!0,priority:0,processEvents:!0,subscribedEvents:[]};function be(t,e,a={}){Object.assign(e,qt,a),v.obj(t,e),v.event(t,e,"InteractionEvent"),v.event(t,e,"StartInteractionEvent"),v.event(t,e,"EndInteractionEvent"),v.get(t,e,["_interactor","enabled"]),v.setGet(t,e,["priority","processEvents"]),v.moveToProtected(t,e,["interactor"]),Jt(t,e)}var At=v.newInstance(be,"vtkInteractorObserver"),en={newInstance:At,extend:be,...Zt},{States:L}=Ce,ge={Rotate:L.IS_ROTATE,Pan:L.IS_PAN,Spin:L.IS_SPIN,Dolly:L.IS_DOLLY,CameraPose:L.IS_CAMERA_POSE,WindowLevel:L.IS_WINDOW_LEVEL,Slice:L.IS_SLICE};function tn(t,e){e.classHierarchy.push("vtkInteractorStyle"),Object.keys(ge).forEach(a=>{v.event(t,e,`Start${a}Event`),t[`start${a}`]=()=>{e.state===L.IS_NONE&&(e.state=ge[a],e._interactor.requestAnimation(t),t.invokeStartInteractionEvent({type:"StartInteractionEvent"}),t[`invokeStart${a}Event`]({type:`Start${a}Event`}))},v.event(t,e,`End${a}Event`),t[`end${a}`]=()=>{e.state===ge[a]&&(e.state=L.IS_NONE,e._interactor.cancelAnimation(t),t.invokeEndInteractionEvent({type:"EndInteractionEvent"}),t[`invokeEnd${a}Event`]({type:`End${a}Event`}),e._interactor.render())}}),e.getRenderer=a=>e.focusedRenderer||a.pokedRenderer,t.handleKeyPress=a=>{const s=e._interactor;let n=null;switch(a.key){case"r":case"R":e.getRenderer(a).resetCamera(),s.render();break;case"w":case"W":n=e.getRenderer(a).getActors(),n.forEach(r=>{const o=r.getProperty();o.setRepresentationToWireframe&&o.setRepresentationToWireframe()}),s.render();break;case"s":case"S":n=e.getRenderer(a).getActors(),n.forEach(r=>{const o=r.getProperty();o.setRepresentationToSurface&&o.setRepresentationToSurface()}),s.render();break;case"v":case"V":n=e.getRenderer(a).getActors(),n.forEach(r=>{const o=r.getProperty();o.setRepresentationToPoints&&o.setRepresentationToPoints()}),s.render();break}}}var nn={state:L.IS_NONE,handleObservers:1,autoAdjustCameraClippingRange:1};function Ie(t,e,a={}){Object.assign(e,nn,a),en.extend(t,e,a),v.setGet(t,e,["focusedRenderer"]),tn(t,e)}var an=v.newInstance(Ie,"vtkInteractorStyle"),xe={newInstance:an,extend:Ie,...Ce},{States:G}=Ce;function rn(t,e){e.classHierarchy.push("vtkInteractorStyleTrackballCamera"),t.handleMouseMove=a=>{const s=a.position,n=e.getRenderer(a);switch(e.state){case G.IS_ROTATE:t.handleMouseRotate(n,s),t.invokeInteractionEvent({type:"InteractionEvent"});break;case G.IS_PAN:t.handleMousePan(n,s),t.invokeInteractionEvent({type:"InteractionEvent"});break;case G.IS_DOLLY:e.wheelDolly||(t.handleMouseDolly(n,s),t.invokeInteractionEvent({type:"InteractionEvent"}));break;case G.IS_SPIN:t.handleMouseSpin(n,s),t.invokeInteractionEvent({type:"InteractionEvent"});break}e.previousPosition=s},t.handleButton3D=a=>{if(a&&a.pressed&&a.device===De.RightController&&(a.input===ae.Trigger||a.input===ae.TrackPad)){t.startCameraPose();return}a&&!a.pressed&&a.device===De.RightController&&(a.input===ae.Trigger||a.input===ae.TrackPad)&&e.state===G.IS_CAMERA_POSE&&t.endCameraPose()},t.handleMove3D=a=>{e.state===G.IS_CAMERA_POSE&&t.updateCameraPose(a)},t.updateCameraPose=a=>{const s=e.getRenderer(a).getActiveCamera(),n=s.getPhysicalTranslation(),r=.5*.05*s.getPhysicalScale(),o=s.physicalOrientationToWorldDirection([a.orientation.x,a.orientation.y,a.orientation.z,a.orientation.w]);s.setPhysicalTranslation(n[0]+o[0]*r,n[1]+o[1]*r,n[2]+o[2]*r)},t.handleLeftButtonPress=a=>{e.previousPosition=a.position,a.shiftKey?a.controlKey||a.altKey?t.startDolly():t.startPan():a.controlKey||a.altKey?t.startSpin():t.startRotate()},t.handleLeftButtonRelease=()=>{switch(e.state){case G.IS_DOLLY:t.endDolly();break;case G.IS_PAN:t.endPan();break;case G.IS_SPIN:t.endSpin();break;case G.IS_ROTATE:t.endRotate();break}},t.handleStartMouseWheel=()=>{e.wheelDolly=!0,t.startDolly()},t.handleEndMouseWheel=()=>{t.endDolly(),e.wheelDolly=!1},t.handleStartPinch=a=>{e.previousScale=a.scale,t.startDolly()},t.handleEndPinch=()=>{t.endDolly()},t.handleStartRotate=a=>{e.previousRotation=a.rotation,t.startRotate()},t.handleEndRotate=()=>{t.endRotate()},t.handleStartPan=a=>{e.previousTranslation=a.translation,t.startPan()},t.handleEndPan=()=>{t.endPan()},t.handlePinch=a=>{t.dollyByFactor(e.getRenderer(a),a.scale/e.previousScale),e.previousScale=a.scale},t.handlePan=a=>{const s=e.getRenderer(a).getActiveCamera();let n=s.getFocalPoint();n=t.computeWorldToDisplay(e.getRenderer(a),n[0],n[1],n[2]);const r=n[2],o=a.translation,i=e.previousTranslation,u=t.computeDisplayToWorld(e.getRenderer(a),n[0]+o[0]-i[0],n[1]+o[1]-i[1],r),p=t.computeDisplayToWorld(e.getRenderer(a),n[0],n[1],r),c=[];c[0]=p[0]-u[0],c[1]=p[1]-u[1],c[2]=p[2]-u[2],n=s.getFocalPoint();const l=s.getPosition();s.setFocalPoint(c[0]+n[0],c[1]+n[1],c[2]+n[2]),s.setPosition(c[0]+l[0],c[1]+l[1],c[2]+l[2]),e._interactor.getLightFollowCamera()&&e.getRenderer(a).updateLightsGeometryToFollowCamera(),s.orthogonalizeViewUp(),e.previousTranslation=a.translation},t.handleRotate=a=>{const s=e.getRenderer(a).getActiveCamera();s.roll(a.rotation-e.previousRotation),s.orthogonalizeViewUp(),e.previousRotation=a.rotation},t.handleMouseRotate=(a,s)=>{if(!e.previousPosition)return;const n=e._interactor,r=s.x-e.previousPosition.x,o=s.y-e.previousPosition.y,i=n.getView().getViewportSize(a);let u=-.1,p=-.1;i[0]&&i[1]&&(u=-20/i[1],p=-20/i[0]);const c=r*p*e.motionFactor,l=o*u*e.motionFactor,g=a.getActiveCamera();!Number.isNaN(c)&&!Number.isNaN(l)&&(g.azimuth(c),g.elevation(l),g.orthogonalizeViewUp()),e.autoAdjustCameraClippingRange&&a.resetCameraClippingRange(),n.getLightFollowCamera()&&a.updateLightsGeometryToFollowCamera()},t.handleMouseSpin=(a,s)=>{if(!e.previousPosition)return;const n=e._interactor,r=a.getActiveCamera(),o=n.getView().getViewportCenter(a),i=_e(Math.atan2(e.previousPosition.y-o[1],e.previousPosition.x-o[0])),u=_e(Math.atan2(s.y-o[1],s.x-o[0]))-i;Number.isNaN(u)||(r.roll(u),r.orthogonalizeViewUp())},t.handleMousePan=(a,s)=>{if(!e.previousPosition)return;const n=a.getActiveCamera();let r=n.getFocalPoint();r=t.computeWorldToDisplay(a,r[0],r[1],r[2]);const o=r[2],i=t.computeDisplayToWorld(a,s.x,s.y,o),u=t.computeDisplayToWorld(a,e.previousPosition.x,e.previousPosition.y,o),p=[];p[0]=u[0]-i[0],p[1]=u[1]-i[1],p[2]=u[2]-i[2],r=n.getFocalPoint();const c=n.getPosition();n.setFocalPoint(p[0]+r[0],p[1]+r[1],p[2]+r[2]),n.setPosition(p[0]+c[0],p[1]+c[1],p[2]+c[2]),e._interactor.getLightFollowCamera()&&a.updateLightsGeometryToFollowCamera()},t.handleMouseDolly=(a,s)=>{if(!e.previousPosition)return;const n=s.y-e.previousPosition.y,r=e._interactor.getView().getViewportCenter(a),o=e.motionFactor*n/r[1];t.dollyByFactor(a,1.1**o)},t.handleMouseWheel=a=>{const s=1-a.spinY/e.zoomFactor;t.dollyByFactor(e.getRenderer(a),s)},t.dollyByFactor=(a,s)=>{if(Number.isNaN(s))return;const n=a.getActiveCamera();n.getParallelProjection()?n.setParallelScale(n.getParallelScale()/s):(n.dolly(s),e.autoAdjustCameraClippingRange&&a.resetCameraClippingRange()),e._interactor.getLightFollowCamera()&&a.updateLightsGeometryToFollowCamera()}}var sn={motionFactor:10,zoomFactor:10,wheelDolly:!1};function je(t,e,a={}){Object.assign(e,sn,a),xe.extend(t,e,a),v.setGet(t,e,["motionFactor","zoomFactor"]),rn(t,e)}var on=v.newInstance(je,"vtkInteractorStyleTrackballCamera"),cn={newInstance:on,extend:je},{vtkErrorMacro:un}=gt,fe=["setBindGroup","setIndexBuffer","setVertexBuffer","draw","drawIndexed"];function ln(t,e){e.classHierarchy.push("vtkWebGPURenderEncoder"),t.begin=a=>{e.drawCallbacks=[],e.handle=a.beginRenderPass(e.description),e.label&&e.handle.pushDebugGroup(e.label)},t.end=()=>{for(let a=0;a<e.drawCallbacks.length;a++){const s=e.drawCallbacks[a],n=s.pipeline;t.setPipeline(n);for(let r=0;r<s.callbacks.length;r++)s.callbacks[r](t)}e.label&&e.handle.popDebugGroup(),e.handle.end(),e.boundPipeline=null},t.setPipeline=a=>{if(e.boundPipeline===a)return;e.handle.setPipeline(a.getHandle());const s=a.getPipelineDescription(),n=s.fragment?.targets;if(e.colorTextureViews.length!==n.length)console.log(`mismatched attachment counts on pipeline ${n.length} while encoder has ${e.colorTextureViews.length}`),console.trace();else for(let r=0;r<e.colorTextureViews.length;r++){const o=e.colorTextureViews[r].getTexture()?.getFormat();o&&o!==n[r].format&&(console.log(`mismatched attachments for attachment ${r} on pipeline ${n[r].format} while encoder has ${o}`),console.trace())}if(!!e.depthTextureView!="depthStencil"in s)console.log("mismatched depth attachments"),console.trace();else if(e.depthTextureView){const r=e.depthTextureView.getTexture()?.getFormat();r&&r!==s.depthStencil.format&&(console.log(`mismatched depth attachments on pipeline ${s.depthStencil.format} while encoder has ${r}`),console.trace())}e.boundPipeline=a},t.replaceShaderCode=a=>{e.replaceShaderCodeFunction(a)},t.setColorTextureView=(a,s)=>{e.colorTextureViews[a]!==s&&(e.colorTextureViews[a]=s)},t.activateBindGroup=a=>{const s=e.boundPipeline.getDevice(),n=e.boundPipeline.getBindGroupLayoutIndex(a.getLabel());if(n<0){un(`vtkWebGPURenderEncoder: could not find bind group layout ${a.getLabel()}`);return}e.handle.setBindGroup(n,a.getBindGroup(s));const r=s.getBindGroupLayoutDescription(a.getBindGroupLayout(s)),o=s.getBindGroupLayoutDescription(e.boundPipeline.getBindGroupLayout(n));r!==o&&(console.log(`renderEncoder ${e.pipelineHash} mismatched bind group layouts bind group has
4
4
  ${r}
package/dist/index.html CHANGED
@@ -12,7 +12,7 @@
12
12
  href="https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap"
13
13
  rel="stylesheet"
14
14
  />
15
- <script type="module" crossorigin src="./assets/index-Dtsm0q-Z.js"></script>
15
+ <script type="module" crossorigin src="./assets/index-Bm3uV1GS.js"></script>
16
16
  <link rel="stylesheet" crossorigin href="./assets/index-CIblWv2u.css">
17
17
  </head>
18
18
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fnndsc/argus",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "ARGUS: the LCARS web surface for mise — a browser console over a calypso session",
5
5
  "type": "module",
6
6
  "scripts": {