@netless/appliance-plugin 1.1.22-beta.4 → 1.1.22-beta.6

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.
@@ -392,20 +392,20 @@ _inherits(o,_r$default22);return _createClass(o,[{key:"texture",get:function get
392
392
  * @param radian 1,逆时针180度 -1,顺时针
393
393
  * @param average 均分数
394
394
  * @returns
395
- */},{key:"GetSemicircleStroke",value:function GetSemicircleStroke(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:-1;var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:8;var i=r*(Math.PI+1e-3),l=[];for(var o=1/n,a=o;a<=1;a+=o)l.push(Nt.RotWith(t,e,i*a));return l;}}]);}(at);var yr=(typeof globalThis==="undefined"?"undefined":_typeof(globalThis))<"u"?globalThis:(typeof window==="undefined"?"undefined":_typeof(window))<"u"?window:(typeof global==="undefined"?"undefined":_typeof(global))<"u"?global:(typeof self==="undefined"?"undefined":_typeof(self))<"u"?self:{};function Ne(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u["default"]:u;}var xo=_typeof(yr)=="object"&&yr&&yr.Object===Object&&yr,mi=xo,To=mi,Co=(typeof self==="undefined"?"undefined":_typeof(self))=="object"&&self&&self.Object===Object&&self,Io=To||Co||Function("return this")(),Ae=Io,Oo=Ae,Eo=Oo.Symbol,ur=Eo,xn=ur,vi=Object.prototype,Mo=vi.hasOwnProperty,Ao=vi.toString,sr=xn?xn.toStringTag:void 0;function wo(u){var e=Mo.call(u,sr),t=u[sr];try{u[sr]=void 0;var r=!0;}catch(_unused18){}var n=Ao.call(u);return r&&(e?u[sr]=t:delete u[sr]),n;}var Lo=wo,Ro=Object.prototype,Do=Ro.toString;function bo(u){return Do.call(u);}var No=bo,Tn=ur,Bo=Lo,Wo=No,Fo="[object Null]",Uo="[object Undefined]",Cn=Tn?Tn.toStringTag:void 0;function jo(u){return u==null?u===void 0?Uo:Fo:Cn&&Cn in Object(u)?Bo(u):Wo(u);}var qe=jo;function Yo(u){return u!=null&&_typeof(u)=="object";}var Le=Yo,Xo=qe,zo=Le,$o="[object Number]";function Go(u){return typeof u=="number"||zo(u)&&Xo(u)==$o;}var ko=Go,ue=/* @__PURE__ */Ne(ko);function Ho(){this.__data__=[],this.size=0;}var Vo=Ho;function Ko(u,e){return u===e||u!==u&&e!==e;}var qr=Ko,Zo=qr;function Jo(u,e){for(var t=u.length;t--;)if(Zo(u[t][0],e))return t;return-1;}var Rr=Jo,Qo=Rr,qo=Array.prototype,_o=qo.splice;function ta(u){var e=this.__data__,t=Qo(e,u);if(t<0)return!1;var r=e.length-1;return t==r?e.pop():_o.call(e,t,1),--this.size,!0;}var ea=ta,ra=Rr;function na(u){var e=this.__data__,t=ra(e,u);return t<0?void 0:e[t][1];}var ia=na,sa=Rr;function oa(u){return sa(this.__data__,u)>-1;}var aa=oa,la=Rr;function ca(u,e){var t=this.__data__,r=la(t,u);return r<0?(++this.size,t.push([u,e])):t[r][1]=e,this;}var fa=ca,ha=Vo,ua=ea,da=ia,pa=aa,ma=fa;function _e(u){var e=-1,t=u==null?0:u.length;for(this.clear();++e<t;){var r=u[e];this.set(r[0],r[1]);}}_e.prototype.clear=ha;_e.prototype["delete"]=ua;_e.prototype.get=da;_e.prototype.has=pa;_e.prototype.set=ma;var Dr=_e,va=Dr;function ya(){this.__data__=new va(),this.size=0;}var ga=ya;function Pa(u){var e=this.__data__,t=e["delete"](u);return this.size=e.size,t;}var Sa=Pa;function xa(u){return this.__data__.get(u);}var Ta=xa;function Ca(u){return this.__data__.has(u);}var Ia=Ca;function Oa(u){var e=_typeof(u);return u!=null&&(e=="object"||e=="function");}var dr=Oa,Ea=qe,Ma=dr,Aa="[object AsyncFunction]",wa="[object Function]",La="[object GeneratorFunction]",Ra="[object Proxy]";function Da(u){if(!Ma(u))return!1;var e=Ea(u);return e==wa||e==La||e==Aa||e==Ra;}var yi=Da,ba=Ae,Na=ba["__core-js_shared__"],Ba=Na,jr=Ba,In=function(){var u=/[^.]+$/.exec(jr&&jr.keys&&jr.keys.IE_PROTO||"");return u?"Symbol(src)_1."+u:"";}();function Wa(u){return!!In&&In in u;}var Fa=Wa,Ua=Function.prototype,ja=Ua.toString;function Ya(u){if(u!=null){try{return ja.call(u);}catch(_unused19){}try{return u+"";}catch(_unused20){}}return"";}var gi=Ya,Xa=yi,za=Fa,$a=dr,Ga=gi,ka=/[\\^$.*+?()[\]{}|]/g,Ha=/^\[object .+?Constructor\]$/,Va=Function.prototype,Ka=Object.prototype,Za=Va.toString,Ja=Ka.hasOwnProperty,Qa=RegExp("^"+Za.call(Ja).replace(ka,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function qa(u){if(!$a(u)||za(u))return!1;var e=Xa(u)?Qa:Ha;return e.test(Ga(u));}var _a=qa;function tl(u,e){return u==null?void 0:u[e];}var el=tl,rl=_a,nl=el;function il(u,e){var t=nl(u,e);return rl(t)?t:void 0;}var Ue=il,sl=Ue,ol=Ae,al=sl(ol,"Map"),_r=al,ll=Ue,cl=ll(Object,"create"),br=cl,On=br;function fl(){this.__data__=On?On(null):{},this.size=0;}var hl=fl;function ul(u){var e=this.has(u)&&delete this.__data__[u];return this.size-=e?1:0,e;}var dl=ul,pl=br,ml="__lodash_hash_undefined__",vl=Object.prototype,yl=vl.hasOwnProperty;function gl(u){var e=this.__data__;if(pl){var t=e[u];return t===ml?void 0:t;}return yl.call(e,u)?e[u]:void 0;}var Pl=gl,Sl=br,xl=Object.prototype,Tl=xl.hasOwnProperty;function Cl(u){var e=this.__data__;return Sl?e[u]!==void 0:Tl.call(e,u);}var Il=Cl,Ol=br,El="__lodash_hash_undefined__";function Ml(u,e){var t=this.__data__;return this.size+=this.has(u)?0:1,t[u]=Ol&&e===void 0?El:e,this;}var Al=Ml,wl=hl,Ll=dl,Rl=Pl,Dl=Il,bl=Al;function tr(u){var e=-1,t=u==null?0:u.length;for(this.clear();++e<t;){var r=u[e];this.set(r[0],r[1]);}}tr.prototype.clear=wl;tr.prototype["delete"]=Ll;tr.prototype.get=Rl;tr.prototype.has=Dl;tr.prototype.set=bl;var Nl=tr,En=Nl,Bl=Dr,Wl=_r;function Fl(){this.size=0,this.__data__={hash:new En(),map:new(Wl||Bl)(),string:new En()};}var Ul=Fl;function jl(u){var e=_typeof(u);return e=="string"||e=="number"||e=="symbol"||e=="boolean"?u!=="__proto__":u===null;}var Yl=jl,Xl=Yl;function zl(u,e){var t=u.__data__;return Xl(e)?t[typeof e=="string"?"string":"hash"]:t.map;}var Nr=zl,$l=Nr;function Gl(u){var e=$l(this,u)["delete"](u);return this.size-=e?1:0,e;}var kl=Gl,Hl=Nr;function Vl(u){return Hl(this,u).get(u);}var Kl=Vl,Zl=Nr;function Jl(u){return Zl(this,u).has(u);}var Ql=Jl,ql=Nr;function _l(u,e){var t=ql(this,u),r=t.size;return t.set(u,e),this.size+=t.size==r?0:1,this;}var tc=_l,ec=Ul,rc=kl,nc=Kl,ic=Ql,sc=tc;function er(u){var e=-1,t=u==null?0:u.length;for(this.clear();++e<t;){var r=u[e];this.set(r[0],r[1]);}}er.prototype.clear=ec;er.prototype["delete"]=rc;er.prototype.get=nc;er.prototype.has=ic;er.prototype.set=sc;var Pi=er,oc=Dr,ac=_r,lc=Pi,cc=200;function fc(u,e){var t=this.__data__;if(t instanceof oc){var r=t.__data__;if(!ac||r.length<cc-1)return r.push([u,e]),this.size=++t.size,this;t=this.__data__=new lc(r);}return t.set(u,e),this.size=t.size,this;}var hc=fc,uc=Dr,dc=ga,pc=Sa,mc=Ta,vc=Ia,yc=hc;function rr(u){var e=this.__data__=new uc(u);this.size=e.size;}rr.prototype.clear=dc;rr.prototype["delete"]=pc;rr.prototype.get=mc;rr.prototype.has=vc;rr.prototype.set=yc;var Si=rr;function gc(u,e){for(var t=-1,r=u==null?0:u.length;++t<r&&e(u[t],t,u)!==!1;);return u;}var Pc=gc,Sc=Ue,xc=function(){try{var u=Sc(Object,"defineProperty");return u({},"",{}),u;}catch(_unused21){}}(),xi=xc,Mn=xi;function Tc(u,e,t){e=="__proto__"&&Mn?Mn(u,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):u[e]=t;}var Ti=Tc,Cc=Ti,Ic=qr,Oc=Object.prototype,Ec=Oc.hasOwnProperty;function Mc(u,e,t){var r=u[e];(!(Ec.call(u,e)&&Ic(r,t))||t===void 0&&!(e in u))&&Cc(u,e,t);}var Ci=Mc,Ac=Ci,wc=Ti;function Lc(u,e,t,r){var n=!t;t||(t={});for(var i=-1,l=e.length;++i<l;){var o=e[i],a=r?r(t[o],u[o],o,t,u):void 0;a===void 0&&(a=u[o]),n?wc(t,o,a):Ac(t,o,a);}return t;}var Br=Lc;function Rc(u,e){for(var t=-1,r=Array(u);++t<u;)r[t]=e(t);return r;}var Dc=Rc,bc=qe,Nc=Le,Bc="[object Arguments]";function Wc(u){return Nc(u)&&bc(u)==Bc;}var Fc=Wc,An=Fc,Uc=Le,Ii=Object.prototype,jc=Ii.hasOwnProperty,Yc=Ii.propertyIsEnumerable,Xc=An(/* @__PURE__ */function(){return arguments;}())?An:function(u){return Uc(u)&&jc.call(u,"callee")&&!Yc.call(u,"callee");},Oi=Xc,zc=Array.isArray,pr=zc,Sr={exports:{}};function $c(){return!1;}var Gc=$c;Sr.exports;(function(u,e){var t=Ae,r=Gc,n=e&&!e.nodeType&&e,i=n&&!0&&u&&!u.nodeType&&u,l=i&&i.exports===n,o=l?t.Buffer:void 0,a=o?o.isBuffer:void 0,c=a||r;u.exports=c;})(Sr,Sr.exports);var tn=Sr.exports,kc=9007199254740991,Hc=/^(?:0|[1-9]\d*)$/;function Vc(u,e){var _e2;var t=_typeof(u);return e=(_e2=e)!==null&&_e2!==void 0?_e2:kc,!!e&&(t=="number"||t!="symbol"&&Hc.test(u))&&u>-1&&u%1==0&&u<e;}var Kc=Vc,Zc=9007199254740991;function Jc(u){return typeof u=="number"&&u>-1&&u%1==0&&u<=Zc;}var Ei=Jc,Qc=qe,qc=Ei,_c=Le,tf="[object Arguments]",ef="[object Array]",rf="[object Boolean]",nf="[object Date]",sf="[object Error]",of="[object Function]",af="[object Map]",lf="[object Number]",cf="[object Object]",ff="[object RegExp]",hf="[object Set]",uf="[object String]",df="[object WeakMap]",pf="[object ArrayBuffer]",mf="[object DataView]",vf="[object Float32Array]",yf="[object Float64Array]",gf="[object Int8Array]",Pf="[object Int16Array]",Sf="[object Int32Array]",xf="[object Uint8Array]",Tf="[object Uint8ClampedArray]",Cf="[object Uint16Array]",If="[object Uint32Array]",ne={};ne[vf]=ne[yf]=ne[gf]=ne[Pf]=ne[Sf]=ne[xf]=ne[Tf]=ne[Cf]=ne[If]=!0;ne[tf]=ne[ef]=ne[pf]=ne[rf]=ne[mf]=ne[nf]=ne[sf]=ne[of]=ne[af]=ne[lf]=ne[cf]=ne[ff]=ne[hf]=ne[uf]=ne[df]=!1;function Of(u){return _c(u)&&qc(u.length)&&!!ne[Qc(u)];}var Ef=Of;function Mf(u){return function(e){return u(e);};}var Wr=Mf,xr={exports:{}};xr.exports;(function(u,e){var t=mi,r=e&&!e.nodeType&&e,n=r&&!0&&u&&!u.nodeType&&u,i=n&&n.exports===r,l=i&&t.process,o=function(){try{var a=n&&n.require&&n.require("util").types;return a||l&&l.binding&&l.binding("util");}catch(_unused22){}}();u.exports=o;})(xr,xr.exports);var en=xr.exports,Af=Ef,wf=Wr,wn=en,Ln=wn&&wn.isTypedArray,Lf=Ln?wf(Ln):Af,Mi=Lf,Rf=Dc,Df=Oi,bf=pr,Nf=tn,Bf=Kc,Wf=Mi,Ff=Object.prototype,Uf=Ff.hasOwnProperty;function jf(u,e){var t=bf(u),r=!t&&Df(u),n=!t&&!r&&Nf(u),i=!t&&!r&&!n&&Wf(u),l=t||r||n||i,o=l?Rf(u.length,String):[],a=o.length;for(var c in u)(e||Uf.call(u,c))&&!(l&&(// Safari 9 has enumerable `arguments.length` in strict mode.
395
+ */},{key:"GetSemicircleStroke",value:function GetSemicircleStroke(e,t){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:-1;var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:8;var i=r*(Math.PI+1e-3),l=[];for(var o=1/n,a=o;a<=1;a+=o)l.push(Nt.RotWith(t,e,i*a));return l;}}]);}(at);var yr=(typeof globalThis==="undefined"?"undefined":_typeof(globalThis))<"u"?globalThis:(typeof window==="undefined"?"undefined":_typeof(window))<"u"?window:(typeof global==="undefined"?"undefined":_typeof(global))<"u"?global:(typeof self==="undefined"?"undefined":_typeof(self))<"u"?self:{};function Ne(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u["default"]:u;}var xo=_typeof(yr)=="object"&&yr&&yr.Object===Object&&yr,mi=xo,To=mi,Co=(typeof self==="undefined"?"undefined":_typeof(self))=="object"&&self&&self.Object===Object&&self,Io=To||Co||Function("return this")(),Ae=Io,Oo=Ae,Eo=Oo.Symbol,ur=Eo,xn=ur,vi=Object.prototype,Mo=vi.hasOwnProperty,Ao=vi.toString,sr=xn?xn.toStringTag:void 0;function wo(u){var e=Mo.call(u,sr),t=u[sr];try{u[sr]=void 0;var r=!0;}catch(_unused18){}var n=Ao.call(u);return r&&(e?u[sr]=t:delete u[sr]),n;}var Lo=wo,Ro=Object.prototype,Do=Ro.toString;function bo(u){return Do.call(u);}var No=bo,Tn=ur,Bo=Lo,Wo=No,Fo="[object Null]",Uo="[object Undefined]",Cn=Tn?Tn.toStringTag:void 0;function jo(u){return u==null?u===void 0?Uo:Fo:Cn&&Cn in Object(u)?Bo(u):Wo(u);}var qe=jo;function Yo(u){return u!=null&&_typeof(u)=="object";}var Le=Yo,Xo=qe,zo=Le,$o="[object Number]";function Go(u){return typeof u=="number"||zo(u)&&Xo(u)==$o;}var ko=Go,he=/* @__PURE__ */Ne(ko);function Ho(){this.__data__=[],this.size=0;}var Vo=Ho;function Ko(u,e){return u===e||u!==u&&e!==e;}var qr=Ko,Zo=qr;function Jo(u,e){for(var t=u.length;t--;)if(Zo(u[t][0],e))return t;return-1;}var Rr=Jo,Qo=Rr,qo=Array.prototype,_o=qo.splice;function ta(u){var e=this.__data__,t=Qo(e,u);if(t<0)return!1;var r=e.length-1;return t==r?e.pop():_o.call(e,t,1),--this.size,!0;}var ea=ta,ra=Rr;function na(u){var e=this.__data__,t=ra(e,u);return t<0?void 0:e[t][1];}var ia=na,sa=Rr;function oa(u){return sa(this.__data__,u)>-1;}var aa=oa,la=Rr;function ca(u,e){var t=this.__data__,r=la(t,u);return r<0?(++this.size,t.push([u,e])):t[r][1]=e,this;}var fa=ca,ha=Vo,ua=ea,da=ia,pa=aa,ma=fa;function _e(u){var e=-1,t=u==null?0:u.length;for(this.clear();++e<t;){var r=u[e];this.set(r[0],r[1]);}}_e.prototype.clear=ha;_e.prototype["delete"]=ua;_e.prototype.get=da;_e.prototype.has=pa;_e.prototype.set=ma;var Dr=_e,va=Dr;function ya(){this.__data__=new va(),this.size=0;}var ga=ya;function Pa(u){var e=this.__data__,t=e["delete"](u);return this.size=e.size,t;}var Sa=Pa;function xa(u){return this.__data__.get(u);}var Ta=xa;function Ca(u){return this.__data__.has(u);}var Ia=Ca;function Oa(u){var e=_typeof(u);return u!=null&&(e=="object"||e=="function");}var dr=Oa,Ea=qe,Ma=dr,Aa="[object AsyncFunction]",wa="[object Function]",La="[object GeneratorFunction]",Ra="[object Proxy]";function Da(u){if(!Ma(u))return!1;var e=Ea(u);return e==wa||e==La||e==Aa||e==Ra;}var yi=Da,ba=Ae,Na=ba["__core-js_shared__"],Ba=Na,jr=Ba,In=function(){var u=/[^.]+$/.exec(jr&&jr.keys&&jr.keys.IE_PROTO||"");return u?"Symbol(src)_1."+u:"";}();function Wa(u){return!!In&&In in u;}var Fa=Wa,Ua=Function.prototype,ja=Ua.toString;function Ya(u){if(u!=null){try{return ja.call(u);}catch(_unused19){}try{return u+"";}catch(_unused20){}}return"";}var gi=Ya,Xa=yi,za=Fa,$a=dr,Ga=gi,ka=/[\\^$.*+?()[\]{}|]/g,Ha=/^\[object .+?Constructor\]$/,Va=Function.prototype,Ka=Object.prototype,Za=Va.toString,Ja=Ka.hasOwnProperty,Qa=RegExp("^"+Za.call(Ja).replace(ka,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function qa(u){if(!$a(u)||za(u))return!1;var e=Xa(u)?Qa:Ha;return e.test(Ga(u));}var _a=qa;function tl(u,e){return u==null?void 0:u[e];}var el=tl,rl=_a,nl=el;function il(u,e){var t=nl(u,e);return rl(t)?t:void 0;}var Ue=il,sl=Ue,ol=Ae,al=sl(ol,"Map"),_r=al,ll=Ue,cl=ll(Object,"create"),br=cl,On=br;function fl(){this.__data__=On?On(null):{},this.size=0;}var hl=fl;function ul(u){var e=this.has(u)&&delete this.__data__[u];return this.size-=e?1:0,e;}var dl=ul,pl=br,ml="__lodash_hash_undefined__",vl=Object.prototype,yl=vl.hasOwnProperty;function gl(u){var e=this.__data__;if(pl){var t=e[u];return t===ml?void 0:t;}return yl.call(e,u)?e[u]:void 0;}var Pl=gl,Sl=br,xl=Object.prototype,Tl=xl.hasOwnProperty;function Cl(u){var e=this.__data__;return Sl?e[u]!==void 0:Tl.call(e,u);}var Il=Cl,Ol=br,El="__lodash_hash_undefined__";function Ml(u,e){var t=this.__data__;return this.size+=this.has(u)?0:1,t[u]=Ol&&e===void 0?El:e,this;}var Al=Ml,wl=hl,Ll=dl,Rl=Pl,Dl=Il,bl=Al;function tr(u){var e=-1,t=u==null?0:u.length;for(this.clear();++e<t;){var r=u[e];this.set(r[0],r[1]);}}tr.prototype.clear=wl;tr.prototype["delete"]=Ll;tr.prototype.get=Rl;tr.prototype.has=Dl;tr.prototype.set=bl;var Nl=tr,En=Nl,Bl=Dr,Wl=_r;function Fl(){this.size=0,this.__data__={hash:new En(),map:new(Wl||Bl)(),string:new En()};}var Ul=Fl;function jl(u){var e=_typeof(u);return e=="string"||e=="number"||e=="symbol"||e=="boolean"?u!=="__proto__":u===null;}var Yl=jl,Xl=Yl;function zl(u,e){var t=u.__data__;return Xl(e)?t[typeof e=="string"?"string":"hash"]:t.map;}var Nr=zl,$l=Nr;function Gl(u){var e=$l(this,u)["delete"](u);return this.size-=e?1:0,e;}var kl=Gl,Hl=Nr;function Vl(u){return Hl(this,u).get(u);}var Kl=Vl,Zl=Nr;function Jl(u){return Zl(this,u).has(u);}var Ql=Jl,ql=Nr;function _l(u,e){var t=ql(this,u),r=t.size;return t.set(u,e),this.size+=t.size==r?0:1,this;}var tc=_l,ec=Ul,rc=kl,nc=Kl,ic=Ql,sc=tc;function er(u){var e=-1,t=u==null?0:u.length;for(this.clear();++e<t;){var r=u[e];this.set(r[0],r[1]);}}er.prototype.clear=ec;er.prototype["delete"]=rc;er.prototype.get=nc;er.prototype.has=ic;er.prototype.set=sc;var Pi=er,oc=Dr,ac=_r,lc=Pi,cc=200;function fc(u,e){var t=this.__data__;if(t instanceof oc){var r=t.__data__;if(!ac||r.length<cc-1)return r.push([u,e]),this.size=++t.size,this;t=this.__data__=new lc(r);}return t.set(u,e),this.size=t.size,this;}var hc=fc,uc=Dr,dc=ga,pc=Sa,mc=Ta,vc=Ia,yc=hc;function rr(u){var e=this.__data__=new uc(u);this.size=e.size;}rr.prototype.clear=dc;rr.prototype["delete"]=pc;rr.prototype.get=mc;rr.prototype.has=vc;rr.prototype.set=yc;var Si=rr;function gc(u,e){for(var t=-1,r=u==null?0:u.length;++t<r&&e(u[t],t,u)!==!1;);return u;}var Pc=gc,Sc=Ue,xc=function(){try{var u=Sc(Object,"defineProperty");return u({},"",{}),u;}catch(_unused21){}}(),xi=xc,Mn=xi;function Tc(u,e,t){e=="__proto__"&&Mn?Mn(u,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):u[e]=t;}var Ti=Tc,Cc=Ti,Ic=qr,Oc=Object.prototype,Ec=Oc.hasOwnProperty;function Mc(u,e,t){var r=u[e];(!(Ec.call(u,e)&&Ic(r,t))||t===void 0&&!(e in u))&&Cc(u,e,t);}var Ci=Mc,Ac=Ci,wc=Ti;function Lc(u,e,t,r){var n=!t;t||(t={});for(var i=-1,l=e.length;++i<l;){var o=e[i],a=r?r(t[o],u[o],o,t,u):void 0;a===void 0&&(a=u[o]),n?wc(t,o,a):Ac(t,o,a);}return t;}var Br=Lc;function Rc(u,e){for(var t=-1,r=Array(u);++t<u;)r[t]=e(t);return r;}var Dc=Rc,bc=qe,Nc=Le,Bc="[object Arguments]";function Wc(u){return Nc(u)&&bc(u)==Bc;}var Fc=Wc,An=Fc,Uc=Le,Ii=Object.prototype,jc=Ii.hasOwnProperty,Yc=Ii.propertyIsEnumerable,Xc=An(/* @__PURE__ */function(){return arguments;}())?An:function(u){return Uc(u)&&jc.call(u,"callee")&&!Yc.call(u,"callee");},Oi=Xc,zc=Array.isArray,pr=zc,Sr={exports:{}};function $c(){return!1;}var Gc=$c;Sr.exports;(function(u,e){var t=Ae,r=Gc,n=e&&!e.nodeType&&e,i=n&&!0&&u&&!u.nodeType&&u,l=i&&i.exports===n,o=l?t.Buffer:void 0,a=o?o.isBuffer:void 0,c=a||r;u.exports=c;})(Sr,Sr.exports);var tn=Sr.exports,kc=9007199254740991,Hc=/^(?:0|[1-9]\d*)$/;function Vc(u,e){var _e2;var t=_typeof(u);return e=(_e2=e)!==null&&_e2!==void 0?_e2:kc,!!e&&(t=="number"||t!="symbol"&&Hc.test(u))&&u>-1&&u%1==0&&u<e;}var Kc=Vc,Zc=9007199254740991;function Jc(u){return typeof u=="number"&&u>-1&&u%1==0&&u<=Zc;}var Ei=Jc,Qc=qe,qc=Ei,_c=Le,tf="[object Arguments]",ef="[object Array]",rf="[object Boolean]",nf="[object Date]",sf="[object Error]",of="[object Function]",af="[object Map]",lf="[object Number]",cf="[object Object]",ff="[object RegExp]",hf="[object Set]",uf="[object String]",df="[object WeakMap]",pf="[object ArrayBuffer]",mf="[object DataView]",vf="[object Float32Array]",yf="[object Float64Array]",gf="[object Int8Array]",Pf="[object Int16Array]",Sf="[object Int32Array]",xf="[object Uint8Array]",Tf="[object Uint8ClampedArray]",Cf="[object Uint16Array]",If="[object Uint32Array]",ne={};ne[vf]=ne[yf]=ne[gf]=ne[Pf]=ne[Sf]=ne[xf]=ne[Tf]=ne[Cf]=ne[If]=!0;ne[tf]=ne[ef]=ne[pf]=ne[rf]=ne[mf]=ne[nf]=ne[sf]=ne[of]=ne[af]=ne[lf]=ne[cf]=ne[ff]=ne[hf]=ne[uf]=ne[df]=!1;function Of(u){return _c(u)&&qc(u.length)&&!!ne[Qc(u)];}var Ef=Of;function Mf(u){return function(e){return u(e);};}var Wr=Mf,xr={exports:{}};xr.exports;(function(u,e){var t=mi,r=e&&!e.nodeType&&e,n=r&&!0&&u&&!u.nodeType&&u,i=n&&n.exports===r,l=i&&t.process,o=function(){try{var a=n&&n.require&&n.require("util").types;return a||l&&l.binding&&l.binding("util");}catch(_unused22){}}();u.exports=o;})(xr,xr.exports);var en=xr.exports,Af=Ef,wf=Wr,wn=en,Ln=wn&&wn.isTypedArray,Lf=Ln?wf(Ln):Af,Mi=Lf,Rf=Dc,Df=Oi,bf=pr,Nf=tn,Bf=Kc,Wf=Mi,Ff=Object.prototype,Uf=Ff.hasOwnProperty;function jf(u,e){var t=bf(u),r=!t&&Df(u),n=!t&&!r&&Nf(u),i=!t&&!r&&!n&&Wf(u),l=t||r||n||i,o=l?Rf(u.length,String):[],a=o.length;for(var c in u)(e||Uf.call(u,c))&&!(l&&(// Safari 9 has enumerable `arguments.length` in strict mode.
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
- Bf(c,a)))&&o.push(c);return o;}var Ai=jf,Yf=Object.prototype;function Xf(u){var e=u&&u.constructor,t=typeof e=="function"&&e.prototype||Yf;return u===t;}var rn=Xf;function zf(u,e){return function(t){return u(e(t));};}var wi=zf,$f=wi,Gf=$f(Object.keys,Object),kf=Gf,Hf=rn,Vf=kf,Kf=Object.prototype,Zf=Kf.hasOwnProperty;function Jf(u){if(!Hf(u))return Vf(u);var e=[];for(var t in Object(u))Zf.call(u,t)&&t!="constructor"&&e.push(t);return e;}var Qf=Jf,qf=yi,_f=Ei;function th(u){return u!=null&&_f(u.length)&&!qf(u);}var nn=th,eh=Ai,rh=Qf,nh=nn;function ih(u){return nh(u)?eh(u):rh(u);}var sn=ih,sh=Br,oh=sn;function ah(u,e){return u&&sh(e,oh(e),u);}var lh=ah;function ch(u){var e=[];if(u!=null)for(var t in Object(u))e.push(t);return e;}var fh=ch,hh=dr,uh=rn,dh=fh,ph=Object.prototype,mh=ph.hasOwnProperty;function vh(u){if(!hh(u))return dh(u);var e=uh(u),t=[];for(var r in u)r=="constructor"&&(e||!mh.call(u,r))||t.push(r);return t;}var yh=vh,gh=Ai,Ph=yh,Sh=nn;function xh(u){return Sh(u)?gh(u,!0):Ph(u);}var on=xh,Th=Br,Ch=on;function Ih(u,e){return u&&Th(e,Ch(e),u);}var Oh=Ih,Tr={exports:{}};Tr.exports;(function(u,e){var t=Ae,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,m){if(m)return c.slice();var f=c.length,v=o?o(f):new c.constructor(f);return c.copy(v),v;}u.exports=a;})(Tr,Tr.exports);var Eh=Tr.exports;function Mh(u,e){var t=-1,r=u.length;for(e||(e=Array(r));++t<r;)e[t]=u[t];return e;}var Ah=Mh;function wh(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 Li=wh;function Lh(){return[];}var Ri=Lh,Rh=Li,Dh=Ri,bh=Object.prototype,Nh=bh.propertyIsEnumerable,Rn=Object.getOwnPropertySymbols,Bh=Rn?function(u){return u==null?[]:(u=Object(u),Rh(Rn(u),function(e){return Nh.call(u,e);}));}:Dh,an=Bh,Wh=Br,Fh=an;function Uh(u,e){return Wh(u,Fh(u),e);}var jh=Uh;function Yh(u,e){for(var t=-1,r=e.length,n=u.length;++t<r;)u[n+t]=e[t];return u;}var ln=Yh,Xh=wi,zh=Xh(Object.getPrototypeOf,Object),Di=zh,$h=ln,Gh=Di,kh=an,Hh=Ri,Vh=Object.getOwnPropertySymbols,Kh=Vh?function(u){for(var e=[];u;)$h(e,kh(u)),u=Gh(u);return e;}:Hh,bi=Kh,Zh=Br,Jh=bi;function Qh(u,e){return Zh(u,Jh(u),e);}var qh=Qh,_h=ln,tu=pr;function eu(u,e,t){var r=e(u);return tu(u)?r:_h(r,t(u));}var Ni=eu,ru=Ni,nu=an,iu=sn;function su(u){return ru(u,iu,nu);}var Bi=su,ou=Ni,au=bi,lu=on;function cu(u){return ou(u,lu,au);}var fu=cu,hu=Ue,uu=Ae,du=hu(uu,"DataView"),pu=du,mu=Ue,vu=Ae,yu=mu(vu,"Promise"),gu=yu,Pu=Ue,Su=Ae,xu=Pu(Su,"Set"),Wi=xu,Tu=Ue,Cu=Ae,Iu=Tu(Cu,"WeakMap"),Ou=Iu,Gr=pu,kr=_r,Hr=gu,Vr=Wi,Kr=Ou,Fi=qe,nr=gi,Dn="[object Map]",Eu="[object Object]",bn="[object Promise]",Nn="[object Set]",Bn="[object WeakMap]",Wn="[object DataView]",Mu=nr(Gr),Au=nr(kr),wu=nr(Hr),Lu=nr(Vr),Ru=nr(Kr),Fe=Fi;(Gr&&Fe(new Gr(new ArrayBuffer(1)))!=Wn||kr&&Fe(new kr())!=Dn||Hr&&Fe(Hr.resolve())!=bn||Vr&&Fe(new Vr())!=Nn||Kr&&Fe(new Kr())!=Bn)&&(Fe=function Fe(u){var e=Fi(u),t=e==Eu?u.constructor:void 0,r=t?nr(t):"";if(r)switch(r){case Mu:return Wn;case Au:return Dn;case wu:return bn;case Lu:return Nn;case Ru:return Bn;}return e;});var Fr=Fe,Du=Object.prototype,bu=Du.hasOwnProperty;function Nu(u){var e=u.length,t=new u.constructor(e);return e&&typeof u[0]=="string"&&bu.call(u,"index")&&(t.index=u.index,t.input=u.input),t;}var Bu=Nu,Wu=Ae,Fu=Wu.Uint8Array,Ui=Fu,Fn=Ui;function Uu(u){var e=new u.constructor(u.byteLength);return new Fn(e).set(new Fn(u)),e;}var cn=Uu,ju=cn;function Yu(u,e){var t=e?ju(u.buffer):u.buffer;return new u.constructor(t,u.byteOffset,u.byteLength);}var Xu=Yu,zu=/\w*$/;function $u(u){var e=new u.constructor(u.source,zu.exec(u));return e.lastIndex=u.lastIndex,e;}var Gu=$u,Un=ur,jn=Un?Un.prototype:void 0,Yn=jn?jn.valueOf:void 0;function ku(u){return Yn?Object(Yn.call(u)):{};}var Hu=ku,Vu=cn;function Ku(u,e){var t=e?Vu(u.buffer):u.buffer;return new u.constructor(t,u.byteOffset,u.length);}var Zu=Ku,Ju=cn,Qu=Xu,qu=Gu,_u=Hu,td=Zu,ed="[object Boolean]",rd="[object Date]",nd="[object Map]",id="[object Number]",sd="[object RegExp]",od="[object Set]",ad="[object String]",ld="[object Symbol]",cd="[object ArrayBuffer]",fd="[object DataView]",hd="[object Float32Array]",ud="[object Float64Array]",dd="[object Int8Array]",pd="[object Int16Array]",md="[object Int32Array]",vd="[object Uint8Array]",yd="[object Uint8ClampedArray]",gd="[object Uint16Array]",Pd="[object Uint32Array]";function Sd(u,e,t){var r=u.constructor;switch(e){case cd:return Ju(u);case ed:case rd:return new r(+u);case fd:return Qu(u,t);case hd:case ud:case dd:case pd:case md:case vd:case yd:case gd:case Pd:return td(u,t);case nd:return new r();case id:case ad:return new r(u);case sd:return qu(u);case od:return new r();case ld:return _u(u);}}var xd=Sd,Td=dr,Xn=Object.create,Cd=/* @__PURE__ */function(){function u(){}return function(e){if(!Td(e))return{};if(Xn)return Xn(e);u.prototype=e;var t=new u();return u.prototype=void 0,t;};}(),Id=Cd,Od=Id,Ed=Di,Md=rn;function Ad(u){return typeof u.constructor=="function"&&!Md(u)?Od(Ed(u)):{};}var wd=Ad,Ld=Fr,Rd=Le,Dd="[object Map]";function bd(u){return Rd(u)&&Ld(u)==Dd;}var Nd=bd,Bd=Nd,Wd=Wr,zn=en,$n=zn&&zn.isMap,Fd=$n?Wd($n):Bd,Ud=Fd,jd=Fr,Yd=Le,Xd="[object Set]";function zd(u){return Yd(u)&&jd(u)==Xd;}var $d=zd,Gd=$d,kd=Wr,Gn=en,kn=Gn&&Gn.isSet,Hd=kn?kd(kn):Gd,ji=Hd,Vd=/* @__PURE__ */Ne(ji),Kd=Si,Zd=Pc,Jd=Ci,Qd=lh,qd=Oh,_d=Eh,tp=Ah,ep=jh,rp=qh,np=Bi,ip=fu,sp=Fr,op=Bu,ap=xd,lp=wd,cp=pr,fp=tn,hp=Ud,up=dr,dp=ji,pp=sn,mp=on,vp=1,yp=2,gp=4,Yi="[object Arguments]",Pp="[object Array]",Sp="[object Boolean]",xp="[object Date]",Tp="[object Error]",Xi="[object Function]",Cp="[object GeneratorFunction]",Ip="[object Map]",Op="[object Number]",zi="[object Object]",Ep="[object RegExp]",Mp="[object Set]",Ap="[object String]",wp="[object Symbol]",Lp="[object WeakMap]",Rp="[object ArrayBuffer]",Dp="[object DataView]",bp="[object Float32Array]",Np="[object Float64Array]",Bp="[object Int8Array]",Wp="[object Int16Array]",Fp="[object Int32Array]",Up="[object Uint8Array]",jp="[object Uint8ClampedArray]",Yp="[object Uint16Array]",Xp="[object Uint32Array]",re={};re[Yi]=re[Pp]=re[Rp]=re[Dp]=re[Sp]=re[xp]=re[bp]=re[Np]=re[Bp]=re[Wp]=re[Fp]=re[Ip]=re[Op]=re[zi]=re[Ep]=re[Mp]=re[Ap]=re[wp]=re[Up]=re[jp]=re[Yp]=re[Xp]=!0;re[Tp]=re[Xi]=re[Lp]=!1;function Pr(u,e,t,r,n,i){var l,o=e&vp,a=e&yp,c=e&gp;if(t&&(l=n?t(u,r,n,i):t(u)),l!==void 0)return l;if(!up(u))return u;var m=cp(u);if(m){if(l=op(u),!o)return tp(u,l);}else{var f=sp(u),v=f==Xi||f==Cp;if(fp(u))return _d(u,o);if(f==zi||f==Yi||v&&!n){if(l=a||v?{}:lp(u),!o)return a?rp(u,qd(l,u)):ep(u,Qd(l,u));}else{if(!re[f])return n?u:{};l=ap(u,f,o);}}i||(i=new Kd());var S=i.get(u);if(S)return S;i.set(u,l),dp(u)?u.forEach(function(P){l.add(Pr(P,e,t,P,u,i));}):hp(u)&&u.forEach(function(P,x){l.set(x,Pr(P,e,t,x,u,i));});var E=c?a?ip:np:a?mp:pp,T=m?void 0:E(u);return Zd(T||u,function(P,x){T&&(x=P,P=u[x]),Jd(l,x,Pr(P,e,t,x,u,i));}),l;}var zp=Pr,$p=zp,Gp=1,kp=4;function Hp(u){return $p(u,Gp|kp);}var Vp=Hp,he=/* @__PURE__ */Ne(Vp);var $i="1.1.22-beta.4",Kp="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var u=window.__netlessUA||"";u+=" ".concat(Kp,"@").concat($i),window.__netlessUA=u;}var me={useWorker:"auto",useSimple:!1,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 Te=/*#__PURE__*/function(){function Te(e){_classCallCheck(this,Te);ot(this,"maxImageWidth",me.pencilEraser.maxImageWidth);ot(this,"maxImageHeight",me.pencilEraser.maxImageHeight);ot(this,"syncUnitTime",me.syncOpt.interval);ot(this,"vNodes");ot(this,"drawLayer");ot(this,"fullLayer");ot(this,"workId");ot(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(Te,[{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,m=e.scale,f=e.angle,v=e.translate,S={};ue(c)&&(S.zIndex=c),a&&(S.pos=[a[0],a[1]]),m&&(S.scale=m),f&&(S.rotate=f),v&&(S.translate=v),o.attr(S);var E=o==null?void 0:o.getBoundingClientRect();return E&&(t=bt(t,{x:Math.floor(E.x-Te.SafeBorderPadding),y:Math.floor(E.y-Te.SafeBorderPadding),w:Math.floor(E.width+Te.SafeBorderPadding*2),h:Math.floor(E.height+Te.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,m=r.getBoundingClientRect(),f=m.width*c*l.worldScaling[0],v=m.height*c*l.worldScaling[1];var S=1;(f>this.maxImageWidth||v>this.maxImageHeight)&&(S=Math.min(this.maxImageWidth/f,this.maxImageHeight/v));var E=l.getAttribute("scale");E=[E[0]*S,E[1]*S];var T=l.parent.parent,P=l.getAttribute("translate"),_x53=this.createVmRenderNode("".concat(this.workId,"_bitMapLayer"),T,{offscreen:o.offscreen,width:o.width,height:o.height,contextType:"2d",autoRender:!1,bufferSize:500},E,P),_h28=r.cloneNode(!0);if(!n||!n.length)return;this.addEraserlines(_h28,n,i,!1),_x53.appendChild(_h28);var p=_x53.parent;p.render();var d=_x53.renderer.canvasRenderer,g=d.context;if(!g)return;var O=d.options.displayRatio,w=_h28.getBoundingClientRect(),L={x:w.x,y:w.y,w:w.width,h:w.height},B={x:0,y:0,w:T.width,h:T.height};if(or(L,B)===Pe.outside){Se(_h28,p),T.removeChild(p),this.isDelete=!0;return;}var b=he(L);b.x=Math.floor(Math.max(L.x,0)),b.y=Math.floor(Math.max(L.y,0)),b.w=Math.min(L.x+L.w,T.width)-b.x,b.h=Math.min(L.y+L.h,T.height)-b.y;var W=this.getGroupRect(b,O),D=W.x,R=W.y,X=W.w,H=W.h;var J=g.getImageData(D,R,X,H);if(this.isTransparentRectByCanvas(J)){Se(_h28,p),T.removeChild(p),this.isDelete=!0,J=null;return;}Se(r,o);var it=this.createSpriteNode({imageData:J,safariRect:b,originRect:L,worldScaling:_x53.worldScaling});it&&r.append(it),Se(_h28,p),T.removeChild(p),o.deleteTexture(J),J=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),m=new ye({anchor:[0.5,0.5],pos:[l*0.5,o*0.5],size:[l,o],name:"viewport",id:e});return m.setAttribute("scale",n),m.setAttribute("translate",i),c.append(m),m;}},{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(E,T){return T%2?E-r[1]:E-r[0];}),m=this.computEraserPoints(c,l),f=De(m,!0),v={pos:[0,0],d:f,fillColor:"rgba(0,0,0,1)"},S=new be(v);S.addEventListener("beforerender",function(_ref164){var E=_ref164.detail;var T=E.context;n?T.blendFuncSeparate(T.ZERO,T.ZERO,T.ZERO,T.ZERO):T.globalCompositeOperation="destination-out";}),S.addEventListener("afterrender",function(_ref165){var E=_ref165.detail;var T=E.context;n?T.blendFuncSeparate(T.SRC_ALPHA,T.ONE_MINUS_SRC_ALPHA,T.ONE,T.ONE_MINUS_SRC_ALPHA):T.globalCompositeOperation="source-over";}),e.append(S);}}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 m=l.getContext("2d");m&&m.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 _m4=l.getContext("2d");_m4&&_m4.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 di(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 Nt(e[0],e[1]);return Nt.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 Nt(e[o],e[o+1]);var c=void 0;if(o==e.length-2){var m=new Nt(e[o-2],e[o-1]);c=at.Sub(a,m).uni(),i=a;}else{o===0&&(l=a);var _m5=new Nt(e[o+2],e[o+3]);c=at.Sub(_m5,a).uni();}if(c){var _m6=at.Per(c).mul(t);r.push(Nt.Sub(a,_m6)),n.push(Nt.Add(a,_m6));}}if(i&&l){var _o3=Nt.GetSemicircleStroke(i,r[r.length-1],-1,8),_a4=Nt.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?Tm(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,m=r.originPoint,f=r.scenePoint,v=r.scale,S=r.pointMap,E=r.thickness;var T;var P=l&&he(l)||n.get(t.name);if(!P)return;ue(o)&&(t.setAttribute("zIndex",o),P.opt.zIndex=o);var x=t.parent;if(x){if(m&&v&&l){var p=[P.op[0],P.op[1]];vn(P.op,f,v,a);var d=[P.op[0],P.op[1]],g=[d[0]-p[0],d[1]-p[1]];if(P.centerPos=[P.centerPos[0]+g[0],P.centerPos[1]+g[1]],P.opt.translate=void 0,P.opt.scale=void 0,P.opt.eraserlines)for(var O=0;O<P.opt.eraserlines.length;O++){var _P$opt$eraserlines$O=P.opt.eraserlines[O],w=_P$opt$eraserlines$O.op,L=_P$opt$eraserlines$O.thickness;P.opt.eraserlines[O].thickness=Math.round(L*Math.max(v[0],v[1]));for(var B=0;B<w.length;B++)yn(w[B],f,v,a);}}else if(a){if(t.setAttribute("translate",a),P.opt.translate=a,l){var _p6=[a[0]*x.worldScaling[0],a[1]*x.worldScaling[1]];T=fr(P.rect,_p6),P.rect=T;}else{var _p7=Te.getRectFromLayer(x,t.name);P.rect=_p7||P.rect;}}else if(ue(c))if(t.setAttribute("rotate",c),P.opt.rotate=c,l)T=os(P.rect,c),P.rect=T;else{var _p8=Te.getRectFromLayer(x,t.name);P.rect=_p8||P.rect;}if(S){var _p9=S.get(t.name);if(_p9)for(var _d11=0,_g9=0;_d11<P.op.length;_d11+=3,_g9++)P.op[_d11]=_p9[_g9][0],P.op[_d11+1]=_p9[_g9][1];}if(E&&(h=P==null?void 0:P.opt)!=null&&h.thickness&&(P.opt.thickness=E),i&&!(m&&v&&l)){if(a){var _p10=P.op.map(function(d,g){var O=g%3;return O===0?d+a[0]:O===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 _g10=P.opt.eraserlines[_d12].op;for(var _O6=0;_O6<_g10.length;_O6++){var _w3=_g10[_O6].map(function(L,B){return B%2?L+a[1]:L+a[0];});P.opt.eraserlines[_d12].op[_O6]=_w3;}}}else if(ue(c)){var _p11=P.op;if(pm(_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 _g11=P.opt.eraserlines[_d13].op;for(var _O7=0;_O7<_g11.length;_O7++)mm(_g11[_O7],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-Te.SafeBorderPadding),y:Math.floor(n.y-Te.SafeBorderPadding),w:Math.floor(n.width+Te.SafeBorderPadding*2),h:Math.floor(n.height+Te.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===pt.Text&&(i.fontSize||i.translate||i.textInfos&&i.textInfos.get(n.name))||t===pt.Image&&(i.angle||i.translate||i.scale||i.strokeColor&&i.type===Qr.Iconify)||t===i.toolsType&&i.willRefresh||r.eraserlines&&r.eraserlines.length&&(i.strokeColor||i.fillColor));}}]);}();ot(Te,"SafeBorderPadding",10);var At=Te;var fn=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 hn={exports:{}};hn.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 m=0;m<a.length;m++)i[a][a.charAt(m)]=m;}return i[a][c];}var o={compressToBase64:function compressToBase64(a){if(a==null)return"";var c=o._compress(a,6,function(m){return r.charAt(m);});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
+ Bf(c,a)))&&o.push(c);return o;}var Ai=jf,Yf=Object.prototype;function Xf(u){var e=u&&u.constructor,t=typeof e=="function"&&e.prototype||Yf;return u===t;}var rn=Xf;function zf(u,e){return function(t){return u(e(t));};}var wi=zf,$f=wi,Gf=$f(Object.keys,Object),kf=Gf,Hf=rn,Vf=kf,Kf=Object.prototype,Zf=Kf.hasOwnProperty;function Jf(u){if(!Hf(u))return Vf(u);var e=[];for(var t in Object(u))Zf.call(u,t)&&t!="constructor"&&e.push(t);return e;}var Qf=Jf,qf=yi,_f=Ei;function th(u){return u!=null&&_f(u.length)&&!qf(u);}var nn=th,eh=Ai,rh=Qf,nh=nn;function ih(u){return nh(u)?eh(u):rh(u);}var sn=ih,sh=Br,oh=sn;function ah(u,e){return u&&sh(e,oh(e),u);}var lh=ah;function ch(u){var e=[];if(u!=null)for(var t in Object(u))e.push(t);return e;}var fh=ch,hh=dr,uh=rn,dh=fh,ph=Object.prototype,mh=ph.hasOwnProperty;function vh(u){if(!hh(u))return dh(u);var e=uh(u),t=[];for(var r in u)r=="constructor"&&(e||!mh.call(u,r))||t.push(r);return t;}var yh=vh,gh=Ai,Ph=yh,Sh=nn;function xh(u){return Sh(u)?gh(u,!0):Ph(u);}var on=xh,Th=Br,Ch=on;function Ih(u,e){return u&&Th(e,Ch(e),u);}var Oh=Ih,Tr={exports:{}};Tr.exports;(function(u,e){var t=Ae,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,m){if(m)return c.slice();var f=c.length,v=o?o(f):new c.constructor(f);return c.copy(v),v;}u.exports=a;})(Tr,Tr.exports);var Eh=Tr.exports;function Mh(u,e){var t=-1,r=u.length;for(e||(e=Array(r));++t<r;)e[t]=u[t];return e;}var Ah=Mh;function wh(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 Li=wh;function Lh(){return[];}var Ri=Lh,Rh=Li,Dh=Ri,bh=Object.prototype,Nh=bh.propertyIsEnumerable,Rn=Object.getOwnPropertySymbols,Bh=Rn?function(u){return u==null?[]:(u=Object(u),Rh(Rn(u),function(e){return Nh.call(u,e);}));}:Dh,an=Bh,Wh=Br,Fh=an;function Uh(u,e){return Wh(u,Fh(u),e);}var jh=Uh;function Yh(u,e){for(var t=-1,r=e.length,n=u.length;++t<r;)u[n+t]=e[t];return u;}var ln=Yh,Xh=wi,zh=Xh(Object.getPrototypeOf,Object),Di=zh,$h=ln,Gh=Di,kh=an,Hh=Ri,Vh=Object.getOwnPropertySymbols,Kh=Vh?function(u){for(var e=[];u;)$h(e,kh(u)),u=Gh(u);return e;}:Hh,bi=Kh,Zh=Br,Jh=bi;function Qh(u,e){return Zh(u,Jh(u),e);}var qh=Qh,_h=ln,tu=pr;function eu(u,e,t){var r=e(u);return tu(u)?r:_h(r,t(u));}var Ni=eu,ru=Ni,nu=an,iu=sn;function su(u){return ru(u,iu,nu);}var Bi=su,ou=Ni,au=bi,lu=on;function cu(u){return ou(u,lu,au);}var fu=cu,hu=Ue,uu=Ae,du=hu(uu,"DataView"),pu=du,mu=Ue,vu=Ae,yu=mu(vu,"Promise"),gu=yu,Pu=Ue,Su=Ae,xu=Pu(Su,"Set"),Wi=xu,Tu=Ue,Cu=Ae,Iu=Tu(Cu,"WeakMap"),Ou=Iu,Gr=pu,kr=_r,Hr=gu,Vr=Wi,Kr=Ou,Fi=qe,nr=gi,Dn="[object Map]",Eu="[object Object]",bn="[object Promise]",Nn="[object Set]",Bn="[object WeakMap]",Wn="[object DataView]",Mu=nr(Gr),Au=nr(kr),wu=nr(Hr),Lu=nr(Vr),Ru=nr(Kr),Fe=Fi;(Gr&&Fe(new Gr(new ArrayBuffer(1)))!=Wn||kr&&Fe(new kr())!=Dn||Hr&&Fe(Hr.resolve())!=bn||Vr&&Fe(new Vr())!=Nn||Kr&&Fe(new Kr())!=Bn)&&(Fe=function Fe(u){var e=Fi(u),t=e==Eu?u.constructor:void 0,r=t?nr(t):"";if(r)switch(r){case Mu:return Wn;case Au:return Dn;case wu:return bn;case Lu:return Nn;case Ru:return Bn;}return e;});var Fr=Fe,Du=Object.prototype,bu=Du.hasOwnProperty;function Nu(u){var e=u.length,t=new u.constructor(e);return e&&typeof u[0]=="string"&&bu.call(u,"index")&&(t.index=u.index,t.input=u.input),t;}var Bu=Nu,Wu=Ae,Fu=Wu.Uint8Array,Ui=Fu,Fn=Ui;function Uu(u){var e=new u.constructor(u.byteLength);return new Fn(e).set(new Fn(u)),e;}var cn=Uu,ju=cn;function Yu(u,e){var t=e?ju(u.buffer):u.buffer;return new u.constructor(t,u.byteOffset,u.byteLength);}var Xu=Yu,zu=/\w*$/;function $u(u){var e=new u.constructor(u.source,zu.exec(u));return e.lastIndex=u.lastIndex,e;}var Gu=$u,Un=ur,jn=Un?Un.prototype:void 0,Yn=jn?jn.valueOf:void 0;function ku(u){return Yn?Object(Yn.call(u)):{};}var Hu=ku,Vu=cn;function Ku(u,e){var t=e?Vu(u.buffer):u.buffer;return new u.constructor(t,u.byteOffset,u.length);}var Zu=Ku,Ju=cn,Qu=Xu,qu=Gu,_u=Hu,td=Zu,ed="[object Boolean]",rd="[object Date]",nd="[object Map]",id="[object Number]",sd="[object RegExp]",od="[object Set]",ad="[object String]",ld="[object Symbol]",cd="[object ArrayBuffer]",fd="[object DataView]",hd="[object Float32Array]",ud="[object Float64Array]",dd="[object Int8Array]",pd="[object Int16Array]",md="[object Int32Array]",vd="[object Uint8Array]",yd="[object Uint8ClampedArray]",gd="[object Uint16Array]",Pd="[object Uint32Array]";function Sd(u,e,t){var r=u.constructor;switch(e){case cd:return Ju(u);case ed:case rd:return new r(+u);case fd:return Qu(u,t);case hd:case ud:case dd:case pd:case md:case vd:case yd:case gd:case Pd:return td(u,t);case nd:return new r();case id:case ad:return new r(u);case sd:return qu(u);case od:return new r();case ld:return _u(u);}}var xd=Sd,Td=dr,Xn=Object.create,Cd=/* @__PURE__ */function(){function u(){}return function(e){if(!Td(e))return{};if(Xn)return Xn(e);u.prototype=e;var t=new u();return u.prototype=void 0,t;};}(),Id=Cd,Od=Id,Ed=Di,Md=rn;function Ad(u){return typeof u.constructor=="function"&&!Md(u)?Od(Ed(u)):{};}var wd=Ad,Ld=Fr,Rd=Le,Dd="[object Map]";function bd(u){return Rd(u)&&Ld(u)==Dd;}var Nd=bd,Bd=Nd,Wd=Wr,zn=en,$n=zn&&zn.isMap,Fd=$n?Wd($n):Bd,Ud=Fd,jd=Fr,Yd=Le,Xd="[object Set]";function zd(u){return Yd(u)&&jd(u)==Xd;}var $d=zd,Gd=$d,kd=Wr,Gn=en,kn=Gn&&Gn.isSet,Hd=kn?kd(kn):Gd,ji=Hd,Vd=/* @__PURE__ */Ne(ji),Kd=Si,Zd=Pc,Jd=Ci,Qd=lh,qd=Oh,_d=Eh,tp=Ah,ep=jh,rp=qh,np=Bi,ip=fu,sp=Fr,op=Bu,ap=xd,lp=wd,cp=pr,fp=tn,hp=Ud,up=dr,dp=ji,pp=sn,mp=on,vp=1,yp=2,gp=4,Yi="[object Arguments]",Pp="[object Array]",Sp="[object Boolean]",xp="[object Date]",Tp="[object Error]",Xi="[object Function]",Cp="[object GeneratorFunction]",Ip="[object Map]",Op="[object Number]",zi="[object Object]",Ep="[object RegExp]",Mp="[object Set]",Ap="[object String]",wp="[object Symbol]",Lp="[object WeakMap]",Rp="[object ArrayBuffer]",Dp="[object DataView]",bp="[object Float32Array]",Np="[object Float64Array]",Bp="[object Int8Array]",Wp="[object Int16Array]",Fp="[object Int32Array]",Up="[object Uint8Array]",jp="[object Uint8ClampedArray]",Yp="[object Uint16Array]",Xp="[object Uint32Array]",re={};re[Yi]=re[Pp]=re[Rp]=re[Dp]=re[Sp]=re[xp]=re[bp]=re[Np]=re[Bp]=re[Wp]=re[Fp]=re[Ip]=re[Op]=re[zi]=re[Ep]=re[Mp]=re[Ap]=re[wp]=re[Up]=re[jp]=re[Yp]=re[Xp]=!0;re[Tp]=re[Xi]=re[Lp]=!1;function Pr(u,e,t,r,n,i){var l,o=e&vp,a=e&yp,c=e&gp;if(t&&(l=n?t(u,r,n,i):t(u)),l!==void 0)return l;if(!up(u))return u;var m=cp(u);if(m){if(l=op(u),!o)return tp(u,l);}else{var f=sp(u),v=f==Xi||f==Cp;if(fp(u))return _d(u,o);if(f==zi||f==Yi||v&&!n){if(l=a||v?{}:lp(u),!o)return a?rp(u,qd(l,u)):ep(u,Qd(l,u));}else{if(!re[f])return n?u:{};l=ap(u,f,o);}}i||(i=new Kd());var S=i.get(u);if(S)return S;i.set(u,l),dp(u)?u.forEach(function(P){l.add(Pr(P,e,t,P,u,i));}):hp(u)&&u.forEach(function(P,x){l.set(x,Pr(P,e,t,x,u,i));});var E=c?a?ip:np:a?mp:pp,T=m?void 0:E(u);return Zd(T||u,function(P,x){T&&(x=P,P=u[x]),Jd(l,x,Pr(P,e,t,x,u,i));}),l;}var zp=Pr,$p=zp,Gp=1,kp=4;function Hp(u){return $p(u,Gp|kp);}var Vp=Hp,ue=/* @__PURE__ */Ne(Vp);var $i="1.1.22-beta.6",Kp="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var u=window.__netlessUA||"";u+=" ".concat(Kp,"@").concat($i),window.__netlessUA=u;}var me={useWorker:"auto",useSimple:!1,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 Te=/*#__PURE__*/function(){function Te(e){_classCallCheck(this,Te);ot(this,"maxImageWidth",me.pencilEraser.maxImageWidth);ot(this,"maxImageHeight",me.pencilEraser.maxImageHeight);ot(this,"syncUnitTime",me.syncOpt.interval);ot(this,"vNodes");ot(this,"drawLayer");ot(this,"fullLayer");ot(this,"workId");ot(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(Te,[{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,m=e.scale,f=e.angle,v=e.translate,S={};he(c)&&(S.zIndex=c),a&&(S.pos=[a[0],a[1]]),m&&(S.scale=m),f&&(S.rotate=f),v&&(S.translate=v),o.attr(S);var E=o==null?void 0:o.getBoundingClientRect();return E&&(t=bt(t,{x:Math.floor(E.x-Te.SafeBorderPadding),y:Math.floor(E.y-Te.SafeBorderPadding),w:Math.floor(E.width+Te.SafeBorderPadding*2),h:Math.floor(E.height+Te.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,m=r.getBoundingClientRect(),f=m.width*c*l.worldScaling[0],v=m.height*c*l.worldScaling[1];var S=1;(f>this.maxImageWidth||v>this.maxImageHeight)&&(S=Math.min(this.maxImageWidth/f,this.maxImageHeight/v));var E=l.getAttribute("scale");E=[E[0]*S,E[1]*S];var T=l.parent.parent,P=l.getAttribute("translate"),_x53=this.createVmRenderNode("".concat(this.workId,"_bitMapLayer"),T,{offscreen:o.offscreen,width:o.width,height:o.height,contextType:"2d",autoRender:!1,bufferSize:500},E,P),_h28=r.cloneNode(!0);if(!n||!n.length)return;this.addEraserlines(_h28,n,i,!1),_x53.appendChild(_h28);var p=_x53.parent;p.render();var d=_x53.renderer.canvasRenderer,g=d.context;if(!g)return;var O=d.options.displayRatio,w=_h28.getBoundingClientRect(),L={x:w.x,y:w.y,w:w.width,h:w.height},B={x:0,y:0,w:T.width,h:T.height};if(or(L,B)===Pe.outside){Se(_h28,p),T.removeChild(p),this.isDelete=!0;return;}var b=ue(L);b.x=Math.floor(Math.max(L.x,0)),b.y=Math.floor(Math.max(L.y,0)),b.w=Math.min(L.x+L.w,T.width)-b.x,b.h=Math.min(L.y+L.h,T.height)-b.y;var W=this.getGroupRect(b,O),D=W.x,R=W.y,X=W.w,H=W.h;var J=g.getImageData(D,R,X,H);if(this.isTransparentRectByCanvas(J)){Se(_h28,p),T.removeChild(p),this.isDelete=!0,J=null;return;}Se(r,o);var it=this.createSpriteNode({imageData:J,safariRect:b,originRect:L,worldScaling:_x53.worldScaling});it&&r.append(it),Se(_h28,p),T.removeChild(p),o.deleteTexture(J),J=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),m=new ye({anchor:[0.5,0.5],pos:[l*0.5,o*0.5],size:[l,o],name:"viewport",id:e});return m.setAttribute("scale",n),m.setAttribute("translate",i),c.append(m),m;}},{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(E,T){return T%2?E-r[1]:E-r[0];}),m=this.computEraserPoints(c,l),f=De(m,!0),v={pos:[0,0],d:f,fillColor:"rgba(0,0,0,1)"},S=new be(v);S.addEventListener("beforerender",function(_ref164){var E=_ref164.detail;var T=E.context;n?T.blendFuncSeparate(T.ZERO,T.ZERO,T.ZERO,T.ZERO):T.globalCompositeOperation="destination-out";}),S.addEventListener("afterrender",function(_ref165){var E=_ref165.detail;var T=E.context;n?T.blendFuncSeparate(T.SRC_ALPHA,T.ONE_MINUS_SRC_ALPHA,T.ONE,T.ONE_MINUS_SRC_ALPHA):T.globalCompositeOperation="source-over";}),e.append(S);}}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 m=l.getContext("2d");m&&m.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 _m4=l.getContext("2d");_m4&&_m4.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 di(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 Nt(e[0],e[1]);return Nt.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 Nt(e[o],e[o+1]);var c=void 0;if(o==e.length-2){var m=new Nt(e[o-2],e[o-1]);c=at.Sub(a,m).uni(),i=a;}else{o===0&&(l=a);var _m5=new Nt(e[o+2],e[o+3]);c=at.Sub(_m5,a).uni();}if(c){var _m6=at.Per(c).mul(t);r.push(Nt.Sub(a,_m6)),n.push(Nt.Add(a,_m6));}}if(i&&l){var _o3=Nt.GetSemicircleStroke(i,r[r.length-1],-1,8),_a4=Nt.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?Tm(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,m=r.originPoint,f=r.scenePoint,v=r.scale,S=r.pointMap,E=r.thickness;var T;var P=l&&ue(l)||n.get(t.name);if(!P)return;he(o)&&(t.setAttribute("zIndex",o),P.opt.zIndex=o);var x=t.parent;if(x){if(m&&v&&l){var p=[P.op[0],P.op[1]];vn(P.op,f,v,a);var d=[P.op[0],P.op[1]],g=[d[0]-p[0],d[1]-p[1]];if(P.centerPos=[P.centerPos[0]+g[0],P.centerPos[1]+g[1]],P.opt.translate=void 0,P.opt.scale=void 0,P.opt.eraserlines)for(var O=0;O<P.opt.eraserlines.length;O++){var _P$opt$eraserlines$O=P.opt.eraserlines[O],w=_P$opt$eraserlines$O.op,L=_P$opt$eraserlines$O.thickness;P.opt.eraserlines[O].thickness=Math.round(L*Math.max(v[0],v[1]));for(var B=0;B<w.length;B++)yn(w[B],f,v,a);}}else if(a){if(t.setAttribute("translate",a),P.opt.translate=a,l){var _p6=[a[0]*x.worldScaling[0],a[1]*x.worldScaling[1]];T=fr(P.rect,_p6),P.rect=T;}else{var _p7=Te.getRectFromLayer(x,t.name);P.rect=_p7||P.rect;}}else if(he(c))if(t.setAttribute("rotate",c),P.opt.rotate=c,l)T=os(P.rect,c),P.rect=T;else{var _p8=Te.getRectFromLayer(x,t.name);P.rect=_p8||P.rect;}if(S){var _p9=S.get(t.name);if(_p9)for(var _d11=0,_g9=0;_d11<P.op.length;_d11+=3,_g9++)P.op[_d11]=_p9[_g9][0],P.op[_d11+1]=_p9[_g9][1];}if(E&&(h=P==null?void 0:P.opt)!=null&&h.thickness&&(P.opt.thickness=E),i&&!(m&&v&&l)){if(a){var _p10=P.op.map(function(d,g){var O=g%3;return O===0?d+a[0]:O===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 _g10=P.opt.eraserlines[_d12].op;for(var _O6=0;_O6<_g10.length;_O6++){var _w3=_g10[_O6].map(function(L,B){return B%2?L+a[1]:L+a[0];});P.opt.eraserlines[_d12].op[_O6]=_w3;}}}else if(he(c)){var _p11=P.op;if(pm(_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 _g11=P.opt.eraserlines[_d13].op;for(var _O7=0;_O7<_g11.length;_O7++)mm(_g11[_O7],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-Te.SafeBorderPadding),y:Math.floor(n.y-Te.SafeBorderPadding),w:Math.floor(n.width+Te.SafeBorderPadding*2),h:Math.floor(n.height+Te.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===pt.Text&&(i.fontSize||i.translate||i.textInfos&&i.textInfos.get(n.name))||t===pt.Image&&(i.angle||i.translate||i.scale||i.strokeColor&&i.type===Qr.Iconify)||t===i.toolsType&&i.willRefresh||r.eraserlines&&r.eraserlines.length&&(i.strokeColor||i.fillColor));}}]);}();ot(Te,"SafeBorderPadding",10);var At=Te;var fn=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 hn={exports:{}};hn.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 m=0;m<a.length;m++)i[a][a.charAt(m)]=m;}return i[a][c];}var o={compressToBase64:function compressToBase64(a){if(a==null)return"";var c=o._compress(a,6,function(m){return r.charAt(m);});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),m=new Uint8Array(c.length*2),f=0,v=c.length;f<v;f++){var S=c.charCodeAt(f);m[f*2]=S>>>8,m[f*2+1]=S%256;}return m;},//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),m=0,f=c.length;m<f;m++)c[m]=a[m*2]*256+a[m*2+1];var v=[];return c.forEach(function(S){v.push(t(S));}),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,m){if(a==null)return"";var f,v,S={},E={},T="",P="",x="",h=2,p=3,d=2,g=[],O=0,w=0,L;for(L=0;L<a.length;L+=1)if(T=a.charAt(L),Object.prototype.hasOwnProperty.call(S,T)||(S[T]=p++,E[T]=!0),P=x+T,Object.prototype.hasOwnProperty.call(S,P))x=P;else{if(Object.prototype.hasOwnProperty.call(E,x)){if(x.charCodeAt(0)<256){for(f=0;f<d;f++)O=O<<1,w==c-1?(w=0,g.push(m(O)),O=0):w++;for(v=x.charCodeAt(0),f=0;f<8;f++)O=O<<1|v&1,w==c-1?(w=0,g.push(m(O)),O=0):w++,v=v>>1;}else{for(v=1,f=0;f<d;f++)O=O<<1|v,w==c-1?(w=0,g.push(m(O)),O=0):w++,v=0;for(v=x.charCodeAt(0),f=0;f<16;f++)O=O<<1|v&1,w==c-1?(w=0,g.push(m(O)),O=0):w++,v=v>>1;}h--,h==0&&(h=Math.pow(2,d),d++),delete E[x];}else for(v=S[x],f=0;f<d;f++)O=O<<1|v&1,w==c-1?(w=0,g.push(m(O)),O=0):w++,v=v>>1;h--,h==0&&(h=Math.pow(2,d),d++),S[P]=p++,x=String(T);}if(x!==""){if(Object.prototype.hasOwnProperty.call(E,x)){if(x.charCodeAt(0)<256){for(f=0;f<d;f++)O=O<<1,w==c-1?(w=0,g.push(m(O)),O=0):w++;for(v=x.charCodeAt(0),f=0;f<8;f++)O=O<<1|v&1,w==c-1?(w=0,g.push(m(O)),O=0):w++,v=v>>1;}else{for(v=1,f=0;f<d;f++)O=O<<1|v,w==c-1?(w=0,g.push(m(O)),O=0):w++,v=0;for(v=x.charCodeAt(0),f=0;f<16;f++)O=O<<1|v&1,w==c-1?(w=0,g.push(m(O)),O=0):w++,v=v>>1;}h--,h==0&&(h=Math.pow(2,d),d++),delete E[x];}else for(v=S[x],f=0;f<d;f++)O=O<<1|v&1,w==c-1?(w=0,g.push(m(O)),O=0):w++,v=v>>1;h--,h==0&&(h=Math.pow(2,d),d++);}for(v=2,f=0;f<d;f++)O=O<<1|v&1,w==c-1?(w=0,g.push(m(O)),O=0):w++,v=v>>1;for(;;)if(O=O<<1,w==c-1){g.push(m(O));break;}else w++;return g.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,m){var f=[],v=4,S=4,E=3,T="",P=[],x,h,p,d,g,O,w,L={val:m(0),position:c,index:1};for(x=0;x<3;x+=1)f[x]=x;for(p=0,g=Math.pow(2,2),O=1;O!=g;)d=L.val&L.position,L.position>>=1,L.position==0&&(L.position=c,L.val=m(L.index++)),p|=(d>0?1:0)*O,O<<=1;switch(p){case 0:for(p=0,g=Math.pow(2,8),O=1;O!=g;)d=L.val&L.position,L.position>>=1,L.position==0&&(L.position=c,L.val=m(L.index++)),p|=(d>0?1:0)*O,O<<=1;w=t(p);break;case 1:for(p=0,g=Math.pow(2,16),O=1;O!=g;)d=L.val&L.position,L.position>>=1,L.position==0&&(L.position=c,L.val=m(L.index++)),p|=(d>0?1:0)*O,O<<=1;w=t(p);break;case 2:return"";}for(f[3]=w,h=w,P.push(w);;){if(L.index>a)return"";for(p=0,g=Math.pow(2,E),O=1;O!=g;)d=L.val&L.position,L.position>>=1,L.position==0&&(L.position=c,L.val=m(L.index++)),p|=(d>0?1:0)*O,O<<=1;switch(w=p){case 0:for(p=0,g=Math.pow(2,8),O=1;O!=g;)d=L.val&L.position,L.position>>=1,L.position==0&&(L.position=c,L.val=m(L.index++)),p|=(d>0?1:0)*O,O<<=1;f[S++]=t(p),w=S-1,v--;break;case 1:for(p=0,g=Math.pow(2,16),O=1;O!=g;)d=L.val&L.position,L.position>>=1,L.position==0&&(L.position=c,L.val=m(L.index++)),p|=(d>0?1:0)*O,O<<=1;f[S++]=t(p),w=S-1,v--;break;case 2:return P.join("");}if(v==0&&(v=Math.pow(2,E),E++),f[w])T=f[w];else if(w===S)T=h+h.charAt(0);else return null;P.push(T),f[S++]=h+T.charAt(0),v--,h=T,v==0&&(v=Math.pow(2,E),E++);}}};return o;}();u!=null?u.exports=e:(typeof angular==="undefined"?"undefined":_typeof(angular))<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return e;});})(hn);var Gi=hn.exports;function Qe(u){return JSON.parse(Gi.decompress(u));}function ve(u){return Gi.compress(JSON.stringify(u));}var ki={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,y,I){e.biginteger_used=1,s!=null&&(typeof s=="number"&&_typeof(y)>"u"?this.fromInt(s):typeof s=="number"?this.fromNumber(s,y,I):y==null&&typeof s!="string"?this.fromString(s,256):this.fromString(s,y));}function a(){return new o(null,void 0,void 0);}function c(s,y,I,N,z,Z){for(;--Z>=0;){var tt=y*this[s++]+I[N]+z;z=Math.floor(tt/67108864),I[N++]=tt&67108863;}return z;}function m(s,y,I,N,z,Z){for(var tt=y&32767,ft=y>>15;--Z>=0;){var ht=this[s]&32767,It=this[s++]>>15,Rt=ft*ht+It*tt;ht=tt*ht+((Rt&32767)<<15)+I[N]+(z&1073741823),z=(ht>>>30)+(Rt>>>15)+ft*It+(z>>>30),I[N++]=ht&1073741823;}return z;}function f(s,y,I,N,z,Z){for(var tt=y&16383,ft=y>>14;--Z>=0;){var ht=this[s]&16383,It=this[s++]>>14,Rt=ft*ht+It*tt;ht=tt*ht+((Rt&16383)<<14)+I[N]+z,z=(ht>>28)+(Rt>>14)+ft*It,I[N++]=ht&268435455;}return z;}r=="Microsoft Internet Explorer"?(o.prototype.am=m,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 S="0123456789abcdefghijklmnopqrstuvwxyz",E=new Array(),T,P;for(T=48,P=0;P<=9;++P)E[T++]=P;for(T=97,P=10;P<36;++P)E[T++]=P;for(T=65,P=10;P<36;++P)E[T++]=P;function x(s){return S.charAt(s);}function h(s,y){var I=E[s.charCodeAt(y)];return I!==null&&I!==void 0?I:-1;}function p(s){for(var y=this.t-1;y>=0;--y)s[y]=this[y];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 g(s){var y=a();return y.fromInt(s),y;}function O(s,y){var I;if(y==16)I=4;else if(y==8)I=3;else if(y==256)I=8;else if(y==2)I=1;else if(y==32)I=5;else if(y==4)I=2;else{this.fromRadix(s,y);return;}this.t=0,this.s=0;for(var N=s.length,z=!1,Z=0;--N>=0;){var tt=I==8?s[N]&255:h(s,N);if(tt<0){s.charAt(N)=="-"&&(z=!0);continue;}z=!1,Z==0?this[this.t++]=tt:Z+I>this.DB?(this[this.t-1]|=(tt&(1<<this.DB-Z)-1)<<Z,this[this.t++]=tt>>this.DB-Z):this[this.t-1]|=tt<<Z,Z+=I,Z>=this.DB&&(Z-=this.DB);}I==8&&s[0]&128&&(this.s=-1,Z>0&&(this[this.t-1]|=(1<<this.DB-Z)-1<<Z)),this.clamp(),z&&o.ZERO.subTo(this,this);}function w(){for(var s=this.s&this.DM;this.t>0&&this[this.t-1]==s;)--this.t;}function L(s){if(this.s<0)return"-"+this.negate().toString(s);var y;if(s==16)y=4;else if(s==8)y=3;else if(s==2)y=1;else if(s==32)y=5;else if(s==4)y=2;else return this.toRadix(s);var I=(1<<y)-1,N,z=!1,Z="",tt=this.t,ft=this.DB-tt*this.DB%y;if(tt-->0)for(ft<this.DB&&(N=this[tt]>>ft)>0&&(z=!0,Z=x(N));tt>=0;)ft<y?(N=(this[tt]&(1<<ft)-1)<<y-ft,N|=this[--tt]>>(ft+=this.DB-y)):(N=this[tt]>>(ft-=y)&I,ft<=0&&(ft+=this.DB,--tt)),N>0&&(z=!0),z&&(Z+=x(N));return z?Z:"0";}function B(){var s=a();return o.ZERO.subTo(this,s),s;}function A(){return this.s<0?this.negate():this;}function b(s){var y=this.s-s.s;if(y!=0)return y;var I=this.t;if(y=I-s.t,y!=0)return this.s<0?-y:y;for(;--I>=0;)if((y=this[I]-s[I])!=0)return y;return 0;}function W(s){var y=1,I;return(I=s>>>16)!=0&&(s=I,y+=16),(I=s>>8)!=0&&(s=I,y+=8),(I=s>>4)!=0&&(s=I,y+=4),(I=s>>2)!=0&&(s=I,y+=2),(I=s>>1)!=0&&(s=I,y+=1),y;}function D(){return this.t<=0?0:this.DB*(this.t-1)+W(this[this.t-1]^this.s&this.DM);}function R(s,y){var I;for(I=this.t-1;I>=0;--I)y[I+s]=this[I];for(I=s-1;I>=0;--I)y[I]=0;y.t=this.t+s,y.s=this.s;}function X(s,y){for(var I=s;I<this.t;++I)y[I-s]=this[I];y.t=Math.max(this.t-s,0),y.s=this.s;}function H(s,y){var I=s%this.DB,N=this.DB-I,z=(1<<N)-1,Z=Math.floor(s/this.DB),tt=this.s<<I&this.DM,ft;for(ft=this.t-1;ft>=0;--ft)y[ft+Z+1]=this[ft]>>N|tt,tt=(this[ft]&z)<<I;for(ft=Z-1;ft>=0;--ft)y[ft]=0;y[Z]=tt,y.t=this.t+Z+1,y.s=this.s,y.clamp();}function J(s,y){y.s=this.s;var I=Math.floor(s/this.DB);if(I>=this.t){y.t=0;return;}var N=s%this.DB,z=this.DB-N,Z=(1<<N)-1;y[0]=this[I]>>N;for(var tt=I+1;tt<this.t;++tt)y[tt-I-1]|=(this[tt]&Z)<<z,y[tt-I]=this[tt]>>N;N>0&&(y[this.t-I-1]|=(this.s&Z)<<z),y.t=this.t-I,y.clamp();}function et(s,y){for(var I=0,N=0,z=Math.min(s.t,this.t);I<z;)N+=this[I]-s[I],y[I++]=N&this.DM,N>>=this.DB;if(s.t<this.t){for(N-=s.s;I<this.t;)N+=this[I],y[I++]=N&this.DM,N>>=this.DB;N+=this.s;}else{for(N+=this.s;I<s.t;)N-=s[I],y[I++]=N&this.DM,N>>=this.DB;N-=s.s;}y.s=N<0?-1:0,N<-1?y[I++]=this.DV+N:N>0&&(y[I++]=N),y.t=I,y.clamp();}function it(s,y){var I=this.abs(),N=s.abs(),z=I.t;for(y.t=z+N.t;--z>=0;)y[z]=0;for(z=0;z<N.t;++z)y[z+I.t]=I.am(0,N[z],y,z,0,I.t);y.s=0,y.clamp(),this.s!=s.s&&o.ZERO.subTo(y,y);}function $(s){for(var y=this.abs(),I=s.t=2*y.t;--I>=0;)s[I]=0;for(I=0;I<y.t-1;++I){var N=y.am(I,y[I],s,2*I,0,1);(s[I+y.t]+=y.am(I+1,2*y[I],s,2*I+1,N,y.t-I-1))>=y.DV&&(s[I+y.t]-=y.DV,s[I+y.t+1]=1);}s.t>0&&(s[s.t-1]+=y.am(I,y[I],s,2*I,0,1)),s.s=0,s.clamp();}function V(s,y,I){var N=s.abs();if(!(N.t<=0)){var z=this.abs();if(z.t<N.t){y!=null&&y.fromInt(0),I!=null&&this.copyTo(I);return;}I==null&&(I=a());var Z=a(),tt=this.s,ft=s.s,ht=this.DB-W(N[N.t-1]);ht>0?(N.lShiftTo(ht,Z),z.lShiftTo(ht,I)):(N.copyTo(Z),z.copyTo(I));var It=Z.t,Rt=Z[It-1];if(Rt!=0){var Lt=Rt*(1<<this.F1)+(It>1?Z[It-2]>>this.F2:0),Wt=this.FV/Lt,Yt=(1<<this.F1)/Lt,Vt=1<<this.F2,Kt=I.t,ee=Kt-It,ge=y!==null&&y!==void 0?y:a();for(Z.dlShiftTo(ee,ge),I.compareTo(ge)>=0&&(I[I.t++]=1,I.subTo(ge,I)),o.ONE.dlShiftTo(It,ge),ge.subTo(Z,Z);Z.t<It;)Z[Z.t++]=0;for(;--ee>=0;){var Oe=I[--Kt]==Rt?this.DM:Math.floor(I[Kt]*Wt+(I[Kt-1]+Vt)*Yt);if((I[Kt]+=Z.am(0,Oe,I,ee,0,It))<Oe)for(Z.dlShiftTo(ee,ge),I.subTo(ge,I);I[Kt]<--Oe;)I.subTo(ge,I);}y!=null&&(I.drShiftTo(It,y),tt!=ft&&o.ZERO.subTo(y,y)),I.t=It,I.clamp(),ht>0&&I.rShiftTo(ht,I),tt<0&&o.ZERO.subTo(I,I);}}}function rt(s){var y=a();return this.abs().divRemTo(s,null,y),this.s<0&&y.compareTo(o.ZERO)>0&&s.subTo(y,y),y;}function lt(s){this.m=s;}function ct(s){return s.s<0||s.compareTo(this.m)>=0?s.mod(this.m):s;}function gt(s){return s;}function st(s){s.divRemTo(this.m,null,s);}function Ct(s,y,I){s.multiplyTo(y,I),this.reduce(I);}function xt(s,y){s.squareTo(y),this.reduce(y);}lt.prototype.convert=ct,lt.prototype.revert=gt,lt.prototype.reduce=st,lt.prototype.mulTo=Ct,lt.prototype.sqrTo=xt;function F(){if(this.t<1)return 0;var s=this[0];if(!(s&1))return 0;var y=s&3;return y=y*(2-(s&15)*y)&15,y=y*(2-(s&255)*y)&255,y=y*(2-((s&65535)*y&65535))&65535,y=y*(2-s*y%this.DV)%this.DV,y>0?this.DV-y:-y;}function U(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 K(s){var y=a();return s.abs().dlShiftTo(this.m.t,y),y.divRemTo(this.m,null,y),s.s<0&&y.compareTo(o.ZERO)>0&&this.m.subTo(y,y),y;}function q(s){var y=a();return s.copyTo(y),this.reduce(y),y;}function Y(s){for(;s.t<=this.mt2;)s[s.t++]=0;for(var y=0;y<this.m.t;++y){var I=s[y]&32767,N=I*this.mpl+((I*this.mph+(s[y]>>15)*this.mpl&this.um)<<15)&s.DM;for(I=y+this.m.t,s[I]+=this.m.am(0,N,s,y,0,this.m.t);s[I]>=s.DV;)s[I]-=s.DV,s[++I]++;}s.clamp(),s.drShiftTo(this.m.t,s),s.compareTo(this.m)>=0&&s.subTo(this.m,s);}function k(s,y){s.squareTo(y),this.reduce(y);}function C(s,y,I){s.multiplyTo(y,I),this.reduce(I);}U.prototype.convert=K,U.prototype.revert=q,U.prototype.reduce=Y,U.prototype.mulTo=C,U.prototype.sqrTo=k;function M(){return(this.t>0?this[0]&1:this.s)==0;}function j(s,y){if(s>4294967295||s<1)return o.ONE;var I=a(),N=a(),z=y.convert(this),Z=W(s)-1;for(z.copyTo(I);--Z>=0;)if(y.sqrTo(I,N),(s&1<<Z)>0)y.mulTo(N,z,I);else{var tt=I;I=N,N=tt;}return y.revert(I);}function G(s,y){var I;return s<256||y.isEven()?I=new lt(y):I=new U(y),this.exp(s,I);}o.prototype.copyTo=p,o.prototype.fromInt=d,o.prototype.fromString=O,o.prototype.clamp=w,o.prototype.dlShiftTo=R,o.prototype.drShiftTo=X,o.prototype.lShiftTo=H,o.prototype.rShiftTo=J,o.prototype.subTo=et,o.prototype.multiplyTo=it,o.prototype.squareTo=$,o.prototype.divRemTo=V,o.prototype.invDigit=F,o.prototype.isEven=M,o.prototype.exp=j,o.prototype.toString=L,o.prototype.negate=B,o.prototype.abs=A,o.prototype.compareTo=b,o.prototype.bitLength=D,o.prototype.mod=rt,o.prototype.modPowInt=G,o.ZERO=g(0),o.ONE=g(1);function Q(){var s=a();return this.copyTo(s),s;}function _(){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 mt(s){return Math.floor(Math.LN2*this.DB/Math.log(s));}function Pt(){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 y=this.chunkSize(s),I=Math.pow(s,y),N=g(I),z=a(),Z=a(),tt="";for(this.divRemTo(N,z,Z);z.signum()>0;)tt=(I+Z.intValue()).toString(s).substr(1)+tt,z.divRemTo(N,z,Z);return Z.intValue().toString(s)+tt;}function yt(s,y){this.fromInt(0),y==null&&(y=10);for(var I=this.chunkSize(y),N=Math.pow(y,I),z=!1,Z=0,tt=0,ft=0;ft<s.length;++ft){var ht=h(s,ft);if(ht<0){s.charAt(ft)=="-"&&this.signum()==0&&(z=!0);continue;}tt=y*tt+ht,++Z>=I&&(this.dMultiply(N),this.dAddOffset(tt,0),Z=0,tt=0);}Z>0&&(this.dMultiply(Math.pow(y,Z)),this.dAddOffset(tt,0)),z&&o.ZERO.subTo(this,this);}function vt(s,y,I){if(typeof y=="number"){if(s<2)this.fromInt(1);else for(this.fromNumber(s,I),this.testBit(s-1)||this.bitwiseTo(o.ONE.shiftLeft(s-1),Ut,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(y);)this.dAddOffset(2,0),this.bitLength()>s&&this.subTo(o.ONE.shiftLeft(s-1),this);}else{var N=new Array(),z=s&7;N.length=(s>>3)+1,y.nextBytes(N),z>0?N[0]&=(1<<z)-1:N[0]=0,this.fromString(N,256);}}function St(){var s=this.t,y=new Array();y[0]=this.s;var I=this.DB-s*this.DB%8,N,z=0;if(s-->0)for(I<this.DB&&(N=this[s]>>I)!=(this.s&this.DM)>>I&&(y[z++]=N|this.s<<this.DB-I);s>=0;)I<8?(N=(this[s]&(1<<I)-1)<<8-I,N|=this[--s]>>(I+=this.DB-8)):(N=this[s]>>(I-=8)&255,I<=0&&(I+=this.DB,--s)),N&128&&(N|=-256),z==0&&(this.s&128)!=(N&128)&&++z,(z>0||N!=this.s)&&(y[z++]=N);return y;}function Mt(s){return this.compareTo(s)==0;}function wt(s){return this.compareTo(s)<0?this:s;}function Ot(s){return this.compareTo(s)>0?this:s;}function Bt(s,y,I){var N,z,Z=Math.min(s.t,this.t);for(N=0;N<Z;++N)I[N]=y(this[N],s[N]);if(s.t<this.t){for(z=s.s&this.DM,N=Z;N<this.t;++N)I[N]=y(this[N],z);I.t=this.t;}else{for(z=this.s&this.DM,N=Z;N<s.t;++N)I[N]=y(z,s[N]);I.t=s.t;}I.s=y(this.s,s.s),I.clamp();}function Gt(s,y){return s&y;}function jt(s){var y=a();return this.bitwiseTo(s,Gt,y),y;}function Ut(s,y){return s|y;}function zt(s){var y=a();return this.bitwiseTo(s,Ut,y),y;}function Xt(s,y){return s^y;}function ae(s){var y=a();return this.bitwiseTo(s,Xt,y),y;}function ie(s,y){return s&~y;}function se(s){var y=a();return this.bitwiseTo(s,ie,y),y;}function oe(){for(var s=a(),y=0;y<this.t;++y)s[y]=this.DM&~this[y];return s.t=this.t,s.s=~this.s,s;}function le(s){var y=a();return s<0?this.rShiftTo(-s,y):this.lShiftTo(s,y),y;}function ce(s){var y=a();return s<0?this.lShiftTo(-s,y):this.rShiftTo(s,y),y;}function fe(s){if(s==0)return-1;var y=0;return s&65535||(s>>=16,y+=16),s&255||(s>>=8,y+=8),s&15||(s>>=4,y+=4),s&3||(s>>=2,y+=2),s&1||++y,y;}function Jt(){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 xe(s){for(var y=0;s!=0;)s&=s-1,++y;return y;}function Be(){for(var s=0,y=this.s&this.DM,I=0;I<this.t;++I)s+=xe(this[I]^y);return s;}function We(s){var y=Math.floor(s/this.DB);return y>=this.t?this.s!=0:(this[y]&1<<s%this.DB)!=0;}function mr(s,y){var I=o.ONE.shiftLeft(s);return this.bitwiseTo(I,y,I),I;}function vr(s){return this.changeBit(s,Ut);}function xs(s){return this.changeBit(s,ie);}function Ts(s){return this.changeBit(s,Xt);}function Cs(s,y){for(var I=0,N=0,z=Math.min(s.t,this.t);I<z;)N+=this[I]+s[I],y[I++]=N&this.DM,N>>=this.DB;if(s.t<this.t){for(N+=s.s;I<this.t;)N+=this[I],y[I++]=N&this.DM,N>>=this.DB;N+=this.s;}else{for(N+=this.s;I<s.t;)N+=s[I],y[I++]=N&this.DM,N>>=this.DB;N+=s.s;}y.s=N<0?-1:0,N>0?y[I++]=N:N<-1&&(y[I++]=this.DV+N),y.t=I,y.clamp();}function Is(s){var y=a();return this.addTo(s,y),y;}function Os(s){var y=a();return this.subTo(s,y),y;}function Es(s){var y=a();return this.multiplyTo(s,y),y;}function Ms(){var s=a();return this.squareTo(s),s;}function As(s){var y=a();return this.divRemTo(s,y,null),y;}function ws(s){var y=a();return this.divRemTo(s,null,y),y;}function Ls(s){var y=a(),I=a();return this.divRemTo(s,y,I),new Array(y,I);}function Rs(s){this[this.t]=this.am(0,s-1,this,0,0,this.t),++this.t,this.clamp();}function Ds(s,y){if(s!=0){for(;this.t<=y;)this[this.t++]=0;for(this[y]+=s;this[y]>=this.DV;)this[y]-=this.DV,++y>=this.t&&(this[this.t++]=0),++this[y];}}function ir(){}function gn(s){return s;}function bs(s,y,I){s.multiplyTo(y,I);}function Ns(s,y){s.squareTo(y);}ir.prototype.convert=gn,ir.prototype.revert=gn,ir.prototype.mulTo=bs,ir.prototype.sqrTo=Ns;function Bs(s){return this.exp(s,new ir());}function Ws(s,y,I){var N=Math.min(this.t+s.t,y);for(I.s=0,I.t=N;N>0;)I[--N]=0;var z;for(z=I.t-this.t;N<z;++N)I[N+this.t]=this.am(0,s[N],I,N,0,this.t);for(z=Math.min(s.t,y);N<z;++N)this.am(0,s[N],I,N,0,y-N);I.clamp();}function Fs(s,y,I){--y;var N=I.t=this.t+s.t-y;for(I.s=0;--N>=0;)I[N]=0;for(N=Math.max(y-this.t,0);N<s.t;++N)I[this.t+N-y]=this.am(y-N,s[N],I,0,0,this.t+N-y);I.clamp(),I.drShiftTo(1,I);}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 Us(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 y=a();return s.copyTo(y),this.reduce(y),y;}function js(s){return s;}function Ys(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 Xs(s,y){s.squareTo(y),this.reduce(y);}function zs(s,y,I){s.multiplyTo(y,I),this.reduce(I);}je.prototype.convert=Us,je.prototype.revert=js,je.prototype.reduce=Ys,je.prototype.mulTo=zs,je.prototype.sqrTo=Xs;function $s(s,y){var I=s.bitLength(),N,z=g(1),Z;if(I<=0)return z;I<18?N=1:I<48?N=3:I<144?N=4:I<768?N=5:N=6,I<8?Z=new lt(y):y.isEven()?Z=new je(y):Z=new U(y);var tt=new Array(),ft=3,ht=N-1,It=(1<<N)-1;if(tt[1]=Z.convert(this),N>1){var Rt=a();for(Z.sqrTo(tt[1],Rt);ft<=It;)tt[ft]=a(),Z.mulTo(Rt,tt[ft-2],tt[ft]),ft+=2;}var Lt=s.t-1,Wt,Yt=!0,Vt=a(),Kt;for(I=W(s[Lt])-1;Lt>=0;){for(I>=ht?Wt=s[Lt]>>I-ht&It:(Wt=(s[Lt]&(1<<I+1)-1)<<ht-I,Lt>0&&(Wt|=s[Lt-1]>>this.DB+I-ht)),ft=N;!(Wt&1);)Wt>>=1,--ft;if((I-=ft)<0&&(I+=this.DB,--Lt),Yt)tt[Wt].copyTo(z),Yt=!1;else{for(;ft>1;)Z.sqrTo(z,Vt),Z.sqrTo(Vt,z),ft-=2;ft>0?Z.sqrTo(z,Vt):(Kt=z,z=Vt,Vt=Kt),Z.mulTo(Vt,tt[Wt],z);}for(;Lt>=0&&!(s[Lt]&1<<I);)Z.sqrTo(z,Vt),Kt=z,z=Vt,Vt=Kt,--I<0&&(I=this.DB-1,--Lt);}return Z.revert(z);}function Gs(s){var y=this.s<0?this.negate():this.clone(),I=s.s<0?s.negate():s.clone();if(y.compareTo(I)<0){var N=y;y=I,I=N;}var z=y.getLowestSetBit(),Z=I.getLowestSetBit();if(Z<0)return y;for(z<Z&&(Z=z),Z>0&&(y.rShiftTo(Z,y),I.rShiftTo(Z,I));y.signum()>0;)(z=y.getLowestSetBit())>0&&y.rShiftTo(z,y),(z=I.getLowestSetBit())>0&&I.rShiftTo(z,I),y.compareTo(I)>=0?(y.subTo(I,y),y.rShiftTo(1,y)):(I.subTo(y,I),I.rShiftTo(1,I));return Z>0&&I.lShiftTo(Z,I),I;}function ks(s){if(s<=0)return 0;var y=this.DV%s,I=this.s<0?s-1:0;if(this.t>0)if(y==0)I=this[0]%s;else for(var N=this.t-1;N>=0;--N)I=(y*I+this[N])%s;return I;}function Hs(s){var y=s.isEven();if(this.isEven()&&y||s.signum()==0)return o.ZERO;for(var I=s.clone(),N=this.clone(),z=g(1),Z=g(0),tt=g(0),ft=g(1);I.signum()!=0;){for(;I.isEven();)I.rShiftTo(1,I),y?((!z.isEven()||!Z.isEven())&&(z.addTo(this,z),Z.subTo(s,Z)),z.rShiftTo(1,z)):Z.isEven()||Z.subTo(s,Z),Z.rShiftTo(1,Z);for(;N.isEven();)N.rShiftTo(1,N),y?((!tt.isEven()||!ft.isEven())&&(tt.addTo(this,tt),ft.subTo(s,ft)),tt.rShiftTo(1,tt)):ft.isEven()||ft.subTo(s,ft),ft.rShiftTo(1,ft);I.compareTo(N)>=0?(I.subTo(N,I),y&&z.subTo(tt,z),Z.subTo(ft,Z)):(N.subTo(I,N),y&&tt.subTo(z,tt),ft.subTo(Z,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],Vs=(1<<26)/de[de.length-1];function Ks(s){var y,I=this.abs();if(I.t==1&&I[0]<=de[de.length-1]){for(y=0;y<de.length;++y)if(I[0]==de[y])return!0;return!1;}if(I.isEven())return!1;for(y=1;y<de.length;){for(var N=de[y],z=y+1;z<de.length&&N<Vs;)N*=de[z++];for(N=I.modInt(N);y<z;)if(N%de[y++]==0)return!1;}return I.millerRabin(s);}function Zs(s){var y=this.subtract(o.ONE),I=y.getLowestSetBit();if(I<=0)return!1;var N=y.shiftRight(I);s=s+1>>1,s>de.length&&(s=de.length);for(var z=a(),Z=0;Z<s;++Z){z.fromInt(de[Math.floor(Math.random()*de.length)]);var tt=z.modPow(N,this);if(tt.compareTo(o.ONE)!=0&&tt.compareTo(y)!=0){for(var ft=1;ft++<I&&tt.compareTo(y)!=0;)if(tt=tt.modPowInt(2,this),tt.compareTo(o.ONE)==0)return!1;if(tt.compareTo(y)!=0)return!1;}}return!0;}o.prototype.chunkSize=mt,o.prototype.toRadix=Tt,o.prototype.fromRadix=yt,o.prototype.fromNumber=vt,o.prototype.bitwiseTo=Bt,o.prototype.changeBit=mr,o.prototype.addTo=Cs,o.prototype.dMultiply=Rs,o.prototype.dAddOffset=Ds,o.prototype.multiplyLowerTo=Ws,o.prototype.multiplyUpperTo=Fs,o.prototype.modInt=ks,o.prototype.millerRabin=Zs,o.prototype.clone=Q,o.prototype.intValue=_,o.prototype.byteValue=nt,o.prototype.shortValue=ut,o.prototype.signum=Pt,o.prototype.toByteArray=St,o.prototype.equals=Mt,o.prototype.min=wt,o.prototype.max=Ot,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=Jt,o.prototype.bitCount=Be,o.prototype.testBit=We,o.prototype.setBit=vr,o.prototype.clearBit=xs,o.prototype.flipBit=Ts,o.prototype.add=Is,o.prototype.subtract=Os,o.prototype.multiply=Es,o.prototype.divide=As,o.prototype.remainder=ws,o.prototype.divideAndRemainder=Ls,o.prototype.modPow=$s,o.prototype.modInverse=Hs,o.prototype.pow=Bs,o.prototype.gcd=Gs,o.prototype.isProbablePrime=Ks,o.prototype.square=Ms;var Ht=o;Ht.prototype.IsNegative=function(){return this.compareTo(Ht.ZERO)==-1;},Ht.op_Equality=function(s,y){return s.compareTo(y)==0;},Ht.op_Inequality=function(s,y){return s.compareTo(y)!=0;},Ht.op_GreaterThan=function(s,y){return s.compareTo(y)>0;},Ht.op_LessThan=function(s,y){return s.compareTo(y)<0;},Ht.op_Addition=function(s,y){return new Ht(s,void 0,void 0).add(new Ht(y,void 0,void 0));},Ht.op_Subtraction=function(s,y){return new Ht(s,void 0,void 0).subtract(new Ht(y,void 0,void 0));},Ht.Int128Mul=function(s,y){return new Ht(s,void 0,void 0).multiply(new Ht(y,void 0,void 0));},Ht.op_Division=function(s,y){return s.divide(y);},Ht.prototype.ToDouble=function(){return parseFloat(this.toString());};var Pn=function Pn(s,y){var I;if(_typeof(Object.getOwnPropertyNames)>"u"){for(I in y.prototype)(_typeof(s.prototype[I])>"u"||s.prototype[I]===Object.prototype[I])&&(s.prototype[I]=y.prototype[I]);for(I in y)_typeof(s[I])>"u"&&(s[I]=y[I]);s.$baseCtor=y;}else{for(var N=Object.getOwnPropertyNames(y.prototype),z=0;z<N.length;z++)_typeof(Object.getOwnPropertyDescriptor(s.prototype,N[z]))>"u"&&Object.defineProperty(s.prototype,N[z],Object.getOwnPropertyDescriptor(y.prototype,N[z]));for(I in y)_typeof(s[I])>"u"&&(s[I]=y[I]);s.$baseCtor=y;}};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,y){this.X=s,this.Y=y;},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,y=this.m_Parent;y!==null;)s=!s,y=y.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 y=this.m_Childs.length;this.m_Childs.push(s),s.m_Parent=this,s.m_Index=y;},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,y=this.m_AllPolys.length;s<y;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;},Pn(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,y){return Math.max(s,y);},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,y=s.length;if(this.X=0,this.Y=0,e.use_xyz){if(this.Z=0,y===3)this.X=s[0],this.Y=s[1],this.Z=s[2];else if(y===2)this.X=s[0],this.Y=s[1],this.Z=0;else if(y===1){if(s[0]instanceof e.DoublePoint){var I=s[0];this.X=e.Clipper.Round(I.X),this.Y=e.Clipper.Round(I.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(y===2)this.X=s[0],this.Y=s[1];else if(y===1){if(s[0]instanceof e.DoublePoint){var I=s[0];this.X=e.Clipper.Round(I.X),this.Y=e.Clipper.Round(I.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,y){return s.X===y.X&&s.Y===y.Y;},e.IntPoint.op_Inequality=function(s,y){return s.X!==y.X||s.Y!==y.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,y,I){this.X=s,this.Y=y,e.use_xyz&&(_typeof(I)>"u"?this.Z=0:this.Z=I);},e.IntPoint2.prototype=e.IntPoint.prototype,e.IntRect=function(){var s=arguments,y=s.length;if(y===4)this.left=s[0],this.top=s[1],this.right=s[2],this.bottom=s[3];else if(y===1){var I=s[0];this.left=I.left,this.top=I.top,this.right=I.right,this.bottom=I.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,y,I,N){this.left=s,this.top=y,this.right=I,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,y){var I=y.Pt.Y-s.Pt.Y;return I>0?1:I<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,y){var I=y;do{if(e.IntPoint.op_Equality(I.Pt,s))return!0;I=I.Next;}while(I!==y);return!1;},e.ClipperBase.prototype.PointOnLineSegment=function(s,y,I,N){return N?s.X===y.X&&s.Y===y.Y||s.X===I.X&&s.Y===I.Y||s.X>y.X==s.X<I.X&&s.Y>y.Y==s.Y<I.Y&&Ht.op_Equality(Ht.Int128Mul(s.X-y.X,I.Y-y.Y),Ht.Int128Mul(I.X-y.X,s.Y-y.Y)):s.X===y.X&&s.Y===y.Y||s.X===I.X&&s.Y===I.Y||s.X>y.X==s.X<I.X&&s.Y>y.Y==s.Y<I.Y&&(s.X-y.X)*(I.Y-y.Y)===(I.X-y.X)*(s.Y-y.Y);},e.ClipperBase.prototype.PointOnPolygon=function(s,y,I){for(var N=y;;){if(this.PointOnLineSegment(s,N.Pt,N.Next.Pt,I))return!0;if(N=N.Next,N===y)break;}return!1;},e.ClipperBase.prototype.SlopesEqual=e.ClipperBase.SlopesEqual=function(){var s=arguments,y=s.length,I,N,z,Z,tt,ft,ht;return y===3?(I=s[0],N=s[1],ht=s[2],ht?Ht.op_Equality(Ht.Int128Mul(I.Delta.Y,N.Delta.X),Ht.Int128Mul(I.Delta.X,N.Delta.Y)):e.Cast_Int64(I.Delta.Y*N.Delta.X)===e.Cast_Int64(I.Delta.X*N.Delta.Y)):y===4?(z=s[0],Z=s[1],tt=s[2],ht=s[3],ht?Ht.op_Equality(Ht.Int128Mul(z.Y-Z.Y,Z.X-tt.X),Ht.Int128Mul(z.X-Z.X,Z.Y-tt.Y)):e.Cast_Int64((z.Y-Z.Y)*(Z.X-tt.X))-e.Cast_Int64((z.X-Z.X)*(Z.Y-tt.Y))===0):(z=s[0],Z=s[1],tt=s[2],ft=s[3],ht=s[4],ht?Ht.op_Equality(Ht.Int128Mul(z.Y-Z.Y,tt.X-ft.X),Ht.Int128Mul(z.X-Z.X,tt.Y-ft.Y)):e.Cast_Int64((z.Y-Z.Y)*(tt.X-ft.X))-e.Cast_Int64((z.X-Z.X)*(tt.Y-ft.Y))===0);},e.ClipperBase.SlopesEqual3=function(s,y,I){return I?Ht.op_Equality(Ht.Int128Mul(s.Delta.Y,y.Delta.X),Ht.Int128Mul(s.Delta.X,y.Delta.Y)):e.Cast_Int64(s.Delta.Y*y.Delta.X)===e.Cast_Int64(s.Delta.X*y.Delta.Y);},e.ClipperBase.SlopesEqual4=function(s,y,I,N){return N?Ht.op_Equality(Ht.Int128Mul(s.Y-y.Y,y.X-I.X),Ht.Int128Mul(s.X-y.X,y.Y-I.Y)):e.Cast_Int64((s.Y-y.Y)*(y.X-I.X))-e.Cast_Int64((s.X-y.X)*(y.Y-I.Y))===0;},e.ClipperBase.SlopesEqual5=function(s,y,I,N,z){return z?Ht.op_Equality(Ht.Int128Mul(s.Y-y.Y,I.X-N.X),Ht.Int128Mul(s.X-y.X,I.Y-N.Y)):e.Cast_Int64((s.Y-y.Y)*(I.X-N.X))-e.Cast_Int64((s.X-y.X)*(I.Y-N.Y))===0;},e.ClipperBase.prototype.Clear=function(){this.DisposeLocalMinimaList();for(var s=0,y=this.m_edges.length;s<y;++s){for(var I=0,N=this.m_edges[s].length;I<N;++I)this.m_edges[s][I]=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,y){y.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)&&(y.Value=!0,this.RangeTest(s,y));},e.ClipperBase.prototype.InitEdge=function(s,y,I,N){s.Next=y,s.Prev=I,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,y){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=y;},e.ClipperBase.prototype.FindNextLocMin=function(s){for(var y;;){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(y=s;s.Dx===e.ClipperBase.horizontal;)s=s.Next;if(s.Top.Y!==s.Prev.Bot.Y){y.Prev.Bot.X<s.Bot.X&&(s=y);break;}}return s;},e.ClipperBase.prototype.ProcessBound=function(s,y){var I,N=s,z;if(N.OutIdx===e.ClipperBase.Skip){if(s=N,y){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)y?N=s.Next:N=s.Prev;else{y?s=N.Next:s=N.Prev;var Z=new e.LocalMinima();Z.Next=null,Z.Y=s.Bot.Y,Z.LeftBound=null,Z.RightBound=s,s.WindDelta=0,N=this.ProcessBound(s,y),this.InsertLocalMinima(Z);}return N;}if(s.Dx===e.ClipperBase.horizontal&&(y?I=s.Prev:I=s.Next,I.Dx===e.ClipperBase.horizontal?I.Bot.X!==s.Bot.X&&I.Top.X!==s.Bot.X&&this.ReverseHorizontal(s):I.Bot.X!==s.Bot.X&&this.ReverseHorizontal(s)),I=s,y){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(z=N;z.Prev.Dx===e.ClipperBase.horizontal;)z=z.Prev;z.Prev.Top.X>N.Next.Top.X&&(N=z.Prev);}for(;s!==N;)s.NextInLML=s.Next,s.Dx===e.ClipperBase.horizontal&&s!==I&&s.Bot.X!==s.Prev.Top.X&&this.ReverseHorizontal(s),s=s.Next;s.Dx===e.ClipperBase.horizontal&&s!==I&&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(z=N;z.Next.Dx===e.ClipperBase.horizontal;)z=z.Next;(z.Next.Top.X===N.Prev.Top.X||z.Next.Top.X>N.Prev.Top.X)&&(N=z.Next);}for(;s!==N;)s.NextInLML=s.Prev,s.Dx===e.ClipperBase.horizontal&&s!==I&&s.Bot.X!==s.Next.Top.X&&this.ReverseHorizontal(s),s=s.Prev;s.Dx===e.ClipperBase.horizontal&&s!==I&&s.Bot.X!==s.Next.Top.X&&this.ReverseHorizontal(s),N=N.Prev;}return N;},e.ClipperBase.prototype.AddPath=function(s,y,I){e.use_lines?!I&&y===e.PolyType.ptClip&&e.Error("AddPath: Open paths must be subject."):I||e.Error("AddPath: Open paths have been disabled.");var N=s.length-1;if(I)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(I&&N<2||!I&&N<1)return!1;for(var z=new Array(),Z=0;Z<=N;Z++)z.push(new e.TEdge());var tt=!0;z[1].Curr.X=s[1].X,z[1].Curr.Y=s[1].Y,e.use_xyz&&(z[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(z[0],z[1],z[N],s[0]),this.InitEdge(z[N],z[0],z[N-1],s[N]);for(var Z=N-1;Z>=1;--Z)ft.Value=this.m_UseFullRange,this.RangeTest(s[Z],ft),this.m_UseFullRange=ft.Value,this.InitEdge(z[Z],z[Z+1],z[Z-1],s[Z]);for(var ht=z[0],It=ht,Rt=ht;;){if(It.Curr===It.Next.Curr&&(I||It.Next!==ht)){if(It===It.Next)break;It===ht&&(ht=It.Next),It=this.RemoveEdge(It),Rt=It;continue;}if(It.Prev===It.Next)break;if(I&&e.ClipperBase.SlopesEqual4(It.Prev.Curr,It.Curr,It.Next.Curr,this.m_UseFullRange)&&(!this.PreserveCollinear||!this.Pt2IsBetweenPt1AndPt3(It.Prev.Curr,It.Curr,It.Next.Curr))){It===ht&&(ht=It.Next),It=this.RemoveEdge(It),It=It.Prev,Rt=It;continue;}if(It=It.Next,It===Rt||!I&&It.Next===ht)break;}if(!I&&It===It.Next||I&&It.Prev===It.Next)return!1;I||(this.m_HasOpenPaths=!0,ht.Prev.OutIdx=e.ClipperBase.Skip),It=ht;do this.InitEdge2(It,y),It=It.Next,tt&&It.Curr.Y!==ht.Curr.Y&&(tt=!1);while(It!==ht);if(tt){if(I)return!1;It.Prev.OutIdx=e.ClipperBase.Skip;var Lt=new e.LocalMinima();for(Lt.Next=null,Lt.Y=It.Bot.Y,Lt.LeftBound=null,Lt.RightBound=It,Lt.RightBound.Side=e.EdgeSide.esRight,Lt.RightBound.WindDelta=0;It.Bot.X!==It.Prev.Top.X&&this.ReverseHorizontal(It),It.Next.OutIdx!==e.ClipperBase.Skip;)It.NextInLML=It.Next,It=It.Next;return this.InsertLocalMinima(Lt),this.m_edges.push(z),!0;}this.m_edges.push(z);var Wt,Yt=null;for(e.IntPoint.op_Equality(It.Prev.Bot,It.Prev.Top)&&(It=It.Next);It=this.FindNextLocMin(It),It!==Yt;){Yt===null&&(Yt=It);var Lt=new e.LocalMinima();Lt.Next=null,Lt.Y=It.Bot.Y,It.Dx<It.Prev.Dx?(Lt.LeftBound=It.Prev,Lt.RightBound=It,Wt=!1):(Lt.LeftBound=It,Lt.RightBound=It.Prev,Wt=!0),Lt.LeftBound.Side=e.EdgeSide.esLeft,Lt.RightBound.Side=e.EdgeSide.esRight,I?Lt.LeftBound.Next===Lt.RightBound?Lt.LeftBound.WindDelta=-1:Lt.LeftBound.WindDelta=1:Lt.LeftBound.WindDelta=0,Lt.RightBound.WindDelta=-Lt.LeftBound.WindDelta,It=this.ProcessBound(Lt.LeftBound,Wt),It.OutIdx===e.ClipperBase.Skip&&(It=this.ProcessBound(It,Wt));var Vt=this.ProcessBound(Lt.RightBound,!Wt);Vt.OutIdx===e.ClipperBase.Skip&&(Vt=this.ProcessBound(Vt,!Wt)),Lt.LeftBound.OutIdx===e.ClipperBase.Skip?Lt.LeftBound=null:Lt.RightBound.OutIdx===e.ClipperBase.Skip&&(Lt.RightBound=null),this.InsertLocalMinima(Lt),Wt||(It=Vt);}return!0;},e.ClipperBase.prototype.AddPaths=function(s,y,I){for(var N=!1,z=0,Z=s.length;z<Z;++z)this.AddPath(s[z],y,I)&&(N=!0);return N;},e.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(s,y,I){return e.IntPoint.op_Equality(s,I)||e.IntPoint.op_Equality(s,y)||e.IntPoint.op_Equality(I,y)?!1:s.X!==I.X?y.X>s.X==y.X<I.X:y.Y>s.Y==y.Y<I.Y;},e.ClipperBase.prototype.RemoveEdge=function(s){s.Prev.Next=s.Next,s.Next.Prev=s.Prev;var y=s.Next;return s.Prev=null,y;},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 y=this.m_MinimaList;y.Next!==null&&s.Y<y.Next.Y;)y=y.Next;s.Next=y.Next,y.Next=s;}},e.ClipperBase.prototype.PopLocalMinima=function(s,y){return y.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 y=s.Top.X;s.Top.X=s.Bot.X,s.Bot.X=y,e.use_xyz&&(y=s.Top.Z,s.Top.Z=s.Bot.Z,s.Bot.Z=y);},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 y=s.LeftBound;y!==null&&(y.Curr.X=y.Bot.X,y.Curr.Y=y.Bot.Y,e.use_xyz&&(y.Curr.Z=y.Bot.Z),y.OutIdx=e.ClipperBase.Unassigned),y=s.RightBound,y!==null&&(y.Curr.X=y.Bot.X,y.Curr.Y=y.Bot.Y,e.use_xyz&&(y.Curr.Z=y.Bot.Z),y.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 y=new e.Scanbeam();y.Y=s,y.Next=this.m_Scanbeam,this.m_Scanbeam=y;}else{for(var I=this.m_Scanbeam;I.Next!==null&&s<=I.Next.Y;)I=I.Next;if(s===I.Y)return;var N=new e.Scanbeam();N.Y=s,N.Next=I.Next,I.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 y=this.m_PolyOuts[s];y.Pts=null,y=null,this.m_PolyOuts[s]=null;},e.ClipperBase.prototype.UpdateEdgeIntoAEL=function(s){s.NextInLML===null&&e.Error("UpdateEdgeIntoAEL: invalid call");var y=s.PrevInAEL,I=s.NextInAEL;return s.NextInLML.OutIdx=s.OutIdx,y!==null?y.NextInAEL=s.NextInLML:this.m_ActiveEdges=s.NextInLML,I!==null&&(I.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=y,s.NextInAEL=I,e.ClipperBase.IsHorizontal(s)||this.InsertScanbeam(s.Top.Y),s;},e.ClipperBase.prototype.SwapPositionsInAEL=function(s,y){if(!(s.NextInAEL===s.PrevInAEL||y.NextInAEL===y.PrevInAEL)){if(s.NextInAEL===y){var I=y.NextInAEL;I!==null&&(I.PrevInAEL=s);var N=s.PrevInAEL;N!==null&&(N.NextInAEL=y),y.PrevInAEL=N,y.NextInAEL=s,s.PrevInAEL=y,s.NextInAEL=I;}else if(y.NextInAEL===s){var z=s.NextInAEL;z!==null&&(z.PrevInAEL=y);var Z=y.PrevInAEL;Z!==null&&(Z.NextInAEL=s),s.PrevInAEL=Z,s.NextInAEL=y,y.PrevInAEL=s,y.NextInAEL=z;}else{var tt=s.NextInAEL,ft=s.PrevInAEL;s.NextInAEL=y.NextInAEL,s.NextInAEL!==null&&(s.NextInAEL.PrevInAEL=s),s.PrevInAEL=y.PrevInAEL,s.PrevInAEL!==null&&(s.PrevInAEL.NextInAEL=s),y.NextInAEL=tt,y.NextInAEL!==null&&(y.NextInAEL.PrevInAEL=y),y.PrevInAEL=ft,y.PrevInAEL!==null&&(y.PrevInAEL.NextInAEL=y);}s.PrevInAEL===null?this.m_ActiveEdges=s:y.PrevInAEL===null&&(this.m_ActiveEdges=y);}},e.ClipperBase.prototype.DeleteFromAEL=function(s){var y=s.PrevInAEL,I=s.NextInAEL;y===null&&I===null&&s!==this.m_ActiveEdges||(y!==null?y.NextInAEL=I:this.m_ActiveEdges=I,I!==null&&(I.PrevInAEL=y),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 y=new e.Maxima();if(y.X=s,this.m_Maxima===null)this.m_Maxima=y,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(s<this.m_Maxima.X)y.Next=this.m_Maxima,y.Prev=null,this.m_Maxima=y;else{for(var I=this.m_Maxima;I.Next!==null&&s>=I.Next.X;)I=I.Next;if(s===I.X)return;y.Next=I.Next,y.Prev=I,I.Next!==null&&(I.Next.Prev=y),I.Next=y;}},e.Clipper.prototype.Execute=function(){var s=arguments,y=s.length,I=s[1]instanceof e.PolyTree;if(y===4&&!I){var N=s[0],z=s[1],Z=s[2],tt=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(z),this.m_SubjFillType=Z,this.m_ClipFillType=tt,this.m_ClipType=N,this.m_UsingPolyTree=!1;try{var ft=this.ExecuteInternal();ft&&this.BuildResult(z);}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1;}return ft;}else if(y===4&&I){var N=s[0],ht=s[1],Z=s[2],tt=s[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=Z,this.m_ClipFillType=tt,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(y===2&&!I){var N=s[0],z=s[1];return this.Execute(N,z,e.PolyFillType.pftEvenOdd,e.PolyFillType.pftEvenOdd);}else if(y===2&&I){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 y=s.FirstLeft;y!==null&&(y.IsHole===s.IsHole||y.Pts===null);)y=y.FirstLeft;s.FirstLeft=y;}},e.Clipper.prototype.ExecuteInternal=function(){try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var s={},y={};if(!this.PopScanbeam(s))return!1;for(this.InsertLocalMinimaIntoAEL(s.v);this.PopScanbeam(y)||this.LocalMinimaPending();){if(this.ProcessHorizontals(),this.m_GhostJoins.length=0,!this.ProcessIntersections(y.v))return!1;this.ProcessEdgesAtTopOfScanbeam(y.v),s.v=y.v,this.InsertLocalMinimaIntoAEL(s.v);}var I,N,z;for(N=0,z=this.m_PolyOuts.length;N<z;N++)I=this.m_PolyOuts[N],!(I.Pts===null||I.IsOpen)&&(I.IsHole^this.ReverseSolution)==this.Area$1(I)>0&&this.ReversePolyPtLinks(I.Pts);for(this.JoinCommonEdges(),N=0,z=this.m_PolyOuts.length;N<z;N++)I=this.m_PolyOuts[N],I.Pts!==null&&(I.IsOpen?this.FixupOutPolyline(I):this.FixupOutPolygon(I));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,y=this.m_PolyOuts.length;s<y;++s)this.DisposeOutRec(s);e.Clear(this.m_PolyOuts);},e.Clipper.prototype.AddJoin=function(s,y,I){var N=new e.Join();N.OutPt1=s,N.OutPt2=y,N.OffPt.X=I.X,N.OffPt.Y=I.Y,e.use_xyz&&(N.OffPt.Z=I.Z),this.m_Joins.push(N);},e.Clipper.prototype.AddGhostJoin=function(s,y){var I=new e.Join();I.OutPt1=s,I.OffPt.X=y.X,I.OffPt.Y=y.Y,e.use_xyz&&(I.OffPt.Z=y.Z),this.m_GhostJoins.push(I);},e.Clipper.prototype.SetZ=function(s,y,I){if(this.ZFillFunction!==null){if(s.Z!==0||this.ZFillFunction===null)return;e.IntPoint.op_Equality(s,y.Bot)?s.Z=y.Bot.Z:e.IntPoint.op_Equality(s,y.Top)?s.Z=y.Top.Z:e.IntPoint.op_Equality(s,I.Bot)?s.Z=I.Bot.Z:e.IntPoint.op_Equality(s,I.Top)?s.Z=I.Top.Z:this.ZFillFunction(y.Bot,y.Top,I.Bot,I.Top,s);}},e.Clipper.prototype.InsertLocalMinimaIntoAEL=function(s){for(var y={},I,N;this.PopLocalMinima(s,y);){I=y.v.LeftBound,N=y.v.RightBound;var z=null;if(I===null?(this.InsertEdgeIntoAEL(N,null),this.SetWindingCount(N),this.IsContributing(N)&&(z=this.AddOutPt(N,N.Bot))):N===null?(this.InsertEdgeIntoAEL(I,null),this.SetWindingCount(I),this.IsContributing(I)&&(z=this.AddOutPt(I,I.Bot)),this.InsertScanbeam(I.Top.Y)):(this.InsertEdgeIntoAEL(I,null),this.InsertEdgeIntoAEL(N,I),this.SetWindingCount(I),N.WindCnt=I.WindCnt,N.WindCnt2=I.WindCnt2,this.IsContributing(I)&&(z=this.AddLocalMinPoly(I,N,I.Bot)),this.InsertScanbeam(I.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)),!(I===null||N===null)){if(z!==null&&e.ClipperBase.IsHorizontal(N)&&this.m_GhostJoins.length>0&&N.WindDelta!==0)for(var Z=0,tt=this.m_GhostJoins.length;Z<tt;Z++){var ft=this.m_GhostJoins[Z];this.HorzSegmentsOverlap(ft.OutPt1.Pt.X,ft.OffPt.X,N.Bot.X,N.Top.X)&&this.AddJoin(ft.OutPt1,z,ft.OffPt);}if(I.OutIdx>=0&&I.PrevInAEL!==null&&I.PrevInAEL.Curr.X===I.Bot.X&&I.PrevInAEL.OutIdx>=0&&e.ClipperBase.SlopesEqual5(I.PrevInAEL.Curr,I.PrevInAEL.Top,I.Curr,I.Top,this.m_UseFullRange)&&I.WindDelta!==0&&I.PrevInAEL.WindDelta!==0){var ht=this.AddOutPt(I.PrevInAEL,I.Bot);this.AddJoin(z,ht,I.Top);}if(I.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(z,ht,N.Top);}var It=I.NextInAEL;if(It!==null)for(;It!==N;)this.IntersectEdges(N,It,I.Curr),It=It.NextInAEL;}}}},e.Clipper.prototype.InsertEdgeIntoAEL=function(s,y){if(this.m_ActiveEdges===null)s.PrevInAEL=null,s.NextInAEL=null,this.m_ActiveEdges=s;else if(y===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(y===null&&(y=this.m_ActiveEdges);y.NextInAEL!==null&&!this.E2InsertsBeforeE1(y.NextInAEL,s);)y=y.NextInAEL;s.NextInAEL=y.NextInAEL,y.NextInAEL!==null&&(y.NextInAEL.PrevInAEL=s),s.PrevInAEL=y,y.NextInAEL=s;}},e.Clipper.prototype.E2InsertsBeforeE1=function(s,y){return y.Curr.X===s.Curr.X?y.Top.Y>s.Top.Y?y.Top.X<e.Clipper.TopX(s,y.Top.Y):s.Top.X>e.Clipper.TopX(y,s.Top.Y):y.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 y,I;switch(s.PolyTyp===e.PolyType.ptSubject?(y=this.m_SubjFillType,I=this.m_ClipFillType):(y=this.m_ClipFillType,I=this.m_SubjFillType),y){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(I){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(I){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(I){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(I){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(I){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 y=s.PrevInAEL;y!==null&&(y.PolyTyp!==s.PolyTyp||y.WindDelta===0);)y=y.PrevInAEL;if(y===null){var I=s.PolyTyp===e.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;s.WindDelta===0?s.WindCnt=I===e.PolyFillType.pftNegative?-1:1:s.WindCnt=s.WindDelta,s.WindCnt2=0,y=this.m_ActiveEdges;}else if(s.WindDelta===0&&this.m_ClipType!==e.ClipType.ctUnion)s.WindCnt=1,s.WindCnt2=y.WindCnt2,y=y.NextInAEL;else if(this.IsEvenOddFillType(s)){if(s.WindDelta===0){for(var N=!0,z=y.PrevInAEL;z!==null;)z.PolyTyp===y.PolyTyp&&z.WindDelta!==0&&(N=!N),z=z.PrevInAEL;s.WindCnt=N?0:1;}else s.WindCnt=s.WindDelta;s.WindCnt2=y.WindCnt2,y=y.NextInAEL;}else y.WindCnt*y.WindDelta<0?Math.abs(y.WindCnt)>1?y.WindDelta*s.WindDelta<0?s.WindCnt=y.WindCnt:s.WindCnt=y.WindCnt+s.WindDelta:s.WindCnt=s.WindDelta===0?1:s.WindDelta:s.WindDelta===0?s.WindCnt=y.WindCnt<0?y.WindCnt-1:y.WindCnt+1:y.WindDelta*s.WindDelta<0?s.WindCnt=y.WindCnt:s.WindCnt=y.WindCnt+s.WindDelta,s.WindCnt2=y.WindCnt2,y=y.NextInAEL;if(this.IsEvenOddAltFillType(s))for(;y!==s;)y.WindDelta!==0&&(s.WindCnt2=s.WindCnt2===0?1:0),y=y.NextInAEL;else for(;y!==s;)s.WindCnt2+=y.WindDelta,y=y.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 y=s.v;return this.m_SortedEdges=s.v.NextInSEL,this.m_SortedEdges!==null&&(this.m_SortedEdges.PrevInSEL=null),y.NextInSEL=null,y.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,y){if(!(s.NextInSEL===null&&s.PrevInSEL===null)&&!(y.NextInSEL===null&&y.PrevInSEL===null)){if(s.NextInSEL===y){var I=y.NextInSEL;I!==null&&(I.PrevInSEL=s);var N=s.PrevInSEL;N!==null&&(N.NextInSEL=y),y.PrevInSEL=N,y.NextInSEL=s,s.PrevInSEL=y,s.NextInSEL=I;}else if(y.NextInSEL===s){var I=s.NextInSEL;I!==null&&(I.PrevInSEL=y);var N=y.PrevInSEL;N!==null&&(N.NextInSEL=s),s.PrevInSEL=N,s.NextInSEL=y,y.PrevInSEL=s,y.NextInSEL=I;}else{var I=s.NextInSEL,N=s.PrevInSEL;s.NextInSEL=y.NextInSEL,s.NextInSEL!==null&&(s.NextInSEL.PrevInSEL=s),s.PrevInSEL=y.PrevInSEL,s.PrevInSEL!==null&&(s.PrevInSEL.NextInSEL=s),y.NextInSEL=I,y.NextInSEL!==null&&(y.NextInSEL.PrevInSEL=y),y.PrevInSEL=N,y.PrevInSEL!==null&&(y.PrevInSEL.NextInSEL=y);}s.PrevInSEL===null?this.m_SortedEdges=s:y.PrevInSEL===null&&(this.m_SortedEdges=y);}},e.Clipper.prototype.AddLocalMaxPoly=function(s,y,I){this.AddOutPt(s,I),y.WindDelta===0&&this.AddOutPt(y,I),s.OutIdx===y.OutIdx?(s.OutIdx=-1,y.OutIdx=-1):s.OutIdx<y.OutIdx?this.AppendPolygon(s,y):this.AppendPolygon(y,s);},e.Clipper.prototype.AddLocalMinPoly=function(s,y,I){var N,z,Z;if(e.ClipperBase.IsHorizontal(y)||s.Dx>y.Dx?(N=this.AddOutPt(s,I),y.OutIdx=s.OutIdx,s.Side=e.EdgeSide.esLeft,y.Side=e.EdgeSide.esRight,z=s,z.PrevInAEL===y?Z=y.PrevInAEL:Z=z.PrevInAEL):(N=this.AddOutPt(y,I),s.OutIdx=y.OutIdx,s.Side=e.EdgeSide.esRight,y.Side=e.EdgeSide.esLeft,z=y,z.PrevInAEL===s?Z=s.PrevInAEL:Z=z.PrevInAEL),Z!==null&&Z.OutIdx>=0&&Z.Top.Y<I.Y&&z.Top.Y<I.Y){var tt=e.Clipper.TopX(Z,I.Y),ft=e.Clipper.TopX(z,I.Y);if(tt===ft&&z.WindDelta!==0&&Z.WindDelta!==0&&e.ClipperBase.SlopesEqual5(new e.IntPoint2(tt,I.Y),Z.Top,new e.IntPoint2(ft,I.Y),z.Top,this.m_UseFullRange)){var ht=this.AddOutPt(Z,I);this.AddJoin(N,ht,z.Top);}}return N;},e.Clipper.prototype.AddOutPt=function(s,y){if(s.OutIdx<0){var I=this.CreateOutRec();I.IsOpen=s.WindDelta===0;var N=new e.OutPt();return I.Pts=N,N.Idx=I.Idx,N.Pt.X=y.X,N.Pt.Y=y.Y,e.use_xyz&&(N.Pt.Z=y.Z),N.Next=N,N.Prev=N,I.IsOpen||this.SetHoleState(s,I),s.OutIdx=I.Idx,N;}else{var I=this.m_PolyOuts[s.OutIdx],z=I.Pts,Z=s.Side===e.EdgeSide.esLeft;if(Z&&e.IntPoint.op_Equality(y,z.Pt))return z;if(!Z&&e.IntPoint.op_Equality(y,z.Prev.Pt))return z.Prev;var N=new e.OutPt();return N.Idx=I.Idx,N.Pt.X=y.X,N.Pt.Y=y.Y,e.use_xyz&&(N.Pt.Z=y.Z),N.Next=z,N.Prev=z.Prev,N.Prev.Next=N,z.Prev=N,Z&&(I.Pts=N),N;}},e.Clipper.prototype.GetLastOutPt=function(s){var y=this.m_PolyOuts[s.OutIdx];return s.Side===e.EdgeSide.esLeft?y.Pts:y.Pts.Prev;},e.Clipper.prototype.SwapPoints=function(s,y){var I=new e.IntPoint1(s.Value);s.Value.X=y.Value.X,s.Value.Y=y.Value.Y,e.use_xyz&&(s.Value.Z=y.Value.Z),y.Value.X=I.X,y.Value.Y=I.Y,e.use_xyz&&(y.Value.Z=I.Z);},e.Clipper.prototype.HorzSegmentsOverlap=function(s,y,I,N){var z;return s>y&&(z=s,s=y,y=z),I>N&&(z=I,I=N,N=z),s<N&&I<y;},e.Clipper.prototype.SetHoleState=function(s,y){for(var I=s.PrevInAEL,N=null;I!==null;)I.OutIdx>=0&&I.WindDelta!==0&&(N===null?N=I:N.OutIdx===I.OutIdx&&(N=null)),I=I.PrevInAEL;N===null?(y.FirstLeft=null,y.IsHole=!1):(y.FirstLeft=this.m_PolyOuts[N.OutIdx],y.IsHole=!y.FirstLeft.IsHole);},e.Clipper.prototype.GetDx=function(s,y){return s.Y===y.Y?e.ClipperBase.horizontal:(y.X-s.X)/(y.Y-s.Y);},e.Clipper.prototype.FirstIsBottomPt=function(s,y){for(var I=s.Prev;e.IntPoint.op_Equality(I.Pt,s.Pt)&&I!==s;)I=I.Prev;var N=Math.abs(this.GetDx(s.Pt,I.Pt));for(I=s.Next;e.IntPoint.op_Equality(I.Pt,s.Pt)&&I!==s;)I=I.Next;var z=Math.abs(this.GetDx(s.Pt,I.Pt));for(I=y.Prev;e.IntPoint.op_Equality(I.Pt,y.Pt)&&I!==y;)I=I.Prev;var Z=Math.abs(this.GetDx(y.Pt,I.Pt));for(I=y.Next;e.IntPoint.op_Equality(I.Pt,y.Pt)&&I!==y;)I=I.Next;var tt=Math.abs(this.GetDx(y.Pt,I.Pt));return Math.max(N,z)===Math.max(Z,tt)&&Math.min(N,z)===Math.min(Z,tt)?this.Area(s)>0:N>=Z&&N>=tt||z>=Z&&z>=tt;},e.Clipper.prototype.GetBottomPt=function(s){for(var y=null,I=s.Next;I!==s;)I.Pt.Y>s.Pt.Y?(s=I,y=null):I.Pt.Y===s.Pt.Y&&I.Pt.X<=s.Pt.X&&(I.Pt.X<s.Pt.X?(y=null,s=I):I.Next!==s&&I.Prev!==s&&(y=I)),I=I.Next;if(y!==null)for(;y!==I;)for(this.FirstIsBottomPt(I,y)||(s=y),y=y.Next;e.IntPoint.op_Inequality(y.Pt,s.Pt);)y=y.Next;return s;},e.Clipper.prototype.GetLowermostRec=function(s,y){s.BottomPt===null&&(s.BottomPt=this.GetBottomPt(s.Pts)),y.BottomPt===null&&(y.BottomPt=this.GetBottomPt(y.Pts));var I=s.BottomPt,N=y.BottomPt;return I.Pt.Y>N.Pt.Y?s:I.Pt.Y<N.Pt.Y?y:I.Pt.X<N.Pt.X?s:I.Pt.X>N.Pt.X||I.Next===I?y:N.Next===N||this.FirstIsBottomPt(I,N)?s:y;},e.Clipper.prototype.OutRec1RightOfOutRec2=function(s,y){do if(s=s.FirstLeft,s===y)return!0;while(s!==null);return!1;},e.Clipper.prototype.GetOutRec=function(s){for(var y=this.m_PolyOuts[s];y!==this.m_PolyOuts[y.Idx];)y=this.m_PolyOuts[y.Idx];return y;},e.Clipper.prototype.AppendPolygon=function(s,y){var I=this.m_PolyOuts[s.OutIdx],N=this.m_PolyOuts[y.OutIdx],z;this.OutRec1RightOfOutRec2(I,N)?z=N:this.OutRec1RightOfOutRec2(N,I)?z=I:z=this.GetLowermostRec(I,N);var Z=I.Pts,tt=Z.Prev,ft=N.Pts,ht=ft.Prev;s.Side===e.EdgeSide.esLeft?y.Side===e.EdgeSide.esLeft?(this.ReversePolyPtLinks(ft),ft.Next=Z,Z.Prev=ft,tt.Next=ht,ht.Prev=tt,I.Pts=ht):(ht.Next=Z,Z.Prev=ht,ft.Prev=tt,tt.Next=ft,I.Pts=ft):y.Side===e.EdgeSide.esRight?(this.ReversePolyPtLinks(ft),tt.Next=ht,ht.Prev=tt,ft.Next=Z,Z.Prev=ft):(tt.Next=ft,ft.Prev=tt,Z.Prev=ht,ht.Next=Z),I.BottomPt=null,z===N&&(N.FirstLeft!==I&&(I.FirstLeft=N.FirstLeft),I.IsHole=N.IsHole),N.Pts=null,N.BottomPt=null,N.FirstLeft=I;var It=s.OutIdx,Rt=y.OutIdx;s.OutIdx=-1,y.OutIdx=-1;for(var Lt=this.m_ActiveEdges;Lt!==null;){if(Lt.OutIdx===Rt){Lt.OutIdx=It,Lt.Side=s.Side;break;}Lt=Lt.NextInAEL;}N.Idx=I.Idx;},e.Clipper.prototype.ReversePolyPtLinks=function(s){if(s!==null){var y,I;y=s;do I=y.Next,y.Next=y.Prev,y.Prev=I,y=I;while(y!==s);}},e.Clipper.SwapSides=function(s,y){var I=s.Side;s.Side=y.Side,y.Side=I;},e.Clipper.SwapPolyIndexes=function(s,y){var I=s.OutIdx;s.OutIdx=y.OutIdx,y.OutIdx=I;},e.Clipper.prototype.IntersectEdges=function(s,y,I){var N=s.OutIdx>=0,z=y.OutIdx>=0;if(e.use_xyz&&this.SetZ(I,s,y),e.use_lines&&(s.WindDelta===0||y.WindDelta===0)){if(s.WindDelta===0&&y.WindDelta===0)return;s.PolyTyp===y.PolyTyp&&s.WindDelta!==y.WindDelta&&this.m_ClipType===e.ClipType.ctUnion?s.WindDelta===0?z&&(this.AddOutPt(s,I),N&&(s.OutIdx=-1)):N&&(this.AddOutPt(y,I),z&&(y.OutIdx=-1)):s.PolyTyp!==y.PolyTyp&&(s.WindDelta===0&&Math.abs(y.WindCnt)===1&&(this.m_ClipType!==e.ClipType.ctUnion||y.WindCnt2===0)?(this.AddOutPt(s,I),N&&(s.OutIdx=-1)):y.WindDelta===0&&Math.abs(s.WindCnt)===1&&(this.m_ClipType!==e.ClipType.ctUnion||s.WindCnt2===0)&&(this.AddOutPt(y,I),z&&(y.OutIdx=-1)));return;}if(s.PolyTyp===y.PolyTyp){if(this.IsEvenOddFillType(s)){var Z=s.WindCnt;s.WindCnt=y.WindCnt,y.WindCnt=Z;}else s.WindCnt+y.WindDelta===0?s.WindCnt=-s.WindCnt:s.WindCnt+=y.WindDelta,y.WindCnt-s.WindDelta===0?y.WindCnt=-y.WindCnt:y.WindCnt-=s.WindDelta;}else this.IsEvenOddFillType(y)?s.WindCnt2=s.WindCnt2===0?1:0:s.WindCnt2+=y.WindDelta,this.IsEvenOddFillType(s)?y.WindCnt2=y.WindCnt2===0?1:0:y.WindCnt2-=s.WindDelta;var tt,ft,ht,It;s.PolyTyp===e.PolyType.ptSubject?(tt=this.m_SubjFillType,ht=this.m_ClipFillType):(tt=this.m_ClipFillType,ht=this.m_SubjFillType),y.PolyTyp===e.PolyType.ptSubject?(ft=this.m_SubjFillType,It=this.m_ClipFillType):(ft=this.m_ClipFillType,It=this.m_SubjFillType);var Rt,Lt;switch(tt){case e.PolyFillType.pftPositive:Rt=s.WindCnt;break;case e.PolyFillType.pftNegative:Rt=-s.WindCnt;break;default:Rt=Math.abs(s.WindCnt);break;}switch(ft){case e.PolyFillType.pftPositive:Lt=y.WindCnt;break;case e.PolyFillType.pftNegative:Lt=-y.WindCnt;break;default:Lt=Math.abs(y.WindCnt);break;}if(N&&z)Rt!==0&&Rt!==1||Lt!==0&&Lt!==1||s.PolyTyp!==y.PolyTyp&&this.m_ClipType!==e.ClipType.ctXor?this.AddLocalMaxPoly(s,y,I):(this.AddOutPt(s,I),this.AddOutPt(y,I),e.Clipper.SwapSides(s,y),e.Clipper.SwapPolyIndexes(s,y));else if(N)(Lt===0||Lt===1)&&(this.AddOutPt(s,I),e.Clipper.SwapSides(s,y),e.Clipper.SwapPolyIndexes(s,y));else if(z)(Rt===0||Rt===1)&&(this.AddOutPt(y,I),e.Clipper.SwapSides(s,y),e.Clipper.SwapPolyIndexes(s,y));else if((Rt===0||Rt===1)&&(Lt===0||Lt===1)){var Wt,Yt;switch(ht){case e.PolyFillType.pftPositive:Wt=s.WindCnt2;break;case e.PolyFillType.pftNegative:Wt=-s.WindCnt2;break;default:Wt=Math.abs(s.WindCnt2);break;}switch(It){case e.PolyFillType.pftPositive:Yt=y.WindCnt2;break;case e.PolyFillType.pftNegative:Yt=-y.WindCnt2;break;default:Yt=Math.abs(y.WindCnt2);break;}if(s.PolyTyp!==y.PolyTyp)this.AddLocalMinPoly(s,y,I);else if(Rt===1&&Lt===1)switch(this.m_ClipType){case e.ClipType.ctIntersection:Wt>0&&Yt>0&&this.AddLocalMinPoly(s,y,I);break;case e.ClipType.ctUnion:Wt<=0&&Yt<=0&&this.AddLocalMinPoly(s,y,I);break;case e.ClipType.ctDifference:(s.PolyTyp===e.PolyType.ptClip&&Wt>0&&Yt>0||s.PolyTyp===e.PolyType.ptSubject&&Wt<=0&&Yt<=0)&&this.AddLocalMinPoly(s,y,I);break;case e.ClipType.ctXor:this.AddLocalMinPoly(s,y,I);break;}else e.Clipper.SwapSides(s,y);}},e.Clipper.prototype.DeleteFromSEL=function(s){var y=s.PrevInSEL,I=s.NextInSEL;y===null&&I===null&&s!==this.m_SortedEdges||(y!==null?y.NextInSEL=I:this.m_SortedEdges=I,I!==null&&(I.PrevInSEL=y),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,y){s.Bot.X<s.Top.X?(y.Left=s.Bot.X,y.Right=s.Top.X,y.Dir=e.Direction.dLeftToRight):(y.Left=s.Top.X,y.Right=s.Bot.X,y.Dir=e.Direction.dRightToLeft);},e.Clipper.prototype.ProcessHorizontal=function(s){var y={Dir:null,Left:null,Right:null};this.GetHorzDirection(s,y);for(var I=y.Dir,N=y.Left,z=y.Right,Z=s.WindDelta===0,tt=s,ft=null;tt.NextInLML!==null&&e.ClipperBase.IsHorizontal(tt.NextInLML);)tt=tt.NextInLML;tt.NextInLML===null&&(ft=this.GetMaximaPair(tt));var ht=this.m_Maxima;if(ht!==null)if(I===e.Direction.dLeftToRight){for(;ht!==null&&ht.X<=s.Bot.X;)ht=ht.Next;ht!==null&&ht.X>=tt.Top.X&&(ht=null);}else{for(;ht.Next!==null&&ht.Next.X<s.Bot.X;)ht=ht.Next;ht.X<=tt.Top.X&&(ht=null);}for(var It=null;;){for(var Rt=s===tt,Lt=this.GetNextInAEL(s,I);Lt!==null;){if(ht!==null)if(I===e.Direction.dLeftToRight)for(;ht!==null&&ht.X<Lt.Curr.X;)s.OutIdx>=0&&!Z&&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&&!Z&&this.AddOutPt(s,new e.IntPoint2(ht.X,s.Bot.Y)),ht=ht.Prev;if(I===e.Direction.dLeftToRight&&Lt.Curr.X>z||I===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&&!Z){e.use_xyz&&(I===e.Direction.dLeftToRight?this.SetZ(Lt.Curr,s,Lt):this.SetZ(Lt.Curr,Lt,s)),It=this.AddOutPt(s,Lt.Curr);for(var Wt=this.m_SortedEdges;Wt!==null;){if(Wt.OutIdx>=0&&this.HorzSegmentsOverlap(s.Bot.X,s.Top.X,Wt.Bot.X,Wt.Top.X)){var Yt=this.GetLastOutPt(Wt);this.AddJoin(Yt,It,Wt.Top);}Wt=Wt.NextInSEL;}this.AddGhostJoin(It,s.Bot);}if(Lt===ft&&Rt){s.OutIdx>=0&&this.AddLocalMaxPoly(s,ft,s.Top),this.DeleteFromAEL(s),this.DeleteFromAEL(ft);return;}if(I===e.Direction.dLeftToRight){var Vt=new e.IntPoint2(Lt.Curr.X,s.Curr.Y);this.IntersectEdges(s,Lt,Vt);}else{var Vt=new e.IntPoint2(Lt.Curr.X,s.Curr.Y);this.IntersectEdges(Lt,s,Vt);}var Kt=this.GetNextInAEL(Lt,I);this.SwapPositionsInAEL(s,Lt),Lt=Kt;}if(s.NextInLML===null||!e.ClipperBase.IsHorizontal(s.NextInLML))break;s=this.UpdateEdgeIntoAEL(s),s.OutIdx>=0&&this.AddOutPt(s,s.Bot),y={Dir:I,Left:N,Right:z},this.GetHorzDirection(s,y),I=y.Dir,N=y.Left,z=y.Right;}if(s.OutIdx>=0&&It===null){It=this.GetLastOutPt(s);for(var Wt=this.m_SortedEdges;Wt!==null;){if(Wt.OutIdx>=0&&this.HorzSegmentsOverlap(s.Bot.X,s.Top.X,Wt.Bot.X,Wt.Top.X)){var Yt=this.GetLastOutPt(Wt);this.AddJoin(Yt,It,Wt.Top);}Wt=Wt.NextInSEL;}this.AddGhostJoin(It,s.Top);}if(s.NextInLML!==null){if(s.OutIdx>=0){if(It=this.AddOutPt(s,s.Top),s=this.UpdateEdgeIntoAEL(s),s.WindDelta===0)return;var ee=s.PrevInAEL,Kt=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(It,Yt,s.Top);}else if(Kt!==null&&Kt.Curr.X===s.Bot.X&&Kt.Curr.Y===s.Bot.Y&&Kt.WindDelta!==0&&Kt.OutIdx>=0&&Kt.Curr.Y>Kt.Top.Y&&e.ClipperBase.SlopesEqual3(s,Kt,this.m_UseFullRange)){var Yt=this.AddOutPt(Kt,s.Bot);this.AddJoin(It,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,y){return y===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,y){return s!==null&&s.Top.Y===y&&s.NextInLML===null;},e.Clipper.prototype.IsIntermediate=function(s,y){return s.Top.Y===y&&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 y=this.GetMaximaPair(s);return y===null||y.OutIdx===e.ClipperBase.Skip||y.NextInAEL===y.PrevInAEL&&!e.ClipperBase.IsHorizontal(y)?null:y;},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 y=this.m_ActiveEdges;for(this.m_SortedEdges=y;y!==null;)y.PrevInSEL=y.PrevInAEL,y.NextInSEL=y.NextInAEL,y.Curr.X=e.Clipper.TopX(y,s),y=y.NextInAEL;for(var I=!0;I&&this.m_SortedEdges!==null;){for(I=!1,y=this.m_SortedEdges;y.NextInSEL!==null;){var N=y.NextInSEL,z=new e.IntPoint0();if(y.Curr.X>N.Curr.X){this.IntersectPoint(y,N,z),z.Y<s&&(z=new e.IntPoint2(e.Clipper.TopX(y,s),s));var Z=new e.IntersectNode();Z.Edge1=y,Z.Edge2=N,Z.Pt.X=z.X,Z.Pt.Y=z.Y,e.use_xyz&&(Z.Pt.Z=z.Z),this.m_IntersectList.push(Z),this.SwapPositionsInSEL(y,N),I=!0;}else y=N;}if(y.PrevInSEL!==null)y.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,y){return y.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,y=0;y<s;y++){if(!this.EdgesAdjacent(this.m_IntersectList[y])){for(var I=y+1;I<s&&!this.EdgesAdjacent(this.m_IntersectList[I]);)I++;if(I===s)return!1;var N=this.m_IntersectList[y];this.m_IntersectList[y]=this.m_IntersectList[I],this.m_IntersectList[I]=N;}this.SwapPositionsInSEL(this.m_IntersectList[y].Edge1,this.m_IntersectList[y].Edge2);}return!0;},e.Clipper.prototype.ProcessIntersectList=function(){for(var s=0,y=this.m_IntersectList.length;s<y;s++){var I=this.m_IntersectList[s];this.IntersectEdges(I.Edge1,I.Edge2,I.Pt),this.SwapPositionsInAEL(I.Edge1,I.Edge2);}this.m_IntersectList.length=0;};var Js=function Js(s){return s<0?Math.ceil(s-0.5):Math.round(s);},Qs=function Qs(s){return s<0?Math.ceil(s-0.5):Math.floor(s+0.5);},qs=function qs(s){return s<0?-Math.round(Math.abs(s)):Math.round(s);},_s=function _s(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=Js:i.chromium?e.Clipper.Round=qs:i.safari?e.Clipper.Round=_s:e.Clipper.Round=Qs,e.Clipper.TopX=function(s,y){return y===s.Top.Y?s.Top.X:s.Bot.X+e.Clipper.Round(s.Dx*(y-s.Bot.Y));},e.Clipper.prototype.IntersectPoint=function(s,y,I){I.X=0,I.Y=0;var N,z;if(s.Dx===y.Dx){I.Y=s.Curr.Y,I.X=e.Clipper.TopX(s,I.Y);return;}if(s.Delta.X===0)I.X=s.Bot.X,e.ClipperBase.IsHorizontal(y)?I.Y=y.Bot.Y:(z=y.Bot.Y-y.Bot.X/y.Dx,I.Y=e.Clipper.Round(I.X/y.Dx+z));else if(y.Delta.X===0)I.X=y.Bot.X,e.ClipperBase.IsHorizontal(s)?I.Y=s.Bot.Y:(N=s.Bot.Y-s.Bot.X/s.Dx,I.Y=e.Clipper.Round(I.X/s.Dx+N));else{N=s.Bot.X-s.Bot.Y*s.Dx,z=y.Bot.X-y.Bot.Y*y.Dx;var Z=(z-N)/(s.Dx-y.Dx);I.Y=e.Clipper.Round(Z),Math.abs(s.Dx)<Math.abs(y.Dx)?I.X=e.Clipper.Round(s.Dx*Z+N):I.X=e.Clipper.Round(y.Dx*Z+z);}if(I.Y<s.Top.Y||I.Y<y.Top.Y){if(s.Top.Y>y.Top.Y)return I.Y=s.Top.Y,I.X=e.Clipper.TopX(y,s.Top.Y),I.X<s.Top.X;I.Y=y.Top.Y,Math.abs(s.Dx)<Math.abs(y.Dx)?I.X=e.Clipper.TopX(s,I.Y):I.X=e.Clipper.TopX(y,I.Y);}I.Y>s.Curr.Y&&(I.Y=s.Curr.Y,Math.abs(s.Dx)>Math.abs(y.Dx)?I.X=e.Clipper.TopX(y,I.Y):I.X=e.Clipper.TopX(s,I.Y));},e.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(s){for(var y=this.m_ActiveEdges;y!==null;){var I=this.IsMaxima(y,s);if(I){var N=this.GetMaximaPairEx(y);I=N===null||!e.ClipperBase.IsHorizontal(N);}if(I){this.StrictlySimple&&this.InsertMaxima(y.Top.X);var z=y.PrevInAEL;this.DoMaxima(y),z===null?y=this.m_ActiveEdges:y=z.NextInAEL;}else{if(this.IsIntermediate(y,s)&&e.ClipperBase.IsHorizontal(y.NextInLML)?(y=this.UpdateEdgeIntoAEL(y),y.OutIdx>=0&&this.AddOutPt(y,y.Bot),this.AddEdgeToSEL(y)):(y.Curr.X=e.Clipper.TopX(y,s),y.Curr.Y=s),e.use_xyz&&(y.Top.Y===s?y.Curr.Z=y.Top.Z:y.Bot.Y===s?y.Curr.Z=y.Bot.Z:y.Curr.Z=0),this.StrictlySimple){var z=y.PrevInAEL;if(y.OutIdx>=0&&y.WindDelta!==0&&z!==null&&z.OutIdx>=0&&z.Curr.X===y.Curr.X&&z.WindDelta!==0){var Z=new e.IntPoint1(y.Curr);e.use_xyz&&this.SetZ(Z,z,y);var tt=this.AddOutPt(z,Z),ft=this.AddOutPt(y,Z);this.AddJoin(tt,ft,Z);}}y=y.NextInAEL;}}for(this.ProcessHorizontals(),this.m_Maxima=null,y=this.m_ActiveEdges;y!==null;){if(this.IsIntermediate(y,s)){var tt=null;y.OutIdx>=0&&(tt=this.AddOutPt(y,y.Top)),y=this.UpdateEdgeIntoAEL(y);var z=y.PrevInAEL,ht=y.NextInAEL;if(z!==null&&z.Curr.X===y.Bot.X&&z.Curr.Y===y.Bot.Y&&tt!==null&&z.OutIdx>=0&&z.Curr.Y===z.Top.Y&&e.ClipperBase.SlopesEqual5(y.Curr,y.Top,z.Curr,z.Top,this.m_UseFullRange)&&y.WindDelta!==0&&z.WindDelta!==0){var ft=this.AddOutPt(ePrev2,y.Bot);this.AddJoin(tt,ft,y.Top);}else if(ht!==null&&ht.Curr.X===y.Bot.X&&ht.Curr.Y===y.Bot.Y&&tt!==null&&ht.OutIdx>=0&&ht.Curr.Y===ht.Top.Y&&e.ClipperBase.SlopesEqual5(y.Curr,y.Top,ht.Curr,ht.Top,this.m_UseFullRange)&&y.WindDelta!==0&&ht.WindDelta!==0){var ft=this.AddOutPt(ht,y.Bot);this.AddJoin(tt,ft,y.Top);}}y=y.NextInAEL;}},e.Clipper.prototype.DoMaxima=function(s){var y=this.GetMaximaPairEx(s);if(y===null){s.OutIdx>=0&&this.AddOutPt(s,s.Top),this.DeleteFromAEL(s);return;}for(var I=s.NextInAEL;I!==null&&I!==y;)this.IntersectEdges(s,I,s.Top),this.SwapPositionsInAEL(s,I),I=s.NextInAEL;s.OutIdx===-1&&y.OutIdx===-1?(this.DeleteFromAEL(s),this.DeleteFromAEL(y)):s.OutIdx>=0&&y.OutIdx>=0?(s.OutIdx>=0&&this.AddLocalMaxPoly(s,y,s.Top),this.DeleteFromAEL(s),this.DeleteFromAEL(y)):e.use_lines&&s.WindDelta===0?(s.OutIdx>=0&&(this.AddOutPt(s,s.Top),s.OutIdx=e.ClipperBase.Unassigned),this.DeleteFromAEL(s),y.OutIdx>=0&&(this.AddOutPt(y,s.Top),y.OutIdx=e.ClipperBase.Unassigned),this.DeleteFromAEL(y)):e.Error("DoMaxima error");},e.Clipper.ReversePaths=function(s){for(var y=0,I=s.length;y<I;y++)s[y].reverse();},e.Clipper.Orientation=function(s){return e.Clipper.Area(s)>=0;},e.Clipper.prototype.PointCount=function(s){if(s===null)return 0;var y=0,I=s;do y++,I=I.Next;while(I!==s);return y;},e.Clipper.prototype.BuildResult=function(s){e.Clear(s);for(var y=0,I=this.m_PolyOuts.length;y<I;y++){var N=this.m_PolyOuts[y];if(N.Pts!==null){var z=N.Pts.Prev,Z=this.PointCount(z);if(!(Z<2)){for(var tt=new Array(Z),ft=0;ft<Z;ft++)tt[ft]=z.Pt,z=z.Prev;s.push(tt);}}}},e.Clipper.prototype.BuildResult2=function(s){s.Clear();for(var y=0,I=this.m_PolyOuts.length;y<I;y++){var N=this.m_PolyOuts[y],z=this.PointCount(N.Pts);if(!(N.IsOpen&&z<2||!N.IsOpen&&z<3)){this.FixHoleLinkage(N);var Z=new e.PolyNode();s.m_AllPolys.push(Z),N.PolyNode=Z,Z.m_polygon.length=z;for(var tt=N.Pts.Prev,ft=0;ft<z;ft++)Z.m_polygon[ft]=tt.Pt,tt=tt.Prev;}}for(var y=0,I=this.m_PolyOuts.length;y<I;y++){var N=this.m_PolyOuts[y];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 y=s.Pts,I=y.Prev;y!==I;)if(y=y.Next,e.IntPoint.op_Equality(y.Pt,y.Prev.Pt)){y===I&&(I=y.Prev);var N=y.Prev;N.Next=y.Next,y.Next.Prev=N,y=N;}y===y.Prev&&(s.Pts=null);},e.Clipper.prototype.FixupOutPolygon=function(s){var y=null;s.BottomPt=null;for(var I=s.Pts,N=this.PreserveCollinear||this.StrictlySimple;;){if(I.Prev===I||I.Prev===I.Next){s.Pts=null;return;}if(e.IntPoint.op_Equality(I.Pt,I.Next.Pt)||e.IntPoint.op_Equality(I.Pt,I.Prev.Pt)||e.ClipperBase.SlopesEqual4(I.Prev.Pt,I.Pt,I.Next.Pt,this.m_UseFullRange)&&(!N||!this.Pt2IsBetweenPt1AndPt3(I.Prev.Pt,I.Pt,I.Next.Pt)))y=null,I.Prev.Next=I.Next,I.Next.Prev=I.Prev,I=I.Prev;else{if(I===y)break;y===null&&(y=I),I=I.Next;}}s.Pts=I;},e.Clipper.prototype.DupOutPt=function(s,y){var I=new e.OutPt();return I.Pt.X=s.Pt.X,I.Pt.Y=s.Pt.Y,e.use_xyz&&(I.Pt.Z=s.Pt.Z),I.Idx=s.Idx,y?(I.Next=s.Next,I.Prev=s,s.Next.Prev=I,s.Next=I):(I.Prev=s.Prev,I.Next=s,s.Prev.Next=I,s.Prev=I),I;},e.Clipper.prototype.GetOverlap=function(s,y,I,N,z){return s<y?I<N?(z.Left=Math.max(s,I),z.Right=Math.min(y,N)):(z.Left=Math.max(s,N),z.Right=Math.min(y,I)):I<N?(z.Left=Math.max(y,I),z.Right=Math.min(s,N)):(z.Left=Math.max(y,N),z.Right=Math.min(s,I)),z.Left<z.Right;},e.Clipper.prototype.JoinHorz=function(s,y,I,N,z,Z){var tt=s.Pt.X>y.Pt.X?e.Direction.dRightToLeft:e.Direction.dLeftToRight,ft=I.Pt.X>N.Pt.X?e.Direction.dRightToLeft:e.Direction.dLeftToRight;if(tt===ft)return!1;if(tt===e.Direction.dLeftToRight){for(;s.Next.Pt.X<=z.X&&s.Next.Pt.X>=s.Pt.X&&s.Next.Pt.Y===z.Y;)s=s.Next;Z&&s.Pt.X!==z.X&&(s=s.Next),y=this.DupOutPt(s,!Z),e.IntPoint.op_Inequality(y.Pt,z)&&(s=y,s.Pt.X=z.X,s.Pt.Y=z.Y,e.use_xyz&&(s.Pt.Z=z.Z),y=this.DupOutPt(s,!Z));}else{for(;s.Next.Pt.X>=z.X&&s.Next.Pt.X<=s.Pt.X&&s.Next.Pt.Y===z.Y;)s=s.Next;!Z&&s.Pt.X!==z.X&&(s=s.Next),y=this.DupOutPt(s,Z),e.IntPoint.op_Inequality(y.Pt,z)&&(s=y,s.Pt.X=z.X,s.Pt.Y=z.Y,e.use_xyz&&(s.Pt.Z=z.Z),y=this.DupOutPt(s,Z));}if(ft===e.Direction.dLeftToRight){for(;I.Next.Pt.X<=z.X&&I.Next.Pt.X>=I.Pt.X&&I.Next.Pt.Y===z.Y;)I=I.Next;Z&&I.Pt.X!==z.X&&(I=I.Next),N=this.DupOutPt(I,!Z),e.IntPoint.op_Inequality(N.Pt,z)&&(I=N,I.Pt.X=z.X,I.Pt.Y=z.Y,e.use_xyz&&(I.Pt.Z=z.Z),N=this.DupOutPt(I,!Z));}else{for(;I.Next.Pt.X>=z.X&&I.Next.Pt.X<=I.Pt.X&&I.Next.Pt.Y===z.Y;)I=I.Next;!Z&&I.Pt.X!==z.X&&(I=I.Next),N=this.DupOutPt(I,Z),e.IntPoint.op_Inequality(N.Pt,z)&&(I=N,I.Pt.X=z.X,I.Pt.Y=z.Y,e.use_xyz&&(I.Pt.Z=z.Z),N=this.DupOutPt(I,Z));}return tt===e.Direction.dLeftToRight===Z?(s.Prev=I,I.Next=s,y.Next=N,N.Prev=y):(s.Next=I,I.Prev=s,y.Prev=N,N.Next=y),!0;},e.Clipper.prototype.JoinPoints=function(s,y,I){var N=s.OutPt1,z=new e.OutPt(),Z=s.OutPt2,tt=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(y!==I)return!1;for(z=s.OutPt1.Next;z!==N&&e.IntPoint.op_Equality(z.Pt,s.OffPt);)z=z.Next;var ht=z.Pt.Y>s.OffPt.Y;for(tt=s.OutPt2.Next;tt!==Z&&e.IntPoint.op_Equality(tt.Pt,s.OffPt);)tt=tt.Next;var It=tt.Pt.Y>s.OffPt.Y;return ht===It?!1:ht?(z=this.DupOutPt(N,!1),tt=this.DupOutPt(Z,!0),N.Prev=Z,Z.Next=N,z.Next=tt,tt.Prev=z,s.OutPt1=N,s.OutPt2=z,!0):(z=this.DupOutPt(N,!0),tt=this.DupOutPt(Z,!1),N.Next=Z,Z.Prev=N,z.Prev=tt,tt.Next=z,s.OutPt1=N,s.OutPt2=z,!0);}else if(ft){for(z=N;N.Prev.Pt.Y===N.Pt.Y&&N.Prev!==z&&N.Prev!==Z;)N=N.Prev;for(;z.Next.Pt.Y===z.Pt.Y&&z.Next!==N&&z.Next!==Z;)z=z.Next;if(z.Next===N||z.Next===Z)return!1;for(tt=Z;Z.Prev.Pt.Y===Z.Pt.Y&&Z.Prev!==tt&&Z.Prev!==z;)Z=Z.Prev;for(;tt.Next.Pt.Y===tt.Pt.Y&&tt.Next!==Z&&tt.Next!==N;)tt=tt.Next;if(tt.Next===Z||tt.Next===N)return!1;var Rt={Left:null,Right:null};if(!this.GetOverlap(N.Pt.X,z.Pt.X,Z.Pt.X,tt.Pt.X,Rt))return!1;var Lt=Rt.Left,Wt=Rt.Right,Yt=new e.IntPoint0(),Vt;return N.Pt.X>=Lt&&N.Pt.X<=Wt?(Yt.X=N.Pt.X,Yt.Y=N.Pt.Y,e.use_xyz&&(Yt.Z=N.Pt.Z),Vt=N.Pt.X>z.Pt.X):Z.Pt.X>=Lt&&Z.Pt.X<=Wt?(Yt.X=Z.Pt.X,Yt.Y=Z.Pt.Y,e.use_xyz&&(Yt.Z=Z.Pt.Z),Vt=Z.Pt.X>tt.Pt.X):z.Pt.X>=Lt&&z.Pt.X<=Wt?(Yt.X=z.Pt.X,Yt.Y=z.Pt.Y,e.use_xyz&&(Yt.Z=z.Pt.Z),Vt=z.Pt.X>N.Pt.X):(Yt.X=tt.Pt.X,Yt.Y=tt.Pt.Y,e.use_xyz&&(Yt.Z=tt.Pt.Z),Vt=tt.Pt.X>Z.Pt.X),s.OutPt1=N,s.OutPt2=Z,this.JoinHorz(N,z,Z,tt,Yt,Vt);}else{for(z=N.Next;e.IntPoint.op_Equality(z.Pt,N.Pt)&&z!==N;)z=z.Next;var Kt=z.Pt.Y>N.Pt.Y||!e.ClipperBase.SlopesEqual4(N.Pt,z.Pt,s.OffPt,this.m_UseFullRange);if(Kt){for(z=N.Prev;e.IntPoint.op_Equality(z.Pt,N.Pt)&&z!==N;)z=z.Prev;if(z.Pt.Y>N.Pt.Y||!e.ClipperBase.SlopesEqual4(N.Pt,z.Pt,s.OffPt,this.m_UseFullRange))return!1;}for(tt=Z.Next;e.IntPoint.op_Equality(tt.Pt,Z.Pt)&&tt!==Z;)tt=tt.Next;var ee=tt.Pt.Y>Z.Pt.Y||!e.ClipperBase.SlopesEqual4(Z.Pt,tt.Pt,s.OffPt,this.m_UseFullRange);if(ee){for(tt=Z.Prev;e.IntPoint.op_Equality(tt.Pt,Z.Pt)&&tt!==Z;)tt=tt.Prev;if(tt.Pt.Y>Z.Pt.Y||!e.ClipperBase.SlopesEqual4(Z.Pt,tt.Pt,s.OffPt,this.m_UseFullRange))return!1;}return z===N||tt===Z||z===tt||y===I&&Kt===ee?!1:Kt?(z=this.DupOutPt(N,!1),tt=this.DupOutPt(Z,!0),N.Prev=Z,Z.Next=N,z.Next=tt,tt.Prev=z,s.OutPt1=N,s.OutPt2=z,!0):(z=this.DupOutPt(N,!0),tt=this.DupOutPt(Z,!1),N.Next=Z,Z.Prev=N,z.Prev=tt,tt.Next=z,s.OutPt1=N,s.OutPt2=z,!0);}},e.Clipper.GetBounds=function(s){for(var y=0,I=s.length;y<I&&s[y].length===0;)y++;if(y===I)return new e.IntRect(0,0,0,0);var N=new e.IntRect();for(N.left=s[y][0].X,N.right=N.left,N.top=s[y][0].Y,N.bottom=N.top;y<I;y++)for(var z=0,Z=s[y].length;z<Z;z++)s[y][z].X<N.left?N.left=s[y][z].X:s[y][z].X>N.right&&(N.right=s[y][z].X),s[y][z].Y<N.top?N.top=s[y][z].Y:s[y][z].Y>N.bottom&&(N.bottom=s[y][z].Y);return N;},e.Clipper.prototype.GetBounds2=function(s){var y=s,I=new e.IntRect();for(I.left=s.Pt.X,I.right=s.Pt.X,I.top=s.Pt.Y,I.bottom=s.Pt.Y,s=s.Next;s!==y;)s.Pt.X<I.left&&(I.left=s.Pt.X),s.Pt.X>I.right&&(I.right=s.Pt.X),s.Pt.Y<I.top&&(I.top=s.Pt.Y),s.Pt.Y>I.bottom&&(I.bottom=s.Pt.Y),s=s.Next;return I;},e.Clipper.PointInPolygon=function(s,y){var I=0,N=y.length;if(N<3)return 0;for(var z=y[0],Z=1;Z<=N;++Z){var tt=Z===N?y[0]:y[Z];if(tt.Y===s.Y&&(tt.X===s.X||z.Y===s.Y&&tt.X>s.X==z.X<s.X))return-1;if(z.Y<s.Y!=tt.Y<s.Y){if(z.X>=s.X){if(tt.X>s.X)I=1-I;else{var ft=(z.X-s.X)*(tt.Y-s.Y)-(tt.X-s.X)*(z.Y-s.Y);if(ft===0)return-1;ft>0==tt.Y>z.Y&&(I=1-I);}}else if(tt.X>s.X){var ft=(z.X-s.X)*(tt.Y-s.Y)-(tt.X-s.X)*(z.Y-s.Y);if(ft===0)return-1;ft>0==tt.Y>z.Y&&(I=1-I);}}z=tt;}return I;},e.Clipper.prototype.PointInPolygon=function(s,y){var I=0,N=y,z=s.X,Z=s.Y,tt=y.Pt.X,ft=y.Pt.Y;do{y=y.Next;var ht=y.Pt.X,It=y.Pt.Y;if(It===Z&&(ht===z||ft===Z&&ht>z==tt<z))return-1;if(ft<Z!=It<Z){if(tt>=z){if(ht>z)I=1-I;else{var Rt=(tt-z)*(It-Z)-(ht-z)*(ft-Z);if(Rt===0)return-1;Rt>0==It>ft&&(I=1-I);}}else if(ht>z){var Rt=(tt-z)*(It-Z)-(ht-z)*(ft-Z);if(Rt===0)return-1;Rt>0==It>ft&&(I=1-I);}}tt=ht,ft=It;}while(N!==y);return I;},e.Clipper.prototype.Poly2ContainsPoly1=function(s,y){var I=s;do{var N=this.PointInPolygon(I.Pt,y);if(N>=0)return N>0;I=I.Next;}while(I!==s);return!0;},e.Clipper.prototype.FixupFirstLefts1=function(s,y){for(var I,N,z=0,Z=this.m_PolyOuts.length;z<Z;z++)I=this.m_PolyOuts[z],N=e.Clipper.ParseFirstLeft(I.FirstLeft),I.Pts!==null&&N===s&&this.Poly2ContainsPoly1(I.Pts,y.Pts)&&(I.FirstLeft=y);},e.Clipper.prototype.FixupFirstLefts2=function(s,y){for(var I=y.FirstLeft,N,z,Z=0,tt=this.m_PolyOuts.length;Z<tt;Z++)N=this.m_PolyOuts[Z],!(N.Pts===null||N===y||N===s)&&(z=e.Clipper.ParseFirstLeft(N.FirstLeft),!(z!==I&&z!==s&&z!==y)&&(this.Poly2ContainsPoly1(N.Pts,s.Pts)?N.FirstLeft=s:this.Poly2ContainsPoly1(N.Pts,y.Pts)?N.FirstLeft=y:(N.FirstLeft===s||N.FirstLeft===y)&&(N.FirstLeft=I)));},e.Clipper.prototype.FixupFirstLefts3=function(s,y){for(var I,N,z=0,Z=this.m_PolyOuts.length;z<Z;z++)I=this.m_PolyOuts[z],N=e.Clipper.ParseFirstLeft(I.FirstLeft),I.Pts!==null&&N===s&&(I.FirstLeft=y);},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,y=this.m_Joins.length;s<y;s++){var I=this.m_Joins[s],N=this.GetOutRec(I.OutPt1.Idx),z=this.GetOutRec(I.OutPt2.Idx);if(!(N.Pts===null||z.Pts===null)&&!(N.IsOpen||z.IsOpen)){var Z;N===z?Z=N:this.OutRec1RightOfOutRec2(N,z)?Z=z:this.OutRec1RightOfOutRec2(z,N)?Z=N:Z=this.GetLowermostRec(N,z),this.JoinPoints(I,N,z)&&(N===z?(N.Pts=I.OutPt1,N.BottomPt=null,z=this.CreateOutRec(),z.Pts=I.OutPt2,this.UpdateOutPtIdxs(z),this.Poly2ContainsPoly1(z.Pts,N.Pts)?(z.IsHole=!N.IsHole,z.FirstLeft=N,this.m_UsingPolyTree&&this.FixupFirstLefts2(z,N),(z.IsHole^this.ReverseSolution)==this.Area$1(z)>0&&this.ReversePolyPtLinks(z.Pts)):this.Poly2ContainsPoly1(N.Pts,z.Pts)?(z.IsHole=N.IsHole,N.IsHole=!z.IsHole,z.FirstLeft=N.FirstLeft,N.FirstLeft=z,this.m_UsingPolyTree&&this.FixupFirstLefts2(N,z),(N.IsHole^this.ReverseSolution)==this.Area$1(N)>0&&this.ReversePolyPtLinks(N.Pts)):(z.IsHole=N.IsHole,z.FirstLeft=N.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(N,z))):(z.Pts=null,z.BottomPt=null,z.Idx=N.Idx,N.IsHole=Z.IsHole,Z===z&&(N.FirstLeft=z.FirstLeft),z.FirstLeft=N,this.m_UsingPolyTree&&this.FixupFirstLefts3(z,N)));}}},e.Clipper.prototype.UpdateOutPtIdxs=function(s){var y=s.Pts;do y.Idx=s.Idx,y=y.Prev;while(y!==s.Pts);},e.Clipper.prototype.DoSimplePolygons=function(){for(var s=0;s<this.m_PolyOuts.length;){var y=this.m_PolyOuts[s++],I=y.Pts;if(!(I===null||y.IsOpen))do{for(var N=I.Next;N!==y.Pts;){if(e.IntPoint.op_Equality(I.Pt,N.Pt)&&N.Next!==I&&N.Prev!==I){var z=I.Prev,Z=N.Prev;I.Prev=Z,Z.Next=I,N.Prev=z,z.Next=N,y.Pts=I;var tt=this.CreateOutRec();tt.Pts=N,this.UpdateOutPtIdxs(tt),this.Poly2ContainsPoly1(tt.Pts,y.Pts)?(tt.IsHole=!y.IsHole,tt.FirstLeft=y,this.m_UsingPolyTree&&this.FixupFirstLefts2(tt,y)):this.Poly2ContainsPoly1(y.Pts,tt.Pts)?(tt.IsHole=y.IsHole,y.IsHole=!tt.IsHole,tt.FirstLeft=y.FirstLeft,y.FirstLeft=tt,this.m_UsingPolyTree&&this.FixupFirstLefts2(y,tt)):(tt.IsHole=y.IsHole,tt.FirstLeft=y.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(y,tt)),N=I;}N=N.Next;}I=I.Next;}while(I!==y.Pts);}},e.Clipper.Area=function(s){if(!Array.isArray(s))return 0;var y=s.length;if(y<3)return 0;for(var I=0,N=0,z=y-1;N<y;++N)I+=(s[z].X+s[N].X)*(s[z].Y-s[N].Y),z=N;return-I*0.5;},e.Clipper.prototype.Area=function(s){var y=s;if(s===null)return 0;var I=0;do I=I+(s.Prev.Pt.X+s.Pt.X)*(s.Prev.Pt.Y-s.Pt.Y),s=s.Next;while(s!==y);return I*0.5;},e.Clipper.prototype.Area$1=function(s){return this.Area(s.Pts);},e.Clipper.SimplifyPolygon=function(s,y){var I=new Array(),N=new e.Clipper(0);return N.StrictlySimple=!0,N.AddPath(s,e.PolyType.ptSubject,!0),N.Execute(e.ClipType.ctUnion,I,y,y),I;},e.Clipper.SimplifyPolygons=function(s,y){_typeof(y)>"u"&&(y=e.PolyFillType.pftEvenOdd);var I=new Array(),N=new e.Clipper(0);return N.StrictlySimple=!0,N.AddPaths(s,e.PolyType.ptSubject,!0),N.Execute(e.ClipType.ctUnion,I,y,y),I;},e.Clipper.DistanceSqrd=function(s,y){var I=s.X-y.X,N=s.Y-y.Y;return I*I+N*N;},e.Clipper.DistanceFromLineSqrd=function(s,y,I){var N=y.Y-I.Y,z=I.X-y.X,Z=N*y.X+z*y.Y;return Z=N*s.X+z*s.Y-Z,Z*Z/(N*N+z*z);},e.Clipper.SlopesNearCollinear=function(s,y,I,N){return Math.abs(s.X-y.X)>Math.abs(s.Y-y.Y)?s.X>y.X==s.X<I.X?e.Clipper.DistanceFromLineSqrd(s,y,I)<N:y.X>s.X==y.X<I.X?e.Clipper.DistanceFromLineSqrd(y,s,I)<N:e.Clipper.DistanceFromLineSqrd(I,s,y)<N:s.Y>y.Y==s.Y<I.Y?e.Clipper.DistanceFromLineSqrd(s,y,I)<N:y.Y>s.Y==y.Y<I.Y?e.Clipper.DistanceFromLineSqrd(y,s,I)<N:e.Clipper.DistanceFromLineSqrd(I,s,y)<N;},e.Clipper.PointsAreClose=function(s,y,I){var N=s.X-y.X,z=s.Y-y.Y;return N*N+z*z<=I;},e.Clipper.ExcludeOp=function(s){var y=s.Prev;return y.Next=s.Next,s.Next.Prev=y,y.Idx=0,y;},e.Clipper.CleanPolygon=function(s,y){_typeof(y)>"u"&&(y=1.415);var I=s.length;if(I===0)return new Array();for(var N=new Array(I),z=0;z<I;++z)N[z]=new e.OutPt();for(var z=0;z<I;++z)N[z].Pt=s[z],N[z].Next=N[(z+1)%I],N[z].Next.Prev=N[z],N[z].Idx=0;for(var Z=y*y,tt=N[0];tt.Idx===0&&tt.Next!==tt.Prev;)e.Clipper.PointsAreClose(tt.Pt,tt.Prev.Pt,Z)?(tt=e.Clipper.ExcludeOp(tt),I--):e.Clipper.PointsAreClose(tt.Prev.Pt,tt.Next.Pt,Z)?(e.Clipper.ExcludeOp(tt.Next),tt=e.Clipper.ExcludeOp(tt),I-=2):e.Clipper.SlopesNearCollinear(tt.Prev.Pt,tt.Pt,tt.Next.Pt,Z)?(tt=e.Clipper.ExcludeOp(tt),I--):(tt.Idx=1,tt=tt.Next);I<3&&(I=0);for(var ft=new Array(I),z=0;z<I;++z)ft[z]=new e.IntPoint1(tt.Pt),tt=tt.Next;return N=null,ft;},e.Clipper.CleanPolygons=function(s,y){for(var I=new Array(s.length),N=0,z=s.length;N<z;N++)I[N]=e.Clipper.CleanPolygon(s[N],y);return I;},e.Clipper.Minkowski=function(s,y,I,N){var z=N?1:0,Z=s.length,tt=y.length,ft=new Array();if(I)for(var ht=0;ht<tt;ht++){for(var It=new Array(Z),Rt=0,Lt=s.length,Wt=s[Rt];Rt<Lt;Rt++,Wt=s[Rt])It[Rt]=new e.IntPoint2(y[ht].X+Wt.X,y[ht].Y+Wt.Y);ft.push(It);}else for(var ht=0;ht<tt;ht++){for(var It=new Array(Z),Rt=0,Lt=s.length,Wt=s[Rt];Rt<Lt;Rt++,Wt=s[Rt])It[Rt]=new e.IntPoint2(y[ht].X-Wt.X,y[ht].Y-Wt.Y);ft.push(It);}for(var Yt=new Array(),ht=0;ht<tt-1+z;ht++)for(var Rt=0;Rt<Z;Rt++){var Vt=new Array();Vt.push(ft[ht%tt][Rt%Z]),Vt.push(ft[(ht+1)%tt][Rt%Z]),Vt.push(ft[(ht+1)%tt][(Rt+1)%Z]),Vt.push(ft[ht%tt][(Rt+1)%Z]),e.Clipper.Orientation(Vt)||Vt.reverse(),Yt.push(Vt);}return Yt;},e.Clipper.MinkowskiSum=function(s,y,I){if(y[0]instanceof Array){for(var z=y,tt=new e.Paths(),Z=new e.Clipper(),ft=0;ft<z.length;++ft){var ht=e.Clipper.Minkowski(s,z[ft],!0,I);if(Z.AddPaths(ht,e.PolyType.ptSubject,!0),I){var N=e.Clipper.TranslatePath(z[ft],s[0]);Z.AddPath(N,e.PolyType.ptClip,!0);}}return Z.Execute(e.ClipType.ctUnion,tt,e.PolyFillType.pftNonZero,e.PolyFillType.pftNonZero),tt;}else{var N=y,z=e.Clipper.Minkowski(s,N,!0,I),Z=new e.Clipper();return Z.AddPaths(z,e.PolyType.ptSubject,!0),Z.Execute(e.ClipType.ctUnion,z,e.PolyFillType.pftNonZero,e.PolyFillType.pftNonZero),z;}},e.Clipper.TranslatePath=function(s,y){for(var I=new e.Path(),N=0;N<s.length;N++)I.push(new e.IntPoint2(s[N].X+y.X,s[N].Y+y.Y));return I;},e.Clipper.MinkowskiDiff=function(s,y){var I=e.Clipper.Minkowski(s,y,!1,!0),N=new e.Clipper();return N.AddPaths(I,e.PolyType.ptSubject,!0),N.Execute(e.ClipType.ctUnion,I,e.PolyFillType.pftNonZero,e.PolyFillType.pftNonZero),I;},e.Clipper.PolyTreeToPaths=function(s){var y=new Array();return e.Clipper.AddPolyNodeToPaths(s,e.Clipper.NodeType.ntAny,y),y;},e.Clipper.AddPolyNodeToPaths=function(s,y,I){var N=!0;switch(y){case e.Clipper.NodeType.ntOpen:return;case e.Clipper.NodeType.ntClosed:N=!s.IsOpen;break;}s.m_polygon.length>0&&N&&I.push(s.m_polygon);for(var z=0,Z=s.Childs(),tt=Z.length,ft=Z[z];z<tt;z++,ft=Z[z])e.Clipper.AddPolyNodeToPaths(ft,y,I);},e.Clipper.OpenPathsFromPolyTree=function(s){for(var y=new e.Paths(),I=0,N=s.ChildCount();I<N;I++)s.Childs()[I].IsOpen&&y.push(s.Childs()[I].m_polygon);return y;},e.Clipper.ClosedPathsFromPolyTree=function(s){var y=new e.Paths();return e.Clipper.AddPolyNodeToPaths(s,e.Clipper.NodeType.ntClosed,y),y;},Pn(e.Clipper,e.ClipperBase),e.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2},e.ClipperOffset=function(s,y){_typeof(s)>"u"&&(s=2),_typeof(y)>"u"&&(y=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=y,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,y,I){var N=s.length-1;if(!(N<0)){var z=new e.PolyNode();if(z.m_jointype=y,z.m_endtype=I,I===e.EndType.etClosedLine||I===e.EndType.etClosedPolygon)for(;N>0&&e.IntPoint.op_Equality(s[0],s[N]);)N--;z.m_polygon.push(s[0]);for(var Z=0,tt=0,ft=1;ft<=N;ft++)e.IntPoint.op_Inequality(z.m_polygon[Z],s[ft])&&(Z++,z.m_polygon.push(s[ft]),(s[ft].Y>z.m_polygon[tt].Y||s[ft].Y===z.m_polygon[tt].Y&&s[ft].X<z.m_polygon[tt].X)&&(tt=Z));if(!(I===e.EndType.etClosedPolygon&&Z<2)&&(this.m_polyNodes.AddChild(z),I===e.EndType.etClosedPolygon))if(this.m_lowest.X<0)this.m_lowest=new e.IntPoint2(this.m_polyNodes.ChildCount()-1,tt);else{var ht=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(z.m_polygon[tt].Y>ht.Y||z.m_polygon[tt].Y===ht.Y&&z.m_polygon[tt].X<ht.X)&&(this.m_lowest=new e.IntPoint2(this.m_polyNodes.ChildCount()-1,tt));}}},e.ClipperOffset.prototype.AddPaths=function(s,y,I){for(var N=0,z=s.length;N<z;N++)this.AddPath(s[N],y,I);},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 y=this.m_polyNodes.Childs()[s];(y.m_endtype===e.EndType.etClosedPolygon||y.m_endtype===e.EndType.etClosedLine&&e.Clipper.Orientation(y.m_polygon))&&y.m_polygon.reverse();}else for(var s=0;s<this.m_polyNodes.ChildCount();s++){var y=this.m_polyNodes.Childs()[s];y.m_endtype===e.EndType.etClosedLine&&!e.Clipper.Orientation(y.m_polygon)&&y.m_polygon.reverse();}},e.ClipperOffset.GetUnitNormal=function(s,y){var I=y.X-s.X,N=y.Y-s.Y;if(I===0&&N===0)return new e.DoublePoint2(0,0);var z=1/Math.sqrt(I*I+N*N);return I*=z,N*=z,new e.DoublePoint2(N,-I);},e.ClipperOffset.prototype.DoOffset=function(s){if(this.m_destPolys=new Array(),this.m_delta=s,e.ClipperBase.near_zero(s)){for(var y=0;y<this.m_polyNodes.ChildCount();y++){var I=this.m_polyNodes.Childs()[y];I.m_endtype===e.EndType.etClosedPolygon&&this.m_destPolys.push(I.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 z=3.14159265358979/Math.acos(1-N/Math.abs(s));this.m_sin=Math.sin(e.ClipperOffset.two_pi/z),this.m_cos=Math.cos(e.ClipperOffset.two_pi/z),this.m_StepsPerRad=z/e.ClipperOffset.two_pi,s<0&&(this.m_sin=-this.m_sin);for(var y=0;y<this.m_polyNodes.ChildCount();y++){var I=this.m_polyNodes.Childs()[y];this.m_srcPoly=I.m_polygon;var Z=this.m_srcPoly.length;if(!(Z===0||s<=0&&(Z<3||I.m_endtype!==e.EndType.etClosedPolygon))){if(this.m_destPoly=new Array(),Z===1){if(I.m_jointype===e.JoinType.jtRound)for(var tt=1,ft=0,ht=1;ht<=z;ht++){this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[0].X+tt*s),e.ClipperOffset.Round(this.m_srcPoly[0].Y+ft*s)));var It=tt;tt=tt*this.m_cos-this.m_sin*ft,ft=It*this.m_sin+ft*this.m_cos;}else for(var tt=-1,ft=-1,ht=0;ht<4;++ht)this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[0].X+tt*s),e.ClipperOffset.Round(this.m_srcPoly[0].Y+ft*s))),tt<0?tt=1:ft<0?ft=1:tt=-1;this.m_destPolys.push(this.m_destPoly);continue;}this.m_normals.length=0;for(var ht=0;ht<Z-1;ht++)this.m_normals.push(e.ClipperOffset.GetUnitNormal(this.m_srcPoly[ht],this.m_srcPoly[ht+1]));if(I.m_endtype===e.EndType.etClosedLine||I.m_endtype===e.EndType.etClosedPolygon?this.m_normals.push(e.ClipperOffset.GetUnitNormal(this.m_srcPoly[Z-1],this.m_srcPoly[0])):this.m_normals.push(new e.DoublePoint1(this.m_normals[Z-2])),I.m_endtype===e.EndType.etClosedPolygon){for(var Rt=Z-1,ht=0;ht<Z;ht++)Rt=this.OffsetPoint(ht,Rt,I.m_jointype);this.m_destPolys.push(this.m_destPoly);}else if(I.m_endtype===e.EndType.etClosedLine){for(var Rt=Z-1,ht=0;ht<Z;ht++)Rt=this.OffsetPoint(ht,Rt,I.m_jointype);this.m_destPolys.push(this.m_destPoly),this.m_destPoly=new Array();for(var Lt=this.m_normals[Z-1],ht=Z-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),Rt=0;for(var ht=Z-1;ht>=0;ht--)Rt=this.OffsetPoint(ht,Rt,I.m_jointype);this.m_destPolys.push(this.m_destPoly);}else{for(var Rt=0,ht=1;ht<Z-1;++ht)Rt=this.OffsetPoint(ht,Rt,I.m_jointype);var Wt;if(I.m_endtype===e.EndType.etOpenButt){var ht=Z-1;Wt=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(Wt),Wt=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(Wt);}else{var ht=Z-1;Rt=Z-2,this.m_sinA=0,this.m_normals[ht]=new e.DoublePoint2(-this.m_normals[ht].X,-this.m_normals[ht].Y),I.m_endtype===e.EndType.etOpenSquare?this.DoSquare(ht,Rt):this.DoRound(ht,Rt);}for(var ht=Z-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),Rt=Z-1;for(var ht=Rt-1;ht>0;--ht)Rt=this.OffsetPoint(ht,Rt,I.m_jointype);I.m_endtype===e.EndType.etOpenButt?(Wt=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(Wt),Wt=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(Wt)):(Rt=1,this.m_sinA=0,I.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,y=s[0]instanceof e.PolyTree;if(y){var I=s[0],N=s[1];I.Clear(),this.FixOrientations(),this.DoOffset(N);var z=new e.Clipper(0);if(z.AddPaths(this.m_destPolys,e.PolyType.ptSubject,!0),N>0)z.Execute(e.ClipType.ctUnion,I,e.PolyFillType.pftPositive,e.PolyFillType.pftPositive);else{var Z=e.Clipper.GetBounds(this.m_destPolys),tt=new e.Path();if(tt.push(new e.IntPoint2(Z.left-10,Z.bottom+10)),tt.push(new e.IntPoint2(Z.right+10,Z.bottom+10)),tt.push(new e.IntPoint2(Z.right+10,Z.top-10)),tt.push(new e.IntPoint2(Z.left-10,Z.top-10)),z.AddPath(tt,e.PolyType.ptSubject,!0),z.ReverseSolution=!0,z.Execute(e.ClipType.ctUnion,I,e.PolyFillType.pftNegative,e.PolyFillType.pftNegative),I.ChildCount()===1&&I.Childs()[0].ChildCount()>0){var ft=I.Childs()[0];I.Childs()[0]=ft.Childs()[0],I.Childs()[0].m_Parent=I;for(var ht=1;ht<ft.ChildCount();ht++)I.AddChild(ft.Childs()[ht]);}else I.Clear();}}else{var I=s[0],N=s[1];e.Clear(I),this.FixOrientations(),this.DoOffset(N);var z=new e.Clipper(0);if(z.AddPaths(this.m_destPolys,e.PolyType.ptSubject,!0),N>0)z.Execute(e.ClipType.ctUnion,I,e.PolyFillType.pftPositive,e.PolyFillType.pftPositive);else{var Z=e.Clipper.GetBounds(this.m_destPolys),tt=new e.Path();tt.push(new e.IntPoint2(Z.left-10,Z.bottom+10)),tt.push(new e.IntPoint2(Z.right+10,Z.bottom+10)),tt.push(new e.IntPoint2(Z.right+10,Z.top-10)),tt.push(new e.IntPoint2(Z.left-10,Z.top-10)),z.AddPath(tt,e.PolyType.ptSubject,!0),z.ReverseSolution=!0,z.Execute(e.ClipType.ctUnion,I,e.PolyFillType.pftNegative,e.PolyFillType.pftNegative),I.length>0&&I.splice(0,1);}}},e.ClipperOffset.prototype.OffsetPoint=function(s,y,I){if(this.m_sinA=this.m_normals[y].X*this.m_normals[s].Y-this.m_normals[s].X*this.m_normals[y].Y,Math.abs(this.m_sinA*this.m_delta)<1){var N=this.m_normals[y].X*this.m_normals[s].X+this.m_normals[s].Y*this.m_normals[y].Y;if(N>0)return this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+this.m_normals[y].X*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_normals[y].Y*this.m_delta))),y;}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[y].X*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_normals[y].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(I){case e.JoinType.jtMiter:{var z=1+(this.m_normals[s].X*this.m_normals[y].X+this.m_normals[s].Y*this.m_normals[y].Y);z>=this.m_miterLim?this.DoMiter(s,y,z):this.DoSquare(s,y);break;}case e.JoinType.jtSquare:this.DoSquare(s,y);break;case e.JoinType.jtRound:this.DoRound(s,y);break;}return y=s,y;},e.ClipperOffset.prototype.DoSquare=function(s,y){var I=Math.tan(Math.atan2(this.m_sinA,this.m_normals[y].X*this.m_normals[s].X+this.m_normals[y].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[y].X-this.m_normals[y].Y*I)),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_delta*(this.m_normals[y].Y+this.m_normals[y].X*I)))),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*I)),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_delta*(this.m_normals[s].Y-this.m_normals[s].X*I))));},e.ClipperOffset.prototype.DoMiter=function(s,y,I){var N=this.m_delta/I;this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+(this.m_normals[y].X+this.m_normals[s].X)*N),e.ClipperOffset.Round(this.m_srcPoly[s].Y+(this.m_normals[y].Y+this.m_normals[s].Y)*N)));},e.ClipperOffset.prototype.DoRound=function(s,y){for(var I=Math.atan2(this.m_sinA,this.m_normals[y].X*this.m_normals[s].X+this.m_normals[y].Y*this.m_normals[s].Y),N=Math.max(e.Cast_Int32(e.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(I))),1),z=this.m_normals[y].X,Z=this.m_normals[y].Y,tt,ft=0;ft<N;++ft)this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+z*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[s].Y+Z*this.m_delta))),tt=z,z=z*this.m_cos-this.m_sin*Z,Z=tt*this.m_sin+Z*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(y){alert(y.message);}},e.JS={},e.JS.AreaOfPolygon=function(s,y){return y||(y=1),e.Clipper.Area(s)/(y*y);},e.JS.AreaOfPolygons=function(s,y){y||(y=1);for(var I=0,N=0;N<s.length;N++)I+=e.Clipper.Area(s[N]);return I/(y*y);},e.JS.BoundsOfPath=function(s,y){return e.JS.BoundsOfPaths([s],y);},e.JS.BoundsOfPaths=function(s,y){y||(y=1);var I=e.Clipper.GetBounds(s);return I.left/=y,I.bottom/=y,I.right/=y,I.top/=y,I;},e.JS.Clean=function(N,y){if(!(N instanceof Array))return[];var I=N[0]instanceof Array,N=e.JS.Clone(N);if(typeof y!="number"||y===null)return e.Error("Delta is not a number in Clean()."),N;if(N.length===0||N.length===1&&N[0].length===0||y<0)return N;I||(N=[N]);for(var z=N.length,Z,tt,ft,ht,It,Rt,Lt,Wt=[],Yt=0;Yt<z;Yt++)if(tt=N[Yt],Z=tt.length,Z!==0){if(Z<3){ft=tt,Wt.push(ft);continue;}for(ft=tt,ht=y*y,It=tt[0],Rt=1,Lt=1;Lt<Z;Lt++)(tt[Lt].X-It.X)*(tt[Lt].X-It.X)+(tt[Lt].Y-It.Y)*(tt[Lt].Y-It.Y)<=ht||(ft[Rt]=tt[Lt],It=tt[Lt],Rt++);It=tt[Rt-1],(tt[0].X-It.X)*(tt[0].X-It.X)+(tt[0].Y-It.Y)*(tt[0].Y-It.Y)<=ht&&Rt--,Rt<Z&&ft.splice(Rt,Z-Rt),ft.length&&Wt.push(ft);}return!I&&Wt.length?Wt=Wt[0]:!I&&Wt.length===0?Wt=[]:I&&Wt.length===0&&(Wt=[[]]),Wt;},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 y=s[0]instanceof Array;y||(s=[s]);var I=s.length,N,z,Z,tt,ft=new Array(I);for(z=0;z<I;z++){for(N=s[z].length,tt=new Array(N),Z=0;Z<N;Z++)tt[Z]={X:s[z][Z].X,Y:s[z][Z].Y};ft[z]=tt;}return y||(ft=ft[0]),ft;},e.JS.Lighten=function(s,y){if(!(s instanceof Array))return[];if(typeof y!="number"||y===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||y<0)return e.JS.Clone(s);var I=s[0]instanceof Array;I||(s=[s]);var N,z,Z,tt,ft,ht,It,Rt,Lt,Wt,Yt,Vt,Kt,ee,ge,Oe,Ye,to=s.length,eo=y*y,Xe=[];for(N=0;N<to;N++)if(Z=s[N],ht=Z.length,ht!==0){for(tt=0;tt<1e6;tt++){for(ft=[],ht=Z.length,Z[ht-1].X!==Z[0].X||Z[ht-1].Y!==Z[0].Y?(Vt=1,Z.push({X:Z[0].X,Y:Z[0].Y}),ht=Z.length):Vt=0,Yt=[],z=0;z<ht-2;z++)It=Z[z],Lt=Z[z+1],Rt=Z[z+2],Oe=It.X,Ye=It.Y,Kt=Rt.X-Oe,ee=Rt.Y-Ye,(Kt!==0||ee!==0)&&(ge=((Lt.X-Oe)*Kt+(Lt.Y-Ye)*ee)/(Kt*Kt+ee*ee),ge>1?(Oe=Rt.X,Ye=Rt.Y):ge>0&&(Oe+=Kt*ge,Ye+=ee*ge)),Kt=Lt.X-Oe,ee=Lt.Y-Ye,Wt=Kt*Kt+ee*ee,Wt<=eo&&(Yt[z+1]=1,z++);for(ft.push({X:Z[0].X,Y:Z[0].Y}),z=1;z<ht-1;z++)Yt[z]||ft.push({X:Z[z].X,Y:Z[z].Y});if(ft.push({X:Z[ht-1].X,Y:Z[ht-1].Y}),Vt&&Z.pop(),Yt.length)Z=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 I||(Xe=Xe[0]),_typeof(Xe)>"u"&&(Xe=[]),Xe;},e.JS.PerimeterOfPath=function(s,y,I){if(_typeof(s)>"u")return 0;var N=Math.sqrt,z=0,Z,tt,ft=0,ht=0,It=0,Rt=0,Lt=s.length;if(Lt<2)return 0;for(y&&(s[Lt]=s[0],Lt++);--Lt;)Z=s[Lt],ft=Z.X,ht=Z.Y,tt=s[Lt-1],It=tt.X,Rt=tt.Y,z+=N((ft-It)*(ft-It)+(ht-Rt)*(ht-Rt));return y&&s.pop(),z/I;},e.JS.PerimeterOfPaths=function(s,y,I){I||(I=1);for(var N=0,z=0;z<s.length;z++)N+=e.JS.PerimeterOfPath(s[z],y,I);return N;},e.JS.ScaleDownPath=function(s,y){var I,N;for(y||(y=1),I=s.length;I--;)N=s[I],N.X=N.X/y,N.Y=N.Y/y;},e.JS.ScaleDownPaths=function(s,y){var I,N,z;for(y||(y=1),I=s.length;I--;)for(N=s[I].length;N--;)z=s[I][N],z.X=z.X/y,z.Y=z.Y/y;},e.JS.ScaleUpPath=function(s,y){var I,N,z=Math.round;for(y||(y=1),I=s.length;I--;)N=s[I],N.X=z(N.X*y),N.Y=z(N.Y*y);},e.JS.ScaleUpPaths=function(s,y){var I,N,z,Z=Math.round;for(y||(y=1),I=s.length;I--;)for(N=s[I].length;N--;)z=s[I][N],z.X=Z(z.X*y),z.Y=Z(z.Y*y);},e.ExPolygons=function(){return[];},e.ExPolygon=function(){this.outer=null,this.holes=null;},e.JS.AddOuterPolyNodeToExPolygons=function(s,y){var I=new e.ExPolygon();I.outer=s.Contour();var N=s.Childs(),z=N.length;I.holes=new Array(z);var Z,tt,ft,ht,It,Rt;for(ft=0;ft<z;ft++)for(Z=N[ft],I.holes[ft]=Z.Contour(),ht=0,It=Z.Childs(),Rt=It.length;ht<Rt;ht++)tt=It[ht],e.JS.AddOuterPolyNodeToExPolygons(tt,y);y.push(I);},e.JS.ExPolygonsToPaths=function(s){var y,I,N,z,Z=new e.Paths();for(y=0,N=s.length;y<N;y++)for(Z.push(s[y].outer),I=0,z=s[y].holes.length;I<z;I++)Z.push(s[y].holes[I]);return Z;},e.JS.PolyTreeToExPolygons=function(s){var y=new e.ExPolygons(),I,N,z,Z;for(N=0,z=s.Childs(),Z=z.length;N<Z;N++)I=z[N],e.JS.AddOuterPolyNodeToExPolygons(I,y);return y;};})();})(ki);var Zp=ki.exports,Ee=/* @__PURE__ */Ne(Zp);function Hi(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 Jp(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++)Hi([u[r][0],u[r][1]],t[t.length-1],e)||t.push([u[r][0],u[r][1]]);return t;}function Qp(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 Hi(t,r,e)?u.slice(0,-1):u;}function qp(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 _p(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=qp(t);return t.sort(function(n,i){var l=Hn(r,n),o=Hn(r,i);return l-o;});}function t0(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,m=0;for(var f=0;f<e.length;f++){var v=e[f],S=Math.sqrt(Math.pow(v.x-o[0],2)+Math.pow(v.y-o[1],2));S<c&&(c=S,a=f,m=v.z);}return{point:o,index:a,bestZ:m};}).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 e0(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),S=_ref167[0],E=_ref167[1];return{X:Math.round(S*v),Y:Math.round(E*v)};});},l=new Ee.ClipperOffset();l.AddPath(i(n,1e3),Ee.JoinType.jtRound,Ee.EndType.etOpenButt);var o=[];l.Execute(o,1);var a=new Ee.Clipper();a.AddPaths(o,Ee.PolyType.ptSubject,!0),e.forEach(function(f){a.AddPath(i(f,1e3),Ee.PolyType.ptClip,!0);});var c=new Ee.Paths();a.Execute(Ee.ClipType.ctDifference,c,Ee.PolyFillType.pftNonZero,Ee.PolyFillType.pftNonZero);var m=c.map(function(f){return Qp(_p(Jp(f.map(function(v){return[v.X/1e3,v.Y/1e3];}),t),t),t);}).filter(function(f){return f.length>=2;});return t0(m,u);}var Vi=/*#__PURE__*/function(_At){function Vi(t){var _this62;_classCallCheck(this,Vi);_this62=_callSuper(this,Vi,[t]);ot(_this62,"canRotate",!0);ot(_this62,"scaleType",Qt.all);ot(_this62,"toolsType",pt.Pencil);ot(_this62,"syncTimestamp");ot(_this62,"syncIndex",0);ot(_this62,"tmpPoints",[]);ot(_this62,"MAX_REPEAR",10);/** 合并原始点的灵敏度 */ot(_this62,"uniThickness");ot(_this62,"workOptions");ot(_this62,"centerPos",[0,0]);_this62.workOptions=t.toolsOpt,_this62.uniThickness=_this62.MAX_REPEAR/_this62.workOptions.thickness/10,_this62.syncTimestamp=0;return _this62;}/** 批量合并消费本地数据,返回绘制结果 */_inherits(Vi,_At);return _createClass(Vi,[{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:Dt.Local};}},{key:"setWorkOptions",value:function setWorkOptions(t){_superPropGet(Vi,"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=t.isSimpleWorker,m=r.workId,f=r.syncUnitTime;f&&(this.syncUnitTime=f);var _this$transformData=this.transformData(r,!1),v=_this$transformData.tasks,S=_this$transformData.effects,E=_this$transformData.consumeIndex;this.syncIndex=Math.min(this.syncIndex,E,Math.max(0,this.tmpPoints.length-2));var T={name:m,id:ue(o)&&o.toString()||void 0};var P,x=!1;var h=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),v.length&&(v[0].taskId-this.syncTimestamp>this.syncUnitTime&&(x=!0,this.syncTimestamp=v[0].taskId,this.syncIndex=this.tmpPoints.length),i||l||c)){var d=n?this.fullLayer:this.drawLayer||this.fullLayer;P=this.draw({attrs:T,tasks:v,effects:S,layer:d,removeDrawCount:a});}if(c){var _d14=[];return this.tmpPoints.slice(h).forEach(function(g){_d14.push(g.x,g.y,_this63.computRadius(g.z,_this63.workOptions.thickness));}),_objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:dt.DrawWork,dataType:Dt.Local,op:x?_d14:void 0,index:x?h*3:void 0,updateNodeOpt:{useAnimation:!0}});}if(i)return E>10&&this.tmpPoints.splice(0,E-10),{rect:P,type:dt.DrawWork,dataType:Dt.Local};var p=[];return this.tmpPoints.slice(h).forEach(function(d){p.push(d.x,d.y,_this63.computRadius(d.z,_this63.workOptions.thickness));}),_objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:dt.DrawWork,dataType:Dt.Local,rect:P,op:x?p:void 0,index:x?h*3:void 0,updateNodeOpt:{useAnimation:!0}});}},{key:"consumeAll",value:function consumeAll(t){var m;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===Zt.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=ve(a);return(m=this.vNodes)==null||m.setInfo(r,{rect:l,op:a,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:l&&At.getCenterPos(l,o)}),_objectSpread(_objectSpread({},this.baseConsumeResult),{},{rect:l,type:dt.FullWork,dataType:Dt.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 S=0;S<r.length;S+=3){var E=new Nt(r[S],r[S+1],r[S+2]);if(this.tmpPoints.length>0){var T=this.tmpPoints[this.tmpPoints.length-1],P=at.Sub(E,T).uni();E.setv(P);}this.tmpPoints.push(E);}if(this.tmpPoints.length<2)return;var o=this.transformDataAll(!0),a=(f=this.workId)==null?void 0:f.toString(),c={name:a};var m;if(a&&o.length){var _S8=n?this.fullLayer:this.drawLayer||this.fullLayer;m=this.draw({attrs:c,tasks:o,replaceId:i,layer:_S8,isDrawEraserlines:l===Ft.Done}),(v=this.vNodes)==null||v.setInfo(a,{rect:m,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:m&&At.getCenterPos(m,_S8)});}return m;}},{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 Nt(n[a],n[a+1],n[a+2]);if(this.tmpPoints.length>0){var m=this.tmpPoints[this.tmpPoints.length-1],f=at.Sub(c,m).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,m=_o$_a.points,f=m.map(function(E){return E.point.addXY(c[0],c[1]);}),v=[];var _iterator17=_createForOfIteratorHelper(i),_step17;try{for(_iterator17.s();!(_step17=_iterator17.n()).done;){var E=_step17.value;var T=[];for(var _x54=0;_x54<E.length;_x54+=2){var _h29=new Nt(E[_x54],E[_x54+1]);if(T.length>0){var p=T[T.length-1].point,d=at.Sub(_h29,p).uni();_h29.setv(d);}T.push({point:_h29,radius:l});}var _this64$computStroke=_this64.computStroke(T,!1),P=_this64$computStroke.ps;v.push(P.map(function(x){return x.XY;}));}}catch(err){_iterator17.e(err);}finally{_iterator17.f();}e0(f,v,0.01).forEach(function(E){r.push(E.map(function(T){return[T[0],T[1],T[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,m=_this$workOptions.strokeColor,f=_this$workOptions.strokeType,v=_this$workOptions.thickness,S=_this$workOptions.zIndex,E=_this$workOptions.scale,T=_this$workOptions.rotate,P=_this$workOptions.translate,x=_this$workOptions.eraserlines;l!=null&&l.size&&(l.forEach(function(w){var L;(L=o.getElementById(w+""))==null||L.remove();}),l.clear()),a&&this.removeDrawCountNodes(o,a);var h;var p=[],d=o.worldPosition,g=o.worldScaling;for(var w=0;w<n.length;w++){var _n$w=n[w],L=_n$w.pos,B=_n$w.points,_this$computDrawPoint=this.computDrawPoints(B),A=_this$computDrawPoint.ps,b=_this$computDrawPoint.rect;var W=void 0;var D=B.length===1;f===Zt.Stroke||D?W=De(A,!0):W=De(A,!1);var R={pos:L,d:W,fillColor:f===Zt.Stroke||D?m:void 0,lineDash:f===Zt.Dotted&&!D?[1,v*2]:f===Zt.LongDotted&&!D?[v,v*2]:void 0,strokeColor:m,lineCap:f===Zt.Stroke||D?void 0:"round",lineWidth:f===Zt.Stroke||D?0:v};h=bt(h,{x:Math.floor((b.x+L[0])*g[0]+d[0]-At.SafeBorderPadding),y:Math.floor((b.y+L[1])*g[1]+d[1]-At.SafeBorderPadding),w:Math.floor(b.w*g[0]+2*At.SafeBorderPadding),h:Math.floor(b.h*g[1]+2*At.SafeBorderPadding)}),p.push(R);}E&&(r.scale=E),T&&(r.rotate=T),P&&(r.translate=P);var O=new ye();if(h){this.centerPos=At.getCenterPos(h,o);var _w4=f===Zt.Stroke&&!x;O.attr(_objectSpread(_objectSpread({},r),{},{normalize:!0,anchor:[0.5,0.5],bgcolor:_w4?m:void 0,pos:this.centerPos,size:[(h.w-2*At.SafeBorderPadding)/g[0],(h.h-2*At.SafeBorderPadding)/g[1]],zIndex:S}));var _L5=p.map(function(B){return B.pos=[B.pos[0]-_this65.centerPos[0],B.pos[1]-_this65.centerPos[1]],new be(B);});O.append.apply(O,_toConsumableArray(_L5)),_w4&&O.seal(),x&&(this.scaleType=Qt.proportional,this.drawEraserlines({group:O,eraserlines:x,pos:this.centerPos,layer:o},c)),this.replace(o,i,O);}if(E||T||P){var _w5=O==null?void 0:O.getBoundingClientRect();_w5&&(h={x:Math.floor(_w5.x-At.SafeBorderPadding),y:Math.floor(_w5.y-At.SafeBorderPadding),w:Math.floor(_w5.width+At.SafeBorderPadding*2),h:Math.floor(_w5.height+At.SafeBorderPadding*2)});}return this.isDelete&&O.setAttribute("opacity",0),h;}},{key:"computDrawPoints",value:function computDrawPoints(t){return this.workOptions.strokeType===Zt.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,m=_t$a.radius;var f=c.v;a===0&&t.length>1&&(f=t[a+1].point.v);var v=at.Per(f).mul(m);n.push(Nt.Sub(c,v)),i.push(Nt.Add(c,v));}var l=t[t.length-1];if(r){var _a6=Nt.GetSemicircleStroke(l.point,n[n.length-1],-1,8),_c4=Nt.GetSemicircleStroke(t[0].point,i[0],-1,8),_m7=n.concat(_a6,i.reverse(),_c4);return{ps:_m7,rect:_t(_m7)};}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:Nt.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,m=/* @__PURE__ */new Set();l=a===Zt.Stroke?this.updateTempPointsWithPressure(n,c,m):this.updateTempPoints(n,c,m);var f=r?this.tmpPoints:this.tmpPoints.slice(l);return o=this.getTaskPoints(f,c),{tasks:o,effects:m,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=[],m=t[0].t;for(;i<t.length;){var v=t[i],S=v.x-l,E=v.y-o,T=v.z,P=r?this.computRadius(T,r):T;if(c.push({point:new Nt(S,E,T,t[i].v),radius:P}),i>0&&i<t.length-1){var _x55=t[i].getAngleByPoints(t[i-1],t[i+1]);if(_x55<60||_x55>300){var _h30=(f=c.pop())==null?void 0:f.point.clone();_h30&&n.push({taskId:m,pos:a,points:[].concat(_toConsumableArray(c),[{point:_h30,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 Nt(p,d,T),radius:P}],m=Date.now();}}i++;}return n.push({taskId:m,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 m=this.tmpPoints.length,f=new Nt(t[c],t[c+1]);if(m===0){this.tmpPoints.push(f);continue;}var v=m-1,S=this.tmpPoints[v],E=at.Sub(f,S).uni();if(f.isNear(S,r)){if(S.z<this.MAX_REPEAR){if(S.setz(Math.min(S.z+1,this.MAX_REPEAR)),o=Math.min(o,v),m>1){var _x56=m-1;for(;_x56>0;){var _h31=this.tmpPoints[_x56].distance(this.tmpPoints[_x56-1]),p=Math.max(this.tmpPoints[_x56].z-this.uniThickness*_h31,0);if(this.tmpPoints[_x56-1].z>=p)break;this.tmpPoints[_x56-1].setz(p),o=Math.min(o,_x56-1),_x56--;}}}else o=1/0;continue;}f.setv(E);var T=f.distance(S),P=Math.max(S.z-this.uniThickness*T,0);m>1&&at.Equals(E,S.v,0.02)&&(P>0||S.z<=0)&&(n&&S.t&&n.add(S.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 _m8=this.tmpPoints[_c6].t;if(_m8&&(n==null||n.add(_m8),_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 m=0;m<t.length;m+=2){var f=this.tmpPoints.length,v=new Nt(t[m],t[m+1]);if(f===0){this.tmpPoints.push(v);continue;}var S=f-1,E=this.tmpPoints[S],T=at.Sub(v,E).uni();if(v.isNear(E,r/2)){o=Math.min(S,o);continue;}at.Equals(T,E.v,0.02)&&(n&&E.t&&n.add(E.t),this.tmpPoints.pop(),o=Math.min(S,o)),v.setv(T),this.tmpPoints.push(v);}var a=l;if(o===l){a=Math.max(a-1,0);var _m9=this.tmpPoints[a].t;_m9&&(n==null||n.add(_m9));}else{var _m10=Math.min(l-1,o);for(a=o;_m10>=0;){var _f4=(c=this.tmpPoints[_m10])==null?void 0:c.t;if(_f4&&(n==null||n.add(_f4),_m10<=o)){a=_m10,_m10=-1;break;}_m10--;}}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 Nt(t[l],t[l+1]);if(o===0){this.tmpPoints.push(a);continue;}var c=o-1,m=this.tmpPoints[c],f=at.Sub(a,m).uni(),v=a.distance(m);if(o>1&&m.z===i)break;if(a.isNear(m,r/2)){if(n<3&&m.z<this.MAX_REPEAR&&(m.setz(Math.min(m.z+1,this.MAX_REPEAR)),o>1)){var E=o-1;for(;E>0;){var T=this.tmpPoints[E].distance(this.tmpPoints[E-1]),P=Math.max(this.tmpPoints[E].z-this.uniThickness*T,-r/4);if(this.tmpPoints[E-1].z>=P)break;this.tmpPoints[E-1].setz(P),E--;}}continue;}a.setv(f);var S=Math.max(m.z-this.uniThickness*v,i);o>1&&at.Equals(f,m.v,0.02)&&m.z<=0&&this.tmpPoints.pop(),a.setz(S),this.tmpPoints.push(a);}}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var c,m;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"?xm(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&&(m=a.opt)!=null&&m.strokeType&&(a.opt.strokeType=o),a&&i.setInfo(r.name,a),At.updateNodeOpt(t);}}]);}(At);var Ki=/*#__PURE__*/function(_At2){function Ki(t){var _this66;_classCallCheck(this,Ki);_this66=_callSuper(this,Ki,[t]);ot(_this66,"toolsType",pt.LaserPen);ot(_this66,"canRotate",!1);ot(_this66,"scaleType",Qt.none);ot(_this66,"syncTimestamp");ot(_this66,"syncIndex",0);ot(_this66,"tmpPoints",[]);ot(_this66,"workOptions");ot(_this66,"consumeIndex",0);_this66.workOptions=t.toolsOpt,_this66.syncTimestamp=0;return _this66;}_inherits(Ki,_At2);return _createClass(Ki,[{key:"combineConsume",value:function combineConsume(){}},{key:"setWorkOptions",value:function setWorkOptions(t){_superPropGet(Ki,"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,m=_this$workOptions3.strokeType,f=_t(this.tmpPoints,c);var v=!1;var S=this.syncIndex,E=this.tmpPoints.slice(this.consumeIndex);this.consumeIndex=this.tmpPoints.length-1,this.syncTimestamp===0&&(this.syncTimestamp=Date.now());var T={name:i==null?void 0:i.toString(),opacity:1,lineDash:m===Zt.Dotted?[1,c*2]:m===Zt.LongDotted?[c,c*2]:void 0,strokeColor:a,lineCap:"round",lineWidth:c,anchor:[0.5,0.5]},P=this.getTaskPoints(E);if(P.length){var _h32=Date.now();_h32-this.syncTimestamp>this.syncUnitTime&&(v=!0,this.syncTimestamp=_h32,this.syncIndex=this.tmpPoints.length),n&&this.draw({attrs:T,tasks:P,isDot:!1,layer:this.drawLayer||this.fullLayer});}var x=[];return this.tmpPoints.slice(S).forEach(function(h){x.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:Dt.Local,op:v?x:void 0,index:v?S*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,m=_this$workOptions4.thickness,f=_this$workOptions4.strokeType;if(a){var E=this.computDotStroke({point:o[0],radius:m/2});o=E.ps,r=E.rect;}else r=_t(this.tmpPoints,m);var v={name:t==null?void 0:t.toString(),fillColor:a?c:void 0,opacity:1,lineDash:f===Zt.Dotted&&!a?[1,m*2]:f===Zt.LongDotted&&!a?[m,m*2]:void 0,strokeColor:c,lineCap:a?void 0:"round",lineWidth:a?0:m,anchor:[0.5,0.5]},S=this.getTaskPoints(o);S.length&&this.draw({attrs:v,tasks:S,isDot:a,layer:this.drawLayer||this.fullLayer});}var n=[];this.tmpPoints.forEach(function(o){n.push(o.x,o.y);});var i=ve(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:Dt.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 T;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 m,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,m=_P6.rect;}else m=_t(this.tmpPoints,o);var S={name:(T=this.workId)==null?void 0:T.toString(),fillColor:v?l:void 0,opacity:1,lineDash:a===Zt.Dotted&&!v?[1,o*2]:a===Zt.LongDotted&&!v?[o,o*2]:void 0,strokeColor:l,lineCap:v?void 0:"round",lineWidth:v?0:o,anchor:[0.5,0.5]},E=this.getTaskPoints(f);if(E.length){var _P7=i?this.fullLayer:this.drawLayer||this.fullLayer;this.draw({attrs:S,tasks:E,isDot:v,replaceId:n,layer:_P7});}return{x:m.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:m.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:m.w*this.fullLayer.worldScaling[0],h:m.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:Nt.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 Nt(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,m,f,v,_this67$workOptions,S,E,T,_l$getResolution,P,_x58;return _regeneratorRuntime().wrap(function _loop5$(_context22){while(1)switch(_context22.prev=_context22.next){case 0:a=_step18.value;c=new be(),m=a.pos,f=a.points;i?v=De(f,!0):v=De(f,!1),c.attr(_objectSpread(_objectSpread({},r),{},{pos:m,d:v}));_this67$workOptions=_this67.workOptions,S=_this67$workOptions.vertex,E=_this67$workOptions.fragment;if(S&&E){T=l.renderer.createProgram({vertex:S,fragment:E}),_l$getResolution=l.getResolution(),P=_l$getResolution.width,_x58=_l$getResolution.height;c.setUniforms({u_time:0,u_resolution:[P,_x58]}),c.setProgram(T);}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(_x57){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 m=t[n],f=m.x-i,v=m.y-l;if(a.push(new Nt(f,v)),n>0&&n<t.length-1){var S=t[n].getAngleByPoints(t[n-1],t[n+1]);if(S<60||S>300){var E=(c=a.pop())==null?void 0:c.clone();E&&r.push({pos:o,points:[].concat(_toConsumableArray(a),[E])}),i=t[n].x,l=t[n].y,o=[i,l];var T=m.x-i,P=m.y-l;a=[new Nt(T,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=bt(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;}}]);}(At);var r0=Cr;Cr.polyline=Cr;Cr.polygon=n0;function Cr(u,e,t){var r=u.length,n=Ge(u[0],e),i=[],l,o,a,c,m;for(t||(t=[]),l=1;l<r;l++){for(o=u[l-1],a=u[l],c=m=Ge(a,e);;)if(n|c){if(n&c)break;n?(o=Zr(o,a,n,e),n=Ge(o,e)):(a=Zr(o,a,c,e),c=Ge(a,e));}else{i.push(o),c!==m?(i.push(a),l<r-1&&(t.push(i),i=[])):l===r-1&&i.push(a);break;}n=m;}return i.length&&t.push(i),t;}function n0(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(Zr(n,o,r,e)),a&&t.push(o),n=o,i=a;if(u=t,!u.length)break;}return t;}function Zr(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,m){if(a==null)return"";var f,v,S={},E={},T="",P="",x="",h=2,p=3,d=2,g=[],O=0,w=0,L;for(L=0;L<a.length;L+=1)if(T=a.charAt(L),Object.prototype.hasOwnProperty.call(S,T)||(S[T]=p++,E[T]=!0),P=x+T,Object.prototype.hasOwnProperty.call(S,P))x=P;else{if(Object.prototype.hasOwnProperty.call(E,x)){if(x.charCodeAt(0)<256){for(f=0;f<d;f++)O=O<<1,w==c-1?(w=0,g.push(m(O)),O=0):w++;for(v=x.charCodeAt(0),f=0;f<8;f++)O=O<<1|v&1,w==c-1?(w=0,g.push(m(O)),O=0):w++,v=v>>1;}else{for(v=1,f=0;f<d;f++)O=O<<1|v,w==c-1?(w=0,g.push(m(O)),O=0):w++,v=0;for(v=x.charCodeAt(0),f=0;f<16;f++)O=O<<1|v&1,w==c-1?(w=0,g.push(m(O)),O=0):w++,v=v>>1;}h--,h==0&&(h=Math.pow(2,d),d++),delete E[x];}else for(v=S[x],f=0;f<d;f++)O=O<<1|v&1,w==c-1?(w=0,g.push(m(O)),O=0):w++,v=v>>1;h--,h==0&&(h=Math.pow(2,d),d++),S[P]=p++,x=String(T);}if(x!==""){if(Object.prototype.hasOwnProperty.call(E,x)){if(x.charCodeAt(0)<256){for(f=0;f<d;f++)O=O<<1,w==c-1?(w=0,g.push(m(O)),O=0):w++;for(v=x.charCodeAt(0),f=0;f<8;f++)O=O<<1|v&1,w==c-1?(w=0,g.push(m(O)),O=0):w++,v=v>>1;}else{for(v=1,f=0;f<d;f++)O=O<<1|v,w==c-1?(w=0,g.push(m(O)),O=0):w++,v=0;for(v=x.charCodeAt(0),f=0;f<16;f++)O=O<<1|v&1,w==c-1?(w=0,g.push(m(O)),O=0):w++,v=v>>1;}h--,h==0&&(h=Math.pow(2,d),d++),delete E[x];}else for(v=S[x],f=0;f<d;f++)O=O<<1|v&1,w==c-1?(w=0,g.push(m(O)),O=0):w++,v=v>>1;h--,h==0&&(h=Math.pow(2,d),d++);}for(v=2,f=0;f<d;f++)O=O<<1|v&1,w==c-1?(w=0,g.push(m(O)),O=0):w++,v=v>>1;for(;;)if(O=O<<1,w==c-1){g.push(m(O));break;}else w++;return g.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,m){var f=[],v=4,S=4,E=3,T="",P=[],x,h,p,d,g,O,w,L={val:m(0),position:c,index:1};for(x=0;x<3;x+=1)f[x]=x;for(p=0,g=Math.pow(2,2),O=1;O!=g;)d=L.val&L.position,L.position>>=1,L.position==0&&(L.position=c,L.val=m(L.index++)),p|=(d>0?1:0)*O,O<<=1;switch(p){case 0:for(p=0,g=Math.pow(2,8),O=1;O!=g;)d=L.val&L.position,L.position>>=1,L.position==0&&(L.position=c,L.val=m(L.index++)),p|=(d>0?1:0)*O,O<<=1;w=t(p);break;case 1:for(p=0,g=Math.pow(2,16),O=1;O!=g;)d=L.val&L.position,L.position>>=1,L.position==0&&(L.position=c,L.val=m(L.index++)),p|=(d>0?1:0)*O,O<<=1;w=t(p);break;case 2:return"";}for(f[3]=w,h=w,P.push(w);;){if(L.index>a)return"";for(p=0,g=Math.pow(2,E),O=1;O!=g;)d=L.val&L.position,L.position>>=1,L.position==0&&(L.position=c,L.val=m(L.index++)),p|=(d>0?1:0)*O,O<<=1;switch(w=p){case 0:for(p=0,g=Math.pow(2,8),O=1;O!=g;)d=L.val&L.position,L.position>>=1,L.position==0&&(L.position=c,L.val=m(L.index++)),p|=(d>0?1:0)*O,O<<=1;f[S++]=t(p),w=S-1,v--;break;case 1:for(p=0,g=Math.pow(2,16),O=1;O!=g;)d=L.val&L.position,L.position>>=1,L.position==0&&(L.position=c,L.val=m(L.index++)),p|=(d>0?1:0)*O,O<<=1;f[S++]=t(p),w=S-1,v--;break;case 2:return P.join("");}if(v==0&&(v=Math.pow(2,E),E++),f[w])T=f[w];else if(w===S)T=h+h.charAt(0);else return null;P.push(T),f[S++]=h+T.charAt(0),v--,h=T,v==0&&(v=Math.pow(2,E),E++);}}};return o;}();u!=null?u.exports=e:(typeof angular==="undefined"?"undefined":_typeof(angular))<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return e;});})(hn);var Gi=hn.exports;function Qe(u){return JSON.parse(Gi.decompress(u));}function ve(u){return Gi.compress(JSON.stringify(u));}var ki={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,y,I){e.biginteger_used=1,s!=null&&(typeof s=="number"&&_typeof(y)>"u"?this.fromInt(s):typeof s=="number"?this.fromNumber(s,y,I):y==null&&typeof s!="string"?this.fromString(s,256):this.fromString(s,y));}function a(){return new o(null,void 0,void 0);}function c(s,y,I,N,z,Z){for(;--Z>=0;){var tt=y*this[s++]+I[N]+z;z=Math.floor(tt/67108864),I[N++]=tt&67108863;}return z;}function m(s,y,I,N,z,Z){for(var tt=y&32767,ft=y>>15;--Z>=0;){var ht=this[s]&32767,It=this[s++]>>15,Rt=ft*ht+It*tt;ht=tt*ht+((Rt&32767)<<15)+I[N]+(z&1073741823),z=(ht>>>30)+(Rt>>>15)+ft*It+(z>>>30),I[N++]=ht&1073741823;}return z;}function f(s,y,I,N,z,Z){for(var tt=y&16383,ft=y>>14;--Z>=0;){var ht=this[s]&16383,It=this[s++]>>14,Rt=ft*ht+It*tt;ht=tt*ht+((Rt&16383)<<14)+I[N]+z,z=(ht>>28)+(Rt>>14)+ft*It,I[N++]=ht&268435455;}return z;}r=="Microsoft Internet Explorer"?(o.prototype.am=m,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 S="0123456789abcdefghijklmnopqrstuvwxyz",E=new Array(),T,P;for(T=48,P=0;P<=9;++P)E[T++]=P;for(T=97,P=10;P<36;++P)E[T++]=P;for(T=65,P=10;P<36;++P)E[T++]=P;function x(s){return S.charAt(s);}function h(s,y){var I=E[s.charCodeAt(y)];return I!==null&&I!==void 0?I:-1;}function p(s){for(var y=this.t-1;y>=0;--y)s[y]=this[y];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 g(s){var y=a();return y.fromInt(s),y;}function O(s,y){var I;if(y==16)I=4;else if(y==8)I=3;else if(y==256)I=8;else if(y==2)I=1;else if(y==32)I=5;else if(y==4)I=2;else{this.fromRadix(s,y);return;}this.t=0,this.s=0;for(var N=s.length,z=!1,Z=0;--N>=0;){var tt=I==8?s[N]&255:h(s,N);if(tt<0){s.charAt(N)=="-"&&(z=!0);continue;}z=!1,Z==0?this[this.t++]=tt:Z+I>this.DB?(this[this.t-1]|=(tt&(1<<this.DB-Z)-1)<<Z,this[this.t++]=tt>>this.DB-Z):this[this.t-1]|=tt<<Z,Z+=I,Z>=this.DB&&(Z-=this.DB);}I==8&&s[0]&128&&(this.s=-1,Z>0&&(this[this.t-1]|=(1<<this.DB-Z)-1<<Z)),this.clamp(),z&&o.ZERO.subTo(this,this);}function w(){for(var s=this.s&this.DM;this.t>0&&this[this.t-1]==s;)--this.t;}function L(s){if(this.s<0)return"-"+this.negate().toString(s);var y;if(s==16)y=4;else if(s==8)y=3;else if(s==2)y=1;else if(s==32)y=5;else if(s==4)y=2;else return this.toRadix(s);var I=(1<<y)-1,N,z=!1,Z="",tt=this.t,ft=this.DB-tt*this.DB%y;if(tt-->0)for(ft<this.DB&&(N=this[tt]>>ft)>0&&(z=!0,Z=x(N));tt>=0;)ft<y?(N=(this[tt]&(1<<ft)-1)<<y-ft,N|=this[--tt]>>(ft+=this.DB-y)):(N=this[tt]>>(ft-=y)&I,ft<=0&&(ft+=this.DB,--tt)),N>0&&(z=!0),z&&(Z+=x(N));return z?Z:"0";}function B(){var s=a();return o.ZERO.subTo(this,s),s;}function A(){return this.s<0?this.negate():this;}function b(s){var y=this.s-s.s;if(y!=0)return y;var I=this.t;if(y=I-s.t,y!=0)return this.s<0?-y:y;for(;--I>=0;)if((y=this[I]-s[I])!=0)return y;return 0;}function W(s){var y=1,I;return(I=s>>>16)!=0&&(s=I,y+=16),(I=s>>8)!=0&&(s=I,y+=8),(I=s>>4)!=0&&(s=I,y+=4),(I=s>>2)!=0&&(s=I,y+=2),(I=s>>1)!=0&&(s=I,y+=1),y;}function D(){return this.t<=0?0:this.DB*(this.t-1)+W(this[this.t-1]^this.s&this.DM);}function R(s,y){var I;for(I=this.t-1;I>=0;--I)y[I+s]=this[I];for(I=s-1;I>=0;--I)y[I]=0;y.t=this.t+s,y.s=this.s;}function X(s,y){for(var I=s;I<this.t;++I)y[I-s]=this[I];y.t=Math.max(this.t-s,0),y.s=this.s;}function H(s,y){var I=s%this.DB,N=this.DB-I,z=(1<<N)-1,Z=Math.floor(s/this.DB),tt=this.s<<I&this.DM,ft;for(ft=this.t-1;ft>=0;--ft)y[ft+Z+1]=this[ft]>>N|tt,tt=(this[ft]&z)<<I;for(ft=Z-1;ft>=0;--ft)y[ft]=0;y[Z]=tt,y.t=this.t+Z+1,y.s=this.s,y.clamp();}function J(s,y){y.s=this.s;var I=Math.floor(s/this.DB);if(I>=this.t){y.t=0;return;}var N=s%this.DB,z=this.DB-N,Z=(1<<N)-1;y[0]=this[I]>>N;for(var tt=I+1;tt<this.t;++tt)y[tt-I-1]|=(this[tt]&Z)<<z,y[tt-I]=this[tt]>>N;N>0&&(y[this.t-I-1]|=(this.s&Z)<<z),y.t=this.t-I,y.clamp();}function et(s,y){for(var I=0,N=0,z=Math.min(s.t,this.t);I<z;)N+=this[I]-s[I],y[I++]=N&this.DM,N>>=this.DB;if(s.t<this.t){for(N-=s.s;I<this.t;)N+=this[I],y[I++]=N&this.DM,N>>=this.DB;N+=this.s;}else{for(N+=this.s;I<s.t;)N-=s[I],y[I++]=N&this.DM,N>>=this.DB;N-=s.s;}y.s=N<0?-1:0,N<-1?y[I++]=this.DV+N:N>0&&(y[I++]=N),y.t=I,y.clamp();}function it(s,y){var I=this.abs(),N=s.abs(),z=I.t;for(y.t=z+N.t;--z>=0;)y[z]=0;for(z=0;z<N.t;++z)y[z+I.t]=I.am(0,N[z],y,z,0,I.t);y.s=0,y.clamp(),this.s!=s.s&&o.ZERO.subTo(y,y);}function $(s){for(var y=this.abs(),I=s.t=2*y.t;--I>=0;)s[I]=0;for(I=0;I<y.t-1;++I){var N=y.am(I,y[I],s,2*I,0,1);(s[I+y.t]+=y.am(I+1,2*y[I],s,2*I+1,N,y.t-I-1))>=y.DV&&(s[I+y.t]-=y.DV,s[I+y.t+1]=1);}s.t>0&&(s[s.t-1]+=y.am(I,y[I],s,2*I,0,1)),s.s=0,s.clamp();}function V(s,y,I){var N=s.abs();if(!(N.t<=0)){var z=this.abs();if(z.t<N.t){y!=null&&y.fromInt(0),I!=null&&this.copyTo(I);return;}I==null&&(I=a());var Z=a(),tt=this.s,ft=s.s,ht=this.DB-W(N[N.t-1]);ht>0?(N.lShiftTo(ht,Z),z.lShiftTo(ht,I)):(N.copyTo(Z),z.copyTo(I));var It=Z.t,Rt=Z[It-1];if(Rt!=0){var Lt=Rt*(1<<this.F1)+(It>1?Z[It-2]>>this.F2:0),Wt=this.FV/Lt,Yt=(1<<this.F1)/Lt,Vt=1<<this.F2,Kt=I.t,ee=Kt-It,ge=y!==null&&y!==void 0?y:a();for(Z.dlShiftTo(ee,ge),I.compareTo(ge)>=0&&(I[I.t++]=1,I.subTo(ge,I)),o.ONE.dlShiftTo(It,ge),ge.subTo(Z,Z);Z.t<It;)Z[Z.t++]=0;for(;--ee>=0;){var Oe=I[--Kt]==Rt?this.DM:Math.floor(I[Kt]*Wt+(I[Kt-1]+Vt)*Yt);if((I[Kt]+=Z.am(0,Oe,I,ee,0,It))<Oe)for(Z.dlShiftTo(ee,ge),I.subTo(ge,I);I[Kt]<--Oe;)I.subTo(ge,I);}y!=null&&(I.drShiftTo(It,y),tt!=ft&&o.ZERO.subTo(y,y)),I.t=It,I.clamp(),ht>0&&I.rShiftTo(ht,I),tt<0&&o.ZERO.subTo(I,I);}}}function rt(s){var y=a();return this.abs().divRemTo(s,null,y),this.s<0&&y.compareTo(o.ZERO)>0&&s.subTo(y,y),y;}function lt(s){this.m=s;}function ct(s){return s.s<0||s.compareTo(this.m)>=0?s.mod(this.m):s;}function gt(s){return s;}function st(s){s.divRemTo(this.m,null,s);}function Ct(s,y,I){s.multiplyTo(y,I),this.reduce(I);}function xt(s,y){s.squareTo(y),this.reduce(y);}lt.prototype.convert=ct,lt.prototype.revert=gt,lt.prototype.reduce=st,lt.prototype.mulTo=Ct,lt.prototype.sqrTo=xt;function F(){if(this.t<1)return 0;var s=this[0];if(!(s&1))return 0;var y=s&3;return y=y*(2-(s&15)*y)&15,y=y*(2-(s&255)*y)&255,y=y*(2-((s&65535)*y&65535))&65535,y=y*(2-s*y%this.DV)%this.DV,y>0?this.DV-y:-y;}function U(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 K(s){var y=a();return s.abs().dlShiftTo(this.m.t,y),y.divRemTo(this.m,null,y),s.s<0&&y.compareTo(o.ZERO)>0&&this.m.subTo(y,y),y;}function q(s){var y=a();return s.copyTo(y),this.reduce(y),y;}function Y(s){for(;s.t<=this.mt2;)s[s.t++]=0;for(var y=0;y<this.m.t;++y){var I=s[y]&32767,N=I*this.mpl+((I*this.mph+(s[y]>>15)*this.mpl&this.um)<<15)&s.DM;for(I=y+this.m.t,s[I]+=this.m.am(0,N,s,y,0,this.m.t);s[I]>=s.DV;)s[I]-=s.DV,s[++I]++;}s.clamp(),s.drShiftTo(this.m.t,s),s.compareTo(this.m)>=0&&s.subTo(this.m,s);}function k(s,y){s.squareTo(y),this.reduce(y);}function C(s,y,I){s.multiplyTo(y,I),this.reduce(I);}U.prototype.convert=K,U.prototype.revert=q,U.prototype.reduce=Y,U.prototype.mulTo=C,U.prototype.sqrTo=k;function M(){return(this.t>0?this[0]&1:this.s)==0;}function j(s,y){if(s>4294967295||s<1)return o.ONE;var I=a(),N=a(),z=y.convert(this),Z=W(s)-1;for(z.copyTo(I);--Z>=0;)if(y.sqrTo(I,N),(s&1<<Z)>0)y.mulTo(N,z,I);else{var tt=I;I=N,N=tt;}return y.revert(I);}function G(s,y){var I;return s<256||y.isEven()?I=new lt(y):I=new U(y),this.exp(s,I);}o.prototype.copyTo=p,o.prototype.fromInt=d,o.prototype.fromString=O,o.prototype.clamp=w,o.prototype.dlShiftTo=R,o.prototype.drShiftTo=X,o.prototype.lShiftTo=H,o.prototype.rShiftTo=J,o.prototype.subTo=et,o.prototype.multiplyTo=it,o.prototype.squareTo=$,o.prototype.divRemTo=V,o.prototype.invDigit=F,o.prototype.isEven=M,o.prototype.exp=j,o.prototype.toString=L,o.prototype.negate=B,o.prototype.abs=A,o.prototype.compareTo=b,o.prototype.bitLength=D,o.prototype.mod=rt,o.prototype.modPowInt=G,o.ZERO=g(0),o.ONE=g(1);function Q(){var s=a();return this.copyTo(s),s;}function _(){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 mt(s){return Math.floor(Math.LN2*this.DB/Math.log(s));}function Pt(){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 y=this.chunkSize(s),I=Math.pow(s,y),N=g(I),z=a(),Z=a(),tt="";for(this.divRemTo(N,z,Z);z.signum()>0;)tt=(I+Z.intValue()).toString(s).substr(1)+tt,z.divRemTo(N,z,Z);return Z.intValue().toString(s)+tt;}function yt(s,y){this.fromInt(0),y==null&&(y=10);for(var I=this.chunkSize(y),N=Math.pow(y,I),z=!1,Z=0,tt=0,ft=0;ft<s.length;++ft){var ht=h(s,ft);if(ht<0){s.charAt(ft)=="-"&&this.signum()==0&&(z=!0);continue;}tt=y*tt+ht,++Z>=I&&(this.dMultiply(N),this.dAddOffset(tt,0),Z=0,tt=0);}Z>0&&(this.dMultiply(Math.pow(y,Z)),this.dAddOffset(tt,0)),z&&o.ZERO.subTo(this,this);}function vt(s,y,I){if(typeof y=="number"){if(s<2)this.fromInt(1);else for(this.fromNumber(s,I),this.testBit(s-1)||this.bitwiseTo(o.ONE.shiftLeft(s-1),Ut,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(y);)this.dAddOffset(2,0),this.bitLength()>s&&this.subTo(o.ONE.shiftLeft(s-1),this);}else{var N=new Array(),z=s&7;N.length=(s>>3)+1,y.nextBytes(N),z>0?N[0]&=(1<<z)-1:N[0]=0,this.fromString(N,256);}}function St(){var s=this.t,y=new Array();y[0]=this.s;var I=this.DB-s*this.DB%8,N,z=0;if(s-->0)for(I<this.DB&&(N=this[s]>>I)!=(this.s&this.DM)>>I&&(y[z++]=N|this.s<<this.DB-I);s>=0;)I<8?(N=(this[s]&(1<<I)-1)<<8-I,N|=this[--s]>>(I+=this.DB-8)):(N=this[s]>>(I-=8)&255,I<=0&&(I+=this.DB,--s)),N&128&&(N|=-256),z==0&&(this.s&128)!=(N&128)&&++z,(z>0||N!=this.s)&&(y[z++]=N);return y;}function Mt(s){return this.compareTo(s)==0;}function wt(s){return this.compareTo(s)<0?this:s;}function Ot(s){return this.compareTo(s)>0?this:s;}function Bt(s,y,I){var N,z,Z=Math.min(s.t,this.t);for(N=0;N<Z;++N)I[N]=y(this[N],s[N]);if(s.t<this.t){for(z=s.s&this.DM,N=Z;N<this.t;++N)I[N]=y(this[N],z);I.t=this.t;}else{for(z=this.s&this.DM,N=Z;N<s.t;++N)I[N]=y(z,s[N]);I.t=s.t;}I.s=y(this.s,s.s),I.clamp();}function Gt(s,y){return s&y;}function jt(s){var y=a();return this.bitwiseTo(s,Gt,y),y;}function Ut(s,y){return s|y;}function zt(s){var y=a();return this.bitwiseTo(s,Ut,y),y;}function Xt(s,y){return s^y;}function ae(s){var y=a();return this.bitwiseTo(s,Xt,y),y;}function ie(s,y){return s&~y;}function se(s){var y=a();return this.bitwiseTo(s,ie,y),y;}function oe(){for(var s=a(),y=0;y<this.t;++y)s[y]=this.DM&~this[y];return s.t=this.t,s.s=~this.s,s;}function le(s){var y=a();return s<0?this.rShiftTo(-s,y):this.lShiftTo(s,y),y;}function ce(s){var y=a();return s<0?this.lShiftTo(-s,y):this.rShiftTo(s,y),y;}function fe(s){if(s==0)return-1;var y=0;return s&65535||(s>>=16,y+=16),s&255||(s>>=8,y+=8),s&15||(s>>=4,y+=4),s&3||(s>>=2,y+=2),s&1||++y,y;}function Jt(){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 xe(s){for(var y=0;s!=0;)s&=s-1,++y;return y;}function Be(){for(var s=0,y=this.s&this.DM,I=0;I<this.t;++I)s+=xe(this[I]^y);return s;}function We(s){var y=Math.floor(s/this.DB);return y>=this.t?this.s!=0:(this[y]&1<<s%this.DB)!=0;}function mr(s,y){var I=o.ONE.shiftLeft(s);return this.bitwiseTo(I,y,I),I;}function vr(s){return this.changeBit(s,Ut);}function xs(s){return this.changeBit(s,ie);}function Ts(s){return this.changeBit(s,Xt);}function Cs(s,y){for(var I=0,N=0,z=Math.min(s.t,this.t);I<z;)N+=this[I]+s[I],y[I++]=N&this.DM,N>>=this.DB;if(s.t<this.t){for(N+=s.s;I<this.t;)N+=this[I],y[I++]=N&this.DM,N>>=this.DB;N+=this.s;}else{for(N+=this.s;I<s.t;)N+=s[I],y[I++]=N&this.DM,N>>=this.DB;N+=s.s;}y.s=N<0?-1:0,N>0?y[I++]=N:N<-1&&(y[I++]=this.DV+N),y.t=I,y.clamp();}function Is(s){var y=a();return this.addTo(s,y),y;}function Os(s){var y=a();return this.subTo(s,y),y;}function Es(s){var y=a();return this.multiplyTo(s,y),y;}function Ms(){var s=a();return this.squareTo(s),s;}function As(s){var y=a();return this.divRemTo(s,y,null),y;}function ws(s){var y=a();return this.divRemTo(s,null,y),y;}function Ls(s){var y=a(),I=a();return this.divRemTo(s,y,I),new Array(y,I);}function Rs(s){this[this.t]=this.am(0,s-1,this,0,0,this.t),++this.t,this.clamp();}function Ds(s,y){if(s!=0){for(;this.t<=y;)this[this.t++]=0;for(this[y]+=s;this[y]>=this.DV;)this[y]-=this.DV,++y>=this.t&&(this[this.t++]=0),++this[y];}}function ir(){}function gn(s){return s;}function bs(s,y,I){s.multiplyTo(y,I);}function Ns(s,y){s.squareTo(y);}ir.prototype.convert=gn,ir.prototype.revert=gn,ir.prototype.mulTo=bs,ir.prototype.sqrTo=Ns;function Bs(s){return this.exp(s,new ir());}function Ws(s,y,I){var N=Math.min(this.t+s.t,y);for(I.s=0,I.t=N;N>0;)I[--N]=0;var z;for(z=I.t-this.t;N<z;++N)I[N+this.t]=this.am(0,s[N],I,N,0,this.t);for(z=Math.min(s.t,y);N<z;++N)this.am(0,s[N],I,N,0,y-N);I.clamp();}function Fs(s,y,I){--y;var N=I.t=this.t+s.t-y;for(I.s=0;--N>=0;)I[N]=0;for(N=Math.max(y-this.t,0);N<s.t;++N)I[this.t+N-y]=this.am(y-N,s[N],I,0,0,this.t+N-y);I.clamp(),I.drShiftTo(1,I);}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 Us(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 y=a();return s.copyTo(y),this.reduce(y),y;}function js(s){return s;}function Ys(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 Xs(s,y){s.squareTo(y),this.reduce(y);}function zs(s,y,I){s.multiplyTo(y,I),this.reduce(I);}je.prototype.convert=Us,je.prototype.revert=js,je.prototype.reduce=Ys,je.prototype.mulTo=zs,je.prototype.sqrTo=Xs;function $s(s,y){var I=s.bitLength(),N,z=g(1),Z;if(I<=0)return z;I<18?N=1:I<48?N=3:I<144?N=4:I<768?N=5:N=6,I<8?Z=new lt(y):y.isEven()?Z=new je(y):Z=new U(y);var tt=new Array(),ft=3,ht=N-1,It=(1<<N)-1;if(tt[1]=Z.convert(this),N>1){var Rt=a();for(Z.sqrTo(tt[1],Rt);ft<=It;)tt[ft]=a(),Z.mulTo(Rt,tt[ft-2],tt[ft]),ft+=2;}var Lt=s.t-1,Wt,Yt=!0,Vt=a(),Kt;for(I=W(s[Lt])-1;Lt>=0;){for(I>=ht?Wt=s[Lt]>>I-ht&It:(Wt=(s[Lt]&(1<<I+1)-1)<<ht-I,Lt>0&&(Wt|=s[Lt-1]>>this.DB+I-ht)),ft=N;!(Wt&1);)Wt>>=1,--ft;if((I-=ft)<0&&(I+=this.DB,--Lt),Yt)tt[Wt].copyTo(z),Yt=!1;else{for(;ft>1;)Z.sqrTo(z,Vt),Z.sqrTo(Vt,z),ft-=2;ft>0?Z.sqrTo(z,Vt):(Kt=z,z=Vt,Vt=Kt),Z.mulTo(Vt,tt[Wt],z);}for(;Lt>=0&&!(s[Lt]&1<<I);)Z.sqrTo(z,Vt),Kt=z,z=Vt,Vt=Kt,--I<0&&(I=this.DB-1,--Lt);}return Z.revert(z);}function Gs(s){var y=this.s<0?this.negate():this.clone(),I=s.s<0?s.negate():s.clone();if(y.compareTo(I)<0){var N=y;y=I,I=N;}var z=y.getLowestSetBit(),Z=I.getLowestSetBit();if(Z<0)return y;for(z<Z&&(Z=z),Z>0&&(y.rShiftTo(Z,y),I.rShiftTo(Z,I));y.signum()>0;)(z=y.getLowestSetBit())>0&&y.rShiftTo(z,y),(z=I.getLowestSetBit())>0&&I.rShiftTo(z,I),y.compareTo(I)>=0?(y.subTo(I,y),y.rShiftTo(1,y)):(I.subTo(y,I),I.rShiftTo(1,I));return Z>0&&I.lShiftTo(Z,I),I;}function ks(s){if(s<=0)return 0;var y=this.DV%s,I=this.s<0?s-1:0;if(this.t>0)if(y==0)I=this[0]%s;else for(var N=this.t-1;N>=0;--N)I=(y*I+this[N])%s;return I;}function Hs(s){var y=s.isEven();if(this.isEven()&&y||s.signum()==0)return o.ZERO;for(var I=s.clone(),N=this.clone(),z=g(1),Z=g(0),tt=g(0),ft=g(1);I.signum()!=0;){for(;I.isEven();)I.rShiftTo(1,I),y?((!z.isEven()||!Z.isEven())&&(z.addTo(this,z),Z.subTo(s,Z)),z.rShiftTo(1,z)):Z.isEven()||Z.subTo(s,Z),Z.rShiftTo(1,Z);for(;N.isEven();)N.rShiftTo(1,N),y?((!tt.isEven()||!ft.isEven())&&(tt.addTo(this,tt),ft.subTo(s,ft)),tt.rShiftTo(1,tt)):ft.isEven()||ft.subTo(s,ft),ft.rShiftTo(1,ft);I.compareTo(N)>=0?(I.subTo(N,I),y&&z.subTo(tt,z),Z.subTo(ft,Z)):(N.subTo(I,N),y&&tt.subTo(z,tt),ft.subTo(Z,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],Vs=(1<<26)/de[de.length-1];function Ks(s){var y,I=this.abs();if(I.t==1&&I[0]<=de[de.length-1]){for(y=0;y<de.length;++y)if(I[0]==de[y])return!0;return!1;}if(I.isEven())return!1;for(y=1;y<de.length;){for(var N=de[y],z=y+1;z<de.length&&N<Vs;)N*=de[z++];for(N=I.modInt(N);y<z;)if(N%de[y++]==0)return!1;}return I.millerRabin(s);}function Zs(s){var y=this.subtract(o.ONE),I=y.getLowestSetBit();if(I<=0)return!1;var N=y.shiftRight(I);s=s+1>>1,s>de.length&&(s=de.length);for(var z=a(),Z=0;Z<s;++Z){z.fromInt(de[Math.floor(Math.random()*de.length)]);var tt=z.modPow(N,this);if(tt.compareTo(o.ONE)!=0&&tt.compareTo(y)!=0){for(var ft=1;ft++<I&&tt.compareTo(y)!=0;)if(tt=tt.modPowInt(2,this),tt.compareTo(o.ONE)==0)return!1;if(tt.compareTo(y)!=0)return!1;}}return!0;}o.prototype.chunkSize=mt,o.prototype.toRadix=Tt,o.prototype.fromRadix=yt,o.prototype.fromNumber=vt,o.prototype.bitwiseTo=Bt,o.prototype.changeBit=mr,o.prototype.addTo=Cs,o.prototype.dMultiply=Rs,o.prototype.dAddOffset=Ds,o.prototype.multiplyLowerTo=Ws,o.prototype.multiplyUpperTo=Fs,o.prototype.modInt=ks,o.prototype.millerRabin=Zs,o.prototype.clone=Q,o.prototype.intValue=_,o.prototype.byteValue=nt,o.prototype.shortValue=ut,o.prototype.signum=Pt,o.prototype.toByteArray=St,o.prototype.equals=Mt,o.prototype.min=wt,o.prototype.max=Ot,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=Jt,o.prototype.bitCount=Be,o.prototype.testBit=We,o.prototype.setBit=vr,o.prototype.clearBit=xs,o.prototype.flipBit=Ts,o.prototype.add=Is,o.prototype.subtract=Os,o.prototype.multiply=Es,o.prototype.divide=As,o.prototype.remainder=ws,o.prototype.divideAndRemainder=Ls,o.prototype.modPow=$s,o.prototype.modInverse=Hs,o.prototype.pow=Bs,o.prototype.gcd=Gs,o.prototype.isProbablePrime=Ks,o.prototype.square=Ms;var Ht=o;Ht.prototype.IsNegative=function(){return this.compareTo(Ht.ZERO)==-1;},Ht.op_Equality=function(s,y){return s.compareTo(y)==0;},Ht.op_Inequality=function(s,y){return s.compareTo(y)!=0;},Ht.op_GreaterThan=function(s,y){return s.compareTo(y)>0;},Ht.op_LessThan=function(s,y){return s.compareTo(y)<0;},Ht.op_Addition=function(s,y){return new Ht(s,void 0,void 0).add(new Ht(y,void 0,void 0));},Ht.op_Subtraction=function(s,y){return new Ht(s,void 0,void 0).subtract(new Ht(y,void 0,void 0));},Ht.Int128Mul=function(s,y){return new Ht(s,void 0,void 0).multiply(new Ht(y,void 0,void 0));},Ht.op_Division=function(s,y){return s.divide(y);},Ht.prototype.ToDouble=function(){return parseFloat(this.toString());};var Pn=function Pn(s,y){var I;if(_typeof(Object.getOwnPropertyNames)>"u"){for(I in y.prototype)(_typeof(s.prototype[I])>"u"||s.prototype[I]===Object.prototype[I])&&(s.prototype[I]=y.prototype[I]);for(I in y)_typeof(s[I])>"u"&&(s[I]=y[I]);s.$baseCtor=y;}else{for(var N=Object.getOwnPropertyNames(y.prototype),z=0;z<N.length;z++)_typeof(Object.getOwnPropertyDescriptor(s.prototype,N[z]))>"u"&&Object.defineProperty(s.prototype,N[z],Object.getOwnPropertyDescriptor(y.prototype,N[z]));for(I in y)_typeof(s[I])>"u"&&(s[I]=y[I]);s.$baseCtor=y;}};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,y){this.X=s,this.Y=y;},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,y=this.m_Parent;y!==null;)s=!s,y=y.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 y=this.m_Childs.length;this.m_Childs.push(s),s.m_Parent=this,s.m_Index=y;},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,y=this.m_AllPolys.length;s<y;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;},Pn(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,y){return Math.max(s,y);},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,y=s.length;if(this.X=0,this.Y=0,e.use_xyz){if(this.Z=0,y===3)this.X=s[0],this.Y=s[1],this.Z=s[2];else if(y===2)this.X=s[0],this.Y=s[1],this.Z=0;else if(y===1){if(s[0]instanceof e.DoublePoint){var I=s[0];this.X=e.Clipper.Round(I.X),this.Y=e.Clipper.Round(I.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(y===2)this.X=s[0],this.Y=s[1];else if(y===1){if(s[0]instanceof e.DoublePoint){var I=s[0];this.X=e.Clipper.Round(I.X),this.Y=e.Clipper.Round(I.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,y){return s.X===y.X&&s.Y===y.Y;},e.IntPoint.op_Inequality=function(s,y){return s.X!==y.X||s.Y!==y.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,y,I){this.X=s,this.Y=y,e.use_xyz&&(_typeof(I)>"u"?this.Z=0:this.Z=I);},e.IntPoint2.prototype=e.IntPoint.prototype,e.IntRect=function(){var s=arguments,y=s.length;if(y===4)this.left=s[0],this.top=s[1],this.right=s[2],this.bottom=s[3];else if(y===1){var I=s[0];this.left=I.left,this.top=I.top,this.right=I.right,this.bottom=I.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,y,I,N){this.left=s,this.top=y,this.right=I,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,y){var I=y.Pt.Y-s.Pt.Y;return I>0?1:I<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,y){var I=y;do{if(e.IntPoint.op_Equality(I.Pt,s))return!0;I=I.Next;}while(I!==y);return!1;},e.ClipperBase.prototype.PointOnLineSegment=function(s,y,I,N){return N?s.X===y.X&&s.Y===y.Y||s.X===I.X&&s.Y===I.Y||s.X>y.X==s.X<I.X&&s.Y>y.Y==s.Y<I.Y&&Ht.op_Equality(Ht.Int128Mul(s.X-y.X,I.Y-y.Y),Ht.Int128Mul(I.X-y.X,s.Y-y.Y)):s.X===y.X&&s.Y===y.Y||s.X===I.X&&s.Y===I.Y||s.X>y.X==s.X<I.X&&s.Y>y.Y==s.Y<I.Y&&(s.X-y.X)*(I.Y-y.Y)===(I.X-y.X)*(s.Y-y.Y);},e.ClipperBase.prototype.PointOnPolygon=function(s,y,I){for(var N=y;;){if(this.PointOnLineSegment(s,N.Pt,N.Next.Pt,I))return!0;if(N=N.Next,N===y)break;}return!1;},e.ClipperBase.prototype.SlopesEqual=e.ClipperBase.SlopesEqual=function(){var s=arguments,y=s.length,I,N,z,Z,tt,ft,ht;return y===3?(I=s[0],N=s[1],ht=s[2],ht?Ht.op_Equality(Ht.Int128Mul(I.Delta.Y,N.Delta.X),Ht.Int128Mul(I.Delta.X,N.Delta.Y)):e.Cast_Int64(I.Delta.Y*N.Delta.X)===e.Cast_Int64(I.Delta.X*N.Delta.Y)):y===4?(z=s[0],Z=s[1],tt=s[2],ht=s[3],ht?Ht.op_Equality(Ht.Int128Mul(z.Y-Z.Y,Z.X-tt.X),Ht.Int128Mul(z.X-Z.X,Z.Y-tt.Y)):e.Cast_Int64((z.Y-Z.Y)*(Z.X-tt.X))-e.Cast_Int64((z.X-Z.X)*(Z.Y-tt.Y))===0):(z=s[0],Z=s[1],tt=s[2],ft=s[3],ht=s[4],ht?Ht.op_Equality(Ht.Int128Mul(z.Y-Z.Y,tt.X-ft.X),Ht.Int128Mul(z.X-Z.X,tt.Y-ft.Y)):e.Cast_Int64((z.Y-Z.Y)*(tt.X-ft.X))-e.Cast_Int64((z.X-Z.X)*(tt.Y-ft.Y))===0);},e.ClipperBase.SlopesEqual3=function(s,y,I){return I?Ht.op_Equality(Ht.Int128Mul(s.Delta.Y,y.Delta.X),Ht.Int128Mul(s.Delta.X,y.Delta.Y)):e.Cast_Int64(s.Delta.Y*y.Delta.X)===e.Cast_Int64(s.Delta.X*y.Delta.Y);},e.ClipperBase.SlopesEqual4=function(s,y,I,N){return N?Ht.op_Equality(Ht.Int128Mul(s.Y-y.Y,y.X-I.X),Ht.Int128Mul(s.X-y.X,y.Y-I.Y)):e.Cast_Int64((s.Y-y.Y)*(y.X-I.X))-e.Cast_Int64((s.X-y.X)*(y.Y-I.Y))===0;},e.ClipperBase.SlopesEqual5=function(s,y,I,N,z){return z?Ht.op_Equality(Ht.Int128Mul(s.Y-y.Y,I.X-N.X),Ht.Int128Mul(s.X-y.X,I.Y-N.Y)):e.Cast_Int64((s.Y-y.Y)*(I.X-N.X))-e.Cast_Int64((s.X-y.X)*(I.Y-N.Y))===0;},e.ClipperBase.prototype.Clear=function(){this.DisposeLocalMinimaList();for(var s=0,y=this.m_edges.length;s<y;++s){for(var I=0,N=this.m_edges[s].length;I<N;++I)this.m_edges[s][I]=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,y){y.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)&&(y.Value=!0,this.RangeTest(s,y));},e.ClipperBase.prototype.InitEdge=function(s,y,I,N){s.Next=y,s.Prev=I,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,y){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=y;},e.ClipperBase.prototype.FindNextLocMin=function(s){for(var y;;){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(y=s;s.Dx===e.ClipperBase.horizontal;)s=s.Next;if(s.Top.Y!==s.Prev.Bot.Y){y.Prev.Bot.X<s.Bot.X&&(s=y);break;}}return s;},e.ClipperBase.prototype.ProcessBound=function(s,y){var I,N=s,z;if(N.OutIdx===e.ClipperBase.Skip){if(s=N,y){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)y?N=s.Next:N=s.Prev;else{y?s=N.Next:s=N.Prev;var Z=new e.LocalMinima();Z.Next=null,Z.Y=s.Bot.Y,Z.LeftBound=null,Z.RightBound=s,s.WindDelta=0,N=this.ProcessBound(s,y),this.InsertLocalMinima(Z);}return N;}if(s.Dx===e.ClipperBase.horizontal&&(y?I=s.Prev:I=s.Next,I.Dx===e.ClipperBase.horizontal?I.Bot.X!==s.Bot.X&&I.Top.X!==s.Bot.X&&this.ReverseHorizontal(s):I.Bot.X!==s.Bot.X&&this.ReverseHorizontal(s)),I=s,y){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(z=N;z.Prev.Dx===e.ClipperBase.horizontal;)z=z.Prev;z.Prev.Top.X>N.Next.Top.X&&(N=z.Prev);}for(;s!==N;)s.NextInLML=s.Next,s.Dx===e.ClipperBase.horizontal&&s!==I&&s.Bot.X!==s.Prev.Top.X&&this.ReverseHorizontal(s),s=s.Next;s.Dx===e.ClipperBase.horizontal&&s!==I&&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(z=N;z.Next.Dx===e.ClipperBase.horizontal;)z=z.Next;(z.Next.Top.X===N.Prev.Top.X||z.Next.Top.X>N.Prev.Top.X)&&(N=z.Next);}for(;s!==N;)s.NextInLML=s.Prev,s.Dx===e.ClipperBase.horizontal&&s!==I&&s.Bot.X!==s.Next.Top.X&&this.ReverseHorizontal(s),s=s.Prev;s.Dx===e.ClipperBase.horizontal&&s!==I&&s.Bot.X!==s.Next.Top.X&&this.ReverseHorizontal(s),N=N.Prev;}return N;},e.ClipperBase.prototype.AddPath=function(s,y,I){e.use_lines?!I&&y===e.PolyType.ptClip&&e.Error("AddPath: Open paths must be subject."):I||e.Error("AddPath: Open paths have been disabled.");var N=s.length-1;if(I)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(I&&N<2||!I&&N<1)return!1;for(var z=new Array(),Z=0;Z<=N;Z++)z.push(new e.TEdge());var tt=!0;z[1].Curr.X=s[1].X,z[1].Curr.Y=s[1].Y,e.use_xyz&&(z[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(z[0],z[1],z[N],s[0]),this.InitEdge(z[N],z[0],z[N-1],s[N]);for(var Z=N-1;Z>=1;--Z)ft.Value=this.m_UseFullRange,this.RangeTest(s[Z],ft),this.m_UseFullRange=ft.Value,this.InitEdge(z[Z],z[Z+1],z[Z-1],s[Z]);for(var ht=z[0],It=ht,Rt=ht;;){if(It.Curr===It.Next.Curr&&(I||It.Next!==ht)){if(It===It.Next)break;It===ht&&(ht=It.Next),It=this.RemoveEdge(It),Rt=It;continue;}if(It.Prev===It.Next)break;if(I&&e.ClipperBase.SlopesEqual4(It.Prev.Curr,It.Curr,It.Next.Curr,this.m_UseFullRange)&&(!this.PreserveCollinear||!this.Pt2IsBetweenPt1AndPt3(It.Prev.Curr,It.Curr,It.Next.Curr))){It===ht&&(ht=It.Next),It=this.RemoveEdge(It),It=It.Prev,Rt=It;continue;}if(It=It.Next,It===Rt||!I&&It.Next===ht)break;}if(!I&&It===It.Next||I&&It.Prev===It.Next)return!1;I||(this.m_HasOpenPaths=!0,ht.Prev.OutIdx=e.ClipperBase.Skip),It=ht;do this.InitEdge2(It,y),It=It.Next,tt&&It.Curr.Y!==ht.Curr.Y&&(tt=!1);while(It!==ht);if(tt){if(I)return!1;It.Prev.OutIdx=e.ClipperBase.Skip;var Lt=new e.LocalMinima();for(Lt.Next=null,Lt.Y=It.Bot.Y,Lt.LeftBound=null,Lt.RightBound=It,Lt.RightBound.Side=e.EdgeSide.esRight,Lt.RightBound.WindDelta=0;It.Bot.X!==It.Prev.Top.X&&this.ReverseHorizontal(It),It.Next.OutIdx!==e.ClipperBase.Skip;)It.NextInLML=It.Next,It=It.Next;return this.InsertLocalMinima(Lt),this.m_edges.push(z),!0;}this.m_edges.push(z);var Wt,Yt=null;for(e.IntPoint.op_Equality(It.Prev.Bot,It.Prev.Top)&&(It=It.Next);It=this.FindNextLocMin(It),It!==Yt;){Yt===null&&(Yt=It);var Lt=new e.LocalMinima();Lt.Next=null,Lt.Y=It.Bot.Y,It.Dx<It.Prev.Dx?(Lt.LeftBound=It.Prev,Lt.RightBound=It,Wt=!1):(Lt.LeftBound=It,Lt.RightBound=It.Prev,Wt=!0),Lt.LeftBound.Side=e.EdgeSide.esLeft,Lt.RightBound.Side=e.EdgeSide.esRight,I?Lt.LeftBound.Next===Lt.RightBound?Lt.LeftBound.WindDelta=-1:Lt.LeftBound.WindDelta=1:Lt.LeftBound.WindDelta=0,Lt.RightBound.WindDelta=-Lt.LeftBound.WindDelta,It=this.ProcessBound(Lt.LeftBound,Wt),It.OutIdx===e.ClipperBase.Skip&&(It=this.ProcessBound(It,Wt));var Vt=this.ProcessBound(Lt.RightBound,!Wt);Vt.OutIdx===e.ClipperBase.Skip&&(Vt=this.ProcessBound(Vt,!Wt)),Lt.LeftBound.OutIdx===e.ClipperBase.Skip?Lt.LeftBound=null:Lt.RightBound.OutIdx===e.ClipperBase.Skip&&(Lt.RightBound=null),this.InsertLocalMinima(Lt),Wt||(It=Vt);}return!0;},e.ClipperBase.prototype.AddPaths=function(s,y,I){for(var N=!1,z=0,Z=s.length;z<Z;++z)this.AddPath(s[z],y,I)&&(N=!0);return N;},e.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(s,y,I){return e.IntPoint.op_Equality(s,I)||e.IntPoint.op_Equality(s,y)||e.IntPoint.op_Equality(I,y)?!1:s.X!==I.X?y.X>s.X==y.X<I.X:y.Y>s.Y==y.Y<I.Y;},e.ClipperBase.prototype.RemoveEdge=function(s){s.Prev.Next=s.Next,s.Next.Prev=s.Prev;var y=s.Next;return s.Prev=null,y;},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 y=this.m_MinimaList;y.Next!==null&&s.Y<y.Next.Y;)y=y.Next;s.Next=y.Next,y.Next=s;}},e.ClipperBase.prototype.PopLocalMinima=function(s,y){return y.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 y=s.Top.X;s.Top.X=s.Bot.X,s.Bot.X=y,e.use_xyz&&(y=s.Top.Z,s.Top.Z=s.Bot.Z,s.Bot.Z=y);},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 y=s.LeftBound;y!==null&&(y.Curr.X=y.Bot.X,y.Curr.Y=y.Bot.Y,e.use_xyz&&(y.Curr.Z=y.Bot.Z),y.OutIdx=e.ClipperBase.Unassigned),y=s.RightBound,y!==null&&(y.Curr.X=y.Bot.X,y.Curr.Y=y.Bot.Y,e.use_xyz&&(y.Curr.Z=y.Bot.Z),y.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 y=new e.Scanbeam();y.Y=s,y.Next=this.m_Scanbeam,this.m_Scanbeam=y;}else{for(var I=this.m_Scanbeam;I.Next!==null&&s<=I.Next.Y;)I=I.Next;if(s===I.Y)return;var N=new e.Scanbeam();N.Y=s,N.Next=I.Next,I.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 y=this.m_PolyOuts[s];y.Pts=null,y=null,this.m_PolyOuts[s]=null;},e.ClipperBase.prototype.UpdateEdgeIntoAEL=function(s){s.NextInLML===null&&e.Error("UpdateEdgeIntoAEL: invalid call");var y=s.PrevInAEL,I=s.NextInAEL;return s.NextInLML.OutIdx=s.OutIdx,y!==null?y.NextInAEL=s.NextInLML:this.m_ActiveEdges=s.NextInLML,I!==null&&(I.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=y,s.NextInAEL=I,e.ClipperBase.IsHorizontal(s)||this.InsertScanbeam(s.Top.Y),s;},e.ClipperBase.prototype.SwapPositionsInAEL=function(s,y){if(!(s.NextInAEL===s.PrevInAEL||y.NextInAEL===y.PrevInAEL)){if(s.NextInAEL===y){var I=y.NextInAEL;I!==null&&(I.PrevInAEL=s);var N=s.PrevInAEL;N!==null&&(N.NextInAEL=y),y.PrevInAEL=N,y.NextInAEL=s,s.PrevInAEL=y,s.NextInAEL=I;}else if(y.NextInAEL===s){var z=s.NextInAEL;z!==null&&(z.PrevInAEL=y);var Z=y.PrevInAEL;Z!==null&&(Z.NextInAEL=s),s.PrevInAEL=Z,s.NextInAEL=y,y.PrevInAEL=s,y.NextInAEL=z;}else{var tt=s.NextInAEL,ft=s.PrevInAEL;s.NextInAEL=y.NextInAEL,s.NextInAEL!==null&&(s.NextInAEL.PrevInAEL=s),s.PrevInAEL=y.PrevInAEL,s.PrevInAEL!==null&&(s.PrevInAEL.NextInAEL=s),y.NextInAEL=tt,y.NextInAEL!==null&&(y.NextInAEL.PrevInAEL=y),y.PrevInAEL=ft,y.PrevInAEL!==null&&(y.PrevInAEL.NextInAEL=y);}s.PrevInAEL===null?this.m_ActiveEdges=s:y.PrevInAEL===null&&(this.m_ActiveEdges=y);}},e.ClipperBase.prototype.DeleteFromAEL=function(s){var y=s.PrevInAEL,I=s.NextInAEL;y===null&&I===null&&s!==this.m_ActiveEdges||(y!==null?y.NextInAEL=I:this.m_ActiveEdges=I,I!==null&&(I.PrevInAEL=y),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 y=new e.Maxima();if(y.X=s,this.m_Maxima===null)this.m_Maxima=y,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(s<this.m_Maxima.X)y.Next=this.m_Maxima,y.Prev=null,this.m_Maxima=y;else{for(var I=this.m_Maxima;I.Next!==null&&s>=I.Next.X;)I=I.Next;if(s===I.X)return;y.Next=I.Next,y.Prev=I,I.Next!==null&&(I.Next.Prev=y),I.Next=y;}},e.Clipper.prototype.Execute=function(){var s=arguments,y=s.length,I=s[1]instanceof e.PolyTree;if(y===4&&!I){var N=s[0],z=s[1],Z=s[2],tt=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(z),this.m_SubjFillType=Z,this.m_ClipFillType=tt,this.m_ClipType=N,this.m_UsingPolyTree=!1;try{var ft=this.ExecuteInternal();ft&&this.BuildResult(z);}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1;}return ft;}else if(y===4&&I){var N=s[0],ht=s[1],Z=s[2],tt=s[3];if(this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=Z,this.m_ClipFillType=tt,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(y===2&&!I){var N=s[0],z=s[1];return this.Execute(N,z,e.PolyFillType.pftEvenOdd,e.PolyFillType.pftEvenOdd);}else if(y===2&&I){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 y=s.FirstLeft;y!==null&&(y.IsHole===s.IsHole||y.Pts===null);)y=y.FirstLeft;s.FirstLeft=y;}},e.Clipper.prototype.ExecuteInternal=function(){try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var s={},y={};if(!this.PopScanbeam(s))return!1;for(this.InsertLocalMinimaIntoAEL(s.v);this.PopScanbeam(y)||this.LocalMinimaPending();){if(this.ProcessHorizontals(),this.m_GhostJoins.length=0,!this.ProcessIntersections(y.v))return!1;this.ProcessEdgesAtTopOfScanbeam(y.v),s.v=y.v,this.InsertLocalMinimaIntoAEL(s.v);}var I,N,z;for(N=0,z=this.m_PolyOuts.length;N<z;N++)I=this.m_PolyOuts[N],!(I.Pts===null||I.IsOpen)&&(I.IsHole^this.ReverseSolution)==this.Area$1(I)>0&&this.ReversePolyPtLinks(I.Pts);for(this.JoinCommonEdges(),N=0,z=this.m_PolyOuts.length;N<z;N++)I=this.m_PolyOuts[N],I.Pts!==null&&(I.IsOpen?this.FixupOutPolyline(I):this.FixupOutPolygon(I));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,y=this.m_PolyOuts.length;s<y;++s)this.DisposeOutRec(s);e.Clear(this.m_PolyOuts);},e.Clipper.prototype.AddJoin=function(s,y,I){var N=new e.Join();N.OutPt1=s,N.OutPt2=y,N.OffPt.X=I.X,N.OffPt.Y=I.Y,e.use_xyz&&(N.OffPt.Z=I.Z),this.m_Joins.push(N);},e.Clipper.prototype.AddGhostJoin=function(s,y){var I=new e.Join();I.OutPt1=s,I.OffPt.X=y.X,I.OffPt.Y=y.Y,e.use_xyz&&(I.OffPt.Z=y.Z),this.m_GhostJoins.push(I);},e.Clipper.prototype.SetZ=function(s,y,I){if(this.ZFillFunction!==null){if(s.Z!==0||this.ZFillFunction===null)return;e.IntPoint.op_Equality(s,y.Bot)?s.Z=y.Bot.Z:e.IntPoint.op_Equality(s,y.Top)?s.Z=y.Top.Z:e.IntPoint.op_Equality(s,I.Bot)?s.Z=I.Bot.Z:e.IntPoint.op_Equality(s,I.Top)?s.Z=I.Top.Z:this.ZFillFunction(y.Bot,y.Top,I.Bot,I.Top,s);}},e.Clipper.prototype.InsertLocalMinimaIntoAEL=function(s){for(var y={},I,N;this.PopLocalMinima(s,y);){I=y.v.LeftBound,N=y.v.RightBound;var z=null;if(I===null?(this.InsertEdgeIntoAEL(N,null),this.SetWindingCount(N),this.IsContributing(N)&&(z=this.AddOutPt(N,N.Bot))):N===null?(this.InsertEdgeIntoAEL(I,null),this.SetWindingCount(I),this.IsContributing(I)&&(z=this.AddOutPt(I,I.Bot)),this.InsertScanbeam(I.Top.Y)):(this.InsertEdgeIntoAEL(I,null),this.InsertEdgeIntoAEL(N,I),this.SetWindingCount(I),N.WindCnt=I.WindCnt,N.WindCnt2=I.WindCnt2,this.IsContributing(I)&&(z=this.AddLocalMinPoly(I,N,I.Bot)),this.InsertScanbeam(I.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)),!(I===null||N===null)){if(z!==null&&e.ClipperBase.IsHorizontal(N)&&this.m_GhostJoins.length>0&&N.WindDelta!==0)for(var Z=0,tt=this.m_GhostJoins.length;Z<tt;Z++){var ft=this.m_GhostJoins[Z];this.HorzSegmentsOverlap(ft.OutPt1.Pt.X,ft.OffPt.X,N.Bot.X,N.Top.X)&&this.AddJoin(ft.OutPt1,z,ft.OffPt);}if(I.OutIdx>=0&&I.PrevInAEL!==null&&I.PrevInAEL.Curr.X===I.Bot.X&&I.PrevInAEL.OutIdx>=0&&e.ClipperBase.SlopesEqual5(I.PrevInAEL.Curr,I.PrevInAEL.Top,I.Curr,I.Top,this.m_UseFullRange)&&I.WindDelta!==0&&I.PrevInAEL.WindDelta!==0){var ht=this.AddOutPt(I.PrevInAEL,I.Bot);this.AddJoin(z,ht,I.Top);}if(I.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(z,ht,N.Top);}var It=I.NextInAEL;if(It!==null)for(;It!==N;)this.IntersectEdges(N,It,I.Curr),It=It.NextInAEL;}}}},e.Clipper.prototype.InsertEdgeIntoAEL=function(s,y){if(this.m_ActiveEdges===null)s.PrevInAEL=null,s.NextInAEL=null,this.m_ActiveEdges=s;else if(y===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(y===null&&(y=this.m_ActiveEdges);y.NextInAEL!==null&&!this.E2InsertsBeforeE1(y.NextInAEL,s);)y=y.NextInAEL;s.NextInAEL=y.NextInAEL,y.NextInAEL!==null&&(y.NextInAEL.PrevInAEL=s),s.PrevInAEL=y,y.NextInAEL=s;}},e.Clipper.prototype.E2InsertsBeforeE1=function(s,y){return y.Curr.X===s.Curr.X?y.Top.Y>s.Top.Y?y.Top.X<e.Clipper.TopX(s,y.Top.Y):s.Top.X>e.Clipper.TopX(y,s.Top.Y):y.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 y,I;switch(s.PolyTyp===e.PolyType.ptSubject?(y=this.m_SubjFillType,I=this.m_ClipFillType):(y=this.m_ClipFillType,I=this.m_SubjFillType),y){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(I){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(I){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(I){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(I){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(I){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 y=s.PrevInAEL;y!==null&&(y.PolyTyp!==s.PolyTyp||y.WindDelta===0);)y=y.PrevInAEL;if(y===null){var I=s.PolyTyp===e.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;s.WindDelta===0?s.WindCnt=I===e.PolyFillType.pftNegative?-1:1:s.WindCnt=s.WindDelta,s.WindCnt2=0,y=this.m_ActiveEdges;}else if(s.WindDelta===0&&this.m_ClipType!==e.ClipType.ctUnion)s.WindCnt=1,s.WindCnt2=y.WindCnt2,y=y.NextInAEL;else if(this.IsEvenOddFillType(s)){if(s.WindDelta===0){for(var N=!0,z=y.PrevInAEL;z!==null;)z.PolyTyp===y.PolyTyp&&z.WindDelta!==0&&(N=!N),z=z.PrevInAEL;s.WindCnt=N?0:1;}else s.WindCnt=s.WindDelta;s.WindCnt2=y.WindCnt2,y=y.NextInAEL;}else y.WindCnt*y.WindDelta<0?Math.abs(y.WindCnt)>1?y.WindDelta*s.WindDelta<0?s.WindCnt=y.WindCnt:s.WindCnt=y.WindCnt+s.WindDelta:s.WindCnt=s.WindDelta===0?1:s.WindDelta:s.WindDelta===0?s.WindCnt=y.WindCnt<0?y.WindCnt-1:y.WindCnt+1:y.WindDelta*s.WindDelta<0?s.WindCnt=y.WindCnt:s.WindCnt=y.WindCnt+s.WindDelta,s.WindCnt2=y.WindCnt2,y=y.NextInAEL;if(this.IsEvenOddAltFillType(s))for(;y!==s;)y.WindDelta!==0&&(s.WindCnt2=s.WindCnt2===0?1:0),y=y.NextInAEL;else for(;y!==s;)s.WindCnt2+=y.WindDelta,y=y.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 y=s.v;return this.m_SortedEdges=s.v.NextInSEL,this.m_SortedEdges!==null&&(this.m_SortedEdges.PrevInSEL=null),y.NextInSEL=null,y.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,y){if(!(s.NextInSEL===null&&s.PrevInSEL===null)&&!(y.NextInSEL===null&&y.PrevInSEL===null)){if(s.NextInSEL===y){var I=y.NextInSEL;I!==null&&(I.PrevInSEL=s);var N=s.PrevInSEL;N!==null&&(N.NextInSEL=y),y.PrevInSEL=N,y.NextInSEL=s,s.PrevInSEL=y,s.NextInSEL=I;}else if(y.NextInSEL===s){var I=s.NextInSEL;I!==null&&(I.PrevInSEL=y);var N=y.PrevInSEL;N!==null&&(N.NextInSEL=s),s.PrevInSEL=N,s.NextInSEL=y,y.PrevInSEL=s,y.NextInSEL=I;}else{var I=s.NextInSEL,N=s.PrevInSEL;s.NextInSEL=y.NextInSEL,s.NextInSEL!==null&&(s.NextInSEL.PrevInSEL=s),s.PrevInSEL=y.PrevInSEL,s.PrevInSEL!==null&&(s.PrevInSEL.NextInSEL=s),y.NextInSEL=I,y.NextInSEL!==null&&(y.NextInSEL.PrevInSEL=y),y.PrevInSEL=N,y.PrevInSEL!==null&&(y.PrevInSEL.NextInSEL=y);}s.PrevInSEL===null?this.m_SortedEdges=s:y.PrevInSEL===null&&(this.m_SortedEdges=y);}},e.Clipper.prototype.AddLocalMaxPoly=function(s,y,I){this.AddOutPt(s,I),y.WindDelta===0&&this.AddOutPt(y,I),s.OutIdx===y.OutIdx?(s.OutIdx=-1,y.OutIdx=-1):s.OutIdx<y.OutIdx?this.AppendPolygon(s,y):this.AppendPolygon(y,s);},e.Clipper.prototype.AddLocalMinPoly=function(s,y,I){var N,z,Z;if(e.ClipperBase.IsHorizontal(y)||s.Dx>y.Dx?(N=this.AddOutPt(s,I),y.OutIdx=s.OutIdx,s.Side=e.EdgeSide.esLeft,y.Side=e.EdgeSide.esRight,z=s,z.PrevInAEL===y?Z=y.PrevInAEL:Z=z.PrevInAEL):(N=this.AddOutPt(y,I),s.OutIdx=y.OutIdx,s.Side=e.EdgeSide.esRight,y.Side=e.EdgeSide.esLeft,z=y,z.PrevInAEL===s?Z=s.PrevInAEL:Z=z.PrevInAEL),Z!==null&&Z.OutIdx>=0&&Z.Top.Y<I.Y&&z.Top.Y<I.Y){var tt=e.Clipper.TopX(Z,I.Y),ft=e.Clipper.TopX(z,I.Y);if(tt===ft&&z.WindDelta!==0&&Z.WindDelta!==0&&e.ClipperBase.SlopesEqual5(new e.IntPoint2(tt,I.Y),Z.Top,new e.IntPoint2(ft,I.Y),z.Top,this.m_UseFullRange)){var ht=this.AddOutPt(Z,I);this.AddJoin(N,ht,z.Top);}}return N;},e.Clipper.prototype.AddOutPt=function(s,y){if(s.OutIdx<0){var I=this.CreateOutRec();I.IsOpen=s.WindDelta===0;var N=new e.OutPt();return I.Pts=N,N.Idx=I.Idx,N.Pt.X=y.X,N.Pt.Y=y.Y,e.use_xyz&&(N.Pt.Z=y.Z),N.Next=N,N.Prev=N,I.IsOpen||this.SetHoleState(s,I),s.OutIdx=I.Idx,N;}else{var I=this.m_PolyOuts[s.OutIdx],z=I.Pts,Z=s.Side===e.EdgeSide.esLeft;if(Z&&e.IntPoint.op_Equality(y,z.Pt))return z;if(!Z&&e.IntPoint.op_Equality(y,z.Prev.Pt))return z.Prev;var N=new e.OutPt();return N.Idx=I.Idx,N.Pt.X=y.X,N.Pt.Y=y.Y,e.use_xyz&&(N.Pt.Z=y.Z),N.Next=z,N.Prev=z.Prev,N.Prev.Next=N,z.Prev=N,Z&&(I.Pts=N),N;}},e.Clipper.prototype.GetLastOutPt=function(s){var y=this.m_PolyOuts[s.OutIdx];return s.Side===e.EdgeSide.esLeft?y.Pts:y.Pts.Prev;},e.Clipper.prototype.SwapPoints=function(s,y){var I=new e.IntPoint1(s.Value);s.Value.X=y.Value.X,s.Value.Y=y.Value.Y,e.use_xyz&&(s.Value.Z=y.Value.Z),y.Value.X=I.X,y.Value.Y=I.Y,e.use_xyz&&(y.Value.Z=I.Z);},e.Clipper.prototype.HorzSegmentsOverlap=function(s,y,I,N){var z;return s>y&&(z=s,s=y,y=z),I>N&&(z=I,I=N,N=z),s<N&&I<y;},e.Clipper.prototype.SetHoleState=function(s,y){for(var I=s.PrevInAEL,N=null;I!==null;)I.OutIdx>=0&&I.WindDelta!==0&&(N===null?N=I:N.OutIdx===I.OutIdx&&(N=null)),I=I.PrevInAEL;N===null?(y.FirstLeft=null,y.IsHole=!1):(y.FirstLeft=this.m_PolyOuts[N.OutIdx],y.IsHole=!y.FirstLeft.IsHole);},e.Clipper.prototype.GetDx=function(s,y){return s.Y===y.Y?e.ClipperBase.horizontal:(y.X-s.X)/(y.Y-s.Y);},e.Clipper.prototype.FirstIsBottomPt=function(s,y){for(var I=s.Prev;e.IntPoint.op_Equality(I.Pt,s.Pt)&&I!==s;)I=I.Prev;var N=Math.abs(this.GetDx(s.Pt,I.Pt));for(I=s.Next;e.IntPoint.op_Equality(I.Pt,s.Pt)&&I!==s;)I=I.Next;var z=Math.abs(this.GetDx(s.Pt,I.Pt));for(I=y.Prev;e.IntPoint.op_Equality(I.Pt,y.Pt)&&I!==y;)I=I.Prev;var Z=Math.abs(this.GetDx(y.Pt,I.Pt));for(I=y.Next;e.IntPoint.op_Equality(I.Pt,y.Pt)&&I!==y;)I=I.Next;var tt=Math.abs(this.GetDx(y.Pt,I.Pt));return Math.max(N,z)===Math.max(Z,tt)&&Math.min(N,z)===Math.min(Z,tt)?this.Area(s)>0:N>=Z&&N>=tt||z>=Z&&z>=tt;},e.Clipper.prototype.GetBottomPt=function(s){for(var y=null,I=s.Next;I!==s;)I.Pt.Y>s.Pt.Y?(s=I,y=null):I.Pt.Y===s.Pt.Y&&I.Pt.X<=s.Pt.X&&(I.Pt.X<s.Pt.X?(y=null,s=I):I.Next!==s&&I.Prev!==s&&(y=I)),I=I.Next;if(y!==null)for(;y!==I;)for(this.FirstIsBottomPt(I,y)||(s=y),y=y.Next;e.IntPoint.op_Inequality(y.Pt,s.Pt);)y=y.Next;return s;},e.Clipper.prototype.GetLowermostRec=function(s,y){s.BottomPt===null&&(s.BottomPt=this.GetBottomPt(s.Pts)),y.BottomPt===null&&(y.BottomPt=this.GetBottomPt(y.Pts));var I=s.BottomPt,N=y.BottomPt;return I.Pt.Y>N.Pt.Y?s:I.Pt.Y<N.Pt.Y?y:I.Pt.X<N.Pt.X?s:I.Pt.X>N.Pt.X||I.Next===I?y:N.Next===N||this.FirstIsBottomPt(I,N)?s:y;},e.Clipper.prototype.OutRec1RightOfOutRec2=function(s,y){do if(s=s.FirstLeft,s===y)return!0;while(s!==null);return!1;},e.Clipper.prototype.GetOutRec=function(s){for(var y=this.m_PolyOuts[s];y!==this.m_PolyOuts[y.Idx];)y=this.m_PolyOuts[y.Idx];return y;},e.Clipper.prototype.AppendPolygon=function(s,y){var I=this.m_PolyOuts[s.OutIdx],N=this.m_PolyOuts[y.OutIdx],z;this.OutRec1RightOfOutRec2(I,N)?z=N:this.OutRec1RightOfOutRec2(N,I)?z=I:z=this.GetLowermostRec(I,N);var Z=I.Pts,tt=Z.Prev,ft=N.Pts,ht=ft.Prev;s.Side===e.EdgeSide.esLeft?y.Side===e.EdgeSide.esLeft?(this.ReversePolyPtLinks(ft),ft.Next=Z,Z.Prev=ft,tt.Next=ht,ht.Prev=tt,I.Pts=ht):(ht.Next=Z,Z.Prev=ht,ft.Prev=tt,tt.Next=ft,I.Pts=ft):y.Side===e.EdgeSide.esRight?(this.ReversePolyPtLinks(ft),tt.Next=ht,ht.Prev=tt,ft.Next=Z,Z.Prev=ft):(tt.Next=ft,ft.Prev=tt,Z.Prev=ht,ht.Next=Z),I.BottomPt=null,z===N&&(N.FirstLeft!==I&&(I.FirstLeft=N.FirstLeft),I.IsHole=N.IsHole),N.Pts=null,N.BottomPt=null,N.FirstLeft=I;var It=s.OutIdx,Rt=y.OutIdx;s.OutIdx=-1,y.OutIdx=-1;for(var Lt=this.m_ActiveEdges;Lt!==null;){if(Lt.OutIdx===Rt){Lt.OutIdx=It,Lt.Side=s.Side;break;}Lt=Lt.NextInAEL;}N.Idx=I.Idx;},e.Clipper.prototype.ReversePolyPtLinks=function(s){if(s!==null){var y,I;y=s;do I=y.Next,y.Next=y.Prev,y.Prev=I,y=I;while(y!==s);}},e.Clipper.SwapSides=function(s,y){var I=s.Side;s.Side=y.Side,y.Side=I;},e.Clipper.SwapPolyIndexes=function(s,y){var I=s.OutIdx;s.OutIdx=y.OutIdx,y.OutIdx=I;},e.Clipper.prototype.IntersectEdges=function(s,y,I){var N=s.OutIdx>=0,z=y.OutIdx>=0;if(e.use_xyz&&this.SetZ(I,s,y),e.use_lines&&(s.WindDelta===0||y.WindDelta===0)){if(s.WindDelta===0&&y.WindDelta===0)return;s.PolyTyp===y.PolyTyp&&s.WindDelta!==y.WindDelta&&this.m_ClipType===e.ClipType.ctUnion?s.WindDelta===0?z&&(this.AddOutPt(s,I),N&&(s.OutIdx=-1)):N&&(this.AddOutPt(y,I),z&&(y.OutIdx=-1)):s.PolyTyp!==y.PolyTyp&&(s.WindDelta===0&&Math.abs(y.WindCnt)===1&&(this.m_ClipType!==e.ClipType.ctUnion||y.WindCnt2===0)?(this.AddOutPt(s,I),N&&(s.OutIdx=-1)):y.WindDelta===0&&Math.abs(s.WindCnt)===1&&(this.m_ClipType!==e.ClipType.ctUnion||s.WindCnt2===0)&&(this.AddOutPt(y,I),z&&(y.OutIdx=-1)));return;}if(s.PolyTyp===y.PolyTyp){if(this.IsEvenOddFillType(s)){var Z=s.WindCnt;s.WindCnt=y.WindCnt,y.WindCnt=Z;}else s.WindCnt+y.WindDelta===0?s.WindCnt=-s.WindCnt:s.WindCnt+=y.WindDelta,y.WindCnt-s.WindDelta===0?y.WindCnt=-y.WindCnt:y.WindCnt-=s.WindDelta;}else this.IsEvenOddFillType(y)?s.WindCnt2=s.WindCnt2===0?1:0:s.WindCnt2+=y.WindDelta,this.IsEvenOddFillType(s)?y.WindCnt2=y.WindCnt2===0?1:0:y.WindCnt2-=s.WindDelta;var tt,ft,ht,It;s.PolyTyp===e.PolyType.ptSubject?(tt=this.m_SubjFillType,ht=this.m_ClipFillType):(tt=this.m_ClipFillType,ht=this.m_SubjFillType),y.PolyTyp===e.PolyType.ptSubject?(ft=this.m_SubjFillType,It=this.m_ClipFillType):(ft=this.m_ClipFillType,It=this.m_SubjFillType);var Rt,Lt;switch(tt){case e.PolyFillType.pftPositive:Rt=s.WindCnt;break;case e.PolyFillType.pftNegative:Rt=-s.WindCnt;break;default:Rt=Math.abs(s.WindCnt);break;}switch(ft){case e.PolyFillType.pftPositive:Lt=y.WindCnt;break;case e.PolyFillType.pftNegative:Lt=-y.WindCnt;break;default:Lt=Math.abs(y.WindCnt);break;}if(N&&z)Rt!==0&&Rt!==1||Lt!==0&&Lt!==1||s.PolyTyp!==y.PolyTyp&&this.m_ClipType!==e.ClipType.ctXor?this.AddLocalMaxPoly(s,y,I):(this.AddOutPt(s,I),this.AddOutPt(y,I),e.Clipper.SwapSides(s,y),e.Clipper.SwapPolyIndexes(s,y));else if(N)(Lt===0||Lt===1)&&(this.AddOutPt(s,I),e.Clipper.SwapSides(s,y),e.Clipper.SwapPolyIndexes(s,y));else if(z)(Rt===0||Rt===1)&&(this.AddOutPt(y,I),e.Clipper.SwapSides(s,y),e.Clipper.SwapPolyIndexes(s,y));else if((Rt===0||Rt===1)&&(Lt===0||Lt===1)){var Wt,Yt;switch(ht){case e.PolyFillType.pftPositive:Wt=s.WindCnt2;break;case e.PolyFillType.pftNegative:Wt=-s.WindCnt2;break;default:Wt=Math.abs(s.WindCnt2);break;}switch(It){case e.PolyFillType.pftPositive:Yt=y.WindCnt2;break;case e.PolyFillType.pftNegative:Yt=-y.WindCnt2;break;default:Yt=Math.abs(y.WindCnt2);break;}if(s.PolyTyp!==y.PolyTyp)this.AddLocalMinPoly(s,y,I);else if(Rt===1&&Lt===1)switch(this.m_ClipType){case e.ClipType.ctIntersection:Wt>0&&Yt>0&&this.AddLocalMinPoly(s,y,I);break;case e.ClipType.ctUnion:Wt<=0&&Yt<=0&&this.AddLocalMinPoly(s,y,I);break;case e.ClipType.ctDifference:(s.PolyTyp===e.PolyType.ptClip&&Wt>0&&Yt>0||s.PolyTyp===e.PolyType.ptSubject&&Wt<=0&&Yt<=0)&&this.AddLocalMinPoly(s,y,I);break;case e.ClipType.ctXor:this.AddLocalMinPoly(s,y,I);break;}else e.Clipper.SwapSides(s,y);}},e.Clipper.prototype.DeleteFromSEL=function(s){var y=s.PrevInSEL,I=s.NextInSEL;y===null&&I===null&&s!==this.m_SortedEdges||(y!==null?y.NextInSEL=I:this.m_SortedEdges=I,I!==null&&(I.PrevInSEL=y),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,y){s.Bot.X<s.Top.X?(y.Left=s.Bot.X,y.Right=s.Top.X,y.Dir=e.Direction.dLeftToRight):(y.Left=s.Top.X,y.Right=s.Bot.X,y.Dir=e.Direction.dRightToLeft);},e.Clipper.prototype.ProcessHorizontal=function(s){var y={Dir:null,Left:null,Right:null};this.GetHorzDirection(s,y);for(var I=y.Dir,N=y.Left,z=y.Right,Z=s.WindDelta===0,tt=s,ft=null;tt.NextInLML!==null&&e.ClipperBase.IsHorizontal(tt.NextInLML);)tt=tt.NextInLML;tt.NextInLML===null&&(ft=this.GetMaximaPair(tt));var ht=this.m_Maxima;if(ht!==null)if(I===e.Direction.dLeftToRight){for(;ht!==null&&ht.X<=s.Bot.X;)ht=ht.Next;ht!==null&&ht.X>=tt.Top.X&&(ht=null);}else{for(;ht.Next!==null&&ht.Next.X<s.Bot.X;)ht=ht.Next;ht.X<=tt.Top.X&&(ht=null);}for(var It=null;;){for(var Rt=s===tt,Lt=this.GetNextInAEL(s,I);Lt!==null;){if(ht!==null)if(I===e.Direction.dLeftToRight)for(;ht!==null&&ht.X<Lt.Curr.X;)s.OutIdx>=0&&!Z&&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&&!Z&&this.AddOutPt(s,new e.IntPoint2(ht.X,s.Bot.Y)),ht=ht.Prev;if(I===e.Direction.dLeftToRight&&Lt.Curr.X>z||I===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&&!Z){e.use_xyz&&(I===e.Direction.dLeftToRight?this.SetZ(Lt.Curr,s,Lt):this.SetZ(Lt.Curr,Lt,s)),It=this.AddOutPt(s,Lt.Curr);for(var Wt=this.m_SortedEdges;Wt!==null;){if(Wt.OutIdx>=0&&this.HorzSegmentsOverlap(s.Bot.X,s.Top.X,Wt.Bot.X,Wt.Top.X)){var Yt=this.GetLastOutPt(Wt);this.AddJoin(Yt,It,Wt.Top);}Wt=Wt.NextInSEL;}this.AddGhostJoin(It,s.Bot);}if(Lt===ft&&Rt){s.OutIdx>=0&&this.AddLocalMaxPoly(s,ft,s.Top),this.DeleteFromAEL(s),this.DeleteFromAEL(ft);return;}if(I===e.Direction.dLeftToRight){var Vt=new e.IntPoint2(Lt.Curr.X,s.Curr.Y);this.IntersectEdges(s,Lt,Vt);}else{var Vt=new e.IntPoint2(Lt.Curr.X,s.Curr.Y);this.IntersectEdges(Lt,s,Vt);}var Kt=this.GetNextInAEL(Lt,I);this.SwapPositionsInAEL(s,Lt),Lt=Kt;}if(s.NextInLML===null||!e.ClipperBase.IsHorizontal(s.NextInLML))break;s=this.UpdateEdgeIntoAEL(s),s.OutIdx>=0&&this.AddOutPt(s,s.Bot),y={Dir:I,Left:N,Right:z},this.GetHorzDirection(s,y),I=y.Dir,N=y.Left,z=y.Right;}if(s.OutIdx>=0&&It===null){It=this.GetLastOutPt(s);for(var Wt=this.m_SortedEdges;Wt!==null;){if(Wt.OutIdx>=0&&this.HorzSegmentsOverlap(s.Bot.X,s.Top.X,Wt.Bot.X,Wt.Top.X)){var Yt=this.GetLastOutPt(Wt);this.AddJoin(Yt,It,Wt.Top);}Wt=Wt.NextInSEL;}this.AddGhostJoin(It,s.Top);}if(s.NextInLML!==null){if(s.OutIdx>=0){if(It=this.AddOutPt(s,s.Top),s=this.UpdateEdgeIntoAEL(s),s.WindDelta===0)return;var ee=s.PrevInAEL,Kt=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(It,Yt,s.Top);}else if(Kt!==null&&Kt.Curr.X===s.Bot.X&&Kt.Curr.Y===s.Bot.Y&&Kt.WindDelta!==0&&Kt.OutIdx>=0&&Kt.Curr.Y>Kt.Top.Y&&e.ClipperBase.SlopesEqual3(s,Kt,this.m_UseFullRange)){var Yt=this.AddOutPt(Kt,s.Bot);this.AddJoin(It,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,y){return y===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,y){return s!==null&&s.Top.Y===y&&s.NextInLML===null;},e.Clipper.prototype.IsIntermediate=function(s,y){return s.Top.Y===y&&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 y=this.GetMaximaPair(s);return y===null||y.OutIdx===e.ClipperBase.Skip||y.NextInAEL===y.PrevInAEL&&!e.ClipperBase.IsHorizontal(y)?null:y;},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 y=this.m_ActiveEdges;for(this.m_SortedEdges=y;y!==null;)y.PrevInSEL=y.PrevInAEL,y.NextInSEL=y.NextInAEL,y.Curr.X=e.Clipper.TopX(y,s),y=y.NextInAEL;for(var I=!0;I&&this.m_SortedEdges!==null;){for(I=!1,y=this.m_SortedEdges;y.NextInSEL!==null;){var N=y.NextInSEL,z=new e.IntPoint0();if(y.Curr.X>N.Curr.X){this.IntersectPoint(y,N,z),z.Y<s&&(z=new e.IntPoint2(e.Clipper.TopX(y,s),s));var Z=new e.IntersectNode();Z.Edge1=y,Z.Edge2=N,Z.Pt.X=z.X,Z.Pt.Y=z.Y,e.use_xyz&&(Z.Pt.Z=z.Z),this.m_IntersectList.push(Z),this.SwapPositionsInSEL(y,N),I=!0;}else y=N;}if(y.PrevInSEL!==null)y.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,y){return y.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,y=0;y<s;y++){if(!this.EdgesAdjacent(this.m_IntersectList[y])){for(var I=y+1;I<s&&!this.EdgesAdjacent(this.m_IntersectList[I]);)I++;if(I===s)return!1;var N=this.m_IntersectList[y];this.m_IntersectList[y]=this.m_IntersectList[I],this.m_IntersectList[I]=N;}this.SwapPositionsInSEL(this.m_IntersectList[y].Edge1,this.m_IntersectList[y].Edge2);}return!0;},e.Clipper.prototype.ProcessIntersectList=function(){for(var s=0,y=this.m_IntersectList.length;s<y;s++){var I=this.m_IntersectList[s];this.IntersectEdges(I.Edge1,I.Edge2,I.Pt),this.SwapPositionsInAEL(I.Edge1,I.Edge2);}this.m_IntersectList.length=0;};var Js=function Js(s){return s<0?Math.ceil(s-0.5):Math.round(s);},Qs=function Qs(s){return s<0?Math.ceil(s-0.5):Math.floor(s+0.5);},qs=function qs(s){return s<0?-Math.round(Math.abs(s)):Math.round(s);},_s=function _s(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=Js:i.chromium?e.Clipper.Round=qs:i.safari?e.Clipper.Round=_s:e.Clipper.Round=Qs,e.Clipper.TopX=function(s,y){return y===s.Top.Y?s.Top.X:s.Bot.X+e.Clipper.Round(s.Dx*(y-s.Bot.Y));},e.Clipper.prototype.IntersectPoint=function(s,y,I){I.X=0,I.Y=0;var N,z;if(s.Dx===y.Dx){I.Y=s.Curr.Y,I.X=e.Clipper.TopX(s,I.Y);return;}if(s.Delta.X===0)I.X=s.Bot.X,e.ClipperBase.IsHorizontal(y)?I.Y=y.Bot.Y:(z=y.Bot.Y-y.Bot.X/y.Dx,I.Y=e.Clipper.Round(I.X/y.Dx+z));else if(y.Delta.X===0)I.X=y.Bot.X,e.ClipperBase.IsHorizontal(s)?I.Y=s.Bot.Y:(N=s.Bot.Y-s.Bot.X/s.Dx,I.Y=e.Clipper.Round(I.X/s.Dx+N));else{N=s.Bot.X-s.Bot.Y*s.Dx,z=y.Bot.X-y.Bot.Y*y.Dx;var Z=(z-N)/(s.Dx-y.Dx);I.Y=e.Clipper.Round(Z),Math.abs(s.Dx)<Math.abs(y.Dx)?I.X=e.Clipper.Round(s.Dx*Z+N):I.X=e.Clipper.Round(y.Dx*Z+z);}if(I.Y<s.Top.Y||I.Y<y.Top.Y){if(s.Top.Y>y.Top.Y)return I.Y=s.Top.Y,I.X=e.Clipper.TopX(y,s.Top.Y),I.X<s.Top.X;I.Y=y.Top.Y,Math.abs(s.Dx)<Math.abs(y.Dx)?I.X=e.Clipper.TopX(s,I.Y):I.X=e.Clipper.TopX(y,I.Y);}I.Y>s.Curr.Y&&(I.Y=s.Curr.Y,Math.abs(s.Dx)>Math.abs(y.Dx)?I.X=e.Clipper.TopX(y,I.Y):I.X=e.Clipper.TopX(s,I.Y));},e.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(s){for(var y=this.m_ActiveEdges;y!==null;){var I=this.IsMaxima(y,s);if(I){var N=this.GetMaximaPairEx(y);I=N===null||!e.ClipperBase.IsHorizontal(N);}if(I){this.StrictlySimple&&this.InsertMaxima(y.Top.X);var z=y.PrevInAEL;this.DoMaxima(y),z===null?y=this.m_ActiveEdges:y=z.NextInAEL;}else{if(this.IsIntermediate(y,s)&&e.ClipperBase.IsHorizontal(y.NextInLML)?(y=this.UpdateEdgeIntoAEL(y),y.OutIdx>=0&&this.AddOutPt(y,y.Bot),this.AddEdgeToSEL(y)):(y.Curr.X=e.Clipper.TopX(y,s),y.Curr.Y=s),e.use_xyz&&(y.Top.Y===s?y.Curr.Z=y.Top.Z:y.Bot.Y===s?y.Curr.Z=y.Bot.Z:y.Curr.Z=0),this.StrictlySimple){var z=y.PrevInAEL;if(y.OutIdx>=0&&y.WindDelta!==0&&z!==null&&z.OutIdx>=0&&z.Curr.X===y.Curr.X&&z.WindDelta!==0){var Z=new e.IntPoint1(y.Curr);e.use_xyz&&this.SetZ(Z,z,y);var tt=this.AddOutPt(z,Z),ft=this.AddOutPt(y,Z);this.AddJoin(tt,ft,Z);}}y=y.NextInAEL;}}for(this.ProcessHorizontals(),this.m_Maxima=null,y=this.m_ActiveEdges;y!==null;){if(this.IsIntermediate(y,s)){var tt=null;y.OutIdx>=0&&(tt=this.AddOutPt(y,y.Top)),y=this.UpdateEdgeIntoAEL(y);var z=y.PrevInAEL,ht=y.NextInAEL;if(z!==null&&z.Curr.X===y.Bot.X&&z.Curr.Y===y.Bot.Y&&tt!==null&&z.OutIdx>=0&&z.Curr.Y===z.Top.Y&&e.ClipperBase.SlopesEqual5(y.Curr,y.Top,z.Curr,z.Top,this.m_UseFullRange)&&y.WindDelta!==0&&z.WindDelta!==0){var ft=this.AddOutPt(ePrev2,y.Bot);this.AddJoin(tt,ft,y.Top);}else if(ht!==null&&ht.Curr.X===y.Bot.X&&ht.Curr.Y===y.Bot.Y&&tt!==null&&ht.OutIdx>=0&&ht.Curr.Y===ht.Top.Y&&e.ClipperBase.SlopesEqual5(y.Curr,y.Top,ht.Curr,ht.Top,this.m_UseFullRange)&&y.WindDelta!==0&&ht.WindDelta!==0){var ft=this.AddOutPt(ht,y.Bot);this.AddJoin(tt,ft,y.Top);}}y=y.NextInAEL;}},e.Clipper.prototype.DoMaxima=function(s){var y=this.GetMaximaPairEx(s);if(y===null){s.OutIdx>=0&&this.AddOutPt(s,s.Top),this.DeleteFromAEL(s);return;}for(var I=s.NextInAEL;I!==null&&I!==y;)this.IntersectEdges(s,I,s.Top),this.SwapPositionsInAEL(s,I),I=s.NextInAEL;s.OutIdx===-1&&y.OutIdx===-1?(this.DeleteFromAEL(s),this.DeleteFromAEL(y)):s.OutIdx>=0&&y.OutIdx>=0?(s.OutIdx>=0&&this.AddLocalMaxPoly(s,y,s.Top),this.DeleteFromAEL(s),this.DeleteFromAEL(y)):e.use_lines&&s.WindDelta===0?(s.OutIdx>=0&&(this.AddOutPt(s,s.Top),s.OutIdx=e.ClipperBase.Unassigned),this.DeleteFromAEL(s),y.OutIdx>=0&&(this.AddOutPt(y,s.Top),y.OutIdx=e.ClipperBase.Unassigned),this.DeleteFromAEL(y)):e.Error("DoMaxima error");},e.Clipper.ReversePaths=function(s){for(var y=0,I=s.length;y<I;y++)s[y].reverse();},e.Clipper.Orientation=function(s){return e.Clipper.Area(s)>=0;},e.Clipper.prototype.PointCount=function(s){if(s===null)return 0;var y=0,I=s;do y++,I=I.Next;while(I!==s);return y;},e.Clipper.prototype.BuildResult=function(s){e.Clear(s);for(var y=0,I=this.m_PolyOuts.length;y<I;y++){var N=this.m_PolyOuts[y];if(N.Pts!==null){var z=N.Pts.Prev,Z=this.PointCount(z);if(!(Z<2)){for(var tt=new Array(Z),ft=0;ft<Z;ft++)tt[ft]=z.Pt,z=z.Prev;s.push(tt);}}}},e.Clipper.prototype.BuildResult2=function(s){s.Clear();for(var y=0,I=this.m_PolyOuts.length;y<I;y++){var N=this.m_PolyOuts[y],z=this.PointCount(N.Pts);if(!(N.IsOpen&&z<2||!N.IsOpen&&z<3)){this.FixHoleLinkage(N);var Z=new e.PolyNode();s.m_AllPolys.push(Z),N.PolyNode=Z,Z.m_polygon.length=z;for(var tt=N.Pts.Prev,ft=0;ft<z;ft++)Z.m_polygon[ft]=tt.Pt,tt=tt.Prev;}}for(var y=0,I=this.m_PolyOuts.length;y<I;y++){var N=this.m_PolyOuts[y];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 y=s.Pts,I=y.Prev;y!==I;)if(y=y.Next,e.IntPoint.op_Equality(y.Pt,y.Prev.Pt)){y===I&&(I=y.Prev);var N=y.Prev;N.Next=y.Next,y.Next.Prev=N,y=N;}y===y.Prev&&(s.Pts=null);},e.Clipper.prototype.FixupOutPolygon=function(s){var y=null;s.BottomPt=null;for(var I=s.Pts,N=this.PreserveCollinear||this.StrictlySimple;;){if(I.Prev===I||I.Prev===I.Next){s.Pts=null;return;}if(e.IntPoint.op_Equality(I.Pt,I.Next.Pt)||e.IntPoint.op_Equality(I.Pt,I.Prev.Pt)||e.ClipperBase.SlopesEqual4(I.Prev.Pt,I.Pt,I.Next.Pt,this.m_UseFullRange)&&(!N||!this.Pt2IsBetweenPt1AndPt3(I.Prev.Pt,I.Pt,I.Next.Pt)))y=null,I.Prev.Next=I.Next,I.Next.Prev=I.Prev,I=I.Prev;else{if(I===y)break;y===null&&(y=I),I=I.Next;}}s.Pts=I;},e.Clipper.prototype.DupOutPt=function(s,y){var I=new e.OutPt();return I.Pt.X=s.Pt.X,I.Pt.Y=s.Pt.Y,e.use_xyz&&(I.Pt.Z=s.Pt.Z),I.Idx=s.Idx,y?(I.Next=s.Next,I.Prev=s,s.Next.Prev=I,s.Next=I):(I.Prev=s.Prev,I.Next=s,s.Prev.Next=I,s.Prev=I),I;},e.Clipper.prototype.GetOverlap=function(s,y,I,N,z){return s<y?I<N?(z.Left=Math.max(s,I),z.Right=Math.min(y,N)):(z.Left=Math.max(s,N),z.Right=Math.min(y,I)):I<N?(z.Left=Math.max(y,I),z.Right=Math.min(s,N)):(z.Left=Math.max(y,N),z.Right=Math.min(s,I)),z.Left<z.Right;},e.Clipper.prototype.JoinHorz=function(s,y,I,N,z,Z){var tt=s.Pt.X>y.Pt.X?e.Direction.dRightToLeft:e.Direction.dLeftToRight,ft=I.Pt.X>N.Pt.X?e.Direction.dRightToLeft:e.Direction.dLeftToRight;if(tt===ft)return!1;if(tt===e.Direction.dLeftToRight){for(;s.Next.Pt.X<=z.X&&s.Next.Pt.X>=s.Pt.X&&s.Next.Pt.Y===z.Y;)s=s.Next;Z&&s.Pt.X!==z.X&&(s=s.Next),y=this.DupOutPt(s,!Z),e.IntPoint.op_Inequality(y.Pt,z)&&(s=y,s.Pt.X=z.X,s.Pt.Y=z.Y,e.use_xyz&&(s.Pt.Z=z.Z),y=this.DupOutPt(s,!Z));}else{for(;s.Next.Pt.X>=z.X&&s.Next.Pt.X<=s.Pt.X&&s.Next.Pt.Y===z.Y;)s=s.Next;!Z&&s.Pt.X!==z.X&&(s=s.Next),y=this.DupOutPt(s,Z),e.IntPoint.op_Inequality(y.Pt,z)&&(s=y,s.Pt.X=z.X,s.Pt.Y=z.Y,e.use_xyz&&(s.Pt.Z=z.Z),y=this.DupOutPt(s,Z));}if(ft===e.Direction.dLeftToRight){for(;I.Next.Pt.X<=z.X&&I.Next.Pt.X>=I.Pt.X&&I.Next.Pt.Y===z.Y;)I=I.Next;Z&&I.Pt.X!==z.X&&(I=I.Next),N=this.DupOutPt(I,!Z),e.IntPoint.op_Inequality(N.Pt,z)&&(I=N,I.Pt.X=z.X,I.Pt.Y=z.Y,e.use_xyz&&(I.Pt.Z=z.Z),N=this.DupOutPt(I,!Z));}else{for(;I.Next.Pt.X>=z.X&&I.Next.Pt.X<=I.Pt.X&&I.Next.Pt.Y===z.Y;)I=I.Next;!Z&&I.Pt.X!==z.X&&(I=I.Next),N=this.DupOutPt(I,Z),e.IntPoint.op_Inequality(N.Pt,z)&&(I=N,I.Pt.X=z.X,I.Pt.Y=z.Y,e.use_xyz&&(I.Pt.Z=z.Z),N=this.DupOutPt(I,Z));}return tt===e.Direction.dLeftToRight===Z?(s.Prev=I,I.Next=s,y.Next=N,N.Prev=y):(s.Next=I,I.Prev=s,y.Prev=N,N.Next=y),!0;},e.Clipper.prototype.JoinPoints=function(s,y,I){var N=s.OutPt1,z=new e.OutPt(),Z=s.OutPt2,tt=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(y!==I)return!1;for(z=s.OutPt1.Next;z!==N&&e.IntPoint.op_Equality(z.Pt,s.OffPt);)z=z.Next;var ht=z.Pt.Y>s.OffPt.Y;for(tt=s.OutPt2.Next;tt!==Z&&e.IntPoint.op_Equality(tt.Pt,s.OffPt);)tt=tt.Next;var It=tt.Pt.Y>s.OffPt.Y;return ht===It?!1:ht?(z=this.DupOutPt(N,!1),tt=this.DupOutPt(Z,!0),N.Prev=Z,Z.Next=N,z.Next=tt,tt.Prev=z,s.OutPt1=N,s.OutPt2=z,!0):(z=this.DupOutPt(N,!0),tt=this.DupOutPt(Z,!1),N.Next=Z,Z.Prev=N,z.Prev=tt,tt.Next=z,s.OutPt1=N,s.OutPt2=z,!0);}else if(ft){for(z=N;N.Prev.Pt.Y===N.Pt.Y&&N.Prev!==z&&N.Prev!==Z;)N=N.Prev;for(;z.Next.Pt.Y===z.Pt.Y&&z.Next!==N&&z.Next!==Z;)z=z.Next;if(z.Next===N||z.Next===Z)return!1;for(tt=Z;Z.Prev.Pt.Y===Z.Pt.Y&&Z.Prev!==tt&&Z.Prev!==z;)Z=Z.Prev;for(;tt.Next.Pt.Y===tt.Pt.Y&&tt.Next!==Z&&tt.Next!==N;)tt=tt.Next;if(tt.Next===Z||tt.Next===N)return!1;var Rt={Left:null,Right:null};if(!this.GetOverlap(N.Pt.X,z.Pt.X,Z.Pt.X,tt.Pt.X,Rt))return!1;var Lt=Rt.Left,Wt=Rt.Right,Yt=new e.IntPoint0(),Vt;return N.Pt.X>=Lt&&N.Pt.X<=Wt?(Yt.X=N.Pt.X,Yt.Y=N.Pt.Y,e.use_xyz&&(Yt.Z=N.Pt.Z),Vt=N.Pt.X>z.Pt.X):Z.Pt.X>=Lt&&Z.Pt.X<=Wt?(Yt.X=Z.Pt.X,Yt.Y=Z.Pt.Y,e.use_xyz&&(Yt.Z=Z.Pt.Z),Vt=Z.Pt.X>tt.Pt.X):z.Pt.X>=Lt&&z.Pt.X<=Wt?(Yt.X=z.Pt.X,Yt.Y=z.Pt.Y,e.use_xyz&&(Yt.Z=z.Pt.Z),Vt=z.Pt.X>N.Pt.X):(Yt.X=tt.Pt.X,Yt.Y=tt.Pt.Y,e.use_xyz&&(Yt.Z=tt.Pt.Z),Vt=tt.Pt.X>Z.Pt.X),s.OutPt1=N,s.OutPt2=Z,this.JoinHorz(N,z,Z,tt,Yt,Vt);}else{for(z=N.Next;e.IntPoint.op_Equality(z.Pt,N.Pt)&&z!==N;)z=z.Next;var Kt=z.Pt.Y>N.Pt.Y||!e.ClipperBase.SlopesEqual4(N.Pt,z.Pt,s.OffPt,this.m_UseFullRange);if(Kt){for(z=N.Prev;e.IntPoint.op_Equality(z.Pt,N.Pt)&&z!==N;)z=z.Prev;if(z.Pt.Y>N.Pt.Y||!e.ClipperBase.SlopesEqual4(N.Pt,z.Pt,s.OffPt,this.m_UseFullRange))return!1;}for(tt=Z.Next;e.IntPoint.op_Equality(tt.Pt,Z.Pt)&&tt!==Z;)tt=tt.Next;var ee=tt.Pt.Y>Z.Pt.Y||!e.ClipperBase.SlopesEqual4(Z.Pt,tt.Pt,s.OffPt,this.m_UseFullRange);if(ee){for(tt=Z.Prev;e.IntPoint.op_Equality(tt.Pt,Z.Pt)&&tt!==Z;)tt=tt.Prev;if(tt.Pt.Y>Z.Pt.Y||!e.ClipperBase.SlopesEqual4(Z.Pt,tt.Pt,s.OffPt,this.m_UseFullRange))return!1;}return z===N||tt===Z||z===tt||y===I&&Kt===ee?!1:Kt?(z=this.DupOutPt(N,!1),tt=this.DupOutPt(Z,!0),N.Prev=Z,Z.Next=N,z.Next=tt,tt.Prev=z,s.OutPt1=N,s.OutPt2=z,!0):(z=this.DupOutPt(N,!0),tt=this.DupOutPt(Z,!1),N.Next=Z,Z.Prev=N,z.Prev=tt,tt.Next=z,s.OutPt1=N,s.OutPt2=z,!0);}},e.Clipper.GetBounds=function(s){for(var y=0,I=s.length;y<I&&s[y].length===0;)y++;if(y===I)return new e.IntRect(0,0,0,0);var N=new e.IntRect();for(N.left=s[y][0].X,N.right=N.left,N.top=s[y][0].Y,N.bottom=N.top;y<I;y++)for(var z=0,Z=s[y].length;z<Z;z++)s[y][z].X<N.left?N.left=s[y][z].X:s[y][z].X>N.right&&(N.right=s[y][z].X),s[y][z].Y<N.top?N.top=s[y][z].Y:s[y][z].Y>N.bottom&&(N.bottom=s[y][z].Y);return N;},e.Clipper.prototype.GetBounds2=function(s){var y=s,I=new e.IntRect();for(I.left=s.Pt.X,I.right=s.Pt.X,I.top=s.Pt.Y,I.bottom=s.Pt.Y,s=s.Next;s!==y;)s.Pt.X<I.left&&(I.left=s.Pt.X),s.Pt.X>I.right&&(I.right=s.Pt.X),s.Pt.Y<I.top&&(I.top=s.Pt.Y),s.Pt.Y>I.bottom&&(I.bottom=s.Pt.Y),s=s.Next;return I;},e.Clipper.PointInPolygon=function(s,y){var I=0,N=y.length;if(N<3)return 0;for(var z=y[0],Z=1;Z<=N;++Z){var tt=Z===N?y[0]:y[Z];if(tt.Y===s.Y&&(tt.X===s.X||z.Y===s.Y&&tt.X>s.X==z.X<s.X))return-1;if(z.Y<s.Y!=tt.Y<s.Y){if(z.X>=s.X){if(tt.X>s.X)I=1-I;else{var ft=(z.X-s.X)*(tt.Y-s.Y)-(tt.X-s.X)*(z.Y-s.Y);if(ft===0)return-1;ft>0==tt.Y>z.Y&&(I=1-I);}}else if(tt.X>s.X){var ft=(z.X-s.X)*(tt.Y-s.Y)-(tt.X-s.X)*(z.Y-s.Y);if(ft===0)return-1;ft>0==tt.Y>z.Y&&(I=1-I);}}z=tt;}return I;},e.Clipper.prototype.PointInPolygon=function(s,y){var I=0,N=y,z=s.X,Z=s.Y,tt=y.Pt.X,ft=y.Pt.Y;do{y=y.Next;var ht=y.Pt.X,It=y.Pt.Y;if(It===Z&&(ht===z||ft===Z&&ht>z==tt<z))return-1;if(ft<Z!=It<Z){if(tt>=z){if(ht>z)I=1-I;else{var Rt=(tt-z)*(It-Z)-(ht-z)*(ft-Z);if(Rt===0)return-1;Rt>0==It>ft&&(I=1-I);}}else if(ht>z){var Rt=(tt-z)*(It-Z)-(ht-z)*(ft-Z);if(Rt===0)return-1;Rt>0==It>ft&&(I=1-I);}}tt=ht,ft=It;}while(N!==y);return I;},e.Clipper.prototype.Poly2ContainsPoly1=function(s,y){var I=s;do{var N=this.PointInPolygon(I.Pt,y);if(N>=0)return N>0;I=I.Next;}while(I!==s);return!0;},e.Clipper.prototype.FixupFirstLefts1=function(s,y){for(var I,N,z=0,Z=this.m_PolyOuts.length;z<Z;z++)I=this.m_PolyOuts[z],N=e.Clipper.ParseFirstLeft(I.FirstLeft),I.Pts!==null&&N===s&&this.Poly2ContainsPoly1(I.Pts,y.Pts)&&(I.FirstLeft=y);},e.Clipper.prototype.FixupFirstLefts2=function(s,y){for(var I=y.FirstLeft,N,z,Z=0,tt=this.m_PolyOuts.length;Z<tt;Z++)N=this.m_PolyOuts[Z],!(N.Pts===null||N===y||N===s)&&(z=e.Clipper.ParseFirstLeft(N.FirstLeft),!(z!==I&&z!==s&&z!==y)&&(this.Poly2ContainsPoly1(N.Pts,s.Pts)?N.FirstLeft=s:this.Poly2ContainsPoly1(N.Pts,y.Pts)?N.FirstLeft=y:(N.FirstLeft===s||N.FirstLeft===y)&&(N.FirstLeft=I)));},e.Clipper.prototype.FixupFirstLefts3=function(s,y){for(var I,N,z=0,Z=this.m_PolyOuts.length;z<Z;z++)I=this.m_PolyOuts[z],N=e.Clipper.ParseFirstLeft(I.FirstLeft),I.Pts!==null&&N===s&&(I.FirstLeft=y);},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,y=this.m_Joins.length;s<y;s++){var I=this.m_Joins[s],N=this.GetOutRec(I.OutPt1.Idx),z=this.GetOutRec(I.OutPt2.Idx);if(!(N.Pts===null||z.Pts===null)&&!(N.IsOpen||z.IsOpen)){var Z;N===z?Z=N:this.OutRec1RightOfOutRec2(N,z)?Z=z:this.OutRec1RightOfOutRec2(z,N)?Z=N:Z=this.GetLowermostRec(N,z),this.JoinPoints(I,N,z)&&(N===z?(N.Pts=I.OutPt1,N.BottomPt=null,z=this.CreateOutRec(),z.Pts=I.OutPt2,this.UpdateOutPtIdxs(z),this.Poly2ContainsPoly1(z.Pts,N.Pts)?(z.IsHole=!N.IsHole,z.FirstLeft=N,this.m_UsingPolyTree&&this.FixupFirstLefts2(z,N),(z.IsHole^this.ReverseSolution)==this.Area$1(z)>0&&this.ReversePolyPtLinks(z.Pts)):this.Poly2ContainsPoly1(N.Pts,z.Pts)?(z.IsHole=N.IsHole,N.IsHole=!z.IsHole,z.FirstLeft=N.FirstLeft,N.FirstLeft=z,this.m_UsingPolyTree&&this.FixupFirstLefts2(N,z),(N.IsHole^this.ReverseSolution)==this.Area$1(N)>0&&this.ReversePolyPtLinks(N.Pts)):(z.IsHole=N.IsHole,z.FirstLeft=N.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(N,z))):(z.Pts=null,z.BottomPt=null,z.Idx=N.Idx,N.IsHole=Z.IsHole,Z===z&&(N.FirstLeft=z.FirstLeft),z.FirstLeft=N,this.m_UsingPolyTree&&this.FixupFirstLefts3(z,N)));}}},e.Clipper.prototype.UpdateOutPtIdxs=function(s){var y=s.Pts;do y.Idx=s.Idx,y=y.Prev;while(y!==s.Pts);},e.Clipper.prototype.DoSimplePolygons=function(){for(var s=0;s<this.m_PolyOuts.length;){var y=this.m_PolyOuts[s++],I=y.Pts;if(!(I===null||y.IsOpen))do{for(var N=I.Next;N!==y.Pts;){if(e.IntPoint.op_Equality(I.Pt,N.Pt)&&N.Next!==I&&N.Prev!==I){var z=I.Prev,Z=N.Prev;I.Prev=Z,Z.Next=I,N.Prev=z,z.Next=N,y.Pts=I;var tt=this.CreateOutRec();tt.Pts=N,this.UpdateOutPtIdxs(tt),this.Poly2ContainsPoly1(tt.Pts,y.Pts)?(tt.IsHole=!y.IsHole,tt.FirstLeft=y,this.m_UsingPolyTree&&this.FixupFirstLefts2(tt,y)):this.Poly2ContainsPoly1(y.Pts,tt.Pts)?(tt.IsHole=y.IsHole,y.IsHole=!tt.IsHole,tt.FirstLeft=y.FirstLeft,y.FirstLeft=tt,this.m_UsingPolyTree&&this.FixupFirstLefts2(y,tt)):(tt.IsHole=y.IsHole,tt.FirstLeft=y.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(y,tt)),N=I;}N=N.Next;}I=I.Next;}while(I!==y.Pts);}},e.Clipper.Area=function(s){if(!Array.isArray(s))return 0;var y=s.length;if(y<3)return 0;for(var I=0,N=0,z=y-1;N<y;++N)I+=(s[z].X+s[N].X)*(s[z].Y-s[N].Y),z=N;return-I*0.5;},e.Clipper.prototype.Area=function(s){var y=s;if(s===null)return 0;var I=0;do I=I+(s.Prev.Pt.X+s.Pt.X)*(s.Prev.Pt.Y-s.Pt.Y),s=s.Next;while(s!==y);return I*0.5;},e.Clipper.prototype.Area$1=function(s){return this.Area(s.Pts);},e.Clipper.SimplifyPolygon=function(s,y){var I=new Array(),N=new e.Clipper(0);return N.StrictlySimple=!0,N.AddPath(s,e.PolyType.ptSubject,!0),N.Execute(e.ClipType.ctUnion,I,y,y),I;},e.Clipper.SimplifyPolygons=function(s,y){_typeof(y)>"u"&&(y=e.PolyFillType.pftEvenOdd);var I=new Array(),N=new e.Clipper(0);return N.StrictlySimple=!0,N.AddPaths(s,e.PolyType.ptSubject,!0),N.Execute(e.ClipType.ctUnion,I,y,y),I;},e.Clipper.DistanceSqrd=function(s,y){var I=s.X-y.X,N=s.Y-y.Y;return I*I+N*N;},e.Clipper.DistanceFromLineSqrd=function(s,y,I){var N=y.Y-I.Y,z=I.X-y.X,Z=N*y.X+z*y.Y;return Z=N*s.X+z*s.Y-Z,Z*Z/(N*N+z*z);},e.Clipper.SlopesNearCollinear=function(s,y,I,N){return Math.abs(s.X-y.X)>Math.abs(s.Y-y.Y)?s.X>y.X==s.X<I.X?e.Clipper.DistanceFromLineSqrd(s,y,I)<N:y.X>s.X==y.X<I.X?e.Clipper.DistanceFromLineSqrd(y,s,I)<N:e.Clipper.DistanceFromLineSqrd(I,s,y)<N:s.Y>y.Y==s.Y<I.Y?e.Clipper.DistanceFromLineSqrd(s,y,I)<N:y.Y>s.Y==y.Y<I.Y?e.Clipper.DistanceFromLineSqrd(y,s,I)<N:e.Clipper.DistanceFromLineSqrd(I,s,y)<N;},e.Clipper.PointsAreClose=function(s,y,I){var N=s.X-y.X,z=s.Y-y.Y;return N*N+z*z<=I;},e.Clipper.ExcludeOp=function(s){var y=s.Prev;return y.Next=s.Next,s.Next.Prev=y,y.Idx=0,y;},e.Clipper.CleanPolygon=function(s,y){_typeof(y)>"u"&&(y=1.415);var I=s.length;if(I===0)return new Array();for(var N=new Array(I),z=0;z<I;++z)N[z]=new e.OutPt();for(var z=0;z<I;++z)N[z].Pt=s[z],N[z].Next=N[(z+1)%I],N[z].Next.Prev=N[z],N[z].Idx=0;for(var Z=y*y,tt=N[0];tt.Idx===0&&tt.Next!==tt.Prev;)e.Clipper.PointsAreClose(tt.Pt,tt.Prev.Pt,Z)?(tt=e.Clipper.ExcludeOp(tt),I--):e.Clipper.PointsAreClose(tt.Prev.Pt,tt.Next.Pt,Z)?(e.Clipper.ExcludeOp(tt.Next),tt=e.Clipper.ExcludeOp(tt),I-=2):e.Clipper.SlopesNearCollinear(tt.Prev.Pt,tt.Pt,tt.Next.Pt,Z)?(tt=e.Clipper.ExcludeOp(tt),I--):(tt.Idx=1,tt=tt.Next);I<3&&(I=0);for(var ft=new Array(I),z=0;z<I;++z)ft[z]=new e.IntPoint1(tt.Pt),tt=tt.Next;return N=null,ft;},e.Clipper.CleanPolygons=function(s,y){for(var I=new Array(s.length),N=0,z=s.length;N<z;N++)I[N]=e.Clipper.CleanPolygon(s[N],y);return I;},e.Clipper.Minkowski=function(s,y,I,N){var z=N?1:0,Z=s.length,tt=y.length,ft=new Array();if(I)for(var ht=0;ht<tt;ht++){for(var It=new Array(Z),Rt=0,Lt=s.length,Wt=s[Rt];Rt<Lt;Rt++,Wt=s[Rt])It[Rt]=new e.IntPoint2(y[ht].X+Wt.X,y[ht].Y+Wt.Y);ft.push(It);}else for(var ht=0;ht<tt;ht++){for(var It=new Array(Z),Rt=0,Lt=s.length,Wt=s[Rt];Rt<Lt;Rt++,Wt=s[Rt])It[Rt]=new e.IntPoint2(y[ht].X-Wt.X,y[ht].Y-Wt.Y);ft.push(It);}for(var Yt=new Array(),ht=0;ht<tt-1+z;ht++)for(var Rt=0;Rt<Z;Rt++){var Vt=new Array();Vt.push(ft[ht%tt][Rt%Z]),Vt.push(ft[(ht+1)%tt][Rt%Z]),Vt.push(ft[(ht+1)%tt][(Rt+1)%Z]),Vt.push(ft[ht%tt][(Rt+1)%Z]),e.Clipper.Orientation(Vt)||Vt.reverse(),Yt.push(Vt);}return Yt;},e.Clipper.MinkowskiSum=function(s,y,I){if(y[0]instanceof Array){for(var z=y,tt=new e.Paths(),Z=new e.Clipper(),ft=0;ft<z.length;++ft){var ht=e.Clipper.Minkowski(s,z[ft],!0,I);if(Z.AddPaths(ht,e.PolyType.ptSubject,!0),I){var N=e.Clipper.TranslatePath(z[ft],s[0]);Z.AddPath(N,e.PolyType.ptClip,!0);}}return Z.Execute(e.ClipType.ctUnion,tt,e.PolyFillType.pftNonZero,e.PolyFillType.pftNonZero),tt;}else{var N=y,z=e.Clipper.Minkowski(s,N,!0,I),Z=new e.Clipper();return Z.AddPaths(z,e.PolyType.ptSubject,!0),Z.Execute(e.ClipType.ctUnion,z,e.PolyFillType.pftNonZero,e.PolyFillType.pftNonZero),z;}},e.Clipper.TranslatePath=function(s,y){for(var I=new e.Path(),N=0;N<s.length;N++)I.push(new e.IntPoint2(s[N].X+y.X,s[N].Y+y.Y));return I;},e.Clipper.MinkowskiDiff=function(s,y){var I=e.Clipper.Minkowski(s,y,!1,!0),N=new e.Clipper();return N.AddPaths(I,e.PolyType.ptSubject,!0),N.Execute(e.ClipType.ctUnion,I,e.PolyFillType.pftNonZero,e.PolyFillType.pftNonZero),I;},e.Clipper.PolyTreeToPaths=function(s){var y=new Array();return e.Clipper.AddPolyNodeToPaths(s,e.Clipper.NodeType.ntAny,y),y;},e.Clipper.AddPolyNodeToPaths=function(s,y,I){var N=!0;switch(y){case e.Clipper.NodeType.ntOpen:return;case e.Clipper.NodeType.ntClosed:N=!s.IsOpen;break;}s.m_polygon.length>0&&N&&I.push(s.m_polygon);for(var z=0,Z=s.Childs(),tt=Z.length,ft=Z[z];z<tt;z++,ft=Z[z])e.Clipper.AddPolyNodeToPaths(ft,y,I);},e.Clipper.OpenPathsFromPolyTree=function(s){for(var y=new e.Paths(),I=0,N=s.ChildCount();I<N;I++)s.Childs()[I].IsOpen&&y.push(s.Childs()[I].m_polygon);return y;},e.Clipper.ClosedPathsFromPolyTree=function(s){var y=new e.Paths();return e.Clipper.AddPolyNodeToPaths(s,e.Clipper.NodeType.ntClosed,y),y;},Pn(e.Clipper,e.ClipperBase),e.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2},e.ClipperOffset=function(s,y){_typeof(s)>"u"&&(s=2),_typeof(y)>"u"&&(y=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=y,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,y,I){var N=s.length-1;if(!(N<0)){var z=new e.PolyNode();if(z.m_jointype=y,z.m_endtype=I,I===e.EndType.etClosedLine||I===e.EndType.etClosedPolygon)for(;N>0&&e.IntPoint.op_Equality(s[0],s[N]);)N--;z.m_polygon.push(s[0]);for(var Z=0,tt=0,ft=1;ft<=N;ft++)e.IntPoint.op_Inequality(z.m_polygon[Z],s[ft])&&(Z++,z.m_polygon.push(s[ft]),(s[ft].Y>z.m_polygon[tt].Y||s[ft].Y===z.m_polygon[tt].Y&&s[ft].X<z.m_polygon[tt].X)&&(tt=Z));if(!(I===e.EndType.etClosedPolygon&&Z<2)&&(this.m_polyNodes.AddChild(z),I===e.EndType.etClosedPolygon))if(this.m_lowest.X<0)this.m_lowest=new e.IntPoint2(this.m_polyNodes.ChildCount()-1,tt);else{var ht=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(z.m_polygon[tt].Y>ht.Y||z.m_polygon[tt].Y===ht.Y&&z.m_polygon[tt].X<ht.X)&&(this.m_lowest=new e.IntPoint2(this.m_polyNodes.ChildCount()-1,tt));}}},e.ClipperOffset.prototype.AddPaths=function(s,y,I){for(var N=0,z=s.length;N<z;N++)this.AddPath(s[N],y,I);},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 y=this.m_polyNodes.Childs()[s];(y.m_endtype===e.EndType.etClosedPolygon||y.m_endtype===e.EndType.etClosedLine&&e.Clipper.Orientation(y.m_polygon))&&y.m_polygon.reverse();}else for(var s=0;s<this.m_polyNodes.ChildCount();s++){var y=this.m_polyNodes.Childs()[s];y.m_endtype===e.EndType.etClosedLine&&!e.Clipper.Orientation(y.m_polygon)&&y.m_polygon.reverse();}},e.ClipperOffset.GetUnitNormal=function(s,y){var I=y.X-s.X,N=y.Y-s.Y;if(I===0&&N===0)return new e.DoublePoint2(0,0);var z=1/Math.sqrt(I*I+N*N);return I*=z,N*=z,new e.DoublePoint2(N,-I);},e.ClipperOffset.prototype.DoOffset=function(s){if(this.m_destPolys=new Array(),this.m_delta=s,e.ClipperBase.near_zero(s)){for(var y=0;y<this.m_polyNodes.ChildCount();y++){var I=this.m_polyNodes.Childs()[y];I.m_endtype===e.EndType.etClosedPolygon&&this.m_destPolys.push(I.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 z=3.14159265358979/Math.acos(1-N/Math.abs(s));this.m_sin=Math.sin(e.ClipperOffset.two_pi/z),this.m_cos=Math.cos(e.ClipperOffset.two_pi/z),this.m_StepsPerRad=z/e.ClipperOffset.two_pi,s<0&&(this.m_sin=-this.m_sin);for(var y=0;y<this.m_polyNodes.ChildCount();y++){var I=this.m_polyNodes.Childs()[y];this.m_srcPoly=I.m_polygon;var Z=this.m_srcPoly.length;if(!(Z===0||s<=0&&(Z<3||I.m_endtype!==e.EndType.etClosedPolygon))){if(this.m_destPoly=new Array(),Z===1){if(I.m_jointype===e.JoinType.jtRound)for(var tt=1,ft=0,ht=1;ht<=z;ht++){this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[0].X+tt*s),e.ClipperOffset.Round(this.m_srcPoly[0].Y+ft*s)));var It=tt;tt=tt*this.m_cos-this.m_sin*ft,ft=It*this.m_sin+ft*this.m_cos;}else for(var tt=-1,ft=-1,ht=0;ht<4;++ht)this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[0].X+tt*s),e.ClipperOffset.Round(this.m_srcPoly[0].Y+ft*s))),tt<0?tt=1:ft<0?ft=1:tt=-1;this.m_destPolys.push(this.m_destPoly);continue;}this.m_normals.length=0;for(var ht=0;ht<Z-1;ht++)this.m_normals.push(e.ClipperOffset.GetUnitNormal(this.m_srcPoly[ht],this.m_srcPoly[ht+1]));if(I.m_endtype===e.EndType.etClosedLine||I.m_endtype===e.EndType.etClosedPolygon?this.m_normals.push(e.ClipperOffset.GetUnitNormal(this.m_srcPoly[Z-1],this.m_srcPoly[0])):this.m_normals.push(new e.DoublePoint1(this.m_normals[Z-2])),I.m_endtype===e.EndType.etClosedPolygon){for(var Rt=Z-1,ht=0;ht<Z;ht++)Rt=this.OffsetPoint(ht,Rt,I.m_jointype);this.m_destPolys.push(this.m_destPoly);}else if(I.m_endtype===e.EndType.etClosedLine){for(var Rt=Z-1,ht=0;ht<Z;ht++)Rt=this.OffsetPoint(ht,Rt,I.m_jointype);this.m_destPolys.push(this.m_destPoly),this.m_destPoly=new Array();for(var Lt=this.m_normals[Z-1],ht=Z-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),Rt=0;for(var ht=Z-1;ht>=0;ht--)Rt=this.OffsetPoint(ht,Rt,I.m_jointype);this.m_destPolys.push(this.m_destPoly);}else{for(var Rt=0,ht=1;ht<Z-1;++ht)Rt=this.OffsetPoint(ht,Rt,I.m_jointype);var Wt;if(I.m_endtype===e.EndType.etOpenButt){var ht=Z-1;Wt=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(Wt),Wt=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(Wt);}else{var ht=Z-1;Rt=Z-2,this.m_sinA=0,this.m_normals[ht]=new e.DoublePoint2(-this.m_normals[ht].X,-this.m_normals[ht].Y),I.m_endtype===e.EndType.etOpenSquare?this.DoSquare(ht,Rt):this.DoRound(ht,Rt);}for(var ht=Z-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),Rt=Z-1;for(var ht=Rt-1;ht>0;--ht)Rt=this.OffsetPoint(ht,Rt,I.m_jointype);I.m_endtype===e.EndType.etOpenButt?(Wt=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(Wt),Wt=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(Wt)):(Rt=1,this.m_sinA=0,I.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,y=s[0]instanceof e.PolyTree;if(y){var I=s[0],N=s[1];I.Clear(),this.FixOrientations(),this.DoOffset(N);var z=new e.Clipper(0);if(z.AddPaths(this.m_destPolys,e.PolyType.ptSubject,!0),N>0)z.Execute(e.ClipType.ctUnion,I,e.PolyFillType.pftPositive,e.PolyFillType.pftPositive);else{var Z=e.Clipper.GetBounds(this.m_destPolys),tt=new e.Path();if(tt.push(new e.IntPoint2(Z.left-10,Z.bottom+10)),tt.push(new e.IntPoint2(Z.right+10,Z.bottom+10)),tt.push(new e.IntPoint2(Z.right+10,Z.top-10)),tt.push(new e.IntPoint2(Z.left-10,Z.top-10)),z.AddPath(tt,e.PolyType.ptSubject,!0),z.ReverseSolution=!0,z.Execute(e.ClipType.ctUnion,I,e.PolyFillType.pftNegative,e.PolyFillType.pftNegative),I.ChildCount()===1&&I.Childs()[0].ChildCount()>0){var ft=I.Childs()[0];I.Childs()[0]=ft.Childs()[0],I.Childs()[0].m_Parent=I;for(var ht=1;ht<ft.ChildCount();ht++)I.AddChild(ft.Childs()[ht]);}else I.Clear();}}else{var I=s[0],N=s[1];e.Clear(I),this.FixOrientations(),this.DoOffset(N);var z=new e.Clipper(0);if(z.AddPaths(this.m_destPolys,e.PolyType.ptSubject,!0),N>0)z.Execute(e.ClipType.ctUnion,I,e.PolyFillType.pftPositive,e.PolyFillType.pftPositive);else{var Z=e.Clipper.GetBounds(this.m_destPolys),tt=new e.Path();tt.push(new e.IntPoint2(Z.left-10,Z.bottom+10)),tt.push(new e.IntPoint2(Z.right+10,Z.bottom+10)),tt.push(new e.IntPoint2(Z.right+10,Z.top-10)),tt.push(new e.IntPoint2(Z.left-10,Z.top-10)),z.AddPath(tt,e.PolyType.ptSubject,!0),z.ReverseSolution=!0,z.Execute(e.ClipType.ctUnion,I,e.PolyFillType.pftNegative,e.PolyFillType.pftNegative),I.length>0&&I.splice(0,1);}}},e.ClipperOffset.prototype.OffsetPoint=function(s,y,I){if(this.m_sinA=this.m_normals[y].X*this.m_normals[s].Y-this.m_normals[s].X*this.m_normals[y].Y,Math.abs(this.m_sinA*this.m_delta)<1){var N=this.m_normals[y].X*this.m_normals[s].X+this.m_normals[s].Y*this.m_normals[y].Y;if(N>0)return this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+this.m_normals[y].X*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_normals[y].Y*this.m_delta))),y;}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[y].X*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_normals[y].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(I){case e.JoinType.jtMiter:{var z=1+(this.m_normals[s].X*this.m_normals[y].X+this.m_normals[s].Y*this.m_normals[y].Y);z>=this.m_miterLim?this.DoMiter(s,y,z):this.DoSquare(s,y);break;}case e.JoinType.jtSquare:this.DoSquare(s,y);break;case e.JoinType.jtRound:this.DoRound(s,y);break;}return y=s,y;},e.ClipperOffset.prototype.DoSquare=function(s,y){var I=Math.tan(Math.atan2(this.m_sinA,this.m_normals[y].X*this.m_normals[s].X+this.m_normals[y].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[y].X-this.m_normals[y].Y*I)),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_delta*(this.m_normals[y].Y+this.m_normals[y].X*I)))),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*I)),e.ClipperOffset.Round(this.m_srcPoly[s].Y+this.m_delta*(this.m_normals[s].Y-this.m_normals[s].X*I))));},e.ClipperOffset.prototype.DoMiter=function(s,y,I){var N=this.m_delta/I;this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+(this.m_normals[y].X+this.m_normals[s].X)*N),e.ClipperOffset.Round(this.m_srcPoly[s].Y+(this.m_normals[y].Y+this.m_normals[s].Y)*N)));},e.ClipperOffset.prototype.DoRound=function(s,y){for(var I=Math.atan2(this.m_sinA,this.m_normals[y].X*this.m_normals[s].X+this.m_normals[y].Y*this.m_normals[s].Y),N=Math.max(e.Cast_Int32(e.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(I))),1),z=this.m_normals[y].X,Z=this.m_normals[y].Y,tt,ft=0;ft<N;++ft)this.m_destPoly.push(new e.IntPoint2(e.ClipperOffset.Round(this.m_srcPoly[s].X+z*this.m_delta),e.ClipperOffset.Round(this.m_srcPoly[s].Y+Z*this.m_delta))),tt=z,z=z*this.m_cos-this.m_sin*Z,Z=tt*this.m_sin+Z*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(y){alert(y.message);}},e.JS={},e.JS.AreaOfPolygon=function(s,y){return y||(y=1),e.Clipper.Area(s)/(y*y);},e.JS.AreaOfPolygons=function(s,y){y||(y=1);for(var I=0,N=0;N<s.length;N++)I+=e.Clipper.Area(s[N]);return I/(y*y);},e.JS.BoundsOfPath=function(s,y){return e.JS.BoundsOfPaths([s],y);},e.JS.BoundsOfPaths=function(s,y){y||(y=1);var I=e.Clipper.GetBounds(s);return I.left/=y,I.bottom/=y,I.right/=y,I.top/=y,I;},e.JS.Clean=function(N,y){if(!(N instanceof Array))return[];var I=N[0]instanceof Array,N=e.JS.Clone(N);if(typeof y!="number"||y===null)return e.Error("Delta is not a number in Clean()."),N;if(N.length===0||N.length===1&&N[0].length===0||y<0)return N;I||(N=[N]);for(var z=N.length,Z,tt,ft,ht,It,Rt,Lt,Wt=[],Yt=0;Yt<z;Yt++)if(tt=N[Yt],Z=tt.length,Z!==0){if(Z<3){ft=tt,Wt.push(ft);continue;}for(ft=tt,ht=y*y,It=tt[0],Rt=1,Lt=1;Lt<Z;Lt++)(tt[Lt].X-It.X)*(tt[Lt].X-It.X)+(tt[Lt].Y-It.Y)*(tt[Lt].Y-It.Y)<=ht||(ft[Rt]=tt[Lt],It=tt[Lt],Rt++);It=tt[Rt-1],(tt[0].X-It.X)*(tt[0].X-It.X)+(tt[0].Y-It.Y)*(tt[0].Y-It.Y)<=ht&&Rt--,Rt<Z&&ft.splice(Rt,Z-Rt),ft.length&&Wt.push(ft);}return!I&&Wt.length?Wt=Wt[0]:!I&&Wt.length===0?Wt=[]:I&&Wt.length===0&&(Wt=[[]]),Wt;},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 y=s[0]instanceof Array;y||(s=[s]);var I=s.length,N,z,Z,tt,ft=new Array(I);for(z=0;z<I;z++){for(N=s[z].length,tt=new Array(N),Z=0;Z<N;Z++)tt[Z]={X:s[z][Z].X,Y:s[z][Z].Y};ft[z]=tt;}return y||(ft=ft[0]),ft;},e.JS.Lighten=function(s,y){if(!(s instanceof Array))return[];if(typeof y!="number"||y===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||y<0)return e.JS.Clone(s);var I=s[0]instanceof Array;I||(s=[s]);var N,z,Z,tt,ft,ht,It,Rt,Lt,Wt,Yt,Vt,Kt,ee,ge,Oe,Ye,to=s.length,eo=y*y,Xe=[];for(N=0;N<to;N++)if(Z=s[N],ht=Z.length,ht!==0){for(tt=0;tt<1e6;tt++){for(ft=[],ht=Z.length,Z[ht-1].X!==Z[0].X||Z[ht-1].Y!==Z[0].Y?(Vt=1,Z.push({X:Z[0].X,Y:Z[0].Y}),ht=Z.length):Vt=0,Yt=[],z=0;z<ht-2;z++)It=Z[z],Lt=Z[z+1],Rt=Z[z+2],Oe=It.X,Ye=It.Y,Kt=Rt.X-Oe,ee=Rt.Y-Ye,(Kt!==0||ee!==0)&&(ge=((Lt.X-Oe)*Kt+(Lt.Y-Ye)*ee)/(Kt*Kt+ee*ee),ge>1?(Oe=Rt.X,Ye=Rt.Y):ge>0&&(Oe+=Kt*ge,Ye+=ee*ge)),Kt=Lt.X-Oe,ee=Lt.Y-Ye,Wt=Kt*Kt+ee*ee,Wt<=eo&&(Yt[z+1]=1,z++);for(ft.push({X:Z[0].X,Y:Z[0].Y}),z=1;z<ht-1;z++)Yt[z]||ft.push({X:Z[z].X,Y:Z[z].Y});if(ft.push({X:Z[ht-1].X,Y:Z[ht-1].Y}),Vt&&Z.pop(),Yt.length)Z=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 I||(Xe=Xe[0]),_typeof(Xe)>"u"&&(Xe=[]),Xe;},e.JS.PerimeterOfPath=function(s,y,I){if(_typeof(s)>"u")return 0;var N=Math.sqrt,z=0,Z,tt,ft=0,ht=0,It=0,Rt=0,Lt=s.length;if(Lt<2)return 0;for(y&&(s[Lt]=s[0],Lt++);--Lt;)Z=s[Lt],ft=Z.X,ht=Z.Y,tt=s[Lt-1],It=tt.X,Rt=tt.Y,z+=N((ft-It)*(ft-It)+(ht-Rt)*(ht-Rt));return y&&s.pop(),z/I;},e.JS.PerimeterOfPaths=function(s,y,I){I||(I=1);for(var N=0,z=0;z<s.length;z++)N+=e.JS.PerimeterOfPath(s[z],y,I);return N;},e.JS.ScaleDownPath=function(s,y){var I,N;for(y||(y=1),I=s.length;I--;)N=s[I],N.X=N.X/y,N.Y=N.Y/y;},e.JS.ScaleDownPaths=function(s,y){var I,N,z;for(y||(y=1),I=s.length;I--;)for(N=s[I].length;N--;)z=s[I][N],z.X=z.X/y,z.Y=z.Y/y;},e.JS.ScaleUpPath=function(s,y){var I,N,z=Math.round;for(y||(y=1),I=s.length;I--;)N=s[I],N.X=z(N.X*y),N.Y=z(N.Y*y);},e.JS.ScaleUpPaths=function(s,y){var I,N,z,Z=Math.round;for(y||(y=1),I=s.length;I--;)for(N=s[I].length;N--;)z=s[I][N],z.X=Z(z.X*y),z.Y=Z(z.Y*y);},e.ExPolygons=function(){return[];},e.ExPolygon=function(){this.outer=null,this.holes=null;},e.JS.AddOuterPolyNodeToExPolygons=function(s,y){var I=new e.ExPolygon();I.outer=s.Contour();var N=s.Childs(),z=N.length;I.holes=new Array(z);var Z,tt,ft,ht,It,Rt;for(ft=0;ft<z;ft++)for(Z=N[ft],I.holes[ft]=Z.Contour(),ht=0,It=Z.Childs(),Rt=It.length;ht<Rt;ht++)tt=It[ht],e.JS.AddOuterPolyNodeToExPolygons(tt,y);y.push(I);},e.JS.ExPolygonsToPaths=function(s){var y,I,N,z,Z=new e.Paths();for(y=0,N=s.length;y<N;y++)for(Z.push(s[y].outer),I=0,z=s[y].holes.length;I<z;I++)Z.push(s[y].holes[I]);return Z;},e.JS.PolyTreeToExPolygons=function(s){var y=new e.ExPolygons(),I,N,z,Z;for(N=0,z=s.Childs(),Z=z.length;N<Z;N++)I=z[N],e.JS.AddOuterPolyNodeToExPolygons(I,y);return y;};})();})(ki);var Zp=ki.exports,Ee=/* @__PURE__ */Ne(Zp);function Hi(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 Jp(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++)Hi([u[r][0],u[r][1]],t[t.length-1],e)||t.push([u[r][0],u[r][1]]);return t;}function Qp(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 Hi(t,r,e)?u.slice(0,-1):u;}function qp(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 _p(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=qp(t);return t.sort(function(n,i){var l=Hn(r,n),o=Hn(r,i);return l-o;});}function t0(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,m=0;for(var f=0;f<e.length;f++){var v=e[f],S=Math.sqrt(Math.pow(v.x-o[0],2)+Math.pow(v.y-o[1],2));S<c&&(c=S,a=f,m=v.z);}return{point:o,index:a,bestZ:m};}).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 e0(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),S=_ref167[0],E=_ref167[1];return{X:Math.round(S*v),Y:Math.round(E*v)};});},l=new Ee.ClipperOffset();l.AddPath(i(n,1e3),Ee.JoinType.jtRound,Ee.EndType.etOpenButt);var o=[];l.Execute(o,1);var a=new Ee.Clipper();a.AddPaths(o,Ee.PolyType.ptSubject,!0),e.forEach(function(f){a.AddPath(i(f,1e3),Ee.PolyType.ptClip,!0);});var c=new Ee.Paths();a.Execute(Ee.ClipType.ctDifference,c,Ee.PolyFillType.pftNonZero,Ee.PolyFillType.pftNonZero);var m=c.map(function(f){return Qp(_p(Jp(f.map(function(v){return[v.X/1e3,v.Y/1e3];}),t),t),t);}).filter(function(f){return f.length>=2;});return t0(m,u);}var Vi=/*#__PURE__*/function(_At){function Vi(t){var _this62;_classCallCheck(this,Vi);_this62=_callSuper(this,Vi,[t]);ot(_this62,"canRotate",!0);ot(_this62,"scaleType",Qt.all);ot(_this62,"toolsType",pt.Pencil);ot(_this62,"syncTimestamp");ot(_this62,"syncIndex",0);ot(_this62,"tmpPoints",[]);ot(_this62,"MAX_REPEAR",10);/** 合并原始点的灵敏度 */ot(_this62,"uniThickness");ot(_this62,"workOptions");ot(_this62,"centerPos",[0,0]);_this62.workOptions=t.toolsOpt,_this62.uniThickness=_this62.MAX_REPEAR/_this62.workOptions.thickness/10,_this62.syncTimestamp=0;return _this62;}/** 批量合并消费本地数据,返回绘制结果 */_inherits(Vi,_At);return _createClass(Vi,[{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:Dt.Local};}},{key:"setWorkOptions",value:function setWorkOptions(t){_superPropGet(Vi,"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=t.isSimpleWorker,m=r.workId,f=r.syncUnitTime;f&&(this.syncUnitTime=f);var _this$transformData=this.transformData(r,!1),v=_this$transformData.tasks,S=_this$transformData.effects,E=_this$transformData.consumeIndex;this.syncIndex=Math.min(this.syncIndex,E,Math.max(0,this.tmpPoints.length-2));var T={name:m,id:he(o)&&o.toString()||void 0};var P,x=!1;var h=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),v.length&&(v[0].taskId-this.syncTimestamp>this.syncUnitTime&&(x=!0,this.syncTimestamp=v[0].taskId,this.syncIndex=this.tmpPoints.length),i||l||c)){var d=n?this.fullLayer:this.drawLayer||this.fullLayer;P=this.draw({attrs:T,tasks:v,effects:S,layer:d,removeDrawCount:a});}if(c){var _d14=[];return this.tmpPoints.slice(h).forEach(function(g){_d14.push(g.x,g.y,_this63.computRadius(g.z,_this63.workOptions.thickness));}),_objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:dt.DrawWork,dataType:Dt.Local,op:x?_d14:void 0,index:x?h*3:void 0,updateNodeOpt:{useAnimation:!0}});}if(i)return E>10&&this.tmpPoints.splice(0,E-10),{rect:P,type:dt.DrawWork,dataType:Dt.Local};var p=[];return this.tmpPoints.slice(h).forEach(function(d){p.push(d.x,d.y,_this63.computRadius(d.z,_this63.workOptions.thickness));}),_objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:dt.DrawWork,dataType:Dt.Local,rect:P,op:x?p:void 0,index:x?h*3:void 0,updateNodeOpt:{useAnimation:!0}});}},{key:"consumeAll",value:function consumeAll(t){var m;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===Zt.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=ve(a);return(m=this.vNodes)==null||m.setInfo(r,{rect:l,op:a,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:l&&At.getCenterPos(l,o)}),_objectSpread(_objectSpread({},this.baseConsumeResult),{},{rect:l,type:dt.FullWork,dataType:Dt.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 S=0;S<r.length;S+=3){var E=new Nt(r[S],r[S+1],r[S+2]);if(this.tmpPoints.length>0){var T=this.tmpPoints[this.tmpPoints.length-1],P=at.Sub(E,T).uni();E.setv(P);}this.tmpPoints.push(E);}if(this.tmpPoints.length<2)return;var o=this.transformDataAll(!0),a=(f=this.workId)==null?void 0:f.toString(),c={name:a};var m;if(a&&o.length){var _S8=n?this.fullLayer:this.drawLayer||this.fullLayer;m=this.draw({attrs:c,tasks:o,replaceId:i,layer:_S8,isDrawEraserlines:l===Ft.Done}),(v=this.vNodes)==null||v.setInfo(a,{rect:m,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:m&&At.getCenterPos(m,_S8)});}return m;}},{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 Nt(n[a],n[a+1],n[a+2]);if(this.tmpPoints.length>0){var m=this.tmpPoints[this.tmpPoints.length-1],f=at.Sub(c,m).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,m=_o$_a.points,f=m.map(function(E){return E.point.addXY(c[0],c[1]);}),v=[];var _iterator17=_createForOfIteratorHelper(i),_step17;try{for(_iterator17.s();!(_step17=_iterator17.n()).done;){var E=_step17.value;var T=[];for(var _x54=0;_x54<E.length;_x54+=2){var _h29=new Nt(E[_x54],E[_x54+1]);if(T.length>0){var p=T[T.length-1].point,d=at.Sub(_h29,p).uni();_h29.setv(d);}T.push({point:_h29,radius:l});}var _this64$computStroke=_this64.computStroke(T,!1),P=_this64$computStroke.ps;v.push(P.map(function(x){return x.XY;}));}}catch(err){_iterator17.e(err);}finally{_iterator17.f();}e0(f,v,0.01).forEach(function(E){r.push(E.map(function(T){return[T[0],T[1],T[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,m=_this$workOptions.strokeColor,f=_this$workOptions.strokeType,v=_this$workOptions.thickness,S=_this$workOptions.zIndex,E=_this$workOptions.scale,T=_this$workOptions.rotate,P=_this$workOptions.translate,x=_this$workOptions.eraserlines;l!=null&&l.size&&(l.forEach(function(w){var L;(L=o.getElementById(w+""))==null||L.remove();}),l.clear()),a&&this.removeDrawCountNodes(o,a);var h;var p=[],d=o.worldPosition,g=o.worldScaling;for(var w=0;w<n.length;w++){var _n$w=n[w],L=_n$w.pos,B=_n$w.points,_this$computDrawPoint=this.computDrawPoints(B),A=_this$computDrawPoint.ps,b=_this$computDrawPoint.rect;var W=void 0;var D=B.length===1;f===Zt.Stroke||D?W=De(A,!0):W=De(A,!1);var R={pos:L,d:W,fillColor:f===Zt.Stroke||D?m:void 0,lineDash:f===Zt.Dotted&&!D?[1,v*2]:f===Zt.LongDotted&&!D?[v,v*2]:void 0,strokeColor:m,lineCap:f===Zt.Stroke||D?void 0:"round",lineWidth:f===Zt.Stroke||D?0:v};h=bt(h,{x:Math.floor((b.x+L[0])*g[0]+d[0]-At.SafeBorderPadding),y:Math.floor((b.y+L[1])*g[1]+d[1]-At.SafeBorderPadding),w:Math.floor(b.w*g[0]+2*At.SafeBorderPadding),h:Math.floor(b.h*g[1]+2*At.SafeBorderPadding)}),p.push(R);}E&&(r.scale=E),T&&(r.rotate=T),P&&(r.translate=P);var O=new ye();if(h){this.centerPos=At.getCenterPos(h,o);var _w4=f===Zt.Stroke&&!x;O.attr(_objectSpread(_objectSpread({},r),{},{normalize:!0,anchor:[0.5,0.5],bgcolor:_w4?m:void 0,pos:this.centerPos,size:[(h.w-2*At.SafeBorderPadding)/g[0],(h.h-2*At.SafeBorderPadding)/g[1]],zIndex:S}));var _L5=p.map(function(B){return B.pos=[B.pos[0]-_this65.centerPos[0],B.pos[1]-_this65.centerPos[1]],new be(B);});O.append.apply(O,_toConsumableArray(_L5)),_w4&&O.seal(),x&&(this.scaleType=Qt.proportional,this.drawEraserlines({group:O,eraserlines:x,pos:this.centerPos,layer:o},c)),this.replace(o,i,O);}if(E||T||P){var _w5=O==null?void 0:O.getBoundingClientRect();_w5&&(h={x:Math.floor(_w5.x-At.SafeBorderPadding),y:Math.floor(_w5.y-At.SafeBorderPadding),w:Math.floor(_w5.width+At.SafeBorderPadding*2),h:Math.floor(_w5.height+At.SafeBorderPadding*2)});}return this.isDelete&&O.setAttribute("opacity",0),h;}},{key:"computDrawPoints",value:function computDrawPoints(t){return this.workOptions.strokeType===Zt.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,m=_t$a.radius;var f=c.v;a===0&&t.length>1&&(f=t[a+1].point.v);var v=at.Per(f).mul(m);n.push(Nt.Sub(c,v)),i.push(Nt.Add(c,v));}var l=t[t.length-1];if(r){var _a6=Nt.GetSemicircleStroke(l.point,n[n.length-1],-1,8),_c4=Nt.GetSemicircleStroke(t[0].point,i[0],-1,8),_m7=n.concat(_a6,i.reverse(),_c4);return{ps:_m7,rect:_t(_m7)};}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:Nt.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,m=/* @__PURE__ */new Set();l=a===Zt.Stroke?this.updateTempPointsWithPressure(n,c,m):this.updateTempPoints(n,c,m);var f=r?this.tmpPoints:this.tmpPoints.slice(l);return o=this.getTaskPoints(f,c),{tasks:o,effects:m,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=[],m=t[0].t;for(;i<t.length;){var v=t[i],S=v.x-l,E=v.y-o,T=v.z,P=r?this.computRadius(T,r):T;if(c.push({point:new Nt(S,E,T,t[i].v),radius:P}),i>0&&i<t.length-1){var _x55=t[i].getAngleByPoints(t[i-1],t[i+1]);if(_x55<60||_x55>300){var _h30=(f=c.pop())==null?void 0:f.point.clone();_h30&&n.push({taskId:m,pos:a,points:[].concat(_toConsumableArray(c),[{point:_h30,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 Nt(p,d,T),radius:P}],m=Date.now();}}i++;}return n.push({taskId:m,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 m=this.tmpPoints.length,f=new Nt(t[c],t[c+1]);if(m===0){this.tmpPoints.push(f);continue;}var v=m-1,S=this.tmpPoints[v],E=at.Sub(f,S).uni();if(f.isNear(S,r)){if(S.z<this.MAX_REPEAR){if(S.setz(Math.min(S.z+1,this.MAX_REPEAR)),o=Math.min(o,v),m>1){var _x56=m-1;for(;_x56>0;){var _h31=this.tmpPoints[_x56].distance(this.tmpPoints[_x56-1]),p=Math.max(this.tmpPoints[_x56].z-this.uniThickness*_h31,0);if(this.tmpPoints[_x56-1].z>=p)break;this.tmpPoints[_x56-1].setz(p),o=Math.min(o,_x56-1),_x56--;}}}else o=1/0;continue;}f.setv(E);var T=f.distance(S),P=Math.max(S.z-this.uniThickness*T,0);m>1&&at.Equals(E,S.v,0.02)&&(P>0||S.z<=0)&&(n&&S.t&&n.add(S.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 _m8=this.tmpPoints[_c6].t;if(_m8&&(n==null||n.add(_m8),_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 m=0;m<t.length;m+=2){var f=this.tmpPoints.length,v=new Nt(t[m],t[m+1]);if(f===0){this.tmpPoints.push(v);continue;}var S=f-1,E=this.tmpPoints[S],T=at.Sub(v,E).uni();if(v.isNear(E,r/2)){o=Math.min(S,o);continue;}at.Equals(T,E.v,0.02)&&(n&&E.t&&n.add(E.t),this.tmpPoints.pop(),o=Math.min(S,o)),v.setv(T),this.tmpPoints.push(v);}var a=l;if(o===l){a=Math.max(a-1,0);var _m9=this.tmpPoints[a].t;_m9&&(n==null||n.add(_m9));}else{var _m10=Math.min(l-1,o);for(a=o;_m10>=0;){var _f4=(c=this.tmpPoints[_m10])==null?void 0:c.t;if(_f4&&(n==null||n.add(_f4),_m10<=o)){a=_m10,_m10=-1;break;}_m10--;}}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 Nt(t[l],t[l+1]);if(o===0){this.tmpPoints.push(a);continue;}var c=o-1,m=this.tmpPoints[c],f=at.Sub(a,m).uni(),v=a.distance(m);if(o>1&&m.z===i)break;if(a.isNear(m,r/2)){if(n<3&&m.z<this.MAX_REPEAR&&(m.setz(Math.min(m.z+1,this.MAX_REPEAR)),o>1)){var E=o-1;for(;E>0;){var T=this.tmpPoints[E].distance(this.tmpPoints[E-1]),P=Math.max(this.tmpPoints[E].z-this.uniThickness*T,-r/4);if(this.tmpPoints[E-1].z>=P)break;this.tmpPoints[E-1].setz(P),E--;}}continue;}a.setv(f);var S=Math.max(m.z-this.uniThickness*v,i);o>1&&at.Equals(f,m.v,0.02)&&m.z<=0&&this.tmpPoints.pop(),a.setz(S),this.tmpPoints.push(a);}}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var c,m;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"?xm(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&&(m=a.opt)!=null&&m.strokeType&&(a.opt.strokeType=o),a&&i.setInfo(r.name,a),At.updateNodeOpt(t);}}]);}(At);var Ki=/*#__PURE__*/function(_At2){function Ki(t){var _this66;_classCallCheck(this,Ki);_this66=_callSuper(this,Ki,[t]);ot(_this66,"toolsType",pt.LaserPen);ot(_this66,"canRotate",!1);ot(_this66,"scaleType",Qt.none);ot(_this66,"syncTimestamp");ot(_this66,"syncIndex",0);ot(_this66,"tmpPoints",[]);ot(_this66,"workOptions");ot(_this66,"consumeIndex",0);_this66.workOptions=t.toolsOpt,_this66.syncTimestamp=0;return _this66;}_inherits(Ki,_At2);return _createClass(Ki,[{key:"combineConsume",value:function combineConsume(){}},{key:"setWorkOptions",value:function setWorkOptions(t){_superPropGet(Ki,"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,m=_this$workOptions3.strokeType,f=_t(this.tmpPoints,c);var v=!1;var S=this.syncIndex,E=this.tmpPoints.slice(this.consumeIndex);this.consumeIndex=this.tmpPoints.length-1,this.syncTimestamp===0&&(this.syncTimestamp=Date.now());var T={name:i==null?void 0:i.toString(),opacity:1,lineDash:m===Zt.Dotted?[1,c*2]:m===Zt.LongDotted?[c,c*2]:void 0,strokeColor:a,lineCap:"round",lineWidth:c,anchor:[0.5,0.5]},P=this.getTaskPoints(E);if(P.length){var _h32=Date.now();_h32-this.syncTimestamp>this.syncUnitTime&&(v=!0,this.syncTimestamp=_h32,this.syncIndex=this.tmpPoints.length),n&&this.draw({attrs:T,tasks:P,isDot:!1,layer:this.drawLayer||this.fullLayer});}var x=[];return this.tmpPoints.slice(S).forEach(function(h){x.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:Dt.Local,op:v?x:void 0,index:v?S*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,m=_this$workOptions4.thickness,f=_this$workOptions4.strokeType;if(a){var E=this.computDotStroke({point:o[0],radius:m/2});o=E.ps,r=E.rect;}else r=_t(this.tmpPoints,m);var v={name:t==null?void 0:t.toString(),fillColor:a?c:void 0,opacity:1,lineDash:f===Zt.Dotted&&!a?[1,m*2]:f===Zt.LongDotted&&!a?[m,m*2]:void 0,strokeColor:c,lineCap:a?void 0:"round",lineWidth:a?0:m,anchor:[0.5,0.5]},S=this.getTaskPoints(o);S.length&&this.draw({attrs:v,tasks:S,isDot:a,layer:this.drawLayer||this.fullLayer});}var n=[];this.tmpPoints.forEach(function(o){n.push(o.x,o.y);});var i=ve(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:Dt.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 T;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 m,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,m=_P6.rect;}else m=_t(this.tmpPoints,o);var S={name:(T=this.workId)==null?void 0:T.toString(),fillColor:v?l:void 0,opacity:1,lineDash:a===Zt.Dotted&&!v?[1,o*2]:a===Zt.LongDotted&&!v?[o,o*2]:void 0,strokeColor:l,lineCap:v?void 0:"round",lineWidth:v?0:o,anchor:[0.5,0.5]},E=this.getTaskPoints(f);if(E.length){var _P7=i?this.fullLayer:this.drawLayer||this.fullLayer;this.draw({attrs:S,tasks:E,isDot:v,replaceId:n,layer:_P7});}return{x:m.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:m.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:m.w*this.fullLayer.worldScaling[0],h:m.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:Nt.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 Nt(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,m,f,v,_this67$workOptions,S,E,T,_l$getResolution,P,_x58;return _regeneratorRuntime().wrap(function _loop5$(_context22){while(1)switch(_context22.prev=_context22.next){case 0:a=_step18.value;c=new be(),m=a.pos,f=a.points;i?v=De(f,!0):v=De(f,!1),c.attr(_objectSpread(_objectSpread({},r),{},{pos:m,d:v}));_this67$workOptions=_this67.workOptions,S=_this67$workOptions.vertex,E=_this67$workOptions.fragment;if(S&&E){T=l.renderer.createProgram({vertex:S,fragment:E}),_l$getResolution=l.getResolution(),P=_l$getResolution.width,_x58=_l$getResolution.height;c.setUniforms({u_time:0,u_resolution:[P,_x58]}),c.setProgram(T);}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(_x57){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 m=t[n],f=m.x-i,v=m.y-l;if(a.push(new Nt(f,v)),n>0&&n<t.length-1){var S=t[n].getAngleByPoints(t[n-1],t[n+1]);if(S<60||S>300){var E=(c=a.pop())==null?void 0:c.clone();E&&r.push({pos:o,points:[].concat(_toConsumableArray(a),[E])}),i=t[n].x,l=t[n].y,o=[i,l];var T=m.x-i,P=m.y-l;a=[new Nt(T,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=bt(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;}}]);}(At);var r0=Cr;Cr.polyline=Cr;Cr.polygon=n0;function Cr(u,e,t){var r=u.length,n=Ge(u[0],e),i=[],l,o,a,c,m;for(t||(t=[]),l=1;l<r;l++){for(o=u[l-1],a=u[l],c=m=Ge(a,e);;)if(n|c){if(n&c)break;n?(o=Zr(o,a,n,e),n=Ge(o,e)):(a=Zr(o,a,c,e),c=Ge(a,e));}else{i.push(o),c!==m?(i.push(a),l<r-1&&(t.push(i),i=[])):l===r-1&&i.push(a);break;}n=m;}return i.length&&t.push(i),t;}function n0(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(Zr(n,o,r,e)),a&&t.push(o),n=o,i=a;if(u=t,!u.length)break;}return t;}function Zr(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
407
407
  null;}function Ge(u,e){var t=0;return u[0]<e[0]?t|=1:u[0]>e[2]&&(t|=2),u[1]<e[1]?t|=4:u[1]>e[3]&&(t|=8),t;}var un=/* @__PURE__ */Ne(r0);var Ve=/*#__PURE__*/function(_At3){function Ve(t,r){var _this68;_classCallCheck(this,Ve);_this68=_callSuper(this,Ve,[t]);ot(_this68,"canRotate",!1);ot(_this68,"scaleType",Qt.none);ot(_this68,"toolsType",pt.Eraser);ot(_this68,"serviceWork");ot(_this68,"tmpPoints",[]);ot(_this68,"workOptions");ot(_this68,"worldPosition");ot(_this68,"worldScaling");ot(_this68,"eraserRect");ot(_this68,"eraserPolyline");_this68.serviceWork=r,_this68.workOptions=t.toolsOpt,_this68.worldPosition=_this68.fullLayer.worldPosition,_this68.worldScaling=_this68.fullLayer.worldScaling;return _this68;}_inherits(Ve,_At3);return _createClass(Ve,[{key:"combineConsume",value:function combineConsume(){}},{key:"consumeService",value:function consumeService(){}},{key:"setWorkOptions",value:function setWorkOptions(t){_superPropGet(Ve,"setWorkOptions",this,3)([t]);}},{key:"createEraserRect",value:function createEraserRect(t){var r=t[0]*this.worldScaling[0]+this.worldPosition[0],n=t[1]*this.worldScaling[1]+this.worldPosition[1],_Ve$eraserSizes$this$=Ve.eraserSizes[this.workOptions.thickness],i=_Ve$eraserSizes$this$.width,l=_Ve$eraserSizes$this$.height;this.eraserRect={x:r-i*0.5,y:n-l*0.5,w:i,h:l},this.eraserPolyline=[this.eraserRect.x,this.eraserRect.y,this.eraserRect.x+this.eraserRect.w,this.eraserRect.y+this.eraserRect.h];}},{key:"computRectCenterPoints",value:function computRectCenterPoints(){var t=this.tmpPoints.slice(-2);if(this.tmpPoints.length===4){var r=new at(this.tmpPoints[0],this.tmpPoints[1]),n=new at(this.tmpPoints[2],this.tmpPoints[3]),i=at.Sub(n,r).uni(),l=at.Dist(r,n),_Ve$eraserSizes$this$2=Ve.eraserSizes[this.workOptions.thickness],o=_Ve$eraserSizes$this$2.width,a=_Ve$eraserSizes$this$2.height,c=Math.min(o,a),m=Math.round(l/c);if(m>1){var f=[];for(var v=0;v<m;v++){var S=at.Mul(i,v*c);f.push(this.tmpPoints[0]+S.x,this.tmpPoints[1]+S.y);}return f.concat(t);}}return t;}},{key:"isNear",value:function isNear(t,r){var n=new at(t[0],t[1]),i=new at(r[0],r[1]),_Ve$eraserSizes$this$3=Ve.eraserSizes[this.workOptions.thickness],l=_Ve$eraserSizes$this$3.width,o=_Ve$eraserSizes$this$3.height;return at.Dist(n,i)<Math.hypot(l,o)*0.5;}},{key:"remove",value:function remove(t){var _this69=this;var r=t.curNodeMap,n=t.removeIds;var i;var _iterator19=_createForOfIteratorHelper(r.values()),_step19;try{for(_iterator19.s();!(_step19=_iterator19.n()).done;){var l=_step19.value;if(l.rect&&this.eraserRect&&this.eraserPolyline&&Jr(this.eraserRect,l.rect)){var o=l.op,a=[],c=[];for(var f=0;f<o.length;f+=3){var v=new at(o[f]*this.worldScaling[0]+this.worldPosition[0],o[f+1]*this.worldScaling[1]+this.worldPosition[1],o[f+2]);c.push(v),a.push(new Nt(v.x,v.y));}var m=a.length&&_t(a)||l.rect;Jr(m,this.eraserRect)&&(c.length>1?un.polyline(c.map(function(v){return v.XY;}),this.eraserPolyline).length&&n.add(l.name):n.add(l.name),i=bt(i,l.rect||m));}}}catch(err){_iterator19.e(err);}finally{_iterator19.f();}return n.forEach(function(l){var a;var o=_this69.fullLayer.getElementsByName(l);o[0]&&(o[0].remove(),_pe(o[0],_this69.fullLayer.parent),(a=_this69.vNodes)==null||a["delete"](l));}),i&&(i.x-=At.SafeBorderPadding,i.y-=At.SafeBorderPadding,i.w+=At.SafeBorderPadding*2,i.h+=At.SafeBorderPadding*2),i;}},{key:"consume",value:function consume(t){var _t$data2=t.data,r=_t$data2.op,n=_t$data2.disableEraseImage,i=_t$data2.disableEraseText;if(!r||r.length===0)return _objectSpread({type:dt.None},this.baseConsumeResult);var l=this.tmpPoints.length;if(l>1&&this.isNear([r[0],r[1]],[this.tmpPoints[l-2],this.tmpPoints[l-1]]))return _objectSpread({type:dt.None},this.baseConsumeResult);l<3?this.tmpPoints.push(r[0],r[1]):this.tmpPoints.splice(2,2,r[0],r[1]);var o=this.computRectCenterPoints();var a;var c=/* @__PURE__ */new Set();if(!this.vNodes)return _objectSpread({type:dt.None},this.baseConsumeResult);var m=this.getCanEraserNodeMap(this.vNodes.getCanEraserNodes(this.vNodes.curNodeMap,{disableEraseImage:n,disableEraseText:i}));for(var f=0;f<o.length-1;f+=2){this.createEraserRect(o.slice(f,f+2));var v=this.remove({curNodeMap:m,removeIds:c});a=bt(a,v);}return a&&c.size?{type:dt.RemoveNode,rect:a,removeIds:_toConsumableArray(c)}:_objectSpread({type:dt.None},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(t){return this.consume(t);}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}},{key:"getCanEraserNodeMap",value:function getCanEraserNodeMap(t){var r;if(this.serviceWork){var n=new Map(t),i=this.serviceWork.selectorWorkShapes,l=this.serviceWork.workShapes;var _iterator20=_createForOfIteratorHelper(i.values()),_step20;try{for(_iterator20.s();!(_step20=_iterator20.n()).done;){var o=_step20.value;if((r=o.selectIds)!=null&&r.length){var _iterator22=_createForOfIteratorHelper(o.selectIds),_step22;try{for(_iterator22.s();!(_step22=_iterator22.n()).done;){var a=_step22.value;n["delete"](a);}}catch(err){_iterator22.e(err);}finally{_iterator22.f();}}}}catch(err){_iterator20.e(err);}finally{_iterator20.f();}var _iterator21=_createForOfIteratorHelper(l.keys()),_step21;try{for(_iterator21.s();!(_step21=_iterator21.n()).done;){var _o4=_step21.value;n["delete"](_o4);}}catch(err){_iterator21.e(err);}finally{_iterator21.f();}return n;}return t;}}]);}(At);// 来源于white-sdk
408
- ot(Ve,"eraserSizes",fn);var Ir=Ve;var i0="__lodash_hash_undefined__";function s0(u){return this.__data__.set(u,i0),this;}var o0=s0;function a0(u){return this.__data__.has(u);}var l0=a0,c0=Pi,f0=o0,h0=l0;function Or(u){var e=-1,t=u==null?0:u.length;for(this.__data__=new c0();++e<t;)this.add(u[e]);}Or.prototype.add=Or.prototype.push=f0;Or.prototype.has=h0;var dn=Or;function u0(u,e){for(var t=-1,r=u==null?0:u.length;++t<r;)if(e(u[t],t,u))return!0;return!1;}var d0=u0;function p0(u,e){return u.has(e);}var pn=p0,m0=dn,v0=d0,y0=pn,g0=1,P0=2;function S0(u,e,t,r,n,i){var l=t&g0,o=u.length,a=e.length;if(o!=a&&!(l&&a>o))return!1;var c=i.get(u),m=i.get(e);if(c&&m)return c==e&&m==u;var f=-1,v=!0,S=t&P0?new m0():void 0;for(i.set(u,e),i.set(e,u);++f<o;){var E=u[f],T=e[f];if(r)var P=l?r(T,E,f,e,u,i):r(E,T,f,u,e,i);if(P!==void 0){if(P)continue;v=!1;break;}if(S){if(!v0(e,function(x,h){if(!y0(S,h)&&(E===x||n(E,x,t,r,i)))return S.push(h);})){v=!1;break;}}else if(!(E===T||n(E,T,t,r,i))){v=!1;break;}}return i["delete"](u),i["delete"](e),v;}var Zi=S0;function x0(u){var e=-1,t=Array(u.size);return u.forEach(function(r,n){t[++e]=[n,r];}),t;}var T0=x0;function C0(u){var e=-1,t=Array(u.size);return u.forEach(function(r){t[++e]=r;}),t;}var mn=C0,Vn=ur,Kn=Ui,I0=qr,O0=Zi,E0=T0,M0=mn,A0=1,w0=2,L0="[object Boolean]",R0="[object Date]",D0="[object Error]",b0="[object Map]",N0="[object Number]",B0="[object RegExp]",W0="[object Set]",F0="[object String]",U0="[object Symbol]",j0="[object ArrayBuffer]",Y0="[object DataView]",Zn=Vn?Vn.prototype:void 0,Yr=Zn?Zn.valueOf:void 0;function X0(u,e,t,r,n,i,l){switch(t){case Y0:if(u.byteLength!=e.byteLength||u.byteOffset!=e.byteOffset)return!1;u=u.buffer,e=e.buffer;case j0:return!(u.byteLength!=e.byteLength||!i(new Kn(u),new Kn(e)));case L0:case R0:case N0:return I0(+u,+e);case D0:return u.name==e.name&&u.message==e.message;case B0:case F0:return u==e+"";case b0:var o=E0;case W0:var a=r&A0;if(o||(o=M0),u.size!=e.size&&!a)return!1;var c=l.get(u);if(c)return c==e;r|=w0,l.set(u,e);var m=O0(o(u),o(e),r,n,i,l);return l["delete"](u),m;case U0:if(Yr)return Yr.call(u)==Yr.call(e);}return!1;}var z0=X0,Jn=Bi,$0=1,G0=Object.prototype,k0=G0.hasOwnProperty;function H0(u,e,t,r,n,i){var l=t&$0,o=Jn(u),a=o.length,c=Jn(e),m=c.length;if(a!=m&&!l)return!1;for(var f=a;f--;){var v=o[f];if(!(l?v in e:k0.call(e,v)))return!1;}var S=i.get(u),E=i.get(e);if(S&&E)return S==e&&E==u;var T=!0;i.set(u,e),i.set(e,u);for(var P=l;++f<a;){v=o[f];var x=u[v],h=e[v];if(r)var p=l?r(h,x,v,e,u,i):r(x,h,v,u,e,i);if(!(p===void 0?x===h||n(x,h,t,r,i):p)){T=!1;break;}P||(P=v=="constructor");}if(T&&!P){var d=u.constructor,g=e.constructor;d!=g&&"constructor"in u&&"constructor"in e&&!(typeof d=="function"&&d instanceof d&&typeof g=="function"&&g instanceof g)&&(T=!1);}return i["delete"](u),i["delete"](e),T;}var V0=H0,Xr=Si,K0=Zi,Z0=z0,J0=V0,Qn=Fr,qn=pr,_n=tn,Q0=Mi,q0=1,ti="[object Arguments]",ei="[object Array]",gr="[object Object]",_0=Object.prototype,ri=_0.hasOwnProperty;function tm(u,e,t,r,n,i){var l=qn(u),o=qn(e),a=l?ei:Qn(u),c=o?ei:Qn(e);a=a==ti?gr:a,c=c==ti?gr:c;var m=a==gr,f=c==gr,v=a==c;if(v&&_n(u)){if(!_n(e))return!1;l=!0,m=!1;}if(v&&!m)return i||(i=new Xr()),l||Q0(u)?K0(u,e,t,r,n,i):Z0(u,e,a,t,r,n,i);if(!(t&q0)){var S=m&&ri.call(u,"__wrapped__"),E=f&&ri.call(e,"__wrapped__");if(S||E){var T=S?u.value():u,P=E?e.value():e;return i||(i=new Xr()),n(T,P,t,r,i);}}return v?(i||(i=new Xr()),J0(u,e,t,r,n,i)):!1;}var em=tm,rm=em,ni=Le;function Ji(u,e,t,r,n){return u===e?!0:u==null||e==null||!ni(u)&&!ni(e)?u!==u&&e!==e:rm(u,e,t,r,Ji,n);}var nm=Ji,im=nm;function sm(u,e){return im(u,e);}var om=sm,Me=/* @__PURE__ */Ne(om);function ii(u,e,t){var r=arguments.length>3&&arguments[3]!==undefined?arguments[3]:1;return"rgba(".concat(u,",").concat(e,",").concat(t,",").concat(r,")");}function am(u){var e=u.split(","),t=parseInt(e[0].split("(")[1]),r=parseInt(e[1]),n=parseInt(e[2]),i=Number(e[3].split(")")[0]);return[t,r,n,i];}var Lr=/*#__PURE__*/function(_At4){function Lr(t){var _this70;_classCallCheck(this,Lr);_this70=_callSuper(this,Lr,[t]);ot(_this70,"toolsType",pt.Selector);ot(_this70,"tmpPoints",[]);ot(_this70,"subTmpPoints",[]);ot(_this70,"workOptions");ot(_this70,"vNodes");ot(_this70,"selectIds");ot(_this70,"selectorColor");ot(_this70,"strokeColor");ot(_this70,"fillColor");ot(_this70,"oldSelectRect");ot(_this70,"oldSubSelectRect");ot(_this70,"canRotate",!1);ot(_this70,"canTextEdit",!1);ot(_this70,"canLock",!1);ot(_this70,"scaleType",Qt.all);ot(_this70,"toolsTypes");ot(_this70,"shapeOpt");ot(_this70,"textOpt");ot(_this70,"isLocked");ot(_this70,"thickness");ot(_this70,"strokeType");ot(_this70,"useStroke");_this70.workOptions=t.toolsOpt,_this70.vNodes=t.vNodes;return _this70;}_inherits(Lr,_At4);return _createClass(Lr,[{key:"computSelector",value:function computSelector(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:!0;var r=_t(this.tmpPoints);if(r.w===0||r.h===0)return{selectIds:[],intersectRect:void 0,subNodeMap:/* @__PURE__ */new Map()};var _this$vNodes$getRectI=this.vNodes.getRectIntersectRange(r,t),n=_this$vNodes$getRectI.rectRange,i=_this$vNodes$getRectI.nodeRange;return{selectIds:_toConsumableArray(i.keys()),intersectRect:n,subNodeMap:i};}},{key:"updateTempPoints",value:function updateTempPoints(t){var r=this.tmpPoints.length,n=t.length;if(n>1){var i=new Nt(t[n-2]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],t[n-1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]);r===2?this.tmpPoints.splice(1,1,i):this.tmpPoints.push(i);}}},{key:"drawSelector",value:function drawSelector(t){var _this71=this;var r=t.drawRect,n=t.subNodeMap,i=t.selectorId,l=t.layer,o=t.isService,a=new ye({pos:[r.x,r.y],anchor:[0,0],size:[r.w,r.h],id:i,name:i,zIndex:9999}),c=[];if(o){var m=new Sn({normalize:!0,pos:[r.w/2,r.h/2],lineWidth:1,strokeColor:this.selectorColor||this.workOptions.strokeColor,width:r.w,height:r.h,name:Lr.selectorBorderId});c.push(m);}n.forEach(function(m,f){var v=[m.rect.x+m.rect.w/2-r.x,m.rect.y+m.rect.h/2-r.y],S=new Sn({normalize:!0,pos:v,lineWidth:1,strokeColor:n.size>1?_this71.selectorColor||_this71.workOptions.strokeColor:void 0,width:m.rect.w,height:m.rect.h,id:"selector-".concat(f),name:"selector-".concat(f)});c.push(S);}),c&&a.append.apply(a,c),(l==null?void 0:l.parent).appendChild(a);}},{key:"draw",value:function draw(t,r,n){var i=arguments.length>3&&arguments[3]!==undefined?arguments[3]:!1;var a,c;var l=n.intersectRect,o=n.subNodeMap;(c=(a=r.parent)==null?void 0:a.getElementById(t))==null||c.remove(),l&&this.drawSelector({drawRect:l,subNodeMap:o,selectorId:t,layer:r,isService:i});}},{key:"getSelecteorInfo",value:function getSelecteorInfo(t){this.scaleType=Qt.all,this.canRotate=!1,this.textOpt=void 0,this.strokeColor=void 0,this.fillColor=void 0,this.canTextEdit=!1,this.canLock=!1,this.isLocked=!1,this.toolsTypes=void 0,this.shapeOpt=void 0,this.thickness=void 0,this.strokeType=void 0,this.useStroke=!1;var r=/* @__PURE__ */new Set();var n,i=!0;var _iterator23=_createForOfIteratorHelper(t.values()),_step23;try{for(_iterator23.s();!(_step23=_iterator23.n()).done;){var l=_step23.value;var o=l.opt,a=l.canRotate,c=l.scaleType,m=l.toolsType;this.selectorColor=this.workOptions.strokeColor,o.strokeColor&&(this.strokeColor=o.strokeColor),o.fillColor&&(this.fillColor=o.fillColor),o.textOpt&&(this.textOpt=o.textOpt),o.thickness&&(this.thickness=o.thickness),m!==pt.Pencil&&(i=!1),o.strokeType&&(this.strokeType=o.strokeType),m===pt.SpeechBalloon&&(r.add(m),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.placement=o.placement),m===pt.Polygon&&(r.add(m),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=o.vertices),m===pt.Star&&(r.add(m),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=o.vertices,this.shapeOpt.innerRatio=o.innerRatio,this.shapeOpt.innerVerticeStep=o.innerVerticeStep),m===pt.Text&&(this.textOpt=o),t.size===1&&(this.textOpt&&(this.canTextEdit=!0),this.canRotate=a,this.scaleType=c),m===pt.Image&&(n=l),(c===Qt.proportional&&this.scaleType!==Qt.none||c===Qt.none)&&(this.scaleType=c);}}catch(err){_iterator23.e(err);}finally{_iterator23.f();}i&&(this.useStroke=!0),r.size&&(this.toolsTypes=_toConsumableArray(r)),n&&(t.size===1?(this.canLock=!0,n.opt.locked&&(this.isLocked=!0,this.scaleType=Qt.none,this.canRotate=!1,this.textOpt=void 0,this.fillColor=void 0,this.selectorColor="rgb(177,177,177)",this.strokeColor=void 0,this.canTextEdit=!1,this.thickness=void 0,this.strokeType=void 0,this.useStroke=void 0)):t.size>1&&!n.opt.locked&&(this.canLock=!1,this.canRotate=!1));}},{key:"getChildrenPoints",value:function getChildrenPoints(){var t,r;if(this.scaleType===Qt.both&&((t=this.selectIds)==null?void 0:t.length)===1){var n=this.selectIds[0],i=(r=this.vNodes.get(n))==null?void 0:r.op;if(i){var l=[];for(var o=0;o<i.length;o+=3)l.push([i[o],i[o+1]]);return l;}}}},{key:"consume",value:function consume(t){if(t.isSubWorker)return this.subWorkerConsume(t);var r=_objectSpread({type:dt.Select,dataType:Dt.Local},this.baseConsumeResult);if(t.isSimpleWorker){var m=this.subWorkerConsume(t);r.subRect=m.rect;}var _t$data3=t.data,n=_t$data3.op,i=_t$data3.workState;var l=this.oldSelectRect;if(i===Ft.Start&&(l=this.unSelectedAllIds()),!(n!=null&&n.length)||!this.vNodes.curNodeMap.size)return t.isSimpleWorker?r:{type:dt.None};this.updateTempPoints(n);var o=this.computSelector();if(this.selectIds&&Me(this.selectIds,o.selectIds))return t.isSimpleWorker?r:{type:dt.None};this.selectIds=o.selectIds;var a=o.intersectRect;this.getSelecteorInfo(o.subNodeMap),this.draw(qt,this.fullLayer,o),this.oldSelectRect=a;var c=this.getChildrenPoints();return r=_objectSpread(_objectSpread({},r),{},{rect:bt(a,l),selectIds:o.selectIds,selectRect:a,selectorColor:this.selectorColor,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:c,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType}),r;}},{key:"consumeAll",value:function consumeAll(){var r,n;var t=this.oldSelectRect;if(!((r=this.selectIds)!=null&&r.length)&&this.tmpPoints[0]&&this.selectSingleTool(this.tmpPoints[0].XY,qt,!1),(n=this.selectIds)!=null&&n.length&&(t=this.selectedByIds(this.selectIds)),t){var i=this.getChildrenPoints();return _objectSpread({type:dt.Select,dataType:Dt.Local,rect:this.oldSelectRect,selectIds:this.selectIds,selectorColor:this.selectorColor,selectRect:this.oldSelectRect,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:i,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType},this.baseConsumeResult);}return{type:dt.None};}},{key:"consumeService",value:function consumeService(){}},{key:"updateTempPointsForSubWorker",value:function updateTempPointsForSubWorker(t){var r=t.slice(-2),n=new Nt(r[0],r[1]);if(this.subTmpPoints[0].isNear(n,1))return!1;if(this.subTmpPoints.length===2){if(n.isNear(this.subTmpPoints[1],1))return!1;this.subTmpPoints[1]=n;}else this.subTmpPoints.push(n);return!0;}},{key:"computDrawPoints",value:function computDrawPoints(t){var r=this.workOptions.thickness,n=[];var _iterator24=_createForOfIteratorHelper(t),_step24;try{for(_iterator24.s();!(_step24=_iterator24.n()).done;){var o=_step24.value;n.push(_construct(at,_toConsumableArray(o)));}}catch(err){_iterator24.e(err);}finally{_iterator24.f();}var i=_t(n,r),l=[i.x+i.w/2,i.y+i.h/2];return{rect:i,pos:l,points:n.map(function(o){return o.XY;}).flat(1)};}},{key:"drawForSubWorker",value:function drawForSubWorker(t){var r=t.workId,n=t.layer,i=t.ps,_this$workOptions6=this.workOptions,l=_this$workOptions6.strokeColor,o=_this$workOptions6.scale,a=_this$workOptions6.rotate,c=_this$workOptions6.translate,m=n.worldPosition,f=n.worldScaling,_this$computDrawPoint2=this.computDrawPoints(i),v=_this$computDrawPoint2.points,S=_this$computDrawPoint2.rect,E=_this$computDrawPoint2.pos,T=1/n.worldScaling[0],P=l&&am(l)||[0,0,0,0],x={close:!0,normalize:!0,points:v,lineWidth:T,fillColor:ii(P[0],P[1],P[2],0.1),strokeColor:ii(P[0],P[1],P[2],1),lineJoin:"round",lineCap:"round"};var h={x:Math.floor(S.x*f[0]+m[0]-At.SafeBorderPadding),y:Math.floor(S.y*f[1]+m[1]-At.SafeBorderPadding),w:Math.floor(S.w*f[0]+2*At.SafeBorderPadding),h:Math.floor(S.h*f[0]+2*At.SafeBorderPadding)};var p=new ye({name:r,id:r,pos:E,anchor:[0.5,0.5],size:[S.w,S.h],scale:o,rotate:a,translate:c}),d=new we(_objectSpread(_objectSpread({},x),{},{pos:[0,0]}));if(p.appendChild(d),this.replace(n,r,p),o||a||c){var g=p.getBoundingClientRect();h={x:Math.floor(g.x-At.SafeBorderPadding),y:Math.floor(g.y-At.SafeBorderPadding),w:Math.floor(g.width+2*At.SafeBorderPadding),h:Math.floor(g.height+2*At.SafeBorderPadding)};}return h;}},{key:"transformData",value:function transformData(t){var r=_t(t);return[[r.x,r.y,0],[r.x+r.w,r.y,0],[r.x+r.w,r.y+r.h,0],[r.x,r.y+r.h,0]];}},{key:"subWorkerConsume",value:function subWorkerConsume(t){var r=t.data,n=t.isFullWork,i=r.op,l=r.syncUnitTime;l&&(this.syncUnitTime=l);var o=i==null?void 0:i.length;if(!o||o<2)return{type:dt.None,rect:void 0};var a;if(this.subTmpPoints.length===0?(this.subTmpPoints=[new Nt(i[0],i[1])],a=!1):a=this.updateTempPointsForSubWorker(i),!a)return{type:dt.None,rect:void 0};var c=this.transformData(this.subTmpPoints),m=n?this.fullLayer:this.drawLayer||this.fullLayer,f=this.drawForSubWorker({ps:c,workId:this.workId,layer:m}),v=bt(f,this.oldSubSelectRect);return this.oldSubSelectRect=f,_objectSpread({rect:v,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);}},{key:"subWorkerConsumeAll",value:function subWorkerConsumeAll(t){var r=t.isFullWork,n=r?this.fullLayer:this.drawLayer||this.fullLayer;return this.replace(n,this.workId),_objectSpread({rect:this.oldSelectRect,type:dt.FullWork,dataType:Dt.Local},this.baseConsumeResult);}},{key:"clearSubTmpPoints",value:function clearSubTmpPoints(){this.subTmpPoints.length=0;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0,this.clearSubTmpPoints();}},{key:"clearSubSelectData",value:function clearSubSelectData(){this.oldSubSelectRect=void 0;}},{key:"clearSelectData",value:function clearSelectData(){this.selectIds=void 0,this.oldSelectRect=void 0,this.clearSubSelectData();}},{key:"selectSingleTool",value:function selectSingleTool(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:qt;var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!1;if(t.length===2){var i=t[0],l=t[1];var o;var _this$vNodes$getRectI2=this.vNodes.getRectIntersectRange({x:i,y:l,w:0,h:0},!1),a=_this$vNodes$getRectI2.nodeRange,c=_toConsumableArray(a.values()).sort(function(m,f){return(f.opt.zIndex||0)-(m.opt.zIndex||0);});var _iterator25=_createForOfIteratorHelper(c),_step25;try{for(_iterator25.s();!(_step25=_iterator25.n()).done;){var _m11=_step25.value;var _f5=this.fullLayer.getElementsByName(_m11.name);if(ss(_f5).find(function(S){return S.isPointCollision(i,l);})){o=_m11;break;}}}catch(err){_iterator25.e(err);}finally{_iterator25.f();}if(o){var m=o.name;if(!Me(this.oldSelectRect,o.rect)){var f=/* @__PURE__ */new Map([[m,o]]);this.getSelecteorInfo(f),this.draw(r,this.fullLayer,{intersectRect:o.rect,subNodeMap:f,selectIds:this.selectIds||[]},n);}this.selectIds=[m],this.oldSelectRect=o.rect;}}}},{key:"unSelectedAllIds",value:function unSelectedAllIds(){var t;var _iterator26=_createForOfIteratorHelper(this.vNodes.curNodeMap.entries()),_step26;try{for(_iterator26.s();!(_step26=_iterator26.n()).done;){var _step26$value=_slicedToArray(_step26.value,2),r=_step26$value[0],n=_step26$value[1];n.isSelected&&(t=bt(t,n.rect),this.vNodes.unSelected(r));}}catch(err){_iterator26.e(err);}finally{_iterator26.f();}return t;}},{key:"unSelectedByIds",value:function unSelectedByIds(t){var r;var _iterator27=_createForOfIteratorHelper(t),_step27;try{for(_iterator27.s();!(_step27=_iterator27.n()).done;){var n=_step27.value;var i=this.vNodes.get(n);i&&i.isSelected&&(r=bt(r,i.rect),this.vNodes.unSelected(n));}}catch(err){_iterator27.e(err);}finally{_iterator27.f();}return r;}},{key:"selectedByIds",value:function selectedByIds(t){var r;var _iterator28=_createForOfIteratorHelper(t),_step28;try{for(_iterator28.s();!(_step28=_iterator28.n()).done;){var n=_step28.value;var i=this.vNodes.get(n);i&&(r=bt(r,i.rect),this.vNodes.selected(n));}}catch(err){_iterator28.e(err);}finally{_iterator28.f();}return r;}},{key:"getSelectorRect",value:function getSelectorRect(t,r){var o;var n;var i=(o=t.parent)==null?void 0:o.getElementById(r),l=i==null?void 0:i.getBoundingClientRect();return l&&(n=bt(n,{x:Math.floor(l.x),y:Math.floor(l.y),w:Math.floor(l.width+1),h:Math.floor(l.height+1)})),n;}},{key:"isCanFillColor",value:function isCanFillColor(t){return t===pt.Ellipse||t===pt.Triangle||t===pt.Rectangle||t===pt.Polygon||t===pt.Star||t===pt.SpeechBalloon;}},{key:"updateSelector",value:function(){var _updateSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22(t){var r,n,i,l,o,a,c,m,f,v,S,E,T,P,x,h,_iterator29,_step29,g,O,w,L,B,A,b,W,D,R,X,p,_g12,_O8,_w6,d;return _regeneratorRuntime().wrap(function _callee22$(_context24){while(1)switch(_context24.prev=_context24.next){case 0:r=t.updateSelectorOpt,n=t.selectIds,i=t.vNodes,l=t.willSerializeData,o=t.worker,a=t.offset,c=this.fullLayer;if(c){_context24.next=3;break;}return _context24.abrupt("return");case 3:f=/* @__PURE__ */new Map(),v=r.originPoint,S=r.workState,E=r.angle,T=r.translate,P=r.dir,x=r.scale;a&&(T?r.translate=[T[0]+a[0],T[1]+a[1]]:r.translate=a);if(!(v||T||ue(E))){_context24.next=10;break;}if(!(S===Ft.Start&&n)){_context24.next=8;break;}return _context24.abrupt("return",(i.setTargetAssignKeys(n),{type:dt.Select,dataType:Dt.Local,selectRect:this.oldSelectRect,rect:this.oldSelectRect}));case 8:if(!(h=i.getLastTarget(),!h)){_context24.next=10;break;}return _context24.abrupt("return");case 10:if(!n){_context24.next=62;break;}_iterator29=_createForOfIteratorHelper(n);_context24.prev=12;_iterator29.s();case 14:if((_step29=_iterator29.n()).done){_context24.next=54;break;}g=_step29.value;O=i.get(g);if(!O){_context24.next=52;break;}w=O.toolsType,L=O.opt,B=(c==null?void 0:c.getElementsByName(g))[0];if(!B){_context24.next=52;break;}A=_objectSpread({},r);b=void 0;W=At.isWillRefresh({toolsType:w,opt:L,updateOpt:A,vNodes:i,node:B,willSerializeData:l});if(!w){_context24.next=52;break;}b=h==null?void 0:h.get(g);D=is(w);if(!(D==null||D.updateNodeOpt({node:B,opt:A,vNodes:i,willSerializeData:l,targetNode:b}),O&&o&&W)){_context24.next=51;break;}R=o.createWorkShapeNode({workId:g,toolsType:w,toolsOpt:O.opt});R==null||R.setWorkId(g);X=void 0;if(!(w===pt.Image)){_context24.next=36;break;}_context24.next=33;return R.consumeServiceAsync({isFullWork:!0,replaceId:g,worker:o});case 33:X=_context24.sent;_context24.next=50;break;case 36:if(!(w===pt.Text)){_context24.next=42;break;}_context24.next=39;return R.consumeServiceAsync({isFullWork:!0,replaceId:g});case 39:X=_context24.sent;_context24.next=50;break;case 42:_context24.prev=42;X=R==null?void 0:R.consumeService({op:O.op,isFullWork:!0,replaceId:g,workState:S});_context24.next=50;break;case 46:_context24.prev=46;_context24.t0=_context24["catch"](42);console.error("consumeService error",_context24.t0);return _context24.abrupt("continue",52);case 50:X&&(O.rect=X);case 51:O&&(f.set(g,O),m=bt(m,O.rect));case 52:_context24.next=14;break;case 54:_context24.next=59;break;case 56:_context24.prev=56;_context24.t1=_context24["catch"](12);_iterator29.e(_context24.t1);case 59:_context24.prev=59;_iterator29.f();return _context24.finish(59);case 62:h&&S===Ft.Done&&(i.deleteLastTarget(),h=void 0);p=m;if(!(v&&T&&x&&P&&p&&!a)){_context24.next=82;break;}_g12=[[p.x,p.y],[p.x+p.w,p.y],[p.x+p.w,p.y+p.h],[p.x,p.y+p.h]];_context24.t2=P;_context24.next=_context24.t2==="top"?69:_context24.t2==="topLeft"?69:_context24.t2==="left"?69:_context24.t2==="topRight"?71:_context24.t2==="right"?73:_context24.t2==="bottomRight"?73:_context24.t2==="bottom"?73:_context24.t2==="bottomLeft"?75:77;break;case 69:T[0]>0&&T[1]>0?_O8=_g12[0]:T[0]>0?_O8=_g12[3]:T[1]>0?_O8=_g12[1]:_O8=_g12[2];return _context24.abrupt("break",77);case 71:T[0]<0&&T[1]>0?_O8=_g12[1]:T[0]<0?_O8=_g12[2]:T[1]>0?_O8=_g12[0]:_O8=_g12[3];return _context24.abrupt("break",77);case 73:T[0]<0&&T[1]<0?_O8=_g12[2]:T[0]<0?_O8=_g12[1]:T[1]<0?_O8=_g12[3]:_O8=_g12[0];return _context24.abrupt("break",77);case 75:T[0]>0&&T[1]<0?_O8=_g12[3]:T[0]>0?_O8=_g12[0]:T[1]<0?_O8=_g12[2]:_O8=_g12[1];return _context24.abrupt("break",77);case 77:_w6=_O8&&[v[0]-_O8[0],v[1]-_O8[1]]||[0,0];if(Me(_w6,[0,0])){_context24.next=82;break;}_context24.next=81;return this.updateSelector(_objectSpread(_objectSpread({},t),{},{updateSelectorOpt:{workState:S},offset:_w6}));case 81:return _context24.abrupt("return",_context24.sent);case 82:this.getSelecteorInfo(f),this.draw(qt,c,{selectIds:n||[],subNodeMap:f,intersectRect:p});d=bt(this.oldSelectRect,p);return _context24.abrupt("return",(this.oldSelectRect=p,{type:dt.Select,dataType:Dt.Local,selectRect:p,renderRect:m,rect:bt(d,p),selectIds:n}));case 85:case"end":return _context24.stop();}},_callee22,this,[[12,56,59,62],[42,46]]);}));function updateSelector(_x59){return _updateSelector.apply(this,arguments);}return updateSelector;}()},{key:"blurSelector",value:function blurSelector(){var t=this.unSelectedAllIds();return{type:dt.Select,dataType:Dt.Local,rect:t,selectIds:[],willSyncService:!0};}},{key:"getRightServiceId",value:function getRightServiceId(t){return t.replace(Je,"-");}},{key:"selectServiceNode",value:function selectServiceNode(t,r,n){var _this72=this;var i=r.selectIds,l=this.getRightServiceId(t),o=this.getSelectorRect(this.fullLayer,l);var a;var c=/* @__PURE__ */new Map();return i==null||i.forEach(function(m){var f=_this72.vNodes.get(m);f&&(a=bt(a,f.rect),c.set(m,f));}),this.getSelecteorInfo(c),this.draw(l,this.fullLayer,{intersectRect:a,selectIds:i||[],subNodeMap:c},n),bt(a,o);}},{key:"reRenderSelector",value:function reRenderSelector(){var _this73=this;var n;var t;var r=/* @__PURE__ */new Map();return(n=this.selectIds)==null||n.forEach(function(i){var l=_this73.vNodes.get(i);l&&(t=bt(t,l.rect),r.set(i,l));},this),this.getSelecteorInfo(r),this.draw(qt,this.fullLayer,{intersectRect:t,subNodeMap:r,selectIds:this.selectIds||[]}),this.oldSelectRect=t,t;}},{key:"updateSelectIds",value:function updateSelectIds(t){var l;var r;var n=(l=this.selectIds)==null?void 0:l.filter(function(o){return!t.includes(o);});if(n!=null&&n.length&&(r=this.unSelectedByIds(n)),t.length){var o=this.selectedByIds(t);r=bt(r,o);}this.selectIds=t;var i=this.reRenderSelector();return{bgRect:r,selectRect:i};}},{key:"cursorHover",value:function cursorHover(t){var l,o;var r=this.oldSelectRect;this.selectIds=[];var n=(l=this.workId)==null?void 0:l.toString(),i=[t[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],t[1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]];if(this.selectSingleTool(i,n,!0),this.oldSelectRect&&!Me(r,this.oldSelectRect))return{type:dt.CursorHover,dataType:Dt.Local,rect:bt(r,this.oldSelectRect),selectorColor:this.selectorColor,willSyncService:!1};if((o=this.selectIds)!=null&&o.length||(this.oldSelectRect=void 0),r&&!this.oldSelectRect)return this.cursorBlur(),{type:dt.CursorHover,dataType:Dt.Local,rect:r,selectorColor:this.selectorColor,willSyncService:!1};}},{key:"cursorBlur",value:function cursorBlur(){var r,n;this.selectIds=[];var t=(r=this.workId)==null?void 0:r.toString();((n=this.fullLayer)==null?void 0:n.parent).children.forEach(function(i){i.name===t&&i.remove();});}}]);}(At);ot(Lr,"selectorBorderId","selector-border");var ar=Lr;var Qi=/*#__PURE__*/function(_At5){function Qi(t){var _this74;_classCallCheck(this,Qi);_this74=_callSuper(this,Qi,[t]);ot(_this74,"canRotate",!1);ot(_this74,"scaleType",Qt.both);ot(_this74,"toolsType",pt.Arrow);ot(_this74,"tmpPoints",[]);ot(_this74,"workOptions");ot(_this74,"oldRect");ot(_this74,"arrowTipWidth");ot(_this74,"syncTimestamp");_this74.workOptions=t.toolsOpt,_this74.arrowTipWidth=_this74.workOptions.thickness*4,_this74.syncTimestamp=0,_this74.syncUnitTime=50;return _this74;}_inherits(Qi,_At5);return _createClass(Qi,[{key:"consume",value:function consume(t){var r=t.data,n=t.isFullWork,i=t.isSubWorker,l=t.isMainThread,o=t.smoothSync,a=t.isSimpleWorker,c=this.workId,m=r.op,f=r.syncUnitTime;f&&(this.syncUnitTime=f);var v=m==null?void 0:m.length;if(!v||v<2)return{type:dt.None};var S;if(this.tmpPoints.length===0?(this.tmpPoints=[new Nt(m[0],m[1])],S=!1):S=this.updateTempPoints(m),!S)return{type:dt.None};var E;if(i||l||a){var P=n?this.fullLayer:this.drawLayer||this.fullLayer;E=this.draw({workId:c,layer:P});}if(a){var _P8=bt(E,this.oldRect);this.oldRect=E;var _x60=_objectSpread({rect:_P8,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);if(o){var _h33=Date.now();_h33-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=_h33,_x60.op=this.tmpPoints.map(function(p){return[].concat(_toConsumableArray(p.XY),[0]);}).flat(1),_x60.index=0,_x60.isSync=!0);}return _x60;}if(!i&&o){var _P9=Date.now();return _P9-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_P9,_objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:dt.DrawWork,dataType:Dt.Local,op:this.tmpPoints.map(function(x){return[].concat(_toConsumableArray(x.XY),[0]);}).flat(1),isSync:!0,index:0})):{type:dt.None};}var T=bt(E,this.oldRect);return this.oldRect=E,_objectSpread(_objectSpread({rect:T},this.baseConsumeResult),{},{type:dt.DrawWork,dataType:Dt.Local});}},{key:"consumeAll",value:function consumeAll(){var o;var t=this.workId;if(this.tmpPoints.length<2)return{type:dt.RemoveNode,removeIds:[t]};var r=this.fullLayer,n=this.draw({workId:t,layer:r});this.oldRect=n;var i=this.tmpPoints.map(function(a){return[].concat(_toConsumableArray(a.XY),[0]);}).flat(1),l=ve(i);return(o=this.vNodes)==null||o.setInfo(t,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:At.getCenterPos(n,r)}),_objectSpread(_objectSpread({rect:n},this.baseConsumeResult),{},{type:dt.FullWork,dataType:Dt.Local,ops:l,isSync:!0,updateNodeOpt:{useAnimation:!0}});}},{key:"draw",value:function draw(t){var r=t.workId,n=t.layer,i=t.isDrawEraserlines,_this$workOptions7=this.workOptions,l=_this$workOptions7.strokeColor,o=_this$workOptions7.thickness,a=_this$workOptions7.zIndex,c=_this$workOptions7.scale,m=_this$workOptions7.rotate,f=_this$workOptions7.translate,v=_this$workOptions7.strokeType,S=_this$workOptions7.eraserlines,E=n.worldPosition,T=n.worldScaling,_this$computDrawPoint3=this.computDrawPoints(o),P=_this$computDrawPoint3.points,x=_this$computDrawPoint3.pos,h=_this$computDrawPoint3.rect,p=_this$computDrawPoint3.isTriangle,d=_this$computDrawPoint3.trianglePoints,g=_this$computDrawPoint3.trianglePos,O=[h.x+h.w/2,h.y+h.h/2],w={pos:O,name:r,id:r,zIndex:a,anchor:[0.5,0.5],size:[h.w,h.h]};c&&(w.scale=c),m&&(w.rotate=m),f&&(w.translate=f);var L=new ye(w),B={points:d,pos:[g[0]-O[0],g[1]-O[1]],fillColor:l,strokeColor:l,lineWidth:0,normalize:!1},A=new we(B);if(L.append(A),!p&&P&&x){var W={points:P,pos:[x[0]-O[0],x[1]-O[1]],fillColor:l,strokeColor:l,lineDash:v===Zt.Dotted&&!p?[1,o*2]:v===Zt.LongDotted&&!p?[o,o*2]:void 0,lineCap:v===Zt.Normal?void 0:"round",lineWidth:o,normalize:!1},D=new we(W);L.append(D);}S&&(this.scaleType=Qt.proportional,this.drawEraserlines({group:L,eraserlines:S,pos:O,layer:n},i)),this.replace(n,r,L);var b={x:Math.floor(h.x*T[0]+E[0]-At.SafeBorderPadding),y:Math.floor(h.y*T[1]+E[1]-At.SafeBorderPadding),w:Math.floor(h.w*T[0]+2*At.SafeBorderPadding),h:Math.floor(h.h*T[1]+2*At.SafeBorderPadding)};if(c||m||f){var _W9=L.getBoundingClientRect();b={x:Math.floor(_W9.x-At.SafeBorderPadding),y:Math.floor(_W9.y-At.SafeBorderPadding),w:Math.floor(_W9.width+At.SafeBorderPadding*2),h:Math.floor(_W9.height+At.SafeBorderPadding*2)};}return this.isDelete&&L.setAttribute("opacity",0),b;}},{key:"computDrawPoints",value:function computDrawPoints(t){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.arrowTipWidth?this.computFullArrowPoints(t):this.computTrianglePoints();}},{key:"computFullArrowPoints",value:function computFullArrowPoints(t){var _this75=this;var r=at.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),n=at.Per(r).mul(t/2),i=Nt.Sub(this.tmpPoints[0],n),l=Nt.Add(this.tmpPoints[0],n),o=at.Mul(r,this.arrowTipWidth),a=at.Sub(this.tmpPoints[1],o),c=Nt.Sub(a,n),m=Nt.Add(a,n),f=at.Per(r).mul(t*1.5),v=Nt.Sub(a,f),S=Nt.Add(a,f),E=[this.tmpPoints[0],a],T=[v,this.tmpPoints[1],S],P=[i,l].concat(T,[c,m]);return{trianglePoints:T.map(function(x){return Nt.Sub(x,_this75.tmpPoints[1]).XY;}).flat(1),trianglePos:this.tmpPoints[1].XY,points:E.map(function(x){return Nt.Sub(x,_this75.tmpPoints[0]).XY;}).flat(1),rect:_t(P),isTriangle:!1,pos:this.tmpPoints[0].XY};}},{key:"computTrianglePoints",value:function computTrianglePoints(){var _this76=this;var t=at.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),r=this.tmpPoints[1].distance(this.tmpPoints[0]),n=at.Per(t).mul(Math.floor(r*3/8)),i=Nt.Sub(this.tmpPoints[0],n),l=Nt.Add(this.tmpPoints[0],n),o=[i,this.tmpPoints[1],l];return{trianglePoints:o.map(function(a){return Nt.Sub(a,_this76.tmpPoints[1]).XY;}).flat(1),trianglePos:this.tmpPoints[1].XY,rect:_t(o),isTriangle:!0};}},{key:"updateTempPoints",value:function updateTempPoints(t){var r=t.slice(-2),n=new Nt(r[0],r[1]),i=this.tmpPoints[0],l=this.workOptions.thickness;if(i.isNear(n,l))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n;}else this.tmpPoints.push(n);return!0;}},{key:"consumeService",value:function consumeService(t){var c,m;var r=t.op,n=t.isFullWork,_t$workState2=t.workState,i=_t$workState2===void 0?Ft.Done:_t$workState2,l=(c=this.workId)==null?void 0:c.toString();if(!l)return;this.tmpPoints.length=0;for(var f=0;f<r.length;f+=3)this.tmpPoints.push(new Nt(r[f],r[f+1],r[f+2]));var o=n?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:l,layer:o,isDrawEraserlines:i===Ft.Done});return this.oldRect=a,(m=this.vNodes)==null||m.setInfo(l,{rect:a,op:r,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:At.getCenterPos(a,o)}),a;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var c,m;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"?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&&(m=a.opt)!=null&&m.strokeType&&(a.opt.strokeType=o),a&&i.setInfo(r.name,a),At.updateNodeOpt(t);}}]);}(At);var qi=/*#__PURE__*/function(_At6){function qi(t){var _this77;_classCallCheck(this,qi);_this77=_callSuper(this,qi,[t]);ot(_this77,"canRotate",!1);ot(_this77,"scaleType",Qt.all);ot(_this77,"toolsType",pt.Ellipse);ot(_this77,"tmpPoints",[]);ot(_this77,"workOptions");ot(_this77,"oldRect");ot(_this77,"syncTimestamp");_this77.workOptions=t.toolsOpt,_this77.syncTimestamp=0,_this77.syncUnitTime=50;return _this77;}_inherits(qi,_At6);return _createClass(qi,[{key:"consume",value:function consume(t){var r=t.data,n=t.isFullWork,i=t.isSubWorker,l=t.isMainThread,o=t.smoothSync,a=t.isSimpleWorker,c=this.workId,m=r.op,f=r.syncUnitTime;f&&(this.syncUnitTime=f);var v=m==null?void 0:m.length;if(!v||v<2)return{type:dt.None};var S;if(this.tmpPoints.length===0?(this.tmpPoints=[new Nt(m[0],m[1])],S=!1):S=this.updateTempPoints(m),!S)return{type:dt.None};var E;if(i||l||a){var T=n?this.fullLayer:this.drawLayer||this.fullLayer;E=this.draw({workId:c,layer:T,isDrawing:!0});var P=T.parent.parent,_x61={x:0,y:0,w:Math.floor(P.width),h:Math.floor(P.height)},_h34=_objectSpread({type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);if(or(E,_x61)!==Pe.outside){var d=bt(E,this.oldRect);if(this.oldRect=E,_h34.rect=d,!a)return _h34;}if(a){var _d15=Date.now();return _d15-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=_d15,_h34.op=this.tmpPoints.map(function(g){return[].concat(_toConsumableArray(g.XY),[0]);}).flat(1),_h34.index=0,_h34.isSync=!0),_h34;}return{type:dt.None};}if(!i&&!l&&!a&&o){var _T3=Date.now();return _T3-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_T3,_objectSpread(_objectSpread({type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult),{},{op:this.tmpPoints.map(function(P){return[].concat(_toConsumableArray(P.XY),[0]);}).flat(1),isSync:!0,index:0})):{type:dt.None};}return{type:dt.None};}},{key:"consumeAll",value:function consumeAll(){var o;var t=this.workId;if(this.tmpPoints.length<2)return{type:dt.RemoveNode,removeIds:[t]};var r=this.fullLayer,n=this.draw({workId:t,layer:r,isDrawing:!1});this.oldRect=n;var i=this.tmpPoints.map(function(a){return[].concat(_toConsumableArray(a.XY),[0]);}).flat(1),l=ve(i);return(o=this.vNodes)==null||o.setInfo(t,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:n&&At.getCenterPos(n,r)}),_objectSpread(_objectSpread({rect:n,type:dt.FullWork,dataType:Dt.Local},this.baseConsumeResult),{},{ops:l,isSync:!0,updateNodeOpt:{useAnimation:!0}});}},{key:"draw",value:function draw(t){var r=t.workId,n=t.layer,i=t.isDrawing,l=t.isDrawEraserlines,_this$workOptions8=this.workOptions,o=_this$workOptions8.strokeColor,a=_this$workOptions8.fillColor,c=_this$workOptions8.thickness,m=_this$workOptions8.zIndex,f=_this$workOptions8.scale,v=_this$workOptions8.rotate,S=_this$workOptions8.translate,E=_this$workOptions8.strokeType,T=_this$workOptions8.eraserlines,P=n.worldScaling,_this$computDrawPoint4=this.computDrawPoints(c),x=_this$computDrawPoint4.radius,h=_this$computDrawPoint4.rect,p=_this$computDrawPoint4.pos,d={closeType:"normal",radius:x,lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:o,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:E===Zt.Dotted?[1,c*2]:E===Zt.LongDotted?[c,c*2]:void 0},g={name:r,id:r,zIndex:m,pos:p,anchor:[0.5,0.5],size:[h.w,h.h]};f&&(g.scale=f),v&&(g.rotate=v),S&&(g.translate=S);var O=new ye(g);if(i){var B=new be({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:o,lineWidth:1,scale:[1/P[0],1/P[1]]});O.append(B);}var w=new io(_objectSpread(_objectSpread({},d),{},{pos:[0,0]}));O.append(w),T&&(this.scaleType=Qt.proportional,this.drawEraserlines({group:O,eraserlines:T,pos:p,layer:n},l)),this.replace(n,r,O);var L=O.getBoundingClientRect();return this.isDelete&&O.setAttribute("opacity",0),{x:Math.floor(L.x-At.SafeBorderPadding),y:Math.floor(L.y-At.SafeBorderPadding),w:Math.floor(L.width+At.SafeBorderPadding*2),h:Math.floor(L.height+At.SafeBorderPadding*2)};}},{key:"computDrawPoints",value:function computDrawPoints(t){var r=_t(this.tmpPoints),n=_t(this.tmpPoints,t),i=[Math.floor(r.x+r.w/2),Math.floor(r.y+r.h/2)];return{rect:n,pos:i,radius:[Math.floor(r.w/2),Math.floor(r.h/2)]};}},{key:"updateTempPoints",value:function updateTempPoints(t){var r=t.slice(-2),n=new Nt(r[0],r[1]),i=this.tmpPoints[0],l=this.workOptions.thickness;if(i.isNear(n,l))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n;}else this.tmpPoints.push(n);return!0;}},{key:"consumeService",value:function consumeService(t){var c,m;var r=t.op,n=t.isFullWork,_t$workState3=t.workState,i=_t$workState3===void 0?Ft.Done:_t$workState3,l=(c=this.workId)==null?void 0:c.toString();if(!l)return;this.tmpPoints.length=0;for(var f=0;f<r.length;f+=3)this.tmpPoints.push(new Nt(r[f],r[f+1],r[f+2]));var o=n?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:l,layer:o,isDrawing:!1,isDrawEraserlines:i===Ft.Done});return this.oldRect=a,(m=this.vNodes)==null||m.setInfo(l,{rect:a,op:r,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:At.getCenterPos(a,o)}),a;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var f,v,S;var r=t.node,n=t.opt,i=t.vNodes,l=n.strokeColor,o=n.fillColor,a=n.strokeType,c=i.get(r.name);var m=r;return r.tagName==="GROUP"&&(m=r.children[0]),l&&(m.setAttribute("strokeColor",l),(f=c==null?void 0:c.opt)!=null&&f.strokeColor&&(c.opt.strokeColor=l)),o&&(o==="transparent"?m.setAttribute("fillColor","rgba(0,0,0,0)"):m.setAttribute("fillColor",o),(v=c==null?void 0:c.opt)!=null&&v.fillColor&&(c.opt.fillColor=o)),a&&c!=null&&c.opt&&(S=c.opt)!=null&&S.strokeType&&(c.opt.strokeType=a),c&&i.setInfo(r.name,c),At.updateNodeOpt(t);}}]);}(At);var _i=/*#__PURE__*/function(_At7){function _i(t){var _this78;_classCallCheck(this,_i);_this78=_callSuper(this,_i,[t]);ot(_this78,"canRotate",!0);ot(_this78,"scaleType",Qt.all);ot(_this78,"toolsType",pt.Rectangle);ot(_this78,"tmpPoints",[]);ot(_this78,"workOptions");ot(_this78,"oldRect");ot(_this78,"syncTimestamp");_this78.workOptions=t.toolsOpt,_this78.syncTimestamp=0,_this78.syncUnitTime=50;return _this78;}_inherits(_i,_At7);return _createClass(_i,[{key:"transformData",value:function transformData(){var t=_t(this.tmpPoints);return[[t.x,t.y,0],[t.x+t.w,t.y,0],[t.x+t.w,t.y+t.h,0],[t.x,t.y+t.h,0]];}},{key:"computDrawPoints",value:function computDrawPoints(t){var r=this.workOptions.thickness,n=[];var _iterator30=_createForOfIteratorHelper(t),_step30;try{for(_iterator30.s();!(_step30=_iterator30.n()).done;){var o=_step30.value;n.push(_construct(at,_toConsumableArray(o)));}}catch(err){_iterator30.e(err);}finally{_iterator30.f();}var i=_t(n,r),l=[i.x+i.w/2,i.y+i.h/2];return{rect:i,pos:l,points:n.map(function(o){return o.XY;}).flat(1)};}},{key:"consume",value:function consume(t){var r=t.data,n=t.isFullWork,i=t.isSubWorker,l=t.isMainThread,o=t.smoothSync,a=t.isSimpleWorker,c=this.workId,m=r.op,f=m==null?void 0:m.length;if(!f||f<2)return{type:dt.None};var v;if(this.tmpPoints.length===0?(this.tmpPoints=[new Nt(m[0],m[1])],v=!1):v=this.updateTempPoints(m),!v)return{type:dt.None};var S=this.transformData();var E;if(i||l||a){var P=n?this.fullLayer:this.drawLayer||this.fullLayer;E=this.draw({ps:S,workId:c,layer:P,isDrawing:!0});}if(a){var _P10=bt(E,this.oldRect);this.oldRect=E;var _x62=_objectSpread({rect:_P10,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);if(o){var _h35=Date.now();_h35-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=_h35,_x62.op=S.flat(1),_x62.index=0,_x62.isSync=!0);}return _x62;}if(!i&&o){var _P11=Date.now();return _P11-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_P11,_objectSpread({type:dt.DrawWork,dataType:Dt.Local,op:S.flat(1),isSync:!0,index:0},this.baseConsumeResult)):{type:dt.None};}var T=bt(E,this.oldRect);return this.oldRect=E,_objectSpread({rect:T,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var a;var t=this.workId;if(this.tmpPoints.length<2)return{type:dt.RemoveNode,removeIds:[t]};var r=this.transformData(),n=this.fullLayer,i=this.draw({ps:r,workId:t,layer:n,isDrawing:!1});this.oldRect=i;var l=r.flat(1),o=ve(l);return(a=this.vNodes)==null||a.setInfo(t,{rect:i,op:l,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&At.getCenterPos(i,n)}),_objectSpread(_objectSpread({rect:i,type:dt.FullWork,dataType:Dt.Local,ops:o,isSync:!0},this.baseConsumeResult),{},{updateNodeOpt:{useAnimation:!0}});}},{key:"draw",value:function draw(t){var r=t.workId,n=t.layer,i=t.isDrawing,l=t.ps,o=t.replaceId,_t$isDrawEraserlines2=t.isDrawEraserlines,a=_t$isDrawEraserlines2===void 0?!0:_t$isDrawEraserlines2,_this$workOptions9=this.workOptions,c=_this$workOptions9.strokeColor,m=_this$workOptions9.fillColor,f=_this$workOptions9.thickness,v=_this$workOptions9.zIndex,S=_this$workOptions9.scale,E=_this$workOptions9.rotate,T=_this$workOptions9.translate,P=_this$workOptions9.strokeType,x=_this$workOptions9.eraserlines,h=n.worldPosition,p=n.worldScaling,_this$computDrawPoint5=this.computDrawPoints(l),d=_this$computDrawPoint5.points,g=_this$computDrawPoint5.rect,O=_this$computDrawPoint5.pos,w={close:!0,normalize:!0,points:d,lineWidth:f,fillColor:m!=="transparent"&&m||void 0,strokeColor:c,lineJoin:"round",lineCap:"round",lineDash:P===Zt.Dotted?[1,f*2]:P===Zt.LongDotted?[f,f*2]:void 0};var L={x:Math.floor(g.x*p[0]+h[0]-At.SafeBorderPadding),y:Math.floor(g.y*p[1]+h[1]-At.SafeBorderPadding),w:Math.floor(g.w*p[0]+2*At.SafeBorderPadding),h:Math.floor(g.h*p[0]+2*At.SafeBorderPadding)};var B=new ye({name:r,id:r,zIndex:v,pos:O,anchor:[0.5,0.5],size:[g.w,g.h],scale:S,rotate:E,translate:T}),A=new we(_objectSpread(_objectSpread({},w),{},{pos:[0,0]}));if(B.appendChild(A),i){var b=new be({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:c,lineWidth:1,scale:[1/p[0],1/p[1]]});B.appendChild(b);}if(x&&(this.scaleType=Qt.proportional,this.drawEraserlines({group:B,eraserlines:x,pos:O,layer:n},a)),this.replace(n,o||r,B),S||E||T){var _b8=B.getBoundingClientRect();L={x:Math.floor(_b8.x-At.SafeBorderPadding),y:Math.floor(_b8.y-At.SafeBorderPadding),w:Math.floor(_b8.width+2*At.SafeBorderPadding),h:Math.floor(_b8.height+2*At.SafeBorderPadding)};}return this.isDelete&&B.setAttribute("opacity",0),L;}},{key:"updateTempPoints",value:function updateTempPoints(t){var r=t.slice(-2),n=new Nt(r[0],r[1]),i=this.tmpPoints[0],l=this.workOptions.thickness;if(i.isNear(n,l))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n;}else this.tmpPoints.push(n);return!0;}},{key:"consumeService",value:function consumeService(t){var f,v;var r=t.op,n=t.isFullWork,i=t.replaceId,_t$workState4=t.workState,l=_t$workState4===void 0?Ft.Done:_t$workState4,o=(f=this.workId)==null?void 0:f.toString();if(!o)return;var a=[];for(var S=0;S<r.length;S+=3)a.push([r[S],r[S+1],r[S+2]]);var c=n?this.fullLayer:this.drawLayer||this.fullLayer,m=this.draw({ps:a,workId:o,layer:c,isDrawing:!1,replaceId:i,isDrawEraserlines:l===Ft.Done});return this.oldRect=m,(v=this.vNodes)==null||v.setInfo(o,{rect:m,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:m&&At.getCenterPos(m,c)}),m;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var f,v,S;var r=t.node,n=t.opt,i=t.vNodes,l=n.strokeColor,o=n.fillColor,a=n.strokeType,c=i.get(r.name);var m=r;return r.tagName==="GROUP"&&(m=r.children[0]),l&&(m.setAttribute("strokeColor",l),(f=c==null?void 0:c.opt)!=null&&f.strokeColor&&(c.opt.strokeColor=l)),o&&(o==="transparent"?m.setAttribute("fillColor","rgba(0,0,0,0)"):m.setAttribute("fillColor",o),(v=c==null?void 0:c.opt)!=null&&v.fillColor&&(c.opt.fillColor=o)),a&&c!=null&&c.opt&&(S=c.opt)!=null&&S.strokeType&&(c.opt.strokeType=a),c&&i.setInfo(r.name,c),At.updateNodeOpt(t);}}]);}(At);var ts=/*#__PURE__*/function(_At8){function ts(t){var _this79;_classCallCheck(this,ts);_this79=_callSuper(this,ts,[t]);ot(_this79,"canRotate",!1);ot(_this79,"scaleType",Qt.all);ot(_this79,"toolsType",pt.Star);ot(_this79,"tmpPoints",[]);ot(_this79,"workOptions");ot(_this79,"oldRect");ot(_this79,"syncTimestamp");_this79.workOptions=t.toolsOpt,_this79.syncTimestamp=0,_this79.syncUnitTime=50;return _this79;}_inherits(ts,_At8);return _createClass(ts,[{key:"consume",value:function consume(t){var r=t.data,n=t.isFullWork,i=t.isSubWorker,l=t.isMainThread,o=t.smoothSync,a=t.isSimpleWorker,c=this.workId,m=r.op,f=r.syncUnitTime,v=m==null?void 0:m.length;if(!v||v<2)return{type:dt.None};f&&(this.syncUnitTime=f);var S;if(this.tmpPoints.length===0?(this.tmpPoints=[new Nt(m[0],m[1])],S=!1):S=this.updateTempPoints(m),!S)return{type:dt.None};var E;if(i||l||a){var P=n?this.fullLayer:this.drawLayer||this.fullLayer;E=this.draw({workId:c,layer:P,isDrawing:!0});}if(a){var _P12=bt(E,this.oldRect);this.oldRect=E;var _x63=_objectSpread({rect:_P12,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);if(o){var _h36=Date.now();_h36-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=_h36,_x63.op=this.tmpPoints.map(function(p){return[].concat(_toConsumableArray(p.XY),[0]);}).flat(1),_x63.index=0,_x63.isSync=!0);}return _x63;}if(!i&&o){var _P13=Date.now();return _P13-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_P13,_objectSpread({type:dt.DrawWork,dataType:Dt.Local,op:this.tmpPoints.map(function(x){return[].concat(_toConsumableArray(x.XY),[0]);}).flat(1),isSync:!0,index:0},this.baseConsumeResult)):{type:dt.None};}var T=bt(E,this.oldRect);return this.oldRect=E,_objectSpread({rect:T,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var o;var t=this.workId;if(this.tmpPoints.length<2)return{type:dt.RemoveNode,removeIds:[t]};var r=this.fullLayer,n=this.draw({workId:t,layer:r,isDrawing:!1});this.oldRect=n;var i=this.tmpPoints.map(function(a){return[].concat(_toConsumableArray(a.XY),[0]);}).flat(1),l=ve(i);return(o=this.vNodes)==null||o.setInfo(t,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&At.getCenterPos(n,r)}),_objectSpread(_objectSpread({rect:n,type:dt.FullWork,dataType:Dt.Local,ops:l,isSync:!0},this.baseConsumeResult),{},{updateNodeOpt:{useAnimation:!0}});}},{key:"draw",value:function draw(t){var r=t.workId,n=t.layer,i=t.isDrawing,_t$isDrawEraserlines3=t.isDrawEraserlines,l=_t$isDrawEraserlines3===void 0?!0:_t$isDrawEraserlines3,_this$workOptions10=this.workOptions,o=_this$workOptions10.strokeColor,a=_this$workOptions10.fillColor,c=_this$workOptions10.thickness,m=_this$workOptions10.zIndex,f=_this$workOptions10.vertices,v=_this$workOptions10.innerVerticeStep,S=_this$workOptions10.innerRatio,E=_this$workOptions10.scale,T=_this$workOptions10.rotate,P=_this$workOptions10.translate,x=_this$workOptions10.strokeType,h=_this$workOptions10.eraserlines,p=n.worldScaling,_this$computDrawPoint6=this.computDrawPoints(c,f,v,S),d=_this$computDrawPoint6.rect,g=_this$computDrawPoint6.pos,O=_this$computDrawPoint6.points,w={close:!0,points:O,lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:o,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:x===Zt.Dotted?[1,c*2]:x===Zt.LongDotted?[c,c*2]:void 0},L={name:r,id:r,zIndex:m,pos:g,anchor:[0.5,0.5],size:[d.w,d.h]};E&&(L.scale=E),T&&(L.rotate=T),P&&(L.translate=P);var B=new ye(L);if(i){var W=new be({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:o,lineWidth:1,scale:[1/p[0],1/p[1]]});B.append(W);}var A=new we(_objectSpread(_objectSpread({},w),{},{pos:[0,0]}));B.append(A),h&&(this.scaleType=Qt.proportional,this.drawEraserlines({group:B,eraserlines:h,pos:g,layer:n},l)),this.replace(n,r,B);var b=B.getBoundingClientRect();return this.isDelete&&B.setAttribute("opacity",0),{x:Math.floor(b.x-At.SafeBorderPadding),y:Math.floor(b.y-At.SafeBorderPadding),w:Math.floor(b.width+At.SafeBorderPadding*2),h:Math.floor(b.height+At.SafeBorderPadding*2)};}},{key:"computDrawPoints",value:function computDrawPoints(t,r,n,i){var l=_t(this.tmpPoints),o=[Math.floor(l.x+l.w/2),Math.floor(l.y+l.h/2)],a=ls(l.w,l.h),c=Math.floor(Math.min(l.w,l.h)/2),m=i*c,f=[],v=2*Math.PI/r;for(var E=0;E<r;E++){var T=E*v-0.5*Math.PI;var P=void 0,_x64=void 0;E%n===1?(P=m*a[0]*Math.cos(T),_x64=m*a[1]*Math.sin(T)):(P=c*a[0]*Math.cos(T),_x64=c*a[1]*Math.sin(T),f.push(P,_x64)),f.push(P,_x64);}return{rect:_t(this.tmpPoints,t),pos:o,points:f};}},{key:"updateTempPoints",value:function updateTempPoints(t){var r=t.slice(-2),n=new Nt(r[0],r[1]),i=this.tmpPoints[0],l=this.workOptions.thickness;if(i.isNear(n,l)||Nt.Sub(i,n).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n;}else this.tmpPoints.push(n);return!0;}},{key:"consumeService",value:function consumeService(t){var c,m;var r=t.op,n=t.isFullWork,_t$workState5=t.workState,i=_t$workState5===void 0?Ft.Done:_t$workState5,l=(c=this.workId)==null?void 0:c.toString();if(!l)return;this.tmpPoints.length=0;for(var f=0;f<r.length;f+=3)this.tmpPoints.push(new Nt(r[f],r[f+1],r[f+2]));var o=n?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:l,layer:o,isDrawing:!1,isDrawEraserlines:i===Ft.Done});return this.oldRect=a,(m=this.vNodes)==null||m.setInfo(l,{rect:a,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&At.getCenterPos(a,o)}),a;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var P;var r=t.node,n=t.opt,i=t.vNodes,l=n.strokeColor,o=n.fillColor,a=n.toolsType,c=n.vertices,m=n.innerVerticeStep,f=n.innerRatio,v=n.strokeType,S=i.get(r.name),E=S==null?void 0:S.opt;var T=r;return r.tagName==="GROUP"&&(T=r.children[0]),l&&(T.setAttribute("strokeColor",l),E!=null&&E.strokeColor&&(E.strokeColor=l)),o&&(o==="transparent"?T.setAttribute("fillColor","rgba(0,0,0,0)"):T.setAttribute("fillColor",o),E!=null&&E.fillColor&&(E.fillColor=o)),a===pt.Star&&(c&&(E.vertices=c),m&&(E.innerVerticeStep=m),f&&(E.innerRatio=f)),v&&S!=null&&S.opt&&(P=S.opt)!=null&&P.strokeType&&(S.opt.strokeType=v),S&&i.setInfo(r.name,_objectSpread(_objectSpread({},S),{},{opt:E})),At.updateNodeOpt(t);}}]);}(At);var es=/*#__PURE__*/function(_At9){function es(t){var _this80;_classCallCheck(this,es);_this80=_callSuper(this,es,[t]);ot(_this80,"canRotate",!1);ot(_this80,"scaleType",Qt.all);ot(_this80,"toolsType",pt.Polygon);ot(_this80,"tmpPoints",[]);ot(_this80,"workOptions");ot(_this80,"oldRect");ot(_this80,"syncTimestamp");_this80.workOptions=t.toolsOpt,_this80.syncTimestamp=0,_this80.syncUnitTime=50;return _this80;}_inherits(es,_At9);return _createClass(es,[{key:"consume",value:function consume(t){var r=t.data,n=t.isFullWork,i=t.isSubWorker,l=t.isMainThread,o=t.smoothSync,a=t.isSimpleWorker,c=r.op,m=r.syncUnitTime;m&&(this.syncUnitTime=m);var f=this.workId,v=c==null?void 0:c.length;if(!v||v<2)return{type:dt.None};var S;if(this.tmpPoints.length===0?(this.tmpPoints=[new Nt(c[0],c[1])],S=!1):S=this.updateTempPoints(c),!S)return{type:dt.None};var E;if(i||l||a){var P=n?this.fullLayer:this.drawLayer||this.fullLayer;E=this.draw({workId:f,layer:P,isDrawing:!0});}if(a){var _P14=bt(E,this.oldRect);this.oldRect=E;var _x65=_objectSpread({type:dt.DrawWork,rect:_P14,dataType:Dt.Local},this.baseConsumeResult);if(o){var _h37=Date.now();_h37-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=_h37,_x65.op=this.tmpPoints.map(function(p){return[].concat(_toConsumableArray(p.XY),[0]);}).flat(1),_x65.index=0,_x65.isSync=!0);}return _x65;}if(!i&&o){var _P15=Date.now();return _P15-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_P15,_objectSpread({type:dt.DrawWork,dataType:Dt.Local,op:this.tmpPoints.map(function(x){return[].concat(_toConsumableArray(x.XY),[0]);}).flat(1),isSync:!0,index:0},this.baseConsumeResult)):{type:dt.None};}var T=bt(E,this.oldRect);return this.oldRect=E,_objectSpread({rect:T,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var o;var t=this.workId;if(this.tmpPoints.length<2)return{type:dt.RemoveNode,removeIds:[t]};var r=this.fullLayer,n=this.draw({workId:t,layer:r,isDrawing:!1});this.oldRect=n;var i=this.tmpPoints.map(function(a){return[].concat(_toConsumableArray(a.XY),[0]);}).flat(1),l=ve(i);return(o=this.vNodes)==null||o.setInfo(t,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&At.getCenterPos(n,r)}),_objectSpread(_objectSpread({rect:n,type:dt.FullWork,dataType:Dt.Local,ops:l,isSync:!0},this.baseConsumeResult),{},{updateNodeOpt:{useAnimation:!0}});}},{key:"draw",value:function draw(t){var r=t.workId,n=t.layer,i=t.isDrawing,_t$isDrawEraserlines4=t.isDrawEraserlines,l=_t$isDrawEraserlines4===void 0?!0:_t$isDrawEraserlines4,_this$workOptions11=this.workOptions,o=_this$workOptions11.strokeColor,a=_this$workOptions11.fillColor,c=_this$workOptions11.thickness,m=_this$workOptions11.zIndex,f=_this$workOptions11.vertices,v=_this$workOptions11.scale,S=_this$workOptions11.rotate,E=_this$workOptions11.translate,T=_this$workOptions11.strokeType,P=_this$workOptions11.eraserlines,x=n.worldScaling,_this$computDrawPoint7=this.computDrawPoints(c,f),h=_this$computDrawPoint7.rect,p=_this$computDrawPoint7.pos,d=_this$computDrawPoint7.points,g={close:!0,points:d,lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:o,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:T===Zt.Dotted?[1,c*2]:T===Zt.LongDotted?[c,c*2]:void 0},O={name:r,id:r,zIndex:m,pos:p,anchor:[0.5,0.5],size:[h.w,h.h]};v&&(O.scale=v),S&&(O.rotate=S),E&&(O.translate=E);var w=new ye(O);if(i){var A=new be({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:o,lineWidth:1,scale:[1/x[0],1/x[1]]});w.append(A);}var L=new we(_objectSpread(_objectSpread({},g),{},{pos:[0,0]}));w.append(L),P&&(this.scaleType=Qt.proportional,this.drawEraserlines({group:w,eraserlines:P,pos:p,layer:n},l)),this.replace(n,r,w);var B=w.getBoundingClientRect();return this.isDelete&&w.setAttribute("opacity",0),{x:Math.floor(B.x-At.SafeBorderPadding),y:Math.floor(B.y-At.SafeBorderPadding),w:Math.floor(B.width+At.SafeBorderPadding*2),h:Math.floor(B.height+At.SafeBorderPadding*2)};}},{key:"computDrawPoints",value:function computDrawPoints(t,r){var n=_t(this.tmpPoints),i=[Math.floor(n.x+n.w/2),Math.floor(n.y+n.h/2)],l=ls(n.w,n.h),o=Math.floor(Math.min(n.w,n.h)/2),a=[],c=2*Math.PI/r;for(var f=0;f<r;f++){var v=f*c-0.5*Math.PI,S=o*l[0]*Math.cos(v),E=o*l[1]*Math.sin(v);a.push(S,E);}return{rect:_t(this.tmpPoints,t),pos:i,points:a};}},{key:"updateTempPoints",value:function updateTempPoints(t){var r=t.slice(-2),n=new Nt(r[0],r[1]),i=this.tmpPoints[0],l=this.workOptions.thickness;if(i.isNear(n,l)||Nt.Sub(i,n).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n;}else this.tmpPoints.push(n);return!0;}},{key:"consumeService",value:function consumeService(t){var c,m;var r=t.op,n=t.isFullWork,_t$workState6=t.workState,i=_t$workState6===void 0?Ft.Done:_t$workState6,l=(c=this.workId)==null?void 0:c.toString();if(!l)return;this.tmpPoints.length=0;for(var f=0;f<r.length;f+=3)this.tmpPoints.push(new Nt(r[f],r[f+1],r[f+2]));var o=n?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:l,layer:o,isDrawing:!1,isDrawEraserlines:i===Ft.Done});return this.oldRect=a,(m=this.vNodes)==null||m.setInfo(l,{rect:a,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&At.getCenterPos(a,o)}),a;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var E;var r=t.node,n=t.opt,i=t.vNodes,l=n.strokeColor,o=n.fillColor,a=n.toolsType,c=n.vertices,m=n.strokeType,f=i.get(r.name),v=f==null?void 0:f.opt;var S=r;return r.tagName==="GROUP"&&(S=r.children[0]),l&&(S.setAttribute("strokeColor",l),v!=null&&v.strokeColor&&(v.strokeColor=l)),o&&(o==="transparent"?S.setAttribute("fillColor","rgba(0,0,0,0)"):S.setAttribute("fillColor",o),v!=null&&v.fillColor&&(v.fillColor=o)),a===pt.Polygon&&c&&(v.vertices=c),m&&f!=null&&f.opt&&(E=f.opt)!=null&&E.strokeType&&(f.opt.strokeType=m),f&&i.setInfo(r.name,_objectSpread(_objectSpread({},f),{},{opt:v})),At.updateNodeOpt(t);}}]);}(At);var Ce=/*#__PURE__*/function(){function Ce(){_classCallCheck(this,Ce);}return _createClass(Ce,null,[{key:"bezier",value:function bezier(e,t){var r=[];for(var n=0;n<t.length;n+=4){var i=t[n],l=t[n+1],o=t[n+2],a=t[n+3];i&&l&&o&&a?r.push.apply(r,_toConsumableArray(Ce.getBezierPoints(e,i,l,o,a))):i&&l&&o?r.push.apply(r,_toConsumableArray(Ce.getBezierPoints(e,i,l,o))):i&&l?r.push.apply(r,_toConsumableArray(Ce.getBezierPoints(e,i,l))):i&&r.push(i);}return r;}/**
408
+ ot(Ve,"eraserSizes",fn);var Ir=Ve;var i0="__lodash_hash_undefined__";function s0(u){return this.__data__.set(u,i0),this;}var o0=s0;function a0(u){return this.__data__.has(u);}var l0=a0,c0=Pi,f0=o0,h0=l0;function Or(u){var e=-1,t=u==null?0:u.length;for(this.__data__=new c0();++e<t;)this.add(u[e]);}Or.prototype.add=Or.prototype.push=f0;Or.prototype.has=h0;var dn=Or;function u0(u,e){for(var t=-1,r=u==null?0:u.length;++t<r;)if(e(u[t],t,u))return!0;return!1;}var d0=u0;function p0(u,e){return u.has(e);}var pn=p0,m0=dn,v0=d0,y0=pn,g0=1,P0=2;function S0(u,e,t,r,n,i){var l=t&g0,o=u.length,a=e.length;if(o!=a&&!(l&&a>o))return!1;var c=i.get(u),m=i.get(e);if(c&&m)return c==e&&m==u;var f=-1,v=!0,S=t&P0?new m0():void 0;for(i.set(u,e),i.set(e,u);++f<o;){var E=u[f],T=e[f];if(r)var P=l?r(T,E,f,e,u,i):r(E,T,f,u,e,i);if(P!==void 0){if(P)continue;v=!1;break;}if(S){if(!v0(e,function(x,h){if(!y0(S,h)&&(E===x||n(E,x,t,r,i)))return S.push(h);})){v=!1;break;}}else if(!(E===T||n(E,T,t,r,i))){v=!1;break;}}return i["delete"](u),i["delete"](e),v;}var Zi=S0;function x0(u){var e=-1,t=Array(u.size);return u.forEach(function(r,n){t[++e]=[n,r];}),t;}var T0=x0;function C0(u){var e=-1,t=Array(u.size);return u.forEach(function(r){t[++e]=r;}),t;}var mn=C0,Vn=ur,Kn=Ui,I0=qr,O0=Zi,E0=T0,M0=mn,A0=1,w0=2,L0="[object Boolean]",R0="[object Date]",D0="[object Error]",b0="[object Map]",N0="[object Number]",B0="[object RegExp]",W0="[object Set]",F0="[object String]",U0="[object Symbol]",j0="[object ArrayBuffer]",Y0="[object DataView]",Zn=Vn?Vn.prototype:void 0,Yr=Zn?Zn.valueOf:void 0;function X0(u,e,t,r,n,i,l){switch(t){case Y0:if(u.byteLength!=e.byteLength||u.byteOffset!=e.byteOffset)return!1;u=u.buffer,e=e.buffer;case j0:return!(u.byteLength!=e.byteLength||!i(new Kn(u),new Kn(e)));case L0:case R0:case N0:return I0(+u,+e);case D0:return u.name==e.name&&u.message==e.message;case B0:case F0:return u==e+"";case b0:var o=E0;case W0:var a=r&A0;if(o||(o=M0),u.size!=e.size&&!a)return!1;var c=l.get(u);if(c)return c==e;r|=w0,l.set(u,e);var m=O0(o(u),o(e),r,n,i,l);return l["delete"](u),m;case U0:if(Yr)return Yr.call(u)==Yr.call(e);}return!1;}var z0=X0,Jn=Bi,$0=1,G0=Object.prototype,k0=G0.hasOwnProperty;function H0(u,e,t,r,n,i){var l=t&$0,o=Jn(u),a=o.length,c=Jn(e),m=c.length;if(a!=m&&!l)return!1;for(var f=a;f--;){var v=o[f];if(!(l?v in e:k0.call(e,v)))return!1;}var S=i.get(u),E=i.get(e);if(S&&E)return S==e&&E==u;var T=!0;i.set(u,e),i.set(e,u);for(var P=l;++f<a;){v=o[f];var x=u[v],h=e[v];if(r)var p=l?r(h,x,v,e,u,i):r(x,h,v,u,e,i);if(!(p===void 0?x===h||n(x,h,t,r,i):p)){T=!1;break;}P||(P=v=="constructor");}if(T&&!P){var d=u.constructor,g=e.constructor;d!=g&&"constructor"in u&&"constructor"in e&&!(typeof d=="function"&&d instanceof d&&typeof g=="function"&&g instanceof g)&&(T=!1);}return i["delete"](u),i["delete"](e),T;}var V0=H0,Xr=Si,K0=Zi,Z0=z0,J0=V0,Qn=Fr,qn=pr,_n=tn,Q0=Mi,q0=1,ti="[object Arguments]",ei="[object Array]",gr="[object Object]",_0=Object.prototype,ri=_0.hasOwnProperty;function tm(u,e,t,r,n,i){var l=qn(u),o=qn(e),a=l?ei:Qn(u),c=o?ei:Qn(e);a=a==ti?gr:a,c=c==ti?gr:c;var m=a==gr,f=c==gr,v=a==c;if(v&&_n(u)){if(!_n(e))return!1;l=!0,m=!1;}if(v&&!m)return i||(i=new Xr()),l||Q0(u)?K0(u,e,t,r,n,i):Z0(u,e,a,t,r,n,i);if(!(t&q0)){var S=m&&ri.call(u,"__wrapped__"),E=f&&ri.call(e,"__wrapped__");if(S||E){var T=S?u.value():u,P=E?e.value():e;return i||(i=new Xr()),n(T,P,t,r,i);}}return v?(i||(i=new Xr()),J0(u,e,t,r,n,i)):!1;}var em=tm,rm=em,ni=Le;function Ji(u,e,t,r,n){return u===e?!0:u==null||e==null||!ni(u)&&!ni(e)?u!==u&&e!==e:rm(u,e,t,r,Ji,n);}var nm=Ji,im=nm;function sm(u,e){return im(u,e);}var om=sm,Me=/* @__PURE__ */Ne(om);function ii(u,e,t){var r=arguments.length>3&&arguments[3]!==undefined?arguments[3]:1;return"rgba(".concat(u,",").concat(e,",").concat(t,",").concat(r,")");}function am(u){var e=u.split(","),t=parseInt(e[0].split("(")[1]),r=parseInt(e[1]),n=parseInt(e[2]),i=Number(e[3].split(")")[0]);return[t,r,n,i];}var Lr=/*#__PURE__*/function(_At4){function Lr(t){var _this70;_classCallCheck(this,Lr);_this70=_callSuper(this,Lr,[t]);ot(_this70,"toolsType",pt.Selector);ot(_this70,"tmpPoints",[]);ot(_this70,"subTmpPoints",[]);ot(_this70,"workOptions");ot(_this70,"vNodes");ot(_this70,"selectIds");ot(_this70,"selectorColor");ot(_this70,"strokeColor");ot(_this70,"fillColor");ot(_this70,"oldSelectRect");ot(_this70,"oldSubSelectRect");ot(_this70,"canRotate",!1);ot(_this70,"canTextEdit",!1);ot(_this70,"canLock",!1);ot(_this70,"scaleType",Qt.all);ot(_this70,"toolsTypes");ot(_this70,"shapeOpt");ot(_this70,"textOpt");ot(_this70,"isLocked");ot(_this70,"thickness");ot(_this70,"strokeType");ot(_this70,"useStroke");_this70.workOptions=t.toolsOpt,_this70.vNodes=t.vNodes;return _this70;}_inherits(Lr,_At4);return _createClass(Lr,[{key:"computSelector",value:function computSelector(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:!0;var r=_t(this.tmpPoints);if(r.w===0||r.h===0)return{selectIds:[],intersectRect:void 0,subNodeMap:/* @__PURE__ */new Map()};var _this$vNodes$getRectI=this.vNodes.getRectIntersectRange(r,t),n=_this$vNodes$getRectI.rectRange,i=_this$vNodes$getRectI.nodeRange;return{selectIds:_toConsumableArray(i.keys()),intersectRect:n,subNodeMap:i};}},{key:"updateTempPoints",value:function updateTempPoints(t){var r=this.tmpPoints.length,n=t.length;if(n>1){var i=new Nt(t[n-2]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],t[n-1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]);r===2?this.tmpPoints.splice(1,1,i):this.tmpPoints.push(i);}}},{key:"drawSelector",value:function drawSelector(t){var _this71=this;var r=t.drawRect,n=t.subNodeMap,i=t.selectorId,l=t.layer,o=t.isService,a=new ye({pos:[r.x,r.y],anchor:[0,0],size:[r.w,r.h],id:i,name:i,zIndex:9999}),c=[];if(o){var m=new Sn({normalize:!0,pos:[r.w/2,r.h/2],lineWidth:1,strokeColor:this.selectorColor||this.workOptions.strokeColor,width:r.w,height:r.h,name:Lr.selectorBorderId});c.push(m);}n.forEach(function(m,f){var v=[m.rect.x+m.rect.w/2-r.x,m.rect.y+m.rect.h/2-r.y],S=new Sn({normalize:!0,pos:v,lineWidth:1,strokeColor:n.size>1?_this71.selectorColor||_this71.workOptions.strokeColor:void 0,width:m.rect.w,height:m.rect.h,id:"selector-".concat(f),name:"selector-".concat(f)});c.push(S);}),c&&a.append.apply(a,c),(l==null?void 0:l.parent).appendChild(a);}},{key:"draw",value:function draw(t,r,n){var i=arguments.length>3&&arguments[3]!==undefined?arguments[3]:!1;var a,c;var l=n.intersectRect,o=n.subNodeMap;(c=(a=r.parent)==null?void 0:a.getElementById(t))==null||c.remove(),l&&this.drawSelector({drawRect:l,subNodeMap:o,selectorId:t,layer:r,isService:i});}},{key:"getSelecteorInfo",value:function getSelecteorInfo(t){this.scaleType=Qt.all,this.canRotate=!1,this.textOpt=void 0,this.strokeColor=void 0,this.fillColor=void 0,this.canTextEdit=!1,this.canLock=!1,this.isLocked=!1,this.toolsTypes=void 0,this.shapeOpt=void 0,this.thickness=void 0,this.strokeType=void 0,this.useStroke=!1;var r=/* @__PURE__ */new Set();var n,i=!0;var _iterator23=_createForOfIteratorHelper(t.values()),_step23;try{for(_iterator23.s();!(_step23=_iterator23.n()).done;){var l=_step23.value;var o=l.opt,a=l.canRotate,c=l.scaleType,m=l.toolsType;this.selectorColor=this.workOptions.strokeColor,o.strokeColor&&(this.strokeColor=o.strokeColor),o.fillColor&&(this.fillColor=o.fillColor),o.textOpt&&(this.textOpt=o.textOpt),o.thickness&&(this.thickness=o.thickness),m!==pt.Pencil&&(i=!1),o.strokeType&&(this.strokeType=o.strokeType),m===pt.SpeechBalloon&&(r.add(m),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.placement=o.placement),m===pt.Polygon&&(r.add(m),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=o.vertices),m===pt.Star&&(r.add(m),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=o.vertices,this.shapeOpt.innerRatio=o.innerRatio,this.shapeOpt.innerVerticeStep=o.innerVerticeStep),m===pt.Text&&(this.textOpt=o),t.size===1&&(this.textOpt&&(this.canTextEdit=!0),this.canRotate=a,this.scaleType=c),m===pt.Image&&(n=l),(c===Qt.proportional&&this.scaleType!==Qt.none||c===Qt.none)&&(this.scaleType=c);}}catch(err){_iterator23.e(err);}finally{_iterator23.f();}i&&(this.useStroke=!0),r.size&&(this.toolsTypes=_toConsumableArray(r)),n&&(t.size===1?(this.canLock=!0,n.opt.locked&&(this.isLocked=!0,this.scaleType=Qt.none,this.canRotate=!1,this.textOpt=void 0,this.fillColor=void 0,this.selectorColor="rgb(177,177,177)",this.strokeColor=void 0,this.canTextEdit=!1,this.thickness=void 0,this.strokeType=void 0,this.useStroke=void 0)):t.size>1&&!n.opt.locked&&(this.canLock=!1,this.canRotate=!1));}},{key:"getChildrenPoints",value:function getChildrenPoints(){var t,r;if(this.scaleType===Qt.both&&((t=this.selectIds)==null?void 0:t.length)===1){var n=this.selectIds[0],i=(r=this.vNodes.get(n))==null?void 0:r.op;if(i){var l=[];for(var o=0;o<i.length;o+=3)l.push([i[o],i[o+1]]);return l;}}}},{key:"consume",value:function consume(t){if(t.isSubWorker)return this.subWorkerConsume(t);var r=_objectSpread({type:dt.Select,dataType:Dt.Local},this.baseConsumeResult);if(t.isSimpleWorker){var m=this.subWorkerConsume(t);r.subRect=m.rect;}var _t$data3=t.data,n=_t$data3.op,i=_t$data3.workState;var l=this.oldSelectRect;if(i===Ft.Start&&(l=this.unSelectedAllIds()),!(n!=null&&n.length)||!this.vNodes.curNodeMap.size)return t.isSimpleWorker?r:{type:dt.None};this.updateTempPoints(n);var o=this.computSelector();if(this.selectIds&&Me(this.selectIds,o.selectIds))return t.isSimpleWorker?r:{type:dt.None};this.selectIds=o.selectIds;var a=o.intersectRect;this.getSelecteorInfo(o.subNodeMap),this.draw(qt,this.fullLayer,o),this.oldSelectRect=a;var c=this.getChildrenPoints();return r=_objectSpread(_objectSpread({},r),{},{rect:bt(a,l),selectIds:o.selectIds,selectRect:a,selectorColor:this.selectorColor,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:c,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType}),r;}},{key:"consumeAll",value:function consumeAll(){var r,n;var t=this.oldSelectRect;if(!((r=this.selectIds)!=null&&r.length)&&this.tmpPoints[0]&&this.selectSingleTool(this.tmpPoints[0].XY,qt,!1),(n=this.selectIds)!=null&&n.length&&(t=this.selectedByIds(this.selectIds)),t){var i=this.getChildrenPoints();return _objectSpread({type:dt.Select,dataType:Dt.Local,rect:this.oldSelectRect,selectIds:this.selectIds,selectorColor:this.selectorColor,selectRect:this.oldSelectRect,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:i,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType},this.baseConsumeResult);}return{type:dt.None};}},{key:"consumeService",value:function consumeService(){}},{key:"updateTempPointsForSubWorker",value:function updateTempPointsForSubWorker(t){var r=t.slice(-2),n=new Nt(r[0],r[1]);if(this.subTmpPoints[0].isNear(n,1))return!1;if(this.subTmpPoints.length===2){if(n.isNear(this.subTmpPoints[1],1))return!1;this.subTmpPoints[1]=n;}else this.subTmpPoints.push(n);return!0;}},{key:"computDrawPoints",value:function computDrawPoints(t){var r=this.workOptions.thickness,n=[];var _iterator24=_createForOfIteratorHelper(t),_step24;try{for(_iterator24.s();!(_step24=_iterator24.n()).done;){var o=_step24.value;n.push(_construct(at,_toConsumableArray(o)));}}catch(err){_iterator24.e(err);}finally{_iterator24.f();}var i=_t(n,r),l=[i.x+i.w/2,i.y+i.h/2];return{rect:i,pos:l,points:n.map(function(o){return o.XY;}).flat(1)};}},{key:"drawForSubWorker",value:function drawForSubWorker(t){var r=t.workId,n=t.layer,i=t.ps,_this$workOptions6=this.workOptions,l=_this$workOptions6.strokeColor,o=_this$workOptions6.scale,a=_this$workOptions6.rotate,c=_this$workOptions6.translate,m=n.worldPosition,f=n.worldScaling,_this$computDrawPoint2=this.computDrawPoints(i),v=_this$computDrawPoint2.points,S=_this$computDrawPoint2.rect,E=_this$computDrawPoint2.pos,T=1/n.worldScaling[0],P=l&&am(l)||[0,0,0,0],x={close:!0,normalize:!0,points:v,lineWidth:T,fillColor:ii(P[0],P[1],P[2],0.1),strokeColor:ii(P[0],P[1],P[2],1),lineJoin:"round",lineCap:"round"};var h={x:Math.floor(S.x*f[0]+m[0]-At.SafeBorderPadding),y:Math.floor(S.y*f[1]+m[1]-At.SafeBorderPadding),w:Math.floor(S.w*f[0]+2*At.SafeBorderPadding),h:Math.floor(S.h*f[0]+2*At.SafeBorderPadding)};var p=new ye({name:r,id:r,pos:E,anchor:[0.5,0.5],size:[S.w,S.h],scale:o,rotate:a,translate:c}),d=new we(_objectSpread(_objectSpread({},x),{},{pos:[0,0]}));if(p.appendChild(d),this.replace(n,r,p),o||a||c){var g=p.getBoundingClientRect();h={x:Math.floor(g.x-At.SafeBorderPadding),y:Math.floor(g.y-At.SafeBorderPadding),w:Math.floor(g.width+2*At.SafeBorderPadding),h:Math.floor(g.height+2*At.SafeBorderPadding)};}return h;}},{key:"transformData",value:function transformData(t){var r=_t(t);return[[r.x,r.y,0],[r.x+r.w,r.y,0],[r.x+r.w,r.y+r.h,0],[r.x,r.y+r.h,0]];}},{key:"subWorkerConsume",value:function subWorkerConsume(t){var r=t.data,n=t.isFullWork,i=r.op,l=r.syncUnitTime;l&&(this.syncUnitTime=l);var o=i==null?void 0:i.length;if(!o||o<2)return{type:dt.None,rect:void 0};var a;if(this.subTmpPoints.length===0?(this.subTmpPoints=[new Nt(i[0],i[1])],a=!1):a=this.updateTempPointsForSubWorker(i),!a)return{type:dt.None,rect:void 0};var c=this.transformData(this.subTmpPoints),m=n?this.fullLayer:this.drawLayer||this.fullLayer,f=this.drawForSubWorker({ps:c,workId:this.workId,layer:m}),v=bt(f,this.oldSubSelectRect);return this.oldSubSelectRect=f,_objectSpread({rect:v,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);}},{key:"subWorkerConsumeAll",value:function subWorkerConsumeAll(t){var r=t.isFullWork,n=r?this.fullLayer:this.drawLayer||this.fullLayer;return this.replace(n,this.workId),_objectSpread({rect:this.oldSelectRect,type:dt.FullWork,dataType:Dt.Local},this.baseConsumeResult);}},{key:"clearSubTmpPoints",value:function clearSubTmpPoints(){this.subTmpPoints.length=0;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0,this.clearSubTmpPoints();}},{key:"clearSubSelectData",value:function clearSubSelectData(){this.oldSubSelectRect=void 0;}},{key:"clearSelectData",value:function clearSelectData(){this.selectIds=void 0,this.oldSelectRect=void 0,this.clearSubSelectData();}},{key:"selectSingleTool",value:function selectSingleTool(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:qt;var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!1;if(t.length===2){var i=t[0],l=t[1];var o;var _this$vNodes$getRectI2=this.vNodes.getRectIntersectRange({x:i,y:l,w:0,h:0},!1),a=_this$vNodes$getRectI2.nodeRange,c=_toConsumableArray(a.values()).sort(function(m,f){return(f.opt.zIndex||0)-(m.opt.zIndex||0);});var _iterator25=_createForOfIteratorHelper(c),_step25;try{for(_iterator25.s();!(_step25=_iterator25.n()).done;){var _m11=_step25.value;var _f5=this.fullLayer.getElementsByName(_m11.name);if(ss(_f5).find(function(S){return S.isPointCollision(i,l);})){o=_m11;break;}}}catch(err){_iterator25.e(err);}finally{_iterator25.f();}if(o){var m=o.name;if(!Me(this.oldSelectRect,o.rect)){var f=/* @__PURE__ */new Map([[m,o]]);this.getSelecteorInfo(f),this.draw(r,this.fullLayer,{intersectRect:o.rect,subNodeMap:f,selectIds:this.selectIds||[]},n);}this.selectIds=[m],this.oldSelectRect=o.rect;}}}},{key:"unSelectedAllIds",value:function unSelectedAllIds(){var t;var _iterator26=_createForOfIteratorHelper(this.vNodes.curNodeMap.entries()),_step26;try{for(_iterator26.s();!(_step26=_iterator26.n()).done;){var _step26$value=_slicedToArray(_step26.value,2),r=_step26$value[0],n=_step26$value[1];n.isSelected&&(t=bt(t,n.rect),this.vNodes.unSelected(r));}}catch(err){_iterator26.e(err);}finally{_iterator26.f();}return t;}},{key:"unSelectedByIds",value:function unSelectedByIds(t){var r;var _iterator27=_createForOfIteratorHelper(t),_step27;try{for(_iterator27.s();!(_step27=_iterator27.n()).done;){var n=_step27.value;var i=this.vNodes.get(n);i&&i.isSelected&&(r=bt(r,i.rect),this.vNodes.unSelected(n));}}catch(err){_iterator27.e(err);}finally{_iterator27.f();}return r;}},{key:"selectedByIds",value:function selectedByIds(t){var r;var _iterator28=_createForOfIteratorHelper(t),_step28;try{for(_iterator28.s();!(_step28=_iterator28.n()).done;){var n=_step28.value;var i=this.vNodes.get(n);i&&(r=bt(r,i.rect),this.vNodes.selected(n));}}catch(err){_iterator28.e(err);}finally{_iterator28.f();}return r;}},{key:"getSelectorRect",value:function getSelectorRect(t,r){var o;var n;var i=(o=t.parent)==null?void 0:o.getElementById(r),l=i==null?void 0:i.getBoundingClientRect();return l&&(n=bt(n,{x:Math.floor(l.x),y:Math.floor(l.y),w:Math.floor(l.width+1),h:Math.floor(l.height+1)})),n;}},{key:"isCanFillColor",value:function isCanFillColor(t){return t===pt.Ellipse||t===pt.Triangle||t===pt.Rectangle||t===pt.Polygon||t===pt.Star||t===pt.SpeechBalloon;}},{key:"updateSelector",value:function(){var _updateSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22(t){var r,n,i,l,o,a,c,m,f,v,S,E,T,P,x,h,_iterator29,_step29,g,O,w,L,B,A,b,W,D,R,X,p,_g12,_O8,_w6,d;return _regeneratorRuntime().wrap(function _callee22$(_context24){while(1)switch(_context24.prev=_context24.next){case 0:r=t.updateSelectorOpt,n=t.selectIds,i=t.vNodes,l=t.willSerializeData,o=t.worker,a=t.offset,c=this.fullLayer;if(c){_context24.next=3;break;}return _context24.abrupt("return");case 3:f=/* @__PURE__ */new Map(),v=r.originPoint,S=r.workState,E=r.angle,T=r.translate,P=r.dir,x=r.scale;a&&(T?r.translate=[T[0]+a[0],T[1]+a[1]]:r.translate=a);if(!(v||T||he(E))){_context24.next=10;break;}if(!(S===Ft.Start&&n)){_context24.next=8;break;}return _context24.abrupt("return",(i.setTargetAssignKeys(n),{type:dt.Select,dataType:Dt.Local,selectRect:this.oldSelectRect,rect:this.oldSelectRect}));case 8:if(!(h=i.getLastTarget(),!h)){_context24.next=10;break;}return _context24.abrupt("return");case 10:if(!n){_context24.next=62;break;}_iterator29=_createForOfIteratorHelper(n);_context24.prev=12;_iterator29.s();case 14:if((_step29=_iterator29.n()).done){_context24.next=54;break;}g=_step29.value;O=i.get(g);if(!O){_context24.next=52;break;}w=O.toolsType,L=O.opt,B=(c==null?void 0:c.getElementsByName(g))[0];if(!B){_context24.next=52;break;}A=_objectSpread({},r);b=void 0;W=At.isWillRefresh({toolsType:w,opt:L,updateOpt:A,vNodes:i,node:B,willSerializeData:l});if(!w){_context24.next=52;break;}b=h==null?void 0:h.get(g);D=is(w);if(!(D==null||D.updateNodeOpt({node:B,opt:A,vNodes:i,willSerializeData:l,targetNode:b}),O&&o&&W)){_context24.next=51;break;}R=o.createWorkShapeNode({workId:g,toolsType:w,toolsOpt:O.opt});R==null||R.setWorkId(g);X=void 0;if(!(w===pt.Image)){_context24.next=36;break;}_context24.next=33;return R.consumeServiceAsync({isFullWork:!0,replaceId:g,worker:o});case 33:X=_context24.sent;_context24.next=50;break;case 36:if(!(w===pt.Text)){_context24.next=42;break;}_context24.next=39;return R.consumeServiceAsync({isFullWork:!0,replaceId:g});case 39:X=_context24.sent;_context24.next=50;break;case 42:_context24.prev=42;X=R==null?void 0:R.consumeService({op:O.op,isFullWork:!0,replaceId:g,workState:S});_context24.next=50;break;case 46:_context24.prev=46;_context24.t0=_context24["catch"](42);console.error("consumeService error",_context24.t0);return _context24.abrupt("continue",52);case 50:X&&(O.rect=X);case 51:O&&(f.set(g,O),m=bt(m,O.rect));case 52:_context24.next=14;break;case 54:_context24.next=59;break;case 56:_context24.prev=56;_context24.t1=_context24["catch"](12);_iterator29.e(_context24.t1);case 59:_context24.prev=59;_iterator29.f();return _context24.finish(59);case 62:h&&S===Ft.Done&&(i.deleteLastTarget(),h=void 0);p=m;if(!(v&&T&&x&&P&&p&&!a)){_context24.next=82;break;}_g12=[[p.x,p.y],[p.x+p.w,p.y],[p.x+p.w,p.y+p.h],[p.x,p.y+p.h]];_context24.t2=P;_context24.next=_context24.t2==="top"?69:_context24.t2==="topLeft"?69:_context24.t2==="left"?69:_context24.t2==="topRight"?71:_context24.t2==="right"?73:_context24.t2==="bottomRight"?73:_context24.t2==="bottom"?73:_context24.t2==="bottomLeft"?75:77;break;case 69:T[0]>0&&T[1]>0?_O8=_g12[0]:T[0]>0?_O8=_g12[3]:T[1]>0?_O8=_g12[1]:_O8=_g12[2];return _context24.abrupt("break",77);case 71:T[0]<0&&T[1]>0?_O8=_g12[1]:T[0]<0?_O8=_g12[2]:T[1]>0?_O8=_g12[0]:_O8=_g12[3];return _context24.abrupt("break",77);case 73:T[0]<0&&T[1]<0?_O8=_g12[2]:T[0]<0?_O8=_g12[1]:T[1]<0?_O8=_g12[3]:_O8=_g12[0];return _context24.abrupt("break",77);case 75:T[0]>0&&T[1]<0?_O8=_g12[3]:T[0]>0?_O8=_g12[0]:T[1]<0?_O8=_g12[2]:_O8=_g12[1];return _context24.abrupt("break",77);case 77:_w6=_O8&&[v[0]-_O8[0],v[1]-_O8[1]]||[0,0];if(Me(_w6,[0,0])){_context24.next=82;break;}_context24.next=81;return this.updateSelector(_objectSpread(_objectSpread({},t),{},{updateSelectorOpt:{workState:S},offset:_w6}));case 81:return _context24.abrupt("return",_context24.sent);case 82:this.getSelecteorInfo(f),this.draw(qt,c,{selectIds:n||[],subNodeMap:f,intersectRect:p});d=bt(this.oldSelectRect,p);return _context24.abrupt("return",(this.oldSelectRect=p,{type:dt.Select,dataType:Dt.Local,selectRect:p,renderRect:m,rect:bt(d,p),selectIds:n}));case 85:case"end":return _context24.stop();}},_callee22,this,[[12,56,59,62],[42,46]]);}));function updateSelector(_x59){return _updateSelector.apply(this,arguments);}return updateSelector;}()},{key:"blurSelector",value:function blurSelector(){var t=this.unSelectedAllIds();return{type:dt.Select,dataType:Dt.Local,rect:t,selectIds:[],willSyncService:!0};}},{key:"getRightServiceId",value:function getRightServiceId(t){return t.replace(Je,"-");}},{key:"selectServiceNode",value:function selectServiceNode(t,r,n){var _this72=this;var i=r.selectIds,l=this.getRightServiceId(t),o=this.getSelectorRect(this.fullLayer,l);var a;var c=/* @__PURE__ */new Map();return i==null||i.forEach(function(m){var f=_this72.vNodes.get(m);f&&(a=bt(a,f.rect),c.set(m,f));}),this.getSelecteorInfo(c),this.draw(l,this.fullLayer,{intersectRect:a,selectIds:i||[],subNodeMap:c},n),bt(a,o);}},{key:"reRenderSelector",value:function reRenderSelector(){var _this73=this;var n;var t;var r=/* @__PURE__ */new Map();return(n=this.selectIds)==null||n.forEach(function(i){var l=_this73.vNodes.get(i);l&&(t=bt(t,l.rect),r.set(i,l));},this),this.getSelecteorInfo(r),this.draw(qt,this.fullLayer,{intersectRect:t,subNodeMap:r,selectIds:this.selectIds||[]}),this.oldSelectRect=t,t;}},{key:"updateSelectIds",value:function updateSelectIds(t){var l;var r;var n=(l=this.selectIds)==null?void 0:l.filter(function(o){return!t.includes(o);});if(n!=null&&n.length&&(r=this.unSelectedByIds(n)),t.length){var o=this.selectedByIds(t);r=bt(r,o);}this.selectIds=t;var i=this.reRenderSelector();return{bgRect:r,selectRect:i};}},{key:"cursorHover",value:function cursorHover(t){var l,o;var r=this.oldSelectRect;this.selectIds=[];var n=(l=this.workId)==null?void 0:l.toString(),i=[t[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],t[1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]];if(this.selectSingleTool(i,n,!0),this.oldSelectRect&&!Me(r,this.oldSelectRect))return{type:dt.CursorHover,dataType:Dt.Local,rect:bt(r,this.oldSelectRect),selectorColor:this.selectorColor,willSyncService:!1};if((o=this.selectIds)!=null&&o.length||(this.oldSelectRect=void 0),r&&!this.oldSelectRect)return this.cursorBlur(),{type:dt.CursorHover,dataType:Dt.Local,rect:r,selectorColor:this.selectorColor,willSyncService:!1};}},{key:"cursorBlur",value:function cursorBlur(){var r,n;this.selectIds=[];var t=(r=this.workId)==null?void 0:r.toString();((n=this.fullLayer)==null?void 0:n.parent).children.forEach(function(i){i.name===t&&i.remove();});}}]);}(At);ot(Lr,"selectorBorderId","selector-border");var ar=Lr;var Qi=/*#__PURE__*/function(_At5){function Qi(t){var _this74;_classCallCheck(this,Qi);_this74=_callSuper(this,Qi,[t]);ot(_this74,"canRotate",!1);ot(_this74,"scaleType",Qt.both);ot(_this74,"toolsType",pt.Arrow);ot(_this74,"tmpPoints",[]);ot(_this74,"workOptions");ot(_this74,"oldRect");ot(_this74,"arrowTipWidth");ot(_this74,"syncTimestamp");_this74.workOptions=t.toolsOpt,_this74.arrowTipWidth=_this74.workOptions.thickness*4,_this74.syncTimestamp=0,_this74.syncUnitTime=50;return _this74;}_inherits(Qi,_At5);return _createClass(Qi,[{key:"consume",value:function consume(t){var r=t.data,n=t.isFullWork,i=t.isSubWorker,l=t.isMainThread,o=t.smoothSync,a=t.isSimpleWorker,c=this.workId,m=r.op,f=r.syncUnitTime;f&&(this.syncUnitTime=f);var v=m==null?void 0:m.length;if(!v||v<2)return{type:dt.None};var S;if(this.tmpPoints.length===0?(this.tmpPoints=[new Nt(m[0],m[1])],S=!1):S=this.updateTempPoints(m),!S)return{type:dt.None};var E;if(i||l||a){var P=n?this.fullLayer:this.drawLayer||this.fullLayer;E=this.draw({workId:c,layer:P});}if(a){var _P8=bt(E,this.oldRect);this.oldRect=E;var _x60=_objectSpread({rect:_P8,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);if(o){var _h33=Date.now();_h33-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=_h33,_x60.op=this.tmpPoints.map(function(p){return[].concat(_toConsumableArray(p.XY),[0]);}).flat(1),_x60.index=0,_x60.isSync=!0);}return _x60;}if(!i&&o){var _P9=Date.now();return _P9-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_P9,_objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:dt.DrawWork,dataType:Dt.Local,op:this.tmpPoints.map(function(x){return[].concat(_toConsumableArray(x.XY),[0]);}).flat(1),isSync:!0,index:0})):{type:dt.None};}var T=bt(E,this.oldRect);return this.oldRect=E,_objectSpread(_objectSpread({rect:T},this.baseConsumeResult),{},{type:dt.DrawWork,dataType:Dt.Local});}},{key:"consumeAll",value:function consumeAll(){var o;var t=this.workId;if(this.tmpPoints.length<2)return{type:dt.RemoveNode,removeIds:[t]};var r=this.fullLayer,n=this.draw({workId:t,layer:r});this.oldRect=n;var i=this.tmpPoints.map(function(a){return[].concat(_toConsumableArray(a.XY),[0]);}).flat(1),l=ve(i);return(o=this.vNodes)==null||o.setInfo(t,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:At.getCenterPos(n,r)}),_objectSpread(_objectSpread({rect:n},this.baseConsumeResult),{},{type:dt.FullWork,dataType:Dt.Local,ops:l,isSync:!0,updateNodeOpt:{useAnimation:!0}});}},{key:"draw",value:function draw(t){var r=t.workId,n=t.layer,i=t.isDrawEraserlines,_this$workOptions7=this.workOptions,l=_this$workOptions7.strokeColor,o=_this$workOptions7.thickness,a=_this$workOptions7.zIndex,c=_this$workOptions7.scale,m=_this$workOptions7.rotate,f=_this$workOptions7.translate,v=_this$workOptions7.strokeType,S=_this$workOptions7.eraserlines,E=n.worldPosition,T=n.worldScaling,_this$computDrawPoint3=this.computDrawPoints(o),P=_this$computDrawPoint3.points,x=_this$computDrawPoint3.pos,h=_this$computDrawPoint3.rect,p=_this$computDrawPoint3.isTriangle,d=_this$computDrawPoint3.trianglePoints,g=_this$computDrawPoint3.trianglePos,O=[h.x+h.w/2,h.y+h.h/2],w={pos:O,name:r,id:r,zIndex:a,anchor:[0.5,0.5],size:[h.w,h.h]};c&&(w.scale=c),m&&(w.rotate=m),f&&(w.translate=f);var L=new ye(w),B={points:d,pos:[g[0]-O[0],g[1]-O[1]],fillColor:l,strokeColor:l,lineWidth:0,normalize:!1},A=new we(B);if(L.append(A),!p&&P&&x){var W={points:P,pos:[x[0]-O[0],x[1]-O[1]],fillColor:l,strokeColor:l,lineDash:v===Zt.Dotted&&!p?[1,o*2]:v===Zt.LongDotted&&!p?[o,o*2]:void 0,lineCap:v===Zt.Normal?void 0:"round",lineWidth:o,normalize:!1},D=new we(W);L.append(D);}S&&(this.scaleType=Qt.proportional,this.drawEraserlines({group:L,eraserlines:S,pos:O,layer:n},i)),this.replace(n,r,L);var b={x:Math.floor(h.x*T[0]+E[0]-At.SafeBorderPadding),y:Math.floor(h.y*T[1]+E[1]-At.SafeBorderPadding),w:Math.floor(h.w*T[0]+2*At.SafeBorderPadding),h:Math.floor(h.h*T[1]+2*At.SafeBorderPadding)};if(c||m||f){var _W9=L.getBoundingClientRect();b={x:Math.floor(_W9.x-At.SafeBorderPadding),y:Math.floor(_W9.y-At.SafeBorderPadding),w:Math.floor(_W9.width+At.SafeBorderPadding*2),h:Math.floor(_W9.height+At.SafeBorderPadding*2)};}return this.isDelete&&L.setAttribute("opacity",0),b;}},{key:"computDrawPoints",value:function computDrawPoints(t){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.arrowTipWidth?this.computFullArrowPoints(t):this.computTrianglePoints();}},{key:"computFullArrowPoints",value:function computFullArrowPoints(t){var _this75=this;var r=at.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),n=at.Per(r).mul(t/2),i=Nt.Sub(this.tmpPoints[0],n),l=Nt.Add(this.tmpPoints[0],n),o=at.Mul(r,this.arrowTipWidth),a=at.Sub(this.tmpPoints[1],o),c=Nt.Sub(a,n),m=Nt.Add(a,n),f=at.Per(r).mul(t*1.5),v=Nt.Sub(a,f),S=Nt.Add(a,f),E=[this.tmpPoints[0],a],T=[v,this.tmpPoints[1],S],P=[i,l].concat(T,[c,m]);return{trianglePoints:T.map(function(x){return Nt.Sub(x,_this75.tmpPoints[1]).XY;}).flat(1),trianglePos:this.tmpPoints[1].XY,points:E.map(function(x){return Nt.Sub(x,_this75.tmpPoints[0]).XY;}).flat(1),rect:_t(P),isTriangle:!1,pos:this.tmpPoints[0].XY};}},{key:"computTrianglePoints",value:function computTrianglePoints(){var _this76=this;var t=at.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),r=this.tmpPoints[1].distance(this.tmpPoints[0]),n=at.Per(t).mul(Math.floor(r*3/8)),i=Nt.Sub(this.tmpPoints[0],n),l=Nt.Add(this.tmpPoints[0],n),o=[i,this.tmpPoints[1],l];return{trianglePoints:o.map(function(a){return Nt.Sub(a,_this76.tmpPoints[1]).XY;}).flat(1),trianglePos:this.tmpPoints[1].XY,rect:_t(o),isTriangle:!0};}},{key:"updateTempPoints",value:function updateTempPoints(t){var r=t.slice(-2),n=new Nt(r[0],r[1]),i=this.tmpPoints[0],l=this.workOptions.thickness;if(i.isNear(n,l))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n;}else this.tmpPoints.push(n);return!0;}},{key:"consumeService",value:function consumeService(t){var c,m;var r=t.op,n=t.isFullWork,_t$workState2=t.workState,i=_t$workState2===void 0?Ft.Done:_t$workState2,l=(c=this.workId)==null?void 0:c.toString();if(!l)return;this.tmpPoints.length=0;for(var f=0;f<r.length;f+=3)this.tmpPoints.push(new Nt(r[f],r[f+1],r[f+2]));var o=n?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:l,layer:o,isDrawEraserlines:i===Ft.Done});return this.oldRect=a,(m=this.vNodes)==null||m.setInfo(l,{rect:a,op:r,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:At.getCenterPos(a,o)}),a;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var c,m;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"?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&&(m=a.opt)!=null&&m.strokeType&&(a.opt.strokeType=o),a&&i.setInfo(r.name,a),At.updateNodeOpt(t);}}]);}(At);var qi=/*#__PURE__*/function(_At6){function qi(t){var _this77;_classCallCheck(this,qi);_this77=_callSuper(this,qi,[t]);ot(_this77,"canRotate",!1);ot(_this77,"scaleType",Qt.all);ot(_this77,"toolsType",pt.Ellipse);ot(_this77,"tmpPoints",[]);ot(_this77,"workOptions");ot(_this77,"oldRect");ot(_this77,"syncTimestamp");_this77.workOptions=t.toolsOpt,_this77.syncTimestamp=0,_this77.syncUnitTime=50;return _this77;}_inherits(qi,_At6);return _createClass(qi,[{key:"consume",value:function consume(t){var r=t.data,n=t.isFullWork,i=t.isSubWorker,l=t.isMainThread,o=t.smoothSync,a=t.isSimpleWorker,c=this.workId,m=r.op,f=r.syncUnitTime;f&&(this.syncUnitTime=f);var v=m==null?void 0:m.length;if(!v||v<2)return{type:dt.None};var S;if(this.tmpPoints.length===0?(this.tmpPoints=[new Nt(m[0],m[1])],S=!1):S=this.updateTempPoints(m),!S)return{type:dt.None};var E;if(i||l||a){var T=n?this.fullLayer:this.drawLayer||this.fullLayer;E=this.draw({workId:c,layer:T,isDrawing:!0});var P=T.parent.parent,_x61={x:0,y:0,w:Math.floor(P.width),h:Math.floor(P.height)},_h34=_objectSpread({type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);if(or(E,_x61)!==Pe.outside){var d=bt(E,this.oldRect);if(this.oldRect=E,_h34.rect=d,!a)return _h34;}if(a){var _d15=Date.now();return _d15-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=_d15,_h34.op=this.tmpPoints.map(function(g){return[].concat(_toConsumableArray(g.XY),[0]);}).flat(1),_h34.index=0,_h34.isSync=!0),_h34;}return{type:dt.None};}if(!i&&!l&&!a&&o){var _T3=Date.now();return _T3-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_T3,_objectSpread(_objectSpread({type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult),{},{op:this.tmpPoints.map(function(P){return[].concat(_toConsumableArray(P.XY),[0]);}).flat(1),isSync:!0,index:0})):{type:dt.None};}return{type:dt.None};}},{key:"consumeAll",value:function consumeAll(){var o;var t=this.workId;if(this.tmpPoints.length<2)return{type:dt.RemoveNode,removeIds:[t]};var r=this.fullLayer,n=this.draw({workId:t,layer:r,isDrawing:!1});this.oldRect=n;var i=this.tmpPoints.map(function(a){return[].concat(_toConsumableArray(a.XY),[0]);}).flat(1),l=ve(i);return(o=this.vNodes)==null||o.setInfo(t,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:n&&At.getCenterPos(n,r)}),_objectSpread(_objectSpread({rect:n,type:dt.FullWork,dataType:Dt.Local},this.baseConsumeResult),{},{ops:l,isSync:!0,updateNodeOpt:{useAnimation:!0}});}},{key:"draw",value:function draw(t){var r=t.workId,n=t.layer,i=t.isDrawing,l=t.isDrawEraserlines,_this$workOptions8=this.workOptions,o=_this$workOptions8.strokeColor,a=_this$workOptions8.fillColor,c=_this$workOptions8.thickness,m=_this$workOptions8.zIndex,f=_this$workOptions8.scale,v=_this$workOptions8.rotate,S=_this$workOptions8.translate,E=_this$workOptions8.strokeType,T=_this$workOptions8.eraserlines,P=n.worldScaling,_this$computDrawPoint4=this.computDrawPoints(c),x=_this$computDrawPoint4.radius,h=_this$computDrawPoint4.rect,p=_this$computDrawPoint4.pos,d={closeType:"normal",radius:x,lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:o,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:E===Zt.Dotted?[1,c*2]:E===Zt.LongDotted?[c,c*2]:void 0},g={name:r,id:r,zIndex:m,pos:p,anchor:[0.5,0.5],size:[h.w,h.h]};f&&(g.scale=f),v&&(g.rotate=v),S&&(g.translate=S);var O=new ye(g);if(i){var B=new be({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:o,lineWidth:1,scale:[1/P[0],1/P[1]]});O.append(B);}var w=new io(_objectSpread(_objectSpread({},d),{},{pos:[0,0]}));O.append(w),T&&(this.scaleType=Qt.proportional,this.drawEraserlines({group:O,eraserlines:T,pos:p,layer:n},l)),this.replace(n,r,O);var L=O.getBoundingClientRect();return this.isDelete&&O.setAttribute("opacity",0),{x:Math.floor(L.x-At.SafeBorderPadding),y:Math.floor(L.y-At.SafeBorderPadding),w:Math.floor(L.width+At.SafeBorderPadding*2),h:Math.floor(L.height+At.SafeBorderPadding*2)};}},{key:"computDrawPoints",value:function computDrawPoints(t){var r=_t(this.tmpPoints),n=_t(this.tmpPoints,t),i=[Math.floor(r.x+r.w/2),Math.floor(r.y+r.h/2)];return{rect:n,pos:i,radius:[Math.floor(r.w/2),Math.floor(r.h/2)]};}},{key:"updateTempPoints",value:function updateTempPoints(t){var r=t.slice(-2),n=new Nt(r[0],r[1]),i=this.tmpPoints[0],l=this.workOptions.thickness;if(i.isNear(n,l))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n;}else this.tmpPoints.push(n);return!0;}},{key:"consumeService",value:function consumeService(t){var c,m;var r=t.op,n=t.isFullWork,_t$workState3=t.workState,i=_t$workState3===void 0?Ft.Done:_t$workState3,l=(c=this.workId)==null?void 0:c.toString();if(!l)return;this.tmpPoints.length=0;for(var f=0;f<r.length;f+=3)this.tmpPoints.push(new Nt(r[f],r[f+1],r[f+2]));var o=n?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:l,layer:o,isDrawing:!1,isDrawEraserlines:i===Ft.Done});return this.oldRect=a,(m=this.vNodes)==null||m.setInfo(l,{rect:a,op:r,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:At.getCenterPos(a,o)}),a;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var f,v,S;var r=t.node,n=t.opt,i=t.vNodes,l=n.strokeColor,o=n.fillColor,a=n.strokeType,c=i.get(r.name);var m=r;return r.tagName==="GROUP"&&(m=r.children[0]),l&&(m.setAttribute("strokeColor",l),(f=c==null?void 0:c.opt)!=null&&f.strokeColor&&(c.opt.strokeColor=l)),o&&(o==="transparent"?m.setAttribute("fillColor","rgba(0,0,0,0)"):m.setAttribute("fillColor",o),(v=c==null?void 0:c.opt)!=null&&v.fillColor&&(c.opt.fillColor=o)),a&&c!=null&&c.opt&&(S=c.opt)!=null&&S.strokeType&&(c.opt.strokeType=a),c&&i.setInfo(r.name,c),At.updateNodeOpt(t);}}]);}(At);var _i=/*#__PURE__*/function(_At7){function _i(t){var _this78;_classCallCheck(this,_i);_this78=_callSuper(this,_i,[t]);ot(_this78,"canRotate",!0);ot(_this78,"scaleType",Qt.all);ot(_this78,"toolsType",pt.Rectangle);ot(_this78,"tmpPoints",[]);ot(_this78,"workOptions");ot(_this78,"oldRect");ot(_this78,"syncTimestamp");_this78.workOptions=t.toolsOpt,_this78.syncTimestamp=0,_this78.syncUnitTime=50;return _this78;}_inherits(_i,_At7);return _createClass(_i,[{key:"transformData",value:function transformData(){var t=_t(this.tmpPoints);return[[t.x,t.y,0],[t.x+t.w,t.y,0],[t.x+t.w,t.y+t.h,0],[t.x,t.y+t.h,0]];}},{key:"computDrawPoints",value:function computDrawPoints(t){var r=this.workOptions.thickness,n=[];var _iterator30=_createForOfIteratorHelper(t),_step30;try{for(_iterator30.s();!(_step30=_iterator30.n()).done;){var o=_step30.value;n.push(_construct(at,_toConsumableArray(o)));}}catch(err){_iterator30.e(err);}finally{_iterator30.f();}var i=_t(n,r),l=[i.x+i.w/2,i.y+i.h/2];return{rect:i,pos:l,points:n.map(function(o){return o.XY;}).flat(1)};}},{key:"consume",value:function consume(t){var r=t.data,n=t.isFullWork,i=t.isSubWorker,l=t.isMainThread,o=t.smoothSync,a=t.isSimpleWorker,c=this.workId,m=r.op,f=m==null?void 0:m.length;if(!f||f<2)return{type:dt.None};var v;if(this.tmpPoints.length===0?(this.tmpPoints=[new Nt(m[0],m[1])],v=!1):v=this.updateTempPoints(m),!v)return{type:dt.None};var S=this.transformData();var E;if(i||l||a){var P=n?this.fullLayer:this.drawLayer||this.fullLayer;E=this.draw({ps:S,workId:c,layer:P,isDrawing:!0});}if(a){var _P10=bt(E,this.oldRect);this.oldRect=E;var _x62=_objectSpread({rect:_P10,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);if(o){var _h35=Date.now();_h35-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=_h35,_x62.op=S.flat(1),_x62.index=0,_x62.isSync=!0);}return _x62;}if(!i&&o){var _P11=Date.now();return _P11-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_P11,_objectSpread({type:dt.DrawWork,dataType:Dt.Local,op:S.flat(1),isSync:!0,index:0},this.baseConsumeResult)):{type:dt.None};}var T=bt(E,this.oldRect);return this.oldRect=E,_objectSpread({rect:T,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var a;var t=this.workId;if(this.tmpPoints.length<2)return{type:dt.RemoveNode,removeIds:[t]};var r=this.transformData(),n=this.fullLayer,i=this.draw({ps:r,workId:t,layer:n,isDrawing:!1});this.oldRect=i;var l=r.flat(1),o=ve(l);return(a=this.vNodes)==null||a.setInfo(t,{rect:i,op:l,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&At.getCenterPos(i,n)}),_objectSpread(_objectSpread({rect:i,type:dt.FullWork,dataType:Dt.Local,ops:o,isSync:!0},this.baseConsumeResult),{},{updateNodeOpt:{useAnimation:!0}});}},{key:"draw",value:function draw(t){var r=t.workId,n=t.layer,i=t.isDrawing,l=t.ps,o=t.replaceId,_t$isDrawEraserlines2=t.isDrawEraserlines,a=_t$isDrawEraserlines2===void 0?!0:_t$isDrawEraserlines2,_this$workOptions9=this.workOptions,c=_this$workOptions9.strokeColor,m=_this$workOptions9.fillColor,f=_this$workOptions9.thickness,v=_this$workOptions9.zIndex,S=_this$workOptions9.scale,E=_this$workOptions9.rotate,T=_this$workOptions9.translate,P=_this$workOptions9.strokeType,x=_this$workOptions9.eraserlines,h=n.worldPosition,p=n.worldScaling,_this$computDrawPoint5=this.computDrawPoints(l),d=_this$computDrawPoint5.points,g=_this$computDrawPoint5.rect,O=_this$computDrawPoint5.pos,w={close:!0,normalize:!0,points:d,lineWidth:f,fillColor:m!=="transparent"&&m||void 0,strokeColor:c,lineJoin:"round",lineCap:"round",lineDash:P===Zt.Dotted?[1,f*2]:P===Zt.LongDotted?[f,f*2]:void 0};var L={x:Math.floor(g.x*p[0]+h[0]-At.SafeBorderPadding),y:Math.floor(g.y*p[1]+h[1]-At.SafeBorderPadding),w:Math.floor(g.w*p[0]+2*At.SafeBorderPadding),h:Math.floor(g.h*p[0]+2*At.SafeBorderPadding)};var B=new ye({name:r,id:r,zIndex:v,pos:O,anchor:[0.5,0.5],size:[g.w,g.h],scale:S,rotate:E,translate:T}),A=new we(_objectSpread(_objectSpread({},w),{},{pos:[0,0]}));if(B.appendChild(A),i){var b=new be({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:c,lineWidth:1,scale:[1/p[0],1/p[1]]});B.appendChild(b);}if(x&&(this.scaleType=Qt.proportional,this.drawEraserlines({group:B,eraserlines:x,pos:O,layer:n},a)),this.replace(n,o||r,B),S||E||T){var _b8=B.getBoundingClientRect();L={x:Math.floor(_b8.x-At.SafeBorderPadding),y:Math.floor(_b8.y-At.SafeBorderPadding),w:Math.floor(_b8.width+2*At.SafeBorderPadding),h:Math.floor(_b8.height+2*At.SafeBorderPadding)};}return this.isDelete&&B.setAttribute("opacity",0),L;}},{key:"updateTempPoints",value:function updateTempPoints(t){var r=t.slice(-2),n=new Nt(r[0],r[1]),i=this.tmpPoints[0],l=this.workOptions.thickness;if(i.isNear(n,l))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n;}else this.tmpPoints.push(n);return!0;}},{key:"consumeService",value:function consumeService(t){var f,v;var r=t.op,n=t.isFullWork,i=t.replaceId,_t$workState4=t.workState,l=_t$workState4===void 0?Ft.Done:_t$workState4,o=(f=this.workId)==null?void 0:f.toString();if(!o)return;var a=[];for(var S=0;S<r.length;S+=3)a.push([r[S],r[S+1],r[S+2]]);var c=n?this.fullLayer:this.drawLayer||this.fullLayer,m=this.draw({ps:a,workId:o,layer:c,isDrawing:!1,replaceId:i,isDrawEraserlines:l===Ft.Done});return this.oldRect=m,(v=this.vNodes)==null||v.setInfo(o,{rect:m,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:m&&At.getCenterPos(m,c)}),m;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var f,v,S;var r=t.node,n=t.opt,i=t.vNodes,l=n.strokeColor,o=n.fillColor,a=n.strokeType,c=i.get(r.name);var m=r;return r.tagName==="GROUP"&&(m=r.children[0]),l&&(m.setAttribute("strokeColor",l),(f=c==null?void 0:c.opt)!=null&&f.strokeColor&&(c.opt.strokeColor=l)),o&&(o==="transparent"?m.setAttribute("fillColor","rgba(0,0,0,0)"):m.setAttribute("fillColor",o),(v=c==null?void 0:c.opt)!=null&&v.fillColor&&(c.opt.fillColor=o)),a&&c!=null&&c.opt&&(S=c.opt)!=null&&S.strokeType&&(c.opt.strokeType=a),c&&i.setInfo(r.name,c),At.updateNodeOpt(t);}}]);}(At);var ts=/*#__PURE__*/function(_At8){function ts(t){var _this79;_classCallCheck(this,ts);_this79=_callSuper(this,ts,[t]);ot(_this79,"canRotate",!1);ot(_this79,"scaleType",Qt.all);ot(_this79,"toolsType",pt.Star);ot(_this79,"tmpPoints",[]);ot(_this79,"workOptions");ot(_this79,"oldRect");ot(_this79,"syncTimestamp");_this79.workOptions=t.toolsOpt,_this79.syncTimestamp=0,_this79.syncUnitTime=50;return _this79;}_inherits(ts,_At8);return _createClass(ts,[{key:"consume",value:function consume(t){var r=t.data,n=t.isFullWork,i=t.isSubWorker,l=t.isMainThread,o=t.smoothSync,a=t.isSimpleWorker,c=this.workId,m=r.op,f=r.syncUnitTime,v=m==null?void 0:m.length;if(!v||v<2)return{type:dt.None};f&&(this.syncUnitTime=f);var S;if(this.tmpPoints.length===0?(this.tmpPoints=[new Nt(m[0],m[1])],S=!1):S=this.updateTempPoints(m),!S)return{type:dt.None};var E;if(i||l||a){var P=n?this.fullLayer:this.drawLayer||this.fullLayer;E=this.draw({workId:c,layer:P,isDrawing:!0});}if(a){var _P12=bt(E,this.oldRect);this.oldRect=E;var _x63=_objectSpread({rect:_P12,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);if(o){var _h36=Date.now();_h36-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=_h36,_x63.op=this.tmpPoints.map(function(p){return[].concat(_toConsumableArray(p.XY),[0]);}).flat(1),_x63.index=0,_x63.isSync=!0);}return _x63;}if(!i&&o){var _P13=Date.now();return _P13-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_P13,_objectSpread({type:dt.DrawWork,dataType:Dt.Local,op:this.tmpPoints.map(function(x){return[].concat(_toConsumableArray(x.XY),[0]);}).flat(1),isSync:!0,index:0},this.baseConsumeResult)):{type:dt.None};}var T=bt(E,this.oldRect);return this.oldRect=E,_objectSpread({rect:T,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var o;var t=this.workId;if(this.tmpPoints.length<2)return{type:dt.RemoveNode,removeIds:[t]};var r=this.fullLayer,n=this.draw({workId:t,layer:r,isDrawing:!1});this.oldRect=n;var i=this.tmpPoints.map(function(a){return[].concat(_toConsumableArray(a.XY),[0]);}).flat(1),l=ve(i);return(o=this.vNodes)==null||o.setInfo(t,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&At.getCenterPos(n,r)}),_objectSpread(_objectSpread({rect:n,type:dt.FullWork,dataType:Dt.Local,ops:l,isSync:!0},this.baseConsumeResult),{},{updateNodeOpt:{useAnimation:!0}});}},{key:"draw",value:function draw(t){var r=t.workId,n=t.layer,i=t.isDrawing,_t$isDrawEraserlines3=t.isDrawEraserlines,l=_t$isDrawEraserlines3===void 0?!0:_t$isDrawEraserlines3,_this$workOptions10=this.workOptions,o=_this$workOptions10.strokeColor,a=_this$workOptions10.fillColor,c=_this$workOptions10.thickness,m=_this$workOptions10.zIndex,f=_this$workOptions10.vertices,v=_this$workOptions10.innerVerticeStep,S=_this$workOptions10.innerRatio,E=_this$workOptions10.scale,T=_this$workOptions10.rotate,P=_this$workOptions10.translate,x=_this$workOptions10.strokeType,h=_this$workOptions10.eraserlines,p=n.worldScaling,_this$computDrawPoint6=this.computDrawPoints(c,f,v,S),d=_this$computDrawPoint6.rect,g=_this$computDrawPoint6.pos,O=_this$computDrawPoint6.points,w={close:!0,points:O,lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:o,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:x===Zt.Dotted?[1,c*2]:x===Zt.LongDotted?[c,c*2]:void 0},L={name:r,id:r,zIndex:m,pos:g,anchor:[0.5,0.5],size:[d.w,d.h]};E&&(L.scale=E),T&&(L.rotate=T),P&&(L.translate=P);var B=new ye(L);if(i){var W=new be({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:o,lineWidth:1,scale:[1/p[0],1/p[1]]});B.append(W);}var A=new we(_objectSpread(_objectSpread({},w),{},{pos:[0,0]}));B.append(A),h&&(this.scaleType=Qt.proportional,this.drawEraserlines({group:B,eraserlines:h,pos:g,layer:n},l)),this.replace(n,r,B);var b=B.getBoundingClientRect();return this.isDelete&&B.setAttribute("opacity",0),{x:Math.floor(b.x-At.SafeBorderPadding),y:Math.floor(b.y-At.SafeBorderPadding),w:Math.floor(b.width+At.SafeBorderPadding*2),h:Math.floor(b.height+At.SafeBorderPadding*2)};}},{key:"computDrawPoints",value:function computDrawPoints(t,r,n,i){var l=_t(this.tmpPoints),o=[Math.floor(l.x+l.w/2),Math.floor(l.y+l.h/2)],a=ls(l.w,l.h),c=Math.floor(Math.min(l.w,l.h)/2),m=i*c,f=[],v=2*Math.PI/r;for(var E=0;E<r;E++){var T=E*v-0.5*Math.PI;var P=void 0,_x64=void 0;E%n===1?(P=m*a[0]*Math.cos(T),_x64=m*a[1]*Math.sin(T)):(P=c*a[0]*Math.cos(T),_x64=c*a[1]*Math.sin(T),f.push(P,_x64)),f.push(P,_x64);}return{rect:_t(this.tmpPoints,t),pos:o,points:f};}},{key:"updateTempPoints",value:function updateTempPoints(t){var r=t.slice(-2),n=new Nt(r[0],r[1]),i=this.tmpPoints[0],l=this.workOptions.thickness;if(i.isNear(n,l)||Nt.Sub(i,n).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n;}else this.tmpPoints.push(n);return!0;}},{key:"consumeService",value:function consumeService(t){var c,m;var r=t.op,n=t.isFullWork,_t$workState5=t.workState,i=_t$workState5===void 0?Ft.Done:_t$workState5,l=(c=this.workId)==null?void 0:c.toString();if(!l)return;this.tmpPoints.length=0;for(var f=0;f<r.length;f+=3)this.tmpPoints.push(new Nt(r[f],r[f+1],r[f+2]));var o=n?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:l,layer:o,isDrawing:!1,isDrawEraserlines:i===Ft.Done});return this.oldRect=a,(m=this.vNodes)==null||m.setInfo(l,{rect:a,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&At.getCenterPos(a,o)}),a;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var P;var r=t.node,n=t.opt,i=t.vNodes,l=n.strokeColor,o=n.fillColor,a=n.toolsType,c=n.vertices,m=n.innerVerticeStep,f=n.innerRatio,v=n.strokeType,S=i.get(r.name),E=S==null?void 0:S.opt;var T=r;return r.tagName==="GROUP"&&(T=r.children[0]),l&&(T.setAttribute("strokeColor",l),E!=null&&E.strokeColor&&(E.strokeColor=l)),o&&(o==="transparent"?T.setAttribute("fillColor","rgba(0,0,0,0)"):T.setAttribute("fillColor",o),E!=null&&E.fillColor&&(E.fillColor=o)),a===pt.Star&&(c&&(E.vertices=c),m&&(E.innerVerticeStep=m),f&&(E.innerRatio=f)),v&&S!=null&&S.opt&&(P=S.opt)!=null&&P.strokeType&&(S.opt.strokeType=v),S&&i.setInfo(r.name,_objectSpread(_objectSpread({},S),{},{opt:E})),At.updateNodeOpt(t);}}]);}(At);var es=/*#__PURE__*/function(_At9){function es(t){var _this80;_classCallCheck(this,es);_this80=_callSuper(this,es,[t]);ot(_this80,"canRotate",!1);ot(_this80,"scaleType",Qt.all);ot(_this80,"toolsType",pt.Polygon);ot(_this80,"tmpPoints",[]);ot(_this80,"workOptions");ot(_this80,"oldRect");ot(_this80,"syncTimestamp");_this80.workOptions=t.toolsOpt,_this80.syncTimestamp=0,_this80.syncUnitTime=50;return _this80;}_inherits(es,_At9);return _createClass(es,[{key:"consume",value:function consume(t){var r=t.data,n=t.isFullWork,i=t.isSubWorker,l=t.isMainThread,o=t.smoothSync,a=t.isSimpleWorker,c=r.op,m=r.syncUnitTime;m&&(this.syncUnitTime=m);var f=this.workId,v=c==null?void 0:c.length;if(!v||v<2)return{type:dt.None};var S;if(this.tmpPoints.length===0?(this.tmpPoints=[new Nt(c[0],c[1])],S=!1):S=this.updateTempPoints(c),!S)return{type:dt.None};var E;if(i||l||a){var P=n?this.fullLayer:this.drawLayer||this.fullLayer;E=this.draw({workId:f,layer:P,isDrawing:!0});}if(a){var _P14=bt(E,this.oldRect);this.oldRect=E;var _x65=_objectSpread({type:dt.DrawWork,rect:_P14,dataType:Dt.Local},this.baseConsumeResult);if(o){var _h37=Date.now();_h37-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=_h37,_x65.op=this.tmpPoints.map(function(p){return[].concat(_toConsumableArray(p.XY),[0]);}).flat(1),_x65.index=0,_x65.isSync=!0);}return _x65;}if(!i&&o){var _P15=Date.now();return _P15-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_P15,_objectSpread({type:dt.DrawWork,dataType:Dt.Local,op:this.tmpPoints.map(function(x){return[].concat(_toConsumableArray(x.XY),[0]);}).flat(1),isSync:!0,index:0},this.baseConsumeResult)):{type:dt.None};}var T=bt(E,this.oldRect);return this.oldRect=E,_objectSpread({rect:T,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var o;var t=this.workId;if(this.tmpPoints.length<2)return{type:dt.RemoveNode,removeIds:[t]};var r=this.fullLayer,n=this.draw({workId:t,layer:r,isDrawing:!1});this.oldRect=n;var i=this.tmpPoints.map(function(a){return[].concat(_toConsumableArray(a.XY),[0]);}).flat(1),l=ve(i);return(o=this.vNodes)==null||o.setInfo(t,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&At.getCenterPos(n,r)}),_objectSpread(_objectSpread({rect:n,type:dt.FullWork,dataType:Dt.Local,ops:l,isSync:!0},this.baseConsumeResult),{},{updateNodeOpt:{useAnimation:!0}});}},{key:"draw",value:function draw(t){var r=t.workId,n=t.layer,i=t.isDrawing,_t$isDrawEraserlines4=t.isDrawEraserlines,l=_t$isDrawEraserlines4===void 0?!0:_t$isDrawEraserlines4,_this$workOptions11=this.workOptions,o=_this$workOptions11.strokeColor,a=_this$workOptions11.fillColor,c=_this$workOptions11.thickness,m=_this$workOptions11.zIndex,f=_this$workOptions11.vertices,v=_this$workOptions11.scale,S=_this$workOptions11.rotate,E=_this$workOptions11.translate,T=_this$workOptions11.strokeType,P=_this$workOptions11.eraserlines,x=n.worldScaling,_this$computDrawPoint7=this.computDrawPoints(c,f),h=_this$computDrawPoint7.rect,p=_this$computDrawPoint7.pos,d=_this$computDrawPoint7.points,g={close:!0,points:d,lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:o,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:T===Zt.Dotted?[1,c*2]:T===Zt.LongDotted?[c,c*2]:void 0},O={name:r,id:r,zIndex:m,pos:p,anchor:[0.5,0.5],size:[h.w,h.h]};v&&(O.scale=v),S&&(O.rotate=S),E&&(O.translate=E);var w=new ye(O);if(i){var A=new be({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:o,lineWidth:1,scale:[1/x[0],1/x[1]]});w.append(A);}var L=new we(_objectSpread(_objectSpread({},g),{},{pos:[0,0]}));w.append(L),P&&(this.scaleType=Qt.proportional,this.drawEraserlines({group:w,eraserlines:P,pos:p,layer:n},l)),this.replace(n,r,w);var B=w.getBoundingClientRect();return this.isDelete&&w.setAttribute("opacity",0),{x:Math.floor(B.x-At.SafeBorderPadding),y:Math.floor(B.y-At.SafeBorderPadding),w:Math.floor(B.width+At.SafeBorderPadding*2),h:Math.floor(B.height+At.SafeBorderPadding*2)};}},{key:"computDrawPoints",value:function computDrawPoints(t,r){var n=_t(this.tmpPoints),i=[Math.floor(n.x+n.w/2),Math.floor(n.y+n.h/2)],l=ls(n.w,n.h),o=Math.floor(Math.min(n.w,n.h)/2),a=[],c=2*Math.PI/r;for(var f=0;f<r;f++){var v=f*c-0.5*Math.PI,S=o*l[0]*Math.cos(v),E=o*l[1]*Math.sin(v);a.push(S,E);}return{rect:_t(this.tmpPoints,t),pos:i,points:a};}},{key:"updateTempPoints",value:function updateTempPoints(t){var r=t.slice(-2),n=new Nt(r[0],r[1]),i=this.tmpPoints[0],l=this.workOptions.thickness;if(i.isNear(n,l)||Nt.Sub(i,n).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n;}else this.tmpPoints.push(n);return!0;}},{key:"consumeService",value:function consumeService(t){var c,m;var r=t.op,n=t.isFullWork,_t$workState6=t.workState,i=_t$workState6===void 0?Ft.Done:_t$workState6,l=(c=this.workId)==null?void 0:c.toString();if(!l)return;this.tmpPoints.length=0;for(var f=0;f<r.length;f+=3)this.tmpPoints.push(new Nt(r[f],r[f+1],r[f+2]));var o=n?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:l,layer:o,isDrawing:!1,isDrawEraserlines:i===Ft.Done});return this.oldRect=a,(m=this.vNodes)==null||m.setInfo(l,{rect:a,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&At.getCenterPos(a,o)}),a;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var E;var r=t.node,n=t.opt,i=t.vNodes,l=n.strokeColor,o=n.fillColor,a=n.toolsType,c=n.vertices,m=n.strokeType,f=i.get(r.name),v=f==null?void 0:f.opt;var S=r;return r.tagName==="GROUP"&&(S=r.children[0]),l&&(S.setAttribute("strokeColor",l),v!=null&&v.strokeColor&&(v.strokeColor=l)),o&&(o==="transparent"?S.setAttribute("fillColor","rgba(0,0,0,0)"):S.setAttribute("fillColor",o),v!=null&&v.fillColor&&(v.fillColor=o)),a===pt.Polygon&&c&&(v.vertices=c),m&&f!=null&&f.opt&&(E=f.opt)!=null&&E.strokeType&&(f.opt.strokeType=m),f&&i.setInfo(r.name,_objectSpread(_objectSpread({},f),{},{opt:v})),At.updateNodeOpt(t);}}]);}(At);var Ce=/*#__PURE__*/function(){function Ce(){_classCallCheck(this,Ce);}return _createClass(Ce,null,[{key:"bezier",value:function bezier(e,t){var r=[];for(var n=0;n<t.length;n+=4){var i=t[n],l=t[n+1],o=t[n+2],a=t[n+3];i&&l&&o&&a?r.push.apply(r,_toConsumableArray(Ce.getBezierPoints(e,i,l,o,a))):i&&l&&o?r.push.apply(r,_toConsumableArray(Ce.getBezierPoints(e,i,l,o))):i&&l?r.push.apply(r,_toConsumableArray(Ce.getBezierPoints(e,i,l))):i&&r.push(i);}return r;}/**
409
409
  * @desc 获取点,这里可以设置点的个数
410
410
  * @param {number} num 点个数
411
411
  * @param {Vec2d} p1 点坐标
@@ -433,11 +433,11 @@ ot(Ve,"eraserSizes",fn);var Ir=Ve;var i0="__lodash_hash_undefined__";function s0
433
433
  * @param {Array} p2 终点坐标
434
434
  * @param {Array} cp1 控制点1
435
435
  * @param {Array} cp2 控制点2
436
- */},{key:"threeBezier",value:function threeBezier(e,t,r,n,i){var l=t.x*(1-e)*(1-e)*(1-e)+3*r.x*e*(1-e)*(1-e)+3*n.x*e*e*(1-e)+i.x*e*e*e,o=t.y*(1-e)*(1-e)*(1-e)+3*r.y*e*(1-e)*(1-e)+3*n.y*e*e*(1-e)+i.y*e*e*e;return new at(l,o);}}]);}();var rs=/*#__PURE__*/function(_At10){function rs(t){var _this81;_classCallCheck(this,rs);_this81=_callSuper(this,rs,[t]);ot(_this81,"canRotate",!1);ot(_this81,"scaleType",Qt.all);ot(_this81,"toolsType",pt.SpeechBalloon);ot(_this81,"ratio",0.8);ot(_this81,"tmpPoints",[]);ot(_this81,"workOptions");ot(_this81,"oldRect");ot(_this81,"syncTimestamp");_this81.workOptions=t.toolsOpt,_this81.syncTimestamp=0,_this81.syncUnitTime=50;return _this81;}_inherits(rs,_At10);return _createClass(rs,[{key:"consume",value:function consume(t){var T;var r=t.data,n=t.isFullWork,i=t.isSubWorker,l=t.isMainThread,o=t.smoothSync,a=t.isSimpleWorker,c=(T=r==null?void 0:r.workId)==null?void 0:T.toString();if(!c)return{type:dt.None};var m=r.op,f=m==null?void 0:m.length;if(!f||f<2)return{type:dt.None};var v;if(this.tmpPoints.length===0?(this.tmpPoints=[new Nt(m[0],m[1])],v=!1):v=this.updateTempPoints(m),!v)return{type:dt.None};var S;if(i||l||a){var P=n?this.fullLayer:this.drawLayer||this.fullLayer;S=this.draw({workId:c,layer:P,isDrawing:!0});}if(a){var _P16=bt(S,this.oldRect);this.oldRect=S;var _x66=_objectSpread({rect:_P16,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);if(o){var _h38=Date.now();_h38-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=_h38,_x66.op=this.tmpPoints.map(function(p){return[].concat(_toConsumableArray(p.XY),[0]);}).flat(1),_x66.index=0,_x66.isSync=!0);}return _x66;}if(!i&&o){var _P17=Date.now();return _P17-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_P17,_objectSpread({type:dt.DrawWork,dataType:Dt.Local,op:this.tmpPoints.map(function(x){return[].concat(_toConsumableArray(x.XY),[0]);}).flat(1),isSync:!0,index:0},this.baseConsumeResult)):{type:dt.None};}var E=bt(S,this.oldRect);return this.oldRect=S,_objectSpread({rect:E,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var o;var t=this.workId;if(this.tmpPoints.length<2)return{type:dt.RemoveNode,removeIds:[t]};var r=this.fullLayer,n=this.draw({workId:t,layer:r,isDrawing:!1});this.oldRect=n;var i=this.tmpPoints.map(function(a){return[].concat(_toConsumableArray(a.XY),[0]);}).flat(1),l=ve(i);return(o=this.vNodes)==null||o.setInfo(t,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&At.getCenterPos(n,r)}),_objectSpread(_objectSpread({rect:n,type:dt.FullWork,dataType:Dt.Local,ops:l,isSync:!0},this.baseConsumeResult),{},{updateNodeOpt:{useAnimation:!0}});}},{key:"draw",value:function draw(t){var r=t.workId,n=t.layer,_t$isDrawEraserlines5=t.isDrawEraserlines,i=_t$isDrawEraserlines5===void 0?!0:_t$isDrawEraserlines5,_this$workOptions12=this.workOptions,l=_this$workOptions12.strokeColor,o=_this$workOptions12.fillColor,a=_this$workOptions12.thickness,c=_this$workOptions12.zIndex,m=_this$workOptions12.placement,f=_this$workOptions12.scale,v=_this$workOptions12.rotate,S=_this$workOptions12.translate,E=_this$workOptions12.strokeType,T=_this$workOptions12.eraserlines,_this$computDrawPoint8=this.computDrawPoints(a,m),P=_this$computDrawPoint8.rect,x=_this$computDrawPoint8.pos,h=_this$computDrawPoint8.points,p={points:h.map(function(L){return L.XY;}),lineWidth:a,fillColor:o!=="transparent"&&o||void 0,strokeColor:l,normalize:!0,className:"".concat(x[0],",").concat(x[1]),close:!0,lineJoin:"round",lineCap:"round",lineDash:E===Zt.Dotted?[1,a*2]:E===Zt.LongDotted?[a,a*2]:void 0},d={name:r,id:r,zIndex:c,pos:x,anchor:[0.5,0.5],size:[P.w,P.h]};f&&(d.scale=f),v&&(d.rotate=v),S&&(d.translate=S);var g=new ye(d),O=new we(_objectSpread(_objectSpread({},p),{},{pos:[0,0]}));g.append(O),T&&(this.scaleType=Qt.proportional,this.drawEraserlines({group:g,eraserlines:T,pos:x,layer:n},i)),this.replace(n,r,g);var w=g.getBoundingClientRect();return this.isDelete&&g.setAttribute("opacity",0),{x:Math.floor(w.x-At.SafeBorderPadding),y:Math.floor(w.y-At.SafeBorderPadding),w:Math.floor(w.width+At.SafeBorderPadding*2),h:Math.floor(w.height+At.SafeBorderPadding*2)};}},{key:"transformControlPoints",value:function transformControlPoints(t){var r=_t(this.tmpPoints);switch(t){case"bottom":case"bottomLeft":case"bottomRight":{var n=r.y+r.h*this.ratio;return[new at(r.x,r.y,0),new at(r.x+r.w,r.y,0),new at(r.x+r.w,n,0),new at(r.x,n,0)];}case"top":case"topLeft":case"topRight":{var _n4=r.y+r.h*(1-this.ratio);return[new at(r.x,_n4,0),new at(r.x+r.w,_n4,0),new at(r.x+r.w,r.y+r.h,0),new at(r.x,r.y+r.h,0)];}case"left":case"leftBottom":case"leftTop":{var _n5=r.x+r.w*(1-this.ratio);return[new at(_n5,r.y,0),new at(r.x+r.w,r.y,0),new at(r.x+r.w,r.y+r.h,0),new at(_n5,r.y+r.h,0)];}case"right":case"rightBottom":case"rightTop":{var _n6=r.x+r.w*this.ratio;return[new at(r.x,r.y,0),new at(_n6,r.y,0),new at(_n6,r.y+r.h,0),new at(r.x,r.y+r.h,0)];}}}},{key:"computDrawPoints",value:function computDrawPoints(t,r){var n=_t(this.tmpPoints),i=this.transformControlPoints(r),l=Math.floor(n.w*0.1),o=Math.floor(n.h*0.1),a=[],c=at.Add(i[0],new at(0,o,0)),m=at.Add(i[0],new at(l,0,0)),f=Ce.getBezierPoints(10,c,i[0],m),v=at.Sub(i[1],new at(l,0,0)),S=at.Add(i[1],new at(0,o,0)),E=Ce.getBezierPoints(10,v,i[1],S),T=at.Sub(i[2],new at(0,o,0)),P=at.Sub(i[2],new at(l,0,0)),x=Ce.getBezierPoints(10,T,i[2],P),h=at.Add(i[3],new at(l,0,0)),p=at.Sub(i[3],new at(0,o,0)),d=Ce.getBezierPoints(10,h,i[3],p),g=l*(1-this.ratio)*10,O=o*(1-this.ratio)*10;switch(r){case"bottom":{var B=at.Sub(i[2],new at(l*5-g/2,0,0)),A=at.Sub(i[2],new at(l*5,-O,0)),b=at.Sub(i[2],new at(l*5+g/2,0,0));a.push.apply(a,[A,b].concat(_toConsumableArray(d),_toConsumableArray(f),_toConsumableArray(E),_toConsumableArray(x),[B]));break;}case"bottomRight":{var _B11=at.Sub(i[2],new at(l*1.1,0,0)),_A9=at.Sub(i[2],new at(l*1.1+g/2,-O,0)),_b9=at.Sub(i[2],new at(l*1.1+g,0,0));a.push.apply(a,[_A9,_b9].concat(_toConsumableArray(d),_toConsumableArray(f),_toConsumableArray(E),_toConsumableArray(x),[_B11]));break;}case"bottomLeft":{var _B12=at.Add(i[3],new at(l*1.1+g,0,0)),_A10=at.Add(i[3],new at(l*1.1+g/2,O,0)),_b10=at.Add(i[3],new at(l*1.1,0,0));a.push.apply(a,[_A10,_b10].concat(_toConsumableArray(d),_toConsumableArray(f),_toConsumableArray(E),_toConsumableArray(x),[_B12]));break;}case"top":{var _B13=at.Sub(i[1],new at(l*5-g/2,0,0)),_A11=at.Sub(i[1],new at(l*5,O,0)),_b11=at.Sub(i[1],new at(l*5+g/2,0,0));a.push.apply(a,[_A11,_B13].concat(_toConsumableArray(E),_toConsumableArray(x),_toConsumableArray(d),_toConsumableArray(f),[_b11]));break;}case"topRight":{var _B14=at.Sub(i[1],new at(l*1.1,0,0)),_A12=at.Sub(i[1],new at(l*1.1+g/2,O,0)),_b12=at.Sub(i[1],new at(l*1.1+g,0,0));a.push.apply(a,[_A12,_B14].concat(_toConsumableArray(E),_toConsumableArray(x),_toConsumableArray(d),_toConsumableArray(f),[_b12]));break;}case"topLeft":{var _B15=at.Add(i[0],new at(l*1.1+g,0,0)),_A13=at.Add(i[0],new at(l*1.1+g/2,-O,0)),_b13=at.Add(i[0],new at(l*1.1,0,0));a.push.apply(a,[_A13,_B15].concat(_toConsumableArray(E),_toConsumableArray(x),_toConsumableArray(d),_toConsumableArray(f),[_b13]));break;}case"left":{var _B16=at.Add(i[0],new at(0,o*5-O/2,0)),_A14=at.Add(i[0],new at(-g,o*5,0)),_b14=at.Add(i[0],new at(0,o*5+O/2,0));a.push.apply(a,[_A14,_B16].concat(_toConsumableArray(f),_toConsumableArray(E),_toConsumableArray(x),_toConsumableArray(d),[_b14]));break;}case"leftTop":{var _B17=at.Add(i[0],new at(0,o*1.1,0)),_A15=at.Add(i[0],new at(-g,o*1.1+O/2,0)),_b15=at.Add(i[0],new at(0,o*1.1+O,0));a.push.apply(a,[_A15,_B17].concat(_toConsumableArray(f),_toConsumableArray(E),_toConsumableArray(x),_toConsumableArray(d),[_b15]));break;}case"leftBottom":{var _B18=at.Sub(i[3],new at(0,o*1.1+O,0)),_A16=at.Sub(i[3],new at(g,o*1.1+O/2,0)),_b16=at.Sub(i[3],new at(0,o*1.1,0));a.push.apply(a,[_A16,_B18].concat(_toConsumableArray(f),_toConsumableArray(E),_toConsumableArray(x),_toConsumableArray(d),[_b16]));break;}case"right":{var _B19=at.Add(i[1],new at(0,o*5-O/2,0)),_A17=at.Add(i[1],new at(g,o*5,0)),_b17=at.Add(i[1],new at(0,o*5+O/2,0));a.push.apply(a,[_A17,_b17].concat(_toConsumableArray(x),_toConsumableArray(d),_toConsumableArray(f),_toConsumableArray(E),[_B19]));break;}case"rightTop":{var _B20=at.Add(i[1],new at(0,o*1.1,0)),_A18=at.Add(i[1],new at(g,o*1.1+O/2,0)),_b18=at.Add(i[1],new at(0,o*1.1+O,0));a.push.apply(a,[_A18,_b18].concat(_toConsumableArray(x),_toConsumableArray(d),_toConsumableArray(f),_toConsumableArray(E),[_B20]));break;}case"rightBottom":{var _B21=at.Sub(i[2],new at(0,o*1.1+O,0)),_A19=at.Sub(i[2],new at(-g,o*1.1+O/2,0)),_b19=at.Sub(i[2],new at(0,o*1.1,0));a.push.apply(a,[_A19,_b19].concat(_toConsumableArray(x),_toConsumableArray(d),_toConsumableArray(f),_toConsumableArray(E),[_B21]));break;}}var w=_t(this.tmpPoints,t),L=[Math.floor(w.x+w.w/2),Math.floor(w.y+w.h/2)];return{rect:w,pos:L,points:a};}},{key:"updateTempPoints",value:function updateTempPoints(t){var r=t.slice(-2),n=new Nt(r[0],r[1]),i=this.tmpPoints[0],l=this.workOptions.thickness;if(i.isNear(n,l)||Nt.Sub(i,n).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n;}else this.tmpPoints.push(n);return!0;}},{key:"consumeService",value:function consumeService(t){var c,m;var r=t.op,n=t.isFullWork,_t$workState7=t.workState,i=_t$workState7===void 0?Ft.Done:_t$workState7,l=(c=this.workId)==null?void 0:c.toString();if(!l)return;this.tmpPoints.length=0;for(var f=0;f<r.length;f+=3)this.tmpPoints.push(new Nt(r[f],r[f+1],r[f+2]));var o=n?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:l,layer:o,isDrawing:!1,isDrawEraserlines:i===Ft.Done});return this.oldRect=a,(m=this.vNodes)==null||m.setInfo(l,{rect:a,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&At.getCenterPos(a,o)}),a;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var E;var r=t.node,n=t.opt,i=t.vNodes,l=n.strokeColor,o=n.fillColor,a=n.toolsType,c=n.placement,m=n.strokeType,f=i.get(r.name),v=f==null?void 0:f.opt;var S=r;return r.tagName==="GROUP"&&(S=r.children[0]),l&&(S.setAttribute("strokeColor",l),v!=null&&v.strokeColor&&(v.strokeColor=l)),o&&(o==="transparent"?S.setAttribute("fillColor","rgba(0,0,0,0)"):S.setAttribute("fillColor",o),v!=null&&v.fillColor&&(v.fillColor=o)),a===pt.SpeechBalloon&&c&&(v.placement=c),m&&f!=null&&f.opt&&(E=f.opt)!=null&&E.strokeType&&(f.opt.strokeType=m),f&&i.setInfo(r.name,_objectSpread(_objectSpread({},f),{},{opt:v})),At.updateNodeOpt(t);}}]);}(At);var lm=qe,cm=Le,fm="[object Boolean]";function hm(u){return u===!0||u===!1||cm(u)&&lm(u)==fm;}var um=hm,ke=/* @__PURE__ */Ne(um);var lr=/*#__PURE__*/function(_At11){function lr(t){var _this82;_classCallCheck(this,lr);_this82=_callSuper(this,lr,[t]);ot(_this82,"canRotate",!0);ot(_this82,"scaleType",Qt.all);ot(_this82,"toolsType",pt.Image);ot(_this82,"tmpPoints",[]);ot(_this82,"workOptions");ot(_this82,"oldRect");_this82.workOptions=t.toolsOpt,_this82.scaleType=lr.getScaleType(_this82.workOptions);return _this82;}_inherits(lr,_At11);return _createClass(lr,[{key:"consume",value:function consume(){return{type:dt.None};}},{key:"consumeAll",value:function consumeAll(){return{type:dt.None};}},{key:"draw",value:function draw(t){var r=t.layer,n=t.workId,i=t.replaceId,l=t.imageBitmap,_this$workOptions13=this.workOptions,o=_this$workOptions13.centerX,a=_this$workOptions13.centerY,c=_this$workOptions13.width,m=_this$workOptions13.height,f=_this$workOptions13.rotate,v=_this$workOptions13.zIndex,S=_this$workOptions13.eraserlines,E=new ye({anchor:[0.5,0.5],pos:[o,a],name:n,size:[c,m],zIndex:v,rotate:f}),T={anchor:[0.5,0.5],pos:[0,0],size:[c,m],texture:l};l||(T.bgcolor="rgba(0,0,0,0.3)");var P=new di(T);E.append(P),S&&this.drawEraserlines({group:E,eraserlines:S,pos:[o,a],layer:r}),this.replace(r,i||n,E);var x=E.getBoundingClientRect();if(x)return{x:Math.floor(x.x-At.SafeBorderPadding),y:Math.floor(x.y-At.SafeBorderPadding),w:Math.floor(x.width+At.SafeBorderPadding*2),h:Math.floor(x.height+At.SafeBorderPadding*2)};}},{key:"consumeService",value:function consumeService(){}},{key:"consumeServiceAsync",value:function(){var _consumeServiceAsync=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23(t){var m,f,v,S,r,n,i,_this$workOptions14,l,o,a,c,E,T;return _regeneratorRuntime().wrap(function _callee23$(_context25){while(1)switch(_context25.prev=_context25.next){case 0:r=t.isFullWork,n=t.replaceId,i=t.worker,_this$workOptions14=this.workOptions,l=_this$workOptions14.src,o=_this$workOptions14.uuid,a=((m=this.workId)==null?void 0:m.toString())||o,c=r?this.fullLayer:this.drawLayer||this.fullLayer;if(!l){_context25.next=8;break;}_context25.next=4;return i.loadImageBitMap({toolsType:this.toolsType,opt:this.workOptions,workId:a,isSubWorker:i instanceof Ps});case 4:E=_context25.sent;if(!E){_context25.next=8;break;}T=this.draw({workId:a,layer:c,replaceId:n,imageBitmap:E});return _context25.abrupt("return",(this.oldRect=a&&((v=(f=this.vNodes)==null?void 0:f.get(a))==null?void 0:v.rect)||void 0,(S=this.vNodes)==null||S.setInfo(a,{rect:T,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:T&&At.getCenterPos(T,c)}),T));case 8:case"end":return _context25.stop();}},_callee23,this);}));function consumeServiceAsync(_x67){return _consumeServiceAsync.apply(this,arguments);}return consumeServiceAsync;}()},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"getScaleType",value:function getScaleType(t){var r=t.uniformScale,n=t.rotate;return r!==!1||n&&Math.abs(n)%90>0?Qt.proportional:Qt.all;}},{key:"updateNodeOpt",value:function updateNodeOpt(t){var r=t.node,n=t.opt,i=t.vNodes,l=t.targetNode,o=n.translate,a=n.originPoint,c=n.scenePoint,m=n.scale,f=n.angle,v=n.isLocked,S=n.zIndex,E=n.strokeColor,T=l&&he(l)||i.get(r.name);if(!T)return;var P=r.parent;if(P){if(E&&(T.opt.strokeColor=E),ue(S)&&(r.setAttribute("zIndex",S),T.opt.zIndex=S),ke(v)&&(T.opt.locked=v),a&&c&&m&&o){var _T$opt=T.opt,_x68=_T$opt.centerX,_h39=_T$opt.centerY,p=_T$opt.width,d=_T$opt.height,g=_T$opt.uniformScale,O=g!==!1?[m[0],m[0]]:m,w=[_x68,_h39],L=[_x68,_h39];vn(L,c,O,o);var B=[L[0]-w[0],L[1]-w[1]];if(T.centerPos=[T.centerPos[0]+B[0],T.centerPos[1]+B[1]],T.opt.width=Math.round(p*O[0]),T.opt.height=Math.round(d*O[1]),T.opt.centerX=L[0],T.opt.centerY=L[1],T.opt.eraserlines){var _iterator31=_createForOfIteratorHelper(T.opt.eraserlines),_step31;try{for(_iterator31.s();!(_step31=_iterator31.n()).done;){var A=_step31.value;var b=A.op,W=A.thickness;A.thickness=Math.round(W*Math.max(m[0],m[1]));for(var D=0;D<b.length;D++)yn(b[D],c,m,o);}}catch(err){_iterator31.e(err);}finally{_iterator31.f();}}}else if(o){if(T.opt.centerX=T.opt.centerX+o[0],T.opt.centerY=T.opt.centerY+o[1],T.centerPos=[T.centerPos[0]+o[0],T.centerPos[1]+o[1]],T.opt.eraserlines){var _iterator32=_createForOfIteratorHelper(T.opt.eraserlines),_step32;try{for(_iterator32.s();!(_step32=_iterator32.n()).done;){var _x69=_step32.value;var _h40=_x69.op;for(var _p12=0;_p12<_h40.length;_p12++){var _d16=_h40[_p12].map(function(g,O){return O%2?g+o[1]:g+o[0];});_x69.op[_p12]=_d16;}}}catch(err){_iterator32.e(err);}finally{_iterator32.f();}}}else if(ue(f))if(T.opt.rotate=f,T.scaleType=lr.getScaleType(T.opt),l){var _x70=os(T.rect,f);T.rect=_x70;}else{var _x71=At.getRectFromLayer(P,r.name);T.rect=_x71||T.rect;}return T&&i.setInfo(r.name,T),T==null?void 0:T.rect;}}}]);}(At);var ns=/*#__PURE__*/function(_At12){function ns(t){var _this83;_classCallCheck(this,ns);_this83=_callSuper(this,ns,[t]);ot(_this83,"canRotate",!1);ot(_this83,"scaleType",Qt.both);ot(_this83,"toolsType",pt.Straight);ot(_this83,"tmpPoints",[]);ot(_this83,"workOptions");ot(_this83,"oldRect");ot(_this83,"straightTipWidth");ot(_this83,"syncTimestamp");_this83.workOptions=t.toolsOpt,_this83.straightTipWidth=_this83.workOptions.thickness/2,_this83.syncTimestamp=0,_this83.syncUnitTime=50;return _this83;}_inherits(ns,_At12);return _createClass(ns,[{key:"consume",value:function consume(t){var r=t.data,n=t.isFullWork,i=t.isSubWorker,l=t.isMainThread,o=t.smoothSync,a=t.isSimpleWorker,c=this.workId,m=r.op,f=r.syncUnitTime,v=m==null?void 0:m.length;if(!v||v<2)return{type:dt.None};f&&(this.syncUnitTime=f);var S;if(this.tmpPoints.length===0?(this.tmpPoints=[new Nt(m[0],m[1])],S=!1):S=this.updateTempPoints(m),!S)return{type:dt.None};var E;if(i||l||a){var P=n?this.fullLayer:this.drawLayer||this.fullLayer;E=this.draw({workId:c,layer:P});}if(a){var _P18=bt(E,this.oldRect);this.oldRect=E;var _x72=_objectSpread({rect:_P18,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);if(o){var _h41=Date.now();_h41-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=_h41,_x72.op=this.tmpPoints.map(function(p){return[].concat(_toConsumableArray(p.XY),[0]);}).flat(1),_x72.index=0,_x72.isSync=!0);}return _x72;}if(!i&&o){var _P19=Date.now();return _P19-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_P19,_objectSpread({type:dt.DrawWork,dataType:Dt.Local,op:this.tmpPoints.map(function(x){return[].concat(_toConsumableArray(x.XY),[0]);}).flat(1),isSync:!0,index:0},this.baseConsumeResult)):{type:dt.None};}var T=bt(E,this.oldRect);return this.oldRect=E,_objectSpread({rect:T,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var o;var t=this.workId;if(this.tmpPoints.length<2)return{type:dt.RemoveNode,removeIds:[t]};var r=this.fullLayer,n=this.draw({workId:t,layer:r});this.oldRect=n;var i=this.tmpPoints.map(function(a){return[].concat(_toConsumableArray(a.XY),[0]);}).flat(1),l=ve(i);return(o=this.vNodes)==null||o.setInfo(t,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&At.getCenterPos(n,r)}),_objectSpread(_objectSpread({rect:n,type:dt.FullWork,dataType:Dt.Local,ops:l,isSync:!0},this.baseConsumeResult),{},{updateNodeOpt:{useAnimation:!0}});}},{key:"draw",value:function draw(t){var r=t.workId,n=t.layer,_t$isDrawEraserlines6=t.isDrawEraserlines,i=_t$isDrawEraserlines6===void 0?!0:_t$isDrawEraserlines6,_this$workOptions15=this.workOptions,l=_this$workOptions15.strokeColor,o=_this$workOptions15.thickness,a=_this$workOptions15.zIndex,c=_this$workOptions15.scale,m=_this$workOptions15.rotate,f=_this$workOptions15.translate,v=_this$workOptions15.strokeType,S=_this$workOptions15.eraserlines,E=n.worldPosition,T=n.worldScaling,_this$computDrawPoint9=this.computDrawPoints(o,v),P=_this$computDrawPoint9.d,x=_this$computDrawPoint9.rect,h=_this$computDrawPoint9.isDot,p=[x.x+x.w/2,x.y+x.h/2],d=new ye({pos:p,anchor:[0.5,0.5],size:[x.w,x.h],name:r,id:r,normalize:!0,zIndex:a}),g={pos:[0,0],normalize:!0,d:P,fillColor:l,strokeColor:l,lineDash:v===Zt.Dotted&&!h?[1,o*2]:v===Zt.LongDotted&&!h?[o,o*2]:void 0,lineCap:v===Zt.Normal||h?void 0:"round",lineWidth:v===Zt.Normal||h?0:o};c&&(g.scale=c),m&&(g.rotate=m),f&&(g.translate=f);var O=new be(g);d.append(O),S&&(this.scaleType=Qt.proportional,this.drawEraserlines({group:d,eraserlines:S,pos:p,layer:n},i)),this.replace(n,r,d);var w={x:Math.floor(x.x*T[0]+E[0]-At.SafeBorderPadding),y:Math.floor(x.y*T[1]+E[1]-At.SafeBorderPadding),w:Math.floor(x.w*T[0]+2*At.SafeBorderPadding),h:Math.floor(x.h*T[1]+2*At.SafeBorderPadding)};if(m||c||f){var L=O.getBoundingClientRect();w={x:Math.floor(L.x-At.SafeBorderPadding),y:Math.floor(L.y-At.SafeBorderPadding),w:Math.floor(L.width+At.SafeBorderPadding*2),h:Math.floor(L.height+At.SafeBorderPadding*2)};}return this.isDelete&&d.setAttribute("opacity",0),w;}},{key:"computDrawPoints",value:function computDrawPoints(t,r){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.straightTipWidth?this.computFullPoints(t,r):this.computDotPoints(t);}},{key:"computFullPoints",value:function computFullPoints(t,r){var n=at.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),i=at.Per(n).mul(t/2),l=Nt.Sub(this.tmpPoints[0],i),o=Nt.Add(this.tmpPoints[0],i),a=Nt.Sub(this.tmpPoints[1],i),c=Nt.Add(this.tmpPoints[1],i),m=Nt.GetSemicircleStroke(this.tmpPoints[1],a,-1,8),f=Nt.GetSemicircleStroke(this.tmpPoints[0],o,-1,8),v=[l,a].concat(_toConsumableArray(m),[c,o],_toConsumableArray(f));var S;return r!==Zt.Normal?S=De(this.tmpPoints,!1):S=De(v,!0),{d:S,rect:_t(v),isDot:!1,pos:this.tmpPoints[0].XY};}},{key:"computDotPoints",value:function computDotPoints(t){var r=Nt.GetDotStroke(this.tmpPoints[0],t/2,8);return{d:De(r,!0),rect:_t(r),isDot:!0,pos:this.tmpPoints[0].XY};}},{key:"updateTempPoints",value:function updateTempPoints(t){var r=t.slice(-2),n=new Nt(r[0],r[1]),i=this.tmpPoints[0],l=this.workOptions.thickness;if(i.isNear(n,l))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n;}else this.tmpPoints.push(n);return!0;}},{key:"consumeService",value:function consumeService(t){var c,m;var r=t.op,n=t.isFullWork,_t$workState8=t.workState,i=_t$workState8===void 0?Ft.Done:_t$workState8,l=(c=this.workId)==null?void 0:c.toString();if(!l)return;this.tmpPoints.length=0;for(var f=0;f<r.length;f+=3)this.tmpPoints.push(new Nt(r[f],r[f+1],r[f+2]));var o=n?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:l,layer:o,isDrawEraserlines:i===Ft.Done});return this.oldRect=a,(m=this.vNodes)==null||m.setInfo(l,{rect:a,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&At.getCenterPos(a,o)}),a;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var c,m;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"?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&&(m=a.opt)!=null&&m.strokeType&&(a.opt.strokeType=o),a&&i.setInfo(r.name,a),At.updateNodeOpt(t);}}]);}(At);var Re=/*#__PURE__*/function(_At13){function Re(t){var _this84;_classCallCheck(this,Re);_this84=_callSuper(this,Re,[t]);ot(_this84,"canRotate",!1);ot(_this84,"scaleType",Qt.proportional);ot(_this84,"toolsType",pt.Text);ot(_this84,"tmpPoints",[]);ot(_this84,"workOptions");ot(_this84,"oldRect");_this84.workOptions=t.toolsOpt;return _this84;}_inherits(Re,_At13);return _createClass(Re,[{key:"consume",value:function consume(){return{type:dt.None};}},{key:"consumeAll",value:function consumeAll(){return{type:dt.None};}},{key:"consumeService",value:function consumeService(){}},{key:"draw",value:function(){var _draw3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24(t){var r,n,i,_this$workOptions16,l,o,a,c,m,f,v,S,E,T,P,_x74;return _regeneratorRuntime().wrap(function _callee24$(_context26){while(1)switch(_context26.prev=_context26.next){case 0:r=t.workId,n=t.layer,i=t.isDrawLabel,_this$workOptions16=this.workOptions,l=_this$workOptions16.boxSize,o=_this$workOptions16.boxPoint,a=_this$workOptions16.zIndex,c=n.worldPosition,m=n.worldScaling;if(!(!o||!l)){_context26.next=3;break;}return _context26.abrupt("return");case 3:f={name:r,id:r,pos:[o[0],o[1]],anchor:[0,0],size:l,zIndex:a},v=new ye(f),S={x:o[0],y:o[1],w:l[0],h:l[1]},E={x:Math.floor(S.x*m[0]+c[0]),y:Math.floor(S.y*m[1]+c[1]),w:Math.floor(S.w*m[0])+2,h:Math.floor(S.h*m[1])+2};if(!(this.replace(n,r,v),i&&n&&this.workOptions.text)){_context26.next=11;break;}_context26.next=7;return Re.createLabels(this.workOptions,n,E);case 7:T=_context26.sent;P=T.labels;_x74=T.maxWidth;v.append.apply(v,_toConsumableArray(P)),E.w=Math.ceil(Math.max(_x74*n.worldScaling[0],E.w));case 11:return _context26.abrupt("return",E);case 12:case"end":return _context26.stop();}},_callee24,this);}));function draw(_x73){return _draw3.apply(this,arguments);}return draw;}()},{key:"consumeServiceAsync",value:function(){var _consumeServiceAsync2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25(t){var c,m,f,v,r,n,i,l,o,a;return _regeneratorRuntime().wrap(function _callee25$(_context27){while(1)switch(_context27.prev=_context27.next){case 0:r=(c=this.workId)==null?void 0:c.toString();if(r){_context27.next=3;break;}return _context27.abrupt("return");case 3:n=t.isFullWork,i=t.replaceId,l=t.isDrawLabel;this.oldRect=i&&((f=(m=this.vNodes)==null?void 0:m.get(i))==null?void 0:f.rect)||void 0;o=n?this.fullLayer:this.drawLayer||this.fullLayer;_context27.next=8;return this.draw({workId:r,layer:o,isDrawLabel:_typeof(l)>"u"&&this.workOptions.workState===Ft.Done||l});case 8:a=_context27.sent;return _context27.abrupt("return",((v=this.vNodes)==null||v.setInfo(r,{rect:a,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&At.getCenterPos(a,o)}),a));case 10:case"end":return _context27.stop();}},_callee25,this);}));function consumeServiceAsync(_x75){return _consumeServiceAsync2.apply(this,arguments);}return consumeServiceAsync;}()},{key:"updataOptService",value:function updataOptService(){}},{key:"updataOptServiceAsync",value:function(){var _updataOptServiceAsync=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26(t,r){var E,T,n,i,l,o,a,c,m,f,v,S;return _regeneratorRuntime().wrap(function _callee26$(_context28){while(1)switch(_context28.prev=_context28.next){case 0:if(this.workId){_context28.next=2;break;}return _context28.abrupt("return");case 2:n=this.workId.toString(),i=t.fontColor,l=t.fontBgColor,o=t.bold,a=t.italic,c=t.lineThrough,m=t.underline,f=t.zIndex,v=(E=this.vNodes)==null?void 0:E.get(n);if(v){_context28.next=5;break;}return _context28.abrupt("return");case 5:i&&(v.opt.fontColor=i),l&&(v.opt.fontBgColor=l),o&&(v.opt.bold=o),a&&(v.opt.italic=a),ke(c)&&(v.opt.lineThrough=c),ke(m)&&(v.opt.underline=m),ue(f)&&(v.opt.zIndex=f),this.oldRect=v.rect;_context28.next=8;return this.draw({workId:n,layer:this.fullLayer,isDrawLabel:_typeof(r)>"u"&&this.workOptions.workState===Ft.Done||r});case 8:S=_context28.sent;return _context28.abrupt("return",((T=this.vNodes)==null||T.setInfo(n,{rect:S,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:S&&At.getCenterPos(S,this.fullLayer)}),S));case 10:case"end":return _context28.stop();}},_callee26,this);}));function updataOptServiceAsync(_x76,_x77){return _updataOptServiceAsync.apply(this,arguments);}return updataOptServiceAsync;}()},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"getSafetySnippetRatio",value:function getSafetySnippetRatio(t){var r=(t==null?void 0:t.parent).displayRatio||1,n=Math.ceil(t.worldScaling[0]*10)/10;var i=n;return n>=0.2&&n<1?i=n*r:n<=2&&n>=1?i=n*r*1.6:n>2&&n<=3?i=n*r*1.4:n>3&&n<=4?i=n*r*0.8:n>4&&(i=n*r*0.6),Math.floor(i*1e3)/1e3;}},{key:"getSafetySnippetFontLength",value:function getSafetySnippetFontLength(t){return Math.floor(Re.textImageSnippetSize*3/4/t)||1;}},{key:"createLabels",value:function(){var _createLabels=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27(t,r,n){var b,i,l,o,_ref168,a,c,m,f,v,S,E,T,P,x,h,p,d,g,O,w,L,B,A,W,D,R,X,H,J,et,it,$,V,rt,ct,gt,st,Ct,xt,F,U,K,q,lt,_st2,_Ct,_xt,_st3,_Ct2,_ct3,_gt2;return _regeneratorRuntime().wrap(function _callee27$(_context29){while(1)switch(_context29.prev=_context29.next){case 0:i=[],l=n.x,o=n.y,_ref168=(b=r.parent)==null?void 0:b.parent,a=_ref168.width,c=_ref168.height,m=Qe(t.text),f=m.length,v=t.fontSize,S=t.lineHeight,E=t.bold,T=t.textAlign,P=t.italic,x=t.fontFamily,h=t.verticalAlign,p=t.fontColor,d=t.fontBgColor,g=t.underline,O=t.lineThrough,w=Re.getSafetySnippetRatio(r)||1,L=Math.floor(v*w),B=Re.getSafetySnippetFontLength(L);A=0;W=0;case 3:if(!(W<f)){_context29.next=33;break;}D=m[W],R=S||L*1.5;if(!D){_context29.next=30;break;}X=Cm(D),H=[0,0],J=[0,v*1.2];h==="middle"&&(H[1]=W*v*1.2+5);et=[0,-v*0.15];H[0]=5;it=Math.sin(Math.PI/180*20);$=0;V=[];rt=0;case 14:if(!(rt<X)){_context29.next=27;break;}T==="left"&&(et[0]=$),rt===0&&P==="italic"&&(et[0]=et[0]-it/2*v);ct=D.slice(rt,rt+B);gt={anchor:[0,0],pos:et,text:ct,fontFamily:x,fontSize:L,lineHeight:R,strokeColor:p,fontWeight:E,fillColor:p,textAlign:T,fontStyle:P,scale:[1/w,1/w]};st=new so(gt);_context29.next=21;return st.textImageReady;case 21:Ct=_context29.sent;xt=!0;if(Ct){F=Ct.rect&&Ct.rect[2],U=Ct.rect&&Ct.rect[3];if(F&&U){K=F/w,q=U/w;$=K+$,P==="italic"&&(E==="bold"?$=$-it*v*1.2:$=$-it*v),((et[0]+H[0]+K)*r.worldScaling[0]+l<=0||(et[0]+H[0])*r.worldScaling[0]+l>=a||(et[1]+H[1]+q)*r.worldScaling[1]+o<=0||(et[1]+H[1])*r.worldScaling[1]+o>=c)&&(st.disconnect(),xt=!1),xt&&V.push(st);}}rt+=B;case 25:_context29.next=14;break;case 27:J[0]=$,P==="italic"&&(J[0]=J[0]+it*v),A=Math.max(A,J[0]);lt=!0;if(((H[0]+J[0])*r.worldScaling[0]+l<=0||H[0]*r.worldScaling[0]+l>=a||(H[1]+J[1])*r.worldScaling[0]+o<=0||H[1]*r.worldScaling[1]+o>=c)&&(lt=!1),lt){if(g){_st2=Math.floor(v/10),_Ct={normalize:!1,pos:[0,v*1.1+_st2/2],lineWidth:_st2,points:[0,0,Math.ceil(J[0]),0],strokeColor:p,className:"underline"},_xt=new we(_Ct);V.push(_xt);}if(O){_st3={normalize:!1,pos:[0,v*1.2/2],lineWidth:Math.floor(v/10),points:[0,0,Math.ceil(J[0]),0],strokeColor:p,className:"lineThrough"},_Ct2=new we(_st3);V.push(_Ct2);}_ct3={pos:H,anchor:[0,0],size:J,bgcolor:d},_gt2=new ye(_ct3);_gt2.append.apply(_gt2,V),i.push(_gt2);}case 30:W++;_context29.next=3;break;case 33:return _context29.abrupt("return",{labels:i,maxWidth:A});case 34:case"end":return _context29.stop();}},_callee27);}));function createLabels(_x78,_x79,_x80){return _createLabels.apply(this,arguments);}return createLabels;}()},{key:"updateNodeOpt",value:function updateNodeOpt(t){var r=t.node,n=t.opt,i=t.vNodes,l=t.targetNode,o=n.fontBgColor,a=n.fontColor,c=n.translate,m=n.originPoint,f=n.scenePoint,v=n.scale,S=n.bold,E=n.italic,T=n.lineThrough,P=n.underline,x=n.fontSize,h=n.textInfos,p=n.zIndex,d=l&&he(l)||i.get(r.name);if(!d||!r.parent)return;var O=d.opt;if(ue(p)&&(r.setAttribute("zIndex",p),d.opt.zIndex=p),a&&O.fontColor&&(O.fontColor=a,r.children.forEach(function(w){w.tagName==="GROUP"&&w.children.forEach(function(L){L.tagName==="LABEL"?(L.setAttribute("fillColor",a),L.setAttribute("strokeColor",a)):L.tagName==="POLYLINE"&&L.setAttribute("strokeColor",a);});})),o&&O.fontBgColor&&(O.fontBgColor=o,r.children.forEach(function(w){w.tagName==="GROUP"&&w.setAttribute("bgcolor",o);})),S&&(O.bold=S),E&&(O.italic=E),ke(T)&&(O.lineThrough=T),ke(P)&&(O.underline=P),x&&(O.fontSize=x),m&&f&&v&&l&&O.boxPoint){var w=h==null?void 0:h.get(r.name);if(w){var b=w.fontSize,W=w.boxSize;O.boxSize=W||O.boxSize,O.fontSize=b||O.fontSize;}var L=[O.boxPoint[0],O.boxPoint[1]];vn(O.boxPoint,f,v,c);var B=[d.op[0],d.op[1]],A=[B[0]-L[0],B[1]-L[1]];if(d.centerPos=[d.centerPos[0]+A[0],d.centerPos[1]+A[1]],d.opt.eraserlines){var _iterator33=_createForOfIteratorHelper(d.opt.eraserlines),_step33;try{for(_iterator33.s();!(_step33=_iterator33.n()).done;){var _b20=_step33.value;var _W10=_b20.op,D=_b20.thickness;_b20.thickness=Math.round(D*Math.max(v[0],v[1]));for(var R=0;R<_W10.length;R++)yn(_W10[R],f,v,c);}}catch(err){_iterator33.e(err);}finally{_iterator33.f();}}}else if(c&&O.boxPoint&&(O.boxPoint=[O.boxPoint[0]+c[0],O.boxPoint[1]+c[1]],d.centerPos=[d.centerPos[0]+c[0],d.centerPos[1]+c[1]],d.opt.eraserlines)){var _iterator34=_createForOfIteratorHelper(d.opt.eraserlines),_step34;try{for(_iterator34.s();!(_step34=_iterator34.n()).done;){var _w7=_step34.value;var _L6=_w7.op;for(var _B22=0;_B22<_L6.length;_B22++){var _A20=_L6[_B22].map(function(b,W){return W%2?b+c[1]:b+c[0];});_w7.op[_B22]=_A20;}}}catch(err){_iterator34.e(err);}finally{_iterator34.f();}}return d&&i.setInfo(r.name,d),d==null?void 0:d.rect;}},{key:"getRectFromLayer",value:function getRectFromLayer(t,r){var n=t.getElementsByName(r)[0];if(n){var i=n.getBoundingClientRect();var l={x:Math.floor(i.x),y:Math.floor(i.y),w:Math.floor(i.width+2),h:Math.floor(i.height+2)};return n.children.forEach(function(o){if(o.tagName==="GROUP"){var a=n.getBoundingClientRect();l=bt(l,{x:Math.floor(a.x),y:Math.floor(a.y),w:Math.floor(a.width+2),h:Math.floor(a.height+2)});}}),l;}}}]);}(At);// 4k
436
+ */},{key:"threeBezier",value:function threeBezier(e,t,r,n,i){var l=t.x*(1-e)*(1-e)*(1-e)+3*r.x*e*(1-e)*(1-e)+3*n.x*e*e*(1-e)+i.x*e*e*e,o=t.y*(1-e)*(1-e)*(1-e)+3*r.y*e*(1-e)*(1-e)+3*n.y*e*e*(1-e)+i.y*e*e*e;return new at(l,o);}}]);}();var rs=/*#__PURE__*/function(_At10){function rs(t){var _this81;_classCallCheck(this,rs);_this81=_callSuper(this,rs,[t]);ot(_this81,"canRotate",!1);ot(_this81,"scaleType",Qt.all);ot(_this81,"toolsType",pt.SpeechBalloon);ot(_this81,"ratio",0.8);ot(_this81,"tmpPoints",[]);ot(_this81,"workOptions");ot(_this81,"oldRect");ot(_this81,"syncTimestamp");_this81.workOptions=t.toolsOpt,_this81.syncTimestamp=0,_this81.syncUnitTime=50;return _this81;}_inherits(rs,_At10);return _createClass(rs,[{key:"consume",value:function consume(t){var T;var r=t.data,n=t.isFullWork,i=t.isSubWorker,l=t.isMainThread,o=t.smoothSync,a=t.isSimpleWorker,c=(T=r==null?void 0:r.workId)==null?void 0:T.toString();if(!c)return{type:dt.None};var m=r.op,f=m==null?void 0:m.length;if(!f||f<2)return{type:dt.None};var v;if(this.tmpPoints.length===0?(this.tmpPoints=[new Nt(m[0],m[1])],v=!1):v=this.updateTempPoints(m),!v)return{type:dt.None};var S;if(i||l||a){var P=n?this.fullLayer:this.drawLayer||this.fullLayer;S=this.draw({workId:c,layer:P,isDrawing:!0});}if(a){var _P16=bt(S,this.oldRect);this.oldRect=S;var _x66=_objectSpread({rect:_P16,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);if(o){var _h38=Date.now();_h38-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=_h38,_x66.op=this.tmpPoints.map(function(p){return[].concat(_toConsumableArray(p.XY),[0]);}).flat(1),_x66.index=0,_x66.isSync=!0);}return _x66;}if(!i&&o){var _P17=Date.now();return _P17-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_P17,_objectSpread({type:dt.DrawWork,dataType:Dt.Local,op:this.tmpPoints.map(function(x){return[].concat(_toConsumableArray(x.XY),[0]);}).flat(1),isSync:!0,index:0},this.baseConsumeResult)):{type:dt.None};}var E=bt(S,this.oldRect);return this.oldRect=S,_objectSpread({rect:E,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var o;var t=this.workId;if(this.tmpPoints.length<2)return{type:dt.RemoveNode,removeIds:[t]};var r=this.fullLayer,n=this.draw({workId:t,layer:r,isDrawing:!1});this.oldRect=n;var i=this.tmpPoints.map(function(a){return[].concat(_toConsumableArray(a.XY),[0]);}).flat(1),l=ve(i);return(o=this.vNodes)==null||o.setInfo(t,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&At.getCenterPos(n,r)}),_objectSpread(_objectSpread({rect:n,type:dt.FullWork,dataType:Dt.Local,ops:l,isSync:!0},this.baseConsumeResult),{},{updateNodeOpt:{useAnimation:!0}});}},{key:"draw",value:function draw(t){var r=t.workId,n=t.layer,_t$isDrawEraserlines5=t.isDrawEraserlines,i=_t$isDrawEraserlines5===void 0?!0:_t$isDrawEraserlines5,_this$workOptions12=this.workOptions,l=_this$workOptions12.strokeColor,o=_this$workOptions12.fillColor,a=_this$workOptions12.thickness,c=_this$workOptions12.zIndex,m=_this$workOptions12.placement,f=_this$workOptions12.scale,v=_this$workOptions12.rotate,S=_this$workOptions12.translate,E=_this$workOptions12.strokeType,T=_this$workOptions12.eraserlines,_this$computDrawPoint8=this.computDrawPoints(a,m),P=_this$computDrawPoint8.rect,x=_this$computDrawPoint8.pos,h=_this$computDrawPoint8.points,p={points:h.map(function(L){return L.XY;}),lineWidth:a,fillColor:o!=="transparent"&&o||void 0,strokeColor:l,normalize:!0,className:"".concat(x[0],",").concat(x[1]),close:!0,lineJoin:"round",lineCap:"round",lineDash:E===Zt.Dotted?[1,a*2]:E===Zt.LongDotted?[a,a*2]:void 0},d={name:r,id:r,zIndex:c,pos:x,anchor:[0.5,0.5],size:[P.w,P.h]};f&&(d.scale=f),v&&(d.rotate=v),S&&(d.translate=S);var g=new ye(d),O=new we(_objectSpread(_objectSpread({},p),{},{pos:[0,0]}));g.append(O),T&&(this.scaleType=Qt.proportional,this.drawEraserlines({group:g,eraserlines:T,pos:x,layer:n},i)),this.replace(n,r,g);var w=g.getBoundingClientRect();return this.isDelete&&g.setAttribute("opacity",0),{x:Math.floor(w.x-At.SafeBorderPadding),y:Math.floor(w.y-At.SafeBorderPadding),w:Math.floor(w.width+At.SafeBorderPadding*2),h:Math.floor(w.height+At.SafeBorderPadding*2)};}},{key:"transformControlPoints",value:function transformControlPoints(t){var r=_t(this.tmpPoints);switch(t){case"bottom":case"bottomLeft":case"bottomRight":{var n=r.y+r.h*this.ratio;return[new at(r.x,r.y,0),new at(r.x+r.w,r.y,0),new at(r.x+r.w,n,0),new at(r.x,n,0)];}case"top":case"topLeft":case"topRight":{var _n4=r.y+r.h*(1-this.ratio);return[new at(r.x,_n4,0),new at(r.x+r.w,_n4,0),new at(r.x+r.w,r.y+r.h,0),new at(r.x,r.y+r.h,0)];}case"left":case"leftBottom":case"leftTop":{var _n5=r.x+r.w*(1-this.ratio);return[new at(_n5,r.y,0),new at(r.x+r.w,r.y,0),new at(r.x+r.w,r.y+r.h,0),new at(_n5,r.y+r.h,0)];}case"right":case"rightBottom":case"rightTop":{var _n6=r.x+r.w*this.ratio;return[new at(r.x,r.y,0),new at(_n6,r.y,0),new at(_n6,r.y+r.h,0),new at(r.x,r.y+r.h,0)];}}}},{key:"computDrawPoints",value:function computDrawPoints(t,r){var n=_t(this.tmpPoints),i=this.transformControlPoints(r),l=Math.floor(n.w*0.1),o=Math.floor(n.h*0.1),a=[],c=at.Add(i[0],new at(0,o,0)),m=at.Add(i[0],new at(l,0,0)),f=Ce.getBezierPoints(10,c,i[0],m),v=at.Sub(i[1],new at(l,0,0)),S=at.Add(i[1],new at(0,o,0)),E=Ce.getBezierPoints(10,v,i[1],S),T=at.Sub(i[2],new at(0,o,0)),P=at.Sub(i[2],new at(l,0,0)),x=Ce.getBezierPoints(10,T,i[2],P),h=at.Add(i[3],new at(l,0,0)),p=at.Sub(i[3],new at(0,o,0)),d=Ce.getBezierPoints(10,h,i[3],p),g=l*(1-this.ratio)*10,O=o*(1-this.ratio)*10;switch(r){case"bottom":{var B=at.Sub(i[2],new at(l*5-g/2,0,0)),A=at.Sub(i[2],new at(l*5,-O,0)),b=at.Sub(i[2],new at(l*5+g/2,0,0));a.push.apply(a,[A,b].concat(_toConsumableArray(d),_toConsumableArray(f),_toConsumableArray(E),_toConsumableArray(x),[B]));break;}case"bottomRight":{var _B11=at.Sub(i[2],new at(l*1.1,0,0)),_A9=at.Sub(i[2],new at(l*1.1+g/2,-O,0)),_b9=at.Sub(i[2],new at(l*1.1+g,0,0));a.push.apply(a,[_A9,_b9].concat(_toConsumableArray(d),_toConsumableArray(f),_toConsumableArray(E),_toConsumableArray(x),[_B11]));break;}case"bottomLeft":{var _B12=at.Add(i[3],new at(l*1.1+g,0,0)),_A10=at.Add(i[3],new at(l*1.1+g/2,O,0)),_b10=at.Add(i[3],new at(l*1.1,0,0));a.push.apply(a,[_A10,_b10].concat(_toConsumableArray(d),_toConsumableArray(f),_toConsumableArray(E),_toConsumableArray(x),[_B12]));break;}case"top":{var _B13=at.Sub(i[1],new at(l*5-g/2,0,0)),_A11=at.Sub(i[1],new at(l*5,O,0)),_b11=at.Sub(i[1],new at(l*5+g/2,0,0));a.push.apply(a,[_A11,_B13].concat(_toConsumableArray(E),_toConsumableArray(x),_toConsumableArray(d),_toConsumableArray(f),[_b11]));break;}case"topRight":{var _B14=at.Sub(i[1],new at(l*1.1,0,0)),_A12=at.Sub(i[1],new at(l*1.1+g/2,O,0)),_b12=at.Sub(i[1],new at(l*1.1+g,0,0));a.push.apply(a,[_A12,_B14].concat(_toConsumableArray(E),_toConsumableArray(x),_toConsumableArray(d),_toConsumableArray(f),[_b12]));break;}case"topLeft":{var _B15=at.Add(i[0],new at(l*1.1+g,0,0)),_A13=at.Add(i[0],new at(l*1.1+g/2,-O,0)),_b13=at.Add(i[0],new at(l*1.1,0,0));a.push.apply(a,[_A13,_B15].concat(_toConsumableArray(E),_toConsumableArray(x),_toConsumableArray(d),_toConsumableArray(f),[_b13]));break;}case"left":{var _B16=at.Add(i[0],new at(0,o*5-O/2,0)),_A14=at.Add(i[0],new at(-g,o*5,0)),_b14=at.Add(i[0],new at(0,o*5+O/2,0));a.push.apply(a,[_A14,_B16].concat(_toConsumableArray(f),_toConsumableArray(E),_toConsumableArray(x),_toConsumableArray(d),[_b14]));break;}case"leftTop":{var _B17=at.Add(i[0],new at(0,o*1.1,0)),_A15=at.Add(i[0],new at(-g,o*1.1+O/2,0)),_b15=at.Add(i[0],new at(0,o*1.1+O,0));a.push.apply(a,[_A15,_B17].concat(_toConsumableArray(f),_toConsumableArray(E),_toConsumableArray(x),_toConsumableArray(d),[_b15]));break;}case"leftBottom":{var _B18=at.Sub(i[3],new at(0,o*1.1+O,0)),_A16=at.Sub(i[3],new at(g,o*1.1+O/2,0)),_b16=at.Sub(i[3],new at(0,o*1.1,0));a.push.apply(a,[_A16,_B18].concat(_toConsumableArray(f),_toConsumableArray(E),_toConsumableArray(x),_toConsumableArray(d),[_b16]));break;}case"right":{var _B19=at.Add(i[1],new at(0,o*5-O/2,0)),_A17=at.Add(i[1],new at(g,o*5,0)),_b17=at.Add(i[1],new at(0,o*5+O/2,0));a.push.apply(a,[_A17,_b17].concat(_toConsumableArray(x),_toConsumableArray(d),_toConsumableArray(f),_toConsumableArray(E),[_B19]));break;}case"rightTop":{var _B20=at.Add(i[1],new at(0,o*1.1,0)),_A18=at.Add(i[1],new at(g,o*1.1+O/2,0)),_b18=at.Add(i[1],new at(0,o*1.1+O,0));a.push.apply(a,[_A18,_b18].concat(_toConsumableArray(x),_toConsumableArray(d),_toConsumableArray(f),_toConsumableArray(E),[_B20]));break;}case"rightBottom":{var _B21=at.Sub(i[2],new at(0,o*1.1+O,0)),_A19=at.Sub(i[2],new at(-g,o*1.1+O/2,0)),_b19=at.Sub(i[2],new at(0,o*1.1,0));a.push.apply(a,[_A19,_b19].concat(_toConsumableArray(x),_toConsumableArray(d),_toConsumableArray(f),_toConsumableArray(E),[_B21]));break;}}var w=_t(this.tmpPoints,t),L=[Math.floor(w.x+w.w/2),Math.floor(w.y+w.h/2)];return{rect:w,pos:L,points:a};}},{key:"updateTempPoints",value:function updateTempPoints(t){var r=t.slice(-2),n=new Nt(r[0],r[1]),i=this.tmpPoints[0],l=this.workOptions.thickness;if(i.isNear(n,l)||Nt.Sub(i,n).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n;}else this.tmpPoints.push(n);return!0;}},{key:"consumeService",value:function consumeService(t){var c,m;var r=t.op,n=t.isFullWork,_t$workState7=t.workState,i=_t$workState7===void 0?Ft.Done:_t$workState7,l=(c=this.workId)==null?void 0:c.toString();if(!l)return;this.tmpPoints.length=0;for(var f=0;f<r.length;f+=3)this.tmpPoints.push(new Nt(r[f],r[f+1],r[f+2]));var o=n?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:l,layer:o,isDrawing:!1,isDrawEraserlines:i===Ft.Done});return this.oldRect=a,(m=this.vNodes)==null||m.setInfo(l,{rect:a,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&At.getCenterPos(a,o)}),a;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var E;var r=t.node,n=t.opt,i=t.vNodes,l=n.strokeColor,o=n.fillColor,a=n.toolsType,c=n.placement,m=n.strokeType,f=i.get(r.name),v=f==null?void 0:f.opt;var S=r;return r.tagName==="GROUP"&&(S=r.children[0]),l&&(S.setAttribute("strokeColor",l),v!=null&&v.strokeColor&&(v.strokeColor=l)),o&&(o==="transparent"?S.setAttribute("fillColor","rgba(0,0,0,0)"):S.setAttribute("fillColor",o),v!=null&&v.fillColor&&(v.fillColor=o)),a===pt.SpeechBalloon&&c&&(v.placement=c),m&&f!=null&&f.opt&&(E=f.opt)!=null&&E.strokeType&&(f.opt.strokeType=m),f&&i.setInfo(r.name,_objectSpread(_objectSpread({},f),{},{opt:v})),At.updateNodeOpt(t);}}]);}(At);var lm=qe,cm=Le,fm="[object Boolean]";function hm(u){return u===!0||u===!1||cm(u)&&lm(u)==fm;}var um=hm,ke=/* @__PURE__ */Ne(um);var lr=/*#__PURE__*/function(_At11){function lr(t){var _this82;_classCallCheck(this,lr);_this82=_callSuper(this,lr,[t]);ot(_this82,"canRotate",!0);ot(_this82,"scaleType",Qt.all);ot(_this82,"toolsType",pt.Image);ot(_this82,"tmpPoints",[]);ot(_this82,"workOptions");ot(_this82,"oldRect");_this82.workOptions=t.toolsOpt,_this82.scaleType=lr.getScaleType(_this82.workOptions);return _this82;}_inherits(lr,_At11);return _createClass(lr,[{key:"consume",value:function consume(){return{type:dt.None};}},{key:"consumeAll",value:function consumeAll(){return{type:dt.None};}},{key:"draw",value:function draw(t){var r=t.layer,n=t.workId,i=t.replaceId,l=t.imageBitmap,_this$workOptions13=this.workOptions,o=_this$workOptions13.centerX,a=_this$workOptions13.centerY,c=_this$workOptions13.width,m=_this$workOptions13.height,f=_this$workOptions13.rotate,v=_this$workOptions13.zIndex,S=_this$workOptions13.eraserlines,E=new ye({anchor:[0.5,0.5],pos:[o,a],name:n,size:[c,m],zIndex:v,rotate:f}),T={anchor:[0.5,0.5],pos:[0,0],size:[c,m],texture:l};l||(T.bgcolor="rgba(0,0,0,0.3)");var P=new di(T);E.append(P),S&&this.drawEraserlines({group:E,eraserlines:S,pos:[o,a],layer:r}),this.replace(r,i||n,E);var x=E.getBoundingClientRect();if(x)return{x:Math.floor(x.x-At.SafeBorderPadding),y:Math.floor(x.y-At.SafeBorderPadding),w:Math.floor(x.width+At.SafeBorderPadding*2),h:Math.floor(x.height+At.SafeBorderPadding*2)};}},{key:"consumeService",value:function consumeService(){}},{key:"consumeServiceAsync",value:function(){var _consumeServiceAsync=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23(t){var m,f,v,S,r,n,i,_this$workOptions14,l,o,a,c,E,T;return _regeneratorRuntime().wrap(function _callee23$(_context25){while(1)switch(_context25.prev=_context25.next){case 0:r=t.isFullWork,n=t.replaceId,i=t.worker,_this$workOptions14=this.workOptions,l=_this$workOptions14.src,o=_this$workOptions14.uuid,a=((m=this.workId)==null?void 0:m.toString())||o,c=r?this.fullLayer:this.drawLayer||this.fullLayer;if(!l){_context25.next=8;break;}_context25.next=4;return i.loadImageBitMap({toolsType:this.toolsType,opt:this.workOptions,workId:a,isSubWorker:i instanceof Ps});case 4:E=_context25.sent;if(!E){_context25.next=8;break;}T=this.draw({workId:a,layer:c,replaceId:n,imageBitmap:E});return _context25.abrupt("return",(this.oldRect=a&&((v=(f=this.vNodes)==null?void 0:f.get(a))==null?void 0:v.rect)||void 0,(S=this.vNodes)==null||S.setInfo(a,{rect:T,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:T&&At.getCenterPos(T,c)}),T));case 8:case"end":return _context25.stop();}},_callee23,this);}));function consumeServiceAsync(_x67){return _consumeServiceAsync.apply(this,arguments);}return consumeServiceAsync;}()},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"getScaleType",value:function getScaleType(t){var r=t.uniformScale,n=t.rotate;return r!==!1||n&&Math.abs(n)%90>0?Qt.proportional:Qt.all;}},{key:"updateNodeOpt",value:function updateNodeOpt(t){var r=t.node,n=t.opt,i=t.vNodes,l=t.targetNode,o=n.translate,a=n.originPoint,c=n.scenePoint,m=n.scale,f=n.angle,v=n.isLocked,S=n.zIndex,E=n.strokeColor,T=l&&ue(l)||i.get(r.name);if(!T)return;var P=r.parent;if(P){if(E&&(T.opt.strokeColor=E),he(S)&&(r.setAttribute("zIndex",S),T.opt.zIndex=S),ke(v)&&(T.opt.locked=v),a&&c&&m&&o){var _T$opt=T.opt,_x68=_T$opt.centerX,_h39=_T$opt.centerY,p=_T$opt.width,d=_T$opt.height,g=_T$opt.uniformScale,O=g!==!1?[m[0],m[0]]:m,w=[_x68,_h39],L=[_x68,_h39];vn(L,c,O,o);var B=[L[0]-w[0],L[1]-w[1]];if(T.centerPos=[T.centerPos[0]+B[0],T.centerPos[1]+B[1]],T.opt.width=Math.round(p*O[0]),T.opt.height=Math.round(d*O[1]),T.opt.centerX=L[0],T.opt.centerY=L[1],T.opt.eraserlines){var _iterator31=_createForOfIteratorHelper(T.opt.eraserlines),_step31;try{for(_iterator31.s();!(_step31=_iterator31.n()).done;){var A=_step31.value;var b=A.op,W=A.thickness;A.thickness=Math.round(W*Math.max(m[0],m[1]));for(var D=0;D<b.length;D++)yn(b[D],c,m,o);}}catch(err){_iterator31.e(err);}finally{_iterator31.f();}}}else if(o){if(T.opt.centerX=T.opt.centerX+o[0],T.opt.centerY=T.opt.centerY+o[1],T.centerPos=[T.centerPos[0]+o[0],T.centerPos[1]+o[1]],T.opt.eraserlines){var _iterator32=_createForOfIteratorHelper(T.opt.eraserlines),_step32;try{for(_iterator32.s();!(_step32=_iterator32.n()).done;){var _x69=_step32.value;var _h40=_x69.op;for(var _p12=0;_p12<_h40.length;_p12++){var _d16=_h40[_p12].map(function(g,O){return O%2?g+o[1]:g+o[0];});_x69.op[_p12]=_d16;}}}catch(err){_iterator32.e(err);}finally{_iterator32.f();}}}else if(he(f))if(T.opt.rotate=f,T.scaleType=lr.getScaleType(T.opt),l){var _x70=os(T.rect,f);T.rect=_x70;}else{var _x71=At.getRectFromLayer(P,r.name);T.rect=_x71||T.rect;}return T&&i.setInfo(r.name,T),T==null?void 0:T.rect;}}}]);}(At);var ns=/*#__PURE__*/function(_At12){function ns(t){var _this83;_classCallCheck(this,ns);_this83=_callSuper(this,ns,[t]);ot(_this83,"canRotate",!1);ot(_this83,"scaleType",Qt.both);ot(_this83,"toolsType",pt.Straight);ot(_this83,"tmpPoints",[]);ot(_this83,"workOptions");ot(_this83,"oldRect");ot(_this83,"straightTipWidth");ot(_this83,"syncTimestamp");_this83.workOptions=t.toolsOpt,_this83.straightTipWidth=_this83.workOptions.thickness/2,_this83.syncTimestamp=0,_this83.syncUnitTime=50;return _this83;}_inherits(ns,_At12);return _createClass(ns,[{key:"consume",value:function consume(t){var r=t.data,n=t.isFullWork,i=t.isSubWorker,l=t.isMainThread,o=t.smoothSync,a=t.isSimpleWorker,c=this.workId,m=r.op,f=r.syncUnitTime,v=m==null?void 0:m.length;if(!v||v<2)return{type:dt.None};f&&(this.syncUnitTime=f);var S;if(this.tmpPoints.length===0?(this.tmpPoints=[new Nt(m[0],m[1])],S=!1):S=this.updateTempPoints(m),!S)return{type:dt.None};var E;if(i||l||a){var P=n?this.fullLayer:this.drawLayer||this.fullLayer;E=this.draw({workId:c,layer:P});}if(a){var _P18=bt(E,this.oldRect);this.oldRect=E;var _x72=_objectSpread({rect:_P18,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);if(o){var _h41=Date.now();_h41-this.syncTimestamp>this.syncUnitTime&&(this.syncTimestamp=_h41,_x72.op=this.tmpPoints.map(function(p){return[].concat(_toConsumableArray(p.XY),[0]);}).flat(1),_x72.index=0,_x72.isSync=!0);}return _x72;}if(!i&&o){var _P19=Date.now();return _P19-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_P19,_objectSpread({type:dt.DrawWork,dataType:Dt.Local,op:this.tmpPoints.map(function(x){return[].concat(_toConsumableArray(x.XY),[0]);}).flat(1),isSync:!0,index:0},this.baseConsumeResult)):{type:dt.None};}var T=bt(E,this.oldRect);return this.oldRect=E,_objectSpread({rect:T,type:dt.DrawWork,dataType:Dt.Local},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var o;var t=this.workId;if(this.tmpPoints.length<2)return{type:dt.RemoveNode,removeIds:[t]};var r=this.fullLayer,n=this.draw({workId:t,layer:r});this.oldRect=n;var i=this.tmpPoints.map(function(a){return[].concat(_toConsumableArray(a.XY),[0]);}).flat(1),l=ve(i);return(o=this.vNodes)==null||o.setInfo(t,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&At.getCenterPos(n,r)}),_objectSpread(_objectSpread({rect:n,type:dt.FullWork,dataType:Dt.Local,ops:l,isSync:!0},this.baseConsumeResult),{},{updateNodeOpt:{useAnimation:!0}});}},{key:"draw",value:function draw(t){var r=t.workId,n=t.layer,_t$isDrawEraserlines6=t.isDrawEraserlines,i=_t$isDrawEraserlines6===void 0?!0:_t$isDrawEraserlines6,_this$workOptions15=this.workOptions,l=_this$workOptions15.strokeColor,o=_this$workOptions15.thickness,a=_this$workOptions15.zIndex,c=_this$workOptions15.scale,m=_this$workOptions15.rotate,f=_this$workOptions15.translate,v=_this$workOptions15.strokeType,S=_this$workOptions15.eraserlines,E=n.worldPosition,T=n.worldScaling,_this$computDrawPoint9=this.computDrawPoints(o,v),P=_this$computDrawPoint9.d,x=_this$computDrawPoint9.rect,h=_this$computDrawPoint9.isDot,p=[x.x+x.w/2,x.y+x.h/2],d=new ye({pos:p,anchor:[0.5,0.5],size:[x.w,x.h],name:r,id:r,normalize:!0,zIndex:a}),g={pos:[0,0],normalize:!0,d:P,fillColor:l,strokeColor:l,lineDash:v===Zt.Dotted&&!h?[1,o*2]:v===Zt.LongDotted&&!h?[o,o*2]:void 0,lineCap:v===Zt.Normal||h?void 0:"round",lineWidth:v===Zt.Normal||h?0:o};c&&(g.scale=c),m&&(g.rotate=m),f&&(g.translate=f);var O=new be(g);d.append(O),S&&(this.scaleType=Qt.proportional,this.drawEraserlines({group:d,eraserlines:S,pos:p,layer:n},i)),this.replace(n,r,d);var w={x:Math.floor(x.x*T[0]+E[0]-At.SafeBorderPadding),y:Math.floor(x.y*T[1]+E[1]-At.SafeBorderPadding),w:Math.floor(x.w*T[0]+2*At.SafeBorderPadding),h:Math.floor(x.h*T[1]+2*At.SafeBorderPadding)};if(m||c||f){var L=O.getBoundingClientRect();w={x:Math.floor(L.x-At.SafeBorderPadding),y:Math.floor(L.y-At.SafeBorderPadding),w:Math.floor(L.width+At.SafeBorderPadding*2),h:Math.floor(L.height+At.SafeBorderPadding*2)};}return this.isDelete&&d.setAttribute("opacity",0),w;}},{key:"computDrawPoints",value:function computDrawPoints(t,r){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.straightTipWidth?this.computFullPoints(t,r):this.computDotPoints(t);}},{key:"computFullPoints",value:function computFullPoints(t,r){var n=at.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),i=at.Per(n).mul(t/2),l=Nt.Sub(this.tmpPoints[0],i),o=Nt.Add(this.tmpPoints[0],i),a=Nt.Sub(this.tmpPoints[1],i),c=Nt.Add(this.tmpPoints[1],i),m=Nt.GetSemicircleStroke(this.tmpPoints[1],a,-1,8),f=Nt.GetSemicircleStroke(this.tmpPoints[0],o,-1,8),v=[l,a].concat(_toConsumableArray(m),[c,o],_toConsumableArray(f));var S;return r!==Zt.Normal?S=De(this.tmpPoints,!1):S=De(v,!0),{d:S,rect:_t(v),isDot:!1,pos:this.tmpPoints[0].XY};}},{key:"computDotPoints",value:function computDotPoints(t){var r=Nt.GetDotStroke(this.tmpPoints[0],t/2,8);return{d:De(r,!0),rect:_t(r),isDot:!0,pos:this.tmpPoints[0].XY};}},{key:"updateTempPoints",value:function updateTempPoints(t){var r=t.slice(-2),n=new Nt(r[0],r[1]),i=this.tmpPoints[0],l=this.workOptions.thickness;if(i.isNear(n,l))return!1;if(this.tmpPoints.length===2){if(n.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=n;}else this.tmpPoints.push(n);return!0;}},{key:"consumeService",value:function consumeService(t){var c,m;var r=t.op,n=t.isFullWork,_t$workState8=t.workState,i=_t$workState8===void 0?Ft.Done:_t$workState8,l=(c=this.workId)==null?void 0:c.toString();if(!l)return;this.tmpPoints.length=0;for(var f=0;f<r.length;f+=3)this.tmpPoints.push(new Nt(r[f],r[f+1],r[f+2]));var o=n?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:l,layer:o,isDrawEraserlines:i===Ft.Done});return this.oldRect=a,(m=this.vNodes)==null||m.setInfo(l,{rect:a,op:r,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&At.getCenterPos(a,o)}),a;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var c,m;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"?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&&(m=a.opt)!=null&&m.strokeType&&(a.opt.strokeType=o),a&&i.setInfo(r.name,a),At.updateNodeOpt(t);}}]);}(At);var Re=/*#__PURE__*/function(_At13){function Re(t){var _this84;_classCallCheck(this,Re);_this84=_callSuper(this,Re,[t]);ot(_this84,"canRotate",!1);ot(_this84,"scaleType",Qt.proportional);ot(_this84,"toolsType",pt.Text);ot(_this84,"tmpPoints",[]);ot(_this84,"workOptions");ot(_this84,"oldRect");_this84.workOptions=t.toolsOpt;return _this84;}_inherits(Re,_At13);return _createClass(Re,[{key:"consume",value:function consume(){return{type:dt.None};}},{key:"consumeAll",value:function consumeAll(){return{type:dt.None};}},{key:"consumeService",value:function consumeService(){}},{key:"draw",value:function(){var _draw3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24(t){var r,n,i,_this$workOptions16,l,o,a,c,m,f,v,S,E,T,P,_x74;return _regeneratorRuntime().wrap(function _callee24$(_context26){while(1)switch(_context26.prev=_context26.next){case 0:r=t.workId,n=t.layer,i=t.isDrawLabel,_this$workOptions16=this.workOptions,l=_this$workOptions16.boxSize,o=_this$workOptions16.boxPoint,a=_this$workOptions16.zIndex,c=n.worldPosition,m=n.worldScaling;if(!(!o||!l)){_context26.next=3;break;}return _context26.abrupt("return");case 3:f={name:r,id:r,pos:[o[0],o[1]],anchor:[0,0],size:l,zIndex:a},v=new ye(f),S={x:o[0],y:o[1],w:l[0],h:l[1]},E={x:Math.floor(S.x*m[0]+c[0]),y:Math.floor(S.y*m[1]+c[1]),w:Math.floor(S.w*m[0])+2,h:Math.floor(S.h*m[1])+2};if(!(this.replace(n,r,v),i&&n&&this.workOptions.text)){_context26.next=11;break;}_context26.next=7;return Re.createLabels(this.workOptions,n,E);case 7:T=_context26.sent;P=T.labels;_x74=T.maxWidth;v.append.apply(v,_toConsumableArray(P)),E.w=Math.ceil(Math.max(_x74*n.worldScaling[0],E.w));case 11:return _context26.abrupt("return",E);case 12:case"end":return _context26.stop();}},_callee24,this);}));function draw(_x73){return _draw3.apply(this,arguments);}return draw;}()},{key:"consumeServiceAsync",value:function(){var _consumeServiceAsync2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25(t){var c,m,f,v,r,n,i,l,o,a;return _regeneratorRuntime().wrap(function _callee25$(_context27){while(1)switch(_context27.prev=_context27.next){case 0:r=(c=this.workId)==null?void 0:c.toString();if(r){_context27.next=3;break;}return _context27.abrupt("return");case 3:n=t.isFullWork,i=t.replaceId,l=t.isDrawLabel;this.oldRect=i&&((f=(m=this.vNodes)==null?void 0:m.get(i))==null?void 0:f.rect)||void 0;o=n?this.fullLayer:this.drawLayer||this.fullLayer;_context27.next=8;return this.draw({workId:r,layer:o,isDrawLabel:_typeof(l)>"u"&&this.workOptions.workState===Ft.Done||l});case 8:a=_context27.sent;return _context27.abrupt("return",((v=this.vNodes)==null||v.setInfo(r,{rect:a,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&At.getCenterPos(a,o)}),a));case 10:case"end":return _context27.stop();}},_callee25,this);}));function consumeServiceAsync(_x75){return _consumeServiceAsync2.apply(this,arguments);}return consumeServiceAsync;}()},{key:"updataOptService",value:function updataOptService(){}},{key:"updataOptServiceAsync",value:function(){var _updataOptServiceAsync=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26(t,r){var E,T,n,i,l,o,a,c,m,f,v,S;return _regeneratorRuntime().wrap(function _callee26$(_context28){while(1)switch(_context28.prev=_context28.next){case 0:if(this.workId){_context28.next=2;break;}return _context28.abrupt("return");case 2:n=this.workId.toString(),i=t.fontColor,l=t.fontBgColor,o=t.bold,a=t.italic,c=t.lineThrough,m=t.underline,f=t.zIndex,v=(E=this.vNodes)==null?void 0:E.get(n);if(v){_context28.next=5;break;}return _context28.abrupt("return");case 5:i&&(v.opt.fontColor=i),l&&(v.opt.fontBgColor=l),o&&(v.opt.bold=o),a&&(v.opt.italic=a),ke(c)&&(v.opt.lineThrough=c),ke(m)&&(v.opt.underline=m),he(f)&&(v.opt.zIndex=f),this.oldRect=v.rect;_context28.next=8;return this.draw({workId:n,layer:this.fullLayer,isDrawLabel:_typeof(r)>"u"&&this.workOptions.workState===Ft.Done||r});case 8:S=_context28.sent;return _context28.abrupt("return",((T=this.vNodes)==null||T.setInfo(n,{rect:S,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:S&&At.getCenterPos(S,this.fullLayer)}),S));case 10:case"end":return _context28.stop();}},_callee26,this);}));function updataOptServiceAsync(_x76,_x77){return _updataOptServiceAsync.apply(this,arguments);}return updataOptServiceAsync;}()},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"getSafetySnippetRatio",value:function getSafetySnippetRatio(t){var r=(t==null?void 0:t.parent).displayRatio||1,n=Math.ceil(t.worldScaling[0]*10)/10;var i=n;return n>=0.2&&n<1?i=n*r:n<=2&&n>=1?i=n*r*1.6:n>2&&n<=3?i=n*r*1.4:n>3&&n<=4?i=n*r*0.8:n>4&&(i=n*r*0.6),Math.floor(i*1e3)/1e3;}},{key:"getSafetySnippetFontLength",value:function getSafetySnippetFontLength(t){return Math.floor(Re.textImageSnippetSize*3/4/t)||1;}},{key:"createLabels",value:function(){var _createLabels=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27(t,r,n){var b,i,l,o,_ref168,a,c,m,f,v,S,E,T,P,x,h,p,d,g,O,w,L,B,A,W,D,R,X,H,J,et,it,$,V,rt,ct,gt,st,Ct,xt,F,U,K,q,lt,_st2,_Ct,_xt,_st3,_Ct2,_ct3,_gt2;return _regeneratorRuntime().wrap(function _callee27$(_context29){while(1)switch(_context29.prev=_context29.next){case 0:i=[],l=n.x,o=n.y,_ref168=(b=r.parent)==null?void 0:b.parent,a=_ref168.width,c=_ref168.height,m=Qe(t.text),f=m.length,v=t.fontSize,S=t.lineHeight,E=t.bold,T=t.textAlign,P=t.italic,x=t.fontFamily,h=t.verticalAlign,p=t.fontColor,d=t.fontBgColor,g=t.underline,O=t.lineThrough,w=Re.getSafetySnippetRatio(r)||1,L=Math.floor(v*w),B=Re.getSafetySnippetFontLength(L);A=0;W=0;case 3:if(!(W<f)){_context29.next=33;break;}D=m[W],R=S||L*1.5;if(!D){_context29.next=30;break;}X=Cm(D),H=[0,0],J=[0,v*1.2];h==="middle"&&(H[1]=W*v*1.2+5);et=[0,-v*0.15];H[0]=5;it=Math.sin(Math.PI/180*20);$=0;V=[];rt=0;case 14:if(!(rt<X)){_context29.next=27;break;}T==="left"&&(et[0]=$),rt===0&&P==="italic"&&(et[0]=et[0]-it/2*v);ct=D.slice(rt,rt+B);gt={anchor:[0,0],pos:et,text:ct,fontFamily:x,fontSize:L,lineHeight:R,strokeColor:p,fontWeight:E,fillColor:p,textAlign:T,fontStyle:P,scale:[1/w,1/w]};st=new so(gt);_context29.next=21;return st.textImageReady;case 21:Ct=_context29.sent;xt=!0;if(Ct){F=Ct.rect&&Ct.rect[2],U=Ct.rect&&Ct.rect[3];if(F&&U){K=F/w,q=U/w;$=K+$,P==="italic"&&(E==="bold"?$=$-it*v*1.2:$=$-it*v),((et[0]+H[0]+K)*r.worldScaling[0]+l<=0||(et[0]+H[0])*r.worldScaling[0]+l>=a||(et[1]+H[1]+q)*r.worldScaling[1]+o<=0||(et[1]+H[1])*r.worldScaling[1]+o>=c)&&(st.disconnect(),xt=!1),xt&&V.push(st);}}rt+=B;case 25:_context29.next=14;break;case 27:J[0]=$,P==="italic"&&(J[0]=J[0]+it*v),A=Math.max(A,J[0]);lt=!0;if(((H[0]+J[0])*r.worldScaling[0]+l<=0||H[0]*r.worldScaling[0]+l>=a||(H[1]+J[1])*r.worldScaling[0]+o<=0||H[1]*r.worldScaling[1]+o>=c)&&(lt=!1),lt){if(g){_st2=Math.floor(v/10),_Ct={normalize:!1,pos:[0,v*1.1+_st2/2],lineWidth:_st2,points:[0,0,Math.ceil(J[0]),0],strokeColor:p,className:"underline"},_xt=new we(_Ct);V.push(_xt);}if(O){_st3={normalize:!1,pos:[0,v*1.2/2],lineWidth:Math.floor(v/10),points:[0,0,Math.ceil(J[0]),0],strokeColor:p,className:"lineThrough"},_Ct2=new we(_st3);V.push(_Ct2);}_ct3={pos:H,anchor:[0,0],size:J,bgcolor:d},_gt2=new ye(_ct3);_gt2.append.apply(_gt2,V),i.push(_gt2);}case 30:W++;_context29.next=3;break;case 33:return _context29.abrupt("return",{labels:i,maxWidth:A});case 34:case"end":return _context29.stop();}},_callee27);}));function createLabels(_x78,_x79,_x80){return _createLabels.apply(this,arguments);}return createLabels;}()},{key:"updateNodeOpt",value:function updateNodeOpt(t){var r=t.node,n=t.opt,i=t.vNodes,l=t.targetNode,o=n.fontBgColor,a=n.fontColor,c=n.translate,m=n.originPoint,f=n.scenePoint,v=n.scale,S=n.bold,E=n.italic,T=n.lineThrough,P=n.underline,x=n.fontSize,h=n.textInfos,p=n.zIndex,d=l&&ue(l)||i.get(r.name);if(!d||!r.parent)return;var O=d.opt;if(he(p)&&(r.setAttribute("zIndex",p),d.opt.zIndex=p),a&&O.fontColor&&(O.fontColor=a,r.children.forEach(function(w){w.tagName==="GROUP"&&w.children.forEach(function(L){L.tagName==="LABEL"?(L.setAttribute("fillColor",a),L.setAttribute("strokeColor",a)):L.tagName==="POLYLINE"&&L.setAttribute("strokeColor",a);});})),o&&O.fontBgColor&&(O.fontBgColor=o,r.children.forEach(function(w){w.tagName==="GROUP"&&w.setAttribute("bgcolor",o);})),S&&(O.bold=S),E&&(O.italic=E),ke(T)&&(O.lineThrough=T),ke(P)&&(O.underline=P),x&&(O.fontSize=x),m&&f&&v&&l&&O.boxPoint){var w=h==null?void 0:h.get(r.name);if(w){var b=w.fontSize,W=w.boxSize;O.boxSize=W||O.boxSize,O.fontSize=b||O.fontSize;}var L=[O.boxPoint[0],O.boxPoint[1]];vn(O.boxPoint,f,v,c);var B=[d.op[0],d.op[1]],A=[B[0]-L[0],B[1]-L[1]];if(d.centerPos=[d.centerPos[0]+A[0],d.centerPos[1]+A[1]],d.opt.eraserlines){var _iterator33=_createForOfIteratorHelper(d.opt.eraserlines),_step33;try{for(_iterator33.s();!(_step33=_iterator33.n()).done;){var _b20=_step33.value;var _W10=_b20.op,D=_b20.thickness;_b20.thickness=Math.round(D*Math.max(v[0],v[1]));for(var R=0;R<_W10.length;R++)yn(_W10[R],f,v,c);}}catch(err){_iterator33.e(err);}finally{_iterator33.f();}}}else if(c&&O.boxPoint&&(O.boxPoint=[O.boxPoint[0]+c[0],O.boxPoint[1]+c[1]],d.centerPos=[d.centerPos[0]+c[0],d.centerPos[1]+c[1]],d.opt.eraserlines)){var _iterator34=_createForOfIteratorHelper(d.opt.eraserlines),_step34;try{for(_iterator34.s();!(_step34=_iterator34.n()).done;){var _w7=_step34.value;var _L6=_w7.op;for(var _B22=0;_B22<_L6.length;_B22++){var _A20=_L6[_B22].map(function(b,W){return W%2?b+c[1]:b+c[0];});_w7.op[_B22]=_A20;}}}catch(err){_iterator34.e(err);}finally{_iterator34.f();}}return d&&i.setInfo(r.name,d),d==null?void 0:d.rect;}},{key:"getRectFromLayer",value:function getRectFromLayer(t,r){var n=t.getElementsByName(r)[0];if(n){var i=n.getBoundingClientRect();var l={x:Math.floor(i.x),y:Math.floor(i.y),w:Math.floor(i.width+2),h:Math.floor(i.height+2)};return n.children.forEach(function(o){if(o.tagName==="GROUP"){var a=n.getBoundingClientRect();l=bt(l,{x:Math.floor(a.x),y:Math.floor(a.y),w:Math.floor(a.width+2),h:Math.floor(a.height+2)});}}),l;}}}]);}(At);// 4k
437
437
  ot(Re,"textImageSnippetSize",1024*4),ot(Re,"SafeBorderPadding",30);var cr=Re;var Ke=/*#__PURE__*/function(_At14){function Ke(t){var _this85;_classCallCheck(this,Ke);_this85=_callSuper(this,Ke,[t]);ot(_this85,"canRotate",!1);ot(_this85,"scaleType",Qt.none);ot(_this85,"toolsType",pt.PencilEraser);ot(_this85,"tmpPoints",[]);ot(_this85,"workOptions");ot(_this85,"worldPosition");ot(_this85,"worldScaling");ot(_this85,"eraserRect");ot(_this85,"eraserPolyline");_this85.workOptions=t.toolsOpt,_this85.worldPosition=_this85.fullLayer.worldPosition,_this85.worldScaling=_this85.fullLayer.worldScaling;return _this85;}/** 批量合并消费本地数据,返回绘制结果 */_inherits(Ke,_At14);return _createClass(Ke,[{key:"combineConsume",value:function combineConsume(t){var r=t.workerEngine;if(this.tmpPoints.length<2)return{type:dt.None};var n=this.workOptions.thickness,_Ke$eraserSizes$n=Ke.eraserSizes[n],i=_Ke$eraserSizes$n.width,l=_Ke$eraserSizes$n.height,o=Math.round(Math.max(i,l)/this.worldScaling[0]),_this$getChangeNodes=this.getChangeNodes(o,r),a=_this$getChangeNodes.rect,c=_this$getChangeNodes.willNewNodes,m=_this$getChangeNodes.willDeleteNodes;return _objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:dt.DrawWork,rect:a,willNewNodes:c,willDeleteNodes:m});}},{key:"consumeService",value:function consumeService(){}},{key:"updateTempPoints",value:function updateTempPoints(t,r){var n=this.tmpPoints.length-1;var i=Date.now();for(var l=0;l<t.length;l+=2){var o=this.tmpPoints.length,a=new Nt(t[l],t[l+1]);if(o===0){this.tmpPoints.push(a);continue;}var c=o-1,m=this.tmpPoints[c],f=at.Sub(a,m).uni();a.isNear(m,r/2)||(at.Equals(f,m.v,0.02)&&(this.tmpPoints.pop(),n--),a.setv(f),a.setT(i),this.tmpPoints.push(a));}return Math.max(n,0);}},{key:"getChangeNodes",value:function getChangeNodes(t,r){var n=/* @__PURE__ */new Map(),i=/* @__PURE__ */new Set();var l;if(!this.vNodes)return{willDeleteNodes:i,willNewNodes:n,rect:l};var o=this.worldPosition;var a=_t(this.tmpPoints,t);a=fr(a,o),a=as(a,this.worldScaling,o);var _this$vNodes$getRectI3=this.vNodes.getRectIntersectRange(a),c=_this$vNodes$getRectI3.nodeRange;if(!c.size)return{willDeleteNodes:i,willNewNodes:n,rect:l};var m=this.computEraserPointLines(this.tmpPoints,90);var _iterator35=_createForOfIteratorHelper(c.entries()),_step35;try{for(_iterator35.s();!(_step35=_iterator35.n()).done;){var _step35$value=_slicedToArray(_step35.value,2),f=_step35$value[0],v=_step35$value[1];if(v.toolsType!==pt.Pencil)continue;var S=fr(v.rect,[-o[0],-o[1]]);S={x:S.x/this.worldScaling[0],y:S.y/this.worldScaling[1],w:S.w/this.worldScaling[0],h:S.h/this.worldScaling[1]};var E=[S.x,S.y,S.x+S.w,S.y+S.h],T=[],P=[];var _iterator36=_createForOfIteratorHelper(m),_step36;try{for(_iterator36.s();!(_step36=_iterator36.n()).done;){var _x83=_step36.value;un.polyline(_x83,E,T);}}catch(err){_iterator36.e(err);}finally{_iterator36.f();}if(T.length&&v.opt){var _iterator37=_createForOfIteratorHelper(T),_step37;try{for(_iterator37.s();!(_step37=_iterator37.n()).done;){var _x81=_step37.value;var _h42=[];for(var p=0;p<_x81.length;p++)p!==0&&Me(_x81[p],_x81[p-1])||_h42.push.apply(_h42,_toConsumableArray(_x81[p]));P.push(_h42);}}catch(err){_iterator37.e(err);}finally{_iterator37.f();}}if(P.length&&r){var _x82=r.createWorkShapeNode({workId:f,toolsType:pt.Pencil,toolsOpt:v.opt});_x82.setWorkId(f);var _h43=_x82==null?void 0:_x82.computPencilPoints({op:v.op,eraserPolylines:P,eraserThickness:t});if(l=bt(l,v.rect),i.add(f),r.removeNode(f),_h43.length)for(var _p13=0;_p13<_h43.length;_p13++){var d="".concat(f,"_").concat(Date.now(),"_").concat(_p13),g=d,w=r.setFullWork({workId:g,opt:v.opt,toolsType:pt.Pencil}).consumeService({op:_h43[_p13],isFullWork:!0,replaceId:g});r.clearWorkShapeNodeCache(g),l=bt(l,w),n.set(d,_objectSpread(_objectSpread({},v),{},{toolsType:pt.Pencil,rect:w!==null&&w!==void 0?w:v.rect,name:d,op:_h43[_p13]}));}}}}catch(err){_iterator35.e(err);}finally{_iterator35.f();}return{willNewNodes:n,willDeleteNodes:i,rect:l};}},{key:"consume",value:function consume(t){var r=t.data,n=r.op;if(!n||n.length===0)return _objectSpread({type:dt.None},this.baseConsumeResult);var i=this.workOptions.thickness,_Ke$eraserSizes$i=Ke.eraserSizes[i],l=_Ke$eraserSizes$i.width,o=_Ke$eraserSizes$i.height,a=Math.max(l,o)/this.worldScaling[0];return this.updateTempPoints(n,a),_objectSpread({type:dt.None},this.baseConsumeResult);}},{key:"computEraserPointLines",value:function computEraserPointLines(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:60;var n=[];var i=0;var l=360-r;for(var o=1;o<t.length;o++){var a=t[o-1],c=t[o];if(o===1&&i===0&&(n[i]=[a.XY]),n[i].push(c.XY),o<t.length-1){var m=c.getAngleByPoints(a,t[o+1]);(m<r||m>l)&&(i++,n[i]=[c.XY]);}}return t.length===1&&n.length===0&&n.push([t[0].XY,t[0].XY]),n;}},{key:"consumeAll",value:function consumeAll(t){var r=t.workerEngine;if(this.replace(this.fullLayer,this.workId),!this.tmpPoints.length)return _objectSpread({type:dt.None},this.baseConsumeResult);var n=this.workOptions.thickness,_Ke$eraserSizes$n2=Ke.eraserSizes[n],i=_Ke$eraserSizes$n2.width,l=_Ke$eraserSizes$n2.height,o=Math.max(i,l)/this.worldScaling[0],_this$getChangeNodes2=this.getChangeNodes(o,r),a=_this$getChangeNodes2.willDeleteNodes,c=_this$getChangeNodes2.willNewNodes,m=_this$getChangeNodes2.rect;if(a.size===0&&c.size===0)return _objectSpread(_objectSpread({type:dt.FullWork},this.baseConsumeResult),{},{rect:m});var f=[];this.tmpPoints.map(function(S){f.push(S.x,S.y,o/2);});var v=ve(f);return _objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:dt.FullWork,dataType:Dt.Local,rect:m,ops:v,willNewNodes:c,willDeleteNodes:a});}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}]);}(At);// 来源于white-sdk
438
438
  ot(Ke,"eraserSizes",fn);var Er=Ke;var Ze=/*#__PURE__*/function(_At15){function Ze(t){var _this86;_classCallCheck(this,Ze);_this86=_callSuper(this,Ze,[t]);ot(_this86,"canRotate",!1);ot(_this86,"scaleType",Qt.none);ot(_this86,"toolsType",pt.BitMapEraser);ot(_this86,"tmpPoints",[]);ot(_this86,"workOptions");ot(_this86,"worldPosition");ot(_this86,"worldScaling");ot(_this86,"eraserRect");ot(_this86,"eraserPolyline");ot(_this86,"oldRect");_this86.workOptions=t.toolsOpt,_this86.worldPosition=_this86.fullLayer.worldPosition,_this86.worldScaling=_this86.fullLayer.worldScaling;return _this86;}/** 批量合并消费本地数据,返回绘制结果 */_inherits(Ze,_At15);return _createClass(Ze,[{key:"combineConsume",value:function combineConsume(t){var r=t.workerEngine;if(this.tmpPoints.length<2)return{type:dt.None};var n=this.workOptions.thickness,_Ze$eraserSizes$n=Ze.eraserSizes[n],i=_Ze$eraserSizes$n.width,l=_Ze$eraserSizes$n.height,o=Math.round(Math.max(i,l)/this.worldScaling[0]),_this$getChangeNodes3=this.getChangeNodes(o,r),a=_this$getChangeNodes3.willDeleteNodes,c=_this$getChangeNodes3.rect;return _objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:dt.DrawWork,rect:c,willDeleteNodes:a});}},{key:"consumeService",value:function consumeService(){}},{key:"updateTempPoints",value:function updateTempPoints(t,r){var n=this.tmpPoints.length-1;var i=Date.now();for(var l=0;l<t.length;l+=2){var o=this.tmpPoints.length,a=new Nt(t[l],t[l+1]);if(o===0){this.tmpPoints.push(a);continue;}var c=o-1,m=this.tmpPoints[c],f=at.Sub(a,m).uni();a.isNear(m,r/2)||(at.Equals(f,m.v,0.02)&&(this.tmpPoints.pop(),n--),a.setv(f),a.setT(i),this.tmpPoints.push(a));}return Math.max(n,0);}},{key:"getChangeNodes",value:function getChangeNodes(t,r){var _this87=this;var n=/* @__PURE__ */new Map(),i=/* @__PURE__ */new Set();var l;if(!this.vNodes)return{willDeleteNodes:i,willUpdateNodes:n,rect:l};var o=this.worldPosition;var a=_t(this.tmpPoints,t);a=fr(a,o),a=as(a,this.worldScaling,o);var _this$vNodes$getRectI4=this.vNodes.getRectIntersectRange(a),c=_this$vNodes$getRectI4.nodeRange;if(!c.size)return{willDeleteNodes:i,willUpdateNodes:n,rect:l};var m=this.computEraserPointLines(this.tmpPoints,120);var _iterator38=_createForOfIteratorHelper(c.entries()),_step38;try{for(_iterator38.s();!(_step38=_iterator38.n()).done;){var _step38$value=_slicedToArray(_step38.value,2),f=_step38$value[0],v=_step38$value[1];if(v.toolsType===pt.Text||v.toolsType===pt.Image)continue;var S=fr(v.rect,[-o[0],-o[1]]);S={x:S.x/this.worldScaling[0],y:S.y/this.worldScaling[1],w:S.w/this.worldScaling[0],h:S.h/this.worldScaling[1]};var E=[S.x,S.y,S.x+S.w,S.y+S.h],T=[],P=[];var _iterator39=_createForOfIteratorHelper(m),_step39;try{for(_iterator39.s();!(_step39=_iterator39.n()).done;){var _p15=_step39.value;un.polyline(_p15,E,T);}}catch(err){_iterator39.e(err);}finally{_iterator39.f();}if(T.length&&v.opt){var _iterator40=_createForOfIteratorHelper(T),_step40;try{for(_iterator40.s();!(_step40=_iterator40.n()).done;){var p=_step40.value;var d=[];for(var g=0;g<p.length&&!(isNaN(p[g][0])||isNaN(p[g][1]));g++){var O=p[g].map(function(w){return Math.round(w*100)/100;});if(g!==0){var w=p[g-1].map(function(L){return Math.round(L*100)/100;});if(Me(O,w))continue;}d.push.apply(d,_toConsumableArray(O));}d.length!==0&&P.push(d);}}catch(err){_iterator40.e(err);}finally{_iterator40.f();}}if(!P.length)continue;var _x84=v.opt.eraserlines?v.opt.eraserlines:[],_h44=_x84.find(function(p){return p.workId===_this87.workId;});if(_h44?_h44.op=P:_x84.push({workId:this.workId,op:P,thickness:t}),v.opt.eraserlines=_x84,r){var _p14=v.toolsType,_d17=r.createWorkShapeNode({workId:f,toolsType:_p14,toolsOpt:v.opt});_d17==null||_d17.setWorkId(f);var _g13=_d17==null?void 0:_d17.consumeService({op:v.op,isFullWork:!0,replaceId:f});if(l=bt(l,_g13),_d17!=null&&_d17.isDelete){r.removeNode(f),i.add(f);continue;}}n.set(f,v);}}catch(err){_iterator38.e(err);}finally{_iterator38.f();}return{willUpdateNodes:n,willDeleteNodes:i,rect:l};}},{key:"consume",value:function consume(t){var r=t.data,n=r.op;if(!n||n.length===0)return _objectSpread({type:dt.None},this.baseConsumeResult);var i=this.workOptions.thickness,_Ze$eraserSizes$i=Ze.eraserSizes[i],l=_Ze$eraserSizes$i.width,o=_Ze$eraserSizes$i.height,a=Math.round(Math.max(l,o)/this.worldScaling[0]);return this.updateTempPoints(n,a),_objectSpread({type:dt.None},this.baseConsumeResult);}},{key:"computEraserPointLines",value:function computEraserPointLines(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:60;var n=[];var i=0;var l=360-r;for(var o=1;o<t.length;o++){var a=t[o-1],c=t[o];if(o===1&&i===0&&(n[i]=[a.XY]),n[i].push(c.XY),o<t.length-1){var m=c.getAngleByPoints(a,t[o+1]);(m<r||m>l)&&(i++,n[i]=[c.XY]);}}return t.length===1&&n.length===0&&n.push([t[0].XY,t[0].XY]),n;}},{key:"consumeAll",value:function consumeAll(t){var r=t.workerEngine;if(this.replace(this.fullLayer,this.workId),!this.tmpPoints.length)return _objectSpread({type:dt.None},this.baseConsumeResult);var n=this.workOptions.thickness,_Ze$eraserSizes$n2=Ze.eraserSizes[n],i=_Ze$eraserSizes$n2.width,l=_Ze$eraserSizes$n2.height,o=Math.round(Math.max(i,l)/this.worldScaling[0]),_this$getChangeNodes4=this.getChangeNodes(o,r),a=_this$getChangeNodes4.willDeleteNodes,c=_this$getChangeNodes4.willUpdateNodes,m=_this$getChangeNodes4.rect;if(a.size===0&&c.size===0)return _objectSpread(_objectSpread({type:dt.FullWork},this.baseConsumeResult),{},{rect:m});var f=[];this.tmpPoints.map(function(S){f.push(S.x,S.y,o/2);});var v=ve(f);return _objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:dt.FullWork,dataType:Dt.Local,rect:m,ops:v,willUpdateNodes:c,willDeleteNodes:a});}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}]);}(At);// 来源于white-sdk
439
- ot(Ze,"eraserSizes",fn);var Mr=Ze;function is(u){switch(u){case pt.Arrow:return Qi;case pt.Pencil:return Vi;case pt.Straight:return ns;case pt.Ellipse:return qi;case pt.Polygon:case pt.Triangle:return es;case pt.Star:case pt.Rhombus:return ts;case pt.Rectangle:return _i;case pt.SpeechBalloon:return rs;case pt.Text:return cr;case pt.LaserPen:return Ki;case pt.Eraser:return Ir;case pt.PencilEraser:return Er;case pt.BitMapEraser:return Mr;case pt.Selector:return ar;case pt.Image:return lr;}}function Ur(u,e){var t=u.toolsType,r=_objectWithoutProperties(u,_excluded);switch(t){case pt.Arrow:return new Qi(r);case pt.Pencil:return new Vi(r);case pt.Straight:return new ns(r);case pt.Ellipse:return new qi(r);case pt.Polygon:case pt.Triangle:return new es(r);case pt.Star:case pt.Rhombus:return new ts(r);case pt.Rectangle:return new _i(r);case pt.SpeechBalloon:return new rs(r);case pt.Text:return new cr(r);case pt.LaserPen:return new Ki(r);case pt.Eraser:return new Ir(r,e);case pt.BitMapEraser:return new Mr(r);case pt.PencilEraser:return new Er(r);case pt.Selector:return r.vNodes?new ar(_objectSpread(_objectSpread({},r),{},{vNodes:r.vNodes,drawLayer:r.fullLayer})):void 0;case pt.Image:return new lr(r);default:return;}}function ss(u){var e=[],t=["PATH","SPRITE","POLYLINE","RECT","ELLIPSE","LABEL"];var _iterator41=_createForOfIteratorHelper(u),_step41;try{for(_iterator41.s();!(_step41=_iterator41.n()).done;){var r=_step41.value;if(r.tagName==="GROUP"&&r.children.length){var n=ss(r.children);e.push.apply(e,_toConsumableArray(n));}r.tagName&&t.includes(r.tagName)&&e.push(r);}}catch(err){_iterator41.e(err);}finally{_iterator41.f();}return e;}function bt(u,e){if(u&&e){var t=Math.min(u.x,e.x),r=Math.min(u.y,e.y),n=Math.max(u.x+u.w,e.x+e.w),i=Math.max(u.y+u.h,e.y+e.h),l=n-t,o=i-r;return{x:t,y:r,w:l,h:o};}return e||u;}function _t(u){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var t={x:0,y:0,w:0,h:0};var r=1/0,n=1/0,i=-1/0,l=-1/0;return u.forEach(function(o){var _o$XY=_slicedToArray(o.XY,2),a=_o$XY[0],c=_o$XY[1];r=Math.min(r,a-e),n=Math.min(n,c-e),i=Math.max(i,a+e),l=Math.max(l,c+e);}),t.x=r,t.y=n,t.w=i-r,t.h=l-n,t;}function Jr(u,e){return!(u.x+u.w<e.x||u.x>e.x+e.w||u.y+u.h<e.y||u.y>e.y+e.h);}function kt(u){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;return{x:Math.floor(u.x-e),y:Math.floor(u.y-e),w:Math.ceil(u.w+e*2),h:Math.ceil(u.h+e*2)};}function fr(u,e){return{x:u.x+e[0],y:u.y+e[1],w:u.w,h:u.h};}function dm(u,e){var t=new at(u.x,u.y),r=new at(u.x+u.w,u.y),n=new at(u.x+u.w,u.y+u.h),i=new at(u.x,u.y+u.h),l=new at(u.x+u.w/2,u.y+u.h/2),o=Math.PI*e/180,a=at.RotWith(t,l,o),c=at.RotWith(r,l,o),m=at.RotWith(n,l,o),f=at.RotWith(i,l,o);return[a,c,m,f];}function os(u,e){var t=dm(u,e);return _t(t);}function as(u,e,t){var r=new at(u.x,u.y),n=new at(u.x+u.w,u.y),i=new at(u.x+u.w,u.y+u.h),l=new at(u.x,u.y+u.h),o=new at(t[0],t[1]),a=new at(e[0],e[1]),c=at.ScaleWOrigin(r,a,o),m=at.ScaleWOrigin(n,a,o),f=at.ScaleWOrigin(i,a,o),v=at.ScaleWOrigin(l,a,o);return _t([c,m,f,v]);}function pm(u,e,t){var r=new at(e[0],e[1]);for(var n=0;n<u.length;n+=3){var i=new at(u[n],u[n+1]),l=Math.PI*t/180,o=at.RotWith(i,r,l);u[n]=o.x,u[n+1]=o.y;}}function mm(u,e,t){var r=new at(e[0],e[1]);for(var n=0;n<u.length;n+=2){var i=new at(u[n],u[n+1]),l=Math.PI*t/180,o=at.RotWith(i,r,l);u[n]=o.x,u[n+1]=o.y;}}function vn(u,e,t){var r=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[0,0];var n=new at(e[0],e[1]);for(var i=0;i<u.length;i+=3){var l=new at(u[i],u[i+1]),o=new at(t[0],t[1]),a=at.ScaleWOrigin(l,o,n);u[i]=a.x+r[0],u[i+1]=a.y+r[1];}}function yn(u,e,t){var r=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[0,0];var n=new at(e[0],e[1]);for(var i=0;i<u.length;i+=2){var l=new at(u[i],u[i+1]),o=new at(t[0],t[1]),a=at.ScaleWOrigin(l,o,n);u[i]=a.x+r[0],u[i+1]=a.y+r[1];}}function vm(u,e){return u[0]>=e.x&&u[0]<=e.x+e.w&&u[1]>=e.y&&u[1]<=e.y+e.h;}function ls(u,e){var t=u<=e?1:u/e,r=e<=u?1:e/u;return[t,r];}function ym(u){var _iterator42=_createForOfIteratorHelper(u),_step42;try{for(_iterator42.s();!(_step42=_iterator42.n()).done;){var _e3=_step42.value;if(isNaN(_e3)||_e3===1/0||_e3===-1/0)return!1;}}catch(err){_iterator42.e(err);}finally{_iterator42.f();}return!0;}function gm(u){return u!==Math.floor(u);}function Pm(u){var e=u.toString();return e.indexOf(".")!==-1?e.split(".")[1].length:0;}function Sm(u,e){for(;e!==0;){var _ref169=[e,u%e];u=_ref169[0];e=_ref169[1];}return u;}var xm=function xm(u){if(u.tagName==="GROUP"){var _e4=Object.getOwnPropertySymbols(u).find(function(t){return t.toString()==="Symbol(sealed)";});if(_e4&&u[_e4])return!0;}return!1;},_pe=function pe(u,e){if(u.mesh&&u.mesh.texture&&u.name==="eraserTexture"){var t=u.mesh.texture.image;e.deleteTexture(t);}else if(u.tagName==="GROUP"&&u&&u.children){var _iterator43=_createForOfIteratorHelper(u.children),_step43;try{for(_iterator43.s();!(_step43=_iterator43.n()).done;){var _t3=_step43.value;_pe(_t3,e);}}catch(err){_iterator43.e(err);}finally{_iterator43.f();}}},Se=function Se(u,e){_pe(u,e),u.removeAllChildren();},Tm=function Tm(u,e,t){var r=t.parent;if(e){var n=e.children;if(n){var _iterator44=_createForOfIteratorHelper(n),_step44;try{for(_iterator44.s();!(_step44=_iterator44.n()).done;){var i=_step44.value;if(_pe(i,r),i.tagName==="GROUP"){var _iterator45=_createForOfIteratorHelper(i.children),_step45;try{for(_iterator45.s();!(_step45=_iterator45.n()).done;){var l=_step45.value;_pe(l,r);}}catch(err){_iterator45.e(err);}finally{_iterator45.f();}}}}catch(err){_iterator44.e(err);}finally{_iterator44.f();}}}e.parent.replaceChild(u,e);},cs=function cs(u,e,t){if(u.w+u.x<=0||u.h+u.y<=0||u.w<=0||u.h<=0)return;var r=e.width,n=e.height,i={x:Math.floor(Math.max(0,u.x)),y:Math.floor(Math.max(0,u.y)),w:Math.floor(Math.min(r,u.w)),h:Math.floor(Math.min(n,u.h))};if(i.x+i.w>r&&(i.w=Math.floor(r-i.x)),i.y+i.h>n&&(i.h=Math.floor(n-i.y)),gm(t)){var l=Pm(t),o=Math.pow(10,l),a=Sm(o,t*o),c=i.x%a,m=i.x-c;m>=0?(i.x=m,i.w=i.w+c):(i.x=0,i.w=i.w+c-m);var f=i.y%a,v=i.y-f;v>=0?(i.y=v,i.h=i.h+f):(i.y=0,i.h=i.h+f-v);}return i;};function ze(u){return"".concat(Ar(u.x),",").concat(Ar(u.y)," ");}function $e(u,e){return"".concat(Ar((u.x+e.x)/2),",").concat(Ar((u.y+e.y)/2)," ");}function Ar(u){return+u.toFixed(4);}var or=function or(u,e){return u.x+u.w<e.x||u.x>e.x+e.w||u.y+u.h<e.y||u.y>e.y+e.h?Pe.outside:u.x>=e.x&&u.y>=e.y&&u.x+u.w<=e.x+e.w&&u.y+u.h<=e.y+e.h?Pe.inside:Pe.intersect;};function Cm(u){var e=0;for(var t=0;t<u.length;t++){var r=u.charCodeAt(t);r>=1&&r<=126||65376<=r&&r<=65439?e++:e+=2;}return e;}var He="cursorhover",si=20,hr="mainView";var Im=/*#__PURE__*/function(){function Im(e,t){_classCallCheck(this,Im);ot(this,"viewId");ot(this,"scene");ot(this,"fullLayer");ot(this,"curNodeMap",/* @__PURE__ */new Map());ot(this,"targetNodeMap",[]);ot(this,"highLevelIds");ot(this,"canClearUids");ot(this,"localUid");this.viewId=e,this.scene=t;}return _createClass(Im,[{key:"init",value:function init(e){this.fullLayer=e;}},{key:"get",value:function get(e){return this.curNodeMap.get(e);}},{key:"setLocalUid",value:function setLocalUid(e){this.localUid=e;}},{key:"getLocalUid",value:function getLocalUid(){return this.localUid;}},{key:"setCanClearUids",value:function setCanClearUids(e){this.canClearUids=e;}},{key:"getCanClearUids",value:function getCanClearUids(){return this.canClearUids;}},{key:"getCanEraserNodes",value:function getCanEraserNodes(e,t){var r=/* @__PURE__ */new Map();var _iterator46=_createForOfIteratorHelper(e.entries()),_step46;try{for(_iterator46.s();!(_step46=_iterator46.n()).done;){var _step46$value=_slicedToArray(_step46.value,2),n=_step46$value[0],i=_step46$value[1];i.toolsType===pt.Image&&(i.opt.locked||t&&t.disableEraseImage)||i.toolsType===pt.Text&&(i.opt.workState===Ft.Doing||i.opt.workState===Ft.Start||t&&t.disableEraseText)||this.isCanClearWorkId(n)&&r.set(n,i);}}catch(err){_iterator46.e(err);}finally{_iterator46.f();}return r;}},{key:"getNodesByType",value:function getNodesByType(e){var t=/* @__PURE__ */new Map();return this.curNodeMap.forEach(function(r,n){r.toolsType===e&&t.set(n,r);}),t;}},{key:"gethasEraserNodes",value:function gethasEraserNodes(){var e=/* @__PURE__ */new Map();return this.curNodeMap.forEach(function(t,r){var n;(n=t.opt.eraserlines)!=null&&n.length&&e.set(r,t);}),e;}},{key:"hasRenderNodes",value:function hasRenderNodes(){return!0;}},{key:"has",value:function has(e){return this.curNodeMap.has(e);}},{key:"setInfo",value:function setInfo(e,t){var r=this.curNodeMap.get(e)||{name:e,rect:t.rect};t.rect&&(r.rect=he(t.rect)),t.op&&ym(t.op)&&(r.op=he(t.op)),t.canRotate&&(r.canRotate=t.canRotate),t.scaleType&&(r.scaleType=t.scaleType),t.opt&&(r.opt=he(t.opt)),t.toolsType&&(r.toolsType=t.toolsType),t.centerPos&&(r.centerPos=he(t.centerPos)),ke(t.isSelected)&&(r.isSelected=t.isSelected),r.rect?this.curNodeMap.set(e,r):this.curNodeMap["delete"](e);}},{key:"selected",value:function selected(e){this.setInfo(e,{isSelected:!0});}},{key:"unSelected",value:function unSelected(e){this.setInfo(e,{isSelected:!1});}},{key:"delete",value:function _delete(e){this.curNodeMap["delete"](e);}},{key:"clear",value:function clear(){this.curNodeMap.clear(),this.targetNodeMap.length=0;}},{key:"getRectIntersectRange",value:function getRectIntersectRange(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!0;var n;var i=/* @__PURE__ */new Map();var _iterator47=_createForOfIteratorHelper(this.curNodeMap.entries()),_step47;try{for(_iterator47.s();!(_step47=_iterator47.n()).done;){var _step47$value=_slicedToArray(_step47.value,2),l=_step47$value[0],o=_step47$value[1];if(Jr(e,o.rect)){if(t&&o.toolsType===pt.Image&&o.opt.locked||r&&o.toolsType===pt.Text&&(o.opt.workState===Ft.Doing||o.opt.workState===Ft.Start))continue;n=bt(n,o.rect),i.set(l,o);}}}catch(err){_iterator47.e(err);}finally{_iterator47.f();}return{rectRange:n,nodeRange:i};}},{key:"getNodeRectFormShape",value:function getNodeRectFormShape(e,t){var r=is(t.toolsType);return this.fullLayer&&(r==null?void 0:r.getRectFromLayer(this.fullLayer,e));}},{key:"updateNodeRect",value:function updateNodeRect(e){var t=this.curNodeMap.get(e);if(t){var r=this.getNodeRectFormShape(e,t);if(!r){this.curNodeMap["delete"](e);return;}t.rect=r,this.curNodeMap.set(e,t);}}},{key:"updateHighLevelNodesRect",value:function updateHighLevelNodesRect(e){this.highLevelIds=e;var _iterator48=_createForOfIteratorHelper(this.highLevelIds.keys()),_step48;try{for(_iterator48.s();!(_step48=_iterator48.n()).done;){var t=_step48.value;this.updateNodeRect(t);}}catch(err){_iterator48.e(err);}finally{_iterator48.f();}}},{key:"updateLowLevelNodesRect",value:function updateLowLevelNodesRect(){var e;var _iterator49=_createForOfIteratorHelper(this.curNodeMap.keys()),_step49;try{for(_iterator49.s();!(_step49=_iterator49.n()).done;){var t=_step49.value;(e=this.highLevelIds)!=null&&e.has(t)||this.updateNodeRect(t);}}catch(err){_iterator49.e(err);}finally{_iterator49.f();}}},{key:"clearHighLevelIds",value:function clearHighLevelIds(){this.highLevelIds=void 0;}},{key:"setTargetAssignKeys",value:function setTargetAssignKeys(e){var t=/* @__PURE__ */new Map();var _iterator50=_createForOfIteratorHelper(e),_step50;try{for(_iterator50.s();!(_step50=_iterator50.n()).done;){var r=_step50.value;var n=this.curNodeMap.get(r);n&&t.set(r,he(n));}}catch(err){_iterator50.e(err);}finally{_iterator50.f();}return this.targetNodeMap.push(he(t)),this.targetNodeMap.length-1;}},{key:"setTarget",value:function setTarget(){return this.targetNodeMap.push(he(this.curNodeMap)),this.targetNodeMap.length-1;}},{key:"getLastTarget",value:function getLastTarget(){return this.targetNodeMap[this.targetNodeMap.length-1];}},{key:"deleteLastTarget",value:function deleteLastTarget(){this.targetNodeMap.length&&(this.targetNodeMap.length=this.targetNodeMap.length-1);}},{key:"getTarget",value:function getTarget(e){return this.targetNodeMap[e];}},{key:"deleteTarget",value:function deleteTarget(e){this.targetNodeMap.length=e;}},{key:"clearTarget",value:function clearTarget(){this.targetNodeMap.length=0;}},{key:"isLocalWorkId",value:function isLocalWorkId(e){return e.split(Je).length===1;}},{key:"isCanClearWorkId",value:function isCanClearWorkId(e){if(this.canClearUids===void 0||this.canClearUids===!0)return!0;if(Vd(this.canClearUids)){var t=e.split(Je);if(t.length===1)return this.canClearUids.has("localSelf")||this.localUid&&this.canClearUids.has(this.localUid);if(t.length===2)return this.canClearUids.has(t[0]);}return!1;}}]);}();var fs=/*#__PURE__*/function(){function fs(e,t,r){_classCallCheck(this,fs);ot(this,"viewId");ot(this,"type");ot(this,"scene");ot(this,"fullLayer");ot(this,"vNodes");ot(this,"dpr");ot(this,"contextType");ot(this,"opt");ot(this,"cameraOpt");ot(this,"isSafari",!1);ot(this,"combinePostMsg",/* @__PURE__ */new Set());ot(this,"workerTaskId");ot(this,"protectedTask");// protected hasPriorityDraw: boolean = true;
440
- ot(this,"delayPostDoneResolve");ot(this,"cacheImages",/* @__PURE__ */new Map());ot(this,"imageResolveMap",/* @__PURE__ */new Map());ot(this,"taskUpdateCameraId");ot(this,"debounceUpdateCameraId");var n,i;if(this.viewId=e,this.type=r,this.opt=t,this.dpr=t.dpr,this.contextType=this.getSupportContextType(r,(n=t==null?void 0:t.offscreenCanvasOpt)==null?void 0:n.contextType),!this.contextType)throw new Error("Sorry, your browser doesn't support canvas context type 2d or webgl");try{this.scene=this.createScene(t),this.createRenderLayer(this.scene,t);}catch(l){if(this.contextType!=="2d")this.contextType="2d",(i=this.scene)==null||i.disconnect(),this.scene=this.createScene(t),this.createRenderLayer(this.scene,t);else throw l;}this.vNodes=new Im(e,this.scene);}return _createClass(fs,[{key:"createRenderLayer",value:function createRenderLayer(e,t){var r=me.bufferSize.full,n=me.bufferSize.sub;this.fullLayer=this.createLayer("fullLayer",e,_objectSpread(_objectSpread({},t.layerOpt),{},{bufferSize:this.viewId===hr?r:n*2}));}},{key:"updateDpr",value:function(){var _updateDpr=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28(e){return _regeneratorRuntime().wrap(function _callee28$(_context30){while(1)switch(_context30.prev=_context30.next){case 0:this.dpr=e,this.scene.displayRatio=e;case 1:case"end":return _context30.stop();}},_callee28,this);}));function updateDpr(_x85){return _updateDpr.apply(this,arguments);}return updateDpr;}()},{key:"getCachedImages",value:function getCachedImages(e){var t;return(t=this.cacheImages.get(e))==null?void 0:t.imageBitmap;}},{key:"getCachedImagesByWorkId",value:function getCachedImagesByWorkId(e){var _iterator51=_createForOfIteratorHelper(this.cacheImages.entries()),_step51;try{for(_iterator51.s();!(_step51=_iterator51.n()).done;){var _step51$value=_slicedToArray(_step51.value,2),t=_step51$value[0],r=_step51$value[1];if(t===e&&r.imageBitmap)return r.imageBitmap;}}catch(err){_iterator51.e(err);}finally{_iterator51.f();}}},{key:"deleteCachedImagesByWorkId",value:function deleteCachedImagesByWorkId(e,t){var _iterator52=_createForOfIteratorHelper(this.cacheImages.entries()),_step52;try{for(_iterator52.s();!(_step52=_iterator52.n()).done;){var _step52$value=_slicedToArray(_step52.value,2),r=_step52$value[0],n=_step52$value[1];t&&r===t||n.workId===e&&(n.imageBitmap.close(),this.cacheImages["delete"](r));}}catch(err){_iterator52.e(err);}finally{_iterator52.f();}}},{key:"clearCacheImages",value:function clearCacheImages(){this.cacheImages.forEach(function(e){return e.imageBitmap.close();}),this.cacheImages.clear();}},{key:"clearImageResolveMap",value:function clearImageResolveMap(){this.imageResolveMap.forEach(function(_ref170){var e=_ref170.timer;e&&clearTimeout(e);}),this.imageResolveMap.clear();}},{key:"setIsSafari",value:function setIsSafari(e){this.isSafari=e;}},{key:"on",value:function(){var _on=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee29(e){var t,r,n,i,l,o,a,c,_c7,m,f,v;return _regeneratorRuntime().wrap(function _callee29$(_context31){while(1)switch(_context31.prev=_context31.next){case 0:t=e.msgType,r=e.toolsType,n=e.opt,i=e.imageSrc,l=e.imageBitmap,o=e.workId,a=e.dpr;_context31.t0=t;_context31.next=_context31.t0===dt.UpdateDpr?4:_context31.t0===dt.UpdateCamera?9:_context31.t0===dt.Destroy?12:_context31.t0===dt.Clear?14:_context31.t0===dt.UpdateTools?17:_context31.t0===dt.GetImageBitMap?19:21;break;case 4:_context31.t1=ue(a);if(!_context31.t1){_context31.next=8;break;}_context31.next=8;return this.updateDpr(a);case 8:return _context31.abrupt("break",21);case 9:_context31.next=11;return this.updateCamera(e);case 11:return _context31.abrupt("break",21);case 12:this.destroy();return _context31.abrupt("break",21);case 14:_context31.next=16;return this.clearAll();case 16:return _context31.abrupt("break",21);case 17:if(r&&n){c={toolsType:r,toolsOpt:n,combineUnitTime:e.combineUnitTime,maxCombineEraserTime:e.maxCombineEraserTime};this.localWork.setToolsOpt(c);}return _context31.abrupt("break",21);case 19:if(i&&l&&o){_c7=o.toString();this.cacheImages.set(i,{imageBitmap:l,workId:_c7});m=this.imageResolveMap.get(i);if(m){f=m.resolve,v=m.timer;v&&clearTimeout(v),f&&f(i);}this.deleteCachedImagesByWorkId(_c7,i);}return _context31.abrupt("break",21);case 21:case"end":return _context31.stop();}},_callee29,this);}));function on(_x86){return _on.apply(this,arguments);}return on;}()},{key:"getIconSize",value:function getIconSize(e,t,r){var n=e*r,i=t*r;return n<=50||i<=50?[50,50]:n<=100||i<=100?[100,100]:n<=200||i<=200?[200,200]:n<=400||i<=400?[400,400]:n<=800||i<=800?[800,800]:[1600,1600];}},{key:"loadImageBitMap",value:function(){var _loadImageBitMap=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee30(e){var _this88=this;var t,r,n,i,l,o,a,c,m,f,v,_this$getIconSize,_this$getIconSize2,P,_x88,_P20,_P21,T;return _regeneratorRuntime().wrap(function _callee30$(_context32){while(1)switch(_context32.prev=_context32.next){case 0:t=e.toolsType,r=e.opt,n=e.workId,i=e.isSubWorker;if(!(t===pt.Image&&r&&n)){_context32.next=19;break;}l=n.toString(),o=r.src,a=r.type,c=r.width,m=r.height,f=r.strokeColor;if(!(!o||!a||!c||!m)){_context32.next=5;break;}return _context32.abrupt("return");case 5:v=o;if(a===Qr.Iconify){_this$getIconSize=this.getIconSize(c,m,this.dpr),_this$getIconSize2=_slicedToArray(_this$getIconSize,2),P=_this$getIconSize2[0],_x88=_this$getIconSize2[1];v="".concat(o,"?width=").concat(P,"&height=").concat(_x88,"&color=").concat(f);}if(!this.cacheImages.has(v)){_context32.next=11;break;}_P20=this.getCachedImages(v);if(!_P20){_context32.next=11;break;}return _context32.abrupt("return",_P20);case 11:if(!this.imageResolveMap.has(v)){_context32.next=15;break;}_P21=this.getCachedImagesByWorkId(l);if(!_P21){_context32.next=15;break;}return _context32.abrupt("return",_P21);case 15:_context32.next=17;return new Promise(function(P){var x=_this88.imageResolveMap.get(v)||{resolve:void 0,timer:void 0};x.timer&&clearTimeout(x.timer),x.resolve=P,x.timer=setTimeout(function(){var h=_this88.imageResolveMap.get(v);h!=null&&h.resolve&&h.resolve(v);},5e3),_this88.imageResolveMap.set(v,x),_this88._post({sp:[{imageSrc:v,workId:l,viewId:_this88.viewId,isgl:!!_this88.fullLayer.parent.gl,isSubWorker:i,type:dt.GetImageBitMap}]});});case 17:T=_context32.sent;return _context32.abrupt("return",(this.imageResolveMap["delete"](T),this.getCachedImages(v)));case 19:case"end":return _context32.stop();}},_callee30,this);}));function loadImageBitMap(_x87){return _loadImageBitMap.apply(this,arguments);}return loadImageBitMap;}()},{key:"createLocalWork",value:function createLocalWork(e){var t=e.workId,r=e.opt,n=e.toolsType;t&&r&&(!this.localWork.getToolsOpt()&&n&&this.setToolsOpt({toolsType:n,toolsOpt:r}),this.setWorkOpt({workId:t,toolsOpt:r}));}},{key:"updateScene",value:function updateScene(e,t,r){e.attr(_objectSpread({},t));var n=t.width,i=t.height;e.container.width=n,e.container.height=i,e.width=n,e.height=i,this.updateLayer({width:n,height:i},r);}},{key:"updateLayer",value:function updateLayer(e,t){var r=e.width,n=e.height,i=t||this.fullLayer;i&&(i.parent.setAttribute("width",r),i.parent.setAttribute("height",n),i.setAttribute("size",[r,n]),i.setAttribute("pos",[r*0.5,n*0.5]));}},{key:"getSupportContextType",value:function getSupportContextType(e,t){var r=new OffscreenCanvas(100,100);var n=["2d"];e===wr.Full&&this.viewId===hr&&(n=["webgl2","webgl","2d"],t&&n.unshift(t));for(var _i3=0,_n7=n;_i3<_n7.length;_i3++){var i=_n7[_i3];try{if(r.getContext(i))return i;}catch(l){throw l;}}}},{key:"createScene",value:function createScene(e){var t=e.offscreenCanvasOpt,r=t.width,n=t.height,i=new OffscreenCanvas(r,n);t.contextType&&delete t.contextType;var l=new ui(_objectSpread(_objectSpread({container:i,displayRatio:this.dpr,depth:!1,desynchronized:!0,failIfMajorPerformanceCaveat:!0},t),{},{contextType:this.contextType,id:this.viewId}));return l.setAttribute("id",this.viewId),l;}},{key:"createLayer",value:function createLayer(e,t,r,n){var i="offscreen-".concat(e),l=r.width,o=r.height;n&&(r.offscreen=!0,r.canvas=n);var a=t.layer(i,r),c=new ye({anchor:[0.5,0.5],pos:[l*0.5,o*0.5],size:[l,o],name:"viewport",id:e});return a.append(c),c;}},{key:"clearAll",value:function(){var _clearAll=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee31(){var e;return _regeneratorRuntime().wrap(function _callee31$(_context33){while(1)switch(_context33.prev=_context33.next){case 0:this.fullLayer&&(this.fullLayer.parent.children.forEach(function(t){t.name!=="viewport"&&t.remove();}),Se(this.fullLayer,this.fullLayer.parent)),this.taskUpdateCameraId&&(clearTimeout(this.taskUpdateCameraId),this.taskUpdateCameraId=void 0),this.debounceUpdateCameraId&&(clearTimeout(this.debounceUpdateCameraId),this.debounceUpdateCameraId=void 0),this.clearCacheImages(),this.clearImageResolveMap(),this.localWork.destroy(),(e=this.serviceWork)==null||e.destroy();case 1:case"end":return _context33.stop();}},_callee31,this);}));function clearAll(){return _clearAll.apply(this,arguments);}return clearAll;}()},{key:"setToolsOpt",value:function setToolsOpt(e){this.localWork.setToolsOpt(e);}},{key:"setWorkOpt",value:function setWorkOpt(e){var t=e.workId,r=e.toolsOpt;t&&r&&this.localWork.setWorkOptions(t.toString(),r);}},{key:"destroy",value:function destroy(){var e;this.vNodes.clear(),this.fullLayer.remove(),_pe(this.fullLayer,this.fullLayer.parent),this.clearCacheImages(),this.clearImageResolveMap(),this.scene.remove(),this.localWork.destroy(),(e=this.serviceWork)==null||e.destroy();}},{key:"post",value:function(){var _post=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee32(e){return _regeneratorRuntime().wrap(function _callee32$(_context34){while(1)switch(_context34.prev=_context34.next){case 0:this.combinePostMsg.add(e);_context34.next=3;return this.runBatchPostData();case 3:case"end":return _context34.stop();}},_callee32,this);}));function post(_x89){return _post.apply(this,arguments);}return post;}()},{key:"runBatchPostData",value:function(){var _runBatchPostData=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee33(){var _this89=this;return _regeneratorRuntime().wrap(function _callee33$(_context35){while(1)switch(_context35.prev=_context35.next){case 0:this.workerTaskId||(this.workerTaskId=setTimeout(function(){_this89.workerTaskId=void 0,_this89.combinePost();},16));_context35.t0=this.type===wr.Full&&!this.delayPostDoneResolve;if(!_context35.t0){_context35.next=6;break;}_context35.next=5;return new Promise(function(t){_this89.delayPostDoneResolve=t;});case 5:_context35.t0=_context35.sent;case 6:_context35.t1=_context35.t0;if(!_context35.t1){_context35.next=9;break;}this.delayPostDoneResolve=void 0;case 9:case"end":return _context35.stop();}},_callee33,this);}));function runBatchPostData(){return _runBatchPostData.apply(this,arguments);}return runBatchPostData;}()},{key:"combinePostData",value:function combinePostData(){var o,a;this.workerTaskId=void 0;var e=[],t=[];var r,n,i;var l=/* @__PURE__ */new Set();var _iterator53=_createForOfIteratorHelper(this.combinePostMsg.values()),_step53;try{for(_iterator53.s();!(_step53=_iterator53.n()).done;){var c=_step53.value;if((o=c.render)!=null&&o.length){var _iterator54=_createForOfIteratorHelper(c.render),_step54;try{for(_iterator54.s();!(_step54=_iterator54.n()).done;){var m=_step54.value;var f=!1;if(m.workId&&l.add(m.workId),m.isClearAll&&(m.rect=this.getSceneRect(),m.isClear=!0,delete m.isClearAll),m.drawCanvas){var v=this.getLayer(m.drawCanvas);if(!v||!(v.parent instanceof $r))continue;if(v.parent.render(),m.isDrawAll){var S=this.getSceneRect();m.rect=S,delete m.isDrawAll;}}var _iterator55=_createForOfIteratorHelper(e),_step55;try{for(_iterator55.s();!(_step55=_iterator55.n()).done;){var _v3=_step55.value;if(m.viewId===_v3.viewId){m.isClear&&_v3.clearCanvas&&_v3.isClear&&_v3.clearCanvas===m.clearCanvas&&(_v3.rect=bt(_v3.rect,m.rect),f=!0),_v3.drawCanvas&&_v3.drawCanvas===m.drawCanvas&&(_v3.rect=bt(_v3.rect,m.rect),f=!0);continue;}}}catch(err){_iterator55.e(err);}finally{_iterator55.f();}f||(m.isClear&&!m.drawCanvas?e.unshift(m):e.push(m));}}catch(err){_iterator54.e(err);}finally{_iterator54.f();}}if((a=c.sp)!=null&&a.length){var _iterator56=_createForOfIteratorHelper(c.sp),_step56;try{for(_iterator56.s();!(_step56=_iterator56.n()).done;){var _m12=_step56.value;var _f6=!1;var _iterator57=_createForOfIteratorHelper(t),_step57;try{for(_iterator57.s();!(_step57=_iterator57.n()).done;){var _v4=_step57.value;if(Me(_m12,_v4)){_f6=!0;break;}}}catch(err){_iterator57.e(err);}finally{_iterator57.f();}_f6||t.push(_m12);}}catch(err){_iterator56.e(err);}finally{_iterator56.f();}}ue(c.fullWorkerDrawCount)&&(r=c.fullWorkerDrawCount),ue(c.subWorkerDrawCount)&&(n=c.subWorkerDrawCount),ue(c.consumeCount)&&(i=c.consumeCount);}}catch(err){_iterator53.e(err);}finally{_iterator53.f();}return this.combinePostMsg.clear(),{render:e,sp:t,fullWorkerDrawCount:r,subWorkerDrawCount:n,consumeCount:i,workIds:l,viewId:this.viewId};}},{key:"getSceneRect",value:function getSceneRect(){var _this$scene=this.scene,e=_this$scene.width,t=_this$scene.height;return{x:0,y:0,w:Math.floor(e),h:Math.floor(t)};}}]);}();var hs=/*#__PURE__*/function(){function hs(e){_classCallCheck(this,hs);ot(this,"viewId");ot(this,"vNodes");ot(this,"thread");ot(this,"fullLayer");ot(this,"drawLayer");ot(this,"_post");ot(this,"tmpOpt");ot(this,"workShapes",/* @__PURE__ */new Map());ot(this,"drawCount",0);ot(this,"consumeCount",0);ot(this,"syncUnitTime",me.syncOpt.interval);ot(this,"combineUnitTime",me.bezier.combineUnitTime);ot(this,"maxCombineEraserTime",me.pencilEraser.maxCombineTime);this.thread=e.thread,this.viewId=e.viewId,this.vNodes=e.vNodes,this.fullLayer=e.fullLayer,this.drawLayer=e.drawLayer,this._post=this.thread.post.bind(e.thread);}return _createClass(hs,[{key:"setmaxCombineEraserTime",value:function setmaxCombineEraserTime(e){this.maxCombineEraserTime=e;}},{key:"setCombineUnitTime",value:function setCombineUnitTime(e){this.combineUnitTime=e;}},{key:"setSyncUnitTime",value:function setSyncUnitTime(e){this.syncUnitTime=e;}},{key:"destroy",value:function destroy(){this.workShapes.clear();}},{key:"getWorkShapes",value:function getWorkShapes(){return this.workShapes;}},{key:"getWorkShape",value:function getWorkShape(e){return this.workShapes.get(e);}},{key:"createWorkShape",value:function createWorkShape(e,t){if(e&&this.tmpOpt){var r={toolsType:this.tmpOpt.toolsType,toolsOpt:t||this.tmpOpt.toolsOpt},n=this.createWorkShapeNode(_objectSpread(_objectSpread({},r),{},{workId:e}));n&&this.workShapes.set(e,n);}}},{key:"setWorkOptions",value:function setWorkOptions(e,t){var r=this.getWorkShape(e);r||this.createWorkShape(e,t),r==null||r.setWorkOptions(t);}},{key:"createWorkShapeNode",value:function createWorkShapeNode(e){var t;return Ur(_objectSpread(_objectSpread({},e),{},{vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer}),(t=this.thread)==null?void 0:t.serviceWork);}},{key:"setToolsOpt",value:function setToolsOpt(e){var t,r,n;((t=this.tmpOpt)==null?void 0:t.toolsType)!==e.toolsType&&(r=this.tmpOpt)!=null&&r.toolsType&&this.clearAllWorkShapesCache(),this.tmpOpt=e,(n=e.toolsOpt)!=null&&n.syncUnitTime&&(this.syncUnitTime=e.toolsOpt.syncUnitTime),e.combineUnitTime&&(this.combineUnitTime=e.combineUnitTime),e.maxCombineEraserTime&&(this.maxCombineEraserTime=e.maxCombineEraserTime);}},{key:"getToolsOpt",value:function getToolsOpt(){return this.tmpOpt;}},{key:"clearWorkShapeNodeCache",value:function clearWorkShapeNodeCache(e){var t;(t=this.getWorkShape(e))==null||t.clearTmpPoints(),this.workShapes["delete"](e);}},{key:"clearAllWorkShapesCache",value:function clearAllWorkShapesCache(){this.workShapes.forEach(function(e){return e.clearTmpPoints();}),this.workShapes.clear();}},{key:"setFullWork",value:function setFullWork(e){var t=e.workId,r=e.opt,n=e.toolsType;if(t&&r&&n){var i=t.toString();var l;return t&&this.workShapes.has(i)?(l=this.workShapes.get(i),l==null||l.setWorkOptions(r)):l=this.createWorkShapeNode({toolsOpt:r,toolsType:n,workId:i}),l?(this.workShapes.set(i,l),l):void 0;}}}]);}();var us=/*#__PURE__*/function(){function us(e){_classCallCheck(this,us);ot(this,"snapshotFullLayer");ot(this,"opt");this.opt=e;}return _createClass(us,[{key:"getRectImageBitmap",value:function getRectImageBitmap(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!1;var r=arguments.length>2?arguments[2]:undefined;var n=e.rect,i=e.drawCanvas,l=this.opt.getDpr(),o=Math.floor(n.x*l),a=Math.floor(n.y*l),c=Math.floor(n.w*l),m=Math.floor(n.h*l);return createImageBitmap(this.opt.getOffscreen(i,t),o,a,c,m,r);}},{key:"createSnapshotFullLayer",value:function createSnapshotFullLayer(e,t){this.snapshotFullLayer=this.opt.createLayer("snapshotFullLayer",e,t);}},{key:"destroySnapshotFullLayer",value:function destroySnapshotFullLayer(){var e,t;(e=this.snapshotFullLayer)==null||e.disconnect(),(t=this.snapshotFullLayer)==null||t.remove(),this.snapshotFullLayer=void 0;}},{key:"getSnapshot",value:function(){var _getSnapshot=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee34(e){var t,r,n,i,l,o,a,_i4,_Object$entries,_Object$entries$_i,m,f,v,S,E,c;return _regeneratorRuntime().wrap(function _callee34$(_context36){while(1)switch(_context36.prev=_context36.next){case 0:t=e.scenePath,r=e.scenes,n=e.cameraOpt,i=e.w,l=e.h;if(!(t&&r&&n&&this.snapshotFullLayer)){_context36.next=26;break;}o=he(this.opt.getCameraOpt());this.opt.setCameraOpt(n,this.snapshotFullLayer),this.opt.localWork.fullLayer=this.snapshotFullLayer,this.opt.localWork.drawLayer=void 0;_i4=0,_Object$entries=Object.entries(r);case 5:if(!(_i4<_Object$entries.length)){_context36.next=21;break;}_Object$entries$_i=_slicedToArray(_Object$entries[_i4],2),m=_Object$entries$_i[0],f=_Object$entries$_i[1];if(!(f!=null&&f.type)){_context36.next=18;break;}_context36.t0=f==null?void 0:f.type;_context36.next=_context36.t0===dt.UpdateNode?11:_context36.t0===dt.FullWork?11:18;break;case 11:v=f.opt;S=_objectSpread(_objectSpread({},f),{},{opt:v,workId:m,msgType:dt.FullWork,dataType:Dt.Service,viewId:this.opt.viewId});_context36.next=15;return this.runFullWork(S);case 15:E=_context36.sent;a=bt(a,E);return _context36.abrupt("break",18);case 18:_i4++;_context36.next=5;break;case 21:i&&l&&(c={resizeWidth:i,resizeHeight:l});_context36.next=24;return this.getSnapshotRender({scenePath:t,curCameraOpt:o,options:c});case 24:this.opt.localWork.fullLayer=this.opt.fullLayer;this.opt.localWork.drawLayer=void 0;case 26:case"end":return _context36.stop();}},_callee34,this);}));function getSnapshot(_x90){return _getSnapshot.apply(this,arguments);}return getSnapshot;}()},{key:"runFullWork",value:function(){var _runFullWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee35(e){var n,t,r,i,l,o;return _regeneratorRuntime().wrap(function _callee35$(_context37){while(1)switch(_context37.prev=_context37.next){case 0:t=this.opt.localWork.setFullWork(e),r=e.ops&&Qe(e.ops);if(!t){_context37.next=18;break;}o=(n=t.getWorkId())==null?void 0:n.toString();if(!(t.toolsType===pt.Image)){_context37.next=9;break;}_context37.next=6;return t.consumeServiceAsync({isFullWork:!0,worker:this.opt.thread});case 6:i=_context37.sent;_context37.next=16;break;case 9:if(!(t.toolsType===pt.Text)){_context37.next=15;break;}_context37.next=12;return t.consumeServiceAsync({isFullWork:!0,replaceId:o,isDrawLabel:!0});case 12:i=_context37.sent;_context37.next=16;break;case 15:i=t.consumeService({op:r,isFullWork:!0,replaceId:o}),l=(e==null?void 0:e.updateNodeOpt)&&t.updataOptService(e.updateNodeOpt);case 16:e.workId&&this.opt.localWork.workShapes["delete"](e.workId.toString());return _context37.abrupt("return",bt(i,l));case 18:case"end":return _context37.stop();}},_callee35,this);}));function runFullWork(_x91){return _runFullWork.apply(this,arguments);}return runFullWork;}()},{key:"getSnapshotRender",value:function(){var _getSnapshotRender=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee36(e){var l,t,r,n,i;return _regeneratorRuntime().wrap(function _callee36$(_context38){while(1)switch(_context38.prev=_context38.next){case 0:t=e.scenePath,r=e.curCameraOpt,n=e.options;((l=this.snapshotFullLayer)==null?void 0:l.parent).render();_context38.next=4;return this.getRectImageBitmap({rect:this.opt.getSceneRect(),drawCanvas:Et.None},!0,n);case 4:i=_context38.sent;i&&(this.opt.post({sp:[{type:dt.Snapshot,scenePath:t,imageBitmap:i,viewId:this.opt.viewId}]},[i]),i.close(),this.snapshotFullLayer&&Se(this.snapshotFullLayer,this.snapshotFullLayer.parent),this.opt.setCameraOpt(r,this.opt.fullLayer));case 6:case"end":return _context38.stop();}},_callee36,this);}));function getSnapshotRender(_x92){return _getSnapshotRender.apply(this,arguments);}return getSnapshotRender;}()},{key:"getBoundingRect",value:function(){var _getBoundingRect=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee37(e){var t,r,n,i,l,_i5,_Object$entries2,_Object$entries2$_i,o,a,c;return _regeneratorRuntime().wrap(function _callee37$(_context39){while(1)switch(_context39.prev=_context39.next){case 0:t=e.scenePath,r=e.scenes,n=e.cameraOpt;if(!(t&&r&&n&&this.snapshotFullLayer)){_context39.next=27;break;}i=he(this.opt.getCameraOpt());this.opt.setCameraOpt(n,this.snapshotFullLayer),this.opt.localWork.fullLayer=this.snapshotFullLayer,this.opt.localWork.drawLayer=void 0;_i5=0,_Object$entries2=Object.entries(r);case 5:if(!(_i5<_Object$entries2.length)){_context39.next=19;break;}_Object$entries2$_i=_slicedToArray(_Object$entries2[_i5],2),o=_Object$entries2$_i[0],a=_Object$entries2$_i[1];if(!(a!=null&&a.type)){_context39.next=16;break;}_context39.t0=a==null?void 0:a.type;_context39.next=_context39.t0===dt.UpdateNode?11:_context39.t0===dt.FullWork?11:16;break;case 11:_context39.next=13;return this.runFullWork(_objectSpread(_objectSpread({},a),{},{workId:o,msgType:dt.FullWork,dataType:Dt.Service,viewId:this.opt.viewId}));case 13:c=_context39.sent;l=bt(l,c);return _context39.abrupt("break",16);case 16:_i5++;_context39.next=5;break;case 19:_context39.t1=l;if(!_context39.t1){_context39.next=23;break;}_context39.next=23;return this.opt.post({sp:[{type:dt.BoundingBox,scenePath:t,rect:l}]});case 23:this.opt.localWork.fullLayer=this.opt.fullLayer;this.opt.localWork.drawLayer=void 0;Se(this.snapshotFullLayer,this.snapshotFullLayer.parent);this.opt.setCameraOpt(i,this.opt.fullLayer);case 27:case"end":return _context39.stop();}},_callee37,this);}));function getBoundingRect(_x93){return _getBoundingRect.apply(this,arguments);}return getBoundingRect;}()}]);}();function Om(u){return u;}var ds=Om;function Em(u,e,t){switch(t.length){case 0:return u.call(e);case 1:return u.call(e,t[0]);case 2:return u.call(e,t[0],t[1]);case 3:return u.call(e,t[0],t[1],t[2]);}return u.apply(e,t);}var Mm=Em,Am=Mm,oi=Math.max;function wm(u,e,t){return e=oi(e===void 0?u.length-1:e,0),function(){for(var r=arguments,n=-1,i=oi(r.length-e,0),l=Array(i);++n<i;)l[n]=r[e+n];n=-1;for(var o=Array(e+1);++n<e;)o[n]=r[n];return o[e]=t(l),Am(u,this,o);};}var Lm=wm;function Rm(u){return function(){return u;};}var Dm=Rm,bm=Dm,ai=xi,Nm=ds,Bm=ai?function(u,e){return ai(u,"toString",{configurable:!0,enumerable:!1,value:bm(e),writable:!0});}:Nm,Wm=Bm,Fm=800,Um=16,jm=Date.now;function Ym(u){var e=0,t=0;return function(){var r=jm(),n=Um-(r-t);if(t=r,n>0){if(++e>=Fm)return arguments[0];}else e=0;return u.apply(void 0,arguments);};}var Xm=Ym,zm=Wm,$m=Xm,Gm=$m(zm),km=Gm,Hm=ds,Vm=Lm,Km=km;function Zm(u,e){return Km(Vm(u,e,Hm),u+"");}var Jm=Zm;function Qm(u,e,t,r){for(var n=u.length,i=t+(r?1:-1);r?i--:++i<n;)if(e(u[i],i,u))return i;return-1;}var qm=Qm;function _m(u){return u!==u;}var tv=_m;function ev(u,e,t){for(var r=t-1,n=u.length;++r<n;)if(u[r]===e)return r;return-1;}var rv=ev,nv=qm,iv=tv,sv=rv;function ov(u,e,t){return e===e?sv(u,e,t):nv(u,iv,t);}var av=ov,lv=av;function cv(u,e){var t=u==null?0:u.length;return!!t&&lv(u,e,0)>-1;}var ps=cv;function fv(u,e,t){for(var r=-1,n=u==null?0:u.length;++r<n;)if(t(e,u[r]))return!0;return!1;}var ms=fv;function hv(u,e){for(var t=-1,r=u==null?0:u.length,n=Array(r);++t<r;)n[t]=e(u[t],t,u);return n;}var uv=hv,dv=dn,pv=ps,mv=ms,vv=uv,yv=Wr,gv=pn,Pv=200;function Sv(u,e,t,r){var n=-1,i=pv,l=!0,o=u.length,a=[],c=e.length;if(!o)return a;t&&(e=vv(e,yv(t))),r?(i=mv,l=!1):e.length>=Pv&&(i=gv,l=!1,e=new dv(e));t:for(;++n<o;){var m=u[n],f=t==null?m:t(m);if(m=r||m!==0?m:0,l&&f===f){for(var v=c;v--;)if(e[v]===f)continue t;a.push(m);}else i(e,f,r)||a.push(m);}return a;}var xv=Sv,li=ur,Tv=Oi,Cv=pr,ci=li?li.isConcatSpreadable:void 0;function Iv(u){return Cv(u)||Tv(u)||!!(ci&&u&&u[ci]);}var Ov=Iv,Ev=ln,Mv=Ov;function vs(u,e,t,r,n){var i=-1,l=u.length;for(t||(t=Mv),n||(n=[]);++i<l;){var o=u[i];e>0&&t(o)?e>1?vs(o,e-1,t,r,n):Ev(n,o):r||(n[n.length]=o);}return n;}var Av=vs;function wv(){}var Lv=wv,zr=Wi,Rv=Lv,Dv=mn,bv=1/0,Nv=zr&&1/Dv(new zr([,-0]))[1]==bv?function(u){return new zr(u);}:Rv,Bv=Nv,Wv=dn,Fv=ps,Uv=ms,jv=pn,Yv=Bv,Xv=mn,zv=200;function $v(u,e,t){var r=-1,n=Fv,i=u.length,l=!0,o=[],a=o;if(t)l=!1,n=Uv;else if(i>=zv){var c=e?null:Yv(u);if(c)return Xv(c);l=!1,n=jv,a=new Wv();}else a=e?[]:o;t:for(;++r<i;){var m=u[r],f=e?e(m):m;if(m=t||m!==0?m:0,l&&f===f){for(var v=a.length;v--;)if(a[v]===f)continue t;e&&a.push(f),o.push(m);}else n(a,f,t)||(a!==o&&a.push(f),o.push(m));}return o;}var Gv=$v,kv=xv,Hv=Av,fi=Gv;function Vv(u,e,t){var r=u.length;if(r<2)return r?fi(u[0]):[];for(var n=-1,i=Array(r);++n<r;)for(var l=u[n],o=-1;++o<r;)o!=n&&(i[n]=kv(i[n]||l,u[o],e,t));return fi(Hv(i,1),e,t);}var Kv=Vv,Zv=nn,Jv=Le;function Qv(u){return Jv(u)&&Zv(u);}var qv=Qv,_v=Li,ty=Jm,ey=Kv,ry=qv,ny=ty(function(u){return ey(_v(u,ry));}),iy=ny,sy=/* @__PURE__ */Ne(iy);var ys=/*#__PURE__*/function(_hs){function ys(t){var _this90;_classCallCheck(this,ys);_this90=_callSuper(this,ys,[t]);ot(_this90,"_type","full");ot(_this90,"combineTimerId");ot(_this90,"combineDrawResolve");ot(_this90,"combineDrawActiveId");ot(_this90,"drawWorkActiveId");ot(_this90,"effectSelectNodeData",/* @__PURE__ */new Set());return _this90;}_inherits(ys,_hs);return _createClass(ys,[{key:"loadImageBitMap",value:function(){var _loadImageBitMap2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee38(t){return _regeneratorRuntime().wrap(function _callee38$(_context40){while(1)switch(_context40.prev=_context40.next){case 0:_context40.next=2;return this.thread.loadImageBitMap(t);case 2:return _context40.abrupt("return",_context40.sent);case 3:case"end":return _context40.stop();}},_callee38,this);}));function loadImageBitMap(_x94){return _loadImageBitMap2.apply(this,arguments);}return loadImageBitMap;}()},{key:"consumeDraw",value:function(){var _consumeDraw=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee39(t,r){var _this91=this;var n,i,l,o,a,c,m,f,v;return _regeneratorRuntime().wrap(function _callee39$(_context41){while(1)switch(_context41.prev=_context41.next){case 0:n=t.op,i=t.workId,l=t.scenePath,o=t.postCount,a=t.smoothSync;if(!(n!=null&&n.length&&i)){_context41.next=48;break;}c=i.toString(),m=this.getWorkShape(c);if(m){_context41.next=5;break;}return _context41.abrupt("return");case 5:f=m.toolsType;if(!(f===pt.LaserPen)){_context41.next=8;break;}return _context41.abrupt("return");case 8:_context41.t0=this.combineDrawActiveId&&this.combineDrawActiveId!==c;if(!_context41.t0){_context41.next=13;break;}this.combineTimerId&&(clearTimeout(this.combineTimerId),this.combineTimerId=void 0,this.combineDrawResolve&&this.combineDrawResolve(!1),this.combineDrawActiveId=void 0);_context41.next=13;return this.consumeDrawAll({workId:this.combineDrawActiveId,scenePath:l,viewId:this.viewId,msgType:dt.DrawWork,dataType:Dt.Local},r);case 13:_context41.t1=this.drawWorkActiveId&&this.drawWorkActiveId!==c;if(!_context41.t1){_context41.next=18;break;}_context41.next=17;return this.consumeDrawAll({workId:this.drawWorkActiveId,scenePath:l,viewId:this.viewId,msgType:dt.DrawWork,dataType:Dt.Local},r);case 17:this.drawWorkActiveId=void 0;case 18:!this.drawWorkActiveId&&c!==qt&&(this.drawWorkActiveId=c);ue(o)&&(this.consumeCount=o);v=m.consume({data:t,isFullWork:!0,smoothSync:a});_context41.t2=f;_context41.next=_context41.t2===pt.Selector?24:_context41.t2===pt.PencilEraser?30:_context41.t2===pt.BitMapEraser?30:_context41.t2===pt.Eraser?32:_context41.t2===pt.Arrow?35:_context41.t2===pt.Straight?35:_context41.t2===pt.Ellipse?35:_context41.t2===pt.Rectangle?35:_context41.t2===pt.Star?35:_context41.t2===pt.Polygon?35:_context41.t2===pt.SpeechBalloon?35:_context41.t2===pt.Pencil?41:48;break;case 24:_context41.t3=v.type===dt.Select;if(!_context41.t3){_context41.next=29;break;}v.selectIds&&r.runReverseSelectWork(v.selectIds);_context41.next=29;return this.drawSelector(v);case 29:return _context41.abrupt("break",48);case 30:this.drawCount++,this.combineTimerId||(this.combineTimerId=1,this.combineDrawActiveId=c,this.drawEraserCombine(c,this.drawCount).then(function(){_this91.combineTimerId=void 0;}));return _context41.abrupt("break",48);case 32:_context41.next=34;return this.drawEraser(v);case 34:return _context41.abrupt("break",48);case 35:_context41.t4=v;if(!_context41.t4){_context41.next=40;break;}this.drawCount++;_context41.next=40;return this.drawShape(v);case 40:return _context41.abrupt("break",48);case 41:this.drawCount++;!this.combineTimerId&&this.combineUnitTime!==1/0&&new Promise(function(S){_this91.combineDrawActiveId=c,_this91.combineDrawResolve=S,_this91.combineTimerId=setTimeout(function(){_this91.combineTimerId=void 0,_this91.combineDrawResolve&&_this91.combineDrawResolve(!0);},_this91.combineUnitTime);}).then(function(S){S&&_this91.drawPencilCombine(c,_this91.drawCount),_this91.combineDrawResolve=void 0;});_context41.t5=v;if(!_context41.t5){_context41.next=47;break;}_context41.next=47;return this.drawPencil(v);case 47:return _context41.abrupt("break",48);case 48:case"end":return _context41.stop();}},_callee39,this);}));function consumeDraw(_x95,_x96){return _consumeDraw.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee40(t,r){var o,a,c,n,i,l,m,f,v,S,E,T;return _regeneratorRuntime().wrap(function _callee40$(_context42){while(1)switch(_context42.prev=_context42.next){case 0:this.combineTimerId&&(clearTimeout(this.combineTimerId),this.combineTimerId=void 0,this.combineDrawResolve&&this.combineDrawResolve(!1),this.combineDrawActiveId=void 0);n=t.workId,i=t.scenePath,l=t.isLockSentEventCursor;if(!n){_context42.next=38;break;}m=n.toString();this.drawWorkActiveId===m&&(this.drawWorkActiveId=void 0);f=this.workShapes.get(m);if(f){_context42.next=8;break;}return _context42.abrupt("return");case 8:v=f.toolsType;if(!(v===pt.LaserPen)){_context42.next=11;break;}return _context42.abrupt("return");case 11:S=this.workShapes.get(He),E=(o=S==null?void 0:S.selectIds)==null?void 0:o[0],T=f.consumeAll({data:t,workerEngine:this});_context42.t0=v;_context42.next=_context42.t0===pt.Selector?15:_context42.t0===pt.PencilEraser?21:_context42.t0===pt.BitMapEraser?21:_context42.t0===pt.Eraser?26:_context42.t0===pt.Arrow?28:_context42.t0===pt.Straight?28:_context42.t0===pt.Ellipse?28:_context42.t0===pt.Rectangle?28:_context42.t0===pt.Star?28:_context42.t0===pt.Polygon?28:_context42.t0===pt.SpeechBalloon?28:_context42.t0===pt.Pencil?33:38;break;case 15:T.selectIds&&E&&(a=T.selectIds)!=null&&a.includes(E)&&S.cursorBlur();T.selectIds&&r.runReverseSelectWork(T.selectIds);_context42.next=19;return this.drawSelector(_objectSpread(_objectSpread({},T),{},{scenePath:i}),l);case 19:(c=f.selectIds)!=null&&c.length?f.clearTmpPoints():this.clearWorkShapeNodeCache(m);return _context42.abrupt("break",38);case 21:_context42.next=23;return this.drawEraserFull(f,_objectSpread(_objectSpread({},T),{},{scenePath:i}),l);case 23:this.drawCount=0;this.clearWorkShapeNodeCache(m);return _context42.abrupt("break",38);case 26:this.drawEraser(_objectSpread(_objectSpread({},T),{},{scenePath:i}),l),f.clearTmpPoints();return _context42.abrupt("break",38);case 28:_context42.next=30;return this.drawPencilFull(_objectSpread(_objectSpread({},T),{},{scenePath:i}),l);case 30:this.drawCount=0;this.clearWorkShapeNodeCache(m);return _context42.abrupt("break",38);case 33:_context42.next=35;return this.drawPencilFull(_objectSpread(_objectSpread({},T),{},{scenePath:i}),l);case 35:this.drawCount=0;this.clearWorkShapeNodeCache(m);return _context42.abrupt("break",38);case 38:case"end":return _context42.stop();}},_callee40,this);}));function consumeDrawAll(_x97,_x98){return _consumeDrawAll.apply(this,arguments);}return consumeDrawAll;}()},{key:"workShapesDone",value:function(){var _workShapesDone=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee41(t,r){var _iterator58,_step58,n;return _regeneratorRuntime().wrap(function _callee41$(_context43){while(1)switch(_context43.prev=_context43.next){case 0:_iterator58=_createForOfIteratorHelper(this.workShapes.keys());_context43.prev=1;_iterator58.s();case 3:if((_step58=_iterator58.n()).done){_context43.next=9;break;}n=_step58.value;_context43.next=7;return this.consumeDrawAll({workId:n,scenePath:t,viewId:this.viewId,msgType:dt.DrawWork,dataType:Dt.Local},r);case 7:_context43.next=3;break;case 9:_context43.next=14;break;case 11:_context43.prev=11;_context43.t0=_context43["catch"](1);_iterator58.e(_context43.t0);case 14:_context43.prev=14;_iterator58.f();return _context43.finish(14);case 17:case"end":return _context43.stop();}},_callee41,this,[[1,11,14,17]]);}));function workShapesDone(_x99,_x100){return _workShapesDone.apply(this,arguments);}return workShapesDone;}()},{key:"consumeFull",value:function(){var _consumeFull=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee42(t){var i,l,r,n,o,a,c,m,f,v,S;return _regeneratorRuntime().wrap(function _callee42$(_context44){while(1)switch(_context44.prev=_context44.next){case 0:r=this.setFullWork(t),n=t.ops&&Qe(t.ops)||t.op;if(!r){_context44.next=26;break;}o=(i=t.workId)==null?void 0:i.toString();if(o){_context44.next=5;break;}return _context44.abrupt("return");case 5:a=(l=this.vNodes.get(o))==null?void 0:l.rect;if(!(r.toolsType===pt.Image)){_context44.next=13;break;}_context44.next=9;return r.consumeServiceAsync({isFullWork:!0,replaceId:o,worker:this});case 9:c=_context44.sent;m=(t==null?void 0:t.updateNodeOpt)&&r.updataOptService(t.updateNodeOpt);_context44.next=20;break;case 13:if(!(r.toolsType===pt.Text)){_context44.next=19;break;}_context44.next=16;return r.consumeServiceAsync({isFullWork:!0,replaceId:o});case 16:c=_context44.sent;_context44.next=20;break;case 19:c=r.consumeService({op:n,isFullWork:!0,replaceId:o}),m=(t==null?void 0:t.updateNodeOpt)&&r.updataOptService(t.updateNodeOpt);case 20:c=bt(c,m);f=[],v=[];if(!(t.workId&&this.workShapes["delete"](t.workId.toString()),c&&t.willRefresh&&(a&&(f.push({rect:kt(a),isClear:!0,clearCanvas:Et.Bg,viewId:this.viewId}),c=bt(c,a)),f.push({rect:kt(c),drawCanvas:Et.Bg,viewId:this.viewId})),t.willSyncService&&v.push({opt:t.opt,toolsType:t.toolsType,type:dt.FullWork,workId:t.workId,ops:t.ops,updateNodeOpt:t.updateNodeOpt,viewId:this.viewId}),f.length||v.length)){_context44.next=26;break;}S={render:f,sp:v};_context44.next=26;return this._post(S);case 26:case"end":return _context44.stop();}},_callee42,this);}));function consumeFull(_x101){return _consumeFull.apply(this,arguments);}return consumeFull;}()},{key:"commandDeleteText",value:function commandDeleteText(t){var r=this.vNodes.get(t);if(r&&r.toolsType===pt.Text)return{type:dt.TextUpdate,toolsType:pt.Text,workId:t,dataType:Dt.Local};}},{key:"removeSelector",value:function(){var _removeSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee43(t,r){var n,i,l,o,a,c,_iterator59,_step59,m,S,v;return _regeneratorRuntime().wrap(function _callee43$(_context45){while(1)switch(_context45.prev=_context45.next){case 0:n=t.willSyncService,i=[],l=[],o=[],a=this.workShapes.get(qt);if(a){_context45.next=3;break;}return _context45.abrupt("return");case 3:c=a.selectIds&&_toConsumableArray(a.selectIds)||[];_iterator59=_createForOfIteratorHelper(c);try{for(_iterator59.s();!(_step59=_iterator59.n()).done;){m=_step59.value;if(this.vNodes.get(m)){S=this.commandDeleteText(m);S&&i.push(S);}v=this._removeWork(m);v.length&&l.push.apply(l,_toConsumableArray(v)),r==null||r.deleteCachedImagesByWorkId(m),o.push(m);}}catch(err){_iterator59.e(err);}finally{_iterator59.f();}o.length&&i.push({type:dt.RemoveNode,removeIds:o});i.push({type:dt.Select,selectIds:[],willSyncService:n});_context45.next=10;return this.blurSelector();case 10:_context45.t0=l.length||i.length;if(!_context45.t0){_context45.next=14;break;}_context45.next=14;return this._post({render:l,sp:i});case 14:case"end":return _context45.stop();}},_callee43,this);}));function removeSelector(_x102,_x103){return _removeSelector.apply(this,arguments);}return removeSelector;}()},{key:"removeWork",value:function(){var _removeWork2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee44(t){var r,n,i;return _regeneratorRuntime().wrap(function _callee44$(_context46){while(1)switch(_context46.prev=_context46.next){case 0:r=t.workId,n=r==null?void 0:r.toString();if(!n){_context46.next=7;break;}i=this._removeWork(n);_context46.t0=i.length;if(!_context46.t0){_context46.next=7;break;}_context46.next=7;return this._post({render:i});case 7:case"end":return _context46.stop();}},_callee44,this);}));function removeWork(_x104){return _removeWork2.apply(this,arguments);}return removeWork;}()},{key:"removeNode",value:function removeNode(t){var _this92=this;var i,l,o;var r=this.vNodes.get(t);r&&((i=this.fullLayer)==null||i.getElementsByName(t).forEach(function(a){a.remove(),_pe(a,_this92.fullLayer.parent);}),this.vNodes["delete"](t));var n=this.drawLayer&&At.getRectFromLayer(this.drawLayer,t);if(n){var a=(l=this.drawLayer)==null?void 0:l.getElementsByName(t)[0];a&&(a.remove(),_pe(a,(o=this.drawLayer)==null?void 0:o.parent));}return this.getWorkShape(t)&&this.clearWorkShapeNodeCache(t),{fullRect:r==null?void 0:r.rect,drawRect:n};}},{key:"_removeWork",value:function _removeWork(t){var _this$removeNode=this.removeNode(t),r=_this$removeNode.fullRect,n=_this$removeNode.drawRect,i=[];return r&&i.push({rect:kt(r),clearCanvas:Et.Bg,isClear:!0,viewId:this.viewId},{rect:kt(r),drawCanvas:Et.Bg,viewId:this.viewId}),n&&i.push({rect:kt(n),clearCanvas:Et.Float,isClear:!0,viewId:this.viewId},{rect:kt(n),drawCanvas:Et.Float,viewId:this.viewId}),i;}},{key:"checkTextActive",value:function(){var _checkTextActive=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee45(t){var r,n,i,l,o,a,c,_iterator60,_step60,m,f,v,S,E;return _regeneratorRuntime().wrap(function _callee45$(_context47){while(1)switch(_context47.prev=_context47.next){case 0:r=t.op,n=t.viewId,i=t.dataType;if(!(r!=null&&r.length)){_context47.next=32;break;}a=r[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],c=r[1]*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1];_iterator60=_createForOfIteratorHelper(this.vNodes.curNodeMap.values());_context47.prev=4;_iterator60.s();case 6:if((_step60=_iterator60.n()).done){_context47.next=14;break;}m=_step60.value;f=m.rect,v=m.name,S=m.toolsType,E=m.opt;if(!(S===pt.Text&&E.workState===Ft.Done&&vm([a,c],f))){_context47.next=12;break;}l=v,o=this.setFullWork({workId:v,toolsType:S,opt:E});return _context47.abrupt("break",14);case 12:_context47.next=6;break;case 14:_context47.next=19;break;case 16:_context47.prev=16;_context47.t0=_context47["catch"](4);_iterator60.e(_context47.t0);case 19:_context47.prev=19;_iterator60.f();return _context47.finish(19);case 22:_context47.t1=l;if(!_context47.t1){_context47.next=32;break;}_context47.t2=o;if(!_context47.t2){_context47.next=28;break;}_context47.next=28;return o.consumeServiceAsync({isFullWork:!0,replaceId:o.getWorkId(),isDrawLabel:!1});case 28:_context47.next=30;return this.blurSelector({viewId:n,msgType:dt.Select,dataType:i,isSync:!0});case 30:_context47.next=32;return this._post({sp:[{type:dt.GetTextActive,toolsType:pt.Text,workId:l}]});case 32:case"end":return _context47.stop();}},_callee45,this,[[4,16,19,22]]);}));function checkTextActive(_x105){return _checkTextActive.apply(this,arguments);}return checkTextActive;}()},{key:"colloctEffectSelectWork",value:function(){var _colloctEffectSelectWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee46(t){var _this93=this;var r,n,i;return _regeneratorRuntime().wrap(function _callee46$(_context48){while(1)switch(_context48.prev=_context48.next){case 0:r=this.workShapes.get(qt),n=t.workId,i=t.msgType;if(!(r&&n&&r.selectIds&&r.selectIds.includes(n.toString()))){_context48.next=6;break;}i===dt.RemoveNode?r.selectIds=r.selectIds.filter(function(l){return l!==n.toString();}):this.effectSelectNodeData.add(t);_context48.next=5;return this.runEffectSelectWork(!0).then(function(){var l;(l=_this93.effectSelectNodeData)==null||l.clear();});case 5:return _context48.abrupt("return");case 6:return _context48.abrupt("return",t);case 7:case"end":return _context48.stop();}},_callee46,this);}));function colloctEffectSelectWork(_x106){return _colloctEffectSelectWork.apply(this,arguments);}return colloctEffectSelectWork;}()},{key:"updateSelector",value:function(){var _updateSelector2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee47(t){var _this94=this;var T,r,n,i,l,o,a,c,m,f,v,S,E;return _regeneratorRuntime().wrap(function _callee47$(_context49){while(1)switch(_context49.prev=_context49.next){case 0:r=this.workShapes.get(qt);if((T=r==null?void 0:r.selectIds)!=null&&T.length){_context49.next=3;break;}return _context49.abrupt("return");case 3:n=t.callback;i=_objectWithoutProperties(t,_excluded2);l=i.updateSelectorOpt;o=i.willSerializeData;a=i.smoothSync;_context49.next=10;return r==null?void 0:r.updateSelector({updateSelectorOpt:l,selectIds:he(r.selectIds),vNodes:this.vNodes,willSerializeData:o,worker:this});case 10:c=_context49.sent;m=/* @__PURE__ */new Map();c!=null&&c.selectIds&&(f=sy(r.selectIds,c.selectIds),c.selectIds.forEach(function(P){var x=_this94.vNodes.get(P);if(x){var _h45=x.toolsType,p=x.op,d=x.opt;m.set(P,{opt:d,toolsType:_h45,ops:(p==null?void 0:p.length)&&ve(p)||void 0});}}),r.selectIds=c.selectIds);v=[],S=[];c!=null&&c.rect&&v.push({rect:kt(c.rect),clearCanvas:Et.Bg,isClear:!0,viewId:this.viewId},{rect:kt(c.rect),drawCanvas:Et.Bg,viewId:this.viewId});E=n&&n({res:c,workShapeNode:r,param:i,postData:{render:v,sp:S},newServiceStore:m,smoothSync:a})||{render:v,sp:S};f&&E.sp.push({type:dt.RemoveNode,removeIds:f,viewId:this.viewId});_context49.t0=E.render.length||E.sp.length;if(!_context49.t0){_context49.next=21;break;}_context49.next=21;return this._post(E);case 21:case"end":return _context49.stop();}},_callee47,this);}));function updateSelector(_x107){return _updateSelector2.apply(this,arguments);}return updateSelector;}()},{key:"blurSelector",value:function(){var _blurSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee48(t){var i,r,n,l;return _regeneratorRuntime().wrap(function _callee48$(_context50){while(1)switch(_context50.prev=_context50.next){case 0:r=this.workShapes.get(qt),n=r==null?void 0:r.blurSelector();if(!(this.clearWorkShapeNodeCache(qt),((i=this.fullLayer)==null?void 0:i.parent).children.forEach(function(l){l.name===qt&&l.remove();}),n)){_context50.next=6;break;}l=[];l.push(_objectSpread(_objectSpread({},n),{},{isSync:t==null?void 0:t.isSync}));_context50.next=6;return this._post({render:(n==null?void 0:n.rect)&&[{rect:kt(n.rect),clearCanvas:Et.Bg,isClear:!0,viewId:this.viewId},{rect:kt(n.rect),drawCanvas:Et.Bg,viewId:this.viewId}],sp:l});case 6:case"end":return _context50.stop();}},_callee48,this);}));function blurSelector(_x108){return _blurSelector.apply(this,arguments);}return blurSelector;}()},{key:"hasSelector",value:function hasSelector(){return this.workShapes.has(qt);}},{key:"getSelector",value:function getSelector(){return this.workShapes.get(qt);}},{key:"reRenderSelector",value:function(){var _reRenderSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee49(){var t,l,r,n,i,o,_args51=arguments;return _regeneratorRuntime().wrap(function _callee49$(_context51){while(1)switch(_context51.prev=_context51.next){case 0:t=_args51.length>0&&_args51[0]!==undefined?_args51[0]:!1;r=this.workShapes.get(qt);if(r){_context51.next=4;break;}return _context51.abrupt("return");case 4:if(!(r&&!((l=r.selectIds)!=null&&l.length))){_context51.next=8;break;}_context51.next=7;return this.blurSelector();case 7:return _context51.abrupt("return");case 8:n=r.oldSelectRect,i=r.reRenderSelector();if(!i){_context51.next=13;break;}o=bt(n,i)||i;_context51.next=13;return this._post({render:[{rect:kt(o),clearCanvas:Et.Bg,isClear:!0,viewId:this.viewId},{rect:kt(o),drawCanvas:Et.Bg,viewId:this.viewId}],sp:[{type:dt.Select,selectIds:r.selectIds,selectRect:i,willSyncService:t,viewId:this.viewId,points:r.getChildrenPoints(),textOpt:r.textOpt,selectorColor:r.selectorColor,strokeColor:r.strokeColor,fillColor:r.fillColor,canTextEdit:r.canTextEdit,canRotate:r.canRotate,scaleType:r.scaleType,opt:r.getWorkOptions()||void 0,canLock:r.canLock,isLocked:r.isLocked,toolsTypes:r.toolsTypes,shapeOpt:r.shapeOpt,thickness:r.thickness,useStroke:r.useStroke,strokeType:r.strokeType}]});case 13:case"end":return _context51.stop();}},_callee49,this);}));function reRenderSelector(){return _reRenderSelector.apply(this,arguments);}return reRenderSelector;}()},{key:"updateFullSelectWork",value:function(){var _updateFullSelectWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee50(t){var i,l,o,a,c,m,f,r,n,_r$updateSelectIds,v,S,E;return _regeneratorRuntime().wrap(function _callee50$(_context52){while(1)switch(_context52.prev=_context52.next){case 0:r=this.workShapes.get(qt),n=t.selectIds;if(n!=null&&n.length){_context52.next=5;break;}_context52.next=4;return this.blurSelector(t);case 4:return _context52.abrupt("return");case 5:if(r){_context52.next=10;break;}!this.setFullWork(t)&&t.workId&&((i=this.tmpOpt)==null?void 0:i.toolsType)===pt.Selector&&this.createWorkShape(t.workId.toString());_context52.next=9;return this.updateFullSelectWork(t);case 9:return _context52.abrupt("return");case 10:if(!(r&&n!=null&&n.length)){_context52.next=16;break;}_r$updateSelectIds=r.updateSelectIds(n),v=_r$updateSelectIds.bgRect,S=_r$updateSelectIds.selectRect,E={render:[],sp:[]};v&&((l=E.render)==null||l.push({rect:kt(v),clearCanvas:Et.Bg,isClear:!0,viewId:this.viewId},{rect:kt(v),drawCanvas:Et.Bg,viewId:this.viewId}));(f=E.sp)==null||f.push(_objectSpread(_objectSpread({},t),{},{selectorColor:((o=t.opt)==null?void 0:o.strokeColor)||r.selectorColor,strokeColor:((a=t.opt)==null?void 0:a.strokeColor)||r.strokeColor,fillColor:((c=t.opt)==null?void 0:c.fillColor)||r.fillColor,textOpt:((m=t.opt)==null?void 0:m.textOpt)||r.textOpt,canTextEdit:r.canTextEdit,canRotate:r.canRotate,scaleType:r.scaleType,type:dt.Select,selectRect:S,points:r.getChildrenPoints(),willSyncService:(t==null?void 0:t.willSyncService)||!1,opt:(t==null?void 0:t.willSyncService)&&r.getWorkOptions()||void 0,canLock:r.canLock,isLocked:r.isLocked,toolsTypes:r.toolsTypes,shapeOpt:r.shapeOpt,thickness:r.thickness,useStroke:r.useStroke,strokeType:r.strokeType}));_context52.next=16;return this._post(E);case 16:case"end":return _context52.stop();}},_callee50,this);}));function updateFullSelectWork(_x109){return _updateFullSelectWork.apply(this,arguments);}return updateFullSelectWork;}()},{key:"destroy",value:function destroy(){this.combineTimerId&&(clearTimeout(this.combineTimerId),this.combineTimerId=void 0,this.combineDrawResolve&&this.combineDrawResolve(!1)),_superPropGet(ys,"destroy",this,3)([]),this.effectSelectNodeData.clear();}},{key:"drawEraserCombine",value:function(){var _drawEraserCombine=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee51(t,r){var i,l,o,a,n,c,m,f,v,_iterator61,_step61,_step61$value,_v5,S;return _regeneratorRuntime().wrap(function _callee51$(_context53){while(1)switch(_context53.prev=_context53.next){case 0:n=(i=this.workShapes.get(t))==null?void 0:i.combineConsume({workerEngine:this});if(!n){_context53.next=7;break;}c=n.willDeleteNodes,m=n.willNewNodes,f={render:[],fullWorkerDrawCount:r,sp:[]};if(n!=null&&n.rect){v=kt(n.rect);(l=f.render)==null||l.push({rect:v,isClear:!0,clearCanvas:Et.Bg,viewId:this.viewId},{rect:v,drawCanvas:Et.Bg,viewId:this.viewId});}if(c!=null&&c.size&&((o=f.sp)==null||o.push({type:dt.RemoveNode,removeIds:_toConsumableArray(c),viewId:this.thread.viewId})),m!=null&&m.size){_iterator61=_createForOfIteratorHelper(m);try{for(_iterator61.s();!(_step61=_iterator61.n()).done;){_step61$value=_slicedToArray(_step61.value,2),_v5=_step61$value[0],S=_step61$value[1];(a=f.sp)==null||a.push({type:dt.FullWork,dataType:Dt.Local,toolsType:pt.Pencil,ops:ve(S.op),opt:S.opt,workId:_v5,updateNodeOpt:{useAnimation:!1}});}}catch(err){_iterator61.e(err);}finally{_iterator61.f();}}_context53.next=7;return this._post(f);case 7:case"end":return _context53.stop();}},_callee51,this);}));function drawEraserCombine(_x110,_x111){return _drawEraserCombine.apply(this,arguments);}return drawEraserCombine;}()},{key:"drawPencilCombine",value:function(){var _drawPencilCombine=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee52(t,r){var i,l,o,n,a,c;return _regeneratorRuntime().wrap(function _callee52$(_context54){while(1)switch(_context54.prev=_context54.next){case 0:n=(i=this.workShapes.get(t))==null?void 0:i.combineConsume();if(!n){_context54.next=6;break;}a={render:[],fullWorkerDrawCount:r};if(n!=null&&n.rect){c=kt(n.rect);(l=a.render)==null||l.push({rect:c,isClear:!0,clearCanvas:Et.Float,viewId:this.viewId}),(o=a.render)==null||o.push({rect:c,drawCanvas:Et.Float,viewId:this.viewId});}_context54.next=6;return this._post(a);case 6:case"end":return _context54.stop();}},_callee52,this);}));function drawPencilCombine(_x112,_x113){return _drawPencilCombine.apply(this,arguments);}return drawPencilCombine;}()},{key:"drawSelector",value:function(){var _drawSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee53(t,r){var i,l,n;return _regeneratorRuntime().wrap(function _callee53$(_context55){while(1)switch(_context55.prev=_context55.next){case 0:n={render:[],sp:[t]};r&&((i=n.sp)==null||i.push({type:dt.None,isLockSentEventCursor:r}));t.rect&&((l=n.render)==null||l.push({rect:kt(t.rect),clearCanvas:Et.Bg,isClear:!0,viewId:this.viewId},{rect:kt(t.rect),drawCanvas:Et.Bg,viewId:this.viewId}));_context55.next=5;return this._post(n);case 5:case"end":return _context55.stop();}},_callee53,this);}));function drawSelector(_x114,_x115){return _drawSelector.apply(this,arguments);}return drawSelector;}()},{key:"drawPencilFull",value:function(){var _drawPencilFull=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee54(t,r){var i,l,n;return _regeneratorRuntime().wrap(function _callee54$(_context56){while(1)switch(_context56.prev=_context56.next){case 0:n={fullWorkerDrawCount:1/0,render:[],sp:[t]};r&&((i=n.sp)==null||i.push({type:dt.None,isLockSentEventCursor:r}));t!=null&&t.rect&&((l=n.render)==null||l.push({isClearAll:!0,clearCanvas:Et.Float,viewId:this.viewId},{rect:t.rect,isClear:!0,clearCanvas:Et.Bg,viewId:this.viewId},{rect:t.rect,drawCanvas:Et.Bg,viewId:this.viewId}));_context56.next=5;return this._post(n);case 5:case"end":return _context56.stop();}},_callee54,this);}));function drawPencilFull(_x116,_x117){return _drawPencilFull.apply(this,arguments);}return drawPencilFull;}()},{key:"drawEraserFull",value:function(){var _drawEraserFull=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee55(t,r,n){var i,l,o,a,c,m,_iterator62,_step62,_step62$value,v,S,_iterator63,_step63,_step63$value,_v6,_S9,f;return _regeneratorRuntime().wrap(function _callee55$(_context57){while(1)switch(_context57.prev=_context57.next){case 0:i=r.rect,l=r.willUpdateNodes,o=r.willDeleteNodes,a=r.willNewNodes,c=t.getWorkId(),m=[{type:dt.RemoveNode,removeIds:[c],viewId:this.viewId}];if(n&&m.push({type:dt.None,isLockSentEventCursor:n}),l!=null&&l.size||o!=null&&o.size||a!=null&&a.size){if(l!=null&&l.size){_iterator62=_createForOfIteratorHelper(l);try{for(_iterator62.s();!(_step62=_iterator62.n()).done;){_step62$value=_slicedToArray(_step62.value,2),v=_step62$value[0],S=_step62$value[1];m.push({type:dt.UpdateNode,dataType:Dt.Local,opt:S.opt,workId:v,updateNodeOpt:{useAnimation:!1}});}}catch(err){_iterator62.e(err);}finally{_iterator62.f();}}if(o!=null&&o.size&&m.push({type:dt.RemoveNode,removeIds:_toConsumableArray(o),viewId:this.thread.viewId}),a!=null&&a.size){_iterator63=_createForOfIteratorHelper(a);try{for(_iterator63.s();!(_step63=_iterator63.n()).done;){_step63$value=_slicedToArray(_step63.value,2),_v6=_step63$value[0],_S9=_step63$value[1];m.push({type:dt.FullWork,dataType:Dt.Local,toolsType:_S9.toolsType,ops:ve(_S9.op),opt:_S9.opt,workId:_v6,updateNodeOpt:{useAnimation:!1}});}}catch(err){_iterator63.e(err);}finally{_iterator63.f();}}}f=[{isClearAll:!0,clearCanvas:Et.Float,viewId:this.viewId}];i&&f.push({rect:i,isClear:!0,clearCanvas:Et.Bg,viewId:this.viewId},{rect:i,drawCanvas:Et.Bg,viewId:this.viewId});_context57.next=6;return this._post({sp:m,render:f,fullWorkerDrawCount:1/0});case 6:case"end":return _context57.stop();}},_callee55,this);}));function drawEraserFull(_x118,_x119,_x120){return _drawEraserFull.apply(this,arguments);}return drawEraserFull;}()},{key:"drawEraser",value:function(){var _drawEraser=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee56(t,r){var n,i;return _regeneratorRuntime().wrap(function _callee56$(_context58){while(1)switch(_context58.prev=_context58.next){case 0:n=[],i=[];r&&n.push({type:dt.None,isLockSentEventCursor:r});t.removeIds&&n.push(t);t.rect&&i.push({rect:t.rect,isClear:!0,clearCanvas:Et.Bg,viewId:this.viewId},{rect:t.rect,drawCanvas:Et.Bg,viewId:this.viewId});_context58.next=6;return this._post({sp:n,render:i,consumeCount:this.consumeCount});case 6:case"end":return _context58.stop();}},_callee56,this);}));function drawEraser(_x121,_x122){return _drawEraser.apply(this,arguments);}return drawEraser;}()},{key:"drawShape",value:function(){var _drawShape=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee57(t){return _regeneratorRuntime().wrap(function _callee57$(_context59){while(1)switch(_context59.prev=_context59.next){case 0:_context59.next=2;return this._post({fullWorkerDrawCount:this.drawCount,sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context59.stop();}},_callee57,this);}));function drawShape(_x123){return _drawShape.apply(this,arguments);}return drawShape;}()},{key:"drawPencil",value:function(){var _drawPencil=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee58(t){return _regeneratorRuntime().wrap(function _callee58$(_context60){while(1)switch(_context60.prev=_context60.next){case 0:_context60.next=2;return this._post({sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context60.stop();}},_callee58,this);}));function drawPencil(_x124){return _drawPencil.apply(this,arguments);}return drawPencil;}()},{key:"runEffectSelectWork",value:function(){var _runEffectSelectWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee59(t){var r,_iterator64,_step64,n,i,l,o;return _regeneratorRuntime().wrap(function _callee59$(_context61){while(1)switch(_context61.prev=_context61.next){case 0:_iterator64=_createForOfIteratorHelper(this.effectSelectNodeData.values());_context61.prev=1;_iterator64.s();case 3:if((_step64=_iterator64.n()).done){_context61.next=23;break;}n=_step64.value;i=this.setFullWork(n);if(!i){_context61.next=21;break;}l=(r=i.getWorkId())==null?void 0:r.toString();if(!(i.toolsType===pt.Image)){_context61.next=13;break;}_context61.next=11;return i.consumeServiceAsync({isFullWork:!0,replaceId:l,worker:this});case 11:_context61.next=20;break;case 13:if(!(i.toolsType===pt.Text)){_context61.next=18;break;}_context61.next=16;return i.consumeServiceAsync({isFullWork:!0,replaceId:l});case 16:_context61.next=20;break;case 18:o=n.ops&&Qe(n.ops);i.consumeService({op:o,isFullWork:!0,replaceId:l}),n!=null&&n.updateNodeOpt&&i.updataOptService(n.updateNodeOpt);case 20:n.workId&&this.workShapes["delete"](n.workId.toString());case 21:_context61.next=3;break;case 23:_context61.next=28;break;case 25:_context61.prev=25;_context61.t0=_context61["catch"](1);_iterator64.e(_context61.t0);case 28:_context61.prev=28;_iterator64.f();return _context61.finish(28);case 31:_context61.next=33;return this.reRenderSelector(t);case 33:case"end":return _context61.stop();}},_callee59,this,[[1,25,28,31]]);}));function runEffectSelectWork(_x125){return _runEffectSelectWork.apply(this,arguments);}return runEffectSelectWork;}()},{key:"cursorHover",value:function(){var _cursorHover=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee60(t){var o,r,n,i,l,a,c;return _regeneratorRuntime().wrap(function _callee60$(_context62){while(1)switch(_context62.prev=_context62.next){case 0:r=t.opt,n=t.toolsType,i=t.point,l=this.setFullWork({workId:He,toolsType:n,opt:r});if(!(l&&i)){_context62.next=8;break;}a=l.cursorHover(i),c={render:[]};_context62.t0=a&&a.type===dt.CursorHover&&a.rect;if(!_context62.t0){_context62.next=8;break;}(o=c.render)==null||o.push({rect:kt(a.rect),clearCanvas:Et.Bg,isClear:!0,viewId:this.viewId},{rect:kt(a.rect),drawCanvas:Et.Bg,viewId:this.viewId});_context62.next=8;return this._post(c);case 8:case"end":return _context62.stop();}},_callee60,this);}));function cursorHover(_x126){return _cursorHover.apply(this,arguments);}return cursorHover;}()},{key:"cursorBlur",value:function(){var _cursorBlur=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee61(){var n,t,r;return _regeneratorRuntime().wrap(function _callee61$(_context63){while(1)switch(_context63.prev=_context63.next){case 0:t=this.getWorkShape(He);_context63.t0=t&&(n=t.selectIds)!=null&&n.length;if(!_context63.t0){_context63.next=10;break;}r=t.oldSelectRect;t.cursorBlur();this.clearWorkShapeNodeCache(He);_context63.t1=r;if(!_context63.t1){_context63.next=10;break;}_context63.next=10;return this._post({render:[{rect:kt(r),clearCanvas:Et.Bg,isClear:!0,viewId:this.viewId},{rect:kt(r),drawCanvas:Et.Bg,viewId:this.viewId}]});case 10:this.fullLayer.parent.children.forEach(function(i){i.name==="Cursor_Hover_Id"&&i.remove();});case 11:case"end":return _context63.stop();}},_callee61,this);}));function cursorBlur(){return _cursorBlur.apply(this,arguments);}return cursorBlur;}()}]);}(hs);var gs=/*#__PURE__*/function(){function gs(e){_classCallCheck(this,gs);ot(this,"viewId");ot(this,"vNodes");ot(this,"fullLayer");ot(this,"drawLayer");ot(this,"workShapes",/* @__PURE__ */new Map());ot(this,"selectorWorkShapes",/* @__PURE__ */new Map());ot(this,"thread");ot(this,"animationId");ot(this,"willRunEffectSelectorIds",/* @__PURE__ */new Set());ot(this,"runEffectId");ot(this,"noAnimationRect");ot(this,"syncUnitTime",me.syncOpt.interval);ot(this,"post");this.viewId=e.viewId,this.vNodes=e.vNodes,this.fullLayer=e.fullLayer,this.drawLayer=e.drawLayer,this.thread=e.thread,this.post=e.thread.post.bind(e.thread);}return _createClass(gs,[{key:"destroy",value:function destroy(){this.workShapes.clear(),this.selectorWorkShapes.clear(),this.willRunEffectSelectorIds.clear();}},{key:"consumeDraw",value:function(){var _consumeDraw2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee62(e){return _regeneratorRuntime().wrap(function _callee62$(_context64){while(1)switch(_context64.prev=_context64.next){case 0:this.activeWorkShape(e),this.runAnimation();case 1:case"end":return _context64.stop();}},_callee62,this);}));function consumeDraw(_x127){return _consumeDraw2.apply(this,arguments);}return consumeDraw;}()},{key:"consumeFull",value:function consumeFull(e){this.activeWorkShape(e),this.runAnimation();}},{key:"runSelectWork",value:function runSelectWork(e){this.activeSelectorShape(e);var t=e.workId,r=t==null?void 0:t.toString();r&&this.willRunEffectSelectorIds.add(r),this.runEffect();}},{key:"setNodeKey",value:function setNodeKey(e,t,r,n){return t.toolsType=r,t.node=Ur({workId:e,toolsType:r,toolsOpt:n,vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer},this),t;}},{key:"runReverseSelectWork",value:function runReverseSelectWork(e){var _this95=this;e.forEach(function(t){_this95.selectorWorkShapes.forEach(function(r,n){var i;if((i=r.selectIds)!=null&&i.length){var l=r.selectIds.indexOf(t);l>-1&&(r.selectIds.splice(l,1),_this95.willRunEffectSelectorIds.add(n));}});}),this.willRunEffectSelectorIds.size&&this.runEffect();}},{key:"removeWork",value:function(){var _removeWork3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee63(e){var t,r,n;return _regeneratorRuntime().wrap(function _callee63$(_context65){while(1)switch(_context65.prev=_context65.next){case 0:t=e.workId,r=t==null?void 0:t.toString();if(!r){_context65.next=10;break;}n=this.workShapes.get(r);if(!n){_context65.next=8;break;}this.workShapes["delete"](r);_context65.next=7;return this.removeNode(r,e,n==null?void 0:n.totalRect,!1);case 7:return _context65.abrupt("return");case 8:_context65.next=10;return this.removeNode(r,e);case 10:case"end":return _context65.stop();}},_callee63,this);}));function removeWork(_x128){return _removeWork3.apply(this,arguments);}return removeWork;}()},{key:"removeSelectWork",value:function removeSelectWork(e){var t=e.workId,r=t==null?void 0:t.toString();r&&(this.activeSelectorShape(e),this.willRunEffectSelectorIds.add(r)),this.runEffect();}},{key:"removeNode",value:function(){var _removeNode=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee64(e,t,r){var _this96=this;var n,c,i,l,o,a,_args66=arguments;return _regeneratorRuntime().wrap(function _callee64$(_context66){while(1)switch(_context66.prev=_context66.next){case 0:n=_args66.length>3&&_args66[3]!==undefined?_args66[3]:!0;e.indexOf(qt)>-1&&this.removeSelectWork(t);i=r;l=(c=this.vNodes.get(e))==null?void 0:c.rect;l&&(i=bt(l,i));o=this.fullLayer&&At.getRectFromLayer(this.fullLayer,e);i=bt(i,o);a=this.drawLayer&&At.getRectFromLayer(this.drawLayer,e);i=bt(i,a);this.fullLayer.getElementsByName(e).forEach(function(m){m.remove(),_pe(m,_this96.fullLayer.parent);});this.drawLayer.getElementsByName(e).forEach(function(m){m.remove(),_pe(m,_this96.drawLayer.parent);});this.vNodes["delete"](e);_context66.t0=i;if(!_context66.t0){_context66.next=16;break;}_context66.next=16;return this.post({render:[{rect:kt(i),isClear:!0,clearCanvas:n?Et.Bg:Et.ServiceFloat,workerType:n?void 0:Dt.Service,viewId:this.viewId},{rect:kt(i),drawCanvas:n?Et.Bg:Et.ServiceFloat,workerType:n?void 0:Dt.Service,viewId:this.viewId}]});case 16:case"end":return _context66.stop();}},_callee64,this);}));function removeNode(_x129,_x130,_x131){return _removeNode.apply(this,arguments);}return removeNode;}()},{key:"activeWorkShape",value:function activeWorkShape(e){var E,T,P,x;var t=e.workId,r=e.opt,n=e.toolsType,i=e.type,l=e.updateNodeOpt,o=e.ops,a=e.op,c=e.useAnimation,m=e.isEnableCursor;if(!t)return;var f=t.toString(),v=(E=this.vNodes.get(f))==null?void 0:E.rect;if(!((T=this.workShapes)!=null&&T.has(f))){var _h46={toolsType:n,animationWorkData:a||[],animationIndex:0,type:i,updateNodeOpt:l,ops:o,useAnimation:_typeof(c)<"u"?c:_typeof(l==null?void 0:l.useAnimation)<"u"?l==null?void 0:l.useAnimation:!0,oldRect:v,isDiff:!1,isEnableCursor:m};n&&r&&(_h46=this.setNodeKey(f,_h46,n,r)),(P=this.workShapes)==null||P.set(f,_h46);}var S=(x=this.workShapes)==null?void 0:x.get(f);S.isEnableCursor=m,i&&(S.type=i),o&&(S.animationWorkData=Qe(o),S.ops=o),l&&(S.updateNodeOpt=l),a&&(S.isDiff=this.hasDiffData(S.animationWorkData||[],a,S.toolsType),S.animationWorkData=a),S.node&&S.node.getWorkId()!==f&&S.node.setWorkId(f),v&&(S.oldRect=v),n&&r&&(r.syncUnitTime&&(this.syncUnitTime=r.syncUnitTime),S.toolsType!==n&&n&&r&&this.setNodeKey(f,S,n,r),S.node&&S.node.setWorkOptions(r));}},{key:"hasDiffData",value:function hasDiffData(e,t,r){var n=e.length;if(t.length<n)return!0;switch(r){case pt.Pencil:{for(var i=0;i<n;i+=3)if(t[i]!==e[i]||t[i+1]!==e[i+1])return!0;break;}case pt.LaserPen:{for(var _i6=0;_i6<n;_i6+=2)if(t[_i6]!==e[_i6]||t[_i6+1]!==e[_i6+1])return!0;break;}}return!1;}},{key:"animationDraw",value:function(){var _animationDraw=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee65(){var _this97=this;var n,i,l,o,a,c,m,f,v,S,E,T,P,x,h,p,d,g,O,w,L,B,A,b,W,D,R,X,H,J,et,it,$,V,rt,lt,ct,gt,st,Ct,e,t,r,_iterator65,_step65,_loop6;return _regeneratorRuntime().wrap(function _callee65$(_context68){while(1)switch(_context68.prev=_context68.next){case 0:this.animationId=void 0;e=!1;t={render:[]},r=/* @__PURE__ */new Map();_iterator65=_createForOfIteratorHelper(this.workShapes.entries());_context68.prev=4;_loop6=/*#__PURE__*/_regeneratorRuntime().mark(function _loop6(){var _step65$value,xt,F,U,K,_U,_K,_U2,_K2,q,Y,_U3,_K3,_q,_Y2,k,C,M,_C,_U4,_K4,_q2,_Y3;return _regeneratorRuntime().wrap(function _loop6$(_context67){while(1)switch(_context67.prev=_context67.next){case 0:_step65$value=_slicedToArray(_step65.value,2),xt=_step65$value[0],F=_step65$value[1];_context67.t0=F.toolsType;_context67.next=_context67.t0===pt.Image?4:_context67.t0===pt.Text?11:_context67.t0===pt.Arrow?19:_context67.t0===pt.Straight?19:_context67.t0===pt.Rectangle?19:_context67.t0===pt.Ellipse?19:_context67.t0===pt.Star?19:_context67.t0===pt.Polygon?19:_context67.t0===pt.SpeechBalloon?19:_context67.t0===pt.Pencil?22:38;break;case 4:U=F.oldRect;U&&((n=t.render)==null||n.push({rect:U,isClear:!0,clearCanvas:Et.Bg,viewId:_this97.viewId}),(i=t.render)==null||i.push({rect:U,drawCanvas:Et.Bg,viewId:_this97.viewId}));_context67.next=8;return(l=F.node)==null?void 0:l.consumeServiceAsync({isFullWork:!0,worker:_this97.thread});case 8:K=_context67.sent;_this97.selectorWorkShapes.forEach(function(q,Y){var k;(k=q.selectIds)!=null&&k.includes(xt)&&(_this97.willRunEffectSelectorIds.add(Y),_this97.noAnimationRect=bt(_this97.noAnimationRect,U),_this97.noAnimationRect=bt(_this97.noAnimationRect,K),_this97.runEffect());}),_this97.workShapes["delete"](xt),(o=t.render)==null||o.push({rect:K,drawCanvas:Et.Bg,viewId:_this97.viewId});return _context67.abrupt("break",38);case 11:if(!F.node){_context67.next=18;break;}_U=F.oldRect;_U&&((a=t.render)==null||a.push({rect:_U,isClear:!0,clearCanvas:Et.Bg,viewId:_this97.viewId}),(c=t.render)==null||c.push({rect:_U,drawCanvas:Et.Bg,viewId:_this97.viewId}));_context67.next=16;return F.node.consumeServiceAsync({isFullWork:!0,replaceId:xt});case 16:_K=_context67.sent;_this97.selectorWorkShapes.forEach(function(q,Y){var k;(k=q.selectIds)!=null&&k.includes(xt)&&(_this97.willRunEffectSelectorIds.add(Y),_this97.noAnimationRect=bt(_this97.noAnimationRect,_U),_this97.noAnimationRect=bt(_this97.noAnimationRect,_K),_this97.runEffect());}),(m=F.node)==null||m.clearTmpPoints(),_this97.workShapes["delete"](xt),(f=t.render)==null||f.push({rect:_K,drawCanvas:Et.Bg,viewId:_this97.viewId});case 18:return _context67.abrupt("break",38);case 19:_U2=!!F.ops;if((v=F.animationWorkData)!=null&&v.length){_K2=F.oldRect,q=F.node.oldRect;_K2&&((S=t.render)==null||S.push({rect:_K2,isClear:!0,clearCanvas:Et.Bg,viewId:_this97.viewId}),(E=t.render)==null||E.push({rect:_K2,drawCanvas:Et.Bg,viewId:_this97.viewId})),q&&((T=t.render)==null||T.push({rect:q,isClear:!0,clearCanvas:Et.ServiceFloat,viewId:_this97.viewId}));Y=(P=F.node)==null?void 0:P.consumeService({op:F.animationWorkData,isFullWork:_U2});F.isEnableCursor?r.set(xt,{workState:_K2?F.ops?Ft.Done:Ft.Doing:Ft.Start,op:F.animationWorkData.slice(-3,-1)}):_U2&&!F.useAnimation&&(x=F.updateNodeOpt)!=null&&x.useAnimation&&r.set(xt,{workState:Ft.Done,op:F.animationWorkData.slice(-3,-1),uid:(h=F.updateNodeOpt)==null?void 0:h.uid}),_U2?(_this97.selectorWorkShapes.forEach(function(k,C){var M;(M=k.selectIds)!=null&&M.includes(xt)&&(_this97.willRunEffectSelectorIds.add(C),_this97.noAnimationRect=bt(_this97.noAnimationRect,_K2),_this97.noAnimationRect=bt(_this97.noAnimationRect,q),_this97.noAnimationRect=bt(_this97.noAnimationRect,Y),_this97.runEffect());}),(p=F.node)==null||p.clearTmpPoints(),_this97.workShapes["delete"](xt),(d=t.render)==null||d.push({rect:Y,drawCanvas:Et.Bg,viewId:_this97.viewId})):(g=t.render)==null||g.push({rect:Y,drawCanvas:Et.ServiceFloat,workerType:_U2?void 0:Dt.Service,viewId:_this97.viewId}),F.animationWorkData.length=0;}return _context67.abrupt("break",38);case 22:if(!F.useAnimation){_context67.next=33;break;}if(!F.useAnimation){_context67.next=31;break;}if(!F.isDel){_context67.next=27;break;}(et=F.node)==null||et.clearTmpPoints(),_this97.workShapes["delete"](xt);return _context67.abrupt("break",38);case 27:_U3=3,_K3=_this97.computNextAnimationIndex(F,_U3),_q=F.isDiff?0:Math.max(0,(F.animationIndex||0)-_U3),_Y2=(F.animationWorkData||[]).slice(0,_K3),k=($=(it=F.node)==null?void 0:it.getWorkId())==null?void 0:$.toString();if((F.animationIndex||0)<_K3||F.isDiff){C=(V=F.node)==null?void 0:V.consumeService({op:_Y2,isFullWork:!1,replaceId:k});if((rt=t.render)==null||rt.push({isClear:!0,rect:C,clearCanvas:Et.ServiceFloat,viewId:_this97.viewId}),(lt=t.render)==null||lt.push({rect:C,drawCanvas:Et.ServiceFloat,viewId:_this97.viewId}),F.animationIndex=_K3,F.isDiff&&(F.isDiff=!1),_Y2.length&&F.isEnableCursor){M=_Y2.slice(-3,-1);r.set(xt,{workState:_q===0?Ft.Start:_K3===((ct=F.animationWorkData)==null?void 0:ct.length)?Ft.Done:Ft.Doing,op:M});}}else if(F.ops){_C=(gt=F.node)==null?void 0:gt.consumeService({op:F.animationWorkData||[],isFullWork:!0,replaceId:k});F.isDel=!0,(st=t.render)==null||st.push({isClear:!0,rect:_C,clearCanvas:Et.ServiceFloat,viewId:_this97.viewId},{rect:_C,drawCanvas:Et.ServiceFloat,viewId:_this97.viewId},{isClear:!0,rect:_C,clearCanvas:Et.Bg,viewId:_this97.viewId},{rect:_C,drawCanvas:Et.Bg,viewId:_this97.viewId}),F.isEnableCursor&&r.set(xt,{workState:Ft.Done,op:_Y2.slice(-3,-1)});}e=!0;return _context67.abrupt("break",38);case 31:_context67.next=37;break;case 33:_U4=!!F.ops;_K4=(O=F.node)==null?void 0:O.consumeService({op:F.animationWorkData||[],isFullWork:_U4,replaceId:xt});_q2=(w=F.node)==null?void 0:w.updataOptService(F.updateNodeOpt);if(_U4){if(_K4=bt(_K4,_q2),(L=t.render)==null||L.push({isClear:!0,rect:bt(F.oldRect,_K4),clearCanvas:Et.Bg,viewId:_this97.viewId}),(B=t.render)==null||B.push({rect:bt(F.oldRect,_K4),drawCanvas:Et.Bg,viewId:_this97.viewId}),(A=F.updateNodeOpt)!=null&&A.useAnimation&&((b=t.render)==null||b.push({isClear:!0,rect:bt(F.oldRect,_K4),clearCanvas:Et.ServiceFloat,viewId:_this97.viewId}),(W=t.render)==null||W.push({rect:bt(F.oldRect,_K4),drawCanvas:Et.ServiceFloat,viewId:_this97.viewId}),!F.isEnableCursor&&(D=F.animationWorkData)!=null&&D.length)){_Y3=F.animationWorkData.slice(-3,-1);r.set(xt,{workState:Ft.Done,op:_Y3,uid:(R=F.updateNodeOpt)==null?void 0:R.uid});}_this97.selectorWorkShapes.forEach(function(Y,k){var C;(C=Y.selectIds)!=null&&C.includes(xt)&&(_this97.willRunEffectSelectorIds.add(k),_this97.noAnimationRect=bt(_this97.noAnimationRect,_K4),_this97.runEffect());}),(X=F.node)==null||X.clearTmpPoints(),_this97.workShapes["delete"](xt);}else _K4=bt(_K4,_q2),(H=t.render)==null||H.push({isClear:!0,rect:bt(F.oldRect,_K4),clearCanvas:Et.ServiceFloat,viewId:_this97.viewId}),(J=t.render)==null||J.push({rect:bt(F.oldRect,_K4),drawCanvas:Et.ServiceFloat,viewId:_this97.viewId});case 37:return _context67.abrupt("break",38);case 38:case"end":return _context67.stop();}},_loop6);});_iterator65.s();case 7:if((_step65=_iterator65.n()).done){_context68.next=11;break;}return _context68.delegateYield(_loop6(),"t0",9);case 9:_context68.next=7;break;case 11:_context68.next=16;break;case 13:_context68.prev=13;_context68.t1=_context68["catch"](4);_iterator65.e(_context68.t1);case 16:_context68.prev=16;_iterator65.f();return _context68.finish(16);case 19:e&&this.runAnimation();r.size&&(t.sp=[],r.forEach(function(xt,F){var U;(U=t.sp)==null||U.push({type:dt.Cursor,uid:xt.uid||F.split(Je)[0],op:xt.op,workState:xt.workState,viewId:_this97.viewId});}));_context68.t2=(Ct=t.render)!=null&&Ct.length;if(!_context68.t2){_context68.next=25;break;}_context68.next=25;return this.post(t);case 25:case"end":return _context68.stop();}},_callee65,this,[[4,13,16,19]]);}));function animationDraw(){return _animationDraw.apply(this,arguments);}return animationDraw;}()},{key:"runAnimation",value:function runAnimation(){var _this98=this;this.animationId||(this.animationId=setTimeout(function(){_this98.animationId=void 0,_this98.animationDraw();},16));}},{key:"computNextAnimationIndex",value:function computNextAnimationIndex(e,t){var r=Math.floor((e.animationWorkData||[]).slice(e.animationIndex).length*48/t/this.syncUnitTime)*t;return Math.min((e.animationIndex||0)+(r||t),(e.animationWorkData||[]).length);}},{key:"runEffect",value:function runEffect(){this.runEffectId||(this.runEffectId=setTimeout(this.effectRunSelector.bind(this),0));}},{key:"effectRunSelector",value:function(){var _effectRunSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee66(){var _this99=this;var e;return _regeneratorRuntime().wrap(function _callee66$(_context69){while(1)switch(_context69.prev=_context69.next){case 0:this.runEffectId=void 0;e=this.noAnimationRect;this.willRunEffectSelectorIds.forEach(function(t){var i,l;var r=_this99.selectorWorkShapes.get(t),n=r&&r.selectIds&&((i=r.node)==null?void 0:i.selectServiceNode(t,r,!0));e=bt(e,n),(l=r==null?void 0:r.selectIds)!=null&&l.length||_this99.selectorWorkShapes["delete"](t);});_context69.t0=e;if(!_context69.t0){_context69.next=7;break;}_context69.next=7;return this.post({render:[{rect:kt(e),isClear:!0,clearCanvas:Et.Bg,viewId:this.viewId},{rect:kt(e),drawCanvas:Et.Bg,viewId:this.viewId}]});case 7:this.willRunEffectSelectorIds.clear();this.noAnimationRect=void 0;case 9:case"end":return _context69.stop();}},_callee66,this);}));function effectRunSelector(){return _effectRunSelector.apply(this,arguments);}return effectRunSelector;}()},{key:"activeSelectorShape",value:function activeSelectorShape(e){var m,f,v;var t=e.workId,r=e.opt,n=e.toolsType,i=e.type,l=e.selectIds,o=e.imageBitmap;if(!t)return;var a=t.toString();if(!((m=this.selectorWorkShapes)!=null&&m.has(a))){var S={toolsType:n,selectIds:l,type:i,opt:r,imageBitmap:o};n&&r&&(S=this.setNodeKey(a,S,n,r)),(f=this.selectorWorkShapes)==null||f.set(a,S);}var c=(v=this.selectorWorkShapes)==null?void 0:v.get(a);i&&(c.type=i),c.node&&c.node.getWorkId()!==a&&c.node.setWorkId(a),o&&(c.imageBitmap=o),c.selectIds=l||[];}}]);}();var oy=/*#__PURE__*/function(_hs2){function oy(t){var _this100;_classCallCheck(this,oy);_this100=_callSuper(this,oy,[t]);ot(_this100,"drawWorkActiveId");return _this100;}// async runFullWork(data: IWorkerMessage): Promise<IRectType | undefined> {
439
+ ot(Ze,"eraserSizes",fn);var Mr=Ze;function is(u){switch(u){case pt.Arrow:return Qi;case pt.Pencil:return Vi;case pt.Straight:return ns;case pt.Ellipse:return qi;case pt.Polygon:case pt.Triangle:return es;case pt.Star:case pt.Rhombus:return ts;case pt.Rectangle:return _i;case pt.SpeechBalloon:return rs;case pt.Text:return cr;case pt.LaserPen:return Ki;case pt.Eraser:return Ir;case pt.PencilEraser:return Er;case pt.BitMapEraser:return Mr;case pt.Selector:return ar;case pt.Image:return lr;}}function Ur(u,e){var t=u.toolsType,r=_objectWithoutProperties(u,_excluded);switch(t){case pt.Arrow:return new Qi(r);case pt.Pencil:return new Vi(r);case pt.Straight:return new ns(r);case pt.Ellipse:return new qi(r);case pt.Polygon:case pt.Triangle:return new es(r);case pt.Star:case pt.Rhombus:return new ts(r);case pt.Rectangle:return new _i(r);case pt.SpeechBalloon:return new rs(r);case pt.Text:return new cr(r);case pt.LaserPen:return new Ki(r);case pt.Eraser:return new Ir(r,e);case pt.BitMapEraser:return new Mr(r);case pt.PencilEraser:return new Er(r);case pt.Selector:return r.vNodes?new ar(_objectSpread(_objectSpread({},r),{},{vNodes:r.vNodes,drawLayer:r.fullLayer})):void 0;case pt.Image:return new lr(r);default:return;}}function ss(u){var e=[],t=["PATH","SPRITE","POLYLINE","RECT","ELLIPSE","LABEL"];var _iterator41=_createForOfIteratorHelper(u),_step41;try{for(_iterator41.s();!(_step41=_iterator41.n()).done;){var r=_step41.value;if(r.tagName==="GROUP"&&r.children.length){var n=ss(r.children);e.push.apply(e,_toConsumableArray(n));}r.tagName&&t.includes(r.tagName)&&e.push(r);}}catch(err){_iterator41.e(err);}finally{_iterator41.f();}return e;}function bt(u,e){if(u&&e){var t=Math.min(u.x,e.x),r=Math.min(u.y,e.y),n=Math.max(u.x+u.w,e.x+e.w),i=Math.max(u.y+u.h,e.y+e.h),l=n-t,o=i-r;return{x:t,y:r,w:l,h:o};}return e||u;}function _t(u){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var t={x:0,y:0,w:0,h:0};var r=1/0,n=1/0,i=-1/0,l=-1/0;return u.forEach(function(o){var _o$XY=_slicedToArray(o.XY,2),a=_o$XY[0],c=_o$XY[1];r=Math.min(r,a-e),n=Math.min(n,c-e),i=Math.max(i,a+e),l=Math.max(l,c+e);}),t.x=r,t.y=n,t.w=i-r,t.h=l-n,t;}function Jr(u,e){return!(u.x+u.w<e.x||u.x>e.x+e.w||u.y+u.h<e.y||u.y>e.y+e.h);}function kt(u){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;return{x:Math.floor(u.x-e),y:Math.floor(u.y-e),w:Math.ceil(u.w+e*2),h:Math.ceil(u.h+e*2)};}function fr(u,e){return{x:u.x+e[0],y:u.y+e[1],w:u.w,h:u.h};}function dm(u,e){var t=new at(u.x,u.y),r=new at(u.x+u.w,u.y),n=new at(u.x+u.w,u.y+u.h),i=new at(u.x,u.y+u.h),l=new at(u.x+u.w/2,u.y+u.h/2),o=Math.PI*e/180,a=at.RotWith(t,l,o),c=at.RotWith(r,l,o),m=at.RotWith(n,l,o),f=at.RotWith(i,l,o);return[a,c,m,f];}function os(u,e){var t=dm(u,e);return _t(t);}function as(u,e,t){var r=new at(u.x,u.y),n=new at(u.x+u.w,u.y),i=new at(u.x+u.w,u.y+u.h),l=new at(u.x,u.y+u.h),o=new at(t[0],t[1]),a=new at(e[0],e[1]),c=at.ScaleWOrigin(r,a,o),m=at.ScaleWOrigin(n,a,o),f=at.ScaleWOrigin(i,a,o),v=at.ScaleWOrigin(l,a,o);return _t([c,m,f,v]);}function pm(u,e,t){var r=new at(e[0],e[1]);for(var n=0;n<u.length;n+=3){var i=new at(u[n],u[n+1]),l=Math.PI*t/180,o=at.RotWith(i,r,l);u[n]=o.x,u[n+1]=o.y;}}function mm(u,e,t){var r=new at(e[0],e[1]);for(var n=0;n<u.length;n+=2){var i=new at(u[n],u[n+1]),l=Math.PI*t/180,o=at.RotWith(i,r,l);u[n]=o.x,u[n+1]=o.y;}}function vn(u,e,t){var r=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[0,0];var n=new at(e[0],e[1]);for(var i=0;i<u.length;i+=3){var l=new at(u[i],u[i+1]),o=new at(t[0],t[1]),a=at.ScaleWOrigin(l,o,n);u[i]=a.x+r[0],u[i+1]=a.y+r[1];}}function yn(u,e,t){var r=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[0,0];var n=new at(e[0],e[1]);for(var i=0;i<u.length;i+=2){var l=new at(u[i],u[i+1]),o=new at(t[0],t[1]),a=at.ScaleWOrigin(l,o,n);u[i]=a.x+r[0],u[i+1]=a.y+r[1];}}function vm(u,e){return u[0]>=e.x&&u[0]<=e.x+e.w&&u[1]>=e.y&&u[1]<=e.y+e.h;}function ls(u,e){var t=u<=e?1:u/e,r=e<=u?1:e/u;return[t,r];}function ym(u){var _iterator42=_createForOfIteratorHelper(u),_step42;try{for(_iterator42.s();!(_step42=_iterator42.n()).done;){var _e3=_step42.value;if(isNaN(_e3)||_e3===1/0||_e3===-1/0)return!1;}}catch(err){_iterator42.e(err);}finally{_iterator42.f();}return!0;}function gm(u){return u!==Math.floor(u);}function Pm(u){var e=u.toString();return e.indexOf(".")!==-1?e.split(".")[1].length:0;}function Sm(u,e){for(;e!==0;){var _ref169=[e,u%e];u=_ref169[0];e=_ref169[1];}return u;}var xm=function xm(u){if(u.tagName==="GROUP"){var _e4=Object.getOwnPropertySymbols(u).find(function(t){return t.toString()==="Symbol(sealed)";});if(_e4&&u[_e4])return!0;}return!1;},_pe=function pe(u,e){if(u.mesh&&u.mesh.texture&&u.name==="eraserTexture"){var t=u.mesh.texture.image;e.deleteTexture(t);}else if(u.tagName==="GROUP"&&u&&u.children){var _iterator43=_createForOfIteratorHelper(u.children),_step43;try{for(_iterator43.s();!(_step43=_iterator43.n()).done;){var _t3=_step43.value;_pe(_t3,e);}}catch(err){_iterator43.e(err);}finally{_iterator43.f();}}},Se=function Se(u,e){_pe(u,e),u.removeAllChildren();},Tm=function Tm(u,e,t){var r=t.parent;if(e){var n=e.children;if(n){var _iterator44=_createForOfIteratorHelper(n),_step44;try{for(_iterator44.s();!(_step44=_iterator44.n()).done;){var i=_step44.value;if(_pe(i,r),i.tagName==="GROUP"){var _iterator45=_createForOfIteratorHelper(i.children),_step45;try{for(_iterator45.s();!(_step45=_iterator45.n()).done;){var l=_step45.value;_pe(l,r);}}catch(err){_iterator45.e(err);}finally{_iterator45.f();}}}}catch(err){_iterator44.e(err);}finally{_iterator44.f();}}}e.parent.replaceChild(u,e);},cs=function cs(u,e,t){if(u.w+u.x<=0||u.h+u.y<=0||u.w<=0||u.h<=0)return;var r=e.width,n=e.height,i={x:Math.floor(Math.max(0,u.x)),y:Math.floor(Math.max(0,u.y)),w:Math.floor(Math.min(r,u.w)),h:Math.floor(Math.min(n,u.h))};if(i.x+i.w>r&&(i.w=Math.floor(r-i.x)),i.y+i.h>n&&(i.h=Math.floor(n-i.y)),gm(t)){var l=Pm(t),o=Math.pow(10,l),a=Sm(o,t*o),c=i.x%a,m=i.x-c;m>=0?(i.x=m,i.w=i.w+c):(i.x=0,i.w=i.w+c-m);var f=i.y%a,v=i.y-f;v>=0?(i.y=v,i.h=i.h+f):(i.y=0,i.h=i.h+f-v);}return i;};function ze(u){return"".concat(Ar(u.x),",").concat(Ar(u.y)," ");}function $e(u,e){return"".concat(Ar((u.x+e.x)/2),",").concat(Ar((u.y+e.y)/2)," ");}function Ar(u){return+u.toFixed(4);}var or=function or(u,e){return u.x+u.w<e.x||u.x>e.x+e.w||u.y+u.h<e.y||u.y>e.y+e.h?Pe.outside:u.x>=e.x&&u.y>=e.y&&u.x+u.w<=e.x+e.w&&u.y+u.h<=e.y+e.h?Pe.inside:Pe.intersect;};function Cm(u){var e=0;for(var t=0;t<u.length;t++){var r=u.charCodeAt(t);r>=1&&r<=126||65376<=r&&r<=65439?e++:e+=2;}return e;}var He="cursorhover",si=20,hr="mainView";var Im=/*#__PURE__*/function(){function Im(e,t){_classCallCheck(this,Im);ot(this,"viewId");ot(this,"scene");ot(this,"fullLayer");ot(this,"curNodeMap",/* @__PURE__ */new Map());ot(this,"targetNodeMap",[]);ot(this,"highLevelIds");ot(this,"canClearUids");ot(this,"localUid");this.viewId=e,this.scene=t;}return _createClass(Im,[{key:"init",value:function init(e){this.fullLayer=e;}},{key:"get",value:function get(e){return this.curNodeMap.get(e);}},{key:"setLocalUid",value:function setLocalUid(e){this.localUid=e;}},{key:"getLocalUid",value:function getLocalUid(){return this.localUid;}},{key:"setCanClearUids",value:function setCanClearUids(e){this.canClearUids=e;}},{key:"getCanClearUids",value:function getCanClearUids(){return this.canClearUids;}},{key:"getCanEraserNodes",value:function getCanEraserNodes(e,t){var r=/* @__PURE__ */new Map();var _iterator46=_createForOfIteratorHelper(e.entries()),_step46;try{for(_iterator46.s();!(_step46=_iterator46.n()).done;){var _step46$value=_slicedToArray(_step46.value,2),n=_step46$value[0],i=_step46$value[1];i.toolsType===pt.Image&&(i.opt.locked||t&&t.disableEraseImage)||i.toolsType===pt.Text&&(i.opt.workState===Ft.Doing||i.opt.workState===Ft.Start||t&&t.disableEraseText)||this.isCanClearWorkId(n)&&r.set(n,i);}}catch(err){_iterator46.e(err);}finally{_iterator46.f();}return r;}},{key:"getNodesByType",value:function getNodesByType(e){var t=/* @__PURE__ */new Map();return this.curNodeMap.forEach(function(r,n){r.toolsType===e&&t.set(n,r);}),t;}},{key:"gethasEraserNodes",value:function gethasEraserNodes(){var e=/* @__PURE__ */new Map();return this.curNodeMap.forEach(function(t,r){var n;(n=t.opt.eraserlines)!=null&&n.length&&e.set(r,t);}),e;}},{key:"hasRenderNodes",value:function hasRenderNodes(){return!0;}},{key:"has",value:function has(e){return this.curNodeMap.has(e);}},{key:"setInfo",value:function setInfo(e,t){var r=this.curNodeMap.get(e)||{name:e,rect:t.rect};t.rect&&(r.rect=ue(t.rect)),t.op&&ym(t.op)&&(r.op=ue(t.op)),t.canRotate&&(r.canRotate=t.canRotate),t.scaleType&&(r.scaleType=t.scaleType),t.opt&&(r.opt=ue(t.opt)),t.toolsType&&(r.toolsType=t.toolsType),t.centerPos&&(r.centerPos=ue(t.centerPos)),ke(t.isSelected)&&(r.isSelected=t.isSelected),r.rect?this.curNodeMap.set(e,r):this.curNodeMap["delete"](e);}},{key:"selected",value:function selected(e){this.setInfo(e,{isSelected:!0});}},{key:"unSelected",value:function unSelected(e){this.setInfo(e,{isSelected:!1});}},{key:"delete",value:function _delete(e){this.curNodeMap["delete"](e);}},{key:"clear",value:function clear(){this.curNodeMap.clear(),this.targetNodeMap.length=0;}},{key:"getRectIntersectRange",value:function getRectIntersectRange(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!0;var n;var i=/* @__PURE__ */new Map();var _iterator47=_createForOfIteratorHelper(this.curNodeMap.entries()),_step47;try{for(_iterator47.s();!(_step47=_iterator47.n()).done;){var _step47$value=_slicedToArray(_step47.value,2),l=_step47$value[0],o=_step47$value[1];if(Jr(e,o.rect)){if(t&&o.toolsType===pt.Image&&o.opt.locked||r&&o.toolsType===pt.Text&&(o.opt.workState===Ft.Doing||o.opt.workState===Ft.Start))continue;n=bt(n,o.rect),i.set(l,o);}}}catch(err){_iterator47.e(err);}finally{_iterator47.f();}return{rectRange:n,nodeRange:i};}},{key:"getNodeRectFormShape",value:function getNodeRectFormShape(e,t){var r=is(t.toolsType);return this.fullLayer&&(r==null?void 0:r.getRectFromLayer(this.fullLayer,e));}},{key:"updateNodeRect",value:function updateNodeRect(e){var t=this.curNodeMap.get(e);if(t){var r=this.getNodeRectFormShape(e,t);if(!r){this.curNodeMap["delete"](e);return;}t.rect=r,this.curNodeMap.set(e,t);}}},{key:"updateHighLevelNodesRect",value:function updateHighLevelNodesRect(e){this.highLevelIds=e;var _iterator48=_createForOfIteratorHelper(this.highLevelIds.keys()),_step48;try{for(_iterator48.s();!(_step48=_iterator48.n()).done;){var t=_step48.value;this.updateNodeRect(t);}}catch(err){_iterator48.e(err);}finally{_iterator48.f();}}},{key:"updateLowLevelNodesRect",value:function updateLowLevelNodesRect(){var e;var _iterator49=_createForOfIteratorHelper(this.curNodeMap.keys()),_step49;try{for(_iterator49.s();!(_step49=_iterator49.n()).done;){var t=_step49.value;(e=this.highLevelIds)!=null&&e.has(t)||this.updateNodeRect(t);}}catch(err){_iterator49.e(err);}finally{_iterator49.f();}}},{key:"clearHighLevelIds",value:function clearHighLevelIds(){this.highLevelIds=void 0;}},{key:"setTargetAssignKeys",value:function setTargetAssignKeys(e){var t=/* @__PURE__ */new Map();var _iterator50=_createForOfIteratorHelper(e),_step50;try{for(_iterator50.s();!(_step50=_iterator50.n()).done;){var r=_step50.value;var n=this.curNodeMap.get(r);n&&t.set(r,ue(n));}}catch(err){_iterator50.e(err);}finally{_iterator50.f();}return this.targetNodeMap.push(ue(t)),this.targetNodeMap.length-1;}},{key:"setTarget",value:function setTarget(){return this.targetNodeMap.push(ue(this.curNodeMap)),this.targetNodeMap.length-1;}},{key:"getLastTarget",value:function getLastTarget(){return this.targetNodeMap[this.targetNodeMap.length-1];}},{key:"deleteLastTarget",value:function deleteLastTarget(){this.targetNodeMap.length&&(this.targetNodeMap.length=this.targetNodeMap.length-1);}},{key:"getTarget",value:function getTarget(e){return this.targetNodeMap[e];}},{key:"deleteTarget",value:function deleteTarget(e){this.targetNodeMap.length=e;}},{key:"clearTarget",value:function clearTarget(){this.targetNodeMap.length=0;}},{key:"isLocalWorkId",value:function isLocalWorkId(e){return e.split(Je).length===1;}},{key:"isCanClearWorkId",value:function isCanClearWorkId(e){if(this.canClearUids===void 0||this.canClearUids===!0)return!0;if(Vd(this.canClearUids)){var t=e.split(Je);if(t.length===1)return this.canClearUids.has("localSelf")||this.localUid&&this.canClearUids.has(this.localUid);if(t.length===2)return this.canClearUids.has(t[0]);}return!1;}}]);}();var fs=/*#__PURE__*/function(){function fs(e,t,r){_classCallCheck(this,fs);ot(this,"viewId");ot(this,"type");ot(this,"scene");ot(this,"fullLayer");ot(this,"vNodes");ot(this,"dpr");ot(this,"contextType");ot(this,"opt");ot(this,"cameraOpt");ot(this,"isSafari",!1);ot(this,"combinePostMsg",/* @__PURE__ */new Set());ot(this,"workerTaskId");ot(this,"protectedTask");// protected hasPriorityDraw: boolean = true;
440
+ ot(this,"delayPostDoneResolve");ot(this,"cacheImages",/* @__PURE__ */new Map());ot(this,"imageResolveMap",/* @__PURE__ */new Map());ot(this,"taskUpdateCameraId");ot(this,"debounceUpdateCameraId");var n,i;if(this.viewId=e,this.type=r,this.opt=t,this.dpr=t.dpr,this.contextType=this.getSupportContextType(r,(n=t==null?void 0:t.offscreenCanvasOpt)==null?void 0:n.contextType),!this.contextType)throw new Error("Sorry, your browser doesn't support canvas context type 2d or webgl");try{this.scene=this.createScene(t),this.createRenderLayer(this.scene,t);}catch(l){if(this.contextType!=="2d")this.contextType="2d",(i=this.scene)==null||i.disconnect(),this.scene=this.createScene(t),this.createRenderLayer(this.scene,t);else throw l;}this.vNodes=new Im(e,this.scene);}return _createClass(fs,[{key:"createRenderLayer",value:function createRenderLayer(e,t){var r=me.bufferSize.full,n=me.bufferSize.sub;this.fullLayer=this.createLayer("fullLayer",e,_objectSpread(_objectSpread({},t.layerOpt),{},{bufferSize:this.viewId===hr?r:n*2}));}},{key:"updateDpr",value:function(){var _updateDpr=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28(e){return _regeneratorRuntime().wrap(function _callee28$(_context30){while(1)switch(_context30.prev=_context30.next){case 0:this.dpr=e,this.scene.displayRatio=e;case 1:case"end":return _context30.stop();}},_callee28,this);}));function updateDpr(_x85){return _updateDpr.apply(this,arguments);}return updateDpr;}()},{key:"getCachedImages",value:function getCachedImages(e){var t;return(t=this.cacheImages.get(e))==null?void 0:t.imageBitmap;}},{key:"getCachedImagesByWorkId",value:function getCachedImagesByWorkId(e){var _iterator51=_createForOfIteratorHelper(this.cacheImages.entries()),_step51;try{for(_iterator51.s();!(_step51=_iterator51.n()).done;){var _step51$value=_slicedToArray(_step51.value,2),t=_step51$value[0],r=_step51$value[1];if(t===e&&r.imageBitmap)return r.imageBitmap;}}catch(err){_iterator51.e(err);}finally{_iterator51.f();}}},{key:"deleteCachedImagesByWorkId",value:function deleteCachedImagesByWorkId(e,t){var _iterator52=_createForOfIteratorHelper(this.cacheImages.entries()),_step52;try{for(_iterator52.s();!(_step52=_iterator52.n()).done;){var _step52$value=_slicedToArray(_step52.value,2),r=_step52$value[0],n=_step52$value[1];t&&r===t||n.workId===e&&(n.imageBitmap.close(),this.cacheImages["delete"](r));}}catch(err){_iterator52.e(err);}finally{_iterator52.f();}}},{key:"clearCacheImages",value:function clearCacheImages(){this.cacheImages.forEach(function(e){return e.imageBitmap.close();}),this.cacheImages.clear();}},{key:"clearImageResolveMap",value:function clearImageResolveMap(){this.imageResolveMap.forEach(function(_ref170){var e=_ref170.timer;e&&clearTimeout(e);}),this.imageResolveMap.clear();}},{key:"setIsSafari",value:function setIsSafari(e){this.isSafari=e;}},{key:"on",value:function(){var _on=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee29(e){var t,r,n,i,l,o,a,c,_c7,m,f,v;return _regeneratorRuntime().wrap(function _callee29$(_context31){while(1)switch(_context31.prev=_context31.next){case 0:t=e.msgType,r=e.toolsType,n=e.opt,i=e.imageSrc,l=e.imageBitmap,o=e.workId,a=e.dpr;_context31.t0=t;_context31.next=_context31.t0===dt.UpdateDpr?4:_context31.t0===dt.UpdateCamera?9:_context31.t0===dt.Destroy?12:_context31.t0===dt.Clear?14:_context31.t0===dt.UpdateTools?17:_context31.t0===dt.GetImageBitMap?19:21;break;case 4:_context31.t1=he(a);if(!_context31.t1){_context31.next=8;break;}_context31.next=8;return this.updateDpr(a);case 8:return _context31.abrupt("break",21);case 9:_context31.next=11;return this.updateCamera(e);case 11:return _context31.abrupt("break",21);case 12:this.destroy();return _context31.abrupt("break",21);case 14:_context31.next=16;return this.clearAll();case 16:return _context31.abrupt("break",21);case 17:if(r&&n){c={toolsType:r,toolsOpt:n,combineUnitTime:e.combineUnitTime,maxCombineEraserTime:e.maxCombineEraserTime};this.localWork.setToolsOpt(c);}return _context31.abrupt("break",21);case 19:if(i&&l&&o){_c7=o.toString();this.cacheImages.set(i,{imageBitmap:l,workId:_c7});m=this.imageResolveMap.get(i);if(m){f=m.resolve,v=m.timer;v&&clearTimeout(v),f&&f(i);}this.deleteCachedImagesByWorkId(_c7,i);}return _context31.abrupt("break",21);case 21:case"end":return _context31.stop();}},_callee29,this);}));function on(_x86){return _on.apply(this,arguments);}return on;}()},{key:"getIconSize",value:function getIconSize(e,t,r){var n=e*r,i=t*r;return n<=50||i<=50?[50,50]:n<=100||i<=100?[100,100]:n<=200||i<=200?[200,200]:n<=400||i<=400?[400,400]:n<=800||i<=800?[800,800]:[1600,1600];}},{key:"loadImageBitMap",value:function(){var _loadImageBitMap=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee30(e){var _this88=this;var t,r,n,i,l,o,a,c,m,f,v,_this$getIconSize,_this$getIconSize2,P,_x88,_P20,_P21,T;return _regeneratorRuntime().wrap(function _callee30$(_context32){while(1)switch(_context32.prev=_context32.next){case 0:t=e.toolsType,r=e.opt,n=e.workId,i=e.isSubWorker;if(!(t===pt.Image&&r&&n)){_context32.next=19;break;}l=n.toString(),o=r.src,a=r.type,c=r.width,m=r.height,f=r.strokeColor;if(!(!o||!a||!c||!m)){_context32.next=5;break;}return _context32.abrupt("return");case 5:v=o;if(a===Qr.Iconify){_this$getIconSize=this.getIconSize(c,m,this.dpr),_this$getIconSize2=_slicedToArray(_this$getIconSize,2),P=_this$getIconSize2[0],_x88=_this$getIconSize2[1];v="".concat(o,"?width=").concat(P,"&height=").concat(_x88,"&color=").concat(f);}if(!this.cacheImages.has(v)){_context32.next=11;break;}_P20=this.getCachedImages(v);if(!_P20){_context32.next=11;break;}return _context32.abrupt("return",_P20);case 11:if(!this.imageResolveMap.has(v)){_context32.next=15;break;}_P21=this.getCachedImagesByWorkId(l);if(!_P21){_context32.next=15;break;}return _context32.abrupt("return",_P21);case 15:_context32.next=17;return new Promise(function(P){var x=_this88.imageResolveMap.get(v)||{resolve:void 0,timer:void 0};x.timer&&clearTimeout(x.timer),x.resolve=P,x.timer=setTimeout(function(){var h=_this88.imageResolveMap.get(v);h!=null&&h.resolve&&h.resolve(v);},5e3),_this88.imageResolveMap.set(v,x),_this88._post({sp:[{imageSrc:v,workId:l,viewId:_this88.viewId,isgl:!!_this88.fullLayer.parent.gl,isSubWorker:i,type:dt.GetImageBitMap}]});});case 17:T=_context32.sent;return _context32.abrupt("return",(this.imageResolveMap["delete"](T),this.getCachedImages(v)));case 19:case"end":return _context32.stop();}},_callee30,this);}));function loadImageBitMap(_x87){return _loadImageBitMap.apply(this,arguments);}return loadImageBitMap;}()},{key:"createLocalWork",value:function createLocalWork(e){var t=e.workId,r=e.opt,n=e.toolsType;t&&r&&(!this.localWork.getToolsOpt()&&n&&this.setToolsOpt({toolsType:n,toolsOpt:r}),this.setWorkOpt({workId:t,toolsOpt:r}));}},{key:"updateScene",value:function updateScene(e,t,r){e.attr(_objectSpread({},t));var n=t.width,i=t.height;e.container.width=n,e.container.height=i,e.width=n,e.height=i,this.updateLayer({width:n,height:i},r);}},{key:"updateLayer",value:function updateLayer(e,t){var r=e.width,n=e.height,i=t||this.fullLayer;i&&(i.parent.setAttribute("width",r),i.parent.setAttribute("height",n),i.setAttribute("size",[r,n]),i.setAttribute("pos",[r*0.5,n*0.5]));}},{key:"getSupportContextType",value:function getSupportContextType(e,t){var r=new OffscreenCanvas(100,100);var n=["2d"];e===wr.Full&&this.viewId===hr&&(n=["webgl2","webgl","2d"],t&&n.unshift(t));for(var _i3=0,_n7=n;_i3<_n7.length;_i3++){var i=_n7[_i3];try{if(r.getContext(i))return i;}catch(l){throw l;}}}},{key:"createScene",value:function createScene(e){var t=e.offscreenCanvasOpt,r=t.width,n=t.height,i=new OffscreenCanvas(r,n);t.contextType&&delete t.contextType;var l=new ui(_objectSpread(_objectSpread({container:i,displayRatio:this.dpr,depth:!1,desynchronized:!0,failIfMajorPerformanceCaveat:!0},t),{},{contextType:this.contextType,id:this.viewId}));return l.setAttribute("id",this.viewId),l;}},{key:"createLayer",value:function createLayer(e,t,r,n){var i="offscreen-".concat(e),l=r.width,o=r.height;n&&(r.offscreen=!0,r.canvas=n);var a=t.layer(i,r),c=new ye({anchor:[0.5,0.5],pos:[l*0.5,o*0.5],size:[l,o],name:"viewport",id:e});return a.append(c),c;}},{key:"clearAll",value:function(){var _clearAll=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee31(){var e;return _regeneratorRuntime().wrap(function _callee31$(_context33){while(1)switch(_context33.prev=_context33.next){case 0:this.fullLayer&&(this.fullLayer.parent.children.forEach(function(t){t.name!=="viewport"&&t.remove();}),Se(this.fullLayer,this.fullLayer.parent)),this.taskUpdateCameraId&&(clearTimeout(this.taskUpdateCameraId),this.taskUpdateCameraId=void 0),this.debounceUpdateCameraId&&(clearTimeout(this.debounceUpdateCameraId),this.debounceUpdateCameraId=void 0),this.clearCacheImages(),this.clearImageResolveMap(),this.localWork.destroy(),(e=this.serviceWork)==null||e.destroy();case 1:case"end":return _context33.stop();}},_callee31,this);}));function clearAll(){return _clearAll.apply(this,arguments);}return clearAll;}()},{key:"setToolsOpt",value:function setToolsOpt(e){this.localWork.setToolsOpt(e);}},{key:"setWorkOpt",value:function setWorkOpt(e){var t=e.workId,r=e.toolsOpt;t&&r&&this.localWork.setWorkOptions(t.toString(),r);}},{key:"destroy",value:function destroy(){var e;this.vNodes.clear(),this.fullLayer.remove(),_pe(this.fullLayer,this.fullLayer.parent),this.clearCacheImages(),this.clearImageResolveMap(),this.scene.remove(),this.localWork.destroy(),(e=this.serviceWork)==null||e.destroy();}},{key:"post",value:function(){var _post=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee32(e){return _regeneratorRuntime().wrap(function _callee32$(_context34){while(1)switch(_context34.prev=_context34.next){case 0:this.combinePostMsg.add(e);_context34.next=3;return this.runBatchPostData();case 3:case"end":return _context34.stop();}},_callee32,this);}));function post(_x89){return _post.apply(this,arguments);}return post;}()},{key:"runBatchPostData",value:function(){var _runBatchPostData=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee33(){var _this89=this;return _regeneratorRuntime().wrap(function _callee33$(_context35){while(1)switch(_context35.prev=_context35.next){case 0:this.workerTaskId||(this.workerTaskId=setTimeout(function(){_this89.workerTaskId=void 0,_this89.combinePost();},16));_context35.t0=this.type===wr.Full&&!this.delayPostDoneResolve;if(!_context35.t0){_context35.next=6;break;}_context35.next=5;return new Promise(function(t){_this89.delayPostDoneResolve=t;});case 5:_context35.t0=_context35.sent;case 6:_context35.t1=_context35.t0;if(!_context35.t1){_context35.next=9;break;}this.delayPostDoneResolve=void 0;case 9:case"end":return _context35.stop();}},_callee33,this);}));function runBatchPostData(){return _runBatchPostData.apply(this,arguments);}return runBatchPostData;}()},{key:"combinePostData",value:function combinePostData(){var o,a;this.workerTaskId=void 0;var e=[],t=[];var r,n,i;var l=/* @__PURE__ */new Set();var _iterator53=_createForOfIteratorHelper(this.combinePostMsg.values()),_step53;try{for(_iterator53.s();!(_step53=_iterator53.n()).done;){var c=_step53.value;if((o=c.render)!=null&&o.length){var _iterator54=_createForOfIteratorHelper(c.render),_step54;try{for(_iterator54.s();!(_step54=_iterator54.n()).done;){var m=_step54.value;var f=!1;if(m.workId&&l.add(m.workId),m.isClearAll&&(m.rect=this.getSceneRect(),m.isClear=!0,delete m.isClearAll),m.drawCanvas){var v=this.getLayer(m.drawCanvas);if(!v||!(v.parent instanceof $r))continue;if(v.parent.render(),m.isDrawAll){var S=this.getSceneRect();m.rect=S,delete m.isDrawAll;}}var _iterator55=_createForOfIteratorHelper(e),_step55;try{for(_iterator55.s();!(_step55=_iterator55.n()).done;){var _v3=_step55.value;if(m.viewId===_v3.viewId){m.isClear&&_v3.clearCanvas&&_v3.isClear&&_v3.clearCanvas===m.clearCanvas&&(_v3.rect=bt(_v3.rect,m.rect),f=!0),_v3.drawCanvas&&_v3.drawCanvas===m.drawCanvas&&(_v3.rect=bt(_v3.rect,m.rect),f=!0);continue;}}}catch(err){_iterator55.e(err);}finally{_iterator55.f();}f||(m.isClear&&!m.drawCanvas?e.unshift(m):e.push(m));}}catch(err){_iterator54.e(err);}finally{_iterator54.f();}}if((a=c.sp)!=null&&a.length){var _iterator56=_createForOfIteratorHelper(c.sp),_step56;try{for(_iterator56.s();!(_step56=_iterator56.n()).done;){var _m12=_step56.value;var _f6=!1;var _iterator57=_createForOfIteratorHelper(t),_step57;try{for(_iterator57.s();!(_step57=_iterator57.n()).done;){var _v4=_step57.value;if(Me(_m12,_v4)){_f6=!0;break;}}}catch(err){_iterator57.e(err);}finally{_iterator57.f();}_f6||t.push(_m12);}}catch(err){_iterator56.e(err);}finally{_iterator56.f();}}he(c.fullWorkerDrawCount)&&(r=c.fullWorkerDrawCount),he(c.subWorkerDrawCount)&&(n=c.subWorkerDrawCount),he(c.consumeCount)&&(i=c.consumeCount);}}catch(err){_iterator53.e(err);}finally{_iterator53.f();}return this.combinePostMsg.clear(),{render:e,sp:t,fullWorkerDrawCount:r,subWorkerDrawCount:n,consumeCount:i,workIds:l,viewId:this.viewId};}},{key:"getSceneRect",value:function getSceneRect(){var _this$scene=this.scene,e=_this$scene.width,t=_this$scene.height;return{x:0,y:0,w:Math.floor(e),h:Math.floor(t)};}}]);}();var hs=/*#__PURE__*/function(){function hs(e){_classCallCheck(this,hs);ot(this,"viewId");ot(this,"vNodes");ot(this,"thread");ot(this,"fullLayer");ot(this,"drawLayer");ot(this,"_post");ot(this,"tmpOpt");ot(this,"workShapes",/* @__PURE__ */new Map());ot(this,"drawCount",0);ot(this,"consumeCount",0);ot(this,"syncUnitTime",me.syncOpt.interval);ot(this,"combineUnitTime",me.bezier.combineUnitTime);ot(this,"maxCombineEraserTime",me.pencilEraser.maxCombineTime);this.thread=e.thread,this.viewId=e.viewId,this.vNodes=e.vNodes,this.fullLayer=e.fullLayer,this.drawLayer=e.drawLayer,this._post=this.thread.post.bind(e.thread);}return _createClass(hs,[{key:"setmaxCombineEraserTime",value:function setmaxCombineEraserTime(e){this.maxCombineEraserTime=e;}},{key:"setCombineUnitTime",value:function setCombineUnitTime(e){this.combineUnitTime=e;}},{key:"setSyncUnitTime",value:function setSyncUnitTime(e){this.syncUnitTime=e;}},{key:"destroy",value:function destroy(){this.workShapes.clear();}},{key:"getWorkShapes",value:function getWorkShapes(){return this.workShapes;}},{key:"getWorkShape",value:function getWorkShape(e){return this.workShapes.get(e);}},{key:"createWorkShape",value:function createWorkShape(e,t){if(e&&this.tmpOpt){var r={toolsType:this.tmpOpt.toolsType,toolsOpt:t||this.tmpOpt.toolsOpt},n=this.createWorkShapeNode(_objectSpread(_objectSpread({},r),{},{workId:e}));n&&this.workShapes.set(e,n);}}},{key:"setWorkOptions",value:function setWorkOptions(e,t){var r=this.getWorkShape(e);r||this.createWorkShape(e,t),r==null||r.setWorkOptions(t);}},{key:"createWorkShapeNode",value:function createWorkShapeNode(e){var t;return Ur(_objectSpread(_objectSpread({},e),{},{vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer}),(t=this.thread)==null?void 0:t.serviceWork);}},{key:"setToolsOpt",value:function setToolsOpt(e){var t,r,n;((t=this.tmpOpt)==null?void 0:t.toolsType)!==e.toolsType&&(r=this.tmpOpt)!=null&&r.toolsType&&this.clearAllWorkShapesCache(),this.tmpOpt=e,(n=e.toolsOpt)!=null&&n.syncUnitTime&&(this.syncUnitTime=e.toolsOpt.syncUnitTime),e.combineUnitTime&&(this.combineUnitTime=e.combineUnitTime),e.maxCombineEraserTime&&(this.maxCombineEraserTime=e.maxCombineEraserTime);}},{key:"getToolsOpt",value:function getToolsOpt(){return this.tmpOpt;}},{key:"clearWorkShapeNodeCache",value:function clearWorkShapeNodeCache(e){var t;(t=this.getWorkShape(e))==null||t.clearTmpPoints(),this.workShapes["delete"](e);}},{key:"clearAllWorkShapesCache",value:function clearAllWorkShapesCache(){this.workShapes.forEach(function(e){return e.clearTmpPoints();}),this.workShapes.clear();}},{key:"setFullWork",value:function setFullWork(e){var t=e.workId,r=e.opt,n=e.toolsType;if(t&&r&&n){var i=t.toString();var l;return t&&this.workShapes.has(i)?(l=this.workShapes.get(i),l==null||l.setWorkOptions(r)):l=this.createWorkShapeNode({toolsOpt:r,toolsType:n,workId:i}),l?(this.workShapes.set(i,l),l):void 0;}}}]);}();var us=/*#__PURE__*/function(){function us(e){_classCallCheck(this,us);ot(this,"snapshotFullLayer");ot(this,"opt");this.opt=e;}return _createClass(us,[{key:"getRectImageBitmap",value:function getRectImageBitmap(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!1;var r=arguments.length>2?arguments[2]:undefined;var n=e.rect,i=e.drawCanvas,l=this.opt.getDpr(),o=Math.floor(n.x*l),a=Math.floor(n.y*l),c=Math.floor(n.w*l),m=Math.floor(n.h*l);return createImageBitmap(this.opt.getOffscreen(i,t),o,a,c,m,r);}},{key:"createSnapshotFullLayer",value:function createSnapshotFullLayer(e,t){this.snapshotFullLayer=this.opt.createLayer("snapshotFullLayer",e,t);}},{key:"destroySnapshotFullLayer",value:function destroySnapshotFullLayer(){var e,t;(e=this.snapshotFullLayer)==null||e.disconnect(),(t=this.snapshotFullLayer)==null||t.remove(),this.snapshotFullLayer=void 0;}},{key:"getSnapshot",value:function(){var _getSnapshot=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee34(e){var t,r,n,i,l,o,a,_i4,_Object$entries,_Object$entries$_i,m,f,v,S,E,c;return _regeneratorRuntime().wrap(function _callee34$(_context36){while(1)switch(_context36.prev=_context36.next){case 0:t=e.scenePath,r=e.scenes,n=e.cameraOpt,i=e.w,l=e.h;if(!(t&&r&&n&&this.snapshotFullLayer)){_context36.next=26;break;}o=ue(this.opt.getCameraOpt());this.opt.setCameraOpt(n,this.snapshotFullLayer),this.opt.localWork.fullLayer=this.snapshotFullLayer,this.opt.localWork.drawLayer=void 0;_i4=0,_Object$entries=Object.entries(r);case 5:if(!(_i4<_Object$entries.length)){_context36.next=21;break;}_Object$entries$_i=_slicedToArray(_Object$entries[_i4],2),m=_Object$entries$_i[0],f=_Object$entries$_i[1];if(!(f!=null&&f.type)){_context36.next=18;break;}_context36.t0=f==null?void 0:f.type;_context36.next=_context36.t0===dt.UpdateNode?11:_context36.t0===dt.FullWork?11:18;break;case 11:v=f.opt;S=_objectSpread(_objectSpread({},f),{},{opt:v,workId:m,msgType:dt.FullWork,dataType:Dt.Service,viewId:this.opt.viewId});_context36.next=15;return this.runFullWork(S);case 15:E=_context36.sent;a=bt(a,E);return _context36.abrupt("break",18);case 18:_i4++;_context36.next=5;break;case 21:i&&l&&(c={resizeWidth:i,resizeHeight:l});_context36.next=24;return this.getSnapshotRender({scenePath:t,curCameraOpt:o,options:c});case 24:this.opt.localWork.fullLayer=this.opt.fullLayer;this.opt.localWork.drawLayer=void 0;case 26:case"end":return _context36.stop();}},_callee34,this);}));function getSnapshot(_x90){return _getSnapshot.apply(this,arguments);}return getSnapshot;}()},{key:"runFullWork",value:function(){var _runFullWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee35(e){var n,t,r,i,l,o;return _regeneratorRuntime().wrap(function _callee35$(_context37){while(1)switch(_context37.prev=_context37.next){case 0:t=this.opt.localWork.setFullWork(e),r=e.ops&&Qe(e.ops);if(!t){_context37.next=18;break;}o=(n=t.getWorkId())==null?void 0:n.toString();if(!(t.toolsType===pt.Image)){_context37.next=9;break;}_context37.next=6;return t.consumeServiceAsync({isFullWork:!0,worker:this.opt.thread});case 6:i=_context37.sent;_context37.next=16;break;case 9:if(!(t.toolsType===pt.Text)){_context37.next=15;break;}_context37.next=12;return t.consumeServiceAsync({isFullWork:!0,replaceId:o,isDrawLabel:!0});case 12:i=_context37.sent;_context37.next=16;break;case 15:i=t.consumeService({op:r,isFullWork:!0,replaceId:o}),l=(e==null?void 0:e.updateNodeOpt)&&t.updataOptService(e.updateNodeOpt);case 16:e.workId&&this.opt.localWork.workShapes["delete"](e.workId.toString());return _context37.abrupt("return",bt(i,l));case 18:case"end":return _context37.stop();}},_callee35,this);}));function runFullWork(_x91){return _runFullWork.apply(this,arguments);}return runFullWork;}()},{key:"getSnapshotRender",value:function(){var _getSnapshotRender=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee36(e){var l,t,r,n,i;return _regeneratorRuntime().wrap(function _callee36$(_context38){while(1)switch(_context38.prev=_context38.next){case 0:t=e.scenePath,r=e.curCameraOpt,n=e.options;((l=this.snapshotFullLayer)==null?void 0:l.parent).render();_context38.next=4;return this.getRectImageBitmap({rect:this.opt.getSceneRect(),drawCanvas:Et.None},!0,n);case 4:i=_context38.sent;i&&(this.opt.post({sp:[{type:dt.Snapshot,scenePath:t,imageBitmap:i,viewId:this.opt.viewId}]},[i]),i.close(),this.snapshotFullLayer&&Se(this.snapshotFullLayer,this.snapshotFullLayer.parent),this.opt.setCameraOpt(r,this.opt.fullLayer));case 6:case"end":return _context38.stop();}},_callee36,this);}));function getSnapshotRender(_x92){return _getSnapshotRender.apply(this,arguments);}return getSnapshotRender;}()},{key:"getBoundingRect",value:function(){var _getBoundingRect=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee37(e){var t,r,n,i,l,_i5,_Object$entries2,_Object$entries2$_i,o,a,c;return _regeneratorRuntime().wrap(function _callee37$(_context39){while(1)switch(_context39.prev=_context39.next){case 0:t=e.scenePath,r=e.scenes,n=e.cameraOpt;if(!(t&&r&&n&&this.snapshotFullLayer)){_context39.next=27;break;}i=ue(this.opt.getCameraOpt());this.opt.setCameraOpt(n,this.snapshotFullLayer),this.opt.localWork.fullLayer=this.snapshotFullLayer,this.opt.localWork.drawLayer=void 0;_i5=0,_Object$entries2=Object.entries(r);case 5:if(!(_i5<_Object$entries2.length)){_context39.next=19;break;}_Object$entries2$_i=_slicedToArray(_Object$entries2[_i5],2),o=_Object$entries2$_i[0],a=_Object$entries2$_i[1];if(!(a!=null&&a.type)){_context39.next=16;break;}_context39.t0=a==null?void 0:a.type;_context39.next=_context39.t0===dt.UpdateNode?11:_context39.t0===dt.FullWork?11:16;break;case 11:_context39.next=13;return this.runFullWork(_objectSpread(_objectSpread({},a),{},{workId:o,msgType:dt.FullWork,dataType:Dt.Service,viewId:this.opt.viewId}));case 13:c=_context39.sent;l=bt(l,c);return _context39.abrupt("break",16);case 16:_i5++;_context39.next=5;break;case 19:_context39.t1=l;if(!_context39.t1){_context39.next=23;break;}_context39.next=23;return this.opt.post({sp:[{type:dt.BoundingBox,scenePath:t,rect:l}]});case 23:this.opt.localWork.fullLayer=this.opt.fullLayer;this.opt.localWork.drawLayer=void 0;Se(this.snapshotFullLayer,this.snapshotFullLayer.parent);this.opt.setCameraOpt(i,this.opt.fullLayer);case 27:case"end":return _context39.stop();}},_callee37,this);}));function getBoundingRect(_x93){return _getBoundingRect.apply(this,arguments);}return getBoundingRect;}()}]);}();function Om(u){return u;}var ds=Om;function Em(u,e,t){switch(t.length){case 0:return u.call(e);case 1:return u.call(e,t[0]);case 2:return u.call(e,t[0],t[1]);case 3:return u.call(e,t[0],t[1],t[2]);}return u.apply(e,t);}var Mm=Em,Am=Mm,oi=Math.max;function wm(u,e,t){return e=oi(e===void 0?u.length-1:e,0),function(){for(var r=arguments,n=-1,i=oi(r.length-e,0),l=Array(i);++n<i;)l[n]=r[e+n];n=-1;for(var o=Array(e+1);++n<e;)o[n]=r[n];return o[e]=t(l),Am(u,this,o);};}var Lm=wm;function Rm(u){return function(){return u;};}var Dm=Rm,bm=Dm,ai=xi,Nm=ds,Bm=ai?function(u,e){return ai(u,"toString",{configurable:!0,enumerable:!1,value:bm(e),writable:!0});}:Nm,Wm=Bm,Fm=800,Um=16,jm=Date.now;function Ym(u){var e=0,t=0;return function(){var r=jm(),n=Um-(r-t);if(t=r,n>0){if(++e>=Fm)return arguments[0];}else e=0;return u.apply(void 0,arguments);};}var Xm=Ym,zm=Wm,$m=Xm,Gm=$m(zm),km=Gm,Hm=ds,Vm=Lm,Km=km;function Zm(u,e){return Km(Vm(u,e,Hm),u+"");}var Jm=Zm;function Qm(u,e,t,r){for(var n=u.length,i=t+(r?1:-1);r?i--:++i<n;)if(e(u[i],i,u))return i;return-1;}var qm=Qm;function _m(u){return u!==u;}var tv=_m;function ev(u,e,t){for(var r=t-1,n=u.length;++r<n;)if(u[r]===e)return r;return-1;}var rv=ev,nv=qm,iv=tv,sv=rv;function ov(u,e,t){return e===e?sv(u,e,t):nv(u,iv,t);}var av=ov,lv=av;function cv(u,e){var t=u==null?0:u.length;return!!t&&lv(u,e,0)>-1;}var ps=cv;function fv(u,e,t){for(var r=-1,n=u==null?0:u.length;++r<n;)if(t(e,u[r]))return!0;return!1;}var ms=fv;function hv(u,e){for(var t=-1,r=u==null?0:u.length,n=Array(r);++t<r;)n[t]=e(u[t],t,u);return n;}var uv=hv,dv=dn,pv=ps,mv=ms,vv=uv,yv=Wr,gv=pn,Pv=200;function Sv(u,e,t,r){var n=-1,i=pv,l=!0,o=u.length,a=[],c=e.length;if(!o)return a;t&&(e=vv(e,yv(t))),r?(i=mv,l=!1):e.length>=Pv&&(i=gv,l=!1,e=new dv(e));t:for(;++n<o;){var m=u[n],f=t==null?m:t(m);if(m=r||m!==0?m:0,l&&f===f){for(var v=c;v--;)if(e[v]===f)continue t;a.push(m);}else i(e,f,r)||a.push(m);}return a;}var xv=Sv,li=ur,Tv=Oi,Cv=pr,ci=li?li.isConcatSpreadable:void 0;function Iv(u){return Cv(u)||Tv(u)||!!(ci&&u&&u[ci]);}var Ov=Iv,Ev=ln,Mv=Ov;function vs(u,e,t,r,n){var i=-1,l=u.length;for(t||(t=Mv),n||(n=[]);++i<l;){var o=u[i];e>0&&t(o)?e>1?vs(o,e-1,t,r,n):Ev(n,o):r||(n[n.length]=o);}return n;}var Av=vs;function wv(){}var Lv=wv,zr=Wi,Rv=Lv,Dv=mn,bv=1/0,Nv=zr&&1/Dv(new zr([,-0]))[1]==bv?function(u){return new zr(u);}:Rv,Bv=Nv,Wv=dn,Fv=ps,Uv=ms,jv=pn,Yv=Bv,Xv=mn,zv=200;function $v(u,e,t){var r=-1,n=Fv,i=u.length,l=!0,o=[],a=o;if(t)l=!1,n=Uv;else if(i>=zv){var c=e?null:Yv(u);if(c)return Xv(c);l=!1,n=jv,a=new Wv();}else a=e?[]:o;t:for(;++r<i;){var m=u[r],f=e?e(m):m;if(m=t||m!==0?m:0,l&&f===f){for(var v=a.length;v--;)if(a[v]===f)continue t;e&&a.push(f),o.push(m);}else n(a,f,t)||(a!==o&&a.push(f),o.push(m));}return o;}var Gv=$v,kv=xv,Hv=Av,fi=Gv;function Vv(u,e,t){var r=u.length;if(r<2)return r?fi(u[0]):[];for(var n=-1,i=Array(r);++n<r;)for(var l=u[n],o=-1;++o<r;)o!=n&&(i[n]=kv(i[n]||l,u[o],e,t));return fi(Hv(i,1),e,t);}var Kv=Vv,Zv=nn,Jv=Le;function Qv(u){return Jv(u)&&Zv(u);}var qv=Qv,_v=Li,ty=Jm,ey=Kv,ry=qv,ny=ty(function(u){return ey(_v(u,ry));}),iy=ny,sy=/* @__PURE__ */Ne(iy);var ys=/*#__PURE__*/function(_hs){function ys(t){var _this90;_classCallCheck(this,ys);_this90=_callSuper(this,ys,[t]);ot(_this90,"_type","full");ot(_this90,"combineTimerId");ot(_this90,"combineDrawResolve");ot(_this90,"combineDrawActiveId");ot(_this90,"drawWorkActiveId");ot(_this90,"effectSelectNodeData",/* @__PURE__ */new Set());return _this90;}_inherits(ys,_hs);return _createClass(ys,[{key:"loadImageBitMap",value:function(){var _loadImageBitMap2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee38(t){return _regeneratorRuntime().wrap(function _callee38$(_context40){while(1)switch(_context40.prev=_context40.next){case 0:_context40.next=2;return this.thread.loadImageBitMap(t);case 2:return _context40.abrupt("return",_context40.sent);case 3:case"end":return _context40.stop();}},_callee38,this);}));function loadImageBitMap(_x94){return _loadImageBitMap2.apply(this,arguments);}return loadImageBitMap;}()},{key:"consumeDraw",value:function(){var _consumeDraw=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee39(t,r){var _this91=this;var n,i,l,o,a,c,m,f,v;return _regeneratorRuntime().wrap(function _callee39$(_context41){while(1)switch(_context41.prev=_context41.next){case 0:n=t.op,i=t.workId,l=t.scenePath,o=t.postCount,a=t.smoothSync;if(!(n!=null&&n.length&&i)){_context41.next=48;break;}c=i.toString(),m=this.getWorkShape(c);if(m){_context41.next=5;break;}return _context41.abrupt("return");case 5:f=m.toolsType;if(!(f===pt.LaserPen)){_context41.next=8;break;}return _context41.abrupt("return");case 8:_context41.t0=this.combineDrawActiveId&&this.combineDrawActiveId!==c;if(!_context41.t0){_context41.next=13;break;}this.combineTimerId&&(clearTimeout(this.combineTimerId),this.combineTimerId=void 0,this.combineDrawResolve&&this.combineDrawResolve(!1),this.combineDrawActiveId=void 0);_context41.next=13;return this.consumeDrawAll({workId:this.combineDrawActiveId,scenePath:l,viewId:this.viewId,msgType:dt.DrawWork,dataType:Dt.Local},r);case 13:_context41.t1=this.drawWorkActiveId&&this.drawWorkActiveId!==c;if(!_context41.t1){_context41.next=18;break;}_context41.next=17;return this.consumeDrawAll({workId:this.drawWorkActiveId,scenePath:l,viewId:this.viewId,msgType:dt.DrawWork,dataType:Dt.Local},r);case 17:this.drawWorkActiveId=void 0;case 18:!this.drawWorkActiveId&&c!==qt&&(this.drawWorkActiveId=c);he(o)&&(this.consumeCount=o);v=m.consume({data:t,isFullWork:!0,smoothSync:a});_context41.t2=f;_context41.next=_context41.t2===pt.Selector?24:_context41.t2===pt.PencilEraser?30:_context41.t2===pt.BitMapEraser?30:_context41.t2===pt.Eraser?32:_context41.t2===pt.Arrow?35:_context41.t2===pt.Straight?35:_context41.t2===pt.Ellipse?35:_context41.t2===pt.Rectangle?35:_context41.t2===pt.Star?35:_context41.t2===pt.Polygon?35:_context41.t2===pt.SpeechBalloon?35:_context41.t2===pt.Pencil?41:48;break;case 24:_context41.t3=v.type===dt.Select;if(!_context41.t3){_context41.next=29;break;}v.selectIds&&r.runReverseSelectWork(v.selectIds);_context41.next=29;return this.drawSelector(v);case 29:return _context41.abrupt("break",48);case 30:this.drawCount++,this.combineTimerId||(this.combineTimerId=1,this.combineDrawActiveId=c,this.drawEraserCombine(c,this.drawCount).then(function(){_this91.combineTimerId=void 0;}));return _context41.abrupt("break",48);case 32:_context41.next=34;return this.drawEraser(v);case 34:return _context41.abrupt("break",48);case 35:_context41.t4=v;if(!_context41.t4){_context41.next=40;break;}this.drawCount++;_context41.next=40;return this.drawShape(v);case 40:return _context41.abrupt("break",48);case 41:this.drawCount++;!this.combineTimerId&&this.combineUnitTime!==1/0&&new Promise(function(S){_this91.combineDrawActiveId=c,_this91.combineDrawResolve=S,_this91.combineTimerId=setTimeout(function(){_this91.combineTimerId=void 0,_this91.combineDrawResolve&&_this91.combineDrawResolve(!0);},_this91.combineUnitTime);}).then(function(S){S&&_this91.drawPencilCombine(c,_this91.drawCount),_this91.combineDrawResolve=void 0;});_context41.t5=v;if(!_context41.t5){_context41.next=47;break;}_context41.next=47;return this.drawPencil(v);case 47:return _context41.abrupt("break",48);case 48:case"end":return _context41.stop();}},_callee39,this);}));function consumeDraw(_x95,_x96){return _consumeDraw.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee40(t,r){var o,a,c,n,i,l,m,f,v,S,E,T;return _regeneratorRuntime().wrap(function _callee40$(_context42){while(1)switch(_context42.prev=_context42.next){case 0:this.combineTimerId&&(clearTimeout(this.combineTimerId),this.combineTimerId=void 0,this.combineDrawResolve&&this.combineDrawResolve(!1),this.combineDrawActiveId=void 0);n=t.workId,i=t.scenePath,l=t.isLockSentEventCursor;if(!n){_context42.next=38;break;}m=n.toString();this.drawWorkActiveId===m&&(this.drawWorkActiveId=void 0);f=this.workShapes.get(m);if(f){_context42.next=8;break;}return _context42.abrupt("return");case 8:v=f.toolsType;if(!(v===pt.LaserPen)){_context42.next=11;break;}return _context42.abrupt("return");case 11:S=this.workShapes.get(He),E=(o=S==null?void 0:S.selectIds)==null?void 0:o[0],T=f.consumeAll({data:t,workerEngine:this});_context42.t0=v;_context42.next=_context42.t0===pt.Selector?15:_context42.t0===pt.PencilEraser?21:_context42.t0===pt.BitMapEraser?21:_context42.t0===pt.Eraser?26:_context42.t0===pt.Arrow?28:_context42.t0===pt.Straight?28:_context42.t0===pt.Ellipse?28:_context42.t0===pt.Rectangle?28:_context42.t0===pt.Star?28:_context42.t0===pt.Polygon?28:_context42.t0===pt.SpeechBalloon?28:_context42.t0===pt.Pencil?33:38;break;case 15:T.selectIds&&E&&(a=T.selectIds)!=null&&a.includes(E)&&S.cursorBlur();T.selectIds&&r.runReverseSelectWork(T.selectIds);_context42.next=19;return this.drawSelector(_objectSpread(_objectSpread({},T),{},{scenePath:i}),l);case 19:(c=f.selectIds)!=null&&c.length?f.clearTmpPoints():this.clearWorkShapeNodeCache(m);return _context42.abrupt("break",38);case 21:_context42.next=23;return this.drawEraserFull(f,_objectSpread(_objectSpread({},T),{},{scenePath:i}),l);case 23:this.drawCount=0;this.clearWorkShapeNodeCache(m);return _context42.abrupt("break",38);case 26:this.drawEraser(_objectSpread(_objectSpread({},T),{},{scenePath:i}),l),f.clearTmpPoints();return _context42.abrupt("break",38);case 28:_context42.next=30;return this.drawPencilFull(_objectSpread(_objectSpread({},T),{},{scenePath:i}),l);case 30:this.drawCount=0;this.clearWorkShapeNodeCache(m);return _context42.abrupt("break",38);case 33:_context42.next=35;return this.drawPencilFull(_objectSpread(_objectSpread({},T),{},{scenePath:i}),l);case 35:this.drawCount=0;this.clearWorkShapeNodeCache(m);return _context42.abrupt("break",38);case 38:case"end":return _context42.stop();}},_callee40,this);}));function consumeDrawAll(_x97,_x98){return _consumeDrawAll.apply(this,arguments);}return consumeDrawAll;}()},{key:"workShapesDone",value:function(){var _workShapesDone=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee41(t,r){var _iterator58,_step58,n;return _regeneratorRuntime().wrap(function _callee41$(_context43){while(1)switch(_context43.prev=_context43.next){case 0:_iterator58=_createForOfIteratorHelper(this.workShapes.keys());_context43.prev=1;_iterator58.s();case 3:if((_step58=_iterator58.n()).done){_context43.next=9;break;}n=_step58.value;_context43.next=7;return this.consumeDrawAll({workId:n,scenePath:t,viewId:this.viewId,msgType:dt.DrawWork,dataType:Dt.Local},r);case 7:_context43.next=3;break;case 9:_context43.next=14;break;case 11:_context43.prev=11;_context43.t0=_context43["catch"](1);_iterator58.e(_context43.t0);case 14:_context43.prev=14;_iterator58.f();return _context43.finish(14);case 17:case"end":return _context43.stop();}},_callee41,this,[[1,11,14,17]]);}));function workShapesDone(_x99,_x100){return _workShapesDone.apply(this,arguments);}return workShapesDone;}()},{key:"consumeFull",value:function(){var _consumeFull=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee42(t){var i,l,r,n,o,a,c,m,f,v,S;return _regeneratorRuntime().wrap(function _callee42$(_context44){while(1)switch(_context44.prev=_context44.next){case 0:r=this.setFullWork(t),n=t.ops&&Qe(t.ops)||t.op;if(!r){_context44.next=26;break;}o=(i=t.workId)==null?void 0:i.toString();if(o){_context44.next=5;break;}return _context44.abrupt("return");case 5:a=(l=this.vNodes.get(o))==null?void 0:l.rect;if(!(r.toolsType===pt.Image)){_context44.next=13;break;}_context44.next=9;return r.consumeServiceAsync({isFullWork:!0,replaceId:o,worker:this});case 9:c=_context44.sent;m=(t==null?void 0:t.updateNodeOpt)&&r.updataOptService(t.updateNodeOpt);_context44.next=20;break;case 13:if(!(r.toolsType===pt.Text)){_context44.next=19;break;}_context44.next=16;return r.consumeServiceAsync({isFullWork:!0,replaceId:o});case 16:c=_context44.sent;_context44.next=20;break;case 19:c=r.consumeService({op:n,isFullWork:!0,replaceId:o}),m=(t==null?void 0:t.updateNodeOpt)&&r.updataOptService(t.updateNodeOpt);case 20:c=bt(c,m);f=[],v=[];if(!(t.workId&&this.workShapes["delete"](t.workId.toString()),c&&t.willRefresh&&(a&&(f.push({rect:kt(a),isClear:!0,clearCanvas:Et.Bg,viewId:this.viewId}),c=bt(c,a)),f.push({rect:kt(c),drawCanvas:Et.Bg,viewId:this.viewId})),t.willSyncService&&v.push({opt:t.opt,toolsType:t.toolsType,type:dt.FullWork,workId:t.workId,ops:t.ops,updateNodeOpt:t.updateNodeOpt,viewId:this.viewId}),f.length||v.length)){_context44.next=26;break;}S={render:f,sp:v};_context44.next=26;return this._post(S);case 26:case"end":return _context44.stop();}},_callee42,this);}));function consumeFull(_x101){return _consumeFull.apply(this,arguments);}return consumeFull;}()},{key:"commandDeleteText",value:function commandDeleteText(t){var r=this.vNodes.get(t);if(r&&r.toolsType===pt.Text)return{type:dt.TextUpdate,toolsType:pt.Text,workId:t,dataType:Dt.Local};}},{key:"removeSelector",value:function(){var _removeSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee43(t,r){var n,i,l,o,a,c,_iterator59,_step59,m,S,v;return _regeneratorRuntime().wrap(function _callee43$(_context45){while(1)switch(_context45.prev=_context45.next){case 0:n=t.willSyncService,i=[],l=[],o=[],a=this.workShapes.get(qt);if(a){_context45.next=3;break;}return _context45.abrupt("return");case 3:c=a.selectIds&&_toConsumableArray(a.selectIds)||[];_iterator59=_createForOfIteratorHelper(c);try{for(_iterator59.s();!(_step59=_iterator59.n()).done;){m=_step59.value;if(this.vNodes.get(m)){S=this.commandDeleteText(m);S&&i.push(S);}v=this._removeWork(m);v.length&&l.push.apply(l,_toConsumableArray(v)),r==null||r.deleteCachedImagesByWorkId(m),o.push(m);}}catch(err){_iterator59.e(err);}finally{_iterator59.f();}o.length&&i.push({type:dt.RemoveNode,removeIds:o});i.push({type:dt.Select,selectIds:[],willSyncService:n});_context45.next=10;return this.blurSelector();case 10:_context45.t0=l.length||i.length;if(!_context45.t0){_context45.next=14;break;}_context45.next=14;return this._post({render:l,sp:i});case 14:case"end":return _context45.stop();}},_callee43,this);}));function removeSelector(_x102,_x103){return _removeSelector.apply(this,arguments);}return removeSelector;}()},{key:"removeWork",value:function(){var _removeWork2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee44(t){var r,n,i;return _regeneratorRuntime().wrap(function _callee44$(_context46){while(1)switch(_context46.prev=_context46.next){case 0:r=t.workId,n=r==null?void 0:r.toString();if(!n){_context46.next=7;break;}i=this._removeWork(n);_context46.t0=i.length;if(!_context46.t0){_context46.next=7;break;}_context46.next=7;return this._post({render:i});case 7:case"end":return _context46.stop();}},_callee44,this);}));function removeWork(_x104){return _removeWork2.apply(this,arguments);}return removeWork;}()},{key:"removeNode",value:function removeNode(t){var _this92=this;var i,l,o;var r=this.vNodes.get(t);r&&((i=this.fullLayer)==null||i.getElementsByName(t).forEach(function(a){a.remove(),_pe(a,_this92.fullLayer.parent);}),this.vNodes["delete"](t));var n=this.drawLayer&&At.getRectFromLayer(this.drawLayer,t);if(n){var a=(l=this.drawLayer)==null?void 0:l.getElementsByName(t)[0];a&&(a.remove(),_pe(a,(o=this.drawLayer)==null?void 0:o.parent));}return this.getWorkShape(t)&&this.clearWorkShapeNodeCache(t),{fullRect:r==null?void 0:r.rect,drawRect:n};}},{key:"_removeWork",value:function _removeWork(t){var _this$removeNode=this.removeNode(t),r=_this$removeNode.fullRect,n=_this$removeNode.drawRect,i=[];return r&&i.push({rect:kt(r),clearCanvas:Et.Bg,isClear:!0,viewId:this.viewId},{rect:kt(r),drawCanvas:Et.Bg,viewId:this.viewId}),n&&i.push({rect:kt(n),clearCanvas:Et.Float,isClear:!0,viewId:this.viewId},{rect:kt(n),drawCanvas:Et.Float,viewId:this.viewId}),i;}},{key:"checkTextActive",value:function(){var _checkTextActive=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee45(t){var r,n,i,l,o,a,c,_iterator60,_step60,m,f,v,S,E;return _regeneratorRuntime().wrap(function _callee45$(_context47){while(1)switch(_context47.prev=_context47.next){case 0:r=t.op,n=t.viewId,i=t.dataType;if(!(r!=null&&r.length)){_context47.next=32;break;}a=r[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],c=r[1]*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1];_iterator60=_createForOfIteratorHelper(this.vNodes.curNodeMap.values());_context47.prev=4;_iterator60.s();case 6:if((_step60=_iterator60.n()).done){_context47.next=14;break;}m=_step60.value;f=m.rect,v=m.name,S=m.toolsType,E=m.opt;if(!(S===pt.Text&&E.workState===Ft.Done&&vm([a,c],f))){_context47.next=12;break;}l=v,o=this.setFullWork({workId:v,toolsType:S,opt:E});return _context47.abrupt("break",14);case 12:_context47.next=6;break;case 14:_context47.next=19;break;case 16:_context47.prev=16;_context47.t0=_context47["catch"](4);_iterator60.e(_context47.t0);case 19:_context47.prev=19;_iterator60.f();return _context47.finish(19);case 22:_context47.t1=l;if(!_context47.t1){_context47.next=32;break;}_context47.t2=o;if(!_context47.t2){_context47.next=28;break;}_context47.next=28;return o.consumeServiceAsync({isFullWork:!0,replaceId:o.getWorkId(),isDrawLabel:!1});case 28:_context47.next=30;return this.blurSelector({viewId:n,msgType:dt.Select,dataType:i,isSync:!0});case 30:_context47.next=32;return this._post({sp:[{type:dt.GetTextActive,toolsType:pt.Text,workId:l}]});case 32:case"end":return _context47.stop();}},_callee45,this,[[4,16,19,22]]);}));function checkTextActive(_x105){return _checkTextActive.apply(this,arguments);}return checkTextActive;}()},{key:"colloctEffectSelectWork",value:function(){var _colloctEffectSelectWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee46(t){var _this93=this;var r,n,i;return _regeneratorRuntime().wrap(function _callee46$(_context48){while(1)switch(_context48.prev=_context48.next){case 0:r=this.workShapes.get(qt),n=t.workId,i=t.msgType;if(!(r&&n&&r.selectIds&&r.selectIds.includes(n.toString()))){_context48.next=6;break;}i===dt.RemoveNode?r.selectIds=r.selectIds.filter(function(l){return l!==n.toString();}):this.effectSelectNodeData.add(t);_context48.next=5;return this.runEffectSelectWork(!0).then(function(){var l;(l=_this93.effectSelectNodeData)==null||l.clear();});case 5:return _context48.abrupt("return");case 6:return _context48.abrupt("return",t);case 7:case"end":return _context48.stop();}},_callee46,this);}));function colloctEffectSelectWork(_x106){return _colloctEffectSelectWork.apply(this,arguments);}return colloctEffectSelectWork;}()},{key:"updateSelector",value:function(){var _updateSelector2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee47(t){var _this94=this;var T,r,n,i,l,o,a,c,m,f,v,S,E;return _regeneratorRuntime().wrap(function _callee47$(_context49){while(1)switch(_context49.prev=_context49.next){case 0:r=this.workShapes.get(qt);if((T=r==null?void 0:r.selectIds)!=null&&T.length){_context49.next=3;break;}return _context49.abrupt("return");case 3:n=t.callback;i=_objectWithoutProperties(t,_excluded2);l=i.updateSelectorOpt;o=i.willSerializeData;a=i.smoothSync;_context49.next=10;return r==null?void 0:r.updateSelector({updateSelectorOpt:l,selectIds:ue(r.selectIds),vNodes:this.vNodes,willSerializeData:o,worker:this});case 10:c=_context49.sent;m=/* @__PURE__ */new Map();c!=null&&c.selectIds&&(f=sy(r.selectIds,c.selectIds),c.selectIds.forEach(function(P){var x=_this94.vNodes.get(P);if(x){var _h45=x.toolsType,p=x.op,d=x.opt;m.set(P,{opt:d,toolsType:_h45,ops:(p==null?void 0:p.length)&&ve(p)||void 0});}}),r.selectIds=c.selectIds);v=[],S=[];c!=null&&c.rect&&v.push({rect:kt(c.rect),clearCanvas:Et.Bg,isClear:!0,viewId:this.viewId},{rect:kt(c.rect),drawCanvas:Et.Bg,viewId:this.viewId});E=n&&n({res:c,workShapeNode:r,param:i,postData:{render:v,sp:S},newServiceStore:m,smoothSync:a})||{render:v,sp:S};f&&E.sp.push({type:dt.RemoveNode,removeIds:f,viewId:this.viewId});_context49.t0=E.render.length||E.sp.length;if(!_context49.t0){_context49.next=21;break;}_context49.next=21;return this._post(E);case 21:case"end":return _context49.stop();}},_callee47,this);}));function updateSelector(_x107){return _updateSelector2.apply(this,arguments);}return updateSelector;}()},{key:"blurSelector",value:function(){var _blurSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee48(t){var i,r,n,l;return _regeneratorRuntime().wrap(function _callee48$(_context50){while(1)switch(_context50.prev=_context50.next){case 0:r=this.workShapes.get(qt),n=r==null?void 0:r.blurSelector();if(!(this.clearWorkShapeNodeCache(qt),((i=this.fullLayer)==null?void 0:i.parent).children.forEach(function(l){l.name===qt&&l.remove();}),n)){_context50.next=6;break;}l=[];l.push(_objectSpread(_objectSpread({},n),{},{isSync:t==null?void 0:t.isSync}));_context50.next=6;return this._post({render:(n==null?void 0:n.rect)&&[{rect:kt(n.rect),clearCanvas:Et.Bg,isClear:!0,viewId:this.viewId},{rect:kt(n.rect),drawCanvas:Et.Bg,viewId:this.viewId}],sp:l});case 6:case"end":return _context50.stop();}},_callee48,this);}));function blurSelector(_x108){return _blurSelector.apply(this,arguments);}return blurSelector;}()},{key:"hasSelector",value:function hasSelector(){return this.workShapes.has(qt);}},{key:"getSelector",value:function getSelector(){return this.workShapes.get(qt);}},{key:"reRenderSelector",value:function(){var _reRenderSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee49(){var t,l,r,n,i,o,_args51=arguments;return _regeneratorRuntime().wrap(function _callee49$(_context51){while(1)switch(_context51.prev=_context51.next){case 0:t=_args51.length>0&&_args51[0]!==undefined?_args51[0]:!1;r=this.workShapes.get(qt);if(r){_context51.next=4;break;}return _context51.abrupt("return");case 4:if(!(r&&!((l=r.selectIds)!=null&&l.length))){_context51.next=8;break;}_context51.next=7;return this.blurSelector();case 7:return _context51.abrupt("return");case 8:n=r.oldSelectRect,i=r.reRenderSelector();if(!i){_context51.next=13;break;}o=bt(n,i)||i;_context51.next=13;return this._post({render:[{rect:kt(o),clearCanvas:Et.Bg,isClear:!0,viewId:this.viewId},{rect:kt(o),drawCanvas:Et.Bg,viewId:this.viewId}],sp:[{type:dt.Select,selectIds:r.selectIds,selectRect:i,willSyncService:t,viewId:this.viewId,points:r.getChildrenPoints(),textOpt:r.textOpt,selectorColor:r.selectorColor,strokeColor:r.strokeColor,fillColor:r.fillColor,canTextEdit:r.canTextEdit,canRotate:r.canRotate,scaleType:r.scaleType,opt:r.getWorkOptions()||void 0,canLock:r.canLock,isLocked:r.isLocked,toolsTypes:r.toolsTypes,shapeOpt:r.shapeOpt,thickness:r.thickness,useStroke:r.useStroke,strokeType:r.strokeType}]});case 13:case"end":return _context51.stop();}},_callee49,this);}));function reRenderSelector(){return _reRenderSelector.apply(this,arguments);}return reRenderSelector;}()},{key:"updateFullSelectWork",value:function(){var _updateFullSelectWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee50(t){var i,l,o,a,c,m,f,r,n,_r$updateSelectIds,v,S,E;return _regeneratorRuntime().wrap(function _callee50$(_context52){while(1)switch(_context52.prev=_context52.next){case 0:r=this.workShapes.get(qt),n=t.selectIds;if(n!=null&&n.length){_context52.next=5;break;}_context52.next=4;return this.blurSelector(t);case 4:return _context52.abrupt("return");case 5:if(r){_context52.next=10;break;}!this.setFullWork(t)&&t.workId&&((i=this.tmpOpt)==null?void 0:i.toolsType)===pt.Selector&&this.createWorkShape(t.workId.toString());_context52.next=9;return this.updateFullSelectWork(t);case 9:return _context52.abrupt("return");case 10:if(!(r&&n!=null&&n.length)){_context52.next=16;break;}_r$updateSelectIds=r.updateSelectIds(n),v=_r$updateSelectIds.bgRect,S=_r$updateSelectIds.selectRect,E={render:[],sp:[]};v&&((l=E.render)==null||l.push({rect:kt(v),clearCanvas:Et.Bg,isClear:!0,viewId:this.viewId},{rect:kt(v),drawCanvas:Et.Bg,viewId:this.viewId}));(f=E.sp)==null||f.push(_objectSpread(_objectSpread({},t),{},{selectorColor:((o=t.opt)==null?void 0:o.strokeColor)||r.selectorColor,strokeColor:((a=t.opt)==null?void 0:a.strokeColor)||r.strokeColor,fillColor:((c=t.opt)==null?void 0:c.fillColor)||r.fillColor,textOpt:((m=t.opt)==null?void 0:m.textOpt)||r.textOpt,canTextEdit:r.canTextEdit,canRotate:r.canRotate,scaleType:r.scaleType,type:dt.Select,selectRect:S,points:r.getChildrenPoints(),willSyncService:(t==null?void 0:t.willSyncService)||!1,opt:(t==null?void 0:t.willSyncService)&&r.getWorkOptions()||void 0,canLock:r.canLock,isLocked:r.isLocked,toolsTypes:r.toolsTypes,shapeOpt:r.shapeOpt,thickness:r.thickness,useStroke:r.useStroke,strokeType:r.strokeType}));_context52.next=16;return this._post(E);case 16:case"end":return _context52.stop();}},_callee50,this);}));function updateFullSelectWork(_x109){return _updateFullSelectWork.apply(this,arguments);}return updateFullSelectWork;}()},{key:"destroy",value:function destroy(){this.combineTimerId&&(clearTimeout(this.combineTimerId),this.combineTimerId=void 0,this.combineDrawResolve&&this.combineDrawResolve(!1)),_superPropGet(ys,"destroy",this,3)([]),this.effectSelectNodeData.clear();}},{key:"drawEraserCombine",value:function(){var _drawEraserCombine=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee51(t,r){var i,l,o,a,n,c,m,f,v,_iterator61,_step61,_step61$value,_v5,S;return _regeneratorRuntime().wrap(function _callee51$(_context53){while(1)switch(_context53.prev=_context53.next){case 0:n=(i=this.workShapes.get(t))==null?void 0:i.combineConsume({workerEngine:this});if(!n){_context53.next=7;break;}c=n.willDeleteNodes,m=n.willNewNodes,f={render:[],fullWorkerDrawCount:r,sp:[]};if(n!=null&&n.rect){v=kt(n.rect);(l=f.render)==null||l.push({rect:v,isClear:!0,clearCanvas:Et.Bg,viewId:this.viewId},{rect:v,drawCanvas:Et.Bg,viewId:this.viewId});}if(c!=null&&c.size&&((o=f.sp)==null||o.push({type:dt.RemoveNode,removeIds:_toConsumableArray(c),viewId:this.thread.viewId})),m!=null&&m.size){_iterator61=_createForOfIteratorHelper(m);try{for(_iterator61.s();!(_step61=_iterator61.n()).done;){_step61$value=_slicedToArray(_step61.value,2),_v5=_step61$value[0],S=_step61$value[1];(a=f.sp)==null||a.push({type:dt.FullWork,dataType:Dt.Local,toolsType:pt.Pencil,ops:ve(S.op),opt:S.opt,workId:_v5,updateNodeOpt:{useAnimation:!1}});}}catch(err){_iterator61.e(err);}finally{_iterator61.f();}}_context53.next=7;return this._post(f);case 7:case"end":return _context53.stop();}},_callee51,this);}));function drawEraserCombine(_x110,_x111){return _drawEraserCombine.apply(this,arguments);}return drawEraserCombine;}()},{key:"drawPencilCombine",value:function(){var _drawPencilCombine=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee52(t,r){var i,l,o,n,a,c;return _regeneratorRuntime().wrap(function _callee52$(_context54){while(1)switch(_context54.prev=_context54.next){case 0:n=(i=this.workShapes.get(t))==null?void 0:i.combineConsume();if(!n){_context54.next=6;break;}a={render:[],fullWorkerDrawCount:r};if(n!=null&&n.rect){c=kt(n.rect);(l=a.render)==null||l.push({rect:c,isClear:!0,clearCanvas:Et.Float,viewId:this.viewId}),(o=a.render)==null||o.push({rect:c,drawCanvas:Et.Float,viewId:this.viewId});}_context54.next=6;return this._post(a);case 6:case"end":return _context54.stop();}},_callee52,this);}));function drawPencilCombine(_x112,_x113){return _drawPencilCombine.apply(this,arguments);}return drawPencilCombine;}()},{key:"drawSelector",value:function(){var _drawSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee53(t,r){var i,l,n;return _regeneratorRuntime().wrap(function _callee53$(_context55){while(1)switch(_context55.prev=_context55.next){case 0:n={render:[],sp:[t]};r&&((i=n.sp)==null||i.push({type:dt.None,isLockSentEventCursor:r}));t.rect&&((l=n.render)==null||l.push({rect:kt(t.rect),clearCanvas:Et.Bg,isClear:!0,viewId:this.viewId},{rect:kt(t.rect),drawCanvas:Et.Bg,viewId:this.viewId}));_context55.next=5;return this._post(n);case 5:case"end":return _context55.stop();}},_callee53,this);}));function drawSelector(_x114,_x115){return _drawSelector.apply(this,arguments);}return drawSelector;}()},{key:"drawPencilFull",value:function(){var _drawPencilFull=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee54(t,r){var i,l,n;return _regeneratorRuntime().wrap(function _callee54$(_context56){while(1)switch(_context56.prev=_context56.next){case 0:n={fullWorkerDrawCount:1/0,render:[],sp:[t]};r&&((i=n.sp)==null||i.push({type:dt.None,isLockSentEventCursor:r}));t!=null&&t.rect&&((l=n.render)==null||l.push({isClearAll:!0,clearCanvas:Et.Float,viewId:this.viewId},{rect:t.rect,isClear:!0,clearCanvas:Et.Bg,viewId:this.viewId},{rect:t.rect,drawCanvas:Et.Bg,viewId:this.viewId}));_context56.next=5;return this._post(n);case 5:case"end":return _context56.stop();}},_callee54,this);}));function drawPencilFull(_x116,_x117){return _drawPencilFull.apply(this,arguments);}return drawPencilFull;}()},{key:"drawEraserFull",value:function(){var _drawEraserFull=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee55(t,r,n){var i,l,o,a,c,m,_iterator62,_step62,_step62$value,v,S,_iterator63,_step63,_step63$value,_v6,_S9,f;return _regeneratorRuntime().wrap(function _callee55$(_context57){while(1)switch(_context57.prev=_context57.next){case 0:i=r.rect,l=r.willUpdateNodes,o=r.willDeleteNodes,a=r.willNewNodes,c=t.getWorkId(),m=[{type:dt.RemoveNode,removeIds:[c],viewId:this.viewId}];if(n&&m.push({type:dt.None,isLockSentEventCursor:n}),l!=null&&l.size||o!=null&&o.size||a!=null&&a.size){if(l!=null&&l.size){_iterator62=_createForOfIteratorHelper(l);try{for(_iterator62.s();!(_step62=_iterator62.n()).done;){_step62$value=_slicedToArray(_step62.value,2),v=_step62$value[0],S=_step62$value[1];m.push({type:dt.UpdateNode,dataType:Dt.Local,opt:S.opt,workId:v,updateNodeOpt:{useAnimation:!1}});}}catch(err){_iterator62.e(err);}finally{_iterator62.f();}}if(o!=null&&o.size&&m.push({type:dt.RemoveNode,removeIds:_toConsumableArray(o),viewId:this.thread.viewId}),a!=null&&a.size){_iterator63=_createForOfIteratorHelper(a);try{for(_iterator63.s();!(_step63=_iterator63.n()).done;){_step63$value=_slicedToArray(_step63.value,2),_v6=_step63$value[0],_S9=_step63$value[1];m.push({type:dt.FullWork,dataType:Dt.Local,toolsType:_S9.toolsType,ops:ve(_S9.op),opt:_S9.opt,workId:_v6,updateNodeOpt:{useAnimation:!1}});}}catch(err){_iterator63.e(err);}finally{_iterator63.f();}}}f=[{isClearAll:!0,clearCanvas:Et.Float,viewId:this.viewId}];i&&f.push({rect:i,isClear:!0,clearCanvas:Et.Bg,viewId:this.viewId},{rect:i,drawCanvas:Et.Bg,viewId:this.viewId});_context57.next=6;return this._post({sp:m,render:f,fullWorkerDrawCount:1/0});case 6:case"end":return _context57.stop();}},_callee55,this);}));function drawEraserFull(_x118,_x119,_x120){return _drawEraserFull.apply(this,arguments);}return drawEraserFull;}()},{key:"drawEraser",value:function(){var _drawEraser=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee56(t,r){var n,i;return _regeneratorRuntime().wrap(function _callee56$(_context58){while(1)switch(_context58.prev=_context58.next){case 0:n=[],i=[];r&&n.push({type:dt.None,isLockSentEventCursor:r});t.removeIds&&n.push(t);t.rect&&i.push({rect:t.rect,isClear:!0,clearCanvas:Et.Bg,viewId:this.viewId},{rect:t.rect,drawCanvas:Et.Bg,viewId:this.viewId});_context58.next=6;return this._post({sp:n,render:i,consumeCount:this.consumeCount});case 6:case"end":return _context58.stop();}},_callee56,this);}));function drawEraser(_x121,_x122){return _drawEraser.apply(this,arguments);}return drawEraser;}()},{key:"drawShape",value:function(){var _drawShape=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee57(t){return _regeneratorRuntime().wrap(function _callee57$(_context59){while(1)switch(_context59.prev=_context59.next){case 0:_context59.next=2;return this._post({fullWorkerDrawCount:this.drawCount,sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context59.stop();}},_callee57,this);}));function drawShape(_x123){return _drawShape.apply(this,arguments);}return drawShape;}()},{key:"drawPencil",value:function(){var _drawPencil=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee58(t){return _regeneratorRuntime().wrap(function _callee58$(_context60){while(1)switch(_context60.prev=_context60.next){case 0:_context60.next=2;return this._post({sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context60.stop();}},_callee58,this);}));function drawPencil(_x124){return _drawPencil.apply(this,arguments);}return drawPencil;}()},{key:"runEffectSelectWork",value:function(){var _runEffectSelectWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee59(t){var r,_iterator64,_step64,n,i,l,o;return _regeneratorRuntime().wrap(function _callee59$(_context61){while(1)switch(_context61.prev=_context61.next){case 0:_iterator64=_createForOfIteratorHelper(this.effectSelectNodeData.values());_context61.prev=1;_iterator64.s();case 3:if((_step64=_iterator64.n()).done){_context61.next=23;break;}n=_step64.value;i=this.setFullWork(n);if(!i){_context61.next=21;break;}l=(r=i.getWorkId())==null?void 0:r.toString();if(!(i.toolsType===pt.Image)){_context61.next=13;break;}_context61.next=11;return i.consumeServiceAsync({isFullWork:!0,replaceId:l,worker:this});case 11:_context61.next=20;break;case 13:if(!(i.toolsType===pt.Text)){_context61.next=18;break;}_context61.next=16;return i.consumeServiceAsync({isFullWork:!0,replaceId:l});case 16:_context61.next=20;break;case 18:o=n.ops&&Qe(n.ops);i.consumeService({op:o,isFullWork:!0,replaceId:l}),n!=null&&n.updateNodeOpt&&i.updataOptService(n.updateNodeOpt);case 20:n.workId&&this.workShapes["delete"](n.workId.toString());case 21:_context61.next=3;break;case 23:_context61.next=28;break;case 25:_context61.prev=25;_context61.t0=_context61["catch"](1);_iterator64.e(_context61.t0);case 28:_context61.prev=28;_iterator64.f();return _context61.finish(28);case 31:_context61.next=33;return this.reRenderSelector(t);case 33:case"end":return _context61.stop();}},_callee59,this,[[1,25,28,31]]);}));function runEffectSelectWork(_x125){return _runEffectSelectWork.apply(this,arguments);}return runEffectSelectWork;}()},{key:"cursorHover",value:function(){var _cursorHover=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee60(t){var o,r,n,i,l,a,c;return _regeneratorRuntime().wrap(function _callee60$(_context62){while(1)switch(_context62.prev=_context62.next){case 0:r=t.opt,n=t.toolsType,i=t.point,l=this.setFullWork({workId:He,toolsType:n,opt:r});if(!(l&&i)){_context62.next=8;break;}a=l.cursorHover(i),c={render:[]};_context62.t0=a&&a.type===dt.CursorHover&&a.rect;if(!_context62.t0){_context62.next=8;break;}(o=c.render)==null||o.push({rect:kt(a.rect),clearCanvas:Et.Bg,isClear:!0,viewId:this.viewId},{rect:kt(a.rect),drawCanvas:Et.Bg,viewId:this.viewId});_context62.next=8;return this._post(c);case 8:case"end":return _context62.stop();}},_callee60,this);}));function cursorHover(_x126){return _cursorHover.apply(this,arguments);}return cursorHover;}()},{key:"cursorBlur",value:function(){var _cursorBlur=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee61(){var n,t,r;return _regeneratorRuntime().wrap(function _callee61$(_context63){while(1)switch(_context63.prev=_context63.next){case 0:t=this.getWorkShape(He);_context63.t0=t&&(n=t.selectIds)!=null&&n.length;if(!_context63.t0){_context63.next=10;break;}r=t.oldSelectRect;t.cursorBlur();this.clearWorkShapeNodeCache(He);_context63.t1=r;if(!_context63.t1){_context63.next=10;break;}_context63.next=10;return this._post({render:[{rect:kt(r),clearCanvas:Et.Bg,isClear:!0,viewId:this.viewId},{rect:kt(r),drawCanvas:Et.Bg,viewId:this.viewId}]});case 10:this.fullLayer.parent.children.forEach(function(i){i.name==="Cursor_Hover_Id"&&i.remove();});case 11:case"end":return _context63.stop();}},_callee61,this);}));function cursorBlur(){return _cursorBlur.apply(this,arguments);}return cursorBlur;}()}]);}(hs);var gs=/*#__PURE__*/function(){function gs(e){_classCallCheck(this,gs);ot(this,"viewId");ot(this,"vNodes");ot(this,"fullLayer");ot(this,"drawLayer");ot(this,"workShapes",/* @__PURE__ */new Map());ot(this,"selectorWorkShapes",/* @__PURE__ */new Map());ot(this,"thread");ot(this,"animationId");ot(this,"willRunEffectSelectorIds",/* @__PURE__ */new Set());ot(this,"runEffectId");ot(this,"noAnimationRect");ot(this,"syncUnitTime",me.syncOpt.interval);ot(this,"post");this.viewId=e.viewId,this.vNodes=e.vNodes,this.fullLayer=e.fullLayer,this.drawLayer=e.drawLayer,this.thread=e.thread,this.post=e.thread.post.bind(e.thread);}return _createClass(gs,[{key:"destroy",value:function destroy(){this.workShapes.clear(),this.selectorWorkShapes.clear(),this.willRunEffectSelectorIds.clear();}},{key:"consumeDraw",value:function(){var _consumeDraw2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee62(e){return _regeneratorRuntime().wrap(function _callee62$(_context64){while(1)switch(_context64.prev=_context64.next){case 0:this.activeWorkShape(e),this.runAnimation();case 1:case"end":return _context64.stop();}},_callee62,this);}));function consumeDraw(_x127){return _consumeDraw2.apply(this,arguments);}return consumeDraw;}()},{key:"consumeFull",value:function consumeFull(e){this.activeWorkShape(e),this.runAnimation();}},{key:"runSelectWork",value:function runSelectWork(e){this.activeSelectorShape(e);var t=e.workId,r=t==null?void 0:t.toString();r&&this.willRunEffectSelectorIds.add(r),this.runEffect();}},{key:"setNodeKey",value:function setNodeKey(e,t,r,n){return t.toolsType=r,t.node=Ur({workId:e,toolsType:r,toolsOpt:n,vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer},this),t;}},{key:"runReverseSelectWork",value:function runReverseSelectWork(e){var _this95=this;e.forEach(function(t){_this95.selectorWorkShapes.forEach(function(r,n){var i;if((i=r.selectIds)!=null&&i.length){var l=r.selectIds.indexOf(t);l>-1&&(r.selectIds.splice(l,1),_this95.willRunEffectSelectorIds.add(n));}});}),this.willRunEffectSelectorIds.size&&this.runEffect();}},{key:"removeWork",value:function(){var _removeWork3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee63(e){var t,r,n;return _regeneratorRuntime().wrap(function _callee63$(_context65){while(1)switch(_context65.prev=_context65.next){case 0:t=e.workId,r=t==null?void 0:t.toString();if(!r){_context65.next=10;break;}n=this.workShapes.get(r);if(!n){_context65.next=8;break;}this.workShapes["delete"](r);_context65.next=7;return this.removeNode(r,e,n==null?void 0:n.totalRect,!1);case 7:return _context65.abrupt("return");case 8:_context65.next=10;return this.removeNode(r,e);case 10:case"end":return _context65.stop();}},_callee63,this);}));function removeWork(_x128){return _removeWork3.apply(this,arguments);}return removeWork;}()},{key:"removeSelectWork",value:function removeSelectWork(e){var t=e.workId,r=t==null?void 0:t.toString();r&&(this.activeSelectorShape(e),this.willRunEffectSelectorIds.add(r)),this.runEffect();}},{key:"removeNode",value:function(){var _removeNode=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee64(e,t,r){var _this96=this;var n,c,i,l,o,a,_args66=arguments;return _regeneratorRuntime().wrap(function _callee64$(_context66){while(1)switch(_context66.prev=_context66.next){case 0:n=_args66.length>3&&_args66[3]!==undefined?_args66[3]:!0;e.indexOf(qt)>-1&&this.removeSelectWork(t);i=r;l=(c=this.vNodes.get(e))==null?void 0:c.rect;l&&(i=bt(l,i));o=this.fullLayer&&At.getRectFromLayer(this.fullLayer,e);i=bt(i,o);a=this.drawLayer&&At.getRectFromLayer(this.drawLayer,e);i=bt(i,a);this.fullLayer.getElementsByName(e).forEach(function(m){m.remove(),_pe(m,_this96.fullLayer.parent);});this.drawLayer.getElementsByName(e).forEach(function(m){m.remove(),_pe(m,_this96.drawLayer.parent);});this.vNodes["delete"](e);_context66.t0=i;if(!_context66.t0){_context66.next=16;break;}_context66.next=16;return this.post({render:[{rect:kt(i),isClear:!0,clearCanvas:n?Et.Bg:Et.ServiceFloat,workerType:n?void 0:Dt.Service,viewId:this.viewId},{rect:kt(i),drawCanvas:n?Et.Bg:Et.ServiceFloat,workerType:n?void 0:Dt.Service,viewId:this.viewId}]});case 16:case"end":return _context66.stop();}},_callee64,this);}));function removeNode(_x129,_x130,_x131){return _removeNode.apply(this,arguments);}return removeNode;}()},{key:"activeWorkShape",value:function activeWorkShape(e){var E,T,P,x;var t=e.workId,r=e.opt,n=e.toolsType,i=e.type,l=e.updateNodeOpt,o=e.ops,a=e.op,c=e.useAnimation,m=e.isEnableCursor;if(!t)return;var f=t.toString(),v=(E=this.vNodes.get(f))==null?void 0:E.rect;if(!((T=this.workShapes)!=null&&T.has(f))){var _h46={toolsType:n,animationWorkData:a||[],animationIndex:0,type:i,updateNodeOpt:l,ops:o,useAnimation:_typeof(c)<"u"?c:_typeof(l==null?void 0:l.useAnimation)<"u"?l==null?void 0:l.useAnimation:!0,oldRect:v,isDiff:!1,isEnableCursor:m};n&&r&&(_h46=this.setNodeKey(f,_h46,n,r)),(P=this.workShapes)==null||P.set(f,_h46);}var S=(x=this.workShapes)==null?void 0:x.get(f);S.isEnableCursor=m,i&&(S.type=i),o&&(S.animationWorkData=Qe(o),S.ops=o),l&&(S.updateNodeOpt=l),a&&(S.isDiff=this.hasDiffData(S.animationWorkData||[],a,S.toolsType),S.animationWorkData=a),S.node&&S.node.getWorkId()!==f&&S.node.setWorkId(f),v&&(S.oldRect=v),n&&r&&(r.syncUnitTime&&(this.syncUnitTime=r.syncUnitTime),S.toolsType!==n&&n&&r&&this.setNodeKey(f,S,n,r),S.node&&S.node.setWorkOptions(r));}},{key:"hasDiffData",value:function hasDiffData(e,t,r){var n=e.length;if(t.length<n)return!0;switch(r){case pt.Pencil:{for(var i=0;i<n;i+=3)if(t[i]!==e[i]||t[i+1]!==e[i+1])return!0;break;}case pt.LaserPen:{for(var _i6=0;_i6<n;_i6+=2)if(t[_i6]!==e[_i6]||t[_i6+1]!==e[_i6+1])return!0;break;}}return!1;}},{key:"animationDraw",value:function(){var _animationDraw=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee65(){var _this97=this;var n,i,l,o,a,c,m,f,v,S,E,T,P,x,h,p,d,g,O,w,L,B,A,b,W,D,R,X,H,J,et,it,$,V,rt,lt,ct,gt,st,Ct,e,t,r,_iterator65,_step65,_loop6;return _regeneratorRuntime().wrap(function _callee65$(_context68){while(1)switch(_context68.prev=_context68.next){case 0:this.animationId=void 0;e=!1;t={render:[]},r=/* @__PURE__ */new Map();_iterator65=_createForOfIteratorHelper(this.workShapes.entries());_context68.prev=4;_loop6=/*#__PURE__*/_regeneratorRuntime().mark(function _loop6(){var _step65$value,xt,F,U,K,_U,_K,_U2,_K2,q,Y,_U3,_K3,_q,_Y2,k,C,M,_C,_U4,_K4,_q2,_Y3;return _regeneratorRuntime().wrap(function _loop6$(_context67){while(1)switch(_context67.prev=_context67.next){case 0:_step65$value=_slicedToArray(_step65.value,2),xt=_step65$value[0],F=_step65$value[1];_context67.t0=F.toolsType;_context67.next=_context67.t0===pt.Image?4:_context67.t0===pt.Text?11:_context67.t0===pt.Arrow?19:_context67.t0===pt.Straight?19:_context67.t0===pt.Rectangle?19:_context67.t0===pt.Ellipse?19:_context67.t0===pt.Star?19:_context67.t0===pt.Polygon?19:_context67.t0===pt.SpeechBalloon?19:_context67.t0===pt.Pencil?22:38;break;case 4:U=F.oldRect;U&&((n=t.render)==null||n.push({rect:U,isClear:!0,clearCanvas:Et.Bg,viewId:_this97.viewId}),(i=t.render)==null||i.push({rect:U,drawCanvas:Et.Bg,viewId:_this97.viewId}));_context67.next=8;return(l=F.node)==null?void 0:l.consumeServiceAsync({isFullWork:!0,worker:_this97.thread});case 8:K=_context67.sent;_this97.selectorWorkShapes.forEach(function(q,Y){var k;(k=q.selectIds)!=null&&k.includes(xt)&&(_this97.willRunEffectSelectorIds.add(Y),_this97.noAnimationRect=bt(_this97.noAnimationRect,U),_this97.noAnimationRect=bt(_this97.noAnimationRect,K),_this97.runEffect());}),_this97.workShapes["delete"](xt),(o=t.render)==null||o.push({rect:K,drawCanvas:Et.Bg,viewId:_this97.viewId});return _context67.abrupt("break",38);case 11:if(!F.node){_context67.next=18;break;}_U=F.oldRect;_U&&((a=t.render)==null||a.push({rect:_U,isClear:!0,clearCanvas:Et.Bg,viewId:_this97.viewId}),(c=t.render)==null||c.push({rect:_U,drawCanvas:Et.Bg,viewId:_this97.viewId}));_context67.next=16;return F.node.consumeServiceAsync({isFullWork:!0,replaceId:xt});case 16:_K=_context67.sent;_this97.selectorWorkShapes.forEach(function(q,Y){var k;(k=q.selectIds)!=null&&k.includes(xt)&&(_this97.willRunEffectSelectorIds.add(Y),_this97.noAnimationRect=bt(_this97.noAnimationRect,_U),_this97.noAnimationRect=bt(_this97.noAnimationRect,_K),_this97.runEffect());}),(m=F.node)==null||m.clearTmpPoints(),_this97.workShapes["delete"](xt),(f=t.render)==null||f.push({rect:_K,drawCanvas:Et.Bg,viewId:_this97.viewId});case 18:return _context67.abrupt("break",38);case 19:_U2=!!F.ops;if((v=F.animationWorkData)!=null&&v.length){_K2=F.oldRect,q=F.node.oldRect;_K2&&((S=t.render)==null||S.push({rect:_K2,isClear:!0,clearCanvas:Et.Bg,viewId:_this97.viewId}),(E=t.render)==null||E.push({rect:_K2,drawCanvas:Et.Bg,viewId:_this97.viewId})),q&&((T=t.render)==null||T.push({rect:q,isClear:!0,clearCanvas:Et.ServiceFloat,viewId:_this97.viewId}));Y=(P=F.node)==null?void 0:P.consumeService({op:F.animationWorkData,isFullWork:_U2});F.isEnableCursor?r.set(xt,{workState:_K2?F.ops?Ft.Done:Ft.Doing:Ft.Start,op:F.animationWorkData.slice(-3,-1)}):_U2&&!F.useAnimation&&(x=F.updateNodeOpt)!=null&&x.useAnimation&&r.set(xt,{workState:Ft.Done,op:F.animationWorkData.slice(-3,-1),uid:(h=F.updateNodeOpt)==null?void 0:h.uid}),_U2?(_this97.selectorWorkShapes.forEach(function(k,C){var M;(M=k.selectIds)!=null&&M.includes(xt)&&(_this97.willRunEffectSelectorIds.add(C),_this97.noAnimationRect=bt(_this97.noAnimationRect,_K2),_this97.noAnimationRect=bt(_this97.noAnimationRect,q),_this97.noAnimationRect=bt(_this97.noAnimationRect,Y),_this97.runEffect());}),(p=F.node)==null||p.clearTmpPoints(),_this97.workShapes["delete"](xt),(d=t.render)==null||d.push({rect:Y,drawCanvas:Et.Bg,viewId:_this97.viewId})):(g=t.render)==null||g.push({rect:Y,drawCanvas:Et.ServiceFloat,workerType:_U2?void 0:Dt.Service,viewId:_this97.viewId}),F.animationWorkData.length=0;}return _context67.abrupt("break",38);case 22:if(!F.useAnimation){_context67.next=33;break;}if(!F.useAnimation){_context67.next=31;break;}if(!F.isDel){_context67.next=27;break;}(et=F.node)==null||et.clearTmpPoints(),_this97.workShapes["delete"](xt);return _context67.abrupt("break",38);case 27:_U3=3,_K3=_this97.computNextAnimationIndex(F,_U3),_q=F.isDiff?0:Math.max(0,(F.animationIndex||0)-_U3),_Y2=(F.animationWorkData||[]).slice(0,_K3),k=($=(it=F.node)==null?void 0:it.getWorkId())==null?void 0:$.toString();if((F.animationIndex||0)<_K3||F.isDiff){C=(V=F.node)==null?void 0:V.consumeService({op:_Y2,isFullWork:!1,replaceId:k});if((rt=t.render)==null||rt.push({isClear:!0,rect:C,clearCanvas:Et.ServiceFloat,viewId:_this97.viewId}),(lt=t.render)==null||lt.push({rect:C,drawCanvas:Et.ServiceFloat,viewId:_this97.viewId}),F.animationIndex=_K3,F.isDiff&&(F.isDiff=!1),_Y2.length&&F.isEnableCursor){M=_Y2.slice(-3,-1);r.set(xt,{workState:_q===0?Ft.Start:_K3===((ct=F.animationWorkData)==null?void 0:ct.length)?Ft.Done:Ft.Doing,op:M});}}else if(F.ops){_C=(gt=F.node)==null?void 0:gt.consumeService({op:F.animationWorkData||[],isFullWork:!0,replaceId:k});F.isDel=!0,(st=t.render)==null||st.push({isClear:!0,rect:_C,clearCanvas:Et.ServiceFloat,viewId:_this97.viewId},{rect:_C,drawCanvas:Et.ServiceFloat,viewId:_this97.viewId},{isClear:!0,rect:_C,clearCanvas:Et.Bg,viewId:_this97.viewId},{rect:_C,drawCanvas:Et.Bg,viewId:_this97.viewId}),F.isEnableCursor&&r.set(xt,{workState:Ft.Done,op:_Y2.slice(-3,-1)});}e=!0;return _context67.abrupt("break",38);case 31:_context67.next=37;break;case 33:_U4=!!F.ops;_K4=(O=F.node)==null?void 0:O.consumeService({op:F.animationWorkData||[],isFullWork:_U4,replaceId:xt});_q2=(w=F.node)==null?void 0:w.updataOptService(F.updateNodeOpt);if(_U4){if(_K4=bt(_K4,_q2),(L=t.render)==null||L.push({isClear:!0,rect:bt(F.oldRect,_K4),clearCanvas:Et.Bg,viewId:_this97.viewId}),(B=t.render)==null||B.push({rect:bt(F.oldRect,_K4),drawCanvas:Et.Bg,viewId:_this97.viewId}),(A=F.updateNodeOpt)!=null&&A.useAnimation&&((b=t.render)==null||b.push({isClear:!0,rect:bt(F.oldRect,_K4),clearCanvas:Et.ServiceFloat,viewId:_this97.viewId}),(W=t.render)==null||W.push({rect:bt(F.oldRect,_K4),drawCanvas:Et.ServiceFloat,viewId:_this97.viewId}),!F.isEnableCursor&&(D=F.animationWorkData)!=null&&D.length)){_Y3=F.animationWorkData.slice(-3,-1);r.set(xt,{workState:Ft.Done,op:_Y3,uid:(R=F.updateNodeOpt)==null?void 0:R.uid});}_this97.selectorWorkShapes.forEach(function(Y,k){var C;(C=Y.selectIds)!=null&&C.includes(xt)&&(_this97.willRunEffectSelectorIds.add(k),_this97.noAnimationRect=bt(_this97.noAnimationRect,_K4),_this97.runEffect());}),(X=F.node)==null||X.clearTmpPoints(),_this97.workShapes["delete"](xt);}else _K4=bt(_K4,_q2),(H=t.render)==null||H.push({isClear:!0,rect:bt(F.oldRect,_K4),clearCanvas:Et.ServiceFloat,viewId:_this97.viewId}),(J=t.render)==null||J.push({rect:bt(F.oldRect,_K4),drawCanvas:Et.ServiceFloat,viewId:_this97.viewId});case 37:return _context67.abrupt("break",38);case 38:case"end":return _context67.stop();}},_loop6);});_iterator65.s();case 7:if((_step65=_iterator65.n()).done){_context68.next=11;break;}return _context68.delegateYield(_loop6(),"t0",9);case 9:_context68.next=7;break;case 11:_context68.next=16;break;case 13:_context68.prev=13;_context68.t1=_context68["catch"](4);_iterator65.e(_context68.t1);case 16:_context68.prev=16;_iterator65.f();return _context68.finish(16);case 19:e&&this.runAnimation();r.size&&(t.sp=[],r.forEach(function(xt,F){var U;(U=t.sp)==null||U.push({type:dt.Cursor,uid:xt.uid||F.split(Je)[0],op:xt.op,workState:xt.workState,viewId:_this97.viewId});}));_context68.t2=(Ct=t.render)!=null&&Ct.length;if(!_context68.t2){_context68.next=25;break;}_context68.next=25;return this.post(t);case 25:case"end":return _context68.stop();}},_callee65,this,[[4,13,16,19]]);}));function animationDraw(){return _animationDraw.apply(this,arguments);}return animationDraw;}()},{key:"runAnimation",value:function runAnimation(){var _this98=this;this.animationId||(this.animationId=setTimeout(function(){_this98.animationId=void 0,_this98.animationDraw();},16));}},{key:"computNextAnimationIndex",value:function computNextAnimationIndex(e,t){var r=Math.floor((e.animationWorkData||[]).slice(e.animationIndex).length*48/t/this.syncUnitTime)*t;return Math.min((e.animationIndex||0)+(r||t),(e.animationWorkData||[]).length);}},{key:"runEffect",value:function runEffect(){this.runEffectId||(this.runEffectId=setTimeout(this.effectRunSelector.bind(this),0));}},{key:"effectRunSelector",value:function(){var _effectRunSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee66(){var _this99=this;var e;return _regeneratorRuntime().wrap(function _callee66$(_context69){while(1)switch(_context69.prev=_context69.next){case 0:this.runEffectId=void 0;e=this.noAnimationRect;this.willRunEffectSelectorIds.forEach(function(t){var i,l;var r=_this99.selectorWorkShapes.get(t),n=r&&r.selectIds&&((i=r.node)==null?void 0:i.selectServiceNode(t,r,!0));e=bt(e,n),(l=r==null?void 0:r.selectIds)!=null&&l.length||_this99.selectorWorkShapes["delete"](t);});_context69.t0=e;if(!_context69.t0){_context69.next=7;break;}_context69.next=7;return this.post({render:[{rect:kt(e),isClear:!0,clearCanvas:Et.Bg,viewId:this.viewId},{rect:kt(e),drawCanvas:Et.Bg,viewId:this.viewId}]});case 7:this.willRunEffectSelectorIds.clear();this.noAnimationRect=void 0;case 9:case"end":return _context69.stop();}},_callee66,this);}));function effectRunSelector(){return _effectRunSelector.apply(this,arguments);}return effectRunSelector;}()},{key:"activeSelectorShape",value:function activeSelectorShape(e){var m,f,v;var t=e.workId,r=e.opt,n=e.toolsType,i=e.type,l=e.selectIds,o=e.imageBitmap;if(!t)return;var a=t.toString();if(!((m=this.selectorWorkShapes)!=null&&m.has(a))){var S={toolsType:n,selectIds:l,type:i,opt:r,imageBitmap:o};n&&r&&(S=this.setNodeKey(a,S,n,r)),(f=this.selectorWorkShapes)==null||f.set(a,S);}var c=(v=this.selectorWorkShapes)==null?void 0:v.get(a);i&&(c.type=i),c.node&&c.node.getWorkId()!==a&&c.node.setWorkId(a),o&&(c.imageBitmap=o),c.selectIds=l||[];}}]);}();var oy=/*#__PURE__*/function(_hs2){function oy(t){var _this100;_classCallCheck(this,oy);_this100=_callSuper(this,oy,[t]);ot(_this100,"drawWorkActiveId");return _this100;}// async runFullWork(data: IWorkerMessage): Promise<IRectType | undefined> {
441
441
  // const workShape = this.setFullWork(data);
442
442
  // const op = data.ops && transformToNormalData(data.ops);
443
443
  // if (workShape) {
@@ -468,6 +468,6 @@ ot(this,"delayPostDoneResolve");ot(this,"cacheImages",/* @__PURE__ */new Map());
468
468
  // return computRect(rect, updataOptRect);
469
469
  // }
470
470
  // }
471
- _inherits(oy,_hs2);return _createClass(oy,[{key:"runSelectWork",value:function runSelectWork(t){var n;var r=this.setFullWork(t);r&&(n=t.selectIds)!=null&&n.length&&t.workId&&r.selectServiceNode(t.workId.toString(),{selectIds:t.selectIds},!1);}},{key:"workShapesDone",value:function workShapesDone(){var _iterator66=_createForOfIteratorHelper(this.workShapes.keys()),_step66;try{for(_iterator66.s();!(_step66=_iterator66.n()).done;){var t=_step66.value;this.clearWorkShapeNodeCache(t);}}catch(err){_iterator66.e(err);}finally{_iterator66.f();}Se(this.fullLayer,this.fullLayer.parent);}},{key:"consumeDraw",value:function(){var _consumeDraw3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee67(t){var r,n,i,l,o,a,c;return _regeneratorRuntime().wrap(function _callee67$(_context70){while(1)switch(_context70.prev=_context70.next){case 0:r=t.workId,n=t.fullWorkerDrawCount,i=t.postCount,l=r==null?void 0:r.toString(),o=l&&this.workShapes.get(l);if(o){_context70.next=3;break;}return _context70.abrupt("return");case 3:_context70.t0=this.drawWorkActiveId&&this.drawWorkActiveId!==l;if(!_context70.t0){_context70.next=8;break;}_context70.next=7;return this.consumeDrawAll({workId:this.drawWorkActiveId,viewId:this.viewId,msgType:dt.DrawWork,dataType:Dt.Local});case 7:this.drawWorkActiveId=void 0;case 8:!this.drawWorkActiveId&&l!==qt&&(this.drawWorkActiveId=l);a=o.toolsType;ue(i)&&(this.consumeCount=i);c=o.consume({data:t,drawCount:this.drawCount,isFullWork:!0,isSubWorker:!0,removeDrawCount:n});_context70.t1=a;_context70.next=_context70.t1===pt.Selector?15:_context70.t1===pt.Ellipse?21:_context70.t1===pt.Arrow?21:_context70.t1===pt.Straight?21:_context70.t1===pt.Rectangle?21:_context70.t1===pt.Star?21:_context70.t1===pt.Polygon?21:_context70.t1===pt.SpeechBalloon?21:_context70.t1===pt.Pencil?27:_context70.t1===pt.BitMapEraser?33:_context70.t1===pt.PencilEraser?33:39;break;case 15:_context70.t2=c;if(!_context70.t2){_context70.next=20;break;}this.drawCount++;_context70.next=20;return this.drawSelector(c);case 20:return _context70.abrupt("break",39);case 21:_context70.t3=c;if(!_context70.t3){_context70.next=26;break;}this.drawCount++;_context70.next=26;return this.drawShape(c);case 26:return _context70.abrupt("break",39);case 27:_context70.t4=c;if(!_context70.t4){_context70.next=32;break;}this.drawCount++;_context70.next=32;return this.drawPencil(c,r==null?void 0:r.toString());case 32:return _context70.abrupt("break",39);case 33:_context70.t5=c;if(!_context70.t5){_context70.next=38;break;}this.drawCount++;_context70.next=38;return this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount});case 38:return _context70.abrupt("break",39);case 39:case"end":return _context70.stop();}},_callee67,this);}));function consumeDraw(_x132){return _consumeDraw3.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee68(t){var r,n,i;return _regeneratorRuntime().wrap(function _callee68$(_context71){while(1)switch(_context71.prev=_context71.next){case 0:r=t.workId;if(!r){_context71.next=14;break;}n=r.toString();this.drawWorkActiveId===n&&(this.drawWorkActiveId=void 0);i=this.workShapes.get(n);if(i){_context71.next=7;break;}return _context71.abrupt("return");case 7:_context71.t0=i.toolsType;_context71.next=_context71.t0===pt.Selector?10:_context71.t0===pt.Arrow?12:_context71.t0===pt.Straight?12:_context71.t0===pt.Ellipse?12:_context71.t0===pt.Pencil?12:_context71.t0===pt.Rectangle?12:_context71.t0===pt.Star?12:_context71.t0===pt.Polygon?12:_context71.t0===pt.SpeechBalloon?12:_context71.t0===pt.BitMapEraser?12:_context71.t0===pt.PencilEraser?12:14;break;case 10:this.drawCount=0,Se(this.fullLayer,this.fullLayer.parent),this.clearWorkShapeNodeCache(n),this._post({render:[{isClearAll:!0,clearCanvas:Et.Float,viewId:this.viewId}]});return _context71.abrupt("break",14);case 12:this.drawCount=0,Se(this.fullLayer,this.fullLayer.parent),this.clearWorkShapeNodeCache(n);return _context71.abrupt("break",14);case 14:case"end":return _context71.stop();}},_callee68,this);}));function consumeDrawAll(_x133){return _consumeDrawAll2.apply(this,arguments);}return consumeDrawAll;}()},{key:"removeWork",value:function(){var _removeWork4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee69(t){var r,n,i,l;return _regeneratorRuntime().wrap(function _callee69$(_context72){while(1)switch(_context72.prev=_context72.next){case 0:r=t.workId,n=r==null?void 0:r.toString();if(!n){_context72.next=8;break;}i=this.removeNode(n);if(!i){_context72.next=8;break;}l=[];l.push({rect:kt(i),clearCanvas:Et.Float,isClear:!0,viewId:this.viewId},{rect:kt(i),drawCanvas:Et.Float,viewId:this.viewId});_context72.next=8;return this._post({render:l});case 8:case"end":return _context72.stop();}},_callee69,this);}));function removeWork(_x134){return _removeWork4.apply(this,arguments);}return removeWork;}()},{key:"removeNode",value:function removeNode(t){var _this101=this;var r=this.workShapes.has(t);var n;return r&&(this.fullLayer.getElementsByName(t).forEach(function(i){var l=i.getBoundingClientRect();n=bt(n,{x:l.x-At.SafeBorderPadding,y:l.y-At.SafeBorderPadding,w:l.width+At.SafeBorderPadding*2,h:l.height+At.SafeBorderPadding*2}),i.remove(),_pe(i,_this101.fullLayer.parent);}),n&&this.clearWorkShapeNodeCache(t)),n;}},{key:"drawPencil",value:function(){var _drawPencil2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee70(t,r){return _regeneratorRuntime().wrap(function _callee70$(_context73){while(1)switch(_context73.prev=_context73.next){case 0:_context73.next=2;return this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:t==null?void 0:t.rect,workId:r,drawCanvas:Et.Float,viewId:this.viewId}],sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context73.stop();}},_callee70,this);}));function drawPencil(_x135,_x136){return _drawPencil2.apply(this,arguments);}return drawPencil;}()},{key:"drawShape",value:function(){var _drawShape2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee71(t){return _regeneratorRuntime().wrap(function _callee71$(_context74){while(1)switch(_context74.prev=_context74.next){case 0:_context74.next=2;return this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:(t==null?void 0:t.rect)&&kt(t.rect),isClear:!0,clearCanvas:Et.Float,viewId:this.viewId},{rect:(t==null?void 0:t.rect)&&kt(t.rect),drawCanvas:Et.Float,viewId:this.viewId}]});case 2:case"end":return _context74.stop();}},_callee71,this);}));function drawShape(_x137){return _drawShape2.apply(this,arguments);}return drawShape;}()},{key:"drawSelector",value:function(){var _drawSelector2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee72(t){return _regeneratorRuntime().wrap(function _callee72$(_context75){while(1)switch(_context75.prev=_context75.next){case 0:_context75.next=2;return this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:(t==null?void 0:t.rect)&&kt(t.rect),isClear:!0,clearCanvas:Et.Float,viewId:this.viewId},{rect:(t==null?void 0:t.rect)&&kt(t.rect),drawCanvas:Et.Float,viewId:this.viewId}]});case 2:case"end":return _context75.stop();}},_callee72,this);}));function drawSelector(_x138){return _drawSelector2.apply(this,arguments);}return drawSelector;}()}]);}(hs);var ay=/*#__PURE__*/function(){function ay(e){_classCallCheck(this,ay);ot(this,"viewId");ot(this,"vNodes");ot(this,"topLayer");ot(this,"thread");ot(this,"post");ot(this,"serviceWorkShapes",/* @__PURE__ */new Map());ot(this,"localWorkShapes",/* @__PURE__ */new Map());ot(this,"tmpOpt");ot(this,"syncUnitTime",me.syncOpt.interval);ot(this,"animationId");this.viewId=e.viewId,this.vNodes=e.vNodes,this.topLayer=e.topLayer,this.thread=e.thread,this.post=e.thread.post.bind(e.thread);}return _createClass(ay,[{key:"canUseTopLayer",value:function canUseTopLayer(e){return e===pt.LaserPen;}},{key:"getWorkShape",value:function getWorkShape(e){return this.localWorkShapes.get(e);}},{key:"createWorkShape",value:function createWorkShape(e,t){if(e&&this.tmpOpt){var r={toolsType:this.tmpOpt.toolsType,toolsOpt:t||this.tmpOpt.toolsOpt},n=this.createWorkShapeNode(_objectSpread(_objectSpread({},r),{},{workId:e}));return n&&this.localWorkShapes.set(e,{node:n,toolsType:n.toolsType,workState:Ft.Start}),n;}}},{key:"setWorkOptions",value:function setWorkOptions(e,t){var n;var r=(n=this.localWorkShapes.get(e))==null?void 0:n.node;r||this.createWorkShape(e,t),r==null||r.setWorkOptions(t);}},{key:"createWorkShapeNode",value:function createWorkShapeNode(e){var t=e.toolsType;if(t===pt.LaserPen)return Ur(_objectSpread(_objectSpread({},e),{},{vNodes:this.vNodes,fullLayer:this.topLayer,drawLayer:this.topLayer}));}},{key:"clearAllWorkShapesCache",value:function clearAllWorkShapesCache(){this.localWorkShapes.forEach(function(e){var t;return(t=e.node)==null?void 0:t.clearTmpPoints();}),this.localWorkShapes.clear();}},{key:"setToolsOpt",value:function setToolsOpt(e){var t;this.tmpOpt=e,(t=e.toolsOpt)!=null&&t.syncUnitTime&&(this.syncUnitTime=e.toolsOpt.syncUnitTime);}},{key:"getToolsOpt",value:function getToolsOpt(){return this.tmpOpt;}},{key:"consumeDraw",value:function consumeDraw(e){var t=e.workId,r=e.dataType;if(r===Dt.Service)this.activeServiceWorkShape(e);else{var n=t==null?void 0:t.toString(),i=n&&this.localWorkShapes.get(n);if(!i)return;var l=i.node.consume({data:e,isFullWork:!1,isSubWorker:!0});l.rect&&(i.totalRect=bt(l.rect,i.totalRect),i.result=l,i.workState=Ft.Doing,n&&this.localWorkShapes.set(n,i));}this.runAnimation();}},{key:"consumeDrawAll",value:function consumeDrawAll(e){var t=e.workId,r=e.dataType;if(r===Dt.Service)this.activeServiceWorkShape(e);else{var n=t==null?void 0:t.toString(),i=n&&this.localWorkShapes.get(n);if(!i)return;var l=i.node.consumeAll({data:e});i.totalRect=bt(l.rect,i.totalRect),i.result=l,i.workState=Ft.Done,n&&this.localWorkShapes.set(n,i);}this.runAnimation();}},{key:"destroy",value:function destroy(){this.serviceWorkShapes.clear(),this.localWorkShapes.clear();}},{key:"setNodeKey",value:function setNodeKey(e,t,r,n){return t.toolsType=r,t.node=this.createWorkShapeNode({workId:e,toolsType:r,toolsOpt:n}),t;}},{key:"activeServiceWorkShape",value:function activeServiceWorkShape(e){var v,S;var t=e.workId,r=e.opt,n=e.toolsType,i=e.type,l=e.updateNodeOpt,o=e.ops,a=e.op;if(!t)return;var c=t.toString(),m=(v=this.vNodes.get(c))==null?void 0:v.rect;if(!((S=this.serviceWorkShapes)!=null&&S.has(c))){var E={toolsType:n,animationWorkData:a||[],animationIndex:0,type:i,updateNodeOpt:l,ops:o,oldRect:m};n&&r&&(E=this.setNodeKey(c,E,n,r)),this.serviceWorkShapes.set(c,E);}var f=this.serviceWorkShapes.get(c);i&&(f.type=i),o&&(f.animationWorkData=Qe(o),f.ops=o),l&&(f.updateNodeOpt=l),a&&(f.animationWorkData=a),f.node&&f.node.getWorkId()!==c&&f.node.setWorkId(c),m&&(f.oldRect=m),n&&r&&(f.toolsType!==n&&n&&r&&this.setNodeKey(c,f,n,r),f.node&&f.node.setWorkOptions(r));}},{key:"computNextAnimationIndex",value:function computNextAnimationIndex(e,t){var r=Math.floor((e.animationWorkData||[]).slice(e.animationIndex).length*32/t/this.syncUnitTime)*t;return Math.min((e.animationIndex||0)+(r||t),(e.animationWorkData||[]).length);}},{key:"animationDraw",value:function(){var _animationDraw2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee73(){var _this102=this;var l,o,a,c,e,t,r,n,i,_iterator67,_step67,_step67$value,m,f,S,E,T,P,_iterator68,_step68,_step68$value,_m13,_f7,v,_S10,_E2,_T4,_P22;return _regeneratorRuntime().wrap(function _callee73$(_context76){while(1)switch(_context76.prev=_context76.next){case 0:this.animationId=void 0;e=!1;t=/* @__PURE__ */new Map(),r=[],n=[],i=[];_iterator67=_createForOfIteratorHelper(this.serviceWorkShapes.entries());_context76.prev=4;_iterator67.s();case 6:if((_step67=_iterator67.n()).done){_context76.next=20;break;}_step67$value=_slicedToArray(_step67.value,2),m=_step67$value[0],f=_step67$value[1];_context76.t0=f.toolsType;_context76.next=_context76.t0===pt.LaserPen?11:18;break;case 11:S=this.computNextAnimationIndex(f,8),E=Math.max(0,f.animationIndex||0),T=(f.animationWorkData||[]).slice(E,S);if((f.animationIndex||0)<S){P=(l=f.node)==null?void 0:l.consumeService({op:T,isFullWork:!1});f.totalRect=bt(f.totalRect,P),f.animationIndex=S,T.length&&t.set(m,{workState:E===0?Ft.Start:S===((o=f.animationWorkData)==null?void 0:o.length)?Ft.Done:Ft.Doing,op:T.slice(-2)});}if(!(n.push({isClear:!0,rect:f.totalRect,clearCanvas:Et.TopFloat,viewId:this.viewId}),r.push({rect:f.totalRect,drawCanvas:Et.TopFloat,viewId:this.viewId}),f.isDel)){_context76.next=16;break;}(a=f.node)==null||a.clearTmpPoints(),this.serviceWorkShapes["delete"](m);return _context76.abrupt("break",18);case 16:f.ops&&f.animationIndex===((c=f.animationWorkData)==null?void 0:c.length)&&!f.isDel&&(this.topLayer.getElementsByName(m.toString())[0]||(f.isDel=!0,this.serviceWorkShapes.set(m,f))),e=!0;return _context76.abrupt("break",18);case 18:_context76.next=6;break;case 20:_context76.next=25;break;case 22:_context76.prev=22;_context76.t1=_context76["catch"](4);_iterator67.e(_context76.t1);case 25:_context76.prev=25;_iterator67.f();return _context76.finish(25);case 28:_iterator68=_createForOfIteratorHelper(this.localWorkShapes.entries());_context76.prev=29;_iterator68.s();case 31:if((_step68=_iterator68.n()).done){_context76.next=44;break;}_step68$value=_slicedToArray(_step68.value,2),_m13=_step68$value[0],_f7=_step68$value[1];v=_f7.result,_S10=_f7.toolsType,_E2=_f7.totalRect,_T4=_f7.isDel,_P22=_f7.workState;_context76.t2=_S10;_context76.next=_context76.t2===pt.LaserPen?37:42;break;case 37:if(!(_E2&&(n.push({isClear:!0,rect:_E2,clearCanvas:Et.TopFloat,viewId:this.viewId}),r.push({rect:_E2,drawCanvas:Et.TopFloat,viewId:this.viewId})),_T4)){_context76.next=40;break;}_f7.node.clearTmpPoints(),this.localWorkShapes["delete"](_m13),i.push({removeIds:[_m13.toString()],viewId:this.viewId,type:dt.RemoveNode});return _context76.abrupt("break",42);case 40:v&&((v.op||v.ops)&&i.push(v),_f7.result=void 0),!this.topLayer.getElementsByName(_m13.toString())[0]&&_P22===Ft.Done&&(_f7.isDel=!0,this.localWorkShapes.set(_m13,_f7)),e=!0;return _context76.abrupt("break",42);case 42:_context76.next=31;break;case 44:_context76.next=49;break;case 46:_context76.prev=46;_context76.t3=_context76["catch"](29);_iterator68.e(_context76.t3);case 49:_context76.prev=49;_iterator68.f();return _context76.finish(49);case 52:e&&this.runAnimation(),t.size&&t.forEach(function(m,f){i.push({type:dt.Cursor,uid:f.split(Je)[0],op:m.op,workState:m.workState,viewId:_this102.viewId});}),(r.length||n.length||i.length)&&this.post({render:[].concat(n,r),sp:i});case 53:case"end":return _context76.stop();}},_callee73,this,[[4,22,25,28],[29,46,49,52]]);}));function animationDraw(){return _animationDraw2.apply(this,arguments);}return animationDraw;}()},{key:"runAnimation",value:function runAnimation(){var _this103=this;this.animationId||(this.animationId=setTimeout(function(){_this103.animationId=void 0,_this103.animationDraw();},16));}}]);}();var ly=/*#__PURE__*/function(_ys){function ly(t){var _this104;_classCallCheck(this,ly);_this104=_callSuper(this,ly,[t]);ot(_this104,"_type","simple");return _this104;}_inherits(ly,_ys);return _createClass(ly,[{key:"createWorkShapeNode",value:function createWorkShapeNode(t){var n;var r=t.toolsType;return r===pt.Selector?this.vNodes?new ar(_objectSpread(_objectSpread({},t),{},{fullLayer:this.fullLayer,vNodes:this.vNodes,drawLayer:this.drawLayer})):void 0:Ur(_objectSpread(_objectSpread({},t),{},{vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer}),(n=this.thread)==null?void 0:n.serviceWork);}},{key:"drawPencil",value:function(){var _drawPencil3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee74(t,r){return _regeneratorRuntime().wrap(function _callee74$(_context77){while(1)switch(_context77.prev=_context77.next){case 0:_context77.next=2;return this._post({consumeCount:this.consumeCount,render:[{rect:t==null?void 0:t.rect,workId:r,drawCanvas:Et.Float,viewId:this.viewId}],sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context77.stop();}},_callee74,this);}));function drawPencil(_x139,_x140){return _drawPencil3.apply(this,arguments);}return drawPencil;}()},{key:"drawShape",value:function(){var _drawShape3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee75(t){return _regeneratorRuntime().wrap(function _callee75$(_context78){while(1)switch(_context78.prev=_context78.next){case 0:_context78.next=2;return this._post({consumeCount:this.consumeCount,sp:(t==null?void 0:t.op)&&[t],render:[{rect:(t==null?void 0:t.rect)&&kt(t.rect),isClear:!0,clearCanvas:Et.Float,viewId:this.viewId},{rect:(t==null?void 0:t.rect)&&kt(t.rect),drawCanvas:Et.Float,viewId:this.viewId}]});case 2:case"end":return _context78.stop();}},_callee75,this);}));function drawShape(_x141){return _drawShape3.apply(this,arguments);}return drawShape;}()},{key:"drawSelector",value:function(){var _drawSelector3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee76(t,r){var n,l,o,a,i,_args79=arguments;return _regeneratorRuntime().wrap(function _callee76$(_context79){while(1)switch(_context79.prev=_context79.next){case 0:n=_args79.length>2&&_args79[2]!==undefined?_args79[2]:[];i={render:n,sp:[t],consumeCount:this.consumeCount};r&&((l=i.sp)==null||l.push({type:dt.None,isLockSentEventCursor:r}));t.subRect&&((o=i.render)==null||o.push({rect:kt(t.subRect),isClear:!0,clearCanvas:Et.Float,viewId:this.viewId},{rect:kt(t.subRect),drawCanvas:Et.Float,viewId:this.viewId}));t.rect&&((a=i.render)==null||a.push({rect:kt(t.rect),clearCanvas:Et.Bg,isClear:!0,viewId:this.viewId},{rect:kt(t.rect),drawCanvas:Et.Bg,viewId:this.viewId}));_context79.next=7;return this._post(i);case 7:case"end":return _context79.stop();}},_callee76,this);}));function drawSelector(_x142,_x143){return _drawSelector3.apply(this,arguments);}return drawSelector;}()},{key:"drawEraserCombine",value:function(){var _drawEraserCombine2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee77(t){var n,i,l,o,r,a,c,m,f,_iterator69,_step69,_step69$value,_f8,v;return _regeneratorRuntime().wrap(function _callee77$(_context80){while(1)switch(_context80.prev=_context80.next){case 0:r=(n=this.workShapes.get(t))==null?void 0:n.combineConsume({workerEngine:this});if(!r){_context80.next=7;break;}a=r.willDeleteNodes,c=r.willNewNodes,m={render:[],sp:[]};if(r!=null&&r.rect){f=kt(r.rect);(i=m.render)==null||i.push({rect:f,isClear:!0,clearCanvas:Et.Bg,viewId:this.viewId},{rect:f,drawCanvas:Et.Bg,viewId:this.viewId});}if(a!=null&&a.size&&((l=m.sp)==null||l.push({type:dt.RemoveNode,removeIds:_toConsumableArray(a),viewId:this.thread.viewId})),c!=null&&c.size){_iterator69=_createForOfIteratorHelper(c);try{for(_iterator69.s();!(_step69=_iterator69.n()).done;){_step69$value=_slicedToArray(_step69.value,2),_f8=_step69$value[0],v=_step69$value[1];(o=m.sp)==null||o.push({type:dt.FullWork,dataType:Dt.Local,toolsType:pt.Pencil,ops:ve(v.op),opt:v.opt,workId:_f8,updateNodeOpt:{useAnimation:!1}});}}catch(err){_iterator69.e(err);}finally{_iterator69.f();}}_context80.next=7;return this._post(m);case 7:case"end":return _context80.stop();}},_callee77,this);}));function drawEraserCombine(_x144){return _drawEraserCombine2.apply(this,arguments);}return drawEraserCombine;}()},{key:"consumeDraw",value:function(){var _consumeDraw4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee78(t,r){var _this105=this;var n,i,l,o,a,c,m,f,v;return _regeneratorRuntime().wrap(function _callee78$(_context81){while(1)switch(_context81.prev=_context81.next){case 0:n=t.op,i=t.workId,l=t.scenePath,o=t.postCount,a=t.smoothSync;if(!(n!=null&&n.length&&i)){_context81.next=42;break;}c=i.toString(),m=this.getWorkShape(c);if(m){_context81.next=5;break;}return _context81.abrupt("return");case 5:f=m.toolsType;if(!(f===pt.LaserPen)){_context81.next=8;break;}return _context81.abrupt("return");case 8:_context81.t0=this.drawWorkActiveId&&this.drawWorkActiveId!==c;if(!_context81.t0){_context81.next=13;break;}_context81.next=12;return this.consumeDrawAll({workId:this.drawWorkActiveId,scenePath:l,viewId:this.viewId,msgType:dt.DrawWork,dataType:Dt.Local},r);case 12:this.drawWorkActiveId=void 0;case 13:!this.drawWorkActiveId&&c!==qt&&(this.drawWorkActiveId=c);ue(o)&&(this.consumeCount=o);v=m.consume({data:t,isSimpleWorker:!0,smoothSync:a});_context81.t1=f;_context81.next=_context81.t1===pt.Selector?19:_context81.t1===pt.PencilEraser?24:_context81.t1===pt.BitMapEraser?24:_context81.t1===pt.Eraser?29:_context81.t1===pt.Arrow?32:_context81.t1===pt.Straight?32:_context81.t1===pt.Ellipse?32:_context81.t1===pt.Rectangle?32:_context81.t1===pt.Star?32:_context81.t1===pt.Polygon?32:_context81.t1===pt.SpeechBalloon?32:_context81.t1===pt.Pencil?38:42;break;case 19:this.drawCount++;v.type===dt.Select&&v.selectIds&&r.runReverseSelectWork(v.selectIds);_context81.next=23;return this.drawSelector(v);case 23:return _context81.abrupt("break",42);case 24:this.drawCount++;this.combineTimerId||(this.combineTimerId=1,this.combineDrawActiveId=c,this.drawEraserCombine(c).then(function(){_this105.combineTimerId=void 0;}));_context81.next=28;return this._post({consumeCount:this.consumeCount});case 28:return _context81.abrupt("break",42);case 29:_context81.next=31;return this.drawEraser(v);case 31:return _context81.abrupt("break",42);case 32:_context81.t2=v;if(!_context81.t2){_context81.next=37;break;}this.drawCount++;_context81.next=37;return this.drawShape(v);case 37:return _context81.abrupt("break",42);case 38:this.drawCount++;_context81.next=41;return this.drawPencil(v,c);case 41:return _context81.abrupt("break",42);case 42:case"end":return _context81.stop();}},_callee78,this);}));function consumeDraw(_x145,_x146){return _consumeDraw4.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee79(t,r){var o,a,c,n,i,l,m,f,v,S,E,T,P;return _regeneratorRuntime().wrap(function _callee79$(_context82){while(1)switch(_context82.prev=_context82.next){case 0:this.combineTimerId&&(clearTimeout(this.combineTimerId),this.combineTimerId=void 0,this.combineDrawResolve&&this.combineDrawResolve(!1),this.combineDrawActiveId=void 0);n=t.workId,i=t.scenePath,l=t.isLockSentEventCursor;if(!n){_context82.next=40;break;}m=n.toString();this.drawWorkActiveId===m&&(this.drawWorkActiveId=void 0);f=this.workShapes.get(m);if(f){_context82.next=8;break;}return _context82.abrupt("return");case 8:v=f.toolsType;if(!(v===pt.LaserPen)){_context82.next=11;break;}return _context82.abrupt("return");case 11:S=this.workShapes.get(He),E=(o=S==null?void 0:S.selectIds)==null?void 0:o[0],T=f.consumeAll({data:t,workerEngine:this});_context82.t0=v;_context82.next=_context82.t0===pt.Selector?15:_context82.t0===pt.PencilEraser?23:_context82.t0===pt.BitMapEraser?23:_context82.t0===pt.Eraser?28:_context82.t0===pt.Arrow?30:_context82.t0===pt.Straight?30:_context82.t0===pt.Ellipse?30:_context82.t0===pt.Rectangle?30:_context82.t0===pt.Star?30:_context82.t0===pt.Polygon?30:_context82.t0===pt.SpeechBalloon?30:_context82.t0===pt.Pencil?35:40;break;case 15:P=[];this.drawLayer&&(this.drawCount=0,Se(this.drawLayer,this.drawLayer.parent),this.getWorkShape(m).clearSubTmpPoints(),P.push({isClearAll:!0,clearCanvas:Et.Float,viewId:this.viewId}));T.selectIds&&E&&(a=T.selectIds)!=null&&a.includes(E)&&S.cursorBlur();T.selectIds&&r.runReverseSelectWork(T.selectIds);_context82.next=21;return this.drawSelector(_objectSpread(_objectSpread({},T),{},{scenePath:i}),l,P);case 21:(c=f.selectIds)!=null&&c.length?f.clearTmpPoints():this.clearWorkShapeNodeCache(m);return _context82.abrupt("break",40);case 23:_context82.next=25;return this.drawEraserFull(f,_objectSpread(_objectSpread({},T),{},{scenePath:i}),l);case 25:this.drawCount=0;this.clearWorkShapeNodeCache(m);return _context82.abrupt("break",40);case 28:this.drawEraser(_objectSpread(_objectSpread({},T),{},{scenePath:i}),l),f.clearTmpPoints();return _context82.abrupt("break",40);case 30:_context82.next=32;return this.drawPencilFull(_objectSpread(_objectSpread({},T),{},{scenePath:i}),l);case 32:this.drawCount=0;this.clearWorkShapeNodeCache(m);return _context82.abrupt("break",40);case 35:_context82.next=37;return this.drawPencilFull(_objectSpread(_objectSpread({},T),{},{scenePath:i}),l);case 37:this.drawCount=0;this.clearWorkShapeNodeCache(m);return _context82.abrupt("break",40);case 40:case"end":return _context82.stop();}},_callee79,this);}));function consumeDrawAll(_x147,_x148){return _consumeDrawAll3.apply(this,arguments);}return consumeDrawAll;}()}]);}(ys);var cy=/*#__PURE__*/function(_gs){function cy(t){var _this106;_classCallCheck(this,cy);_this106=_callSuper(this,cy,[t]);ot(_this106,"_type","simple");return _this106;}_inherits(cy,_gs);return _createClass(cy,[{key:"animationDraw",value:function(){var _animationDraw3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee80(){var _this107=this;var i,l,o,a,c,m,f,v,S,E,T,P,x,h,p,d,g,O,w,L,B,A,b,W,D,R,X,H,J,et,it,$,V,rt,lt,ct,gt,st,Ct,xt,t,r,n,_iterator70,_step70,_loop7;return _regeneratorRuntime().wrap(function _callee80$(_context84){while(1)switch(_context84.prev=_context84.next){case 0:this.animationId=void 0;t=!1;r={render:[]},n=/* @__PURE__ */new Map();_iterator70=_createForOfIteratorHelper(this.workShapes.entries());_context84.prev=4;_loop7=/*#__PURE__*/_regeneratorRuntime().mark(function _loop7(){var _step70$value,F,U,K,q,_K5,_q3,_K6,_q4,Y,k,_K7,_q5,_Y4,_k3,C,M,j,_M,_K8,_q6,_Y5,_k4;return _regeneratorRuntime().wrap(function _loop7$(_context83){while(1)switch(_context83.prev=_context83.next){case 0:_step70$value=_slicedToArray(_step70.value,2),F=_step70$value[0],U=_step70$value[1];_context83.t0=U.toolsType;_context83.next=_context83.t0===pt.Image?4:_context83.t0===pt.Text?11:_context83.t0===pt.Arrow?19:_context83.t0===pt.Straight?19:_context83.t0===pt.Rectangle?19:_context83.t0===pt.Ellipse?19:_context83.t0===pt.Star?19:_context83.t0===pt.Polygon?19:_context83.t0===pt.SpeechBalloon?19:_context83.t0===pt.Pencil?22:38;break;case 4:K=U.oldRect;K&&((i=r.render)==null||i.push({rect:K,isClear:!0,clearCanvas:Et.Bg,viewId:_this107.viewId}),(l=r.render)==null||l.push({rect:K,drawCanvas:Et.Bg,viewId:_this107.viewId}));_context83.next=8;return(o=U.node)==null?void 0:o.consumeServiceAsync({isFullWork:!0,worker:_this107.thread});case 8:q=_context83.sent;_this107.selectorWorkShapes.forEach(function(Y,k){var C;(C=Y.selectIds)!=null&&C.includes(F)&&(_this107.willRunEffectSelectorIds.add(k),_this107.noAnimationRect=bt(_this107.noAnimationRect,K),_this107.noAnimationRect=bt(_this107.noAnimationRect,q),_this107.runEffect());}),_this107.workShapes["delete"](F),(a=r.render)==null||a.push({rect:q,drawCanvas:Et.Bg,viewId:_this107.viewId});return _context83.abrupt("break",38);case 11:if(!U.node){_context83.next=18;break;}_K5=U.oldRect;_K5&&((c=r.render)==null||c.push({rect:_K5,isClear:!0,clearCanvas:Et.Bg,viewId:_this107.viewId}),(m=r.render)==null||m.push({rect:_K5,drawCanvas:Et.Bg,viewId:_this107.viewId}));_context83.next=16;return U.node.consumeServiceAsync({isFullWork:!0,replaceId:F});case 16:_q3=_context83.sent;_this107.selectorWorkShapes.forEach(function(Y,k){var C;(C=Y.selectIds)!=null&&C.includes(F)&&(_this107.willRunEffectSelectorIds.add(k),_this107.noAnimationRect=bt(_this107.noAnimationRect,_K5),_this107.noAnimationRect=bt(_this107.noAnimationRect,_q3),_this107.runEffect());}),(f=U.node)==null||f.clearTmpPoints(),_this107.workShapes["delete"](F),(v=r.render)==null||v.push({rect:_q3,drawCanvas:Et.Bg,viewId:_this107.viewId});case 18:return _context83.abrupt("break",38);case 19:_K6=!!U.ops;if((S=U.animationWorkData)!=null&&S.length){_q4=U.oldRect,Y=U.node.oldRect;_q4&&((E=r.render)==null||E.push({rect:_q4,isClear:!0,clearCanvas:Et.Bg,viewId:_this107.viewId}),(T=r.render)==null||T.push({rect:_q4,drawCanvas:Et.Bg,viewId:_this107.viewId})),Y&&((P=r.render)==null||P.push({rect:Y,isClear:!0,clearCanvas:Et.ServiceFloat,viewId:_this107.viewId}));k=(x=U.node)==null?void 0:x.consumeService({op:U.animationWorkData,isFullWork:_K6});U.isEnableCursor?n.set(F,{workState:_q4?U.ops?Ft.Done:Ft.Doing:Ft.Start,op:U.animationWorkData.slice(-3,-1)}):_K6&&!U.useAnimation&&(h=U.updateNodeOpt)!=null&&h.useAnimation&&n.set(F,{workState:Ft.Done,op:U.animationWorkData.slice(-3,-1),uid:(p=U.updateNodeOpt)==null?void 0:p.uid}),_K6?(_this107.selectorWorkShapes.forEach(function(C,M){var j;(j=C.selectIds)!=null&&j.includes(F)&&(_this107.willRunEffectSelectorIds.add(M),_this107.noAnimationRect=bt(_this107.noAnimationRect,_q4),_this107.noAnimationRect=bt(_this107.noAnimationRect,Y),_this107.noAnimationRect=bt(_this107.noAnimationRect,k),_this107.runEffect());}),(d=U.node)==null||d.clearTmpPoints(),_this107.workShapes["delete"](F),(g=r.render)==null||g.push({rect:k,drawCanvas:Et.Bg,viewId:_this107.viewId})):(O=r.render)==null||O.push({rect:k,drawCanvas:Et.ServiceFloat,workerType:_K6?void 0:Dt.Service,viewId:_this107.viewId}),U.animationWorkData.length=0;}return _context83.abrupt("break",38);case 22:if(!U.useAnimation){_context83.next=33;break;}if(!U.useAnimation){_context83.next=31;break;}if(!U.isDel){_context83.next=27;break;}(it=U.node)==null||it.clearTmpPoints(),_this107.workShapes["delete"](F);return _context83.abrupt("break",38);case 27:_K7=3,_q5=_this107.computNextAnimationIndex(U,_K7),_Y4=U.isDiff?0:Math.max(0,(U.animationIndex||0)-_K7),_k3=(U.animationWorkData||[]).slice(0,_q5),C=(V=($=U.node)==null?void 0:$.getWorkId())==null?void 0:V.toString();if((U.animationIndex||0)<_q5||U.isDiff){M=(rt=U.node)==null?void 0:rt.consumeService({op:_k3,isFullWork:!1,replaceId:C});if((lt=r.render)==null||lt.push({isClear:!0,rect:M,clearCanvas:Et.ServiceFloat,viewId:_this107.viewId}),(ct=r.render)==null||ct.push({rect:M,drawCanvas:Et.ServiceFloat,viewId:_this107.viewId}),U.animationIndex=_q5,U.isDiff&&(U.isDiff=!1),_k3.length&&U.isEnableCursor){j=_k3.slice(-3,-1);n.set(F,{workState:_Y4===0?Ft.Start:_q5===((gt=U.animationWorkData)==null?void 0:gt.length)?Ft.Done:Ft.Doing,op:j});}}else if(U.ops){_M=(st=U.node)==null?void 0:st.consumeService({op:U.animationWorkData||[],isFullWork:!0,replaceId:C});U.isDel=!0,(Ct=r.render)==null||Ct.push({isClear:!0,rect:_M,clearCanvas:Et.ServiceFloat,viewId:_this107.viewId},{rect:_M,drawCanvas:Et.ServiceFloat,viewId:_this107.viewId},{isClear:!0,rect:_M,clearCanvas:Et.Bg,viewId:_this107.viewId},{rect:_M,drawCanvas:Et.Bg,viewId:_this107.viewId}),U.isEnableCursor&&n.set(F,{workState:Ft.Done,op:_k3.slice(-3,-1)});}t=!0;return _context83.abrupt("break",38);case 31:_context83.next=37;break;case 33:_K8=!!U.ops;_q6=(w=U.node)==null?void 0:w.consumeService({op:U.animationWorkData||[],isFullWork:_K8,replaceId:F});_Y5=(L=U.node)==null?void 0:L.updataOptService(U.updateNodeOpt);if(_K8){if(_q6=bt(_q6,_Y5),(B=r.render)==null||B.push({isClear:!0,rect:bt(U.oldRect,_q6),clearCanvas:Et.Bg,viewId:_this107.viewId}),(A=r.render)==null||A.push({rect:bt(U.oldRect,_q6),drawCanvas:Et.Bg,viewId:_this107.viewId}),(b=U.updateNodeOpt)!=null&&b.useAnimation&&((W=r.render)==null||W.push({isClear:!0,rect:bt(U.oldRect,_q6),clearCanvas:Et.ServiceFloat,viewId:_this107.viewId}),(D=r.render)==null||D.push({rect:bt(U.oldRect,_q6),drawCanvas:Et.ServiceFloat,viewId:_this107.viewId}),!U.isEnableCursor&&(R=U.animationWorkData)!=null&&R.length)){_k4=U.animationWorkData.slice(-3,-1);n.set(F,{workState:Ft.Done,op:_k4,uid:(X=U.updateNodeOpt)==null?void 0:X.uid});}_this107.selectorWorkShapes.forEach(function(k,C){var M;(M=k.selectIds)!=null&&M.includes(F)&&(_this107.willRunEffectSelectorIds.add(C),_this107.noAnimationRect=bt(_this107.noAnimationRect,_q6),_this107.runEffect());}),(H=U.node)==null||H.clearTmpPoints(),_this107.workShapes["delete"](F);}else _q6=bt(_q6,_Y5),(J=r.render)==null||J.push({isClear:!0,rect:bt(U.oldRect,_q6),clearCanvas:Et.ServiceFloat,viewId:_this107.viewId}),(et=r.render)==null||et.push({rect:bt(U.oldRect,_q6),drawCanvas:Et.ServiceFloat,viewId:_this107.viewId});case 37:return _context83.abrupt("break",38);case 38:case"end":return _context83.stop();}},_loop7);});_iterator70.s();case 7:if((_step70=_iterator70.n()).done){_context84.next=11;break;}return _context84.delegateYield(_loop7(),"t0",9);case 9:_context84.next=7;break;case 11:_context84.next=16;break;case 13:_context84.prev=13;_context84.t1=_context84["catch"](4);_iterator70.e(_context84.t1);case 16:_context84.prev=16;_iterator70.f();return _context84.finish(16);case 19:t&&this.runAnimation();n.size&&(r.sp=[],n.forEach(function(F,U){var K;(K=r.sp)==null||K.push({type:dt.Cursor,uid:F.uid||U.split(Je)[0],op:F.op,workState:F.workState,viewId:_this107.viewId});}));_context84.t2=(xt=r.render)!=null&&xt.length;if(!_context84.t2){_context84.next=25;break;}_context84.next=25;return this.post(r);case 25:case"end":return _context84.stop();}},_callee80,this,[[4,13,16,19]]);}));function animationDraw(){return _animationDraw3.apply(this,arguments);}return animationDraw;}()}]);}(gs);var wr=/* @__PURE__ */function(u){return u.Full="full",u.Sub="sub",u;}(wr||{});var fy=/*#__PURE__*/function(){function fy(e,t){var _this108=this;_classCallCheck(this,fy);ot(this,"_self");ot(this,"version",$i);ot(this,"type");// protected hasPriorityDraw: boolean = true;
471
+ _inherits(oy,_hs2);return _createClass(oy,[{key:"runSelectWork",value:function runSelectWork(t){var n;var r=this.setFullWork(t);r&&(n=t.selectIds)!=null&&n.length&&t.workId&&r.selectServiceNode(t.workId.toString(),{selectIds:t.selectIds},!1);}},{key:"workShapesDone",value:function workShapesDone(){var _iterator66=_createForOfIteratorHelper(this.workShapes.keys()),_step66;try{for(_iterator66.s();!(_step66=_iterator66.n()).done;){var t=_step66.value;this.clearWorkShapeNodeCache(t);}}catch(err){_iterator66.e(err);}finally{_iterator66.f();}Se(this.fullLayer,this.fullLayer.parent);}},{key:"consumeDraw",value:function(){var _consumeDraw3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee67(t){var r,n,i,l,o,a,c;return _regeneratorRuntime().wrap(function _callee67$(_context70){while(1)switch(_context70.prev=_context70.next){case 0:r=t.workId,n=t.fullWorkerDrawCount,i=t.postCount,l=r==null?void 0:r.toString(),o=l&&this.workShapes.get(l);if(o){_context70.next=3;break;}return _context70.abrupt("return");case 3:_context70.t0=this.drawWorkActiveId&&this.drawWorkActiveId!==l;if(!_context70.t0){_context70.next=8;break;}_context70.next=7;return this.consumeDrawAll({workId:this.drawWorkActiveId,viewId:this.viewId,msgType:dt.DrawWork,dataType:Dt.Local});case 7:this.drawWorkActiveId=void 0;case 8:!this.drawWorkActiveId&&l!==qt&&(this.drawWorkActiveId=l);a=o.toolsType;he(i)&&(this.consumeCount=i);c=o.consume({data:t,drawCount:this.drawCount,isFullWork:!0,isSubWorker:!0,removeDrawCount:n});_context70.t1=a;_context70.next=_context70.t1===pt.Selector?15:_context70.t1===pt.Ellipse?21:_context70.t1===pt.Arrow?21:_context70.t1===pt.Straight?21:_context70.t1===pt.Rectangle?21:_context70.t1===pt.Star?21:_context70.t1===pt.Polygon?21:_context70.t1===pt.SpeechBalloon?21:_context70.t1===pt.Pencil?27:_context70.t1===pt.BitMapEraser?33:_context70.t1===pt.PencilEraser?33:39;break;case 15:_context70.t2=c;if(!_context70.t2){_context70.next=20;break;}this.drawCount++;_context70.next=20;return this.drawSelector(c);case 20:return _context70.abrupt("break",39);case 21:_context70.t3=c;if(!_context70.t3){_context70.next=26;break;}this.drawCount++;_context70.next=26;return this.drawShape(c);case 26:return _context70.abrupt("break",39);case 27:_context70.t4=c;if(!_context70.t4){_context70.next=32;break;}this.drawCount++;_context70.next=32;return this.drawPencil(c,r==null?void 0:r.toString());case 32:return _context70.abrupt("break",39);case 33:_context70.t5=c;if(!_context70.t5){_context70.next=38;break;}this.drawCount++;_context70.next=38;return this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount});case 38:return _context70.abrupt("break",39);case 39:case"end":return _context70.stop();}},_callee67,this);}));function consumeDraw(_x132){return _consumeDraw3.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee68(t){var r,n,i;return _regeneratorRuntime().wrap(function _callee68$(_context71){while(1)switch(_context71.prev=_context71.next){case 0:r=t.workId;if(!r){_context71.next=14;break;}n=r.toString();this.drawWorkActiveId===n&&(this.drawWorkActiveId=void 0);i=this.workShapes.get(n);if(i){_context71.next=7;break;}return _context71.abrupt("return");case 7:_context71.t0=i.toolsType;_context71.next=_context71.t0===pt.Selector?10:_context71.t0===pt.Arrow?12:_context71.t0===pt.Straight?12:_context71.t0===pt.Ellipse?12:_context71.t0===pt.Pencil?12:_context71.t0===pt.Rectangle?12:_context71.t0===pt.Star?12:_context71.t0===pt.Polygon?12:_context71.t0===pt.SpeechBalloon?12:_context71.t0===pt.BitMapEraser?12:_context71.t0===pt.PencilEraser?12:14;break;case 10:this.drawCount=0,Se(this.fullLayer,this.fullLayer.parent),this.clearWorkShapeNodeCache(n),this._post({render:[{isClearAll:!0,clearCanvas:Et.Float,viewId:this.viewId}]});return _context71.abrupt("break",14);case 12:this.drawCount=0,Se(this.fullLayer,this.fullLayer.parent),this.clearWorkShapeNodeCache(n);return _context71.abrupt("break",14);case 14:case"end":return _context71.stop();}},_callee68,this);}));function consumeDrawAll(_x133){return _consumeDrawAll2.apply(this,arguments);}return consumeDrawAll;}()},{key:"removeWork",value:function(){var _removeWork4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee69(t){var r,n,i,l;return _regeneratorRuntime().wrap(function _callee69$(_context72){while(1)switch(_context72.prev=_context72.next){case 0:r=t.workId,n=r==null?void 0:r.toString();if(!n){_context72.next=8;break;}i=this.removeNode(n);if(!i){_context72.next=8;break;}l=[];l.push({rect:kt(i),clearCanvas:Et.Float,isClear:!0,viewId:this.viewId},{rect:kt(i),drawCanvas:Et.Float,viewId:this.viewId});_context72.next=8;return this._post({render:l});case 8:case"end":return _context72.stop();}},_callee69,this);}));function removeWork(_x134){return _removeWork4.apply(this,arguments);}return removeWork;}()},{key:"removeNode",value:function removeNode(t){var _this101=this;var r=this.workShapes.has(t);var n;return r&&(this.fullLayer.getElementsByName(t).forEach(function(i){var l=i.getBoundingClientRect();n=bt(n,{x:l.x-At.SafeBorderPadding,y:l.y-At.SafeBorderPadding,w:l.width+At.SafeBorderPadding*2,h:l.height+At.SafeBorderPadding*2}),i.remove(),_pe(i,_this101.fullLayer.parent);}),n&&this.clearWorkShapeNodeCache(t)),n;}},{key:"drawPencil",value:function(){var _drawPencil2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee70(t,r){return _regeneratorRuntime().wrap(function _callee70$(_context73){while(1)switch(_context73.prev=_context73.next){case 0:_context73.next=2;return this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:t==null?void 0:t.rect,workId:r,drawCanvas:Et.Float,viewId:this.viewId}],sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context73.stop();}},_callee70,this);}));function drawPencil(_x135,_x136){return _drawPencil2.apply(this,arguments);}return drawPencil;}()},{key:"drawShape",value:function(){var _drawShape2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee71(t){return _regeneratorRuntime().wrap(function _callee71$(_context74){while(1)switch(_context74.prev=_context74.next){case 0:_context74.next=2;return this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:(t==null?void 0:t.rect)&&kt(t.rect),isClear:!0,clearCanvas:Et.Float,viewId:this.viewId},{rect:(t==null?void 0:t.rect)&&kt(t.rect),drawCanvas:Et.Float,viewId:this.viewId}]});case 2:case"end":return _context74.stop();}},_callee71,this);}));function drawShape(_x137){return _drawShape2.apply(this,arguments);}return drawShape;}()},{key:"drawSelector",value:function(){var _drawSelector2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee72(t){return _regeneratorRuntime().wrap(function _callee72$(_context75){while(1)switch(_context75.prev=_context75.next){case 0:_context75.next=2;return this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:(t==null?void 0:t.rect)&&kt(t.rect),isClear:!0,clearCanvas:Et.Float,viewId:this.viewId},{rect:(t==null?void 0:t.rect)&&kt(t.rect),drawCanvas:Et.Float,viewId:this.viewId}]});case 2:case"end":return _context75.stop();}},_callee72,this);}));function drawSelector(_x138){return _drawSelector2.apply(this,arguments);}return drawSelector;}()}]);}(hs);var ay=/*#__PURE__*/function(){function ay(e){_classCallCheck(this,ay);ot(this,"viewId");ot(this,"vNodes");ot(this,"topLayer");ot(this,"thread");ot(this,"post");ot(this,"serviceWorkShapes",/* @__PURE__ */new Map());ot(this,"localWorkShapes",/* @__PURE__ */new Map());ot(this,"tmpOpt");ot(this,"syncUnitTime",me.syncOpt.interval);ot(this,"animationId");this.viewId=e.viewId,this.vNodes=e.vNodes,this.topLayer=e.topLayer,this.thread=e.thread,this.post=e.thread.post.bind(e.thread);}return _createClass(ay,[{key:"canUseTopLayer",value:function canUseTopLayer(e){return e===pt.LaserPen;}},{key:"getWorkShape",value:function getWorkShape(e){return this.localWorkShapes.get(e);}},{key:"createWorkShape",value:function createWorkShape(e,t){if(e&&this.tmpOpt){var r={toolsType:this.tmpOpt.toolsType,toolsOpt:t||this.tmpOpt.toolsOpt},n=this.createWorkShapeNode(_objectSpread(_objectSpread({},r),{},{workId:e}));return n&&this.localWorkShapes.set(e,{node:n,toolsType:n.toolsType,workState:Ft.Start}),n;}}},{key:"setWorkOptions",value:function setWorkOptions(e,t){var n;var r=(n=this.localWorkShapes.get(e))==null?void 0:n.node;r||this.createWorkShape(e,t),r==null||r.setWorkOptions(t);}},{key:"createWorkShapeNode",value:function createWorkShapeNode(e){var t=e.toolsType;if(t===pt.LaserPen)return Ur(_objectSpread(_objectSpread({},e),{},{vNodes:this.vNodes,fullLayer:this.topLayer,drawLayer:this.topLayer}));}},{key:"clearAllWorkShapesCache",value:function clearAllWorkShapesCache(){this.localWorkShapes.forEach(function(e){var t;return(t=e.node)==null?void 0:t.clearTmpPoints();}),this.localWorkShapes.clear();}},{key:"setToolsOpt",value:function setToolsOpt(e){var t;this.tmpOpt=e,(t=e.toolsOpt)!=null&&t.syncUnitTime&&(this.syncUnitTime=e.toolsOpt.syncUnitTime);}},{key:"getToolsOpt",value:function getToolsOpt(){return this.tmpOpt;}},{key:"consumeDraw",value:function consumeDraw(e){var t=e.workId,r=e.dataType;if(r===Dt.Service)this.activeServiceWorkShape(e);else{var n=t==null?void 0:t.toString(),i=n&&this.localWorkShapes.get(n);if(!i)return;var l=i.node.consume({data:e,isFullWork:!1,isSubWorker:!0});l.rect&&(i.totalRect=bt(l.rect,i.totalRect),i.result=l,i.workState=Ft.Doing,n&&this.localWorkShapes.set(n,i));}this.runAnimation();}},{key:"consumeDrawAll",value:function consumeDrawAll(e){var t=e.workId,r=e.dataType;if(r===Dt.Service)this.activeServiceWorkShape(e);else{var n=t==null?void 0:t.toString(),i=n&&this.localWorkShapes.get(n);if(!i)return;var l=i.node.consumeAll({data:e});i.totalRect=bt(l.rect,i.totalRect),i.result=l,i.workState=Ft.Done,n&&this.localWorkShapes.set(n,i);}this.runAnimation();}},{key:"destroy",value:function destroy(){this.serviceWorkShapes.clear(),this.localWorkShapes.clear();}},{key:"setNodeKey",value:function setNodeKey(e,t,r,n){return t.toolsType=r,t.node=this.createWorkShapeNode({workId:e,toolsType:r,toolsOpt:n}),t;}},{key:"activeServiceWorkShape",value:function activeServiceWorkShape(e){var v,S;var t=e.workId,r=e.opt,n=e.toolsType,i=e.type,l=e.updateNodeOpt,o=e.ops,a=e.op;if(!t)return;var c=t.toString(),m=(v=this.vNodes.get(c))==null?void 0:v.rect;if(!((S=this.serviceWorkShapes)!=null&&S.has(c))){var E={toolsType:n,animationWorkData:a||[],animationIndex:0,type:i,updateNodeOpt:l,ops:o,oldRect:m};n&&r&&(E=this.setNodeKey(c,E,n,r)),this.serviceWorkShapes.set(c,E);}var f=this.serviceWorkShapes.get(c);i&&(f.type=i),o&&(f.animationWorkData=Qe(o),f.ops=o),l&&(f.updateNodeOpt=l),a&&(f.animationWorkData=a),f.node&&f.node.getWorkId()!==c&&f.node.setWorkId(c),m&&(f.oldRect=m),n&&r&&(f.toolsType!==n&&n&&r&&this.setNodeKey(c,f,n,r),f.node&&f.node.setWorkOptions(r));}},{key:"computNextAnimationIndex",value:function computNextAnimationIndex(e,t){var r=Math.floor((e.animationWorkData||[]).slice(e.animationIndex).length*32/t/this.syncUnitTime)*t;return Math.min((e.animationIndex||0)+(r||t),(e.animationWorkData||[]).length);}},{key:"animationDraw",value:function(){var _animationDraw2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee73(){var _this102=this;var l,o,a,c,e,t,r,n,i,_iterator67,_step67,_step67$value,m,f,S,E,T,P,_iterator68,_step68,_step68$value,_m13,_f7,v,_S10,_E2,_T4,_P22;return _regeneratorRuntime().wrap(function _callee73$(_context76){while(1)switch(_context76.prev=_context76.next){case 0:this.animationId=void 0;e=!1;t=/* @__PURE__ */new Map(),r=[],n=[],i=[];_iterator67=_createForOfIteratorHelper(this.serviceWorkShapes.entries());_context76.prev=4;_iterator67.s();case 6:if((_step67=_iterator67.n()).done){_context76.next=20;break;}_step67$value=_slicedToArray(_step67.value,2),m=_step67$value[0],f=_step67$value[1];_context76.t0=f.toolsType;_context76.next=_context76.t0===pt.LaserPen?11:18;break;case 11:S=this.computNextAnimationIndex(f,8),E=Math.max(0,f.animationIndex||0),T=(f.animationWorkData||[]).slice(E,S);if((f.animationIndex||0)<S){P=(l=f.node)==null?void 0:l.consumeService({op:T,isFullWork:!1});f.totalRect=bt(f.totalRect,P),f.animationIndex=S,T.length&&t.set(m,{workState:E===0?Ft.Start:S===((o=f.animationWorkData)==null?void 0:o.length)?Ft.Done:Ft.Doing,op:T.slice(-2)});}if(!(n.push({isClear:!0,rect:f.totalRect,clearCanvas:Et.TopFloat,viewId:this.viewId}),r.push({rect:f.totalRect,drawCanvas:Et.TopFloat,viewId:this.viewId}),f.isDel)){_context76.next=16;break;}(a=f.node)==null||a.clearTmpPoints(),this.serviceWorkShapes["delete"](m);return _context76.abrupt("break",18);case 16:f.ops&&f.animationIndex===((c=f.animationWorkData)==null?void 0:c.length)&&!f.isDel&&(this.topLayer.getElementsByName(m.toString())[0]||(f.isDel=!0,this.serviceWorkShapes.set(m,f))),e=!0;return _context76.abrupt("break",18);case 18:_context76.next=6;break;case 20:_context76.next=25;break;case 22:_context76.prev=22;_context76.t1=_context76["catch"](4);_iterator67.e(_context76.t1);case 25:_context76.prev=25;_iterator67.f();return _context76.finish(25);case 28:_iterator68=_createForOfIteratorHelper(this.localWorkShapes.entries());_context76.prev=29;_iterator68.s();case 31:if((_step68=_iterator68.n()).done){_context76.next=44;break;}_step68$value=_slicedToArray(_step68.value,2),_m13=_step68$value[0],_f7=_step68$value[1];v=_f7.result,_S10=_f7.toolsType,_E2=_f7.totalRect,_T4=_f7.isDel,_P22=_f7.workState;_context76.t2=_S10;_context76.next=_context76.t2===pt.LaserPen?37:42;break;case 37:if(!(_E2&&(n.push({isClear:!0,rect:_E2,clearCanvas:Et.TopFloat,viewId:this.viewId}),r.push({rect:_E2,drawCanvas:Et.TopFloat,viewId:this.viewId})),_T4)){_context76.next=40;break;}_f7.node.clearTmpPoints(),this.localWorkShapes["delete"](_m13),i.push({removeIds:[_m13.toString()],viewId:this.viewId,type:dt.RemoveNode});return _context76.abrupt("break",42);case 40:v&&((v.op||v.ops)&&i.push(v),_f7.result=void 0),!this.topLayer.getElementsByName(_m13.toString())[0]&&_P22===Ft.Done&&(_f7.isDel=!0,this.localWorkShapes.set(_m13,_f7)),e=!0;return _context76.abrupt("break",42);case 42:_context76.next=31;break;case 44:_context76.next=49;break;case 46:_context76.prev=46;_context76.t3=_context76["catch"](29);_iterator68.e(_context76.t3);case 49:_context76.prev=49;_iterator68.f();return _context76.finish(49);case 52:e&&this.runAnimation(),t.size&&t.forEach(function(m,f){i.push({type:dt.Cursor,uid:f.split(Je)[0],op:m.op,workState:m.workState,viewId:_this102.viewId});}),(r.length||n.length||i.length)&&this.post({render:[].concat(n,r),sp:i});case 53:case"end":return _context76.stop();}},_callee73,this,[[4,22,25,28],[29,46,49,52]]);}));function animationDraw(){return _animationDraw2.apply(this,arguments);}return animationDraw;}()},{key:"runAnimation",value:function runAnimation(){var _this103=this;this.animationId||(this.animationId=setTimeout(function(){_this103.animationId=void 0,_this103.animationDraw();},16));}}]);}();var ly=/*#__PURE__*/function(_ys){function ly(t){var _this104;_classCallCheck(this,ly);_this104=_callSuper(this,ly,[t]);ot(_this104,"_type","simple");return _this104;}_inherits(ly,_ys);return _createClass(ly,[{key:"createWorkShapeNode",value:function createWorkShapeNode(t){var n;var r=t.toolsType;return r===pt.Selector?this.vNodes?new ar(_objectSpread(_objectSpread({},t),{},{fullLayer:this.fullLayer,vNodes:this.vNodes,drawLayer:this.drawLayer})):void 0:Ur(_objectSpread(_objectSpread({},t),{},{vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer}),(n=this.thread)==null?void 0:n.serviceWork);}},{key:"drawPencil",value:function(){var _drawPencil3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee74(t,r){return _regeneratorRuntime().wrap(function _callee74$(_context77){while(1)switch(_context77.prev=_context77.next){case 0:_context77.next=2;return this._post({consumeCount:this.consumeCount,render:[{rect:t==null?void 0:t.rect,workId:r,drawCanvas:Et.Float,viewId:this.viewId}],sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context77.stop();}},_callee74,this);}));function drawPencil(_x139,_x140){return _drawPencil3.apply(this,arguments);}return drawPencil;}()},{key:"drawShape",value:function(){var _drawShape3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee75(t){return _regeneratorRuntime().wrap(function _callee75$(_context78){while(1)switch(_context78.prev=_context78.next){case 0:_context78.next=2;return this._post({consumeCount:this.consumeCount,sp:(t==null?void 0:t.op)&&[t],render:[{rect:(t==null?void 0:t.rect)&&kt(t.rect),isClear:!0,clearCanvas:Et.Float,viewId:this.viewId},{rect:(t==null?void 0:t.rect)&&kt(t.rect),drawCanvas:Et.Float,viewId:this.viewId}]});case 2:case"end":return _context78.stop();}},_callee75,this);}));function drawShape(_x141){return _drawShape3.apply(this,arguments);}return drawShape;}()},{key:"drawSelector",value:function(){var _drawSelector3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee76(t,r){var n,l,o,a,i,_args79=arguments;return _regeneratorRuntime().wrap(function _callee76$(_context79){while(1)switch(_context79.prev=_context79.next){case 0:n=_args79.length>2&&_args79[2]!==undefined?_args79[2]:[];i={render:n,sp:[t],consumeCount:this.consumeCount};r&&((l=i.sp)==null||l.push({type:dt.None,isLockSentEventCursor:r}));t.subRect&&((o=i.render)==null||o.push({rect:kt(t.subRect),isClear:!0,clearCanvas:Et.Float,viewId:this.viewId},{rect:kt(t.subRect),drawCanvas:Et.Float,viewId:this.viewId}));t.rect&&((a=i.render)==null||a.push({rect:kt(t.rect),clearCanvas:Et.Bg,isClear:!0,viewId:this.viewId},{rect:kt(t.rect),drawCanvas:Et.Bg,viewId:this.viewId}));_context79.next=7;return this._post(i);case 7:case"end":return _context79.stop();}},_callee76,this);}));function drawSelector(_x142,_x143){return _drawSelector3.apply(this,arguments);}return drawSelector;}()},{key:"drawEraserCombine",value:function(){var _drawEraserCombine2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee77(t){var n,i,l,o,r,a,c,m,f,_iterator69,_step69,_step69$value,_f8,v;return _regeneratorRuntime().wrap(function _callee77$(_context80){while(1)switch(_context80.prev=_context80.next){case 0:r=(n=this.workShapes.get(t))==null?void 0:n.combineConsume({workerEngine:this});if(!r){_context80.next=7;break;}a=r.willDeleteNodes,c=r.willNewNodes,m={render:[],sp:[]};if(r!=null&&r.rect){f=kt(r.rect);(i=m.render)==null||i.push({rect:f,isClear:!0,clearCanvas:Et.Bg,viewId:this.viewId},{rect:f,drawCanvas:Et.Bg,viewId:this.viewId});}if(a!=null&&a.size&&((l=m.sp)==null||l.push({type:dt.RemoveNode,removeIds:_toConsumableArray(a),viewId:this.thread.viewId})),c!=null&&c.size){_iterator69=_createForOfIteratorHelper(c);try{for(_iterator69.s();!(_step69=_iterator69.n()).done;){_step69$value=_slicedToArray(_step69.value,2),_f8=_step69$value[0],v=_step69$value[1];(o=m.sp)==null||o.push({type:dt.FullWork,dataType:Dt.Local,toolsType:pt.Pencil,ops:ve(v.op),opt:v.opt,workId:_f8,updateNodeOpt:{useAnimation:!1}});}}catch(err){_iterator69.e(err);}finally{_iterator69.f();}}_context80.next=7;return this._post(m);case 7:case"end":return _context80.stop();}},_callee77,this);}));function drawEraserCombine(_x144){return _drawEraserCombine2.apply(this,arguments);}return drawEraserCombine;}()},{key:"consumeDraw",value:function(){var _consumeDraw4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee78(t,r){var _this105=this;var n,i,l,o,a,c,m,f,v;return _regeneratorRuntime().wrap(function _callee78$(_context81){while(1)switch(_context81.prev=_context81.next){case 0:n=t.op,i=t.workId,l=t.scenePath,o=t.postCount,a=t.smoothSync;if(!(n!=null&&n.length&&i)){_context81.next=42;break;}c=i.toString(),m=this.getWorkShape(c);if(m){_context81.next=5;break;}return _context81.abrupt("return");case 5:f=m.toolsType;if(!(f===pt.LaserPen)){_context81.next=8;break;}return _context81.abrupt("return");case 8:_context81.t0=this.drawWorkActiveId&&this.drawWorkActiveId!==c;if(!_context81.t0){_context81.next=13;break;}_context81.next=12;return this.consumeDrawAll({workId:this.drawWorkActiveId,scenePath:l,viewId:this.viewId,msgType:dt.DrawWork,dataType:Dt.Local},r);case 12:this.drawWorkActiveId=void 0;case 13:!this.drawWorkActiveId&&c!==qt&&(this.drawWorkActiveId=c);he(o)&&(this.consumeCount=o);v=m.consume({data:t,isSimpleWorker:!0,smoothSync:a});_context81.t1=f;_context81.next=_context81.t1===pt.Selector?19:_context81.t1===pt.PencilEraser?24:_context81.t1===pt.BitMapEraser?24:_context81.t1===pt.Eraser?29:_context81.t1===pt.Arrow?32:_context81.t1===pt.Straight?32:_context81.t1===pt.Ellipse?32:_context81.t1===pt.Rectangle?32:_context81.t1===pt.Star?32:_context81.t1===pt.Polygon?32:_context81.t1===pt.SpeechBalloon?32:_context81.t1===pt.Pencil?38:42;break;case 19:this.drawCount++;v.type===dt.Select&&v.selectIds&&r.runReverseSelectWork(v.selectIds);_context81.next=23;return this.drawSelector(v);case 23:return _context81.abrupt("break",42);case 24:this.drawCount++;this.combineTimerId||(this.combineTimerId=1,this.combineDrawActiveId=c,this.drawEraserCombine(c).then(function(){_this105.combineTimerId=void 0;}));_context81.next=28;return this._post({consumeCount:this.consumeCount});case 28:return _context81.abrupt("break",42);case 29:_context81.next=31;return this.drawEraser(v);case 31:return _context81.abrupt("break",42);case 32:_context81.t2=v;if(!_context81.t2){_context81.next=37;break;}this.drawCount++;_context81.next=37;return this.drawShape(v);case 37:return _context81.abrupt("break",42);case 38:this.drawCount++;_context81.next=41;return this.drawPencil(v,c);case 41:return _context81.abrupt("break",42);case 42:case"end":return _context81.stop();}},_callee78,this);}));function consumeDraw(_x145,_x146){return _consumeDraw4.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee79(t,r){var o,a,c,n,i,l,m,f,v,S,E,T,P;return _regeneratorRuntime().wrap(function _callee79$(_context82){while(1)switch(_context82.prev=_context82.next){case 0:this.combineTimerId&&(clearTimeout(this.combineTimerId),this.combineTimerId=void 0,this.combineDrawResolve&&this.combineDrawResolve(!1),this.combineDrawActiveId=void 0);n=t.workId,i=t.scenePath,l=t.isLockSentEventCursor;if(!n){_context82.next=40;break;}m=n.toString();this.drawWorkActiveId===m&&(this.drawWorkActiveId=void 0);f=this.workShapes.get(m);if(f){_context82.next=8;break;}return _context82.abrupt("return");case 8:v=f.toolsType;if(!(v===pt.LaserPen)){_context82.next=11;break;}return _context82.abrupt("return");case 11:S=this.workShapes.get(He),E=(o=S==null?void 0:S.selectIds)==null?void 0:o[0],T=f.consumeAll({data:t,workerEngine:this});_context82.t0=v;_context82.next=_context82.t0===pt.Selector?15:_context82.t0===pt.PencilEraser?23:_context82.t0===pt.BitMapEraser?23:_context82.t0===pt.Eraser?28:_context82.t0===pt.Arrow?30:_context82.t0===pt.Straight?30:_context82.t0===pt.Ellipse?30:_context82.t0===pt.Rectangle?30:_context82.t0===pt.Star?30:_context82.t0===pt.Polygon?30:_context82.t0===pt.SpeechBalloon?30:_context82.t0===pt.Pencil?35:40;break;case 15:P=[];this.drawLayer&&(this.drawCount=0,Se(this.drawLayer,this.drawLayer.parent),this.getWorkShape(m).clearSubTmpPoints(),P.push({isClearAll:!0,clearCanvas:Et.Float,viewId:this.viewId}));T.selectIds&&E&&(a=T.selectIds)!=null&&a.includes(E)&&S.cursorBlur();T.selectIds&&r.runReverseSelectWork(T.selectIds);_context82.next=21;return this.drawSelector(_objectSpread(_objectSpread({},T),{},{scenePath:i}),l,P);case 21:(c=f.selectIds)!=null&&c.length?f.clearTmpPoints():this.clearWorkShapeNodeCache(m);return _context82.abrupt("break",40);case 23:_context82.next=25;return this.drawEraserFull(f,_objectSpread(_objectSpread({},T),{},{scenePath:i}),l);case 25:this.drawCount=0;this.clearWorkShapeNodeCache(m);return _context82.abrupt("break",40);case 28:this.drawEraser(_objectSpread(_objectSpread({},T),{},{scenePath:i}),l),f.clearTmpPoints();return _context82.abrupt("break",40);case 30:_context82.next=32;return this.drawPencilFull(_objectSpread(_objectSpread({},T),{},{scenePath:i}),l);case 32:this.drawCount=0;this.clearWorkShapeNodeCache(m);return _context82.abrupt("break",40);case 35:_context82.next=37;return this.drawPencilFull(_objectSpread(_objectSpread({},T),{},{scenePath:i}),l);case 37:this.drawCount=0;this.clearWorkShapeNodeCache(m);return _context82.abrupt("break",40);case 40:case"end":return _context82.stop();}},_callee79,this);}));function consumeDrawAll(_x147,_x148){return _consumeDrawAll3.apply(this,arguments);}return consumeDrawAll;}()}]);}(ys);var cy=/*#__PURE__*/function(_gs){function cy(t){var _this106;_classCallCheck(this,cy);_this106=_callSuper(this,cy,[t]);ot(_this106,"_type","simple");return _this106;}_inherits(cy,_gs);return _createClass(cy,[{key:"animationDraw",value:function(){var _animationDraw3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee80(){var _this107=this;var i,l,o,a,c,m,f,v,S,E,T,P,x,h,p,d,g,O,w,L,B,A,b,W,D,R,X,H,J,et,it,$,V,rt,lt,ct,gt,st,Ct,xt,t,r,n,_iterator70,_step70,_loop7;return _regeneratorRuntime().wrap(function _callee80$(_context84){while(1)switch(_context84.prev=_context84.next){case 0:this.animationId=void 0;t=!1;r={render:[]},n=/* @__PURE__ */new Map();_iterator70=_createForOfIteratorHelper(this.workShapes.entries());_context84.prev=4;_loop7=/*#__PURE__*/_regeneratorRuntime().mark(function _loop7(){var _step70$value,F,U,K,q,_K5,_q3,_K6,_q4,Y,k,_K7,_q5,_Y4,_k3,C,M,j,_M,_K8,_q6,_Y5,_k4;return _regeneratorRuntime().wrap(function _loop7$(_context83){while(1)switch(_context83.prev=_context83.next){case 0:_step70$value=_slicedToArray(_step70.value,2),F=_step70$value[0],U=_step70$value[1];_context83.t0=U.toolsType;_context83.next=_context83.t0===pt.Image?4:_context83.t0===pt.Text?11:_context83.t0===pt.Arrow?19:_context83.t0===pt.Straight?19:_context83.t0===pt.Rectangle?19:_context83.t0===pt.Ellipse?19:_context83.t0===pt.Star?19:_context83.t0===pt.Polygon?19:_context83.t0===pt.SpeechBalloon?19:_context83.t0===pt.Pencil?22:38;break;case 4:K=U.oldRect;K&&((i=r.render)==null||i.push({rect:K,isClear:!0,clearCanvas:Et.Bg,viewId:_this107.viewId}),(l=r.render)==null||l.push({rect:K,drawCanvas:Et.Bg,viewId:_this107.viewId}));_context83.next=8;return(o=U.node)==null?void 0:o.consumeServiceAsync({isFullWork:!0,worker:_this107.thread});case 8:q=_context83.sent;_this107.selectorWorkShapes.forEach(function(Y,k){var C;(C=Y.selectIds)!=null&&C.includes(F)&&(_this107.willRunEffectSelectorIds.add(k),_this107.noAnimationRect=bt(_this107.noAnimationRect,K),_this107.noAnimationRect=bt(_this107.noAnimationRect,q),_this107.runEffect());}),_this107.workShapes["delete"](F),(a=r.render)==null||a.push({rect:q,drawCanvas:Et.Bg,viewId:_this107.viewId});return _context83.abrupt("break",38);case 11:if(!U.node){_context83.next=18;break;}_K5=U.oldRect;_K5&&((c=r.render)==null||c.push({rect:_K5,isClear:!0,clearCanvas:Et.Bg,viewId:_this107.viewId}),(m=r.render)==null||m.push({rect:_K5,drawCanvas:Et.Bg,viewId:_this107.viewId}));_context83.next=16;return U.node.consumeServiceAsync({isFullWork:!0,replaceId:F});case 16:_q3=_context83.sent;_this107.selectorWorkShapes.forEach(function(Y,k){var C;(C=Y.selectIds)!=null&&C.includes(F)&&(_this107.willRunEffectSelectorIds.add(k),_this107.noAnimationRect=bt(_this107.noAnimationRect,_K5),_this107.noAnimationRect=bt(_this107.noAnimationRect,_q3),_this107.runEffect());}),(f=U.node)==null||f.clearTmpPoints(),_this107.workShapes["delete"](F),(v=r.render)==null||v.push({rect:_q3,drawCanvas:Et.Bg,viewId:_this107.viewId});case 18:return _context83.abrupt("break",38);case 19:_K6=!!U.ops;if((S=U.animationWorkData)!=null&&S.length){_q4=U.oldRect,Y=U.node.oldRect;_q4&&((E=r.render)==null||E.push({rect:_q4,isClear:!0,clearCanvas:Et.Bg,viewId:_this107.viewId}),(T=r.render)==null||T.push({rect:_q4,drawCanvas:Et.Bg,viewId:_this107.viewId})),Y&&((P=r.render)==null||P.push({rect:Y,isClear:!0,clearCanvas:Et.ServiceFloat,viewId:_this107.viewId}));k=(x=U.node)==null?void 0:x.consumeService({op:U.animationWorkData,isFullWork:_K6});U.isEnableCursor?n.set(F,{workState:_q4?U.ops?Ft.Done:Ft.Doing:Ft.Start,op:U.animationWorkData.slice(-3,-1)}):_K6&&!U.useAnimation&&(h=U.updateNodeOpt)!=null&&h.useAnimation&&n.set(F,{workState:Ft.Done,op:U.animationWorkData.slice(-3,-1),uid:(p=U.updateNodeOpt)==null?void 0:p.uid}),_K6?(_this107.selectorWorkShapes.forEach(function(C,M){var j;(j=C.selectIds)!=null&&j.includes(F)&&(_this107.willRunEffectSelectorIds.add(M),_this107.noAnimationRect=bt(_this107.noAnimationRect,_q4),_this107.noAnimationRect=bt(_this107.noAnimationRect,Y),_this107.noAnimationRect=bt(_this107.noAnimationRect,k),_this107.runEffect());}),(d=U.node)==null||d.clearTmpPoints(),_this107.workShapes["delete"](F),(g=r.render)==null||g.push({rect:k,drawCanvas:Et.Bg,viewId:_this107.viewId})):(O=r.render)==null||O.push({rect:k,drawCanvas:Et.ServiceFloat,workerType:_K6?void 0:Dt.Service,viewId:_this107.viewId}),U.animationWorkData.length=0;}return _context83.abrupt("break",38);case 22:if(!U.useAnimation){_context83.next=33;break;}if(!U.useAnimation){_context83.next=31;break;}if(!U.isDel){_context83.next=27;break;}(it=U.node)==null||it.clearTmpPoints(),_this107.workShapes["delete"](F);return _context83.abrupt("break",38);case 27:_K7=3,_q5=_this107.computNextAnimationIndex(U,_K7),_Y4=U.isDiff?0:Math.max(0,(U.animationIndex||0)-_K7),_k3=(U.animationWorkData||[]).slice(0,_q5),C=(V=($=U.node)==null?void 0:$.getWorkId())==null?void 0:V.toString();if((U.animationIndex||0)<_q5||U.isDiff){M=(rt=U.node)==null?void 0:rt.consumeService({op:_k3,isFullWork:!1,replaceId:C});if((lt=r.render)==null||lt.push({isClear:!0,rect:M,clearCanvas:Et.ServiceFloat,viewId:_this107.viewId}),(ct=r.render)==null||ct.push({rect:M,drawCanvas:Et.ServiceFloat,viewId:_this107.viewId}),U.animationIndex=_q5,U.isDiff&&(U.isDiff=!1),_k3.length&&U.isEnableCursor){j=_k3.slice(-3,-1);n.set(F,{workState:_Y4===0?Ft.Start:_q5===((gt=U.animationWorkData)==null?void 0:gt.length)?Ft.Done:Ft.Doing,op:j});}}else if(U.ops){_M=(st=U.node)==null?void 0:st.consumeService({op:U.animationWorkData||[],isFullWork:!0,replaceId:C});U.isDel=!0,(Ct=r.render)==null||Ct.push({isClear:!0,rect:_M,clearCanvas:Et.ServiceFloat,viewId:_this107.viewId},{rect:_M,drawCanvas:Et.ServiceFloat,viewId:_this107.viewId},{isClear:!0,rect:_M,clearCanvas:Et.Bg,viewId:_this107.viewId},{rect:_M,drawCanvas:Et.Bg,viewId:_this107.viewId}),U.isEnableCursor&&n.set(F,{workState:Ft.Done,op:_k3.slice(-3,-1)});}t=!0;return _context83.abrupt("break",38);case 31:_context83.next=37;break;case 33:_K8=!!U.ops;_q6=(w=U.node)==null?void 0:w.consumeService({op:U.animationWorkData||[],isFullWork:_K8,replaceId:F});_Y5=(L=U.node)==null?void 0:L.updataOptService(U.updateNodeOpt);if(_K8){if(_q6=bt(_q6,_Y5),(B=r.render)==null||B.push({isClear:!0,rect:bt(U.oldRect,_q6),clearCanvas:Et.Bg,viewId:_this107.viewId}),(A=r.render)==null||A.push({rect:bt(U.oldRect,_q6),drawCanvas:Et.Bg,viewId:_this107.viewId}),(b=U.updateNodeOpt)!=null&&b.useAnimation&&((W=r.render)==null||W.push({isClear:!0,rect:bt(U.oldRect,_q6),clearCanvas:Et.ServiceFloat,viewId:_this107.viewId}),(D=r.render)==null||D.push({rect:bt(U.oldRect,_q6),drawCanvas:Et.ServiceFloat,viewId:_this107.viewId}),!U.isEnableCursor&&(R=U.animationWorkData)!=null&&R.length)){_k4=U.animationWorkData.slice(-3,-1);n.set(F,{workState:Ft.Done,op:_k4,uid:(X=U.updateNodeOpt)==null?void 0:X.uid});}_this107.selectorWorkShapes.forEach(function(k,C){var M;(M=k.selectIds)!=null&&M.includes(F)&&(_this107.willRunEffectSelectorIds.add(C),_this107.noAnimationRect=bt(_this107.noAnimationRect,_q6),_this107.runEffect());}),(H=U.node)==null||H.clearTmpPoints(),_this107.workShapes["delete"](F);}else _q6=bt(_q6,_Y5),(J=r.render)==null||J.push({isClear:!0,rect:bt(U.oldRect,_q6),clearCanvas:Et.ServiceFloat,viewId:_this107.viewId}),(et=r.render)==null||et.push({rect:bt(U.oldRect,_q6),drawCanvas:Et.ServiceFloat,viewId:_this107.viewId});case 37:return _context83.abrupt("break",38);case 38:case"end":return _context83.stop();}},_loop7);});_iterator70.s();case 7:if((_step70=_iterator70.n()).done){_context84.next=11;break;}return _context84.delegateYield(_loop7(),"t0",9);case 9:_context84.next=7;break;case 11:_context84.next=16;break;case 13:_context84.prev=13;_context84.t1=_context84["catch"](4);_iterator70.e(_context84.t1);case 16:_context84.prev=16;_iterator70.f();return _context84.finish(16);case 19:t&&this.runAnimation();n.size&&(r.sp=[],n.forEach(function(F,U){var K;(K=r.sp)==null||K.push({type:dt.Cursor,uid:F.uid||U.split(Je)[0],op:F.op,workState:F.workState,viewId:_this107.viewId});}));_context84.t2=(xt=r.render)!=null&&xt.length;if(!_context84.t2){_context84.next=25;break;}_context84.next=25;return this.post(r);case 25:case"end":return _context84.stop();}},_callee80,this,[[4,13,16,19]]);}));function animationDraw(){return _animationDraw3.apply(this,arguments);}return animationDraw;}()}]);}(gs);var wr=/* @__PURE__ */function(u){return u.Full="full",u.Sub="sub",u;}(wr||{});var fy=/*#__PURE__*/function(){function fy(e,t){var _this108=this;_classCallCheck(this,fy);ot(this,"_self");ot(this,"version",$i);ot(this,"type");// protected hasPriorityDraw: boolean = true;
472
472
  ot(this,"workThreadMap",/* @__PURE__ */new Map());ot(this,"post",function(e,t){t?_this108._self.postMessage(e,t):_this108._self.postMessage(e);});this._self=e,this.type=t,this.register();}return _createClass(fy,[{key:"init",value:function init(e){var t=e.viewId,r=e.dpr,n=e.offscreenCanvasOpt,i=e.layerOpt,l=e.isSafari,o=e.combineUnitTime,a=e.syncUnitTime,c=e.maxCombineEraserTime,m=e.offscreenCanvas,f=e.isUseSimple;if(!r||!n||!i)return;var v;this.type==="full"&&(f?v=new hy(t,{dpr:r,offscreenCanvasOpt:n,layerOpt:i,combineUnitTime:o,syncUnitTime:a,maxCombineEraserTime:c,offscreenCanvas:m},this.post):v=new Ss(t,{dpr:r,offscreenCanvasOpt:n,layerOpt:i,combineUnitTime:o,syncUnitTime:a,maxCombineEraserTime:c},this.post)),this.type==="sub"&&!f&&(v=new Ps(t,{dpr:r,offscreenCanvasOpt:n,layerOpt:i,isUseSimple:f},this.post)),v&&l&&v.setIsSafari(l),v&&e.cameraOpt&&v.setCameraOpt(e.cameraOpt),v&&this.workThreadMap.set(t,v);}},{key:"setFontFaces",value:function(){var _setFontFaces=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee81(e){var _this109=this;var t,r,_iterator71,_step71,_loop8;return _regeneratorRuntime().wrap(function _callee81$(_context86){while(1)switch(_context86.prev=_context86.next){case 0:t=[],r=[];_iterator71=_createForOfIteratorHelper(e);_context86.prev=2;_loop8=/*#__PURE__*/_regeneratorRuntime().mark(function _loop8(){var n,i,l,o,a,c,m,f,v;return _regeneratorRuntime().wrap(function _loop8$(_context85){while(1)switch(_context85.prev=_context85.next){case 0:n=_step71.value;i=n.fontFamily,l=n.buffer;_context85.prev=2;if(!(!l||l.byteLength===0)){_context85.next=5;break;}throw new Error("Invalid font data for ".concat(i,": empty buffer"));case 5:try{o=new FontFace(i,l);}catch(_unused24){a=new Uint8Array(l);o=new FontFace(i,a);}_context85.next=8;return _this109._self.fonts.add(o);case 8:_context85.prev=8;_context85.next=11;return o.loaded;case 11:t.push(i);_context85.next=49;break;case 14:_context85.prev=14;_context85.t0=_context85["catch"](8);c=_this109._self.fonts;if(!(c&&typeof c.load=="function")){_context85.next=42;break;}_context85.prev=18;m=c.load(i);f=new Promise(function(S,E){return setTimeout(function(){return E(new Error("Font load timeout for ".concat(i)));},5e3);});_context85.next=23;return Promise.race([m,f]);case 23:v=_context85.sent;if(!(v&&v.length>0)){_context85.next=28;break;}t.push(i);_context85.next=29;break;case 28:throw new Error("Font ".concat(i," load returned empty result"));case 29:_context85.next=40;break;case 31:_context85.prev=31;_context85.t1=_context85["catch"](18);_context85.next=35;return _this109.isFontAvailable(i);case 35:if(!_context85.sent){_context85.next=39;break;}t.push(i);_context85.next=40;break;case 39:throw _context85.t1;case 40:_context85.next=49;break;case 42:_context85.next=44;return _this109.isFontAvailable(i);case 44:if(!_context85.sent){_context85.next=48;break;}t.push(i);_context85.next=49;break;case 48:throw _context85.t0;case 49:_context85.next=54;break;case 51:_context85.prev=51;_context85.t2=_context85["catch"](2);console.error("Font ".concat(i," load error: ").concat(_context85.t2)),r.push(i);case 54:case"end":return _context85.stop();}},_loop8,null,[[2,51],[8,14],[18,31]]);});_iterator71.s();case 5:if((_step71=_iterator71.n()).done){_context86.next=9;break;}return _context86.delegateYield(_loop8(),"t0",7);case 7:_context86.next=5;break;case 9:_context86.next=14;break;case 11:_context86.prev=11;_context86.t1=_context86["catch"](2);_iterator71.e(_context86.t1);case 14:_context86.prev=14;_iterator71.f();return _context86.finish(14);case 17:this.post({sp:[{type:dt.SetFontFace,setFontFaceResult:!0,failedFonts:r.length>0?r:void 0}]});case 18:case"end":return _context86.stop();}},_callee81,this,[[2,11,14,17]]);}));function setFontFaces(_x149){return _setFontFaces.apply(this,arguments);}return setFontFaces;}()// 检查字体是否可用
473
- },{key:"isFontAvailable",value:function(){var _isFontAvailable=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee82(e){var t,r,n,_iterator72,_step72,_i7,i;return _regeneratorRuntime().wrap(function _callee82$(_context87){while(1)switch(_context87.prev=_context87.next){case 0:_context87.prev=0;t=this._self.fonts;if(t){_context87.next=4;break;}return _context87.abrupt("return",!1);case 4:r=!1,n=null;_iterator72=_createForOfIteratorHelper(t);_context87.prev=6;_iterator72.s();case 8:if((_step72=_iterator72.n()).done){_context87.next=15;break;}_i7=_step72.value;if(!(_i7.family===e)){_context87.next=13;break;}r=!0,n=_i7;return _context87.abrupt("break",15);case 13:_context87.next=8;break;case 15:_context87.next=20;break;case 17:_context87.prev=17;_context87.t0=_context87["catch"](6);_iterator72.e(_context87.t0);case 20:_context87.prev=20;_iterator72.f();return _context87.finish(20);case 23:if(!(!r||!n)){_context87.next=25;break;}return _context87.abrupt("return",!1);case 25:if(!(n.status==="loaded")){_context87.next=27;break;}return _context87.abrupt("return",!0);case 27:_context87.prev=27;_context87.next=30;return n.loaded;case 30:return _context87.abrupt("return",!0);case 33:_context87.prev=33;_context87.t1=_context87["catch"](27);if(!(t&&typeof t.load=="function")){_context87.next=48;break;}_context87.prev=36;_context87.next=39;return t.load(e);case 39:i=_context87.sent;return _context87.abrupt("return",i&&i.length>0);case 43:_context87.prev=43;_context87.t2=_context87["catch"](36);return _context87.abrupt("return",!1);case 46:_context87.next=49;break;case 48:return _context87.abrupt("return",!0);case 49:_context87.next=54;break;case 51:_context87.prev=51;_context87.t3=_context87["catch"](0);return _context87.abrupt("return",!1);case 54:case"end":return _context87.stop();}},_callee82,this,[[0,51],[6,17,20,23],[27,33],[36,43]]);}));function isFontAvailable(_x150){return _isFontAvailable.apply(this,arguments);}return isFontAvailable;}()},{key:"register",value:function register(){var _this110=this;onmessage=/*#__PURE__*/function(){var _ref171=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee83(e){var t,_iteratorAbruptCompletion,_didIteratorError,_iteratorError,_iterator,_step,r,n,i,l,o,a,_iterator73,_step73,_step73$value,m,f,v,_iterator74,_step74,_m14,c;return _regeneratorRuntime().wrap(function _callee83$(_context88){while(1)switch(_context88.prev=_context88.next){case 0:t=e.data;if(!t){_context88.next=54;break;}_iteratorAbruptCompletion=false;_didIteratorError=false;_context88.prev=4;_iterator=_asyncIterator(t.values());case 6:_context88.next=8;return _iterator.next();case 8:if(!(_iteratorAbruptCompletion=!(_step=_context88.sent).done)){_context88.next=38;break;}r=_step.value;n=r.msgType,i=r.viewId,l=r.tasksqueue,o=r.mainTasksqueueCount,a=r.fontBuffers;if(!a){_context88.next=14;break;}_this110.setFontFaces(a);return _context88.abrupt("continue",35);case 14:if(!(n===dt.Console)){_context88.next=17;break;}console.log(_this110);return _context88.abrupt("continue",35);case 17:if(!(n===dt.Init)){_context88.next=20;break;}_this110.init(r);return _context88.abrupt("continue",35);case 20:if(!(n===dt.TasksQueue&&l!=null&&l.size)){_context88.next=25;break;}_iterator73=_createForOfIteratorHelper(_this110.workThreadMap.entries());try{for(_iterator73.s();!(_step73=_iterator73.n()).done;){_step73$value=_slicedToArray(_step73.value,2),m=_step73$value[0],f=_step73$value[1];v=l.get(m);v&&f.on(v);}}catch(err){_iterator73.e(err);}finally{_iterator73.f();}_this110.type==="full"&&ue(o)&&_this110.post({workerTasksqueueCount:o});return _context88.abrupt("continue",35);case 25:if(!(i===ao)){_context88.next=29;break;}_iterator74=_createForOfIteratorHelper(_this110.workThreadMap.values());try{for(_iterator74.s();!(_step74=_iterator74.n()).done;){_m14=_step74.value;_m14.on(r),n===dt.Destroy&&_this110.workThreadMap["delete"](i);}}catch(err){_iterator74.e(err);}finally{_iterator74.f();}return _context88.abrupt("continue",35);case 29:c=_this110.workThreadMap.get(i);_context88.t0=c;if(!_context88.t0){_context88.next=35;break;}_context88.next=34;return c.on(r);case 34:n===dt.Destroy&&_this110.workThreadMap["delete"](i);case 35:_iteratorAbruptCompletion=false;_context88.next=6;break;case 38:_context88.next=44;break;case 40:_context88.prev=40;_context88.t1=_context88["catch"](4);_didIteratorError=true;_iteratorError=_context88.t1;case 44:_context88.prev=44;_context88.prev=45;if(!(_iteratorAbruptCompletion&&_iterator["return"]!=null)){_context88.next=49;break;}_context88.next=49;return _iterator["return"]();case 49:_context88.prev=49;if(!_didIteratorError){_context88.next=52;break;}throw _iteratorError;case 52:return _context88.finish(49);case 53:return _context88.finish(44);case 54:case"end":return _context88.stop();}},_callee83,null,[[4,40,44,54],[45,,49,53]]);}));return function onmessage(_x151){return _ref171.apply(this,arguments);};}();}}]);}();var Ps=/*#__PURE__*/function(_fs){function Ps(t,r,n){var _this111;_classCallCheck(this,Ps);_this111=_callSuper(this,Ps,[t,r,"sub"/* Sub */]);ot(_this111,"type","sub");ot(_this111,"_post");ot(_this111,"topLayer");ot(_this111,"snapshotFullLayer");ot(_this111,"serviceWork");ot(_this111,"localWork");ot(_this111,"topLayerWork");ot(_this111,"snapshotWork");_this111._post=n;var i=me.bufferSize.sub;_this111.topLayer=r.isUseSimple?void 0:_this111.createLayer("topLayer",_this111.scene,_objectSpread(_objectSpread({},r.layerOpt),{},{bufferSize:i,contextType:"2d"}));var l={thread:_this111,viewId:_this111.viewId,vNodes:_this111.vNodes,fullLayer:_this111.fullLayer,topLayer:_this111.topLayer,isUseSimple:r.isUseSimple};_this111.localWork=new oy(l),r.isUseSimple||(_this111.topLayerWork=new ay(l)),_this111.vNodes.init(_this111.fullLayer),_this111.snapshotWork=new us({post:n,fullLayer:_this111.fullLayer,localWork:_this111.localWork,thread:_this111,viewId:t,getDpr:function getDpr(){return _this111.dpr;},getCameraOpt:function getCameraOpt(){return _this111.cameraOpt;},getOffscreen:_this111.getOffscreen,setCameraOpt:_this111.setCameraOpt,getSceneRect:_this111.getSceneRect,createLayer:_this111.createLayer});return _this111;}_inherits(Ps,_fs);return _createClass(Ps,[{key:"combinePost",value:function(){var _combinePost=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee84(){var _this112=this;var l,o,_this$combinePostData,t,r,n,a,_iterator75,_step75,c,m,i;return _regeneratorRuntime().wrap(function _callee84$(_context89){while(1)switch(_context89.prev=_context89.next){case 0:_this$combinePostData=this.combinePostData(),t=_this$combinePostData.render,r=_objectWithoutProperties(_this$combinePostData,_excluded3);if(!(t!=null&&t.length)){_context89.next=28;break;}a=[];_iterator75=_createForOfIteratorHelper(t);_context89.prev=4;_iterator75.s();case 6:if((_step75=_iterator75.n()).done){_context89.next=19;break;}c=_step75.value;if(!c.rect){_context89.next=17;break;}if(!(c.rect=cs(he(c.rect),this.scene,this.dpr),!c.rect)){_context89.next=11;break;}return _context89.abrupt("continue",17);case 11:if(!(c.drawCanvas&&c.rect&&c.rect.w>0&&c.rect.h>0)){_context89.next=16;break;}_context89.next=14;return this.getRectImageBitmap(c);case 14:m=_context89.sent;c.imageBitmap=m,n||(n=[]),n.push(m);case 16:a.push(c);case 17:_context89.next=6;break;case 19:_context89.next=24;break;case 21:_context89.prev=21;_context89.t0=_context89["catch"](4);_iterator75.e(_context89.t0);case 24:_context89.prev=24;_iterator75.f();return _context89.finish(24);case 27:r.render=a;case 28:i=(l=r.sp)==null?void 0:l.filter(function(a){return a.type!==dt.None||a.isLockSentEventCursor;});i!=null&&i.length?r.sp=i.map(function(a){return _objectSpread(_objectSpread({},a),{},{viewId:_this112.viewId});}):delete r.sp,r.consumeCount===void 0&&delete r.consumeCount,r.subWorkerDrawCount===void 0&&delete r.subWorkerDrawCount,(i!=null&&i.length||r.consumeCount||r.subWorkerDrawCount||(o=r==null?void 0:r.render)!=null&&o.length)&&(console.log("msg---layer--sub",this.viewId,he(r),this.fullLayer.children.length),this._post(r,n)),this.delayPostDoneResolve&&this.delayPostDoneResolve(!0);case 30:case"end":return _context89.stop();}},_callee84,this,[[4,21,24,27]]);}));function combinePost(){return _combinePost.apply(this,arguments);}return combinePost;}()},{key:"getLayer",value:function getLayer(t,r){if(r&&this.snapshotFullLayer)return this.snapshotFullLayer;switch(t){case Et.TopFloat:return this.topLayer||this.fullLayer;default:return this.fullLayer;}}},{key:"on",value:function(){var _on2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee85(t){var c,m,r,n,i,l,o,a,f;return _regeneratorRuntime().wrap(function _callee85$(_context90){while(1)switch(_context90.prev=_context90.next){case 0:r=t.msgType,n=t.toolsType,i=t.opt,l=t.dataType,o=t.workState,a=t.isLockSentEventCursor;_context90.t0=r;_context90.next=_context90.t0===dt.UpdateTools?4:_context90.t0===dt.CreateWork?9:_context90.t0===dt.DrawWork?11:_context90.t0===dt.RemoveNode?19:_context90.t0===dt.FullWork?22:_context90.t0===dt.Snapshot?27:_context90.t0===dt.BoundingBox?32:37;break;case 4:if(!(n&&(c=this.topLayerWork)!=null&&c.canUseTopLayer(n)&&i)){_context90.next=8;break;}f={toolsType:n,toolsOpt:i};this.topLayerWork.setToolsOpt(f);return _context90.abrupt("return");case 8:return _context90.abrupt("break",37);case 9:this.createLocalWork(t);return _context90.abrupt("return");case 11:if(!(o===Ft.Done&&l===Dt.Local)){_context90.next=17;break;}_context90.next=14;return this.consumeDrawAll(l,t);case 14:n===pt.LaserPen&&a&&this.post({sp:[{type:dt.None,isLockSentEventCursor:a}]});_context90.next=18;break;case 17:this.consumeDraw(l,t);case 18:return _context90.abrupt("return");case 19:_context90.next=21;return this.removeNode(t);case 21:return _context90.abrupt("return");case 22:_context90.t1=n&&(m=this.topLayerWork)!=null&&m.canUseTopLayer(n);if(!_context90.t1){_context90.next=26;break;}_context90.next=26;return this.consumeDrawAll(l,t);case 26:return _context90.abrupt("return");case 27:this.snapshotWork.createSnapshotFullLayer(this.scene,_objectSpread(_objectSpread({},this.opt.layerOpt),{},{bufferSize:this.viewId===hr?6e3:3e3,contextType:"2d"}));_context90.next=30;return this.snapshotWork.getSnapshot(t);case 30:this.snapshotWork.destroySnapshotFullLayer();return _context90.abrupt("return");case 32:this.snapshotWork.createSnapshotFullLayer(this.scene,_objectSpread(_objectSpread({},this.opt.layerOpt),{},{bufferSize:this.viewId===hr?6e3:3e3,contextType:"2d"}));_context90.next=35;return this.snapshotWork.getBoundingRect(t);case 35:this.snapshotWork.destroySnapshotFullLayer();return _context90.abrupt("return");case 37:_context90.next=39;return _superPropGet(Ps,"on",this,3)([t]);case 39:case"end":return _context90.stop();}},_callee85,this);}));function on(_x152){return _on2.apply(this,arguments);}return on;}()},{key:"createLocalWork",value:function createLocalWork(t){var l;var r=t.workId,n=t.toolsType,i=t.opt;if(n&&(l=this.topLayerWork)!=null&&l.canUseTopLayer(n)&&r&&i){this.topLayerWork.getToolsOpt()||this.topLayerWork.setToolsOpt({toolsType:n,toolsOpt:i}),this.topLayerWork.setWorkOptions(r.toString(),i);return;}n&&_superPropGet(Ps,"createLocalWork",this,3)([t]);}},{key:"removeNode",value:function(){var _removeNode2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee86(t){var r;return _regeneratorRuntime().wrap(function _callee86$(_context91){while(1)switch(_context91.prev=_context91.next){case 0:r=t.dataType;_context91.t0=r===Dt.Local;if(!_context91.t0){_context91.next=5;break;}_context91.next=5;return this.localWork.removeWork(t);case 5:case"end":return _context91.stop();}},_callee86,this);}));function removeNode(_x153){return _removeNode2.apply(this,arguments);}return removeNode;}()},{key:"getOffscreen",value:function getOffscreen(t,r){var i;return((i=this.getLayer(t,r))==null?void 0:i.parent).canvas;}},{key:"consumeDraw",value:function(){var _consumeDraw5=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee87(t,r){var l,n,i;return _regeneratorRuntime().wrap(function _callee87$(_context92){while(1)switch(_context92.prev=_context92.next){case 0:n=r.workId,i=r.toolsType;if(!n){_context92.next=11;break;}if(!(i&&(l=this.topLayerWork)!=null&&l.canUseTopLayer(i))){_context92.next=5;break;}t===Dt.Local&&(this.topLayerWork.getWorkShape(n.toString())||this.createLocalWork(r)),this.topLayerWork.consumeDraw(r);return _context92.abrupt("return");case 5:_context92.t0=i;if(!_context92.t0){_context92.next=10;break;}this.localWork.getWorkShape(n.toString())||this.createLocalWork(r);_context92.next=10;return this.localWork.consumeDraw(r);case 10:return _context92.abrupt("return");case 11:case"end":return _context92.stop();}},_callee87,this);}));function consumeDraw(_x154,_x155){return _consumeDraw5.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee88(t,r){var o,n,i,l,a;return _regeneratorRuntime().wrap(function _callee88$(_context93){while(1)switch(_context93.prev=_context93.next){case 0:n=r.workId,i=r.toolsType,l=r.dataType;if(!n){_context93.next=8;break;}a=n.toString();if(!(i&&(o=this.topLayerWork)!=null&&o.canUseTopLayer(i))){_context93.next=6;break;}l===Dt.Local&&(this.topLayerWork.getWorkShape(a)||this.createLocalWork(r)),this.topLayerWork.consumeDrawAll(r);return _context93.abrupt("return");case 6:i&&(this.localWork.getWorkShape(a)||_superPropGet(Ps,"createLocalWork",this,3)([r]),this.localWork.consumeDrawAll(r));return _context93.abrupt("return");case 8:case"end":return _context93.stop();}},_callee88,this);}));function consumeDrawAll(_x156,_x157){return _consumeDrawAll4.apply(this,arguments);}return consumeDrawAll;}()},{key:"clearAll",value:function(){var _clearAll2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee89(){return _regeneratorRuntime().wrap(function _callee89$(_context94){while(1)switch(_context94.prev=_context94.next){case 0:this.vNodes.clear();_superPropGet(Ps,"clearAll",this,3)([]);this.topLayer&&(this.topLayer.parent.children.forEach(function(t){t.name!=="viewport"&&t.remove();}),Se(this.topLayer,this.topLayer.parent));_context94.next=5;return this.post({render:[{isClearAll:!0,clearCanvas:Et.TopFloat,viewId:this.viewId}],sp:[{type:dt.Clear}]});case 5:case"end":return _context94.stop();}},_callee89,this);}));function clearAll(){return _clearAll2.apply(this,arguments);}return clearAll;}()},{key:"getRectImageBitmap",value:function getRectImageBitmap(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!1;var n=arguments.length>2?arguments[2]:undefined;var i=t.rect,l=t.drawCanvas,o=Math.floor(i.x*this.dpr),a=Math.floor(i.y*this.dpr),c=Math.floor(i.w*this.dpr||1),m=Math.floor(i.h*this.dpr||1);return createImageBitmap(this.getOffscreen(l,r),o,a,c,m,n);}},{key:"updateLayer",value:function updateLayer(t){var r=t.width,n=t.height;_superPropGet(Ps,"updateLayer",this,3)([t]),this.topLayer&&(this.topLayer.parent.setAttribute("width",r),this.topLayer.parent.setAttribute("height",n),this.topLayer.setAttribute("size",[r,n]),this.topLayer.setAttribute("pos",[r*0.5,n*0.5])),this.snapshotFullLayer&&(this.snapshotFullLayer.parent.setAttribute("width",r),this.snapshotFullLayer.parent.setAttribute("height",n),this.snapshotFullLayer.setAttribute("size",[r,n]),this.snapshotFullLayer.setAttribute("pos",[r*0.5,n*0.5]));}},{key:"updateDpr",value:function(){var _updateDpr2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee90(t){var r,n,i;return _regeneratorRuntime().wrap(function _callee90$(_context95){while(1)switch(_context95.prev=_context95.next){case 0:_superPropGet(Ps,"updateDpr",this,3)([t]);r=this.topLayerWork&&!!this.topLayerWork.localWorkShapes.size||!1,n=!!this.localWork.getWorkShapes().size,i=[];n&&i.push({isClearAll:!0,clearCanvas:Et.Float,viewId:this.viewId});r&&i.push({isClearAll:!0,clearCanvas:Et.TopFloat,viewId:this.viewId});_context95.t0=i.length;if(!_context95.t0){_context95.next=8;break;}_context95.next=8;return this.post({render:i});case 8:case"end":return _context95.stop();}},_callee90,this);}));function updateDpr(_x158){return _updateDpr2.apply(this,arguments);}return updateDpr;}()},{key:"updateCamera",value:function(){var _updateCamera=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee91(t){var _this113=this;var i,r,n,l,o,_iterator76,_step76,_loop9;return _regeneratorRuntime().wrap(function _callee91$(_context97){while(1)switch(_context97.prev=_context97.next){case 0:r=[],n=t.cameraOpt;if(!(n&&!Me(this.cameraOpt,n))){_context97.next=25;break;}l=this.topLayerWork&&!!this.topLayerWork.localWorkShapes.size||!1,o=!!this.localWork.getWorkShapes().size;if(!(o&&this.localWork.workShapesDone(),this.setCameraOpt(n),o&&r.push({isClearAll:!0,clearCanvas:Et.Float,viewId:this.viewId}),l&&this.topLayerWork)){_context97.next=21;break;}r.push({isClearAll:!0,clearCanvas:Et.TopFloat,viewId:this.viewId});_iterator76=_createForOfIteratorHelper(this.topLayerWork.localWorkShapes.entries()||[]);_context97.prev=6;_loop9=/*#__PURE__*/_regeneratorRuntime().mark(function _loop9(){var _step76$value,a,c,m;return _regeneratorRuntime().wrap(function _loop9$(_context96){while(1)switch(_context96.prev=_context96.next){case 0:_step76$value=_slicedToArray(_step76.value,2),a=_step76$value[0],c=_step76$value[1];if(c.totalRect){(i=_this113.topLayer)==null||i.getElementsByName(a.toString()).forEach(function(f){var v=f.getBoundingClientRect(),S=kt({x:v.x,y:v.y,w:v.width,h:v.height});m=bt(m,S);}),c.totalRect=m,_this113.topLayerWork.localWorkShapes.set(a,c);}case 2:case"end":return _context96.stop();}},_loop9);});_iterator76.s();case 9:if((_step76=_iterator76.n()).done){_context97.next=13;break;}return _context97.delegateYield(_loop9(),"t0",11);case 11:_context97.next=9;break;case 13:_context97.next=18;break;case 15:_context97.prev=15;_context97.t1=_context97["catch"](6);_iterator76.e(_context97.t1);case 18:_context97.prev=18;_iterator76.f();return _context97.finish(18);case 21:_context97.t2=r.length;if(!_context97.t2){_context97.next=25;break;}_context97.next=25;return this.post({render:r});case 25:case"end":return _context97.stop();}},_callee91,this,[[6,15,18,21]]);}));function updateCamera(_x159){return _updateCamera.apply(this,arguments);}return updateCamera;}()},{key:"setCameraOpt",value:function setCameraOpt(t,r){var c,m;this.cameraOpt=t;var n=t.scale,i=t.centerX,l=t.centerY,o=t.width,a=t.height;(o!==this.scene.width||a!==this.scene.height)&&this.updateScene(this.scene,{width:o,height:a}),r?(r.setAttribute("scale",[n,n]),r.setAttribute("translate",[-i,-l])):(this.fullLayer.setAttribute("scale",[n,n]),this.fullLayer.setAttribute("translate",[-i,-l]),(c=this.topLayer)==null||c.setAttribute("scale",[n,n]),(m=this.topLayer)==null||m.setAttribute("translate",[-i,-l]));}}]);}(fs);var Ss=/*#__PURE__*/function(_fs2){function Ss(t,r,n){var _this114;_classCallCheck(this,Ss);_this114=_callSuper(this,Ss,[t,r,"full"/* Full */]);ot(_this114,"serviceDrawLayer");ot(_this114,"localDrawLayer");ot(_this114,"snapshotFullLayer");ot(_this114,"methodBuilder");ot(_this114,"localWork");ot(_this114,"serviceWork");ot(_this114,"_post");ot(_this114,"debounceUpdateCache",/* @__PURE__ */new Set());_this114._post=n;var i=me.bufferSize.sub;_this114.serviceDrawLayer=_this114.createLayer("serviceDrawLayer",_this114.scene,_objectSpread(_objectSpread({},r.layerOpt),{},{bufferSize:i,contextType:"2d"})),_this114.localDrawLayer=_this114.createLayer("localDrawLayer",_this114.scene,_objectSpread(_objectSpread({},r.layerOpt),{},{bufferSize:i,contextType:"2d"}));var l={thread:_this114,viewId:_this114.viewId,vNodes:_this114.vNodes,fullLayer:_this114.fullLayer};_this114.localWork=new ys(_objectSpread(_objectSpread({},l),{},{drawLayer:_this114.localDrawLayer})),r.combineUnitTime&&_this114.localWork.setCombineUnitTime(r.combineUnitTime),r.maxCombineEraserTime&&_this114.localWork.setmaxCombineEraserTime(r.maxCombineEraserTime),r.syncUnitTime&&_this114.localWork.setSyncUnitTime(r.syncUnitTime),_this114.serviceWork=new gs(_objectSpread(_objectSpread({},l),{},{drawLayer:_this114.serviceDrawLayer})),_this114.methodBuilder=new pi([$t.CopyNode,$t.SetColorNode,$t.DeleteNode,$t.RotateNode,$t.ScaleNode,$t.TranslateNode,$t.ZIndexNode,$t.SetFontStyle,$t.SetPoint,$t.SetLock,$t.SetShapeOpt]).registerForWorker(_this114),_this114.vNodes.init(_this114.fullLayer);return _this114;}_inherits(Ss,_fs2);return _createClass(Ss,[{key:"combinePost",value:function(){var _combinePost2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee92(){var _this115=this;var l,o,_this$combinePostData2,t,r,n,a,_iterator77,_step77,c,m,i;return _regeneratorRuntime().wrap(function _callee92$(_context98){while(1)switch(_context98.prev=_context98.next){case 0:_this$combinePostData2=this.combinePostData(),t=_this$combinePostData2.render,r=_objectWithoutProperties(_this$combinePostData2,_excluded4);if(!(t!=null&&t.length)){_context98.next=28;break;}a=[];_iterator77=_createForOfIteratorHelper(t);_context98.prev=4;_iterator77.s();case 6:if((_step77=_iterator77.n()).done){_context98.next=19;break;}c=_step77.value;if(!c.rect){_context98.next=17;break;}if(!(c.rect=cs(he(c.rect),this.scene,this.dpr),!c.rect)){_context98.next=11;break;}return _context98.abrupt("continue",17);case 11:if(!(c.drawCanvas&&c.rect&&c.rect.w>0&&c.rect.h>0)){_context98.next=16;break;}_context98.next=14;return this.getRectImageBitmap(c);case 14:m=_context98.sent;c.imageBitmap=m,n||(n=[]),n.push(m);case 16:a.push(c);case 17:_context98.next=6;break;case 19:_context98.next=24;break;case 21:_context98.prev=21;_context98.t0=_context98["catch"](4);_iterator77.e(_context98.t0);case 24:_context98.prev=24;_iterator77.f();return _context98.finish(24);case 27:r.render=a;case 28:i=(l=r.sp)==null?void 0:l.filter(function(a){return a.type!==dt.None||a.isLockSentEventCursor;});i!=null&&i.length?r.sp=i.map(function(a){return _objectSpread(_objectSpread({},a),{},{viewId:_this115.viewId});}):delete r.sp,r.fullWorkerDrawCount===void 0&&delete r.fullWorkerDrawCount,r.consumeCount===void 0&&delete r.consumeCount,(r!=null&&r.fullWorkerDrawCount||r.consumeCount||i!=null&&i.length||(o=r.render)!=null&&o.length)&&(console.log("msg---layer--full",r.consumeCount),this._post(r,n)),this.delayPostDoneResolve&&this.delayPostDoneResolve(!0);case 30:case"end":return _context98.stop();}},_callee92,this,[[4,21,24,27]]);}));function combinePost(){return _combinePost2.apply(this,arguments);}return combinePost;}()},{key:"on",value:function(){var _on3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee93(t){var _this116=this;var r,n,i,l,o,a,c,m,_c8;return _regeneratorRuntime().wrap(function _callee93$(_context99){while(1)switch(_context99.prev=_context99.next){case 0:if(!this.methodBuilder.consumeForWorker(t)){_context99.next=2;break;}return _context99.abrupt("return");case 2:r=t.msgType,n=t.dataType,i=t.workId,l=t.toolsType,o=t.workState,a=t.workIds;_context99.t0=r;_context99.next=_context99.t0===dt.AuthClear?6:_context99.t0===dt.CreateWork?9:_context99.t0===dt.DrawWork?11:_context99.t0===dt.Select?20:_context99.t0===dt.UpdateNode?27:_context99.t0===dt.FullWork?27:_context99.t0===dt.RemoveNode?29:_context99.t0===dt.GetTextActive?32:_context99.t0===dt.CursorHover?35:_context99.t0===dt.CursorBlur?38:_context99.t0===dt.GetVNodeInfo?41:43;break;case 6:c=t.clearUids,m=t.localUid;this.vNodes.setCanClearUids(c),this.vNodes.setLocalUid(m);return _context99.abrupt("break",43);case 9:l!==pt.LaserPen&&this.createLocalWork(t);return _context99.abrupt("break",43);case 11:_context99.t1=l!==pt.LaserPen;if(!_context99.t1){_context99.next=19;break;}if(!(o===Ft.Done&&n===Dt.Local)){_context99.next=18;break;}_context99.next=16;return this.consumeDrawAll(n,t);case 16:_context99.next=19;break;case 18:this.consumeDraw(n,t);case 19:return _context99.abrupt("break",43);case 20:if(!(i===qt)){_context99.next=25;break;}_context99.next=23;return this.localWork.updateFullSelectWork(t);case 23:_context99.next=26;break;case 25:this.serviceWork.runSelectWork(t);case 26:return _context99.abrupt("return");case 27:this.consumeFull(n,t);return _context99.abrupt("return");case 29:_context99.next=31;return this.removeNode(t);case 31:return _context99.abrupt("return");case 32:_context99.next=34;return this.checkTextActive(t);case 34:return _context99.abrupt("return");case 35:_context99.next=37;return this.cursorHover(t);case 37:return _context99.abrupt("return");case 38:_context99.next=40;return this.cursorBlur();case 40:return _context99.abrupt("return");case 41:if(i&&a){_c8=a.map(function(m){return _this116.vNodes.get(m);});this.post({sp:[{type:dt.GetVNodeInfo,dataType:Dt.Worker,workId:i,vInfo:_c8}]});}return _context99.abrupt("break",43);case 43:_context99.next=45;return _superPropGet(Ss,"on",this,3)([t]);case 45:case"end":return _context99.stop();}},_callee93,this);}));function on(_x160){return _on3.apply(this,arguments);}return on;}()},{key:"removeNode",value:function(){var _removeNode3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee94(t){var _this117=this;var r,n,i,l,o,_iterator78,_step78,_loop10;return _regeneratorRuntime().wrap(function _callee94$(_context101){while(1)switch(_context101.prev=_context101.next){case 0:r=t.dataType,n=t.workId,i=t.removeIds,l=[],o=i||[];if(!(n&&o.push(n.toString()),o.length)){_context101.next=20;break;}_iterator78=_createForOfIteratorHelper(o);_context101.prev=3;_loop10=/*#__PURE__*/_regeneratorRuntime().mark(function _loop10(){var a;return _regeneratorRuntime().wrap(function _loop10$(_context100){while(1)switch(_context100.prev=_context100.next){case 0:a=_step78.value;a===qt?l.push(_this117.localWork.removeSelector(t,_this117)):r===Dt.Local?l.push(_this117.localWork.removeWork(t).then(function(){_this117.localWork.colloctEffectSelectWork(t),_this117.deleteCachedImagesByWorkId(a);})):r===Dt.Service&&l.push(_this117.serviceWork.removeWork(t).then(function(){_this117.localWork.colloctEffectSelectWork(t),_this117.deleteCachedImagesByWorkId(a);}));case 2:case"end":return _context100.stop();}},_loop10);});_iterator78.s();case 6:if((_step78=_iterator78.n()).done){_context101.next=10;break;}return _context101.delegateYield(_loop10(),"t0",8);case 8:_context101.next=6;break;case 10:_context101.next=15;break;case 12:_context101.prev=12;_context101.t1=_context101["catch"](3);_iterator78.e(_context101.t1);case 15:_context101.prev=15;_iterator78.f();return _context101.finish(15);case 18:_context101.next=20;return Promise.all(l);case 20:case"end":return _context101.stop();}},_callee94,null,[[3,12,15,18]]);}));function removeNode(_x161){return _removeNode3.apply(this,arguments);}return removeNode;}()},{key:"checkTextActive",value:function(){var _checkTextActive2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee95(t){var r;return _regeneratorRuntime().wrap(function _callee95$(_context102){while(1)switch(_context102.prev=_context102.next){case 0:r=t.dataType;_context102.t0=r===Dt.Local;if(!_context102.t0){_context102.next=5;break;}_context102.next=5;return this.localWork.checkTextActive(t);case 5:case"end":return _context102.stop();}},_callee95,this);}));function checkTextActive(_x162){return _checkTextActive2.apply(this,arguments);}return checkTextActive;}()},{key:"clearAll",value:function(){var _clearAll3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee96(){return _regeneratorRuntime().wrap(function _callee96$(_context103){while(1)switch(_context103.prev=_context103.next){case 0:this.vNodes.clear();_superPropGet(Ss,"clearAll",this,3)([]);this.localDrawLayer&&(this.localDrawLayer.parent.children.forEach(function(t){t.name!=="viewport"&&t.remove();}),Se(this.localDrawLayer,this.localDrawLayer.parent));this.serviceDrawLayer&&(this.serviceDrawLayer.parent.children.forEach(function(t){t.name!=="viewport"&&t.remove();}),Se(this.serviceDrawLayer,this.serviceDrawLayer.parent));_context103.next=6;return this.post({render:[{isClearAll:!0,clearCanvas:Et.Bg,viewId:this.viewId},{isClearAll:!0,clearCanvas:Et.ServiceFloat,viewId:this.viewId},{isClearAll:!0,clearCanvas:Et.Float,viewId:this.viewId}],sp:[{type:dt.Clear}]});case 6:case"end":return _context103.stop();}},_callee96,this);}));function clearAll(){return _clearAll3.apply(this,arguments);}return clearAll;}()},{key:"updateLayer",value:function updateLayer(t){var r=t.width,n=t.height;_superPropGet(Ss,"updateLayer",this,3)([t]),this.localDrawLayer&&(this.localDrawLayer.parent.setAttribute("width",r),this.localDrawLayer.parent.setAttribute("height",n),this.localDrawLayer.setAttribute("size",[r,n]),this.localDrawLayer.setAttribute("pos",[r*0.5,n*0.5])),this.serviceDrawLayer&&(this.serviceDrawLayer.parent.setAttribute("width",r),this.serviceDrawLayer.parent.setAttribute("height",n),this.serviceDrawLayer.setAttribute("size",[r,n]),this.serviceDrawLayer.setAttribute("pos",[r*0.5,n*0.5]));}},{key:"setCameraOpt",value:function setCameraOpt(t){this.cameraOpt=t;var r=t.scale,n=t.centerX,i=t.centerY,l=t.width,o=t.height;(l!==this.scene.width||o!==this.scene.height)&&this.updateScene(this.scene,{width:l,height:o}),this.fullLayer&&(this.fullLayer.setAttribute("scale",[r,r]),this.fullLayer.setAttribute("translate",[-n,-i])),this.localDrawLayer&&(this.localDrawLayer.setAttribute("scale",[r,r]),this.localDrawLayer.setAttribute("translate",[-n,-i])),this.serviceDrawLayer&&(this.serviceDrawLayer.setAttribute("scale",[r,r]),this.serviceDrawLayer.setAttribute("translate",[-n,-i]));}},{key:"getLayer",value:function getLayer(t){switch(t){case Et.Bg:return this.fullLayer;case Et.ServiceFloat:return this.serviceDrawLayer;case Et.Float:return this.localDrawLayer;}}},{key:"getOffscreen",value:function getOffscreen(t){return this.getLayer(t).parent.canvas;}},{key:"consumeFull",value:function(){var _consumeFull2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee97(t,r){var n;return _regeneratorRuntime().wrap(function _callee97$(_context104){while(1)switch(_context104.prev=_context104.next){case 0:_context104.next=2;return this.localWork.colloctEffectSelectWork(r);case 2:n=_context104.sent;_context104.t0=n&&t===Dt.Local;if(!_context104.t0){_context104.next=7;break;}_context104.next=7;return this.localWork.consumeFull(n);case 7:n&&t===Dt.Service&&this.serviceWork.consumeFull(n);case 8:case"end":return _context104.stop();}},_callee97,this);}));function consumeFull(_x163,_x164){return _consumeFull2.apply(this,arguments);}return consumeFull;}()},{key:"consumeDraw",value:function(){var _consumeDraw6=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee98(t,r){var n;return _regeneratorRuntime().wrap(function _callee98$(_context105){while(1)switch(_context105.prev=_context105.next){case 0:n=r.workId;_context105.t0=t===Dt.Local&&n;if(!_context105.t0){_context105.next=6;break;}this.localWork.getWorkShape(n.toString())||this.createLocalWork(r);_context105.next=6;return this.localWork.consumeDraw(r,this.serviceWork);case 6:t===Dt.Service&&this.serviceWork.consumeDraw(r);case 7:case"end":return _context105.stop();}},_callee98,this);}));function consumeDraw(_x165,_x166){return _consumeDraw6.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll5=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee99(t,r){var n;return _regeneratorRuntime().wrap(function _callee99$(_context106){while(1)switch(_context106.prev=_context106.next){case 0:n=r.workId;_context106.t0=t===Dt.Local&&n;if(!_context106.t0){_context106.next=6;break;}this.localWork.getWorkShape(n.toString())||this.createLocalWork(r);_context106.next=6;return this.localWork.consumeDrawAll(r,this.serviceWork);case 6:case"end":return _context106.stop();}},_callee99,this);}));function consumeDrawAll(_x167,_x168){return _consumeDrawAll5.apply(this,arguments);}return consumeDrawAll;}()},{key:"updateDpr",value:function(){var _updateDpr3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee100(t){return _regeneratorRuntime().wrap(function _callee100$(_context107){while(1)switch(_context107.prev=_context107.next){case 0:_superPropGet(Ss,"updateDpr",this,3)([t]);_context107.next=3;return this.post({render:[{isClearAll:!0,clearCanvas:Et.Bg,viewId:this.viewId},{isDrawAll:!0,drawCanvas:Et.Bg,viewId:this.viewId}]});case 3:case"end":return _context107.stop();}},_callee100,this);}));function updateDpr(_x169){return _updateDpr3.apply(this,arguments);}return updateDpr;}()},{key:"updateCamera",value:function(){var _updateCamera2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee101(t){var _this118=this;var l,o,a,c,m,r,n,i,f,P,_iterator79,_step79,_step79$value,_x171,_h47,v,_iterator80,_step80,_step80$value,_P27,_x176,_h50,_iterator81,_step81,_step81$value,_P28,_x177,_h51,S,E,_P23,_iterator82,_step82,_x172,T,_iterator83,_step83,_P24,_x173,_iterator84,_step84,_h48,_iterator85,_step85,_step85$value,_P26,_step85$value$,_x175,_h49,p,d,g,O,w,L,B,A,b,W,_iterator86,_step86,_step86$value,_P25,_x174;return _regeneratorRuntime().wrap(function _callee101$(_context108){while(1)switch(_context108.prev=_context108.next){case 0:r=[],n=t.cameraOpt,i=t.scenePath;if(!(n&&!Me(this.cameraOpt,n))){_context108.next=42;break;}this.taskUpdateCameraId&&(clearTimeout(this.taskUpdateCameraId),this.taskUpdateCameraId=void 0);f=!!this.serviceDrawLayer.children.length;if(!i){_context108.next=30;break;}P=!1;_iterator79=_createForOfIteratorHelper(this.localWork.getWorkShapes().entries());_context108.prev=7;_iterator79.s();case 9:if((_step79=_iterator79.n()).done){_context108.next=19;break;}_step79$value=_slicedToArray(_step79.value,2),_x171=_step79$value[0],_h47=_step79$value[1];_context108.t0=_h47.toolsType;_context108.next=_context108.t0===pt.Text?14:_context108.t0===pt.PencilEraser?14:_context108.t0===pt.Eraser?14:_context108.t0===pt.Selector?14:_context108.t0===pt.LaserPen?14:15;break;case 14:return _context108.abrupt("break",17);case 15:_x171!==He&&_x171!==qt&&(P=!0);return _context108.abrupt("break",17);case 17:_context108.next=9;break;case 19:_context108.next=24;break;case 21:_context108.prev=21;_context108.t1=_context108["catch"](7);_iterator79.e(_context108.t1);case 24:_context108.prev=24;_iterator79.f();return _context108.finish(24);case 27:if(!P){_context108.next=30;break;}this.taskUpdateCameraId=setTimeout(function(){_this118.taskUpdateCameraId=void 0,_this118.updateCamera(t);},si);return _context108.abrupt("return");case 30:v=/* @__PURE__ */new Map();_iterator80=_createForOfIteratorHelper(this.vNodes.getNodesByType(pt.Text).entries());try{for(_iterator80.s();!(_step80=_iterator80.n()).done;){_step80$value=_slicedToArray(_step80.value,2),_P27=_step80$value[0],_x176=_step80$value[1];_h50=_x176.rect;v.set(_P27,{rect:he(_h50),scale:(l=this.cameraOpt)==null?void 0:l.scale});}}catch(err){_iterator80.e(err);}finally{_iterator80.f();}_iterator81=_createForOfIteratorHelper(this.vNodes.gethasEraserNodes().entries());try{for(_iterator81.s();!(_step81=_iterator81.n()).done;){_step81$value=_slicedToArray(_step81.value,2),_P28=_step81$value[0],_x177=_step81$value[1];_h51=_x177.rect;v.set(_P28,{rect:he(_h51),scale:(o=this.cameraOpt)==null?void 0:o.scale});}}catch(err){_iterator81.e(err);}finally{_iterator81.f();}S=new Set(v.keys());E=!1;if(this.localWork.hasSelector()){_P23=(a=this.localWork.getSelector())==null?void 0:a.selectIds;if(_P23){E=!0;_iterator82=_createForOfIteratorHelper(_P23);try{for(_iterator82.s();!(_step82=_iterator82.n()).done;){_x172=_step82.value;S.add(_x172);}}catch(err){_iterator82.e(err);}finally{_iterator82.f();}}}T=!1;if(this.serviceWork.selectorWorkShapes.size){_iterator83=_createForOfIteratorHelper(this.serviceWork.selectorWorkShapes.values());try{for(_iterator83.s();!(_step83=_iterator83.n()).done;){_P24=_step83.value;_x173=_P24.selectIds;if(_x173){T=!0;_iterator84=_createForOfIteratorHelper(_x173);try{for(_iterator84.s();!(_step84=_iterator84.n()).done;){_h48=_step84.value;S.add(_h48);}}catch(err){_iterator84.e(err);}finally{_iterator84.f();}}}}catch(err){_iterator83.e(err);}finally{_iterator83.f();}}if(this.setCameraOpt(n),this.vNodes.curNodeMap.size){this.vNodes.clearTarget(),this.vNodes.updateHighLevelNodesRect(S),this.debounceUpdateCameraId&&clearTimeout(this.debounceUpdateCameraId);_iterator85=_createForOfIteratorHelper(v.entries());try{for(_iterator85.s();!(_step85=_iterator85.n()).done;){_step85$value=_slicedToArray(_step85.value,2),_P26=_step85$value[0],_step85$value$=_step85$value[1],_x175=_step85$value$.rect,_h49=_step85$value$.scale;p=this.vNodes.get(_P26);if(p){d=_x175,g=p.rect,O=this.getSceneRect(),w=or(d,O),L=or(g,O),B=p.toolsType,A=p.opt;b=!1;(w!==L||d.w!==g.w||d.h!==g.h||L===Pe.intersect)&&(b=!0),B===pt.Text&&A.workState===Ft.Done&&b&&this.debounceUpdateCache.add(_P26);W=!1;_h49&&(c=this.cameraOpt)!=null&&c.scale&&_h49>this.cameraOpt.scale?L!==Pe.outside&&w!==Pe.inside&&(W=!0):_h49&&(m=this.cameraOpt)!=null&&m.scale&&_h49===this.cameraOpt.scale&&(d.x!==g.x||d.y!==g.y)&&(L===Pe.inside&&w!==Pe.inside||L===Pe.intersect&&w===Pe.intersect)&&(W=!0),A.eraserlines&&A.eraserlines.length&&W&&!this.debounceUpdateCache.has(_P26)&&this.debounceUpdateCache.add(_P26);}}}catch(err){_iterator85.e(err);}finally{_iterator85.f();}if(E&&this.localWork.reRenderSelector(),T){_iterator86=_createForOfIteratorHelper(this.serviceWork.selectorWorkShapes.entries());try{for(_iterator86.s();!(_step86=_iterator86.n()).done;){_step86$value=_slicedToArray(_step86.value,2),_P25=_step86$value[0],_x174=_step86$value[1];this.serviceWork.runSelectWork({workId:_P25,selectIds:_x174.selectIds,msgType:dt.Select,dataType:Dt.Service,viewId:this.viewId});}}catch(err){_iterator86.e(err);}finally{_iterator86.f();}}this.debounceUpdateCameraId=setTimeout(function(){var x;_this118.debounceUpdateCameraId=void 0;var P=[];var _iterator87=_createForOfIteratorHelper(_this118.debounceUpdateCache.values()),_step87;try{var _loop11=function _loop11(){var h=_step87.value;var p=_this118.vNodes.get(h);if(p){var d=p.toolsType,g=p.opt,O=p.rect,w=p.op,L=_this118.localWork.setFullWork({toolsType:d,opt:g,workId:h});if(L){var B=_this118.getSceneRect(),A=or(O,B);d===pt.Text?(x=_this118.fullLayer)!=null&&x.getElementsByName(h)[0]&&L instanceof cr&&P.push(L.consumeServiceAsync({isFullWork:!0,replaceId:h,isDrawLabel:A!==Pe.outside})):g.eraserlines&&g.eraserlines.length&&P.push(new Promise(function(b){var W=L.consumeService({op:w,isFullWork:!0,replaceId:h,workState:Ft.Done});_this118.localWork.clearWorkShapeNodeCache(h),b(W);}));}}_this118.debounceUpdateCache["delete"](h);};for(_iterator87.s();!(_step87=_iterator87.n()).done;){_loop11();}}catch(err){_iterator87.e(err);}finally{_iterator87.f();}P.length?Promise.all(P).then(function(){var h=[];h.push({isClearAll:!0,clearCanvas:Et.Bg,viewId:_this118.viewId},{isDrawAll:!0,drawCanvas:Et.Bg,viewId:_this118.viewId}),h.length&&_this118.post({render:h}),_this118.vNodes.updateLowLevelNodesRect(),_this118.vNodes.clearHighLevelIds();}):(_this118.vNodes.updateLowLevelNodesRect(),_this118.vNodes.clearHighLevelIds());},si*10);}f&&r.push({isClearAll:!0,clearCanvas:Et.ServiceFloat,viewId:this.viewId}),this.vNodes.hasRenderNodes()&&r.push({isClearAll:!0,clearCanvas:Et.Bg,viewId:this.viewId},{isDrawAll:!0,drawCanvas:Et.Bg,viewId:this.viewId}),r.length&&this.post({render:r});case 42:case"end":return _context108.stop();}},_callee101,this,[[7,21,24,27]]);}));function updateCamera(_x170){return _updateCamera2.apply(this,arguments);}return updateCamera;}()},{key:"getRectImageBitmap",value:function getRectImageBitmap(t){var r=t.rect,n=t.drawCanvas,i=Math.floor(r.x*this.dpr),l=Math.floor(r.y*this.dpr),o=Math.floor(r.w*this.dpr||1),a=Math.floor(r.h*this.dpr||1);return createImageBitmap(this.getOffscreen(n),i,l,o,a,{resizeQuality:"low"});}},{key:"cursorHover",value:function(){var _cursorHover2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee102(t){return _regeneratorRuntime().wrap(function _callee102$(_context109){while(1)switch(_context109.prev=_context109.next){case 0:_context109.next=2;return this.localWork.cursorHover(t);case 2:case"end":return _context109.stop();}},_callee102,this);}));function cursorHover(_x178){return _cursorHover2.apply(this,arguments);}return cursorHover;}()},{key:"cursorBlur",value:function(){var _cursorBlur2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee103(){return _regeneratorRuntime().wrap(function _callee103$(_context110){while(1)switch(_context110.prev=_context110.next){case 0:_context110.next=2;return this.localWork.cursorBlur();case 2:case"end":return _context110.stop();}},_callee103,this);}));function cursorBlur(){return _cursorBlur2.apply(this,arguments);}return cursorBlur;}()},{key:"destroy",value:function destroy(){_superPropGet(Ss,"destroy",this,3)([]);}}]);}(fs);var hy=/*#__PURE__*/function(_Ss){function hy(t,r,n){var _this119;_classCallCheck(this,hy);var l,o,a,c;_this119=_callSuper(this,hy,[t,r,n]);ot(_this119,"snapshotWork");ot(_this119,"localDrawScene");ot(_this119,"serviceDrawScene");ot(_this119,"offscreenCanvas");ot(_this119,"localWork");ot(_this119,"serviceWork");if(_this119._post=n,r.offscreenCanvas){_this119.offscreenCanvas=r.offscreenCanvas,_this119.localDrawScene=_this119.createScene(r,(l=_this119.offscreenCanvas)==null?void 0:l.localCanvas),_this119.serviceDrawScene=_this119.createScene(r,(o=_this119.offscreenCanvas)==null?void 0:o.serviceCanvas);var m=me.bufferSize.sub;_this119.serviceDrawLayer=_this119.createLayer("serviceDrawLayer",_this119.serviceDrawScene||_this119.scene,_objectSpread(_objectSpread({},r.layerOpt),{},{bufferSize:m,contextType:"2d"}),(a=_this119.offscreenCanvas)==null?void 0:a.serviceCanvas),_this119.localDrawLayer=_this119.createLayer("localDrawLayer",_this119.localDrawScene||_this119.scene,_objectSpread(_objectSpread({},r.layerOpt),{},{bufferSize:m,contextType:"2d"}),(c=_this119.offscreenCanvas)==null?void 0:c.localCanvas);}var i={thread:_this119,viewId:_this119.viewId,vNodes:_this119.vNodes,fullLayer:_this119.fullLayer};_this119.localWork=new ly(_objectSpread(_objectSpread({},i),{},{drawLayer:_this119.localDrawLayer})),r.combineUnitTime&&_this119.localWork.setCombineUnitTime(r.combineUnitTime),r.maxCombineEraserTime&&_this119.localWork.setmaxCombineEraserTime(r.maxCombineEraserTime),r.syncUnitTime&&_this119.localWork.setSyncUnitTime(r.syncUnitTime),_this119.serviceWork=new cy(_objectSpread(_objectSpread({},i),{},{drawLayer:_this119.serviceDrawLayer})),_this119.snapshotWork=new us({post:n,fullLayer:_this119.fullLayer,localWork:_this119.localWork,viewId:t,thread:_this119,getDpr:function getDpr(){return _this119.dpr;},getCameraOpt:function getCameraOpt(){return _this119.cameraOpt;},getOffscreen:_this119.getOffscreen,setCameraOpt:_this119.setCameraOpt,getSceneRect:_this119.getSceneRect,createLayer:_this119.createLayer}),_this119.methodBuilder=new pi([$t.CopyNode,$t.SetColorNode,$t.DeleteNode,$t.RotateNode,$t.ScaleNode,$t.TranslateNode,$t.ZIndexNode,$t.SetFontStyle,$t.SetPoint,$t.SetLock,$t.SetShapeOpt]).registerForWorker(_this119);return _this119;}_inherits(hy,_Ss);return _createClass(hy,[{key:"createRenderLayer",value:function createRenderLayer(t,r,n){var o;var i=me.bufferSize.full,l=me.bufferSize.sub;this.fullLayer=this.createLayer("fullLayer",t,_objectSpread(_objectSpread({},r.layerOpt),{},{bufferSize:this.viewId===hr?i:l*2}),n||((o=r.offscreenCanvas)==null?void 0:o.bgCanvas));}},{key:"createScene",value:function createScene(t,r){var n=t.offscreenCanvas,i=t.offscreenCanvasOpt,l=i.width,o=i.height,a=r||(n==null?void 0:n.bgCanvas)||new OffscreenCanvas(l,o);i.contextType&&delete i.contextType;var c=new ui(_objectSpread(_objectSpread({container:a,displayRatio:this.dpr,depth:!1,desynchronized:!0,failIfMajorPerformanceCaveat:!0},i),{},{contextType:this.contextType,id:this.viewId}));return c.setAttribute("id",this.viewId),c;}},{key:"combinePostData",value:function combinePostData(){var l,o;this.workerTaskId=void 0;var t=[],r=[];var n;var i=/* @__PURE__ */new Set();var _iterator88=_createForOfIteratorHelper(this.combinePostMsg.values()),_step88;try{for(_iterator88.s();!(_step88=_iterator88.n()).done;){var a=_step88.value;if((l=a.render)!=null&&l.length)if(this.offscreenCanvas){var _iterator89=_createForOfIteratorHelper(a.render),_step89;try{for(_iterator89.s();!(_step89=_iterator89.n()).done;){var c=_step89.value;c.workId&&i.add(c.workId);var m=c.drawCanvas||c.clearCanvas;if(m){var f=this.getLayer(m);if(!f||!(f.parent instanceof $r))continue;f.parent.render();}}}catch(err){_iterator89.e(err);}finally{_iterator89.f();}}else{var _iterator90=_createForOfIteratorHelper(a.render),_step90;try{for(_iterator90.s();!(_step90=_iterator90.n()).done;){var _c9=_step90.value;var _m15=!1;if(_c9.workId&&i.add(_c9.workId),_c9.isClearAll&&(_c9.rect=this.getSceneRect(),_c9.isClear=!0,delete _c9.isClearAll),_c9.drawCanvas){var _f9=this.getLayer(_c9.drawCanvas);if(!_f9||!(_f9.parent instanceof $r))continue;if(_f9.parent.render(),_c9.isDrawAll){var v=this.getSceneRect();_c9.rect=v,delete _c9.isDrawAll;}}var _iterator91=_createForOfIteratorHelper(t),_step91;try{for(_iterator91.s();!(_step91=_iterator91.n()).done;){var _f10=_step91.value;if(_c9.viewId===_f10.viewId){_c9.isClear&&_f10.clearCanvas&&_f10.isClear&&_f10.clearCanvas===_c9.clearCanvas&&(_f10.rect=bt(_f10.rect,_c9.rect),_m15=!0),_f10.drawCanvas&&_f10.drawCanvas===_c9.drawCanvas&&(_f10.rect=bt(_f10.rect,_c9.rect),_m15=!0);continue;}}}catch(err){_iterator91.e(err);}finally{_iterator91.f();}_m15||(_c9.isClear&&!_c9.drawCanvas?t.unshift(_c9):t.push(_c9));}}catch(err){_iterator90.e(err);}finally{_iterator90.f();}}if((o=a.sp)!=null&&o.length){var _iterator92=_createForOfIteratorHelper(a.sp),_step92;try{for(_iterator92.s();!(_step92=_iterator92.n()).done;){var _c10=_step92.value;var _m16=!1;var _iterator93=_createForOfIteratorHelper(r),_step93;try{for(_iterator93.s();!(_step93=_iterator93.n()).done;){var _f11=_step93.value;if(Me(_c10,_f11)){_m16=!0;break;}}}catch(err){_iterator93.e(err);}finally{_iterator93.f();}_m16||r.push(_c10);}}catch(err){_iterator92.e(err);}finally{_iterator92.f();}}ue(a.consumeCount)&&(n=a.consumeCount);}}catch(err){_iterator88.e(err);}finally{_iterator88.f();}return this.combinePostMsg.clear(),{render:t,sp:r,consumeCount:n,workIds:i,viewId:this.viewId};}},{key:"on",value:function(){var _on4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee104(t){var r;return _regeneratorRuntime().wrap(function _callee104$(_context111){while(1)switch(_context111.prev=_context111.next){case 0:if(!this.methodBuilder.consumeForWorker(t)){_context111.next=2;break;}return _context111.abrupt("return");case 2:r=t.msgType;_context111.t0=r;_context111.next=_context111.t0===dt.Snapshot?6:_context111.t0===dt.BoundingBox?11:16;break;case 6:this.snapshotWork.createSnapshotFullLayer(this.scene,this.opt.layerOpt);_context111.next=9;return this.snapshotWork.getSnapshot(t);case 9:this.snapshotWork.destroySnapshotFullLayer();return _context111.abrupt("return");case 11:this.snapshotWork.createSnapshotFullLayer(this.scene,this.opt.layerOpt);_context111.next=14;return this.snapshotWork.getBoundingRect(t);case 14:this.snapshotWork.destroySnapshotFullLayer();return _context111.abrupt("return");case 16:_context111.next=18;return _superPropGet(hy,"on",this,3)([t]);case 18:case"end":return _context111.stop();}},_callee104,this);}));function on(_x179){return _on4.apply(this,arguments);}return on;}()},{key:"setCameraOpt",value:function setCameraOpt(t){if(this.localDrawScene&&this.serviceDrawScene){var r=t.width,n=t.height;(r!==this.localDrawScene.width||n!==this.localDrawScene.height)&&this.updateScene(this.localDrawScene,{width:r,height:n},this.localDrawLayer),(r!==this.serviceDrawScene.width||n!==this.serviceDrawScene.height)&&this.updateScene(this.serviceDrawScene,{width:r,height:n},this.serviceDrawLayer);}_superPropGet(hy,"setCameraOpt",this,3)([t]);}},{key:"updateDpr",value:function(){var _updateDpr4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee105(t){return _regeneratorRuntime().wrap(function _callee105$(_context112){while(1)switch(_context112.prev=_context112.next){case 0:this.localDrawScene&&this.serviceDrawScene&&(this.localDrawScene.displayRatio=t,this.serviceDrawScene.displayRatio=t),_superPropGet(hy,"updateDpr",this,3)([t]);case 1:case"end":return _context112.stop();}},_callee105,this);}));function updateDpr(_x180){return _updateDpr4.apply(this,arguments);}return updateDpr;}()}]);}(Ss);var hi=self;hi.full=new fy(hi,wr.Full);
473
+ },{key:"isFontAvailable",value:function(){var _isFontAvailable=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee82(e){var t,r,n,_iterator72,_step72,_i7,i;return _regeneratorRuntime().wrap(function _callee82$(_context87){while(1)switch(_context87.prev=_context87.next){case 0:_context87.prev=0;t=this._self.fonts;if(t){_context87.next=4;break;}return _context87.abrupt("return",!1);case 4:r=!1,n=null;_iterator72=_createForOfIteratorHelper(t);_context87.prev=6;_iterator72.s();case 8:if((_step72=_iterator72.n()).done){_context87.next=15;break;}_i7=_step72.value;if(!(_i7.family===e)){_context87.next=13;break;}r=!0,n=_i7;return _context87.abrupt("break",15);case 13:_context87.next=8;break;case 15:_context87.next=20;break;case 17:_context87.prev=17;_context87.t0=_context87["catch"](6);_iterator72.e(_context87.t0);case 20:_context87.prev=20;_iterator72.f();return _context87.finish(20);case 23:if(!(!r||!n)){_context87.next=25;break;}return _context87.abrupt("return",!1);case 25:if(!(n.status==="loaded")){_context87.next=27;break;}return _context87.abrupt("return",!0);case 27:_context87.prev=27;_context87.next=30;return n.loaded;case 30:return _context87.abrupt("return",!0);case 33:_context87.prev=33;_context87.t1=_context87["catch"](27);if(!(t&&typeof t.load=="function")){_context87.next=48;break;}_context87.prev=36;_context87.next=39;return t.load(e);case 39:i=_context87.sent;return _context87.abrupt("return",i&&i.length>0);case 43:_context87.prev=43;_context87.t2=_context87["catch"](36);return _context87.abrupt("return",!1);case 46:_context87.next=49;break;case 48:return _context87.abrupt("return",!0);case 49:_context87.next=54;break;case 51:_context87.prev=51;_context87.t3=_context87["catch"](0);return _context87.abrupt("return",!1);case 54:case"end":return _context87.stop();}},_callee82,this,[[0,51],[6,17,20,23],[27,33],[36,43]]);}));function isFontAvailable(_x150){return _isFontAvailable.apply(this,arguments);}return isFontAvailable;}()},{key:"register",value:function register(){var _this110=this;onmessage=/*#__PURE__*/function(){var _ref171=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee83(e){var t,_iteratorAbruptCompletion,_didIteratorError,_iteratorError,_iterator,_step,r,n,i,l,o,a,_iterator73,_step73,_step73$value,m,f,v,_iterator74,_step74,_m14,c;return _regeneratorRuntime().wrap(function _callee83$(_context88){while(1)switch(_context88.prev=_context88.next){case 0:t=e.data;if(!t){_context88.next=54;break;}_iteratorAbruptCompletion=false;_didIteratorError=false;_context88.prev=4;_iterator=_asyncIterator(t.values());case 6:_context88.next=8;return _iterator.next();case 8:if(!(_iteratorAbruptCompletion=!(_step=_context88.sent).done)){_context88.next=38;break;}r=_step.value;n=r.msgType,i=r.viewId,l=r.tasksqueue,o=r.mainTasksqueueCount,a=r.fontBuffers;if(!a){_context88.next=14;break;}_this110.setFontFaces(a);return _context88.abrupt("continue",35);case 14:if(!(n===dt.Console)){_context88.next=17;break;}console.log(_this110);return _context88.abrupt("continue",35);case 17:if(!(n===dt.Init)){_context88.next=20;break;}_this110.init(r);return _context88.abrupt("continue",35);case 20:if(!(n===dt.TasksQueue&&l!=null&&l.size)){_context88.next=25;break;}_iterator73=_createForOfIteratorHelper(_this110.workThreadMap.entries());try{for(_iterator73.s();!(_step73=_iterator73.n()).done;){_step73$value=_slicedToArray(_step73.value,2),m=_step73$value[0],f=_step73$value[1];v=l.get(m);v&&f.on(v);}}catch(err){_iterator73.e(err);}finally{_iterator73.f();}_this110.type==="full"&&he(o)&&_this110.post({workerTasksqueueCount:o});return _context88.abrupt("continue",35);case 25:if(!(i===ao)){_context88.next=29;break;}_iterator74=_createForOfIteratorHelper(_this110.workThreadMap.values());try{for(_iterator74.s();!(_step74=_iterator74.n()).done;){_m14=_step74.value;_m14.on(r),n===dt.Destroy&&_this110.workThreadMap["delete"](i);}}catch(err){_iterator74.e(err);}finally{_iterator74.f();}return _context88.abrupt("continue",35);case 29:c=_this110.workThreadMap.get(i);_context88.t0=c;if(!_context88.t0){_context88.next=35;break;}_context88.next=34;return c.on(r);case 34:n===dt.Destroy&&_this110.workThreadMap["delete"](i);case 35:_iteratorAbruptCompletion=false;_context88.next=6;break;case 38:_context88.next=44;break;case 40:_context88.prev=40;_context88.t1=_context88["catch"](4);_didIteratorError=true;_iteratorError=_context88.t1;case 44:_context88.prev=44;_context88.prev=45;if(!(_iteratorAbruptCompletion&&_iterator["return"]!=null)){_context88.next=49;break;}_context88.next=49;return _iterator["return"]();case 49:_context88.prev=49;if(!_didIteratorError){_context88.next=52;break;}throw _iteratorError;case 52:return _context88.finish(49);case 53:return _context88.finish(44);case 54:case"end":return _context88.stop();}},_callee83,null,[[4,40,44,54],[45,,49,53]]);}));return function onmessage(_x151){return _ref171.apply(this,arguments);};}();}}]);}();var Ps=/*#__PURE__*/function(_fs){function Ps(t,r,n){var _this111;_classCallCheck(this,Ps);_this111=_callSuper(this,Ps,[t,r,"sub"/* Sub */]);ot(_this111,"type","sub");ot(_this111,"_post");ot(_this111,"topLayer");ot(_this111,"snapshotFullLayer");ot(_this111,"serviceWork");ot(_this111,"localWork");ot(_this111,"topLayerWork");ot(_this111,"snapshotWork");_this111._post=n;var i=me.bufferSize.sub;_this111.topLayer=r.isUseSimple?void 0:_this111.createLayer("topLayer",_this111.scene,_objectSpread(_objectSpread({},r.layerOpt),{},{bufferSize:i,contextType:"2d"}));var l={thread:_this111,viewId:_this111.viewId,vNodes:_this111.vNodes,fullLayer:_this111.fullLayer,topLayer:_this111.topLayer,isUseSimple:r.isUseSimple};_this111.localWork=new oy(l),r.isUseSimple||(_this111.topLayerWork=new ay(l)),_this111.vNodes.init(_this111.fullLayer),_this111.snapshotWork=new us({post:n,fullLayer:_this111.fullLayer,localWork:_this111.localWork,thread:_this111,viewId:t,getDpr:function getDpr(){return _this111.dpr;},getCameraOpt:function getCameraOpt(){return _this111.cameraOpt;},getOffscreen:_this111.getOffscreen,setCameraOpt:_this111.setCameraOpt,getSceneRect:_this111.getSceneRect,createLayer:_this111.createLayer});return _this111;}_inherits(Ps,_fs);return _createClass(Ps,[{key:"combinePost",value:function(){var _combinePost=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee84(){var _this112=this;var l,o,_this$combinePostData,t,r,n,a,_iterator75,_step75,c,m,i;return _regeneratorRuntime().wrap(function _callee84$(_context89){while(1)switch(_context89.prev=_context89.next){case 0:_this$combinePostData=this.combinePostData(),t=_this$combinePostData.render,r=_objectWithoutProperties(_this$combinePostData,_excluded3);if(!(t!=null&&t.length)){_context89.next=28;break;}a=[];_iterator75=_createForOfIteratorHelper(t);_context89.prev=4;_iterator75.s();case 6:if((_step75=_iterator75.n()).done){_context89.next=19;break;}c=_step75.value;if(!c.rect){_context89.next=17;break;}if(!(c.rect=cs(ue(c.rect),this.scene,this.dpr),!c.rect)){_context89.next=11;break;}return _context89.abrupt("continue",17);case 11:if(!(c.drawCanvas&&c.rect&&c.rect.w>0&&c.rect.h>0)){_context89.next=16;break;}_context89.next=14;return this.getRectImageBitmap(c);case 14:m=_context89.sent;c.imageBitmap=m,n||(n=[]),n.push(m);case 16:a.push(c);case 17:_context89.next=6;break;case 19:_context89.next=24;break;case 21:_context89.prev=21;_context89.t0=_context89["catch"](4);_iterator75.e(_context89.t0);case 24:_context89.prev=24;_iterator75.f();return _context89.finish(24);case 27:r.render=a;case 28:i=(l=r.sp)==null?void 0:l.filter(function(a){return a.type!==dt.None||a.isLockSentEventCursor;});i!=null&&i.length?r.sp=i.map(function(a){return _objectSpread(_objectSpread({},a),{},{viewId:_this112.viewId});}):delete r.sp,r.consumeCount===void 0&&delete r.consumeCount,r.subWorkerDrawCount===void 0&&delete r.subWorkerDrawCount,(i!=null&&i.length||r.consumeCount||r.subWorkerDrawCount||(o=r==null?void 0:r.render)!=null&&o.length)&&this._post(r,n),this.delayPostDoneResolve&&this.delayPostDoneResolve(!0);case 30:case"end":return _context89.stop();}},_callee84,this,[[4,21,24,27]]);}));function combinePost(){return _combinePost.apply(this,arguments);}return combinePost;}()},{key:"getLayer",value:function getLayer(t,r){if(r&&this.snapshotFullLayer)return this.snapshotFullLayer;switch(t){case Et.TopFloat:return this.topLayer||this.fullLayer;default:return this.fullLayer;}}},{key:"on",value:function(){var _on2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee85(t){var c,m,r,n,i,l,o,a,f;return _regeneratorRuntime().wrap(function _callee85$(_context90){while(1)switch(_context90.prev=_context90.next){case 0:r=t.msgType,n=t.toolsType,i=t.opt,l=t.dataType,o=t.workState,a=t.isLockSentEventCursor;_context90.t0=r;_context90.next=_context90.t0===dt.UpdateTools?4:_context90.t0===dt.CreateWork?9:_context90.t0===dt.DrawWork?11:_context90.t0===dt.RemoveNode?19:_context90.t0===dt.FullWork?22:_context90.t0===dt.Snapshot?27:_context90.t0===dt.BoundingBox?32:37;break;case 4:if(!(n&&(c=this.topLayerWork)!=null&&c.canUseTopLayer(n)&&i)){_context90.next=8;break;}f={toolsType:n,toolsOpt:i};this.topLayerWork.setToolsOpt(f);return _context90.abrupt("return");case 8:return _context90.abrupt("break",37);case 9:this.createLocalWork(t);return _context90.abrupt("return");case 11:if(!(o===Ft.Done&&l===Dt.Local)){_context90.next=17;break;}_context90.next=14;return this.consumeDrawAll(l,t);case 14:n===pt.LaserPen&&a&&this.post({sp:[{type:dt.None,isLockSentEventCursor:a}]});_context90.next=18;break;case 17:this.consumeDraw(l,t);case 18:return _context90.abrupt("return");case 19:_context90.next=21;return this.removeNode(t);case 21:return _context90.abrupt("return");case 22:_context90.t1=n&&(m=this.topLayerWork)!=null&&m.canUseTopLayer(n);if(!_context90.t1){_context90.next=26;break;}_context90.next=26;return this.consumeDrawAll(l,t);case 26:return _context90.abrupt("return");case 27:this.snapshotWork.createSnapshotFullLayer(this.scene,_objectSpread(_objectSpread({},this.opt.layerOpt),{},{bufferSize:this.viewId===hr?6e3:3e3,contextType:"2d"}));_context90.next=30;return this.snapshotWork.getSnapshot(t);case 30:this.snapshotWork.destroySnapshotFullLayer();return _context90.abrupt("return");case 32:this.snapshotWork.createSnapshotFullLayer(this.scene,_objectSpread(_objectSpread({},this.opt.layerOpt),{},{bufferSize:this.viewId===hr?6e3:3e3,contextType:"2d"}));_context90.next=35;return this.snapshotWork.getBoundingRect(t);case 35:this.snapshotWork.destroySnapshotFullLayer();return _context90.abrupt("return");case 37:_context90.next=39;return _superPropGet(Ps,"on",this,3)([t]);case 39:case"end":return _context90.stop();}},_callee85,this);}));function on(_x152){return _on2.apply(this,arguments);}return on;}()},{key:"createLocalWork",value:function createLocalWork(t){var l;var r=t.workId,n=t.toolsType,i=t.opt;if(n&&(l=this.topLayerWork)!=null&&l.canUseTopLayer(n)&&r&&i){this.topLayerWork.getToolsOpt()||this.topLayerWork.setToolsOpt({toolsType:n,toolsOpt:i}),this.topLayerWork.setWorkOptions(r.toString(),i);return;}n&&_superPropGet(Ps,"createLocalWork",this,3)([t]);}},{key:"removeNode",value:function(){var _removeNode2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee86(t){var r;return _regeneratorRuntime().wrap(function _callee86$(_context91){while(1)switch(_context91.prev=_context91.next){case 0:r=t.dataType;_context91.t0=r===Dt.Local;if(!_context91.t0){_context91.next=5;break;}_context91.next=5;return this.localWork.removeWork(t);case 5:case"end":return _context91.stop();}},_callee86,this);}));function removeNode(_x153){return _removeNode2.apply(this,arguments);}return removeNode;}()},{key:"getOffscreen",value:function getOffscreen(t,r){var i;return((i=this.getLayer(t,r))==null?void 0:i.parent).canvas;}},{key:"consumeDraw",value:function(){var _consumeDraw5=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee87(t,r){var l,n,i;return _regeneratorRuntime().wrap(function _callee87$(_context92){while(1)switch(_context92.prev=_context92.next){case 0:n=r.workId,i=r.toolsType;if(!n){_context92.next=11;break;}if(!(i&&(l=this.topLayerWork)!=null&&l.canUseTopLayer(i))){_context92.next=5;break;}t===Dt.Local&&(this.topLayerWork.getWorkShape(n.toString())||this.createLocalWork(r)),this.topLayerWork.consumeDraw(r);return _context92.abrupt("return");case 5:_context92.t0=i;if(!_context92.t0){_context92.next=10;break;}this.localWork.getWorkShape(n.toString())||this.createLocalWork(r);_context92.next=10;return this.localWork.consumeDraw(r);case 10:return _context92.abrupt("return");case 11:case"end":return _context92.stop();}},_callee87,this);}));function consumeDraw(_x154,_x155){return _consumeDraw5.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee88(t,r){var o,n,i,l,a;return _regeneratorRuntime().wrap(function _callee88$(_context93){while(1)switch(_context93.prev=_context93.next){case 0:n=r.workId,i=r.toolsType,l=r.dataType;if(!n){_context93.next=8;break;}a=n.toString();if(!(i&&(o=this.topLayerWork)!=null&&o.canUseTopLayer(i))){_context93.next=6;break;}l===Dt.Local&&(this.topLayerWork.getWorkShape(a)||this.createLocalWork(r)),this.topLayerWork.consumeDrawAll(r);return _context93.abrupt("return");case 6:i&&(this.localWork.getWorkShape(a)||_superPropGet(Ps,"createLocalWork",this,3)([r]),this.localWork.consumeDrawAll(r));return _context93.abrupt("return");case 8:case"end":return _context93.stop();}},_callee88,this);}));function consumeDrawAll(_x156,_x157){return _consumeDrawAll4.apply(this,arguments);}return consumeDrawAll;}()},{key:"clearAll",value:function(){var _clearAll2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee89(){return _regeneratorRuntime().wrap(function _callee89$(_context94){while(1)switch(_context94.prev=_context94.next){case 0:this.vNodes.clear();_superPropGet(Ps,"clearAll",this,3)([]);this.topLayer&&(this.topLayer.parent.children.forEach(function(t){t.name!=="viewport"&&t.remove();}),Se(this.topLayer,this.topLayer.parent));_context94.next=5;return this.post({render:[{isClearAll:!0,clearCanvas:Et.TopFloat,viewId:this.viewId}],sp:[{type:dt.Clear}]});case 5:case"end":return _context94.stop();}},_callee89,this);}));function clearAll(){return _clearAll2.apply(this,arguments);}return clearAll;}()},{key:"getRectImageBitmap",value:function getRectImageBitmap(t){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!1;var n=arguments.length>2?arguments[2]:undefined;var i=t.rect,l=t.drawCanvas,o=Math.floor(i.x*this.dpr),a=Math.floor(i.y*this.dpr),c=Math.floor(i.w*this.dpr||1),m=Math.floor(i.h*this.dpr||1);return createImageBitmap(this.getOffscreen(l,r),o,a,c,m,n);}},{key:"updateLayer",value:function updateLayer(t){var r=t.width,n=t.height;_superPropGet(Ps,"updateLayer",this,3)([t]),this.topLayer&&(this.topLayer.parent.setAttribute("width",r),this.topLayer.parent.setAttribute("height",n),this.topLayer.setAttribute("size",[r,n]),this.topLayer.setAttribute("pos",[r*0.5,n*0.5])),this.snapshotFullLayer&&(this.snapshotFullLayer.parent.setAttribute("width",r),this.snapshotFullLayer.parent.setAttribute("height",n),this.snapshotFullLayer.setAttribute("size",[r,n]),this.snapshotFullLayer.setAttribute("pos",[r*0.5,n*0.5]));}},{key:"updateDpr",value:function(){var _updateDpr2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee90(t){var r,n,i;return _regeneratorRuntime().wrap(function _callee90$(_context95){while(1)switch(_context95.prev=_context95.next){case 0:_superPropGet(Ps,"updateDpr",this,3)([t]);r=this.topLayerWork&&!!this.topLayerWork.localWorkShapes.size||!1,n=!!this.localWork.getWorkShapes().size,i=[];n&&i.push({isClearAll:!0,clearCanvas:Et.Float,viewId:this.viewId});r&&i.push({isClearAll:!0,clearCanvas:Et.TopFloat,viewId:this.viewId});_context95.t0=i.length;if(!_context95.t0){_context95.next=8;break;}_context95.next=8;return this.post({render:i});case 8:case"end":return _context95.stop();}},_callee90,this);}));function updateDpr(_x158){return _updateDpr2.apply(this,arguments);}return updateDpr;}()},{key:"updateCamera",value:function(){var _updateCamera=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee91(t){var _this113=this;var i,r,n,l,o,_iterator76,_step76,_loop9;return _regeneratorRuntime().wrap(function _callee91$(_context97){while(1)switch(_context97.prev=_context97.next){case 0:r=[],n=t.cameraOpt;if(!(n&&!Me(this.cameraOpt,n))){_context97.next=25;break;}l=this.topLayerWork&&!!this.topLayerWork.localWorkShapes.size||!1,o=!!this.localWork.getWorkShapes().size;if(!(o&&this.localWork.workShapesDone(),this.setCameraOpt(n),o&&r.push({isClearAll:!0,clearCanvas:Et.Float,viewId:this.viewId}),l&&this.topLayerWork)){_context97.next=21;break;}r.push({isClearAll:!0,clearCanvas:Et.TopFloat,viewId:this.viewId});_iterator76=_createForOfIteratorHelper(this.topLayerWork.localWorkShapes.entries()||[]);_context97.prev=6;_loop9=/*#__PURE__*/_regeneratorRuntime().mark(function _loop9(){var _step76$value,a,c,m;return _regeneratorRuntime().wrap(function _loop9$(_context96){while(1)switch(_context96.prev=_context96.next){case 0:_step76$value=_slicedToArray(_step76.value,2),a=_step76$value[0],c=_step76$value[1];if(c.totalRect){(i=_this113.topLayer)==null||i.getElementsByName(a.toString()).forEach(function(f){var v=f.getBoundingClientRect(),S=kt({x:v.x,y:v.y,w:v.width,h:v.height});m=bt(m,S);}),c.totalRect=m,_this113.topLayerWork.localWorkShapes.set(a,c);}case 2:case"end":return _context96.stop();}},_loop9);});_iterator76.s();case 9:if((_step76=_iterator76.n()).done){_context97.next=13;break;}return _context97.delegateYield(_loop9(),"t0",11);case 11:_context97.next=9;break;case 13:_context97.next=18;break;case 15:_context97.prev=15;_context97.t1=_context97["catch"](6);_iterator76.e(_context97.t1);case 18:_context97.prev=18;_iterator76.f();return _context97.finish(18);case 21:_context97.t2=r.length;if(!_context97.t2){_context97.next=25;break;}_context97.next=25;return this.post({render:r});case 25:case"end":return _context97.stop();}},_callee91,this,[[6,15,18,21]]);}));function updateCamera(_x159){return _updateCamera.apply(this,arguments);}return updateCamera;}()},{key:"setCameraOpt",value:function setCameraOpt(t,r){var c,m;this.cameraOpt=t;var n=t.scale,i=t.centerX,l=t.centerY,o=t.width,a=t.height;(o!==this.scene.width||a!==this.scene.height)&&this.updateScene(this.scene,{width:o,height:a}),r?(r.setAttribute("scale",[n,n]),r.setAttribute("translate",[-i,-l])):(this.fullLayer.setAttribute("scale",[n,n]),this.fullLayer.setAttribute("translate",[-i,-l]),(c=this.topLayer)==null||c.setAttribute("scale",[n,n]),(m=this.topLayer)==null||m.setAttribute("translate",[-i,-l]));}}]);}(fs);var Ss=/*#__PURE__*/function(_fs2){function Ss(t,r,n){var _this114;_classCallCheck(this,Ss);_this114=_callSuper(this,Ss,[t,r,"full"/* Full */]);ot(_this114,"serviceDrawLayer");ot(_this114,"localDrawLayer");ot(_this114,"snapshotFullLayer");ot(_this114,"methodBuilder");ot(_this114,"localWork");ot(_this114,"serviceWork");ot(_this114,"_post");ot(_this114,"debounceUpdateCache",/* @__PURE__ */new Set());_this114._post=n;var i=me.bufferSize.sub;_this114.serviceDrawLayer=_this114.createLayer("serviceDrawLayer",_this114.scene,_objectSpread(_objectSpread({},r.layerOpt),{},{bufferSize:i,contextType:"2d"})),_this114.localDrawLayer=_this114.createLayer("localDrawLayer",_this114.scene,_objectSpread(_objectSpread({},r.layerOpt),{},{bufferSize:i,contextType:"2d"}));var l={thread:_this114,viewId:_this114.viewId,vNodes:_this114.vNodes,fullLayer:_this114.fullLayer};_this114.localWork=new ys(_objectSpread(_objectSpread({},l),{},{drawLayer:_this114.localDrawLayer})),r.combineUnitTime&&_this114.localWork.setCombineUnitTime(r.combineUnitTime),r.maxCombineEraserTime&&_this114.localWork.setmaxCombineEraserTime(r.maxCombineEraserTime),r.syncUnitTime&&_this114.localWork.setSyncUnitTime(r.syncUnitTime),_this114.serviceWork=new gs(_objectSpread(_objectSpread({},l),{},{drawLayer:_this114.serviceDrawLayer})),_this114.methodBuilder=new pi([$t.CopyNode,$t.SetColorNode,$t.DeleteNode,$t.RotateNode,$t.ScaleNode,$t.TranslateNode,$t.ZIndexNode,$t.SetFontStyle,$t.SetPoint,$t.SetLock,$t.SetShapeOpt]).registerForWorker(_this114),_this114.vNodes.init(_this114.fullLayer);return _this114;}_inherits(Ss,_fs2);return _createClass(Ss,[{key:"combinePost",value:function(){var _combinePost2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee92(){var _this115=this;var l,o,_this$combinePostData2,t,r,n,a,_iterator77,_step77,c,m,i;return _regeneratorRuntime().wrap(function _callee92$(_context98){while(1)switch(_context98.prev=_context98.next){case 0:_this$combinePostData2=this.combinePostData(),t=_this$combinePostData2.render,r=_objectWithoutProperties(_this$combinePostData2,_excluded4);if(!(t!=null&&t.length)){_context98.next=28;break;}a=[];_iterator77=_createForOfIteratorHelper(t);_context98.prev=4;_iterator77.s();case 6:if((_step77=_iterator77.n()).done){_context98.next=19;break;}c=_step77.value;if(!c.rect){_context98.next=17;break;}if(!(c.rect=cs(ue(c.rect),this.scene,this.dpr),!c.rect)){_context98.next=11;break;}return _context98.abrupt("continue",17);case 11:if(!(c.drawCanvas&&c.rect&&c.rect.w>0&&c.rect.h>0)){_context98.next=16;break;}_context98.next=14;return this.getRectImageBitmap(c);case 14:m=_context98.sent;c.imageBitmap=m,n||(n=[]),n.push(m);case 16:a.push(c);case 17:_context98.next=6;break;case 19:_context98.next=24;break;case 21:_context98.prev=21;_context98.t0=_context98["catch"](4);_iterator77.e(_context98.t0);case 24:_context98.prev=24;_iterator77.f();return _context98.finish(24);case 27:r.render=a;case 28:i=(l=r.sp)==null?void 0:l.filter(function(a){return a.type!==dt.None||a.isLockSentEventCursor;});i!=null&&i.length?r.sp=i.map(function(a){return _objectSpread(_objectSpread({},a),{},{viewId:_this115.viewId});}):delete r.sp,r.fullWorkerDrawCount===void 0&&delete r.fullWorkerDrawCount,r.consumeCount===void 0&&delete r.consumeCount,(r!=null&&r.fullWorkerDrawCount||r.consumeCount||i!=null&&i.length||(o=r.render)!=null&&o.length)&&this._post(r,n),this.delayPostDoneResolve&&this.delayPostDoneResolve(!0);case 30:case"end":return _context98.stop();}},_callee92,this,[[4,21,24,27]]);}));function combinePost(){return _combinePost2.apply(this,arguments);}return combinePost;}()},{key:"on",value:function(){var _on3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee93(t){var _this116=this;var r,n,i,l,o,a,c,m,_c8;return _regeneratorRuntime().wrap(function _callee93$(_context99){while(1)switch(_context99.prev=_context99.next){case 0:if(!this.methodBuilder.consumeForWorker(t)){_context99.next=2;break;}return _context99.abrupt("return");case 2:r=t.msgType,n=t.dataType,i=t.workId,l=t.toolsType,o=t.workState,a=t.workIds;_context99.t0=r;_context99.next=_context99.t0===dt.AuthClear?6:_context99.t0===dt.CreateWork?9:_context99.t0===dt.DrawWork?11:_context99.t0===dt.Select?20:_context99.t0===dt.UpdateNode?27:_context99.t0===dt.FullWork?27:_context99.t0===dt.RemoveNode?29:_context99.t0===dt.GetTextActive?32:_context99.t0===dt.CursorHover?35:_context99.t0===dt.CursorBlur?38:_context99.t0===dt.GetVNodeInfo?41:43;break;case 6:c=t.clearUids,m=t.localUid;this.vNodes.setCanClearUids(c),this.vNodes.setLocalUid(m);return _context99.abrupt("break",43);case 9:l!==pt.LaserPen&&this.createLocalWork(t);return _context99.abrupt("break",43);case 11:_context99.t1=l!==pt.LaserPen;if(!_context99.t1){_context99.next=19;break;}if(!(o===Ft.Done&&n===Dt.Local)){_context99.next=18;break;}_context99.next=16;return this.consumeDrawAll(n,t);case 16:_context99.next=19;break;case 18:this.consumeDraw(n,t);case 19:return _context99.abrupt("break",43);case 20:if(!(i===qt)){_context99.next=25;break;}_context99.next=23;return this.localWork.updateFullSelectWork(t);case 23:_context99.next=26;break;case 25:this.serviceWork.runSelectWork(t);case 26:return _context99.abrupt("return");case 27:this.consumeFull(n,t);return _context99.abrupt("return");case 29:_context99.next=31;return this.removeNode(t);case 31:return _context99.abrupt("return");case 32:_context99.next=34;return this.checkTextActive(t);case 34:return _context99.abrupt("return");case 35:_context99.next=37;return this.cursorHover(t);case 37:return _context99.abrupt("return");case 38:_context99.next=40;return this.cursorBlur();case 40:return _context99.abrupt("return");case 41:if(i&&a){_c8=a.map(function(m){return _this116.vNodes.get(m);});this.post({sp:[{type:dt.GetVNodeInfo,dataType:Dt.Worker,workId:i,vInfo:_c8}]});}return _context99.abrupt("break",43);case 43:_context99.next=45;return _superPropGet(Ss,"on",this,3)([t]);case 45:case"end":return _context99.stop();}},_callee93,this);}));function on(_x160){return _on3.apply(this,arguments);}return on;}()},{key:"removeNode",value:function(){var _removeNode3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee94(t){var _this117=this;var r,n,i,l,o,_iterator78,_step78,_loop10;return _regeneratorRuntime().wrap(function _callee94$(_context101){while(1)switch(_context101.prev=_context101.next){case 0:r=t.dataType,n=t.workId,i=t.removeIds,l=[],o=i||[];if(!(n&&o.push(n.toString()),o.length)){_context101.next=20;break;}_iterator78=_createForOfIteratorHelper(o);_context101.prev=3;_loop10=/*#__PURE__*/_regeneratorRuntime().mark(function _loop10(){var a;return _regeneratorRuntime().wrap(function _loop10$(_context100){while(1)switch(_context100.prev=_context100.next){case 0:a=_step78.value;a===qt?l.push(_this117.localWork.removeSelector(t,_this117)):r===Dt.Local?l.push(_this117.localWork.removeWork(t).then(function(){_this117.localWork.colloctEffectSelectWork(t),_this117.deleteCachedImagesByWorkId(a);})):r===Dt.Service&&l.push(_this117.serviceWork.removeWork(t).then(function(){_this117.localWork.colloctEffectSelectWork(t),_this117.deleteCachedImagesByWorkId(a);}));case 2:case"end":return _context100.stop();}},_loop10);});_iterator78.s();case 6:if((_step78=_iterator78.n()).done){_context101.next=10;break;}return _context101.delegateYield(_loop10(),"t0",8);case 8:_context101.next=6;break;case 10:_context101.next=15;break;case 12:_context101.prev=12;_context101.t1=_context101["catch"](3);_iterator78.e(_context101.t1);case 15:_context101.prev=15;_iterator78.f();return _context101.finish(15);case 18:_context101.next=20;return Promise.all(l);case 20:case"end":return _context101.stop();}},_callee94,null,[[3,12,15,18]]);}));function removeNode(_x161){return _removeNode3.apply(this,arguments);}return removeNode;}()},{key:"checkTextActive",value:function(){var _checkTextActive2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee95(t){var r;return _regeneratorRuntime().wrap(function _callee95$(_context102){while(1)switch(_context102.prev=_context102.next){case 0:r=t.dataType;_context102.t0=r===Dt.Local;if(!_context102.t0){_context102.next=5;break;}_context102.next=5;return this.localWork.checkTextActive(t);case 5:case"end":return _context102.stop();}},_callee95,this);}));function checkTextActive(_x162){return _checkTextActive2.apply(this,arguments);}return checkTextActive;}()},{key:"clearAll",value:function(){var _clearAll3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee96(){return _regeneratorRuntime().wrap(function _callee96$(_context103){while(1)switch(_context103.prev=_context103.next){case 0:this.vNodes.clear();_superPropGet(Ss,"clearAll",this,3)([]);this.localDrawLayer&&(this.localDrawLayer.parent.children.forEach(function(t){t.name!=="viewport"&&t.remove();}),Se(this.localDrawLayer,this.localDrawLayer.parent));this.serviceDrawLayer&&(this.serviceDrawLayer.parent.children.forEach(function(t){t.name!=="viewport"&&t.remove();}),Se(this.serviceDrawLayer,this.serviceDrawLayer.parent));_context103.next=6;return this.post({render:[{isClearAll:!0,clearCanvas:Et.Bg,viewId:this.viewId},{isClearAll:!0,clearCanvas:Et.ServiceFloat,viewId:this.viewId},{isClearAll:!0,clearCanvas:Et.Float,viewId:this.viewId}],sp:[{type:dt.Clear}]});case 6:case"end":return _context103.stop();}},_callee96,this);}));function clearAll(){return _clearAll3.apply(this,arguments);}return clearAll;}()},{key:"updateLayer",value:function updateLayer(t){var r=t.width,n=t.height;_superPropGet(Ss,"updateLayer",this,3)([t]),this.localDrawLayer&&(this.localDrawLayer.parent.setAttribute("width",r),this.localDrawLayer.parent.setAttribute("height",n),this.localDrawLayer.setAttribute("size",[r,n]),this.localDrawLayer.setAttribute("pos",[r*0.5,n*0.5])),this.serviceDrawLayer&&(this.serviceDrawLayer.parent.setAttribute("width",r),this.serviceDrawLayer.parent.setAttribute("height",n),this.serviceDrawLayer.setAttribute("size",[r,n]),this.serviceDrawLayer.setAttribute("pos",[r*0.5,n*0.5]));}},{key:"setCameraOpt",value:function setCameraOpt(t){this.cameraOpt=t;var r=t.scale,n=t.centerX,i=t.centerY,l=t.width,o=t.height;(l!==this.scene.width||o!==this.scene.height)&&this.updateScene(this.scene,{width:l,height:o}),this.fullLayer&&(this.fullLayer.setAttribute("scale",[r,r]),this.fullLayer.setAttribute("translate",[-n,-i])),this.localDrawLayer&&(this.localDrawLayer.setAttribute("scale",[r,r]),this.localDrawLayer.setAttribute("translate",[-n,-i])),this.serviceDrawLayer&&(this.serviceDrawLayer.setAttribute("scale",[r,r]),this.serviceDrawLayer.setAttribute("translate",[-n,-i]));}},{key:"getLayer",value:function getLayer(t){switch(t){case Et.Bg:return this.fullLayer;case Et.ServiceFloat:return this.serviceDrawLayer;case Et.Float:return this.localDrawLayer;}}},{key:"getOffscreen",value:function getOffscreen(t){return this.getLayer(t).parent.canvas;}},{key:"consumeFull",value:function(){var _consumeFull2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee97(t,r){var n;return _regeneratorRuntime().wrap(function _callee97$(_context104){while(1)switch(_context104.prev=_context104.next){case 0:_context104.next=2;return this.localWork.colloctEffectSelectWork(r);case 2:n=_context104.sent;_context104.t0=n&&t===Dt.Local;if(!_context104.t0){_context104.next=7;break;}_context104.next=7;return this.localWork.consumeFull(n);case 7:n&&t===Dt.Service&&this.serviceWork.consumeFull(n);case 8:case"end":return _context104.stop();}},_callee97,this);}));function consumeFull(_x163,_x164){return _consumeFull2.apply(this,arguments);}return consumeFull;}()},{key:"consumeDraw",value:function(){var _consumeDraw6=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee98(t,r){var n;return _regeneratorRuntime().wrap(function _callee98$(_context105){while(1)switch(_context105.prev=_context105.next){case 0:n=r.workId;_context105.t0=t===Dt.Local&&n;if(!_context105.t0){_context105.next=6;break;}this.localWork.getWorkShape(n.toString())||this.createLocalWork(r);_context105.next=6;return this.localWork.consumeDraw(r,this.serviceWork);case 6:t===Dt.Service&&this.serviceWork.consumeDraw(r);case 7:case"end":return _context105.stop();}},_callee98,this);}));function consumeDraw(_x165,_x166){return _consumeDraw6.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll5=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee99(t,r){var n;return _regeneratorRuntime().wrap(function _callee99$(_context106){while(1)switch(_context106.prev=_context106.next){case 0:n=r.workId;_context106.t0=t===Dt.Local&&n;if(!_context106.t0){_context106.next=6;break;}this.localWork.getWorkShape(n.toString())||this.createLocalWork(r);_context106.next=6;return this.localWork.consumeDrawAll(r,this.serviceWork);case 6:case"end":return _context106.stop();}},_callee99,this);}));function consumeDrawAll(_x167,_x168){return _consumeDrawAll5.apply(this,arguments);}return consumeDrawAll;}()},{key:"updateDpr",value:function(){var _updateDpr3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee100(t){return _regeneratorRuntime().wrap(function _callee100$(_context107){while(1)switch(_context107.prev=_context107.next){case 0:_superPropGet(Ss,"updateDpr",this,3)([t]);_context107.next=3;return this.post({render:[{isClearAll:!0,clearCanvas:Et.Bg,viewId:this.viewId},{isDrawAll:!0,drawCanvas:Et.Bg,viewId:this.viewId}]});case 3:case"end":return _context107.stop();}},_callee100,this);}));function updateDpr(_x169){return _updateDpr3.apply(this,arguments);}return updateDpr;}()},{key:"updateCamera",value:function(){var _updateCamera2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee101(t){var _this118=this;var l,o,a,c,m,r,n,i,f,P,_iterator79,_step79,_step79$value,_x171,_h47,v,_iterator80,_step80,_step80$value,_P27,_x176,_h50,_iterator81,_step81,_step81$value,_P28,_x177,_h51,S,E,_P23,_iterator82,_step82,_x172,T,_iterator83,_step83,_P24,_x173,_iterator84,_step84,_h48,_iterator85,_step85,_step85$value,_P26,_step85$value$,_x175,_h49,p,d,g,O,w,L,B,A,b,W,_iterator86,_step86,_step86$value,_P25,_x174;return _regeneratorRuntime().wrap(function _callee101$(_context108){while(1)switch(_context108.prev=_context108.next){case 0:r=[],n=t.cameraOpt,i=t.scenePath;if(!(n&&!Me(this.cameraOpt,n))){_context108.next=42;break;}this.taskUpdateCameraId&&(clearTimeout(this.taskUpdateCameraId),this.taskUpdateCameraId=void 0);f=!!this.serviceDrawLayer.children.length;if(!i){_context108.next=30;break;}P=!1;_iterator79=_createForOfIteratorHelper(this.localWork.getWorkShapes().entries());_context108.prev=7;_iterator79.s();case 9:if((_step79=_iterator79.n()).done){_context108.next=19;break;}_step79$value=_slicedToArray(_step79.value,2),_x171=_step79$value[0],_h47=_step79$value[1];_context108.t0=_h47.toolsType;_context108.next=_context108.t0===pt.Text?14:_context108.t0===pt.PencilEraser?14:_context108.t0===pt.Eraser?14:_context108.t0===pt.Selector?14:_context108.t0===pt.LaserPen?14:15;break;case 14:return _context108.abrupt("break",17);case 15:_x171!==He&&_x171!==qt&&(P=!0);return _context108.abrupt("break",17);case 17:_context108.next=9;break;case 19:_context108.next=24;break;case 21:_context108.prev=21;_context108.t1=_context108["catch"](7);_iterator79.e(_context108.t1);case 24:_context108.prev=24;_iterator79.f();return _context108.finish(24);case 27:if(!P){_context108.next=30;break;}this.taskUpdateCameraId=setTimeout(function(){_this118.taskUpdateCameraId=void 0,_this118.updateCamera(t);},si);return _context108.abrupt("return");case 30:v=/* @__PURE__ */new Map();_iterator80=_createForOfIteratorHelper(this.vNodes.getNodesByType(pt.Text).entries());try{for(_iterator80.s();!(_step80=_iterator80.n()).done;){_step80$value=_slicedToArray(_step80.value,2),_P27=_step80$value[0],_x176=_step80$value[1];_h50=_x176.rect;v.set(_P27,{rect:ue(_h50),scale:(l=this.cameraOpt)==null?void 0:l.scale});}}catch(err){_iterator80.e(err);}finally{_iterator80.f();}_iterator81=_createForOfIteratorHelper(this.vNodes.gethasEraserNodes().entries());try{for(_iterator81.s();!(_step81=_iterator81.n()).done;){_step81$value=_slicedToArray(_step81.value,2),_P28=_step81$value[0],_x177=_step81$value[1];_h51=_x177.rect;v.set(_P28,{rect:ue(_h51),scale:(o=this.cameraOpt)==null?void 0:o.scale});}}catch(err){_iterator81.e(err);}finally{_iterator81.f();}S=new Set(v.keys());E=!1;if(this.localWork.hasSelector()){_P23=(a=this.localWork.getSelector())==null?void 0:a.selectIds;if(_P23){E=!0;_iterator82=_createForOfIteratorHelper(_P23);try{for(_iterator82.s();!(_step82=_iterator82.n()).done;){_x172=_step82.value;S.add(_x172);}}catch(err){_iterator82.e(err);}finally{_iterator82.f();}}}T=!1;if(this.serviceWork.selectorWorkShapes.size){_iterator83=_createForOfIteratorHelper(this.serviceWork.selectorWorkShapes.values());try{for(_iterator83.s();!(_step83=_iterator83.n()).done;){_P24=_step83.value;_x173=_P24.selectIds;if(_x173){T=!0;_iterator84=_createForOfIteratorHelper(_x173);try{for(_iterator84.s();!(_step84=_iterator84.n()).done;){_h48=_step84.value;S.add(_h48);}}catch(err){_iterator84.e(err);}finally{_iterator84.f();}}}}catch(err){_iterator83.e(err);}finally{_iterator83.f();}}if(this.setCameraOpt(n),this.vNodes.curNodeMap.size){this.vNodes.clearTarget(),this.vNodes.updateHighLevelNodesRect(S),this.debounceUpdateCameraId&&clearTimeout(this.debounceUpdateCameraId);_iterator85=_createForOfIteratorHelper(v.entries());try{for(_iterator85.s();!(_step85=_iterator85.n()).done;){_step85$value=_slicedToArray(_step85.value,2),_P26=_step85$value[0],_step85$value$=_step85$value[1],_x175=_step85$value$.rect,_h49=_step85$value$.scale;p=this.vNodes.get(_P26);if(p){d=_x175,g=p.rect,O=this.getSceneRect(),w=or(d,O),L=or(g,O),B=p.toolsType,A=p.opt;b=!1;(w!==L||d.w!==g.w||d.h!==g.h||L===Pe.intersect)&&(b=!0),B===pt.Text&&A.workState===Ft.Done&&b&&this.debounceUpdateCache.add(_P26);W=!1;_h49&&(c=this.cameraOpt)!=null&&c.scale&&_h49>this.cameraOpt.scale?L!==Pe.outside&&w!==Pe.inside&&(W=!0):_h49&&(m=this.cameraOpt)!=null&&m.scale&&_h49===this.cameraOpt.scale&&(d.x!==g.x||d.y!==g.y)&&(L===Pe.inside&&w!==Pe.inside||L===Pe.intersect&&w===Pe.intersect)&&(W=!0),A.eraserlines&&A.eraserlines.length&&W&&!this.debounceUpdateCache.has(_P26)&&this.debounceUpdateCache.add(_P26);}}}catch(err){_iterator85.e(err);}finally{_iterator85.f();}if(E&&this.localWork.reRenderSelector(),T){_iterator86=_createForOfIteratorHelper(this.serviceWork.selectorWorkShapes.entries());try{for(_iterator86.s();!(_step86=_iterator86.n()).done;){_step86$value=_slicedToArray(_step86.value,2),_P25=_step86$value[0],_x174=_step86$value[1];this.serviceWork.runSelectWork({workId:_P25,selectIds:_x174.selectIds,msgType:dt.Select,dataType:Dt.Service,viewId:this.viewId});}}catch(err){_iterator86.e(err);}finally{_iterator86.f();}}this.debounceUpdateCameraId=setTimeout(function(){var x;_this118.debounceUpdateCameraId=void 0;var P=[];var _iterator87=_createForOfIteratorHelper(_this118.debounceUpdateCache.values()),_step87;try{var _loop11=function _loop11(){var h=_step87.value;var p=_this118.vNodes.get(h);if(p){var d=p.toolsType,g=p.opt,O=p.rect,w=p.op,L=_this118.localWork.setFullWork({toolsType:d,opt:g,workId:h});if(L){var B=_this118.getSceneRect(),A=or(O,B);d===pt.Text?(x=_this118.fullLayer)!=null&&x.getElementsByName(h)[0]&&L instanceof cr&&P.push(L.consumeServiceAsync({isFullWork:!0,replaceId:h,isDrawLabel:A!==Pe.outside})):g.eraserlines&&g.eraserlines.length&&P.push(new Promise(function(b){var W=L.consumeService({op:w,isFullWork:!0,replaceId:h,workState:Ft.Done});_this118.localWork.clearWorkShapeNodeCache(h),b(W);}));}}_this118.debounceUpdateCache["delete"](h);};for(_iterator87.s();!(_step87=_iterator87.n()).done;){_loop11();}}catch(err){_iterator87.e(err);}finally{_iterator87.f();}P.length?Promise.all(P).then(function(){var h=[];h.push({isClearAll:!0,clearCanvas:Et.Bg,viewId:_this118.viewId},{isDrawAll:!0,drawCanvas:Et.Bg,viewId:_this118.viewId}),h.length&&_this118.post({render:h}),_this118.vNodes.updateLowLevelNodesRect(),_this118.vNodes.clearHighLevelIds();}):(_this118.vNodes.updateLowLevelNodesRect(),_this118.vNodes.clearHighLevelIds());},si*10);}f&&r.push({isClearAll:!0,clearCanvas:Et.ServiceFloat,viewId:this.viewId}),this.vNodes.hasRenderNodes()&&r.push({isClearAll:!0,clearCanvas:Et.Bg,viewId:this.viewId},{isDrawAll:!0,drawCanvas:Et.Bg,viewId:this.viewId}),r.length&&this.post({render:r});case 42:case"end":return _context108.stop();}},_callee101,this,[[7,21,24,27]]);}));function updateCamera(_x170){return _updateCamera2.apply(this,arguments);}return updateCamera;}()},{key:"getRectImageBitmap",value:function getRectImageBitmap(t){var r=t.rect,n=t.drawCanvas,i=Math.floor(r.x*this.dpr),l=Math.floor(r.y*this.dpr),o=Math.floor(r.w*this.dpr||1),a=Math.floor(r.h*this.dpr||1);return createImageBitmap(this.getOffscreen(n),i,l,o,a,{resizeQuality:"low"});}},{key:"cursorHover",value:function(){var _cursorHover2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee102(t){return _regeneratorRuntime().wrap(function _callee102$(_context109){while(1)switch(_context109.prev=_context109.next){case 0:_context109.next=2;return this.localWork.cursorHover(t);case 2:case"end":return _context109.stop();}},_callee102,this);}));function cursorHover(_x178){return _cursorHover2.apply(this,arguments);}return cursorHover;}()},{key:"cursorBlur",value:function(){var _cursorBlur2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee103(){return _regeneratorRuntime().wrap(function _callee103$(_context110){while(1)switch(_context110.prev=_context110.next){case 0:_context110.next=2;return this.localWork.cursorBlur();case 2:case"end":return _context110.stop();}},_callee103,this);}));function cursorBlur(){return _cursorBlur2.apply(this,arguments);}return cursorBlur;}()},{key:"destroy",value:function destroy(){_superPropGet(Ss,"destroy",this,3)([]);}}]);}(fs);var hy=/*#__PURE__*/function(_Ss){function hy(t,r,n){var _this119;_classCallCheck(this,hy);var l,o,a,c;_this119=_callSuper(this,hy,[t,r,n]);ot(_this119,"snapshotWork");ot(_this119,"localDrawScene");ot(_this119,"serviceDrawScene");ot(_this119,"offscreenCanvas");ot(_this119,"localWork");ot(_this119,"serviceWork");if(_this119._post=n,r.offscreenCanvas){_this119.offscreenCanvas=r.offscreenCanvas,_this119.localDrawScene=_this119.createScene(r,(l=_this119.offscreenCanvas)==null?void 0:l.localCanvas),_this119.serviceDrawScene=_this119.createScene(r,(o=_this119.offscreenCanvas)==null?void 0:o.serviceCanvas);var m=me.bufferSize.sub;_this119.serviceDrawLayer=_this119.createLayer("serviceDrawLayer",_this119.serviceDrawScene||_this119.scene,_objectSpread(_objectSpread({},r.layerOpt),{},{bufferSize:m,contextType:"2d"}),(a=_this119.offscreenCanvas)==null?void 0:a.serviceCanvas),_this119.localDrawLayer=_this119.createLayer("localDrawLayer",_this119.localDrawScene||_this119.scene,_objectSpread(_objectSpread({},r.layerOpt),{},{bufferSize:m,contextType:"2d"}),(c=_this119.offscreenCanvas)==null?void 0:c.localCanvas);}var i={thread:_this119,viewId:_this119.viewId,vNodes:_this119.vNodes,fullLayer:_this119.fullLayer};_this119.localWork=new ly(_objectSpread(_objectSpread({},i),{},{drawLayer:_this119.localDrawLayer})),r.combineUnitTime&&_this119.localWork.setCombineUnitTime(r.combineUnitTime),r.maxCombineEraserTime&&_this119.localWork.setmaxCombineEraserTime(r.maxCombineEraserTime),r.syncUnitTime&&_this119.localWork.setSyncUnitTime(r.syncUnitTime),_this119.serviceWork=new cy(_objectSpread(_objectSpread({},i),{},{drawLayer:_this119.serviceDrawLayer})),_this119.snapshotWork=new us({post:n,fullLayer:_this119.fullLayer,localWork:_this119.localWork,viewId:t,thread:_this119,getDpr:function getDpr(){return _this119.dpr;},getCameraOpt:function getCameraOpt(){return _this119.cameraOpt;},getOffscreen:_this119.getOffscreen,setCameraOpt:_this119.setCameraOpt,getSceneRect:_this119.getSceneRect,createLayer:_this119.createLayer}),_this119.methodBuilder=new pi([$t.CopyNode,$t.SetColorNode,$t.DeleteNode,$t.RotateNode,$t.ScaleNode,$t.TranslateNode,$t.ZIndexNode,$t.SetFontStyle,$t.SetPoint,$t.SetLock,$t.SetShapeOpt]).registerForWorker(_this119);return _this119;}_inherits(hy,_Ss);return _createClass(hy,[{key:"createRenderLayer",value:function createRenderLayer(t,r,n){var o;var i=me.bufferSize.full,l=me.bufferSize.sub;this.fullLayer=this.createLayer("fullLayer",t,_objectSpread(_objectSpread({},r.layerOpt),{},{bufferSize:this.viewId===hr?i:l*2}),n||((o=r.offscreenCanvas)==null?void 0:o.bgCanvas));}},{key:"createScene",value:function createScene(t,r){var n=t.offscreenCanvas,i=t.offscreenCanvasOpt,l=i.width,o=i.height,a=r||(n==null?void 0:n.bgCanvas)||new OffscreenCanvas(l,o);i.contextType&&delete i.contextType;var c=new ui(_objectSpread(_objectSpread({container:a,displayRatio:this.dpr,depth:!1,desynchronized:!0,failIfMajorPerformanceCaveat:!0},i),{},{contextType:this.contextType,id:this.viewId}));return c.setAttribute("id",this.viewId),c;}},{key:"combinePostData",value:function combinePostData(){var l,o;this.workerTaskId=void 0;var t=[],r=[];var n;var i=/* @__PURE__ */new Set();var _iterator88=_createForOfIteratorHelper(this.combinePostMsg.values()),_step88;try{for(_iterator88.s();!(_step88=_iterator88.n()).done;){var a=_step88.value;if((l=a.render)!=null&&l.length)if(this.offscreenCanvas){var _iterator89=_createForOfIteratorHelper(a.render),_step89;try{for(_iterator89.s();!(_step89=_iterator89.n()).done;){var c=_step89.value;c.workId&&i.add(c.workId);var m=c.drawCanvas||c.clearCanvas;if(m){var f=this.getLayer(m);if(!f||!(f.parent instanceof $r))continue;f.parent.render();}}}catch(err){_iterator89.e(err);}finally{_iterator89.f();}}else{var _iterator90=_createForOfIteratorHelper(a.render),_step90;try{for(_iterator90.s();!(_step90=_iterator90.n()).done;){var _c9=_step90.value;var _m15=!1;if(_c9.workId&&i.add(_c9.workId),_c9.isClearAll&&(_c9.rect=this.getSceneRect(),_c9.isClear=!0,delete _c9.isClearAll),_c9.drawCanvas){var _f9=this.getLayer(_c9.drawCanvas);if(!_f9||!(_f9.parent instanceof $r))continue;if(_f9.parent.render(),_c9.isDrawAll){var v=this.getSceneRect();_c9.rect=v,delete _c9.isDrawAll;}}var _iterator91=_createForOfIteratorHelper(t),_step91;try{for(_iterator91.s();!(_step91=_iterator91.n()).done;){var _f10=_step91.value;if(_c9.viewId===_f10.viewId){_c9.isClear&&_f10.clearCanvas&&_f10.isClear&&_f10.clearCanvas===_c9.clearCanvas&&(_f10.rect=bt(_f10.rect,_c9.rect),_m15=!0),_f10.drawCanvas&&_f10.drawCanvas===_c9.drawCanvas&&(_f10.rect=bt(_f10.rect,_c9.rect),_m15=!0);continue;}}}catch(err){_iterator91.e(err);}finally{_iterator91.f();}_m15||(_c9.isClear&&!_c9.drawCanvas?t.unshift(_c9):t.push(_c9));}}catch(err){_iterator90.e(err);}finally{_iterator90.f();}}if((o=a.sp)!=null&&o.length){var _iterator92=_createForOfIteratorHelper(a.sp),_step92;try{for(_iterator92.s();!(_step92=_iterator92.n()).done;){var _c10=_step92.value;var _m16=!1;var _iterator93=_createForOfIteratorHelper(r),_step93;try{for(_iterator93.s();!(_step93=_iterator93.n()).done;){var _f11=_step93.value;if(Me(_c10,_f11)){_m16=!0;break;}}}catch(err){_iterator93.e(err);}finally{_iterator93.f();}_m16||r.push(_c10);}}catch(err){_iterator92.e(err);}finally{_iterator92.f();}}he(a.consumeCount)&&(n=a.consumeCount);}}catch(err){_iterator88.e(err);}finally{_iterator88.f();}return this.combinePostMsg.clear(),{render:t,sp:r,consumeCount:n,workIds:i,viewId:this.viewId};}},{key:"on",value:function(){var _on4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee104(t){var r;return _regeneratorRuntime().wrap(function _callee104$(_context111){while(1)switch(_context111.prev=_context111.next){case 0:if(!this.methodBuilder.consumeForWorker(t)){_context111.next=2;break;}return _context111.abrupt("return");case 2:r=t.msgType;_context111.t0=r;_context111.next=_context111.t0===dt.Snapshot?6:_context111.t0===dt.BoundingBox?11:16;break;case 6:this.snapshotWork.createSnapshotFullLayer(this.scene,this.opt.layerOpt);_context111.next=9;return this.snapshotWork.getSnapshot(t);case 9:this.snapshotWork.destroySnapshotFullLayer();return _context111.abrupt("return");case 11:this.snapshotWork.createSnapshotFullLayer(this.scene,this.opt.layerOpt);_context111.next=14;return this.snapshotWork.getBoundingRect(t);case 14:this.snapshotWork.destroySnapshotFullLayer();return _context111.abrupt("return");case 16:_context111.next=18;return _superPropGet(hy,"on",this,3)([t]);case 18:case"end":return _context111.stop();}},_callee104,this);}));function on(_x179){return _on4.apply(this,arguments);}return on;}()},{key:"setCameraOpt",value:function setCameraOpt(t){if(this.localDrawScene&&this.serviceDrawScene){var r=t.width,n=t.height;(r!==this.localDrawScene.width||n!==this.localDrawScene.height)&&this.updateScene(this.localDrawScene,{width:r,height:n},this.localDrawLayer),(r!==this.serviceDrawScene.width||n!==this.serviceDrawScene.height)&&this.updateScene(this.serviceDrawScene,{width:r,height:n},this.serviceDrawLayer);}_superPropGet(hy,"setCameraOpt",this,3)([t]);}},{key:"updateDpr",value:function(){var _updateDpr4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee105(t){return _regeneratorRuntime().wrap(function _callee105$(_context112){while(1)switch(_context112.prev=_context112.next){case 0:this.localDrawScene&&this.serviceDrawScene&&(this.localDrawScene.displayRatio=t,this.serviceDrawScene.displayRatio=t),_superPropGet(hy,"updateDpr",this,3)([t]);case 1:case"end":return _context112.stop();}},_callee105,this);}));function updateDpr(_x180){return _updateDpr4.apply(this,arguments);}return updateDpr;}()}]);}(Ss);var hi=self;hi.full=new fy(hi,wr.Full);