!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.EMFJS=e():t.EMFJS=e()}(this,(()=>(()=>{"use strict";var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Error:()=>a,Renderer:()=>x,loggingEnabled:()=>c});var i,s=function(){function t(){}return t.prototype.flood=function(t,e,i,s,n){var o=document.createElementNS("http://www.w3.org/2000/svg","feFlood");e&&o.setAttribute("id",e),o.setAttribute("flood-color",i),o.setAttribute("flood-opacity",s.toString()),t.appendChild(o)},t.prototype.composite=function(t,e,i,s,n,o,r,a,h){var c=document.createElementNS("http://www.w3.org/2000/svg","feComposite");e&&c.setAttribute("id",e),c.setAttribute("in",i),c.setAttribute("in2",s),t.appendChild(c)},t}(),n=function(){function t(){this._path=""}return t.prototype.move=function(t,e){this._path+=" M ".concat(t," ").concat(e)},t.prototype.path=function(){return this._path.substr(1)},t.prototype.line=function(t){var e=this;t.forEach((function(t){e._path+=" L ".concat(t[0]," ").concat(t[1])}))},t.prototype.curveC=function(t,e,i,s,n,o){this._path+=" C ".concat(t," ").concat(e,", ").concat(i," ").concat(s,", ").concat(n," ").concat(o)},t.prototype.close=function(){this._path+=" Z"},t}(),o=function(){function t(t){this.filters=new s,this._defs=void 0,this._svg=t}return t.prototype.svg=function(t,e,i,s,n,o){var r=document.createElementNS("http://www.w3.org/2000/svg","svg");return r.setAttribute("x",e.toString()),r.setAttribute("y",i.toString()),r.setAttribute("width",s.toString()),r.setAttribute("height",n.toString()),this._appendSettings(o,r),null!=t?t.appendChild(r):this._svg.appendChild(r),r},t.prototype.image=function(t,e,i,s,n,o,r){var a=document.createElementNS("http://www.w3.org/2000/svg","image");return a.setAttribute("x",e.toString()),a.setAttribute("y",i.toString()),a.setAttribute("width",s.toString()),a.setAttribute("height",n.toString()),a.setAttributeNS("http://www.w3.org/1999/xlink","href",o),this._appendSettings(r,a),t.appendChild(a),a},t.prototype.rect=function(t,e,i,s,n,o,r,a){var h=document.createElementNS("http://www.w3.org/2000/svg","rect");return h.setAttribute("x",e.toString()),h.setAttribute("y",i.toString()),h.setAttribute("width",s.toString()),h.setAttribute("height",n.toString()),void 0!==o&&(o instanceof Number?h.setAttribute("rx",o.toString()):o instanceof Object&&this._appendSettings(o,h)),void 0!==r&&h.setAttribute("ry",r.toString()),this._appendSettings(a,h),t.appendChild(h),h},t.prototype.line=function(t,e,i,s,n,o){var r=document.createElementNS("http://www.w3.org/2000/svg","line");return r.setAttribute("x1",e.toString()),r.setAttribute("y1",i.toString()),r.setAttribute("x2",s.toString()),r.setAttribute("y2",n.toString()),this._appendSettings(o,r),t.appendChild(r),r},t.prototype.polygon=function(t,e,i){var s=document.createElementNS("http://www.w3.org/2000/svg","polygon");return s.setAttribute("points",e.map((function(t){return t.join(",")})).join(" ")),this._appendSettings(i,s),t.appendChild(s),s},t.prototype.polyline=function(t,e,i){var s=document.createElementNS("http://www.w3.org/2000/svg","polyline");return s.setAttribute("points",e.map((function(t){return t.join(",")})).join(" ")),this._appendSettings(i,s),t.appendChild(s),s},t.prototype.ellipse=function(t,e,i,s,n,o){var r=document.createElementNS("http://www.w3.org/2000/svg","ellipse");return r.setAttribute("cx",e.toString()),r.setAttribute("cy",i.toString()),r.setAttribute("rx",s.toString()),r.setAttribute("ry",n.toString()),this._appendSettings(o,r),t.appendChild(r),r},t.prototype.path=function(t,e,i){var s=document.createElementNS("http://www.w3.org/2000/svg","path");return s.setAttribute("d",e.path()),this._appendSettings(i,s),t.appendChild(s),s},t.prototype.text=function(t,e,i,s,n){var o=document.createElementNS("http://www.w3.org/2000/svg","text");o.setAttribute("x",e.toString()),o.setAttribute("y",i.toString()),this._appendSettings(n,o);var r=document.createTextNode(s);return o.appendChild(r),t.appendChild(o),o},t.prototype.filter=function(t,e,i,s,n,o,r){var a=document.createElementNS("http://www.w3.org/2000/svg","filter");return a.setAttribute("x",i.toString()),a.setAttribute("y",s.toString()),a.setAttribute("width",n.toString()),a.setAttribute("height",o.toString()),this._appendSettings(r,a),t.appendChild(a),a},t.prototype.pattern=function(t,e,i,s,n,o,r){var a=document.createElementNS("http://www.w3.org/2000/svg","pattern");return e&&a.setAttribute("id",e),a.setAttribute("x",i.toString()),a.setAttribute("y",s.toString()),a.setAttribute("width",n.toString()),a.setAttribute("height",o.toString()),this._appendSettings(r,a),t.appendChild(a),a},t.prototype.defs=function(){if(void 0===this._defs){var t=document.createElementNS("http://www.w3.org/2000/svg","defs");this._svg.appendChild(t),this._defs=t}return this._defs},t.prototype.clipPath=function(t,e,i,s){var n=document.createElementNS("http://www.w3.org/2000/svg","clipPath");return e&&n.setAttribute("id",e),void 0===i&&(i="userSpaceOnUse"),n.setAttribute("clipPathUnits",i),this._appendSettings(s,n),t.appendChild(n),n},t.prototype.createPath=function(){return new n},t.prototype._appendSettings=function(t,e){void 0!==t&&Object.keys(t).forEach((function(i){e.setAttribute(i,t[i])}))},t}(),r=(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},i(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function s(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(s.prototype=e.prototype,new s)}),a=function(t){function e(e){var i=this.constructor,s=t.call(this,e)||this;return Object.setPrototypeOf(s,i.prototype),s}return r(e,t),e}(Error),h=!0;function c(t){h=t}var l=function(){function t(){}return t.log=function(t){h&&console.log(t)},t._makeUniqueId=function(t){return"EMFJS_"+t+this._uniqueId++},t._writeUint32Val=function(t,e,i){t[e++]=255&i,t[e++]=i>>>8&255,t[e++]=i>>>16&255,t[e++]=i>>>24&255},t._blobToBinary=function(t){for(var e="",i=t.length,s=0;s=this.data.length},t.prototype.seek=function(t){if(t<0||t>this.data.length)throw new a("Invalid seek position");this.pos=t},t.prototype.skip=function(t){var e=this.pos+t;if(e>this.data.length)throw new a("Unexpected end of file");this.pos=e},t.prototype.readBinary=function(t){if(this.pos+t>this.data.length)throw new a("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 a("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 a("Unexpected end of file");var t=this.data[this.pos++];return t|=this.data[this.pos++]<<8,(t|=this.data[this.pos++]<<16)|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 a("Unexpected end of file");return this.data[this.pos++]|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 a("Unexpected end of file");for(var e="",i=0;i>>0);return e},t.prototype.readNullTermString=function(t){var e="";if(t>0){t--;for(var i=0;ithis.data.length)throw new a("Unexpected end of file");var s=this.data[this.pos+i]>>>0;if(0===s)break;e+=String.fromCharCode(s)}}return e},t.prototype.readFixedSizeUnicodeString=function(t){for(var e="",i=0;i=this.right||this.top>=this.bottom},t.prototype.intersect=function(e){return this.empty()||e.empty()||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}(),_=function(){function t(t,e,i){null!=t?(this.cx=t.readUint32(),this.cy=t.readUint32()):(this.cx=e,this.cy=i)}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}(),R=function(){function t(t){this.type=t}return t.prototype.clone=function(){throw new a("clone not implemented")},t.prototype.toString=function(){throw new a("toString not implemented")},t}(),T=function(){var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},t(e,i)};return function(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function s(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}}(),g=function(t){function e(e,i){var s=t.call(this,"region")||this;if(null!=e){if(32!==e.readUint32())throw new a("Invalid region header");e.skip(4);var n=e.readUint32();if(16*n!==e.readUint32())throw new a("Invalid region data");s.bounds=new d(e),s.scans=[];for(var o=void 0,r=0;r=t.top){var i=E.clone();E.bottom=t.top-1,i.top=t.top,E.top>=E.bottom?this.scans[e]=i:(l.log("[emf] Region split top scan "+e+" for substraction"),this.scans.splice(++e,0,i));break}e++}for(var s=e;et.bottom);){if(E.bottom>t.bottom){i=E.clone(),E.bottom=t.bottom,i.top=t.bottom+1,E.top>=E.bottom?this.scans[e]=i:(l.log("[emf] Region split bottom scan "+e+" for substraction"),this.scans.splice(++e,0,i));break}e++}if(s0){var _=E.scanlines[0];(null==r||_.lefta)&&(a=_.right)}}null!=r&&null!=o&&null!=a&&null!=h?(this.bounds=new d(null,r,o,a,h),this._updateComplexity()):(this.bounds=null,this.scans=null,this.complexity=0)}else this._updateComplexity()}l.log("[emf] Region subtraction -> "+this.toString())},e.prototype.intersect=function(t){if(l.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&&(l.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){l.log("[emf] Region remove "+(this.scans.length-e)+" scans from bottom"),this.scans.splice(e,this.scans.length-e);break}i.intersect(this.bounds.left,this.bounds.right)?e++:(l.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;l.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 i=this.scans.length,s=0;s=t&&(o.right=t-1,o.left>=o.right)?this.scanlines.splice(i,1):i++;for(var s=i,n=0;ie){o.left=e,n=i-s,o.left>=o.right&&n++;break}i++}return n>0&&s0},t.prototype.intersect=function(t,e){for(var i=0;i=t||s.right>=t){i>0&&this.scanlines.splice(0,i);break}if(this.scanlines.length>0){var s;for((s=this.scanlines[0]).lefte){this.scanlines.splice(i,this.scanlines.length-i);break}this.scanlines.length>0&&(s=this.scanlines[this.scanlines.length-1]).right>e&&(s.right=e)}return this.scanlines.length>0},t}(),y=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<>6&3;var o=i,r=e.pos;s.facename=e.readFixedSizeUnicodeString(Math.min(o-(e.pos-r),32))}else null!=i?(i=i,s.height=i.height,s.width=i.width,s.escapement=i.escapement,s.orientation=i.orientation,s.weight=i.weight,s.italic=i.italic,s.underline=i.underline,s.strikeout=i.strikeout,s.charset=i.charset,s.outprecision=i.outprecision,s.clipprecision=i.clipprecision,s.quality=i.quality,s.pitch=i.pitch,s.family=i.family,s.facename=i.facename):(s.height=-80,s.width=0,s.escapement=0,s.orientation=0,s.weight=400,s.italic=0,s.underline=0,s.strikeout=0,s.charset=0,s.outprecision=0,s.clipprecision=0,s.quality=0,s.pitch=0,s.family=0,s.facename="Helvetica");return s}return O(e,t),e.prototype.clone=function(){return new e(null,this)},e.prototype.toString=function(){return JSON.stringify(this)},e}(R),w=function(t){function e(e,i){var s=t.call(this,"brush")||this;if(null!=e){var n=e.pos;switch(s.style=e.readUint32(),s.style){case l.GDI.BrushStyle.BS_SOLID:s.color=new M(e);break;case l.GDI.BrushStyle.BS_PATTERN:s.pattern=new v(e);break;case l.GDI.BrushStyle.BS_DIBPATTERNPT:s.dibpatternpt=new v(e);break;case l.GDI.BrushStyle.BS_HATCHED:s.color=new M(e),s.hatchstyle=e.readUint32()}e.seek(n+12)}else switch(s.style=i.style,s.style){case l.GDI.BrushStyle.BS_SOLID:s.color=i.color.clone();break;case l.GDI.BrushStyle.BS_PATTERN:s.pattern=i.pattern;break;case l.GDI.BrushStyle.BS_DIBPATTERNPT:s.dibpatternpt=i.dibpatternpt;break;case l.GDI.BrushStyle.BS_HATCHED:s.color=i.color.clone(),s.hatchstyle=i.hatchstyle}return s}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 l.GDI.BrushStyle.BS_SOLID:t+=", color: "+this.color.toString();break;case l.GDI.BrushStyle.BS_HATCHED:t+=", color: "+this.color.toString()+", hatchstyle: "+this.hatchstyle}return t+"}"},e}(R),P=function(t){function e(e,i,s,n,o){var r=t.call(this,"pen")||this;return null!=e?null!=i?(r.style=255&e.readUint32(),r.width=e.readUint32(),r.brush=new w(e),r.color=null!=r.brush.color?r.brush.color.clone():new M(null,0,0,0)):(r.style=255&e.readUint32(),r.width=new u(e).x,r.color=new M(e)):(r.style=i,r.width=s,null!=n&&(r.color=n),null!=o&&(r.brush=o)),r}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}(R),D=function(){function t(t,e){var i=t.pos-8;if(this.size=e,this.bounds=new d(t),this.frame=new d(t),t.readUint32()!==l.GDI.FormatSignature.ENHMETA_SIGNATURE)throw new a("Invalid header signature");t.skip(4),t.skip(4),t.skip(4),t.skip(2),t.skip(2);var s=t.readUint32(),n=t.readUint32();this.nPalEntries=t.readUint32(),this.refDevCx=t.readUint32(),this.refDevCy=t.readUint32(),this.refDevCxMm=t.readUint32(),this.refDevCyMm=t.readUint32();var o=e;if(s>0){if(n<88)throw new a("Invalid header description offset");if((o=n+2*s)>e)throw new a("Invalid header description length");var r=t.pos;t.seek(i+n),this.description=t.readFixedSizeUnicodeString(s),t.seek(r)}else this.description="";if(o>=100){var h=t.readUint32(),c=t.readUint32();if(0!==t.readUint32())throw new a("OpenGL records are not yet supported");if(0!==c){if(c<100||ce)throw new a("Invalid pixel format size")}o>=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 D(t,e);var i=!1,s=e,n=function(){t.seek(s);var e=t.readUint32(),n=t.readUint32();if(n<8)throw new a("Invalid record size");switch(e){case l.GDI.RecordType.EMR_EOF:return i=!0,"break-main_loop";case l.GDI.RecordType.EMR_SETMAPMODE:var r=t.readInt32();o._records.push((function(t){t.setMapMode(r)}));break;case l.GDI.RecordType.EMR_SETWINDOWORGEX:var h=t.readInt32(),c=t.readInt32();o._records.push((function(t){t.setWindowOrgEx(h,c)}));break;case l.GDI.RecordType.EMR_SETWINDOWEXTEX:var p=t.readUint32(),R=t.readUint32();o._records.push((function(t){t.setWindowExtEx(p,R)}));break;case l.GDI.RecordType.EMR_SETVIEWPORTORGEX:var T=t.readInt32(),f=t.readInt32();o._records.push((function(t){t.setViewportOrgEx(T,f)}));break;case l.GDI.RecordType.EMR_SETVIEWPORTEXTEX:var y=t.readUint32(),S=t.readUint32();o._records.push((function(t){t.setViewportExtEx(y,S)}));break;case l.GDI.RecordType.EMR_SAVEDC:o._records.push((function(t){t.saveDC()}));break;case l.GDI.RecordType.EMR_RESTOREDC:var I=t.readInt32();o._records.push((function(t){t.restoreDC(I)}));break;case l.GDI.RecordType.EMR_SETBKMODE:var v=t.readUint32();o._records.push((function(t){t.setBkMode(v)}));break;case l.GDI.RecordType.EMR_SETBKCOLOR:var O=new M(t);o._records.push((function(t){t.setBkColor(O)}));break;case l.GDI.RecordType.EMR_CREATEBRUSHINDIRECT:var b=t.readUint32(),D=new w(t);o._records.push((function(t){t.createBrush(b,D)}));break;case l.GDI.RecordType.EMR_CREATEPEN:var A=t.readUint32(),L=new P(t,null);o._records.push((function(t){t.createPen(A,L)}));break;case l.GDI.RecordType.EMR_EXTCREATEPEN:var C=t.readUint32(),N=t.readUint32(),G=t.readUint32(),m=t.readUint32(),x=t.readUint32(),U=new P(t,{header:{off:N,size:G},data:{off:m,size:x}});o._records.push((function(t){t.createPen(C,U)}));break;case l.GDI.RecordType.EMR_SELECTOBJECT:var B=t.readUint32();o._records.push((function(t){t.selectObject(B,null)}));break;case l.GDI.RecordType.EMR_DELETEOBJECT:var k=t.readUint32();o._records.push((function(t){t.deleteObject(k)}));break;case l.GDI.RecordType.EMR_RECTANGLE:var F=new d(t);o._records.push((function(t){t.rectangle(F,0,0)}));break;case l.GDI.RecordType.EMR_ROUNDRECT:var H=new d(t),X=new _(t);o._records.push((function(t){t.rectangle(H,X.cx,X.cy)}));break;case l.GDI.RecordType.EMR_LINETO:var Y=t.readInt32(),W=t.readInt32();o._records.push((function(t){t.lineTo(Y,W)}));break;case l.GDI.RecordType.EMR_MOVETOEX:var j=t.readInt32(),z=t.readInt32();o._records.push((function(t){t.moveToEx(j,z)}));break;case l.GDI.RecordType.EMR_POLYGON:case l.GDI.RecordType.EMR_POLYGON16:for(var V=e===l.GDI.RecordType.EMR_POLYGON16,K=new d(t),Z=t.readUint32(),J=[];Z>0;)J.push(V?new E(t):new u(t)),Z--;o._records.push((function(t){t.polygon(J,K,!0)}));break;case l.GDI.RecordType.EMR_POLYPOLYGON:case l.GDI.RecordType.EMR_POLYPOLYGON16:V=e===l.GDI.RecordType.EMR_POLYPOLYGON16;var q=new d(t),Q=t.readUint32();t.skip(4);for(var $=[],tt=0;tt0;)ht.push(new E(t)),Z--;o._records.push((function(t){t.polyline(rt,ht,at)}));break;case l.GDI.RecordType.EMR_POLYBEZIER:case l.GDI.RecordType.EMR_POLYBEZIERTO:for(var ct=e===l.GDI.RecordType.EMR_POLYBEZIERTO,lt=new d(t),pt=(Z=t.readUint32(),[]);Z>0;)pt.push(new u(t)),Z--;o._records.push((function(t){t.polybezier(ct,pt,lt)}));break;case l.GDI.RecordType.EMR_POLYBEZIER16:for(var Et=new d(t),ut=new u(t),dt=(Z=t.readUint32(),[ut]);Z>0;)dt.push(new E(t)),Z--;o._records.push((function(t){t.polybezier(!1,dt,Et)}));break;case l.GDI.RecordType.EMR_POLYBEZIERTO16:for(var _t=new d(t),Rt=(Z=t.readUint32(),[]);Z>0;)Rt.push(new E(t)),Z--;o._records.push((function(t){t.polybezier(!0,Rt,_t)}));break;case l.GDI.RecordType.EMR_SETTEXTALIGN:var Tt=t.readUint32();o._records.push((function(t){t.setTextAlign(Tt)}));break;case l.GDI.RecordType.EMR_SETSTRETCHBLTMODE:var gt=t.readUint32();o._records.push((function(t){t.setStretchBltMode(gt)}));break;case l.GDI.RecordType.EMR_SETBRUSHORGEX:var ft=new u(t);o._records.push((function(t){t.setBrushOrgEx(ft)}));break;case l.GDI.RecordType.EMR_BEGINPATH:o._records.push((function(t){t.beginPath()}));break;case l.GDI.RecordType.EMR_ENDPATH:o._records.push((function(t){t.endPath()}));break;case l.GDI.RecordType.EMR_ABORTPATH:o._records.push((function(t){t.abortPath()}));break;case l.GDI.RecordType.EMR_CLOSEFIGURE:o._records.push((function(t){t.closeFigure()}));break;case l.GDI.RecordType.EMR_FILLPATH:var yt=new d(t);o._records.push((function(t){t.fillPath(yt)}));break;case l.GDI.RecordType.EMR_STROKEPATH:var St=new d(t);o._records.push((function(t){t.strokePath(St)}));break;case l.GDI.RecordType.EMR_SELECTCLIPPATH:var It=t.readUint32();o._records.push((function(t){t.selectClipPath(It)}));break;case l.GDI.RecordType.EMR_EXTSELECTCLIPRGN:t.skip(4);var vt=t.readUint32(),Ot=vt!==l.GDI.RegionMode.RGN_COPY?new g(t):null;o._records.push((function(t){t.selectClipRgn(vt,Ot)}));break;case l.GDI.RecordType.EMR_OFFSETCLIPRGN:var Mt=new u(t);o._records.push((function(t){t.offsetClipRgn(Mt)}));break;case l.GDI.RecordType.EMR_SETMITERLIMIT:var bt=t.readUint32();o._records.push((function(t){t.setMiterLimit(bt)}));break;case l.GDI.RecordType.EMR_POLYLINE:case l.GDI.RecordType.EMR_POLYLINETO:case l.GDI.RecordType.EMR_POLYPOLYLINE:case l.GDI.RecordType.EMR_SETPIXELV:case l.GDI.RecordType.EMR_SETMAPPERFLAGS:case l.GDI.RecordType.EMR_SETROP2:case l.GDI.RecordType.EMR_SETCOLORADJUSTMENT:case l.GDI.RecordType.EMR_SETTEXTCOLOR:case l.GDI.RecordType.EMR_SETMETARGN:case l.GDI.RecordType.EMR_EXCLUDECLIPRECT:case l.GDI.RecordType.EMR_INTERSECTCLIPRECT:case l.GDI.RecordType.EMR_SCALEVIEWPORTEXTEX:case l.GDI.RecordType.EMR_SCALEWINDOWEXTEX:case l.GDI.RecordType.EMR_SETWORLDTRANSFORM:case l.GDI.RecordType.EMR_MODIFYWORLDTRANSFORM:case l.GDI.RecordType.EMR_ANGLEARC:case l.GDI.RecordType.EMR_ELLIPSE:case l.GDI.RecordType.EMR_ARC:case l.GDI.RecordType.EMR_CHORD:case l.GDI.RecordType.EMR_PIE:case l.GDI.RecordType.EMR_SELECTPALETTE:case l.GDI.RecordType.EMR_CREATEPALETTE:case l.GDI.RecordType.EMR_SETPALETTEENTRIES:case l.GDI.RecordType.EMR_RESIZEPALETTE:case l.GDI.RecordType.EMR_REALIZEPALETTE:case l.GDI.RecordType.EMR_EXTFLOODFILL:case l.GDI.RecordType.EMR_ARCTO:case l.GDI.RecordType.EMR_POLYDRAW:case l.GDI.RecordType.EMR_SETARCDIRECTION:case l.GDI.RecordType.EMR_STROKEANDFILLPATH:case l.GDI.RecordType.EMR_FLATTENPATH:case l.GDI.RecordType.EMR_WIDENPATH:case l.GDI.RecordType.EMR_COMMENT:case l.GDI.RecordType.EMR_FILLRGN:case l.GDI.RecordType.EMR_FRAMERGN:case l.GDI.RecordType.EMR_INVERTRGN:case l.GDI.RecordType.EMR_PAINTRGN:case l.GDI.RecordType.EMR_BITBLT:case l.GDI.RecordType.EMR_STRETCHBLT:case l.GDI.RecordType.EMR_MASKBLT:case l.GDI.RecordType.EMR_PLGBLT:case l.GDI.RecordType.EMR_SETDIBITSTODEVICE:case l.GDI.RecordType.EMR_STRETCHDIBITS:case l.GDI.RecordType.EMR_EXTCREATEFONTINDIRECTW:case l.GDI.RecordType.EMR_EXTTEXTOUTA:case l.GDI.RecordType.EMR_EXTTEXTOUTW:case l.GDI.RecordType.EMR_POLYPOLYLINE16:case l.GDI.RecordType.EMR_POLYDRAW16:case l.GDI.RecordType.EMR_CREATEMONOBRUSH:case l.GDI.RecordType.EMR_CREATEDIBPATTERNBRUSHPT:case l.GDI.RecordType.EMR_POLYTEXTOUTA:case l.GDI.RecordType.EMR_POLYTEXTOUTW:case l.GDI.RecordType.EMR_SETICMMODE:case l.GDI.RecordType.EMR_CREATECOLORSPACE:case l.GDI.RecordType.EMR_SETCOLORSPACE:case l.GDI.RecordType.EMR_DELETECOLORSPACE:case l.GDI.RecordType.EMR_GLSRECORD:case l.GDI.RecordType.EMR_GLSBOUNDEDRECORD:case l.GDI.RecordType.EMR_PIXELFORMAT:case l.GDI.RecordType.EMR_DRAWESCAPE:case l.GDI.RecordType.EMR_EXTESCAPE:case l.GDI.RecordType.EMR_SMALLTEXTOUT:case l.GDI.RecordType.EMR_FORCEUFIMAPPING:case l.GDI.RecordType.EMR_NAMEDESCAPE:case l.GDI.RecordType.EMR_COLORCORRECTPALETTE:case l.GDI.RecordType.EMR_SETICMPROFILEA:case l.GDI.RecordType.EMR_SETICMPROFILEW:case l.GDI.RecordType.EMR_ALPHABLEND:case l.GDI.RecordType.EMR_SETLAYOUT:case l.GDI.RecordType.EMR_TRANSPARENTBLT:case l.GDI.RecordType.EMR_GRADIENTFILL:case l.GDI.RecordType.EMR_SETLINKEDUFIS:case l.GDI.RecordType.EMR_SETTEXTJUSTIFICATION:case l.GDI.RecordType.EMR_COLORMATCHTOTARGETW:case l.GDI.RecordType.EMR_CREATECOLORSPACEW:default:var wt="UNKNOWN";for(var Pt in l.GDI.RecordType)if(l.GDI.RecordType[Pt]===e){wt=Pt;break}l.log("[EMF] "+wt+" record (0x"+e.toString(16)+") at offset 0x"+s.toString(16)+" with "+n+" bytes")}s+=n},o=this;t:for(;!i&&"break-main_loop"!==n(););if(!i)throw new a("Could not read all records")}return t.prototype.play=function(t){for(var e=this._records.length,i=0;i1)throw new a("restoreDC: absolute restore not implemented")}this.state._svggroup=null},t.prototype.setStretchBltMode=function(t){l.log("[gdi] setStretchBltMode: stretchMode="+t)},t.prototype.rectangle=function(t,e,i){l.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),r=this._todevX(t.left);e=this._todevH(e),i=this._todevH(i),l.log("[gdi] rectangle: TRANSLATED: bottom="+s+" right="+n+" top="+o+" left="+r+" rh="+i+" rw="+e),this._pushGroup();var a=this._applyOpts(null,!0,!0,!1);this._svg.rect(this.state._svggroup,r,o,n-r,s-o,e/2,i/2,a)},t.prototype.lineTo=function(t,e){l.log("[gdi] lineTo: x="+t+" y="+e+" with pen "+this.state.selected.pen.toString());var i=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,l.log("[gdi] lineTo: TRANSLATED: toX="+i+" toY="+s+" fromX="+n+" fromY="+o),this._pushGroup();var r=this._applyOpts(null,!0,!1,!1);this._svg.line(this.state._svggroup,n,o,i,s,r)},t.prototype.moveToEx=function(t,e){l.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),l.log("[gdi] new path: "+this._svgPath.path()))},t.prototype.polygon=function(t,e,i){l.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,i){l.log("[gdi] polybezier: isPolyBezierTo="+t.toString()+", points="+e+", bounds="+i.toString()+" with pen "+this.state.selected.pen.toString());for(var s=[],n=0;n0){var r=s[0];this._svgPath.move(r.x,r.y)}else this._svgPath.move(this._todevX(this.state.x),this._todevY(this.state.y));if(s.length<(t?3:4))throw new a("Not enough points to draw bezier");for(n=t?1:0;n+3<=s.length;n+=3){var h=s[n],c=s[n+1],p=s[n+2];this._svgPath.curveC(h.x,h.y,c.x,c.y,p.x,p.y)}if(l.log("[gdi] new path: "+this._svgPath.path()),e.length>0){var E=e[e.length-1];this.state.x=E.x,this.state.y=E.y}},t.prototype.selectClipPath=function(t){l.log("[gdi] selectClipPath: rgnMode=0x"+t.toString(16))},t.prototype.selectClipRgn=function(t,e){if(l.log("[gdi] selectClipRgn: rgnMode=0x"+t.toString(16)),t!==l.GDI.RegionMode.RGN_COPY){if(null==e)throw new a("No clip region to select");throw new a("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){l.log("[gdi] offsetClipRgn: offset="+t.toString()),this._getClipRgn().offset(t.x,t.y)},t.prototype.setTextAlign=function(t){l.log("[gdi] setTextAlign: textAlignmentMode=0x"+t.toString(16)),this.state.textalign=t},t.prototype.setMiterLimit=function(t){l.log("[gdi] setMiterLimit: miterLimit="+t),this.state.miterlimit=t},t.prototype.setBkMode=function(t){l.log("[gdi] setBkMode: bkMode=0x"+t.toString(16)),this.state.bkmode=t},t.prototype.setBkColor=function(t){l.log("[gdi] setBkColor: bkColor="+t.toString()),this.state.bkcolor=t,this.state._svgtextbkfilter=null},t.prototype.setPolyFillMode=function(t){l.log("[gdi] setPolyFillMode: polyFillMode="+t),this.state.polyfillmode=t},t.prototype.createBrush=function(t,e){var i=this._storeObject(e,t);l.log("[gdi] createBrush: brush="+e.toString()+" with handle "+i)},t.prototype.createPen=function(t,e){var i=this._storeObject(e,t);l.log("[gdi] createPen: pen="+e.toString()+" width handle "+i)},t.prototype.createPenEx=function(t,e){var i=this._storeObject(e,t);l.log("[gdi] createPenEx: pen="+e.toString()+" width handle "+i)},t.prototype.selectObject=function(t,e){var i=this._getObject(t);null==i||null!=e&&i.type!==e?l.log("[gdi] selectObject: objIdx="+t+(i?" invalid object type: "+i.type:"[invalid index]")):(this._selectObject(i),l.log("[gdi] selectObject: objIdx="+t+(i?" selected "+i.type+": "+i.toString():"[invalid index]")))},t.prototype.abortPath=function(){l.log("[gdi] abortPath"),null!=this._svgPath&&(this._svgPath=null)},t.prototype.beginPath=function(){l.log("[gdi] beginPath"),null!=this._svgPath&&(this._svgPath=null),this._svgPath=this._svg.createPath()},t.prototype.closeFigure=function(){if(l.log("[gdi] closeFigure"),null==this._svgPath)throw new a("No path bracket: cannot close figure");this._svgPath.close()},t.prototype.fillPath=function(t){if(l.log("[gdi] fillPath"),null==this.state.selected.path)throw new a("No path selected");var e=this.state.selected.path,i=this._applyOpts(null,!0,!0,!1);this._svg.path(this.state._svggroup,e.svgPath,i),this._pushGroup(),this.state.selected.path=null},t.prototype.strokePath=function(t){if(l.log("[gdi] strokePath"),null==this.state.selected.path)throw new a("No path selected");var e=this.state.selected.path,i=this._applyOpts({fill:"none"},!0,!1,!1);this._svg.path(this.state._svggroup,e.svgPath,i),this._pushGroup(),this.state.selected.path=null},t.prototype.endPath=function(){if(l.log("[gdi] endPath"),null==this._svgPath)throw new a("No path bracket: cannot end path");this._pushGroup(),this._selectObject(new C(this._svgPath)),this._svgPath=null},t.prototype.deleteObject=function(t){var e=this._deleteObject(t);l.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?(l.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)+")"):l.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?N[(t-2147483648).toString()]:t===l.GDI.StockObject.DC_BRUSH?this.state.selected.brush:t===l.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 l.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))&&l.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 i=l._makeUniqueId("c"),s=this._svg.clipPath(this._getSvgDef(),i,"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","stroke-width":0});break;case 2:for(var n=0;n