!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./jquery.svg"),require("./jquery.svgfilter"),require("jquery")):"function"==typeof define&&define.amd?define(["./jquery.svg","./jquery.svgfilter","jquery"],e):"object"==typeof exports?exports.EMFJS=e(require("./jquery.svg"),require("./jquery.svgfilter"),require("jquery")):t.EMFJS=e(t.$,t.$,t.$)}(this,function(t,e,r){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var s=e[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,r),s.l=!0,s.exports}return r.m=t,r.c=e,r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)r.d(i,s,function(e){return t[e]}.bind(null,s));return i},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";r.r(e);r(1),r(2);var i=r(3);r.d(e,"Renderer",function(){return i.Renderer});var s=r(6);r.d(e,"Error",function(){return s.EMFJSError}),r.d(e,"loggingEnabled",function(){return s.loggingEnabled})},function(e,r){e.exports=t},function(t,r){t.exports=e},function(t,e,r){"use strict";r.r(e),r.d(e,"Renderer",function(){return a}),r.d(e,"EMF",function(){return h});var i=r(4),s=r(5),n=r(7),o=r(12),l=r(6),a=function(){function t(t){this.parse(t),l.Helper.log("EMFJS.Renderer instantiated")}return t.prototype.render=function(t){var e=this,r=i("
").svg({onLoad:function(r){return e._render(r,t.mapMode,t.wExt,t.hExt,t.xExt,t.yExt)},settings:{viewBox:[0,0,t.xExt,t.yExt].join(" "),preserveAspectRatio:"none"}}),s=i(r[0]).svg("get");return i(s.root()).attr("width",t.width).attr("height",t.height)},t.prototype.parse=function(t){this._img=null;var e=new s.Blob(t);if(1!==e.readUint32())throw new l.EMFJSError("Not an EMF file");var r=e.readUint32();if(r%4!=0)throw new l.EMFJSError("Not an EMF file");if(this._img=new h(e,r),null==this._img)throw new l.EMFJSError("Format not recognized")},t.prototype._render=function(t,e,r,i,s,n){var a=new o.GDIContext(t);a.setWindowExtEx(r,i),a.setViewportExtEx(s,n),a.setMapMode(e),l.Helper.log("[EMF] BEGIN RENDERING ---\x3e"),this._img.render(a),l.Helper.log("[EMF] <--- DONE RENDERING")},t}(),h=function(){function t(t,e){this._hdrsize=e,this._records=new n.EMFRecords(t,this._hdrsize)}return t.prototype.render=function(t){this._records.play(t)},t}()},function(t,e){t.exports=r},function(t,e,r){"use strict";r.r(e),r.d(e,"Blob",function(){return s});var i=r(6),s=function(){function t(e,r){e instanceof t?(this.blob=e.blob,this.data=e.data,this.pos=r||e.pos):(this.blob=e,this.data=new Uint8Array(e),this.pos=r||0)}return t.prototype.eof=function(){return this.pos>=this.data.length},t.prototype.seek=function(t){if(t<0||t>this.data.length)throw new i.EMFJSError("Invalid seek position");this.pos=t},t.prototype.skip=function(t){var e=this.pos+t;if(e>this.data.length)throw new i.EMFJSError("Unexpected end of file");this.pos=e},t.prototype.readBinary=function(t){if(this.pos+t>this.data.length)throw new i.EMFJSError("Unexpected end of file");for(var e="";t-- >0;)e+=String.fromCharCode(this.data[this.pos++]);return e},t.prototype.readInt8=function(){if(this.pos+1>this.data.length)throw new i.EMFJSError("Unexpected end of file");return this.data[this.pos++]},t.prototype.readUint8=function(){return this.readInt8()>>>0},t.prototype.readInt32=function(){if(this.pos+4>this.data.length)throw new i.EMFJSError("Unexpected end of file");var t=this.data[this.pos++];return t|=this.data[this.pos++]<<8,t|=this.data[this.pos++]<<16,t|=this.data[this.pos++]<<24},t.prototype.readUint32=function(){return this.readInt32()>>>0},t.prototype.readUint16=function(){if(this.pos+2>this.data.length)throw new i.EMFJSError("Unexpected end of file");var t=this.data[this.pos++];return t|=this.data[this.pos++]<<8},t.prototype.readInt16=function(){var t=this.readUint16();return t>32767&&(t-=65536),t},t.prototype.readString=function(t){if(this.pos+t>this.data.length)throw new i.EMFJSError("Unexpected end of file");for(var e="",r=0;r>>0);return e},t.prototype.readNullTermString=function(t){var e="";if(t>0){t--;for(var r=0;rthis.data.length)throw new i.EMFJSError("Unexpected end of file");var s=this.data[this.pos+r]>>>0;if(0===s)break;e+=String.fromCharCode(s)}}return e},t.prototype.readFixedSizeUnicodeString=function(t){for(var e="",r=0;r>>8&255,t[e++]=r>>>16&255,t[e++]=r>>>24&255},t._blobToBinary=function(t){for(var e="",r=t.length,i=0;i0){if(o<88)throw new i.EMFJSError("Invalid header description offset");if((l=o+2*n)>e)throw new i.EMFJSError("Invalid header description length");var a=t.pos;t.seek(r+o),this.description=t.readFixedSizeUnicodeString(n),t.seek(a)}else this.description="";if(l>=100){var h=t.readUint32(),c=t.readUint32();if(0!==t.readUint32())throw new i.EMFJSError("OpenGL records are not yet supported");if(0!==c){if(c<100||ce)throw new i.EMFJSError("Invalid pixel format size")}l>=108&&(this.displayDevCxUm=t.readUint32(),this.displayDevCyUm=t.readUint32())}}return t.prototype.toString=function(){return"{bounds: "+this.bounds.toString()+", frame: "+this.frame.toString()+", description: "+this.description+"}"},t}(),a=function(){function t(t,e){this._records=[],this._header=new l(t,e);var r=!1,a=e,h=function(){t.seek(a);var e=t.readUint32(),l=t.readUint32();if(l<8)throw new i.EMFJSError("Invalid record size");switch(e){case i.Helper.GDI.RecordType.EMR_EOF:return r=!0,"break-main_loop";case i.Helper.GDI.RecordType.EMR_SETMAPMODE:var h=t.readInt32();c._records.push(function(t){t.setMapMode(h)});break;case i.Helper.GDI.RecordType.EMR_SETWINDOWORGEX:var p=t.readInt32(),E=t.readInt32();c._records.push(function(t){t.setWindowOrgEx(p,E)});break;case i.Helper.GDI.RecordType.EMR_SETWINDOWEXTEX:var u=t.readUint32(),d=t.readUint32();c._records.push(function(t){t.setWindowExtEx(u,d)});break;case i.Helper.GDI.RecordType.EMR_SETVIEWPORTORGEX:var R=t.readInt32(),_=t.readInt32();c._records.push(function(t){t.setViewportOrgEx(R,_)});break;case i.Helper.GDI.RecordType.EMR_SETVIEWPORTEXTEX:var T=t.readUint32(),f=t.readUint32();c._records.push(function(t){t.setViewportExtEx(T,f)});break;case i.Helper.GDI.RecordType.EMR_SAVEDC:c._records.push(function(t){t.saveDC()});break;case i.Helper.GDI.RecordType.EMR_RESTOREDC:var g=t.readInt32();c._records.push(function(t){t.restoreDC(g)});break;case i.Helper.GDI.RecordType.EMR_SETBKMODE:var y=t.readUint32();c._records.push(function(t){t.setBkMode(y)});break;case i.Helper.GDI.RecordType.EMR_SETBKCOLOR:var S=new o.ColorRef(t);c._records.push(function(t){t.setBkColor(S)});break;case i.Helper.GDI.RecordType.EMR_CREATEBRUSHINDIRECT:var I=t.readUint32(),M=new o.Brush(t);c._records.push(function(t){t.createBrush(I,M)});break;case i.Helper.GDI.RecordType.EMR_CREATEPEN:var O=t.readUint32(),v=new o.Pen(t,null);c._records.push(function(t){t.createPen(O,v)});break;case i.Helper.GDI.RecordType.EMR_EXTCREATEPEN:var P=t.readUint32(),D=t.readUint32(),H=t.readUint32(),b=t.readUint32(),L=t.readUint32(),w=new o.Pen(t,{header:{off:D,size:H},data:{off:b,size:L}});c._records.push(function(t){t.createPen(P,w)});break;case i.Helper.GDI.RecordType.EMR_SELECTOBJECT:var A=t.readUint32();c._records.push(function(t){t.selectObject(A,null)});break;case i.Helper.GDI.RecordType.EMR_DELETEOBJECT:var C=t.readUint32();c._records.push(function(t){t.deleteObject(C)});break;case i.Helper.GDI.RecordType.EMR_RECTANGLE:var G=new s.RectL(t);c._records.push(function(t){t.rectangle(G,0,0)});break;case i.Helper.GDI.RecordType.EMR_ROUNDRECT:var N=new s.RectL(t),m=new s.SizeL(t);c._records.push(function(t){t.rectangle(N,m.cx,m.cy)});break;case i.Helper.GDI.RecordType.EMR_LINETO:var x=t.readInt32(),B=t.readInt32();c._records.push(function(t){t.lineTo(x,B)});break;case i.Helper.GDI.RecordType.EMR_MOVETOEX:var U=t.readInt32(),F=t.readInt32();c._records.push(function(t){t.moveToEx(U,F)});break;case i.Helper.GDI.RecordType.EMR_POLYGON:case i.Helper.GDI.RecordType.EMR_POLYGON16:for(var k=e===i.Helper.GDI.RecordType.EMR_POLYGON16,X=new s.RectL(t),Y=t.readUint32(),j=[];Y>0;)j.push(k?new s.PointS(t):new s.PointL(t)),Y--;c._records.push(function(t){t.polygon(j,X,!0)});break;case i.Helper.GDI.RecordType.EMR_POLYPOLYGON:case i.Helper.GDI.RecordType.EMR_POLYPOLYGON16:k=e===i.Helper.GDI.RecordType.EMR_POLYPOLYGON16;var W=new s.RectL(t),J=t.readUint32();t.skip(4);for(var z=[],V=0;V0;)rt.push(new s.PointS(t)),Y--;c._records.push(function(t){t.polyline(tt,rt,et)});break;case i.Helper.GDI.RecordType.EMR_POLYBEZIER:case i.Helper.GDI.RecordType.EMR_POLYBEZIERTO:for(var it=e===i.Helper.GDI.RecordType.EMR_POLYBEZIERTO,st=new s.RectL(t),nt=(Y=t.readUint32(),[]);Y>0;)nt.push(new s.PointL(t)),Y--;c._records.push(function(t){t.polybezier(it,nt,st)});break;case i.Helper.GDI.RecordType.EMR_POLYBEZIER16:for(var ot=new s.RectL(t),lt=new s.PointL(t),at=(Y=t.readUint32(),[lt]);Y>0;)at.push(new s.PointS(t)),Y--;c._records.push(function(t){t.polybezier(!1,at,ot)});break;case i.Helper.GDI.RecordType.EMR_POLYBEZIERTO16:for(var ht=new s.RectL(t),ct=(Y=t.readUint32(),[]);Y>0;)ct.push(new s.PointS(t)),Y--;c._records.push(function(t){t.polybezier(!0,ct,ht)});break;case i.Helper.GDI.RecordType.EMR_SETTEXTALIGN:var pt=t.readUint32();c._records.push(function(t){t.setTextAlign(pt)});break;case i.Helper.GDI.RecordType.EMR_SETSTRETCHBLTMODE:var Et=t.readUint32();c._records.push(function(t){t.setStretchBltMode(Et)});break;case i.Helper.GDI.RecordType.EMR_SETBRUSHORGEX:var ut=new s.PointL(t);c._records.push(function(t){t.setBrushOrgEx(ut)});break;case i.Helper.GDI.RecordType.EMR_BEGINPATH:c._records.push(function(t){t.beginPath()});break;case i.Helper.GDI.RecordType.EMR_ENDPATH:c._records.push(function(t){t.endPath()});break;case i.Helper.GDI.RecordType.EMR_ABORTPATH:c._records.push(function(t){t.abortPath()});break;case i.Helper.GDI.RecordType.EMR_CLOSEFIGURE:c._records.push(function(t){t.closeFigure()});break;case i.Helper.GDI.RecordType.EMR_FILLPATH:var dt=new s.RectL(t);c._records.push(function(t){t.fillPath(dt)});break;case i.Helper.GDI.RecordType.EMR_STROKEPATH:var Rt=new s.RectL(t);c._records.push(function(t){t.strokePath(Rt)});break;case i.Helper.GDI.RecordType.EMR_SELECTCLIPPATH:var _t=t.readUint32();c._records.push(function(t){t.selectClipPath(_t)});break;case i.Helper.GDI.RecordType.EMR_EXTSELECTCLIPRGN:t.skip(4);var Tt=t.readUint32(),ft=Tt!==i.Helper.GDI.RegionMode.RGN_COPY?new n.Region(t):null;c._records.push(function(t){t.selectClipRgn(Tt,ft)});break;case i.Helper.GDI.RecordType.EMR_OFFSETCLIPRGN:var gt=new s.PointL(t);c._records.push(function(t){t.offsetClipRgn(gt)});break;case i.Helper.GDI.RecordType.EMR_SETMITERLIMIT:var yt=t.readUint32();c._records.push(function(t){t.setMiterLimit(yt)});break;case i.Helper.GDI.RecordType.EMR_POLYLINE:case i.Helper.GDI.RecordType.EMR_POLYLINETO:case i.Helper.GDI.RecordType.EMR_POLYPOLYLINE:case i.Helper.GDI.RecordType.EMR_SETPIXELV:case i.Helper.GDI.RecordType.EMR_SETMAPPERFLAGS:case i.Helper.GDI.RecordType.EMR_SETROP2:case i.Helper.GDI.RecordType.EMR_SETCOLORADJUSTMENT:case i.Helper.GDI.RecordType.EMR_SETTEXTCOLOR:case i.Helper.GDI.RecordType.EMR_SETMETARGN:case i.Helper.GDI.RecordType.EMR_EXCLUDECLIPRECT:case i.Helper.GDI.RecordType.EMR_INTERSECTCLIPRECT:case i.Helper.GDI.RecordType.EMR_SCALEVIEWPORTEXTEX:case i.Helper.GDI.RecordType.EMR_SCALEWINDOWEXTEX:case i.Helper.GDI.RecordType.EMR_SETWORLDTRANSFORM:case i.Helper.GDI.RecordType.EMR_MODIFYWORLDTRANSFORM:case i.Helper.GDI.RecordType.EMR_ANGLEARC:case i.Helper.GDI.RecordType.EMR_ELLIPSE:case i.Helper.GDI.RecordType.EMR_ARC:case i.Helper.GDI.RecordType.EMR_CHORD:case i.Helper.GDI.RecordType.EMR_PIE:case i.Helper.GDI.RecordType.EMR_SELECTPALETTE:case i.Helper.GDI.RecordType.EMR_CREATEPALETTE:case i.Helper.GDI.RecordType.EMR_SETPALETTEENTRIES:case i.Helper.GDI.RecordType.EMR_RESIZEPALETTE:case i.Helper.GDI.RecordType.EMR_REALIZEPALETTE:case i.Helper.GDI.RecordType.EMR_EXTFLOODFILL:case i.Helper.GDI.RecordType.EMR_ARCTO:case i.Helper.GDI.RecordType.EMR_POLYDRAW:case i.Helper.GDI.RecordType.EMR_SETARCDIRECTION:case i.Helper.GDI.RecordType.EMR_STROKEANDFILLPATH:case i.Helper.GDI.RecordType.EMR_FLATTENPATH:case i.Helper.GDI.RecordType.EMR_WIDENPATH:case i.Helper.GDI.RecordType.EMR_COMMENT:case i.Helper.GDI.RecordType.EMR_FILLRGN:case i.Helper.GDI.RecordType.EMR_FRAMERGN:case i.Helper.GDI.RecordType.EMR_INVERTRGN:case i.Helper.GDI.RecordType.EMR_PAINTRGN:case i.Helper.GDI.RecordType.EMR_BITBLT:case i.Helper.GDI.RecordType.EMR_STRETCHBLT:case i.Helper.GDI.RecordType.EMR_MASKBLT:case i.Helper.GDI.RecordType.EMR_PLGBLT:case i.Helper.GDI.RecordType.EMR_SETDIBITSTODEVICE:case i.Helper.GDI.RecordType.EMR_STRETCHDIBITS:case i.Helper.GDI.RecordType.EMR_EXTCREATEFONTINDIRECTW:case i.Helper.GDI.RecordType.EMR_EXTTEXTOUTA:case i.Helper.GDI.RecordType.EMR_EXTTEXTOUTW:case i.Helper.GDI.RecordType.EMR_POLYPOLYLINE16:case i.Helper.GDI.RecordType.EMR_POLYDRAW16:case i.Helper.GDI.RecordType.EMR_CREATEMONOBRUSH:case i.Helper.GDI.RecordType.EMR_CREATEDIBPATTERNBRUSHPT:case i.Helper.GDI.RecordType.EMR_POLYTEXTOUTA:case i.Helper.GDI.RecordType.EMR_POLYTEXTOUTW:case i.Helper.GDI.RecordType.EMR_SETICMMODE:case i.Helper.GDI.RecordType.EMR_CREATECOLORSPACE:case i.Helper.GDI.RecordType.EMR_SETCOLORSPACE:case i.Helper.GDI.RecordType.EMR_DELETECOLORSPACE:case i.Helper.GDI.RecordType.EMR_GLSRECORD:case i.Helper.GDI.RecordType.EMR_GLSBOUNDEDRECORD:case i.Helper.GDI.RecordType.EMR_PIXELFORMAT:case i.Helper.GDI.RecordType.EMR_DRAWESCAPE:case i.Helper.GDI.RecordType.EMR_EXTESCAPE:case i.Helper.GDI.RecordType.EMR_SMALLTEXTOUT:case i.Helper.GDI.RecordType.EMR_FORCEUFIMAPPING:case i.Helper.GDI.RecordType.EMR_NAMEDESCAPE:case i.Helper.GDI.RecordType.EMR_COLORCORRECTPALETTE:case i.Helper.GDI.RecordType.EMR_SETICMPROFILEA:case i.Helper.GDI.RecordType.EMR_SETICMPROFILEW:case i.Helper.GDI.RecordType.EMR_ALPHABLEND:case i.Helper.GDI.RecordType.EMR_SETLAYOUT:case i.Helper.GDI.RecordType.EMR_TRANSPARENTBLT:case i.Helper.GDI.RecordType.EMR_GRADIENTFILL:case i.Helper.GDI.RecordType.EMR_SETLINKEDUFIS:case i.Helper.GDI.RecordType.EMR_SETTEXTJUSTIFICATION:case i.Helper.GDI.RecordType.EMR_COLORMATCHTOTARGETW:case i.Helper.GDI.RecordType.EMR_CREATECOLORSPACEW:default:var St="UNKNOWN";for(var It in i.Helper.GDI.RecordType){if(i.Helper.GDI.RecordType[It]===e){St=It;break}}i.Helper.log("[EMF] "+St+" record (0x"+e.toString(16)+") at offset 0x"+a.toString(16)+" with "+l+" bytes")}a+=l},c=this;t:for(;!r;){switch(h()){case"break-main_loop":break t}}if(!r)throw new i.EMFJSError("Could not read all records")}return t.prototype.play=function(t){for(var e=this._records.length,r=0;r=this.right||this.top>=this.bottom},t.prototype.intersect=function(e){return this.empty()||e.empty()?null:this.left>=e.right||this.top>=e.bottom||this.right<=e.left||this.bottom<=e.top?null:new t(null,Math.max(this.left,e.left),Math.max(this.top,e.top),Math.min(this.right,e.right),Math.min(this.bottom,e.bottom))},t}(),l=function(){function t(t,e,r){null!=t?(this.cx=t.readUint32(),this.cy=t.readUint32()):(this.cx=e,this.cy=r)}return t.prototype.clone=function(){return new t(null,this.cx,this.cy)},t.prototype.toString=function(){return"{cx: "+this.cx+", cy: "+this.cy+"}"},t}(),a=function(){function t(t){this.type=t}return t.prototype.clone=function(){throw new i.EMFJSError("clone not implemented")},t.prototype.toString=function(){throw new i.EMFJSError("toString not implemented")},t}()},function(t,e,r){"use strict";r.r(e),r.d(e,"Region",function(){return o}),r.d(e,"CreateSimpleRegion",function(){return l}),r.d(e,"Scan",function(){return a});var i=r(6),s=r(8),n=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function i(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),o=function(t){function e(e,r){var n=t.call(this,"region")||this;if(null!=e){if(32!==e.readUint32())throw new i.EMFJSError("Invalid region header");e.skip(4);var o=e.readUint32();if(16*o!==e.readUint32())throw new i.EMFJSError("Invalid region data");n.bounds=new s.RectL(e),n.scans=[];for(var l=void 0,h=0;h=t.top){var r=d.clone();d.bottom=t.top-1,r.top=t.top,d.top>=d.bottom?this.scans[e]=r:(i.Helper.log("[emf] Region split top scan "+e+" for substraction"),this.scans.splice(++e,0,r));break}e++}for(var n=e;et.bottom)break;if(d.bottom>t.bottom){r=d.clone();d.bottom=t.bottom,r.top=t.bottom+1,d.top>=d.bottom?this.scans[e]=r:(i.Helper.log("[emf] Region split bottom scan "+e+" for substraction"),this.scans.splice(++e,0,r));break}e++}if(n0){var _=d.scanlines[0];(null==h||_.leftc)&&(c=_.right)}}null!=h&&null!=l&&null!=c&&null!=p?(this.bounds=new s.RectL(null,h,l,c,p),this._updateComplexity()):(this.bounds=null,this.scans=null,this.complexity=0)}else this._updateComplexity()}i.Helper.log("[emf] Region subtraction -> "+this.toString())},e.prototype.intersect=function(t){if(i.Helper.log("[emf] Region "+this.toString()+" intersect with "+t.toString()),null!=this.bounds)if(this.bounds=this.bounds.intersect(t),null!=this.bounds){if(null!=this.scans){for(var e=0;e0&&(i.Helper.log("[emf] Region remove "+e+" scans from top"),this.scans.splice(0,e),this.scans.length>0&&(this.scans[0].top=this.bounds.top)),e=0;ethis.bounds.bottom){i.Helper.log("[emf] Region remove "+(this.scans.length-e)+" scans from bottom"),this.scans.splice(e,this.scans.length-e);break}r.intersect(this.bounds.left,this.bounds.right)?e++:(i.Helper.log("[emf] Region remove now empty scan "+e+" due to intersection"),this.scans.splice(e,1))}this.scans.length>0&&(this.scans[this.scans.length-1].bottom=this.bounds.bottom),this._updateComplexity()}}else this.scans=null,this.complexity=0;i.Helper.log("[emf] Region intersection -> "+this.toString())},e.prototype.offset=function(t,e){if(null!=this.bounds&&(this.bounds.left+=t,this.bounds.top+=e,this.bounds.right+=t,this.bounds.bottom+=e),null!=this.scans)for(var r=this.scans.length,i=0;i=t&&(n.right=t-1,n.left>=n.right)?this.scanlines.splice(r,1):r++}for(var i=r,s=0;re){n.left=e,s=r-i,n.left>=n.right&&s++;break}r++}return s>0&&i0},t.prototype.intersect=function(t,e){for(var r=0;r=t||i.right>=t){r>0&&this.scanlines.splice(0,r);break}}if(this.scanlines.length>0){var i;(i=this.scanlines[0]).lefte){this.scanlines.splice(r,this.scanlines.length-r);break}this.scanlines.length>0&&(i=this.scanlines[this.scanlines.length-1]).right>e&&(i.right=e)}return this.scanlines.length>0},t}()},function(t,e,r){"use strict";r.r(e),r.d(e,"ColorRef",function(){return l}),r.d(e,"Font",function(){return a}),r.d(e,"Brush",function(){return h}),r.d(e,"Pen",function(){return c});var i=r(11),s=r(6),n=r(8),o=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function i(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),l=function(){function t(t,e,r,i){null!=t?(this.r=t.readUint8(),this.g=t.readUint8(),this.b=t.readUint8(),t.skip(1)):(this.r=e,this.g=r,this.b=i)}return t.prototype.clone=function(){return new t(null,this.r,this.g,this.b)},t.prototype.toHex=function(){return(16777216+(this.r<<16|this.g<<8|this.b)).toString(16).slice(1)},t.prototype.toString=function(){return"{r: "+this.r+", g: "+this.g+", b: "+this.b+"}"},t}(),a=function(t){function e(e,r){var i=t.call(this,"font")||this;if(null!=e){i.height=e.readInt32(),i.width=e.readInt32(),i.escapement=e.readInt32(),i.orientation=e.readInt32(),i.weight=e.readInt32(),i.italic=e.readUint8(),i.underline=e.readUint8(),i.strikeout=e.readUint8(),i.charset=e.readUint8(),i.outprecision=e.readUint8(),i.clipprecision=e.readUint8(),i.quality=e.readUint8();var s=e.readUint8();i.pitch=15&s,i.family=s>>6&3;var n=r,o=e.pos;i.facename=e.readFixedSizeUnicodeString(Math.min(n-(e.pos-o),32))}else null!=r?(r=r,i.height=r.height,i.width=r.width,i.escapement=r.escapement,i.orientation=r.orientation,i.weight=r.weight,i.italic=r.italic,i.underline=r.underline,i.strikeout=r.strikeout,i.charset=r.charset,i.outprecision=r.outprecision,i.clipprecision=r.clipprecision,i.quality=r.quality,i.pitch=r.pitch,i.family=r.family,i.facename=r.facename):(i.height=-80,i.width=0,i.escapement=0,i.orientation=0,i.weight=400,i.italic=0,i.underline=0,i.strikeout=0,i.charset=0,i.outprecision=0,i.clipprecision=0,i.quality=0,i.pitch=0,i.family=0,i.facename="Helvetica");return i}return o(e,t),e.prototype.clone=function(){return new e(null,this)},e.prototype.toString=function(){return JSON.stringify(this)},e}(n.Obj),h=function(t){function e(e,r){var n=t.call(this,"brush")||this;if(null!=e){var o=e.pos;switch(n.style=e.readUint32(),n.style){case s.Helper.GDI.BrushStyle.BS_SOLID:n.color=new l(e);break;case s.Helper.GDI.BrushStyle.BS_PATTERN:n.pattern=new i.DIBitmap(e);break;case s.Helper.GDI.BrushStyle.BS_DIBPATTERNPT:n.dibpatternpt=new i.DIBitmap(e);break;case s.Helper.GDI.BrushStyle.BS_HATCHED:n.color=new l(e),n.hatchstyle=e.readUint32()}e.seek(o+12)}else switch(n.style=r.style,n.style){case s.Helper.GDI.BrushStyle.BS_SOLID:n.color=r.color.clone();break;case s.Helper.GDI.BrushStyle.BS_PATTERN:n.pattern=r.pattern;break;case s.Helper.GDI.BrushStyle.BS_DIBPATTERNPT:n.dibpatternpt=r.dibpatternpt;break;case s.Helper.GDI.BrushStyle.BS_HATCHED:n.color=r.color.clone(),n.hatchstyle=r.hatchstyle}return n}return o(e,t),e.prototype.clone=function(){return new e(null,this)},e.prototype.toString=function(){var t="{style: "+this.style;switch(this.style){case s.Helper.GDI.BrushStyle.BS_SOLID:t+=", color: "+this.color.toString();break;case s.Helper.GDI.BrushStyle.BS_HATCHED:t+=", color: "+this.color.toString()+", hatchstyle: "+this.hatchstyle}return t+"}"},e}(n.Obj),c=function(t){function e(e,r,i,s,o){var a=t.call(this,"pen")||this;if(null!=e)if(null!=r){a.style=255&e.readUint32(),a.width=e.readUint32(),a.brush=new h(e),a.color=null!=a.brush.color?a.brush.color.clone():new l(null,0,0,0)}else a.style=255&e.readUint32(),a.width=new n.PointL(e).x,a.color=new l(e);else a.style=r,a.width=i,null!=s&&(a.color=s),null!=o&&(a.brush=o);return a}return o(e,t),e.prototype.clone=function(){return new e(null,this.style,this.width,null!=this.color?this.color.clone():null,null!=this.brush?this.brush.clone():null)},e.prototype.toString=function(){return"{style: "+this.style+", width: "+this.width+", color: "+(null!=this.color?this.color.toString():"none")+"}"},e}(n.Obj)},function(t,e,r){"use strict";r.r(e),r.d(e,"BitmapBase",function(){return n}),r.d(e,"BitmapCoreHeader",function(){return o}),r.d(e,"BitmapInfoHeader",function(){return l}),r.d(e,"BitmapInfo",function(){return a}),r.d(e,"DIBitmap",function(){return h});var i=r(6),s=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function i(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}}(),n=function(){function t(){}return t.prototype.getWidth=function(){throw new i.EMFJSError("getWidth not implemented")},t.prototype.getHeight=function(){throw new i.EMFJSError("getHeight not implemented")},t}(),o=function(){function t(t,e){e&&t.skip(4),this.width=t.readUint16(),this.height=t.readUint16(),this.planes=t.readUint16(),this.bitcount=t.readUint16()}return t.prototype.colors=function(){return this.bitcount<=8?1<8?0:1<1)throw new i.EMFJSError("restoreDC: absolute restore not implemented")}this.state._svggroup=null},t.prototype.setStretchBltMode=function(t){i.Helper.log("[gdi] setStretchBltMode: stretchMode="+t)},t.prototype.rectangle=function(t,e,r){i.Helper.log("[gdi] rectangle: rect="+t.toString()+" with pen "+this.state.selected.pen.toString()+" and brush "+this.state.selected.brush.toString());var s=this._todevY(t.bottom),n=this._todevX(t.right),o=this._todevY(t.top),l=this._todevX(t.left);e=this._todevH(e),r=this._todevH(r),i.Helper.log("[gdi] rectangle: TRANSLATED: bottom="+s+" right="+n+" top="+o+" left="+l+" rh="+r+" rw="+e),this._pushGroup();var a=this._applyOpts(null,!0,!0,!1);this._svg.rect(this.state._svggroup,l,o,n-l,s-o,e/2,r/2,a)},t.prototype.lineTo=function(t,e){i.Helper.log("[gdi] lineTo: x="+t+" y="+e+" with pen "+this.state.selected.pen.toString());var r=this._todevX(t),s=this._todevY(e),n=this._todevX(this.state.x),o=this._todevY(this.state.y);this.state.x=t,this.state.y=e,i.Helper.log("[gdi] lineTo: TRANSLATED: toX="+r+" toY="+s+" fromX="+n+" fromY="+o),this._pushGroup();var l=this._applyOpts(null,!0,!1,!1);this._svg.line(this.state._svggroup,n,o,r,s,l)},t.prototype.moveToEx=function(t,e){i.Helper.log("[gdi] moveToEx: x="+t+" y="+e),this.state.x=t,this.state.y=e,null!=this._svgPath&&(this._svgPath.move(this.state.x,this.state.y),i.Helper.log("[gdi] new path: "+this._svgPath.path()))},t.prototype.polygon=function(t,e,r){i.Helper.log("[gdi] polygon: points="+t+" with pen "+this.state.selected.pen.toString()+" and brush "+this.state.selected.brush.toString());for(var s=[],n=0;n0){var h=e[0];h.x===this.state.x&&h.y===this.state.y||s.unshift([this._todevX(this.state.x),this._todevY(this.state.y)])}this._svg.polyline(this.state._svggroup,s,a)}if(e.length>0){var c=e[e.length-1];this.state.x=c.x,this.state.y=c.y}},t.prototype.polybezier=function(t,e,r){i.Helper.log("[gdi] polybezier: isPolyBezierTo="+t.toString()+", points="+e+", bounds="+r.toString()+" with pen "+this.state.selected.pen.toString());for(var s=[],n=0;n0){var l=s[0];this._svgPath.move(l.x,l.y)}else this._svgPath.move(this._todevX(this.state.x),this._todevY(this.state.y));if(s.length<(t?3:4))throw new i.EMFJSError("Not enough points to draw bezier");for(n=t?1:0;n+3<=s.length;n+=3){var a=s[n],h=s[n+1],c=s[n+2];this._svgPath.curveC(a.x,a.y,h.x,h.y,c.x,c.y)}if(i.Helper.log("[gdi] new path: "+this._svgPath.path()),e.length>0){var p=e[e.length-1];this.state.x=p.x,this.state.y=p.y}},t.prototype.selectClipPath=function(t){i.Helper.log("[gdi] selectClipPath: rgnMode=0x"+t.toString(16))},t.prototype.selectClipRgn=function(t,e){if(i.Helper.log("[gdi] selectClipRgn: rgnMode=0x"+t.toString(16)),t!==i.Helper.GDI.RegionMode.RGN_COPY){if(null==e)throw new i.EMFJSError("No clip region to select");throw new i.EMFJSError("Not implemented: rgnMode=0x"+t.toString(16))}this.state.selected.region=e,this.state.clip=null,this.state.ownclip=!1,this.state._svgclipChanged=!0},t.prototype.offsetClipRgn=function(t){i.Helper.log("[gdi] offsetClipRgn: offset="+t.toString()),this._getClipRgn().offset(t.x,t.y)},t.prototype.setTextAlign=function(t){i.Helper.log("[gdi] setTextAlign: textAlignmentMode=0x"+t.toString(16)),this.state.textalign=t},t.prototype.setMiterLimit=function(t){i.Helper.log("[gdi] setMiterLimit: miterLimit="+t),this.state.miterlimit=t},t.prototype.setBkMode=function(t){i.Helper.log("[gdi] setBkMode: bkMode=0x"+t.toString(16)),this.state.bkmode=t},t.prototype.setBkColor=function(t){i.Helper.log("[gdi] setBkColor: bkColor="+t.toString()),this.state.bkcolor=t,this.state._svgtextbkfilter=null},t.prototype.setPolyFillMode=function(t){i.Helper.log("[gdi] setPolyFillMode: polyFillMode="+t),this.state.polyfillmode=t},t.prototype.createBrush=function(t,e){var r=this._storeObject(e,t);i.Helper.log("[gdi] createBrush: brush="+e.toString()+" with handle "+r)},t.prototype.createPen=function(t,e){var r=this._storeObject(e,t);i.Helper.log("[gdi] createPen: pen="+e.toString()+" width handle "+r)},t.prototype.createPenEx=function(t,e){var r=this._storeObject(e,t);i.Helper.log("[gdi] createPenEx: pen="+e.toString()+" width handle "+r)},t.prototype.selectObject=function(t,e){var r=this._getObject(t);null==r||null!=e&&r.type!==e?i.Helper.log("[gdi] selectObject: objIdx="+t+(r?" invalid object type: "+r.type:"[invalid index]")):(this._selectObject(r),i.Helper.log("[gdi] selectObject: objIdx="+t+(r?" selected "+r.type+": "+r.toString():"[invalid index]")))},t.prototype.abortPath=function(){i.Helper.log("[gdi] abortPath"),null!=this._svgPath&&(this._svgPath=null)},t.prototype.beginPath=function(){i.Helper.log("[gdi] beginPath"),null!=this._svgPath&&(this._svgPath=null),this._svgPath=this._svg.createPath()},t.prototype.closeFigure=function(){if(i.Helper.log("[gdi] closeFigure"),null==this._svgPath)throw new i.EMFJSError("No path bracket: cannot close figure");this._svgPath.close()},t.prototype.fillPath=function(t){if(i.Helper.log("[gdi] fillPath"),null==this.state.selected.path)throw new i.EMFJSError("No path selected");var e=this.state.selected.path,r=this._applyOpts(null,!0,!0,!1);this._svg.path(this.state._svggroup,e.svgPath,r),this._pushGroup(),this.state.selected.path=null},t.prototype.strokePath=function(t){if(i.Helper.log("[gdi] strokePath"),null==this.state.selected.path)throw new i.EMFJSError("No path selected");var e=this.state.selected.path,r=this._applyOpts({fill:"none"},!0,!1,!1);this._svg.path(this.state._svggroup,e.svgPath,r),this._pushGroup(),this.state.selected.path=null},t.prototype.endPath=function(){if(i.Helper.log("[gdi] endPath"),null==this._svgPath)throw new i.EMFJSError("No path bracket: cannot end path");this._pushGroup(),this._selectObject(new a(this._svgPath)),this._svgPath=null},t.prototype.deleteObject=function(t){var e=this._deleteObject(t);i.Helper.log("[gdi] deleteObject: objIdx="+t+(e?" deleted object":"[invalid index]"))},t.prototype._pushGroup=function(){if(null==this.state._svggroup||this.state._svgclipChanged){this.state._svgclipChanged=!1,this.state._svgtextbkfilter=null;var t={viewBox:[this.state.vx,this.state.vy,this.state.vw,this.state.vh].join(" "),preserveAspectRatio:"none"};null!=this.state.clip?(i.Helper.log("[gdi] new svg x="+this.state.vx+" y="+this.state.vy+" width="+this.state.vw+" height="+this.state.vh+" with clipping"),t["clip-path"]="url(#"+this._getSvgClipPathForRegion(this.state.clip)+")"):i.Helper.log("[gdi] new svg x="+this.state.vx+" y="+this.state.vy+" width="+this.state.vw+" height="+this.state.vh+" without clipping"),this.state._svggroup=this._svg.svg(this.state._svggroup,this.state.vx,this.state.vy,this.state.vw,this.state.vh,t)}},t.prototype._getStockObject=function(t){return t>=2147483648&&t<=2147483665?h[(t-2147483648).toString()]:t===i.Helper.GDI.StockObject.DC_BRUSH?this.state.selected.brush:t===i.Helper.GDI.StockObject.DC_PEN?this.state.selected.pen:null},t.prototype._storeObject=function(t,e){if(!e){for(e=0;null!=this.objects[e.toString()]&&e<=65535;)e++;if(e>65535)return i.Helper.log("[gdi] Too many objects!"),-1}return this.objects[e.toString()]=t,e},t.prototype._getObject=function(t){var e=this.objects[t.toString()];return null==e&&null==(e=this._getStockObject(t))&&i.Helper.log("[gdi] No object with handle "+t),e},t.prototype._getSvgDef=function(){return null==this._svgdefs&&(this._svgdefs=this._svg.defs()),this._svgdefs},t.prototype._getSvgClipPathForRegion=function(t){for(var e in this._svgClipPaths){if(this._svgClipPaths[e]===t)return e}var r=i.Helper._makeUniqueId("c"),s=this._svg.clipPath(this._getSvgDef(),r,"userSpaceOnUse");switch(t.complexity){case 1:this._svg.rect(s,this._todevX(t.bounds.left),this._todevY(t.bounds.top),this._todevW(t.bounds.right-t.bounds.left),this._todevH(t.bounds.bottom-t.bounds.top),{fill:"black",strokeWidth:0});break;case 2:for(var n=0;n