!function(e){"use strict";var t="addImage_",r=["jpeg","jpg","png"],n=function(e){var t=this.internal.newObject(),r=this.internal.write,a=this.internal.putStream;if(e.n=t,r("<>"),"trns"in e&&e.trns.constructor==Array){for(var i="",o=0,s=e.trns.length;s>o;o++)i+=e.trns[o]+" "+e.trns[o]+" ";r("/Mask ["+i+"]")}if("smask"in e&&r("/SMask "+(t+1)+" 0 R"),r("/Length "+e.data.length+">>"),a(e.data),r("endobj"),"smask"in e){var c="/Predictor "+e.p+" /Colors 1 /BitsPerComponent "+e.bpc+" /Columns "+e.w,h={w:e.w,h:e.h,cs:"DeviceGray",bpc:e.bpc,dp:c,data:e.smask};"f"in e&&(h.f=e.f),n.call(this,h)}e.cs===this.color_spaces.INDEXED&&(this.internal.newObject(),r("<< /Length "+e.pal.length+">>"),a(this.arrayBufferToBinaryString(new Uint8Array(e.pal))),r("endobj"))},a=function(){var e=this.internal.collections[t+"images"];for(var r in e)n.call(this,e[r])},i=function(){var e,r=this.internal.collections[t+"images"],n=this.internal.write;for(var a in r)e=r[a],n("/I"+e.i,e.n,"0","R")},o=function(t){return t&&"string"==typeof t&&(t=t.toUpperCase()),t in e.image_compression?t:e.image_compression.NONE},s=function(){var e=this.internal.collections[t+"images"];return e||(this.internal.collections[t+"images"]=e={},this.internal.events.subscribe("putResources",a),this.internal.events.subscribe("putXobjectDict",i)),e},c=function(e){var t=0;return e&&(t=Object.keys?Object.keys(e).length:function(e){var t=0;for(var r in e)e.hasOwnProperty(r)&&t++;return t}(e)),t},h=function(e){return"undefined"==typeof e||null===e},f=function(t){return"string"==typeof t&&e.sHashCode(t)},d=function(e){return-1===r.indexOf(e)},u=function(t){return"function"!=typeof e["process"+t.toUpperCase()]},l=function(e){return"object"==typeof e&&1===e.nodeType},p=function(e,t,r){if("IMG"===e.nodeName&&e.hasAttribute("src")){var n=""+e.getAttribute("src");if(!r&&0===n.indexOf("data:image/"))return n;!t&&/\.png(?:[?#].*)?$/i.test(n)&&(t="png")}if("CANVAS"===e.nodeName)var a=e;else{var a=document.createElement("canvas");a.width=e.clientWidth||e.width,a.height=e.clientHeight||e.height;var i=a.getContext("2d");if(!i)throw"addImage requires canvas to be supported by browser.";if(r){var o,s,c,h,f,d,u,l,p=Math.PI/180;"object"==typeof r&&(o=r.x,s=r.y,c=r.bg,r=r.angle),l=r*p,h=Math.abs(Math.cos(l)),f=Math.abs(Math.sin(l)),d=a.width,u=a.height,a.width=u*f+d*h,a.height=u*h+d*f,isNaN(o)&&(o=a.width/2),isNaN(s)&&(s=a.height/2),i.clearRect(0,0,a.width,a.height),i.fillStyle=c||"white",i.fillRect(0,0,a.width,a.height),i.save(),i.translate(o,s),i.rotate(l),i.drawImage(e,-(d/2),-(u/2)),i.rotate(-l),i.translate(-o,-s),i.restore()}else i.drawImage(e,0,0,a.width,a.height)}return a.toDataURL("png"==(""+t).toLowerCase()?"image/png":"image/jpeg")},C=function(e,t){var r;if(t)for(var n in t)if(e===t[n].alias){r=t[n];break}return r},g=function(e,t,r){return e||t||(e=-96,t=-96),0>e&&(e=-1*r.w*72/e/this.internal.scaleFactor),0>t&&(t=-1*r.h*72/t/this.internal.scaleFactor),0===e&&(e=t*r.w/r.h),0===t&&(t=e*r.h/r.w),[e,t]},A=function(e,t,r,n,a,i,o){var s=g.call(this,r,n,a),c=this.internal.getCoordinateString,h=this.internal.getVerticalCoordinateString;r=s[0],n=s[1],o[i]=a,this.internal.write("q",c(r),"0 0",c(n),c(e),h(t+n),"cm /I"+a.i,"Do Q")};e.color_spaces={DEVICE_RGB:"DeviceRGB",DEVICE_GRAY:"DeviceGray",DEVICE_CMYK:"DeviceCMYK",CAL_GREY:"CalGray",CAL_RGB:"CalRGB",LAB:"Lab",ICC_BASED:"ICCBased",INDEXED:"Indexed",PATTERN:"Pattern",SEPARATION:"Separation",DEVICE_N:"DeviceN"},e.decode={DCT_DECODE:"DCTDecode",FLATE_DECODE:"FlateDecode",LZW_DECODE:"LZWDecode",JPX_DECODE:"JPXDecode",JBIG2_DECODE:"JBIG2Decode",ASCII85_DECODE:"ASCII85Decode",ASCII_HEX_DECODE:"ASCIIHexDecode",RUN_LENGTH_DECODE:"RunLengthDecode",CCITT_FAX_DECODE:"CCITTFaxDecode"},e.image_compression={NONE:"NONE",FAST:"FAST",MEDIUM:"MEDIUM",SLOW:"SLOW"},e.sHashCode=function(e){return Array.prototype.reduce&&e.split("").reduce(function(e,t){return e=(e<<5)-e+t.charCodeAt(0),e&e},0)},e.isString=function(e){return"string"==typeof e},e.extractInfoFromBase64DataURI=function(e){return/^data:([\w]+?\/([\w]+?));base64,(.+?)$/g.exec(e)},e.supportsArrayBuffer=function(){return"undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array},e.isArrayBuffer=function(e){return this.supportsArrayBuffer()?e instanceof ArrayBuffer:!1},e.isArrayBufferView=function(e){return this.supportsArrayBuffer()?"undefined"==typeof Uint32Array?!1:e instanceof Int8Array||e instanceof Uint8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array:!1},e.binaryStringToUint8Array=function(e){for(var t=e.length,r=new Uint8Array(t),n=0;t>n;n++)r[n]=e.charCodeAt(n);return r},e.arrayBufferToBinaryString=function(e){this.isArrayBuffer(e)&&(e=new Uint8Array(e));for(var t="",r=e.byteLength,n=0;r>n;n++)t+=String.fromCharCode(e[n]);return t},e.arrayBufferToBase64=function(e){for(var t,r,n,a,i,o="",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=new Uint8Array(e),h=c.byteLength,f=h%3,d=h-f,u=0;d>u;u+=3)i=c[u]<<16|c[u+1]<<8|c[u+2],t=(16515072&i)>>18,r=(258048&i)>>12,n=(4032&i)>>6,a=63&i,o+=s[t]+s[r]+s[n]+s[a];return 1==f?(i=c[d],t=(252&i)>>2,r=(3&i)<<4,o+=s[t]+s[r]+"=="):2==f&&(i=c[d]<<8|c[d+1],t=(64512&i)>>10,r=(1008&i)>>4,n=(15&i)<<2,o+=s[t]+s[r]+s[n]+"="),o},e.createImageInfo=function(e,t,r,n,a,i,o,s,c,h,f,d,u){var l={alias:s,w:t,h:r,cs:n,bpc:a,i:o,data:e};return i&&(l.f=i),c&&(l.dp=c),h&&(l.trns=h),f&&(l.pal=f),d&&(l.smask=d),u&&(l.p=u),l},e.addImage=function(e,t,n,a,i,g,y,D,E){if("string"!=typeof t){var m=g;g=i,i=a,a=n,n=t,t=m}if("object"==typeof e&&!l(e)&&"imageData"in e){var w=e;e=w.imageData,t=w.format||t,n=w.x||n||0,a=w.y||a||0,i=w.w||i,g=w.h||g,y=w.alias||y,D=w.compression||D,E=w.rotation||w.angle||E}if(isNaN(n)||isNaN(a))throw console.error("jsPDF.addImage: Invalid coordinates",arguments),new Error("Invalid coordinates passed to jsPDF.addImage");var I,v=s.call(this);if(!(I=C(e,v))){var b;if(l(e)&&(e=p(e,t,E)),h(y)&&(y=f(e)),!(I=C(y,v))){if(this.isString(e)){var B=this.extractInfoFromBase64DataURI(e);B?(t=B[2],e=atob(B[3])):137===e.charCodeAt(0)&&80===e.charCodeAt(1)&&78===e.charCodeAt(2)&&71===e.charCodeAt(3)&&(t="png")}if(t=(t||"JPEG").toLowerCase(),d(t))throw new Error("addImage currently only supports formats "+r+", not '"+t+"'");if(u(t))throw new Error("please ensure that the plugin for '"+t+"' support is added");if(this.supportsArrayBuffer()&&(e instanceof Uint8Array||(b=e,e=this.binaryStringToUint8Array(e))),I=this["process"+t.toUpperCase()](e,c(v),y,o(D),b),!I)throw new Error("An unkwown error occurred whilst processing the image")}}return A.call(this,n,a,i,g,I,I.i,v),this};var y=function(e){var t,r,n;if(255===!e.charCodeAt(0)||216===!e.charCodeAt(1)||255===!e.charCodeAt(2)||224===!e.charCodeAt(3)||!e.charCodeAt(6)==="J".charCodeAt(0)||!e.charCodeAt(7)==="F".charCodeAt(0)||!e.charCodeAt(8)==="I".charCodeAt(0)||!e.charCodeAt(9)==="F".charCodeAt(0)||0===!e.charCodeAt(10))throw new Error("getJpegSize requires a binary string jpeg file");for(var a=256*e.charCodeAt(4)+e.charCodeAt(5),i=4,o=e.length;o>i;){if(i+=a,255!==e.charCodeAt(i))throw new Error("getJpegSize could not find the size of the image");if(192===e.charCodeAt(i+1)||193===e.charCodeAt(i+1)||194===e.charCodeAt(i+1)||195===e.charCodeAt(i+1)||196===e.charCodeAt(i+1)||197===e.charCodeAt(i+1)||198===e.charCodeAt(i+1)||199===e.charCodeAt(i+1))return r=256*e.charCodeAt(i+5)+e.charCodeAt(i+6),t=256*e.charCodeAt(i+7)+e.charCodeAt(i+8),n=e.charCodeAt(i+9),[t,r,n];i+=2,a=256*e.charCodeAt(i)+e.charCodeAt(i+1)}},D=function(e){var t=e[0]<<8|e[1];if(65496!==t)throw new Error("Supplied data is not a JPEG");for(var r,n,a,i,o=e.length,s=(e[4]<<8)+e[5],c=4;o>c;){if(c+=s,r=E(e,c),s=(r[2]<<8)+r[3],(192===r[1]||194===r[1])&&255===r[0]&&s>7)return r=E(e,c+5),n=(r[2]<<8)+r[3],a=(r[0]<<8)+r[1],i=r[4],{width:n,height:a,numcomponents:i};c+=2}throw new Error("getJpegSizeFromBytes could not find the size of the image")},E=function(e,t){return e.subarray(t,t+5)};e.processJPEG=function(e,t,r,n,a){var i,o=this.color_spaces.DEVICE_RGB,s=this.decode.DCT_DECODE,c=8;return this.isString(e)?(i=y(e),this.createImageInfo(e,i[0],i[1],1==i[3]?this.color_spaces.DEVICE_GRAY:o,c,s,t,r)):(this.isArrayBuffer(e)&&(e=new Uint8Array(e)),this.isArrayBufferView(e)?(i=D(e),e=a||this.arrayBufferToBinaryString(e),this.createImageInfo(e,i.width,i.height,1==i.numcomponents?this.color_spaces.DEVICE_GRAY:o,c,s,t,r)):null)},e.processJPG=function(){return this.processJPEG.apply(this,arguments)}}(jsPDF.API);