@netless/appliance-plugin 1.1.22-beta.1 → 1.1.22-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/cdn.js +1 -1
- package/cdn/{fullWorker-BQclbf.js → fullWorker-C2mqiS.js} +2 -2
- package/cdn/{subWorker-Co2GgG.js → subWorker-D4IDQn.js} +2 -2
- package/dist/appliance-plugin.js +1 -1
- package/dist/appliance-plugin.mjs +1 -1
- package/dist/fullWorker.js +2 -2
- package/dist/{index-ggI7Ru6d.js → index-8SjVoT5b.js} +1 -1
- package/dist/index-BUrnEVL4.js +1 -0
- package/dist/{index-CEBD0CPi.mjs → index-C-JUkHdV.mjs} +1 -1
- package/dist/{index-Cyb4w2Wb.mjs → index-ChQedSu7.mjs} +1910 -1854
- package/dist/plugin/baseViewContainerManager.d.ts +6 -0
- package/dist/plugin/types.d.ts +8 -1
- package/dist/subWorker.js +2 -2
- package/package.json +1 -1
- package/dist/index-7Ry75r2W.js +0 -1
|
@@ -396,11 +396,11 @@ _inherits(o,_r$default22);return _createClass(o,[{key:"texture",get:function get
|
|
|
396
396
|
c=="length"||// Node.js 0.10 has enumerable non-index properties on buffers.
|
|
397
397
|
n&&(c=="offset"||c=="parent")||// PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
398
398
|
i&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||// Skip index properties.
|
|
399
|
-
Rf(c,a)))&&o.push(c);return o;}var Ii=Bf,Wf=Object.prototype;function Ff(u){var e=u&&u.constructor,t=typeof e=="function"&&e.prototype||Wf;return u===t;}var tn=Ff;function Uf(u,e){return function(t){return u(e(t));};}var Mi=Uf,jf=Mi,Yf=jf(Object.keys,Object),Xf=Yf,zf=tn,$f=Xf,Gf=Object.prototype,Hf=Gf.hasOwnProperty;function Vf(u){if(!zf(u))return $f(u);var e=[];for(var t in Object(u))Hf.call(u,t)&&t!="constructor"&&e.push(t);return e;}var Kf=Vf,kf=pi,Zf=Ci;function Jf(u){return u!=null&&Zf(u.length)&&!kf(u);}var en=Jf,Qf=Ii,qf=Kf,_f=en;function th(u){return _f(u)?Qf(u):qf(u);}var rn=th,eh=Br,rh=rn;function nh(u,e){return u&&eh(e,rh(e),u);}var ih=nh;function sh(u){var e=[];if(u!=null)for(var t in Object(u))e.push(t);return e;}var oh=sh,ah=hr,lh=tn,ch=oh,fh=Object.prototype,hh=fh.hasOwnProperty;function uh(u){if(!ah(u))return ch(u);var e=lh(u),t=[];for(var r in u)r=="constructor"&&(e||!hh.call(u,r))||t.push(r);return t;}var dh=uh,ph=Ii,mh=dh,vh=en;function yh(u){return vh(u)?ph(u,!0):mh(u);}var nn=yh,gh=Br,Ph=nn;function xh(u,e){return u&&gh(e,Ph(e),u);}var Sh=xh,xr={exports:{}};xr.exports;(function(u,e){var t=Ee,r=e&&!e.nodeType&&e,n=r&&!0&&u&&!u.nodeType&&u,i=n&&n.exports===r,l=i?t.Buffer:void 0,o=l?l.allocUnsafe:void 0;function a(c,g){if(g)return c.slice();var f=c.length,v=o?o(f):new c.constructor(f);return c.copy(v),v;}u.exports=a;})(xr,xr.exports);var Th=xr.exports;function Ch(u,e){var t=-1,r=u.length;for(e||(e=Array(r));++t<r;)e[t]=u[t];return e;}var Oh=Ch;function Ih(u,e){for(var t=-1,r=u==null?0:u.length,n=0,i=[];++t<r;){var l=u[t];e(l,t,u)&&(i[n++]=l);}return i;}var Ei=Ih;function Mh(){return[];}var Ai=Mh,Eh=Ei,Ah=Ai,Lh=Object.prototype,wh=Lh.propertyIsEnumerable,wn=Object.getOwnPropertySymbols,Rh=wn?function(u){return u==null?[]:(u=Object(u),Eh(wn(u),function(e){return wh.call(u,e);}));}:Ah,sn=Rh,Dh=Br,bh=sn;function Nh(u,e){return Dh(u,bh(u),e);}var Bh=Nh;function Wh(u,e){for(var t=-1,r=e.length,n=u.length;++t<r;)u[n+t]=e[t];return u;}var on=Wh,Fh=Mi,Uh=Fh(Object.getPrototypeOf,Object),Li=Uh,jh=on,Yh=Li,Xh=sn,zh=Ai,$h=Object.getOwnPropertySymbols,Gh=$h?function(u){for(var e=[];u;)jh(e,Xh(u)),u=Yh(u);return e;}:zh,wi=Gh,Hh=Br,Vh=wi;function Kh(u,e){return Hh(u,Vh(u),e);}var kh=Kh,Zh=on,Jh=ur;function Qh(u,e,t){var r=e(u);return Jh(u)?r:Zh(r,t(u));}var Ri=Qh,qh=Ri,_h=sn,tu=rn;function eu(u){return qh(u,tu,_h);}var Di=eu,ru=Ri,nu=wi,iu=nn;function su(u){return ru(u,iu,nu);}var ou=su,au=Ue,lu=Ee,cu=au(lu,"DataView"),fu=cu,hu=Ue,uu=Ee,du=hu(uu,"Promise"),pu=du,mu=Ue,vu=Ee,yu=mu(vu,"Set"),bi=yu,gu=Ue,Pu=Ee,xu=gu(Pu,"WeakMap"),Su=xu,zr=fu,$r=Qr,Gr=pu,Hr=bi,Vr=Su,Ni=Je,er=mi,Rn="[object Map]",Tu="[object Object]",Dn="[object Promise]",bn="[object Set]",Nn="[object WeakMap]",Bn="[object DataView]",Cu=er(zr),Ou=er($r),Iu=er(Gr),Mu=er(Hr),Eu=er(Vr),Fe=Ni;(zr&&Fe(new zr(new ArrayBuffer(1)))!=Bn||$r&&Fe(new $r())!=Rn||Gr&&Fe(Gr.resolve())!=Dn||Hr&&Fe(new Hr())!=bn||Vr&&Fe(new Vr())!=Nn)&&(Fe=function Fe(u){var e=Ni(u),t=e==Tu?u.constructor:void 0,r=t?er(t):"";if(r)switch(r){case Cu:return Bn;case Ou:return Rn;case Iu:return Dn;case Mu:return bn;case Eu:return Nn;}return e;});var Fr=Fe,Au=Object.prototype,Lu=Au.hasOwnProperty;function wu(u){var e=u.length,t=new u.constructor(e);return e&&typeof u[0]=="string"&&Lu.call(u,"index")&&(t.index=u.index,t.input=u.input),t;}var Ru=wu,Du=Ee,bu=Du.Uint8Array,Bi=bu,Wn=Bi;function Nu(u){var e=new u.constructor(u.byteLength);return new Wn(e).set(new Wn(u)),e;}var an=Nu,Bu=an;function Wu(u,e){var t=e?Bu(u.buffer):u.buffer;return new u.constructor(t,u.byteOffset,u.byteLength);}var Fu=Wu,Uu=/\w*$/;function ju(u){var e=new u.constructor(u.source,Uu.exec(u));return e.lastIndex=u.lastIndex,e;}var Yu=ju,Fn=fr,Un=Fn?Fn.prototype:void 0,jn=Un?Un.valueOf:void 0;function Xu(u){return jn?Object(jn.call(u)):{};}var zu=Xu,$u=an;function Gu(u,e){var t=e?$u(u.buffer):u.buffer;return new u.constructor(t,u.byteOffset,u.length);}var Hu=Gu,Vu=an,Ku=Fu,ku=Yu,Zu=zu,Ju=Hu,Qu="[object Boolean]",qu="[object Date]",_u="[object Map]",td="[object Number]",ed="[object RegExp]",rd="[object Set]",nd="[object String]",id="[object Symbol]",sd="[object ArrayBuffer]",od="[object DataView]",ad="[object Float32Array]",ld="[object Float64Array]",cd="[object Int8Array]",fd="[object Int16Array]",hd="[object Int32Array]",ud="[object Uint8Array]",dd="[object Uint8ClampedArray]",pd="[object Uint16Array]",md="[object Uint32Array]";function vd(u,e,t){var r=u.constructor;switch(e){case sd:return Vu(u);case Qu:case qu:return new r(+u);case od:return Ku(u,t);case ad:case ld:case cd:case fd:case hd:case ud:case dd:case pd:case md:return Ju(u,t);case _u:return new r();case td:case nd:return new r(u);case ed:return ku(u);case rd:return new r();case id:return Zu(u);}}var yd=vd,gd=hr,Yn=Object.create,Pd=/* @__PURE__ */function(){function u(){}return function(e){if(!gd(e))return{};if(Yn)return Yn(e);u.prototype=e;var t=new u();return u.prototype=void 0,t;};}(),xd=Pd,Sd=xd,Td=Li,Cd=tn;function Od(u){return typeof u.constructor=="function"&&!Cd(u)?Sd(Td(u)):{};}var Id=Od,Md=Fr,Ed=we,Ad="[object Map]";function Ld(u){return Ed(u)&&Md(u)==Ad;}var wd=Ld,Rd=wd,Dd=Wr,Xn=_r,zn=Xn&&Xn.isMap,bd=zn?Dd(zn):Rd,Nd=bd,Bd=Fr,Wd=we,Fd="[object Set]";function Ud(u){return Wd(u)&&Bd(u)==Fd;}var jd=Ud,Yd=jd,Xd=Wr,$n=_r,Gn=$n&&$n.isSet,zd=Gn?Xd(Gn):Yd,Wi=zd,$d=/* @__PURE__ */Ne(Wi),Gd=yi,Hd=mc,Vd=xi,Kd=ih,kd=Sh,Zd=Th,Jd=Oh,Qd=Bh,qd=kh,_d=Di,tp=ou,ep=Fr,rp=Ru,np=yd,ip=Id,sp=ur,op=qr,ap=Nd,lp=hr,cp=Wi,fp=rn,hp=nn,up=1,dp=2,pp=4,Fi="[object Arguments]",mp="[object Array]",vp="[object Boolean]",yp="[object Date]",gp="[object Error]",Ui="[object Function]",Pp="[object GeneratorFunction]",xp="[object Map]",Sp="[object Number]",ji="[object Object]",Tp="[object RegExp]",Cp="[object Set]",Op="[object String]",Ip="[object Symbol]",Mp="[object WeakMap]",Ep="[object ArrayBuffer]",Ap="[object DataView]",Lp="[object Float32Array]",wp="[object Float64Array]",Rp="[object Int8Array]",Dp="[object Int16Array]",bp="[object Int32Array]",Np="[object Uint8Array]",Bp="[object Uint8ClampedArray]",Wp="[object Uint16Array]",Fp="[object Uint32Array]",re={};re[Fi]=re[mp]=re[Ep]=re[Ap]=re[vp]=re[yp]=re[Lp]=re[wp]=re[Rp]=re[Dp]=re[bp]=re[xp]=re[Sp]=re[ji]=re[Tp]=re[Cp]=re[Op]=re[Ip]=re[Np]=re[Bp]=re[Wp]=re[Fp]=!0;re[gp]=re[Ui]=re[Mp]=!1;function yr(u,e,t,r,n,i){var l,o=e&up,a=e&dp,c=e&pp;if(t&&(l=n?t(u,r,n,i):t(u)),l!==void 0)return l;if(!lp(u))return u;var g=sp(u);if(g){if(l=rp(u),!o)return Jd(u,l);}else{var f=ep(u),v=f==Ui||f==Pp;if(op(u))return Zd(u,o);if(f==ji||f==Fi||v&&!n){if(l=a||v?{}:ip(u),!o)return a?qd(u,kd(l,u)):Qd(u,Kd(l,u));}else{if(!re[f])return n?u:{};l=np(u,f,o);}}i||(i=new Gd());var x=i.get(u);if(x)return x;i.set(u,l),cp(u)?u.forEach(function(P){l.add(yr(P,e,t,P,u,i));}):ap(u)&&u.forEach(function(P,C){l.set(C,yr(P,e,t,C,u,i));});var M=c?a?tp:_d:a?hp:fp,S=g?void 0:M(u);return Hd(S||u,function(P,C){S&&(C=P,P=u[C]),Vd(l,C,yr(P,e,t,C,u,i));}),l;}var Up=yr,jp=Up,Yp=1,Xp=4;function zp(u){return jp(u,Yp|Xp);}var $p=zp,he=/* @__PURE__ */Ne($p);var Yi="1.1.22-beta.1",Gp="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var u=window.__netlessUA||"";u+=" ".concat(Gp,"@").concat(Yi),window.__netlessUA=u;}var Te={useWorker:"auto",syncOpt:{interval:300,smoothSync:!0},cursor:{enable:!0,expirationTime:5e3,moveDelayTime:100},bufferSize:{full:2e4,sub:600},bezier:{enable:!0,maxDrawCount:1/0,combineUnitTime:300},pencilEraser:{useBitMap:!0,maxImageWidth:1920,maxImageHeight:1920,maxCombineTime:500},strokeWidth:{min:1,max:10},textEditor:{showFloatBar:!0,canSelectorSwitch:!0,rightBoundBreak:!1,extendFontFaces:[],loadFontFacesTimeout:1e4}};function De(u){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var t=u.length;if(t<2)return"";var r=u[0],n=u[1];if(t===2)return"M".concat(ze(r),"L").concat(ze(n));var i="";for(var l=2,o=t-1;l<o;l++)r=u[l],n=u[l+1],i+=$e(r,n);return e?"M".concat($e(u[0],u[1]),"Q").concat(ze(u[1])).concat($e(u[1],u[2]),"T").concat(i).concat($e(u[t-1],u[0])).concat($e(u[0],u[1]),"Z"):"M".concat(ze(u[0]),"Q").concat(ze(u[1])).concat($e(u[1],u[2])).concat(u.length>3?"T":"").concat(i,"L").concat(ze(u[t-1]));}var xe=/*#__PURE__*/function(){function xe(e){_classCallCheck(this,xe);at(this,"maxImageWidth",Te.pencilEraser.maxImageWidth);at(this,"maxImageHeight",Te.pencilEraser.maxImageHeight);at(this,"syncUnitTime",Te.syncOpt.interval);at(this,"vNodes");at(this,"drawLayer");at(this,"fullLayer");at(this,"workId");at(this,"isDelete",!1);var t=e.vNodes,r=e.fullLayer,n=e.drawLayer,i=e.workId,l=e.toolsOpt;this.vNodes=t,this.fullLayer=r,this.drawLayer=n,this.workId=i,this.syncUnitTime=l.syncUnitTime||this.syncUnitTime;}return _createClass(xe,[{key:"baseConsumeResult",get:function get(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions};}},{key:"filterSamePoints",value:function filterSamePoints(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0.01;return e.reduce(function(r,n){var i=r[r.length-1];return(n&&!i||n&&i&&!n.isNear(i,t))&&r.push(n),r;},[]);}/** 设置工作id */},{key:"setWorkId",value:function setWorkId(e){this.workId=e;}},{key:"getWorkId",value:function getWorkId(){return this.workId;}/** 获取工作选项配置 */},{key:"getWorkOptions",value:function getWorkOptions(){return this.workOptions;}/** 设置工作选项配置 */},{key:"setWorkOptions",value:function setWorkOptions(e){var n,i,l;this.workOptions=e,this.syncUnitTime=e.syncUnitTime||this.syncUnitTime;var t=(n=this.workId)==null?void 0:n.toString(),r=t&&((i=this.vNodes)==null?void 0:i.get(t))||void 0;t&&r&&(r.opt=e,(l=this.vNodes)==null||l.setInfo(t,r));}/** 更新服务端同步配置,返回绘制结果 */},{key:"updataOptService",value:function updataOptService(e){var n,i;var t;var r=(n=this.workId)==null?void 0:n.toString();if(r&&e){var l=this.fullLayer.getElementsByName(r)||this.drawLayer&&this.drawLayer.getElementsByName(r)||[];if(l.length!==1)return;var o=l[0],a=e.pos,c=e.zIndex,g=e.scale,f=e.angle,v=e.translate,x={};ue(c)&&(x.zIndex=c),a&&(x.pos=[a[0],a[1]]),g&&(x.scale=g),f&&(x.rotate=f),v&&(x.translate=v),o.attr(x);var M=o==null?void 0:o.getBoundingClientRect();return M&&(t=Wt(t,{x:Math.floor(M.x-xe.SafeBorderPadding),y:Math.floor(M.y-xe.SafeBorderPadding),w:Math.floor(M.width+xe.SafeBorderPadding*2),h:Math.floor(M.height+xe.SafeBorderPadding*2)})),(i=this.vNodes)==null||i.setInfo(r,{rect:t,centerPos:a}),t;}}},{key:"drawEraserlines",value:function drawEraserlines(e,t){var r=e.group,n=e.eraserlines,i=e.pos,l=e.layer,o=l.parent;if(t)try{var c=(l.renderer.glRenderer||l.renderer.canvasRenderer).options.displayRatio,g=r.getBoundingClientRect(),f=g.width*c*l.worldScaling[0],v=g.height*c*l.worldScaling[1];var x=1;(f>this.maxImageWidth||v>this.maxImageHeight)&&(x=Math.min(this.maxImageWidth/f,this.maxImageHeight/v));var M=l.getAttribute("scale");M=[M[0]*x,M[1]*x];var S=l.parent.parent,P=l.getAttribute("translate"),_C28=this.createVmRenderNode("".concat(this.workId,"_bitMapLayer"),S,{offscreen:o.offscreen,width:o.width,height:o.height,contextType:"2d",autoRender:!1,bufferSize:500},M,P),_h26=r.cloneNode(!0);if(!n||!n.length)return;this.addEraserlines(_h26,n,i,!1),_C28.appendChild(_h26);var p=_C28.parent;p.render();var d=_C28.renderer.canvasRenderer,y=d.context;if(!y)return;var I=d.options.displayRatio,L=_h26.getBoundingClientRect(),w={x:L.x,y:L.y,w:L.width,h:L.height},B={x:0,y:0,w:S.width,h:S.height};if(sr(w,B)===ye.outside){Se(_h26,p),S.removeChild(p),this.isDelete=!0;return;}var b=he(w);b.x=Math.floor(Math.max(w.x,0)),b.y=Math.floor(Math.max(w.y,0)),b.w=Math.min(w.x+w.w,S.width)-b.x,b.h=Math.min(w.y+w.h,S.height)-b.y;var W=this.getGroupRect(b,I),D=W.x,R=W.y,Y=W.w,V=W.h;var Q=y.getImageData(D,R,Y,V);if(this.isTransparentRectByCanvas(Q)){Se(_h26,p),S.removeChild(p),this.isDelete=!0,Q=null;return;}Se(r,o);var it=this.createSpriteNode({imageData:Q,safariRect:b,originRect:w,worldScaling:_C28.worldScaling});it&&r.append(it),Se(_h26,p),S.removeChild(p),o.deleteTexture(Q),Q=null;}catch(a){console.error("[BaseShapeTool] drawEraserlines error:",a);return;}}},{key:"createVmRenderNode",value:function createVmRenderNode(e,t,r,n,i){var l=r.width,o=r.height,a="bitMap-".concat(e),c=t.layer(a,r),g=new me({anchor:[0.5,0.5],pos:[l*0.5,o*0.5],size:[l,o],name:"viewport",id:e});return g.setAttribute("scale",n),g.setAttribute("translate",i),c.append(g),g;}},{key:"getGroupRect",value:function getGroupRect(e,t){var r=Math.floor(e.x*t),n=Math.floor(e.y*t),i=Math.floor(e.w*t),l=Math.floor(e.h*t);return{x:r,y:n,w:i,h:l};}},{key:"addEraserlines",value:function addEraserlines(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:!0;var _iterator13=_createForOfIteratorHelper(t),_step13;try{for(_iterator13.s();!(_step13=_iterator13.n()).done;){var i=_step13.value;var l=i.thickness,o=i.op;var _iterator14=_createForOfIteratorHelper(o),_step14;try{for(_iterator14.s();!(_step14=_iterator14.n()).done;){var a=_step14.value;var c=a.map(function(M,S){return S%2?M-r[1]:M-r[0];}),g=this.computEraserPoints(c,l),f=De(g,!0),v={pos:[0,0],d:f,fillColor:"rgba(0,0,0,1)"},x=new be(v);x.addEventListener("beforerender",function(_ref164){var M=_ref164.detail;var S=M.context;n?S.blendFuncSeparate(S.ZERO,S.ZERO,S.ZERO,S.ZERO):S.globalCompositeOperation="destination-out";}),x.addEventListener("afterrender",function(_ref165){var M=_ref165.detail;var S=M.context;n?S.blendFuncSeparate(S.SRC_ALPHA,S.ONE_MINUS_SRC_ALPHA,S.ONE,S.ONE_MINUS_SRC_ALPHA):S.globalCompositeOperation="source-over";}),e.append(x);}}catch(err){_iterator14.e(err);}finally{_iterator14.f();}}}catch(err){_iterator13.e(err);}finally{_iterator13.f();}}},{key:"isTransparentRectByCanvas",value:function isTransparentRectByCanvas(e){var t=!0;for(var r=0;r<e.data.length;r+=4)if(e.data[r+3]!==0){t=!1;break;}return t;}},{key:"createSpriteNode",value:function createSpriteNode(e){var t=e.imageData,r=e.worldScaling,n=e.safariRect,i=e.originRect;var l;if(typeof OffscreenCanvas=="function"){l=new OffscreenCanvas(t.width,t.height);var g=l.getContext("2d");g&&g.putImageData(t,0,0);}else if((typeof document==="undefined"?"undefined":_typeof(document))<"u"){l=document.createElement("canvas"),l.width=t.width,l.height=t.height;var _g3=l.getContext("2d");_g3&&_g3.putImageData(t,0,0);}if(!l)return console.warn("Failed to create imageEraserBitmap Sprite"),null;var o=[Math.floor(i.w/r[0]),Math.floor(i.h/r[1])],a=[Math.floor((n.x-i.x)/r[0]),Math.floor((n.y-i.y)/r[1]),Math.floor(n.w/r[0]),Math.floor(n.h/r[1])],c={name:"eraserTexture",anchor:[0.5,0.5],pos:[0,0],size:o,texture:l,textureRect:a};return new hi(c);}},{key:"computEraserPoints",value:function computEraserPoints(e,t){var r=Math.ceil(t/2);return e.length===2?this.computDot(e,r):this.computLine(e,r);}},{key:"computDot",value:function computDot(e,t){var r=new Dt(e[0],e[1]);return Dt.GetDotStroke(r,t,8);}},{key:"computLine",value:function computLine(e,t){var r=[],n=[];var i,l;for(var o=0;o<e.length;o+=2){var a=new Dt(e[o],e[o+1]);var c=void 0;if(o==e.length-2){var g=new Dt(e[o-2],e[o-1]);c=ot.Sub(a,g).uni(),i=a;}else{o===0&&(l=a);var _g4=new Dt(e[o+2],e[o+3]);c=ot.Sub(_g4,a).uni();}if(c){var _g5=ot.Per(c).mul(t);r.push(Dt.Sub(a,_g5)),n.push(Dt.Add(a,_g5));}}if(i&&l){var _o3=Dt.GetSemicircleStroke(i,r[r.length-1],-1,8),_a4=Dt.GetSemicircleStroke(l,n[0],-1,8);return r.concat(_o3,n.reverse(),_a4);}return[];}},{key:"replace",value:function replace(e,t,r){var _this61=this;var i;if(!t){r&&e.append(r);return;}var n=e.getElementsByName(t);if(n.length){var _iterator15=_createForOfIteratorHelper(n),_step15;try{for(_iterator15.s();!(_step15=_iterator15.n()).done;){var l=_step15.value;r?gm(r,l,e):(l.remove(),_pe(l,e.parent));}}catch(err){_iterator15.e(err);}finally{_iterator15.f();}}else r&&e.append(r);this.fullLayer!==this.drawLayer&&(this.fullLayer===e?(i=this.drawLayer)==null||i.getElementsByName(t).forEach(function(o){var a;o.remove(),_pe(o,(a=_this61.drawLayer)==null?void 0:a.parent);}):this.fullLayer.getElementsByName(t).forEach(function(o){o.remove(),_pe(o,_this61.fullLayer.parent);}));}},{key:"removeDrawCountNodes",value:function removeDrawCountNodes(e,t){var r=[];e.getElementsByName(this.workId).forEach(function(n){n.id&&t&&Number(n.id)<t&&r.push(n);});for(var _i2=0,_r3=r;_i2<_r3.length;_i2++){var n=_r3[_i2];n.remove(),_pe(n,e.parent);}}}],[{key:"updateNodeOpt",value:function updateNodeOpt(e){var h;var t=e.node,r=e.opt,n=e.vNodes,i=e.willSerializeData,l=e.targetNode,o=r.zIndex,a=r.translate,c=r.angle,g=r.originPoint,f=r.scenePoint,v=r.scale,x=r.pointMap,M=r.thickness;var S;var P=l&&he(l)||n.get(t.name);if(!P)return;ue(o)&&(t.setAttribute("zIndex",o),P.opt.zIndex=o);var C=t.parent;if(C){if(g&&v&&l){var p=[P.op[0],P.op[1]];mn(P.op,f,v,a);var d=[P.op[0],P.op[1]],y=[d[0]-p[0],d[1]-p[1]];if(P.centerPos=[P.centerPos[0]+y[0],P.centerPos[1]+y[1]],P.opt.translate=void 0,P.opt.scale=void 0,P.opt.eraserlines)for(var I=0;I<P.opt.eraserlines.length;I++){var _P$opt$eraserlines$I=P.opt.eraserlines[I],L=_P$opt$eraserlines$I.op,w=_P$opt$eraserlines$I.thickness;P.opt.eraserlines[I].thickness=Math.round(w*Math.max(v[0],v[1]));for(var B=0;B<L.length;B++)vn(L[B],f,v,a);}}else if(a){if(t.setAttribute("translate",a),P.opt.translate=a,l){var _p6=[a[0]*C.worldScaling[0],a[1]*C.worldScaling[1]];S=cr(P.rect,_p6),P.rect=S;}else{var _p7=xe.getRectFromLayer(C,t.name);P.rect=_p7||P.rect;}}else if(ue(c))if(t.setAttribute("rotate",c),P.opt.rotate=c,l)S=ns(P.rect,c),P.rect=S;else{var _p8=xe.getRectFromLayer(C,t.name);P.rect=_p8||P.rect;}if(x){var _p9=x.get(t.name);if(_p9)for(var _d11=0,_y9=0;_d11<P.op.length;_d11+=3,_y9++)P.op[_d11]=_p9[_y9][0],P.op[_d11+1]=_p9[_y9][1];}if(M&&(h=P==null?void 0:P.opt)!=null&&h.thickness&&(P.opt.thickness=M),i&&!(g&&v&&l)){if(a){var _p10=P.op.map(function(d,y){var I=y%3;return I===0?d+a[0]:I===1?d+a[1]:d;});if(P.op=_p10,P.centerPos=[P.centerPos[0]+a[0],P.centerPos[1]+a[1]],P!=null&&P.opt&&(P.opt.translate=void 0),P.opt.eraserlines)for(var _d12=0;_d12<P.opt.eraserlines.length;_d12++){var _y10=P.opt.eraserlines[_d12].op;for(var _I6=0;_I6<_y10.length;_I6++){var _L3=_y10[_I6].map(function(w,B){return B%2?w+a[1]:w+a[0];});P.opt.eraserlines[_d12].op[_I6]=_L3;}}}else if(ue(c)){var _p11=P.op;if(fm(_p11,P.centerPos,c),P.op=_p11,P!=null&&P.opt&&(P.opt.rotate=void 0),P.opt.eraserlines)for(var _d13=0;_d13<P.opt.eraserlines.length;_d13++){var _y11=P.opt.eraserlines[_d13].op;for(var _I7=0;_I7<_y11.length;_I7++)hm(_y11[_I7],P.centerPos,c);}}}P&&n.setInfo(t.name,P);}}},{key:"getCenterPos",value:function getCenterPos(e,t){var r=t.worldPosition,n=t.worldScaling;return[(e.x+e.w/2-r[0])/n[0],(e.y+e.h/2-r[1])/n[1]];}},{key:"getRectFromLayer",value:function getRectFromLayer(e,t){var r=e.getElementsByName(t)[0];if(r){var n=r.getBoundingClientRect();return{x:Math.floor(n.x-xe.SafeBorderPadding),y:Math.floor(n.y-xe.SafeBorderPadding),w:Math.floor(n.width+xe.SafeBorderPadding*2),h:Math.floor(n.height+xe.SafeBorderPadding*2)};}}},{key:"isWillRefresh",value:function isWillRefresh(e){var t=e.toolsType,r=e.opt,n=e.node,i=e.updateOpt,l=e.willSerializeData;return!!(l&&(i.angle||i.translate)||i.thickness&&r.thickness&&r.thickness!==i.thickness||i.strokeType&&r.strokeType&&r.strokeType!==i.strokeType||i.originPoint&&i.scenePoint&&i.scale||i.pointMap&&i.pointMap.has(n.name)||t===xt.Text&&(i.fontSize||i.translate||i.textInfos&&i.textInfos.get(n.name))||t===xt.Image&&(i.angle||i.translate||i.scale||i.strokeColor&&i.type===Zr.Iconify)||t===i.toolsType&&i.willRefresh||r.eraserlines&&r.eraserlines.length&&(i.strokeColor||i.fillColor));}}]);}();at(xe,"SafeBorderPadding",10);var Et=xe;var ln=Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50}),Object.freeze({width:48,height:74})]);var cn={exports:{}};cn.exports;(function(u){var e=function(){var t=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function l(a,c){if(!i[a]){i[a]={};for(var g=0;g<a.length;g++)i[a][a.charAt(g)]=g;}return i[a][c];}var o={compressToBase64:function compressToBase64(a){if(a==null)return"";var c=o._compress(a,6,function(g){return r.charAt(g);});switch(c.length%4){default:case 0:return c;case 1:return c+"===";case 2:return c+"==";case 3:return c+"=";}},decompressFromBase64:function decompressFromBase64(a){return a==null?"":a==""?null:o._decompress(a.length,32,function(c){return l(r,a.charAt(c));});},compressToUTF16:function compressToUTF16(a){return a==null?"":o._compress(a,15,function(c){return t(c+32);})+" ";},decompressFromUTF16:function decompressFromUTF16(a){return a==null?"":a==""?null:o._decompress(a.length,16384,function(c){return a.charCodeAt(c)-32;});},//compress into uint8array (UCS-2 big endian format)
|
|
399
|
+
Rf(c,a)))&&o.push(c);return o;}var Ii=Bf,Wf=Object.prototype;function Ff(u){var e=u&&u.constructor,t=typeof e=="function"&&e.prototype||Wf;return u===t;}var tn=Ff;function Uf(u,e){return function(t){return u(e(t));};}var Mi=Uf,jf=Mi,Yf=jf(Object.keys,Object),Xf=Yf,zf=tn,$f=Xf,Gf=Object.prototype,Hf=Gf.hasOwnProperty;function Vf(u){if(!zf(u))return $f(u);var e=[];for(var t in Object(u))Hf.call(u,t)&&t!="constructor"&&e.push(t);return e;}var Kf=Vf,kf=pi,Zf=Ci;function Jf(u){return u!=null&&Zf(u.length)&&!kf(u);}var en=Jf,Qf=Ii,qf=Kf,_f=en;function th(u){return _f(u)?Qf(u):qf(u);}var rn=th,eh=Br,rh=rn;function nh(u,e){return u&&eh(e,rh(e),u);}var ih=nh;function sh(u){var e=[];if(u!=null)for(var t in Object(u))e.push(t);return e;}var oh=sh,ah=hr,lh=tn,ch=oh,fh=Object.prototype,hh=fh.hasOwnProperty;function uh(u){if(!ah(u))return ch(u);var e=lh(u),t=[];for(var r in u)r=="constructor"&&(e||!hh.call(u,r))||t.push(r);return t;}var dh=uh,ph=Ii,mh=dh,vh=en;function yh(u){return vh(u)?ph(u,!0):mh(u);}var nn=yh,gh=Br,Ph=nn;function xh(u,e){return u&&gh(e,Ph(e),u);}var Sh=xh,xr={exports:{}};xr.exports;(function(u,e){var t=Ee,r=e&&!e.nodeType&&e,n=r&&!0&&u&&!u.nodeType&&u,i=n&&n.exports===r,l=i?t.Buffer:void 0,o=l?l.allocUnsafe:void 0;function a(c,g){if(g)return c.slice();var f=c.length,v=o?o(f):new c.constructor(f);return c.copy(v),v;}u.exports=a;})(xr,xr.exports);var Th=xr.exports;function Ch(u,e){var t=-1,r=u.length;for(e||(e=Array(r));++t<r;)e[t]=u[t];return e;}var Oh=Ch;function Ih(u,e){for(var t=-1,r=u==null?0:u.length,n=0,i=[];++t<r;){var l=u[t];e(l,t,u)&&(i[n++]=l);}return i;}var Ei=Ih;function Mh(){return[];}var Ai=Mh,Eh=Ei,Ah=Ai,Lh=Object.prototype,wh=Lh.propertyIsEnumerable,wn=Object.getOwnPropertySymbols,Rh=wn?function(u){return u==null?[]:(u=Object(u),Eh(wn(u),function(e){return wh.call(u,e);}));}:Ah,sn=Rh,Dh=Br,bh=sn;function Nh(u,e){return Dh(u,bh(u),e);}var Bh=Nh;function Wh(u,e){for(var t=-1,r=e.length,n=u.length;++t<r;)u[n+t]=e[t];return u;}var on=Wh,Fh=Mi,Uh=Fh(Object.getPrototypeOf,Object),Li=Uh,jh=on,Yh=Li,Xh=sn,zh=Ai,$h=Object.getOwnPropertySymbols,Gh=$h?function(u){for(var e=[];u;)jh(e,Xh(u)),u=Yh(u);return e;}:zh,wi=Gh,Hh=Br,Vh=wi;function Kh(u,e){return Hh(u,Vh(u),e);}var kh=Kh,Zh=on,Jh=ur;function Qh(u,e,t){var r=e(u);return Jh(u)?r:Zh(r,t(u));}var Ri=Qh,qh=Ri,_h=sn,tu=rn;function eu(u){return qh(u,tu,_h);}var Di=eu,ru=Ri,nu=wi,iu=nn;function su(u){return ru(u,iu,nu);}var ou=su,au=Ue,lu=Ee,cu=au(lu,"DataView"),fu=cu,hu=Ue,uu=Ee,du=hu(uu,"Promise"),pu=du,mu=Ue,vu=Ee,yu=mu(vu,"Set"),bi=yu,gu=Ue,Pu=Ee,xu=gu(Pu,"WeakMap"),Su=xu,zr=fu,$r=Qr,Gr=pu,Hr=bi,Vr=Su,Ni=Je,er=mi,Rn="[object Map]",Tu="[object Object]",Dn="[object Promise]",bn="[object Set]",Nn="[object WeakMap]",Bn="[object DataView]",Cu=er(zr),Ou=er($r),Iu=er(Gr),Mu=er(Hr),Eu=er(Vr),Fe=Ni;(zr&&Fe(new zr(new ArrayBuffer(1)))!=Bn||$r&&Fe(new $r())!=Rn||Gr&&Fe(Gr.resolve())!=Dn||Hr&&Fe(new Hr())!=bn||Vr&&Fe(new Vr())!=Nn)&&(Fe=function Fe(u){var e=Ni(u),t=e==Tu?u.constructor:void 0,r=t?er(t):"";if(r)switch(r){case Cu:return Bn;case Ou:return Rn;case Iu:return Dn;case Mu:return bn;case Eu:return Nn;}return e;});var Fr=Fe,Au=Object.prototype,Lu=Au.hasOwnProperty;function wu(u){var e=u.length,t=new u.constructor(e);return e&&typeof u[0]=="string"&&Lu.call(u,"index")&&(t.index=u.index,t.input=u.input),t;}var Ru=wu,Du=Ee,bu=Du.Uint8Array,Bi=bu,Wn=Bi;function Nu(u){var e=new u.constructor(u.byteLength);return new Wn(e).set(new Wn(u)),e;}var an=Nu,Bu=an;function Wu(u,e){var t=e?Bu(u.buffer):u.buffer;return new u.constructor(t,u.byteOffset,u.byteLength);}var Fu=Wu,Uu=/\w*$/;function ju(u){var e=new u.constructor(u.source,Uu.exec(u));return e.lastIndex=u.lastIndex,e;}var Yu=ju,Fn=fr,Un=Fn?Fn.prototype:void 0,jn=Un?Un.valueOf:void 0;function Xu(u){return jn?Object(jn.call(u)):{};}var zu=Xu,$u=an;function Gu(u,e){var t=e?$u(u.buffer):u.buffer;return new u.constructor(t,u.byteOffset,u.length);}var Hu=Gu,Vu=an,Ku=Fu,ku=Yu,Zu=zu,Ju=Hu,Qu="[object Boolean]",qu="[object Date]",_u="[object Map]",td="[object Number]",ed="[object RegExp]",rd="[object Set]",nd="[object String]",id="[object Symbol]",sd="[object ArrayBuffer]",od="[object DataView]",ad="[object Float32Array]",ld="[object Float64Array]",cd="[object Int8Array]",fd="[object Int16Array]",hd="[object Int32Array]",ud="[object Uint8Array]",dd="[object Uint8ClampedArray]",pd="[object Uint16Array]",md="[object Uint32Array]";function vd(u,e,t){var r=u.constructor;switch(e){case sd:return Vu(u);case Qu:case qu:return new r(+u);case od:return Ku(u,t);case ad:case ld:case cd:case fd:case hd:case ud:case dd:case pd:case md:return Ju(u,t);case _u:return new r();case td:case nd:return new r(u);case ed:return ku(u);case rd:return new r();case id:return Zu(u);}}var yd=vd,gd=hr,Yn=Object.create,Pd=/* @__PURE__ */function(){function u(){}return function(e){if(!gd(e))return{};if(Yn)return Yn(e);u.prototype=e;var t=new u();return u.prototype=void 0,t;};}(),xd=Pd,Sd=xd,Td=Li,Cd=tn;function Od(u){return typeof u.constructor=="function"&&!Cd(u)?Sd(Td(u)):{};}var Id=Od,Md=Fr,Ed=we,Ad="[object Map]";function Ld(u){return Ed(u)&&Md(u)==Ad;}var wd=Ld,Rd=wd,Dd=Wr,Xn=_r,zn=Xn&&Xn.isMap,bd=zn?Dd(zn):Rd,Nd=bd,Bd=Fr,Wd=we,Fd="[object Set]";function Ud(u){return Wd(u)&&Bd(u)==Fd;}var jd=Ud,Yd=jd,Xd=Wr,$n=_r,Gn=$n&&$n.isSet,zd=Gn?Xd(Gn):Yd,Wi=zd,$d=/* @__PURE__ */Ne(Wi),Gd=yi,Hd=mc,Vd=xi,Kd=ih,kd=Sh,Zd=Th,Jd=Oh,Qd=Bh,qd=kh,_d=Di,tp=ou,ep=Fr,rp=Ru,np=yd,ip=Id,sp=ur,op=qr,ap=Nd,lp=hr,cp=Wi,fp=rn,hp=nn,up=1,dp=2,pp=4,Fi="[object Arguments]",mp="[object Array]",vp="[object Boolean]",yp="[object Date]",gp="[object Error]",Ui="[object Function]",Pp="[object GeneratorFunction]",xp="[object Map]",Sp="[object Number]",ji="[object Object]",Tp="[object RegExp]",Cp="[object Set]",Op="[object String]",Ip="[object Symbol]",Mp="[object WeakMap]",Ep="[object ArrayBuffer]",Ap="[object DataView]",Lp="[object Float32Array]",wp="[object Float64Array]",Rp="[object Int8Array]",Dp="[object Int16Array]",bp="[object Int32Array]",Np="[object Uint8Array]",Bp="[object Uint8ClampedArray]",Wp="[object Uint16Array]",Fp="[object Uint32Array]",re={};re[Fi]=re[mp]=re[Ep]=re[Ap]=re[vp]=re[yp]=re[Lp]=re[wp]=re[Rp]=re[Dp]=re[bp]=re[xp]=re[Sp]=re[ji]=re[Tp]=re[Cp]=re[Op]=re[Ip]=re[Np]=re[Bp]=re[Wp]=re[Fp]=!0;re[gp]=re[Ui]=re[Mp]=!1;function yr(u,e,t,r,n,i){var l,o=e&up,a=e&dp,c=e&pp;if(t&&(l=n?t(u,r,n,i):t(u)),l!==void 0)return l;if(!lp(u))return u;var g=sp(u);if(g){if(l=rp(u),!o)return Jd(u,l);}else{var f=ep(u),v=f==Ui||f==Pp;if(op(u))return Zd(u,o);if(f==ji||f==Fi||v&&!n){if(l=a||v?{}:ip(u),!o)return a?qd(u,kd(l,u)):Qd(u,Kd(l,u));}else{if(!re[f])return n?u:{};l=np(u,f,o);}}i||(i=new Gd());var x=i.get(u);if(x)return x;i.set(u,l),cp(u)?u.forEach(function(P){l.add(yr(P,e,t,P,u,i));}):ap(u)&&u.forEach(function(P,C){l.set(C,yr(P,e,t,C,u,i));});var M=c?a?tp:_d:a?hp:fp,S=g?void 0:M(u);return Hd(S||u,function(P,C){S&&(C=P,P=u[C]),Vd(l,C,yr(P,e,t,C,u,i));}),l;}var Up=yr,jp=Up,Yp=1,Xp=4;function zp(u){return jp(u,Yp|Xp);}var $p=zp,he=/* @__PURE__ */Ne($p);var Yi="1.1.22-beta.2",Gp="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var u=window.__netlessUA||"";u+=" ".concat(Gp,"@").concat(Yi),window.__netlessUA=u;}var Te={useWorker:"auto",syncOpt:{interval:300,smoothSync:!0},cursor:{enable:!0,expirationTime:5e3,moveDelayTime:100},bufferSize:{full:2e4,sub:600},bezier:{enable:!0,maxDrawCount:1/0,combineUnitTime:300},pencilEraser:{useBitMap:!0,maxImageWidth:1920,maxImageHeight:1920,maxCombineTime:500},strokeWidth:{min:1,max:10},textEditor:{showFloatBar:!0,canSelectorSwitch:!0,rightBoundBreak:!1,extendFontFaces:[],loadFontFacesTimeout:1e4}};function De(u){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var t=u.length;if(t<2)return"";var r=u[0],n=u[1];if(t===2)return"M".concat(ze(r),"L").concat(ze(n));var i="";for(var l=2,o=t-1;l<o;l++)r=u[l],n=u[l+1],i+=$e(r,n);return e?"M".concat($e(u[0],u[1]),"Q").concat(ze(u[1])).concat($e(u[1],u[2]),"T").concat(i).concat($e(u[t-1],u[0])).concat($e(u[0],u[1]),"Z"):"M".concat(ze(u[0]),"Q").concat(ze(u[1])).concat($e(u[1],u[2])).concat(u.length>3?"T":"").concat(i,"L").concat(ze(u[t-1]));}var xe=/*#__PURE__*/function(){function xe(e){_classCallCheck(this,xe);at(this,"maxImageWidth",Te.pencilEraser.maxImageWidth);at(this,"maxImageHeight",Te.pencilEraser.maxImageHeight);at(this,"syncUnitTime",Te.syncOpt.interval);at(this,"vNodes");at(this,"drawLayer");at(this,"fullLayer");at(this,"workId");at(this,"isDelete",!1);var t=e.vNodes,r=e.fullLayer,n=e.drawLayer,i=e.workId,l=e.toolsOpt;this.vNodes=t,this.fullLayer=r,this.drawLayer=n,this.workId=i,this.syncUnitTime=l.syncUnitTime||this.syncUnitTime;}return _createClass(xe,[{key:"baseConsumeResult",get:function get(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions};}},{key:"filterSamePoints",value:function filterSamePoints(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0.01;return e.reduce(function(r,n){var i=r[r.length-1];return(n&&!i||n&&i&&!n.isNear(i,t))&&r.push(n),r;},[]);}/** 设置工作id */},{key:"setWorkId",value:function setWorkId(e){this.workId=e;}},{key:"getWorkId",value:function getWorkId(){return this.workId;}/** 获取工作选项配置 */},{key:"getWorkOptions",value:function getWorkOptions(){return this.workOptions;}/** 设置工作选项配置 */},{key:"setWorkOptions",value:function setWorkOptions(e){var n,i,l;this.workOptions=e,this.syncUnitTime=e.syncUnitTime||this.syncUnitTime;var t=(n=this.workId)==null?void 0:n.toString(),r=t&&((i=this.vNodes)==null?void 0:i.get(t))||void 0;t&&r&&(r.opt=e,(l=this.vNodes)==null||l.setInfo(t,r));}/** 更新服务端同步配置,返回绘制结果 */},{key:"updataOptService",value:function updataOptService(e){var n,i;var t;var r=(n=this.workId)==null?void 0:n.toString();if(r&&e){var l=this.fullLayer.getElementsByName(r)||this.drawLayer&&this.drawLayer.getElementsByName(r)||[];if(l.length!==1)return;var o=l[0],a=e.pos,c=e.zIndex,g=e.scale,f=e.angle,v=e.translate,x={};ue(c)&&(x.zIndex=c),a&&(x.pos=[a[0],a[1]]),g&&(x.scale=g),f&&(x.rotate=f),v&&(x.translate=v),o.attr(x);var M=o==null?void 0:o.getBoundingClientRect();return M&&(t=Wt(t,{x:Math.floor(M.x-xe.SafeBorderPadding),y:Math.floor(M.y-xe.SafeBorderPadding),w:Math.floor(M.width+xe.SafeBorderPadding*2),h:Math.floor(M.height+xe.SafeBorderPadding*2)})),(i=this.vNodes)==null||i.setInfo(r,{rect:t,centerPos:a}),t;}}},{key:"drawEraserlines",value:function drawEraserlines(e,t){var r=e.group,n=e.eraserlines,i=e.pos,l=e.layer,o=l.parent;if(t)try{var c=(l.renderer.glRenderer||l.renderer.canvasRenderer).options.displayRatio,g=r.getBoundingClientRect(),f=g.width*c*l.worldScaling[0],v=g.height*c*l.worldScaling[1];var x=1;(f>this.maxImageWidth||v>this.maxImageHeight)&&(x=Math.min(this.maxImageWidth/f,this.maxImageHeight/v));var M=l.getAttribute("scale");M=[M[0]*x,M[1]*x];var S=l.parent.parent,P=l.getAttribute("translate"),_C28=this.createVmRenderNode("".concat(this.workId,"_bitMapLayer"),S,{offscreen:o.offscreen,width:o.width,height:o.height,contextType:"2d",autoRender:!1,bufferSize:500},M,P),_h26=r.cloneNode(!0);if(!n||!n.length)return;this.addEraserlines(_h26,n,i,!1),_C28.appendChild(_h26);var p=_C28.parent;p.render();var d=_C28.renderer.canvasRenderer,y=d.context;if(!y)return;var I=d.options.displayRatio,L=_h26.getBoundingClientRect(),w={x:L.x,y:L.y,w:L.width,h:L.height},B={x:0,y:0,w:S.width,h:S.height};if(sr(w,B)===ye.outside){Se(_h26,p),S.removeChild(p),this.isDelete=!0;return;}var b=he(w);b.x=Math.floor(Math.max(w.x,0)),b.y=Math.floor(Math.max(w.y,0)),b.w=Math.min(w.x+w.w,S.width)-b.x,b.h=Math.min(w.y+w.h,S.height)-b.y;var W=this.getGroupRect(b,I),D=W.x,R=W.y,Y=W.w,V=W.h;var Q=y.getImageData(D,R,Y,V);if(this.isTransparentRectByCanvas(Q)){Se(_h26,p),S.removeChild(p),this.isDelete=!0,Q=null;return;}Se(r,o);var it=this.createSpriteNode({imageData:Q,safariRect:b,originRect:w,worldScaling:_C28.worldScaling});it&&r.append(it),Se(_h26,p),S.removeChild(p),o.deleteTexture(Q),Q=null;}catch(a){console.error("[BaseShapeTool] drawEraserlines error:",a);return;}}},{key:"createVmRenderNode",value:function createVmRenderNode(e,t,r,n,i){var l=r.width,o=r.height,a="bitMap-".concat(e),c=t.layer(a,r),g=new me({anchor:[0.5,0.5],pos:[l*0.5,o*0.5],size:[l,o],name:"viewport",id:e});return g.setAttribute("scale",n),g.setAttribute("translate",i),c.append(g),g;}},{key:"getGroupRect",value:function getGroupRect(e,t){var r=Math.floor(e.x*t),n=Math.floor(e.y*t),i=Math.floor(e.w*t),l=Math.floor(e.h*t);return{x:r,y:n,w:i,h:l};}},{key:"addEraserlines",value:function addEraserlines(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:!0;var _iterator13=_createForOfIteratorHelper(t),_step13;try{for(_iterator13.s();!(_step13=_iterator13.n()).done;){var i=_step13.value;var l=i.thickness,o=i.op;var _iterator14=_createForOfIteratorHelper(o),_step14;try{for(_iterator14.s();!(_step14=_iterator14.n()).done;){var a=_step14.value;var c=a.map(function(M,S){return S%2?M-r[1]:M-r[0];}),g=this.computEraserPoints(c,l),f=De(g,!0),v={pos:[0,0],d:f,fillColor:"rgba(0,0,0,1)"},x=new be(v);x.addEventListener("beforerender",function(_ref164){var M=_ref164.detail;var S=M.context;n?S.blendFuncSeparate(S.ZERO,S.ZERO,S.ZERO,S.ZERO):S.globalCompositeOperation="destination-out";}),x.addEventListener("afterrender",function(_ref165){var M=_ref165.detail;var S=M.context;n?S.blendFuncSeparate(S.SRC_ALPHA,S.ONE_MINUS_SRC_ALPHA,S.ONE,S.ONE_MINUS_SRC_ALPHA):S.globalCompositeOperation="source-over";}),e.append(x);}}catch(err){_iterator14.e(err);}finally{_iterator14.f();}}}catch(err){_iterator13.e(err);}finally{_iterator13.f();}}},{key:"isTransparentRectByCanvas",value:function isTransparentRectByCanvas(e){var t=!0;for(var r=0;r<e.data.length;r+=4)if(e.data[r+3]!==0){t=!1;break;}return t;}},{key:"createSpriteNode",value:function createSpriteNode(e){var t=e.imageData,r=e.worldScaling,n=e.safariRect,i=e.originRect;var l;if(typeof OffscreenCanvas=="function"){l=new OffscreenCanvas(t.width,t.height);var g=l.getContext("2d");g&&g.putImageData(t,0,0);}else if((typeof document==="undefined"?"undefined":_typeof(document))<"u"){l=document.createElement("canvas"),l.width=t.width,l.height=t.height;var _g3=l.getContext("2d");_g3&&_g3.putImageData(t,0,0);}if(!l)return console.warn("Failed to create imageEraserBitmap Sprite"),null;var o=[Math.floor(i.w/r[0]),Math.floor(i.h/r[1])],a=[Math.floor((n.x-i.x)/r[0]),Math.floor((n.y-i.y)/r[1]),Math.floor(n.w/r[0]),Math.floor(n.h/r[1])],c={name:"eraserTexture",anchor:[0.5,0.5],pos:[0,0],size:o,texture:l,textureRect:a};return new hi(c);}},{key:"computEraserPoints",value:function computEraserPoints(e,t){var r=Math.ceil(t/2);return e.length===2?this.computDot(e,r):this.computLine(e,r);}},{key:"computDot",value:function computDot(e,t){var r=new Dt(e[0],e[1]);return Dt.GetDotStroke(r,t,8);}},{key:"computLine",value:function computLine(e,t){var r=[],n=[];var i,l;for(var o=0;o<e.length;o+=2){var a=new Dt(e[o],e[o+1]);var c=void 0;if(o==e.length-2){var g=new Dt(e[o-2],e[o-1]);c=ot.Sub(a,g).uni(),i=a;}else{o===0&&(l=a);var _g4=new Dt(e[o+2],e[o+3]);c=ot.Sub(_g4,a).uni();}if(c){var _g5=ot.Per(c).mul(t);r.push(Dt.Sub(a,_g5)),n.push(Dt.Add(a,_g5));}}if(i&&l){var _o3=Dt.GetSemicircleStroke(i,r[r.length-1],-1,8),_a4=Dt.GetSemicircleStroke(l,n[0],-1,8);return r.concat(_o3,n.reverse(),_a4);}return[];}},{key:"replace",value:function replace(e,t,r){var _this61=this;var i;if(!t){r&&e.append(r);return;}var n=e.getElementsByName(t);if(n.length){var _iterator15=_createForOfIteratorHelper(n),_step15;try{for(_iterator15.s();!(_step15=_iterator15.n()).done;){var l=_step15.value;r?gm(r,l,e):(l.remove(),_pe(l,e.parent));}}catch(err){_iterator15.e(err);}finally{_iterator15.f();}}else r&&e.append(r);this.fullLayer!==this.drawLayer&&(this.fullLayer===e?(i=this.drawLayer)==null||i.getElementsByName(t).forEach(function(o){var a;o.remove(),_pe(o,(a=_this61.drawLayer)==null?void 0:a.parent);}):this.fullLayer.getElementsByName(t).forEach(function(o){o.remove(),_pe(o,_this61.fullLayer.parent);}));}},{key:"removeDrawCountNodes",value:function removeDrawCountNodes(e,t){var r=[];e.getElementsByName(this.workId).forEach(function(n){n.id&&t&&Number(n.id)<t&&r.push(n);});for(var _i2=0,_r3=r;_i2<_r3.length;_i2++){var n=_r3[_i2];n.remove(),_pe(n,e.parent);}}}],[{key:"updateNodeOpt",value:function updateNodeOpt(e){var h;var t=e.node,r=e.opt,n=e.vNodes,i=e.willSerializeData,l=e.targetNode,o=r.zIndex,a=r.translate,c=r.angle,g=r.originPoint,f=r.scenePoint,v=r.scale,x=r.pointMap,M=r.thickness;var S;var P=l&&he(l)||n.get(t.name);if(!P)return;ue(o)&&(t.setAttribute("zIndex",o),P.opt.zIndex=o);var C=t.parent;if(C){if(g&&v&&l){var p=[P.op[0],P.op[1]];mn(P.op,f,v,a);var d=[P.op[0],P.op[1]],y=[d[0]-p[0],d[1]-p[1]];if(P.centerPos=[P.centerPos[0]+y[0],P.centerPos[1]+y[1]],P.opt.translate=void 0,P.opt.scale=void 0,P.opt.eraserlines)for(var I=0;I<P.opt.eraserlines.length;I++){var _P$opt$eraserlines$I=P.opt.eraserlines[I],L=_P$opt$eraserlines$I.op,w=_P$opt$eraserlines$I.thickness;P.opt.eraserlines[I].thickness=Math.round(w*Math.max(v[0],v[1]));for(var B=0;B<L.length;B++)vn(L[B],f,v,a);}}else if(a){if(t.setAttribute("translate",a),P.opt.translate=a,l){var _p6=[a[0]*C.worldScaling[0],a[1]*C.worldScaling[1]];S=cr(P.rect,_p6),P.rect=S;}else{var _p7=xe.getRectFromLayer(C,t.name);P.rect=_p7||P.rect;}}else if(ue(c))if(t.setAttribute("rotate",c),P.opt.rotate=c,l)S=ns(P.rect,c),P.rect=S;else{var _p8=xe.getRectFromLayer(C,t.name);P.rect=_p8||P.rect;}if(x){var _p9=x.get(t.name);if(_p9)for(var _d11=0,_y9=0;_d11<P.op.length;_d11+=3,_y9++)P.op[_d11]=_p9[_y9][0],P.op[_d11+1]=_p9[_y9][1];}if(M&&(h=P==null?void 0:P.opt)!=null&&h.thickness&&(P.opt.thickness=M),i&&!(g&&v&&l)){if(a){var _p10=P.op.map(function(d,y){var I=y%3;return I===0?d+a[0]:I===1?d+a[1]:d;});if(P.op=_p10,P.centerPos=[P.centerPos[0]+a[0],P.centerPos[1]+a[1]],P!=null&&P.opt&&(P.opt.translate=void 0),P.opt.eraserlines)for(var _d12=0;_d12<P.opt.eraserlines.length;_d12++){var _y10=P.opt.eraserlines[_d12].op;for(var _I6=0;_I6<_y10.length;_I6++){var _L3=_y10[_I6].map(function(w,B){return B%2?w+a[1]:w+a[0];});P.opt.eraserlines[_d12].op[_I6]=_L3;}}}else if(ue(c)){var _p11=P.op;if(fm(_p11,P.centerPos,c),P.op=_p11,P!=null&&P.opt&&(P.opt.rotate=void 0),P.opt.eraserlines)for(var _d13=0;_d13<P.opt.eraserlines.length;_d13++){var _y11=P.opt.eraserlines[_d13].op;for(var _I7=0;_I7<_y11.length;_I7++)hm(_y11[_I7],P.centerPos,c);}}}P&&n.setInfo(t.name,P);}}},{key:"getCenterPos",value:function getCenterPos(e,t){var r=t.worldPosition,n=t.worldScaling;return[(e.x+e.w/2-r[0])/n[0],(e.y+e.h/2-r[1])/n[1]];}},{key:"getRectFromLayer",value:function getRectFromLayer(e,t){var r=e.getElementsByName(t)[0];if(r){var n=r.getBoundingClientRect();return{x:Math.floor(n.x-xe.SafeBorderPadding),y:Math.floor(n.y-xe.SafeBorderPadding),w:Math.floor(n.width+xe.SafeBorderPadding*2),h:Math.floor(n.height+xe.SafeBorderPadding*2)};}}},{key:"isWillRefresh",value:function isWillRefresh(e){var t=e.toolsType,r=e.opt,n=e.node,i=e.updateOpt,l=e.willSerializeData;return!!(l&&(i.angle||i.translate)||i.thickness&&r.thickness&&r.thickness!==i.thickness||i.strokeType&&r.strokeType&&r.strokeType!==i.strokeType||i.originPoint&&i.scenePoint&&i.scale||i.pointMap&&i.pointMap.has(n.name)||t===xt.Text&&(i.fontSize||i.translate||i.textInfos&&i.textInfos.get(n.name))||t===xt.Image&&(i.angle||i.translate||i.scale||i.strokeColor&&i.type===Zr.Iconify)||t===i.toolsType&&i.willRefresh||r.eraserlines&&r.eraserlines.length&&(i.strokeColor||i.fillColor));}}]);}();at(xe,"SafeBorderPadding",10);var Et=xe;var ln=Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50}),Object.freeze({width:48,height:74})]);var cn={exports:{}};cn.exports;(function(u){var e=function(){var t=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function l(a,c){if(!i[a]){i[a]={};for(var g=0;g<a.length;g++)i[a][a.charAt(g)]=g;}return i[a][c];}var o={compressToBase64:function compressToBase64(a){if(a==null)return"";var c=o._compress(a,6,function(g){return r.charAt(g);});switch(c.length%4){default:case 0:return c;case 1:return c+"===";case 2:return c+"==";case 3:return c+"=";}},decompressFromBase64:function decompressFromBase64(a){return a==null?"":a==""?null:o._decompress(a.length,32,function(c){return l(r,a.charAt(c));});},compressToUTF16:function compressToUTF16(a){return a==null?"":o._compress(a,15,function(c){return t(c+32);})+" ";},decompressFromUTF16:function decompressFromUTF16(a){return a==null?"":a==""?null:o._decompress(a.length,16384,function(c){return a.charCodeAt(c)-32;});},//compress into uint8array (UCS-2 big endian format)
|
|
400
400
|
compressToUint8Array:function compressToUint8Array(a){for(var c=o.compress(a),g=new Uint8Array(c.length*2),f=0,v=c.length;f<v;f++){var x=c.charCodeAt(f);g[f*2]=x>>>8,g[f*2+1]=x%256;}return g;},//decompress from uint8array (UCS-2 big endian format)
|
|
401
401
|
decompressFromUint8Array:function decompressFromUint8Array(a){if(a==null)return o.decompress(a);for(var c=new Array(a.length/2),g=0,f=c.length;g<f;g++)c[g]=a[g*2]*256+a[g*2+1];var v=[];return c.forEach(function(x){v.push(t(x));}),o.decompress(v.join(""));},//compress into a string that is already URI encoded
|
|
402
402
|
compressToEncodedURIComponent:function compressToEncodedURIComponent(a){return a==null?"":o._compress(a,6,function(c){return n.charAt(c);});},//decompress from an output of compressToEncodedURIComponent
|
|
403
|
-
decompressFromEncodedURIComponent:function decompressFromEncodedURIComponent(a){return a==null?"":a==""?null:(a=a.replace(/ /g,"+"),o._decompress(a.length,32,function(c){return l(n,a.charAt(c));}));},compress:function compress(a){return o._compress(a,16,function(c){return t(c);});},_compress:function _compress(a,c,g){if(a==null)return"";var f,v,x={},M={},S="",P="",C="",h=2,p=3,d=2,y=[],I=0,L=0,w;for(w=0;w<a.length;w+=1)if(S=a.charAt(w),Object.prototype.hasOwnProperty.call(x,S)||(x[S]=p++,M[S]=!0),P=C+S,Object.prototype.hasOwnProperty.call(x,P))C=P;else{if(Object.prototype.hasOwnProperty.call(M,C)){if(C.charCodeAt(0)<256){for(f=0;f<d;f++)I=I<<1,L==c-1?(L=0,y.push(g(I)),I=0):L++;for(v=C.charCodeAt(0),f=0;f<8;f++)I=I<<1|v&1,L==c-1?(L=0,y.push(g(I)),I=0):L++,v=v>>1;}else{for(v=1,f=0;f<d;f++)I=I<<1|v,L==c-1?(L=0,y.push(g(I)),I=0):L++,v=0;for(v=C.charCodeAt(0),f=0;f<16;f++)I=I<<1|v&1,L==c-1?(L=0,y.push(g(I)),I=0):L++,v=v>>1;}h--,h==0&&(h=Math.pow(2,d),d++),delete M[C];}else for(v=x[C],f=0;f<d;f++)I=I<<1|v&1,L==c-1?(L=0,y.push(g(I)),I=0):L++,v=v>>1;h--,h==0&&(h=Math.pow(2,d),d++),x[P]=p++,C=String(S);}if(C!==""){if(Object.prototype.hasOwnProperty.call(M,C)){if(C.charCodeAt(0)<256){for(f=0;f<d;f++)I=I<<1,L==c-1?(L=0,y.push(g(I)),I=0):L++;for(v=C.charCodeAt(0),f=0;f<8;f++)I=I<<1|v&1,L==c-1?(L=0,y.push(g(I)),I=0):L++,v=v>>1;}else{for(v=1,f=0;f<d;f++)I=I<<1|v,L==c-1?(L=0,y.push(g(I)),I=0):L++,v=0;for(v=C.charCodeAt(0),f=0;f<16;f++)I=I<<1|v&1,L==c-1?(L=0,y.push(g(I)),I=0):L++,v=v>>1;}h--,h==0&&(h=Math.pow(2,d),d++),delete M[C];}else for(v=x[C],f=0;f<d;f++)I=I<<1|v&1,L==c-1?(L=0,y.push(g(I)),I=0):L++,v=v>>1;h--,h==0&&(h=Math.pow(2,d),d++);}for(v=2,f=0;f<d;f++)I=I<<1|v&1,L==c-1?(L=0,y.push(g(I)),I=0):L++,v=v>>1;for(;;)if(I=I<<1,L==c-1){y.push(g(I));break;}else L++;return y.join("");},decompress:function decompress(a){return a==null?"":a==""?null:o._decompress(a.length,32768,function(c){return a.charCodeAt(c);});},_decompress:function _decompress(a,c,g){var f=[],v=4,x=4,M=3,S="",P=[],C,h,p,d,y,I,L,w={val:g(0),position:c,index:1};for(C=0;C<3;C+=1)f[C]=C;for(p=0,y=Math.pow(2,2),I=1;I!=y;)d=w.val&w.position,w.position>>=1,w.position==0&&(w.position=c,w.val=g(w.index++)),p|=(d>0?1:0)*I,I<<=1;switch(p){case 0:for(p=0,y=Math.pow(2,8),I=1;I!=y;)d=w.val&w.position,w.position>>=1,w.position==0&&(w.position=c,w.val=g(w.index++)),p|=(d>0?1:0)*I,I<<=1;L=t(p);break;case 1:for(p=0,y=Math.pow(2,16),I=1;I!=y;)d=w.val&w.position,w.position>>=1,w.position==0&&(w.position=c,w.val=g(w.index++)),p|=(d>0?1:0)*I,I<<=1;L=t(p);break;case 2:return"";}for(f[3]=L,h=L,P.push(L);;){if(w.index>a)return"";for(p=0,y=Math.pow(2,M),I=1;I!=y;)d=w.val&w.position,w.position>>=1,w.position==0&&(w.position=c,w.val=g(w.index++)),p|=(d>0?1:0)*I,I<<=1;switch(L=p){case 0:for(p=0,y=Math.pow(2,8),I=1;I!=y;)d=w.val&w.position,w.position>>=1,w.position==0&&(w.position=c,w.val=g(w.index++)),p|=(d>0?1:0)*I,I<<=1;f[x++]=t(p),L=x-1,v--;break;case 1:for(p=0,y=Math.pow(2,16),I=1;I!=y;)d=w.val&w.position,w.position>>=1,w.position==0&&(w.position=c,w.val=g(w.index++)),p|=(d>0?1:0)*I,I<<=1;f[x++]=t(p),L=x-1,v--;break;case 2:return P.join("");}if(v==0&&(v=Math.pow(2,M),M++),f[L])S=f[L];else if(L===x)S=h+h.charAt(0);else return null;P.push(S),f[x++]=h+S.charAt(0),v--,h=S,v==0&&(v=Math.pow(2,M),M++);}}};return o;}();u!=null?u.exports=e:(typeof angular==="undefined"?"undefined":_typeof(angular))<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return e;});})(cn);var Xi=cn.exports;function Ze(u){return JSON.parse(Xi.decompress(u));}function ge(u){return Xi.compress(JSON.stringify(u));}var zi={exports:{}};(function(u){(function(){var e={};e.version="6.4.2.2",e.use_lines=!0,e.use_xyz=!1;var t=!1;u.exports?(u.exports=e,t=!0):(typeof document==="undefined"?"undefined":_typeof(document))<"u"?window.ClipperLib=e:self.ClipperLib=e;var r;if(t){var n="chrome";r="Netscape";}else{var n=navigator.userAgent.toString().toLowerCase();r=navigator.appName;}var i={};n.indexOf("chrome")!=-1&&n.indexOf("chromium")==-1?i.chrome=1:i.chrome=0,n.indexOf("chromium")!=-1?i.chromium=1:i.chromium=0,n.indexOf("safari")!=-1&&n.indexOf("chrome")==-1&&n.indexOf("chromium")==-1?i.safari=1:i.safari=0,n.indexOf("firefox")!=-1?i.firefox=1:i.firefox=0,n.indexOf("firefox/17")!=-1?i.firefox17=1:i.firefox17=0,n.indexOf("firefox/15")!=-1?i.firefox15=1:i.firefox15=0,n.indexOf("firefox/3")!=-1?i.firefox3=1:i.firefox3=0,n.indexOf("opera")!=-1?i.opera=1:i.opera=0,n.indexOf("msie 10")!=-1?i.msie10=1:i.msie10=0,n.indexOf("msie 9")!=-1?i.msie9=1:i.msie9=0,n.indexOf("msie 8")!=-1?i.msie8=1:i.msie8=0,n.indexOf("msie 7")!=-1?i.msie7=1:i.msie7=0,n.indexOf("msie ")!=-1?i.msie=1:i.msie=0,e.biginteger_used=null;var l;function o(s,m,O){e.biginteger_used=1,s!=null&&(typeof s=="number"&&_typeof(m)>"u"?this.fromInt(s):typeof s=="number"?this.fromNumber(s,m,O):m==null&&typeof s!="string"?this.fromString(s,256):this.fromString(s,m));}function a(){return new o(null,void 0,void 0);}function c(s,m,O,N,X,k){for(;--k>=0;){var _=m*this[s++]+O[N]+X;X=Math.floor(_/67108864),O[N++]=_&67108863;}return X;}function g(s,m,O,N,X,k){for(var _=m&32767,ft=m>>15;--k>=0;){var ht=this[s]&32767,Ct=this[s++]>>15,wt=ft*ht+Ct*_;ht=_*ht+((wt&32767)<<15)+O[N]+(X&1073741823),X=(ht>>>30)+(wt>>>15)+ft*Ct+(X>>>30),O[N++]=ht&1073741823;}return X;}function f(s,m,O,N,X,k){for(var _=m&16383,ft=m>>14;--k>=0;){var ht=this[s]&16383,Ct=this[s++]>>14,wt=ft*ht+Ct*_;ht=_*ht+((wt&16383)<<14)+O[N]+X,X=(ht>>28)+(wt>>14)+ft*Ct,O[N++]=ht&268435455;}return X;}r=="Microsoft Internet Explorer"?(o.prototype.am=g,l=30):r!="Netscape"?(o.prototype.am=c,l=26):(o.prototype.am=f,l=28),o.prototype.DB=l,o.prototype.DM=(1<<l)-1,o.prototype.DV=1<<l;var v=52;o.prototype.FV=Math.pow(2,v),o.prototype.F1=v-l,o.prototype.F2=2*l-v;var x="0123456789abcdefghijklmnopqrstuvwxyz",M=new Array(),S,P;for(S=48,P=0;P<=9;++P)M[S++]=P;for(S=97,P=10;P<36;++P)M[S++]=P;for(S=65,P=10;P<36;++P)M[S++]=P;function C(s){return x.charAt(s);}function h(s,m){var O=M[s.charCodeAt(m)];return O!==null&&O!==void 0?O:-1;}function p(s){for(var m=this.t-1;m>=0;--m)s[m]=this[m];s.t=this.t,s.s=this.s;}function d(s){this.t=1,this.s=s<0?-1:0,s>0?this[0]=s:s<-1?this[0]=s+this.DV:this.t=0;}function y(s){var m=a();return m.fromInt(s),m;}function I(s,m){var O;if(m==16)O=4;else if(m==8)O=3;else if(m==256)O=8;else if(m==2)O=1;else if(m==32)O=5;else if(m==4)O=2;else{this.fromRadix(s,m);return;}this.t=0,this.s=0;for(var N=s.length,X=!1,k=0;--N>=0;){var _=O==8?s[N]&255:h(s,N);if(_<0){s.charAt(N)=="-"&&(X=!0);continue;}X=!1,k==0?this[this.t++]=_:k+O>this.DB?(this[this.t-1]|=(_&(1<<this.DB-k)-1)<<k,this[this.t++]=_>>this.DB-k):this[this.t-1]|=_<<k,k+=O,k>=this.DB&&(k-=this.DB);}O==8&&s[0]&128&&(this.s=-1,k>0&&(this[this.t-1]|=(1<<this.DB-k)-1<<k)),this.clamp(),X&&o.ZERO.subTo(this,this);}function L(){for(var s=this.s&this.DM;this.t>0&&this[this.t-1]==s;)--this.t;}function w(s){if(this.s<0)return"-"+this.negate().toString(s);var m;if(s==16)m=4;else if(s==8)m=3;else if(s==2)m=1;else if(s==32)m=5;else if(s==4)m=2;else return this.toRadix(s);var O=(1<<m)-1,N,X=!1,k="",_=this.t,ft=this.DB-_*this.DB%m;if(_-->0)for(ft<this.DB&&(N=this[_]>>ft)>0&&(X=!0,k=C(N));_>=0;)ft<m?(N=(this[_]&(1<<ft)-1)<<m-ft,N|=this[--_]>>(ft+=this.DB-m)):(N=this[_]>>(ft-=m)&O,ft<=0&&(ft+=this.DB,--_)),N>0&&(X=!0),X&&(k+=C(N));return X?k:"0";}function B(){var s=a();return o.ZERO.subTo(this,s),s;}function E(){return this.s<0?this.negate():this;}function b(s){var m=this.s-s.s;if(m!=0)return m;var O=this.t;if(m=O-s.t,m!=0)return this.s<0?-m:m;for(;--O>=0;)if((m=this[O]-s[O])!=0)return m;return 0;}function W(s){var m=1,O;return(O=s>>>16)!=0&&(s=O,m+=16),(O=s>>8)!=0&&(s=O,m+=8),(O=s>>4)!=0&&(s=O,m+=4),(O=s>>2)!=0&&(s=O,m+=2),(O=s>>1)!=0&&(s=O,m+=1),m;}function D(){return this.t<=0?0:this.DB*(this.t-1)+W(this[this.t-1]^this.s&this.DM);}function R(s,m){var O;for(O=this.t-1;O>=0;--O)m[O+s]=this[O];for(O=s-1;O>=0;--O)m[O]=0;m.t=this.t+s,m.s=this.s;}function Y(s,m){for(var O=s;O<this.t;++O)m[O-s]=this[O];m.t=Math.max(this.t-s,0),m.s=this.s;}function V(s,m){var O=s%this.DB,N=this.DB-O,X=(1<<N)-1,k=Math.floor(s/this.DB),_=this.s<<O&this.DM,ft;for(ft=this.t-1;ft>=0;--ft)m[ft+k+1]=this[ft]>>N|_,_=(this[ft]&X)<<O;for(ft=k-1;ft>=0;--ft)m[ft]=0;m[k]=_,m.t=this.t+k+1,m.s=this.s,m.clamp();}function Q(s,m){m.s=this.s;var O=Math.floor(s/this.DB);if(O>=this.t){m.t=0;return;}var N=s%this.DB,X=this.DB-N,k=(1<<N)-1;m[0]=this[O]>>N;for(var _=O+1;_<this.t;++_)m[_-O-1]|=(this[_]&k)<<X,m[_-O]=this[_]>>N;N>0&&(m[this.t-O-1]|=(this.s&k)<<X),m.t=this.t-O,m.clamp();}function et(s,m){for(var O=0,N=0,X=Math.min(s.t,this.t);O<X;)N+=this[O]-s[O],m[O++]=N&this.DM,N>>=this.DB;if(s.t<this.t){for(N-=s.s;O<this.t;)N+=this[O],m[O++]=N&this.DM,N>>=this.DB;N+=this.s;}else{for(N+=this.s;O<s.t;)N-=s[O],m[O++]=N&this.DM,N>>=this.DB;N-=s.s;}m.s=N<0?-1:0,N<-1?m[O++]=this.DV+N:N>0&&(m[O++]=N),m.t=O,m.clamp();}function it(s,m){var O=this.abs(),N=s.abs(),X=O.t;for(m.t=X+N.t;--X>=0;)m[X]=0;for(X=0;X<N.t;++X)m[X+O.t]=O.am(0,N[X],m,X,0,O.t);m.s=0,m.clamp(),this.s!=s.s&&o.ZERO.subTo(m,m);}function $(s){for(var m=this.abs(),O=s.t=2*m.t;--O>=0;)s[O]=0;for(O=0;O<m.t-1;++O){var N=m.am(O,m[O],s,2*O,0,1);(s[O+m.t]+=m.am(O+1,2*m[O],s,2*O+1,N,m.t-O-1))>=m.DV&&(s[O+m.t]-=m.DV,s[O+m.t+1]=1);}s.t>0&&(s[s.t-1]+=m.am(O,m[O],s,2*O,0,1)),s.s=0,s.clamp();}function K(s,m,O){var N=s.abs();if(!(N.t<=0)){var X=this.abs();if(X.t<N.t){m!=null&&m.fromInt(0),O!=null&&this.copyTo(O);return;}O==null&&(O=a());var k=a(),_=this.s,ft=s.s,ht=this.DB-W(N[N.t-1]);ht>0?(N.lShiftTo(ht,k),X.lShiftTo(ht,O)):(N.copyTo(k),X.copyTo(O));var Ct=k.t,wt=k[Ct-1];if(wt!=0){var Lt=wt*(1<<this.F1)+(Ct>1?k[Ct-2]>>this.F2:0),Bt=this.FV/Lt,Yt=(1<<this.F1)/Lt,Ht=1<<this.F2,Vt=O.t,ee=Vt-Ct,ve=m!==null&&m!==void 0?m:a();for(k.dlShiftTo(ee,ve),O.compareTo(ve)>=0&&(O[O.t++]=1,O.subTo(ve,O)),o.ONE.dlShiftTo(Ct,ve),ve.subTo(k,k);k.t<Ct;)k[k.t++]=0;for(;--ee>=0;){var Ie=O[--Vt]==wt?this.DM:Math.floor(O[Vt]*Bt+(O[Vt-1]+Ht)*Yt);if((O[Vt]+=k.am(0,Ie,O,ee,0,Ct))<Ie)for(k.dlShiftTo(ee,ve),O.subTo(ve,O);O[Vt]<--Ie;)O.subTo(ve,O);}m!=null&&(O.drShiftTo(Ct,m),_!=ft&&o.ZERO.subTo(m,m)),O.t=Ct,O.clamp(),ht>0&&O.rShiftTo(ht,O),_<0&&o.ZERO.subTo(O,O);}}}function rt(s){var m=a();return this.abs().divRemTo(s,null,m),this.s<0&&m.compareTo(o.ZERO)>0&&s.subTo(m,m),m;}function lt(s){this.m=s;}function ct(s){return s.s<0||s.compareTo(this.m)>=0?s.mod(this.m):s;}function yt(s){return s;}function st(s){s.divRemTo(this.m,null,s);}function Ot(s,m,O){s.multiplyTo(m,O),this.reduce(O);}function St(s,m){s.squareTo(m),this.reduce(m);}lt.prototype.convert=ct,lt.prototype.revert=yt,lt.prototype.reduce=st,lt.prototype.mulTo=Ot,lt.prototype.sqrTo=St;function F(){if(this.t<1)return 0;var s=this[0];if(!(s&1))return 0;var m=s&3;return m=m*(2-(s&15)*m)&15,m=m*(2-(s&255)*m)&255,m=m*(2-((s&65535)*m&65535))&65535,m=m*(2-s*m%this.DV)%this.DV,m>0?this.DV-m:-m;}function z(s){this.m=s,this.mp=s.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<s.DB-15)-1,this.mt2=2*s.t;}function Z(s){var m=a();return s.abs().dlShiftTo(this.m.t,m),m.divRemTo(this.m,null,m),s.s<0&&m.compareTo(o.ZERO)>0&&this.m.subTo(m,m),m;}function tt(s){var m=a();return s.copyTo(m),this.reduce(m),m;}function j(s){for(;s.t<=this.mt2;)s[s.t++]=0;for(var m=0;m<this.m.t;++m){var O=s[m]&32767,N=O*this.mpl+((O*this.mph+(s[m]>>15)*this.mpl&this.um)<<15)&s.DM;for(O=m+this.m.t,s[O]+=this.m.am(0,N,s,m,0,this.m.t);s[O]>=s.DV;)s[O]-=s.DV,s[++O]++;}s.clamp(),s.drShiftTo(this.m.t,s),s.compareTo(this.m)>=0&&s.subTo(this.m,s);}function H(s,m){s.squareTo(m),this.reduce(m);}function T(s,m,O){s.multiplyTo(m,O),this.reduce(O);}z.prototype.convert=Z,z.prototype.revert=tt,z.prototype.reduce=j,z.prototype.mulTo=T,z.prototype.sqrTo=H;function A(){return(this.t>0?this[0]&1:this.s)==0;}function U(s,m){if(s>4294967295||s<1)return o.ONE;var O=a(),N=a(),X=m.convert(this),k=W(s)-1;for(X.copyTo(O);--k>=0;)if(m.sqrTo(O,N),(s&1<<k)>0)m.mulTo(N,X,O);else{var _=O;O=N,N=_;}return m.revert(O);}function G(s,m){var O;return s<256||m.isEven()?O=new lt(m):O=new z(m),this.exp(s,O);}o.prototype.copyTo=p,o.prototype.fromInt=d,o.prototype.fromString=I,o.prototype.clamp=L,o.prototype.dlShiftTo=R,o.prototype.drShiftTo=Y,o.prototype.lShiftTo=V,o.prototype.rShiftTo=Q,o.prototype.subTo=et,o.prototype.multiplyTo=it,o.prototype.squareTo=$,o.prototype.divRemTo=K,o.prototype.invDigit=F,o.prototype.isEven=A,o.prototype.exp=U,o.prototype.toString=w,o.prototype.negate=B,o.prototype.abs=E,o.prototype.compareTo=b,o.prototype.bitLength=D,o.prototype.mod=rt,o.prototype.modPowInt=G,o.ZERO=y(0),o.ONE=y(1);function J(){var s=a();return this.copyTo(s),s;}function q(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1;}else{if(this.t==1)return this[0];if(this.t==0)return 0;}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0];}function nt(){return this.t==0?this.s:this[0]<<24>>24;}function ut(){return this.t==0?this.s:this[0]<<16>>16;}function pt(s){return Math.floor(Math.LN2*this.DB/Math.log(s));}function gt(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1;}function Tt(s){if(s==null&&(s=10),this.signum()==0||s<2||s>36)return"0";var m=this.chunkSize(s),O=Math.pow(s,m),N=y(O),X=a(),k=a(),_="";for(this.divRemTo(N,X,k);X.signum()>0;)_=(O+k.intValue()).toString(s).substr(1)+_,X.divRemTo(N,X,k);return k.intValue().toString(s)+_;}function vt(s,m){this.fromInt(0),m==null&&(m=10);for(var O=this.chunkSize(m),N=Math.pow(m,O),X=!1,k=0,_=0,ft=0;ft<s.length;++ft){var ht=h(s,ft);if(ht<0){s.charAt(ft)=="-"&&this.signum()==0&&(X=!0);continue;}_=m*_+ht,++k>=O&&(this.dMultiply(N),this.dAddOffset(_,0),k=0,_=0);}k>0&&(this.dMultiply(Math.pow(m,k)),this.dAddOffset(_,0)),X&&o.ZERO.subTo(this,this);}function mt(s,m,O){if(typeof m=="number"){if(s<2)this.fromInt(1);else for(this.fromNumber(s,O),this.testBit(s-1)||this.bitwiseTo(o.ONE.shiftLeft(s-1),Ut,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(m);)this.dAddOffset(2,0),this.bitLength()>s&&this.subTo(o.ONE.shiftLeft(s-1),this);}else{var N=new Array(),X=s&7;N.length=(s>>3)+1,m.nextBytes(N),X>0?N[0]&=(1<<X)-1:N[0]=0,this.fromString(N,256);}}function Pt(){var s=this.t,m=new Array();m[0]=this.s;var O=this.DB-s*this.DB%8,N,X=0;if(s-->0)for(O<this.DB&&(N=this[s]>>O)!=(this.s&this.DM)>>O&&(m[X++]=N|this.s<<this.DB-O);s>=0;)O<8?(N=(this[s]&(1<<O)-1)<<8-O,N|=this[--s]>>(O+=this.DB-8)):(N=this[s]>>(O-=8)&255,O<=0&&(O+=this.DB,--s)),N&128&&(N|=-256),X==0&&(this.s&128)!=(N&128)&&++X,(X>0||N!=this.s)&&(m[X++]=N);return m;}function Mt(s){return this.compareTo(s)==0;}function At(s){return this.compareTo(s)<0?this:s;}function It(s){return this.compareTo(s)>0?this:s;}function Nt(s,m,O){var N,X,k=Math.min(s.t,this.t);for(N=0;N<k;++N)O[N]=m(this[N],s[N]);if(s.t<this.t){for(X=s.s&this.DM,N=k;N<this.t;++N)O[N]=m(this[N],X);O.t=this.t;}else{for(X=this.s&this.DM,N=k;N<s.t;++N)O[N]=m(X,s[N]);O.t=s.t;}O.s=m(this.s,s.s),O.clamp();}function $t(s,m){return s&m;}function jt(s){var m=a();return this.bitwiseTo(s,$t,m),m;}function Ut(s,m){return s|m;}function zt(s){var m=a();return this.bitwiseTo(s,Ut,m),m;}function Xt(s,m){return s^m;}function ae(s){var m=a();return this.bitwiseTo(s,Xt,m),m;}function ie(s,m){return s&~m;}function se(s){var m=a();return this.bitwiseTo(s,ie,m),m;}function oe(){for(var s=a(),m=0;m<this.t;++m)s[m]=this.DM&~this[m];return s.t=this.t,s.s=~this.s,s;}function le(s){var m=a();return s<0?this.rShiftTo(-s,m):this.lShiftTo(s,m),m;}function ce(s){var m=a();return s<0?this.lShiftTo(-s,m):this.rShiftTo(s,m),m;}function fe(s){if(s==0)return-1;var m=0;return s&65535||(s>>=16,m+=16),s&255||(s>>=8,m+=8),s&15||(s>>=4,m+=4),s&3||(s>>=2,m+=2),s&1||++m,m;}function Zt(){for(var s=0;s<this.t;++s)if(this[s]!=0)return s*this.DB+fe(this[s]);return this.s<0?this.t*this.DB:-1;}function Pe(s){for(var m=0;s!=0;)s&=s-1,++m;return m;}function Be(){for(var s=0,m=this.s&this.DM,O=0;O<this.t;++O)s+=Pe(this[O]^m);return s;}function We(s){var m=Math.floor(s/this.DB);return m>=this.t?this.s!=0:(this[m]&1<<s%this.DB)!=0;}function dr(s,m){var O=o.ONE.shiftLeft(s);return this.bitwiseTo(O,m,O),O;}function pr(s){return this.changeBit(s,Ut);}function ps(s){return this.changeBit(s,ie);}function ms(s){return this.changeBit(s,Xt);}function vs(s,m){for(var O=0,N=0,X=Math.min(s.t,this.t);O<X;)N+=this[O]+s[O],m[O++]=N&this.DM,N>>=this.DB;if(s.t<this.t){for(N+=s.s;O<this.t;)N+=this[O],m[O++]=N&this.DM,N>>=this.DB;N+=this.s;}else{for(N+=this.s;O<s.t;)N+=s[O],m[O++]=N&this.DM,N>>=this.DB;N+=s.s;}m.s=N<0?-1:0,N>0?m[O++]=N:N<-1&&(m[O++]=this.DV+N),m.t=O,m.clamp();}function ys(s){var m=a();return this.addTo(s,m),m;}function gs(s){var m=a();return this.subTo(s,m),m;}function Ps(s){var m=a();return this.multiplyTo(s,m),m;}function xs(){var s=a();return this.squareTo(s),s;}function Ss(s){var m=a();return this.divRemTo(s,m,null),m;}function Ts(s){var m=a();return this.divRemTo(s,null,m),m;}function Cs(s){var m=a(),O=a();return this.divRemTo(s,m,O),new Array(m,O);}function Os(s){this[this.t]=this.am(0,s-1,this,0,0,this.t),++this.t,this.clamp();}function Is(s,m){if(s!=0){for(;this.t<=m;)this[this.t++]=0;for(this[m]+=s;this[m]>=this.DV;)this[m]-=this.DV,++m>=this.t&&(this[this.t++]=0),++this[m];}}function rr(){}function yn(s){return s;}function Ms(s,m,O){s.multiplyTo(m,O);}function Es(s,m){s.squareTo(m);}rr.prototype.convert=yn,rr.prototype.revert=yn,rr.prototype.mulTo=Ms,rr.prototype.sqrTo=Es;function As(s){return this.exp(s,new rr());}function Ls(s,m,O){var N=Math.min(this.t+s.t,m);for(O.s=0,O.t=N;N>0;)O[--N]=0;var X;for(X=O.t-this.t;N<X;++N)O[N+this.t]=this.am(0,s[N],O,N,0,this.t);for(X=Math.min(s.t,m);N<X;++N)this.am(0,s[N],O,N,0,m-N);O.clamp();}function ws(s,m,O){--m;var N=O.t=this.t+s.t-m;for(O.s=0;--N>=0;)O[N]=0;for(N=Math.max(m-this.t,0);N<s.t;++N)O[this.t+N-m]=this.am(m-N,s[N],O,0,0,this.t+N-m);O.clamp(),O.drShiftTo(1,O);}function je(s){this.r2=a(),this.q3=a(),o.ONE.dlShiftTo(2*s.t,this.r2),this.mu=this.r2.divide(s),this.m=s;}function Rs(s){if(s.s<0||s.t>2*this.m.t)return s.mod(this.m);if(s.compareTo(this.m)<0)return s;var m=a();return s.copyTo(m),this.reduce(m),m;}function Ds(s){return s;}function bs(s){for(s.drShiftTo(this.m.t-1,this.r2),s.t>this.m.t+1&&(s.t=this.m.t+1,s.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);s.compareTo(this.r2)<0;)s.dAddOffset(1,this.m.t+1);for(s.subTo(this.r2,s);s.compareTo(this.m)>=0;)s.subTo(this.m,s);}function Ns(s,m){s.squareTo(m),this.reduce(m);}function Bs(s,m,O){s.multiplyTo(m,O),this.reduce(O);}je.prototype.convert=Rs,je.prototype.revert=Ds,je.prototype.reduce=bs,je.prototype.mulTo=Bs,je.prototype.sqrTo=Ns;function Ws(s,m){var O=s.bitLength(),N,X=y(1),k;if(O<=0)return X;O<18?N=1:O<48?N=3:O<144?N=4:O<768?N=5:N=6,O<8?k=new lt(m):m.isEven()?k=new je(m):k=new z(m);var _=new Array(),ft=3,ht=N-1,Ct=(1<<N)-1;if(_[1]=k.convert(this),N>1){var wt=a();for(k.sqrTo(_[1],wt);ft<=Ct;)_[ft]=a(),k.mulTo(wt,_[ft-2],_[ft]),ft+=2;}var Lt=s.t-1,Bt,Yt=!0,Ht=a(),Vt;for(O=W(s[Lt])-1;Lt>=0;){for(O>=ht?Bt=s[Lt]>>O-ht&Ct:(Bt=(s[Lt]&(1<<O+1)-1)<<ht-O,Lt>0&&(Bt|=s[Lt-1]>>this.DB+O-ht)),ft=N;!(Bt&1);)Bt>>=1,--ft;if((O-=ft)<0&&(O+=this.DB,--Lt),Yt)_[Bt].copyTo(X),Yt=!1;else{for(;ft>1;)k.sqrTo(X,Ht),k.sqrTo(Ht,X),ft-=2;ft>0?k.sqrTo(X,Ht):(Vt=X,X=Ht,Ht=Vt),k.mulTo(Ht,_[Bt],X);}for(;Lt>=0&&!(s[Lt]&1<<O);)k.sqrTo(X,Ht),Vt=X,X=Ht,Ht=Vt,--O<0&&(O=this.DB-1,--Lt);}return k.revert(X);}function Fs(s){var m=this.s<0?this.negate():this.clone(),O=s.s<0?s.negate():s.clone();if(m.compareTo(O)<0){var N=m;m=O,O=N;}var X=m.getLowestSetBit(),k=O.getLowestSetBit();if(k<0)return m;for(X<k&&(k=X),k>0&&(m.rShiftTo(k,m),O.rShiftTo(k,O));m.signum()>0;)(X=m.getLowestSetBit())>0&&m.rShiftTo(X,m),(X=O.getLowestSetBit())>0&&O.rShiftTo(X,O),m.compareTo(O)>=0?(m.subTo(O,m),m.rShiftTo(1,m)):(O.subTo(m,O),O.rShiftTo(1,O));return k>0&&O.lShiftTo(k,O),O;}function Us(s){if(s<=0)return 0;var m=this.DV%s,O=this.s<0?s-1:0;if(this.t>0)if(m==0)O=this[0]%s;else for(var N=this.t-1;N>=0;--N)O=(m*O+this[N])%s;return O;}function js(s){var m=s.isEven();if(this.isEven()&&m||s.signum()==0)return o.ZERO;for(var O=s.clone(),N=this.clone(),X=y(1),k=y(0),_=y(0),ft=y(1);O.signum()!=0;){for(;O.isEven();)O.rShiftTo(1,O),m?((!X.isEven()||!k.isEven())&&(X.addTo(this,X),k.subTo(s,k)),X.rShiftTo(1,X)):k.isEven()||k.subTo(s,k),k.rShiftTo(1,k);for(;N.isEven();)N.rShiftTo(1,N),m?((!_.isEven()||!ft.isEven())&&(_.addTo(this,_),ft.subTo(s,ft)),_.rShiftTo(1,_)):ft.isEven()||ft.subTo(s,ft),ft.rShiftTo(1,ft);O.compareTo(N)>=0?(O.subTo(N,O),m&&X.subTo(_,X),k.subTo(ft,k)):(N.subTo(O,N),m&&_.subTo(X,_),ft.subTo(k,ft));}if(N.compareTo(o.ONE)!=0)return o.ZERO;if(ft.compareTo(s)>=0)return ft.subtract(s);if(ft.signum()<0)ft.addTo(s,ft);else return ft;return ft.signum()<0?ft.add(s):ft;}var de=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Ys=(1<<26)/de[de.length-1];function Xs(s){var m,O=this.abs();if(O.t==1&&O[0]<=de[de.length-1]){for(m=0;m<de.length;++m)if(O[0]==de[m])return!0;return!1;}if(O.isEven())return!1;for(m=1;m<de.length;){for(var N=de[m],X=m+1;X<de.length&&N<Ys;)N*=de[X++];for(N=O.modInt(N);m<X;)if(N%de[m++]==0)return!1;}return O.millerRabin(s);}function zs(s){var m=this.subtract(o.ONE),O=m.getLowestSetBit();if(O<=0)return!1;var N=m.shiftRight(O);s=s+1>>1,s>de.length&&(s=de.length);for(var X=a(),k=0;k<s;++k){X.fromInt(de[Math.floor(Math.random()*de.length)]);var _=X.modPow(N,this);if(_.compareTo(o.ONE)!=0&&_.compareTo(m)!=0){for(var ft=1;ft++<O&&_.compareTo(m)!=0;)if(_=_.modPowInt(2,this),_.compareTo(o.ONE)==0)return!1;if(_.compareTo(m)!=0)return!1;}}return!0;}o.prototype.chunkSize=pt,o.prototype.toRadix=Tt,o.prototype.fromRadix=vt,o.prototype.fromNumber=mt,o.prototype.bitwiseTo=Nt,o.prototype.changeBit=dr,o.prototype.addTo=vs,o.prototype.dMultiply=Os,o.prototype.dAddOffset=Is,o.prototype.multiplyLowerTo=Ls,o.prototype.multiplyUpperTo=ws,o.prototype.modInt=Us,o.prototype.millerRabin=zs,o.prototype.clone=J,o.prototype.intValue=q,o.prototype.byteValue=nt,o.prototype.shortValue=ut,o.prototype.signum=gt,o.prototype.toByteArray=Pt,o.prototype.equals=Mt,o.prototype.min=At,o.prototype.max=It,o.prototype.and=jt,o.prototype.or=zt,o.prototype.xor=ae,o.prototype.andNot=se,o.prototype.not=oe,o.prototype.shiftLeft=le,o.prototype.shiftRight=ce,o.prototype.getLowestSetBit=Zt,o.prototype.bitCount=Be,o.prototype.testBit=We,o.prototype.setBit=pr,o.prototype.clearBit=ps,o.prototype.flipBit=ms,o.prototype.add=ys,o.prototype.subtract=gs,o.prototype.multiply=Ps,o.prototype.divide=Ss,o.prototype.remainder=Ts,o.prototype.divideAndRemainder=Cs,o.prototype.modPow=Ws,o.prototype.modInverse=js,o.prototype.pow=As,o.prototype.gcd=Fs,o.prototype.isProbablePrime=Xs,o.prototype.square=xs;var Gt=o;Gt.prototype.IsNegative=function(){return this.compareTo(Gt.ZERO)==-1;},Gt.op_Equality=function(s,m){return s.compareTo(m)==0;},Gt.op_Inequality=function(s,m){return s.compareTo(m)!=0;},Gt.op_GreaterThan=function(s,m){return s.compareTo(m)>0;},Gt.op_LessThan=function(s,m){return s.compareTo(m)<0;},Gt.op_Addition=function(s,m){return new Gt(s,void 0,void 0).add(new Gt(m,void 0,void 0));},Gt.op_Subtraction=function(s,m){return new Gt(s,void 0,void 0).subtract(new Gt(m,void 0,void 0));},Gt.Int128Mul=function(s,m){return new Gt(s,void 0,void 0).multiply(new Gt(m,void 0,void 0));},Gt.op_Division=function(s,m){return s.divide(m);},Gt.prototype.ToDouble=function(){return parseFloat(this.toString());};var gn=function gn(s,m){var O;if(_typeof(Object.getOwnPropertyNames)>"u"){for(O in m.prototype)(_typeof(s.prototype[O])>"u"||s.prototype[O]===Object.prototype[O])&&(s.prototype[O]=m.prototype[O]);for(O in m)_typeof(s[O])>"u"&&(s[O]=m[O]);s.$baseCtor=m;}else{for(var N=Object.getOwnPropertyNames(m.prototype),X=0;X<N.length;X++)_typeof(Object.getOwnPropertyDescriptor(s.prototype,N[X]))>"u"&&Object.defineProperty(s.prototype,N[X],Object.getOwnPropertyDescriptor(m.prototype,N[X]));for(O in m)_typeof(s[O])>"u"&&(s[O]=m[O]);s.$baseCtor=m;}};e.Path=function(){return[];},e.Path.prototype.push=Array.prototype.push,e.Paths=function(){return[];},e.Paths.prototype.push=Array.prototype.push,e.DoublePoint=function(){var s=arguments;this.X=0,this.Y=0,s.length===1?(this.X=s[0].X,this.Y=s[0].Y):s.length===2&&(this.X=s[0],this.Y=s[1]);},e.DoublePoint0=function(){this.X=0,this.Y=0;},e.DoublePoint0.prototype=e.DoublePoint.prototype,e.DoublePoint1=function(s){this.X=s.X,this.Y=s.Y;},e.DoublePoint1.prototype=e.DoublePoint.prototype,e.DoublePoint2=function(s,m){this.X=s,this.Y=m;},e.DoublePoint2.prototype=e.DoublePoint.prototype,e.PolyNode=function(){this.m_Parent=null,this.m_polygon=new e.Path(),this.m_Index=0,this.m_jointype=0,this.m_endtype=0,this.m_Childs=[],this.IsOpen=!1;},e.PolyNode.prototype.IsHoleNode=function(){for(var s=!0,m=this.m_Parent;m!==null;)s=!s,m=m.m_Parent;return s;},e.PolyNode.prototype.ChildCount=function(){return this.m_Childs.length;},e.PolyNode.prototype.Contour=function(){return this.m_polygon;},e.PolyNode.prototype.AddChild=function(s){var m=this.m_Childs.length;this.m_Childs.push(s),s.m_Parent=this,s.m_Index=m;},e.PolyNode.prototype.GetNext=function(){return this.m_Childs.length>0?this.m_Childs[0]:this.GetNextSiblingUp();},e.PolyNode.prototype.GetNextSiblingUp=function(){return this.m_Parent===null?null:this.m_Index===this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+1];},e.PolyNode.prototype.Childs=function(){return this.m_Childs;},e.PolyNode.prototype.Parent=function(){return this.m_Parent;},e.PolyNode.prototype.IsHole=function(){return this.IsHoleNode();},e.PolyTree=function(){this.m_AllPolys=[],e.PolyNode.call(this);},e.PolyTree.prototype.Clear=function(){for(var s=0,m=this.m_AllPolys.length;s<m;s++)this.m_AllPolys[s]=null;this.m_AllPolys.length=0,this.m_Childs.length=0;},e.PolyTree.prototype.GetFirst=function(){return this.m_Childs.length>0?this.m_Childs[0]:null;},e.PolyTree.prototype.Total=function(){var s=this.m_AllPolys.length;return s>0&&this.m_Childs[0]!==this.m_AllPolys[0]&&s--,s;},gn(e.PolyTree,e.PolyNode),e.Math_Abs_Int64=e.Math_Abs_Int32=e.Math_Abs_Double=function(s){return Math.abs(s);},e.Math_Max_Int32_Int32=function(s,m){return Math.max(s,m);},i.msie||i.opera||i.safari?e.Cast_Int32=function(s){return s|0;}:e.Cast_Int32=function(s){return~~s;},_typeof(Number.toInteger)>"u"&&(Number.toInteger=null),i.chrome?e.Cast_Int64=function(s){return s<-2147483648||s>2147483647?s<0?Math.ceil(s):Math.floor(s):~~s;}:i.firefox&&typeof Number.toInteger=="function"?e.Cast_Int64=function(s){return Number.toInteger(s);}:i.msie7||i.msie8?e.Cast_Int64=function(s){return parseInt(s,10);}:i.msie?e.Cast_Int64=function(s){return s<-2147483648||s>2147483647?s<0?Math.ceil(s):Math.floor(s):s|0;}:e.Cast_Int64=function(s){return s<0?Math.ceil(s):Math.floor(s);},e.Clear=function(s){s.length=0;},e.PI=3.141592653589793,e.PI2=2*3.141592653589793,e.IntPoint=function(){var s=arguments,m=s.length;if(this.X=0,this.Y=0,e.use_xyz){if(this.Z=0,m===3)this.X=s[0],this.Y=s[1],this.Z=s[2];else if(m===2)this.X=s[0],this.Y=s[1],this.Z=0;else if(m===1){if(s[0]instanceof e.DoublePoint){var O=s[0];this.X=e.Clipper.Round(O.X),this.Y=e.Clipper.Round(O.Y),this.Z=0;}else{var N=s[0];_typeof(N.Z)>"u"&&(N.Z=0),this.X=N.X,this.Y=N.Y,this.Z=N.Z;}}else this.X=0,this.Y=0,this.Z=0;}else if(m===2)this.X=s[0],this.Y=s[1];else if(m===1){if(s[0]instanceof e.DoublePoint){var O=s[0];this.X=e.Clipper.Round(O.X),this.Y=e.Clipper.Round(O.Y);}else{var N=s[0];this.X=N.X,this.Y=N.Y;}}else this.X=0,this.Y=0;},e.IntPoint.op_Equality=function(s,m){return s.X===m.X&&s.Y===m.Y;},e.IntPoint.op_Inequality=function(s,m){return s.X!==m.X||s.Y!==m.Y;},e.IntPoint0=function(){this.X=0,this.Y=0,e.use_xyz&&(this.Z=0);},e.IntPoint0.prototype=e.IntPoint.prototype,e.IntPoint1=function(s){this.X=s.X,this.Y=s.Y,e.use_xyz&&(_typeof(s.Z)>"u"?this.Z=0:this.Z=s.Z);},e.IntPoint1.prototype=e.IntPoint.prototype,e.IntPoint1dp=function(s){this.X=e.Clipper.Round(s.X),this.Y=e.Clipper.Round(s.Y),e.use_xyz&&(this.Z=0);},e.IntPoint1dp.prototype=e.IntPoint.prototype,e.IntPoint2=function(s,m,O){this.X=s,this.Y=m,e.use_xyz&&(_typeof(O)>"u"?this.Z=0:this.Z=O);},e.IntPoint2.prototype=e.IntPoint.prototype,e.IntRect=function(){var s=arguments,m=s.length;if(m===4)this.left=s[0],this.top=s[1],this.right=s[2],this.bottom=s[3];else if(m===1){var O=s[0];this.left=O.left,this.top=O.top,this.right=O.right,this.bottom=O.bottom;}else this.left=0,this.top=0,this.right=0,this.bottom=0;},e.IntRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0;},e.IntRect0.prototype=e.IntRect.prototype,e.IntRect1=function(s){this.left=s.left,this.top=s.top,this.right=s.right,this.bottom=s.bottom;},e.IntRect1.prototype=e.IntRect.prototype,e.IntRect4=function(s,m,O,N){this.left=s,this.top=m,this.right=O,this.bottom=N;},e.IntRect4.prototype=e.IntRect.prototype,e.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},e.PolyType={ptSubject:0,ptClip:1},e.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},e.JoinType={jtSquare:0,jtRound:1,jtMiter:2},e.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},e.EdgeSide={esLeft:0,esRight:1},e.Direction={dRightToLeft:0,dLeftToRight:1},e.TEdge=function(){this.Bot=new e.IntPoint0(),this.Curr=new e.IntPoint0(),this.Top=new e.IntPoint0(),this.Delta=new e.IntPoint0(),this.Dx=0,this.PolyTyp=e.PolyType.ptSubject,this.Side=e.EdgeSide.esLeft,this.WindDelta=0,this.WindCnt=0,this.WindCnt2=0,this.OutIdx=0,this.Next=null,this.Prev=null,this.NextInLML=null,this.NextInAEL=null,this.PrevInAEL=null,this.NextInSEL=null,this.PrevInSEL=null;},e.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new e.IntPoint0();},e.MyIntersectNodeSort=function(){},e.MyIntersectNodeSort.Compare=function(s,m){var O=m.Pt.Y-s.Pt.Y;return O>0?1:O<0?-1:0;},e.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null;},e.Scanbeam=function(){this.Y=0,this.Next=null;},e.Maxima=function(){this.X=0,this.Next=null,this.Prev=null;},e.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null;},e.OutPt=function(){this.Idx=0,this.Pt=new e.IntPoint0(),this.Next=null,this.Prev=null;},e.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new e.IntPoint0();},e.ClipperBase=function(){this.m_MinimaList=null,this.m_CurrentLM=null,this.m_edges=new Array(),this.m_UseFullRange=!1,this.m_HasOpenPaths=!1,this.PreserveCollinear=!1,this.m_Scanbeam=null,this.m_PolyOuts=null,this.m_ActiveEdges=null;},e.ClipperBase.horizontal=-9007199254740992,e.ClipperBase.Skip=-2,e.ClipperBase.Unassigned=-1,e.ClipperBase.tolerance=1e-20,e.ClipperBase.loRange=47453132,e.ClipperBase.hiRange=4503599627370495,e.ClipperBase.near_zero=function(s){return s>-e.ClipperBase.tolerance&&s<e.ClipperBase.tolerance;},e.ClipperBase.IsHorizontal=function(s){return s.Delta.Y===0;},e.ClipperBase.prototype.PointIsVertex=function(s,m){var O=m;do{if(e.IntPoint.op_Equality(O.Pt,s))return!0;O=O.Next;}while(O!==m);return!1;},e.ClipperBase.prototype.PointOnLineSegment=function(s,m,O,N){return N?s.X===m.X&&s.Y===m.Y||s.X===O.X&&s.Y===O.Y||s.X>m.X==s.X<O.X&&s.Y>m.Y==s.Y<O.Y&&Gt.op_Equality(Gt.Int128Mul(s.X-m.X,O.Y-m.Y),Gt.Int128Mul(O.X-m.X,s.Y-m.Y)):s.X===m.X&&s.Y===m.Y||s.X===O.X&&s.Y===O.Y||s.X>m.X==s.X<O.X&&s.Y>m.Y==s.Y<O.Y&&(s.X-m.X)*(O.Y-m.Y)===(O.X-m.X)*(s.Y-m.Y);},e.ClipperBase.prototype.PointOnPolygon=function(s,m,O){for(var N=m;;){if(this.PointOnLineSegment(s,N.Pt,N.Next.Pt,O))return!0;if(N=N.Next,N===m)break;}return!1;},e.ClipperBase.prototype.SlopesEqual=e.ClipperBase.SlopesEqual=function(){var s=arguments,m=s.length,O,N,X,k,_,ft,ht;return m===3?(O=s[0],N=s[1],ht=s[2],ht?Gt.op_Equality(Gt.Int128Mul(O.Delta.Y,N.Delta.X),Gt.Int128Mul(O.Delta.X,N.Delta.Y)):e.Cast_Int64(O.Delta.Y*N.Delta.X)===e.Cast_Int64(O.Delta.X*N.Delta.Y)):m===4?(X=s[0],k=s[1],_=s[2],ht=s[3],ht?Gt.op_Equality(Gt.Int128Mul(X.Y-k.Y,k.X-_.X),Gt.Int128Mul(X.X-k.X,k.Y-_.Y)):e.Cast_Int64((X.Y-k.Y)*(k.X-_.X))-e.Cast_Int64((X.X-k.X)*(k.Y-_.Y))===0):(X=s[0],k=s[1],_=s[2],ft=s[3],ht=s[4],ht?Gt.op_Equality(Gt.Int128Mul(X.Y-k.Y,_.X-ft.X),Gt.Int128Mul(X.X-k.X,_.Y-ft.Y)):e.Cast_Int64((X.Y-k.Y)*(_.X-ft.X))-e.Cast_Int64((X.X-k.X)*(_.Y-ft.Y))===0);},e.ClipperBase.SlopesEqual3=function(s,m,O){return O?Gt.op_Equality(Gt.Int128Mul(s.Delta.Y,m.Delta.X),Gt.Int128Mul(s.Delta.X,m.Delta.Y)):e.Cast_Int64(s.Delta.Y*m.Delta.X)===e.Cast_Int64(s.Delta.X*m.Delta.Y);},e.ClipperBase.SlopesEqual4=function(s,m,O,N){return N?Gt.op_Equality(Gt.Int128Mul(s.Y-m.Y,m.X-O.X),Gt.Int128Mul(s.X-m.X,m.Y-O.Y)):e.Cast_Int64((s.Y-m.Y)*(m.X-O.X))-e.Cast_Int64((s.X-m.X)*(m.Y-O.Y))===0;},e.ClipperBase.SlopesEqual5=function(s,m,O,N,X){return X?Gt.op_Equality(Gt.Int128Mul(s.Y-m.Y,O.X-N.X),Gt.Int128Mul(s.X-m.X,O.Y-N.Y)):e.Cast_Int64((s.Y-m.Y)*(O.X-N.X))-e.Cast_Int64((s.X-m.X)*(O.Y-N.Y))===0;},e.ClipperBase.prototype.Clear=function(){this.DisposeLocalMinimaList();for(var s=0,m=this.m_edges.length;s<m;++s){for(var O=0,N=this.m_edges[s].length;O<N;++O)this.m_edges[s][O]=null;e.Clear(this.m_edges[s]);}e.Clear(this.m_edges),this.m_UseFullRange=!1,this.m_HasOpenPaths=!1;},e.ClipperBase.prototype.DisposeLocalMinimaList=function(){for(;this.m_MinimaList!==null;){var s=this.m_MinimaList.Next;this.m_MinimaList=null,this.m_MinimaList=s;}this.m_CurrentLM=null;},e.ClipperBase.prototype.RangeTest=function(s,m){m.Value?(s.X>e.ClipperBase.hiRange||s.Y>e.ClipperBase.hiRange||-s.X>e.ClipperBase.hiRange||-s.Y>e.ClipperBase.hiRange)&&e.Error("Coordinate outside allowed range in RangeTest()."):(s.X>e.ClipperBase.loRange||s.Y>e.ClipperBase.loRange||-s.X>e.ClipperBase.loRange||-s.Y>e.ClipperBase.loRange)&&(m.Value=!0,this.RangeTest(s,m));},e.ClipperBase.prototype.InitEdge=function(s,m,O,N){s.Next=m,s.Prev=O,s.Curr.X=N.X,s.Curr.Y=N.Y,e.use_xyz&&(s.Curr.Z=N.Z),s.OutIdx=-1;},e.ClipperBase.prototype.InitEdge2=function(s,m){s.Curr.Y>=s.Next.Curr.Y?(s.Bot.X=s.Curr.X,s.Bot.Y=s.Curr.Y,e.use_xyz&&(s.Bot.Z=s.Curr.Z),s.Top.X=s.Next.Curr.X,s.Top.Y=s.Next.Curr.Y,e.use_xyz&&(s.Top.Z=s.Next.Curr.Z)):(s.Top.X=s.Curr.X,s.Top.Y=s.Curr.Y,e.use_xyz&&(s.Top.Z=s.Curr.Z),s.Bot.X=s.Next.Curr.X,s.Bot.Y=s.Next.Curr.Y,e.use_xyz&&(s.Bot.Z=s.Next.Curr.Z)),this.SetDx(s),s.PolyTyp=m;},e.ClipperBase.prototype.FindNextLocMin=function(s){for(var m;;){for(;e.IntPoint.op_Inequality(s.Bot,s.Prev.Bot)||e.IntPoint.op_Equality(s.Curr,s.Top);)s=s.Next;if(s.Dx!==e.ClipperBase.horizontal&&s.Prev.Dx!==e.ClipperBase.horizontal)break;for(;s.Prev.Dx===e.ClipperBase.horizontal;)s=s.Prev;for(m=s;s.Dx===e.ClipperBase.horizontal;)s=s.Next;if(s.Top.Y!==s.Prev.Bot.Y){m.Prev.Bot.X<s.Bot.X&&(s=m);break;}}return s;},e.ClipperBase.prototype.ProcessBound=function(s,m){var O,N=s,X;if(N.OutIdx===e.ClipperBase.Skip){if(s=N,m){for(;s.Top.Y===s.Next.Bot.Y;)s=s.Next;for(;s!==N&&s.Dx===e.ClipperBase.horizontal;)s=s.Prev;}else{for(;s.Top.Y===s.Prev.Bot.Y;)s=s.Prev;for(;s!==N&&s.Dx===e.ClipperBase.horizontal;)s=s.Next;}if(s===N)m?N=s.Next:N=s.Prev;else{m?s=N.Next:s=N.Prev;var k=new e.LocalMinima();k.Next=null,k.Y=s.Bot.Y,k.LeftBound=null,k.RightBound=s,s.WindDelta=0,N=this.ProcessBound(s,m),this.InsertLocalMinima(k);}return N;}if(s.Dx===e.ClipperBase.horizontal&&(m?O=s.Prev:O=s.Next,O.Dx===e.ClipperBase.horizontal?O.Bot.X!==s.Bot.X&&O.Top.X!==s.Bot.X&&this.ReverseHorizontal(s):O.Bot.X!==s.Bot.X&&this.ReverseHorizontal(s)),O=s,m){for(;N.Top.Y===N.Next.Bot.Y&&N.Next.OutIdx!==e.ClipperBase.Skip;)N=N.Next;if(N.Dx===e.ClipperBase.horizontal&&N.Next.OutIdx!==e.ClipperBase.Skip){for(X=N;X.Prev.Dx===e.ClipperBase.horizontal;)X=X.Prev;X.Prev.Top.X>N.Next.Top.X&&(N=X.Prev);}for(;s!==N;)s.NextInLML=s.Next,s.Dx===e.ClipperBase.horizontal&&s!==O&&s.Bot.X!==s.Prev.Top.X&&this.ReverseHorizontal(s),s=s.Next;s.Dx===e.ClipperBase.horizontal&&s!==O&&s.Bot.X!==s.Prev.Top.X&&this.ReverseHorizontal(s),N=N.Next;}else{for(;N.Top.Y===N.Prev.Bot.Y&&N.Prev.OutIdx!==e.ClipperBase.Skip;)N=N.Prev;if(N.Dx===e.ClipperBase.horizontal&&N.Prev.OutIdx!==e.ClipperBase.Skip){for(X=N;X.Next.Dx===e.ClipperBase.horizontal;)X=X.Next;(X.Next.Top.X===N.Prev.Top.X||X.Next.Top.X>N.Prev.Top.X)&&(N=X.Next);}for(;s!==N;)s.NextInLML=s.Prev,s.Dx===e.ClipperBase.horizontal&&s!==O&&s.Bot.X!==s.Next.Top.X&&this.ReverseHorizontal(s),s=s.Prev;s.Dx===e.ClipperBase.horizontal&&s!==O&&s.Bot.X!==s.Next.Top.X&&this.ReverseHorizontal(s),N=N.Prev;}return N;},e.ClipperBase.prototype.AddPath=function(s,m,O){e.use_lines?!O&&m===e.PolyType.ptClip&&e.Error("AddPath: Open paths must be subject."):O||e.Error("AddPath: Open paths have been disabled.");var N=s.length-1;if(O)for(;N>0&&e.IntPoint.op_Equality(s[N],s[0]);)--N;for(;N>0&&e.IntPoint.op_Equality(s[N],s[N-1]);)--N;if(O&&N<2||!O&&N<1)return!1;for(var X=new Array(),k=0;k<=N;k++)X.push(new e.TEdge());var _=!0;X[1].Curr.X=s[1].X,X[1].Curr.Y=s[1].Y,e.use_xyz&&(X[1].Curr.Z=s[1].Z);var ft={Value:this.m_UseFullRange};this.RangeTest(s[0],ft),this.m_UseFullRange=ft.Value,ft.Value=this.m_UseFullRange,this.RangeTest(s[N],ft),this.m_UseFullRange=ft.Value,this.InitEdge(X[0],X[1],X[N],s[0]),this.InitEdge(X[N],X[0],X[N-1],s[N]);for(var k=N-1;k>=1;--k)ft.Value=this.m_UseFullRange,this.RangeTest(s[k],ft),this.m_UseFullRange=ft.Value,this.InitEdge(X[k],X[k+1],X[k-1],s[k]);for(var ht=X[0],Ct=ht,wt=ht;;){if(Ct.Curr===Ct.Next.Curr&&(O||Ct.Next!==ht)){if(Ct===Ct.Next)break;Ct===ht&&(ht=Ct.Next),Ct=this.RemoveEdge(Ct),wt=Ct;continue;}if(Ct.Prev===Ct.Next)break;if(O&&e.ClipperBase.SlopesEqual4(Ct.Prev.Curr,Ct.Curr,Ct.Next.Curr,this.m_UseFullRange)&&(!this.PreserveCollinear||!this.Pt2IsBetweenPt1AndPt3(Ct.Prev.Curr,Ct.Curr,Ct.Next.Curr))){Ct===ht&&(ht=Ct.Next),Ct=this.RemoveEdge(Ct),Ct=Ct.Prev,wt=Ct;continue;}if(Ct=Ct.Next,Ct===wt||!O&&Ct.Next===ht)break;}if(!O&&Ct===Ct.Next||O&&Ct.Prev===Ct.Next)return!1;O||(this.m_HasOpenPaths=!0,ht.Prev.OutIdx=e.ClipperBase.Skip),Ct=ht;do this.InitEdge2(Ct,m),Ct=Ct.Next,_&&Ct.Curr.Y!==ht.Curr.Y&&(_=!1);while(Ct!==ht);if(_){if(O)return!1;Ct.Prev.OutIdx=e.ClipperBase.Skip;var Lt=new e.LocalMinima();for(Lt.Next=null,Lt.Y=Ct.Bot.Y,Lt.LeftBound=null,Lt.RightBound=Ct,Lt.RightBound.Side=e.EdgeSide.esRight,Lt.RightBound.WindDelta=0;Ct.Bot.X!==Ct.Prev.Top.X&&this.ReverseHorizontal(Ct),Ct.Next.OutIdx!==e.ClipperBase.Skip;)Ct.NextInLML=Ct.Next,Ct=Ct.Next;return this.InsertLocalMinima(Lt),this.m_edges.push(X),!0;}this.m_edges.push(X);var Bt,Yt=null;for(e.IntPoint.op_Equality(Ct.Prev.Bot,Ct.Prev.Top)&&(Ct=Ct.Next);Ct=this.FindNextLocMin(Ct),Ct!==Yt;){Yt===null&&(Yt=Ct);var Lt=new e.LocalMinima();Lt.Next=null,Lt.Y=Ct.Bot.Y,Ct.Dx<Ct.Prev.Dx?(Lt.LeftBound=Ct.Prev,Lt.RightBound=Ct,Bt=!1):(Lt.LeftBound=Ct,Lt.RightBound=Ct.Prev,Bt=!0),Lt.LeftBound.Side=e.EdgeSide.esLeft,Lt.RightBound.Side=e.EdgeSide.esRight,O?Lt.LeftBound.Next===Lt.RightBound?Lt.LeftBound.WindDelta=-1:Lt.LeftBound.WindDelta=1:Lt.LeftBound.WindDelta=0,Lt.RightBound.WindDelta=-Lt.LeftBound.WindDelta,Ct=this.ProcessBound(Lt.LeftBound,Bt),Ct.OutIdx===e.ClipperBase.Skip&&(Ct=this.ProcessBound(Ct,Bt));var Ht=this.ProcessBound(Lt.RightBound,!Bt);Ht.OutIdx===e.ClipperBase.Skip&&(Ht=this.ProcessBound(Ht,!Bt)),Lt.LeftBound.OutIdx===e.ClipperBase.Skip?Lt.LeftBound=null:Lt.RightBound.OutIdx===e.ClipperBase.Skip&&(Lt.RightBound=null),this.InsertLocalMinima(Lt),Bt||(Ct=Ht);}return!0;},e.ClipperBase.prototype.AddPaths=function(s,m,O){for(var N=!1,X=0,k=s.length;X<k;++X)this.AddPath(s[X],m,O)&&(N=!0);return N;},e.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(s,m,O){return e.IntPoint.op_Equality(s,O)||e.IntPoint.op_Equality(s,m)||e.IntPoint.op_Equality(O,m)?!1:s.X!==O.X?m.X>s.X==m.X<O.X:m.Y>s.Y==m.Y<O.Y;},e.ClipperBase.prototype.RemoveEdge=function(s){s.Prev.Next=s.Next,s.Next.Prev=s.Prev;var m=s.Next;return s.Prev=null,m;},e.ClipperBase.prototype.SetDx=function(s){s.Delta.X=s.Top.X-s.Bot.X,s.Delta.Y=s.Top.Y-s.Bot.Y,s.Delta.Y===0?s.Dx=e.ClipperBase.horizontal:s.Dx=s.Delta.X/s.Delta.Y;},e.ClipperBase.prototype.InsertLocalMinima=function(s){if(this.m_MinimaList===null)this.m_MinimaList=s;else if(s.Y>=this.m_MinimaList.Y)s.Next=this.m_MinimaList,this.m_MinimaList=s;else{for(var m=this.m_MinimaList;m.Next!==null&&s.Y<m.Next.Y;)m=m.Next;s.Next=m.Next,m.Next=s;}},e.ClipperBase.prototype.PopLocalMinima=function(s,m){return m.v=this.m_CurrentLM,this.m_CurrentLM!==null&&this.m_CurrentLM.Y===s?(this.m_CurrentLM=this.m_CurrentLM.Next,!0):!1;},e.ClipperBase.prototype.ReverseHorizontal=function(s){var m=s.Top.X;s.Top.X=s.Bot.X,s.Bot.X=m,e.use_xyz&&(m=s.Top.Z,s.Top.Z=s.Bot.Z,s.Bot.Z=m);},e.ClipperBase.prototype.Reset=function(){if(this.m_CurrentLM=this.m_MinimaList,this.m_CurrentLM!==null){this.m_Scanbeam=null;for(var s=this.m_MinimaList;s!==null;){this.InsertScanbeam(s.Y);var m=s.LeftBound;m!==null&&(m.Curr.X=m.Bot.X,m.Curr.Y=m.Bot.Y,e.use_xyz&&(m.Curr.Z=m.Bot.Z),m.OutIdx=e.ClipperBase.Unassigned),m=s.RightBound,m!==null&&(m.Curr.X=m.Bot.X,m.Curr.Y=m.Bot.Y,e.use_xyz&&(m.Curr.Z=m.Bot.Z),m.OutIdx=e.ClipperBase.Unassigned),s=s.Next;}this.m_ActiveEdges=null;}},e.ClipperBase.prototype.InsertScanbeam=function(s){if(this.m_Scanbeam===null)this.m_Scanbeam=new e.Scanbeam(),this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=s;else if(s>this.m_Scanbeam.Y){var m=new e.Scanbeam();m.Y=s,m.Next=this.m_Scanbeam,this.m_Scanbeam=m;}else{for(var O=this.m_Scanbeam;O.Next!==null&&s<=O.Next.Y;)O=O.Next;if(s===O.Y)return;var N=new e.Scanbeam();N.Y=s,N.Next=O.Next,O.Next=N;}},e.ClipperBase.prototype.PopScanbeam=function(s){return this.m_Scanbeam===null?(s.v=0,!1):(s.v=this.m_Scanbeam.Y,this.m_Scanbeam=this.m_Scanbeam.Next,!0);},e.ClipperBase.prototype.LocalMinimaPending=function(){return this.m_CurrentLM!==null;},e.ClipperBase.prototype.CreateOutRec=function(){var s=new e.OutRec();return s.Idx=e.ClipperBase.Unassigned,s.IsHole=!1,s.IsOpen=!1,s.FirstLeft=null,s.Pts=null,s.BottomPt=null,s.PolyNode=null,this.m_PolyOuts.push(s),s.Idx=this.m_PolyOuts.length-1,s;},e.ClipperBase.prototype.DisposeOutRec=function(s){var m=this.m_PolyOuts[s];m.Pts=null,m=null,this.m_PolyOuts[s]=null;},e.ClipperBase.prototype.UpdateEdgeIntoAEL=function(s){s.NextInLML===null&&e.Error("UpdateEdgeIntoAEL: invalid call");var m=s.PrevInAEL,O=s.NextInAEL;return s.NextInLML.OutIdx=s.OutIdx,m!==null?m.NextInAEL=s.NextInLML:this.m_ActiveEdges=s.NextInLML,O!==null&&(O.PrevInAEL=s.NextInLML),s.NextInLML.Side=s.Side,s.NextInLML.WindDelta=s.WindDelta,s.NextInLML.WindCnt=s.WindCnt,s.NextInLML.WindCnt2=s.WindCnt2,s=s.NextInLML,s.Curr.X=s.Bot.X,s.Curr.Y=s.Bot.Y,s.PrevInAEL=m,s.NextInAEL=O,e.ClipperBase.IsHorizontal(s)||this.InsertScanbeam(s.Top.Y),s;},e.ClipperBase.prototype.SwapPositionsInAEL=function(s,m){if(!(s.NextInAEL===s.PrevInAEL||m.NextInAEL===m.PrevInAEL)){if(s.NextInAEL===m){var O=m.NextInAEL;O!==null&&(O.PrevInAEL=s);var N=s.PrevInAEL;N!==null&&(N.NextInAEL=m),m.PrevInAEL=N,m.NextInAEL=s,s.PrevInAEL=m,s.NextInAEL=O;}else if(m.NextInAEL===s){var X=s.NextInAEL;X!==null&&(X.PrevInAEL=m);var k=m.PrevInAEL;k!==null&&(k.NextInAEL=s),s.PrevInAEL=k,s.NextInAEL=m,m.PrevInAEL=s,m.NextInAEL=X;}else{var _=s.NextInAEL,ft=s.PrevInAEL;s.NextInAEL=m.NextInAEL,s.NextInAEL!==null&&(s.NextInAEL.PrevInAEL=s),s.PrevInAEL=m.PrevInAEL,s.PrevInAEL!==null&&(s.PrevInAEL.NextInAEL=s),m.NextInAEL=_,m.NextInAEL!==null&&(m.NextInAEL.PrevInAEL=m),m.PrevInAEL=ft,m.PrevInAEL!==null&&(m.PrevInAEL.NextInAEL=m);}s.PrevInAEL===null?this.m_ActiveEdges=s:m.PrevInAEL===null&&(this.m_ActiveEdges=m);}},e.ClipperBase.prototype.DeleteFromAEL=function(s){var m=s.PrevInAEL,O=s.NextInAEL;m===null&&O===null&&s!==this.m_ActiveEdges||(m!==null?m.NextInAEL=O:this.m_ActiveEdges=O,O!==null&&(O.PrevInAEL=m),s.NextInAEL=null,s.PrevInAEL=null);},e.Clipper=function(s){_typeof(s)>"u"&&(s=0),this.m_PolyOuts=null,this.m_ClipType=e.ClipType.ctIntersection,this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=null,this.m_IntersectNodeComparer=null,this.m_ExecuteLocked=!1,this.m_ClipFillType=e.PolyFillType.pftEvenOdd,this.m_SubjFillType=e.PolyFillType.pftEvenOdd,this.m_Joins=null,this.m_GhostJoins=null,this.m_UsingPolyTree=!1,this.ReverseSolution=!1,this.StrictlySimple=!1,e.ClipperBase.call(this),this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=new Array(),this.m_IntersectNodeComparer=e.MyIntersectNodeSort.Compare,this.m_ExecuteLocked=!1,this.m_UsingPolyTree=!1,this.m_PolyOuts=new Array(),this.m_Joins=new Array(),this.m_GhostJoins=new Array(),this.ReverseSolution=(1&s)!==0,this.StrictlySimple=(2&s)!==0,this.PreserveCollinear=(4&s)!==0,e.use_xyz&&(this.ZFillFunction=null);},e.Clipper.ioReverseSolution=1,e.Clipper.ioStrictlySimple=2,e.Clipper.ioPreserveCollinear=4,e.Clipper.prototype.Clear=function(){this.m_edges.length!==0&&(this.DisposeAllPolyPts(),e.ClipperBase.prototype.Clear.call(this));},e.Clipper.prototype.InsertMaxima=function(s){var m=new e.Maxima();if(m.X=s,this.m_Maxima===null)this.m_Maxima=m,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(s<this.m_Maxima.X)m.Next=this.m_Maxima,m.Prev=null,this.m_Maxima=m;else{for(var O=this.m_Maxima;O.Next!==null&&s>=O.Next.X;)O=O.Next;if(s===O.X)return;m.Next=O.Next,m.Prev=O,O.Next!==null&&(O.Next.Prev=m),O.Next=m;}},e.Clipper.prototype.Execute=function(){var s=arguments,m=s.length,O=s[1]instanceof e.PolyTree;if(m===4&&!O){var N=s[0],X=s[1],k=s[2],_=s[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&e.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,e.Clear(X),this.m_SubjFillType=k,this.m_ClipFillType=_,this.m_ClipType=N,this.m_UsingPolyTree=!1;try{var ft=this.ExecuteInternal();ft&&this.BuildResult(X);}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1;}return ft;}else if(m===4&&O){var N=s[0],ht=s[1],k=s[2],_=s[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=k,this.m_ClipFillType=_,this.m_ClipType=N,this.m_UsingPolyTree=!0;try{var ft=this.ExecuteInternal();ft&&this.BuildResult2(ht);}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1;}return ft;}else if(m===2&&!O){var N=s[0],X=s[1];return this.Execute(N,X,e.PolyFillType.pftEvenOdd,e.PolyFillType.pftEvenOdd);}else if(m===2&&O){var N=s[0],ht=s[1];return this.Execute(N,ht,e.PolyFillType.pftEvenOdd,e.PolyFillType.pftEvenOdd);}},e.Clipper.prototype.FixHoleLinkage=function(s){if(!(s.FirstLeft===null||s.IsHole!==s.FirstLeft.IsHole&&s.FirstLeft.Pts!==null)){for(var m=s.FirstLeft;m!==null&&(m.IsHole===s.IsHole||m.Pts===null);)m=m.FirstLeft;s.FirstLeft=m;}},e.Clipper.prototype.ExecuteInternal=function(){try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var s={},m={};if(!this.PopScanbeam(s))return!1;for(this.InsertLocalMinimaIntoAEL(s.v);this.PopScanbeam(m)||this.LocalMinimaPending();){if(this.ProcessHorizontals(),this.m_GhostJoins.length=0,!this.ProcessIntersections(m.v))return!1;this.ProcessEdgesAtTopOfScanbeam(m.v),s.v=m.v,this.InsertLocalMinimaIntoAEL(s.v);}var O,N,X;for(N=0,X=this.m_PolyOuts.length;N<X;N++)O=this.m_PolyOuts[N],!(O.Pts===null||O.IsOpen)&&(O.IsHole^this.ReverseSolution)==this.Area$1(O)>0&&this.ReversePolyPtLinks(O.Pts);for(this.JoinCommonEdges(),N=0,X=this.m_PolyOuts.length;N<X;N++)O=this.m_PolyOuts[N],O.Pts!==null&&(O.IsOpen?this.FixupOutPolyline(O):this.FixupOutPolygon(O));return this.StrictlySimple&&this.DoSimplePolygons(),!0;}finally{this.m_Joins.length=0,this.m_GhostJoins.length=0;}},e.Clipper.prototype.DisposeAllPolyPts=function(){for(var s=0,m=this.m_PolyOuts.length;s<m;++s)this.DisposeOutRec(s);e.Clear(this.m_PolyOuts);},e.Clipper.prototype.AddJoin=function(s,m,O){var N=new e.Join();N.OutPt1=s,N.OutPt2=m,N.OffPt.X=O.X,N.OffPt.Y=O.Y,e.use_xyz&&(N.OffPt.Z=O.Z),this.m_Joins.push(N);},e.Clipper.prototype.AddGhostJoin=function(s,m){var O=new e.Join();O.OutPt1=s,O.OffPt.X=m.X,O.OffPt.Y=m.Y,e.use_xyz&&(O.OffPt.Z=m.Z),this.m_GhostJoins.push(O);},e.Clipper.prototype.SetZ=function(s,m,O){if(this.ZFillFunction!==null){if(s.Z!==0||this.ZFillFunction===null)return;e.IntPoint.op_Equality(s,m.Bot)?s.Z=m.Bot.Z:e.IntPoint.op_Equality(s,m.Top)?s.Z=m.Top.Z:e.IntPoint.op_Equality(s,O.Bot)?s.Z=O.Bot.Z:e.IntPoint.op_Equality(s,O.Top)?s.Z=O.Top.Z:this.ZFillFunction(m.Bot,m.Top,O.Bot,O.Top,s);}},e.Clipper.prototype.InsertLocalMinimaIntoAEL=function(s){for(var m={},O,N;this.PopLocalMinima(s,m);){O=m.v.LeftBound,N=m.v.RightBound;var X=null;if(O===null?(this.InsertEdgeIntoAEL(N,null),this.SetWindingCount(N),this.IsContributing(N)&&(X=this.AddOutPt(N,N.Bot))):N===null?(this.InsertEdgeIntoAEL(O,null),this.SetWindingCount(O),this.IsContributing(O)&&(X=this.AddOutPt(O,O.Bot)),this.InsertScanbeam(O.Top.Y)):(this.InsertEdgeIntoAEL(O,null),this.InsertEdgeIntoAEL(N,O),this.SetWindingCount(O),N.WindCnt=O.WindCnt,N.WindCnt2=O.WindCnt2,this.IsContributing(O)&&(X=this.AddLocalMinPoly(O,N,O.Bot)),this.InsertScanbeam(O.Top.Y)),N!==null&&(e.ClipperBase.IsHorizontal(N)?(N.NextInLML!==null&&this.InsertScanbeam(N.NextInLML.Top.Y),this.AddEdgeToSEL(N)):this.InsertScanbeam(N.Top.Y)),!(O===null||N===null)){if(X!==null&&e.ClipperBase.IsHorizontal(N)&&this.m_GhostJoins.length>0&&N.WindDelta!==0)for(var k=0,_=this.m_GhostJoins.length;k<_;k++){var ft=this.m_GhostJoins[k];this.HorzSegmentsOverlap(ft.OutPt1.Pt.X,ft.OffPt.X,N.Bot.X,N.Top.X)&&this.AddJoin(ft.OutPt1,X,ft.OffPt);}if(O.OutIdx>=0&&O.PrevInAEL!==null&&O.PrevInAEL.Curr.X===O.Bot.X&&O.PrevInAEL.OutIdx>=0&&e.ClipperBase.SlopesEqual5(O.PrevInAEL.Curr,O.PrevInAEL.Top,O.Curr,O.Top,this.m_UseFullRange)&&O.WindDelta!==0&&O.PrevInAEL.WindDelta!==0){var ht=this.AddOutPt(O.PrevInAEL,O.Bot);this.AddJoin(X,ht,O.Top);}if(O.NextInAEL!==N){if(N.OutIdx>=0&&N.PrevInAEL.OutIdx>=0&&e.ClipperBase.SlopesEqual5(N.PrevInAEL.Curr,N.PrevInAEL.Top,N.Curr,N.Top,this.m_UseFullRange)&&N.WindDelta!==0&&N.PrevInAEL.WindDelta!==0){var ht=this.AddOutPt(N.PrevInAEL,N.Bot);this.AddJoin(X,ht,N.Top);}var Ct=O.NextInAEL;if(Ct!==null)for(;Ct!==N;)this.IntersectEdges(N,Ct,O.Curr),Ct=Ct.NextInAEL;}}}},e.Clipper.prototype.InsertEdgeIntoAEL=function(s,m){if(this.m_ActiveEdges===null)s.PrevInAEL=null,s.NextInAEL=null,this.m_ActiveEdges=s;else if(m===null&&this.E2InsertsBeforeE1(this.m_ActiveEdges,s))s.PrevInAEL=null,s.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=s,this.m_ActiveEdges=s;else{for(m===null&&(m=this.m_ActiveEdges);m.NextInAEL!==null&&!this.E2InsertsBeforeE1(m.NextInAEL,s);)m=m.NextInAEL;s.NextInAEL=m.NextInAEL,m.NextInAEL!==null&&(m.NextInAEL.PrevInAEL=s),s.PrevInAEL=m,m.NextInAEL=s;}},e.Clipper.prototype.E2InsertsBeforeE1=function(s,m){return m.Curr.X===s.Curr.X?m.Top.Y>s.Top.Y?m.Top.X<e.Clipper.TopX(s,m.Top.Y):s.Top.X>e.Clipper.TopX(m,s.Top.Y):m.Curr.X<s.Curr.X;},e.Clipper.prototype.IsEvenOddFillType=function(s){return s.PolyTyp===e.PolyType.ptSubject?this.m_SubjFillType===e.PolyFillType.pftEvenOdd:this.m_ClipFillType===e.PolyFillType.pftEvenOdd;},e.Clipper.prototype.IsEvenOddAltFillType=function(s){return s.PolyTyp===e.PolyType.ptSubject?this.m_ClipFillType===e.PolyFillType.pftEvenOdd:this.m_SubjFillType===e.PolyFillType.pftEvenOdd;},e.Clipper.prototype.IsContributing=function(s){var m,O;switch(s.PolyTyp===e.PolyType.ptSubject?(m=this.m_SubjFillType,O=this.m_ClipFillType):(m=this.m_ClipFillType,O=this.m_SubjFillType),m){case e.PolyFillType.pftEvenOdd:if(s.WindDelta===0&&s.WindCnt!==1)return!1;break;case e.PolyFillType.pftNonZero:if(Math.abs(s.WindCnt)!==1)return!1;break;case e.PolyFillType.pftPositive:if(s.WindCnt!==1)return!1;break;default:if(s.WindCnt!==-1)return!1;break;}switch(this.m_ClipType){case e.ClipType.ctIntersection:switch(O){case e.PolyFillType.pftEvenOdd:case e.PolyFillType.pftNonZero:return s.WindCnt2!==0;case e.PolyFillType.pftPositive:return s.WindCnt2>0;default:return s.WindCnt2<0;}case e.ClipType.ctUnion:switch(O){case e.PolyFillType.pftEvenOdd:case e.PolyFillType.pftNonZero:return s.WindCnt2===0;case e.PolyFillType.pftPositive:return s.WindCnt2<=0;default:return s.WindCnt2>=0;}case e.ClipType.ctDifference:if(s.PolyTyp===e.PolyType.ptSubject)switch(O){case e.PolyFillType.pftEvenOdd:case e.PolyFillType.pftNonZero:return s.WindCnt2===0;case e.PolyFillType.pftPositive:return s.WindCnt2<=0;default:return s.WindCnt2>=0;}else switch(O){case e.PolyFillType.pftEvenOdd:case e.PolyFillType.pftNonZero:return s.WindCnt2!==0;case e.PolyFillType.pftPositive:return s.WindCnt2>0;default:return s.WindCnt2<0;}case e.ClipType.ctXor:if(s.WindDelta===0)switch(O){case e.PolyFillType.pftEvenOdd:case e.PolyFillType.pftNonZero:return s.WindCnt2===0;case e.PolyFillType.pftPositive:return s.WindCnt2<=0;default:return s.WindCnt2>=0;}else return!0;}return!0;},e.Clipper.prototype.SetWindingCount=function(s){for(var m=s.PrevInAEL;m!==null&&(m.PolyTyp!==s.PolyTyp||m.WindDelta===0);)m=m.PrevInAEL;if(m===null){var O=s.PolyTyp===e.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;s.WindDelta===0?s.WindCnt=O===e.PolyFillType.pftNegative?-1:1:s.WindCnt=s.WindDelta,s.WindCnt2=0,m=this.m_ActiveEdges;}else if(s.WindDelta===0&&this.m_ClipType!==e.ClipType.ctUnion)s.WindCnt=1,s.WindCnt2=m.WindCnt2,m=m.NextInAEL;else if(this.IsEvenOddFillType(s)){if(s.WindDelta===0){for(var N=!0,X=m.PrevInAEL;X!==null;)X.PolyTyp===m.PolyTyp&&X.WindDelta!==0&&(N=!N),X=X.PrevInAEL;s.WindCnt=N?0:1;}else s.WindCnt=s.WindDelta;s.WindCnt2=m.WindCnt2,m=m.NextInAEL;}else m.WindCnt*m.WindDelta<0?Math.abs(m.WindCnt)>1?m.WindDelta*s.WindDelta<0?s.WindCnt=m.WindCnt:s.WindCnt=m.WindCnt+s.WindDelta:s.WindCnt=s.WindDelta===0?1:s.WindDelta:s.WindDelta===0?s.WindCnt=m.WindCnt<0?m.WindCnt-1:m.WindCnt+1:m.WindDelta*s.WindDelta<0?s.WindCnt=m.WindCnt:s.WindCnt=m.WindCnt+s.WindDelta,s.WindCnt2=m.WindCnt2,m=m.NextInAEL;if(this.IsEvenOddAltFillType(s))for(;m!==s;)m.WindDelta!==0&&(s.WindCnt2=s.WindCnt2===0?1:0),m=m.NextInAEL;else for(;m!==s;)s.WindCnt2+=m.WindDelta,m=m.NextInAEL;},e.Clipper.prototype.AddEdgeToSEL=function(s){this.m_SortedEdges===null?(this.m_SortedEdges=s,s.PrevInSEL=null,s.NextInSEL=null):(s.NextInSEL=this.m_SortedEdges,s.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=s,this.m_SortedEdges=s);},e.Clipper.prototype.PopEdgeFromSEL=function(s){if(s.v=this.m_SortedEdges,s.v===null)return!1;var m=s.v;return this.m_SortedEdges=s.v.NextInSEL,this.m_SortedEdges!==null&&(this.m_SortedEdges.PrevInSEL=null),m.NextInSEL=null,m.PrevInSEL=null,!0;},e.Clipper.prototype.CopyAELToSEL=function(){var s=this.m_ActiveEdges;for(this.m_SortedEdges=s;s!==null;)s.PrevInSEL=s.PrevInAEL,s.NextInSEL=s.NextInAEL,s=s.NextInAEL;},e.Clipper.prototype.SwapPositionsInSEL=function(s,m){if(!(s.NextInSEL===null&&s.PrevInSEL===null)&&!(m.NextInSEL===null&&m.PrevInSEL===null)){if(s.NextInSEL===m){var O=m.NextInSEL;O!==null&&(O.PrevInSEL=s);var N=s.PrevInSEL;N!==null&&(N.NextInSEL=m),m.PrevInSEL=N,m.NextInSEL=s,s.PrevInSEL=m,s.NextInSEL=O;}else if(m.NextInSEL===s){var O=s.NextInSEL;O!==null&&(O.PrevInSEL=m);var N=m.PrevInSEL;N!==null&&(N.NextInSEL=s),s.PrevInSEL=N,s.NextInSEL=m,m.PrevInSEL=s,m.NextInSEL=O;}else{var O=s.NextInSEL,N=s.PrevInSEL;s.NextInSEL=m.NextInSEL,s.NextInSEL!==null&&(s.NextInSEL.PrevInSEL=s),s.PrevInSEL=m.PrevInSEL,s.PrevInSEL!==null&&(s.PrevInSEL.NextInSEL=s),m.NextInSEL=O,m.NextInSEL!==null&&(m.NextInSEL.PrevInSEL=m),m.PrevInSEL=N,m.PrevInSEL!==null&&(m.PrevInSEL.NextInSEL=m);}s.PrevInSEL===null?this.m_SortedEdges=s:m.PrevInSEL===null&&(this.m_SortedEdges=m);}},e.Clipper.prototype.AddLocalMaxPoly=function(s,m,O){this.AddOutPt(s,O),m.WindDelta===0&&this.AddOutPt(m,O),s.OutIdx===m.OutIdx?(s.OutIdx=-1,m.OutIdx=-1):s.OutIdx<m.OutIdx?this.AppendPolygon(s,m):this.AppendPolygon(m,s);},e.Clipper.prototype.AddLocalMinPoly=function(s,m,O){var N,X,k;if(e.ClipperBase.IsHorizontal(m)||s.Dx>m.Dx?(N=this.AddOutPt(s,O),m.OutIdx=s.OutIdx,s.Side=e.EdgeSide.esLeft,m.Side=e.EdgeSide.esRight,X=s,X.PrevInAEL===m?k=m.PrevInAEL:k=X.PrevInAEL):(N=this.AddOutPt(m,O),s.OutIdx=m.OutIdx,s.Side=e.EdgeSide.esRight,m.Side=e.EdgeSide.esLeft,X=m,X.PrevInAEL===s?k=s.PrevInAEL:k=X.PrevInAEL),k!==null&&k.OutIdx>=0&&k.Top.Y<O.Y&&X.Top.Y<O.Y){var _=e.Clipper.TopX(k,O.Y),ft=e.Clipper.TopX(X,O.Y);if(_===ft&&X.WindDelta!==0&&k.WindDelta!==0&&e.ClipperBase.SlopesEqual5(new e.IntPoint2(_,O.Y),k.Top,new e.IntPoint2(ft,O.Y),X.Top,this.m_UseFullRange)){var ht=this.AddOutPt(k,O);this.AddJoin(N,ht,X.Top);}}return N;},e.Clipper.prototype.AddOutPt=function(s,m){if(s.OutIdx<0){var O=this.CreateOutRec();O.IsOpen=s.WindDelta===0;var N=new e.OutPt();return O.Pts=N,N.Idx=O.Idx,N.Pt.X=m.X,N.Pt.Y=m.Y,e.use_xyz&&(N.Pt.Z=m.Z),N.Next=N,N.Prev=N,O.IsOpen||this.SetHoleState(s,O),s.OutIdx=O.Idx,N;}else{var O=this.m_PolyOuts[s.OutIdx],X=O.Pts,k=s.Side===e.EdgeSide.esLeft;if(k&&e.IntPoint.op_Equality(m,X.Pt))return X;if(!k&&e.IntPoint.op_Equality(m,X.Prev.Pt))return X.Prev;var N=new e.OutPt();return N.Idx=O.Idx,N.Pt.X=m.X,N.Pt.Y=m.Y,e.use_xyz&&(N.Pt.Z=m.Z),N.Next=X,N.Prev=X.Prev,N.Prev.Next=N,X.Prev=N,k&&(O.Pts=N),N;}},e.Clipper.prototype.GetLastOutPt=function(s){var m=this.m_PolyOuts[s.OutIdx];return s.Side===e.EdgeSide.esLeft?m.Pts:m.Pts.Prev;},e.Clipper.prototype.SwapPoints=function(s,m){var O=new e.IntPoint1(s.Value);s.Value.X=m.Value.X,s.Value.Y=m.Value.Y,e.use_xyz&&(s.Value.Z=m.Value.Z),m.Value.X=O.X,m.Value.Y=O.Y,e.use_xyz&&(m.Value.Z=O.Z);},e.Clipper.prototype.HorzSegmentsOverlap=function(s,m,O,N){var X;return s>m&&(X=s,s=m,m=X),O>N&&(X=O,O=N,N=X),s<N&&O<m;},e.Clipper.prototype.SetHoleState=function(s,m){for(var O=s.PrevInAEL,N=null;O!==null;)O.OutIdx>=0&&O.WindDelta!==0&&(N===null?N=O:N.OutIdx===O.OutIdx&&(N=null)),O=O.PrevInAEL;N===null?(m.FirstLeft=null,m.IsHole=!1):(m.FirstLeft=this.m_PolyOuts[N.OutIdx],m.IsHole=!m.FirstLeft.IsHole);},e.Clipper.prototype.GetDx=function(s,m){return s.Y===m.Y?e.ClipperBase.horizontal:(m.X-s.X)/(m.Y-s.Y);},e.Clipper.prototype.FirstIsBottomPt=function(s,m){for(var O=s.Prev;e.IntPoint.op_Equality(O.Pt,s.Pt)&&O!==s;)O=O.Prev;var N=Math.abs(this.GetDx(s.Pt,O.Pt));for(O=s.Next;e.IntPoint.op_Equality(O.Pt,s.Pt)&&O!==s;)O=O.Next;var X=Math.abs(this.GetDx(s.Pt,O.Pt));for(O=m.Prev;e.IntPoint.op_Equality(O.Pt,m.Pt)&&O!==m;)O=O.Prev;var k=Math.abs(this.GetDx(m.Pt,O.Pt));for(O=m.Next;e.IntPoint.op_Equality(O.Pt,m.Pt)&&O!==m;)O=O.Next;var _=Math.abs(this.GetDx(m.Pt,O.Pt));return Math.max(N,X)===Math.max(k,_)&&Math.min(N,X)===Math.min(k,_)?this.Area(s)>0:N>=k&&N>=_||X>=k&&X>=_;},e.Clipper.prototype.GetBottomPt=function(s){for(var m=null,O=s.Next;O!==s;)O.Pt.Y>s.Pt.Y?(s=O,m=null):O.Pt.Y===s.Pt.Y&&O.Pt.X<=s.Pt.X&&(O.Pt.X<s.Pt.X?(m=null,s=O):O.Next!==s&&O.Prev!==s&&(m=O)),O=O.Next;if(m!==null)for(;m!==O;)for(this.FirstIsBottomPt(O,m)||(s=m),m=m.Next;e.IntPoint.op_Inequality(m.Pt,s.Pt);)m=m.Next;return s;},e.Clipper.prototype.GetLowermostRec=function(s,m){s.BottomPt===null&&(s.BottomPt=this.GetBottomPt(s.Pts)),m.BottomPt===null&&(m.BottomPt=this.GetBottomPt(m.Pts));var O=s.BottomPt,N=m.BottomPt;return O.Pt.Y>N.Pt.Y?s:O.Pt.Y<N.Pt.Y?m:O.Pt.X<N.Pt.X?s:O.Pt.X>N.Pt.X||O.Next===O?m:N.Next===N||this.FirstIsBottomPt(O,N)?s:m;},e.Clipper.prototype.OutRec1RightOfOutRec2=function(s,m){do if(s=s.FirstLeft,s===m)return!0;while(s!==null);return!1;},e.Clipper.prototype.GetOutRec=function(s){for(var m=this.m_PolyOuts[s];m!==this.m_PolyOuts[m.Idx];)m=this.m_PolyOuts[m.Idx];return m;},e.Clipper.prototype.AppendPolygon=function(s,m){var O=this.m_PolyOuts[s.OutIdx],N=this.m_PolyOuts[m.OutIdx],X;this.OutRec1RightOfOutRec2(O,N)?X=N:this.OutRec1RightOfOutRec2(N,O)?X=O:X=this.GetLowermostRec(O,N);var k=O.Pts,_=k.Prev,ft=N.Pts,ht=ft.Prev;s.Side===e.EdgeSide.esLeft?m.Side===e.EdgeSide.esLeft?(this.ReversePolyPtLinks(ft),ft.Next=k,k.Prev=ft,_.Next=ht,ht.Prev=_,O.Pts=ht):(ht.Next=k,k.Prev=ht,ft.Prev=_,_.Next=ft,O.Pts=ft):m.Side===e.EdgeSide.esRight?(this.ReversePolyPtLinks(ft),_.Next=ht,ht.Prev=_,ft.Next=k,k.Prev=ft):(_.Next=ft,ft.Prev=_,k.Prev=ht,ht.Next=k),O.BottomPt=null,X===N&&(N.FirstLeft!==O&&(O.FirstLeft=N.FirstLeft),O.IsHole=N.IsHole),N.Pts=null,N.BottomPt=null,N.FirstLeft=O;var Ct=s.OutIdx,wt=m.OutIdx;s.OutIdx=-1,m.OutIdx=-1;for(var Lt=this.m_ActiveEdges;Lt!==null;){if(Lt.OutIdx===wt){Lt.OutIdx=Ct,Lt.Side=s.Side;break;}Lt=Lt.NextInAEL;}N.Idx=O.Idx;},e.Clipper.prototype.ReversePolyPtLinks=function(s){if(s!==null){var m,O;m=s;do O=m.Next,m.Next=m.Prev,m.Prev=O,m=O;while(m!==s);}},e.Clipper.SwapSides=function(s,m){var O=s.Side;s.Side=m.Side,m.Side=O;},e.Clipper.SwapPolyIndexes=function(s,m){var O=s.OutIdx;s.OutIdx=m.OutIdx,m.OutIdx=O;},e.Clipper.prototype.IntersectEdges=function(s,m,O){var N=s.OutIdx>=0,X=m.OutIdx>=0;if(e.use_xyz&&this.SetZ(O,s,m),e.use_lines&&(s.WindDelta===0||m.WindDelta===0)){if(s.WindDelta===0&&m.WindDelta===0)return;s.PolyTyp===m.PolyTyp&&s.WindDelta!==m.WindDelta&&this.m_ClipType===e.ClipType.ctUnion?s.WindDelta===0?X&&(this.AddOutPt(s,O),N&&(s.OutIdx=-1)):N&&(this.AddOutPt(m,O),X&&(m.OutIdx=-1)):s.PolyTyp!==m.PolyTyp&&(s.WindDelta===0&&Math.abs(m.WindCnt)===1&&(this.m_ClipType!==e.ClipType.ctUnion||m.WindCnt2===0)?(this.AddOutPt(s,O),N&&(s.OutIdx=-1)):m.WindDelta===0&&Math.abs(s.WindCnt)===1&&(this.m_ClipType!==e.ClipType.ctUnion||s.WindCnt2===0)&&(this.AddOutPt(m,O),X&&(m.OutIdx=-1)));return;}if(s.PolyTyp===m.PolyTyp){if(this.IsEvenOddFillType(s)){var k=s.WindCnt;s.WindCnt=m.WindCnt,m.WindCnt=k;}else s.WindCnt+m.WindDelta===0?s.WindCnt=-s.WindCnt:s.WindCnt+=m.WindDelta,m.WindCnt-s.WindDelta===0?m.WindCnt=-m.WindCnt:m.WindCnt-=s.WindDelta;}else this.IsEvenOddFillType(m)?s.WindCnt2=s.WindCnt2===0?1:0:s.WindCnt2+=m.WindDelta,this.IsEvenOddFillType(s)?m.WindCnt2=m.WindCnt2===0?1:0:m.WindCnt2-=s.WindDelta;var _,ft,ht,Ct;s.PolyTyp===e.PolyType.ptSubject?(_=this.m_SubjFillType,ht=this.m_ClipFillType):(_=this.m_ClipFillType,ht=this.m_SubjFillType),m.PolyTyp===e.PolyType.ptSubject?(ft=this.m_SubjFillType,Ct=this.m_ClipFillType):(ft=this.m_ClipFillType,Ct=this.m_SubjFillType);var wt,Lt;switch(_){case e.PolyFillType.pftPositive:wt=s.WindCnt;break;case e.PolyFillType.pftNegative:wt=-s.WindCnt;break;default:wt=Math.abs(s.WindCnt);break;}switch(ft){case e.PolyFillType.pftPositive:Lt=m.WindCnt;break;case e.PolyFillType.pftNegative:Lt=-m.WindCnt;break;default:Lt=Math.abs(m.WindCnt);break;}if(N&&X)wt!==0&&wt!==1||Lt!==0&&Lt!==1||s.PolyTyp!==m.PolyTyp&&this.m_ClipType!==e.ClipType.ctXor?this.AddLocalMaxPoly(s,m,O):(this.AddOutPt(s,O),this.AddOutPt(m,O),e.Clipper.SwapSides(s,m),e.Clipper.SwapPolyIndexes(s,m));else if(N)(Lt===0||Lt===1)&&(this.AddOutPt(s,O),e.Clipper.SwapSides(s,m),e.Clipper.SwapPolyIndexes(s,m));else if(X)(wt===0||wt===1)&&(this.AddOutPt(m,O),e.Clipper.SwapSides(s,m),e.Clipper.SwapPolyIndexes(s,m));else if((wt===0||wt===1)&&(Lt===0||Lt===1)){var Bt,Yt;switch(ht){case e.PolyFillType.pftPositive:Bt=s.WindCnt2;break;case e.PolyFillType.pftNegative:Bt=-s.WindCnt2;break;default:Bt=Math.abs(s.WindCnt2);break;}switch(Ct){case e.PolyFillType.pftPositive:Yt=m.WindCnt2;break;case e.PolyFillType.pftNegative:Yt=-m.WindCnt2;break;default:Yt=Math.abs(m.WindCnt2);break;}if(s.PolyTyp!==m.PolyTyp)this.AddLocalMinPoly(s,m,O);else if(wt===1&&Lt===1)switch(this.m_ClipType){case e.ClipType.ctIntersection:Bt>0&&Yt>0&&this.AddLocalMinPoly(s,m,O);break;case e.ClipType.ctUnion:Bt<=0&&Yt<=0&&this.AddLocalMinPoly(s,m,O);break;case e.ClipType.ctDifference:(s.PolyTyp===e.PolyType.ptClip&&Bt>0&&Yt>0||s.PolyTyp===e.PolyType.ptSubject&&Bt<=0&&Yt<=0)&&this.AddLocalMinPoly(s,m,O);break;case e.ClipType.ctXor:this.AddLocalMinPoly(s,m,O);break;}else e.Clipper.SwapSides(s,m);}},e.Clipper.prototype.DeleteFromSEL=function(s){var m=s.PrevInSEL,O=s.NextInSEL;m===null&&O===null&&s!==this.m_SortedEdges||(m!==null?m.NextInSEL=O:this.m_SortedEdges=O,O!==null&&(O.PrevInSEL=m),s.NextInSEL=null,s.PrevInSEL=null);},e.Clipper.prototype.ProcessHorizontals=function(){for(var s={};this.PopEdgeFromSEL(s);)this.ProcessHorizontal(s.v);},e.Clipper.prototype.GetHorzDirection=function(s,m){s.Bot.X<s.Top.X?(m.Left=s.Bot.X,m.Right=s.Top.X,m.Dir=e.Direction.dLeftToRight):(m.Left=s.Top.X,m.Right=s.Bot.X,m.Dir=e.Direction.dRightToLeft);},e.Clipper.prototype.ProcessHorizontal=function(s){var m={Dir:null,Left:null,Right:null};this.GetHorzDirection(s,m);for(var O=m.Dir,N=m.Left,X=m.Right,k=s.WindDelta===0,_=s,ft=null;_.NextInLML!==null&&e.ClipperBase.IsHorizontal(_.NextInLML);)_=_.NextInLML;_.NextInLML===null&&(ft=this.GetMaximaPair(_));var ht=this.m_Maxima;if(ht!==null)if(O===e.Direction.dLeftToRight){for(;ht!==null&&ht.X<=s.Bot.X;)ht=ht.Next;ht!==null&&ht.X>=_.Top.X&&(ht=null);}else{for(;ht.Next!==null&&ht.Next.X<s.Bot.X;)ht=ht.Next;ht.X<=_.Top.X&&(ht=null);}for(var Ct=null;;){for(var wt=s===_,Lt=this.GetNextInAEL(s,O);Lt!==null;){if(ht!==null)if(O===e.Direction.dLeftToRight)for(;ht!==null&&ht.X<Lt.Curr.X;)s.OutIdx>=0&&!k&&this.AddOutPt(s,new e.IntPoint2(ht.X,s.Bot.Y)),ht=ht.Next;else for(;ht!==null&&ht.X>Lt.Curr.X;)s.OutIdx>=0&&!k&&this.AddOutPt(s,new e.IntPoint2(ht.X,s.Bot.Y)),ht=ht.Prev;if(O===e.Direction.dLeftToRight&&Lt.Curr.X>X||O===e.Direction.dRightToLeft&&Lt.Curr.X<N||Lt.Curr.X===s.Top.X&&s.NextInLML!==null&&Lt.Dx<s.NextInLML.Dx)break;if(s.OutIdx>=0&&!k){e.use_xyz&&(O===e.Direction.dLeftToRight?this.SetZ(Lt.Curr,s,Lt):this.SetZ(Lt.Curr,Lt,s)),Ct=this.AddOutPt(s,Lt.Curr);for(var Bt=this.m_SortedEdges;Bt!==null;){if(Bt.OutIdx>=0&&this.HorzSegmentsOverlap(s.Bot.X,s.Top.X,Bt.Bot.X,Bt.Top.X)){var Yt=this.GetLastOutPt(Bt);this.AddJoin(Yt,Ct,Bt.Top);}Bt=Bt.NextInSEL;}this.AddGhostJoin(Ct,s.Bot);}if(Lt===ft&&wt){s.OutIdx>=0&&this.AddLocalMaxPoly(s,ft,s.Top),this.DeleteFromAEL(s),this.DeleteFromAEL(ft);return;}if(O===e.Direction.dLeftToRight){var Ht=new e.IntPoint2(Lt.Curr.X,s.Curr.Y);this.IntersectEdges(s,Lt,Ht);}else{var Ht=new e.IntPoint2(Lt.Curr.X,s.Curr.Y);this.IntersectEdges(Lt,s,Ht);}var Vt=this.GetNextInAEL(Lt,O);this.SwapPositionsInAEL(s,Lt),Lt=Vt;}if(s.NextInLML===null||!e.ClipperBase.IsHorizontal(s.NextInLML))break;s=this.UpdateEdgeIntoAEL(s),s.OutIdx>=0&&this.AddOutPt(s,s.Bot),m={Dir:O,Left:N,Right:X},this.GetHorzDirection(s,m),O=m.Dir,N=m.Left,X=m.Right;}if(s.OutIdx>=0&&Ct===null){Ct=this.GetLastOutPt(s);for(var Bt=this.m_SortedEdges;Bt!==null;){if(Bt.OutIdx>=0&&this.HorzSegmentsOverlap(s.Bot.X,s.Top.X,Bt.Bot.X,Bt.Top.X)){var Yt=this.GetLastOutPt(Bt);this.AddJoin(Yt,Ct,Bt.Top);}Bt=Bt.NextInSEL;}this.AddGhostJoin(Ct,s.Top);}if(s.NextInLML!==null){if(s.OutIdx>=0){if(Ct=this.AddOutPt(s,s.Top),s=this.UpdateEdgeIntoAEL(s),s.WindDelta===0)return;var ee=s.PrevInAEL,Vt=s.NextInAEL;if(ee!==null&&ee.Curr.X===s.Bot.X&&ee.Curr.Y===s.Bot.Y&&ee.WindDelta===0&&ee.OutIdx>=0&&ee.Curr.Y>ee.Top.Y&&e.ClipperBase.SlopesEqual3(s,ee,this.m_UseFullRange)){var Yt=this.AddOutPt(ee,s.Bot);this.AddJoin(Ct,Yt,s.Top);}else if(Vt!==null&&Vt.Curr.X===s.Bot.X&&Vt.Curr.Y===s.Bot.Y&&Vt.WindDelta!==0&&Vt.OutIdx>=0&&Vt.Curr.Y>Vt.Top.Y&&e.ClipperBase.SlopesEqual3(s,Vt,this.m_UseFullRange)){var Yt=this.AddOutPt(Vt,s.Bot);this.AddJoin(Ct,Yt,s.Top);}}else s=this.UpdateEdgeIntoAEL(s);}else s.OutIdx>=0&&this.AddOutPt(s,s.Top),this.DeleteFromAEL(s);},e.Clipper.prototype.GetNextInAEL=function(s,m){return m===e.Direction.dLeftToRight?s.NextInAEL:s.PrevInAEL;},e.Clipper.prototype.IsMinima=function(s){return s!==null&&s.Prev.NextInLML!==s&&s.Next.NextInLML!==s;},e.Clipper.prototype.IsMaxima=function(s,m){return s!==null&&s.Top.Y===m&&s.NextInLML===null;},e.Clipper.prototype.IsIntermediate=function(s,m){return s.Top.Y===m&&s.NextInLML!==null;},e.Clipper.prototype.GetMaximaPair=function(s){return e.IntPoint.op_Equality(s.Next.Top,s.Top)&&s.Next.NextInLML===null?s.Next:e.IntPoint.op_Equality(s.Prev.Top,s.Top)&&s.Prev.NextInLML===null?s.Prev:null;},e.Clipper.prototype.GetMaximaPairEx=function(s){var m=this.GetMaximaPair(s);return m===null||m.OutIdx===e.ClipperBase.Skip||m.NextInAEL===m.PrevInAEL&&!e.ClipperBase.IsHorizontal(m)?null:m;},e.Clipper.prototype.ProcessIntersections=function(s){if(this.m_ActiveEdges===null)return!0;try{if(this.BuildIntersectList(s),this.m_IntersectList.length===0)return!0;if(this.m_IntersectList.length===1||this.FixupIntersectionOrder())this.ProcessIntersectList();else return!1;}catch(_unused23){this.m_SortedEdges=null,this.m_IntersectList.length=0,e.Error("ProcessIntersections error");}return this.m_SortedEdges=null,!0;},e.Clipper.prototype.BuildIntersectList=function(s){if(this.m_ActiveEdges!==null){var m=this.m_ActiveEdges;for(this.m_SortedEdges=m;m!==null;)m.PrevInSEL=m.PrevInAEL,m.NextInSEL=m.NextInAEL,m.Curr.X=e.Clipper.TopX(m,s),m=m.NextInAEL;for(var O=!0;O&&this.m_SortedEdges!==null;){for(O=!1,m=this.m_SortedEdges;m.NextInSEL!==null;){var N=m.NextInSEL,X=new e.IntPoint0();if(m.Curr.X>N.Curr.X){this.IntersectPoint(m,N,X),X.Y<s&&(X=new e.IntPoint2(e.Clipper.TopX(m,s),s));var k=new e.IntersectNode();k.Edge1=m,k.Edge2=N,k.Pt.X=X.X,k.Pt.Y=X.Y,e.use_xyz&&(k.Pt.Z=X.Z),this.m_IntersectList.push(k),this.SwapPositionsInSEL(m,N),O=!0;}else m=N;}if(m.PrevInSEL!==null)m.PrevInSEL.NextInSEL=null;else break;}this.m_SortedEdges=null;}},e.Clipper.prototype.EdgesAdjacent=function(s){return s.Edge1.NextInSEL===s.Edge2||s.Edge1.PrevInSEL===s.Edge2;},e.Clipper.IntersectNodeSort=function(s,m){return m.Pt.Y-s.Pt.Y;},e.Clipper.prototype.FixupIntersectionOrder=function(){this.m_IntersectList.sort(this.m_IntersectNodeComparer),this.CopyAELToSEL();for(var s=this.m_IntersectList.length,m=0;m<s;m++){if(!this.EdgesAdjacent(this.m_IntersectList[m])){for(var O=m+1;O<s&&!this.EdgesAdjacent(this.m_IntersectList[O]);)O++;if(O===s)return!1;var N=this.m_IntersectList[m];this.m_IntersectList[m]=this.m_IntersectList[O],this.m_IntersectList[O]=N;}this.SwapPositionsInSEL(this.m_IntersectList[m].Edge1,this.m_IntersectList[m].Edge2);}return!0;},e.Clipper.prototype.ProcessIntersectList=function(){for(var s=0,m=this.m_IntersectList.length;s<m;s++){var O=this.m_IntersectList[s];this.IntersectEdges(O.Edge1,O.Edge2,O.Pt),this.SwapPositionsInAEL(O.Edge1,O.Edge2);}this.m_IntersectList.length=0;};var $s=function $s(s){return s<0?Math.ceil(s-0.5):Math.round(s);},Gs=function Gs(s){return s<0?Math.ceil(s-0.5):Math.floor(s+0.5);},Hs=function Hs(s){return s<0?-Math.round(Math.abs(s)):Math.round(s);},Vs=function Vs(s){return s<0?(s-=0.5,s<-2147483648?Math.ceil(s):s|0):(s+=0.5,s>2147483647?Math.floor(s):s|0);};i.msie?e.Clipper.Round=$s:i.chromium?e.Clipper.Round=Hs:i.safari?e.Clipper.Round=Vs:e.Clipper.Round=Gs,e.Clipper.TopX=function(s,m){return m===s.Top.Y?s.Top.X:s.Bot.X+e.Clipper.Round(s.Dx*(m-s.Bot.Y));},e.Clipper.prototype.IntersectPoint=function(s,m,O){O.X=0,O.Y=0;var N,X;if(s.Dx===m.Dx){O.Y=s.Curr.Y,O.X=e.Clipper.TopX(s,O.Y);return;}if(s.Delta.X===0)O.X=s.Bot.X,e.ClipperBase.IsHorizontal(m)?O.Y=m.Bot.Y:(X=m.Bot.Y-m.Bot.X/m.Dx,O.Y=e.Clipper.Round(O.X/m.Dx+X));else if(m.Delta.X===0)O.X=m.Bot.X,e.ClipperBase.IsHorizontal(s)?O.Y=s.Bot.Y:(N=s.Bot.Y-s.Bot.X/s.Dx,O.Y=e.Clipper.Round(O.X/s.Dx+N));else{N=s.Bot.X-s.Bot.Y*s.Dx,X=m.Bot.X-m.Bot.Y*m.Dx;var k=(X-N)/(s.Dx-m.Dx);O.Y=e.Clipper.Round(k),Math.abs(s.Dx)<Math.abs(m.Dx)?O.X=e.Clipper.Round(s.Dx*k+N):O.X=e.Clipper.Round(m.Dx*k+X);}if(O.Y<s.Top.Y||O.Y<m.Top.Y){if(s.Top.Y>m.Top.Y)return O.Y=s.Top.Y,O.X=e.Clipper.TopX(m,s.Top.Y),O.X<s.Top.X;O.Y=m.Top.Y,Math.abs(s.Dx)<Math.abs(m.Dx)?O.X=e.Clipper.TopX(s,O.Y):O.X=e.Clipper.TopX(m,O.Y);}O.Y>s.Curr.Y&&(O.Y=s.Curr.Y,Math.abs(s.Dx)>Math.abs(m.Dx)?O.X=e.Clipper.TopX(m,O.Y):O.X=e.Clipper.TopX(s,O.Y));},e.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(s){for(var m=this.m_ActiveEdges;m!==null;){var O=this.IsMaxima(m,s);if(O){var N=this.GetMaximaPairEx(m);O=N===null||!e.ClipperBase.IsHorizontal(N);}if(O){this.StrictlySimple&&this.InsertMaxima(m.Top.X);var X=m.PrevInAEL;this.DoMaxima(m),X===null?m=this.m_ActiveEdges:m=X.NextInAEL;}else{if(this.IsIntermediate(m,s)&&e.ClipperBase.IsHorizontal(m.NextInLML)?(m=this.UpdateEdgeIntoAEL(m),m.OutIdx>=0&&this.AddOutPt(m,m.Bot),this.AddEdgeToSEL(m)):(m.Curr.X=e.Clipper.TopX(m,s),m.Curr.Y=s),e.use_xyz&&(m.Top.Y===s?m.Curr.Z=m.Top.Z:m.Bot.Y===s?m.Curr.Z=m.Bot.Z:m.Curr.Z=0),this.StrictlySimple){var X=m.PrevInAEL;if(m.OutIdx>=0&&m.WindDelta!==0&&X!==null&&X.OutIdx>=0&&X.Curr.X===m.Curr.X&&X.WindDelta!==0){var k=new e.IntPoint1(m.Curr);e.use_xyz&&this.SetZ(k,X,m);var _=this.AddOutPt(X,k),ft=this.AddOutPt(m,k);this.AddJoin(_,ft,k);}}m=m.NextInAEL;}}for(this.ProcessHorizontals(),this.m_Maxima=null,m=this.m_ActiveEdges;m!==null;){if(this.IsIntermediate(m,s)){var _=null;m.OutIdx>=0&&(_=this.AddOutPt(m,m.Top)),m=this.UpdateEdgeIntoAEL(m);var X=m.PrevInAEL,ht=m.NextInAEL;if(X!==null&&X.Curr.X===m.Bot.X&&X.Curr.Y===m.Bot.Y&&_!==null&&X.OutIdx>=0&&X.Curr.Y===X.Top.Y&&e.ClipperBase.SlopesEqual5(m.Curr,m.Top,X.Curr,X.Top,this.m_UseFullRange)&&m.WindDelta!==0&&X.WindDelta!==0){var ft=this.AddOutPt(ePrev2,m.Bot);this.AddJoin(_,ft,m.Top);}else if(ht!==null&&ht.Curr.X===m.Bot.X&&ht.Curr.Y===m.Bot.Y&&_!==null&&ht.OutIdx>=0&&ht.Curr.Y===ht.Top.Y&&e.ClipperBase.SlopesEqual5(m.Curr,m.Top,ht.Curr,ht.Top,this.m_UseFullRange)&&m.WindDelta!==0&&ht.WindDelta!==0){var ft=this.AddOutPt(ht,m.Bot);this.AddJoin(_,ft,m.Top);}}m=m.NextInAEL;}},e.Clipper.prototype.DoMaxima=function(s){var m=this.GetMaximaPairEx(s);if(m===null){s.OutIdx>=0&&this.AddOutPt(s,s.Top),this.DeleteFromAEL(s);return;}for(var O=s.NextInAEL;O!==null&&O!==m;)this.IntersectEdges(s,O,s.Top),this.SwapPositionsInAEL(s,O),O=s.NextInAEL;s.OutIdx===-1&&m.OutIdx===-1?(this.DeleteFromAEL(s),this.DeleteFromAEL(m)):s.OutIdx>=0&&m.OutIdx>=0?(s.OutIdx>=0&&this.AddLocalMaxPoly(s,m,s.Top),this.DeleteFromAEL(s),this.DeleteFromAEL(m)):e.use_lines&&s.WindDelta===0?(s.OutIdx>=0&&(this.AddOutPt(s,s.Top),s.OutIdx=e.ClipperBase.Unassigned),this.DeleteFromAEL(s),m.OutIdx>=0&&(this.AddOutPt(m,s.Top),m.OutIdx=e.ClipperBase.Unassigned),this.DeleteFromAEL(m)):e.Error("DoMaxima error");},e.Clipper.ReversePaths=function(s){for(var m=0,O=s.length;m<O;m++)s[m].reverse();},e.Clipper.Orientation=function(s){return e.Clipper.Area(s)>=0;},e.Clipper.prototype.PointCount=function(s){if(s===null)return 0;var m=0,O=s;do m++,O=O.Next;while(O!==s);return m;},e.Clipper.prototype.BuildResult=function(s){e.Clear(s);for(var m=0,O=this.m_PolyOuts.length;m<O;m++){var N=this.m_PolyOuts[m];if(N.Pts!==null){var X=N.Pts.Prev,k=this.PointCount(X);if(!(k<2)){for(var _=new Array(k),ft=0;ft<k;ft++)_[ft]=X.Pt,X=X.Prev;s.push(_);}}}},e.Clipper.prototype.BuildResult2=function(s){s.Clear();for(var m=0,O=this.m_PolyOuts.length;m<O;m++){var N=this.m_PolyOuts[m],X=this.PointCount(N.Pts);if(!(N.IsOpen&&X<2||!N.IsOpen&&X<3)){this.FixHoleLinkage(N);var k=new e.PolyNode();s.m_AllPolys.push(k),N.PolyNode=k,k.m_polygon.length=X;for(var _=N.Pts.Prev,ft=0;ft<X;ft++)k.m_polygon[ft]=_.Pt,_=_.Prev;}}for(var m=0,O=this.m_PolyOuts.length;m<O;m++){var N=this.m_PolyOuts[m];N.PolyNode!==null&&(N.IsOpen?(N.PolyNode.IsOpen=!0,s.AddChild(N.PolyNode)):N.FirstLeft!==null&&N.FirstLeft.PolyNode!==null?N.FirstLeft.PolyNode.AddChild(N.PolyNode):s.AddChild(N.PolyNode));}},e.Clipper.prototype.FixupOutPolyline=function(s){for(var m=s.Pts,O=m.Prev;m!==O;)if(m=m.Next,e.IntPoint.op_Equality(m.Pt,m.Prev.Pt)){m===O&&(O=m.Prev);var N=m.Prev;N.Next=m.Next,m.Next.Prev=N,m=N;}m===m.Prev&&(s.Pts=null);},e.Clipper.prototype.FixupOutPolygon=function(s){var m=null;s.BottomPt=null;for(var O=s.Pts,N=this.PreserveCollinear||this.StrictlySimple;;){if(O.Prev===O||O.Prev===O.Next){s.Pts=null;return;}if(e.IntPoint.op_Equality(O.Pt,O.Next.Pt)||e.IntPoint.op_Equality(O.Pt,O.Prev.Pt)||e.ClipperBase.SlopesEqual4(O.Prev.Pt,O.Pt,O.Next.Pt,this.m_UseFullRange)&&(!N||!this.Pt2IsBetweenPt1AndPt3(O.Prev.Pt,O.Pt,O.Next.Pt)))m=null,O.Prev.Next=O.Next,O.Next.Prev=O.Prev,O=O.Prev;else{if(O===m)break;m===null&&(m=O),O=O.Next;}}s.Pts=O;},e.Clipper.prototype.DupOutPt=function(s,m){var O=new e.OutPt();return O.Pt.X=s.Pt.X,O.Pt.Y=s.Pt.Y,e.use_xyz&&(O.Pt.Z=s.Pt.Z),O.Idx=s.Idx,m?(O.Next=s.Next,O.Prev=s,s.Next.Prev=O,s.Next=O):(O.Prev=s.Prev,O.Next=s,s.Prev.Next=O,s.Prev=O),O;},e.Clipper.prototype.GetOverlap=function(s,m,O,N,X){return s<m?O<N?(X.Left=Math.max(s,O),X.Right=Math.min(m,N)):(X.Left=Math.max(s,N),X.Right=Math.min(m,O)):O<N?(X.Left=Math.max(m,O),X.Right=Math.min(s,N)):(X.Left=Math.max(m,N),X.Right=Math.min(s,O)),X.Left<X.Right;},e.Clipper.prototype.JoinHorz=function(s,m,O,N,X,k){var _=s.Pt.X>m.Pt.X?e.Direction.dRightToLeft:e.Direction.dLeftToRight,ft=O.Pt.X>N.Pt.X?e.Direction.dRightToLeft:e.Direction.dLeftToRight;if(_===ft)return!1;if(_===e.Direction.dLeftToRight){for(;s.Next.Pt.X<=X.X&&s.Next.Pt.X>=s.Pt.X&&s.Next.Pt.Y===X.Y;)s=s.Next;k&&s.Pt.X!==X.X&&(s=s.Next),m=this.DupOutPt(s,!k),e.IntPoint.op_Inequality(m.Pt,X)&&(s=m,s.Pt.X=X.X,s.Pt.Y=X.Y,e.use_xyz&&(s.Pt.Z=X.Z),m=this.DupOutPt(s,!k));}else{for(;s.Next.Pt.X>=X.X&&s.Next.Pt.X<=s.Pt.X&&s.Next.Pt.Y===X.Y;)s=s.Next;!k&&s.Pt.X!==X.X&&(s=s.Next),m=this.DupOutPt(s,k),e.IntPoint.op_Inequality(m.Pt,X)&&(s=m,s.Pt.X=X.X,s.Pt.Y=X.Y,e.use_xyz&&(s.Pt.Z=X.Z),m=this.DupOutPt(s,k));}if(ft===e.Direction.dLeftToRight){for(;O.Next.Pt.X<=X.X&&O.Next.Pt.X>=O.Pt.X&&O.Next.Pt.Y===X.Y;)O=O.Next;k&&O.Pt.X!==X.X&&(O=O.Next),N=this.DupOutPt(O,!k),e.IntPoint.op_Inequality(N.Pt,X)&&(O=N,O.Pt.X=X.X,O.Pt.Y=X.Y,e.use_xyz&&(O.Pt.Z=X.Z),N=this.DupOutPt(O,!k));}else{for(;O.Next.Pt.X>=X.X&&O.Next.Pt.X<=O.Pt.X&&O.Next.Pt.Y===X.Y;)O=O.Next;!k&&O.Pt.X!==X.X&&(O=O.Next),N=this.DupOutPt(O,k),e.IntPoint.op_Inequality(N.Pt,X)&&(O=N,O.Pt.X=X.X,O.Pt.Y=X.Y,e.use_xyz&&(O.Pt.Z=X.Z),N=this.DupOutPt(O,k));}return _===e.Direction.dLeftToRight===k?(s.Prev=O,O.Next=s,m.Next=N,N.Prev=m):(s.Next=O,O.Prev=s,m.Prev=N,N.Next=m),!0;},e.Clipper.prototype.JoinPoints=function(s,m,O){var N=s.OutPt1,X=new e.OutPt(),k=s.OutPt2,_=new e.OutPt(),ft=s.OutPt1.Pt.Y===s.OffPt.Y;if(ft&&e.IntPoint.op_Equality(s.OffPt,s.OutPt1.Pt)&&e.IntPoint.op_Equality(s.OffPt,s.OutPt2.Pt)){if(m!==O)return!1;for(X=s.OutPt1.Next;X!==N&&e.IntPoint.op_Equality(X.Pt,s.OffPt);)X=X.Next;var ht=X.Pt.Y>s.OffPt.Y;for(_=s.OutPt2.Next;_!==k&&e.IntPoint.op_Equality(_.Pt,s.OffPt);)_=_.Next;var Ct=_.Pt.Y>s.OffPt.Y;return ht===Ct?!1:ht?(X=this.DupOutPt(N,!1),_=this.DupOutPt(k,!0),N.Prev=k,k.Next=N,X.Next=_,_.Prev=X,s.OutPt1=N,s.OutPt2=X,!0):(X=this.DupOutPt(N,!0),_=this.DupOutPt(k,!1),N.Next=k,k.Prev=N,X.Prev=_,_.Next=X,s.OutPt1=N,s.OutPt2=X,!0);}else if(ft){for(X=N;N.Prev.Pt.Y===N.Pt.Y&&N.Prev!==X&&N.Prev!==k;)N=N.Prev;for(;X.Next.Pt.Y===X.Pt.Y&&X.Next!==N&&X.Next!==k;)X=X.Next;if(X.Next===N||X.Next===k)return!1;for(_=k;k.Prev.Pt.Y===k.Pt.Y&&k.Prev!==_&&k.Prev!==X;)k=k.Prev;for(;_.Next.Pt.Y===_.Pt.Y&&_.Next!==k&&_.Next!==N;)_=_.Next;if(_.Next===k||_.Next===N)return!1;var wt={Left:null,Right:null};if(!this.GetOverlap(N.Pt.X,X.Pt.X,k.Pt.X,_.Pt.X,wt))return!1;var Lt=wt.Left,Bt=wt.Right,Yt=new e.IntPoint0(),Ht;return N.Pt.X>=Lt&&N.Pt.X<=Bt?(Yt.X=N.Pt.X,Yt.Y=N.Pt.Y,e.use_xyz&&(Yt.Z=N.Pt.Z),Ht=N.Pt.X>X.Pt.X):k.Pt.X>=Lt&&k.Pt.X<=Bt?(Yt.X=k.Pt.X,Yt.Y=k.Pt.Y,e.use_xyz&&(Yt.Z=k.Pt.Z),Ht=k.Pt.X>_.Pt.X):X.Pt.X>=Lt&&X.Pt.X<=Bt?(Yt.X=X.Pt.X,Yt.Y=X.Pt.Y,e.use_xyz&&(Yt.Z=X.Pt.Z),Ht=X.Pt.X>N.Pt.X):(Yt.X=_.Pt.X,Yt.Y=_.Pt.Y,e.use_xyz&&(Yt.Z=_.Pt.Z),Ht=_.Pt.X>k.Pt.X),s.OutPt1=N,s.OutPt2=k,this.JoinHorz(N,X,k,_,Yt,Ht);}else{for(X=N.Next;e.IntPoint.op_Equality(X.Pt,N.Pt)&&X!==N;)X=X.Next;var Vt=X.Pt.Y>N.Pt.Y||!e.ClipperBase.SlopesEqual4(N.Pt,X.Pt,s.OffPt,this.m_UseFullRange);if(Vt){for(X=N.Prev;e.IntPoint.op_Equality(X.Pt,N.Pt)&&X!==N;)X=X.Prev;if(X.Pt.Y>N.Pt.Y||!e.ClipperBase.SlopesEqual4(N.Pt,X.Pt,s.OffPt,this.m_UseFullRange))return!1;}for(_=k.Next;e.IntPoint.op_Equality(_.Pt,k.Pt)&&_!==k;)_=_.Next;var ee=_.Pt.Y>k.Pt.Y||!e.ClipperBase.SlopesEqual4(k.Pt,_.Pt,s.OffPt,this.m_UseFullRange);if(ee){for(_=k.Prev;e.IntPoint.op_Equality(_.Pt,k.Pt)&&_!==k;)_=_.Prev;if(_.Pt.Y>k.Pt.Y||!e.ClipperBase.SlopesEqual4(k.Pt,_.Pt,s.OffPt,this.m_UseFullRange))return!1;}return X===N||_===k||X===_||m===O&&Vt===ee?!1:Vt?(X=this.DupOutPt(N,!1),_=this.DupOutPt(k,!0),N.Prev=k,k.Next=N,X.Next=_,_.Prev=X,s.OutPt1=N,s.OutPt2=X,!0):(X=this.DupOutPt(N,!0),_=this.DupOutPt(k,!1),N.Next=k,k.Prev=N,X.Prev=_,_.Next=X,s.OutPt1=N,s.OutPt2=X,!0);}},e.Clipper.GetBounds=function(s){for(var m=0,O=s.length;m<O&&s[m].length===0;)m++;if(m===O)return new e.IntRect(0,0,0,0);var N=new e.IntRect();for(N.left=s[m][0].X,N.right=N.left,N.top=s[m][0].Y,N.bottom=N.top;m<O;m++)for(var X=0,k=s[m].length;X<k;X++)s[m][X].X<N.left?N.left=s[m][X].X:s[m][X].X>N.right&&(N.right=s[m][X].X),s[m][X].Y<N.top?N.top=s[m][X].Y:s[m][X].Y>N.bottom&&(N.bottom=s[m][X].Y);return N;},e.Clipper.prototype.GetBounds2=function(s){var m=s,O=new e.IntRect();for(O.left=s.Pt.X,O.right=s.Pt.X,O.top=s.Pt.Y,O.bottom=s.Pt.Y,s=s.Next;s!==m;)s.Pt.X<O.left&&(O.left=s.Pt.X),s.Pt.X>O.right&&(O.right=s.Pt.X),s.Pt.Y<O.top&&(O.top=s.Pt.Y),s.Pt.Y>O.bottom&&(O.bottom=s.Pt.Y),s=s.Next;return O;},e.Clipper.PointInPolygon=function(s,m){var O=0,N=m.length;if(N<3)return 0;for(var X=m[0],k=1;k<=N;++k){var _=k===N?m[0]:m[k];if(_.Y===s.Y&&(_.X===s.X||X.Y===s.Y&&_.X>s.X==X.X<s.X))return-1;if(X.Y<s.Y!=_.Y<s.Y){if(X.X>=s.X){if(_.X>s.X)O=1-O;else{var ft=(X.X-s.X)*(_.Y-s.Y)-(_.X-s.X)*(X.Y-s.Y);if(ft===0)return-1;ft>0==_.Y>X.Y&&(O=1-O);}}else if(_.X>s.X){var ft=(X.X-s.X)*(_.Y-s.Y)-(_.X-s.X)*(X.Y-s.Y);if(ft===0)return-1;ft>0==_.Y>X.Y&&(O=1-O);}}X=_;}return O;},e.Clipper.prototype.PointInPolygon=function(s,m){var O=0,N=m,X=s.X,k=s.Y,_=m.Pt.X,ft=m.Pt.Y;do{m=m.Next;var ht=m.Pt.X,Ct=m.Pt.Y;if(Ct===k&&(ht===X||ft===k&&ht>X==_<X))return-1;if(ft<k!=Ct<k){if(_>=X){if(ht>X)O=1-O;else{var wt=(_-X)*(Ct-k)-(ht-X)*(ft-k);if(wt===0)return-1;wt>0==Ct>ft&&(O=1-O);}}else if(ht>X){var wt=(_-X)*(Ct-k)-(ht-X)*(ft-k);if(wt===0)return-1;wt>0==Ct>ft&&(O=1-O);}}_=ht,ft=Ct;}while(N!==m);return O;},e.Clipper.prototype.Poly2ContainsPoly1=function(s,m){var O=s;do{var N=this.PointInPolygon(O.Pt,m);if(N>=0)return N>0;O=O.Next;}while(O!==s);return!0;},e.Clipper.prototype.FixupFirstLefts1=function(s,m){for(var O,N,X=0,k=this.m_PolyOuts.length;X<k;X++)O=this.m_PolyOuts[X],N=e.Clipper.ParseFirstLeft(O.FirstLeft),O.Pts!==null&&N===s&&this.Poly2ContainsPoly1(O.Pts,m.Pts)&&(O.FirstLeft=m);},e.Clipper.prototype.FixupFirstLefts2=function(s,m){for(var O=m.FirstLeft,N,X,k=0,_=this.m_PolyOuts.length;k<_;k++)N=this.m_PolyOuts[k],!(N.Pts===null||N===m||N===s)&&(X=e.Clipper.ParseFirstLeft(N.FirstLeft),!(X!==O&&X!==s&&X!==m)&&(this.Poly2ContainsPoly1(N.Pts,s.Pts)?N.FirstLeft=s:this.Poly2ContainsPoly1(N.Pts,m.Pts)?N.FirstLeft=m:(N.FirstLeft===s||N.FirstLeft===m)&&(N.FirstLeft=O)));},e.Clipper.prototype.FixupFirstLefts3=function(s,m){for(var O,N,X=0,k=this.m_PolyOuts.length;X<k;X++)O=this.m_PolyOuts[X],N=e.Clipper.ParseFirstLeft(O.FirstLeft),O.Pts!==null&&N===s&&(O.FirstLeft=m);},e.Clipper.ParseFirstLeft=function(s){for(;s!==null&&s.Pts===null;)s=s.FirstLeft;return s;},e.Clipper.prototype.JoinCommonEdges=function(){for(var s=0,m=this.m_Joins.length;s<m;s++){var O=this.m_Joins[s],N=this.GetOutRec(O.OutPt1.Idx),X=this.GetOutRec(O.OutPt2.Idx);if(!(N.Pts===null||X.Pts===null)&&!(N.IsOpen||X.IsOpen)){var k;N===X?k=N:this.OutRec1RightOfOutRec2(N,X)?k=X:this.OutRec1RightOfOutRec2(X,N)?k=N:k=this.GetLowermostRec(N,X),this.JoinPoints(O,N,X)&&(N===X?(N.Pts=O.OutPt1,N.BottomPt=null,X=this.CreateOutRec(),X.Pts=O.OutPt2,this.UpdateOutPtIdxs(X),this.Poly2ContainsPoly1(X.Pts,N.Pts)?(X.IsHole=!N.IsHole,X.FirstLeft=N,this.m_UsingPolyTree&&this.FixupFirstLefts2(X,N),(X.IsHole^this.ReverseSolution)==this.Area$1(X)>0&&this.ReversePolyPtLinks(X.Pts)):this.Poly2ContainsPoly1(N.Pts,X.Pts)?(X.IsHole=N.IsHole,N.IsHole=!X.IsHole,X.FirstLeft=N.FirstLeft,N.FirstLeft=X,this.m_UsingPolyTree&&this.FixupFirstLefts2(N,X),(N.IsHole^this.ReverseSolution)==this.Area$1(N)>0&&this.ReversePolyPtLinks(N.Pts)):(X.IsHole=N.IsHole,X.FirstLeft=N.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(N,X))):(X.Pts=null,X.BottomPt=null,X.Idx=N.Idx,N.IsHole=k.IsHole,k===X&&(N.FirstLeft=X.FirstLeft),X.FirstLeft=N,this.m_UsingPolyTree&&this.FixupFirstLefts3(X,N)));}}},e.Clipper.prototype.UpdateOutPtIdxs=function(s){var m=s.Pts;do m.Idx=s.Idx,m=m.Prev;while(m!==s.Pts);},e.Clipper.prototype.DoSimplePolygons=function(){for(var s=0;s<this.m_PolyOuts.length;){var m=this.m_PolyOuts[s++],O=m.Pts;if(!(O===null||m.IsOpen))do{for(var N=O.Next;N!==m.Pts;){if(e.IntPoint.op_Equality(O.Pt,N.Pt)&&N.Next!==O&&N.Prev!==O){var X=O.Prev,k=N.Prev;O.Prev=k,k.Next=O,N.Prev=X,X.Next=N,m.Pts=O;var _=this.CreateOutRec();_.Pts=N,this.UpdateOutPtIdxs(_),this.Poly2ContainsPoly1(_.Pts,m.Pts)?(_.IsHole=!m.IsHole,_.FirstLeft=m,this.m_UsingPolyTree&&this.FixupFirstLefts2(_,m)):this.Poly2ContainsPoly1(m.Pts,_.Pts)?(_.IsHole=m.IsHole,m.IsHole=!_.IsHole,_.FirstLeft=m.FirstLeft,m.FirstLeft=_,this.m_UsingPolyTree&&this.FixupFirstLefts2(m,_)):(_.IsHole=m.IsHole,_.FirstLeft=m.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(m,_)),N=O;}N=N.Next;}O=O.Next;}while(O!==m.Pts);}},e.Clipper.Area=function(s){if(!Array.isArray(s))return 0;var m=s.length;if(m<3)return 0;for(var O=0,N=0,X=m-1;N<m;++N)O+=(s[X].X+s[N].X)*(s[X].Y-s[N].Y),X=N;return-O*0.5;},e.Clipper.prototype.Area=function(s){var m=s;if(s===null)return 0;var O=0;do O=O+(s.Prev.Pt.X+s.Pt.X)*(s.Prev.Pt.Y-s.Pt.Y),s=s.Next;while(s!==m);return O*0.5;},e.Clipper.prototype.Area$1=function(s){return this.Area(s.Pts);},e.Clipper.SimplifyPolygon=function(s,m){var O=new Array(),N=new e.Clipper(0);return N.StrictlySimple=!0,N.AddPath(s,e.PolyType.ptSubject,!0),N.Execute(e.ClipType.ctUnion,O,m,m),O;},e.Clipper.SimplifyPolygons=function(s,m){_typeof(m)>"u"&&(m=e.PolyFillType.pftEvenOdd);var O=new Array(),N=new e.Clipper(0);return N.StrictlySimple=!0,N.AddPaths(s,e.PolyType.ptSubject,!0),N.Execute(e.ClipType.ctUnion,O,m,m),O;},e.Clipper.DistanceSqrd=function(s,m){var O=s.X-m.X,N=s.Y-m.Y;return O*O+N*N;},e.Clipper.DistanceFromLineSqrd=function(s,m,O){var N=m.Y-O.Y,X=O.X-m.X,k=N*m.X+X*m.Y;return k=N*s.X+X*s.Y-k,k*k/(N*N+X*X);},e.Clipper.SlopesNearCollinear=function(s,m,O,N){return Math.abs(s.X-m.X)>Math.abs(s.Y-m.Y)?s.X>m.X==s.X<O.X?e.Clipper.DistanceFromLineSqrd(s,m,O)<N:m.X>s.X==m.X<O.X?e.Clipper.DistanceFromLineSqrd(m,s,O)<N:e.Clipper.DistanceFromLineSqrd(O,s,m)<N:s.Y>m.Y==s.Y<O.Y?e.Clipper.DistanceFromLineSqrd(s,m,O)<N:m.Y>s.Y==m.Y<O.Y?e.Clipper.DistanceFromLineSqrd(m,s,O)<N:e.Clipper.DistanceFromLineSqrd(O,s,m)<N;},e.Clipper.PointsAreClose=function(s,m,O){var N=s.X-m.X,X=s.Y-m.Y;return N*N+X*X<=O;},e.Clipper.ExcludeOp=function(s){var m=s.Prev;return m.Next=s.Next,s.Next.Prev=m,m.Idx=0,m;},e.Clipper.CleanPolygon=function(s,m){_typeof(m)>"u"&&(m=1.415);var O=s.length;if(O===0)return new Array();for(var N=new Array(O),X=0;X<O;++X)N[X]=new e.OutPt();for(var X=0;X<O;++X)N[X].Pt=s[X],N[X].Next=N[(X+1)%O],N[X].Next.Prev=N[X],N[X].Idx=0;for(var k=m*m,_=N[0];_.Idx===0&&_.Next!==_.Prev;)e.Clipper.PointsAreClose(_.Pt,_.Prev.Pt,k)?(_=e.Clipper.ExcludeOp(_),O--):e.Clipper.PointsAreClose(_.Prev.Pt,_.Next.Pt,k)?(e.Clipper.ExcludeOp(_.Next),_=e.Clipper.ExcludeOp(_),O-=2):e.Clipper.SlopesNearCollinear(_.Prev.Pt,_.Pt,_.Next.Pt,k)?(_=e.Clipper.ExcludeOp(_),O--):(_.Idx=1,_=_.Next);O<3&&(O=0);for(var ft=new Array(O),X=0;X<O;++X)ft[X]=new e.IntPoint1(_.Pt),_=_.Next;return N=null,ft;},e.Clipper.CleanPolygons=function(s,m){for(var O=new Array(s.length),N=0,X=s.length;N<X;N++)O[N]=e.Clipper.CleanPolygon(s[N],m);return O;},e.Clipper.Minkowski=function(s,m,O,N){var X=N?1:0,k=s.length,_=m.length,ft=new Array();if(O)for(var ht=0;ht<_;ht++){for(var Ct=new Array(k),wt=0,Lt=s.length,Bt=s[wt];wt<Lt;wt++,Bt=s[wt])Ct[wt]=new e.IntPoint2(m[ht].X+Bt.X,m[ht].Y+Bt.Y);ft.push(Ct);}else for(var ht=0;ht<_;ht++){for(var Ct=new Array(k),wt=0,Lt=s.length,Bt=s[wt];wt<Lt;wt++,Bt=s[wt])Ct[wt]=new e.IntPoint2(m[ht].X-Bt.X,m[ht].Y-Bt.Y);ft.push(Ct);}for(var Yt=new Array(),ht=0;ht<_-1+X;ht++)for(var wt=0;wt<k;wt++){var Ht=new Array();Ht.push(ft[ht%_][wt%k]),Ht.push(ft[(ht+1)%_][wt%k]),Ht.push(ft[(ht+1)%_][(wt+1)%k]),Ht.push(ft[ht%_][(wt+1)%k]),e.Clipper.Orientation(Ht)||Ht.reverse(),Yt.push(Ht);}return Yt;},e.Clipper.MinkowskiSum=function(s,m,O){if(m[0]instanceof Array){for(var X=m,_=new e.Paths(),k=new e.Clipper(),ft=0;ft<X.length;++ft){var ht=e.Clipper.Minkowski(s,X[ft],!0,O);if(k.AddPaths(ht,e.PolyType.ptSubject,!0),O){var N=e.Clipper.TranslatePath(X[ft],s[0]);k.AddPath(N,e.PolyType.ptClip,!0);}}return k.Execute(e.ClipType.ctUnion,_,e.PolyFillType.pftNonZero,e.PolyFillType.pftNonZero),_;}else{var N=m,X=e.Clipper.Minkowski(s,N,!0,O),k=new e.Clipper();return k.AddPaths(X,e.PolyType.ptSubject,!0),k.Execute(e.ClipType.ctUnion,X,e.PolyFillType.pftNonZero,e.PolyFillType.pftNonZero),X;}},e.Clipper.TranslatePath=function(s,m){for(var O=new e.Path(),N=0;N<s.length;N++)O.push(new e.IntPoint2(s[N].X+m.X,s[N].Y+m.Y));return O;},e.Clipper.MinkowskiDiff=function(s,m){var O=e.Clipper.Minkowski(s,m,!1,!0),N=new e.Clipper();return N.AddPaths(O,e.PolyType.ptSubject,!0),N.Execute(e.ClipType.ctUnion,O,e.PolyFillType.pftNonZero,e.PolyFillType.pftNonZero),O;},e.Clipper.PolyTreeToPaths=function(s){var m=new Array();return e.Clipper.AddPolyNodeToPaths(s,e.Clipper.NodeType.ntAny,m),m;},e.Clipper.AddPolyNodeToPaths=function(s,m,O){var N=!0;switch(m){case e.Clipper.NodeType.ntOpen:return;case e.Clipper.NodeType.ntClosed:N=!s.IsOpen;break;}s.m_polygon.length>0&&N&&O.push(s.m_polygon);for(var X=0,k=s.Childs(),_=k.length,ft=k[X];X<_;X++,ft=k[X])e.Clipper.AddPolyNodeToPaths(ft,m,O);},e.Clipper.OpenPathsFromPolyTree=function(s){for(var m=new e.Paths(),O=0,N=s.ChildCount();O<N;O++)s.Childs()[O].IsOpen&&m.push(s.Childs()[O].m_polygon);return m;},e.Clipper.ClosedPathsFromPolyTree=function(s){var m=new e.Paths();return e.Clipper.AddPolyNodeToPaths(s,e.Clipper.NodeType.ntClosed,m),m;},gn(e.Clipper,e.ClipperBase),e.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2},e.ClipperOffset=function(s,m){_typeof(s)>"u"&&(s=2),_typeof(m)>"u"&&(m=e.ClipperOffset.def_arc_tolerance),this.m_destPolys=new e.Paths(),this.m_srcPoly=new e.Path(),this.m_destPoly=new e.Path(),this.m_normals=new Array(),this.m_delta=0,this.m_sinA=0,this.m_sin=0,this.m_cos=0,this.m_miterLim=0,this.m_StepsPerRad=0,this.m_lowest=new e.IntPoint0(),this.m_polyNodes=new e.PolyNode(),this.MiterLimit=s,this.ArcTolerance=m,this.m_lowest.X=-1;},e.ClipperOffset.two_pi=6.28318530717959,e.ClipperOffset.def_arc_tolerance=0.25,e.ClipperOffset.prototype.Clear=function(){e.Clear(this.m_polyNodes.Childs()),this.m_lowest.X=-1;},e.ClipperOffset.Round=e.Clipper.Round,e.ClipperOffset.prototype.AddPath=function(s,m,O){var N=s.length-1;if(!(N<0)){var X=new e.PolyNode();if(X.m_jointype=m,X.m_endtype=O,O===e.EndType.etClosedLine||O===e.EndType.etClosedPolygon)for(;N>0&&e.IntPoint.op_Equality(s[0],s[N]);)N--;X.m_polygon.push(s[0]);for(var k=0,_=0,ft=1;ft<=N;ft++)e.IntPoint.op_Inequality(X.m_polygon[k],s[ft])&&(k++,X.m_polygon.push(s[ft]),(s[ft].Y>X.m_polygon[_].Y||s[ft].Y===X.m_polygon[_].Y&&s[ft].X<X.m_polygon[_].X)&&(_=k));if(!(O===e.EndType.etClosedPolygon&&k<2)&&(this.m_polyNodes.AddChild(X),O===e.EndType.etClosedPolygon))if(this.m_lowest.X<0)this.m_lowest=new e.IntPoint2(this.m_polyNodes.ChildCount()-1,_);else{var ht=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(X.m_polygon[_].Y>ht.Y||X.m_polygon[_].Y===ht.Y&&X.m_polygon[_].X<ht.X)&&(this.m_lowest=new e.IntPoint2(this.m_polyNodes.ChildCount()-1,_));}}},e.ClipperOffset.prototype.AddPaths=function(s,m,O){for(var N=0,X=s.length;N<X;N++)this.AddPath(s[N],m,O);},e.ClipperOffset.prototype.FixOrientations=function(){if(this.m_lowest.X>=0&&!e.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var s=0;s<this.m_polyNodes.ChildCount();s++){var m=this.m_polyNodes.Childs()[s];(m.m_endtype===e.EndType.etClosedPolygon||m.m_endtype===e.EndType.etClosedLine&&e.Clipper.Orientation(m.m_polygon))&&m.m_polygon.reverse();}else for(var s=0;s<this.m_polyNodes.ChildCount();s++){var m=this.m_polyNodes.Childs()[s];m.m_endtype===e.EndType.etClosedLine&&!e.Clipper.Orientation(m.m_polygon)&&m.m_polygon.reverse();}},e.ClipperOffset.GetUnitNormal=function(s,m){var O=m.X-s.X,N=m.Y-s.Y;if(O===0&&N===0)return new e.DoublePoint2(0,0);var X=1/Math.sqrt(O*O+N*N);return O*=X,N*=X,new e.DoublePoint2(N,-O);},e.ClipperOffset.prototype.DoOffset=function(s){if(this.m_destPolys=new Array(),this.m_delta=s,e.ClipperBase.near_zero(s)){for(var m=0;m<this.m_polyNodes.ChildCount();m++){var O=this.m_polyNodes.Childs()[m];O.m_endtype===e.EndType.etClosedPolygon&&this.m_destPolys.push(O.m_polygon);}return;}this.MiterLimit>2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=0.5;var N;this.ArcTolerance<=0?N=e.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(s)*e.ClipperOffset.def_arc_tolerance?N=Math.abs(s)*e.ClipperOffset.def_arc_tolerance:N=this.ArcTolerance;var X=3.14159265358979/Math.acos(1-N/Math.abs(s));this.m_sin=Math.sin(e.ClipperOffset.two_pi/X),this.m_cos=Math.cos(e.ClipperOffset.two_pi/X),this.m_StepsPerRad=X/e.ClipperOffset.two_pi,s<0&&(this.m_sin=-this.m_sin);for(var m=0;m<this.m_polyNodes.ChildCount();m++){var O=this.m_polyNodes.Childs()[m];this.m_srcPoly=O.m_polygon;var k=this.m_srcPoly.length;if(!(k===0||s<=0&&(k<3||O.m_endtype!==e.EndType.etClosedPolygon))){if(this.m_destPoly=new Array(),k===1){if(O.m_jointype===e.JoinType.jtRound)for(var _=1,ft=0,ht=1;ht<=X;ht++){this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[0].X+_*s),e.ClipperOffset.Round(this.m_srcPoly[0].Y+ft*s)));var Ct=_;_=_*this.m_cos-this.m_sin*ft,ft=Ct*this.m_sin+ft*this.m_cos;}else for(var _=-1,ft=-1,ht=0;ht<4;++ht)this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[0].X+_*s),e.ClipperOffset.Round(this.m_srcPoly[0].Y+ft*s))),_<0?_=1:ft<0?ft=1:_=-1;this.m_destPolys.push(this.m_destPoly);continue;}this.m_normals.length=0;for(var ht=0;ht<k-1;ht++)this.m_normals.push(e.ClipperOffset.GetUnitNormal(this.m_srcPoly[ht],this.m_srcPoly[ht+1]));if(O.m_endtype===e.EndType.etClosedLine||O.m_endtype===e.EndType.etClosedPolygon?this.m_normals.push(e.ClipperOffset.GetUnitNormal(this.m_srcPoly[k-1],this.m_srcPoly[0])):this.m_normals.push(new e.DoublePoint1(this.m_normals[k-2])),O.m_endtype===e.EndType.etClosedPolygon){for(var wt=k-1,ht=0;ht<k;ht++)wt=this.OffsetPoint(ht,wt,O.m_jointype);this.m_destPolys.push(this.m_destPoly);}else if(O.m_endtype===e.EndType.etClosedLine){for(var wt=k-1,ht=0;ht<k;ht++)wt=this.OffsetPoint(ht,wt,O.m_jointype);this.m_destPolys.push(this.m_destPoly),this.m_destPoly=new Array();for(var Lt=this.m_normals[k-1],ht=k-1;ht>0;ht--)this.m_normals[ht]=new e.DoublePoint2(-this.m_normals[ht-1].X,-this.m_normals[ht-1].Y);this.m_normals[0]=new e.DoublePoint2(-Lt.X,-Lt.Y),wt=0;for(var ht=k-1;ht>=0;ht--)wt=this.OffsetPoint(ht,wt,O.m_jointype);this.m_destPolys.push(this.m_destPoly);}else{for(var wt=0,ht=1;ht<k-1;++ht)wt=this.OffsetPoint(ht,wt,O.m_jointype);var Bt;if(O.m_endtype===e.EndType.etOpenButt){var ht=k-1;Bt=new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[ht].X+this.m_normals[ht].X*s),e.ClipperOffset.Round(this.m_srcPoly[ht].Y+this.m_normals[ht].Y*s)),this.m_destPoly.push(Bt),Bt=new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[ht].X-this.m_normals[ht].X*s),e.ClipperOffset.Round(this.m_srcPoly[ht].Y-this.m_normals[ht].Y*s)),this.m_destPoly.push(Bt);}else{var ht=k-1;wt=k-2,this.m_sinA=0,this.m_normals[ht]=new e.DoublePoint2(-this.m_normals[ht].X,-this.m_normals[ht].Y),O.m_endtype===e.EndType.etOpenSquare?this.DoSquare(ht,wt):this.DoRound(ht,wt);}for(var ht=k-1;ht>0;ht--)this.m_normals[ht]=new e.DoublePoint2(-this.m_normals[ht-1].X,-this.m_normals[ht-1].Y);this.m_normals[0]=new e.DoublePoint2(-this.m_normals[1].X,-this.m_normals[1].Y),wt=k-1;for(var ht=wt-1;ht>0;--ht)wt=this.OffsetPoint(ht,wt,O.m_jointype);O.m_endtype===e.EndType.etOpenButt?(Bt=new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[0].X-this.m_normals[0].X*s),e.ClipperOffset.Round(this.m_srcPoly[0].Y-this.m_normals[0].Y*s)),this.m_destPoly.push(Bt),Bt=new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[0].X+this.m_normals[0].X*s),e.ClipperOffset.Round(this.m_srcPoly[0].Y+this.m_normals[0].Y*s)),this.m_destPoly.push(Bt)):(wt=1,this.m_sinA=0,O.m_endtype===e.EndType.etOpenSquare?this.DoSquare(0,1):this.DoRound(0,1)),this.m_destPolys.push(this.m_destPoly);}}}},e.ClipperOffset.prototype.Execute=function(){var s=arguments,m=s[0]instanceof e.PolyTree;if(m){var O=s[0],N=s[1];O.Clear(),this.FixOrientations(),this.DoOffset(N);var X=new e.Clipper(0);if(X.AddPaths(this.m_destPolys,e.PolyType.ptSubject,!0),N>0)X.Execute(e.ClipType.ctUnion,O,e.PolyFillType.pftPositive,e.PolyFillType.pftPositive);else{var k=e.Clipper.GetBounds(this.m_destPolys),_=new e.Path();if(_.push(new e.IntPoint2(k.left-10,k.bottom+10)),_.push(new e.IntPoint2(k.right+10,k.bottom+10)),_.push(new e.IntPoint2(k.right+10,k.top-10)),_.push(new e.IntPoint2(k.left-10,k.top-10)),X.AddPath(_,e.PolyType.ptSubject,!0),X.ReverseSolution=!0,X.Execute(e.ClipType.ctUnion,O,e.PolyFillType.pftNegative,e.PolyFillType.pftNegative),O.ChildCount()===1&&O.Childs()[0].ChildCount()>0){var ft=O.Childs()[0];O.Childs()[0]=ft.Childs()[0],O.Childs()[0].m_Parent=O;for(var ht=1;ht<ft.ChildCount();ht++)O.AddChild(ft.Childs()[ht]);}else O.Clear();}}else{var O=s[0],N=s[1];e.Clear(O),this.FixOrientations(),this.DoOffset(N);var X=new e.Clipper(0);if(X.AddPaths(this.m_destPolys,e.PolyType.ptSubject,!0),N>0)X.Execute(e.ClipType.ctUnion,O,e.PolyFillType.pftPositive,e.PolyFillType.pftPositive);else{var k=e.Clipper.GetBounds(this.m_destPolys),_=new e.Path();_.push(new e.IntPoint2(k.left-10,k.bottom+10)),_.push(new e.IntPoint2(k.right+10,k.bottom+10)),_.push(new e.IntPoint2(k.right+10,k.top-10)),_.push(new e.IntPoint2(k.left-10,k.top-10)),X.AddPath(_,e.PolyType.ptSubject,!0),X.ReverseSolution=!0,X.Execute(e.ClipType.ctUnion,O,e.PolyFillType.pftNegative,e.PolyFillType.pftNegative),O.length>0&&O.splice(0,1);}}},e.ClipperOffset.prototype.OffsetPoint=function(s,m,O){if(this.m_sinA=this.m_normals[m].X*this.m_normals[s].Y-this.m_normals[s].X*this.m_normals[m].Y,Math.abs(this.m_sinA*this.m_delta)<1){var N=this.m_normals[m].X*this.m_normals[s].X+this.m_normals[s].Y*this.m_normals[m].Y;if(N>0)return this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+this.m_normals[m].X*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_normals[m].Y*this.m_delta))),m;}else this.m_sinA>1?this.m_sinA=1:this.m_sinA<-1&&(this.m_sinA=-1);if(this.m_sinA*this.m_delta<0)this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+this.m_normals[m].X*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_normals[m].Y*this.m_delta))),this.m_destPoly.push(new e.IntPoint1(this.m_srcPoly[s])),this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+this.m_normals[s].X*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_normals[s].Y*this.m_delta)));else switch(O){case e.JoinType.jtMiter:{var X=1+(this.m_normals[s].X*this.m_normals[m].X+this.m_normals[s].Y*this.m_normals[m].Y);X>=this.m_miterLim?this.DoMiter(s,m,X):this.DoSquare(s,m);break;}case e.JoinType.jtSquare:this.DoSquare(s,m);break;case e.JoinType.jtRound:this.DoRound(s,m);break;}return m=s,m;},e.ClipperOffset.prototype.DoSquare=function(s,m){var O=Math.tan(Math.atan2(this.m_sinA,this.m_normals[m].X*this.m_normals[s].X+this.m_normals[m].Y*this.m_normals[s].Y)/4);this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+this.m_delta*(this.m_normals[m].X-this.m_normals[m].Y*O)),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_delta*(this.m_normals[m].Y+this.m_normals[m].X*O)))),this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+this.m_delta*(this.m_normals[s].X+this.m_normals[s].Y*O)),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_delta*(this.m_normals[s].Y-this.m_normals[s].X*O))));},e.ClipperOffset.prototype.DoMiter=function(s,m,O){var N=this.m_delta/O;this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+(this.m_normals[m].X+this.m_normals[s].X)*N),e.ClipperOffset.Round(this.m_srcPoly[s].Y+(this.m_normals[m].Y+this.m_normals[s].Y)*N)));},e.ClipperOffset.prototype.DoRound=function(s,m){for(var O=Math.atan2(this.m_sinA,this.m_normals[m].X*this.m_normals[s].X+this.m_normals[m].Y*this.m_normals[s].Y),N=Math.max(e.Cast_Int32(e.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(O))),1),X=this.m_normals[m].X,k=this.m_normals[m].Y,_,ft=0;ft<N;++ft)this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+X*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[s].Y+k*this.m_delta))),_=X,X=X*this.m_cos-this.m_sin*k,k=_*this.m_sin+k*this.m_cos;this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+this.m_normals[s].X*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_normals[s].Y*this.m_delta)));},e.Error=function(s){try{throw new Error(s);}catch(m){alert(m.message);}},e.JS={},e.JS.AreaOfPolygon=function(s,m){return m||(m=1),e.Clipper.Area(s)/(m*m);},e.JS.AreaOfPolygons=function(s,m){m||(m=1);for(var O=0,N=0;N<s.length;N++)O+=e.Clipper.Area(s[N]);return O/(m*m);},e.JS.BoundsOfPath=function(s,m){return e.JS.BoundsOfPaths([s],m);},e.JS.BoundsOfPaths=function(s,m){m||(m=1);var O=e.Clipper.GetBounds(s);return O.left/=m,O.bottom/=m,O.right/=m,O.top/=m,O;},e.JS.Clean=function(N,m){if(!(N instanceof Array))return[];var O=N[0]instanceof Array,N=e.JS.Clone(N);if(typeof m!="number"||m===null)return e.Error("Delta is not a number in Clean()."),N;if(N.length===0||N.length===1&&N[0].length===0||m<0)return N;O||(N=[N]);for(var X=N.length,k,_,ft,ht,Ct,wt,Lt,Bt=[],Yt=0;Yt<X;Yt++)if(_=N[Yt],k=_.length,k!==0){if(k<3){ft=_,Bt.push(ft);continue;}for(ft=_,ht=m*m,Ct=_[0],wt=1,Lt=1;Lt<k;Lt++)(_[Lt].X-Ct.X)*(_[Lt].X-Ct.X)+(_[Lt].Y-Ct.Y)*(_[Lt].Y-Ct.Y)<=ht||(ft[wt]=_[Lt],Ct=_[Lt],wt++);Ct=_[wt-1],(_[0].X-Ct.X)*(_[0].X-Ct.X)+(_[0].Y-Ct.Y)*(_[0].Y-Ct.Y)<=ht&&wt--,wt<k&&ft.splice(wt,k-wt),ft.length&&Bt.push(ft);}return!O&&Bt.length?Bt=Bt[0]:!O&&Bt.length===0?Bt=[]:O&&Bt.length===0&&(Bt=[[]]),Bt;},e.JS.Clone=function(s){if(!(s instanceof Array))return[];if(s.length===0)return[];if(s.length===1&&s[0].length===0)return[[]];var m=s[0]instanceof Array;m||(s=[s]);var O=s.length,N,X,k,_,ft=new Array(O);for(X=0;X<O;X++){for(N=s[X].length,_=new Array(N),k=0;k<N;k++)_[k]={X:s[X][k].X,Y:s[X][k].Y};ft[X]=_;}return m||(ft=ft[0]),ft;},e.JS.Lighten=function(s,m){if(!(s instanceof Array))return[];if(typeof m!="number"||m===null)return e.Error("Tolerance is not a number in Lighten()."),e.JS.Clone(s);if(s.length===0||s.length===1&&s[0].length===0||m<0)return e.JS.Clone(s);var O=s[0]instanceof Array;O||(s=[s]);var N,X,k,_,ft,ht,Ct,wt,Lt,Bt,Yt,Ht,Vt,ee,ve,Ie,Ye,Ks=s.length,ks=m*m,Xe=[];for(N=0;N<Ks;N++)if(k=s[N],ht=k.length,ht!==0){for(_=0;_<1e6;_++){for(ft=[],ht=k.length,k[ht-1].X!==k[0].X||k[ht-1].Y!==k[0].Y?(Ht=1,k.push({X:k[0].X,Y:k[0].Y}),ht=k.length):Ht=0,Yt=[],X=0;X<ht-2;X++)Ct=k[X],Lt=k[X+1],wt=k[X+2],Ie=Ct.X,Ye=Ct.Y,Vt=wt.X-Ie,ee=wt.Y-Ye,(Vt!==0||ee!==0)&&(ve=((Lt.X-Ie)*Vt+(Lt.Y-Ye)*ee)/(Vt*Vt+ee*ee),ve>1?(Ie=wt.X,Ye=wt.Y):ve>0&&(Ie+=Vt*ve,Ye+=ee*ve)),Vt=Lt.X-Ie,ee=Lt.Y-Ye,Bt=Vt*Vt+ee*ee,Bt<=ks&&(Yt[X+1]=1,X++);for(ft.push({X:k[0].X,Y:k[0].Y}),X=1;X<ht-1;X++)Yt[X]||ft.push({X:k[X].X,Y:k[X].Y});if(ft.push({X:k[ht-1].X,Y:k[ht-1].Y}),Ht&&k.pop(),Yt.length)k=ft;else break;}ht=ft.length,ft[ht-1].X===ft[0].X&&ft[ht-1].Y===ft[0].Y&&ft.pop(),ft.length>2&&Xe.push(ft);}return O||(Xe=Xe[0]),_typeof(Xe)>"u"&&(Xe=[]),Xe;},e.JS.PerimeterOfPath=function(s,m,O){if(_typeof(s)>"u")return 0;var N=Math.sqrt,X=0,k,_,ft=0,ht=0,Ct=0,wt=0,Lt=s.length;if(Lt<2)return 0;for(m&&(s[Lt]=s[0],Lt++);--Lt;)k=s[Lt],ft=k.X,ht=k.Y,_=s[Lt-1],Ct=_.X,wt=_.Y,X+=N((ft-Ct)*(ft-Ct)+(ht-wt)*(ht-wt));return m&&s.pop(),X/O;},e.JS.PerimeterOfPaths=function(s,m,O){O||(O=1);for(var N=0,X=0;X<s.length;X++)N+=e.JS.PerimeterOfPath(s[X],m,O);return N;},e.JS.ScaleDownPath=function(s,m){var O,N;for(m||(m=1),O=s.length;O--;)N=s[O],N.X=N.X/m,N.Y=N.Y/m;},e.JS.ScaleDownPaths=function(s,m){var O,N,X;for(m||(m=1),O=s.length;O--;)for(N=s[O].length;N--;)X=s[O][N],X.X=X.X/m,X.Y=X.Y/m;},e.JS.ScaleUpPath=function(s,m){var O,N,X=Math.round;for(m||(m=1),O=s.length;O--;)N=s[O],N.X=X(N.X*m),N.Y=X(N.Y*m);},e.JS.ScaleUpPaths=function(s,m){var O,N,X,k=Math.round;for(m||(m=1),O=s.length;O--;)for(N=s[O].length;N--;)X=s[O][N],X.X=k(X.X*m),X.Y=k(X.Y*m);},e.ExPolygons=function(){return[];},e.ExPolygon=function(){this.outer=null,this.holes=null;},e.JS.AddOuterPolyNodeToExPolygons=function(s,m){var O=new e.ExPolygon();O.outer=s.Contour();var N=s.Childs(),X=N.length;O.holes=new Array(X);var k,_,ft,ht,Ct,wt;for(ft=0;ft<X;ft++)for(k=N[ft],O.holes[ft]=k.Contour(),ht=0,Ct=k.Childs(),wt=Ct.length;ht<wt;ht++)_=Ct[ht],e.JS.AddOuterPolyNodeToExPolygons(_,m);m.push(O);},e.JS.ExPolygonsToPaths=function(s){var m,O,N,X,k=new e.Paths();for(m=0,N=s.length;m<N;m++)for(k.push(s[m].outer),O=0,X=s[m].holes.length;O<X;O++)k.push(s[m].holes[O]);return k;},e.JS.PolyTreeToExPolygons=function(s){var m=new e.ExPolygons(),O,N,X,k;for(N=0,X=s.Childs(),k=X.length;N<k;N++)O=X[N],e.JS.AddOuterPolyNodeToExPolygons(O,m);return m;};})();})(zi);var Hp=zi.exports,Me=/* @__PURE__ */Ne(Hp);function $i(u,e){var t=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0.01;return Math.abs(u[0]-e[0])<t&&Math.abs(u[1]-e[1])<t;}function Vp(u){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0.01;if(u.length===0)return[];var t=[[u[0][0],u[0][1]]];for(var r=1;r<u.length;r++)$i([u[r][0],u[r][1]],t[t.length-1],e)||t.push([u[r][0],u[r][1]]);return t;}function Kp(u){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0.01;if(u.length<=2)return u;var t=u[0],r=u[u.length-1];return $i(t,r,e)?u.slice(0,-1):u;}function kp(u){var e=u.reduce(function(r,n){return r+n[0];},0)/u.length,t=u.reduce(function(r,n){return r+n[1];},0)/u.length;return[e,t];}function Hn(u,e){return Math.atan2(e[1]-u[1],e[0]-u[0]);}function Zp(u){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0.01;if(u.length<=2)return u;var t=[];var _iterator16=_createForOfIteratorHelper(u),_step16;try{var _loop3=function _loop3(){var n=_step16.value;t.some(function(l){return Math.abs(l[0]-n[0])<e&&Math.abs(l[1]-n[1])<e;})||t.push([n[0],n[1]]);};for(_iterator16.s();!(_step16=_iterator16.n()).done;){_loop3();}}catch(err){_iterator16.e(err);}finally{_iterator16.f();}var r=kp(t);return t.sort(function(n,i){var l=Hn(r,n),o=Hn(r,i);return l-o;});}function Jp(u,e){var t=e[0].x<e[e.length-1].x;return u.map(function(n){var l=n.map(function(o){var a=-1,c=1/0,g=0;for(var f=0;f<e.length;f++){var v=e[f],x=Math.sqrt(Math.pow(v.x-o[0],2)+Math.pow(v.y-o[1],2));x<c&&(c=x,a=f,g=v.z);}return{point:o,index:a,bestZ:g};}).sort(function(o,a){return o.index-a.index;}).map(function(o){return[].concat(_toConsumableArray(o.point),[o.bestZ]);});return t&&l[0][0]>l[l.length-1][0]||!t&&l[0][0]<l[l.length-1][0]?l.reverse():l;}).sort(function(n,i){var l=n[0][0],o=i[0][0];return t?l-o:o-l;});}function Qp(u,e){var t=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0.01;var n=u.map(function(f){return[f.x,f.y];}),i=function i(f,v){return f.map(function(_ref166){var _ref167=_slicedToArray(_ref166,2),x=_ref167[0],M=_ref167[1];return{X:Math.round(x*v),Y:Math.round(M*v)};});},l=new Me.ClipperOffset();l.AddPath(i(n,1e3),Me.JoinType.jtRound,Me.EndType.etOpenButt);var o=[];l.Execute(o,1);var a=new Me.Clipper();a.AddPaths(o,Me.PolyType.ptSubject,!0),e.forEach(function(f){a.AddPath(i(f,1e3),Me.PolyType.ptClip,!0);});var c=new Me.Paths();a.Execute(Me.ClipType.ctDifference,c,Me.PolyFillType.pftNonZero,Me.PolyFillType.pftNonZero);var g=c.map(function(f){return Kp(Zp(Vp(f.map(function(v){return[v.X/1e3,v.Y/1e3];}),t),t),t);}).filter(function(f){return f.length>=2;});return Jp(g,u);}var Gi=/*#__PURE__*/function(_Et){function Gi(t){var _this62;_classCallCheck(this,Gi);_this62=_callSuper(this,Gi,[t]);at(_this62,"canRotate",!0);at(_this62,"scaleType",Qt.all);at(_this62,"toolsType",xt.Pencil);at(_this62,"syncTimestamp");at(_this62,"syncIndex",0);at(_this62,"tmpPoints",[]);at(_this62,"MAX_REPEAR",10);/** 合并原始点的灵敏度 */at(_this62,"uniThickness");at(_this62,"workOptions");at(_this62,"centerPos",[0,0]);_this62.workOptions=t.toolsOpt,_this62.uniThickness=_this62.MAX_REPEAR/_this62.workOptions.thickness/10,_this62.syncTimestamp=0;return _this62;}/** 批量合并消费本地数据,返回绘制结果 */_inherits(Gi,_Et);return _createClass(Gi,[{key:"combineConsume",value:function combineConsume(){var o;var t=(o=this.workId)==null?void 0:o.toString();if(this.tmpPoints.length<2)return{type:dt.None};var r=this.transformDataAll(!0),n={name:t};var i;var l=this.drawLayer||this.fullLayer;return r.length&&(i=this.draw({attrs:n,tasks:r,replaceId:t,layer:l})),{rect:i,type:dt.DrawWork,dataType:bt.Local};}},{key:"setWorkOptions",value:function setWorkOptions(t){_superPropGet(Gi,"setWorkOptions",this,3)([t]),this.syncTimestamp=Date.now();}},{key:"consume",value:function consume(t){var _this63=this;var r=t.data,n=t.isFullWork,i=t.isSubWorker,l=t.isMainThread,o=t.drawCount,a=t.removeDrawCount,c=r.workId,g=r.syncUnitTime;g&&(this.syncUnitTime=g);var _this$transformData=this.transformData(r,!1),f=_this$transformData.tasks,v=_this$transformData.effects,x=_this$transformData.consumeIndex;this.syncIndex=Math.min(this.syncIndex,x,Math.max(0,this.tmpPoints.length-2));var M={name:c,id:ue(o)&&o.toString()||void 0};var S,P=!1;var C=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),f.length&&(f[0].taskId-this.syncTimestamp>this.syncUnitTime&&(P=!0,this.syncTimestamp=f[0].taskId,this.syncIndex=this.tmpPoints.length),i||l)){var p=n?this.fullLayer:this.drawLayer||this.fullLayer;S=this.draw({attrs:M,tasks:f,effects:v,layer:p,removeDrawCount:a});}if(i)return x>10&&this.tmpPoints.splice(0,x-10),{rect:S,type:dt.DrawWork,dataType:bt.Local};var h=[];return this.tmpPoints.slice(C).forEach(function(p){h.push(p.x,p.y,_this63.computRadius(p.z,_this63.workOptions.thickness));}),_objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:dt.DrawWork,dataType:bt.Local,rect:S,op:P?h:void 0,index:P?C*3:void 0,updateNodeOpt:{useAnimation:!0}});}},{key:"consumeAll",value:function consumeAll(t){var g;var r=this.workId;if(t.data){var _t$data=t.data,f=_t$data.op,v=_t$data.workState;f!=null&&f.length&&v===Ft.Done&&this.workOptions.strokeType===Kt.Stroke&&this.updateTempPointsWithPressureWhenDone(f);}var n=this.transformDataAll(!0),i={name:r};var l;var o=this.fullLayer;if(n.length&&(l=this.draw({attrs:i,tasks:n,replaceId:r,layer:o})),this.tmpPoints.length<2)return this.replace(o,r),{type:dt.RemoveNode,removeIds:[r],rect:l};var a=[];this.tmpPoints.map(function(f){a.push(f.x,f.y,f.z);}),this.syncTimestamp=0,delete this.workOptions.syncUnitTime;var c=ge(a);return(g=this.vNodes)==null||g.setInfo(r,{rect:l,op:a,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:l&&Et.getCenterPos(l,o)}),_objectSpread(_objectSpread({},this.baseConsumeResult),{},{rect:l,type:dt.FullWork,dataType:bt.Local,ops:c,updateNodeOpt:{pos:this.centerPos,useAnimation:!0}});}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0;}},{key:"consumeService",value:function consumeService(t){var f,v;var r=t.op,n=t.isFullWork,i=t.replaceId,_t$workState=t.workState,l=_t$workState===void 0?Ft.Done:_t$workState;this.tmpPoints.length=0;for(var x=0;x<r.length;x+=3){var M=new Dt(r[x],r[x+1],r[x+2]);if(this.tmpPoints.length>0){var S=this.tmpPoints[this.tmpPoints.length-1],P=ot.Sub(M,S).uni();M.setv(P);}this.tmpPoints.push(M);}if(this.tmpPoints.length<2)return;var o=this.transformDataAll(!0),a=(f=this.workId)==null?void 0:f.toString(),c={name:a};var g;if(a&&o.length){var _x30=n?this.fullLayer:this.drawLayer||this.fullLayer;g=this.draw({attrs:c,tasks:o,replaceId:i,layer:_x30,isDrawEraserlines:l===Ft.Done}),(v=this.vNodes)==null||v.setInfo(a,{rect:g,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:g&&Et.getCenterPos(g,_x30)});}return g;}},{key:"computPencilPoints",value:function computPencilPoints(t){var _this64=this;var r=[],n=t.op,i=t.eraserPolylines,l=t.eraserThickness;this.tmpPoints.length=0;for(var a=0;a<n.length;a+=3){var c=new Dt(n[a],n[a+1],n[a+2]);if(this.tmpPoints.length>0){var g=this.tmpPoints[this.tmpPoints.length-1],f=ot.Sub(c,g).uni();c.setv(f);}this.tmpPoints.push(c);}if(this.tmpPoints.length<2)return;var o=this.transformDataAll(!0);if(o.length){var _loop4=function _loop4(){var _o$_a=o[_a5],c=_o$_a.pos,g=_o$_a.points,f=g.map(function(M){return M.point.addXY(c[0],c[1]);}),v=[];var _iterator17=_createForOfIteratorHelper(i),_step17;try{for(_iterator17.s();!(_step17=_iterator17.n()).done;){var M=_step17.value;var S=[];for(var _C29=0;_C29<M.length;_C29+=2){var _h27=new Dt(M[_C29],M[_C29+1]);if(S.length>0){var p=S[S.length-1].point,d=ot.Sub(_h27,p).uni();_h27.setv(d);}S.push({point:_h27,radius:l});}var _this64$computStroke=_this64.computStroke(S,!1),P=_this64$computStroke.ps;v.push(P.map(function(C){return C.XY;}));}}catch(err){_iterator17.e(err);}finally{_iterator17.f();}Qp(f,v,0.01).forEach(function(M){r.push(M.map(function(S){return[S[0],S[1],S[2]];}).flat(1));});};for(var _a5=0;_a5<o.length;_a5++){_loop4();}}return r;}},{key:"transformDataAll",value:function transformDataAll(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:!0;var r=this.filterSamePoints(this.tmpPoints,this.workOptions.thickness);return this.getTaskPoints(r,t&&this.workOptions.thickness||void 0);}},{key:"draw",value:function draw(t){var _this65=this;var r=t.attrs,n=t.tasks,i=t.replaceId,l=t.effects,o=t.layer,a=t.removeDrawCount,_t$isDrawEraserlines=t.isDrawEraserlines,c=_t$isDrawEraserlines===void 0?!0:_t$isDrawEraserlines,_this$workOptions=this.workOptions,g=_this$workOptions.strokeColor,f=_this$workOptions.strokeType,v=_this$workOptions.thickness,x=_this$workOptions.zIndex,M=_this$workOptions.scale,S=_this$workOptions.rotate,P=_this$workOptions.translate,C=_this$workOptions.eraserlines;l!=null&&l.size&&(l.forEach(function(L){var w;(w=o.getElementById(L+""))==null||w.remove();}),l.clear()),a&&this.removeDrawCountNodes(o,a);var h;var p=[],d=o.worldPosition,y=o.worldScaling;for(var L=0;L<n.length;L++){var _n$L=n[L],w=_n$L.pos,B=_n$L.points,_this$computDrawPoint=this.computDrawPoints(B),E=_this$computDrawPoint.ps,b=_this$computDrawPoint.rect;var W=void 0;var D=B.length===1;f===Kt.Stroke||D?W=De(E,!0):W=De(E,!1);var R={pos:w,d:W,fillColor:f===Kt.Stroke||D?g:void 0,lineDash:f===Kt.Dotted&&!D?[1,v*2]:f===Kt.LongDotted&&!D?[v,v*2]:void 0,strokeColor:g,lineCap:f===Kt.Stroke||D?void 0:"round",lineWidth:f===Kt.Stroke||D?0:v};h=Wt(h,{x:Math.floor((b.x+w[0])*y[0]+d[0]-Et.SafeBorderPadding),y:Math.floor((b.y+w[1])*y[1]+d[1]-Et.SafeBorderPadding),w:Math.floor(b.w*y[0]+2*Et.SafeBorderPadding),h:Math.floor(b.h*y[1]+2*Et.SafeBorderPadding)}),p.push(R);}M&&(r.scale=M),S&&(r.rotate=S),P&&(r.translate=P);var I=new me();if(h){this.centerPos=Et.getCenterPos(h,o);var _L4=f===Kt.Stroke&&!C;I.attr(_objectSpread(_objectSpread({},r),{},{normalize:!0,anchor:[0.5,0.5],bgcolor:_L4?g:void 0,pos:this.centerPos,size:[(h.w-2*Et.SafeBorderPadding)/y[0],(h.h-2*Et.SafeBorderPadding)/y[1]],zIndex:x}));var _w5=p.map(function(B){return B.pos=[B.pos[0]-_this65.centerPos[0],B.pos[1]-_this65.centerPos[1]],new be(B);});I.append.apply(I,_toConsumableArray(_w5)),_L4&&I.seal(),C&&(this.scaleType=Qt.proportional,this.drawEraserlines({group:I,eraserlines:C,pos:this.centerPos,layer:o},c)),this.replace(o,i,I);}if(M||S||P){var _L5=I==null?void 0:I.getBoundingClientRect();_L5&&(h={x:Math.floor(_L5.x-Et.SafeBorderPadding),y:Math.floor(_L5.y-Et.SafeBorderPadding),w:Math.floor(_L5.width+Et.SafeBorderPadding*2),h:Math.floor(_L5.height+Et.SafeBorderPadding*2)});}return this.isDelete&&I.setAttribute("opacity",0),h;}},{key:"computDrawPoints",value:function computDrawPoints(t){return this.workOptions.strokeType===Kt.Stroke||t.length===1?this.computStroke(t):this.computNomal(t);}},{key:"computNomal",value:function computNomal(t){var r=this.workOptions.thickness;var n=t.map(function(i){return r=Math.max(r,i.radius),i.point;});return{ps:n,rect:_t(n,r)};}},{key:"computStroke",value:function computStroke(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;return t.length===1?this.computDotStroke(t[0]):this.computLineStroke(t,r);}},{key:"computLineStroke",value:function computLineStroke(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var n=[],i=[];for(var a=0;a<t.length;a++){var _t$a=t[a],c=_t$a.point,g=_t$a.radius;var f=c.v;a===0&&t.length>1&&(f=t[a+1].point.v);var v=ot.Per(f).mul(g);n.push(Dt.Sub(c,v)),i.push(Dt.Add(c,v));}var l=t[t.length-1];if(r){var _a6=Dt.GetSemicircleStroke(l.point,n[n.length-1],-1,8),_c4=Dt.GetSemicircleStroke(t[0].point,i[0],-1,8),_g6=n.concat(_a6,i.reverse(),_c4);return{ps:_g6,rect:_t(_g6)};}var o=n.concat(i.reverse());return{ps:o,rect:_t(o)};}},{key:"computDotStroke",value:function computDotStroke(t){var r=t.point,n=t.radius,i={x:r.x-n,y:r.y-n,w:n*2,h:n*2};return{ps:Dt.GetDotStroke(r,n,8),rect:i};}},{key:"transformData",value:function transformData(t,r){var n=t.op,i=t.workState;var l=this.tmpPoints.length-1,o=[];if(n!=null&&n.length&&i){var _this$workOptions2=this.workOptions,a=_this$workOptions2.strokeType,c=_this$workOptions2.thickness,g=/* @__PURE__ */new Set();l=a===Kt.Stroke?this.updateTempPointsWithPressure(n,c,g):this.updateTempPoints(n,c,g);var f=r?this.tmpPoints:this.tmpPoints.slice(l);return o=this.getTaskPoints(f,c),{tasks:o,effects:g,consumeIndex:l};}return{tasks:o,consumeIndex:l};}/** 压力渐变公式 */},{key:"computRadius",value:function computRadius(t,r){return t*0.03*r+r*0.5;}},{key:"getMinZ",value:function getMinZ(t,r){return((r||Math.max(1,Math.floor(t*0.3)))-t*0.5)*100/t/3;}},{key:"getTaskPoints",value:function getTaskPoints(t,r){var f;var n=[];if(t.length===0)return[];var i=0,l=t[0].x,o=t[0].y,a=[l,o],c=[],g=t[0].t;for(;i<t.length;){var v=t[i],x=v.x-l,M=v.y-o,S=v.z,P=r?this.computRadius(S,r):S;if(c.push({point:new Dt(x,M,S,t[i].v),radius:P}),i>0&&i<t.length-1){var _C30=t[i].getAngleByPoints(t[i-1],t[i+1]);if(_C30<60||_C30>300){var _h28=(f=c.pop())==null?void 0:f.point.clone();_h28&&n.push({taskId:g,pos:a,points:[].concat(_toConsumableArray(c),[{point:_h28,radius:P}])}),l=t[i].x,o=t[i].y,a=[l,o];var p=v.x-l,d=v.y-o;c=[{point:new Dt(p,d,S),radius:P}],g=Date.now();}}i++;}return n.push({taskId:g,pos:a,points:c}),n;}},{key:"updateTempPointsWithPressure",value:function updateTempPointsWithPressure(t,r,n){var i=Date.now(),l=this.tmpPoints.length;var o=l;for(var c=0;c<t.length;c+=2){o=Math.min(o,l);var g=this.tmpPoints.length,f=new Dt(t[c],t[c+1]);if(g===0){this.tmpPoints.push(f);continue;}var v=g-1,x=this.tmpPoints[v],M=ot.Sub(f,x).uni();if(f.isNear(x,r)){if(x.z<this.MAX_REPEAR){if(x.setz(Math.min(x.z+1,this.MAX_REPEAR)),o=Math.min(o,v),g>1){var _C31=g-1;for(;_C31>0;){var _h29=this.tmpPoints[_C31].distance(this.tmpPoints[_C31-1]),p=Math.max(this.tmpPoints[_C31].z-this.uniThickness*_h29,0);if(this.tmpPoints[_C31-1].z>=p)break;this.tmpPoints[_C31-1].setz(p),o=Math.min(o,_C31-1),_C31--;}}}else o=1/0;continue;}f.setv(M);var S=f.distance(x),P=Math.max(x.z-this.uniThickness*S,0);g>1&&ot.Equals(M,x.v,0.02)&&(P>0||x.z<=0)&&(n&&x.t&&n.add(x.t),this.tmpPoints.pop(),o=Math.min(v,o)),f.setz(P),this.tmpPoints.push(f);}if(o===1/0)return this.tmpPoints.length;var a=l;if(o===l){a=Math.max(a-1,0);var _c5=this.tmpPoints[a].t;_c5&&(n==null||n.add(_c5));}else{var _c6=l-1;for(a=o;_c6>=0;){var _g7=this.tmpPoints[_c6].t;if(_g7&&(n==null||n.add(_g7),_c6<=o)){a=_c6,_c6=-1;break;}_c6--;}}return this.tmpPoints[a].setT(i),a;}},{key:"updateTempPoints",value:function updateTempPoints(t,r,n){var c;var i=Date.now(),l=this.tmpPoints.length;var o=l;for(var g=0;g<t.length;g+=2){var f=this.tmpPoints.length,v=new Dt(t[g],t[g+1]);if(f===0){this.tmpPoints.push(v);continue;}var x=f-1,M=this.tmpPoints[x],S=ot.Sub(v,M).uni();if(v.isNear(M,r/2)){o=Math.min(x,o);continue;}ot.Equals(S,M.v,0.02)&&(n&&M.t&&n.add(M.t),this.tmpPoints.pop(),o=Math.min(x,o)),v.setv(S),this.tmpPoints.push(v);}var a=l;if(o===l){a=Math.max(a-1,0);var _g8=this.tmpPoints[a].t;_g8&&(n==null||n.add(_g8));}else{var _g9=Math.min(l-1,o);for(a=o;_g9>=0;){var _f4=(c=this.tmpPoints[_g9])==null?void 0:c.t;if(_f4&&(n==null||n.add(_f4),_g9<=o)){a=_g9,_g9=-1;break;}_g9--;}}return this.tmpPoints[a].setT(i),a;}},{key:"updateTempPointsWithPressureWhenDone",value:function updateTempPointsWithPressureWhenDone(t){var r=this.workOptions.thickness,n=t.length,i=this.getMinZ(r);for(var l=0;l<n;l+=2){var o=this.tmpPoints.length,a=new Dt(t[l],t[l+1]);if(o===0){this.tmpPoints.push(a);continue;}var c=o-1,g=this.tmpPoints[c],f=ot.Sub(a,g).uni(),v=a.distance(g);if(o>1&&g.z===i)break;if(a.isNear(g,r/2)){if(n<3&&g.z<this.MAX_REPEAR&&(g.setz(Math.min(g.z+1,this.MAX_REPEAR)),o>1)){var M=o-1;for(;M>0;){var S=this.tmpPoints[M].distance(this.tmpPoints[M-1]),P=Math.max(this.tmpPoints[M].z-this.uniThickness*S,-r/4);if(this.tmpPoints[M-1].z>=P)break;this.tmpPoints[M-1].setz(P),M--;}}continue;}a.setv(f);var x=Math.max(g.z-this.uniThickness*v,i);o>1&&ot.Equals(f,g.v,0.02)&&g.z<=0&&this.tmpPoints.pop(),a.setz(x),this.tmpPoints.push(a);}}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var c,g;var r=t.node,n=t.opt,i=t.vNodes,l=n.strokeColor,o=n.strokeType,a=i.get(r.name);return l&&(r.tagName==="GROUP"?ym(r)?r.setAttribute("bgcolor",l):r.children.forEach(function(f){f.setAttribute("strokeColor",l),f.getAttribute("fillColor")&&f.setAttribute("fillColor",l);}):(r.setAttribute("strokeColor",l),r.setAttribute("fillColor",l)),(c=a==null?void 0:a.opt)!=null&&c.strokeColor&&(a.opt.strokeColor=l)),o&&a!=null&&a.opt&&(g=a.opt)!=null&&g.strokeType&&(a.opt.strokeType=o),a&&i.setInfo(r.name,a),Et.updateNodeOpt(t);}}]);}(Et);var Hi=/*#__PURE__*/function(_Et2){function Hi(t){var _this66;_classCallCheck(this,Hi);_this66=_callSuper(this,Hi,[t]);at(_this66,"toolsType",xt.LaserPen);at(_this66,"canRotate",!1);at(_this66,"scaleType",Qt.none);at(_this66,"syncTimestamp");at(_this66,"syncIndex",0);at(_this66,"tmpPoints",[]);at(_this66,"workOptions");at(_this66,"consumeIndex",0);_this66.workOptions=t.toolsOpt,_this66.syncTimestamp=0;return _this66;}_inherits(Hi,_Et2);return _createClass(Hi,[{key:"combineConsume",value:function combineConsume(){}},{key:"setWorkOptions",value:function setWorkOptions(t){_superPropGet(Hi,"setWorkOptions",this,3)([t]),this.syncTimestamp=Date.now();}},{key:"consume",value:function consume(t){var r=t.data,n=t.isSubWorker,i=r.workId,l=r.op,o=r.syncUnitTime;if((l==null?void 0:l.length)===0)return{type:dt.None};if(o&&(this.syncUnitTime=o),this.updateTempPoints(l||[]),this.consumeIndex>this.tmpPoints.length-4)return{type:dt.None};var _this$workOptions3=this.workOptions,a=_this$workOptions3.strokeColor,c=_this$workOptions3.thickness,g=_this$workOptions3.strokeType,f=_t(this.tmpPoints,c);var v=!1;var x=this.syncIndex,M=this.tmpPoints.slice(this.consumeIndex);this.consumeIndex=this.tmpPoints.length-1,this.syncTimestamp===0&&(this.syncTimestamp=Date.now());var S={name:i==null?void 0:i.toString(),opacity:1,lineDash:g===Kt.Dotted?[1,c*2]:g===Kt.LongDotted?[c,c*2]:void 0,strokeColor:a,lineCap:"round",lineWidth:c,anchor:[0.5,0.5]},P=this.getTaskPoints(M);if(P.length){var _h30=Date.now();_h30-this.syncTimestamp>this.syncUnitTime&&(v=!0,this.syncTimestamp=_h30,this.syncIndex=this.tmpPoints.length),n&&this.draw({attrs:S,tasks:P,isDot:!1,layer:this.drawLayer||this.fullLayer});}var C=[];return this.tmpPoints.slice(x).forEach(function(h){C.push(h.x,h.y);}),_objectSpread({rect:{x:f.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:f.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:f.w*this.fullLayer.worldScaling[0],h:f.h*this.fullLayer.worldScaling[1]},type:dt.DrawWork,dataType:bt.Local,op:v?C:void 0,index:v?x*2:void 0},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var l;var t=(l=this.workId)==null?void 0:l.toString();var r;if(this.tmpPoints.length-1>this.consumeIndex){var o=this.tmpPoints.slice(this.consumeIndex);var a=o.length===1,_this$workOptions4=this.workOptions,c=_this$workOptions4.strokeColor,g=_this$workOptions4.thickness,f=_this$workOptions4.strokeType;if(a){var M=this.computDotStroke({point:o[0],radius:g/2});o=M.ps,r=M.rect;}else r=_t(this.tmpPoints,g);var v={name:t==null?void 0:t.toString(),fillColor:a?c:void 0,opacity:1,lineDash:f===Kt.Dotted&&!a?[1,g*2]:f===Kt.LongDotted&&!a?[g,g*2]:void 0,strokeColor:c,lineCap:a?void 0:"round",lineWidth:a?0:g,anchor:[0.5,0.5]},x=this.getTaskPoints(o);x.length&&this.draw({attrs:v,tasks:x,isDot:a,layer:this.drawLayer||this.fullLayer});}var n=[];this.tmpPoints.forEach(function(o){n.push(o.x,o.y);});var i=ge(n);return _objectSpread({rect:r&&{x:r.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:r.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:r.w*this.fullLayer.worldScaling[0],h:r.h*this.fullLayer.worldScaling[1]},type:dt.FullWork,dataType:bt.Local,ops:i,index:this.syncIndex*2},this.baseConsumeResult);}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0;}},{key:"consumeService",value:function consumeService(t){var S;var r=t.op,n=t.replaceId,i=t.isFullWork,_this$workOptions5=this.workOptions,l=_this$workOptions5.strokeColor,o=_this$workOptions5.thickness,a=_this$workOptions5.strokeType;if(!r.length){var P=_t(this.tmpPoints,o);return{x:P.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:P.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:P.w*this.fullLayer.worldScaling[0],h:P.h*this.fullLayer.worldScaling[1]};}var c=Math.max(0,this.tmpPoints.length-1);this.updateTempPoints(r||[]);var g,f=this.tmpPoints.slice(c);var v=f.length===1;if(v){var _P6=this.computDotStroke({point:f[0],radius:o/2});f=_P6.ps,g=_P6.rect;}else g=_t(this.tmpPoints,o);var x={name:(S=this.workId)==null?void 0:S.toString(),fillColor:v?l:void 0,opacity:1,lineDash:a===Kt.Dotted&&!v?[1,o*2]:a===Kt.LongDotted&&!v?[o,o*2]:void 0,strokeColor:l,lineCap:v?void 0:"round",lineWidth:v?0:o,anchor:[0.5,0.5]},M=this.getTaskPoints(f);if(M.length){var _P7=i?this.fullLayer:this.drawLayer||this.fullLayer;this.draw({attrs:x,tasks:M,isDot:v,replaceId:n,layer:_P7});}return{x:g.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:g.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:g.w*this.fullLayer.worldScaling[0],h:g.h*this.fullLayer.worldScaling[1]};}},{key:"computDotStroke",value:function computDotStroke(t){var r=t.point,n=t.radius,i={x:r.x-n,y:r.y-n,w:n*2,h:n*2};return{ps:Dt.GetDotStroke(r,n,8),rect:i};}},{key:"updateTempPoints",value:function updateTempPoints(t){var r=this.tmpPoints.length;for(var n=0;n<t.length;n+=2){if(r){var i=this.tmpPoints.slice(-1)[0];i&&i.x===t[n]&&i.y===t[n+1]&&this.tmpPoints.pop();}this.tmpPoints.push(new Dt(t[n],t[n+1]));}}},{key:"draw",value:function(){var _draw2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21(t){var _this67=this;var r,n,i,l,o,_iterator18,_step18,_loop5;return _regeneratorRuntime().wrap(function _callee21$(_context23){while(1)switch(_context23.prev=_context23.next){case 0:r=t.attrs,n=t.tasks,i=t.isDot,l=t.layer,o=this.workOptions.duration;_iterator18=_createForOfIteratorHelper(n);_context23.prev=2;_loop5=/*#__PURE__*/_regeneratorRuntime().mark(function _loop5(){var a,c,g,f,v,_this67$workOptions,x,M,S,_l$getResolution,P,_C32;return _regeneratorRuntime().wrap(function _loop5$(_context22){while(1)switch(_context22.prev=_context22.next){case 0:a=_step18.value;c=new be(),g=a.pos,f=a.points;i?v=De(f,!0):v=De(f,!1),c.attr(_objectSpread(_objectSpread({},r),{},{pos:g,d:v}));_this67$workOptions=_this67.workOptions,x=_this67$workOptions.vertex,M=_this67$workOptions.fragment;if(x&&M){S=l.renderer.createProgram({vertex:x,fragment:M}),_l$getResolution=l.getResolution(),P=_l$getResolution.width,_C32=_l$getResolution.height;c.setUniforms({u_time:0,u_resolution:[P,_C32]}),c.setProgram(S);}l.appendChild(c),c.transition(o).attr({scale:i?[0.1,0.1]:[1,1],lineWidth:i?0:1}).then(function(){c.remove();});case 6:case"end":return _context22.stop();}},_loop5);});_iterator18.s();case 5:if((_step18=_iterator18.n()).done){_context23.next=9;break;}return _context23.delegateYield(_loop5(),"t0",7);case 7:_context23.next=5;break;case 9:_context23.next=14;break;case 11:_context23.prev=11;_context23.t1=_context23["catch"](2);_iterator18.e(_context23.t1);case 14:_context23.prev=14;_iterator18.f();return _context23.finish(14);case 17:case"end":return _context23.stop();}},_callee21,this,[[2,11,14,17]]);}));function draw(_x31){return _draw2.apply(this,arguments);}return draw;}()},{key:"getTaskPoints",value:function getTaskPoints(t){var c;var r=[];if(t.length===0)return[];var n=0,i=t[0].x,l=t[0].y,o=[i,l],a=[];for(;n<t.length;){var g=t[n],f=g.x-i,v=g.y-l;if(a.push(new Dt(f,v)),n>0&&n<t.length-1){var x=t[n].getAngleByPoints(t[n-1],t[n+1]);if(x<60||x>300){var M=(c=a.pop())==null?void 0:c.clone();M&&r.push({pos:o,points:[].concat(_toConsumableArray(a),[M])}),i=t[n].x,l=t[n].y,o=[i,l];var S=g.x-i,P=g.y-l;a=[new Dt(S,P)];}}n++;}return r.push({pos:o,points:a}),r;}},{key:"removeLocal",value:function removeLocal(){}},{key:"removeService",value:function removeService(t){var r;var n=[];return this.fullLayer.getElementsByName(t).forEach(function(i){if(i.name===t){var l=i.getBoundingClientRect();r=Wt(r,{x:l.x,y:l.y,w:l.width,h:l.height}),n.push(i);}}),n.length&&n.forEach(function(i){return i.remove();}),r;}}]);}(Et);var qp=Sr;Sr.polyline=Sr;Sr.polygon=_p;function Sr(u,e,t){var r=u.length,n=Ge(u[0],e),i=[],l,o,a,c,g;for(t||(t=[]),l=1;l<r;l++){for(o=u[l-1],a=u[l],c=g=Ge(a,e);;)if(n|c){if(n&c)break;n?(o=Kr(o,a,n,e),n=Ge(o,e)):(a=Kr(o,a,c,e),c=Ge(a,e));}else{i.push(o),c!==g?(i.push(a),l<r-1&&(t.push(i),i=[])):l===r-1&&i.push(a);break;}n=g;}return i.length&&t.push(i),t;}function _p(u,e){var t,r,n,i,l,o,a;for(r=1;r<=8;r*=2){for(t=[],n=u[u.length-1],i=!(Ge(n,e)&r),l=0;l<u.length;l++)o=u[l],a=!(Ge(o,e)&r),a!==i&&t.push(Kr(n,o,r,e)),a&&t.push(o),n=o,i=a;if(u=t,!u.length)break;}return t;}function Kr(u,e,t,r){return t&8?[u[0]+(e[0]-u[0])*(r[3]-u[1])/(e[1]-u[1]),r[3]]:// top
|
|
403
|
+
decompressFromEncodedURIComponent:function decompressFromEncodedURIComponent(a){return a==null?"":a==""?null:(a=a.replace(/ /g,"+"),o._decompress(a.length,32,function(c){return l(n,a.charAt(c));}));},compress:function compress(a){return o._compress(a,16,function(c){return t(c);});},_compress:function _compress(a,c,g){if(a==null)return"";var f,v,x={},M={},S="",P="",C="",h=2,p=3,d=2,y=[],I=0,L=0,w;for(w=0;w<a.length;w+=1)if(S=a.charAt(w),Object.prototype.hasOwnProperty.call(x,S)||(x[S]=p++,M[S]=!0),P=C+S,Object.prototype.hasOwnProperty.call(x,P))C=P;else{if(Object.prototype.hasOwnProperty.call(M,C)){if(C.charCodeAt(0)<256){for(f=0;f<d;f++)I=I<<1,L==c-1?(L=0,y.push(g(I)),I=0):L++;for(v=C.charCodeAt(0),f=0;f<8;f++)I=I<<1|v&1,L==c-1?(L=0,y.push(g(I)),I=0):L++,v=v>>1;}else{for(v=1,f=0;f<d;f++)I=I<<1|v,L==c-1?(L=0,y.push(g(I)),I=0):L++,v=0;for(v=C.charCodeAt(0),f=0;f<16;f++)I=I<<1|v&1,L==c-1?(L=0,y.push(g(I)),I=0):L++,v=v>>1;}h--,h==0&&(h=Math.pow(2,d),d++),delete M[C];}else for(v=x[C],f=0;f<d;f++)I=I<<1|v&1,L==c-1?(L=0,y.push(g(I)),I=0):L++,v=v>>1;h--,h==0&&(h=Math.pow(2,d),d++),x[P]=p++,C=String(S);}if(C!==""){if(Object.prototype.hasOwnProperty.call(M,C)){if(C.charCodeAt(0)<256){for(f=0;f<d;f++)I=I<<1,L==c-1?(L=0,y.push(g(I)),I=0):L++;for(v=C.charCodeAt(0),f=0;f<8;f++)I=I<<1|v&1,L==c-1?(L=0,y.push(g(I)),I=0):L++,v=v>>1;}else{for(v=1,f=0;f<d;f++)I=I<<1|v,L==c-1?(L=0,y.push(g(I)),I=0):L++,v=0;for(v=C.charCodeAt(0),f=0;f<16;f++)I=I<<1|v&1,L==c-1?(L=0,y.push(g(I)),I=0):L++,v=v>>1;}h--,h==0&&(h=Math.pow(2,d),d++),delete M[C];}else for(v=x[C],f=0;f<d;f++)I=I<<1|v&1,L==c-1?(L=0,y.push(g(I)),I=0):L++,v=v>>1;h--,h==0&&(h=Math.pow(2,d),d++);}for(v=2,f=0;f<d;f++)I=I<<1|v&1,L==c-1?(L=0,y.push(g(I)),I=0):L++,v=v>>1;for(;;)if(I=I<<1,L==c-1){y.push(g(I));break;}else L++;return y.join("");},decompress:function decompress(a){return a==null?"":a==""?null:o._decompress(a.length,32768,function(c){return a.charCodeAt(c);});},_decompress:function _decompress(a,c,g){var f=[],v=4,x=4,M=3,S="",P=[],C,h,p,d,y,I,L,w={val:g(0),position:c,index:1};for(C=0;C<3;C+=1)f[C]=C;for(p=0,y=Math.pow(2,2),I=1;I!=y;)d=w.val&w.position,w.position>>=1,w.position==0&&(w.position=c,w.val=g(w.index++)),p|=(d>0?1:0)*I,I<<=1;switch(p){case 0:for(p=0,y=Math.pow(2,8),I=1;I!=y;)d=w.val&w.position,w.position>>=1,w.position==0&&(w.position=c,w.val=g(w.index++)),p|=(d>0?1:0)*I,I<<=1;L=t(p);break;case 1:for(p=0,y=Math.pow(2,16),I=1;I!=y;)d=w.val&w.position,w.position>>=1,w.position==0&&(w.position=c,w.val=g(w.index++)),p|=(d>0?1:0)*I,I<<=1;L=t(p);break;case 2:return"";}for(f[3]=L,h=L,P.push(L);;){if(w.index>a)return"";for(p=0,y=Math.pow(2,M),I=1;I!=y;)d=w.val&w.position,w.position>>=1,w.position==0&&(w.position=c,w.val=g(w.index++)),p|=(d>0?1:0)*I,I<<=1;switch(L=p){case 0:for(p=0,y=Math.pow(2,8),I=1;I!=y;)d=w.val&w.position,w.position>>=1,w.position==0&&(w.position=c,w.val=g(w.index++)),p|=(d>0?1:0)*I,I<<=1;f[x++]=t(p),L=x-1,v--;break;case 1:for(p=0,y=Math.pow(2,16),I=1;I!=y;)d=w.val&w.position,w.position>>=1,w.position==0&&(w.position=c,w.val=g(w.index++)),p|=(d>0?1:0)*I,I<<=1;f[x++]=t(p),L=x-1,v--;break;case 2:return P.join("");}if(v==0&&(v=Math.pow(2,M),M++),f[L])S=f[L];else if(L===x)S=h+h.charAt(0);else return null;P.push(S),f[x++]=h+S.charAt(0),v--,h=S,v==0&&(v=Math.pow(2,M),M++);}}};return o;}();u!=null?u.exports=e:(typeof angular==="undefined"?"undefined":_typeof(angular))<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return e;});})(cn);var Xi=cn.exports;function Ze(u){return JSON.parse(Xi.decompress(u));}function ge(u){return Xi.compress(JSON.stringify(u));}var zi={exports:{}};(function(u){(function(){var e={};e.version="6.4.2.2",e.use_lines=!0,e.use_xyz=!1;var t=!1;u.exports?(u.exports=e,t=!0):(typeof document==="undefined"?"undefined":_typeof(document))<"u"?window.ClipperLib=e:self.ClipperLib=e;var r;if(t){var n="chrome";r="Netscape";}else{var n=navigator.userAgent.toString().toLowerCase();r=navigator.appName;}var i={};n.indexOf("chrome")!=-1&&n.indexOf("chromium")==-1?i.chrome=1:i.chrome=0,n.indexOf("chromium")!=-1?i.chromium=1:i.chromium=0,n.indexOf("safari")!=-1&&n.indexOf("chrome")==-1&&n.indexOf("chromium")==-1?i.safari=1:i.safari=0,n.indexOf("firefox")!=-1?i.firefox=1:i.firefox=0,n.indexOf("firefox/17")!=-1?i.firefox17=1:i.firefox17=0,n.indexOf("firefox/15")!=-1?i.firefox15=1:i.firefox15=0,n.indexOf("firefox/3")!=-1?i.firefox3=1:i.firefox3=0,n.indexOf("opera")!=-1?i.opera=1:i.opera=0,n.indexOf("msie 10")!=-1?i.msie10=1:i.msie10=0,n.indexOf("msie 9")!=-1?i.msie9=1:i.msie9=0,n.indexOf("msie 8")!=-1?i.msie8=1:i.msie8=0,n.indexOf("msie 7")!=-1?i.msie7=1:i.msie7=0,n.indexOf("msie ")!=-1?i.msie=1:i.msie=0,e.biginteger_used=null;var l;function o(s,m,O){e.biginteger_used=1,s!=null&&(typeof s=="number"&&_typeof(m)>"u"?this.fromInt(s):typeof s=="number"?this.fromNumber(s,m,O):m==null&&typeof s!="string"?this.fromString(s,256):this.fromString(s,m));}function a(){return new o(null,void 0,void 0);}function c(s,m,O,N,X,k){for(;--k>=0;){var _=m*this[s++]+O[N]+X;X=Math.floor(_/67108864),O[N++]=_&67108863;}return X;}function g(s,m,O,N,X,k){for(var _=m&32767,ft=m>>15;--k>=0;){var ht=this[s]&32767,Ct=this[s++]>>15,wt=ft*ht+Ct*_;ht=_*ht+((wt&32767)<<15)+O[N]+(X&1073741823),X=(ht>>>30)+(wt>>>15)+ft*Ct+(X>>>30),O[N++]=ht&1073741823;}return X;}function f(s,m,O,N,X,k){for(var _=m&16383,ft=m>>14;--k>=0;){var ht=this[s]&16383,Ct=this[s++]>>14,wt=ft*ht+Ct*_;ht=_*ht+((wt&16383)<<14)+O[N]+X,X=(ht>>28)+(wt>>14)+ft*Ct,O[N++]=ht&268435455;}return X;}r=="Microsoft Internet Explorer"?(o.prototype.am=g,l=30):r!="Netscape"?(o.prototype.am=c,l=26):(o.prototype.am=f,l=28),o.prototype.DB=l,o.prototype.DM=(1<<l)-1,o.prototype.DV=1<<l;var v=52;o.prototype.FV=Math.pow(2,v),o.prototype.F1=v-l,o.prototype.F2=2*l-v;var x="0123456789abcdefghijklmnopqrstuvwxyz",M=new Array(),S,P;for(S=48,P=0;P<=9;++P)M[S++]=P;for(S=97,P=10;P<36;++P)M[S++]=P;for(S=65,P=10;P<36;++P)M[S++]=P;function C(s){return x.charAt(s);}function h(s,m){var O=M[s.charCodeAt(m)];return O!==null&&O!==void 0?O:-1;}function p(s){for(var m=this.t-1;m>=0;--m)s[m]=this[m];s.t=this.t,s.s=this.s;}function d(s){this.t=1,this.s=s<0?-1:0,s>0?this[0]=s:s<-1?this[0]=s+this.DV:this.t=0;}function y(s){var m=a();return m.fromInt(s),m;}function I(s,m){var O;if(m==16)O=4;else if(m==8)O=3;else if(m==256)O=8;else if(m==2)O=1;else if(m==32)O=5;else if(m==4)O=2;else{this.fromRadix(s,m);return;}this.t=0,this.s=0;for(var N=s.length,X=!1,k=0;--N>=0;){var _=O==8?s[N]&255:h(s,N);if(_<0){s.charAt(N)=="-"&&(X=!0);continue;}X=!1,k==0?this[this.t++]=_:k+O>this.DB?(this[this.t-1]|=(_&(1<<this.DB-k)-1)<<k,this[this.t++]=_>>this.DB-k):this[this.t-1]|=_<<k,k+=O,k>=this.DB&&(k-=this.DB);}O==8&&s[0]&128&&(this.s=-1,k>0&&(this[this.t-1]|=(1<<this.DB-k)-1<<k)),this.clamp(),X&&o.ZERO.subTo(this,this);}function L(){for(var s=this.s&this.DM;this.t>0&&this[this.t-1]==s;)--this.t;}function w(s){if(this.s<0)return"-"+this.negate().toString(s);var m;if(s==16)m=4;else if(s==8)m=3;else if(s==2)m=1;else if(s==32)m=5;else if(s==4)m=2;else return this.toRadix(s);var O=(1<<m)-1,N,X=!1,k="",_=this.t,ft=this.DB-_*this.DB%m;if(_-->0)for(ft<this.DB&&(N=this[_]>>ft)>0&&(X=!0,k=C(N));_>=0;)ft<m?(N=(this[_]&(1<<ft)-1)<<m-ft,N|=this[--_]>>(ft+=this.DB-m)):(N=this[_]>>(ft-=m)&O,ft<=0&&(ft+=this.DB,--_)),N>0&&(X=!0),X&&(k+=C(N));return X?k:"0";}function B(){var s=a();return o.ZERO.subTo(this,s),s;}function E(){return this.s<0?this.negate():this;}function b(s){var m=this.s-s.s;if(m!=0)return m;var O=this.t;if(m=O-s.t,m!=0)return this.s<0?-m:m;for(;--O>=0;)if((m=this[O]-s[O])!=0)return m;return 0;}function W(s){var m=1,O;return(O=s>>>16)!=0&&(s=O,m+=16),(O=s>>8)!=0&&(s=O,m+=8),(O=s>>4)!=0&&(s=O,m+=4),(O=s>>2)!=0&&(s=O,m+=2),(O=s>>1)!=0&&(s=O,m+=1),m;}function D(){return this.t<=0?0:this.DB*(this.t-1)+W(this[this.t-1]^this.s&this.DM);}function R(s,m){var O;for(O=this.t-1;O>=0;--O)m[O+s]=this[O];for(O=s-1;O>=0;--O)m[O]=0;m.t=this.t+s,m.s=this.s;}function Y(s,m){for(var O=s;O<this.t;++O)m[O-s]=this[O];m.t=Math.max(this.t-s,0),m.s=this.s;}function V(s,m){var O=s%this.DB,N=this.DB-O,X=(1<<N)-1,k=Math.floor(s/this.DB),_=this.s<<O&this.DM,ft;for(ft=this.t-1;ft>=0;--ft)m[ft+k+1]=this[ft]>>N|_,_=(this[ft]&X)<<O;for(ft=k-1;ft>=0;--ft)m[ft]=0;m[k]=_,m.t=this.t+k+1,m.s=this.s,m.clamp();}function Q(s,m){m.s=this.s;var O=Math.floor(s/this.DB);if(O>=this.t){m.t=0;return;}var N=s%this.DB,X=this.DB-N,k=(1<<N)-1;m[0]=this[O]>>N;for(var _=O+1;_<this.t;++_)m[_-O-1]|=(this[_]&k)<<X,m[_-O]=this[_]>>N;N>0&&(m[this.t-O-1]|=(this.s&k)<<X),m.t=this.t-O,m.clamp();}function et(s,m){for(var O=0,N=0,X=Math.min(s.t,this.t);O<X;)N+=this[O]-s[O],m[O++]=N&this.DM,N>>=this.DB;if(s.t<this.t){for(N-=s.s;O<this.t;)N+=this[O],m[O++]=N&this.DM,N>>=this.DB;N+=this.s;}else{for(N+=this.s;O<s.t;)N-=s[O],m[O++]=N&this.DM,N>>=this.DB;N-=s.s;}m.s=N<0?-1:0,N<-1?m[O++]=this.DV+N:N>0&&(m[O++]=N),m.t=O,m.clamp();}function it(s,m){var O=this.abs(),N=s.abs(),X=O.t;for(m.t=X+N.t;--X>=0;)m[X]=0;for(X=0;X<N.t;++X)m[X+O.t]=O.am(0,N[X],m,X,0,O.t);m.s=0,m.clamp(),this.s!=s.s&&o.ZERO.subTo(m,m);}function $(s){for(var m=this.abs(),O=s.t=2*m.t;--O>=0;)s[O]=0;for(O=0;O<m.t-1;++O){var N=m.am(O,m[O],s,2*O,0,1);(s[O+m.t]+=m.am(O+1,2*m[O],s,2*O+1,N,m.t-O-1))>=m.DV&&(s[O+m.t]-=m.DV,s[O+m.t+1]=1);}s.t>0&&(s[s.t-1]+=m.am(O,m[O],s,2*O,0,1)),s.s=0,s.clamp();}function K(s,m,O){var N=s.abs();if(!(N.t<=0)){var X=this.abs();if(X.t<N.t){m!=null&&m.fromInt(0),O!=null&&this.copyTo(O);return;}O==null&&(O=a());var k=a(),_=this.s,ft=s.s,ht=this.DB-W(N[N.t-1]);ht>0?(N.lShiftTo(ht,k),X.lShiftTo(ht,O)):(N.copyTo(k),X.copyTo(O));var Ct=k.t,wt=k[Ct-1];if(wt!=0){var Lt=wt*(1<<this.F1)+(Ct>1?k[Ct-2]>>this.F2:0),Bt=this.FV/Lt,Yt=(1<<this.F1)/Lt,Ht=1<<this.F2,Vt=O.t,ee=Vt-Ct,ve=m!==null&&m!==void 0?m:a();for(k.dlShiftTo(ee,ve),O.compareTo(ve)>=0&&(O[O.t++]=1,O.subTo(ve,O)),o.ONE.dlShiftTo(Ct,ve),ve.subTo(k,k);k.t<Ct;)k[k.t++]=0;for(;--ee>=0;){var Ie=O[--Vt]==wt?this.DM:Math.floor(O[Vt]*Bt+(O[Vt-1]+Ht)*Yt);if((O[Vt]+=k.am(0,Ie,O,ee,0,Ct))<Ie)for(k.dlShiftTo(ee,ve),O.subTo(ve,O);O[Vt]<--Ie;)O.subTo(ve,O);}m!=null&&(O.drShiftTo(Ct,m),_!=ft&&o.ZERO.subTo(m,m)),O.t=Ct,O.clamp(),ht>0&&O.rShiftTo(ht,O),_<0&&o.ZERO.subTo(O,O);}}}function rt(s){var m=a();return this.abs().divRemTo(s,null,m),this.s<0&&m.compareTo(o.ZERO)>0&&s.subTo(m,m),m;}function lt(s){this.m=s;}function ct(s){return s.s<0||s.compareTo(this.m)>=0?s.mod(this.m):s;}function yt(s){return s;}function st(s){s.divRemTo(this.m,null,s);}function Ot(s,m,O){s.multiplyTo(m,O),this.reduce(O);}function St(s,m){s.squareTo(m),this.reduce(m);}lt.prototype.convert=ct,lt.prototype.revert=yt,lt.prototype.reduce=st,lt.prototype.mulTo=Ot,lt.prototype.sqrTo=St;function F(){if(this.t<1)return 0;var s=this[0];if(!(s&1))return 0;var m=s&3;return m=m*(2-(s&15)*m)&15,m=m*(2-(s&255)*m)&255,m=m*(2-((s&65535)*m&65535))&65535,m=m*(2-s*m%this.DV)%this.DV,m>0?this.DV-m:-m;}function z(s){this.m=s,this.mp=s.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<s.DB-15)-1,this.mt2=2*s.t;}function Z(s){var m=a();return s.abs().dlShiftTo(this.m.t,m),m.divRemTo(this.m,null,m),s.s<0&&m.compareTo(o.ZERO)>0&&this.m.subTo(m,m),m;}function tt(s){var m=a();return s.copyTo(m),this.reduce(m),m;}function j(s){for(;s.t<=this.mt2;)s[s.t++]=0;for(var m=0;m<this.m.t;++m){var O=s[m]&32767,N=O*this.mpl+((O*this.mph+(s[m]>>15)*this.mpl&this.um)<<15)&s.DM;for(O=m+this.m.t,s[O]+=this.m.am(0,N,s,m,0,this.m.t);s[O]>=s.DV;)s[O]-=s.DV,s[++O]++;}s.clamp(),s.drShiftTo(this.m.t,s),s.compareTo(this.m)>=0&&s.subTo(this.m,s);}function H(s,m){s.squareTo(m),this.reduce(m);}function T(s,m,O){s.multiplyTo(m,O),this.reduce(O);}z.prototype.convert=Z,z.prototype.revert=tt,z.prototype.reduce=j,z.prototype.mulTo=T,z.prototype.sqrTo=H;function A(){return(this.t>0?this[0]&1:this.s)==0;}function U(s,m){if(s>4294967295||s<1)return o.ONE;var O=a(),N=a(),X=m.convert(this),k=W(s)-1;for(X.copyTo(O);--k>=0;)if(m.sqrTo(O,N),(s&1<<k)>0)m.mulTo(N,X,O);else{var _=O;O=N,N=_;}return m.revert(O);}function G(s,m){var O;return s<256||m.isEven()?O=new lt(m):O=new z(m),this.exp(s,O);}o.prototype.copyTo=p,o.prototype.fromInt=d,o.prototype.fromString=I,o.prototype.clamp=L,o.prototype.dlShiftTo=R,o.prototype.drShiftTo=Y,o.prototype.lShiftTo=V,o.prototype.rShiftTo=Q,o.prototype.subTo=et,o.prototype.multiplyTo=it,o.prototype.squareTo=$,o.prototype.divRemTo=K,o.prototype.invDigit=F,o.prototype.isEven=A,o.prototype.exp=U,o.prototype.toString=w,o.prototype.negate=B,o.prototype.abs=E,o.prototype.compareTo=b,o.prototype.bitLength=D,o.prototype.mod=rt,o.prototype.modPowInt=G,o.ZERO=y(0),o.ONE=y(1);function J(){var s=a();return this.copyTo(s),s;}function q(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1;}else{if(this.t==1)return this[0];if(this.t==0)return 0;}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0];}function nt(){return this.t==0?this.s:this[0]<<24>>24;}function ut(){return this.t==0?this.s:this[0]<<16>>16;}function pt(s){return Math.floor(Math.LN2*this.DB/Math.log(s));}function gt(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1;}function Tt(s){if(s==null&&(s=10),this.signum()==0||s<2||s>36)return"0";var m=this.chunkSize(s),O=Math.pow(s,m),N=y(O),X=a(),k=a(),_="";for(this.divRemTo(N,X,k);X.signum()>0;)_=(O+k.intValue()).toString(s).substr(1)+_,X.divRemTo(N,X,k);return k.intValue().toString(s)+_;}function vt(s,m){this.fromInt(0),m==null&&(m=10);for(var O=this.chunkSize(m),N=Math.pow(m,O),X=!1,k=0,_=0,ft=0;ft<s.length;++ft){var ht=h(s,ft);if(ht<0){s.charAt(ft)=="-"&&this.signum()==0&&(X=!0);continue;}_=m*_+ht,++k>=O&&(this.dMultiply(N),this.dAddOffset(_,0),k=0,_=0);}k>0&&(this.dMultiply(Math.pow(m,k)),this.dAddOffset(_,0)),X&&o.ZERO.subTo(this,this);}function mt(s,m,O){if(typeof m=="number"){if(s<2)this.fromInt(1);else for(this.fromNumber(s,O),this.testBit(s-1)||this.bitwiseTo(o.ONE.shiftLeft(s-1),Ut,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(m);)this.dAddOffset(2,0),this.bitLength()>s&&this.subTo(o.ONE.shiftLeft(s-1),this);}else{var N=new Array(),X=s&7;N.length=(s>>3)+1,m.nextBytes(N),X>0?N[0]&=(1<<X)-1:N[0]=0,this.fromString(N,256);}}function Pt(){var s=this.t,m=new Array();m[0]=this.s;var O=this.DB-s*this.DB%8,N,X=0;if(s-->0)for(O<this.DB&&(N=this[s]>>O)!=(this.s&this.DM)>>O&&(m[X++]=N|this.s<<this.DB-O);s>=0;)O<8?(N=(this[s]&(1<<O)-1)<<8-O,N|=this[--s]>>(O+=this.DB-8)):(N=this[s]>>(O-=8)&255,O<=0&&(O+=this.DB,--s)),N&128&&(N|=-256),X==0&&(this.s&128)!=(N&128)&&++X,(X>0||N!=this.s)&&(m[X++]=N);return m;}function Mt(s){return this.compareTo(s)==0;}function At(s){return this.compareTo(s)<0?this:s;}function It(s){return this.compareTo(s)>0?this:s;}function Nt(s,m,O){var N,X,k=Math.min(s.t,this.t);for(N=0;N<k;++N)O[N]=m(this[N],s[N]);if(s.t<this.t){for(X=s.s&this.DM,N=k;N<this.t;++N)O[N]=m(this[N],X);O.t=this.t;}else{for(X=this.s&this.DM,N=k;N<s.t;++N)O[N]=m(X,s[N]);O.t=s.t;}O.s=m(this.s,s.s),O.clamp();}function $t(s,m){return s&m;}function jt(s){var m=a();return this.bitwiseTo(s,$t,m),m;}function Ut(s,m){return s|m;}function zt(s){var m=a();return this.bitwiseTo(s,Ut,m),m;}function Xt(s,m){return s^m;}function ae(s){var m=a();return this.bitwiseTo(s,Xt,m),m;}function ie(s,m){return s&~m;}function se(s){var m=a();return this.bitwiseTo(s,ie,m),m;}function oe(){for(var s=a(),m=0;m<this.t;++m)s[m]=this.DM&~this[m];return s.t=this.t,s.s=~this.s,s;}function le(s){var m=a();return s<0?this.rShiftTo(-s,m):this.lShiftTo(s,m),m;}function ce(s){var m=a();return s<0?this.lShiftTo(-s,m):this.rShiftTo(s,m),m;}function fe(s){if(s==0)return-1;var m=0;return s&65535||(s>>=16,m+=16),s&255||(s>>=8,m+=8),s&15||(s>>=4,m+=4),s&3||(s>>=2,m+=2),s&1||++m,m;}function Zt(){for(var s=0;s<this.t;++s)if(this[s]!=0)return s*this.DB+fe(this[s]);return this.s<0?this.t*this.DB:-1;}function Pe(s){for(var m=0;s!=0;)s&=s-1,++m;return m;}function Be(){for(var s=0,m=this.s&this.DM,O=0;O<this.t;++O)s+=Pe(this[O]^m);return s;}function We(s){var m=Math.floor(s/this.DB);return m>=this.t?this.s!=0:(this[m]&1<<s%this.DB)!=0;}function dr(s,m){var O=o.ONE.shiftLeft(s);return this.bitwiseTo(O,m,O),O;}function pr(s){return this.changeBit(s,Ut);}function ps(s){return this.changeBit(s,ie);}function ms(s){return this.changeBit(s,Xt);}function vs(s,m){for(var O=0,N=0,X=Math.min(s.t,this.t);O<X;)N+=this[O]+s[O],m[O++]=N&this.DM,N>>=this.DB;if(s.t<this.t){for(N+=s.s;O<this.t;)N+=this[O],m[O++]=N&this.DM,N>>=this.DB;N+=this.s;}else{for(N+=this.s;O<s.t;)N+=s[O],m[O++]=N&this.DM,N>>=this.DB;N+=s.s;}m.s=N<0?-1:0,N>0?m[O++]=N:N<-1&&(m[O++]=this.DV+N),m.t=O,m.clamp();}function ys(s){var m=a();return this.addTo(s,m),m;}function gs(s){var m=a();return this.subTo(s,m),m;}function Ps(s){var m=a();return this.multiplyTo(s,m),m;}function xs(){var s=a();return this.squareTo(s),s;}function Ss(s){var m=a();return this.divRemTo(s,m,null),m;}function Ts(s){var m=a();return this.divRemTo(s,null,m),m;}function Cs(s){var m=a(),O=a();return this.divRemTo(s,m,O),new Array(m,O);}function Os(s){this[this.t]=this.am(0,s-1,this,0,0,this.t),++this.t,this.clamp();}function Is(s,m){if(s!=0){for(;this.t<=m;)this[this.t++]=0;for(this[m]+=s;this[m]>=this.DV;)this[m]-=this.DV,++m>=this.t&&(this[this.t++]=0),++this[m];}}function rr(){}function yn(s){return s;}function Ms(s,m,O){s.multiplyTo(m,O);}function Es(s,m){s.squareTo(m);}rr.prototype.convert=yn,rr.prototype.revert=yn,rr.prototype.mulTo=Ms,rr.prototype.sqrTo=Es;function As(s){return this.exp(s,new rr());}function Ls(s,m,O){var N=Math.min(this.t+s.t,m);for(O.s=0,O.t=N;N>0;)O[--N]=0;var X;for(X=O.t-this.t;N<X;++N)O[N+this.t]=this.am(0,s[N],O,N,0,this.t);for(X=Math.min(s.t,m);N<X;++N)this.am(0,s[N],O,N,0,m-N);O.clamp();}function ws(s,m,O){--m;var N=O.t=this.t+s.t-m;for(O.s=0;--N>=0;)O[N]=0;for(N=Math.max(m-this.t,0);N<s.t;++N)O[this.t+N-m]=this.am(m-N,s[N],O,0,0,this.t+N-m);O.clamp(),O.drShiftTo(1,O);}function je(s){this.r2=a(),this.q3=a(),o.ONE.dlShiftTo(2*s.t,this.r2),this.mu=this.r2.divide(s),this.m=s;}function Rs(s){if(s.s<0||s.t>2*this.m.t)return s.mod(this.m);if(s.compareTo(this.m)<0)return s;var m=a();return s.copyTo(m),this.reduce(m),m;}function Ds(s){return s;}function bs(s){for(s.drShiftTo(this.m.t-1,this.r2),s.t>this.m.t+1&&(s.t=this.m.t+1,s.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);s.compareTo(this.r2)<0;)s.dAddOffset(1,this.m.t+1);for(s.subTo(this.r2,s);s.compareTo(this.m)>=0;)s.subTo(this.m,s);}function Ns(s,m){s.squareTo(m),this.reduce(m);}function Bs(s,m,O){s.multiplyTo(m,O),this.reduce(O);}je.prototype.convert=Rs,je.prototype.revert=Ds,je.prototype.reduce=bs,je.prototype.mulTo=Bs,je.prototype.sqrTo=Ns;function Ws(s,m){var O=s.bitLength(),N,X=y(1),k;if(O<=0)return X;O<18?N=1:O<48?N=3:O<144?N=4:O<768?N=5:N=6,O<8?k=new lt(m):m.isEven()?k=new je(m):k=new z(m);var _=new Array(),ft=3,ht=N-1,Ct=(1<<N)-1;if(_[1]=k.convert(this),N>1){var wt=a();for(k.sqrTo(_[1],wt);ft<=Ct;)_[ft]=a(),k.mulTo(wt,_[ft-2],_[ft]),ft+=2;}var Lt=s.t-1,Bt,Yt=!0,Ht=a(),Vt;for(O=W(s[Lt])-1;Lt>=0;){for(O>=ht?Bt=s[Lt]>>O-ht&Ct:(Bt=(s[Lt]&(1<<O+1)-1)<<ht-O,Lt>0&&(Bt|=s[Lt-1]>>this.DB+O-ht)),ft=N;!(Bt&1);)Bt>>=1,--ft;if((O-=ft)<0&&(O+=this.DB,--Lt),Yt)_[Bt].copyTo(X),Yt=!1;else{for(;ft>1;)k.sqrTo(X,Ht),k.sqrTo(Ht,X),ft-=2;ft>0?k.sqrTo(X,Ht):(Vt=X,X=Ht,Ht=Vt),k.mulTo(Ht,_[Bt],X);}for(;Lt>=0&&!(s[Lt]&1<<O);)k.sqrTo(X,Ht),Vt=X,X=Ht,Ht=Vt,--O<0&&(O=this.DB-1,--Lt);}return k.revert(X);}function Fs(s){var m=this.s<0?this.negate():this.clone(),O=s.s<0?s.negate():s.clone();if(m.compareTo(O)<0){var N=m;m=O,O=N;}var X=m.getLowestSetBit(),k=O.getLowestSetBit();if(k<0)return m;for(X<k&&(k=X),k>0&&(m.rShiftTo(k,m),O.rShiftTo(k,O));m.signum()>0;)(X=m.getLowestSetBit())>0&&m.rShiftTo(X,m),(X=O.getLowestSetBit())>0&&O.rShiftTo(X,O),m.compareTo(O)>=0?(m.subTo(O,m),m.rShiftTo(1,m)):(O.subTo(m,O),O.rShiftTo(1,O));return k>0&&O.lShiftTo(k,O),O;}function Us(s){if(s<=0)return 0;var m=this.DV%s,O=this.s<0?s-1:0;if(this.t>0)if(m==0)O=this[0]%s;else for(var N=this.t-1;N>=0;--N)O=(m*O+this[N])%s;return O;}function js(s){var m=s.isEven();if(this.isEven()&&m||s.signum()==0)return o.ZERO;for(var O=s.clone(),N=this.clone(),X=y(1),k=y(0),_=y(0),ft=y(1);O.signum()!=0;){for(;O.isEven();)O.rShiftTo(1,O),m?((!X.isEven()||!k.isEven())&&(X.addTo(this,X),k.subTo(s,k)),X.rShiftTo(1,X)):k.isEven()||k.subTo(s,k),k.rShiftTo(1,k);for(;N.isEven();)N.rShiftTo(1,N),m?((!_.isEven()||!ft.isEven())&&(_.addTo(this,_),ft.subTo(s,ft)),_.rShiftTo(1,_)):ft.isEven()||ft.subTo(s,ft),ft.rShiftTo(1,ft);O.compareTo(N)>=0?(O.subTo(N,O),m&&X.subTo(_,X),k.subTo(ft,k)):(N.subTo(O,N),m&&_.subTo(X,_),ft.subTo(k,ft));}if(N.compareTo(o.ONE)!=0)return o.ZERO;if(ft.compareTo(s)>=0)return ft.subtract(s);if(ft.signum()<0)ft.addTo(s,ft);else return ft;return ft.signum()<0?ft.add(s):ft;}var de=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Ys=(1<<26)/de[de.length-1];function Xs(s){var m,O=this.abs();if(O.t==1&&O[0]<=de[de.length-1]){for(m=0;m<de.length;++m)if(O[0]==de[m])return!0;return!1;}if(O.isEven())return!1;for(m=1;m<de.length;){for(var N=de[m],X=m+1;X<de.length&&N<Ys;)N*=de[X++];for(N=O.modInt(N);m<X;)if(N%de[m++]==0)return!1;}return O.millerRabin(s);}function zs(s){var m=this.subtract(o.ONE),O=m.getLowestSetBit();if(O<=0)return!1;var N=m.shiftRight(O);s=s+1>>1,s>de.length&&(s=de.length);for(var X=a(),k=0;k<s;++k){X.fromInt(de[Math.floor(Math.random()*de.length)]);var _=X.modPow(N,this);if(_.compareTo(o.ONE)!=0&&_.compareTo(m)!=0){for(var ft=1;ft++<O&&_.compareTo(m)!=0;)if(_=_.modPowInt(2,this),_.compareTo(o.ONE)==0)return!1;if(_.compareTo(m)!=0)return!1;}}return!0;}o.prototype.chunkSize=pt,o.prototype.toRadix=Tt,o.prototype.fromRadix=vt,o.prototype.fromNumber=mt,o.prototype.bitwiseTo=Nt,o.prototype.changeBit=dr,o.prototype.addTo=vs,o.prototype.dMultiply=Os,o.prototype.dAddOffset=Is,o.prototype.multiplyLowerTo=Ls,o.prototype.multiplyUpperTo=ws,o.prototype.modInt=Us,o.prototype.millerRabin=zs,o.prototype.clone=J,o.prototype.intValue=q,o.prototype.byteValue=nt,o.prototype.shortValue=ut,o.prototype.signum=gt,o.prototype.toByteArray=Pt,o.prototype.equals=Mt,o.prototype.min=At,o.prototype.max=It,o.prototype.and=jt,o.prototype.or=zt,o.prototype.xor=ae,o.prototype.andNot=se,o.prototype.not=oe,o.prototype.shiftLeft=le,o.prototype.shiftRight=ce,o.prototype.getLowestSetBit=Zt,o.prototype.bitCount=Be,o.prototype.testBit=We,o.prototype.setBit=pr,o.prototype.clearBit=ps,o.prototype.flipBit=ms,o.prototype.add=ys,o.prototype.subtract=gs,o.prototype.multiply=Ps,o.prototype.divide=Ss,o.prototype.remainder=Ts,o.prototype.divideAndRemainder=Cs,o.prototype.modPow=Ws,o.prototype.modInverse=js,o.prototype.pow=As,o.prototype.gcd=Fs,o.prototype.isProbablePrime=Xs,o.prototype.square=xs;var Gt=o;Gt.prototype.IsNegative=function(){return this.compareTo(Gt.ZERO)==-1;},Gt.op_Equality=function(s,m){return s.compareTo(m)==0;},Gt.op_Inequality=function(s,m){return s.compareTo(m)!=0;},Gt.op_GreaterThan=function(s,m){return s.compareTo(m)>0;},Gt.op_LessThan=function(s,m){return s.compareTo(m)<0;},Gt.op_Addition=function(s,m){return new Gt(s,void 0,void 0).add(new Gt(m,void 0,void 0));},Gt.op_Subtraction=function(s,m){return new Gt(s,void 0,void 0).subtract(new Gt(m,void 0,void 0));},Gt.Int128Mul=function(s,m){return new Gt(s,void 0,void 0).multiply(new Gt(m,void 0,void 0));},Gt.op_Division=function(s,m){return s.divide(m);},Gt.prototype.ToDouble=function(){return parseFloat(this.toString());};var gn=function gn(s,m){var O;if(_typeof(Object.getOwnPropertyNames)>"u"){for(O in m.prototype)(_typeof(s.prototype[O])>"u"||s.prototype[O]===Object.prototype[O])&&(s.prototype[O]=m.prototype[O]);for(O in m)_typeof(s[O])>"u"&&(s[O]=m[O]);s.$baseCtor=m;}else{for(var N=Object.getOwnPropertyNames(m.prototype),X=0;X<N.length;X++)_typeof(Object.getOwnPropertyDescriptor(s.prototype,N[X]))>"u"&&Object.defineProperty(s.prototype,N[X],Object.getOwnPropertyDescriptor(m.prototype,N[X]));for(O in m)_typeof(s[O])>"u"&&(s[O]=m[O]);s.$baseCtor=m;}};e.Path=function(){return[];},e.Path.prototype.push=Array.prototype.push,e.Paths=function(){return[];},e.Paths.prototype.push=Array.prototype.push,e.DoublePoint=function(){var s=arguments;this.X=0,this.Y=0,s.length===1?(this.X=s[0].X,this.Y=s[0].Y):s.length===2&&(this.X=s[0],this.Y=s[1]);},e.DoublePoint0=function(){this.X=0,this.Y=0;},e.DoublePoint0.prototype=e.DoublePoint.prototype,e.DoublePoint1=function(s){this.X=s.X,this.Y=s.Y;},e.DoublePoint1.prototype=e.DoublePoint.prototype,e.DoublePoint2=function(s,m){this.X=s,this.Y=m;},e.DoublePoint2.prototype=e.DoublePoint.prototype,e.PolyNode=function(){this.m_Parent=null,this.m_polygon=new e.Path(),this.m_Index=0,this.m_jointype=0,this.m_endtype=0,this.m_Childs=[],this.IsOpen=!1;},e.PolyNode.prototype.IsHoleNode=function(){for(var s=!0,m=this.m_Parent;m!==null;)s=!s,m=m.m_Parent;return s;},e.PolyNode.prototype.ChildCount=function(){return this.m_Childs.length;},e.PolyNode.prototype.Contour=function(){return this.m_polygon;},e.PolyNode.prototype.AddChild=function(s){var m=this.m_Childs.length;this.m_Childs.push(s),s.m_Parent=this,s.m_Index=m;},e.PolyNode.prototype.GetNext=function(){return this.m_Childs.length>0?this.m_Childs[0]:this.GetNextSiblingUp();},e.PolyNode.prototype.GetNextSiblingUp=function(){return this.m_Parent===null?null:this.m_Index===this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+1];},e.PolyNode.prototype.Childs=function(){return this.m_Childs;},e.PolyNode.prototype.Parent=function(){return this.m_Parent;},e.PolyNode.prototype.IsHole=function(){return this.IsHoleNode();},e.PolyTree=function(){this.m_AllPolys=[],e.PolyNode.call(this);},e.PolyTree.prototype.Clear=function(){for(var s=0,m=this.m_AllPolys.length;s<m;s++)this.m_AllPolys[s]=null;this.m_AllPolys.length=0,this.m_Childs.length=0;},e.PolyTree.prototype.GetFirst=function(){return this.m_Childs.length>0?this.m_Childs[0]:null;},e.PolyTree.prototype.Total=function(){var s=this.m_AllPolys.length;return s>0&&this.m_Childs[0]!==this.m_AllPolys[0]&&s--,s;},gn(e.PolyTree,e.PolyNode),e.Math_Abs_Int64=e.Math_Abs_Int32=e.Math_Abs_Double=function(s){return Math.abs(s);},e.Math_Max_Int32_Int32=function(s,m){return Math.max(s,m);},i.msie||i.opera||i.safari?e.Cast_Int32=function(s){return s|0;}:e.Cast_Int32=function(s){return~~s;},_typeof(Number.toInteger)>"u"&&(Number.toInteger=null),i.chrome?e.Cast_Int64=function(s){return s<-2147483648||s>2147483647?s<0?Math.ceil(s):Math.floor(s):~~s;}:i.firefox&&typeof Number.toInteger=="function"?e.Cast_Int64=function(s){return Number.toInteger(s);}:i.msie7||i.msie8?e.Cast_Int64=function(s){return parseInt(s,10);}:i.msie?e.Cast_Int64=function(s){return s<-2147483648||s>2147483647?s<0?Math.ceil(s):Math.floor(s):s|0;}:e.Cast_Int64=function(s){return s<0?Math.ceil(s):Math.floor(s);},e.Clear=function(s){s.length=0;},e.PI=3.141592653589793,e.PI2=2*3.141592653589793,e.IntPoint=function(){var s=arguments,m=s.length;if(this.X=0,this.Y=0,e.use_xyz){if(this.Z=0,m===3)this.X=s[0],this.Y=s[1],this.Z=s[2];else if(m===2)this.X=s[0],this.Y=s[1],this.Z=0;else if(m===1){if(s[0]instanceof e.DoublePoint){var O=s[0];this.X=e.Clipper.Round(O.X),this.Y=e.Clipper.Round(O.Y),this.Z=0;}else{var N=s[0];_typeof(N.Z)>"u"&&(N.Z=0),this.X=N.X,this.Y=N.Y,this.Z=N.Z;}}else this.X=0,this.Y=0,this.Z=0;}else if(m===2)this.X=s[0],this.Y=s[1];else if(m===1){if(s[0]instanceof e.DoublePoint){var O=s[0];this.X=e.Clipper.Round(O.X),this.Y=e.Clipper.Round(O.Y);}else{var N=s[0];this.X=N.X,this.Y=N.Y;}}else this.X=0,this.Y=0;},e.IntPoint.op_Equality=function(s,m){return s.X===m.X&&s.Y===m.Y;},e.IntPoint.op_Inequality=function(s,m){return s.X!==m.X||s.Y!==m.Y;},e.IntPoint0=function(){this.X=0,this.Y=0,e.use_xyz&&(this.Z=0);},e.IntPoint0.prototype=e.IntPoint.prototype,e.IntPoint1=function(s){this.X=s.X,this.Y=s.Y,e.use_xyz&&(_typeof(s.Z)>"u"?this.Z=0:this.Z=s.Z);},e.IntPoint1.prototype=e.IntPoint.prototype,e.IntPoint1dp=function(s){this.X=e.Clipper.Round(s.X),this.Y=e.Clipper.Round(s.Y),e.use_xyz&&(this.Z=0);},e.IntPoint1dp.prototype=e.IntPoint.prototype,e.IntPoint2=function(s,m,O){this.X=s,this.Y=m,e.use_xyz&&(_typeof(O)>"u"?this.Z=0:this.Z=O);},e.IntPoint2.prototype=e.IntPoint.prototype,e.IntRect=function(){var s=arguments,m=s.length;if(m===4)this.left=s[0],this.top=s[1],this.right=s[2],this.bottom=s[3];else if(m===1){var O=s[0];this.left=O.left,this.top=O.top,this.right=O.right,this.bottom=O.bottom;}else this.left=0,this.top=0,this.right=0,this.bottom=0;},e.IntRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0;},e.IntRect0.prototype=e.IntRect.prototype,e.IntRect1=function(s){this.left=s.left,this.top=s.top,this.right=s.right,this.bottom=s.bottom;},e.IntRect1.prototype=e.IntRect.prototype,e.IntRect4=function(s,m,O,N){this.left=s,this.top=m,this.right=O,this.bottom=N;},e.IntRect4.prototype=e.IntRect.prototype,e.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},e.PolyType={ptSubject:0,ptClip:1},e.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},e.JoinType={jtSquare:0,jtRound:1,jtMiter:2},e.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},e.EdgeSide={esLeft:0,esRight:1},e.Direction={dRightToLeft:0,dLeftToRight:1},e.TEdge=function(){this.Bot=new e.IntPoint0(),this.Curr=new e.IntPoint0(),this.Top=new e.IntPoint0(),this.Delta=new e.IntPoint0(),this.Dx=0,this.PolyTyp=e.PolyType.ptSubject,this.Side=e.EdgeSide.esLeft,this.WindDelta=0,this.WindCnt=0,this.WindCnt2=0,this.OutIdx=0,this.Next=null,this.Prev=null,this.NextInLML=null,this.NextInAEL=null,this.PrevInAEL=null,this.NextInSEL=null,this.PrevInSEL=null;},e.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new e.IntPoint0();},e.MyIntersectNodeSort=function(){},e.MyIntersectNodeSort.Compare=function(s,m){var O=m.Pt.Y-s.Pt.Y;return O>0?1:O<0?-1:0;},e.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null;},e.Scanbeam=function(){this.Y=0,this.Next=null;},e.Maxima=function(){this.X=0,this.Next=null,this.Prev=null;},e.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null;},e.OutPt=function(){this.Idx=0,this.Pt=new e.IntPoint0(),this.Next=null,this.Prev=null;},e.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new e.IntPoint0();},e.ClipperBase=function(){this.m_MinimaList=null,this.m_CurrentLM=null,this.m_edges=new Array(),this.m_UseFullRange=!1,this.m_HasOpenPaths=!1,this.PreserveCollinear=!1,this.m_Scanbeam=null,this.m_PolyOuts=null,this.m_ActiveEdges=null;},e.ClipperBase.horizontal=-9007199254740992,e.ClipperBase.Skip=-2,e.ClipperBase.Unassigned=-1,e.ClipperBase.tolerance=1e-20,e.ClipperBase.loRange=47453132,e.ClipperBase.hiRange=4503599627370495,e.ClipperBase.near_zero=function(s){return s>-e.ClipperBase.tolerance&&s<e.ClipperBase.tolerance;},e.ClipperBase.IsHorizontal=function(s){return s.Delta.Y===0;},e.ClipperBase.prototype.PointIsVertex=function(s,m){var O=m;do{if(e.IntPoint.op_Equality(O.Pt,s))return!0;O=O.Next;}while(O!==m);return!1;},e.ClipperBase.prototype.PointOnLineSegment=function(s,m,O,N){return N?s.X===m.X&&s.Y===m.Y||s.X===O.X&&s.Y===O.Y||s.X>m.X==s.X<O.X&&s.Y>m.Y==s.Y<O.Y&&Gt.op_Equality(Gt.Int128Mul(s.X-m.X,O.Y-m.Y),Gt.Int128Mul(O.X-m.X,s.Y-m.Y)):s.X===m.X&&s.Y===m.Y||s.X===O.X&&s.Y===O.Y||s.X>m.X==s.X<O.X&&s.Y>m.Y==s.Y<O.Y&&(s.X-m.X)*(O.Y-m.Y)===(O.X-m.X)*(s.Y-m.Y);},e.ClipperBase.prototype.PointOnPolygon=function(s,m,O){for(var N=m;;){if(this.PointOnLineSegment(s,N.Pt,N.Next.Pt,O))return!0;if(N=N.Next,N===m)break;}return!1;},e.ClipperBase.prototype.SlopesEqual=e.ClipperBase.SlopesEqual=function(){var s=arguments,m=s.length,O,N,X,k,_,ft,ht;return m===3?(O=s[0],N=s[1],ht=s[2],ht?Gt.op_Equality(Gt.Int128Mul(O.Delta.Y,N.Delta.X),Gt.Int128Mul(O.Delta.X,N.Delta.Y)):e.Cast_Int64(O.Delta.Y*N.Delta.X)===e.Cast_Int64(O.Delta.X*N.Delta.Y)):m===4?(X=s[0],k=s[1],_=s[2],ht=s[3],ht?Gt.op_Equality(Gt.Int128Mul(X.Y-k.Y,k.X-_.X),Gt.Int128Mul(X.X-k.X,k.Y-_.Y)):e.Cast_Int64((X.Y-k.Y)*(k.X-_.X))-e.Cast_Int64((X.X-k.X)*(k.Y-_.Y))===0):(X=s[0],k=s[1],_=s[2],ft=s[3],ht=s[4],ht?Gt.op_Equality(Gt.Int128Mul(X.Y-k.Y,_.X-ft.X),Gt.Int128Mul(X.X-k.X,_.Y-ft.Y)):e.Cast_Int64((X.Y-k.Y)*(_.X-ft.X))-e.Cast_Int64((X.X-k.X)*(_.Y-ft.Y))===0);},e.ClipperBase.SlopesEqual3=function(s,m,O){return O?Gt.op_Equality(Gt.Int128Mul(s.Delta.Y,m.Delta.X),Gt.Int128Mul(s.Delta.X,m.Delta.Y)):e.Cast_Int64(s.Delta.Y*m.Delta.X)===e.Cast_Int64(s.Delta.X*m.Delta.Y);},e.ClipperBase.SlopesEqual4=function(s,m,O,N){return N?Gt.op_Equality(Gt.Int128Mul(s.Y-m.Y,m.X-O.X),Gt.Int128Mul(s.X-m.X,m.Y-O.Y)):e.Cast_Int64((s.Y-m.Y)*(m.X-O.X))-e.Cast_Int64((s.X-m.X)*(m.Y-O.Y))===0;},e.ClipperBase.SlopesEqual5=function(s,m,O,N,X){return X?Gt.op_Equality(Gt.Int128Mul(s.Y-m.Y,O.X-N.X),Gt.Int128Mul(s.X-m.X,O.Y-N.Y)):e.Cast_Int64((s.Y-m.Y)*(O.X-N.X))-e.Cast_Int64((s.X-m.X)*(O.Y-N.Y))===0;},e.ClipperBase.prototype.Clear=function(){this.DisposeLocalMinimaList();for(var s=0,m=this.m_edges.length;s<m;++s){for(var O=0,N=this.m_edges[s].length;O<N;++O)this.m_edges[s][O]=null;e.Clear(this.m_edges[s]);}e.Clear(this.m_edges),this.m_UseFullRange=!1,this.m_HasOpenPaths=!1;},e.ClipperBase.prototype.DisposeLocalMinimaList=function(){for(;this.m_MinimaList!==null;){var s=this.m_MinimaList.Next;this.m_MinimaList=null,this.m_MinimaList=s;}this.m_CurrentLM=null;},e.ClipperBase.prototype.RangeTest=function(s,m){m.Value?(s.X>e.ClipperBase.hiRange||s.Y>e.ClipperBase.hiRange||-s.X>e.ClipperBase.hiRange||-s.Y>e.ClipperBase.hiRange)&&e.Error("Coordinate outside allowed range in RangeTest()."):(s.X>e.ClipperBase.loRange||s.Y>e.ClipperBase.loRange||-s.X>e.ClipperBase.loRange||-s.Y>e.ClipperBase.loRange)&&(m.Value=!0,this.RangeTest(s,m));},e.ClipperBase.prototype.InitEdge=function(s,m,O,N){s.Next=m,s.Prev=O,s.Curr.X=N.X,s.Curr.Y=N.Y,e.use_xyz&&(s.Curr.Z=N.Z),s.OutIdx=-1;},e.ClipperBase.prototype.InitEdge2=function(s,m){s.Curr.Y>=s.Next.Curr.Y?(s.Bot.X=s.Curr.X,s.Bot.Y=s.Curr.Y,e.use_xyz&&(s.Bot.Z=s.Curr.Z),s.Top.X=s.Next.Curr.X,s.Top.Y=s.Next.Curr.Y,e.use_xyz&&(s.Top.Z=s.Next.Curr.Z)):(s.Top.X=s.Curr.X,s.Top.Y=s.Curr.Y,e.use_xyz&&(s.Top.Z=s.Curr.Z),s.Bot.X=s.Next.Curr.X,s.Bot.Y=s.Next.Curr.Y,e.use_xyz&&(s.Bot.Z=s.Next.Curr.Z)),this.SetDx(s),s.PolyTyp=m;},e.ClipperBase.prototype.FindNextLocMin=function(s){for(var m;;){for(;e.IntPoint.op_Inequality(s.Bot,s.Prev.Bot)||e.IntPoint.op_Equality(s.Curr,s.Top);)s=s.Next;if(s.Dx!==e.ClipperBase.horizontal&&s.Prev.Dx!==e.ClipperBase.horizontal)break;for(;s.Prev.Dx===e.ClipperBase.horizontal;)s=s.Prev;for(m=s;s.Dx===e.ClipperBase.horizontal;)s=s.Next;if(s.Top.Y!==s.Prev.Bot.Y){m.Prev.Bot.X<s.Bot.X&&(s=m);break;}}return s;},e.ClipperBase.prototype.ProcessBound=function(s,m){var O,N=s,X;if(N.OutIdx===e.ClipperBase.Skip){if(s=N,m){for(;s.Top.Y===s.Next.Bot.Y;)s=s.Next;for(;s!==N&&s.Dx===e.ClipperBase.horizontal;)s=s.Prev;}else{for(;s.Top.Y===s.Prev.Bot.Y;)s=s.Prev;for(;s!==N&&s.Dx===e.ClipperBase.horizontal;)s=s.Next;}if(s===N)m?N=s.Next:N=s.Prev;else{m?s=N.Next:s=N.Prev;var k=new e.LocalMinima();k.Next=null,k.Y=s.Bot.Y,k.LeftBound=null,k.RightBound=s,s.WindDelta=0,N=this.ProcessBound(s,m),this.InsertLocalMinima(k);}return N;}if(s.Dx===e.ClipperBase.horizontal&&(m?O=s.Prev:O=s.Next,O.Dx===e.ClipperBase.horizontal?O.Bot.X!==s.Bot.X&&O.Top.X!==s.Bot.X&&this.ReverseHorizontal(s):O.Bot.X!==s.Bot.X&&this.ReverseHorizontal(s)),O=s,m){for(;N.Top.Y===N.Next.Bot.Y&&N.Next.OutIdx!==e.ClipperBase.Skip;)N=N.Next;if(N.Dx===e.ClipperBase.horizontal&&N.Next.OutIdx!==e.ClipperBase.Skip){for(X=N;X.Prev.Dx===e.ClipperBase.horizontal;)X=X.Prev;X.Prev.Top.X>N.Next.Top.X&&(N=X.Prev);}for(;s!==N;)s.NextInLML=s.Next,s.Dx===e.ClipperBase.horizontal&&s!==O&&s.Bot.X!==s.Prev.Top.X&&this.ReverseHorizontal(s),s=s.Next;s.Dx===e.ClipperBase.horizontal&&s!==O&&s.Bot.X!==s.Prev.Top.X&&this.ReverseHorizontal(s),N=N.Next;}else{for(;N.Top.Y===N.Prev.Bot.Y&&N.Prev.OutIdx!==e.ClipperBase.Skip;)N=N.Prev;if(N.Dx===e.ClipperBase.horizontal&&N.Prev.OutIdx!==e.ClipperBase.Skip){for(X=N;X.Next.Dx===e.ClipperBase.horizontal;)X=X.Next;(X.Next.Top.X===N.Prev.Top.X||X.Next.Top.X>N.Prev.Top.X)&&(N=X.Next);}for(;s!==N;)s.NextInLML=s.Prev,s.Dx===e.ClipperBase.horizontal&&s!==O&&s.Bot.X!==s.Next.Top.X&&this.ReverseHorizontal(s),s=s.Prev;s.Dx===e.ClipperBase.horizontal&&s!==O&&s.Bot.X!==s.Next.Top.X&&this.ReverseHorizontal(s),N=N.Prev;}return N;},e.ClipperBase.prototype.AddPath=function(s,m,O){e.use_lines?!O&&m===e.PolyType.ptClip&&e.Error("AddPath: Open paths must be subject."):O||e.Error("AddPath: Open paths have been disabled.");var N=s.length-1;if(O)for(;N>0&&e.IntPoint.op_Equality(s[N],s[0]);)--N;for(;N>0&&e.IntPoint.op_Equality(s[N],s[N-1]);)--N;if(O&&N<2||!O&&N<1)return!1;for(var X=new Array(),k=0;k<=N;k++)X.push(new e.TEdge());var _=!0;X[1].Curr.X=s[1].X,X[1].Curr.Y=s[1].Y,e.use_xyz&&(X[1].Curr.Z=s[1].Z);var ft={Value:this.m_UseFullRange};this.RangeTest(s[0],ft),this.m_UseFullRange=ft.Value,ft.Value=this.m_UseFullRange,this.RangeTest(s[N],ft),this.m_UseFullRange=ft.Value,this.InitEdge(X[0],X[1],X[N],s[0]),this.InitEdge(X[N],X[0],X[N-1],s[N]);for(var k=N-1;k>=1;--k)ft.Value=this.m_UseFullRange,this.RangeTest(s[k],ft),this.m_UseFullRange=ft.Value,this.InitEdge(X[k],X[k+1],X[k-1],s[k]);for(var ht=X[0],Ct=ht,wt=ht;;){if(Ct.Curr===Ct.Next.Curr&&(O||Ct.Next!==ht)){if(Ct===Ct.Next)break;Ct===ht&&(ht=Ct.Next),Ct=this.RemoveEdge(Ct),wt=Ct;continue;}if(Ct.Prev===Ct.Next)break;if(O&&e.ClipperBase.SlopesEqual4(Ct.Prev.Curr,Ct.Curr,Ct.Next.Curr,this.m_UseFullRange)&&(!this.PreserveCollinear||!this.Pt2IsBetweenPt1AndPt3(Ct.Prev.Curr,Ct.Curr,Ct.Next.Curr))){Ct===ht&&(ht=Ct.Next),Ct=this.RemoveEdge(Ct),Ct=Ct.Prev,wt=Ct;continue;}if(Ct=Ct.Next,Ct===wt||!O&&Ct.Next===ht)break;}if(!O&&Ct===Ct.Next||O&&Ct.Prev===Ct.Next)return!1;O||(this.m_HasOpenPaths=!0,ht.Prev.OutIdx=e.ClipperBase.Skip),Ct=ht;do this.InitEdge2(Ct,m),Ct=Ct.Next,_&&Ct.Curr.Y!==ht.Curr.Y&&(_=!1);while(Ct!==ht);if(_){if(O)return!1;Ct.Prev.OutIdx=e.ClipperBase.Skip;var Lt=new e.LocalMinima();for(Lt.Next=null,Lt.Y=Ct.Bot.Y,Lt.LeftBound=null,Lt.RightBound=Ct,Lt.RightBound.Side=e.EdgeSide.esRight,Lt.RightBound.WindDelta=0;Ct.Bot.X!==Ct.Prev.Top.X&&this.ReverseHorizontal(Ct),Ct.Next.OutIdx!==e.ClipperBase.Skip;)Ct.NextInLML=Ct.Next,Ct=Ct.Next;return this.InsertLocalMinima(Lt),this.m_edges.push(X),!0;}this.m_edges.push(X);var Bt,Yt=null;for(e.IntPoint.op_Equality(Ct.Prev.Bot,Ct.Prev.Top)&&(Ct=Ct.Next);Ct=this.FindNextLocMin(Ct),Ct!==Yt;){Yt===null&&(Yt=Ct);var Lt=new e.LocalMinima();Lt.Next=null,Lt.Y=Ct.Bot.Y,Ct.Dx<Ct.Prev.Dx?(Lt.LeftBound=Ct.Prev,Lt.RightBound=Ct,Bt=!1):(Lt.LeftBound=Ct,Lt.RightBound=Ct.Prev,Bt=!0),Lt.LeftBound.Side=e.EdgeSide.esLeft,Lt.RightBound.Side=e.EdgeSide.esRight,O?Lt.LeftBound.Next===Lt.RightBound?Lt.LeftBound.WindDelta=-1:Lt.LeftBound.WindDelta=1:Lt.LeftBound.WindDelta=0,Lt.RightBound.WindDelta=-Lt.LeftBound.WindDelta,Ct=this.ProcessBound(Lt.LeftBound,Bt),Ct.OutIdx===e.ClipperBase.Skip&&(Ct=this.ProcessBound(Ct,Bt));var Ht=this.ProcessBound(Lt.RightBound,!Bt);Ht.OutIdx===e.ClipperBase.Skip&&(Ht=this.ProcessBound(Ht,!Bt)),Lt.LeftBound.OutIdx===e.ClipperBase.Skip?Lt.LeftBound=null:Lt.RightBound.OutIdx===e.ClipperBase.Skip&&(Lt.RightBound=null),this.InsertLocalMinima(Lt),Bt||(Ct=Ht);}return!0;},e.ClipperBase.prototype.AddPaths=function(s,m,O){for(var N=!1,X=0,k=s.length;X<k;++X)this.AddPath(s[X],m,O)&&(N=!0);return N;},e.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(s,m,O){return e.IntPoint.op_Equality(s,O)||e.IntPoint.op_Equality(s,m)||e.IntPoint.op_Equality(O,m)?!1:s.X!==O.X?m.X>s.X==m.X<O.X:m.Y>s.Y==m.Y<O.Y;},e.ClipperBase.prototype.RemoveEdge=function(s){s.Prev.Next=s.Next,s.Next.Prev=s.Prev;var m=s.Next;return s.Prev=null,m;},e.ClipperBase.prototype.SetDx=function(s){s.Delta.X=s.Top.X-s.Bot.X,s.Delta.Y=s.Top.Y-s.Bot.Y,s.Delta.Y===0?s.Dx=e.ClipperBase.horizontal:s.Dx=s.Delta.X/s.Delta.Y;},e.ClipperBase.prototype.InsertLocalMinima=function(s){if(this.m_MinimaList===null)this.m_MinimaList=s;else if(s.Y>=this.m_MinimaList.Y)s.Next=this.m_MinimaList,this.m_MinimaList=s;else{for(var m=this.m_MinimaList;m.Next!==null&&s.Y<m.Next.Y;)m=m.Next;s.Next=m.Next,m.Next=s;}},e.ClipperBase.prototype.PopLocalMinima=function(s,m){return m.v=this.m_CurrentLM,this.m_CurrentLM!==null&&this.m_CurrentLM.Y===s?(this.m_CurrentLM=this.m_CurrentLM.Next,!0):!1;},e.ClipperBase.prototype.ReverseHorizontal=function(s){var m=s.Top.X;s.Top.X=s.Bot.X,s.Bot.X=m,e.use_xyz&&(m=s.Top.Z,s.Top.Z=s.Bot.Z,s.Bot.Z=m);},e.ClipperBase.prototype.Reset=function(){if(this.m_CurrentLM=this.m_MinimaList,this.m_CurrentLM!==null){this.m_Scanbeam=null;for(var s=this.m_MinimaList;s!==null;){this.InsertScanbeam(s.Y);var m=s.LeftBound;m!==null&&(m.Curr.X=m.Bot.X,m.Curr.Y=m.Bot.Y,e.use_xyz&&(m.Curr.Z=m.Bot.Z),m.OutIdx=e.ClipperBase.Unassigned),m=s.RightBound,m!==null&&(m.Curr.X=m.Bot.X,m.Curr.Y=m.Bot.Y,e.use_xyz&&(m.Curr.Z=m.Bot.Z),m.OutIdx=e.ClipperBase.Unassigned),s=s.Next;}this.m_ActiveEdges=null;}},e.ClipperBase.prototype.InsertScanbeam=function(s){if(this.m_Scanbeam===null)this.m_Scanbeam=new e.Scanbeam(),this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=s;else if(s>this.m_Scanbeam.Y){var m=new e.Scanbeam();m.Y=s,m.Next=this.m_Scanbeam,this.m_Scanbeam=m;}else{for(var O=this.m_Scanbeam;O.Next!==null&&s<=O.Next.Y;)O=O.Next;if(s===O.Y)return;var N=new e.Scanbeam();N.Y=s,N.Next=O.Next,O.Next=N;}},e.ClipperBase.prototype.PopScanbeam=function(s){return this.m_Scanbeam===null?(s.v=0,!1):(s.v=this.m_Scanbeam.Y,this.m_Scanbeam=this.m_Scanbeam.Next,!0);},e.ClipperBase.prototype.LocalMinimaPending=function(){return this.m_CurrentLM!==null;},e.ClipperBase.prototype.CreateOutRec=function(){var s=new e.OutRec();return s.Idx=e.ClipperBase.Unassigned,s.IsHole=!1,s.IsOpen=!1,s.FirstLeft=null,s.Pts=null,s.BottomPt=null,s.PolyNode=null,this.m_PolyOuts.push(s),s.Idx=this.m_PolyOuts.length-1,s;},e.ClipperBase.prototype.DisposeOutRec=function(s){var m=this.m_PolyOuts[s];m.Pts=null,m=null,this.m_PolyOuts[s]=null;},e.ClipperBase.prototype.UpdateEdgeIntoAEL=function(s){s.NextInLML===null&&e.Error("UpdateEdgeIntoAEL: invalid call");var m=s.PrevInAEL,O=s.NextInAEL;return s.NextInLML.OutIdx=s.OutIdx,m!==null?m.NextInAEL=s.NextInLML:this.m_ActiveEdges=s.NextInLML,O!==null&&(O.PrevInAEL=s.NextInLML),s.NextInLML.Side=s.Side,s.NextInLML.WindDelta=s.WindDelta,s.NextInLML.WindCnt=s.WindCnt,s.NextInLML.WindCnt2=s.WindCnt2,s=s.NextInLML,s.Curr.X=s.Bot.X,s.Curr.Y=s.Bot.Y,s.PrevInAEL=m,s.NextInAEL=O,e.ClipperBase.IsHorizontal(s)||this.InsertScanbeam(s.Top.Y),s;},e.ClipperBase.prototype.SwapPositionsInAEL=function(s,m){if(!(s.NextInAEL===s.PrevInAEL||m.NextInAEL===m.PrevInAEL)){if(s.NextInAEL===m){var O=m.NextInAEL;O!==null&&(O.PrevInAEL=s);var N=s.PrevInAEL;N!==null&&(N.NextInAEL=m),m.PrevInAEL=N,m.NextInAEL=s,s.PrevInAEL=m,s.NextInAEL=O;}else if(m.NextInAEL===s){var X=s.NextInAEL;X!==null&&(X.PrevInAEL=m);var k=m.PrevInAEL;k!==null&&(k.NextInAEL=s),s.PrevInAEL=k,s.NextInAEL=m,m.PrevInAEL=s,m.NextInAEL=X;}else{var _=s.NextInAEL,ft=s.PrevInAEL;s.NextInAEL=m.NextInAEL,s.NextInAEL!==null&&(s.NextInAEL.PrevInAEL=s),s.PrevInAEL=m.PrevInAEL,s.PrevInAEL!==null&&(s.PrevInAEL.NextInAEL=s),m.NextInAEL=_,m.NextInAEL!==null&&(m.NextInAEL.PrevInAEL=m),m.PrevInAEL=ft,m.PrevInAEL!==null&&(m.PrevInAEL.NextInAEL=m);}s.PrevInAEL===null?this.m_ActiveEdges=s:m.PrevInAEL===null&&(this.m_ActiveEdges=m);}},e.ClipperBase.prototype.DeleteFromAEL=function(s){var m=s.PrevInAEL,O=s.NextInAEL;m===null&&O===null&&s!==this.m_ActiveEdges||(m!==null?m.NextInAEL=O:this.m_ActiveEdges=O,O!==null&&(O.PrevInAEL=m),s.NextInAEL=null,s.PrevInAEL=null);},e.Clipper=function(s){_typeof(s)>"u"&&(s=0),this.m_PolyOuts=null,this.m_ClipType=e.ClipType.ctIntersection,this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=null,this.m_IntersectNodeComparer=null,this.m_ExecuteLocked=!1,this.m_ClipFillType=e.PolyFillType.pftEvenOdd,this.m_SubjFillType=e.PolyFillType.pftEvenOdd,this.m_Joins=null,this.m_GhostJoins=null,this.m_UsingPolyTree=!1,this.ReverseSolution=!1,this.StrictlySimple=!1,e.ClipperBase.call(this),this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=new Array(),this.m_IntersectNodeComparer=e.MyIntersectNodeSort.Compare,this.m_ExecuteLocked=!1,this.m_UsingPolyTree=!1,this.m_PolyOuts=new Array(),this.m_Joins=new Array(),this.m_GhostJoins=new Array(),this.ReverseSolution=(1&s)!==0,this.StrictlySimple=(2&s)!==0,this.PreserveCollinear=(4&s)!==0,e.use_xyz&&(this.ZFillFunction=null);},e.Clipper.ioReverseSolution=1,e.Clipper.ioStrictlySimple=2,e.Clipper.ioPreserveCollinear=4,e.Clipper.prototype.Clear=function(){this.m_edges.length!==0&&(this.DisposeAllPolyPts(),e.ClipperBase.prototype.Clear.call(this));},e.Clipper.prototype.InsertMaxima=function(s){var m=new e.Maxima();if(m.X=s,this.m_Maxima===null)this.m_Maxima=m,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(s<this.m_Maxima.X)m.Next=this.m_Maxima,m.Prev=null,this.m_Maxima=m;else{for(var O=this.m_Maxima;O.Next!==null&&s>=O.Next.X;)O=O.Next;if(s===O.X)return;m.Next=O.Next,m.Prev=O,O.Next!==null&&(O.Next.Prev=m),O.Next=m;}},e.Clipper.prototype.Execute=function(){var s=arguments,m=s.length,O=s[1]instanceof e.PolyTree;if(m===4&&!O){var N=s[0],X=s[1],k=s[2],_=s[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&e.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,e.Clear(X),this.m_SubjFillType=k,this.m_ClipFillType=_,this.m_ClipType=N,this.m_UsingPolyTree=!1;try{var ft=this.ExecuteInternal();ft&&this.BuildResult(X);}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1;}return ft;}else if(m===4&&O){var N=s[0],ht=s[1],k=s[2],_=s[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=k,this.m_ClipFillType=_,this.m_ClipType=N,this.m_UsingPolyTree=!0;try{var ft=this.ExecuteInternal();ft&&this.BuildResult2(ht);}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1;}return ft;}else if(m===2&&!O){var N=s[0],X=s[1];return this.Execute(N,X,e.PolyFillType.pftEvenOdd,e.PolyFillType.pftEvenOdd);}else if(m===2&&O){var N=s[0],ht=s[1];return this.Execute(N,ht,e.PolyFillType.pftEvenOdd,e.PolyFillType.pftEvenOdd);}},e.Clipper.prototype.FixHoleLinkage=function(s){if(!(s.FirstLeft===null||s.IsHole!==s.FirstLeft.IsHole&&s.FirstLeft.Pts!==null)){for(var m=s.FirstLeft;m!==null&&(m.IsHole===s.IsHole||m.Pts===null);)m=m.FirstLeft;s.FirstLeft=m;}},e.Clipper.prototype.ExecuteInternal=function(){try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var s={},m={};if(!this.PopScanbeam(s))return!1;for(this.InsertLocalMinimaIntoAEL(s.v);this.PopScanbeam(m)||this.LocalMinimaPending();){if(this.ProcessHorizontals(),this.m_GhostJoins.length=0,!this.ProcessIntersections(m.v))return!1;this.ProcessEdgesAtTopOfScanbeam(m.v),s.v=m.v,this.InsertLocalMinimaIntoAEL(s.v);}var O,N,X;for(N=0,X=this.m_PolyOuts.length;N<X;N++)O=this.m_PolyOuts[N],!(O.Pts===null||O.IsOpen)&&(O.IsHole^this.ReverseSolution)==this.Area$1(O)>0&&this.ReversePolyPtLinks(O.Pts);for(this.JoinCommonEdges(),N=0,X=this.m_PolyOuts.length;N<X;N++)O=this.m_PolyOuts[N],O.Pts!==null&&(O.IsOpen?this.FixupOutPolyline(O):this.FixupOutPolygon(O));return this.StrictlySimple&&this.DoSimplePolygons(),!0;}finally{this.m_Joins.length=0,this.m_GhostJoins.length=0;}},e.Clipper.prototype.DisposeAllPolyPts=function(){for(var s=0,m=this.m_PolyOuts.length;s<m;++s)this.DisposeOutRec(s);e.Clear(this.m_PolyOuts);},e.Clipper.prototype.AddJoin=function(s,m,O){var N=new e.Join();N.OutPt1=s,N.OutPt2=m,N.OffPt.X=O.X,N.OffPt.Y=O.Y,e.use_xyz&&(N.OffPt.Z=O.Z),this.m_Joins.push(N);},e.Clipper.prototype.AddGhostJoin=function(s,m){var O=new e.Join();O.OutPt1=s,O.OffPt.X=m.X,O.OffPt.Y=m.Y,e.use_xyz&&(O.OffPt.Z=m.Z),this.m_GhostJoins.push(O);},e.Clipper.prototype.SetZ=function(s,m,O){if(this.ZFillFunction!==null){if(s.Z!==0||this.ZFillFunction===null)return;e.IntPoint.op_Equality(s,m.Bot)?s.Z=m.Bot.Z:e.IntPoint.op_Equality(s,m.Top)?s.Z=m.Top.Z:e.IntPoint.op_Equality(s,O.Bot)?s.Z=O.Bot.Z:e.IntPoint.op_Equality(s,O.Top)?s.Z=O.Top.Z:this.ZFillFunction(m.Bot,m.Top,O.Bot,O.Top,s);}},e.Clipper.prototype.InsertLocalMinimaIntoAEL=function(s){for(var m={},O,N;this.PopLocalMinima(s,m);){O=m.v.LeftBound,N=m.v.RightBound;var X=null;if(O===null?(this.InsertEdgeIntoAEL(N,null),this.SetWindingCount(N),this.IsContributing(N)&&(X=this.AddOutPt(N,N.Bot))):N===null?(this.InsertEdgeIntoAEL(O,null),this.SetWindingCount(O),this.IsContributing(O)&&(X=this.AddOutPt(O,O.Bot)),this.InsertScanbeam(O.Top.Y)):(this.InsertEdgeIntoAEL(O,null),this.InsertEdgeIntoAEL(N,O),this.SetWindingCount(O),N.WindCnt=O.WindCnt,N.WindCnt2=O.WindCnt2,this.IsContributing(O)&&(X=this.AddLocalMinPoly(O,N,O.Bot)),this.InsertScanbeam(O.Top.Y)),N!==null&&(e.ClipperBase.IsHorizontal(N)?(N.NextInLML!==null&&this.InsertScanbeam(N.NextInLML.Top.Y),this.AddEdgeToSEL(N)):this.InsertScanbeam(N.Top.Y)),!(O===null||N===null)){if(X!==null&&e.ClipperBase.IsHorizontal(N)&&this.m_GhostJoins.length>0&&N.WindDelta!==0)for(var k=0,_=this.m_GhostJoins.length;k<_;k++){var ft=this.m_GhostJoins[k];this.HorzSegmentsOverlap(ft.OutPt1.Pt.X,ft.OffPt.X,N.Bot.X,N.Top.X)&&this.AddJoin(ft.OutPt1,X,ft.OffPt);}if(O.OutIdx>=0&&O.PrevInAEL!==null&&O.PrevInAEL.Curr.X===O.Bot.X&&O.PrevInAEL.OutIdx>=0&&e.ClipperBase.SlopesEqual5(O.PrevInAEL.Curr,O.PrevInAEL.Top,O.Curr,O.Top,this.m_UseFullRange)&&O.WindDelta!==0&&O.PrevInAEL.WindDelta!==0){var ht=this.AddOutPt(O.PrevInAEL,O.Bot);this.AddJoin(X,ht,O.Top);}if(O.NextInAEL!==N){if(N.OutIdx>=0&&N.PrevInAEL.OutIdx>=0&&e.ClipperBase.SlopesEqual5(N.PrevInAEL.Curr,N.PrevInAEL.Top,N.Curr,N.Top,this.m_UseFullRange)&&N.WindDelta!==0&&N.PrevInAEL.WindDelta!==0){var ht=this.AddOutPt(N.PrevInAEL,N.Bot);this.AddJoin(X,ht,N.Top);}var Ct=O.NextInAEL;if(Ct!==null)for(;Ct!==N;)this.IntersectEdges(N,Ct,O.Curr),Ct=Ct.NextInAEL;}}}},e.Clipper.prototype.InsertEdgeIntoAEL=function(s,m){if(this.m_ActiveEdges===null)s.PrevInAEL=null,s.NextInAEL=null,this.m_ActiveEdges=s;else if(m===null&&this.E2InsertsBeforeE1(this.m_ActiveEdges,s))s.PrevInAEL=null,s.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=s,this.m_ActiveEdges=s;else{for(m===null&&(m=this.m_ActiveEdges);m.NextInAEL!==null&&!this.E2InsertsBeforeE1(m.NextInAEL,s);)m=m.NextInAEL;s.NextInAEL=m.NextInAEL,m.NextInAEL!==null&&(m.NextInAEL.PrevInAEL=s),s.PrevInAEL=m,m.NextInAEL=s;}},e.Clipper.prototype.E2InsertsBeforeE1=function(s,m){return m.Curr.X===s.Curr.X?m.Top.Y>s.Top.Y?m.Top.X<e.Clipper.TopX(s,m.Top.Y):s.Top.X>e.Clipper.TopX(m,s.Top.Y):m.Curr.X<s.Curr.X;},e.Clipper.prototype.IsEvenOddFillType=function(s){return s.PolyTyp===e.PolyType.ptSubject?this.m_SubjFillType===e.PolyFillType.pftEvenOdd:this.m_ClipFillType===e.PolyFillType.pftEvenOdd;},e.Clipper.prototype.IsEvenOddAltFillType=function(s){return s.PolyTyp===e.PolyType.ptSubject?this.m_ClipFillType===e.PolyFillType.pftEvenOdd:this.m_SubjFillType===e.PolyFillType.pftEvenOdd;},e.Clipper.prototype.IsContributing=function(s){var m,O;switch(s.PolyTyp===e.PolyType.ptSubject?(m=this.m_SubjFillType,O=this.m_ClipFillType):(m=this.m_ClipFillType,O=this.m_SubjFillType),m){case e.PolyFillType.pftEvenOdd:if(s.WindDelta===0&&s.WindCnt!==1)return!1;break;case e.PolyFillType.pftNonZero:if(Math.abs(s.WindCnt)!==1)return!1;break;case e.PolyFillType.pftPositive:if(s.WindCnt!==1)return!1;break;default:if(s.WindCnt!==-1)return!1;break;}switch(this.m_ClipType){case e.ClipType.ctIntersection:switch(O){case e.PolyFillType.pftEvenOdd:case e.PolyFillType.pftNonZero:return s.WindCnt2!==0;case e.PolyFillType.pftPositive:return s.WindCnt2>0;default:return s.WindCnt2<0;}case e.ClipType.ctUnion:switch(O){case e.PolyFillType.pftEvenOdd:case e.PolyFillType.pftNonZero:return s.WindCnt2===0;case e.PolyFillType.pftPositive:return s.WindCnt2<=0;default:return s.WindCnt2>=0;}case e.ClipType.ctDifference:if(s.PolyTyp===e.PolyType.ptSubject)switch(O){case e.PolyFillType.pftEvenOdd:case e.PolyFillType.pftNonZero:return s.WindCnt2===0;case e.PolyFillType.pftPositive:return s.WindCnt2<=0;default:return s.WindCnt2>=0;}else switch(O){case e.PolyFillType.pftEvenOdd:case e.PolyFillType.pftNonZero:return s.WindCnt2!==0;case e.PolyFillType.pftPositive:return s.WindCnt2>0;default:return s.WindCnt2<0;}case e.ClipType.ctXor:if(s.WindDelta===0)switch(O){case e.PolyFillType.pftEvenOdd:case e.PolyFillType.pftNonZero:return s.WindCnt2===0;case e.PolyFillType.pftPositive:return s.WindCnt2<=0;default:return s.WindCnt2>=0;}else return!0;}return!0;},e.Clipper.prototype.SetWindingCount=function(s){for(var m=s.PrevInAEL;m!==null&&(m.PolyTyp!==s.PolyTyp||m.WindDelta===0);)m=m.PrevInAEL;if(m===null){var O=s.PolyTyp===e.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;s.WindDelta===0?s.WindCnt=O===e.PolyFillType.pftNegative?-1:1:s.WindCnt=s.WindDelta,s.WindCnt2=0,m=this.m_ActiveEdges;}else if(s.WindDelta===0&&this.m_ClipType!==e.ClipType.ctUnion)s.WindCnt=1,s.WindCnt2=m.WindCnt2,m=m.NextInAEL;else if(this.IsEvenOddFillType(s)){if(s.WindDelta===0){for(var N=!0,X=m.PrevInAEL;X!==null;)X.PolyTyp===m.PolyTyp&&X.WindDelta!==0&&(N=!N),X=X.PrevInAEL;s.WindCnt=N?0:1;}else s.WindCnt=s.WindDelta;s.WindCnt2=m.WindCnt2,m=m.NextInAEL;}else m.WindCnt*m.WindDelta<0?Math.abs(m.WindCnt)>1?m.WindDelta*s.WindDelta<0?s.WindCnt=m.WindCnt:s.WindCnt=m.WindCnt+s.WindDelta:s.WindCnt=s.WindDelta===0?1:s.WindDelta:s.WindDelta===0?s.WindCnt=m.WindCnt<0?m.WindCnt-1:m.WindCnt+1:m.WindDelta*s.WindDelta<0?s.WindCnt=m.WindCnt:s.WindCnt=m.WindCnt+s.WindDelta,s.WindCnt2=m.WindCnt2,m=m.NextInAEL;if(this.IsEvenOddAltFillType(s))for(;m!==s;)m.WindDelta!==0&&(s.WindCnt2=s.WindCnt2===0?1:0),m=m.NextInAEL;else for(;m!==s;)s.WindCnt2+=m.WindDelta,m=m.NextInAEL;},e.Clipper.prototype.AddEdgeToSEL=function(s){this.m_SortedEdges===null?(this.m_SortedEdges=s,s.PrevInSEL=null,s.NextInSEL=null):(s.NextInSEL=this.m_SortedEdges,s.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=s,this.m_SortedEdges=s);},e.Clipper.prototype.PopEdgeFromSEL=function(s){if(s.v=this.m_SortedEdges,s.v===null)return!1;var m=s.v;return this.m_SortedEdges=s.v.NextInSEL,this.m_SortedEdges!==null&&(this.m_SortedEdges.PrevInSEL=null),m.NextInSEL=null,m.PrevInSEL=null,!0;},e.Clipper.prototype.CopyAELToSEL=function(){var s=this.m_ActiveEdges;for(this.m_SortedEdges=s;s!==null;)s.PrevInSEL=s.PrevInAEL,s.NextInSEL=s.NextInAEL,s=s.NextInAEL;},e.Clipper.prototype.SwapPositionsInSEL=function(s,m){if(!(s.NextInSEL===null&&s.PrevInSEL===null)&&!(m.NextInSEL===null&&m.PrevInSEL===null)){if(s.NextInSEL===m){var O=m.NextInSEL;O!==null&&(O.PrevInSEL=s);var N=s.PrevInSEL;N!==null&&(N.NextInSEL=m),m.PrevInSEL=N,m.NextInSEL=s,s.PrevInSEL=m,s.NextInSEL=O;}else if(m.NextInSEL===s){var O=s.NextInSEL;O!==null&&(O.PrevInSEL=m);var N=m.PrevInSEL;N!==null&&(N.NextInSEL=s),s.PrevInSEL=N,s.NextInSEL=m,m.PrevInSEL=s,m.NextInSEL=O;}else{var O=s.NextInSEL,N=s.PrevInSEL;s.NextInSEL=m.NextInSEL,s.NextInSEL!==null&&(s.NextInSEL.PrevInSEL=s),s.PrevInSEL=m.PrevInSEL,s.PrevInSEL!==null&&(s.PrevInSEL.NextInSEL=s),m.NextInSEL=O,m.NextInSEL!==null&&(m.NextInSEL.PrevInSEL=m),m.PrevInSEL=N,m.PrevInSEL!==null&&(m.PrevInSEL.NextInSEL=m);}s.PrevInSEL===null?this.m_SortedEdges=s:m.PrevInSEL===null&&(this.m_SortedEdges=m);}},e.Clipper.prototype.AddLocalMaxPoly=function(s,m,O){this.AddOutPt(s,O),m.WindDelta===0&&this.AddOutPt(m,O),s.OutIdx===m.OutIdx?(s.OutIdx=-1,m.OutIdx=-1):s.OutIdx<m.OutIdx?this.AppendPolygon(s,m):this.AppendPolygon(m,s);},e.Clipper.prototype.AddLocalMinPoly=function(s,m,O){var N,X,k;if(e.ClipperBase.IsHorizontal(m)||s.Dx>m.Dx?(N=this.AddOutPt(s,O),m.OutIdx=s.OutIdx,s.Side=e.EdgeSide.esLeft,m.Side=e.EdgeSide.esRight,X=s,X.PrevInAEL===m?k=m.PrevInAEL:k=X.PrevInAEL):(N=this.AddOutPt(m,O),s.OutIdx=m.OutIdx,s.Side=e.EdgeSide.esRight,m.Side=e.EdgeSide.esLeft,X=m,X.PrevInAEL===s?k=s.PrevInAEL:k=X.PrevInAEL),k!==null&&k.OutIdx>=0&&k.Top.Y<O.Y&&X.Top.Y<O.Y){var _=e.Clipper.TopX(k,O.Y),ft=e.Clipper.TopX(X,O.Y);if(_===ft&&X.WindDelta!==0&&k.WindDelta!==0&&e.ClipperBase.SlopesEqual5(new e.IntPoint2(_,O.Y),k.Top,new e.IntPoint2(ft,O.Y),X.Top,this.m_UseFullRange)){var ht=this.AddOutPt(k,O);this.AddJoin(N,ht,X.Top);}}return N;},e.Clipper.prototype.AddOutPt=function(s,m){if(s.OutIdx<0){var O=this.CreateOutRec();O.IsOpen=s.WindDelta===0;var N=new e.OutPt();return O.Pts=N,N.Idx=O.Idx,N.Pt.X=m.X,N.Pt.Y=m.Y,e.use_xyz&&(N.Pt.Z=m.Z),N.Next=N,N.Prev=N,O.IsOpen||this.SetHoleState(s,O),s.OutIdx=O.Idx,N;}else{var O=this.m_PolyOuts[s.OutIdx],X=O.Pts,k=s.Side===e.EdgeSide.esLeft;if(k&&e.IntPoint.op_Equality(m,X.Pt))return X;if(!k&&e.IntPoint.op_Equality(m,X.Prev.Pt))return X.Prev;var N=new e.OutPt();return N.Idx=O.Idx,N.Pt.X=m.X,N.Pt.Y=m.Y,e.use_xyz&&(N.Pt.Z=m.Z),N.Next=X,N.Prev=X.Prev,N.Prev.Next=N,X.Prev=N,k&&(O.Pts=N),N;}},e.Clipper.prototype.GetLastOutPt=function(s){var m=this.m_PolyOuts[s.OutIdx];return s.Side===e.EdgeSide.esLeft?m.Pts:m.Pts.Prev;},e.Clipper.prototype.SwapPoints=function(s,m){var O=new e.IntPoint1(s.Value);s.Value.X=m.Value.X,s.Value.Y=m.Value.Y,e.use_xyz&&(s.Value.Z=m.Value.Z),m.Value.X=O.X,m.Value.Y=O.Y,e.use_xyz&&(m.Value.Z=O.Z);},e.Clipper.prototype.HorzSegmentsOverlap=function(s,m,O,N){var X;return s>m&&(X=s,s=m,m=X),O>N&&(X=O,O=N,N=X),s<N&&O<m;},e.Clipper.prototype.SetHoleState=function(s,m){for(var O=s.PrevInAEL,N=null;O!==null;)O.OutIdx>=0&&O.WindDelta!==0&&(N===null?N=O:N.OutIdx===O.OutIdx&&(N=null)),O=O.PrevInAEL;N===null?(m.FirstLeft=null,m.IsHole=!1):(m.FirstLeft=this.m_PolyOuts[N.OutIdx],m.IsHole=!m.FirstLeft.IsHole);},e.Clipper.prototype.GetDx=function(s,m){return s.Y===m.Y?e.ClipperBase.horizontal:(m.X-s.X)/(m.Y-s.Y);},e.Clipper.prototype.FirstIsBottomPt=function(s,m){for(var O=s.Prev;e.IntPoint.op_Equality(O.Pt,s.Pt)&&O!==s;)O=O.Prev;var N=Math.abs(this.GetDx(s.Pt,O.Pt));for(O=s.Next;e.IntPoint.op_Equality(O.Pt,s.Pt)&&O!==s;)O=O.Next;var X=Math.abs(this.GetDx(s.Pt,O.Pt));for(O=m.Prev;e.IntPoint.op_Equality(O.Pt,m.Pt)&&O!==m;)O=O.Prev;var k=Math.abs(this.GetDx(m.Pt,O.Pt));for(O=m.Next;e.IntPoint.op_Equality(O.Pt,m.Pt)&&O!==m;)O=O.Next;var _=Math.abs(this.GetDx(m.Pt,O.Pt));return Math.max(N,X)===Math.max(k,_)&&Math.min(N,X)===Math.min(k,_)?this.Area(s)>0:N>=k&&N>=_||X>=k&&X>=_;},e.Clipper.prototype.GetBottomPt=function(s){for(var m=null,O=s.Next;O!==s;)O.Pt.Y>s.Pt.Y?(s=O,m=null):O.Pt.Y===s.Pt.Y&&O.Pt.X<=s.Pt.X&&(O.Pt.X<s.Pt.X?(m=null,s=O):O.Next!==s&&O.Prev!==s&&(m=O)),O=O.Next;if(m!==null)for(;m!==O;)for(this.FirstIsBottomPt(O,m)||(s=m),m=m.Next;e.IntPoint.op_Inequality(m.Pt,s.Pt);)m=m.Next;return s;},e.Clipper.prototype.GetLowermostRec=function(s,m){s.BottomPt===null&&(s.BottomPt=this.GetBottomPt(s.Pts)),m.BottomPt===null&&(m.BottomPt=this.GetBottomPt(m.Pts));var O=s.BottomPt,N=m.BottomPt;return O.Pt.Y>N.Pt.Y?s:O.Pt.Y<N.Pt.Y?m:O.Pt.X<N.Pt.X?s:O.Pt.X>N.Pt.X||O.Next===O?m:N.Next===N||this.FirstIsBottomPt(O,N)?s:m;},e.Clipper.prototype.OutRec1RightOfOutRec2=function(s,m){do if(s=s.FirstLeft,s===m)return!0;while(s!==null);return!1;},e.Clipper.prototype.GetOutRec=function(s){for(var m=this.m_PolyOuts[s];m!==this.m_PolyOuts[m.Idx];)m=this.m_PolyOuts[m.Idx];return m;},e.Clipper.prototype.AppendPolygon=function(s,m){var O=this.m_PolyOuts[s.OutIdx],N=this.m_PolyOuts[m.OutIdx],X;this.OutRec1RightOfOutRec2(O,N)?X=N:this.OutRec1RightOfOutRec2(N,O)?X=O:X=this.GetLowermostRec(O,N);var k=O.Pts,_=k.Prev,ft=N.Pts,ht=ft.Prev;s.Side===e.EdgeSide.esLeft?m.Side===e.EdgeSide.esLeft?(this.ReversePolyPtLinks(ft),ft.Next=k,k.Prev=ft,_.Next=ht,ht.Prev=_,O.Pts=ht):(ht.Next=k,k.Prev=ht,ft.Prev=_,_.Next=ft,O.Pts=ft):m.Side===e.EdgeSide.esRight?(this.ReversePolyPtLinks(ft),_.Next=ht,ht.Prev=_,ft.Next=k,k.Prev=ft):(_.Next=ft,ft.Prev=_,k.Prev=ht,ht.Next=k),O.BottomPt=null,X===N&&(N.FirstLeft!==O&&(O.FirstLeft=N.FirstLeft),O.IsHole=N.IsHole),N.Pts=null,N.BottomPt=null,N.FirstLeft=O;var Ct=s.OutIdx,wt=m.OutIdx;s.OutIdx=-1,m.OutIdx=-1;for(var Lt=this.m_ActiveEdges;Lt!==null;){if(Lt.OutIdx===wt){Lt.OutIdx=Ct,Lt.Side=s.Side;break;}Lt=Lt.NextInAEL;}N.Idx=O.Idx;},e.Clipper.prototype.ReversePolyPtLinks=function(s){if(s!==null){var m,O;m=s;do O=m.Next,m.Next=m.Prev,m.Prev=O,m=O;while(m!==s);}},e.Clipper.SwapSides=function(s,m){var O=s.Side;s.Side=m.Side,m.Side=O;},e.Clipper.SwapPolyIndexes=function(s,m){var O=s.OutIdx;s.OutIdx=m.OutIdx,m.OutIdx=O;},e.Clipper.prototype.IntersectEdges=function(s,m,O){var N=s.OutIdx>=0,X=m.OutIdx>=0;if(e.use_xyz&&this.SetZ(O,s,m),e.use_lines&&(s.WindDelta===0||m.WindDelta===0)){if(s.WindDelta===0&&m.WindDelta===0)return;s.PolyTyp===m.PolyTyp&&s.WindDelta!==m.WindDelta&&this.m_ClipType===e.ClipType.ctUnion?s.WindDelta===0?X&&(this.AddOutPt(s,O),N&&(s.OutIdx=-1)):N&&(this.AddOutPt(m,O),X&&(m.OutIdx=-1)):s.PolyTyp!==m.PolyTyp&&(s.WindDelta===0&&Math.abs(m.WindCnt)===1&&(this.m_ClipType!==e.ClipType.ctUnion||m.WindCnt2===0)?(this.AddOutPt(s,O),N&&(s.OutIdx=-1)):m.WindDelta===0&&Math.abs(s.WindCnt)===1&&(this.m_ClipType!==e.ClipType.ctUnion||s.WindCnt2===0)&&(this.AddOutPt(m,O),X&&(m.OutIdx=-1)));return;}if(s.PolyTyp===m.PolyTyp){if(this.IsEvenOddFillType(s)){var k=s.WindCnt;s.WindCnt=m.WindCnt,m.WindCnt=k;}else s.WindCnt+m.WindDelta===0?s.WindCnt=-s.WindCnt:s.WindCnt+=m.WindDelta,m.WindCnt-s.WindDelta===0?m.WindCnt=-m.WindCnt:m.WindCnt-=s.WindDelta;}else this.IsEvenOddFillType(m)?s.WindCnt2=s.WindCnt2===0?1:0:s.WindCnt2+=m.WindDelta,this.IsEvenOddFillType(s)?m.WindCnt2=m.WindCnt2===0?1:0:m.WindCnt2-=s.WindDelta;var _,ft,ht,Ct;s.PolyTyp===e.PolyType.ptSubject?(_=this.m_SubjFillType,ht=this.m_ClipFillType):(_=this.m_ClipFillType,ht=this.m_SubjFillType),m.PolyTyp===e.PolyType.ptSubject?(ft=this.m_SubjFillType,Ct=this.m_ClipFillType):(ft=this.m_ClipFillType,Ct=this.m_SubjFillType);var wt,Lt;switch(_){case e.PolyFillType.pftPositive:wt=s.WindCnt;break;case e.PolyFillType.pftNegative:wt=-s.WindCnt;break;default:wt=Math.abs(s.WindCnt);break;}switch(ft){case e.PolyFillType.pftPositive:Lt=m.WindCnt;break;case e.PolyFillType.pftNegative:Lt=-m.WindCnt;break;default:Lt=Math.abs(m.WindCnt);break;}if(N&&X)wt!==0&&wt!==1||Lt!==0&&Lt!==1||s.PolyTyp!==m.PolyTyp&&this.m_ClipType!==e.ClipType.ctXor?this.AddLocalMaxPoly(s,m,O):(this.AddOutPt(s,O),this.AddOutPt(m,O),e.Clipper.SwapSides(s,m),e.Clipper.SwapPolyIndexes(s,m));else if(N)(Lt===0||Lt===1)&&(this.AddOutPt(s,O),e.Clipper.SwapSides(s,m),e.Clipper.SwapPolyIndexes(s,m));else if(X)(wt===0||wt===1)&&(this.AddOutPt(m,O),e.Clipper.SwapSides(s,m),e.Clipper.SwapPolyIndexes(s,m));else if((wt===0||wt===1)&&(Lt===0||Lt===1)){var Bt,Yt;switch(ht){case e.PolyFillType.pftPositive:Bt=s.WindCnt2;break;case e.PolyFillType.pftNegative:Bt=-s.WindCnt2;break;default:Bt=Math.abs(s.WindCnt2);break;}switch(Ct){case e.PolyFillType.pftPositive:Yt=m.WindCnt2;break;case e.PolyFillType.pftNegative:Yt=-m.WindCnt2;break;default:Yt=Math.abs(m.WindCnt2);break;}if(s.PolyTyp!==m.PolyTyp)this.AddLocalMinPoly(s,m,O);else if(wt===1&&Lt===1)switch(this.m_ClipType){case e.ClipType.ctIntersection:Bt>0&&Yt>0&&this.AddLocalMinPoly(s,m,O);break;case e.ClipType.ctUnion:Bt<=0&&Yt<=0&&this.AddLocalMinPoly(s,m,O);break;case e.ClipType.ctDifference:(s.PolyTyp===e.PolyType.ptClip&&Bt>0&&Yt>0||s.PolyTyp===e.PolyType.ptSubject&&Bt<=0&&Yt<=0)&&this.AddLocalMinPoly(s,m,O);break;case e.ClipType.ctXor:this.AddLocalMinPoly(s,m,O);break;}else e.Clipper.SwapSides(s,m);}},e.Clipper.prototype.DeleteFromSEL=function(s){var m=s.PrevInSEL,O=s.NextInSEL;m===null&&O===null&&s!==this.m_SortedEdges||(m!==null?m.NextInSEL=O:this.m_SortedEdges=O,O!==null&&(O.PrevInSEL=m),s.NextInSEL=null,s.PrevInSEL=null);},e.Clipper.prototype.ProcessHorizontals=function(){for(var s={};this.PopEdgeFromSEL(s);)this.ProcessHorizontal(s.v);},e.Clipper.prototype.GetHorzDirection=function(s,m){s.Bot.X<s.Top.X?(m.Left=s.Bot.X,m.Right=s.Top.X,m.Dir=e.Direction.dLeftToRight):(m.Left=s.Top.X,m.Right=s.Bot.X,m.Dir=e.Direction.dRightToLeft);},e.Clipper.prototype.ProcessHorizontal=function(s){var m={Dir:null,Left:null,Right:null};this.GetHorzDirection(s,m);for(var O=m.Dir,N=m.Left,X=m.Right,k=s.WindDelta===0,_=s,ft=null;_.NextInLML!==null&&e.ClipperBase.IsHorizontal(_.NextInLML);)_=_.NextInLML;_.NextInLML===null&&(ft=this.GetMaximaPair(_));var ht=this.m_Maxima;if(ht!==null)if(O===e.Direction.dLeftToRight){for(;ht!==null&&ht.X<=s.Bot.X;)ht=ht.Next;ht!==null&&ht.X>=_.Top.X&&(ht=null);}else{for(;ht.Next!==null&&ht.Next.X<s.Bot.X;)ht=ht.Next;ht.X<=_.Top.X&&(ht=null);}for(var Ct=null;;){for(var wt=s===_,Lt=this.GetNextInAEL(s,O);Lt!==null;){if(ht!==null)if(O===e.Direction.dLeftToRight)for(;ht!==null&&ht.X<Lt.Curr.X;)s.OutIdx>=0&&!k&&this.AddOutPt(s,new e.IntPoint2(ht.X,s.Bot.Y)),ht=ht.Next;else for(;ht!==null&&ht.X>Lt.Curr.X;)s.OutIdx>=0&&!k&&this.AddOutPt(s,new e.IntPoint2(ht.X,s.Bot.Y)),ht=ht.Prev;if(O===e.Direction.dLeftToRight&&Lt.Curr.X>X||O===e.Direction.dRightToLeft&&Lt.Curr.X<N||Lt.Curr.X===s.Top.X&&s.NextInLML!==null&&Lt.Dx<s.NextInLML.Dx)break;if(s.OutIdx>=0&&!k){e.use_xyz&&(O===e.Direction.dLeftToRight?this.SetZ(Lt.Curr,s,Lt):this.SetZ(Lt.Curr,Lt,s)),Ct=this.AddOutPt(s,Lt.Curr);for(var Bt=this.m_SortedEdges;Bt!==null;){if(Bt.OutIdx>=0&&this.HorzSegmentsOverlap(s.Bot.X,s.Top.X,Bt.Bot.X,Bt.Top.X)){var Yt=this.GetLastOutPt(Bt);this.AddJoin(Yt,Ct,Bt.Top);}Bt=Bt.NextInSEL;}this.AddGhostJoin(Ct,s.Bot);}if(Lt===ft&&wt){s.OutIdx>=0&&this.AddLocalMaxPoly(s,ft,s.Top),this.DeleteFromAEL(s),this.DeleteFromAEL(ft);return;}if(O===e.Direction.dLeftToRight){var Ht=new e.IntPoint2(Lt.Curr.X,s.Curr.Y);this.IntersectEdges(s,Lt,Ht);}else{var Ht=new e.IntPoint2(Lt.Curr.X,s.Curr.Y);this.IntersectEdges(Lt,s,Ht);}var Vt=this.GetNextInAEL(Lt,O);this.SwapPositionsInAEL(s,Lt),Lt=Vt;}if(s.NextInLML===null||!e.ClipperBase.IsHorizontal(s.NextInLML))break;s=this.UpdateEdgeIntoAEL(s),s.OutIdx>=0&&this.AddOutPt(s,s.Bot),m={Dir:O,Left:N,Right:X},this.GetHorzDirection(s,m),O=m.Dir,N=m.Left,X=m.Right;}if(s.OutIdx>=0&&Ct===null){Ct=this.GetLastOutPt(s);for(var Bt=this.m_SortedEdges;Bt!==null;){if(Bt.OutIdx>=0&&this.HorzSegmentsOverlap(s.Bot.X,s.Top.X,Bt.Bot.X,Bt.Top.X)){var Yt=this.GetLastOutPt(Bt);this.AddJoin(Yt,Ct,Bt.Top);}Bt=Bt.NextInSEL;}this.AddGhostJoin(Ct,s.Top);}if(s.NextInLML!==null){if(s.OutIdx>=0){if(Ct=this.AddOutPt(s,s.Top),s=this.UpdateEdgeIntoAEL(s),s.WindDelta===0)return;var ee=s.PrevInAEL,Vt=s.NextInAEL;if(ee!==null&&ee.Curr.X===s.Bot.X&&ee.Curr.Y===s.Bot.Y&&ee.WindDelta===0&&ee.OutIdx>=0&&ee.Curr.Y>ee.Top.Y&&e.ClipperBase.SlopesEqual3(s,ee,this.m_UseFullRange)){var Yt=this.AddOutPt(ee,s.Bot);this.AddJoin(Ct,Yt,s.Top);}else if(Vt!==null&&Vt.Curr.X===s.Bot.X&&Vt.Curr.Y===s.Bot.Y&&Vt.WindDelta!==0&&Vt.OutIdx>=0&&Vt.Curr.Y>Vt.Top.Y&&e.ClipperBase.SlopesEqual3(s,Vt,this.m_UseFullRange)){var Yt=this.AddOutPt(Vt,s.Bot);this.AddJoin(Ct,Yt,s.Top);}}else s=this.UpdateEdgeIntoAEL(s);}else s.OutIdx>=0&&this.AddOutPt(s,s.Top),this.DeleteFromAEL(s);},e.Clipper.prototype.GetNextInAEL=function(s,m){return m===e.Direction.dLeftToRight?s.NextInAEL:s.PrevInAEL;},e.Clipper.prototype.IsMinima=function(s){return s!==null&&s.Prev.NextInLML!==s&&s.Next.NextInLML!==s;},e.Clipper.prototype.IsMaxima=function(s,m){return s!==null&&s.Top.Y===m&&s.NextInLML===null;},e.Clipper.prototype.IsIntermediate=function(s,m){return s.Top.Y===m&&s.NextInLML!==null;},e.Clipper.prototype.GetMaximaPair=function(s){return e.IntPoint.op_Equality(s.Next.Top,s.Top)&&s.Next.NextInLML===null?s.Next:e.IntPoint.op_Equality(s.Prev.Top,s.Top)&&s.Prev.NextInLML===null?s.Prev:null;},e.Clipper.prototype.GetMaximaPairEx=function(s){var m=this.GetMaximaPair(s);return m===null||m.OutIdx===e.ClipperBase.Skip||m.NextInAEL===m.PrevInAEL&&!e.ClipperBase.IsHorizontal(m)?null:m;},e.Clipper.prototype.ProcessIntersections=function(s){if(this.m_ActiveEdges===null)return!0;try{if(this.BuildIntersectList(s),this.m_IntersectList.length===0)return!0;if(this.m_IntersectList.length===1||this.FixupIntersectionOrder())this.ProcessIntersectList();else return!1;}catch(_unused23){this.m_SortedEdges=null,this.m_IntersectList.length=0,e.Error("ProcessIntersections error");}return this.m_SortedEdges=null,!0;},e.Clipper.prototype.BuildIntersectList=function(s){if(this.m_ActiveEdges!==null){var m=this.m_ActiveEdges;for(this.m_SortedEdges=m;m!==null;)m.PrevInSEL=m.PrevInAEL,m.NextInSEL=m.NextInAEL,m.Curr.X=e.Clipper.TopX(m,s),m=m.NextInAEL;for(var O=!0;O&&this.m_SortedEdges!==null;){for(O=!1,m=this.m_SortedEdges;m.NextInSEL!==null;){var N=m.NextInSEL,X=new e.IntPoint0();if(m.Curr.X>N.Curr.X){this.IntersectPoint(m,N,X),X.Y<s&&(X=new e.IntPoint2(e.Clipper.TopX(m,s),s));var k=new e.IntersectNode();k.Edge1=m,k.Edge2=N,k.Pt.X=X.X,k.Pt.Y=X.Y,e.use_xyz&&(k.Pt.Z=X.Z),this.m_IntersectList.push(k),this.SwapPositionsInSEL(m,N),O=!0;}else m=N;}if(m.PrevInSEL!==null)m.PrevInSEL.NextInSEL=null;else break;}this.m_SortedEdges=null;}},e.Clipper.prototype.EdgesAdjacent=function(s){return s.Edge1.NextInSEL===s.Edge2||s.Edge1.PrevInSEL===s.Edge2;},e.Clipper.IntersectNodeSort=function(s,m){return m.Pt.Y-s.Pt.Y;},e.Clipper.prototype.FixupIntersectionOrder=function(){this.m_IntersectList.sort(this.m_IntersectNodeComparer),this.CopyAELToSEL();for(var s=this.m_IntersectList.length,m=0;m<s;m++){if(!this.EdgesAdjacent(this.m_IntersectList[m])){for(var O=m+1;O<s&&!this.EdgesAdjacent(this.m_IntersectList[O]);)O++;if(O===s)return!1;var N=this.m_IntersectList[m];this.m_IntersectList[m]=this.m_IntersectList[O],this.m_IntersectList[O]=N;}this.SwapPositionsInSEL(this.m_IntersectList[m].Edge1,this.m_IntersectList[m].Edge2);}return!0;},e.Clipper.prototype.ProcessIntersectList=function(){for(var s=0,m=this.m_IntersectList.length;s<m;s++){var O=this.m_IntersectList[s];this.IntersectEdges(O.Edge1,O.Edge2,O.Pt),this.SwapPositionsInAEL(O.Edge1,O.Edge2);}this.m_IntersectList.length=0;};var $s=function $s(s){return s<0?Math.ceil(s-0.5):Math.round(s);},Gs=function Gs(s){return s<0?Math.ceil(s-0.5):Math.floor(s+0.5);},Hs=function Hs(s){return s<0?-Math.round(Math.abs(s)):Math.round(s);},Vs=function Vs(s){return s<0?(s-=0.5,s<-2147483648?Math.ceil(s):s|0):(s+=0.5,s>2147483647?Math.floor(s):s|0);};i.msie?e.Clipper.Round=$s:i.chromium?e.Clipper.Round=Hs:i.safari?e.Clipper.Round=Vs:e.Clipper.Round=Gs,e.Clipper.TopX=function(s,m){return m===s.Top.Y?s.Top.X:s.Bot.X+e.Clipper.Round(s.Dx*(m-s.Bot.Y));},e.Clipper.prototype.IntersectPoint=function(s,m,O){O.X=0,O.Y=0;var N,X;if(s.Dx===m.Dx){O.Y=s.Curr.Y,O.X=e.Clipper.TopX(s,O.Y);return;}if(s.Delta.X===0)O.X=s.Bot.X,e.ClipperBase.IsHorizontal(m)?O.Y=m.Bot.Y:(X=m.Bot.Y-m.Bot.X/m.Dx,O.Y=e.Clipper.Round(O.X/m.Dx+X));else if(m.Delta.X===0)O.X=m.Bot.X,e.ClipperBase.IsHorizontal(s)?O.Y=s.Bot.Y:(N=s.Bot.Y-s.Bot.X/s.Dx,O.Y=e.Clipper.Round(O.X/s.Dx+N));else{N=s.Bot.X-s.Bot.Y*s.Dx,X=m.Bot.X-m.Bot.Y*m.Dx;var k=(X-N)/(s.Dx-m.Dx);O.Y=e.Clipper.Round(k),Math.abs(s.Dx)<Math.abs(m.Dx)?O.X=e.Clipper.Round(s.Dx*k+N):O.X=e.Clipper.Round(m.Dx*k+X);}if(O.Y<s.Top.Y||O.Y<m.Top.Y){if(s.Top.Y>m.Top.Y)return O.Y=s.Top.Y,O.X=e.Clipper.TopX(m,s.Top.Y),O.X<s.Top.X;O.Y=m.Top.Y,Math.abs(s.Dx)<Math.abs(m.Dx)?O.X=e.Clipper.TopX(s,O.Y):O.X=e.Clipper.TopX(m,O.Y);}O.Y>s.Curr.Y&&(O.Y=s.Curr.Y,Math.abs(s.Dx)>Math.abs(m.Dx)?O.X=e.Clipper.TopX(m,O.Y):O.X=e.Clipper.TopX(s,O.Y));},e.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(s){for(var m=this.m_ActiveEdges;m!==null;){var O=this.IsMaxima(m,s);if(O){var N=this.GetMaximaPairEx(m);O=N===null||!e.ClipperBase.IsHorizontal(N);}if(O){this.StrictlySimple&&this.InsertMaxima(m.Top.X);var X=m.PrevInAEL;this.DoMaxima(m),X===null?m=this.m_ActiveEdges:m=X.NextInAEL;}else{if(this.IsIntermediate(m,s)&&e.ClipperBase.IsHorizontal(m.NextInLML)?(m=this.UpdateEdgeIntoAEL(m),m.OutIdx>=0&&this.AddOutPt(m,m.Bot),this.AddEdgeToSEL(m)):(m.Curr.X=e.Clipper.TopX(m,s),m.Curr.Y=s),e.use_xyz&&(m.Top.Y===s?m.Curr.Z=m.Top.Z:m.Bot.Y===s?m.Curr.Z=m.Bot.Z:m.Curr.Z=0),this.StrictlySimple){var X=m.PrevInAEL;if(m.OutIdx>=0&&m.WindDelta!==0&&X!==null&&X.OutIdx>=0&&X.Curr.X===m.Curr.X&&X.WindDelta!==0){var k=new e.IntPoint1(m.Curr);e.use_xyz&&this.SetZ(k,X,m);var _=this.AddOutPt(X,k),ft=this.AddOutPt(m,k);this.AddJoin(_,ft,k);}}m=m.NextInAEL;}}for(this.ProcessHorizontals(),this.m_Maxima=null,m=this.m_ActiveEdges;m!==null;){if(this.IsIntermediate(m,s)){var _=null;m.OutIdx>=0&&(_=this.AddOutPt(m,m.Top)),m=this.UpdateEdgeIntoAEL(m);var X=m.PrevInAEL,ht=m.NextInAEL;if(X!==null&&X.Curr.X===m.Bot.X&&X.Curr.Y===m.Bot.Y&&_!==null&&X.OutIdx>=0&&X.Curr.Y===X.Top.Y&&e.ClipperBase.SlopesEqual5(m.Curr,m.Top,X.Curr,X.Top,this.m_UseFullRange)&&m.WindDelta!==0&&X.WindDelta!==0){var ft=this.AddOutPt(ePrev2,m.Bot);this.AddJoin(_,ft,m.Top);}else if(ht!==null&&ht.Curr.X===m.Bot.X&&ht.Curr.Y===m.Bot.Y&&_!==null&&ht.OutIdx>=0&&ht.Curr.Y===ht.Top.Y&&e.ClipperBase.SlopesEqual5(m.Curr,m.Top,ht.Curr,ht.Top,this.m_UseFullRange)&&m.WindDelta!==0&&ht.WindDelta!==0){var ft=this.AddOutPt(ht,m.Bot);this.AddJoin(_,ft,m.Top);}}m=m.NextInAEL;}},e.Clipper.prototype.DoMaxima=function(s){var m=this.GetMaximaPairEx(s);if(m===null){s.OutIdx>=0&&this.AddOutPt(s,s.Top),this.DeleteFromAEL(s);return;}for(var O=s.NextInAEL;O!==null&&O!==m;)this.IntersectEdges(s,O,s.Top),this.SwapPositionsInAEL(s,O),O=s.NextInAEL;s.OutIdx===-1&&m.OutIdx===-1?(this.DeleteFromAEL(s),this.DeleteFromAEL(m)):s.OutIdx>=0&&m.OutIdx>=0?(s.OutIdx>=0&&this.AddLocalMaxPoly(s,m,s.Top),this.DeleteFromAEL(s),this.DeleteFromAEL(m)):e.use_lines&&s.WindDelta===0?(s.OutIdx>=0&&(this.AddOutPt(s,s.Top),s.OutIdx=e.ClipperBase.Unassigned),this.DeleteFromAEL(s),m.OutIdx>=0&&(this.AddOutPt(m,s.Top),m.OutIdx=e.ClipperBase.Unassigned),this.DeleteFromAEL(m)):e.Error("DoMaxima error");},e.Clipper.ReversePaths=function(s){for(var m=0,O=s.length;m<O;m++)s[m].reverse();},e.Clipper.Orientation=function(s){return e.Clipper.Area(s)>=0;},e.Clipper.prototype.PointCount=function(s){if(s===null)return 0;var m=0,O=s;do m++,O=O.Next;while(O!==s);return m;},e.Clipper.prototype.BuildResult=function(s){e.Clear(s);for(var m=0,O=this.m_PolyOuts.length;m<O;m++){var N=this.m_PolyOuts[m];if(N.Pts!==null){var X=N.Pts.Prev,k=this.PointCount(X);if(!(k<2)){for(var _=new Array(k),ft=0;ft<k;ft++)_[ft]=X.Pt,X=X.Prev;s.push(_);}}}},e.Clipper.prototype.BuildResult2=function(s){s.Clear();for(var m=0,O=this.m_PolyOuts.length;m<O;m++){var N=this.m_PolyOuts[m],X=this.PointCount(N.Pts);if(!(N.IsOpen&&X<2||!N.IsOpen&&X<3)){this.FixHoleLinkage(N);var k=new e.PolyNode();s.m_AllPolys.push(k),N.PolyNode=k,k.m_polygon.length=X;for(var _=N.Pts.Prev,ft=0;ft<X;ft++)k.m_polygon[ft]=_.Pt,_=_.Prev;}}for(var m=0,O=this.m_PolyOuts.length;m<O;m++){var N=this.m_PolyOuts[m];N.PolyNode!==null&&(N.IsOpen?(N.PolyNode.IsOpen=!0,s.AddChild(N.PolyNode)):N.FirstLeft!==null&&N.FirstLeft.PolyNode!==null?N.FirstLeft.PolyNode.AddChild(N.PolyNode):s.AddChild(N.PolyNode));}},e.Clipper.prototype.FixupOutPolyline=function(s){for(var m=s.Pts,O=m.Prev;m!==O;)if(m=m.Next,e.IntPoint.op_Equality(m.Pt,m.Prev.Pt)){m===O&&(O=m.Prev);var N=m.Prev;N.Next=m.Next,m.Next.Prev=N,m=N;}m===m.Prev&&(s.Pts=null);},e.Clipper.prototype.FixupOutPolygon=function(s){var m=null;s.BottomPt=null;for(var O=s.Pts,N=this.PreserveCollinear||this.StrictlySimple;;){if(O.Prev===O||O.Prev===O.Next){s.Pts=null;return;}if(e.IntPoint.op_Equality(O.Pt,O.Next.Pt)||e.IntPoint.op_Equality(O.Pt,O.Prev.Pt)||e.ClipperBase.SlopesEqual4(O.Prev.Pt,O.Pt,O.Next.Pt,this.m_UseFullRange)&&(!N||!this.Pt2IsBetweenPt1AndPt3(O.Prev.Pt,O.Pt,O.Next.Pt)))m=null,O.Prev.Next=O.Next,O.Next.Prev=O.Prev,O=O.Prev;else{if(O===m)break;m===null&&(m=O),O=O.Next;}}s.Pts=O;},e.Clipper.prototype.DupOutPt=function(s,m){var O=new e.OutPt();return O.Pt.X=s.Pt.X,O.Pt.Y=s.Pt.Y,e.use_xyz&&(O.Pt.Z=s.Pt.Z),O.Idx=s.Idx,m?(O.Next=s.Next,O.Prev=s,s.Next.Prev=O,s.Next=O):(O.Prev=s.Prev,O.Next=s,s.Prev.Next=O,s.Prev=O),O;},e.Clipper.prototype.GetOverlap=function(s,m,O,N,X){return s<m?O<N?(X.Left=Math.max(s,O),X.Right=Math.min(m,N)):(X.Left=Math.max(s,N),X.Right=Math.min(m,O)):O<N?(X.Left=Math.max(m,O),X.Right=Math.min(s,N)):(X.Left=Math.max(m,N),X.Right=Math.min(s,O)),X.Left<X.Right;},e.Clipper.prototype.JoinHorz=function(s,m,O,N,X,k){var _=s.Pt.X>m.Pt.X?e.Direction.dRightToLeft:e.Direction.dLeftToRight,ft=O.Pt.X>N.Pt.X?e.Direction.dRightToLeft:e.Direction.dLeftToRight;if(_===ft)return!1;if(_===e.Direction.dLeftToRight){for(;s.Next.Pt.X<=X.X&&s.Next.Pt.X>=s.Pt.X&&s.Next.Pt.Y===X.Y;)s=s.Next;k&&s.Pt.X!==X.X&&(s=s.Next),m=this.DupOutPt(s,!k),e.IntPoint.op_Inequality(m.Pt,X)&&(s=m,s.Pt.X=X.X,s.Pt.Y=X.Y,e.use_xyz&&(s.Pt.Z=X.Z),m=this.DupOutPt(s,!k));}else{for(;s.Next.Pt.X>=X.X&&s.Next.Pt.X<=s.Pt.X&&s.Next.Pt.Y===X.Y;)s=s.Next;!k&&s.Pt.X!==X.X&&(s=s.Next),m=this.DupOutPt(s,k),e.IntPoint.op_Inequality(m.Pt,X)&&(s=m,s.Pt.X=X.X,s.Pt.Y=X.Y,e.use_xyz&&(s.Pt.Z=X.Z),m=this.DupOutPt(s,k));}if(ft===e.Direction.dLeftToRight){for(;O.Next.Pt.X<=X.X&&O.Next.Pt.X>=O.Pt.X&&O.Next.Pt.Y===X.Y;)O=O.Next;k&&O.Pt.X!==X.X&&(O=O.Next),N=this.DupOutPt(O,!k),e.IntPoint.op_Inequality(N.Pt,X)&&(O=N,O.Pt.X=X.X,O.Pt.Y=X.Y,e.use_xyz&&(O.Pt.Z=X.Z),N=this.DupOutPt(O,!k));}else{for(;O.Next.Pt.X>=X.X&&O.Next.Pt.X<=O.Pt.X&&O.Next.Pt.Y===X.Y;)O=O.Next;!k&&O.Pt.X!==X.X&&(O=O.Next),N=this.DupOutPt(O,k),e.IntPoint.op_Inequality(N.Pt,X)&&(O=N,O.Pt.X=X.X,O.Pt.Y=X.Y,e.use_xyz&&(O.Pt.Z=X.Z),N=this.DupOutPt(O,k));}return _===e.Direction.dLeftToRight===k?(s.Prev=O,O.Next=s,m.Next=N,N.Prev=m):(s.Next=O,O.Prev=s,m.Prev=N,N.Next=m),!0;},e.Clipper.prototype.JoinPoints=function(s,m,O){var N=s.OutPt1,X=new e.OutPt(),k=s.OutPt2,_=new e.OutPt(),ft=s.OutPt1.Pt.Y===s.OffPt.Y;if(ft&&e.IntPoint.op_Equality(s.OffPt,s.OutPt1.Pt)&&e.IntPoint.op_Equality(s.OffPt,s.OutPt2.Pt)){if(m!==O)return!1;for(X=s.OutPt1.Next;X!==N&&e.IntPoint.op_Equality(X.Pt,s.OffPt);)X=X.Next;var ht=X.Pt.Y>s.OffPt.Y;for(_=s.OutPt2.Next;_!==k&&e.IntPoint.op_Equality(_.Pt,s.OffPt);)_=_.Next;var Ct=_.Pt.Y>s.OffPt.Y;return ht===Ct?!1:ht?(X=this.DupOutPt(N,!1),_=this.DupOutPt(k,!0),N.Prev=k,k.Next=N,X.Next=_,_.Prev=X,s.OutPt1=N,s.OutPt2=X,!0):(X=this.DupOutPt(N,!0),_=this.DupOutPt(k,!1),N.Next=k,k.Prev=N,X.Prev=_,_.Next=X,s.OutPt1=N,s.OutPt2=X,!0);}else if(ft){for(X=N;N.Prev.Pt.Y===N.Pt.Y&&N.Prev!==X&&N.Prev!==k;)N=N.Prev;for(;X.Next.Pt.Y===X.Pt.Y&&X.Next!==N&&X.Next!==k;)X=X.Next;if(X.Next===N||X.Next===k)return!1;for(_=k;k.Prev.Pt.Y===k.Pt.Y&&k.Prev!==_&&k.Prev!==X;)k=k.Prev;for(;_.Next.Pt.Y===_.Pt.Y&&_.Next!==k&&_.Next!==N;)_=_.Next;if(_.Next===k||_.Next===N)return!1;var wt={Left:null,Right:null};if(!this.GetOverlap(N.Pt.X,X.Pt.X,k.Pt.X,_.Pt.X,wt))return!1;var Lt=wt.Left,Bt=wt.Right,Yt=new e.IntPoint0(),Ht;return N.Pt.X>=Lt&&N.Pt.X<=Bt?(Yt.X=N.Pt.X,Yt.Y=N.Pt.Y,e.use_xyz&&(Yt.Z=N.Pt.Z),Ht=N.Pt.X>X.Pt.X):k.Pt.X>=Lt&&k.Pt.X<=Bt?(Yt.X=k.Pt.X,Yt.Y=k.Pt.Y,e.use_xyz&&(Yt.Z=k.Pt.Z),Ht=k.Pt.X>_.Pt.X):X.Pt.X>=Lt&&X.Pt.X<=Bt?(Yt.X=X.Pt.X,Yt.Y=X.Pt.Y,e.use_xyz&&(Yt.Z=X.Pt.Z),Ht=X.Pt.X>N.Pt.X):(Yt.X=_.Pt.X,Yt.Y=_.Pt.Y,e.use_xyz&&(Yt.Z=_.Pt.Z),Ht=_.Pt.X>k.Pt.X),s.OutPt1=N,s.OutPt2=k,this.JoinHorz(N,X,k,_,Yt,Ht);}else{for(X=N.Next;e.IntPoint.op_Equality(X.Pt,N.Pt)&&X!==N;)X=X.Next;var Vt=X.Pt.Y>N.Pt.Y||!e.ClipperBase.SlopesEqual4(N.Pt,X.Pt,s.OffPt,this.m_UseFullRange);if(Vt){for(X=N.Prev;e.IntPoint.op_Equality(X.Pt,N.Pt)&&X!==N;)X=X.Prev;if(X.Pt.Y>N.Pt.Y||!e.ClipperBase.SlopesEqual4(N.Pt,X.Pt,s.OffPt,this.m_UseFullRange))return!1;}for(_=k.Next;e.IntPoint.op_Equality(_.Pt,k.Pt)&&_!==k;)_=_.Next;var ee=_.Pt.Y>k.Pt.Y||!e.ClipperBase.SlopesEqual4(k.Pt,_.Pt,s.OffPt,this.m_UseFullRange);if(ee){for(_=k.Prev;e.IntPoint.op_Equality(_.Pt,k.Pt)&&_!==k;)_=_.Prev;if(_.Pt.Y>k.Pt.Y||!e.ClipperBase.SlopesEqual4(k.Pt,_.Pt,s.OffPt,this.m_UseFullRange))return!1;}return X===N||_===k||X===_||m===O&&Vt===ee?!1:Vt?(X=this.DupOutPt(N,!1),_=this.DupOutPt(k,!0),N.Prev=k,k.Next=N,X.Next=_,_.Prev=X,s.OutPt1=N,s.OutPt2=X,!0):(X=this.DupOutPt(N,!0),_=this.DupOutPt(k,!1),N.Next=k,k.Prev=N,X.Prev=_,_.Next=X,s.OutPt1=N,s.OutPt2=X,!0);}},e.Clipper.GetBounds=function(s){for(var m=0,O=s.length;m<O&&s[m].length===0;)m++;if(m===O)return new e.IntRect(0,0,0,0);var N=new e.IntRect();for(N.left=s[m][0].X,N.right=N.left,N.top=s[m][0].Y,N.bottom=N.top;m<O;m++)for(var X=0,k=s[m].length;X<k;X++)s[m][X].X<N.left?N.left=s[m][X].X:s[m][X].X>N.right&&(N.right=s[m][X].X),s[m][X].Y<N.top?N.top=s[m][X].Y:s[m][X].Y>N.bottom&&(N.bottom=s[m][X].Y);return N;},e.Clipper.prototype.GetBounds2=function(s){var m=s,O=new e.IntRect();for(O.left=s.Pt.X,O.right=s.Pt.X,O.top=s.Pt.Y,O.bottom=s.Pt.Y,s=s.Next;s!==m;)s.Pt.X<O.left&&(O.left=s.Pt.X),s.Pt.X>O.right&&(O.right=s.Pt.X),s.Pt.Y<O.top&&(O.top=s.Pt.Y),s.Pt.Y>O.bottom&&(O.bottom=s.Pt.Y),s=s.Next;return O;},e.Clipper.PointInPolygon=function(s,m){var O=0,N=m.length;if(N<3)return 0;for(var X=m[0],k=1;k<=N;++k){var _=k===N?m[0]:m[k];if(_.Y===s.Y&&(_.X===s.X||X.Y===s.Y&&_.X>s.X==X.X<s.X))return-1;if(X.Y<s.Y!=_.Y<s.Y){if(X.X>=s.X){if(_.X>s.X)O=1-O;else{var ft=(X.X-s.X)*(_.Y-s.Y)-(_.X-s.X)*(X.Y-s.Y);if(ft===0)return-1;ft>0==_.Y>X.Y&&(O=1-O);}}else if(_.X>s.X){var ft=(X.X-s.X)*(_.Y-s.Y)-(_.X-s.X)*(X.Y-s.Y);if(ft===0)return-1;ft>0==_.Y>X.Y&&(O=1-O);}}X=_;}return O;},e.Clipper.prototype.PointInPolygon=function(s,m){var O=0,N=m,X=s.X,k=s.Y,_=m.Pt.X,ft=m.Pt.Y;do{m=m.Next;var ht=m.Pt.X,Ct=m.Pt.Y;if(Ct===k&&(ht===X||ft===k&&ht>X==_<X))return-1;if(ft<k!=Ct<k){if(_>=X){if(ht>X)O=1-O;else{var wt=(_-X)*(Ct-k)-(ht-X)*(ft-k);if(wt===0)return-1;wt>0==Ct>ft&&(O=1-O);}}else if(ht>X){var wt=(_-X)*(Ct-k)-(ht-X)*(ft-k);if(wt===0)return-1;wt>0==Ct>ft&&(O=1-O);}}_=ht,ft=Ct;}while(N!==m);return O;},e.Clipper.prototype.Poly2ContainsPoly1=function(s,m){var O=s;do{var N=this.PointInPolygon(O.Pt,m);if(N>=0)return N>0;O=O.Next;}while(O!==s);return!0;},e.Clipper.prototype.FixupFirstLefts1=function(s,m){for(var O,N,X=0,k=this.m_PolyOuts.length;X<k;X++)O=this.m_PolyOuts[X],N=e.Clipper.ParseFirstLeft(O.FirstLeft),O.Pts!==null&&N===s&&this.Poly2ContainsPoly1(O.Pts,m.Pts)&&(O.FirstLeft=m);},e.Clipper.prototype.FixupFirstLefts2=function(s,m){for(var O=m.FirstLeft,N,X,k=0,_=this.m_PolyOuts.length;k<_;k++)N=this.m_PolyOuts[k],!(N.Pts===null||N===m||N===s)&&(X=e.Clipper.ParseFirstLeft(N.FirstLeft),!(X!==O&&X!==s&&X!==m)&&(this.Poly2ContainsPoly1(N.Pts,s.Pts)?N.FirstLeft=s:this.Poly2ContainsPoly1(N.Pts,m.Pts)?N.FirstLeft=m:(N.FirstLeft===s||N.FirstLeft===m)&&(N.FirstLeft=O)));},e.Clipper.prototype.FixupFirstLefts3=function(s,m){for(var O,N,X=0,k=this.m_PolyOuts.length;X<k;X++)O=this.m_PolyOuts[X],N=e.Clipper.ParseFirstLeft(O.FirstLeft),O.Pts!==null&&N===s&&(O.FirstLeft=m);},e.Clipper.ParseFirstLeft=function(s){for(;s!==null&&s.Pts===null;)s=s.FirstLeft;return s;},e.Clipper.prototype.JoinCommonEdges=function(){for(var s=0,m=this.m_Joins.length;s<m;s++){var O=this.m_Joins[s],N=this.GetOutRec(O.OutPt1.Idx),X=this.GetOutRec(O.OutPt2.Idx);if(!(N.Pts===null||X.Pts===null)&&!(N.IsOpen||X.IsOpen)){var k;N===X?k=N:this.OutRec1RightOfOutRec2(N,X)?k=X:this.OutRec1RightOfOutRec2(X,N)?k=N:k=this.GetLowermostRec(N,X),this.JoinPoints(O,N,X)&&(N===X?(N.Pts=O.OutPt1,N.BottomPt=null,X=this.CreateOutRec(),X.Pts=O.OutPt2,this.UpdateOutPtIdxs(X),this.Poly2ContainsPoly1(X.Pts,N.Pts)?(X.IsHole=!N.IsHole,X.FirstLeft=N,this.m_UsingPolyTree&&this.FixupFirstLefts2(X,N),(X.IsHole^this.ReverseSolution)==this.Area$1(X)>0&&this.ReversePolyPtLinks(X.Pts)):this.Poly2ContainsPoly1(N.Pts,X.Pts)?(X.IsHole=N.IsHole,N.IsHole=!X.IsHole,X.FirstLeft=N.FirstLeft,N.FirstLeft=X,this.m_UsingPolyTree&&this.FixupFirstLefts2(N,X),(N.IsHole^this.ReverseSolution)==this.Area$1(N)>0&&this.ReversePolyPtLinks(N.Pts)):(X.IsHole=N.IsHole,X.FirstLeft=N.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(N,X))):(X.Pts=null,X.BottomPt=null,X.Idx=N.Idx,N.IsHole=k.IsHole,k===X&&(N.FirstLeft=X.FirstLeft),X.FirstLeft=N,this.m_UsingPolyTree&&this.FixupFirstLefts3(X,N)));}}},e.Clipper.prototype.UpdateOutPtIdxs=function(s){var m=s.Pts;do m.Idx=s.Idx,m=m.Prev;while(m!==s.Pts);},e.Clipper.prototype.DoSimplePolygons=function(){for(var s=0;s<this.m_PolyOuts.length;){var m=this.m_PolyOuts[s++],O=m.Pts;if(!(O===null||m.IsOpen))do{for(var N=O.Next;N!==m.Pts;){if(e.IntPoint.op_Equality(O.Pt,N.Pt)&&N.Next!==O&&N.Prev!==O){var X=O.Prev,k=N.Prev;O.Prev=k,k.Next=O,N.Prev=X,X.Next=N,m.Pts=O;var _=this.CreateOutRec();_.Pts=N,this.UpdateOutPtIdxs(_),this.Poly2ContainsPoly1(_.Pts,m.Pts)?(_.IsHole=!m.IsHole,_.FirstLeft=m,this.m_UsingPolyTree&&this.FixupFirstLefts2(_,m)):this.Poly2ContainsPoly1(m.Pts,_.Pts)?(_.IsHole=m.IsHole,m.IsHole=!_.IsHole,_.FirstLeft=m.FirstLeft,m.FirstLeft=_,this.m_UsingPolyTree&&this.FixupFirstLefts2(m,_)):(_.IsHole=m.IsHole,_.FirstLeft=m.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(m,_)),N=O;}N=N.Next;}O=O.Next;}while(O!==m.Pts);}},e.Clipper.Area=function(s){if(!Array.isArray(s))return 0;var m=s.length;if(m<3)return 0;for(var O=0,N=0,X=m-1;N<m;++N)O+=(s[X].X+s[N].X)*(s[X].Y-s[N].Y),X=N;return-O*0.5;},e.Clipper.prototype.Area=function(s){var m=s;if(s===null)return 0;var O=0;do O=O+(s.Prev.Pt.X+s.Pt.X)*(s.Prev.Pt.Y-s.Pt.Y),s=s.Next;while(s!==m);return O*0.5;},e.Clipper.prototype.Area$1=function(s){return this.Area(s.Pts);},e.Clipper.SimplifyPolygon=function(s,m){var O=new Array(),N=new e.Clipper(0);return N.StrictlySimple=!0,N.AddPath(s,e.PolyType.ptSubject,!0),N.Execute(e.ClipType.ctUnion,O,m,m),O;},e.Clipper.SimplifyPolygons=function(s,m){_typeof(m)>"u"&&(m=e.PolyFillType.pftEvenOdd);var O=new Array(),N=new e.Clipper(0);return N.StrictlySimple=!0,N.AddPaths(s,e.PolyType.ptSubject,!0),N.Execute(e.ClipType.ctUnion,O,m,m),O;},e.Clipper.DistanceSqrd=function(s,m){var O=s.X-m.X,N=s.Y-m.Y;return O*O+N*N;},e.Clipper.DistanceFromLineSqrd=function(s,m,O){var N=m.Y-O.Y,X=O.X-m.X,k=N*m.X+X*m.Y;return k=N*s.X+X*s.Y-k,k*k/(N*N+X*X);},e.Clipper.SlopesNearCollinear=function(s,m,O,N){return Math.abs(s.X-m.X)>Math.abs(s.Y-m.Y)?s.X>m.X==s.X<O.X?e.Clipper.DistanceFromLineSqrd(s,m,O)<N:m.X>s.X==m.X<O.X?e.Clipper.DistanceFromLineSqrd(m,s,O)<N:e.Clipper.DistanceFromLineSqrd(O,s,m)<N:s.Y>m.Y==s.Y<O.Y?e.Clipper.DistanceFromLineSqrd(s,m,O)<N:m.Y>s.Y==m.Y<O.Y?e.Clipper.DistanceFromLineSqrd(m,s,O)<N:e.Clipper.DistanceFromLineSqrd(O,s,m)<N;},e.Clipper.PointsAreClose=function(s,m,O){var N=s.X-m.X,X=s.Y-m.Y;return N*N+X*X<=O;},e.Clipper.ExcludeOp=function(s){var m=s.Prev;return m.Next=s.Next,s.Next.Prev=m,m.Idx=0,m;},e.Clipper.CleanPolygon=function(s,m){_typeof(m)>"u"&&(m=1.415);var O=s.length;if(O===0)return new Array();for(var N=new Array(O),X=0;X<O;++X)N[X]=new e.OutPt();for(var X=0;X<O;++X)N[X].Pt=s[X],N[X].Next=N[(X+1)%O],N[X].Next.Prev=N[X],N[X].Idx=0;for(var k=m*m,_=N[0];_.Idx===0&&_.Next!==_.Prev;)e.Clipper.PointsAreClose(_.Pt,_.Prev.Pt,k)?(_=e.Clipper.ExcludeOp(_),O--):e.Clipper.PointsAreClose(_.Prev.Pt,_.Next.Pt,k)?(e.Clipper.ExcludeOp(_.Next),_=e.Clipper.ExcludeOp(_),O-=2):e.Clipper.SlopesNearCollinear(_.Prev.Pt,_.Pt,_.Next.Pt,k)?(_=e.Clipper.ExcludeOp(_),O--):(_.Idx=1,_=_.Next);O<3&&(O=0);for(var ft=new Array(O),X=0;X<O;++X)ft[X]=new e.IntPoint1(_.Pt),_=_.Next;return N=null,ft;},e.Clipper.CleanPolygons=function(s,m){for(var O=new Array(s.length),N=0,X=s.length;N<X;N++)O[N]=e.Clipper.CleanPolygon(s[N],m);return O;},e.Clipper.Minkowski=function(s,m,O,N){var X=N?1:0,k=s.length,_=m.length,ft=new Array();if(O)for(var ht=0;ht<_;ht++){for(var Ct=new Array(k),wt=0,Lt=s.length,Bt=s[wt];wt<Lt;wt++,Bt=s[wt])Ct[wt]=new e.IntPoint2(m[ht].X+Bt.X,m[ht].Y+Bt.Y);ft.push(Ct);}else for(var ht=0;ht<_;ht++){for(var Ct=new Array(k),wt=0,Lt=s.length,Bt=s[wt];wt<Lt;wt++,Bt=s[wt])Ct[wt]=new e.IntPoint2(m[ht].X-Bt.X,m[ht].Y-Bt.Y);ft.push(Ct);}for(var Yt=new Array(),ht=0;ht<_-1+X;ht++)for(var wt=0;wt<k;wt++){var Ht=new Array();Ht.push(ft[ht%_][wt%k]),Ht.push(ft[(ht+1)%_][wt%k]),Ht.push(ft[(ht+1)%_][(wt+1)%k]),Ht.push(ft[ht%_][(wt+1)%k]),e.Clipper.Orientation(Ht)||Ht.reverse(),Yt.push(Ht);}return Yt;},e.Clipper.MinkowskiSum=function(s,m,O){if(m[0]instanceof Array){for(var X=m,_=new e.Paths(),k=new e.Clipper(),ft=0;ft<X.length;++ft){var ht=e.Clipper.Minkowski(s,X[ft],!0,O);if(k.AddPaths(ht,e.PolyType.ptSubject,!0),O){var N=e.Clipper.TranslatePath(X[ft],s[0]);k.AddPath(N,e.PolyType.ptClip,!0);}}return k.Execute(e.ClipType.ctUnion,_,e.PolyFillType.pftNonZero,e.PolyFillType.pftNonZero),_;}else{var N=m,X=e.Clipper.Minkowski(s,N,!0,O),k=new e.Clipper();return k.AddPaths(X,e.PolyType.ptSubject,!0),k.Execute(e.ClipType.ctUnion,X,e.PolyFillType.pftNonZero,e.PolyFillType.pftNonZero),X;}},e.Clipper.TranslatePath=function(s,m){for(var O=new e.Path(),N=0;N<s.length;N++)O.push(new e.IntPoint2(s[N].X+m.X,s[N].Y+m.Y));return O;},e.Clipper.MinkowskiDiff=function(s,m){var O=e.Clipper.Minkowski(s,m,!1,!0),N=new e.Clipper();return N.AddPaths(O,e.PolyType.ptSubject,!0),N.Execute(e.ClipType.ctUnion,O,e.PolyFillType.pftNonZero,e.PolyFillType.pftNonZero),O;},e.Clipper.PolyTreeToPaths=function(s){var m=new Array();return e.Clipper.AddPolyNodeToPaths(s,e.Clipper.NodeType.ntAny,m),m;},e.Clipper.AddPolyNodeToPaths=function(s,m,O){var N=!0;switch(m){case e.Clipper.NodeType.ntOpen:return;case e.Clipper.NodeType.ntClosed:N=!s.IsOpen;break;}s.m_polygon.length>0&&N&&O.push(s.m_polygon);for(var X=0,k=s.Childs(),_=k.length,ft=k[X];X<_;X++,ft=k[X])e.Clipper.AddPolyNodeToPaths(ft,m,O);},e.Clipper.OpenPathsFromPolyTree=function(s){for(var m=new e.Paths(),O=0,N=s.ChildCount();O<N;O++)s.Childs()[O].IsOpen&&m.push(s.Childs()[O].m_polygon);return m;},e.Clipper.ClosedPathsFromPolyTree=function(s){var m=new e.Paths();return e.Clipper.AddPolyNodeToPaths(s,e.Clipper.NodeType.ntClosed,m),m;},gn(e.Clipper,e.ClipperBase),e.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2},e.ClipperOffset=function(s,m){_typeof(s)>"u"&&(s=2),_typeof(m)>"u"&&(m=e.ClipperOffset.def_arc_tolerance),this.m_destPolys=new e.Paths(),this.m_srcPoly=new e.Path(),this.m_destPoly=new e.Path(),this.m_normals=new Array(),this.m_delta=0,this.m_sinA=0,this.m_sin=0,this.m_cos=0,this.m_miterLim=0,this.m_StepsPerRad=0,this.m_lowest=new e.IntPoint0(),this.m_polyNodes=new e.PolyNode(),this.MiterLimit=s,this.ArcTolerance=m,this.m_lowest.X=-1;},e.ClipperOffset.two_pi=6.28318530717959,e.ClipperOffset.def_arc_tolerance=0.25,e.ClipperOffset.prototype.Clear=function(){e.Clear(this.m_polyNodes.Childs()),this.m_lowest.X=-1;},e.ClipperOffset.Round=e.Clipper.Round,e.ClipperOffset.prototype.AddPath=function(s,m,O){var N=s.length-1;if(!(N<0)){var X=new e.PolyNode();if(X.m_jointype=m,X.m_endtype=O,O===e.EndType.etClosedLine||O===e.EndType.etClosedPolygon)for(;N>0&&e.IntPoint.op_Equality(s[0],s[N]);)N--;X.m_polygon.push(s[0]);for(var k=0,_=0,ft=1;ft<=N;ft++)e.IntPoint.op_Inequality(X.m_polygon[k],s[ft])&&(k++,X.m_polygon.push(s[ft]),(s[ft].Y>X.m_polygon[_].Y||s[ft].Y===X.m_polygon[_].Y&&s[ft].X<X.m_polygon[_].X)&&(_=k));if(!(O===e.EndType.etClosedPolygon&&k<2)&&(this.m_polyNodes.AddChild(X),O===e.EndType.etClosedPolygon))if(this.m_lowest.X<0)this.m_lowest=new e.IntPoint2(this.m_polyNodes.ChildCount()-1,_);else{var ht=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(X.m_polygon[_].Y>ht.Y||X.m_polygon[_].Y===ht.Y&&X.m_polygon[_].X<ht.X)&&(this.m_lowest=new e.IntPoint2(this.m_polyNodes.ChildCount()-1,_));}}},e.ClipperOffset.prototype.AddPaths=function(s,m,O){for(var N=0,X=s.length;N<X;N++)this.AddPath(s[N],m,O);},e.ClipperOffset.prototype.FixOrientations=function(){if(this.m_lowest.X>=0&&!e.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var s=0;s<this.m_polyNodes.ChildCount();s++){var m=this.m_polyNodes.Childs()[s];(m.m_endtype===e.EndType.etClosedPolygon||m.m_endtype===e.EndType.etClosedLine&&e.Clipper.Orientation(m.m_polygon))&&m.m_polygon.reverse();}else for(var s=0;s<this.m_polyNodes.ChildCount();s++){var m=this.m_polyNodes.Childs()[s];m.m_endtype===e.EndType.etClosedLine&&!e.Clipper.Orientation(m.m_polygon)&&m.m_polygon.reverse();}},e.ClipperOffset.GetUnitNormal=function(s,m){var O=m.X-s.X,N=m.Y-s.Y;if(O===0&&N===0)return new e.DoublePoint2(0,0);var X=1/Math.sqrt(O*O+N*N);return O*=X,N*=X,new e.DoublePoint2(N,-O);},e.ClipperOffset.prototype.DoOffset=function(s){if(this.m_destPolys=new Array(),this.m_delta=s,e.ClipperBase.near_zero(s)){for(var m=0;m<this.m_polyNodes.ChildCount();m++){var O=this.m_polyNodes.Childs()[m];O.m_endtype===e.EndType.etClosedPolygon&&this.m_destPolys.push(O.m_polygon);}return;}this.MiterLimit>2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=0.5;var N;this.ArcTolerance<=0?N=e.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(s)*e.ClipperOffset.def_arc_tolerance?N=Math.abs(s)*e.ClipperOffset.def_arc_tolerance:N=this.ArcTolerance;var X=3.14159265358979/Math.acos(1-N/Math.abs(s));this.m_sin=Math.sin(e.ClipperOffset.two_pi/X),this.m_cos=Math.cos(e.ClipperOffset.two_pi/X),this.m_StepsPerRad=X/e.ClipperOffset.two_pi,s<0&&(this.m_sin=-this.m_sin);for(var m=0;m<this.m_polyNodes.ChildCount();m++){var O=this.m_polyNodes.Childs()[m];this.m_srcPoly=O.m_polygon;var k=this.m_srcPoly.length;if(!(k===0||s<=0&&(k<3||O.m_endtype!==e.EndType.etClosedPolygon))){if(this.m_destPoly=new Array(),k===1){if(O.m_jointype===e.JoinType.jtRound)for(var _=1,ft=0,ht=1;ht<=X;ht++){this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[0].X+_*s),e.ClipperOffset.Round(this.m_srcPoly[0].Y+ft*s)));var Ct=_;_=_*this.m_cos-this.m_sin*ft,ft=Ct*this.m_sin+ft*this.m_cos;}else for(var _=-1,ft=-1,ht=0;ht<4;++ht)this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[0].X+_*s),e.ClipperOffset.Round(this.m_srcPoly[0].Y+ft*s))),_<0?_=1:ft<0?ft=1:_=-1;this.m_destPolys.push(this.m_destPoly);continue;}this.m_normals.length=0;for(var ht=0;ht<k-1;ht++)this.m_normals.push(e.ClipperOffset.GetUnitNormal(this.m_srcPoly[ht],this.m_srcPoly[ht+1]));if(O.m_endtype===e.EndType.etClosedLine||O.m_endtype===e.EndType.etClosedPolygon?this.m_normals.push(e.ClipperOffset.GetUnitNormal(this.m_srcPoly[k-1],this.m_srcPoly[0])):this.m_normals.push(new e.DoublePoint1(this.m_normals[k-2])),O.m_endtype===e.EndType.etClosedPolygon){for(var wt=k-1,ht=0;ht<k;ht++)wt=this.OffsetPoint(ht,wt,O.m_jointype);this.m_destPolys.push(this.m_destPoly);}else if(O.m_endtype===e.EndType.etClosedLine){for(var wt=k-1,ht=0;ht<k;ht++)wt=this.OffsetPoint(ht,wt,O.m_jointype);this.m_destPolys.push(this.m_destPoly),this.m_destPoly=new Array();for(var Lt=this.m_normals[k-1],ht=k-1;ht>0;ht--)this.m_normals[ht]=new e.DoublePoint2(-this.m_normals[ht-1].X,-this.m_normals[ht-1].Y);this.m_normals[0]=new e.DoublePoint2(-Lt.X,-Lt.Y),wt=0;for(var ht=k-1;ht>=0;ht--)wt=this.OffsetPoint(ht,wt,O.m_jointype);this.m_destPolys.push(this.m_destPoly);}else{for(var wt=0,ht=1;ht<k-1;++ht)wt=this.OffsetPoint(ht,wt,O.m_jointype);var Bt;if(O.m_endtype===e.EndType.etOpenButt){var ht=k-1;Bt=new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[ht].X+this.m_normals[ht].X*s),e.ClipperOffset.Round(this.m_srcPoly[ht].Y+this.m_normals[ht].Y*s)),this.m_destPoly.push(Bt),Bt=new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[ht].X-this.m_normals[ht].X*s),e.ClipperOffset.Round(this.m_srcPoly[ht].Y-this.m_normals[ht].Y*s)),this.m_destPoly.push(Bt);}else{var ht=k-1;wt=k-2,this.m_sinA=0,this.m_normals[ht]=new e.DoublePoint2(-this.m_normals[ht].X,-this.m_normals[ht].Y),O.m_endtype===e.EndType.etOpenSquare?this.DoSquare(ht,wt):this.DoRound(ht,wt);}for(var ht=k-1;ht>0;ht--)this.m_normals[ht]=new e.DoublePoint2(-this.m_normals[ht-1].X,-this.m_normals[ht-1].Y);this.m_normals[0]=new e.DoublePoint2(-this.m_normals[1].X,-this.m_normals[1].Y),wt=k-1;for(var ht=wt-1;ht>0;--ht)wt=this.OffsetPoint(ht,wt,O.m_jointype);O.m_endtype===e.EndType.etOpenButt?(Bt=new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[0].X-this.m_normals[0].X*s),e.ClipperOffset.Round(this.m_srcPoly[0].Y-this.m_normals[0].Y*s)),this.m_destPoly.push(Bt),Bt=new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[0].X+this.m_normals[0].X*s),e.ClipperOffset.Round(this.m_srcPoly[0].Y+this.m_normals[0].Y*s)),this.m_destPoly.push(Bt)):(wt=1,this.m_sinA=0,O.m_endtype===e.EndType.etOpenSquare?this.DoSquare(0,1):this.DoRound(0,1)),this.m_destPolys.push(this.m_destPoly);}}}},e.ClipperOffset.prototype.Execute=function(){var s=arguments,m=s[0]instanceof e.PolyTree;if(m){var O=s[0],N=s[1];O.Clear(),this.FixOrientations(),this.DoOffset(N);var X=new e.Clipper(0);if(X.AddPaths(this.m_destPolys,e.PolyType.ptSubject,!0),N>0)X.Execute(e.ClipType.ctUnion,O,e.PolyFillType.pftPositive,e.PolyFillType.pftPositive);else{var k=e.Clipper.GetBounds(this.m_destPolys),_=new e.Path();if(_.push(new e.IntPoint2(k.left-10,k.bottom+10)),_.push(new e.IntPoint2(k.right+10,k.bottom+10)),_.push(new e.IntPoint2(k.right+10,k.top-10)),_.push(new e.IntPoint2(k.left-10,k.top-10)),X.AddPath(_,e.PolyType.ptSubject,!0),X.ReverseSolution=!0,X.Execute(e.ClipType.ctUnion,O,e.PolyFillType.pftNegative,e.PolyFillType.pftNegative),O.ChildCount()===1&&O.Childs()[0].ChildCount()>0){var ft=O.Childs()[0];O.Childs()[0]=ft.Childs()[0],O.Childs()[0].m_Parent=O;for(var ht=1;ht<ft.ChildCount();ht++)O.AddChild(ft.Childs()[ht]);}else O.Clear();}}else{var O=s[0],N=s[1];e.Clear(O),this.FixOrientations(),this.DoOffset(N);var X=new e.Clipper(0);if(X.AddPaths(this.m_destPolys,e.PolyType.ptSubject,!0),N>0)X.Execute(e.ClipType.ctUnion,O,e.PolyFillType.pftPositive,e.PolyFillType.pftPositive);else{var k=e.Clipper.GetBounds(this.m_destPolys),_=new e.Path();_.push(new e.IntPoint2(k.left-10,k.bottom+10)),_.push(new e.IntPoint2(k.right+10,k.bottom+10)),_.push(new e.IntPoint2(k.right+10,k.top-10)),_.push(new e.IntPoint2(k.left-10,k.top-10)),X.AddPath(_,e.PolyType.ptSubject,!0),X.ReverseSolution=!0,X.Execute(e.ClipType.ctUnion,O,e.PolyFillType.pftNegative,e.PolyFillType.pftNegative),O.length>0&&O.splice(0,1);}}},e.ClipperOffset.prototype.OffsetPoint=function(s,m,O){if(this.m_sinA=this.m_normals[m].X*this.m_normals[s].Y-this.m_normals[s].X*this.m_normals[m].Y,Math.abs(this.m_sinA*this.m_delta)<1){var N=this.m_normals[m].X*this.m_normals[s].X+this.m_normals[s].Y*this.m_normals[m].Y;if(N>0)return this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+this.m_normals[m].X*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_normals[m].Y*this.m_delta))),m;}else this.m_sinA>1?this.m_sinA=1:this.m_sinA<-1&&(this.m_sinA=-1);if(this.m_sinA*this.m_delta<0)this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+this.m_normals[m].X*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_normals[m].Y*this.m_delta))),this.m_destPoly.push(new e.IntPoint1(this.m_srcPoly[s])),this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+this.m_normals[s].X*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_normals[s].Y*this.m_delta)));else switch(O){case e.JoinType.jtMiter:{var X=1+(this.m_normals[s].X*this.m_normals[m].X+this.m_normals[s].Y*this.m_normals[m].Y);X>=this.m_miterLim?this.DoMiter(s,m,X):this.DoSquare(s,m);break;}case e.JoinType.jtSquare:this.DoSquare(s,m);break;case e.JoinType.jtRound:this.DoRound(s,m);break;}return m=s,m;},e.ClipperOffset.prototype.DoSquare=function(s,m){var O=Math.tan(Math.atan2(this.m_sinA,this.m_normals[m].X*this.m_normals[s].X+this.m_normals[m].Y*this.m_normals[s].Y)/4);this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+this.m_delta*(this.m_normals[m].X-this.m_normals[m].Y*O)),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_delta*(this.m_normals[m].Y+this.m_normals[m].X*O)))),this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+this.m_delta*(this.m_normals[s].X+this.m_normals[s].Y*O)),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_delta*(this.m_normals[s].Y-this.m_normals[s].X*O))));},e.ClipperOffset.prototype.DoMiter=function(s,m,O){var N=this.m_delta/O;this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+(this.m_normals[m].X+this.m_normals[s].X)*N),e.ClipperOffset.Round(this.m_srcPoly[s].Y+(this.m_normals[m].Y+this.m_normals[s].Y)*N)));},e.ClipperOffset.prototype.DoRound=function(s,m){for(var O=Math.atan2(this.m_sinA,this.m_normals[m].X*this.m_normals[s].X+this.m_normals[m].Y*this.m_normals[s].Y),N=Math.max(e.Cast_Int32(e.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(O))),1),X=this.m_normals[m].X,k=this.m_normals[m].Y,_,ft=0;ft<N;++ft)this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+X*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[s].Y+k*this.m_delta))),_=X,X=X*this.m_cos-this.m_sin*k,k=_*this.m_sin+k*this.m_cos;this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+this.m_normals[s].X*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_normals[s].Y*this.m_delta)));},e.Error=function(s){try{throw new Error(s);}catch(m){alert(m.message);}},e.JS={},e.JS.AreaOfPolygon=function(s,m){return m||(m=1),e.Clipper.Area(s)/(m*m);},e.JS.AreaOfPolygons=function(s,m){m||(m=1);for(var O=0,N=0;N<s.length;N++)O+=e.Clipper.Area(s[N]);return O/(m*m);},e.JS.BoundsOfPath=function(s,m){return e.JS.BoundsOfPaths([s],m);},e.JS.BoundsOfPaths=function(s,m){m||(m=1);var O=e.Clipper.GetBounds(s);return O.left/=m,O.bottom/=m,O.right/=m,O.top/=m,O;},e.JS.Clean=function(N,m){if(!(N instanceof Array))return[];var O=N[0]instanceof Array,N=e.JS.Clone(N);if(typeof m!="number"||m===null)return e.Error("Delta is not a number in Clean()."),N;if(N.length===0||N.length===1&&N[0].length===0||m<0)return N;O||(N=[N]);for(var X=N.length,k,_,ft,ht,Ct,wt,Lt,Bt=[],Yt=0;Yt<X;Yt++)if(_=N[Yt],k=_.length,k!==0){if(k<3){ft=_,Bt.push(ft);continue;}for(ft=_,ht=m*m,Ct=_[0],wt=1,Lt=1;Lt<k;Lt++)(_[Lt].X-Ct.X)*(_[Lt].X-Ct.X)+(_[Lt].Y-Ct.Y)*(_[Lt].Y-Ct.Y)<=ht||(ft[wt]=_[Lt],Ct=_[Lt],wt++);Ct=_[wt-1],(_[0].X-Ct.X)*(_[0].X-Ct.X)+(_[0].Y-Ct.Y)*(_[0].Y-Ct.Y)<=ht&&wt--,wt<k&&ft.splice(wt,k-wt),ft.length&&Bt.push(ft);}return!O&&Bt.length?Bt=Bt[0]:!O&&Bt.length===0?Bt=[]:O&&Bt.length===0&&(Bt=[[]]),Bt;},e.JS.Clone=function(s){if(!(s instanceof Array))return[];if(s.length===0)return[];if(s.length===1&&s[0].length===0)return[[]];var m=s[0]instanceof Array;m||(s=[s]);var O=s.length,N,X,k,_,ft=new Array(O);for(X=0;X<O;X++){for(N=s[X].length,_=new Array(N),k=0;k<N;k++)_[k]={X:s[X][k].X,Y:s[X][k].Y};ft[X]=_;}return m||(ft=ft[0]),ft;},e.JS.Lighten=function(s,m){if(!(s instanceof Array))return[];if(typeof m!="number"||m===null)return e.Error("Tolerance is not a number in Lighten()."),e.JS.Clone(s);if(s.length===0||s.length===1&&s[0].length===0||m<0)return e.JS.Clone(s);var O=s[0]instanceof Array;O||(s=[s]);var N,X,k,_,ft,ht,Ct,wt,Lt,Bt,Yt,Ht,Vt,ee,ve,Ie,Ye,Ks=s.length,ks=m*m,Xe=[];for(N=0;N<Ks;N++)if(k=s[N],ht=k.length,ht!==0){for(_=0;_<1e6;_++){for(ft=[],ht=k.length,k[ht-1].X!==k[0].X||k[ht-1].Y!==k[0].Y?(Ht=1,k.push({X:k[0].X,Y:k[0].Y}),ht=k.length):Ht=0,Yt=[],X=0;X<ht-2;X++)Ct=k[X],Lt=k[X+1],wt=k[X+2],Ie=Ct.X,Ye=Ct.Y,Vt=wt.X-Ie,ee=wt.Y-Ye,(Vt!==0||ee!==0)&&(ve=((Lt.X-Ie)*Vt+(Lt.Y-Ye)*ee)/(Vt*Vt+ee*ee),ve>1?(Ie=wt.X,Ye=wt.Y):ve>0&&(Ie+=Vt*ve,Ye+=ee*ve)),Vt=Lt.X-Ie,ee=Lt.Y-Ye,Bt=Vt*Vt+ee*ee,Bt<=ks&&(Yt[X+1]=1,X++);for(ft.push({X:k[0].X,Y:k[0].Y}),X=1;X<ht-1;X++)Yt[X]||ft.push({X:k[X].X,Y:k[X].Y});if(ft.push({X:k[ht-1].X,Y:k[ht-1].Y}),Ht&&k.pop(),Yt.length)k=ft;else break;}ht=ft.length,ft[ht-1].X===ft[0].X&&ft[ht-1].Y===ft[0].Y&&ft.pop(),ft.length>2&&Xe.push(ft);}return O||(Xe=Xe[0]),_typeof(Xe)>"u"&&(Xe=[]),Xe;},e.JS.PerimeterOfPath=function(s,m,O){if(_typeof(s)>"u")return 0;var N=Math.sqrt,X=0,k,_,ft=0,ht=0,Ct=0,wt=0,Lt=s.length;if(Lt<2)return 0;for(m&&(s[Lt]=s[0],Lt++);--Lt;)k=s[Lt],ft=k.X,ht=k.Y,_=s[Lt-1],Ct=_.X,wt=_.Y,X+=N((ft-Ct)*(ft-Ct)+(ht-wt)*(ht-wt));return m&&s.pop(),X/O;},e.JS.PerimeterOfPaths=function(s,m,O){O||(O=1);for(var N=0,X=0;X<s.length;X++)N+=e.JS.PerimeterOfPath(s[X],m,O);return N;},e.JS.ScaleDownPath=function(s,m){var O,N;for(m||(m=1),O=s.length;O--;)N=s[O],N.X=N.X/m,N.Y=N.Y/m;},e.JS.ScaleDownPaths=function(s,m){var O,N,X;for(m||(m=1),O=s.length;O--;)for(N=s[O].length;N--;)X=s[O][N],X.X=X.X/m,X.Y=X.Y/m;},e.JS.ScaleUpPath=function(s,m){var O,N,X=Math.round;for(m||(m=1),O=s.length;O--;)N=s[O],N.X=X(N.X*m),N.Y=X(N.Y*m);},e.JS.ScaleUpPaths=function(s,m){var O,N,X,k=Math.round;for(m||(m=1),O=s.length;O--;)for(N=s[O].length;N--;)X=s[O][N],X.X=k(X.X*m),X.Y=k(X.Y*m);},e.ExPolygons=function(){return[];},e.ExPolygon=function(){this.outer=null,this.holes=null;},e.JS.AddOuterPolyNodeToExPolygons=function(s,m){var O=new e.ExPolygon();O.outer=s.Contour();var N=s.Childs(),X=N.length;O.holes=new Array(X);var k,_,ft,ht,Ct,wt;for(ft=0;ft<X;ft++)for(k=N[ft],O.holes[ft]=k.Contour(),ht=0,Ct=k.Childs(),wt=Ct.length;ht<wt;ht++)_=Ct[ht],e.JS.AddOuterPolyNodeToExPolygons(_,m);m.push(O);},e.JS.ExPolygonsToPaths=function(s){var m,O,N,X,k=new e.Paths();for(m=0,N=s.length;m<N;m++)for(k.push(s[m].outer),O=0,X=s[m].holes.length;O<X;O++)k.push(s[m].holes[O]);return k;},e.JS.PolyTreeToExPolygons=function(s){var m=new e.ExPolygons(),O,N,X,k;for(N=0,X=s.Childs(),k=X.length;N<k;N++)O=X[N],e.JS.AddOuterPolyNodeToExPolygons(O,m);return m;};})();})(zi);var Hp=zi.exports,Me=/* @__PURE__ */Ne(Hp);function $i(u,e){var t=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0.01;return Math.abs(u[0]-e[0])<t&&Math.abs(u[1]-e[1])<t;}function Vp(u){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0.01;if(u.length===0)return[];var t=[[u[0][0],u[0][1]]];for(var r=1;r<u.length;r++)$i([u[r][0],u[r][1]],t[t.length-1],e)||t.push([u[r][0],u[r][1]]);return t;}function Kp(u){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0.01;if(u.length<=2)return u;var t=u[0],r=u[u.length-1];return $i(t,r,e)?u.slice(0,-1):u;}function kp(u){var e=u.reduce(function(r,n){return r+n[0];},0)/u.length,t=u.reduce(function(r,n){return r+n[1];},0)/u.length;return[e,t];}function Hn(u,e){return Math.atan2(e[1]-u[1],e[0]-u[0]);}function Zp(u){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0.01;if(u.length<=2)return u;var t=[];var _iterator16=_createForOfIteratorHelper(u),_step16;try{var _loop3=function _loop3(){var n=_step16.value;t.some(function(l){return Math.abs(l[0]-n[0])<e&&Math.abs(l[1]-n[1])<e;})||t.push([n[0],n[1]]);};for(_iterator16.s();!(_step16=_iterator16.n()).done;){_loop3();}}catch(err){_iterator16.e(err);}finally{_iterator16.f();}var r=kp(t);return t.sort(function(n,i){var l=Hn(r,n),o=Hn(r,i);return l-o;});}function Jp(u,e){var t=e[0].x<e[e.length-1].x;return u.map(function(n){var l=n.map(function(o){var a=-1,c=1/0,g=0;for(var f=0;f<e.length;f++){var v=e[f],x=Math.sqrt(Math.pow(v.x-o[0],2)+Math.pow(v.y-o[1],2));x<c&&(c=x,a=f,g=v.z);}return{point:o,index:a,bestZ:g};}).sort(function(o,a){return o.index-a.index;}).map(function(o){return[].concat(_toConsumableArray(o.point),[o.bestZ]);});return t&&l[0][0]>l[l.length-1][0]||!t&&l[0][0]<l[l.length-1][0]?l.reverse():l;}).sort(function(n,i){var l=n[0][0],o=i[0][0];return t?l-o:o-l;});}function Qp(u,e){var t=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0.01;var n=u.map(function(f){return[f.x,f.y];}),i=function i(f,v){return f.map(function(_ref166){var _ref167=_slicedToArray(_ref166,2),x=_ref167[0],M=_ref167[1];return{X:Math.round(x*v),Y:Math.round(M*v)};});},l=new Me.ClipperOffset();l.AddPath(i(n,1e3),Me.JoinType.jtRound,Me.EndType.etOpenButt);var o=[];l.Execute(o,1);var a=new Me.Clipper();a.AddPaths(o,Me.PolyType.ptSubject,!0),e.forEach(function(f){a.AddPath(i(f,1e3),Me.PolyType.ptClip,!0);});var c=new Me.Paths();a.Execute(Me.ClipType.ctDifference,c,Me.PolyFillType.pftNonZero,Me.PolyFillType.pftNonZero);var g=c.map(function(f){return Kp(Zp(Vp(f.map(function(v){return[v.X/1e3,v.Y/1e3];}),t),t),t);}).filter(function(f){return f.length>=2;});return Jp(g,u);}var Gi=/*#__PURE__*/function(_Et){function Gi(t){var _this62;_classCallCheck(this,Gi);_this62=_callSuper(this,Gi,[t]);at(_this62,"canRotate",!0);at(_this62,"scaleType",Qt.all);at(_this62,"toolsType",xt.Pencil);at(_this62,"syncTimestamp");at(_this62,"syncIndex",0);at(_this62,"tmpPoints",[]);at(_this62,"MAX_REPEAR",10);/** 合并原始点的灵敏度 */at(_this62,"uniThickness");at(_this62,"workOptions");at(_this62,"centerPos",[0,0]);_this62.workOptions=t.toolsOpt,_this62.uniThickness=_this62.MAX_REPEAR/_this62.workOptions.thickness/10,_this62.syncTimestamp=0;return _this62;}/** 批量合并消费本地数据,返回绘制结果 */_inherits(Gi,_Et);return _createClass(Gi,[{key:"combineConsume",value:function combineConsume(){var o;var t=(o=this.workId)==null?void 0:o.toString();if(this.tmpPoints.length<2)return{type:dt.None};var r=this.transformDataAll(!0),n={name:t};var i;var l=this.drawLayer||this.fullLayer;return r.length&&(i=this.draw({attrs:n,tasks:r,replaceId:t,layer:l})),{rect:i,type:dt.DrawWork,dataType:bt.Local};}},{key:"setWorkOptions",value:function setWorkOptions(t){_superPropGet(Gi,"setWorkOptions",this,3)([t]),this.syncTimestamp=Date.now();}},{key:"consume",value:function consume(t){var _this63=this;var r=t.data,n=t.isFullWork,i=t.isSubWorker,l=t.isMainThread,o=t.drawCount,a=t.removeDrawCount,c=r.workId,g=r.syncUnitTime;g&&(this.syncUnitTime=g);var _this$transformData=this.transformData(r,!1),f=_this$transformData.tasks,v=_this$transformData.effects,x=_this$transformData.consumeIndex;this.syncIndex=Math.min(this.syncIndex,x,Math.max(0,this.tmpPoints.length-2));var M={name:c,id:ue(o)&&o.toString()||void 0};var S,P=!1;var C=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),f.length&&(f[0].taskId-this.syncTimestamp>this.syncUnitTime&&(P=!0,this.syncTimestamp=f[0].taskId,this.syncIndex=this.tmpPoints.length),i||l)){var p=n?this.fullLayer:this.drawLayer||this.fullLayer;S=this.draw({attrs:M,tasks:f,effects:v,layer:p,removeDrawCount:a});}if(i)return x>10&&this.tmpPoints.splice(0,x-10),{rect:S,type:dt.DrawWork,dataType:bt.Local};var h=[];return this.tmpPoints.slice(C).forEach(function(p){h.push(p.x,p.y,_this63.computRadius(p.z,_this63.workOptions.thickness));}),_objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:dt.DrawWork,dataType:bt.Local,rect:S,op:P?h:void 0,index:P?C*3:void 0,updateNodeOpt:{useAnimation:!0}});}},{key:"consumeAll",value:function consumeAll(t){var g;var r=this.workId;if(t.data){var _t$data=t.data,f=_t$data.op,v=_t$data.workState;f!=null&&f.length&&v===Ft.Done&&this.workOptions.strokeType===Kt.Stroke&&this.updateTempPointsWithPressureWhenDone(f);}var n=this.transformDataAll(!0),i={name:r};var l;var o=this.fullLayer;if(n.length&&(l=this.draw({attrs:i,tasks:n,replaceId:r,layer:o})),this.tmpPoints.length<2)return this.replace(o,r),{type:dt.RemoveNode,removeIds:[r],rect:l};var a=[];this.tmpPoints.map(function(f){a.push(f.x,f.y,f.z);}),this.syncTimestamp=0,delete this.workOptions.syncUnitTime;var c=ge(a);return(g=this.vNodes)==null||g.setInfo(r,{rect:l,op:a,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:l&&Et.getCenterPos(l,o)}),_objectSpread(_objectSpread({},this.baseConsumeResult),{},{rect:l,type:dt.FullWork,dataType:bt.Local,ops:c,updateNodeOpt:{pos:this.centerPos,useAnimation:!0}});}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0;}},{key:"consumeService",value:function consumeService(t){var f,v;var r=t.op,n=t.isFullWork,i=t.replaceId,_t$workState=t.workState,l=_t$workState===void 0?Ft.Done:_t$workState;this.tmpPoints.length=0;for(var x=0;x<r.length;x+=3){var M=new Dt(r[x],r[x+1],r[x+2]);if(this.tmpPoints.length>0){var S=this.tmpPoints[this.tmpPoints.length-1],P=ot.Sub(M,S).uni();M.setv(P);}this.tmpPoints.push(M);}if(this.tmpPoints.length<2)return;var o=this.transformDataAll(!0),a=(f=this.workId)==null?void 0:f.toString(),c={name:a};var g;if(a&&o.length){var _x30=n?this.fullLayer:this.drawLayer||this.fullLayer;g=this.draw({attrs:c,tasks:o,replaceId:i,layer:_x30,isDrawEraserlines:l===Ft.Done}),(v=this.vNodes)==null||v.setInfo(a,{rect:g,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:g&&Et.getCenterPos(g,_x30)});}return g;}},{key:"computPencilPoints",value:function computPencilPoints(t){var _this64=this;var r=[],n=t.op,i=t.eraserPolylines,l=t.eraserThickness;this.tmpPoints.length=0;for(var a=0;a<n.length;a+=3){var c=new Dt(n[a],n[a+1],n[a+2]);if(this.tmpPoints.length>0){var g=this.tmpPoints[this.tmpPoints.length-1],f=ot.Sub(c,g).uni();c.setv(f);}this.tmpPoints.push(c);}if(this.tmpPoints.length<2)return;var o=this.transformDataAll(!0);if(o.length){var _loop4=function _loop4(){var _o$_a=o[_a5],c=_o$_a.pos,g=_o$_a.points,f=g.map(function(M){return M.point.addXY(c[0],c[1]);}),v=[];var _iterator17=_createForOfIteratorHelper(i),_step17;try{for(_iterator17.s();!(_step17=_iterator17.n()).done;){var M=_step17.value;var S=[];for(var _C29=0;_C29<M.length;_C29+=2){var _h27=new Dt(M[_C29],M[_C29+1]);if(S.length>0){var p=S[S.length-1].point,d=ot.Sub(_h27,p).uni();_h27.setv(d);}S.push({point:_h27,radius:l});}var _this64$computStroke=_this64.computStroke(S,!1),P=_this64$computStroke.ps;v.push(P.map(function(C){return C.XY;}));}}catch(err){_iterator17.e(err);}finally{_iterator17.f();}Qp(f,v,0.01).forEach(function(M){r.push(M.map(function(S){return[S[0],S[1],S[2]];}).flat(1));});};for(var _a5=0;_a5<o.length;_a5++){_loop4();}}return r;}},{key:"transformDataAll",value:function transformDataAll(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:!0;return this.getTaskPoints(this.tmpPoints,t&&this.workOptions.thickness||void 0);}},{key:"draw",value:function draw(t){var _this65=this;var r=t.attrs,n=t.tasks,i=t.replaceId,l=t.effects,o=t.layer,a=t.removeDrawCount,_t$isDrawEraserlines=t.isDrawEraserlines,c=_t$isDrawEraserlines===void 0?!0:_t$isDrawEraserlines,_this$workOptions=this.workOptions,g=_this$workOptions.strokeColor,f=_this$workOptions.strokeType,v=_this$workOptions.thickness,x=_this$workOptions.zIndex,M=_this$workOptions.scale,S=_this$workOptions.rotate,P=_this$workOptions.translate,C=_this$workOptions.eraserlines;l!=null&&l.size&&(l.forEach(function(L){var w;(w=o.getElementById(L+""))==null||w.remove();}),l.clear()),a&&this.removeDrawCountNodes(o,a);var h;var p=[],d=o.worldPosition,y=o.worldScaling;for(var L=0;L<n.length;L++){var _n$L=n[L],w=_n$L.pos,B=_n$L.points,_this$computDrawPoint=this.computDrawPoints(B),E=_this$computDrawPoint.ps,b=_this$computDrawPoint.rect;var W=void 0;var D=B.length===1;f===Kt.Stroke||D?W=De(E,!0):W=De(E,!1);var R={pos:w,d:W,fillColor:f===Kt.Stroke||D?g:void 0,lineDash:f===Kt.Dotted&&!D?[1,v*2]:f===Kt.LongDotted&&!D?[v,v*2]:void 0,strokeColor:g,lineCap:f===Kt.Stroke||D?void 0:"round",lineWidth:f===Kt.Stroke||D?0:v};h=Wt(h,{x:Math.floor((b.x+w[0])*y[0]+d[0]-Et.SafeBorderPadding),y:Math.floor((b.y+w[1])*y[1]+d[1]-Et.SafeBorderPadding),w:Math.floor(b.w*y[0]+2*Et.SafeBorderPadding),h:Math.floor(b.h*y[1]+2*Et.SafeBorderPadding)}),p.push(R);}M&&(r.scale=M),S&&(r.rotate=S),P&&(r.translate=P);var I=new me();if(h){this.centerPos=Et.getCenterPos(h,o);var _L4=f===Kt.Stroke&&!C;I.attr(_objectSpread(_objectSpread({},r),{},{normalize:!0,anchor:[0.5,0.5],bgcolor:_L4?g:void 0,pos:this.centerPos,size:[(h.w-2*Et.SafeBorderPadding)/y[0],(h.h-2*Et.SafeBorderPadding)/y[1]],zIndex:x}));var _w5=p.map(function(B){return B.pos=[B.pos[0]-_this65.centerPos[0],B.pos[1]-_this65.centerPos[1]],new be(B);});I.append.apply(I,_toConsumableArray(_w5)),_L4&&I.seal(),C&&(this.scaleType=Qt.proportional,this.drawEraserlines({group:I,eraserlines:C,pos:this.centerPos,layer:o},c)),this.replace(o,i,I);}if(M||S||P){var _L5=I==null?void 0:I.getBoundingClientRect();_L5&&(h={x:Math.floor(_L5.x-Et.SafeBorderPadding),y:Math.floor(_L5.y-Et.SafeBorderPadding),w:Math.floor(_L5.width+Et.SafeBorderPadding*2),h:Math.floor(_L5.height+Et.SafeBorderPadding*2)});}return this.isDelete&&I.setAttribute("opacity",0),h;}},{key:"computDrawPoints",value:function computDrawPoints(t){return this.workOptions.strokeType===Kt.Stroke||t.length===1?this.computStroke(t):this.computNomal(t);}},{key:"computNomal",value:function computNomal(t){var r=this.workOptions.thickness;var n=t.map(function(i){return r=Math.max(r,i.radius),i.point;});return{ps:n,rect:_t(n,r)};}},{key:"computStroke",value:function computStroke(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;return t.length===1?this.computDotStroke(t[0]):this.computLineStroke(t,r);}},{key:"computLineStroke",value:function computLineStroke(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var n=[],i=[];for(var a=0;a<t.length;a++){var _t$a=t[a],c=_t$a.point,g=_t$a.radius;var f=c.v;a===0&&t.length>1&&(f=t[a+1].point.v);var v=ot.Per(f).mul(g);n.push(Dt.Sub(c,v)),i.push(Dt.Add(c,v));}var l=t[t.length-1];if(r){var _a6=Dt.GetSemicircleStroke(l.point,n[n.length-1],-1,8),_c4=Dt.GetSemicircleStroke(t[0].point,i[0],-1,8),_g6=n.concat(_a6,i.reverse(),_c4);return{ps:_g6,rect:_t(_g6)};}var o=n.concat(i.reverse());return{ps:o,rect:_t(o)};}},{key:"computDotStroke",value:function computDotStroke(t){var r=t.point,n=t.radius,i={x:r.x-n,y:r.y-n,w:n*2,h:n*2};return{ps:Dt.GetDotStroke(r,n,8),rect:i};}},{key:"transformData",value:function transformData(t,r){var n=t.op,i=t.workState;var l=this.tmpPoints.length-1,o=[];if(n!=null&&n.length&&i){var _this$workOptions2=this.workOptions,a=_this$workOptions2.strokeType,c=_this$workOptions2.thickness,g=/* @__PURE__ */new Set();l=a===Kt.Stroke?this.updateTempPointsWithPressure(n,c,g):this.updateTempPoints(n,c,g);var f=r?this.tmpPoints:this.tmpPoints.slice(l);return o=this.getTaskPoints(f,c),{tasks:o,effects:g,consumeIndex:l};}return{tasks:o,consumeIndex:l};}/** 压力渐变公式 */},{key:"computRadius",value:function computRadius(t,r){return t*0.03*r+r*0.5;}},{key:"getMinZ",value:function getMinZ(t,r){return((r||Math.max(1,Math.floor(t*0.3)))-t*0.5)*100/t/3;}},{key:"getTaskPoints",value:function getTaskPoints(t,r){var f;var n=[];if(t.length===0)return[];var i=0,l=t[0].x,o=t[0].y,a=[l,o],c=[],g=t[0].t;for(;i<t.length;){var v=t[i],x=v.x-l,M=v.y-o,S=v.z,P=r?this.computRadius(S,r):S;if(c.push({point:new Dt(x,M,S,t[i].v),radius:P}),i>0&&i<t.length-1){var _C30=t[i].getAngleByPoints(t[i-1],t[i+1]);if(_C30<60||_C30>300){var _h28=(f=c.pop())==null?void 0:f.point.clone();_h28&&n.push({taskId:g,pos:a,points:[].concat(_toConsumableArray(c),[{point:_h28,radius:P}])}),l=t[i].x,o=t[i].y,a=[l,o];var p=v.x-l,d=v.y-o;c=[{point:new Dt(p,d,S),radius:P}],g=Date.now();}}i++;}return n.push({taskId:g,pos:a,points:c}),n;}},{key:"updateTempPointsWithPressure",value:function updateTempPointsWithPressure(t,r,n){var i=Date.now(),l=this.tmpPoints.length;var o=l;for(var c=0;c<t.length;c+=2){o=Math.min(o,l);var g=this.tmpPoints.length,f=new Dt(t[c],t[c+1]);if(g===0){this.tmpPoints.push(f);continue;}var v=g-1,x=this.tmpPoints[v],M=ot.Sub(f,x).uni();if(f.isNear(x,r)){if(x.z<this.MAX_REPEAR){if(x.setz(Math.min(x.z+1,this.MAX_REPEAR)),o=Math.min(o,v),g>1){var _C31=g-1;for(;_C31>0;){var _h29=this.tmpPoints[_C31].distance(this.tmpPoints[_C31-1]),p=Math.max(this.tmpPoints[_C31].z-this.uniThickness*_h29,0);if(this.tmpPoints[_C31-1].z>=p)break;this.tmpPoints[_C31-1].setz(p),o=Math.min(o,_C31-1),_C31--;}}}else o=1/0;continue;}f.setv(M);var S=f.distance(x),P=Math.max(x.z-this.uniThickness*S,0);g>1&&ot.Equals(M,x.v,0.02)&&(P>0||x.z<=0)&&(n&&x.t&&n.add(x.t),this.tmpPoints.pop(),o=Math.min(v,o)),f.setz(P),this.tmpPoints.push(f);}if(o===1/0)return this.tmpPoints.length;var a=l;if(o===l){a=Math.max(a-1,0);var _c5=this.tmpPoints[a].t;_c5&&(n==null||n.add(_c5));}else{var _c6=l-1;for(a=o;_c6>=0;){var _g7=this.tmpPoints[_c6].t;if(_g7&&(n==null||n.add(_g7),_c6<=o)){a=_c6,_c6=-1;break;}_c6--;}}return this.tmpPoints[a].setT(i),a;}},{key:"updateTempPoints",value:function updateTempPoints(t,r,n){var c;var i=Date.now(),l=this.tmpPoints.length;var o=l;for(var g=0;g<t.length;g+=2){var f=this.tmpPoints.length,v=new Dt(t[g],t[g+1]);if(f===0){this.tmpPoints.push(v);continue;}var x=f-1,M=this.tmpPoints[x],S=ot.Sub(v,M).uni();if(v.isNear(M,r/2)){o=Math.min(x,o);continue;}ot.Equals(S,M.v,0.02)&&(n&&M.t&&n.add(M.t),this.tmpPoints.pop(),o=Math.min(x,o)),v.setv(S),this.tmpPoints.push(v);}var a=l;if(o===l){a=Math.max(a-1,0);var _g8=this.tmpPoints[a].t;_g8&&(n==null||n.add(_g8));}else{var _g9=Math.min(l-1,o);for(a=o;_g9>=0;){var _f4=(c=this.tmpPoints[_g9])==null?void 0:c.t;if(_f4&&(n==null||n.add(_f4),_g9<=o)){a=_g9,_g9=-1;break;}_g9--;}}return this.tmpPoints[a].setT(i),a;}},{key:"updateTempPointsWithPressureWhenDone",value:function updateTempPointsWithPressureWhenDone(t){var r=this.workOptions.thickness,n=t.length,i=this.getMinZ(r);for(var l=0;l<n;l+=2){var o=this.tmpPoints.length,a=new Dt(t[l],t[l+1]);if(o===0){this.tmpPoints.push(a);continue;}var c=o-1,g=this.tmpPoints[c],f=ot.Sub(a,g).uni(),v=a.distance(g);if(o>1&&g.z===i)break;if(a.isNear(g,r/2)){if(n<3&&g.z<this.MAX_REPEAR&&(g.setz(Math.min(g.z+1,this.MAX_REPEAR)),o>1)){var M=o-1;for(;M>0;){var S=this.tmpPoints[M].distance(this.tmpPoints[M-1]),P=Math.max(this.tmpPoints[M].z-this.uniThickness*S,-r/4);if(this.tmpPoints[M-1].z>=P)break;this.tmpPoints[M-1].setz(P),M--;}}continue;}a.setv(f);var x=Math.max(g.z-this.uniThickness*v,i);o>1&&ot.Equals(f,g.v,0.02)&&g.z<=0&&this.tmpPoints.pop(),a.setz(x),this.tmpPoints.push(a);}}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var c,g;var r=t.node,n=t.opt,i=t.vNodes,l=n.strokeColor,o=n.strokeType,a=i.get(r.name);return l&&(r.tagName==="GROUP"?ym(r)?r.setAttribute("bgcolor",l):r.children.forEach(function(f){f.setAttribute("strokeColor",l),f.getAttribute("fillColor")&&f.setAttribute("fillColor",l);}):(r.setAttribute("strokeColor",l),r.setAttribute("fillColor",l)),(c=a==null?void 0:a.opt)!=null&&c.strokeColor&&(a.opt.strokeColor=l)),o&&a!=null&&a.opt&&(g=a.opt)!=null&&g.strokeType&&(a.opt.strokeType=o),a&&i.setInfo(r.name,a),Et.updateNodeOpt(t);}}]);}(Et);var Hi=/*#__PURE__*/function(_Et2){function Hi(t){var _this66;_classCallCheck(this,Hi);_this66=_callSuper(this,Hi,[t]);at(_this66,"toolsType",xt.LaserPen);at(_this66,"canRotate",!1);at(_this66,"scaleType",Qt.none);at(_this66,"syncTimestamp");at(_this66,"syncIndex",0);at(_this66,"tmpPoints",[]);at(_this66,"workOptions");at(_this66,"consumeIndex",0);_this66.workOptions=t.toolsOpt,_this66.syncTimestamp=0;return _this66;}_inherits(Hi,_Et2);return _createClass(Hi,[{key:"combineConsume",value:function combineConsume(){}},{key:"setWorkOptions",value:function setWorkOptions(t){_superPropGet(Hi,"setWorkOptions",this,3)([t]),this.syncTimestamp=Date.now();}},{key:"consume",value:function consume(t){var r=t.data,n=t.isSubWorker,i=r.workId,l=r.op,o=r.syncUnitTime;if((l==null?void 0:l.length)===0)return{type:dt.None};if(o&&(this.syncUnitTime=o),this.updateTempPoints(l||[]),this.consumeIndex>this.tmpPoints.length-4)return{type:dt.None};var _this$workOptions3=this.workOptions,a=_this$workOptions3.strokeColor,c=_this$workOptions3.thickness,g=_this$workOptions3.strokeType,f=_t(this.tmpPoints,c);var v=!1;var x=this.syncIndex,M=this.tmpPoints.slice(this.consumeIndex);this.consumeIndex=this.tmpPoints.length-1,this.syncTimestamp===0&&(this.syncTimestamp=Date.now());var S={name:i==null?void 0:i.toString(),opacity:1,lineDash:g===Kt.Dotted?[1,c*2]:g===Kt.LongDotted?[c,c*2]:void 0,strokeColor:a,lineCap:"round",lineWidth:c,anchor:[0.5,0.5]},P=this.getTaskPoints(M);if(P.length){var _h30=Date.now();_h30-this.syncTimestamp>this.syncUnitTime&&(v=!0,this.syncTimestamp=_h30,this.syncIndex=this.tmpPoints.length),n&&this.draw({attrs:S,tasks:P,isDot:!1,layer:this.drawLayer||this.fullLayer});}var C=[];return this.tmpPoints.slice(x).forEach(function(h){C.push(h.x,h.y);}),_objectSpread({rect:{x:f.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:f.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:f.w*this.fullLayer.worldScaling[0],h:f.h*this.fullLayer.worldScaling[1]},type:dt.DrawWork,dataType:bt.Local,op:v?C:void 0,index:v?x*2:void 0},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var l;var t=(l=this.workId)==null?void 0:l.toString();var r;if(this.tmpPoints.length-1>this.consumeIndex){var o=this.tmpPoints.slice(this.consumeIndex);var a=o.length===1,_this$workOptions4=this.workOptions,c=_this$workOptions4.strokeColor,g=_this$workOptions4.thickness,f=_this$workOptions4.strokeType;if(a){var M=this.computDotStroke({point:o[0],radius:g/2});o=M.ps,r=M.rect;}else r=_t(this.tmpPoints,g);var v={name:t==null?void 0:t.toString(),fillColor:a?c:void 0,opacity:1,lineDash:f===Kt.Dotted&&!a?[1,g*2]:f===Kt.LongDotted&&!a?[g,g*2]:void 0,strokeColor:c,lineCap:a?void 0:"round",lineWidth:a?0:g,anchor:[0.5,0.5]},x=this.getTaskPoints(o);x.length&&this.draw({attrs:v,tasks:x,isDot:a,layer:this.drawLayer||this.fullLayer});}var n=[];this.tmpPoints.forEach(function(o){n.push(o.x,o.y);});var i=ge(n);return _objectSpread({rect:r&&{x:r.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:r.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:r.w*this.fullLayer.worldScaling[0],h:r.h*this.fullLayer.worldScaling[1]},type:dt.FullWork,dataType:bt.Local,ops:i,index:this.syncIndex*2},this.baseConsumeResult);}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0;}},{key:"consumeService",value:function consumeService(t){var S;var r=t.op,n=t.replaceId,i=t.isFullWork,_this$workOptions5=this.workOptions,l=_this$workOptions5.strokeColor,o=_this$workOptions5.thickness,a=_this$workOptions5.strokeType;if(!r.length){var P=_t(this.tmpPoints,o);return{x:P.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:P.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:P.w*this.fullLayer.worldScaling[0],h:P.h*this.fullLayer.worldScaling[1]};}var c=Math.max(0,this.tmpPoints.length-1);this.updateTempPoints(r||[]);var g,f=this.tmpPoints.slice(c);var v=f.length===1;if(v){var _P6=this.computDotStroke({point:f[0],radius:o/2});f=_P6.ps,g=_P6.rect;}else g=_t(this.tmpPoints,o);var x={name:(S=this.workId)==null?void 0:S.toString(),fillColor:v?l:void 0,opacity:1,lineDash:a===Kt.Dotted&&!v?[1,o*2]:a===Kt.LongDotted&&!v?[o,o*2]:void 0,strokeColor:l,lineCap:v?void 0:"round",lineWidth:v?0:o,anchor:[0.5,0.5]},M=this.getTaskPoints(f);if(M.length){var _P7=i?this.fullLayer:this.drawLayer||this.fullLayer;this.draw({attrs:x,tasks:M,isDot:v,replaceId:n,layer:_P7});}return{x:g.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:g.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:g.w*this.fullLayer.worldScaling[0],h:g.h*this.fullLayer.worldScaling[1]};}},{key:"computDotStroke",value:function computDotStroke(t){var r=t.point,n=t.radius,i={x:r.x-n,y:r.y-n,w:n*2,h:n*2};return{ps:Dt.GetDotStroke(r,n,8),rect:i};}},{key:"updateTempPoints",value:function updateTempPoints(t){var r=this.tmpPoints.length;for(var n=0;n<t.length;n+=2){if(r){var i=this.tmpPoints.slice(-1)[0];i&&i.x===t[n]&&i.y===t[n+1]&&this.tmpPoints.pop();}this.tmpPoints.push(new Dt(t[n],t[n+1]));}}},{key:"draw",value:function(){var _draw2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21(t){var _this67=this;var r,n,i,l,o,_iterator18,_step18,_loop5;return _regeneratorRuntime().wrap(function _callee21$(_context23){while(1)switch(_context23.prev=_context23.next){case 0:r=t.attrs,n=t.tasks,i=t.isDot,l=t.layer,o=this.workOptions.duration;_iterator18=_createForOfIteratorHelper(n);_context23.prev=2;_loop5=/*#__PURE__*/_regeneratorRuntime().mark(function _loop5(){var a,c,g,f,v,_this67$workOptions,x,M,S,_l$getResolution,P,_C32;return _regeneratorRuntime().wrap(function _loop5$(_context22){while(1)switch(_context22.prev=_context22.next){case 0:a=_step18.value;c=new be(),g=a.pos,f=a.points;i?v=De(f,!0):v=De(f,!1),c.attr(_objectSpread(_objectSpread({},r),{},{pos:g,d:v}));_this67$workOptions=_this67.workOptions,x=_this67$workOptions.vertex,M=_this67$workOptions.fragment;if(x&&M){S=l.renderer.createProgram({vertex:x,fragment:M}),_l$getResolution=l.getResolution(),P=_l$getResolution.width,_C32=_l$getResolution.height;c.setUniforms({u_time:0,u_resolution:[P,_C32]}),c.setProgram(S);}l.appendChild(c),c.transition(o).attr({scale:i?[0.1,0.1]:[1,1],lineWidth:i?0:1}).then(function(){c.remove();});case 6:case"end":return _context22.stop();}},_loop5);});_iterator18.s();case 5:if((_step18=_iterator18.n()).done){_context23.next=9;break;}return _context23.delegateYield(_loop5(),"t0",7);case 7:_context23.next=5;break;case 9:_context23.next=14;break;case 11:_context23.prev=11;_context23.t1=_context23["catch"](2);_iterator18.e(_context23.t1);case 14:_context23.prev=14;_iterator18.f();return _context23.finish(14);case 17:case"end":return _context23.stop();}},_callee21,this,[[2,11,14,17]]);}));function draw(_x31){return _draw2.apply(this,arguments);}return draw;}()},{key:"getTaskPoints",value:function getTaskPoints(t){var c;var r=[];if(t.length===0)return[];var n=0,i=t[0].x,l=t[0].y,o=[i,l],a=[];for(;n<t.length;){var g=t[n],f=g.x-i,v=g.y-l;if(a.push(new Dt(f,v)),n>0&&n<t.length-1){var x=t[n].getAngleByPoints(t[n-1],t[n+1]);if(x<60||x>300){var M=(c=a.pop())==null?void 0:c.clone();M&&r.push({pos:o,points:[].concat(_toConsumableArray(a),[M])}),i=t[n].x,l=t[n].y,o=[i,l];var S=g.x-i,P=g.y-l;a=[new Dt(S,P)];}}n++;}return r.push({pos:o,points:a}),r;}},{key:"removeLocal",value:function removeLocal(){}},{key:"removeService",value:function removeService(t){var r;var n=[];return this.fullLayer.getElementsByName(t).forEach(function(i){if(i.name===t){var l=i.getBoundingClientRect();r=Wt(r,{x:l.x,y:l.y,w:l.width,h:l.height}),n.push(i);}}),n.length&&n.forEach(function(i){return i.remove();}),r;}}]);}(Et);var qp=Sr;Sr.polyline=Sr;Sr.polygon=_p;function Sr(u,e,t){var r=u.length,n=Ge(u[0],e),i=[],l,o,a,c,g;for(t||(t=[]),l=1;l<r;l++){for(o=u[l-1],a=u[l],c=g=Ge(a,e);;)if(n|c){if(n&c)break;n?(o=Kr(o,a,n,e),n=Ge(o,e)):(a=Kr(o,a,c,e),c=Ge(a,e));}else{i.push(o),c!==g?(i.push(a),l<r-1&&(t.push(i),i=[])):l===r-1&&i.push(a);break;}n=g;}return i.length&&t.push(i),t;}function _p(u,e){var t,r,n,i,l,o,a;for(r=1;r<=8;r*=2){for(t=[],n=u[u.length-1],i=!(Ge(n,e)&r),l=0;l<u.length;l++)o=u[l],a=!(Ge(o,e)&r),a!==i&&t.push(Kr(n,o,r,e)),a&&t.push(o),n=o,i=a;if(u=t,!u.length)break;}return t;}function Kr(u,e,t,r){return t&8?[u[0]+(e[0]-u[0])*(r[3]-u[1])/(e[1]-u[1]),r[3]]:// top
|
|
404
404
|
t&4?[u[0]+(e[0]-u[0])*(r[1]-u[1])/(e[1]-u[1]),r[1]]:// bottom
|
|
405
405
|
t&2?[r[2],u[1]+(e[1]-u[1])*(r[2]-u[0])/(e[0]-u[0])]:// right
|
|
406
406
|
t&1?[r[0],u[1]+(e[1]-u[1])*(r[0]-u[0])/(e[0]-u[0])]:// left
|