/*! cornerstone - v0.5.2 - 2014-11-11 | (c) 2014 Chris Hafey | https://github.com/chafey/cornerstone */ var cornerstone=function(a,b){"use strict";function c(c,d,e){if(void 0===c)throw"displayImage: parameter element cannot be undefined";if(void 0===d)throw"displayImage: parameter image cannot be undefined";var f=b.getEnabledElement(c);if(f.image=d,void 0===f.viewport&&(f.viewport=b.getDefaultViewport(f.canvas,d)),e)for(var g in e)null!==e[g]&&(f.viewport[g]=e[g]);var h,i=new Date;if(void 0!==f.lastImageTimeStamp){var j=i.getTime()-f.lastImageTimeStamp;h=(1e3/j).toFixed()}f.lastImageTimeStamp=i.getTime();var k={viewport:f.viewport,element:f.element,image:f.image,enabledElement:f,frameRate:h};a(f.element).trigger("CornerstoneNewImage",k),b.updateImage(c)}return void 0===b&&(b={}),b.displayImage=c,b}($,cornerstone),cornerstone=function(a,b){"use strict";function c(b,c){var d=new Date;b.image.render(b,c);var e=b.canvas.getContext("2d"),f=new Date,g=f-d,h={viewport:b.viewport,element:b.element,image:b.image,enabledElement:b,canvasContext:e,renderTimeInMs:g};a(b.element).trigger("CornerstoneImageRendered",h)}return void 0===b&&(b={}),b.drawImage=c,b}($,cornerstone),cornerstone=function(a){"use strict";function b(b){if(void 0===b)throw"enable: parameter element cannot be undefined";var c=document.createElement("canvas");b.appendChild(c);var d={element:b,canvas:c,image:void 0,data:{}};return a.addEnabledElement(d),a.resize(b,!0),b}return void 0===a&&(a={}),a.enable=b,a}(cornerstone),cornerstone=function(a){"use strict";function b(b,c){var d=a.getEnabledElement(b);return d.data.hasOwnProperty(c)===!1&&(d.data[c]={}),d.data[c]}function c(b,c){var d=a.getEnabledElement(b);delete d.data[c]}return void 0===a&&(a={}),a.getElementData=b,a.removeElementData=c,a}(cornerstone),cornerstone=function(a){"use strict";function b(a){if(void 0===a)throw"getEnabledElement: parameter element must not be undefined";for(var b=0;b=h;h++)e=h*l+m,f=255*((e-o)/n+.5),g=Math.min(Math.max(f,0),255),i[h+-k]=Math.round(255-g);else for(h=a.minPixelValue;j>=h;h++)e=h*l+m,f=255*((e-o)/n+.5),g=Math.min(Math.max(f,0),255),i[h+-k]=Math.round(g)}return void 0===a&&(a={}),a.generateLut=b,a}(cornerstone),cornerstone=function(a){"use strict";function b(a,b){if(void 0===a)throw"getDefaultViewport: parameter canvas must not be undefined";if(void 0===b)throw"getDefaultViewport: parameter image must not be undefined";var c={scale:1,translation:{x:0,y:0},voi:{windowWidth:b.windowWidth,windowCenter:b.windowCenter},invert:b.invert,pixelReplication:!1},d=a.height/b.rows,e=a.width/b.columns;return c.scale=d>e?e:d,c}return void 0===a&&(a={}),a.getDefaultViewport=b,a}(cornerstone),cornerstone=function(a){"use strict";function b(b,c,d,e,f){if(void 0===b)throw"getStoredPixels: parameter element must not be undefined";c=Math.round(c),d=Math.round(d);for(var g=a.getEnabledElement(b),h=[],i=0,j=g.image.getPixelData(),k=0;f>k;k++)for(var l=0;e>l;l++){var m=(k+d)*g.image.columns+(l+c);h[i++]=j[m]}return h}function c(c,d,e,f,g){var h=b(c,d,e,f,g),i=a.getEnabledElement(c),j=i.image.slope,k=i.image.intercept,l=h.map(function(a){return a*j+k});return l}return void 0===a&&(a={}),a.getStoredPixels=b,a.getPixels=c,a}(cornerstone),cornerstone=function(a){"use strict";function b(a){if(void 0===a)throw"setMaximumSizeBytes: parameter numBytes must not be undefined";if(void 0===a.toFixed)throw"setMaximumSizeBytes: parameter numBytes must be a number";j=a,c()}function c(){function a(a,b){return a.timeStamp>b.timeStamp?-1:a.timeStamp=k))for(i.sort(a);k>j;){var b=i[i.length-1];k-=b.sizeInBytes,delete h[b.imageId],i.pop()}}function d(a,b){if(void 0===a)throw"getImagePromise: imageId must not be undefined";if(void 0===b)throw"getImagePromise: imagePromise must not be undefined";if(h.hasOwnProperty(a)===!0)throw"putImagePromise: imageId already in cache";var d={imageId:a,imagePromise:b,timeStamp:new Date,sizeInBytes:0};h[a]=d,i.push(d),b.then(function(a){if(d.loaded=!0,void 0===a.sizeInBytes)throw"putImagePromise: image does not have sizeInBytes property or";if(void 0===a.sizeInBytes.toFixed)throw"putImagePromise: image.sizeInBytes is not a number";d.sizeInBytes=a.sizeInBytes,k+=d.sizeInBytes,c()})}function e(a){if(void 0===a)throw"getImagePromise: imageId must not be undefined";var b=h[a];return void 0===b?void 0:(b.timeStamp=new Date,b.imagePromise)}function f(){return{maximumSizeInBytes:j,cacheSizeInBytes:k,numberOfImagesCached:i.length}}function g(){var a=j;j=0,c(),j=a}void 0===a&&(a={});var h={},i=[],j=1073741824,k=0;return a.imageCache={putImagePromise:d,getImagePromise:e,setMaximumSizeBytes:b,getCacheInfo:f,purgeCache:g},a}(cornerstone),cornerstone=function(a,b){"use strict";function c(c){var d,e=c.indexOf(":"),f=c.substring(0,e),g=i[f];return void 0===g||null===g?void 0!==h?d=h(c):void 0:(d=g(c),d.then(function(c){a(b).trigger("CornerstoneImageLoaded",{image:c})}),d)}function d(a){if(void 0===a)throw"loadImage: parameter imageId must not be undefined";var d=b.imageCache.getImagePromise(a);if(void 0!==d)return d;if(d=c(a),void 0===d)throw"loadImage: no image loader for imageId";return d}function e(a){if(void 0===a)throw"loadAndCacheImage: parameter imageId must not be undefined";var d=b.imageCache.getImagePromise(a);if(void 0!==d)return d;if(d=c(a),void 0===d)throw"loadAndCacheImage: no image loader for imageId";return b.imageCache.putImagePromise(a,d),d}function f(a,b){i[a]=b}function g(a){var b=h;return h=a,b}void 0===b&&(b={});var h,i={};return b.loadImage=d,b.loadAndCacheImage=e,b.registerImageLoader=f,b.registerUnknownImageLoader=g,b}($,cornerstone),cornerstone=function(a){"use strict";function b(b){var c=a.getEnabledElementsByImageId(b);c.forEach(function(b){a.drawImage(b,!0)})}return void 0===a&&(a={}),a.invalidateImageId=b,a}(cornerstone),cornerstone=function(a){"use strict";function b(b,c,d){var e=a.getEnabledElement(b);if(void 0===e.image)throw"image has not been loaded yet";var f=b.getBoundingClientRect(),g=c-f.left-window.pageXOffset,h=d-f.top-window.pageYOffset,i=g-f.width/2,j=h-f.height/2,k=e.viewport,l=e.viewport.scale,m=e.viewport.scale;e.image.rowPixelSpacinge)for(;h>g;)k[f]=j[i[g++]+-e],f+=4;else for(;h>g;)k[f]=j[i[g++]],f+=4}function c(a,b,c){var d=a.minPixelValue,e=0,f=0,g=a.width*a.height*4,h=a.getPixelData(),i=b,j=c;if(0>d)for(;g>f;)j[e++]=i[h[f++]+-d],j[e++]=i[h[f++]+-d],j[e]=i[h[f]+-d],f+=2,e+=2;else for(;g>f;)j[e++]=i[h[f++]],j[e++]=i[h[f++]],j[e]=i[h[f]],f+=2,e+=2}return void 0===a&&(a={}),a.storedPixelDataToCanvasImageData=b,a.storedColorPixelDataToCanvasImageData=c,a}(cornerstone),cornerstone=function(a){"use strict";function b(b,c){var d=a.getEnabledElement(b);if(void 0===d.image)throw"updateImage: image has not been loaded yet";a.drawImage(d,c)}return void 0===a&&(a={}),a.updateImage=b,a}(cornerstone),cornerstone=function(a){"use strict";function b(b,c){var d=a.getEnabledElement(b);d.viewport.scale=c.scale,d.viewport.translation.x=c.translation.x,d.viewport.translation.y=c.translation.y,d.viewport.voi.windowWidth=c.voi.windowWidth,d.viewport.voi.windowCenter=c.voi.windowCenter,d.viewport.invert=c.invert,d.viewport.pixelReplication=c.pixelReplication,d.viewport.voi.windowWidth<1&&(d.viewport.voi.windowWidth=1),d.viewport.scale<1e-4&&(d.viewport.scale=.25),a.updateImage(b)}function c(b){var c=a.getEnabledElement(b),d=c.viewport;return void 0===d?void 0:{scale:d.scale,translation:{x:d.translation.x,y:d.translation.y},voi:{windowWidth:d.voi.windowWidth,windowCenter:d.voi.windowCenter},invert:d.invert,pixelReplication:d.pixelReplication}}return void 0===a&&(a={}),a.getViewport=c,a.setViewport=b,a}(cornerstone);