@netless/appliance-plugin 1.1.34-beta.0 → 1.1.34-beta.1

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-A-oik2.js",e="/subWorker-hEAHPy.js";exports.fullWorkerUrl=r;exports.subWorkerUrl=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r="/fullWorker-B-f0DA.js",e="/subWorker-CQa79_.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
- ET(h,f)))&&l.push(h);return l;}var nh=bT,DT=Object.prototype;function NT(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||DT;return i===t;}var yl=NT;function BT(i,e){return function(t){return i(e(t));};}var ih=BT,WT=ih,FT=WT(Object.keys,Object),UT=FT,YT=yl,XT=UT,zT=Object.prototype,$T=zT.hasOwnProperty;function jT(i){if(!YT(i))return XT(i);var e=[];for(var t in Object(i))$T.call(i,t)&&t!="constructor"&&e.push(t);return e;}var GT=jT,kT=Hu,HT=eh;function VT(i){return i!=null&&HT(i.length)&&!kT(i);}var Sl=VT,KT=nh,ZT=GT,JT=Sl;function QT(i){return JT(i)?KT(i):ZT(i);}var Pl=QT,qT=Po,_T=Pl;function tC(i,e){return i&&qT(e,_T(e),i);}var eC=tC;function rC(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e;}var nC=rC,iC=qi,sC=yl,oC=nC,aC=Object.prototype,lC=aC.hasOwnProperty;function fC(i){if(!iC(i))return oC(i);var e=sC(i),t=[];for(var r in i)r=="constructor"&&(e||!lC.call(i,r))||t.push(r);return t;}var cC=fC,uC=nh,hC=cC,dC=Sl;function pC(i){return dC(i)?uC(i,!0):hC(i);}var xl=pC,vC=Po,gC=xl;function mC(i,e){return i&&vC(e,gC(e),i);}var yC=mC,no={exports:{}};no.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,v){if(v)return h.slice();var u=h.length,y=l?l(u):new h.constructor(u);return h.copy(y),y;}i.exports=f;})(no,no.exports);var SC=no.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 xC=PC;function TC(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 sh=TC;function CC(){return[];}var oh=CC,IC=sh,OC=oh,wC=Object.prototype,AC=wC.propertyIsEnumerable,tu=Object.getOwnPropertySymbols,EC=tu?function(i){return i==null?[]:(i=Object(i),IC(tu(i),function(e){return AC.call(i,e);}));}:OC,Tl=EC,MC=Po,LC=Tl;function RC(i,e){return MC(i,LC(i),e);}var bC=RC;function DC(i,e){for(var t=-1,r=e.length,n=i.length;++t<r;)i[n+t]=e[t];return i;}var Cl=DC,NC=ih,BC=NC(Object.getPrototypeOf,Object),ah=BC,WC=Cl,FC=ah,UC=Tl,YC=oh,XC=Object.getOwnPropertySymbols,zC=XC?function(i){for(var e=[];i;)WC(e,UC(i)),i=FC(i);return e;}:YC,lh=zC,$C=Po,jC=lh;function GC(i,e){return $C(i,jC(i),e);}var kC=GC,HC=Cl,VC=_i;function KC(i,e,t){var r=e(i);return VC(i)?r:HC(r,t(i));}var fh=KC,ZC=fh,JC=Tl,QC=Pl;function qC(i){return ZC(i,QC,JC);}var ch=qC,_C=fh,tI=lh,eI=xl;function rI(i){return _C(i,eI,tI);}var nI=rI,iI=Gn,sI=_r,oI=iI(sI,"DataView"),aI=oI,lI=Gn,fI=_r,cI=lI(fI,"Promise"),uI=cI,hI=Gn,dI=_r,pI=hI(dI,"Set"),uh=pI,vI=Gn,gI=_r,mI=vI(gI,"WeakMap"),yI=mI,ol=aI,al=vl,ll=uI,fl=uh,cl=yI,hh=Pi,Oi=Vu,eu="[object Map]",SI="[object Object]",ru="[object Promise]",nu="[object Set]",iu="[object WeakMap]",su="[object DataView]",PI=Oi(ol),xI=Oi(al),TI=Oi(ll),CI=Oi(fl),II=Oi(cl),zn=hh;(ol&&zn(new ol(new ArrayBuffer(1)))!=su||al&&zn(new al())!=eu||ll&&zn(ll.resolve())!=ru||fl&&zn(new fl())!=nu||cl&&zn(new cl())!=iu)&&(zn=function zn(i){var e=hh(i),t=e==SI?i.constructor:void 0,r=t?Oi(t):"";if(r)switch(r){case PI:return su;case xI:return eu;case TI:return ru;case CI:return nu;case II:return iu;}return e;});var To=zn,OI=Object.prototype,wI=OI.hasOwnProperty;function AI(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&wI.call(i,"index")&&(t.index=i.index,t.input=i.input),t;}var EI=AI,MI=_r,LI=MI.Uint8Array,dh=LI,ou=dh;function RI(i){var e=new i.constructor(i.byteLength);return new ou(e).set(new ou(i)),e;}var Il=RI,bI=Il;function DI(i,e){var t=e?bI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength);}var NI=DI,BI=/\w*$/;function WI(i){var e=new i.constructor(i.source,BI.exec(i));return e.lastIndex=i.lastIndex,e;}var FI=WI,au=Qi,lu=au?au.prototype:void 0,fu=lu?lu.valueOf:void 0;function UI(i){return fu?Object(fu.call(i)):{};}var YI=UI,XI=Il;function zI(i,e){var t=e?XI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length);}var $I=zI,jI=Il,GI=NI,kI=FI,HI=YI,VI=$I,KI="[object Boolean]",ZI="[object Date]",JI="[object Map]",QI="[object Number]",qI="[object RegExp]",_I="[object Set]",tO="[object String]",eO="[object Symbol]",rO="[object ArrayBuffer]",nO="[object DataView]",iO="[object Float32Array]",sO="[object Float64Array]",oO="[object Int8Array]",aO="[object Int16Array]",lO="[object Int32Array]",fO="[object Uint8Array]",cO="[object Uint8ClampedArray]",uO="[object Uint16Array]",hO="[object Uint32Array]";function dO(i,e,t){var r=i.constructor;switch(e){case rO:return jI(i);case KI:case ZI:return new r(+i);case nO:return GI(i,t);case iO:case sO:case oO:case aO:case lO:case fO:case cO:case uO:case hO:return VI(i,t);case JI:return new r();case QI:case tO:return new r(i);case qI:return kI(i);case _I:return new r();case eO:return HI(i);}}var pO=dO,vO=qi,cu=Object.create,gO=/* @__PURE__ */function(){function i(){}return function(e){if(!vO(e))return{};if(cu)return cu(e);i.prototype=e;var t=new i();return i.prototype=void 0,t;};}(),mO=gO,yO=mO,SO=ah,PO=yl;function xO(i){return typeof i.constructor=="function"&&!PO(i)?yO(SO(i)):{};}var TO=xO,CO=To,IO=pn,OO="[object Map]";function wO(i){return IO(i)&&CO(i)==OO;}var AO=wO,EO=AO,MO=xo,uu=ml,hu=uu&&uu.isMap,LO=hu?MO(hu):EO,RO=LO,bO=To,DO=pn,NO="[object Set]";function BO(i){return DO(i)&&bO(i)==NO;}var WO=BO,FO=WO,UO=xo,du=ml,pu=du&&du.isSet,YO=pu?UO(pu):FO,ph=YO,XO=/* @__PURE__ */Ln(ph),zO=Zu,$O=dx,jO=qu,GO=eC,kO=yC,HO=SC,VO=xC,KO=bC,ZO=kC,JO=ch,QO=nI,qO=To,_O=EI,tw=pO,ew=TO,rw=_i,nw=gl,iw=RO,sw=qi,ow=ph,aw=Pl,lw=xl,fw=1,cw=2,uw=4,vh="[object Arguments]",hw="[object Array]",dw="[object Boolean]",pw="[object Date]",vw="[object Error]",gh="[object Function]",gw="[object GeneratorFunction]",mw="[object Map]",yw="[object Number]",mh="[object Object]",Sw="[object RegExp]",Pw="[object Set]",xw="[object String]",Tw="[object Symbol]",Cw="[object WeakMap]",Iw="[object ArrayBuffer]",Ow="[object DataView]",ww="[object Float32Array]",Aw="[object Float64Array]",Ew="[object Int8Array]",Mw="[object Int16Array]",Lw="[object Int32Array]",Rw="[object Uint8Array]",bw="[object Uint8ClampedArray]",Dw="[object Uint16Array]",Nw="[object Uint32Array]",Ye={};Ye[vh]=Ye[hw]=Ye[Iw]=Ye[Ow]=Ye[dw]=Ye[pw]=Ye[ww]=Ye[Aw]=Ye[Ew]=Ye[Mw]=Ye[Lw]=Ye[mw]=Ye[yw]=Ye[mh]=Ye[Sw]=Ye[Pw]=Ye[xw]=Ye[Tw]=Ye[Rw]=Ye[bw]=Ye[Dw]=Ye[Nw]=!0;Ye[vw]=Ye[gh]=Ye[Cw]=!1;function _s(i,e,t,r,n,s){var c,l=e&fw,f=e&cw,h=e&uw;if(t&&(c=n?t(i,r,n,s):t(i)),c!==void 0)return c;if(!sw(i))return i;var v=rw(i);if(v){if(c=_O(i),!l)return VO(i,c);}else{var u=qO(i),y=u==gh||u==gw;if(nw(i))return HO(i,l);if(u==mh||u==vh||y&&!n){if(c=f||y?{}:ew(i),!l)return f?ZO(i,kO(c,i)):KO(i,GO(c,i));}else{if(!Ye[u])return n?i:{};c=tw(i,u,l);}}s||(s=new zO());var T=s.get(i);if(T)return T;s.set(i,c),ow(i)?i.forEach(function(S){c.add(_s(S,e,t,S,i,s));}):iw(i)&&i.forEach(function(S,O){c.set(O,_s(S,e,t,O,i,s));});var w=h?f?QO:JO:f?lw:aw,I=v?void 0:w(i);return $O(I||i,function(S,O){I&&(O=S,S=i[O]),jO(c,O,_s(S,e,t,O,i,s));}),c;}var Bw=_s,Ww=Bw,Fw=1,Uw=4;function Yw(i){return Ww(i,Fw|Uw);}var Xw=Yw,fr=/* @__PURE__ */Ln(Xw);var yh="1.1.34-beta.0",zw="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var i=window.__netlessUA||"";i+=" ".concat(zw,"@").concat(yh),window.__netlessUA=i;}var gr={useWorker:"auto",useSimple:!1,useBackgroundThread:!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"},undoRedo:{enableGlobal:!1,maxStackLength:20},markmap:{enable:!0,timeout:1e4,options:{autoFit:!0,duration:0,zoom:!1,pan:!1,maxInitialScale:10}}};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(ui(r),"L").concat(ui(n));var s="";for(var c=2,l=t-1;c<l;c++)r=i[c],n=i[c+1],s+=hi(r,n);return e?"M".concat(hi(i[0],i[1]),"Q").concat(ui(i[1])).concat(hi(i[1],i[2]),"T").concat(s).concat(hi(i[t-1],i[0])).concat(hi(i[0],i[1]),"Z"):"M".concat(ui(i[0]),"Q").concat(ui(i[1])).concat(hi(i[1],i[2])).concat(i.length>3?"T":"").concat(s,"L").concat(ui(i[t-1]));}var Mr=/*#__PURE__*/function(){function Mr(e){_classCallCheck(this,Mr);dt(this,"maxImageWidth",gr.pencilEraser.maxImageWidth);dt(this,"maxImageHeight",gr.pencilEraser.maxImageHeight);dt(this,"syncUnitTime",gr.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,v=e.scale,u=e.angle,y=e.translate,T={};_e(h)&&(T.zIndex=h),f&&(T.pos=[f[0],f[1]]),v&&(T.scale=v),u&&(T.rotate=u),y&&(T.translate=y),l.attr(T);var w=l==null?void 0:l.getBoundingClientRect();return w&&(t=Zt(t,{x:Math.floor(w.x-Mr.SafeBorderPadding),y:Math.floor(w.y-Mr.SafeBorderPadding),w:Math.floor(w.width+Mr.SafeBorderPadding*2),h:Math.floor(w.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,v=r.getBoundingClientRect(),u=v.width*h*c.worldScaling[0],y=v.height*h*c.worldScaling[1];var T=1;(u>this.maxImageWidth||y>this.maxImageHeight)&&(T=Math.min(this.maxImageWidth/u,this.maxImageHeight/y));var w=c.getAttribute("scale");w=[w[0]*T,w[1]*T];var I=c.parent.parent,S=c.getAttribute("translate"),_O30=this.createVmRenderNode("".concat(this.workId,"_bitMapLayer"),I,{offscreen:l.offscreen,width:l.width,height:l.height,contextType:"2d",autoRender:!1,bufferSize:500},w,S),_d30=r.cloneNode(!0);if(!n||!n.length)return;this.addEraserlines(_d30,n,s,!1),_O30.appendChild(_d30);var g=_O30.parent;g.render();var p=_O30.renderer.canvasRenderer,x=p.context;if(!x)return;var E=p.options.displayRatio,R=_d30.getBoundingClientRect(),D={x:R.x,y:R.y,w:R.width,h:R.height},U={x:0,y:0,w:I.width,h:I.height};if(Ji(D,U)===Tr.outside){Lr(_d30,g),I.removeChild(g),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,I.width)-W.x,W.h=Math.min(D.y+D.h,I.height)-W.y;var X=this.getGroupRect(W,E),B=X.x,N=X.y,$=X.w,J=X.h;var tt=x.getImageData(B,N,$,J);if(this.isTransparentRectByCanvas(tt)){Lr(_d30,g),I.removeChild(g),this.isDelete=!0,tt=null;return;}Lr(r,l);var ut=this.createSpriteNode({imageData:tt,safariRect:W,originRect:D,worldScaling:_O30.worldScaling});ut&&r.append(ut),Lr(_d30,g),I.removeChild(g),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),v=new cr({anchor:[0.5,0.5],pos:[c*0.5,l*0.5],size:[c,l],name:"viewport",id:e});return v.setAttribute("scale",n),v.setAttribute("translate",s),h.append(v),v;}},{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(w,I){return I%2?w-r[1]:w-r[0];}),v=this.computEraserPoints(h,c),u=En(v,!0),y={pos:[0,0],d:u,fillColor:"rgba(0,0,0,1)"},T=new Mn(y);T.addEventListener("beforerender",function(_ref164){var w=_ref164.detail;var I=w.context;n?I.blendFuncSeparate(I.ZERO,I.ZERO,I.ZERO,I.ZERO):I.globalCompositeOperation="destination-out";}),T.addEventListener("afterrender",function(_ref165){var w=_ref165.detail;var I=w.context;n?I.blendFuncSeparate(I.SRC_ALPHA,I.ONE_MINUS_SRC_ALPHA,I.ONE,I.ONE_MINUS_SRC_ALPHA):I.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 v=c.getContext("2d");v&&v.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 _v4=c.getContext("2d");_v4&&_v4.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 $u(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 v=new Jt(e[l-2],e[l-1]);h=pt.Sub(f,v).uni(),s=f;}else{l===0&&(c=f);var _v5=new Jt(e[l+2],e[l+3]);h=pt.Sub(_v5,f).uni();}if(h){var _v6=pt.Per(h).mul(t);r.push(Jt.Sub(f,_v6)),n.push(Jt.Add(f,_v6));}}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 _this60=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?sE(r,c,e):(c.remove(),_vr(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(),_vr(l,(f=_this60.drawLayer)==null?void 0:f.parent);}):this.fullLayer.getElementsByName(t).forEach(function(l){l.remove(),_vr(l,_this60.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(),_vr(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,v=r.originPoint,u=r.scenePoint,y=r.scale,T=r.pointMap,w=r.thickness;var I;var S=c&&fr(c)||n.get(t.name);if(!S)return;_e(l)&&(t.setAttribute("zIndex",l),S.opt.zIndex=l);var O=t.parent;if(O){if(v&&y&&c){var g=[S.op[0],S.op[1]];Oo(S.op,u,y,f);var p=[S.op[0],S.op[1]],x=[p[0]-g[0],p[1]-g[1]];if(S.centerPos=[S.centerPos[0]+x[0],S.centerPos[1]+x[1]],S.opt.translate=void 0,S.opt.scale=void 0,S.opt.eraserlines)for(var E=0;E<S.opt.eraserlines.length;E++){var _S$opt$eraserlines$E=S.opt.eraserlines[E],R=_S$opt$eraserlines$E.op,D=_S$opt$eraserlines$E.thickness;S.opt.eraserlines[E].thickness=Math.round(D*Math.max(y[0],y[1]));for(var U=0;U<R.length;U++)Nl(R[U],u,y,f);}}else if(f){if(t.setAttribute("translate",f),S.opt.translate=f,c){var _g6=[f[0]*O.worldScaling[0],f[1]*O.worldScaling[1]];I=Zi(S.rect,_g6),S.rect=I;}else{var _g7=Mr.getRectFromLayer(O,t.name);S.rect=_g7||S.rect;}}else if(_e(h))if(t.setAttribute("rotate",h),S.opt.rotate=h,c)I=Dl(S.rect,h),S.rect=I;else{var _g8=Mr.getRectFromLayer(O,t.name);S.rect=_g8||S.rect;}if(T){var _g9=T.get(t.name);if(_g9)for(var _p10=0,_x37=0;_p10<S.op.length;_p10+=3,_x37++)S.op[_p10]=_g9[_x37][0],S.op[_p10+1]=_g9[_x37][1];}if(w&&(d=S==null?void 0:S.opt)!=null&&d.thickness&&(S.opt.thickness=w),s&&!(v&&y&&c)){if(f){var _g10=S.op.map(function(p,x){var E=x%3;return E===0?p+f[0]:E===1?p+f[1]:p;});if(S.op=_g10,S.centerPos=[S.centerPos[0]+f[0],S.centerPos[1]+f[1]],S!=null&&S.opt&&(S.opt.translate=void 0),S.opt.eraserlines)for(var _p11=0;_p11<S.opt.eraserlines.length;_p11++){var _x38=S.opt.eraserlines[_p11].op;for(var _E7=0;_E7<_x38.length;_E7++){var _R3=_x38[_E7].map(function(D,U){return U%2?D+f[1]:D+f[0];});S.opt.eraserlines[_p11].op[_E7]=_R3;}}}else if(_e(h)){var _g11=S.op;if(QA(_g11,S.centerPos,h),S.op=_g11,S!=null&&S.opt&&(S.opt.rotate=void 0),S.opt.eraserlines)for(var _p12=0;_p12<S.opt.eraserlines.length;_p12++){var _x39=S.opt.eraserlines[_p12].op;for(var _E8=0;_E8<_x39.length;_E8++)qA(_x39[_E8],S.centerPos,h);}}}S&&n.setInfo(t.name,S);}}},{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===xt.Text&&(s.fontSize||s.translate||s.textInfos&&s.textInfos.get(n.name))||t===xt.BackgroundSVG&&(s.translate||s.scale)||t===xt.Image&&(s.angle||s.translate||s.scale||s.strokeColor&&r.type===vo.Iconify)||t===s.toolsType&&s.willRefresh||r.eraserlines&&r.eraserlines.length&&(s.strokeColor||s.fillColor));}}]);}();dt(Mr,"SafeBorderPadding",10);var Xt=Mr;var Ol=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 wl={exports:{}};wl.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 v=0;v<f.length;v++)s[f][f.charAt(v)]=v;}return s[f][h];}var l={compressToBase64:function compressToBase64(f){if(f==null)return"";var h=l._compress(f,6,function(v){return r.charAt(v);});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
+ ET(h,f)))&&l.push(h);return l;}var nh=bT,DT=Object.prototype;function NT(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||DT;return i===t;}var yl=NT;function BT(i,e){return function(t){return i(e(t));};}var ih=BT,WT=ih,FT=WT(Object.keys,Object),UT=FT,YT=yl,XT=UT,zT=Object.prototype,$T=zT.hasOwnProperty;function jT(i){if(!YT(i))return XT(i);var e=[];for(var t in Object(i))$T.call(i,t)&&t!="constructor"&&e.push(t);return e;}var GT=jT,kT=Hu,HT=eh;function VT(i){return i!=null&&HT(i.length)&&!kT(i);}var Sl=VT,KT=nh,ZT=GT,JT=Sl;function QT(i){return JT(i)?KT(i):ZT(i);}var Pl=QT,qT=Po,_T=Pl;function tC(i,e){return i&&qT(e,_T(e),i);}var eC=tC;function rC(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e;}var nC=rC,iC=qi,sC=yl,oC=nC,aC=Object.prototype,lC=aC.hasOwnProperty;function fC(i){if(!iC(i))return oC(i);var e=sC(i),t=[];for(var r in i)r=="constructor"&&(e||!lC.call(i,r))||t.push(r);return t;}var cC=fC,uC=nh,hC=cC,dC=Sl;function pC(i){return dC(i)?uC(i,!0):hC(i);}var xl=pC,vC=Po,gC=xl;function mC(i,e){return i&&vC(e,gC(e),i);}var yC=mC,no={exports:{}};no.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,v){if(v)return h.slice();var u=h.length,y=l?l(u):new h.constructor(u);return h.copy(y),y;}i.exports=f;})(no,no.exports);var SC=no.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 xC=PC;function TC(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 sh=TC;function CC(){return[];}var oh=CC,IC=sh,OC=oh,wC=Object.prototype,AC=wC.propertyIsEnumerable,tu=Object.getOwnPropertySymbols,EC=tu?function(i){return i==null?[]:(i=Object(i),IC(tu(i),function(e){return AC.call(i,e);}));}:OC,Tl=EC,MC=Po,LC=Tl;function RC(i,e){return MC(i,LC(i),e);}var bC=RC;function DC(i,e){for(var t=-1,r=e.length,n=i.length;++t<r;)i[n+t]=e[t];return i;}var Cl=DC,NC=ih,BC=NC(Object.getPrototypeOf,Object),ah=BC,WC=Cl,FC=ah,UC=Tl,YC=oh,XC=Object.getOwnPropertySymbols,zC=XC?function(i){for(var e=[];i;)WC(e,UC(i)),i=FC(i);return e;}:YC,lh=zC,$C=Po,jC=lh;function GC(i,e){return $C(i,jC(i),e);}var kC=GC,HC=Cl,VC=_i;function KC(i,e,t){var r=e(i);return VC(i)?r:HC(r,t(i));}var fh=KC,ZC=fh,JC=Tl,QC=Pl;function qC(i){return ZC(i,QC,JC);}var ch=qC,_C=fh,tI=lh,eI=xl;function rI(i){return _C(i,eI,tI);}var nI=rI,iI=Gn,sI=_r,oI=iI(sI,"DataView"),aI=oI,lI=Gn,fI=_r,cI=lI(fI,"Promise"),uI=cI,hI=Gn,dI=_r,pI=hI(dI,"Set"),uh=pI,vI=Gn,gI=_r,mI=vI(gI,"WeakMap"),yI=mI,ol=aI,al=vl,ll=uI,fl=uh,cl=yI,hh=Pi,Oi=Vu,eu="[object Map]",SI="[object Object]",ru="[object Promise]",nu="[object Set]",iu="[object WeakMap]",su="[object DataView]",PI=Oi(ol),xI=Oi(al),TI=Oi(ll),CI=Oi(fl),II=Oi(cl),zn=hh;(ol&&zn(new ol(new ArrayBuffer(1)))!=su||al&&zn(new al())!=eu||ll&&zn(ll.resolve())!=ru||fl&&zn(new fl())!=nu||cl&&zn(new cl())!=iu)&&(zn=function zn(i){var e=hh(i),t=e==SI?i.constructor:void 0,r=t?Oi(t):"";if(r)switch(r){case PI:return su;case xI:return eu;case TI:return ru;case CI:return nu;case II:return iu;}return e;});var To=zn,OI=Object.prototype,wI=OI.hasOwnProperty;function AI(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&wI.call(i,"index")&&(t.index=i.index,t.input=i.input),t;}var EI=AI,MI=_r,LI=MI.Uint8Array,dh=LI,ou=dh;function RI(i){var e=new i.constructor(i.byteLength);return new ou(e).set(new ou(i)),e;}var Il=RI,bI=Il;function DI(i,e){var t=e?bI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength);}var NI=DI,BI=/\w*$/;function WI(i){var e=new i.constructor(i.source,BI.exec(i));return e.lastIndex=i.lastIndex,e;}var FI=WI,au=Qi,lu=au?au.prototype:void 0,fu=lu?lu.valueOf:void 0;function UI(i){return fu?Object(fu.call(i)):{};}var YI=UI,XI=Il;function zI(i,e){var t=e?XI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length);}var $I=zI,jI=Il,GI=NI,kI=FI,HI=YI,VI=$I,KI="[object Boolean]",ZI="[object Date]",JI="[object Map]",QI="[object Number]",qI="[object RegExp]",_I="[object Set]",tO="[object String]",eO="[object Symbol]",rO="[object ArrayBuffer]",nO="[object DataView]",iO="[object Float32Array]",sO="[object Float64Array]",oO="[object Int8Array]",aO="[object Int16Array]",lO="[object Int32Array]",fO="[object Uint8Array]",cO="[object Uint8ClampedArray]",uO="[object Uint16Array]",hO="[object Uint32Array]";function dO(i,e,t){var r=i.constructor;switch(e){case rO:return jI(i);case KI:case ZI:return new r(+i);case nO:return GI(i,t);case iO:case sO:case oO:case aO:case lO:case fO:case cO:case uO:case hO:return VI(i,t);case JI:return new r();case QI:case tO:return new r(i);case qI:return kI(i);case _I:return new r();case eO:return HI(i);}}var pO=dO,vO=qi,cu=Object.create,gO=/* @__PURE__ */function(){function i(){}return function(e){if(!vO(e))return{};if(cu)return cu(e);i.prototype=e;var t=new i();return i.prototype=void 0,t;};}(),mO=gO,yO=mO,SO=ah,PO=yl;function xO(i){return typeof i.constructor=="function"&&!PO(i)?yO(SO(i)):{};}var TO=xO,CO=To,IO=pn,OO="[object Map]";function wO(i){return IO(i)&&CO(i)==OO;}var AO=wO,EO=AO,MO=xo,uu=ml,hu=uu&&uu.isMap,LO=hu?MO(hu):EO,RO=LO,bO=To,DO=pn,NO="[object Set]";function BO(i){return DO(i)&&bO(i)==NO;}var WO=BO,FO=WO,UO=xo,du=ml,pu=du&&du.isSet,YO=pu?UO(pu):FO,ph=YO,XO=/* @__PURE__ */Ln(ph),zO=Zu,$O=dx,jO=qu,GO=eC,kO=yC,HO=SC,VO=xC,KO=bC,ZO=kC,JO=ch,QO=nI,qO=To,_O=EI,tw=pO,ew=TO,rw=_i,nw=gl,iw=RO,sw=qi,ow=ph,aw=Pl,lw=xl,fw=1,cw=2,uw=4,vh="[object Arguments]",hw="[object Array]",dw="[object Boolean]",pw="[object Date]",vw="[object Error]",gh="[object Function]",gw="[object GeneratorFunction]",mw="[object Map]",yw="[object Number]",mh="[object Object]",Sw="[object RegExp]",Pw="[object Set]",xw="[object String]",Tw="[object Symbol]",Cw="[object WeakMap]",Iw="[object ArrayBuffer]",Ow="[object DataView]",ww="[object Float32Array]",Aw="[object Float64Array]",Ew="[object Int8Array]",Mw="[object Int16Array]",Lw="[object Int32Array]",Rw="[object Uint8Array]",bw="[object Uint8ClampedArray]",Dw="[object Uint16Array]",Nw="[object Uint32Array]",Ye={};Ye[vh]=Ye[hw]=Ye[Iw]=Ye[Ow]=Ye[dw]=Ye[pw]=Ye[ww]=Ye[Aw]=Ye[Ew]=Ye[Mw]=Ye[Lw]=Ye[mw]=Ye[yw]=Ye[mh]=Ye[Sw]=Ye[Pw]=Ye[xw]=Ye[Tw]=Ye[Rw]=Ye[bw]=Ye[Dw]=Ye[Nw]=!0;Ye[vw]=Ye[gh]=Ye[Cw]=!1;function _s(i,e,t,r,n,s){var c,l=e&fw,f=e&cw,h=e&uw;if(t&&(c=n?t(i,r,n,s):t(i)),c!==void 0)return c;if(!sw(i))return i;var v=rw(i);if(v){if(c=_O(i),!l)return VO(i,c);}else{var u=qO(i),y=u==gh||u==gw;if(nw(i))return HO(i,l);if(u==mh||u==vh||y&&!n){if(c=f||y?{}:ew(i),!l)return f?ZO(i,kO(c,i)):KO(i,GO(c,i));}else{if(!Ye[u])return n?i:{};c=tw(i,u,l);}}s||(s=new zO());var T=s.get(i);if(T)return T;s.set(i,c),ow(i)?i.forEach(function(S){c.add(_s(S,e,t,S,i,s));}):iw(i)&&i.forEach(function(S,O){c.set(O,_s(S,e,t,O,i,s));});var w=h?f?QO:JO:f?lw:aw,I=v?void 0:w(i);return $O(I||i,function(S,O){I&&(O=S,S=i[O]),jO(c,O,_s(S,e,t,O,i,s));}),c;}var Bw=_s,Ww=Bw,Fw=1,Uw=4;function Yw(i){return Ww(i,Fw|Uw);}var Xw=Yw,fr=/* @__PURE__ */Ln(Xw);var yh="1.1.34-beta.1",zw="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var i=window.__netlessUA||"";i+=" ".concat(zw,"@").concat(yh),window.__netlessUA=i;}var gr={useWorker:"auto",useSimple:!1,useBackgroundThread:!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"},undoRedo:{enableGlobal:!1,maxStackLength:20},markmap:{enable:!0,timeout:1e4,options:{autoFit:!0,duration:0,zoom:!1,pan:!1,maxInitialScale:10}}};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(ui(r),"L").concat(ui(n));var s="";for(var c=2,l=t-1;c<l;c++)r=i[c],n=i[c+1],s+=hi(r,n);return e?"M".concat(hi(i[0],i[1]),"Q").concat(ui(i[1])).concat(hi(i[1],i[2]),"T").concat(s).concat(hi(i[t-1],i[0])).concat(hi(i[0],i[1]),"Z"):"M".concat(ui(i[0]),"Q").concat(ui(i[1])).concat(hi(i[1],i[2])).concat(i.length>3?"T":"").concat(s,"L").concat(ui(i[t-1]));}var Mr=/*#__PURE__*/function(){function Mr(e){_classCallCheck(this,Mr);dt(this,"maxImageWidth",gr.pencilEraser.maxImageWidth);dt(this,"maxImageHeight",gr.pencilEraser.maxImageHeight);dt(this,"syncUnitTime",gr.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,v=e.scale,u=e.angle,y=e.translate,T={};_e(h)&&(T.zIndex=h),f&&(T.pos=[f[0],f[1]]),v&&(T.scale=v),u&&(T.rotate=u),y&&(T.translate=y),l.attr(T);var w=l==null?void 0:l.getBoundingClientRect();return w&&(t=Zt(t,{x:Math.floor(w.x-Mr.SafeBorderPadding),y:Math.floor(w.y-Mr.SafeBorderPadding),w:Math.floor(w.width+Mr.SafeBorderPadding*2),h:Math.floor(w.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,v=r.getBoundingClientRect(),u=v.width*h*c.worldScaling[0],y=v.height*h*c.worldScaling[1];var T=1;(u>this.maxImageWidth||y>this.maxImageHeight)&&(T=Math.min(this.maxImageWidth/u,this.maxImageHeight/y));var w=c.getAttribute("scale");w=[w[0]*T,w[1]*T];var I=c.parent.parent,S=c.getAttribute("translate"),_O30=this.createVmRenderNode("".concat(this.workId,"_bitMapLayer"),I,{offscreen:l.offscreen,width:l.width,height:l.height,contextType:"2d",autoRender:!1,bufferSize:500},w,S),_d30=r.cloneNode(!0);if(!n||!n.length)return;this.addEraserlines(_d30,n,s,!1),_O30.appendChild(_d30);var g=_O30.parent;g.render();var p=_O30.renderer.canvasRenderer,x=p.context;if(!x)return;var E=p.options.displayRatio,R=_d30.getBoundingClientRect(),D={x:R.x,y:R.y,w:R.width,h:R.height},U={x:0,y:0,w:I.width,h:I.height};if(Ji(D,U)===Tr.outside){Lr(_d30,g),I.removeChild(g),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,I.width)-W.x,W.h=Math.min(D.y+D.h,I.height)-W.y;var X=this.getGroupRect(W,E),B=X.x,N=X.y,$=X.w,J=X.h;var tt=x.getImageData(B,N,$,J);if(this.isTransparentRectByCanvas(tt)){Lr(_d30,g),I.removeChild(g),this.isDelete=!0,tt=null;return;}Lr(r,l);var ut=this.createSpriteNode({imageData:tt,safariRect:W,originRect:D,worldScaling:_O30.worldScaling});ut&&r.append(ut),Lr(_d30,g),I.removeChild(g),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),v=new cr({anchor:[0.5,0.5],pos:[c*0.5,l*0.5],size:[c,l],name:"viewport",id:e});return v.setAttribute("scale",n),v.setAttribute("translate",s),h.append(v),v;}},{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(w,I){return I%2?w-r[1]:w-r[0];}),v=this.computEraserPoints(h,c),u=En(v,!0),y={pos:[0,0],d:u,fillColor:"rgba(0,0,0,1)"},T=new Mn(y);T.addEventListener("beforerender",function(_ref164){var w=_ref164.detail;var I=w.context;n?I.blendFuncSeparate(I.ZERO,I.ZERO,I.ZERO,I.ZERO):I.globalCompositeOperation="destination-out";}),T.addEventListener("afterrender",function(_ref165){var w=_ref165.detail;var I=w.context;n?I.blendFuncSeparate(I.SRC_ALPHA,I.ONE_MINUS_SRC_ALPHA,I.ONE,I.ONE_MINUS_SRC_ALPHA):I.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 v=c.getContext("2d");v&&v.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 _v4=c.getContext("2d");_v4&&_v4.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 $u(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 v=new Jt(e[l-2],e[l-1]);h=pt.Sub(f,v).uni(),s=f;}else{l===0&&(c=f);var _v5=new Jt(e[l+2],e[l+3]);h=pt.Sub(_v5,f).uni();}if(h){var _v6=pt.Per(h).mul(t);r.push(Jt.Sub(f,_v6)),n.push(Jt.Add(f,_v6));}}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 _this60=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?sE(r,c,e):(c.remove(),_vr(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(),_vr(l,(f=_this60.drawLayer)==null?void 0:f.parent);}):this.fullLayer.getElementsByName(t).forEach(function(l){l.remove(),_vr(l,_this60.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(),_vr(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,v=r.originPoint,u=r.scenePoint,y=r.scale,T=r.pointMap,w=r.thickness;var I;var S=c&&fr(c)||n.get(t.name);if(!S)return;_e(l)&&(t.setAttribute("zIndex",l),S.opt.zIndex=l);var O=t.parent;if(O){if(v&&y&&c){var g=[S.op[0],S.op[1]];Oo(S.op,u,y,f);var p=[S.op[0],S.op[1]],x=[p[0]-g[0],p[1]-g[1]];if(S.centerPos=[S.centerPos[0]+x[0],S.centerPos[1]+x[1]],S.opt.translate=void 0,S.opt.scale=void 0,S.opt.eraserlines)for(var E=0;E<S.opt.eraserlines.length;E++){var _S$opt$eraserlines$E=S.opt.eraserlines[E],R=_S$opt$eraserlines$E.op,D=_S$opt$eraserlines$E.thickness;S.opt.eraserlines[E].thickness=Math.round(D*Math.max(y[0],y[1]));for(var U=0;U<R.length;U++)Nl(R[U],u,y,f);}}else if(f){if(t.setAttribute("translate",f),S.opt.translate=f,c){var _g6=[f[0]*O.worldScaling[0],f[1]*O.worldScaling[1]];I=Zi(S.rect,_g6),S.rect=I;}else{var _g7=Mr.getRectFromLayer(O,t.name);S.rect=_g7||S.rect;}}else if(_e(h))if(t.setAttribute("rotate",h),S.opt.rotate=h,c)I=Dl(S.rect,h),S.rect=I;else{var _g8=Mr.getRectFromLayer(O,t.name);S.rect=_g8||S.rect;}if(T){var _g9=T.get(t.name);if(_g9)for(var _p10=0,_x37=0;_p10<S.op.length;_p10+=3,_x37++)S.op[_p10]=_g9[_x37][0],S.op[_p10+1]=_g9[_x37][1];}if(w&&(d=S==null?void 0:S.opt)!=null&&d.thickness&&(S.opt.thickness=w),s&&!(v&&y&&c)){if(f){var _g10=S.op.map(function(p,x){var E=x%3;return E===0?p+f[0]:E===1?p+f[1]:p;});if(S.op=_g10,S.centerPos=[S.centerPos[0]+f[0],S.centerPos[1]+f[1]],S!=null&&S.opt&&(S.opt.translate=void 0),S.opt.eraserlines)for(var _p11=0;_p11<S.opt.eraserlines.length;_p11++){var _x38=S.opt.eraserlines[_p11].op;for(var _E7=0;_E7<_x38.length;_E7++){var _R3=_x38[_E7].map(function(D,U){return U%2?D+f[1]:D+f[0];});S.opt.eraserlines[_p11].op[_E7]=_R3;}}}else if(_e(h)){var _g11=S.op;if(QA(_g11,S.centerPos,h),S.op=_g11,S!=null&&S.opt&&(S.opt.rotate=void 0),S.opt.eraserlines)for(var _p12=0;_p12<S.opt.eraserlines.length;_p12++){var _x39=S.opt.eraserlines[_p12].op;for(var _E8=0;_E8<_x39.length;_E8++)qA(_x39[_E8],S.centerPos,h);}}}S&&n.setInfo(t.name,S);}}},{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===xt.Text&&(s.fontSize||s.translate||s.textInfos&&s.textInfos.get(n.name))||t===xt.BackgroundSVG&&(s.translate||s.scale)||t===xt.Image&&(s.angle||s.translate||s.scale||s.strokeColor&&r.type===vo.Iconify)||t===s.toolsType&&s.willRefresh||r.eraserlines&&r.eraserlines.length&&(s.strokeColor||s.fillColor));}}]);}();dt(Mr,"SafeBorderPadding",10);var Xt=Mr;var Ol=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 wl={exports:{}};wl.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 v=0;v<f.length;v++)s[f][f.charAt(v)]=v;}return s[f][h];}var l={compressToBase64:function compressToBase64(f){if(f==null)return"";var h=l._compress(f,6,function(v){return r.charAt(v);});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),v=new Uint8Array(h.length*2),u=0,y=h.length;u<y;u++){var T=h.charCodeAt(u);v[u*2]=T>>>8,v[u*2+1]=T%256;}return v;},//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),v=0,u=h.length;v<u;v++)h[v]=f[v*2]*256+f[v*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
- ET(h,f)))&&l.push(h);return l;}var nh=bT,DT=Object.prototype;function NT(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||DT;return i===t;}var yl=NT;function BT(i,e){return function(t){return i(e(t));};}var ih=BT,WT=ih,FT=WT(Object.keys,Object),UT=FT,YT=yl,XT=UT,zT=Object.prototype,$T=zT.hasOwnProperty;function jT(i){if(!YT(i))return XT(i);var e=[];for(var t in Object(i))$T.call(i,t)&&t!="constructor"&&e.push(t);return e;}var GT=jT,kT=Hu,HT=eh;function VT(i){return i!=null&&HT(i.length)&&!kT(i);}var Sl=VT,KT=nh,ZT=GT,JT=Sl;function QT(i){return JT(i)?KT(i):ZT(i);}var Pl=QT,qT=Po,_T=Pl;function tC(i,e){return i&&qT(e,_T(e),i);}var eC=tC;function rC(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e;}var nC=rC,iC=qi,sC=yl,oC=nC,aC=Object.prototype,lC=aC.hasOwnProperty;function fC(i){if(!iC(i))return oC(i);var e=sC(i),t=[];for(var r in i)r=="constructor"&&(e||!lC.call(i,r))||t.push(r);return t;}var cC=fC,uC=nh,hC=cC,dC=Sl;function pC(i){return dC(i)?uC(i,!0):hC(i);}var xl=pC,vC=Po,gC=xl;function mC(i,e){return i&&vC(e,gC(e),i);}var yC=mC,no={exports:{}};no.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,v){if(v)return h.slice();var u=h.length,y=l?l(u):new h.constructor(u);return h.copy(y),y;}i.exports=f;})(no,no.exports);var SC=no.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 xC=PC;function TC(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 sh=TC;function CC(){return[];}var oh=CC,IC=sh,OC=oh,wC=Object.prototype,AC=wC.propertyIsEnumerable,tu=Object.getOwnPropertySymbols,EC=tu?function(i){return i==null?[]:(i=Object(i),IC(tu(i),function(e){return AC.call(i,e);}));}:OC,Tl=EC,MC=Po,LC=Tl;function RC(i,e){return MC(i,LC(i),e);}var bC=RC;function DC(i,e){for(var t=-1,r=e.length,n=i.length;++t<r;)i[n+t]=e[t];return i;}var Cl=DC,NC=ih,BC=NC(Object.getPrototypeOf,Object),ah=BC,WC=Cl,FC=ah,UC=Tl,YC=oh,XC=Object.getOwnPropertySymbols,zC=XC?function(i){for(var e=[];i;)WC(e,UC(i)),i=FC(i);return e;}:YC,lh=zC,$C=Po,jC=lh;function GC(i,e){return $C(i,jC(i),e);}var kC=GC,HC=Cl,VC=_i;function KC(i,e,t){var r=e(i);return VC(i)?r:HC(r,t(i));}var fh=KC,ZC=fh,JC=Tl,QC=Pl;function qC(i){return ZC(i,QC,JC);}var ch=qC,_C=fh,tI=lh,eI=xl;function rI(i){return _C(i,eI,tI);}var nI=rI,iI=Gn,sI=_r,oI=iI(sI,"DataView"),aI=oI,lI=Gn,fI=_r,cI=lI(fI,"Promise"),uI=cI,hI=Gn,dI=_r,pI=hI(dI,"Set"),uh=pI,vI=Gn,gI=_r,mI=vI(gI,"WeakMap"),yI=mI,ol=aI,al=vl,ll=uI,fl=uh,cl=yI,hh=Pi,Oi=Vu,eu="[object Map]",SI="[object Object]",ru="[object Promise]",nu="[object Set]",iu="[object WeakMap]",su="[object DataView]",PI=Oi(ol),xI=Oi(al),TI=Oi(ll),CI=Oi(fl),II=Oi(cl),zn=hh;(ol&&zn(new ol(new ArrayBuffer(1)))!=su||al&&zn(new al())!=eu||ll&&zn(ll.resolve())!=ru||fl&&zn(new fl())!=nu||cl&&zn(new cl())!=iu)&&(zn=function zn(i){var e=hh(i),t=e==SI?i.constructor:void 0,r=t?Oi(t):"";if(r)switch(r){case PI:return su;case xI:return eu;case TI:return ru;case CI:return nu;case II:return iu;}return e;});var To=zn,OI=Object.prototype,wI=OI.hasOwnProperty;function AI(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&wI.call(i,"index")&&(t.index=i.index,t.input=i.input),t;}var EI=AI,MI=_r,LI=MI.Uint8Array,dh=LI,ou=dh;function RI(i){var e=new i.constructor(i.byteLength);return new ou(e).set(new ou(i)),e;}var Il=RI,bI=Il;function DI(i,e){var t=e?bI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength);}var NI=DI,BI=/\w*$/;function WI(i){var e=new i.constructor(i.source,BI.exec(i));return e.lastIndex=i.lastIndex,e;}var FI=WI,au=Qi,lu=au?au.prototype:void 0,fu=lu?lu.valueOf:void 0;function UI(i){return fu?Object(fu.call(i)):{};}var YI=UI,XI=Il;function zI(i,e){var t=e?XI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length);}var $I=zI,jI=Il,GI=NI,kI=FI,HI=YI,VI=$I,KI="[object Boolean]",ZI="[object Date]",JI="[object Map]",QI="[object Number]",qI="[object RegExp]",_I="[object Set]",tO="[object String]",eO="[object Symbol]",rO="[object ArrayBuffer]",nO="[object DataView]",iO="[object Float32Array]",sO="[object Float64Array]",oO="[object Int8Array]",aO="[object Int16Array]",lO="[object Int32Array]",fO="[object Uint8Array]",cO="[object Uint8ClampedArray]",uO="[object Uint16Array]",hO="[object Uint32Array]";function dO(i,e,t){var r=i.constructor;switch(e){case rO:return jI(i);case KI:case ZI:return new r(+i);case nO:return GI(i,t);case iO:case sO:case oO:case aO:case lO:case fO:case cO:case uO:case hO:return VI(i,t);case JI:return new r();case QI:case tO:return new r(i);case qI:return kI(i);case _I:return new r();case eO:return HI(i);}}var pO=dO,vO=qi,cu=Object.create,gO=/* @__PURE__ */function(){function i(){}return function(e){if(!vO(e))return{};if(cu)return cu(e);i.prototype=e;var t=new i();return i.prototype=void 0,t;};}(),mO=gO,yO=mO,SO=ah,PO=yl;function xO(i){return typeof i.constructor=="function"&&!PO(i)?yO(SO(i)):{};}var TO=xO,CO=To,IO=pn,OO="[object Map]";function wO(i){return IO(i)&&CO(i)==OO;}var AO=wO,EO=AO,MO=xo,uu=ml,hu=uu&&uu.isMap,LO=hu?MO(hu):EO,RO=LO,bO=To,DO=pn,NO="[object Set]";function BO(i){return DO(i)&&bO(i)==NO;}var WO=BO,FO=WO,UO=xo,du=ml,pu=du&&du.isSet,YO=pu?UO(pu):FO,ph=YO,XO=/* @__PURE__ */Ln(ph),zO=Zu,$O=dx,jO=qu,GO=eC,kO=yC,HO=SC,VO=xC,KO=bC,ZO=kC,JO=ch,QO=nI,qO=To,_O=EI,tw=pO,ew=TO,rw=_i,nw=gl,iw=RO,sw=qi,ow=ph,aw=Pl,lw=xl,fw=1,cw=2,uw=4,vh="[object Arguments]",hw="[object Array]",dw="[object Boolean]",pw="[object Date]",vw="[object Error]",gh="[object Function]",gw="[object GeneratorFunction]",mw="[object Map]",yw="[object Number]",mh="[object Object]",Sw="[object RegExp]",Pw="[object Set]",xw="[object String]",Tw="[object Symbol]",Cw="[object WeakMap]",Iw="[object ArrayBuffer]",Ow="[object DataView]",ww="[object Float32Array]",Aw="[object Float64Array]",Ew="[object Int8Array]",Mw="[object Int16Array]",Lw="[object Int32Array]",Rw="[object Uint8Array]",bw="[object Uint8ClampedArray]",Dw="[object Uint16Array]",Nw="[object Uint32Array]",Ye={};Ye[vh]=Ye[hw]=Ye[Iw]=Ye[Ow]=Ye[dw]=Ye[pw]=Ye[ww]=Ye[Aw]=Ye[Ew]=Ye[Mw]=Ye[Lw]=Ye[mw]=Ye[yw]=Ye[mh]=Ye[Sw]=Ye[Pw]=Ye[xw]=Ye[Tw]=Ye[Rw]=Ye[bw]=Ye[Dw]=Ye[Nw]=!0;Ye[vw]=Ye[gh]=Ye[Cw]=!1;function _s(i,e,t,r,n,s){var c,l=e&fw,f=e&cw,h=e&uw;if(t&&(c=n?t(i,r,n,s):t(i)),c!==void 0)return c;if(!sw(i))return i;var v=rw(i);if(v){if(c=_O(i),!l)return VO(i,c);}else{var u=qO(i),y=u==gh||u==gw;if(nw(i))return HO(i,l);if(u==mh||u==vh||y&&!n){if(c=f||y?{}:ew(i),!l)return f?ZO(i,kO(c,i)):KO(i,GO(c,i));}else{if(!Ye[u])return n?i:{};c=tw(i,u,l);}}s||(s=new zO());var T=s.get(i);if(T)return T;s.set(i,c),ow(i)?i.forEach(function(S){c.add(_s(S,e,t,S,i,s));}):iw(i)&&i.forEach(function(S,O){c.set(O,_s(S,e,t,O,i,s));});var w=h?f?QO:JO:f?lw:aw,I=v?void 0:w(i);return $O(I||i,function(S,O){I&&(O=S,S=i[O]),jO(c,O,_s(S,e,t,O,i,s));}),c;}var Bw=_s,Ww=Bw,Fw=1,Uw=4;function Yw(i){return Ww(i,Fw|Uw);}var Xw=Yw,fr=/* @__PURE__ */Ln(Xw);var yh="1.1.34-beta.0",zw="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var i=window.__netlessUA||"";i+=" ".concat(zw,"@").concat(yh),window.__netlessUA=i;}var gr={useWorker:"auto",useSimple:!1,useBackgroundThread:!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"},undoRedo:{enableGlobal:!1,maxStackLength:20},markmap:{enable:!0,timeout:1e4,options:{autoFit:!0,duration:0,zoom:!1,pan:!1,maxInitialScale:10}}};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(ui(r),"L").concat(ui(n));var s="";for(var c=2,l=t-1;c<l;c++)r=i[c],n=i[c+1],s+=hi(r,n);return e?"M".concat(hi(i[0],i[1]),"Q").concat(ui(i[1])).concat(hi(i[1],i[2]),"T").concat(s).concat(hi(i[t-1],i[0])).concat(hi(i[0],i[1]),"Z"):"M".concat(ui(i[0]),"Q").concat(ui(i[1])).concat(hi(i[1],i[2])).concat(i.length>3?"T":"").concat(s,"L").concat(ui(i[t-1]));}var Mr=/*#__PURE__*/function(){function Mr(e){_classCallCheck(this,Mr);dt(this,"maxImageWidth",gr.pencilEraser.maxImageWidth);dt(this,"maxImageHeight",gr.pencilEraser.maxImageHeight);dt(this,"syncUnitTime",gr.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,v=e.scale,u=e.angle,y=e.translate,T={};_e(h)&&(T.zIndex=h),f&&(T.pos=[f[0],f[1]]),v&&(T.scale=v),u&&(T.rotate=u),y&&(T.translate=y),l.attr(T);var w=l==null?void 0:l.getBoundingClientRect();return w&&(t=Zt(t,{x:Math.floor(w.x-Mr.SafeBorderPadding),y:Math.floor(w.y-Mr.SafeBorderPadding),w:Math.floor(w.width+Mr.SafeBorderPadding*2),h:Math.floor(w.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,v=r.getBoundingClientRect(),u=v.width*h*c.worldScaling[0],y=v.height*h*c.worldScaling[1];var T=1;(u>this.maxImageWidth||y>this.maxImageHeight)&&(T=Math.min(this.maxImageWidth/u,this.maxImageHeight/y));var w=c.getAttribute("scale");w=[w[0]*T,w[1]*T];var I=c.parent.parent,S=c.getAttribute("translate"),_O30=this.createVmRenderNode("".concat(this.workId,"_bitMapLayer"),I,{offscreen:l.offscreen,width:l.width,height:l.height,contextType:"2d",autoRender:!1,bufferSize:500},w,S),_d30=r.cloneNode(!0);if(!n||!n.length)return;this.addEraserlines(_d30,n,s,!1),_O30.appendChild(_d30);var g=_O30.parent;g.render();var p=_O30.renderer.canvasRenderer,x=p.context;if(!x)return;var E=p.options.displayRatio,R=_d30.getBoundingClientRect(),D={x:R.x,y:R.y,w:R.width,h:R.height},U={x:0,y:0,w:I.width,h:I.height};if(Ji(D,U)===Tr.outside){Lr(_d30,g),I.removeChild(g),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,I.width)-W.x,W.h=Math.min(D.y+D.h,I.height)-W.y;var X=this.getGroupRect(W,E),B=X.x,N=X.y,$=X.w,J=X.h;var tt=x.getImageData(B,N,$,J);if(this.isTransparentRectByCanvas(tt)){Lr(_d30,g),I.removeChild(g),this.isDelete=!0,tt=null;return;}Lr(r,l);var ut=this.createSpriteNode({imageData:tt,safariRect:W,originRect:D,worldScaling:_O30.worldScaling});ut&&r.append(ut),Lr(_d30,g),I.removeChild(g),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),v=new cr({anchor:[0.5,0.5],pos:[c*0.5,l*0.5],size:[c,l],name:"viewport",id:e});return v.setAttribute("scale",n),v.setAttribute("translate",s),h.append(v),v;}},{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(w,I){return I%2?w-r[1]:w-r[0];}),v=this.computEraserPoints(h,c),u=En(v,!0),y={pos:[0,0],d:u,fillColor:"rgba(0,0,0,1)"},T=new Mn(y);T.addEventListener("beforerender",function(_ref164){var w=_ref164.detail;var I=w.context;n?I.blendFuncSeparate(I.ZERO,I.ZERO,I.ZERO,I.ZERO):I.globalCompositeOperation="destination-out";}),T.addEventListener("afterrender",function(_ref165){var w=_ref165.detail;var I=w.context;n?I.blendFuncSeparate(I.SRC_ALPHA,I.ONE_MINUS_SRC_ALPHA,I.ONE,I.ONE_MINUS_SRC_ALPHA):I.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 v=c.getContext("2d");v&&v.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 _v4=c.getContext("2d");_v4&&_v4.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 $u(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 v=new Jt(e[l-2],e[l-1]);h=pt.Sub(f,v).uni(),s=f;}else{l===0&&(c=f);var _v5=new Jt(e[l+2],e[l+3]);h=pt.Sub(_v5,f).uni();}if(h){var _v6=pt.Per(h).mul(t);r.push(Jt.Sub(f,_v6)),n.push(Jt.Add(f,_v6));}}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 _this60=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?sE(r,c,e):(c.remove(),_vr(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(),_vr(l,(f=_this60.drawLayer)==null?void 0:f.parent);}):this.fullLayer.getElementsByName(t).forEach(function(l){l.remove(),_vr(l,_this60.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(),_vr(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,v=r.originPoint,u=r.scenePoint,y=r.scale,T=r.pointMap,w=r.thickness;var I;var S=c&&fr(c)||n.get(t.name);if(!S)return;_e(l)&&(t.setAttribute("zIndex",l),S.opt.zIndex=l);var O=t.parent;if(O){if(v&&y&&c){var g=[S.op[0],S.op[1]];Oo(S.op,u,y,f);var p=[S.op[0],S.op[1]],x=[p[0]-g[0],p[1]-g[1]];if(S.centerPos=[S.centerPos[0]+x[0],S.centerPos[1]+x[1]],S.opt.translate=void 0,S.opt.scale=void 0,S.opt.eraserlines)for(var E=0;E<S.opt.eraserlines.length;E++){var _S$opt$eraserlines$E=S.opt.eraserlines[E],R=_S$opt$eraserlines$E.op,D=_S$opt$eraserlines$E.thickness;S.opt.eraserlines[E].thickness=Math.round(D*Math.max(y[0],y[1]));for(var U=0;U<R.length;U++)Nl(R[U],u,y,f);}}else if(f){if(t.setAttribute("translate",f),S.opt.translate=f,c){var _g6=[f[0]*O.worldScaling[0],f[1]*O.worldScaling[1]];I=Zi(S.rect,_g6),S.rect=I;}else{var _g7=Mr.getRectFromLayer(O,t.name);S.rect=_g7||S.rect;}}else if(_e(h))if(t.setAttribute("rotate",h),S.opt.rotate=h,c)I=Dl(S.rect,h),S.rect=I;else{var _g8=Mr.getRectFromLayer(O,t.name);S.rect=_g8||S.rect;}if(T){var _g9=T.get(t.name);if(_g9)for(var _p10=0,_x37=0;_p10<S.op.length;_p10+=3,_x37++)S.op[_p10]=_g9[_x37][0],S.op[_p10+1]=_g9[_x37][1];}if(w&&(d=S==null?void 0:S.opt)!=null&&d.thickness&&(S.opt.thickness=w),s&&!(v&&y&&c)){if(f){var _g10=S.op.map(function(p,x){var E=x%3;return E===0?p+f[0]:E===1?p+f[1]:p;});if(S.op=_g10,S.centerPos=[S.centerPos[0]+f[0],S.centerPos[1]+f[1]],S!=null&&S.opt&&(S.opt.translate=void 0),S.opt.eraserlines)for(var _p11=0;_p11<S.opt.eraserlines.length;_p11++){var _x38=S.opt.eraserlines[_p11].op;for(var _E7=0;_E7<_x38.length;_E7++){var _R3=_x38[_E7].map(function(D,U){return U%2?D+f[1]:D+f[0];});S.opt.eraserlines[_p11].op[_E7]=_R3;}}}else if(_e(h)){var _g11=S.op;if(QA(_g11,S.centerPos,h),S.op=_g11,S!=null&&S.opt&&(S.opt.rotate=void 0),S.opt.eraserlines)for(var _p12=0;_p12<S.opt.eraserlines.length;_p12++){var _x39=S.opt.eraserlines[_p12].op;for(var _E8=0;_E8<_x39.length;_E8++)qA(_x39[_E8],S.centerPos,h);}}}S&&n.setInfo(t.name,S);}}},{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===xt.Text&&(s.fontSize||s.translate||s.textInfos&&s.textInfos.get(n.name))||t===xt.BackgroundSVG&&(s.translate||s.scale)||t===xt.Image&&(s.angle||s.translate||s.scale||s.strokeColor&&r.type===vo.Iconify)||t===s.toolsType&&s.willRefresh||r.eraserlines&&r.eraserlines.length&&(s.strokeColor||s.fillColor));}}]);}();dt(Mr,"SafeBorderPadding",10);var Xt=Mr;var Ol=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 wl={exports:{}};wl.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 v=0;v<f.length;v++)s[f][f.charAt(v)]=v;}return s[f][h];}var l={compressToBase64:function compressToBase64(f){if(f==null)return"";var h=l._compress(f,6,function(v){return r.charAt(v);});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
+ ET(h,f)))&&l.push(h);return l;}var nh=bT,DT=Object.prototype;function NT(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||DT;return i===t;}var yl=NT;function BT(i,e){return function(t){return i(e(t));};}var ih=BT,WT=ih,FT=WT(Object.keys,Object),UT=FT,YT=yl,XT=UT,zT=Object.prototype,$T=zT.hasOwnProperty;function jT(i){if(!YT(i))return XT(i);var e=[];for(var t in Object(i))$T.call(i,t)&&t!="constructor"&&e.push(t);return e;}var GT=jT,kT=Hu,HT=eh;function VT(i){return i!=null&&HT(i.length)&&!kT(i);}var Sl=VT,KT=nh,ZT=GT,JT=Sl;function QT(i){return JT(i)?KT(i):ZT(i);}var Pl=QT,qT=Po,_T=Pl;function tC(i,e){return i&&qT(e,_T(e),i);}var eC=tC;function rC(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e;}var nC=rC,iC=qi,sC=yl,oC=nC,aC=Object.prototype,lC=aC.hasOwnProperty;function fC(i){if(!iC(i))return oC(i);var e=sC(i),t=[];for(var r in i)r=="constructor"&&(e||!lC.call(i,r))||t.push(r);return t;}var cC=fC,uC=nh,hC=cC,dC=Sl;function pC(i){return dC(i)?uC(i,!0):hC(i);}var xl=pC,vC=Po,gC=xl;function mC(i,e){return i&&vC(e,gC(e),i);}var yC=mC,no={exports:{}};no.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,v){if(v)return h.slice();var u=h.length,y=l?l(u):new h.constructor(u);return h.copy(y),y;}i.exports=f;})(no,no.exports);var SC=no.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 xC=PC;function TC(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 sh=TC;function CC(){return[];}var oh=CC,IC=sh,OC=oh,wC=Object.prototype,AC=wC.propertyIsEnumerable,tu=Object.getOwnPropertySymbols,EC=tu?function(i){return i==null?[]:(i=Object(i),IC(tu(i),function(e){return AC.call(i,e);}));}:OC,Tl=EC,MC=Po,LC=Tl;function RC(i,e){return MC(i,LC(i),e);}var bC=RC;function DC(i,e){for(var t=-1,r=e.length,n=i.length;++t<r;)i[n+t]=e[t];return i;}var Cl=DC,NC=ih,BC=NC(Object.getPrototypeOf,Object),ah=BC,WC=Cl,FC=ah,UC=Tl,YC=oh,XC=Object.getOwnPropertySymbols,zC=XC?function(i){for(var e=[];i;)WC(e,UC(i)),i=FC(i);return e;}:YC,lh=zC,$C=Po,jC=lh;function GC(i,e){return $C(i,jC(i),e);}var kC=GC,HC=Cl,VC=_i;function KC(i,e,t){var r=e(i);return VC(i)?r:HC(r,t(i));}var fh=KC,ZC=fh,JC=Tl,QC=Pl;function qC(i){return ZC(i,QC,JC);}var ch=qC,_C=fh,tI=lh,eI=xl;function rI(i){return _C(i,eI,tI);}var nI=rI,iI=Gn,sI=_r,oI=iI(sI,"DataView"),aI=oI,lI=Gn,fI=_r,cI=lI(fI,"Promise"),uI=cI,hI=Gn,dI=_r,pI=hI(dI,"Set"),uh=pI,vI=Gn,gI=_r,mI=vI(gI,"WeakMap"),yI=mI,ol=aI,al=vl,ll=uI,fl=uh,cl=yI,hh=Pi,Oi=Vu,eu="[object Map]",SI="[object Object]",ru="[object Promise]",nu="[object Set]",iu="[object WeakMap]",su="[object DataView]",PI=Oi(ol),xI=Oi(al),TI=Oi(ll),CI=Oi(fl),II=Oi(cl),zn=hh;(ol&&zn(new ol(new ArrayBuffer(1)))!=su||al&&zn(new al())!=eu||ll&&zn(ll.resolve())!=ru||fl&&zn(new fl())!=nu||cl&&zn(new cl())!=iu)&&(zn=function zn(i){var e=hh(i),t=e==SI?i.constructor:void 0,r=t?Oi(t):"";if(r)switch(r){case PI:return su;case xI:return eu;case TI:return ru;case CI:return nu;case II:return iu;}return e;});var To=zn,OI=Object.prototype,wI=OI.hasOwnProperty;function AI(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&wI.call(i,"index")&&(t.index=i.index,t.input=i.input),t;}var EI=AI,MI=_r,LI=MI.Uint8Array,dh=LI,ou=dh;function RI(i){var e=new i.constructor(i.byteLength);return new ou(e).set(new ou(i)),e;}var Il=RI,bI=Il;function DI(i,e){var t=e?bI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength);}var NI=DI,BI=/\w*$/;function WI(i){var e=new i.constructor(i.source,BI.exec(i));return e.lastIndex=i.lastIndex,e;}var FI=WI,au=Qi,lu=au?au.prototype:void 0,fu=lu?lu.valueOf:void 0;function UI(i){return fu?Object(fu.call(i)):{};}var YI=UI,XI=Il;function zI(i,e){var t=e?XI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length);}var $I=zI,jI=Il,GI=NI,kI=FI,HI=YI,VI=$I,KI="[object Boolean]",ZI="[object Date]",JI="[object Map]",QI="[object Number]",qI="[object RegExp]",_I="[object Set]",tO="[object String]",eO="[object Symbol]",rO="[object ArrayBuffer]",nO="[object DataView]",iO="[object Float32Array]",sO="[object Float64Array]",oO="[object Int8Array]",aO="[object Int16Array]",lO="[object Int32Array]",fO="[object Uint8Array]",cO="[object Uint8ClampedArray]",uO="[object Uint16Array]",hO="[object Uint32Array]";function dO(i,e,t){var r=i.constructor;switch(e){case rO:return jI(i);case KI:case ZI:return new r(+i);case nO:return GI(i,t);case iO:case sO:case oO:case aO:case lO:case fO:case cO:case uO:case hO:return VI(i,t);case JI:return new r();case QI:case tO:return new r(i);case qI:return kI(i);case _I:return new r();case eO:return HI(i);}}var pO=dO,vO=qi,cu=Object.create,gO=/* @__PURE__ */function(){function i(){}return function(e){if(!vO(e))return{};if(cu)return cu(e);i.prototype=e;var t=new i();return i.prototype=void 0,t;};}(),mO=gO,yO=mO,SO=ah,PO=yl;function xO(i){return typeof i.constructor=="function"&&!PO(i)?yO(SO(i)):{};}var TO=xO,CO=To,IO=pn,OO="[object Map]";function wO(i){return IO(i)&&CO(i)==OO;}var AO=wO,EO=AO,MO=xo,uu=ml,hu=uu&&uu.isMap,LO=hu?MO(hu):EO,RO=LO,bO=To,DO=pn,NO="[object Set]";function BO(i){return DO(i)&&bO(i)==NO;}var WO=BO,FO=WO,UO=xo,du=ml,pu=du&&du.isSet,YO=pu?UO(pu):FO,ph=YO,XO=/* @__PURE__ */Ln(ph),zO=Zu,$O=dx,jO=qu,GO=eC,kO=yC,HO=SC,VO=xC,KO=bC,ZO=kC,JO=ch,QO=nI,qO=To,_O=EI,tw=pO,ew=TO,rw=_i,nw=gl,iw=RO,sw=qi,ow=ph,aw=Pl,lw=xl,fw=1,cw=2,uw=4,vh="[object Arguments]",hw="[object Array]",dw="[object Boolean]",pw="[object Date]",vw="[object Error]",gh="[object Function]",gw="[object GeneratorFunction]",mw="[object Map]",yw="[object Number]",mh="[object Object]",Sw="[object RegExp]",Pw="[object Set]",xw="[object String]",Tw="[object Symbol]",Cw="[object WeakMap]",Iw="[object ArrayBuffer]",Ow="[object DataView]",ww="[object Float32Array]",Aw="[object Float64Array]",Ew="[object Int8Array]",Mw="[object Int16Array]",Lw="[object Int32Array]",Rw="[object Uint8Array]",bw="[object Uint8ClampedArray]",Dw="[object Uint16Array]",Nw="[object Uint32Array]",Ye={};Ye[vh]=Ye[hw]=Ye[Iw]=Ye[Ow]=Ye[dw]=Ye[pw]=Ye[ww]=Ye[Aw]=Ye[Ew]=Ye[Mw]=Ye[Lw]=Ye[mw]=Ye[yw]=Ye[mh]=Ye[Sw]=Ye[Pw]=Ye[xw]=Ye[Tw]=Ye[Rw]=Ye[bw]=Ye[Dw]=Ye[Nw]=!0;Ye[vw]=Ye[gh]=Ye[Cw]=!1;function _s(i,e,t,r,n,s){var c,l=e&fw,f=e&cw,h=e&uw;if(t&&(c=n?t(i,r,n,s):t(i)),c!==void 0)return c;if(!sw(i))return i;var v=rw(i);if(v){if(c=_O(i),!l)return VO(i,c);}else{var u=qO(i),y=u==gh||u==gw;if(nw(i))return HO(i,l);if(u==mh||u==vh||y&&!n){if(c=f||y?{}:ew(i),!l)return f?ZO(i,kO(c,i)):KO(i,GO(c,i));}else{if(!Ye[u])return n?i:{};c=tw(i,u,l);}}s||(s=new zO());var T=s.get(i);if(T)return T;s.set(i,c),ow(i)?i.forEach(function(S){c.add(_s(S,e,t,S,i,s));}):iw(i)&&i.forEach(function(S,O){c.set(O,_s(S,e,t,O,i,s));});var w=h?f?QO:JO:f?lw:aw,I=v?void 0:w(i);return $O(I||i,function(S,O){I&&(O=S,S=i[O]),jO(c,O,_s(S,e,t,O,i,s));}),c;}var Bw=_s,Ww=Bw,Fw=1,Uw=4;function Yw(i){return Ww(i,Fw|Uw);}var Xw=Yw,fr=/* @__PURE__ */Ln(Xw);var yh="1.1.34-beta.1",zw="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var i=window.__netlessUA||"";i+=" ".concat(zw,"@").concat(yh),window.__netlessUA=i;}var gr={useWorker:"auto",useSimple:!1,useBackgroundThread:!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"},undoRedo:{enableGlobal:!1,maxStackLength:20},markmap:{enable:!0,timeout:1e4,options:{autoFit:!0,duration:0,zoom:!1,pan:!1,maxInitialScale:10}}};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(ui(r),"L").concat(ui(n));var s="";for(var c=2,l=t-1;c<l;c++)r=i[c],n=i[c+1],s+=hi(r,n);return e?"M".concat(hi(i[0],i[1]),"Q").concat(ui(i[1])).concat(hi(i[1],i[2]),"T").concat(s).concat(hi(i[t-1],i[0])).concat(hi(i[0],i[1]),"Z"):"M".concat(ui(i[0]),"Q").concat(ui(i[1])).concat(hi(i[1],i[2])).concat(i.length>3?"T":"").concat(s,"L").concat(ui(i[t-1]));}var Mr=/*#__PURE__*/function(){function Mr(e){_classCallCheck(this,Mr);dt(this,"maxImageWidth",gr.pencilEraser.maxImageWidth);dt(this,"maxImageHeight",gr.pencilEraser.maxImageHeight);dt(this,"syncUnitTime",gr.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,v=e.scale,u=e.angle,y=e.translate,T={};_e(h)&&(T.zIndex=h),f&&(T.pos=[f[0],f[1]]),v&&(T.scale=v),u&&(T.rotate=u),y&&(T.translate=y),l.attr(T);var w=l==null?void 0:l.getBoundingClientRect();return w&&(t=Zt(t,{x:Math.floor(w.x-Mr.SafeBorderPadding),y:Math.floor(w.y-Mr.SafeBorderPadding),w:Math.floor(w.width+Mr.SafeBorderPadding*2),h:Math.floor(w.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,v=r.getBoundingClientRect(),u=v.width*h*c.worldScaling[0],y=v.height*h*c.worldScaling[1];var T=1;(u>this.maxImageWidth||y>this.maxImageHeight)&&(T=Math.min(this.maxImageWidth/u,this.maxImageHeight/y));var w=c.getAttribute("scale");w=[w[0]*T,w[1]*T];var I=c.parent.parent,S=c.getAttribute("translate"),_O30=this.createVmRenderNode("".concat(this.workId,"_bitMapLayer"),I,{offscreen:l.offscreen,width:l.width,height:l.height,contextType:"2d",autoRender:!1,bufferSize:500},w,S),_d30=r.cloneNode(!0);if(!n||!n.length)return;this.addEraserlines(_d30,n,s,!1),_O30.appendChild(_d30);var g=_O30.parent;g.render();var p=_O30.renderer.canvasRenderer,x=p.context;if(!x)return;var E=p.options.displayRatio,R=_d30.getBoundingClientRect(),D={x:R.x,y:R.y,w:R.width,h:R.height},U={x:0,y:0,w:I.width,h:I.height};if(Ji(D,U)===Tr.outside){Lr(_d30,g),I.removeChild(g),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,I.width)-W.x,W.h=Math.min(D.y+D.h,I.height)-W.y;var X=this.getGroupRect(W,E),B=X.x,N=X.y,$=X.w,J=X.h;var tt=x.getImageData(B,N,$,J);if(this.isTransparentRectByCanvas(tt)){Lr(_d30,g),I.removeChild(g),this.isDelete=!0,tt=null;return;}Lr(r,l);var ut=this.createSpriteNode({imageData:tt,safariRect:W,originRect:D,worldScaling:_O30.worldScaling});ut&&r.append(ut),Lr(_d30,g),I.removeChild(g),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),v=new cr({anchor:[0.5,0.5],pos:[c*0.5,l*0.5],size:[c,l],name:"viewport",id:e});return v.setAttribute("scale",n),v.setAttribute("translate",s),h.append(v),v;}},{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(w,I){return I%2?w-r[1]:w-r[0];}),v=this.computEraserPoints(h,c),u=En(v,!0),y={pos:[0,0],d:u,fillColor:"rgba(0,0,0,1)"},T=new Mn(y);T.addEventListener("beforerender",function(_ref164){var w=_ref164.detail;var I=w.context;n?I.blendFuncSeparate(I.ZERO,I.ZERO,I.ZERO,I.ZERO):I.globalCompositeOperation="destination-out";}),T.addEventListener("afterrender",function(_ref165){var w=_ref165.detail;var I=w.context;n?I.blendFuncSeparate(I.SRC_ALPHA,I.ONE_MINUS_SRC_ALPHA,I.ONE,I.ONE_MINUS_SRC_ALPHA):I.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 v=c.getContext("2d");v&&v.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 _v4=c.getContext("2d");_v4&&_v4.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 $u(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 v=new Jt(e[l-2],e[l-1]);h=pt.Sub(f,v).uni(),s=f;}else{l===0&&(c=f);var _v5=new Jt(e[l+2],e[l+3]);h=pt.Sub(_v5,f).uni();}if(h){var _v6=pt.Per(h).mul(t);r.push(Jt.Sub(f,_v6)),n.push(Jt.Add(f,_v6));}}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 _this60=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?sE(r,c,e):(c.remove(),_vr(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(),_vr(l,(f=_this60.drawLayer)==null?void 0:f.parent);}):this.fullLayer.getElementsByName(t).forEach(function(l){l.remove(),_vr(l,_this60.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(),_vr(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,v=r.originPoint,u=r.scenePoint,y=r.scale,T=r.pointMap,w=r.thickness;var I;var S=c&&fr(c)||n.get(t.name);if(!S)return;_e(l)&&(t.setAttribute("zIndex",l),S.opt.zIndex=l);var O=t.parent;if(O){if(v&&y&&c){var g=[S.op[0],S.op[1]];Oo(S.op,u,y,f);var p=[S.op[0],S.op[1]],x=[p[0]-g[0],p[1]-g[1]];if(S.centerPos=[S.centerPos[0]+x[0],S.centerPos[1]+x[1]],S.opt.translate=void 0,S.opt.scale=void 0,S.opt.eraserlines)for(var E=0;E<S.opt.eraserlines.length;E++){var _S$opt$eraserlines$E=S.opt.eraserlines[E],R=_S$opt$eraserlines$E.op,D=_S$opt$eraserlines$E.thickness;S.opt.eraserlines[E].thickness=Math.round(D*Math.max(y[0],y[1]));for(var U=0;U<R.length;U++)Nl(R[U],u,y,f);}}else if(f){if(t.setAttribute("translate",f),S.opt.translate=f,c){var _g6=[f[0]*O.worldScaling[0],f[1]*O.worldScaling[1]];I=Zi(S.rect,_g6),S.rect=I;}else{var _g7=Mr.getRectFromLayer(O,t.name);S.rect=_g7||S.rect;}}else if(_e(h))if(t.setAttribute("rotate",h),S.opt.rotate=h,c)I=Dl(S.rect,h),S.rect=I;else{var _g8=Mr.getRectFromLayer(O,t.name);S.rect=_g8||S.rect;}if(T){var _g9=T.get(t.name);if(_g9)for(var _p10=0,_x37=0;_p10<S.op.length;_p10+=3,_x37++)S.op[_p10]=_g9[_x37][0],S.op[_p10+1]=_g9[_x37][1];}if(w&&(d=S==null?void 0:S.opt)!=null&&d.thickness&&(S.opt.thickness=w),s&&!(v&&y&&c)){if(f){var _g10=S.op.map(function(p,x){var E=x%3;return E===0?p+f[0]:E===1?p+f[1]:p;});if(S.op=_g10,S.centerPos=[S.centerPos[0]+f[0],S.centerPos[1]+f[1]],S!=null&&S.opt&&(S.opt.translate=void 0),S.opt.eraserlines)for(var _p11=0;_p11<S.opt.eraserlines.length;_p11++){var _x38=S.opt.eraserlines[_p11].op;for(var _E7=0;_E7<_x38.length;_E7++){var _R3=_x38[_E7].map(function(D,U){return U%2?D+f[1]:D+f[0];});S.opt.eraserlines[_p11].op[_E7]=_R3;}}}else if(_e(h)){var _g11=S.op;if(QA(_g11,S.centerPos,h),S.op=_g11,S!=null&&S.opt&&(S.opt.rotate=void 0),S.opt.eraserlines)for(var _p12=0;_p12<S.opt.eraserlines.length;_p12++){var _x39=S.opt.eraserlines[_p12].op;for(var _E8=0;_E8<_x39.length;_E8++)qA(_x39[_E8],S.centerPos,h);}}}S&&n.setInfo(t.name,S);}}},{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===xt.Text&&(s.fontSize||s.translate||s.textInfos&&s.textInfos.get(n.name))||t===xt.BackgroundSVG&&(s.translate||s.scale)||t===xt.Image&&(s.angle||s.translate||s.scale||s.strokeColor&&r.type===vo.Iconify)||t===s.toolsType&&s.willRefresh||r.eraserlines&&r.eraserlines.length&&(s.strokeColor||s.fillColor));}}]);}();dt(Mr,"SafeBorderPadding",10);var Xt=Mr;var Ol=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 wl={exports:{}};wl.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 v=0;v<f.length;v++)s[f][f.charAt(v)]=v;}return s[f][h];}var l={compressToBase64:function compressToBase64(f){if(f==null)return"";var h=l._compress(f,6,function(v){return r.charAt(v);});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),v=new Uint8Array(h.length*2),u=0,y=h.length;u<y;u++){var T=h.charCodeAt(u);v[u*2]=T>>>8,v[u*2+1]=T%256;}return v;},//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),v=0,u=h.length;v<u;v++)h[v]=f[v*2]*256+f[v*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-DjSg1GK5.js");exports.ActiveContainerType=e.ActiveContainerType;exports.ApplianceMultiPlugin=e.ApplianceMultiPlugin;exports.ApplianceNames=e.ApplianceNames;exports.ApplianceSigleWrapper=e.ApplianceSigleWrapper;exports.ApplianceSinglePlugin=e.ApplianceSinglePlugin;exports.Cursor_Hover_Id=e.Cursor_Hover_Id;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.ESVGType=e.ESVGType;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.EventWorkState=e.EventWorkState;exports.EvevtWorkState=e.EventWorkState;exports.InternalMsgEmitterType=e.InternalMsgEmitterType;exports.Main_View_Id=e.Main_View_Id;exports.Plugin=e.Plugin;exports.ShapeType=e.ShapeType;exports.Task_Time_Interval=e.Task_Time_Interval;exports.fullWorkerUrl=e.fullWorker;exports.subWorkerUrl=e.subWorker;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DL5KtEyz.js");exports.ActiveContainerType=e.ActiveContainerType;exports.ApplianceMultiPlugin=e.ApplianceMultiPlugin;exports.ApplianceNames=e.ApplianceNames;exports.ApplianceSigleWrapper=e.ApplianceSigleWrapper;exports.ApplianceSinglePlugin=e.ApplianceSinglePlugin;exports.Cursor_Hover_Id=e.Cursor_Hover_Id;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.ESVGType=e.ESVGType;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.EventWorkState=e.EventWorkState;exports.EvevtWorkState=e.EventWorkState;exports.InternalMsgEmitterType=e.InternalMsgEmitterType;exports.Main_View_Id=e.Main_View_Id;exports.Plugin=e.Plugin;exports.ShapeType=e.ShapeType;exports.Task_Time_Interval=e.Task_Time_Interval;exports.fullWorkerUrl=e.fullWorker;exports.subWorkerUrl=e.subWorker;
@@ -1,4 +1,4 @@
1
- import { af as s, a9 as p, ac as r, ab as t, aa as i, a4 as l, Z as n, b as E, ag as o, t as T, j as y, aj as v, a as g, ak as S, d as c, u, w as k, c as m, ai as M, E as _, ah as d, v as A, v as I, ae as W, Y as P, al as b, ad as f, a6 as h, a7 as w, a8 as C } from "./index-B5PYiw1o.mjs";
1
+ import { af as s, a9 as p, ac as r, ab as t, aa as i, a4 as l, Z as n, b as E, ag as o, t as T, j as y, aj as v, a as g, ak as S, d as c, u, w as k, c as m, ai as M, E as _, ah as d, v as A, v as I, ae as W, Y as P, al as b, ad as f, a6 as h, a7 as w, a8 as C } from "./index-HXQHn0xU.mjs";
2
2
  export {
3
3
  s as ActiveContainerType,
4
4
  p as ApplianceMultiPlugin,
@@ -26,6 +26,7 @@ export declare class Collector extends BaseCollector<ISerializableStorageViewDat
26
26
  private limitNums;
27
27
  private syncInterval;
28
28
  constructor(control: BaseApplianceManager, plugin: AppliancePluginLike, syncInterval: number);
29
+ get Logger(): import("..").Logger;
29
30
  hasId(viewId: string, scenePath: string, key: string): boolean;
30
31
  private getLimitNum;
31
32
  private getLimitNums;
@@ -164,6 +164,7 @@ export declare class MasterControlForWorker extends MasterController {
164
164
  private markmapIdResolveMap;
165
165
  constructor(props: BaseSubWorkModuleProps);
166
166
  get isBezier(): boolean;
167
+ get Logger(): import("..").Logger;
167
168
  destroy(): void;
168
169
  private get consumeCount();
169
170
  private set consumeCount(value);
@@ -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
- ET(h,f)))&&l.push(h);return l;}var nh=bT,DT=Object.prototype;function NT(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||DT;return i===t;}var yl=NT;function BT(i,e){return function(t){return i(e(t));};}var ih=BT,WT=ih,FT=WT(Object.keys,Object),UT=FT,YT=yl,XT=UT,zT=Object.prototype,$T=zT.hasOwnProperty;function jT(i){if(!YT(i))return XT(i);var e=[];for(var t in Object(i))$T.call(i,t)&&t!="constructor"&&e.push(t);return e;}var GT=jT,kT=Hu,HT=eh;function VT(i){return i!=null&&HT(i.length)&&!kT(i);}var Sl=VT,KT=nh,ZT=GT,JT=Sl;function QT(i){return JT(i)?KT(i):ZT(i);}var Pl=QT,qT=Po,_T=Pl;function tC(i,e){return i&&qT(e,_T(e),i);}var eC=tC;function rC(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e;}var nC=rC,iC=qi,sC=yl,oC=nC,aC=Object.prototype,lC=aC.hasOwnProperty;function fC(i){if(!iC(i))return oC(i);var e=sC(i),t=[];for(var r in i)r=="constructor"&&(e||!lC.call(i,r))||t.push(r);return t;}var cC=fC,uC=nh,hC=cC,dC=Sl;function pC(i){return dC(i)?uC(i,!0):hC(i);}var xl=pC,vC=Po,gC=xl;function mC(i,e){return i&&vC(e,gC(e),i);}var yC=mC,no={exports:{}};no.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,v){if(v)return h.slice();var u=h.length,y=l?l(u):new h.constructor(u);return h.copy(y),y;}i.exports=f;})(no,no.exports);var SC=no.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 xC=PC;function TC(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 sh=TC;function CC(){return[];}var oh=CC,IC=sh,OC=oh,wC=Object.prototype,AC=wC.propertyIsEnumerable,tu=Object.getOwnPropertySymbols,EC=tu?function(i){return i==null?[]:(i=Object(i),IC(tu(i),function(e){return AC.call(i,e);}));}:OC,Tl=EC,MC=Po,LC=Tl;function RC(i,e){return MC(i,LC(i),e);}var bC=RC;function DC(i,e){for(var t=-1,r=e.length,n=i.length;++t<r;)i[n+t]=e[t];return i;}var Cl=DC,NC=ih,BC=NC(Object.getPrototypeOf,Object),ah=BC,WC=Cl,FC=ah,UC=Tl,YC=oh,XC=Object.getOwnPropertySymbols,zC=XC?function(i){for(var e=[];i;)WC(e,UC(i)),i=FC(i);return e;}:YC,lh=zC,$C=Po,jC=lh;function GC(i,e){return $C(i,jC(i),e);}var kC=GC,HC=Cl,VC=_i;function KC(i,e,t){var r=e(i);return VC(i)?r:HC(r,t(i));}var fh=KC,ZC=fh,JC=Tl,QC=Pl;function qC(i){return ZC(i,QC,JC);}var ch=qC,_C=fh,tI=lh,eI=xl;function rI(i){return _C(i,eI,tI);}var nI=rI,iI=Gn,sI=_r,oI=iI(sI,"DataView"),aI=oI,lI=Gn,fI=_r,cI=lI(fI,"Promise"),uI=cI,hI=Gn,dI=_r,pI=hI(dI,"Set"),uh=pI,vI=Gn,gI=_r,mI=vI(gI,"WeakMap"),yI=mI,ol=aI,al=vl,ll=uI,fl=uh,cl=yI,hh=Pi,Oi=Vu,eu="[object Map]",SI="[object Object]",ru="[object Promise]",nu="[object Set]",iu="[object WeakMap]",su="[object DataView]",PI=Oi(ol),xI=Oi(al),TI=Oi(ll),CI=Oi(fl),II=Oi(cl),zn=hh;(ol&&zn(new ol(new ArrayBuffer(1)))!=su||al&&zn(new al())!=eu||ll&&zn(ll.resolve())!=ru||fl&&zn(new fl())!=nu||cl&&zn(new cl())!=iu)&&(zn=function zn(i){var e=hh(i),t=e==SI?i.constructor:void 0,r=t?Oi(t):"";if(r)switch(r){case PI:return su;case xI:return eu;case TI:return ru;case CI:return nu;case II:return iu;}return e;});var To=zn,OI=Object.prototype,wI=OI.hasOwnProperty;function AI(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&wI.call(i,"index")&&(t.index=i.index,t.input=i.input),t;}var EI=AI,MI=_r,LI=MI.Uint8Array,dh=LI,ou=dh;function RI(i){var e=new i.constructor(i.byteLength);return new ou(e).set(new ou(i)),e;}var Il=RI,bI=Il;function DI(i,e){var t=e?bI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength);}var NI=DI,BI=/\w*$/;function WI(i){var e=new i.constructor(i.source,BI.exec(i));return e.lastIndex=i.lastIndex,e;}var FI=WI,au=Qi,lu=au?au.prototype:void 0,fu=lu?lu.valueOf:void 0;function UI(i){return fu?Object(fu.call(i)):{};}var YI=UI,XI=Il;function zI(i,e){var t=e?XI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length);}var $I=zI,jI=Il,GI=NI,kI=FI,HI=YI,VI=$I,KI="[object Boolean]",ZI="[object Date]",JI="[object Map]",QI="[object Number]",qI="[object RegExp]",_I="[object Set]",tO="[object String]",eO="[object Symbol]",rO="[object ArrayBuffer]",nO="[object DataView]",iO="[object Float32Array]",sO="[object Float64Array]",oO="[object Int8Array]",aO="[object Int16Array]",lO="[object Int32Array]",fO="[object Uint8Array]",cO="[object Uint8ClampedArray]",uO="[object Uint16Array]",hO="[object Uint32Array]";function dO(i,e,t){var r=i.constructor;switch(e){case rO:return jI(i);case KI:case ZI:return new r(+i);case nO:return GI(i,t);case iO:case sO:case oO:case aO:case lO:case fO:case cO:case uO:case hO:return VI(i,t);case JI:return new r();case QI:case tO:return new r(i);case qI:return kI(i);case _I:return new r();case eO:return HI(i);}}var pO=dO,vO=qi,cu=Object.create,gO=/* @__PURE__ */function(){function i(){}return function(e){if(!vO(e))return{};if(cu)return cu(e);i.prototype=e;var t=new i();return i.prototype=void 0,t;};}(),mO=gO,yO=mO,SO=ah,PO=yl;function xO(i){return typeof i.constructor=="function"&&!PO(i)?yO(SO(i)):{};}var TO=xO,CO=To,IO=pn,OO="[object Map]";function wO(i){return IO(i)&&CO(i)==OO;}var AO=wO,EO=AO,MO=xo,uu=ml,hu=uu&&uu.isMap,LO=hu?MO(hu):EO,RO=LO,bO=To,DO=pn,NO="[object Set]";function BO(i){return DO(i)&&bO(i)==NO;}var WO=BO,FO=WO,UO=xo,du=ml,pu=du&&du.isSet,YO=pu?UO(pu):FO,ph=YO,XO=/* @__PURE__ */Ln(ph),zO=Zu,$O=dx,jO=qu,GO=eC,kO=yC,HO=SC,VO=xC,KO=bC,ZO=kC,JO=ch,QO=nI,qO=To,_O=EI,tw=pO,ew=TO,rw=_i,nw=gl,iw=RO,sw=qi,ow=ph,aw=Pl,lw=xl,fw=1,cw=2,uw=4,vh="[object Arguments]",hw="[object Array]",dw="[object Boolean]",pw="[object Date]",vw="[object Error]",gh="[object Function]",gw="[object GeneratorFunction]",mw="[object Map]",yw="[object Number]",mh="[object Object]",Sw="[object RegExp]",Pw="[object Set]",xw="[object String]",Tw="[object Symbol]",Cw="[object WeakMap]",Iw="[object ArrayBuffer]",Ow="[object DataView]",ww="[object Float32Array]",Aw="[object Float64Array]",Ew="[object Int8Array]",Mw="[object Int16Array]",Lw="[object Int32Array]",Rw="[object Uint8Array]",bw="[object Uint8ClampedArray]",Dw="[object Uint16Array]",Nw="[object Uint32Array]",Ye={};Ye[vh]=Ye[hw]=Ye[Iw]=Ye[Ow]=Ye[dw]=Ye[pw]=Ye[ww]=Ye[Aw]=Ye[Ew]=Ye[Mw]=Ye[Lw]=Ye[mw]=Ye[yw]=Ye[mh]=Ye[Sw]=Ye[Pw]=Ye[xw]=Ye[Tw]=Ye[Rw]=Ye[bw]=Ye[Dw]=Ye[Nw]=!0;Ye[vw]=Ye[gh]=Ye[Cw]=!1;function _s(i,e,t,r,n,s){var c,l=e&fw,f=e&cw,h=e&uw;if(t&&(c=n?t(i,r,n,s):t(i)),c!==void 0)return c;if(!sw(i))return i;var v=rw(i);if(v){if(c=_O(i),!l)return VO(i,c);}else{var u=qO(i),y=u==gh||u==gw;if(nw(i))return HO(i,l);if(u==mh||u==vh||y&&!n){if(c=f||y?{}:ew(i),!l)return f?ZO(i,kO(c,i)):KO(i,GO(c,i));}else{if(!Ye[u])return n?i:{};c=tw(i,u,l);}}s||(s=new zO());var T=s.get(i);if(T)return T;s.set(i,c),ow(i)?i.forEach(function(S){c.add(_s(S,e,t,S,i,s));}):iw(i)&&i.forEach(function(S,O){c.set(O,_s(S,e,t,O,i,s));});var w=h?f?QO:JO:f?lw:aw,I=v?void 0:w(i);return $O(I||i,function(S,O){I&&(O=S,S=i[O]),jO(c,O,_s(S,e,t,O,i,s));}),c;}var Bw=_s,Ww=Bw,Fw=1,Uw=4;function Yw(i){return Ww(i,Fw|Uw);}var Xw=Yw,fr=/* @__PURE__ */Ln(Xw);var yh="1.1.34-beta.0",zw="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var i=window.__netlessUA||"";i+=" ".concat(zw,"@").concat(yh),window.__netlessUA=i;}var gr={useWorker:"auto",useSimple:!1,useBackgroundThread:!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"},undoRedo:{enableGlobal:!1,maxStackLength:20},markmap:{enable:!0,timeout:1e4,options:{autoFit:!0,duration:0,zoom:!1,pan:!1,maxInitialScale:10}}};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(ui(r),"L").concat(ui(n));var s="";for(var c=2,l=t-1;c<l;c++)r=i[c],n=i[c+1],s+=hi(r,n);return e?"M".concat(hi(i[0],i[1]),"Q").concat(ui(i[1])).concat(hi(i[1],i[2]),"T").concat(s).concat(hi(i[t-1],i[0])).concat(hi(i[0],i[1]),"Z"):"M".concat(ui(i[0]),"Q").concat(ui(i[1])).concat(hi(i[1],i[2])).concat(i.length>3?"T":"").concat(s,"L").concat(ui(i[t-1]));}var Mr=/*#__PURE__*/function(){function Mr(e){_classCallCheck(this,Mr);dt(this,"maxImageWidth",gr.pencilEraser.maxImageWidth);dt(this,"maxImageHeight",gr.pencilEraser.maxImageHeight);dt(this,"syncUnitTime",gr.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,v=e.scale,u=e.angle,y=e.translate,T={};_e(h)&&(T.zIndex=h),f&&(T.pos=[f[0],f[1]]),v&&(T.scale=v),u&&(T.rotate=u),y&&(T.translate=y),l.attr(T);var w=l==null?void 0:l.getBoundingClientRect();return w&&(t=Zt(t,{x:Math.floor(w.x-Mr.SafeBorderPadding),y:Math.floor(w.y-Mr.SafeBorderPadding),w:Math.floor(w.width+Mr.SafeBorderPadding*2),h:Math.floor(w.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,v=r.getBoundingClientRect(),u=v.width*h*c.worldScaling[0],y=v.height*h*c.worldScaling[1];var T=1;(u>this.maxImageWidth||y>this.maxImageHeight)&&(T=Math.min(this.maxImageWidth/u,this.maxImageHeight/y));var w=c.getAttribute("scale");w=[w[0]*T,w[1]*T];var I=c.parent.parent,S=c.getAttribute("translate"),_O30=this.createVmRenderNode("".concat(this.workId,"_bitMapLayer"),I,{offscreen:l.offscreen,width:l.width,height:l.height,contextType:"2d",autoRender:!1,bufferSize:500},w,S),_d30=r.cloneNode(!0);if(!n||!n.length)return;this.addEraserlines(_d30,n,s,!1),_O30.appendChild(_d30);var g=_O30.parent;g.render();var p=_O30.renderer.canvasRenderer,x=p.context;if(!x)return;var E=p.options.displayRatio,R=_d30.getBoundingClientRect(),D={x:R.x,y:R.y,w:R.width,h:R.height},U={x:0,y:0,w:I.width,h:I.height};if(Ji(D,U)===Tr.outside){Lr(_d30,g),I.removeChild(g),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,I.width)-W.x,W.h=Math.min(D.y+D.h,I.height)-W.y;var X=this.getGroupRect(W,E),B=X.x,N=X.y,$=X.w,J=X.h;var tt=x.getImageData(B,N,$,J);if(this.isTransparentRectByCanvas(tt)){Lr(_d30,g),I.removeChild(g),this.isDelete=!0,tt=null;return;}Lr(r,l);var ut=this.createSpriteNode({imageData:tt,safariRect:W,originRect:D,worldScaling:_O30.worldScaling});ut&&r.append(ut),Lr(_d30,g),I.removeChild(g),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),v=new cr({anchor:[0.5,0.5],pos:[c*0.5,l*0.5],size:[c,l],name:"viewport",id:e});return v.setAttribute("scale",n),v.setAttribute("translate",s),h.append(v),v;}},{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(w,I){return I%2?w-r[1]:w-r[0];}),v=this.computEraserPoints(h,c),u=En(v,!0),y={pos:[0,0],d:u,fillColor:"rgba(0,0,0,1)"},T=new Mn(y);T.addEventListener("beforerender",function(_ref164){var w=_ref164.detail;var I=w.context;n?I.blendFuncSeparate(I.ZERO,I.ZERO,I.ZERO,I.ZERO):I.globalCompositeOperation="destination-out";}),T.addEventListener("afterrender",function(_ref165){var w=_ref165.detail;var I=w.context;n?I.blendFuncSeparate(I.SRC_ALPHA,I.ONE_MINUS_SRC_ALPHA,I.ONE,I.ONE_MINUS_SRC_ALPHA):I.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 v=c.getContext("2d");v&&v.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 _v4=c.getContext("2d");_v4&&_v4.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 $u(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 v=new Jt(e[l-2],e[l-1]);h=pt.Sub(f,v).uni(),s=f;}else{l===0&&(c=f);var _v5=new Jt(e[l+2],e[l+3]);h=pt.Sub(_v5,f).uni();}if(h){var _v6=pt.Per(h).mul(t);r.push(Jt.Sub(f,_v6)),n.push(Jt.Add(f,_v6));}}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 _this60=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?sE(r,c,e):(c.remove(),_vr(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(),_vr(l,(f=_this60.drawLayer)==null?void 0:f.parent);}):this.fullLayer.getElementsByName(t).forEach(function(l){l.remove(),_vr(l,_this60.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(),_vr(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,v=r.originPoint,u=r.scenePoint,y=r.scale,T=r.pointMap,w=r.thickness;var I;var S=c&&fr(c)||n.get(t.name);if(!S)return;_e(l)&&(t.setAttribute("zIndex",l),S.opt.zIndex=l);var O=t.parent;if(O){if(v&&y&&c){var g=[S.op[0],S.op[1]];Oo(S.op,u,y,f);var p=[S.op[0],S.op[1]],x=[p[0]-g[0],p[1]-g[1]];if(S.centerPos=[S.centerPos[0]+x[0],S.centerPos[1]+x[1]],S.opt.translate=void 0,S.opt.scale=void 0,S.opt.eraserlines)for(var E=0;E<S.opt.eraserlines.length;E++){var _S$opt$eraserlines$E=S.opt.eraserlines[E],R=_S$opt$eraserlines$E.op,D=_S$opt$eraserlines$E.thickness;S.opt.eraserlines[E].thickness=Math.round(D*Math.max(y[0],y[1]));for(var U=0;U<R.length;U++)Nl(R[U],u,y,f);}}else if(f){if(t.setAttribute("translate",f),S.opt.translate=f,c){var _g6=[f[0]*O.worldScaling[0],f[1]*O.worldScaling[1]];I=Zi(S.rect,_g6),S.rect=I;}else{var _g7=Mr.getRectFromLayer(O,t.name);S.rect=_g7||S.rect;}}else if(_e(h))if(t.setAttribute("rotate",h),S.opt.rotate=h,c)I=Dl(S.rect,h),S.rect=I;else{var _g8=Mr.getRectFromLayer(O,t.name);S.rect=_g8||S.rect;}if(T){var _g9=T.get(t.name);if(_g9)for(var _p10=0,_x37=0;_p10<S.op.length;_p10+=3,_x37++)S.op[_p10]=_g9[_x37][0],S.op[_p10+1]=_g9[_x37][1];}if(w&&(d=S==null?void 0:S.opt)!=null&&d.thickness&&(S.opt.thickness=w),s&&!(v&&y&&c)){if(f){var _g10=S.op.map(function(p,x){var E=x%3;return E===0?p+f[0]:E===1?p+f[1]:p;});if(S.op=_g10,S.centerPos=[S.centerPos[0]+f[0],S.centerPos[1]+f[1]],S!=null&&S.opt&&(S.opt.translate=void 0),S.opt.eraserlines)for(var _p11=0;_p11<S.opt.eraserlines.length;_p11++){var _x38=S.opt.eraserlines[_p11].op;for(var _E7=0;_E7<_x38.length;_E7++){var _R3=_x38[_E7].map(function(D,U){return U%2?D+f[1]:D+f[0];});S.opt.eraserlines[_p11].op[_E7]=_R3;}}}else if(_e(h)){var _g11=S.op;if(QA(_g11,S.centerPos,h),S.op=_g11,S!=null&&S.opt&&(S.opt.rotate=void 0),S.opt.eraserlines)for(var _p12=0;_p12<S.opt.eraserlines.length;_p12++){var _x39=S.opt.eraserlines[_p12].op;for(var _E8=0;_E8<_x39.length;_E8++)qA(_x39[_E8],S.centerPos,h);}}}S&&n.setInfo(t.name,S);}}},{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===xt.Text&&(s.fontSize||s.translate||s.textInfos&&s.textInfos.get(n.name))||t===xt.BackgroundSVG&&(s.translate||s.scale)||t===xt.Image&&(s.angle||s.translate||s.scale||s.strokeColor&&r.type===vo.Iconify)||t===s.toolsType&&s.willRefresh||r.eraserlines&&r.eraserlines.length&&(s.strokeColor||s.fillColor));}}]);}();dt(Mr,"SafeBorderPadding",10);var Xt=Mr;var Ol=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 wl={exports:{}};wl.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 v=0;v<f.length;v++)s[f][f.charAt(v)]=v;}return s[f][h];}var l={compressToBase64:function compressToBase64(f){if(f==null)return"";var h=l._compress(f,6,function(v){return r.charAt(v);});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
+ ET(h,f)))&&l.push(h);return l;}var nh=bT,DT=Object.prototype;function NT(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||DT;return i===t;}var yl=NT;function BT(i,e){return function(t){return i(e(t));};}var ih=BT,WT=ih,FT=WT(Object.keys,Object),UT=FT,YT=yl,XT=UT,zT=Object.prototype,$T=zT.hasOwnProperty;function jT(i){if(!YT(i))return XT(i);var e=[];for(var t in Object(i))$T.call(i,t)&&t!="constructor"&&e.push(t);return e;}var GT=jT,kT=Hu,HT=eh;function VT(i){return i!=null&&HT(i.length)&&!kT(i);}var Sl=VT,KT=nh,ZT=GT,JT=Sl;function QT(i){return JT(i)?KT(i):ZT(i);}var Pl=QT,qT=Po,_T=Pl;function tC(i,e){return i&&qT(e,_T(e),i);}var eC=tC;function rC(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e;}var nC=rC,iC=qi,sC=yl,oC=nC,aC=Object.prototype,lC=aC.hasOwnProperty;function fC(i){if(!iC(i))return oC(i);var e=sC(i),t=[];for(var r in i)r=="constructor"&&(e||!lC.call(i,r))||t.push(r);return t;}var cC=fC,uC=nh,hC=cC,dC=Sl;function pC(i){return dC(i)?uC(i,!0):hC(i);}var xl=pC,vC=Po,gC=xl;function mC(i,e){return i&&vC(e,gC(e),i);}var yC=mC,no={exports:{}};no.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,v){if(v)return h.slice();var u=h.length,y=l?l(u):new h.constructor(u);return h.copy(y),y;}i.exports=f;})(no,no.exports);var SC=no.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 xC=PC;function TC(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 sh=TC;function CC(){return[];}var oh=CC,IC=sh,OC=oh,wC=Object.prototype,AC=wC.propertyIsEnumerable,tu=Object.getOwnPropertySymbols,EC=tu?function(i){return i==null?[]:(i=Object(i),IC(tu(i),function(e){return AC.call(i,e);}));}:OC,Tl=EC,MC=Po,LC=Tl;function RC(i,e){return MC(i,LC(i),e);}var bC=RC;function DC(i,e){for(var t=-1,r=e.length,n=i.length;++t<r;)i[n+t]=e[t];return i;}var Cl=DC,NC=ih,BC=NC(Object.getPrototypeOf,Object),ah=BC,WC=Cl,FC=ah,UC=Tl,YC=oh,XC=Object.getOwnPropertySymbols,zC=XC?function(i){for(var e=[];i;)WC(e,UC(i)),i=FC(i);return e;}:YC,lh=zC,$C=Po,jC=lh;function GC(i,e){return $C(i,jC(i),e);}var kC=GC,HC=Cl,VC=_i;function KC(i,e,t){var r=e(i);return VC(i)?r:HC(r,t(i));}var fh=KC,ZC=fh,JC=Tl,QC=Pl;function qC(i){return ZC(i,QC,JC);}var ch=qC,_C=fh,tI=lh,eI=xl;function rI(i){return _C(i,eI,tI);}var nI=rI,iI=Gn,sI=_r,oI=iI(sI,"DataView"),aI=oI,lI=Gn,fI=_r,cI=lI(fI,"Promise"),uI=cI,hI=Gn,dI=_r,pI=hI(dI,"Set"),uh=pI,vI=Gn,gI=_r,mI=vI(gI,"WeakMap"),yI=mI,ol=aI,al=vl,ll=uI,fl=uh,cl=yI,hh=Pi,Oi=Vu,eu="[object Map]",SI="[object Object]",ru="[object Promise]",nu="[object Set]",iu="[object WeakMap]",su="[object DataView]",PI=Oi(ol),xI=Oi(al),TI=Oi(ll),CI=Oi(fl),II=Oi(cl),zn=hh;(ol&&zn(new ol(new ArrayBuffer(1)))!=su||al&&zn(new al())!=eu||ll&&zn(ll.resolve())!=ru||fl&&zn(new fl())!=nu||cl&&zn(new cl())!=iu)&&(zn=function zn(i){var e=hh(i),t=e==SI?i.constructor:void 0,r=t?Oi(t):"";if(r)switch(r){case PI:return su;case xI:return eu;case TI:return ru;case CI:return nu;case II:return iu;}return e;});var To=zn,OI=Object.prototype,wI=OI.hasOwnProperty;function AI(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&wI.call(i,"index")&&(t.index=i.index,t.input=i.input),t;}var EI=AI,MI=_r,LI=MI.Uint8Array,dh=LI,ou=dh;function RI(i){var e=new i.constructor(i.byteLength);return new ou(e).set(new ou(i)),e;}var Il=RI,bI=Il;function DI(i,e){var t=e?bI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength);}var NI=DI,BI=/\w*$/;function WI(i){var e=new i.constructor(i.source,BI.exec(i));return e.lastIndex=i.lastIndex,e;}var FI=WI,au=Qi,lu=au?au.prototype:void 0,fu=lu?lu.valueOf:void 0;function UI(i){return fu?Object(fu.call(i)):{};}var YI=UI,XI=Il;function zI(i,e){var t=e?XI(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length);}var $I=zI,jI=Il,GI=NI,kI=FI,HI=YI,VI=$I,KI="[object Boolean]",ZI="[object Date]",JI="[object Map]",QI="[object Number]",qI="[object RegExp]",_I="[object Set]",tO="[object String]",eO="[object Symbol]",rO="[object ArrayBuffer]",nO="[object DataView]",iO="[object Float32Array]",sO="[object Float64Array]",oO="[object Int8Array]",aO="[object Int16Array]",lO="[object Int32Array]",fO="[object Uint8Array]",cO="[object Uint8ClampedArray]",uO="[object Uint16Array]",hO="[object Uint32Array]";function dO(i,e,t){var r=i.constructor;switch(e){case rO:return jI(i);case KI:case ZI:return new r(+i);case nO:return GI(i,t);case iO:case sO:case oO:case aO:case lO:case fO:case cO:case uO:case hO:return VI(i,t);case JI:return new r();case QI:case tO:return new r(i);case qI:return kI(i);case _I:return new r();case eO:return HI(i);}}var pO=dO,vO=qi,cu=Object.create,gO=/* @__PURE__ */function(){function i(){}return function(e){if(!vO(e))return{};if(cu)return cu(e);i.prototype=e;var t=new i();return i.prototype=void 0,t;};}(),mO=gO,yO=mO,SO=ah,PO=yl;function xO(i){return typeof i.constructor=="function"&&!PO(i)?yO(SO(i)):{};}var TO=xO,CO=To,IO=pn,OO="[object Map]";function wO(i){return IO(i)&&CO(i)==OO;}var AO=wO,EO=AO,MO=xo,uu=ml,hu=uu&&uu.isMap,LO=hu?MO(hu):EO,RO=LO,bO=To,DO=pn,NO="[object Set]";function BO(i){return DO(i)&&bO(i)==NO;}var WO=BO,FO=WO,UO=xo,du=ml,pu=du&&du.isSet,YO=pu?UO(pu):FO,ph=YO,XO=/* @__PURE__ */Ln(ph),zO=Zu,$O=dx,jO=qu,GO=eC,kO=yC,HO=SC,VO=xC,KO=bC,ZO=kC,JO=ch,QO=nI,qO=To,_O=EI,tw=pO,ew=TO,rw=_i,nw=gl,iw=RO,sw=qi,ow=ph,aw=Pl,lw=xl,fw=1,cw=2,uw=4,vh="[object Arguments]",hw="[object Array]",dw="[object Boolean]",pw="[object Date]",vw="[object Error]",gh="[object Function]",gw="[object GeneratorFunction]",mw="[object Map]",yw="[object Number]",mh="[object Object]",Sw="[object RegExp]",Pw="[object Set]",xw="[object String]",Tw="[object Symbol]",Cw="[object WeakMap]",Iw="[object ArrayBuffer]",Ow="[object DataView]",ww="[object Float32Array]",Aw="[object Float64Array]",Ew="[object Int8Array]",Mw="[object Int16Array]",Lw="[object Int32Array]",Rw="[object Uint8Array]",bw="[object Uint8ClampedArray]",Dw="[object Uint16Array]",Nw="[object Uint32Array]",Ye={};Ye[vh]=Ye[hw]=Ye[Iw]=Ye[Ow]=Ye[dw]=Ye[pw]=Ye[ww]=Ye[Aw]=Ye[Ew]=Ye[Mw]=Ye[Lw]=Ye[mw]=Ye[yw]=Ye[mh]=Ye[Sw]=Ye[Pw]=Ye[xw]=Ye[Tw]=Ye[Rw]=Ye[bw]=Ye[Dw]=Ye[Nw]=!0;Ye[vw]=Ye[gh]=Ye[Cw]=!1;function _s(i,e,t,r,n,s){var c,l=e&fw,f=e&cw,h=e&uw;if(t&&(c=n?t(i,r,n,s):t(i)),c!==void 0)return c;if(!sw(i))return i;var v=rw(i);if(v){if(c=_O(i),!l)return VO(i,c);}else{var u=qO(i),y=u==gh||u==gw;if(nw(i))return HO(i,l);if(u==mh||u==vh||y&&!n){if(c=f||y?{}:ew(i),!l)return f?ZO(i,kO(c,i)):KO(i,GO(c,i));}else{if(!Ye[u])return n?i:{};c=tw(i,u,l);}}s||(s=new zO());var T=s.get(i);if(T)return T;s.set(i,c),ow(i)?i.forEach(function(S){c.add(_s(S,e,t,S,i,s));}):iw(i)&&i.forEach(function(S,O){c.set(O,_s(S,e,t,O,i,s));});var w=h?f?QO:JO:f?lw:aw,I=v?void 0:w(i);return $O(I||i,function(S,O){I&&(O=S,S=i[O]),jO(c,O,_s(S,e,t,O,i,s));}),c;}var Bw=_s,Ww=Bw,Fw=1,Uw=4;function Yw(i){return Ww(i,Fw|Uw);}var Xw=Yw,fr=/* @__PURE__ */Ln(Xw);var yh="1.1.34-beta.1",zw="@netless/appliance-plugin";if((typeof window==="undefined"?"undefined":_typeof(window))<"u"){var i=window.__netlessUA||"";i+=" ".concat(zw,"@").concat(yh),window.__netlessUA=i;}var gr={useWorker:"auto",useSimple:!1,useBackgroundThread:!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"},undoRedo:{enableGlobal:!1,maxStackLength:20},markmap:{enable:!0,timeout:1e4,options:{autoFit:!0,duration:0,zoom:!1,pan:!1,maxInitialScale:10}}};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(ui(r),"L").concat(ui(n));var s="";for(var c=2,l=t-1;c<l;c++)r=i[c],n=i[c+1],s+=hi(r,n);return e?"M".concat(hi(i[0],i[1]),"Q").concat(ui(i[1])).concat(hi(i[1],i[2]),"T").concat(s).concat(hi(i[t-1],i[0])).concat(hi(i[0],i[1]),"Z"):"M".concat(ui(i[0]),"Q").concat(ui(i[1])).concat(hi(i[1],i[2])).concat(i.length>3?"T":"").concat(s,"L").concat(ui(i[t-1]));}var Mr=/*#__PURE__*/function(){function Mr(e){_classCallCheck(this,Mr);dt(this,"maxImageWidth",gr.pencilEraser.maxImageWidth);dt(this,"maxImageHeight",gr.pencilEraser.maxImageHeight);dt(this,"syncUnitTime",gr.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,v=e.scale,u=e.angle,y=e.translate,T={};_e(h)&&(T.zIndex=h),f&&(T.pos=[f[0],f[1]]),v&&(T.scale=v),u&&(T.rotate=u),y&&(T.translate=y),l.attr(T);var w=l==null?void 0:l.getBoundingClientRect();return w&&(t=Zt(t,{x:Math.floor(w.x-Mr.SafeBorderPadding),y:Math.floor(w.y-Mr.SafeBorderPadding),w:Math.floor(w.width+Mr.SafeBorderPadding*2),h:Math.floor(w.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,v=r.getBoundingClientRect(),u=v.width*h*c.worldScaling[0],y=v.height*h*c.worldScaling[1];var T=1;(u>this.maxImageWidth||y>this.maxImageHeight)&&(T=Math.min(this.maxImageWidth/u,this.maxImageHeight/y));var w=c.getAttribute("scale");w=[w[0]*T,w[1]*T];var I=c.parent.parent,S=c.getAttribute("translate"),_O30=this.createVmRenderNode("".concat(this.workId,"_bitMapLayer"),I,{offscreen:l.offscreen,width:l.width,height:l.height,contextType:"2d",autoRender:!1,bufferSize:500},w,S),_d30=r.cloneNode(!0);if(!n||!n.length)return;this.addEraserlines(_d30,n,s,!1),_O30.appendChild(_d30);var g=_O30.parent;g.render();var p=_O30.renderer.canvasRenderer,x=p.context;if(!x)return;var E=p.options.displayRatio,R=_d30.getBoundingClientRect(),D={x:R.x,y:R.y,w:R.width,h:R.height},U={x:0,y:0,w:I.width,h:I.height};if(Ji(D,U)===Tr.outside){Lr(_d30,g),I.removeChild(g),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,I.width)-W.x,W.h=Math.min(D.y+D.h,I.height)-W.y;var X=this.getGroupRect(W,E),B=X.x,N=X.y,$=X.w,J=X.h;var tt=x.getImageData(B,N,$,J);if(this.isTransparentRectByCanvas(tt)){Lr(_d30,g),I.removeChild(g),this.isDelete=!0,tt=null;return;}Lr(r,l);var ut=this.createSpriteNode({imageData:tt,safariRect:W,originRect:D,worldScaling:_O30.worldScaling});ut&&r.append(ut),Lr(_d30,g),I.removeChild(g),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),v=new cr({anchor:[0.5,0.5],pos:[c*0.5,l*0.5],size:[c,l],name:"viewport",id:e});return v.setAttribute("scale",n),v.setAttribute("translate",s),h.append(v),v;}},{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(w,I){return I%2?w-r[1]:w-r[0];}),v=this.computEraserPoints(h,c),u=En(v,!0),y={pos:[0,0],d:u,fillColor:"rgba(0,0,0,1)"},T=new Mn(y);T.addEventListener("beforerender",function(_ref164){var w=_ref164.detail;var I=w.context;n?I.blendFuncSeparate(I.ZERO,I.ZERO,I.ZERO,I.ZERO):I.globalCompositeOperation="destination-out";}),T.addEventListener("afterrender",function(_ref165){var w=_ref165.detail;var I=w.context;n?I.blendFuncSeparate(I.SRC_ALPHA,I.ONE_MINUS_SRC_ALPHA,I.ONE,I.ONE_MINUS_SRC_ALPHA):I.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 v=c.getContext("2d");v&&v.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 _v4=c.getContext("2d");_v4&&_v4.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 $u(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 v=new Jt(e[l-2],e[l-1]);h=pt.Sub(f,v).uni(),s=f;}else{l===0&&(c=f);var _v5=new Jt(e[l+2],e[l+3]);h=pt.Sub(_v5,f).uni();}if(h){var _v6=pt.Per(h).mul(t);r.push(Jt.Sub(f,_v6)),n.push(Jt.Add(f,_v6));}}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 _this60=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?sE(r,c,e):(c.remove(),_vr(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(),_vr(l,(f=_this60.drawLayer)==null?void 0:f.parent);}):this.fullLayer.getElementsByName(t).forEach(function(l){l.remove(),_vr(l,_this60.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(),_vr(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,v=r.originPoint,u=r.scenePoint,y=r.scale,T=r.pointMap,w=r.thickness;var I;var S=c&&fr(c)||n.get(t.name);if(!S)return;_e(l)&&(t.setAttribute("zIndex",l),S.opt.zIndex=l);var O=t.parent;if(O){if(v&&y&&c){var g=[S.op[0],S.op[1]];Oo(S.op,u,y,f);var p=[S.op[0],S.op[1]],x=[p[0]-g[0],p[1]-g[1]];if(S.centerPos=[S.centerPos[0]+x[0],S.centerPos[1]+x[1]],S.opt.translate=void 0,S.opt.scale=void 0,S.opt.eraserlines)for(var E=0;E<S.opt.eraserlines.length;E++){var _S$opt$eraserlines$E=S.opt.eraserlines[E],R=_S$opt$eraserlines$E.op,D=_S$opt$eraserlines$E.thickness;S.opt.eraserlines[E].thickness=Math.round(D*Math.max(y[0],y[1]));for(var U=0;U<R.length;U++)Nl(R[U],u,y,f);}}else if(f){if(t.setAttribute("translate",f),S.opt.translate=f,c){var _g6=[f[0]*O.worldScaling[0],f[1]*O.worldScaling[1]];I=Zi(S.rect,_g6),S.rect=I;}else{var _g7=Mr.getRectFromLayer(O,t.name);S.rect=_g7||S.rect;}}else if(_e(h))if(t.setAttribute("rotate",h),S.opt.rotate=h,c)I=Dl(S.rect,h),S.rect=I;else{var _g8=Mr.getRectFromLayer(O,t.name);S.rect=_g8||S.rect;}if(T){var _g9=T.get(t.name);if(_g9)for(var _p10=0,_x37=0;_p10<S.op.length;_p10+=3,_x37++)S.op[_p10]=_g9[_x37][0],S.op[_p10+1]=_g9[_x37][1];}if(w&&(d=S==null?void 0:S.opt)!=null&&d.thickness&&(S.opt.thickness=w),s&&!(v&&y&&c)){if(f){var _g10=S.op.map(function(p,x){var E=x%3;return E===0?p+f[0]:E===1?p+f[1]:p;});if(S.op=_g10,S.centerPos=[S.centerPos[0]+f[0],S.centerPos[1]+f[1]],S!=null&&S.opt&&(S.opt.translate=void 0),S.opt.eraserlines)for(var _p11=0;_p11<S.opt.eraserlines.length;_p11++){var _x38=S.opt.eraserlines[_p11].op;for(var _E7=0;_E7<_x38.length;_E7++){var _R3=_x38[_E7].map(function(D,U){return U%2?D+f[1]:D+f[0];});S.opt.eraserlines[_p11].op[_E7]=_R3;}}}else if(_e(h)){var _g11=S.op;if(QA(_g11,S.centerPos,h),S.op=_g11,S!=null&&S.opt&&(S.opt.rotate=void 0),S.opt.eraserlines)for(var _p12=0;_p12<S.opt.eraserlines.length;_p12++){var _x39=S.opt.eraserlines[_p12].op;for(var _E8=0;_E8<_x39.length;_E8++)qA(_x39[_E8],S.centerPos,h);}}}S&&n.setInfo(t.name,S);}}},{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===xt.Text&&(s.fontSize||s.translate||s.textInfos&&s.textInfos.get(n.name))||t===xt.BackgroundSVG&&(s.translate||s.scale)||t===xt.Image&&(s.angle||s.translate||s.scale||s.strokeColor&&r.type===vo.Iconify)||t===s.toolsType&&s.willRefresh||r.eraserlines&&r.eraserlines.length&&(s.strokeColor||s.fillColor));}}]);}();dt(Mr,"SafeBorderPadding",10);var Xt=Mr;var Ol=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 wl={exports:{}};wl.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 v=0;v<f.length;v++)s[f][f.charAt(v)]=v;}return s[f][h];}var l={compressToBase64:function compressToBase64(f){if(f==null)return"";var h=l._compress(f,6,function(v){return r.charAt(v);});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),v=new Uint8Array(h.length*2),u=0,y=h.length;u<y;u++){var T=h.charCodeAt(u);v[u*2]=T>>>8,v[u*2+1]=T%256;}return v;},//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),v=0,u=h.length;v<u;v++)h[v]=f[v*2]*256+f[v*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,3 +1,3 @@
1
- "use strict";var j=Object.create;var N=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var R=(o,e,t)=>e in o?N(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var _=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of U(e))!Y.call(o,a)&&a!==t&&N(o,a,{get:()=>e[a],enumerable:!(r=G(e,a))||r.enumerable});return o};var Z=(o,e,t)=>(t=o!=null?j(X(o)):{},_(e||!o||!o.__esModule?N(t,"default",{value:o,enumerable:!0}):t,o));var g=(o,e,t)=>R(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index-DjSg1GK5.js"),M=require("lodash");require("white-web-sdk");require("spritejs");require("lz-string");require("clipper-lib");require("lineclip");require("xss");require("react-dom");require("react");const J=require("markmap-view"),Q=require("markmap-lib"),ee=require("./ObserverMap-DTz9zucn.js");function te(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const $=te(J);class re{constructor(){g(this,"threadEngine")}registerBackgroundThread(e){return this.threadEngine=e,this}}class ae extends re{constructor(){super(...arguments);g(this,"emitEventType",u.EmitEventType.CopyNode)}async consume(t){const{msgType:r,dataType:a,emitEventType:i}=t;if(r===u.EPostMessageType.FullWork&&a===u.EDataType.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var a;const{workId:r}=t;r&&await((a=this.threadEngine)==null?void 0:a.consumeFull(t))}}class se{constructor(e){g(this,"builders",new Map);this.builders=new Map(e.map(t=>[t,this.build(t)]))}build(e){switch(e){case u.EmitEventType.CopyNode:return new ae}}registerForBackgroundThread(e){return this.builders.forEach(t=>{t&&t.registerBackgroundThread(e)}),this}async consumeForBackgroundThread(e){for(const t of this.builders.values())if(await(t==null?void 0:t.consume(e)))return!0;return!1}}let C=null,A=null,L=!1;function B(o){return!o||typeof o!="string"?!1:/```\s*mermaid[\s\S]*?```/i.test(o)}async function ie(){return C||A||(A=import("mermaid").then(o=>(C=o,A=null,o)).catch(o=>{throw A=null,o}),A)}async function ne(){const o=await ie();return L||(o.default.initialize({startOnLoad:!1,theme:"default"}),L=!0),o}function oe(){return(C==null?void 0:C.default)||null}const T=class T{constructor(){g(this,"mermaidCodeBlocksByWorkId",new Map)}static getInstance(){return T.instance||(T.instance=new T),T.instance}generateId(){return`mermaid-${Math.random().toString(36).substr(2,9)}`}createContainer(e,t,r){if(t&&r){let a=this.mermaidCodeBlocksByWorkId.get(r);a||(a=new Map,this.mermaidCodeBlocksByWorkId.set(r,a)),a.set(e,t)}return`<div class="mermaid-container" data-mermaid-id="${e}"><div class="mermaid-placeholder" id="${e}">正在渲染图表...</div></div>`}getCode(e,t){const r=this.mermaidCodeBlocksByWorkId.get(t);return r==null?void 0:r.get(e)}clear(e){e?this.mermaidCodeBlocksByWorkId.delete(e):this.mermaidCodeBlocksByWorkId.clear()}extendMarkdown(e,t){const r=e.md.renderer,a=r.rules.fence,i=this;r.rules.fence=(s,n,c,d,w)=>{const p=s[n];if(p.info.trim()==="mermaid"){const f=i.generateId();return i.createContainer(f,p.content,t)}return a?a(s,n,c,d,w):""}}static generateId(){return T.getInstance().generateId()}static createContainer(e,t,r){return T.getInstance().createContainer(e,t,r)}static getCode(e,t){return T.getInstance().getCode(e,t)}static clear(e){T.getInstance().clear(e)}static extendMarkdown(e,t){T.getInstance().extendMarkdown(e,t)}};g(T,"instance",null);let b=T;class I{static checkNodeHasMermaid(e){if(!e)return!1;if(e.content&&typeof e.content=="string"&&(e.content.includes('class="mermaid-container"')||e.content.includes("class='mermaid-container'")||e.content.includes("data-mermaid-id=")||e.content.includes("mermaid-placeholder")))return!0;if(e.children&&Array.isArray(e.children)){for(const t of e.children)if(I.checkNodeHasMermaid(t))return!0}return!1}static async renderMermaidAfterDOMUpdate(e,t){await I.renderMermaidBlocks(e,t)}static async renderMermaidBlocks(e,t){if(!e)return;try{await ne()}catch(n){console.error("[renderMermaidBlocks] error: ",n);return}const r=oe();if(!r)return;let a=null,i=!1;for(let n=0;n<30;n++){const c=e.querySelectorAll("foreignObject");if(a=e.querySelectorAll(".mermaid-container"),a.length>0||(c.length>0&&(i=!0),await new Promise(d=>setTimeout(d,50)),i&&n>=20))break}if(!a||a.length===0)return;const s=Array.from(a).map(async(n,c)=>{const d=n,w=d.getAttribute("data-mermaid-id"),p=w?b.getCode(w,t):void 0,l=d.querySelector(".mermaid-placeholder");if(!(!l||!p))try{const y=`mermaid-${t.replace(/[^a-zA-Z0-9_-]/g,"-")}-${Date.now()}-${c}`,{svg:v}=await r.render(y,p);if(l&&l.parentNode){const k=document.createElement("div");k.innerHTML=v;const m=k.querySelector("svg");if(m){if(!m.getAttribute("viewBox")&&m.getAttribute("width")&&m.getAttribute("height")){const O=m.getAttribute("width"),S=m.getAttribute("height"),x=parseFloat((O==null?void 0:O.replace(/px|%/,""))||"0"),E=parseFloat((S==null?void 0:S.replace(/px|%/,""))||"0");x>0&&E>0&&m.setAttribute("viewBox",`0 0 ${x} ${E}`)}m.style.display="block",m.style.maxWidth="100%",m.style.width="auto",m.style.height="auto",m.style.overflow="visible",m.style.verticalAlign="top",m.style.objectFit="contain";const h=document.createElement("div");h.className="mermaid-wrapper",h.style.width="100%",h.style.height="auto",h.style.overflow="hidden",h.style.display="inline-block",h.style.verticalAlign="top",h.style.margin="0",h.style.padding="0",h.style.boxSizing="border-box",h.style.position="relative",this.isSafari()&&(h.style.clipPath="inset(100% 0 0 0)",h.style.pointerEvents="none"),h.appendChild(m),m.style.width="100%",m.style.height="100%",m.style.maxWidth="100%",m.style.maxHeight="100%",m.style.objectFit="contain",m.setAttribute("data-type","mermaid"),this.isSafari()&&(m.style.opacity="0"),l.parentNode.replaceChild(h,l)}else l.outerHTML=v}}catch(f){const y=f instanceof Error?f.message:String(f);l&&(l.textContent=`Mermaid 渲染失败: ${y}`,l.style.color="red",l.style.fontSize="12px")}});await Promise.all(s)}static isSafari(){const e=navigator.userAgent.toLowerCase(),t=e.indexOf("safari")!==-1&&e.indexOf("chrome")===-1&&e.indexOf("chromium")===-1,r=!!(navigator.vendor&&navigator.vendor.indexOf("Apple")!==-1);return t||r}static async transformMermaidSvgToMarkmapSvg(e){if(!e)return;await new Promise(s=>setTimeout(s,200));const t=e.querySelectorAll('g[data-mermaid-wrapper][data-mermaid-clone="true"]'),r=e.querySelectorAll("foreignObject"),a=new Set;if(r.forEach(s=>{const n=s.querySelector(".mermaid-container"),c=n==null?void 0:n.getAttribute("data-mermaid-id");c&&a.add(c)}),t.forEach(s=>{const n=s.getAttribute("data-mermaid-id");n&&!a.has(n)&&s.remove()}),r.length===0)return;const i=Array.from(r).map(async s=>{let n=s.querySelector('svg[data-type="mermaid"]');if(!n){const w=s.querySelector(".mermaid-wrapper");w&&(n=w.querySelector('svg[data-type="mermaid"]'))}if(!n)return;const c=s.querySelector(".mermaid-container"),d=c==null?void 0:c.getAttribute("data-mermaid-id");if(d)try{const w=parseFloat(s.getAttribute("x")||"0"),p=parseFloat(s.getAttribute("y")||"0"),l=parseFloat(s.getAttribute("width")||"0"),f=parseFloat(s.getAttribute("height")||"0");if(l<=0||f<=0)return;const y=s.parentElement;if(!y||y.tagName!=="g")return;let v=y.getAttribute("transform");if(!v)v=`translate(${w}, ${p})`;else{const S=v.match(/translate\(([^,]+),([^)]+)\)/);if(S){const x=parseFloat(S[1]),E=parseFloat(S[2]),P=x+w,K=E+p;v=v.replace(/translate\([^)]+\)/,`translate(${P}, ${K})`)}else v=`translate(${w}, ${p}) ${v}`}const k=e.querySelector(`g[data-mermaid-wrapper][data-mermaid-id="${d}"][data-mermaid-clone="true"]`);let m;if(k){m=k;const S=m.querySelector('svg[data-type="mermaid"]');S&&m.removeChild(S)}else m=document.createElementNS("http://www.w3.org/2000/svg","g"),m.setAttribute("data-mermaid-wrapper","true"),m.setAttribute("data-mermaid-clone","true"),m.setAttribute("data-mermaid-id",d);m.setAttribute("transform",v);const h=n.cloneNode(!0);if(h.setAttribute("width",l.toString()),h.setAttribute("height",f.toString()),h.setAttribute("data-mermaid-transformed","true"),h.style.width="",h.style.height="",h.style.maxWidth="",h.style.maxHeight="",h.style.transform="",h.style.transformOrigin="",h.style.display="block",h.style.overflow="visible",h.style.opacity="1",!h.getAttribute("viewBox")){const S=h.getAttribute("width"),x=h.getAttribute("height");if(S&&x){const E=parseFloat(S.replace(/px|%/,"")||"0"),P=parseFloat(x.replace(/px|%/,"")||"0");E>0&&P>0&&h.setAttribute("viewBox",`0 0 ${E} ${P}`)}}m.appendChild(h),k||(y&&y.parentNode?y.parentNode.insertBefore(m,y.nextSibling):e.appendChild(m)),c&&(c.style.opacity="0",c.style.pointerEvents="none")}catch(w){console.error("[transformMermaidSvgToMarkmapSvg] error: ",w)}});await Promise.all(i)}static injectMermaidHtml(e,t,r){const a=[],i=t.split(`
1
+ "use strict";var j=Object.create;var N=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var R=(o,e,t)=>e in o?N(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var _=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of U(e))!Y.call(o,a)&&a!==t&&N(o,a,{get:()=>e[a],enumerable:!(r=G(e,a))||r.enumerable});return o};var Z=(o,e,t)=>(t=o!=null?j(X(o)):{},_(e||!o||!o.__esModule?N(t,"default",{value:o,enumerable:!0}):t,o));var g=(o,e,t)=>R(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index-DL5KtEyz.js"),M=require("lodash");require("white-web-sdk");require("spritejs");require("lz-string");require("clipper-lib");require("lineclip");require("xss");require("react-dom");require("react");const J=require("markmap-view"),Q=require("markmap-lib"),ee=require("./ObserverMap-DTz9zucn.js");function te(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const $=te(J);class re{constructor(){g(this,"threadEngine")}registerBackgroundThread(e){return this.threadEngine=e,this}}class ae extends re{constructor(){super(...arguments);g(this,"emitEventType",u.EmitEventType.CopyNode)}async consume(t){const{msgType:r,dataType:a,emitEventType:i}=t;if(r===u.EPostMessageType.FullWork&&a===u.EDataType.Local&&i===this.emitEventType)return this.consumeForLocalWorker(t),!0}async consumeForLocalWorker(t){var a;const{workId:r}=t;r&&await((a=this.threadEngine)==null?void 0:a.consumeFull(t))}}class se{constructor(e){g(this,"builders",new Map);this.builders=new Map(e.map(t=>[t,this.build(t)]))}build(e){switch(e){case u.EmitEventType.CopyNode:return new ae}}registerForBackgroundThread(e){return this.builders.forEach(t=>{t&&t.registerBackgroundThread(e)}),this}async consumeForBackgroundThread(e){for(const t of this.builders.values())if(await(t==null?void 0:t.consume(e)))return!0;return!1}}let C=null,A=null,L=!1;function B(o){return!o||typeof o!="string"?!1:/```\s*mermaid[\s\S]*?```/i.test(o)}async function ie(){return C||A||(A=import("mermaid").then(o=>(C=o,A=null,o)).catch(o=>{throw A=null,o}),A)}async function ne(){const o=await ie();return L||(o.default.initialize({startOnLoad:!1,theme:"default"}),L=!0),o}function oe(){return(C==null?void 0:C.default)||null}const T=class T{constructor(){g(this,"mermaidCodeBlocksByWorkId",new Map)}static getInstance(){return T.instance||(T.instance=new T),T.instance}generateId(){return`mermaid-${Math.random().toString(36).substr(2,9)}`}createContainer(e,t,r){if(t&&r){let a=this.mermaidCodeBlocksByWorkId.get(r);a||(a=new Map,this.mermaidCodeBlocksByWorkId.set(r,a)),a.set(e,t)}return`<div class="mermaid-container" data-mermaid-id="${e}"><div class="mermaid-placeholder" id="${e}">正在渲染图表...</div></div>`}getCode(e,t){const r=this.mermaidCodeBlocksByWorkId.get(t);return r==null?void 0:r.get(e)}clear(e){e?this.mermaidCodeBlocksByWorkId.delete(e):this.mermaidCodeBlocksByWorkId.clear()}extendMarkdown(e,t){const r=e.md.renderer,a=r.rules.fence,i=this;r.rules.fence=(s,n,c,d,w)=>{const p=s[n];if(p.info.trim()==="mermaid"){const f=i.generateId();return i.createContainer(f,p.content,t)}return a?a(s,n,c,d,w):""}}static generateId(){return T.getInstance().generateId()}static createContainer(e,t,r){return T.getInstance().createContainer(e,t,r)}static getCode(e,t){return T.getInstance().getCode(e,t)}static clear(e){T.getInstance().clear(e)}static extendMarkdown(e,t){T.getInstance().extendMarkdown(e,t)}};g(T,"instance",null);let b=T;class I{static checkNodeHasMermaid(e){if(!e)return!1;if(e.content&&typeof e.content=="string"&&(e.content.includes('class="mermaid-container"')||e.content.includes("class='mermaid-container'")||e.content.includes("data-mermaid-id=")||e.content.includes("mermaid-placeholder")))return!0;if(e.children&&Array.isArray(e.children)){for(const t of e.children)if(I.checkNodeHasMermaid(t))return!0}return!1}static async renderMermaidAfterDOMUpdate(e,t){await I.renderMermaidBlocks(e,t)}static async renderMermaidBlocks(e,t){if(!e)return;try{await ne()}catch(n){console.error("[renderMermaidBlocks] error: ",n);return}const r=oe();if(!r)return;let a=null,i=!1;for(let n=0;n<30;n++){const c=e.querySelectorAll("foreignObject");if(a=e.querySelectorAll(".mermaid-container"),a.length>0||(c.length>0&&(i=!0),await new Promise(d=>setTimeout(d,50)),i&&n>=20))break}if(!a||a.length===0)return;const s=Array.from(a).map(async(n,c)=>{const d=n,w=d.getAttribute("data-mermaid-id"),p=w?b.getCode(w,t):void 0,l=d.querySelector(".mermaid-placeholder");if(!(!l||!p))try{const y=`mermaid-${t.replace(/[^a-zA-Z0-9_-]/g,"-")}-${Date.now()}-${c}`,{svg:v}=await r.render(y,p);if(l&&l.parentNode){const k=document.createElement("div");k.innerHTML=v;const m=k.querySelector("svg");if(m){if(!m.getAttribute("viewBox")&&m.getAttribute("width")&&m.getAttribute("height")){const O=m.getAttribute("width"),S=m.getAttribute("height"),x=parseFloat((O==null?void 0:O.replace(/px|%/,""))||"0"),E=parseFloat((S==null?void 0:S.replace(/px|%/,""))||"0");x>0&&E>0&&m.setAttribute("viewBox",`0 0 ${x} ${E}`)}m.style.display="block",m.style.maxWidth="100%",m.style.width="auto",m.style.height="auto",m.style.overflow="visible",m.style.verticalAlign="top",m.style.objectFit="contain";const h=document.createElement("div");h.className="mermaid-wrapper",h.style.width="100%",h.style.height="auto",h.style.overflow="hidden",h.style.display="inline-block",h.style.verticalAlign="top",h.style.margin="0",h.style.padding="0",h.style.boxSizing="border-box",h.style.position="relative",this.isSafari()&&(h.style.clipPath="inset(100% 0 0 0)",h.style.pointerEvents="none"),h.appendChild(m),m.style.width="100%",m.style.height="100%",m.style.maxWidth="100%",m.style.maxHeight="100%",m.style.objectFit="contain",m.setAttribute("data-type","mermaid"),this.isSafari()&&(m.style.opacity="0"),l.parentNode.replaceChild(h,l)}else l.outerHTML=v}}catch(f){const y=f instanceof Error?f.message:String(f);l&&(l.textContent=`Mermaid 渲染失败: ${y}`,l.style.color="red",l.style.fontSize="12px")}});await Promise.all(s)}static isSafari(){const e=navigator.userAgent.toLowerCase(),t=e.indexOf("safari")!==-1&&e.indexOf("chrome")===-1&&e.indexOf("chromium")===-1,r=!!(navigator.vendor&&navigator.vendor.indexOf("Apple")!==-1);return t||r}static async transformMermaidSvgToMarkmapSvg(e){if(!e)return;await new Promise(s=>setTimeout(s,200));const t=e.querySelectorAll('g[data-mermaid-wrapper][data-mermaid-clone="true"]'),r=e.querySelectorAll("foreignObject"),a=new Set;if(r.forEach(s=>{const n=s.querySelector(".mermaid-container"),c=n==null?void 0:n.getAttribute("data-mermaid-id");c&&a.add(c)}),t.forEach(s=>{const n=s.getAttribute("data-mermaid-id");n&&!a.has(n)&&s.remove()}),r.length===0)return;const i=Array.from(r).map(async s=>{let n=s.querySelector('svg[data-type="mermaid"]');if(!n){const w=s.querySelector(".mermaid-wrapper");w&&(n=w.querySelector('svg[data-type="mermaid"]'))}if(!n)return;const c=s.querySelector(".mermaid-container"),d=c==null?void 0:c.getAttribute("data-mermaid-id");if(d)try{const w=parseFloat(s.getAttribute("x")||"0"),p=parseFloat(s.getAttribute("y")||"0"),l=parseFloat(s.getAttribute("width")||"0"),f=parseFloat(s.getAttribute("height")||"0");if(l<=0||f<=0)return;const y=s.parentElement;if(!y||y.tagName!=="g")return;let v=y.getAttribute("transform");if(!v)v=`translate(${w}, ${p})`;else{const S=v.match(/translate\(([^,]+),([^)]+)\)/);if(S){const x=parseFloat(S[1]),E=parseFloat(S[2]),P=x+w,K=E+p;v=v.replace(/translate\([^)]+\)/,`translate(${P}, ${K})`)}else v=`translate(${w}, ${p}) ${v}`}const k=e.querySelector(`g[data-mermaid-wrapper][data-mermaid-id="${d}"][data-mermaid-clone="true"]`);let m;if(k){m=k;const S=m.querySelector('svg[data-type="mermaid"]');S&&m.removeChild(S)}else m=document.createElementNS("http://www.w3.org/2000/svg","g"),m.setAttribute("data-mermaid-wrapper","true"),m.setAttribute("data-mermaid-clone","true"),m.setAttribute("data-mermaid-id",d);m.setAttribute("transform",v);const h=n.cloneNode(!0);if(h.setAttribute("width",l.toString()),h.setAttribute("height",f.toString()),h.setAttribute("data-mermaid-transformed","true"),h.style.width="",h.style.height="",h.style.maxWidth="",h.style.maxHeight="",h.style.transform="",h.style.transformOrigin="",h.style.display="block",h.style.overflow="visible",h.style.opacity="1",!h.getAttribute("viewBox")){const S=h.getAttribute("width"),x=h.getAttribute("height");if(S&&x){const E=parseFloat(S.replace(/px|%/,"")||"0"),P=parseFloat(x.replace(/px|%/,"")||"0");E>0&&P>0&&h.setAttribute("viewBox",`0 0 ${E} ${P}`)}}m.appendChild(h),k||(y&&y.parentNode?y.parentNode.insertBefore(m,y.nextSibling):e.appendChild(m)),c&&(c.style.opacity="0",c.style.pointerEvents="none")}catch(w){console.error("[transformMermaidSvgToMarkmapSvg] error: ",w)}});await Promise.all(i)}static injectMermaidHtml(e,t,r){const a=[],i=t.split(`
2
2
  `);let s="",n=!1,c=[],d=-1;for(let p=0;p<i.length;p++){const l=i[p],f=l.match(/^(#{1,6})\s+(.+)$/);if(f&&(s=f[2].trim()),l.trim().startsWith("```mermaid"))n=!0,c=[],d=p;else if(n&&l.trim()==="```"){n=!1;const y=c.join(`
3
3
  `);y&&s&&a.push({title:s,content:y,index:d}),c=[]}else n&&c.push(l)}const w=p=>{if(!p)return;const l=p.content||"",f=I.decodeHtmlEntities(l);for(const y of a)if(f.includes(y.title)||l.includes(y.title)){const v=b.generateId(),k=b.createContainer(v,y.content,r);p.content?p.content=p.content+k:p.content=k;break}p.children&&p.children.length>0&&p.children.forEach(y=>{w(y)})};return w(e),e}static decodeHtmlEntities(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}static hasMermaidSvg(e){return e.querySelectorAll("svg[data-type='mermaid']").length>0}}class H extends Q.Transformer{constructor(t){super(t);g(this,"currentWorkId",null)}setWorkId(t){this.currentWorkId=t,t&&b.extendMarkdown(this,t)}transform(t,r){this.currentWorkId?b.clear(this.currentWorkId):b.clear();const a=this.convertKatexToText(t),i=super.transform(a,r);return i.root&&this.processKatexInRoot(i.root),i}convertKatexToText(t){if(!t)return t;let r=t.replace(/\$\$([\s\S]*?)\$\$/g,(a,i)=>i.replace(/\\/g,"").replace(/\{/g,"").replace(/\}/g,"").replace(/\\over/g,"/").replace(/\\pm/g,"±").replace(/\\sqrt/g,"√").replace(/\\frac/g,"/").trim());return r=r.replace(/\$([^$\n]+?)\$/g,(a,i)=>i.replace(/\\/g,"").replace(/\{/g,"").replace(/\}/g,"").replace(/\\over/g,"/").replace(/\\pm/g,"±").replace(/\\sqrt/g,"√").replace(/\\frac/g,"/").trim()),r}processKatexInRoot(t){if(t){if(t.content&&typeof t.content=="string"&&(t.content.includes("katex")||t.content.includes("katex-mathml"))){const r=t.content.match(/<annotation[^>]*encoding="application\/x-tex">([^<]+)<\/annotation>/);if(r){const a=r[1].replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/\\/g,"").replace(/\{/g,"").replace(/\}/g,"").replace(/\\over/g,"/").replace(/\\pm/g,"±").replace(/\\sqrt/g,"√").replace(/\\frac/g,"/").trim();t.content=t.content.replace(/<div[^>]*xmlns="http:\/\/www\.w3\.org\/1999\/xhtml"[^>]*>Katex:\s*<span[^>]*class="katex"[^>]*>[\s\S]*?<\/span><\/div>/g,a)}else{const a=document.createElement("div");a.innerHTML=t.content;const i=a.querySelector(".katex");if(i){let s=i.textContent||"";s=s.replace(/^Katex:\s*/i,"").trim(),t.content=t.content.replace(/<div[^>]*xmlns="http:\/\/www\.w3\.org\/1999\/xhtml"[^>]*>Katex:\s*<span[^>]*class="katex"[^>]*>[\s\S]*?<\/span><\/div>/g,s||"公式")}else{const s=t.content.replace(/<[^>]+>/g," ").replace(/\s+/g," ").replace(/^Katex:\s*/i,"").trim();t.content=s||"公式"}}}t.children&&Array.isArray(t.children)&&t.children.forEach(r=>{this.processKatexInRoot(r)})}}static async waitForImagesInForeignObjects(t,r=1e4){if(!t)return;const a=t.querySelectorAll("foreignObject.markmap-foreign img");if(a.length===0)return;const i=[],s=new Set;a.forEach(n=>{const c=n.src||n.getAttribute("src");if(!c||s.has(c)||(s.add(c),n.complete&&n.naturalWidth>0))return;const d=new Promise(w=>{const p=setTimeout(()=>{w()},r);if(n.complete&&n.naturalWidth>0){clearTimeout(p),w();return}const l=()=>{clearTimeout(p),n.removeEventListener("load",l),n.removeEventListener("error",f),w()},f=()=>{clearTimeout(p),n.removeEventListener("load",l),n.removeEventListener("error",f),w()};n.addEventListener("load",l),n.addEventListener("error",f),!n.src&&c&&(n.src=c)});i.push(d)}),i.length>0&&await Promise.all(i)}}const W=new H,{loadCSS:ce,loadJS:le,Markmap:he}=$,{scripts:F,styles:q}=W.getAssets();q&&ce(q);F&&le(F,{getMarkmap:()=>$});async function de(o){const e=o.querySelectorAll("img"),t=Array.from(e).map(i=>{if(!i.crossOrigin&&i.src&&!i.src.startsWith("data:")&&(i.crossOrigin="anonymous",i.complete)){const s=i.src;i.src="",i.src=s}return i.complete&&i.crossOrigin?Promise.resolve():new Promise(s=>{i.onload=()=>{s(void 0)},i.onerror=()=>{s(void 0)}})});return o.querySelectorAll("svg").forEach(i=>{i.querySelectorAll("image").forEach(n=>{n.href&&!n.href.baseVal.startsWith("data:")&&(n.getAttribute("crossorigin")||n.setAttribute("crossorigin","anonymous"),t.push(new Promise(c=>{const d=new Image;d.crossOrigin="anonymous",d.onload=()=>{c(void 0)},d.onerror=()=>{c(void 0)},d.src=n.href.baseVal})))})}),await Promise.all(t)}async function me(o){const r=Date.now();let a=!1;for(;Date.now()-r<5e3;){const i=o.querySelectorAll("path");if(i.length>0&&(a=Array.from(i).some(s=>{const n=s.getAttribute("d")||"";return n!=="M0,0C0,0,0,0,0,0"&&n.length>10}),a))break;await new Promise(s=>setTimeout(s,50))}}async function ue(o){const e=o.querySelectorAll("svg");if(!e.length)return;const t=[];for(let r=0;r<e.length;r++){const a=e[r];t.push(me(a))}await Promise.all(t)}async function V(o){if(I.hasMermaidSvg(o)){const r=Date.now();let a=!1;for(;Date.now()-r<5e3&&!a;){const i=o.querySelectorAll("foreignObject");if(i.length>0){let s=!0;for(const n of Array.from(i)){const c=parseFloat(n.getAttribute("width")||"0"),d=parseFloat(n.getAttribute("height")||"0");if(n.querySelector(".mermaid-container")&&(c<50||d<50)){s=!1;break}}if(s){a=!0;break}}else a=!0;await new Promise(s=>setTimeout(s,50))}}}async function pe(o,e={}){const{width:t=o.offsetWidth,height:r=o.offsetHeight}=e,a=o.offsetWidth||t,i=o.offsetHeight||r;try{const{loadSvgToImageLib:s,getSvgToImageLib:n}=await Promise.resolve().then(()=>require("./svgToImageLoader-DPRAAhwW.js"));let c=n();if(!c)try{c=await s()}catch(l){return console.error("[loadSvgToImageLib] error: ",l),null}const d=o.style.width,w=o.style.height,p=o.style.display;o.style.width||(o.style.width=`${a}px`),o.style.height||(o.style.height=`${i}px`),(!o.style.display||o.style.display==="none")&&(o.style.display="block");try{await new Promise(f=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{f()})})});const l=await c.toPng(o,{width:a,height:i,quality:1});return o.style.width=d,o.style.height=w,o.style.display=p,new Promise(f=>{const y=new Image;y.crossOrigin="anonymous",y.onload=()=>{f(y)},y.onerror=()=>{f(null)},y.src=l})}catch(l){return o.style.width=d,o.style.height=w,o.style.display=p,console.error("[divToImageElement] error: ",l),null}}catch(s){return console.error("[divToImageElement] error: ",s),null}}class ge{constructor(e){g(this,"toolsType",u.EToolsKey.BackgroundSVG);g(this,"vNodes");g(this,"workOptions");g(this,"workId");g(this,"markmapInstance",null);g(this,"isDestroyed",!1);g(this,"element");g(this,"manager");const{vNodes:t,workId:r,toolsOpt:a,manager:i}=e;this.workId=r,this.vNodes=t,this.workOptions=a,this.manager=i,this.element=this.createElement(),this.manager.fullLayer.appendChild(this.element),this.vNodes.setInfo(this.workId,{workShape:this})}get fullLayer(){return this.manager.fullLayer}get collector(){return this.manager.master.control.collector}get scenePath(){return this.manager.master.control.viewContainerManager.getCurScenePath(this.manager.viewId)}async init(){await this.render()}createElement(){const{type:e}=this.workOptions;let t;return e===u.ESVGType.markmap?(t=document.createElementNS("http://www.w3.org/2000/svg","svg"),t.classList.add("svg")):(t=document.createElement("img"),t.classList.add("img")),t.id=this.workId,t.setAttribute("data-id",this.workId),t}async render(e){this.isDestroyed||!this.element||!this.element.parentNode||(this.updateElementPosition(e),await this.updateSvg(e))}isSameSize(e){const{width:t,height:r}=e,{width:a,height:i}=this.workOptions,s=t*this.manager.camera.scale,n=r*this.manager.camera.scale,c=a*this.manager.camera.scale,d=i*this.manager.camera.scale;return s===c&&n===d}isSamePosition(e){const{centerX:t,centerY:r}=e,{centerX:a,centerY:i}=this.workOptions,s=this.manager.getPagePoint(a,i),n=this.manager.getPagePoint(t,r);return M.isEqual(n,s)}isSameZIndex(e){const{zIndex:t}=e,{zIndex:r}=this.workOptions;return t===r}isSameState(e){const{state:t}=e,{state:r}=this.workOptions;return M.isEqual(t,r)}isSameData(e){const{data:t}=e,{data:r}=this.workOptions;return M.isEqual(t,r)}updateElementPosition(e){if(this.isDestroyed||!this.element||!this.fullLayer)return;const{centerX:t,centerY:r,width:a,height:i,zIndex:s}=this.workOptions,n=this.manager.getPagePoint(t,r),c=a*this.manager.camera.scale,d=i*this.manager.camera.scale;(!e||e&&!this.isSameSize(e))&&(this.element.setAttribute("width",`${c}`),this.element.setAttribute("height",`${d}`),this.element.style.width=`${c}px`,this.element.style.height=`${d}px`),(!e||e&&!this.isSamePosition(e))&&(this.element.style.left=`${n.x}px`,this.element.style.top=`${n.y}px`),(!e||e&&!this.isSameZIndex(e))&&(this.element.style.zIndex=(s||0).toString())}async updateSvg(e){const{type:t,state:r}=this.workOptions;if(t===u.ESVGType.markmap){const{data:a}=this.workOptions;if(this.markmapInstance||(this.markmapInstance=he.create(this.element,this.manager.markmapOptions),this.markmapInstance.handleClick=async(n,c)=>{var p,l,f;(p=this.markmapInstance)==null||p.toggleNode(c);const d=this.serializeData((l=this.markmapInstance)==null?void 0:l.state.data);this.setWorkOptions({...this.workOptions,state:d},!1),I.checkNodeHasMermaid(c)&&await I.renderMermaidAfterDOMUpdate(this.element,this.workId),this.scenePath&&this.collector&&((f=this.collector)==null||f.dispatch({type:u.EPostMessageType.UpdateNode,workId:this.workId,opt:this.workOptions,isSync:!0,viewId:this.manager.viewId,scenePath:this.scenePath}))}),e&&this.isSameState(e)&&this.isSameSize(e)&&this.isSameData(e))return;W.setWorkId(this.workId);const i=W.transform(a);let{root:s}=i;a&&B(a)&&(s=I.injectMermaidHtml(s,a,this.workId));try{r&&Array.isArray(r)&&this.transformState(r,s),await this.markmapInstance.setData(s),!this.isDestroyed&&this.element&&this.fullLayer&&this.markmapInstance&&(window.markmapInstance=this.markmapInstance,a&&B(a)&&await I.renderMermaidAfterDOMUpdate(this.element,this.workId),await this.fit(!e||e&&!this.isSameData(e)))}catch(n){console.error("[updateSvg] error: ",n)}}else{const{src:a,crossOrigin:i}=this.workOptions;this.element.src=a,this.element.crossOrigin=M.isString(i)?i:"anonymous";try{await new Promise((s,n)=>{this.element.onload=()=>{s()},this.element.onerror=function(){n()}})}catch(s){console.error("[updateSvg] error: ",s)}}}async fit(e=!0){var t;!this.isDestroyed&&this.element&&this.fullLayer&&this.markmapInstance&&(e&&this.element&&await H.waitForImagesInForeignObjects(this.element),await((t=this.markmapInstance)==null?void 0:t.fit()),this.element&&I.isSafari()&&I.hasMermaidSvg(this.element)&&(await V(this.element),await I.transformMermaidSvgToMarkmapSvg(this.element)))}serializeData(e){var a;const t=[e],r=[];for(;t.length>0;){const i=t.pop();i&&(i!=null&&i.children&&t.push(...i.children),r.push(((a=i==null?void 0:i.payload)==null?void 0:a.fold)||0))}return r}transformState(e,t){const r=[t];for(;r.length>0;){const a=r.pop();a&&(a!=null&&a.children&&r.push(...a.children),a.payload?a.payload.fold=e.shift():e.shift())}}async updateCamera(){this.updateElementPosition(),await this.fit(!1)}async setWorkOptions(e,t=!0){if(!M.isEqual(this.workOptions,e)){const r=M.clone(this.workOptions);this.workOptions=e,t&&await this.render(r)}}destroy(){this.isDestroyed=!0,this.element.remove()}getRectFromLayer(){const e=this.element.getBoundingClientRect();return{x:e.x,y:e.y,w:e.width,h:e.height}}}function D(o){const{toolsType:e,...t}=o;switch(e){case u.EToolsKey.BackgroundSVG:return new ge(t);default:return}}class z{constructor(e){g(this,"viewId");g(this,"fullLayer");g(this,"curNodeMap");this.viewId=e,this.curNodeMap=new ee.ObserverMap}init(e){this.fullLayer=e}get(e){return this.curNodeMap.get(e)}setInfo(e,t){const r=this.curNodeMap.get(e)||{name:e,workShape:t.workShape};t.workShape&&(r.workShape=t.workShape),this.curNodeMap.set(e,r)}getNodeRectFormShape(e){const t=this.curNodeMap.get(e);if(t&&t.workShape)return t.workShape.getRectFromLayer()}delete(e){const t=this.curNodeMap.get(e);t&&t.workShape.destroy(),this.curNodeMap.delete(e)}clear(){for(const e of this.curNodeMap.values())e.workShape.destroy();this.curNodeMap.clear()}}class fe{constructor(e,t){g(this,"opt");g(this,"viewId");g(this,"fullLayer");g(this,"vNodes");g(this,"master");g(this,"cameraOpt");g(this,"methodBuilder");g(this,"updateCamera",M.throttle(async e=>{const{cameraOpt:t}=e;t&&!M.isEqual(this.cameraOpt,t)&&await this.setCameraOpt(t)},100));this.viewId=e,this.opt=t,this.master=t.master,this.fullLayer=t.container,this.methodBuilder=new se([u.EmitEventType.CopyNode]).registerForBackgroundThread(this),this.vNodes=new z(e),this.vNodes.init(this.fullLayer)}get camera(){return this.cameraOpt||{scale:1,centerX:0,centerY:0,width:0,height:0}}get view(){var e;return(e=this.master.control.viewContainerManager.getView(this.viewId))==null?void 0:e.viewData}get markmapOptions(){return this.master.control.pluginOptions.extras.markmap.options}getPagePoint(e,t){const{scale:r,centerX:a,centerY:i,width:s,height:n}=this.camera;return{x:(e-a)*r+s/2,y:(t-i)*r+n/2}}async setCameraOpt(e){this.cameraOpt=e;for(const t of this.vNodes.curNodeMap.values()){const{workShape:r}=t;r&&await r.updateCamera()}}clearAll(){this.vNodes.clear()}canUseFullLayer(e){return e===u.EToolsKey.BackgroundSVG}async consumeFull(e){const{toolsType:t,opt:r,workId:a}=e;if(a!=null&&a.toString()&&t&&this.canUseFullLayer(t))switch(t){case u.EToolsKey.BackgroundSVG:await this.setFullWork({toolsType:t,opt:r,workId:a});break}}async setFullWork(e){const{workId:t,opt:r,toolsType:a}=e;if(t&&r&&a){const i=t.toString();let s;const n=this.vNodes.get(i);return!n||!n.workShape?(s=this.createWorkShapeNode({toolsOpt:r,toolsType:u.EToolsKey.BackgroundSVG,workId:i}),s&&await s.init()):(s=n.workShape,await s.setWorkOptions(r)),s}}createWorkShapeNode(e){return D({...e,vNodes:this.vNodes,manager:this})}removeWork(e){const{workId:t}=e,r=t==null?void 0:t.toString();r&&this.removeNode(r)}removeNode(e){this.vNodes.delete(e)}async on(e){if(!await this.methodBuilder.consumeForBackgroundThread(e)){const{msgType:t,toolsType:r}=e;switch(t){case u.EPostMessageType.Destroy:{this.destroy();break}case u.EPostMessageType.Clear:{this.clearAll();break}case u.EPostMessageType.UpdateCamera:{this.updateCamera(e);break}case u.EPostMessageType.UpdateTools:{this.toggleFullLayer(r===u.EToolsKey.Clicker);break}case u.EPostMessageType.BackgroundSVGUpdate:case u.EPostMessageType.UpdateNode:case u.EPostMessageType.FullWork:{r&&this.canUseFullLayer(r)&&await this.consumeFull(e);break}case u.EPostMessageType.BackgroundSVGDelete:{this.removeWork(e);break}}}}toggleFullLayer(e){this.fullLayer.classList.toggle("appliance-plugin-background-svg-active",e)}destroy(){this.vNodes.clear()}}class ye{constructor(e,t){g(this,"viewId");g(this,"fullLayer");g(this,"master");g(this,"vNodes");g(this,"cameraOpt");g(this,"opt");g(this,"workShapes",new Map);this.viewId=e,this.opt=t,this.master=t.master,this.fullLayer=t.container,this.vNodes=new z(e),this.vNodes.init(this.fullLayer)}get camera(){return this.cameraOpt||{scale:1,centerX:0,centerY:0,width:0,height:0}}get view(){var e;return(e=this.master.control.viewContainerManager.getView(this.viewId))==null?void 0:e.viewData}get markmapOptions(){return this.master.control.pluginOptions.extras.markmap.options}createOffscreenCanvas(e){const{width:t,height:r}=e.canvasOpt,a=new OffscreenCanvas(e.canvasOpt.width,e.canvasOpt.height);a.width=t,a.height=r}async setCameraOpt(e){this.cameraOpt=e;for(const t of this.vNodes.curNodeMap.values()){const{workShape:r}=t;r&&await r.updateCamera()}}getPagePoint(e,t){const{scale:r,centerX:a,centerY:i,width:s,height:n}=this.camera;return{x:(e-a)*r+s/2,y:(t-i)*r+n/2}}async getSnapshot(e){const{scenePath:t,scenes:r,cameraOpt:a}=e;if(t&&r&&a){await this.setCameraOpt(a);for(const[i,s]of Object.entries(r))if(s!=null&&s.type&&(s==null?void 0:s.toolsType)===u.EToolsKey.BackgroundSVG)switch(s==null?void 0:s.type){case u.EPostMessageType.UpdateNode:case u.EPostMessageType.FullWork:{const{opt:n}=s,c={...s,opt:n,workId:i,msgType:u.EPostMessageType.FullWork,dataType:u.EDataType.Service,viewId:this.viewId};await this.runFullWork(c);break}}try{if(t){await V(this.fullLayer),await de(this.fullLayer),await ue(this.fullLayer);const i=await pe(this.fullLayer);i&&this.opt.post({sp:[{type:u.EPostMessageType.Snapshot,scenePath:t,imageElement:i,viewId:this.viewId,index:1}]})}}catch(i){const s=i&&i instanceof Error?i.message:i==null?void 0:i.toString();this.opt.post({sp:[{type:u.EPostMessageType.ReportError,reportString:`[SnapshotThreadImpl] getSnapshotRender error: ${s}`}]})}}}createWorkShapeNode(e){return D({...e,vNodes:this.vNodes,manager:this})}async setFullWork(e){const{workId:t,opt:r,toolsType:a}=e;if(t&&r&&a){const i=t.toString();let s;const n=this.vNodes.get(i);return!n||!n.workShape?(s=this.createWorkShapeNode({toolsOpt:r,toolsType:u.EToolsKey.BackgroundSVG,workId:i}),s&&await s.init()):(s=n.workShape,await s.setWorkOptions(r)),s}}async runFullWork(e){const{toolsType:t,opt:r,workId:a}=e;await this.setFullWork({toolsType:t,opt:r,workId:a})}destroy(){this.fullLayer.innerHTML="",this.fullLayer.style.width="",this.fullLayer.style.height=""}}class we{constructor(e){g(this,"backgroundThreadMap",new Map);g(this,"snapshotThread");g(this,"master");g(this,"post",e=>{const{sp:t}=e;t&&this.master.collectorSyncData(t)});this.master=e,this.backgroundThreadMap=new Map}createBackgroundThread(e,t){return new fe(e,t)}createSnapshotThread(e,t){return new ye(e,t)}async consume(e){var t,r,a,i,s;for(const n of e.values()){const{msgType:c,viewId:d,layerOpt:w,offscreenCanvasOpt:p,cameraOpt:l,tasksqueue:f,mainTasksqueueCount:y}=n;if(c===u.EPostMessageType.Console){console.log(this);continue}if(c===u.EPostMessageType.Init){const k=(t=this.master.control.viewContainerManager.getView(d))==null?void 0:t.displayer,m=(r=k==null?void 0:k.backgroundContainerRef)==null?void 0:r.current;if(k&&m&&w&&p){const h=this.createBackgroundThread(d,{displayer:k,container:m,layerOpt:w,master:this.master,canvasOpt:p,post:this.post});this.backgroundThreadMap.set(d,h),h&&l&&await h.setCameraOpt(l)}continue}if(c===u.EPostMessageType.Snapshot){const k=(a=this.master.control.viewContainerManager.getView(d))==null?void 0:a.displayer,h=(s=((i=this.master.control.viewContainerManager.mainView)==null?void 0:i.displayer).backgroundSnapshotContainerRef)==null?void 0:s.current;if(k&&h&&l){h.style.width=`${l.width}px`,h.style.height=`${l.height}px`;const O={...u.ViewContainerManager.defaultLayerOpt,offscreen:!1,width:l.width,height:l.height},S={...u.ViewContainerManager.defaultScreenCanvasOpt,width:l.width,height:l.height};this.snapshotThread=this.createSnapshotThread(d,{displayer:k,container:h,layerOpt:O,master:this.master,canvasOpt:S,post:this.post}),await this.snapshotThread.getSnapshot(n),this.snapshotThread.destroy(),this.snapshotThread=void 0;continue}}if(c===u.EPostMessageType.TasksQueue&&(f!=null&&f.size)){for(const[k,m]of this.backgroundThreadMap.entries()){const h=f.get(k);h&&(await m.on(h),y&&this.post({workerTasksqueueCount:y}))}continue}if(d===u.Storage_ViewId_ALL){for(const k of this.backgroundThreadMap.values())k.on(n),c===u.EPostMessageType.Destroy&&this.backgroundThreadMap.delete(d);continue}const v=this.backgroundThreadMap.get(d);v&&(v.on(n),c===u.EPostMessageType.Destroy&&this.backgroundThreadMap.delete(d))}}async consumeTargetOne(e,t){const r=this.backgroundThreadMap.get(e);r&&await r.on(t)}destroy(){this.backgroundThreadMap.clear()}}exports.BackgroundThreadManagerImpl=we;