2 lines
27 KiB
JavaScript
2 lines
27 KiB
JavaScript
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[604],{97604:(e,t,r)=>{function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(a=n.key,i=void 0,"symbol"==typeof(i=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(a,"string"))?i:String(i)),n)}var a,i}function i(e){for(var t=new Uint8Array(e.length),r=0,n=e.length;r<n;r++)t[r]=e.charCodeAt(r);return t}function s(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(r+t.length>e.length)return!1;for(var n=r,a=0;a<t.length;a++){if(t[a]!==e[n])return!1;n+=1}return!0}function o(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3?arguments[3]:void 0,a=e.length;n&&(a=Math.min(r+n,e.length));for(var i=r;i<a;i++)if(e[i]===t[0]&&s(e,t,i))return i;return-1}function c(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return"".concat(e()+e(),"-").concat(e(),"-").concat(e(),"-").concat(e(),"-").concat(e()).concat(e()).concat(e())}(),r="Content-Type: ".concat(arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/dicom"),n="\r\n--".concat(t,"\r\n").concat(r,"\r\n\r\n"),a="\r\n--".concat(t,"--"),s=i(n),o=i(a),c=s.length,u=o.length,d=0,l=e.map((function(e){var t=new Uint8Array(e),r=t.length;return d+=c+r+u,t})),p=new Uint8Array(d);p.set(s,0);var f=0;return l.forEach((function(e){p.set(s,f),p.set(e,f+c),f+=c+e.length})),p.set(o,f),{data:p.buffer,boundary:t}}function u(e){var t=new Uint8Array(e),r=i("\r\n\r\n"),n=o(t,r,0,1e3);if(-1===n)throw new Error("Response message has no multipart mime header");var a=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(arguments.length>2?arguments[2]:void 0)||e.length-t,n="",a=t;a<t+r;a++)n+=String.fromCharCode(e[a]);return n}(t,0,n),s=function(e){for(var t=e.split("\r\n"),r=0;r<t.length;r++)if("--"===t[r].substr(0,2))return t[r];return null}(a);if(!s)throw new Error("Header of response message does not specify boundary");for(var c,u=i(s),d=u.length,l=[],p=d;-1!==c&&-1!==(c=o(t,u,p));){var f=o(t,r,p,1e3);if(-1===f)throw new Error("Response message part has no mime header");p=f+r.length;var h=e.slice(p,c-2);l.push(h),p=c+d}return l}function d(e){return"object"===n(e)&&null!==e}function l(e){return 0===Object.keys(e).length&&e.constructor===Object}r.d(t,{api:()=>m});var p=function(e){return e[0]},f="application/dicom",h="application/dicom+json",v="application/octet-stream",y="application/pdf";var m={DICOMwebClient:function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.baseURL=t.url,this.baseURL||console.error("no DICOMweb base url provided - calls that require a URL will fail"),"username"in t&&(this.username=t.username,"password"in t||console.error("no password provided to authenticate with DICOMweb service"),this.password=t.password),"qidoURLPrefix"in t?(console.log("use URL prefix for QIDO-RS: ".concat(t.qidoURLPrefix)),this.qidoURL="".concat(this.baseURL,"/").concat(t.qidoURLPrefix)):this.qidoURL=this.baseURL,"wadoURLPrefix"in t?(console.log("use URL prefix for WADO-RS: ".concat(t.wadoURLPrefix)),this.wadoURL="".concat(this.baseURL,"/").concat(t.wadoURLPrefix)):this.wadoURL=this.baseURL,"stowURLPrefix"in t?(console.log("use URL prefix for STOW-RS: ".concat(t.stowURLPrefix)),this.stowURL="".concat(this.baseURL,"/").concat(t.stowURLPrefix)):this.stowURL=this.baseURL,"requestHooks"in t&&(this.requestHooks=t.requestHooks),this.headers=t.headers||{},this.errorInterceptor=t.errorInterceptor||function(){},this.verbose=!1!==t.verbose}var t,r,i;return t=e,r=[{key:"setVerbose",value:function(e){this.verbose=e}},{key:"getVerbose",value:function(){return this.verbose}},{key:"_httpRequest",value:function(e,t){var r=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},s=this.errorInterceptor,o=this.requestHooks;return new Promise((function(c,u){var d=i.request?i.request:new XMLHttpRequest;d.open(t,e,!0),"responseType"in i&&(d.responseType=i.responseType),"object"===n(a)&&Object.keys(a).forEach((function(e){d.setRequestHeader(e,a[e])}));var l,p=r.headers;if(Object.keys(p).forEach((function(e){d.setRequestHeader(e,p[e])})),d.onloadstart=function(){},d.onloadend=function(){},d.onreadystatechange=function(){if(4===d.readyState)if(200===d.status)c(d.response);else if(202===d.status)r.verbose&&console.warn("some resources already existed: ",d),c(d.response);else if(204===d.status)r.verbose&&console.warn("empty response for request: ",d),c([]);else{var e=new Error("request failed");e.request=d,e.response=d.response,e.status=d.status,r.verbose&&(console.error("request failed: ",d),console.error(e),console.error(e.response)),s(e),u(e)}},"progressCallback"in i&&"function"==typeof i.progressCallback&&(d.onprogress=i.progressCallback),o&&function(e){var t=Array.isArray(e)&&e.every((function(e){return"function"==typeof e&&2===e.length}));return t||console.warn("Request hooks should have the following signature: function requestHook(request, metadata) { return request; }"),t}(o)){var f=Object.assign({},a,r.headers),h={method:t,url:e,headers:f},v=(l=o,function(e){return l.reduce((function(e,t){return t(e,h)}),e)});d=v(d)}"withCredentials"in i&&i.withCredentials&&(d.withCredentials=!0),"data"in i?d.send(i.data):d.send()}))}},{key:"_httpGet",value:function(e,t,r,n,a){return this._httpRequest(e,"get",t,{responseType:r,progressCallback:n,withCredentials:a})}},{key:"_httpGetApplicationJson",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,s=t;"object"===n(r)&&(l(r)||(s+=e._parseQueryParameters(r)));var o={Accept:h};return this._httpGet(s,o,"json",a,i)}},{key:"_httpGetApplicationPdf",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,s=t;"object"===n(r)&&(l(r)||(s+=e._parseQueryParameters(r)));var o={Accept:y};return this._httpGet(s,o,"json",a,i)}},{key:"_httpGetImage",value:function(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0,o=t;"object"===n(a)&&(l(a)||(o+=e._parseQueryParameters(a)));var c={Accept:e._buildAcceptHeaderFieldValue(r,["image/","image/*","image/jpeg","image/jp2","image/gif","image/png"])};return this._httpGet(o,c,"arraybuffer",i,s)}},{key:"_httpGetText",value:function(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0,o=t;"object"===n(a)&&(l(a)||(o+=e._parseQueryParameters(a)));var c={Accept:e._buildAcceptHeaderFieldValue(r,["text/","text/*","text/html","text/plain","text/rtf","text/xml"])};return this._httpGet(o,c,"arraybuffer",i,s)}},{key:"_httpGetVideo",value:function(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0,o=t;"object"===n(a)&&(l(a)||(o+=e._parseQueryParameters(a)));var c={Accept:e._buildAcceptHeaderFieldValue(r,["video/","video/*","video/mpeg","video/mp4","video/H265"])};return this._httpGet(o,c,"arraybuffer",i,s)}},{key:"_httpGetMultipartImage",value:function(t,r,n,a){var i,s=arguments.length>5?arguments[5]:void 0,o=arguments.length>6?arguments[6]:void 0,c={};return arguments.length>4&&void 0!==arguments[4]&&arguments[4]?i=["image/jpeg","image/gif","image/png","image/jp2"]:(i={"1.2.840.10008.1.2.5":["image/x-dicom-rle"],"1.2.840.10008.1.2.4.50":["image/jpeg"],"1.2.840.10008.1.2.4.51":["image/jpeg"],"1.2.840.10008.1.2.4.57":["image/jpeg"],"1.2.840.10008.1.2.4.70":["image/jpeg"],"1.2.840.10008.1.2.4.80":["image/x-jls","image/jls"],"1.2.840.10008.1.2.4.81":["image/x-jls","image/jls"],"1.2.840.10008.1.2.4.90":["image/jp2"],"1.2.840.10008.1.2.4.91":["image/jp2"],"1.2.840.10008.1.2.4.92":["image/jpx"],"1.2.840.10008.1.2.4.93":["image/jpx"]},n&&(c.Range=e._buildRangeHeaderFieldValue(n))),c.Accept=e._buildMultipartAcceptHeaderFieldValue(r,i),this._httpGet(t,c,"arraybuffer",s,o).then(u)}},{key:"_httpGetMultipartVideo",value:function(t,r,n,a){var i,s=arguments.length>5?arguments[5]:void 0,o=arguments.length>6?arguments[6]:void 0,c={};return arguments.length>4&&void 0!==arguments[4]&&arguments[4]?i=["video/","video/*","video/mpeg2","video/mp4","video/H265"]:(i={"1.2.840.10008.1.2.4.100":["video/mpeg2"],"1.2.840.10008.1.2.4.101":["video/mpeg2"],"1.2.840.10008.1.2.4.102":["video/mp4"],"1.2.840.10008.1.2.4.103":["video/mp4"],"1.2.840.10008.1.2.4.104":["video/mp4"],"1.2.840.10008.1.2.4.105":["video/mp4"],"1.2.840.10008.1.2.4.106":["video/mp4"]},n&&(c.Range=e._buildRangeHeaderFieldValue(n))),c.Accept=e._buildMultipartAcceptHeaderFieldValue(r,i),this._httpGet(t,c,"arraybuffer",s,o).then(u)}},{key:"_httpGetMultipartApplicationDicom",value:function(t,r,n,a,i){var s={},o="application/dicom",c={"1.2.840.10008.1.2.1":[o],"1.2.840.10008.1.2.5":[o],"1.2.840.10008.1.2.4.50":[o],"1.2.840.10008.1.2.4.51":[o],"1.2.840.10008.1.2.4.57":[o],"1.2.840.10008.1.2.4.70":[o],"1.2.840.10008.1.2.4.80":[o],"1.2.840.10008.1.2.4.81":[o],"1.2.840.10008.1.2.4.90":[o],"1.2.840.10008.1.2.4.91":[o],"1.2.840.10008.1.2.4.92":[o],"1.2.840.10008.1.2.4.93":[o],"1.2.840.10008.1.2.4.100":[o],"1.2.840.10008.1.2.4.101":[o],"1.2.840.10008.1.2.4.102":[o],"1.2.840.10008.1.2.4.103":[o],"1.2.840.10008.1.2.4.104":[o],"1.2.840.10008.1.2.4.105":[o],"1.2.840.10008.1.2.4.106":[o]},d=r;return r||(d=[{mediaType:o}]),s.Accept=e._buildMultipartAcceptHeaderFieldValue(d,c),this._httpGet(t,s,"arraybuffer",a,i).then(u)}},{key:"_httpGetMultipartApplicationOctetStream",value:function(t,r,n,a,i,s){var o={},c="application/octet-stream",d={"1.2.840.10008.1.2.1":[c]},l=r;return r||(l=[{mediaType:c}]),n&&(o.Range=e._buildRangeHeaderFieldValue(n)),o.Accept=e._buildMultipartAcceptHeaderFieldValue(l,d),this._httpGet(t,o,"arraybuffer",i,s).then(u)}},{key:"_httpPost",value:function(e,t,r,n,a,i){return this._httpRequest(e,"post",t,{data:r,progressCallback:n,withCredentials:a,request:i})}},{key:"_httpPostApplicationJson",value:function(e,t,r,n){var a={"Content-Type":h};return this._httpPost(e,a,t,r,n)}},{key:"searchForStudies",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};console.log("search for studies");var r=!1,n="".concat(this.qidoURL,"/studies");return"queryParams"in t&&(n+=e._parseQueryParameters(t.queryParams)),"withCredentials"in t&&t.withCredentials&&(r=t.withCredentials),this._httpGetApplicationJson(n,{},!1,r)}},{key:"retrieveStudyMetadata",value:function(e){if(!("studyInstanceUID"in e))throw new Error("Study Instance UID is required for retrieval of study metadata");console.log("retrieve metadata of study ".concat(e.studyInstanceUID));var t="".concat(this.wadoURL,"/studies/").concat(e.studyInstanceUID,"/metadata"),r=!1;return"withCredentials"in e&&e.withCredentials&&(r=e.withCredentials),this._httpGetApplicationJson(t,{},!1,r)}},{key:"searchForSeries",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=this.qidoURL;"studyInstanceUID"in t&&(console.log("search series of study ".concat(t.studyInstanceUID)),r+="/studies/".concat(t.studyInstanceUID)),r+="/series","queryParams"in t&&(r+=e._parseQueryParameters(t.queryParams));var n=!1;return"withCredentials"in t&&t.withCredentials&&(n=t.withCredentials),this._httpGetApplicationJson(r,{},!1,n)}},{key:"retrieveSeriesMetadata",value:function(e){if(!("studyInstanceUID"in e))throw new Error("Study Instance UID is required for retrieval of series metadata");if(!("seriesInstanceUID"in e))throw new Error("Series Instance UID is required for retrieval of series metadata");console.log("retrieve metadata of series ".concat(e.seriesInstanceUID));var t="".concat(this.wadoURL,"/studies/").concat(e.studyInstanceUID,"/series/").concat(e.seriesInstanceUID,"/metadata"),r=!1;return"withCredentials"in e&&e.withCredentials&&(r=e.withCredentials),this._httpGetApplicationJson(t,{},!1,r)}},{key:"searchForInstances",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=this.qidoURL,n=!1;return"studyInstanceUID"in t?(r+="/studies/".concat(t.studyInstanceUID),"seriesInstanceUID"in t?(console.log("search for instances of series ".concat(t.seriesInstanceUID)),r+="/series/".concat(t.seriesInstanceUID)):console.log("search for instances of study ".concat(t.studyInstanceUID))):console.log("search for instances"),r+="/instances","queryParams"in t&&(r+=e._parseQueryParameters(t.queryParams)),"withCredentials"in t&&t.withCredentials&&(n=t.withCredentials),this._httpGetApplicationJson(r,{},!1,n)}},{key:"buildInstanceWadoURIUrl",value:function(e){if(!("studyInstanceUID"in e))throw new Error("Study Instance UID is required.");if(!("seriesInstanceUID"in e))throw new Error("Series Instance UID is required.");if(!("sopInstanceUID"in e))throw new Error("SOP Instance UID is required.");var t=e.contentType||f,r=e.transferSyntax||"*",n=[];n.push("requestType=WADO"),n.push("studyUID=".concat(e.studyInstanceUID)),n.push("seriesUID=".concat(e.seriesInstanceUID)),n.push("objectUID=".concat(e.sopInstanceUID)),n.push("contentType=".concat(t)),n.push("transferSyntax=".concat(r));var a=n.join("&");return"".concat(this.wadoURL,"?").concat(a)}},{key:"retrieveInstanceMetadata",value:function(e){if(!("studyInstanceUID"in e))throw new Error("Study Instance UID is required for retrieval of instance metadata");if(!("seriesInstanceUID"in e))throw new Error("Series Instance UID is required for retrieval of instance metadata");if(!("sopInstanceUID"in e))throw new Error("SOP Instance UID is required for retrieval of instance metadata");console.log("retrieve metadata of instance ".concat(e.sopInstanceUID));var t="".concat(this.wadoURL,"/studies/").concat(e.studyInstanceUID,"/series/").concat(e.seriesInstanceUID,"/instances/").concat(e.sopInstanceUID,"/metadata"),r=!1;return"withCredentials"in e&&e.withCredentials&&(r=e.withCredentials),this._httpGetApplicationJson(t,{},!1,r)}},{key:"retrieveInstanceFrames",value:function(t){if(!("studyInstanceUID"in t))throw new Error("Study Instance UID is required for retrieval of instance frames");if(!("seriesInstanceUID"in t))throw new Error("Series Instance UID is required for retrieval of instance frames");if(!("sopInstanceUID"in t))throw new Error("SOP Instance UID is required for retrieval of instance frames");if(!("frameNumbers"in t))throw new Error("frame numbers are required for retrieval of instance frames");console.log("retrieve frames ".concat(t.frameNumbers.toString()," of instance ").concat(t.sopInstanceUID));var r="".concat(this.wadoURL,"/studies/").concat(t.studyInstanceUID,"/series/").concat(t.seriesInstanceUID,"/instances/").concat(t.sopInstanceUID,"/frames/").concat(t.frameNumbers.toString()),n=t.mediaTypes,a=!1;"withCredentials"in t&&t.withCredentials&&(a=t.withCredentials);var i=!1;if("progressCallback"in t&&(i=t.progressCallback),!n)return this._httpGetMultipartApplicationOctetStream(r,!1,!1,!1,i,a);if(e._getSharedMediaTypes(n).length>1){var s={Accept:e._buildMultipartAcceptHeaderFieldValue(n,{"1.2.840.10008.1.2.1":["application/octet-stream"],"1.2.840.10008.1.2.5":["image/x-dicom-rle"],"1.2.840.10008.1.2.4.50":["image/jpeg"],"1.2.840.10008.1.2.4.51":["image/jpeg"],"1.2.840.10008.1.2.4.57":["image/jpeg"],"1.2.840.10008.1.2.4.70":["image/jpeg"],"1.2.840.10008.1.2.4.80":["image/x-jls","image/jls"],"1.2.840.10008.1.2.4.81":["image/x-jls","image/jls"],"1.2.840.10008.1.2.4.90":["image/jp2"],"1.2.840.10008.1.2.4.91":["image/jp2"],"1.2.840.10008.1.2.4.92":["image/jpx"],"1.2.840.10008.1.2.4.93":["image/jpx"]})};return this._httpGet(r,s,"arraybuffer",i,a).then(u)}var o=e._getCommonMediaType(n);if(o.startsWith("application"))return this._httpGetMultipartApplicationOctetStream(r,n,!1,!1,i,a);if(o.startsWith("image"))return this._httpGetMultipartImage(r,n,!1,!1,!1,i,a);if(o.startsWith("video"))return this._httpGetMultipartVideo(r,n,!1,!1,!1,i,a);throw new Error("Media type ".concat(o," is not supported for retrieval of frames."))}},{key:"retrieveInstanceRendered",value:function(t){if(!("studyInstanceUID"in t))throw new Error("Study Instance UID is required for retrieval of rendered instance");if(!("seriesInstanceUID"in t))throw new Error("Series Instance UID is required for retrieval of rendered instance");if(!("sopInstanceUID"in t))throw new Error("SOP Instance UID is required for retrieval of rendered instance");var r="".concat(this.wadoURL,"/studies/").concat(t.studyInstanceUID,"/series/").concat(t.seriesInstanceUID,"/instances/").concat(t.sopInstanceUID,"/rendered"),n=t.mediaTypes,a=t.queryParams,i=!1;"withCredentials"in t&&t.withCredentials&&(i=t.withCredentials);var s=!1;if("progressCallback"in t&&(s=t.progressCallback),!n)return a&&(r+=e._parseQueryParameters(a)),this._httpGet(r,{},"arraybuffer",s,i);var o=e._getCommonMediaType(n);if(o.startsWith("image"))return this._httpGetImage(r,n,a,s,i);if(o.startsWith("video"))return this._httpGetVideo(r,n,a,s,i);if(o.startsWith("text"))return this._httpGetText(r,n,a,s,i);if(o===y)return this._httpGetApplicationPdf(r,a,s,i);throw new Error("Media type ".concat(o," is not supported ")+"for retrieval of rendered instance.")}},{key:"retrieveInstanceThumbnail",value:function(t){if(!("studyInstanceUID"in t))throw new Error("Study Instance UID is required for retrieval of rendered instance");if(!("seriesInstanceUID"in t))throw new Error("Series Instance UID is required for retrieval of rendered instance");if(!("sopInstanceUID"in t))throw new Error("SOP Instance UID is required for retrieval of rendered instance");var r="".concat(this.wadoURL,"/studies/").concat(t.studyInstanceUID,"/series/").concat(t.seriesInstanceUID,"/instances/").concat(t.sopInstanceUID,"/thumbnail"),n=t.mediaTypes,a=t.queryParams,i=!1;"withCredentials"in t&&t.withCredentials&&(i=t.withCredentials);var s=!1;if("progressCallback"in t&&(s=t.progressCallback),!n)return a&&(r+=e._parseQueryParameters(a)),this._httpGet(r,{},"arraybuffer",s,i);var o=e._getCommonMediaType(n);if(o.startsWith("image"))return this._httpGetImage(r,n,a,s,i);throw new Error("Media type ".concat(o," is not supported ")+"for retrieval of rendered instance.")}},{key:"retrieveInstanceFramesRendered",value:function(t){if(!("studyInstanceUID"in t))throw new Error("Study Instance UID is required for retrieval of rendered instance frames");if(!("seriesInstanceUID"in t))throw new Error("Series Instance UID is required for retrieval of rendered instance frames");if(!("sopInstanceUID"in t))throw new Error("SOP Instance UID is required for retrieval of rendered instance frames");if(!("frameNumbers"in t))throw new Error("frame numbers are required for retrieval of rendered instance frames");console.debug("retrieve rendered frames ".concat(t.frameNumbers.toString()," of instance ").concat(t.sopInstanceUID));var r="".concat(this.wadoURL,"/studies/").concat(t.studyInstanceUID,"/series/").concat(t.seriesInstanceUID,"/instances/").concat(t.sopInstanceUID,"/frames/").concat(t.frameNumbers.toString(),"/rendered"),n=t.mediaTypes,a=t.queryParams,i=!1;"withCredentials"in t&&t.withCredentials&&(i=t.withCredentials);var s=!1;if("progressCallback"in t&&(s=t.progressCallback),!n)return a&&(r+=e._parseQueryParameters(a)),this._httpGet(r,{},"arraybuffer",!1,i);var o=e._getCommonMediaType(n);if(o.startsWith("image"))return this._httpGetImage(r,n,a,s,i);if(o.startsWith("video"))return this._httpGetVideo(r,n,a,s,i);throw new Error("Media type ".concat(o," is not supported ")+"for retrieval of rendered frame.")}},{key:"retrieveInstanceFramesThumbnail",value:function(t){if(!("studyInstanceUID"in t))throw new Error("Study Instance UID is required for retrieval of rendered instance frames");if(!("seriesInstanceUID"in t))throw new Error("Series Instance UID is required for retrieval of rendered instance frames");if(!("sopInstanceUID"in t))throw new Error("SOP Instance UID is required for retrieval of rendered instance frames");if(!("frameNumbers"in t))throw new Error("frame numbers are required for retrieval of rendered instance frames");console.debug("retrieve rendered frames ".concat(t.frameNumbers.toString()," of instance ").concat(t.sopInstanceUID));var r="".concat(this.wadoURL,"/studies/").concat(t.studyInstanceUID,"/series/").concat(t.seriesInstanceUID,"/instances/").concat(t.sopInstanceUID,"/frames/").concat(t.frameNumbers.toString(),"/thumbnail"),n=t.mediaTypes,a=t.queryParams,i=!1;"withCredentials"in t&&t.withCredentials&&(i=t.withCredentials);var s=!1;if("progressCallback"in t&&(s=t.progressCallback),!n)return a&&(r+=e._parseQueryParameters(a)),this._httpGet(r,{},"arraybuffer",s,i);var o=e._getCommonMediaType(n);if(o.startsWith("image"))return this._httpGetImage(r,n,a,s,i);throw new Error("Media type ".concat(o," is not supported ")+"for retrieval of rendered frame.")}},{key:"retrieveInstance",value:function(t){if(!("studyInstanceUID"in t))throw new Error("Study Instance UID is required");if(!("seriesInstanceUID"in t))throw new Error("Series Instance UID is required");if(!("sopInstanceUID"in t))throw new Error("SOP Instance UID is required");var r="".concat(this.wadoURL,"/studies/").concat(t.studyInstanceUID,"/series/").concat(t.seriesInstanceUID,"/instances/").concat(t.sopInstanceUID),n=t.mediaTypes,a=t.withCredentials,i=void 0!==a&&a,s=t.progressCallback,o=void 0!==s&&s;if(!n)return this._httpGetMultipartApplicationDicom(r,!1,!1,o,i).then(p);var c=e._getCommonMediaType(n);if(c===f)return this._httpGetMultipartApplicationDicom(r,n,!1,o,i).then(p);throw new Error("Media type ".concat(c," is not supported for retrieval of instance."))}},{key:"retrieveSeries",value:function(t){if(!("studyInstanceUID"in t))throw new Error("Study Instance UID is required");if(!("seriesInstanceUID"in t))throw new Error("Series Instance UID is required");var r="".concat(this.wadoURL,"/studies/").concat(t.studyInstanceUID,"/series/").concat(t.seriesInstanceUID),n=t.mediaTypes,a=!1;"withCredentials"in t&&t.withCredentials&&(a=t.withCredentials);var i=!1;if("progressCallback"in t&&(i=t.progressCallback),!n)return this._httpGetMultipartApplicationDicom(r,!1,!1,i,a);var s=e._getCommonMediaType(n);if(s===f)return this._httpGetMultipartApplicationDicom(r,n,!1,i,a);throw new Error("Media type ".concat(s," is not supported for retrieval of series."))}},{key:"retrieveStudy",value:function(t){if(!("studyInstanceUID"in t))throw new Error("Study Instance UID is required");var r="".concat(this.wadoURL,"/studies/").concat(t.studyInstanceUID),n=t.mediaTypes,a=t.withCredentials,i=void 0!==a&&a,s=t.progressCallback,o=void 0!==s&&s;if(!n)return this._httpGetMultipartApplicationDicom(r,!1,!1,o,i);var c=e._getCommonMediaType(n);if(c===f)return this._httpGetMultipartApplicationDicom(r,n,!1,o,i);throw new Error("Media type ".concat(c," is not supported for retrieval of study."))}},{key:"retrieveBulkData",value:function(t){if(!("BulkDataURI"in t))throw new Error("BulkDataURI is required.");var r=t.BulkDataURI,n=t.mediaTypes,a=t.byteRange,i=t.withCredentials,s=void 0!==i&&i,o=t.progressCallback,c=void 0!==o&&o;if(!n)return this._httpGetMultipartApplicationOctetStream(r,n,a,!1,!1,s);var u=e._getCommonMediaType(n);if(u===v)return this._httpGetMultipartApplicationOctetStream(r,n,a,!1,c,s);if(u.startsWith("image"))return this._httpGetMultipartImage(r,n,a,!1,!1,c,s);throw new Error("Media type ".concat(u," is not supported for retrieval of bulk data."))}},{key:"storeInstances",value:function(e){if(!("datasets"in e))throw new Error("datasets are required for storing");var t="".concat(this.stowURL,"/studies");"studyInstanceUID"in e&&(t+="/".concat(e.studyInstanceUID));var r=c(e.datasets),n=r.data,a=r.boundary,i={"Content-Type":'multipart/related; type="application/dicom"; boundary="'.concat(a,'"')},s=e.withCredentials,o=void 0!==s&&s;return this._httpPost(t,i,n,e.progressCallback,o,e.request)}}],i=[{key:"_parseQueryParameters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="?";return Object.keys(e).forEach((function(r,n){0!==n&&(t+="&"),t+="".concat(r,"=").concat(encodeURIComponent(e[r]))})),t}},{key:"_assertMediaTypeIsValid",value:function(e){if(!e)throw new Error("Not a valid media type: ".concat(e));var t=e.indexOf("/");if(-1===t)throw new Error("Not a valid media type: ".concat(e));var r=e.slice(0,t);if(!["application","image","text","video"].includes(r))throw new Error("Not a valid media type: ".concat(e));if(e.slice(t+1).includes("/"))throw new Error("Not a valid media type: ".concat(e))}},{key:"_parseMediaType",value:function(t){return e._assertMediaTypeIsValid(t),t.split("/")}},{key:"_buildAcceptHeaderFieldValue",value:function(t,r){if(!Array.isArray(t))throw new Error("Acceptable media types must be provided as an Array");return t.map((function(t){var n=t.mediaType;if(e._assertMediaTypeIsValid(n),!r.includes(n))throw new Error("Media type ".concat(n," is not supported for requested resource"));return n})).join(", ")}},{key:"_buildMultipartAcceptHeaderFieldValue",value:function(t,r){if(!Array.isArray(t))throw new Error("Acceptable media types must be provided as an Array");if(!Array.isArray(r)&&!d(r))throw new Error("Supported media types must be provided as an Array or an Object");var n=[];return t.forEach((function(t){var a=t.transferSyntaxUID,i=t.mediaType;e._assertMediaTypeIsValid(i);var s='multipart/related; type="'.concat(i,'"');if(d(r)){if(!(Object.values(r).flat(1).includes(i)||i.endsWith("/*")&&i.endsWith("/")))throw new Error("Media type ".concat(i," is not supported for requested resource"));if(a){if("*"!==a){if(!Object.keys(r).includes(a))throw new Error("Transfer syntax ".concat(a," is not supported for requested resource"));var o=r[a];if(!o.includes(i)){var c=e._parseMediaType(i)[0];o.map((function(t){var r=e._parseMediaType(t)[0];if(c!==r||!i.endsWith("/*")&&!i.endsWith("/"))throw new Error("Transfer syntax ".concat(a," is not supported for requested resource"))}))}}s+="; transfer-syntax=".concat(a)}}else if(Array.isArray(r)&&!r.includes(i))throw new Error("Media type ".concat(i," is not supported for requested resource"));n.push(s)})),n.join(", ")}},{key:"_buildRangeHeaderFieldValue",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return 1===e.length?"bytes=".concat(e[0],"-"):2===e.length?"bytes=".concat(e[0],"-").concat(e[1]):"bytes=0-"}},{key:"_getSharedMediaTypes",value:function(t){var r=new Set;return t&&t.length?(t.forEach((function(t){var n=t.mediaType,a=e._parseMediaType(n)[0];r.add("".concat(a,"/"))})),Array.from(r)):r}},{key:"_getCommonMediaType",value:function(t){if(!t||!t.length)throw new Error("No acceptable media types provided");var r=e._getSharedMediaTypes(t);if(0===r.length)throw new Error("No common acceptable media type could be identified.");if(r.length>1)throw new Error("Acceptable media types must have the same type.");return r[0]}}],r&&a(t.prototype,r),i&&a(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}()}}}]);
|
|
//# sourceMappingURL=604.bundle.9477bed4d89c962cb3df.js.map
|