"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[822],{86822:(e,t,n)=>{n.r(t),n.d(t,{default:()=>f});var r=n(43001),s=n(3827),a=n.n(s),i=n(71771),o=n(71783),l=n(69190),c=n(14957),u=n(41832),m=n(3743);function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},d.apply(this,arguments)}const{formatDate:p}=i.utils;function E(e){const{displaySets:t,viewportId:n,viewportLabel:s,servicesManager:a,extensionManager:E}=e,{t:f}=(0,l.$G)("Common"),{measurementService:S,cornerstoneViewportService:v,viewportGridService:g}=a.services,b=t[0],[w,D]=(0,u.I)(),[I,h]=(0,r.useState)(!1),[y,N]=(0,r.useState)(null),[V,x]=(0,r.useState)(null),{trackedSeries:k}=w.context,{SeriesDate:M,SeriesDescription:T,SeriesInstanceUID:U,SeriesNumber:R}=b,{PatientID:O,PatientName:A,PatientSex:C,PatientAge:P,SliceThickness:_,SpacingBetweenSlices:j,StudyDate:F,ManufacturerModelName:L}=b.images[0],W=(0,r.useCallback)((()=>{const e=v.getCornerstoneViewport(n);if(e instanceof m.BaseVolumeViewport){const t=e?.getCurrentImageId();if(!t)return void(I&&h(!1))}k.includes(U)!==I&&h(!I)}),[I,w,n,U]),q=(0,r.useCallback)((e=>{e.detail.element!==V&&(e.detail.element?.addEventListener(m.Enums.Events.VOLUME_VIEWPORT_NEW_VOLUME,W),x(e.detail.element))}),[W,V]),G=(0,r.useCallback)((()=>{V?.removeEventListener(m.Enums.Events.VOLUME_VIEWPORT_NEW_VOLUME,W)}),[W,V]);(0,r.useEffect)(W,[W]),(0,r.useEffect)((()=>{const{unsubscribe:e}=v.subscribe(v.EVENTS.VIEWPORT_DATA_CHANGED,(e=>{e.viewportId===n&&W()}));return()=>{e()}}),[W,n]),(0,r.useEffect)((()=>I?(c.annotation.config.style.setViewportToolStyles(n,{global:{lineDash:""}}),void v.getRenderingEngine().renderViewport(n)):(c.annotation.config.style.setViewportToolStyles(n,{global:{lineDash:"4,4"}}),v.getRenderingEngine().renderViewport(n),()=>{c.annotation.config.style.setViewportToolStyles(n,{})})),[I]),(0,r.useEffect)((()=>{const e=S.EVENTS.MEASUREMENT_ADDED,t=S.EVENTS.RAW_MEASUREMENT_ADDED,r=[];return[e,t].forEach((e=>{r.push(S.subscribe(e,(e=>{let{source:t,measurement:r}=e;const{activeViewportId:s}=g.getState();if(n===s){const{referenceStudyUID:e,referenceSeriesUID:t}=r;D("SET_DIRTY",{SeriesInstanceUID:t}),D("TRACK_SERIES",{viewportId:n,StudyInstanceUID:e,SeriesInstanceUID:t})}})).unsubscribe)})),()=>{r.forEach((e=>{e()}))}}),[S,D,n,g]);return r.createElement(r.Fragment,null,r.createElement(o.uY,{onDoubleClick:e=>{e.stopPropagation(),e.preventDefault()},useAltStyling:I,onArrowsClick:e=>function(e){const t=function(e,t,n,r){const{measurementService:s,viewportGridService:a}=t.services,i=s.getMeasurements(),{activeViewportId:o,viewports:l}=a.getState(),{displaySetInstanceUIDs:c}=l.get(o),{trackedSeries:u}=r.context,m=i.filter((e=>u.includes(e.referenceSeriesUID)&&c.includes(e.displaySetInstanceUID)));if(!m.length)return;const d=m.length,p=m.map((e=>e.uid));let E=p.findIndex((e=>e===n));return-1===E?E=0:"left"===e?(E--,E<0&&(E=d-1)):"right"===e&&(E++,E===d&&(E=0)),p[E]}(e,a,y,w);t&&(N(t),S.jumpToMeasurement(n,t))}(e),getStatusComponent:()=>function(e){const t=e?"status-tracked":"status-untracked";return r.createElement("div",{className:"relative"},r.createElement(o.u,{position:"bottom-left",content:r.createElement("div",{className:"flex py-2"},r.createElement("div",{className:"flex pt-1"},r.createElement(o.JO,{name:"info-link",className:"text-primary-main w-4"})),r.createElement("div",{className:"ml-4 flex"},r.createElement("span",{className:"text-common-light text-base"},e?r.createElement(r.Fragment,null,"Series is",r.createElement("span",{className:"font-bold text-white"}," tracked")," and can be viewed ",r.createElement("br",null)," ","in the measurement panel"):r.createElement(r.Fragment,null,"Measurements for",r.createElement("span",{className:"font-bold text-white"}," untracked "),"series ",r.createElement("br",null)," will not be shown in the ",r.createElement("br",null)," measurements panel"))))},r.createElement(o.JO,{name:t,className:"text-aqua-pale"})))}(I),studyData:{label:s,studyDate:p(M)||p(F)||f("NoStudyDate"),currentSeries:R,seriesDescription:T,patientInformation:{patientName:A?i.default.utils.formatPN(A):"",patientSex:C||"",patientAge:P||"",MRN:O||"",thickness:_?`${parseFloat(_).toFixed(2)}`:"",thicknessUnits:"mm",spacing:void 0!==j?`${parseFloat(j).toFixed(2)}mm`:"",scanner:L||""}}}),r.createElement("div",{className:"relative flex h-full w-full flex-row overflow-hidden"},(()=>{const{component:t}=E.getModuleEntry("@ohif/extension-cornerstone.viewportModule.cornerstone");return r.createElement(t,d({},e,{onElementEnabled:q,onElementDisabled:G}))})()))}E.propTypes={displaySets:a().arrayOf(a().object.isRequired).isRequired,viewportId:a().string.isRequired,dataSource:a().object,children:a().node,customProps:a().object},E.defaultProps={customProps:{}};const f=E}}]);
//# sourceMappingURL=822.bundle.c7db86db8d8ed49ef794.js.map