@netless/appliance-plugin 1.1.14-beta.0 → 1.1.14-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/cdn.js +1 -1
- package/cdn/{fullWorker-CU-58a.js → fullWorker-CUsksx.js} +5 -5
- package/cdn/{subWorker-D5mpo3.js → subWorker-cNQ5uE.js} +5 -5
- package/dist/appliance-plugin.js +1 -1
- package/dist/appliance-plugin.mjs +1 -1
- package/dist/collector/collector.d.ts +1 -1
- package/dist/core/renderCotrol.d.ts +1 -1
- package/dist/fullWorker.js +5 -5
- package/dist/index-BSM4GXSD.js +1 -0
- package/dist/{index-CrpL9wA9.mjs → index-D5vax7MJ.mjs} +2 -1
- package/dist/{index-B3RMMnuz.mjs → index-DvFs8TTv.mjs} +2694 -2709
- package/dist/index-tiKesnMr.js +1 -0
- package/dist/subWorker.js +5 -5
- package/package.json +1 -1
- package/dist/index-CKH81YBR.js +0 -1
- package/dist/index-CaVWchrK.js +0 -1
package/dist/fullWorker.js
CHANGED
|
@@ -396,7 +396,7 @@ _inherits(o,_e$default22);return _createClass(o,[{key:"texture",get:function get
|
|
|
396
396
|
l=="length"||// Node.js 0.10 has enumerable non-index properties on buffers.
|
|
397
397
|
n&&(l=="offset"||l=="parent")||// PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
398
398
|
i&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||// Skip index properties.
|
|
399
|
-
mc(l,s)))&&o.push(l);return o;}var Jn=xc,Tc=Object.prototype;function Mc(h){var r=h&&h.constructor,t=typeof r=="function"&&r.prototype||Tc;return h===t;}var Er=Mc;function Pc(h,r){return function(t){return h(r(t));};}var Zn=Pc,Oc=Zn,Ec=Oc(Object.keys,Object),Cc=Ec,Ac=Er,Rc=Cc,Ic=Object.prototype,Lc=Ic.hasOwnProperty;function wc(h){if(!Ac(h))return Rc(h);var r=[];for(var t in Object(h))Lc.call(h,t)&&t!="constructor"&&r.push(t);return r;}var bc=wc,Dc=Un,Nc=kn;function Wc(h){return h!=null&&Nc(h.length)&&!Dc(h);}var Cr=Wc,Bc=Jn,Fc=bc,Uc=Cr;function jc(h){return Uc(h)?Bc(h):Fc(h);}var Ar=jc,$c=ir,zc=Ar;function Gc(h,r){return h&&$c(r,zc(r),h);}var Hc=Gc;function Kc(h){var r=[];if(h!=null)for(var t in Object(h))r.push(t);return r;}var Yc=Kc,Vc=he,kc=Er,Xc=Yc,Jc=Object.prototype,Zc=Jc.hasOwnProperty;function Qc(h){if(!Vc(h))return Xc(h);var r=kc(h),t=[];for(var e in h)e=="constructor"&&(r||!Zc.call(h,e))||t.push(e);return t;}var qc=Qc,_c=Jn,tf=qc,ef=Cr;function rf(h){return ef(h)?_c(h,!0):tf(h);}var Rr=rf,nf=ir,sf=Rr;function of(h,r){return h&&nf(r,sf(r),h);}var af=of,He={exports:{}};He.exports;(function(h,r){var t=ee,e=r&&!r.nodeType&&r,n=e&&!0&&h&&!h.nodeType&&h,i=n&&n.exports===e,a=i?t.Buffer:void 0,o=a?a.allocUnsafe:void 0;function s(l,g){if(g)return l.slice();var c=l.length,d=o?o(c):new l.constructor(c);return l.copy(d),d;}h.exports=s;})(He,He.exports);var lf=He.exports;function cf(h,r){var t=-1,e=h.length;for(r||(r=Array(e));++t<e;)r[t]=h[t];return r;}var ff=cf;function hf(h,r){for(var t=-1,e=h==null?0:h.length,n=0,i=[];++t<e;){var a=h[t];r(a,t,h)&&(i[n++]=a);}return i;}var Qn=hf;function uf(){return[];}var qn=uf,df=Qn,pf=qn,gf=Object.prototype,mf=gf.propertyIsEnumerable,_r=Object.getOwnPropertySymbols,vf=_r?function(h){return h==null?[]:(h=Object(h),df(_r(h),function(r){return mf.call(h,r);}));}:pf,Ir=vf,yf=ir,Sf=Ir;function xf(h,r){return yf(h,Sf(h),r);}var Tf=xf;function Mf(h,r){for(var t=-1,e=r.length,n=h.length;++t<e;)h[n+t]=r[t];return h;}var Lr=Mf,Pf=Zn,Of=Pf(Object.getPrototypeOf,Object),_n=Of,Ef=Lr,Cf=_n,Af=Ir,Rf=qn,If=Object.getOwnPropertySymbols,Lf=If?function(h){for(var r=[];h;)Ef(r,Af(h)),h=Cf(h);return r;}:Rf,ti=Lf,wf=ir,bf=ti;function Df(h,r){return wf(h,bf(h),r);}var Nf=Df,Wf=Lr,Bf=Fe;function Ff(h,r,t){var e=r(h);return Bf(h)?e:Wf(e,t(h));}var ei=Ff,Uf=ei,jf=Ir,$f=Ar;function zf(h){return Uf(h,$f,jf);}var ri=zf,Gf=ei,Hf=ti,Kf=Rr;function Yf(h){return Gf(h,Kf,Hf);}var Vf=Yf,kf=pe,Xf=ee,Jf=kf(Xf,"DataView"),Zf=Jf,Qf=pe,qf=ee,_f=Qf(qf,"Promise"),th=_f,eh=pe,rh=ee,nh=eh(rh,"Set"),ni=nh,ih=pe,sh=ee,oh=ih(sh,"WeakMap"),ah=oh,dr=Zf,pr=Mr,gr=th,mr=ni,vr=ah,ii=de,Re=jn,tn="[object Map]",lh="[object Object]",en="[object Promise]",rn="[object Set]",nn="[object WeakMap]",sn="[object DataView]",ch=Re(dr),fh=Re(pr),hh=Re(gr),uh=Re(mr),dh=Re(vr),ue=ii;(dr&&ue(new dr(new ArrayBuffer(1)))!=sn||pr&&ue(new pr())!=tn||gr&&ue(gr.resolve())!=en||mr&&ue(new mr())!=rn||vr&&ue(new vr())!=nn)&&(ue=function ue(h){var r=ii(h),t=r==lh?h.constructor:void 0,e=t?Re(t):"";if(e)switch(e){case ch:return sn;case fh:return tn;case hh:return en;case uh:return rn;case dh:return nn;}return r;});var or=ue,ph=Object.prototype,gh=ph.hasOwnProperty;function mh(h){var r=h.length,t=new h.constructor(r);return r&&typeof h[0]=="string"&&gh.call(h,"index")&&(t.index=h.index,t.input=h.input),t;}var vh=mh,yh=ee,Sh=yh.Uint8Array,si=Sh,on=si;function xh(h){var r=new h.constructor(h.byteLength);return new on(r).set(new on(h)),r;}var wr=xh,Th=wr;function Mh(h,r){var t=r?Th(h.buffer):h.buffer;return new h.constructor(t,h.byteOffset,h.byteLength);}var Ph=Mh,Oh=/\w*$/;function Eh(h){var r=new h.constructor(h.source,Oh.exec(h));return r.lastIndex=h.lastIndex,r;}var Ch=Eh,an=Be,ln=an?an.prototype:void 0,cn=ln?ln.valueOf:void 0;function Ah(h){return cn?Object(cn.call(h)):{};}var Rh=Ah,Ih=wr;function Lh(h,r){var t=r?Ih(h.buffer):h.buffer;return new h.constructor(t,h.byteOffset,h.length);}var wh=Lh,bh=wr,Dh=Ph,Nh=Ch,Wh=Rh,Bh=wh,Fh="[object Boolean]",Uh="[object Date]",jh="[object Map]",$h="[object Number]",zh="[object RegExp]",Gh="[object Set]",Hh="[object String]",Kh="[object Symbol]",Yh="[object ArrayBuffer]",Vh="[object DataView]",kh="[object Float32Array]",Xh="[object Float64Array]",Jh="[object Int8Array]",Zh="[object Int16Array]",Qh="[object Int32Array]",qh="[object Uint8Array]",_h="[object Uint8ClampedArray]",tu="[object Uint16Array]",eu="[object Uint32Array]";function ru(h,r,t){var e=h.constructor;switch(r){case Yh:return bh(h);case Fh:case Uh:return new e(+h);case Vh:return Dh(h,t);case kh:case Xh:case Jh:case Zh:case Qh:case qh:case _h:case tu:case eu:return Bh(h,t);case jh:return new e();case $h:case Hh:return new e(h);case zh:return Nh(h);case Gh:return new e();case Kh:return Wh(h);}}var nu=ru,iu=he,fn=Object.create,su=/* @__PURE__ */function(){function h(){}return function(r){if(!iu(r))return{};if(fn)return fn(r);h.prototype=r;var t=new h();return h.prototype=void 0,t;};}(),ou=su,au=ou,lu=_n,cu=Er;function fu(h){return typeof h.constructor=="function"&&!cu(h)?au(lu(h)):{};}var hu=fu,uu=or,du=ne,pu="[object Map]";function gu(h){return du(h)&&uu(h)==pu;}var mu=gu,vu=mu,yu=sr,hn=Or,un=hn&&hn.isMap,Su=un?yu(un):vu,xu=Su,Tu=or,Mu=ne,Pu="[object Set]";function Ou(h){return Mu(h)&&Tu(h)==Pu;}var Eu=Ou,Cu=Eu,Au=sr,dn=Or,pn=dn&&dn.isSet,Ru=pn?Au(pn):Cu,oi=Ru,Iu=/* @__PURE__ */fe(oi),Lu=zn,wu=el,bu=Kn,Du=Hc,Nu=af,Wu=lf,Bu=ff,Fu=Tf,Uu=Nf,ju=ri,$u=Vf,zu=or,Gu=vh,Hu=nu,Ku=hu,Yu=Fe,Vu=Pr,ku=xu,Xu=he,Ju=oi,Zu=Ar,Qu=Rr,qu=1,_u=2,td=4,ai="[object Arguments]",ed="[object Array]",rd="[object Boolean]",nd="[object Date]",id="[object Error]",li="[object Function]",sd="[object GeneratorFunction]",od="[object Map]",ad="[object Number]",ci="[object Object]",ld="[object RegExp]",cd="[object Set]",fd="[object String]",hd="[object Symbol]",ud="[object WeakMap]",dd="[object ArrayBuffer]",pd="[object DataView]",gd="[object Float32Array]",md="[object Float64Array]",vd="[object Int8Array]",yd="[object Int16Array]",Sd="[object Int32Array]",xd="[object Uint8Array]",Td="[object Uint8ClampedArray]",Md="[object Uint16Array]",Pd="[object Uint32Array]",Ut={};Ut[ai]=Ut[ed]=Ut[dd]=Ut[pd]=Ut[rd]=Ut[nd]=Ut[gd]=Ut[md]=Ut[vd]=Ut[yd]=Ut[Sd]=Ut[od]=Ut[ad]=Ut[ci]=Ut[ld]=Ut[cd]=Ut[fd]=Ut[hd]=Ut[xd]=Ut[Td]=Ut[Md]=Ut[Pd]=!0;Ut[id]=Ut[li]=Ut[ud]=!1;function $e(h,r,t,e,n,i){var a,o=r&qu,s=r&_u,l=r&td;if(t&&(a=n?t(h,e,n,i):t(h)),a!==void 0)return a;if(!Xu(h))return h;var g=Yu(h);if(g){if(a=Gu(h),!o)return Bu(h,a);}else{var c=zu(h),d=c==li||c==sd;if(Vu(h))return Wu(h,o);if(c==ci||c==ai||d&&!n){if(a=s||d?{}:Ku(h),!o)return s?Uu(h,Nu(a,h)):Fu(h,Du(a,h));}else{if(!Ut[c])return n?h:{};a=Hu(h,c,o);}}i||(i=new Lu());var y=i.get(h);if(y)return y;i.set(h,a),Ju(h)?h.forEach(function(v){a.add($e(v,r,t,v,h,i));}):ku(h)&&h.forEach(function(v,T){a.set(T,$e(v,r,t,T,h,i));});var P=l?s?$u:ju:s?Qu:Zu,S=g?void 0:P(h);return wu(S||h,function(v,T){S&&(T=v,v=h[T]),bu(a,T,$e(v,r,t,T,h,i));}),a;}var Od=$e,Ed=Od,Cd=1,Ad=4;function Rd(h){return Ed(h,Cd|Ad);}var Id=Rd,Jt=/* @__PURE__ */fe(Id);var fi="1.1.14-beta.0",Ld="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var h=window.__netlessUA||"";h+=" ".concat(Ld,"@").concat(fi),window.__netlessUA=h;}var re={syncOpt:{interval:500},cdn:{subWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/subWorker.js",fullWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/fullWorker.js"},cursor:{expirationTime:5e3},bufferSize:{full:2e4,sub:600},bezier:{combineUnitTime:100},pencilEraser:{useBitMap:!0},strokeWidth:{min:1,max:10}};function ie(h){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var t=h.length;if(t<2)return"";var e=h[0],n=h[1];if(t===2)return"M".concat(ge(e),"L").concat(ge(n));var i="";for(var a=2,o=t-1;a<o;a++)e=h[a],n=h[a+1],i+=me(e,n);return r?"M".concat(me(h[0],h[1]),"Q").concat(ge(h[1])).concat(me(h[1],h[2]),"T").concat(i).concat(me(h[t-1],h[0])).concat(me(h[0],h[1]),"Z"):"M".concat(ge(h[0]),"Q").concat(ge(h[1])).concat(me(h[1],h[2])).concat(h.length>3?"T":"").concat(i,"L").concat(ge(h[t-1]));}var Xt=/*#__PURE__*/function(){function Xt(r){_classCallCheck(this,Xt);tt(this,"syncUnitTime",re.syncOpt.interval);tt(this,"vNodes");tt(this,"drawLayer");tt(this,"fullLayer");tt(this,"workId");tt(this,"isDelete",!1);var t=r.vNodes,e=r.fullLayer,n=r.drawLayer,i=r.workId,a=r.toolsOpt;this.vNodes=t,this.fullLayer=e,this.drawLayer=n,this.workId=i,this.syncUnitTime=a.syncUnitTime||this.syncUnitTime;}return _createClass(Xt,[{key:"baseConsumeResult",get:function get(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions};}},{key:"filterSamePoints",value:function filterSamePoints(r){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0.01;return r.reduce(function(e,n){var i=e[e.length-1];return(n&&!i||n&&i&&!n.isNear(i,t))&&e.push(n),e;},[]);}/** 设置工作id */},{key:"setWorkId",value:function setWorkId(r){this.workId=r;}},{key:"getWorkId",value:function getWorkId(){return this.workId;}/** 获取工作选项配置 */},{key:"getWorkOptions",value:function getWorkOptions(){return this.workOptions;}/** 设置工作选项配置 */},{key:"setWorkOptions",value:function setWorkOptions(r){var n,i,a;this.workOptions=r,this.syncUnitTime=r.syncUnitTime||this.syncUnitTime;var t=(n=this.workId)==null?void 0:n.toString(),e=t&&((i=this.vNodes)==null?void 0:i.get(t))||void 0;t&&e&&(e.opt=r,(a=this.vNodes)==null||a.setInfo(t,e));}/** 更新服务端同步配置,返回绘制结果 */},{key:"updataOptService",value:function updataOptService(r){var n,i;var t;var e=(n=this.workId)==null?void 0:n.toString();if(e&&r){var a=this.fullLayer.getElementsByName(e)||this.drawLayer&&this.drawLayer.getElementsByName(e)||[];if(a.length!==1)return;var o=a[0],s=r.pos,l=r.zIndex,g=r.scale,c=r.angle,d=r.translate,y={};Vt(l)&&(y.zIndex=l),s&&(y.pos=[s[0],s[1]]),g&&(y.scale=g),c&&(y.rotate=c),d&&(y.translate=d),o.attr(y);var P=o==null?void 0:o.getBoundingClientRect();return P&&(t=Pt(t,{x:Math.floor(P.x-Xt.SafeBorderPadding),y:Math.floor(P.y-Xt.SafeBorderPadding),w:Math.floor(P.width+Xt.SafeBorderPadding*2),h:Math.floor(P.height+Xt.SafeBorderPadding*2)})),(i=this.vNodes)==null||i.setInfo(e,{rect:t,centerPos:s}),t;}}},{key:"drawEraserlines",value:function drawEraserlines(r){var O;var t=r.group,e=r.eraserlines,n=r.pos,i=r.layer,a=!!i.renderer.glRenderer,o=i.parent,s=i.parent.parent,l=i.getAttribute("scale"),g=i.getAttribute("translate"),c=this.createVmRenderNode("".concat(this.workId,"_bitMapLayer"),s,{offscreen:o.offscreen,width:o.width,height:o.height,contextType:"2d",autoRender:!1,// desynchronized: true,
|
|
399
|
+
mc(l,s)))&&o.push(l);return o;}var Jn=xc,Tc=Object.prototype;function Mc(h){var r=h&&h.constructor,t=typeof r=="function"&&r.prototype||Tc;return h===t;}var Er=Mc;function Pc(h,r){return function(t){return h(r(t));};}var Zn=Pc,Oc=Zn,Ec=Oc(Object.keys,Object),Cc=Ec,Ac=Er,Rc=Cc,Ic=Object.prototype,Lc=Ic.hasOwnProperty;function wc(h){if(!Ac(h))return Rc(h);var r=[];for(var t in Object(h))Lc.call(h,t)&&t!="constructor"&&r.push(t);return r;}var bc=wc,Dc=Un,Nc=kn;function Wc(h){return h!=null&&Nc(h.length)&&!Dc(h);}var Cr=Wc,Bc=Jn,Fc=bc,Uc=Cr;function jc(h){return Uc(h)?Bc(h):Fc(h);}var Ar=jc,$c=ir,zc=Ar;function Gc(h,r){return h&&$c(r,zc(r),h);}var Hc=Gc;function Kc(h){var r=[];if(h!=null)for(var t in Object(h))r.push(t);return r;}var Yc=Kc,Vc=he,kc=Er,Xc=Yc,Jc=Object.prototype,Zc=Jc.hasOwnProperty;function Qc(h){if(!Vc(h))return Xc(h);var r=kc(h),t=[];for(var e in h)e=="constructor"&&(r||!Zc.call(h,e))||t.push(e);return t;}var qc=Qc,_c=Jn,tf=qc,ef=Cr;function rf(h){return ef(h)?_c(h,!0):tf(h);}var Rr=rf,nf=ir,sf=Rr;function of(h,r){return h&&nf(r,sf(r),h);}var af=of,He={exports:{}};He.exports;(function(h,r){var t=ee,e=r&&!r.nodeType&&r,n=e&&!0&&h&&!h.nodeType&&h,i=n&&n.exports===e,a=i?t.Buffer:void 0,o=a?a.allocUnsafe:void 0;function s(l,g){if(g)return l.slice();var c=l.length,d=o?o(c):new l.constructor(c);return l.copy(d),d;}h.exports=s;})(He,He.exports);var lf=He.exports;function cf(h,r){var t=-1,e=h.length;for(r||(r=Array(e));++t<e;)r[t]=h[t];return r;}var ff=cf;function hf(h,r){for(var t=-1,e=h==null?0:h.length,n=0,i=[];++t<e;){var a=h[t];r(a,t,h)&&(i[n++]=a);}return i;}var Qn=hf;function uf(){return[];}var qn=uf,df=Qn,pf=qn,gf=Object.prototype,mf=gf.propertyIsEnumerable,_r=Object.getOwnPropertySymbols,vf=_r?function(h){return h==null?[]:(h=Object(h),df(_r(h),function(r){return mf.call(h,r);}));}:pf,Ir=vf,yf=ir,Sf=Ir;function xf(h,r){return yf(h,Sf(h),r);}var Tf=xf;function Mf(h,r){for(var t=-1,e=r.length,n=h.length;++t<e;)h[n+t]=r[t];return h;}var Lr=Mf,Pf=Zn,Of=Pf(Object.getPrototypeOf,Object),_n=Of,Ef=Lr,Cf=_n,Af=Ir,Rf=qn,If=Object.getOwnPropertySymbols,Lf=If?function(h){for(var r=[];h;)Ef(r,Af(h)),h=Cf(h);return r;}:Rf,ti=Lf,wf=ir,bf=ti;function Df(h,r){return wf(h,bf(h),r);}var Nf=Df,Wf=Lr,Bf=Fe;function Ff(h,r,t){var e=r(h);return Bf(h)?e:Wf(e,t(h));}var ei=Ff,Uf=ei,jf=Ir,$f=Ar;function zf(h){return Uf(h,$f,jf);}var ri=zf,Gf=ei,Hf=ti,Kf=Rr;function Yf(h){return Gf(h,Kf,Hf);}var Vf=Yf,kf=pe,Xf=ee,Jf=kf(Xf,"DataView"),Zf=Jf,Qf=pe,qf=ee,_f=Qf(qf,"Promise"),th=_f,eh=pe,rh=ee,nh=eh(rh,"Set"),ni=nh,ih=pe,sh=ee,oh=ih(sh,"WeakMap"),ah=oh,dr=Zf,pr=Mr,gr=th,mr=ni,vr=ah,ii=de,Re=jn,tn="[object Map]",lh="[object Object]",en="[object Promise]",rn="[object Set]",nn="[object WeakMap]",sn="[object DataView]",ch=Re(dr),fh=Re(pr),hh=Re(gr),uh=Re(mr),dh=Re(vr),ue=ii;(dr&&ue(new dr(new ArrayBuffer(1)))!=sn||pr&&ue(new pr())!=tn||gr&&ue(gr.resolve())!=en||mr&&ue(new mr())!=rn||vr&&ue(new vr())!=nn)&&(ue=function ue(h){var r=ii(h),t=r==lh?h.constructor:void 0,e=t?Re(t):"";if(e)switch(e){case ch:return sn;case fh:return tn;case hh:return en;case uh:return rn;case dh:return nn;}return r;});var or=ue,ph=Object.prototype,gh=ph.hasOwnProperty;function mh(h){var r=h.length,t=new h.constructor(r);return r&&typeof h[0]=="string"&&gh.call(h,"index")&&(t.index=h.index,t.input=h.input),t;}var vh=mh,yh=ee,Sh=yh.Uint8Array,si=Sh,on=si;function xh(h){var r=new h.constructor(h.byteLength);return new on(r).set(new on(h)),r;}var wr=xh,Th=wr;function Mh(h,r){var t=r?Th(h.buffer):h.buffer;return new h.constructor(t,h.byteOffset,h.byteLength);}var Ph=Mh,Oh=/\w*$/;function Eh(h){var r=new h.constructor(h.source,Oh.exec(h));return r.lastIndex=h.lastIndex,r;}var Ch=Eh,an=Be,ln=an?an.prototype:void 0,cn=ln?ln.valueOf:void 0;function Ah(h){return cn?Object(cn.call(h)):{};}var Rh=Ah,Ih=wr;function Lh(h,r){var t=r?Ih(h.buffer):h.buffer;return new h.constructor(t,h.byteOffset,h.length);}var wh=Lh,bh=wr,Dh=Ph,Nh=Ch,Wh=Rh,Bh=wh,Fh="[object Boolean]",Uh="[object Date]",jh="[object Map]",$h="[object Number]",zh="[object RegExp]",Gh="[object Set]",Hh="[object String]",Kh="[object Symbol]",Yh="[object ArrayBuffer]",Vh="[object DataView]",kh="[object Float32Array]",Xh="[object Float64Array]",Jh="[object Int8Array]",Zh="[object Int16Array]",Qh="[object Int32Array]",qh="[object Uint8Array]",_h="[object Uint8ClampedArray]",tu="[object Uint16Array]",eu="[object Uint32Array]";function ru(h,r,t){var e=h.constructor;switch(r){case Yh:return bh(h);case Fh:case Uh:return new e(+h);case Vh:return Dh(h,t);case kh:case Xh:case Jh:case Zh:case Qh:case qh:case _h:case tu:case eu:return Bh(h,t);case jh:return new e();case $h:case Hh:return new e(h);case zh:return Nh(h);case Gh:return new e();case Kh:return Wh(h);}}var nu=ru,iu=he,fn=Object.create,su=/* @__PURE__ */function(){function h(){}return function(r){if(!iu(r))return{};if(fn)return fn(r);h.prototype=r;var t=new h();return h.prototype=void 0,t;};}(),ou=su,au=ou,lu=_n,cu=Er;function fu(h){return typeof h.constructor=="function"&&!cu(h)?au(lu(h)):{};}var hu=fu,uu=or,du=ne,pu="[object Map]";function gu(h){return du(h)&&uu(h)==pu;}var mu=gu,vu=mu,yu=sr,hn=Or,un=hn&&hn.isMap,Su=un?yu(un):vu,xu=Su,Tu=or,Mu=ne,Pu="[object Set]";function Ou(h){return Mu(h)&&Tu(h)==Pu;}var Eu=Ou,Cu=Eu,Au=sr,dn=Or,pn=dn&&dn.isSet,Ru=pn?Au(pn):Cu,oi=Ru,Iu=/* @__PURE__ */fe(oi),Lu=zn,wu=el,bu=Kn,Du=Hc,Nu=af,Wu=lf,Bu=ff,Fu=Tf,Uu=Nf,ju=ri,$u=Vf,zu=or,Gu=vh,Hu=nu,Ku=hu,Yu=Fe,Vu=Pr,ku=xu,Xu=he,Ju=oi,Zu=Ar,Qu=Rr,qu=1,_u=2,td=4,ai="[object Arguments]",ed="[object Array]",rd="[object Boolean]",nd="[object Date]",id="[object Error]",li="[object Function]",sd="[object GeneratorFunction]",od="[object Map]",ad="[object Number]",ci="[object Object]",ld="[object RegExp]",cd="[object Set]",fd="[object String]",hd="[object Symbol]",ud="[object WeakMap]",dd="[object ArrayBuffer]",pd="[object DataView]",gd="[object Float32Array]",md="[object Float64Array]",vd="[object Int8Array]",yd="[object Int16Array]",Sd="[object Int32Array]",xd="[object Uint8Array]",Td="[object Uint8ClampedArray]",Md="[object Uint16Array]",Pd="[object Uint32Array]",Ut={};Ut[ai]=Ut[ed]=Ut[dd]=Ut[pd]=Ut[rd]=Ut[nd]=Ut[gd]=Ut[md]=Ut[vd]=Ut[yd]=Ut[Sd]=Ut[od]=Ut[ad]=Ut[ci]=Ut[ld]=Ut[cd]=Ut[fd]=Ut[hd]=Ut[xd]=Ut[Td]=Ut[Md]=Ut[Pd]=!0;Ut[id]=Ut[li]=Ut[ud]=!1;function $e(h,r,t,e,n,i){var a,o=r&qu,s=r&_u,l=r&td;if(t&&(a=n?t(h,e,n,i):t(h)),a!==void 0)return a;if(!Xu(h))return h;var g=Yu(h);if(g){if(a=Gu(h),!o)return Bu(h,a);}else{var c=zu(h),d=c==li||c==sd;if(Vu(h))return Wu(h,o);if(c==ci||c==ai||d&&!n){if(a=s||d?{}:Ku(h),!o)return s?Uu(h,Nu(a,h)):Fu(h,Du(a,h));}else{if(!Ut[c])return n?h:{};a=Hu(h,c,o);}}i||(i=new Lu());var y=i.get(h);if(y)return y;i.set(h,a),Ju(h)?h.forEach(function(v){a.add($e(v,r,t,v,h,i));}):ku(h)&&h.forEach(function(v,T){a.set(T,$e(v,r,t,T,h,i));});var P=l?s?$u:ju:s?Qu:Zu,S=g?void 0:P(h);return wu(S||h,function(v,T){S&&(T=v,v=h[T]),bu(a,T,$e(v,r,t,T,h,i));}),a;}var Od=$e,Ed=Od,Cd=1,Ad=4;function Rd(h){return Ed(h,Cd|Ad);}var Id=Rd,Jt=/* @__PURE__ */fe(Id);var fi="1.1.14-beta.2",Ld="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var h=window.__netlessUA||"";h+=" ".concat(Ld,"@").concat(fi),window.__netlessUA=h;}var re={syncOpt:{interval:500},cdn:{subWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/subWorker.js",fullWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/fullWorker.js"},cursor:{expirationTime:5e3},bufferSize:{full:2e4,sub:600},bezier:{combineUnitTime:100},pencilEraser:{useBitMap:!0},strokeWidth:{min:1,max:10}};function ie(h){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var t=h.length;if(t<2)return"";var e=h[0],n=h[1];if(t===2)return"M".concat(ge(e),"L").concat(ge(n));var i="";for(var a=2,o=t-1;a<o;a++)e=h[a],n=h[a+1],i+=me(e,n);return r?"M".concat(me(h[0],h[1]),"Q").concat(ge(h[1])).concat(me(h[1],h[2]),"T").concat(i).concat(me(h[t-1],h[0])).concat(me(h[0],h[1]),"Z"):"M".concat(ge(h[0]),"Q").concat(ge(h[1])).concat(me(h[1],h[2])).concat(h.length>3?"T":"").concat(i,"L").concat(ge(h[t-1]));}var Xt=/*#__PURE__*/function(){function Xt(r){_classCallCheck(this,Xt);tt(this,"syncUnitTime",re.syncOpt.interval);tt(this,"vNodes");tt(this,"drawLayer");tt(this,"fullLayer");tt(this,"workId");tt(this,"isDelete",!1);var t=r.vNodes,e=r.fullLayer,n=r.drawLayer,i=r.workId,a=r.toolsOpt;this.vNodes=t,this.fullLayer=e,this.drawLayer=n,this.workId=i,this.syncUnitTime=a.syncUnitTime||this.syncUnitTime;}return _createClass(Xt,[{key:"baseConsumeResult",get:function get(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions};}},{key:"filterSamePoints",value:function filterSamePoints(r){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0.01;return r.reduce(function(e,n){var i=e[e.length-1];return(n&&!i||n&&i&&!n.isNear(i,t))&&e.push(n),e;},[]);}/** 设置工作id */},{key:"setWorkId",value:function setWorkId(r){this.workId=r;}},{key:"getWorkId",value:function getWorkId(){return this.workId;}/** 获取工作选项配置 */},{key:"getWorkOptions",value:function getWorkOptions(){return this.workOptions;}/** 设置工作选项配置 */},{key:"setWorkOptions",value:function setWorkOptions(r){var n,i,a;this.workOptions=r,this.syncUnitTime=r.syncUnitTime||this.syncUnitTime;var t=(n=this.workId)==null?void 0:n.toString(),e=t&&((i=this.vNodes)==null?void 0:i.get(t))||void 0;t&&e&&(e.opt=r,(a=this.vNodes)==null||a.setInfo(t,e));}/** 更新服务端同步配置,返回绘制结果 */},{key:"updataOptService",value:function updataOptService(r){var n,i;var t;var e=(n=this.workId)==null?void 0:n.toString();if(e&&r){var a=this.fullLayer.getElementsByName(e)||this.drawLayer&&this.drawLayer.getElementsByName(e)||[];if(a.length!==1)return;var o=a[0],s=r.pos,l=r.zIndex,g=r.scale,c=r.angle,d=r.translate,y={};Vt(l)&&(y.zIndex=l),s&&(y.pos=[s[0],s[1]]),g&&(y.scale=g),c&&(y.rotate=c),d&&(y.translate=d),o.attr(y);var P=o==null?void 0:o.getBoundingClientRect();return P&&(t=Pt(t,{x:Math.floor(P.x-Xt.SafeBorderPadding),y:Math.floor(P.y-Xt.SafeBorderPadding),w:Math.floor(P.width+Xt.SafeBorderPadding*2),h:Math.floor(P.height+Xt.SafeBorderPadding*2)})),(i=this.vNodes)==null||i.setInfo(e,{rect:t,centerPos:s}),t;}}},{key:"drawEraserlines",value:function drawEraserlines(r){var O;var t=r.group,e=r.eraserlines,n=r.pos,i=r.layer,a=!!i.renderer.glRenderer,o=i.parent,s=i.parent.parent,l=i.getAttribute("scale"),g=i.getAttribute("translate"),c=this.createVmRenderNode("".concat(this.workId,"_bitMapLayer"),s,{offscreen:o.offscreen,width:o.width,height:o.height,contextType:"2d",autoRender:!1,// desynchronized: true,
|
|
400
400
|
bufferSize:500// depth: true,
|
|
401
401
|
},l,g),d=t.cloneNode(!0);this.addEraserlines(d,e,n,!1),c.appendChild(d);var y=c.parent;y.render();var P=c.renderer.canvasRenderer,S=d.getBoundingClientRect(),v={x:Math.floor(S.x-Xt.SafeBorderPadding),y:Math.floor(S.y-Xt.SafeBorderPadding),width:Math.floor(S.width+Xt.SafeBorderPadding*2),height:Math.floor(S.height+Xt.SafeBorderPadding*2)},T=P.options.displayRatio,f=Math.floor(v.x*T),p=Math.floor(v.y*T),u=Math.floor(v.width*T),m=Math.floor(v.height*T),M=this.isTransparentRectByCanvas(P.context,{x:f,y:p,w:u,h:m});if(s.removeChild(y),M){this.isDelete=!0,console.log("isTransparent===>",this.workId,(O=this.vNodes)==null?void 0:O.curNodeMap.size);return;}this.addEraserlines(t,e,n,a);}},{key:"createVmRenderNode",value:function createVmRenderNode(r,t,e,n,i){var a=e.width,o=e.height,s="bitMap-".concat(r),l=t.layer(s,e),g=new Zt({anchor:[0.5,0.5],pos:[a*0.5,o*0.5],size:[a,o],name:"viewport",id:r});return g.setAttribute("scale",n),g.setAttribute("translate",i),l.append(g),g;}// private destroyVmRenderNode(vmLayer:Group) {
|
|
402
402
|
// // todo
|
|
@@ -406,7 +406,7 @@ bufferSize:500// depth: true,
|
|
|
406
406
|
compressToUint8Array:function compressToUint8Array(s){for(var l=o.compress(s),g=new Uint8Array(l.length*2),c=0,d=l.length;c<d;c++){var y=l.charCodeAt(c);g[c*2]=y>>>8,g[c*2+1]=y%256;}return g;},//decompress from uint8array (UCS-2 big endian format)
|
|
407
407
|
decompressFromUint8Array:function decompressFromUint8Array(s){if(s==null)return o.decompress(s);for(var l=new Array(s.length/2),g=0,c=l.length;g<c;g++)l[g]=s[g*2]*256+s[g*2+1];var d=[];return l.forEach(function(y){d.push(t(y));}),o.decompress(d.join(""));},//compress into a string that is already URI encoded
|
|
408
408
|
compressToEncodedURIComponent:function compressToEncodedURIComponent(s){return s==null?"":o._compress(s,6,function(l){return n.charAt(l);});},//decompress from an output of compressToEncodedURIComponent
|
|
409
|
-
decompressFromEncodedURIComponent:function decompressFromEncodedURIComponent(s){return s==null?"":s==""?null:(s=s.replace(/ /g,"+"),o._decompress(s.length,32,function(l){return a(n,s.charAt(l));}));},compress:function compress(s){return o._compress(s,16,function(l){return t(l);});},_compress:function _compress(s,l,g){if(s==null)return"";var c,d,y={},P={},S="",v="",T="",f=2,p=3,u=2,m=[],M=0,O=0,A;for(A=0;A<s.length;A+=1)if(S=s.charAt(A),Object.prototype.hasOwnProperty.call(y,S)||(y[S]=p++,P[S]=!0),v=T+S,Object.prototype.hasOwnProperty.call(y,v))T=v;else{if(Object.prototype.hasOwnProperty.call(P,T)){if(T.charCodeAt(0)<256){for(c=0;c<u;c++)M=M<<1,O==l-1?(O=0,m.push(g(M)),M=0):O++;for(d=T.charCodeAt(0),c=0;c<8;c++)M=M<<1|d&1,O==l-1?(O=0,m.push(g(M)),M=0):O++,d=d>>1;}else{for(d=1,c=0;c<u;c++)M=M<<1|d,O==l-1?(O=0,m.push(g(M)),M=0):O++,d=0;for(d=T.charCodeAt(0),c=0;c<16;c++)M=M<<1|d&1,O==l-1?(O=0,m.push(g(M)),M=0):O++,d=d>>1;}f--,f==0&&(f=Math.pow(2,u),u++),delete P[T];}else for(d=y[T],c=0;c<u;c++)M=M<<1|d&1,O==l-1?(O=0,m.push(g(M)),M=0):O++,d=d>>1;f--,f==0&&(f=Math.pow(2,u),u++),y[v]=p++,T=String(S);}if(T!==""){if(Object.prototype.hasOwnProperty.call(P,T)){if(T.charCodeAt(0)<256){for(c=0;c<u;c++)M=M<<1,O==l-1?(O=0,m.push(g(M)),M=0):O++;for(d=T.charCodeAt(0),c=0;c<8;c++)M=M<<1|d&1,O==l-1?(O=0,m.push(g(M)),M=0):O++,d=d>>1;}else{for(d=1,c=0;c<u;c++)M=M<<1|d,O==l-1?(O=0,m.push(g(M)),M=0):O++,d=0;for(d=T.charCodeAt(0),c=0;c<16;c++)M=M<<1|d&1,O==l-1?(O=0,m.push(g(M)),M=0):O++,d=d>>1;}f--,f==0&&(f=Math.pow(2,u),u++),delete P[T];}else for(d=y[T],c=0;c<u;c++)M=M<<1|d&1,O==l-1?(O=0,m.push(g(M)),M=0):O++,d=d>>1;f--,f==0&&(f=Math.pow(2,u),u++);}for(d=2,c=0;c<u;c++)M=M<<1|d&1,O==l-1?(O=0,m.push(g(M)),M=0):O++,d=d>>1;for(;;)if(M=M<<1,O==l-1){m.push(g(M));break;}else O++;return m.join("");},decompress:function decompress(s){return s==null?"":s==""?null:o._decompress(s.length,32768,function(l){return s.charCodeAt(l);});},_decompress:function _decompress(s,l,g){var c=[],d=4,y=4,P=3,S="",v=[],T,f,p,u,m,M,O,A={val:g(0),position:l,index:1};for(T=0;T<3;T+=1)c[T]=T;for(p=0,m=Math.pow(2,2),M=1;M!=m;)u=A.val&A.position,A.position>>=1,A.position==0&&(A.position=l,A.val=g(A.index++)),p|=(u>0?1:0)*M,M<<=1;switch(p){case 0:for(p=0,m=Math.pow(2,8),M=1;M!=m;)u=A.val&A.position,A.position>>=1,A.position==0&&(A.position=l,A.val=g(A.index++)),p|=(u>0?1:0)*M,M<<=1;O=t(p);break;case 1:for(p=0,m=Math.pow(2,16),M=1;M!=m;)u=A.val&A.position,A.position>>=1,A.position==0&&(A.position=l,A.val=g(A.index++)),p|=(u>0?1:0)*M,M<<=1;O=t(p);break;case 2:return"";}for(c[3]=O,f=O,v.push(O);;){if(A.index>s)return"";for(p=0,m=Math.pow(2,P),M=1;M!=m;)u=A.val&A.position,A.position>>=1,A.position==0&&(A.position=l,A.val=g(A.index++)),p|=(u>0?1:0)*M,M<<=1;switch(O=p){case 0:for(p=0,m=Math.pow(2,8),M=1;M!=m;)u=A.val&A.position,A.position>>=1,A.position==0&&(A.position=l,A.val=g(A.index++)),p|=(u>0?1:0)*M,M<<=1;c[y++]=t(p),O=y-1,d--;break;case 1:for(p=0,m=Math.pow(2,16),M=1;M!=m;)u=A.val&A.position,A.position>>=1,A.position==0&&(A.position=l,A.val=g(A.index++)),p|=(u>0?1:0)*M,M<<=1;c[y++]=t(p),O=y-1,d--;break;case 2:return v.join("");}if(d==0&&(d=Math.pow(2,P),P++),c[O])S=c[O];else if(O===y)S=f+f.charAt(0);else return null;v.push(S),c[y++]=f+S.charAt(0),d--,f=S,d==0&&(d=Math.pow(2,P),P++);}}};return o;}();h!=null?h.exports=r:(typeof angular==="undefined"?"undefined":_typeof(angular))<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return r;});})(br);var hi=br.exports;function Pe(h){return JSON.parse(hi.decompress(h));}function Qt(h){return hi.compress(JSON.stringify(h));}var ui=/*#__PURE__*/function(_vt){function ui(t){var _this62;_classCallCheck(this,ui);_this62=_callSuper(this,ui,[t]);tt(_this62,"canRotate",!0);tt(_this62,"scaleType",Nt.all);tt(_this62,"toolsType",dt.Pencil);tt(_this62,"syncTimestamp");tt(_this62,"syncIndex",0);tt(_this62,"tmpPoints",[]);tt(_this62,"MAX_REPEAR",10);/** 合并原始点的灵敏度 */tt(_this62,"uniThickness");tt(_this62,"workOptions");tt(_this62,"centerPos",[0,0]);_this62.workOptions=t.toolsOpt,_this62.uniThickness=_this62.MAX_REPEAR/_this62.workOptions.thickness/10,_this62.syncTimestamp=0;return _this62;}/** 批量合并消费本地数据,返回绘制结果 */_inherits(ui,_vt);return _createClass(ui,[{key:"combineConsume",value:function combineConsume(){var o;var t=(o=this.workId)==null?void 0:o.toString();if(this.tmpPoints.length<2)return{type:ot.None};var e=this.transformDataAll(!0),n={name:t};var i;var a=this.drawLayer||this.fullLayer;return e.length&&(i=this.draw({attrs:n,tasks:e,replaceId:t,layer:a})),{rect:i,type:ot.DrawWork,dataType:Tt.Local};}},{key:"setWorkOptions",value:function setWorkOptions(t){_superPropGet(ui,"setWorkOptions",this,3)([t]),this.syncTimestamp=Date.now();}},{key:"consume",value:function consume(t){var _this63=this;var e=t.data,n=t.isFullWork,i=t.isSubWorker,a=t.isMainThread,o=t.drawCount,s=t.removeDrawCount,l=e.workId,_this$transformData=this.transformData(e,!1),g=_this$transformData.tasks,c=_this$transformData.effects,d=_this$transformData.consumeIndex;this.syncIndex=Math.min(this.syncIndex,d,Math.max(0,this.tmpPoints.length-2));var y={name:l,id:Vt(o)&&o.toString()||void 0};var P,S=!1;var v=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),g.length&&(g[0].taskId-this.syncTimestamp>this.syncUnitTime&&(S=!0,this.syncTimestamp=g[0].taskId,this.syncIndex=this.tmpPoints.length),i||a)){var _f26=n?this.fullLayer:this.drawLayer||this.fullLayer;P=this.draw({attrs:y,tasks:g,effects:c,layer:_f26,removeDrawCount:s});}if(i)return d>10&&this.tmpPoints.splice(0,d-10),{rect:P,type:ot.DrawWork,dataType:Tt.Local};var T=[];return this.tmpPoints.slice(v).forEach(function(f){T.push(f.x,f.y,_this63.computRadius(f.z,_this63.workOptions.thickness));}),_objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:ot.DrawWork,dataType:Tt.Local,rect:P,op:S?T:void 0,index:S?v*3:void 0,updateNodeOpt:{useAnimation:!0}});}},{key:"consumeAll",value:function consumeAll(t){var g;var e=this.workId;if(t.data){var _t$data=t.data,c=_t$data.op,d=_t$data.workState;c!=null&&c.length&&d===It.Done&&this.workOptions.strokeType===Lt.Stroke&&this.updateTempPointsWithPressureWhenDone(c);}var n=this.transformDataAll(!0),i={name:e};var a;var o=this.fullLayer;if(n.length&&(a=this.draw({attrs:i,tasks:n,replaceId:e,layer:o})),this.tmpPoints.length<2)return this.replace(o,e),{type:ot.RemoveNode,removeIds:[e],rect:a};var s=[];this.tmpPoints.map(function(c){s.push(c.x,c.y,c.z);}),this.syncTimestamp=0,delete this.workOptions.syncUnitTime;var l=Qt(s);return(g=this.vNodes)==null||g.setInfo(e,{rect:a,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&vt.getCenterPos(a,o)}),_objectSpread(_objectSpread({},this.baseConsumeResult),{},{rect:a,type:ot.FullWork,dataType:Tt.Local,ops:l,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 g,c;var e=t.op,n=t.isFullWork,i=t.replaceId;this.tmpPoints.length=0;for(var d=0;d<e.length;d+=3){var y=new xt(e[d],e[d+1],e[d+2]);if(this.tmpPoints.length>0){var P=this.tmpPoints[this.tmpPoints.length-1],S=_.Sub(y,P).uni();y.setv(S);}this.tmpPoints.push(y);}if(this.tmpPoints.length<2)return;var a=this.transformDataAll(!0),o=(g=this.workId)==null?void 0:g.toString(),s={name:o};var l;if(o&&a.length){var _d3=n?this.fullLayer:this.drawLayer||this.fullLayer;l=this.draw({attrs:s,tasks:a,replaceId:i,layer:_d3}),(c=this.vNodes)==null||c.setInfo(o,{rect:l,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:l&&vt.getCenterPos(l,_d3)});}return l;}},{key:"transformDataAll",value:function transformDataAll(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:!0;var e=this.filterSamePoints(this.tmpPoints,this.workOptions.thickness);return this.getTaskPoints(e,t&&this.workOptions.thickness||void 0);}},{key:"draw",value:function draw(t){var _this64=this;var e=t.attrs,n=t.tasks,i=t.replaceId,a=t.effects,o=t.layer,s=t.removeDrawCount,_this$workOptions=this.workOptions,l=_this$workOptions.strokeColor,g=_this$workOptions.strokeType,c=_this$workOptions.thickness,d=_this$workOptions.zIndex,y=_this$workOptions.scale,P=_this$workOptions.rotate,S=_this$workOptions.translate,v=_this$workOptions.eraserlines;a!=null&&a.size&&(a.forEach(function(M){var O;(O=o.getElementById(M+""))==null||O.remove();}),a.clear()),s&&this.removeDrawCountNodes(o,s);var T;var f=[],p=o.worldPosition,u=o.worldScaling;for(var M=0;M<n.length;M++){var _n$M=n[M],O=_n$M.pos,A=_n$M.points,_this$computDrawPoint=this.computDrawPoints(A),w=_this$computDrawPoint.ps,E=_this$computDrawPoint.rect;var L=void 0;var b=A.length===1;g===Lt.Stroke||b?L=ie(w,!0):L=ie(w,!1);var I={pos:O,d:L,fillColor:g===Lt.Stroke||b?l:void 0,lineDash:g===Lt.Dotted&&!b?[1,c*2]:g===Lt.LongDotted&&!b?[c,c*2]:void 0,strokeColor:l,lineCap:g===Lt.Stroke||b?void 0:"round",lineWidth:g===Lt.Stroke||b?0:c};T=Pt(T,{x:Math.floor((E.x+O[0])*u[0]+p[0]-vt.SafeBorderPadding),y:Math.floor((E.y+O[1])*u[1]+p[1]-vt.SafeBorderPadding),w:Math.floor(E.w*u[0]+2*vt.SafeBorderPadding),h:Math.floor(E.h*u[1]+2*vt.SafeBorderPadding)}),f.push(I);}y&&(e.scale=y),P&&(e.rotate=P),S&&(e.translate=S);var m=new Zt();if(T){this.centerPos=vt.getCenterPos(T,o);var _M8=g===Lt.Stroke&&!v;m.attr(_objectSpread(_objectSpread({},e),{},{normalize:!0,anchor:[0.5,0.5],bgcolor:_M8?l:void 0,pos:this.centerPos,size:[(T.w-2*vt.SafeBorderPadding)/u[0],(T.h-2*vt.SafeBorderPadding)/u[1]],zIndex:d}));var _O4=f.map(function(A){return A.pos=[A.pos[0]-_this64.centerPos[0],A.pos[1]-_this64.centerPos[1]],new se(A);});m.append.apply(m,_toConsumableArray(_O4)),_M8&&m.seal(),v&&(this.scaleType=Nt.proportional,this.drawEraserlines({group:m,eraserlines:v,pos:this.centerPos,layer:o})),this.replace(o,i,m);}if(y||P||S){var _M9=m==null?void 0:m.getBoundingClientRect();if(_M9)return{x:Math.floor(_M9.x-vt.SafeBorderPadding),y:Math.floor(_M9.y-vt.SafeBorderPadding),w:Math.floor(_M9.width+vt.SafeBorderPadding*2),h:Math.floor(_M9.height+vt.SafeBorderPadding*2)};}return T;}},{key:"computDrawPoints",value:function computDrawPoints(t){return this.workOptions.strokeType===Lt.Stroke||t.length===1?this.computStroke(t):this.computNomal(t);}},{key:"computNomal",value:function computNomal(t){var e=this.workOptions.thickness;var n=t.map(function(i){return e=Math.max(e,i.radius),i.point;});return{ps:n,rect:Ft(n,e)};}},{key:"computStroke",value:function computStroke(t){return t.length===1?this.computDotStroke(t[0]):this.computLineStroke(t);}},{key:"computLineStroke",value:function computLineStroke(t){var e=[],n=[];for(var l=0;l<t.length;l++){var _t$l=t[l],g=_t$l.point,c=_t$l.radius;var d=g.v;l===0&&t.length>1&&(d=t[l+1].point.v);var y=_.Per(d).mul(c);e.push(xt.Sub(g,y)),n.push(xt.Add(g,y));}var i=t[t.length-1],a=xt.GetSemicircleStroke(i.point,e[e.length-1],-1,8),o=xt.GetSemicircleStroke(t[0].point,n[0],-1,8),s=e.concat(a,n.reverse(),o);return{ps:s,rect:Ft(s)};}},{key:"computDotStroke",value:function computDotStroke(t){var e=t.point,n=t.radius,i={x:e.x-n,y:e.y-n,w:n*2,h:n*2};return{ps:xt.GetDotStroke(e,n,8),rect:i};}},{key:"transformData",value:function transformData(t,e){var n=t.op,i=t.workState;var a=this.tmpPoints.length-1,o=[];if(n!=null&&n.length&&i){var _this$workOptions2=this.workOptions,s=_this$workOptions2.strokeType,l=_this$workOptions2.thickness,g=/* @__PURE__ */new Set();a=s===Lt.Stroke?this.updateTempPointsWithPressure(n,l,g):this.updateTempPoints(n,l,g);var c=e?this.tmpPoints:this.tmpPoints.slice(a);return o=this.getTaskPoints(c,l),{tasks:o,effects:g,consumeIndex:a};}return{tasks:o,consumeIndex:a};}/** 压力渐变公式 */},{key:"computRadius",value:function computRadius(t,e){return t*0.03*e+e*0.5;}},{key:"getMinZ",value:function getMinZ(t,e){return((e||Math.max(1,Math.floor(t*0.3)))-t*0.5)*100/t/3;}},{key:"getTaskPoints",value:function getTaskPoints(t,e){var c;var n=[];if(t.length===0)return[];var i=0,a=t[0].x,o=t[0].y,s=[a,o],l=[],g=t[0].t;for(;i<t.length;){var d=t[i],y=d.x-a,P=d.y-o,S=d.z,v=e?this.computRadius(S,e):S;if(l.push({point:new xt(y,P,S,t[i].v),radius:v}),i>0&&i<t.length-1){var _T28=t[i].getAngleByPoints(t[i-1],t[i+1]);if(_T28<90||_T28>270){var _f27=(c=l.pop())==null?void 0:c.point.clone();_f27&&n.push({taskId:g,pos:s,points:[].concat(_toConsumableArray(l),[{point:_f27,radius:v}])}),a=t[i].x,o=t[i].y,s=[a,o];var p=d.x-a,u=d.y-o;l=[{point:new xt(p,u,S),radius:v}],g=Date.now();}}i++;}return n.push({taskId:g,pos:s,points:l}),n;}},{key:"updateTempPointsWithPressure",value:function updateTempPointsWithPressure(t,e,n){var i=Date.now(),a=this.tmpPoints.length;var o=a;for(var l=0;l<t.length;l+=2){o=Math.min(o,a);var g=this.tmpPoints.length,c=new xt(t[l],t[l+1]);if(g===0){this.tmpPoints.push(c);continue;}var d=g-1,y=this.tmpPoints[d],P=_.Sub(c,y).uni();if(c.isNear(y,e)){if(y.z<this.MAX_REPEAR){if(y.setz(Math.min(y.z+1,this.MAX_REPEAR)),o=Math.min(o,d),g>1){var _T29=g-1;for(;_T29>0;){var _f28=this.tmpPoints[_T29].distance(this.tmpPoints[_T29-1]),p=Math.max(this.tmpPoints[_T29].z-this.uniThickness*_f28,0);if(this.tmpPoints[_T29-1].z>=p)break;this.tmpPoints[_T29-1].setz(p),o=Math.min(o,_T29-1),_T29--;}}}else o=1/0;continue;}c.setv(P);var S=c.distance(y),v=Math.max(y.z-this.uniThickness*S,0);g>1&&_.Equals(P,y.v,0.02)&&(v>0||y.z<=0)&&(n&&y.t&&n.add(y.t),this.tmpPoints.pop(),o=Math.min(d,o)),c.setz(v),this.tmpPoints.push(c);}if(o===1/0)return this.tmpPoints.length;var s=a;if(o===a){s=Math.max(s-1,0);var _l4=this.tmpPoints[s].t;_l4&&(n==null||n.add(_l4));}else{var _l5=a-1;for(s=o;_l5>=0;){var _g6=this.tmpPoints[_l5].t;if(_g6&&(n==null||n.add(_g6),_l5<=o)){s=_l5,_l5=-1;break;}_l5--;}}return this.tmpPoints[s].setT(i),s;}},{key:"updateTempPoints",value:function updateTempPoints(t,e,n){var l;var i=Date.now(),a=this.tmpPoints.length;var o=a;for(var g=0;g<t.length;g+=2){var c=this.tmpPoints.length,d=new xt(t[g],t[g+1]);if(c===0){this.tmpPoints.push(d);continue;}var y=c-1,P=this.tmpPoints[y],S=_.Sub(d,P).uni();if(d.isNear(P,e/2)){o=Math.min(y,o);continue;}_.Equals(S,P.v,0.02)&&(n&&P.t&&n.add(P.t),this.tmpPoints.pop(),o=Math.min(y,o)),d.setv(S),this.tmpPoints.push(d);}var s=a;if(o===a){s=Math.max(s-1,0);var _g7=this.tmpPoints[s].t;_g7&&(n==null||n.add(_g7));}else{var _g8=Math.min(a-1,o);for(s=o;_g8>=0;){var _c4=(l=this.tmpPoints[_g8])==null?void 0:l.t;if(_c4&&(n==null||n.add(_c4),_g8<=o)){s=_g8,_g8=-1;break;}_g8--;}}return this.tmpPoints[s].setT(i),s;}},{key:"updateTempPointsWithPressureWhenDone",value:function updateTempPointsWithPressureWhenDone(t){var e=this.workOptions.thickness,n=t.length,i=this.getMinZ(e);for(var a=0;a<n;a+=2){var o=this.tmpPoints.length,s=new xt(t[a],t[a+1]);if(o===0){this.tmpPoints.push(s);continue;}var l=o-1,g=this.tmpPoints[l],c=_.Sub(s,g).uni(),d=s.distance(g);if(o>1&&g.z===i)break;if(s.isNear(g,e/2)){if(n<3&&g.z<this.MAX_REPEAR&&(g.setz(Math.min(g.z+1,this.MAX_REPEAR)),o>1)){var P=o-1;for(;P>0;){var S=this.tmpPoints[P].distance(this.tmpPoints[P-1]),v=Math.max(this.tmpPoints[P].z-this.uniThickness*S,-e/4);if(this.tmpPoints[P-1].z>=v)break;this.tmpPoints[P-1].setz(v),P--;}}continue;}s.setv(c);var y=Math.max(g.z-this.uniThickness*d,i);o>1&&_.Equals(c,g.v,0.02)&&g.z<=0&&this.tmpPoints.pop(),s.setz(y),this.tmpPoints.push(s);}}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var l,g;var e=t.node,n=t.opt,i=t.vNodes,a=n.strokeColor,o=n.strokeType,s=i.get(e.name);return a&&(e.tagName==="GROUP"?Zp(e)?e.setAttribute("bgcolor",a):e.children.forEach(function(c){c.setAttribute("strokeColor",a),c.getAttribute("fillColor")&&c.setAttribute("fillColor",a);}):(e.setAttribute("strokeColor",a),e.setAttribute("fillColor",a)),(l=s==null?void 0:s.opt)!=null&&l.strokeColor&&(s.opt.strokeColor=a)),o&&s!=null&&s.opt&&(g=s.opt)!=null&&g.strokeType&&(s.opt.strokeType=o),s&&i.setInfo(e.name,s),vt.updateNodeOpt(t);}}]);}(vt);var di=/*#__PURE__*/function(_vt2){function di(t){var _this65;_classCallCheck(this,di);_this65=_callSuper(this,di,[t]);tt(_this65,"toolsType",dt.LaserPen);tt(_this65,"canRotate",!1);tt(_this65,"scaleType",Nt.none);tt(_this65,"syncTimestamp");tt(_this65,"syncIndex",0);tt(_this65,"tmpPoints",[]);tt(_this65,"workOptions");tt(_this65,"consumeIndex",0);_this65.workOptions=t.toolsOpt,_this65.syncTimestamp=0;return _this65;}_inherits(di,_vt2);return _createClass(di,[{key:"combineConsume",value:function combineConsume(){}},{key:"setWorkOptions",value:function setWorkOptions(t){_superPropGet(di,"setWorkOptions",this,3)([t]),this.syncTimestamp=Date.now();}},{key:"consume",value:function consume(t){var e=t.data,n=t.isSubWorker,i=e.workId,a=e.op;if((a==null?void 0:a.length)===0)return{type:ot.None};if(this.updateTempPoints(a||[]),this.consumeIndex>this.tmpPoints.length-4)return{type:ot.None};var _this$workOptions3=this.workOptions,o=_this$workOptions3.strokeColor,s=_this$workOptions3.thickness,l=_this$workOptions3.strokeType,g=Ft(this.tmpPoints,s);var c=!1;var d=this.syncIndex,y=this.tmpPoints.slice(this.consumeIndex);this.consumeIndex=this.tmpPoints.length-1,this.syncTimestamp===0&&(this.syncTimestamp=Date.now());var P={name:i==null?void 0:i.toString(),opacity:1,lineDash:l===Lt.Dotted?[1,s*2]:l===Lt.LongDotted?[s,s*2]:void 0,strokeColor:o,lineCap:"round",lineWidth:s,anchor:[0.5,0.5]},S=this.getTaskPoints(y);if(S.length){var _T30=Date.now();_T30-this.syncTimestamp>this.syncUnitTime&&(c=!0,this.syncTimestamp=_T30,this.syncIndex=this.tmpPoints.length),n&&this.draw({attrs:P,tasks:S,isDot:!1,layer:this.drawLayer||this.fullLayer});}var v=[];return this.tmpPoints.slice(d).forEach(function(T){v.push(T.x,T.y);}),_objectSpread({rect:{x:g.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:g.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:g.w*this.fullLayer.worldScaling[0],h:g.h*this.fullLayer.worldScaling[1]},type:ot.DrawWork,dataType:Tt.Local,op:c?v:void 0,index:c?d*2:void 0},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var a;var t=(a=this.workId)==null?void 0:a.toString();var e;if(this.tmpPoints.length-1>this.consumeIndex){var o=this.tmpPoints.slice(this.consumeIndex);var s=o.length===1,_this$workOptions4=this.workOptions,l=_this$workOptions4.strokeColor,g=_this$workOptions4.thickness,c=_this$workOptions4.strokeType;if(s){var P=this.computDotStroke({point:o[0],radius:g/2});o=P.ps,e=P.rect;}else e=Ft(this.tmpPoints,g);var d={name:t==null?void 0:t.toString(),fillColor:s?l:void 0,opacity:1,lineDash:c===Lt.Dotted&&!s?[1,g*2]:c===Lt.LongDotted&&!s?[g,g*2]:void 0,strokeColor:l,lineCap:s?void 0:"round",lineWidth:s?0:g,anchor:[0.5,0.5]},y=this.getTaskPoints(o);y.length&&this.draw({attrs:d,tasks:y,isDot:s,layer:this.drawLayer||this.fullLayer});}var n=[];this.tmpPoints.forEach(function(o){n.push(o.x,o.y);});var i=Qt(n);return _objectSpread({rect:e&&{x:e.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:e.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:e.w*this.fullLayer.worldScaling[0],h:e.h*this.fullLayer.worldScaling[1]},type:ot.FullWork,dataType:Tt.Local,ops:i,index:this.syncIndex*2},this.baseConsumeResult);}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0;}},{key:"consumeService",value:function consumeService(t){var S;var e=t.op,n=t.replaceId,i=t.isFullWork,_this$workOptions5=this.workOptions,a=_this$workOptions5.strokeColor,o=_this$workOptions5.thickness,s=_this$workOptions5.strokeType;if(!e.length){var v=Ft(this.tmpPoints,o);return{x:v.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:v.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:v.w*this.fullLayer.worldScaling[0],h:v.h*this.fullLayer.worldScaling[1]};}var l=Math.max(0,this.tmpPoints.length-1);this.updateTempPoints(e||[]);var g,c=this.tmpPoints.slice(l);var d=c.length===1;if(d){var _v6=this.computDotStroke({point:c[0],radius:o/2});c=_v6.ps,g=_v6.rect;}else g=Ft(this.tmpPoints,o);var y={name:(S=this.workId)==null?void 0:S.toString(),fillColor:d?a:void 0,opacity:1,lineDash:s===Lt.Dotted&&!d?[1,o*2]:s===Lt.LongDotted&&!d?[o,o*2]:void 0,strokeColor:a,lineCap:d?void 0:"round",lineWidth:d?0:o,anchor:[0.5,0.5]},P=this.getTaskPoints(c);if(P.length){var _v7=i?this.fullLayer:this.drawLayer||this.fullLayer;this.draw({attrs:y,tasks:P,isDot:d,replaceId:n,layer:_v7});}return{x:g.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:g.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:g.w*this.fullLayer.worldScaling[0],h:g.h*this.fullLayer.worldScaling[1]};}},{key:"computDotStroke",value:function computDotStroke(t){var e=t.point,n=t.radius,i={x:e.x-n,y:e.y-n,w:n*2,h:n*2};return{ps:xt.GetDotStroke(e,n,8),rect:i};}},{key:"updateTempPoints",value:function updateTempPoints(t){var e=this.tmpPoints.length;for(var n=0;n<t.length;n+=2){if(e){var i=this.tmpPoints.slice(-1)[0];i&&i.x===t[n]&&i.y===t[n+1]&&this.tmpPoints.pop();}this.tmpPoints.push(new xt(t[n],t[n+1]));}}},{key:"draw",value:function(){var _draw2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21(t){var _this66=this;var e,n,i,a,o,_iterator15,_step15,_loop3;return _regeneratorRuntime().wrap(function _callee21$(_context23){while(1)switch(_context23.prev=_context23.next){case 0:e=t.attrs,n=t.tasks,i=t.isDot,a=t.layer,o=this.workOptions.duration;_iterator15=_createForOfIteratorHelper(n);_context23.prev=2;_loop3=/*#__PURE__*/_regeneratorRuntime().mark(function _loop3(){var s,l,g,c,d,_this66$workOptions,y,P,S,_a$getResolution,v,_T31;return _regeneratorRuntime().wrap(function _loop3$(_context22){while(1)switch(_context22.prev=_context22.next){case 0:s=_step15.value;l=new se(),g=s.pos,c=s.points;i?d=ie(c,!0):d=ie(c,!1),l.attr(_objectSpread(_objectSpread({},e),{},{pos:g,d:d}));_this66$workOptions=_this66.workOptions,y=_this66$workOptions.vertex,P=_this66$workOptions.fragment;if(y&&P){S=a.renderer.createProgram({vertex:y,fragment:P}),_a$getResolution=a.getResolution(),v=_a$getResolution.width,_T31=_a$getResolution.height;l.setUniforms({u_time:0,u_resolution:[v,_T31]}),l.setProgram(S);}a.appendChild(l),l.transition(o).attr({scale:i?[0.1,0.1]:[1,1],lineWidth:i?0:1}).then(function(){l.remove();});case 6:case"end":return _context22.stop();}},_loop3);});_iterator15.s();case 5:if((_step15=_iterator15.n()).done){_context23.next=9;break;}return _context23.delegateYield(_loop3(),"t0",7);case 7:_context23.next=5;break;case 9:_context23.next=14;break;case 11:_context23.prev=11;_context23.t1=_context23["catch"](2);_iterator15.e(_context23.t1);case 14:_context23.prev=14;_iterator15.f();return _context23.finish(14);case 17:case"end":return _context23.stop();}},_callee21,this,[[2,11,14,17]]);}));function draw(_x23){return _draw2.apply(this,arguments);}return draw;}()},{key:"getTaskPoints",value:function getTaskPoints(t){var l;var e=[];if(t.length===0)return[];var n=0,i=t[0].x,a=t[0].y,o=[i,a],s=[];for(;n<t.length;){var g=t[n],c=g.x-i,d=g.y-a;if(s.push(new xt(c,d)),n>0&&n<t.length-1){var y=t[n].getAngleByPoints(t[n-1],t[n+1]);if(y<90||y>270){var P=(l=s.pop())==null?void 0:l.clone();P&&e.push({pos:o,points:[].concat(_toConsumableArray(s),[P])}),i=t[n].x,a=t[n].y,o=[i,a];var S=g.x-i,v=g.y-a;s=[new xt(S,v)];}}n++;}return e.push({pos:o,points:s}),e;}},{key:"removeLocal",value:function removeLocal(){}},{key:"removeService",value:function removeService(t){var e;var n=[];return this.fullLayer.getElementsByName(t).forEach(function(i){if(i.name===t){var a=i.getBoundingClientRect();e=Pt(e,{x:a.x,y:a.y,w:a.width,h:a.height}),n.push(i);}}),n.length&&n.forEach(function(i){return i.remove();}),e;}}]);}(vt);var wd=Ke;Ke.polyline=Ke;Ke.polygon=bd;function Ke(h,r,t){var e=h.length,n=ve(h[0],r),i=[],a,o,s,l,g;for(t||(t=[]),a=1;a<e;a++){for(o=h[a-1],s=h[a],l=g=ve(s,r);;)if(n|l){if(n&l)break;n?(o=yr(o,s,n,r),n=ve(o,r)):(s=yr(o,s,l,r),l=ve(s,r));}else{i.push(o),l!==g?(i.push(s),a<e-1&&(t.push(i),i=[])):a===e-1&&i.push(s);break;}n=g;}return i.length&&t.push(i),t;}function bd(h,r){var t,e,n,i,a,o,s;for(e=1;e<=8;e*=2){for(t=[],n=h[h.length-1],i=!(ve(n,r)&e),a=0;a<h.length;a++)o=h[a],s=!(ve(o,r)&e),s!==i&&t.push(yr(n,o,e,r)),s&&t.push(o),n=o,i=s;if(h=t,!h.length)break;}return t;}function yr(h,r,t,e){return t&8?[h[0]+(r[0]-h[0])*(e[3]-h[1])/(r[1]-h[1]),e[3]]:// top
|
|
409
|
+
decompressFromEncodedURIComponent:function decompressFromEncodedURIComponent(s){return s==null?"":s==""?null:(s=s.replace(/ /g,"+"),o._decompress(s.length,32,function(l){return a(n,s.charAt(l));}));},compress:function compress(s){return o._compress(s,16,function(l){return t(l);});},_compress:function _compress(s,l,g){if(s==null)return"";var c,d,y={},P={},S="",v="",T="",f=2,p=3,u=2,m=[],M=0,O=0,A;for(A=0;A<s.length;A+=1)if(S=s.charAt(A),Object.prototype.hasOwnProperty.call(y,S)||(y[S]=p++,P[S]=!0),v=T+S,Object.prototype.hasOwnProperty.call(y,v))T=v;else{if(Object.prototype.hasOwnProperty.call(P,T)){if(T.charCodeAt(0)<256){for(c=0;c<u;c++)M=M<<1,O==l-1?(O=0,m.push(g(M)),M=0):O++;for(d=T.charCodeAt(0),c=0;c<8;c++)M=M<<1|d&1,O==l-1?(O=0,m.push(g(M)),M=0):O++,d=d>>1;}else{for(d=1,c=0;c<u;c++)M=M<<1|d,O==l-1?(O=0,m.push(g(M)),M=0):O++,d=0;for(d=T.charCodeAt(0),c=0;c<16;c++)M=M<<1|d&1,O==l-1?(O=0,m.push(g(M)),M=0):O++,d=d>>1;}f--,f==0&&(f=Math.pow(2,u),u++),delete P[T];}else for(d=y[T],c=0;c<u;c++)M=M<<1|d&1,O==l-1?(O=0,m.push(g(M)),M=0):O++,d=d>>1;f--,f==0&&(f=Math.pow(2,u),u++),y[v]=p++,T=String(S);}if(T!==""){if(Object.prototype.hasOwnProperty.call(P,T)){if(T.charCodeAt(0)<256){for(c=0;c<u;c++)M=M<<1,O==l-1?(O=0,m.push(g(M)),M=0):O++;for(d=T.charCodeAt(0),c=0;c<8;c++)M=M<<1|d&1,O==l-1?(O=0,m.push(g(M)),M=0):O++,d=d>>1;}else{for(d=1,c=0;c<u;c++)M=M<<1|d,O==l-1?(O=0,m.push(g(M)),M=0):O++,d=0;for(d=T.charCodeAt(0),c=0;c<16;c++)M=M<<1|d&1,O==l-1?(O=0,m.push(g(M)),M=0):O++,d=d>>1;}f--,f==0&&(f=Math.pow(2,u),u++),delete P[T];}else for(d=y[T],c=0;c<u;c++)M=M<<1|d&1,O==l-1?(O=0,m.push(g(M)),M=0):O++,d=d>>1;f--,f==0&&(f=Math.pow(2,u),u++);}for(d=2,c=0;c<u;c++)M=M<<1|d&1,O==l-1?(O=0,m.push(g(M)),M=0):O++,d=d>>1;for(;;)if(M=M<<1,O==l-1){m.push(g(M));break;}else O++;return m.join("");},decompress:function decompress(s){return s==null?"":s==""?null:o._decompress(s.length,32768,function(l){return s.charCodeAt(l);});},_decompress:function _decompress(s,l,g){var c=[],d=4,y=4,P=3,S="",v=[],T,f,p,u,m,M,O,A={val:g(0),position:l,index:1};for(T=0;T<3;T+=1)c[T]=T;for(p=0,m=Math.pow(2,2),M=1;M!=m;)u=A.val&A.position,A.position>>=1,A.position==0&&(A.position=l,A.val=g(A.index++)),p|=(u>0?1:0)*M,M<<=1;switch(p){case 0:for(p=0,m=Math.pow(2,8),M=1;M!=m;)u=A.val&A.position,A.position>>=1,A.position==0&&(A.position=l,A.val=g(A.index++)),p|=(u>0?1:0)*M,M<<=1;O=t(p);break;case 1:for(p=0,m=Math.pow(2,16),M=1;M!=m;)u=A.val&A.position,A.position>>=1,A.position==0&&(A.position=l,A.val=g(A.index++)),p|=(u>0?1:0)*M,M<<=1;O=t(p);break;case 2:return"";}for(c[3]=O,f=O,v.push(O);;){if(A.index>s)return"";for(p=0,m=Math.pow(2,P),M=1;M!=m;)u=A.val&A.position,A.position>>=1,A.position==0&&(A.position=l,A.val=g(A.index++)),p|=(u>0?1:0)*M,M<<=1;switch(O=p){case 0:for(p=0,m=Math.pow(2,8),M=1;M!=m;)u=A.val&A.position,A.position>>=1,A.position==0&&(A.position=l,A.val=g(A.index++)),p|=(u>0?1:0)*M,M<<=1;c[y++]=t(p),O=y-1,d--;break;case 1:for(p=0,m=Math.pow(2,16),M=1;M!=m;)u=A.val&A.position,A.position>>=1,A.position==0&&(A.position=l,A.val=g(A.index++)),p|=(u>0?1:0)*M,M<<=1;c[y++]=t(p),O=y-1,d--;break;case 2:return v.join("");}if(d==0&&(d=Math.pow(2,P),P++),c[O])S=c[O];else if(O===y)S=f+f.charAt(0);else return null;v.push(S),c[y++]=f+S.charAt(0),d--,f=S,d==0&&(d=Math.pow(2,P),P++);}}};return o;}();h!=null?h.exports=r:(typeof angular==="undefined"?"undefined":_typeof(angular))<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return r;});})(br);var hi=br.exports;function Pe(h){return JSON.parse(hi.decompress(h));}function Qt(h){return hi.compress(JSON.stringify(h));}var ui=/*#__PURE__*/function(_vt){function ui(t){var _this62;_classCallCheck(this,ui);_this62=_callSuper(this,ui,[t]);tt(_this62,"canRotate",!0);tt(_this62,"scaleType",Nt.all);tt(_this62,"toolsType",dt.Pencil);tt(_this62,"syncTimestamp");tt(_this62,"syncIndex",0);tt(_this62,"tmpPoints",[]);tt(_this62,"MAX_REPEAR",10);/** 合并原始点的灵敏度 */tt(_this62,"uniThickness");tt(_this62,"workOptions");tt(_this62,"centerPos",[0,0]);_this62.workOptions=t.toolsOpt,_this62.uniThickness=_this62.MAX_REPEAR/_this62.workOptions.thickness/10,_this62.syncTimestamp=0;return _this62;}/** 批量合并消费本地数据,返回绘制结果 */_inherits(ui,_vt);return _createClass(ui,[{key:"combineConsume",value:function combineConsume(){var o;var t=(o=this.workId)==null?void 0:o.toString();if(this.tmpPoints.length<2)return{type:ot.None};var e=this.transformDataAll(!0),n={name:t};var i;var a=this.drawLayer||this.fullLayer;return e.length&&(i=this.draw({attrs:n,tasks:e,replaceId:t,layer:a})),{rect:i,type:ot.DrawWork,dataType:Tt.Local};}},{key:"setWorkOptions",value:function setWorkOptions(t){_superPropGet(ui,"setWorkOptions",this,3)([t]),this.syncTimestamp=Date.now();}},{key:"consume",value:function consume(t){var _this63=this;var e=t.data,n=t.isFullWork,i=t.isSubWorker,a=t.isMainThread,o=t.drawCount,s=t.removeDrawCount,l=e.workId,_this$transformData=this.transformData(e,!1),g=_this$transformData.tasks,c=_this$transformData.effects,d=_this$transformData.consumeIndex;this.syncIndex=Math.min(this.syncIndex,d,Math.max(0,this.tmpPoints.length-2));var y={name:l,id:Vt(o)&&o.toString()||void 0};var P,S=!1;var v=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),g.length&&(g[0].taskId-this.syncTimestamp>this.syncUnitTime&&(S=!0,this.syncTimestamp=g[0].taskId,this.syncIndex=this.tmpPoints.length),i||a)){var _f26=n?this.fullLayer:this.drawLayer||this.fullLayer;P=this.draw({attrs:y,tasks:g,effects:c,layer:_f26,removeDrawCount:s});}if(i)return d>10&&this.tmpPoints.splice(0,d-10),{rect:P,type:ot.DrawWork,dataType:Tt.Local};var T=[];return this.tmpPoints.slice(v).forEach(function(f){T.push(f.x,f.y,_this63.computRadius(f.z,_this63.workOptions.thickness));}),_objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:ot.DrawWork,dataType:Tt.Local,rect:P,op:S?T:void 0,index:S?v*3:void 0,updateNodeOpt:{useAnimation:!0}});}},{key:"consumeAll",value:function consumeAll(t){var g;var e=this.workId;if(t.data){var _t$data=t.data,c=_t$data.op,d=_t$data.workState;c!=null&&c.length&&d===It.Done&&this.workOptions.strokeType===Lt.Stroke&&this.updateTempPointsWithPressureWhenDone(c);}var n=this.transformDataAll(!0),i={name:e};var a;var o=this.fullLayer;if(n.length&&(a=this.draw({attrs:i,tasks:n,replaceId:e,layer:o})),this.tmpPoints.length<2)return this.replace(o,e),{type:ot.RemoveNode,removeIds:[e],rect:a};var s=[];this.tmpPoints.map(function(c){s.push(c.x,c.y,c.z);}),this.syncTimestamp=0,delete this.workOptions.syncUnitTime;var l=Qt(s);return(g=this.vNodes)==null||g.setInfo(e,{rect:a,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&vt.getCenterPos(a,o)}),_objectSpread(_objectSpread({},this.baseConsumeResult),{},{rect:a,type:ot.FullWork,dataType:Tt.Local,ops:l,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 g,c;var e=t.op,n=t.isFullWork,i=t.replaceId;this.tmpPoints.length=0;for(var d=0;d<e.length;d+=3){var y=new xt(e[d],e[d+1],e[d+2]);if(this.tmpPoints.length>0){var P=this.tmpPoints[this.tmpPoints.length-1],S=_.Sub(y,P).uni();y.setv(S);}this.tmpPoints.push(y);}if(this.tmpPoints.length<2)return;var a=this.transformDataAll(!0),o=(g=this.workId)==null?void 0:g.toString(),s={name:o};var l;if(o&&a.length){var _d3=n?this.fullLayer:this.drawLayer||this.fullLayer;l=this.draw({attrs:s,tasks:a,replaceId:i,layer:_d3}),(c=this.vNodes)==null||c.setInfo(o,{rect:l,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:l&&vt.getCenterPos(l,_d3)});}return l;}},{key:"transformDataAll",value:function transformDataAll(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:!0;var e=this.filterSamePoints(this.tmpPoints,this.workOptions.thickness);return this.getTaskPoints(e,t&&this.workOptions.thickness||void 0);}},{key:"draw",value:function draw(t){var _this64=this;var e=t.attrs,n=t.tasks,i=t.replaceId,a=t.effects,o=t.layer,s=t.removeDrawCount,_this$workOptions=this.workOptions,l=_this$workOptions.strokeColor,g=_this$workOptions.strokeType,c=_this$workOptions.thickness,d=_this$workOptions.zIndex,y=_this$workOptions.scale,P=_this$workOptions.rotate,S=_this$workOptions.translate,v=_this$workOptions.eraserlines;a!=null&&a.size&&(a.forEach(function(M){var O;(O=o.getElementById(M+""))==null||O.remove();}),a.clear()),s&&this.removeDrawCountNodes(o,s);var T;var f=[],p=o.worldPosition,u=o.worldScaling;for(var M=0;M<n.length;M++){var _n$M=n[M],O=_n$M.pos,A=_n$M.points,_this$computDrawPoint=this.computDrawPoints(A),w=_this$computDrawPoint.ps,E=_this$computDrawPoint.rect;var L=void 0;var b=A.length===1;g===Lt.Stroke||b?L=ie(w,!0):L=ie(w,!1);var I={pos:O,d:L,fillColor:g===Lt.Stroke||b?l:void 0,lineDash:g===Lt.Dotted&&!b?[1,c*2]:g===Lt.LongDotted&&!b?[c,c*2]:void 0,strokeColor:l,lineCap:g===Lt.Stroke||b?void 0:"round",lineWidth:g===Lt.Stroke||b?0:c};T=Pt(T,{x:Math.floor((E.x+O[0])*u[0]+p[0]-vt.SafeBorderPadding),y:Math.floor((E.y+O[1])*u[1]+p[1]-vt.SafeBorderPadding),w:Math.floor(E.w*u[0]+2*vt.SafeBorderPadding),h:Math.floor(E.h*u[1]+2*vt.SafeBorderPadding)}),f.push(I);}y&&(e.scale=y),P&&(e.rotate=P),S&&(e.translate=S);var m=new Zt();if(T){this.centerPos=vt.getCenterPos(T,o);var _M8=g===Lt.Stroke&&!v;m.attr(_objectSpread(_objectSpread({},e),{},{normalize:!0,anchor:[0.5,0.5],bgcolor:_M8?l:void 0,pos:this.centerPos,size:[(T.w-2*vt.SafeBorderPadding)/u[0],(T.h-2*vt.SafeBorderPadding)/u[1]],zIndex:d}));var _O4=f.map(function(A){return A.pos=[A.pos[0]-_this64.centerPos[0],A.pos[1]-_this64.centerPos[1]],new se(A);});m.append.apply(m,_toConsumableArray(_O4)),_M8&&m.seal(),v&&(this.scaleType=Nt.proportional,this.drawEraserlines({group:m,eraserlines:v,pos:this.centerPos,layer:o})),this.replace(o,i,m);}if(y||P||S){var _M9=m==null?void 0:m.getBoundingClientRect();if(_M9)return{x:Math.floor(_M9.x-vt.SafeBorderPadding),y:Math.floor(_M9.y-vt.SafeBorderPadding),w:Math.floor(_M9.width+vt.SafeBorderPadding*2),h:Math.floor(_M9.height+vt.SafeBorderPadding*2)};}return T;}},{key:"computDrawPoints",value:function computDrawPoints(t){return this.workOptions.strokeType===Lt.Stroke||t.length===1?this.computStroke(t):this.computNomal(t);}},{key:"computNomal",value:function computNomal(t){var e=this.workOptions.thickness;var n=t.map(function(i){return e=Math.max(e,i.radius),i.point;});return{ps:n,rect:Ft(n,e)};}},{key:"computStroke",value:function computStroke(t){return t.length===1?this.computDotStroke(t[0]):this.computLineStroke(t);}},{key:"computLineStroke",value:function computLineStroke(t){var e=[],n=[];for(var l=0;l<t.length;l++){var _t$l=t[l],g=_t$l.point,c=_t$l.radius;var d=g.v;l===0&&t.length>1&&(d=t[l+1].point.v);var y=_.Per(d).mul(c);e.push(xt.Sub(g,y)),n.push(xt.Add(g,y));}var i=t[t.length-1],a=xt.GetSemicircleStroke(i.point,e[e.length-1],-1,8),o=xt.GetSemicircleStroke(t[0].point,n[0],-1,8),s=e.concat(a,n.reverse(),o);return{ps:s,rect:Ft(s)};}},{key:"computDotStroke",value:function computDotStroke(t){var e=t.point,n=t.radius,i={x:e.x-n,y:e.y-n,w:n*2,h:n*2};return{ps:xt.GetDotStroke(e,n,8),rect:i};}},{key:"transformData",value:function transformData(t,e){var n=t.op,i=t.workState;var a=this.tmpPoints.length-1,o=[];if(n!=null&&n.length&&i){var _this$workOptions2=this.workOptions,s=_this$workOptions2.strokeType,l=_this$workOptions2.thickness,g=/* @__PURE__ */new Set();a=s===Lt.Stroke?this.updateTempPointsWithPressure(n,l,g):this.updateTempPoints(n,l,g);var c=e?this.tmpPoints:this.tmpPoints.slice(a);return o=this.getTaskPoints(c,l),{tasks:o,effects:g,consumeIndex:a};}return{tasks:o,consumeIndex:a};}/** 压力渐变公式 */},{key:"computRadius",value:function computRadius(t,e){return t*0.03*e+e*0.5;}},{key:"getMinZ",value:function getMinZ(t,e){return((e||Math.max(1,Math.floor(t*0.3)))-t*0.5)*100/t/3;}},{key:"getTaskPoints",value:function getTaskPoints(t,e){var c;var n=[];if(t.length===0)return[];var i=0,a=t[0].x,o=t[0].y,s=[a,o],l=[],g=t[0].t;for(;i<t.length;){var d=t[i],y=d.x-a,P=d.y-o,S=d.z,v=e?this.computRadius(S,e):S;if(l.push({point:new xt(y,P,S,t[i].v),radius:v}),i>0&&i<t.length-1){var _T28=t[i].getAngleByPoints(t[i-1],t[i+1]);if(_T28<60||_T28>300){var _f27=(c=l.pop())==null?void 0:c.point.clone();_f27&&n.push({taskId:g,pos:s,points:[].concat(_toConsumableArray(l),[{point:_f27,radius:v}])}),a=t[i].x,o=t[i].y,s=[a,o];var p=d.x-a,u=d.y-o;l=[{point:new xt(p,u,S),radius:v}],g=Date.now();}}i++;}return n.push({taskId:g,pos:s,points:l}),n;}},{key:"updateTempPointsWithPressure",value:function updateTempPointsWithPressure(t,e,n){var i=Date.now(),a=this.tmpPoints.length;var o=a;for(var l=0;l<t.length;l+=2){o=Math.min(o,a);var g=this.tmpPoints.length,c=new xt(t[l],t[l+1]);if(g===0){this.tmpPoints.push(c);continue;}var d=g-1,y=this.tmpPoints[d],P=_.Sub(c,y).uni();if(c.isNear(y,e)){if(y.z<this.MAX_REPEAR){if(y.setz(Math.min(y.z+1,this.MAX_REPEAR)),o=Math.min(o,d),g>1){var _T29=g-1;for(;_T29>0;){var _f28=this.tmpPoints[_T29].distance(this.tmpPoints[_T29-1]),p=Math.max(this.tmpPoints[_T29].z-this.uniThickness*_f28,0);if(this.tmpPoints[_T29-1].z>=p)break;this.tmpPoints[_T29-1].setz(p),o=Math.min(o,_T29-1),_T29--;}}}else o=1/0;continue;}c.setv(P);var S=c.distance(y),v=Math.max(y.z-this.uniThickness*S,0);g>1&&_.Equals(P,y.v,0.02)&&(v>0||y.z<=0)&&(n&&y.t&&n.add(y.t),this.tmpPoints.pop(),o=Math.min(d,o)),c.setz(v),this.tmpPoints.push(c);}if(o===1/0)return this.tmpPoints.length;var s=a;if(o===a){s=Math.max(s-1,0);var _l4=this.tmpPoints[s].t;_l4&&(n==null||n.add(_l4));}else{var _l5=a-1;for(s=o;_l5>=0;){var _g6=this.tmpPoints[_l5].t;if(_g6&&(n==null||n.add(_g6),_l5<=o)){s=_l5,_l5=-1;break;}_l5--;}}return this.tmpPoints[s].setT(i),s;}},{key:"updateTempPoints",value:function updateTempPoints(t,e,n){var l;var i=Date.now(),a=this.tmpPoints.length;var o=a;for(var g=0;g<t.length;g+=2){var c=this.tmpPoints.length,d=new xt(t[g],t[g+1]);if(c===0){this.tmpPoints.push(d);continue;}var y=c-1,P=this.tmpPoints[y],S=_.Sub(d,P).uni();if(d.isNear(P,e/2)){o=Math.min(y,o);continue;}_.Equals(S,P.v,0.02)&&(n&&P.t&&n.add(P.t),this.tmpPoints.pop(),o=Math.min(y,o)),d.setv(S),this.tmpPoints.push(d);}var s=a;if(o===a){s=Math.max(s-1,0);var _g7=this.tmpPoints[s].t;_g7&&(n==null||n.add(_g7));}else{var _g8=Math.min(a-1,o);for(s=o;_g8>=0;){var _c4=(l=this.tmpPoints[_g8])==null?void 0:l.t;if(_c4&&(n==null||n.add(_c4),_g8<=o)){s=_g8,_g8=-1;break;}_g8--;}}return this.tmpPoints[s].setT(i),s;}},{key:"updateTempPointsWithPressureWhenDone",value:function updateTempPointsWithPressureWhenDone(t){var e=this.workOptions.thickness,n=t.length,i=this.getMinZ(e);for(var a=0;a<n;a+=2){var o=this.tmpPoints.length,s=new xt(t[a],t[a+1]);if(o===0){this.tmpPoints.push(s);continue;}var l=o-1,g=this.tmpPoints[l],c=_.Sub(s,g).uni(),d=s.distance(g);if(o>1&&g.z===i)break;if(s.isNear(g,e/2)){if(n<3&&g.z<this.MAX_REPEAR&&(g.setz(Math.min(g.z+1,this.MAX_REPEAR)),o>1)){var P=o-1;for(;P>0;){var S=this.tmpPoints[P].distance(this.tmpPoints[P-1]),v=Math.max(this.tmpPoints[P].z-this.uniThickness*S,-e/4);if(this.tmpPoints[P-1].z>=v)break;this.tmpPoints[P-1].setz(v),P--;}}continue;}s.setv(c);var y=Math.max(g.z-this.uniThickness*d,i);o>1&&_.Equals(c,g.v,0.02)&&g.z<=0&&this.tmpPoints.pop(),s.setz(y),this.tmpPoints.push(s);}}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var l,g;var e=t.node,n=t.opt,i=t.vNodes,a=n.strokeColor,o=n.strokeType,s=i.get(e.name);return a&&(e.tagName==="GROUP"?Zp(e)?e.setAttribute("bgcolor",a):e.children.forEach(function(c){c.setAttribute("strokeColor",a),c.getAttribute("fillColor")&&c.setAttribute("fillColor",a);}):(e.setAttribute("strokeColor",a),e.setAttribute("fillColor",a)),(l=s==null?void 0:s.opt)!=null&&l.strokeColor&&(s.opt.strokeColor=a)),o&&s!=null&&s.opt&&(g=s.opt)!=null&&g.strokeType&&(s.opt.strokeType=o),s&&i.setInfo(e.name,s),vt.updateNodeOpt(t);}}]);}(vt);var di=/*#__PURE__*/function(_vt2){function di(t){var _this65;_classCallCheck(this,di);_this65=_callSuper(this,di,[t]);tt(_this65,"toolsType",dt.LaserPen);tt(_this65,"canRotate",!1);tt(_this65,"scaleType",Nt.none);tt(_this65,"syncTimestamp");tt(_this65,"syncIndex",0);tt(_this65,"tmpPoints",[]);tt(_this65,"workOptions");tt(_this65,"consumeIndex",0);_this65.workOptions=t.toolsOpt,_this65.syncTimestamp=0;return _this65;}_inherits(di,_vt2);return _createClass(di,[{key:"combineConsume",value:function combineConsume(){}},{key:"setWorkOptions",value:function setWorkOptions(t){_superPropGet(di,"setWorkOptions",this,3)([t]),this.syncTimestamp=Date.now();}},{key:"consume",value:function consume(t){var e=t.data,n=t.isSubWorker,i=e.workId,a=e.op;if((a==null?void 0:a.length)===0)return{type:ot.None};if(this.updateTempPoints(a||[]),this.consumeIndex>this.tmpPoints.length-4)return{type:ot.None};var _this$workOptions3=this.workOptions,o=_this$workOptions3.strokeColor,s=_this$workOptions3.thickness,l=_this$workOptions3.strokeType,g=Ft(this.tmpPoints,s);var c=!1;var d=this.syncIndex,y=this.tmpPoints.slice(this.consumeIndex);this.consumeIndex=this.tmpPoints.length-1,this.syncTimestamp===0&&(this.syncTimestamp=Date.now());var P={name:i==null?void 0:i.toString(),opacity:1,lineDash:l===Lt.Dotted?[1,s*2]:l===Lt.LongDotted?[s,s*2]:void 0,strokeColor:o,lineCap:"round",lineWidth:s,anchor:[0.5,0.5]},S=this.getTaskPoints(y);if(S.length){var _T30=Date.now();_T30-this.syncTimestamp>this.syncUnitTime&&(c=!0,this.syncTimestamp=_T30,this.syncIndex=this.tmpPoints.length),n&&this.draw({attrs:P,tasks:S,isDot:!1,layer:this.drawLayer||this.fullLayer});}var v=[];return this.tmpPoints.slice(d).forEach(function(T){v.push(T.x,T.y);}),_objectSpread({rect:{x:g.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:g.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:g.w*this.fullLayer.worldScaling[0],h:g.h*this.fullLayer.worldScaling[1]},type:ot.DrawWork,dataType:Tt.Local,op:c?v:void 0,index:c?d*2:void 0},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var a;var t=(a=this.workId)==null?void 0:a.toString();var e;if(this.tmpPoints.length-1>this.consumeIndex){var o=this.tmpPoints.slice(this.consumeIndex);var s=o.length===1,_this$workOptions4=this.workOptions,l=_this$workOptions4.strokeColor,g=_this$workOptions4.thickness,c=_this$workOptions4.strokeType;if(s){var P=this.computDotStroke({point:o[0],radius:g/2});o=P.ps,e=P.rect;}else e=Ft(this.tmpPoints,g);var d={name:t==null?void 0:t.toString(),fillColor:s?l:void 0,opacity:1,lineDash:c===Lt.Dotted&&!s?[1,g*2]:c===Lt.LongDotted&&!s?[g,g*2]:void 0,strokeColor:l,lineCap:s?void 0:"round",lineWidth:s?0:g,anchor:[0.5,0.5]},y=this.getTaskPoints(o);y.length&&this.draw({attrs:d,tasks:y,isDot:s,layer:this.drawLayer||this.fullLayer});}var n=[];this.tmpPoints.forEach(function(o){n.push(o.x,o.y);});var i=Qt(n);return _objectSpread({rect:e&&{x:e.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:e.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:e.w*this.fullLayer.worldScaling[0],h:e.h*this.fullLayer.worldScaling[1]},type:ot.FullWork,dataType:Tt.Local,ops:i,index:this.syncIndex*2},this.baseConsumeResult);}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0;}},{key:"consumeService",value:function consumeService(t){var S;var e=t.op,n=t.replaceId,i=t.isFullWork,_this$workOptions5=this.workOptions,a=_this$workOptions5.strokeColor,o=_this$workOptions5.thickness,s=_this$workOptions5.strokeType;if(!e.length){var v=Ft(this.tmpPoints,o);return{x:v.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:v.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:v.w*this.fullLayer.worldScaling[0],h:v.h*this.fullLayer.worldScaling[1]};}var l=Math.max(0,this.tmpPoints.length-1);this.updateTempPoints(e||[]);var g,c=this.tmpPoints.slice(l);var d=c.length===1;if(d){var _v6=this.computDotStroke({point:c[0],radius:o/2});c=_v6.ps,g=_v6.rect;}else g=Ft(this.tmpPoints,o);var y={name:(S=this.workId)==null?void 0:S.toString(),fillColor:d?a:void 0,opacity:1,lineDash:s===Lt.Dotted&&!d?[1,o*2]:s===Lt.LongDotted&&!d?[o,o*2]:void 0,strokeColor:a,lineCap:d?void 0:"round",lineWidth:d?0:o,anchor:[0.5,0.5]},P=this.getTaskPoints(c);if(P.length){var _v7=i?this.fullLayer:this.drawLayer||this.fullLayer;this.draw({attrs:y,tasks:P,isDot:d,replaceId:n,layer:_v7});}return{x:g.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:g.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:g.w*this.fullLayer.worldScaling[0],h:g.h*this.fullLayer.worldScaling[1]};}},{key:"computDotStroke",value:function computDotStroke(t){var e=t.point,n=t.radius,i={x:e.x-n,y:e.y-n,w:n*2,h:n*2};return{ps:xt.GetDotStroke(e,n,8),rect:i};}},{key:"updateTempPoints",value:function updateTempPoints(t){var e=this.tmpPoints.length;for(var n=0;n<t.length;n+=2){if(e){var i=this.tmpPoints.slice(-1)[0];i&&i.x===t[n]&&i.y===t[n+1]&&this.tmpPoints.pop();}this.tmpPoints.push(new xt(t[n],t[n+1]));}}},{key:"draw",value:function(){var _draw2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21(t){var _this66=this;var e,n,i,a,o,_iterator15,_step15,_loop3;return _regeneratorRuntime().wrap(function _callee21$(_context23){while(1)switch(_context23.prev=_context23.next){case 0:e=t.attrs,n=t.tasks,i=t.isDot,a=t.layer,o=this.workOptions.duration;_iterator15=_createForOfIteratorHelper(n);_context23.prev=2;_loop3=/*#__PURE__*/_regeneratorRuntime().mark(function _loop3(){var s,l,g,c,d,_this66$workOptions,y,P,S,_a$getResolution,v,_T31;return _regeneratorRuntime().wrap(function _loop3$(_context22){while(1)switch(_context22.prev=_context22.next){case 0:s=_step15.value;l=new se(),g=s.pos,c=s.points;i?d=ie(c,!0):d=ie(c,!1),l.attr(_objectSpread(_objectSpread({},e),{},{pos:g,d:d}));_this66$workOptions=_this66.workOptions,y=_this66$workOptions.vertex,P=_this66$workOptions.fragment;if(y&&P){S=a.renderer.createProgram({vertex:y,fragment:P}),_a$getResolution=a.getResolution(),v=_a$getResolution.width,_T31=_a$getResolution.height;l.setUniforms({u_time:0,u_resolution:[v,_T31]}),l.setProgram(S);}a.appendChild(l),l.transition(o).attr({scale:i?[0.1,0.1]:[1,1],lineWidth:i?0:1}).then(function(){l.remove();});case 6:case"end":return _context22.stop();}},_loop3);});_iterator15.s();case 5:if((_step15=_iterator15.n()).done){_context23.next=9;break;}return _context23.delegateYield(_loop3(),"t0",7);case 7:_context23.next=5;break;case 9:_context23.next=14;break;case 11:_context23.prev=11;_context23.t1=_context23["catch"](2);_iterator15.e(_context23.t1);case 14:_context23.prev=14;_iterator15.f();return _context23.finish(14);case 17:case"end":return _context23.stop();}},_callee21,this,[[2,11,14,17]]);}));function draw(_x23){return _draw2.apply(this,arguments);}return draw;}()},{key:"getTaskPoints",value:function getTaskPoints(t){var l;var e=[];if(t.length===0)return[];var n=0,i=t[0].x,a=t[0].y,o=[i,a],s=[];for(;n<t.length;){var g=t[n],c=g.x-i,d=g.y-a;if(s.push(new xt(c,d)),n>0&&n<t.length-1){var y=t[n].getAngleByPoints(t[n-1],t[n+1]);if(y<60||y>300){var P=(l=s.pop())==null?void 0:l.clone();P&&e.push({pos:o,points:[].concat(_toConsumableArray(s),[P])}),i=t[n].x,a=t[n].y,o=[i,a];var S=g.x-i,v=g.y-a;s=[new xt(S,v)];}}n++;}return e.push({pos:o,points:s}),e;}},{key:"removeLocal",value:function removeLocal(){}},{key:"removeService",value:function removeService(t){var e;var n=[];return this.fullLayer.getElementsByName(t).forEach(function(i){if(i.name===t){var a=i.getBoundingClientRect();e=Pt(e,{x:a.x,y:a.y,w:a.width,h:a.height}),n.push(i);}}),n.length&&n.forEach(function(i){return i.remove();}),e;}}]);}(vt);var wd=Ke;Ke.polyline=Ke;Ke.polygon=bd;function Ke(h,r,t){var e=h.length,n=ve(h[0],r),i=[],a,o,s,l,g;for(t||(t=[]),a=1;a<e;a++){for(o=h[a-1],s=h[a],l=g=ve(s,r);;)if(n|l){if(n&l)break;n?(o=yr(o,s,n,r),n=ve(o,r)):(s=yr(o,s,l,r),l=ve(s,r));}else{i.push(o),l!==g?(i.push(s),a<e-1&&(t.push(i),i=[])):a===e-1&&i.push(s);break;}n=g;}return i.length&&t.push(i),t;}function bd(h,r){var t,e,n,i,a,o,s;for(e=1;e<=8;e*=2){for(t=[],n=h[h.length-1],i=!(ve(n,r)&e),a=0;a<h.length;a++)o=h[a],s=!(ve(o,r)&e),s!==i&&t.push(yr(n,o,e,r)),s&&t.push(o),n=o,i=s;if(h=t,!h.length)break;}return t;}function yr(h,r,t,e){return t&8?[h[0]+(r[0]-h[0])*(e[3]-h[1])/(r[1]-h[1]),e[3]]:// top
|
|
410
410
|
t&4?[h[0]+(r[0]-h[0])*(e[1]-h[1])/(r[1]-h[1]),e[1]]:// bottom
|
|
411
411
|
t&2?[e[2],h[1]+(r[1]-h[1])*(e[2]-h[0])/(r[0]-h[0])]:// right
|
|
412
412
|
t&1?[e[0],h[1]+(r[1]-h[1])*(e[0]-h[0])/(r[0]-h[0])]:// left
|
|
@@ -439,7 +439,7 @@ tt(Se,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.fr
|
|
|
439
439
|
* @param {Array} p2 终点坐标
|
|
440
440
|
* @param {Array} cp1 控制点1
|
|
441
441
|
* @param {Array} cp2 控制点2
|
|
442
|
-
*/},{key:"threeBezier",value:function threeBezier(r,t,e,n,i){var a=t.x*(1-r)*(1-r)*(1-r)+3*e.x*r*(1-r)*(1-r)+3*n.x*r*r*(1-r)+i.x*r*r*r,o=t.y*(1-r)*(1-r)*(1-r)+3*e.y*r*(1-r)*(1-r)+3*n.y*r*r*(1-r)+i.y*r*r*r;return new _(a,o);}}]);}();var Ti=/*#__PURE__*/function(_vt10){function Ti(t){var _this80;_classCallCheck(this,Ti);_this80=_callSuper(this,Ti,[t]);tt(_this80,"canRotate",!1);tt(_this80,"scaleType",Nt.all);tt(_this80,"toolsType",dt.SpeechBalloon);tt(_this80,"ratio",0.8);tt(_this80,"tmpPoints",[]);tt(_this80,"workOptions");tt(_this80,"oldRect");tt(_this80,"syncTimestamp");_this80.workOptions=t.toolsOpt,_this80.syncTimestamp=0,_this80.syncUnitTime=50;return _this80;}_inherits(Ti,_vt10);return _createClass(Ti,[{key:"consume",value:function consume(t){var y;var e=t.data,n=t.isFullWork,i=t.isSubWorker,a=t.isMainThread,o=(y=e==null?void 0:e.workId)==null?void 0:y.toString();if(!o)return{type:ot.None};var s=e.op,l=s==null?void 0:s.length;if(!l||l<2)return{type:ot.None};var g;if(this.tmpPoints.length===0?(this.tmpPoints=[new xt(s[0],s[1])],g=!1):g=this.updateTempPoints(s),!g)return{type:ot.None};var c;if(i||a){var P=n?this.fullLayer:this.drawLayer||this.fullLayer;c=this.draw({workId:o,layer:P,isDrawing:!0});}if(!i){var _P3=Date.now();return _P3-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_P3,_objectSpread({type:ot.DrawWork,dataType:Tt.Local,op:this.tmpPoints.map(function(S){return[].concat(_toConsumableArray(S.XY),[0]);}).flat(1),isSync:!0,index:0},this.baseConsumeResult)):{type:ot.None};}var d=Pt(c,this.oldRect);return this.oldRect=c,_objectSpread({rect:d,type:ot.DrawWork,dataType:Tt.Local},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var o;var t=this.workId;if(this.tmpPoints.length<2)return{type:ot.RemoveNode,removeIds:[t]};var e=this.fullLayer,n=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=n;var i=this.tmpPoints.map(function(s){return[].concat(_toConsumableArray(s.XY),[0]);}).flat(1),a=Qt(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&&vt.getCenterPos(n,e)}),_objectSpread({rect:n,type:ot.FullWork,dataType:Tt.Local,ops:a,isSync:!0},this.baseConsumeResult);}},{key:"draw",value:function draw(t){var e=t.workId,n=t.layer,_this$workOptions11=this.workOptions,i=_this$workOptions11.strokeColor,a=_this$workOptions11.fillColor,o=_this$workOptions11.thickness,s=_this$workOptions11.zIndex,l=_this$workOptions11.placement,g=_this$workOptions11.scale,c=_this$workOptions11.rotate,d=_this$workOptions11.translate,y=_this$workOptions11.strokeType,P=_this$workOptions11.eraserlines,_this$computDrawPoint7=this.computDrawPoints(o,l),S=_this$computDrawPoint7.rect,v=_this$computDrawPoint7.pos,T=_this$computDrawPoint7.points,f={points:T.map(function(O){return O.XY;}),lineWidth:o,fillColor:a!=="transparent"&&a||void 0,strokeColor:i,normalize:!0,className:"".concat(v[0],",").concat(v[1]),close:!0,lineJoin:"round",lineCap:"round",lineDash:y===Lt.Dotted?[1,o*2]:y===Lt.LongDotted?[o,o*2]:void 0},p={name:e,id:e,zIndex:s,pos:v,anchor:[0.5,0.5],size:[S.w,S.h]};g&&(p.scale=g),c&&(p.rotate=c),d&&(p.translate=d);var u=new Zt(p),m=new ce(_objectSpread(_objectSpread({},f),{},{pos:[0,0]}));u.append(m),P&&(this.scaleType=Nt.proportional,this.drawEraserlines({group:u,eraserlines:P,pos:v,layer:n})),this.replace(n,e,u);var M=u.getBoundingClientRect();return{x:Math.floor(M.x-vt.SafeBorderPadding),y:Math.floor(M.y-vt.SafeBorderPadding),w:Math.floor(M.width+vt.SafeBorderPadding*2),h:Math.floor(M.height+vt.SafeBorderPadding*2)};}},{key:"transformControlPoints",value:function transformControlPoints(t){var e=Ft(this.tmpPoints);switch(t){case"bottom":case"bottomLeft":case"bottomRight":{var n=e.y+e.h*this.ratio;return[new _(e.x,e.y,0),new _(e.x+e.w,e.y,0),new _(e.x+e.w,n,0),new _(e.x,n,0)];}case"top":case"topLeft":case"topRight":{var _n4=e.y+e.h*(1-this.ratio);return[new _(e.x,_n4,0),new _(e.x+e.w,_n4,0),new _(e.x+e.w,e.y+e.h,0),new _(e.x,e.y+e.h,0)];}case"left":case"leftBottom":case"leftTop":{var _n5=e.x+e.w*(1-this.ratio);return[new _(_n5,e.y,0),new _(e.x+e.w,e.y,0),new _(e.x+e.w,e.y+e.h,0),new _(_n5,e.y+e.h,0)];}case"right":case"rightBottom":case"rightTop":{var _n6=e.x+e.w*this.ratio;return[new _(e.x,e.y,0),new _(_n6,e.y,0),new _(_n6,e.y+e.h,0),new _(e.x,e.y+e.h,0)];}}}},{key:"computDrawPoints",value:function computDrawPoints(t,e){var n=Ft(this.tmpPoints),i=this.transformControlPoints(e),a=Math.floor(n.w*0.1),o=Math.floor(n.h*0.1),s=[],l=_.Add(i[0],new _(0,o,0)),g=_.Add(i[0],new _(a,0,0)),c=_t.getBezierPoints(10,l,i[0],g),d=_.Sub(i[1],new _(a,0,0)),y=_.Add(i[1],new _(0,o,0)),P=_t.getBezierPoints(10,d,i[1],y),S=_.Sub(i[2],new _(0,o,0)),v=_.Sub(i[2],new _(a,0,0)),T=_t.getBezierPoints(10,S,i[2],v),f=_.Add(i[3],new _(a,0,0)),p=_.Sub(i[3],new _(0,o,0)),u=_t.getBezierPoints(10,f,i[3],p),m=a*(1-this.ratio)*10,M=o*(1-this.ratio)*10;switch(e){case"bottom":{var w=_.Sub(i[2],new _(a*5-m/2,0,0)),E=_.Sub(i[2],new _(a*5,-M,0)),L=_.Sub(i[2],new _(a*5+m/2,0,0));s.push.apply(s,[E,L].concat(_toConsumableArray(u),_toConsumableArray(c),_toConsumableArray(P),_toConsumableArray(T),[w]));break;}case"bottomRight":{var _w11=_.Sub(i[2],new _(a*1.1,0,0)),_E11=_.Sub(i[2],new _(a*1.1+m/2,-M,0)),_L8=_.Sub(i[2],new _(a*1.1+m,0,0));s.push.apply(s,[_E11,_L8].concat(_toConsumableArray(u),_toConsumableArray(c),_toConsumableArray(P),_toConsumableArray(T),[_w11]));break;}case"bottomLeft":{var _w12=_.Add(i[3],new _(a*1.1+m,0,0)),_E12=_.Add(i[3],new _(a*1.1+m/2,M,0)),_L9=_.Add(i[3],new _(a*1.1,0,0));s.push.apply(s,[_E12,_L9].concat(_toConsumableArray(u),_toConsumableArray(c),_toConsumableArray(P),_toConsumableArray(T),[_w12]));break;}case"top":{var _w13=_.Sub(i[1],new _(a*5-m/2,0,0)),_E13=_.Sub(i[1],new _(a*5,M,0)),_L10=_.Sub(i[1],new _(a*5+m/2,0,0));s.push.apply(s,[_E13,_w13].concat(_toConsumableArray(P),_toConsumableArray(T),_toConsumableArray(u),_toConsumableArray(c),[_L10]));break;}case"topRight":{var _w14=_.Sub(i[1],new _(a*1.1,0,0)),_E14=_.Sub(i[1],new _(a*1.1+m/2,M,0)),_L11=_.Sub(i[1],new _(a*1.1+m,0,0));s.push.apply(s,[_E14,_w14].concat(_toConsumableArray(P),_toConsumableArray(T),_toConsumableArray(u),_toConsumableArray(c),[_L11]));break;}case"topLeft":{var _w15=_.Add(i[0],new _(a*1.1+m,0,0)),_E15=_.Add(i[0],new _(a*1.1+m/2,-M,0)),_L12=_.Add(i[0],new _(a*1.1,0,0));s.push.apply(s,[_E15,_w15].concat(_toConsumableArray(P),_toConsumableArray(T),_toConsumableArray(u),_toConsumableArray(c),[_L12]));break;}case"left":{var _w16=_.Add(i[0],new _(0,o*5-M/2,0)),_E16=_.Add(i[0],new _(-m,o*5,0)),_L13=_.Add(i[0],new _(0,o*5+M/2,0));s.push.apply(s,[_E16,_w16].concat(_toConsumableArray(c),_toConsumableArray(P),_toConsumableArray(T),_toConsumableArray(u),[_L13]));break;}case"leftTop":{var _w17=_.Add(i[0],new _(0,o*1.1,0)),_E17=_.Add(i[0],new _(-m,o*1.1+M/2,0)),_L14=_.Add(i[0],new _(0,o*1.1+M,0));s.push.apply(s,[_E17,_w17].concat(_toConsumableArray(c),_toConsumableArray(P),_toConsumableArray(T),_toConsumableArray(u),[_L14]));break;}case"leftBottom":{var _w18=_.Sub(i[3],new _(0,o*1.1+M,0)),_E18=_.Sub(i[3],new _(m,o*1.1+M/2,0)),_L15=_.Sub(i[3],new _(0,o*1.1,0));s.push.apply(s,[_E18,_w18].concat(_toConsumableArray(c),_toConsumableArray(P),_toConsumableArray(T),_toConsumableArray(u),[_L15]));break;}case"right":{var _w19=_.Add(i[1],new _(0,o*5-M/2,0)),_E19=_.Add(i[1],new _(m,o*5,0)),_L16=_.Add(i[1],new _(0,o*5+M/2,0));s.push.apply(s,[_E19,_L16].concat(_toConsumableArray(T),_toConsumableArray(u),_toConsumableArray(c),_toConsumableArray(P),[_w19]));break;}case"rightTop":{var _w20=_.Add(i[1],new _(0,o*1.1,0)),_E20=_.Add(i[1],new _(m,o*1.1+M/2,0)),_L17=_.Add(i[1],new _(0,o*1.1+M,0));s.push.apply(s,[_E20,_L17].concat(_toConsumableArray(T),_toConsumableArray(u),_toConsumableArray(c),_toConsumableArray(P),[_w20]));break;}case"rightBottom":{var _w21=_.Sub(i[2],new _(0,o*1.1+M,0)),_E21=_.Sub(i[2],new _(-m,o*1.1+M/2,0)),_L18=_.Sub(i[2],new _(0,o*1.1,0));s.push.apply(s,[_E21,_L18].concat(_toConsumableArray(T),_toConsumableArray(u),_toConsumableArray(c),_toConsumableArray(P),[_w21]));break;}}var O=Ft(this.tmpPoints,t),A=[Math.floor(O.x+O.w/2),Math.floor(O.y+O.h/2)];return{rect:O,pos:A,points:s};}},{key:"updateTempPoints",value:function updateTempPoints(t){var e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],a=this.workOptions.thickness;if(i.isNear(n,a)||xt.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 s,l;var e=t.op,n=t.isFullWork,i=(s=this.workId)==null?void 0:s.toString();if(!i)return;this.tmpPoints.length=0;for(var g=0;g<e.length;g+=3)this.tmpPoints.push(new xt(e[g],e[g+1],e[g+2]));var a=n?this.fullLayer:this.drawLayer||this.fullLayer,o=this.draw({workId:i,layer:a,isDrawing:!1});return this.oldRect=o,(l=this.vNodes)==null||l.setInfo(i,{rect:o,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&vt.getCenterPos(o,a)}),o;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var P;var e=t.node,n=t.opt,i=t.vNodes,a=n.strokeColor,o=n.fillColor,s=n.toolsType,l=n.placement,g=n.strokeType,c=i.get(e.name),d=c==null?void 0:c.opt;var y=e;return e.tagName==="GROUP"&&(y=e.children[0]),a&&(y.setAttribute("strokeColor",a),d!=null&&d.strokeColor&&(d.strokeColor=a)),o&&(o==="transparent"?y.setAttribute("fillColor","rgba(0,0,0,0)"):y.setAttribute("fillColor",o),d!=null&&d.fillColor&&(d.fillColor=o)),s===dt.SpeechBalloon&&l&&(d.placement=l),g&&c!=null&&c.opt&&(P=c.opt)!=null&&P.strokeType&&(c.opt.strokeType=g),c&&i.setInfo(e.name,_objectSpread(_objectSpread({},c),{},{opt:d})),vt.updateNodeOpt(t);}}]);}(vt);var Bp=de,Fp=ne,Up="[object Boolean]";function jp(h){return h===!0||h===!1||Fp(h)&&Bp(h)==Up;}var $p=jp,ye=/* @__PURE__ */fe($p);var Ne=/*#__PURE__*/function(_vt11){function Ne(t){var _this81;_classCallCheck(this,Ne);_this81=_callSuper(this,Ne,[t]);tt(_this81,"canRotate",!0);tt(_this81,"scaleType",Nt.all);tt(_this81,"toolsType",dt.Image);tt(_this81,"tmpPoints",[]);tt(_this81,"workOptions");tt(_this81,"oldRect");_this81.workOptions=t.toolsOpt,_this81.scaleType=Ne.getScaleType(_this81.workOptions);return _this81;}_inherits(Ne,_vt11);return _createClass(Ne,[{key:"consume",value:function consume(){return{type:ot.None};}},{key:"consumeAll",value:function consumeAll(){return{type:ot.None};}},{key:"draw",value:function draw(t){var e=t.layer,n=t.workId,i=t.replaceId,a=t.imageBitmap,_this$workOptions12=this.workOptions,o=_this$workOptions12.centerX,s=_this$workOptions12.centerY,l=_this$workOptions12.width,g=_this$workOptions12.height,c=_this$workOptions12.rotate,d=_this$workOptions12.zIndex,y=_this$workOptions12.eraserlines,P=new Zt({anchor:[0.5,0.5],pos:[o,s],name:n,size:[l,g],zIndex:d,rotate:c}),S={anchor:[0.5,0.5],pos:[0,0],size:[l,g],texture:a};a||(S.bgcolor="rgba(0,0,0,0.3)");var v=new es(S);P.append(v),y&&this.drawEraserlines({group:P,eraserlines:y,pos:[o,s],layer:e}),this.replace(e,i||n,P);var T=P.getBoundingClientRect();if(T)return{x:Math.floor(T.x-vt.SafeBorderPadding),y:Math.floor(T.y-vt.SafeBorderPadding),w:Math.floor(T.width+vt.SafeBorderPadding*2),h:Math.floor(T.height+vt.SafeBorderPadding*2)};}},{key:"consumeService",value:function consumeService(){}},{key:"consumeServiceAsync",value:function(){var _consumeServiceAsync=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23(t){var g,c,d,y,e,n,i,_this$workOptions13,a,o,s,l,P,S;return _regeneratorRuntime().wrap(function _callee23$(_context25){while(1)switch(_context25.prev=_context25.next){case 0:e=t.isFullWork,n=t.replaceId,i=t.worker,_this$workOptions13=this.workOptions,a=_this$workOptions13.src,o=_this$workOptions13.uuid,s=((g=this.workId)==null?void 0:g.toString())||o,l=e?this.fullLayer:this.drawLayer||this.fullLayer;if(!a){_context25.next=8;break;}_context25.next=4;return i.loadImageBitMap({toolsType:this.toolsType,opt:this.workOptions,workId:s,isSubWorker:i instanceof Di});case 4:P=_context25.sent;if(!P){_context25.next=8;break;}S=this.draw({workId:s,layer:l,replaceId:n,imageBitmap:P});return _context25.abrupt("return",(this.oldRect=s&&((d=(c=this.vNodes)==null?void 0:c.get(s))==null?void 0:d.rect)||void 0,(y=this.vNodes)==null||y.setInfo(s,{rect:S,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:S&&vt.getCenterPos(S,l)}),S));case 8:case"end":return _context25.stop();}},_callee23,this);}));function consumeServiceAsync(_x25){return _consumeServiceAsync.apply(this,arguments);}return consumeServiceAsync;}()},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"getScaleType",value:function getScaleType(t){var e=t.uniformScale,n=t.rotate;return e!==!1||n&&Math.abs(n)%90>0?Nt.proportional:Nt.all;}},{key:"updateNodeOpt",value:function updateNodeOpt(t){var e=t.node,n=t.opt,i=t.vNodes,a=t.targetNode,o=n.translate,s=n.originPoint,l=n.scenePoint,g=n.scale,c=n.angle,d=n.isLocked,y=n.zIndex,P=n.strokeColor,S=a&&Jt(a)||i.get(e.name);if(!S)return;var v=e.parent;if(v){if(P&&(S.opt.strokeColor=P),Vt(y)&&(e.setAttribute("zIndex",y),S.opt.zIndex=y),ye(d)&&(S.opt.locked=d),s&&l&&g&&o){var _S$opt=S.opt,_T33=_S$opt.centerX,_f29=_S$opt.centerY,p=_S$opt.width,u=_S$opt.height,m=_S$opt.uniformScale,M=m!==!1?[g[0],g[0]]:g,O=[_T33,_f29],A=[_T33,_f29];Ur(A,l,M,o);var w=[A[0]-O[0],A[1]-O[1]];if(S.centerPos=[S.centerPos[0]+w[0],S.centerPos[1]+w[1]],S.opt.width=Math.round(p*M[0]),S.opt.height=Math.round(u*M[1]),S.opt.centerX=A[0],S.opt.centerY=A[1],S.opt.eraserlines)for(var _i6=0,_Object$values4=Object.values(S.opt.eraserlines);_i6<_Object$values4.length;_i6++){var E=_Object$values4[_i6];var L=E.op,b=E.thickness;E.thickness=b*Math.max(g[0],g[1]);for(var I=0;I<L.length;I++)jr(L[I],l,g,o);}}else if(o){if(S.opt.centerX=S.opt.centerX+o[0],S.opt.centerY=S.opt.centerY+o[1],S.centerPos=[S.centerPos[0]+o[0],S.centerPos[1]+o[1]],S.opt.eraserlines)for(var _i7=0,_Object$values5=Object.values(S.opt.eraserlines);_i7<_Object$values5.length;_i7++){var _T34=_Object$values5[_i7];var _f30=_T34.op;for(var _p12=0;_p12<_f30.length;_p12++){var _u13=_f30[_p12].map(function(m,M){return M%2?m+o[1]:m+o[0];});_T34.op[_p12]=_u13;}}}else if(Vt(c))if(S.opt.rotate=c,S.scaleType=Ne.getScaleType(S.opt),a){var _T35=Ei(S.rect,c);S.rect=_T35;}else{var _T36=vt.getRectFromLayer(v,e.name);S.rect=_T36||S.rect;}return S&&i.setInfo(e.name,S),S==null?void 0:S.rect;}}}]);}(vt);var Mi=/*#__PURE__*/function(_vt12){function Mi(t){var _this82;_classCallCheck(this,Mi);_this82=_callSuper(this,Mi,[t]);tt(_this82,"canRotate",!1);tt(_this82,"scaleType",Nt.both);tt(_this82,"toolsType",dt.Straight);tt(_this82,"tmpPoints",[]);tt(_this82,"workOptions");tt(_this82,"oldRect");tt(_this82,"straightTipWidth");tt(_this82,"syncTimestamp");_this82.workOptions=t.toolsOpt,_this82.straightTipWidth=_this82.workOptions.thickness/2,_this82.syncTimestamp=0,_this82.syncUnitTime=50;return _this82;}_inherits(Mi,_vt12);return _createClass(Mi,[{key:"consume",value:function consume(t){var e=t.data,n=t.isFullWork,i=t.isSubWorker,a=t.isMainThread,o=this.workId,s=e.op,l=s==null?void 0:s.length;if(!l||l<2)return{type:ot.None};var g;if(this.tmpPoints.length===0?(this.tmpPoints=[new xt(s[0],s[1])],g=!1):g=this.updateTempPoints(s),!g)return{type:ot.None};var c;if(i||a){var y=n?this.fullLayer:this.drawLayer||this.fullLayer;c=this.draw({workId:o,layer:y});}if(!i){var _y12=Date.now();return _y12-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_y12,_objectSpread({type:ot.DrawWork,dataType:Tt.Local,op:this.tmpPoints.map(function(P){return[].concat(_toConsumableArray(P.XY),[0]);}).flat(1),isSync:!0,index:0},this.baseConsumeResult)):{type:ot.None};}var d=Pt(c,this.oldRect);return this.oldRect=c,_objectSpread({rect:d,type:ot.DrawWork,dataType:Tt.Local},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var o;var t=this.workId;if(this.tmpPoints.length<2)return{type:ot.RemoveNode,removeIds:[t]};var e=this.fullLayer,n=this.draw({workId:t,layer:e});this.oldRect=n;var i=this.tmpPoints.map(function(s){return[].concat(_toConsumableArray(s.XY),[0]);}).flat(1),a=Qt(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&&vt.getCenterPos(n,e)}),_objectSpread({rect:n,type:ot.FullWork,dataType:Tt.Local,ops:a,isSync:!0},this.baseConsumeResult);}},{key:"draw",value:function draw(t){var e=t.workId,n=t.layer,_this$workOptions14=this.workOptions,i=_this$workOptions14.strokeColor,a=_this$workOptions14.thickness,o=_this$workOptions14.zIndex,s=_this$workOptions14.scale,l=_this$workOptions14.rotate,g=_this$workOptions14.translate,c=_this$workOptions14.strokeType,d=_this$workOptions14.eraserlines,y=n.worldPosition,P=n.worldScaling,_this$computDrawPoint8=this.computDrawPoints(a,c),S=_this$computDrawPoint8.d,v=_this$computDrawPoint8.rect,T=_this$computDrawPoint8.isDot,f=[v.x+v.w/2,v.y+v.h/2],p=new Zt({pos:f,anchor:[0.5,0.5],size:[v.w,v.h],name:e,id:e,normalize:!0,zIndex:o}),u={pos:[0,0],normalize:!0,d:S,fillColor:i,strokeColor:i,lineDash:c===Lt.Dotted&&!T?[1,a*2]:c===Lt.LongDotted&&!T?[a,a*2]:void 0,lineCap:c===Lt.Normal||T?void 0:"round",lineWidth:c===Lt.Normal||T?0:a};s&&(u.scale=s),l&&(u.rotate=l),g&&(u.translate=g);var m=new se(u);if(p.append(m),d&&(this.scaleType=Nt.proportional,this.drawEraserlines({group:p,eraserlines:d,pos:f,layer:n})),this.replace(n,e,p),l||s||g){var O=m.getBoundingClientRect();return{x:Math.floor(O.x-vt.SafeBorderPadding),y:Math.floor(O.y-vt.SafeBorderPadding),w:Math.floor(O.width+vt.SafeBorderPadding*2),h:Math.floor(O.height+vt.SafeBorderPadding*2)};}return{x:Math.floor(v.x*P[0]+y[0]-vt.SafeBorderPadding),y:Math.floor(v.y*P[1]+y[1]-vt.SafeBorderPadding),w:Math.floor(v.w*P[0]+2*vt.SafeBorderPadding),h:Math.floor(v.h*P[1]+2*vt.SafeBorderPadding)};}},{key:"computDrawPoints",value:function computDrawPoints(t,e){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.straightTipWidth?this.computFullPoints(t,e):this.computDotPoints(t);}},{key:"computFullPoints",value:function computFullPoints(t,e){var n=_.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),i=_.Per(n).mul(t/2),a=xt.Sub(this.tmpPoints[0],i),o=xt.Add(this.tmpPoints[0],i),s=xt.Sub(this.tmpPoints[1],i),l=xt.Add(this.tmpPoints[1],i),g=xt.GetSemicircleStroke(this.tmpPoints[1],s,-1,8),c=xt.GetSemicircleStroke(this.tmpPoints[0],o,-1,8),d=[a,s].concat(_toConsumableArray(g),[l,o],_toConsumableArray(c));var y;return e!==Lt.Normal?y=ie(this.tmpPoints,!1):y=ie(d,!0),{d:y,rect:Ft(d),isDot:!1,pos:this.tmpPoints[0].XY};}},{key:"computDotPoints",value:function computDotPoints(t){var e=xt.GetDotStroke(this.tmpPoints[0],t/2,8);return{d:ie(e,!0),rect:Ft(e),isDot:!0,pos:this.tmpPoints[0].XY};}},{key:"updateTempPoints",value:function updateTempPoints(t){var e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],a=this.workOptions.thickness;if(i.isNear(n,a))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 s,l;var e=t.op,n=t.isFullWork,i=(s=this.workId)==null?void 0:s.toString();if(!i)return;this.tmpPoints.length=0;for(var g=0;g<e.length;g+=3)this.tmpPoints.push(new xt(e[g],e[g+1],e[g+2]));var a=n?this.fullLayer:this.drawLayer||this.fullLayer,o=this.draw({workId:i,layer:a});return this.oldRect=o,(l=this.vNodes)==null||l.setInfo(i,{rect:o,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&vt.getCenterPos(o,a)}),o;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var l,g;var e=t.node,n=t.opt,i=t.vNodes,a=n.strokeColor,o=n.strokeType,s=i.get(e.name);return a&&(e.tagName==="GROUP"?e.children.forEach(function(c){c.setAttribute("strokeColor",a),c.getAttribute("fillColor")&&c.setAttribute("fillColor",a);}):(e.setAttribute("strokeColor",a),e.setAttribute("fillColor",a)),(l=s==null?void 0:s.opt)!=null&&l.strokeColor&&(s.opt.strokeColor=a)),o&&s!=null&&s.opt&&(g=s.opt)!=null&&g.strokeType&&(s.opt.strokeType=o),s&&i.setInfo(e.name,s),vt.updateNodeOpt(t);}}]);}(vt);var oe=/*#__PURE__*/function(_vt13){function oe(t){var _this83;_classCallCheck(this,oe);_this83=_callSuper(this,oe,[t]);tt(_this83,"canRotate",!1);tt(_this83,"scaleType",Nt.proportional);tt(_this83,"toolsType",dt.Text);tt(_this83,"tmpPoints",[]);tt(_this83,"workOptions");tt(_this83,"oldRect");_this83.workOptions=t.toolsOpt;return _this83;}_inherits(oe,_vt13);return _createClass(oe,[{key:"consume",value:function consume(){return{type:ot.None};}},{key:"consumeAll",value:function consumeAll(){return{type:ot.None};}},{key:"consumeService",value:function consumeService(){}},{key:"draw",value:function(){var _draw3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24(t){var e,n,i,_this$workOptions15,a,o,s,l,g,c,d,y,P,S,v,_T37;return _regeneratorRuntime().wrap(function _callee24$(_context26){while(1)switch(_context26.prev=_context26.next){case 0:e=t.workId,n=t.layer,i=t.isDrawLabel,_this$workOptions15=this.workOptions,a=_this$workOptions15.boxSize,o=_this$workOptions15.boxPoint,s=_this$workOptions15.zIndex,l=n.worldPosition,g=n.worldScaling;if(!(!o||!a)){_context26.next=3;break;}return _context26.abrupt("return");case 3:c={name:e,id:e,pos:[o[0],o[1]],anchor:[0,0],size:a,zIndex:s},d=new Zt(c),y={x:o[0],y:o[1],w:a[0],h:a[1]},P={x:Math.floor(y.x*g[0]+l[0]),y:Math.floor(y.y*g[1]+l[1]),w:Math.floor(y.w*g[0])+2,h:Math.floor(y.h*g[1])+2};if(!(this.replace(n,e,d),i&&n&&this.workOptions.text)){_context26.next=11;break;}_context26.next=7;return oe.createLabels(this.workOptions,n,P);case 7:S=_context26.sent;v=S.labels;_T37=S.maxWidth;d.append.apply(d,_toConsumableArray(v)),P.w=Math.ceil(Math.max(_T37*n.worldScaling[0],P.w));case 11:return _context26.abrupt("return",P);case 12:case"end":return _context26.stop();}},_callee24,this);}));function draw(_x26){return _draw3.apply(this,arguments);}return draw;}()},{key:"consumeServiceAsync",value:function(){var _consumeServiceAsync2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25(t){var l,g,c,d,e,n,i,a,o,s;return _regeneratorRuntime().wrap(function _callee25$(_context27){while(1)switch(_context27.prev=_context27.next){case 0:e=(l=this.workId)==null?void 0:l.toString();if(e){_context27.next=3;break;}return _context27.abrupt("return");case 3:n=t.isFullWork,i=t.replaceId,a=t.isDrawLabel;this.oldRect=i&&((c=(g=this.vNodes)==null?void 0:g.get(i))==null?void 0:c.rect)||void 0;o=n?this.fullLayer:this.drawLayer||this.fullLayer;_context27.next=8;return this.draw({workId:e,layer:o,isDrawLabel:_typeof(a)>"u"&&this.workOptions.workState===It.Done||a});case 8:s=_context27.sent;return _context27.abrupt("return",((d=this.vNodes)==null||d.setInfo(e,{rect:s,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&vt.getCenterPos(s,o)}),s));case 10:case"end":return _context27.stop();}},_callee25,this);}));function consumeServiceAsync(_x27){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,e){var P,S,n,i,a,o,s,l,g,c,d,y;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,a=t.fontBgColor,o=t.bold,s=t.italic,l=t.lineThrough,g=t.underline,c=t.zIndex,d=(P=this.vNodes)==null?void 0:P.get(n);if(d){_context28.next=5;break;}return _context28.abrupt("return");case 5:i&&(d.opt.fontColor=i),a&&(d.opt.fontBgColor=a),o&&(d.opt.bold=o),s&&(d.opt.italic=s),ye(l)&&(d.opt.lineThrough=l),ye(g)&&(d.opt.underline=g),Vt(c)&&(d.opt.zIndex=c),this.oldRect=d.rect;_context28.next=8;return this.draw({workId:n,layer:this.fullLayer,isDrawLabel:_typeof(e)>"u"&&this.workOptions.workState===It.Done||e});case 8:y=_context28.sent;return _context28.abrupt("return",((S=this.vNodes)==null||S.setInfo(n,{rect:y,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:y&&vt.getCenterPos(y,this.fullLayer)}),y));case 10:case"end":return _context28.stop();}},_callee26,this);}));function updataOptServiceAsync(_x28,_x29){return _updataOptServiceAsync.apply(this,arguments);}return updataOptServiceAsync;}()},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"getSafetySnippetRatio",value:function getSafetySnippetRatio(t){var e=(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*e:n<=2&&n>=1?i=n*e*1.6:n>2&&n<=3?i=n*e*1.4:n>3&&n<=4?i=n*e*0.8:n>4&&(i=n*e*0.6),Math.floor(i*1e3)/1e3;}},{key:"getSafetySnippetFontLength",value:function getSafetySnippetFontLength(t){return Math.floor(oe.textImageSnippetSize*3/4/t)||1;}},{key:"createLabels",value:function(){var _createLabels=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27(t,e,n){var L,i,a,o,_ref167,s,l,g,c,d,y,P,S,v,T,f,p,u,m,M,O,A,w,E,b,I,R,W,z,K,J,q,U,G,Z,et,it,X,ct,ut,B,F,Y,k,rt,_X2,_ct,_ut,_X3,_ct2,_et3,_it2;return _regeneratorRuntime().wrap(function _callee27$(_context29){while(1)switch(_context29.prev=_context29.next){case 0:i=[],a=n.x,o=n.y,_ref167=(L=e.parent)==null?void 0:L.parent,s=_ref167.width,l=_ref167.height,g=Pe(t.text),c=g.length,d=t.fontSize,y=t.lineHeight,P=t.bold,S=t.textAlign,v=t.italic,T=t.fontFamily,f=t.verticalAlign,p=t.fontColor,u=t.fontBgColor,m=t.underline,M=t.lineThrough,O=oe.getSafetySnippetRatio(e)||1,A=Math.floor(d*O),w=oe.getSafetySnippetFontLength(A);E=0;b=0;case 3:if(!(b<c)){_context29.next=33;break;}I=g[b],R=y||A*1.5;if(!I){_context29.next=30;break;}W=Qp(I),z=[0,0],K=[0,d*1.2];f==="middle"&&(z[1]=b*d*1.2+5);J=[0,-d*0.15];z[0]=5;q=Math.sin(Math.PI/180*20);U=0;G=[];Z=0;case 14:if(!(Z<W)){_context29.next=27;break;}S==="left"&&(J[0]=U),Z===0&&v==="italic"&&(J[0]=J[0]-q/2*d);et=I.slice(Z,Z+w);it={anchor:[0,0],pos:J,text:et,fontFamily:T,fontSize:A,lineHeight:R,strokeColor:p,fontWeight:P,fillColor:p,textAlign:S,fontStyle:v,scale:[1/O,1/O]};X=new qi(it);_context29.next=21;return X.textImageReady;case 21:ct=_context29.sent;ut=!0;if(ct){B=ct.rect&&ct.rect[2],F=ct.rect&&ct.rect[3];if(B&&F){Y=B/O,k=F/O;U=Y+U,v==="italic"&&(P==="bold"?U=U-q*d*1.2:U=U-q*d),((J[0]+z[0]+Y)*e.worldScaling[0]+a<=0||(J[0]+z[0])*e.worldScaling[0]+a>=s||(J[1]+z[1]+k)*e.worldScaling[1]+o<=0||(J[1]+z[1])*e.worldScaling[1]+o>=l)&&(X.disconnect(),ut=!1),ut&&G.push(X);}}Z+=w;case 25:_context29.next=14;break;case 27:K[0]=U,v==="italic"&&(K[0]=K[0]+q*d),E=Math.max(E,K[0]);rt=!0;if(((z[0]+K[0])*e.worldScaling[0]+a<=0||z[0]*e.worldScaling[0]+a>=s||(z[1]+K[1])*e.worldScaling[0]+o<=0||z[1]*e.worldScaling[1]+o>=l)&&(rt=!1),rt){if(m){_X2=Math.floor(d/10),_ct={normalize:!1,pos:[0,d*1.1+_X2/2],lineWidth:_X2,points:[0,0,Math.ceil(K[0]),0],strokeColor:p,className:"underline"},_ut=new ce(_ct);G.push(_ut);}if(M){_X3={normalize:!1,pos:[0,d*1.2/2],lineWidth:Math.floor(d/10),points:[0,0,Math.ceil(K[0]),0],strokeColor:p,className:"lineThrough"},_ct2=new ce(_X3);G.push(_ct2);}_et3={pos:z,anchor:[0,0],size:K,bgcolor:u},_it2=new Zt(_et3);_it2.append.apply(_it2,G),i.push(_it2);}case 30:b++;_context29.next=3;break;case 33:return _context29.abrupt("return",{labels:i,maxWidth:E});case 34:case"end":return _context29.stop();}},_callee27);}));function createLabels(_x30,_x31,_x32){return _createLabels.apply(this,arguments);}return createLabels;}()},{key:"updateNodeOpt",value:function updateNodeOpt(t){var e=t.node,n=t.opt,i=t.vNodes,a=t.targetNode,o=n.fontBgColor,s=n.fontColor,l=n.translate,g=n.originPoint,c=n.scenePoint,d=n.scale,y=n.bold,P=n.italic,S=n.lineThrough,v=n.underline,T=n.fontSize,f=n.textInfos,p=n.zIndex,u=a&&Jt(a);if(!u||!e.parent)return;var M=u.opt;if(Vt(p)&&(e.setAttribute("zIndex",p),u.opt.zIndex=p),s&&M.fontColor&&(M.fontColor=s,e.children.forEach(function(O){O.tagName==="GROUP"&&O.children.forEach(function(A){A.tagName==="LABEL"?(A.setAttribute("fillColor",s),A.setAttribute("strokeColor",s)):A.tagName==="POLYLINE"&&A.setAttribute("strokeColor",s);});})),o&&M.fontBgColor&&(M.fontBgColor=o,e.children.forEach(function(O){O.tagName==="GROUP"&&O.setAttribute("bgcolor",o);})),y&&(M.bold=y),P&&(M.italic=P),ye(S)&&(M.lineThrough=S),ye(v)&&(M.underline=v),T&&(M.fontSize=T),g&&c&&d&&a&&M.boxPoint){var O=f==null?void 0:f.get(e.name);if(O){var L=O.fontSize,b=O.boxSize;M.boxSize=b||M.boxSize,M.fontSize=L||M.fontSize;}var A=[M.boxPoint[0],M.boxPoint[1]];Ur(M.boxPoint,c,d,l);var w=[u.op[0],u.op[1]],E=[w[0]-A[0],w[1]-A[1]];if(u.centerPos=[u.centerPos[0]+E[0],u.centerPos[1]+E[1]],u.opt.eraserlines)for(var _i8=0,_Object$values6=Object.values(u.opt.eraserlines);_i8<_Object$values6.length;_i8++){var _L19=_Object$values6[_i8];var _b9=_L19.op,I=_L19.thickness;_L19.thickness=I*Math.max(d[0],d[1]);for(var R=0;R<_b9.length;R++)jr(_b9[R],c,d,l);}}else if(l&&M.boxPoint&&(M.boxPoint=[M.boxPoint[0]+l[0],M.boxPoint[1]+l[1]],u.centerPos=[u.centerPos[0]+l[0],u.centerPos[1]+l[1]],u.opt.eraserlines))for(var _i9=0,_Object$values7=Object.values(u.opt.eraserlines);_i9<_Object$values7.length;_i9++){var _O6=_Object$values7[_i9];var _A6=_O6.op;for(var _w22=0;_w22<_A6.length;_w22++){var _E22=_A6[_w22].map(function(L,b){return b%2?L+l[1]:L+l[0];});_O6.op[_w22]=_E22;}}return u&&i.setInfo(e.name,u),u==null?void 0:u.rect;}},{key:"getRectFromLayer",value:function getRectFromLayer(t,e){var n=t.getElementsByName(e)[0];if(n){var i=n.getBoundingClientRect();var a={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 s=n.getBoundingClientRect();a=Pt(a,{x:Math.floor(s.x),y:Math.floor(s.y),w:Math.floor(s.width+2),h:Math.floor(s.height+2)});}}),a;}}}]);}(vt);// 4k
|
|
442
|
+
*/},{key:"threeBezier",value:function threeBezier(r,t,e,n,i){var a=t.x*(1-r)*(1-r)*(1-r)+3*e.x*r*(1-r)*(1-r)+3*n.x*r*r*(1-r)+i.x*r*r*r,o=t.y*(1-r)*(1-r)*(1-r)+3*e.y*r*(1-r)*(1-r)+3*n.y*r*r*(1-r)+i.y*r*r*r;return new _(a,o);}}]);}();var Ti=/*#__PURE__*/function(_vt10){function Ti(t){var _this80;_classCallCheck(this,Ti);_this80=_callSuper(this,Ti,[t]);tt(_this80,"canRotate",!1);tt(_this80,"scaleType",Nt.all);tt(_this80,"toolsType",dt.SpeechBalloon);tt(_this80,"ratio",0.8);tt(_this80,"tmpPoints",[]);tt(_this80,"workOptions");tt(_this80,"oldRect");tt(_this80,"syncTimestamp");_this80.workOptions=t.toolsOpt,_this80.syncTimestamp=0,_this80.syncUnitTime=50;return _this80;}_inherits(Ti,_vt10);return _createClass(Ti,[{key:"consume",value:function consume(t){var y;var e=t.data,n=t.isFullWork,i=t.isSubWorker,a=t.isMainThread,o=(y=e==null?void 0:e.workId)==null?void 0:y.toString();if(!o)return{type:ot.None};var s=e.op,l=s==null?void 0:s.length;if(!l||l<2)return{type:ot.None};var g;if(this.tmpPoints.length===0?(this.tmpPoints=[new xt(s[0],s[1])],g=!1):g=this.updateTempPoints(s),!g)return{type:ot.None};var c;if(i||a){var P=n?this.fullLayer:this.drawLayer||this.fullLayer;c=this.draw({workId:o,layer:P,isDrawing:!0});}if(!i){var _P3=Date.now();return _P3-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_P3,_objectSpread({type:ot.DrawWork,dataType:Tt.Local,op:this.tmpPoints.map(function(S){return[].concat(_toConsumableArray(S.XY),[0]);}).flat(1),isSync:!0,index:0},this.baseConsumeResult)):{type:ot.None};}var d=Pt(c,this.oldRect);return this.oldRect=c,_objectSpread({rect:d,type:ot.DrawWork,dataType:Tt.Local},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var o;var t=this.workId;if(this.tmpPoints.length<2)return{type:ot.RemoveNode,removeIds:[t]};var e=this.fullLayer,n=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=n;var i=this.tmpPoints.map(function(s){return[].concat(_toConsumableArray(s.XY),[0]);}).flat(1),a=Qt(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&&vt.getCenterPos(n,e)}),_objectSpread({rect:n,type:ot.FullWork,dataType:Tt.Local,ops:a,isSync:!0},this.baseConsumeResult);}},{key:"draw",value:function draw(t){var e=t.workId,n=t.layer,_this$workOptions11=this.workOptions,i=_this$workOptions11.strokeColor,a=_this$workOptions11.fillColor,o=_this$workOptions11.thickness,s=_this$workOptions11.zIndex,l=_this$workOptions11.placement,g=_this$workOptions11.scale,c=_this$workOptions11.rotate,d=_this$workOptions11.translate,y=_this$workOptions11.strokeType,P=_this$workOptions11.eraserlines,_this$computDrawPoint7=this.computDrawPoints(o,l),S=_this$computDrawPoint7.rect,v=_this$computDrawPoint7.pos,T=_this$computDrawPoint7.points,f={points:T.map(function(O){return O.XY;}),lineWidth:o,fillColor:a!=="transparent"&&a||void 0,strokeColor:i,normalize:!0,className:"".concat(v[0],",").concat(v[1]),close:!0,lineJoin:"round",lineCap:"round",lineDash:y===Lt.Dotted?[1,o*2]:y===Lt.LongDotted?[o,o*2]:void 0},p={name:e,id:e,zIndex:s,pos:v,anchor:[0.5,0.5],size:[S.w,S.h]};g&&(p.scale=g),c&&(p.rotate=c),d&&(p.translate=d);var u=new Zt(p),m=new ce(_objectSpread(_objectSpread({},f),{},{pos:[0,0]}));u.append(m),P&&(this.scaleType=Nt.proportional,this.drawEraserlines({group:u,eraserlines:P,pos:v,layer:n})),this.replace(n,e,u);var M=u.getBoundingClientRect();return{x:Math.floor(M.x-vt.SafeBorderPadding),y:Math.floor(M.y-vt.SafeBorderPadding),w:Math.floor(M.width+vt.SafeBorderPadding*2),h:Math.floor(M.height+vt.SafeBorderPadding*2)};}},{key:"transformControlPoints",value:function transformControlPoints(t){var e=Ft(this.tmpPoints);switch(t){case"bottom":case"bottomLeft":case"bottomRight":{var n=e.y+e.h*this.ratio;return[new _(e.x,e.y,0),new _(e.x+e.w,e.y,0),new _(e.x+e.w,n,0),new _(e.x,n,0)];}case"top":case"topLeft":case"topRight":{var _n4=e.y+e.h*(1-this.ratio);return[new _(e.x,_n4,0),new _(e.x+e.w,_n4,0),new _(e.x+e.w,e.y+e.h,0),new _(e.x,e.y+e.h,0)];}case"left":case"leftBottom":case"leftTop":{var _n5=e.x+e.w*(1-this.ratio);return[new _(_n5,e.y,0),new _(e.x+e.w,e.y,0),new _(e.x+e.w,e.y+e.h,0),new _(_n5,e.y+e.h,0)];}case"right":case"rightBottom":case"rightTop":{var _n6=e.x+e.w*this.ratio;return[new _(e.x,e.y,0),new _(_n6,e.y,0),new _(_n6,e.y+e.h,0),new _(e.x,e.y+e.h,0)];}}}},{key:"computDrawPoints",value:function computDrawPoints(t,e){var n=Ft(this.tmpPoints),i=this.transformControlPoints(e),a=Math.floor(n.w*0.1),o=Math.floor(n.h*0.1),s=[],l=_.Add(i[0],new _(0,o,0)),g=_.Add(i[0],new _(a,0,0)),c=_t.getBezierPoints(10,l,i[0],g),d=_.Sub(i[1],new _(a,0,0)),y=_.Add(i[1],new _(0,o,0)),P=_t.getBezierPoints(10,d,i[1],y),S=_.Sub(i[2],new _(0,o,0)),v=_.Sub(i[2],new _(a,0,0)),T=_t.getBezierPoints(10,S,i[2],v),f=_.Add(i[3],new _(a,0,0)),p=_.Sub(i[3],new _(0,o,0)),u=_t.getBezierPoints(10,f,i[3],p),m=a*(1-this.ratio)*10,M=o*(1-this.ratio)*10;switch(e){case"bottom":{var w=_.Sub(i[2],new _(a*5-m/2,0,0)),E=_.Sub(i[2],new _(a*5,-M,0)),L=_.Sub(i[2],new _(a*5+m/2,0,0));s.push.apply(s,[E,L].concat(_toConsumableArray(u),_toConsumableArray(c),_toConsumableArray(P),_toConsumableArray(T),[w]));break;}case"bottomRight":{var _w11=_.Sub(i[2],new _(a*1.1,0,0)),_E11=_.Sub(i[2],new _(a*1.1+m/2,-M,0)),_L8=_.Sub(i[2],new _(a*1.1+m,0,0));s.push.apply(s,[_E11,_L8].concat(_toConsumableArray(u),_toConsumableArray(c),_toConsumableArray(P),_toConsumableArray(T),[_w11]));break;}case"bottomLeft":{var _w12=_.Add(i[3],new _(a*1.1+m,0,0)),_E12=_.Add(i[3],new _(a*1.1+m/2,M,0)),_L9=_.Add(i[3],new _(a*1.1,0,0));s.push.apply(s,[_E12,_L9].concat(_toConsumableArray(u),_toConsumableArray(c),_toConsumableArray(P),_toConsumableArray(T),[_w12]));break;}case"top":{var _w13=_.Sub(i[1],new _(a*5-m/2,0,0)),_E13=_.Sub(i[1],new _(a*5,M,0)),_L10=_.Sub(i[1],new _(a*5+m/2,0,0));s.push.apply(s,[_E13,_w13].concat(_toConsumableArray(P),_toConsumableArray(T),_toConsumableArray(u),_toConsumableArray(c),[_L10]));break;}case"topRight":{var _w14=_.Sub(i[1],new _(a*1.1,0,0)),_E14=_.Sub(i[1],new _(a*1.1+m/2,M,0)),_L11=_.Sub(i[1],new _(a*1.1+m,0,0));s.push.apply(s,[_E14,_w14].concat(_toConsumableArray(P),_toConsumableArray(T),_toConsumableArray(u),_toConsumableArray(c),[_L11]));break;}case"topLeft":{var _w15=_.Add(i[0],new _(a*1.1+m,0,0)),_E15=_.Add(i[0],new _(a*1.1+m/2,-M,0)),_L12=_.Add(i[0],new _(a*1.1,0,0));s.push.apply(s,[_E15,_w15].concat(_toConsumableArray(P),_toConsumableArray(T),_toConsumableArray(u),_toConsumableArray(c),[_L12]));break;}case"left":{var _w16=_.Add(i[0],new _(0,o*5-M/2,0)),_E16=_.Add(i[0],new _(-m,o*5,0)),_L13=_.Add(i[0],new _(0,o*5+M/2,0));s.push.apply(s,[_E16,_w16].concat(_toConsumableArray(c),_toConsumableArray(P),_toConsumableArray(T),_toConsumableArray(u),[_L13]));break;}case"leftTop":{var _w17=_.Add(i[0],new _(0,o*1.1,0)),_E17=_.Add(i[0],new _(-m,o*1.1+M/2,0)),_L14=_.Add(i[0],new _(0,o*1.1+M,0));s.push.apply(s,[_E17,_w17].concat(_toConsumableArray(c),_toConsumableArray(P),_toConsumableArray(T),_toConsumableArray(u),[_L14]));break;}case"leftBottom":{var _w18=_.Sub(i[3],new _(0,o*1.1+M,0)),_E18=_.Sub(i[3],new _(m,o*1.1+M/2,0)),_L15=_.Sub(i[3],new _(0,o*1.1,0));s.push.apply(s,[_E18,_w18].concat(_toConsumableArray(c),_toConsumableArray(P),_toConsumableArray(T),_toConsumableArray(u),[_L15]));break;}case"right":{var _w19=_.Add(i[1],new _(0,o*5-M/2,0)),_E19=_.Add(i[1],new _(m,o*5,0)),_L16=_.Add(i[1],new _(0,o*5+M/2,0));s.push.apply(s,[_E19,_L16].concat(_toConsumableArray(T),_toConsumableArray(u),_toConsumableArray(c),_toConsumableArray(P),[_w19]));break;}case"rightTop":{var _w20=_.Add(i[1],new _(0,o*1.1,0)),_E20=_.Add(i[1],new _(m,o*1.1+M/2,0)),_L17=_.Add(i[1],new _(0,o*1.1+M,0));s.push.apply(s,[_E20,_L17].concat(_toConsumableArray(T),_toConsumableArray(u),_toConsumableArray(c),_toConsumableArray(P),[_w20]));break;}case"rightBottom":{var _w21=_.Sub(i[2],new _(0,o*1.1+M,0)),_E21=_.Sub(i[2],new _(-m,o*1.1+M/2,0)),_L18=_.Sub(i[2],new _(0,o*1.1,0));s.push.apply(s,[_E21,_L18].concat(_toConsumableArray(T),_toConsumableArray(u),_toConsumableArray(c),_toConsumableArray(P),[_w21]));break;}}var O=Ft(this.tmpPoints,t),A=[Math.floor(O.x+O.w/2),Math.floor(O.y+O.h/2)];return{rect:O,pos:A,points:s};}},{key:"updateTempPoints",value:function updateTempPoints(t){var e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],a=this.workOptions.thickness;if(i.isNear(n,a)||xt.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 s,l;var e=t.op,n=t.isFullWork,i=(s=this.workId)==null?void 0:s.toString();if(!i)return;this.tmpPoints.length=0;for(var g=0;g<e.length;g+=3)this.tmpPoints.push(new xt(e[g],e[g+1],e[g+2]));var a=n?this.fullLayer:this.drawLayer||this.fullLayer,o=this.draw({workId:i,layer:a,isDrawing:!1});return this.oldRect=o,(l=this.vNodes)==null||l.setInfo(i,{rect:o,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&vt.getCenterPos(o,a)}),o;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var P;var e=t.node,n=t.opt,i=t.vNodes,a=n.strokeColor,o=n.fillColor,s=n.toolsType,l=n.placement,g=n.strokeType,c=i.get(e.name),d=c==null?void 0:c.opt;var y=e;return e.tagName==="GROUP"&&(y=e.children[0]),a&&(y.setAttribute("strokeColor",a),d!=null&&d.strokeColor&&(d.strokeColor=a)),o&&(o==="transparent"?y.setAttribute("fillColor","rgba(0,0,0,0)"):y.setAttribute("fillColor",o),d!=null&&d.fillColor&&(d.fillColor=o)),s===dt.SpeechBalloon&&l&&(d.placement=l),g&&c!=null&&c.opt&&(P=c.opt)!=null&&P.strokeType&&(c.opt.strokeType=g),c&&i.setInfo(e.name,_objectSpread(_objectSpread({},c),{},{opt:d})),vt.updateNodeOpt(t);}}]);}(vt);var Bp=de,Fp=ne,Up="[object Boolean]";function jp(h){return h===!0||h===!1||Fp(h)&&Bp(h)==Up;}var $p=jp,ye=/* @__PURE__ */fe($p);var Ne=/*#__PURE__*/function(_vt11){function Ne(t){var _this81;_classCallCheck(this,Ne);_this81=_callSuper(this,Ne,[t]);tt(_this81,"canRotate",!0);tt(_this81,"scaleType",Nt.all);tt(_this81,"toolsType",dt.Image);tt(_this81,"tmpPoints",[]);tt(_this81,"workOptions");tt(_this81,"oldRect");_this81.workOptions=t.toolsOpt,_this81.scaleType=Ne.getScaleType(_this81.workOptions);return _this81;}_inherits(Ne,_vt11);return _createClass(Ne,[{key:"consume",value:function consume(){return{type:ot.None};}},{key:"consumeAll",value:function consumeAll(){return{type:ot.None};}},{key:"draw",value:function draw(t){var e=t.layer,n=t.workId,i=t.replaceId,a=t.imageBitmap,_this$workOptions12=this.workOptions,o=_this$workOptions12.centerX,s=_this$workOptions12.centerY,l=_this$workOptions12.width,g=_this$workOptions12.height,c=_this$workOptions12.rotate,d=_this$workOptions12.zIndex,y=_this$workOptions12.eraserlines,P=new Zt({anchor:[0.5,0.5],pos:[o,s],name:n,size:[l,g],zIndex:d,rotate:c}),S={anchor:[0.5,0.5],pos:[0,0],size:[l,g],texture:a};a||(S.bgcolor="rgba(0,0,0,0.3)");var v=new es(S);P.append(v),y&&this.drawEraserlines({group:P,eraserlines:y,pos:[o,s],layer:e}),this.replace(e,i||n,P);var T=P.getBoundingClientRect();if(T)return{x:Math.floor(T.x-vt.SafeBorderPadding),y:Math.floor(T.y-vt.SafeBorderPadding),w:Math.floor(T.width+vt.SafeBorderPadding*2),h:Math.floor(T.height+vt.SafeBorderPadding*2)};}},{key:"consumeService",value:function consumeService(){}},{key:"consumeServiceAsync",value:function(){var _consumeServiceAsync=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23(t){var g,c,d,y,e,n,i,_this$workOptions13,a,o,s,l,P,S;return _regeneratorRuntime().wrap(function _callee23$(_context25){while(1)switch(_context25.prev=_context25.next){case 0:e=t.isFullWork,n=t.replaceId,i=t.worker,_this$workOptions13=this.workOptions,a=_this$workOptions13.src,o=_this$workOptions13.uuid,s=((g=this.workId)==null?void 0:g.toString())||o,l=e?this.fullLayer:this.drawLayer||this.fullLayer;if(!a){_context25.next=8;break;}_context25.next=4;return i.loadImageBitMap({toolsType:this.toolsType,opt:this.workOptions,workId:s,isSubWorker:i instanceof Di});case 4:P=_context25.sent;if(!P){_context25.next=8;break;}S=this.draw({workId:s,layer:l,replaceId:n,imageBitmap:P});return _context25.abrupt("return",(this.oldRect=s&&((d=(c=this.vNodes)==null?void 0:c.get(s))==null?void 0:d.rect)||void 0,(y=this.vNodes)==null||y.setInfo(s,{rect:S,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:S&&vt.getCenterPos(S,l)}),S));case 8:case"end":return _context25.stop();}},_callee23,this);}));function consumeServiceAsync(_x25){return _consumeServiceAsync.apply(this,arguments);}return consumeServiceAsync;}()},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"getScaleType",value:function getScaleType(t){var e=t.uniformScale,n=t.rotate;return e!==!1||n&&Math.abs(n)%90>0?Nt.proportional:Nt.all;}},{key:"updateNodeOpt",value:function updateNodeOpt(t){var e=t.node,n=t.opt,i=t.vNodes,a=t.targetNode,o=n.translate,s=n.originPoint,l=n.scenePoint,g=n.scale,c=n.angle,d=n.isLocked,y=n.zIndex,P=n.strokeColor,S=a&&Jt(a)||i.get(e.name);if(!S)return;var v=e.parent;if(v){if(P&&(S.opt.strokeColor=P),Vt(y)&&(e.setAttribute("zIndex",y),S.opt.zIndex=y),ye(d)&&(S.opt.locked=d),s&&l&&g&&o){var _S$opt=S.opt,_T33=_S$opt.centerX,_f29=_S$opt.centerY,p=_S$opt.width,u=_S$opt.height,m=_S$opt.uniformScale,M=m!==!1?[g[0],g[0]]:g,O=[_T33,_f29],A=[_T33,_f29];Ur(A,l,M,o);var w=[A[0]-O[0],A[1]-O[1]];if(S.centerPos=[S.centerPos[0]+w[0],S.centerPos[1]+w[1]],S.opt.width=Math.round(p*M[0]),S.opt.height=Math.round(u*M[1]),S.opt.centerX=A[0],S.opt.centerY=A[1],S.opt.eraserlines)for(var _i6=0,_Object$values4=Object.values(S.opt.eraserlines);_i6<_Object$values4.length;_i6++){var E=_Object$values4[_i6];var L=E.op,b=E.thickness;E.thickness=b*Math.max(g[0],g[1]);for(var I=0;I<L.length;I++)jr(L[I],l,g,o);}}else if(o){if(S.opt.centerX=S.opt.centerX+o[0],S.opt.centerY=S.opt.centerY+o[1],S.centerPos=[S.centerPos[0]+o[0],S.centerPos[1]+o[1]],S.opt.eraserlines)for(var _i7=0,_Object$values5=Object.values(S.opt.eraserlines);_i7<_Object$values5.length;_i7++){var _T34=_Object$values5[_i7];var _f30=_T34.op;for(var _p12=0;_p12<_f30.length;_p12++){var _u13=_f30[_p12].map(function(m,M){return M%2?m+o[1]:m+o[0];});_T34.op[_p12]=_u13;}}}else if(Vt(c))if(S.opt.rotate=c,S.scaleType=Ne.getScaleType(S.opt),a){var _T35=Ei(S.rect,c);S.rect=_T35;}else{var _T36=vt.getRectFromLayer(v,e.name);S.rect=_T36||S.rect;}return S&&i.setInfo(e.name,S),S==null?void 0:S.rect;}}}]);}(vt);var Mi=/*#__PURE__*/function(_vt12){function Mi(t){var _this82;_classCallCheck(this,Mi);_this82=_callSuper(this,Mi,[t]);tt(_this82,"canRotate",!1);tt(_this82,"scaleType",Nt.both);tt(_this82,"toolsType",dt.Straight);tt(_this82,"tmpPoints",[]);tt(_this82,"workOptions");tt(_this82,"oldRect");tt(_this82,"straightTipWidth");tt(_this82,"syncTimestamp");_this82.workOptions=t.toolsOpt,_this82.straightTipWidth=_this82.workOptions.thickness/2,_this82.syncTimestamp=0,_this82.syncUnitTime=50;return _this82;}_inherits(Mi,_vt12);return _createClass(Mi,[{key:"consume",value:function consume(t){var e=t.data,n=t.isFullWork,i=t.isSubWorker,a=t.isMainThread,o=this.workId,s=e.op,l=s==null?void 0:s.length;if(!l||l<2)return{type:ot.None};var g;if(this.tmpPoints.length===0?(this.tmpPoints=[new xt(s[0],s[1])],g=!1):g=this.updateTempPoints(s),!g)return{type:ot.None};var c;if(i||a){var y=n?this.fullLayer:this.drawLayer||this.fullLayer;c=this.draw({workId:o,layer:y});}if(!i){var _y12=Date.now();return _y12-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=_y12,_objectSpread({type:ot.DrawWork,dataType:Tt.Local,op:this.tmpPoints.map(function(P){return[].concat(_toConsumableArray(P.XY),[0]);}).flat(1),isSync:!0,index:0},this.baseConsumeResult)):{type:ot.None};}var d=Pt(c,this.oldRect);return this.oldRect=c,_objectSpread({rect:d,type:ot.DrawWork,dataType:Tt.Local},this.baseConsumeResult);}},{key:"consumeAll",value:function consumeAll(){var o;var t=this.workId;if(this.tmpPoints.length<2)return{type:ot.RemoveNode,removeIds:[t]};var e=this.fullLayer,n=this.draw({workId:t,layer:e});this.oldRect=n;var i=this.tmpPoints.map(function(s){return[].concat(_toConsumableArray(s.XY),[0]);}).flat(1),a=Qt(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&&vt.getCenterPos(n,e)}),_objectSpread({rect:n,type:ot.FullWork,dataType:Tt.Local,ops:a,isSync:!0},this.baseConsumeResult);}},{key:"draw",value:function draw(t){var e=t.workId,n=t.layer,_this$workOptions14=this.workOptions,i=_this$workOptions14.strokeColor,a=_this$workOptions14.thickness,o=_this$workOptions14.zIndex,s=_this$workOptions14.scale,l=_this$workOptions14.rotate,g=_this$workOptions14.translate,c=_this$workOptions14.strokeType,d=_this$workOptions14.eraserlines,y=n.worldPosition,P=n.worldScaling,_this$computDrawPoint8=this.computDrawPoints(a,c),S=_this$computDrawPoint8.d,v=_this$computDrawPoint8.rect,T=_this$computDrawPoint8.isDot,f=[v.x+v.w/2,v.y+v.h/2],p=new Zt({pos:f,anchor:[0.5,0.5],size:[v.w,v.h],name:e,id:e,normalize:!0,zIndex:o}),u={pos:[0,0],normalize:!0,d:S,fillColor:i,strokeColor:i,lineDash:c===Lt.Dotted&&!T?[1,a*2]:c===Lt.LongDotted&&!T?[a,a*2]:void 0,lineCap:c===Lt.Normal||T?void 0:"round",lineWidth:c===Lt.Normal||T?0:a};s&&(u.scale=s),l&&(u.rotate=l),g&&(u.translate=g);var m=new se(u);if(p.append(m),d&&(this.scaleType=Nt.proportional,this.drawEraserlines({group:p,eraserlines:d,pos:f,layer:n})),this.replace(n,e,p),l||s||g){var O=m.getBoundingClientRect();return{x:Math.floor(O.x-vt.SafeBorderPadding),y:Math.floor(O.y-vt.SafeBorderPadding),w:Math.floor(O.width+vt.SafeBorderPadding*2),h:Math.floor(O.height+vt.SafeBorderPadding*2)};}return{x:Math.floor(v.x*P[0]+y[0]-vt.SafeBorderPadding),y:Math.floor(v.y*P[1]+y[1]-vt.SafeBorderPadding),w:Math.floor(v.w*P[0]+2*vt.SafeBorderPadding),h:Math.floor(v.h*P[1]+2*vt.SafeBorderPadding)};}},{key:"computDrawPoints",value:function computDrawPoints(t,e){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.straightTipWidth?this.computFullPoints(t,e):this.computDotPoints(t);}},{key:"computFullPoints",value:function computFullPoints(t,e){var n=_.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),i=_.Per(n).mul(t/2),a=xt.Sub(this.tmpPoints[0],i),o=xt.Add(this.tmpPoints[0],i),s=xt.Sub(this.tmpPoints[1],i),l=xt.Add(this.tmpPoints[1],i),g=xt.GetSemicircleStroke(this.tmpPoints[1],s,-1,8),c=xt.GetSemicircleStroke(this.tmpPoints[0],o,-1,8),d=[a,s].concat(_toConsumableArray(g),[l,o],_toConsumableArray(c));var y;return e!==Lt.Normal?y=ie(this.tmpPoints,!1):y=ie(d,!0),{d:y,rect:Ft(d),isDot:!1,pos:this.tmpPoints[0].XY};}},{key:"computDotPoints",value:function computDotPoints(t){var e=xt.GetDotStroke(this.tmpPoints[0],t/2,8);return{d:ie(e,!0),rect:Ft(e),isDot:!0,pos:this.tmpPoints[0].XY};}},{key:"updateTempPoints",value:function updateTempPoints(t){var e=t.slice(-2),n=new xt(e[0],e[1]),i=this.tmpPoints[0],a=this.workOptions.thickness;if(i.isNear(n,a))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 s,l;var e=t.op,n=t.isFullWork,i=(s=this.workId)==null?void 0:s.toString();if(!i)return;this.tmpPoints.length=0;for(var g=0;g<e.length;g+=3)this.tmpPoints.push(new xt(e[g],e[g+1],e[g+2]));var a=n?this.fullLayer:this.drawLayer||this.fullLayer,o=this.draw({workId:i,layer:a});return this.oldRect=o,(l=this.vNodes)==null||l.setInfo(i,{rect:o,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&vt.getCenterPos(o,a)}),o;}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"updateNodeOpt",value:function updateNodeOpt(t){var l,g;var e=t.node,n=t.opt,i=t.vNodes,a=n.strokeColor,o=n.strokeType,s=i.get(e.name);return a&&(e.tagName==="GROUP"?e.children.forEach(function(c){c.setAttribute("strokeColor",a),c.getAttribute("fillColor")&&c.setAttribute("fillColor",a);}):(e.setAttribute("strokeColor",a),e.setAttribute("fillColor",a)),(l=s==null?void 0:s.opt)!=null&&l.strokeColor&&(s.opt.strokeColor=a)),o&&s!=null&&s.opt&&(g=s.opt)!=null&&g.strokeType&&(s.opt.strokeType=o),s&&i.setInfo(e.name,s),vt.updateNodeOpt(t);}}]);}(vt);var oe=/*#__PURE__*/function(_vt13){function oe(t){var _this83;_classCallCheck(this,oe);_this83=_callSuper(this,oe,[t]);tt(_this83,"canRotate",!1);tt(_this83,"scaleType",Nt.proportional);tt(_this83,"toolsType",dt.Text);tt(_this83,"tmpPoints",[]);tt(_this83,"workOptions");tt(_this83,"oldRect");_this83.workOptions=t.toolsOpt;return _this83;}_inherits(oe,_vt13);return _createClass(oe,[{key:"consume",value:function consume(){return{type:ot.None};}},{key:"consumeAll",value:function consumeAll(){return{type:ot.None};}},{key:"consumeService",value:function consumeService(){}},{key:"draw",value:function(){var _draw3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24(t){var e,n,i,_this$workOptions15,a,o,s,l,g,c,d,y,P,S,v,_T37;return _regeneratorRuntime().wrap(function _callee24$(_context26){while(1)switch(_context26.prev=_context26.next){case 0:e=t.workId,n=t.layer,i=t.isDrawLabel,_this$workOptions15=this.workOptions,a=_this$workOptions15.boxSize,o=_this$workOptions15.boxPoint,s=_this$workOptions15.zIndex,l=n.worldPosition,g=n.worldScaling;if(!(!o||!a)){_context26.next=3;break;}return _context26.abrupt("return");case 3:c={name:e,id:e,pos:[o[0],o[1]],anchor:[0,0],size:a,zIndex:s},d=new Zt(c),y={x:o[0],y:o[1],w:a[0],h:a[1]},P={x:Math.floor(y.x*g[0]+l[0]),y:Math.floor(y.y*g[1]+l[1]),w:Math.floor(y.w*g[0])+2,h:Math.floor(y.h*g[1])+2};if(!(this.replace(n,e,d),i&&n&&this.workOptions.text)){_context26.next=11;break;}_context26.next=7;return oe.createLabels(this.workOptions,n,P);case 7:S=_context26.sent;v=S.labels;_T37=S.maxWidth;d.append.apply(d,_toConsumableArray(v)),P.w=Math.ceil(Math.max(_T37*n.worldScaling[0],P.w));case 11:return _context26.abrupt("return",P);case 12:case"end":return _context26.stop();}},_callee24,this);}));function draw(_x26){return _draw3.apply(this,arguments);}return draw;}()},{key:"consumeServiceAsync",value:function(){var _consumeServiceAsync2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25(t){var l,g,c,d,e,n,i,a,o,s;return _regeneratorRuntime().wrap(function _callee25$(_context27){while(1)switch(_context27.prev=_context27.next){case 0:e=(l=this.workId)==null?void 0:l.toString();if(e){_context27.next=3;break;}return _context27.abrupt("return");case 3:n=t.isFullWork,i=t.replaceId,a=t.isDrawLabel;this.oldRect=i&&((c=(g=this.vNodes)==null?void 0:g.get(i))==null?void 0:c.rect)||void 0;o=n?this.fullLayer:this.drawLayer||this.fullLayer;_context27.next=8;return this.draw({workId:e,layer:o,isDrawLabel:_typeof(a)>"u"&&this.workOptions.workState===It.Done||a});case 8:s=_context27.sent;return _context27.abrupt("return",((d=this.vNodes)==null||d.setInfo(e,{rect:s,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&vt.getCenterPos(s,o)}),s));case 10:case"end":return _context27.stop();}},_callee25,this);}));function consumeServiceAsync(_x27){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,e){var P,S,n,i,a,o,s,l,g,c,d,y;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,a=t.fontBgColor,o=t.bold,s=t.italic,l=t.lineThrough,g=t.underline,c=t.zIndex,d=(P=this.vNodes)==null?void 0:P.get(n);if(d){_context28.next=5;break;}return _context28.abrupt("return");case 5:i&&(d.opt.fontColor=i),a&&(d.opt.fontBgColor=a),o&&(d.opt.bold=o),s&&(d.opt.italic=s),ye(l)&&(d.opt.lineThrough=l),ye(g)&&(d.opt.underline=g),Vt(c)&&(d.opt.zIndex=c),this.oldRect=d.rect;_context28.next=8;return this.draw({workId:n,layer:this.fullLayer,isDrawLabel:_typeof(e)>"u"&&this.workOptions.workState===It.Done||e});case 8:y=_context28.sent;return _context28.abrupt("return",((S=this.vNodes)==null||S.setInfo(n,{rect:y,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:y&&vt.getCenterPos(y,this.fullLayer)}),y));case 10:case"end":return _context28.stop();}},_callee26,this);}));function updataOptServiceAsync(_x28,_x29){return _updataOptServiceAsync.apply(this,arguments);}return updataOptServiceAsync;}()},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}],[{key:"getSafetySnippetRatio",value:function getSafetySnippetRatio(t){var e=(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*e:n<=2&&n>=1?i=n*e*1.6:n>2&&n<=3?i=n*e*1.4:n>3&&n<=4?i=n*e*0.8:n>4&&(i=n*e*0.6),Math.floor(i*1e3)/1e3;}},{key:"getSafetySnippetFontLength",value:function getSafetySnippetFontLength(t){return Math.floor(oe.textImageSnippetSize*3/4/t)||1;}},{key:"createLabels",value:function(){var _createLabels=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27(t,e,n){var L,i,a,o,_ref167,s,l,g,c,d,y,P,S,v,T,f,p,u,m,M,O,A,w,E,b,I,R,W,z,K,J,q,U,G,Z,et,it,X,ct,ut,B,F,Y,k,rt,_X2,_ct,_ut,_X3,_ct2,_et3,_it2;return _regeneratorRuntime().wrap(function _callee27$(_context29){while(1)switch(_context29.prev=_context29.next){case 0:i=[],a=n.x,o=n.y,_ref167=(L=e.parent)==null?void 0:L.parent,s=_ref167.width,l=_ref167.height,g=Pe(t.text),c=g.length,d=t.fontSize,y=t.lineHeight,P=t.bold,S=t.textAlign,v=t.italic,T=t.fontFamily,f=t.verticalAlign,p=t.fontColor,u=t.fontBgColor,m=t.underline,M=t.lineThrough,O=oe.getSafetySnippetRatio(e)||1,A=Math.floor(d*O),w=oe.getSafetySnippetFontLength(A);E=0;b=0;case 3:if(!(b<c)){_context29.next=33;break;}I=g[b],R=y||A*1.5;if(!I){_context29.next=30;break;}W=Qp(I),z=[0,0],K=[0,d*1.2];f==="middle"&&(z[1]=b*d*1.2+5);J=[0,-d*0.15];z[0]=5;q=Math.sin(Math.PI/180*20);U=0;G=[];Z=0;case 14:if(!(Z<W)){_context29.next=27;break;}S==="left"&&(J[0]=U),Z===0&&v==="italic"&&(J[0]=J[0]-q/2*d);et=I.slice(Z,Z+w);it={anchor:[0,0],pos:J,text:et,fontFamily:T,fontSize:A,lineHeight:R,strokeColor:p,fontWeight:P,fillColor:p,textAlign:S,fontStyle:v,scale:[1/O,1/O]};X=new qi(it);_context29.next=21;return X.textImageReady;case 21:ct=_context29.sent;ut=!0;if(ct){B=ct.rect&&ct.rect[2],F=ct.rect&&ct.rect[3];if(B&&F){Y=B/O,k=F/O;U=Y+U,v==="italic"&&(P==="bold"?U=U-q*d*1.2:U=U-q*d),((J[0]+z[0]+Y)*e.worldScaling[0]+a<=0||(J[0]+z[0])*e.worldScaling[0]+a>=s||(J[1]+z[1]+k)*e.worldScaling[1]+o<=0||(J[1]+z[1])*e.worldScaling[1]+o>=l)&&(X.disconnect(),ut=!1),ut&&G.push(X);}}Z+=w;case 25:_context29.next=14;break;case 27:K[0]=U,v==="italic"&&(K[0]=K[0]+q*d),E=Math.max(E,K[0]);rt=!0;if(((z[0]+K[0])*e.worldScaling[0]+a<=0||z[0]*e.worldScaling[0]+a>=s||(z[1]+K[1])*e.worldScaling[0]+o<=0||z[1]*e.worldScaling[1]+o>=l)&&(rt=!1),rt){if(m){_X2=Math.floor(d/10),_ct={normalize:!1,pos:[0,d*1.1+_X2/2],lineWidth:_X2,points:[0,0,Math.ceil(K[0]),0],strokeColor:p,className:"underline"},_ut=new ce(_ct);G.push(_ut);}if(M){_X3={normalize:!1,pos:[0,d*1.2/2],lineWidth:Math.floor(d/10),points:[0,0,Math.ceil(K[0]),0],strokeColor:p,className:"lineThrough"},_ct2=new ce(_X3);G.push(_ct2);}_et3={pos:z,anchor:[0,0],size:K,bgcolor:u},_it2=new Zt(_et3);_it2.append.apply(_it2,G),i.push(_it2);}case 30:b++;_context29.next=3;break;case 33:return _context29.abrupt("return",{labels:i,maxWidth:E});case 34:case"end":return _context29.stop();}},_callee27);}));function createLabels(_x30,_x31,_x32){return _createLabels.apply(this,arguments);}return createLabels;}()},{key:"updateNodeOpt",value:function updateNodeOpt(t){var e=t.node,n=t.opt,i=t.vNodes,a=t.targetNode,o=n.fontBgColor,s=n.fontColor,l=n.translate,g=n.originPoint,c=n.scenePoint,d=n.scale,y=n.bold,P=n.italic,S=n.lineThrough,v=n.underline,T=n.fontSize,f=n.textInfos,p=n.zIndex,u=a&&Jt(a)||i.get(e.name);if(!u||!e.parent)return;var M=u.opt;if(Vt(p)&&(e.setAttribute("zIndex",p),u.opt.zIndex=p),s&&M.fontColor&&(M.fontColor=s,e.children.forEach(function(O){O.tagName==="GROUP"&&O.children.forEach(function(A){A.tagName==="LABEL"?(A.setAttribute("fillColor",s),A.setAttribute("strokeColor",s)):A.tagName==="POLYLINE"&&A.setAttribute("strokeColor",s);});})),o&&M.fontBgColor&&(M.fontBgColor=o,e.children.forEach(function(O){O.tagName==="GROUP"&&O.setAttribute("bgcolor",o);})),y&&(M.bold=y),P&&(M.italic=P),ye(S)&&(M.lineThrough=S),ye(v)&&(M.underline=v),T&&(M.fontSize=T),g&&c&&d&&a&&M.boxPoint){var O=f==null?void 0:f.get(e.name);if(O){var L=O.fontSize,b=O.boxSize;M.boxSize=b||M.boxSize,M.fontSize=L||M.fontSize;}var A=[M.boxPoint[0],M.boxPoint[1]];Ur(M.boxPoint,c,d,l);var w=[u.op[0],u.op[1]],E=[w[0]-A[0],w[1]-A[1]];if(u.centerPos=[u.centerPos[0]+E[0],u.centerPos[1]+E[1]],u.opt.eraserlines)for(var _i8=0,_Object$values6=Object.values(u.opt.eraserlines);_i8<_Object$values6.length;_i8++){var _L19=_Object$values6[_i8];var _b9=_L19.op,I=_L19.thickness;_L19.thickness=I*Math.max(d[0],d[1]);for(var R=0;R<_b9.length;R++)jr(_b9[R],c,d,l);}}else if(l&&M.boxPoint&&(M.boxPoint=[M.boxPoint[0]+l[0],M.boxPoint[1]+l[1]],u.centerPos=[u.centerPos[0]+l[0],u.centerPos[1]+l[1]],u.opt.eraserlines))for(var _i9=0,_Object$values7=Object.values(u.opt.eraserlines);_i9<_Object$values7.length;_i9++){var _O6=_Object$values7[_i9];var _A6=_O6.op;for(var _w22=0;_w22<_A6.length;_w22++){var _E22=_A6[_w22].map(function(L,b){return b%2?L+l[1]:L+l[0];});_O6.op[_w22]=_E22;}}return u&&i.setInfo(e.name,u),u==null?void 0:u.rect;}},{key:"getRectFromLayer",value:function getRectFromLayer(t,e){var n=t.getElementsByName(e)[0];if(n){var i=n.getBoundingClientRect();var a={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 s=n.getBoundingClientRect();a=Pt(a,{x:Math.floor(s.x),y:Math.floor(s.y),w:Math.floor(s.width+2),h:Math.floor(s.height+2)});}}),a;}}}]);}(vt);// 4k
|
|
443
443
|
tt(oe,"textImageSnippetSize",1024*4),tt(oe,"SafeBorderPadding",30);var ke=oe;var xe=/*#__PURE__*/function(_vt14){function xe(t,e){var _this84;_classCallCheck(this,xe);_this84=_callSuper(this,xe,[t]);tt(_this84,"canRotate",!1);tt(_this84,"scaleType",Nt.none);tt(_this84,"toolsType",dt.PencilEraser);tt(_this84,"serviceWork");tt(_this84,"tmpPoints",[]);tt(_this84,"workOptions");tt(_this84,"worldPosition");tt(_this84,"worldScaling");tt(_this84,"eraserRect");tt(_this84,"eraserPolyline");_this84.serviceWork=e,_this84.workOptions=t.toolsOpt,_this84.worldPosition=_this84.fullLayer.worldPosition,_this84.worldScaling=_this84.fullLayer.worldScaling;return _this84;}_inherits(xe,_vt14);return _createClass(xe,[{key:"consumeService",value:function consumeService(){}},{key:"createEraserRect",value:function createEraserRect(t){var e=t[0]*this.worldScaling[0]+this.worldPosition[0],n=t[1]*this.worldScaling[1]+this.worldPosition[1],_xe$eraserSizes$this$=xe.eraserSizes[this.workOptions.thickness],i=_xe$eraserSizes$this$.width,a=_xe$eraserSizes$this$.height;this.eraserRect={x:e-i*0.5,y:n-a*0.5,w:i,h:a},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 _e6=new _(this.tmpPoints[0],this.tmpPoints[1]),n=new _(this.tmpPoints[2],this.tmpPoints[3]),i=_.Sub(n,_e6).uni(),a=_.Dist(_e6,n),_xe$eraserSizes$this$2=xe.eraserSizes[this.workOptions.thickness],o=_xe$eraserSizes$this$2.width,s=_xe$eraserSizes$this$2.height,l=Math.min(o,s),g=Math.round(a/l);if(g>1){var c=[];for(var d=0;d<g;d++){var y=_.Mul(i,d*l);c.push(this.tmpPoints[0]+y.x,this.tmpPoints[1]+y.y);}return c.concat(t);}}return t;}},{key:"isNear",value:function isNear(t,e){var n=new _(t[0],t[1]),i=new _(e[0],e[1]),_xe$eraserSizes$this$3=xe.eraserSizes[this.workOptions.thickness],a=_xe$eraserSizes$this$3.width,o=_xe$eraserSizes$this$3.height;return _.Dist(n,i)<Math.hypot(a,o)*0.5;}},{key:"cutPolyline",value:function cutPolyline(t,e){var n=[e],i=0;for(;i<t.length;){var s=t[i];if(s.length<2)break;n=a(n,s),i++;}return n;function a(s,l){var g=s;var _loop4=function _loop4(){var d=s[c],y=d.findIndex(function(P,S){return S<d.length-1?o([P,d[S+1]],[l[0],l[1]]):!1;});if(y!==-1&&y>-1){var P=[],S=d.slice(0,y+1);if(_.Equals(d[y],l[0])||S.push(l[0].clone().setz(d[y].z)),S.length>1&&P.push(S),y+l.length-1<d.length-1){var v=y+l.length-1,_T38=d.slice(v),_f31=l[l.length-1];_.Equals(d[v],_f31)||_T38.unshift(_f31.clone().setz(d[v].z)),_T38.length>1&&P.push(_T38);}return{v:(g.splice.apply(g,[c,1].concat(P)),g)};}},_ret;for(var c=0;c<s.length;c++){_ret=_loop4();if(_ret)return _ret.v;}return g;}function o(s,l){var g=_.Sub(s[1],s[0]),c=_.Sub(l[1],l[0]),d=_.Sub(l[0],s[0]);return Math.abs(_.Cpr(g,c))<0.1&&Math.abs(_.Cpr(g,d))<0.1;}}},{key:"isSamePoint",value:function isSamePoint(t,e){return t[0]===e[0]&&t[1]===e[1];}},{key:"translateIntersect",value:function translateIntersect(t){var _this85=this;var e=[];for(var n=0;n<t.length;n++){var i=t[n].filter(function(s,l,g){return!(l>0&&_this85.isSamePoint(s,g[l-1]));}),a=[];var o=0;for(;o<i.length;){var s=i[o],l=new _(s[0],s[1]);a.push(l),o++;}e.push(a);}return e;}},{key:"isLineEraser",value:function isLineEraser(t,e){return!(t===dt.Pencil&&!e);}},{key:"remove",value:function remove(t){var _this86=this;var e=t.curNodeMap,n=t.removeIds,i=t.newWorkDatas;var a;var _iterator27=_createForOfIteratorHelper(e.entries()),_step27;try{for(_iterator27.s();!(_step27=_iterator27.n()).done;){var _step27$value=_slicedToArray(_step27.value,2),o=_step27$value[0],s=_step27$value[1];if(s.rect&&this.eraserRect&&this.eraserPolyline&&We(this.eraserRect,s.rect)){var l=s.op,g=s.toolsType,c=this.isLineEraser(g,!1),d=[],y=[];for(var S=0;S<l.length;S+=3){var v=new _(l[S]*this.worldScaling[0]+this.worldPosition[0],l[S+1]*this.worldScaling[1]+this.worldPosition[1],l[S+2]);y.push(v),d.push(new xt(v.x,v.y));}var P=d.length&&Ft(d)||s.rect;if(We(P,this.eraserRect)){if(y.length>1){var _S3=Dr.polyline(y.map(function(v){return v.XY;}),this.eraserPolyline);if(_S3.length&&(n.add(s.name),!c)){var _v8=this.translateIntersect(_S3),_T39=this.cutPolyline(_v8,y);var _loop5=function _loop5(){var p="".concat(o,"_s_").concat(_f32),u=[];_T39[_f32].forEach(function(m){u.push((m.x-_this86.worldPosition[0])/_this86.worldScaling[0],(m.y-_this86.worldPosition[1])/_this86.worldScaling[1],m.z);}),s.opt&&s.toolsType&&_this86.vNodes&&(_this86.vNodes.setInfo(p,{rect:P,op:u,opt:s.opt,canRotate:s.canRotate,scaleType:s.scaleType,toolsType:s.toolsType}),i.set(p,{workId:p,op:u,opt:s.opt,toolsType:s.toolsType}));};for(var _f32=0;_f32<_T39.length;_f32++){_loop5();}}}else n.add(s.name);a=Pt(a,P);}}}}catch(err){_iterator27.e(err);}finally{_iterator27.f();}return n.forEach(function(o){var s;return(s=_this86.vNodes)==null?void 0:s["delete"](o);}),a&&(a.x-=vt.SafeBorderPadding,a.y-=vt.SafeBorderPadding,a.w+=vt.SafeBorderPadding*2,a.h+=vt.SafeBorderPadding*2),a;}},{key:"consume",value:function consume(t){var _t$data4=t.data,e=_t$data4.op,n=_t$data4.disableEraseImage,i=_t$data4.disableEraseText;if(!e||e.length===0)return _objectSpread({type:ot.None},this.baseConsumeResult);var a=this.tmpPoints.length;if(a>1&&this.isNear([e[0],e[1]],[this.tmpPoints[a-2],this.tmpPoints[a-1]]))return _objectSpread({type:ot.None},this.baseConsumeResult);a<3?this.tmpPoints.push(e[0],e[1]):this.tmpPoints.splice(2,2,e[0],e[1]);var o=this.computRectCenterPoints();var s;var l=/* @__PURE__ */new Set(),g=/* @__PURE__ */new Map();if(!this.vNodes)return _objectSpread({type:ot.None},this.baseConsumeResult);this.vNodes.setTarget();var c=this.getCanEraserNodeMap(this.vNodes.getCanEraserNodes(this.vNodes.getLastTarget(),{disableEraseImage:n,disableEraseText:i}));for(var d=0;d<o.length-1;d+=2){this.createEraserRect(o.slice(d,d+2));var y=this.remove({curNodeMap:c,removeIds:l,newWorkDatas:g});s=Pt(s,y);}if(this.vNodes.deleteLastTarget(),s&&l.size){var _iterator28=_createForOfIteratorHelper(g.keys()),_step28;try{for(_iterator28.s();!(_step28=_iterator28.n()).done;){var _d4=_step28.value;l.has(_d4)&&g["delete"](_d4);}}catch(err){_iterator28.e(err);}finally{_iterator28.f();}return{type:ot.RemoveNode,rect:s,removeIds:_toConsumableArray(l),newWorkDatas:g};}return _objectSpread({type:ot.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 e;if(this.serviceWork){var n=Jt(t),i=this.serviceWork.selectorWorkShapes,a=this.serviceWork.workShapes;var _iterator29=_createForOfIteratorHelper(i.values()),_step29;try{for(_iterator29.s();!(_step29=_iterator29.n()).done;){var o=_step29.value;if((e=o.selectIds)!=null&&e.length){var _iterator31=_createForOfIteratorHelper(o.selectIds),_step31;try{for(_iterator31.s();!(_step31=_iterator31.n()).done;){var s=_step31.value;n["delete"](s);}}catch(err){_iterator31.e(err);}finally{_iterator31.f();}}}}catch(err){_iterator29.e(err);}finally{_iterator29.f();}var _iterator30=_createForOfIteratorHelper(a.keys()),_step30;try{for(_iterator30.s();!(_step30=_iterator30.n()).done;){var _o5=_step30.value;n["delete"](_o5);}}catch(err){_iterator30.e(err);}finally{_iterator30.f();}return n;}return t;}}]);}(vt);// 来源于white-sdk
|
|
444
|
-
tt(xe,"eraserSizes",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 Xe=xe;var Te=/*#__PURE__*/function(_vt15){function Te(t){var _this87;_classCallCheck(this,Te);_this87=_callSuper(this,Te,[t]);tt(_this87,"canRotate",!1);tt(_this87,"scaleType",Nt.none);tt(_this87,"toolsType",dt.BitMapEraser);tt(_this87,"tmpPoints",[]);tt(_this87,"workOptions");tt(_this87,"worldPosition");tt(_this87,"worldScaling");tt(_this87,"eraserRect");tt(_this87,"eraserPolyline");tt(_this87,"syncUnitTime",re.syncOpt.interval);tt(_this87,"syncIndex",0);tt(_this87,"syncTimestamp");_this87.workOptions=t.toolsOpt,_this87.worldPosition=_this87.fullLayer.worldPosition,_this87.worldScaling=_this87.fullLayer.worldScaling,_this87.syncTimestamp=0;return _this87;}/** 批量合并消费本地数据,返回绘制结果 */_inherits(Te,_vt15);return _createClass(Te,[{key:"combineConsume",value:function combineConsume(){if(this.tmpPoints.length<2)return{type:ot.None};var t=this.workOptions.thickness,_Te$eraserSizes$t=Te.eraserSizes[t],e=_Te$eraserSizes$t.width,n=_Te$eraserSizes$t.height,i=Math.max(e,n)/this.worldScaling[0],a=this.drawLayer||this.fullLayer,o=this.workId,s={name:o};return{rect:this.draw({attrs:s,consumePoints:this.tmpPoints,replaceId:o,layer:a,thickness:i
|
|
445
|
-
tt(Te,"eraserSizes",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 Je=Te;function Pi(h){switch(h){case dt.Arrow:return mi;case dt.Pencil:return ui;case dt.Straight:return Mi;case dt.Ellipse:return vi;case dt.Polygon:case dt.Triangle:return xi;case dt.Star:case dt.Rhombus:return Si;case dt.Rectangle:return yi;case dt.SpeechBalloon:return Ti;case dt.Text:return ke;case dt.LaserPen:return di;case dt.Eraser:return ae;case dt.PencilEraser:return Xe;case dt.BitMapEraser:return Je;case dt.Selector:return Ve;case dt.Image:return Ne;}}function Fr(h,r){var t=h.toolsType,e=_objectWithoutProperties(h,_excluded);switch(t){case dt.Arrow:return new mi(e);case dt.Pencil:return new ui(e);case dt.Straight:return new Mi(e);case dt.Ellipse:return new vi(e);case dt.Polygon:case dt.Triangle:return new xi(e);case dt.Star:case dt.Rhombus:return new Si(e);case dt.Rectangle:return new yi(e);case dt.SpeechBalloon:return new Ti(e);case dt.Text:return new ke(e);case dt.LaserPen:return new di(e);case dt.Eraser:return new ae(e,r);case dt.BitMapEraser:return new Je(e);case dt.PencilEraser:return new Xe(e,r);case dt.Selector:return e.vNodes?new Ve(_objectSpread(_objectSpread({},e),{},{vNodes:e.vNodes,drawLayer:e.fullLayer})):void 0;case dt.Image:return new Ne(e);default:return;}}function Oi(h){var r=[],t=["PATH","SPRITE","POLYLINE","RECT","ELLIPSE","LABEL"];var _iterator36=_createForOfIteratorHelper(h),_step36;try{for(_iterator36.s();!(_step36=_iterator36.n()).done;){var _e7=_step36.value;if(_e7.tagName==="GROUP"&&_e7.children.length)return Oi(_e7.children);_e7.tagName&&t.includes(_e7.tagName)&&r.push(_e7);}}catch(err){_iterator36.e(err);}finally{_iterator36.f();}return r;}function Pt(h,r){if(h&&r){var t=Math.min(h.x,r.x),_e8=Math.min(h.y,r.y),n=Math.max(h.x+h.w,r.x+r.w),i=Math.max(h.y+h.h,r.y+r.h),a=n-t,o=i-_e8;return{x:t,y:_e8,w:a,h:o};}return r||h;}function Ft(h){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var t={x:0,y:0,w:0,h:0};var e=1/0,n=1/0,i=-1/0,a=-1/0;return h.forEach(function(o){var _o$XY=_slicedToArray(o.XY,2),s=_o$XY[0],l=_o$XY[1];e=Math.min(e,s-r),n=Math.min(n,l-r),i=Math.max(i,s+r),a=Math.max(a,l+r);}),t.x=e,t.y=n,t.w=i-e,t.h=a-n,t;}function We(h,r){return!(h.x+h.w<r.x||h.x>r.x+r.w||h.y+h.h<r.y||h.y>r.y+r.h);}function Dt(h){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;return{x:Math.floor(h.x-r),y:Math.floor(h.y-r),w:Math.ceil(h.w+r*2),h:Math.ceil(h.h+r*2)};}function Sr(h,r){return{x:h.x+r[0],y:h.y+r[1],w:h.w,h:h.h};}function zp(h,r){var t=new _(h.x,h.y),e=new _(h.x+h.w,h.y),n=new _(h.x+h.w,h.y+h.h),i=new _(h.x,h.y+h.h),a=new _(h.x+h.w/2,h.y+h.h/2),o=Math.PI*r/180,s=_.RotWith(t,a,o),l=_.RotWith(e,a,o),g=_.RotWith(n,a,o),c=_.RotWith(i,a,o);return[s,l,g,c];}function Ei(h,r){var t=zp(h,r);return Ft(t);}function Gp(h,r,t){var e=new _(h.x,h.y),n=new _(h.x+h.w,h.y),i=new _(h.x+h.w,h.y+h.h),a=new _(h.x,h.y+h.h),o=new _(t[0],t[1]),s=new _(r[0],r[1]),l=_.ScaleWOrigin(e,s,o),g=_.ScaleWOrigin(n,s,o),c=_.ScaleWOrigin(i,s,o),d=_.ScaleWOrigin(a,s,o);return Ft([l,g,c,d]);}function Hp(h,r,t){var e=new _(r[0],r[1]);for(var n=0;n<h.length;n+=3){var i=new _(h[n],h[n+1]),a=Math.PI*t/180,o=_.RotWith(i,e,a);h[n]=o.x,h[n+1]=o.y;}}function Kp(h,r,t){var e=new _(r[0],r[1]);for(var n=0;n<h.length;n+=2){var i=new _(h[n],h[n+1]),a=Math.PI*t/180,o=_.RotWith(i,e,a);h[n]=o.x,h[n+1]=o.y;}}function Ur(h,r,t){var e=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[0,0];var n=new _(r[0],r[1]);for(var i=0;i<h.length;i+=3){var a=new _(h[i],h[i+1]),o=new _(t[0],t[1]),s=_.ScaleWOrigin(a,o,n);h[i]=s.x+e[0],h[i+1]=s.y+e[1];}}function jr(h,r,t){var e=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[0,0];var n=new _(r[0],r[1]);for(var i=0;i<h.length;i+=2){var a=new _(h[i],h[i+1]),o=new _(t[0],t[1]),s=_.ScaleWOrigin(a,o,n);h[i]=s.x+e[0],h[i+1]=s.y+e[1];}}function Yp(h,r){return h[0]>=r.x&&h[0]<=r.x+r.w&&h[1]>=r.y&&h[1]<=r.y+r.h;}function Ci(h,r){var t=h<=r?1:h/r,e=r<=h?1:r/h;return[t,e];}function Vp(h){var _iterator37=_createForOfIteratorHelper(h),_step37;try{for(_iterator37.s();!(_step37=_iterator37.n()).done;){var r=_step37.value;if(isNaN(r)||r===1/0||r===-1/0)return!1;}}catch(err){_iterator37.e(err);}finally{_iterator37.f();}return!0;}function kp(h){return h!==Math.floor(h);}function Xp(h){var r=h.toString();return r.indexOf(".")!==-1?r.split(".")[1].length:0;}function Jp(h,r){for(;r!==0;){var _ref168=[r,h%r];h=_ref168[0];r=_ref168[1];}return h;}var Zp=function Zp(h){if(h.tagName==="GROUP"){var r=Object.getOwnPropertySymbols(h).find(function(t){return t.toString()==="Symbol(sealed)";});if(r&&h[r])return!0;}return!1;};function ge(h){return"".concat(Ze(h.x),",").concat(Ze(h.y)," ");}function me(h,r){return"".concat(Ze((h.x+r.x)/2),",").concat(Ze((h.y+r.y)/2)," ");}function Ze(h){return+h.toFixed(4);}var fr=function fr(h,r){return h.x+h.w<r.x||h.x>r.x+r.w||h.y+h.h<r.y||h.y>r.y+r.h?Me.outside:h.x>=r.x&&h.y>=r.y&&h.x+h.w<=r.x+r.w&&h.y+h.h<=r.y+r.h?Me.inside:Me.intersect;};function Qp(h){var r=0;for(var t=0;t<h.length;t++){var _e9=h.charCodeAt(t);_e9>=1&&_e9<=126||65376<=_e9&&_e9<=65439?r++:r+=2;}return r;}var be="cursorhover",Cn=20,Qe="mainView";var qp=/*#__PURE__*/function(){function qp(r,t){_classCallCheck(this,qp);tt(this,"viewId");tt(this,"scene");tt(this,"fullLayer");tt(this,"curNodeMap",/* @__PURE__ */new Map());tt(this,"targetNodeMap",[]);tt(this,"highLevelIds");tt(this,"canClearUids");tt(this,"localUid");this.viewId=r,this.scene=t;}return _createClass(qp,[{key:"init",value:function init(r){this.fullLayer=r;}},{key:"get",value:function get(r){return this.curNodeMap.get(r);}},{key:"setLocalUid",value:function setLocalUid(r){this.localUid=r;}},{key:"getLocalUid",value:function getLocalUid(){return this.localUid;}},{key:"setCanClearUids",value:function setCanClearUids(r){this.canClearUids=r;}},{key:"getCanClearUids",value:function getCanClearUids(){return this.canClearUids;}},{key:"getCanEraserNodes",value:function getCanEraserNodes(r,t){var e=/* @__PURE__ */new Map();var _iterator38=_createForOfIteratorHelper(r.entries()),_step38;try{for(_iterator38.s();!(_step38=_iterator38.n()).done;){var _step38$value=_slicedToArray(_step38.value,2),n=_step38$value[0],i=_step38$value[1];i.toolsType===dt.Image&&(i.opt.locked||t&&t.disableEraseImage)||i.toolsType===dt.Text&&(i.opt.workState===It.Doing||i.opt.workState===It.Start||t&&t.disableEraseText)||this.isCanClearWorkId(n)&&e.set(n,i);}}catch(err){_iterator38.e(err);}finally{_iterator38.f();}return e;}},{key:"getNodesByType",value:function getNodesByType(r){var t=/* @__PURE__ */new Map();return this.curNodeMap.forEach(function(e,n){e.toolsType===r&&t.set(n,e);}),t;}},{key:"gethasEraserNodes",value:function gethasEraserNodes(){var r=/* @__PURE__ */new Map();return this.curNodeMap.forEach(function(t,e){var n;(n=t.opt.eraserlines)!=null&&n.length&&r.set(e,t);}),r;}},{key:"hasRenderNodes",value:function hasRenderNodes(){return!0;}},{key:"has",value:function has(r){return this.curNodeMap.has(r);}},{key:"setInfo",value:function setInfo(r,t){var e=this.curNodeMap.get(r)||{name:r,rect:t.rect};t.rect&&(e.rect=Jt(t.rect)),t.op&&Vp(t.op)&&(e.op=Jt(t.op)),t.canRotate&&(e.canRotate=t.canRotate),t.scaleType&&(e.scaleType=t.scaleType),t.opt&&(e.opt=Jt(t.opt)),t.toolsType&&(e.toolsType=t.toolsType),t.centerPos&&(e.centerPos=Jt(t.centerPos)),ye(t.isSelected)&&(e.isSelected=t.isSelected),e.rect?this.curNodeMap.set(r,e):this.curNodeMap["delete"](r);}},{key:"selected",value:function selected(r){this.setInfo(r,{isSelected:!0});}},{key:"unSelected",value:function unSelected(r){this.setInfo(r,{isSelected:!1});}},{key:"delete",value:function _delete(r){this.curNodeMap["delete"](r);}},{key:"clear",value:function clear(){this.curNodeMap.clear(),this.targetNodeMap.length=0;}},{key:"getRectIntersectRange",value:function getRectIntersectRange(r){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var e=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!0;var n;var i=/* @__PURE__ */new Map();var _iterator39=_createForOfIteratorHelper(this.curNodeMap.entries()),_step39;try{for(_iterator39.s();!(_step39=_iterator39.n()).done;){var _step39$value=_slicedToArray(_step39.value,2),a=_step39$value[0],o=_step39$value[1];if(We(r,o.rect)){if(t&&o.toolsType===dt.Image&&o.opt.locked||e&&o.toolsType===dt.Text&&(o.opt.workState===It.Doing||o.opt.workState===It.Start))continue;n=Pt(n,o.rect),i.set(a,o);}}}catch(err){_iterator39.e(err);}finally{_iterator39.f();}return{rectRange:n,nodeRange:i};}},{key:"getNodeRectFormShape",value:function getNodeRectFormShape(r,t){var e=Pi(t.toolsType);return this.fullLayer&&(e==null?void 0:e.getRectFromLayer(this.fullLayer,r));}},{key:"updateNodeRect",value:function updateNodeRect(r){var t=this.curNodeMap.get(r);if(t){var _e10=this.getNodeRectFormShape(r,t);if(!_e10){this.curNodeMap["delete"](r);return;}t.rect=_e10,this.curNodeMap.set(r,t);}}},{key:"updateHighLevelNodesRect",value:function updateHighLevelNodesRect(r){this.highLevelIds=r;var _iterator40=_createForOfIteratorHelper(this.highLevelIds.keys()),_step40;try{for(_iterator40.s();!(_step40=_iterator40.n()).done;){var t=_step40.value;this.updateNodeRect(t);}}catch(err){_iterator40.e(err);}finally{_iterator40.f();}}},{key:"updateLowLevelNodesRect",value:function updateLowLevelNodesRect(){var r;var _iterator41=_createForOfIteratorHelper(this.curNodeMap.keys()),_step41;try{for(_iterator41.s();!(_step41=_iterator41.n()).done;){var t=_step41.value;(r=this.highLevelIds)!=null&&r.has(t)||this.updateNodeRect(t);}}catch(err){_iterator41.e(err);}finally{_iterator41.f();}}},{key:"clearHighLevelIds",value:function clearHighLevelIds(){this.highLevelIds=void 0;}},{key:"setTargetAssignKeys",value:function setTargetAssignKeys(r){var t=/* @__PURE__ */new Map();var _iterator42=_createForOfIteratorHelper(r),_step42;try{for(_iterator42.s();!(_step42=_iterator42.n()).done;){var _e11=_step42.value;var n=this.curNodeMap.get(_e11);n&&t.set(_e11,Jt(n));}}catch(err){_iterator42.e(err);}finally{_iterator42.f();}return this.targetNodeMap.push(Jt(t)),this.targetNodeMap.length-1;}},{key:"setTarget",value:function setTarget(){return this.targetNodeMap.push(Jt(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(r){return this.targetNodeMap[r];}},{key:"deleteTarget",value:function deleteTarget(r){this.targetNodeMap.length=r;}},{key:"clearTarget",value:function clearTarget(){this.targetNodeMap.length=0;}},{key:"isLocalWorkId",value:function isLocalWorkId(r){return r.split(De).length===1;}},{key:"isCanClearWorkId",value:function isCanClearWorkId(r){if(this.canClearUids===void 0||this.canClearUids===!0)return!0;if(Iu(this.canClearUids)){var t=r.split(De);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 Ai=/*#__PURE__*/function(){function Ai(r,t,e){_classCallCheck(this,Ai);tt(this,"viewId");tt(this,"scene");tt(this,"fullLayer");tt(this,"vNodes");tt(this,"dpr");tt(this,"contextType");tt(this,"opt");tt(this,"cameraOpt");tt(this,"isSafari",!1);tt(this,"combinePostMsg",/* @__PURE__ */new Set());tt(this,"workerTaskId");tt(this,"protectedTask");tt(this,"hasPriorityDraw",!0);tt(this,"delayPostDoneResolve");tt(this,"cacheImages",/* @__PURE__ */new Map());tt(this,"imageResolveMap",/* @__PURE__ */new Map());var n,i;if(this.viewId=r,this.opt=t,this.dpr=t.dpr,this.contextType=this.getSupportContextType(e,(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.createRenderLayer(t);}catch(_unused24){if(this.contextType!=="2d")this.contextType="2d",(i=this.scene)==null||i.disconnect(),this.createRenderLayer(t);else throw new Error("Sorry, your browser doesn't support canvas context type ".concat(this.contextType));}this.vNodes=new qp(r,this.scene);}return _createClass(Ai,[{key:"createRenderLayer",value:function createRenderLayer(r){this.scene=this.createScene(r.offscreenCanvasOpt);var t=re.bufferSize.full,e=re.bufferSize.sub;this.fullLayer=this.createLayer("fullLayer",this.scene,_objectSpread(_objectSpread({},r.layerOpt),{},{bufferSize:this.viewId===Qe?t:e*2}));}},{key:"updateDpr",value:function(){var _updateDpr=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28(r){return _regeneratorRuntime().wrap(function _callee28$(_context30){while(1)switch(_context30.prev=_context30.next){case 0:this.dpr=r,this.scene.displayRatio=r;case 1:case"end":return _context30.stop();}},_callee28,this);}));function updateDpr(_x33){return _updateDpr.apply(this,arguments);}return updateDpr;}()},{key:"getCachedImages",value:function getCachedImages(r){var t;return(t=this.cacheImages.get(r))==null?void 0:t.imageBitmap;}},{key:"getCachedImagesByWorkId",value:function getCachedImagesByWorkId(r){var _iterator43=_createForOfIteratorHelper(this.cacheImages.entries()),_step43;try{for(_iterator43.s();!(_step43=_iterator43.n()).done;){var _step43$value=_slicedToArray(_step43.value,2),t=_step43$value[0],_e12=_step43$value[1];if(t===r&&_e12.imageBitmap)return _e12.imageBitmap;}}catch(err){_iterator43.e(err);}finally{_iterator43.f();}}},{key:"deleteCachedImagesByWorkId",value:function deleteCachedImagesByWorkId(r,t){var _iterator44=_createForOfIteratorHelper(this.cacheImages.entries()),_step44;try{for(_iterator44.s();!(_step44=_iterator44.n()).done;){var _step44$value=_slicedToArray(_step44.value,2),_e13=_step44$value[0],n=_step44$value[1];t&&_e13===t||n.workId===r&&(n.imageBitmap.close(),this.cacheImages["delete"](_e13));}}catch(err){_iterator44.e(err);}finally{_iterator44.f();}}},{key:"clearCacheImages",value:function clearCacheImages(){this.cacheImages.forEach(function(r){return r.imageBitmap.close();}),this.cacheImages.clear();}},{key:"clearImageResolveMap",value:function clearImageResolveMap(){this.imageResolveMap.forEach(function(_ref169){var r=_ref169.timer;r&&clearTimeout(r);}),this.imageResolveMap.clear();}},{key:"setHasPriorityDraw",value:function setHasPriorityDraw(r){this.hasPriorityDraw=r;}},{key:"getPriorityDraw",value:function getPriorityDraw(){return this.hasPriorityDraw;}},{key:"setIsSafari",value:function setIsSafari(r){this.isSafari=r;}},{key:"on",value:function(){var _on=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee29(r){var t,e,n,i,a,o,s,l,_l6,g,c,d;return _regeneratorRuntime().wrap(function _callee29$(_context31){while(1)switch(_context31.prev=_context31.next){case 0:t=r.msgType,e=r.toolsType,n=r.opt,i=r.imageSrc,a=r.imageBitmap,o=r.workId,s=r.dpr;_context31.t0=t;_context31.next=_context31.t0===ot.UpdateDpr?4:_context31.t0===ot.UpdateCamera?9:_context31.t0===ot.Destroy?12:_context31.t0===ot.Clear?14:_context31.t0===ot.UpdateTools?17:_context31.t0===ot.GetImageBitMap?19:21;break;case 4:_context31.t1=Vt(s);if(!_context31.t1){_context31.next=8;break;}_context31.next=8;return this.updateDpr(s);case 8:return _context31.abrupt("break",21);case 9:_context31.next=11;return this.updateCamera(r);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(e&&n){l={toolsType:e,toolsOpt:n};this.localWork.setToolsOpt(l);}return _context31.abrupt("break",21);case 19:if(i&&a&&o){_l6=o.toString();this.cacheImages.set(i,{imageBitmap:a,workId:_l6});g=this.imageResolveMap.get(i);if(g){c=g.resolve,d=g.timer;d&&clearTimeout(d),c&&c(i);}this.deleteCachedImagesByWorkId(_l6,i);}return _context31.abrupt("break",21);case 21:case"end":return _context31.stop();}},_callee29,this);}));function on(_x34){return _on.apply(this,arguments);}return on;}()},{key:"getIconSize",value:function getIconSize(r,t,e){var n=r*e,i=t*e;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(r){var _this88=this;var t,e,n,i,a,o,s,l,g,c,d,_this$getIconSize,_this$getIconSize2,v,_T41,_v9,_v10,S;return _regeneratorRuntime().wrap(function _callee30$(_context32){while(1)switch(_context32.prev=_context32.next){case 0:t=r.toolsType,e=r.opt,n=r.workId,i=r.isSubWorker;if(!(t===dt.Image&&e&&n)){_context32.next=19;break;}a=n.toString(),o=e.src,s=e.type,l=e.width,g=e.height,c=e.strokeColor;if(!(!o||!s||!l||!g)){_context32.next=5;break;}return _context32.abrupt("return");case 5:d=o;if(s===xr.Iconify){_this$getIconSize=this.getIconSize(l,g,this.dpr),_this$getIconSize2=_slicedToArray(_this$getIconSize,2),v=_this$getIconSize2[0],_T41=_this$getIconSize2[1];d="".concat(o,"?width=").concat(v,"&height=").concat(_T41,"&color=").concat(c);}if(!this.cacheImages.has(d)){_context32.next=11;break;}_v9=this.getCachedImages(d);if(!_v9){_context32.next=11;break;}return _context32.abrupt("return",_v9);case 11:if(!this.imageResolveMap.has(d)){_context32.next=15;break;}_v10=this.getCachedImagesByWorkId(a);if(!_v10){_context32.next=15;break;}return _context32.abrupt("return",_v10);case 15:_context32.next=17;return new Promise(function(v){var T=_this88.imageResolveMap.get(d)||{resolve:void 0,timer:void 0};T.timer&&clearTimeout(T.timer),T.resolve=v,T.timer=setTimeout(function(){var f=_this88.imageResolveMap.get(d);f!=null&&f.resolve&&f.resolve(d);},5e3),_this88.imageResolveMap.set(d,T),_this88._post({sp:[{imageSrc:d,workId:a,viewId:_this88.viewId,isgl:!!_this88.fullLayer.parent.gl,isSubWorker:i,type:ot.GetImageBitMap}]});});case 17:S=_context32.sent;return _context32.abrupt("return",(this.imageResolveMap["delete"](S),this.getCachedImages(d)));case 19:case"end":return _context32.stop();}},_callee30,this);}));function loadImageBitMap(_x35){return _loadImageBitMap.apply(this,arguments);}return loadImageBitMap;}()},{key:"createLocalWork",value:function createLocalWork(r){var t=r.workId,e=r.opt,n=r.toolsType;t&&e&&(!this.localWork.getToolsOpt()&&n&&this.setToolsOpt({toolsType:n,toolsOpt:e}),this.setWorkOpt({workId:t,toolsOpt:e}));}},{key:"updateScene",value:function updateScene(r){this.scene.attr(_objectSpread({},r));var t=r.width,e=r.height;this.scene.container.width=t,this.scene.container.height=e,this.scene.width=t,this.scene.height=e,this.updateLayer({width:t,height:e});}},{key:"updateLayer",value:function updateLayer(r){var t=r.width,e=r.height;this.fullLayer&&(this.fullLayer.parent.setAttribute("width",t),this.fullLayer.parent.setAttribute("height",e),this.fullLayer.setAttribute("size",[t,e]),this.fullLayer.setAttribute("pos",[t*0.5,e*0.5]));}},{key:"getSupportContextType",value:function getSupportContextType(r,t){var e=new OffscreenCanvas(100,100);var n=["2d"];r===qe.Full&&this.viewId===Qe&&(n=["webgl2","webgl","2d"],t&&n.unshift(t));for(var _i11=0,_n7=n;_i11<_n7.length;_i11++){var i=_n7[_i11];try{if(e.getContext(i))return i;}catch(_unused25){continue;}}}},{key:"createScene",value:function createScene(r){var t=r.width,e=r.height,n=new OffscreenCanvas(t,e);r.contextType&&delete r.contextType;var i=new ts(_objectSpread(_objectSpread({container:n,displayRatio:this.dpr,depth:!1,desynchronized:!0,failIfMajorPerformanceCaveat:!0},r),{},{contextType:this.contextType,id:this.viewId}));return i.setAttribute("id",this.viewId),i;}},{key:"createLayer",value:function createLayer(r,t,e){var n=e.width,i=e.height,a="offscreen-".concat(r),o=t.layer(a,e),s=new Zt({anchor:[0.5,0.5],pos:[n*0.5,i*0.5],size:[n,i],name:"viewport",id:r});return o.append(s),s;}},{key:"clearAll",value:function(){var _clearAll=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee31(){var r;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();}),this.fullLayer.removeAllChildren()),this.clearCacheImages(),this.clearImageResolveMap(),this.localWork.destroy(),(r=this.serviceWork)==null||r.destroy();case 1:case"end":return _context33.stop();}},_callee31,this);}));function clearAll(){return _clearAll.apply(this,arguments);}return clearAll;}()},{key:"setToolsOpt",value:function setToolsOpt(r){this.localWork.setToolsOpt(r);}},{key:"setWorkOpt",value:function setWorkOpt(r){var t=r.workId,e=r.toolsOpt;t&&e&&this.localWork.setWorkOptions(t.toString(),e);}},{key:"destroy",value:function destroy(){var r;this.vNodes.clear(),this.fullLayer.remove(),this.clearCacheImages(),this.clearImageResolveMap(),this.scene.remove(),this.localWork.destroy(),(r=this.serviceWork)==null||r.destroy();}},{key:"post",value:function(){var _post=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee32(r){return _regeneratorRuntime().wrap(function _callee32$(_context34){while(1)switch(_context34.prev=_context34.next){case 0:this.combinePostMsg.add(r);_context34.next=3;return this.runBatchPostData();case 3:case"end":return _context34.stop();}},_callee32,this);}));function post(_x36){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===qe.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,s;this.workerTaskId=void 0;var r=[],t=[];var e,n,i;var a=/* @__PURE__ */new Set();var _iterator45=_createForOfIteratorHelper(this.combinePostMsg.values()),_step45;try{for(_iterator45.s();!(_step45=_iterator45.n()).done;){var l=_step45.value;if((o=l.render)!=null&&o.length){var _iterator46=_createForOfIteratorHelper(l.render),_step46;try{for(_iterator46.s();!(_step46=_iterator46.n()).done;){var g=_step46.value;var c=!1;if(g.workId&&a.add(g.workId),g.isClearAll&&(g.rect=this.getSceneRect(),g.isClear=!0,delete g.isClearAll),g.drawCanvas){var d=this.getLayer(g.drawCanvas);if(!d||!(d.parent instanceof _i))continue;if(d.parent.render(),g.isDrawAll){var y=this.getSceneRect();g.rect=y,delete g.isDrawAll;}}var _iterator47=_createForOfIteratorHelper(r),_step47;try{for(_iterator47.s();!(_step47=_iterator47.n()).done;){var _d5=_step47.value;if(g.viewId===_d5.viewId){g.isClear&&_d5.clearCanvas&&_d5.isClear&&_d5.clearCanvas===g.clearCanvas&&(_d5.rect=Pt(_d5.rect,g.rect),c=!0),_d5.drawCanvas&&_d5.drawCanvas===g.drawCanvas&&(_d5.rect=Pt(_d5.rect,g.rect),c=!0);continue;}}}catch(err){_iterator47.e(err);}finally{_iterator47.f();}c||(g.isClear&&!g.drawCanvas?r.unshift(g):r.push(g));}}catch(err){_iterator46.e(err);}finally{_iterator46.f();}}if((s=l.sp)!=null&&s.length){var _iterator48=_createForOfIteratorHelper(l.sp),_step48;try{for(_iterator48.s();!(_step48=_iterator48.n()).done;){var _g10=_step48.value;var _c6=!1;var _iterator49=_createForOfIteratorHelper(t),_step49;try{for(_iterator49.s();!(_step49=_iterator49.n()).done;){var _d6=_step49.value;if(le(_g10,_d6)){_c6=!0;break;}}}catch(err){_iterator49.e(err);}finally{_iterator49.f();}_c6||t.push(_g10);}}catch(err){_iterator48.e(err);}finally{_iterator48.f();}}Vt(l.fullWorkerDrawCount)&&(e=l.fullWorkerDrawCount),Vt(l.subWorkerDrawCount)&&(n=l.subWorkerDrawCount),Vt(l.consumeCount)&&(i=l.consumeCount);}}catch(err){_iterator45.e(err);}finally{_iterator45.f();}return this.combinePostMsg.clear(),{render:r,sp:t,fullWorkerDrawCount:e,subWorkerDrawCount:n,consumeCount:i,workIds:a,viewId:this.viewId};}},{key:"safariFixRect",value:function safariFixRect(r,t){if(r.w+r.x<=0||r.h+r.y<=0||r.w<=0||r.h<=0)return;var e=this.scene.width,n=this.scene.height,i={x:Math.floor(Math.max(0,r.x)),y:Math.floor(Math.max(0,r.y)),w:Math.floor(Math.min(e,r.w)),h:Math.floor(Math.min(n,r.h))};if(i.x+i.w>e&&(i.w=Math.floor(e-i.x)),i.y+i.h>n&&(i.h=Math.floor(n-i.y)),kp(t)){var a=Xp(t),o=Math.pow(10,a),s=Jp(o,t*o),l=i.x%s,g=i.x-l;g>=0?(i.x=g,i.w=i.w+l):(i.x=0,i.w=i.w+l-g);var c=i.y%s,d=i.y-c;d>=0?(i.y=d,i.h=i.h+c):(i.y=0,i.h=i.h+c-d);}return i;}},{key:"getSceneRect",value:function getSceneRect(){var _this$scene=this.scene,r=_this$scene.width,t=_this$scene.height;return{x:0,y:0,w:Math.floor(r),h:Math.floor(t)};}}]);}();var Ri=/*#__PURE__*/function(){function Ri(r){_classCallCheck(this,Ri);tt(this,"viewId");tt(this,"vNodes");tt(this,"thread");tt(this,"fullLayer");tt(this,"drawLayer");tt(this,"_post");tt(this,"tmpOpt");tt(this,"workShapes",/* @__PURE__ */new Map());tt(this,"drawCount",0);tt(this,"consumeCount",0);tt(this,"syncUnitTime",re.syncOpt.interval);this.thread=r.thread,this.viewId=r.viewId,this.vNodes=r.vNodes,this.fullLayer=r.fullLayer,this.drawLayer=r.drawLayer,this._post=this.thread.post.bind(r.thread);}return _createClass(Ri,[{key:"destroy",value:function destroy(){this.workShapes.clear();}},{key:"getWorkShapes",value:function getWorkShapes(){return this.workShapes;}},{key:"getWorkShape",value:function getWorkShape(r){return this.workShapes.get(r);}},{key:"createWorkShape",value:function createWorkShape(r,t){if(r&&this.tmpOpt){var _e14={toolsType:this.tmpOpt.toolsType,toolsOpt:t||this.tmpOpt.toolsOpt},n=this.createWorkShapeNode(_objectSpread(_objectSpread({},_e14),{},{workId:r}));n&&this.workShapes.set(r,n);}}},{key:"setWorkOptions",value:function setWorkOptions(r,t){var e=this.getWorkShape(r);e||this.createWorkShape(r,t),e==null||e.setWorkOptions(t);}},{key:"createWorkShapeNode",value:function createWorkShapeNode(r){var t;return Fr(_objectSpread(_objectSpread({},r),{},{vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer}),(t=this.thread)==null?void 0:t.serviceWork);}},{key:"setToolsOpt",value:function setToolsOpt(r){var t,e,n;((t=this.tmpOpt)==null?void 0:t.toolsType)!==r.toolsType&&(e=this.tmpOpt)!=null&&e.toolsType&&this.clearAllWorkShapesCache(),this.tmpOpt=r,(n=r.toolsOpt)!=null&&n.syncUnitTime&&(this.syncUnitTime=r.toolsOpt.syncUnitTime);}},{key:"getToolsOpt",value:function getToolsOpt(){return this.tmpOpt;}},{key:"clearWorkShapeNodeCache",value:function clearWorkShapeNodeCache(r){var t;(t=this.getWorkShape(r))==null||t.clearTmpPoints(),this.workShapes["delete"](r);}},{key:"clearAllWorkShapesCache",value:function clearAllWorkShapesCache(){this.workShapes.forEach(function(r){return r.clearTmpPoints();}),this.workShapes.clear();}},{key:"setFullWork",value:function setFullWork(r){var t=r.workId,e=r.opt,n=r.toolsType;if(t&&e&&n){var i=t.toString();var a;return t&&this.workShapes.has(i)?(a=this.workShapes.get(i),a==null||a.setWorkOptions(e)):a=this.createWorkShapeNode({toolsOpt:e,toolsType:n,workId:i}),a?(this.workShapes.set(i,a),a):void 0;}}}]);}();var _p=ee,t0=function t0(){return _p.Date.now();},e0=t0,r0=/\s/;function n0(h){for(var r=h.length;r--&&r0.test(h.charAt(r)););return r;}var i0=n0,s0=i0,o0=/^\s+/;function a0(h){return h&&h.slice(0,s0(h)+1).replace(o0,"");}var l0=a0,c0=de,f0=ne,h0="[object Symbol]";function u0(h){return _typeof(h)=="symbol"||f0(h)&&c0(h)==h0;}var d0=u0,p0=l0,An=he,g0=d0,Rn=NaN,m0=/^[-+]0x[0-9a-f]+$/i,v0=/^0b[01]+$/i,y0=/^0o[0-7]+$/i,S0=parseInt;function x0(h){if(typeof h=="number")return h;if(g0(h))return Rn;if(An(h)){var r=typeof h.valueOf=="function"?h.valueOf():h;h=An(r)?r+"":r;}if(typeof h!="string")return h===0?h:+h;h=p0(h);var t=v0.test(h);return t||y0.test(h)?S0(h.slice(2),t?2:8):m0.test(h)?Rn:+h;}var T0=x0,M0=he,hr=e0,In=T0,P0="Expected a function",O0=Math.max,E0=Math.min;function C0(h,r,t){var e,n,i,a,o,s,l=0,g=!1,c=!1,d=!0;if(typeof h!="function")throw new TypeError(P0);r=In(r)||0,M0(t)&&(g=!!t.leading,c="maxWait"in t,i=c?O0(In(t.maxWait)||0,r):i,d="trailing"in t?!!t.trailing:d);function y(M){var O=e,A=n;return e=n=void 0,l=M,a=h.apply(A,O),a;}function P(M){return l=M,o=setTimeout(T,r),g?y(M):a;}function S(M){var O=M-s,A=M-l,w=r-O;return c?E0(w,i-A):w;}function v(M){var O=M-s,A=M-l;return s===void 0||O>=r||O<0||c&&A>=i;}function T(){var M=hr();if(v(M))return f(M);o=setTimeout(T,S(M));}function f(M){return o=void 0,d&&e?y(M):(e=n=void 0,a);}function p(){o!==void 0&&clearTimeout(o),l=0,e=s=n=o=void 0;}function u(){return o===void 0?a:f(hr());}function m(){var M=hr(),O=v(M);if(e=arguments,n=this,s=M,O){if(o===void 0)return P(s);if(c)return clearTimeout(o),o=setTimeout(T,r),y(s);}return o===void 0&&(o=setTimeout(T,r)),a;}return m.cancel=p,m.flush=u,m;}var A0=C0,R0=A0,I0=he,L0="Expected a function";function w0(h,r,t){var e=!0,n=!0;if(typeof h!="function")throw new TypeError(L0);return I0(t)&&(e="leading"in t?!!t.leading:e,n="trailing"in t?!!t.trailing:n),R0(h,r,{leading:e,maxWait:r,trailing:n});}var b0=w0,D0=/* @__PURE__ */fe(b0);function N0(h){return h;}var Ii=N0;function W0(h,r,t){switch(t.length){case 0:return h.call(r);case 1:return h.call(r,t[0]);case 2:return h.call(r,t[0],t[1]);case 3:return h.call(r,t[0],t[1],t[2]);}return h.apply(r,t);}var B0=W0,F0=B0,Ln=Math.max;function U0(h,r,t){return r=Ln(r===void 0?h.length-1:r,0),function(){for(var e=arguments,n=-1,i=Ln(e.length-r,0),a=Array(i);++n<i;)a[n]=e[r+n];n=-1;for(var o=Array(r+1);++n<r;)o[n]=e[n];return o[r]=t(a),F0(h,this,o);};}var j0=U0;function $0(h){return function(){return h;};}var z0=$0,G0=z0,wn=Gn,H0=Ii,K0=wn?function(h,r){return wn(h,"toString",{configurable:!0,enumerable:!1,value:G0(r),writable:!0});}:H0,Y0=K0,V0=800,k0=16,X0=Date.now;function J0(h){var r=0,t=0;return function(){var e=X0(),n=k0-(e-t);if(t=e,n>0){if(++r>=V0)return arguments[0];}else r=0;return h.apply(void 0,arguments);};}var Z0=J0,Q0=Y0,q0=Z0,_0=q0(Q0),tg=_0,eg=Ii,rg=j0,ng=tg;function ig(h,r){return ng(rg(h,r,eg),h+"");}var sg=ig;function og(h,r,t,e){for(var n=h.length,i=t+(e?1:-1);e?i--:++i<n;)if(r(h[i],i,h))return i;return-1;}var ag=og;function lg(h){return h!==h;}var cg=lg;function fg(h,r,t){for(var e=t-1,n=h.length;++e<n;)if(h[e]===r)return e;return-1;}var hg=fg,ug=ag,dg=cg,pg=hg;function gg(h,r,t){return r===r?pg(h,r,t):ug(h,dg,t);}var mg=gg,vg=mg;function yg(h,r){var t=h==null?0:h.length;return!!t&&vg(h,r,0)>-1;}var Li=yg;function Sg(h,r,t){for(var e=-1,n=h==null?0:h.length;++e<n;)if(t(r,h[e]))return!0;return!1;}var wi=Sg;function xg(h,r){for(var t=-1,e=h==null?0:h.length,n=Array(e);++t<e;)n[t]=r(h[t],t,h);return n;}var Tg=xg,Mg=Nr,Pg=Li,Og=wi,Eg=Tg,Cg=sr,Ag=Wr,Rg=200;function Ig(h,r,t,e){var n=-1,i=Pg,a=!0,o=h.length,s=[],l=r.length;if(!o)return s;t&&(r=Eg(r,Cg(t))),e?(i=Og,a=!1):r.length>=Rg&&(i=Ag,a=!1,r=new Mg(r));t:for(;++n<o;){var g=h[n],c=t==null?g:t(g);if(g=e||g!==0?g:0,a&&c===c){for(var d=l;d--;)if(r[d]===c)continue t;s.push(g);}else i(r,c,e)||s.push(g);}return s;}var Lg=Ig,bn=Be,wg=Vn,bg=Fe,Dn=bn?bn.isConcatSpreadable:void 0;function Dg(h){return bg(h)||wg(h)||!!(Dn&&h&&h[Dn]);}var Ng=Dg,Wg=Lr,Bg=Ng;function bi(h,r,t,e,n){var i=-1,a=h.length;for(t||(t=Bg),n||(n=[]);++i<a;){var o=h[i];r>0&&t(o)?r>1?bi(o,r-1,t,e,n):Wg(n,o):e||(n[n.length]=o);}return n;}var Fg=bi;function Ug(){}var jg=Ug,ur=ni,$g=jg,zg=Br,Gg=1/0,Hg=ur&&1/zg(new ur([,-0]))[1]==Gg?function(h){return new ur(h);}:$g,Kg=Hg,Yg=Nr,Vg=Li,kg=wi,Xg=Wr,Jg=Kg,Zg=Br,Qg=200;function qg(h,r,t){var e=-1,n=Vg,i=h.length,a=!0,o=[],s=o;if(t)a=!1,n=kg;else if(i>=Qg){var l=r?null:Jg(h);if(l)return Zg(l);a=!1,n=Xg,s=new Yg();}else s=r?[]:o;t:for(;++e<i;){var g=h[e],c=r?r(g):g;if(g=t||g!==0?g:0,a&&c===c){for(var d=s.length;d--;)if(s[d]===c)continue t;r&&s.push(c),o.push(g);}else n(s,c,t)||(s!==o&&s.push(c),o.push(g));}return o;}var _g=qg,tm=Lg,em=Fg,Nn=_g;function rm(h,r,t){var e=h.length;if(e<2)return e?Nn(h[0]):[];for(var n=-1,i=Array(e);++n<e;)for(var a=h[n],o=-1;++o<e;)o!=n&&(i[n]=tm(i[n]||a,h[o],r,t));return Nn(em(i,1),r,t);}var nm=rm,im=Cr,sm=ne;function om(h){return sm(h)&&im(h);}var am=om,lm=Qn,cm=sg,fm=nm,hm=am,um=cm(function(h){return fm(lm(h,hm));}),dm=um,pm=/* @__PURE__ */fe(dm);var gm=/*#__PURE__*/function(_Ri){function gm(t){var _this90;_classCallCheck(this,gm);_this90=_callSuper(this,gm,[t]);tt(_this90,"combineUnitTime",re.bezier.combineUnitTime);tt(_this90,"combineTimerId");tt(_this90,"combineDrawResolve");tt(_this90,"combineDrawActiveId");tt(_this90,"drawWorkActiveId");tt(_this90,"effectSelectNodeData",/* @__PURE__ */new Set());tt(_this90,"batchEraserWorks",/* @__PURE__ */new Set());tt(_this90,"batchEraserRemoveNodes",/* @__PURE__ */new Set());tt(_this90,"batchEraserCombine",D0(function(){var t=_this90.updateBatchEraserCombineNode(_this90.batchEraserWorks,_this90.batchEraserRemoveNodes);_this90.batchEraserWorks.clear(),_this90.batchEraserRemoveNodes.clear(),t.length&&_this90._post({render:t});},200,{leading:!1}));return _this90;}_inherits(gm,_Ri);return _createClass(gm,[{key:"loadImageBitMap",value:function(){var _loadImageBitMap2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee34(t){return _regeneratorRuntime().wrap(function _callee34$(_context36){while(1)switch(_context36.prev=_context36.next){case 0:_context36.next=2;return this.thread.loadImageBitMap(t);case 2:return _context36.abrupt("return",_context36.sent);case 3:case"end":return _context36.stop();}},_callee34,this);}));function loadImageBitMap(_x37){return _loadImageBitMap2.apply(this,arguments);}return loadImageBitMap;}()},{key:"consumeDraw",value:function(){var _consumeDraw=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee35(t,e){var _this91=this;var n,i,a,o,s,l,g,c;return _regeneratorRuntime().wrap(function _callee35$(_context37){while(1)switch(_context37.prev=_context37.next){case 0:n=t.op,i=t.workId,a=t.scenePath,o=t.postCount;if(!(n!=null&&n.length&&i)){_context37.next=56;break;}s=i.toString(),l=this.getWorkShape(s);if(l){_context37.next=5;break;}return _context37.abrupt("return");case 5:g=l.toolsType;if(!(g===dt.LaserPen)){_context37.next=8;break;}return _context37.abrupt("return");case 8:_context37.t0=this.combineDrawActiveId&&this.combineDrawActiveId!==s;if(!_context37.t0){_context37.next=13;break;}this.combineTimerId&&(clearTimeout(this.combineTimerId),this.combineTimerId=void 0,this.combineDrawResolve&&this.combineDrawResolve(!1),this.combineDrawActiveId=void 0);_context37.next=13;return this.consumeDrawAll({workId:this.combineDrawActiveId,scenePath:a,viewId:this.viewId,msgType:ot.DrawWork,dataType:Tt.Local},e);case 13:_context37.t1=this.drawWorkActiveId&&this.drawWorkActiveId!==s;if(!_context37.t1){_context37.next=18;break;}_context37.next=17;return this.consumeDrawAll({workId:this.drawWorkActiveId,scenePath:a,viewId:this.viewId,msgType:ot.DrawWork,dataType:Tt.Local},e);case 17:this.drawWorkActiveId=void 0;case 18:!this.drawWorkActiveId&&s!==Wt&&(this.drawWorkActiveId=s);Vt(o)&&(this.consumeCount=o);c=l.consume({data:t,isFullWork:!0});_context37.t2=g;_context37.next=_context37.t2===dt.Selector?24:_context37.t2===dt.PencilEraser?30:_context37.t2===dt.BitMapEraser?33:_context37.t2===dt.Eraser?40:_context37.t2===dt.Arrow?43:_context37.t2===dt.Straight?43:_context37.t2===dt.Ellipse?43:_context37.t2===dt.Rectangle?43:_context37.t2===dt.Star?43:_context37.t2===dt.Polygon?43:_context37.t2===dt.SpeechBalloon?43:_context37.t2===dt.Pencil?49:56;break;case 24:_context37.t3=c.type===ot.Select;if(!_context37.t3){_context37.next=29;break;}c.selectIds&&e.runReverseSelectWork(c.selectIds);_context37.next=29;return this.drawSelector(c);case 29:return _context37.abrupt("break",56);case 30:_context37.next=32;return this.drawPencilEraser(c);case 32:return _context37.abrupt("break",56);case 33:this.drawCount++;this.combineTimerId||new Promise(function(d){_this91.combineDrawActiveId=s,_this91.combineDrawResolve=d,_this91.combineTimerId=setTimeout(function(){_this91.combineTimerId=void 0,_this91.combineDrawResolve&&_this91.combineDrawResolve(!0);},_this91.combineUnitTime);}).then(function(d){d&&_this91.drawBitMapCombine(s,_this91.drawCount),_this91.combineDrawResolve=void 0;});_context37.t4=c;if(!_context37.t4){_context37.next=39;break;}_context37.next=39;return this.drawBitMapEraser(c);case 39:return _context37.abrupt("break",56);case 40:_context37.next=42;return this.drawEraser(c);case 42:return _context37.abrupt("break",56);case 43:_context37.t5=c;if(!_context37.t5){_context37.next=48;break;}this.drawCount++;_context37.next=48;return this.drawShape(c);case 48:return _context37.abrupt("break",56);case 49:this.drawCount++;this.combineTimerId||new Promise(function(d){_this91.combineDrawActiveId=s,_this91.combineDrawResolve=d,_this91.combineTimerId=setTimeout(function(){_this91.combineTimerId=void 0,_this91.combineDrawResolve&&_this91.combineDrawResolve(!0);},_this91.combineUnitTime);}).then(function(d){d&&_this91.drawPencilCombine(s,_this91.drawCount),_this91.combineDrawResolve=void 0;});_context37.t6=c;if(!_context37.t6){_context37.next=55;break;}_context37.next=55;return this.drawPencil(c);case 55:return _context37.abrupt("break",56);case 56:case"end":return _context37.stop();}},_callee35,this);}));function consumeDraw(_x38,_x39){return _consumeDraw.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee36(t,e){var o,s,l,n,i,a,g,c,d,y,P,S;return _regeneratorRuntime().wrap(function _callee36$(_context38){while(1)switch(_context38.prev=_context38.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,a=t.isLockSentEventCursor;if(!n){_context38.next=42;break;}g=n.toString();this.drawWorkActiveId===g&&(this.drawWorkActiveId=void 0);c=this.workShapes.get(g);if(c){_context38.next=8;break;}return _context38.abrupt("return");case 8:d=c.toolsType;if(!(d===dt.LaserPen)){_context38.next=11;break;}return _context38.abrupt("return");case 11:y=this.workShapes.get(be),P=(o=y==null?void 0:y.selectIds)==null?void 0:o[0],S=c.consumeAll({data:t,workerEngine:this});_context38.t0=d;_context38.next=_context38.t0===dt.Selector?15:_context38.t0===dt.PencilEraser?21:_context38.t0===dt.BitMapEraser?23:_context38.t0===dt.Eraser?28:_context38.t0===dt.Arrow?30:_context38.t0===dt.Straight?30:_context38.t0===dt.Ellipse?30:_context38.t0===dt.Rectangle?30:_context38.t0===dt.Star?30:_context38.t0===dt.Polygon?30:_context38.t0===dt.SpeechBalloon?30:_context38.t0===dt.Pencil?35:42;break;case 15:S.selectIds&&P&&(s=S.selectIds)!=null&&s.includes(P)&&y.cursorBlur();S.selectIds&&e.runReverseSelectWork(S.selectIds);_context38.next=19;return this.drawSelector(_objectSpread(_objectSpread({},S),{},{scenePath:i}));case 19:(l=c.selectIds)!=null&&l.length?c.clearTmpPoints():this.clearWorkShapeNodeCache(g);return _context38.abrupt("break",42);case 21:this.drawPencilEraser(_objectSpread(_objectSpread({},S),{},{scenePath:i}),a),c.clearTmpPoints();return _context38.abrupt("break",42);case 23:_context38.next=25;return this.drawBitMapEraserFull(c,_objectSpread(_objectSpread({},S),{},{scenePath:i}),a);case 25:this.drawCount=0;this.clearWorkShapeNodeCache(g);return _context38.abrupt("break",42);case 28:this.drawEraser(_objectSpread(_objectSpread({},S),{},{scenePath:i}),a),c.clearTmpPoints();return _context38.abrupt("break",42);case 30:_context38.next=32;return this.drawPencilFull(_objectSpread(_objectSpread({},S),{},{scenePath:i}),a);case 32:this.drawCount=0;this.clearWorkShapeNodeCache(g);return _context38.abrupt("break",42);case 35:_context38.t1=S!=null&&S.rect;if(!_context38.t1){_context38.next=40;break;}_context38.next=39;return this.drawPencilFull(_objectSpread(_objectSpread({},S),{},{scenePath:i}),a);case 39:this.drawCount=0;case 40:this.clearWorkShapeNodeCache(g);return _context38.abrupt("break",42);case 42:case"end":return _context38.stop();}},_callee36,this);}));function consumeDrawAll(_x40,_x41){return _consumeDrawAll.apply(this,arguments);}return consumeDrawAll;}()},{key:"workShapesDone",value:function(){var _workShapesDone=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee37(t,e){var _iterator50,_step50,n;return _regeneratorRuntime().wrap(function _callee37$(_context39){while(1)switch(_context39.prev=_context39.next){case 0:_iterator50=_createForOfIteratorHelper(this.workShapes.keys());_context39.prev=1;_iterator50.s();case 3:if((_step50=_iterator50.n()).done){_context39.next=9;break;}n=_step50.value;_context39.next=7;return this.consumeDrawAll({workId:n,scenePath:t,viewId:this.viewId,msgType:ot.DrawWork,dataType:Tt.Local},e);case 7:_context39.next=3;break;case 9:_context39.next=14;break;case 11:_context39.prev=11;_context39.t0=_context39["catch"](1);_iterator50.e(_context39.t0);case 14:_context39.prev=14;_iterator50.f();return _context39.finish(14);case 17:case"end":return _context39.stop();}},_callee37,this,[[1,11,14,17]]);}));function workShapesDone(_x42,_x43){return _workShapesDone.apply(this,arguments);}return workShapesDone;}()},{key:"consumeFull",value:function(){var _consumeFull=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee38(t){var i,a,e,n,o,s,l,g,c,d,y;return _regeneratorRuntime().wrap(function _callee38$(_context40){while(1)switch(_context40.prev=_context40.next){case 0:e=this.setFullWork(t),n=t.ops&&Pe(t.ops)||t.op;if(!e){_context40.next=26;break;}o=(i=t.workId)==null?void 0:i.toString();if(o){_context40.next=5;break;}return _context40.abrupt("return");case 5:s=(a=this.vNodes.get(o))==null?void 0:a.rect;if(!(e.toolsType===dt.Image)){_context40.next=13;break;}_context40.next=9;return e.consumeServiceAsync({isFullWork:!0,replaceId:o,worker:this});case 9:l=_context40.sent;g=(t==null?void 0:t.updateNodeOpt)&&e.updataOptService(t.updateNodeOpt);_context40.next=20;break;case 13:if(!(e.toolsType===dt.Text)){_context40.next=19;break;}_context40.next=16;return e.consumeServiceAsync({isFullWork:!0,replaceId:o});case 16:l=_context40.sent;_context40.next=20;break;case 19:l=e.consumeService({op:n,isFullWork:!0,replaceId:o}),g=(t==null?void 0:t.updateNodeOpt)&&e.updataOptService(t.updateNodeOpt);case 20:l=Pt(l,g);c=[],d=[];if(!(t.workId&&this.workShapes["delete"](t.workId.toString()),l&&t.willRefresh&&(s&&c.push({rect:Dt(s),isClear:!0,clearCanvas:St.Bg,viewId:this.viewId}),c.push({rect:Dt(l),drawCanvas:St.Bg,viewId:this.viewId})),t.willSyncService&&d.push({opt:t.opt,toolsType:t.toolsType,type:ot.FullWork,workId:t.workId,ops:t.ops,updateNodeOpt:t.updateNodeOpt,viewId:this.viewId}),c.length||d.length)){_context40.next=26;break;}y={render:c,sp:d};_context40.next=26;return this._post(y);case 26:case"end":return _context40.stop();}},_callee38,this);}));function consumeFull(_x44){return _consumeFull.apply(this,arguments);}return consumeFull;}()},{key:"commandDeleteText",value:function commandDeleteText(t){var e=this.vNodes.get(t);if(e&&e.toolsType===dt.Text)return{type:ot.TextUpdate,toolsType:dt.Text,workId:t,dataType:Tt.Local};}},{key:"removeSelector",value:function(){var _removeSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee39(t,e){var n,i,a,o,s,l,_iterator51,_step51,g,y,d;return _regeneratorRuntime().wrap(function _callee39$(_context41){while(1)switch(_context41.prev=_context41.next){case 0:n=t.willSyncService,i=[],a=[],o=[],s=this.workShapes.get(Wt);if(s){_context41.next=3;break;}return _context41.abrupt("return");case 3:l=s.selectIds&&_toConsumableArray(s.selectIds)||[];_iterator51=_createForOfIteratorHelper(l);try{for(_iterator51.s();!(_step51=_iterator51.n()).done;){g=_step51.value;if(this.vNodes.get(g)){y=this.commandDeleteText(g);y&&i.push(y);}d=this._removeWork(g);d.length&&a.push.apply(a,_toConsumableArray(d)),e==null||e.deleteCachedImagesByWorkId(g),o.push(g);}}catch(err){_iterator51.e(err);}finally{_iterator51.f();}o.length&&i.push({type:ot.RemoveNode,removeIds:o});i.push({type:ot.Select,selectIds:[],willSyncService:n});_context41.next=10;return this.blurSelector();case 10:_context41.t0=a.length||i.length;if(!_context41.t0){_context41.next=14;break;}_context41.next=14;return this._post({render:a,sp:i});case 14:case"end":return _context41.stop();}},_callee39,this);}));function removeSelector(_x45,_x46){return _removeSelector.apply(this,arguments);}return removeSelector;}()},{key:"removeWork",value:function(){var _removeWork2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee40(t){var e,n,i;return _regeneratorRuntime().wrap(function _callee40$(_context42){while(1)switch(_context42.prev=_context42.next){case 0:e=t.workId,n=e==null?void 0:e.toString();if(!n){_context42.next=7;break;}i=this._removeWork(n);_context42.t0=i.length;if(!_context42.t0){_context42.next=7;break;}_context42.next=7;return this._post({render:i});case 7:case"end":return _context42.stop();}},_callee40,this);}));function removeWork(_x47){return _removeWork2.apply(this,arguments);}return removeWork;}()},{key:"removeNode",value:function removeNode(t){var i,a,o;var e=this.vNodes.get(t);e&&((i=this.fullLayer)==null||i.getElementsByName(t).forEach(function(s){s.remove();}),this.vNodes["delete"](t));var n=this.drawLayer&&vt.getRectFromLayer(this.drawLayer,t);if(n){var s=(a=this.drawLayer)==null?void 0:a.getElementsByName(t)[0];(o=this.drawLayer)==null||o.removeChild(s);}return this.getWorkShape(t)&&this.clearWorkShapeNodeCache(t),{fullRect:e==null?void 0:e.rect,drawRect:n};}},{key:"_removeWork",value:function _removeWork(t){var _this$removeNode=this.removeNode(t),e=_this$removeNode.fullRect,n=_this$removeNode.drawRect,i=[];return e&&i.push({rect:Dt(e),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:Dt(e),drawCanvas:St.Bg,viewId:this.viewId}),n&&i.push({rect:Dt(n),clearCanvas:St.Float,isClear:!0,viewId:this.viewId},{rect:Dt(n),drawCanvas:St.Float,viewId:this.viewId}),i;}},{key:"checkTextActive",value:function(){var _checkTextActive=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee41(t){var e,n,i,a,o,s,l,_iterator52,_step52,g,c,d,y,P;return _regeneratorRuntime().wrap(function _callee41$(_context43){while(1)switch(_context43.prev=_context43.next){case 0:e=t.op,n=t.viewId,i=t.dataType;if(!(e!=null&&e.length)){_context43.next=32;break;}s=e[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],l=e[1]*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1];_iterator52=_createForOfIteratorHelper(this.vNodes.curNodeMap.values());_context43.prev=4;_iterator52.s();case 6:if((_step52=_iterator52.n()).done){_context43.next=14;break;}g=_step52.value;c=g.rect,d=g.name,y=g.toolsType,P=g.opt;if(!(y===dt.Text&&P.workState===It.Done&&Yp([s,l],c))){_context43.next=12;break;}a=d,o=this.setFullWork({workId:d,toolsType:y,opt:P});return _context43.abrupt("break",14);case 12:_context43.next=6;break;case 14:_context43.next=19;break;case 16:_context43.prev=16;_context43.t0=_context43["catch"](4);_iterator52.e(_context43.t0);case 19:_context43.prev=19;_iterator52.f();return _context43.finish(19);case 22:_context43.t1=a;if(!_context43.t1){_context43.next=32;break;}_context43.t2=o;if(!_context43.t2){_context43.next=28;break;}_context43.next=28;return o.consumeServiceAsync({isFullWork:!0,replaceId:o.getWorkId(),isDrawLabel:!1});case 28:_context43.next=30;return this.blurSelector({viewId:n,msgType:ot.Select,dataType:i,isSync:!0});case 30:_context43.next=32;return this._post({sp:[{type:ot.GetTextActive,toolsType:dt.Text,workId:a}]});case 32:case"end":return _context43.stop();}},_callee41,this,[[4,16,19,22]]);}));function checkTextActive(_x48){return _checkTextActive.apply(this,arguments);}return checkTextActive;}()},{key:"colloctEffectSelectWork",value:function(){var _colloctEffectSelectWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee42(t){var _this92=this;var e,n,i;return _regeneratorRuntime().wrap(function _callee42$(_context44){while(1)switch(_context44.prev=_context44.next){case 0:e=this.workShapes.get(Wt),n=t.workId,i=t.msgType;if(!(e&&n&&e.selectIds&&e.selectIds.includes(n.toString()))){_context44.next=6;break;}i===ot.RemoveNode?e.selectIds=e.selectIds.filter(function(a){return a!==n.toString();}):this.effectSelectNodeData.add(t);_context44.next=5;return this.runEffectSelectWork(!0).then(function(){var a;(a=_this92.effectSelectNodeData)==null||a.clear();});case 5:return _context44.abrupt("return");case 6:return _context44.abrupt("return",t);case 7:case"end":return _context44.stop();}},_callee42,this);}));function colloctEffectSelectWork(_x49){return _colloctEffectSelectWork.apply(this,arguments);}return colloctEffectSelectWork;}()},{key:"updateSelector",value:function(){var _updateSelector2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee43(t){var _this93=this;var P,e,n,i,a,o,s,l,g,c,d,y;return _regeneratorRuntime().wrap(function _callee43$(_context45){while(1)switch(_context45.prev=_context45.next){case 0:e=this.workShapes.get(Wt);if((P=e==null?void 0:e.selectIds)!=null&&P.length){_context45.next=3;break;}return _context45.abrupt("return");case 3:n=t.callback;i=_objectWithoutProperties(t,_excluded2);a=i.updateSelectorOpt;o=i.willSerializeData;_context45.next=9;return e==null?void 0:e.updateSelector({updateSelectorOpt:a,selectIds:Jt(e.selectIds),vNodes:this.vNodes,willSerializeData:o,worker:this});case 9:s=_context45.sent;l=/* @__PURE__ */new Map();s!=null&&s.selectIds&&(g=pm(e.selectIds,s.selectIds),s.selectIds.forEach(function(S){var v=_this93.vNodes.get(S);if(v){var _T42=v.toolsType,_f37=v.op,p=v.opt;l.set(S,{opt:p,toolsType:_T42,ops:(_f37==null?void 0:_f37.length)&&Qt(_f37)||void 0});}}),e.selectIds=s.selectIds);c=[],d=[];s!=null&&s.rect&&c.push({rect:Dt(s.rect),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:Dt(s.rect),drawCanvas:St.Bg,viewId:this.viewId});y=n&&n({res:s,workShapeNode:e,param:i,postData:{render:c,sp:d},newServiceStore:l})||{render:c,sp:d};g&&y.sp.push({type:ot.RemoveNode,removeIds:g,viewId:this.viewId});_context45.t0=y.render.length||y.sp.length;if(!_context45.t0){_context45.next=20;break;}_context45.next=20;return this._post(y);case 20:case"end":return _context45.stop();}},_callee43,this);}));function updateSelector(_x50){return _updateSelector2.apply(this,arguments);}return updateSelector;}()},{key:"blurSelector",value:function(){var _blurSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee44(t){var i,e,n,a;return _regeneratorRuntime().wrap(function _callee44$(_context46){while(1)switch(_context46.prev=_context46.next){case 0:e=this.workShapes.get(Wt),n=e==null?void 0:e.blurSelector();if(!(this.clearWorkShapeNodeCache(Wt),((i=this.fullLayer)==null?void 0:i.parent).children.forEach(function(a){a.name===Wt&&a.remove();}),n)){_context46.next=6;break;}a=[];a.push(_objectSpread(_objectSpread({},n),{},{isSync:t==null?void 0:t.isSync}));_context46.next=6;return this._post({render:(n==null?void 0:n.rect)&&[{rect:Dt(n.rect),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:Dt(n.rect),drawCanvas:St.Bg,viewId:this.viewId}],sp:a});case 6:case"end":return _context46.stop();}},_callee44,this);}));function blurSelector(_x51){return _blurSelector.apply(this,arguments);}return blurSelector;}()},{key:"hasSelector",value:function hasSelector(){return this.workShapes.has(Wt);}},{key:"getSelector",value:function getSelector(){return this.workShapes.get(Wt);}},{key:"reRenderSelector",value:function(){var _reRenderSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee45(){var t,a,e,n,i,o,_args47=arguments;return _regeneratorRuntime().wrap(function _callee45$(_context47){while(1)switch(_context47.prev=_context47.next){case 0:t=_args47.length>0&&_args47[0]!==undefined?_args47[0]:!1;e=this.workShapes.get(Wt);if(e){_context47.next=4;break;}return _context47.abrupt("return");case 4:if(!(e&&!((a=e.selectIds)!=null&&a.length))){_context47.next=8;break;}_context47.next=7;return this.blurSelector();case 7:return _context47.abrupt("return");case 8:n=e.oldSelectRect,i=e.reRenderSelector();if(!i){_context47.next=13;break;}o=Pt(n,i)||i;_context47.next=13;return this._post({render:[{rect:Dt(o),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:Dt(o),drawCanvas:St.Bg,viewId:this.viewId}],sp:[{type:ot.Select,selectIds:e.selectIds,selectRect:i,willSyncService:t,viewId:this.viewId,points:e.getChildrenPoints(),textOpt:e.textOpt,selectorColor:e.selectorColor,strokeColor:e.strokeColor,fillColor:e.fillColor,canTextEdit:e.canTextEdit,canRotate:e.canRotate,scaleType:e.scaleType,opt:e.getWorkOptions()||void 0,canLock:e.canLock,isLocked:e.isLocked,toolsTypes:e.toolsTypes,shapeOpt:e.shapeOpt,thickness:e.thickness,useStroke:e.useStroke,strokeType:e.strokeType}]});case 13:case"end":return _context47.stop();}},_callee45,this);}));function reRenderSelector(){return _reRenderSelector.apply(this,arguments);}return reRenderSelector;}()},{key:"updateFullSelectWork",value:function(){var _updateFullSelectWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee46(t){var i,a,o,s,l,g,c,e,n,_e$updateSelectIds,d,y,P;return _regeneratorRuntime().wrap(function _callee46$(_context48){while(1)switch(_context48.prev=_context48.next){case 0:e=this.workShapes.get(Wt),n=t.selectIds;if(n!=null&&n.length){_context48.next=5;break;}_context48.next=4;return this.blurSelector(t);case 4:return _context48.abrupt("return");case 5:if(e){_context48.next=10;break;}!this.setFullWork(t)&&t.workId&&((i=this.tmpOpt)==null?void 0:i.toolsType)===dt.Selector&&this.createWorkShape(t.workId.toString());_context48.next=9;return this.updateFullSelectWork(t);case 9:return _context48.abrupt("return");case 10:if(!(e&&n!=null&&n.length)){_context48.next=16;break;}_e$updateSelectIds=e.updateSelectIds(n),d=_e$updateSelectIds.bgRect,y=_e$updateSelectIds.selectRect,P={render:[],sp:[]};d&&((a=P.render)==null||a.push({rect:Dt(d),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:Dt(d),drawCanvas:St.Bg,viewId:this.viewId}));(c=P.sp)==null||c.push(_objectSpread(_objectSpread({},t),{},{selectorColor:((o=t.opt)==null?void 0:o.strokeColor)||e.selectorColor,strokeColor:((s=t.opt)==null?void 0:s.strokeColor)||e.strokeColor,fillColor:((l=t.opt)==null?void 0:l.fillColor)||e.fillColor,textOpt:((g=t.opt)==null?void 0:g.textOpt)||e.textOpt,canTextEdit:e.canTextEdit,canRotate:e.canRotate,scaleType:e.scaleType,type:ot.Select,selectRect:y,points:e.getChildrenPoints(),willSyncService:(t==null?void 0:t.willSyncService)||!1,opt:(t==null?void 0:t.willSyncService)&&e.getWorkOptions()||void 0,canLock:e.canLock,isLocked:e.isLocked,toolsTypes:e.toolsTypes,shapeOpt:e.shapeOpt,thickness:e.thickness,useStroke:e.useStroke,strokeType:e.strokeType}));_context48.next=16;return this._post(P);case 16:case"end":return _context48.stop();}},_callee46,this);}));function updateFullSelectWork(_x52){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(gm,"destroy",this,3)([]),this.effectSelectNodeData.clear(),this.batchEraserWorks.clear(),this.batchEraserRemoveNodes.clear();}},{key:"drawBitMapEraser",value:function(){var _drawBitMapEraser=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee47(t){return _regeneratorRuntime().wrap(function _callee47$(_context49){while(1)switch(_context49.prev=_context49.next){case 0:_context49.next=2;return this._post({sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context49.stop();}},_callee47,this);}));function drawBitMapEraser(_x53){return _drawBitMapEraser.apply(this,arguments);}return drawBitMapEraser;}()},{key:"drawBitMapEraserFull",value:function(){var _drawBitMapEraserFull=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee48(t,e,n){var i,a,o,s,l,_iterator53,_step53,_step53$value,c,d,g;return _regeneratorRuntime().wrap(function _callee48$(_context50){while(1)switch(_context50.prev=_context50.next){case 0:i=e.rect,a=e.willUpdateNodes,o=e.willDeleteNodes,s=t.getWorkId(),l=[{type:ot.RemoveNode,removeIds:[s],viewId:this.viewId}];if(n&&l.push({type:ot.None,isLockSentEventCursor:n}),a!=null&&a.size||o!=null&&o.size){if(a!=null&&a.size){_iterator53=_createForOfIteratorHelper(a);try{for(_iterator53.s();!(_step53=_iterator53.n()).done;){_step53$value=_slicedToArray(_step53.value,2),c=_step53$value[0],d=_step53$value[1];l.push({type:ot.UpdateNode,dataType:Tt.Local,opt:d.opt,workId:c,updateNodeOpt:{useAnimation:!1}});}}catch(err){_iterator53.e(err);}finally{_iterator53.f();}}o!=null&&o.size&&l.push({type:ot.RemoveNode,removeIds:_toConsumableArray(o),viewId:this.thread.viewId});}g=[{isClearAll:!0,clearCanvas:St.Float,viewId:this.viewId}];i&&g.push({rect:i,isClear:!0,clearCanvas:St.Bg,viewId:this.viewId},{rect:i,drawCanvas:St.Bg,viewId:this.viewId});_context50.next=6;return this._post({sp:l,render:g,fullWorkerDrawCount:1/0});case 6:case"end":return _context50.stop();}},_callee48,this);}));function drawBitMapEraserFull(_x54,_x55,_x56){return _drawBitMapEraserFull.apply(this,arguments);}return drawBitMapEraserFull;}()},{key:"drawBitMapCombine",value:function(){var _drawBitMapCombine=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee49(t,e){var i,a,o,n,s,l;return _regeneratorRuntime().wrap(function _callee49$(_context51){while(1)switch(_context51.prev=_context51.next){case 0:n=(i=this.workShapes.get(t))==null?void 0:i.combineConsume();if(!n){_context51.next=6;break;}s={render:[],fullWorkerDrawCount:e};if(n!=null&&n.rect){l=Dt(n.rect);(a=s.render)==null||a.push({rect:l,isClear:!0,clearCanvas:St.Float,viewId:this.viewId}),(o=s.render)==null||o.push({rect:l,drawCanvas:St.Float,viewId:this.viewId});}_context51.next=6;return this._post(s);case 6:case"end":return _context51.stop();}},_callee49,this);}));function drawBitMapCombine(_x57,_x58){return _drawBitMapCombine.apply(this,arguments);}return drawBitMapCombine;}()},{key:"drawPencilCombine",value:function(){var _drawPencilCombine=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee50(t,e){var i,a,o,n,s,l;return _regeneratorRuntime().wrap(function _callee50$(_context52){while(1)switch(_context52.prev=_context52.next){case 0:n=(i=this.workShapes.get(t))==null?void 0:i.combineConsume();if(!n){_context52.next=6;break;}s={render:[],fullWorkerDrawCount:e};if(n!=null&&n.rect){l=Dt(n.rect);(a=s.render)==null||a.push({rect:l,isClear:!0,clearCanvas:St.Float,viewId:this.viewId}),(o=s.render)==null||o.push({rect:l,drawCanvas:St.Float,viewId:this.viewId});}_context52.next=6;return this._post(s);case 6:case"end":return _context52.stop();}},_callee50,this);}));function drawPencilCombine(_x59,_x60){return _drawPencilCombine.apply(this,arguments);}return drawPencilCombine;}()},{key:"drawSelector",value:function(){var _drawSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee51(t){var n,e;return _regeneratorRuntime().wrap(function _callee51$(_context53){while(1)switch(_context53.prev=_context53.next){case 0:e={render:[],sp:[t]};t.rect&&((n=e.render)==null||n.push({rect:Dt(t.rect),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:Dt(t.rect),drawCanvas:St.Bg,viewId:this.viewId}));_context53.next=4;return this._post(e);case 4:case"end":return _context53.stop();}},_callee51,this);}));function drawSelector(_x61){return _drawSelector.apply(this,arguments);}return drawSelector;}()},{key:"drawPencilEraser",value:function(){var _drawPencilEraser=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee52(t,e){var _this94=this;var i,a,n,_iterator54,_step54,o,s;return _regeneratorRuntime().wrap(function _callee52$(_context54){while(1)switch(_context54.prev=_context54.next){case 0:n=[];if((i=t.newWorkDatas)!=null&&i.size){_iterator54=_createForOfIteratorHelper(t.newWorkDatas.values());try{for(_iterator54.s();!(_step54=_iterator54.n()).done;){o=_step54.value;s=o.workId.toString();this.batchEraserWorks.add(s),n.push({type:ot.FullWork,workId:s,ops:Qt(o.op),opt:o.opt,toolsType:o.toolsType,updateNodeOpt:{useAnimation:!1}});}}catch(err){_iterator54.e(err);}finally{_iterator54.f();}delete t.newWorkDatas;}(a=t.removeIds)==null||a.forEach(function(o){_this94.batchEraserRemoveNodes.add(o);});e&&n.push({type:ot.None,isLockSentEventCursor:e});t.rect&&n.push(t);_context54.next=7;return this._post({sp:n,consumeCount:this.consumeCount});case 7:this.batchEraserCombine();case 8:case"end":return _context54.stop();}},_callee52,this);}));function drawPencilEraser(_x62,_x63){return _drawPencilEraser.apply(this,arguments);}return drawPencilEraser;}()},{key:"drawEraser",value:function(){var _drawEraser=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee53(t,e){var n,i;return _regeneratorRuntime().wrap(function _callee53$(_context55){while(1)switch(_context55.prev=_context55.next){case 0:n=[],i=[];e&&n.push({type:ot.None,isLockSentEventCursor:e});t.removeIds&&n.push(t);t.rect&&i.push({rect:t.rect,isClear:!0,clearCanvas:St.Bg,viewId:this.viewId},{rect:t.rect,drawCanvas:St.Bg,viewId:this.viewId});_context55.next=6;return this._post({sp:n,render:i,consumeCount:this.consumeCount});case 6:case"end":return _context55.stop();}},_callee53,this);}));function drawEraser(_x64,_x65){return _drawEraser.apply(this,arguments);}return drawEraser;}()},{key:"drawShape",value:function(){var _drawShape=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee54(t){return _regeneratorRuntime().wrap(function _callee54$(_context56){while(1)switch(_context56.prev=_context56.next){case 0:_context56.next=2;return this._post({fullWorkerDrawCount:this.drawCount,sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context56.stop();}},_callee54,this);}));function drawShape(_x66){return _drawShape.apply(this,arguments);}return drawShape;}()},{key:"drawPencil",value:function(){var _drawPencil=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee55(t){return _regeneratorRuntime().wrap(function _callee55$(_context57){while(1)switch(_context57.prev=_context57.next){case 0:_context57.next=2;return this._post({sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context57.stop();}},_callee55,this);}));function drawPencil(_x67){return _drawPencil.apply(this,arguments);}return drawPencil;}()},{key:"drawPencilFull",value:function(){var _drawPencilFull=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee56(t,e){var i,a,n;return _regeneratorRuntime().wrap(function _callee56$(_context58){while(1)switch(_context58.prev=_context58.next){case 0:n={fullWorkerDrawCount:1/0,render:[],sp:[t]};e&&((i=n.sp)==null||i.push({type:ot.None,isLockSentEventCursor:e}));(a=n.render)==null||a.push({isClearAll:!0,clearCanvas:St.Float,viewId:this.viewId},{rect:t.rect,isClear:!0,clearCanvas:St.Bg,viewId:this.viewId},{rect:t.rect,drawCanvas:St.Bg,viewId:this.viewId});_context58.next=5;return this._post(n);case 5:case"end":return _context58.stop();}},_callee56,this);}));function drawPencilFull(_x68,_x69){return _drawPencilFull.apply(this,arguments);}return drawPencilFull;}()},{key:"updateBatchEraserCombineNode",value:function updateBatchEraserCombineNode(t,e){var _this95=this;var n=[];var i;var _iterator55=_createForOfIteratorHelper(e.keys()),_step55;try{for(_iterator55.s();!(_step55=_iterator55.n()).done;){var a=_step55.value;this.fullLayer.getElementsByName(a).forEach(function(o){var s=o.getBoundingClientRect();i=Pt(i,{x:s.x-ae.SafeBorderPadding,y:s.y-ae.SafeBorderPadding,w:s.width+ae.SafeBorderPadding*2,h:s.height+ae.SafeBorderPadding*2}),o.remove();});}}catch(err){_iterator55.e(err);}finally{_iterator55.f();}return t.forEach(function(a){var o=_this95.vNodes.get(a);if(o)if(_this95.fullLayer.getElementsByName(a)[0])i=Pt(i,o.rect);else{var l=_this95.setFullWork(_objectSpread(_objectSpread({},o),{},{workId:a})),g=l&&l.consumeService({op:o.op,isFullWork:!0});g&&(o.rect=g,i=Pt(i,g));}}),i&&n.push({rect:i,isClear:!0,clearCanvas:St.Bg,viewId:this.viewId},{rect:i,drawCanvas:St.Bg,viewId:this.viewId}),n;}},{key:"runEffectSelectWork",value:function(){var _runEffectSelectWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee57(t){var e,_iterator56,_step56,n,i,a,o;return _regeneratorRuntime().wrap(function _callee57$(_context59){while(1)switch(_context59.prev=_context59.next){case 0:_iterator56=_createForOfIteratorHelper(this.effectSelectNodeData.values());_context59.prev=1;_iterator56.s();case 3:if((_step56=_iterator56.n()).done){_context59.next=23;break;}n=_step56.value;i=this.setFullWork(n);if(!i){_context59.next=21;break;}a=(e=i.getWorkId())==null?void 0:e.toString();if(!(i.toolsType===dt.Image)){_context59.next=13;break;}_context59.next=11;return i.consumeServiceAsync({isFullWork:!0,replaceId:a,worker:this});case 11:_context59.next=20;break;case 13:if(!(i.toolsType===dt.Text)){_context59.next=18;break;}_context59.next=16;return i.consumeServiceAsync({isFullWork:!0,replaceId:a});case 16:_context59.next=20;break;case 18:o=n.ops&&Pe(n.ops);i.consumeService({op:o,isFullWork:!0,replaceId:a}),n!=null&&n.updateNodeOpt&&i.updataOptService(n.updateNodeOpt);case 20:n.workId&&this.workShapes["delete"](n.workId.toString());case 21:_context59.next=3;break;case 23:_context59.next=28;break;case 25:_context59.prev=25;_context59.t0=_context59["catch"](1);_iterator56.e(_context59.t0);case 28:_context59.prev=28;_iterator56.f();return _context59.finish(28);case 31:_context59.next=33;return this.reRenderSelector(t);case 33:case"end":return _context59.stop();}},_callee57,this,[[1,25,28,31]]);}));function runEffectSelectWork(_x70){return _runEffectSelectWork.apply(this,arguments);}return runEffectSelectWork;}()},{key:"cursorHover",value:function(){var _cursorHover=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee58(t){var o,e,n,i,a,s,l;return _regeneratorRuntime().wrap(function _callee58$(_context60){while(1)switch(_context60.prev=_context60.next){case 0:e=t.opt,n=t.toolsType,i=t.point,a=this.setFullWork({workId:be,toolsType:n,opt:e});if(!(a&&i)){_context60.next=8;break;}s=a.cursorHover(i),l={render:[]};_context60.t0=s&&s.type===ot.CursorHover&&s.rect;if(!_context60.t0){_context60.next=8;break;}(o=l.render)==null||o.push({rect:Dt(s.rect),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:Dt(s.rect),drawCanvas:St.Bg,viewId:this.viewId});_context60.next=8;return this._post(l);case 8:case"end":return _context60.stop();}},_callee58,this);}));function cursorHover(_x71){return _cursorHover.apply(this,arguments);}return cursorHover;}()},{key:"cursorBlur",value:function(){var _cursorBlur=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee59(){var n,t,e;return _regeneratorRuntime().wrap(function _callee59$(_context61){while(1)switch(_context61.prev=_context61.next){case 0:t=this.getWorkShape(be);_context61.t0=t&&(n=t.selectIds)!=null&&n.length;if(!_context61.t0){_context61.next=10;break;}e=t.oldSelectRect;t.cursorBlur();this.clearWorkShapeNodeCache(be);_context61.t1=e;if(!_context61.t1){_context61.next=10;break;}_context61.next=10;return this._post({render:[{rect:Dt(e),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:Dt(e),drawCanvas:St.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 _context61.stop();}},_callee59,this);}));function cursorBlur(){return _cursorBlur.apply(this,arguments);}return cursorBlur;}()}]);}(Ri);var mm=/*#__PURE__*/function(){function mm(r){_classCallCheck(this,mm);tt(this,"viewId");tt(this,"vNodes");tt(this,"fullLayer");tt(this,"drawLayer");tt(this,"workShapes",/* @__PURE__ */new Map());tt(this,"selectorWorkShapes",/* @__PURE__ */new Map());tt(this,"thread");tt(this,"animationId");tt(this,"willRunEffectSelectorIds",/* @__PURE__ */new Set());tt(this,"runEffectId");tt(this,"noAnimationRect");tt(this,"syncUnitTime",re.syncOpt.interval);tt(this,"post");this.viewId=r.viewId,this.vNodes=r.vNodes,this.fullLayer=r.fullLayer,this.drawLayer=r.drawLayer,this.thread=r.thread,this.post=r.thread.post.bind(r.thread);}return _createClass(mm,[{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 _callee60(r){return _regeneratorRuntime().wrap(function _callee60$(_context62){while(1)switch(_context62.prev=_context62.next){case 0:this.activeWorkShape(r),this.runAnimation();case 1:case"end":return _context62.stop();}},_callee60,this);}));function consumeDraw(_x72){return _consumeDraw2.apply(this,arguments);}return consumeDraw;}()},{key:"consumeFull",value:function consumeFull(r){this.activeWorkShape(r),this.runAnimation();}},{key:"runSelectWork",value:function runSelectWork(r){this.activeSelectorShape(r);var t=r.workId,e=t==null?void 0:t.toString();e&&this.willRunEffectSelectorIds.add(e),this.runEffect();}},{key:"setNodeKey",value:function setNodeKey(r,t,e,n){return t.toolsType=e,t.node=Fr({workId:r,toolsType:e,toolsOpt:n,vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer},this),t;}},{key:"runReverseSelectWork",value:function runReverseSelectWork(r){var _this96=this;r.forEach(function(t){_this96.selectorWorkShapes.forEach(function(e,n){var i;if((i=e.selectIds)!=null&&i.length){var a=e.selectIds.indexOf(t);a>-1&&(e.selectIds.splice(a,1),_this96.willRunEffectSelectorIds.add(n));}});}),this.willRunEffectSelectorIds.size&&this.runEffect();}},{key:"removeWork",value:function(){var _removeWork3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee61(r){var t,e,n;return _regeneratorRuntime().wrap(function _callee61$(_context63){while(1)switch(_context63.prev=_context63.next){case 0:t=r.workId,e=t==null?void 0:t.toString();if(!e){_context63.next=10;break;}n=this.workShapes.get(e);if(!n){_context63.next=8;break;}this.workShapes["delete"](e);_context63.next=7;return this.removeNode(e,r,n==null?void 0:n.totalRect,!1);case 7:return _context63.abrupt("return");case 8:_context63.next=10;return this.removeNode(e,r);case 10:case"end":return _context63.stop();}},_callee61,this);}));function removeWork(_x73){return _removeWork3.apply(this,arguments);}return removeWork;}()},{key:"removeSelectWork",value:function removeSelectWork(r){var t=r.workId,e=t==null?void 0:t.toString();e&&(this.activeSelectorShape(r),this.willRunEffectSelectorIds.add(e)),this.runEffect();}},{key:"removeNode",value:function(){var _removeNode=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee62(r,t,e){var n,l,i,a,o,s,_args64=arguments;return _regeneratorRuntime().wrap(function _callee62$(_context64){while(1)switch(_context64.prev=_context64.next){case 0:n=_args64.length>3&&_args64[3]!==undefined?_args64[3]:!0;r.indexOf(Wt)>-1&&this.removeSelectWork(t);i=e;a=(l=this.vNodes.get(r))==null?void 0:l.rect;a&&(i=Pt(a,i));o=this.fullLayer&&vt.getRectFromLayer(this.fullLayer,r);i=Pt(i,o);s=this.drawLayer&&vt.getRectFromLayer(this.drawLayer,r);i=Pt(i,s);this.fullLayer.getElementsByName(r).forEach(function(g){g.remove();});this.drawLayer.getElementsByName(r).forEach(function(g){g.remove();});this.vNodes["delete"](r);_context64.t0=i;if(!_context64.t0){_context64.next=16;break;}_context64.next=16;return this.post({render:[{rect:Dt(i),isClear:!0,clearCanvas:n?St.Bg:St.ServiceFloat,workerType:n?void 0:Tt.Service,viewId:this.viewId},{rect:Dt(i),drawCanvas:n?St.Bg:St.ServiceFloat,workerType:n?void 0:Tt.Service,viewId:this.viewId}]});case 16:case"end":return _context64.stop();}},_callee62,this);}));function removeNode(_x74,_x75,_x76){return _removeNode.apply(this,arguments);}return removeNode;}()},{key:"activeWorkShape",value:function activeWorkShape(r){var y,P,S,v;var t=r.workId,e=r.opt,n=r.toolsType,i=r.type,a=r.updateNodeOpt,o=r.ops,s=r.op,l=r.useAnimation;if(!t)return;var g=t.toString(),c=(y=this.vNodes.get(g))==null?void 0:y.rect;if(!((P=this.workShapes)!=null&&P.has(g))){var _T43={toolsType:n,animationWorkData:s||[],animationIndex:0,type:i,updateNodeOpt:a,ops:o,useAnimation:_typeof(l)<"u"?l:_typeof(a==null?void 0:a.useAnimation)<"u"?a==null?void 0:a.useAnimation:!0,oldRect:c,isDiff:!1};n&&e&&(_T43=this.setNodeKey(g,_T43,n,e)),(S=this.workShapes)==null||S.set(g,_T43);}var d=(v=this.workShapes)==null?void 0:v.get(g);i&&(d.type=i),o&&(d.animationWorkData=Pe(o),d.ops=o),a&&(d.updateNodeOpt=a),s&&(d.isDiff=this.hasDiffData(d.animationWorkData||[],s,d.toolsType),d.animationWorkData=s),d.node&&d.node.getWorkId()!==g&&d.node.setWorkId(g),c&&(d.oldRect=c),n&&e&&(e.syncUnitTime&&(this.syncUnitTime=e.syncUnitTime),d.toolsType!==n&&n&&e&&this.setNodeKey(g,d,n,e),d.node&&d.node.setWorkOptions(e));}},{key:"hasDiffData",value:function hasDiffData(r,t,e){var n=r.length;if(t.length<n)return!0;switch(e){case dt.Pencil:{for(var i=0;i<n;i+=3)if(t[i]!==r[i]||t[i+1]!==r[i+1])return!0;break;}case dt.LaserPen:{for(var _i12=0;_i12<n;_i12+=2)if(t[_i12]!==r[_i12]||t[_i12+1]!==r[_i12+1])return!0;break;}}return!1;}},{key:"animationDraw",value:function(){var _animationDraw=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee63(){var _this97=this;var n,i,a,o,s,l,g,c,d,y,P,S,v,T,f,p,u,m,M,O,A,w,E,L,b,I,R,W,z,K,J,q,U,G,Z,rt,et,r,t,e,_iterator57,_step57,_loop6;return _regeneratorRuntime().wrap(function _callee63$(_context66){while(1)switch(_context66.prev=_context66.next){case 0:this.animationId=void 0;r=!1;t={render:[]},e=/* @__PURE__ */new Map();_iterator57=_createForOfIteratorHelper(this.workShapes.entries());_context66.prev=4;_loop6=/*#__PURE__*/_regeneratorRuntime().mark(function _loop6(){var _step57$value,it,X,ct,ut,_ct3,_ut2,_ct4,_ut3,B,F,_ct5,_ut4,_ct6,_ut5,_B,_F,Y,k,N,_k,_ct7,_ut6,_B2,_F2,_Y,_k2;return _regeneratorRuntime().wrap(function _loop6$(_context65){while(1)switch(_context65.prev=_context65.next){case 0:_step57$value=_slicedToArray(_step57.value,2),it=_step57$value[0],X=_step57$value[1];_context65.t0=X.toolsType;_context65.next=_context65.t0===dt.Image?4:_context65.t0===dt.Text?11:_context65.t0===dt.Arrow?19:_context65.t0===dt.Straight?19:_context65.t0===dt.Rectangle?19:_context65.t0===dt.Ellipse?19:_context65.t0===dt.Star?19:_context65.t0===dt.Polygon?19:_context65.t0===dt.SpeechBalloon?19:_context65.t0===dt.Pencil?22:_context65.t0===dt.BitMapEraser?37:50;break;case 4:ct=X.oldRect;ct&&((n=t.render)==null||n.push({rect:ct,isClear:!0,clearCanvas:St.Bg,viewId:_this97.viewId}),(i=t.render)==null||i.push({rect:ct,drawCanvas:St.Bg,viewId:_this97.viewId}));_context65.next=8;return(a=X.node)==null?void 0:a.consumeServiceAsync({isFullWork:!0,worker:_this97.thread});case 8:ut=_context65.sent;_this97.selectorWorkShapes.forEach(function(B,F){var Y;(Y=B.selectIds)!=null&&Y.includes(it)&&(_this97.willRunEffectSelectorIds.add(F),_this97.noAnimationRect=Pt(_this97.noAnimationRect,ct),_this97.noAnimationRect=Pt(_this97.noAnimationRect,ut),_this97.runEffect());}),_this97.workShapes["delete"](it),(o=t.render)==null||o.push({rect:ut,drawCanvas:St.Bg,viewId:_this97.viewId});return _context65.abrupt("break",50);case 11:if(!X.node){_context65.next=18;break;}_ct3=X.oldRect;_ct3&&((s=t.render)==null||s.push({rect:_ct3,isClear:!0,clearCanvas:St.Bg,viewId:_this97.viewId}),(l=t.render)==null||l.push({rect:_ct3,drawCanvas:St.Bg,viewId:_this97.viewId}));_context65.next=16;return X.node.consumeServiceAsync({isFullWork:!0,replaceId:it});case 16:_ut2=_context65.sent;_this97.selectorWorkShapes.forEach(function(B,F){var Y;(Y=B.selectIds)!=null&&Y.includes(it)&&(_this97.willRunEffectSelectorIds.add(F),_this97.noAnimationRect=Pt(_this97.noAnimationRect,_ct3),_this97.noAnimationRect=Pt(_this97.noAnimationRect,_ut2),_this97.runEffect());}),(g=X.node)==null||g.clearTmpPoints(),_this97.workShapes["delete"](it),(c=t.render)==null||c.push({rect:_ut2,drawCanvas:St.Bg,viewId:_this97.viewId});case 18:return _context65.abrupt("break",50);case 19:_ct4=!!X.ops;if((d=X.animationWorkData)!=null&&d.length){_ut3=X.oldRect,B=X.node.oldRect;_ut3&&((y=t.render)==null||y.push({rect:_ut3,isClear:!0,clearCanvas:St.Bg,viewId:_this97.viewId}),(P=t.render)==null||P.push({rect:_ut3,drawCanvas:St.Bg,viewId:_this97.viewId})),B&&((S=t.render)==null||S.push({rect:B,isClear:!0,clearCanvas:St.ServiceFloat,viewId:_this97.viewId}));F=(v=X.node)==null?void 0:v.consumeService({op:X.animationWorkData,isFullWork:_ct4});e.set(it,{workState:_ut3?X.ops?It.Done:It.Doing:It.Start,op:X.animationWorkData.filter(function(Y,k){if(k%3!==2)return!0;}).slice(-2)}),_ct4?(_this97.selectorWorkShapes.forEach(function(Y,k){var N;(N=Y.selectIds)!=null&&N.includes(it)&&(_this97.willRunEffectSelectorIds.add(k),_this97.noAnimationRect=Pt(_this97.noAnimationRect,_ut3),_this97.noAnimationRect=Pt(_this97.noAnimationRect,B),_this97.noAnimationRect=Pt(_this97.noAnimationRect,F),_this97.runEffect());}),(T=X.node)==null||T.clearTmpPoints(),_this97.workShapes["delete"](it),(f=t.render)==null||f.push({rect:F,drawCanvas:St.Bg,viewId:_this97.viewId})):(p=t.render)==null||p.push({rect:F,drawCanvas:St.ServiceFloat,workerType:_ct4?void 0:Tt.Service,viewId:_this97.viewId}),X.animationWorkData.length=0;}return _context65.abrupt("break",50);case 22:if(!(!X.useAnimation&&X.ops)){_context65.next=28;break;}_ct5=(u=X.node)==null?void 0:u.consumeService({op:X.animationWorkData||[],isFullWork:!0,replaceId:it});_ut4=(m=X.node)==null?void 0:m.updataOptService(X.updateNodeOpt);_ct5=Pt(_ct5,_ut4),(M=t.render)==null||M.push({isClear:!0,rect:Pt(X.oldRect,_ct5),clearCanvas:St.Bg,viewId:_this97.viewId}),(O=t.render)==null||O.push({rect:Pt(X.oldRect,_ct5),drawCanvas:St.Bg,viewId:_this97.viewId}),_this97.selectorWorkShapes.forEach(function(B,F){var Y;(Y=B.selectIds)!=null&&Y.includes(it)&&(_this97.willRunEffectSelectorIds.add(F),_this97.noAnimationRect=Pt(_this97.noAnimationRect,_ct5),_this97.runEffect());}),(A=X.node)==null||A.clearTmpPoints(),_this97.workShapes["delete"](it);_context65.next=36;break;case 28:if(!X.useAnimation){_context65.next=36;break;}if(!X.isDel){_context65.next=32;break;}(w=X.node)==null||w.clearTmpPoints(),_this97.workShapes["delete"](it);return _context65.abrupt("break",50);case 32:_ct6=3,_ut5=_this97.computNextAnimationIndex(X,_ct6),_B=X.isDiff?0:Math.max(0,(X.animationIndex||0)-_ct6),_F=(X.animationWorkData||[]).slice(0,_ut5),Y=(L=(E=X.node)==null?void 0:E.getWorkId())==null?void 0:L.toString();if((X.animationIndex||0)<_ut5||X.isDiff){k=(b=X.node)==null?void 0:b.consumeService({op:_F,isFullWork:!1,replaceId:Y});if((I=t.render)==null||I.push({isClear:!0,rect:k,clearCanvas:St.ServiceFloat,viewId:_this97.viewId}),(R=t.render)==null||R.push({rect:k,drawCanvas:St.ServiceFloat,viewId:_this97.viewId}),X.animationIndex=_ut5,X.isDiff&&(X.isDiff=!1),_F.length){N=_F.filter(function($,x){if(x%_ct6!==_ct6-1)return!0;}).slice(-2);e.set(it,{workState:_B===0?It.Start:_ut5===((W=X.animationWorkData)==null?void 0:W.length)?It.Done:It.Doing,op:N});}}else if(X.ops){_k=(z=X.node)==null?void 0:z.consumeService({op:X.animationWorkData||[],isFullWork:!0,replaceId:Y});X.isDel=!0,(K=t.render)==null||K.push({isClear:!0,rect:_k,clearCanvas:St.ServiceFloat,viewId:_this97.viewId},{rect:_k,drawCanvas:St.ServiceFloat,viewId:_this97.viewId},{isClear:!0,rect:_k,clearCanvas:St.Bg,viewId:_this97.viewId},{rect:_k,drawCanvas:St.Bg,viewId:_this97.viewId}),e.set(it,{workState:It.Done,op:_F.filter(function(N,$){if($%_ct6!==_ct6-1)return!0;}).slice(-2)});}r=!0;return _context65.abrupt("break",50);case 36:return _context65.abrupt("break",50);case 37:if(!X.isDel){_context65.next=40;break;}(J=X.node)==null||J.clearTmpPoints(),_this97.workShapes["delete"](it);return _context65.abrupt("break",50);case 40:if(!(X.ops&&(q=X.animationWorkData)!=null&&q.length)){_context65.next=44;break;}_ct7=X.animationWorkData.slice(-3,-1);e.set(it,{workState:It.Done,op:_ct7}),X.isDel=!0;return _context65.abrupt("break",50);case 44:if(!X.useAnimation){_context65.next=49;break;}_ut6=_this97.computNextAnimationIndex(X,3),_B2=X.isDiff?0:Math.max(0,(X.animationIndex||0)-3),_F2=(X.animationWorkData||[]).slice(0,_ut6);if((X.animationIndex||0)<_ut6||X.isDiff){_Y=(U=X.node)==null?void 0:U.consumeService({op:_F2,isFullWork:!1,replaceId:it});if((G=t.render)==null||G.push({isClear:!0,rect:Pt(X.oldRect,_Y),clearCanvas:St.ServiceFloat,viewId:_this97.viewId}),(Z=t.render)==null||Z.push({rect:Pt(X.oldRect,_Y),drawCanvas:St.ServiceFloat,viewId:_this97.viewId}),X.animationIndex=_ut6,X.isDiff&&(X.isDiff=!1),_F2.length){_k2=_F2.filter(function(N,$){if($%3!==2)return!0;}).slice(-2);e.set(it,{workState:_B2===0?It.Start:_ut6===((rt=X.animationWorkData)==null?void 0:rt.length)?It.Done:It.Doing,op:_k2});}}r=!0;return _context65.abrupt("break",50);case 49:return _context65.abrupt("break",50);case 50:case"end":return _context65.stop();}},_loop6);});_iterator57.s();case 7:if((_step57=_iterator57.n()).done){_context66.next=11;break;}return _context66.delegateYield(_loop6(),"t0",9);case 9:_context66.next=7;break;case 11:_context66.next=16;break;case 13:_context66.prev=13;_context66.t1=_context66["catch"](4);_iterator57.e(_context66.t1);case 16:_context66.prev=16;_iterator57.f();return _context66.finish(16);case 19:r&&this.runAnimation();e.size&&(t.sp=[],e.forEach(function(it,X){var ct;(ct=t.sp)==null||ct.push({type:ot.Cursor,uid:X.split(De)[0],op:it.op,workState:it.workState,viewId:_this97.viewId});}));_context66.t2=(et=t.render)!=null&&et.length;if(!_context66.t2){_context66.next=25;break;}_context66.next=25;return this.post(t);case 25:case"end":return _context66.stop();}},_callee63,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(r,t){var e=Math.floor((r.animationWorkData||[]).slice(r.animationIndex).length*48/t/this.syncUnitTime)*t;return Math.min((r.animationIndex||0)+(e||t),(r.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 _callee64(){var _this99=this;var r;return _regeneratorRuntime().wrap(function _callee64$(_context67){while(1)switch(_context67.prev=_context67.next){case 0:this.runEffectId=void 0;r=this.noAnimationRect;this.willRunEffectSelectorIds.forEach(function(t){var i,a;var e=_this99.selectorWorkShapes.get(t),n=e&&e.selectIds&&((i=e.node)==null?void 0:i.selectServiceNode(t,e,!0));r=Pt(r,n),(a=e==null?void 0:e.selectIds)!=null&&a.length||_this99.selectorWorkShapes["delete"](t);});_context67.t0=r;if(!_context67.t0){_context67.next=7;break;}_context67.next=7;return this.post({render:[{rect:Dt(r),isClear:!0,clearCanvas:St.Bg,viewId:this.viewId},{rect:Dt(r),drawCanvas:St.Bg,viewId:this.viewId}]});case 7:this.willRunEffectSelectorIds.clear();this.noAnimationRect=void 0;case 9:case"end":return _context67.stop();}},_callee64,this);}));function effectRunSelector(){return _effectRunSelector.apply(this,arguments);}return effectRunSelector;}()},{key:"activeSelectorShape",value:function activeSelectorShape(r){var g,c,d;var t=r.workId,e=r.opt,n=r.toolsType,i=r.type,a=r.selectIds,o=r.imageBitmap;if(!t)return;var s=t.toString();if(!((g=this.selectorWorkShapes)!=null&&g.has(s))){var y={toolsType:n,selectIds:a,type:i,opt:e,imageBitmap:o};n&&e&&(y=this.setNodeKey(s,y,n,e)),(c=this.selectorWorkShapes)==null||c.set(s,y);}var l=(d=this.selectorWorkShapes)==null?void 0:d.get(s);i&&(l.type=i),l.node&&l.node.getWorkId()!==s&&l.node.setWorkId(s),o&&(l.imageBitmap=o),l.selectIds=a||[];}}]);}();var vm=/*#__PURE__*/function(_Ri2){function vm(t){var _this100;_classCallCheck(this,vm);_this100=_callSuper(this,vm,[t]);tt(_this100,"drawWorkActiveId");return _this100;}_inherits(vm,_Ri2);return _createClass(vm,[{key:"runFullWork",value:function(){var _runFullWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee65(t){var i,e,n,a,o,s;return _regeneratorRuntime().wrap(function _callee65$(_context68){while(1)switch(_context68.prev=_context68.next){case 0:e=this.setFullWork(t),n=t.ops&&Pe(t.ops);if(!e){_context68.next=18;break;}s=(i=e.getWorkId())==null?void 0:i.toString();if(!(e.toolsType===dt.Image)){_context68.next=9;break;}_context68.next=6;return e.consumeServiceAsync({isFullWork:!0,worker:this.thread});case 6:a=_context68.sent;_context68.next=16;break;case 9:if(!(e.toolsType===dt.Text)){_context68.next=15;break;}_context68.next=12;return e.consumeServiceAsync({isFullWork:!0,replaceId:s,isDrawLabel:!0});case 12:a=_context68.sent;_context68.next=16;break;case 15:a=e.consumeService({op:n,isFullWork:!0,replaceId:s}),o=(t==null?void 0:t.updateNodeOpt)&&e.updataOptService(t.updateNodeOpt);case 16:t.workId&&this.workShapes["delete"](t.workId.toString());return _context68.abrupt("return",Pt(a,o));case 18:case"end":return _context68.stop();}},_callee65,this);}));function runFullWork(_x77){return _runFullWork.apply(this,arguments);}return runFullWork;}()},{key:"runSelectWork",value:function runSelectWork(t){var n;var e=this.setFullWork(t);e&&(n=t.selectIds)!=null&&n.length&&t.workId&&e.selectServiceNode(t.workId.toString(),{selectIds:t.selectIds},!1);}},{key:"workShapesDone",value:function workShapesDone(){var _iterator58=_createForOfIteratorHelper(this.workShapes.keys()),_step58;try{for(_iterator58.s();!(_step58=_iterator58.n()).done;){var t=_step58.value;this.clearWorkShapeNodeCache(t);}}catch(err){_iterator58.e(err);}finally{_iterator58.f();}this.fullLayer.removeAllChildren();}},{key:"canUseSubWorker",value:function canUseSubWorker(t){var e=this.thread.getPriorityDraw();return e||!e&&t!==dt.Pencil;}},{key:"consumeDraw",value:function(){var _consumeDraw3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee66(t){var e,n,i,a,o,s,l;return _regeneratorRuntime().wrap(function _callee66$(_context69){while(1)switch(_context69.prev=_context69.next){case 0:e=t.workId,n=t.fullWorkerDrawCount,i=t.postCount,a=e==null?void 0:e.toString(),o=a&&this.workShapes.get(a);if(o){_context69.next=3;break;}return _context69.abrupt("return");case 3:_context69.t0=this.drawWorkActiveId&&this.drawWorkActiveId!==a;if(!_context69.t0){_context69.next=8;break;}_context69.next=7;return this.consumeDrawAll({workId:this.drawWorkActiveId,viewId:this.viewId,msgType:ot.DrawWork,dataType:Tt.Local});case 7:this.drawWorkActiveId=void 0;case 8:!this.drawWorkActiveId&&a!==Wt&&(this.drawWorkActiveId=a);s=o.toolsType;Vt(i)&&(this.consumeCount=i);l=o.consume({data:t,drawCount:this.drawCount,isFullWork:!0,isSubWorker:!0,removeDrawCount:n});_context69.t1=s;_context69.next=_context69.t1===dt.Arrow?15:_context69.t1===dt.Straight?15:_context69.t1===dt.Ellipse?15:_context69.t1===dt.Rectangle?15:_context69.t1===dt.Star?15:_context69.t1===dt.Polygon?15:_context69.t1===dt.SpeechBalloon?15:_context69.t1===dt.Pencil?21:_context69.t1===dt.BitMapEraser?21:27;break;case 15:_context69.t2=l;if(!_context69.t2){_context69.next=20;break;}this.drawCount++;_context69.next=20;return this.drawShape(l);case 20:return _context69.abrupt("break",27);case 21:_context69.t3=l;if(!_context69.t3){_context69.next=26;break;}this.drawCount++;_context69.next=26;return this.drawPencil(l,e==null?void 0:e.toString());case 26:return _context69.abrupt("break",27);case 27:case"end":return _context69.stop();}},_callee66,this);}));function consumeDraw(_x78){return _consumeDraw3.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee67(t){var e,n,i;return _regeneratorRuntime().wrap(function _callee67$(_context70){while(1)switch(_context70.prev=_context70.next){case 0:e=t.workId;if(!e){_context70.next=12;break;}n=e.toString();this.drawWorkActiveId===n&&(this.drawWorkActiveId=void 0);i=this.workShapes.get(n);if(i){_context70.next=7;break;}return _context70.abrupt("return");case 7:_context70.t0=i.toolsType;_context70.next=_context70.t0===dt.Arrow?10:_context70.t0===dt.Straight?10:_context70.t0===dt.Ellipse?10:_context70.t0===dt.Pencil?10:_context70.t0===dt.Rectangle?10:_context70.t0===dt.Star?10:_context70.t0===dt.Polygon?10:_context70.t0===dt.SpeechBalloon?10:_context70.t0===dt.BitMapEraser?10:12;break;case 10:this.drawCount=0,this.fullLayer.removeAllChildren(),this.clearWorkShapeNodeCache(n);return _context70.abrupt("break",12);case 12:case"end":return _context70.stop();}},_callee67,this);}));function consumeDrawAll(_x79){return _consumeDrawAll2.apply(this,arguments);}return consumeDrawAll;}()},{key:"removeWork",value:function(){var _removeWork4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee68(t){var e,n,i,a;return _regeneratorRuntime().wrap(function _callee68$(_context71){while(1)switch(_context71.prev=_context71.next){case 0:e=t.workId,n=e==null?void 0:e.toString();if(!n){_context71.next=8;break;}i=this.removeNode(n);if(!i){_context71.next=8;break;}a=[];a.push({rect:Dt(i),clearCanvas:St.Float,isClear:!0,viewId:this.viewId},{rect:Dt(i),drawCanvas:St.Float,viewId:this.viewId});_context71.next=8;return this._post({render:a});case 8:case"end":return _context71.stop();}},_callee68,this);}));function removeWork(_x80){return _removeWork4.apply(this,arguments);}return removeWork;}()},{key:"removeNode",value:function removeNode(t){var e=this.workShapes.has(t);var n;return e&&(this.fullLayer.getElementsByName(t).forEach(function(i){var a=i.getBoundingClientRect();n=Pt(n,{x:a.x-vt.SafeBorderPadding,y:a.y-vt.SafeBorderPadding,w:a.width+vt.SafeBorderPadding*2,h:a.height+vt.SafeBorderPadding*2}),i.remove();}),n&&this.clearWorkShapeNodeCache(t)),n;}},{key:"drawPencil",value:function(){var _drawPencil2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee69(t,e){return _regeneratorRuntime().wrap(function _callee69$(_context72){while(1)switch(_context72.prev=_context72.next){case 0:_context72.next=2;return this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:t==null?void 0:t.rect,workId:e,drawCanvas:St.Float,viewId:this.viewId}],sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context72.stop();}},_callee69,this);}));function drawPencil(_x81,_x82){return _drawPencil2.apply(this,arguments);}return drawPencil;}()},{key:"drawShape",value:function(){var _drawShape2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee70(t){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)&&Dt(t.rect),isClear:!0,clearCanvas:St.Float,viewId:this.viewId},{rect:(t==null?void 0:t.rect)&&Dt(t.rect),drawCanvas:St.Float,viewId:this.viewId}]});case 2:case"end":return _context73.stop();}},_callee70,this);}));function drawShape(_x83){return _drawShape2.apply(this,arguments);}return drawShape;}()}]);}(Ri);var ym=/*#__PURE__*/function(){function ym(r){_classCallCheck(this,ym);tt(this,"viewId");tt(this,"vNodes");tt(this,"topLayer");tt(this,"thread");tt(this,"post");tt(this,"serviceWorkShapes",/* @__PURE__ */new Map());tt(this,"localWorkShapes",/* @__PURE__ */new Map());tt(this,"tmpOpt");tt(this,"syncUnitTime",re.syncOpt.interval);tt(this,"animationId");this.viewId=r.viewId,this.vNodes=r.vNodes,this.topLayer=r.topLayer,this.thread=r.thread,this.post=r.thread.post.bind(r.thread);}return _createClass(ym,[{key:"canUseTopLayer",value:function canUseTopLayer(r){return r===dt.LaserPen;}},{key:"getWorkShape",value:function getWorkShape(r){return this.localWorkShapes.get(r);}},{key:"createWorkShape",value:function createWorkShape(r,t){if(r&&this.tmpOpt){var _e15={toolsType:this.tmpOpt.toolsType,toolsOpt:t||this.tmpOpt.toolsOpt},n=this.createWorkShapeNode(_objectSpread(_objectSpread({},_e15),{},{workId:r}));return n&&this.localWorkShapes.set(r,{node:n,toolsType:n.toolsType,workState:It.Start}),n;}}},{key:"setWorkOptions",value:function setWorkOptions(r,t){var n;var e=(n=this.localWorkShapes.get(r))==null?void 0:n.node;e||this.createWorkShape(r,t),e==null||e.setWorkOptions(t);}},{key:"createWorkShapeNode",value:function createWorkShapeNode(r){var t=r.toolsType;if(t===dt.LaserPen)return Fr(_objectSpread(_objectSpread({},r),{},{vNodes:this.vNodes,fullLayer:this.topLayer,drawLayer:this.topLayer}));}},{key:"clearAllWorkShapesCache",value:function clearAllWorkShapesCache(){this.localWorkShapes.forEach(function(r){var t;return(t=r.node)==null?void 0:t.clearTmpPoints();}),this.localWorkShapes.clear();}},{key:"setToolsOpt",value:function setToolsOpt(r){var t;this.tmpOpt=r,(t=r.toolsOpt)!=null&&t.syncUnitTime&&(this.syncUnitTime=r.toolsOpt.syncUnitTime);}},{key:"getToolsOpt",value:function getToolsOpt(){return this.tmpOpt;}},{key:"consumeDraw",value:function consumeDraw(r){var t=r.workId,e=r.dataType;if(e===Tt.Service)this.activeServiceWorkShape(r);else{var n=t==null?void 0:t.toString(),i=n&&this.localWorkShapes.get(n);if(!i)return;var a=i.node.consume({data:r,isFullWork:!1,isSubWorker:!0});a.rect&&(i.totalRect=Pt(a.rect,i.totalRect),i.result=a,i.workState=It.Doing,n&&this.localWorkShapes.set(n,i));}this.runAnimation();}},{key:"consumeDrawAll",value:function consumeDrawAll(r){var t=r.workId,e=r.dataType;if(e===Tt.Service)this.activeServiceWorkShape(r);else{var n=t==null?void 0:t.toString(),i=n&&this.localWorkShapes.get(n);if(!i)return;var a=i.node.consumeAll({data:r});i.totalRect=Pt(a.rect,i.totalRect),i.result=a,i.workState=It.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(r,t,e,n){return t.toolsType=e,t.node=this.createWorkShapeNode({workId:r,toolsType:e,toolsOpt:n}),t;}},{key:"activeServiceWorkShape",value:function activeServiceWorkShape(r){var d,y;var t=r.workId,e=r.opt,n=r.toolsType,i=r.type,a=r.updateNodeOpt,o=r.ops,s=r.op;if(!t)return;var l=t.toString(),g=(d=this.vNodes.get(l))==null?void 0:d.rect;if(!((y=this.serviceWorkShapes)!=null&&y.has(l))){var P={toolsType:n,animationWorkData:s||[],animationIndex:0,type:i,updateNodeOpt:a,ops:o,oldRect:g};n&&e&&(P=this.setNodeKey(l,P,n,e)),this.serviceWorkShapes.set(l,P);}var c=this.serviceWorkShapes.get(l);i&&(c.type=i),o&&(c.animationWorkData=Pe(o),c.ops=o),a&&(c.updateNodeOpt=a),s&&(c.animationWorkData=s),c.node&&c.node.getWorkId()!==l&&c.node.setWorkId(l),g&&(c.oldRect=g),n&&e&&(c.toolsType!==n&&n&&e&&this.setNodeKey(l,c,n,e),c.node&&c.node.setWorkOptions(e));}},{key:"computNextAnimationIndex",value:function computNextAnimationIndex(r,t){var e=Math.floor((r.animationWorkData||[]).slice(r.animationIndex).length*32/t/this.syncUnitTime)*t;return Math.min((r.animationIndex||0)+(e||t),(r.animationWorkData||[]).length);}},{key:"animationDraw",value:function(){var _animationDraw2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee71(){var _this101=this;var a,o,s,l,r,t,e,n,i,_iterator59,_step59,_step59$value,g,c,y,P,S,v,_iterator60,_step60,_step60$value,_g11,_c7,d,_y14,_P5,_S4,_v11;return _regeneratorRuntime().wrap(function _callee71$(_context74){while(1)switch(_context74.prev=_context74.next){case 0:this.animationId=void 0;r=!1;t=/* @__PURE__ */new Map(),e=[],n=[],i=[];_iterator59=_createForOfIteratorHelper(this.serviceWorkShapes.entries());_context74.prev=4;_iterator59.s();case 6:if((_step59=_iterator59.n()).done){_context74.next=20;break;}_step59$value=_slicedToArray(_step59.value,2),g=_step59$value[0],c=_step59$value[1];_context74.t0=c.toolsType;_context74.next=_context74.t0===dt.LaserPen?11:18;break;case 11:y=this.computNextAnimationIndex(c,8),P=Math.max(0,c.animationIndex||0),S=(c.animationWorkData||[]).slice(P,y);if((c.animationIndex||0)<y){v=(a=c.node)==null?void 0:a.consumeService({op:S,isFullWork:!1});c.totalRect=Pt(c.totalRect,v),c.animationIndex=y,S.length&&t.set(g,{workState:P===0?It.Start:y===((o=c.animationWorkData)==null?void 0:o.length)?It.Done:It.Doing,op:S.slice(-2)});}if(!(n.push({isClear:!0,rect:c.totalRect,clearCanvas:St.TopFloat,viewId:this.viewId}),e.push({rect:c.totalRect,drawCanvas:St.TopFloat,viewId:this.viewId}),c.isDel)){_context74.next=16;break;}(s=c.node)==null||s.clearTmpPoints(),this.serviceWorkShapes["delete"](g);return _context74.abrupt("break",18);case 16:c.ops&&c.animationIndex===((l=c.animationWorkData)==null?void 0:l.length)&&!c.isDel&&(this.topLayer.getElementsByName(g.toString())[0]||(c.isDel=!0,this.serviceWorkShapes.set(g,c))),r=!0;return _context74.abrupt("break",18);case 18:_context74.next=6;break;case 20:_context74.next=25;break;case 22:_context74.prev=22;_context74.t1=_context74["catch"](4);_iterator59.e(_context74.t1);case 25:_context74.prev=25;_iterator59.f();return _context74.finish(25);case 28:_iterator60=_createForOfIteratorHelper(this.localWorkShapes.entries());_context74.prev=29;_iterator60.s();case 31:if((_step60=_iterator60.n()).done){_context74.next=44;break;}_step60$value=_slicedToArray(_step60.value,2),_g11=_step60$value[0],_c7=_step60$value[1];d=_c7.result,_y14=_c7.toolsType,_P5=_c7.totalRect,_S4=_c7.isDel,_v11=_c7.workState;_context74.t2=_y14;_context74.next=_context74.t2===dt.LaserPen?37:42;break;case 37:if(!(_P5&&(n.push({isClear:!0,rect:_P5,clearCanvas:St.TopFloat,viewId:this.viewId}),e.push({rect:_P5,drawCanvas:St.TopFloat,viewId:this.viewId})),_S4)){_context74.next=40;break;}_c7.node.clearTmpPoints(),this.localWorkShapes["delete"](_g11),i.push({removeIds:[_g11.toString()],viewId:this.viewId,type:ot.RemoveNode});return _context74.abrupt("break",42);case 40:d&&((d.op||d.ops)&&i.push(d),_c7.result=void 0),!this.topLayer.getElementsByName(_g11.toString())[0]&&_v11===It.Done&&(_c7.isDel=!0,this.localWorkShapes.set(_g11,_c7)),r=!0;return _context74.abrupt("break",42);case 42:_context74.next=31;break;case 44:_context74.next=49;break;case 46:_context74.prev=46;_context74.t3=_context74["catch"](29);_iterator60.e(_context74.t3);case 49:_context74.prev=49;_iterator60.f();return _context74.finish(49);case 52:r&&this.runAnimation(),t.size&&t.forEach(function(g,c){i.push({type:ot.Cursor,uid:c.split(De)[0],op:g.op,workState:g.workState,viewId:_this101.viewId});}),(e.length||n.length||i.length)&&this.post({render:[].concat(n,e),sp:i});case 53:case"end":return _context74.stop();}},_callee71,this,[[4,22,25,28],[29,46,49,52]]);}));function animationDraw(){return _animationDraw2.apply(this,arguments);}return animationDraw;}()},{key:"runAnimation",value:function runAnimation(){var _this102=this;this.animationId||(this.animationId=setTimeout(function(){_this102.animationId=void 0,_this102.animationDraw();},16));}}]);}();var qe=/* @__PURE__ */function(h){return h.Full="full",h.Sub="sub",h;}(qe||{});var Sm=/*#__PURE__*/function(){function Sm(r,t){_classCallCheck(this,Sm);tt(this,"_self");tt(this,"version",fi);tt(this,"type");tt(this,"hasPriorityDraw",!0);tt(this,"workThreadMap",/* @__PURE__ */new Map());this._self=r,this.type=t,this.register();}return _createClass(Sm,[{key:"init",value:function init(r){var t=r.viewId,e=r.dpr,n=r.offscreenCanvasOpt,i=r.layerOpt,a=r.isSafari;if(!e||!n||!i)return;var o;this.type==="full"&&(o=new xm(t,{dpr:e,offscreenCanvasOpt:n,layerOpt:i},this.post.bind(this))),this.type==="sub"&&(o=new Di(t,{dpr:e,offscreenCanvasOpt:n,layerOpt:i},this.post.bind(this)),o.setHasPriorityDraw(this.hasPriorityDraw)),o&&a&&o.setIsSafari(a),o&&r.cameraOpt&&o.setCameraOpt(r.cameraOpt),o&&this.workThreadMap.set(t,o);}},{key:"register",value:function register(){var _this103=this;onmessage=/*#__PURE__*/function(){var _ref170=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee72(r){var t,_iteratorAbruptCompletion,_didIteratorError,_iteratorError,_iterator,_step,_e16,n,i,a,o,_iterator61,_step61,l,_iterator62,_step62,_step62$value,_l7,g,c,_iterator63,_step63,_l8,s;return _regeneratorRuntime().wrap(function _callee72$(_context75){while(1)switch(_context75.prev=_context75.next){case 0:t=r.data;if(!t){_context75.next=56;break;}_iteratorAbruptCompletion=false;_didIteratorError=false;_context75.prev=4;_iterator=_asyncIterator(t.values());case 6:_context75.next=8;return _iterator.next();case 8:if(!(_iteratorAbruptCompletion=!(_step=_context75.sent).done)){_context75.next=40;break;}_e16=_step.value;n=_e16.msgType,i=_e16.viewId,a=_e16.tasksqueue,o=_e16.mainTasksqueueCount;if(!(n===ot.Console)){_context75.next=14;break;}console.log(_this103);return _context75.abrupt("continue",37);case 14:if(!(n===ot.Init)){_context75.next=17;break;}_this103.init(_e16);return _context75.abrupt("continue",37);case 17:if(!(_this103.type==="sub"&&(n===ot.PriorityWorker||n===ot.PriorityMainThreadWorker))){_context75.next=22;break;}n===ot.PriorityWorker?_this103.hasPriorityDraw=!0:n===ot.PriorityMainThreadWorker&&(_this103.hasPriorityDraw=!1);_iterator61=_createForOfIteratorHelper(_this103.workThreadMap.values());try{for(_iterator61.s();!(_step61=_iterator61.n()).done;){l=_step61.value;l.setHasPriorityDraw(_this103.hasPriorityDraw);}}catch(err){_iterator61.e(err);}finally{_iterator61.f();}return _context75.abrupt("continue",37);case 22:if(!(n===ot.TasksQueue&&a!=null&&a.size)){_context75.next=27;break;}_iterator62=_createForOfIteratorHelper(_this103.workThreadMap.entries());try{for(_iterator62.s();!(_step62=_iterator62.n()).done;){_step62$value=_slicedToArray(_step62.value,2),_l7=_step62$value[0],g=_step62$value[1];c=a.get(_l7);c&&g.on(c);}}catch(err){_iterator62.e(err);}finally{_iterator62.f();}_this103.type==="full"&&Vt(o)&&_this103.post({workerTasksqueueCount:o});return _context75.abrupt("continue",37);case 27:if(!(i===Fi)){_context75.next=31;break;}_iterator63=_createForOfIteratorHelper(_this103.workThreadMap.values());try{for(_iterator63.s();!(_step63=_iterator63.n()).done;){_l8=_step63.value;_l8.on(_e16),n===ot.Destroy&&_this103.workThreadMap["delete"](i);}}catch(err){_iterator63.e(err);}finally{_iterator63.f();}return _context75.abrupt("continue",37);case 31:s=_this103.workThreadMap.get(i);_context75.t0=s;if(!_context75.t0){_context75.next=37;break;}_context75.next=36;return s.on(_e16);case 36:n===ot.Destroy&&_this103.workThreadMap["delete"](i);case 37:_iteratorAbruptCompletion=false;_context75.next=6;break;case 40:_context75.next=46;break;case 42:_context75.prev=42;_context75.t1=_context75["catch"](4);_didIteratorError=true;_iteratorError=_context75.t1;case 46:_context75.prev=46;_context75.prev=47;if(!(_iteratorAbruptCompletion&&_iterator["return"]!=null)){_context75.next=51;break;}_context75.next=51;return _iterator["return"]();case 51:_context75.prev=51;if(!_didIteratorError){_context75.next=54;break;}throw _iteratorError;case 54:return _context75.finish(51);case 55:return _context75.finish(46);case 56:case"end":return _context75.stop();}},_callee72,null,[[4,42,46,56],[47,,51,55]]);}));return function onmessage(_x84){return _ref170.apply(this,arguments);};}();}},{key:"post",value:function post(r,t){t?this._self.postMessage(r,t):this._self.postMessage(r);}}]);}();var xm=/*#__PURE__*/function(_Ai){function xm(t,e,n){var _this104;_classCallCheck(this,xm);_this104=_callSuper(this,xm,[t,e,"full"/* Full */]);tt(_this104,"type","full");tt(_this104,"serviceDrawLayer");tt(_this104,"localDrawLayer");tt(_this104,"snapshotFullLayer");tt(_this104,"methodBuilder");tt(_this104,"localWork");tt(_this104,"serviceWork");tt(_this104,"_post");tt(_this104,"taskUpdateCameraId");tt(_this104,"debounceUpdateCameraId");tt(_this104,"debounceUpdateCache",/* @__PURE__ */new Set());_this104._post=n;var i=re.bufferSize.sub;_this104.serviceDrawLayer=_this104.createLayer("serviceDrawLayer",_this104.scene,_objectSpread(_objectSpread({},e.layerOpt),{},{bufferSize:i,contextType:"2d"})),_this104.localDrawLayer=_this104.createLayer("localDrawLayer",_this104.scene,_objectSpread(_objectSpread({},e.layerOpt),{},{bufferSize:i,contextType:"2d"}));var a={thread:_this104,viewId:_this104.viewId,vNodes:_this104.vNodes,fullLayer:_this104.fullLayer};_this104.localWork=new gm(_objectSpread(_objectSpread({},a),{},{drawLayer:_this104.localDrawLayer})),_this104.serviceWork=new mm(_objectSpread(_objectSpread({},a),{},{drawLayer:_this104.serviceDrawLayer})),_this104.methodBuilder=new Xi([wt.CopyNode,wt.SetColorNode,wt.DeleteNode,wt.RotateNode,wt.ScaleNode,wt.TranslateNode,wt.ZIndexNode,wt.SetFontStyle,wt.SetPoint,wt.SetLock,wt.SetShapeOpt]).registerForWorker(_this104),_this104.vNodes.init(_this104.fullLayer);return _this104;}_inherits(xm,_Ai);return _createClass(xm,[{key:"combinePost",value:function(){var _combinePost=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee73(){var _this105=this;var a,o,_this$combinePostData,t,e,n,s,_iterator64,_step64,l,g,i;return _regeneratorRuntime().wrap(function _callee73$(_context76){while(1)switch(_context76.prev=_context76.next){case 0:_this$combinePostData=this.combinePostData(),t=_this$combinePostData.render,e=_objectWithoutProperties(_this$combinePostData,_excluded3);if(!(t!=null&&t.length)){_context76.next=28;break;}s=[];_iterator64=_createForOfIteratorHelper(t);_context76.prev=4;_iterator64.s();case 6:if((_step64=_iterator64.n()).done){_context76.next=19;break;}l=_step64.value;if(!l.rect){_context76.next=17;break;}if(!(l.rect=this.safariFixRect(Jt(l.rect),this.dpr),!l.rect)){_context76.next=11;break;}return _context76.abrupt("continue",17);case 11:if(!(l.drawCanvas&&l.rect&&l.rect.w>0&&l.rect.h>0)){_context76.next=16;break;}_context76.next=14;return this.getRectImageBitmap(l);case 14:g=_context76.sent;l.imageBitmap=g,n||(n=[]),n.push(g);case 16:s.push(l);case 17:_context76.next=6;break;case 19:_context76.next=24;break;case 21:_context76.prev=21;_context76.t0=_context76["catch"](4);_iterator64.e(_context76.t0);case 24:_context76.prev=24;_iterator64.f();return _context76.finish(24);case 27:e.render=s;case 28:i=(a=e.sp)==null?void 0:a.filter(function(s){return s.type!==ot.None||s.isLockSentEventCursor;});i!=null&&i.length?e.sp=i.map(function(s){return _objectSpread(_objectSpread({},s),{},{viewId:_this105.viewId});}):delete e.sp,e.fullWorkerDrawCount===void 0&&delete e.fullWorkerDrawCount,e.consumeCount===void 0&&delete e.consumeCount,(e!=null&&e.fullWorkerDrawCount||e.consumeCount||i!=null&&i.length||(o=e.render)!=null&&o.length)&&this._post(e,n),this.delayPostDoneResolve&&this.delayPostDoneResolve(!0);case 30:case"end":return _context76.stop();}},_callee73,this,[[4,21,24,27]]);}));function combinePost(){return _combinePost.apply(this,arguments);}return combinePost;}()},{key:"on",value:function(){var _on2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee74(t){var _this106=this;var e,n,i,a,o,s,l,g,_l9;return _regeneratorRuntime().wrap(function _callee74$(_context77){while(1)switch(_context77.prev=_context77.next){case 0:if(!this.methodBuilder.consumeForWorker(t)){_context77.next=2;break;}return _context77.abrupt("return");case 2:e=t.msgType,n=t.dataType,i=t.workId,a=t.toolsType,o=t.workState,s=t.workIds;_context77.t0=e;_context77.next=_context77.t0===ot.AuthClear?6:_context77.t0===ot.CreateWork?9:_context77.t0===ot.DrawWork?11:_context77.t0===ot.Select?20:_context77.t0===ot.UpdateNode?27:_context77.t0===ot.FullWork?27:_context77.t0===ot.RemoveNode?29:_context77.t0===ot.GetTextActive?32:_context77.t0===ot.CursorHover?35:_context77.t0===ot.CursorBlur?38:_context77.t0===ot.GetVNodeInfo?41:43;break;case 6:l=t.clearUids,g=t.localUid;this.vNodes.setCanClearUids(l),this.vNodes.setLocalUid(g);return _context77.abrupt("break",43);case 9:a!==dt.LaserPen&&this.createLocalWork(t);return _context77.abrupt("break",43);case 11:_context77.t1=a!==dt.LaserPen;if(!_context77.t1){_context77.next=19;break;}if(!(o===It.Done&&n===Tt.Local)){_context77.next=18;break;}_context77.next=16;return this.consumeDrawAll(n,t);case 16:_context77.next=19;break;case 18:this.consumeDraw(n,t);case 19:return _context77.abrupt("break",43);case 20:if(!(i===Wt)){_context77.next=25;break;}_context77.next=23;return this.localWork.updateFullSelectWork(t);case 23:_context77.next=26;break;case 25:this.serviceWork.runSelectWork(t);case 26:return _context77.abrupt("return");case 27:this.consumeFull(n,t);return _context77.abrupt("return");case 29:_context77.next=31;return this.removeNode(t);case 31:return _context77.abrupt("return");case 32:_context77.next=34;return this.checkTextActive(t);case 34:return _context77.abrupt("return");case 35:_context77.next=37;return this.cursorHover(t);case 37:return _context77.abrupt("return");case 38:_context77.next=40;return this.cursorBlur();case 40:return _context77.abrupt("return");case 41:if(i&&s){_l9=s.map(function(g){return _this106.vNodes.get(g);});this.post({sp:[{type:ot.GetVNodeInfo,dataType:Tt.Worker,workId:i,vInfo:_l9}]});}return _context77.abrupt("break",43);case 43:_context77.next=45;return _superPropGet(xm,"on",this,3)([t]);case 45:case"end":return _context77.stop();}},_callee74,this);}));function on(_x85){return _on2.apply(this,arguments);}return on;}()},{key:"removeNode",value:function(){var _removeNode2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee75(t){var _this107=this;var e,n,i,a,o,_iterator65,_step65,_loop7;return _regeneratorRuntime().wrap(function _callee75$(_context79){while(1)switch(_context79.prev=_context79.next){case 0:e=t.dataType,n=t.workId,i=t.removeIds,a=[],o=i||[];if(!(n&&o.push(n.toString()),o.length)){_context79.next=20;break;}_iterator65=_createForOfIteratorHelper(o);_context79.prev=3;_loop7=/*#__PURE__*/_regeneratorRuntime().mark(function _loop7(){var s;return _regeneratorRuntime().wrap(function _loop7$(_context78){while(1)switch(_context78.prev=_context78.next){case 0:s=_step65.value;s===Wt?a.push(_this107.localWork.removeSelector(t,_this107)):e===Tt.Local?a.push(_this107.localWork.removeWork(t).then(function(){_this107.localWork.colloctEffectSelectWork(t),_this107.deleteCachedImagesByWorkId(s);})):e===Tt.Service&&a.push(_this107.serviceWork.removeWork(t).then(function(){_this107.localWork.colloctEffectSelectWork(t),_this107.deleteCachedImagesByWorkId(s);}));case 2:case"end":return _context78.stop();}},_loop7);});_iterator65.s();case 6:if((_step65=_iterator65.n()).done){_context79.next=10;break;}return _context79.delegateYield(_loop7(),"t0",8);case 8:_context79.next=6;break;case 10:_context79.next=15;break;case 12:_context79.prev=12;_context79.t1=_context79["catch"](3);_iterator65.e(_context79.t1);case 15:_context79.prev=15;_iterator65.f();return _context79.finish(15);case 18:_context79.next=20;return Promise.all(a);case 20:case"end":return _context79.stop();}},_callee75,null,[[3,12,15,18]]);}));function removeNode(_x86){return _removeNode2.apply(this,arguments);}return removeNode;}()},{key:"checkTextActive",value:function(){var _checkTextActive2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee76(t){var e;return _regeneratorRuntime().wrap(function _callee76$(_context80){while(1)switch(_context80.prev=_context80.next){case 0:e=t.dataType;_context80.t0=e===Tt.Local;if(!_context80.t0){_context80.next=5;break;}_context80.next=5;return this.localWork.checkTextActive(t);case 5:case"end":return _context80.stop();}},_callee76,this);}));function checkTextActive(_x87){return _checkTextActive2.apply(this,arguments);}return checkTextActive;}()},{key:"clearAll",value:function(){var _clearAll2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee77(){return _regeneratorRuntime().wrap(function _callee77$(_context81){while(1)switch(_context81.prev=_context81.next){case 0:this.vNodes.clear();_superPropGet(xm,"clearAll",this,3)([]);this.localDrawLayer&&(this.localDrawLayer.parent.children.forEach(function(t){t.name!=="viewport"&&t.remove();}),this.localDrawLayer.removeAllChildren());this.serviceDrawLayer&&(this.serviceDrawLayer.parent.children.forEach(function(t){t.name!=="viewport"&&t.remove();}),this.serviceDrawLayer.removeAllChildren());_context81.next=6;return this.post({render:[{isClearAll:!0,clearCanvas:St.Bg,viewId:this.viewId},{isClearAll:!0,clearCanvas:St.ServiceFloat,viewId:this.viewId},{isClearAll:!0,clearCanvas:St.Float,viewId:this.viewId}],sp:[{type:ot.Clear}]});case 6:case"end":return _context81.stop();}},_callee77,this);}));function clearAll(){return _clearAll2.apply(this,arguments);}return clearAll;}()},{key:"updateLayer",value:function updateLayer(t){var e=t.width,n=t.height;_superPropGet(xm,"updateLayer",this,3)([t]),this.localDrawLayer&&(this.localDrawLayer.parent.setAttribute("width",e),this.localDrawLayer.parent.setAttribute("height",n),this.localDrawLayer.setAttribute("size",[e,n]),this.localDrawLayer.setAttribute("pos",[e*0.5,n*0.5])),this.serviceDrawLayer&&(this.serviceDrawLayer.parent.setAttribute("width",e),this.serviceDrawLayer.parent.setAttribute("height",n),this.serviceDrawLayer.setAttribute("size",[e,n]),this.serviceDrawLayer.setAttribute("pos",[e*0.5,n*0.5]));}},{key:"setCameraOpt",value:function setCameraOpt(t){this.cameraOpt=t;var e=t.scale,n=t.centerX,i=t.centerY,a=t.width,o=t.height;(a!==this.scene.width||o!==this.scene.height)&&this.updateScene({width:a,height:o}),this.fullLayer&&(this.fullLayer.setAttribute("scale",[e,e]),this.fullLayer.setAttribute("translate",[-n,-i])),this.localDrawLayer&&(this.localDrawLayer.setAttribute("scale",[e,e]),this.localDrawLayer.setAttribute("translate",[-n,-i])),this.serviceDrawLayer&&(this.serviceDrawLayer.setAttribute("scale",[e,e]),this.serviceDrawLayer.setAttribute("translate",[-n,-i]));}},{key:"getLayer",value:function getLayer(t){switch(t){case St.Bg:return this.fullLayer;case St.ServiceFloat:return this.serviceDrawLayer;case St.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 _callee78(t,e){var n;return _regeneratorRuntime().wrap(function _callee78$(_context82){while(1)switch(_context82.prev=_context82.next){case 0:_context82.next=2;return this.localWork.colloctEffectSelectWork(e);case 2:n=_context82.sent;_context82.t0=n&&t===Tt.Local;if(!_context82.t0){_context82.next=7;break;}_context82.next=7;return this.localWork.consumeFull(n);case 7:n&&t===Tt.Service&&this.serviceWork.consumeFull(n);case 8:case"end":return _context82.stop();}},_callee78,this);}));function consumeFull(_x88,_x89){return _consumeFull2.apply(this,arguments);}return consumeFull;}()},{key:"consumeDraw",value:function(){var _consumeDraw4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee79(t,e){var n;return _regeneratorRuntime().wrap(function _callee79$(_context83){while(1)switch(_context83.prev=_context83.next){case 0:n=e.workId;_context83.t0=t===Tt.Local&&n;if(!_context83.t0){_context83.next=6;break;}this.localWork.getWorkShape(n.toString())||this.createLocalWork(e);_context83.next=6;return this.localWork.consumeDraw(e,this.serviceWork);case 6:t===Tt.Service&&this.serviceWork.consumeDraw(e);case 7:case"end":return _context83.stop();}},_callee79,this);}));function consumeDraw(_x90,_x91){return _consumeDraw4.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee80(t,e){var n;return _regeneratorRuntime().wrap(function _callee80$(_context84){while(1)switch(_context84.prev=_context84.next){case 0:n=e.workId;_context84.t0=t===Tt.Local&&n;if(!_context84.t0){_context84.next=6;break;}this.localWork.getWorkShape(n.toString())||this.createLocalWork(e);_context84.next=6;return this.localWork.consumeDrawAll(e,this.serviceWork);case 6:case"end":return _context84.stop();}},_callee80,this);}));function consumeDrawAll(_x92,_x93){return _consumeDrawAll3.apply(this,arguments);}return consumeDrawAll;}()},{key:"updateDpr",value:function(){var _updateDpr2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee81(t){return _regeneratorRuntime().wrap(function _callee81$(_context85){while(1)switch(_context85.prev=_context85.next){case 0:_superPropGet(xm,"updateDpr",this,3)([t]);_context85.next=3;return this.post({render:[{isClearAll:!0,clearCanvas:St.Bg,viewId:this.viewId},{isDrawAll:!0,drawCanvas:St.Bg,viewId:this.viewId}]});case 3:case"end":return _context85.stop();}},_callee81,this);}));function updateDpr(_x94){return _updateDpr2.apply(this,arguments);}return updateDpr;}()},{key:"updateCamera",value:function(){var _updateCamera=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee82(t){var _this108=this;var a,e,n,i,o,d,_iterator66,_step66,_step66$value,y,P,s,_iterator67,_step67,_step67$value,_d11,_y19,_P9,l,g,_d7,_iterator68,_step68,_y15,c,_iterator69,_step69,_d8,_y16,_iterator70,_step70,_P6,_iterator71,_step71,_step71$value,_d10,_y18,_P8,S,v,_T45,_f39,p,u,m,M,_iterator72,_step72,_step72$value,_d9,_y17;return _regeneratorRuntime().wrap(function _callee82$(_context86){while(1)switch(_context86.prev=_context86.next){case 0:e=[],n=t.cameraOpt,i=t.scenePath;if(!(n&&!le(this.cameraOpt,n))){_context86.next=40;break;}this.taskUpdateCameraId&&(clearTimeout(this.taskUpdateCameraId),this.taskUpdateCameraId=void 0);o=!!this.serviceDrawLayer.children.length;if(!i){_context86.next=30;break;}d=!1;_iterator66=_createForOfIteratorHelper(this.localWork.getWorkShapes().entries());_context86.prev=7;_iterator66.s();case 9:if((_step66=_iterator66.n()).done){_context86.next=19;break;}_step66$value=_slicedToArray(_step66.value,2),y=_step66$value[0],P=_step66$value[1];_context86.t0=P.toolsType;_context86.next=_context86.t0===dt.Text?14:_context86.t0===dt.PencilEraser?14:_context86.t0===dt.Eraser?14:_context86.t0===dt.Selector?14:_context86.t0===dt.LaserPen?14:15;break;case 14:return _context86.abrupt("break",17);case 15:y!==be&&y!==Wt&&(d=!0);return _context86.abrupt("break",17);case 17:_context86.next=9;break;case 19:_context86.next=24;break;case 21:_context86.prev=21;_context86.t1=_context86["catch"](7);_iterator66.e(_context86.t1);case 24:_context86.prev=24;_iterator66.f();return _context86.finish(24);case 27:if(!d){_context86.next=30;break;}this.taskUpdateCameraId=setTimeout(function(){_this108.taskUpdateCameraId=void 0,_this108.updateCamera(t);},Cn);return _context86.abrupt("return");case 30:s=/* @__PURE__ */new Map();_iterator67=_createForOfIteratorHelper(this.vNodes.getNodesByType(dt.Text).entries());try{for(_iterator67.s();!(_step67=_iterator67.n()).done;){_step67$value=_slicedToArray(_step67.value,2),_d11=_step67$value[0],_y19=_step67$value[1];_P9=_y19.rect;s.set(_d11,Jt(_P9));}}catch(err){_iterator67.e(err);}finally{_iterator67.f();}l=new Set(s.keys());g=!1;if(this.localWork.hasSelector()){_d7=(a=this.localWork.getSelector())==null?void 0:a.selectIds;if(_d7){g=!0;_iterator68=_createForOfIteratorHelper(_d7);try{for(_iterator68.s();!(_step68=_iterator68.n()).done;){_y15=_step68.value;l.add(_y15);}}catch(err){_iterator68.e(err);}finally{_iterator68.f();}}}c=!1;if(this.serviceWork.selectorWorkShapes.size){_iterator69=_createForOfIteratorHelper(this.serviceWork.selectorWorkShapes.values());try{for(_iterator69.s();!(_step69=_iterator69.n()).done;){_d8=_step69.value;_y16=_d8.selectIds;if(_y16){c=!0;_iterator70=_createForOfIteratorHelper(_y16);try{for(_iterator70.s();!(_step70=_iterator70.n()).done;){_P6=_step70.value;l.add(_P6);}}catch(err){_iterator70.e(err);}finally{_iterator70.f();}}}}catch(err){_iterator69.e(err);}finally{_iterator69.f();}}if(this.setCameraOpt(n),this.vNodes.curNodeMap.size){this.vNodes.clearTarget(),this.vNodes.updateHighLevelNodesRect(l),this.debounceUpdateCameraId&&clearTimeout(this.debounceUpdateCameraId);_iterator71=_createForOfIteratorHelper(s.entries());try{for(_iterator71.s();!(_step71=_iterator71.n()).done;){_step71$value=_slicedToArray(_step71.value,2),_d10=_step71$value[0],_y18=_step71$value[1];_P8=this.vNodes.get(_d10);if(_P8){S=_y18,v=_P8.rect,_T45=this.getSceneRect(),_f39=fr(S,_T45),p=fr(v,_T45);u=!1;if((_f39!==p||S.w!==v.w||S.h!==v.h||p===Me.intersect)&&(u=!0),u){m=_P8.toolsType,M=_P8.opt;m===dt.Text&&M.workState===It.Done&&this.debounceUpdateCache.add(_d10);}}}}catch(err){_iterator71.e(err);}finally{_iterator71.f();}if(g&&this.localWork.reRenderSelector(),c){_iterator72=_createForOfIteratorHelper(this.serviceWork.selectorWorkShapes.entries());try{for(_iterator72.s();!(_step72=_iterator72.n()).done;){_step72$value=_slicedToArray(_step72.value,2),_d9=_step72$value[0],_y17=_step72$value[1];this.serviceWork.runSelectWork({workId:_d9,selectIds:_y17.selectIds,msgType:ot.Select,dataType:Tt.Service,viewId:this.viewId});}}catch(err){_iterator72.e(err);}finally{_iterator72.f();}}this.debounceUpdateCameraId=setTimeout(function(){var y;_this108.debounceUpdateCameraId=void 0;var d=[];var _iterator73=_createForOfIteratorHelper(_this108.debounceUpdateCache.values()),_step73;try{for(_iterator73.s();!(_step73=_iterator73.n()).done;){var _P7=_step73.value;if((y=_this108.fullLayer)==null?void 0:y.getElementsByName(_P7)[0]){var v=_this108.vNodes.get(_P7);if(v){var _T44=v.toolsType,_f38=v.opt,p=v.rect,u=_this108.localWork.setFullWork({toolsType:_T44,opt:_f38,workId:_P7});if(u){var m=_this108.getSceneRect(),M=fr(p,m);d.push(u.consumeServiceAsync({isFullWork:!0,replaceId:_P7,isDrawLabel:M!==Me.outside}));}}}_this108.debounceUpdateCache["delete"](_P7);}}catch(err){_iterator73.e(err);}finally{_iterator73.f();}d.length?Promise.all(d).then(function(){var P=[];P.push({isClearAll:!0,clearCanvas:St.Bg,viewId:_this108.viewId},{isDrawAll:!0,drawCanvas:St.Bg,viewId:_this108.viewId}),P.length&&_this108.post({render:P}),_this108.vNodes.updateLowLevelNodesRect(),_this108.vNodes.clearHighLevelIds();}):(_this108.vNodes.updateLowLevelNodesRect(),_this108.vNodes.clearHighLevelIds());},Cn);}o&&e.push({isClearAll:!0,clearCanvas:St.ServiceFloat,viewId:this.viewId}),this.vNodes.hasRenderNodes()&&e.push({isClearAll:!0,clearCanvas:St.Bg,viewId:this.viewId},{isDrawAll:!0,drawCanvas:St.Bg,viewId:this.viewId}),e.length&&this.post({render:e});case 40:case"end":return _context86.stop();}},_callee82,this,[[7,21,24,27]]);}));function updateCamera(_x95){return _updateCamera.apply(this,arguments);}return updateCamera;}()},{key:"getRectImageBitmap",value:function getRectImageBitmap(t){var e=t.rect,n=t.drawCanvas,i=Math.floor(e.x*this.dpr),a=Math.floor(e.y*this.dpr),o=Math.floor(e.w*this.dpr||1),s=Math.floor(e.h*this.dpr||1);return createImageBitmap(this.getOffscreen(n),i,a,o,s,{resizeQuality:"low"});}},{key:"cursorHover",value:function(){var _cursorHover2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee83(t){return _regeneratorRuntime().wrap(function _callee83$(_context87){while(1)switch(_context87.prev=_context87.next){case 0:_context87.next=2;return this.localWork.cursorHover(t);case 2:case"end":return _context87.stop();}},_callee83,this);}));function cursorHover(_x96){return _cursorHover2.apply(this,arguments);}return cursorHover;}()},{key:"cursorBlur",value:function(){var _cursorBlur2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee84(){return _regeneratorRuntime().wrap(function _callee84$(_context88){while(1)switch(_context88.prev=_context88.next){case 0:_context88.next=2;return this.localWork.cursorBlur();case 2:case"end":return _context88.stop();}},_callee84,this);}));function cursorBlur(){return _cursorBlur2.apply(this,arguments);}return cursorBlur;}()},{key:"destroy",value:function destroy(){_superPropGet(xm,"destroy",this,3)([]);}}]);}(Ai);var Di=/*#__PURE__*/function(_Ai2){function Di(t,e,n){var _this109;_classCallCheck(this,Di);_this109=_callSuper(this,Di,[t,e,"sub"/* Sub */]);tt(_this109,"type","sub");tt(_this109,"_post");tt(_this109,"topLayer");tt(_this109,"snapshotFullLayer");tt(_this109,"serviceWork");tt(_this109,"localWork");tt(_this109,"topLayerWork");_this109._post=n;var i=re.bufferSize.sub;_this109.topLayer=_this109.createLayer("topLayer",_this109.scene,_objectSpread(_objectSpread({},e.layerOpt),{},{bufferSize:i,contextType:"2d"}));var a={thread:_this109,viewId:_this109.viewId,vNodes:_this109.vNodes,fullLayer:_this109.fullLayer,topLayer:_this109.topLayer};_this109.localWork=new vm(a),_this109.topLayerWork=new ym(a),_this109.vNodes.init(_this109.fullLayer);return _this109;}_inherits(Di,_Ai2);return _createClass(Di,[{key:"combinePost",value:function(){var _combinePost2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee85(){var _this110=this;var a,o,_this$combinePostData2,t,e,n,s,_iterator74,_step74,l,g,i;return _regeneratorRuntime().wrap(function _callee85$(_context89){while(1)switch(_context89.prev=_context89.next){case 0:_this$combinePostData2=this.combinePostData(),t=_this$combinePostData2.render,e=_objectWithoutProperties(_this$combinePostData2,_excluded4);if(!(t!=null&&t.length)){_context89.next=28;break;}s=[];_iterator74=_createForOfIteratorHelper(t);_context89.prev=4;_iterator74.s();case 6:if((_step74=_iterator74.n()).done){_context89.next=19;break;}l=_step74.value;if(!l.rect){_context89.next=17;break;}if(!(l.rect=this.safariFixRect(Jt(l.rect),this.dpr),!l.rect)){_context89.next=11;break;}return _context89.abrupt("continue",17);case 11:if(!(l.drawCanvas&&l.rect&&l.rect.w>0&&l.rect.h>0)){_context89.next=16;break;}_context89.next=14;return this.getRectImageBitmap(l);case 14:g=_context89.sent;l.imageBitmap=g,n||(n=[]),n.push(g);case 16:s.push(l);case 17:_context89.next=6;break;case 19:_context89.next=24;break;case 21:_context89.prev=21;_context89.t0=_context89["catch"](4);_iterator74.e(_context89.t0);case 24:_context89.prev=24;_iterator74.f();return _context89.finish(24);case 27:e.render=s;case 28:i=(a=e.sp)==null?void 0:a.filter(function(s){return s.type!==ot.None;});i!=null&&i.length?e.sp=i.map(function(s){return _objectSpread(_objectSpread({},s),{},{viewId:_this110.viewId});}):delete e.sp,e.consumeCount===void 0&&delete e.consumeCount,e.subWorkerDrawCount===void 0&&delete e.subWorkerDrawCount,(i!=null&&i.length||e.consumeCount||e.subWorkerDrawCount||(o=e==null?void 0:e.render)!=null&&o.length)&&this._post(e,n),this.delayPostDoneResolve&&this.delayPostDoneResolve(!0);case 30:case"end":return _context89.stop();}},_callee85,this,[[4,21,24,27]]);}));function combinePost(){return _combinePost2.apply(this,arguments);}return combinePost;}()},{key:"getLayer",value:function getLayer(t,e){if(e&&this.snapshotFullLayer)return this.snapshotFullLayer;switch(t){case St.TopFloat:return this.topLayer;default:return this.fullLayer;}}},{key:"on",value:function(){var _on3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee86(t){var e,n,i,a,o,s;return _regeneratorRuntime().wrap(function _callee86$(_context90){while(1)switch(_context90.prev=_context90.next){case 0:e=t.msgType,n=t.toolsType,i=t.opt,a=t.dataType,o=t.workState;_context90.t0=e;_context90.next=_context90.t0===ot.UpdateTools?4:_context90.t0===ot.CreateWork?9:_context90.t0===ot.DrawWork?11:_context90.t0===ot.RemoveNode?18:_context90.t0===ot.FullWork?21:_context90.t0===ot.Snapshot?26:_context90.t0===ot.BoundingBox?33:40;break;case 4:if(!(n&&this.topLayerWork.canUseTopLayer(n)&&i)){_context90.next=8;break;}s={toolsType:n,toolsOpt:i};this.topLayerWork.setToolsOpt(s);return _context90.abrupt("return");case 8:return _context90.abrupt("break",40);case 9:this.createLocalWork(t);return _context90.abrupt("return");case 11:if(!(o===It.Done&&a===Tt.Local)){_context90.next=16;break;}_context90.next=14;return this.consumeDrawAll(a,t);case 14:_context90.next=17;break;case 16:this.consumeDraw(a,t);case 17:return _context90.abrupt("return");case 18:_context90.next=20;return this.removeNode(t);case 20:return _context90.abrupt("return");case 21:_context90.t1=n&&this.topLayerWork.canUseTopLayer(n);if(!_context90.t1){_context90.next=25;break;}_context90.next=25;return this.consumeDrawAll(a,t);case 25:return _context90.abrupt("return");case 26:this.snapshotFullLayer=this.createLayer("snapshotFullLayer",this.scene,_objectSpread(_objectSpread({},this.opt.layerOpt),{},{bufferSize:this.viewId===Qe?6e3:3e3,contextType:"2d"}));_context90.t2=this.snapshotFullLayer;if(!_context90.t2){_context90.next=32;break;}_context90.next=31;return this.getSnapshot(t);case 31:this.snapshotFullLayer=void 0;case 32:return _context90.abrupt("return");case 33:this.snapshotFullLayer=this.createLayer("snapshotFullLayer",this.scene,_objectSpread(_objectSpread({},this.opt.layerOpt),{},{bufferSize:this.viewId===Qe?6e3:3e3,contextType:"2d"}));_context90.t3=this.snapshotFullLayer;if(!_context90.t3){_context90.next=39;break;}_context90.next=38;return this.getBoundingRect(t);case 38:this.snapshotFullLayer=void 0;case 39:return _context90.abrupt("return");case 40:_context90.next=42;return _superPropGet(Di,"on",this,3)([t]);case 42:case"end":return _context90.stop();}},_callee86,this);}));function on(_x97){return _on3.apply(this,arguments);}return on;}()},{key:"createLocalWork",value:function createLocalWork(t){var e=t.workId,n=t.toolsType,i=t.opt;if(n&&this.topLayerWork.canUseTopLayer(n)&&e&&i){this.topLayerWork.getToolsOpt()||this.topLayerWork.setToolsOpt({toolsType:n,toolsOpt:i}),this.topLayerWork.setWorkOptions(e.toString(),i);return;}n&&this.localWork.canUseSubWorker(n)&&_superPropGet(Di,"createLocalWork",this,3)([t]);}},{key:"removeNode",value:function(){var _removeNode3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee87(t){var e;return _regeneratorRuntime().wrap(function _callee87$(_context91){while(1)switch(_context91.prev=_context91.next){case 0:e=t.dataType;_context91.t0=e===Tt.Local;if(!_context91.t0){_context91.next=5;break;}_context91.next=5;return this.localWork.removeWork(t);case 5:case"end":return _context91.stop();}},_callee87,this);}));function removeNode(_x98){return _removeNode3.apply(this,arguments);}return removeNode;}()},{key:"getOffscreen",value:function getOffscreen(t,e){return this.getLayer(t,e).parent.canvas;}},{key:"consumeDraw",value:function(){var _consumeDraw5=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee88(t,e){var n,i;return _regeneratorRuntime().wrap(function _callee88$(_context92){while(1)switch(_context92.prev=_context92.next){case 0:n=e.workId,i=e.toolsType;if(!n){_context92.next=11;break;}if(!(i&&this.topLayerWork.canUseTopLayer(i))){_context92.next=5;break;}t===Tt.Local&&(this.topLayerWork.getWorkShape(n.toString())||this.createLocalWork(e)),this.topLayerWork.consumeDraw(e);return _context92.abrupt("return");case 5:_context92.t0=i&&this.localWork.canUseSubWorker(i);if(!_context92.t0){_context92.next=10;break;}this.localWork.getWorkShape(n.toString())||this.createLocalWork(e);_context92.next=10;return this.localWork.consumeDraw(e);case 10:return _context92.abrupt("return");case 11:case"end":return _context92.stop();}},_callee88,this);}));function consumeDraw(_x99,_x100){return _consumeDraw5.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee89(t,e){var n,i,a,o;return _regeneratorRuntime().wrap(function _callee89$(_context93){while(1)switch(_context93.prev=_context93.next){case 0:n=e.workId,i=e.toolsType,a=e.dataType;if(!n){_context93.next=8;break;}o=n.toString();if(!(i&&this.topLayerWork.canUseTopLayer(i))){_context93.next=6;break;}a===Tt.Local&&(this.topLayerWork.getWorkShape(o)||this.createLocalWork(e)),this.topLayerWork.consumeDrawAll(e);return _context93.abrupt("return");case 6:i&&this.localWork.canUseSubWorker(i)&&(this.localWork.getWorkShape(o)||_superPropGet(Di,"createLocalWork",this,3)([e]),this.localWork.consumeDrawAll(e));return _context93.abrupt("return");case 8:case"end":return _context93.stop();}},_callee89,this);}));function consumeDrawAll(_x101,_x102){return _consumeDrawAll4.apply(this,arguments);}return consumeDrawAll;}()},{key:"clearAll",value:function(){var _clearAll3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee90(){return _regeneratorRuntime().wrap(function _callee90$(_context94){while(1)switch(_context94.prev=_context94.next){case 0:this.vNodes.clear();_superPropGet(Di,"clearAll",this,3)([]);this.topLayer&&(this.topLayer.parent.children.forEach(function(t){t.name!=="viewport"&&t.remove();}),this.topLayer.removeAllChildren());_context94.next=5;return this.post({render:[{isClearAll:!0,clearCanvas:St.TopFloat,viewId:this.viewId}],sp:[{type:ot.Clear}]});case 5:case"end":return _context94.stop();}},_callee90,this);}));function clearAll(){return _clearAll3.apply(this,arguments);}return clearAll;}()},{key:"getRectImageBitmap",value:function getRectImageBitmap(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!1;var n=arguments.length>2?arguments[2]:undefined;var i=t.rect,a=t.drawCanvas,o=Math.floor(i.x*this.dpr),s=Math.floor(i.y*this.dpr),l=Math.floor(i.w*this.dpr||1),g=Math.floor(i.h*this.dpr||1);return createImageBitmap(this.getOffscreen(a,e),o,s,l,g,n);}},{key:"updateLayer",value:function updateLayer(t){var e=t.width,n=t.height;_superPropGet(Di,"updateLayer",this,3)([t]),this.topLayer&&(this.topLayer.parent.setAttribute("width",e),this.topLayer.parent.setAttribute("height",n),this.topLayer.setAttribute("size",[e,n]),this.topLayer.setAttribute("pos",[e*0.5,n*0.5])),this.snapshotFullLayer&&(this.snapshotFullLayer.parent.setAttribute("width",e),this.snapshotFullLayer.parent.setAttribute("height",n),this.snapshotFullLayer.setAttribute("size",[e,n]),this.snapshotFullLayer.setAttribute("pos",[e*0.5,n*0.5]));}},{key:"updateDpr",value:function(){var _updateDpr3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee91(t){var e,n,i;return _regeneratorRuntime().wrap(function _callee91$(_context95){while(1)switch(_context95.prev=_context95.next){case 0:_superPropGet(Di,"updateDpr",this,3)([t]);e=!!this.topLayerWork.localWorkShapes.size,n=!!this.localWork.getWorkShapes().size,i=[];n&&i.push({isClearAll:!0,clearCanvas:St.Float,viewId:this.viewId});e&&i.push({isClearAll:!0,clearCanvas:St.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();}},_callee91,this);}));function updateDpr(_x103){return _updateDpr3.apply(this,arguments);}return updateDpr;}()},{key:"updateCamera",value:function(){var _updateCamera2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee92(t){var _this111=this;var e,n,i,a,_iterator75,_step75,_loop8;return _regeneratorRuntime().wrap(function _callee92$(_context97){while(1)switch(_context97.prev=_context97.next){case 0:e=[],n=t.cameraOpt;if(!(n&&!le(this.cameraOpt,n))){_context97.next=25;break;}i=!!this.topLayerWork.localWorkShapes.size,a=!!this.localWork.getWorkShapes().size;if(!(a&&this.localWork.workShapesDone(),this.setCameraOpt(n),a&&e.push({isClearAll:!0,clearCanvas:St.Float,viewId:this.viewId}),i)){_context97.next=21;break;}e.push({isClearAll:!0,clearCanvas:St.TopFloat,viewId:this.viewId});_iterator75=_createForOfIteratorHelper(this.topLayerWork.localWorkShapes.entries());_context97.prev=6;_loop8=/*#__PURE__*/_regeneratorRuntime().mark(function _loop8(){var _step75$value,o,s,l;return _regeneratorRuntime().wrap(function _loop8$(_context96){while(1)switch(_context96.prev=_context96.next){case 0:_step75$value=_slicedToArray(_step75.value,2),o=_step75$value[0],s=_step75$value[1];if(s.totalRect){_this111.topLayer.getElementsByName(o.toString()).forEach(function(g){var c=g.getBoundingClientRect(),d=Dt({x:c.x,y:c.y,w:c.width,h:c.height});l=Pt(l,d);}),s.totalRect=l,_this111.topLayerWork.localWorkShapes.set(o,s);}case 2:case"end":return _context96.stop();}},_loop8);});_iterator75.s();case 9:if((_step75=_iterator75.n()).done){_context97.next=13;break;}return _context97.delegateYield(_loop8(),"t0",11);case 11:_context97.next=9;break;case 13:_context97.next=18;break;case 15:_context97.prev=15;_context97.t1=_context97["catch"](6);_iterator75.e(_context97.t1);case 18:_context97.prev=18;_iterator75.f();return _context97.finish(18);case 21:_context97.t2=e.length;if(!_context97.t2){_context97.next=25;break;}_context97.next=25;return this.post({render:e});case 25:case"end":return _context97.stop();}},_callee92,this,[[6,15,18,21]]);}));function updateCamera(_x104){return _updateCamera2.apply(this,arguments);}return updateCamera;}()},{key:"setCameraOpt",value:function setCameraOpt(t,e){this.cameraOpt=t;var n=t.scale,i=t.centerX,a=t.centerY,o=t.width,s=t.height;(o!==this.scene.width||s!==this.scene.height)&&this.updateScene({width:o,height:s}),e?(e.setAttribute("scale",[n,n]),e.setAttribute("translate",[-i,-a])):(this.fullLayer.setAttribute("scale",[n,n]),this.fullLayer.setAttribute("translate",[-i,-a]),this.topLayer.setAttribute("scale",[n,n]),this.topLayer.setAttribute("translate",[-i,-a]));}},{key:"getSnapshot",value:function(){var _getSnapshot=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee93(t){var e,n,i,a,o,s,l,_i13,_Object$entries,_Object$entries$_i,c,d,y,P,S,g;return _regeneratorRuntime().wrap(function _callee93$(_context98){while(1)switch(_context98.prev=_context98.next){case 0:e=t.scenePath,n=t.scenes,i=t.cameraOpt,a=t.w,o=t.h;if(!(e&&n&&i&&this.snapshotFullLayer)){_context98.next=26;break;}s=Jt(this.cameraOpt);this.setCameraOpt(i,this.snapshotFullLayer),this.localWork.fullLayer=this.snapshotFullLayer,this.localWork.drawLayer=void 0;_i13=0,_Object$entries=Object.entries(n);case 5:if(!(_i13<_Object$entries.length)){_context98.next=21;break;}_Object$entries$_i=_slicedToArray(_Object$entries[_i13],2),c=_Object$entries$_i[0],d=_Object$entries$_i[1];if(!(d!=null&&d.type)){_context98.next=18;break;}_context98.t0=d==null?void 0:d.type;_context98.next=_context98.t0===ot.UpdateNode?11:_context98.t0===ot.FullWork?11:18;break;case 11:y=d.opt;P=_objectSpread(_objectSpread({},d),{},{opt:y,workId:c,msgType:ot.FullWork,dataType:Tt.Service,viewId:this.viewId});_context98.next=15;return this.localWork.runFullWork(P);case 15:S=_context98.sent;l=Pt(l,S);return _context98.abrupt("break",18);case 18:_i13++;_context98.next=5;break;case 21:a&&o&&(g={resizeWidth:a,resizeHeight:o});_context98.next=24;return this.getSnapshotRender({scenePath:e,curCameraOpt:s,options:g});case 24:this.localWork.fullLayer=this.fullLayer;this.localWork.drawLayer=void 0;case 26:case"end":return _context98.stop();}},_callee93,this);}));function getSnapshot(_x105){return _getSnapshot.apply(this,arguments);}return getSnapshot;}()},{key:"getSnapshotRender",value:function(){var _getSnapshotRender=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee94(t){var o,s,e,n,i,a;return _regeneratorRuntime().wrap(function _callee94$(_context99){while(1)switch(_context99.prev=_context99.next){case 0:e=t.scenePath,n=t.curCameraOpt,i=t.options;((o=this.snapshotFullLayer)==null?void 0:o.parent).render();_context99.next=4;return this.getRectImageBitmap({rect:this.getSceneRect(),drawCanvas:St.None},!0,i);case 4:a=_context99.sent;a&&(this._post({sp:[{type:ot.Snapshot,scenePath:e,imageBitmap:a,viewId:this.viewId}]},[a]),a.close(),(s=this.snapshotFullLayer)==null||s.removeAllChildren(),this.setCameraOpt(n,this.fullLayer));case 6:case"end":return _context99.stop();}},_callee94,this);}));function getSnapshotRender(_x106){return _getSnapshotRender.apply(this,arguments);}return getSnapshotRender;}()},{key:"getBoundingRect",value:function(){var _getBoundingRect=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee95(t){var e,n,i,a,o,_i14,_Object$entries2,_Object$entries2$_i,s,l,g;return _regeneratorRuntime().wrap(function _callee95$(_context100){while(1)switch(_context100.prev=_context100.next){case 0:e=t.scenePath,n=t.scenes,i=t.cameraOpt;if(!(e&&n&&i&&this.snapshotFullLayer)){_context100.next=27;break;}a=Jt(this.cameraOpt);this.setCameraOpt(i,this.snapshotFullLayer),this.localWork.fullLayer=this.snapshotFullLayer,this.localWork.drawLayer=void 0;_i14=0,_Object$entries2=Object.entries(n);case 5:if(!(_i14<_Object$entries2.length)){_context100.next=19;break;}_Object$entries2$_i=_slicedToArray(_Object$entries2[_i14],2),s=_Object$entries2$_i[0],l=_Object$entries2$_i[1];if(!(l!=null&&l.type)){_context100.next=16;break;}_context100.t0=l==null?void 0:l.type;_context100.next=_context100.t0===ot.UpdateNode?11:_context100.t0===ot.FullWork?11:16;break;case 11:_context100.next=13;return this.localWork.runFullWork(_objectSpread(_objectSpread({},l),{},{workId:s,msgType:ot.FullWork,dataType:Tt.Service,viewId:this.viewId}));case 13:g=_context100.sent;o=Pt(o,g);return _context100.abrupt("break",16);case 16:_i14++;_context100.next=5;break;case 19:_context100.t1=o;if(!_context100.t1){_context100.next=23;break;}_context100.next=23;return this.post({sp:[{type:ot.BoundingBox,scenePath:e,rect:o}]});case 23:this.localWork.fullLayer=this.fullLayer;this.localWork.drawLayer=void 0;this.snapshotFullLayer.removeAllChildren();this.setCameraOpt(a,this.fullLayer);case 27:case"end":return _context100.stop();}},_callee95,this);}));function getBoundingRect(_x107){return _getBoundingRect.apply(this,arguments);}return getBoundingRect;}()}]);}(Ai);var Wn=self;Wn.full=new Sm(Wn,qe.Full);
|
|
444
|
+
tt(xe,"eraserSizes",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 Xe=xe;var Te=/*#__PURE__*/function(_vt15){function Te(t){var _this87;_classCallCheck(this,Te);_this87=_callSuper(this,Te,[t]);tt(_this87,"canRotate",!1);tt(_this87,"scaleType",Nt.none);tt(_this87,"toolsType",dt.BitMapEraser);tt(_this87,"tmpPoints",[]);tt(_this87,"workOptions");tt(_this87,"worldPosition");tt(_this87,"worldScaling");tt(_this87,"eraserRect");tt(_this87,"eraserPolyline");tt(_this87,"syncUnitTime",re.syncOpt.interval);tt(_this87,"syncIndex",0);tt(_this87,"syncTimestamp");_this87.workOptions=t.toolsOpt,_this87.worldPosition=_this87.fullLayer.worldPosition,_this87.worldScaling=_this87.fullLayer.worldScaling,_this87.syncTimestamp=0;return _this87;}/** 批量合并消费本地数据,返回绘制结果 */_inherits(Te,_vt15);return _createClass(Te,[{key:"combineConsume",value:function combineConsume(){if(this.tmpPoints.length<2)return{type:ot.None};var t=this.workOptions.thickness,_Te$eraserSizes$t=Te.eraserSizes[t],e=_Te$eraserSizes$t.width,n=_Te$eraserSizes$t.height,i=Math.max(e,n)/this.worldScaling[0],a=this.drawLayer||this.fullLayer,o=this.workId,s={name:o};return{rect:this.draw({attrs:s,consumePoints:this.tmpPoints,replaceId:o,layer:a,thickness:i}),type:ot.DrawWork,dataType:Tt.Local};}},{key:"consumeService",value:function consumeService(t){var e=t.op,n=t.isFullWork,i=t.replaceId;this.tmpPoints.length=0;for(var c=0;c<e.length;c+=3){var d=new xt(e[c],e[c+1],e[c+2]);if(this.tmpPoints.length>0){var y=this.tmpPoints[this.tmpPoints.length-1],P=_.Sub(d,y).uni();d.setv(P);}this.tmpPoints.push(d);}if(this.tmpPoints.length<2)return;var a=this.tmpPoints[0].z*2,o=n?this.fullLayer:this.drawLayer||this.fullLayer,l={name:this.workId};return this.draw({attrs:l,consumePoints:this.tmpPoints,layer:o,thickness:a,replaceId:i});}},{key:"updateTempPoints",value:function updateTempPoints(t,e){var n=this.tmpPoints.length-1;var i=Date.now();for(var a=0;a<t.length;a+=2){var o=this.tmpPoints.length,s=new xt(t[a],t[a+1]);if(o===0){this.tmpPoints.push(s);continue;}var l=o-1,g=this.tmpPoints[l],c=_.Sub(s,g).uni();s.isNear(g,e/2)||(_.Equals(c,g.v,0.02)&&(this.tmpPoints.pop(),n--),s.setv(c),s.setT(i),this.tmpPoints.push(s));}return Math.max(n,0);}},{key:"getChangeNodes",value:function getChangeNodes(t,e){var n=/* @__PURE__ */new Map(),i=/* @__PURE__ */new Set();var a;if(!this.vNodes)return{willDeleteNodes:i,willUpdateNodes:n,rect:a};var o=this.worldPosition;var s=Ft(this.tmpPoints,t);s=Sr(s,o),s=Gp(s,this.worldScaling,o);var _this$vNodes$getRectI3=this.vNodes.getRectIntersectRange(s),l=_this$vNodes$getRectI3.nodeRange;if(!l.size)return{willDeleteNodes:i,willUpdateNodes:n,rect:a};var g=this.computEraserPointLines(this.tmpPoints);var _iterator32=_createForOfIteratorHelper(l.entries()),_step32;try{for(_iterator32.s();!(_step32=_iterator32.n()).done;){var _step32$value=_slicedToArray(_step32.value,2),c=_step32$value[0],d=_step32$value[1];if(d.toolsType===dt.Text||d.toolsType===dt.Image)continue;var y=Sr(d.rect,[-o[0],-o[1]]);y={x:y.x/this.worldScaling[0],y:y.y/this.worldScaling[1],w:y.w/this.worldScaling[0],h:y.h/this.worldScaling[1]};var P=[y.x,y.y,y.x+y.w,y.y+y.h],S=[],v=[];var _iterator33=_createForOfIteratorHelper(g),_step33;try{for(_iterator33.s();!(_step33=_iterator33.n()).done;){var _f35=_step33.value;Dr.polyline(_f35,P,S);}}catch(err){_iterator33.e(err);}finally{_iterator33.f();}if(S.length&&d.opt){var _iterator34=_createForOfIteratorHelper(S),_step34;try{for(_iterator34.s();!(_step34=_iterator34.n()).done;){var _f33=_step34.value;var p=[];for(var u=0;u<_f33.length;u++)u!==0&&le(_f33[u],_f33[u-1])||p.push.apply(p,_toConsumableArray(_f33[u]));v.push(p);}}catch(err){_iterator34.e(err);}finally{_iterator34.f();}}if(d.opt.eraserlines||(d.opt.eraserlines=[]),d.opt.eraserlines){if(d.opt.eraserlines.push({op:v,thickness:t}),e){var _f34=d.toolsType,_p13=e.createWorkShapeNode({workId:c,toolsType:_f34,toolsOpt:d.opt});_p13==null||_p13.setWorkId(c);var _u14=_p13==null?void 0:_p13.consumeService({op:d.op,isFullWork:!0,replaceId:c});if(a=Pt(a,_u14),_p13!=null&&_p13.isDelete){e.removeNode(c),i.add(c);continue;}}n.set(c,d);}}}catch(err){_iterator32.e(err);}finally{_iterator32.f();}return{willUpdateNodes:n,willDeleteNodes:i,rect:a};}},{key:"consume",value:function consume(t){var e=t.data,n=t.isFullWork,i=t.isSubWorker,a=t.isMainThread,o=t.removeDrawCount,s=t.drawCount,l=e.op;if(!l||l.length===0)return _objectSpread({type:ot.None},this.baseConsumeResult);var g=this.workOptions.thickness,_Te$eraserSizes$g=Te.eraserSizes[g],c=_Te$eraserSizes$g.width,d=_Te$eraserSizes$g.height,y=Math.max(c,d)/this.worldScaling[0],P=this.tmpPoints.length,S=this.tmpPoints[this.tmpPoints.length-1],v=this.updateTempPoints(l,y),T=this.tmpPoints[this.tmpPoints.length-1];if(P===this.tmpPoints.length&&T.equalsXY(S.x,S.y))return _objectSpread({type:ot.None},this.baseConsumeResult);this.syncIndex=Math.min(this.syncIndex,v,Math.max(0,this.tmpPoints.length-2));var f={name:this.workId,id:Vt(s)&&s.toString()||void 0},p=this.syncIndex;this.syncTimestamp===0&&(this.syncTimestamp=Date.now());var u=!1,m;var M=this.tmpPoints.slice(v);if(i||a){var A=n?this.fullLayer:this.drawLayer||this.fullLayer;m=this.draw({attrs:f,consumePoints:M,layer:A,removeDrawCount:o,thickness:y});}if(i)return v>10&&this.tmpPoints.splice(0,v-10),{rect:m,type:ot.DrawWork,dataType:Tt.Local};M[0].t-this.syncTimestamp>this.syncUnitTime&&(u=!0,this.syncTimestamp=M[0].t,this.syncIndex=this.tmpPoints.length);var O=[];return this.tmpPoints.slice(p).forEach(function(A){O.push(A.x,A.y,y/2);}),_objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:ot.DrawWork,dataType:Tt.Local,rect:m,op:u?O:void 0,index:u?p*3:void 0,updateNodeOpt:{useAnimation:!0}});}},{key:"draw",value:function draw(t){var e=t.attrs,n=t.consumePoints,i=t.layer,a=t.thickness,o=t.replaceId,s=t.removeDrawCount;s&&this.removeDrawCountNodes(i,s);var l=Ft(n,a);l={x:Math.floor(l.x*this.worldScaling[0]+this.worldPosition[0]-vt.SafeBorderPadding),y:Math.floor(l.y*this.worldScaling[1]+this.worldPosition[1]-vt.SafeBorderPadding),w:Math.floor(l.w*this.worldScaling[0]+2*vt.SafeBorderPadding),h:Math.floor(l.h*this.worldScaling[1]+2*vt.SafeBorderPadding)};var g=new Zt(_objectSpread(_objectSpread({},e),{},{normalize:!0,pos:[0,0],anchor:[0.5,0.5],zIndex:9999,bgcolor:"rgba(136,136,136,0.3)"})),c=this.computEraserPointLines(n),d=[];var _iterator35=_createForOfIteratorHelper(c),_step35;try{for(_iterator35.s();!(_step35=_iterator35.n()).done;){var _y13=_step35.value;d.push({op:_y13,thickness:a});}}catch(err){_iterator35.e(err);}finally{_iterator35.f();}for(var _i10=0,_d5=d;_i10<_d5.length;_i10++){var y=_d5[_i10];var P=y.thickness,S=y.op,v=S.reduce(function(m,M,O,A){return O>0&&A[O-1][0]===M[0]&&A[O-1][1]===M[1]?m:m.concat(M[0],M[1]);},[]),_T40=this.computEraserPoints(v,P),_f36=ie(_T40,!0),p={pos:[0,0],d:_f36,fillColor:"rgba(136,136,136,0.3)"},u=new se(p);g.append(u),g.seal();}return this.replace(i,o,g),l;}},{key:"computEraserPointLines",value:function computEraserPointLines(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:60;var n=[];var i=0;var a=360-e;for(var o=1;o<t.length;o++){var s=t[o-1],l=t[o];if(o===1&&i===0&&(n[i]=[s.XY]),n[i].push(l.XY),o<t.length-1){var g=l.getAngleByPoints(s,t[o+1]);(g<e||g>a)&&(i++,n[i]=[l.XY]);}}return t.length===1&&n.length===0&&n.push([t[0].XY,t[0].XY]),n;}},{key:"consumeAll",value:function consumeAll(t){var e=t.workerEngine;if(this.replace(this.fullLayer,this.workId),!this.tmpPoints.length)return _objectSpread({type:ot.None},this.baseConsumeResult);var n=this.workOptions.thickness,_Te$eraserSizes$n=Te.eraserSizes[n],i=_Te$eraserSizes$n.width,a=_Te$eraserSizes$n.height,o=Math.max(i,a)/this.worldScaling[0],_this$getChangeNodes=this.getChangeNodes(o,e),s=_this$getChangeNodes.willDeleteNodes,l=_this$getChangeNodes.willUpdateNodes,g=_this$getChangeNodes.rect;if(s.size===0&&l.size===0)return _objectSpread(_objectSpread({type:ot.FullWork},this.baseConsumeResult),{},{rect:g});var c=[];this.tmpPoints.map(function(y){c.push(y.x,y.y,o/2);});var d=Qt(c);return _objectSpread(_objectSpread({},this.baseConsumeResult),{},{type:ot.FullWork,dataType:Tt.Local,rect:g,ops:d,willUpdateNodes:l,willDeleteNodes:s});}},{key:"clearTmpPoints",value:function clearTmpPoints(){this.tmpPoints.length=0;}}]);}(vt);// 来源于white-sdk
|
|
445
|
+
tt(Te,"eraserSizes",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 Je=Te;function Pi(h){switch(h){case dt.Arrow:return mi;case dt.Pencil:return ui;case dt.Straight:return Mi;case dt.Ellipse:return vi;case dt.Polygon:case dt.Triangle:return xi;case dt.Star:case dt.Rhombus:return Si;case dt.Rectangle:return yi;case dt.SpeechBalloon:return Ti;case dt.Text:return ke;case dt.LaserPen:return di;case dt.Eraser:return ae;case dt.PencilEraser:return Xe;case dt.BitMapEraser:return Je;case dt.Selector:return Ve;case dt.Image:return Ne;}}function Fr(h,r){var t=h.toolsType,e=_objectWithoutProperties(h,_excluded);switch(t){case dt.Arrow:return new mi(e);case dt.Pencil:return new ui(e);case dt.Straight:return new Mi(e);case dt.Ellipse:return new vi(e);case dt.Polygon:case dt.Triangle:return new xi(e);case dt.Star:case dt.Rhombus:return new Si(e);case dt.Rectangle:return new yi(e);case dt.SpeechBalloon:return new Ti(e);case dt.Text:return new ke(e);case dt.LaserPen:return new di(e);case dt.Eraser:return new ae(e,r);case dt.BitMapEraser:return new Je(e);case dt.PencilEraser:return new Xe(e,r);case dt.Selector:return e.vNodes?new Ve(_objectSpread(_objectSpread({},e),{},{vNodes:e.vNodes,drawLayer:e.fullLayer})):void 0;case dt.Image:return new Ne(e);default:return;}}function Oi(h){var r=[],t=["PATH","SPRITE","POLYLINE","RECT","ELLIPSE","LABEL"];var _iterator36=_createForOfIteratorHelper(h),_step36;try{for(_iterator36.s();!(_step36=_iterator36.n()).done;){var _e7=_step36.value;if(_e7.tagName==="GROUP"&&_e7.children.length)return Oi(_e7.children);_e7.tagName&&t.includes(_e7.tagName)&&r.push(_e7);}}catch(err){_iterator36.e(err);}finally{_iterator36.f();}return r;}function Pt(h,r){if(h&&r){var t=Math.min(h.x,r.x),_e8=Math.min(h.y,r.y),n=Math.max(h.x+h.w,r.x+r.w),i=Math.max(h.y+h.h,r.y+r.h),a=n-t,o=i-_e8;return{x:t,y:_e8,w:a,h:o};}return r||h;}function Ft(h){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var t={x:0,y:0,w:0,h:0};var e=1/0,n=1/0,i=-1/0,a=-1/0;return h.forEach(function(o){var _o$XY=_slicedToArray(o.XY,2),s=_o$XY[0],l=_o$XY[1];e=Math.min(e,s-r),n=Math.min(n,l-r),i=Math.max(i,s+r),a=Math.max(a,l+r);}),t.x=e,t.y=n,t.w=i-e,t.h=a-n,t;}function We(h,r){return!(h.x+h.w<r.x||h.x>r.x+r.w||h.y+h.h<r.y||h.y>r.y+r.h);}function Dt(h){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:10;return{x:Math.floor(h.x-r),y:Math.floor(h.y-r),w:Math.ceil(h.w+r*2),h:Math.ceil(h.h+r*2)};}function Sr(h,r){return{x:h.x+r[0],y:h.y+r[1],w:h.w,h:h.h};}function zp(h,r){var t=new _(h.x,h.y),e=new _(h.x+h.w,h.y),n=new _(h.x+h.w,h.y+h.h),i=new _(h.x,h.y+h.h),a=new _(h.x+h.w/2,h.y+h.h/2),o=Math.PI*r/180,s=_.RotWith(t,a,o),l=_.RotWith(e,a,o),g=_.RotWith(n,a,o),c=_.RotWith(i,a,o);return[s,l,g,c];}function Ei(h,r){var t=zp(h,r);return Ft(t);}function Gp(h,r,t){var e=new _(h.x,h.y),n=new _(h.x+h.w,h.y),i=new _(h.x+h.w,h.y+h.h),a=new _(h.x,h.y+h.h),o=new _(t[0],t[1]),s=new _(r[0],r[1]),l=_.ScaleWOrigin(e,s,o),g=_.ScaleWOrigin(n,s,o),c=_.ScaleWOrigin(i,s,o),d=_.ScaleWOrigin(a,s,o);return Ft([l,g,c,d]);}function Hp(h,r,t){var e=new _(r[0],r[1]);for(var n=0;n<h.length;n+=3){var i=new _(h[n],h[n+1]),a=Math.PI*t/180,o=_.RotWith(i,e,a);h[n]=o.x,h[n+1]=o.y;}}function Kp(h,r,t){var e=new _(r[0],r[1]);for(var n=0;n<h.length;n+=2){var i=new _(h[n],h[n+1]),a=Math.PI*t/180,o=_.RotWith(i,e,a);h[n]=o.x,h[n+1]=o.y;}}function Ur(h,r,t){var e=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[0,0];var n=new _(r[0],r[1]);for(var i=0;i<h.length;i+=3){var a=new _(h[i],h[i+1]),o=new _(t[0],t[1]),s=_.ScaleWOrigin(a,o,n);h[i]=s.x+e[0],h[i+1]=s.y+e[1];}}function jr(h,r,t){var e=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[0,0];var n=new _(r[0],r[1]);for(var i=0;i<h.length;i+=2){var a=new _(h[i],h[i+1]),o=new _(t[0],t[1]),s=_.ScaleWOrigin(a,o,n);h[i]=s.x+e[0],h[i+1]=s.y+e[1];}}function Yp(h,r){return h[0]>=r.x&&h[0]<=r.x+r.w&&h[1]>=r.y&&h[1]<=r.y+r.h;}function Ci(h,r){var t=h<=r?1:h/r,e=r<=h?1:r/h;return[t,e];}function Vp(h){var _iterator37=_createForOfIteratorHelper(h),_step37;try{for(_iterator37.s();!(_step37=_iterator37.n()).done;){var r=_step37.value;if(isNaN(r)||r===1/0||r===-1/0)return!1;}}catch(err){_iterator37.e(err);}finally{_iterator37.f();}return!0;}function kp(h){return h!==Math.floor(h);}function Xp(h){var r=h.toString();return r.indexOf(".")!==-1?r.split(".")[1].length:0;}function Jp(h,r){for(;r!==0;){var _ref168=[r,h%r];h=_ref168[0];r=_ref168[1];}return h;}var Zp=function Zp(h){if(h.tagName==="GROUP"){var r=Object.getOwnPropertySymbols(h).find(function(t){return t.toString()==="Symbol(sealed)";});if(r&&h[r])return!0;}return!1;};function ge(h){return"".concat(Ze(h.x),",").concat(Ze(h.y)," ");}function me(h,r){return"".concat(Ze((h.x+r.x)/2),",").concat(Ze((h.y+r.y)/2)," ");}function Ze(h){return+h.toFixed(4);}var fr=function fr(h,r){return h.x+h.w<r.x||h.x>r.x+r.w||h.y+h.h<r.y||h.y>r.y+r.h?Me.outside:h.x>=r.x&&h.y>=r.y&&h.x+h.w<=r.x+r.w&&h.y+h.h<=r.y+r.h?Me.inside:Me.intersect;};function Qp(h){var r=0;for(var t=0;t<h.length;t++){var _e9=h.charCodeAt(t);_e9>=1&&_e9<=126||65376<=_e9&&_e9<=65439?r++:r+=2;}return r;}var be="cursorhover",Cn=20,Qe="mainView";var qp=/*#__PURE__*/function(){function qp(r,t){_classCallCheck(this,qp);tt(this,"viewId");tt(this,"scene");tt(this,"fullLayer");tt(this,"curNodeMap",/* @__PURE__ */new Map());tt(this,"targetNodeMap",[]);tt(this,"highLevelIds");tt(this,"canClearUids");tt(this,"localUid");this.viewId=r,this.scene=t;}return _createClass(qp,[{key:"init",value:function init(r){this.fullLayer=r;}},{key:"get",value:function get(r){return this.curNodeMap.get(r);}},{key:"setLocalUid",value:function setLocalUid(r){this.localUid=r;}},{key:"getLocalUid",value:function getLocalUid(){return this.localUid;}},{key:"setCanClearUids",value:function setCanClearUids(r){this.canClearUids=r;}},{key:"getCanClearUids",value:function getCanClearUids(){return this.canClearUids;}},{key:"getCanEraserNodes",value:function getCanEraserNodes(r,t){var e=/* @__PURE__ */new Map();var _iterator38=_createForOfIteratorHelper(r.entries()),_step38;try{for(_iterator38.s();!(_step38=_iterator38.n()).done;){var _step38$value=_slicedToArray(_step38.value,2),n=_step38$value[0],i=_step38$value[1];i.toolsType===dt.Image&&(i.opt.locked||t&&t.disableEraseImage)||i.toolsType===dt.Text&&(i.opt.workState===It.Doing||i.opt.workState===It.Start||t&&t.disableEraseText)||this.isCanClearWorkId(n)&&e.set(n,i);}}catch(err){_iterator38.e(err);}finally{_iterator38.f();}return e;}},{key:"getNodesByType",value:function getNodesByType(r){var t=/* @__PURE__ */new Map();return this.curNodeMap.forEach(function(e,n){e.toolsType===r&&t.set(n,e);}),t;}},{key:"gethasEraserNodes",value:function gethasEraserNodes(){var r=/* @__PURE__ */new Map();return this.curNodeMap.forEach(function(t,e){var n;(n=t.opt.eraserlines)!=null&&n.length&&r.set(e,t);}),r;}},{key:"hasRenderNodes",value:function hasRenderNodes(){return!0;}},{key:"has",value:function has(r){return this.curNodeMap.has(r);}},{key:"setInfo",value:function setInfo(r,t){var e=this.curNodeMap.get(r)||{name:r,rect:t.rect};t.rect&&(e.rect=Jt(t.rect)),t.op&&Vp(t.op)&&(e.op=Jt(t.op)),t.canRotate&&(e.canRotate=t.canRotate),t.scaleType&&(e.scaleType=t.scaleType),t.opt&&(e.opt=Jt(t.opt)),t.toolsType&&(e.toolsType=t.toolsType),t.centerPos&&(e.centerPos=Jt(t.centerPos)),ye(t.isSelected)&&(e.isSelected=t.isSelected),e.rect?this.curNodeMap.set(r,e):this.curNodeMap["delete"](r);}},{key:"selected",value:function selected(r){this.setInfo(r,{isSelected:!0});}},{key:"unSelected",value:function unSelected(r){this.setInfo(r,{isSelected:!1});}},{key:"delete",value:function _delete(r){this.curNodeMap["delete"](r);}},{key:"clear",value:function clear(){this.curNodeMap.clear(),this.targetNodeMap.length=0;}},{key:"getRectIntersectRange",value:function getRectIntersectRange(r){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var e=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!0;var n;var i=/* @__PURE__ */new Map();var _iterator39=_createForOfIteratorHelper(this.curNodeMap.entries()),_step39;try{for(_iterator39.s();!(_step39=_iterator39.n()).done;){var _step39$value=_slicedToArray(_step39.value,2),a=_step39$value[0],o=_step39$value[1];if(We(r,o.rect)){if(t&&o.toolsType===dt.Image&&o.opt.locked||e&&o.toolsType===dt.Text&&(o.opt.workState===It.Doing||o.opt.workState===It.Start))continue;n=Pt(n,o.rect),i.set(a,o);}}}catch(err){_iterator39.e(err);}finally{_iterator39.f();}return{rectRange:n,nodeRange:i};}},{key:"getNodeRectFormShape",value:function getNodeRectFormShape(r,t){var e=Pi(t.toolsType);return this.fullLayer&&(e==null?void 0:e.getRectFromLayer(this.fullLayer,r));}},{key:"updateNodeRect",value:function updateNodeRect(r){var t=this.curNodeMap.get(r);if(t){var _e10=this.getNodeRectFormShape(r,t);if(!_e10){this.curNodeMap["delete"](r);return;}t.rect=_e10,this.curNodeMap.set(r,t);}}},{key:"updateHighLevelNodesRect",value:function updateHighLevelNodesRect(r){this.highLevelIds=r;var _iterator40=_createForOfIteratorHelper(this.highLevelIds.keys()),_step40;try{for(_iterator40.s();!(_step40=_iterator40.n()).done;){var t=_step40.value;this.updateNodeRect(t);}}catch(err){_iterator40.e(err);}finally{_iterator40.f();}}},{key:"updateLowLevelNodesRect",value:function updateLowLevelNodesRect(){var r;var _iterator41=_createForOfIteratorHelper(this.curNodeMap.keys()),_step41;try{for(_iterator41.s();!(_step41=_iterator41.n()).done;){var t=_step41.value;(r=this.highLevelIds)!=null&&r.has(t)||this.updateNodeRect(t);}}catch(err){_iterator41.e(err);}finally{_iterator41.f();}}},{key:"clearHighLevelIds",value:function clearHighLevelIds(){this.highLevelIds=void 0;}},{key:"setTargetAssignKeys",value:function setTargetAssignKeys(r){var t=/* @__PURE__ */new Map();var _iterator42=_createForOfIteratorHelper(r),_step42;try{for(_iterator42.s();!(_step42=_iterator42.n()).done;){var _e11=_step42.value;var n=this.curNodeMap.get(_e11);n&&t.set(_e11,Jt(n));}}catch(err){_iterator42.e(err);}finally{_iterator42.f();}return this.targetNodeMap.push(Jt(t)),this.targetNodeMap.length-1;}},{key:"setTarget",value:function setTarget(){return this.targetNodeMap.push(Jt(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(r){return this.targetNodeMap[r];}},{key:"deleteTarget",value:function deleteTarget(r){this.targetNodeMap.length=r;}},{key:"clearTarget",value:function clearTarget(){this.targetNodeMap.length=0;}},{key:"isLocalWorkId",value:function isLocalWorkId(r){return r.split(De).length===1;}},{key:"isCanClearWorkId",value:function isCanClearWorkId(r){if(this.canClearUids===void 0||this.canClearUids===!0)return!0;if(Iu(this.canClearUids)){var t=r.split(De);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 Ai=/*#__PURE__*/function(){function Ai(r,t,e){_classCallCheck(this,Ai);tt(this,"viewId");tt(this,"scene");tt(this,"fullLayer");tt(this,"vNodes");tt(this,"dpr");tt(this,"contextType");tt(this,"opt");tt(this,"cameraOpt");tt(this,"isSafari",!1);tt(this,"combinePostMsg",/* @__PURE__ */new Set());tt(this,"workerTaskId");tt(this,"protectedTask");tt(this,"hasPriorityDraw",!0);tt(this,"delayPostDoneResolve");tt(this,"cacheImages",/* @__PURE__ */new Map());tt(this,"imageResolveMap",/* @__PURE__ */new Map());var n,i;if(this.viewId=r,this.opt=t,this.dpr=t.dpr,this.contextType=this.getSupportContextType(e,(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.createRenderLayer(t);}catch(_unused24){if(this.contextType!=="2d")this.contextType="2d",(i=this.scene)==null||i.disconnect(),this.createRenderLayer(t);else throw new Error("Sorry, your browser doesn't support canvas context type ".concat(this.contextType));}this.vNodes=new qp(r,this.scene);}return _createClass(Ai,[{key:"createRenderLayer",value:function createRenderLayer(r){this.scene=this.createScene(r.offscreenCanvasOpt);var t=re.bufferSize.full,e=re.bufferSize.sub;this.fullLayer=this.createLayer("fullLayer",this.scene,_objectSpread(_objectSpread({},r.layerOpt),{},{bufferSize:this.viewId===Qe?t:e*2}));}},{key:"updateDpr",value:function(){var _updateDpr=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28(r){return _regeneratorRuntime().wrap(function _callee28$(_context30){while(1)switch(_context30.prev=_context30.next){case 0:this.dpr=r,this.scene.displayRatio=r;case 1:case"end":return _context30.stop();}},_callee28,this);}));function updateDpr(_x33){return _updateDpr.apply(this,arguments);}return updateDpr;}()},{key:"getCachedImages",value:function getCachedImages(r){var t;return(t=this.cacheImages.get(r))==null?void 0:t.imageBitmap;}},{key:"getCachedImagesByWorkId",value:function getCachedImagesByWorkId(r){var _iterator43=_createForOfIteratorHelper(this.cacheImages.entries()),_step43;try{for(_iterator43.s();!(_step43=_iterator43.n()).done;){var _step43$value=_slicedToArray(_step43.value,2),t=_step43$value[0],_e12=_step43$value[1];if(t===r&&_e12.imageBitmap)return _e12.imageBitmap;}}catch(err){_iterator43.e(err);}finally{_iterator43.f();}}},{key:"deleteCachedImagesByWorkId",value:function deleteCachedImagesByWorkId(r,t){var _iterator44=_createForOfIteratorHelper(this.cacheImages.entries()),_step44;try{for(_iterator44.s();!(_step44=_iterator44.n()).done;){var _step44$value=_slicedToArray(_step44.value,2),_e13=_step44$value[0],n=_step44$value[1];t&&_e13===t||n.workId===r&&(n.imageBitmap.close(),this.cacheImages["delete"](_e13));}}catch(err){_iterator44.e(err);}finally{_iterator44.f();}}},{key:"clearCacheImages",value:function clearCacheImages(){this.cacheImages.forEach(function(r){return r.imageBitmap.close();}),this.cacheImages.clear();}},{key:"clearImageResolveMap",value:function clearImageResolveMap(){this.imageResolveMap.forEach(function(_ref169){var r=_ref169.timer;r&&clearTimeout(r);}),this.imageResolveMap.clear();}},{key:"setHasPriorityDraw",value:function setHasPriorityDraw(r){this.hasPriorityDraw=r;}},{key:"getPriorityDraw",value:function getPriorityDraw(){return this.hasPriorityDraw;}},{key:"setIsSafari",value:function setIsSafari(r){this.isSafari=r;}},{key:"on",value:function(){var _on=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee29(r){var t,e,n,i,a,o,s,l,_l6,g,c,d;return _regeneratorRuntime().wrap(function _callee29$(_context31){while(1)switch(_context31.prev=_context31.next){case 0:t=r.msgType,e=r.toolsType,n=r.opt,i=r.imageSrc,a=r.imageBitmap,o=r.workId,s=r.dpr;_context31.t0=t;_context31.next=_context31.t0===ot.UpdateDpr?4:_context31.t0===ot.UpdateCamera?9:_context31.t0===ot.Destroy?12:_context31.t0===ot.Clear?14:_context31.t0===ot.UpdateTools?17:_context31.t0===ot.GetImageBitMap?19:21;break;case 4:_context31.t1=Vt(s);if(!_context31.t1){_context31.next=8;break;}_context31.next=8;return this.updateDpr(s);case 8:return _context31.abrupt("break",21);case 9:_context31.next=11;return this.updateCamera(r);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(e&&n){l={toolsType:e,toolsOpt:n};this.localWork.setToolsOpt(l);}return _context31.abrupt("break",21);case 19:if(i&&a&&o){_l6=o.toString();this.cacheImages.set(i,{imageBitmap:a,workId:_l6});g=this.imageResolveMap.get(i);if(g){c=g.resolve,d=g.timer;d&&clearTimeout(d),c&&c(i);}this.deleteCachedImagesByWorkId(_l6,i);}return _context31.abrupt("break",21);case 21:case"end":return _context31.stop();}},_callee29,this);}));function on(_x34){return _on.apply(this,arguments);}return on;}()},{key:"getIconSize",value:function getIconSize(r,t,e){var n=r*e,i=t*e;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(r){var _this88=this;var t,e,n,i,a,o,s,l,g,c,d,_this$getIconSize,_this$getIconSize2,v,_T41,_v9,_v10,S;return _regeneratorRuntime().wrap(function _callee30$(_context32){while(1)switch(_context32.prev=_context32.next){case 0:t=r.toolsType,e=r.opt,n=r.workId,i=r.isSubWorker;if(!(t===dt.Image&&e&&n)){_context32.next=19;break;}a=n.toString(),o=e.src,s=e.type,l=e.width,g=e.height,c=e.strokeColor;if(!(!o||!s||!l||!g)){_context32.next=5;break;}return _context32.abrupt("return");case 5:d=o;if(s===xr.Iconify){_this$getIconSize=this.getIconSize(l,g,this.dpr),_this$getIconSize2=_slicedToArray(_this$getIconSize,2),v=_this$getIconSize2[0],_T41=_this$getIconSize2[1];d="".concat(o,"?width=").concat(v,"&height=").concat(_T41,"&color=").concat(c);}if(!this.cacheImages.has(d)){_context32.next=11;break;}_v9=this.getCachedImages(d);if(!_v9){_context32.next=11;break;}return _context32.abrupt("return",_v9);case 11:if(!this.imageResolveMap.has(d)){_context32.next=15;break;}_v10=this.getCachedImagesByWorkId(a);if(!_v10){_context32.next=15;break;}return _context32.abrupt("return",_v10);case 15:_context32.next=17;return new Promise(function(v){var T=_this88.imageResolveMap.get(d)||{resolve:void 0,timer:void 0};T.timer&&clearTimeout(T.timer),T.resolve=v,T.timer=setTimeout(function(){var f=_this88.imageResolveMap.get(d);f!=null&&f.resolve&&f.resolve(d);},5e3),_this88.imageResolveMap.set(d,T),_this88._post({sp:[{imageSrc:d,workId:a,viewId:_this88.viewId,isgl:!!_this88.fullLayer.parent.gl,isSubWorker:i,type:ot.GetImageBitMap}]});});case 17:S=_context32.sent;return _context32.abrupt("return",(this.imageResolveMap["delete"](S),this.getCachedImages(d)));case 19:case"end":return _context32.stop();}},_callee30,this);}));function loadImageBitMap(_x35){return _loadImageBitMap.apply(this,arguments);}return loadImageBitMap;}()},{key:"createLocalWork",value:function createLocalWork(r){var t=r.workId,e=r.opt,n=r.toolsType;t&&e&&(!this.localWork.getToolsOpt()&&n&&this.setToolsOpt({toolsType:n,toolsOpt:e}),this.setWorkOpt({workId:t,toolsOpt:e}));}},{key:"updateScene",value:function updateScene(r){this.scene.attr(_objectSpread({},r));var t=r.width,e=r.height;this.scene.container.width=t,this.scene.container.height=e,this.scene.width=t,this.scene.height=e,this.updateLayer({width:t,height:e});}},{key:"updateLayer",value:function updateLayer(r){var t=r.width,e=r.height;this.fullLayer&&(this.fullLayer.parent.setAttribute("width",t),this.fullLayer.parent.setAttribute("height",e),this.fullLayer.setAttribute("size",[t,e]),this.fullLayer.setAttribute("pos",[t*0.5,e*0.5]));}},{key:"getSupportContextType",value:function getSupportContextType(r,t){var e=new OffscreenCanvas(100,100);var n=["2d"];r===qe.Full&&this.viewId===Qe&&(n=["webgl2","webgl","2d"],t&&n.unshift(t));for(var _i11=0,_n7=n;_i11<_n7.length;_i11++){var i=_n7[_i11];try{if(e.getContext(i))return i;}catch(_unused25){continue;}}}},{key:"createScene",value:function createScene(r){var t=r.width,e=r.height,n=new OffscreenCanvas(t,e);r.contextType&&delete r.contextType;var i=new ts(_objectSpread(_objectSpread({container:n,displayRatio:this.dpr,depth:!1,desynchronized:!0,failIfMajorPerformanceCaveat:!0},r),{},{contextType:this.contextType,id:this.viewId}));return i.setAttribute("id",this.viewId),i;}},{key:"createLayer",value:function createLayer(r,t,e){var n=e.width,i=e.height,a="offscreen-".concat(r),o=t.layer(a,e),s=new Zt({anchor:[0.5,0.5],pos:[n*0.5,i*0.5],size:[n,i],name:"viewport",id:r});return o.append(s),s;}},{key:"clearAll",value:function(){var _clearAll=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee31(){var r;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();}),this.fullLayer.removeAllChildren()),this.clearCacheImages(),this.clearImageResolveMap(),this.localWork.destroy(),(r=this.serviceWork)==null||r.destroy();case 1:case"end":return _context33.stop();}},_callee31,this);}));function clearAll(){return _clearAll.apply(this,arguments);}return clearAll;}()},{key:"setToolsOpt",value:function setToolsOpt(r){this.localWork.setToolsOpt(r);}},{key:"setWorkOpt",value:function setWorkOpt(r){var t=r.workId,e=r.toolsOpt;t&&e&&this.localWork.setWorkOptions(t.toString(),e);}},{key:"destroy",value:function destroy(){var r;this.vNodes.clear(),this.fullLayer.remove(),this.clearCacheImages(),this.clearImageResolveMap(),this.scene.remove(),this.localWork.destroy(),(r=this.serviceWork)==null||r.destroy();}},{key:"post",value:function(){var _post=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee32(r){return _regeneratorRuntime().wrap(function _callee32$(_context34){while(1)switch(_context34.prev=_context34.next){case 0:this.combinePostMsg.add(r);_context34.next=3;return this.runBatchPostData();case 3:case"end":return _context34.stop();}},_callee32,this);}));function post(_x36){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===qe.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,s;this.workerTaskId=void 0;var r=[],t=[];var e,n,i;var a=/* @__PURE__ */new Set();var _iterator45=_createForOfIteratorHelper(this.combinePostMsg.values()),_step45;try{for(_iterator45.s();!(_step45=_iterator45.n()).done;){var l=_step45.value;if((o=l.render)!=null&&o.length){var _iterator46=_createForOfIteratorHelper(l.render),_step46;try{for(_iterator46.s();!(_step46=_iterator46.n()).done;){var g=_step46.value;var c=!1;if(g.workId&&a.add(g.workId),g.isClearAll&&(g.rect=this.getSceneRect(),g.isClear=!0,delete g.isClearAll),g.drawCanvas){var d=this.getLayer(g.drawCanvas);if(!d||!(d.parent instanceof _i))continue;if(d.parent.render(),g.isDrawAll){var y=this.getSceneRect();g.rect=y,delete g.isDrawAll;}}var _iterator47=_createForOfIteratorHelper(r),_step47;try{for(_iterator47.s();!(_step47=_iterator47.n()).done;){var _d6=_step47.value;if(g.viewId===_d6.viewId){g.isClear&&_d6.clearCanvas&&_d6.isClear&&_d6.clearCanvas===g.clearCanvas&&(_d6.rect=Pt(_d6.rect,g.rect),c=!0),_d6.drawCanvas&&_d6.drawCanvas===g.drawCanvas&&(_d6.rect=Pt(_d6.rect,g.rect),c=!0);continue;}}}catch(err){_iterator47.e(err);}finally{_iterator47.f();}c||(g.isClear&&!g.drawCanvas?r.unshift(g):r.push(g));}}catch(err){_iterator46.e(err);}finally{_iterator46.f();}}if((s=l.sp)!=null&&s.length){var _iterator48=_createForOfIteratorHelper(l.sp),_step48;try{for(_iterator48.s();!(_step48=_iterator48.n()).done;){var _g10=_step48.value;var _c6=!1;var _iterator49=_createForOfIteratorHelper(t),_step49;try{for(_iterator49.s();!(_step49=_iterator49.n()).done;){var _d7=_step49.value;if(le(_g10,_d7)){_c6=!0;break;}}}catch(err){_iterator49.e(err);}finally{_iterator49.f();}_c6||t.push(_g10);}}catch(err){_iterator48.e(err);}finally{_iterator48.f();}}Vt(l.fullWorkerDrawCount)&&(e=l.fullWorkerDrawCount),Vt(l.subWorkerDrawCount)&&(n=l.subWorkerDrawCount),Vt(l.consumeCount)&&(i=l.consumeCount);}}catch(err){_iterator45.e(err);}finally{_iterator45.f();}return this.combinePostMsg.clear(),{render:r,sp:t,fullWorkerDrawCount:e,subWorkerDrawCount:n,consumeCount:i,workIds:a,viewId:this.viewId};}},{key:"safariFixRect",value:function safariFixRect(r,t){if(r.w+r.x<=0||r.h+r.y<=0||r.w<=0||r.h<=0)return;var e=this.scene.width,n=this.scene.height,i={x:Math.floor(Math.max(0,r.x)),y:Math.floor(Math.max(0,r.y)),w:Math.floor(Math.min(e,r.w)),h:Math.floor(Math.min(n,r.h))};if(i.x+i.w>e&&(i.w=Math.floor(e-i.x)),i.y+i.h>n&&(i.h=Math.floor(n-i.y)),kp(t)){var a=Xp(t),o=Math.pow(10,a),s=Jp(o,t*o),l=i.x%s,g=i.x-l;g>=0?(i.x=g,i.w=i.w+l):(i.x=0,i.w=i.w+l-g);var c=i.y%s,d=i.y-c;d>=0?(i.y=d,i.h=i.h+c):(i.y=0,i.h=i.h+c-d);}return i;}},{key:"getSceneRect",value:function getSceneRect(){var _this$scene=this.scene,r=_this$scene.width,t=_this$scene.height;return{x:0,y:0,w:Math.floor(r),h:Math.floor(t)};}}]);}();var Ri=/*#__PURE__*/function(){function Ri(r){_classCallCheck(this,Ri);tt(this,"viewId");tt(this,"vNodes");tt(this,"thread");tt(this,"fullLayer");tt(this,"drawLayer");tt(this,"_post");tt(this,"tmpOpt");tt(this,"workShapes",/* @__PURE__ */new Map());tt(this,"drawCount",0);tt(this,"consumeCount",0);tt(this,"syncUnitTime",re.syncOpt.interval);this.thread=r.thread,this.viewId=r.viewId,this.vNodes=r.vNodes,this.fullLayer=r.fullLayer,this.drawLayer=r.drawLayer,this._post=this.thread.post.bind(r.thread);}return _createClass(Ri,[{key:"destroy",value:function destroy(){this.workShapes.clear();}},{key:"getWorkShapes",value:function getWorkShapes(){return this.workShapes;}},{key:"getWorkShape",value:function getWorkShape(r){return this.workShapes.get(r);}},{key:"createWorkShape",value:function createWorkShape(r,t){if(r&&this.tmpOpt){var _e14={toolsType:this.tmpOpt.toolsType,toolsOpt:t||this.tmpOpt.toolsOpt},n=this.createWorkShapeNode(_objectSpread(_objectSpread({},_e14),{},{workId:r}));n&&this.workShapes.set(r,n);}}},{key:"setWorkOptions",value:function setWorkOptions(r,t){var e=this.getWorkShape(r);e||this.createWorkShape(r,t),e==null||e.setWorkOptions(t);}},{key:"createWorkShapeNode",value:function createWorkShapeNode(r){var t;return Fr(_objectSpread(_objectSpread({},r),{},{vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer}),(t=this.thread)==null?void 0:t.serviceWork);}},{key:"setToolsOpt",value:function setToolsOpt(r){var t,e,n;((t=this.tmpOpt)==null?void 0:t.toolsType)!==r.toolsType&&(e=this.tmpOpt)!=null&&e.toolsType&&this.clearAllWorkShapesCache(),this.tmpOpt=r,(n=r.toolsOpt)!=null&&n.syncUnitTime&&(this.syncUnitTime=r.toolsOpt.syncUnitTime);}},{key:"getToolsOpt",value:function getToolsOpt(){return this.tmpOpt;}},{key:"clearWorkShapeNodeCache",value:function clearWorkShapeNodeCache(r){var t;(t=this.getWorkShape(r))==null||t.clearTmpPoints(),this.workShapes["delete"](r);}},{key:"clearAllWorkShapesCache",value:function clearAllWorkShapesCache(){this.workShapes.forEach(function(r){return r.clearTmpPoints();}),this.workShapes.clear();}},{key:"setFullWork",value:function setFullWork(r){var t=r.workId,e=r.opt,n=r.toolsType;if(t&&e&&n){var i=t.toString();var a;return t&&this.workShapes.has(i)?(a=this.workShapes.get(i),a==null||a.setWorkOptions(e)):a=this.createWorkShapeNode({toolsOpt:e,toolsType:n,workId:i}),a?(this.workShapes.set(i,a),a):void 0;}}}]);}();var _p=ee,t0=function t0(){return _p.Date.now();},e0=t0,r0=/\s/;function n0(h){for(var r=h.length;r--&&r0.test(h.charAt(r)););return r;}var i0=n0,s0=i0,o0=/^\s+/;function a0(h){return h&&h.slice(0,s0(h)+1).replace(o0,"");}var l0=a0,c0=de,f0=ne,h0="[object Symbol]";function u0(h){return _typeof(h)=="symbol"||f0(h)&&c0(h)==h0;}var d0=u0,p0=l0,An=he,g0=d0,Rn=NaN,m0=/^[-+]0x[0-9a-f]+$/i,v0=/^0b[01]+$/i,y0=/^0o[0-7]+$/i,S0=parseInt;function x0(h){if(typeof h=="number")return h;if(g0(h))return Rn;if(An(h)){var r=typeof h.valueOf=="function"?h.valueOf():h;h=An(r)?r+"":r;}if(typeof h!="string")return h===0?h:+h;h=p0(h);var t=v0.test(h);return t||y0.test(h)?S0(h.slice(2),t?2:8):m0.test(h)?Rn:+h;}var T0=x0,M0=he,hr=e0,In=T0,P0="Expected a function",O0=Math.max,E0=Math.min;function C0(h,r,t){var e,n,i,a,o,s,l=0,g=!1,c=!1,d=!0;if(typeof h!="function")throw new TypeError(P0);r=In(r)||0,M0(t)&&(g=!!t.leading,c="maxWait"in t,i=c?O0(In(t.maxWait)||0,r):i,d="trailing"in t?!!t.trailing:d);function y(M){var O=e,A=n;return e=n=void 0,l=M,a=h.apply(A,O),a;}function P(M){return l=M,o=setTimeout(T,r),g?y(M):a;}function S(M){var O=M-s,A=M-l,w=r-O;return c?E0(w,i-A):w;}function v(M){var O=M-s,A=M-l;return s===void 0||O>=r||O<0||c&&A>=i;}function T(){var M=hr();if(v(M))return f(M);o=setTimeout(T,S(M));}function f(M){return o=void 0,d&&e?y(M):(e=n=void 0,a);}function p(){o!==void 0&&clearTimeout(o),l=0,e=s=n=o=void 0;}function u(){return o===void 0?a:f(hr());}function m(){var M=hr(),O=v(M);if(e=arguments,n=this,s=M,O){if(o===void 0)return P(s);if(c)return clearTimeout(o),o=setTimeout(T,r),y(s);}return o===void 0&&(o=setTimeout(T,r)),a;}return m.cancel=p,m.flush=u,m;}var A0=C0,R0=A0,I0=he,L0="Expected a function";function w0(h,r,t){var e=!0,n=!0;if(typeof h!="function")throw new TypeError(L0);return I0(t)&&(e="leading"in t?!!t.leading:e,n="trailing"in t?!!t.trailing:n),R0(h,r,{leading:e,maxWait:r,trailing:n});}var b0=w0,D0=/* @__PURE__ */fe(b0);function N0(h){return h;}var Ii=N0;function W0(h,r,t){switch(t.length){case 0:return h.call(r);case 1:return h.call(r,t[0]);case 2:return h.call(r,t[0],t[1]);case 3:return h.call(r,t[0],t[1],t[2]);}return h.apply(r,t);}var B0=W0,F0=B0,Ln=Math.max;function U0(h,r,t){return r=Ln(r===void 0?h.length-1:r,0),function(){for(var e=arguments,n=-1,i=Ln(e.length-r,0),a=Array(i);++n<i;)a[n]=e[r+n];n=-1;for(var o=Array(r+1);++n<r;)o[n]=e[n];return o[r]=t(a),F0(h,this,o);};}var j0=U0;function $0(h){return function(){return h;};}var z0=$0,G0=z0,wn=Gn,H0=Ii,K0=wn?function(h,r){return wn(h,"toString",{configurable:!0,enumerable:!1,value:G0(r),writable:!0});}:H0,Y0=K0,V0=800,k0=16,X0=Date.now;function J0(h){var r=0,t=0;return function(){var e=X0(),n=k0-(e-t);if(t=e,n>0){if(++r>=V0)return arguments[0];}else r=0;return h.apply(void 0,arguments);};}var Z0=J0,Q0=Y0,q0=Z0,_0=q0(Q0),tg=_0,eg=Ii,rg=j0,ng=tg;function ig(h,r){return ng(rg(h,r,eg),h+"");}var sg=ig;function og(h,r,t,e){for(var n=h.length,i=t+(e?1:-1);e?i--:++i<n;)if(r(h[i],i,h))return i;return-1;}var ag=og;function lg(h){return h!==h;}var cg=lg;function fg(h,r,t){for(var e=t-1,n=h.length;++e<n;)if(h[e]===r)return e;return-1;}var hg=fg,ug=ag,dg=cg,pg=hg;function gg(h,r,t){return r===r?pg(h,r,t):ug(h,dg,t);}var mg=gg,vg=mg;function yg(h,r){var t=h==null?0:h.length;return!!t&&vg(h,r,0)>-1;}var Li=yg;function Sg(h,r,t){for(var e=-1,n=h==null?0:h.length;++e<n;)if(t(r,h[e]))return!0;return!1;}var wi=Sg;function xg(h,r){for(var t=-1,e=h==null?0:h.length,n=Array(e);++t<e;)n[t]=r(h[t],t,h);return n;}var Tg=xg,Mg=Nr,Pg=Li,Og=wi,Eg=Tg,Cg=sr,Ag=Wr,Rg=200;function Ig(h,r,t,e){var n=-1,i=Pg,a=!0,o=h.length,s=[],l=r.length;if(!o)return s;t&&(r=Eg(r,Cg(t))),e?(i=Og,a=!1):r.length>=Rg&&(i=Ag,a=!1,r=new Mg(r));t:for(;++n<o;){var g=h[n],c=t==null?g:t(g);if(g=e||g!==0?g:0,a&&c===c){for(var d=l;d--;)if(r[d]===c)continue t;s.push(g);}else i(r,c,e)||s.push(g);}return s;}var Lg=Ig,bn=Be,wg=Vn,bg=Fe,Dn=bn?bn.isConcatSpreadable:void 0;function Dg(h){return bg(h)||wg(h)||!!(Dn&&h&&h[Dn]);}var Ng=Dg,Wg=Lr,Bg=Ng;function bi(h,r,t,e,n){var i=-1,a=h.length;for(t||(t=Bg),n||(n=[]);++i<a;){var o=h[i];r>0&&t(o)?r>1?bi(o,r-1,t,e,n):Wg(n,o):e||(n[n.length]=o);}return n;}var Fg=bi;function Ug(){}var jg=Ug,ur=ni,$g=jg,zg=Br,Gg=1/0,Hg=ur&&1/zg(new ur([,-0]))[1]==Gg?function(h){return new ur(h);}:$g,Kg=Hg,Yg=Nr,Vg=Li,kg=wi,Xg=Wr,Jg=Kg,Zg=Br,Qg=200;function qg(h,r,t){var e=-1,n=Vg,i=h.length,a=!0,o=[],s=o;if(t)a=!1,n=kg;else if(i>=Qg){var l=r?null:Jg(h);if(l)return Zg(l);a=!1,n=Xg,s=new Yg();}else s=r?[]:o;t:for(;++e<i;){var g=h[e],c=r?r(g):g;if(g=t||g!==0?g:0,a&&c===c){for(var d=s.length;d--;)if(s[d]===c)continue t;r&&s.push(c),o.push(g);}else n(s,c,t)||(s!==o&&s.push(c),o.push(g));}return o;}var _g=qg,tm=Lg,em=Fg,Nn=_g;function rm(h,r,t){var e=h.length;if(e<2)return e?Nn(h[0]):[];for(var n=-1,i=Array(e);++n<e;)for(var a=h[n],o=-1;++o<e;)o!=n&&(i[n]=tm(i[n]||a,h[o],r,t));return Nn(em(i,1),r,t);}var nm=rm,im=Cr,sm=ne;function om(h){return sm(h)&&im(h);}var am=om,lm=Qn,cm=sg,fm=nm,hm=am,um=cm(function(h){return fm(lm(h,hm));}),dm=um,pm=/* @__PURE__ */fe(dm);var gm=/*#__PURE__*/function(_Ri){function gm(t){var _this90;_classCallCheck(this,gm);_this90=_callSuper(this,gm,[t]);tt(_this90,"combineUnitTime",re.bezier.combineUnitTime);tt(_this90,"combineTimerId");tt(_this90,"combineDrawResolve");tt(_this90,"combineDrawActiveId");tt(_this90,"drawWorkActiveId");tt(_this90,"effectSelectNodeData",/* @__PURE__ */new Set());tt(_this90,"batchEraserWorks",/* @__PURE__ */new Set());tt(_this90,"batchEraserRemoveNodes",/* @__PURE__ */new Set());tt(_this90,"batchEraserCombine",D0(function(){var t=_this90.updateBatchEraserCombineNode(_this90.batchEraserWorks,_this90.batchEraserRemoveNodes);_this90.batchEraserWorks.clear(),_this90.batchEraserRemoveNodes.clear(),t.length&&_this90._post({render:t});},200,{leading:!1}));return _this90;}_inherits(gm,_Ri);return _createClass(gm,[{key:"loadImageBitMap",value:function(){var _loadImageBitMap2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee34(t){return _regeneratorRuntime().wrap(function _callee34$(_context36){while(1)switch(_context36.prev=_context36.next){case 0:_context36.next=2;return this.thread.loadImageBitMap(t);case 2:return _context36.abrupt("return",_context36.sent);case 3:case"end":return _context36.stop();}},_callee34,this);}));function loadImageBitMap(_x37){return _loadImageBitMap2.apply(this,arguments);}return loadImageBitMap;}()},{key:"consumeDraw",value:function(){var _consumeDraw=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee35(t,e){var _this91=this;var n,i,a,o,s,l,g,c;return _regeneratorRuntime().wrap(function _callee35$(_context37){while(1)switch(_context37.prev=_context37.next){case 0:n=t.op,i=t.workId,a=t.scenePath,o=t.postCount;if(!(n!=null&&n.length&&i)){_context37.next=56;break;}s=i.toString(),l=this.getWorkShape(s);if(l){_context37.next=5;break;}return _context37.abrupt("return");case 5:g=l.toolsType;if(!(g===dt.LaserPen)){_context37.next=8;break;}return _context37.abrupt("return");case 8:_context37.t0=this.combineDrawActiveId&&this.combineDrawActiveId!==s;if(!_context37.t0){_context37.next=13;break;}this.combineTimerId&&(clearTimeout(this.combineTimerId),this.combineTimerId=void 0,this.combineDrawResolve&&this.combineDrawResolve(!1),this.combineDrawActiveId=void 0);_context37.next=13;return this.consumeDrawAll({workId:this.combineDrawActiveId,scenePath:a,viewId:this.viewId,msgType:ot.DrawWork,dataType:Tt.Local},e);case 13:_context37.t1=this.drawWorkActiveId&&this.drawWorkActiveId!==s;if(!_context37.t1){_context37.next=18;break;}_context37.next=17;return this.consumeDrawAll({workId:this.drawWorkActiveId,scenePath:a,viewId:this.viewId,msgType:ot.DrawWork,dataType:Tt.Local},e);case 17:this.drawWorkActiveId=void 0;case 18:!this.drawWorkActiveId&&s!==Wt&&(this.drawWorkActiveId=s);Vt(o)&&(this.consumeCount=o);c=l.consume({data:t,isFullWork:!0});_context37.t2=g;_context37.next=_context37.t2===dt.Selector?24:_context37.t2===dt.PencilEraser?30:_context37.t2===dt.BitMapEraser?33:_context37.t2===dt.Eraser?40:_context37.t2===dt.Arrow?43:_context37.t2===dt.Straight?43:_context37.t2===dt.Ellipse?43:_context37.t2===dt.Rectangle?43:_context37.t2===dt.Star?43:_context37.t2===dt.Polygon?43:_context37.t2===dt.SpeechBalloon?43:_context37.t2===dt.Pencil?49:56;break;case 24:_context37.t3=c.type===ot.Select;if(!_context37.t3){_context37.next=29;break;}c.selectIds&&e.runReverseSelectWork(c.selectIds);_context37.next=29;return this.drawSelector(c);case 29:return _context37.abrupt("break",56);case 30:_context37.next=32;return this.drawPencilEraser(c);case 32:return _context37.abrupt("break",56);case 33:this.drawCount++;this.combineTimerId||new Promise(function(d){_this91.combineDrawActiveId=s,_this91.combineDrawResolve=d,_this91.combineTimerId=setTimeout(function(){_this91.combineTimerId=void 0,_this91.combineDrawResolve&&_this91.combineDrawResolve(!0);},_this91.combineUnitTime);}).then(function(d){d&&_this91.drawBitMapCombine(s,_this91.drawCount),_this91.combineDrawResolve=void 0;});_context37.t4=c;if(!_context37.t4){_context37.next=39;break;}_context37.next=39;return this.drawBitMapEraser(c);case 39:return _context37.abrupt("break",56);case 40:_context37.next=42;return this.drawEraser(c);case 42:return _context37.abrupt("break",56);case 43:_context37.t5=c;if(!_context37.t5){_context37.next=48;break;}this.drawCount++;_context37.next=48;return this.drawShape(c);case 48:return _context37.abrupt("break",56);case 49:this.drawCount++;this.combineTimerId||new Promise(function(d){_this91.combineDrawActiveId=s,_this91.combineDrawResolve=d,_this91.combineTimerId=setTimeout(function(){_this91.combineTimerId=void 0,_this91.combineDrawResolve&&_this91.combineDrawResolve(!0);},_this91.combineUnitTime);}).then(function(d){d&&_this91.drawPencilCombine(s,_this91.drawCount),_this91.combineDrawResolve=void 0;});_context37.t6=c;if(!_context37.t6){_context37.next=55;break;}_context37.next=55;return this.drawPencil(c);case 55:return _context37.abrupt("break",56);case 56:case"end":return _context37.stop();}},_callee35,this);}));function consumeDraw(_x38,_x39){return _consumeDraw.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee36(t,e){var o,s,l,n,i,a,g,c,d,y,P,S;return _regeneratorRuntime().wrap(function _callee36$(_context38){while(1)switch(_context38.prev=_context38.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,a=t.isLockSentEventCursor;if(!n){_context38.next=42;break;}g=n.toString();this.drawWorkActiveId===g&&(this.drawWorkActiveId=void 0);c=this.workShapes.get(g);if(c){_context38.next=8;break;}return _context38.abrupt("return");case 8:d=c.toolsType;if(!(d===dt.LaserPen)){_context38.next=11;break;}return _context38.abrupt("return");case 11:y=this.workShapes.get(be),P=(o=y==null?void 0:y.selectIds)==null?void 0:o[0],S=c.consumeAll({data:t,workerEngine:this});_context38.t0=d;_context38.next=_context38.t0===dt.Selector?15:_context38.t0===dt.PencilEraser?21:_context38.t0===dt.BitMapEraser?23:_context38.t0===dt.Eraser?28:_context38.t0===dt.Arrow?30:_context38.t0===dt.Straight?30:_context38.t0===dt.Ellipse?30:_context38.t0===dt.Rectangle?30:_context38.t0===dt.Star?30:_context38.t0===dt.Polygon?30:_context38.t0===dt.SpeechBalloon?30:_context38.t0===dt.Pencil?35:42;break;case 15:S.selectIds&&P&&(s=S.selectIds)!=null&&s.includes(P)&&y.cursorBlur();S.selectIds&&e.runReverseSelectWork(S.selectIds);_context38.next=19;return this.drawSelector(_objectSpread(_objectSpread({},S),{},{scenePath:i}));case 19:(l=c.selectIds)!=null&&l.length?c.clearTmpPoints():this.clearWorkShapeNodeCache(g);return _context38.abrupt("break",42);case 21:this.drawPencilEraser(_objectSpread(_objectSpread({},S),{},{scenePath:i}),a),c.clearTmpPoints();return _context38.abrupt("break",42);case 23:_context38.next=25;return this.drawBitMapEraserFull(c,_objectSpread(_objectSpread({},S),{},{scenePath:i}),a);case 25:this.drawCount=0;this.clearWorkShapeNodeCache(g);return _context38.abrupt("break",42);case 28:this.drawEraser(_objectSpread(_objectSpread({},S),{},{scenePath:i}),a),c.clearTmpPoints();return _context38.abrupt("break",42);case 30:_context38.next=32;return this.drawPencilFull(_objectSpread(_objectSpread({},S),{},{scenePath:i}),a);case 32:this.drawCount=0;this.clearWorkShapeNodeCache(g);return _context38.abrupt("break",42);case 35:_context38.t1=S!=null&&S.rect;if(!_context38.t1){_context38.next=40;break;}_context38.next=39;return this.drawPencilFull(_objectSpread(_objectSpread({},S),{},{scenePath:i}),a);case 39:this.drawCount=0;case 40:this.clearWorkShapeNodeCache(g);return _context38.abrupt("break",42);case 42:case"end":return _context38.stop();}},_callee36,this);}));function consumeDrawAll(_x40,_x41){return _consumeDrawAll.apply(this,arguments);}return consumeDrawAll;}()},{key:"workShapesDone",value:function(){var _workShapesDone=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee37(t,e){var _iterator50,_step50,n;return _regeneratorRuntime().wrap(function _callee37$(_context39){while(1)switch(_context39.prev=_context39.next){case 0:_iterator50=_createForOfIteratorHelper(this.workShapes.keys());_context39.prev=1;_iterator50.s();case 3:if((_step50=_iterator50.n()).done){_context39.next=9;break;}n=_step50.value;_context39.next=7;return this.consumeDrawAll({workId:n,scenePath:t,viewId:this.viewId,msgType:ot.DrawWork,dataType:Tt.Local},e);case 7:_context39.next=3;break;case 9:_context39.next=14;break;case 11:_context39.prev=11;_context39.t0=_context39["catch"](1);_iterator50.e(_context39.t0);case 14:_context39.prev=14;_iterator50.f();return _context39.finish(14);case 17:case"end":return _context39.stop();}},_callee37,this,[[1,11,14,17]]);}));function workShapesDone(_x42,_x43){return _workShapesDone.apply(this,arguments);}return workShapesDone;}()},{key:"consumeFull",value:function(){var _consumeFull=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee38(t){var i,a,e,n,o,s,l,g,c,d,y;return _regeneratorRuntime().wrap(function _callee38$(_context40){while(1)switch(_context40.prev=_context40.next){case 0:e=this.setFullWork(t),n=t.ops&&Pe(t.ops)||t.op;if(!e){_context40.next=26;break;}o=(i=t.workId)==null?void 0:i.toString();if(o){_context40.next=5;break;}return _context40.abrupt("return");case 5:s=(a=this.vNodes.get(o))==null?void 0:a.rect;if(!(e.toolsType===dt.Image)){_context40.next=13;break;}_context40.next=9;return e.consumeServiceAsync({isFullWork:!0,replaceId:o,worker:this});case 9:l=_context40.sent;g=(t==null?void 0:t.updateNodeOpt)&&e.updataOptService(t.updateNodeOpt);_context40.next=20;break;case 13:if(!(e.toolsType===dt.Text)){_context40.next=19;break;}_context40.next=16;return e.consumeServiceAsync({isFullWork:!0,replaceId:o});case 16:l=_context40.sent;_context40.next=20;break;case 19:l=e.consumeService({op:n,isFullWork:!0,replaceId:o}),g=(t==null?void 0:t.updateNodeOpt)&&e.updataOptService(t.updateNodeOpt);case 20:l=Pt(l,g);c=[],d=[];if(!(t.workId&&this.workShapes["delete"](t.workId.toString()),l&&t.willRefresh&&(s&&c.push({rect:Dt(s),isClear:!0,clearCanvas:St.Bg,viewId:this.viewId}),c.push({rect:Dt(l),drawCanvas:St.Bg,viewId:this.viewId})),t.willSyncService&&d.push({opt:t.opt,toolsType:t.toolsType,type:ot.FullWork,workId:t.workId,ops:t.ops,updateNodeOpt:t.updateNodeOpt,viewId:this.viewId}),c.length||d.length)){_context40.next=26;break;}y={render:c,sp:d};_context40.next=26;return this._post(y);case 26:case"end":return _context40.stop();}},_callee38,this);}));function consumeFull(_x44){return _consumeFull.apply(this,arguments);}return consumeFull;}()},{key:"commandDeleteText",value:function commandDeleteText(t){var e=this.vNodes.get(t);if(e&&e.toolsType===dt.Text)return{type:ot.TextUpdate,toolsType:dt.Text,workId:t,dataType:Tt.Local};}},{key:"removeSelector",value:function(){var _removeSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee39(t,e){var n,i,a,o,s,l,_iterator51,_step51,g,y,d;return _regeneratorRuntime().wrap(function _callee39$(_context41){while(1)switch(_context41.prev=_context41.next){case 0:n=t.willSyncService,i=[],a=[],o=[],s=this.workShapes.get(Wt);if(s){_context41.next=3;break;}return _context41.abrupt("return");case 3:l=s.selectIds&&_toConsumableArray(s.selectIds)||[];_iterator51=_createForOfIteratorHelper(l);try{for(_iterator51.s();!(_step51=_iterator51.n()).done;){g=_step51.value;if(this.vNodes.get(g)){y=this.commandDeleteText(g);y&&i.push(y);}d=this._removeWork(g);d.length&&a.push.apply(a,_toConsumableArray(d)),e==null||e.deleteCachedImagesByWorkId(g),o.push(g);}}catch(err){_iterator51.e(err);}finally{_iterator51.f();}o.length&&i.push({type:ot.RemoveNode,removeIds:o});i.push({type:ot.Select,selectIds:[],willSyncService:n});_context41.next=10;return this.blurSelector();case 10:_context41.t0=a.length||i.length;if(!_context41.t0){_context41.next=14;break;}_context41.next=14;return this._post({render:a,sp:i});case 14:case"end":return _context41.stop();}},_callee39,this);}));function removeSelector(_x45,_x46){return _removeSelector.apply(this,arguments);}return removeSelector;}()},{key:"removeWork",value:function(){var _removeWork2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee40(t){var e,n,i;return _regeneratorRuntime().wrap(function _callee40$(_context42){while(1)switch(_context42.prev=_context42.next){case 0:e=t.workId,n=e==null?void 0:e.toString();if(!n){_context42.next=7;break;}i=this._removeWork(n);_context42.t0=i.length;if(!_context42.t0){_context42.next=7;break;}_context42.next=7;return this._post({render:i});case 7:case"end":return _context42.stop();}},_callee40,this);}));function removeWork(_x47){return _removeWork2.apply(this,arguments);}return removeWork;}()},{key:"removeNode",value:function removeNode(t){var i,a,o;var e=this.vNodes.get(t);e&&((i=this.fullLayer)==null||i.getElementsByName(t).forEach(function(s){s.remove();}),this.vNodes["delete"](t));var n=this.drawLayer&&vt.getRectFromLayer(this.drawLayer,t);if(n){var s=(a=this.drawLayer)==null?void 0:a.getElementsByName(t)[0];(o=this.drawLayer)==null||o.removeChild(s);}return this.getWorkShape(t)&&this.clearWorkShapeNodeCache(t),{fullRect:e==null?void 0:e.rect,drawRect:n};}},{key:"_removeWork",value:function _removeWork(t){var _this$removeNode=this.removeNode(t),e=_this$removeNode.fullRect,n=_this$removeNode.drawRect,i=[];return e&&i.push({rect:Dt(e),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:Dt(e),drawCanvas:St.Bg,viewId:this.viewId}),n&&i.push({rect:Dt(n),clearCanvas:St.Float,isClear:!0,viewId:this.viewId},{rect:Dt(n),drawCanvas:St.Float,viewId:this.viewId}),i;}},{key:"checkTextActive",value:function(){var _checkTextActive=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee41(t){var e,n,i,a,o,s,l,_iterator52,_step52,g,c,d,y,P;return _regeneratorRuntime().wrap(function _callee41$(_context43){while(1)switch(_context43.prev=_context43.next){case 0:e=t.op,n=t.viewId,i=t.dataType;if(!(e!=null&&e.length)){_context43.next=32;break;}s=e[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],l=e[1]*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1];_iterator52=_createForOfIteratorHelper(this.vNodes.curNodeMap.values());_context43.prev=4;_iterator52.s();case 6:if((_step52=_iterator52.n()).done){_context43.next=14;break;}g=_step52.value;c=g.rect,d=g.name,y=g.toolsType,P=g.opt;if(!(y===dt.Text&&P.workState===It.Done&&Yp([s,l],c))){_context43.next=12;break;}a=d,o=this.setFullWork({workId:d,toolsType:y,opt:P});return _context43.abrupt("break",14);case 12:_context43.next=6;break;case 14:_context43.next=19;break;case 16:_context43.prev=16;_context43.t0=_context43["catch"](4);_iterator52.e(_context43.t0);case 19:_context43.prev=19;_iterator52.f();return _context43.finish(19);case 22:_context43.t1=a;if(!_context43.t1){_context43.next=32;break;}_context43.t2=o;if(!_context43.t2){_context43.next=28;break;}_context43.next=28;return o.consumeServiceAsync({isFullWork:!0,replaceId:o.getWorkId(),isDrawLabel:!1});case 28:_context43.next=30;return this.blurSelector({viewId:n,msgType:ot.Select,dataType:i,isSync:!0});case 30:_context43.next=32;return this._post({sp:[{type:ot.GetTextActive,toolsType:dt.Text,workId:a}]});case 32:case"end":return _context43.stop();}},_callee41,this,[[4,16,19,22]]);}));function checkTextActive(_x48){return _checkTextActive.apply(this,arguments);}return checkTextActive;}()},{key:"colloctEffectSelectWork",value:function(){var _colloctEffectSelectWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee42(t){var _this92=this;var e,n,i;return _regeneratorRuntime().wrap(function _callee42$(_context44){while(1)switch(_context44.prev=_context44.next){case 0:e=this.workShapes.get(Wt),n=t.workId,i=t.msgType;if(!(e&&n&&e.selectIds&&e.selectIds.includes(n.toString()))){_context44.next=6;break;}i===ot.RemoveNode?e.selectIds=e.selectIds.filter(function(a){return a!==n.toString();}):this.effectSelectNodeData.add(t);_context44.next=5;return this.runEffectSelectWork(!0).then(function(){var a;(a=_this92.effectSelectNodeData)==null||a.clear();});case 5:return _context44.abrupt("return");case 6:return _context44.abrupt("return",t);case 7:case"end":return _context44.stop();}},_callee42,this);}));function colloctEffectSelectWork(_x49){return _colloctEffectSelectWork.apply(this,arguments);}return colloctEffectSelectWork;}()},{key:"updateSelector",value:function(){var _updateSelector2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee43(t){var _this93=this;var P,e,n,i,a,o,s,l,g,c,d,y;return _regeneratorRuntime().wrap(function _callee43$(_context45){while(1)switch(_context45.prev=_context45.next){case 0:e=this.workShapes.get(Wt);if((P=e==null?void 0:e.selectIds)!=null&&P.length){_context45.next=3;break;}return _context45.abrupt("return");case 3:n=t.callback;i=_objectWithoutProperties(t,_excluded2);a=i.updateSelectorOpt;o=i.willSerializeData;_context45.next=9;return e==null?void 0:e.updateSelector({updateSelectorOpt:a,selectIds:Jt(e.selectIds),vNodes:this.vNodes,willSerializeData:o,worker:this});case 9:s=_context45.sent;l=/* @__PURE__ */new Map();s!=null&&s.selectIds&&(g=pm(e.selectIds,s.selectIds),s.selectIds.forEach(function(S){var v=_this93.vNodes.get(S);if(v){var _T42=v.toolsType,_f37=v.op,p=v.opt;l.set(S,{opt:p,toolsType:_T42,ops:(_f37==null?void 0:_f37.length)&&Qt(_f37)||void 0});}}),e.selectIds=s.selectIds);c=[],d=[];s!=null&&s.rect&&c.push({rect:Dt(s.rect),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:Dt(s.rect),drawCanvas:St.Bg,viewId:this.viewId});y=n&&n({res:s,workShapeNode:e,param:i,postData:{render:c,sp:d},newServiceStore:l})||{render:c,sp:d};g&&y.sp.push({type:ot.RemoveNode,removeIds:g,viewId:this.viewId});_context45.t0=y.render.length||y.sp.length;if(!_context45.t0){_context45.next=20;break;}_context45.next=20;return this._post(y);case 20:case"end":return _context45.stop();}},_callee43,this);}));function updateSelector(_x50){return _updateSelector2.apply(this,arguments);}return updateSelector;}()},{key:"blurSelector",value:function(){var _blurSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee44(t){var i,e,n,a;return _regeneratorRuntime().wrap(function _callee44$(_context46){while(1)switch(_context46.prev=_context46.next){case 0:e=this.workShapes.get(Wt),n=e==null?void 0:e.blurSelector();if(!(this.clearWorkShapeNodeCache(Wt),((i=this.fullLayer)==null?void 0:i.parent).children.forEach(function(a){a.name===Wt&&a.remove();}),n)){_context46.next=6;break;}a=[];a.push(_objectSpread(_objectSpread({},n),{},{isSync:t==null?void 0:t.isSync}));_context46.next=6;return this._post({render:(n==null?void 0:n.rect)&&[{rect:Dt(n.rect),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:Dt(n.rect),drawCanvas:St.Bg,viewId:this.viewId}],sp:a});case 6:case"end":return _context46.stop();}},_callee44,this);}));function blurSelector(_x51){return _blurSelector.apply(this,arguments);}return blurSelector;}()},{key:"hasSelector",value:function hasSelector(){return this.workShapes.has(Wt);}},{key:"getSelector",value:function getSelector(){return this.workShapes.get(Wt);}},{key:"reRenderSelector",value:function(){var _reRenderSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee45(){var t,a,e,n,i,o,_args47=arguments;return _regeneratorRuntime().wrap(function _callee45$(_context47){while(1)switch(_context47.prev=_context47.next){case 0:t=_args47.length>0&&_args47[0]!==undefined?_args47[0]:!1;e=this.workShapes.get(Wt);if(e){_context47.next=4;break;}return _context47.abrupt("return");case 4:if(!(e&&!((a=e.selectIds)!=null&&a.length))){_context47.next=8;break;}_context47.next=7;return this.blurSelector();case 7:return _context47.abrupt("return");case 8:n=e.oldSelectRect,i=e.reRenderSelector();if(!i){_context47.next=13;break;}o=Pt(n,i)||i;_context47.next=13;return this._post({render:[{rect:Dt(o),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:Dt(o),drawCanvas:St.Bg,viewId:this.viewId}],sp:[{type:ot.Select,selectIds:e.selectIds,selectRect:i,willSyncService:t,viewId:this.viewId,points:e.getChildrenPoints(),textOpt:e.textOpt,selectorColor:e.selectorColor,strokeColor:e.strokeColor,fillColor:e.fillColor,canTextEdit:e.canTextEdit,canRotate:e.canRotate,scaleType:e.scaleType,opt:e.getWorkOptions()||void 0,canLock:e.canLock,isLocked:e.isLocked,toolsTypes:e.toolsTypes,shapeOpt:e.shapeOpt,thickness:e.thickness,useStroke:e.useStroke,strokeType:e.strokeType}]});case 13:case"end":return _context47.stop();}},_callee45,this);}));function reRenderSelector(){return _reRenderSelector.apply(this,arguments);}return reRenderSelector;}()},{key:"updateFullSelectWork",value:function(){var _updateFullSelectWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee46(t){var i,a,o,s,l,g,c,e,n,_e$updateSelectIds,d,y,P;return _regeneratorRuntime().wrap(function _callee46$(_context48){while(1)switch(_context48.prev=_context48.next){case 0:e=this.workShapes.get(Wt),n=t.selectIds;if(n!=null&&n.length){_context48.next=5;break;}_context48.next=4;return this.blurSelector(t);case 4:return _context48.abrupt("return");case 5:if(e){_context48.next=10;break;}!this.setFullWork(t)&&t.workId&&((i=this.tmpOpt)==null?void 0:i.toolsType)===dt.Selector&&this.createWorkShape(t.workId.toString());_context48.next=9;return this.updateFullSelectWork(t);case 9:return _context48.abrupt("return");case 10:if(!(e&&n!=null&&n.length)){_context48.next=16;break;}_e$updateSelectIds=e.updateSelectIds(n),d=_e$updateSelectIds.bgRect,y=_e$updateSelectIds.selectRect,P={render:[],sp:[]};d&&((a=P.render)==null||a.push({rect:Dt(d),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:Dt(d),drawCanvas:St.Bg,viewId:this.viewId}));(c=P.sp)==null||c.push(_objectSpread(_objectSpread({},t),{},{selectorColor:((o=t.opt)==null?void 0:o.strokeColor)||e.selectorColor,strokeColor:((s=t.opt)==null?void 0:s.strokeColor)||e.strokeColor,fillColor:((l=t.opt)==null?void 0:l.fillColor)||e.fillColor,textOpt:((g=t.opt)==null?void 0:g.textOpt)||e.textOpt,canTextEdit:e.canTextEdit,canRotate:e.canRotate,scaleType:e.scaleType,type:ot.Select,selectRect:y,points:e.getChildrenPoints(),willSyncService:(t==null?void 0:t.willSyncService)||!1,opt:(t==null?void 0:t.willSyncService)&&e.getWorkOptions()||void 0,canLock:e.canLock,isLocked:e.isLocked,toolsTypes:e.toolsTypes,shapeOpt:e.shapeOpt,thickness:e.thickness,useStroke:e.useStroke,strokeType:e.strokeType}));_context48.next=16;return this._post(P);case 16:case"end":return _context48.stop();}},_callee46,this);}));function updateFullSelectWork(_x52){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(gm,"destroy",this,3)([]),this.effectSelectNodeData.clear(),this.batchEraserWorks.clear(),this.batchEraserRemoveNodes.clear();}},{key:"drawBitMapEraser",value:function(){var _drawBitMapEraser=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee47(t){return _regeneratorRuntime().wrap(function _callee47$(_context49){while(1)switch(_context49.prev=_context49.next){case 0:_context49.next=2;return this._post({sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context49.stop();}},_callee47,this);}));function drawBitMapEraser(_x53){return _drawBitMapEraser.apply(this,arguments);}return drawBitMapEraser;}()},{key:"drawBitMapEraserFull",value:function(){var _drawBitMapEraserFull=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee48(t,e,n){var i,a,o,s,l,_iterator53,_step53,_step53$value,c,d,g;return _regeneratorRuntime().wrap(function _callee48$(_context50){while(1)switch(_context50.prev=_context50.next){case 0:i=e.rect,a=e.willUpdateNodes,o=e.willDeleteNodes,s=t.getWorkId(),l=[{type:ot.RemoveNode,removeIds:[s],viewId:this.viewId}];if(n&&l.push({type:ot.None,isLockSentEventCursor:n}),a!=null&&a.size||o!=null&&o.size){if(a!=null&&a.size){_iterator53=_createForOfIteratorHelper(a);try{for(_iterator53.s();!(_step53=_iterator53.n()).done;){_step53$value=_slicedToArray(_step53.value,2),c=_step53$value[0],d=_step53$value[1];l.push({type:ot.UpdateNode,dataType:Tt.Local,opt:d.opt,workId:c,updateNodeOpt:{useAnimation:!1}});}}catch(err){_iterator53.e(err);}finally{_iterator53.f();}}o!=null&&o.size&&l.push({type:ot.RemoveNode,removeIds:_toConsumableArray(o),viewId:this.thread.viewId});}g=[{isClearAll:!0,clearCanvas:St.Float,viewId:this.viewId}];i&&g.push({rect:i,isClear:!0,clearCanvas:St.Bg,viewId:this.viewId},{rect:i,drawCanvas:St.Bg,viewId:this.viewId});_context50.next=6;return this._post({sp:l,render:g,fullWorkerDrawCount:1/0});case 6:case"end":return _context50.stop();}},_callee48,this);}));function drawBitMapEraserFull(_x54,_x55,_x56){return _drawBitMapEraserFull.apply(this,arguments);}return drawBitMapEraserFull;}()},{key:"drawBitMapCombine",value:function(){var _drawBitMapCombine=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee49(t,e){var i,a,o,n,s,l;return _regeneratorRuntime().wrap(function _callee49$(_context51){while(1)switch(_context51.prev=_context51.next){case 0:n=(i=this.workShapes.get(t))==null?void 0:i.combineConsume();if(!n){_context51.next=6;break;}s={render:[],fullWorkerDrawCount:e};if(n!=null&&n.rect){l=Dt(n.rect);(a=s.render)==null||a.push({rect:l,isClear:!0,clearCanvas:St.Float,viewId:this.viewId}),(o=s.render)==null||o.push({rect:l,drawCanvas:St.Float,viewId:this.viewId});}_context51.next=6;return this._post(s);case 6:case"end":return _context51.stop();}},_callee49,this);}));function drawBitMapCombine(_x57,_x58){return _drawBitMapCombine.apply(this,arguments);}return drawBitMapCombine;}()},{key:"drawPencilCombine",value:function(){var _drawPencilCombine=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee50(t,e){var i,a,o,n,s,l;return _regeneratorRuntime().wrap(function _callee50$(_context52){while(1)switch(_context52.prev=_context52.next){case 0:n=(i=this.workShapes.get(t))==null?void 0:i.combineConsume();if(!n){_context52.next=6;break;}s={render:[],fullWorkerDrawCount:e};if(n!=null&&n.rect){l=Dt(n.rect);(a=s.render)==null||a.push({rect:l,isClear:!0,clearCanvas:St.Float,viewId:this.viewId}),(o=s.render)==null||o.push({rect:l,drawCanvas:St.Float,viewId:this.viewId});}_context52.next=6;return this._post(s);case 6:case"end":return _context52.stop();}},_callee50,this);}));function drawPencilCombine(_x59,_x60){return _drawPencilCombine.apply(this,arguments);}return drawPencilCombine;}()},{key:"drawSelector",value:function(){var _drawSelector=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee51(t){var n,e;return _regeneratorRuntime().wrap(function _callee51$(_context53){while(1)switch(_context53.prev=_context53.next){case 0:e={render:[],sp:[t]};t.rect&&((n=e.render)==null||n.push({rect:Dt(t.rect),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:Dt(t.rect),drawCanvas:St.Bg,viewId:this.viewId}));_context53.next=4;return this._post(e);case 4:case"end":return _context53.stop();}},_callee51,this);}));function drawSelector(_x61){return _drawSelector.apply(this,arguments);}return drawSelector;}()},{key:"drawPencilEraser",value:function(){var _drawPencilEraser=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee52(t,e){var _this94=this;var i,a,n,_iterator54,_step54,o,s;return _regeneratorRuntime().wrap(function _callee52$(_context54){while(1)switch(_context54.prev=_context54.next){case 0:n=[];if((i=t.newWorkDatas)!=null&&i.size){_iterator54=_createForOfIteratorHelper(t.newWorkDatas.values());try{for(_iterator54.s();!(_step54=_iterator54.n()).done;){o=_step54.value;s=o.workId.toString();this.batchEraserWorks.add(s),n.push({type:ot.FullWork,workId:s,ops:Qt(o.op),opt:o.opt,toolsType:o.toolsType,updateNodeOpt:{useAnimation:!1}});}}catch(err){_iterator54.e(err);}finally{_iterator54.f();}delete t.newWorkDatas;}(a=t.removeIds)==null||a.forEach(function(o){_this94.batchEraserRemoveNodes.add(o);});e&&n.push({type:ot.None,isLockSentEventCursor:e});t.rect&&n.push(t);_context54.next=7;return this._post({sp:n,consumeCount:this.consumeCount});case 7:this.batchEraserCombine();case 8:case"end":return _context54.stop();}},_callee52,this);}));function drawPencilEraser(_x62,_x63){return _drawPencilEraser.apply(this,arguments);}return drawPencilEraser;}()},{key:"drawEraser",value:function(){var _drawEraser=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee53(t,e){var n,i;return _regeneratorRuntime().wrap(function _callee53$(_context55){while(1)switch(_context55.prev=_context55.next){case 0:n=[],i=[];e&&n.push({type:ot.None,isLockSentEventCursor:e});t.removeIds&&n.push(t);t.rect&&i.push({rect:t.rect,isClear:!0,clearCanvas:St.Bg,viewId:this.viewId},{rect:t.rect,drawCanvas:St.Bg,viewId:this.viewId});_context55.next=6;return this._post({sp:n,render:i,consumeCount:this.consumeCount});case 6:case"end":return _context55.stop();}},_callee53,this);}));function drawEraser(_x64,_x65){return _drawEraser.apply(this,arguments);}return drawEraser;}()},{key:"drawShape",value:function(){var _drawShape=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee54(t){return _regeneratorRuntime().wrap(function _callee54$(_context56){while(1)switch(_context56.prev=_context56.next){case 0:_context56.next=2;return this._post({fullWorkerDrawCount:this.drawCount,sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context56.stop();}},_callee54,this);}));function drawShape(_x66){return _drawShape.apply(this,arguments);}return drawShape;}()},{key:"drawPencil",value:function(){var _drawPencil=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee55(t){return _regeneratorRuntime().wrap(function _callee55$(_context57){while(1)switch(_context57.prev=_context57.next){case 0:_context57.next=2;return this._post({sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context57.stop();}},_callee55,this);}));function drawPencil(_x67){return _drawPencil.apply(this,arguments);}return drawPencil;}()},{key:"drawPencilFull",value:function(){var _drawPencilFull=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee56(t,e){var i,a,n;return _regeneratorRuntime().wrap(function _callee56$(_context58){while(1)switch(_context58.prev=_context58.next){case 0:n={fullWorkerDrawCount:1/0,render:[],sp:[t]};e&&((i=n.sp)==null||i.push({type:ot.None,isLockSentEventCursor:e}));(a=n.render)==null||a.push({isClearAll:!0,clearCanvas:St.Float,viewId:this.viewId},{rect:t.rect,isClear:!0,clearCanvas:St.Bg,viewId:this.viewId},{rect:t.rect,drawCanvas:St.Bg,viewId:this.viewId});_context58.next=5;return this._post(n);case 5:case"end":return _context58.stop();}},_callee56,this);}));function drawPencilFull(_x68,_x69){return _drawPencilFull.apply(this,arguments);}return drawPencilFull;}()},{key:"updateBatchEraserCombineNode",value:function updateBatchEraserCombineNode(t,e){var _this95=this;var n=[];var i;var _iterator55=_createForOfIteratorHelper(e.keys()),_step55;try{for(_iterator55.s();!(_step55=_iterator55.n()).done;){var a=_step55.value;this.fullLayer.getElementsByName(a).forEach(function(o){var s=o.getBoundingClientRect();i=Pt(i,{x:s.x-ae.SafeBorderPadding,y:s.y-ae.SafeBorderPadding,w:s.width+ae.SafeBorderPadding*2,h:s.height+ae.SafeBorderPadding*2}),o.remove();});}}catch(err){_iterator55.e(err);}finally{_iterator55.f();}return t.forEach(function(a){var o=_this95.vNodes.get(a);if(o)if(_this95.fullLayer.getElementsByName(a)[0])i=Pt(i,o.rect);else{var l=_this95.setFullWork(_objectSpread(_objectSpread({},o),{},{workId:a})),g=l&&l.consumeService({op:o.op,isFullWork:!0});g&&(o.rect=g,i=Pt(i,g));}}),i&&n.push({rect:i,isClear:!0,clearCanvas:St.Bg,viewId:this.viewId},{rect:i,drawCanvas:St.Bg,viewId:this.viewId}),n;}},{key:"runEffectSelectWork",value:function(){var _runEffectSelectWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee57(t){var e,_iterator56,_step56,n,i,a,o;return _regeneratorRuntime().wrap(function _callee57$(_context59){while(1)switch(_context59.prev=_context59.next){case 0:_iterator56=_createForOfIteratorHelper(this.effectSelectNodeData.values());_context59.prev=1;_iterator56.s();case 3:if((_step56=_iterator56.n()).done){_context59.next=23;break;}n=_step56.value;i=this.setFullWork(n);if(!i){_context59.next=21;break;}a=(e=i.getWorkId())==null?void 0:e.toString();if(!(i.toolsType===dt.Image)){_context59.next=13;break;}_context59.next=11;return i.consumeServiceAsync({isFullWork:!0,replaceId:a,worker:this});case 11:_context59.next=20;break;case 13:if(!(i.toolsType===dt.Text)){_context59.next=18;break;}_context59.next=16;return i.consumeServiceAsync({isFullWork:!0,replaceId:a});case 16:_context59.next=20;break;case 18:o=n.ops&&Pe(n.ops);i.consumeService({op:o,isFullWork:!0,replaceId:a}),n!=null&&n.updateNodeOpt&&i.updataOptService(n.updateNodeOpt);case 20:n.workId&&this.workShapes["delete"](n.workId.toString());case 21:_context59.next=3;break;case 23:_context59.next=28;break;case 25:_context59.prev=25;_context59.t0=_context59["catch"](1);_iterator56.e(_context59.t0);case 28:_context59.prev=28;_iterator56.f();return _context59.finish(28);case 31:_context59.next=33;return this.reRenderSelector(t);case 33:case"end":return _context59.stop();}},_callee57,this,[[1,25,28,31]]);}));function runEffectSelectWork(_x70){return _runEffectSelectWork.apply(this,arguments);}return runEffectSelectWork;}()},{key:"cursorHover",value:function(){var _cursorHover=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee58(t){var o,e,n,i,a,s,l;return _regeneratorRuntime().wrap(function _callee58$(_context60){while(1)switch(_context60.prev=_context60.next){case 0:e=t.opt,n=t.toolsType,i=t.point,a=this.setFullWork({workId:be,toolsType:n,opt:e});if(!(a&&i)){_context60.next=8;break;}s=a.cursorHover(i),l={render:[]};_context60.t0=s&&s.type===ot.CursorHover&&s.rect;if(!_context60.t0){_context60.next=8;break;}(o=l.render)==null||o.push({rect:Dt(s.rect),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:Dt(s.rect),drawCanvas:St.Bg,viewId:this.viewId});_context60.next=8;return this._post(l);case 8:case"end":return _context60.stop();}},_callee58,this);}));function cursorHover(_x71){return _cursorHover.apply(this,arguments);}return cursorHover;}()},{key:"cursorBlur",value:function(){var _cursorBlur=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee59(){var n,t,e;return _regeneratorRuntime().wrap(function _callee59$(_context61){while(1)switch(_context61.prev=_context61.next){case 0:t=this.getWorkShape(be);_context61.t0=t&&(n=t.selectIds)!=null&&n.length;if(!_context61.t0){_context61.next=10;break;}e=t.oldSelectRect;t.cursorBlur();this.clearWorkShapeNodeCache(be);_context61.t1=e;if(!_context61.t1){_context61.next=10;break;}_context61.next=10;return this._post({render:[{rect:Dt(e),clearCanvas:St.Bg,isClear:!0,viewId:this.viewId},{rect:Dt(e),drawCanvas:St.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 _context61.stop();}},_callee59,this);}));function cursorBlur(){return _cursorBlur.apply(this,arguments);}return cursorBlur;}()}]);}(Ri);var mm=/*#__PURE__*/function(){function mm(r){_classCallCheck(this,mm);tt(this,"viewId");tt(this,"vNodes");tt(this,"fullLayer");tt(this,"drawLayer");tt(this,"workShapes",/* @__PURE__ */new Map());tt(this,"selectorWorkShapes",/* @__PURE__ */new Map());tt(this,"thread");tt(this,"animationId");tt(this,"willRunEffectSelectorIds",/* @__PURE__ */new Set());tt(this,"runEffectId");tt(this,"noAnimationRect");tt(this,"syncUnitTime",re.syncOpt.interval);tt(this,"post");this.viewId=r.viewId,this.vNodes=r.vNodes,this.fullLayer=r.fullLayer,this.drawLayer=r.drawLayer,this.thread=r.thread,this.post=r.thread.post.bind(r.thread);}return _createClass(mm,[{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 _callee60(r){return _regeneratorRuntime().wrap(function _callee60$(_context62){while(1)switch(_context62.prev=_context62.next){case 0:this.activeWorkShape(r),this.runAnimation();case 1:case"end":return _context62.stop();}},_callee60,this);}));function consumeDraw(_x72){return _consumeDraw2.apply(this,arguments);}return consumeDraw;}()},{key:"consumeFull",value:function consumeFull(r){this.activeWorkShape(r),this.runAnimation();}},{key:"runSelectWork",value:function runSelectWork(r){this.activeSelectorShape(r);var t=r.workId,e=t==null?void 0:t.toString();e&&this.willRunEffectSelectorIds.add(e),this.runEffect();}},{key:"setNodeKey",value:function setNodeKey(r,t,e,n){return t.toolsType=e,t.node=Fr({workId:r,toolsType:e,toolsOpt:n,vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer},this),t;}},{key:"runReverseSelectWork",value:function runReverseSelectWork(r){var _this96=this;r.forEach(function(t){_this96.selectorWorkShapes.forEach(function(e,n){var i;if((i=e.selectIds)!=null&&i.length){var a=e.selectIds.indexOf(t);a>-1&&(e.selectIds.splice(a,1),_this96.willRunEffectSelectorIds.add(n));}});}),this.willRunEffectSelectorIds.size&&this.runEffect();}},{key:"removeWork",value:function(){var _removeWork3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee61(r){var t,e,n;return _regeneratorRuntime().wrap(function _callee61$(_context63){while(1)switch(_context63.prev=_context63.next){case 0:t=r.workId,e=t==null?void 0:t.toString();if(!e){_context63.next=10;break;}n=this.workShapes.get(e);if(!n){_context63.next=8;break;}this.workShapes["delete"](e);_context63.next=7;return this.removeNode(e,r,n==null?void 0:n.totalRect,!1);case 7:return _context63.abrupt("return");case 8:_context63.next=10;return this.removeNode(e,r);case 10:case"end":return _context63.stop();}},_callee61,this);}));function removeWork(_x73){return _removeWork3.apply(this,arguments);}return removeWork;}()},{key:"removeSelectWork",value:function removeSelectWork(r){var t=r.workId,e=t==null?void 0:t.toString();e&&(this.activeSelectorShape(r),this.willRunEffectSelectorIds.add(e)),this.runEffect();}},{key:"removeNode",value:function(){var _removeNode=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee62(r,t,e){var n,l,i,a,o,s,_args64=arguments;return _regeneratorRuntime().wrap(function _callee62$(_context64){while(1)switch(_context64.prev=_context64.next){case 0:n=_args64.length>3&&_args64[3]!==undefined?_args64[3]:!0;r.indexOf(Wt)>-1&&this.removeSelectWork(t);i=e;a=(l=this.vNodes.get(r))==null?void 0:l.rect;a&&(i=Pt(a,i));o=this.fullLayer&&vt.getRectFromLayer(this.fullLayer,r);i=Pt(i,o);s=this.drawLayer&&vt.getRectFromLayer(this.drawLayer,r);i=Pt(i,s);this.fullLayer.getElementsByName(r).forEach(function(g){g.remove();});this.drawLayer.getElementsByName(r).forEach(function(g){g.remove();});this.vNodes["delete"](r);_context64.t0=i;if(!_context64.t0){_context64.next=16;break;}_context64.next=16;return this.post({render:[{rect:Dt(i),isClear:!0,clearCanvas:n?St.Bg:St.ServiceFloat,workerType:n?void 0:Tt.Service,viewId:this.viewId},{rect:Dt(i),drawCanvas:n?St.Bg:St.ServiceFloat,workerType:n?void 0:Tt.Service,viewId:this.viewId}]});case 16:case"end":return _context64.stop();}},_callee62,this);}));function removeNode(_x74,_x75,_x76){return _removeNode.apply(this,arguments);}return removeNode;}()},{key:"activeWorkShape",value:function activeWorkShape(r){var y,P,S,v;var t=r.workId,e=r.opt,n=r.toolsType,i=r.type,a=r.updateNodeOpt,o=r.ops,s=r.op,l=r.useAnimation;if(!t)return;var g=t.toString(),c=(y=this.vNodes.get(g))==null?void 0:y.rect;if(!((P=this.workShapes)!=null&&P.has(g))){var _T43={toolsType:n,animationWorkData:s||[],animationIndex:0,type:i,updateNodeOpt:a,ops:o,useAnimation:_typeof(l)<"u"?l:_typeof(a==null?void 0:a.useAnimation)<"u"?a==null?void 0:a.useAnimation:!0,oldRect:c,isDiff:!1};n&&e&&(_T43=this.setNodeKey(g,_T43,n,e)),(S=this.workShapes)==null||S.set(g,_T43);}var d=(v=this.workShapes)==null?void 0:v.get(g);i&&(d.type=i),o&&(d.animationWorkData=Pe(o),d.ops=o),a&&(d.updateNodeOpt=a),s&&(d.isDiff=this.hasDiffData(d.animationWorkData||[],s,d.toolsType),d.animationWorkData=s),d.node&&d.node.getWorkId()!==g&&d.node.setWorkId(g),c&&(d.oldRect=c),n&&e&&(e.syncUnitTime&&(this.syncUnitTime=e.syncUnitTime),d.toolsType!==n&&n&&e&&this.setNodeKey(g,d,n,e),d.node&&d.node.setWorkOptions(e));}},{key:"hasDiffData",value:function hasDiffData(r,t,e){var n=r.length;if(t.length<n)return!0;switch(e){case dt.Pencil:{for(var i=0;i<n;i+=3)if(t[i]!==r[i]||t[i+1]!==r[i+1])return!0;break;}case dt.LaserPen:{for(var _i12=0;_i12<n;_i12+=2)if(t[_i12]!==r[_i12]||t[_i12+1]!==r[_i12+1])return!0;break;}}return!1;}},{key:"animationDraw",value:function(){var _animationDraw=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee63(){var _this97=this;var n,i,a,o,s,l,g,c,d,y,P,S,v,T,f,p,u,m,M,O,A,w,E,L,b,I,R,W,z,K,J,q,U,G,Z,rt,et,r,t,e,_iterator57,_step57,_loop6;return _regeneratorRuntime().wrap(function _callee63$(_context66){while(1)switch(_context66.prev=_context66.next){case 0:this.animationId=void 0;r=!1;t={render:[]},e=/* @__PURE__ */new Map();_iterator57=_createForOfIteratorHelper(this.workShapes.entries());_context66.prev=4;_loop6=/*#__PURE__*/_regeneratorRuntime().mark(function _loop6(){var _step57$value,it,X,ct,ut,_ct3,_ut2,_ct4,_ut3,B,F,_ct5,_ut4,_ct6,_ut5,_B,_F,Y,k,N,_k,_ct7,_ut6,_B2,_F2,_Y,_k2;return _regeneratorRuntime().wrap(function _loop6$(_context65){while(1)switch(_context65.prev=_context65.next){case 0:_step57$value=_slicedToArray(_step57.value,2),it=_step57$value[0],X=_step57$value[1];_context65.t0=X.toolsType;_context65.next=_context65.t0===dt.Image?4:_context65.t0===dt.Text?11:_context65.t0===dt.Arrow?19:_context65.t0===dt.Straight?19:_context65.t0===dt.Rectangle?19:_context65.t0===dt.Ellipse?19:_context65.t0===dt.Star?19:_context65.t0===dt.Polygon?19:_context65.t0===dt.SpeechBalloon?19:_context65.t0===dt.Pencil?22:_context65.t0===dt.BitMapEraser?37:50;break;case 4:ct=X.oldRect;ct&&((n=t.render)==null||n.push({rect:ct,isClear:!0,clearCanvas:St.Bg,viewId:_this97.viewId}),(i=t.render)==null||i.push({rect:ct,drawCanvas:St.Bg,viewId:_this97.viewId}));_context65.next=8;return(a=X.node)==null?void 0:a.consumeServiceAsync({isFullWork:!0,worker:_this97.thread});case 8:ut=_context65.sent;_this97.selectorWorkShapes.forEach(function(B,F){var Y;(Y=B.selectIds)!=null&&Y.includes(it)&&(_this97.willRunEffectSelectorIds.add(F),_this97.noAnimationRect=Pt(_this97.noAnimationRect,ct),_this97.noAnimationRect=Pt(_this97.noAnimationRect,ut),_this97.runEffect());}),_this97.workShapes["delete"](it),(o=t.render)==null||o.push({rect:ut,drawCanvas:St.Bg,viewId:_this97.viewId});return _context65.abrupt("break",50);case 11:if(!X.node){_context65.next=18;break;}_ct3=X.oldRect;_ct3&&((s=t.render)==null||s.push({rect:_ct3,isClear:!0,clearCanvas:St.Bg,viewId:_this97.viewId}),(l=t.render)==null||l.push({rect:_ct3,drawCanvas:St.Bg,viewId:_this97.viewId}));_context65.next=16;return X.node.consumeServiceAsync({isFullWork:!0,replaceId:it});case 16:_ut2=_context65.sent;_this97.selectorWorkShapes.forEach(function(B,F){var Y;(Y=B.selectIds)!=null&&Y.includes(it)&&(_this97.willRunEffectSelectorIds.add(F),_this97.noAnimationRect=Pt(_this97.noAnimationRect,_ct3),_this97.noAnimationRect=Pt(_this97.noAnimationRect,_ut2),_this97.runEffect());}),(g=X.node)==null||g.clearTmpPoints(),_this97.workShapes["delete"](it),(c=t.render)==null||c.push({rect:_ut2,drawCanvas:St.Bg,viewId:_this97.viewId});case 18:return _context65.abrupt("break",50);case 19:_ct4=!!X.ops;if((d=X.animationWorkData)!=null&&d.length){_ut3=X.oldRect,B=X.node.oldRect;_ut3&&((y=t.render)==null||y.push({rect:_ut3,isClear:!0,clearCanvas:St.Bg,viewId:_this97.viewId}),(P=t.render)==null||P.push({rect:_ut3,drawCanvas:St.Bg,viewId:_this97.viewId})),B&&((S=t.render)==null||S.push({rect:B,isClear:!0,clearCanvas:St.ServiceFloat,viewId:_this97.viewId}));F=(v=X.node)==null?void 0:v.consumeService({op:X.animationWorkData,isFullWork:_ct4});e.set(it,{workState:_ut3?X.ops?It.Done:It.Doing:It.Start,op:X.animationWorkData.filter(function(Y,k){if(k%3!==2)return!0;}).slice(-2)}),_ct4?(_this97.selectorWorkShapes.forEach(function(Y,k){var N;(N=Y.selectIds)!=null&&N.includes(it)&&(_this97.willRunEffectSelectorIds.add(k),_this97.noAnimationRect=Pt(_this97.noAnimationRect,_ut3),_this97.noAnimationRect=Pt(_this97.noAnimationRect,B),_this97.noAnimationRect=Pt(_this97.noAnimationRect,F),_this97.runEffect());}),(T=X.node)==null||T.clearTmpPoints(),_this97.workShapes["delete"](it),(f=t.render)==null||f.push({rect:F,drawCanvas:St.Bg,viewId:_this97.viewId})):(p=t.render)==null||p.push({rect:F,drawCanvas:St.ServiceFloat,workerType:_ct4?void 0:Tt.Service,viewId:_this97.viewId}),X.animationWorkData.length=0;}return _context65.abrupt("break",50);case 22:if(!(!X.useAnimation&&X.ops)){_context65.next=28;break;}_ct5=(u=X.node)==null?void 0:u.consumeService({op:X.animationWorkData||[],isFullWork:!0,replaceId:it});_ut4=(m=X.node)==null?void 0:m.updataOptService(X.updateNodeOpt);_ct5=Pt(_ct5,_ut4),(M=t.render)==null||M.push({isClear:!0,rect:Pt(X.oldRect,_ct5),clearCanvas:St.Bg,viewId:_this97.viewId}),(O=t.render)==null||O.push({rect:Pt(X.oldRect,_ct5),drawCanvas:St.Bg,viewId:_this97.viewId}),_this97.selectorWorkShapes.forEach(function(B,F){var Y;(Y=B.selectIds)!=null&&Y.includes(it)&&(_this97.willRunEffectSelectorIds.add(F),_this97.noAnimationRect=Pt(_this97.noAnimationRect,_ct5),_this97.runEffect());}),(A=X.node)==null||A.clearTmpPoints(),_this97.workShapes["delete"](it);_context65.next=36;break;case 28:if(!X.useAnimation){_context65.next=36;break;}if(!X.isDel){_context65.next=32;break;}(w=X.node)==null||w.clearTmpPoints(),_this97.workShapes["delete"](it);return _context65.abrupt("break",50);case 32:_ct6=3,_ut5=_this97.computNextAnimationIndex(X,_ct6),_B=X.isDiff?0:Math.max(0,(X.animationIndex||0)-_ct6),_F=(X.animationWorkData||[]).slice(0,_ut5),Y=(L=(E=X.node)==null?void 0:E.getWorkId())==null?void 0:L.toString();if((X.animationIndex||0)<_ut5||X.isDiff){k=(b=X.node)==null?void 0:b.consumeService({op:_F,isFullWork:!1,replaceId:Y});if((I=t.render)==null||I.push({isClear:!0,rect:k,clearCanvas:St.ServiceFloat,viewId:_this97.viewId}),(R=t.render)==null||R.push({rect:k,drawCanvas:St.ServiceFloat,viewId:_this97.viewId}),X.animationIndex=_ut5,X.isDiff&&(X.isDiff=!1),_F.length){N=_F.filter(function($,x){if(x%_ct6!==_ct6-1)return!0;}).slice(-2);e.set(it,{workState:_B===0?It.Start:_ut5===((W=X.animationWorkData)==null?void 0:W.length)?It.Done:It.Doing,op:N});}}else if(X.ops){_k=(z=X.node)==null?void 0:z.consumeService({op:X.animationWorkData||[],isFullWork:!0,replaceId:Y});X.isDel=!0,(K=t.render)==null||K.push({isClear:!0,rect:_k,clearCanvas:St.ServiceFloat,viewId:_this97.viewId},{rect:_k,drawCanvas:St.ServiceFloat,viewId:_this97.viewId},{isClear:!0,rect:_k,clearCanvas:St.Bg,viewId:_this97.viewId},{rect:_k,drawCanvas:St.Bg,viewId:_this97.viewId}),e.set(it,{workState:It.Done,op:_F.filter(function(N,$){if($%_ct6!==_ct6-1)return!0;}).slice(-2)});}r=!0;return _context65.abrupt("break",50);case 36:return _context65.abrupt("break",50);case 37:if(!X.isDel){_context65.next=40;break;}(J=X.node)==null||J.clearTmpPoints(),_this97.workShapes["delete"](it);return _context65.abrupt("break",50);case 40:if(!(X.ops&&(q=X.animationWorkData)!=null&&q.length)){_context65.next=44;break;}_ct7=X.animationWorkData.slice(-3,-1);e.set(it,{workState:It.Done,op:_ct7}),X.isDel=!0;return _context65.abrupt("break",50);case 44:if(!X.useAnimation){_context65.next=49;break;}_ut6=_this97.computNextAnimationIndex(X,3),_B2=X.isDiff?0:Math.max(0,(X.animationIndex||0)-3),_F2=(X.animationWorkData||[]).slice(0,_ut6);if((X.animationIndex||0)<_ut6||X.isDiff){_Y=(U=X.node)==null?void 0:U.consumeService({op:_F2,isFullWork:!1,replaceId:it});if((G=t.render)==null||G.push({isClear:!0,rect:Pt(X.oldRect,_Y),clearCanvas:St.ServiceFloat,viewId:_this97.viewId}),(Z=t.render)==null||Z.push({rect:Pt(X.oldRect,_Y),drawCanvas:St.ServiceFloat,viewId:_this97.viewId}),X.animationIndex=_ut6,X.isDiff&&(X.isDiff=!1),_F2.length){_k2=_F2.filter(function(N,$){if($%3!==2)return!0;}).slice(-2);e.set(it,{workState:_B2===0?It.Start:_ut6===((rt=X.animationWorkData)==null?void 0:rt.length)?It.Done:It.Doing,op:_k2});}}r=!0;return _context65.abrupt("break",50);case 49:return _context65.abrupt("break",50);case 50:case"end":return _context65.stop();}},_loop6);});_iterator57.s();case 7:if((_step57=_iterator57.n()).done){_context66.next=11;break;}return _context66.delegateYield(_loop6(),"t0",9);case 9:_context66.next=7;break;case 11:_context66.next=16;break;case 13:_context66.prev=13;_context66.t1=_context66["catch"](4);_iterator57.e(_context66.t1);case 16:_context66.prev=16;_iterator57.f();return _context66.finish(16);case 19:r&&this.runAnimation();e.size&&(t.sp=[],e.forEach(function(it,X){var ct;(ct=t.sp)==null||ct.push({type:ot.Cursor,uid:X.split(De)[0],op:it.op,workState:it.workState,viewId:_this97.viewId});}));_context66.t2=(et=t.render)!=null&&et.length;if(!_context66.t2){_context66.next=25;break;}_context66.next=25;return this.post(t);case 25:case"end":return _context66.stop();}},_callee63,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(r,t){var e=Math.floor((r.animationWorkData||[]).slice(r.animationIndex).length*48/t/this.syncUnitTime)*t;return Math.min((r.animationIndex||0)+(e||t),(r.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 _callee64(){var _this99=this;var r;return _regeneratorRuntime().wrap(function _callee64$(_context67){while(1)switch(_context67.prev=_context67.next){case 0:this.runEffectId=void 0;r=this.noAnimationRect;this.willRunEffectSelectorIds.forEach(function(t){var i,a;var e=_this99.selectorWorkShapes.get(t),n=e&&e.selectIds&&((i=e.node)==null?void 0:i.selectServiceNode(t,e,!0));r=Pt(r,n),(a=e==null?void 0:e.selectIds)!=null&&a.length||_this99.selectorWorkShapes["delete"](t);});_context67.t0=r;if(!_context67.t0){_context67.next=7;break;}_context67.next=7;return this.post({render:[{rect:Dt(r),isClear:!0,clearCanvas:St.Bg,viewId:this.viewId},{rect:Dt(r),drawCanvas:St.Bg,viewId:this.viewId}]});case 7:this.willRunEffectSelectorIds.clear();this.noAnimationRect=void 0;case 9:case"end":return _context67.stop();}},_callee64,this);}));function effectRunSelector(){return _effectRunSelector.apply(this,arguments);}return effectRunSelector;}()},{key:"activeSelectorShape",value:function activeSelectorShape(r){var g,c,d;var t=r.workId,e=r.opt,n=r.toolsType,i=r.type,a=r.selectIds,o=r.imageBitmap;if(!t)return;var s=t.toString();if(!((g=this.selectorWorkShapes)!=null&&g.has(s))){var y={toolsType:n,selectIds:a,type:i,opt:e,imageBitmap:o};n&&e&&(y=this.setNodeKey(s,y,n,e)),(c=this.selectorWorkShapes)==null||c.set(s,y);}var l=(d=this.selectorWorkShapes)==null?void 0:d.get(s);i&&(l.type=i),l.node&&l.node.getWorkId()!==s&&l.node.setWorkId(s),o&&(l.imageBitmap=o),l.selectIds=a||[];}}]);}();var vm=/*#__PURE__*/function(_Ri2){function vm(t){var _this100;_classCallCheck(this,vm);_this100=_callSuper(this,vm,[t]);tt(_this100,"drawWorkActiveId");return _this100;}_inherits(vm,_Ri2);return _createClass(vm,[{key:"runFullWork",value:function(){var _runFullWork=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee65(t){var i,e,n,a,o,s;return _regeneratorRuntime().wrap(function _callee65$(_context68){while(1)switch(_context68.prev=_context68.next){case 0:e=this.setFullWork(t),n=t.ops&&Pe(t.ops);if(!e){_context68.next=18;break;}s=(i=e.getWorkId())==null?void 0:i.toString();if(!(e.toolsType===dt.Image)){_context68.next=9;break;}_context68.next=6;return e.consumeServiceAsync({isFullWork:!0,worker:this.thread});case 6:a=_context68.sent;_context68.next=16;break;case 9:if(!(e.toolsType===dt.Text)){_context68.next=15;break;}_context68.next=12;return e.consumeServiceAsync({isFullWork:!0,replaceId:s,isDrawLabel:!0});case 12:a=_context68.sent;_context68.next=16;break;case 15:a=e.consumeService({op:n,isFullWork:!0,replaceId:s}),o=(t==null?void 0:t.updateNodeOpt)&&e.updataOptService(t.updateNodeOpt);case 16:t.workId&&this.workShapes["delete"](t.workId.toString());return _context68.abrupt("return",Pt(a,o));case 18:case"end":return _context68.stop();}},_callee65,this);}));function runFullWork(_x77){return _runFullWork.apply(this,arguments);}return runFullWork;}()},{key:"runSelectWork",value:function runSelectWork(t){var n;var e=this.setFullWork(t);e&&(n=t.selectIds)!=null&&n.length&&t.workId&&e.selectServiceNode(t.workId.toString(),{selectIds:t.selectIds},!1);}},{key:"workShapesDone",value:function workShapesDone(){var _iterator58=_createForOfIteratorHelper(this.workShapes.keys()),_step58;try{for(_iterator58.s();!(_step58=_iterator58.n()).done;){var t=_step58.value;this.clearWorkShapeNodeCache(t);}}catch(err){_iterator58.e(err);}finally{_iterator58.f();}this.fullLayer.removeAllChildren();}},{key:"canUseSubWorker",value:function canUseSubWorker(t){var e=this.thread.getPriorityDraw();return e||!e&&t!==dt.Pencil;}},{key:"consumeDraw",value:function(){var _consumeDraw3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee66(t){var e,n,i,a,o,s,l;return _regeneratorRuntime().wrap(function _callee66$(_context69){while(1)switch(_context69.prev=_context69.next){case 0:e=t.workId,n=t.fullWorkerDrawCount,i=t.postCount,a=e==null?void 0:e.toString(),o=a&&this.workShapes.get(a);if(o){_context69.next=3;break;}return _context69.abrupt("return");case 3:_context69.t0=this.drawWorkActiveId&&this.drawWorkActiveId!==a;if(!_context69.t0){_context69.next=8;break;}_context69.next=7;return this.consumeDrawAll({workId:this.drawWorkActiveId,viewId:this.viewId,msgType:ot.DrawWork,dataType:Tt.Local});case 7:this.drawWorkActiveId=void 0;case 8:!this.drawWorkActiveId&&a!==Wt&&(this.drawWorkActiveId=a);s=o.toolsType;Vt(i)&&(this.consumeCount=i);l=o.consume({data:t,drawCount:this.drawCount,isFullWork:!0,isSubWorker:!0,removeDrawCount:n});_context69.t1=s;_context69.next=_context69.t1===dt.Arrow?15:_context69.t1===dt.Straight?15:_context69.t1===dt.Ellipse?15:_context69.t1===dt.Rectangle?15:_context69.t1===dt.Star?15:_context69.t1===dt.Polygon?15:_context69.t1===dt.SpeechBalloon?15:_context69.t1===dt.Pencil?21:_context69.t1===dt.BitMapEraser?21:27;break;case 15:_context69.t2=l;if(!_context69.t2){_context69.next=20;break;}this.drawCount++;_context69.next=20;return this.drawShape(l);case 20:return _context69.abrupt("break",27);case 21:_context69.t3=l;if(!_context69.t3){_context69.next=26;break;}this.drawCount++;_context69.next=26;return this.drawPencil(l,e==null?void 0:e.toString());case 26:return _context69.abrupt("break",27);case 27:case"end":return _context69.stop();}},_callee66,this);}));function consumeDraw(_x78){return _consumeDraw3.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee67(t){var e,n,i;return _regeneratorRuntime().wrap(function _callee67$(_context70){while(1)switch(_context70.prev=_context70.next){case 0:e=t.workId;if(!e){_context70.next=12;break;}n=e.toString();this.drawWorkActiveId===n&&(this.drawWorkActiveId=void 0);i=this.workShapes.get(n);if(i){_context70.next=7;break;}return _context70.abrupt("return");case 7:_context70.t0=i.toolsType;_context70.next=_context70.t0===dt.Arrow?10:_context70.t0===dt.Straight?10:_context70.t0===dt.Ellipse?10:_context70.t0===dt.Pencil?10:_context70.t0===dt.Rectangle?10:_context70.t0===dt.Star?10:_context70.t0===dt.Polygon?10:_context70.t0===dt.SpeechBalloon?10:_context70.t0===dt.BitMapEraser?10:12;break;case 10:this.drawCount=0,this.fullLayer.removeAllChildren(),this.clearWorkShapeNodeCache(n);return _context70.abrupt("break",12);case 12:case"end":return _context70.stop();}},_callee67,this);}));function consumeDrawAll(_x79){return _consumeDrawAll2.apply(this,arguments);}return consumeDrawAll;}()},{key:"removeWork",value:function(){var _removeWork4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee68(t){var e,n,i,a;return _regeneratorRuntime().wrap(function _callee68$(_context71){while(1)switch(_context71.prev=_context71.next){case 0:e=t.workId,n=e==null?void 0:e.toString();if(!n){_context71.next=8;break;}i=this.removeNode(n);if(!i){_context71.next=8;break;}a=[];a.push({rect:Dt(i),clearCanvas:St.Float,isClear:!0,viewId:this.viewId},{rect:Dt(i),drawCanvas:St.Float,viewId:this.viewId});_context71.next=8;return this._post({render:a});case 8:case"end":return _context71.stop();}},_callee68,this);}));function removeWork(_x80){return _removeWork4.apply(this,arguments);}return removeWork;}()},{key:"removeNode",value:function removeNode(t){var e=this.workShapes.has(t);var n;return e&&(this.fullLayer.getElementsByName(t).forEach(function(i){var a=i.getBoundingClientRect();n=Pt(n,{x:a.x-vt.SafeBorderPadding,y:a.y-vt.SafeBorderPadding,w:a.width+vt.SafeBorderPadding*2,h:a.height+vt.SafeBorderPadding*2}),i.remove();}),n&&this.clearWorkShapeNodeCache(t)),n;}},{key:"drawPencil",value:function(){var _drawPencil2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee69(t,e){return _regeneratorRuntime().wrap(function _callee69$(_context72){while(1)switch(_context72.prev=_context72.next){case 0:_context72.next=2;return this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:t==null?void 0:t.rect,workId:e,drawCanvas:St.Float,viewId:this.viewId}],sp:(t==null?void 0:t.op)&&[t]});case 2:case"end":return _context72.stop();}},_callee69,this);}));function drawPencil(_x81,_x82){return _drawPencil2.apply(this,arguments);}return drawPencil;}()},{key:"drawShape",value:function(){var _drawShape2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee70(t){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)&&Dt(t.rect),isClear:!0,clearCanvas:St.Float,viewId:this.viewId},{rect:(t==null?void 0:t.rect)&&Dt(t.rect),drawCanvas:St.Float,viewId:this.viewId}]});case 2:case"end":return _context73.stop();}},_callee70,this);}));function drawShape(_x83){return _drawShape2.apply(this,arguments);}return drawShape;}()}]);}(Ri);var ym=/*#__PURE__*/function(){function ym(r){_classCallCheck(this,ym);tt(this,"viewId");tt(this,"vNodes");tt(this,"topLayer");tt(this,"thread");tt(this,"post");tt(this,"serviceWorkShapes",/* @__PURE__ */new Map());tt(this,"localWorkShapes",/* @__PURE__ */new Map());tt(this,"tmpOpt");tt(this,"syncUnitTime",re.syncOpt.interval);tt(this,"animationId");this.viewId=r.viewId,this.vNodes=r.vNodes,this.topLayer=r.topLayer,this.thread=r.thread,this.post=r.thread.post.bind(r.thread);}return _createClass(ym,[{key:"canUseTopLayer",value:function canUseTopLayer(r){return r===dt.LaserPen;}},{key:"getWorkShape",value:function getWorkShape(r){return this.localWorkShapes.get(r);}},{key:"createWorkShape",value:function createWorkShape(r,t){if(r&&this.tmpOpt){var _e15={toolsType:this.tmpOpt.toolsType,toolsOpt:t||this.tmpOpt.toolsOpt},n=this.createWorkShapeNode(_objectSpread(_objectSpread({},_e15),{},{workId:r}));return n&&this.localWorkShapes.set(r,{node:n,toolsType:n.toolsType,workState:It.Start}),n;}}},{key:"setWorkOptions",value:function setWorkOptions(r,t){var n;var e=(n=this.localWorkShapes.get(r))==null?void 0:n.node;e||this.createWorkShape(r,t),e==null||e.setWorkOptions(t);}},{key:"createWorkShapeNode",value:function createWorkShapeNode(r){var t=r.toolsType;if(t===dt.LaserPen)return Fr(_objectSpread(_objectSpread({},r),{},{vNodes:this.vNodes,fullLayer:this.topLayer,drawLayer:this.topLayer}));}},{key:"clearAllWorkShapesCache",value:function clearAllWorkShapesCache(){this.localWorkShapes.forEach(function(r){var t;return(t=r.node)==null?void 0:t.clearTmpPoints();}),this.localWorkShapes.clear();}},{key:"setToolsOpt",value:function setToolsOpt(r){var t;this.tmpOpt=r,(t=r.toolsOpt)!=null&&t.syncUnitTime&&(this.syncUnitTime=r.toolsOpt.syncUnitTime);}},{key:"getToolsOpt",value:function getToolsOpt(){return this.tmpOpt;}},{key:"consumeDraw",value:function consumeDraw(r){var t=r.workId,e=r.dataType;if(e===Tt.Service)this.activeServiceWorkShape(r);else{var n=t==null?void 0:t.toString(),i=n&&this.localWorkShapes.get(n);if(!i)return;var a=i.node.consume({data:r,isFullWork:!1,isSubWorker:!0});a.rect&&(i.totalRect=Pt(a.rect,i.totalRect),i.result=a,i.workState=It.Doing,n&&this.localWorkShapes.set(n,i));}this.runAnimation();}},{key:"consumeDrawAll",value:function consumeDrawAll(r){var t=r.workId,e=r.dataType;if(e===Tt.Service)this.activeServiceWorkShape(r);else{var n=t==null?void 0:t.toString(),i=n&&this.localWorkShapes.get(n);if(!i)return;var a=i.node.consumeAll({data:r});i.totalRect=Pt(a.rect,i.totalRect),i.result=a,i.workState=It.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(r,t,e,n){return t.toolsType=e,t.node=this.createWorkShapeNode({workId:r,toolsType:e,toolsOpt:n}),t;}},{key:"activeServiceWorkShape",value:function activeServiceWorkShape(r){var d,y;var t=r.workId,e=r.opt,n=r.toolsType,i=r.type,a=r.updateNodeOpt,o=r.ops,s=r.op;if(!t)return;var l=t.toString(),g=(d=this.vNodes.get(l))==null?void 0:d.rect;if(!((y=this.serviceWorkShapes)!=null&&y.has(l))){var P={toolsType:n,animationWorkData:s||[],animationIndex:0,type:i,updateNodeOpt:a,ops:o,oldRect:g};n&&e&&(P=this.setNodeKey(l,P,n,e)),this.serviceWorkShapes.set(l,P);}var c=this.serviceWorkShapes.get(l);i&&(c.type=i),o&&(c.animationWorkData=Pe(o),c.ops=o),a&&(c.updateNodeOpt=a),s&&(c.animationWorkData=s),c.node&&c.node.getWorkId()!==l&&c.node.setWorkId(l),g&&(c.oldRect=g),n&&e&&(c.toolsType!==n&&n&&e&&this.setNodeKey(l,c,n,e),c.node&&c.node.setWorkOptions(e));}},{key:"computNextAnimationIndex",value:function computNextAnimationIndex(r,t){var e=Math.floor((r.animationWorkData||[]).slice(r.animationIndex).length*32/t/this.syncUnitTime)*t;return Math.min((r.animationIndex||0)+(e||t),(r.animationWorkData||[]).length);}},{key:"animationDraw",value:function(){var _animationDraw2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee71(){var _this101=this;var a,o,s,l,r,t,e,n,i,_iterator59,_step59,_step59$value,g,c,y,P,S,v,_iterator60,_step60,_step60$value,_g11,_c7,d,_y14,_P4,_S4,_v11;return _regeneratorRuntime().wrap(function _callee71$(_context74){while(1)switch(_context74.prev=_context74.next){case 0:this.animationId=void 0;r=!1;t=/* @__PURE__ */new Map(),e=[],n=[],i=[];_iterator59=_createForOfIteratorHelper(this.serviceWorkShapes.entries());_context74.prev=4;_iterator59.s();case 6:if((_step59=_iterator59.n()).done){_context74.next=20;break;}_step59$value=_slicedToArray(_step59.value,2),g=_step59$value[0],c=_step59$value[1];_context74.t0=c.toolsType;_context74.next=_context74.t0===dt.LaserPen?11:18;break;case 11:y=this.computNextAnimationIndex(c,8),P=Math.max(0,c.animationIndex||0),S=(c.animationWorkData||[]).slice(P,y);if((c.animationIndex||0)<y){v=(a=c.node)==null?void 0:a.consumeService({op:S,isFullWork:!1});c.totalRect=Pt(c.totalRect,v),c.animationIndex=y,S.length&&t.set(g,{workState:P===0?It.Start:y===((o=c.animationWorkData)==null?void 0:o.length)?It.Done:It.Doing,op:S.slice(-2)});}if(!(n.push({isClear:!0,rect:c.totalRect,clearCanvas:St.TopFloat,viewId:this.viewId}),e.push({rect:c.totalRect,drawCanvas:St.TopFloat,viewId:this.viewId}),c.isDel)){_context74.next=16;break;}(s=c.node)==null||s.clearTmpPoints(),this.serviceWorkShapes["delete"](g);return _context74.abrupt("break",18);case 16:c.ops&&c.animationIndex===((l=c.animationWorkData)==null?void 0:l.length)&&!c.isDel&&(this.topLayer.getElementsByName(g.toString())[0]||(c.isDel=!0,this.serviceWorkShapes.set(g,c))),r=!0;return _context74.abrupt("break",18);case 18:_context74.next=6;break;case 20:_context74.next=25;break;case 22:_context74.prev=22;_context74.t1=_context74["catch"](4);_iterator59.e(_context74.t1);case 25:_context74.prev=25;_iterator59.f();return _context74.finish(25);case 28:_iterator60=_createForOfIteratorHelper(this.localWorkShapes.entries());_context74.prev=29;_iterator60.s();case 31:if((_step60=_iterator60.n()).done){_context74.next=44;break;}_step60$value=_slicedToArray(_step60.value,2),_g11=_step60$value[0],_c7=_step60$value[1];d=_c7.result,_y14=_c7.toolsType,_P4=_c7.totalRect,_S4=_c7.isDel,_v11=_c7.workState;_context74.t2=_y14;_context74.next=_context74.t2===dt.LaserPen?37:42;break;case 37:if(!(_P4&&(n.push({isClear:!0,rect:_P4,clearCanvas:St.TopFloat,viewId:this.viewId}),e.push({rect:_P4,drawCanvas:St.TopFloat,viewId:this.viewId})),_S4)){_context74.next=40;break;}_c7.node.clearTmpPoints(),this.localWorkShapes["delete"](_g11),i.push({removeIds:[_g11.toString()],viewId:this.viewId,type:ot.RemoveNode});return _context74.abrupt("break",42);case 40:d&&((d.op||d.ops)&&i.push(d),_c7.result=void 0),!this.topLayer.getElementsByName(_g11.toString())[0]&&_v11===It.Done&&(_c7.isDel=!0,this.localWorkShapes.set(_g11,_c7)),r=!0;return _context74.abrupt("break",42);case 42:_context74.next=31;break;case 44:_context74.next=49;break;case 46:_context74.prev=46;_context74.t3=_context74["catch"](29);_iterator60.e(_context74.t3);case 49:_context74.prev=49;_iterator60.f();return _context74.finish(49);case 52:r&&this.runAnimation(),t.size&&t.forEach(function(g,c){i.push({type:ot.Cursor,uid:c.split(De)[0],op:g.op,workState:g.workState,viewId:_this101.viewId});}),(e.length||n.length||i.length)&&this.post({render:[].concat(n,e),sp:i});case 53:case"end":return _context74.stop();}},_callee71,this,[[4,22,25,28],[29,46,49,52]]);}));function animationDraw(){return _animationDraw2.apply(this,arguments);}return animationDraw;}()},{key:"runAnimation",value:function runAnimation(){var _this102=this;this.animationId||(this.animationId=setTimeout(function(){_this102.animationId=void 0,_this102.animationDraw();},16));}}]);}();var qe=/* @__PURE__ */function(h){return h.Full="full",h.Sub="sub",h;}(qe||{});var Sm=/*#__PURE__*/function(){function Sm(r,t){_classCallCheck(this,Sm);tt(this,"_self");tt(this,"version",fi);tt(this,"type");tt(this,"hasPriorityDraw",!0);tt(this,"workThreadMap",/* @__PURE__ */new Map());this._self=r,this.type=t,this.register();}return _createClass(Sm,[{key:"init",value:function init(r){var t=r.viewId,e=r.dpr,n=r.offscreenCanvasOpt,i=r.layerOpt,a=r.isSafari;if(!e||!n||!i)return;var o;this.type==="full"&&(o=new xm(t,{dpr:e,offscreenCanvasOpt:n,layerOpt:i},this.post.bind(this))),this.type==="sub"&&(o=new Di(t,{dpr:e,offscreenCanvasOpt:n,layerOpt:i},this.post.bind(this)),o.setHasPriorityDraw(this.hasPriorityDraw)),o&&a&&o.setIsSafari(a),o&&r.cameraOpt&&o.setCameraOpt(r.cameraOpt),o&&this.workThreadMap.set(t,o);}},{key:"register",value:function register(){var _this103=this;onmessage=/*#__PURE__*/function(){var _ref170=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee72(r){var t,_iteratorAbruptCompletion,_didIteratorError,_iteratorError,_iterator,_step,_e16,n,i,a,o,_iterator61,_step61,l,_iterator62,_step62,_step62$value,_l7,g,c,_iterator63,_step63,_l8,s;return _regeneratorRuntime().wrap(function _callee72$(_context75){while(1)switch(_context75.prev=_context75.next){case 0:t=r.data;if(!t){_context75.next=56;break;}_iteratorAbruptCompletion=false;_didIteratorError=false;_context75.prev=4;_iterator=_asyncIterator(t.values());case 6:_context75.next=8;return _iterator.next();case 8:if(!(_iteratorAbruptCompletion=!(_step=_context75.sent).done)){_context75.next=40;break;}_e16=_step.value;n=_e16.msgType,i=_e16.viewId,a=_e16.tasksqueue,o=_e16.mainTasksqueueCount;if(!(n===ot.Console)){_context75.next=14;break;}console.log(_this103);return _context75.abrupt("continue",37);case 14:if(!(n===ot.Init)){_context75.next=17;break;}_this103.init(_e16);return _context75.abrupt("continue",37);case 17:if(!(_this103.type==="sub"&&(n===ot.PriorityWorker||n===ot.PriorityMainThreadWorker))){_context75.next=22;break;}n===ot.PriorityWorker?_this103.hasPriorityDraw=!0:n===ot.PriorityMainThreadWorker&&(_this103.hasPriorityDraw=!1);_iterator61=_createForOfIteratorHelper(_this103.workThreadMap.values());try{for(_iterator61.s();!(_step61=_iterator61.n()).done;){l=_step61.value;l.setHasPriorityDraw(_this103.hasPriorityDraw);}}catch(err){_iterator61.e(err);}finally{_iterator61.f();}return _context75.abrupt("continue",37);case 22:if(!(n===ot.TasksQueue&&a!=null&&a.size)){_context75.next=27;break;}_iterator62=_createForOfIteratorHelper(_this103.workThreadMap.entries());try{for(_iterator62.s();!(_step62=_iterator62.n()).done;){_step62$value=_slicedToArray(_step62.value,2),_l7=_step62$value[0],g=_step62$value[1];c=a.get(_l7);c&&g.on(c);}}catch(err){_iterator62.e(err);}finally{_iterator62.f();}_this103.type==="full"&&Vt(o)&&_this103.post({workerTasksqueueCount:o});return _context75.abrupt("continue",37);case 27:if(!(i===Fi)){_context75.next=31;break;}_iterator63=_createForOfIteratorHelper(_this103.workThreadMap.values());try{for(_iterator63.s();!(_step63=_iterator63.n()).done;){_l8=_step63.value;_l8.on(_e16),n===ot.Destroy&&_this103.workThreadMap["delete"](i);}}catch(err){_iterator63.e(err);}finally{_iterator63.f();}return _context75.abrupt("continue",37);case 31:s=_this103.workThreadMap.get(i);_context75.t0=s;if(!_context75.t0){_context75.next=37;break;}_context75.next=36;return s.on(_e16);case 36:n===ot.Destroy&&_this103.workThreadMap["delete"](i);case 37:_iteratorAbruptCompletion=false;_context75.next=6;break;case 40:_context75.next=46;break;case 42:_context75.prev=42;_context75.t1=_context75["catch"](4);_didIteratorError=true;_iteratorError=_context75.t1;case 46:_context75.prev=46;_context75.prev=47;if(!(_iteratorAbruptCompletion&&_iterator["return"]!=null)){_context75.next=51;break;}_context75.next=51;return _iterator["return"]();case 51:_context75.prev=51;if(!_didIteratorError){_context75.next=54;break;}throw _iteratorError;case 54:return _context75.finish(51);case 55:return _context75.finish(46);case 56:case"end":return _context75.stop();}},_callee72,null,[[4,42,46,56],[47,,51,55]]);}));return function onmessage(_x84){return _ref170.apply(this,arguments);};}();}},{key:"post",value:function post(r,t){t?this._self.postMessage(r,t):this._self.postMessage(r);}}]);}();var xm=/*#__PURE__*/function(_Ai){function xm(t,e,n){var _this104;_classCallCheck(this,xm);_this104=_callSuper(this,xm,[t,e,"full"/* Full */]);tt(_this104,"type","full");tt(_this104,"serviceDrawLayer");tt(_this104,"localDrawLayer");tt(_this104,"snapshotFullLayer");tt(_this104,"methodBuilder");tt(_this104,"localWork");tt(_this104,"serviceWork");tt(_this104,"_post");tt(_this104,"taskUpdateCameraId");tt(_this104,"debounceUpdateCameraId");tt(_this104,"debounceUpdateCache",/* @__PURE__ */new Set());_this104._post=n;var i=re.bufferSize.sub;_this104.serviceDrawLayer=_this104.createLayer("serviceDrawLayer",_this104.scene,_objectSpread(_objectSpread({},e.layerOpt),{},{bufferSize:i,contextType:"2d"})),_this104.localDrawLayer=_this104.createLayer("localDrawLayer",_this104.scene,_objectSpread(_objectSpread({},e.layerOpt),{},{bufferSize:i,contextType:"2d"}));var a={thread:_this104,viewId:_this104.viewId,vNodes:_this104.vNodes,fullLayer:_this104.fullLayer};_this104.localWork=new gm(_objectSpread(_objectSpread({},a),{},{drawLayer:_this104.localDrawLayer})),_this104.serviceWork=new mm(_objectSpread(_objectSpread({},a),{},{drawLayer:_this104.serviceDrawLayer})),_this104.methodBuilder=new Xi([wt.CopyNode,wt.SetColorNode,wt.DeleteNode,wt.RotateNode,wt.ScaleNode,wt.TranslateNode,wt.ZIndexNode,wt.SetFontStyle,wt.SetPoint,wt.SetLock,wt.SetShapeOpt]).registerForWorker(_this104),_this104.vNodes.init(_this104.fullLayer);return _this104;}_inherits(xm,_Ai);return _createClass(xm,[{key:"combinePost",value:function(){var _combinePost=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee73(){var _this105=this;var a,o,_this$combinePostData,t,e,n,s,_iterator64,_step64,l,g,i;return _regeneratorRuntime().wrap(function _callee73$(_context76){while(1)switch(_context76.prev=_context76.next){case 0:_this$combinePostData=this.combinePostData(),t=_this$combinePostData.render,e=_objectWithoutProperties(_this$combinePostData,_excluded3);if(!(t!=null&&t.length)){_context76.next=28;break;}s=[];_iterator64=_createForOfIteratorHelper(t);_context76.prev=4;_iterator64.s();case 6:if((_step64=_iterator64.n()).done){_context76.next=19;break;}l=_step64.value;if(!l.rect){_context76.next=17;break;}if(!(l.rect=this.safariFixRect(Jt(l.rect),this.dpr),!l.rect)){_context76.next=11;break;}return _context76.abrupt("continue",17);case 11:if(!(l.drawCanvas&&l.rect&&l.rect.w>0&&l.rect.h>0)){_context76.next=16;break;}_context76.next=14;return this.getRectImageBitmap(l);case 14:g=_context76.sent;l.imageBitmap=g,n||(n=[]),n.push(g);case 16:s.push(l);case 17:_context76.next=6;break;case 19:_context76.next=24;break;case 21:_context76.prev=21;_context76.t0=_context76["catch"](4);_iterator64.e(_context76.t0);case 24:_context76.prev=24;_iterator64.f();return _context76.finish(24);case 27:e.render=s;case 28:i=(a=e.sp)==null?void 0:a.filter(function(s){return s.type!==ot.None||s.isLockSentEventCursor;});i!=null&&i.length?e.sp=i.map(function(s){return _objectSpread(_objectSpread({},s),{},{viewId:_this105.viewId});}):delete e.sp,e.fullWorkerDrawCount===void 0&&delete e.fullWorkerDrawCount,e.consumeCount===void 0&&delete e.consumeCount,(e!=null&&e.fullWorkerDrawCount||e.consumeCount||i!=null&&i.length||(o=e.render)!=null&&o.length)&&this._post(e,n),this.delayPostDoneResolve&&this.delayPostDoneResolve(!0);case 30:case"end":return _context76.stop();}},_callee73,this,[[4,21,24,27]]);}));function combinePost(){return _combinePost.apply(this,arguments);}return combinePost;}()},{key:"on",value:function(){var _on2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee74(t){var _this106=this;var e,n,i,a,o,s,l,g,_l9;return _regeneratorRuntime().wrap(function _callee74$(_context77){while(1)switch(_context77.prev=_context77.next){case 0:if(!this.methodBuilder.consumeForWorker(t)){_context77.next=2;break;}return _context77.abrupt("return");case 2:e=t.msgType,n=t.dataType,i=t.workId,a=t.toolsType,o=t.workState,s=t.workIds;_context77.t0=e;_context77.next=_context77.t0===ot.AuthClear?6:_context77.t0===ot.CreateWork?9:_context77.t0===ot.DrawWork?11:_context77.t0===ot.Select?20:_context77.t0===ot.UpdateNode?27:_context77.t0===ot.FullWork?27:_context77.t0===ot.RemoveNode?29:_context77.t0===ot.GetTextActive?32:_context77.t0===ot.CursorHover?35:_context77.t0===ot.CursorBlur?38:_context77.t0===ot.GetVNodeInfo?41:43;break;case 6:l=t.clearUids,g=t.localUid;this.vNodes.setCanClearUids(l),this.vNodes.setLocalUid(g);return _context77.abrupt("break",43);case 9:a!==dt.LaserPen&&this.createLocalWork(t);return _context77.abrupt("break",43);case 11:_context77.t1=a!==dt.LaserPen;if(!_context77.t1){_context77.next=19;break;}if(!(o===It.Done&&n===Tt.Local)){_context77.next=18;break;}_context77.next=16;return this.consumeDrawAll(n,t);case 16:_context77.next=19;break;case 18:this.consumeDraw(n,t);case 19:return _context77.abrupt("break",43);case 20:if(!(i===Wt)){_context77.next=25;break;}_context77.next=23;return this.localWork.updateFullSelectWork(t);case 23:_context77.next=26;break;case 25:this.serviceWork.runSelectWork(t);case 26:return _context77.abrupt("return");case 27:this.consumeFull(n,t);return _context77.abrupt("return");case 29:_context77.next=31;return this.removeNode(t);case 31:return _context77.abrupt("return");case 32:_context77.next=34;return this.checkTextActive(t);case 34:return _context77.abrupt("return");case 35:_context77.next=37;return this.cursorHover(t);case 37:return _context77.abrupt("return");case 38:_context77.next=40;return this.cursorBlur();case 40:return _context77.abrupt("return");case 41:if(i&&s){_l9=s.map(function(g){return _this106.vNodes.get(g);});this.post({sp:[{type:ot.GetVNodeInfo,dataType:Tt.Worker,workId:i,vInfo:_l9}]});}return _context77.abrupt("break",43);case 43:_context77.next=45;return _superPropGet(xm,"on",this,3)([t]);case 45:case"end":return _context77.stop();}},_callee74,this);}));function on(_x85){return _on2.apply(this,arguments);}return on;}()},{key:"removeNode",value:function(){var _removeNode2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee75(t){var _this107=this;var e,n,i,a,o,_iterator65,_step65,_loop7;return _regeneratorRuntime().wrap(function _callee75$(_context79){while(1)switch(_context79.prev=_context79.next){case 0:e=t.dataType,n=t.workId,i=t.removeIds,a=[],o=i||[];if(!(n&&o.push(n.toString()),o.length)){_context79.next=20;break;}_iterator65=_createForOfIteratorHelper(o);_context79.prev=3;_loop7=/*#__PURE__*/_regeneratorRuntime().mark(function _loop7(){var s;return _regeneratorRuntime().wrap(function _loop7$(_context78){while(1)switch(_context78.prev=_context78.next){case 0:s=_step65.value;s===Wt?a.push(_this107.localWork.removeSelector(t,_this107)):e===Tt.Local?a.push(_this107.localWork.removeWork(t).then(function(){_this107.localWork.colloctEffectSelectWork(t),_this107.deleteCachedImagesByWorkId(s);})):e===Tt.Service&&a.push(_this107.serviceWork.removeWork(t).then(function(){_this107.localWork.colloctEffectSelectWork(t),_this107.deleteCachedImagesByWorkId(s);}));case 2:case"end":return _context78.stop();}},_loop7);});_iterator65.s();case 6:if((_step65=_iterator65.n()).done){_context79.next=10;break;}return _context79.delegateYield(_loop7(),"t0",8);case 8:_context79.next=6;break;case 10:_context79.next=15;break;case 12:_context79.prev=12;_context79.t1=_context79["catch"](3);_iterator65.e(_context79.t1);case 15:_context79.prev=15;_iterator65.f();return _context79.finish(15);case 18:_context79.next=20;return Promise.all(a);case 20:case"end":return _context79.stop();}},_callee75,null,[[3,12,15,18]]);}));function removeNode(_x86){return _removeNode2.apply(this,arguments);}return removeNode;}()},{key:"checkTextActive",value:function(){var _checkTextActive2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee76(t){var e;return _regeneratorRuntime().wrap(function _callee76$(_context80){while(1)switch(_context80.prev=_context80.next){case 0:e=t.dataType;_context80.t0=e===Tt.Local;if(!_context80.t0){_context80.next=5;break;}_context80.next=5;return this.localWork.checkTextActive(t);case 5:case"end":return _context80.stop();}},_callee76,this);}));function checkTextActive(_x87){return _checkTextActive2.apply(this,arguments);}return checkTextActive;}()},{key:"clearAll",value:function(){var _clearAll2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee77(){return _regeneratorRuntime().wrap(function _callee77$(_context81){while(1)switch(_context81.prev=_context81.next){case 0:this.vNodes.clear();_superPropGet(xm,"clearAll",this,3)([]);this.localDrawLayer&&(this.localDrawLayer.parent.children.forEach(function(t){t.name!=="viewport"&&t.remove();}),this.localDrawLayer.removeAllChildren());this.serviceDrawLayer&&(this.serviceDrawLayer.parent.children.forEach(function(t){t.name!=="viewport"&&t.remove();}),this.serviceDrawLayer.removeAllChildren());_context81.next=6;return this.post({render:[{isClearAll:!0,clearCanvas:St.Bg,viewId:this.viewId},{isClearAll:!0,clearCanvas:St.ServiceFloat,viewId:this.viewId},{isClearAll:!0,clearCanvas:St.Float,viewId:this.viewId}],sp:[{type:ot.Clear}]});case 6:case"end":return _context81.stop();}},_callee77,this);}));function clearAll(){return _clearAll2.apply(this,arguments);}return clearAll;}()},{key:"updateLayer",value:function updateLayer(t){var e=t.width,n=t.height;_superPropGet(xm,"updateLayer",this,3)([t]),this.localDrawLayer&&(this.localDrawLayer.parent.setAttribute("width",e),this.localDrawLayer.parent.setAttribute("height",n),this.localDrawLayer.setAttribute("size",[e,n]),this.localDrawLayer.setAttribute("pos",[e*0.5,n*0.5])),this.serviceDrawLayer&&(this.serviceDrawLayer.parent.setAttribute("width",e),this.serviceDrawLayer.parent.setAttribute("height",n),this.serviceDrawLayer.setAttribute("size",[e,n]),this.serviceDrawLayer.setAttribute("pos",[e*0.5,n*0.5]));}},{key:"setCameraOpt",value:function setCameraOpt(t){this.cameraOpt=t;var e=t.scale,n=t.centerX,i=t.centerY,a=t.width,o=t.height;(a!==this.scene.width||o!==this.scene.height)&&this.updateScene({width:a,height:o}),this.fullLayer&&(this.fullLayer.setAttribute("scale",[e,e]),this.fullLayer.setAttribute("translate",[-n,-i])),this.localDrawLayer&&(this.localDrawLayer.setAttribute("scale",[e,e]),this.localDrawLayer.setAttribute("translate",[-n,-i])),this.serviceDrawLayer&&(this.serviceDrawLayer.setAttribute("scale",[e,e]),this.serviceDrawLayer.setAttribute("translate",[-n,-i]));}},{key:"getLayer",value:function getLayer(t){switch(t){case St.Bg:return this.fullLayer;case St.ServiceFloat:return this.serviceDrawLayer;case St.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 _callee78(t,e){var n;return _regeneratorRuntime().wrap(function _callee78$(_context82){while(1)switch(_context82.prev=_context82.next){case 0:_context82.next=2;return this.localWork.colloctEffectSelectWork(e);case 2:n=_context82.sent;_context82.t0=n&&t===Tt.Local;if(!_context82.t0){_context82.next=7;break;}_context82.next=7;return this.localWork.consumeFull(n);case 7:n&&t===Tt.Service&&this.serviceWork.consumeFull(n);case 8:case"end":return _context82.stop();}},_callee78,this);}));function consumeFull(_x88,_x89){return _consumeFull2.apply(this,arguments);}return consumeFull;}()},{key:"consumeDraw",value:function(){var _consumeDraw4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee79(t,e){var n;return _regeneratorRuntime().wrap(function _callee79$(_context83){while(1)switch(_context83.prev=_context83.next){case 0:n=e.workId;_context83.t0=t===Tt.Local&&n;if(!_context83.t0){_context83.next=6;break;}this.localWork.getWorkShape(n.toString())||this.createLocalWork(e);_context83.next=6;return this.localWork.consumeDraw(e,this.serviceWork);case 6:t===Tt.Service&&this.serviceWork.consumeDraw(e);case 7:case"end":return _context83.stop();}},_callee79,this);}));function consumeDraw(_x90,_x91){return _consumeDraw4.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee80(t,e){var n;return _regeneratorRuntime().wrap(function _callee80$(_context84){while(1)switch(_context84.prev=_context84.next){case 0:n=e.workId;_context84.t0=t===Tt.Local&&n;if(!_context84.t0){_context84.next=6;break;}this.localWork.getWorkShape(n.toString())||this.createLocalWork(e);_context84.next=6;return this.localWork.consumeDrawAll(e,this.serviceWork);case 6:case"end":return _context84.stop();}},_callee80,this);}));function consumeDrawAll(_x92,_x93){return _consumeDrawAll3.apply(this,arguments);}return consumeDrawAll;}()},{key:"updateDpr",value:function(){var _updateDpr2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee81(t){return _regeneratorRuntime().wrap(function _callee81$(_context85){while(1)switch(_context85.prev=_context85.next){case 0:_superPropGet(xm,"updateDpr",this,3)([t]);_context85.next=3;return this.post({render:[{isClearAll:!0,clearCanvas:St.Bg,viewId:this.viewId},{isDrawAll:!0,drawCanvas:St.Bg,viewId:this.viewId}]});case 3:case"end":return _context85.stop();}},_callee81,this);}));function updateDpr(_x94){return _updateDpr2.apply(this,arguments);}return updateDpr;}()},{key:"updateCamera",value:function(){var _updateCamera=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee82(t){var _this108=this;var a,e,n,i,o,d,_iterator66,_step66,_step66$value,y,P,s,_iterator67,_step67,_step67$value,_d12,_y19,_P8,l,g,_d8,_iterator68,_step68,_y15,c,_iterator69,_step69,_d9,_y16,_iterator70,_step70,_P5,_iterator71,_step71,_step71$value,_d11,_y18,_P7,S,v,_T45,_f39,p,u,m,M,_iterator72,_step72,_step72$value,_d10,_y17;return _regeneratorRuntime().wrap(function _callee82$(_context86){while(1)switch(_context86.prev=_context86.next){case 0:e=[],n=t.cameraOpt,i=t.scenePath;if(!(n&&!le(this.cameraOpt,n))){_context86.next=40;break;}this.taskUpdateCameraId&&(clearTimeout(this.taskUpdateCameraId),this.taskUpdateCameraId=void 0);o=!!this.serviceDrawLayer.children.length;if(!i){_context86.next=30;break;}d=!1;_iterator66=_createForOfIteratorHelper(this.localWork.getWorkShapes().entries());_context86.prev=7;_iterator66.s();case 9:if((_step66=_iterator66.n()).done){_context86.next=19;break;}_step66$value=_slicedToArray(_step66.value,2),y=_step66$value[0],P=_step66$value[1];_context86.t0=P.toolsType;_context86.next=_context86.t0===dt.Text?14:_context86.t0===dt.PencilEraser?14:_context86.t0===dt.Eraser?14:_context86.t0===dt.Selector?14:_context86.t0===dt.LaserPen?14:15;break;case 14:return _context86.abrupt("break",17);case 15:y!==be&&y!==Wt&&(d=!0);return _context86.abrupt("break",17);case 17:_context86.next=9;break;case 19:_context86.next=24;break;case 21:_context86.prev=21;_context86.t1=_context86["catch"](7);_iterator66.e(_context86.t1);case 24:_context86.prev=24;_iterator66.f();return _context86.finish(24);case 27:if(!d){_context86.next=30;break;}this.taskUpdateCameraId=setTimeout(function(){_this108.taskUpdateCameraId=void 0,_this108.updateCamera(t);},Cn);return _context86.abrupt("return");case 30:s=/* @__PURE__ */new Map();_iterator67=_createForOfIteratorHelper(this.vNodes.getNodesByType(dt.Text).entries());try{for(_iterator67.s();!(_step67=_iterator67.n()).done;){_step67$value=_slicedToArray(_step67.value,2),_d12=_step67$value[0],_y19=_step67$value[1];_P8=_y19.rect;s.set(_d12,Jt(_P8));}}catch(err){_iterator67.e(err);}finally{_iterator67.f();}l=new Set(s.keys());g=!1;if(this.localWork.hasSelector()){_d8=(a=this.localWork.getSelector())==null?void 0:a.selectIds;if(_d8){g=!0;_iterator68=_createForOfIteratorHelper(_d8);try{for(_iterator68.s();!(_step68=_iterator68.n()).done;){_y15=_step68.value;l.add(_y15);}}catch(err){_iterator68.e(err);}finally{_iterator68.f();}}}c=!1;if(this.serviceWork.selectorWorkShapes.size){_iterator69=_createForOfIteratorHelper(this.serviceWork.selectorWorkShapes.values());try{for(_iterator69.s();!(_step69=_iterator69.n()).done;){_d9=_step69.value;_y16=_d9.selectIds;if(_y16){c=!0;_iterator70=_createForOfIteratorHelper(_y16);try{for(_iterator70.s();!(_step70=_iterator70.n()).done;){_P5=_step70.value;l.add(_P5);}}catch(err){_iterator70.e(err);}finally{_iterator70.f();}}}}catch(err){_iterator69.e(err);}finally{_iterator69.f();}}if(this.setCameraOpt(n),this.vNodes.curNodeMap.size){this.vNodes.clearTarget(),this.vNodes.updateHighLevelNodesRect(l),this.debounceUpdateCameraId&&clearTimeout(this.debounceUpdateCameraId);_iterator71=_createForOfIteratorHelper(s.entries());try{for(_iterator71.s();!(_step71=_iterator71.n()).done;){_step71$value=_slicedToArray(_step71.value,2),_d11=_step71$value[0],_y18=_step71$value[1];_P7=this.vNodes.get(_d11);if(_P7){S=_y18,v=_P7.rect,_T45=this.getSceneRect(),_f39=fr(S,_T45),p=fr(v,_T45);u=!1;if((_f39!==p||S.w!==v.w||S.h!==v.h||p===Me.intersect)&&(u=!0),u){m=_P7.toolsType,M=_P7.opt;m===dt.Text&&M.workState===It.Done&&this.debounceUpdateCache.add(_d11);}}}}catch(err){_iterator71.e(err);}finally{_iterator71.f();}if(g&&this.localWork.reRenderSelector(),c){_iterator72=_createForOfIteratorHelper(this.serviceWork.selectorWorkShapes.entries());try{for(_iterator72.s();!(_step72=_iterator72.n()).done;){_step72$value=_slicedToArray(_step72.value,2),_d10=_step72$value[0],_y17=_step72$value[1];this.serviceWork.runSelectWork({workId:_d10,selectIds:_y17.selectIds,msgType:ot.Select,dataType:Tt.Service,viewId:this.viewId});}}catch(err){_iterator72.e(err);}finally{_iterator72.f();}}this.debounceUpdateCameraId=setTimeout(function(){var y;_this108.debounceUpdateCameraId=void 0;var d=[];var _iterator73=_createForOfIteratorHelper(_this108.debounceUpdateCache.values()),_step73;try{for(_iterator73.s();!(_step73=_iterator73.n()).done;){var _P6=_step73.value;if((y=_this108.fullLayer)==null?void 0:y.getElementsByName(_P6)[0]){var v=_this108.vNodes.get(_P6);if(v){var _T44=v.toolsType,_f38=v.opt,p=v.rect,u=_this108.localWork.setFullWork({toolsType:_T44,opt:_f38,workId:_P6});if(u){var m=_this108.getSceneRect(),M=fr(p,m);d.push(u.consumeServiceAsync({isFullWork:!0,replaceId:_P6,isDrawLabel:M!==Me.outside}));}}}_this108.debounceUpdateCache["delete"](_P6);}}catch(err){_iterator73.e(err);}finally{_iterator73.f();}d.length?Promise.all(d).then(function(){var P=[];P.push({isClearAll:!0,clearCanvas:St.Bg,viewId:_this108.viewId},{isDrawAll:!0,drawCanvas:St.Bg,viewId:_this108.viewId}),P.length&&_this108.post({render:P}),_this108.vNodes.updateLowLevelNodesRect(),_this108.vNodes.clearHighLevelIds();}):(_this108.vNodes.updateLowLevelNodesRect(),_this108.vNodes.clearHighLevelIds());},Cn);}o&&e.push({isClearAll:!0,clearCanvas:St.ServiceFloat,viewId:this.viewId}),this.vNodes.hasRenderNodes()&&e.push({isClearAll:!0,clearCanvas:St.Bg,viewId:this.viewId},{isDrawAll:!0,drawCanvas:St.Bg,viewId:this.viewId}),e.length&&this.post({render:e});case 40:case"end":return _context86.stop();}},_callee82,this,[[7,21,24,27]]);}));function updateCamera(_x95){return _updateCamera.apply(this,arguments);}return updateCamera;}()},{key:"getRectImageBitmap",value:function getRectImageBitmap(t){var e=t.rect,n=t.drawCanvas,i=Math.floor(e.x*this.dpr),a=Math.floor(e.y*this.dpr),o=Math.floor(e.w*this.dpr||1),s=Math.floor(e.h*this.dpr||1);return createImageBitmap(this.getOffscreen(n),i,a,o,s,{resizeQuality:"low"});}},{key:"cursorHover",value:function(){var _cursorHover2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee83(t){return _regeneratorRuntime().wrap(function _callee83$(_context87){while(1)switch(_context87.prev=_context87.next){case 0:_context87.next=2;return this.localWork.cursorHover(t);case 2:case"end":return _context87.stop();}},_callee83,this);}));function cursorHover(_x96){return _cursorHover2.apply(this,arguments);}return cursorHover;}()},{key:"cursorBlur",value:function(){var _cursorBlur2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee84(){return _regeneratorRuntime().wrap(function _callee84$(_context88){while(1)switch(_context88.prev=_context88.next){case 0:_context88.next=2;return this.localWork.cursorBlur();case 2:case"end":return _context88.stop();}},_callee84,this);}));function cursorBlur(){return _cursorBlur2.apply(this,arguments);}return cursorBlur;}()},{key:"destroy",value:function destroy(){_superPropGet(xm,"destroy",this,3)([]);}}]);}(Ai);var Di=/*#__PURE__*/function(_Ai2){function Di(t,e,n){var _this109;_classCallCheck(this,Di);_this109=_callSuper(this,Di,[t,e,"sub"/* Sub */]);tt(_this109,"type","sub");tt(_this109,"_post");tt(_this109,"topLayer");tt(_this109,"snapshotFullLayer");tt(_this109,"serviceWork");tt(_this109,"localWork");tt(_this109,"topLayerWork");_this109._post=n;var i=re.bufferSize.sub;_this109.topLayer=_this109.createLayer("topLayer",_this109.scene,_objectSpread(_objectSpread({},e.layerOpt),{},{bufferSize:i,contextType:"2d"}));var a={thread:_this109,viewId:_this109.viewId,vNodes:_this109.vNodes,fullLayer:_this109.fullLayer,topLayer:_this109.topLayer};_this109.localWork=new vm(a),_this109.topLayerWork=new ym(a),_this109.vNodes.init(_this109.fullLayer);return _this109;}_inherits(Di,_Ai2);return _createClass(Di,[{key:"combinePost",value:function(){var _combinePost2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee85(){var _this110=this;var a,o,_this$combinePostData2,t,e,n,s,_iterator74,_step74,l,g,i;return _regeneratorRuntime().wrap(function _callee85$(_context89){while(1)switch(_context89.prev=_context89.next){case 0:_this$combinePostData2=this.combinePostData(),t=_this$combinePostData2.render,e=_objectWithoutProperties(_this$combinePostData2,_excluded4);if(!(t!=null&&t.length)){_context89.next=28;break;}s=[];_iterator74=_createForOfIteratorHelper(t);_context89.prev=4;_iterator74.s();case 6:if((_step74=_iterator74.n()).done){_context89.next=19;break;}l=_step74.value;if(!l.rect){_context89.next=17;break;}if(!(l.rect=this.safariFixRect(Jt(l.rect),this.dpr),!l.rect)){_context89.next=11;break;}return _context89.abrupt("continue",17);case 11:if(!(l.drawCanvas&&l.rect&&l.rect.w>0&&l.rect.h>0)){_context89.next=16;break;}_context89.next=14;return this.getRectImageBitmap(l);case 14:g=_context89.sent;l.imageBitmap=g,n||(n=[]),n.push(g);case 16:s.push(l);case 17:_context89.next=6;break;case 19:_context89.next=24;break;case 21:_context89.prev=21;_context89.t0=_context89["catch"](4);_iterator74.e(_context89.t0);case 24:_context89.prev=24;_iterator74.f();return _context89.finish(24);case 27:e.render=s;case 28:i=(a=e.sp)==null?void 0:a.filter(function(s){return s.type!==ot.None;});i!=null&&i.length?e.sp=i.map(function(s){return _objectSpread(_objectSpread({},s),{},{viewId:_this110.viewId});}):delete e.sp,e.consumeCount===void 0&&delete e.consumeCount,e.subWorkerDrawCount===void 0&&delete e.subWorkerDrawCount,(i!=null&&i.length||e.consumeCount||e.subWorkerDrawCount||(o=e==null?void 0:e.render)!=null&&o.length)&&this._post(e,n),this.delayPostDoneResolve&&this.delayPostDoneResolve(!0);case 30:case"end":return _context89.stop();}},_callee85,this,[[4,21,24,27]]);}));function combinePost(){return _combinePost2.apply(this,arguments);}return combinePost;}()},{key:"getLayer",value:function getLayer(t,e){if(e&&this.snapshotFullLayer)return this.snapshotFullLayer;switch(t){case St.TopFloat:return this.topLayer;default:return this.fullLayer;}}},{key:"on",value:function(){var _on3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee86(t){var e,n,i,a,o,s;return _regeneratorRuntime().wrap(function _callee86$(_context90){while(1)switch(_context90.prev=_context90.next){case 0:e=t.msgType,n=t.toolsType,i=t.opt,a=t.dataType,o=t.workState;_context90.t0=e;_context90.next=_context90.t0===ot.UpdateTools?4:_context90.t0===ot.CreateWork?9:_context90.t0===ot.DrawWork?11:_context90.t0===ot.RemoveNode?18:_context90.t0===ot.FullWork?21:_context90.t0===ot.Snapshot?26:_context90.t0===ot.BoundingBox?33:40;break;case 4:if(!(n&&this.topLayerWork.canUseTopLayer(n)&&i)){_context90.next=8;break;}s={toolsType:n,toolsOpt:i};this.topLayerWork.setToolsOpt(s);return _context90.abrupt("return");case 8:return _context90.abrupt("break",40);case 9:this.createLocalWork(t);return _context90.abrupt("return");case 11:if(!(o===It.Done&&a===Tt.Local)){_context90.next=16;break;}_context90.next=14;return this.consumeDrawAll(a,t);case 14:_context90.next=17;break;case 16:this.consumeDraw(a,t);case 17:return _context90.abrupt("return");case 18:_context90.next=20;return this.removeNode(t);case 20:return _context90.abrupt("return");case 21:_context90.t1=n&&this.topLayerWork.canUseTopLayer(n);if(!_context90.t1){_context90.next=25;break;}_context90.next=25;return this.consumeDrawAll(a,t);case 25:return _context90.abrupt("return");case 26:this.snapshotFullLayer=this.createLayer("snapshotFullLayer",this.scene,_objectSpread(_objectSpread({},this.opt.layerOpt),{},{bufferSize:this.viewId===Qe?6e3:3e3,contextType:"2d"}));_context90.t2=this.snapshotFullLayer;if(!_context90.t2){_context90.next=32;break;}_context90.next=31;return this.getSnapshot(t);case 31:this.snapshotFullLayer=void 0;case 32:return _context90.abrupt("return");case 33:this.snapshotFullLayer=this.createLayer("snapshotFullLayer",this.scene,_objectSpread(_objectSpread({},this.opt.layerOpt),{},{bufferSize:this.viewId===Qe?6e3:3e3,contextType:"2d"}));_context90.t3=this.snapshotFullLayer;if(!_context90.t3){_context90.next=39;break;}_context90.next=38;return this.getBoundingRect(t);case 38:this.snapshotFullLayer=void 0;case 39:return _context90.abrupt("return");case 40:_context90.next=42;return _superPropGet(Di,"on",this,3)([t]);case 42:case"end":return _context90.stop();}},_callee86,this);}));function on(_x97){return _on3.apply(this,arguments);}return on;}()},{key:"createLocalWork",value:function createLocalWork(t){var e=t.workId,n=t.toolsType,i=t.opt;if(n&&this.topLayerWork.canUseTopLayer(n)&&e&&i){this.topLayerWork.getToolsOpt()||this.topLayerWork.setToolsOpt({toolsType:n,toolsOpt:i}),this.topLayerWork.setWorkOptions(e.toString(),i);return;}n&&this.localWork.canUseSubWorker(n)&&_superPropGet(Di,"createLocalWork",this,3)([t]);}},{key:"removeNode",value:function(){var _removeNode3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee87(t){var e;return _regeneratorRuntime().wrap(function _callee87$(_context91){while(1)switch(_context91.prev=_context91.next){case 0:e=t.dataType;_context91.t0=e===Tt.Local;if(!_context91.t0){_context91.next=5;break;}_context91.next=5;return this.localWork.removeWork(t);case 5:case"end":return _context91.stop();}},_callee87,this);}));function removeNode(_x98){return _removeNode3.apply(this,arguments);}return removeNode;}()},{key:"getOffscreen",value:function getOffscreen(t,e){return this.getLayer(t,e).parent.canvas;}},{key:"consumeDraw",value:function(){var _consumeDraw5=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee88(t,e){var n,i;return _regeneratorRuntime().wrap(function _callee88$(_context92){while(1)switch(_context92.prev=_context92.next){case 0:n=e.workId,i=e.toolsType;if(!n){_context92.next=11;break;}if(!(i&&this.topLayerWork.canUseTopLayer(i))){_context92.next=5;break;}t===Tt.Local&&(this.topLayerWork.getWorkShape(n.toString())||this.createLocalWork(e)),this.topLayerWork.consumeDraw(e);return _context92.abrupt("return");case 5:_context92.t0=i&&this.localWork.canUseSubWorker(i);if(!_context92.t0){_context92.next=10;break;}this.localWork.getWorkShape(n.toString())||this.createLocalWork(e);_context92.next=10;return this.localWork.consumeDraw(e);case 10:return _context92.abrupt("return");case 11:case"end":return _context92.stop();}},_callee88,this);}));function consumeDraw(_x99,_x100){return _consumeDraw5.apply(this,arguments);}return consumeDraw;}()},{key:"consumeDrawAll",value:function(){var _consumeDrawAll4=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee89(t,e){var n,i,a,o;return _regeneratorRuntime().wrap(function _callee89$(_context93){while(1)switch(_context93.prev=_context93.next){case 0:n=e.workId,i=e.toolsType,a=e.dataType;if(!n){_context93.next=8;break;}o=n.toString();if(!(i&&this.topLayerWork.canUseTopLayer(i))){_context93.next=6;break;}a===Tt.Local&&(this.topLayerWork.getWorkShape(o)||this.createLocalWork(e)),this.topLayerWork.consumeDrawAll(e);return _context93.abrupt("return");case 6:i&&this.localWork.canUseSubWorker(i)&&(this.localWork.getWorkShape(o)||_superPropGet(Di,"createLocalWork",this,3)([e]),this.localWork.consumeDrawAll(e));return _context93.abrupt("return");case 8:case"end":return _context93.stop();}},_callee89,this);}));function consumeDrawAll(_x101,_x102){return _consumeDrawAll4.apply(this,arguments);}return consumeDrawAll;}()},{key:"clearAll",value:function(){var _clearAll3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee90(){return _regeneratorRuntime().wrap(function _callee90$(_context94){while(1)switch(_context94.prev=_context94.next){case 0:this.vNodes.clear();_superPropGet(Di,"clearAll",this,3)([]);this.topLayer&&(this.topLayer.parent.children.forEach(function(t){t.name!=="viewport"&&t.remove();}),this.topLayer.removeAllChildren());_context94.next=5;return this.post({render:[{isClearAll:!0,clearCanvas:St.TopFloat,viewId:this.viewId}],sp:[{type:ot.Clear}]});case 5:case"end":return _context94.stop();}},_callee90,this);}));function clearAll(){return _clearAll3.apply(this,arguments);}return clearAll;}()},{key:"getRectImageBitmap",value:function getRectImageBitmap(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!1;var n=arguments.length>2?arguments[2]:undefined;var i=t.rect,a=t.drawCanvas,o=Math.floor(i.x*this.dpr),s=Math.floor(i.y*this.dpr),l=Math.floor(i.w*this.dpr||1),g=Math.floor(i.h*this.dpr||1);return createImageBitmap(this.getOffscreen(a,e),o,s,l,g,n);}},{key:"updateLayer",value:function updateLayer(t){var e=t.width,n=t.height;_superPropGet(Di,"updateLayer",this,3)([t]),this.topLayer&&(this.topLayer.parent.setAttribute("width",e),this.topLayer.parent.setAttribute("height",n),this.topLayer.setAttribute("size",[e,n]),this.topLayer.setAttribute("pos",[e*0.5,n*0.5])),this.snapshotFullLayer&&(this.snapshotFullLayer.parent.setAttribute("width",e),this.snapshotFullLayer.parent.setAttribute("height",n),this.snapshotFullLayer.setAttribute("size",[e,n]),this.snapshotFullLayer.setAttribute("pos",[e*0.5,n*0.5]));}},{key:"updateDpr",value:function(){var _updateDpr3=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee91(t){var e,n,i;return _regeneratorRuntime().wrap(function _callee91$(_context95){while(1)switch(_context95.prev=_context95.next){case 0:_superPropGet(Di,"updateDpr",this,3)([t]);e=!!this.topLayerWork.localWorkShapes.size,n=!!this.localWork.getWorkShapes().size,i=[];n&&i.push({isClearAll:!0,clearCanvas:St.Float,viewId:this.viewId});e&&i.push({isClearAll:!0,clearCanvas:St.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();}},_callee91,this);}));function updateDpr(_x103){return _updateDpr3.apply(this,arguments);}return updateDpr;}()},{key:"updateCamera",value:function(){var _updateCamera2=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee92(t){var _this111=this;var e,n,i,a,_iterator75,_step75,_loop8;return _regeneratorRuntime().wrap(function _callee92$(_context97){while(1)switch(_context97.prev=_context97.next){case 0:e=[],n=t.cameraOpt;if(!(n&&!le(this.cameraOpt,n))){_context97.next=25;break;}i=!!this.topLayerWork.localWorkShapes.size,a=!!this.localWork.getWorkShapes().size;if(!(a&&this.localWork.workShapesDone(),this.setCameraOpt(n),a&&e.push({isClearAll:!0,clearCanvas:St.Float,viewId:this.viewId}),i)){_context97.next=21;break;}e.push({isClearAll:!0,clearCanvas:St.TopFloat,viewId:this.viewId});_iterator75=_createForOfIteratorHelper(this.topLayerWork.localWorkShapes.entries());_context97.prev=6;_loop8=/*#__PURE__*/_regeneratorRuntime().mark(function _loop8(){var _step75$value,o,s,l;return _regeneratorRuntime().wrap(function _loop8$(_context96){while(1)switch(_context96.prev=_context96.next){case 0:_step75$value=_slicedToArray(_step75.value,2),o=_step75$value[0],s=_step75$value[1];if(s.totalRect){_this111.topLayer.getElementsByName(o.toString()).forEach(function(g){var c=g.getBoundingClientRect(),d=Dt({x:c.x,y:c.y,w:c.width,h:c.height});l=Pt(l,d);}),s.totalRect=l,_this111.topLayerWork.localWorkShapes.set(o,s);}case 2:case"end":return _context96.stop();}},_loop8);});_iterator75.s();case 9:if((_step75=_iterator75.n()).done){_context97.next=13;break;}return _context97.delegateYield(_loop8(),"t0",11);case 11:_context97.next=9;break;case 13:_context97.next=18;break;case 15:_context97.prev=15;_context97.t1=_context97["catch"](6);_iterator75.e(_context97.t1);case 18:_context97.prev=18;_iterator75.f();return _context97.finish(18);case 21:_context97.t2=e.length;if(!_context97.t2){_context97.next=25;break;}_context97.next=25;return this.post({render:e});case 25:case"end":return _context97.stop();}},_callee92,this,[[6,15,18,21]]);}));function updateCamera(_x104){return _updateCamera2.apply(this,arguments);}return updateCamera;}()},{key:"setCameraOpt",value:function setCameraOpt(t,e){this.cameraOpt=t;var n=t.scale,i=t.centerX,a=t.centerY,o=t.width,s=t.height;(o!==this.scene.width||s!==this.scene.height)&&this.updateScene({width:o,height:s}),e?(e.setAttribute("scale",[n,n]),e.setAttribute("translate",[-i,-a])):(this.fullLayer.setAttribute("scale",[n,n]),this.fullLayer.setAttribute("translate",[-i,-a]),this.topLayer.setAttribute("scale",[n,n]),this.topLayer.setAttribute("translate",[-i,-a]));}},{key:"getSnapshot",value:function(){var _getSnapshot=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee93(t){var e,n,i,a,o,s,l,_i13,_Object$entries,_Object$entries$_i,c,d,y,P,S,g;return _regeneratorRuntime().wrap(function _callee93$(_context98){while(1)switch(_context98.prev=_context98.next){case 0:e=t.scenePath,n=t.scenes,i=t.cameraOpt,a=t.w,o=t.h;if(!(e&&n&&i&&this.snapshotFullLayer)){_context98.next=26;break;}s=Jt(this.cameraOpt);this.setCameraOpt(i,this.snapshotFullLayer),this.localWork.fullLayer=this.snapshotFullLayer,this.localWork.drawLayer=void 0;_i13=0,_Object$entries=Object.entries(n);case 5:if(!(_i13<_Object$entries.length)){_context98.next=21;break;}_Object$entries$_i=_slicedToArray(_Object$entries[_i13],2),c=_Object$entries$_i[0],d=_Object$entries$_i[1];if(!(d!=null&&d.type)){_context98.next=18;break;}_context98.t0=d==null?void 0:d.type;_context98.next=_context98.t0===ot.UpdateNode?11:_context98.t0===ot.FullWork?11:18;break;case 11:y=d.opt;P=_objectSpread(_objectSpread({},d),{},{opt:y,workId:c,msgType:ot.FullWork,dataType:Tt.Service,viewId:this.viewId});_context98.next=15;return this.localWork.runFullWork(P);case 15:S=_context98.sent;l=Pt(l,S);return _context98.abrupt("break",18);case 18:_i13++;_context98.next=5;break;case 21:a&&o&&(g={resizeWidth:a,resizeHeight:o});_context98.next=24;return this.getSnapshotRender({scenePath:e,curCameraOpt:s,options:g});case 24:this.localWork.fullLayer=this.fullLayer;this.localWork.drawLayer=void 0;case 26:case"end":return _context98.stop();}},_callee93,this);}));function getSnapshot(_x105){return _getSnapshot.apply(this,arguments);}return getSnapshot;}()},{key:"getSnapshotRender",value:function(){var _getSnapshotRender=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee94(t){var o,s,e,n,i,a;return _regeneratorRuntime().wrap(function _callee94$(_context99){while(1)switch(_context99.prev=_context99.next){case 0:e=t.scenePath,n=t.curCameraOpt,i=t.options;((o=this.snapshotFullLayer)==null?void 0:o.parent).render();_context99.next=4;return this.getRectImageBitmap({rect:this.getSceneRect(),drawCanvas:St.None},!0,i);case 4:a=_context99.sent;a&&(this._post({sp:[{type:ot.Snapshot,scenePath:e,imageBitmap:a,viewId:this.viewId}]},[a]),a.close(),(s=this.snapshotFullLayer)==null||s.removeAllChildren(),this.setCameraOpt(n,this.fullLayer));case 6:case"end":return _context99.stop();}},_callee94,this);}));function getSnapshotRender(_x106){return _getSnapshotRender.apply(this,arguments);}return getSnapshotRender;}()},{key:"getBoundingRect",value:function(){var _getBoundingRect=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee95(t){var e,n,i,a,o,_i14,_Object$entries2,_Object$entries2$_i,s,l,g;return _regeneratorRuntime().wrap(function _callee95$(_context100){while(1)switch(_context100.prev=_context100.next){case 0:e=t.scenePath,n=t.scenes,i=t.cameraOpt;if(!(e&&n&&i&&this.snapshotFullLayer)){_context100.next=27;break;}a=Jt(this.cameraOpt);this.setCameraOpt(i,this.snapshotFullLayer),this.localWork.fullLayer=this.snapshotFullLayer,this.localWork.drawLayer=void 0;_i14=0,_Object$entries2=Object.entries(n);case 5:if(!(_i14<_Object$entries2.length)){_context100.next=19;break;}_Object$entries2$_i=_slicedToArray(_Object$entries2[_i14],2),s=_Object$entries2$_i[0],l=_Object$entries2$_i[1];if(!(l!=null&&l.type)){_context100.next=16;break;}_context100.t0=l==null?void 0:l.type;_context100.next=_context100.t0===ot.UpdateNode?11:_context100.t0===ot.FullWork?11:16;break;case 11:_context100.next=13;return this.localWork.runFullWork(_objectSpread(_objectSpread({},l),{},{workId:s,msgType:ot.FullWork,dataType:Tt.Service,viewId:this.viewId}));case 13:g=_context100.sent;o=Pt(o,g);return _context100.abrupt("break",16);case 16:_i14++;_context100.next=5;break;case 19:_context100.t1=o;if(!_context100.t1){_context100.next=23;break;}_context100.next=23;return this.post({sp:[{type:ot.BoundingBox,scenePath:e,rect:o}]});case 23:this.localWork.fullLayer=this.fullLayer;this.localWork.drawLayer=void 0;this.snapshotFullLayer.removeAllChildren();this.setCameraOpt(a,this.fullLayer);case 27:case"end":return _context100.stop();}},_callee95,this);}));function getBoundingRect(_x107){return _getBoundingRect.apply(this,arguments);}return getBoundingRect;}()}]);}(Ai);var Wn=self;Wn.full=new Sm(Wn,qe.Full);
|