@ohif/ui 3.13.0-beta.116 → 3.13.0-beta.117
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.
- package/dist/ohif-ui.umd.js +1 -1
- package/package.json +1 -1
package/dist/ohif-ui.umd.js
CHANGED
|
@@ -6,7 +6,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
6
6
|
`);var Lu=e=>{var t,r,n,a,i,o,s,l,u,c,d,h,p,f;let{invert:m,toast:g,unstyled:y,interacting:v,setHeights:b,visibleToasts:w,heights:x,index:C,toasts:k,expanded:M,removeToast:E,defaultRichColors:S,closeButton:D,style:I,cancelButtonStyle:P,actionButtonStyle:T,className:_="",descriptionClassName:A="",duration:O,position:R,gap:L,loadingIcon:N,expandByDefault:F,classNames:V,icons:B,closeButtonAriaLabel:j="Close toast",pauseWhenPageIsHidden:W}=e,[U,z]=em.useState(null),[H,G]=em.useState(null),[q,$]=em.useState(!1),[K,Y]=em.useState(!1),[X,Z]=em.useState(!1),[J,Q]=em.useState(!1),[ee,et]=em.useState(!1),[er,en]=em.useState(0),[ea,ei]=em.useState(0),eo=em.useRef(g.duration||O||4e3),es=em.useRef(null),el=em.useRef(null),eu=0===C,ec=C+1<=w,ed=g.type,eh=!1!==g.dismissible,ep=g.className||"",ef=g.descriptionClassName||"",eg=em.useMemo(()=>x.findIndex(e=>e.toastId===g.id)||0,[x,g.id]),ey=em.useMemo(()=>{var e;return null!=(e=g.closeButton)?e:D},[g.closeButton,D]),ev=em.useMemo(()=>g.duration||O||4e3,[g.duration,O]),eb=em.useRef(0),ew=em.useRef(0),ex=em.useRef(0),eC=em.useRef(null),[ek,eM]=R.split("-"),eE=em.useMemo(()=>x.reduce((e,t,r)=>r>=eg?e:e+t.height,0),[x,eg]),eS=(()=>{let[e,t]=em.useState(document.hidden);return em.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",e),()=>window.removeEventListener("visibilitychange",e)},[]),e})(),eD=g.invert||m,eI="loading"===ed;ew.current=em.useMemo(()=>eg*L+eE,[eg,eE]),em.useEffect(()=>{eo.current=ev},[ev]),em.useEffect(()=>{$(!0)},[]),em.useEffect(()=>{let e=el.current;if(e){let t=e.getBoundingClientRect().height;return ei(t),b(e=>[{toastId:g.id,height:t,position:g.position},...e]),()=>b(e=>e.filter(e=>e.toastId!==g.id))}},[b,g.id]),em.useLayoutEffect(()=>{if(!q)return;let e=el.current,t=e.style.height;e.style.height="auto";let r=e.getBoundingClientRect().height;e.style.height=t,ei(r),b(e=>e.find(e=>e.toastId===g.id)?e.map(e=>e.toastId===g.id?{...e,height:r}:e):[{toastId:g.id,height:r,position:g.position},...e])},[q,g.title,g.description,b,g.id]);let eP=em.useCallback(()=>{Y(!0),en(ew.current),b(e=>e.filter(e=>e.toastId!==g.id)),setTimeout(()=>{E(g)},200)},[g,E,b,ew]);return em.useEffect(()=>{let e;if((!g.promise||"loading"!==ed)&&g.duration!==1/0&&"loading"!==g.type)return M||v||W&&eS?(()=>{if(ex.current<eb.current){let e=new Date().getTime()-eb.current;eo.current=eo.current-e}ex.current=new Date().getTime()})():eo.current!==1/0&&(eb.current=new Date().getTime(),e=setTimeout(()=>{var e;null==(e=g.onAutoClose)||e.call(g,g),eP()},eo.current)),()=>clearTimeout(e)},[M,v,g,ed,W,eS,eP]),em.useEffect(()=>{g.delete&&eP()},[eP,g.delete]),em.createElement("li",{tabIndex:0,ref:el,className:Ll(_,ep,null==V?void 0:V.toast,null==(t=null==g?void 0:g.classNames)?void 0:t.toast,null==V?void 0:V.default,null==V?void 0:V[ed],null==(r=null==g?void 0:g.classNames)?void 0:r[ed]),"data-sonner-toast":"","data-rich-colors":null!=(n=g.richColors)?n:S,"data-styled":!(g.jsx||g.unstyled||y),"data-mounted":q,"data-promise":!!g.promise,"data-swiped":ee,"data-removed":K,"data-visible":ec,"data-y-position":ek,"data-x-position":eM,"data-index":C,"data-front":eu,"data-swiping":X,"data-dismissible":eh,"data-type":ed,"data-invert":eD,"data-swipe-out":J,"data-swipe-direction":H,"data-expanded":!!(M||F&&q),style:{"--index":C,"--toasts-before":C,"--z-index":k.length-C,"--offset":`${K?er:ew.current}px`,"--initial-height":F?"auto":`${ea}px`,...I,...g.style},onDragEnd:()=>{Z(!1),z(null),eC.current=null},onPointerDown:e=>{eI||!eh||(es.current=new Date,en(ew.current),e.target.setPointerCapture(e.pointerId),"BUTTON"!==e.target.tagName&&(Z(!0),eC.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{var e,t,r,n;if(J||!eh)return;eC.current=null;let a=Number((null==(e=el.current)?void 0:e.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),i=Number((null==(t=el.current)?void 0:t.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),o=new Date().getTime()-(null==(r=es.current)?void 0:r.getTime()),s="x"===U?a:i,l=Math.abs(s)/o;if(Math.abs(s)>=20||l>.11){en(ew.current),null==(n=g.onDismiss)||n.call(g,g),G("x"===U?a>0?"right":"left":i>0?"down":"up"),eP(),Q(!0),et(!1);return}Z(!1),z(null)},onPointerMove:t=>{var r,n,a,i;if(!eC.current||!eh||(null==(r=window.getSelection())?void 0:r.toString().length)>0)return;let o=t.clientY-eC.current.y,s=t.clientX-eC.current.x,l=null!=(n=e.swipeDirections)?n:function(e){let[t,r]=e.split("-"),n=[];return t&&n.push(t),r&&n.push(r),n}(R);!U&&(Math.abs(s)>1||Math.abs(o)>1)&&z(Math.abs(s)>Math.abs(o)?"x":"y");let u={x:0,y:0};"y"===U?(l.includes("top")||l.includes("bottom"))&&(l.includes("top")&&o<0||l.includes("bottom")&&o>0)&&(u.y=o):"x"===U&&(l.includes("left")||l.includes("right"))&&(l.includes("left")&&s<0||l.includes("right")&&s>0)&&(u.x=s),(Math.abs(u.x)>0||Math.abs(u.y)>0)&&et(!0),null==(a=el.current)||a.style.setProperty("--swipe-amount-x",`${u.x}px`),null==(i=el.current)||i.style.setProperty("--swipe-amount-y",`${u.y}px`)}},ey&&!g.jsx?em.createElement("button",{"aria-label":j,"data-disabled":eI,"data-close-button":!0,onClick:eI||!eh?()=>{}:()=>{var e;eP(),null==(e=g.onDismiss)||e.call(g,g)},className:Ll(null==V?void 0:V.closeButton,null==(a=null==g?void 0:g.classNames)?void 0:a.closeButton)},null!=(i=null==B?void 0:B.close)?i:Ln):null,g.jsx||(0,em.isValidElement)(g.title)?g.jsx?g.jsx:"function"==typeof g.title?g.title():g.title:em.createElement(em.Fragment,null,ed||g.icon||g.promise?em.createElement("div",{"data-icon":"",className:Ll(null==V?void 0:V.icon,null==(o=null==g?void 0:g.classNames)?void 0:o.icon)},g.promise||"loading"===g.type&&!g.icon?g.icon||(null!=B&&B.loading?em.createElement("div",{className:Ll(null==V?void 0:V.loader,null==(h=null==g?void 0:g.classNames)?void 0:h.loader,"sonner-loader"),"data-visible":"loading"===ed},B.loading):N?em.createElement("div",{className:Ll(null==V?void 0:V.loader,null==(p=null==g?void 0:g.classNames)?void 0:p.loader,"sonner-loader"),"data-visible":"loading"===ed},N):em.createElement(R9,{className:Ll(null==V?void 0:V.loader,null==(f=null==g?void 0:g.classNames)?void 0:f.loader),visible:"loading"===ed})):null,"loading"!==g.type?g.icon||(null==B?void 0:B[ed])||(e=>{switch(e){case"success":return R7;case"info":return Lt;case"warning":return Le;case"error":return Lr;default:return null}})(ed):null):null,em.createElement("div",{"data-content":"",className:Ll(null==V?void 0:V.content,null==(s=null==g?void 0:g.classNames)?void 0:s.content)},em.createElement("div",{"data-title":"",className:Ll(null==V?void 0:V.title,null==(l=null==g?void 0:g.classNames)?void 0:l.title)},"function"==typeof g.title?g.title():g.title),g.description?em.createElement("div",{"data-description":"",className:Ll(A,ef,null==V?void 0:V.description,null==(u=null==g?void 0:g.classNames)?void 0:u.description)},"function"==typeof g.description?g.description():g.description):null),(0,em.isValidElement)(g.cancel)?g.cancel:g.cancel&&Ls(g.cancel)?em.createElement("button",{"data-button":!0,"data-cancel":!0,style:g.cancelButtonStyle||P,onClick:e=>{var t,r;Ls(g.cancel)&&eh&&(null==(r=(t=g.cancel).onClick)||r.call(t,e),eP())},className:Ll(null==V?void 0:V.cancelButton,null==(c=null==g?void 0:g.classNames)?void 0:c.cancelButton)},g.cancel.label):null,(0,em.isValidElement)(g.action)?g.action:g.action&&Ls(g.action)?em.createElement("button",{"data-button":!0,"data-action":!0,style:g.actionButtonStyle||T,onClick:e=>{var t,r;Ls(g.action)&&(null==(r=(t=g.action).onClick)||r.call(t,e),e.defaultPrevented||eP())},className:Ll(null==V?void 0:V.actionButton,null==(d=null==g?void 0:g.classNames)?void 0:d.actionButton)},g.action.label):null))};function Lc(){if("u"<typeof window||"u"<typeof document)return"ltr";let e=document.documentElement.getAttribute("dir");return"auto"!==e&&e?e:window.getComputedStyle(document.documentElement).direction}(0,em.forwardRef)(function(e,t){let{invert:r,position:n="bottom-right",hotkey:a=["altKey","KeyT"],expand:i,closeButton:o,className:s,offset:l,mobileOffset:u,theme:c="light",richColors:d,duration:h,style:p,visibleToasts:f=3,toastOptions:m,dir:g=Lc(),gap:y=14,loadingIcon:v,icons:b,containerAriaLabel:w="Notifications",pauseWhenPageIsHidden:x}=e,[C,k]=em.useState([]),M=em.useMemo(()=>Array.from(new Set([n].concat(C.filter(e=>e.position).map(e=>e.position)))),[C,n]),[E,S]=em.useState([]),[D,I]=em.useState(!1),[P,T]=em.useState(!1),[_,A]=em.useState("system"!==c?c:"u">typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),O=em.useRef(null),R=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),L=em.useRef(null),N=em.useRef(!1),F=em.useCallback(e=>{k(t=>{var r;return null!=(r=t.find(t=>t.id===e.id))&&r.delete||Li.dismiss(e.id),t.filter(({id:t})=>t!==e.id)})},[]);return em.useEffect(()=>Li.subscribe(e=>{e.dismiss?k(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t)):setTimeout(()=>{rT.flushSync(()=>{k(t=>{let r=t.findIndex(t=>t.id===e.id);return -1!==r?[...t.slice(0,r),{...t[r],...e},...t.slice(r+1)]:[e,...t]})})})}),[]),em.useEffect(()=>{if("system"!==c)return void A(c);if("system"===c&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?A("dark"):A("light")),"u"<typeof window)return;let e=window.matchMedia("(prefers-color-scheme: dark)");try{e.addEventListener("change",({matches:e})=>{A(e?"dark":"light")})}catch(t){e.addListener(({matches:e})=>{try{A(e?"dark":"light")}catch(e){console.error(e)}})}},[c]),em.useEffect(()=>{C.length<=1&&I(!1)},[C]),em.useEffect(()=>{let e=e=>{var t,r;a.every(t=>e[t]||e.code===t)&&(I(!0),null==(t=O.current)||t.focus()),"Escape"===e.code&&(document.activeElement===O.current||null!=(r=O.current)&&r.contains(document.activeElement))&&I(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[a]),em.useEffect(()=>{if(O.current)return()=>{L.current&&(L.current.focus({preventScroll:!0}),L.current=null,N.current=!1)}},[O.current]),em.createElement("section",{ref:t,"aria-label":`${w} ${R}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},M.map((t,n)=>{var a;let c,[w,k]=t.split("-");return C.length?em.createElement("ol",{key:t,dir:"auto"===g?Lc():g,tabIndex:-1,ref:O,className:s,"data-sonner-toaster":!0,"data-theme":_,"data-y-position":w,"data-lifted":D&&C.length>1&&!i,"data-x-position":k,style:{"--front-toast-height":`${(null==(a=E[0])?void 0:a.height)||0}px`,"--width":"356px","--gap":`${y}px`,...p,...(c={},[l,u].forEach((e,t)=>{let r=1===t,n=r?"--mobile-offset":"--offset",a=r?"16px":"32px";function i(e){["top","right","bottom","left"].forEach(t=>{c[`${n}-${t}`]="number"==typeof e?`${e}px`:e})}"number"==typeof e||"string"==typeof e?i(e):"object"==typeof e?["top","right","bottom","left"].forEach(t=>{void 0===e[t]?c[`${n}-${t}`]=a:c[`${n}-${t}`]="number"==typeof e[t]?`${e[t]}px`:e[t]}):i(a)}),c)},onBlur:e=>{N.current&&!e.currentTarget.contains(e.relatedTarget)&&(N.current=!1,L.current&&(L.current.focus({preventScroll:!0}),L.current=null))},onFocus:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||N.current||(N.current=!0,L.current=e.relatedTarget)},onMouseEnter:()=>I(!0),onMouseMove:()=>I(!0),onMouseLeave:()=>{P||I(!1)},onDragEnd:()=>I(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||T(!0)},onPointerUp:()=>T(!1)},C.filter(e=>!e.position&&0===n||e.position===t).map((n,a)=>{var s,l;return em.createElement(Lu,{key:n.id,icons:b,index:a,toast:n,defaultRichColors:d,duration:null!=(s=null==m?void 0:m.duration)?s:h,className:null==m?void 0:m.className,descriptionClassName:null==m?void 0:m.descriptionClassName,invert:r,visibleToasts:f,closeButton:null!=(l=null==m?void 0:m.closeButton)?l:o,interacting:P,position:t,style:null==m?void 0:m.style,unstyled:null==m?void 0:m.unstyled,classNames:null==m?void 0:m.classNames,cancelButtonStyle:null==m?void 0:m.cancelButtonStyle,actionButtonStyle:null==m?void 0:m.actionButtonStyle,removeToast:F,toasts:C.filter(e=>e.position==n.position),heights:E.filter(e=>e.position==n.position),setHeights:S,expandByDefault:i,gap:y,loadingIcon:v,expanded:D,pauseWhenPageIsHidden:x,swipeDirections:e.swipeDirections})})):null}))});em.Component,ec().node.isRequired,ec().object,ec().number;var Ld=u(2816);let Lh={COMMANDS:"commandsModule",CUSTOMIZATION:"customizationModule",STATE_SYNC:"stateSyncModule",DATA_SOURCE:"dataSourcesModule",PANEL:"panelModule",SOP_CLASS_HANDLER:"sopClassHandlerModule",TOOLBAR:"toolbarModule",VIEWPORT:"viewportModule",CONTEXT:"contextModule",LAYOUT_TEMPLATE:"layoutTemplateModule",HANGING_PROTOCOL:"hangingProtocolModule",UTILITY:"utilityModule"},Lp={error:console.error,warn:console.warn,info:console.log,trace:console.trace,debug:console.debug,time:e=>{Lp.timingKeys[e]=!0,console.time(e)},timeEnd:e=>{Lp.timingKeys[e]&&(Lp.timingKeys[e]=!1,console.timeEnd(e))},timingKeys:{scriptToView:!0}},Lf=()=>{let e=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()},Lm=function(e,t,r){var n;let a=function(){var a=this,i=arguments,o=r&&!n;clearTimeout(n),n=setTimeout(function(){n=null,r||e.apply(a,i)},t),o&&e.apply(a,i)};return a.clearDebounceTimeout=()=>{clearTimeout(n),n=null},a},Lg={subscribe:Ly,_broadcastEvent:Lw,_unsubscribe:Lv,_isValidEvent:Lb};function Ly(e,t){if(this._isValidEvent(e)){let r=Lf(),n={id:r,callback:t};return Array.isArray(this.listeners[e])?this.listeners[e].push(n):this.listeners[e]=[n],{unsubscribe:()=>this._unsubscribe(e,r)}}throw Error(`Event ${e} not supported.`)}function Lv(e,t){if(!this.listeners[e])return;let r=this.listeners[e];Array.isArray(r)?this.listeners[e]=r.filter(({id:e,callback:r})=>(r?.clearDebounceTimeout?.(),e!==t)):this.listeners[e]=void 0}function Lb(e){return Object.values(this.EVENTS).includes(e)}function Lw(e,t){let r=Object.keys(this.listeners).length>0,n=Array.isArray(this.listeners[e]),a=new CustomEvent(e,{detail:t});document.body.dispatchEvent(a),r&&n&&this.listeners[e].forEach(e=>{e.callback(t)})}class Lx{constructor(e){this.EVENTS=void 0,this.subscribe=void 0,this._broadcastEvent=void 0,this._unsubscribe=void 0,this._isValidEvent=void 0,this.listeners=void 0,this.unsubscriptions=void 0,this.EVENTS=e,this.subscribe=Ly,this._broadcastEvent=Lw,this._unsubscribe=Lv,this._isValidEvent=Lb,this.listeners={},this.unsubscriptions=[]}subscribeDebounced(e,t,r=300,n=!1){if(this._isValidEvent(e)){let a=Lm(t,r,n);return this.subscribe(e,a)}throw Error(`Event ${e} not supported.`)}reset(){this.unsubscriptions.forEach(e=>e()),this.unsubscriptions=[],Object.keys(this.listeners).forEach(e=>this.listeners[e].forEach(({callback:e})=>{e?.clearDebounceTimeout?.()})),this.listeners={}}createConsumableEvent(e){return{...e,isConsumed:!1,consume:function(){this.isConsumed=!0}}}}var LC=u(2111),Lk=u.n(LC);let LM=function(e){let t=[],r=new Map;return{SeriesInstanceUID:e,instances:t,addInstance:function(e){this.addInstances([e])},addInstances:function(e){for(let n=0,a=e.length;n<a;n++){let a=e[n];r.has(a.SOPInstanceUID)||(r.set(a.SOPInstanceUID,a),t.push(a))}},getInstance:function(e){return r.get(e)}}},LE=function(e){return{StudyInstanceUID:e,StudyDescription:"",ModalitiesInStudy:[],isLoaded:!1,series:[],addInstanceToSeries:function(e){this.addInstancesToSeries([e])},addInstancesToSeries:function(e){let{SeriesInstanceUID:t}=e[0];this.StudyDescription||(this.StudyDescription=e[0].StudyDescription);let r=this.series.find(e=>e.SeriesInstanceUID===t);r||(r=LM(t),this.series.push(r)),r.addInstances(e)},setSeriesMetadata:function(e,t){let r=this.series.find(t=>t.SeriesInstanceUID===e);if(r)r=Object.assign(r,t);else{let r=LM(e);this.series.push(Object.assign(r,t))}}}},LS=["ImagePositionPatient","ImageOrientationPatient","PixelSpacing"],LD=Symbol("isMetadataProxy"),LI=function(e){if(!e||e[LD])return e;for(let t of LS)t in e||Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:()=>e._parentInstance?.[t]??e._parentInstance?._shared?.[t],set:r=>{Object.defineProperty(e,t,{writable:!0,enumerable:!0,value:r})}});return Object.defineProperty(e,LD,{value:!0}),e},LP={STUDY_ADDED:"event::dicomMetadataStore:studyAdded",INSTANCES_ADDED:"event::dicomMetadataStore:instancesAdded",SERIES_ADDED:"event::dicomMetadataStore:seriesAdded",SERIES_UPDATED:"event::dicomMetadataStore:seriesUpdated"},LT=[];function L_(e){return LT.find(t=>t.StudyInstanceUID===e)}function LA(e,t){if(!e)return LT.map(e=>e.series).flat().find(e=>e.SeriesInstanceUID===t);let r=L_(e);if(r)return r.series.find(e=>e.SeriesInstanceUID===t)}function LO(e,t,r){let n=LA(e,t);if(n)return n.getInstance(r)}let LR=Object.assign({},{EVENTS:LP,listeners:{},addInstance(e){let t,r,{StudyInstanceUID:n,NumberOfFrames:a}=r=void 0===(t=e instanceof ArrayBuffer?Lk().data.DicomMessage.readFile(e).dict:e).SeriesInstanceUID?Lk().data.DicomMetaDictionary.naturalizeDataset(t):t,i=LT.find(e=>e.StudyInstanceUID===n);i||(LT.push(LE(n)),i=LT[LT.length-1]),r=a>1?LI(r):r,i.addInstanceToSeries(r)},addInstances(e,t=!1){let{StudyInstanceUID:r,SeriesInstanceUID:n,NumberOfFrames:a}=e[0];a>1&&(e=e.map(e=>LI(e)));let i=LT.find(e=>e.StudyInstanceUID===r);i||(LT.push(LE(r)),i=LT[LT.length-1]),i.addInstancesToSeries(e),this._broadcastEvent(LP.INSTANCES_ADDED,{StudyInstanceUID:r,SeriesInstanceUID:n,madeInClient:t})},updateSeriesMetadata(e){let{StudyInstanceUID:t,SeriesInstanceUID:r}=e;if(!LA(t,r))return;let n=L_(t);n&&n.setSeriesMetadata(r,e)},addSeriesMetadata(e,t=!1){if(!e||!e.length||!e[0])return;let{StudyInstanceUID:r}=e[0],n=L_(r);n||((n=LE(r)).StudyDescription=e[0].StudyDescription,e.forEach(e=>{-1===n.ModalitiesInStudy.indexOf(e.Modality)&&n.ModalitiesInStudy.push(e.Modality)}),n.NumberOfStudyRelatedSeries=e.length,LT.push(n)),e.forEach(e=>{let{SeriesInstanceUID:t}=e;n.setSeriesMetadata(t,e)}),this._broadcastEvent(LP.SERIES_ADDED,{StudyInstanceUID:r,seriesSummaryMetadata:e,madeInClient:t})},addStudy(e){let{StudyInstanceUID:t}=e;if(!LT.find(e=>e.StudyInstanceUID===t)){let r=LE(t);r.PatientID=e.PatientID,r.PatientName=e.PatientName,r.StudyDate=e.StudyDate,r.ModalitiesInStudy=e.ModalitiesInStudy,r.StudyDescription=e.StudyDescription,r.AccessionNumber=e.AccessionNumber,r.NumInstances=e.NumInstances,LT.push(r)}},getStudyInstanceUIDs:function(){return LT.map(e=>e.StudyInstanceUID)},getStudy:L_,getSeries:LA,getInstance:LO,getInstanceByImageId:function(e){let t=n?.get("frameModule",e);if(t){let{studyInstanceUID:e,seriesInstanceUID:r,sopInstanceUID:n}=t;return LO(e,r,n)}for(let t of(console.warn("No metadata result found for",e,"looking through instances"),LT))for(let r of t.series)for(let t of r.instances)if(t.imageId===e)return t},updateMetadataForSeries:function(e,t,r){let n=L_(e);if(!n)return;let{instances:a}=n.series.find(e=>e.SeriesInstanceUID===t);a.forEach(e=>{Object.keys(r).forEach(t=>{"object"==typeof r[t]?e[t]={...e[t],...r[t]}:e[t]=r[t]})}),this._broadcastEvent(LP.SERIES_UPDATED,{SeriesInstanceUID:t,StudyInstanceUID:e,madeInClient:!0})},setMetaDataProvider:function(e){n=e}},Lg),LL=["uid","color","data","getReport","displayText","SOPInstanceUID","FrameOfReferenceUID","referenceStudyUID","referenceSeriesUID","frameNumber","displaySetInstanceUID","label","isLocked","isVisible","description","type","unit","points","source","toolName","metadata","area","mean","stdDev","perimeter","length","shortestDiameter","longestDiameter","cachedStats","isSelected","textBox","referencedImageId","isDirty"],LN={MEASUREMENT_UPDATED:"event::measurement_updated",INTERNAL_MEASUREMENT_UPDATED:"event:internal_measurement_updated",MEASUREMENT_ADDED:"event::measurement_added",RAW_MEASUREMENT_ADDED:"event::raw_measurement_added",MEASUREMENT_REMOVED:"event::measurement_removed",MEASUREMENTS_CLEARED:"event::measurements_cleared",JUMP_TO_MEASUREMENT:"event:jump_to_measurement"},LF={ANGLE:"value_type::polyline",POLYLINE:"value_type::polyline",POINT:"value_type::point",BIDIRECTIONAL:"value_type::shortAxisLongAxis",ELLIPSE:"value_type::ellipse",RECTANGLE:"value_type::rectangle",MULTIPOINT:"value_type::multipoint",CIRCLE:"value_type::circle",ROI_THRESHOLD:"value_type::roiThreshold",ROI_THRESHOLD_MANUAL:"value_type::roiThresholdManual"};var LV=((em8=LV||{}).HandlesUpdated="HandlesUpdated",em8.LabelChange="LabelChange",em8);let LB=new Set;class Lj extends Lx{constructor(){super(LN),this.VALUE_TYPES=LF,this.measurements=new Map,this.isMeasurementDeletedIndividually=void 0,this.sources={},this.mappings={},this._arrayOfObjects=e=>Object.entries(e).map(e=>({[e[0]]:e[1]})),this.setIsMeasurementDeletedIndividually=e=>{this.isMeasurementDeletedIndividually=e},this.getIsMeasurementDeletedIndividually=()=>this.isMeasurementDeletedIndividually}addMeasurementSchemaKeys(e){Array.isArray(e)||(e=[e]),LL.push(...e)}addValueType(e){if(!LF[e]){if(!e||"object"!=typeof e)return void console.warn(`MeasurementService: addValueType: invalid valueType: ${e}`);Object.keys(e).forEach(t=>{LF[t]||(LF[t]=e[t])})}}getMeasurements(e){let t=[...this.measurements.values()];return e?t.filter(t=>e.call(this,t)):t}getMeasurement(e){return this.measurements.get(e)}setMeasurementSelected(e,t){let r=this.getMeasurement(e);r&&(r.isSelected=t,this._broadcastEvent(this.EVENTS.MEASUREMENT_UPDATED,{source:r.source,measurement:r,notYetUpdatedAtSource:!1}))}createSource(e,t){if(!e)throw Error("Source name not provided.");if(!t)throw Error("Source version not provided.");let r=Object.keys(this.sources);for(let n=0;n<r.length;n++){let a=this.sources[r[n]];if(a.name===e&&a.version===t)return a}let n=Lf(),a={uid:n,name:e,version:t};return a.annotationToMeasurement=(e,t,r=!1)=>this.annotationToMeasurement(a,e,t,r),a.remove=(e,t)=>this.remove(e,a,t),a.getAnnotation=(e,t)=>this.getAnnotation(a,e,t),Lp.info(`New '${e}@${t}' source added.`),this.sources[n]=a,a}getSource(e,t){let{sources:r}=this;return r[this._getSourceUID(e,t)]}getSourceMappings(e,t){let{mappings:r}=this;return r[this._getSourceUID(e,t)]}addMapping(e,t,r,n,a){if(!this._isValidSource(e))throw Error("Invalid source.");if(!r)throw Error("Matching criteria not provided.");if(!t)throw Error("annotationType not provided.");if(!n)throw Error("Mapping function to source schema not provided.");if(!a)throw Error("Measurement mapping function not provided.");let i={matchingCriteria:r,annotationType:t,toAnnotationSchema:n,toMeasurementSchema:a};Array.isArray(this.mappings[e.uid])?this.mappings[e.uid].push(i):this.mappings[e.uid]=[i]}getAnnotation(e,t,r){if(!this._isValidSource(e))return void Lp.warn("Invalid source. Exiting early.");if(!t)return void Lp.warn("No source annotationType provided. Exiting early.");let n=this.getMeasurement(r),a=this._getMappingByMeasurementSource(n,t);if(a)return a.toAnnotationSchema(n,t);let i=this._getMatchingMapping(e,t,n);if(i){Lp.info("Matching mapping found:",i);let{toAnnotationSchema:e,annotationType:t}=i;return e(n,t)}}update(e,t,r=!1){if(!this.measurements.has(e))return;let n={...t,modifiedTimestamp:Math.floor(Date.now()/1e3)};return Lp.info("Updating internal measurement representation...",n),this.measurements.set(e,n),this._broadcastEvent(this.EVENTS.MEASUREMENT_UPDATED,{source:t.source,measurement:n,notYetUpdatedAtSource:r}),n.uid}addRawMeasurement(e,t,r,n,a={}){if(!this._isValidSource(e))return void Lp.warn("Invalid source. Exiting early.");let i=this._getSourceToString(e);if(!t)return void Lp.warn("No source annotationType provided. Exiting early.");if(!this._sourceHasMappings(e))return void Lp.warn(`No measurement mappings found for '${i}' source. Exiting early.`);let o={};try{if(!(o=n(r)))return;o.source=e}catch(e){Lp.warn(`Failed to map '${i}' measurement for annotationType ${t}:`,e);return}if(!this._isValidMeasurement(o))return void Lp.warn(`Attempting to add or update a invalid measurement provided by '${i}'. Exiting early.`);let s=r.uid||Lf(),{annotation:{predecessorImageId:l,data:u}}=r,c={finding:u.finding,predecessorImageId:l,findingSites:u.findingSites,site:u.findingSites?.[0],...o,modifiedTimestamp:Math.floor(Date.now()/1e3),uid:s};return this.measurements.get(s)?(this.measurements.set(s,c),this._broadcastEvent(this.EVENTS.MEASUREMENT_UPDATED,{source:e,measurement:c})):(Lp.info("Measurement added",c),this.measurements.set(s,c),this._broadcastEvent(this.EVENTS.RAW_MEASUREMENT_ADDED,{source:e,measurement:c,data:r,dataSource:a})),c.uid}annotationToMeasurement(e,t,r,n=!1){if(!this._isValidSource(e))throw Error("Invalid source.");if(!t)throw Error("No source annotationType provided.");let a=this._getSourceToString(e);if(!this._sourceHasMappings(e))throw Error(`No measurement mappings found for '${a}' source. Exiting early.`);let i={};try{let n=this.mappings[e.uid].find(e=>e.annotationType===t);if(!n){LB.has(e.uid)||(console.log("No source mapping",e.uid,t,e),LB.add(e.uid)),this.addUnmappedMeasurement(r,e);return}let{toMeasurementSchema:a}=n;if(!(i=a(r)))return;i.source=e}catch(n){throw this.addUnmappedMeasurement(r,e),console.log("Failed to map",n),Error(`Failed to map '${a}' measurement for annotationType ${t}: ${n.message}`)}if(!this._isValidMeasurement(i))throw Error(`Attempting to add or update a invalid measurement provided by '${a}'. Exiting early.`);let o=r.uid;o||(o=Lf(),Lp.info(`Annotation does not have UID, Generating UID for the created Measurement: ${o}`));let s=this.measurements.get(o),l={...s,...i,modifiedTimestamp:Math.floor(Date.now()/1e3),uid:o};return l.isDirty=r.changeType===LV.HandlesUpdated||r.changeType===LV.LabelChange||s?.isDirty,s?(this.measurements.set(o,l),n?this._broadcastEvent(this.EVENTS.MEASUREMENT_UPDATED,{source:e,measurement:l,notYetUpdatedAtSource:!1}):(Lp.info("Measurement added.",l),this._broadcastEvent(this.EVENTS.MEASUREMENT_ADDED,{source:e,measurement:l}))):(Lp.info("Measurement started.",l),this.measurements.set(o,l)),l.uid}findAttributeRecursively(e,t){if(e&&"object"==typeof e){if(e[t])return e[t];for(let r in e)if(e.hasOwnProperty(r)){let n=this.findAttributeRecursively(e[r],t);if(n)return n}}}addUnmappedMeasurement(e,t){if(e.annotation?.invalidated===!0)return void console.log("Measurement is invalidated, skipping...",e);if(e.annotation?.isPreview===!0)return void console.log("Measurement is preview, skipping...",e);let r=this.findAttributeRecursively(e,"metadata"),n=this.findAttributeRecursively(e,"label"),a=this.findAttributeRecursively(e,"referencedImageId"),i=this.findAttributeRecursively(e,"displaySetInstanceUID"),o={...e,isUnmapped:!0,statusTooltip:"This measurement is not compatible with this application",source:{name:t.name,version:t.version,uid:t.uid}};if(r&&(o.metadata=r),n&&(o.label=n),a){o.referencedImageId=a;let e=LR.getInstanceByImageId(a);e?(o.referenceStudyUID=e.StudyInstanceUID,o.referenceSeriesUID=e.SeriesInstanceUID):console.warn("Didn't find instance for",a)}i&&(o.displaySetInstanceUID=i),this.measurements.set(e.uid,o)}remove(e){let t=this.measurements.get(e);if(!e||!t)return void console.debug("No uid provided, or unable to find measurement by uid.");let r=t.source;this.measurements.delete(e),this.isMeasurementDeletedIndividually=!0,this._broadcastEvent(this.EVENTS.MEASUREMENT_REMOVED,{source:r,measurement:e})}removeMany(e){let t=[];for(let r of e){let e=this.measurements.get(r);if(!r||!e){console.debug("No uid provided, or unable to find measurement by uid.");continue}this.measurements.delete(r),t.push(e)}t.length&&this._broadcastEvent(this.EVENTS.MEASUREMENTS_CLEARED,{measurements:t})}clearMeasurements(e,t){let r=this.getMeasurements(e),n=[...r];r.forEach(e=>this.measurements.delete(e.uid)),this._broadcastEvent(this.EVENTS.MEASUREMENTS_CLEARED,{measurements:n,...t})}onModeExit(){this.clearMeasurements()}jumpToMeasurement(e,t){let r=this.measurements.get(t);r?this._broadcastEvent(LN.JUMP_TO_MEASUREMENT,{viewportId:e,measurement:r}):Lp.warn("No measurement uid, or unable to find by uid.")}_getSourceUID(e,t){let{sources:r}=this;return Object.keys(r).find(n=>{let a=r[n];return a.name===e&&a.version===t})}_getMappingByMeasurementSource(e,t){if(this._isValidSource(e.source))return this.mappings[e.source.uid].find(e=>e.annotationType===t)}_getMatchingMapping(e,t,r){return this.mappings[e.uid].filter(e=>e.annotationType===t).find(({matchingCriteria:e})=>r.points&&r.points.length===e.points)}_getSourceToString(e){return`${e.name}@${e.version}`}_isValidSource(e){return e&&this.sources[e.uid]}_sourceHasMappings(e){return Array.isArray(this.mappings[e.uid])&&this.mappings[e.uid].length}_isValidMeasurement(e){return Object.keys(e).every(e=>!!LL.includes(e)||(Lp.warn(`Invalid measurement key: ${e}`),!1))}toggleLockMeasurement(e){let t=this.measurements.get(e);t?(t.isLocked=!t.isLocked,this._broadcastEvent(this.EVENTS.MEASUREMENT_UPDATED,{source:t.source,measurement:t,notYetUpdatedAtSource:!0})):console.debug(`No measurement found for uid: ${e}`)}toggleVisibilityMeasurement(e,t){let r=this.measurements.get(e);r?(r.isVisible!==t||void 0===t)&&(r.isVisible=void 0!==t?t:!r.isVisible,this._broadcastEvent(this.EVENTS.MEASUREMENT_UPDATED,{source:r.source,measurement:r,notYetUpdatedAtSource:!0})):console.debug(`No measurement found for uid: ${e}`)}toggleVisibilityMeasurementMany(e,t){return e.forEach(e=>this.toggleVisibilityMeasurement(e,t))}updateColorMeasurement(e,t){let r=this.measurements.get(e);r?(r.color=t,this._broadcastEvent(this.EVENTS.MEASUREMENT_UPDATED,{source:r.source,measurement:r,notYetUpdatedAtSource:!0})):console.debug(`No measurement found for uid: ${e}`)}}Lj.REGISTRATION={name:"measurementService",altName:"MeasurementService",create:e=>new Lj},Lj.EVENTS=LN,Lj.VALUE_TYPES=LF;let LW="uiDialogService",LU={_show:e=>(console.warn("show() NOT IMPLEMENTED"),""),_hide:e=>console.warn("hide() NOT IMPLEMENTED"),_hideAll:()=>console.warn("hideAll() NOT IMPLEMENTED"),_isEmpty:()=>(console.warn("isEmpty() NOT IMPLEMENTED"),!0),_updatePosition:(e,t)=>console.warn("updatePosition() NOT IMPLEMENTED"),_customComponent:null};class Lz{constructor(){this.name=LW}show(e){return LU._show(e)}hide(e){return LU._hide(e)}hideAll(){return LU._hideAll()}isEmpty(){return LU._isEmpty()}updatePosition(e,t){return LU._updatePosition(e,t)}getCustomComponent(){return LU._customComponent}setServiceImplementation({show:e,hide:t,hideAll:r,isEmpty:n,updatePosition:a,customComponent:i}){e&&(LU._show=e),t&&(LU._hide=t),r&&(LU._hideAll=r),n&&(LU._isEmpty=n),a&&(LU._updatePosition=a),i&&(LU._customComponent=i)}}Lz.REGISTRATION={name:LW,altName:"UIDialogService",create:()=>new Lz};let LH="uiModalService",LG={_hide:()=>console.warn("hide() NOT IMPLEMENTED"),_show:()=>console.warn("show() NOT IMPLEMENTED"),_customComponent:null};class Lq{constructor(){this.name=LH}show({content:e=null,contentProps:t=null,title:r=null,className:n=null,shouldCloseOnEsc:a=!0,shouldCloseOnOverlayClick:i=!0,containerClassName:o=null}){return LG._show({content:e,contentProps:t,shouldCloseOnEsc:a,title:r,className:n,shouldCloseOnOverlayClick:i,containerClassName:o})}hide(){return LG._hide()}getCustomComponent(){return LG._customComponent}setServiceImplementation({hide:e,show:t,customComponent:r}){e&&(LG._hide=e),t&&(LG._show=t),r&&(LG._customComponent=r)}}Lq.REGISTRATION={name:LH,altName:"UIModalService",create:()=>new Lq};let L$={_hide:()=>console.debug("hide() NOT IMPLEMENTED"),_show:e=>(console.debug("show() NOT IMPLEMENTED"),null),_customComponent:null};class LK{getCustomComponent(){return L$._customComponent}setServiceImplementation({hide:e,show:t,customComponent:r}){e&&(L$._hide=e),t&&(L$._show=t),r&&(L$._customComponent=r)}hide(e){return L$._hide(e)}show({title:e,message:t,duration:r=2e3,position:n="bottom-right",type:a="info",autoClose:i=!0,promise:o,promiseMessages:s,id:l,allowDuplicates:u=!1,deduplicationInterval:c=3e4,action:d}){if(o&&s){let t=L$._show({title:e,message:s.loading||"Loading...",type:"loading",autoClose:!1,position:n,id:l?`${l}-loading`:void 0,allowDuplicates:u,deduplicationInterval:c});return o.then(a=>{let o="function"==typeof s.success?s.success(a):s.success||"Success";L$._show({title:e,message:o,type:"success",duration:r,position:n,autoClose:i,id:l?`${l}-success`:void 0,allowDuplicates:u,deduplicationInterval:c,action:d}),this.hide(t)},a=>{let o="function"==typeof s.error?s.error(a):s.error||"Error";L$._show({title:e,message:o,type:"error",duration:r,position:n,autoClose:i,id:l?`${l}-error`:void 0,allowDuplicates:u,deduplicationInterval:c,action:d}),this.hide(t)}),t}return L$._show({title:e,message:t,duration:r,position:n,type:a,autoClose:i,id:l,allowDuplicates:u,deduplicationInterval:c,action:d})}}LK.REGISTRATION={name:"uiNotificationService",altName:"UINotificationService",create:()=>new LK};class LY extends Lx{constructor(){super(LY.EVENTS),this.serviceImplementation={_hide:()=>console.warn("hide() NOT IMPLEMENTED"),_show:()=>console.warn("show() NOT IMPLEMENTED")},this.serviceImplementation={...this.serviceImplementation}}show({viewportId:e,id:t,type:r,message:n,actions:a,onSubmit:i,onOutsideClick:o,onKeyPress:s}){return this.serviceImplementation._show({viewportId:e,id:t,type:r,message:n,actions:a,onSubmit:i,onOutsideClick:o,onKeyPress:s})}hide(){return this.serviceImplementation._hide()}setServiceImplementation({hide:e,show:t}){e&&(this.serviceImplementation._hide=e),t&&(this.serviceImplementation._show=t)}}LY.EVENTS={},LY.REGISTRATION={name:"uiViewportDialogService",altName:"UIViewportDialogService",create:({configuration:e={}})=>new LY};let LX={DISPLAY_SETS_ADDED:"event::displaySetService:displaySetsAdded",DISPLAY_SETS_CHANGED:"event::displaySetService:displaySetsChanged",DISPLAY_SETS_REMOVED:"event::displaySetService:displaySetsRemoved",DISPLAY_SET_SERIES_METADATA_INVALIDATED:"event::displaySetService:displaySetSeriesMetadataInvalidated"},LZ=new Map,LJ=(e,t)=>{let r=new Set;return t.forEach(e=>{let t=e.instances;t?t.forEach(e=>r.add(e.SOPInstanceUID)):console.warn("No instances in",e)}),e.filter(e=>!r.has(e.SOPInstanceUID))};class LQ extends Lx{constructor(){super(LX),this.activeDisplaySets=[],this.unsupportedSOPClassHandler=void 0,this.extensionManager=void 0,this.activeDisplaySetsMap=new Map,this.activeDisplaySetsChanged=!1,this.getDisplaySetsForSeries=e=>[...LZ.values()].filter(t=>t.SeriesInstanceUID===e),this.getDisplaySetsForReferences=e=>{let t=new Map;for(let r of Array.isArray(e)?e:[e]){let{SeriesInstanceUID:e,ReferencedInstanceSequence:n}=r;t.has(e)||t.set(e,new Set);let a=t.get(e);for(let e of n)a.add(e.ReferencedSOPInstanceUID)}return[...LZ.values()].filter(e=>{let r=t.get(e.SeriesInstanceUID);if(r&&e.instances)return e.instances.some(e=>r.has(e.SOPInstanceUID))})},this.getDisplaySetByUID=e=>{if("string"!=typeof e)throw Error(`getDisplaySetByUID: displaySetInstanceUid must be a string, you passed ${e}`);return LZ.get(e)},this.makeDisplaySets=(e,{batch:t=!1,madeInClient:r=!1,settings:n={}}={})=>{if(!e||!e.length)throw Error("No instances were provided.");if(t&&!e[0].length)throw Error("Batch displaySet creation does not contain array of array of instances.");let a=[];if(t)for(let t=0;t<e.length;t++){let r=e[t],i=this.makeDisplaySetForInstances(r,n);a.push(...i)}else{let t=this.makeDisplaySetForInstances(e,n);a.push(...t)}let i={};if(r&&(i.madeInClient=!0),this.activeDisplaySetsChanged&&(this.activeDisplaySetsChanged=!1,this._broadcastEvent(LX.DISPLAY_SETS_CHANGED,this.activeDisplaySets)),a?.length)return this._broadcastEvent(LX.DISPLAY_SETS_ADDED,{displaySetsAdded:a,options:i}),a},this.unsupportedSOPClassHandler="@ohif/extension-default.sopClassHandlerModule.not-supported-display-sets-handler"}init(e,t){this.extensionManager=e,this.SOPClassHandlerIds=t,this.activeDisplaySets=[],this.activeDisplaySetsMap.clear()}_addDisplaySetsToCache(e){e.forEach(e=>{LZ.set(e.displaySetInstanceUID,e)})}_addActiveDisplaySets(e){let{activeDisplaySets:t,activeDisplaySetsMap:r}=this;e.forEach(e=>{r.has(e.displaySetInstanceUID)||(this.activeDisplaySetsChanged=!0,t.push(e),r.set(e.displaySetInstanceUID,e))})}setUnsuportedSOPClassHandler(e){this.unsupportedSOPClassHandler=e}addDisplaySets(...e){return this._addDisplaySetsToCache(e),this._addActiveDisplaySets(e),this.activeDisplaySetsChanged=!1,this._broadcastEvent(LX.DISPLAY_SETS_ADDED,{displaySetsAdded:e,options:{madeInClient:e[0].madeInClient}}),e}getDisplaySetCache(){return LZ}getMostRecentDisplaySet(){return this.activeDisplaySets[this.activeDisplaySets.length-1]}getActiveDisplaySets(){return this.activeDisplaySets}getDisplaySetForSOPInstanceUID(e,t,r){return(t?this.getDisplaySetsForSeries(t):[...this.getDisplaySetCache().values()]).find(t=>t.instances?.some(t=>t.SOPInstanceUID===e))}setDisplaySetMetadataInvalidated(e,t=!0){this.getDisplaySetByUID(e)&&this._broadcastEvent(LX.DISPLAY_SET_SERIES_METADATA_INVALIDATED,{displaySetInstanceUID:e,invalidateData:t})}deleteDisplaySet(e){if(!e)return;let{activeDisplaySets:t,activeDisplaySetsMap:r}=this,n=t.findIndex(t=>t.displaySetInstanceUID===e);LZ.delete(e),t.splice(n,1),r.delete(e),this._broadcastEvent(LX.DISPLAY_SETS_CHANGED,this.activeDisplaySets),this._broadcastEvent(LX.DISPLAY_SETS_REMOVED,{displaySetInstanceUIDs:[e]})}onModeExit(){this.getDisplaySetCache().clear(),this.activeDisplaySets.length=0,this.activeDisplaySetsMap.clear()}makeDisplaySetForInstances(e,t){let r=e.reduce((e,t)=>(t.SOPClassUID in e||(e[t.SOPClassUID]=[]),e[t.SOPClassUID].push(t),e),{}),n=Object.keys(r),a=[];return n.forEach(e=>{let n=this._makeDisplaySetForInstances(r[e],t);a=[...a,...n]}),a}_makeDisplaySetForInstances(e,t){let r=[...e],n=r[0],a=this.getDisplaySetsForSeries(n.SeriesInstanceUID)||[],i=this.SOPClassHandlerIds,o=[];for(let e=0;e<i.length&&r.length;e++){let s=i[e],l=this.extensionManager.getModuleEntry(s);if(l.sopClassUids.includes(n.SOPClassUID)){let e=a.filter(e=>e.SOPClassHandlerId===s);if(e.length){for(let t of(r=LJ(r,e),e)){let e=t.addInstances?.(r,this);if(e&&(this.activeDisplaySetsChanged=!0,r=LJ(r,[e]),this._addActiveDisplaySets([e]),this.setDisplaySetMetadataInvalidated(e.displaySetInstanceUID)),!r.length)return o}if(!r.length)return this._addActiveDisplaySets(e),o}if(!(e=l.getDisplaySetsFromSeries(r))||!e.length)continue;e.forEach(e=>{Object.keys(t).forEach(r=>{e[r]=t[r]})}),this._addDisplaySetsToCache(e),this._addActiveDisplaySets(e),r=LJ(r,e),o.push(...e)}}if(0===o.length){let e=this.extensionManager.getModuleEntry(this.unsupportedSOPClassHandler).getDisplaySetsFromSeries(r);e?.length&&(e.forEach(e=>{Object.keys(t).forEach(r=>{e[r]=t[r]})}),this._addDisplaySetsToCache(e),this._addActiveDisplaySets(e),o.push(...e))}return o}getDisplaySetsBy(e){let t=[];if("function"!=typeof e)throw Error(`The comparator ${e} was not a function`);return this.getActiveDisplaySets().forEach(r=>{e(r)&&t.push(r)}),t}sortDisplaySets(e,t="ascending",r=!1){this.activeDisplaySets.sort(e),"descending"===t&&this.activeDisplaySets.reverse(),r||this._broadcastEvent(LX.DISPLAY_SETS_CHANGED,this.activeDisplaySets)}}LQ.REGISTRATION={altName:"DisplaySetService",name:"displaySetService",create:({configuration:e={}})=>new LQ};let L1={TOOL_BAR_MODIFIED:"event::toolBarService:toolBarModified",TOOL_BAR_STATE_MODIFIED:"event::toolBarService:toolBarStateModified"},L0={primary:"primary",secondary:"secondary",viewportActionMenu:{topLeft:"viewportActionMenu.topLeft",topRight:"viewportActionMenu.topRight",bottomLeft:"viewportActionMenu.bottomLeft",bottomRight:"viewportActionMenu.bottomRight",topMiddle:"viewportActionMenu.topMiddle",bottomMiddle:"viewportActionMenu.bottomMiddle",leftMiddle:"viewportActionMenu.leftMiddle",rightMiddle:"viewportActionMenu.rightMiddle"},labelMapSegmentationToolbox:"labelMapSegmentationToolbox",contourSegmentationToolbox:"contourSegmentationToolbox",labelMapSegmentationUtilities:"labelMapSegmentationUtilities",contourSegmentationUtilities:"contourSegmentationUtilities",dynamicToolbox:"dynamic-toolbox",roiThresholdToolbox:"ROIThresholdToolbox"},L2=((em6={})[em6.TopLeft=0]="TopLeft",em6[em6.TopMiddle=1]="TopMiddle",em6[em6.TopRight=2]="TopRight",em6[em6.LeftMiddle=3]="LeftMiddle",em6[em6.RightMiddle=4]="RightMiddle",em6[em6.BottomLeft=5]="BottomLeft",em6[em6.BottomMiddle=6]="BottomMiddle",em6[em6.BottomRight=7]="BottomRight",em6);class L5 extends Lx{get sections(){return L0}static createButton(e){let{id:t,icon:r,label:n,commands:a,tooltip:i,evaluate:o,listeners:s}=e;return{id:t,icon:r,label:n,commands:a,tooltip:i||n,evaluate:o,listeners:s}}constructor(e,t,r){super(L1),this.state={buttons:{},buttonSections:{}},this._commandsManager=void 0,this._extensionManager=void 0,this._servicesManager=void 0,this._evaluateFunction={},this._serviceSubscriptions=[],this.handleEvaluateNested=e=>{let{buttonSection:t}=e;if(!t)return;let r=this.getButtonSection(t);r?.length&&r.forEach(e=>{this.handleEvaluate(e.componentProps)})},this.handleEvaluate=e=>{let{evaluate:t,options:r}=e;if("string"==typeof r){let t=this._getButtonUITypes();e.options=t[r]?.defaultComponent}if("function"!=typeof t){if(Array.isArray(t)){let r=t.map(e=>{let t="object"==typeof e,r=t?e.name:e,n=this._evaluateFunction[r];if(!n)throw Error(`Evaluate function not found for name: ${r}, you can register an evaluate function with the getToolbarModule in your extensions`);return t?t=>n({...t,...e}):n}),n=e.evaluate;e.evaluate=e=>{let t=r.map(t=>t(e)).filter(Boolean),n=t?.some(e=>e.disabled),a=t.reduce((e,t)=>({...e,...t}),{});return n&&(a.disabled=!0),a},e.evaluateProps=n;return}if("string"==typeof t){let r=this._evaluateFunction[t];if(r){e.evaluate=r;return}throw Error(`Evaluate function not found for name: ${t}, you can register an evaluate function with the getToolbarModule in your extensions`)}if("object"==typeof t){let{name:r,...n}=t,a=this._evaluateFunction[r];if(a){let t=e.evaluate;e.evaluate=e=>a({...e,...n}),e.evaluateProps=t;return}throw Error(`Evaluate function not found for name: ${r}, you can register an evaluate function with the getToolbarModule in your extensions`)}}},this._commandsManager=e,this._extensionManager=t,this._servicesManager=r}reset(){this.state={buttons:{},buttonSections:{}},this.unsubscriptions=[]}onModeEnter(){this.reset()}registerEvaluateFunction(e,t){this._evaluateFunction[e]=t}registerEventForToolbarUpdate(e,t){let{viewportGridService:r}=this._servicesManager.services,n=()=>{let e=r.getActiveViewportId();this.refreshToolbarState({viewportId:e})};t.map(t=>e.subscribe?e.subscribe(t,n):e.addEventListener?e.addEventListener(t,n):void 0).forEach(e=>this._serviceSubscriptions.push(e))}removeButton(e){this.state.buttons[e]&&delete this.state.buttons[e],Object.keys(this.state.buttonSections).forEach(t=>{this.state.buttonSections[t]=this.state.buttonSections[t].filter(t=>t!==e)}),this._broadcastEvent(this.EVENTS.TOOL_BAR_MODIFIED,{...this.state})}register(e,t=!1){e.forEach(e=>{(t||!this.state.buttons[e.id])&&(e.props||(e.props={}),!0===e.props.buttonSection&&(e.props.buttonSection=e.id),this.state.buttons[e.id]=e)}),this._broadcastEvent(this.EVENTS.TOOL_BAR_MODIFIED,{...this.state})}recordInteraction(e,t){"string"==typeof e&&(e=this.getButtonProps(e));let r=e.itemId??e.id;e.itemId=r;let n=Array.isArray(e.commands)?e.commands:[e.commands];if(n=n.filter(Boolean),!n?.length)return void this.refreshToolbarState({...t?.refreshProps,itemId:r,interaction:e});let a={...t,...e};(n=(n=n.map(e=>"function"==typeof e?()=>{e({...a,commandsManager:this._commandsManager,servicesManager:this._servicesManager})}:e)).filter(Boolean)).length&&(this._commandsManager.run(n,a),this.refreshToolbarState({...t?.refreshProps,itemId:r,interaction:e}))}refreshToolbarState(e){let t=this.state.buttons,r={...t},n=new Map,a=(e,t,r)=>{if(n.has(e.id)){let{disabled:r,disabledText:a,className:i,isActive:o}=n.get(e.id);return{...t,disabled:r,disabledText:a,className:i,isActive:o}}{let a=t.evaluateProps,i="function"==typeof t.evaluate?t.evaluate({...r,button:e}):void 0,o=a?.hideWhenDisabled||t.hideWhenDisabled,s=i?.visible===void 0?!(o&&i?.disabled):i?.visible,l={...t,...i,disabled:i?.disabled||!1,visible:s,className:i?.className||t?.className||"",isActive:i?.isActive};return n.set(e.id,l),l}},i=new Set;return Object.values(t).forEach(n=>{if(!i.has(n.id))if(n.props?.buttonSection){let o=n.props,{evaluate:s}=o,l="function"==typeof s?s({...e,button:n}):void 0;o={...o,disabled:l?.disabled??o.disabled,disabledText:l?.disabledText??o.disabledText};let u=this.state.buttonSections[o.buttonSection];if(!u)return;u.forEach(n=>{let o=t[n];if(!o||i.has(n))return;let s=a(o,o.props,e);r[n]={...o,props:s},i.add(n)})}else{this.handleEvaluate(n.props);let t=n.props,o=a(n,t,e);r[n.id]={...n,props:o},i.add(n.id)}}),this.setButtons(r),this.state}setButtons(e){this.state.buttons=e,this._broadcastEvent(this.EVENTS.TOOL_BAR_MODIFIED,{buttons:this.state.buttons,buttonSections:this.state.buttonSections})}getButton(e){return this.state.buttons[e]}addButtons(e,t=!1){console.warn("ToolbarService.addButtons() is deprecated. Use ToolbarService.register() instead."),this.register(e,t)}getButtons(){return this.state.buttons}getButtonProps(e){if(this.state.buttons[e])return this.state.buttons[e].props}_getButtonUITypes(){let e=this._extensionManager.modules.toolbarModule;return Array.isArray(e)?e.reduce((e,t)=>(t.module.forEach(t=>{e[t.name]=t}),e),{}):{}}updateSection(e,t){this.state.buttonSections[e]?this.state.buttonSections[e].push(...t.filter(t=>!this.state.buttonSections[e].find(e=>e===t))):this.state.buttonSections[e]=t,this._broadcastEvent(this.EVENTS.TOOL_BAR_MODIFIED,{...this.state})}createButtonSection(e,t){console.warn("ToolbarService.createButtonSection() is deprecated. Use ToolbarService.updateSection() instead."),this.updateSection(e,t)}getButtonSection(e,t){let r=this.state.buttonSections[e];return r?.map(e=>{let r=this.state.buttons[e];return this._mapButtonToDisplay(r,t)})||[]}getButtonPropsInButtonSection(e){let t=this.state.buttonSections[e];return t?.map(e=>this.getButtonProps(e))||[]}getToolNameForButton(e){let{props:t}=e,r=t?.commands||e.commands,n=(Array.isArray(r)?r:[r])[0];return n?.commandOptions?n.commandOptions.toolName??t?.id??e.id:t?.id??e.id}_mapButtonToDisplay(e,t){if(!e)return;let{id:r,uiType:n}=e,{buttonSection:a}=e.props,i=this._getButtonUITypes()[n];if(e.component||(e.component=i.defaultComponent),!i&&!e.component)return void console.warn(`Neither button type nor a component found for button: ${r}`);a?this.handleEvaluateNested(e.props):this.handleEvaluate(e.props);let{id:o,props:s}=e,l=(e,t)=>{let r=Array.isArray(e)?e:[e],n=this.getButtonProps(t);return r.map(e=>"function"==typeof e.optionComponent?e:{...e,onChange:t=>{e.value=t;let r=Array.isArray(e.commands)?e.commands:[e.commands];if(n&&n.options){let r=n.options.findIndex(t=>t.id===e.id);-1!==r&&(n.options[r].value=t)}r.forEach(r=>{let a={...e,value:t,options:n.options,servicesManager:this._servicesManager,commandsManager:this._commandsManager};this._commandsManager.run(r,a)}),this._broadcastEvent(L1.TOOL_BAR_STATE_MODIFIED,{buttons:this.state.buttons,buttonSections:this.state.buttonSections})}})};if(s?.items?.length){let{items:e=[]}=s;e.forEach(e=>{e.options&&(e.options=l(e.options,e.id))})}else s.options?.length?s.options=l(s.options,o):s.optionComponent&&(s.optionComponent=options.optionComponent);return{id:r,Component:e.component,componentProps:Object.assign({id:r},e.props,t)}}getButtonComponentForUIType(e){return e?this._getButtonUITypes()[e]?.defaultComponent??null:null}clearButtonSection(e){this.state.buttonSections[e]=[],this._broadcastEvent(this.EVENTS.TOOL_BAR_MODIFIED,{...this.state})}isInAnySection(e){return!!e&&Object.values(this.state.buttonSections).some(t=>Array.isArray(t)&&t.includes(e))}getAlignAndSide(e){switch(Number(e)){case L2.TopLeft:return{align:"start",side:"bottom"};case L2.TopMiddle:return{align:"center",side:"bottom"};case L2.TopRight:return{align:"end",side:"bottom"};case L2.LeftMiddle:return{align:"start",side:"right"};case L2.RightMiddle:return{align:"end",side:"left"};case L2.BottomLeft:return{align:"start",side:"top"};case L2.BottomMiddle:return{align:"center",side:"top"};case L2.BottomRight:return{align:"end",side:"top"};default:return{align:"start",side:"bottom"}}}getOptionById(e,t){return e.props.options?.find(e=>e.id===t)}}L5.REGISTRATION={name:"toolbarService",altName:"ToolBarService",create:({commandsManager:e,extensionManager:t,servicesManager:r})=>new L5(e,t,r)},L5.TOOLBAR_SECTIONS=L0;class L3 extends Lx{constructor({servicesManager:e}){super(L3.EVENTS),this.serviceImplementation={},this.servicesManager=void 0,this.presentationIdProviders=void 0,this.servicesManager=e,this.serviceImplementation={},this.presentationIdProviders=new Map}addPresentationIdProvider(e,t){this.presentationIdProviders.set(e,t)}getPresentationIdProvider(e){return this.presentationIdProviders.get(e)}getPresentationId(e,t){let r=this.getState(),n=r.viewports.get(t);return this._getPresentationId(e,{viewport:n,viewports:r.viewports})}_getPresentationId(e,{viewport:t,viewports:r}){let n=[...r.values()].some(e=>e.displaySetInstanceUIDs?.toString()===t.displaySetInstanceUIDs?.toString()&&e.viewportId===t.viewportId),a=this.presentationIdProviders.get(e);return a?a(e,{viewport:t,viewports:r,isUpdatingSameViewport:n,servicesManager:this.servicesManager}):null}getPresentationIds({viewport:e,viewports:t}){return Array.from(this.presentationIdProviders.keys()).reduce((r,n)=>{let a=this._getPresentationId(n,{viewport:e,viewports:t});return null!==a&&(r[n]=a),r},{})}setServiceImplementation({getState:e,setActiveViewportId:t,setDisplaySetsForViewports:r,setLayout:n,reset:a,onModeExit:i,set:o,getNumViewportPanes:s,setViewportIsReady:l,getViewportState:u}){u&&(this.serviceImplementation._getViewportState=u),e&&(this.serviceImplementation._getState=e),t&&(this.serviceImplementation._setActiveViewport=t),r&&(this.serviceImplementation._setDisplaySetsForViewports=r),n&&(this.serviceImplementation._setLayout=n),a&&(this.serviceImplementation._reset=a),i&&(this.serviceImplementation._onModeExit=i),o&&(this.serviceImplementation._set=o),s&&(this.serviceImplementation._getNumViewportPanes=s),l&&(this.serviceImplementation._setViewportIsReady=l)}publishViewportsReady(){this._broadcastEvent(this.EVENTS.VIEWPORTS_READY,{})}publishViewportOnDropHandled(e){this._broadcastEvent(this.EVENTS.VIEWPORT_ONDROP_HANDLED,{eventData:e})}setActiveViewportId(e){e!==this.getActiveViewportId()&&(this.serviceImplementation._setActiveViewport(e),setTimeout(()=>{this._broadcastEvent(this.EVENTS.ACTIVE_VIEWPORT_ID_CHANGED,{viewportId:e})},0))}getState(){return this.serviceImplementation._getState()}getViewportState(e){return this.serviceImplementation._getViewportState(e)}setViewportIsReady(e,t){this.serviceImplementation._setViewportIsReady(e,t)}getActiveViewportId(){return this.getState().activeViewportId}setViewportGridSizeChanged(){let e=this.getState();this._broadcastEvent(this.EVENTS.GRID_SIZE_CHANGED,{state:e})}setDisplaySetsForViewport(e){this.setDisplaySetsForViewports([e])}async setDisplaySetsForViewports(e){await this.serviceImplementation._setDisplaySetsForViewports(e);let t=this.getState(),r=[],n=[];for(let a of e){let e=t.viewports.get(a.viewportId);e?(r.push(e),0===(e.displaySetInstanceUIDs||[]).length&&n.push(a.viewportId)):n.push(a.viewportId)}setTimeout(()=>{this._broadcastEvent(L3.EVENTS.GRID_STATE_CHANGED,{state:t,viewports:r,removedViewportIds:n})})}getDisplaySetsUIDsForViewport(e){let t=this.getState().viewports.get(e);return t?.displaySetInstanceUIDs}async setLayout({numCols:e,numRows:t,layoutOptions:r,layoutType:n="grid",activeViewportId:a,findOrCreateViewport:i,isHangingProtocolLayout:o=!1}){let s=new Set(this.getState().viewports.keys());await this.serviceImplementation._setLayout({numCols:e,numRows:t,layoutOptions:r,layoutType:n,activeViewportId:a,findOrCreateViewport:i,isHangingProtocolLayout:o}),setTimeout(()=>{let r=this.getState(),n=new Set(r.viewports.keys()),a=[...s].filter(e=>!n.has(e));this._broadcastEvent(this.EVENTS.LAYOUT_CHANGED,{numCols:e,numRows:t}),this._broadcastEvent(this.EVENTS.GRID_STATE_CHANGED,{state:r,removedViewportIds:a})},0)}reset(){this.serviceImplementation._reset()}onModeExit(){this.serviceImplementation._onModeExit()}set(e){let t=new Set(this.getState().viewports.keys());this.serviceImplementation._set(e);let r=this.getState(),n=new Set(r.viewports.keys()),a=[...t].filter(e=>!n.has(e));setTimeout(()=>{this._broadcastEvent(this.EVENTS.GRID_STATE_CHANGED,{state:r,removedViewportIds:a})},0)}getNumViewportPanes(){return this.serviceImplementation._getNumViewportPanes()}getLayoutOptionsFromState(e){return Array.from(e.viewports.entries()).map(([e,t])=>({x:t.x,y:t.y,width:t.width,height:t.height}))}}L3.EVENTS={ACTIVE_VIEWPORT_ID_CHANGED:"event::activeviewportidchanged",LAYOUT_CHANGED:"event::layoutChanged",GRID_STATE_CHANGED:"event::gridStateChanged",GRID_SIZE_CHANGED:"event::gridSizeChanged",VIEWPORTS_READY:"event::viewportsReady",VIEWPORT_ONDROP_HANDLED:"event::viewportOnDropHandled"},L3.REGISTRATION={name:"viewportGridService",altName:"ViewportGridService",create:({configuration:e={},servicesManager:t})=>new L3({servicesManager:t})};class L4 extends Lx{constructor(){super(L4.EVENTS),this.serviceImplementation={},this.startedClips=new Map,this.closedViewports=new Set,this.serviceImplementation={}}getState(){return this.serviceImplementation._getState()}setCine({id:e,frameRate:t,isPlaying:r}){return this.serviceImplementation._setCine({id:e,frameRate:t,isPlaying:r})}setIsCineEnabled(e){this.serviceImplementation._setIsCineEnabled(e),e&&this.closedViewports.forEach(e=>{this.clearViewportCineClosed(e)}),queueMicrotask(()=>{this._broadcastEvent(this.EVENTS.CINE_STATE_CHANGED,{isCineEnabled:e})})}playClip(e,t){let r=this.serviceImplementation._playClip(e,t);return this.startedClips.set(e,t),this._broadcastEvent(this.EVENTS.CINE_STATE_CHANGED,{isPlaying:!0}),r}stopClip(e,t){let r=this.serviceImplementation._stopClip(e,t);return this._broadcastEvent(this.EVENTS.CINE_STATE_CHANGED,{isPlaying:!1}),r}onModeExit(){this.setIsCineEnabled(!1),this.startedClips.forEach((e,t)=>{this.stopClip(t,e)})}getSyncedViewports(e){return this.serviceImplementation._getSyncedViewports(e)}setViewportCineClosed(e){this.closedViewports.add(e)}isViewportCineClosed(e){return this.closedViewports.size>0}clearViewportCineClosed(e){this.closedViewports.delete(e)}setServiceImplementation({getState:e,setCine:t,setIsCineEnabled:r,playClip:n,stopClip:a,getSyncedViewports:i}){i&&(this.serviceImplementation._getSyncedViewports=i),e&&(this.serviceImplementation._getState=e),t&&(this.serviceImplementation._setCine=t),r&&(this.serviceImplementation._setIsCineEnabled=r),n&&(this.serviceImplementation._playClip=n),a&&(this.serviceImplementation._stopClip=a)}}L4.EVENTS={CINE_STATE_CHANGED:"event::cineStateChanged"},L4.REGISTRATION={name:"cineService",altName:"CineService",create:({configuration:e={}})=>new L4};var L8=u(3359),L6=u.n(L8);function L9(){var e=[].slice.call(arguments),t=e.length;return function(r,n){var a,i,o,s,l,u,c;for(c=0;c<t&&(u=0,a=r[s="string"==typeof(o=e[c])?o:o.name],i=n[s],void 0!==o.primer&&(a=o.primer(a),i=o.primer(i)),l=o.reverse?-1:1,a<i&&(u=-1*l),a>i&&(u=+l),0===u);c++);return u}}var L7=u(6834),Ne=u.n(L7);Ne().validators.equals=function(e,t,r){let n=Nt(t),a=Nr(e);if(Array.isArray(n)){if(n.length!==a.length)return`${r} must be an array of length ${n.length}`;else for(let e=0;e<n.length;e++)if(n[e]!==a[e])return`${r} ${n[e]} must equal ${a[e]}`}else if(n!==a[0])return`${r} must equal ${n}`},Ne().validators.doesNotEqual=function(e,t,r){let n=Nt(t),a=Nr(e);if(Array.isArray(n)){if(n.length===a.length){let e=0;if(n.forEach((t,r)=>{t===a[r]&&e++}),e===n.length)return`${r} must not equal to ${n}`}}else if(n===a[0])return console.log(a,n),`${r} must not equal to ${n}`},Ne().validators.includes=function(e,t,r){let n=Nt(t),a=Nr(e);return Array.isArray(n)?0===n.filter(e=>a.includes(e)).length?`${r} must include at least one of the following values: ${n.join(", ")}`:void 0:`${r} ${n} must be an array`},Ne().validators.doesNotInclude=function(e,t,r){let n=Nt(t),a=Nr(e);if(!Array.isArray(n))return`${r} ${n} must be an array`;{let e=n.filter(e=>a.includes(e));if(e.length>0)return`${r} must not include the following value: ${e}`}},Ne().validators.containsI=function(e,t,r){let n=Nt(t);if(Array.isArray(e)){if(e.some(e=>!Ne().validators.containsI(e.toLowerCase(),t,r)))return;return`No item of ${e.join(",")} contains ${JSON.stringify(n)}`}if(Array.isArray(n)){if(n.some(t=>!Ne().validators.containsI(e,t.toLowerCase(),r)))return;return`${r} must contain at least one of ${n.join(",")}`}if(n&&e.indexOf&&-1===e.toLowerCase().indexOf(n.toLowerCase()))return r+"must contain any case of"+n},Ne().validators.contains=function(e,t,r){let n=Nt(t);if(Array.isArray(e)){if(e.some(e=>!Ne().validators.contains(e,t,r)))return;return`No item of ${e.join(",")} contains ${JSON.stringify(n)}`}if(Array.isArray(n)){if(n.some(t=>!Ne().validators.contains(e,t,r)))return;return`${r} must contain at least one of ${n.join(",")}`}if(n&&e.indexOf&&-1===e.indexOf(n))return r+"must contain "+n},Ne().validators.containsAll=function(e,t,r){let n=Nt(t);if(!Array.isArray(e)||!Array.isArray(n))return`${r} must be an array and test value must be an array.`;let a=n.filter(t=>!e.includes(t));if(a.length>0)return`${r} must contain all of: ${n.join(", ")}. Missing: ${a.join(", ")}`},Ne().validators.doesNotContain=function(e,t,r){if(!Ne().validators.contains(e,t,r))return`No item of ${e} should contain ${Nt(t)}`},Ne().validators.doesNotContainI=function(e,t,r){if(!Ne().validators.containsI(e,t,r))return`No item of ${e} should not contain ${Nt(t)}`},Ne().validators.startsWith=function(e,t,r){let n=Nt(t);if("string"==typeof n&&(n=[n]),"string"==typeof e){if(!n.some(t=>e.startsWith(t)))return r+" must start with any of these values: "+n}else{if(!Array.isArray(e))return"Value must be a string or an array";let t=!1;for(let r=0;r<e.length;r++){for(let a=0;a<n.length;a++)if(e[r].startsWith(n[a])){t=!0;break}if(t)return}if(!t)return r+" must start with any of these values: "+n}},Ne().validators.endsWith=function(e,t,r){let n=Nt(t);if("string"==typeof n&&(n=[n]),"string"==typeof e){if(!n.some(t=>e.endsWith(t)))return r+" must end with any of these values: "+n}else{if(!Array.isArray(e))return r+" must be a string or an array";let t=!1;for(let r=0;r<e.length;r++){for(let a=0;a<n.length;a++)if(e[r].endsWith(n[a])){t=!0;break}if(t)return}if(!t)return r+" must end with any of these values: "+n}},Ne().validators.greaterThan=function(e,t,r){let n=Nt(t);if(Array.isArray(e)||"string"==typeof e)return`${r} is not allowed as an array or string`;if(Array.isArray(n)){if(1===n.length){if(!(e>=n[0]))return`${r} must be greater than or equal to ${n[0]}, but was ${e}`}else if(n.length>1)return r+" must be an array of length 1"}else if(!(e>=n))return r+" must be greater than "+n},Ne().validators.lessThan=function(e,t,r){let n=Nt(t);if(Array.isArray(n)){if(1===n.length){if(!(e<=n[0]))return`${r} must be less than or equal to ${n[0]}, but was ${e}`}else if(n.length>1)return r+" must be an array of length 1"}else if(!(e<=n))return r+" must be less than "+n},Ne().validators.range=function(e,t,r){let n=Nt(t);if(!Array.isArray(n)||2!==n.length)return`${r} must be an array of length 2`;{let t=Math.min(n[0],n[1]),a=Math.max(n[0],n[1]);if(void 0===e||e<t||e>a)return`${r} with value ${e} must be between ${t} and ${a}`}},Ne().validators.notNull=e=>null==e?"Value is null":void 0;let Nt=e=>Array.isArray(e)?e.map(e=>e?.value??e):e?.value??e,Nr=e=>Array.isArray(e)?[...e]:[e],Nn=Ne();class Na{constructor(e,t){this.protocols=e,this.customAttributeRetrievalCallbacks=t,this.matchedProtocols=new Map,this.matchedProtocolScores={},this.study=void 0}run({studies:e,displaySets:t,activeStudy:r}){return this.studies=e,this.study=r||e[0],this.displaySets=t,this.getBestProtocolMatch()}getBestProtocolMatch(){this.updateProtocolMatches();let e=this._getHighestScoringProtocol();return console.log("ProtocolEngine::getBestProtocolMatch bestMatch",e),e}updateProtocolMatches(){console.log("ProtocolEngine::updateProtocolMatches"),this._clearMatchedProtocols(),this.findMatchByStudy(this.study,{studies:this.studies,displaySets:this.displaySets}).forEach(e=>{let t=e.protocol;t&&(this.matchedProtocols.has(t.id)||(console.log("ProtocolEngine::updateProtocolMatches inserting protocol match",e),this.matchedProtocols.set(t.id,t),this.matchedProtocolScores[t.id]=e.score))})}findMatch(e,t,r){return((e,t=[],r,n)=>{let a={format:"grouped"},i={passed:[],failed:[]},o={},s=!1,l=0,u=n?.studies?.[1],c=n?.studies?.[0],d=e.instances?.[0],h={prior:u,current:c,instance:d,...n,options:n,metadataInstance:e};return t.forEach(t=>{let u,{attribute:c,from:p="metadataInstance"}=t;r.hasOwnProperty(c)?o[c]=r[c].callback.call(t,e,n):o[c]=h[p]?.[c]??d?.[c];let f=((e,t,r,n)=>{if("object"!=typeof t||null===t)return t;let a={};return Object.entries(t).forEach(([e,t])=>{if("object"==typeof t&&Object.keys(t).length>0&&"attribute"in t){let i=t.attribute,o=t.from??"metadataInstance";if(r.hasOwnProperty(i)){let t=r[i].callback.call(null,n[o],n.options);a[e]={value:t}}else a[e]={value:n[o]?.[i]??n.metadataInstance?.[i]}}else a[e]=t},{}),a})(0,t.constraint,r,h),m={[c]:o[c]};try{u=Nn(m,{[c]:f},[a])}catch(e){u=["Something went wrong during validation.",e]}u?(t.required&&(s=!0),i.failed.push({rule:t,errorMessages:u})):(l+=parseInt(t.weight||1,10),i.passed.push({rule:t}))}),s&&(l=0),{score:l,details:i,requiredFailed:s}})(e,t,this.customAttributeRetrievalCallbacks,r)}findMatchByStudy(e,t){let r=[];if(this.protocols.forEach(n=>{let a=n.protocolMatchingRules.slice();if(!a||!a.length)return void console.warn("ProtocolEngine::findMatchByStudy no matching rules - specify protocolMatchingRules for",n.id);let i=this.findMatch(e,a,t).score;i>0&&r.push({score:i,protocol:n})}),!r.length){let e=this.protocols.find(e=>"default"===e.id)??this.protocols[0];return console.log("No protocol matches, defaulting to",e),[{score:0,protocol:e}]}return r.sort((e,t)=>t.score-e.score),console.log("ProtocolEngine::findMatchByStudy matched",r),r}_clearMatchedProtocols(){this.matchedProtocols.clear(),this.matchedProtocolScores={}}_largestKeyByValue(e){return Object.keys(e).reduce((t,r)=>e[t]>e[r]?t:r)}_getHighestScoringProtocol(){if(!Object.keys(this.matchedProtocolScores).length)return;let e=this._largestKeyByValue(this.matchedProtocolScores);return this.matchedProtocols.get(e)}}function Ni(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}var No=u(8985),Ns=u(8681),Nl=u.n(Ns);!function(e,t={timeout:100}){var r=[],n=null,a=[],i=!1,o=null,s=e.prototype.handleKey;function l(e,t,r){if(!this.recording)return void s.apply(this,arguments);if("keydown"==r.type){1===e.length&&i&&c();for(let e=0;e<t.length;++e)u(t[e]);u(e)}else"keyup"==r.type&&a.length>0&&c()}function u(e){for(let t=0;t<a.length;++t)if(a[t]===e)return;a.push(e),1===e.length&&(i=!0)}function c(){r.push(a),a=[],i=!1,clearTimeout(o),o=setTimeout(d,t.timeout)}function d(){if(n){var e=r;for(let t=0;t<e.length;++t)e[t].sort(function(e,t){return e.length>1&&1===t.length?-1:1===e.length&&t.length>1||e>t?1:-1}),e[t]=e[t].join("+");n(r)}r=[],n=null,a=[]}e.prototype.record=function(e){var t=this;t.recording=!0,n=function(){t.recording=!1,e.apply(t,arguments)}},e.prototype.stopRecord=function(){this.recording=!1},e.prototype.startRecording=function(){this.recording=!0},e.prototype.handleKey=function(){l.apply(this,arguments)},e.init()}(Nl()),em7=(em9=Nl()).prototype.stopCallback,em9.prototype.stopCallback=function(e,t,r){return!!this.paused||em7.call(this,e,t,r)},em9.prototype.pause=function(){this.paused=!0},em9.prototype.unpause=function(){this.paused=!1},em9.init();let Nu=Nl();Symbol("Type"),Symbol("Task"),Symbol("List");let Nc=Object.freeze(["SEG","KO","PR","SR","RTSTRUCT","RTDOSE","RTPLAN","RTRECORD","REG"]);function Nd(e){return Nc.includes(e)}let Nh={ComputedRadiographyImageStorage:"1.2.840.10008.5.1.4.1.1.1",DigitalXRayImageStorageForPresentation:"1.2.840.10008.5.1.4.1.1.1.1",DigitalXRayImageStorageForProcessing:"1.2.840.10008.5.1.4.1.1.1.1.1",DigitalMammographyXRayImageStorageForPresentation:"1.2.840.10008.5.1.4.1.1.1.2",DigitalMammographyXRayImageStorageForProcessing:"1.2.840.10008.5.1.4.1.1.1.2.1",DigitalIntraOralXRayImageStorageForPresentation:"1.2.840.10008.5.1.4.1.1.1.3",DigitalIntraOralXRayImageStorageForProcessing:"1.2.840.10008.5.1.4.1.1.1.3.1",CTImageStorage:"1.2.840.10008.5.1.4.1.1.2",EnhancedCTImageStorage:"1.2.840.10008.5.1.4.1.1.2.1",LegacyConvertedEnhancedCTImageStorage:"1.2.840.10008.5.1.4.1.1.2.2",UltrasoundMultiframeImageStorage:"1.2.840.10008.5.1.4.1.1.3.1",MRImageStorage:"1.2.840.10008.5.1.4.1.1.4",EnhancedMRImageStorage:"1.2.840.10008.5.1.4.1.1.4.1",MRSpectroscopyStorage:"1.2.840.10008.5.1.4.1.1.4.2",EnhancedMRColorImageStorage:"1.2.840.10008.5.1.4.1.1.4.3",LegacyConvertedEnhancedMRImageStorage:"1.2.840.10008.5.1.4.1.1.4.4",UltrasoundImageStorage:"1.2.840.10008.5.1.4.1.1.6.1",EnhancedUSVolumeStorage:"1.2.840.10008.5.1.4.1.1.6.2",SecondaryCaptureImageStorage:"1.2.840.10008.5.1.4.1.1.7",MultiframeSingleBitSecondaryCaptureImageStorage:"1.2.840.10008.5.1.4.1.1.7.1",MultiframeGrayscaleByteSecondaryCaptureImageStorage:"1.2.840.10008.5.1.4.1.1.7.2",MultiframeGrayscaleWordSecondaryCaptureImageStorage:"1.2.840.10008.5.1.4.1.1.7.3",MultiframeTrueColorSecondaryCaptureImageStorage:"1.2.840.10008.5.1.4.1.1.7.4",Sop12LeadECGWaveformStorage:"1.2.840.10008.5.1.4.1.1.9.1.1",GeneralECGWaveformStorage:"1.2.840.10008.5.1.4.1.1.9.1.2",AmbulatoryECGWaveformStorage:"1.2.840.10008.5.1.4.1.1.9.1.3",HemodynamicWaveformStorage:"1.2.840.10008.5.1.4.1.1.9.2.1",CardiacElectrophysiologyWaveformStorage:"1.2.840.10008.5.1.4.1.1.9.3.1",BasicVoiceAudioWaveformStorage:"1.2.840.10008.5.1.4.1.1.9.4.1",GeneralAudioWaveformStorage:"1.2.840.10008.5.1.4.1.1.9.4.2",ArterialPulseWaveformStorage:"1.2.840.10008.5.1.4.1.1.9.5.1",RespiratoryWaveformStorage:"1.2.840.10008.5.1.4.1.1.9.6.1",GrayscaleSoftcopyPresentationStateStorage:"1.2.840.10008.5.1.4.1.1.11.1",ColorSoftcopyPresentationStateStorage:"1.2.840.10008.5.1.4.1.1.11.2",PseudoColorSoftcopyPresentationStateStorage:"1.2.840.10008.5.1.4.1.1.11.3",BlendingSoftcopyPresentationStateStorage:"1.2.840.10008.5.1.4.1.1.11.4",XAXRFGrayscaleSoftcopyPresentationStateStorage:"1.2.840.10008.5.1.4.1.1.11.5",XRayAngiographicImageStorage:"1.2.840.10008.5.1.4.1.1.12.1",EnhancedXAImageStorage:"1.2.840.10008.5.1.4.1.1.12.1.1",XRayRadiofluoroscopicImageStorage:"1.2.840.10008.5.1.4.1.1.12.2",EnhancedXRFImageStorage:"1.2.840.10008.5.1.4.1.1.12.2.1",XRay3DAngiographicImageStorage:"1.2.840.10008.5.1.4.1.1.13.1.1",XRay3DCraniofacialImageStorage:"1.2.840.10008.5.1.4.1.1.13.1.2",BreastTomosynthesisImageStorage:"1.2.840.10008.5.1.4.1.1.13.1.3",BreastProjectionXRayImageStorageForPresentation:"1.2.840.10008.5.1.4.1.1.13.1.4",BreastProjectionXRayImageStorageForProcessing:"1.2.840.10008.5.1.4.1.1.13.1.5",IntravascularOpticalCoherenceTomographyImageStorageForPresentation:"1.2.840.10008.5.1.4.1.1.14.1",IntravascularOpticalCoherenceTomographyImageStorageForProcessing:"1.2.840.10008.5.1.4.1.1.14.2",NuclearMedicineImageStorage:"1.2.840.10008.5.1.4.1.1.20",RawDataStorage:"1.2.840.10008.5.1.4.1.1.66",SpatialRegistrationStorage:"1.2.840.10008.5.1.4.1.1.66.1",SpatialFiducialsStorage:"1.2.840.10008.5.1.4.1.1.66.2",DeformableSpatialRegistrationStorage:"1.2.840.10008.5.1.4.1.1.66.3",SegmentationStorage:"1.2.840.10008.5.1.4.1.1.66.4",LabelmapSegmentationStorage:"1.2.840.10008.5.1.4.1.1.66.7",SurfaceSegmentationStorage:"1.2.840.10008.5.1.4.1.1.66.5",RealWorldValueMappingStorage:"1.2.840.10008.5.1.4.1.1.67",SurfaceScanMeshStorage:"1.2.840.10008.5.1.4.1.1.68.1",SurfaceScanPointCloudStorage:"1.2.840.10008.5.1.4.1.1.68.2",VLEndoscopicImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.1",VideoEndoscopicImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.1.1",VLMicroscopicImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.2",VideoMicroscopicImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.2.1",VLSlideCoordinatesMicroscopicImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.3",VLPhotographicImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.4",VideoPhotographicImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.4.1",OphthalmicPhotography8BitImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.5.1",OphthalmicPhotography16BitImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.5.2",StereometricRelationshipStorage:"1.2.840.10008.5.1.4.1.1.77.1.5.3",OphthalmicTomographyImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.5.4",VLWholeSlideMicroscopyImageStorage:"1.2.840.10008.5.1.4.1.1.77.1.6",LensometryMeasurementsStorage:"1.2.840.10008.5.1.4.1.1.78.1",AutorefractionMeasurementsStorage:"1.2.840.10008.5.1.4.1.1.78.2",KeratometryMeasurementsStorage:"1.2.840.10008.5.1.4.1.1.78.3",SubjectiveRefractionMeasurementsStorage:"1.2.840.10008.5.1.4.1.1.78.4",VisualAcuityMeasurementsStorage:"1.2.840.10008.5.1.4.1.1.78.5",SpectaclePrescriptionReportStorage:"1.2.840.10008.5.1.4.1.1.78.6",OphthalmicAxialMeasurementsStorage:"1.2.840.10008.5.1.4.1.1.78.7",IntraocularLensCalculationsStorage:"1.2.840.10008.5.1.4.1.1.78.8",MacularGridThicknessandVolumeReport:"1.2.840.10008.5.1.4.1.1.79.1",OphthalmicVisualFieldStaticPerimetryMeasurementsStorage:"1.2.840.10008.5.1.4.1.1.80.1",OphthalmicThicknessMapStorage:"1.2.840.10008.5.1.4.1.1.81.1",CornealTopographyMapStorage:"1.2.840.10008.5.1.4.1.1.82.1",BasicTextSR:"1.2.840.10008.5.1.4.1.1.88.11",EnhancedSR:"1.2.840.10008.5.1.4.1.1.88.22",ComprehensiveSR:"1.2.840.10008.5.1.4.1.1.88.33",Comprehensive3DSR:"1.2.840.10008.5.1.4.1.1.88.34",ProcedureLog:"1.2.840.10008.5.1.4.1.1.88.40",MammographyCADSR:"1.2.840.10008.5.1.4.1.1.88.50",KeyObjectSelection:"1.2.840.10008.5.1.4.1.1.88.59",ChestCADSR:"1.2.840.10008.5.1.4.1.1.88.65",XRayRadiationDoseSR:"1.2.840.10008.5.1.4.1.1.88.67",RadiopharmaceuticalRadiationDoseSR:"1.2.840.10008.5.1.4.1.1.88.68",ColonCADSR:"1.2.840.10008.5.1.4.1.1.88.69",ImplantationPlanSRDocumentStorage:"1.2.840.10008.5.1.4.1.1.88.70",EncapsulatedPDFStorage:"1.2.840.10008.5.1.4.1.1.104.1",EncapsulatedCDAStorage:"1.2.840.10008.5.1.4.1.1.104.2",PositronEmissionTomographyImageStorage:"1.2.840.10008.5.1.4.1.1.128",EnhancedPETImageStorage:"1.2.840.10008.5.1.4.1.1.130",LegacyConvertedEnhancedPETImageStorage:"1.2.840.10008.5.1.4.1.1.128.1",BasicStructuredDisplayStorage:"1.2.840.10008.5.1.4.1.1.131",RTImageStorage:"1.2.840.10008.5.1.4.1.1.481.1",RTDoseStorage:"1.2.840.10008.5.1.4.1.1.481.2",RTStructureSetStorage:"1.2.840.10008.5.1.4.1.1.481.3",RTBeamsTreatmentRecordStorage:"1.2.840.10008.5.1.4.1.1.481.4",RTPlanStorage:"1.2.840.10008.5.1.4.1.1.481.5",RTBrachyTreatmentRecordStorage:"1.2.840.10008.5.1.4.1.1.481.6",RTTreatmentSummaryRecordStorage:"1.2.840.10008.5.1.4.1.1.481.7",RTIonPlanStorage:"1.2.840.10008.5.1.4.1.1.481.8",RTIonBeamsTreatmentRecordStorage:"1.2.840.10008.5.1.4.1.1.481.9",RTBeamsDeliveryInstructionStorage:"1.2.840.10008.5.1.4.34.7",GenericImplantTemplateStorage:"1.2.840.10008.5.1.4.43.1",ImplantAssemblyTemplateStorage:"1.2.840.10008.5.1.4.44.1",ImplantTemplateGroupStorage:"1.2.840.10008.5.1.4.45.1"},Np=[Nh.ComputedRadiographyImageStorage,Nh.DigitalXRayImageStorageForPresentation,Nh.DigitalXRayImageStorageForProcessing,Nh.DigitalMammographyXRayImageStorageForPresentation,Nh.DigitalMammographyXRayImageStorageForProcessing,Nh.DigitalIntraOralXRayImageStorageForPresentation,Nh.DigitalIntraOralXRayImageStorageForProcessing,Nh.CTImageStorage,Nh.EnhancedCTImageStorage,Nh.LegacyConvertedEnhancedCTImageStorage,Nh.UltrasoundMultiframeImageStorage,Nh.EnhancedUSVolumeStorage,Nh.MRImageStorage,Nh.EnhancedMRImageStorage,Nh.EnhancedMRColorImageStorage,Nh.LegacyConvertedEnhancedMRImageStorage,Nh.UltrasoundImageStorage,Nh.SecondaryCaptureImageStorage,Nh.MultiframeSingleBitSecondaryCaptureImageStorage,Nh.MultiframeGrayscaleByteSecondaryCaptureImageStorage,Nh.MultiframeGrayscaleWordSecondaryCaptureImageStorage,Nh.MultiframeTrueColorSecondaryCaptureImageStorage,Nh.XRayAngiographicImageStorage,Nh.EnhancedXAImageStorage,Nh.XRayRadiofluoroscopicImageStorage,Nh.EnhancedXRFImageStorage,Nh.XRay3DAngiographicImageStorage,Nh.XRay3DCraniofacialImageStorage,Nh.BreastTomosynthesisImageStorage,Nh.BreastProjectionXRayImageStorageForPresentation,Nh.BreastProjectionXRayImageStorageForProcessing,Nh.IntravascularOpticalCoherenceTomographyImageStorageForPresentation,Nh.IntravascularOpticalCoherenceTomographyImageStorageForProcessing,Nh.NuclearMedicineImageStorage,Nh.VLEndoscopicImageStorage,Nh.VideoEndoscopicImageStorage,Nh.VLMicroscopicImageStorage,Nh.VideoMicroscopicImageStorage,Nh.VLSlideCoordinatesMicroscopicImageStorage,Nh.VLPhotographicImageStorage,Nh.VideoPhotographicImageStorage,Nh.OphthalmicPhotography8BitImageStorage,Nh.OphthalmicPhotography16BitImageStorage,Nh.OphthalmicTomographyImageStorage,Nh.VLWholeSlideMicroscopyImageStorage,Nh.PositronEmissionTomographyImageStorage,Nh.EnhancedPETImageStorage,Nh.LegacyConvertedEnhancedPETImageStorage,Nh.RTImageStorage];function Nf(e){return Array.isArray(e)?[...e].map(e=>void 0!==e?Number(e):e):void 0!==e?Number(e):e}var Nm=u(7155);function Ng(e){let t=e.indexOf(":");return e.substring(t+1)}function Ny(e){return(/^(http|https|dicomfile):\/\//.test(e)?e:Ng(e)).split("&frame=")[0].split("?frame=")[0]}let Nv=(e,t)=>e==t?0:!e&&t?-1:!t&&e?1:e<t?-1:1,Nb=new Map,Nw=(e,t)=>{let{compareSameSeries:r="default"}=e,{compareSameSeries:n="default"}=t,a=Nb.get(r),i=Nb.get(n);if(a&&i){let r=a===i?a.compare(e,t):Nv(a.priority,i.priority);if(!r)return r}return NM(e.instance,t.instance)},Nx=(e,t)=>Nv(e.SeriesInstanceUID,t.SeriesInstanceUID)||Nw(e,t),NC=(e,t)=>Nv(`${e.seriesDate??e.SeriesDate} ${e.seriesTime??e.SeriesTime}`,`${t.seriesDate??t.SeriesDate} ${t.seriesTime??t.SeriesTime}`)||Nx(e,t);function Nk(e,t){let r=Nd(e.Modality??e.modality),n=Nd(t.Modality??t.modality);return r?n?NC(t,e):1:n?-1:Nv(e.SeriesNumber??e.seriesNumber,t.SeriesNumber??t.seriesNumber)||NC(e,t)}let NM=(e,t)=>e&&t?(parseInt(e.InstanceNumber)||0)!==(parseInt(t.InstanceNumber)||0)?(parseInt(e.InstanceNumber)||0)-(parseInt(t.InstanceNumber)||0):Nv(e.SOPInstanceUID,t.SOPInstanceUID)||Nv(e.frameNumber,t.frameNumber):!e&&-1||1,NE=e=>{if(!e)return null;for(let t=0;t<e.length;t++)if(-1!==e[t].indexOf(",")){let r=e[t].split(/,/);e.splice(t,1,...r)}return e},NS=(e,t=new URLSearchParams(window.location.search))=>{let r=[...t.keys()].find(t=>t.toLowerCase()===e);if(r)return NE(t.getAll(r))},ND=(0,em.createContext)(null),{Provider:NI}=ND;function NP(e){if(e)return t=>e.includes(t.referenceSeriesUID)}function NT(e){return t=>t.referenceStudyUID==e}function N_(e){return e?.referencedImageId}function NA(e){return t=>t.metadata?.toolName===e}function NO(e){return!0}function NR(e){return!1}function NL(...e){return function(t){for(let r of e)if(!r||("string"==typeof r&&(r=this[r]),"function"==typeof r&&r.call(this,t)))return!0;return!1}}let{POINT:NN}=Lj.VALUE_TYPES;function NF(e){return e.type===NN&&e.referencedImageId}function NV(e,t){return r=>!e(r)&&t(r)}let NB=e=>"string"==typeof e||e instanceof String;function Nj(...e){let t=e.filter(e=>!!e);if(t.length)return 1===t.length&&"function"==typeof t[0]?t[0]:function(e){for(let r of t)if(NB(r)){if(!this[r](e))return!1}else if(!r.call(this,e))return!1;return!0}}let NW=e=>{let t=new URLSearchParams(window.location.search),r=NS("initialseriesinstanceuid",t),n=NS("initialsopinstanceuid",t);if(!r&&!n)return!1;let a=r?.some(t=>e.SeriesInstanceUID===t),i=n?.some(t=>e.instances?.some(e=>t===e.SOPInstanceUID));return a||i};function NU(e){let t=e?.[0];if(!t)return;let r=NS("initialsopinstanceuid");if(!r)return;let n=t.instances.findIndex(e=>r.includes(e.SOPInstanceUID));return -1===n?void 0:{index:n}}let Nz=(e,t)=>{let r=t?.displaySets?.filter(e=>e.numImageFrames>0)?.length;return console.log("number of display sets with images",r),r},NH=(e,t)=>t?.displaySets?.map(e=>e.SeriesDescription),NG={toolGroupId:"default",viewportType:"stack"};class Nq extends Lx{constructor(e,t){super(Nq.EVENTS),this.studies=void 0,this.protocols=void 0,this.activeProtocolIds=void 0,this.protocol=void 0,this._originalProtocol=void 0,this.stageIndex=0,this._commandsManager=void 0,this._servicesManager=void 0,this.protocolEngine=void 0,this.customViewportSettings=[],this.displaySets=[],this.activeStudy=void 0,this.debugLogging=void 0,this.customAttributeRetrievalCallbacks={NumberOfStudyRelatedSeries:{name:"The number of series in the study",callback:e=>e.NumberOfStudyRelatedSeries??e.series?.length},NumberOfSeriesRelatedInstances:{name:"The number of instances in the display set",callback:e=>e.numImageFrames},ModalitiesInStudy:{name:"Gets the array of the modalities for the series",callback:e=>{if(e.ModalitiesInStudy?.length>0)return e.ModalitiesInStudy;if(Array.isArray(e.series)){var t,r;return t=e.series,r="Modality",t.reduce((e,t)=>{let n=t[r];return!n&&t.instances&&t.instances[0]&&(n=t.instances[0][r]),n&&-1===e.indexOf(n)&&e.push(n),e},[])}return[]}},isReconstructable:{name:"Checks if the display set is reconstructable",callback:e=>e.isReconstructable??!1},isDisplaySetFromUrl:{name:"Checks if the display set is as specified in the URL",callback:NW},sopInstanceLocation:{name:"Gets the position of the specified sop instance",callback:NU},seriesDescriptions:{name:"seriesDescriptions",description:"List of Series Descriptions",callback:NH},numberOfDisplaySetsWithImages:{name:"numberOfDisplaySetsWithImages",description:"Number of displays sets with images",callback:Nz}},this.listeners={},this.registeredImageLoadStrategies={},this.activeImageLoadStrategyName=null,this.customImageLoadPerformed=!1,this.displaySetMatchDetails=new Map,this.viewportMatchDetails=new Map,this._commandsManager=e,this._servicesManager=t,this.protocols=new Map,this.protocolEngine=void 0,this.protocol=void 0,this.stageIndex=void 0,this.studies=[]}destroy(){this.reset(),this.protocols=new Map}reset(){this.studies=[],this.viewportMatchDetails=new Map,this.displaySetMatchDetails=new Map,this.protocol=void 0,this.stageIndex=void 0,this.protocolEngine=void 0}onModeEnter(){this.reset()}getActiveProtocol(){return{protocol:this.protocol,_originalProtocol:this._originalProtocol,stage:this.protocol?.stages?.[this.stageIndex],stageIndex:this.stageIndex,activeStudy:this.activeStudy,viewportMatchDetails:this.viewportMatchDetails,displaySetMatchDetails:this.displaySetMatchDetails,activeImageLoadStrategyName:this.activeImageLoadStrategyName}}getState(){if(this.protocol)return{protocolId:this.protocol.id,stageIndex:this.stageIndex,stageId:this.protocol.stages[this.stageIndex].id,activeStudyUID:this.activeStudy?.StudyInstanceUID}}filterSeriesRequiredForRun(e,t){Array.isArray(e)&&(e=e[0]);let r=this.getProtocolById(e)?.hpInitiationCriteria?.minSeriesLoaded||t.length;return{requiredSeries:t.slice(0,r),remaining:t.slice(r)}}getDefaultProtocol(){return this.getProtocolById("default")}getMatchDetails(){return{viewportMatchDetails:this.viewportMatchDetails,displaySetMatchDetails:this.displaySetMatchDetails}}getProtocols(){let e=[];for(let t of this.activeProtocolIds||this.protocols.keys()){let r=this.getProtocolById(t);r&&e.push(r)}return e}getProtocolById(e,t=!0){if(!e)return;if(e===this.protocol?.id)return this.protocol;let r=this.protocols.get(e);if(!r&&t){let t=e.toLowerCase();for(let[e]of this.protocols)if(e.toLowerCase()===t){r=this.getProtocolById(e);break}}if(!r)throw Error(`No protocol ${e} found`);if(!(r instanceof Function))return this._validateProtocol(r);try{let{protocol:e}=this._getProtocolFromGenerator(r);return e}catch(t){console.warn(`Error while executing protocol generator for protocol ${e}: ${t}`)}}addProtocol(e,t){this.protocols.has(e)&&console.warn(`A protocol with id ${e} already exists. It will be overwritten.`),t instanceof Function||(t=this._validateProtocol(t)),this.protocols.set(e,t)}addActiveProtocolId(e){e&&(this.activeProtocolIds||(this.activeProtocolIds=[]),this.activeProtocolIds.push(e))}setActiveProtocolIds(e){if(!e||!e.length){this.activeProtocolIds=null,console.log("No active protocols, setting all to active");return}"string"==typeof e?this.setActiveProtocolIds([e]):this.activeProtocolIds=[...e]}setActiveStudyUID(e){if(e&&e!==this.activeStudy?.StudyInstanceUID)return this.activeStudy=this.studies.find(t=>t.StudyInstanceUID===e),this.activeStudy}hasStudyUID(e){return this.studies.some(t=>t.StudyInstanceUID===e)}addStudy(e){this.hasStudyUID(e.StudyInstanceUID)||this.studies.push(e)}run({studies:e,displaySets:t,activeStudy:r},n,a={}){if(this.studies=[...e||this.studies],this.displaySets=t,this.setActiveStudyUID(r?.StudyInstanceUID||(r||this.studies[0])?.StudyInstanceUID),this.protocolEngine=new Na(this.getProtocols(),this.customAttributeRetrievalCallbacks),this.protocol=null,n&&"string"==typeof n){let e=this.getProtocolById(n);this._setProtocol(e,a)}else{let e=this.protocolEngine.run({studies:this.studies,activeStudy:r,displaySets:t});this._setProtocol(e)}this.protocol?.callbacks?.onProtocolEnter&&this._commandsManager.run(this.protocol?.callbacks?.onProtocolEnter)}hasCustomImageLoadStrategy(){return null!==this.activeImageLoadStrategyName&&this.registeredImageLoadStrategies[this.activeImageLoadStrategyName]instanceof Function}getCustomImageLoadPerformed(){return this.customImageLoadPerformed}getShouldPerformCustomImageLoad(){return this.hasCustomImageLoadStrategy()&&!this.getCustomImageLoadPerformed()}registerImageLoadStrategy(e,t){t instanceof Function&&e&&(this.registeredImageLoadStrategies[e]=t)}addCustomAttribute(e,t,r,n={}){this.customAttributeRetrievalCallbacks[e]={...n,id:e,name:t,callback:r}}runImageLoadStrategy(e){let t=(0,this.registeredImageLoadStrategies[this.activeImageLoadStrategyName])({data:e,displaySetsMatchDetails:this.displaySetMatchDetails,viewportMatchDetails:this.viewportMatchDetails});return t?(this.customImageLoadPerformed=!0,this._broadcastEvent(this.EVENTS.CUSTOM_IMAGE_LOAD_PERFORMED,t),!0):(console.warn("Not able to load data with custom strategy"),!1)}_validateProtocol(e){e.name=e.name??e.id;let{stages:t}=e;if(!t)return void console.warn("Protocol has not stages:",e.id,e);for(let t of Object.keys(e.displaySetSelectors)){let r=e.displaySetSelectors[t];r.id=t;let{seriesMatchingRules:n}=r;if(!n)return void console.warn("Selector has no series matching rules",e.id,t)}return t.forEach(t=>{if(t.viewports)t.viewports=t.viewports.map((r,n)=>{let a=t.defaultViewport||e.defaultViewport||{},i=r.viewportOptions?.viewportId;return{...r,viewportOptions:{...a.viewportOptions,...r.viewportOptions,viewportId:i||(0===n?"default":Ni())},displaySets:r.displaySets||[]}}),t.viewports.forEach(e=>{e.displaySets.forEach(e=>{e.options=e.options||{}})});else{t.name=t.name||t.id,t.viewports=[];let{rows:r,columns:n}=t.viewportStructure.properties;for(let a=0;a<r*n;a++){let r=t.defaultViewport||e.defaultViewport||{};t.viewports.push({viewportOptions:{...r.viewportOptions,viewportId:0===a?"default":Ni()},displaySets:[]})}}}),e}_getProtocolFromGenerator(e){let{protocol:t}=e({servicesManager:this._servicesManager,commandsManager:this._commandsManager});return{protocol:this._validateProtocol(t)}}getViewportsRequireUpdate(e,t,r=!0){let n,a=[{viewportId:e,displaySetInstanceUIDs:[t]}];if(!r)return a;let{displaySetService:i}=this._servicesManager.services,o=i.getDisplaySetByUID(t);if(o?.unsupported)throw Error("Unsupported displaySet");if(o?.isOverlayDisplaySet)return a;let s=this.protocol,l=s.stages[this.stageIndex].viewports;if(!l)return a;let u=l.find(t=>t.viewportOptions.viewportId===e);if(!u)return a;if(u.displaySets.length>1)throw Error("Cannot update viewport with multiple displaySets yet");if(0===u.displaySets.length||u.viewportOptions.allowUnmatchedView)return a;let{id:c,matchedDisplaySetsIndex:d=0}=u.displaySets[0],h=s.displaySetSelectors[c];if(!h||h.allowUnmatchedView||(this._validateViewportSpecificMatch({displaySetInstanceUIDs:[t],viewportOptions:{},displaySetOptions:[]},u,s.displaySetSelectors),!this.displaySetMatchDetails.get(c)))return a;let p=this._originalProtocol;p instanceof Function||(n=p.stages[this.stageIndex]);let f=[];return l.forEach((e,r)=>{if(e.displaySets.some(e=>e.id===c&&(e.matchedDisplaySetsIndex||0)===d)){if(n){let a=n.viewports[r],i=a.viewportOptions,o=a.displaySets;e.viewportOptions=this.getComputedOptions(i,[t]),e.displaySets=this.getComputedOptions(o,[t])}let a=[],i=[];this._updateDisplaySetInstanceUIDs(e,c,t,this.displaySetMatchDetails,a,i),f.push({viewportId:e.viewportOptions.viewportId,displaySetInstanceUIDs:a,viewportOptions:e.viewportOptions,displaySetOptions:i})}}),f}runMatchingRules(e,t,r){return this.protocolEngine.findMatch(e,t,r)}_updateDisplaySetInstanceUIDs(e,t,r,n,a,i){e.displaySets.forEach(e=>{let{id:o}=e,s=n.get(o),{displaySetInstanceUID:l}=s,u=e.id===t?r:l;s.displaySetInstanceUID=u,a.push(u),i.push(e)})}getComputedOptions(e,t){if(Array.isArray(e))return e.map(e=>this.getComputedOptions(e,t));if(null===e||"object"!=typeof e)return e;if(e.custom){let r=this.displaySets.filter(e=>t.includes(e.displaySetInstanceUID)),n=e.custom;if(!(n in this.customAttributeRetrievalCallbacks))throw Error(`Custom key "${n}" not found in customAttributeRetrievalCallbacks.`);let a=this.customAttributeRetrievalCallbacks[n].callback.call(e,r);return void 0===a&&(a=e.defaultValue),this.getComputedOptions(a,t)}let r={};for(let n in e)void 0!==e[n]&&(r[n]=this.getComputedOptions(e[n],t));return r}setProtocol(e,t={},r=null){let n=this.protocols.get(e);if(!n)return void console.warn(`ProtocolEngine::setProtocol - Protocol with id ${e} not found - you should register it first via addProtocol`);try{let e=this._validateProtocol(n);t&&this._validateOptions(t),this._setProtocol(e,t)}catch(e){throw console.log(e),r&&r(e),Error(e)}this._commandsManager.run(this.protocol?.callbacks?.onProtocolEnter)}matchActivation(e,t={},r){let{displaySetSelectors:n}=this.protocol,{displaySetSelectorsMatched:a=[]}=t;for(let e of a){let t=n[e];if(!t)return console.warn("No display set selector for",e),!1;let{bestMatch:r}=this._matchImages(t);if(!r)return!1}return e>=(t.minViewportsMatched??r)}_updateStageStatus(e=null){let t=this.protocol.stages;for(let r=0;r<t.length;r++){let n=t[r],{matchedViewports:a}=this._matchAllViewports(n,e,new Map),i=n.stageActivation||{};this.matchActivation(a,i.passive,0)?this.matchActivation(a,i.enabled,1)?n.status="enabled":n.status="passive":n.status="disabled"}this._broadcastEvent(this.EVENTS.STAGE_ACTIVATION,{protocol:this.protocol,stages:this.protocol.stages})}_findStageIndex(e=null){let t,r=e?.stageId,n=this.protocol.stages;if(r){for(let e=0;e<n.length;e++){let t=n[e];if(t.id===r&&"disabled"!==t.status)return e}return}let a=e?.stageIndex;if(void 0!==a)return n[a]?.status!=="disabled"?a:void 0;for(let e=0;e<n.length;e++){if("enabled"===n[e].status)return e;void 0===t&&"disabled"!==n[e].status&&(t=e)}return t}_setProtocol(e,t=null){let r=this.getActiveProtocol();try{if(!this.protocol||this.protocol.id!==e.id){this.stageIndex=t?.stageIndex||0,this.customImageLoadPerformed=!1,this._originalProtocol=this._copyProtocol(e),this.protocol?.callbacks?.onProtocolExit&&this._commandsManager.run(this.protocol.callbacks.onProtocolExit),this.protocol=e;let{imageLoadStrategy:r}=e;r?this.registeredImageLoadStrategies[r]instanceof Function&&(this.activeImageLoadStrategyName=r):this.activeImageLoadStrategyName=null,this._updateStageStatus(t)}let r=this._findStageIndex(t);if(void 0===r)throw Error(`Can't find applicable stage ${e.id} ${t?.stageIndex}`);this.stageIndex=r,this.protocol?.callbacks?.onStageChange&&this._commandsManager.run(this.protocol.callbacks.onStageChange),this._updateViewports(t)}catch(e){throw console.log(e),Object.assign(this,r),Error(e)}t?.restoreProtocol!==!0?this._broadcastEvent(Nq.EVENTS.PROTOCOL_CHANGED,{viewportMatchDetails:this.viewportMatchDetails,displaySetMatchDetails:this.displaySetMatchDetails,protocol:this.protocol,stageIdx:this.stageIndex,stage:this.protocol.stages[this.stageIndex],activeStudyUID:this.activeStudy?.StudyInstanceUID}):this._broadcastEvent(Nq.EVENTS.PROTOCOL_RESTORED,{protocol:this.protocol,stageIdx:this.stageIndex,stage:this.protocol.stages[this.stageIndex],activeStudyUID:this.activeStudy?.StudyInstanceUID})}getStageIndex(e,t){let r=this.getProtocolById(e),{stageId:n,stageIndex:a}=t;return void 0!==n?r.stages.findIndex(e=>e.id===n):void 0!==a?a:0}_getNumProtocolStages(){if(this.protocol&&this.protocol.stages&&this.protocol.stages.length)return this.protocol.stages.length}_getCurrentStageModel(){return this.protocol.stages[this.stageIndex]}getMissingViewport(e,t,r){this.protocol.id!==e&&(console.warn("setting protocol"),this.protocol=this.getProtocolById(e),this.stageIndex=0);let n=this.protocol,a=(n.stages[t]??n.stages[this.stageIndex]).defaultViewport||n.defaultViewport;if(!a)return;let i={...a};return this._matchViewport(i,r)}getDisplaySetSortFunction(){return(e,t)=>{let r=this._getSeriesSortInfoForDisplaySetSort(e),n=this._getSeriesSortInfoForDisplaySetSort(t);return L9(this._getSeriesFieldForDisplaySetSort())(r,n)}}_updateViewports(e=null){if(!this._getNumProtocolStages())throw Error("No protocol or stages found");this.viewportMatchDetails=new Map,this.displaySetMatchDetails=new Map;let t=this._getCurrentStageModel();if(!t||!t.viewportStructure||!t.viewports||!t.viewports.length)return void console.log("Stage cannot be applied",t);let{layoutType:r}=t.viewportStructure,n=t.viewportStructure.properties;if(!n)return void console.log("No viewportStructure.properties in",t);let{columns:a,rows:i,layoutOptions:o=[]}=n;this.protocol?.callbacks?.onViewportDataInitialized&&this._commandsManager.runCommand("attachProtocolViewportDataListener",{protocol:this.protocol,stageIndex:this.stageIndex}),this._broadcastEvent(this.EVENTS.NEW_LAYOUT,{layoutType:r,numRows:i,numCols:a,layoutOptions:o}),this._matchAllViewports(this.protocol.stages[this.stageIndex],e)}_matchAllViewports(e,t,r=this.viewportMatchDetails,n=this.displaySetMatchDetails){this.activeStudy||=this.studies[0];let a=0;return e.viewports.forEach(e=>{let i=e.viewportOptions.viewportId,o=this._matchViewport(e,t,r,n);o&&(o.displaySetsInfo?.length&&o.displaySetsInfo[0].displaySetInstanceUID?a++:(console.log("Adding an empty set of display sets for mapping purposes"),o.displaySetsInfo=e.displaySets.map(e=>({displaySetOptions:e}))),r.set(i,o))}),{matchedViewports:a,viewportMatchDetails:r,displaySetMatchDetails:n}}findDeduplicatedMatchDetails(e,t,r={}){if(!e)return;if(0===t)return e;let{matchingScores:n=[]}=e;if(-1===t){let{inDisplay:t}=r;if(!t)return e;for(let r=0;r<e.matchingScores.length;r++)if(-1===t.indexOf(e.matchingScores[r].displaySetInstanceUID))return e.matchingScores[r].matchingScore>0?{matchingScores:n,...e.matchingScores[r]}:null;return}let a=n[t];return a?{...a,matchingScores:n}:void 0}validateDisplaySetSelectMatch(e,t,r){if(e.displaySetInstanceUID!==r){if(!e.matchingScores)throw Error("No matchingScores found in "+e);for(let t of e.matchingScores)if(t.displaySetInstanceUID===r)return;throw Error(`Reused viewport details ${t} with ds ${r} not valid`)}}_matchViewport(e,t,r=this.viewportMatchDetails,n=this.displaySetMatchDetails){let a=t?.displaySetSelectorMap||{},{displaySetSelectors:i={}}=this.protocol;for(let t of e.displaySets){let{id:e}=t,r=i[e];if(!r){console.warn("No display set selector for",e);continue}let{bestMatch:a,matchingScores:o}=this._matchImages(r);n.set(e,a),a&&(a.matchingScores=o)}let{viewportOptions:o=NG}=e,s=[],{StudyInstanceUID:l}=this.activeStudy;return e.displaySets.forEach(e=>{let{id:r,matchedDisplaySetsIndex:n=0}=e,i=r&&a[`${l}:${r}:${n||0}`],o=this.displaySetMatchDetails.get(r),u=this.findDeduplicatedMatchDetails(o,n,t);if(i)return void i.forEach(t=>{s.push({displaySetInstanceUID:t,displaySetOptions:e})});if(u){let{displaySetInstanceUID:t}=u;s.push({displaySetInstanceUID:t,displaySetOptions:e})}else console.warn(`
|
|
7
7
|
The hanging protocol viewport is requesting to display ${r} displaySet that is not
|
|
8
8
|
matched based on the provided criteria (e.g. matching rules).
|
|
9
|
-
`)}),{viewportOptions:o,displaySetsInfo:s}}_validateViewportSpecificMatch(e,t,r){let{displaySetService:n}=this._servicesManager.services,a=t.displaySets,i=e.displaySetInstanceUIDs.length;if(a.length>0&&i!==a.length)throw Error(`The number of displaySets to set ${i} does not match the number of displaySets in the protocol ${a} - not currently implemented`);e.displaySetInstanceUIDs.forEach(e=>{let a=n.getDisplaySetByUID(e),{displaySets:i}=t;for(let e of i){let t=r[e.id];t&&this._validateRequiredSelectors(t,a)}})}areRequiredSelectorsValid(e,t){let r=!0;for(let n of e)try{this._validateRequiredSelectors(n,t)}catch(e){r=!1;break}return r}_validateRequiredSelectors(e,t){let{seriesMatchingRules:r}=e,n=r.filter(e=>e.required);if(n.length){let e=this.protocolEngine.findMatch(t,n);if(!e||0===e.score)throw Error(`The displaySetInstanceUID ${t.displaySetInstanceUID} does not satisfy the required seriesMatching criteria for the protocol`)}}_validateOptions(e){let{displaySetService:t}=this._servicesManager.services,{displaySetSelectorMap:r}=e;r&&Object.entries(r).forEach(([e,r])=>{r.forEach(e=>{if(!t.getDisplaySetByUID(e))throw Error(`The displaySetInstanceUID ${e} is not found in the displaySetService`)})})}_matchImages(e){let{id:t,studyMatchingRules:r=[],seriesMatchingRules:n}=e,a=[],i=0;console.log("ProtocolEngine::matchImages",r,n);let o=-1===this.protocol.numberOfPriorsReferenced;this.studies.forEach((e,t)=>{if(o&&this.activeStudy!==e)return;let s=this.displaySets.filter(t=>t.StudyInstanceUID===e.StudyInstanceUID&&!t?.unsupported),l=this.protocolEngine.findMatch(e,r,{studies:this.studies,displaySets:s,allDisplaySets:this.displaySets,displaySetMatchDetails:this.displaySetMatchDetails,studyInstanceUIDsIndex:t});!0!==l.requiredFailed&&(this.debug("study",e.StudyInstanceUID,"display sets #",s.length),s.forEach(t=>{let{StudyInstanceUID:r,SeriesInstanceUID:o,displaySetInstanceUID:u}=t,c=this.protocolEngine.findMatch(t,n,{studies:this.studies,instance:t.images?.[0],displaySetMatchDetails:this.displaySetMatchDetails,displaySets:s});if(!0===c.requiredFailed)return void this.debug("Display set required failed",t,n);this.debug("Found displaySet for rules",t),i=Math.max(c.score,i);let d={passed:[],failed:[]};d.passed=d.passed.concat(c.details.passed),d.passed=d.passed.concat(l.details.passed),d.failed=d.failed.concat(c.details.failed),d.failed=d.failed.concat(l.details.failed);let h=c.score+l.score,p={StudyInstanceUID:r,SeriesInstanceUID:o,displaySetInstanceUID:u,matchingScore:h,matchDetails:d,sortingInfo:{score:h,study:e.StudyInstanceUID,...this._getSeriesSortInfoForDisplaySetSort(t)}};this.debug("Adding display set",t,p),a.push(p)}))}),0===a.length&&console.log("No match found",t);let s=L9({name:"score",reverse:!0},{name:"study",reverse:!0},this._getSeriesFieldForDisplaySetSort());a.sort((e,t)=>s(e.sortingInfo,t.sortingInfo));let l=a[0];return console.log("ProtocolEngine::matchImages bestMatch",l,a),{bestMatch:l,matchingScores:a}}_getSeriesSortInfoForDisplaySetSort(e){return{[this._getSeriesFieldForDisplaySetSort().name]:null!=e.SeriesNumber?parseInt(e.SeriesNumber):parseInt(e.seriesNumber)}}_getSeriesFieldForDisplaySetSort(){return{name:"series"}}_isNextStageAvailable(){let e=this._getNumProtocolStages();return this.stageIndex+1<e}_isPreviousStageAvailable(){return this.stageIndex-1>=0}_setCurrentProtocolStage(e,t){let r;for(r=this.stageIndex+e;r>=0&&r<this.protocol.stages.length&&"disabled"===this.protocol.stages[r].status;r+=e);return!(r<0)&&!(r>=this.protocol.stages.length)&&(this.stageIndex=r,this.debug(`ProtocolEngine::setCurrentProtocolStage stage = ${this.stageIndex}`),this._updateViewports(t),this._broadcastEvent(this.EVENTS.PROTOCOL_CHANGED,{viewportMatchDetails:this.viewportMatchDetails,displaySetMatchDetails:this.displaySetMatchDetails,protocol:this.protocol,stageIdx:this.stageIndex,stage:this.protocol.stages[this.stageIndex]}),!0)}debug(...e){this.debugLogging&&console.log(...e)}_copyProtocol(e){return L6()(e)}}Nq.EVENTS={PROTOCOL_CHANGED:"event::hanging_protocol_changed",PROTOCOL_RESTORED:"event::hanging_protocol_restore",NEW_LAYOUT:"event::hanging_protocol_new_layout",STAGE_ACTIVATION:"event::hanging_protocol_stage_activation",CUSTOM_IMAGE_LOAD_PERFORMED:"event::hanging_protocol_custom_image_load_performed"},Nq.REGISTRATION={name:"hangingProtocolService",altName:"HangingProtocolService",create:({configuration:e={},commandsManager:t,servicesManager:r})=>new Nq(t,r)};class N$ extends Lx{constructor(){super(N$.EVENTS),this.serviceImplementation={_getState:()=>console.warn("getState() NOT IMPLEMENTED"),_setUser:()=>console.warn("_setUser() NOT IMPLEMENTED"),_getUser:()=>console.warn("_getUser() NOT IMPLEMENTED"),_getAuthorizationHeader:()=>{},_handleUnauthenticated:()=>console.warn("_handleUnauthenticated() NOT IMPLEMENTED"),_reset:()=>console.warn("reset() NOT IMPLEMENTED"),_set:()=>console.warn("set() NOT IMPLEMENTED")},this.serviceImplementation={...this.serviceImplementation}}getState(){return this.serviceImplementation._getState()}setUser(e){return this.serviceImplementation._setUser(e)}getUser(){return this.serviceImplementation._getUser()}getAuthorizationHeader(){return this.serviceImplementation._getAuthorizationHeader()}handleUnauthenticated(){return this.serviceImplementation._handleUnauthenticated()}reset(){return this.serviceImplementation._reset()}set(e){return this.serviceImplementation._set(e)}setServiceImplementation({getState:e,setUser:t,getUser:r,getAuthorizationHeader:n,handleUnauthenticated:a,reset:i,set:o}){e&&(this.serviceImplementation._getState=e),t&&(this.serviceImplementation._setUser=t),r&&(this.serviceImplementation._getUser=r),n&&(this.serviceImplementation._getAuthorizationHeader=n),a&&(this.serviceImplementation._handleUnauthenticated=a),i&&(this.serviceImplementation._reset=i),o&&(this.serviceImplementation._set=o)}}N$.EVENTS={},N$.REGISTRATION={name:"userAuthenticationService",altName:"UserAuthenticationService",create:({configuration:e={}})=>new N$};var NK=u(1752),NY=u.n(NK),NX=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,NZ=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,NJ=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,NQ=e=>"string"==typeof e&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||"$"===e||"_"===e||NZ.test(e)),N1=e=>"string"==typeof e&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||"$"===e||"_"===e||""===e||""===e||NJ.test(e)),N0=e=>"string"==typeof e&&/[0-9]/.test(e),N2=e=>"string"==typeof e&&/[0-9A-Fa-f]/.test(e);function N5(){if(a[s])return String.fromCodePoint(a.codePointAt(s))}function N3(){let e=N5();return"\n"===e?(l++,d=0):e?d+=e.length:d++,e&&(s+=e.length),e}let N4={default(){let e;switch(b){case" ":case"\v":case"\f":case" ":case"\xa0":case"\uFEFF":case"\n":case"\r":case"\u2028":case"\u2029":N3();return;case"/":N3(),m="comment";return;case void 0:return N3(),N8("eof")}return"string"==typeof(e=b)&&NX.test(e)?void N3():N4[i]()},comment(){switch(b){case"*":N3(),m="multiLineComment";return;case"/":N3(),m="singleLineComment";return}throw Fr(N3())},multiLineComment(){switch(b){case"*":N3(),m="multiLineCommentAsterisk";return;case void 0:throw Fr(N3())}N3()},multiLineCommentAsterisk(){switch(b){case"*":N3();return;case"/":N3(),m="default";return;case void 0:throw Fr(N3())}N3(),m="multiLineComment"},singleLineComment(){switch(b){case"\n":case"\r":case"\u2028":case"\u2029":N3(),m="default";return;case void 0:return N3(),N8("eof")}N3()},value(){switch(b){case"{":case"[":return N8("punctuator",N3());case"n":return N3(),N6("ull"),N8("null",null);case"t":return N3(),N6("rue"),N8("boolean",!0);case"f":return N3(),N6("alse"),N8("boolean",!1);case"-":case"+":"-"===N3()&&(v=-1),m="sign";return;case".":g=N3(),m="decimalPointLeading";return;case"0":g=N3(),m="zero";return;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":g=N3(),m="decimalInteger";return;case"I":return N3(),N6("nfinity"),N8("numeric",1/0);case"N":return N3(),N6("aN"),N8("numeric",NaN);case'"':case"'":y='"'===N3(),g="",m="string";return}throw Fr(N3())},identifierNameStartEscape(){if("u"!==b)throw Fr(N3());N3();let e=N9();switch(e){case"$":case"_":break;default:if(!NQ(e))throw Fa()}g+=e,m="identifierName"},identifierName(){switch(b){case"$":case"_":case"":case"":g+=N3();return;case"\\":N3(),m="identifierNameEscape";return}if(N1(b)){g+=N3();return}return N8("identifier",g)},identifierNameEscape(){if("u"!==b)throw Fr(N3());N3();let e=N9();switch(e){case"$":case"_":case"":case"":break;default:if(!N1(e))throw Fa()}g+=e,m="identifierName"},sign(){switch(b){case".":g=N3(),m="decimalPointLeading";return;case"0":g=N3(),m="zero";return;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":g=N3(),m="decimalInteger";return;case"I":return N3(),N6("nfinity"),N8("numeric",1/0*v);case"N":return N3(),N6("aN"),N8("numeric",NaN)}throw Fr(N3())},zero(){switch(b){case".":g+=N3(),m="decimalPoint";return;case"e":case"E":g+=N3(),m="decimalExponent";return;case"x":case"X":g+=N3(),m="hexadecimal";return}return N8("numeric",0*v)},decimalInteger(){switch(b){case".":g+=N3(),m="decimalPoint";return;case"e":case"E":g+=N3(),m="decimalExponent";return}if(N0(b)){g+=N3();return}return N8("numeric",v*Number(g))},decimalPointLeading(){if(N0(b)){g+=N3(),m="decimalFraction";return}throw Fr(N3())},decimalPoint(){switch(b){case"e":case"E":g+=N3(),m="decimalExponent";return}if(N0(b)){g+=N3(),m="decimalFraction";return}return N8("numeric",v*Number(g))},decimalFraction(){switch(b){case"e":case"E":g+=N3(),m="decimalExponent";return}if(N0(b)){g+=N3();return}return N8("numeric",v*Number(g))},decimalExponent(){switch(b){case"+":case"-":g+=N3(),m="decimalExponentSign";return}if(N0(b)){g+=N3(),m="decimalExponentInteger";return}throw Fr(N3())},decimalExponentSign(){if(N0(b)){g+=N3(),m="decimalExponentInteger";return}throw Fr(N3())},decimalExponentInteger(){if(N0(b)){g+=N3();return}return N8("numeric",v*Number(g))},hexadecimal(){if(N2(b)){g+=N3(),m="hexadecimalInteger";return}throw Fr(N3())},hexadecimalInteger(){if(N2(b)){g+=N3();return}return N8("numeric",v*Number(g))},string(){switch(b){case"\\":N3(),g+=function(){switch(N5()){case"b":return N3(),"\b";case"f":return N3(),"\f";case"n":return N3(),"\n";case"r":return N3(),"\r";case"t":return N3()," ";case"v":return N3(),"\v";case"0":if(N3(),N0(N5()))throw Fr(N3());return"\0";case"x":return N3(),function(){let e="",t=N5();if(!N2(t)||(e+=N3(),!N2(t=N5())))throw Fr(N3());return String.fromCodePoint(parseInt(e+=N3(),16))}();case"u":return N3(),N9();case"\n":case"\u2028":case"\u2029":return N3(),"";case"\r":return N3(),"\n"===N5()&&N3(),"";case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case void 0:throw Fr(N3())}return N3()}();return;case'"':if(y)return N3(),N8("string",g);g+=N3();return;case"'":if(!y)return N3(),N8("string",g);g+=N3();return;case"\n":case"\r":case void 0:throw Fr(N3());case"\u2028":case"\u2029":var e;e=b,console.warn(`JSON5: '${Fi(e)}' in strings is not valid ECMAScript; consider escaping`)}g+=N3()},start(){switch(b){case"{":case"[":return N8("punctuator",N3())}m="value"},beforePropertyName(){switch(b){case"$":case"_":g=N3(),m="identifierName";return;case"\\":N3(),m="identifierNameStartEscape";return;case"}":return N8("punctuator",N3());case'"':case"'":y='"'===N3(),m="string";return}if(NQ(b)){g+=N3(),m="identifierName";return}throw Fr(N3())},afterPropertyName(){if(":"===b)return N8("punctuator",N3());throw Fr(N3())},beforePropertyValue(){m="value"},afterPropertyValue(){switch(b){case",":case"}":return N8("punctuator",N3())}throw Fr(N3())},beforeArrayValue(){if("]"===b)return N8("punctuator",N3());m="value"},afterArrayValue(){switch(b){case",":case"]":return N8("punctuator",N3())}throw Fr(N3())},end(){throw Fr(N3())}};function N8(e,t){return{type:e,value:t,line:l,column:d}}function N6(e){for(let t of e){if(N5()!==t)throw Fr(N3());N3()}}function N9(){let e="",t=4;for(;t-- >0;){if(!N2(N5()))throw Fr(N3());e+=N3()}return String.fromCodePoint(parseInt(e,16))}let N7={start(){if("eof"===h.type)throw Fn();Fe()},beforePropertyName(){switch(h.type){case"identifier":case"string":p=h.value,i="afterPropertyName";return;case"punctuator":Ft();return;case"eof":throw Fn()}},afterPropertyName(){if("eof"===h.type)throw Fn();i="beforePropertyValue"},beforePropertyValue(){if("eof"===h.type)throw Fn();Fe()},beforeArrayValue(){if("eof"===h.type)throw Fn();"punctuator"===h.type&&"]"===h.value?Ft():Fe()},afterPropertyValue(){if("eof"===h.type)throw Fn();switch(h.value){case",":i="beforePropertyName";return;case"}":Ft()}},afterArrayValue(){if("eof"===h.type)throw Fn();switch(h.value){case",":i="beforeArrayValue";return;case"]":Ft()}},end(){}};function Fe(){let e;switch(h.type){case"punctuator":switch(h.value){case"{":e={};break;case"[":e=[]}break;case"null":case"boolean":case"numeric":case"string":e=h.value}if(void 0===f)f=e;else{let t=o[o.length-1];Array.isArray(t)?t.push(e):Object.defineProperty(t,p,{value:e,writable:!0,enumerable:!0,configurable:!0})}if(null!==e&&"object"==typeof e)o.push(e),i=Array.isArray(e)?"beforeArrayValue":"beforePropertyName";else{let e=o[o.length-1];i=null==e?"end":Array.isArray(e)?"afterArrayValue":"afterPropertyValue"}}function Ft(){o.pop();let e=o[o.length-1];i=null==e?"end":Array.isArray(e)?"afterArrayValue":"afterPropertyValue"}function Fr(e){return void 0===e?Fo(`JSON5: invalid end of input at ${l}:${d}`):Fo(`JSON5: invalid character '${Fi(e)}' at ${l}:${d}`)}function Fn(){return Fo(`JSON5: invalid end of input at ${l}:${d}`)}function Fa(){return d-=5,Fo(`JSON5: invalid identifier character at ${l}:${d}`)}function Fi(e){let t={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(t[e])return t[e];if(e<" "){let t=e.charCodeAt(0).toString(16);return"\\x"+("00"+t).substring(t.length)}return e}function Fo(e){let t=SyntaxError(e);return t.lineNumber=l,t.columnNumber=d,t}let Fs=function(e,t){a=String(e),i="start",o=[],s=0,l=1,d=0,h=void 0,p=void 0,f=void 0;do h=function(){for(m="default",g="",y=!1,v=1;;){b=N5();let e=N4[m]();if(e)return e}}(),N7[i]();while("eof"!==h.type);return"function"==typeof t?function e(t,r,n){let a=t[r];if(null!=a&&"object"==typeof a)if(Array.isArray(a))for(let t=0;t<a.length;t++){let r=String(t),i=e(a,r,n);void 0===i?delete a[r]:Object.defineProperty(a,r,{value:i,writable:!0,enumerable:!0,configurable:!0})}else for(let t in a){let r=e(a,t,n);void 0===r?delete a[t]:Object.defineProperty(a,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}return n.call(t,r,a)}({"":f},"",t):f},Fl="default",Fu={prefixes:{}};function Fc(e){if(!e||"object"!=typeof e)return null;let t=Fd(e.bootstrap),r=Fd(e.global),n=e.mode&&"object"==typeof e.mode&&!Array.isArray(e.mode),a="string"==typeof e.requires||Array.isArray(e.requires)&&e.requires.length>0;return t||r||n||a?{...t?{bootstrap:e.bootstrap}:{},...r?{global:e.global}:{},...n?{mode:e.mode}:{},...a?{requires:e.requires}:{}}:null}function Fd(e){return Array.isArray(e)?e.length>0:!!e&&"object"==typeof e}let Fh=/^([a-z][a-z0-9+.-]*:|\/\/)/i;function Fp(e,t="customization"){let r=[];for(let n of Array.from(new Set(e.keys())))if(n.toLowerCase()===t.toLowerCase()){for(let t of e.getAll(n))if(t)for(let e of t.split(",")){let t=e.trim();t&&r.push(t)}}return r}function Ff(e,t){let r={valid:[],rejected:[]},n=t.prefixes||{};for(let t of e){let e=function(e){let t=e;for(let e=0;e<5;e++){let e;if(!t.includes("%"))return t;try{e=decodeURIComponent(t)}catch{break}if(e===t)break;t=e}return null}(t);if(null===e){r.rejected.push({raw:t,reason:"contains malformed or unsupported percent-encoding"});continue}if(e.includes("..")){r.rejected.push({raw:t,reason:'contains ".." traversal segment'});continue}if(Fh.test(e)){r.rejected.push({raw:t,reason:"full URLs are not permitted"});continue}let a=function(e){if(!e)return null;if(!e.startsWith("/"))return{prefix:Fl,name:e};let t=e.slice(1),r=t.indexOf("/");if(r<=0)return null;let n=t.slice(0,r),a=t.slice(r+1);return n&&a?{prefix:`/${n}/`,name:a}:null}(e.trim());if(!a){r.rejected.push({raw:t,reason:"could not be split into a prefix and name"});continue}let{prefix:i,name:o}=a;if(!Object.prototype.hasOwnProperty.call(n,i)){r.rejected.push({raw:t,reason:`unknown prefix "${i}"`});continue}if(!o.trim()||o.split("/").some(e=>!e||"."===e||".."===e||e.includes(".."))){r.rejected.push({raw:t,reason:"invalid or unsafe customization name"});continue}r.valid.push({raw:t,normalized:i===Fl?`/${Fl}/${o}`:`${i}${o}`,prefix:i,name:o})}return r}let Fm=/^([a-z][a-z0-9+.-]*:|\/\/)/i,Fg="https://ohif.invalid";function Fy(e,t,r){let n,a;try{n=new URL(e,Fg),a=new URL(t,Fg)}catch{throw Error(`Customization URL could not be parsed for "${r.raw}"`)}let i=a.pathname.endsWith("/")?a.pathname:`${a.pathname}/`;if(!(n.origin===a.origin&&n.pathname.startsWith(i)))throw Error(`Customization "${r.raw}" escapes its configured prefix directory`)}let Fv={MODE_CUSTOMIZATION_MODIFIED:"event::CustomizationService:modeModified",GLOBAL_CUSTOMIZATION_MODIFIED:"event::CustomizationService:globalModified",DEFAULT_CUSTOMIZATION_MODIFIED:"event::CustomizationService:defaultModified"},Fb=((ege={}).Global="global",ege.Mode="mode",ege.Default="default",ege);class Fw extends Lx{constructor({configuration:e,commandsManager:t}){super(Fv),this.Scope=Fb,this.commandsManager=void 0,this.extensionManager=void 0,this.globalCustomizations=new Map,this.modeCustomizations=new Map,this.defaultCustomizations=new Map,this.transformedCustomizations=new Map,this.configuration=void 0,this._urlCustomizationLoaded=new Map,this._urlCustomizationPending=new Map,this._resolvedUrlModules=[],this._customizationConfig=null,this._currentModeIds=[],this._extensionCustomizationModuleApplied=new Set,this.configuration=e,this.commandsManager=t}init(e){this.extensionManager=e,this.modeCustomizations.clear(),this.extensionManager.getRegisteredExtensionIds().forEach(e=>{let t=`${e}.customizationModule.default`;if(!this._extensionCustomizationModuleApplied.has(t)){let e=this._findExtensionValue(t);if(e){let{value:r}=e;this._addReference(r,Fb.Default),this._extensionCustomizationModuleApplied.add(t)}}let r=`${e}.customizationModule.global`;if(!this._extensionCustomizationModuleApplied.has(r)){let e=this._findExtensionValue(r);if(e){let{value:t}=e;this._addReference(t,Fb.Global),this._extensionCustomizationModuleApplied.add(r)}}});let t=this._getCustomizationConfig();void 0===t.legacyReferences||this.configuration?._hasBeenAdded||(this.addReferences(t.legacyReferences),Object.defineProperty(this.configuration,"_hasBeenAdded",{value:!0,writable:!1}))}_getCustomizationConfig(){return this._customizationConfig||(this._customizationConfig=function(e){if(!e)return{};if(Array.isArray(e))return{legacyReferences:e};if("object"==typeof e){if(Fx.some(t=>t in e)){let t={};for(let r of Fx)r in e&&(t[r]=e[r]);return{phased:t}}return{legacyReferences:e}}return{}}(this.configuration)),this._customizationConfig}async applyWindowUrlCustomizations(e){"u">typeof window&&await this.applyCustomizationUrlSearchParams(new URLSearchParams(window.location.search),e)}async applyCustomizationUrlSearchParams(e,t){let r=Fp(e);r.length&&await this.requires(r,t)}requires(e,t){return this.loadCustomizationModules(e,t).then(e=>(this._applyLoadedUrlCustomizationModules(e),e))}loadCustomizationModules(e,t){let r,n=t?.policy??((r=this?.extensionManager?.appConfig?.customizationUrlPrefixes)&&"object"==typeof r?{prefixes:r}:Fu),a=(Array.isArray(e)?e:[e]).map(e=>String(e).trim()).filter(Boolean);if(!a.length)return Promise.resolve([]);let{valid:i,rejected:o}=Ff(a,n),s=t?.logger||console;if(o.length){let e=o.map(e=>`"${e.raw}" (${e.reason})`).join("; ");return Promise.reject(Error(`[customizationUrl] refusing to load customization(s): ${e}. Allowed prefixes are configured in appConfig.customizationUrlPrefixes.`))}if(!i.length)return Promise.resolve([]);let l=t?.importFn??this._urlDefaultImport.bind(this),u=new Set,c=[];return i.reduce((e,t)=>e.then(()=>this._urlCustomizationLoadOne(t,n,l,s,u,c)),Promise.resolve()).then(()=>(this._resolvedUrlModules.push(...c),c))}async loadAndApplyBootstrapCustomizations(e,t){this.extensionManager=e;let r=this._getCustomizationConfig(),n=[],a=r.phased?.requires;"string"==typeof a&&a?n.push(a):Array.isArray(a)&&n.push(...a.filter(e=>"string"==typeof e&&e)),"u">typeof window&&n.push(...Fp(new URLSearchParams(window.location.search))),n.length&&await this.loadCustomizationModules(n,t),this.applyBootstrapCustomizations()}applyBootstrapCustomizations(){this._applyPhase("bootstrap")}applyGlobalCustomizations(){this._applyPhase("global")}applyModeCustomizations(e){let t=(Array.isArray(e)?e:[e]).filter(Boolean);this._currentModeIds=t;let r=this._collectPhaseBlocks("mode");for(let e of r){let t=e.mode?.["*"];t&&this.setCustomizations(t,Fb.Mode)}for(let e of r)for(let r of t){let t=e.mode?.[r];t&&this.setCustomizations(t,Fb.Mode)}}onModeEnter(){this.clearTransformedCustomizations(),this.init(this.extensionManager)}onModeExit(){this.clearTransformedCustomizations()}getCustomization(e){let t=this.transformedCustomizations.get(e);if(t)return t;let r=this.globalCustomizations.get(e)??this.modeCustomizations.get(e)??this.defaultCustomizations.get(e),n=this.transform(r);return void 0!==n&&this.transformedCustomizations.set(e,n),n}getValue(e,t){let r=this.getCustomization(e);return void 0===r?t:r}setCustomizations(e,t=Fb.Mode){Array.isArray(e)?e.forEach(e=>{this._addReference(e,t)}):Object.entries(e).forEach(([e,r])=>{this._setCustomization(e,r,t)})}setCustomization(e,t,r=Fb.Mode){console.warn("setCustomization is deprecated. Please use setCustomizations with an object instead."),this._setCustomization(e,t,r)}getCustomizations(e){return e===Fb.Global?this.globalCustomizations:e===Fb.Mode?this.modeCustomizations:this.defaultCustomizations}hasCustomization(e){return this.globalCustomizations.has(e)||this.modeCustomizations.has(e)}transform(e){if(!e)return e;let{inheritsFrom:t}=e;if(!t)return e;let r=this.getCustomization(t),n=r?Object.assign({},r,e):e;return n.$transform?.(this)||n}registerCustomUpdateCommand(e,t){e.startsWith("$")||(e="$"+e),(0,NK.extend)(e,t)}_addReference(e,t=Fb.Global){e&&("string"==typeof e&&(e=this._findExtensionValue(e).value),Object.entries(e).forEach(([e,r])=>{this[t===Fb.Global&&"setGlobalCustomization"||t===Fb.Default&&"setDefaultCustomization"||"setModeCustomization"](e,r)}))}addReferences(e,t=Fb.Global){e&&(Array.isArray(e)?e.forEach(e=>{this._addReference(e,t)}):this._addReference(e,t))}clearTransformedCustomizations(){for(let e of(super.reset(),Array.from(this.modeCustomizations.keys())))this.transformedCustomizations.delete(e);this.modeCustomizations.clear()}async _urlDefaultImport(e){if("function"!=typeof fetch)throw Error(`No fetch implementation available to load customization ${e}`);let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch customization ${e}: ${t.status} ${t.statusText}`);return Fs(await t.text())}_normalizeImportedCustomizationModule(e){return e&&"object"==typeof e&&"customizations"in e?e:e&&"object"==typeof e.default?e.default:e}_collectUrlDependencyRefs(e){let t=new Set,r=Fc(e);if(!r||"object"!=typeof r)return Array.from(t);let n=r.requires;if("string"==typeof n&&n)t.add(n);else if(Array.isArray(n))for(let e of n)"string"==typeof e&&e&&t.add(e);return Array.from(t)}_urlDependencyToRequest(e,t){let r=Ff([e],t);return r.valid.length?r.valid[0]:null}_urlCustomizationLoadOne(e,t,r,n,a,i){let o=e.normalized;if(this._urlCustomizationLoaded.has(o))return Promise.resolve(this._urlCustomizationLoaded.get(o)||null);if(this._urlCustomizationPending.has(o))return this._urlCustomizationPending.get(o);a.add(o);let s=this._urlCustomizationLoadOneBody(e,t,r,n,a,i);return this._urlCustomizationPending.set(o,s),s.then(()=>this._urlCustomizationPending.delete(o),()=>this._urlCustomizationPending.delete(o)),s}_urlCustomizationLoadOneBody(e,t,r,n,a,i){let o,s=e.normalized,l=Symbol("importFailed");try{o=function(e,t){let r=(t.prefixes||{})[e.prefix];if(!r)throw Error(`Unknown customization prefix: ${e.prefix}`);if(e.name.includes(".."))throw Error(`Customization name contains traversal: ${e.name}`);let n=e.name.endsWith(".jsonc")?e.name:`${e.name}.jsonc`,a=r.endsWith("/")?r:`${r}/`,i=`${a}${n}`;if(Fm.test(r))return Fy(i,a,e),i;let o="u">typeof window&&window.location?.origin?window.location.origin:"",s="u"<typeof window?"/":window.PUBLIC_URL||"/",l=s?.startsWith("/")?s:`/${s||""}`,u=e=>e.startsWith("./")?e.slice(2):e.startsWith("/")?e.slice(1):e,c=u(i),d=u(a),h=l.endsWith("/")?l:`${l}/`,p=`${h}${c}`,f=`${h}${d}`,m=o?`${o}${p}`:p;return Fy(m,o?`${o}${f}`:f,e),m}(e,t)}catch(r){let t=`[customizationUrl] failed to resolve "${e.raw}": ${r.message}`;return n.warn(t),Promise.resolve(null)}return r(o).catch(t=>(n.warn(`[customizationUrl] failed to import customization "${e.raw}" (${o})`,t),l)).then(u=>{if(u===l)return null;let c=this._normalizeImportedCustomizationModule(u);if(!c||"object"!=typeof c){let t=`[customizationUrl] missing customization module "${e.raw}" (${o}): module is not an object`;return n.warn(t),null}if(!Fc(c)){let t=`[customizationUrl] missing customization module "${e.raw}" (${o}): no customizations payload`;return n.warn(t),null}let d=this._collectUrlDependencyRefs(c),h=Promise.resolve();for(let e of d)h=h.then(()=>{let o=this._urlDependencyToRequest(e,t);if(!(!o||a.has(o.normalized)))return this._urlCustomizationLoadOne(o,t,r,n,a,i)});return h.then(()=>{let t={request:e,module:c,url:o};return this._urlCustomizationLoaded.set(s,t),i.push(t),t})})}_applyLoadedUrlCustomizationModules(e){if(e?.length)for(let t of e){let e=Fc(t.module);e?.global&&this.setCustomizations(e.global,Fb.Global)}}_collectPhaseBlocks(e){let t=[],r=this._getCustomizationConfig().phased;for(let n of(r&&void 0!==r[e]&&t.push(r),this._resolvedUrlModules)){let r=Fc(n.module);r&&void 0!==r[e]&&t.push(r)}return t}_applyPhase(e){for(let t of this._collectPhaseBlocks(e)){let r=t[e];r&&this.setCustomizations(r,Fb.Global)}}_setCustomization(e,t,r=Fb.Mode){switch(r){case Fb.Global:this.setGlobalCustomization(e,t);break;case Fb.Mode:this.setModeCustomization(e,t);break;case Fb.Default:this.setDefaultCustomization(e,t);break;default:throw Error(`Invalid customization scope: ${r}`)}}setModeCustomization(e,t){let r=this.defaultCustomizations.get(e),n=this.modeCustomizations.get(e),a=this.globalCustomizations.get(e),i=n||this._cloneIfNeeded(a)||r,o=this._update(i,t);this.modeCustomizations.set(e,o),this.transformedCustomizations.clear(),this._broadcastEvent(this.EVENTS.MODE_CUSTOMIZATION_MODIFIED,{buttons:this.modeCustomizations,button:this.modeCustomizations.get(e)})}setGlobalCustomization(e,t){let r=this.defaultCustomizations.get(e),n=this.globalCustomizations.get(e),a=this._cloneIfNeeded(n)||r;this.globalCustomizations.set(e,this._update(a,t)),this.transformedCustomizations.clear(),this._broadcastEvent(this.EVENTS.GLOBAL_CUSTOMIZATION_MODIFIED,{buttons:this.globalCustomizations,button:this.globalCustomizations.get(e)})}setDefaultCustomization(e,t){this.transformedCustomizations.clear();let r=this.defaultCustomizations.get(e);this.defaultCustomizations.set(e,this._update(r,t)),this._broadcastEvent(this.EVENTS.DEFAULT_CUSTOMIZATION_MODIFIED,{buttons:this.defaultCustomizations,button:this.defaultCustomizations.get(e)})}_findExtensionValue(e){return this.extensionManager.getModuleEntry(e)}_update(e,t){return(e||(e=void 0),!function e(t){if(Array.isArray(t)){for(let r of t)if(e(r))return!0}else if(t&&"object"==typeof t){if(t.$$typeof)return!1;for(let r of Object.keys(t))if(r.startsWith("$")&&"$transform"!==r||e(t[r]))return!0}return!1}(t))?t:NY()(e,t)}_cloneIfNeeded(e){return e&&"object"==typeof e?Array.isArray(e)?[...e]:{...e}:e}}Fw.EVENTS=Fv,Fw.REGISTRATION={name:"customizationService",create:({configuration:e,commandsManager:t})=>new Fw({configuration:e,commandsManager:t})},(0,NK.extend)("$filter",(e,t)=>(function e(t,r){if(Array.isArray(t))return"function"==typeof r?t.filter(r):"string"==typeof r?t.filter(e=>e.id!==r):"object"==typeof r&&r.match&&r.$merge?t.map(t=>e(t,r)).map(e=>{var t;return(t=r.match,e&&"object"==typeof e&&Object.entries(t).every(([t,r])=>e[t]===r))?{...e,...r.$merge}:e}):"object"==typeof r&&r.id&&r.$merge?t.map(t=>e(t,r)).map(e=>e.id===r.id?{...e,...r.$merge}:e):t.map(t=>e(t,r));if(t&&"object"==typeof t){let n={...t};for(let[t,a]of Object.entries(n))n[t]=e(a,r);return n}return t})(t,e));let Fx=["requires","bootstrap","global","mode"];function FC(){return(FC=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(null,arguments)}let Fk={PANELS_CHANGED:"event::panelService:panelsChanged",ACTIVATE_PANEL:"event::panelService:activatePanel"},FM=((egt={}).Left="left",egt.Right="right",egt.Bottom="bottom",egt);class FE extends Lx{constructor(e){super(Fk),this._extensionManager=void 0,this._panelsGroups=new Map,this._extensionManager=e}get PanelPosition(){return FM}_getPanelComponent(e){let t=this._extensionManager.getModuleEntry(e);if(!t){let t=this._getSimilarPanels(e);if(t.length>0){let r=`Did you mean: ${t.join(", ")}?`;throw Error(`${e} is not a valid entry for an extension module. ${r} Please check your configuration or make sure the extension is registered.`)}throw Error(`${e} is not a valid entry for an extension module, please check your configuration or make sure the extension is registered.`)}if(!t?.component)throw Error(`No component found from extension ${e}. Check the reference string to the extension in your Mode configuration`);let r=t.component;return{entry:t,content:r}}_getSimilarPanels(e,t=.8){return Object.keys(this._extensionManager.modulesMap).filter(e=>e.includes("panelModule")).filter(r=>this._calculateSimilarity(e,r)>=t)}_calculateSimilarity(e,t){let r=new Set(e.toLowerCase().split("")),n=new Set(t.toLowerCase().split("")),a=new Set([...r].filter(e=>n.has(e))),i=new Set([...r,...n]);return a.size/i.size}getPanelData(e){let t,r;if(Array.isArray(e)){let n=e.map(e=>this._getPanelComponent(e));r=n[0].entry,t=e=>ey().createElement(ey().Fragment,null,n.map(({content:t},r)=>ey().createElement(t,FC({key:r},e))))}else({content:t,entry:r}=this._getPanelComponent(e));return{id:r.id,iconName:r.iconName,iconLabel:r.iconLabel,label:r.label,name:r.name,content:t}}addPanel(e,t,r){let n=this._panelsGroups.get(e);n||(n=[],this._panelsGroups.set(e,n));let a=this.getPanelData(t);n.push(a),this._broadcastEvent(Fk.PANELS_CHANGED,{position:e,options:r})}addPanels(e,t,r){if(!Array.isArray(t))throw Error('Invalid "panelsIds" array');t.forEach(t=>this.addPanel(e,t,r))}setPanels(e,t){this.reset(),Object.keys(e).forEach(r=>{this.addPanels(r,e[r],t)})}getPanels(e){return[...this._panelsGroups.get(e)??[]]}reset(){let e=Array.from(this._panelsGroups.keys());this._panelsGroups.clear(),e.forEach(e=>this._broadcastEvent(Fk.PANELS_CHANGED,{position:e}))}onModeExit(){this.reset()}activatePanel(e,t=!1){this._broadcastEvent(Fk.ACTIVATE_PANEL,{panelId:e,forceActive:t})}addActivatePanelTriggers(e,t,r=!1){return t.map(t=>t.sourceEvents.map(n=>t.sourcePubSubService.subscribe(n,()=>this.activatePanel(e,r)))).flat()}}FE.REGISTRATION={name:"panelService",create:({extensionManager:e})=>new FE(e)};let FS={ACTIVE_STEP_CHANGED:"event::workflowStepsService:activateStepChanged",STEPS_CHANGED:"event::workflowStepsService:stepsChanged"};class FD extends Lx{constructor(e,t,r){super(FS),this._extensionManager=void 0,this._servicesManager=void 0,this._commandsManager=void 0,this._workflowSteps=void 0,this._activeWorkflowStep=void 0,this._workflowSteps=[],this._activeWorkflowStep=null,this._extensionManager=e,this._commandsManager=t,this._servicesManager=r}get workflowSteps(){return[...this._workflowSteps]}get activeWorkflowStep(){return this._activeWorkflowStep}addWorkflowSteps(e){let t=!1;e.forEach(e=>{if(this._workflowSteps.some(t=>t.id===e.id))throw Error(`Duplicated workflow step id (${e.id})`);this._workflowSteps.push(e),t=!0}),t&&this._broadcastEvent(FS.STEPS_CHANGED,{})}_updateToolBar(e){let{toolbarService:t}=this._servicesManager.services,{toolbarButtons:r}=e;(Array.isArray(r)?r:[r]).forEach(({buttonSection:e,buttons:r})=>{t.clearButtonSection(e),t.updateSection(e,r)})}_updatePanels(e){let{panelService:t}=this._servicesManager.services,r=e?.layout?.panels;r&&t.setPanels(r,e?.layout?.options)}_updateHangingProtocol(e){let{hangingProtocol:t}=e;t&&this._commandsManager.runCommand("setHangingProtocol",{protocolId:t.protocolId,stageId:t.stageId,stageIndex:t.stageIndex})}_invokeCallbacks(e){if(!e)return;let t=this._commandsManager;Array.isArray(e)||(e=[e]),e.forEach(e=>{let r=e;if(e?.commandName){let{commandName:n,options:a}=e;r=()=>t.runCommand(n,a)}r()})}setActiveWorkflowStep(e){let t=this._activeWorkflowStep;if(e===t?.id)return;let r=this._workflowSteps.find(t=>t.id===e);if(!r)throw Error(`Invalid workflowStepId (${e})`);this._activeWorkflowStep&&this._invokeCallbacks(t.onExit),this._invokeCallbacks(r.onEnter),this._activeWorkflowStep=r,this._updateToolBar(r),this._updatePanels(r),this._updateHangingProtocol(r),this._broadcastEvent(FS.ACTIVE_STEP_CHANGED,{activeWorkflowStep:r})}reset(){this._activeWorkflowStep=null,this._workflowSteps=[]}onModeEnter(){this.reset()}}FD.REGISTRATION={name:"workflowStepsService",create:({extensionManager:e,commandsManager:t,servicesManager:r})=>new FD(e,t,r)};var FI=((egr=FI||{}).Interaction="interaction",egr.Thumbnail="thumbnail",egr.Prefetch="prefetch",egr.Compute="compute",egr);let FP={SERVICE_STARTED:"event::studyPrefetcherService:started",SERVICE_STOPPED:"event::studyPrefetcherService:stopped",DISPLAYSET_LOAD_PROGRESS:"event::studyPrefetcherService:displaySetLoadProgress",DISPLAYSET_LOAD_COMPLETE:"event::studyPrefetcherService:displaySetLoadComplete"};var FT=((egn=FT||{}).closest="closest",egn.downward="downward",egn.upward="upward",egn);class F_ extends Lx{constructor({servicesManager:e,extensionManager:t,configuration:r}){super(FP),this._extensionManager=void 0,this._servicesManager=void 0,this._subscriptions=void 0,this._activeDisplaySetsInstanceUIDs=[],this._pendingRequests=[],this._inflightRequests=new Map,this._isRunning=!1,this._displaySetLoadingStates=new Map,this._imageIdsToDisplaySetsMap=new Map,this.config={enabled:!1,displaySetsCount:1,maxNumPrefetchRequests:10,order:FT.downward},this.requestType=FI.Prefetch,this.cache=void 0,this.imageLoadPoolManager=void 0,this.imageLoader=void 0,this.imageLoadEventsManager=void 0,this._servicesManager=e,this._extensionManager=t,this._subscriptions=[],Object.assign(this.config,r)}onModeEnter(){this._addEventListeners()}onModeExit(){this._removeEventListeners(),this._stopPrefetching()}_addImageLoadingEventsListeners(){let e=e=>{this._inflightRequests.get(e)||this._sendNextRequests()},t=t=>{let{image:r}=t.detail,{imageId:n}=r;this._moveImageIdToLoadedSet(n),e(n)},r=t=>{let{imageId:r}=t.detail;this._moveImageIdToFailedSet(r),e(r)};return this.imageLoadEventsManager.addEventListeners(t,r)}_addServicesListeners(){let{displaySetService:e,viewportGridService:t}=this._servicesManager.services;return[e.subscribe(e.EVENTS.DISPLAY_SETS_CHANGED,()=>this._syncWithActiveViewport({forceRestart:!0})),t.subscribe(L3.EVENTS.ACTIVE_VIEWPORT_ID_CHANGED,({viewportId:e})=>this._syncWithActiveViewport({activeViewportId:e})),t.subscribe(L3.EVENTS.LAYOUT_CHANGED,()=>this._syncWithActiveViewport()),t.subscribe(L3.EVENTS.GRID_STATE_CHANGED,()=>this._syncWithActiveViewport()),t.subscribe(L3.EVENTS.VIEWPORTS_READY,()=>{this._syncWithActiveViewport(),this._startPrefetching()})]}_addEventListeners(){let e=this._addImageLoadingEventsListeners(),t=this._addServicesListeners();this._subscriptions.push(...e),this._subscriptions.push(...t)}_removeEventListeners(){this._subscriptions.forEach(e=>e.unsubscribe()),this._subscriptions=[]}_syncWithActiveViewport({activeViewportId:e,forceRestart:t}={}){let{viewportGridService:r}=this._servicesManager.services,n=r.getState(),{viewports:a}=n;if(!(e=e??n.activeViewportId))return;let i=a.get(e);if(!i)return;let o=this._setActiveDisplaySetsUIDs(i.displaySetInstanceUIDs);(t||o)&&this._restartPrefetching()}_setActiveDisplaySetsUIDs(e){return!(e.length===this._activeDisplaySetsInstanceUIDs.length&&e.every(e=>this._activeDisplaySetsInstanceUIDs.includes(e)))&&(this._activeDisplaySetsInstanceUIDs=[...e],this._restartPrefetching(),!0)}_areActiveDisplaySetsLoaded(){let{_activeDisplaySetsInstanceUIDs:e}=this;return e.length&&e.every(e=>this._displaySetLoadingStates.get(e).loadingProgress>=1)}_getClosestDisplaySets(e,t){let r=[],n=t-1,a=t+1;for(;n>=0||a<e.length;)n>=0&&(r.push(e[n]),n--),a<e.length&&(r.push(e[a]),a++);return r}_getDownwardDisplaySets(e,t){let r=[];for(let n=t+1;n<e.length;n++)r.push(e[n]);return r}_getUpwardDisplaySets(e,t){let r=[];for(let n=t-1;n>=0&&n!==t;n--)r.push(e[n]);return r}_getSortedDisplaySetsToPrefetch(e){if(!this._activeDisplaySetsInstanceUIDs?.length)return[];let{displaySetsCount:t}=this.config,r=this._activeDisplaySetsInstanceUIDs,[n]=r,a=e.findIndex(e=>e.displaySetInstanceUID===n),i={[FT.closest]:this._getClosestDisplaySets,[FT.downward]:this._getDownwardDisplaySets,[FT.upward]:this._getUpwardDisplaySets},{order:o}=this.config,s=i[o];if(!s)throw Error(`Invalid order (${o})`);let l=new Set(r);return s.call(this,e,a).filter(e=>!l.has(e.displaySetInstanceUID)).slice(0,t)}_getDisplaySets(){let{displaySetService:e}=this._servicesManager.services,t=[...e.getActiveDisplaySets()],r=this._getSortedDisplaySetsToPrefetch(t);return{displaySets:t,displaySetsToPrefetch:r}}_updateImageIdsDisplaySetMap(e,t){for(let r of t){let t=this._imageIdsToDisplaySetsMap.get(r);t||(t=new Set,this._imageIdsToDisplaySetsMap.set(r,t)),t.add(e)}}_getImageIdsForDisplaySet(e){return this._extensionManager.getActiveDataSource()[0].getImageIdsForDisplaySet(e)}_updateDisplaySetLoadingProgress(e){let{numInstances:t,loadedImageIds:r,failedImageIds:n}=e;e.loadingProgress=(r.size+n.size)/t}_addDisplaySetLoadingState(e){let{displaySetInstanceUID:t}=e,r=this._getImageIdsForDisplaySet(e),n=this._displaySetLoadingStates.get(t);if(n)return;let a=new Set(r),i=new Set;for(let e of r)this.cache.isImageCached(e)?i.add(e):a.add(e);n={displaySetInstanceUID:t,numInstances:r.length,pendingImageIds:a,loadedImageIds:i,failedImageIds:new Set,loadingProgress:0},this._updateDisplaySetLoadingProgress(n),this._displaySetLoadingStates.set(t,n),this._updateImageIdsDisplaySetMap(t,r),i.size&&this._triggerDisplaySetEvents(t)}_loadDisplaySets(){let{displaySets:e,displaySetsToPrefetch:t}=this._getDisplaySets();e.forEach(e=>this._addDisplaySetLoadingState(e)),t.forEach(e=>this._enqueueDisplaySetImagesRequests(e))}_moveImageIdToLoadedSet(e){let t=this._imageIdsToDisplaySetsMap.get(e);if(t){for(let r of Array.from(t.values())){let t=this._displaySetLoadingStates.get(r),{pendingImageIds:n,loadedImageIds:a}=t;n.delete(e),a.add(e),this._updateDisplaySetLoadingProgress(t),this._triggerDisplaySetEvents(r)}return!0}}_moveImageIdToFailedSet(e){let t=this._imageIdsToDisplaySetsMap.get(e);if(t){for(let r of Array.from(t.values())){let t=this._displaySetLoadingStates.get(r),{pendingImageIds:n,failedImageIds:a}=t;n.delete(e),a.add(e),this._updateDisplaySetLoadingProgress(t),this._triggerDisplaySetEvents(r)}return!0}}_triggerDisplaySetEvents(e){let{loadingProgress:t,numInstances:r}=this._displaySetLoadingStates.get(e);this._broadcastEvent(this.EVENTS.DISPLAYSET_LOAD_PROGRESS,{displaySetInstanceUID:e,numInstances:r,loadingProgress:t}),t>=1&&this._broadcastEvent(this.EVENTS.DISPLAYSET_LOAD_COMPLETE,{displaySetInstanceUID:e})}_onImagePrefetchSuccess(e){if(e.aborted)return;let{imageId:t}=e;this._inflightRequests.delete(t),this._moveImageIdToLoadedSet(t),this._sendNextRequests()}_onImagePrefetchFailed(e,t){if(e.aborted)return;console.warn(`An error ocurred when trying to load "${e.imageId}"`,t);let{imageId:r}=e;this._inflightRequests.delete(r),this._moveImageIdToFailedSet(r),this._sendNextRequests()}async _sendNextRequests(){if(!this._isRunning||!this._areActiveDisplaySetsLoaded())return;let{_pendingRequests:e,_inflightRequests:t}=this,{maxNumPrefetchRequests:r}=this.config;if(!e.length||t.size>=r)return;let n=Math.min(e.length,r-t.size);this._pendingRequests.splice(0,n).forEach(e=>{let{imageId:r}=e,n={priority:-5,requestType:this.requestType,additionalDetails:{imageId:r},preScale:{enabled:!0}};this.imageLoadPoolManager.addRequest(async()=>this.imageLoader.loadAndCacheImage(r,n).then(t=>this._onImagePrefetchSuccess(e),t=>this._onImagePrefetchFailed(e,t)),this.requestType,{imageId:r}),t.set(r,e)})}_enqueueDisplaySetImagesRequests(e){let{displaySetInstanceUID:t}=e;this._getImageIdsForDisplaySet(e).forEach(e=>{this.cache.isImageCached(e)?this._moveImageIdToLoadedSet(e):this._pendingRequests.push({displaySetInstanceUID:t,imageId:e,aborted:!1})})}_startPrefetching(){if(!this._isRunning){if(!this.config.enabled)return void console.log("StudyPrefetcher is not enabled");this._isRunning=!0,this._loadDisplaySets(),this._sendNextRequests(),this._broadcastEvent(this.EVENTS.SERVICE_STARTED,{})}}_stopPrefetching(){this._isRunning&&(this._isRunning=!1,this._inflightRequests.forEach(e=>e.aborted=!0),this._pendingRequests=[],this._displaySetLoadingStates.clear(),this._imageIdsToDisplaySetsMap.clear(),this._inflightRequests.clear(),this.imageLoadPoolManager.clearRequestStack(this.requestType),this._broadcastEvent(this.EVENTS.SERVICE_STOPPED,{}))}_restartPrefetching(){this._isRunning&&(this._stopPrefetching(),this._startPrefetching())}}F_.REGISTRATION={name:"studyPrefetcherService",altName:"StudyPrefetcherService",create:({configuration:e,servicesManager:t,extensionManager:r})=>new F_({servicesManager:t,extensionManager:r,configuration:e})};class FA{constructor(e,t){this.numberOfScreens=void 0,this.windowsConfig=void 0,this.screenConfig=void 0,this.launchWindows=[],this.basePath=void 0,this.screenNumber=void 0,this.isMultimonitor=void 0,this.setLaunchWindows=e=>{this.launchWindows=e,window.multimonitor.launchWindows=e};const r=new URLSearchParams(window.location.search),n=r.get("screenNumber"),a=r.get("multimonitor"),i={params:r,screenNumber:n,multimonitor:a};this.screenNumber=n?Number(n):-1,this.commandsManager=t;const o=window;for(const r of(o.multimonitor||={setLaunchWindows:this.setLaunchWindows,launchWindows:this.launchWindows,commandsManager:t},o.multimonitor.commandsManager=t,this.launchWindows=window.multimonitor?.launchWindows||this.launchWindows,-1!==this.screenNumber&&(this.launchWindows[this.screenNumber]=window),o.commandsManager=(...t)=>e.commandsManager,Array.isArray(e)?e:[])){if(r.test(i)){if(this.isMultimonitor=!0,this.numberOfScreens=r.screens.length,this.windowsConfig=r,-1===this.screenNumber||null===this.screenNumber)this.screenConfig=FA.SOURCE_SCREEN;else{if(this.screenConfig=r.screens[this.screenNumber],!this.screenConfig)throw Error(`Screen ${n} not configured in ${this.windowsConfig}`);window.name=this.screenConfig.id}return}this.numberOfScreens=1,this.isMultimonitor=!1}}async run(e=1,t,r){let n=(this.screenNumber+(e??1))%this.numberOfScreens,a=await this.getWindow(n);a?a.multimonitor?.commandsManager?a.multimonitor.commandsManager.runAsync(t,r):console.warn("Didn't find a commands manager to run in the other window",a):console.warn("No multimonitor found for screen",n,t)}async launchWindow(e,t=1,r=""){let n=(this.screenNumber+t)%this.numberOfScreens;return this.getWindow(n,e?`StudyInstanceUIDs=${e}${r}`:"")}async getWindow(e,t){return e===this.screenNumber?window:this.launchWindows[e]&&!this.launchWindows[e].closed?this.launchWindows[e]:await this.createWindow(e,t)}async createWindow(e,t){if(e===this.screenNumber)return window;let r=this.windowsConfig.screens[e],n=await window.getScreenDetails?.(),{width:a=1024,height:i=1024,availLeft:o=0,availTop:s=0}=r.screen>=0&&n.screens[r.screen]||n.currentScreen||window.screen||{},l=this.windowsConfig.screens[e],{width:u=1,height:c=1,top:d=0,left:h=0}=l.location||{},p=Math.round(o+h*a),f=Math.round(s+d*i),m=Math.round(a*u),g=Math.round(i*c),y=`${this.basePath}&screenNumber=${e}`,v=t?`${y}#${t}`:y,b=l.id,w=l.options||"",x=`screenX=${p},screenY=${f},width=${m},height=${g},${w}`,C=window.open("",b,x);return(C?.location.href.startsWith(y)||(C=window.open(v,b,x)),C)?(await new Promise(e=>{"complete"===C.document.readyState?e():C.addEventListener("load",()=>e())}),this.launchWindows[e]=C,C):void console.warn("Unable to launch window",v,"called",b,"at",x)}launchAll(){for(let e=0;e<this.numberOfScreens;e++)this.createWindow(e)}setBasePath(){let e=new URL(window.location.href);e.searchParams.delete("screenNumber"),e.searchParams.delete("protocolId"),e.searchParams.delete("launchAll"),e.searchParams.set("multimonitor",e.searchParams.get("multimonitor")||"split"),e.hash="",this.basePath=e.toString()}onModeEnter(){this.setBasePath(),(this.isMultimonitor&&-1===this.screenNumber||-1!==window.location.href.toLowerCase().indexOf("launchall"))&&this.launchAll()}}FA.SOURCE_SCREEN={id:"source",launch:"source",screen:null,location:{screen:null,width:1,height:1,left:0,top:0}},FA.REGISTRATION={name:"multiMonitorService",create:({configuration:e,commandsManager:t})=>new FA(e,t)};class FO extends Lx{constructor({commandsManager:e,servicesManager:t,serviceProvidersManager:r,hotkeysManager:n,appConfig:a={}}){super(FO.EVENTS),this._commandsManager=void 0,this._servicesManager=void 0,this._hotkeysManager=void 0,this._serviceProvidersManager=void 0,this.modulesMap=void 0,this.modules=void 0,this.registeredExtensionIds=void 0,this.moduleTypeNames=void 0,this._appConfig=void 0,this._extensionLifeCycleHooks=void 0,this.dataSourceMap=void 0,this.dataSourceDefs=void 0,this._activeDataSourceName=void 0,this.registerExtensions=async(e,t=[])=>{for(let r=0;r<e.length;r++){let n=e[r],a=Array.isArray(n);try{if(a){let e=n[0],r=n[1];await this.registerExtension(e,r,t)}else await this.registerExtension(n,{},t)}catch(e){console.error(e)}}},this.registerExtension=async(e,t={},r=[])=>{if(!e)throw Error("Attempting to register a null/undefined extension.");let n=e.id;if(!n)throw Lp.warn(e),Error("Extension ID not set");this.registeredExtensionIds.includes(n)?Lp.warn(`Extension ID ${n} has already been registered. Exiting before duplicating modules.`):(e.preRegistration&&await e.preRegistration({servicesManager:this._servicesManager,serviceProvidersManager:this._serviceProvidersManager,commandsManager:this._commandsManager,hotkeysManager:this._hotkeysManager,extensionManager:this,appConfig:this._appConfig,configuration:t}),e.onModeEnter&&(this._extensionLifeCycleHooks.onModeEnter[n]=e.onModeEnter),e.onModeExit&&(this._extensionLifeCycleHooks.onModeExit[n]=e.onModeExit),this.moduleTypeNames.forEach(a=>{let i=this._getExtensionModule(a,e,n,t);if(i){switch(a){case Lh.COMMANDS:this._initCommandsModule(i);break;case Lh.DATA_SOURCE:this._initDataSourcesModule(i,n,r);break;case Lh.HANGING_PROTOCOL:this._initHangingProtocolsModule(i,n);break;case Lh.PANEL:this._initPanelModule(i,n);break;case Lh.TOOLBAR:this._initToolbarModule(i,n);break;case Lh.VIEWPORT:case Lh.SOP_CLASS_HANDLER:case Lh.CONTEXT:case Lh.LAYOUT_TEMPLATE:case Lh.CUSTOMIZATION:case Lh.STATE_SYNC:case Lh.UTILITY:this.processExtensionModule(i,n,a);break;default:throw Error(`Module type invalid: ${a}`)}this.modules[a].push({extensionId:n,module:i})}}),this.registeredExtensionIds.push(n))},this.getModuleEntry=e=>this.modulesMap[e],this.getModulesByType=e=>this.modules[e],this.getDataSources=e=>(e||(e=this._activeDataSourceName),this.dataSourceMap[e]),this.getDataSourceInstance=e=>this.dataSourceMap[e][0],this.getActiveDataSource=()=>this.dataSourceMap[this._activeDataSourceName],this.getActiveDataSourceOrNull=()=>this.dataSourceMap[this._activeDataSourceName]?.[0]??null,this.getDataSourceDefinition=e=>(void 0===e&&(e=this._activeDataSourceName),this.dataSourceDefs[e]),this.getActiveDataSourceDefinition=()=>this.getDataSourceDefinition(this._activeDataSourceName),this.getDataSourcesForUI=()=>{if(this._appConfig?.allowMultiSelectExport===!1)return[];let e=Object.keys(this.dataSourceMap).filter(e=>{let t=this.dataSourceDefs[e]?.configuration,r=this.dataSourceDefs[e].sourceName!==this._activeDataSourceName;return(t?.supportsStow??t?.wadoRoot)&&r});return[this._activeDataSourceName,...e].map(e=>({value:e,label:e,placeHolder:e}))},this._getExtensionModule=(e,t,r,n)=>{var a;let i="get"+((a=e).charAt(0).toUpperCase()+a.substring(1));if(t[i])try{let e=t[i]({appConfig:this._appConfig,commandsManager:this._commandsManager,servicesManager:this._servicesManager,hotkeysManager:this._hotkeysManager,extensionManager:this,configuration:n});return e||Lp.warn(`Null or undefined returned when registering the ${i} module for the ${r} extension`),e}catch(e){throw console.error(e),Error(`Exception thrown while trying to call ${i} for the ${r} extension`)}},this._initHangingProtocolsModule=(e,t)=>{let{hangingProtocolService:r}=this._servicesManager.services;e.forEach(({name:e,protocol:t})=>{t&&r.addProtocol(e,t)})},this._initPanelModule=(e,t)=>{this.processExtensionModule(e,t,Lh.PANEL)},this._initToolbarModule=(e,t)=>{let{toolbarService:r}=this._servicesManager.services;e.forEach(e=>{e.evaluate&&r.registerEvaluateFunction(e.name,e.evaluate)})},this._initCommandsModule=e=>{let{definitions:t,defaultContext:r}=e;t&&0!==Object.keys(t).length?(r=r||"VIEWER",this._commandsManager.getContext(r)||this._commandsManager.createContext(r),Object.keys(t).forEach(e=>{let n=t[e];"function"==typeof n&&(n={commandFn:n}),n.context&&!this._commandsManager.getContext(n.context)&&this._commandsManager.createContext(n.context),this._commandsManager.registerCommand(n.context||r,e,n)})):Lp.warn("Commands Module contains no command definitions")},this.modules={},this.registeredExtensionIds=[],this.moduleTypeNames=Object.values(Lh),this._commandsManager=e,this._servicesManager=t,this._serviceProvidersManager=r,this._hotkeysManager=n,this._appConfig=a,this.modulesMap={},this.moduleTypeNames.forEach(e=>{this.modules[e]=[]}),this._extensionLifeCycleHooks={onModeEnter:{},onModeExit:{}},this.dataSourceMap={},this.dataSourceDefs={},this.defaultDataSourceName=a.defaultDataSourceName,this._activeDataSourceName=a.defaultDataSourceName,this.peerImport=a.peerImport}setActiveDataSource(e){this._activeDataSourceName!==e&&(this._activeDataSourceName=e,this._broadcastEvent(FO.EVENTS.ACTIVE_DATA_SOURCE_CHANGED,this.dataSourceDefs[this._activeDataSourceName]))}getRegisteredExtensionIds(){return[...this.registeredExtensionIds]}getUniqueServicesList(e){return Array.from(new Set(Object.values(e.services)))}onModeEnter(){let{registeredExtensionIds:e,_servicesManager:t,_commandsManager:r,_hotkeysManager:n,_extensionLifeCycleHooks:a}=this;for(let e of this.getUniqueServicesList(t))e?.onModeEnter?.();e.forEach(e=>{let i=a.onModeEnter[e];"function"==typeof i&&i({servicesManager:t,commandsManager:r,hotkeysManager:n,extensionManager:this})})}onModeExit(){let{registeredExtensionIds:e,_servicesManager:t,_commandsManager:r,_extensionLifeCycleHooks:n}=this,a=this.getUniqueServicesList(t);for(let i of(e.forEach(e=>{let a=n.onModeExit[e];"function"==typeof a&&a({servicesManager:t,commandsManager:r})}),a))try{i?.onModeExit?.()}catch(e){console.warn("onModeExit caught",e)}}processExtensionModule(e,t,r){e.forEach(e=>{if(!e.name)throw Error(`Extension ID ${t} module ${r} element has no name`);let n=`${t}.${r}.${e.name}`;e.id=n,this.modulesMap[n]=e})}addDataSource(e,t={activate:!1}){let r=this.getDataSources(e.sourceName);!r?.[0]&&(this._createDataSourceInstance(e),t.activate&&this.setActiveDataSource(e.sourceName))}updateDataSourceConfiguration(e,t){let r=this.getDataSources(e);if(!r?.[0])return;let n=this.dataSourceDefs[e];n.configuration=t,this._createDataSourceInstance(n),this._activeDataSourceName===e&&this._broadcastEvent(FO.EVENTS.ACTIVE_DATA_SOURCE_CHANGED,n)}_createDataSourceInstance(e){let t=this.getModuleEntry(e.namespace);if(!t)return;this.dataSourceDefs[e.sourceName]=e;let r=t.createDataSource(e.configuration,this._servicesManager,this);this.dataSourceMap[e.sourceName]=[r]}_initDataSourcesModule(e,t,r=[]){e.forEach(e=>{this.modulesMap[`${t}.${Lh.DATA_SOURCE}.${e.name}`]=e}),e.forEach(e=>{let n=`${t}.${Lh.DATA_SOURCE}.${e.name}`;r.forEach(e=>{e.namespace===n&&this.addDataSource(e)})})}registerCommandsModule(e,t="VIEWER"){this._initCommandsModule({...e,defaultContext:e.defaultContext||t})}get appConfig(){return this._appConfig}get activeDataSourceName(){return this._activeDataSourceName}}FO.EVENTS={ACTIVE_DATA_SOURCE_CHANGED:"event::activedatasourcechanged"},FO.MODULE_TYPES=Lh;var FR=u(2203),FL=u.n(FR);let FN=[{commandName:"setToolActive",commandOptions:{toolName:"Zoom"},label:"Zoom",keys:["z"],isEditable:!0},{commandName:"scaleUpViewport",label:"Zoom In",keys:["+"],isEditable:!0},{commandName:"scaleDownViewport",label:"Zoom Out",keys:["-"],isEditable:!0},{commandName:"fitViewportToWindow",label:"Zoom to Fit",keys:["="],isEditable:!0},{commandName:"rotateViewportCW",label:"Rotate Right",keys:["r"],isEditable:!0},{commandName:"rotateViewportCCW",label:"Rotate Left",keys:["l"],isEditable:!0},{commandName:"flipViewportHorizontal",label:"Flip Horizontally",keys:["h"],isEditable:!0},{commandName:"flipViewportVertical",label:"Flip Vertically",keys:["v"],isEditable:!0},{commandName:"toggleCine",label:"Cine",keys:["c"]},{commandName:"invertViewport",label:"Invert",keys:["i"],isEditable:!0},{commandName:"incrementActiveViewport",label:"Next Image Viewport",keys:["right"],isEditable:!0},{commandName:"decrementActiveViewport",label:"Previous Image Viewport",keys:["left"],isEditable:!0},{commandName:"updateViewportDisplaySet",commandOptions:{direction:-1},label:"Previous Series",keys:["pageup"],isEditable:!0},{commandName:"updateViewportDisplaySet",commandOptions:{direction:1},label:"Next Series",keys:["pagedown"],isEditable:!0},{commandName:"nextStage",context:"DEFAULT",label:"Next Stage",keys:["."],isEditable:!0},{commandName:"previousStage",context:"DEFAULT",label:"Previous Stage",keys:[","],isEditable:!0},{commandName:"nextImage",label:"Next Image",keys:["down"],isEditable:!0},{commandName:"previousImage",label:"Previous Image",keys:["up"],isEditable:!0},{commandName:"firstImage",label:"First Image",keys:["home"],isEditable:!0},{commandName:"lastImage",label:"Last Image",keys:["end"],isEditable:!0},{commandName:"resetViewport",label:"Reset",keys:["space"],isEditable:!0},{commandName:"cancelActiveOperation",label:"Cancel",keys:["esc"]},{commandName:"setWindowLevelPreset",commandOptions:{presetName:"ct-soft-tissue",presetIndex:0},label:"W/L Preset 1",keys:["1"]},{commandName:"setWindowLevelPreset",commandOptions:{presetName:"ct-lung",presetIndex:1},label:"W/L Preset 2",keys:["2"]},{commandName:"setWindowLevelPreset",commandOptions:{presetName:"ct-bone",presetIndex:2},label:"W/L Preset 3",keys:["3"]},{commandName:"setWindowLevelPreset",commandOptions:{presetName:"ct-brain",presetIndex:3},label:"W/L Preset 4",keys:["4"]},{commandName:"deleteActiveAnnotation",label:"Delete Annotation",keys:["backspace"]},{commandName:"acceptPreview",label:"Accept Preview",keys:["enter"]},{commandName:"undo",label:"Undo",keys:["ctrl+z"],isEditable:!0},{commandName:"redo",label:"Redo",keys:["ctrl+y"],isEditable:!0},{commandName:"interpolateScrollForMarkerLabelmap",label:"Interpolate Scroll",keys:["n"],isEditable:!0},{commandName:"increaseBrushSize",label:"Increase Brush Size",keys:["]"],isEditable:!0},{commandName:"decreaseBrushSize",label:"Decrease Brush Size",keys:["["],isEditable:!0},{commandName:"setToolActive",commandOptions:{toolName:"CircularEraser"},label:"Eraser",keys:["e"],isEditable:!0},{commandName:"setToolActive",commandOptions:{toolName:"CircularBrush"},label:"Brush",keys:["b"],isEditable:!0},{commandName:"addNewSegment",label:"Add New Segment",keys:["a"],isEditable:!0}],FF=function({generateHash:e}){try{let t=localStorage.getItem("hotkey-definitions"),r=localStorage.getItem("hotkeys-migrated");if(!t||"true"===r)return;let n=JSON.parse(t);if(!Array.isArray(n)||0===n.length)return;let a=FN||[],i=JSON.parse(localStorage.getItem("user-preferred-keys")||"{}");n.forEach(t=>{if(!t.commandName||!t.keys)return;let r=a.find(e=>{let r=e.commandName===t.commandName,n=t.commandOptions||{},a=e.commandOptions||{},i=JSON.stringify(n)===JSON.stringify(a);return r&&i});r&&JSON.stringify(r.keys)===JSON.stringify(t.keys)||(i[e({commandName:t.commandName,commandOptions:t.commandOptions||{}})]=t.keys,console.debug(`HotkeysManager: Migrated custom hotkey for ${t.commandName}`))}),localStorage.setItem("user-preferred-keys",JSON.stringify(i)),localStorage.setItem("hotkeys-migrated","true"),localStorage.removeItem("hotkey-definitions"),console.debug("HotkeysManager: Successfully migrated hotkey definitions to new format")}catch(e){console.error("HotkeysManager: Error migrating hotkey definitions",e),localStorage.setItem("hotkeys-migrated","false")}};class FV{constructor(e,t){this._servicesManager=void 0,this._commandsManager=void 0,this.isEnabled=!0,this.hotkeyDefinitions={},this.hotkeyDefaults=[],this.EVENTS=void 0,this.listeners={},this.subscribe=void 0,this._broadcastEvent=void 0,this._unsubscribe=void 0,this._isValidEvent=void 0,this._servicesManager=t,this._commandsManager=e,this.EVENTS=FV.EVENTS,this.subscribe=Lg.subscribe.bind(this),this._broadcastEvent=Lg._broadcastEvent.bind(this),this._unsubscribe=Lg._unsubscribe.bind(this),this._isValidEvent=Lg._isValidEvent.bind(this),FF({generateHash:this.generateHash})}record(e){return Nu.record(e)}cancel(){Nu.stopRecord(),Nu.unpause()}disable(){this.isEnabled=!1,Nu.pause()}enable(){this.isEnabled=!0,Nu.unpause()}restoreDefaultBindings(){this.setHotkeys(this.hotkeyDefaults)}destroy(){this.hotkeyDefaults=[],this.hotkeyDefinitions={},Nu.reset()}setHotkeys(e=[]){try{this.getValidDefinitions(e).forEach(e=>this.registerHotkeys(e))}catch(t){let{uiNotificationService:e}=this._servicesManager.services;e.show({title:"Hotkeys Manager",message:"Error while setting hotkeys",type:"error"})}}generateHash(e){return FL()({commandName:e.commandName,commandOptions:e.commandOptions||{}})}setDefaultHotKeys(e=[]){let t=this.getValidDefinitions(e);this.hotkeyDefaults=t;let r=JSON.parse(localStorage.getItem("user-preferred-keys")||"{}"),n=t.map(e=>{let t=this.generateHash(e);return r[t]?{...e,keys:r[t]}:e});this.setHotkeys(n)}getValidDefinitions(e){let t=Array.isArray(e)?[...e]:this._parseToArrayLike(e);return t.forEach(e=>{void 0===e.isEditable&&(e.isEditable=!0)}),t}getValidHotkeyDefinitions(e){let t=this.getValidDefinitions(e),r={};return t.forEach(e=>{let{commandName:t,commandOptions:n}=e;r[FL()({commandName:t,commandOptions:n})]=e}),r}_parseToArrayLike(e={}){return Object.entries({...e}).map(e=>this._parseToHotKeyObj(e[0],e[1]))}_parseToHotKeyObj(e,t){return{commandName:e,...t}}registerHotkeys({commandName:e,commandOptions:t={},context:r,keys:n,label:a,isEditable:i}){if(!e)throw Error(`No command was defined for hotkey "${n}"`);let o=this.generateHash({commandName:e,commandOptions:t}),s=this.hotkeyDefinitions[o];if(s&&s.keys===n)return void console.debug("HotkeysManager: Identical hotkey registration skipped.");let l=JSON.parse(localStorage.getItem("user-preferred-keys")||"{}");s&&(l[o]=n,localStorage.setItem("user-preferred-keys",JSON.stringify(l)),this._unbindHotkeys(e,s.keys)),this.hotkeyDefinitions[o]={commandName:e,commandOptions:t,keys:n,label:a,isEditable:i},this._bindHotkeys(e,t,r,n)}_bindHotkeys(e,t={},r,n){if(""===n||void 0===n)return;let a=n instanceof Array?n.join("+"):n;Nu.bind(a,n=>{n.preventDefault(),n.stopPropagation(),this._commandsManager.runCommand(e,{evt:n,...t},r),this._broadcastEvent(FV.EVENTS.HOTKEY_PRESSED,{commandName:e,commandOptions:t,keys:a,context:r,evt:n})})}_unbindHotkeys(e,t){if(""!==t&&void 0!==t){if(t instanceof Array){let r=t.join("+");this._unbindHotkeys(e,r);return}Nu.unbind(t)}}}FV.EVENTS={HOTKEY_PRESSED:"event::hotkeysManager:hotkeyPressed"};var FB=u(313),Fj=u.n(FB);(ega=egU||(egU={})).ERROR_EVENT="CORNERSTONE_ERROR",ega.CACHE_SIZE_EXCEEDED="CACHE_SIZE_EXCEEDED",ega.IMAGE_LOAD_ERROR="IMAGE_LOAD_ERROR",ega.CAMERA_MODIFIED="CORNERSTONE_CAMERA_MODIFIED",ega.CAMERA_RESET="CORNERSTONE_CAMERA_RESET",ega.VOI_MODIFIED="CORNERSTONE_VOI_MODIFIED",ega.PRESET_MODIFIED="CORNERSTONE_VIEWPORT_RENDERING_PRESET_MODIFIED",ega.DISPLAY_AREA_MODIFIED="CORNERSTONE_DISPLAY_AREA_MODIFIED",ega.ELEMENT_DISABLED="CORNERSTONE_ELEMENT_DISABLED",ega.ELEMENT_ENABLED="CORNERSTONE_ELEMENT_ENABLED",ega.IMAGE_RENDERED="CORNERSTONE_IMAGE_RENDERED",ega.IMAGE_VOLUME_MODIFIED="CORNERSTONE_IMAGE_VOLUME_MODIFIED",ega.IMAGE_VOLUME_LOADING_COMPLETED="CORNERSTONE_IMAGE_VOLUME_LOADING_COMPLETED",ega.IMAGE_LOADED="CORNERSTONE_IMAGE_LOADED",ega.IMAGE_RETRIEVAL_STAGE="CORNERSTONE_IMAGE_RETRIEVAL_STAGE",ega.IMAGE_LOAD_FAILED="CORNERSTONE_IMAGE_LOAD_FAILED",ega.VOLUME_VIEWPORT_NEW_VOLUME="CORNERSTONE_VOLUME_VIEWPORT_NEW_VOLUME",ega.VOLUME_LOADED="CORNERSTONE_VOLUME_LOADED",ega.VOLUME_LOADED_FAILED="CORNERSTONE_VOLUME_LOADED_FAILED",ega.IMAGE_CACHE_IMAGE_ADDED="CORNERSTONE_IMAGE_CACHE_IMAGE_ADDED",ega.IMAGE_CACHE_IMAGE_REMOVED="CORNERSTONE_IMAGE_CACHE_IMAGE_REMOVED",ega.VOLUME_CACHE_VOLUME_ADDED="CORNERSTONE_VOLUME_CACHE_VOLUME_ADDED",ega.VOLUME_CACHE_VOLUME_REMOVED="CORNERSTONE_VOLUME_CACHE_VOLUME_REMOVED",ega.STACK_NEW_IMAGE="CORNERSTONE_STACK_NEW_IMAGE",ega.VOLUME_NEW_IMAGE="CORNERSTONE_VOLUME_NEW_IMAGE",ega.PRE_STACK_NEW_IMAGE="CORNERSTONE_PRE_STACK_NEW_IMAGE",ega.IMAGE_SPACING_CALIBRATED="CORNERSTONE_IMAGE_SPACING_CALIBRATED",ega.VIEWPORT_NEW_IMAGE_SET="CORNERSTONE_VIEWPORT_NEW_IMAGE_SET",ega.STACK_VIEWPORT_SCROLL="CORNERSTONE_STACK_VIEWPORT_SCROLL",ega.STACK_SCROLL_OUT_OF_BOUNDS="STACK_SCROLL_OUT_OF_BOUNDS",ega.GEOMETRY_CACHE_GEOMETRY_ADDED="CORNERSTONE_GEOMETRY_CACHE_GEOMETRY_ADDED",ega.GEOMETRY_CACHE_GEOMETRY_REMOVED="CORNERSTONE_GEOMETRY_CACHE_GEOMETRY_REMOVED",ega.VOLUME_VIEWPORT_SCROLL_OUT_OF_BOUNDS="VOLUME_VIEWPORT_SCROLL_OUT_OF_BOUNDS",ega.VOLUME_VIEWPORT_SCROLL="VOLUME_VIEWPORT_SCROLL",ega.CLIPPING_PLANES_UPDATED="CORNERSTONE_CLIPPING_PLANES_UPDATED",ega.WEB_WORKER_PROGRESS="CORNERSTONE_WEB_WORKER_PROGRESS",ega.COLORMAP_MODIFIED="CORNERSTONE_COLORMAP_MODIFIED",ega.DYNAMIC_VOLUME_DIMENSION_GROUP_CHANGED="DYNAMIC_VOLUME_DIMENSION_GROUP_CHANGED",ega.DYNAMIC_VOLUME_TIME_POINT_INDEX_CHANGED="DYNAMIC_VOLUME_TIME_POINT_INDEX_CHANGED",ega.DYNAMIC_VOLUME_DIMENSION_GROUP_LOADED="DYNAMIC_VOLUME_DIMENSION_GROUP_LOADED",ega.DYNAMIC_VOLUME_TIME_POINT_LOADED="DYNAMIC_VOLUME_TIME_POINT_LOADED",ega.GEOMETRY_LOADED="GEOMETRY_LOADED",ega.GEOMETRY_LOAD_PROGRESS="GEOMETRY_LOAD_PROGRESS",ega.GEOMETRY_LOADED_FAILED="GEOMETRY_LOADED_FAILED",ega.ACTORS_CHANGED="CORNERSTONE_ACTORS_CHANGED",ega.RENDER_BACKEND_CHANGED="CORNERSTONE_RENDER_BACKEND_CHANGED",ega.WEBGL_CONTEXT_LOST="CORNERSTONE_WEBGL_CONTEXT_LOST",ega.WEBGL_CONTEXT_RESTORED="CORNERSTONE_WEBGL_CONTEXT_RESTORED",ega.RENDER_PATH_ERROR="CORNERSTONE_RENDER_PATH_ERROR",ega.RENDERING_PIPELINE_CHANGED="CORNERSTONE_RENDERING_PIPELINE_CHANGED";let FW=egU;(egi=egz||(egz={})).Interaction="interaction",egi.Thumbnail="thumbnail",egi.Prefetch="prefetch",egi.Compute="compute";let FU=egz;(ego=egH||(egH={})).STACK="stack",ego.ORTHOGRAPHIC="orthographic",ego.PERSPECTIVE="perspective",ego.VOLUME_3D="volume3d",ego.VOLUME_3D_NEXT="volume3dNext",ego.PLANAR_NEXT="planarNext",ego.VIDEO="video",ego.VIDEO_NEXT="videoNext",ego.WHOLE_SLIDE="wholeSlide",ego.WHOLE_SLIDE_NEXT="wholeSlideNext",ego.ECG="ecg",ego.ECG_NEXT="ecgNext";let Fz=egH,FH={STACK:Fz.STACK,ORTHOGRAPHIC:Fz.ORTHOGRAPHIC,PERSPECTIVE:Fz.PERSPECTIVE,VOLUME_3D:Fz.VOLUME_3D,VOLUME_3D_NEXT:Fz.VOLUME_3D_NEXT,PLANAR_NEXT:Fz.PLANAR_NEXT,VIDEO:Fz.VIDEO,VIDEO_NEXT:Fz.VIDEO_NEXT,WHOLE_SLIDE:Fz.WHOLE_SLIDE,WHOLE_SLIDE_NEXT:Fz.WHOLE_SLIDE_NEXT,ECG:Fz.ECG,ECG_NEXT:Fz.ECG_NEXT};(egs=egG||(egG={}))[egs.NEAREST=0]="NEAREST",egs[egs.LINEAR=1]="LINEAR",egs[egs.FAST_LINEAR=2]="FAST_LINEAR";let FG=egG,Fq={COMPOSITE_BLEND:0,MAXIMUM_INTENSITY_BLEND:1,MINIMUM_INTENSITY_BLEND:2,AVERAGE_INTENSITY_BLEND:3,ADDITIVE_INTENSITY_BLEND:4,RADON_TRANSFORM_BLEND:5,LABELMAP_EDGE_PROJECTION_BLEND:6};var F$={BlendMode:Fq};let{BlendMode:FK}=F$;(egl=egq||(egq={}))[egl.COMPOSITE=FK.COMPOSITE_BLEND]="COMPOSITE",egl[egl.MAXIMUM_INTENSITY_BLEND=FK.MAXIMUM_INTENSITY_BLEND]="MAXIMUM_INTENSITY_BLEND",egl[egl.MINIMUM_INTENSITY_BLEND=FK.MINIMUM_INTENSITY_BLEND]="MINIMUM_INTENSITY_BLEND",egl[egl.AVERAGE_INTENSITY_BLEND=FK.AVERAGE_INTENSITY_BLEND]="AVERAGE_INTENSITY_BLEND",egl[egl.LABELMAP_EDGE_PROJECTION_BLEND=FK.LABELMAP_EDGE_PROJECTION_BLEND]="LABELMAP_EDGE_PROJECTION_BLEND";let FY=egq;(egu=eg$||(eg$={})).AXIAL="axial",egu.CORONAL="coronal",egu.SAGITTAL="sagittal",egu.ACQUISITION="acquisition",egu.AXIAL_REFORMAT="axial_reformat",egu.CORONAL_REFORMAT="coronal_reformat",egu.SAGITTAL_REFORMAT="sagittal_reformat",egu.REFORMAT="reformat";let FX=eg$;(egc=egK||(egK={})).CONTOUR="CONTOUR",egc.SURFACE="SURFACE",egc.MESH="MESH";let FZ=egK;(egd=egY||(egY={})).CLOSED_PLANAR="CLOSED_PLANAR",egd.OPEN_PLANAR="OPEN_PLANAR",(egh=egX||(egX={})).PLY="PLY",egh.STL="STL",egh.OBJ="OBJ",egh.VTP="VTP";let FJ=egX;(egp=egZ||(egZ={})).LINEAR="LINEAR",egp.SAMPLED_SIGMOID="SIGMOID",egp.LINEAR_EXACT="LINEAR_EXACT";let FQ=egZ;(egf=egJ||(egJ={})).SUM="SUM",egf.AVERAGE="AVERAGE",egf.SUBTRACT="SUBTRACT";class F1{constructor(e){this.fullDate=e}getTimeInSec(){let e=this.fullDate.substring(0,10),t=this.fullDate.substring(11,28),r=parseInt(e.substring(0,4),10),n=e.length>=7?parseInt(e.substring(5,7),10):void 0,a=e.length>=10?parseInt(e.substring(8,10),10):void 0;if(isNaN(r)||void 0!==n&&isNaN(n)||void 0!==a&&isNaN(a)||r>3e3||n&&(n<1||n>12)||a&&(a<1||a>31))throw Error(`invalid date '${e}'`);let i=new Date(`${e}T00:00:00.000000Z`),o=parseInt(t.substring(0,2),10),s=t.length>=5?parseInt(t.substring(3,5),10):void 0,l=t.length>=8?parseInt(t.substring(6,8),10):void 0,u=t.substring(9,15),c=u?parseInt(u,10)*Math.pow(10,-u.length):void 0;if(isNaN(o)||void 0!==s&&isNaN(s)||void 0!==l&&isNaN(l)||void 0!==c&&isNaN(c)||o<0||o>23||s&&(s<0||s>59)||l&&(l<0||l>59)||c&&(c<0||c>999999))throw Error(`invalid time '${t}'`);let d=i.getTime()/1e3;return d+=3600*o,void 0!==s&&(d+=60*s),void 0!==l&&(d+=l),void 0!==c&&(d+=c),d}getTimeInMicroSec(){return 1e6*this.getTimeInSec()}}function F0(e,t){let r=`${t.hours||"00"}`.padStart(2,"0"),n=`${t.minutes||"00"}`.padStart(2,"0"),a=`${t.seconds||"00"}`.padStart(2,"0"),i=`${e.month}`.padStart(2,"0"),o=`${e.day}`.padStart(2,"0"),s=`${t.fractionalSeconds||"000000"}`.padEnd(6,"0"),l=`${e.year}-${i}-${o}`,u=`T${r}:${n}:${a}.${s}Z`;return new F1(`${l}${u}`)}function F2(e){if(null==e||8!==e.length||"string"!=typeof e)throw Error(`invalid DA '${e}'`);let t=parseInt(e.substring(0,4),10),r=parseInt(e.substring(4,6),10),n=parseInt(e.substring(6,8),10);if(!0!=(!isNaN(t)&&r>0&&r<=12&&n>0&&n<=function(e,t){switch(e){case 2:return t%4==0&&t%100||t%400==0?29:28;case 9:case 4:case 6:case 11:return 30;default:return 31}}(r,t)))throw Error(`invalid DA '${e}'`);return{year:t,month:r,day:n}}function F5(e){if(null==e||e.length<2||"string"!=typeof e)throw Error(`invalid TM '${e}'`);let t=parseInt(e.substring(0,2),10),r=e.length>=4?parseInt(e.substring(2,4),10):void 0,n=e.length>=6?parseInt(e.substring(4,6),10):void 0,a=e.length>=8?e.substring(7,13):void 0,i=a?parseInt(a,10)*Math.pow(10,6-a.length):void 0;if(isNaN(t)||void 0!==r&&isNaN(r)||void 0!==n&&isNaN(n)||void 0!==i&&isNaN(i)||t<0||t>23||r&&(r<0||r>59)||n&&(n<0||n>59)||i&&(i<0||i>999999))throw Error(`invalid TM '${e}'`);return{hours:t,minutes:r,seconds:n,fractionalSeconds:i}}function F3(e){if(null==e)throw Error("dateTimeToFullDateInterface : dateTime not defined.");return F0(F2(e.substring(0,8)),F5(e.substring(8)))}function F4(e){let t,r,{CorrectedImage:n,Units:a,PhilipsPETPrivateGroup:i,PatientWeight:o,PatientSex:s,PatientSize:l}=e[0];if(!n.includes("ATTN")||!n.includes("DECY"))throw Error(`CorrectedImage must contain "ATTN" and "DECY": ${n}`);if(!e.every(t=>{let r;return t.Units===a&&((r=t.CorrectedImage)===n||Array.isArray(r)&&Array.isArray(n)&&r.length===n.length&&r.every((e,t)=>e===n[t]))&&t.PatientWeight===o&&t.PatientSex===s&&t.PatientSize===l&&t.RadionuclideHalfLife===e[0].RadionuclideHalfLife&&t.RadionuclideTotalDose===e[0].RadionuclideTotalDose&&t.DecayCorrection===e[0].DecayCorrection&&t.SeriesDate===e[0].SeriesDate&&t.SeriesTime===e[0].SeriesTime}))throw Error("The set of instances does not appear to come from one Series. Every instance must have identical values for series-level metadata properties");if(null==o)throw Error("PatientWeight value is missing. It is not possible to calculate the SUV factors");let u=Array(e.length);u=function(e){let{RadionuclideTotalDose:t,RadionuclideHalfLife:r,RadiopharmaceuticalStartDateTime:n,RadiopharmaceuticalStartTime:a,SeriesDate:i}=e[0];if(null==t)throw Error("calculateDecayCorrection : RadionuclideTotalDose value not found.");if(null==r)throw Error("calculateDecayCorrection : RadionuclideHalfLife value not found.");let o=function(e){let{SeriesDate:t,SeriesTime:r,GEPrivatePostInjectionDateTime:n}=e[0],a=Array(e.length),i=F0(F2(t),F5(r)),o=new F1("3000-01-01T00:00:00.000000Z"),s=o.getTimeInSec();if(e.forEach(e=>{let{AcquisitionDate:t,AcquisitionTime:r}=e,n=F0(F2(t),F5(r));o=o.getTimeInSec()>=s||n.getTimeInSec()<o.getTimeInSec()?n:o}),o.getTimeInSec()>=s)throw Error("Earliest acquisition time or date could not be parsed.");return i.getTimeInSec()<=o.getTimeInSec()?a.fill(i):n?a.fill(F3(n)):a.fill(o)}(e),s=function(e){let t,{RadiopharmaceuticalStartDateTime:r,RadiopharmaceuticalStartTime:n,SeriesDate:a}=e;if(r)return F3(r);if(n&&a)return t=F5(n),F0(F2(a),t);throw Error(`Invalid input: ${e}`)}({RadiopharmaceuticalStartDateTime:n,RadiopharmaceuticalStartTime:a,SeriesDate:i});return e.map((e,n)=>{let a=o[n].getTimeInSec()-s.getTimeInSec();if(a<0)throw Error("Decay time cannot be less than zero");return 1/(t*Math.pow(2,-a/r))})}(e);let c=Array(e.length),d=1e3*o;if("BQML"===a)c=u.map(function(e){return e*d});else if("CNTS"===a){let t=e.every(e=>{var t,r,n;return e.PhilipsPETPrivateGroup&&(null==(t=e.PhilipsPETPrivateGroup)?void 0:t.SUVScaleFactor)!==null&&(null==(r=e.PhilipsPETPrivateGroup)?void 0:r.SUVScaleFactor)!==void 0&&(null==(n=e.PhilipsPETPrivateGroup)?void 0:n.SUVScaleFactor)!==0}),r=e.every(e=>{var t,r,n;return e.PhilipsPETPrivateGroup&&!(null!=(t=e.PhilipsPETPrivateGroup)&&t.SUVScaleFactor)&&(null==(r=e.PhilipsPETPrivateGroup)?void 0:r.ActivityConcentrationScaleFactor)!==void 0&&(null==(n=e.PhilipsPETPrivateGroup)?void 0:n.ActivityConcentrationScaleFactor)!==0});if(t)c=e.map(e=>e.PhilipsPETPrivateGroup.SUVScaleFactor);else if(r)c=e.map((e,t)=>e.PhilipsPETPrivateGroup.ActivityConcentrationScaleFactor*u[t]*d);else throw Error(`Units are in CNTS, but PhilipsPETPrivateGroup has invalid values: ${JSON.stringify(i)}`)}else if("GML"===a)c.fill(1);else throw Error(`Units has an invalid value: ${a}`);return null==l?console.warn("PatientSize value is missing. It is not possible to calculate the SUV bsa factors"):t=function(e){let{PatientWeight:t,PatientSize:r}=e;return Math.pow(t,.425)*Math.pow(100*r,.725)*71.84}({PatientWeight:o,PatientSize:l}),null==l?console.warn("PatientSize value is missing. It is not possible to calculate the SUV lbm factors"):null==s?console.warn("PatientSex value is missing. It is not possible to calculate the SUV lbm factors"):r=function(e){let t,{PatientSex:r,PatientWeight:n,PatientSize:a}=e,i=n*n/(a*a*1e4);if("F"===r)t=1.07*n-148*i;else if("M"===r)t=1.1*n-120*i;else throw Error(`PatientSex is an invalid value: ${r}`);return 1e3*t}({PatientWeight:o,PatientSex:s,PatientSize:l}),c.map(function(e,n){let a={suvbw:e};return t&&(a.suvbsa=u[n]*t),r&&(a.suvlbm=u[n]*r),a})}(egm=egQ||(egQ={})).NOT_APPLICABLE="",egm.ERMF="ERMF",egm.USER="User",egm.PROJECTION="Proj",egm.REGION="Region",egm.ERROR="Error",egm.UNCALIBRATED="Uncalibrated",egm.CALIBRATED="Calibrated",egm.UNKNOWN="Unknown";let F8=egQ;(egg=eg1||(eg1={})).CALIBRATION="calibrationModule",egg.CINE="cineModule",egg.FRAME_OF_REFERENCE="frameOfReferenceModule",egg.GENERAL_IMAGE="generalImageModule",egg.GENERAL_SERIES="generalSeriesModule",egg.GENERAL_STUDY="generalStudyModule",egg.IMAGE_PIXEL="imagePixelModule",egg.IMAGE_PLANE="imagePlaneModule",egg.IMAGE_URL="imageUrlModule",egg.MODALITY_LUT="modalityLutModule",egg.MULTIFRAME="multiframeModule",egg.NM_MULTIFRAME_GEOMETRY="nmMultiframeGeometryModule",egg.OVERLAY_PLANE="overlayPlaneModule",egg.PATIENT="patientModule",egg.PATIENT_DEMOGRAPHIC="patientDemographicModule",egg.PATIENT_STUDY="patientStudyModule",egg.PET_IMAGE="petImageModule",egg.PET_ISOTOPE="petIsotopeModule",egg.PET_SERIES="petSeriesModule",egg.SCALING="scalingModule",egg.SOP_COMMON="sopCommonModule",egg.ULTRASOUND_ENHANCED_REGION="ultrasoundEnhancedRegionModule",egg.ECG="ecgModule",egg.VOI_LUT="voiLutModule",egg.TRANSFER_SYNTAX="transferSyntax",egg.PLANE_ORIENTATION="PlaneOrientation",egg.PLANE_POSITION="PlanePosition",egg.PIXEL_MEASURES="PixelMeasures",egg.XRAY_GEOMETRY="XrayGeometry",egg.FRAME_PIXEL_DATA="FramePixelData",egg.FRAME_MODULE="frameModule",egg.URI_MODULE="uriModule",egg.WADO_WEB_CLIENT="wadoWebClient",egg.INSTANCE="instance",egg.IMAGE_SOP_INSTANCE_REFERENCE="ImageSopInstanceReference",egg.REFERENCED_SERIES_REFERENCE="ReferencedSeriesReference",egg.PREDECESSOR_SEQUENCE="PredecessorSequence",egg.STUDY_DATA="StudyData",egg.SERIES_DATA="SeriesData",egg.IMAGE_DATA="ImageData",egg.RTSS_INSTANCE_DATA="RtssInstanceData",egg.NEW_INSTANCE_DATA="NewInstanceData",egg.RTSS_CONTOUR="metaRTSSContour",egg.SEG_BIT="metaSegBitmap",egg.SR_ANNOTATION="metaSrAnnotation",egg.COMPRESSED_FRAME_DATA="compressedFrameData",egg.BASE_IMAGE_ID="baseImageId",egg.FRAME_IMAGE_IDS="frameImageIds",egg.NATURALIZED="naturalized",egg.DISPLAY_SET="displaySetModule";let F6=eg1,F9={IMPLICIT_VR_LITTLE_ENDIAN:LC.constants.IMPLICIT_LITTLE_ENDIAN,EXPLICIT_VR_LITTLE_ENDIAN:LC.constants.EXPLICIT_LITTLE_ENDIAN,DEFLATED_EXPLICIT_VR_LITTLE_ENDIAN:LC.constants.DEFLATED_EXPLICIT_LITTLE_ENDIAN,EXPLICIT_VR_BIG_ENDIAN:LC.constants.EXPLICIT_BIG_ENDIAN,RLE_LOSSLESS:"1.2.840.10008.1.2.5",MPEG2_MAIN_PROFILE_MAIN_LEVEL:"1.2.840.10008.1.2.4.100",MPEG2_MAIN_PROFILE_MAIN_LEVEL_FRAGMENTABLE:"1.2.840.10008.1.2.4.100.1",MPEG2_MAIN_PROFILE_HIGH_LEVEL:"1.2.840.10008.1.2.4.101",MPEG2_MAIN_PROFILE_HIGH_LEVEL_FRAGMENTABLE:"1.2.840.10008.1.2.4.101.1",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_1:"1.2.840.10008.1.2.4.102",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_1_FRAGMENTABLE:"1.2.840.10008.1.2.4.102.1",MPEG4_AVC_H264_BD_COMPATIBLE_HIGH_PROFILE_LEVEL_4_1:"1.2.840.10008.1.2.4.103",MPEG4_AVC_H264_BD_COMPATIBLE_HIGH_PROFILE_LEVEL_4_1_FRAGMENTABLE:"1.2.840.10008.1.2.4.103.1",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_2D_VIDEO:"1.2.840.10008.1.2.4.104",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_2D_VIDEO_FRAGMENTABLE:"1.2.840.10008.1.2.4.104.1",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_3D_VIDEO:"1.2.840.10008.1.2.4.105",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_3D_VIDEO_FRAGMENTABLE:"1.2.840.10008.1.2.4.105.1",MPEG4_AVC_H264_STEREO_HIGH_PROFILE_LEVEL_4_2:"1.2.840.10008.1.2.4.106",MPEG4_AVC_H264_STEREO_HIGH_PROFILE_LEVEL_4_2_FRAGMENTABLE:"1.2.840.10008.1.2.4.106.1",HEVC_H265_MAIN_PROFILE_LEVEL_5_1:"1.2.840.10008.1.2.4.107",HEVC_H265_MAIN_10_PROFILE_LEVEL_5_1:"1.2.840.10008.1.2.4.108"},F7=[],Ve=new Map,Vt=new Map;function Vr(e,t=0){let r;if(!F7.some(t=>t.provider===e)){for(r=0;r<F7.length&&!(F7[r].priority<=t);r++);F7.splice(r,0,{priority:t,provider:e})}}function Vn(e,t,r){let n=Vt.get(e);if(n)return n(t,null,r)}function Va(e){for(let t=0;t<F7.length;t++)if(F7[t].provider===e){F7.splice(t,1);break}}function Vi(){for(;F7.length>0;)F7.pop();Ve.clear(),Vt.clear()}function Vo(e,t,r){if(void 0!==t)for(let n=0;n<F7.length;n++){let a=F7[n].provider(e,t,r);if(void 0!==a)return a}}function Vs(e,t,r){return Vo(e,t,r)}let Vl=(e,t)=>{var r;for(let n of[e,(r=e,`${r}Add`)]){let e=Ve.get(n);if(e)for(let r of e)r?.clearQuery?.(t)}},Vu=e=>{var t;for(let r of Array.from(new Set([e,(t=e,`${t}Add`)]))){let e=Ve.get(r);if(e)for(let t of e)t?.clear?.()}},Vc=(e,...t)=>1===t.length?Vo(e,t[0]):t.map(t=>t&&Vo(e,t)).find(e=>void 0!==e);function Vd(e,t,r=Vo){let n={};for(let a of t)try{let t=r(a,e);if(t){let e={};for(let r in t)r in t&&(e[Vh(r)]=t[r]);Object.assign(n,e)}}catch(e){console.error(`Error retrieving ${a} data:`,e)}return n}let Vh=e=>e.startsWith("sop")?`SOP${e.substring(3)}`:e.startsWith("voi")?`VOI${e.substring(3)}`:(e.endsWith("Id")&&(e=`${e.substring(0,e.length-2)}ID`),e.charAt(0).toUpperCase()+e.slice(1)),Vp=e=>e.startsWith("SOP")?`sop${e.substring(3)}`:e.startsWith("VOI")?`voi${e.substring(3)}`:(e.endsWith("ID")&&!e.endsWith("UID")&&(e=`${e.substring(0,e.length-2)}Id`),e.charAt(0).toLowerCase()+e.slice(1));function Vf(e,t,r){return Math.abs(e-t)<=r}function Vm(e){return"number"==typeof e}function Vg(e){return e&&"object"==typeof e&&"length"in e&&"number"==typeof e.length&&e.length>0&&"number"==typeof e[0]}function Vy(e,t,r=1e-5){return typeof e==typeof t&&null!==e&&null!==t&&(Vm(e)&&Vm(t)?Vf(e,t,r):!!(Vg(e)&&Vg(t))&&function(e,t,r=1e-5){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Vf(e[n],t[n],r))return!1;return!0}(e,t,r))}let Vv=e=>"number"==typeof e?-e:e?.map?e.map(Vv):!e,Vb=e=>"number"==typeof e?Math.abs(e):e?.map?e.map(Vb):e,Vw=(e,t,r)=>Vy(Vb(e),Vb(t),r),Vx=V_("cs3d"),VC=Vx.getLogger("metadata"),Vk=Vx.getLogger("core"),VM=Vx.getLogger("tools"),VE=Vx.getLogger("dicomImageLoader"),VS=Vx.getLogger("ai"),VD=Vx.getLogger("examples"),VI=Vx.getLogger("worker"),VP=LC.log.getLogger("consistency.dicom"),VT=LC.log.getLogger("consistency.image");function V_(e){let t=LC.log.getLogger(e);return t.getLogger=(...t)=>V_(`${e}.${t.join(".")}`),t}function VA(...e){return V_(e.join("."))}let VO=new Set([F9.MPEG2_MAIN_PROFILE_MAIN_LEVEL,F9.MPEG2_MAIN_PROFILE_MAIN_LEVEL_FRAGMENTABLE,F9.MPEG2_MAIN_PROFILE_HIGH_LEVEL,F9.MPEG2_MAIN_PROFILE_HIGH_LEVEL_FRAGMENTABLE,F9.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_1,F9.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_1_FRAGMENTABLE,F9.MPEG4_AVC_H264_BD_COMPATIBLE_HIGH_PROFILE_LEVEL_4_1,F9.MPEG4_AVC_H264_BD_COMPATIBLE_HIGH_PROFILE_LEVEL_4_1_FRAGMENTABLE,F9.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_2D_VIDEO,F9.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_2D_VIDEO_FRAGMENTABLE,F9.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_3D_VIDEO,F9.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_3D_VIDEO_FRAGMENTABLE,F9.MPEG4_AVC_H264_STEREO_HIGH_PROFILE_LEVEL_4_2,F9.MPEG4_AVC_H264_STEREO_HIGH_PROFILE_LEVEL_4_2_FRAGMENTABLE,F9.HEVC_H265_MAIN_PROFILE_LEVEL_5_1,F9.HEVC_H265_MAIN_10_PROFILE_LEVEL_5_1]);function VR(e){return!!e&&(Array.isArray(e)?e:[e]).find(e=>VO.has(e))}let VL=/^[a-zA-Z]+:/;function VN(e){if(!e)return"";let t=e.match(VL);if(!t)return e;let r=e.substring(t[0].length);return VL.test(r)?r:e}let VF=new Set(["1.2.840.10008.5.1.4.1.1.1","1.2.840.10008.5.1.4.1.1.1.1","1.2.840.10008.5.1.4.1.1.1.1.1","1.2.840.10008.5.1.4.1.1.1.2","1.2.840.10008.5.1.4.1.1.1.2.1","1.2.840.10008.5.1.4.1.1.1.3","1.2.840.10008.5.1.4.1.1.1.3.1","1.2.840.10008.5.1.4.1.1.12.1","1.2.840.10008.5.1.4.1.1.12.1.1","1.2.840.10008.5.1.4.1.1.12.2","1.2.840.10008.5.1.4.1.1.12.2.1","1.2.840.10008.5.1.4.1.1.12.3"]);function VV(e){let{PixelSpacing:t,ImagerPixelSpacing:r,EstimatedRadiographicMagnificationFactor:n,DistanceSourceToDetector:a,DistanceSourceToEntrance:i,DistanceSourceToPatient:o=i}=e;return n>1?n:o<a?a/o:r?.[0]>t?.[0]||void 0}function VB(e){let{PixelSpacing:t,ImagerPixelSpacing:r,PixelSpacingCalibrationType:n}=e;if(t&&"GEOMETRY"===n)return Vy(t,r)&&console.warn("Calibration type is geometry, but pixel spacing and imager pixel spacing identical",t,r),{PixelSpacing:t,type:F8.ERMF,isProjection:!0};if(t&&"FIDUCIAL"===n)return{PixelSpacing:t,type:F8.CALIBRATED,isProjection:!0};if(r){let n=VV(e);return n>1?{PixelSpacing:r.map(e=>e/n),type:F8.ERMF,isProjection:!0}:!0===n?{PixelSpacing:t,type:F8.ERMF,isProjection:!0}:(n&&console.error("Illegal ERMF value:",n),{PixelSpacing:t||r,type:F8.PROJECTION,isProjection:!0})}return{PixelSpacing:t,type:F8.UNKNOWN,isProjection:!0}}function Vj(e){let{PixelSpacing:t,SOPClassUID:r}=e;return VF.has(r)?VB(e):{PixelSpacing:t,type:F8.NOT_APPLICABLE,isProjection:!1}}let VW=new Map,VU={add:(e,t)=>{let r=VN(e);VW.set(r,t),Vl(F6.IMAGE_PLANE,e)},get:(e,t)=>{if("calibratedPixelSpacing"===e){let e=VN(t);return VW.get(e)}},clear:()=>{VW.clear()}};function Vz(e,t){let r=/\/frames\/\d+/,n=/([?&])frame=\d+/;if(r.test(e))return e.replace(r,`/frames/${t}`);if(n.test(e))return e.replace(n,(e,r)=>`${r}frame=${t}`);let a=e.includes("?")?"&":"?";return`${e}${a}frame=${t}`}function VH(e){if(!e||0===e.length)return null;let t=e[0],r=Vc("instance",t);if(!r)return null;let n=r.NumberOfFrames;if(!n||n<=1)return null;let a=r.TimeSlotVector;if(!a||!Array.isArray(a))return null;let i=r.SliceVector,o=r.NumberOfSlices;if(a.length!==n)return console.warn("TimeSlotVector length does not match NumberOfFrames:",a.length,"vs",n),null;if(i){if(!Array.isArray(i))return console.warn("SliceVector exists but is not an array. Expected length:",n),null;if(i.length!==n||i.some(e=>void 0===e))return console.warn("SliceVector exists but has invalid length or undefined entries. Expected length:",n,"Actual length:",i.length),null}let s=new Map;for(let e=0;e<n;e++){let t=a[e],r=i?.[e]??e;s.has(t)||s.set(t,[]),s.get(t).push({frameIndex:e,sliceIndex:r})}let l=Array.from(s.keys()).sort((e,t)=>e-t).map(e=>{let r=s.get(e);return r.sort((e,t)=>e.sliceIndex-t.sliceIndex),r.map(e=>Vz(t,e.frameIndex+1))}),u=o||l[0]?.length;return l.every(e=>e.length===u)||console.warn("Multiframe 4D split resulted in uneven time slot groups. Expected",u,"slices per time slot."),{imageIdGroups:l,splittingTag:"TimeSlotVector"}}function VG(e,t){let r=Vc(t,e);try{return parseFloat(r)}catch{return}}function Vq(e,t){var r=VG(e,t);if(void 0!==r){if("string"==typeof r||"number"==typeof r||r instanceof String||r instanceof Number){let e=Number(r);return Number.isFinite(e)?e:void 0}return Array.from(r,e=>{let t=Number(e);return Number.isFinite(t)?t:void 0})}}function V$(e){let t=Vc("20011003",e);try{let{InlineBinary:e}=t;if(e){let t=atob(e),r=new ArrayBuffer(t.length),n=new DataView(r);for(let e=0;e<t.length;e++)n.setUint8(e,t.charCodeAt(e));return new Float32Array(r)[0]}return parseFloat(t)}catch{return}}function VK(e){let t=Vc("0019100c",e)||Vc("0019100C",e);try{let{InlineBinary:e}=t;return e&&(t=atob(e)),parseFloat(t)}catch{return}}function VY(e){let t=Vc("00431039",e);try{let{InlineBinary:e}=t;return e&&(t=atob(e).split("//")),parseFloat(t[0])%1e5}catch{return}}function VX(e){let t=Vc("petImageModule",e);return t?t.frameReferenceTime:0}let VZ=function(e){let t=VH(e);if(t)return t;let r=function(e){let t;if(!e||0===e.length||void 0===Vq(e[0],"CardiacNumberOfImages"))return null;let r=new Map;for(let t of e){let e=Vc("StackID",t),n=Vq(t,"InStackPositionNumber"),a=Vq(t,"TriggerTime");if(void 0===e||void 0===n||void 0===a)return null;let i=String(e);r.has(i)||r.set(i,new Map);let o=r.get(i);o.has(n)||o.set(n,[]),o.get(n).push({imageId:t,triggerTime:a})}let n=Array.from(r.keys()).sort((e,t)=>Number(e)-Number(t));if(0===n.length)return null;let a=[];for(let e of n){let n=r.get(e),i=Array.from(n.keys()).sort((e,t)=>e-t);for(let e of i){let r=n.get(e);if(r.sort((e,t)=>e.triggerTime-t.triggerTime),void 0===t)t=r.length;else if(r.length!==t)return null}a.push({stackId:e,positions:i,framesByPosition:n})}if(!t)return null;let i=[];for(let e=0;e<t;e++){let t=[];for(let r of a)for(let n of r.positions){let a=r.framesByPosition.get(n);t.push(a[e].imageId)}i.push(t)}return{imageIdGroups:i,splittingTag:"CardiacTriggerTime"}}(e);if(r)return r;let n=function(e){let t,r=e.map(e=>{let{imagePositionPatient:t}=Vc("imagePlaneModule",e)||{};return{imageId:e,imagePositionPatient:t}});if(!r.every(e=>e.imagePositionPatient))return null;let n=(t="imagePositionPatient",r.reduce((e,r)=>((e[r[t]]=e[r[t]]||[]).push(r),e),{})),a=Object.keys(n),i=n[a[0]].length;return 1!==i&&a.every(e=>n[e].length===i)?n:null}(e);if(!n)return{imageIdGroups:[e],splittingTag:null};let a=["TemporalPositionIdentifier","DiffusionBValue","TriggerTime","EchoTime","EchoNumber","PhilipsPrivateBValue","SiemensPrivateBValue","GEPrivateBValue","PetFrameReferenceTime"],i=[e=>VG(e,a[0]),e=>VG(e,a[1]),e=>VG(e,a[2]),e=>VG(e,a[3]),e=>VG(e,a[4]),V$,VK,VY,VX];for(let e=0;e<i.length;e++){let t=function(e,t){let r={},n=[],a=Object.keys(e);for(let i=0;i<a.length;i++){let o=new Set,s=e[a[i]];for(let e=0;e<s.length;e++){let n=t(s[e].imageId)||0;if(r[n]=r[n]||[],r[n].push({imageId:s[e].imageId}),o.add(n),o.size-1<e)return}if(0==i)n=Array.from(o);else if(!function(e,t){if(e.length!=t.size)return!1;for(let r=0;r<e.length;r++)if(!t.has(e[r]))return!1;return!0}(n,o))return}return r}(n,i[e]);if(t)return{imageIdGroups:Object.keys(t).map(Number.parseFloat).sort((e,t)=>e-t).map(e=>t[e].map(e=>e.imageId)),splittingTag:a[e]}}return{imageIdGroups:[e],splittingTag:null}},VJ=[[F6.TRANSFER_SYNTAX,["TransferSyntaxUID","AvailableTransferSyntaxUID"]],[F6.CINE,["FrameTime","RecommendedDisplayFrameRate"]],[F6.PET_ISOTOPE,[["RadiopharmaceuticalInfo","00540016"]]],["RadiopharmaceuticalInfo",["RadiopharmaceuticalStartTime","RadiopharmaceuticalStopTime","RadionuclideTotalDose","RadionuclideHalfLife"]],[F6.PET_IMAGE,["FrameReferenceTime","ActualFrameDuration"]],[F6.PET_SERIES,["CorrectedImage","Units","DecayCorrection"]],[F6.PATIENT,["PatientID","PatientName","PatientBirthDate","PatientBirthTime"]],[F6.PATIENT_STUDY,["PatientAge","PatientSize","PatientSex","PatientWeight"]],[F6.GENERAL_STUDY,["StudyInstanceUID","StudyDescription","StudyDate","StudyTime","AccessionNumber"]],[F6.GENERAL_SERIES,["StudyInstanceUID","SeriesInstanceUID","Modality","SeriesDescription","SeriesNumber","SeriesDate","SeriesTime","AcquisitionDate","AcquisitionTime"]],["clinicalTrialModule",["ClinicalTrialSponsorName","ClinicalTrialSiteID","ClinicalTrialSiteName","ClinicalTrialSubjectID"]],[F6.SOP_COMMON,["SOPInstanceUID","SOPClassUID"]],[F6.ECG,["StudyInstanceUID","SeriesInstanceUID","SeriesDescription","SeriesNumber","SeriesDate","SeriesTime","Modality","SOPInstanceUID","SOPClassUID"]],[F6.GENERAL_IMAGE,["SOPInstanceUID","SOPClassUID","InstanceNumber","InstanceCreationDate","InstanceCreationTime","ContentTime","LossyImageCompression","LossyImageCompressionRatio","LossyImageCompressionMethod","FrameOfReferenceUID","NumberOfFrames","PixelSpacing"]],[F6.IMAGE_PLANE,["ImagerPixelSpacing","ImageOrientationPatient","ImagePositionPatient","SpacingBetweenSlices","SliceThickness","SliceLocation"]],[F6.IMAGE_PIXEL,["SamplesPerPixel","PhotometricInterpretation","PlanarConfiguration","Rows","Columns","BitsAllocated","BitsStored","HighBit","PixelRepresentation",["SmallestPixelValue","00280106"],["LargestPixelValue","00280107"],"PixelPaddingValue","PixelPaddingRangeLimit","RedPaletteColorLookupTableDescriptor","GreenPaletteColorLookupTableDescriptor","BluePaletteColorLookupTableDescriptor","AlphaPaletteColorLookupTableDescriptor","RedPaletteColorLookupTableData","GreenPaletteColorLookupTableData","BluePaletteColorLookupTableData","AlphaPaletteColorLookupTableData","PaletteColorLookupTableUID","DistanceSourceToDetector","DistanceSourceToPatient","EstimatedRadiographicMagnificationFactor","DistanceSourceToEntrance","PixelSpacingCalibrationType","PixelSpacingCalibrationDescription","SequenceOfUltrasoundRegions"]],[F6.VOI_LUT,["WindowCenter","WindowWidth","VOILUTFunction","WindowCenterWidthExplanation"]],[F6.MODALITY_LUT,["RescaleIntercept","RescaleSlope","RescaleType"]],[F6.ULTRASOUND_ENHANCED_REGION,["SequenceOfUltrasoundRegions"]],["usRegionChild",["PhysicalDeltaX","PhysicalDeltaY","PhysicalUnitsXDirection","PhysicalUnitsYDirection","RegionLocationMinY0","RegionLocationMaxY1","RegionLocationMinX0","RegionLocationMaxX1","ReferencePixelX0","ReferencePixelY0",["ReferencePhysicalPixelValueY","0018602A"],["ReferencePhysicalPixelValueX","00186028"],"RegionSpatialFormat","RegionDataType","RegionFlags","TransducerFrequency"]],[null,["ReferencedImageSequence","ReferencedSOPClassUID","ReferencedSOPInstanceUID","ReferencedFrameNumber","SharedFunctionalGroupsSequence","PerFrameFunctionalGroupsSequence","PlanePositionSequence","AnatomicRegionSequence","PlaneOrientationSequence","PixelMeasuresSequence","PixelValueTransformationSequence","ParametricMapFrameTypeSequence","RealWorldValueMappingSequence"]]],VQ=LC.data.DicomMetaDictionary.dictionary,V1=LC.data.DicomMetaDictionary.nameMap,V0=new Map,V2=new Map,V5={},V3=new Map;for(let[e,t]of VJ)for(let r of t){let t="string"==typeof r?r:r[0],n="string"==typeof r?void 0:r[1],a=V3.get(t);a||(a={hex:n??function(e){let t=V1[e];if(t)return t.tag.substring(1,5)+t.tag.substring(6,10)}(t),groups:[]},V3.set(t,a)),null!==e&&a.groups.push(e)}for(let[e,{hex:t,groups:r}]of V3){if(!t){console.warn(`Tags: keyword "${e}" not found in dcmjs nameMap`);continue}!function(e,t){if(e&&t.name&&e!==t.name)throw Error(`Tag name provided and value don't match: ${e} !== ${t.name}`);t.name||=e,t.lowerName||=Vp(e),V5[e]=t;let{tag:r}=t;t.primaryGroup||=t.groups?.[0];let{groups:n}=t;if(V2.set(e,t),r&&(t.xTag=`x${r.toLowerCase()}`,t.tag=r.toUpperCase(),V2.set(t.xTag,t),V2.set(t.tag,t),!t.vr)){let e=VQ[t.tag];e&&(t.vr=e.vr,t.vm=function(e){if(null==e)return null;if("number"==typeof e)return e;let t=parseInt(e,10);return String(t)===e?t:0}(e.vm))}if(n?.length)for(let r of n){let n=V0.get(r);if(!n){n=[t],V0.set(r,n);return}let a=n.findIndex(t=>t.name===e);-1===a?n.push(t):n[a]=t}}(e,function(e,...t){return{tag:e,groups:t,xTag:null,primaryGroup:null,name:null,lowerName:null,vr:null,vm:null}}(t,...r))}let{DicomMetadataListener:V4}=LC.utilities,{pp:V8,tZ:V6,gE:V9,Um:V7,uu:Be,UA:Bt,_E:Br,RZ:Bn,UX:Ba,bM:Bi,HL:Bo,U5:Bs,Rm:Bl}=ee,Bu=F6.FRAME_IMAGE_IDS,Bc=F6.BASE_IMAGE_ID;class Bd{static setCacheDataInternal(e,t,r){let n=this.mapCacheData.get(e);n||(n=new Map,this.mapCacheData.set(e,n)),n.set(t,r),this.clearRelatedDerivedCache(e,t)}static clearRelatedDerivedCache(e,t){let r=this.secondaryTypesByBaseType.get(e);if(r?.size)for(let e of Vo(Bu,t)??new Set([t]))for(let t of r){let r=this.mapCacheData.get(t);r?.delete(e)}}static registerSecondaryTypes(e,t){if(t)for(let r of Array.isArray(t)?t:[t]){let t=this.secondaryTypesByBaseType.get(r);t||(t=new Set,this.secondaryTypesByBaseType.set(r,t)),t.add(e)}}static getCacheData(e,t){return this.mapCacheData.get(e)?.get(t)}static hasCacheData(e,t){return this.mapCacheData.get(e)?.has(t)===!0}static clearCacheData(){this.mapCacheData.clear(),this.secondaryTypesByBaseType.clear(),Vu(Bu),Vu(Bc)}static clearTypedCacheData(e,t){let r=this.secondaryTypesByBaseType.get(e),n=this.mapCacheData.get(e);if(t){if(n?.delete(t),r?.size)for(let e of r)this.mapCacheData.get(e)?.delete(t);(e===F6.NATURALIZED||r?.size)&&(Vl(Bu,t),Vl(Bc,t));return}if(n?.clear(),r?.size)for(let e of r)this.mapCacheData.get(e)?.clear();(e===F6.NATURALIZED||r?.size)&&(Vu(Bu),Vu(Bc))}static fromAsyncLookup(e,t,r,n){if(n?.noCache!==!0&&n?.reCache!==!0){let r=this.getCacheData(e,t);if(void 0!==r)return r}let a=r();if(void 0!==a)return a instanceof Promise?a.then(r=>(void 0===r||n?.noCache||this.setCacheDataInternal(e,t,r),r)):(n?.noCache||this.setCacheDataInternal(e,t,a),a)}createTypeCacheProvider(e){var t;return t=e,(e,r,n,a)=>Bd.fromAsyncLookup(t,r,()=>e(r,n,a),a)}clearCacheData(){Bd.clearCacheData()}clearTypedCacheData(e,t){Bd.clearTypedCacheData(e,t)}getCacheData(e,t){return Bd.getCacheData(e,t)}hasCacheData(e,t){return Bd.hasCacheData(e,t)}fromAsyncLookup(e,t,r,n){return Bd.fromAsyncLookup(e,t,r,n)}}function Bh(e){return(t,r,n,a)=>(n||=Vn(e,r,a?.[e]),t(r,n,a))}Bd.mapCacheData=new Map,Bd.secondaryTypesByBaseType=new Map,new class e extends Bd{static setCacheData(e,t,r){this.setCacheDataInternal(e,t,r)}setCacheData(t,r,n){e.setCacheData(t,r,n)}},Bh(F6.INSTANCE),Bh(F6.NATURALIZED);let{AsyncDicomReader:Bp}=LC.async;V7.getLogger("tagModules"),F6.COMPRESSED_FRAME_DATA;let{C:Bf}=J;(egy=eg0||(eg0={})).NO_DATA="noData",egy.LOADING="loading",egy.PRE_RENDER="preRender",egy.NEEDS_RENDER="needsRender",egy.RESIZE="resize",egy.RENDERED="rendered";let Bm=eg0;(egv=eg2||(eg2={}))[egv.FAR_REPLICATE=1]="FAR_REPLICATE",egv[egv.ADJACENT_REPLICATE=3]="ADJACENT_REPLICATE",egv[egv.SUBRESOLUTION=6]="SUBRESOLUTION",egv[egv.LOSSY=7]="LOSSY",egv[egv.FULL_RESOLUTION=8]="FULL_RESOLUTION";let Bg=eg2;(egb=eg5||(eg5={})).FRAME="f",egb.SECOND="s";let By=F6;(egw=eg3||(eg3={})).SUM="SUM",egw.SUBTRACT="SUBTRACT",egw.AVERAGE="AVERAGE",(egx=eg4||(eg4={})).RLE="RLE",egx.Volume="Volume",(egC=eg8||(eg8={})).Tiled="tiled",egC.ContextPool="contextPool";let Bv=eg8,Bb={Auto:"auto",GPU:"gpu",CPU:"cpu"},Bw=Bb,Bx={hotIron:{name:"Hot Iron",numOfColors:256,colors:[[0,0,0,255],[2,0,0,255],[4,0,0,255],[6,0,0,255],[8,0,0,255],[10,0,0,255],[12,0,0,255],[14,0,0,255],[16,0,0,255],[18,0,0,255],[20,0,0,255],[22,0,0,255],[24,0,0,255],[26,0,0,255],[28,0,0,255],[30,0,0,255],[32,0,0,255],[34,0,0,255],[36,0,0,255],[38,0,0,255],[40,0,0,255],[42,0,0,255],[44,0,0,255],[46,0,0,255],[48,0,0,255],[50,0,0,255],[52,0,0,255],[54,0,0,255],[56,0,0,255],[58,0,0,255],[60,0,0,255],[62,0,0,255],[64,0,0,255],[66,0,0,255],[68,0,0,255],[70,0,0,255],[72,0,0,255],[74,0,0,255],[76,0,0,255],[78,0,0,255],[80,0,0,255],[82,0,0,255],[84,0,0,255],[86,0,0,255],[88,0,0,255],[90,0,0,255],[92,0,0,255],[94,0,0,255],[96,0,0,255],[98,0,0,255],[100,0,0,255],[102,0,0,255],[104,0,0,255],[106,0,0,255],[108,0,0,255],[110,0,0,255],[112,0,0,255],[114,0,0,255],[116,0,0,255],[118,0,0,255],[120,0,0,255],[122,0,0,255],[124,0,0,255],[126,0,0,255],[128,0,0,255],[130,0,0,255],[132,0,0,255],[134,0,0,255],[136,0,0,255],[138,0,0,255],[140,0,0,255],[142,0,0,255],[144,0,0,255],[146,0,0,255],[148,0,0,255],[150,0,0,255],[152,0,0,255],[154,0,0,255],[156,0,0,255],[158,0,0,255],[160,0,0,255],[162,0,0,255],[164,0,0,255],[166,0,0,255],[168,0,0,255],[170,0,0,255],[172,0,0,255],[174,0,0,255],[176,0,0,255],[178,0,0,255],[180,0,0,255],[182,0,0,255],[184,0,0,255],[186,0,0,255],[188,0,0,255],[190,0,0,255],[192,0,0,255],[194,0,0,255],[196,0,0,255],[198,0,0,255],[200,0,0,255],[202,0,0,255],[204,0,0,255],[206,0,0,255],[208,0,0,255],[210,0,0,255],[212,0,0,255],[214,0,0,255],[216,0,0,255],[218,0,0,255],[220,0,0,255],[222,0,0,255],[224,0,0,255],[226,0,0,255],[228,0,0,255],[230,0,0,255],[232,0,0,255],[234,0,0,255],[236,0,0,255],[238,0,0,255],[240,0,0,255],[242,0,0,255],[244,0,0,255],[246,0,0,255],[248,0,0,255],[250,0,0,255],[252,0,0,255],[254,0,0,255],[255,0,0,255],[255,2,0,255],[255,4,0,255],[255,6,0,255],[255,8,0,255],[255,10,0,255],[255,12,0,255],[255,14,0,255],[255,16,0,255],[255,18,0,255],[255,20,0,255],[255,22,0,255],[255,24,0,255],[255,26,0,255],[255,28,0,255],[255,30,0,255],[255,32,0,255],[255,34,0,255],[255,36,0,255],[255,38,0,255],[255,40,0,255],[255,42,0,255],[255,44,0,255],[255,46,0,255],[255,48,0,255],[255,50,0,255],[255,52,0,255],[255,54,0,255],[255,56,0,255],[255,58,0,255],[255,60,0,255],[255,62,0,255],[255,64,0,255],[255,66,0,255],[255,68,0,255],[255,70,0,255],[255,72,0,255],[255,74,0,255],[255,76,0,255],[255,78,0,255],[255,80,0,255],[255,82,0,255],[255,84,0,255],[255,86,0,255],[255,88,0,255],[255,90,0,255],[255,92,0,255],[255,94,0,255],[255,96,0,255],[255,98,0,255],[255,100,0,255],[255,102,0,255],[255,104,0,255],[255,106,0,255],[255,108,0,255],[255,110,0,255],[255,112,0,255],[255,114,0,255],[255,116,0,255],[255,118,0,255],[255,120,0,255],[255,122,0,255],[255,124,0,255],[255,126,0,255],[255,128,4,255],[255,130,8,255],[255,132,12,255],[255,134,16,255],[255,136,20,255],[255,138,24,255],[255,140,28,255],[255,142,32,255],[255,144,36,255],[255,146,40,255],[255,148,44,255],[255,150,48,255],[255,152,52,255],[255,154,56,255],[255,156,60,255],[255,158,64,255],[255,160,68,255],[255,162,72,255],[255,164,76,255],[255,166,80,255],[255,168,84,255],[255,170,88,255],[255,172,92,255],[255,174,96,255],[255,176,100,255],[255,178,104,255],[255,180,108,255],[255,182,112,255],[255,184,116,255],[255,186,120,255],[255,188,124,255],[255,190,128,255],[255,192,132,255],[255,194,136,255],[255,196,140,255],[255,198,144,255],[255,200,148,255],[255,202,152,255],[255,204,156,255],[255,206,160,255],[255,208,164,255],[255,210,168,255],[255,212,172,255],[255,214,176,255],[255,216,180,255],[255,218,184,255],[255,220,188,255],[255,222,192,255],[255,224,196,255],[255,226,200,255],[255,228,204,255],[255,230,208,255],[255,232,212,255],[255,234,216,255],[255,236,220,255],[255,238,224,255],[255,240,228,255],[255,242,232,255],[255,244,236,255],[255,246,240,255],[255,248,244,255],[255,250,248,255],[255,252,252,255],[255,255,255,255]]},pet:{name:"PET",numColors:256,colors:[[0,0,0,255],[0,2,1,255],[0,4,3,255],[0,6,5,255],[0,8,7,255],[0,10,9,255],[0,12,11,255],[0,14,13,255],[0,16,15,255],[0,18,17,255],[0,20,19,255],[0,22,21,255],[0,24,23,255],[0,26,25,255],[0,28,27,255],[0,30,29,255],[0,32,31,255],[0,34,33,255],[0,36,35,255],[0,38,37,255],[0,40,39,255],[0,42,41,255],[0,44,43,255],[0,46,45,255],[0,48,47,255],[0,50,49,255],[0,52,51,255],[0,54,53,255],[0,56,55,255],[0,58,57,255],[0,60,59,255],[0,62,61,255],[0,65,63,255],[0,67,65,255],[0,69,67,255],[0,71,69,255],[0,73,71,255],[0,75,73,255],[0,77,75,255],[0,79,77,255],[0,81,79,255],[0,83,81,255],[0,85,83,255],[0,87,85,255],[0,89,87,255],[0,91,89,255],[0,93,91,255],[0,95,93,255],[0,97,95,255],[0,99,97,255],[0,101,99,255],[0,103,101,255],[0,105,103,255],[0,107,105,255],[0,109,107,255],[0,111,109,255],[0,113,111,255],[0,115,113,255],[0,117,115,255],[0,119,117,255],[0,121,119,255],[0,123,121,255],[0,125,123,255],[0,128,125,255],[1,126,127,255],[3,124,129,255],[5,122,131,255],[7,120,133,255],[9,118,135,255],[11,116,137,255],[13,114,139,255],[15,112,141,255],[17,110,143,255],[19,108,145,255],[21,106,147,255],[23,104,149,255],[25,102,151,255],[27,100,153,255],[29,98,155,255],[31,96,157,255],[33,94,159,255],[35,92,161,255],[37,90,163,255],[39,88,165,255],[41,86,167,255],[43,84,169,255],[45,82,171,255],[47,80,173,255],[49,78,175,255],[51,76,177,255],[53,74,179,255],[55,72,181,255],[57,70,183,255],[59,68,185,255],[61,66,187,255],[63,64,189,255],[65,63,191,255],[67,61,193,255],[69,59,195,255],[71,57,197,255],[73,55,199,255],[75,53,201,255],[77,51,203,255],[79,49,205,255],[81,47,207,255],[83,45,209,255],[85,43,211,255],[86,41,213,255],[88,39,215,255],[90,37,217,255],[92,35,219,255],[94,33,221,255],[96,31,223,255],[98,29,225,255],[100,27,227,255],[102,25,229,255],[104,23,231,255],[106,21,233,255],[108,19,235,255],[110,17,237,255],[112,15,239,255],[114,13,241,255],[116,11,243,255],[118,9,245,255],[120,7,247,255],[122,5,249,255],[124,3,251,255],[126,1,253,255],[128,0,255,255],[130,2,252,255],[132,4,248,255],[134,6,244,255],[136,8,240,255],[138,10,236,255],[140,12,232,255],[142,14,228,255],[144,16,224,255],[146,18,220,255],[148,20,216,255],[150,22,212,255],[152,24,208,255],[154,26,204,255],[156,28,200,255],[158,30,196,255],[160,32,192,255],[162,34,188,255],[164,36,184,255],[166,38,180,255],[168,40,176,255],[170,42,172,255],[171,44,168,255],[173,46,164,255],[175,48,160,255],[177,50,156,255],[179,52,152,255],[181,54,148,255],[183,56,144,255],[185,58,140,255],[187,60,136,255],[189,62,132,255],[191,64,128,255],[193,66,124,255],[195,68,120,255],[197,70,116,255],[199,72,112,255],[201,74,108,255],[203,76,104,255],[205,78,100,255],[207,80,96,255],[209,82,92,255],[211,84,88,255],[213,86,84,255],[215,88,80,255],[217,90,76,255],[219,92,72,255],[221,94,68,255],[223,96,64,255],[225,98,60,255],[227,100,56,255],[229,102,52,255],[231,104,48,255],[233,106,44,255],[235,108,40,255],[237,110,36,255],[239,112,32,255],[241,114,28,255],[243,116,24,255],[245,118,20,255],[247,120,16,255],[249,122,12,255],[251,124,8,255],[253,126,4,255],[255,128,0,255],[255,130,4,255],[255,132,8,255],[255,134,12,255],[255,136,16,255],[255,138,20,255],[255,140,24,255],[255,142,28,255],[255,144,32,255],[255,146,36,255],[255,148,40,255],[255,150,44,255],[255,152,48,255],[255,154,52,255],[255,156,56,255],[255,158,60,255],[255,160,64,255],[255,162,68,255],[255,164,72,255],[255,166,76,255],[255,168,80,255],[255,170,85,255],[255,172,89,255],[255,174,93,255],[255,176,97,255],[255,178,101,255],[255,180,105,255],[255,182,109,255],[255,184,113,255],[255,186,117,255],[255,188,121,255],[255,190,125,255],[255,192,129,255],[255,194,133,255],[255,196,137,255],[255,198,141,255],[255,200,145,255],[255,202,149,255],[255,204,153,255],[255,206,157,255],[255,208,161,255],[255,210,165,255],[255,212,170,255],[255,214,174,255],[255,216,178,255],[255,218,182,255],[255,220,186,255],[255,222,190,255],[255,224,194,255],[255,226,198,255],[255,228,202,255],[255,230,206,255],[255,232,210,255],[255,234,214,255],[255,236,218,255],[255,238,222,255],[255,240,226,255],[255,242,230,255],[255,244,234,255],[255,246,238,255],[255,248,242,255],[255,250,246,255],[255,252,250,255],[255,255,255,255]]},hotMetalBlue:{name:"Hot Metal Blue",numColors:256,colors:[[0,0,0,255],[0,0,2,255],[0,0,4,255],[0,0,6,255],[0,0,8,255],[0,0,10,255],[0,0,12,255],[0,0,14,255],[0,0,16,255],[0,0,17,255],[0,0,19,255],[0,0,21,255],[0,0,23,255],[0,0,25,255],[0,0,27,255],[0,0,29,255],[0,0,31,255],[0,0,33,255],[0,0,35,255],[0,0,37,255],[0,0,39,255],[0,0,41,255],[0,0,43,255],[0,0,45,255],[0,0,47,255],[0,0,49,255],[0,0,51,255],[0,0,53,255],[0,0,55,255],[0,0,57,255],[0,0,59,255],[0,0,61,255],[0,0,63,255],[0,0,65,255],[0,0,67,255],[0,0,69,255],[0,0,71,255],[0,0,73,255],[0,0,75,255],[0,0,77,255],[0,0,79,255],[0,0,81,255],[0,0,83,255],[0,0,84,255],[0,0,86,255],[0,0,88,255],[0,0,90,255],[0,0,92,255],[0,0,94,255],[0,0,96,255],[0,0,98,255],[0,0,100,255],[0,0,102,255],[0,0,104,255],[0,0,106,255],[0,0,108,255],[0,0,110,255],[0,0,112,255],[0,0,114,255],[0,0,116,255],[0,0,117,255],[0,0,119,255],[0,0,121,255],[0,0,123,255],[0,0,125,255],[0,0,127,255],[0,0,129,255],[0,0,131,255],[0,0,133,255],[0,0,135,255],[0,0,137,255],[0,0,139,255],[0,0,141,255],[0,0,143,255],[0,0,145,255],[0,0,147,255],[0,0,149,255],[0,0,151,255],[0,0,153,255],[0,0,155,255],[0,0,157,255],[0,0,159,255],[0,0,161,255],[0,0,163,255],[0,0,165,255],[0,0,167,255],[3,0,169,255],[6,0,171,255],[9,0,173,255],[12,0,175,255],[15,0,177,255],[18,0,179,255],[21,0,181,255],[24,0,183,255],[26,0,184,255],[29,0,186,255],[32,0,188,255],[35,0,190,255],[38,0,192,255],[41,0,194,255],[44,0,196,255],[47,0,198,255],[50,0,200,255],[52,0,197,255],[55,0,194,255],[57,0,191,255],[59,0,188,255],[62,0,185,255],[64,0,182,255],[66,0,179,255],[69,0,176,255],[71,0,174,255],[74,0,171,255],[76,0,168,255],[78,0,165,255],[81,0,162,255],[83,0,159,255],[85,0,156,255],[88,0,153,255],[90,0,150,255],[93,2,144,255],[96,4,138,255],[99,6,132,255],[102,8,126,255],[105,9,121,255],[108,11,115,255],[111,13,109,255],[114,15,103,255],[116,17,97,255],[119,19,91,255],[122,21,85,255],[125,23,79,255],[128,24,74,255],[131,26,68,255],[134,28,62,255],[137,30,56,255],[140,32,50,255],[143,34,47,255],[146,36,44,255],[149,38,41,255],[152,40,38,255],[155,41,35,255],[158,43,32,255],[161,45,29,255],[164,47,26,255],[166,49,24,255],[169,51,21,255],[172,53,18,255],[175,55,15,255],[178,56,12,255],[181,58,9,255],[184,60,6,255],[187,62,3,255],[190,64,0,255],[194,66,0,255],[198,68,0,255],[201,70,0,255],[205,72,0,255],[209,73,0,255],[213,75,0,255],[217,77,0,255],[221,79,0,255],[224,81,0,255],[228,83,0,255],[232,85,0,255],[236,87,0,255],[240,88,0,255],[244,90,0,255],[247,92,0,255],[251,94,0,255],[255,96,0,255],[255,98,3,255],[255,100,6,255],[255,102,9,255],[255,104,12,255],[255,105,15,255],[255,107,18,255],[255,109,21,255],[255,111,24,255],[255,113,26,255],[255,115,29,255],[255,117,32,255],[255,119,35,255],[255,120,38,255],[255,122,41,255],[255,124,44,255],[255,126,47,255],[255,128,50,255],[255,130,53,255],[255,132,56,255],[255,134,59,255],[255,136,62,255],[255,137,65,255],[255,139,68,255],[255,141,71,255],[255,143,74,255],[255,145,76,255],[255,147,79,255],[255,149,82,255],[255,151,85,255],[255,152,88,255],[255,154,91,255],[255,156,94,255],[255,158,97,255],[255,160,100,255],[255,162,103,255],[255,164,106,255],[255,166,109,255],[255,168,112,255],[255,169,115,255],[255,171,118,255],[255,173,121,255],[255,175,124,255],[255,177,126,255],[255,179,129,255],[255,181,132,255],[255,183,135,255],[255,184,138,255],[255,186,141,255],[255,188,144,255],[255,190,147,255],[255,192,150,255],[255,194,153,255],[255,196,156,255],[255,198,159,255],[255,200,162,255],[255,201,165,255],[255,203,168,255],[255,205,171,255],[255,207,174,255],[255,209,176,255],[255,211,179,255],[255,213,182,255],[255,215,185,255],[255,216,188,255],[255,218,191,255],[255,220,194,255],[255,222,197,255],[255,224,200,255],[255,226,203,255],[255,228,206,255],[255,229,210,255],[255,231,213,255],[255,233,216,255],[255,235,219,255],[255,237,223,255],[255,239,226,255],[255,240,229,255],[255,242,232,255],[255,244,236,255],[255,246,239,255],[255,248,242,255],[255,250,245,255],[255,251,249,255],[255,253,252,255],[255,255,255,255]]},pet20Step:{name:"PET 20 Step",numColors:256,colors:[[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255]]},gray:{name:"Gray",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,1,1]],green:[[0,0,0],[1,1,1]],blue:[[0,0,0],[1,1,1]]}},jet:{name:"Jet",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.35,0,0],[.66,1,1],[.89,1,1],[1,.5,.5]],green:[[0,0,0],[.125,0,0],[.375,1,1],[.64,1,1],[.91,0,0],[1,0,0]],blue:[[0,.5,.5],[.11,1,1],[.34,1,1],[.65,0,0],[1,0,0]]}},hsv:{name:"HSV",numColors:256,gamma:1,segmentedData:{red:[[0,1,1],[.15873,1,1],[.174603,.96875,.96875],[.333333,.03125,.03125],[.349206,0,0],[.666667,0,0],[.68254,.03125,.03125],[.84127,.96875,.96875],[.857143,1,1],[1,1,1]],green:[[0,0,0],[.15873,.9375,.9375],[.174603,1,1],[.507937,1,1],[.666667,.0625,.0625],[.68254,0,0],[1,0,0]],blue:[[0,0,0],[.333333,0,0],[.349206,.0625,.0625],[.507937,1,1],[.84127,1,1],[.857143,.9375,.9375],[1,.09375,.09375]]}},hot:{name:"Hot",numColors:256,gamma:1,segmentedData:{red:[[0,.0416,.0416],[.365079,1,1],[1,1,1]],green:[[0,0,0],[.365079,0,0],[.746032,1,1],[1,1,1]],blue:[[0,0,0],[.746032,0,0],[1,1,1]]}},cool:{name:"Cool",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,1,1]],green:[[0,1,1],[1,0,0]],blue:[[0,1,1],[1,1,1]]}},spring:{name:"Spring",numColors:256,gamma:1,segmentedData:{red:[[0,1,1],[1,1,1]],green:[[0,0,0],[1,1,1]],blue:[[0,1,1],[1,0,0]]}},summer:{name:"Summer",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,1,1]],green:[[0,.5,.5],[1,1,1]],blue:[[0,.4,.4],[1,.4,.4]]}},autumn:{name:"Autumn",numColors:256,gamma:1,segmentedData:{red:[[0,1,1],[1,1,1]],green:[[0,0,0],[1,1,1]],blue:[[0,0,0],[1,0,0]]}},winter:{name:"Winter",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,0,0]],green:[[0,0,0],[1,1,1]],blue:[[0,1,1],[1,.5,.5]]}},bone:{name:"Bone",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.746032,.652778,.652778],[1,1,1]],green:[[0,0,0],[.365079,.319444,.319444],[.746032,.777778,.777778],[1,1,1]],blue:[[0,0,0],[.365079,.444444,.444444],[1,1,1]]}},copper:{name:"Copper",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.809524,1,1],[1,1,1]],green:[[0,0,0],[1,.7812,.7812]],blue:[[0,0,0],[1,.4975,.4975]]}},spectral:{name:"Spectral",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.05,.4667,.4667],[.1,.5333,.5333],[.15,0,0],[.2,0,0],[.25,0,0],[.3,0,0],[.35,0,0],[.4,0,0],[.45,0,0],[.5,0,0],[.55,0,0],[.6,0,0],[.65,.7333,.7333],[.7,.9333,.9333],[.75,1,1],[.8,1,1],[.85,1,1],[.9,.8667,.8667],[.95,.8,.8],[1,.8,.8]],green:[[0,0,0],[.05,0,0],[.1,0,0],[.15,0,0],[.2,0,0],[.25,.4667,.4667],[.3,.6,.6],[.35,.6667,.6667],[.4,.6667,.6667],[.45,.6,.6],[.5,.7333,.7333],[.55,.8667,.8667],[.6,1,1],[.65,1,1],[.7,.9333,.9333],[.75,.8,.8],[.8,.6,.6],[.85,0,0],[.9,0,0],[.95,0,0],[1,.8,.8]],blue:[[0,0,0],[.05,.5333,.5333],[.1,.6,.6],[.15,.6667,.6667],[.2,.8667,.8667],[.25,.8667,.8667],[.3,.8667,.8667],[.35,.6667,.6667],[.4,.5333,.5333],[.45,0,0],[.5,0,0],[.55,0,0],[.6,0,0],[.65,0,0],[.7,0,0],[.75,0,0],[.8,0,0],[.85,0,0],[.9,0,0],[.95,0,0],[1,.8,.8]]}},coolwarm:{name:"CoolWarm",numColors:256,gamma:1,segmentedData:{red:[[0,.2298057,.2298057],[.03125,.26623388,.26623388],[.0625,.30386891,.30386891],[.09375,.342804478,.342804478],[.125,.38301334,.38301334],[.15625,.424369608,.424369608],[.1875,.46666708,.46666708],[.21875,.509635204,.509635204],[.25,.552953156,.552953156],[.28125,.596262162,.596262162],[.3125,.639176211,.639176211],[.34375,.681291281,.681291281],[.375,.722193294,.722193294],[.40625,.761464949,.761464949],[.4375,.798691636,.798691636],[.46875,.833466556,.833466556],[.5,.865395197,.865395197],[.53125,.897787179,.897787179],[.5625,.924127593,.924127593],[.59375,.944468518,.944468518],[.625,.958852946,.958852946],[.65625,.96732803,.96732803],[.6875,.969954137,.969954137],[.71875,.966811177,.966811177],[.75,.958003065,.958003065],[.78125,.943660866,.943660866],[.8125,.923944917,.923944917],[.84375,.89904617,.89904617],[.875,.869186849,.869186849],[.90625,.834620542,.834620542],[.9375,.795631745,.795631745],[.96875,.752534934,.752534934],[1,.705673158,.705673158]],green:[[0,.298717966,.298717966],[.03125,.353094838,.353094838],[.0625,.406535296,.406535296],[.09375,.458757618,.458757618],[.125,.50941904,.50941904],[.15625,.558148092,.558148092],[.1875,.604562568,.604562568],[.21875,.648280772,.648280772],[.25,.688929332,.688929332],[.28125,.726149107,.726149107],[.3125,.759599947,.759599947],[.34375,.788964712,.788964712],[.375,.813952739,.813952739],[.40625,.834302879,.834302879],[.4375,.849786142,.849786142],[.46875,.860207984,.860207984],[.5,.86541021,.86541021],[.53125,.848937047,.848937047],[.5625,.827384882,.827384882],[.59375,.800927443,.800927443],[.625,.769767752,.769767752],[.65625,.734132809,.734132809],[.6875,.694266682,.694266682],[.71875,.650421156,.650421156],[.75,.602842431,.602842431],[.78125,.551750968,.551750968],[.8125,.49730856,.49730856],[.84375,.439559467,.439559467],[.875,.378313092,.378313092],[.90625,.312874446,.312874446],[.9375,.24128379,.24128379],[.96875,.157246067,.157246067],[1,.01555616,.01555616]],blue:[[0,.753683153,.753683153],[.03125,.801466763,.801466763],[.0625,.84495867,.84495867],[.09375,.883725899,.883725899],[.125,.917387822,.917387822],[.15625,.945619588,.945619588],[.1875,.968154911,.968154911],[.21875,.98478814,.98478814],[.25,.995375608,.995375608],[.28125,.999836203,.999836203],[.3125,.998151185,.998151185],[.34375,.990363227,.990363227],[.375,.976574709,.976574709],[.40625,.956945269,.956945269],[.4375,.931688648,.931688648],[.46875,.901068838,.901068838],[.5,.865395561,.865395561],[.53125,.820880546,.820880546],[.5625,.774508472,.774508472],[.59375,.726736146,.726736146],[.625,.678007945,.678007945],[.65625,.628751763,.628751763],[.6875,.579375448,.579375448],[.71875,.530263762,.530263762],[.75,.481775914,.481775914],[.78125,.434243684,.434243684],[.8125,.387970225,.387970225],[.84375,.343229596,.343229596],[.875,.300267182,.300267182],[.90625,.259301199,.259301199],[.9375,.220525627,.220525627],[.96875,.184115123,.184115123],[1,.150232812,.150232812]]}},blues:{name:"Blues",numColors:256,gamma:1,segmentedData:{red:[[0,.9686274528503418,.9686274528503418],[.125,.8705882430076599,.8705882430076599],[.25,.7764706015586853,.7764706015586853],[.375,.6196078658103943,.6196078658103943],[.5,.41960784792900085,.41960784792900085],[.625,.25882354378700256,.25882354378700256],[.75,.12941177189350128,.12941177189350128],[.875,.0313725508749485,.0313725508749485],[1,.0313725508749485,.0313725508749485]],green:[[0,.9843137264251709,.9843137264251709],[.125,.9215686321258545,.9215686321258545],[.25,.8588235378265381,.8588235378265381],[.375,.7921568751335144,.7921568751335144],[.5,.6823529601097107,.6823529601097107],[.625,.572549045085907,.572549045085907],[.75,.4431372582912445,.4431372582912445],[.875,.3176470696926117,.3176470696926117],[1,.1882352977991104,.1882352977991104]],blue:[[0,1,1],[.125,.9686274528503418,.9686274528503418],[.25,.9372549057006836,.9372549057006836],[.375,.8823529481887817,.8823529481887817],[.5,.8392156958580017,.8392156958580017],[.625,.7764706015586853,.7764706015586853],[.75,.7098039388656616,.7098039388656616],[.875,.6117647290229797,.6117647290229797],[1,.41960784792900085,.41960784792900085]]}}},BC={MINIMUM_SLAB_THICKNESS:.05,MAXIMUM_RAY_DISTANCE:1e6};Object.freeze(BC);let Bk=BC,BM=.001,BE=function e(t){for(let r of Object.getOwnPropertyNames(t)){let n=t[r];n&&"object"==typeof n&&e(n)}return Object.freeze(t)}({axial:{viewPlaneNormal:[0,0,-1],viewUp:[0,-1,0],viewRight:[1,0,0]},sagittal:{viewPlaneNormal:[1,0,0],viewUp:[0,0,1],viewRight:[0,1,0]},coronal:{viewPlaneNormal:[0,-1,0],viewUp:[0,0,1],viewRight:[1,0,0]}}),BS=[{name:"CT-AAA",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"12 -3024 0 143.556 0 166.222 0.686275 214.389 0.696078 419.736 0.833333 3071 0.803922",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"24 -3024 0 0 0 143.556 0.615686 0.356863 0.184314 166.222 0.882353 0.603922 0.290196 214.389 1 1 1 419.736 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-AAA2",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"16 -3024 0 129.542 0 145.244 0.166667 157.02 0.5 169.918 0.627451 395.575 0.8125 1578.73 0.8125 3071 0.8125",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"32 -3024 0 0 0 129.542 0.54902 0.25098 0.14902 145.244 0.6 0.627451 0.843137 157.02 0.890196 0.47451 0.6 169.918 0.992157 0.870588 0.392157 395.575 1 0.886275 0.658824 1578.73 1 0.829256 0.957922 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Bone",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"8 -3024 0 -16.4458 0 641.385 0.715686 3071 0.705882",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"16 -3024 0 0 0 -16.4458 0.729412 0.254902 0.301961 641.385 0.905882 0.815686 0.552941 3071 1 1 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Bones",gradientOpacity:"4 0 1 985.12 1",specularPower:"1",scalarOpacity:"8 -1000 0 152.19 0 278.93 0.190476 952 0.2",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"20 -1000 0.3 0.3 1 -488 0.3 1 0.3 463.28 1 0 0 659.15 1 0.912535 0.0374849 953 1 0.3 0.3",diffuse:"1",interpolation:"1"},{name:"CT-Cardiac",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"12 -3024 0 -77.6875 0 94.9518 0.285714 179.052 0.553571 260.439 0.848214 3071 0.875",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"24 -3024 0 0 0 -77.6875 0.54902 0.25098 0.14902 94.9518 0.882353 0.603922 0.290196 179.052 1 0.937033 0.954531 260.439 0.615686 0 0 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Cardiac2",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"12 -3024 0 42.8964 0 163.488 0.428571 277.642 0.776786 1587 0.754902 3071 0.754902",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"24 -3024 0 0 0 42.8964 0.54902 0.25098 0.14902 163.488 0.917647 0.639216 0.0588235 277.642 1 0.878431 0.623529 1587 1 1 1 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Cardiac3",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"14 -3024 0 -86.9767 0 45.3791 0.169643 139.919 0.589286 347.907 0.607143 1224.16 0.607143 3071 0.616071",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"28 -3024 0 0 0 -86.9767 0 0.25098 1 45.3791 1 0 0 139.919 1 0.894893 0.894893 347.907 1 1 0.25098 1224.16 1 1 1 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Chest-Contrast-Enhanced",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"10 -3024 0 67.0106 0 251.105 0.446429 439.291 0.625 3071 0.616071",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"20 -3024 0 0 0 67.0106 0.54902 0.25098 0.14902 251.105 0.882353 0.603922 0.290196 439.291 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Chest-Vessels",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"10 -3024 0 -1278.35 0 22.8277 0.428571 439.291 0.625 3071 0.616071",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"20 -3024 0 0 0 -1278.35 0.54902 0.25098 0.14902 22.8277 0.882353 0.603922 0.290196 439.291 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"1",interpolation:"1"},{name:"CT-Coronary-Arteries",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"12 -2048 0 136.47 0 159.215 0.258929 318.43 0.571429 478.693 0.776786 3661 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"24 -2048 0 0 0 136.47 0 0 0 159.215 0.159804 0.159804 0.159804 318.43 0.764706 0.764706 0.764706 478.693 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Coronary-Arteries-2",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"14 -2048 0 142.677 0 145.016 0.116071 192.174 0.5625 217.24 0.776786 384.347 0.830357 3661 0.830357",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"28 -2048 0 0 0 142.677 0 0 0 145.016 0.615686 0 0.0156863 192.174 0.909804 0.454902 0 217.24 0.972549 0.807843 0.611765 384.347 0.909804 0.909804 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Coronary-Arteries-3",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"14 -2048 0 128.643 0 129.982 0.0982143 173.636 0.669643 255.884 0.857143 584.878 0.866071 3661 1",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"28 -2048 0 0 0 128.643 0 0 0 129.982 0.615686 0 0.0156863 173.636 0.909804 0.454902 0 255.884 0.886275 0.886275 0.886275 584.878 0.968627 0.968627 0.968627 3661 1 1 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Cropped-Volume-Bone",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"10 -2048 0 -451 0 -450 1 1050 1 3661 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"20 -2048 0 0 0 -451 0 0 0 -450 0.0556356 0.0556356 0.0556356 1050 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Fat",gradientOpacity:"6 0 1 985.12 1 988 1",specularPower:"1",scalarOpacity:"14 -1000 0 -100 0 -99 0.15 -60 0.15 -59 0 101.2 0 952 0",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"36 -1000 0.3 0.3 1 -497.5 0.3 1 0.3 -99 0 0 1 -76.946 0 1 0 -65.481 0.835431 0.888889 0.0165387 83.89 1 0 0 463.28 1 0 0 659.15 1 0.912535 0.0374849 2952 1 0.300267 0.299886",diffuse:"1",interpolation:"1"},{name:"CT-Liver-Vasculature",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"14 -2048 0 149.113 0 157.884 0.482143 339.96 0.660714 388.526 0.830357 1197.95 0.839286 3661 0.848214",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"28 -2048 0 0 0 149.113 0 0 0 157.884 0.501961 0.25098 0 339.96 0.695386 0.59603 0.36886 388.526 0.854902 0.85098 0.827451 1197.95 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Lung",gradientOpacity:"6 0 1 985.12 1 988 1",specularPower:"1",scalarOpacity:"12 -1000 0 -600 0 -599 0.15 -400 0.15 -399 0 2952 0",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"24 -1000 0.3 0.3 1 -600 0 0 1 -530 0.134704 0.781726 0.0724558 -460 0.929244 1 0.109473 -400 0.888889 0.254949 0.0240258 2952 1 0.3 0.3",diffuse:"1",interpolation:"1"},{name:"CT-MIP",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"8 -3024 0 -637.62 0 700 1 3071 1",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"16 -3024 0 0 0 -637.62 1 1 1 700 1 1 1 3071 1 1 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Muscle",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"10 -3024 0 -155.407 0 217.641 0.676471 419.736 0.833333 3071 0.803922",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"20 -3024 0 0 0 -155.407 0.54902 0.25098 0.14902 217.641 0.882353 0.603922 0.290196 419.736 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Pulmonary-Arteries",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"14 -2048 0 -568.625 0 -364.081 0.0714286 -244.813 0.401786 18.2775 0.607143 447.798 0.830357 3592.73 0.839286",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"28 -2048 0 0 0 -568.625 0 0 0 -364.081 0.396078 0.301961 0.180392 -244.813 0.611765 0.352941 0.0705882 18.2775 0.843137 0.0156863 0.156863 447.798 0.752941 0.752941 0.752941 3592.73 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Soft-Tissue",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"10 -2048 0 -167.01 0 -160 1 240 1 3661 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"20 -2048 0 0 0 -167.01 0 0 0 -160 0.0556356 0.0556356 0.0556356 240 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Air",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"8 -3024 0.705882 -900.0 0.715686 -500.0 0 3071 0",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"16 -3024 1 1 1 -900.0 0.2 1.0 1.0 -500.0 0.3 0.3 1.0 3071 0 0 0 ",diffuse:"0.9",interpolation:"1"},{name:"MR-Angio",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"12 -2048 0 151.354 0 158.279 0.4375 190.112 0.580357 200.873 0.732143 3661 0.741071",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"24 -2048 0 0 0 151.354 0 0 0 158.279 0.74902 0.376471 0 190.112 1 0.866667 0.733333 200.873 0.937255 0.937255 0.937255 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"MR-Default",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"12 0 0 20 0 40 0.15 120 0.3 220 0.375 1024 0.5",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"24 0 0 0 0 20 0.168627 0 0 40 0.403922 0.145098 0.0784314 120 0.780392 0.607843 0.380392 220 0.847059 0.835294 0.788235 1024 1 1 1",diffuse:"1",interpolation:"1"},{name:"MR-MIP",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"8 0 0 98.3725 0 416.637 1 2800 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"16 0 1 1 1 98.3725 1 1 1 416.637 1 1 1 2800 1 1 1",diffuse:"1",interpolation:"1"},{name:"MR-T2-Brain",gradientOpacity:"4 0 1 160.25 1",specularPower:"40",scalarOpacity:"10 0 0 36.05 0 218.302 0.171429 412.406 1 641 1",specular:"0.5",shade:"1",ambient:"0.3",colorTransfer:"16 0 0 0 0 98.7223 0.956863 0.839216 0.192157 412.406 0 0.592157 0.807843 641 1 1 1",diffuse:"0.6",interpolation:"1"},{name:"DTI-FA-Brain",gradientOpacity:"4 0 1 0.9950 1",specularPower:"40",scalarOpacity:"16 0 0 0 0 0.3501 0.0158 0.49379 0.7619 0.6419 1 0.9920 1 0.9950 0 0.9950 0",specular:"0.5",shade:"1",ambient:"0.3",colorTransfer:"28 0 1 0 0 0 1 0 0 0.24974 0.4941 1 0 0.49949 0 0.9882 1 0.7492 0.51764 0 1 0.9950 1 0 0 0.9950 1 0 0",diffuse:"0.9",interpolation:"1"}],BD={},BI=e=>BD[e],BP=()=>{let e=Object.keys(BD).map(e=>BD[e]);return e.sort((e,t)=>"_"===e.id[0]&&"_"!==t.id[0]?1:"_"!==e.id[0]&&"_"===t.id[0]?-1:0),e},BT=e=>e&&"object"==typeof e&&"[object RegExp]"!==Object.prototype.toString.call(e)&&"[object Date]"!==Object.prototype.toString.call(e),B_=(e,t)=>t&&!0===t.clone&&BT(e)?BO(Array.isArray(e)?[]:{},e,t):e,BA=(e,t,r)=>{let n=e.slice();return t.forEach(function(t,a){void 0===n[a]?n[a]=B_(t,r):BT(t)?n[a]=BO(e[a],t,r):-1===e.indexOf(t)&&(n[a]=B_(t,r))}),n},BO=(e={},t={},r)=>{let n,a=Array.isArray(t),i=(r||{arrayMerge:BA}).arrayMerge||BA;return a?Array.isArray(e)?i(e,t,r):B_(t,r):(n={},BT(e)&&Object.keys(e).forEach(function(t){n[t]=B_(e[t],r)}),Object.keys(t).forEach(function(a){BT(t[a])&&e[a]?n[a]=BO(e[a],t[a],r):n[a]=B_(t[a],r)}),n)},BR=Symbol("Comlink.proxy"),BL=Symbol("Comlink.endpoint"),BN=Symbol("Comlink.releaseProxy"),BF=Symbol("Comlink.finalizer"),BV=Symbol("Comlink.thrown"),BB=e=>"object"==typeof e&&null!==e||"function"==typeof e,Bj=new Map([["proxy",{canHandle:e=>BB(e)&&e[BR],serialize(e){let{port1:t,port2:r}=new MessageChannel;return function e(t,r=globalThis,n=["*"]){r.addEventListener("message",function a(i){let o;if(!i||!i.data)return;if(!function(e,t){for(let r of e)if(t===r||"*"===r||r instanceof RegExp&&r.test(t))return!0;return!1}(n,i.origin))return void console.warn(`Invalid origin '${i.origin}' for comlink proxy`);let{id:s,type:l,path:u}=Object.assign({path:[]},i.data),c=(i.data.argumentList||[]).map(BY);try{var d,h,p;let r=u.slice(0,-1).reduce((e,t)=>e[t],t),n=u.reduce((e,t)=>e[t],t);switch(l){case"GET":o=n;break;case"SET":r[u.slice(-1)[0]]=BY(i.data.value),o=!0;break;case"APPLY":o=n.apply(r,c);break;case"CONSTRUCT":d=new n(...c),o=Object.assign(d,{[BR]:!0});break;case"ENDPOINT":{let{port1:r,port2:n}=new MessageChannel;e(t,n),h=r,p=[r],B$.set(h,p),o=h}break;case"RELEASE":o=void 0;break;default:return}}catch(e){o={value:e,[BV]:0}}Promise.resolve(o).catch(e=>({value:e,[BV]:0})).then(e=>{let[n,i]=BK(e);r.postMessage(Object.assign(Object.assign({},n),{id:s}),i),"RELEASE"===l&&(r.removeEventListener("message",a),BW(r),BF in t&&"function"==typeof t[BF]&&t[BF]())}).catch(e=>{let[t,n]=BK({value:TypeError("Unserializable return value"),[BV]:0});r.postMessage(Object.assign(Object.assign({},t),{id:s}),n)})}),r.start&&r.start()}(e,t),[r,[r]]},deserialize:e=>{var t;let r;return e.start(),t=e,r=new Map,t.addEventListener("message",function(e){let{data:t}=e;if(!t||!t.id)return;let n=r.get(t.id);if(n)try{n(t)}finally{r.delete(t.id)}}),function e(t,r,n=[],a=function(){}){let i,o=!1,s=new Proxy(a,{get(a,i){if(BU(o),i===BN)return()=>{BG&&BG.unregister(s),Bz(t),r.clear(),o=!0};if("then"===i){if(0===n.length)return{then:()=>s};let e=BX(t,r,{type:"GET",path:n.map(e=>e.toString())}).then(BY);return e.then.bind(e)}return e(t,r,[...n,i])},set(e,a,i){BU(o);let[s,l]=BK(i);return BX(t,r,{type:"SET",path:[...n,a].map(e=>e.toString()),value:s},l).then(BY)},apply(a,i,s){BU(o);let l=n[n.length-1];if(l===BL)return BX(t,r,{type:"ENDPOINT"}).then(BY);if("bind"===l)return e(t,r,n.slice(0,-1));let[u,c]=Bq(s);return BX(t,r,{type:"APPLY",path:n.map(e=>e.toString()),argumentList:u},c).then(BY)},construct(e,a){BU(o);let[i,s]=Bq(a);return BX(t,r,{type:"CONSTRUCT",path:n.map(e=>e.toString()),argumentList:i},s).then(BY)}});return i=(BH.get(t)||0)+1,BH.set(t,i),BG&&BG.register(s,t,s),s}(t,r,[],void 0)}}],["throw",{canHandle:e=>BB(e)&&BV in e,serialize:({value:e})=>[e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[]],deserialize(e){if(e.isError)throw Object.assign(Error(e.value.message),e.value);throw e.value}}]]);function BW(e){"MessagePort"===e.constructor.name&&e.close()}function BU(e){if(e)throw Error("Proxy has been released and is not useable")}function Bz(e){return BX(e,new Map,{type:"RELEASE"}).then(()=>{BW(e)})}let BH=new WeakMap,BG="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{let t=(BH.get(e)||0)-1;BH.set(e,t),0===t&&Bz(e)});function Bq(e){var t;let r=e.map(BK);return[r.map(e=>e[0]),(t=r.map(e=>e[1]),Array.prototype.concat.apply([],t))]}let B$=new WeakMap;function BK(e){for(let[t,r]of Bj)if(r.canHandle(e)){let[n,a]=r.serialize(e);return[{type:"HANDLER",name:t,value:n},a]}return[{type:"RAW",value:e},B$.get(e)||[]]}function BY(e){switch(e.type){case"HANDLER":return Bj.get(e.name).deserialize(e.value);case"RAW":return e.value}}function BX(e,t,r,n){return new Promise(a=>{let i=[,,,,].fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");t.set(i,a),e.start&&e.start(),e.postMessage(Object.assign({id:i},r),n)})}function BZ(){return"function"==typeof crypto.randomUUID?crypto.randomUUID():"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}class BJ{constructor(e){this.numRequests={[FU.Interaction]:0,[FU.Thumbnail]:0,[FU.Prefetch]:0,[FU.Compute]:0},this.id=e||BZ(),this.requestPool={[FU.Interaction]:{0:[]},[FU.Thumbnail]:{0:[]},[FU.Prefetch]:{0:[]},[FU.Compute]:{0:[]}},this.grabDelay=5,this.awake=!1,this.numRequests={[FU.Interaction]:0,[FU.Thumbnail]:0,[FU.Prefetch]:0,[FU.Compute]:0},this.maxNumRequests={[FU.Interaction]:6,[FU.Thumbnail]:6,[FU.Prefetch]:5,[FU.Compute]:1e3}}setMaxSimultaneousRequests(e,t){this.maxNumRequests[e]=t}getMaxSimultaneousRequests(e){return this.maxNumRequests[e]}destroy(){this.timeoutHandle&&window.clearTimeout(this.timeoutHandle)}addRequest(e,t,r,n=0){void 0===this.requestPool[t][n]&&(this.requestPool[t][n]=[]),this.requestPool[t][n].push({requestFn:e,type:t,additionalDetails:r}),this.startGrabbing()}filterRequests(e){Object.keys(this.requestPool).forEach(t=>{let r=this.requestPool[t];Object.keys(r).forEach(t=>{r[t]=r[t].filter(t=>e(t))})})}clearRequestStack(e){if(!this.requestPool[e])throw Error(`No category for the type ${e} found`);this.requestPool[e]={0:[]}}sendRequests(e){let t=this.maxNumRequests[e]-this.numRequests[e],r=0;for(let n=0;n<t;n++){let t=this.getNextRequest(e);if(null===t)return!1;if(t){let n;this.numRequests[e]++,this.awake=!0;try{n=t.requestFn()}catch(e){console.warn("sendRequest failed",e)}n?.finally?n.finally(()=>{this.numRequests[e]--,this.startAgain()}):(this.numRequests[e]--,r++)}}return r&&this.startAgain(),!0}getNextRequest(e){for(let t of this.getSortedPriorityGroups(e))if(this.requestPool[e][t].length)return this.requestPool[e][t].shift();return null}startGrabbing(){let e=this.sendRequests(FU.Interaction),t=this.sendRequests(FU.Thumbnail),r=this.sendRequests(FU.Prefetch),n=this.sendRequests(FU.Compute);e||t||r||n||(this.awake=!1)}startAgain(){this.awake&&(void 0!==this.grabDelay?this.timeoutHandle||(this.timeoutHandle=window.setTimeout(()=>{this.timeoutHandle=null,this.startGrabbing()},this.grabDelay)):this.startGrabbing())}getSortedPriorityGroups(e){return Object.keys(this.requestPool[e]).map(Number).filter(t=>this.requestPool[e][t].length).sort((e,t)=>e-t)}getRequestPool(){return this.requestPool}}let{pp:BQ,tZ:B1,gE:B0,bM:B2,uu:B5,UA:B3,_E:B4,RZ:B8,UX:B6,HL:B9,U5:B7}=ee;B2.getLogger("registration");function je(e,{ext:t,filterType:r,texData:n,internalFormat:a,glDataType:i}){try{let o;if(t&&!(o=e.getExtension(t)))return!1;let s=e.createTexture();e.bindTexture(e.TEXTURE_2D,s),e.texImage2D(e.TEXTURE_2D,0,a(e,o),5,1,0,e.RED,i(e,o),n);let l="LINEAR"===r?e.LINEAR:e.NEAREST;e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,l),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,l),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.POINTS,0,1);let u=new Uint8Array(4);e.readPixels(1,1,1,1,e.RGBA,e.UNSIGNED_BYTE,u);let[c,d,h]=u;return e.deleteTexture(s),c===d&&d===h&&0!==c}catch(e){return!1}}let jt="cornerstone3D.renderingCapabilities",jr=/swiftshader|llvmpipe|softpipe|software|microsoft basic render/i,jn={norm16:!1,norm16Linear:!1,float:!1,floatLinear:!1,halfFloat:!1,halfFloatLinear:!1},ja=null;function ji(){return ja||(ja=function({useCache:e=!0}={}){let t=function(){let e={webgl:!1,webgl2:!1,maxTextureSize:0,renderer:""};if("u"<typeof document)return e;try{let t=document.createElement("canvas"),r=t.getContext("webgl2"),n=r||t.getContext("webgl")||t.getContext("experimental-webgl");if(!n)return e;e.webgl=!0,e.webgl2=!!r,e.maxTextureSize=Number(n.getParameter(n.MAX_TEXTURE_SIZE))||0;let a=n.getExtension("WEBGL_debug_renderer_info"),i=a?n.getParameter(a.UNMASKED_RENDERER_WEBGL):n.getParameter(n.RENDERER);e.renderer="string"==typeof i?i:"";let o=n.getExtension("WEBGL_lose_context");o&&o.loseContext()}catch{}return e}();if(!t.webgl)return{...t,...jn,softwareRasterizer:!1};let r=e?function(e,t){try{let r=window.localStorage?.getItem(jt);if(!r)return null;let n=JSON.parse(r);if(n?.probeVersion!==1||n?.renderer!==e||n?.webgl2!==t||"object"!=typeof n?.formats||n?.formats===null)return null;return{...jn,...n.formats}}catch{return null}}(t.renderer,t.webgl2):null;if(!r){let e=function(){let e=function(){try{let e=document.createElement("canvas");e.width=4,e.height=4;let t=e.getContext("webgl2");if(!t)return null;let r=`#version 300 es
|
|
9
|
+
`)}),{viewportOptions:o,displaySetsInfo:s}}_validateViewportSpecificMatch(e,t,r){let{displaySetService:n}=this._servicesManager.services,a=t.displaySets,i=e.displaySetInstanceUIDs.length;if(a.length>0&&i!==a.length)throw Error(`The number of displaySets to set ${i} does not match the number of displaySets in the protocol ${a} - not currently implemented`);e.displaySetInstanceUIDs.forEach(e=>{let a=n.getDisplaySetByUID(e),{displaySets:i}=t;for(let e of i){let t=r[e.id];t&&this._validateRequiredSelectors(t,a)}})}areRequiredSelectorsValid(e,t){let r=!0;for(let n of e)try{this._validateRequiredSelectors(n,t)}catch(e){r=!1;break}return r}_validateRequiredSelectors(e,t){let{seriesMatchingRules:r}=e,n=r.filter(e=>e.required);if(n.length){let e=this.protocolEngine.findMatch(t,n);if(!e||0===e.score)throw Error(`The displaySetInstanceUID ${t.displaySetInstanceUID} does not satisfy the required seriesMatching criteria for the protocol`)}}_validateOptions(e){let{displaySetService:t}=this._servicesManager.services,{displaySetSelectorMap:r}=e;r&&Object.entries(r).forEach(([e,r])=>{r.forEach(e=>{if(!t.getDisplaySetByUID(e))throw Error(`The displaySetInstanceUID ${e} is not found in the displaySetService`)})})}_matchImages(e){let{id:t,studyMatchingRules:r=[],seriesMatchingRules:n}=e,a=[],i=0;console.log("ProtocolEngine::matchImages",r,n);let o=-1===this.protocol.numberOfPriorsReferenced;this.studies.forEach((e,t)=>{if(o&&this.activeStudy!==e)return;let s=this.displaySets.filter(t=>t.StudyInstanceUID===e.StudyInstanceUID&&!t?.unsupported),l=this.protocolEngine.findMatch(e,r,{studies:this.studies,displaySets:s,allDisplaySets:this.displaySets,displaySetMatchDetails:this.displaySetMatchDetails,studyInstanceUIDsIndex:t});!0!==l.requiredFailed&&(this.debug("study",e.StudyInstanceUID,"display sets #",s.length),s.forEach(t=>{let{StudyInstanceUID:r,SeriesInstanceUID:o,displaySetInstanceUID:u}=t,c=this.protocolEngine.findMatch(t,n,{studies:this.studies,instance:t.images?.[0],displaySetMatchDetails:this.displaySetMatchDetails,displaySets:s});if(!0===c.requiredFailed)return void this.debug("Display set required failed",t,n);this.debug("Found displaySet for rules",t),i=Math.max(c.score,i);let d={passed:[],failed:[]};d.passed=d.passed.concat(c.details.passed),d.passed=d.passed.concat(l.details.passed),d.failed=d.failed.concat(c.details.failed),d.failed=d.failed.concat(l.details.failed);let h=c.score+l.score,p={StudyInstanceUID:r,SeriesInstanceUID:o,displaySetInstanceUID:u,matchingScore:h,matchDetails:d,sortingInfo:{score:h,study:e.StudyInstanceUID,...this._getSeriesSortInfoForDisplaySetSort(t)}};this.debug("Adding display set",t,p),a.push(p)}))}),0===a.length&&console.log("No match found",t);let s=L9({name:"score",reverse:!0},{name:"study",reverse:!0},this._getSeriesFieldForDisplaySetSort());a.sort((e,t)=>s(e.sortingInfo,t.sortingInfo));let l=a[0];return console.log("ProtocolEngine::matchImages bestMatch",l,a),{bestMatch:l,matchingScores:a}}_getSeriesSortInfoForDisplaySetSort(e){return{[this._getSeriesFieldForDisplaySetSort().name]:null!=e.SeriesNumber?parseInt(e.SeriesNumber):parseInt(e.seriesNumber)}}_getSeriesFieldForDisplaySetSort(){return{name:"series"}}_isNextStageAvailable(){let e=this._getNumProtocolStages();return this.stageIndex+1<e}_isPreviousStageAvailable(){return this.stageIndex-1>=0}_setCurrentProtocolStage(e,t){let r;for(r=this.stageIndex+e;r>=0&&r<this.protocol.stages.length&&"disabled"===this.protocol.stages[r].status;r+=e);return!(r<0)&&!(r>=this.protocol.stages.length)&&(this.stageIndex=r,this.debug(`ProtocolEngine::setCurrentProtocolStage stage = ${this.stageIndex}`),this._updateViewports(t),this._broadcastEvent(this.EVENTS.PROTOCOL_CHANGED,{viewportMatchDetails:this.viewportMatchDetails,displaySetMatchDetails:this.displaySetMatchDetails,protocol:this.protocol,stageIdx:this.stageIndex,stage:this.protocol.stages[this.stageIndex]}),!0)}debug(...e){this.debugLogging&&console.log(...e)}_copyProtocol(e){return L6()(e)}}Nq.EVENTS={PROTOCOL_CHANGED:"event::hanging_protocol_changed",PROTOCOL_RESTORED:"event::hanging_protocol_restore",NEW_LAYOUT:"event::hanging_protocol_new_layout",STAGE_ACTIVATION:"event::hanging_protocol_stage_activation",CUSTOM_IMAGE_LOAD_PERFORMED:"event::hanging_protocol_custom_image_load_performed"},Nq.REGISTRATION={name:"hangingProtocolService",altName:"HangingProtocolService",create:({configuration:e={},commandsManager:t,servicesManager:r})=>new Nq(t,r)};class N$ extends Lx{constructor(){super(N$.EVENTS),this.serviceImplementation={_getState:()=>console.warn("getState() NOT IMPLEMENTED"),_setUser:()=>console.warn("_setUser() NOT IMPLEMENTED"),_getUser:()=>console.warn("_getUser() NOT IMPLEMENTED"),_getAuthorizationHeader:()=>{},_handleUnauthenticated:()=>console.warn("_handleUnauthenticated() NOT IMPLEMENTED"),_reset:()=>console.warn("reset() NOT IMPLEMENTED"),_set:()=>console.warn("set() NOT IMPLEMENTED")},this.serviceImplementation={...this.serviceImplementation}}getState(){return this.serviceImplementation._getState()}setUser(e){return this.serviceImplementation._setUser(e)}getUser(){return this.serviceImplementation._getUser()}getAuthorizationHeader(){return this.serviceImplementation._getAuthorizationHeader()}handleUnauthenticated(){return this.serviceImplementation._handleUnauthenticated()}reset(){return this.serviceImplementation._reset()}set(e){return this.serviceImplementation._set(e)}setServiceImplementation({getState:e,setUser:t,getUser:r,getAuthorizationHeader:n,handleUnauthenticated:a,reset:i,set:o}){e&&(this.serviceImplementation._getState=e),t&&(this.serviceImplementation._setUser=t),r&&(this.serviceImplementation._getUser=r),n&&(this.serviceImplementation._getAuthorizationHeader=n),a&&(this.serviceImplementation._handleUnauthenticated=a),i&&(this.serviceImplementation._reset=i),o&&(this.serviceImplementation._set=o)}}N$.EVENTS={},N$.REGISTRATION={name:"userAuthenticationService",altName:"UserAuthenticationService",create:({configuration:e={}})=>new N$};var NK=u(1752),NY=u.n(NK),NX=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,NZ=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,NJ=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,NQ=e=>"string"==typeof e&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||"$"===e||"_"===e||NZ.test(e)),N1=e=>"string"==typeof e&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||"$"===e||"_"===e||""===e||""===e||NJ.test(e)),N0=e=>"string"==typeof e&&/[0-9]/.test(e),N2=e=>"string"==typeof e&&/[0-9A-Fa-f]/.test(e);function N5(){if(a[s])return String.fromCodePoint(a.codePointAt(s))}function N3(){let e=N5();return"\n"===e?(l++,d=0):e?d+=e.length:d++,e&&(s+=e.length),e}let N4={default(){let e;switch(b){case" ":case"\v":case"\f":case" ":case"\xa0":case"\uFEFF":case"\n":case"\r":case"\u2028":case"\u2029":N3();return;case"/":N3(),m="comment";return;case void 0:return N3(),N8("eof")}return"string"==typeof(e=b)&&NX.test(e)?void N3():N4[i]()},comment(){switch(b){case"*":N3(),m="multiLineComment";return;case"/":N3(),m="singleLineComment";return}throw Fr(N3())},multiLineComment(){switch(b){case"*":N3(),m="multiLineCommentAsterisk";return;case void 0:throw Fr(N3())}N3()},multiLineCommentAsterisk(){switch(b){case"*":N3();return;case"/":N3(),m="default";return;case void 0:throw Fr(N3())}N3(),m="multiLineComment"},singleLineComment(){switch(b){case"\n":case"\r":case"\u2028":case"\u2029":N3(),m="default";return;case void 0:return N3(),N8("eof")}N3()},value(){switch(b){case"{":case"[":return N8("punctuator",N3());case"n":return N3(),N6("ull"),N8("null",null);case"t":return N3(),N6("rue"),N8("boolean",!0);case"f":return N3(),N6("alse"),N8("boolean",!1);case"-":case"+":"-"===N3()&&(v=-1),m="sign";return;case".":g=N3(),m="decimalPointLeading";return;case"0":g=N3(),m="zero";return;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":g=N3(),m="decimalInteger";return;case"I":return N3(),N6("nfinity"),N8("numeric",1/0);case"N":return N3(),N6("aN"),N8("numeric",NaN);case'"':case"'":y='"'===N3(),g="",m="string";return}throw Fr(N3())},identifierNameStartEscape(){if("u"!==b)throw Fr(N3());N3();let e=N9();switch(e){case"$":case"_":break;default:if(!NQ(e))throw Fa()}g+=e,m="identifierName"},identifierName(){switch(b){case"$":case"_":case"":case"":g+=N3();return;case"\\":N3(),m="identifierNameEscape";return}if(N1(b)){g+=N3();return}return N8("identifier",g)},identifierNameEscape(){if("u"!==b)throw Fr(N3());N3();let e=N9();switch(e){case"$":case"_":case"":case"":break;default:if(!N1(e))throw Fa()}g+=e,m="identifierName"},sign(){switch(b){case".":g=N3(),m="decimalPointLeading";return;case"0":g=N3(),m="zero";return;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":g=N3(),m="decimalInteger";return;case"I":return N3(),N6("nfinity"),N8("numeric",1/0*v);case"N":return N3(),N6("aN"),N8("numeric",NaN)}throw Fr(N3())},zero(){switch(b){case".":g+=N3(),m="decimalPoint";return;case"e":case"E":g+=N3(),m="decimalExponent";return;case"x":case"X":g+=N3(),m="hexadecimal";return}return N8("numeric",0*v)},decimalInteger(){switch(b){case".":g+=N3(),m="decimalPoint";return;case"e":case"E":g+=N3(),m="decimalExponent";return}if(N0(b)){g+=N3();return}return N8("numeric",v*Number(g))},decimalPointLeading(){if(N0(b)){g+=N3(),m="decimalFraction";return}throw Fr(N3())},decimalPoint(){switch(b){case"e":case"E":g+=N3(),m="decimalExponent";return}if(N0(b)){g+=N3(),m="decimalFraction";return}return N8("numeric",v*Number(g))},decimalFraction(){switch(b){case"e":case"E":g+=N3(),m="decimalExponent";return}if(N0(b)){g+=N3();return}return N8("numeric",v*Number(g))},decimalExponent(){switch(b){case"+":case"-":g+=N3(),m="decimalExponentSign";return}if(N0(b)){g+=N3(),m="decimalExponentInteger";return}throw Fr(N3())},decimalExponentSign(){if(N0(b)){g+=N3(),m="decimalExponentInteger";return}throw Fr(N3())},decimalExponentInteger(){if(N0(b)){g+=N3();return}return N8("numeric",v*Number(g))},hexadecimal(){if(N2(b)){g+=N3(),m="hexadecimalInteger";return}throw Fr(N3())},hexadecimalInteger(){if(N2(b)){g+=N3();return}return N8("numeric",v*Number(g))},string(){switch(b){case"\\":N3(),g+=function(){switch(N5()){case"b":return N3(),"\b";case"f":return N3(),"\f";case"n":return N3(),"\n";case"r":return N3(),"\r";case"t":return N3()," ";case"v":return N3(),"\v";case"0":if(N3(),N0(N5()))throw Fr(N3());return"\0";case"x":return N3(),function(){let e="",t=N5();if(!N2(t)||(e+=N3(),!N2(t=N5())))throw Fr(N3());return String.fromCodePoint(parseInt(e+=N3(),16))}();case"u":return N3(),N9();case"\n":case"\u2028":case"\u2029":return N3(),"";case"\r":return N3(),"\n"===N5()&&N3(),"";case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case void 0:throw Fr(N3())}return N3()}();return;case'"':if(y)return N3(),N8("string",g);g+=N3();return;case"'":if(!y)return N3(),N8("string",g);g+=N3();return;case"\n":case"\r":case void 0:throw Fr(N3());case"\u2028":case"\u2029":var e;e=b,console.warn(`JSON5: '${Fi(e)}' in strings is not valid ECMAScript; consider escaping`)}g+=N3()},start(){switch(b){case"{":case"[":return N8("punctuator",N3())}m="value"},beforePropertyName(){switch(b){case"$":case"_":g=N3(),m="identifierName";return;case"\\":N3(),m="identifierNameStartEscape";return;case"}":return N8("punctuator",N3());case'"':case"'":y='"'===N3(),m="string";return}if(NQ(b)){g+=N3(),m="identifierName";return}throw Fr(N3())},afterPropertyName(){if(":"===b)return N8("punctuator",N3());throw Fr(N3())},beforePropertyValue(){m="value"},afterPropertyValue(){switch(b){case",":case"}":return N8("punctuator",N3())}throw Fr(N3())},beforeArrayValue(){if("]"===b)return N8("punctuator",N3());m="value"},afterArrayValue(){switch(b){case",":case"]":return N8("punctuator",N3())}throw Fr(N3())},end(){throw Fr(N3())}};function N8(e,t){return{type:e,value:t,line:l,column:d}}function N6(e){for(let t of e){if(N5()!==t)throw Fr(N3());N3()}}function N9(){let e="",t=4;for(;t-- >0;){if(!N2(N5()))throw Fr(N3());e+=N3()}return String.fromCodePoint(parseInt(e,16))}let N7={start(){if("eof"===h.type)throw Fn();Fe()},beforePropertyName(){switch(h.type){case"identifier":case"string":p=h.value,i="afterPropertyName";return;case"punctuator":Ft();return;case"eof":throw Fn()}},afterPropertyName(){if("eof"===h.type)throw Fn();i="beforePropertyValue"},beforePropertyValue(){if("eof"===h.type)throw Fn();Fe()},beforeArrayValue(){if("eof"===h.type)throw Fn();"punctuator"===h.type&&"]"===h.value?Ft():Fe()},afterPropertyValue(){if("eof"===h.type)throw Fn();switch(h.value){case",":i="beforePropertyName";return;case"}":Ft()}},afterArrayValue(){if("eof"===h.type)throw Fn();switch(h.value){case",":i="beforeArrayValue";return;case"]":Ft()}},end(){}};function Fe(){let e;switch(h.type){case"punctuator":switch(h.value){case"{":e={};break;case"[":e=[]}break;case"null":case"boolean":case"numeric":case"string":e=h.value}if(void 0===f)f=e;else{let t=o[o.length-1];Array.isArray(t)?t.push(e):Object.defineProperty(t,p,{value:e,writable:!0,enumerable:!0,configurable:!0})}if(null!==e&&"object"==typeof e)o.push(e),i=Array.isArray(e)?"beforeArrayValue":"beforePropertyName";else{let e=o[o.length-1];i=null==e?"end":Array.isArray(e)?"afterArrayValue":"afterPropertyValue"}}function Ft(){o.pop();let e=o[o.length-1];i=null==e?"end":Array.isArray(e)?"afterArrayValue":"afterPropertyValue"}function Fr(e){return void 0===e?Fo(`JSON5: invalid end of input at ${l}:${d}`):Fo(`JSON5: invalid character '${Fi(e)}' at ${l}:${d}`)}function Fn(){return Fo(`JSON5: invalid end of input at ${l}:${d}`)}function Fa(){return d-=5,Fo(`JSON5: invalid identifier character at ${l}:${d}`)}function Fi(e){let t={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(t[e])return t[e];if(e<" "){let t=e.charCodeAt(0).toString(16);return"\\x"+("00"+t).substring(t.length)}return e}function Fo(e){let t=SyntaxError(e);return t.lineNumber=l,t.columnNumber=d,t}let Fs=function(e,t){a=String(e),i="start",o=[],s=0,l=1,d=0,h=void 0,p=void 0,f=void 0;do h=function(){for(m="default",g="",y=!1,v=1;;){b=N5();let e=N4[m]();if(e)return e}}(),N7[i]();while("eof"!==h.type);return"function"==typeof t?function e(t,r,n){let a=t[r];if(null!=a&&"object"==typeof a)if(Array.isArray(a))for(let t=0;t<a.length;t++){let r=String(t),i=e(a,r,n);void 0===i?delete a[r]:Object.defineProperty(a,r,{value:i,writable:!0,enumerable:!0,configurable:!0})}else for(let t in a){let r=e(a,t,n);void 0===r?delete a[t]:Object.defineProperty(a,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}return n.call(t,r,a)}({"":f},"",t):f},Fl="default",Fu={prefixes:{}};function Fc(e){if(!e||"object"!=typeof e)return null;let t=Fd(e.bootstrap),r=Fd(e.global),n=e.mode&&"object"==typeof e.mode&&!Array.isArray(e.mode),a="string"==typeof e.requires||Array.isArray(e.requires)&&e.requires.length>0;return t||r||n||a?{...t?{bootstrap:e.bootstrap}:{},...r?{global:e.global}:{},...n?{mode:e.mode}:{},...a?{requires:e.requires}:{}}:null}function Fd(e){return Array.isArray(e)?e.length>0:!!e&&"object"==typeof e}let Fh=/^([a-z][a-z0-9+.-]*:|\/\/)/i;function Fp(e,t="customization"){let r=[];for(let n of Array.from(new Set(e.keys())))if(n.toLowerCase()===t.toLowerCase()){for(let t of e.getAll(n))if(t)for(let e of t.split(",")){let t=e.trim();t&&r.push(t)}}return r}function Ff(e,t){let r={valid:[],rejected:[]},n=t.prefixes||{};for(let t of e){let e=function(e){let t=e;for(let e=0;e<5;e++){let e;if(!t.includes("%"))return t;try{e=decodeURIComponent(t)}catch{break}if(e===t)break;t=e}return null}(t);if(null===e){r.rejected.push({raw:t,reason:"contains malformed or unsupported percent-encoding"});continue}if(e.includes("..")){r.rejected.push({raw:t,reason:'contains ".." traversal segment'});continue}if(Fh.test(e)){r.rejected.push({raw:t,reason:"full URLs are not permitted"});continue}let a=function(e){if(!e)return null;if(!e.startsWith("/"))return{prefix:Fl,name:e};let t=e.slice(1),r=t.indexOf("/");if(r<=0)return null;let n=t.slice(0,r),a=t.slice(r+1);return n&&a?{prefix:`/${n}/`,name:a}:null}(e.trim());if(!a){r.rejected.push({raw:t,reason:"could not be split into a prefix and name"});continue}let{prefix:i,name:o}=a;if(!Object.prototype.hasOwnProperty.call(n,i)){r.rejected.push({raw:t,reason:`unknown prefix "${i}"`});continue}if(!o.trim()||o.split("/").some(e=>!e||"."===e||".."===e||e.includes(".."))){r.rejected.push({raw:t,reason:"invalid or unsafe customization name"});continue}r.valid.push({raw:t,normalized:i===Fl?`/${Fl}/${o}`:`${i}${o}`,prefix:i,name:o})}return r}let Fm=/^([a-z][a-z0-9+.-]*:|\/\/)/i,Fg="https://ohif.invalid";function Fy(e,t,r){let n,a;try{n=new URL(e,Fg),a=new URL(t,Fg)}catch{throw Error(`Customization URL could not be parsed for "${r.raw}"`)}let i=a.pathname.endsWith("/")?a.pathname:`${a.pathname}/`;if(!(n.origin===a.origin&&n.pathname.startsWith(i)))throw Error(`Customization "${r.raw}" escapes its configured prefix directory`)}let Fv={MODE_CUSTOMIZATION_MODIFIED:"event::CustomizationService:modeModified",GLOBAL_CUSTOMIZATION_MODIFIED:"event::CustomizationService:globalModified",DEFAULT_CUSTOMIZATION_MODIFIED:"event::CustomizationService:defaultModified"},Fb=((ege={}).Global="global",ege.Mode="mode",ege.Default="default",ege);class Fw extends Lx{constructor({configuration:e,commandsManager:t}){super(Fv),this.Scope=Fb,this.commandsManager=void 0,this.extensionManager=void 0,this.globalCustomizations=new Map,this.modeCustomizations=new Map,this.defaultCustomizations=new Map,this.transformedCustomizations=new Map,this.configuration=void 0,this._urlCustomizationLoaded=new Map,this._urlCustomizationPending=new Map,this._resolvedUrlModules=[],this._customizationConfig=null,this._currentModeIds=[],this._extensionCustomizationModuleApplied=new Set,this.configuration=e,this.commandsManager=t}init(e){this.extensionManager=e,this.modeCustomizations.clear(),this.extensionManager.getRegisteredExtensionIds().forEach(e=>{let t=`${e}.customizationModule.default`;if(!this._extensionCustomizationModuleApplied.has(t)){let e=this._findExtensionValue(t);if(e){let{value:r}=e;this._addReference(r,Fb.Default),this._extensionCustomizationModuleApplied.add(t)}}let r=`${e}.customizationModule.global`;if(!this._extensionCustomizationModuleApplied.has(r)){let e=this._findExtensionValue(r);if(e){let{value:t}=e;this._addReference(t,Fb.Global),this._extensionCustomizationModuleApplied.add(r)}}});let t=this._getCustomizationConfig();void 0===t.legacyReferences||this.configuration?._hasBeenAdded||(this.addReferences(t.legacyReferences),Object.defineProperty(this.configuration,"_hasBeenAdded",{value:!0,writable:!1}))}_getCustomizationConfig(){return this._customizationConfig||(this._customizationConfig=function(e){if(!e)return{};if(Array.isArray(e))return{legacyReferences:e};if("object"==typeof e){if(Fx.some(t=>t in e)){let t={};for(let r of Fx)r in e&&(t[r]=e[r]);return{phased:t}}return{legacyReferences:e}}return{}}(this.configuration)),this._customizationConfig}async applyWindowUrlCustomizations(e){"u">typeof window&&await this.applyCustomizationUrlSearchParams(new URLSearchParams(window.location.search),e)}async applyCustomizationUrlSearchParams(e,t){let r=Fp(e);r.length&&await this.requires(r,t)}requires(e,t){return this.loadCustomizationModules(e,t).then(e=>(this._applyLoadedUrlCustomizationModules(e),e))}loadCustomizationModules(e,t){let r,n=t?.policy??((r=this?.extensionManager?.appConfig?.customizationUrlPrefixes)&&"object"==typeof r?{prefixes:r}:Fu),a=(Array.isArray(e)?e:[e]).map(e=>String(e).trim()).filter(Boolean);if(!a.length)return Promise.resolve([]);let{valid:i,rejected:o}=Ff(a,n),s=t?.logger||console;if(o.length){let e=o.map(e=>`"${e.raw}" (${e.reason})`).join("; ");return Promise.reject(Error(`[customizationUrl] refusing to load customization(s): ${e}. Allowed prefixes are configured in appConfig.customizationUrlPrefixes.`))}if(!i.length)return Promise.resolve([]);let l=t?.importFn??this._urlDefaultImport.bind(this),u=new Set,c=[];return i.reduce((e,t)=>e.then(()=>this._urlCustomizationLoadOne(t,n,l,s,u,c)),Promise.resolve()).then(()=>(this._resolvedUrlModules.push(...c),c))}async loadAndApplyBootstrapCustomizations(e,t){this.extensionManager=e;let r=this._getCustomizationConfig(),n=[],a=r.phased?.requires;"string"==typeof a&&a?n.push(a):Array.isArray(a)&&n.push(...a.filter(e=>"string"==typeof e&&e)),"u">typeof window&&n.push(...Fp(new URLSearchParams(window.location.search))),n.length&&await this.loadCustomizationModules(n,t),this.applyBootstrapCustomizations()}applyBootstrapCustomizations(){this._applyPhase("bootstrap")}applyGlobalCustomizations(){this._applyPhase("global")}applyModeCustomizations(e){let t=(Array.isArray(e)?e:[e]).filter(Boolean);this._currentModeIds=t;let r=this._collectPhaseBlocks("mode");for(let e of r){let t=e.mode?.["*"];t&&this.setCustomizations(t,Fb.Mode)}for(let e of r)for(let r of t){let t=e.mode?.[r];t&&this.setCustomizations(t,Fb.Mode)}}onModeEnter(){this.clearTransformedCustomizations(),this.init(this.extensionManager)}onModeExit(){this.clearTransformedCustomizations()}getCustomization(e){let t=this.transformedCustomizations.get(e);if(t)return t;let r=this.globalCustomizations.get(e)??this.modeCustomizations.get(e)??this.defaultCustomizations.get(e),n=this._resolveReferences(this.transform(r),new Set([e]));return void 0!==n&&this.transformedCustomizations.set(e,n),n}_resolveReferences(e,t){if(!e||"object"!=typeof e||e.$$typeof)return e;if("string"==typeof e.$reference)return this._resolveReferenceName(e.$reference,t);if(Array.isArray(e)){let r=!1,n=[];for(let a of e)if(a&&"object"==typeof a&&!a.$$typeof&&"string"==typeof a.$reference){r=!0;let e=this._resolveReferenceName(a.$reference,t);Array.isArray(e)?n.push(...e):void 0!==e&&n.push(e)}else{let e=this._resolveReferences(a,t);r||=e!==a,n.push(e)}return r?n:e}if(!function(e){if(null===e||"object"!=typeof e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(e))return e;let r=!1,n={};for(let[a,i]of Object.entries(e)){let e=this._resolveReferences(i,t);r||=e!==i,n[a]=e}return r?n:e}_resolveReferenceName(e,t){if(t.has(e))return void console.warn(`CustomizationService: $reference cycle detected at "${e}"`);let r=this.globalCustomizations.get(e)??this.modeCustomizations.get(e)??this.defaultCustomizations.get(e);if(void 0===r)return void console.warn(`CustomizationService: no customization registered for $reference "${e}"`);let n=new Set(t).add(e);return this._resolveReferences(this.transform(r),n)}getValue(e,t){let r=this.getCustomization(e);return void 0===r?t:r}setCustomizations(e,t=Fb.Mode){Array.isArray(e)?e.forEach(e=>{this._addReference(e,t)}):Object.entries(e).forEach(([e,r])=>{this._setCustomization(e,r,t)})}setCustomization(e,t,r=Fb.Mode){console.warn("setCustomization is deprecated. Please use setCustomizations with an object instead."),this._setCustomization(e,t,r)}getCustomizations(e){return e===Fb.Global?this.globalCustomizations:e===Fb.Mode?this.modeCustomizations:this.defaultCustomizations}hasCustomization(e){return this.globalCustomizations.has(e)||this.modeCustomizations.has(e)}transform(e){if(!e)return e;let{inheritsFrom:t}=e;if(!t)return e;let r=this.getCustomization(t),n=r?Object.assign({},r,e):e;return n.$transform?.(this)||n}registerCustomUpdateCommand(e,t){e.startsWith("$")||(e="$"+e),(0,NK.extend)(e,t)}_addReference(e,t=Fb.Global){e&&("string"==typeof e&&(e=this._findExtensionValue(e).value),Object.entries(e).forEach(([e,r])=>{this[t===Fb.Global&&"setGlobalCustomization"||t===Fb.Default&&"setDefaultCustomization"||"setModeCustomization"](e,r)}))}addReferences(e,t=Fb.Global){e&&(Array.isArray(e)?e.forEach(e=>{this._addReference(e,t)}):this._addReference(e,t))}clearTransformedCustomizations(){for(let e of(super.reset(),Array.from(this.modeCustomizations.keys())))this.transformedCustomizations.delete(e);this.modeCustomizations.clear()}async _urlDefaultImport(e){if("function"!=typeof fetch)throw Error(`No fetch implementation available to load customization ${e}`);let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch customization ${e}: ${t.status} ${t.statusText}`);return Fs(await t.text())}_normalizeImportedCustomizationModule(e){return e&&"object"==typeof e&&"customizations"in e?e:e&&"object"==typeof e.default?e.default:e}_collectUrlDependencyRefs(e){let t=new Set,r=Fc(e);if(!r||"object"!=typeof r)return Array.from(t);let n=r.requires;if("string"==typeof n&&n)t.add(n);else if(Array.isArray(n))for(let e of n)"string"==typeof e&&e&&t.add(e);return Array.from(t)}_urlDependencyToRequest(e,t){let r=Ff([e],t);return r.valid.length?r.valid[0]:null}_urlCustomizationLoadOne(e,t,r,n,a,i){let o=e.normalized;if(this._urlCustomizationLoaded.has(o))return Promise.resolve(this._urlCustomizationLoaded.get(o)||null);if(this._urlCustomizationPending.has(o))return this._urlCustomizationPending.get(o);a.add(o);let s=this._urlCustomizationLoadOneBody(e,t,r,n,a,i);return this._urlCustomizationPending.set(o,s),s.then(()=>this._urlCustomizationPending.delete(o),()=>this._urlCustomizationPending.delete(o)),s}_urlCustomizationLoadOneBody(e,t,r,n,a,i){let o,s=e.normalized,l=Symbol("importFailed");try{o=function(e,t){let r=(t.prefixes||{})[e.prefix];if(!r)throw Error(`Unknown customization prefix: ${e.prefix}`);if(e.name.includes(".."))throw Error(`Customization name contains traversal: ${e.name}`);let n=e.name.endsWith(".jsonc")?e.name:`${e.name}.jsonc`,a=r.endsWith("/")?r:`${r}/`,i=`${a}${n}`;if(Fm.test(r))return Fy(i,a,e),i;let o="u">typeof window&&window.location?.origin?window.location.origin:"",s="u"<typeof window?"/":window.PUBLIC_URL||"/",l=s?.startsWith("/")?s:`/${s||""}`,u=e=>e.startsWith("./")?e.slice(2):e.startsWith("/")?e.slice(1):e,c=u(i),d=u(a),h=l.endsWith("/")?l:`${l}/`,p=`${h}${c}`,f=`${h}${d}`,m=o?`${o}${p}`:p;return Fy(m,o?`${o}${f}`:f,e),m}(e,t)}catch(r){let t=`[customizationUrl] failed to resolve "${e.raw}": ${r.message}`;return n.warn(t),Promise.resolve(null)}return r(o).catch(t=>(n.warn(`[customizationUrl] failed to import customization "${e.raw}" (${o})`,t),l)).then(u=>{if(u===l)return null;let c=this._normalizeImportedCustomizationModule(u);if(!c||"object"!=typeof c){let t=`[customizationUrl] missing customization module "${e.raw}" (${o}): module is not an object`;return n.warn(t),null}if(!Fc(c)){let t=`[customizationUrl] missing customization module "${e.raw}" (${o}): no customizations payload`;return n.warn(t),null}let d=this._collectUrlDependencyRefs(c),h=Promise.resolve();for(let e of d)h=h.then(()=>{let o=this._urlDependencyToRequest(e,t);if(!(!o||a.has(o.normalized)))return this._urlCustomizationLoadOne(o,t,r,n,a,i)});return h.then(()=>{let t={request:e,module:c,url:o};return this._urlCustomizationLoaded.set(s,t),i.push(t),t})})}_applyLoadedUrlCustomizationModules(e){if(e?.length)for(let t of e){let e=Fc(t.module);e?.global&&this.setCustomizations(e.global,Fb.Global)}}_collectPhaseBlocks(e){let t=[],r=this._getCustomizationConfig().phased;for(let n of(r&&void 0!==r[e]&&t.push(r),this._resolvedUrlModules)){let r=Fc(n.module);r&&void 0!==r[e]&&t.push(r)}return t}_applyPhase(e){for(let t of this._collectPhaseBlocks(e)){let r=t[e];r&&this.setCustomizations(r,Fb.Global)}}_setCustomization(e,t,r=Fb.Mode){switch(r){case Fb.Global:this.setGlobalCustomization(e,t);break;case Fb.Mode:this.setModeCustomization(e,t);break;case Fb.Default:this.setDefaultCustomization(e,t);break;default:throw Error(`Invalid customization scope: ${r}`)}}setModeCustomization(e,t){let r=this.defaultCustomizations.get(e),n=this.modeCustomizations.get(e),a=this.globalCustomizations.get(e),i=n||this._cloneIfNeeded(a)||r,o=this._update(i,t);this.modeCustomizations.set(e,o),this.transformedCustomizations.clear(),this._broadcastEvent(this.EVENTS.MODE_CUSTOMIZATION_MODIFIED,{buttons:this.modeCustomizations,button:this.modeCustomizations.get(e)})}setGlobalCustomization(e,t){let r=this.defaultCustomizations.get(e),n=this.globalCustomizations.get(e),a=this._cloneIfNeeded(n)||r;this.globalCustomizations.set(e,this._update(a,t)),this.transformedCustomizations.clear(),this._broadcastEvent(this.EVENTS.GLOBAL_CUSTOMIZATION_MODIFIED,{buttons:this.globalCustomizations,button:this.globalCustomizations.get(e)})}setDefaultCustomization(e,t){this.transformedCustomizations.clear();let r=this.defaultCustomizations.get(e);this.defaultCustomizations.set(e,this._update(r,t)),this._broadcastEvent(this.EVENTS.DEFAULT_CUSTOMIZATION_MODIFIED,{buttons:this.defaultCustomizations,button:this.defaultCustomizations.get(e)})}_findExtensionValue(e){return this.extensionManager.getModuleEntry(e)}_update(e,t){return(e||(e=void 0),!function e(t){if(Array.isArray(t)){for(let r of t)if(e(r))return!0}else if(t&&"object"==typeof t){if(t.$$typeof)return!1;for(let r of Object.keys(t))if(r.startsWith("$")&&"$transform"!==r&&"$reference"!==r||e(t[r]))return!0}return!1}(t))?t:NY()(e,t)}_cloneIfNeeded(e){return e&&"object"==typeof e?Array.isArray(e)?[...e]:{...e}:e}}Fw.EVENTS=Fv,Fw.REGISTRATION={name:"customizationService",create:({configuration:e,commandsManager:t})=>new Fw({configuration:e,commandsManager:t})},(0,NK.extend)("$filter",(e,t)=>(function e(t,r){if(Array.isArray(t))return"function"==typeof r?t.filter(r):"string"==typeof r?t.filter(e=>e.id!==r):"object"==typeof r&&r.match&&r.$merge?t.map(t=>e(t,r)).map(e=>{var t;return(t=r.match,e&&"object"==typeof e&&Object.entries(t).every(([t,r])=>e[t]===r))?{...e,...r.$merge}:e}):"object"==typeof r&&r.id&&r.$merge?t.map(t=>e(t,r)).map(e=>e.id===r.id?{...e,...r.$merge}:e):t.map(t=>e(t,r));if(t&&"object"==typeof t){let n={...t};for(let[t,a]of Object.entries(n))n[t]=e(a,r);return n}return t})(t,e));let Fx=["requires","bootstrap","global","mode"];function FC(){return(FC=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(null,arguments)}let Fk={PANELS_CHANGED:"event::panelService:panelsChanged",ACTIVATE_PANEL:"event::panelService:activatePanel"},FM=((egt={}).Left="left",egt.Right="right",egt.Bottom="bottom",egt);class FE extends Lx{constructor(e){super(Fk),this._extensionManager=void 0,this._panelsGroups=new Map,this._extensionManager=e}get PanelPosition(){return FM}_getPanelComponent(e){let t=this._extensionManager.getModuleEntry(e);if(!t){let t=this._getSimilarPanels(e);if(t.length>0){let r=`Did you mean: ${t.join(", ")}?`;throw Error(`${e} is not a valid entry for an extension module. ${r} Please check your configuration or make sure the extension is registered.`)}throw Error(`${e} is not a valid entry for an extension module, please check your configuration or make sure the extension is registered.`)}if(!t?.component)throw Error(`No component found from extension ${e}. Check the reference string to the extension in your Mode configuration`);let r=t.component;return{entry:t,content:r}}_getSimilarPanels(e,t=.8){return Object.keys(this._extensionManager.modulesMap).filter(e=>e.includes("panelModule")).filter(r=>this._calculateSimilarity(e,r)>=t)}_calculateSimilarity(e,t){let r=new Set(e.toLowerCase().split("")),n=new Set(t.toLowerCase().split("")),a=new Set([...r].filter(e=>n.has(e))),i=new Set([...r,...n]);return a.size/i.size}getPanelData(e){let t,r;if(Array.isArray(e)){let n=e.map(e=>this._getPanelComponent(e));r=n[0].entry,t=e=>ey().createElement(ey().Fragment,null,n.map(({content:t},r)=>ey().createElement(t,FC({key:r},e))))}else({content:t,entry:r}=this._getPanelComponent(e));return{id:r.id,iconName:r.iconName,iconLabel:r.iconLabel,label:r.label,name:r.name,content:t}}addPanel(e,t,r){let n=this._panelsGroups.get(e);n||(n=[],this._panelsGroups.set(e,n));let a=this.getPanelData(t);n.push(a),this._broadcastEvent(Fk.PANELS_CHANGED,{position:e,options:r})}addPanels(e,t,r){if(!Array.isArray(t))throw Error('Invalid "panelsIds" array');t.forEach(t=>this.addPanel(e,t,r))}setPanels(e,t){this.reset(),Object.keys(e).forEach(r=>{this.addPanels(r,e[r],t)})}getPanels(e){return[...this._panelsGroups.get(e)??[]]}reset(){let e=Array.from(this._panelsGroups.keys());this._panelsGroups.clear(),e.forEach(e=>this._broadcastEvent(Fk.PANELS_CHANGED,{position:e}))}onModeExit(){this.reset()}activatePanel(e,t=!1){this._broadcastEvent(Fk.ACTIVATE_PANEL,{panelId:e,forceActive:t})}addActivatePanelTriggers(e,t,r=!1){return t.map(t=>t.sourceEvents.map(n=>t.sourcePubSubService.subscribe(n,()=>this.activatePanel(e,r)))).flat()}}FE.REGISTRATION={name:"panelService",create:({extensionManager:e})=>new FE(e)};let FS={ACTIVE_STEP_CHANGED:"event::workflowStepsService:activateStepChanged",STEPS_CHANGED:"event::workflowStepsService:stepsChanged"};class FD extends Lx{constructor(e,t,r){super(FS),this._extensionManager=void 0,this._servicesManager=void 0,this._commandsManager=void 0,this._workflowSteps=void 0,this._activeWorkflowStep=void 0,this._workflowSteps=[],this._activeWorkflowStep=null,this._extensionManager=e,this._commandsManager=t,this._servicesManager=r}get workflowSteps(){return[...this._workflowSteps]}get activeWorkflowStep(){return this._activeWorkflowStep}addWorkflowSteps(e){let t=!1;e.forEach(e=>{if(this._workflowSteps.some(t=>t.id===e.id))throw Error(`Duplicated workflow step id (${e.id})`);this._workflowSteps.push(e),t=!0}),t&&this._broadcastEvent(FS.STEPS_CHANGED,{})}_updateToolBar(e){let{toolbarService:t}=this._servicesManager.services,{toolbarButtons:r}=e;(Array.isArray(r)?r:[r]).forEach(({buttonSection:e,buttons:r})=>{t.clearButtonSection(e),t.updateSection(e,r)})}_updatePanels(e){let{panelService:t}=this._servicesManager.services,r=e?.layout?.panels;r&&t.setPanels(r,e?.layout?.options)}_updateHangingProtocol(e){let{hangingProtocol:t}=e;t&&this._commandsManager.runCommand("setHangingProtocol",{protocolId:t.protocolId,stageId:t.stageId,stageIndex:t.stageIndex})}_invokeCallbacks(e){if(!e)return;let t=this._commandsManager;Array.isArray(e)||(e=[e]),e.forEach(e=>{let r=e;if(e?.commandName){let{commandName:n,options:a}=e;r=()=>t.runCommand(n,a)}r()})}setActiveWorkflowStep(e){let t=this._activeWorkflowStep;if(e===t?.id)return;let r=this._workflowSteps.find(t=>t.id===e);if(!r)throw Error(`Invalid workflowStepId (${e})`);this._activeWorkflowStep&&this._invokeCallbacks(t.onExit),this._invokeCallbacks(r.onEnter),this._activeWorkflowStep=r,this._updateToolBar(r),this._updatePanels(r),this._updateHangingProtocol(r),this._broadcastEvent(FS.ACTIVE_STEP_CHANGED,{activeWorkflowStep:r})}reset(){this._activeWorkflowStep=null,this._workflowSteps=[]}onModeEnter(){this.reset()}}FD.REGISTRATION={name:"workflowStepsService",create:({extensionManager:e,commandsManager:t,servicesManager:r})=>new FD(e,t,r)};var FI=((egr=FI||{}).Interaction="interaction",egr.Thumbnail="thumbnail",egr.Prefetch="prefetch",egr.Compute="compute",egr);let FP={SERVICE_STARTED:"event::studyPrefetcherService:started",SERVICE_STOPPED:"event::studyPrefetcherService:stopped",DISPLAYSET_LOAD_PROGRESS:"event::studyPrefetcherService:displaySetLoadProgress",DISPLAYSET_LOAD_COMPLETE:"event::studyPrefetcherService:displaySetLoadComplete"};var FT=((egn=FT||{}).closest="closest",egn.downward="downward",egn.upward="upward",egn);class F_ extends Lx{constructor({servicesManager:e,extensionManager:t,configuration:r}){super(FP),this._extensionManager=void 0,this._servicesManager=void 0,this._subscriptions=void 0,this._activeDisplaySetsInstanceUIDs=[],this._pendingRequests=[],this._inflightRequests=new Map,this._isRunning=!1,this._displaySetLoadingStates=new Map,this._imageIdsToDisplaySetsMap=new Map,this.config={enabled:!1,displaySetsCount:1,maxNumPrefetchRequests:10,order:FT.downward},this.requestType=FI.Prefetch,this.cache=void 0,this.imageLoadPoolManager=void 0,this.imageLoader=void 0,this.imageLoadEventsManager=void 0,this._servicesManager=e,this._extensionManager=t,this._subscriptions=[],Object.assign(this.config,r)}onModeEnter(){this._addEventListeners()}onModeExit(){this._removeEventListeners(),this._stopPrefetching()}_addImageLoadingEventsListeners(){let e=e=>{this._inflightRequests.get(e)||this._sendNextRequests()},t=t=>{let{image:r}=t.detail,{imageId:n}=r;this._moveImageIdToLoadedSet(n),e(n)},r=t=>{let{imageId:r}=t.detail;this._moveImageIdToFailedSet(r),e(r)};return this.imageLoadEventsManager.addEventListeners(t,r)}_addServicesListeners(){let{displaySetService:e,viewportGridService:t}=this._servicesManager.services;return[e.subscribe(e.EVENTS.DISPLAY_SETS_CHANGED,()=>this._syncWithActiveViewport({forceRestart:!0})),t.subscribe(L3.EVENTS.ACTIVE_VIEWPORT_ID_CHANGED,({viewportId:e})=>this._syncWithActiveViewport({activeViewportId:e})),t.subscribe(L3.EVENTS.LAYOUT_CHANGED,()=>this._syncWithActiveViewport()),t.subscribe(L3.EVENTS.GRID_STATE_CHANGED,()=>this._syncWithActiveViewport()),t.subscribe(L3.EVENTS.VIEWPORTS_READY,()=>{this._syncWithActiveViewport(),this._startPrefetching()})]}_addEventListeners(){let e=this._addImageLoadingEventsListeners(),t=this._addServicesListeners();this._subscriptions.push(...e),this._subscriptions.push(...t)}_removeEventListeners(){this._subscriptions.forEach(e=>e.unsubscribe()),this._subscriptions=[]}_syncWithActiveViewport({activeViewportId:e,forceRestart:t}={}){let{viewportGridService:r}=this._servicesManager.services,n=r.getState(),{viewports:a}=n;if(!(e=e??n.activeViewportId))return;let i=a.get(e);if(!i)return;let o=this._setActiveDisplaySetsUIDs(i.displaySetInstanceUIDs);(t||o)&&this._restartPrefetching()}_setActiveDisplaySetsUIDs(e){return!(e.length===this._activeDisplaySetsInstanceUIDs.length&&e.every(e=>this._activeDisplaySetsInstanceUIDs.includes(e)))&&(this._activeDisplaySetsInstanceUIDs=[...e],this._restartPrefetching(),!0)}_areActiveDisplaySetsLoaded(){let{_activeDisplaySetsInstanceUIDs:e}=this;return e.length&&e.every(e=>this._displaySetLoadingStates.get(e).loadingProgress>=1)}_getClosestDisplaySets(e,t){let r=[],n=t-1,a=t+1;for(;n>=0||a<e.length;)n>=0&&(r.push(e[n]),n--),a<e.length&&(r.push(e[a]),a++);return r}_getDownwardDisplaySets(e,t){let r=[];for(let n=t+1;n<e.length;n++)r.push(e[n]);return r}_getUpwardDisplaySets(e,t){let r=[];for(let n=t-1;n>=0&&n!==t;n--)r.push(e[n]);return r}_getSortedDisplaySetsToPrefetch(e){if(!this._activeDisplaySetsInstanceUIDs?.length)return[];let{displaySetsCount:t}=this.config,r=this._activeDisplaySetsInstanceUIDs,[n]=r,a=e.findIndex(e=>e.displaySetInstanceUID===n),i={[FT.closest]:this._getClosestDisplaySets,[FT.downward]:this._getDownwardDisplaySets,[FT.upward]:this._getUpwardDisplaySets},{order:o}=this.config,s=i[o];if(!s)throw Error(`Invalid order (${o})`);let l=new Set(r);return s.call(this,e,a).filter(e=>!l.has(e.displaySetInstanceUID)).slice(0,t)}_getDisplaySets(){let{displaySetService:e}=this._servicesManager.services,t=[...e.getActiveDisplaySets()],r=this._getSortedDisplaySetsToPrefetch(t);return{displaySets:t,displaySetsToPrefetch:r}}_updateImageIdsDisplaySetMap(e,t){for(let r of t){let t=this._imageIdsToDisplaySetsMap.get(r);t||(t=new Set,this._imageIdsToDisplaySetsMap.set(r,t)),t.add(e)}}_getImageIdsForDisplaySet(e){return this._extensionManager.getActiveDataSource()[0].getImageIdsForDisplaySet(e)}_updateDisplaySetLoadingProgress(e){let{numInstances:t,loadedImageIds:r,failedImageIds:n}=e;e.loadingProgress=(r.size+n.size)/t}_addDisplaySetLoadingState(e){let{displaySetInstanceUID:t}=e,r=this._getImageIdsForDisplaySet(e),n=this._displaySetLoadingStates.get(t);if(n)return;let a=new Set(r),i=new Set;for(let e of r)this.cache.isImageCached(e)?i.add(e):a.add(e);n={displaySetInstanceUID:t,numInstances:r.length,pendingImageIds:a,loadedImageIds:i,failedImageIds:new Set,loadingProgress:0},this._updateDisplaySetLoadingProgress(n),this._displaySetLoadingStates.set(t,n),this._updateImageIdsDisplaySetMap(t,r),i.size&&this._triggerDisplaySetEvents(t)}_loadDisplaySets(){let{displaySets:e,displaySetsToPrefetch:t}=this._getDisplaySets();e.forEach(e=>this._addDisplaySetLoadingState(e)),t.forEach(e=>this._enqueueDisplaySetImagesRequests(e))}_moveImageIdToLoadedSet(e){let t=this._imageIdsToDisplaySetsMap.get(e);if(t){for(let r of Array.from(t.values())){let t=this._displaySetLoadingStates.get(r),{pendingImageIds:n,loadedImageIds:a}=t;n.delete(e),a.add(e),this._updateDisplaySetLoadingProgress(t),this._triggerDisplaySetEvents(r)}return!0}}_moveImageIdToFailedSet(e){let t=this._imageIdsToDisplaySetsMap.get(e);if(t){for(let r of Array.from(t.values())){let t=this._displaySetLoadingStates.get(r),{pendingImageIds:n,failedImageIds:a}=t;n.delete(e),a.add(e),this._updateDisplaySetLoadingProgress(t),this._triggerDisplaySetEvents(r)}return!0}}_triggerDisplaySetEvents(e){let{loadingProgress:t,numInstances:r}=this._displaySetLoadingStates.get(e);this._broadcastEvent(this.EVENTS.DISPLAYSET_LOAD_PROGRESS,{displaySetInstanceUID:e,numInstances:r,loadingProgress:t}),t>=1&&this._broadcastEvent(this.EVENTS.DISPLAYSET_LOAD_COMPLETE,{displaySetInstanceUID:e})}_onImagePrefetchSuccess(e){if(e.aborted)return;let{imageId:t}=e;this._inflightRequests.delete(t),this._moveImageIdToLoadedSet(t),this._sendNextRequests()}_onImagePrefetchFailed(e,t){if(e.aborted)return;console.warn(`An error ocurred when trying to load "${e.imageId}"`,t);let{imageId:r}=e;this._inflightRequests.delete(r),this._moveImageIdToFailedSet(r),this._sendNextRequests()}async _sendNextRequests(){if(!this._isRunning||!this._areActiveDisplaySetsLoaded())return;let{_pendingRequests:e,_inflightRequests:t}=this,{maxNumPrefetchRequests:r}=this.config;if(!e.length||t.size>=r)return;let n=Math.min(e.length,r-t.size);this._pendingRequests.splice(0,n).forEach(e=>{let{imageId:r}=e,n={priority:-5,requestType:this.requestType,additionalDetails:{imageId:r},preScale:{enabled:!0}};this.imageLoadPoolManager.addRequest(async()=>this.imageLoader.loadAndCacheImage(r,n).then(t=>this._onImagePrefetchSuccess(e),t=>this._onImagePrefetchFailed(e,t)),this.requestType,{imageId:r}),t.set(r,e)})}_enqueueDisplaySetImagesRequests(e){let{displaySetInstanceUID:t}=e;this._getImageIdsForDisplaySet(e).forEach(e=>{this.cache.isImageCached(e)?this._moveImageIdToLoadedSet(e):this._pendingRequests.push({displaySetInstanceUID:t,imageId:e,aborted:!1})})}_startPrefetching(){if(!this._isRunning){if(!this.config.enabled)return void console.log("StudyPrefetcher is not enabled");this._isRunning=!0,this._loadDisplaySets(),this._sendNextRequests(),this._broadcastEvent(this.EVENTS.SERVICE_STARTED,{})}}_stopPrefetching(){this._isRunning&&(this._isRunning=!1,this._inflightRequests.forEach(e=>e.aborted=!0),this._pendingRequests=[],this._displaySetLoadingStates.clear(),this._imageIdsToDisplaySetsMap.clear(),this._inflightRequests.clear(),this.imageLoadPoolManager.clearRequestStack(this.requestType),this._broadcastEvent(this.EVENTS.SERVICE_STOPPED,{}))}_restartPrefetching(){this._isRunning&&(this._stopPrefetching(),this._startPrefetching())}}F_.REGISTRATION={name:"studyPrefetcherService",altName:"StudyPrefetcherService",create:({configuration:e,servicesManager:t,extensionManager:r})=>new F_({servicesManager:t,extensionManager:r,configuration:e})};class FA{constructor(e,t){this.numberOfScreens=void 0,this.windowsConfig=void 0,this.screenConfig=void 0,this.launchWindows=[],this.basePath=void 0,this.screenNumber=void 0,this.isMultimonitor=void 0,this.setLaunchWindows=e=>{this.launchWindows=e,window.multimonitor.launchWindows=e};const r=new URLSearchParams(window.location.search),n=r.get("screenNumber"),a=r.get("multimonitor"),i={params:r,screenNumber:n,multimonitor:a};this.screenNumber=n?Number(n):-1,this.commandsManager=t;const o=window;for(const r of(o.multimonitor||={setLaunchWindows:this.setLaunchWindows,launchWindows:this.launchWindows,commandsManager:t},o.multimonitor.commandsManager=t,this.launchWindows=window.multimonitor?.launchWindows||this.launchWindows,-1!==this.screenNumber&&(this.launchWindows[this.screenNumber]=window),o.commandsManager=(...t)=>e.commandsManager,Array.isArray(e)?e:[])){if(r.test(i)){if(this.isMultimonitor=!0,this.numberOfScreens=r.screens.length,this.windowsConfig=r,-1===this.screenNumber||null===this.screenNumber)this.screenConfig=FA.SOURCE_SCREEN;else{if(this.screenConfig=r.screens[this.screenNumber],!this.screenConfig)throw Error(`Screen ${n} not configured in ${this.windowsConfig}`);window.name=this.screenConfig.id}return}this.numberOfScreens=1,this.isMultimonitor=!1}}async run(e=1,t,r){let n=(this.screenNumber+(e??1))%this.numberOfScreens,a=await this.getWindow(n);a?a.multimonitor?.commandsManager?a.multimonitor.commandsManager.runAsync(t,r):console.warn("Didn't find a commands manager to run in the other window",a):console.warn("No multimonitor found for screen",n,t)}async launchWindow(e,t=1,r=""){let n=(this.screenNumber+t)%this.numberOfScreens;return this.getWindow(n,e?`StudyInstanceUIDs=${e}${r}`:"")}async getWindow(e,t){return e===this.screenNumber?window:this.launchWindows[e]&&!this.launchWindows[e].closed?this.launchWindows[e]:await this.createWindow(e,t)}async createWindow(e,t){if(e===this.screenNumber)return window;let r=this.windowsConfig.screens[e],n=await window.getScreenDetails?.(),{width:a=1024,height:i=1024,availLeft:o=0,availTop:s=0}=r.screen>=0&&n.screens[r.screen]||n.currentScreen||window.screen||{},l=this.windowsConfig.screens[e],{width:u=1,height:c=1,top:d=0,left:h=0}=l.location||{},p=Math.round(o+h*a),f=Math.round(s+d*i),m=Math.round(a*u),g=Math.round(i*c),y=`${this.basePath}&screenNumber=${e}`,v=t?`${y}#${t}`:y,b=l.id,w=l.options||"",x=`screenX=${p},screenY=${f},width=${m},height=${g},${w}`,C=window.open("",b,x);return(C?.location.href.startsWith(y)||(C=window.open(v,b,x)),C)?(await new Promise(e=>{"complete"===C.document.readyState?e():C.addEventListener("load",()=>e())}),this.launchWindows[e]=C,C):void console.warn("Unable to launch window",v,"called",b,"at",x)}launchAll(){for(let e=0;e<this.numberOfScreens;e++)this.createWindow(e)}setBasePath(){let e=new URL(window.location.href);e.searchParams.delete("screenNumber"),e.searchParams.delete("protocolId"),e.searchParams.delete("launchAll"),e.searchParams.set("multimonitor",e.searchParams.get("multimonitor")||"split"),e.hash="",this.basePath=e.toString()}onModeEnter(){this.setBasePath(),(this.isMultimonitor&&-1===this.screenNumber||-1!==window.location.href.toLowerCase().indexOf("launchall"))&&this.launchAll()}}FA.SOURCE_SCREEN={id:"source",launch:"source",screen:null,location:{screen:null,width:1,height:1,left:0,top:0}},FA.REGISTRATION={name:"multiMonitorService",create:({configuration:e,commandsManager:t})=>new FA(e,t)};class FO extends Lx{constructor({commandsManager:e,servicesManager:t,serviceProvidersManager:r,hotkeysManager:n,appConfig:a={}}){super(FO.EVENTS),this._commandsManager=void 0,this._servicesManager=void 0,this._hotkeysManager=void 0,this._serviceProvidersManager=void 0,this.modulesMap=void 0,this.modules=void 0,this.registeredExtensionIds=void 0,this.moduleTypeNames=void 0,this._appConfig=void 0,this._extensionLifeCycleHooks=void 0,this.dataSourceMap=void 0,this.dataSourceDefs=void 0,this._activeDataSourceName=void 0,this.registerExtensions=async(e,t=[])=>{for(let r=0;r<e.length;r++){let n=e[r],a=Array.isArray(n);try{if(a){let e=n[0],r=n[1];await this.registerExtension(e,r,t)}else await this.registerExtension(n,{},t)}catch(e){console.error(e)}}},this.registerExtension=async(e,t={},r=[])=>{if(!e)throw Error("Attempting to register a null/undefined extension.");let n=e.id;if(!n)throw Lp.warn(e),Error("Extension ID not set");this.registeredExtensionIds.includes(n)?Lp.warn(`Extension ID ${n} has already been registered. Exiting before duplicating modules.`):(e.preRegistration&&await e.preRegistration({servicesManager:this._servicesManager,serviceProvidersManager:this._serviceProvidersManager,commandsManager:this._commandsManager,hotkeysManager:this._hotkeysManager,extensionManager:this,appConfig:this._appConfig,configuration:t}),e.onModeEnter&&(this._extensionLifeCycleHooks.onModeEnter[n]=e.onModeEnter),e.onModeExit&&(this._extensionLifeCycleHooks.onModeExit[n]=e.onModeExit),this.moduleTypeNames.forEach(a=>{let i=this._getExtensionModule(a,e,n,t);if(i){switch(a){case Lh.COMMANDS:this._initCommandsModule(i);break;case Lh.DATA_SOURCE:this._initDataSourcesModule(i,n,r);break;case Lh.HANGING_PROTOCOL:this._initHangingProtocolsModule(i,n);break;case Lh.PANEL:this._initPanelModule(i,n);break;case Lh.TOOLBAR:this._initToolbarModule(i,n);break;case Lh.VIEWPORT:case Lh.SOP_CLASS_HANDLER:case Lh.CONTEXT:case Lh.LAYOUT_TEMPLATE:case Lh.CUSTOMIZATION:case Lh.STATE_SYNC:case Lh.UTILITY:this.processExtensionModule(i,n,a);break;default:throw Error(`Module type invalid: ${a}`)}this.modules[a].push({extensionId:n,module:i})}}),this.registeredExtensionIds.push(n))},this.getModuleEntry=e=>this.modulesMap[e],this.getModulesByType=e=>this.modules[e],this.getDataSources=e=>(e||(e=this._activeDataSourceName),this.dataSourceMap[e]),this.getDataSourceInstance=e=>this.dataSourceMap[e][0],this.getActiveDataSource=()=>this.dataSourceMap[this._activeDataSourceName],this.getActiveDataSourceOrNull=()=>this.dataSourceMap[this._activeDataSourceName]?.[0]??null,this.getDataSourceDefinition=e=>(void 0===e&&(e=this._activeDataSourceName),this.dataSourceDefs[e]),this.getActiveDataSourceDefinition=()=>this.getDataSourceDefinition(this._activeDataSourceName),this.getDataSourcesForUI=()=>{if(this._appConfig?.allowMultiSelectExport===!1)return[];let e=Object.keys(this.dataSourceMap).filter(e=>{let t=this.dataSourceDefs[e]?.configuration,r=this.dataSourceDefs[e].sourceName!==this._activeDataSourceName;return(t?.supportsStow??t?.wadoRoot)&&r});return[this._activeDataSourceName,...e].map(e=>({value:e,label:e,placeHolder:e}))},this._getExtensionModule=(e,t,r,n)=>{var a;let i="get"+((a=e).charAt(0).toUpperCase()+a.substring(1));if(t[i])try{let e=t[i]({appConfig:this._appConfig,commandsManager:this._commandsManager,servicesManager:this._servicesManager,hotkeysManager:this._hotkeysManager,extensionManager:this,configuration:n});return e||Lp.warn(`Null or undefined returned when registering the ${i} module for the ${r} extension`),e}catch(e){throw console.error(e),Error(`Exception thrown while trying to call ${i} for the ${r} extension`)}},this._initHangingProtocolsModule=(e,t)=>{let{hangingProtocolService:r}=this._servicesManager.services;e.forEach(({name:e,protocol:t})=>{t&&r.addProtocol(e,t)})},this._initPanelModule=(e,t)=>{this.processExtensionModule(e,t,Lh.PANEL)},this._initToolbarModule=(e,t)=>{let{toolbarService:r}=this._servicesManager.services;e.forEach(e=>{e.evaluate&&r.registerEvaluateFunction(e.name,e.evaluate)})},this._initCommandsModule=e=>{let{definitions:t,defaultContext:r}=e;t&&0!==Object.keys(t).length?(r=r||"VIEWER",this._commandsManager.getContext(r)||this._commandsManager.createContext(r),Object.keys(t).forEach(e=>{let n=t[e];"function"==typeof n&&(n={commandFn:n}),n.context&&!this._commandsManager.getContext(n.context)&&this._commandsManager.createContext(n.context),this._commandsManager.registerCommand(n.context||r,e,n)})):Lp.warn("Commands Module contains no command definitions")},this.modules={},this.registeredExtensionIds=[],this.moduleTypeNames=Object.values(Lh),this._commandsManager=e,this._servicesManager=t,this._serviceProvidersManager=r,this._hotkeysManager=n,this._appConfig=a,this.modulesMap={},this.moduleTypeNames.forEach(e=>{this.modules[e]=[]}),this._extensionLifeCycleHooks={onModeEnter:{},onModeExit:{}},this.dataSourceMap={},this.dataSourceDefs={},this.defaultDataSourceName=a.defaultDataSourceName,this._activeDataSourceName=a.defaultDataSourceName,this.peerImport=a.peerImport}setActiveDataSource(e){this._activeDataSourceName!==e&&(this._activeDataSourceName=e,this._broadcastEvent(FO.EVENTS.ACTIVE_DATA_SOURCE_CHANGED,this.dataSourceDefs[this._activeDataSourceName]))}getRegisteredExtensionIds(){return[...this.registeredExtensionIds]}getUniqueServicesList(e){return Array.from(new Set(Object.values(e.services)))}onModeEnter(){let{registeredExtensionIds:e,_servicesManager:t,_commandsManager:r,_hotkeysManager:n,_extensionLifeCycleHooks:a}=this;for(let e of this.getUniqueServicesList(t))e?.onModeEnter?.();e.forEach(e=>{let i=a.onModeEnter[e];"function"==typeof i&&i({servicesManager:t,commandsManager:r,hotkeysManager:n,extensionManager:this})})}onModeExit(){let{registeredExtensionIds:e,_servicesManager:t,_commandsManager:r,_extensionLifeCycleHooks:n}=this,a=this.getUniqueServicesList(t);for(let i of(e.forEach(e=>{let a=n.onModeExit[e];"function"==typeof a&&a({servicesManager:t,commandsManager:r})}),a))try{i?.onModeExit?.()}catch(e){console.warn("onModeExit caught",e)}}processExtensionModule(e,t,r){e.forEach(e=>{if(!e.name)throw Error(`Extension ID ${t} module ${r} element has no name`);let n=`${t}.${r}.${e.name}`;e.id=n,this.modulesMap[n]=e})}addDataSource(e,t={activate:!1}){let r=this.getDataSources(e.sourceName);!r?.[0]&&(this._createDataSourceInstance(e),t.activate&&this.setActiveDataSource(e.sourceName))}updateDataSourceConfiguration(e,t){let r=this.getDataSources(e);if(!r?.[0])return;let n=this.dataSourceDefs[e];n.configuration=t,this._createDataSourceInstance(n),this._activeDataSourceName===e&&this._broadcastEvent(FO.EVENTS.ACTIVE_DATA_SOURCE_CHANGED,n)}_createDataSourceInstance(e){let t=this.getModuleEntry(e.namespace);if(!t)return;this.dataSourceDefs[e.sourceName]=e;let r=t.createDataSource(e.configuration,this._servicesManager,this);this.dataSourceMap[e.sourceName]=[r]}_initDataSourcesModule(e,t,r=[]){e.forEach(e=>{this.modulesMap[`${t}.${Lh.DATA_SOURCE}.${e.name}`]=e}),e.forEach(e=>{let n=`${t}.${Lh.DATA_SOURCE}.${e.name}`;r.forEach(e=>{e.namespace===n&&this.addDataSource(e)})})}registerCommandsModule(e,t="VIEWER"){this._initCommandsModule({...e,defaultContext:e.defaultContext||t})}get appConfig(){return this._appConfig}get activeDataSourceName(){return this._activeDataSourceName}}FO.EVENTS={ACTIVE_DATA_SOURCE_CHANGED:"event::activedatasourcechanged"},FO.MODULE_TYPES=Lh;var FR=u(2203),FL=u.n(FR);let FN=[{commandName:"setToolActive",commandOptions:{toolName:"Zoom"},label:"Zoom",keys:["z"],isEditable:!0},{commandName:"scaleUpViewport",label:"Zoom In",keys:["+"],isEditable:!0},{commandName:"scaleDownViewport",label:"Zoom Out",keys:["-"],isEditable:!0},{commandName:"fitViewportToWindow",label:"Zoom to Fit",keys:["="],isEditable:!0},{commandName:"rotateViewportCW",label:"Rotate Right",keys:["r"],isEditable:!0},{commandName:"rotateViewportCCW",label:"Rotate Left",keys:["l"],isEditable:!0},{commandName:"flipViewportHorizontal",label:"Flip Horizontally",keys:["h"],isEditable:!0},{commandName:"flipViewportVertical",label:"Flip Vertically",keys:["v"],isEditable:!0},{commandName:"toggleCine",label:"Cine",keys:["c"]},{commandName:"invertViewport",label:"Invert",keys:["i"],isEditable:!0},{commandName:"incrementActiveViewport",label:"Next Image Viewport",keys:["right"],isEditable:!0},{commandName:"decrementActiveViewport",label:"Previous Image Viewport",keys:["left"],isEditable:!0},{commandName:"updateViewportDisplaySet",commandOptions:{direction:-1},label:"Previous Series",keys:["pageup"],isEditable:!0},{commandName:"updateViewportDisplaySet",commandOptions:{direction:1},label:"Next Series",keys:["pagedown"],isEditable:!0},{commandName:"nextStage",context:"DEFAULT",label:"Next Stage",keys:["."],isEditable:!0},{commandName:"previousStage",context:"DEFAULT",label:"Previous Stage",keys:[","],isEditable:!0},{commandName:"nextImage",label:"Next Image",keys:["down"],isEditable:!0},{commandName:"previousImage",label:"Previous Image",keys:["up"],isEditable:!0},{commandName:"firstImage",label:"First Image",keys:["home"],isEditable:!0},{commandName:"lastImage",label:"Last Image",keys:["end"],isEditable:!0},{commandName:"resetViewport",label:"Reset",keys:["space"],isEditable:!0},{commandName:"cancelActiveOperation",label:"Cancel",keys:["esc"]},{commandName:"setWindowLevelPreset",commandOptions:{presetName:"ct-soft-tissue",presetIndex:0},label:"W/L Preset 1",keys:["1"]},{commandName:"setWindowLevelPreset",commandOptions:{presetName:"ct-lung",presetIndex:1},label:"W/L Preset 2",keys:["2"]},{commandName:"setWindowLevelPreset",commandOptions:{presetName:"ct-bone",presetIndex:2},label:"W/L Preset 3",keys:["3"]},{commandName:"setWindowLevelPreset",commandOptions:{presetName:"ct-brain",presetIndex:3},label:"W/L Preset 4",keys:["4"]},{commandName:"deleteActiveAnnotation",label:"Delete Annotation",keys:["backspace"]},{commandName:"acceptPreview",label:"Accept Preview",keys:["enter"]},{commandName:"undo",label:"Undo",keys:["ctrl+z"],isEditable:!0},{commandName:"redo",label:"Redo",keys:["ctrl+y"],isEditable:!0},{commandName:"interpolateScrollForMarkerLabelmap",label:"Interpolate Scroll",keys:["n"],isEditable:!0},{commandName:"increaseBrushSize",label:"Increase Brush Size",keys:["]"],isEditable:!0},{commandName:"decreaseBrushSize",label:"Decrease Brush Size",keys:["["],isEditable:!0},{commandName:"setToolActive",commandOptions:{toolName:"CircularEraser"},label:"Eraser",keys:["e"],isEditable:!0},{commandName:"setToolActive",commandOptions:{toolName:"CircularBrush"},label:"Brush",keys:["b"],isEditable:!0},{commandName:"addNewSegment",label:"Add New Segment",keys:["a"],isEditable:!0}],FF=function({generateHash:e}){try{let t=localStorage.getItem("hotkey-definitions"),r=localStorage.getItem("hotkeys-migrated");if(!t||"true"===r)return;let n=JSON.parse(t);if(!Array.isArray(n)||0===n.length)return;let a=FN||[],i=JSON.parse(localStorage.getItem("user-preferred-keys")||"{}");n.forEach(t=>{if(!t.commandName||!t.keys)return;let r=a.find(e=>{let r=e.commandName===t.commandName,n=t.commandOptions||{},a=e.commandOptions||{},i=JSON.stringify(n)===JSON.stringify(a);return r&&i});r&&JSON.stringify(r.keys)===JSON.stringify(t.keys)||(i[e({commandName:t.commandName,commandOptions:t.commandOptions||{}})]=t.keys,console.debug(`HotkeysManager: Migrated custom hotkey for ${t.commandName}`))}),localStorage.setItem("user-preferred-keys",JSON.stringify(i)),localStorage.setItem("hotkeys-migrated","true"),localStorage.removeItem("hotkey-definitions"),console.debug("HotkeysManager: Successfully migrated hotkey definitions to new format")}catch(e){console.error("HotkeysManager: Error migrating hotkey definitions",e),localStorage.setItem("hotkeys-migrated","false")}};class FV{constructor(e,t){this._servicesManager=void 0,this._commandsManager=void 0,this.isEnabled=!0,this.hotkeyDefinitions={},this.hotkeyDefaults=[],this.EVENTS=void 0,this.listeners={},this.subscribe=void 0,this._broadcastEvent=void 0,this._unsubscribe=void 0,this._isValidEvent=void 0,this._servicesManager=t,this._commandsManager=e,this.EVENTS=FV.EVENTS,this.subscribe=Lg.subscribe.bind(this),this._broadcastEvent=Lg._broadcastEvent.bind(this),this._unsubscribe=Lg._unsubscribe.bind(this),this._isValidEvent=Lg._isValidEvent.bind(this),FF({generateHash:this.generateHash})}record(e){return Nu.record(e)}cancel(){Nu.stopRecord(),Nu.unpause()}disable(){this.isEnabled=!1,Nu.pause()}enable(){this.isEnabled=!0,Nu.unpause()}restoreDefaultBindings(){this.setHotkeys(this.hotkeyDefaults)}destroy(){this.hotkeyDefaults=[],this.hotkeyDefinitions={},Nu.reset()}setHotkeys(e=[]){try{this.getValidDefinitions(e).forEach(e=>this.registerHotkeys(e))}catch(t){let{uiNotificationService:e}=this._servicesManager.services;e.show({title:"Hotkeys Manager",message:"Error while setting hotkeys",type:"error"})}}generateHash(e){return FL()({commandName:e.commandName,commandOptions:e.commandOptions||{}})}setDefaultHotKeys(e=[]){let t=this.getValidDefinitions(e);this.hotkeyDefaults=t;let r=JSON.parse(localStorage.getItem("user-preferred-keys")||"{}"),n=t.map(e=>{let t=this.generateHash(e);return r[t]?{...e,keys:r[t]}:e});this.setHotkeys(n)}getValidDefinitions(e){let t=Array.isArray(e)?[...e]:this._parseToArrayLike(e);return t.forEach(e=>{void 0===e.isEditable&&(e.isEditable=!0)}),t}getValidHotkeyDefinitions(e){let t=this.getValidDefinitions(e),r={};return t.forEach(e=>{let{commandName:t,commandOptions:n}=e;r[FL()({commandName:t,commandOptions:n})]=e}),r}_parseToArrayLike(e={}){return Object.entries({...e}).map(e=>this._parseToHotKeyObj(e[0],e[1]))}_parseToHotKeyObj(e,t){return{commandName:e,...t}}registerHotkeys({commandName:e,commandOptions:t={},context:r,keys:n,label:a,isEditable:i}){if(!e)throw Error(`No command was defined for hotkey "${n}"`);let o=this.generateHash({commandName:e,commandOptions:t}),s=this.hotkeyDefinitions[o];if(s&&s.keys===n)return void console.debug("HotkeysManager: Identical hotkey registration skipped.");let l=JSON.parse(localStorage.getItem("user-preferred-keys")||"{}");s&&(l[o]=n,localStorage.setItem("user-preferred-keys",JSON.stringify(l)),this._unbindHotkeys(e,s.keys)),this.hotkeyDefinitions[o]={commandName:e,commandOptions:t,keys:n,label:a,isEditable:i},this._bindHotkeys(e,t,r,n)}_bindHotkeys(e,t={},r,n){if(""===n||void 0===n)return;let a=n instanceof Array?n.join("+"):n;Nu.bind(a,n=>{n.preventDefault(),n.stopPropagation(),this._commandsManager.runCommand(e,{evt:n,...t},r),this._broadcastEvent(FV.EVENTS.HOTKEY_PRESSED,{commandName:e,commandOptions:t,keys:a,context:r,evt:n})})}_unbindHotkeys(e,t){if(""!==t&&void 0!==t){if(t instanceof Array){let r=t.join("+");this._unbindHotkeys(e,r);return}Nu.unbind(t)}}}FV.EVENTS={HOTKEY_PRESSED:"event::hotkeysManager:hotkeyPressed"};var FB=u(313),Fj=u.n(FB);(ega=egU||(egU={})).ERROR_EVENT="CORNERSTONE_ERROR",ega.CACHE_SIZE_EXCEEDED="CACHE_SIZE_EXCEEDED",ega.IMAGE_LOAD_ERROR="IMAGE_LOAD_ERROR",ega.CAMERA_MODIFIED="CORNERSTONE_CAMERA_MODIFIED",ega.CAMERA_RESET="CORNERSTONE_CAMERA_RESET",ega.VOI_MODIFIED="CORNERSTONE_VOI_MODIFIED",ega.PRESET_MODIFIED="CORNERSTONE_VIEWPORT_RENDERING_PRESET_MODIFIED",ega.DISPLAY_AREA_MODIFIED="CORNERSTONE_DISPLAY_AREA_MODIFIED",ega.ELEMENT_DISABLED="CORNERSTONE_ELEMENT_DISABLED",ega.ELEMENT_ENABLED="CORNERSTONE_ELEMENT_ENABLED",ega.IMAGE_RENDERED="CORNERSTONE_IMAGE_RENDERED",ega.IMAGE_VOLUME_MODIFIED="CORNERSTONE_IMAGE_VOLUME_MODIFIED",ega.IMAGE_VOLUME_LOADING_COMPLETED="CORNERSTONE_IMAGE_VOLUME_LOADING_COMPLETED",ega.IMAGE_LOADED="CORNERSTONE_IMAGE_LOADED",ega.IMAGE_RETRIEVAL_STAGE="CORNERSTONE_IMAGE_RETRIEVAL_STAGE",ega.IMAGE_LOAD_FAILED="CORNERSTONE_IMAGE_LOAD_FAILED",ega.VOLUME_VIEWPORT_NEW_VOLUME="CORNERSTONE_VOLUME_VIEWPORT_NEW_VOLUME",ega.VOLUME_LOADED="CORNERSTONE_VOLUME_LOADED",ega.VOLUME_LOADED_FAILED="CORNERSTONE_VOLUME_LOADED_FAILED",ega.IMAGE_CACHE_IMAGE_ADDED="CORNERSTONE_IMAGE_CACHE_IMAGE_ADDED",ega.IMAGE_CACHE_IMAGE_REMOVED="CORNERSTONE_IMAGE_CACHE_IMAGE_REMOVED",ega.VOLUME_CACHE_VOLUME_ADDED="CORNERSTONE_VOLUME_CACHE_VOLUME_ADDED",ega.VOLUME_CACHE_VOLUME_REMOVED="CORNERSTONE_VOLUME_CACHE_VOLUME_REMOVED",ega.STACK_NEW_IMAGE="CORNERSTONE_STACK_NEW_IMAGE",ega.VOLUME_NEW_IMAGE="CORNERSTONE_VOLUME_NEW_IMAGE",ega.PRE_STACK_NEW_IMAGE="CORNERSTONE_PRE_STACK_NEW_IMAGE",ega.IMAGE_SPACING_CALIBRATED="CORNERSTONE_IMAGE_SPACING_CALIBRATED",ega.VIEWPORT_NEW_IMAGE_SET="CORNERSTONE_VIEWPORT_NEW_IMAGE_SET",ega.STACK_VIEWPORT_SCROLL="CORNERSTONE_STACK_VIEWPORT_SCROLL",ega.STACK_SCROLL_OUT_OF_BOUNDS="STACK_SCROLL_OUT_OF_BOUNDS",ega.GEOMETRY_CACHE_GEOMETRY_ADDED="CORNERSTONE_GEOMETRY_CACHE_GEOMETRY_ADDED",ega.GEOMETRY_CACHE_GEOMETRY_REMOVED="CORNERSTONE_GEOMETRY_CACHE_GEOMETRY_REMOVED",ega.VOLUME_VIEWPORT_SCROLL_OUT_OF_BOUNDS="VOLUME_VIEWPORT_SCROLL_OUT_OF_BOUNDS",ega.VOLUME_VIEWPORT_SCROLL="VOLUME_VIEWPORT_SCROLL",ega.CLIPPING_PLANES_UPDATED="CORNERSTONE_CLIPPING_PLANES_UPDATED",ega.WEB_WORKER_PROGRESS="CORNERSTONE_WEB_WORKER_PROGRESS",ega.COLORMAP_MODIFIED="CORNERSTONE_COLORMAP_MODIFIED",ega.DYNAMIC_VOLUME_DIMENSION_GROUP_CHANGED="DYNAMIC_VOLUME_DIMENSION_GROUP_CHANGED",ega.DYNAMIC_VOLUME_TIME_POINT_INDEX_CHANGED="DYNAMIC_VOLUME_TIME_POINT_INDEX_CHANGED",ega.DYNAMIC_VOLUME_DIMENSION_GROUP_LOADED="DYNAMIC_VOLUME_DIMENSION_GROUP_LOADED",ega.DYNAMIC_VOLUME_TIME_POINT_LOADED="DYNAMIC_VOLUME_TIME_POINT_LOADED",ega.GEOMETRY_LOADED="GEOMETRY_LOADED",ega.GEOMETRY_LOAD_PROGRESS="GEOMETRY_LOAD_PROGRESS",ega.GEOMETRY_LOADED_FAILED="GEOMETRY_LOADED_FAILED",ega.ACTORS_CHANGED="CORNERSTONE_ACTORS_CHANGED",ega.RENDER_BACKEND_CHANGED="CORNERSTONE_RENDER_BACKEND_CHANGED",ega.WEBGL_CONTEXT_LOST="CORNERSTONE_WEBGL_CONTEXT_LOST",ega.WEBGL_CONTEXT_RESTORED="CORNERSTONE_WEBGL_CONTEXT_RESTORED",ega.RENDER_PATH_ERROR="CORNERSTONE_RENDER_PATH_ERROR",ega.RENDERING_PIPELINE_CHANGED="CORNERSTONE_RENDERING_PIPELINE_CHANGED";let FW=egU;(egi=egz||(egz={})).Interaction="interaction",egi.Thumbnail="thumbnail",egi.Prefetch="prefetch",egi.Compute="compute";let FU=egz;(ego=egH||(egH={})).STACK="stack",ego.ORTHOGRAPHIC="orthographic",ego.PERSPECTIVE="perspective",ego.VOLUME_3D="volume3d",ego.VOLUME_3D_NEXT="volume3dNext",ego.PLANAR_NEXT="planarNext",ego.VIDEO="video",ego.VIDEO_NEXT="videoNext",ego.WHOLE_SLIDE="wholeSlide",ego.WHOLE_SLIDE_NEXT="wholeSlideNext",ego.ECG="ecg",ego.ECG_NEXT="ecgNext";let Fz=egH,FH={STACK:Fz.STACK,ORTHOGRAPHIC:Fz.ORTHOGRAPHIC,PERSPECTIVE:Fz.PERSPECTIVE,VOLUME_3D:Fz.VOLUME_3D,VOLUME_3D_NEXT:Fz.VOLUME_3D_NEXT,PLANAR_NEXT:Fz.PLANAR_NEXT,VIDEO:Fz.VIDEO,VIDEO_NEXT:Fz.VIDEO_NEXT,WHOLE_SLIDE:Fz.WHOLE_SLIDE,WHOLE_SLIDE_NEXT:Fz.WHOLE_SLIDE_NEXT,ECG:Fz.ECG,ECG_NEXT:Fz.ECG_NEXT};(egs=egG||(egG={}))[egs.NEAREST=0]="NEAREST",egs[egs.LINEAR=1]="LINEAR",egs[egs.FAST_LINEAR=2]="FAST_LINEAR";let FG=egG,Fq={COMPOSITE_BLEND:0,MAXIMUM_INTENSITY_BLEND:1,MINIMUM_INTENSITY_BLEND:2,AVERAGE_INTENSITY_BLEND:3,ADDITIVE_INTENSITY_BLEND:4,RADON_TRANSFORM_BLEND:5,LABELMAP_EDGE_PROJECTION_BLEND:6};var F$={BlendMode:Fq};let{BlendMode:FK}=F$;(egl=egq||(egq={}))[egl.COMPOSITE=FK.COMPOSITE_BLEND]="COMPOSITE",egl[egl.MAXIMUM_INTENSITY_BLEND=FK.MAXIMUM_INTENSITY_BLEND]="MAXIMUM_INTENSITY_BLEND",egl[egl.MINIMUM_INTENSITY_BLEND=FK.MINIMUM_INTENSITY_BLEND]="MINIMUM_INTENSITY_BLEND",egl[egl.AVERAGE_INTENSITY_BLEND=FK.AVERAGE_INTENSITY_BLEND]="AVERAGE_INTENSITY_BLEND",egl[egl.LABELMAP_EDGE_PROJECTION_BLEND=FK.LABELMAP_EDGE_PROJECTION_BLEND]="LABELMAP_EDGE_PROJECTION_BLEND";let FY=egq;(egu=eg$||(eg$={})).AXIAL="axial",egu.CORONAL="coronal",egu.SAGITTAL="sagittal",egu.ACQUISITION="acquisition",egu.AXIAL_REFORMAT="axial_reformat",egu.CORONAL_REFORMAT="coronal_reformat",egu.SAGITTAL_REFORMAT="sagittal_reformat",egu.REFORMAT="reformat";let FX=eg$;(egc=egK||(egK={})).CONTOUR="CONTOUR",egc.SURFACE="SURFACE",egc.MESH="MESH";let FZ=egK;(egd=egY||(egY={})).CLOSED_PLANAR="CLOSED_PLANAR",egd.OPEN_PLANAR="OPEN_PLANAR",(egh=egX||(egX={})).PLY="PLY",egh.STL="STL",egh.OBJ="OBJ",egh.VTP="VTP";let FJ=egX;(egp=egZ||(egZ={})).LINEAR="LINEAR",egp.SAMPLED_SIGMOID="SIGMOID",egp.LINEAR_EXACT="LINEAR_EXACT";let FQ=egZ;(egf=egJ||(egJ={})).SUM="SUM",egf.AVERAGE="AVERAGE",egf.SUBTRACT="SUBTRACT";class F1{constructor(e){this.fullDate=e}getTimeInSec(){let e=this.fullDate.substring(0,10),t=this.fullDate.substring(11,28),r=parseInt(e.substring(0,4),10),n=e.length>=7?parseInt(e.substring(5,7),10):void 0,a=e.length>=10?parseInt(e.substring(8,10),10):void 0;if(isNaN(r)||void 0!==n&&isNaN(n)||void 0!==a&&isNaN(a)||r>3e3||n&&(n<1||n>12)||a&&(a<1||a>31))throw Error(`invalid date '${e}'`);let i=new Date(`${e}T00:00:00.000000Z`),o=parseInt(t.substring(0,2),10),s=t.length>=5?parseInt(t.substring(3,5),10):void 0,l=t.length>=8?parseInt(t.substring(6,8),10):void 0,u=t.substring(9,15),c=u?parseInt(u,10)*Math.pow(10,-u.length):void 0;if(isNaN(o)||void 0!==s&&isNaN(s)||void 0!==l&&isNaN(l)||void 0!==c&&isNaN(c)||o<0||o>23||s&&(s<0||s>59)||l&&(l<0||l>59)||c&&(c<0||c>999999))throw Error(`invalid time '${t}'`);let d=i.getTime()/1e3;return d+=3600*o,void 0!==s&&(d+=60*s),void 0!==l&&(d+=l),void 0!==c&&(d+=c),d}getTimeInMicroSec(){return 1e6*this.getTimeInSec()}}function F0(e,t){let r=`${t.hours||"00"}`.padStart(2,"0"),n=`${t.minutes||"00"}`.padStart(2,"0"),a=`${t.seconds||"00"}`.padStart(2,"0"),i=`${e.month}`.padStart(2,"0"),o=`${e.day}`.padStart(2,"0"),s=`${t.fractionalSeconds||"000000"}`.padEnd(6,"0"),l=`${e.year}-${i}-${o}`,u=`T${r}:${n}:${a}.${s}Z`;return new F1(`${l}${u}`)}function F2(e){if(null==e||8!==e.length||"string"!=typeof e)throw Error(`invalid DA '${e}'`);let t=parseInt(e.substring(0,4),10),r=parseInt(e.substring(4,6),10),n=parseInt(e.substring(6,8),10);if(!0!=(!isNaN(t)&&r>0&&r<=12&&n>0&&n<=function(e,t){switch(e){case 2:return t%4==0&&t%100||t%400==0?29:28;case 9:case 4:case 6:case 11:return 30;default:return 31}}(r,t)))throw Error(`invalid DA '${e}'`);return{year:t,month:r,day:n}}function F5(e){if(null==e||e.length<2||"string"!=typeof e)throw Error(`invalid TM '${e}'`);let t=parseInt(e.substring(0,2),10),r=e.length>=4?parseInt(e.substring(2,4),10):void 0,n=e.length>=6?parseInt(e.substring(4,6),10):void 0,a=e.length>=8?e.substring(7,13):void 0,i=a?parseInt(a,10)*Math.pow(10,6-a.length):void 0;if(isNaN(t)||void 0!==r&&isNaN(r)||void 0!==n&&isNaN(n)||void 0!==i&&isNaN(i)||t<0||t>23||r&&(r<0||r>59)||n&&(n<0||n>59)||i&&(i<0||i>999999))throw Error(`invalid TM '${e}'`);return{hours:t,minutes:r,seconds:n,fractionalSeconds:i}}function F3(e){if(null==e)throw Error("dateTimeToFullDateInterface : dateTime not defined.");return F0(F2(e.substring(0,8)),F5(e.substring(8)))}function F4(e){let t,r,{CorrectedImage:n,Units:a,PhilipsPETPrivateGroup:i,PatientWeight:o,PatientSex:s,PatientSize:l}=e[0];if(!n.includes("ATTN")||!n.includes("DECY"))throw Error(`CorrectedImage must contain "ATTN" and "DECY": ${n}`);if(!e.every(t=>{let r;return t.Units===a&&((r=t.CorrectedImage)===n||Array.isArray(r)&&Array.isArray(n)&&r.length===n.length&&r.every((e,t)=>e===n[t]))&&t.PatientWeight===o&&t.PatientSex===s&&t.PatientSize===l&&t.RadionuclideHalfLife===e[0].RadionuclideHalfLife&&t.RadionuclideTotalDose===e[0].RadionuclideTotalDose&&t.DecayCorrection===e[0].DecayCorrection&&t.SeriesDate===e[0].SeriesDate&&t.SeriesTime===e[0].SeriesTime}))throw Error("The set of instances does not appear to come from one Series. Every instance must have identical values for series-level metadata properties");if(null==o)throw Error("PatientWeight value is missing. It is not possible to calculate the SUV factors");let u=Array(e.length);u=function(e){let{RadionuclideTotalDose:t,RadionuclideHalfLife:r,RadiopharmaceuticalStartDateTime:n,RadiopharmaceuticalStartTime:a,SeriesDate:i}=e[0];if(null==t)throw Error("calculateDecayCorrection : RadionuclideTotalDose value not found.");if(null==r)throw Error("calculateDecayCorrection : RadionuclideHalfLife value not found.");let o=function(e){let{SeriesDate:t,SeriesTime:r,GEPrivatePostInjectionDateTime:n}=e[0],a=Array(e.length),i=F0(F2(t),F5(r)),o=new F1("3000-01-01T00:00:00.000000Z"),s=o.getTimeInSec();if(e.forEach(e=>{let{AcquisitionDate:t,AcquisitionTime:r}=e,n=F0(F2(t),F5(r));o=o.getTimeInSec()>=s||n.getTimeInSec()<o.getTimeInSec()?n:o}),o.getTimeInSec()>=s)throw Error("Earliest acquisition time or date could not be parsed.");return i.getTimeInSec()<=o.getTimeInSec()?a.fill(i):n?a.fill(F3(n)):a.fill(o)}(e),s=function(e){let t,{RadiopharmaceuticalStartDateTime:r,RadiopharmaceuticalStartTime:n,SeriesDate:a}=e;if(r)return F3(r);if(n&&a)return t=F5(n),F0(F2(a),t);throw Error(`Invalid input: ${e}`)}({RadiopharmaceuticalStartDateTime:n,RadiopharmaceuticalStartTime:a,SeriesDate:i});return e.map((e,n)=>{let a=o[n].getTimeInSec()-s.getTimeInSec();if(a<0)throw Error("Decay time cannot be less than zero");return 1/(t*Math.pow(2,-a/r))})}(e);let c=Array(e.length),d=1e3*o;if("BQML"===a)c=u.map(function(e){return e*d});else if("CNTS"===a){let t=e.every(e=>{var t,r,n;return e.PhilipsPETPrivateGroup&&(null==(t=e.PhilipsPETPrivateGroup)?void 0:t.SUVScaleFactor)!==null&&(null==(r=e.PhilipsPETPrivateGroup)?void 0:r.SUVScaleFactor)!==void 0&&(null==(n=e.PhilipsPETPrivateGroup)?void 0:n.SUVScaleFactor)!==0}),r=e.every(e=>{var t,r,n;return e.PhilipsPETPrivateGroup&&!(null!=(t=e.PhilipsPETPrivateGroup)&&t.SUVScaleFactor)&&(null==(r=e.PhilipsPETPrivateGroup)?void 0:r.ActivityConcentrationScaleFactor)!==void 0&&(null==(n=e.PhilipsPETPrivateGroup)?void 0:n.ActivityConcentrationScaleFactor)!==0});if(t)c=e.map(e=>e.PhilipsPETPrivateGroup.SUVScaleFactor);else if(r)c=e.map((e,t)=>e.PhilipsPETPrivateGroup.ActivityConcentrationScaleFactor*u[t]*d);else throw Error(`Units are in CNTS, but PhilipsPETPrivateGroup has invalid values: ${JSON.stringify(i)}`)}else if("GML"===a)c.fill(1);else throw Error(`Units has an invalid value: ${a}`);return null==l?console.warn("PatientSize value is missing. It is not possible to calculate the SUV bsa factors"):t=function(e){let{PatientWeight:t,PatientSize:r}=e;return Math.pow(t,.425)*Math.pow(100*r,.725)*71.84}({PatientWeight:o,PatientSize:l}),null==l?console.warn("PatientSize value is missing. It is not possible to calculate the SUV lbm factors"):null==s?console.warn("PatientSex value is missing. It is not possible to calculate the SUV lbm factors"):r=function(e){let t,{PatientSex:r,PatientWeight:n,PatientSize:a}=e,i=n*n/(a*a*1e4);if("F"===r)t=1.07*n-148*i;else if("M"===r)t=1.1*n-120*i;else throw Error(`PatientSex is an invalid value: ${r}`);return 1e3*t}({PatientWeight:o,PatientSex:s,PatientSize:l}),c.map(function(e,n){let a={suvbw:e};return t&&(a.suvbsa=u[n]*t),r&&(a.suvlbm=u[n]*r),a})}(egm=egQ||(egQ={})).NOT_APPLICABLE="",egm.ERMF="ERMF",egm.USER="User",egm.PROJECTION="Proj",egm.REGION="Region",egm.ERROR="Error",egm.UNCALIBRATED="Uncalibrated",egm.CALIBRATED="Calibrated",egm.UNKNOWN="Unknown";let F8=egQ;(egg=eg1||(eg1={})).CALIBRATION="calibrationModule",egg.CINE="cineModule",egg.FRAME_OF_REFERENCE="frameOfReferenceModule",egg.GENERAL_IMAGE="generalImageModule",egg.GENERAL_SERIES="generalSeriesModule",egg.GENERAL_STUDY="generalStudyModule",egg.IMAGE_PIXEL="imagePixelModule",egg.IMAGE_PLANE="imagePlaneModule",egg.IMAGE_URL="imageUrlModule",egg.MODALITY_LUT="modalityLutModule",egg.MULTIFRAME="multiframeModule",egg.NM_MULTIFRAME_GEOMETRY="nmMultiframeGeometryModule",egg.OVERLAY_PLANE="overlayPlaneModule",egg.PATIENT="patientModule",egg.PATIENT_DEMOGRAPHIC="patientDemographicModule",egg.PATIENT_STUDY="patientStudyModule",egg.PET_IMAGE="petImageModule",egg.PET_ISOTOPE="petIsotopeModule",egg.PET_SERIES="petSeriesModule",egg.SCALING="scalingModule",egg.SOP_COMMON="sopCommonModule",egg.ULTRASOUND_ENHANCED_REGION="ultrasoundEnhancedRegionModule",egg.ECG="ecgModule",egg.VOI_LUT="voiLutModule",egg.TRANSFER_SYNTAX="transferSyntax",egg.PLANE_ORIENTATION="PlaneOrientation",egg.PLANE_POSITION="PlanePosition",egg.PIXEL_MEASURES="PixelMeasures",egg.XRAY_GEOMETRY="XrayGeometry",egg.FRAME_PIXEL_DATA="FramePixelData",egg.FRAME_MODULE="frameModule",egg.URI_MODULE="uriModule",egg.WADO_WEB_CLIENT="wadoWebClient",egg.INSTANCE="instance",egg.IMAGE_SOP_INSTANCE_REFERENCE="ImageSopInstanceReference",egg.REFERENCED_SERIES_REFERENCE="ReferencedSeriesReference",egg.PREDECESSOR_SEQUENCE="PredecessorSequence",egg.STUDY_DATA="StudyData",egg.SERIES_DATA="SeriesData",egg.IMAGE_DATA="ImageData",egg.RTSS_INSTANCE_DATA="RtssInstanceData",egg.NEW_INSTANCE_DATA="NewInstanceData",egg.RTSS_CONTOUR="metaRTSSContour",egg.SEG_BIT="metaSegBitmap",egg.SR_ANNOTATION="metaSrAnnotation",egg.COMPRESSED_FRAME_DATA="compressedFrameData",egg.BASE_IMAGE_ID="baseImageId",egg.FRAME_IMAGE_IDS="frameImageIds",egg.NATURALIZED="naturalized",egg.DISPLAY_SET="displaySetModule";let F6=eg1,F9={IMPLICIT_VR_LITTLE_ENDIAN:LC.constants.IMPLICIT_LITTLE_ENDIAN,EXPLICIT_VR_LITTLE_ENDIAN:LC.constants.EXPLICIT_LITTLE_ENDIAN,DEFLATED_EXPLICIT_VR_LITTLE_ENDIAN:LC.constants.DEFLATED_EXPLICIT_LITTLE_ENDIAN,EXPLICIT_VR_BIG_ENDIAN:LC.constants.EXPLICIT_BIG_ENDIAN,RLE_LOSSLESS:"1.2.840.10008.1.2.5",MPEG2_MAIN_PROFILE_MAIN_LEVEL:"1.2.840.10008.1.2.4.100",MPEG2_MAIN_PROFILE_MAIN_LEVEL_FRAGMENTABLE:"1.2.840.10008.1.2.4.100.1",MPEG2_MAIN_PROFILE_HIGH_LEVEL:"1.2.840.10008.1.2.4.101",MPEG2_MAIN_PROFILE_HIGH_LEVEL_FRAGMENTABLE:"1.2.840.10008.1.2.4.101.1",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_1:"1.2.840.10008.1.2.4.102",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_1_FRAGMENTABLE:"1.2.840.10008.1.2.4.102.1",MPEG4_AVC_H264_BD_COMPATIBLE_HIGH_PROFILE_LEVEL_4_1:"1.2.840.10008.1.2.4.103",MPEG4_AVC_H264_BD_COMPATIBLE_HIGH_PROFILE_LEVEL_4_1_FRAGMENTABLE:"1.2.840.10008.1.2.4.103.1",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_2D_VIDEO:"1.2.840.10008.1.2.4.104",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_2D_VIDEO_FRAGMENTABLE:"1.2.840.10008.1.2.4.104.1",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_3D_VIDEO:"1.2.840.10008.1.2.4.105",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_3D_VIDEO_FRAGMENTABLE:"1.2.840.10008.1.2.4.105.1",MPEG4_AVC_H264_STEREO_HIGH_PROFILE_LEVEL_4_2:"1.2.840.10008.1.2.4.106",MPEG4_AVC_H264_STEREO_HIGH_PROFILE_LEVEL_4_2_FRAGMENTABLE:"1.2.840.10008.1.2.4.106.1",HEVC_H265_MAIN_PROFILE_LEVEL_5_1:"1.2.840.10008.1.2.4.107",HEVC_H265_MAIN_10_PROFILE_LEVEL_5_1:"1.2.840.10008.1.2.4.108"},F7=[],Ve=new Map,Vt=new Map;function Vr(e,t=0){let r;if(!F7.some(t=>t.provider===e)){for(r=0;r<F7.length&&!(F7[r].priority<=t);r++);F7.splice(r,0,{priority:t,provider:e})}}function Vn(e,t,r){let n=Vt.get(e);if(n)return n(t,null,r)}function Va(e){for(let t=0;t<F7.length;t++)if(F7[t].provider===e){F7.splice(t,1);break}}function Vi(){for(;F7.length>0;)F7.pop();Ve.clear(),Vt.clear()}function Vo(e,t,r){if(void 0!==t)for(let n=0;n<F7.length;n++){let a=F7[n].provider(e,t,r);if(void 0!==a)return a}}function Vs(e,t,r){return Vo(e,t,r)}let Vl=(e,t)=>{var r;for(let n of[e,(r=e,`${r}Add`)]){let e=Ve.get(n);if(e)for(let r of e)r?.clearQuery?.(t)}},Vu=e=>{var t;for(let r of Array.from(new Set([e,(t=e,`${t}Add`)]))){let e=Ve.get(r);if(e)for(let t of e)t?.clear?.()}},Vc=(e,...t)=>1===t.length?Vo(e,t[0]):t.map(t=>t&&Vo(e,t)).find(e=>void 0!==e);function Vd(e,t,r=Vo){let n={};for(let a of t)try{let t=r(a,e);if(t){let e={};for(let r in t)r in t&&(e[Vh(r)]=t[r]);Object.assign(n,e)}}catch(e){console.error(`Error retrieving ${a} data:`,e)}return n}let Vh=e=>e.startsWith("sop")?`SOP${e.substring(3)}`:e.startsWith("voi")?`VOI${e.substring(3)}`:(e.endsWith("Id")&&(e=`${e.substring(0,e.length-2)}ID`),e.charAt(0).toUpperCase()+e.slice(1)),Vp=e=>e.startsWith("SOP")?`sop${e.substring(3)}`:e.startsWith("VOI")?`voi${e.substring(3)}`:(e.endsWith("ID")&&!e.endsWith("UID")&&(e=`${e.substring(0,e.length-2)}Id`),e.charAt(0).toLowerCase()+e.slice(1));function Vf(e,t,r){return Math.abs(e-t)<=r}function Vm(e){return"number"==typeof e}function Vg(e){return e&&"object"==typeof e&&"length"in e&&"number"==typeof e.length&&e.length>0&&"number"==typeof e[0]}function Vy(e,t,r=1e-5){return typeof e==typeof t&&null!==e&&null!==t&&(Vm(e)&&Vm(t)?Vf(e,t,r):!!(Vg(e)&&Vg(t))&&function(e,t,r=1e-5){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Vf(e[n],t[n],r))return!1;return!0}(e,t,r))}let Vv=e=>"number"==typeof e?-e:e?.map?e.map(Vv):!e,Vb=e=>"number"==typeof e?Math.abs(e):e?.map?e.map(Vb):e,Vw=(e,t,r)=>Vy(Vb(e),Vb(t),r),Vx=V_("cs3d"),VC=Vx.getLogger("metadata"),Vk=Vx.getLogger("core"),VM=Vx.getLogger("tools"),VE=Vx.getLogger("dicomImageLoader"),VS=Vx.getLogger("ai"),VD=Vx.getLogger("examples"),VI=Vx.getLogger("worker"),VP=LC.log.getLogger("consistency.dicom"),VT=LC.log.getLogger("consistency.image");function V_(e){let t=LC.log.getLogger(e);return t.getLogger=(...t)=>V_(`${e}.${t.join(".")}`),t}function VA(...e){return V_(e.join("."))}let VO=new Set([F9.MPEG2_MAIN_PROFILE_MAIN_LEVEL,F9.MPEG2_MAIN_PROFILE_MAIN_LEVEL_FRAGMENTABLE,F9.MPEG2_MAIN_PROFILE_HIGH_LEVEL,F9.MPEG2_MAIN_PROFILE_HIGH_LEVEL_FRAGMENTABLE,F9.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_1,F9.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_1_FRAGMENTABLE,F9.MPEG4_AVC_H264_BD_COMPATIBLE_HIGH_PROFILE_LEVEL_4_1,F9.MPEG4_AVC_H264_BD_COMPATIBLE_HIGH_PROFILE_LEVEL_4_1_FRAGMENTABLE,F9.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_2D_VIDEO,F9.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_2D_VIDEO_FRAGMENTABLE,F9.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_3D_VIDEO,F9.MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_2_FOR_3D_VIDEO_FRAGMENTABLE,F9.MPEG4_AVC_H264_STEREO_HIGH_PROFILE_LEVEL_4_2,F9.MPEG4_AVC_H264_STEREO_HIGH_PROFILE_LEVEL_4_2_FRAGMENTABLE,F9.HEVC_H265_MAIN_PROFILE_LEVEL_5_1,F9.HEVC_H265_MAIN_10_PROFILE_LEVEL_5_1]);function VR(e){return!!e&&(Array.isArray(e)?e:[e]).find(e=>VO.has(e))}let VL=/^[a-zA-Z]+:/;function VN(e){if(!e)return"";let t=e.match(VL);if(!t)return e;let r=e.substring(t[0].length);return VL.test(r)?r:e}let VF=new Set(["1.2.840.10008.5.1.4.1.1.1","1.2.840.10008.5.1.4.1.1.1.1","1.2.840.10008.5.1.4.1.1.1.1.1","1.2.840.10008.5.1.4.1.1.1.2","1.2.840.10008.5.1.4.1.1.1.2.1","1.2.840.10008.5.1.4.1.1.1.3","1.2.840.10008.5.1.4.1.1.1.3.1","1.2.840.10008.5.1.4.1.1.12.1","1.2.840.10008.5.1.4.1.1.12.1.1","1.2.840.10008.5.1.4.1.1.12.2","1.2.840.10008.5.1.4.1.1.12.2.1","1.2.840.10008.5.1.4.1.1.12.3"]);function VV(e){let{PixelSpacing:t,ImagerPixelSpacing:r,EstimatedRadiographicMagnificationFactor:n,DistanceSourceToDetector:a,DistanceSourceToEntrance:i,DistanceSourceToPatient:o=i}=e;return n>1?n:o<a?a/o:r?.[0]>t?.[0]||void 0}function VB(e){let{PixelSpacing:t,ImagerPixelSpacing:r,PixelSpacingCalibrationType:n}=e;if(t&&"GEOMETRY"===n)return Vy(t,r)&&console.warn("Calibration type is geometry, but pixel spacing and imager pixel spacing identical",t,r),{PixelSpacing:t,type:F8.ERMF,isProjection:!0};if(t&&"FIDUCIAL"===n)return{PixelSpacing:t,type:F8.CALIBRATED,isProjection:!0};if(r){let n=VV(e);return n>1?{PixelSpacing:r.map(e=>e/n),type:F8.ERMF,isProjection:!0}:!0===n?{PixelSpacing:t,type:F8.ERMF,isProjection:!0}:(n&&console.error("Illegal ERMF value:",n),{PixelSpacing:t||r,type:F8.PROJECTION,isProjection:!0})}return{PixelSpacing:t,type:F8.UNKNOWN,isProjection:!0}}function Vj(e){let{PixelSpacing:t,SOPClassUID:r}=e;return VF.has(r)?VB(e):{PixelSpacing:t,type:F8.NOT_APPLICABLE,isProjection:!1}}let VW=new Map,VU={add:(e,t)=>{let r=VN(e);VW.set(r,t),Vl(F6.IMAGE_PLANE,e)},get:(e,t)=>{if("calibratedPixelSpacing"===e){let e=VN(t);return VW.get(e)}},clear:()=>{VW.clear()}};function Vz(e,t){let r=/\/frames\/\d+/,n=/([?&])frame=\d+/;if(r.test(e))return e.replace(r,`/frames/${t}`);if(n.test(e))return e.replace(n,(e,r)=>`${r}frame=${t}`);let a=e.includes("?")?"&":"?";return`${e}${a}frame=${t}`}function VH(e){if(!e||0===e.length)return null;let t=e[0],r=Vc("instance",t);if(!r)return null;let n=r.NumberOfFrames;if(!n||n<=1)return null;let a=r.TimeSlotVector;if(!a||!Array.isArray(a))return null;let i=r.SliceVector,o=r.NumberOfSlices;if(a.length!==n)return console.warn("TimeSlotVector length does not match NumberOfFrames:",a.length,"vs",n),null;if(i){if(!Array.isArray(i))return console.warn("SliceVector exists but is not an array. Expected length:",n),null;if(i.length!==n||i.some(e=>void 0===e))return console.warn("SliceVector exists but has invalid length or undefined entries. Expected length:",n,"Actual length:",i.length),null}let s=new Map;for(let e=0;e<n;e++){let t=a[e],r=i?.[e]??e;s.has(t)||s.set(t,[]),s.get(t).push({frameIndex:e,sliceIndex:r})}let l=Array.from(s.keys()).sort((e,t)=>e-t).map(e=>{let r=s.get(e);return r.sort((e,t)=>e.sliceIndex-t.sliceIndex),r.map(e=>Vz(t,e.frameIndex+1))}),u=o||l[0]?.length;return l.every(e=>e.length===u)||console.warn("Multiframe 4D split resulted in uneven time slot groups. Expected",u,"slices per time slot."),{imageIdGroups:l,splittingTag:"TimeSlotVector"}}function VG(e,t){let r=Vc(t,e);try{return parseFloat(r)}catch{return}}function Vq(e,t){var r=VG(e,t);if(void 0!==r){if("string"==typeof r||"number"==typeof r||r instanceof String||r instanceof Number){let e=Number(r);return Number.isFinite(e)?e:void 0}return Array.from(r,e=>{let t=Number(e);return Number.isFinite(t)?t:void 0})}}function V$(e){let t=Vc("20011003",e);try{let{InlineBinary:e}=t;if(e){let t=atob(e),r=new ArrayBuffer(t.length),n=new DataView(r);for(let e=0;e<t.length;e++)n.setUint8(e,t.charCodeAt(e));return new Float32Array(r)[0]}return parseFloat(t)}catch{return}}function VK(e){let t=Vc("0019100c",e)||Vc("0019100C",e);try{let{InlineBinary:e}=t;return e&&(t=atob(e)),parseFloat(t)}catch{return}}function VY(e){let t=Vc("00431039",e);try{let{InlineBinary:e}=t;return e&&(t=atob(e).split("//")),parseFloat(t[0])%1e5}catch{return}}function VX(e){let t=Vc("petImageModule",e);return t?t.frameReferenceTime:0}let VZ=function(e){let t=VH(e);if(t)return t;let r=function(e){let t;if(!e||0===e.length||void 0===Vq(e[0],"CardiacNumberOfImages"))return null;let r=new Map;for(let t of e){let e=Vc("StackID",t),n=Vq(t,"InStackPositionNumber"),a=Vq(t,"TriggerTime");if(void 0===e||void 0===n||void 0===a)return null;let i=String(e);r.has(i)||r.set(i,new Map);let o=r.get(i);o.has(n)||o.set(n,[]),o.get(n).push({imageId:t,triggerTime:a})}let n=Array.from(r.keys()).sort((e,t)=>Number(e)-Number(t));if(0===n.length)return null;let a=[];for(let e of n){let n=r.get(e),i=Array.from(n.keys()).sort((e,t)=>e-t);for(let e of i){let r=n.get(e);if(r.sort((e,t)=>e.triggerTime-t.triggerTime),void 0===t)t=r.length;else if(r.length!==t)return null}a.push({stackId:e,positions:i,framesByPosition:n})}if(!t)return null;let i=[];for(let e=0;e<t;e++){let t=[];for(let r of a)for(let n of r.positions){let a=r.framesByPosition.get(n);t.push(a[e].imageId)}i.push(t)}return{imageIdGroups:i,splittingTag:"CardiacTriggerTime"}}(e);if(r)return r;let n=function(e){let t,r=e.map(e=>{let{imagePositionPatient:t}=Vc("imagePlaneModule",e)||{};return{imageId:e,imagePositionPatient:t}});if(!r.every(e=>e.imagePositionPatient))return null;let n=(t="imagePositionPatient",r.reduce((e,r)=>((e[r[t]]=e[r[t]]||[]).push(r),e),{})),a=Object.keys(n),i=n[a[0]].length;return 1!==i&&a.every(e=>n[e].length===i)?n:null}(e);if(!n)return{imageIdGroups:[e],splittingTag:null};let a=["TemporalPositionIdentifier","DiffusionBValue","TriggerTime","EchoTime","EchoNumber","PhilipsPrivateBValue","SiemensPrivateBValue","GEPrivateBValue","PetFrameReferenceTime"],i=[e=>VG(e,a[0]),e=>VG(e,a[1]),e=>VG(e,a[2]),e=>VG(e,a[3]),e=>VG(e,a[4]),V$,VK,VY,VX];for(let e=0;e<i.length;e++){let t=function(e,t){let r={},n=[],a=Object.keys(e);for(let i=0;i<a.length;i++){let o=new Set,s=e[a[i]];for(let e=0;e<s.length;e++){let n=t(s[e].imageId)||0;if(r[n]=r[n]||[],r[n].push({imageId:s[e].imageId}),o.add(n),o.size-1<e)return}if(0==i)n=Array.from(o);else if(!function(e,t){if(e.length!=t.size)return!1;for(let r=0;r<e.length;r++)if(!t.has(e[r]))return!1;return!0}(n,o))return}return r}(n,i[e]);if(t)return{imageIdGroups:Object.keys(t).map(Number.parseFloat).sort((e,t)=>e-t).map(e=>t[e].map(e=>e.imageId)),splittingTag:a[e]}}return{imageIdGroups:[e],splittingTag:null}},VJ=[[F6.TRANSFER_SYNTAX,["TransferSyntaxUID","AvailableTransferSyntaxUID"]],[F6.CINE,["FrameTime","RecommendedDisplayFrameRate"]],[F6.PET_ISOTOPE,[["RadiopharmaceuticalInfo","00540016"]]],["RadiopharmaceuticalInfo",["RadiopharmaceuticalStartTime","RadiopharmaceuticalStopTime","RadionuclideTotalDose","RadionuclideHalfLife"]],[F6.PET_IMAGE,["FrameReferenceTime","ActualFrameDuration"]],[F6.PET_SERIES,["CorrectedImage","Units","DecayCorrection"]],[F6.PATIENT,["PatientID","PatientName","PatientBirthDate","PatientBirthTime"]],[F6.PATIENT_STUDY,["PatientAge","PatientSize","PatientSex","PatientWeight"]],[F6.GENERAL_STUDY,["StudyInstanceUID","StudyDescription","StudyDate","StudyTime","AccessionNumber"]],[F6.GENERAL_SERIES,["StudyInstanceUID","SeriesInstanceUID","Modality","SeriesDescription","SeriesNumber","SeriesDate","SeriesTime","AcquisitionDate","AcquisitionTime"]],["clinicalTrialModule",["ClinicalTrialSponsorName","ClinicalTrialSiteID","ClinicalTrialSiteName","ClinicalTrialSubjectID"]],[F6.SOP_COMMON,["SOPInstanceUID","SOPClassUID"]],[F6.ECG,["StudyInstanceUID","SeriesInstanceUID","SeriesDescription","SeriesNumber","SeriesDate","SeriesTime","Modality","SOPInstanceUID","SOPClassUID"]],[F6.GENERAL_IMAGE,["SOPInstanceUID","SOPClassUID","InstanceNumber","InstanceCreationDate","InstanceCreationTime","ContentTime","LossyImageCompression","LossyImageCompressionRatio","LossyImageCompressionMethod","FrameOfReferenceUID","NumberOfFrames","PixelSpacing"]],[F6.IMAGE_PLANE,["ImagerPixelSpacing","ImageOrientationPatient","ImagePositionPatient","SpacingBetweenSlices","SliceThickness","SliceLocation"]],[F6.IMAGE_PIXEL,["SamplesPerPixel","PhotometricInterpretation","PlanarConfiguration","Rows","Columns","BitsAllocated","BitsStored","HighBit","PixelRepresentation",["SmallestPixelValue","00280106"],["LargestPixelValue","00280107"],"PixelPaddingValue","PixelPaddingRangeLimit","RedPaletteColorLookupTableDescriptor","GreenPaletteColorLookupTableDescriptor","BluePaletteColorLookupTableDescriptor","AlphaPaletteColorLookupTableDescriptor","RedPaletteColorLookupTableData","GreenPaletteColorLookupTableData","BluePaletteColorLookupTableData","AlphaPaletteColorLookupTableData","PaletteColorLookupTableUID","DistanceSourceToDetector","DistanceSourceToPatient","EstimatedRadiographicMagnificationFactor","DistanceSourceToEntrance","PixelSpacingCalibrationType","PixelSpacingCalibrationDescription","SequenceOfUltrasoundRegions"]],[F6.VOI_LUT,["WindowCenter","WindowWidth","VOILUTFunction","WindowCenterWidthExplanation"]],[F6.MODALITY_LUT,["RescaleIntercept","RescaleSlope","RescaleType"]],[F6.ULTRASOUND_ENHANCED_REGION,["SequenceOfUltrasoundRegions"]],["usRegionChild",["PhysicalDeltaX","PhysicalDeltaY","PhysicalUnitsXDirection","PhysicalUnitsYDirection","RegionLocationMinY0","RegionLocationMaxY1","RegionLocationMinX0","RegionLocationMaxX1","ReferencePixelX0","ReferencePixelY0",["ReferencePhysicalPixelValueY","0018602A"],["ReferencePhysicalPixelValueX","00186028"],"RegionSpatialFormat","RegionDataType","RegionFlags","TransducerFrequency"]],[null,["ReferencedImageSequence","ReferencedSOPClassUID","ReferencedSOPInstanceUID","ReferencedFrameNumber","SharedFunctionalGroupsSequence","PerFrameFunctionalGroupsSequence","PlanePositionSequence","AnatomicRegionSequence","PlaneOrientationSequence","PixelMeasuresSequence","PixelValueTransformationSequence","ParametricMapFrameTypeSequence","RealWorldValueMappingSequence"]]],VQ=LC.data.DicomMetaDictionary.dictionary,V1=LC.data.DicomMetaDictionary.nameMap,V0=new Map,V2=new Map,V5={},V3=new Map;for(let[e,t]of VJ)for(let r of t){let t="string"==typeof r?r:r[0],n="string"==typeof r?void 0:r[1],a=V3.get(t);a||(a={hex:n??function(e){let t=V1[e];if(t)return t.tag.substring(1,5)+t.tag.substring(6,10)}(t),groups:[]},V3.set(t,a)),null!==e&&a.groups.push(e)}for(let[e,{hex:t,groups:r}]of V3){if(!t){console.warn(`Tags: keyword "${e}" not found in dcmjs nameMap`);continue}!function(e,t){if(e&&t.name&&e!==t.name)throw Error(`Tag name provided and value don't match: ${e} !== ${t.name}`);t.name||=e,t.lowerName||=Vp(e),V5[e]=t;let{tag:r}=t;t.primaryGroup||=t.groups?.[0];let{groups:n}=t;if(V2.set(e,t),r&&(t.xTag=`x${r.toLowerCase()}`,t.tag=r.toUpperCase(),V2.set(t.xTag,t),V2.set(t.tag,t),!t.vr)){let e=VQ[t.tag];e&&(t.vr=e.vr,t.vm=function(e){if(null==e)return null;if("number"==typeof e)return e;let t=parseInt(e,10);return String(t)===e?t:0}(e.vm))}if(n?.length)for(let r of n){let n=V0.get(r);if(!n){n=[t],V0.set(r,n);return}let a=n.findIndex(t=>t.name===e);-1===a?n.push(t):n[a]=t}}(e,function(e,...t){return{tag:e,groups:t,xTag:null,primaryGroup:null,name:null,lowerName:null,vr:null,vm:null}}(t,...r))}let{DicomMetadataListener:V4}=LC.utilities,{pp:V8,tZ:V6,gE:V9,Um:V7,uu:Be,UA:Bt,_E:Br,RZ:Bn,UX:Ba,bM:Bi,HL:Bo,U5:Bs,Rm:Bl}=ee,Bu=F6.FRAME_IMAGE_IDS,Bc=F6.BASE_IMAGE_ID;class Bd{static setCacheDataInternal(e,t,r){let n=this.mapCacheData.get(e);n||(n=new Map,this.mapCacheData.set(e,n)),n.set(t,r),this.clearRelatedDerivedCache(e,t)}static clearRelatedDerivedCache(e,t){let r=this.secondaryTypesByBaseType.get(e);if(r?.size)for(let e of Vo(Bu,t)??new Set([t]))for(let t of r){let r=this.mapCacheData.get(t);r?.delete(e)}}static registerSecondaryTypes(e,t){if(t)for(let r of Array.isArray(t)?t:[t]){let t=this.secondaryTypesByBaseType.get(r);t||(t=new Set,this.secondaryTypesByBaseType.set(r,t)),t.add(e)}}static getCacheData(e,t){return this.mapCacheData.get(e)?.get(t)}static hasCacheData(e,t){return this.mapCacheData.get(e)?.has(t)===!0}static clearCacheData(){this.mapCacheData.clear(),this.secondaryTypesByBaseType.clear(),Vu(Bu),Vu(Bc)}static clearTypedCacheData(e,t){let r=this.secondaryTypesByBaseType.get(e),n=this.mapCacheData.get(e);if(t){if(n?.delete(t),r?.size)for(let e of r)this.mapCacheData.get(e)?.delete(t);(e===F6.NATURALIZED||r?.size)&&(Vl(Bu,t),Vl(Bc,t));return}if(n?.clear(),r?.size)for(let e of r)this.mapCacheData.get(e)?.clear();(e===F6.NATURALIZED||r?.size)&&(Vu(Bu),Vu(Bc))}static fromAsyncLookup(e,t,r,n){if(n?.noCache!==!0&&n?.reCache!==!0){let r=this.getCacheData(e,t);if(void 0!==r)return r}let a=r();if(void 0!==a)return a instanceof Promise?a.then(r=>(void 0===r||n?.noCache||this.setCacheDataInternal(e,t,r),r)):(n?.noCache||this.setCacheDataInternal(e,t,a),a)}createTypeCacheProvider(e){var t;return t=e,(e,r,n,a)=>Bd.fromAsyncLookup(t,r,()=>e(r,n,a),a)}clearCacheData(){Bd.clearCacheData()}clearTypedCacheData(e,t){Bd.clearTypedCacheData(e,t)}getCacheData(e,t){return Bd.getCacheData(e,t)}hasCacheData(e,t){return Bd.hasCacheData(e,t)}fromAsyncLookup(e,t,r,n){return Bd.fromAsyncLookup(e,t,r,n)}}function Bh(e){return(t,r,n,a)=>(n||=Vn(e,r,a?.[e]),t(r,n,a))}Bd.mapCacheData=new Map,Bd.secondaryTypesByBaseType=new Map,new class e extends Bd{static setCacheData(e,t,r){this.setCacheDataInternal(e,t,r)}setCacheData(t,r,n){e.setCacheData(t,r,n)}},Bh(F6.INSTANCE),Bh(F6.NATURALIZED);let{AsyncDicomReader:Bp}=LC.async;V7.getLogger("tagModules"),F6.COMPRESSED_FRAME_DATA;let{C:Bf}=J;(egy=eg0||(eg0={})).NO_DATA="noData",egy.LOADING="loading",egy.PRE_RENDER="preRender",egy.NEEDS_RENDER="needsRender",egy.RESIZE="resize",egy.RENDERED="rendered";let Bm=eg0;(egv=eg2||(eg2={}))[egv.FAR_REPLICATE=1]="FAR_REPLICATE",egv[egv.ADJACENT_REPLICATE=3]="ADJACENT_REPLICATE",egv[egv.SUBRESOLUTION=6]="SUBRESOLUTION",egv[egv.LOSSY=7]="LOSSY",egv[egv.FULL_RESOLUTION=8]="FULL_RESOLUTION";let Bg=eg2;(egb=eg5||(eg5={})).FRAME="f",egb.SECOND="s";let By=F6;(egw=eg3||(eg3={})).SUM="SUM",egw.SUBTRACT="SUBTRACT",egw.AVERAGE="AVERAGE",(egx=eg4||(eg4={})).RLE="RLE",egx.Volume="Volume",(egC=eg8||(eg8={})).Tiled="tiled",egC.ContextPool="contextPool";let Bv=eg8,Bb={Auto:"auto",GPU:"gpu",CPU:"cpu"},Bw=Bb,Bx={hotIron:{name:"Hot Iron",numOfColors:256,colors:[[0,0,0,255],[2,0,0,255],[4,0,0,255],[6,0,0,255],[8,0,0,255],[10,0,0,255],[12,0,0,255],[14,0,0,255],[16,0,0,255],[18,0,0,255],[20,0,0,255],[22,0,0,255],[24,0,0,255],[26,0,0,255],[28,0,0,255],[30,0,0,255],[32,0,0,255],[34,0,0,255],[36,0,0,255],[38,0,0,255],[40,0,0,255],[42,0,0,255],[44,0,0,255],[46,0,0,255],[48,0,0,255],[50,0,0,255],[52,0,0,255],[54,0,0,255],[56,0,0,255],[58,0,0,255],[60,0,0,255],[62,0,0,255],[64,0,0,255],[66,0,0,255],[68,0,0,255],[70,0,0,255],[72,0,0,255],[74,0,0,255],[76,0,0,255],[78,0,0,255],[80,0,0,255],[82,0,0,255],[84,0,0,255],[86,0,0,255],[88,0,0,255],[90,0,0,255],[92,0,0,255],[94,0,0,255],[96,0,0,255],[98,0,0,255],[100,0,0,255],[102,0,0,255],[104,0,0,255],[106,0,0,255],[108,0,0,255],[110,0,0,255],[112,0,0,255],[114,0,0,255],[116,0,0,255],[118,0,0,255],[120,0,0,255],[122,0,0,255],[124,0,0,255],[126,0,0,255],[128,0,0,255],[130,0,0,255],[132,0,0,255],[134,0,0,255],[136,0,0,255],[138,0,0,255],[140,0,0,255],[142,0,0,255],[144,0,0,255],[146,0,0,255],[148,0,0,255],[150,0,0,255],[152,0,0,255],[154,0,0,255],[156,0,0,255],[158,0,0,255],[160,0,0,255],[162,0,0,255],[164,0,0,255],[166,0,0,255],[168,0,0,255],[170,0,0,255],[172,0,0,255],[174,0,0,255],[176,0,0,255],[178,0,0,255],[180,0,0,255],[182,0,0,255],[184,0,0,255],[186,0,0,255],[188,0,0,255],[190,0,0,255],[192,0,0,255],[194,0,0,255],[196,0,0,255],[198,0,0,255],[200,0,0,255],[202,0,0,255],[204,0,0,255],[206,0,0,255],[208,0,0,255],[210,0,0,255],[212,0,0,255],[214,0,0,255],[216,0,0,255],[218,0,0,255],[220,0,0,255],[222,0,0,255],[224,0,0,255],[226,0,0,255],[228,0,0,255],[230,0,0,255],[232,0,0,255],[234,0,0,255],[236,0,0,255],[238,0,0,255],[240,0,0,255],[242,0,0,255],[244,0,0,255],[246,0,0,255],[248,0,0,255],[250,0,0,255],[252,0,0,255],[254,0,0,255],[255,0,0,255],[255,2,0,255],[255,4,0,255],[255,6,0,255],[255,8,0,255],[255,10,0,255],[255,12,0,255],[255,14,0,255],[255,16,0,255],[255,18,0,255],[255,20,0,255],[255,22,0,255],[255,24,0,255],[255,26,0,255],[255,28,0,255],[255,30,0,255],[255,32,0,255],[255,34,0,255],[255,36,0,255],[255,38,0,255],[255,40,0,255],[255,42,0,255],[255,44,0,255],[255,46,0,255],[255,48,0,255],[255,50,0,255],[255,52,0,255],[255,54,0,255],[255,56,0,255],[255,58,0,255],[255,60,0,255],[255,62,0,255],[255,64,0,255],[255,66,0,255],[255,68,0,255],[255,70,0,255],[255,72,0,255],[255,74,0,255],[255,76,0,255],[255,78,0,255],[255,80,0,255],[255,82,0,255],[255,84,0,255],[255,86,0,255],[255,88,0,255],[255,90,0,255],[255,92,0,255],[255,94,0,255],[255,96,0,255],[255,98,0,255],[255,100,0,255],[255,102,0,255],[255,104,0,255],[255,106,0,255],[255,108,0,255],[255,110,0,255],[255,112,0,255],[255,114,0,255],[255,116,0,255],[255,118,0,255],[255,120,0,255],[255,122,0,255],[255,124,0,255],[255,126,0,255],[255,128,4,255],[255,130,8,255],[255,132,12,255],[255,134,16,255],[255,136,20,255],[255,138,24,255],[255,140,28,255],[255,142,32,255],[255,144,36,255],[255,146,40,255],[255,148,44,255],[255,150,48,255],[255,152,52,255],[255,154,56,255],[255,156,60,255],[255,158,64,255],[255,160,68,255],[255,162,72,255],[255,164,76,255],[255,166,80,255],[255,168,84,255],[255,170,88,255],[255,172,92,255],[255,174,96,255],[255,176,100,255],[255,178,104,255],[255,180,108,255],[255,182,112,255],[255,184,116,255],[255,186,120,255],[255,188,124,255],[255,190,128,255],[255,192,132,255],[255,194,136,255],[255,196,140,255],[255,198,144,255],[255,200,148,255],[255,202,152,255],[255,204,156,255],[255,206,160,255],[255,208,164,255],[255,210,168,255],[255,212,172,255],[255,214,176,255],[255,216,180,255],[255,218,184,255],[255,220,188,255],[255,222,192,255],[255,224,196,255],[255,226,200,255],[255,228,204,255],[255,230,208,255],[255,232,212,255],[255,234,216,255],[255,236,220,255],[255,238,224,255],[255,240,228,255],[255,242,232,255],[255,244,236,255],[255,246,240,255],[255,248,244,255],[255,250,248,255],[255,252,252,255],[255,255,255,255]]},pet:{name:"PET",numColors:256,colors:[[0,0,0,255],[0,2,1,255],[0,4,3,255],[0,6,5,255],[0,8,7,255],[0,10,9,255],[0,12,11,255],[0,14,13,255],[0,16,15,255],[0,18,17,255],[0,20,19,255],[0,22,21,255],[0,24,23,255],[0,26,25,255],[0,28,27,255],[0,30,29,255],[0,32,31,255],[0,34,33,255],[0,36,35,255],[0,38,37,255],[0,40,39,255],[0,42,41,255],[0,44,43,255],[0,46,45,255],[0,48,47,255],[0,50,49,255],[0,52,51,255],[0,54,53,255],[0,56,55,255],[0,58,57,255],[0,60,59,255],[0,62,61,255],[0,65,63,255],[0,67,65,255],[0,69,67,255],[0,71,69,255],[0,73,71,255],[0,75,73,255],[0,77,75,255],[0,79,77,255],[0,81,79,255],[0,83,81,255],[0,85,83,255],[0,87,85,255],[0,89,87,255],[0,91,89,255],[0,93,91,255],[0,95,93,255],[0,97,95,255],[0,99,97,255],[0,101,99,255],[0,103,101,255],[0,105,103,255],[0,107,105,255],[0,109,107,255],[0,111,109,255],[0,113,111,255],[0,115,113,255],[0,117,115,255],[0,119,117,255],[0,121,119,255],[0,123,121,255],[0,125,123,255],[0,128,125,255],[1,126,127,255],[3,124,129,255],[5,122,131,255],[7,120,133,255],[9,118,135,255],[11,116,137,255],[13,114,139,255],[15,112,141,255],[17,110,143,255],[19,108,145,255],[21,106,147,255],[23,104,149,255],[25,102,151,255],[27,100,153,255],[29,98,155,255],[31,96,157,255],[33,94,159,255],[35,92,161,255],[37,90,163,255],[39,88,165,255],[41,86,167,255],[43,84,169,255],[45,82,171,255],[47,80,173,255],[49,78,175,255],[51,76,177,255],[53,74,179,255],[55,72,181,255],[57,70,183,255],[59,68,185,255],[61,66,187,255],[63,64,189,255],[65,63,191,255],[67,61,193,255],[69,59,195,255],[71,57,197,255],[73,55,199,255],[75,53,201,255],[77,51,203,255],[79,49,205,255],[81,47,207,255],[83,45,209,255],[85,43,211,255],[86,41,213,255],[88,39,215,255],[90,37,217,255],[92,35,219,255],[94,33,221,255],[96,31,223,255],[98,29,225,255],[100,27,227,255],[102,25,229,255],[104,23,231,255],[106,21,233,255],[108,19,235,255],[110,17,237,255],[112,15,239,255],[114,13,241,255],[116,11,243,255],[118,9,245,255],[120,7,247,255],[122,5,249,255],[124,3,251,255],[126,1,253,255],[128,0,255,255],[130,2,252,255],[132,4,248,255],[134,6,244,255],[136,8,240,255],[138,10,236,255],[140,12,232,255],[142,14,228,255],[144,16,224,255],[146,18,220,255],[148,20,216,255],[150,22,212,255],[152,24,208,255],[154,26,204,255],[156,28,200,255],[158,30,196,255],[160,32,192,255],[162,34,188,255],[164,36,184,255],[166,38,180,255],[168,40,176,255],[170,42,172,255],[171,44,168,255],[173,46,164,255],[175,48,160,255],[177,50,156,255],[179,52,152,255],[181,54,148,255],[183,56,144,255],[185,58,140,255],[187,60,136,255],[189,62,132,255],[191,64,128,255],[193,66,124,255],[195,68,120,255],[197,70,116,255],[199,72,112,255],[201,74,108,255],[203,76,104,255],[205,78,100,255],[207,80,96,255],[209,82,92,255],[211,84,88,255],[213,86,84,255],[215,88,80,255],[217,90,76,255],[219,92,72,255],[221,94,68,255],[223,96,64,255],[225,98,60,255],[227,100,56,255],[229,102,52,255],[231,104,48,255],[233,106,44,255],[235,108,40,255],[237,110,36,255],[239,112,32,255],[241,114,28,255],[243,116,24,255],[245,118,20,255],[247,120,16,255],[249,122,12,255],[251,124,8,255],[253,126,4,255],[255,128,0,255],[255,130,4,255],[255,132,8,255],[255,134,12,255],[255,136,16,255],[255,138,20,255],[255,140,24,255],[255,142,28,255],[255,144,32,255],[255,146,36,255],[255,148,40,255],[255,150,44,255],[255,152,48,255],[255,154,52,255],[255,156,56,255],[255,158,60,255],[255,160,64,255],[255,162,68,255],[255,164,72,255],[255,166,76,255],[255,168,80,255],[255,170,85,255],[255,172,89,255],[255,174,93,255],[255,176,97,255],[255,178,101,255],[255,180,105,255],[255,182,109,255],[255,184,113,255],[255,186,117,255],[255,188,121,255],[255,190,125,255],[255,192,129,255],[255,194,133,255],[255,196,137,255],[255,198,141,255],[255,200,145,255],[255,202,149,255],[255,204,153,255],[255,206,157,255],[255,208,161,255],[255,210,165,255],[255,212,170,255],[255,214,174,255],[255,216,178,255],[255,218,182,255],[255,220,186,255],[255,222,190,255],[255,224,194,255],[255,226,198,255],[255,228,202,255],[255,230,206,255],[255,232,210,255],[255,234,214,255],[255,236,218,255],[255,238,222,255],[255,240,226,255],[255,242,230,255],[255,244,234,255],[255,246,238,255],[255,248,242,255],[255,250,246,255],[255,252,250,255],[255,255,255,255]]},hotMetalBlue:{name:"Hot Metal Blue",numColors:256,colors:[[0,0,0,255],[0,0,2,255],[0,0,4,255],[0,0,6,255],[0,0,8,255],[0,0,10,255],[0,0,12,255],[0,0,14,255],[0,0,16,255],[0,0,17,255],[0,0,19,255],[0,0,21,255],[0,0,23,255],[0,0,25,255],[0,0,27,255],[0,0,29,255],[0,0,31,255],[0,0,33,255],[0,0,35,255],[0,0,37,255],[0,0,39,255],[0,0,41,255],[0,0,43,255],[0,0,45,255],[0,0,47,255],[0,0,49,255],[0,0,51,255],[0,0,53,255],[0,0,55,255],[0,0,57,255],[0,0,59,255],[0,0,61,255],[0,0,63,255],[0,0,65,255],[0,0,67,255],[0,0,69,255],[0,0,71,255],[0,0,73,255],[0,0,75,255],[0,0,77,255],[0,0,79,255],[0,0,81,255],[0,0,83,255],[0,0,84,255],[0,0,86,255],[0,0,88,255],[0,0,90,255],[0,0,92,255],[0,0,94,255],[0,0,96,255],[0,0,98,255],[0,0,100,255],[0,0,102,255],[0,0,104,255],[0,0,106,255],[0,0,108,255],[0,0,110,255],[0,0,112,255],[0,0,114,255],[0,0,116,255],[0,0,117,255],[0,0,119,255],[0,0,121,255],[0,0,123,255],[0,0,125,255],[0,0,127,255],[0,0,129,255],[0,0,131,255],[0,0,133,255],[0,0,135,255],[0,0,137,255],[0,0,139,255],[0,0,141,255],[0,0,143,255],[0,0,145,255],[0,0,147,255],[0,0,149,255],[0,0,151,255],[0,0,153,255],[0,0,155,255],[0,0,157,255],[0,0,159,255],[0,0,161,255],[0,0,163,255],[0,0,165,255],[0,0,167,255],[3,0,169,255],[6,0,171,255],[9,0,173,255],[12,0,175,255],[15,0,177,255],[18,0,179,255],[21,0,181,255],[24,0,183,255],[26,0,184,255],[29,0,186,255],[32,0,188,255],[35,0,190,255],[38,0,192,255],[41,0,194,255],[44,0,196,255],[47,0,198,255],[50,0,200,255],[52,0,197,255],[55,0,194,255],[57,0,191,255],[59,0,188,255],[62,0,185,255],[64,0,182,255],[66,0,179,255],[69,0,176,255],[71,0,174,255],[74,0,171,255],[76,0,168,255],[78,0,165,255],[81,0,162,255],[83,0,159,255],[85,0,156,255],[88,0,153,255],[90,0,150,255],[93,2,144,255],[96,4,138,255],[99,6,132,255],[102,8,126,255],[105,9,121,255],[108,11,115,255],[111,13,109,255],[114,15,103,255],[116,17,97,255],[119,19,91,255],[122,21,85,255],[125,23,79,255],[128,24,74,255],[131,26,68,255],[134,28,62,255],[137,30,56,255],[140,32,50,255],[143,34,47,255],[146,36,44,255],[149,38,41,255],[152,40,38,255],[155,41,35,255],[158,43,32,255],[161,45,29,255],[164,47,26,255],[166,49,24,255],[169,51,21,255],[172,53,18,255],[175,55,15,255],[178,56,12,255],[181,58,9,255],[184,60,6,255],[187,62,3,255],[190,64,0,255],[194,66,0,255],[198,68,0,255],[201,70,0,255],[205,72,0,255],[209,73,0,255],[213,75,0,255],[217,77,0,255],[221,79,0,255],[224,81,0,255],[228,83,0,255],[232,85,0,255],[236,87,0,255],[240,88,0,255],[244,90,0,255],[247,92,0,255],[251,94,0,255],[255,96,0,255],[255,98,3,255],[255,100,6,255],[255,102,9,255],[255,104,12,255],[255,105,15,255],[255,107,18,255],[255,109,21,255],[255,111,24,255],[255,113,26,255],[255,115,29,255],[255,117,32,255],[255,119,35,255],[255,120,38,255],[255,122,41,255],[255,124,44,255],[255,126,47,255],[255,128,50,255],[255,130,53,255],[255,132,56,255],[255,134,59,255],[255,136,62,255],[255,137,65,255],[255,139,68,255],[255,141,71,255],[255,143,74,255],[255,145,76,255],[255,147,79,255],[255,149,82,255],[255,151,85,255],[255,152,88,255],[255,154,91,255],[255,156,94,255],[255,158,97,255],[255,160,100,255],[255,162,103,255],[255,164,106,255],[255,166,109,255],[255,168,112,255],[255,169,115,255],[255,171,118,255],[255,173,121,255],[255,175,124,255],[255,177,126,255],[255,179,129,255],[255,181,132,255],[255,183,135,255],[255,184,138,255],[255,186,141,255],[255,188,144,255],[255,190,147,255],[255,192,150,255],[255,194,153,255],[255,196,156,255],[255,198,159,255],[255,200,162,255],[255,201,165,255],[255,203,168,255],[255,205,171,255],[255,207,174,255],[255,209,176,255],[255,211,179,255],[255,213,182,255],[255,215,185,255],[255,216,188,255],[255,218,191,255],[255,220,194,255],[255,222,197,255],[255,224,200,255],[255,226,203,255],[255,228,206,255],[255,229,210,255],[255,231,213,255],[255,233,216,255],[255,235,219,255],[255,237,223,255],[255,239,226,255],[255,240,229,255],[255,242,232,255],[255,244,236,255],[255,246,239,255],[255,248,242,255],[255,250,245,255],[255,251,249,255],[255,253,252,255],[255,255,255,255]]},pet20Step:{name:"PET 20 Step",numColors:256,colors:[[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255],[255,255,255,255]]},gray:{name:"Gray",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,1,1]],green:[[0,0,0],[1,1,1]],blue:[[0,0,0],[1,1,1]]}},jet:{name:"Jet",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.35,0,0],[.66,1,1],[.89,1,1],[1,.5,.5]],green:[[0,0,0],[.125,0,0],[.375,1,1],[.64,1,1],[.91,0,0],[1,0,0]],blue:[[0,.5,.5],[.11,1,1],[.34,1,1],[.65,0,0],[1,0,0]]}},hsv:{name:"HSV",numColors:256,gamma:1,segmentedData:{red:[[0,1,1],[.15873,1,1],[.174603,.96875,.96875],[.333333,.03125,.03125],[.349206,0,0],[.666667,0,0],[.68254,.03125,.03125],[.84127,.96875,.96875],[.857143,1,1],[1,1,1]],green:[[0,0,0],[.15873,.9375,.9375],[.174603,1,1],[.507937,1,1],[.666667,.0625,.0625],[.68254,0,0],[1,0,0]],blue:[[0,0,0],[.333333,0,0],[.349206,.0625,.0625],[.507937,1,1],[.84127,1,1],[.857143,.9375,.9375],[1,.09375,.09375]]}},hot:{name:"Hot",numColors:256,gamma:1,segmentedData:{red:[[0,.0416,.0416],[.365079,1,1],[1,1,1]],green:[[0,0,0],[.365079,0,0],[.746032,1,1],[1,1,1]],blue:[[0,0,0],[.746032,0,0],[1,1,1]]}},cool:{name:"Cool",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,1,1]],green:[[0,1,1],[1,0,0]],blue:[[0,1,1],[1,1,1]]}},spring:{name:"Spring",numColors:256,gamma:1,segmentedData:{red:[[0,1,1],[1,1,1]],green:[[0,0,0],[1,1,1]],blue:[[0,1,1],[1,0,0]]}},summer:{name:"Summer",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,1,1]],green:[[0,.5,.5],[1,1,1]],blue:[[0,.4,.4],[1,.4,.4]]}},autumn:{name:"Autumn",numColors:256,gamma:1,segmentedData:{red:[[0,1,1],[1,1,1]],green:[[0,0,0],[1,1,1]],blue:[[0,0,0],[1,0,0]]}},winter:{name:"Winter",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,0,0]],green:[[0,0,0],[1,1,1]],blue:[[0,1,1],[1,.5,.5]]}},bone:{name:"Bone",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.746032,.652778,.652778],[1,1,1]],green:[[0,0,0],[.365079,.319444,.319444],[.746032,.777778,.777778],[1,1,1]],blue:[[0,0,0],[.365079,.444444,.444444],[1,1,1]]}},copper:{name:"Copper",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.809524,1,1],[1,1,1]],green:[[0,0,0],[1,.7812,.7812]],blue:[[0,0,0],[1,.4975,.4975]]}},spectral:{name:"Spectral",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.05,.4667,.4667],[.1,.5333,.5333],[.15,0,0],[.2,0,0],[.25,0,0],[.3,0,0],[.35,0,0],[.4,0,0],[.45,0,0],[.5,0,0],[.55,0,0],[.6,0,0],[.65,.7333,.7333],[.7,.9333,.9333],[.75,1,1],[.8,1,1],[.85,1,1],[.9,.8667,.8667],[.95,.8,.8],[1,.8,.8]],green:[[0,0,0],[.05,0,0],[.1,0,0],[.15,0,0],[.2,0,0],[.25,.4667,.4667],[.3,.6,.6],[.35,.6667,.6667],[.4,.6667,.6667],[.45,.6,.6],[.5,.7333,.7333],[.55,.8667,.8667],[.6,1,1],[.65,1,1],[.7,.9333,.9333],[.75,.8,.8],[.8,.6,.6],[.85,0,0],[.9,0,0],[.95,0,0],[1,.8,.8]],blue:[[0,0,0],[.05,.5333,.5333],[.1,.6,.6],[.15,.6667,.6667],[.2,.8667,.8667],[.25,.8667,.8667],[.3,.8667,.8667],[.35,.6667,.6667],[.4,.5333,.5333],[.45,0,0],[.5,0,0],[.55,0,0],[.6,0,0],[.65,0,0],[.7,0,0],[.75,0,0],[.8,0,0],[.85,0,0],[.9,0,0],[.95,0,0],[1,.8,.8]]}},coolwarm:{name:"CoolWarm",numColors:256,gamma:1,segmentedData:{red:[[0,.2298057,.2298057],[.03125,.26623388,.26623388],[.0625,.30386891,.30386891],[.09375,.342804478,.342804478],[.125,.38301334,.38301334],[.15625,.424369608,.424369608],[.1875,.46666708,.46666708],[.21875,.509635204,.509635204],[.25,.552953156,.552953156],[.28125,.596262162,.596262162],[.3125,.639176211,.639176211],[.34375,.681291281,.681291281],[.375,.722193294,.722193294],[.40625,.761464949,.761464949],[.4375,.798691636,.798691636],[.46875,.833466556,.833466556],[.5,.865395197,.865395197],[.53125,.897787179,.897787179],[.5625,.924127593,.924127593],[.59375,.944468518,.944468518],[.625,.958852946,.958852946],[.65625,.96732803,.96732803],[.6875,.969954137,.969954137],[.71875,.966811177,.966811177],[.75,.958003065,.958003065],[.78125,.943660866,.943660866],[.8125,.923944917,.923944917],[.84375,.89904617,.89904617],[.875,.869186849,.869186849],[.90625,.834620542,.834620542],[.9375,.795631745,.795631745],[.96875,.752534934,.752534934],[1,.705673158,.705673158]],green:[[0,.298717966,.298717966],[.03125,.353094838,.353094838],[.0625,.406535296,.406535296],[.09375,.458757618,.458757618],[.125,.50941904,.50941904],[.15625,.558148092,.558148092],[.1875,.604562568,.604562568],[.21875,.648280772,.648280772],[.25,.688929332,.688929332],[.28125,.726149107,.726149107],[.3125,.759599947,.759599947],[.34375,.788964712,.788964712],[.375,.813952739,.813952739],[.40625,.834302879,.834302879],[.4375,.849786142,.849786142],[.46875,.860207984,.860207984],[.5,.86541021,.86541021],[.53125,.848937047,.848937047],[.5625,.827384882,.827384882],[.59375,.800927443,.800927443],[.625,.769767752,.769767752],[.65625,.734132809,.734132809],[.6875,.694266682,.694266682],[.71875,.650421156,.650421156],[.75,.602842431,.602842431],[.78125,.551750968,.551750968],[.8125,.49730856,.49730856],[.84375,.439559467,.439559467],[.875,.378313092,.378313092],[.90625,.312874446,.312874446],[.9375,.24128379,.24128379],[.96875,.157246067,.157246067],[1,.01555616,.01555616]],blue:[[0,.753683153,.753683153],[.03125,.801466763,.801466763],[.0625,.84495867,.84495867],[.09375,.883725899,.883725899],[.125,.917387822,.917387822],[.15625,.945619588,.945619588],[.1875,.968154911,.968154911],[.21875,.98478814,.98478814],[.25,.995375608,.995375608],[.28125,.999836203,.999836203],[.3125,.998151185,.998151185],[.34375,.990363227,.990363227],[.375,.976574709,.976574709],[.40625,.956945269,.956945269],[.4375,.931688648,.931688648],[.46875,.901068838,.901068838],[.5,.865395561,.865395561],[.53125,.820880546,.820880546],[.5625,.774508472,.774508472],[.59375,.726736146,.726736146],[.625,.678007945,.678007945],[.65625,.628751763,.628751763],[.6875,.579375448,.579375448],[.71875,.530263762,.530263762],[.75,.481775914,.481775914],[.78125,.434243684,.434243684],[.8125,.387970225,.387970225],[.84375,.343229596,.343229596],[.875,.300267182,.300267182],[.90625,.259301199,.259301199],[.9375,.220525627,.220525627],[.96875,.184115123,.184115123],[1,.150232812,.150232812]]}},blues:{name:"Blues",numColors:256,gamma:1,segmentedData:{red:[[0,.9686274528503418,.9686274528503418],[.125,.8705882430076599,.8705882430076599],[.25,.7764706015586853,.7764706015586853],[.375,.6196078658103943,.6196078658103943],[.5,.41960784792900085,.41960784792900085],[.625,.25882354378700256,.25882354378700256],[.75,.12941177189350128,.12941177189350128],[.875,.0313725508749485,.0313725508749485],[1,.0313725508749485,.0313725508749485]],green:[[0,.9843137264251709,.9843137264251709],[.125,.9215686321258545,.9215686321258545],[.25,.8588235378265381,.8588235378265381],[.375,.7921568751335144,.7921568751335144],[.5,.6823529601097107,.6823529601097107],[.625,.572549045085907,.572549045085907],[.75,.4431372582912445,.4431372582912445],[.875,.3176470696926117,.3176470696926117],[1,.1882352977991104,.1882352977991104]],blue:[[0,1,1],[.125,.9686274528503418,.9686274528503418],[.25,.9372549057006836,.9372549057006836],[.375,.8823529481887817,.8823529481887817],[.5,.8392156958580017,.8392156958580017],[.625,.7764706015586853,.7764706015586853],[.75,.7098039388656616,.7098039388656616],[.875,.6117647290229797,.6117647290229797],[1,.41960784792900085,.41960784792900085]]}}},BC={MINIMUM_SLAB_THICKNESS:.05,MAXIMUM_RAY_DISTANCE:1e6};Object.freeze(BC);let Bk=BC,BM=.001,BE=function e(t){for(let r of Object.getOwnPropertyNames(t)){let n=t[r];n&&"object"==typeof n&&e(n)}return Object.freeze(t)}({axial:{viewPlaneNormal:[0,0,-1],viewUp:[0,-1,0],viewRight:[1,0,0]},sagittal:{viewPlaneNormal:[1,0,0],viewUp:[0,0,1],viewRight:[0,1,0]},coronal:{viewPlaneNormal:[0,-1,0],viewUp:[0,0,1],viewRight:[1,0,0]}}),BS=[{name:"CT-AAA",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"12 -3024 0 143.556 0 166.222 0.686275 214.389 0.696078 419.736 0.833333 3071 0.803922",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"24 -3024 0 0 0 143.556 0.615686 0.356863 0.184314 166.222 0.882353 0.603922 0.290196 214.389 1 1 1 419.736 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-AAA2",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"16 -3024 0 129.542 0 145.244 0.166667 157.02 0.5 169.918 0.627451 395.575 0.8125 1578.73 0.8125 3071 0.8125",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"32 -3024 0 0 0 129.542 0.54902 0.25098 0.14902 145.244 0.6 0.627451 0.843137 157.02 0.890196 0.47451 0.6 169.918 0.992157 0.870588 0.392157 395.575 1 0.886275 0.658824 1578.73 1 0.829256 0.957922 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Bone",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"8 -3024 0 -16.4458 0 641.385 0.715686 3071 0.705882",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"16 -3024 0 0 0 -16.4458 0.729412 0.254902 0.301961 641.385 0.905882 0.815686 0.552941 3071 1 1 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Bones",gradientOpacity:"4 0 1 985.12 1",specularPower:"1",scalarOpacity:"8 -1000 0 152.19 0 278.93 0.190476 952 0.2",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"20 -1000 0.3 0.3 1 -488 0.3 1 0.3 463.28 1 0 0 659.15 1 0.912535 0.0374849 953 1 0.3 0.3",diffuse:"1",interpolation:"1"},{name:"CT-Cardiac",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"12 -3024 0 -77.6875 0 94.9518 0.285714 179.052 0.553571 260.439 0.848214 3071 0.875",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"24 -3024 0 0 0 -77.6875 0.54902 0.25098 0.14902 94.9518 0.882353 0.603922 0.290196 179.052 1 0.937033 0.954531 260.439 0.615686 0 0 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Cardiac2",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"12 -3024 0 42.8964 0 163.488 0.428571 277.642 0.776786 1587 0.754902 3071 0.754902",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"24 -3024 0 0 0 42.8964 0.54902 0.25098 0.14902 163.488 0.917647 0.639216 0.0588235 277.642 1 0.878431 0.623529 1587 1 1 1 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Cardiac3",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"14 -3024 0 -86.9767 0 45.3791 0.169643 139.919 0.589286 347.907 0.607143 1224.16 0.607143 3071 0.616071",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"28 -3024 0 0 0 -86.9767 0 0.25098 1 45.3791 1 0 0 139.919 1 0.894893 0.894893 347.907 1 1 0.25098 1224.16 1 1 1 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Chest-Contrast-Enhanced",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"10 -3024 0 67.0106 0 251.105 0.446429 439.291 0.625 3071 0.616071",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"20 -3024 0 0 0 67.0106 0.54902 0.25098 0.14902 251.105 0.882353 0.603922 0.290196 439.291 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Chest-Vessels",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"10 -3024 0 -1278.35 0 22.8277 0.428571 439.291 0.625 3071 0.616071",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"20 -3024 0 0 0 -1278.35 0.54902 0.25098 0.14902 22.8277 0.882353 0.603922 0.290196 439.291 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"1",interpolation:"1"},{name:"CT-Coronary-Arteries",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"12 -2048 0 136.47 0 159.215 0.258929 318.43 0.571429 478.693 0.776786 3661 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"24 -2048 0 0 0 136.47 0 0 0 159.215 0.159804 0.159804 0.159804 318.43 0.764706 0.764706 0.764706 478.693 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Coronary-Arteries-2",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"14 -2048 0 142.677 0 145.016 0.116071 192.174 0.5625 217.24 0.776786 384.347 0.830357 3661 0.830357",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"28 -2048 0 0 0 142.677 0 0 0 145.016 0.615686 0 0.0156863 192.174 0.909804 0.454902 0 217.24 0.972549 0.807843 0.611765 384.347 0.909804 0.909804 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Coronary-Arteries-3",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"14 -2048 0 128.643 0 129.982 0.0982143 173.636 0.669643 255.884 0.857143 584.878 0.866071 3661 1",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"28 -2048 0 0 0 128.643 0 0 0 129.982 0.615686 0 0.0156863 173.636 0.909804 0.454902 0 255.884 0.886275 0.886275 0.886275 584.878 0.968627 0.968627 0.968627 3661 1 1 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Cropped-Volume-Bone",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"10 -2048 0 -451 0 -450 1 1050 1 3661 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"20 -2048 0 0 0 -451 0 0 0 -450 0.0556356 0.0556356 0.0556356 1050 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Fat",gradientOpacity:"6 0 1 985.12 1 988 1",specularPower:"1",scalarOpacity:"14 -1000 0 -100 0 -99 0.15 -60 0.15 -59 0 101.2 0 952 0",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"36 -1000 0.3 0.3 1 -497.5 0.3 1 0.3 -99 0 0 1 -76.946 0 1 0 -65.481 0.835431 0.888889 0.0165387 83.89 1 0 0 463.28 1 0 0 659.15 1 0.912535 0.0374849 2952 1 0.300267 0.299886",diffuse:"1",interpolation:"1"},{name:"CT-Liver-Vasculature",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"14 -2048 0 149.113 0 157.884 0.482143 339.96 0.660714 388.526 0.830357 1197.95 0.839286 3661 0.848214",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"28 -2048 0 0 0 149.113 0 0 0 157.884 0.501961 0.25098 0 339.96 0.695386 0.59603 0.36886 388.526 0.854902 0.85098 0.827451 1197.95 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Lung",gradientOpacity:"6 0 1 985.12 1 988 1",specularPower:"1",scalarOpacity:"12 -1000 0 -600 0 -599 0.15 -400 0.15 -399 0 2952 0",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"24 -1000 0.3 0.3 1 -600 0 0 1 -530 0.134704 0.781726 0.0724558 -460 0.929244 1 0.109473 -400 0.888889 0.254949 0.0240258 2952 1 0.3 0.3",diffuse:"1",interpolation:"1"},{name:"CT-MIP",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"8 -3024 0 -637.62 0 700 1 3071 1",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"16 -3024 0 0 0 -637.62 1 1 1 700 1 1 1 3071 1 1 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Muscle",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"10 -3024 0 -155.407 0 217.641 0.676471 419.736 0.833333 3071 0.803922",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"20 -3024 0 0 0 -155.407 0.54902 0.25098 0.14902 217.641 0.882353 0.603922 0.290196 419.736 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Pulmonary-Arteries",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"14 -2048 0 -568.625 0 -364.081 0.0714286 -244.813 0.401786 18.2775 0.607143 447.798 0.830357 3592.73 0.839286",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"28 -2048 0 0 0 -568.625 0 0 0 -364.081 0.396078 0.301961 0.180392 -244.813 0.611765 0.352941 0.0705882 18.2775 0.843137 0.0156863 0.156863 447.798 0.752941 0.752941 0.752941 3592.73 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Soft-Tissue",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"10 -2048 0 -167.01 0 -160 1 240 1 3661 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"20 -2048 0 0 0 -167.01 0 0 0 -160 0.0556356 0.0556356 0.0556356 240 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Air",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"8 -3024 0.705882 -900.0 0.715686 -500.0 0 3071 0",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"16 -3024 1 1 1 -900.0 0.2 1.0 1.0 -500.0 0.3 0.3 1.0 3071 0 0 0 ",diffuse:"0.9",interpolation:"1"},{name:"MR-Angio",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"12 -2048 0 151.354 0 158.279 0.4375 190.112 0.580357 200.873 0.732143 3661 0.741071",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"24 -2048 0 0 0 151.354 0 0 0 158.279 0.74902 0.376471 0 190.112 1 0.866667 0.733333 200.873 0.937255 0.937255 0.937255 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"MR-Default",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"12 0 0 20 0 40 0.15 120 0.3 220 0.375 1024 0.5",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"24 0 0 0 0 20 0.168627 0 0 40 0.403922 0.145098 0.0784314 120 0.780392 0.607843 0.380392 220 0.847059 0.835294 0.788235 1024 1 1 1",diffuse:"1",interpolation:"1"},{name:"MR-MIP",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"8 0 0 98.3725 0 416.637 1 2800 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"16 0 1 1 1 98.3725 1 1 1 416.637 1 1 1 2800 1 1 1",diffuse:"1",interpolation:"1"},{name:"MR-T2-Brain",gradientOpacity:"4 0 1 160.25 1",specularPower:"40",scalarOpacity:"10 0 0 36.05 0 218.302 0.171429 412.406 1 641 1",specular:"0.5",shade:"1",ambient:"0.3",colorTransfer:"16 0 0 0 0 98.7223 0.956863 0.839216 0.192157 412.406 0 0.592157 0.807843 641 1 1 1",diffuse:"0.6",interpolation:"1"},{name:"DTI-FA-Brain",gradientOpacity:"4 0 1 0.9950 1",specularPower:"40",scalarOpacity:"16 0 0 0 0 0.3501 0.0158 0.49379 0.7619 0.6419 1 0.9920 1 0.9950 0 0.9950 0",specular:"0.5",shade:"1",ambient:"0.3",colorTransfer:"28 0 1 0 0 0 1 0 0 0.24974 0.4941 1 0 0.49949 0 0.9882 1 0.7492 0.51764 0 1 0.9950 1 0 0 0.9950 1 0 0",diffuse:"0.9",interpolation:"1"}],BD={},BI=e=>BD[e],BP=()=>{let e=Object.keys(BD).map(e=>BD[e]);return e.sort((e,t)=>"_"===e.id[0]&&"_"!==t.id[0]?1:"_"!==e.id[0]&&"_"===t.id[0]?-1:0),e},BT=e=>e&&"object"==typeof e&&"[object RegExp]"!==Object.prototype.toString.call(e)&&"[object Date]"!==Object.prototype.toString.call(e),B_=(e,t)=>t&&!0===t.clone&&BT(e)?BO(Array.isArray(e)?[]:{},e,t):e,BA=(e,t,r)=>{let n=e.slice();return t.forEach(function(t,a){void 0===n[a]?n[a]=B_(t,r):BT(t)?n[a]=BO(e[a],t,r):-1===e.indexOf(t)&&(n[a]=B_(t,r))}),n},BO=(e={},t={},r)=>{let n,a=Array.isArray(t),i=(r||{arrayMerge:BA}).arrayMerge||BA;return a?Array.isArray(e)?i(e,t,r):B_(t,r):(n={},BT(e)&&Object.keys(e).forEach(function(t){n[t]=B_(e[t],r)}),Object.keys(t).forEach(function(a){BT(t[a])&&e[a]?n[a]=BO(e[a],t[a],r):n[a]=B_(t[a],r)}),n)},BR=Symbol("Comlink.proxy"),BL=Symbol("Comlink.endpoint"),BN=Symbol("Comlink.releaseProxy"),BF=Symbol("Comlink.finalizer"),BV=Symbol("Comlink.thrown"),BB=e=>"object"==typeof e&&null!==e||"function"==typeof e,Bj=new Map([["proxy",{canHandle:e=>BB(e)&&e[BR],serialize(e){let{port1:t,port2:r}=new MessageChannel;return function e(t,r=globalThis,n=["*"]){r.addEventListener("message",function a(i){let o;if(!i||!i.data)return;if(!function(e,t){for(let r of e)if(t===r||"*"===r||r instanceof RegExp&&r.test(t))return!0;return!1}(n,i.origin))return void console.warn(`Invalid origin '${i.origin}' for comlink proxy`);let{id:s,type:l,path:u}=Object.assign({path:[]},i.data),c=(i.data.argumentList||[]).map(BY);try{var d,h,p;let r=u.slice(0,-1).reduce((e,t)=>e[t],t),n=u.reduce((e,t)=>e[t],t);switch(l){case"GET":o=n;break;case"SET":r[u.slice(-1)[0]]=BY(i.data.value),o=!0;break;case"APPLY":o=n.apply(r,c);break;case"CONSTRUCT":d=new n(...c),o=Object.assign(d,{[BR]:!0});break;case"ENDPOINT":{let{port1:r,port2:n}=new MessageChannel;e(t,n),h=r,p=[r],B$.set(h,p),o=h}break;case"RELEASE":o=void 0;break;default:return}}catch(e){o={value:e,[BV]:0}}Promise.resolve(o).catch(e=>({value:e,[BV]:0})).then(e=>{let[n,i]=BK(e);r.postMessage(Object.assign(Object.assign({},n),{id:s}),i),"RELEASE"===l&&(r.removeEventListener("message",a),BW(r),BF in t&&"function"==typeof t[BF]&&t[BF]())}).catch(e=>{let[t,n]=BK({value:TypeError("Unserializable return value"),[BV]:0});r.postMessage(Object.assign(Object.assign({},t),{id:s}),n)})}),r.start&&r.start()}(e,t),[r,[r]]},deserialize:e=>{var t;let r;return e.start(),t=e,r=new Map,t.addEventListener("message",function(e){let{data:t}=e;if(!t||!t.id)return;let n=r.get(t.id);if(n)try{n(t)}finally{r.delete(t.id)}}),function e(t,r,n=[],a=function(){}){let i,o=!1,s=new Proxy(a,{get(a,i){if(BU(o),i===BN)return()=>{BG&&BG.unregister(s),Bz(t),r.clear(),o=!0};if("then"===i){if(0===n.length)return{then:()=>s};let e=BX(t,r,{type:"GET",path:n.map(e=>e.toString())}).then(BY);return e.then.bind(e)}return e(t,r,[...n,i])},set(e,a,i){BU(o);let[s,l]=BK(i);return BX(t,r,{type:"SET",path:[...n,a].map(e=>e.toString()),value:s},l).then(BY)},apply(a,i,s){BU(o);let l=n[n.length-1];if(l===BL)return BX(t,r,{type:"ENDPOINT"}).then(BY);if("bind"===l)return e(t,r,n.slice(0,-1));let[u,c]=Bq(s);return BX(t,r,{type:"APPLY",path:n.map(e=>e.toString()),argumentList:u},c).then(BY)},construct(e,a){BU(o);let[i,s]=Bq(a);return BX(t,r,{type:"CONSTRUCT",path:n.map(e=>e.toString()),argumentList:i},s).then(BY)}});return i=(BH.get(t)||0)+1,BH.set(t,i),BG&&BG.register(s,t,s),s}(t,r,[],void 0)}}],["throw",{canHandle:e=>BB(e)&&BV in e,serialize:({value:e})=>[e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[]],deserialize(e){if(e.isError)throw Object.assign(Error(e.value.message),e.value);throw e.value}}]]);function BW(e){"MessagePort"===e.constructor.name&&e.close()}function BU(e){if(e)throw Error("Proxy has been released and is not useable")}function Bz(e){return BX(e,new Map,{type:"RELEASE"}).then(()=>{BW(e)})}let BH=new WeakMap,BG="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{let t=(BH.get(e)||0)-1;BH.set(e,t),0===t&&Bz(e)});function Bq(e){var t;let r=e.map(BK);return[r.map(e=>e[0]),(t=r.map(e=>e[1]),Array.prototype.concat.apply([],t))]}let B$=new WeakMap;function BK(e){for(let[t,r]of Bj)if(r.canHandle(e)){let[n,a]=r.serialize(e);return[{type:"HANDLER",name:t,value:n},a]}return[{type:"RAW",value:e},B$.get(e)||[]]}function BY(e){switch(e.type){case"HANDLER":return Bj.get(e.name).deserialize(e.value);case"RAW":return e.value}}function BX(e,t,r,n){return new Promise(a=>{let i=[,,,,].fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");t.set(i,a),e.start&&e.start(),e.postMessage(Object.assign({id:i},r),n)})}function BZ(){return"function"==typeof crypto.randomUUID?crypto.randomUUID():"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}class BJ{constructor(e){this.numRequests={[FU.Interaction]:0,[FU.Thumbnail]:0,[FU.Prefetch]:0,[FU.Compute]:0},this.id=e||BZ(),this.requestPool={[FU.Interaction]:{0:[]},[FU.Thumbnail]:{0:[]},[FU.Prefetch]:{0:[]},[FU.Compute]:{0:[]}},this.grabDelay=5,this.awake=!1,this.numRequests={[FU.Interaction]:0,[FU.Thumbnail]:0,[FU.Prefetch]:0,[FU.Compute]:0},this.maxNumRequests={[FU.Interaction]:6,[FU.Thumbnail]:6,[FU.Prefetch]:5,[FU.Compute]:1e3}}setMaxSimultaneousRequests(e,t){this.maxNumRequests[e]=t}getMaxSimultaneousRequests(e){return this.maxNumRequests[e]}destroy(){this.timeoutHandle&&window.clearTimeout(this.timeoutHandle)}addRequest(e,t,r,n=0){void 0===this.requestPool[t][n]&&(this.requestPool[t][n]=[]),this.requestPool[t][n].push({requestFn:e,type:t,additionalDetails:r}),this.startGrabbing()}filterRequests(e){Object.keys(this.requestPool).forEach(t=>{let r=this.requestPool[t];Object.keys(r).forEach(t=>{r[t]=r[t].filter(t=>e(t))})})}clearRequestStack(e){if(!this.requestPool[e])throw Error(`No category for the type ${e} found`);this.requestPool[e]={0:[]}}sendRequests(e){let t=this.maxNumRequests[e]-this.numRequests[e],r=0;for(let n=0;n<t;n++){let t=this.getNextRequest(e);if(null===t)return!1;if(t){let n;this.numRequests[e]++,this.awake=!0;try{n=t.requestFn()}catch(e){console.warn("sendRequest failed",e)}n?.finally?n.finally(()=>{this.numRequests[e]--,this.startAgain()}):(this.numRequests[e]--,r++)}}return r&&this.startAgain(),!0}getNextRequest(e){for(let t of this.getSortedPriorityGroups(e))if(this.requestPool[e][t].length)return this.requestPool[e][t].shift();return null}startGrabbing(){let e=this.sendRequests(FU.Interaction),t=this.sendRequests(FU.Thumbnail),r=this.sendRequests(FU.Prefetch),n=this.sendRequests(FU.Compute);e||t||r||n||(this.awake=!1)}startAgain(){this.awake&&(void 0!==this.grabDelay?this.timeoutHandle||(this.timeoutHandle=window.setTimeout(()=>{this.timeoutHandle=null,this.startGrabbing()},this.grabDelay)):this.startGrabbing())}getSortedPriorityGroups(e){return Object.keys(this.requestPool[e]).map(Number).filter(t=>this.requestPool[e][t].length).sort((e,t)=>e-t)}getRequestPool(){return this.requestPool}}let{pp:BQ,tZ:B1,gE:B0,bM:B2,uu:B5,UA:B3,_E:B4,RZ:B8,UX:B6,HL:B9,U5:B7}=ee;B2.getLogger("registration");function je(e,{ext:t,filterType:r,texData:n,internalFormat:a,glDataType:i}){try{let o;if(t&&!(o=e.getExtension(t)))return!1;let s=e.createTexture();e.bindTexture(e.TEXTURE_2D,s),e.texImage2D(e.TEXTURE_2D,0,a(e,o),5,1,0,e.RED,i(e,o),n);let l="LINEAR"===r?e.LINEAR:e.NEAREST;e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,l),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,l),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.POINTS,0,1);let u=new Uint8Array(4);e.readPixels(1,1,1,1,e.RGBA,e.UNSIGNED_BYTE,u);let[c,d,h]=u;return e.deleteTexture(s),c===d&&d===h&&0!==c}catch(e){return!1}}let jt="cornerstone3D.renderingCapabilities",jr=/swiftshader|llvmpipe|softpipe|software|microsoft basic render/i,jn={norm16:!1,norm16Linear:!1,float:!1,floatLinear:!1,halfFloat:!1,halfFloatLinear:!1},ja=null;function ji(){return ja||(ja=function({useCache:e=!0}={}){let t=function(){let e={webgl:!1,webgl2:!1,maxTextureSize:0,renderer:""};if("u"<typeof document)return e;try{let t=document.createElement("canvas"),r=t.getContext("webgl2"),n=r||t.getContext("webgl")||t.getContext("experimental-webgl");if(!n)return e;e.webgl=!0,e.webgl2=!!r,e.maxTextureSize=Number(n.getParameter(n.MAX_TEXTURE_SIZE))||0;let a=n.getExtension("WEBGL_debug_renderer_info"),i=a?n.getParameter(a.UNMASKED_RENDERER_WEBGL):n.getParameter(n.RENDERER);e.renderer="string"==typeof i?i:"";let o=n.getExtension("WEBGL_lose_context");o&&o.loseContext()}catch{}return e}();if(!t.webgl)return{...t,...jn,softwareRasterizer:!1};let r=e?function(e,t){try{let r=window.localStorage?.getItem(jt);if(!r)return null;let n=JSON.parse(r);if(n?.probeVersion!==1||n?.renderer!==e||n?.webgl2!==t||"object"!=typeof n?.formats||n?.formats===null)return null;return{...jn,...n.formats}}catch{return null}}(t.renderer,t.webgl2):null;if(!r){let e=function(){let e=function(){try{let e=document.createElement("canvas");e.width=4,e.height=4;let t=e.getContext("webgl2");if(!t)return null;let r=`#version 300 es
|
|
10
10
|
void main() {
|
|
11
11
|
gl_PointSize = 4.0;
|
|
12
12
|
gl_Position = vec4(0, 0, 0, 1);
|