@netless/appliance-plugin 1.1.22-beta.12 → 1.1.22-beta.13

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 CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r="/fullWorker-pzH5VV.js",e="/subWorker-CVXZs2.js";exports.fullWorkerUrl=r;exports.subWorkerUrl=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r="/fullWorker-CoABKr.js",e="/subWorker-Dy_EqD.js";exports.fullWorkerUrl=r;exports.subWorkerUrl=e;
@@ -396,7 +396,7 @@ _inherits(l,_r$default22);return _createClass(l,[{key:"texture",get:function get
396
396
  h=="length"||// Node.js 0.10 has enumerable non-index properties on buffers.
397
397
  n&&(h=="offset"||h=="parent")||// PhantomJS 2 has enumerable non-index properties on typed arrays.
398
398
  s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||// Skip index properties.
399
- AT(h,f)))&&l.push(h);return l;}var th=RT,bT=Object.prototype;function DT(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||bT;return i===t;}var vl=DT;function NT(i,e){return function(t){return i(e(t));};}var eh=NT,BT=eh,WT=BT(Object.keys,Object),FT=WT,UT=vl,YT=FT,XT=Object.prototype,zT=XT.hasOwnProperty;function $T(i){if(!UT(i))return YT(i);var e=[];for(var t in Object(i))zT.call(i,t)&&t!="constructor"&&e.push(t);return e;}var jT=$T,GT=ju,kT=qu;function HT(i){return i!=null&&kT(i.length)&&!GT(i);}var gl=HT,KT=th,VT=jT,ZT=gl;function JT(i){return ZT(i)?KT(i):VT(i);}var ml=JT,QT=yo,qT=ml;function _T(i,e){return i&&QT(e,qT(e),i);}var tC=_T;function eC(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e;}var rC=eC,nC=Qi,iC=vl,sC=rC,oC=Object.prototype,aC=oC.hasOwnProperty;function lC(i){if(!nC(i))return sC(i);var e=iC(i),t=[];for(var r in i)r=="constructor"&&(e||!aC.call(i,r))||t.push(r);return t;}var fC=lC,cC=th,uC=fC,hC=gl;function dC(i){return hC(i)?cC(i,!0):uC(i);}var yl=dC,pC=yo,vC=yl;function gC(i,e){return i&&pC(e,vC(e),i);}var mC=gC,ro={exports:{}};ro.exports;(function(i,e){var t=_r,r=e&&!e.nodeType&&e,n=r&&!0&&i&&!i.nodeType&&i,s=n&&n.exports===r,c=s?t.Buffer:void 0,l=c?c.allocUnsafe:void 0;function f(h,m){if(m)return h.slice();var u=h.length,y=l?l(u):new h.constructor(u);return h.copy(y),y;}i.exports=f;})(ro,ro.exports);var yC=ro.exports;function PC(i,e){var t=-1,r=i.length;for(e||(e=Array(r));++t<r;)e[t]=i[t];return e;}var SC=PC;function xC(i,e){for(var t=-1,r=i==null?0:i.length,n=0,s=[];++t<r;){var c=i[t];e(c,t,i)&&(s[n++]=c);}return s;}var rh=xC;function TC(){return[];}var nh=TC,CC=rh,IC=nh,OC=Object.prototype,wC=OC.propertyIsEnumerable,qc=Object.getOwnPropertySymbols,AC=qc?function(i){return i==null?[]:(i=Object(i),CC(qc(i),function(e){return wC.call(i,e);}));}:IC,Pl=AC,EC=yo,MC=Pl;function LC(i,e){return EC(i,MC(i),e);}var RC=LC;function bC(i,e){for(var t=-1,r=e.length,n=i.length;++t<r;)i[n+t]=e[t];return i;}var Sl=bC,DC=eh,NC=DC(Object.getPrototypeOf,Object),ih=NC,BC=Sl,WC=ih,FC=Pl,UC=nh,YC=Object.getOwnPropertySymbols,XC=YC?function(i){for(var e=[];i;)BC(e,FC(i)),i=WC(i);return e;}:UC,sh=XC,zC=yo,$C=sh;function jC(i,e){return zC(i,$C(i),e);}var GC=jC,kC=Sl,HC=qi;function KC(i,e,t){var r=e(i);return HC(i)?r:kC(r,t(i));}var oh=KC,VC=oh,ZC=Pl,JC=ml;function QC(i){return VC(i,JC,ZC);}var ah=QC,qC=oh,_C=sh,tI=yl;function eI(i){return qC(i,tI,_C);}var rI=eI,nI=$n,iI=_r,sI=nI(iI,"DataView"),oI=sI,aI=$n,lI=_r,fI=aI(lI,"Promise"),cI=fI,uI=$n,hI=_r,dI=uI(hI,"Set"),lh=dI,pI=$n,vI=_r,gI=pI(vI,"WeakMap"),mI=gI,rl=oI,nl=hl,il=cI,sl=lh,ol=mI,fh=Pi,Ii=Gu,_c="[object Map]",yI="[object Object]",tu="[object Promise]",eu="[object Set]",ru="[object WeakMap]",nu="[object DataView]",PI=Ii(rl),SI=Ii(nl),xI=Ii(il),TI=Ii(sl),CI=Ii(ol),zn=fh;(rl&&zn(new rl(new ArrayBuffer(1)))!=nu||nl&&zn(new nl())!=_c||il&&zn(il.resolve())!=tu||sl&&zn(new sl())!=eu||ol&&zn(new ol())!=ru)&&(zn=function zn(i){var e=fh(i),t=e==yI?i.constructor:void 0,r=t?Ii(t):"";if(r)switch(r){case PI:return nu;case SI:return _c;case xI:return tu;case TI:return eu;case CI:return ru;}return e;});var So=zn,II=Object.prototype,OI=II.hasOwnProperty;function wI(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&OI.call(i,"index")&&(t.index=i.index,t.input=i.input),t;}var AI=wI,EI=_r,MI=EI.Uint8Array,ch=MI,iu=ch;function LI(i){var e=new i.constructor(i.byteLength);return new iu(e).set(new iu(i)),e;}var xl=LI,RI=xl;function bI(i,e){var t=e?RI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength);}var DI=bI,NI=/\w*$/;function BI(i){var e=new i.constructor(i.source,NI.exec(i));return e.lastIndex=i.lastIndex,e;}var WI=BI,su=Ji,ou=su?su.prototype:void 0,au=ou?ou.valueOf:void 0;function FI(i){return au?Object(au.call(i)):{};}var UI=FI,YI=xl;function XI(i,e){var t=e?YI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length);}var zI=XI,$I=xl,jI=DI,GI=WI,kI=UI,HI=zI,KI="[object Boolean]",VI="[object Date]",ZI="[object Map]",JI="[object Number]",QI="[object RegExp]",qI="[object Set]",_I="[object String]",tO="[object Symbol]",eO="[object ArrayBuffer]",rO="[object DataView]",nO="[object Float32Array]",iO="[object Float64Array]",sO="[object Int8Array]",oO="[object Int16Array]",aO="[object Int32Array]",lO="[object Uint8Array]",fO="[object Uint8ClampedArray]",cO="[object Uint16Array]",uO="[object Uint32Array]";function hO(i,e,t){var r=i.constructor;switch(e){case eO:return $I(i);case KI:case VI:return new r(+i);case rO:return jI(i,t);case nO:case iO:case sO:case oO:case aO:case lO:case fO:case cO:case uO:return HI(i,t);case ZI:return new r();case JI:case _I:return new r(i);case QI:return GI(i);case qI:return new r();case tO:return kI(i);}}var dO=hO,pO=Qi,lu=Object.create,vO=/* @__PURE__ */function(){function i(){}return function(e){if(!pO(e))return{};if(lu)return lu(e);i.prototype=e;var t=new i();return i.prototype=void 0,t;};}(),gO=vO,mO=gO,yO=ih,PO=vl;function SO(i){return typeof i.constructor=="function"&&!PO(i)?mO(yO(i)):{};}var xO=SO,TO=So,CO=pn,IO="[object Map]";function OO(i){return CO(i)&&TO(i)==IO;}var wO=OO,AO=wO,EO=Po,fu=pl,cu=fu&&fu.isMap,MO=cu?EO(cu):AO,LO=MO,RO=So,bO=pn,DO="[object Set]";function NO(i){return bO(i)&&RO(i)==DO;}var BO=NO,WO=BO,FO=Po,uu=pl,hu=uu&&uu.isSet,UO=hu?FO(hu):WO,uh=UO,YO=/* @__PURE__ */Ln(uh),XO=Hu,zO=hx,$O=Zu,jO=tC,GO=mC,kO=yC,HO=SC,KO=RC,VO=GC,ZO=ah,JO=rI,QO=So,qO=AI,_O=dO,t2=xO,e2=qi,r2=dl,n2=LO,i2=Qi,s2=uh,o2=ml,a2=yl,l2=1,f2=2,c2=4,hh="[object Arguments]",u2="[object Array]",h2="[object Boolean]",d2="[object Date]",p2="[object Error]",dh="[object Function]",v2="[object GeneratorFunction]",g2="[object Map]",m2="[object Number]",ph="[object Object]",y2="[object RegExp]",P2="[object Set]",S2="[object String]",x2="[object Symbol]",T2="[object WeakMap]",C2="[object ArrayBuffer]",I2="[object DataView]",O2="[object Float32Array]",w2="[object Float64Array]",A2="[object Int8Array]",E2="[object Int16Array]",M2="[object Int32Array]",L2="[object Uint8Array]",R2="[object Uint8ClampedArray]",b2="[object Uint16Array]",D2="[object Uint32Array]",Ye={};Ye[hh]=Ye[u2]=Ye[C2]=Ye[I2]=Ye[h2]=Ye[d2]=Ye[O2]=Ye[w2]=Ye[A2]=Ye[E2]=Ye[M2]=Ye[g2]=Ye[m2]=Ye[ph]=Ye[y2]=Ye[P2]=Ye[S2]=Ye[x2]=Ye[L2]=Ye[R2]=Ye[b2]=Ye[D2]=!0;Ye[p2]=Ye[dh]=Ye[T2]=!1;function qs(i,e,t,r,n,s){var c,l=e&l2,f=e&f2,h=e&c2;if(t&&(c=n?t(i,r,n,s):t(i)),c!==void 0)return c;if(!i2(i))return i;var m=e2(i);if(m){if(c=qO(i),!l)return HO(i,c);}else{var u=QO(i),y=u==dh||u==v2;if(r2(i))return kO(i,l);if(u==ph||u==hh||y&&!n){if(c=f||y?{}:t2(i),!l)return f?VO(i,GO(c,i)):KO(i,jO(c,i));}else{if(!Ye[u])return n?i:{};c=_O(i,u,l);}}s||(s=new XO());var T=s.get(i);if(T)return T;s.set(i,c),s2(i)?i.forEach(function(x){c.add(qs(x,e,t,x,i,s));}):n2(i)&&i.forEach(function(x,I){c.set(I,qs(x,e,t,I,i,s));});var E=h?f?JO:ZO:f?a2:o2,C=m?void 0:E(i);return zO(C||i,function(x,I){C&&(I=x,x=i[I]),$O(c,I,qs(x,e,t,I,i,s));}),c;}var N2=qs,B2=N2,W2=1,F2=4;function U2(i){return B2(i,W2|F2);}var Y2=U2,fr=/* @__PURE__ */Ln(Y2);var vh="1.1.22-beta.12",X2="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var i=window.__netlessUA||"";i+=" ".concat(X2,"@").concat(vh),window.__netlessUA=i;}var vr={useWorker:"auto",useSimple:!1,syncOpt:{interval:300,smoothSync:!0},cursor:{enable:!0,expirationTime:5e3,moveDelayTime:100},bufferSize:{full:2e4,sub:600},bezier:{enable:!0,maxDrawCount:1/0,combineUnitTime:300},pencilEraser:{useBitMap:!0,maxImageWidth:1920,maxImageHeight:1920,maxCombineTime:500},strokeWidth:{min:1,max:10},textEditor:{showFloatBar:!0,canSelectorSwitch:!0,rightBoundBreak:!1,extendFontFaces:[],loadFontFacesTimeout:1e4},longDottedStroke:{lineCap:"round",segment:1,gap:2},dottedStroke:{lineCap:"round",segment:1,gap:2},normalStroke:{lineCap:"round"}};function En(i){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var t=i.length;if(t<2)return"";var r=i[0],n=i[1];if(t===2)return"M".concat(fi(r),"L").concat(fi(n));var s="";for(var c=2,l=t-1;c<l;c++)r=i[c],n=i[c+1],s+=ci(r,n);return e?"M".concat(ci(i[0],i[1]),"Q").concat(fi(i[1])).concat(ci(i[1],i[2]),"T").concat(s).concat(ci(i[t-1],i[0])).concat(ci(i[0],i[1]),"Z"):"M".concat(fi(i[0]),"Q").concat(fi(i[1])).concat(ci(i[1],i[2])).concat(i.length>3?"T":"").concat(s,"L").concat(fi(i[t-1]));}var Mr=/*#__PURE__*/function(){function Mr(e){_classCallCheck(this,Mr);dt(this,"maxImageWidth",vr.pencilEraser.maxImageWidth);dt(this,"maxImageHeight",vr.pencilEraser.maxImageHeight);dt(this,"syncUnitTime",vr.syncOpt.interval);dt(this,"vNodes");dt(this,"drawLayer");dt(this,"fullLayer");dt(this,"workId");dt(this,"isDelete",!1);var t=e.vNodes,r=e.fullLayer,n=e.drawLayer,s=e.workId,c=e.toolsOpt;this.vNodes=t,this.fullLayer=r,this.drawLayer=n,this.workId=s,this.syncUnitTime=c.syncUnitTime||this.syncUnitTime;}return _createClass(Mr,[{key:"baseConsumeResult",get:function get(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions};}},{key:"filterSamePoints",value:function filterSamePoints(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0.01;return e.reduce(function(r,n){var s=r[r.length-1];return(n&&!s||n&&s&&!n.isNear(s,t))&&r.push(n),r;},[]);}/** 设置工作id */},{key:"setWorkId",value:function setWorkId(e){this.workId=e;}},{key:"getWorkId",value:function getWorkId(){return this.workId;}/** 获取工作选项配置 */},{key:"getWorkOptions",value:function getWorkOptions(){return this.workOptions;}/** 设置工作选项配置 */},{key:"setWorkOptions",value:function setWorkOptions(e){var n,s,c;this.workOptions=e,this.syncUnitTime=e.syncUnitTime||this.syncUnitTime;var t=(n=this.workId)==null?void 0:n.toString(),r=t&&((s=this.vNodes)==null?void 0:s.get(t))||void 0;t&&r&&(r.opt=e,(c=this.vNodes)==null||c.setInfo(t,r));}/** 更新服务端同步配置,返回绘制结果 */},{key:"updataOptService",value:function updataOptService(e){var n,s;var t;var r=(n=this.workId)==null?void 0:n.toString();if(r&&e){var c=this.fullLayer.getElementsByName(r)||this.drawLayer&&this.drawLayer.getElementsByName(r)||[];if(c.length!==1)return;var l=c[0],f=e.pos,h=e.zIndex,m=e.scale,u=e.angle,y=e.translate,T={};er(h)&&(T.zIndex=h),f&&(T.pos=[f[0],f[1]]),m&&(T.scale=m),u&&(T.rotate=u),y&&(T.translate=y),l.attr(T);var E=l==null?void 0:l.getBoundingClientRect();return E&&(t=Zt(t,{x:Math.floor(E.x-Mr.SafeBorderPadding),y:Math.floor(E.y-Mr.SafeBorderPadding),w:Math.floor(E.width+Mr.SafeBorderPadding*2),h:Math.floor(E.height+Mr.SafeBorderPadding*2)})),(s=this.vNodes)==null||s.setInfo(r,{rect:t,centerPos:f}),t;}}},{key:"drawEraserlines",value:function drawEraserlines(e,t){var r=e.group,n=e.eraserlines,s=e.pos,c=e.layer,l=c.parent;if(t)try{var h=(c.renderer.glRenderer||c.renderer.canvasRenderer).options.displayRatio,m=r.getBoundingClientRect(),u=m.width*h*c.worldScaling[0],y=m.height*h*c.worldScaling[1];var T=1;(u>this.maxImageWidth||y>this.maxImageHeight)&&(T=Math.min(this.maxImageWidth/u,this.maxImageHeight/y));var E=c.getAttribute("scale");E=[E[0]*T,E[1]*T];var C=c.parent.parent,x=c.getAttribute("translate"),_I32=this.createVmRenderNode("".concat(this.workId,"_bitMapLayer"),C,{offscreen:l.offscreen,width:l.width,height:l.height,contextType:"2d",autoRender:!1,bufferSize:500},E,x),_d29=r.cloneNode(!0);if(!n||!n.length)return;this.addEraserlines(_d29,n,s,!1),_I32.appendChild(_d29);var v=_I32.parent;v.render();var p=_I32.renderer.canvasRenderer,S=p.context;if(!S)return;var A=p.options.displayRatio,R=_d29.getBoundingClientRect(),D={x:R.x,y:R.y,w:R.width,h:R.height},U={x:0,y:0,w:C.width,h:C.height};if(Zi(D,U)===Tr.outside){Lr(_d29,v),C.removeChild(v),this.isDelete=!0;return;}var W=fr(D);W.x=Math.floor(Math.max(D.x,0)),W.y=Math.floor(Math.max(D.y,0)),W.w=Math.min(D.x+D.w,C.width)-W.x,W.h=Math.min(D.y+D.h,C.height)-W.y;var Y=this.getGroupRect(W,A),B=Y.x,N=Y.y,G=Y.w,J=Y.h;var tt=S.getImageData(B,N,G,J);if(this.isTransparentRectByCanvas(tt)){Lr(_d29,v),C.removeChild(v),this.isDelete=!0,tt=null;return;}Lr(r,l);var ut=this.createSpriteNode({imageData:tt,safariRect:W,originRect:D,worldScaling:_I32.worldScaling});ut&&r.append(ut),Lr(_d29,v),C.removeChild(v),l.deleteTexture(tt),tt=null;}catch(f){console.error("[BaseShapeTool] drawEraserlines error:",f);return;}}},{key:"createVmRenderNode",value:function createVmRenderNode(e,t,r,n,s){var c=r.width,l=r.height,f="bitMap-".concat(e),h=t.layer(f,r),m=new mr({anchor:[0.5,0.5],pos:[c*0.5,l*0.5],size:[c,l],name:"viewport",id:e});return m.setAttribute("scale",n),m.setAttribute("translate",s),h.append(m),m;}},{key:"getGroupRect",value:function getGroupRect(e,t){var r=Math.floor(e.x*t),n=Math.floor(e.y*t),s=Math.floor(e.w*t),c=Math.floor(e.h*t);return{x:r,y:n,w:s,h:c};}},{key:"addEraserlines",value:function addEraserlines(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:!0;var _iterator13=_createForOfIteratorHelper(t),_step13;try{for(_iterator13.s();!(_step13=_iterator13.n()).done;){var s=_step13.value;var c=s.thickness,l=s.op;var _iterator14=_createForOfIteratorHelper(l),_step14;try{for(_iterator14.s();!(_step14=_iterator14.n()).done;){var f=_step14.value;var h=f.map(function(E,C){return C%2?E-r[1]:E-r[0];}),m=this.computEraserPoints(h,c),u=En(m,!0),y={pos:[0,0],d:u,fillColor:"rgba(0,0,0,1)"},T=new Mn(y);T.addEventListener("beforerender",function(_ref164){var E=_ref164.detail;var C=E.context;n?C.blendFuncSeparate(C.ZERO,C.ZERO,C.ZERO,C.ZERO):C.globalCompositeOperation="destination-out";}),T.addEventListener("afterrender",function(_ref165){var E=_ref165.detail;var C=E.context;n?C.blendFuncSeparate(C.SRC_ALPHA,C.ONE_MINUS_SRC_ALPHA,C.ONE,C.ONE_MINUS_SRC_ALPHA):C.globalCompositeOperation="source-over";}),e.append(T);}}catch(err){_iterator14.e(err);}finally{_iterator14.f();}}}catch(err){_iterator13.e(err);}finally{_iterator13.f();}}},{key:"isTransparentRectByCanvas",value:function isTransparentRectByCanvas(e){var t=!0;for(var r=0;r<e.data.length;r+=4)if(e.data[r+3]!==0){t=!1;break;}return t;}},{key:"createSpriteNode",value:function createSpriteNode(e){var t=e.imageData,r=e.worldScaling,n=e.safariRect,s=e.originRect;var c;if(typeof OffscreenCanvas=="function"){c=new OffscreenCanvas(t.width,t.height);var m=c.getContext("2d");m&&m.putImageData(t,0,0);}else if((typeof document==="undefined"?"undefined":_typeof(document))<"u"){c=document.createElement("canvas"),c.width=t.width,c.height=t.height;var _m4=c.getContext("2d");_m4&&_m4.putImageData(t,0,0);}if(!c)return console.warn("Failed to create imageEraserBitmap Sprite"),null;var l=[Math.floor(s.w/r[0]),Math.floor(s.h/r[1])],f=[Math.floor((n.x-s.x)/r[0]),Math.floor((n.y-s.y)/r[1]),Math.floor(n.w/r[0]),Math.floor(n.h/r[1])],h={name:"eraserTexture",anchor:[0.5,0.5],pos:[0,0],size:l,texture:c,textureRect:f};return new Yu(h);}},{key:"computEraserPoints",value:function computEraserPoints(e,t){var r=Math.ceil(t/2);return e.length===2?this.computDot(e,r):this.computLine(e,r);}},{key:"computDot",value:function computDot(e,t){var r=new Jt(e[0],e[1]);return Jt.GetDotStroke(r,t,8);}},{key:"computLine",value:function computLine(e,t){var r=[],n=[];var s,c;for(var l=0;l<e.length;l+=2){var f=new Jt(e[l],e[l+1]);var h=void 0;if(l==e.length-2){var m=new Jt(e[l-2],e[l-1]);h=pt.Sub(f,m).uni(),s=f;}else{l===0&&(c=f);var _m5=new Jt(e[l+2],e[l+3]);h=pt.Sub(_m5,f).uni();}if(h){var _m6=pt.Per(h).mul(t);r.push(Jt.Sub(f,_m6)),n.push(Jt.Add(f,_m6));}}if(s&&c){var _l3=Jt.GetSemicircleStroke(s,r[r.length-1],-1,8),_f4=Jt.GetSemicircleStroke(c,n[0],-1,8);return r.concat(_l3,n.reverse(),_f4);}return[];}},{key:"replace",value:function replace(e,t,r){var _this61=this;var s;if(!t){r&&e.append(r);return;}var n=e.getElementsByName(t);if(n.length){var _iterator15=_createForOfIteratorHelper(n),_step15;try{for(_iterator15.s();!(_step15=_iterator15.n()).done;){var c=_step15.value;r?iE(r,c,e):(c.remove(),_pr(c,e.parent));}}catch(err){_iterator15.e(err);}finally{_iterator15.f();}}else r&&e.append(r);this.fullLayer!==this.drawLayer&&(this.fullLayer===e?(s=this.drawLayer)==null||s.getElementsByName(t).forEach(function(l){var f;l.remove(),_pr(l,(f=_this61.drawLayer)==null?void 0:f.parent);}):this.fullLayer.getElementsByName(t).forEach(function(l){l.remove(),_pr(l,_this61.fullLayer.parent);}));}},{key:"removeDrawCountNodes",value:function removeDrawCountNodes(e,t){var r=[];e.getElementsByName(this.workId).forEach(function(n){n.id&&t&&Number(n.id)<t&&r.push(n);});for(var _i2=0,_r3=r;_i2<_r3.length;_i2++){var n=_r3[_i2];n.remove(),_pr(n,e.parent);}}}],[{key:"updateNodeOpt",value:function updateNodeOpt(e){var d;var t=e.node,r=e.opt,n=e.vNodes,s=e.willSerializeData,c=e.targetNode,l=r.zIndex,f=r.translate,h=r.angle,m=r.originPoint,u=r.scenePoint,y=r.scale,T=r.pointMap,E=r.thickness;var C;var x=c&&fr(c)||n.get(t.name);if(!x)return;er(l)&&(t.setAttribute("zIndex",l),x.opt.zIndex=l);var I=t.parent;if(I){if(m&&y&&c){var v=[x.op[0],x.op[1]];Ll(x.op,u,y,f);var p=[x.op[0],x.op[1]],S=[p[0]-v[0],p[1]-v[1]];if(x.centerPos=[x.centerPos[0]+S[0],x.centerPos[1]+S[1]],x.opt.translate=void 0,x.opt.scale=void 0,x.opt.eraserlines)for(var A=0;A<x.opt.eraserlines.length;A++){var _x$opt$eraserlines$A=x.opt.eraserlines[A],R=_x$opt$eraserlines$A.op,D=_x$opt$eraserlines$A.thickness;x.opt.eraserlines[A].thickness=Math.round(D*Math.max(y[0],y[1]));for(var U=0;U<R.length;U++)Rl(R[U],u,y,f);}}else if(f){if(t.setAttribute("translate",f),x.opt.translate=f,c){var _v6=[f[0]*I.worldScaling[0],f[1]*I.worldScaling[1]];C=Vi(x.rect,_v6),x.rect=C;}else{var _v7=Mr.getRectFromLayer(I,t.name);x.rect=_v7||x.rect;}}else if(er(h))if(t.setAttribute("rotate",h),x.opt.rotate=h,c)C=Hh(x.rect,h),x.rect=C;else{var _v8=Mr.getRectFromLayer(I,t.name);x.rect=_v8||x.rect;}if(T){var _v9=T.get(t.name);if(_v9)for(var _p10=0,_S10=0;_p10<x.op.length;_p10+=3,_S10++)x.op[_p10]=_v9[_S10][0],x.op[_p10+1]=_v9[_S10][1];}if(E&&(d=x==null?void 0:x.opt)!=null&&d.thickness&&(x.opt.thickness=E),s&&!(m&&y&&c)){if(f){var _v10=x.op.map(function(p,S){var A=S%3;return A===0?p+f[0]:A===1?p+f[1]:p;});if(x.op=_v10,x.centerPos=[x.centerPos[0]+f[0],x.centerPos[1]+f[1]],x!=null&&x.opt&&(x.opt.translate=void 0),x.opt.eraserlines)for(var _p11=0;_p11<x.opt.eraserlines.length;_p11++){var _S11=x.opt.eraserlines[_p11].op;for(var _A7=0;_A7<_S11.length;_A7++){var _R3=_S11[_A7].map(function(D,U){return U%2?D+f[1]:D+f[0];});x.opt.eraserlines[_p11].op[_A7]=_R3;}}}else if(er(h)){var _v11=x.op;if(JA(_v11,x.centerPos,h),x.op=_v11,x!=null&&x.opt&&(x.opt.rotate=void 0),x.opt.eraserlines)for(var _p12=0;_p12<x.opt.eraserlines.length;_p12++){var _S12=x.opt.eraserlines[_p12].op;for(var _A8=0;_A8<_S12.length;_A8++)QA(_S12[_A8],x.centerPos,h);}}}x&&n.setInfo(t.name,x);}}},{key:"getCenterPos",value:function getCenterPos(e,t){var r=t.worldPosition,n=t.worldScaling;return[(e.x+e.w/2-r[0])/n[0],(e.y+e.h/2-r[1])/n[1]];}},{key:"getRectFromLayer",value:function getRectFromLayer(e,t){var r=e.getElementsByName(t)[0];if(r){var n=r.getBoundingClientRect();return{x:Math.floor(n.x-Mr.SafeBorderPadding),y:Math.floor(n.y-Mr.SafeBorderPadding),w:Math.floor(n.width+Mr.SafeBorderPadding*2),h:Math.floor(n.height+Mr.SafeBorderPadding*2)};}}},{key:"isWillRefresh",value:function isWillRefresh(e){var t=e.toolsType,r=e.opt,n=e.node,s=e.updateOpt,c=e.willSerializeData;return!!(c&&(s.angle||s.translate)||s.thickness&&r.thickness&&r.thickness!==s.thickness||s.strokeType&&r.strokeType&&r.strokeType!==s.strokeType||s.originPoint&&s.scenePoint&&s.scale||s.pointMap&&s.pointMap.has(n.name)||t===Tt.Text&&(s.fontSize||s.translate||s.textInfos&&s.textInfos.get(n.name))||t===Tt.Image&&(s.angle||s.translate||s.scale||s.strokeColor&&s.type===cl.Iconify)||t===s.toolsType&&s.willRefresh||r.eraserlines&&r.eraserlines.length&&(s.strokeColor||s.fillColor));}}]);}();dt(Mr,"SafeBorderPadding",10);var $t=Mr;var Tl=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 Cl={exports:{}};Cl.exports;(function(i){var e=function(){var t=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",s={};function c(f,h){if(!s[f]){s[f]={};for(var m=0;m<f.length;m++)s[f][f.charAt(m)]=m;}return s[f][h];}var l={compressToBase64:function compressToBase64(f){if(f==null)return"";var h=l._compress(f,6,function(m){return r.charAt(m);});switch(h.length%4){default:case 0:return h;case 1:return h+"===";case 2:return h+"==";case 3:return h+"=";}},decompressFromBase64:function decompressFromBase64(f){return f==null?"":f==""?null:l._decompress(f.length,32,function(h){return c(r,f.charAt(h));});},compressToUTF16:function compressToUTF16(f){return f==null?"":l._compress(f,15,function(h){return t(h+32);})+" ";},decompressFromUTF16:function decompressFromUTF16(f){return f==null?"":f==""?null:l._decompress(f.length,16384,function(h){return f.charCodeAt(h)-32;});},//compress into uint8array (UCS-2 big endian format)
399
+ AT(h,f)))&&l.push(h);return l;}var th=RT,bT=Object.prototype;function DT(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||bT;return i===t;}var vl=DT;function NT(i,e){return function(t){return i(e(t));};}var eh=NT,BT=eh,WT=BT(Object.keys,Object),FT=WT,UT=vl,YT=FT,XT=Object.prototype,zT=XT.hasOwnProperty;function $T(i){if(!UT(i))return YT(i);var e=[];for(var t in Object(i))zT.call(i,t)&&t!="constructor"&&e.push(t);return e;}var jT=$T,GT=ju,kT=qu;function HT(i){return i!=null&&kT(i.length)&&!GT(i);}var gl=HT,KT=th,VT=jT,ZT=gl;function JT(i){return ZT(i)?KT(i):VT(i);}var ml=JT,QT=yo,qT=ml;function _T(i,e){return i&&QT(e,qT(e),i);}var tC=_T;function eC(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e;}var rC=eC,nC=Qi,iC=vl,sC=rC,oC=Object.prototype,aC=oC.hasOwnProperty;function lC(i){if(!nC(i))return sC(i);var e=iC(i),t=[];for(var r in i)r=="constructor"&&(e||!aC.call(i,r))||t.push(r);return t;}var fC=lC,cC=th,uC=fC,hC=gl;function dC(i){return hC(i)?cC(i,!0):uC(i);}var yl=dC,pC=yo,vC=yl;function gC(i,e){return i&&pC(e,vC(e),i);}var mC=gC,ro={exports:{}};ro.exports;(function(i,e){var t=_r,r=e&&!e.nodeType&&e,n=r&&!0&&i&&!i.nodeType&&i,s=n&&n.exports===r,c=s?t.Buffer:void 0,l=c?c.allocUnsafe:void 0;function f(h,m){if(m)return h.slice();var u=h.length,y=l?l(u):new h.constructor(u);return h.copy(y),y;}i.exports=f;})(ro,ro.exports);var yC=ro.exports;function PC(i,e){var t=-1,r=i.length;for(e||(e=Array(r));++t<r;)e[t]=i[t];return e;}var SC=PC;function xC(i,e){for(var t=-1,r=i==null?0:i.length,n=0,s=[];++t<r;){var c=i[t];e(c,t,i)&&(s[n++]=c);}return s;}var rh=xC;function TC(){return[];}var nh=TC,CC=rh,IC=nh,OC=Object.prototype,wC=OC.propertyIsEnumerable,qc=Object.getOwnPropertySymbols,AC=qc?function(i){return i==null?[]:(i=Object(i),CC(qc(i),function(e){return wC.call(i,e);}));}:IC,Pl=AC,EC=yo,MC=Pl;function LC(i,e){return EC(i,MC(i),e);}var RC=LC;function bC(i,e){for(var t=-1,r=e.length,n=i.length;++t<r;)i[n+t]=e[t];return i;}var Sl=bC,DC=eh,NC=DC(Object.getPrototypeOf,Object),ih=NC,BC=Sl,WC=ih,FC=Pl,UC=nh,YC=Object.getOwnPropertySymbols,XC=YC?function(i){for(var e=[];i;)BC(e,FC(i)),i=WC(i);return e;}:UC,sh=XC,zC=yo,$C=sh;function jC(i,e){return zC(i,$C(i),e);}var GC=jC,kC=Sl,HC=qi;function KC(i,e,t){var r=e(i);return HC(i)?r:kC(r,t(i));}var oh=KC,VC=oh,ZC=Pl,JC=ml;function QC(i){return VC(i,JC,ZC);}var ah=QC,qC=oh,_C=sh,tI=yl;function eI(i){return qC(i,tI,_C);}var rI=eI,nI=$n,iI=_r,sI=nI(iI,"DataView"),oI=sI,aI=$n,lI=_r,fI=aI(lI,"Promise"),cI=fI,uI=$n,hI=_r,dI=uI(hI,"Set"),lh=dI,pI=$n,vI=_r,gI=pI(vI,"WeakMap"),mI=gI,rl=oI,nl=hl,il=cI,sl=lh,ol=mI,fh=Pi,Ii=Gu,_c="[object Map]",yI="[object Object]",tu="[object Promise]",eu="[object Set]",ru="[object WeakMap]",nu="[object DataView]",PI=Ii(rl),SI=Ii(nl),xI=Ii(il),TI=Ii(sl),CI=Ii(ol),zn=fh;(rl&&zn(new rl(new ArrayBuffer(1)))!=nu||nl&&zn(new nl())!=_c||il&&zn(il.resolve())!=tu||sl&&zn(new sl())!=eu||ol&&zn(new ol())!=ru)&&(zn=function zn(i){var e=fh(i),t=e==yI?i.constructor:void 0,r=t?Ii(t):"";if(r)switch(r){case PI:return nu;case SI:return _c;case xI:return tu;case TI:return eu;case CI:return ru;}return e;});var So=zn,II=Object.prototype,OI=II.hasOwnProperty;function wI(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&OI.call(i,"index")&&(t.index=i.index,t.input=i.input),t;}var AI=wI,EI=_r,MI=EI.Uint8Array,ch=MI,iu=ch;function LI(i){var e=new i.constructor(i.byteLength);return new iu(e).set(new iu(i)),e;}var xl=LI,RI=xl;function bI(i,e){var t=e?RI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength);}var DI=bI,NI=/\w*$/;function BI(i){var e=new i.constructor(i.source,NI.exec(i));return e.lastIndex=i.lastIndex,e;}var WI=BI,su=Ji,ou=su?su.prototype:void 0,au=ou?ou.valueOf:void 0;function FI(i){return au?Object(au.call(i)):{};}var UI=FI,YI=xl;function XI(i,e){var t=e?YI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length);}var zI=XI,$I=xl,jI=DI,GI=WI,kI=UI,HI=zI,KI="[object Boolean]",VI="[object Date]",ZI="[object Map]",JI="[object Number]",QI="[object RegExp]",qI="[object Set]",_I="[object String]",tO="[object Symbol]",eO="[object ArrayBuffer]",rO="[object DataView]",nO="[object Float32Array]",iO="[object Float64Array]",sO="[object Int8Array]",oO="[object Int16Array]",aO="[object Int32Array]",lO="[object Uint8Array]",fO="[object Uint8ClampedArray]",cO="[object Uint16Array]",uO="[object Uint32Array]";function hO(i,e,t){var r=i.constructor;switch(e){case eO:return $I(i);case KI:case VI:return new r(+i);case rO:return jI(i,t);case nO:case iO:case sO:case oO:case aO:case lO:case fO:case cO:case uO:return HI(i,t);case ZI:return new r();case JI:case _I:return new r(i);case QI:return GI(i);case qI:return new r();case tO:return kI(i);}}var dO=hO,pO=Qi,lu=Object.create,vO=/* @__PURE__ */function(){function i(){}return function(e){if(!pO(e))return{};if(lu)return lu(e);i.prototype=e;var t=new i();return i.prototype=void 0,t;};}(),gO=vO,mO=gO,yO=ih,PO=vl;function SO(i){return typeof i.constructor=="function"&&!PO(i)?mO(yO(i)):{};}var xO=SO,TO=So,CO=pn,IO="[object Map]";function OO(i){return CO(i)&&TO(i)==IO;}var wO=OO,AO=wO,EO=Po,fu=pl,cu=fu&&fu.isMap,MO=cu?EO(cu):AO,LO=MO,RO=So,bO=pn,DO="[object Set]";function NO(i){return bO(i)&&RO(i)==DO;}var BO=NO,WO=BO,FO=Po,uu=pl,hu=uu&&uu.isSet,UO=hu?FO(hu):WO,uh=UO,YO=/* @__PURE__ */Ln(uh),XO=Hu,zO=hx,$O=Zu,jO=tC,GO=mC,kO=yC,HO=SC,KO=RC,VO=GC,ZO=ah,JO=rI,QO=So,qO=AI,_O=dO,t2=xO,e2=qi,r2=dl,n2=LO,i2=Qi,s2=uh,o2=ml,a2=yl,l2=1,f2=2,c2=4,hh="[object Arguments]",u2="[object Array]",h2="[object Boolean]",d2="[object Date]",p2="[object Error]",dh="[object Function]",v2="[object GeneratorFunction]",g2="[object Map]",m2="[object Number]",ph="[object Object]",y2="[object RegExp]",P2="[object Set]",S2="[object String]",x2="[object Symbol]",T2="[object WeakMap]",C2="[object ArrayBuffer]",I2="[object DataView]",O2="[object Float32Array]",w2="[object Float64Array]",A2="[object Int8Array]",E2="[object Int16Array]",M2="[object Int32Array]",L2="[object Uint8Array]",R2="[object Uint8ClampedArray]",b2="[object Uint16Array]",D2="[object Uint32Array]",Ye={};Ye[hh]=Ye[u2]=Ye[C2]=Ye[I2]=Ye[h2]=Ye[d2]=Ye[O2]=Ye[w2]=Ye[A2]=Ye[E2]=Ye[M2]=Ye[g2]=Ye[m2]=Ye[ph]=Ye[y2]=Ye[P2]=Ye[S2]=Ye[x2]=Ye[L2]=Ye[R2]=Ye[b2]=Ye[D2]=!0;Ye[p2]=Ye[dh]=Ye[T2]=!1;function qs(i,e,t,r,n,s){var c,l=e&l2,f=e&f2,h=e&c2;if(t&&(c=n?t(i,r,n,s):t(i)),c!==void 0)return c;if(!i2(i))return i;var m=e2(i);if(m){if(c=qO(i),!l)return HO(i,c);}else{var u=QO(i),y=u==dh||u==v2;if(r2(i))return kO(i,l);if(u==ph||u==hh||y&&!n){if(c=f||y?{}:t2(i),!l)return f?VO(i,GO(c,i)):KO(i,jO(c,i));}else{if(!Ye[u])return n?i:{};c=_O(i,u,l);}}s||(s=new XO());var T=s.get(i);if(T)return T;s.set(i,c),s2(i)?i.forEach(function(x){c.add(qs(x,e,t,x,i,s));}):n2(i)&&i.forEach(function(x,I){c.set(I,qs(x,e,t,I,i,s));});var E=h?f?JO:ZO:f?a2:o2,C=m?void 0:E(i);return zO(C||i,function(x,I){C&&(I=x,x=i[I]),$O(c,I,qs(x,e,t,I,i,s));}),c;}var N2=qs,B2=N2,W2=1,F2=4;function U2(i){return B2(i,W2|F2);}var Y2=U2,fr=/* @__PURE__ */Ln(Y2);var vh="1.1.22-beta.13",X2="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var i=window.__netlessUA||"";i+=" ".concat(X2,"@").concat(vh),window.__netlessUA=i;}var vr={useWorker:"auto",useSimple:!1,syncOpt:{interval:300,smoothSync:!0},cursor:{enable:!0,expirationTime:5e3,moveDelayTime:100},bufferSize:{full:2e4,sub:600},bezier:{enable:!0,maxDrawCount:1/0,combineUnitTime:300},pencilEraser:{useBitMap:!0,maxImageWidth:1920,maxImageHeight:1920,maxCombineTime:500},strokeWidth:{min:1,max:10},textEditor:{showFloatBar:!0,canSelectorSwitch:!0,rightBoundBreak:!1,extendFontFaces:[],loadFontFacesTimeout:1e4},longDottedStroke:{lineCap:"round",segment:1,gap:2},dottedStroke:{lineCap:"round",segment:1,gap:2},normalStroke:{lineCap:"round"}};function En(i){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var t=i.length;if(t<2)return"";var r=i[0],n=i[1];if(t===2)return"M".concat(fi(r),"L").concat(fi(n));var s="";for(var c=2,l=t-1;c<l;c++)r=i[c],n=i[c+1],s+=ci(r,n);return e?"M".concat(ci(i[0],i[1]),"Q").concat(fi(i[1])).concat(ci(i[1],i[2]),"T").concat(s).concat(ci(i[t-1],i[0])).concat(ci(i[0],i[1]),"Z"):"M".concat(fi(i[0]),"Q").concat(fi(i[1])).concat(ci(i[1],i[2])).concat(i.length>3?"T":"").concat(s,"L").concat(fi(i[t-1]));}var Mr=/*#__PURE__*/function(){function Mr(e){_classCallCheck(this,Mr);dt(this,"maxImageWidth",vr.pencilEraser.maxImageWidth);dt(this,"maxImageHeight",vr.pencilEraser.maxImageHeight);dt(this,"syncUnitTime",vr.syncOpt.interval);dt(this,"vNodes");dt(this,"drawLayer");dt(this,"fullLayer");dt(this,"workId");dt(this,"isDelete",!1);var t=e.vNodes,r=e.fullLayer,n=e.drawLayer,s=e.workId,c=e.toolsOpt;this.vNodes=t,this.fullLayer=r,this.drawLayer=n,this.workId=s,this.syncUnitTime=c.syncUnitTime||this.syncUnitTime;}return _createClass(Mr,[{key:"baseConsumeResult",get:function get(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions};}},{key:"filterSamePoints",value:function filterSamePoints(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0.01;return e.reduce(function(r,n){var s=r[r.length-1];return(n&&!s||n&&s&&!n.isNear(s,t))&&r.push(n),r;},[]);}/** 设置工作id */},{key:"setWorkId",value:function setWorkId(e){this.workId=e;}},{key:"getWorkId",value:function getWorkId(){return this.workId;}/** 获取工作选项配置 */},{key:"getWorkOptions",value:function getWorkOptions(){return this.workOptions;}/** 设置工作选项配置 */},{key:"setWorkOptions",value:function setWorkOptions(e){var n,s,c;this.workOptions=e,this.syncUnitTime=e.syncUnitTime||this.syncUnitTime;var t=(n=this.workId)==null?void 0:n.toString(),r=t&&((s=this.vNodes)==null?void 0:s.get(t))||void 0;t&&r&&(r.opt=e,(c=this.vNodes)==null||c.setInfo(t,r));}/** 更新服务端同步配置,返回绘制结果 */},{key:"updataOptService",value:function updataOptService(e){var n,s;var t;var r=(n=this.workId)==null?void 0:n.toString();if(r&&e){var c=this.fullLayer.getElementsByName(r)||this.drawLayer&&this.drawLayer.getElementsByName(r)||[];if(c.length!==1)return;var l=c[0],f=e.pos,h=e.zIndex,m=e.scale,u=e.angle,y=e.translate,T={};er(h)&&(T.zIndex=h),f&&(T.pos=[f[0],f[1]]),m&&(T.scale=m),u&&(T.rotate=u),y&&(T.translate=y),l.attr(T);var E=l==null?void 0:l.getBoundingClientRect();return E&&(t=Zt(t,{x:Math.floor(E.x-Mr.SafeBorderPadding),y:Math.floor(E.y-Mr.SafeBorderPadding),w:Math.floor(E.width+Mr.SafeBorderPadding*2),h:Math.floor(E.height+Mr.SafeBorderPadding*2)})),(s=this.vNodes)==null||s.setInfo(r,{rect:t,centerPos:f}),t;}}},{key:"drawEraserlines",value:function drawEraserlines(e,t){var r=e.group,n=e.eraserlines,s=e.pos,c=e.layer,l=c.parent;if(t)try{var h=(c.renderer.glRenderer||c.renderer.canvasRenderer).options.displayRatio,m=r.getBoundingClientRect(),u=m.width*h*c.worldScaling[0],y=m.height*h*c.worldScaling[1];var T=1;(u>this.maxImageWidth||y>this.maxImageHeight)&&(T=Math.min(this.maxImageWidth/u,this.maxImageHeight/y));var E=c.getAttribute("scale");E=[E[0]*T,E[1]*T];var C=c.parent.parent,x=c.getAttribute("translate"),_I32=this.createVmRenderNode("".concat(this.workId,"_bitMapLayer"),C,{offscreen:l.offscreen,width:l.width,height:l.height,contextType:"2d",autoRender:!1,bufferSize:500},E,x),_d29=r.cloneNode(!0);if(!n||!n.length)return;this.addEraserlines(_d29,n,s,!1),_I32.appendChild(_d29);var v=_I32.parent;v.render();var p=_I32.renderer.canvasRenderer,S=p.context;if(!S)return;var A=p.options.displayRatio,R=_d29.getBoundingClientRect(),D={x:R.x,y:R.y,w:R.width,h:R.height},U={x:0,y:0,w:C.width,h:C.height};if(Zi(D,U)===Tr.outside){Lr(_d29,v),C.removeChild(v),this.isDelete=!0;return;}var W=fr(D);W.x=Math.floor(Math.max(D.x,0)),W.y=Math.floor(Math.max(D.y,0)),W.w=Math.min(D.x+D.w,C.width)-W.x,W.h=Math.min(D.y+D.h,C.height)-W.y;var Y=this.getGroupRect(W,A),B=Y.x,N=Y.y,G=Y.w,J=Y.h;var tt=S.getImageData(B,N,G,J);if(this.isTransparentRectByCanvas(tt)){Lr(_d29,v),C.removeChild(v),this.isDelete=!0,tt=null;return;}Lr(r,l);var ut=this.createSpriteNode({imageData:tt,safariRect:W,originRect:D,worldScaling:_I32.worldScaling});ut&&r.append(ut),Lr(_d29,v),C.removeChild(v),l.deleteTexture(tt),tt=null;}catch(f){console.error("[BaseShapeTool] drawEraserlines error:",f);return;}}},{key:"createVmRenderNode",value:function createVmRenderNode(e,t,r,n,s){var c=r.width,l=r.height,f="bitMap-".concat(e),h=t.layer(f,r),m=new mr({anchor:[0.5,0.5],pos:[c*0.5,l*0.5],size:[c,l],name:"viewport",id:e});return m.setAttribute("scale",n),m.setAttribute("translate",s),h.append(m),m;}},{key:"getGroupRect",value:function getGroupRect(e,t){var r=Math.floor(e.x*t),n=Math.floor(e.y*t),s=Math.floor(e.w*t),c=Math.floor(e.h*t);return{x:r,y:n,w:s,h:c};}},{key:"addEraserlines",value:function addEraserlines(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:!0;var _iterator13=_createForOfIteratorHelper(t),_step13;try{for(_iterator13.s();!(_step13=_iterator13.n()).done;){var s=_step13.value;var c=s.thickness,l=s.op;var _iterator14=_createForOfIteratorHelper(l),_step14;try{for(_iterator14.s();!(_step14=_iterator14.n()).done;){var f=_step14.value;var h=f.map(function(E,C){return C%2?E-r[1]:E-r[0];}),m=this.computEraserPoints(h,c),u=En(m,!0),y={pos:[0,0],d:u,fillColor:"rgba(0,0,0,1)"},T=new Mn(y);T.addEventListener("beforerender",function(_ref164){var E=_ref164.detail;var C=E.context;n?C.blendFuncSeparate(C.ZERO,C.ZERO,C.ZERO,C.ZERO):C.globalCompositeOperation="destination-out";}),T.addEventListener("afterrender",function(_ref165){var E=_ref165.detail;var C=E.context;n?C.blendFuncSeparate(C.SRC_ALPHA,C.ONE_MINUS_SRC_ALPHA,C.ONE,C.ONE_MINUS_SRC_ALPHA):C.globalCompositeOperation="source-over";}),e.append(T);}}catch(err){_iterator14.e(err);}finally{_iterator14.f();}}}catch(err){_iterator13.e(err);}finally{_iterator13.f();}}},{key:"isTransparentRectByCanvas",value:function isTransparentRectByCanvas(e){var t=!0;for(var r=0;r<e.data.length;r+=4)if(e.data[r+3]!==0){t=!1;break;}return t;}},{key:"createSpriteNode",value:function createSpriteNode(e){var t=e.imageData,r=e.worldScaling,n=e.safariRect,s=e.originRect;var c;if(typeof OffscreenCanvas=="function"){c=new OffscreenCanvas(t.width,t.height);var m=c.getContext("2d");m&&m.putImageData(t,0,0);}else if((typeof document==="undefined"?"undefined":_typeof(document))<"u"){c=document.createElement("canvas"),c.width=t.width,c.height=t.height;var _m4=c.getContext("2d");_m4&&_m4.putImageData(t,0,0);}if(!c)return console.warn("Failed to create imageEraserBitmap Sprite"),null;var l=[Math.floor(s.w/r[0]),Math.floor(s.h/r[1])],f=[Math.floor((n.x-s.x)/r[0]),Math.floor((n.y-s.y)/r[1]),Math.floor(n.w/r[0]),Math.floor(n.h/r[1])],h={name:"eraserTexture",anchor:[0.5,0.5],pos:[0,0],size:l,texture:c,textureRect:f};return new Yu(h);}},{key:"computEraserPoints",value:function computEraserPoints(e,t){var r=Math.ceil(t/2);return e.length===2?this.computDot(e,r):this.computLine(e,r);}},{key:"computDot",value:function computDot(e,t){var r=new Jt(e[0],e[1]);return Jt.GetDotStroke(r,t,8);}},{key:"computLine",value:function computLine(e,t){var r=[],n=[];var s,c;for(var l=0;l<e.length;l+=2){var f=new Jt(e[l],e[l+1]);var h=void 0;if(l==e.length-2){var m=new Jt(e[l-2],e[l-1]);h=pt.Sub(f,m).uni(),s=f;}else{l===0&&(c=f);var _m5=new Jt(e[l+2],e[l+3]);h=pt.Sub(_m5,f).uni();}if(h){var _m6=pt.Per(h).mul(t);r.push(Jt.Sub(f,_m6)),n.push(Jt.Add(f,_m6));}}if(s&&c){var _l3=Jt.GetSemicircleStroke(s,r[r.length-1],-1,8),_f4=Jt.GetSemicircleStroke(c,n[0],-1,8);return r.concat(_l3,n.reverse(),_f4);}return[];}},{key:"replace",value:function replace(e,t,r){var _this61=this;var s;if(!t){r&&e.append(r);return;}var n=e.getElementsByName(t);if(n.length){var _iterator15=_createForOfIteratorHelper(n),_step15;try{for(_iterator15.s();!(_step15=_iterator15.n()).done;){var c=_step15.value;r?iE(r,c,e):(c.remove(),_pr(c,e.parent));}}catch(err){_iterator15.e(err);}finally{_iterator15.f();}}else r&&e.append(r);this.fullLayer!==this.drawLayer&&(this.fullLayer===e?(s=this.drawLayer)==null||s.getElementsByName(t).forEach(function(l){var f;l.remove(),_pr(l,(f=_this61.drawLayer)==null?void 0:f.parent);}):this.fullLayer.getElementsByName(t).forEach(function(l){l.remove(),_pr(l,_this61.fullLayer.parent);}));}},{key:"removeDrawCountNodes",value:function removeDrawCountNodes(e,t){var r=[];e.getElementsByName(this.workId).forEach(function(n){n.id&&t&&Number(n.id)<t&&r.push(n);});for(var _i2=0,_r3=r;_i2<_r3.length;_i2++){var n=_r3[_i2];n.remove(),_pr(n,e.parent);}}}],[{key:"updateNodeOpt",value:function updateNodeOpt(e){var d;var t=e.node,r=e.opt,n=e.vNodes,s=e.willSerializeData,c=e.targetNode,l=r.zIndex,f=r.translate,h=r.angle,m=r.originPoint,u=r.scenePoint,y=r.scale,T=r.pointMap,E=r.thickness;var C;var x=c&&fr(c)||n.get(t.name);if(!x)return;er(l)&&(t.setAttribute("zIndex",l),x.opt.zIndex=l);var I=t.parent;if(I){if(m&&y&&c){var v=[x.op[0],x.op[1]];Ll(x.op,u,y,f);var p=[x.op[0],x.op[1]],S=[p[0]-v[0],p[1]-v[1]];if(x.centerPos=[x.centerPos[0]+S[0],x.centerPos[1]+S[1]],x.opt.translate=void 0,x.opt.scale=void 0,x.opt.eraserlines)for(var A=0;A<x.opt.eraserlines.length;A++){var _x$opt$eraserlines$A=x.opt.eraserlines[A],R=_x$opt$eraserlines$A.op,D=_x$opt$eraserlines$A.thickness;x.opt.eraserlines[A].thickness=Math.round(D*Math.max(y[0],y[1]));for(var U=0;U<R.length;U++)Rl(R[U],u,y,f);}}else if(f){if(t.setAttribute("translate",f),x.opt.translate=f,c){var _v6=[f[0]*I.worldScaling[0],f[1]*I.worldScaling[1]];C=Vi(x.rect,_v6),x.rect=C;}else{var _v7=Mr.getRectFromLayer(I,t.name);x.rect=_v7||x.rect;}}else if(er(h))if(t.setAttribute("rotate",h),x.opt.rotate=h,c)C=Hh(x.rect,h),x.rect=C;else{var _v8=Mr.getRectFromLayer(I,t.name);x.rect=_v8||x.rect;}if(T){var _v9=T.get(t.name);if(_v9)for(var _p10=0,_S10=0;_p10<x.op.length;_p10+=3,_S10++)x.op[_p10]=_v9[_S10][0],x.op[_p10+1]=_v9[_S10][1];}if(E&&(d=x==null?void 0:x.opt)!=null&&d.thickness&&(x.opt.thickness=E),s&&!(m&&y&&c)){if(f){var _v10=x.op.map(function(p,S){var A=S%3;return A===0?p+f[0]:A===1?p+f[1]:p;});if(x.op=_v10,x.centerPos=[x.centerPos[0]+f[0],x.centerPos[1]+f[1]],x!=null&&x.opt&&(x.opt.translate=void 0),x.opt.eraserlines)for(var _p11=0;_p11<x.opt.eraserlines.length;_p11++){var _S11=x.opt.eraserlines[_p11].op;for(var _A7=0;_A7<_S11.length;_A7++){var _R3=_S11[_A7].map(function(D,U){return U%2?D+f[1]:D+f[0];});x.opt.eraserlines[_p11].op[_A7]=_R3;}}}else if(er(h)){var _v11=x.op;if(JA(_v11,x.centerPos,h),x.op=_v11,x!=null&&x.opt&&(x.opt.rotate=void 0),x.opt.eraserlines)for(var _p12=0;_p12<x.opt.eraserlines.length;_p12++){var _S12=x.opt.eraserlines[_p12].op;for(var _A8=0;_A8<_S12.length;_A8++)QA(_S12[_A8],x.centerPos,h);}}}x&&n.setInfo(t.name,x);}}},{key:"getCenterPos",value:function getCenterPos(e,t){var r=t.worldPosition,n=t.worldScaling;return[(e.x+e.w/2-r[0])/n[0],(e.y+e.h/2-r[1])/n[1]];}},{key:"getRectFromLayer",value:function getRectFromLayer(e,t){var r=e.getElementsByName(t)[0];if(r){var n=r.getBoundingClientRect();return{x:Math.floor(n.x-Mr.SafeBorderPadding),y:Math.floor(n.y-Mr.SafeBorderPadding),w:Math.floor(n.width+Mr.SafeBorderPadding*2),h:Math.floor(n.height+Mr.SafeBorderPadding*2)};}}},{key:"isWillRefresh",value:function isWillRefresh(e){var t=e.toolsType,r=e.opt,n=e.node,s=e.updateOpt,c=e.willSerializeData;return!!(c&&(s.angle||s.translate)||s.thickness&&r.thickness&&r.thickness!==s.thickness||s.strokeType&&r.strokeType&&r.strokeType!==s.strokeType||s.originPoint&&s.scenePoint&&s.scale||s.pointMap&&s.pointMap.has(n.name)||t===Tt.Text&&(s.fontSize||s.translate||s.textInfos&&s.textInfos.get(n.name))||t===Tt.Image&&(s.angle||s.translate||s.scale||s.strokeColor&&s.type===cl.Iconify)||t===s.toolsType&&s.willRefresh||r.eraserlines&&r.eraserlines.length&&(s.strokeColor||s.fillColor));}}]);}();dt(Mr,"SafeBorderPadding",10);var $t=Mr;var Tl=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 Cl={exports:{}};Cl.exports;(function(i){var e=function(){var t=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",s={};function c(f,h){if(!s[f]){s[f]={};for(var m=0;m<f.length;m++)s[f][f.charAt(m)]=m;}return s[f][h];}var l={compressToBase64:function compressToBase64(f){if(f==null)return"";var h=l._compress(f,6,function(m){return r.charAt(m);});switch(h.length%4){default:case 0:return h;case 1:return h+"===";case 2:return h+"==";case 3:return h+"=";}},decompressFromBase64:function decompressFromBase64(f){return f==null?"":f==""?null:l._decompress(f.length,32,function(h){return c(r,f.charAt(h));});},compressToUTF16:function compressToUTF16(f){return f==null?"":l._compress(f,15,function(h){return t(h+32);})+" ";},decompressFromUTF16:function decompressFromUTF16(f){return f==null?"":f==""?null:l._decompress(f.length,16384,function(h){return f.charCodeAt(h)-32;});},//compress into uint8array (UCS-2 big endian format)
400
400
  compressToUint8Array:function compressToUint8Array(f){for(var h=l.compress(f),m=new Uint8Array(h.length*2),u=0,y=h.length;u<y;u++){var T=h.charCodeAt(u);m[u*2]=T>>>8,m[u*2+1]=T%256;}return m;},//decompress from uint8array (UCS-2 big endian format)
401
401
  decompressFromUint8Array:function decompressFromUint8Array(f){if(f==null)return l.decompress(f);for(var h=new Array(f.length/2),m=0,u=h.length;m<u;m++)h[m]=f[m*2]*256+f[m*2+1];var y=[];return h.forEach(function(T){y.push(t(T));}),l.decompress(y.join(""));},//compress into a string that is already URI encoded
402
402
  compressToEncodedURIComponent:function compressToEncodedURIComponent(f){return f==null?"":l._compress(f,6,function(h){return n.charAt(h);});},//decompress from an output of compressToEncodedURIComponent
@@ -396,7 +396,7 @@ _inherits(l,_r$default22);return _createClass(l,[{key:"texture",get:function get
396
396
  h=="length"||// Node.js 0.10 has enumerable non-index properties on buffers.
397
397
  n&&(h=="offset"||h=="parent")||// PhantomJS 2 has enumerable non-index properties on typed arrays.
398
398
  s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||// Skip index properties.
399
- AT(h,f)))&&l.push(h);return l;}var th=RT,bT=Object.prototype;function DT(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||bT;return i===t;}var vl=DT;function NT(i,e){return function(t){return i(e(t));};}var eh=NT,BT=eh,WT=BT(Object.keys,Object),FT=WT,UT=vl,YT=FT,XT=Object.prototype,zT=XT.hasOwnProperty;function $T(i){if(!UT(i))return YT(i);var e=[];for(var t in Object(i))zT.call(i,t)&&t!="constructor"&&e.push(t);return e;}var jT=$T,GT=ju,kT=qu;function HT(i){return i!=null&&kT(i.length)&&!GT(i);}var gl=HT,KT=th,VT=jT,ZT=gl;function JT(i){return ZT(i)?KT(i):VT(i);}var ml=JT,QT=yo,qT=ml;function _T(i,e){return i&&QT(e,qT(e),i);}var tC=_T;function eC(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e;}var rC=eC,nC=Qi,iC=vl,sC=rC,oC=Object.prototype,aC=oC.hasOwnProperty;function lC(i){if(!nC(i))return sC(i);var e=iC(i),t=[];for(var r in i)r=="constructor"&&(e||!aC.call(i,r))||t.push(r);return t;}var fC=lC,cC=th,uC=fC,hC=gl;function dC(i){return hC(i)?cC(i,!0):uC(i);}var yl=dC,pC=yo,vC=yl;function gC(i,e){return i&&pC(e,vC(e),i);}var mC=gC,ro={exports:{}};ro.exports;(function(i,e){var t=_r,r=e&&!e.nodeType&&e,n=r&&!0&&i&&!i.nodeType&&i,s=n&&n.exports===r,c=s?t.Buffer:void 0,l=c?c.allocUnsafe:void 0;function f(h,m){if(m)return h.slice();var u=h.length,y=l?l(u):new h.constructor(u);return h.copy(y),y;}i.exports=f;})(ro,ro.exports);var yC=ro.exports;function PC(i,e){var t=-1,r=i.length;for(e||(e=Array(r));++t<r;)e[t]=i[t];return e;}var SC=PC;function xC(i,e){for(var t=-1,r=i==null?0:i.length,n=0,s=[];++t<r;){var c=i[t];e(c,t,i)&&(s[n++]=c);}return s;}var rh=xC;function TC(){return[];}var nh=TC,CC=rh,IC=nh,OC=Object.prototype,wC=OC.propertyIsEnumerable,qc=Object.getOwnPropertySymbols,AC=qc?function(i){return i==null?[]:(i=Object(i),CC(qc(i),function(e){return wC.call(i,e);}));}:IC,Pl=AC,EC=yo,MC=Pl;function LC(i,e){return EC(i,MC(i),e);}var RC=LC;function bC(i,e){for(var t=-1,r=e.length,n=i.length;++t<r;)i[n+t]=e[t];return i;}var Sl=bC,DC=eh,NC=DC(Object.getPrototypeOf,Object),ih=NC,BC=Sl,WC=ih,FC=Pl,UC=nh,YC=Object.getOwnPropertySymbols,XC=YC?function(i){for(var e=[];i;)BC(e,FC(i)),i=WC(i);return e;}:UC,sh=XC,zC=yo,$C=sh;function jC(i,e){return zC(i,$C(i),e);}var GC=jC,kC=Sl,HC=qi;function KC(i,e,t){var r=e(i);return HC(i)?r:kC(r,t(i));}var oh=KC,VC=oh,ZC=Pl,JC=ml;function QC(i){return VC(i,JC,ZC);}var ah=QC,qC=oh,_C=sh,tI=yl;function eI(i){return qC(i,tI,_C);}var rI=eI,nI=$n,iI=_r,sI=nI(iI,"DataView"),oI=sI,aI=$n,lI=_r,fI=aI(lI,"Promise"),cI=fI,uI=$n,hI=_r,dI=uI(hI,"Set"),lh=dI,pI=$n,vI=_r,gI=pI(vI,"WeakMap"),mI=gI,rl=oI,nl=hl,il=cI,sl=lh,ol=mI,fh=Pi,Ii=Gu,_c="[object Map]",yI="[object Object]",tu="[object Promise]",eu="[object Set]",ru="[object WeakMap]",nu="[object DataView]",PI=Ii(rl),SI=Ii(nl),xI=Ii(il),TI=Ii(sl),CI=Ii(ol),zn=fh;(rl&&zn(new rl(new ArrayBuffer(1)))!=nu||nl&&zn(new nl())!=_c||il&&zn(il.resolve())!=tu||sl&&zn(new sl())!=eu||ol&&zn(new ol())!=ru)&&(zn=function zn(i){var e=fh(i),t=e==yI?i.constructor:void 0,r=t?Ii(t):"";if(r)switch(r){case PI:return nu;case SI:return _c;case xI:return tu;case TI:return eu;case CI:return ru;}return e;});var So=zn,II=Object.prototype,OI=II.hasOwnProperty;function wI(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&OI.call(i,"index")&&(t.index=i.index,t.input=i.input),t;}var AI=wI,EI=_r,MI=EI.Uint8Array,ch=MI,iu=ch;function LI(i){var e=new i.constructor(i.byteLength);return new iu(e).set(new iu(i)),e;}var xl=LI,RI=xl;function bI(i,e){var t=e?RI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength);}var DI=bI,NI=/\w*$/;function BI(i){var e=new i.constructor(i.source,NI.exec(i));return e.lastIndex=i.lastIndex,e;}var WI=BI,su=Ji,ou=su?su.prototype:void 0,au=ou?ou.valueOf:void 0;function FI(i){return au?Object(au.call(i)):{};}var UI=FI,YI=xl;function XI(i,e){var t=e?YI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length);}var zI=XI,$I=xl,jI=DI,GI=WI,kI=UI,HI=zI,KI="[object Boolean]",VI="[object Date]",ZI="[object Map]",JI="[object Number]",QI="[object RegExp]",qI="[object Set]",_I="[object String]",tO="[object Symbol]",eO="[object ArrayBuffer]",rO="[object DataView]",nO="[object Float32Array]",iO="[object Float64Array]",sO="[object Int8Array]",oO="[object Int16Array]",aO="[object Int32Array]",lO="[object Uint8Array]",fO="[object Uint8ClampedArray]",cO="[object Uint16Array]",uO="[object Uint32Array]";function hO(i,e,t){var r=i.constructor;switch(e){case eO:return $I(i);case KI:case VI:return new r(+i);case rO:return jI(i,t);case nO:case iO:case sO:case oO:case aO:case lO:case fO:case cO:case uO:return HI(i,t);case ZI:return new r();case JI:case _I:return new r(i);case QI:return GI(i);case qI:return new r();case tO:return kI(i);}}var dO=hO,pO=Qi,lu=Object.create,vO=/* @__PURE__ */function(){function i(){}return function(e){if(!pO(e))return{};if(lu)return lu(e);i.prototype=e;var t=new i();return i.prototype=void 0,t;};}(),gO=vO,mO=gO,yO=ih,PO=vl;function SO(i){return typeof i.constructor=="function"&&!PO(i)?mO(yO(i)):{};}var xO=SO,TO=So,CO=pn,IO="[object Map]";function OO(i){return CO(i)&&TO(i)==IO;}var wO=OO,AO=wO,EO=Po,fu=pl,cu=fu&&fu.isMap,MO=cu?EO(cu):AO,LO=MO,RO=So,bO=pn,DO="[object Set]";function NO(i){return bO(i)&&RO(i)==DO;}var BO=NO,WO=BO,FO=Po,uu=pl,hu=uu&&uu.isSet,UO=hu?FO(hu):WO,uh=UO,YO=/* @__PURE__ */Ln(uh),XO=Hu,zO=hx,$O=Zu,jO=tC,GO=mC,kO=yC,HO=SC,KO=RC,VO=GC,ZO=ah,JO=rI,QO=So,qO=AI,_O=dO,t2=xO,e2=qi,r2=dl,n2=LO,i2=Qi,s2=uh,o2=ml,a2=yl,l2=1,f2=2,c2=4,hh="[object Arguments]",u2="[object Array]",h2="[object Boolean]",d2="[object Date]",p2="[object Error]",dh="[object Function]",v2="[object GeneratorFunction]",g2="[object Map]",m2="[object Number]",ph="[object Object]",y2="[object RegExp]",P2="[object Set]",S2="[object String]",x2="[object Symbol]",T2="[object WeakMap]",C2="[object ArrayBuffer]",I2="[object DataView]",O2="[object Float32Array]",w2="[object Float64Array]",A2="[object Int8Array]",E2="[object Int16Array]",M2="[object Int32Array]",L2="[object Uint8Array]",R2="[object Uint8ClampedArray]",b2="[object Uint16Array]",D2="[object Uint32Array]",Ye={};Ye[hh]=Ye[u2]=Ye[C2]=Ye[I2]=Ye[h2]=Ye[d2]=Ye[O2]=Ye[w2]=Ye[A2]=Ye[E2]=Ye[M2]=Ye[g2]=Ye[m2]=Ye[ph]=Ye[y2]=Ye[P2]=Ye[S2]=Ye[x2]=Ye[L2]=Ye[R2]=Ye[b2]=Ye[D2]=!0;Ye[p2]=Ye[dh]=Ye[T2]=!1;function qs(i,e,t,r,n,s){var c,l=e&l2,f=e&f2,h=e&c2;if(t&&(c=n?t(i,r,n,s):t(i)),c!==void 0)return c;if(!i2(i))return i;var m=e2(i);if(m){if(c=qO(i),!l)return HO(i,c);}else{var u=QO(i),y=u==dh||u==v2;if(r2(i))return kO(i,l);if(u==ph||u==hh||y&&!n){if(c=f||y?{}:t2(i),!l)return f?VO(i,GO(c,i)):KO(i,jO(c,i));}else{if(!Ye[u])return n?i:{};c=_O(i,u,l);}}s||(s=new XO());var T=s.get(i);if(T)return T;s.set(i,c),s2(i)?i.forEach(function(x){c.add(qs(x,e,t,x,i,s));}):n2(i)&&i.forEach(function(x,I){c.set(I,qs(x,e,t,I,i,s));});var E=h?f?JO:ZO:f?a2:o2,C=m?void 0:E(i);return zO(C||i,function(x,I){C&&(I=x,x=i[I]),$O(c,I,qs(x,e,t,I,i,s));}),c;}var N2=qs,B2=N2,W2=1,F2=4;function U2(i){return B2(i,W2|F2);}var Y2=U2,fr=/* @__PURE__ */Ln(Y2);var vh="1.1.22-beta.12",X2="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var i=window.__netlessUA||"";i+=" ".concat(X2,"@").concat(vh),window.__netlessUA=i;}var vr={useWorker:"auto",useSimple:!1,syncOpt:{interval:300,smoothSync:!0},cursor:{enable:!0,expirationTime:5e3,moveDelayTime:100},bufferSize:{full:2e4,sub:600},bezier:{enable:!0,maxDrawCount:1/0,combineUnitTime:300},pencilEraser:{useBitMap:!0,maxImageWidth:1920,maxImageHeight:1920,maxCombineTime:500},strokeWidth:{min:1,max:10},textEditor:{showFloatBar:!0,canSelectorSwitch:!0,rightBoundBreak:!1,extendFontFaces:[],loadFontFacesTimeout:1e4},longDottedStroke:{lineCap:"round",segment:1,gap:2},dottedStroke:{lineCap:"round",segment:1,gap:2},normalStroke:{lineCap:"round"}};function En(i){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var t=i.length;if(t<2)return"";var r=i[0],n=i[1];if(t===2)return"M".concat(fi(r),"L").concat(fi(n));var s="";for(var c=2,l=t-1;c<l;c++)r=i[c],n=i[c+1],s+=ci(r,n);return e?"M".concat(ci(i[0],i[1]),"Q").concat(fi(i[1])).concat(ci(i[1],i[2]),"T").concat(s).concat(ci(i[t-1],i[0])).concat(ci(i[0],i[1]),"Z"):"M".concat(fi(i[0]),"Q").concat(fi(i[1])).concat(ci(i[1],i[2])).concat(i.length>3?"T":"").concat(s,"L").concat(fi(i[t-1]));}var Mr=/*#__PURE__*/function(){function Mr(e){_classCallCheck(this,Mr);dt(this,"maxImageWidth",vr.pencilEraser.maxImageWidth);dt(this,"maxImageHeight",vr.pencilEraser.maxImageHeight);dt(this,"syncUnitTime",vr.syncOpt.interval);dt(this,"vNodes");dt(this,"drawLayer");dt(this,"fullLayer");dt(this,"workId");dt(this,"isDelete",!1);var t=e.vNodes,r=e.fullLayer,n=e.drawLayer,s=e.workId,c=e.toolsOpt;this.vNodes=t,this.fullLayer=r,this.drawLayer=n,this.workId=s,this.syncUnitTime=c.syncUnitTime||this.syncUnitTime;}return _createClass(Mr,[{key:"baseConsumeResult",get:function get(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions};}},{key:"filterSamePoints",value:function filterSamePoints(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0.01;return e.reduce(function(r,n){var s=r[r.length-1];return(n&&!s||n&&s&&!n.isNear(s,t))&&r.push(n),r;},[]);}/** 设置工作id */},{key:"setWorkId",value:function setWorkId(e){this.workId=e;}},{key:"getWorkId",value:function getWorkId(){return this.workId;}/** 获取工作选项配置 */},{key:"getWorkOptions",value:function getWorkOptions(){return this.workOptions;}/** 设置工作选项配置 */},{key:"setWorkOptions",value:function setWorkOptions(e){var n,s,c;this.workOptions=e,this.syncUnitTime=e.syncUnitTime||this.syncUnitTime;var t=(n=this.workId)==null?void 0:n.toString(),r=t&&((s=this.vNodes)==null?void 0:s.get(t))||void 0;t&&r&&(r.opt=e,(c=this.vNodes)==null||c.setInfo(t,r));}/** 更新服务端同步配置,返回绘制结果 */},{key:"updataOptService",value:function updataOptService(e){var n,s;var t;var r=(n=this.workId)==null?void 0:n.toString();if(r&&e){var c=this.fullLayer.getElementsByName(r)||this.drawLayer&&this.drawLayer.getElementsByName(r)||[];if(c.length!==1)return;var l=c[0],f=e.pos,h=e.zIndex,m=e.scale,u=e.angle,y=e.translate,T={};er(h)&&(T.zIndex=h),f&&(T.pos=[f[0],f[1]]),m&&(T.scale=m),u&&(T.rotate=u),y&&(T.translate=y),l.attr(T);var E=l==null?void 0:l.getBoundingClientRect();return E&&(t=Zt(t,{x:Math.floor(E.x-Mr.SafeBorderPadding),y:Math.floor(E.y-Mr.SafeBorderPadding),w:Math.floor(E.width+Mr.SafeBorderPadding*2),h:Math.floor(E.height+Mr.SafeBorderPadding*2)})),(s=this.vNodes)==null||s.setInfo(r,{rect:t,centerPos:f}),t;}}},{key:"drawEraserlines",value:function drawEraserlines(e,t){var r=e.group,n=e.eraserlines,s=e.pos,c=e.layer,l=c.parent;if(t)try{var h=(c.renderer.glRenderer||c.renderer.canvasRenderer).options.displayRatio,m=r.getBoundingClientRect(),u=m.width*h*c.worldScaling[0],y=m.height*h*c.worldScaling[1];var T=1;(u>this.maxImageWidth||y>this.maxImageHeight)&&(T=Math.min(this.maxImageWidth/u,this.maxImageHeight/y));var E=c.getAttribute("scale");E=[E[0]*T,E[1]*T];var C=c.parent.parent,x=c.getAttribute("translate"),_I32=this.createVmRenderNode("".concat(this.workId,"_bitMapLayer"),C,{offscreen:l.offscreen,width:l.width,height:l.height,contextType:"2d",autoRender:!1,bufferSize:500},E,x),_d29=r.cloneNode(!0);if(!n||!n.length)return;this.addEraserlines(_d29,n,s,!1),_I32.appendChild(_d29);var v=_I32.parent;v.render();var p=_I32.renderer.canvasRenderer,S=p.context;if(!S)return;var A=p.options.displayRatio,R=_d29.getBoundingClientRect(),D={x:R.x,y:R.y,w:R.width,h:R.height},U={x:0,y:0,w:C.width,h:C.height};if(Zi(D,U)===Tr.outside){Lr(_d29,v),C.removeChild(v),this.isDelete=!0;return;}var W=fr(D);W.x=Math.floor(Math.max(D.x,0)),W.y=Math.floor(Math.max(D.y,0)),W.w=Math.min(D.x+D.w,C.width)-W.x,W.h=Math.min(D.y+D.h,C.height)-W.y;var Y=this.getGroupRect(W,A),B=Y.x,N=Y.y,G=Y.w,J=Y.h;var tt=S.getImageData(B,N,G,J);if(this.isTransparentRectByCanvas(tt)){Lr(_d29,v),C.removeChild(v),this.isDelete=!0,tt=null;return;}Lr(r,l);var ut=this.createSpriteNode({imageData:tt,safariRect:W,originRect:D,worldScaling:_I32.worldScaling});ut&&r.append(ut),Lr(_d29,v),C.removeChild(v),l.deleteTexture(tt),tt=null;}catch(f){console.error("[BaseShapeTool] drawEraserlines error:",f);return;}}},{key:"createVmRenderNode",value:function createVmRenderNode(e,t,r,n,s){var c=r.width,l=r.height,f="bitMap-".concat(e),h=t.layer(f,r),m=new mr({anchor:[0.5,0.5],pos:[c*0.5,l*0.5],size:[c,l],name:"viewport",id:e});return m.setAttribute("scale",n),m.setAttribute("translate",s),h.append(m),m;}},{key:"getGroupRect",value:function getGroupRect(e,t){var r=Math.floor(e.x*t),n=Math.floor(e.y*t),s=Math.floor(e.w*t),c=Math.floor(e.h*t);return{x:r,y:n,w:s,h:c};}},{key:"addEraserlines",value:function addEraserlines(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:!0;var _iterator13=_createForOfIteratorHelper(t),_step13;try{for(_iterator13.s();!(_step13=_iterator13.n()).done;){var s=_step13.value;var c=s.thickness,l=s.op;var _iterator14=_createForOfIteratorHelper(l),_step14;try{for(_iterator14.s();!(_step14=_iterator14.n()).done;){var f=_step14.value;var h=f.map(function(E,C){return C%2?E-r[1]:E-r[0];}),m=this.computEraserPoints(h,c),u=En(m,!0),y={pos:[0,0],d:u,fillColor:"rgba(0,0,0,1)"},T=new Mn(y);T.addEventListener("beforerender",function(_ref164){var E=_ref164.detail;var C=E.context;n?C.blendFuncSeparate(C.ZERO,C.ZERO,C.ZERO,C.ZERO):C.globalCompositeOperation="destination-out";}),T.addEventListener("afterrender",function(_ref165){var E=_ref165.detail;var C=E.context;n?C.blendFuncSeparate(C.SRC_ALPHA,C.ONE_MINUS_SRC_ALPHA,C.ONE,C.ONE_MINUS_SRC_ALPHA):C.globalCompositeOperation="source-over";}),e.append(T);}}catch(err){_iterator14.e(err);}finally{_iterator14.f();}}}catch(err){_iterator13.e(err);}finally{_iterator13.f();}}},{key:"isTransparentRectByCanvas",value:function isTransparentRectByCanvas(e){var t=!0;for(var r=0;r<e.data.length;r+=4)if(e.data[r+3]!==0){t=!1;break;}return t;}},{key:"createSpriteNode",value:function createSpriteNode(e){var t=e.imageData,r=e.worldScaling,n=e.safariRect,s=e.originRect;var c;if(typeof OffscreenCanvas=="function"){c=new OffscreenCanvas(t.width,t.height);var m=c.getContext("2d");m&&m.putImageData(t,0,0);}else if((typeof document==="undefined"?"undefined":_typeof(document))<"u"){c=document.createElement("canvas"),c.width=t.width,c.height=t.height;var _m4=c.getContext("2d");_m4&&_m4.putImageData(t,0,0);}if(!c)return console.warn("Failed to create imageEraserBitmap Sprite"),null;var l=[Math.floor(s.w/r[0]),Math.floor(s.h/r[1])],f=[Math.floor((n.x-s.x)/r[0]),Math.floor((n.y-s.y)/r[1]),Math.floor(n.w/r[0]),Math.floor(n.h/r[1])],h={name:"eraserTexture",anchor:[0.5,0.5],pos:[0,0],size:l,texture:c,textureRect:f};return new Yu(h);}},{key:"computEraserPoints",value:function computEraserPoints(e,t){var r=Math.ceil(t/2);return e.length===2?this.computDot(e,r):this.computLine(e,r);}},{key:"computDot",value:function computDot(e,t){var r=new Jt(e[0],e[1]);return Jt.GetDotStroke(r,t,8);}},{key:"computLine",value:function computLine(e,t){var r=[],n=[];var s,c;for(var l=0;l<e.length;l+=2){var f=new Jt(e[l],e[l+1]);var h=void 0;if(l==e.length-2){var m=new Jt(e[l-2],e[l-1]);h=pt.Sub(f,m).uni(),s=f;}else{l===0&&(c=f);var _m5=new Jt(e[l+2],e[l+3]);h=pt.Sub(_m5,f).uni();}if(h){var _m6=pt.Per(h).mul(t);r.push(Jt.Sub(f,_m6)),n.push(Jt.Add(f,_m6));}}if(s&&c){var _l3=Jt.GetSemicircleStroke(s,r[r.length-1],-1,8),_f4=Jt.GetSemicircleStroke(c,n[0],-1,8);return r.concat(_l3,n.reverse(),_f4);}return[];}},{key:"replace",value:function replace(e,t,r){var _this61=this;var s;if(!t){r&&e.append(r);return;}var n=e.getElementsByName(t);if(n.length){var _iterator15=_createForOfIteratorHelper(n),_step15;try{for(_iterator15.s();!(_step15=_iterator15.n()).done;){var c=_step15.value;r?iE(r,c,e):(c.remove(),_pr(c,e.parent));}}catch(err){_iterator15.e(err);}finally{_iterator15.f();}}else r&&e.append(r);this.fullLayer!==this.drawLayer&&(this.fullLayer===e?(s=this.drawLayer)==null||s.getElementsByName(t).forEach(function(l){var f;l.remove(),_pr(l,(f=_this61.drawLayer)==null?void 0:f.parent);}):this.fullLayer.getElementsByName(t).forEach(function(l){l.remove(),_pr(l,_this61.fullLayer.parent);}));}},{key:"removeDrawCountNodes",value:function removeDrawCountNodes(e,t){var r=[];e.getElementsByName(this.workId).forEach(function(n){n.id&&t&&Number(n.id)<t&&r.push(n);});for(var _i2=0,_r3=r;_i2<_r3.length;_i2++){var n=_r3[_i2];n.remove(),_pr(n,e.parent);}}}],[{key:"updateNodeOpt",value:function updateNodeOpt(e){var d;var t=e.node,r=e.opt,n=e.vNodes,s=e.willSerializeData,c=e.targetNode,l=r.zIndex,f=r.translate,h=r.angle,m=r.originPoint,u=r.scenePoint,y=r.scale,T=r.pointMap,E=r.thickness;var C;var x=c&&fr(c)||n.get(t.name);if(!x)return;er(l)&&(t.setAttribute("zIndex",l),x.opt.zIndex=l);var I=t.parent;if(I){if(m&&y&&c){var v=[x.op[0],x.op[1]];Ll(x.op,u,y,f);var p=[x.op[0],x.op[1]],S=[p[0]-v[0],p[1]-v[1]];if(x.centerPos=[x.centerPos[0]+S[0],x.centerPos[1]+S[1]],x.opt.translate=void 0,x.opt.scale=void 0,x.opt.eraserlines)for(var A=0;A<x.opt.eraserlines.length;A++){var _x$opt$eraserlines$A=x.opt.eraserlines[A],R=_x$opt$eraserlines$A.op,D=_x$opt$eraserlines$A.thickness;x.opt.eraserlines[A].thickness=Math.round(D*Math.max(y[0],y[1]));for(var U=0;U<R.length;U++)Rl(R[U],u,y,f);}}else if(f){if(t.setAttribute("translate",f),x.opt.translate=f,c){var _v6=[f[0]*I.worldScaling[0],f[1]*I.worldScaling[1]];C=Vi(x.rect,_v6),x.rect=C;}else{var _v7=Mr.getRectFromLayer(I,t.name);x.rect=_v7||x.rect;}}else if(er(h))if(t.setAttribute("rotate",h),x.opt.rotate=h,c)C=Hh(x.rect,h),x.rect=C;else{var _v8=Mr.getRectFromLayer(I,t.name);x.rect=_v8||x.rect;}if(T){var _v9=T.get(t.name);if(_v9)for(var _p10=0,_S10=0;_p10<x.op.length;_p10+=3,_S10++)x.op[_p10]=_v9[_S10][0],x.op[_p10+1]=_v9[_S10][1];}if(E&&(d=x==null?void 0:x.opt)!=null&&d.thickness&&(x.opt.thickness=E),s&&!(m&&y&&c)){if(f){var _v10=x.op.map(function(p,S){var A=S%3;return A===0?p+f[0]:A===1?p+f[1]:p;});if(x.op=_v10,x.centerPos=[x.centerPos[0]+f[0],x.centerPos[1]+f[1]],x!=null&&x.opt&&(x.opt.translate=void 0),x.opt.eraserlines)for(var _p11=0;_p11<x.opt.eraserlines.length;_p11++){var _S11=x.opt.eraserlines[_p11].op;for(var _A7=0;_A7<_S11.length;_A7++){var _R3=_S11[_A7].map(function(D,U){return U%2?D+f[1]:D+f[0];});x.opt.eraserlines[_p11].op[_A7]=_R3;}}}else if(er(h)){var _v11=x.op;if(JA(_v11,x.centerPos,h),x.op=_v11,x!=null&&x.opt&&(x.opt.rotate=void 0),x.opt.eraserlines)for(var _p12=0;_p12<x.opt.eraserlines.length;_p12++){var _S12=x.opt.eraserlines[_p12].op;for(var _A8=0;_A8<_S12.length;_A8++)QA(_S12[_A8],x.centerPos,h);}}}x&&n.setInfo(t.name,x);}}},{key:"getCenterPos",value:function getCenterPos(e,t){var r=t.worldPosition,n=t.worldScaling;return[(e.x+e.w/2-r[0])/n[0],(e.y+e.h/2-r[1])/n[1]];}},{key:"getRectFromLayer",value:function getRectFromLayer(e,t){var r=e.getElementsByName(t)[0];if(r){var n=r.getBoundingClientRect();return{x:Math.floor(n.x-Mr.SafeBorderPadding),y:Math.floor(n.y-Mr.SafeBorderPadding),w:Math.floor(n.width+Mr.SafeBorderPadding*2),h:Math.floor(n.height+Mr.SafeBorderPadding*2)};}}},{key:"isWillRefresh",value:function isWillRefresh(e){var t=e.toolsType,r=e.opt,n=e.node,s=e.updateOpt,c=e.willSerializeData;return!!(c&&(s.angle||s.translate)||s.thickness&&r.thickness&&r.thickness!==s.thickness||s.strokeType&&r.strokeType&&r.strokeType!==s.strokeType||s.originPoint&&s.scenePoint&&s.scale||s.pointMap&&s.pointMap.has(n.name)||t===Tt.Text&&(s.fontSize||s.translate||s.textInfos&&s.textInfos.get(n.name))||t===Tt.Image&&(s.angle||s.translate||s.scale||s.strokeColor&&s.type===cl.Iconify)||t===s.toolsType&&s.willRefresh||r.eraserlines&&r.eraserlines.length&&(s.strokeColor||s.fillColor));}}]);}();dt(Mr,"SafeBorderPadding",10);var $t=Mr;var Tl=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 Cl={exports:{}};Cl.exports;(function(i){var e=function(){var t=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",s={};function c(f,h){if(!s[f]){s[f]={};for(var m=0;m<f.length;m++)s[f][f.charAt(m)]=m;}return s[f][h];}var l={compressToBase64:function compressToBase64(f){if(f==null)return"";var h=l._compress(f,6,function(m){return r.charAt(m);});switch(h.length%4){default:case 0:return h;case 1:return h+"===";case 2:return h+"==";case 3:return h+"=";}},decompressFromBase64:function decompressFromBase64(f){return f==null?"":f==""?null:l._decompress(f.length,32,function(h){return c(r,f.charAt(h));});},compressToUTF16:function compressToUTF16(f){return f==null?"":l._compress(f,15,function(h){return t(h+32);})+" ";},decompressFromUTF16:function decompressFromUTF16(f){return f==null?"":f==""?null:l._decompress(f.length,16384,function(h){return f.charCodeAt(h)-32;});},//compress into uint8array (UCS-2 big endian format)
399
+ AT(h,f)))&&l.push(h);return l;}var th=RT,bT=Object.prototype;function DT(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||bT;return i===t;}var vl=DT;function NT(i,e){return function(t){return i(e(t));};}var eh=NT,BT=eh,WT=BT(Object.keys,Object),FT=WT,UT=vl,YT=FT,XT=Object.prototype,zT=XT.hasOwnProperty;function $T(i){if(!UT(i))return YT(i);var e=[];for(var t in Object(i))zT.call(i,t)&&t!="constructor"&&e.push(t);return e;}var jT=$T,GT=ju,kT=qu;function HT(i){return i!=null&&kT(i.length)&&!GT(i);}var gl=HT,KT=th,VT=jT,ZT=gl;function JT(i){return ZT(i)?KT(i):VT(i);}var ml=JT,QT=yo,qT=ml;function _T(i,e){return i&&QT(e,qT(e),i);}var tC=_T;function eC(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e;}var rC=eC,nC=Qi,iC=vl,sC=rC,oC=Object.prototype,aC=oC.hasOwnProperty;function lC(i){if(!nC(i))return sC(i);var e=iC(i),t=[];for(var r in i)r=="constructor"&&(e||!aC.call(i,r))||t.push(r);return t;}var fC=lC,cC=th,uC=fC,hC=gl;function dC(i){return hC(i)?cC(i,!0):uC(i);}var yl=dC,pC=yo,vC=yl;function gC(i,e){return i&&pC(e,vC(e),i);}var mC=gC,ro={exports:{}};ro.exports;(function(i,e){var t=_r,r=e&&!e.nodeType&&e,n=r&&!0&&i&&!i.nodeType&&i,s=n&&n.exports===r,c=s?t.Buffer:void 0,l=c?c.allocUnsafe:void 0;function f(h,m){if(m)return h.slice();var u=h.length,y=l?l(u):new h.constructor(u);return h.copy(y),y;}i.exports=f;})(ro,ro.exports);var yC=ro.exports;function PC(i,e){var t=-1,r=i.length;for(e||(e=Array(r));++t<r;)e[t]=i[t];return e;}var SC=PC;function xC(i,e){for(var t=-1,r=i==null?0:i.length,n=0,s=[];++t<r;){var c=i[t];e(c,t,i)&&(s[n++]=c);}return s;}var rh=xC;function TC(){return[];}var nh=TC,CC=rh,IC=nh,OC=Object.prototype,wC=OC.propertyIsEnumerable,qc=Object.getOwnPropertySymbols,AC=qc?function(i){return i==null?[]:(i=Object(i),CC(qc(i),function(e){return wC.call(i,e);}));}:IC,Pl=AC,EC=yo,MC=Pl;function LC(i,e){return EC(i,MC(i),e);}var RC=LC;function bC(i,e){for(var t=-1,r=e.length,n=i.length;++t<r;)i[n+t]=e[t];return i;}var Sl=bC,DC=eh,NC=DC(Object.getPrototypeOf,Object),ih=NC,BC=Sl,WC=ih,FC=Pl,UC=nh,YC=Object.getOwnPropertySymbols,XC=YC?function(i){for(var e=[];i;)BC(e,FC(i)),i=WC(i);return e;}:UC,sh=XC,zC=yo,$C=sh;function jC(i,e){return zC(i,$C(i),e);}var GC=jC,kC=Sl,HC=qi;function KC(i,e,t){var r=e(i);return HC(i)?r:kC(r,t(i));}var oh=KC,VC=oh,ZC=Pl,JC=ml;function QC(i){return VC(i,JC,ZC);}var ah=QC,qC=oh,_C=sh,tI=yl;function eI(i){return qC(i,tI,_C);}var rI=eI,nI=$n,iI=_r,sI=nI(iI,"DataView"),oI=sI,aI=$n,lI=_r,fI=aI(lI,"Promise"),cI=fI,uI=$n,hI=_r,dI=uI(hI,"Set"),lh=dI,pI=$n,vI=_r,gI=pI(vI,"WeakMap"),mI=gI,rl=oI,nl=hl,il=cI,sl=lh,ol=mI,fh=Pi,Ii=Gu,_c="[object Map]",yI="[object Object]",tu="[object Promise]",eu="[object Set]",ru="[object WeakMap]",nu="[object DataView]",PI=Ii(rl),SI=Ii(nl),xI=Ii(il),TI=Ii(sl),CI=Ii(ol),zn=fh;(rl&&zn(new rl(new ArrayBuffer(1)))!=nu||nl&&zn(new nl())!=_c||il&&zn(il.resolve())!=tu||sl&&zn(new sl())!=eu||ol&&zn(new ol())!=ru)&&(zn=function zn(i){var e=fh(i),t=e==yI?i.constructor:void 0,r=t?Ii(t):"";if(r)switch(r){case PI:return nu;case SI:return _c;case xI:return tu;case TI:return eu;case CI:return ru;}return e;});var So=zn,II=Object.prototype,OI=II.hasOwnProperty;function wI(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&OI.call(i,"index")&&(t.index=i.index,t.input=i.input),t;}var AI=wI,EI=_r,MI=EI.Uint8Array,ch=MI,iu=ch;function LI(i){var e=new i.constructor(i.byteLength);return new iu(e).set(new iu(i)),e;}var xl=LI,RI=xl;function bI(i,e){var t=e?RI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength);}var DI=bI,NI=/\w*$/;function BI(i){var e=new i.constructor(i.source,NI.exec(i));return e.lastIndex=i.lastIndex,e;}var WI=BI,su=Ji,ou=su?su.prototype:void 0,au=ou?ou.valueOf:void 0;function FI(i){return au?Object(au.call(i)):{};}var UI=FI,YI=xl;function XI(i,e){var t=e?YI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length);}var zI=XI,$I=xl,jI=DI,GI=WI,kI=UI,HI=zI,KI="[object Boolean]",VI="[object Date]",ZI="[object Map]",JI="[object Number]",QI="[object RegExp]",qI="[object Set]",_I="[object String]",tO="[object Symbol]",eO="[object ArrayBuffer]",rO="[object DataView]",nO="[object Float32Array]",iO="[object Float64Array]",sO="[object Int8Array]",oO="[object Int16Array]",aO="[object Int32Array]",lO="[object Uint8Array]",fO="[object Uint8ClampedArray]",cO="[object Uint16Array]",uO="[object Uint32Array]";function hO(i,e,t){var r=i.constructor;switch(e){case eO:return $I(i);case KI:case VI:return new r(+i);case rO:return jI(i,t);case nO:case iO:case sO:case oO:case aO:case lO:case fO:case cO:case uO:return HI(i,t);case ZI:return new r();case JI:case _I:return new r(i);case QI:return GI(i);case qI:return new r();case tO:return kI(i);}}var dO=hO,pO=Qi,lu=Object.create,vO=/* @__PURE__ */function(){function i(){}return function(e){if(!pO(e))return{};if(lu)return lu(e);i.prototype=e;var t=new i();return i.prototype=void 0,t;};}(),gO=vO,mO=gO,yO=ih,PO=vl;function SO(i){return typeof i.constructor=="function"&&!PO(i)?mO(yO(i)):{};}var xO=SO,TO=So,CO=pn,IO="[object Map]";function OO(i){return CO(i)&&TO(i)==IO;}var wO=OO,AO=wO,EO=Po,fu=pl,cu=fu&&fu.isMap,MO=cu?EO(cu):AO,LO=MO,RO=So,bO=pn,DO="[object Set]";function NO(i){return bO(i)&&RO(i)==DO;}var BO=NO,WO=BO,FO=Po,uu=pl,hu=uu&&uu.isSet,UO=hu?FO(hu):WO,uh=UO,YO=/* @__PURE__ */Ln(uh),XO=Hu,zO=hx,$O=Zu,jO=tC,GO=mC,kO=yC,HO=SC,KO=RC,VO=GC,ZO=ah,JO=rI,QO=So,qO=AI,_O=dO,t2=xO,e2=qi,r2=dl,n2=LO,i2=Qi,s2=uh,o2=ml,a2=yl,l2=1,f2=2,c2=4,hh="[object Arguments]",u2="[object Array]",h2="[object Boolean]",d2="[object Date]",p2="[object Error]",dh="[object Function]",v2="[object GeneratorFunction]",g2="[object Map]",m2="[object Number]",ph="[object Object]",y2="[object RegExp]",P2="[object Set]",S2="[object String]",x2="[object Symbol]",T2="[object WeakMap]",C2="[object ArrayBuffer]",I2="[object DataView]",O2="[object Float32Array]",w2="[object Float64Array]",A2="[object Int8Array]",E2="[object Int16Array]",M2="[object Int32Array]",L2="[object Uint8Array]",R2="[object Uint8ClampedArray]",b2="[object Uint16Array]",D2="[object Uint32Array]",Ye={};Ye[hh]=Ye[u2]=Ye[C2]=Ye[I2]=Ye[h2]=Ye[d2]=Ye[O2]=Ye[w2]=Ye[A2]=Ye[E2]=Ye[M2]=Ye[g2]=Ye[m2]=Ye[ph]=Ye[y2]=Ye[P2]=Ye[S2]=Ye[x2]=Ye[L2]=Ye[R2]=Ye[b2]=Ye[D2]=!0;Ye[p2]=Ye[dh]=Ye[T2]=!1;function qs(i,e,t,r,n,s){var c,l=e&l2,f=e&f2,h=e&c2;if(t&&(c=n?t(i,r,n,s):t(i)),c!==void 0)return c;if(!i2(i))return i;var m=e2(i);if(m){if(c=qO(i),!l)return HO(i,c);}else{var u=QO(i),y=u==dh||u==v2;if(r2(i))return kO(i,l);if(u==ph||u==hh||y&&!n){if(c=f||y?{}:t2(i),!l)return f?VO(i,GO(c,i)):KO(i,jO(c,i));}else{if(!Ye[u])return n?i:{};c=_O(i,u,l);}}s||(s=new XO());var T=s.get(i);if(T)return T;s.set(i,c),s2(i)?i.forEach(function(x){c.add(qs(x,e,t,x,i,s));}):n2(i)&&i.forEach(function(x,I){c.set(I,qs(x,e,t,I,i,s));});var E=h?f?JO:ZO:f?a2:o2,C=m?void 0:E(i);return zO(C||i,function(x,I){C&&(I=x,x=i[I]),$O(c,I,qs(x,e,t,I,i,s));}),c;}var N2=qs,B2=N2,W2=1,F2=4;function U2(i){return B2(i,W2|F2);}var Y2=U2,fr=/* @__PURE__ */Ln(Y2);var vh="1.1.22-beta.13",X2="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var i=window.__netlessUA||"";i+=" ".concat(X2,"@").concat(vh),window.__netlessUA=i;}var vr={useWorker:"auto",useSimple:!1,syncOpt:{interval:300,smoothSync:!0},cursor:{enable:!0,expirationTime:5e3,moveDelayTime:100},bufferSize:{full:2e4,sub:600},bezier:{enable:!0,maxDrawCount:1/0,combineUnitTime:300},pencilEraser:{useBitMap:!0,maxImageWidth:1920,maxImageHeight:1920,maxCombineTime:500},strokeWidth:{min:1,max:10},textEditor:{showFloatBar:!0,canSelectorSwitch:!0,rightBoundBreak:!1,extendFontFaces:[],loadFontFacesTimeout:1e4},longDottedStroke:{lineCap:"round",segment:1,gap:2},dottedStroke:{lineCap:"round",segment:1,gap:2},normalStroke:{lineCap:"round"}};function En(i){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var t=i.length;if(t<2)return"";var r=i[0],n=i[1];if(t===2)return"M".concat(fi(r),"L").concat(fi(n));var s="";for(var c=2,l=t-1;c<l;c++)r=i[c],n=i[c+1],s+=ci(r,n);return e?"M".concat(ci(i[0],i[1]),"Q").concat(fi(i[1])).concat(ci(i[1],i[2]),"T").concat(s).concat(ci(i[t-1],i[0])).concat(ci(i[0],i[1]),"Z"):"M".concat(fi(i[0]),"Q").concat(fi(i[1])).concat(ci(i[1],i[2])).concat(i.length>3?"T":"").concat(s,"L").concat(fi(i[t-1]));}var Mr=/*#__PURE__*/function(){function Mr(e){_classCallCheck(this,Mr);dt(this,"maxImageWidth",vr.pencilEraser.maxImageWidth);dt(this,"maxImageHeight",vr.pencilEraser.maxImageHeight);dt(this,"syncUnitTime",vr.syncOpt.interval);dt(this,"vNodes");dt(this,"drawLayer");dt(this,"fullLayer");dt(this,"workId");dt(this,"isDelete",!1);var t=e.vNodes,r=e.fullLayer,n=e.drawLayer,s=e.workId,c=e.toolsOpt;this.vNodes=t,this.fullLayer=r,this.drawLayer=n,this.workId=s,this.syncUnitTime=c.syncUnitTime||this.syncUnitTime;}return _createClass(Mr,[{key:"baseConsumeResult",get:function get(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions};}},{key:"filterSamePoints",value:function filterSamePoints(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0.01;return e.reduce(function(r,n){var s=r[r.length-1];return(n&&!s||n&&s&&!n.isNear(s,t))&&r.push(n),r;},[]);}/** 设置工作id */},{key:"setWorkId",value:function setWorkId(e){this.workId=e;}},{key:"getWorkId",value:function getWorkId(){return this.workId;}/** 获取工作选项配置 */},{key:"getWorkOptions",value:function getWorkOptions(){return this.workOptions;}/** 设置工作选项配置 */},{key:"setWorkOptions",value:function setWorkOptions(e){var n,s,c;this.workOptions=e,this.syncUnitTime=e.syncUnitTime||this.syncUnitTime;var t=(n=this.workId)==null?void 0:n.toString(),r=t&&((s=this.vNodes)==null?void 0:s.get(t))||void 0;t&&r&&(r.opt=e,(c=this.vNodes)==null||c.setInfo(t,r));}/** 更新服务端同步配置,返回绘制结果 */},{key:"updataOptService",value:function updataOptService(e){var n,s;var t;var r=(n=this.workId)==null?void 0:n.toString();if(r&&e){var c=this.fullLayer.getElementsByName(r)||this.drawLayer&&this.drawLayer.getElementsByName(r)||[];if(c.length!==1)return;var l=c[0],f=e.pos,h=e.zIndex,m=e.scale,u=e.angle,y=e.translate,T={};er(h)&&(T.zIndex=h),f&&(T.pos=[f[0],f[1]]),m&&(T.scale=m),u&&(T.rotate=u),y&&(T.translate=y),l.attr(T);var E=l==null?void 0:l.getBoundingClientRect();return E&&(t=Zt(t,{x:Math.floor(E.x-Mr.SafeBorderPadding),y:Math.floor(E.y-Mr.SafeBorderPadding),w:Math.floor(E.width+Mr.SafeBorderPadding*2),h:Math.floor(E.height+Mr.SafeBorderPadding*2)})),(s=this.vNodes)==null||s.setInfo(r,{rect:t,centerPos:f}),t;}}},{key:"drawEraserlines",value:function drawEraserlines(e,t){var r=e.group,n=e.eraserlines,s=e.pos,c=e.layer,l=c.parent;if(t)try{var h=(c.renderer.glRenderer||c.renderer.canvasRenderer).options.displayRatio,m=r.getBoundingClientRect(),u=m.width*h*c.worldScaling[0],y=m.height*h*c.worldScaling[1];var T=1;(u>this.maxImageWidth||y>this.maxImageHeight)&&(T=Math.min(this.maxImageWidth/u,this.maxImageHeight/y));var E=c.getAttribute("scale");E=[E[0]*T,E[1]*T];var C=c.parent.parent,x=c.getAttribute("translate"),_I32=this.createVmRenderNode("".concat(this.workId,"_bitMapLayer"),C,{offscreen:l.offscreen,width:l.width,height:l.height,contextType:"2d",autoRender:!1,bufferSize:500},E,x),_d29=r.cloneNode(!0);if(!n||!n.length)return;this.addEraserlines(_d29,n,s,!1),_I32.appendChild(_d29);var v=_I32.parent;v.render();var p=_I32.renderer.canvasRenderer,S=p.context;if(!S)return;var A=p.options.displayRatio,R=_d29.getBoundingClientRect(),D={x:R.x,y:R.y,w:R.width,h:R.height},U={x:0,y:0,w:C.width,h:C.height};if(Zi(D,U)===Tr.outside){Lr(_d29,v),C.removeChild(v),this.isDelete=!0;return;}var W=fr(D);W.x=Math.floor(Math.max(D.x,0)),W.y=Math.floor(Math.max(D.y,0)),W.w=Math.min(D.x+D.w,C.width)-W.x,W.h=Math.min(D.y+D.h,C.height)-W.y;var Y=this.getGroupRect(W,A),B=Y.x,N=Y.y,G=Y.w,J=Y.h;var tt=S.getImageData(B,N,G,J);if(this.isTransparentRectByCanvas(tt)){Lr(_d29,v),C.removeChild(v),this.isDelete=!0,tt=null;return;}Lr(r,l);var ut=this.createSpriteNode({imageData:tt,safariRect:W,originRect:D,worldScaling:_I32.worldScaling});ut&&r.append(ut),Lr(_d29,v),C.removeChild(v),l.deleteTexture(tt),tt=null;}catch(f){console.error("[BaseShapeTool] drawEraserlines error:",f);return;}}},{key:"createVmRenderNode",value:function createVmRenderNode(e,t,r,n,s){var c=r.width,l=r.height,f="bitMap-".concat(e),h=t.layer(f,r),m=new mr({anchor:[0.5,0.5],pos:[c*0.5,l*0.5],size:[c,l],name:"viewport",id:e});return m.setAttribute("scale",n),m.setAttribute("translate",s),h.append(m),m;}},{key:"getGroupRect",value:function getGroupRect(e,t){var r=Math.floor(e.x*t),n=Math.floor(e.y*t),s=Math.floor(e.w*t),c=Math.floor(e.h*t);return{x:r,y:n,w:s,h:c};}},{key:"addEraserlines",value:function addEraserlines(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:!0;var _iterator13=_createForOfIteratorHelper(t),_step13;try{for(_iterator13.s();!(_step13=_iterator13.n()).done;){var s=_step13.value;var c=s.thickness,l=s.op;var _iterator14=_createForOfIteratorHelper(l),_step14;try{for(_iterator14.s();!(_step14=_iterator14.n()).done;){var f=_step14.value;var h=f.map(function(E,C){return C%2?E-r[1]:E-r[0];}),m=this.computEraserPoints(h,c),u=En(m,!0),y={pos:[0,0],d:u,fillColor:"rgba(0,0,0,1)"},T=new Mn(y);T.addEventListener("beforerender",function(_ref164){var E=_ref164.detail;var C=E.context;n?C.blendFuncSeparate(C.ZERO,C.ZERO,C.ZERO,C.ZERO):C.globalCompositeOperation="destination-out";}),T.addEventListener("afterrender",function(_ref165){var E=_ref165.detail;var C=E.context;n?C.blendFuncSeparate(C.SRC_ALPHA,C.ONE_MINUS_SRC_ALPHA,C.ONE,C.ONE_MINUS_SRC_ALPHA):C.globalCompositeOperation="source-over";}),e.append(T);}}catch(err){_iterator14.e(err);}finally{_iterator14.f();}}}catch(err){_iterator13.e(err);}finally{_iterator13.f();}}},{key:"isTransparentRectByCanvas",value:function isTransparentRectByCanvas(e){var t=!0;for(var r=0;r<e.data.length;r+=4)if(e.data[r+3]!==0){t=!1;break;}return t;}},{key:"createSpriteNode",value:function createSpriteNode(e){var t=e.imageData,r=e.worldScaling,n=e.safariRect,s=e.originRect;var c;if(typeof OffscreenCanvas=="function"){c=new OffscreenCanvas(t.width,t.height);var m=c.getContext("2d");m&&m.putImageData(t,0,0);}else if((typeof document==="undefined"?"undefined":_typeof(document))<"u"){c=document.createElement("canvas"),c.width=t.width,c.height=t.height;var _m4=c.getContext("2d");_m4&&_m4.putImageData(t,0,0);}if(!c)return console.warn("Failed to create imageEraserBitmap Sprite"),null;var l=[Math.floor(s.w/r[0]),Math.floor(s.h/r[1])],f=[Math.floor((n.x-s.x)/r[0]),Math.floor((n.y-s.y)/r[1]),Math.floor(n.w/r[0]),Math.floor(n.h/r[1])],h={name:"eraserTexture",anchor:[0.5,0.5],pos:[0,0],size:l,texture:c,textureRect:f};return new Yu(h);}},{key:"computEraserPoints",value:function computEraserPoints(e,t){var r=Math.ceil(t/2);return e.length===2?this.computDot(e,r):this.computLine(e,r);}},{key:"computDot",value:function computDot(e,t){var r=new Jt(e[0],e[1]);return Jt.GetDotStroke(r,t,8);}},{key:"computLine",value:function computLine(e,t){var r=[],n=[];var s,c;for(var l=0;l<e.length;l+=2){var f=new Jt(e[l],e[l+1]);var h=void 0;if(l==e.length-2){var m=new Jt(e[l-2],e[l-1]);h=pt.Sub(f,m).uni(),s=f;}else{l===0&&(c=f);var _m5=new Jt(e[l+2],e[l+3]);h=pt.Sub(_m5,f).uni();}if(h){var _m6=pt.Per(h).mul(t);r.push(Jt.Sub(f,_m6)),n.push(Jt.Add(f,_m6));}}if(s&&c){var _l3=Jt.GetSemicircleStroke(s,r[r.length-1],-1,8),_f4=Jt.GetSemicircleStroke(c,n[0],-1,8);return r.concat(_l3,n.reverse(),_f4);}return[];}},{key:"replace",value:function replace(e,t,r){var _this61=this;var s;if(!t){r&&e.append(r);return;}var n=e.getElementsByName(t);if(n.length){var _iterator15=_createForOfIteratorHelper(n),_step15;try{for(_iterator15.s();!(_step15=_iterator15.n()).done;){var c=_step15.value;r?iE(r,c,e):(c.remove(),_pr(c,e.parent));}}catch(err){_iterator15.e(err);}finally{_iterator15.f();}}else r&&e.append(r);this.fullLayer!==this.drawLayer&&(this.fullLayer===e?(s=this.drawLayer)==null||s.getElementsByName(t).forEach(function(l){var f;l.remove(),_pr(l,(f=_this61.drawLayer)==null?void 0:f.parent);}):this.fullLayer.getElementsByName(t).forEach(function(l){l.remove(),_pr(l,_this61.fullLayer.parent);}));}},{key:"removeDrawCountNodes",value:function removeDrawCountNodes(e,t){var r=[];e.getElementsByName(this.workId).forEach(function(n){n.id&&t&&Number(n.id)<t&&r.push(n);});for(var _i2=0,_r3=r;_i2<_r3.length;_i2++){var n=_r3[_i2];n.remove(),_pr(n,e.parent);}}}],[{key:"updateNodeOpt",value:function updateNodeOpt(e){var d;var t=e.node,r=e.opt,n=e.vNodes,s=e.willSerializeData,c=e.targetNode,l=r.zIndex,f=r.translate,h=r.angle,m=r.originPoint,u=r.scenePoint,y=r.scale,T=r.pointMap,E=r.thickness;var C;var x=c&&fr(c)||n.get(t.name);if(!x)return;er(l)&&(t.setAttribute("zIndex",l),x.opt.zIndex=l);var I=t.parent;if(I){if(m&&y&&c){var v=[x.op[0],x.op[1]];Ll(x.op,u,y,f);var p=[x.op[0],x.op[1]],S=[p[0]-v[0],p[1]-v[1]];if(x.centerPos=[x.centerPos[0]+S[0],x.centerPos[1]+S[1]],x.opt.translate=void 0,x.opt.scale=void 0,x.opt.eraserlines)for(var A=0;A<x.opt.eraserlines.length;A++){var _x$opt$eraserlines$A=x.opt.eraserlines[A],R=_x$opt$eraserlines$A.op,D=_x$opt$eraserlines$A.thickness;x.opt.eraserlines[A].thickness=Math.round(D*Math.max(y[0],y[1]));for(var U=0;U<R.length;U++)Rl(R[U],u,y,f);}}else if(f){if(t.setAttribute("translate",f),x.opt.translate=f,c){var _v6=[f[0]*I.worldScaling[0],f[1]*I.worldScaling[1]];C=Vi(x.rect,_v6),x.rect=C;}else{var _v7=Mr.getRectFromLayer(I,t.name);x.rect=_v7||x.rect;}}else if(er(h))if(t.setAttribute("rotate",h),x.opt.rotate=h,c)C=Hh(x.rect,h),x.rect=C;else{var _v8=Mr.getRectFromLayer(I,t.name);x.rect=_v8||x.rect;}if(T){var _v9=T.get(t.name);if(_v9)for(var _p10=0,_S10=0;_p10<x.op.length;_p10+=3,_S10++)x.op[_p10]=_v9[_S10][0],x.op[_p10+1]=_v9[_S10][1];}if(E&&(d=x==null?void 0:x.opt)!=null&&d.thickness&&(x.opt.thickness=E),s&&!(m&&y&&c)){if(f){var _v10=x.op.map(function(p,S){var A=S%3;return A===0?p+f[0]:A===1?p+f[1]:p;});if(x.op=_v10,x.centerPos=[x.centerPos[0]+f[0],x.centerPos[1]+f[1]],x!=null&&x.opt&&(x.opt.translate=void 0),x.opt.eraserlines)for(var _p11=0;_p11<x.opt.eraserlines.length;_p11++){var _S11=x.opt.eraserlines[_p11].op;for(var _A7=0;_A7<_S11.length;_A7++){var _R3=_S11[_A7].map(function(D,U){return U%2?D+f[1]:D+f[0];});x.opt.eraserlines[_p11].op[_A7]=_R3;}}}else if(er(h)){var _v11=x.op;if(JA(_v11,x.centerPos,h),x.op=_v11,x!=null&&x.opt&&(x.opt.rotate=void 0),x.opt.eraserlines)for(var _p12=0;_p12<x.opt.eraserlines.length;_p12++){var _S12=x.opt.eraserlines[_p12].op;for(var _A8=0;_A8<_S12.length;_A8++)QA(_S12[_A8],x.centerPos,h);}}}x&&n.setInfo(t.name,x);}}},{key:"getCenterPos",value:function getCenterPos(e,t){var r=t.worldPosition,n=t.worldScaling;return[(e.x+e.w/2-r[0])/n[0],(e.y+e.h/2-r[1])/n[1]];}},{key:"getRectFromLayer",value:function getRectFromLayer(e,t){var r=e.getElementsByName(t)[0];if(r){var n=r.getBoundingClientRect();return{x:Math.floor(n.x-Mr.SafeBorderPadding),y:Math.floor(n.y-Mr.SafeBorderPadding),w:Math.floor(n.width+Mr.SafeBorderPadding*2),h:Math.floor(n.height+Mr.SafeBorderPadding*2)};}}},{key:"isWillRefresh",value:function isWillRefresh(e){var t=e.toolsType,r=e.opt,n=e.node,s=e.updateOpt,c=e.willSerializeData;return!!(c&&(s.angle||s.translate)||s.thickness&&r.thickness&&r.thickness!==s.thickness||s.strokeType&&r.strokeType&&r.strokeType!==s.strokeType||s.originPoint&&s.scenePoint&&s.scale||s.pointMap&&s.pointMap.has(n.name)||t===Tt.Text&&(s.fontSize||s.translate||s.textInfos&&s.textInfos.get(n.name))||t===Tt.Image&&(s.angle||s.translate||s.scale||s.strokeColor&&s.type===cl.Iconify)||t===s.toolsType&&s.willRefresh||r.eraserlines&&r.eraserlines.length&&(s.strokeColor||s.fillColor));}}]);}();dt(Mr,"SafeBorderPadding",10);var $t=Mr;var Tl=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 Cl={exports:{}};Cl.exports;(function(i){var e=function(){var t=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",s={};function c(f,h){if(!s[f]){s[f]={};for(var m=0;m<f.length;m++)s[f][f.charAt(m)]=m;}return s[f][h];}var l={compressToBase64:function compressToBase64(f){if(f==null)return"";var h=l._compress(f,6,function(m){return r.charAt(m);});switch(h.length%4){default:case 0:return h;case 1:return h+"===";case 2:return h+"==";case 3:return h+"=";}},decompressFromBase64:function decompressFromBase64(f){return f==null?"":f==""?null:l._decompress(f.length,32,function(h){return c(r,f.charAt(h));});},compressToUTF16:function compressToUTF16(f){return f==null?"":l._compress(f,15,function(h){return t(h+32);})+" ";},decompressFromUTF16:function decompressFromUTF16(f){return f==null?"":f==""?null:l._decompress(f.length,16384,function(h){return f.charCodeAt(h)-32;});},//compress into uint8array (UCS-2 big endian format)
400
400
  compressToUint8Array:function compressToUint8Array(f){for(var h=l.compress(f),m=new Uint8Array(h.length*2),u=0,y=h.length;u<y;u++){var T=h.charCodeAt(u);m[u*2]=T>>>8,m[u*2+1]=T%256;}return m;},//decompress from uint8array (UCS-2 big endian format)
401
401
  decompressFromUint8Array:function decompressFromUint8Array(f){if(f==null)return l.decompress(f);for(var h=new Array(f.length/2),m=0,u=h.length;m<u;m++)h[m]=f[m*2]*256+f[m*2+1];var y=[];return h.forEach(function(T){y.push(t(T));}),l.decompress(y.join(""));},//compress into a string that is already URI encoded
402
402
  compressToEncodedURIComponent:function compressToEncodedURIComponent(f){return f==null?"":l._compress(f,6,function(h){return n.charAt(h);});},//decompress from an output of compressToEncodedURIComponent
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-kFvKM_hB.js");exports.ActiveContainerType=e.ActiveContainerType;exports.ApplianceMultiPlugin=e.ApplianceMultiPlugin;exports.ApplianceNames=e.ApplianceNames;exports.ApplianceSigleWrapper=e.ApplianceSigleWrapper;exports.ApplianceSinglePlugin=e.ApplianceSinglePlugin;exports.AutoDrawPlugin=e.AutoDrawPlugin;exports.ECanvasShowType=e.ECanvasShowType;exports.EDataType=e.EDataType;exports.EForceStopReason=e.EForceStopReason;exports.EImageType=e.EImageType;exports.EMatrixrRelationType=e.EMatrixrRelationType;exports.EOperationType=e.EOperationType;exports.EPostMessageType=e.EPostMessageType;exports.ERenderFilterType=e.ERenderFilterType;exports.EScaleType=e.EScaleType;exports.EStrokeType=e.EStrokeType;exports.EToolsKey=e.EToolsKey;exports.ElayerType=e.ElayerType;exports.EmitEventType=e.EmitEventType;exports.EventMessageType=e.EventMessageType;exports.EvevtWorkState=e.EvevtWorkState;exports.EvevtWorkType=e.EvevtWorkType;exports.InternalMsgEmitterType=e.InternalMsgEmitterType;exports.Plugin=e.Plugin;exports.ShapeType=e.ShapeType;exports.fullWorkerUrl=e.fullWorker;exports.subWorkerUrl=e.subWorker;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-D4v0aovE.js");exports.ActiveContainerType=e.ActiveContainerType;exports.ApplianceMultiPlugin=e.ApplianceMultiPlugin;exports.ApplianceNames=e.ApplianceNames;exports.ApplianceSigleWrapper=e.ApplianceSigleWrapper;exports.ApplianceSinglePlugin=e.ApplianceSinglePlugin;exports.AutoDrawPlugin=e.AutoDrawPlugin;exports.ECanvasShowType=e.ECanvasShowType;exports.EDataType=e.EDataType;exports.EForceStopReason=e.EForceStopReason;exports.EImageType=e.EImageType;exports.EMatrixrRelationType=e.EMatrixrRelationType;exports.EOperationType=e.EOperationType;exports.EPostMessageType=e.EPostMessageType;exports.ERenderFilterType=e.ERenderFilterType;exports.EScaleType=e.EScaleType;exports.EStrokeType=e.EStrokeType;exports.EToolsKey=e.EToolsKey;exports.ElayerType=e.ElayerType;exports.EmitEventType=e.EmitEventType;exports.EventMessageType=e.EventMessageType;exports.EvevtWorkState=e.EvevtWorkState;exports.EvevtWorkType=e.EvevtWorkType;exports.InternalMsgEmitterType=e.InternalMsgEmitterType;exports.Plugin=e.Plugin;exports.ShapeType=e.ShapeType;exports.fullWorkerUrl=e.fullWorker;exports.subWorkerUrl=e.subWorker;
@@ -1,4 +1,4 @@
1
- import { ae as s, a8 as p, ab as r, aa as t, a9 as l, am as n, U as i, o, af as E, l as y, E as T, aj as g, n as c, ak as u, m as v, t as S, k, ah as m, a2 as A, ag as M, q as P, ai as W, ad as f, al as h, ac as R, a6 as U, a7 as b } from "./index-D0ikwklZ.mjs";
1
+ import { ae as s, a8 as p, ab as r, aa as t, a9 as l, am as n, U as i, o, af as E, l as y, E as T, aj as g, n as c, ak as u, m as v, t as S, k, ah as m, a2 as A, ag as M, q as P, ai as W, ad as f, al as h, ac as R, a6 as U, a7 as b } from "./index-CkDrr8C-.mjs";
2
2
  export {
3
3
  s as ActiveContainerType,
4
4
  p as ApplianceMultiPlugin,
@@ -396,7 +396,7 @@ _inherits(l,_r$default22);return _createClass(l,[{key:"texture",get:function get
396
396
  h=="length"||// Node.js 0.10 has enumerable non-index properties on buffers.
397
397
  n&&(h=="offset"||h=="parent")||// PhantomJS 2 has enumerable non-index properties on typed arrays.
398
398
  s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||// Skip index properties.
399
- AT(h,f)))&&l.push(h);return l;}var th=RT,bT=Object.prototype;function DT(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||bT;return i===t;}var vl=DT;function NT(i,e){return function(t){return i(e(t));};}var eh=NT,BT=eh,WT=BT(Object.keys,Object),FT=WT,UT=vl,YT=FT,XT=Object.prototype,zT=XT.hasOwnProperty;function $T(i){if(!UT(i))return YT(i);var e=[];for(var t in Object(i))zT.call(i,t)&&t!="constructor"&&e.push(t);return e;}var jT=$T,GT=ju,kT=qu;function HT(i){return i!=null&&kT(i.length)&&!GT(i);}var gl=HT,KT=th,VT=jT,ZT=gl;function JT(i){return ZT(i)?KT(i):VT(i);}var ml=JT,QT=yo,qT=ml;function _T(i,e){return i&&QT(e,qT(e),i);}var tC=_T;function eC(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e;}var rC=eC,nC=Qi,iC=vl,sC=rC,oC=Object.prototype,aC=oC.hasOwnProperty;function lC(i){if(!nC(i))return sC(i);var e=iC(i),t=[];for(var r in i)r=="constructor"&&(e||!aC.call(i,r))||t.push(r);return t;}var fC=lC,cC=th,uC=fC,hC=gl;function dC(i){return hC(i)?cC(i,!0):uC(i);}var yl=dC,pC=yo,vC=yl;function gC(i,e){return i&&pC(e,vC(e),i);}var mC=gC,ro={exports:{}};ro.exports;(function(i,e){var t=_r,r=e&&!e.nodeType&&e,n=r&&!0&&i&&!i.nodeType&&i,s=n&&n.exports===r,c=s?t.Buffer:void 0,l=c?c.allocUnsafe:void 0;function f(h,m){if(m)return h.slice();var u=h.length,y=l?l(u):new h.constructor(u);return h.copy(y),y;}i.exports=f;})(ro,ro.exports);var yC=ro.exports;function PC(i,e){var t=-1,r=i.length;for(e||(e=Array(r));++t<r;)e[t]=i[t];return e;}var SC=PC;function xC(i,e){for(var t=-1,r=i==null?0:i.length,n=0,s=[];++t<r;){var c=i[t];e(c,t,i)&&(s[n++]=c);}return s;}var rh=xC;function TC(){return[];}var nh=TC,CC=rh,IC=nh,OC=Object.prototype,wC=OC.propertyIsEnumerable,qc=Object.getOwnPropertySymbols,AC=qc?function(i){return i==null?[]:(i=Object(i),CC(qc(i),function(e){return wC.call(i,e);}));}:IC,Pl=AC,EC=yo,MC=Pl;function LC(i,e){return EC(i,MC(i),e);}var RC=LC;function bC(i,e){for(var t=-1,r=e.length,n=i.length;++t<r;)i[n+t]=e[t];return i;}var Sl=bC,DC=eh,NC=DC(Object.getPrototypeOf,Object),ih=NC,BC=Sl,WC=ih,FC=Pl,UC=nh,YC=Object.getOwnPropertySymbols,XC=YC?function(i){for(var e=[];i;)BC(e,FC(i)),i=WC(i);return e;}:UC,sh=XC,zC=yo,$C=sh;function jC(i,e){return zC(i,$C(i),e);}var GC=jC,kC=Sl,HC=qi;function KC(i,e,t){var r=e(i);return HC(i)?r:kC(r,t(i));}var oh=KC,VC=oh,ZC=Pl,JC=ml;function QC(i){return VC(i,JC,ZC);}var ah=QC,qC=oh,_C=sh,tI=yl;function eI(i){return qC(i,tI,_C);}var rI=eI,nI=$n,iI=_r,sI=nI(iI,"DataView"),oI=sI,aI=$n,lI=_r,fI=aI(lI,"Promise"),cI=fI,uI=$n,hI=_r,dI=uI(hI,"Set"),lh=dI,pI=$n,vI=_r,gI=pI(vI,"WeakMap"),mI=gI,rl=oI,nl=hl,il=cI,sl=lh,ol=mI,fh=Pi,Ii=Gu,_c="[object Map]",yI="[object Object]",tu="[object Promise]",eu="[object Set]",ru="[object WeakMap]",nu="[object DataView]",PI=Ii(rl),SI=Ii(nl),xI=Ii(il),TI=Ii(sl),CI=Ii(ol),zn=fh;(rl&&zn(new rl(new ArrayBuffer(1)))!=nu||nl&&zn(new nl())!=_c||il&&zn(il.resolve())!=tu||sl&&zn(new sl())!=eu||ol&&zn(new ol())!=ru)&&(zn=function zn(i){var e=fh(i),t=e==yI?i.constructor:void 0,r=t?Ii(t):"";if(r)switch(r){case PI:return nu;case SI:return _c;case xI:return tu;case TI:return eu;case CI:return ru;}return e;});var So=zn,II=Object.prototype,OI=II.hasOwnProperty;function wI(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&OI.call(i,"index")&&(t.index=i.index,t.input=i.input),t;}var AI=wI,EI=_r,MI=EI.Uint8Array,ch=MI,iu=ch;function LI(i){var e=new i.constructor(i.byteLength);return new iu(e).set(new iu(i)),e;}var xl=LI,RI=xl;function bI(i,e){var t=e?RI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength);}var DI=bI,NI=/\w*$/;function BI(i){var e=new i.constructor(i.source,NI.exec(i));return e.lastIndex=i.lastIndex,e;}var WI=BI,su=Ji,ou=su?su.prototype:void 0,au=ou?ou.valueOf:void 0;function FI(i){return au?Object(au.call(i)):{};}var UI=FI,YI=xl;function XI(i,e){var t=e?YI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length);}var zI=XI,$I=xl,jI=DI,GI=WI,kI=UI,HI=zI,KI="[object Boolean]",VI="[object Date]",ZI="[object Map]",JI="[object Number]",QI="[object RegExp]",qI="[object Set]",_I="[object String]",tO="[object Symbol]",eO="[object ArrayBuffer]",rO="[object DataView]",nO="[object Float32Array]",iO="[object Float64Array]",sO="[object Int8Array]",oO="[object Int16Array]",aO="[object Int32Array]",lO="[object Uint8Array]",fO="[object Uint8ClampedArray]",cO="[object Uint16Array]",uO="[object Uint32Array]";function hO(i,e,t){var r=i.constructor;switch(e){case eO:return $I(i);case KI:case VI:return new r(+i);case rO:return jI(i,t);case nO:case iO:case sO:case oO:case aO:case lO:case fO:case cO:case uO:return HI(i,t);case ZI:return new r();case JI:case _I:return new r(i);case QI:return GI(i);case qI:return new r();case tO:return kI(i);}}var dO=hO,pO=Qi,lu=Object.create,vO=/* @__PURE__ */function(){function i(){}return function(e){if(!pO(e))return{};if(lu)return lu(e);i.prototype=e;var t=new i();return i.prototype=void 0,t;};}(),gO=vO,mO=gO,yO=ih,PO=vl;function SO(i){return typeof i.constructor=="function"&&!PO(i)?mO(yO(i)):{};}var xO=SO,TO=So,CO=pn,IO="[object Map]";function OO(i){return CO(i)&&TO(i)==IO;}var wO=OO,AO=wO,EO=Po,fu=pl,cu=fu&&fu.isMap,MO=cu?EO(cu):AO,LO=MO,RO=So,bO=pn,DO="[object Set]";function NO(i){return bO(i)&&RO(i)==DO;}var BO=NO,WO=BO,FO=Po,uu=pl,hu=uu&&uu.isSet,UO=hu?FO(hu):WO,uh=UO,YO=/* @__PURE__ */Ln(uh),XO=Hu,zO=hx,$O=Zu,jO=tC,GO=mC,kO=yC,HO=SC,KO=RC,VO=GC,ZO=ah,JO=rI,QO=So,qO=AI,_O=dO,t2=xO,e2=qi,r2=dl,n2=LO,i2=Qi,s2=uh,o2=ml,a2=yl,l2=1,f2=2,c2=4,hh="[object Arguments]",u2="[object Array]",h2="[object Boolean]",d2="[object Date]",p2="[object Error]",dh="[object Function]",v2="[object GeneratorFunction]",g2="[object Map]",m2="[object Number]",ph="[object Object]",y2="[object RegExp]",P2="[object Set]",S2="[object String]",x2="[object Symbol]",T2="[object WeakMap]",C2="[object ArrayBuffer]",I2="[object DataView]",O2="[object Float32Array]",w2="[object Float64Array]",A2="[object Int8Array]",E2="[object Int16Array]",M2="[object Int32Array]",L2="[object Uint8Array]",R2="[object Uint8ClampedArray]",b2="[object Uint16Array]",D2="[object Uint32Array]",Ye={};Ye[hh]=Ye[u2]=Ye[C2]=Ye[I2]=Ye[h2]=Ye[d2]=Ye[O2]=Ye[w2]=Ye[A2]=Ye[E2]=Ye[M2]=Ye[g2]=Ye[m2]=Ye[ph]=Ye[y2]=Ye[P2]=Ye[S2]=Ye[x2]=Ye[L2]=Ye[R2]=Ye[b2]=Ye[D2]=!0;Ye[p2]=Ye[dh]=Ye[T2]=!1;function qs(i,e,t,r,n,s){var c,l=e&l2,f=e&f2,h=e&c2;if(t&&(c=n?t(i,r,n,s):t(i)),c!==void 0)return c;if(!i2(i))return i;var m=e2(i);if(m){if(c=qO(i),!l)return HO(i,c);}else{var u=QO(i),y=u==dh||u==v2;if(r2(i))return kO(i,l);if(u==ph||u==hh||y&&!n){if(c=f||y?{}:t2(i),!l)return f?VO(i,GO(c,i)):KO(i,jO(c,i));}else{if(!Ye[u])return n?i:{};c=_O(i,u,l);}}s||(s=new XO());var T=s.get(i);if(T)return T;s.set(i,c),s2(i)?i.forEach(function(x){c.add(qs(x,e,t,x,i,s));}):n2(i)&&i.forEach(function(x,I){c.set(I,qs(x,e,t,I,i,s));});var E=h?f?JO:ZO:f?a2:o2,C=m?void 0:E(i);return zO(C||i,function(x,I){C&&(I=x,x=i[I]),$O(c,I,qs(x,e,t,I,i,s));}),c;}var N2=qs,B2=N2,W2=1,F2=4;function U2(i){return B2(i,W2|F2);}var Y2=U2,fr=/* @__PURE__ */Ln(Y2);var vh="1.1.22-beta.12",X2="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var i=window.__netlessUA||"";i+=" ".concat(X2,"@").concat(vh),window.__netlessUA=i;}var vr={useWorker:"auto",useSimple:!1,syncOpt:{interval:300,smoothSync:!0},cursor:{enable:!0,expirationTime:5e3,moveDelayTime:100},bufferSize:{full:2e4,sub:600},bezier:{enable:!0,maxDrawCount:1/0,combineUnitTime:300},pencilEraser:{useBitMap:!0,maxImageWidth:1920,maxImageHeight:1920,maxCombineTime:500},strokeWidth:{min:1,max:10},textEditor:{showFloatBar:!0,canSelectorSwitch:!0,rightBoundBreak:!1,extendFontFaces:[],loadFontFacesTimeout:1e4},longDottedStroke:{lineCap:"round",segment:1,gap:2},dottedStroke:{lineCap:"round",segment:1,gap:2},normalStroke:{lineCap:"round"}};function En(i){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var t=i.length;if(t<2)return"";var r=i[0],n=i[1];if(t===2)return"M".concat(fi(r),"L").concat(fi(n));var s="";for(var c=2,l=t-1;c<l;c++)r=i[c],n=i[c+1],s+=ci(r,n);return e?"M".concat(ci(i[0],i[1]),"Q").concat(fi(i[1])).concat(ci(i[1],i[2]),"T").concat(s).concat(ci(i[t-1],i[0])).concat(ci(i[0],i[1]),"Z"):"M".concat(fi(i[0]),"Q").concat(fi(i[1])).concat(ci(i[1],i[2])).concat(i.length>3?"T":"").concat(s,"L").concat(fi(i[t-1]));}var Mr=/*#__PURE__*/function(){function Mr(e){_classCallCheck(this,Mr);dt(this,"maxImageWidth",vr.pencilEraser.maxImageWidth);dt(this,"maxImageHeight",vr.pencilEraser.maxImageHeight);dt(this,"syncUnitTime",vr.syncOpt.interval);dt(this,"vNodes");dt(this,"drawLayer");dt(this,"fullLayer");dt(this,"workId");dt(this,"isDelete",!1);var t=e.vNodes,r=e.fullLayer,n=e.drawLayer,s=e.workId,c=e.toolsOpt;this.vNodes=t,this.fullLayer=r,this.drawLayer=n,this.workId=s,this.syncUnitTime=c.syncUnitTime||this.syncUnitTime;}return _createClass(Mr,[{key:"baseConsumeResult",get:function get(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions};}},{key:"filterSamePoints",value:function filterSamePoints(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0.01;return e.reduce(function(r,n){var s=r[r.length-1];return(n&&!s||n&&s&&!n.isNear(s,t))&&r.push(n),r;},[]);}/** 设置工作id */},{key:"setWorkId",value:function setWorkId(e){this.workId=e;}},{key:"getWorkId",value:function getWorkId(){return this.workId;}/** 获取工作选项配置 */},{key:"getWorkOptions",value:function getWorkOptions(){return this.workOptions;}/** 设置工作选项配置 */},{key:"setWorkOptions",value:function setWorkOptions(e){var n,s,c;this.workOptions=e,this.syncUnitTime=e.syncUnitTime||this.syncUnitTime;var t=(n=this.workId)==null?void 0:n.toString(),r=t&&((s=this.vNodes)==null?void 0:s.get(t))||void 0;t&&r&&(r.opt=e,(c=this.vNodes)==null||c.setInfo(t,r));}/** 更新服务端同步配置,返回绘制结果 */},{key:"updataOptService",value:function updataOptService(e){var n,s;var t;var r=(n=this.workId)==null?void 0:n.toString();if(r&&e){var c=this.fullLayer.getElementsByName(r)||this.drawLayer&&this.drawLayer.getElementsByName(r)||[];if(c.length!==1)return;var l=c[0],f=e.pos,h=e.zIndex,m=e.scale,u=e.angle,y=e.translate,T={};er(h)&&(T.zIndex=h),f&&(T.pos=[f[0],f[1]]),m&&(T.scale=m),u&&(T.rotate=u),y&&(T.translate=y),l.attr(T);var E=l==null?void 0:l.getBoundingClientRect();return E&&(t=Zt(t,{x:Math.floor(E.x-Mr.SafeBorderPadding),y:Math.floor(E.y-Mr.SafeBorderPadding),w:Math.floor(E.width+Mr.SafeBorderPadding*2),h:Math.floor(E.height+Mr.SafeBorderPadding*2)})),(s=this.vNodes)==null||s.setInfo(r,{rect:t,centerPos:f}),t;}}},{key:"drawEraserlines",value:function drawEraserlines(e,t){var r=e.group,n=e.eraserlines,s=e.pos,c=e.layer,l=c.parent;if(t)try{var h=(c.renderer.glRenderer||c.renderer.canvasRenderer).options.displayRatio,m=r.getBoundingClientRect(),u=m.width*h*c.worldScaling[0],y=m.height*h*c.worldScaling[1];var T=1;(u>this.maxImageWidth||y>this.maxImageHeight)&&(T=Math.min(this.maxImageWidth/u,this.maxImageHeight/y));var E=c.getAttribute("scale");E=[E[0]*T,E[1]*T];var C=c.parent.parent,x=c.getAttribute("translate"),_I32=this.createVmRenderNode("".concat(this.workId,"_bitMapLayer"),C,{offscreen:l.offscreen,width:l.width,height:l.height,contextType:"2d",autoRender:!1,bufferSize:500},E,x),_d29=r.cloneNode(!0);if(!n||!n.length)return;this.addEraserlines(_d29,n,s,!1),_I32.appendChild(_d29);var v=_I32.parent;v.render();var p=_I32.renderer.canvasRenderer,S=p.context;if(!S)return;var A=p.options.displayRatio,R=_d29.getBoundingClientRect(),D={x:R.x,y:R.y,w:R.width,h:R.height},U={x:0,y:0,w:C.width,h:C.height};if(Zi(D,U)===Tr.outside){Lr(_d29,v),C.removeChild(v),this.isDelete=!0;return;}var W=fr(D);W.x=Math.floor(Math.max(D.x,0)),W.y=Math.floor(Math.max(D.y,0)),W.w=Math.min(D.x+D.w,C.width)-W.x,W.h=Math.min(D.y+D.h,C.height)-W.y;var Y=this.getGroupRect(W,A),B=Y.x,N=Y.y,G=Y.w,J=Y.h;var tt=S.getImageData(B,N,G,J);if(this.isTransparentRectByCanvas(tt)){Lr(_d29,v),C.removeChild(v),this.isDelete=!0,tt=null;return;}Lr(r,l);var ut=this.createSpriteNode({imageData:tt,safariRect:W,originRect:D,worldScaling:_I32.worldScaling});ut&&r.append(ut),Lr(_d29,v),C.removeChild(v),l.deleteTexture(tt),tt=null;}catch(f){console.error("[BaseShapeTool] drawEraserlines error:",f);return;}}},{key:"createVmRenderNode",value:function createVmRenderNode(e,t,r,n,s){var c=r.width,l=r.height,f="bitMap-".concat(e),h=t.layer(f,r),m=new mr({anchor:[0.5,0.5],pos:[c*0.5,l*0.5],size:[c,l],name:"viewport",id:e});return m.setAttribute("scale",n),m.setAttribute("translate",s),h.append(m),m;}},{key:"getGroupRect",value:function getGroupRect(e,t){var r=Math.floor(e.x*t),n=Math.floor(e.y*t),s=Math.floor(e.w*t),c=Math.floor(e.h*t);return{x:r,y:n,w:s,h:c};}},{key:"addEraserlines",value:function addEraserlines(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:!0;var _iterator13=_createForOfIteratorHelper(t),_step13;try{for(_iterator13.s();!(_step13=_iterator13.n()).done;){var s=_step13.value;var c=s.thickness,l=s.op;var _iterator14=_createForOfIteratorHelper(l),_step14;try{for(_iterator14.s();!(_step14=_iterator14.n()).done;){var f=_step14.value;var h=f.map(function(E,C){return C%2?E-r[1]:E-r[0];}),m=this.computEraserPoints(h,c),u=En(m,!0),y={pos:[0,0],d:u,fillColor:"rgba(0,0,0,1)"},T=new Mn(y);T.addEventListener("beforerender",function(_ref164){var E=_ref164.detail;var C=E.context;n?C.blendFuncSeparate(C.ZERO,C.ZERO,C.ZERO,C.ZERO):C.globalCompositeOperation="destination-out";}),T.addEventListener("afterrender",function(_ref165){var E=_ref165.detail;var C=E.context;n?C.blendFuncSeparate(C.SRC_ALPHA,C.ONE_MINUS_SRC_ALPHA,C.ONE,C.ONE_MINUS_SRC_ALPHA):C.globalCompositeOperation="source-over";}),e.append(T);}}catch(err){_iterator14.e(err);}finally{_iterator14.f();}}}catch(err){_iterator13.e(err);}finally{_iterator13.f();}}},{key:"isTransparentRectByCanvas",value:function isTransparentRectByCanvas(e){var t=!0;for(var r=0;r<e.data.length;r+=4)if(e.data[r+3]!==0){t=!1;break;}return t;}},{key:"createSpriteNode",value:function createSpriteNode(e){var t=e.imageData,r=e.worldScaling,n=e.safariRect,s=e.originRect;var c;if(typeof OffscreenCanvas=="function"){c=new OffscreenCanvas(t.width,t.height);var m=c.getContext("2d");m&&m.putImageData(t,0,0);}else if((typeof document==="undefined"?"undefined":_typeof(document))<"u"){c=document.createElement("canvas"),c.width=t.width,c.height=t.height;var _m4=c.getContext("2d");_m4&&_m4.putImageData(t,0,0);}if(!c)return console.warn("Failed to create imageEraserBitmap Sprite"),null;var l=[Math.floor(s.w/r[0]),Math.floor(s.h/r[1])],f=[Math.floor((n.x-s.x)/r[0]),Math.floor((n.y-s.y)/r[1]),Math.floor(n.w/r[0]),Math.floor(n.h/r[1])],h={name:"eraserTexture",anchor:[0.5,0.5],pos:[0,0],size:l,texture:c,textureRect:f};return new Yu(h);}},{key:"computEraserPoints",value:function computEraserPoints(e,t){var r=Math.ceil(t/2);return e.length===2?this.computDot(e,r):this.computLine(e,r);}},{key:"computDot",value:function computDot(e,t){var r=new Jt(e[0],e[1]);return Jt.GetDotStroke(r,t,8);}},{key:"computLine",value:function computLine(e,t){var r=[],n=[];var s,c;for(var l=0;l<e.length;l+=2){var f=new Jt(e[l],e[l+1]);var h=void 0;if(l==e.length-2){var m=new Jt(e[l-2],e[l-1]);h=pt.Sub(f,m).uni(),s=f;}else{l===0&&(c=f);var _m5=new Jt(e[l+2],e[l+3]);h=pt.Sub(_m5,f).uni();}if(h){var _m6=pt.Per(h).mul(t);r.push(Jt.Sub(f,_m6)),n.push(Jt.Add(f,_m6));}}if(s&&c){var _l3=Jt.GetSemicircleStroke(s,r[r.length-1],-1,8),_f4=Jt.GetSemicircleStroke(c,n[0],-1,8);return r.concat(_l3,n.reverse(),_f4);}return[];}},{key:"replace",value:function replace(e,t,r){var _this61=this;var s;if(!t){r&&e.append(r);return;}var n=e.getElementsByName(t);if(n.length){var _iterator15=_createForOfIteratorHelper(n),_step15;try{for(_iterator15.s();!(_step15=_iterator15.n()).done;){var c=_step15.value;r?iE(r,c,e):(c.remove(),_pr(c,e.parent));}}catch(err){_iterator15.e(err);}finally{_iterator15.f();}}else r&&e.append(r);this.fullLayer!==this.drawLayer&&(this.fullLayer===e?(s=this.drawLayer)==null||s.getElementsByName(t).forEach(function(l){var f;l.remove(),_pr(l,(f=_this61.drawLayer)==null?void 0:f.parent);}):this.fullLayer.getElementsByName(t).forEach(function(l){l.remove(),_pr(l,_this61.fullLayer.parent);}));}},{key:"removeDrawCountNodes",value:function removeDrawCountNodes(e,t){var r=[];e.getElementsByName(this.workId).forEach(function(n){n.id&&t&&Number(n.id)<t&&r.push(n);});for(var _i2=0,_r3=r;_i2<_r3.length;_i2++){var n=_r3[_i2];n.remove(),_pr(n,e.parent);}}}],[{key:"updateNodeOpt",value:function updateNodeOpt(e){var d;var t=e.node,r=e.opt,n=e.vNodes,s=e.willSerializeData,c=e.targetNode,l=r.zIndex,f=r.translate,h=r.angle,m=r.originPoint,u=r.scenePoint,y=r.scale,T=r.pointMap,E=r.thickness;var C;var x=c&&fr(c)||n.get(t.name);if(!x)return;er(l)&&(t.setAttribute("zIndex",l),x.opt.zIndex=l);var I=t.parent;if(I){if(m&&y&&c){var v=[x.op[0],x.op[1]];Ll(x.op,u,y,f);var p=[x.op[0],x.op[1]],S=[p[0]-v[0],p[1]-v[1]];if(x.centerPos=[x.centerPos[0]+S[0],x.centerPos[1]+S[1]],x.opt.translate=void 0,x.opt.scale=void 0,x.opt.eraserlines)for(var A=0;A<x.opt.eraserlines.length;A++){var _x$opt$eraserlines$A=x.opt.eraserlines[A],R=_x$opt$eraserlines$A.op,D=_x$opt$eraserlines$A.thickness;x.opt.eraserlines[A].thickness=Math.round(D*Math.max(y[0],y[1]));for(var U=0;U<R.length;U++)Rl(R[U],u,y,f);}}else if(f){if(t.setAttribute("translate",f),x.opt.translate=f,c){var _v6=[f[0]*I.worldScaling[0],f[1]*I.worldScaling[1]];C=Vi(x.rect,_v6),x.rect=C;}else{var _v7=Mr.getRectFromLayer(I,t.name);x.rect=_v7||x.rect;}}else if(er(h))if(t.setAttribute("rotate",h),x.opt.rotate=h,c)C=Hh(x.rect,h),x.rect=C;else{var _v8=Mr.getRectFromLayer(I,t.name);x.rect=_v8||x.rect;}if(T){var _v9=T.get(t.name);if(_v9)for(var _p10=0,_S10=0;_p10<x.op.length;_p10+=3,_S10++)x.op[_p10]=_v9[_S10][0],x.op[_p10+1]=_v9[_S10][1];}if(E&&(d=x==null?void 0:x.opt)!=null&&d.thickness&&(x.opt.thickness=E),s&&!(m&&y&&c)){if(f){var _v10=x.op.map(function(p,S){var A=S%3;return A===0?p+f[0]:A===1?p+f[1]:p;});if(x.op=_v10,x.centerPos=[x.centerPos[0]+f[0],x.centerPos[1]+f[1]],x!=null&&x.opt&&(x.opt.translate=void 0),x.opt.eraserlines)for(var _p11=0;_p11<x.opt.eraserlines.length;_p11++){var _S11=x.opt.eraserlines[_p11].op;for(var _A7=0;_A7<_S11.length;_A7++){var _R3=_S11[_A7].map(function(D,U){return U%2?D+f[1]:D+f[0];});x.opt.eraserlines[_p11].op[_A7]=_R3;}}}else if(er(h)){var _v11=x.op;if(JA(_v11,x.centerPos,h),x.op=_v11,x!=null&&x.opt&&(x.opt.rotate=void 0),x.opt.eraserlines)for(var _p12=0;_p12<x.opt.eraserlines.length;_p12++){var _S12=x.opt.eraserlines[_p12].op;for(var _A8=0;_A8<_S12.length;_A8++)QA(_S12[_A8],x.centerPos,h);}}}x&&n.setInfo(t.name,x);}}},{key:"getCenterPos",value:function getCenterPos(e,t){var r=t.worldPosition,n=t.worldScaling;return[(e.x+e.w/2-r[0])/n[0],(e.y+e.h/2-r[1])/n[1]];}},{key:"getRectFromLayer",value:function getRectFromLayer(e,t){var r=e.getElementsByName(t)[0];if(r){var n=r.getBoundingClientRect();return{x:Math.floor(n.x-Mr.SafeBorderPadding),y:Math.floor(n.y-Mr.SafeBorderPadding),w:Math.floor(n.width+Mr.SafeBorderPadding*2),h:Math.floor(n.height+Mr.SafeBorderPadding*2)};}}},{key:"isWillRefresh",value:function isWillRefresh(e){var t=e.toolsType,r=e.opt,n=e.node,s=e.updateOpt,c=e.willSerializeData;return!!(c&&(s.angle||s.translate)||s.thickness&&r.thickness&&r.thickness!==s.thickness||s.strokeType&&r.strokeType&&r.strokeType!==s.strokeType||s.originPoint&&s.scenePoint&&s.scale||s.pointMap&&s.pointMap.has(n.name)||t===Tt.Text&&(s.fontSize||s.translate||s.textInfos&&s.textInfos.get(n.name))||t===Tt.Image&&(s.angle||s.translate||s.scale||s.strokeColor&&s.type===cl.Iconify)||t===s.toolsType&&s.willRefresh||r.eraserlines&&r.eraserlines.length&&(s.strokeColor||s.fillColor));}}]);}();dt(Mr,"SafeBorderPadding",10);var $t=Mr;var Tl=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 Cl={exports:{}};Cl.exports;(function(i){var e=function(){var t=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",s={};function c(f,h){if(!s[f]){s[f]={};for(var m=0;m<f.length;m++)s[f][f.charAt(m)]=m;}return s[f][h];}var l={compressToBase64:function compressToBase64(f){if(f==null)return"";var h=l._compress(f,6,function(m){return r.charAt(m);});switch(h.length%4){default:case 0:return h;case 1:return h+"===";case 2:return h+"==";case 3:return h+"=";}},decompressFromBase64:function decompressFromBase64(f){return f==null?"":f==""?null:l._decompress(f.length,32,function(h){return c(r,f.charAt(h));});},compressToUTF16:function compressToUTF16(f){return f==null?"":l._compress(f,15,function(h){return t(h+32);})+" ";},decompressFromUTF16:function decompressFromUTF16(f){return f==null?"":f==""?null:l._decompress(f.length,16384,function(h){return f.charCodeAt(h)-32;});},//compress into uint8array (UCS-2 big endian format)
399
+ AT(h,f)))&&l.push(h);return l;}var th=RT,bT=Object.prototype;function DT(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||bT;return i===t;}var vl=DT;function NT(i,e){return function(t){return i(e(t));};}var eh=NT,BT=eh,WT=BT(Object.keys,Object),FT=WT,UT=vl,YT=FT,XT=Object.prototype,zT=XT.hasOwnProperty;function $T(i){if(!UT(i))return YT(i);var e=[];for(var t in Object(i))zT.call(i,t)&&t!="constructor"&&e.push(t);return e;}var jT=$T,GT=ju,kT=qu;function HT(i){return i!=null&&kT(i.length)&&!GT(i);}var gl=HT,KT=th,VT=jT,ZT=gl;function JT(i){return ZT(i)?KT(i):VT(i);}var ml=JT,QT=yo,qT=ml;function _T(i,e){return i&&QT(e,qT(e),i);}var tC=_T;function eC(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e;}var rC=eC,nC=Qi,iC=vl,sC=rC,oC=Object.prototype,aC=oC.hasOwnProperty;function lC(i){if(!nC(i))return sC(i);var e=iC(i),t=[];for(var r in i)r=="constructor"&&(e||!aC.call(i,r))||t.push(r);return t;}var fC=lC,cC=th,uC=fC,hC=gl;function dC(i){return hC(i)?cC(i,!0):uC(i);}var yl=dC,pC=yo,vC=yl;function gC(i,e){return i&&pC(e,vC(e),i);}var mC=gC,ro={exports:{}};ro.exports;(function(i,e){var t=_r,r=e&&!e.nodeType&&e,n=r&&!0&&i&&!i.nodeType&&i,s=n&&n.exports===r,c=s?t.Buffer:void 0,l=c?c.allocUnsafe:void 0;function f(h,m){if(m)return h.slice();var u=h.length,y=l?l(u):new h.constructor(u);return h.copy(y),y;}i.exports=f;})(ro,ro.exports);var yC=ro.exports;function PC(i,e){var t=-1,r=i.length;for(e||(e=Array(r));++t<r;)e[t]=i[t];return e;}var SC=PC;function xC(i,e){for(var t=-1,r=i==null?0:i.length,n=0,s=[];++t<r;){var c=i[t];e(c,t,i)&&(s[n++]=c);}return s;}var rh=xC;function TC(){return[];}var nh=TC,CC=rh,IC=nh,OC=Object.prototype,wC=OC.propertyIsEnumerable,qc=Object.getOwnPropertySymbols,AC=qc?function(i){return i==null?[]:(i=Object(i),CC(qc(i),function(e){return wC.call(i,e);}));}:IC,Pl=AC,EC=yo,MC=Pl;function LC(i,e){return EC(i,MC(i),e);}var RC=LC;function bC(i,e){for(var t=-1,r=e.length,n=i.length;++t<r;)i[n+t]=e[t];return i;}var Sl=bC,DC=eh,NC=DC(Object.getPrototypeOf,Object),ih=NC,BC=Sl,WC=ih,FC=Pl,UC=nh,YC=Object.getOwnPropertySymbols,XC=YC?function(i){for(var e=[];i;)BC(e,FC(i)),i=WC(i);return e;}:UC,sh=XC,zC=yo,$C=sh;function jC(i,e){return zC(i,$C(i),e);}var GC=jC,kC=Sl,HC=qi;function KC(i,e,t){var r=e(i);return HC(i)?r:kC(r,t(i));}var oh=KC,VC=oh,ZC=Pl,JC=ml;function QC(i){return VC(i,JC,ZC);}var ah=QC,qC=oh,_C=sh,tI=yl;function eI(i){return qC(i,tI,_C);}var rI=eI,nI=$n,iI=_r,sI=nI(iI,"DataView"),oI=sI,aI=$n,lI=_r,fI=aI(lI,"Promise"),cI=fI,uI=$n,hI=_r,dI=uI(hI,"Set"),lh=dI,pI=$n,vI=_r,gI=pI(vI,"WeakMap"),mI=gI,rl=oI,nl=hl,il=cI,sl=lh,ol=mI,fh=Pi,Ii=Gu,_c="[object Map]",yI="[object Object]",tu="[object Promise]",eu="[object Set]",ru="[object WeakMap]",nu="[object DataView]",PI=Ii(rl),SI=Ii(nl),xI=Ii(il),TI=Ii(sl),CI=Ii(ol),zn=fh;(rl&&zn(new rl(new ArrayBuffer(1)))!=nu||nl&&zn(new nl())!=_c||il&&zn(il.resolve())!=tu||sl&&zn(new sl())!=eu||ol&&zn(new ol())!=ru)&&(zn=function zn(i){var e=fh(i),t=e==yI?i.constructor:void 0,r=t?Ii(t):"";if(r)switch(r){case PI:return nu;case SI:return _c;case xI:return tu;case TI:return eu;case CI:return ru;}return e;});var So=zn,II=Object.prototype,OI=II.hasOwnProperty;function wI(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&OI.call(i,"index")&&(t.index=i.index,t.input=i.input),t;}var AI=wI,EI=_r,MI=EI.Uint8Array,ch=MI,iu=ch;function LI(i){var e=new i.constructor(i.byteLength);return new iu(e).set(new iu(i)),e;}var xl=LI,RI=xl;function bI(i,e){var t=e?RI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength);}var DI=bI,NI=/\w*$/;function BI(i){var e=new i.constructor(i.source,NI.exec(i));return e.lastIndex=i.lastIndex,e;}var WI=BI,su=Ji,ou=su?su.prototype:void 0,au=ou?ou.valueOf:void 0;function FI(i){return au?Object(au.call(i)):{};}var UI=FI,YI=xl;function XI(i,e){var t=e?YI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length);}var zI=XI,$I=xl,jI=DI,GI=WI,kI=UI,HI=zI,KI="[object Boolean]",VI="[object Date]",ZI="[object Map]",JI="[object Number]",QI="[object RegExp]",qI="[object Set]",_I="[object String]",tO="[object Symbol]",eO="[object ArrayBuffer]",rO="[object DataView]",nO="[object Float32Array]",iO="[object Float64Array]",sO="[object Int8Array]",oO="[object Int16Array]",aO="[object Int32Array]",lO="[object Uint8Array]",fO="[object Uint8ClampedArray]",cO="[object Uint16Array]",uO="[object Uint32Array]";function hO(i,e,t){var r=i.constructor;switch(e){case eO:return $I(i);case KI:case VI:return new r(+i);case rO:return jI(i,t);case nO:case iO:case sO:case oO:case aO:case lO:case fO:case cO:case uO:return HI(i,t);case ZI:return new r();case JI:case _I:return new r(i);case QI:return GI(i);case qI:return new r();case tO:return kI(i);}}var dO=hO,pO=Qi,lu=Object.create,vO=/* @__PURE__ */function(){function i(){}return function(e){if(!pO(e))return{};if(lu)return lu(e);i.prototype=e;var t=new i();return i.prototype=void 0,t;};}(),gO=vO,mO=gO,yO=ih,PO=vl;function SO(i){return typeof i.constructor=="function"&&!PO(i)?mO(yO(i)):{};}var xO=SO,TO=So,CO=pn,IO="[object Map]";function OO(i){return CO(i)&&TO(i)==IO;}var wO=OO,AO=wO,EO=Po,fu=pl,cu=fu&&fu.isMap,MO=cu?EO(cu):AO,LO=MO,RO=So,bO=pn,DO="[object Set]";function NO(i){return bO(i)&&RO(i)==DO;}var BO=NO,WO=BO,FO=Po,uu=pl,hu=uu&&uu.isSet,UO=hu?FO(hu):WO,uh=UO,YO=/* @__PURE__ */Ln(uh),XO=Hu,zO=hx,$O=Zu,jO=tC,GO=mC,kO=yC,HO=SC,KO=RC,VO=GC,ZO=ah,JO=rI,QO=So,qO=AI,_O=dO,t2=xO,e2=qi,r2=dl,n2=LO,i2=Qi,s2=uh,o2=ml,a2=yl,l2=1,f2=2,c2=4,hh="[object Arguments]",u2="[object Array]",h2="[object Boolean]",d2="[object Date]",p2="[object Error]",dh="[object Function]",v2="[object GeneratorFunction]",g2="[object Map]",m2="[object Number]",ph="[object Object]",y2="[object RegExp]",P2="[object Set]",S2="[object String]",x2="[object Symbol]",T2="[object WeakMap]",C2="[object ArrayBuffer]",I2="[object DataView]",O2="[object Float32Array]",w2="[object Float64Array]",A2="[object Int8Array]",E2="[object Int16Array]",M2="[object Int32Array]",L2="[object Uint8Array]",R2="[object Uint8ClampedArray]",b2="[object Uint16Array]",D2="[object Uint32Array]",Ye={};Ye[hh]=Ye[u2]=Ye[C2]=Ye[I2]=Ye[h2]=Ye[d2]=Ye[O2]=Ye[w2]=Ye[A2]=Ye[E2]=Ye[M2]=Ye[g2]=Ye[m2]=Ye[ph]=Ye[y2]=Ye[P2]=Ye[S2]=Ye[x2]=Ye[L2]=Ye[R2]=Ye[b2]=Ye[D2]=!0;Ye[p2]=Ye[dh]=Ye[T2]=!1;function qs(i,e,t,r,n,s){var c,l=e&l2,f=e&f2,h=e&c2;if(t&&(c=n?t(i,r,n,s):t(i)),c!==void 0)return c;if(!i2(i))return i;var m=e2(i);if(m){if(c=qO(i),!l)return HO(i,c);}else{var u=QO(i),y=u==dh||u==v2;if(r2(i))return kO(i,l);if(u==ph||u==hh||y&&!n){if(c=f||y?{}:t2(i),!l)return f?VO(i,GO(c,i)):KO(i,jO(c,i));}else{if(!Ye[u])return n?i:{};c=_O(i,u,l);}}s||(s=new XO());var T=s.get(i);if(T)return T;s.set(i,c),s2(i)?i.forEach(function(x){c.add(qs(x,e,t,x,i,s));}):n2(i)&&i.forEach(function(x,I){c.set(I,qs(x,e,t,I,i,s));});var E=h?f?JO:ZO:f?a2:o2,C=m?void 0:E(i);return zO(C||i,function(x,I){C&&(I=x,x=i[I]),$O(c,I,qs(x,e,t,I,i,s));}),c;}var N2=qs,B2=N2,W2=1,F2=4;function U2(i){return B2(i,W2|F2);}var Y2=U2,fr=/* @__PURE__ */Ln(Y2);var vh="1.1.22-beta.13",X2="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var i=window.__netlessUA||"";i+=" ".concat(X2,"@").concat(vh),window.__netlessUA=i;}var vr={useWorker:"auto",useSimple:!1,syncOpt:{interval:300,smoothSync:!0},cursor:{enable:!0,expirationTime:5e3,moveDelayTime:100},bufferSize:{full:2e4,sub:600},bezier:{enable:!0,maxDrawCount:1/0,combineUnitTime:300},pencilEraser:{useBitMap:!0,maxImageWidth:1920,maxImageHeight:1920,maxCombineTime:500},strokeWidth:{min:1,max:10},textEditor:{showFloatBar:!0,canSelectorSwitch:!0,rightBoundBreak:!1,extendFontFaces:[],loadFontFacesTimeout:1e4},longDottedStroke:{lineCap:"round",segment:1,gap:2},dottedStroke:{lineCap:"round",segment:1,gap:2},normalStroke:{lineCap:"round"}};function En(i){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var t=i.length;if(t<2)return"";var r=i[0],n=i[1];if(t===2)return"M".concat(fi(r),"L").concat(fi(n));var s="";for(var c=2,l=t-1;c<l;c++)r=i[c],n=i[c+1],s+=ci(r,n);return e?"M".concat(ci(i[0],i[1]),"Q").concat(fi(i[1])).concat(ci(i[1],i[2]),"T").concat(s).concat(ci(i[t-1],i[0])).concat(ci(i[0],i[1]),"Z"):"M".concat(fi(i[0]),"Q").concat(fi(i[1])).concat(ci(i[1],i[2])).concat(i.length>3?"T":"").concat(s,"L").concat(fi(i[t-1]));}var Mr=/*#__PURE__*/function(){function Mr(e){_classCallCheck(this,Mr);dt(this,"maxImageWidth",vr.pencilEraser.maxImageWidth);dt(this,"maxImageHeight",vr.pencilEraser.maxImageHeight);dt(this,"syncUnitTime",vr.syncOpt.interval);dt(this,"vNodes");dt(this,"drawLayer");dt(this,"fullLayer");dt(this,"workId");dt(this,"isDelete",!1);var t=e.vNodes,r=e.fullLayer,n=e.drawLayer,s=e.workId,c=e.toolsOpt;this.vNodes=t,this.fullLayer=r,this.drawLayer=n,this.workId=s,this.syncUnitTime=c.syncUnitTime||this.syncUnitTime;}return _createClass(Mr,[{key:"baseConsumeResult",get:function get(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions};}},{key:"filterSamePoints",value:function filterSamePoints(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0.01;return e.reduce(function(r,n){var s=r[r.length-1];return(n&&!s||n&&s&&!n.isNear(s,t))&&r.push(n),r;},[]);}/** 设置工作id */},{key:"setWorkId",value:function setWorkId(e){this.workId=e;}},{key:"getWorkId",value:function getWorkId(){return this.workId;}/** 获取工作选项配置 */},{key:"getWorkOptions",value:function getWorkOptions(){return this.workOptions;}/** 设置工作选项配置 */},{key:"setWorkOptions",value:function setWorkOptions(e){var n,s,c;this.workOptions=e,this.syncUnitTime=e.syncUnitTime||this.syncUnitTime;var t=(n=this.workId)==null?void 0:n.toString(),r=t&&((s=this.vNodes)==null?void 0:s.get(t))||void 0;t&&r&&(r.opt=e,(c=this.vNodes)==null||c.setInfo(t,r));}/** 更新服务端同步配置,返回绘制结果 */},{key:"updataOptService",value:function updataOptService(e){var n,s;var t;var r=(n=this.workId)==null?void 0:n.toString();if(r&&e){var c=this.fullLayer.getElementsByName(r)||this.drawLayer&&this.drawLayer.getElementsByName(r)||[];if(c.length!==1)return;var l=c[0],f=e.pos,h=e.zIndex,m=e.scale,u=e.angle,y=e.translate,T={};er(h)&&(T.zIndex=h),f&&(T.pos=[f[0],f[1]]),m&&(T.scale=m),u&&(T.rotate=u),y&&(T.translate=y),l.attr(T);var E=l==null?void 0:l.getBoundingClientRect();return E&&(t=Zt(t,{x:Math.floor(E.x-Mr.SafeBorderPadding),y:Math.floor(E.y-Mr.SafeBorderPadding),w:Math.floor(E.width+Mr.SafeBorderPadding*2),h:Math.floor(E.height+Mr.SafeBorderPadding*2)})),(s=this.vNodes)==null||s.setInfo(r,{rect:t,centerPos:f}),t;}}},{key:"drawEraserlines",value:function drawEraserlines(e,t){var r=e.group,n=e.eraserlines,s=e.pos,c=e.layer,l=c.parent;if(t)try{var h=(c.renderer.glRenderer||c.renderer.canvasRenderer).options.displayRatio,m=r.getBoundingClientRect(),u=m.width*h*c.worldScaling[0],y=m.height*h*c.worldScaling[1];var T=1;(u>this.maxImageWidth||y>this.maxImageHeight)&&(T=Math.min(this.maxImageWidth/u,this.maxImageHeight/y));var E=c.getAttribute("scale");E=[E[0]*T,E[1]*T];var C=c.parent.parent,x=c.getAttribute("translate"),_I32=this.createVmRenderNode("".concat(this.workId,"_bitMapLayer"),C,{offscreen:l.offscreen,width:l.width,height:l.height,contextType:"2d",autoRender:!1,bufferSize:500},E,x),_d29=r.cloneNode(!0);if(!n||!n.length)return;this.addEraserlines(_d29,n,s,!1),_I32.appendChild(_d29);var v=_I32.parent;v.render();var p=_I32.renderer.canvasRenderer,S=p.context;if(!S)return;var A=p.options.displayRatio,R=_d29.getBoundingClientRect(),D={x:R.x,y:R.y,w:R.width,h:R.height},U={x:0,y:0,w:C.width,h:C.height};if(Zi(D,U)===Tr.outside){Lr(_d29,v),C.removeChild(v),this.isDelete=!0;return;}var W=fr(D);W.x=Math.floor(Math.max(D.x,0)),W.y=Math.floor(Math.max(D.y,0)),W.w=Math.min(D.x+D.w,C.width)-W.x,W.h=Math.min(D.y+D.h,C.height)-W.y;var Y=this.getGroupRect(W,A),B=Y.x,N=Y.y,G=Y.w,J=Y.h;var tt=S.getImageData(B,N,G,J);if(this.isTransparentRectByCanvas(tt)){Lr(_d29,v),C.removeChild(v),this.isDelete=!0,tt=null;return;}Lr(r,l);var ut=this.createSpriteNode({imageData:tt,safariRect:W,originRect:D,worldScaling:_I32.worldScaling});ut&&r.append(ut),Lr(_d29,v),C.removeChild(v),l.deleteTexture(tt),tt=null;}catch(f){console.error("[BaseShapeTool] drawEraserlines error:",f);return;}}},{key:"createVmRenderNode",value:function createVmRenderNode(e,t,r,n,s){var c=r.width,l=r.height,f="bitMap-".concat(e),h=t.layer(f,r),m=new mr({anchor:[0.5,0.5],pos:[c*0.5,l*0.5],size:[c,l],name:"viewport",id:e});return m.setAttribute("scale",n),m.setAttribute("translate",s),h.append(m),m;}},{key:"getGroupRect",value:function getGroupRect(e,t){var r=Math.floor(e.x*t),n=Math.floor(e.y*t),s=Math.floor(e.w*t),c=Math.floor(e.h*t);return{x:r,y:n,w:s,h:c};}},{key:"addEraserlines",value:function addEraserlines(e,t,r){var n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:!0;var _iterator13=_createForOfIteratorHelper(t),_step13;try{for(_iterator13.s();!(_step13=_iterator13.n()).done;){var s=_step13.value;var c=s.thickness,l=s.op;var _iterator14=_createForOfIteratorHelper(l),_step14;try{for(_iterator14.s();!(_step14=_iterator14.n()).done;){var f=_step14.value;var h=f.map(function(E,C){return C%2?E-r[1]:E-r[0];}),m=this.computEraserPoints(h,c),u=En(m,!0),y={pos:[0,0],d:u,fillColor:"rgba(0,0,0,1)"},T=new Mn(y);T.addEventListener("beforerender",function(_ref164){var E=_ref164.detail;var C=E.context;n?C.blendFuncSeparate(C.ZERO,C.ZERO,C.ZERO,C.ZERO):C.globalCompositeOperation="destination-out";}),T.addEventListener("afterrender",function(_ref165){var E=_ref165.detail;var C=E.context;n?C.blendFuncSeparate(C.SRC_ALPHA,C.ONE_MINUS_SRC_ALPHA,C.ONE,C.ONE_MINUS_SRC_ALPHA):C.globalCompositeOperation="source-over";}),e.append(T);}}catch(err){_iterator14.e(err);}finally{_iterator14.f();}}}catch(err){_iterator13.e(err);}finally{_iterator13.f();}}},{key:"isTransparentRectByCanvas",value:function isTransparentRectByCanvas(e){var t=!0;for(var r=0;r<e.data.length;r+=4)if(e.data[r+3]!==0){t=!1;break;}return t;}},{key:"createSpriteNode",value:function createSpriteNode(e){var t=e.imageData,r=e.worldScaling,n=e.safariRect,s=e.originRect;var c;if(typeof OffscreenCanvas=="function"){c=new OffscreenCanvas(t.width,t.height);var m=c.getContext("2d");m&&m.putImageData(t,0,0);}else if((typeof document==="undefined"?"undefined":_typeof(document))<"u"){c=document.createElement("canvas"),c.width=t.width,c.height=t.height;var _m4=c.getContext("2d");_m4&&_m4.putImageData(t,0,0);}if(!c)return console.warn("Failed to create imageEraserBitmap Sprite"),null;var l=[Math.floor(s.w/r[0]),Math.floor(s.h/r[1])],f=[Math.floor((n.x-s.x)/r[0]),Math.floor((n.y-s.y)/r[1]),Math.floor(n.w/r[0]),Math.floor(n.h/r[1])],h={name:"eraserTexture",anchor:[0.5,0.5],pos:[0,0],size:l,texture:c,textureRect:f};return new Yu(h);}},{key:"computEraserPoints",value:function computEraserPoints(e,t){var r=Math.ceil(t/2);return e.length===2?this.computDot(e,r):this.computLine(e,r);}},{key:"computDot",value:function computDot(e,t){var r=new Jt(e[0],e[1]);return Jt.GetDotStroke(r,t,8);}},{key:"computLine",value:function computLine(e,t){var r=[],n=[];var s,c;for(var l=0;l<e.length;l+=2){var f=new Jt(e[l],e[l+1]);var h=void 0;if(l==e.length-2){var m=new Jt(e[l-2],e[l-1]);h=pt.Sub(f,m).uni(),s=f;}else{l===0&&(c=f);var _m5=new Jt(e[l+2],e[l+3]);h=pt.Sub(_m5,f).uni();}if(h){var _m6=pt.Per(h).mul(t);r.push(Jt.Sub(f,_m6)),n.push(Jt.Add(f,_m6));}}if(s&&c){var _l3=Jt.GetSemicircleStroke(s,r[r.length-1],-1,8),_f4=Jt.GetSemicircleStroke(c,n[0],-1,8);return r.concat(_l3,n.reverse(),_f4);}return[];}},{key:"replace",value:function replace(e,t,r){var _this61=this;var s;if(!t){r&&e.append(r);return;}var n=e.getElementsByName(t);if(n.length){var _iterator15=_createForOfIteratorHelper(n),_step15;try{for(_iterator15.s();!(_step15=_iterator15.n()).done;){var c=_step15.value;r?iE(r,c,e):(c.remove(),_pr(c,e.parent));}}catch(err){_iterator15.e(err);}finally{_iterator15.f();}}else r&&e.append(r);this.fullLayer!==this.drawLayer&&(this.fullLayer===e?(s=this.drawLayer)==null||s.getElementsByName(t).forEach(function(l){var f;l.remove(),_pr(l,(f=_this61.drawLayer)==null?void 0:f.parent);}):this.fullLayer.getElementsByName(t).forEach(function(l){l.remove(),_pr(l,_this61.fullLayer.parent);}));}},{key:"removeDrawCountNodes",value:function removeDrawCountNodes(e,t){var r=[];e.getElementsByName(this.workId).forEach(function(n){n.id&&t&&Number(n.id)<t&&r.push(n);});for(var _i2=0,_r3=r;_i2<_r3.length;_i2++){var n=_r3[_i2];n.remove(),_pr(n,e.parent);}}}],[{key:"updateNodeOpt",value:function updateNodeOpt(e){var d;var t=e.node,r=e.opt,n=e.vNodes,s=e.willSerializeData,c=e.targetNode,l=r.zIndex,f=r.translate,h=r.angle,m=r.originPoint,u=r.scenePoint,y=r.scale,T=r.pointMap,E=r.thickness;var C;var x=c&&fr(c)||n.get(t.name);if(!x)return;er(l)&&(t.setAttribute("zIndex",l),x.opt.zIndex=l);var I=t.parent;if(I){if(m&&y&&c){var v=[x.op[0],x.op[1]];Ll(x.op,u,y,f);var p=[x.op[0],x.op[1]],S=[p[0]-v[0],p[1]-v[1]];if(x.centerPos=[x.centerPos[0]+S[0],x.centerPos[1]+S[1]],x.opt.translate=void 0,x.opt.scale=void 0,x.opt.eraserlines)for(var A=0;A<x.opt.eraserlines.length;A++){var _x$opt$eraserlines$A=x.opt.eraserlines[A],R=_x$opt$eraserlines$A.op,D=_x$opt$eraserlines$A.thickness;x.opt.eraserlines[A].thickness=Math.round(D*Math.max(y[0],y[1]));for(var U=0;U<R.length;U++)Rl(R[U],u,y,f);}}else if(f){if(t.setAttribute("translate",f),x.opt.translate=f,c){var _v6=[f[0]*I.worldScaling[0],f[1]*I.worldScaling[1]];C=Vi(x.rect,_v6),x.rect=C;}else{var _v7=Mr.getRectFromLayer(I,t.name);x.rect=_v7||x.rect;}}else if(er(h))if(t.setAttribute("rotate",h),x.opt.rotate=h,c)C=Hh(x.rect,h),x.rect=C;else{var _v8=Mr.getRectFromLayer(I,t.name);x.rect=_v8||x.rect;}if(T){var _v9=T.get(t.name);if(_v9)for(var _p10=0,_S10=0;_p10<x.op.length;_p10+=3,_S10++)x.op[_p10]=_v9[_S10][0],x.op[_p10+1]=_v9[_S10][1];}if(E&&(d=x==null?void 0:x.opt)!=null&&d.thickness&&(x.opt.thickness=E),s&&!(m&&y&&c)){if(f){var _v10=x.op.map(function(p,S){var A=S%3;return A===0?p+f[0]:A===1?p+f[1]:p;});if(x.op=_v10,x.centerPos=[x.centerPos[0]+f[0],x.centerPos[1]+f[1]],x!=null&&x.opt&&(x.opt.translate=void 0),x.opt.eraserlines)for(var _p11=0;_p11<x.opt.eraserlines.length;_p11++){var _S11=x.opt.eraserlines[_p11].op;for(var _A7=0;_A7<_S11.length;_A7++){var _R3=_S11[_A7].map(function(D,U){return U%2?D+f[1]:D+f[0];});x.opt.eraserlines[_p11].op[_A7]=_R3;}}}else if(er(h)){var _v11=x.op;if(JA(_v11,x.centerPos,h),x.op=_v11,x!=null&&x.opt&&(x.opt.rotate=void 0),x.opt.eraserlines)for(var _p12=0;_p12<x.opt.eraserlines.length;_p12++){var _S12=x.opt.eraserlines[_p12].op;for(var _A8=0;_A8<_S12.length;_A8++)QA(_S12[_A8],x.centerPos,h);}}}x&&n.setInfo(t.name,x);}}},{key:"getCenterPos",value:function getCenterPos(e,t){var r=t.worldPosition,n=t.worldScaling;return[(e.x+e.w/2-r[0])/n[0],(e.y+e.h/2-r[1])/n[1]];}},{key:"getRectFromLayer",value:function getRectFromLayer(e,t){var r=e.getElementsByName(t)[0];if(r){var n=r.getBoundingClientRect();return{x:Math.floor(n.x-Mr.SafeBorderPadding),y:Math.floor(n.y-Mr.SafeBorderPadding),w:Math.floor(n.width+Mr.SafeBorderPadding*2),h:Math.floor(n.height+Mr.SafeBorderPadding*2)};}}},{key:"isWillRefresh",value:function isWillRefresh(e){var t=e.toolsType,r=e.opt,n=e.node,s=e.updateOpt,c=e.willSerializeData;return!!(c&&(s.angle||s.translate)||s.thickness&&r.thickness&&r.thickness!==s.thickness||s.strokeType&&r.strokeType&&r.strokeType!==s.strokeType||s.originPoint&&s.scenePoint&&s.scale||s.pointMap&&s.pointMap.has(n.name)||t===Tt.Text&&(s.fontSize||s.translate||s.textInfos&&s.textInfos.get(n.name))||t===Tt.Image&&(s.angle||s.translate||s.scale||s.strokeColor&&s.type===cl.Iconify)||t===s.toolsType&&s.willRefresh||r.eraserlines&&r.eraserlines.length&&(s.strokeColor||s.fillColor));}}]);}();dt(Mr,"SafeBorderPadding",10);var $t=Mr;var Tl=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 Cl={exports:{}};Cl.exports;(function(i){var e=function(){var t=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",s={};function c(f,h){if(!s[f]){s[f]={};for(var m=0;m<f.length;m++)s[f][f.charAt(m)]=m;}return s[f][h];}var l={compressToBase64:function compressToBase64(f){if(f==null)return"";var h=l._compress(f,6,function(m){return r.charAt(m);});switch(h.length%4){default:case 0:return h;case 1:return h+"===";case 2:return h+"==";case 3:return h+"=";}},decompressFromBase64:function decompressFromBase64(f){return f==null?"":f==""?null:l._decompress(f.length,32,function(h){return c(r,f.charAt(h));});},compressToUTF16:function compressToUTF16(f){return f==null?"":l._compress(f,15,function(h){return t(h+32);})+" ";},decompressFromUTF16:function decompressFromUTF16(f){return f==null?"":f==""?null:l._decompress(f.length,16384,function(h){return f.charCodeAt(h)-32;});},//compress into uint8array (UCS-2 big endian format)
400
400
  compressToUint8Array:function compressToUint8Array(f){for(var h=l.compress(f),m=new Uint8Array(h.length*2),u=0,y=h.length;u<y;u++){var T=h.charCodeAt(u);m[u*2]=T>>>8,m[u*2+1]=T%256;}return m;},//decompress from uint8array (UCS-2 big endian format)
401
401
  decompressFromUint8Array:function decompressFromUint8Array(f){if(f==null)return l.decompress(f);for(var h=new Array(f.length/2),m=0,u=h.length;m<u;m++)h[m]=f[m*2]*256+f[m*2+1];var y=[];return h.forEach(function(T){y.push(t(T));}),l.decompress(y.join(""));},//compress into a string that is already URI encoded
402
402
  compressToEncodedURIComponent:function compressToEncodedURIComponent(f){return f==null?"":l._compress(f,6,function(h){return n.charAt(h);});},//decompress from an output of compressToEncodedURIComponent
@@ -1,7 +1,7 @@
1
1
  var _e = Object.defineProperty;
2
2
  var $e = (S, i, t) => i in S ? _e(S, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : S[i] = t;
3
3
  var y = (S, i, t) => $e(S, typeof i != "symbol" ? i + "" : i, t);
4
- import { g as Kt, _ as ve, i as Vt, p as kt, a as St, D as J, c as E, b as Rt, E as $t, d as st, P as O, V as I, s as Qt, e as Jt, f as Nt, h as Te, r as Ge, j as He, k as v, l as Gt, m as X, n as w, o as D, q as A, t as U, u as tt, v as $, w as jt, x as qe, y as je, z as Ze, A as Ke, B as Ve, C as Qe, F as Je, G as ts, S as _, H as es, I as ae, J as Wt, K as Pe, T as At, L as yt, M as ss, N as Ie, O as os, Q as is, R as ct, U as G, W as ut, X as rs, Y as ns, Z as as, $ as cs, a0 as bt, a1 as ls, a2 as z, a3 as ce, a4 as le, a5 as hs } from "./index-D0ikwklZ.mjs";
4
+ import { g as Kt, _ as ve, i as Vt, p as kt, a as St, D as J, c as E, b as Rt, E as $t, d as st, P as O, V as I, s as Qt, e as Jt, f as Nt, h as Te, r as Ge, j as He, k as v, l as Gt, m as X, n as w, o as D, q as A, t as U, u as tt, v as $, w as jt, x as qe, y as je, z as Ze, A as Ke, B as Ve, C as Qe, F as Je, G as ts, S as _, H as es, I as ae, J as Wt, K as Pe, T as At, L as yt, M as ss, N as Ie, O as os, Q as is, R as ct, U as G, W as ut, X as rs, Y as ns, Z as as, $ as cs, a0 as bt, a1 as ls, a2 as z, a3 as ce, a4 as le, a5 as hs } from "./index-CkDrr8C-.mjs";
5
5
  import { Group as K, Path as wt, Sprite as We, Rect as he, Polyline as ht, Ellipse as ps, Label as ds, Scene as te, Layer as us } from "spritejs";
6
6
  import rt from "clipper-lib";
7
7
  import ee from "lineclip";
@@ -1142,7 +1142,7 @@ function sg(o) {
1142
1142
  return ng(o, og | rg);
1143
1143
  }
1144
1144
  var ag = sg;
1145
- const ri = /* @__PURE__ */ Di(ag), yo = "1.1.22-beta.12", cg = "@netless/appliance-plugin", Tn = typeof OffscreenCanvas == "function" ? "worker" : "mainThread";
1145
+ const ri = /* @__PURE__ */ Di(ag), yo = "1.1.22-beta.13", cg = "@netless/appliance-plugin", Tn = typeof OffscreenCanvas == "function" ? "worker" : "mainThread";
1146
1146
  if (typeof window < "u") {
1147
1147
  let o = window.__netlessUA || "";
1148
1148
  o += ` ${cg}@${yo}`, window.__netlessUA = o;
@@ -2309,7 +2309,7 @@ const Fe = class Fe extends kf {
2309
2309
  ));
2310
2310
  }
2311
2311
  }
2312
- Object.keys(a).length > 0 && e(a);
2312
+ Object.keys(a).length > 0 && e(a), this.control.worker.publicMsgEmitter.emit("syncStorageChange", this.serviceStorage);
2313
2313
  });
2314
2314
  }
2315
2315
  removeStorageStateListener() {
@@ -2609,7 +2609,9 @@ const Fe = class Fe extends kf {
2609
2609
  }
2610
2610
  runSyncService(e) {
2611
2611
  if (!this.control.renderControl.isWritable) {
2612
- console.warn(
2612
+ this.control.room && this.control.room.logger ? this.control.room.logger.error(
2613
+ "The current state is not writable and synchronization cannot be synchronized"
2614
+ ) : console.error(
2613
2615
  "The current state is not writable and synchronization cannot be synchronized"
2614
2616
  );
2615
2617
  return;
@@ -4774,7 +4776,7 @@ class Jf extends Gf {
4774
4776
  "set font faces in main thread success"
4775
4777
  );
4776
4778
  });
4777
- const { MainThreadManagerImpl: e } = await import("./index-CvNbTJN-.mjs");
4779
+ const { MainThreadManagerImpl: e } = await import("./index-CH7D6LfT.mjs");
4778
4780
  this.mainThread = new e(this);
4779
4781
  }
4780
4782
  async on() {
@@ -10706,10 +10708,11 @@ const yp = (o) => {
10706
10708
  stripIgnoreTagBody: ["script"]
10707
10709
  // script标签较特殊,需要过滤标签中间的内容
10708
10710
  });
10709
- J(le, E.current), n(E.current);
10711
+ J(le, E.current), ce((f || 1) * P.current), n(E.current);
10710
10712
  }
10711
10713
  s();
10712
10714
  }
10715
+ return !1;
10713
10716
  }
10714
10717
  function Ge(F) {
10715
10718
  var K;