@netless/appliance-plugin 1.1.21 → 1.1.22-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 +1 -1
- package/cdn/{fullWorker-CCXx1D.js → fullWorker-BQclbf.js} +105 -104
- package/cdn/{subWorker-BQlGot.js → subWorker-Co2GgG.js} +105 -104
- package/dist/appliance-plugin.js +1 -1
- package/dist/appliance-plugin.mjs +1 -1
- package/dist/core/enum.d.ts +3 -1
- package/dist/core/mainEngine.d.ts +3 -0
- package/dist/core/types.d.ts +6 -0
- package/dist/core/worker/workerManager.d.ts +2 -0
- package/dist/fullWorker.js +105 -104
- package/dist/index-7Ry75r2W.js +1 -0
- package/dist/{index-BZCUBik5.mjs → index-CEBD0CPi.mjs} +4 -2
- package/dist/{index-CPGlDbvm.mjs → index-Cyb4w2Wb.mjs} +3821 -3742
- package/dist/{index-CPFLN16a.js → index-ggI7Ru6d.js} +1 -1
- package/dist/plugin/baseApplianceManager.d.ts +6 -0
- package/dist/plugin/baseViewContainerManager.d.ts +6 -4
- package/dist/plugin/types.d.ts +9 -0
- package/dist/subWorker.js +105 -104
- package/package.json +1 -1
- package/dist/index-BdJLKyTl.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var Cn=Object.defineProperty;var kn=(r,i,e)=>i in r?Cn(r,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[i]=e;var M=(r,i,e)=>kn(r,typeof i!="symbol"?i+"":i,e);const H=require("white-web-sdk"),ue=require("spritejs"),ws=require("lz-string"),nt=require("clipper-lib"),_i=require("lineclip"),Yi=require("eventemitter2"),O=require("lodash"),Ui=require("xss"),m=require("react"),Ii=require("react-dom"),Yt=require("react-draggable"),xn=require("re-resizable"),bn="/fullWorker.js",Dn="/subWorker.js";var re=(r=>(r.selector="selector",r.clicker="clicker",r.laserPointer="laserPointer",r.pencil="pencil",r.rectangle="rectangle",r.ellipse="ellipse",r.shape="shape",r.eraser="eraser",r.pencilEraser="pencilEraser",r.text="text",r.straight="straight",r.arrow="arrow",r.hand="hand",r.laserPen="laserPen",r))(re||{}),se=(r=>(r.Normal="Normal",r.Stroke="Stroke",r.Dotted="Dotted",r.LongDotted="LongDotted",r))(se||{}),_e=(r=>(r.Triangle="triangle",r.Rhombus="rhombus",r.Pentagram="pentagram",r.SpeechBalloon="speechBalloon",r.Star="star",r.Polygon="polygon",r))(_e||{}),F=(r=>(r.None="None",r.ShowFloatBar="ShowFloatBar",r.ZIndexFloatBar="ZIndexFloatBar",r.DeleteNode="DeleteNode",r.CopyNode="CopyNode",r.ZIndexActive="ZIndexActive",r.ZIndexNode="ZIndexNode",r.RotateNode="RotateNode",r.SetColorNode="SetColorNode",r.TranslateNode="TranslateNode",r.ScaleNode="ScaleNode",r.OriginalEvent="OriginalEvent",r.CreateScene="CreateScene",r.ActiveCursor="ActiveCursor",r.MoveCursor="MoveCursor",r.CommandEditor="CommandEditor",r.SetEditorData="SetEditorData",r.SetFontStyle="SetFontStyle",r.SetPoint="SetPoint",r.SetLock="SetLock",r.SetShapeOpt="SetShapeOpt",r.CameraChange="CameraChange",r.ActiveMethod="ActiveMethod",r.HidFloatBarBtn="HidFloatBarBtn",r))(F||{}),ne=(r=>(r.DisplayState="DisplayState",r.MainEngine="MainEngine",r.Cursor="Cursor",r.BindMainView="BindMainView",r))(ne||{}),Is=(r=>(r[r.MainView=0]="MainView",r[r.Plugin=1]="Plugin",r[r.Both=2]="Both",r))(Is||{}),Ti=(r=>(r.longPencil="longPencil",r))(Ti||{}),v=(r=>(r[r.Pencil=1]="Pencil",r[r.Eraser=2]="Eraser",r[r.PencilEraser=3]="PencilEraser",r[r.BitMapEraser=4]="BitMapEraser",r[r.Selector=5]="Selector",r[r.Clicker=6]="Clicker",r[r.Arrow=7]="Arrow",r[r.Hand=8]="Hand",r[r.LaserPen=9]="LaserPen",r[r.Text=10]="Text",r[r.Straight=11]="Straight",r[r.Rectangle=12]="Rectangle",r[r.Ellipse=13]="Ellipse",r[r.Star=14]="Star",r[r.Triangle=15]="Triangle",r[r.Rhombus=16]="Rhombus",r[r.Polygon=17]="Polygon",r[r.SpeechBalloon=18]="SpeechBalloon",r[r.Image=19]="Image",r))(v||{}),V=(r=>(r[r.Local=1]="Local",r[r.Service=2]="Service",r[r.Worker=3]="Worker",r))(V||{}),A=(r=>(r[r.Pending=0]="Pending",r[r.Start=1]="Start",r[r.Doing=2]="Doing",r[r.Done=3]="Done",r[r.Unwritable=4]="Unwritable",r))(A||{}),b=(r=>(r[r.None=0]="None",r[r.Init=1]="Init",r[r.UpdateCamera=2]="UpdateCamera",r[r.UpdateTools=3]="UpdateTools",r[r.CreateWork=4]="CreateWork",r[r.DrawWork=5]="DrawWork",r[r.FullWork=6]="FullWork",r[r.UpdateNode=7]="UpdateNode",r[r.RemoveNode=8]="RemoveNode",r[r.Clear=9]="Clear",r[r.Select=10]="Select",r[r.Destroy=11]="Destroy",r[r.Snapshot=12]="Snapshot",r[r.BoundingBox=13]="BoundingBox",r[r.Cursor=14]="Cursor",r[r.TextUpdate=15]="TextUpdate",r[r.GetTextActive=16]="GetTextActive",r[r.TasksQueue=17]="TasksQueue",r[r.CursorHover=18]="CursorHover",r[r.CursorBlur=19]="CursorBlur",r[r.Console=20]="Console",r[r.PriorityWorker=21]="PriorityWorker",r[r.PriorityMainThreadWorker=22]="PriorityMainThreadWorker",r[r.GetImageBitMap=23]="GetImageBitMap",r[r.AuthWriter=24]="AuthWriter",r[r.AuthReader=25]="AuthReader",r[r.AuthClear=26]="AuthClear",r[r.AuthPage=27]="AuthPage",r[r.GetVNodeInfo=28]="GetVNodeInfo",r[r.UpdateDpr=29]="UpdateDpr",r[r.SetFontFace=30]="SetFontFace",r))(b||{}),we=(r=>(r[r.None=0]="None",r[r.Bg=1]="Bg",r[r.ServiceFloat=2]="ServiceFloat",r[r.Float=3]="Float",r[r.TopFloat=4]="TopFloat",r))(we||{}),Xt=(r=>(r[r.Cursor=1]="Cursor",r[r.TextCreate=2]="TextCreate",r))(Xt||{}),Jt=(r=>(r[r.Top=1]="Top",r[r.Bottom=2]="Bottom",r))(Jt||{}),ce=(r=>(r[r.none=1]="none",r[r.all=2]="all",r[r.both=3]="both",r[r.proportional=4]="proportional",r))(ce||{}),Ts=(r=>(r[r.Pending=0]="Pending",r[r.Start=1]="Start",r[r.Doing=2]="Doing",r[r.Done=3]="Done",r[r.Unwritable=4]="Unwritable",r))(Ts||{}),Nt=(r=>(r[r.inside=0]="inside",r[r.outside=1]="outside",r[r.intersect=2]="intersect",r))(Nt||{}),Re=(r=>(r.renderPage="renderPage",r.addPage="addPage",r.deletePage="deletePage",r.addElement="addElement",r.deleteElement="deleteElement",r.clearPage="clearPage",r.clearViewScenePath="clearViewScenePath",r.clearView="clearView",r))(Re||{}),tt=(r=>(r.setAuth="setAuth",r.setShow="addShow",r.setHide="setHide",r.setClear="setClear",r))(tt||{}),St=(r=>(r.Image="image",r.Iconify="iconify",r))(St||{});const Ln={linear:r=>r,easeInQuad:r=>r*r,easeOutQuad:r=>r*(2-r),easeInOutQuad:r=>r<.5?2*r*r:-1+(4-2*r)*r,easeInCubic:r=>r*r*r,easeOutCubic:r=>--r*r*r+1,easeInOutCubic:r=>r<.5?4*r*r*r:(r-1)*(2*r-2)*(2*r-2)+1,easeInQuart:r=>r*r*r*r,easeOutQuart:r=>1- --r*r*r*r,easeInOutQuart:r=>r<.5?8*r*r*r*r:1-8*--r*r*r*r,easeInQuint:r=>r*r*r*r*r,easeOutQuint:r=>1+--r*r*r*r*r,easeInOutQuint:r=>r<.5?16*r*r*r*r*r:1+16*--r*r*r*r*r,easeInSine:r=>1-Math.cos(r*Math.PI/2),easeOutSine:r=>Math.sin(r*Math.PI/2),easeInOutSine:r=>-(Math.cos(Math.PI*r)-1)/2,easeInExpo:r=>r<=0?0:Math.pow(2,10*r-10),easeOutExpo:r=>r>=1?1:1-Math.pow(2,-10*r),easeInOutExpo:r=>r<=0?0:r>=1?1:r<.5?Math.pow(2,20*r-10)/2:(2-Math.pow(2,-20*r+10))/2};class k{constructor(i=0,e=0,t=1){this.x=i,this.y=e,this.z=t}get XY(){return[this.x,this.y]}setz(i){return this.z=i,this}setXY(i=this.x,e=this.y){return this.x=i,this.y=e,this}set(i=this.x,e=this.y,t=this.z){return this.x=i,this.y=e,this.z=t,this}setTo({x:i=0,y:e=0,z:t=1}){return this.x=i,this.y=e,this.z=t,this}rot(i){if(i===0)return this;const{x:e,y:t}=this,o=Math.sin(i),s=Math.cos(i);return this.x=e*s-t*o,this.y=e*o+t*s,this}rotWith(i,e){if(e===0)return this;const t=this.x-i.x,o=this.y-i.y,s=Math.sin(e),n=Math.cos(e);return this.x=i.x+(t*n-o*s),this.y=i.y+(t*s+o*n),this}clone(){const{x:i,y:e,z:t}=this;return new k(i,e,t)}sub(i){return this.x-=i.x,this.y-=i.y,this}subXY(i,e){return this.x-=i,this.y-=e,this}subScalar(i){return this.x-=i,this.y-=i,this}add(i){return this.x+=i.x,this.y+=i.y,this}addXY(i,e){return this.x+=i,this.y+=e,this}addScalar(i){return this.x+=i,this.y+=i,this}clamp(i,e){return this.x=Math.max(this.x,i),this.y=Math.max(this.y,i),e!==void 0&&(this.x=Math.min(this.x,e),this.y=Math.min(this.y,e)),this}div(i){return this.x/=i,this.y/=i,this}divV(i){return this.x/=i.x,this.y/=i.y,this}mul(i){return this.x*=i,this.y*=i,this}mulV(i){return this.x*=i.x,this.y*=i.y,this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this}nudge(i,e){const t=k.Tan(i,this);return this.add(t.mul(e))}neg(){return this.x*=-1,this.y*=-1,this}cross(i){return this.x=this.y*i.z-this.z*i.y,this.y=this.z*i.x-this.x*i.z,this}dpr(i){return k.Dpr(this,i)}cpr(i){return k.Cpr(this,i)}len2(){return k.Len2(this)}len(){return k.Len(this)}pry(i){return k.Pry(this,i)}per(){const{x:i,y:e}=this;return this.x=e,this.y=-i,this}uni(){return k.Uni(this)}tan(i){return k.Tan(this,i)}dist(i){return k.Dist(this,i)}distanceToLineSegment(i,e){return k.DistanceToLineSegment(i,e,this)}slope(i){return k.Slope(this,i)}snapToGrid(i){return this.x=Math.round(this.x/i)*i,this.y=Math.round(this.y/i)*i,this}angle(i){return k.Angle(this,i)}toAngle(){return k.ToAngle(this)}lrp(i,e){return this.x=this.x+(i.x-this.x)*e,this.y=this.y+(i.y-this.y)*e,this}equals(i,e){return k.Equals(this,i,e)}equalsXY(i,e){return k.EqualsXY(this,i,e)}norm(){const i=this.len();return this.x=i===0?0:this.x/i,this.y=i===0?0:this.y/i,this}toFixed(){return k.ToFixed(this)}toString(){return k.ToString(k.ToFixed(this))}toJson(){return k.ToJson(this)}toArray(){return k.ToArray(this)}static Add(i,e){return new k(i.x+e.x,i.y+e.y)}static AddXY(i,e,t){return new k(i.x+e,i.y+t)}static Sub(i,e){return new k(i.x-e.x,i.y-e.y)}static SubXY(i,e,t){return new k(i.x-e,i.y-t)}static AddScalar(i,e){return new k(i.x+e,i.y+e)}static SubScalar(i,e){return new k(i.x-e,i.y-e)}static Div(i,e){return new k(i.x/e,i.y/e)}static Mul(i,e){return new k(i.x*e,i.y*e)}static DivV(i,e){return new k(i.x/e.x,i.y/e.y)}static MulV(i,e){return new k(i.x*e.x,i.y*e.y)}static Neg(i){return new k(-i.x,-i.y)}static Per(i){return new k(i.y,-i.x)}static Dist2(i,e){return k.Sub(i,e).len2()}static Abs(i){return new k(Math.abs(i.x),Math.abs(i.y))}static Dist(i,e){return Math.hypot(i.y-e.y,i.x-e.x)}static Dpr(i,e){return i.x*e.x+i.y*e.y}static Cross(i,e){return new k(i.y*e.z-i.z*e.y,i.z*e.x-i.x*e.z)}static Cpr(i,e){return i.x*e.y-e.x*i.y}static Len2(i){return i.x*i.x+i.y*i.y}static Len(i){return Math.hypot(i.x,i.y)}static Pry(i,e){return k.Dpr(i,e)/k.Len(e)}static Uni(i){return k.Div(i,k.Len(i))}static Tan(i,e){return k.Uni(k.Sub(i,e))}static Min(i,e){return new k(Math.min(i.x,e.x),Math.min(i.y,e.y))}static Max(i,e){return new k(Math.max(i.x,e.x),Math.max(i.y,e.y))}static From(i){return new k().add(i)}static FromArray(i){return new k(i[0],i[1])}static Rot(i,e=0){const t=Math.sin(e),o=Math.cos(e);return new k(i.x*o-i.y*t,i.x*t+i.y*o)}static RotWith(i,e,t){const o=i.x-e.x,s=i.y-e.y,n=Math.sin(t),a=Math.cos(t);return new k(e.x+(o*a-s*n),e.y+(o*n+s*a))}static NearestPointOnLineThroughPoint(i,e,t){return k.Mul(e,k.Sub(t,i).pry(e)).add(i)}static NearestPointOnLineSegment(i,e,t,o=!0){const s=k.Tan(e,i),n=k.Add(i,k.Mul(s,k.Sub(t,i).pry(s)));if(o){if(n.x<Math.min(i.x,e.x))return k.Cast(i.x<e.x?i:e);if(n.x>Math.max(i.x,e.x))return k.Cast(i.x>e.x?i:e);if(n.y<Math.min(i.y,e.y))return k.Cast(i.y<e.y?i:e);if(n.y>Math.max(i.y,e.y))return k.Cast(i.y>e.y?i:e)}return n}static DistanceToLineThroughPoint(i,e,t){return k.Dist(t,k.NearestPointOnLineThroughPoint(i,e,t))}static DistanceToLineSegment(i,e,t,o=!0){return k.Dist(t,k.NearestPointOnLineSegment(i,e,t,o))}static Snap(i,e=1){return new k(Math.round(i.x/e)*e,Math.round(i.y/e)*e)}static Cast(i){return i instanceof k?i:k.From(i)}static Slope(i,e){return i.x===e.y?NaN:(i.y-e.y)/(i.x-e.x)}static Angle(i,e){return Math.atan2(e.y-i.y,e.x-i.x)}static Lrp(i,e,t){return k.Sub(e,i).mul(t).add(i)}static Med(i,e){return new k((i.x+e.x)/2,(i.y+e.y)/2)}static Equals(i,e,t=1e-4){return Math.abs(i.x-e.x)<t&&Math.abs(i.y-e.y)<t}static EqualsXY(i,e,t){return i.x===e&&i.y===t}static EqualsXYZ(i,e,t=1e-4){return k.Equals(i,e,t)&&Math.abs((i.z||0)-(e.z||0))<t}static Clockwise(i,e,t){return(t.x-i.x)*(e.y-i.y)-(e.x-i.x)*(t.y-i.y)<0}static Rescale(i,e){const t=k.Len(i);return new k(e*i.x/t,e*i.y/t)}static ScaleWithOrigin(i,e,t){return k.Sub(i,t).mul(e).add(t)}static ScaleWOrigin(i,e,t){return k.Sub(i,t).mulV(e).add(t)}static ToFixed(i,e=2){return new k(+i.x.toFixed(e),+i.y.toFixed(e),+i.z.toFixed(e))}static Nudge(i,e,t){return k.Add(i,k.Tan(e,i).mul(t))}static ToString(i){return`${i.x}, ${i.y}`}static ToAngle(i){let e=Math.atan2(i.y,i.x);return e<0&&(e+=Math.PI*2),e}static FromAngle(i,e=1){return new k(Math.cos(i)*e,Math.sin(i)*e)}static ToArray(i){return[i.x,i.y,i.z]}static ToJson(i){const{x:e,y:t,z:o}=i;return{x:e,y:t,z:o}}static Average(i){const e=i.length,t=new k(0,0);for(let o=0;o<e;o++)t.add(i[o]);return t.div(e)}static Clamp(i,e,t){return t===void 0?new k(Math.min(Math.max(i.x,e)),Math.min(Math.max(i.y,e))):new k(Math.min(Math.max(i.x,e),t),Math.min(Math.max(i.y,e),t))}static PointsBetween(i,e,t=6){const o=[];for(let s=0;s<t;s++){const n=Ln.easeInQuad(s/(t-1)),a=k.Lrp(i,e,n);a.z=Math.min(1,.5+Math.abs(.5-An(n))*.65),o.push(a)}return o}static SnapToGrid(i,e=8){return new k(Math.round(i.x/e)*e,Math.round(i.y/e)*e)}}const An=r=>r<.5?2*r*r:-1+(4-2*r)*r;class Q extends k{constructor(i=0,e=0,t=0,o={x:0,y:0},s=0,n=0){super(i,e,t),this.x=i,this.y=e,this.z=t,this.v=o,this.t=s,this.a=n}get timestamp(){return this.t}get pressure(){return this.z}get angleNum(){return this.a}get XY(){return[this.x,this.y]}setA(i){this.a=i}setT(i){this.t=i}setv(i){return this.v={x:i.x,y:i.y},this}set(i=this.x,e=this.y,t=this.z,o=this.v,s=this.t,n=this.a){return this.x=i,this.y=e,this.z=t,this.v=o,this.t=s,this.a=n,this}clone(){const{x:i,y:e,z:t,v:o,t:s,a:n}=this,a={x:o.x,y:o.y};return new Q(i,e,t,a,s,n)}distance(i){return Q.GetDistance(this,i)}isNear(i,e){return Q.IsNear(this,i,e)}getAngleByPoints(i,e){return Q.GetAngleByPoints(i,this,e)}static Sub(i,e){return new Q(i.x-e.x,i.y-e.y)}static Add(i,e){return new Q(i.x+e.x,i.y+e.y)}static GetDistance(i,e){return Q.Len(i.clone().sub(e))}static GetAngleByPoints(i,e,t){const o=e.x-i.x,s=t.x-e.x,n=e.y-i.y,a=t.y-e.y;let c=0;const l=Math.sqrt(o*o+n*n),u=Math.sqrt(s*s+a*a);if(l&&u){const h=o*s+n*a;c=Math.acos(h/(l*u)),c=c/Math.PI*180;let d=o*a-n*s;d=d>0?1:-1,c=180+d*c}return c}static IsNear(i,e,t){return Q.Len(i.clone().sub(e))<t}static RotWith(i,e,t,o=2){const s=i.x-e.x,n=i.y-e.y,a=Math.sin(t),c=Math.cos(t),l=Math.pow(10,o),u=Math.floor((e.x+(s*c-n*a))*l)/l,h=Math.floor((e.y+(s*a+n*c))*l)/l;return new Q(u,h)}static GetDotStroke(i,e,t=16){const o=new k(1,1),s=Math.PI+.001,n=Q.Add(i,Q.Sub(i,o).uni().per().mul(-e)),a=[];for(let c=1/t,l=c;l<=1;l+=c)a.push(Q.RotWith(n,i,s*2*l));return a}static GetSemicircleStroke(i,e,t=-1,o=8){const s=t*(Math.PI+.001),n=[];for(let a=1/o,c=a;c<=1;c+=a)n.push(Q.RotWith(e,i,s*c));return n}}var oi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ut(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var jn=typeof oi=="object"&&oi&&oi.Object===Object&&oi,vs=jn,zn=vs,Pn=typeof self=="object"&&self&&self.Object===Object&&self,En=zn||Pn||Function("return this")(),st=En,On=st,Rn=On.Symbol,_t=Rn,Co=_t,Ns=Object.prototype,Wn=Ns.hasOwnProperty,Yn=Ns.toString,Ht=Co?Co.toStringTag:void 0;function Un(r){var i=Wn.call(r,Ht),e=r[Ht];try{r[Ht]=void 0;var t=!0}catch{}var o=Yn.call(r);return t&&(i?r[Ht]=e:delete r[Ht]),o}var Bn=Un,Fn=Object.prototype,Vn=Fn.toString;function Qn(r){return Vn.call(r)}var Zn=Qn,ko=_t,$n=Bn,Hn=Zn,Gn="[object Null]",Xn="[object Undefined]",xo=ko?ko.toStringTag:void 0;function Jn(r){return r==null?r===void 0?Xn:Gn:xo&&xo in Object(r)?$n(r):Hn(r)}var kt=Jn;function qn(r){return r!=null&&typeof r=="object"}var at=qn,Kn=kt,_n=at,er="[object Number]";function tr(r){return typeof r=="number"||_n(r)&&Kn(r)==er}var ir=tr;const We=Ut(ir);function or(){this.__data__=[],this.size=0}var sr=or;function nr(r,i){return r===i||r!==r&&i!==i}var eo=nr,rr=eo;function ar(r,i){for(var e=r.length;e--;)if(rr(r[e][0],i))return e;return-1}var vi=ar,cr=vi,lr=Array.prototype,hr=lr.splice;function ur(r){var i=this.__data__,e=cr(i,r);if(e<0)return!1;var t=i.length-1;return e==t?i.pop():hr.call(i,e,1),--this.size,!0}var dr=ur,pr=vi;function gr(r){var i=this.__data__,e=pr(i,r);return e<0?void 0:i[e][1]}var fr=gr,Mr=vi;function yr(r){return Mr(this.__data__,r)>-1}var mr=yr,wr=vi;function Ir(r,i){var e=this.__data__,t=wr(e,r);return t<0?(++this.size,e.push([r,i])):e[t][1]=i,this}var Tr=Ir,vr=sr,Nr=dr,Sr=fr,Cr=mr,kr=Tr;function Bt(r){var i=-1,e=r==null?0:r.length;for(this.clear();++i<e;){var t=r[i];this.set(t[0],t[1])}}Bt.prototype.clear=vr;Bt.prototype.delete=Nr;Bt.prototype.get=Sr;Bt.prototype.has=Cr;Bt.prototype.set=kr;var Ni=Bt,xr=Ni;function br(){this.__data__=new xr,this.size=0}var Dr=br;function Lr(r){var i=this.__data__,e=i.delete(r);return this.size=i.size,e}var Ar=Lr;function jr(r){return this.__data__.get(r)}var zr=jr;function Pr(r){return this.__data__.has(r)}var Er=Pr;function Or(r){var i=typeof r;return r!=null&&(i=="object"||i=="function")}var Mt=Or,Rr=kt,Wr=Mt,Yr="[object AsyncFunction]",Ur="[object Function]",Br="[object GeneratorFunction]",Fr="[object Proxy]";function Vr(r){if(!Wr(r))return!1;var i=Rr(r);return i==Ur||i==Br||i==Yr||i==Fr}var Ss=Vr,Qr=st,Zr=Qr["__core-js_shared__"],$r=Zr,zi=$r,bo=function(){var r=/[^.]+$/.exec(zi&&zi.keys&&zi.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function Hr(r){return!!bo&&bo in r}var Gr=Hr,Xr=Function.prototype,Jr=Xr.toString;function qr(r){if(r!=null){try{return Jr.call(r)}catch{}try{return r+""}catch{}}return""}var Cs=qr,Kr=Ss,_r=Gr,ea=Mt,ta=Cs,ia=/[\\^$.*+?()[\]{}|]/g,oa=/^\[object .+?Constructor\]$/,sa=Function.prototype,na=Object.prototype,ra=sa.toString,aa=na.hasOwnProperty,ca=RegExp("^"+ra.call(aa).replace(ia,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function la(r){if(!ea(r)||_r(r))return!1;var i=Kr(r)?ca:oa;return i.test(ta(r))}var ha=la;function ua(r,i){return r==null?void 0:r[i]}var da=ua,pa=ha,ga=da;function fa(r,i){var e=ga(r,i);return pa(e)?e:void 0}var xt=fa,Ma=xt,ya=st,ma=Ma(ya,"Map"),to=ma,wa=xt,Ia=wa(Object,"create"),Si=Ia,Do=Si;function Ta(){this.__data__=Do?Do(null):{},this.size=0}var va=Ta;function Na(r){var i=this.has(r)&&delete this.__data__[r];return this.size-=i?1:0,i}var Sa=Na,Ca=Si,ka="__lodash_hash_undefined__",xa=Object.prototype,ba=xa.hasOwnProperty;function Da(r){var i=this.__data__;if(Ca){var e=i[r];return e===ka?void 0:e}return ba.call(i,r)?i[r]:void 0}var La=Da,Aa=Si,ja=Object.prototype,za=ja.hasOwnProperty;function Pa(r){var i=this.__data__;return Aa?i[r]!==void 0:za.call(i,r)}var Ea=Pa,Oa=Si,Ra="__lodash_hash_undefined__";function Wa(r,i){var e=this.__data__;return this.size+=this.has(r)?0:1,e[r]=Oa&&i===void 0?Ra:i,this}var Ya=Wa,Ua=va,Ba=Sa,Fa=La,Va=Ea,Qa=Ya;function Ft(r){var i=-1,e=r==null?0:r.length;for(this.clear();++i<e;){var t=r[i];this.set(t[0],t[1])}}Ft.prototype.clear=Ua;Ft.prototype.delete=Ba;Ft.prototype.get=Fa;Ft.prototype.has=Va;Ft.prototype.set=Qa;var Za=Ft,Lo=Za,$a=Ni,Ha=to;function Ga(){this.size=0,this.__data__={hash:new Lo,map:new(Ha||$a),string:new Lo}}var Xa=Ga;function Ja(r){var i=typeof r;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?r!=="__proto__":r===null}var qa=Ja,Ka=qa;function _a(r,i){var e=r.__data__;return Ka(i)?e[typeof i=="string"?"string":"hash"]:e.map}var Ci=_a,ec=Ci;function tc(r){var i=ec(this,r).delete(r);return this.size-=i?1:0,i}var ic=tc,oc=Ci;function sc(r){return oc(this,r).get(r)}var nc=sc,rc=Ci;function ac(r){return rc(this,r).has(r)}var cc=ac,lc=Ci;function hc(r,i){var e=lc(this,r),t=e.size;return e.set(r,i),this.size+=e.size==t?0:1,this}var uc=hc,dc=Xa,pc=ic,gc=nc,fc=cc,Mc=uc;function Vt(r){var i=-1,e=r==null?0:r.length;for(this.clear();++i<e;){var t=r[i];this.set(t[0],t[1])}}Vt.prototype.clear=dc;Vt.prototype.delete=pc;Vt.prototype.get=gc;Vt.prototype.has=fc;Vt.prototype.set=Mc;var ks=Vt,yc=Ni,mc=to,wc=ks,Ic=200;function Tc(r,i){var e=this.__data__;if(e instanceof yc){var t=e.__data__;if(!mc||t.length<Ic-1)return t.push([r,i]),this.size=++e.size,this;e=this.__data__=new wc(t)}return e.set(r,i),this.size=e.size,this}var vc=Tc,Nc=Ni,Sc=Dr,Cc=Ar,kc=zr,xc=Er,bc=vc;function Qt(r){var i=this.__data__=new Nc(r);this.size=i.size}Qt.prototype.clear=Sc;Qt.prototype.delete=Cc;Qt.prototype.get=kc;Qt.prototype.has=xc;Qt.prototype.set=bc;var xs=Qt;function Dc(r,i){for(var e=-1,t=r==null?0:r.length;++e<t&&i(r[e],e,r)!==!1;);return r}var Lc=Dc,Ac=xt,jc=function(){try{var r=Ac(Object,"defineProperty");return r({},"",{}),r}catch{}}(),bs=jc,Ao=bs;function zc(r,i,e){i=="__proto__"&&Ao?Ao(r,i,{configurable:!0,enumerable:!0,value:e,writable:!0}):r[i]=e}var Ds=zc,Pc=Ds,Ec=eo,Oc=Object.prototype,Rc=Oc.hasOwnProperty;function Wc(r,i,e){var t=r[i];(!(Rc.call(r,i)&&Ec(t,e))||e===void 0&&!(i in r))&&Pc(r,i,e)}var Ls=Wc,Yc=Ls,Uc=Ds;function Bc(r,i,e,t){var o=!e;e||(e={});for(var s=-1,n=i.length;++s<n;){var a=i[s],c=t?t(e[a],r[a],a,e,r):void 0;c===void 0&&(c=r[a]),o?Uc(e,a,c):Yc(e,a,c)}return e}var ki=Bc;function Fc(r,i){for(var e=-1,t=Array(r);++e<r;)t[e]=i(e);return t}var Vc=Fc,Qc=kt,Zc=at,$c="[object Arguments]";function Hc(r){return Zc(r)&&Qc(r)==$c}var Gc=Hc,jo=Gc,Xc=at,As=Object.prototype,Jc=As.hasOwnProperty,qc=As.propertyIsEnumerable,Kc=jo(function(){return arguments}())?jo:function(r){return Xc(r)&&Jc.call(r,"callee")&&!qc.call(r,"callee")},js=Kc,_c=Array.isArray,ei=_c,ci={exports:{}};function el(){return!1}var tl=el;ci.exports;(function(r,i){var e=st,t=tl,o=i&&!i.nodeType&&i,s=o&&!0&&r&&!r.nodeType&&r,n=s&&s.exports===o,a=n?e.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||t;r.exports=l})(ci,ci.exports);var io=ci.exports,il=9007199254740991,ol=/^(?:0|[1-9]\d*)$/;function sl(r,i){var e=typeof r;return i=i??il,!!i&&(e=="number"||e!="symbol"&&ol.test(r))&&r>-1&&r%1==0&&r<i}var nl=sl,rl=9007199254740991;function al(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=rl}var zs=al,cl=kt,ll=zs,hl=at,ul="[object Arguments]",dl="[object Array]",pl="[object Boolean]",gl="[object Date]",fl="[object Error]",Ml="[object Function]",yl="[object Map]",ml="[object Number]",wl="[object Object]",Il="[object RegExp]",Tl="[object Set]",vl="[object String]",Nl="[object WeakMap]",Sl="[object ArrayBuffer]",Cl="[object DataView]",kl="[object Float32Array]",xl="[object Float64Array]",bl="[object Int8Array]",Dl="[object Int16Array]",Ll="[object Int32Array]",Al="[object Uint8Array]",jl="[object Uint8ClampedArray]",zl="[object Uint16Array]",Pl="[object Uint32Array]",Ne={};Ne[kl]=Ne[xl]=Ne[bl]=Ne[Dl]=Ne[Ll]=Ne[Al]=Ne[jl]=Ne[zl]=Ne[Pl]=!0;Ne[ul]=Ne[dl]=Ne[Sl]=Ne[pl]=Ne[Cl]=Ne[gl]=Ne[fl]=Ne[Ml]=Ne[yl]=Ne[ml]=Ne[wl]=Ne[Il]=Ne[Tl]=Ne[vl]=Ne[Nl]=!1;function El(r){return hl(r)&&ll(r.length)&&!!Ne[cl(r)]}var Ol=El;function Rl(r){return function(i){return r(i)}}var xi=Rl,li={exports:{}};li.exports;(function(r,i){var e=vs,t=i&&!i.nodeType&&i,o=t&&!0&&r&&!r.nodeType&&r,s=o&&o.exports===t,n=s&&e.process,a=function(){try{var c=o&&o.require&&o.require("util").types;return c||n&&n.binding&&n.binding("util")}catch{}}();r.exports=a})(li,li.exports);var oo=li.exports,Wl=Ol,Yl=xi,zo=oo,Po=zo&&zo.isTypedArray,Ul=Po?Yl(Po):Wl,Ps=Ul,Bl=Vc,Fl=js,Vl=ei,Ql=io,Zl=nl,$l=Ps,Hl=Object.prototype,Gl=Hl.hasOwnProperty;function Xl(r,i){var e=Vl(r),t=!e&&Fl(r),o=!e&&!t&&Ql(r),s=!e&&!t&&!o&&$l(r),n=e||t||o||s,a=n?Bl(r.length,String):[],c=a.length;for(var l in r)(i||Gl.call(r,l))&&!(n&&(l=="length"||o&&(l=="offset"||l=="parent")||s&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||Zl(l,c)))&&a.push(l);return a}var Es=Xl,Jl=Object.prototype;function ql(r){var i=r&&r.constructor,e=typeof i=="function"&&i.prototype||Jl;return r===e}var so=ql;function Kl(r,i){return function(e){return r(i(e))}}var Os=Kl,_l=Os,eh=_l(Object.keys,Object),th=eh,ih=so,oh=th,sh=Object.prototype,nh=sh.hasOwnProperty;function rh(r){if(!ih(r))return oh(r);var i=[];for(var e in Object(r))nh.call(r,e)&&e!="constructor"&&i.push(e);return i}var ah=rh,ch=Ss,lh=zs;function hh(r){return r!=null&&lh(r.length)&&!ch(r)}var no=hh,uh=Es,dh=ah,ph=no;function gh(r){return ph(r)?uh(r):dh(r)}var ro=gh,fh=ki,Mh=ro;function yh(r,i){return r&&fh(i,Mh(i),r)}var mh=yh;function wh(r){var i=[];if(r!=null)for(var e in Object(r))i.push(e);return i}var Ih=wh,Th=Mt,vh=so,Nh=Ih,Sh=Object.prototype,Ch=Sh.hasOwnProperty;function kh(r){if(!Th(r))return Nh(r);var i=vh(r),e=[];for(var t in r)t=="constructor"&&(i||!Ch.call(r,t))||e.push(t);return e}var xh=kh,bh=Es,Dh=xh,Lh=no;function Ah(r){return Lh(r)?bh(r,!0):Dh(r)}var ao=Ah,jh=ki,zh=ao;function Ph(r,i){return r&&jh(i,zh(i),r)}var Eh=Ph,hi={exports:{}};hi.exports;(function(r,i){var e=st,t=i&&!i.nodeType&&i,o=t&&!0&&r&&!r.nodeType&&r,s=o&&o.exports===t,n=s?e.Buffer:void 0,a=n?n.allocUnsafe:void 0;function c(l,u){if(u)return l.slice();var h=l.length,d=a?a(h):new l.constructor(h);return l.copy(d),d}r.exports=c})(hi,hi.exports);var Oh=hi.exports;function Rh(r,i){var e=-1,t=r.length;for(i||(i=Array(t));++e<t;)i[e]=r[e];return i}var Wh=Rh;function Yh(r,i){for(var e=-1,t=r==null?0:r.length,o=0,s=[];++e<t;){var n=r[e];i(n,e,r)&&(s[o++]=n)}return s}var Rs=Yh;function Uh(){return[]}var Ws=Uh,Bh=Rs,Fh=Ws,Vh=Object.prototype,Qh=Vh.propertyIsEnumerable,Eo=Object.getOwnPropertySymbols,Zh=Eo?function(r){return r==null?[]:(r=Object(r),Bh(Eo(r),function(i){return Qh.call(r,i)}))}:Fh,co=Zh,$h=ki,Hh=co;function Gh(r,i){return $h(r,Hh(r),i)}var Xh=Gh;function Jh(r,i){for(var e=-1,t=i.length,o=r.length;++e<t;)r[o+e]=i[e];return r}var lo=Jh,qh=Os,Kh=qh(Object.getPrototypeOf,Object),Ys=Kh,_h=lo,eu=Ys,tu=co,iu=Ws,ou=Object.getOwnPropertySymbols,su=ou?function(r){for(var i=[];r;)_h(i,tu(r)),r=eu(r);return i}:iu,Us=su,nu=ki,ru=Us;function au(r,i){return nu(r,ru(r),i)}var cu=au,lu=lo,hu=ei;function uu(r,i,e){var t=i(r);return hu(r)?t:lu(t,e(r))}var Bs=uu,du=Bs,pu=co,gu=ro;function fu(r){return du(r,gu,pu)}var Fs=fu,Mu=Bs,yu=Us,mu=ao;function wu(r){return Mu(r,mu,yu)}var Iu=wu,Tu=xt,vu=st,Nu=Tu(vu,"DataView"),Su=Nu,Cu=xt,ku=st,xu=Cu(ku,"Promise"),bu=xu,Du=xt,Lu=st,Au=Du(Lu,"Set"),Vs=Au,ju=xt,zu=st,Pu=ju(zu,"WeakMap"),Eu=Pu,Bi=Su,Fi=to,Vi=bu,Qi=Vs,Zi=Eu,Qs=kt,Zt=Cs,Oo="[object Map]",Ou="[object Object]",Ro="[object Promise]",Wo="[object Set]",Yo="[object WeakMap]",Uo="[object DataView]",Ru=Zt(Bi),Wu=Zt(Fi),Yu=Zt(Vi),Uu=Zt(Qi),Bu=Zt(Zi),mt=Qs;(Bi&&mt(new Bi(new ArrayBuffer(1)))!=Uo||Fi&&mt(new Fi)!=Oo||Vi&&mt(Vi.resolve())!=Ro||Qi&&mt(new Qi)!=Wo||Zi&&mt(new Zi)!=Yo)&&(mt=function(r){var i=Qs(r),e=i==Ou?r.constructor:void 0,t=e?Zt(e):"";if(t)switch(t){case Ru:return Uo;case Wu:return Oo;case Yu:return Ro;case Uu:return Wo;case Bu:return Yo}return i});var bi=mt,Fu=Object.prototype,Vu=Fu.hasOwnProperty;function Qu(r){var i=r.length,e=new r.constructor(i);return i&&typeof r[0]=="string"&&Vu.call(r,"index")&&(e.index=r.index,e.input=r.input),e}var Zu=Qu,$u=st,Hu=$u.Uint8Array,Zs=Hu,Bo=Zs;function Gu(r){var i=new r.constructor(r.byteLength);return new Bo(i).set(new Bo(r)),i}var ho=Gu,Xu=ho;function Ju(r,i){var e=i?Xu(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.byteLength)}var qu=Ju,Ku=/\w*$/;function _u(r){var i=new r.constructor(r.source,Ku.exec(r));return i.lastIndex=r.lastIndex,i}var ed=_u,Fo=_t,Vo=Fo?Fo.prototype:void 0,Qo=Vo?Vo.valueOf:void 0;function td(r){return Qo?Object(Qo.call(r)):{}}var id=td,od=ho;function sd(r,i){var e=i?od(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.length)}var nd=sd,rd=ho,ad=qu,cd=ed,ld=id,hd=nd,ud="[object Boolean]",dd="[object Date]",pd="[object Map]",gd="[object Number]",fd="[object RegExp]",Md="[object Set]",yd="[object String]",md="[object Symbol]",wd="[object ArrayBuffer]",Id="[object DataView]",Td="[object Float32Array]",vd="[object Float64Array]",Nd="[object Int8Array]",Sd="[object Int16Array]",Cd="[object Int32Array]",kd="[object Uint8Array]",xd="[object Uint8ClampedArray]",bd="[object Uint16Array]",Dd="[object Uint32Array]";function Ld(r,i,e){var t=r.constructor;switch(i){case wd:return rd(r);case ud:case dd:return new t(+r);case Id:return ad(r,e);case Td:case vd:case Nd:case Sd:case Cd:case kd:case xd:case bd:case Dd:return hd(r,e);case pd:return new t;case gd:case yd:return new t(r);case fd:return cd(r);case Md:return new t;case md:return ld(r)}}var Ad=Ld,jd=Mt,Zo=Object.create,zd=function(){function r(){}return function(i){if(!jd(i))return{};if(Zo)return Zo(i);r.prototype=i;var e=new r;return r.prototype=void 0,e}}(),Pd=zd,Ed=Pd,Od=Ys,Rd=so;function Wd(r){return typeof r.constructor=="function"&&!Rd(r)?Ed(Od(r)):{}}var Yd=Wd,Ud=bi,Bd=at,Fd="[object Map]";function Vd(r){return Bd(r)&&Ud(r)==Fd}var Qd=Vd,Zd=Qd,$d=xi,$o=oo,Ho=$o&&$o.isMap,Hd=Ho?$d(Ho):Zd,Gd=Hd,Xd=bi,Jd=at,qd="[object Set]";function Kd(r){return Jd(r)&&Xd(r)==qd}var _d=Kd,ep=_d,tp=xi,Go=oo,Xo=Go&&Go.isSet,ip=Xo?tp(Xo):ep,$s=ip;const op=Ut($s);var sp=xs,np=Lc,rp=Ls,ap=mh,cp=Eh,lp=Oh,hp=Wh,up=Xh,dp=cu,pp=Fs,gp=Iu,fp=bi,Mp=Zu,yp=Ad,mp=Yd,wp=ei,Ip=io,Tp=Gd,vp=Mt,Np=$s,Sp=ro,Cp=ao,kp=1,xp=2,bp=4,Hs="[object Arguments]",Dp="[object Array]",Lp="[object Boolean]",Ap="[object Date]",jp="[object Error]",Gs="[object Function]",zp="[object GeneratorFunction]",Pp="[object Map]",Ep="[object Number]",Xs="[object Object]",Op="[object RegExp]",Rp="[object Set]",Wp="[object String]",Yp="[object Symbol]",Up="[object WeakMap]",Bp="[object ArrayBuffer]",Fp="[object DataView]",Vp="[object Float32Array]",Qp="[object Float64Array]",Zp="[object Int8Array]",$p="[object Int16Array]",Hp="[object Int32Array]",Gp="[object Uint8Array]",Xp="[object Uint8ClampedArray]",Jp="[object Uint16Array]",qp="[object Uint32Array]",ve={};ve[Hs]=ve[Dp]=ve[Bp]=ve[Fp]=ve[Lp]=ve[Ap]=ve[Vp]=ve[Qp]=ve[Zp]=ve[$p]=ve[Hp]=ve[Pp]=ve[Ep]=ve[Xs]=ve[Op]=ve[Rp]=ve[Wp]=ve[Yp]=ve[Gp]=ve[Xp]=ve[Jp]=ve[qp]=!0;ve[jp]=ve[Gs]=ve[Up]=!1;function ri(r,i,e,t,o,s){var n,a=i&kp,c=i&xp,l=i&bp;if(e&&(n=o?e(r,t,o,s):e(r)),n!==void 0)return n;if(!vp(r))return r;var u=wp(r);if(u){if(n=Mp(r),!a)return hp(r,n)}else{var h=fp(r),d=h==Gs||h==zp;if(Ip(r))return lp(r,a);if(h==Xs||h==Hs||d&&!o){if(n=c||d?{}:mp(r),!a)return c?dp(r,cp(n,r)):up(r,ap(n,r))}else{if(!ve[h])return o?r:{};n=yp(r,h,a)}}s||(s=new sp);var f=s.get(r);if(f)return f;s.set(r,n),Np(r)?r.forEach(function(y){n.add(ri(y,i,e,y,r,s))}):Tp(r)&&r.forEach(function(y,I){n.set(I,ri(y,i,e,I,r,s))});var g=l?c?gp:pp:c?Cp:Sp,p=u?void 0:g(r);return np(p||r,function(y,I){p&&(I=y,y=r[I]),rp(n,I,ri(y,i,e,I,r,s))}),n}var Kp=ri,_p=Kp,eg=1,tg=4;function ig(r){return _p(r,eg|tg)}var og=ig;const Ae=Ut(og),Js="1.1.22-beta.1",sg="@netless/appliance-plugin",Jo=typeof OffscreenCanvas=="function"?"worker":"mainThread";if(typeof window<"u"){let r=window.__netlessUA||"";r+=` ${sg}@${Js}`,window.__netlessUA=r}const Me={useWorker:"auto",syncOpt:{interval:300,smoothSync:!0},cursor:{enable:!0,expirationTime:5e3,moveDelayTime:100},bufferSize:{full:2e4,sub:600},bezier:{enable:!0,maxDrawCount:1/0,combineUnitTime:300},pencilEraser:{useBitMap:!0,maxImageWidth:1920,maxImageHeight:1920,maxCombineTime:500},strokeWidth:{min:1,max:10},textEditor:{showFloatBar:!0,canSelectorSwitch:!0,rightBoundBreak:!1,extendFontFaces:[],loadFontFacesTimeout:1e4}};function ft(r,i=!0){const e=r.length;if(e<2)return"";let t=r[0],o=r[1];if(e===2)return`M${Lt(t)}L${Lt(o)}`;let s="";for(let n=2,a=e-1;n<a;n++)t=r[n],o=r[n+1],s+=At(t,o);return i?`M${At(r[0],r[1])}Q${Lt(r[1])}${At(r[1],r[2])}T${s}${At(r[e-1],r[0])}${At(r[0],r[1])}Z`:`M${Lt(r[0])}Q${Lt(r[1])}${At(r[1],r[2])}${r.length>3?"T":""}${s}L${Lt(r[e-1])}`}const Ge=class Ge{constructor(i){M(this,"maxImageWidth",Me.pencilEraser.maxImageWidth);M(this,"maxImageHeight",Me.pencilEraser.maxImageHeight);M(this,"syncUnitTime",Me.syncOpt.interval);M(this,"vNodes");M(this,"drawLayer");M(this,"fullLayer");M(this,"workId");M(this,"isDelete",!1);const{vNodes:e,fullLayer:t,drawLayer:o,workId:s,toolsOpt:n}=i;this.vNodes=e,this.fullLayer=t,this.drawLayer=o,this.workId=s,this.syncUnitTime=n.syncUnitTime||this.syncUnitTime}get baseConsumeResult(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions}}filterSamePoints(i,e=.01){return i.reduce((t,o)=>{const s=t[t.length-1];return(o&&!s||o&&s&&!o.isNear(s,e))&&t.push(o),t},[])}setWorkId(i){this.workId=i}getWorkId(){return this.workId}getWorkOptions(){return this.workOptions}setWorkOptions(i){var o,s,n;this.workOptions=i,this.syncUnitTime=i.syncUnitTime||this.syncUnitTime;const e=(o=this.workId)==null?void 0:o.toString(),t=e&&((s=this.vNodes)==null?void 0:s.get(e))||void 0;e&&t&&(t.opt=i,(n=this.vNodes)==null||n.setInfo(e,t))}updataOptService(i){var o,s;let e;const t=(o=this.workId)==null?void 0:o.toString();if(t&&i){const n=this.fullLayer.getElementsByName(t)||this.drawLayer&&this.drawLayer.getElementsByName(t)||[];if(n.length!==1)return;const a=n[0],{pos:c,zIndex:l,scale:u,angle:h,translate:d}=i,f={};We(l)&&(f.zIndex=l),c&&(f.pos=[c[0],c[1]]),u&&(f.scale=u),h&&(f.rotate=h),d&&(f.translate=d),a.attr(f);const g=a==null?void 0:a.getBoundingClientRect();return g&&(e=he(e,{x:Math.floor(g.x-Ge.SafeBorderPadding),y:Math.floor(g.y-Ge.SafeBorderPadding),w:Math.floor(g.width+Ge.SafeBorderPadding*2),h:Math.floor(g.height+Ge.SafeBorderPadding*2)})),(s=this.vNodes)==null||s.setInfo(t,{rect:e,centerPos:c}),e}}drawEraserlines(i,e){const{group:t,eraserlines:o,pos:s,layer:n}=i,a=n.parent;if(e)try{const l=(n.renderer.glRenderer||n.renderer.canvasRenderer).options.displayRatio,u=t.getBoundingClientRect(),h=u.width*l*n.worldScaling[0],d=u.height*l*n.worldScaling[1];let f=1;(h>this.maxImageWidth||d>this.maxImageHeight)&&(f=Math.min(this.maxImageWidth/h,this.maxImageHeight/d));let g=n.getAttribute("scale");g=[g[0]*f,g[1]*f];const p=n.parent.parent,y=n.getAttribute("translate"),I=this.createVmRenderNode(`${this.workId}_bitMapLayer`,p,{offscreen:a.offscreen,width:a.width,height:a.height,contextType:"2d",autoRender:!1,bufferSize:500},g,y),w=t.cloneNode(!0);if(!o||!o.length)return;this.addEraserlines(w,o,s,!1),I.appendChild(w);const S=I.parent;S.render();const C=I.renderer.canvasRenderer,T=C.context;if(!T)return;const N=C.options.displayRatio,x=w.getBoundingClientRect(),D={x:x.x,y:x.y,w:x.width,h:x.height},L={x:0,y:0,w:p.width,h:p.height};if(Io(D,L)===Nt.outside){Be(w,S),p.removeChild(S),this.isDelete=!0;return}const j=Ae(D);j.x=Math.floor(Math.max(D.x,0)),j.y=Math.floor(Math.max(D.y,0)),j.w=Math.min(D.x+D.w,p.width)-j.x,j.h=Math.min(D.y+D.h,p.height)-j.y;const E=this.getGroupRect(j,N),R=E.x,P=E.y,Z=E.w,_=E.h;let B=T.getImageData(R,P,Z,_);if(this.isTransparentRectByCanvas(B)){Be(w,S),p.removeChild(S),this.isDelete=!0,B=null;return}Be(t,a);const ie=this.createSpriteNode({imageData:B,safariRect:j,originRect:D,worldScaling:I.worldScaling});ie&&t.append(ie),Be(w,S),p.removeChild(S),a.deleteTexture(B),B=null}catch(c){console.error("[BaseShapeTool] drawEraserlines error:",c);return}}createVmRenderNode(i,e,t,o,s){const{width:n,height:a}=t,c=`bitMap-${i}`,l=e.layer(c,t),u=new ue.Group({anchor:[.5,.5],pos:[n*.5,a*.5],size:[n,a],name:"viewport",id:i});return u.setAttribute("scale",o),u.setAttribute("translate",s),l.append(u),u}getGroupRect(i,e){const t=Math.floor(i.x*e),o=Math.floor(i.y*e),s=Math.floor(i.w*e),n=Math.floor(i.h*e);return{x:t,y:o,w:s,h:n}}addEraserlines(i,e,t,o=!0){for(const s of e){const{thickness:n,op:a}=s;for(const c of a){const l=c.map((g,p)=>p%2?g-t[1]:g-t[0]),u=this.computEraserPoints(l,n),h=ft(u,!0),d={pos:[0,0],d:h,fillColor:"rgba(0,0,0,1)"},f=new ue.Path(d);f.addEventListener("beforerender",({detail:g})=>{const p=g.context;o?p.blendFuncSeparate(p.ZERO,p.ZERO,p.ZERO,p.ZERO):p.globalCompositeOperation="destination-out"}),f.addEventListener("afterrender",({detail:g})=>{const p=g.context;o?p.blendFuncSeparate(p.SRC_ALPHA,p.ONE_MINUS_SRC_ALPHA,p.ONE,p.ONE_MINUS_SRC_ALPHA):p.globalCompositeOperation="source-over"}),i.append(f)}}}isTransparentRectByCanvas(i){let e=!0;for(let t=0;t<i.data.length;t+=4)if(i.data[t+3]!==0){e=!1;break}return e}createSpriteNode(i){const{imageData:e,worldScaling:t,safariRect:o,originRect:s}=i;let n;if(typeof OffscreenCanvas=="function"){n=new OffscreenCanvas(e.width,e.height);const u=n.getContext("2d");u&&u.putImageData(e,0,0)}else if(typeof document<"u"){n=document.createElement("canvas"),n.width=e.width,n.height=e.height;const u=n.getContext("2d");u&&u.putImageData(e,0,0)}if(!n)return console.warn("Failed to create imageEraserBitmap Sprite"),null;const a=[Math.floor(s.w/t[0]),Math.floor(s.h/t[1])],c=[Math.floor((o.x-s.x)/t[0]),Math.floor((o.y-s.y)/t[1]),Math.floor(o.w/t[0]),Math.floor(o.h/t[1])],l={name:"eraserTexture",anchor:[.5,.5],pos:[0,0],size:a,texture:n,textureRect:c};return new ue.Sprite(l)}computEraserPoints(i,e){const t=Math.ceil(e/2);return i.length===2?this.computDot(i,t):this.computLine(i,t)}computDot(i,e){const t=new Q(i[0],i[1]);return Q.GetDotStroke(t,e,8)}computLine(i,e){const t=[],o=[];let s,n;for(let a=0;a<i.length;a+=2){const c=new Q(i[a],i[a+1]);let l;if(a==i.length-2){const u=new Q(i[a-2],i[a-1]);l=k.Sub(c,u).uni(),s=c}else{a===0&&(n=c);const u=new Q(i[a+2],i[a+3]);l=k.Sub(u,c).uni()}if(l){const u=k.Per(l).mul(e);t.push(Q.Sub(c,u)),o.push(Q.Add(c,u))}}if(s&&n){const a=Q.GetSemicircleStroke(s,t[t.length-1],-1,8),c=Q.GetSemicircleStroke(n,o[0],-1,8);return t.concat(a,o.reverse(),c)}return[]}replace(i,e,t){var s;if(!e){t&&i.append(t);return}const o=i.getElementsByName(e);if(o.length)for(const n of o)t?dy(t,n,i):(n.remove(),$e(n,i.parent));else t&&i.append(t);this.fullLayer!==this.drawLayer&&(this.fullLayer===i?(s=this.drawLayer)==null||s.getElementsByName(e).forEach(a=>{var c;a.remove(),$e(a,(c=this.drawLayer)==null?void 0:c.parent)}):this.fullLayer.getElementsByName(e).forEach(a=>{a.remove(),$e(a,this.fullLayer.parent)}))}removeDrawCountNodes(i,e){const t=[];i.getElementsByName(this.workId).forEach(o=>{o.id&&e&&Number(o.id)<e&&t.push(o)});for(const o of t)o.remove(),$e(o,i.parent)}static updateNodeOpt(i){var w;const{node:e,opt:t,vNodes:o,willSerializeData:s,targetNode:n}=i,{zIndex:a,translate:c,angle:l,originPoint:u,scenePoint:h,scale:d,pointMap:f,thickness:g}=t;let p;const y=n&&Ae(n)||o.get(e.name);if(!y)return;We(a)&&(e.setAttribute("zIndex",a),y.opt.zIndex=a);const I=e.parent;if(I){if(u&&d&&n){const S=[y.op[0],y.op[1]];mo(y.op,h,d,c);const C=[y.op[0],y.op[1]],T=[C[0]-S[0],C[1]-S[1]];if(y.centerPos=[y.centerPos[0]+T[0],y.centerPos[1]+T[1]],y.opt.translate=void 0,y.opt.scale=void 0,y.opt.eraserlines)for(let N=0;N<y.opt.eraserlines.length;N++){const{op:x,thickness:D}=y.opt.eraserlines[N];y.opt.eraserlines[N].thickness=Math.round(D*Math.max(d[0],d[1]));for(let L=0;L<x.length;L++)wo(x[L],h,d,c)}}else if(c)if(e.setAttribute("translate",c),y.opt.translate=c,n){const S=[c[0]*I.worldScaling[0],c[1]*I.worldScaling[1]];p=Kt(y.rect,S),y.rect=p}else{const S=Ge.getRectFromLayer(I,e.name);y.rect=S||y.rect}else if(We(l))if(e.setAttribute("rotate",l),y.opt.rotate=l,n)p=yn(y.rect,l),y.rect=p;else{const S=Ge.getRectFromLayer(I,e.name);y.rect=S||y.rect}if(f){const S=f.get(e.name);if(S)for(let C=0,T=0;C<y.op.length;C+=3,T++)y.op[C]=S[T][0],y.op[C+1]=S[T][1]}if(g&&((w=y==null?void 0:y.opt)!=null&&w.thickness)&&(y.opt.thickness=g),s&&!(u&&d&&n)){if(c){const S=y.op.map((C,T)=>{const N=T%3;return N===0?C+c[0]:N===1?C+c[1]:C});if(y.op=S,y.centerPos=[y.centerPos[0]+c[0],y.centerPos[1]+c[1]],y!=null&&y.opt&&(y.opt.translate=void 0),y.opt.eraserlines)for(let C=0;C<y.opt.eraserlines.length;C++){const{op:T}=y.opt.eraserlines[C];for(let N=0;N<T.length;N++){const x=T[N].map((D,L)=>L%2?D+c[1]:D+c[0]);y.opt.eraserlines[C].op[N]=x}}}else if(We(l)){const S=y.op;if(ny(S,y.centerPos,l),y.op=S,y!=null&&y.opt&&(y.opt.rotate=void 0),y.opt.eraserlines)for(let C=0;C<y.opt.eraserlines.length;C++){const{op:T}=y.opt.eraserlines[C];for(let N=0;N<T.length;N++)ry(T[N],y.centerPos,l)}}}y&&o.setInfo(e.name,y)}}static getCenterPos(i,e){const{worldPosition:t,worldScaling:o}=e;return[(i.x+i.w/2-t[0])/o[0],(i.y+i.h/2-t[1])/o[1]]}static getRectFromLayer(i,e){const t=i.getElementsByName(e)[0];if(t){const o=t.getBoundingClientRect();return{x:Math.floor(o.x-Ge.SafeBorderPadding),y:Math.floor(o.y-Ge.SafeBorderPadding),w:Math.floor(o.width+Ge.SafeBorderPadding*2),h:Math.floor(o.height+Ge.SafeBorderPadding*2)}}}static isWillRefresh(i){const{toolsType:e,opt:t,node:o,updateOpt:s,willSerializeData:n}=i;return!!(n&&(s.angle||s.translate)||s.thickness&&t.thickness&&t.thickness!==s.thickness||s.strokeType&&t.strokeType&&t.strokeType!==s.strokeType||s.originPoint&&s.scenePoint&&s.scale||s.pointMap&&s.pointMap.has(o.name)||e===v.Text&&(s.fontSize||s.translate||s.textInfos&&s.textInfos.get(o.name))||e===v.Image&&(s.angle||s.translate||s.scale||s.strokeColor&&s.type===St.Iconify)||e===s.toolsType&&s.willRefresh||t.eraserlines&&t.eraserlines.length&&(s.strokeColor||s.fillColor))}};M(Ge,"SafeBorderPadding",10);let U=Ge;const uo=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})]);function bt(r){return JSON.parse(ws.decompress(r))}function Ye(r){return ws.compress(JSON.stringify(r))}const Ee=Object.keys;function qs(r,i,e=.01){return Math.abs(r[0]-i[0])<e&&Math.abs(r[1]-i[1])<e}function ng(r,i=.01){if(r.length===0)return[];const e=[[r[0][0],r[0][1]]];for(let t=1;t<r.length;t++)qs([r[t][0],r[t][1]],e[e.length-1],i)||e.push([r[t][0],r[t][1]]);return e}function rg(r,i=.01){if(r.length<=2)return r;const e=r[0],t=r[r.length-1];return qs(e,t,i)?r.slice(0,-1):r}function ag(r){const i=r.reduce((t,o)=>t+o[0],0)/r.length,e=r.reduce((t,o)=>t+o[1],0)/r.length;return[i,e]}function qo(r,i){return Math.atan2(i[1]-r[1],i[0]-r[0])}function cg(r,i=.01){if(r.length<=2)return r;const e=[];for(const o of r)e.some(n=>Math.abs(n[0]-o[0])<i&&Math.abs(n[1]-o[1])<i)||e.push([o[0],o[1]]);const t=ag(e);return e.sort((o,s)=>{const n=qo(t,o),a=qo(t,s);return n-a})}function lg(r,i){const e=i[0].x<i[i.length-1].x;return r.map(o=>{const n=o.map(a=>{let c=-1,l=1/0,u=0;for(let h=0;h<i.length;h++){const d=i[h],f=Math.sqrt(Math.pow(d.x-a[0],2)+Math.pow(d.y-a[1],2));f<l&&(l=f,c=h,u=d.z)}return{point:a,index:c,bestZ:u}}).sort((a,c)=>a.index-c.index).map(a=>[...a.point,a.bestZ]);return e&&n[0][0]>n[n.length-1][0]||!e&&n[0][0]<n[n.length-1][0]?n.reverse():n}).sort((o,s)=>{const n=o[0][0],a=s[0][0];return e?n-a:a-n})}function hg(r,i,e=.01){const o=r.map(h=>[h.x,h.y]),s=(h,d)=>h.map(([f,g])=>({X:Math.round(f*d),Y:Math.round(g*d)})),n=new nt.ClipperOffset;n.AddPath(s(o,1e3),nt.JoinType.jtRound,nt.EndType.etOpenButt);const a=[];n.Execute(a,1);const c=new nt.Clipper;c.AddPaths(a,nt.PolyType.ptSubject,!0),i.forEach(h=>{c.AddPath(s(h,1e3),nt.PolyType.ptClip,!0)});const l=new nt.Paths;c.Execute(nt.ClipType.ctDifference,l,nt.PolyFillType.pftNonZero,nt.PolyFillType.pftNonZero);const u=l.map(h=>rg(cg(ng(h.map(d=>[d.X/1e3,d.Y/1e3]),e),e),e)).filter(h=>h.length>=2);return lg(u,r)}class Ks extends U{constructor(e){super(e);M(this,"canRotate",!0);M(this,"scaleType",ce.all);M(this,"toolsType",v.Pencil);M(this,"syncTimestamp");M(this,"syncIndex",0);M(this,"tmpPoints",[]);M(this,"MAX_REPEAR",10);M(this,"uniThickness");M(this,"workOptions");M(this,"centerPos",[0,0]);this.workOptions=e.toolsOpt,this.uniThickness=this.MAX_REPEAR/this.workOptions.thickness/10,this.syncTimestamp=0}combineConsume(){var a;const e=(a=this.workId)==null?void 0:a.toString();if(this.tmpPoints.length<2)return{type:b.None};const t=this.transformDataAll(!0),o={name:e};let s;const n=this.drawLayer||this.fullLayer;return t.length&&(s=this.draw({attrs:o,tasks:t,replaceId:e,layer:n})),{rect:s,type:b.DrawWork,dataType:V.Local}}setWorkOptions(e){super.setWorkOptions(e),this.syncTimestamp=Date.now()}consume(e){const{data:t,isFullWork:o,isSubWorker:s,isMainThread:n,drawCount:a,removeDrawCount:c}=e,{workId:l,syncUnitTime:u}=t;u&&(this.syncUnitTime=u);const{tasks:h,effects:d,consumeIndex:f}=this.transformData(t,!1);this.syncIndex=Math.min(this.syncIndex,f,Math.max(0,this.tmpPoints.length-2));const g={name:l,id:We(a)&&a.toString()||void 0};let p,y=!1;const I=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),h.length&&(h[0].taskId-this.syncTimestamp>this.syncUnitTime&&(y=!0,this.syncTimestamp=h[0].taskId,this.syncIndex=this.tmpPoints.length),s||n)){const S=o?this.fullLayer:this.drawLayer||this.fullLayer;p=this.draw({attrs:g,tasks:h,effects:d,layer:S,removeDrawCount:c})}if(s)return f>10&&this.tmpPoints.splice(0,f-10),{rect:p,type:b.DrawWork,dataType:V.Local};const w=[];return this.tmpPoints.slice(I).forEach(S=>{w.push(S.x,S.y,this.computRadius(S.z,this.workOptions.thickness))}),{...this.baseConsumeResult,type:b.DrawWork,dataType:V.Local,rect:p,op:y?w:void 0,index:y?I*3:void 0,updateNodeOpt:{useAnimation:!0}}}consumeAll(e){var u;const t=this.workId;if(e.data){const{op:h,workState:d}=e.data;h!=null&&h.length&&d===A.Done&&this.workOptions.strokeType===se.Stroke&&this.updateTempPointsWithPressureWhenDone(h)}const o=this.transformDataAll(!0),s={name:t};let n;const a=this.fullLayer;if(o.length&&(n=this.draw({attrs:s,tasks:o,replaceId:t,layer:a})),this.tmpPoints.length<2)return this.replace(a,t),{type:b.RemoveNode,removeIds:[t],rect:n};const c=[];this.tmpPoints.map(h=>{c.push(h.x,h.y,h.z)}),this.syncTimestamp=0,delete this.workOptions.syncUnitTime;const l=Ye(c);return(u=this.vNodes)==null||u.setInfo(t,{rect:n,op:c,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&U.getCenterPos(n,a)}),{...this.baseConsumeResult,rect:n,type:b.FullWork,dataType:V.Local,ops:l,updateNodeOpt:{pos:this.centerPos,useAnimation:!0}}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(e){var h,d;const{op:t,isFullWork:o,replaceId:s,workState:n=A.Done}=e;this.tmpPoints.length=0;for(let f=0;f<t.length;f+=3){const g=new Q(t[f],t[f+1],t[f+2]);if(this.tmpPoints.length>0){const p=this.tmpPoints[this.tmpPoints.length-1],y=k.Sub(g,p).uni();g.setv(y)}this.tmpPoints.push(g)}if(this.tmpPoints.length<2)return;const a=this.transformDataAll(!0),c=(h=this.workId)==null?void 0:h.toString(),l={name:c};let u;if(c&&a.length){const f=o?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({attrs:l,tasks:a,replaceId:s,layer:f,isDrawEraserlines:n===A.Done}),(d=this.vNodes)==null||d.setInfo(c,{rect:u,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:u&&U.getCenterPos(u,f)})}return u}computPencilPoints(e){const t=[],{op:o,eraserPolylines:s,eraserThickness:n}=e;this.tmpPoints.length=0;for(let c=0;c<o.length;c+=3){const l=new Q(o[c],o[c+1],o[c+2]);if(this.tmpPoints.length>0){const u=this.tmpPoints[this.tmpPoints.length-1],h=k.Sub(l,u).uni();l.setv(h)}this.tmpPoints.push(l)}if(this.tmpPoints.length<2)return;const a=this.transformDataAll(!0);if(a.length)for(let c=0;c<a.length;c++){const{pos:l,points:u}=a[c],h=u.map(g=>g.point.addXY(l[0],l[1])),d=[];for(const g of s){const p=[];for(let I=0;I<g.length;I+=2){const w=new Q(g[I],g[I+1]);if(p.length>0){const S=p[p.length-1].point,C=k.Sub(w,S).uni();w.setv(C)}p.push({point:w,radius:n})}const{ps:y}=this.computStroke(p,!1);d.push(y.map(I=>I.XY))}hg(h,d,.01).forEach(g=>{t.push(g.map(p=>[p[0],p[1],p[2]]).flat(1))})}return t}transformDataAll(e=!0){const t=this.filterSamePoints(this.tmpPoints,this.workOptions.thickness);return this.getTaskPoints(t,e&&this.workOptions.thickness||void 0)}draw(e){const{attrs:t,tasks:o,replaceId:s,effects:n,layer:a,removeDrawCount:c,isDrawEraserlines:l=!0}=e,{strokeColor:u,strokeType:h,thickness:d,zIndex:f,scale:g,rotate:p,translate:y,eraserlines:I}=this.workOptions;n!=null&&n.size&&(n.forEach(x=>{var D;(D=a.getElementById(x+""))==null||D.remove()}),n.clear()),c&&this.removeDrawCountNodes(a,c);let w;const S=[],C=a.worldPosition,T=a.worldScaling;for(let x=0;x<o.length;x++){const{pos:D,points:L}=o[x],{ps:z,rect:j}=this.computDrawPoints(L);let E;const R=L.length===1;h===se.Stroke||R?E=ft(z,!0):E=ft(z,!1);const P={pos:D,d:E,fillColor:h===se.Stroke||R?u:void 0,lineDash:h===se.Dotted&&!R?[1,d*2]:h===se.LongDotted&&!R?[d,d*2]:void 0,strokeColor:u,lineCap:h===se.Stroke||R?void 0:"round",lineWidth:h===se.Stroke||R?0:d};w=he(w,{x:Math.floor((j.x+D[0])*T[0]+C[0]-U.SafeBorderPadding),y:Math.floor((j.y+D[1])*T[1]+C[1]-U.SafeBorderPadding),w:Math.floor(j.w*T[0]+2*U.SafeBorderPadding),h:Math.floor(j.h*T[1]+2*U.SafeBorderPadding)}),S.push(P)}g&&(t.scale=g),p&&(t.rotate=p),y&&(t.translate=y);const N=new ue.Group;if(w){this.centerPos=U.getCenterPos(w,a);const x=h===se.Stroke&&!I;N.attr({...t,normalize:!0,anchor:[.5,.5],bgcolor:x?u:void 0,pos:this.centerPos,size:[(w.w-2*U.SafeBorderPadding)/T[0],(w.h-2*U.SafeBorderPadding)/T[1]],zIndex:f});const D=S.map(L=>(L.pos=[L.pos[0]-this.centerPos[0],L.pos[1]-this.centerPos[1]],new ue.Path(L)));N.append(...D),x&&N.seal(),I&&(this.scaleType=ce.proportional,this.drawEraserlines({group:N,eraserlines:I,pos:this.centerPos,layer:a},l)),this.replace(a,s,N)}if(g||p||y){const x=N==null?void 0:N.getBoundingClientRect();x&&(w={x:Math.floor(x.x-U.SafeBorderPadding),y:Math.floor(x.y-U.SafeBorderPadding),w:Math.floor(x.width+U.SafeBorderPadding*2),h:Math.floor(x.height+U.SafeBorderPadding*2)})}return this.isDelete&&N.setAttribute("opacity",0),w}computDrawPoints(e){return this.workOptions.strokeType===se.Stroke||e.length===1?this.computStroke(e):this.computNomal(e)}computNomal(e){let t=this.workOptions.thickness;const o=e.map(s=>(t=Math.max(t,s.radius),s.point));return{ps:o,rect:me(o,t)}}computStroke(e,t=!0){return e.length===1?this.computDotStroke(e[0]):this.computLineStroke(e,t)}computLineStroke(e,t=!0){const o=[],s=[];for(let c=0;c<e.length;c++){const{point:l,radius:u}=e[c];let h=l.v;c===0&&e.length>1&&(h=e[c+1].point.v);const d=k.Per(h).mul(u);o.push(Q.Sub(l,d)),s.push(Q.Add(l,d))}const n=e[e.length-1];if(t){const c=Q.GetSemicircleStroke(n.point,o[o.length-1],-1,8),l=Q.GetSemicircleStroke(e[0].point,s[0],-1,8),u=o.concat(c,s.reverse(),l);return{ps:u,rect:me(u)}}const a=o.concat(s.reverse());return{ps:a,rect:me(a)}}computDotStroke(e){const{point:t,radius:o}=e,s={x:t.x-o,y:t.y-o,w:o*2,h:o*2};return{ps:Q.GetDotStroke(t,o,8),rect:s}}transformData(e,t){const{op:o,workState:s}=e;let n=this.tmpPoints.length-1,a=[];if(o!=null&&o.length&&s){const{strokeType:c,thickness:l}=this.workOptions,u=new Set;n=c===se.Stroke?this.updateTempPointsWithPressure(o,l,u):this.updateTempPoints(o,l,u);const h=t?this.tmpPoints:this.tmpPoints.slice(n);return a=this.getTaskPoints(h,l),{tasks:a,effects:u,consumeIndex:n}}return{tasks:a,consumeIndex:n}}computRadius(e,t){return e*.03*t+t*.5}getMinZ(e,t){return((t||Math.max(1,Math.floor(e*.3)))-e*.5)*100/e/3}getTaskPoints(e,t){var h;const o=[];if(e.length===0)return[];let s=0,n=e[0].x,a=e[0].y,c=[n,a],l=[],u=e[0].t;for(;s<e.length;){const d=e[s],f=d.x-n,g=d.y-a,p=d.z,y=t?this.computRadius(p,t):p;if(l.push({point:new Q(f,g,p,e[s].v),radius:y}),s>0&&s<e.length-1){const I=e[s].getAngleByPoints(e[s-1],e[s+1]);if(I<60||I>300){const w=(h=l.pop())==null?void 0:h.point.clone();w&&o.push({taskId:u,pos:c,points:[...l,{point:w,radius:y}]}),n=e[s].x,a=e[s].y,c=[n,a];const S=d.x-n,C=d.y-a;l=[{point:new Q(S,C,p),radius:y}],u=Date.now()}}s++}return o.push({taskId:u,pos:c,points:l}),o}updateTempPointsWithPressure(e,t,o){const s=Date.now(),n=this.tmpPoints.length;let a=n;for(let l=0;l<e.length;l+=2){a=Math.min(a,n);const u=this.tmpPoints.length,h=new Q(e[l],e[l+1]);if(u===0){this.tmpPoints.push(h);continue}const d=u-1,f=this.tmpPoints[d],g=k.Sub(h,f).uni();if(h.isNear(f,t)){if(f.z<this.MAX_REPEAR){if(f.setz(Math.min(f.z+1,this.MAX_REPEAR)),a=Math.min(a,d),u>1){let I=u-1;for(;I>0;){const w=this.tmpPoints[I].distance(this.tmpPoints[I-1]),S=Math.max(this.tmpPoints[I].z-this.uniThickness*w,0);if(this.tmpPoints[I-1].z>=S)break;this.tmpPoints[I-1].setz(S),a=Math.min(a,I-1),I--}}}else a=1/0;continue}h.setv(g);const p=h.distance(f),y=Math.max(f.z-this.uniThickness*p,0);u>1&&k.Equals(g,f.v,.02)&&(y>0||f.z<=0)&&(o&&f.t&&o.add(f.t),this.tmpPoints.pop(),a=Math.min(d,a)),h.setz(y),this.tmpPoints.push(h)}if(a===1/0)return this.tmpPoints.length;let c=n;if(a===n){c=Math.max(c-1,0);const l=this.tmpPoints[c].t;l&&(o==null||o.add(l))}else{let l=n-1;for(c=a;l>=0;){const u=this.tmpPoints[l].t;if(u&&(o==null||o.add(u),l<=a)){c=l,l=-1;break}l--}}return this.tmpPoints[c].setT(s),c}updateTempPoints(e,t,o){var l;const s=Date.now(),n=this.tmpPoints.length;let a=n;for(let u=0;u<e.length;u+=2){const h=this.tmpPoints.length,d=new Q(e[u],e[u+1]);if(h===0){this.tmpPoints.push(d);continue}const f=h-1,g=this.tmpPoints[f],p=k.Sub(d,g).uni();if(d.isNear(g,t/2)){a=Math.min(f,a);continue}k.Equals(p,g.v,.02)&&(o&&g.t&&o.add(g.t),this.tmpPoints.pop(),a=Math.min(f,a)),d.setv(p),this.tmpPoints.push(d)}let c=n;if(a===n){c=Math.max(c-1,0);const u=this.tmpPoints[c].t;u&&(o==null||o.add(u))}else{let u=Math.min(n-1,a);for(c=a;u>=0;){const h=(l=this.tmpPoints[u])==null?void 0:l.t;if(h&&(o==null||o.add(h),u<=a)){c=u,u=-1;break}u--}}return this.tmpPoints[c].setT(s),c}updateTempPointsWithPressureWhenDone(e){const{thickness:t}=this.workOptions,o=e.length,s=this.getMinZ(t);for(let n=0;n<o;n+=2){const a=this.tmpPoints.length,c=new Q(e[n],e[n+1]);if(a===0){this.tmpPoints.push(c);continue}const l=a-1,u=this.tmpPoints[l],h=k.Sub(c,u).uni(),d=c.distance(u);if(a>1&&u.z===s)break;if(c.isNear(u,t/2)){if(o<3&&u.z<this.MAX_REPEAR&&(u.setz(Math.min(u.z+1,this.MAX_REPEAR)),a>1)){let g=a-1;for(;g>0;){const p=this.tmpPoints[g].distance(this.tmpPoints[g-1]),y=Math.max(this.tmpPoints[g].z-this.uniThickness*p,-t/4);if(this.tmpPoints[g-1].z>=y)break;this.tmpPoints[g-1].setz(y),g--}}continue}c.setv(h);const f=Math.max(u.z-this.uniThickness*d,s);a>1&&k.Equals(h,u.v,.02)&&u.z<=0&&this.tmpPoints.pop(),c.setz(f),this.tmpPoints.push(c)}}static updateNodeOpt(e){var l,u;const{node:t,opt:o,vNodes:s}=e,{strokeColor:n,strokeType:a}=o,c=s.get(t.name);return n&&(t.tagName==="GROUP"?uy(t)?t.setAttribute("bgcolor",n):t.children.forEach(h=>{h.setAttribute("strokeColor",n),h.getAttribute("fillColor")&&h.setAttribute("fillColor",n)}):(t.setAttribute("strokeColor",n),t.setAttribute("fillColor",n)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=n)),a&&(c!=null&&c.opt)&&((u=c.opt)!=null&&u.strokeType)&&(c.opt.strokeType=a),c&&s.setInfo(t.name,c),U.updateNodeOpt(e)}}class _s extends U{constructor(e){super(e);M(this,"toolsType",v.LaserPen);M(this,"canRotate",!1);M(this,"scaleType",ce.none);M(this,"syncTimestamp");M(this,"syncIndex",0);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"consumeIndex",0);this.workOptions=e.toolsOpt,this.syncTimestamp=0}combineConsume(){}setWorkOptions(e){super.setWorkOptions(e),this.syncTimestamp=Date.now()}consume(e){const{data:t,isSubWorker:o}=e,{workId:s,op:n,syncUnitTime:a}=t;if((n==null?void 0:n.length)===0)return{type:b.None};if(a&&(this.syncUnitTime=a),this.updateTempPoints(n||[]),this.consumeIndex>this.tmpPoints.length-4)return{type:b.None};const{strokeColor:c,thickness:l,strokeType:u}=this.workOptions,h=me(this.tmpPoints,l);let d=!1;const f=this.syncIndex,g=this.tmpPoints.slice(this.consumeIndex);this.consumeIndex=this.tmpPoints.length-1,this.syncTimestamp===0&&(this.syncTimestamp=Date.now());const p={name:s==null?void 0:s.toString(),opacity:1,lineDash:u===se.Dotted?[1,l*2]:u===se.LongDotted?[l,l*2]:void 0,strokeColor:c,lineCap:"round",lineWidth:l,anchor:[.5,.5]},y=this.getTaskPoints(g);if(y.length){const w=Date.now();w-this.syncTimestamp>this.syncUnitTime&&(d=!0,this.syncTimestamp=w,this.syncIndex=this.tmpPoints.length),o&&this.draw({attrs:p,tasks:y,isDot:!1,layer:this.drawLayer||this.fullLayer})}const I=[];return this.tmpPoints.slice(f).forEach(w=>{I.push(w.x,w.y)}),{rect:{x:h.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:h.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:h.w*this.fullLayer.worldScaling[0],h:h.h*this.fullLayer.worldScaling[1]},type:b.DrawWork,dataType:V.Local,op:d?I:void 0,index:d?f*2:void 0,...this.baseConsumeResult}}consumeAll(){var n;const e=(n=this.workId)==null?void 0:n.toString();let t;if(this.tmpPoints.length-1>this.consumeIndex){let a=this.tmpPoints.slice(this.consumeIndex);const c=a.length===1,{strokeColor:l,thickness:u,strokeType:h}=this.workOptions;if(c){const g=this.computDotStroke({point:a[0],radius:u/2});a=g.ps,t=g.rect}else t=me(this.tmpPoints,u);const d={name:e==null?void 0:e.toString(),fillColor:c?l:void 0,opacity:1,lineDash:h===se.Dotted&&!c?[1,u*2]:h===se.LongDotted&&!c?[u,u*2]:void 0,strokeColor:l,lineCap:c?void 0:"round",lineWidth:c?0:u,anchor:[.5,.5]},f=this.getTaskPoints(a);f.length&&this.draw({attrs:d,tasks:f,isDot:c,layer:this.drawLayer||this.fullLayer})}const o=[];this.tmpPoints.forEach(a=>{o.push(a.x,a.y)});const s=Ye(o);return{rect:t&&{x:t.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:t.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:t.w*this.fullLayer.worldScaling[0],h:t.h*this.fullLayer.worldScaling[1]},type:b.FullWork,dataType:V.Local,ops:s,index:this.syncIndex*2,...this.baseConsumeResult}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(e){var p;const{op:t,replaceId:o,isFullWork:s}=e,{strokeColor:n,thickness:a,strokeType:c}=this.workOptions;if(!t.length){const y=me(this.tmpPoints,a);return{x:y.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:y.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:y.w*this.fullLayer.worldScaling[0],h:y.h*this.fullLayer.worldScaling[1]}}const l=Math.max(0,this.tmpPoints.length-1);this.updateTempPoints(t||[]);let u,h=this.tmpPoints.slice(l);const d=h.length===1;if(d){const y=this.computDotStroke({point:h[0],radius:a/2});h=y.ps,u=y.rect}else u=me(this.tmpPoints,a);const f={name:(p=this.workId)==null?void 0:p.toString(),fillColor:d?n:void 0,opacity:1,lineDash:c===se.Dotted&&!d?[1,a*2]:c===se.LongDotted&&!d?[a,a*2]:void 0,strokeColor:n,lineCap:d?void 0:"round",lineWidth:d?0:a,anchor:[.5,.5]},g=this.getTaskPoints(h);if(g.length){const y=s?this.fullLayer:this.drawLayer||this.fullLayer;this.draw({attrs:f,tasks:g,isDot:d,replaceId:o,layer:y})}return{x:u.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:u.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:u.w*this.fullLayer.worldScaling[0],h:u.h*this.fullLayer.worldScaling[1]}}computDotStroke(e){const{point:t,radius:o}=e,s={x:t.x-o,y:t.y-o,w:o*2,h:o*2};return{ps:Q.GetDotStroke(t,o,8),rect:s}}updateTempPoints(e){const t=this.tmpPoints.length;for(let o=0;o<e.length;o+=2){if(t){const s=this.tmpPoints.slice(-1)[0];s&&s.x===e[o]&&s.y===e[o+1]&&this.tmpPoints.pop()}this.tmpPoints.push(new Q(e[o],e[o+1]))}}async draw(e){const{attrs:t,tasks:o,isDot:s,layer:n}=e,{duration:a}=this.workOptions;for(const c of o){const l=new ue.Path,{pos:u,points:h}=c;let d;s?d=ft(h,!0):d=ft(h,!1),l.attr({...t,pos:u,d});const{vertex:f,fragment:g}=this.workOptions;if(f&&g){const p=n.renderer.createProgram({vertex:f,fragment:g}),{width:y,height:I}=n.getResolution();l.setUniforms({u_time:0,u_resolution:[y,I]}),l.setProgram(p)}n.appendChild(l),l.transition(a).attr({scale:s?[.1,.1]:[1,1],lineWidth:s?0:1}).then(()=>{l.remove()})}}getTaskPoints(e){var l;const t=[];if(e.length===0)return[];let o=0,s=e[0].x,n=e[0].y,a=[s,n],c=[];for(;o<e.length;){const u=e[o],h=u.x-s,d=u.y-n;if(c.push(new Q(h,d)),o>0&&o<e.length-1){const f=e[o].getAngleByPoints(e[o-1],e[o+1]);if(f<60||f>300){const g=(l=c.pop())==null?void 0:l.clone();g&&t.push({pos:a,points:[...c,g]}),s=e[o].x,n=e[o].y,a=[s,n];const p=u.x-s,y=u.y-n;c=[new Q(p,y)]}}o++}return t.push({pos:a,points:c}),t}removeLocal(){}removeService(e){let t;const o=[];return this.fullLayer.getElementsByName(e).forEach(s=>{if(s.name===e){const n=s.getBoundingClientRect();t=he(t,{x:n.x,y:n.y,w:n.width,h:n.height}),o.push(s)}}),o.length&&o.forEach(s=>s.remove()),t}}const Pt=class Pt extends U{constructor(e,t){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.none);M(this,"toolsType",v.Eraser);M(this,"serviceWork");M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"worldPosition");M(this,"worldScaling");M(this,"eraserRect");M(this,"eraserPolyline");this.serviceWork=t,this.workOptions=e.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}combineConsume(){}consumeService(){}setWorkOptions(e){super.setWorkOptions(e)}createEraserRect(e){const t=e[0]*this.worldScaling[0]+this.worldPosition[0],o=e[1]*this.worldScaling[1]+this.worldPosition[1],{width:s,height:n}=Pt.eraserSizes[this.workOptions.thickness];this.eraserRect={x:t-s*.5,y:o-n*.5,w:s,h:n},this.eraserPolyline=[this.eraserRect.x,this.eraserRect.y,this.eraserRect.x+this.eraserRect.w,this.eraserRect.y+this.eraserRect.h]}computRectCenterPoints(){const e=this.tmpPoints.slice(-2);if(this.tmpPoints.length===4){const t=new k(this.tmpPoints[0],this.tmpPoints[1]),o=new k(this.tmpPoints[2],this.tmpPoints[3]),s=k.Sub(o,t).uni(),n=k.Dist(t,o),{width:a,height:c}=Pt.eraserSizes[this.workOptions.thickness],l=Math.min(a,c),u=Math.round(n/l);if(u>1){const h=[];for(let d=0;d<u;d++){const f=k.Mul(s,d*l);h.push(this.tmpPoints[0]+f.x,this.tmpPoints[1]+f.y)}return h.concat(e)}}return e}isNear(e,t){const o=new k(e[0],e[1]),s=new k(t[0],t[1]),{width:n,height:a}=Pt.eraserSizes[this.workOptions.thickness];return k.Dist(o,s)<Math.hypot(n,a)*.5}remove(e){const{curNodeMap:t,removeIds:o}=e;let s;for(const n of t.values())if(n.rect&&this.eraserRect&&this.eraserPolyline&&Hi(this.eraserRect,n.rect)){const{op:a}=n,c=[],l=[];for(let h=0;h<a.length;h+=3){const d=new k(a[h]*this.worldScaling[0]+this.worldPosition[0],a[h+1]*this.worldScaling[1]+this.worldPosition[1],a[h+2]);l.push(d),c.push(new Q(d.x,d.y))}const u=c.length&&me(c)||n.rect;Hi(u,this.eraserRect)&&(l.length>1?_i.polyline(l.map(d=>d.XY),this.eraserPolyline).length&&o.add(n.name):o.add(n.name),s=he(s,n.rect||u))}return o.forEach(n=>{var c;const a=this.fullLayer.getElementsByName(n);a[0]&&(a[0].remove(),$e(a[0],this.fullLayer.parent),(c=this.vNodes)==null||c.delete(n))}),s&&(s.x-=U.SafeBorderPadding,s.y-=U.SafeBorderPadding,s.w+=U.SafeBorderPadding*2,s.h+=U.SafeBorderPadding*2),s}consume(e){const{op:t,disableEraseImage:o,disableEraseText:s}=e.data;if(!t||t.length===0)return{type:b.None,...this.baseConsumeResult};const n=this.tmpPoints.length;if(n>1&&this.isNear([t[0],t[1]],[this.tmpPoints[n-2],this.tmpPoints[n-1]]))return{type:b.None,...this.baseConsumeResult};n<3?this.tmpPoints.push(t[0],t[1]):this.tmpPoints.splice(2,2,t[0],t[1]);const a=this.computRectCenterPoints();let c;const l=new Set;if(!this.vNodes)return{type:b.None,...this.baseConsumeResult};const u=this.getCanEraserNodeMap(this.vNodes.getCanEraserNodes(this.vNodes.curNodeMap,{disableEraseImage:o,disableEraseText:s}));for(let h=0;h<a.length-1;h+=2){this.createEraserRect(a.slice(h,h+2));const d=this.remove({curNodeMap:u,removeIds:l});c=he(c,d)}return c&&l.size?{type:b.RemoveNode,rect:c,removeIds:[...l]}:{type:b.None,...this.baseConsumeResult}}consumeAll(e){return this.consume(e)}clearTmpPoints(){this.tmpPoints.length=0}getCanEraserNodeMap(e){var t;if(this.serviceWork){const o=new Map(e),s=this.serviceWork.selectorWorkShapes,n=this.serviceWork.workShapes;for(const a of s.values())if((t=a.selectIds)!=null&&t.length)for(const c of a.selectIds)o.delete(c);for(const a of n.keys())o.delete(a);return o}return e}};M(Pt,"eraserSizes",uo);let ui=Pt;const Ze="++",G="selector",ai="all";var ug="__lodash_hash_undefined__";function dg(r){return this.__data__.set(r,ug),this}var pg=dg;function gg(r){return this.__data__.has(r)}var fg=gg,Mg=ks,yg=pg,mg=fg;function di(r){var i=-1,e=r==null?0:r.length;for(this.__data__=new Mg;++i<e;)this.add(r[i])}di.prototype.add=di.prototype.push=yg;di.prototype.has=mg;var po=di;function wg(r,i){for(var e=-1,t=r==null?0:r.length;++e<t;)if(i(r[e],e,r))return!0;return!1}var Ig=wg;function Tg(r,i){return r.has(i)}var go=Tg,vg=po,Ng=Ig,Sg=go,Cg=1,kg=2;function xg(r,i,e,t,o,s){var n=e&Cg,a=r.length,c=i.length;if(a!=c&&!(n&&c>a))return!1;var l=s.get(r),u=s.get(i);if(l&&u)return l==i&&u==r;var h=-1,d=!0,f=e&kg?new vg:void 0;for(s.set(r,i),s.set(i,r);++h<a;){var g=r[h],p=i[h];if(t)var y=n?t(p,g,h,i,r,s):t(g,p,h,r,i,s);if(y!==void 0){if(y)continue;d=!1;break}if(f){if(!Ng(i,function(I,w){if(!Sg(f,w)&&(g===I||o(g,I,e,t,s)))return f.push(w)})){d=!1;break}}else if(!(g===p||o(g,p,e,t,s))){d=!1;break}}return s.delete(r),s.delete(i),d}var en=xg;function bg(r){var i=-1,e=Array(r.size);return r.forEach(function(t,o){e[++i]=[o,t]}),e}var Dg=bg;function Lg(r){var i=-1,e=Array(r.size);return r.forEach(function(t){e[++i]=t}),e}var fo=Lg,Ko=_t,_o=Zs,Ag=eo,jg=en,zg=Dg,Pg=fo,Eg=1,Og=2,Rg="[object Boolean]",Wg="[object Date]",Yg="[object Error]",Ug="[object Map]",Bg="[object Number]",Fg="[object RegExp]",Vg="[object Set]",Qg="[object String]",Zg="[object Symbol]",$g="[object ArrayBuffer]",Hg="[object DataView]",es=Ko?Ko.prototype:void 0,Pi=es?es.valueOf:void 0;function Gg(r,i,e,t,o,s,n){switch(e){case Hg:if(r.byteLength!=i.byteLength||r.byteOffset!=i.byteOffset)return!1;r=r.buffer,i=i.buffer;case $g:return!(r.byteLength!=i.byteLength||!s(new _o(r),new _o(i)));case Rg:case Wg:case Bg:return Ag(+r,+i);case Yg:return r.name==i.name&&r.message==i.message;case Fg:case Qg:return r==i+"";case Ug:var a=zg;case Vg:var c=t&Eg;if(a||(a=Pg),r.size!=i.size&&!c)return!1;var l=n.get(r);if(l)return l==i;t|=Og,n.set(r,i);var u=jg(a(r),a(i),t,o,s,n);return n.delete(r),u;case Zg:if(Pi)return Pi.call(r)==Pi.call(i)}return!1}var Xg=Gg,ts=Fs,Jg=1,qg=Object.prototype,Kg=qg.hasOwnProperty;function _g(r,i,e,t,o,s){var n=e&Jg,a=ts(r),c=a.length,l=ts(i),u=l.length;if(c!=u&&!n)return!1;for(var h=c;h--;){var d=a[h];if(!(n?d in i:Kg.call(i,d)))return!1}var f=s.get(r),g=s.get(i);if(f&&g)return f==i&&g==r;var p=!0;s.set(r,i),s.set(i,r);for(var y=n;++h<c;){d=a[h];var I=r[d],w=i[d];if(t)var S=n?t(w,I,d,i,r,s):t(I,w,d,r,i,s);if(!(S===void 0?I===w||o(I,w,e,t,s):S)){p=!1;break}y||(y=d=="constructor")}if(p&&!y){var C=r.constructor,T=i.constructor;C!=T&&"constructor"in r&&"constructor"in i&&!(typeof C=="function"&&C instanceof C&&typeof T=="function"&&T instanceof T)&&(p=!1)}return s.delete(r),s.delete(i),p}var ef=_g,Ei=xs,tf=en,of=Xg,sf=ef,is=bi,os=ei,ss=io,nf=Ps,rf=1,ns="[object Arguments]",rs="[object Array]",si="[object Object]",af=Object.prototype,as=af.hasOwnProperty;function cf(r,i,e,t,o,s){var n=os(r),a=os(i),c=n?rs:is(r),l=a?rs:is(i);c=c==ns?si:c,l=l==ns?si:l;var u=c==si,h=l==si,d=c==l;if(d&&ss(r)){if(!ss(i))return!1;n=!0,u=!1}if(d&&!u)return s||(s=new Ei),n||nf(r)?tf(r,i,e,t,o,s):of(r,i,c,e,t,o,s);if(!(e&rf)){var f=u&&as.call(r,"__wrapped__"),g=h&&as.call(i,"__wrapped__");if(f||g){var p=f?r.value():r,y=g?i.value():i;return s||(s=new Ei),o(p,y,e,t,s)}}return d?(s||(s=new Ei),sf(r,i,e,t,o,s)):!1}var lf=cf,hf=lf,cs=at;function tn(r,i,e,t,o){return r===i?!0:r==null||i==null||!cs(r)&&!cs(i)?r!==r&&i!==i:hf(r,i,e,t,tn,o)}var uf=tn,df=uf;function pf(r,i){return df(r,i)}var gf=pf;const lt=Ut(gf);function ti(r,i,e){return"#"+((r<<16)+(i<<8)+e).toString(16).padStart(6,"0")}function be(r,i=1){return"rgba("+parseInt("0x"+r.slice(1,3))+","+parseInt("0x"+r.slice(3,5))+","+parseInt("0x"+r.slice(5,7))+","+i+")"}function wt(r,i,e,t=1){return`rgba(${r},${i},${e},${t})`}function Di(r){const i=r.split(","),e=parseInt(i[0].split("(")[1]),t=parseInt(i[1]),o=parseInt(i[2]),s=Number(i[3].split(")")[0]);return[ti(e,t,o),s]}function Gt(r){const i=r.split(","),e=parseInt(i[0].split("(")[1]),t=parseInt(i[1]),o=parseInt(i[2]),s=Number(i[3].split(")")[0]);return[e,t,o,s]}function ni(r){return r==="transparent"}const wi=class wi extends U{constructor(e){super(e);M(this,"toolsType",v.Selector);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"vNodes");M(this,"selectIds");M(this,"selectorColor");M(this,"strokeColor");M(this,"fillColor");M(this,"oldSelectRect");M(this,"canRotate",!1);M(this,"canTextEdit",!1);M(this,"canLock",!1);M(this,"scaleType",ce.all);M(this,"toolsTypes");M(this,"shapeOpt");M(this,"textOpt");M(this,"isLocked");M(this,"thickness");M(this,"strokeType");M(this,"useStroke");this.workOptions=e.toolsOpt,this.vNodes=e.vNodes}computSelector(e=!0){const t=me(this.tmpPoints);if(t.w===0||t.h===0)return{selectIds:[],intersectRect:void 0,subNodeMap:new Map};const{rectRange:o,nodeRange:s}=this.vNodes.getRectIntersectRange(t,e);return{selectIds:[...s.keys()],intersectRect:o,subNodeMap:s}}updateTempPoints(e){const t=this.tmpPoints.length,o=e.length;if(o>1){const s=new Q(e[o-2]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],e[o-1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]);t===2?this.tmpPoints.splice(1,1,s):this.tmpPoints.push(s)}}drawSelector(e){const{drawRect:t,subNodeMap:o,selectorId:s,layer:n,isService:a}=e,c=new ue.Group({pos:[t.x,t.y],anchor:[0,0],size:[t.w,t.h],id:s,name:s,zIndex:9999}),l=[];if(a){const u=new ue.Rect({normalize:!0,pos:[t.w/2,t.h/2],lineWidth:1,strokeColor:this.selectorColor||this.workOptions.strokeColor,width:t.w,height:t.h,name:wi.selectorBorderId});l.push(u)}o.forEach((u,h)=>{const d=[u.rect.x+u.rect.w/2-t.x,u.rect.y+u.rect.h/2-t.y],f=new ue.Rect({normalize:!0,pos:d,lineWidth:1,strokeColor:o.size>1?this.selectorColor||this.workOptions.strokeColor:void 0,width:u.rect.w,height:u.rect.h,id:`selector-${h}`,name:`selector-${h}`});l.push(f)}),l&&c.append(...l),(n==null?void 0:n.parent).appendChild(c)}draw(e,t,o,s=!1){var c,l;const{intersectRect:n,subNodeMap:a}=o;(l=(c=t.parent)==null?void 0:c.getElementById(e))==null||l.remove(),n&&this.drawSelector({drawRect:n,subNodeMap:a,selectorId:e,layer:t,isService:s})}getSelecteorInfo(e){this.scaleType=ce.all,this.canRotate=!1,this.textOpt=void 0,this.strokeColor=void 0,this.fillColor=void 0,this.canTextEdit=!1,this.canLock=!1,this.isLocked=!1,this.toolsTypes=void 0,this.shapeOpt=void 0,this.thickness=void 0,this.strokeType=void 0,this.useStroke=!1;const t=new Set;let o,s=!0;for(const n of e.values()){const{opt:a,canRotate:c,scaleType:l,toolsType:u}=n;this.selectorColor=this.workOptions.strokeColor,a.strokeColor&&(this.strokeColor=a.strokeColor),a.fillColor&&(this.fillColor=a.fillColor),a.textOpt&&(this.textOpt=a.textOpt),a.thickness&&(this.thickness=a.thickness),u!==v.Pencil&&(s=!1),a.strokeType&&(this.strokeType=a.strokeType),u===v.SpeechBalloon&&(t.add(u),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.placement=a.placement),u===v.Polygon&&(t.add(u),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices),u===v.Star&&(t.add(u),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices,this.shapeOpt.innerRatio=a.innerRatio,this.shapeOpt.innerVerticeStep=a.innerVerticeStep),u===v.Text&&(this.textOpt=a),e.size===1&&(this.textOpt&&(this.canTextEdit=!0),this.canRotate=c,this.scaleType=l),u===v.Image&&(o=n),(l===ce.proportional&&this.scaleType!==ce.none||l===ce.none)&&(this.scaleType=l)}s&&(this.useStroke=!0),t.size&&(this.toolsTypes=[...t]),o&&(e.size===1?(this.canLock=!0,o.opt.locked&&(this.isLocked=!0,this.scaleType=ce.none,this.canRotate=!1,this.textOpt=void 0,this.fillColor=void 0,this.selectorColor="rgb(177,177,177)",this.strokeColor=void 0,this.canTextEdit=!1,this.thickness=void 0,this.strokeType=void 0,this.useStroke=void 0)):e.size>1&&!o.opt.locked&&(this.canLock=!1,this.canRotate=!1))}getChildrenPoints(){var e,t;if(this.scaleType===ce.both&&((e=this.selectIds)==null?void 0:e.length)===1){const o=this.selectIds[0],s=(t=this.vNodes.get(o))==null?void 0:t.op;if(s){const n=[];for(let a=0;a<s.length;a+=3)n.push([s[a],s[a+1]]);return n}}}consume(e){if(e.isSubWorker)return this.subWorkerConsume(e);const{op:t,workState:o}=e.data;let s=this.oldSelectRect;if(o===A.Start&&(s=this.unSelectedAllIds()),!(t!=null&&t.length)||!this.vNodes.curNodeMap.size)return{type:b.None};this.updateTempPoints(t);const n=this.computSelector();if(this.selectIds&<(this.selectIds,n.selectIds))return{type:b.None};this.selectIds=n.selectIds;const a=n.intersectRect;this.getSelecteorInfo(n.subNodeMap),this.draw(G,this.fullLayer,n),this.oldSelectRect=a;const c=this.getChildrenPoints();return{type:b.Select,dataType:V.Local,rect:he(a,s),selectIds:n.selectIds,selectRect:a,selectorColor:this.selectorColor,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:c,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType,...this.baseConsumeResult}}consumeAll(){var t,o;let e=this.oldSelectRect;if(!((t=this.selectIds)!=null&&t.length)&&this.tmpPoints[0]&&this.selectSingleTool(this.tmpPoints[0].XY,G,!1),(o=this.selectIds)!=null&&o.length&&(e=this.selectedByIds(this.selectIds)),e){const s=this.getChildrenPoints();return{type:b.Select,dataType:V.Local,rect:this.oldSelectRect,selectIds:this.selectIds,selectorColor:this.selectorColor,selectRect:this.oldSelectRect,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:s,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType,...this.baseConsumeResult}}return{type:b.None}}consumeService(){}updateTempPointsForSubWorker(e){const t=e.slice(-2),o=new Q(t[0],t[1]);if(this.tmpPoints[0].isNear(o,1))return!1;if(this.tmpPoints.length===2){if(o.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=o}else this.tmpPoints.push(o);return!0}computDrawPoints(e){const{thickness:t}=this.workOptions,o=[];for(const a of e)o.push(new k(...a));const s=me(o,t),n=[s.x+s.w/2,s.y+s.h/2];return{rect:s,pos:n,points:o.map(a=>a.XY).flat(1)}}drawForSubWorker(e){const{workId:t,layer:o,ps:s}=e,{strokeColor:n,scale:a,rotate:c,translate:l}=this.workOptions,u=o.worldPosition,h=o.worldScaling,{points:d,rect:f,pos:g}=this.computDrawPoints(s),p=1/o.worldScaling[0],y=n&&Gt(n)||[0,0,0,0],I={close:!0,normalize:!0,points:d,lineWidth:p,fillColor:wt(y[0],y[1],y[2],.1),strokeColor:wt(y[0],y[1],y[2],1),lineJoin:"round",lineCap:"round"};let w={x:Math.floor(f.x*h[0]+u[0]-U.SafeBorderPadding),y:Math.floor(f.y*h[1]+u[1]-U.SafeBorderPadding),w:Math.floor(f.w*h[0]+2*U.SafeBorderPadding),h:Math.floor(f.h*h[0]+2*U.SafeBorderPadding)};const S=new ue.Group({name:t,id:t,pos:g,anchor:[.5,.5],size:[f.w,f.h],scale:a,rotate:c,translate:l}),C=new ue.Polyline({...I,pos:[0,0]});if(S.appendChild(C),this.replace(o,t,S),a||c||l){const T=S.getBoundingClientRect();w={x:Math.floor(T.x-U.SafeBorderPadding),y:Math.floor(T.y-U.SafeBorderPadding),w:Math.floor(T.width+2*U.SafeBorderPadding),h:Math.floor(T.height+2*U.SafeBorderPadding)}}return w}transformData(){const e=me(this.tmpPoints);return[[e.x,e.y,0],[e.x+e.w,e.y,0],[e.x+e.w,e.y+e.h,0],[e.x,e.y+e.h,0]]}subWorkerConsume(e){const{data:t,isFullWork:o}=e,{op:s,syncUnitTime:n}=t;n&&(this.syncUnitTime=n);const a=s==null?void 0:s.length;if(!a||a<2)return{type:b.None};let c;if(this.tmpPoints.length===0?(this.tmpPoints=[new Q(s[0],s[1])],c=!1):c=this.updateTempPointsForSubWorker(s),!c)return{type:b.None};const l=this.transformData(),u=o?this.fullLayer:this.drawLayer||this.fullLayer,h=this.drawForSubWorker({ps:l,workId:this.workId,layer:u}),d=he(h,this.oldSelectRect);return this.oldSelectRect=h,{rect:d,type:b.DrawWork,dataType:V.Local,...this.baseConsumeResult}}subWorkerConsumeAll(e){const{isFullWork:t}=e,o=t?this.fullLayer:this.drawLayer||this.fullLayer;return this.replace(o,this.workId),{rect:this.oldSelectRect,type:b.FullWork,dataType:V.Local,...this.baseConsumeResult}}clearTmpPoints(){this.tmpPoints.length=0}clearSelectData(){this.selectIds=void 0,this.oldSelectRect=void 0}selectSingleTool(e,t=G,o=!1){if(e.length===2){const s=e[0],n=e[1];let a;const{nodeRange:c}=this.vNodes.getRectIntersectRange({x:s,y:n,w:0,h:0},!1),l=[...c.values()].sort((u,h)=>(h.opt.zIndex||0)-(u.opt.zIndex||0));for(const u of l){const h=this.fullLayer.getElementsByName(u.name);if(un(h).find(f=>f.isPointCollision(s,n))){a=u;break}}if(a){const u=a.name;if(!lt(this.oldSelectRect,a.rect)){const h=new Map([[u,a]]);this.getSelecteorInfo(h),this.draw(t,this.fullLayer,{intersectRect:a.rect,subNodeMap:h,selectIds:this.selectIds||[]},o)}this.selectIds=[u],this.oldSelectRect=a.rect}}}unSelectedAllIds(){let e;for(const[t,o]of this.vNodes.curNodeMap.entries())o.isSelected&&(e=he(e,o.rect),this.vNodes.unSelected(t));return e}unSelectedByIds(e){let t;for(const o of e){const s=this.vNodes.get(o);s&&s.isSelected&&(t=he(t,s.rect),this.vNodes.unSelected(o))}return t}selectedByIds(e){let t;for(const o of e){const s=this.vNodes.get(o);s&&(t=he(t,s.rect),this.vNodes.selected(o))}return t}getSelectorRect(e,t){var a;let o;const s=(a=e.parent)==null?void 0:a.getElementById(t),n=s==null?void 0:s.getBoundingClientRect();return n&&(o=he(o,{x:Math.floor(n.x),y:Math.floor(n.y),w:Math.floor(n.width+1),h:Math.floor(n.height+1)})),o}isCanFillColor(e){return e===v.Ellipse||e===v.Triangle||e===v.Rectangle||e===v.Polygon||e===v.Star||e===v.SpeechBalloon}async updateSelector(e){const{updateSelectorOpt:t,selectIds:o,vNodes:s,willSerializeData:n,worker:a,offset:c}=e,l=this.fullLayer;if(!l)return;let u;const h=new Map,{originPoint:d,workState:f,angle:g,translate:p,dir:y,scale:I}=t;c&&(p?t.translate=[p[0]+c[0],p[1]+c[1]]:t.translate=c);let w;if(d||p||We(g)){if(f===A.Start&&o)return s.setTargetAssignKeys(o),{type:b.Select,dataType:V.Local,selectRect:this.oldSelectRect,rect:this.oldSelectRect};if(w=s.getLastTarget(),!w)return}if(o)for(const T of o){const N=s.get(T);if(N){const{toolsType:x,opt:D}=N,L=(l==null?void 0:l.getElementsByName(T))[0];if(L){const z={...t};let j;const E=U.isWillRefresh({toolsType:x,opt:D,updateOpt:z,vNodes:s,node:L,willSerializeData:n});if(x){j=w==null?void 0:w.get(T);const R=hn(x);if(R==null||R.updateNodeOpt({node:L,opt:z,vNodes:s,willSerializeData:n,targetNode:j}),N&&a&&E){const P=a.createWorkShapeNode({workId:T,toolsType:x,toolsOpt:N.opt});P==null||P.setWorkId(T);let Z;if(x===v.Image)Z=await P.consumeServiceAsync({isFullWork:!0,replaceId:T,worker:a});else if(x===v.Text)Z=await P.consumeServiceAsync({isFullWork:!0,replaceId:T});else try{Z=P==null?void 0:P.consumeService({op:N.op,isFullWork:!0,replaceId:T,workState:f})}catch(_){console.error("consumeService error",_);continue}Z&&(N.rect=Z)}N&&(h.set(T,N),u=he(u,N.rect))}}}}w&&f===A.Done&&(s.deleteLastTarget(),w=void 0);const S=u;if(d&&p&&I&&y&&S&&!c){const T=[[S.x,S.y],[S.x+S.w,S.y],[S.x+S.w,S.y+S.h],[S.x,S.y+S.h]];let N;switch(y){case"top":case"topLeft":case"left":p[0]>0&&p[1]>0?N=T[0]:p[0]>0?N=T[3]:p[1]>0?N=T[1]:N=T[2];break;case"topRight":p[0]<0&&p[1]>0?N=T[1]:p[0]<0?N=T[2]:p[1]>0?N=T[0]:N=T[3];break;case"right":case"bottomRight":case"bottom":p[0]<0&&p[1]<0?N=T[2]:p[0]<0?N=T[1]:p[1]<0?N=T[3]:N=T[0];break;case"bottomLeft":p[0]>0&&p[1]<0?N=T[3]:p[0]>0?N=T[0]:p[1]<0?N=T[2]:N=T[1];break}const x=N&&[d[0]-N[0],d[1]-N[1]]||[0,0];if(!lt(x,[0,0]))return await this.updateSelector({...e,updateSelectorOpt:{workState:f},offset:x})}this.getSelecteorInfo(h),this.draw(G,l,{selectIds:o||[],subNodeMap:h,intersectRect:S});const C=he(this.oldSelectRect,S);return this.oldSelectRect=S,{type:b.Select,dataType:V.Local,selectRect:S,renderRect:u,rect:he(C,S),selectIds:o}}blurSelector(){const e=this.unSelectedAllIds();return{type:b.Select,dataType:V.Local,rect:e,selectIds:[],willSyncService:!0}}getRightServiceId(e){return e.replace(Ze,"-")}selectServiceNode(e,t,o){const{selectIds:s}=t,n=this.getRightServiceId(e),a=this.getSelectorRect(this.fullLayer,n);let c;const l=new Map;return s==null||s.forEach(u=>{const h=this.vNodes.get(u);h&&(c=he(c,h.rect),l.set(u,h))}),this.getSelecteorInfo(l),this.draw(n,this.fullLayer,{intersectRect:c,selectIds:s||[],subNodeMap:l},o),he(c,a)}reRenderSelector(){var o;let e;const t=new Map;return(o=this.selectIds)==null||o.forEach(s=>{const n=this.vNodes.get(s);n&&(e=he(e,n.rect),t.set(s,n))},this),this.getSelecteorInfo(t),this.draw(G,this.fullLayer,{intersectRect:e,subNodeMap:t,selectIds:this.selectIds||[]}),this.oldSelectRect=e,e}updateSelectIds(e){var n;let t;const o=(n=this.selectIds)==null?void 0:n.filter(a=>!e.includes(a));if(o!=null&&o.length&&(t=this.unSelectedByIds(o)),e.length){const a=this.selectedByIds(e);t=he(t,a)}this.selectIds=e;const s=this.reRenderSelector();return{bgRect:t,selectRect:s}}cursorHover(e){var n,a;const t=this.oldSelectRect;this.selectIds=[];const o=(n=this.workId)==null?void 0:n.toString(),s=[e[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],e[1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]];if(this.selectSingleTool(s,o,!0),this.oldSelectRect&&!lt(t,this.oldSelectRect))return{type:b.CursorHover,dataType:V.Local,rect:he(t,this.oldSelectRect),selectorColor:this.selectorColor,willSyncService:!1};if((a=this.selectIds)!=null&&a.length||(this.oldSelectRect=void 0),t&&!this.oldSelectRect)return this.cursorBlur(),{type:b.CursorHover,dataType:V.Local,rect:t,selectorColor:this.selectorColor,willSyncService:!1}}cursorBlur(){var t,o;this.selectIds=[];const e=(t=this.workId)==null?void 0:t.toString();((o=this.fullLayer)==null?void 0:o.parent).children.forEach(s=>{s.name===e&&s.remove()})}};M(wi,"selectorBorderId","selector-border");let pi=wi;class on extends U{constructor(e){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.both);M(this,"toolsType",v.Arrow);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"arrowTipWidth");M(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.arrowTipWidth=this.workOptions.thickness*4,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:o,isSubWorker:s,isMainThread:n,smoothSync:a}=e,c=this.workId,{op:l,syncUnitTime:u}=t;u&&(this.syncUnitTime=u);const h=l==null?void 0:l.length;if(!h||h<2)return{type:b.None};let d;if(this.tmpPoints.length===0?(this.tmpPoints=[new Q(l[0],l[1])],d=!1):d=this.updateTempPoints(l),!d)return{type:b.None};let f;if(s||n){const p=o?this.fullLayer:this.drawLayer||this.fullLayer;f=this.draw({workId:c,layer:p})}if(!s&&a){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{...this.baseConsumeResult,type:b.DrawWork,dataType:V.Local,op:this.tmpPoints.map(y=>[...y.XY,0]).flat(1),isSync:!0,index:0}):{type:b.None}}const g=he(f,this.oldRect);return this.oldRect=f,{rect:g,...this.baseConsumeResult,type:b.DrawWork,dataType:V.Local}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:b.RemoveNode,removeIds:[e]};const t=this.fullLayer,o=this.draw({workId:e,layer:t});this.oldRect=o;const s=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Ye(s);return(a=this.vNodes)==null||a.setInfo(e,{rect:o,op:s,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:U.getCenterPos(o,t)}),{rect:o,...this.baseConsumeResult,type:b.FullWork,dataType:V.Local,ops:n,isSync:!0,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:t,layer:o,isDrawEraserlines:s}=e,{strokeColor:n,thickness:a,zIndex:c,scale:l,rotate:u,translate:h,strokeType:d,eraserlines:f}=this.workOptions,g=o.worldPosition,p=o.worldScaling,{points:y,pos:I,rect:w,isTriangle:S,trianglePoints:C,trianglePos:T}=this.computDrawPoints(a),N=[w.x+w.w/2,w.y+w.h/2],x={pos:N,name:t,id:t,zIndex:c,anchor:[.5,.5],size:[w.w,w.h]};l&&(x.scale=l),u&&(x.rotate=u),h&&(x.translate=h);const D=new ue.Group(x),L={points:C,pos:[T[0]-N[0],T[1]-N[1]],fillColor:n,strokeColor:n,lineWidth:0,normalize:!1},z=new ue.Polyline(L);if(D.append(z),!S&&y&&I){const E={points:y,pos:[I[0]-N[0],I[1]-N[1]],fillColor:n,strokeColor:n,lineDash:d===se.Dotted&&!S?[1,a*2]:d===se.LongDotted&&!S?[a,a*2]:void 0,lineCap:d===se.Normal?void 0:"round",lineWidth:a,normalize:!1},R=new ue.Polyline(E);D.append(R)}f&&(this.scaleType=ce.proportional,this.drawEraserlines({group:D,eraserlines:f,pos:N,layer:o},s)),this.replace(o,t,D);let j={x:Math.floor(w.x*p[0]+g[0]-U.SafeBorderPadding),y:Math.floor(w.y*p[1]+g[1]-U.SafeBorderPadding),w:Math.floor(w.w*p[0]+2*U.SafeBorderPadding),h:Math.floor(w.h*p[1]+2*U.SafeBorderPadding)};if(l||u||h){const E=D.getBoundingClientRect();j={x:Math.floor(E.x-U.SafeBorderPadding),y:Math.floor(E.y-U.SafeBorderPadding),w:Math.floor(E.width+U.SafeBorderPadding*2),h:Math.floor(E.height+U.SafeBorderPadding*2)}}return this.isDelete&&D.setAttribute("opacity",0),j}computDrawPoints(e){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.arrowTipWidth?this.computFullArrowPoints(e):this.computTrianglePoints()}computFullArrowPoints(e){const t=k.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),o=k.Per(t).mul(e/2),s=Q.Sub(this.tmpPoints[0],o),n=Q.Add(this.tmpPoints[0],o),a=k.Mul(t,this.arrowTipWidth),c=k.Sub(this.tmpPoints[1],a),l=Q.Sub(c,o),u=Q.Add(c,o),h=k.Per(t).mul(e*1.5),d=Q.Sub(c,h),f=Q.Add(c,h),g=[this.tmpPoints[0],c],p=[d,this.tmpPoints[1],f],y=[s,n,...p,l,u];return{trianglePoints:p.map(I=>Q.Sub(I,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,points:g.map(I=>Q.Sub(I,this.tmpPoints[0]).XY).flat(1),rect:me(y),isTriangle:!1,pos:this.tmpPoints[0].XY}}computTrianglePoints(){const e=k.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),t=this.tmpPoints[1].distance(this.tmpPoints[0]),o=k.Per(e).mul(Math.floor(t*3/8)),s=Q.Sub(this.tmpPoints[0],o),n=Q.Add(this.tmpPoints[0],o),a=[s,this.tmpPoints[1],n];return{trianglePoints:a.map(c=>Q.Sub(c,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,rect:me(a),isTriangle:!0}}updateTempPoints(e){const t=e.slice(-2),o=new Q(t[0],t[1]),s=this.tmpPoints[0],{thickness:n}=this.workOptions;if(s.isNear(o,n))return!1;if(this.tmpPoints.length===2){if(o.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=o}else this.tmpPoints.push(o);return!0}consumeService(e){var l,u;const{op:t,isFullWork:o,workState:s=A.Done}=e,n=(l=this.workId)==null?void 0:l.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new Q(t[h],t[h+1],t[h+2]));const a=o?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:n,layer:a,isDrawEraserlines:s===A.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(n,{rect:c,op:t,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:U.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var l,u;const{node:t,opt:o,vNodes:s}=e,{strokeColor:n,strokeType:a}=o,c=s.get(t.name);return n&&(t.tagName==="GROUP"?t.children.forEach(h=>{h.setAttribute("strokeColor",n),h.getAttribute("fillColor")&&h.setAttribute("fillColor",n)}):(t.setAttribute("strokeColor",n),t.setAttribute("fillColor",n)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=n)),a&&(c!=null&&c.opt)&&((u=c.opt)!=null&&u.strokeType)&&(c.opt.strokeType=a),c&&s.setInfo(t.name,c),U.updateNodeOpt(e)}}class sn extends U{constructor(e){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.all);M(this,"toolsType",v.Ellipse);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:o,isSubWorker:s,isMainThread:n,smoothSync:a}=e,c=this.workId,{op:l,syncUnitTime:u}=t;u&&(this.syncUnitTime=u);const h=l==null?void 0:l.length;if(!h||h<2)return{type:b.None};let d;if(this.tmpPoints.length===0?(this.tmpPoints=[new Q(l[0],l[1])],d=!1):d=this.updateTempPoints(l),!d)return{type:b.None};if(!s&&a){const g=Date.now();return g-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=g,{type:b.DrawWork,dataType:V.Local,...this.baseConsumeResult,op:this.tmpPoints.map(p=>[...p.XY,0]).flat(1),isSync:!0,index:0}):{type:b.None}}let f;if(s||n){const g=o?this.fullLayer:this.drawLayer||this.fullLayer;f=this.draw({workId:c,layer:g,isDrawing:!0});const p=g.parent.parent,y={x:0,y:0,w:Math.floor(p.width),h:Math.floor(p.height)};if(Io(f,y)!==Nt.outside){const w=he(f,this.oldRect);return this.oldRect=f,{rect:w,type:b.DrawWork,dataType:V.Local,...this.baseConsumeResult}}return{type:b.None}}return{type:b.None}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:b.RemoveNode,removeIds:[e]};const t=this.fullLayer,o=this.draw({workId:e,layer:t,isDrawing:!1});this.oldRect=o;const s=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Ye(s);return(a=this.vNodes)==null||a.setInfo(e,{rect:o,op:s,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:o&&U.getCenterPos(o,t)}),{rect:o,type:b.FullWork,dataType:V.Local,...this.baseConsumeResult,ops:n,isSync:!0,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:t,layer:o,isDrawing:s,isDrawEraserlines:n}=e,{strokeColor:a,fillColor:c,thickness:l,zIndex:u,scale:h,rotate:d,translate:f,strokeType:g,eraserlines:p}=this.workOptions,y=o.worldScaling,{radius:I,rect:w,pos:S}=this.computDrawPoints(l),C={closeType:"normal",radius:I,lineWidth:l,fillColor:c!=="transparent"&&c||void 0,strokeColor:a,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:g===se.Dotted?[1,l*2]:g===se.LongDotted?[l,l*2]:void 0},T={name:t,id:t,zIndex:u,pos:S,anchor:[.5,.5],size:[w.w,w.h]};h&&(T.scale=h),d&&(T.rotate=d),f&&(T.translate=f);const N=new ue.Group(T);if(s){const L=new ue.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/y[0],1/y[1]]});N.append(L)}const x=new ue.Ellipse({...C,pos:[0,0]});N.append(x),p&&(this.scaleType=ce.proportional,this.drawEraserlines({group:N,eraserlines:p,pos:S,layer:o},n)),this.replace(o,t,N);const D=N.getBoundingClientRect();return this.isDelete&&N.setAttribute("opacity",0),{x:Math.floor(D.x-U.SafeBorderPadding),y:Math.floor(D.y-U.SafeBorderPadding),w:Math.floor(D.width+U.SafeBorderPadding*2),h:Math.floor(D.height+U.SafeBorderPadding*2)}}computDrawPoints(e){const t=me(this.tmpPoints),o=me(this.tmpPoints,e),s=[Math.floor(t.x+t.w/2),Math.floor(t.y+t.h/2)];return{rect:o,pos:s,radius:[Math.floor(t.w/2),Math.floor(t.h/2)]}}updateTempPoints(e){const t=e.slice(-2),o=new Q(t[0],t[1]),s=this.tmpPoints[0],{thickness:n}=this.workOptions;if(s.isNear(o,n))return!1;if(this.tmpPoints.length===2){if(o.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=o}else this.tmpPoints.push(o);return!0}consumeService(e){var l,u;const{op:t,isFullWork:o,workState:s=A.Done}=e,n=(l=this.workId)==null?void 0:l.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new Q(t[h],t[h+1],t[h+2]));const a=o?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:n,layer:a,isDrawing:!1,isDrawEraserlines:s===A.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(n,{rect:c,op:t,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:U.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var h,d,f;const{node:t,opt:o,vNodes:s}=e,{strokeColor:n,fillColor:a,strokeType:c}=o,l=s.get(t.name);let u=t;return t.tagName==="GROUP"&&(u=t.children[0]),n&&(u.setAttribute("strokeColor",n),(h=l==null?void 0:l.opt)!=null&&h.strokeColor&&(l.opt.strokeColor=n)),a&&(a==="transparent"?u.setAttribute("fillColor","rgba(0,0,0,0)"):u.setAttribute("fillColor",a),(d=l==null?void 0:l.opt)!=null&&d.fillColor&&(l.opt.fillColor=a)),c&&(l!=null&&l.opt)&&((f=l.opt)!=null&&f.strokeType)&&(l.opt.strokeType=c),l&&s.setInfo(t.name,l),U.updateNodeOpt(e)}}class nn extends U{constructor(e){super(e);M(this,"canRotate",!0);M(this,"scaleType",ce.all);M(this,"toolsType",v.Rectangle);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}transformData(){const e=me(this.tmpPoints);return[[e.x,e.y,0],[e.x+e.w,e.y,0],[e.x+e.w,e.y+e.h,0],[e.x,e.y+e.h,0]]}computDrawPoints(e){const{thickness:t}=this.workOptions,o=[];for(const a of e)o.push(new k(...a));const s=me(o,t),n=[s.x+s.w/2,s.y+s.h/2];return{rect:s,pos:n,points:o.map(a=>a.XY).flat(1)}}consume(e){const{data:t,isFullWork:o,isSubWorker:s,isMainThread:n,smoothSync:a}=e,c=this.workId,{op:l}=t,u=l==null?void 0:l.length;if(!u||u<2)return{type:b.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new Q(l[0],l[1])],h=!1):h=this.updateTempPoints(l),!h)return{type:b.None};const d=this.transformData();let f;if(s||n){const p=o?this.fullLayer:this.drawLayer||this.fullLayer;f=this.draw({ps:d,workId:c,layer:p,isDrawing:!0})}if(!s&&a){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:b.DrawWork,dataType:V.Local,op:d.flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:b.None}}const g=he(f,this.oldRect);return this.oldRect=f,{rect:g,type:b.DrawWork,dataType:V.Local,...this.baseConsumeResult}}consumeAll(){var c;const e=this.workId;if(this.tmpPoints.length<2)return{type:b.RemoveNode,removeIds:[e]};const t=this.transformData(),o=this.fullLayer,s=this.draw({ps:t,workId:e,layer:o,isDrawing:!1});this.oldRect=s;const n=t.flat(1),a=Ye(n);return(c=this.vNodes)==null||c.setInfo(e,{rect:s,op:n,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&U.getCenterPos(s,o)}),{rect:s,type:b.FullWork,dataType:V.Local,ops:a,isSync:!0,...this.baseConsumeResult,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:t,layer:o,isDrawing:s,ps:n,replaceId:a,isDrawEraserlines:c=!0}=e,{strokeColor:l,fillColor:u,thickness:h,zIndex:d,scale:f,rotate:g,translate:p,strokeType:y,eraserlines:I}=this.workOptions,w=o.worldPosition,S=o.worldScaling,{points:C,rect:T,pos:N}=this.computDrawPoints(n),x={close:!0,normalize:!0,points:C,lineWidth:h,fillColor:u!=="transparent"&&u||void 0,strokeColor:l,lineJoin:"round",lineCap:"round",lineDash:y===se.Dotted?[1,h*2]:y===se.LongDotted?[h,h*2]:void 0};let D={x:Math.floor(T.x*S[0]+w[0]-U.SafeBorderPadding),y:Math.floor(T.y*S[1]+w[1]-U.SafeBorderPadding),w:Math.floor(T.w*S[0]+2*U.SafeBorderPadding),h:Math.floor(T.h*S[0]+2*U.SafeBorderPadding)};const L=new ue.Group({name:t,id:t,zIndex:d,pos:N,anchor:[.5,.5],size:[T.w,T.h],scale:f,rotate:g,translate:p}),z=new ue.Polyline({...x,pos:[0,0]});if(L.appendChild(z),s){const j=new ue.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:l,lineWidth:1,scale:[1/S[0],1/S[1]]});L.appendChild(j)}if(I&&(this.scaleType=ce.proportional,this.drawEraserlines({group:L,eraserlines:I,pos:N,layer:o},c)),this.replace(o,a||t,L),f||g||p){const j=L.getBoundingClientRect();D={x:Math.floor(j.x-U.SafeBorderPadding),y:Math.floor(j.y-U.SafeBorderPadding),w:Math.floor(j.width+2*U.SafeBorderPadding),h:Math.floor(j.height+2*U.SafeBorderPadding)}}return this.isDelete&&L.setAttribute("opacity",0),D}updateTempPoints(e){const t=e.slice(-2),o=new Q(t[0],t[1]),s=this.tmpPoints[0],{thickness:n}=this.workOptions;if(s.isNear(o,n))return!1;if(this.tmpPoints.length===2){if(o.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=o}else this.tmpPoints.push(o);return!0}consumeService(e){var h,d;const{op:t,isFullWork:o,replaceId:s,workState:n=A.Done}=e,a=(h=this.workId)==null?void 0:h.toString();if(!a)return;const c=[];for(let f=0;f<t.length;f+=3)c.push([t[f],t[f+1],t[f+2]]);const l=o?this.fullLayer:this.drawLayer||this.fullLayer,u=this.draw({ps:c,workId:a,layer:l,isDrawing:!1,replaceId:s,isDrawEraserlines:n===A.Done});return this.oldRect=u,(d=this.vNodes)==null||d.setInfo(a,{rect:u,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:u&&U.getCenterPos(u,l)}),u}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var h,d,f;const{node:t,opt:o,vNodes:s}=e,{strokeColor:n,fillColor:a,strokeType:c}=o,l=s.get(t.name);let u=t;return t.tagName==="GROUP"&&(u=t.children[0]),n&&(u.setAttribute("strokeColor",n),(h=l==null?void 0:l.opt)!=null&&h.strokeColor&&(l.opt.strokeColor=n)),a&&(a==="transparent"?u.setAttribute("fillColor","rgba(0,0,0,0)"):u.setAttribute("fillColor",a),(d=l==null?void 0:l.opt)!=null&&d.fillColor&&(l.opt.fillColor=a)),c&&(l!=null&&l.opt)&&((f=l.opt)!=null&&f.strokeType)&&(l.opt.strokeType=c),l&&s.setInfo(t.name,l),U.updateNodeOpt(e)}}class rn extends U{constructor(e){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.all);M(this,"toolsType",v.Star);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:o,isSubWorker:s,isMainThread:n,smoothSync:a}=e,c=this.workId,{op:l,syncUnitTime:u}=t,h=l==null?void 0:l.length;if(!h||h<2)return{type:b.None};u&&(this.syncUnitTime=u);let d;if(this.tmpPoints.length===0?(this.tmpPoints=[new Q(l[0],l[1])],d=!1):d=this.updateTempPoints(l),!d)return{type:b.None};let f;if(s||n){const p=o?this.fullLayer:this.drawLayer||this.fullLayer;f=this.draw({workId:c,layer:p,isDrawing:!0})}if(!s&&a){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:b.DrawWork,dataType:V.Local,op:this.tmpPoints.map(y=>[...y.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:b.None}}const g=he(f,this.oldRect);return this.oldRect=f,{rect:g,type:b.DrawWork,dataType:V.Local,...this.baseConsumeResult}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:b.RemoveNode,removeIds:[e]};const t=this.fullLayer,o=this.draw({workId:e,layer:t,isDrawing:!1});this.oldRect=o;const s=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Ye(s);return(a=this.vNodes)==null||a.setInfo(e,{rect:o,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&U.getCenterPos(o,t)}),{rect:o,type:b.FullWork,dataType:V.Local,ops:n,isSync:!0,...this.baseConsumeResult,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:t,layer:o,isDrawing:s,isDrawEraserlines:n=!0}=e,{strokeColor:a,fillColor:c,thickness:l,zIndex:u,vertices:h,innerVerticeStep:d,innerRatio:f,scale:g,rotate:p,translate:y,strokeType:I,eraserlines:w}=this.workOptions,S=o.worldScaling,{rect:C,pos:T,points:N}=this.computDrawPoints(l,h,d,f),x={close:!0,points:N,lineWidth:l,fillColor:c!=="transparent"&&c||void 0,strokeColor:a,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:I===se.Dotted?[1,l*2]:I===se.LongDotted?[l,l*2]:void 0},D={name:t,id:t,zIndex:u,pos:T,anchor:[.5,.5],size:[C.w,C.h]};g&&(D.scale=g),p&&(D.rotate=p),y&&(D.translate=y);const L=new ue.Group(D);if(s){const E=new ue.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/S[0],1/S[1]]});L.append(E)}const z=new ue.Polyline({...x,pos:[0,0]});L.append(z),w&&(this.scaleType=ce.proportional,this.drawEraserlines({group:L,eraserlines:w,pos:T,layer:o},n)),this.replace(o,t,L);const j=L.getBoundingClientRect();return this.isDelete&&L.setAttribute("opacity",0),{x:Math.floor(j.x-U.SafeBorderPadding),y:Math.floor(j.y-U.SafeBorderPadding),w:Math.floor(j.width+U.SafeBorderPadding*2),h:Math.floor(j.height+U.SafeBorderPadding*2)}}computDrawPoints(e,t,o,s){const n=me(this.tmpPoints),a=[Math.floor(n.x+n.w/2),Math.floor(n.y+n.h/2)],c=In(n.w,n.h),l=Math.floor(Math.min(n.w,n.h)/2),u=s*l,h=[],d=2*Math.PI/t;for(let g=0;g<t;g++){const p=g*d-.5*Math.PI;let y,I;g%o===1?(y=u*c[0]*Math.cos(p),I=u*c[1]*Math.sin(p)):(y=l*c[0]*Math.cos(p),I=l*c[1]*Math.sin(p),h.push(y,I)),h.push(y,I)}return{rect:me(this.tmpPoints,e),pos:a,points:h}}updateTempPoints(e){const t=e.slice(-2),o=new Q(t[0],t[1]),s=this.tmpPoints[0],{thickness:n}=this.workOptions;if(s.isNear(o,n)||Q.Sub(s,o).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(o.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=o}else this.tmpPoints.push(o);return!0}consumeService(e){var l,u;const{op:t,isFullWork:o,workState:s=A.Done}=e,n=(l=this.workId)==null?void 0:l.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new Q(t[h],t[h+1],t[h+2]));const a=o?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:n,layer:a,isDrawing:!1,isDrawEraserlines:s===A.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(n,{rect:c,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&U.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var y;const{node:t,opt:o,vNodes:s}=e,{strokeColor:n,fillColor:a,toolsType:c,vertices:l,innerVerticeStep:u,innerRatio:h,strokeType:d}=o,f=s.get(t.name),g=f==null?void 0:f.opt;let p=t;return t.tagName==="GROUP"&&(p=t.children[0]),n&&(p.setAttribute("strokeColor",n),g!=null&&g.strokeColor&&(g.strokeColor=n)),a&&(a==="transparent"?p.setAttribute("fillColor","rgba(0,0,0,0)"):p.setAttribute("fillColor",a),g!=null&&g.fillColor&&(g.fillColor=a)),c===v.Star&&(l&&(g.vertices=l),u&&(g.innerVerticeStep=u),h&&(g.innerRatio=h)),d&&(f!=null&&f.opt)&&((y=f.opt)!=null&&y.strokeType)&&(f.opt.strokeType=d),f&&s.setInfo(t.name,{...f,opt:g}),U.updateNodeOpt(e)}}class an extends U{constructor(e){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.all);M(this,"toolsType",v.Polygon);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:o,isSubWorker:s,isMainThread:n,smoothSync:a}=e,{op:c,syncUnitTime:l}=t;l&&(this.syncUnitTime=l);const u=this.workId,h=c==null?void 0:c.length;if(!h||h<2)return{type:b.None};let d;if(this.tmpPoints.length===0?(this.tmpPoints=[new Q(c[0],c[1])],d=!1):d=this.updateTempPoints(c),!d)return{type:b.None};let f;if(s||n){const p=o?this.fullLayer:this.drawLayer||this.fullLayer;f=this.draw({workId:u,layer:p,isDrawing:!0})}if(!s&&a){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:b.DrawWork,dataType:V.Local,op:this.tmpPoints.map(y=>[...y.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:b.None}}const g=he(f,this.oldRect);return this.oldRect=f,{rect:g,type:b.DrawWork,dataType:V.Local,...this.baseConsumeResult}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:b.RemoveNode,removeIds:[e]};const t=this.fullLayer,o=this.draw({workId:e,layer:t,isDrawing:!1});this.oldRect=o;const s=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Ye(s);return(a=this.vNodes)==null||a.setInfo(e,{rect:o,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&U.getCenterPos(o,t)}),{rect:o,type:b.FullWork,dataType:V.Local,ops:n,isSync:!0,...this.baseConsumeResult,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:t,layer:o,isDrawing:s,isDrawEraserlines:n=!0}=e,{strokeColor:a,fillColor:c,thickness:l,zIndex:u,vertices:h,scale:d,rotate:f,translate:g,strokeType:p,eraserlines:y}=this.workOptions,I=o.worldScaling,{rect:w,pos:S,points:C}=this.computDrawPoints(l,h),T={close:!0,points:C,lineWidth:l,fillColor:c!=="transparent"&&c||void 0,strokeColor:a,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:p===se.Dotted?[1,l*2]:p===se.LongDotted?[l,l*2]:void 0},N={name:t,id:t,zIndex:u,pos:S,anchor:[.5,.5],size:[w.w,w.h]};d&&(N.scale=d),f&&(N.rotate=f),g&&(N.translate=g);const x=new ue.Group(N);if(s){const z=new ue.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:a,lineWidth:1,scale:[1/I[0],1/I[1]]});x.append(z)}const D=new ue.Polyline({...T,pos:[0,0]});x.append(D),y&&(this.scaleType=ce.proportional,this.drawEraserlines({group:x,eraserlines:y,pos:S,layer:o},n)),this.replace(o,t,x);const L=x.getBoundingClientRect();return this.isDelete&&x.setAttribute("opacity",0),{x:Math.floor(L.x-U.SafeBorderPadding),y:Math.floor(L.y-U.SafeBorderPadding),w:Math.floor(L.width+U.SafeBorderPadding*2),h:Math.floor(L.height+U.SafeBorderPadding*2)}}computDrawPoints(e,t){const o=me(this.tmpPoints),s=[Math.floor(o.x+o.w/2),Math.floor(o.y+o.h/2)],n=In(o.w,o.h),a=Math.floor(Math.min(o.w,o.h)/2),c=[],l=2*Math.PI/t;for(let h=0;h<t;h++){const d=h*l-.5*Math.PI,f=a*n[0]*Math.cos(d),g=a*n[1]*Math.sin(d);c.push(f,g)}return{rect:me(this.tmpPoints,e),pos:s,points:c}}updateTempPoints(e){const t=e.slice(-2),o=new Q(t[0],t[1]),s=this.tmpPoints[0],{thickness:n}=this.workOptions;if(s.isNear(o,n)||Q.Sub(s,o).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(o.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=o}else this.tmpPoints.push(o);return!0}consumeService(e){var l,u;const{op:t,isFullWork:o,workState:s=A.Done}=e,n=(l=this.workId)==null?void 0:l.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new Q(t[h],t[h+1],t[h+2]));const a=o?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:n,layer:a,isDrawing:!1,isDrawEraserlines:s===A.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(n,{rect:c,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&U.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var g;const{node:t,opt:o,vNodes:s}=e,{strokeColor:n,fillColor:a,toolsType:c,vertices:l,strokeType:u}=o,h=s.get(t.name),d=h==null?void 0:h.opt;let f=t;return t.tagName==="GROUP"&&(f=t.children[0]),n&&(f.setAttribute("strokeColor",n),d!=null&&d.strokeColor&&(d.strokeColor=n)),a&&(a==="transparent"?f.setAttribute("fillColor","rgba(0,0,0,0)"):f.setAttribute("fillColor",a),d!=null&&d.fillColor&&(d.fillColor=a)),c===v.Polygon&&l&&(d.vertices=l),u&&(h!=null&&h.opt)&&((g=h.opt)!=null&&g.strokeType)&&(h.opt.strokeType=u),h&&s.setInfo(t.name,{...h,opt:d}),U.updateNodeOpt(e)}}class et{static bezier(i,e){const t=[];for(let o=0;o<e.length;o+=4){const s=e[o],n=e[o+1],a=e[o+2],c=e[o+3];s&&n&&a&&c?t.push(...et.getBezierPoints(i,s,n,a,c)):s&&n&&a?t.push(...et.getBezierPoints(i,s,n,a)):s&&n?t.push(...et.getBezierPoints(i,s,n)):s&&t.push(s)}return t}static getBezierPoints(i=10,e,t,o,s){let n=null;const a=[];!o&&!s?n=et.oneBezier:o&&!s?n=et.twoBezier:o&&s&&(n=et.threeBezier);for(let c=0;c<i;c++)n&&a.push(n(c/i,e,t,o,s));return s?a.push(s):o&&a.push(o),a}static oneBezier(i,e,t){const o=e.x+(t.x-e.x)*i,s=e.y+(t.y-e.y)*i;return new k(o,s)}static twoBezier(i,e,t,o){const s=(1-i)*(1-i)*e.x+2*i*(1-i)*t.x+i*i*o.x,n=(1-i)*(1-i)*e.y+2*i*(1-i)*t.y+i*i*o.y;return new k(s,n)}static threeBezier(i,e,t,o,s){const n=e.x*(1-i)*(1-i)*(1-i)+3*t.x*i*(1-i)*(1-i)+3*o.x*i*i*(1-i)+s.x*i*i*i,a=e.y*(1-i)*(1-i)*(1-i)+3*t.y*i*(1-i)*(1-i)+3*o.y*i*i*(1-i)+s.y*i*i*i;return new k(n,a)}}class cn extends U{constructor(e){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.all);M(this,"toolsType",v.SpeechBalloon);M(this,"ratio",.8);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){var g;const{data:t,isFullWork:o,isSubWorker:s,isMainThread:n,smoothSync:a}=e,c=(g=t==null?void 0:t.workId)==null?void 0:g.toString();if(!c)return{type:b.None};const{op:l}=t,u=l==null?void 0:l.length;if(!u||u<2)return{type:b.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new Q(l[0],l[1])],h=!1):h=this.updateTempPoints(l),!h)return{type:b.None};let d;if(s||n){const p=o?this.fullLayer:this.drawLayer||this.fullLayer;d=this.draw({workId:c,layer:p,isDrawing:!0})}if(!s&&a){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:b.DrawWork,dataType:V.Local,op:this.tmpPoints.map(y=>[...y.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:b.None}}const f=he(d,this.oldRect);return this.oldRect=d,{rect:f,type:b.DrawWork,dataType:V.Local,...this.baseConsumeResult}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:b.RemoveNode,removeIds:[e]};const t=this.fullLayer,o=this.draw({workId:e,layer:t,isDrawing:!1});this.oldRect=o;const s=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Ye(s);return(a=this.vNodes)==null||a.setInfo(e,{rect:o,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&U.getCenterPos(o,t)}),{rect:o,type:b.FullWork,dataType:V.Local,ops:n,isSync:!0,...this.baseConsumeResult,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:t,layer:o,isDrawEraserlines:s=!0}=e,{strokeColor:n,fillColor:a,thickness:c,zIndex:l,placement:u,scale:h,rotate:d,translate:f,strokeType:g,eraserlines:p}=this.workOptions,{rect:y,pos:I,points:w}=this.computDrawPoints(c,u),S={points:w.map(D=>D.XY),lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:n,normalize:!0,className:`${I[0]},${I[1]}`,close:!0,lineJoin:"round",lineCap:"round",lineDash:g===se.Dotted?[1,c*2]:g===se.LongDotted?[c,c*2]:void 0},C={name:t,id:t,zIndex:l,pos:I,anchor:[.5,.5],size:[y.w,y.h]};h&&(C.scale=h),d&&(C.rotate=d),f&&(C.translate=f);const T=new ue.Group(C),N=new ue.Polyline({...S,pos:[0,0]});T.append(N),p&&(this.scaleType=ce.proportional,this.drawEraserlines({group:T,eraserlines:p,pos:I,layer:o},s)),this.replace(o,t,T);const x=T.getBoundingClientRect();return this.isDelete&&T.setAttribute("opacity",0),{x:Math.floor(x.x-U.SafeBorderPadding),y:Math.floor(x.y-U.SafeBorderPadding),w:Math.floor(x.width+U.SafeBorderPadding*2),h:Math.floor(x.height+U.SafeBorderPadding*2)}}transformControlPoints(e){const t=me(this.tmpPoints);switch(e){case"bottom":case"bottomLeft":case"bottomRight":{const o=t.y+t.h*this.ratio;return[new k(t.x,t.y,0),new k(t.x+t.w,t.y,0),new k(t.x+t.w,o,0),new k(t.x,o,0)]}case"top":case"topLeft":case"topRight":{const o=t.y+t.h*(1-this.ratio);return[new k(t.x,o,0),new k(t.x+t.w,o,0),new k(t.x+t.w,t.y+t.h,0),new k(t.x,t.y+t.h,0)]}case"left":case"leftBottom":case"leftTop":{const o=t.x+t.w*(1-this.ratio);return[new k(o,t.y,0),new k(t.x+t.w,t.y,0),new k(t.x+t.w,t.y+t.h,0),new k(o,t.y+t.h,0)]}case"right":case"rightBottom":case"rightTop":{const o=t.x+t.w*this.ratio;return[new k(t.x,t.y,0),new k(o,t.y,0),new k(o,t.y+t.h,0),new k(t.x,t.y+t.h,0)]}}}computDrawPoints(e,t){const o=me(this.tmpPoints),s=this.transformControlPoints(t),n=Math.floor(o.w*.1),a=Math.floor(o.h*.1),c=[],l=k.Add(s[0],new k(0,a,0)),u=k.Add(s[0],new k(n,0,0)),h=et.getBezierPoints(10,l,s[0],u),d=k.Sub(s[1],new k(n,0,0)),f=k.Add(s[1],new k(0,a,0)),g=et.getBezierPoints(10,d,s[1],f),p=k.Sub(s[2],new k(0,a,0)),y=k.Sub(s[2],new k(n,0,0)),I=et.getBezierPoints(10,p,s[2],y),w=k.Add(s[3],new k(n,0,0)),S=k.Sub(s[3],new k(0,a,0)),C=et.getBezierPoints(10,w,s[3],S),T=n*(1-this.ratio)*10,N=a*(1-this.ratio)*10;switch(t){case"bottom":{const L=k.Sub(s[2],new k(n*5-T/2,0,0)),z=k.Sub(s[2],new k(n*5,-N,0)),j=k.Sub(s[2],new k(n*5+T/2,0,0));c.push(z,j,...C,...h,...g,...I,L);break}case"bottomRight":{const L=k.Sub(s[2],new k(n*1.1,0,0)),z=k.Sub(s[2],new k(n*1.1+T/2,-N,0)),j=k.Sub(s[2],new k(n*1.1+T,0,0));c.push(z,j,...C,...h,...g,...I,L);break}case"bottomLeft":{const L=k.Add(s[3],new k(n*1.1+T,0,0)),z=k.Add(s[3],new k(n*1.1+T/2,N,0)),j=k.Add(s[3],new k(n*1.1,0,0));c.push(z,j,...C,...h,...g,...I,L);break}case"top":{const L=k.Sub(s[1],new k(n*5-T/2,0,0)),z=k.Sub(s[1],new k(n*5,N,0)),j=k.Sub(s[1],new k(n*5+T/2,0,0));c.push(z,L,...g,...I,...C,...h,j);break}case"topRight":{const L=k.Sub(s[1],new k(n*1.1,0,0)),z=k.Sub(s[1],new k(n*1.1+T/2,N,0)),j=k.Sub(s[1],new k(n*1.1+T,0,0));c.push(z,L,...g,...I,...C,...h,j);break}case"topLeft":{const L=k.Add(s[0],new k(n*1.1+T,0,0)),z=k.Add(s[0],new k(n*1.1+T/2,-N,0)),j=k.Add(s[0],new k(n*1.1,0,0));c.push(z,L,...g,...I,...C,...h,j);break}case"left":{const L=k.Add(s[0],new k(0,a*5-N/2,0)),z=k.Add(s[0],new k(-T,a*5,0)),j=k.Add(s[0],new k(0,a*5+N/2,0));c.push(z,L,...h,...g,...I,...C,j);break}case"leftTop":{const L=k.Add(s[0],new k(0,a*1.1,0)),z=k.Add(s[0],new k(-T,a*1.1+N/2,0)),j=k.Add(s[0],new k(0,a*1.1+N,0));c.push(z,L,...h,...g,...I,...C,j);break}case"leftBottom":{const L=k.Sub(s[3],new k(0,a*1.1+N,0)),z=k.Sub(s[3],new k(T,a*1.1+N/2,0)),j=k.Sub(s[3],new k(0,a*1.1,0));c.push(z,L,...h,...g,...I,...C,j);break}case"right":{const L=k.Add(s[1],new k(0,a*5-N/2,0)),z=k.Add(s[1],new k(T,a*5,0)),j=k.Add(s[1],new k(0,a*5+N/2,0));c.push(z,j,...I,...C,...h,...g,L);break}case"rightTop":{const L=k.Add(s[1],new k(0,a*1.1,0)),z=k.Add(s[1],new k(T,a*1.1+N/2,0)),j=k.Add(s[1],new k(0,a*1.1+N,0));c.push(z,j,...I,...C,...h,...g,L);break}case"rightBottom":{const L=k.Sub(s[2],new k(0,a*1.1+N,0)),z=k.Sub(s[2],new k(-T,a*1.1+N/2,0)),j=k.Sub(s[2],new k(0,a*1.1,0));c.push(z,j,...I,...C,...h,...g,L);break}}const x=me(this.tmpPoints,e),D=[Math.floor(x.x+x.w/2),Math.floor(x.y+x.h/2)];return{rect:x,pos:D,points:c}}updateTempPoints(e){const t=e.slice(-2),o=new Q(t[0],t[1]),s=this.tmpPoints[0],{thickness:n}=this.workOptions;if(s.isNear(o,n)||Q.Sub(s,o).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(o.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=o}else this.tmpPoints.push(o);return!0}consumeService(e){var l,u;const{op:t,isFullWork:o,workState:s=A.Done}=e,n=(l=this.workId)==null?void 0:l.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new Q(t[h],t[h+1],t[h+2]));const a=o?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:n,layer:a,isDrawing:!1,isDrawEraserlines:s===A.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(n,{rect:c,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&U.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var g;const{node:t,opt:o,vNodes:s}=e,{strokeColor:n,fillColor:a,toolsType:c,placement:l,strokeType:u}=o,h=s.get(t.name),d=h==null?void 0:h.opt;let f=t;return t.tagName==="GROUP"&&(f=t.children[0]),n&&(f.setAttribute("strokeColor",n),d!=null&&d.strokeColor&&(d.strokeColor=n)),a&&(a==="transparent"?f.setAttribute("fillColor","rgba(0,0,0,0)"):f.setAttribute("fillColor",a),d!=null&&d.fillColor&&(d.fillColor=a)),c===v.SpeechBalloon&&l&&(d.placement=l),u&&(h!=null&&h.opt)&&((g=h.opt)!=null&&g.strokeType)&&(h.opt.strokeType=u),h&&s.setInfo(t.name,{...h,opt:d}),U.updateNodeOpt(e)}}var ff=kt,Mf=at,yf="[object Boolean]";function mf(r){return r===!0||r===!1||Mf(r)&&ff(r)==yf}var wf=mf;const zt=Ut(wf);class ln extends U{constructor(e){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.both);M(this,"toolsType",v.Straight);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"straightTipWidth");M(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.straightTipWidth=this.workOptions.thickness/2,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:o,isSubWorker:s,isMainThread:n,smoothSync:a}=e,c=this.workId,{op:l,syncUnitTime:u}=t,h=l==null?void 0:l.length;if(!h||h<2)return{type:b.None};u&&(this.syncUnitTime=u);let d;if(this.tmpPoints.length===0?(this.tmpPoints=[new Q(l[0],l[1])],d=!1):d=this.updateTempPoints(l),!d)return{type:b.None};let f;if(s||n){const p=o?this.fullLayer:this.drawLayer||this.fullLayer;f=this.draw({workId:c,layer:p})}if(!s&&a){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:b.DrawWork,dataType:V.Local,op:this.tmpPoints.map(y=>[...y.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:b.None}}const g=he(f,this.oldRect);return this.oldRect=f,{rect:g,type:b.DrawWork,dataType:V.Local,...this.baseConsumeResult}}consumeAll(){var a;const e=this.workId;if(this.tmpPoints.length<2)return{type:b.RemoveNode,removeIds:[e]};const t=this.fullLayer,o=this.draw({workId:e,layer:t});this.oldRect=o;const s=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Ye(s);return(a=this.vNodes)==null||a.setInfo(e,{rect:o,op:s,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&U.getCenterPos(o,t)}),{rect:o,type:b.FullWork,dataType:V.Local,ops:n,isSync:!0,...this.baseConsumeResult,updateNodeOpt:{useAnimation:!0}}}draw(e){const{workId:t,layer:o,isDrawEraserlines:s=!0}=e,{strokeColor:n,thickness:a,zIndex:c,scale:l,rotate:u,translate:h,strokeType:d,eraserlines:f}=this.workOptions,g=o.worldPosition,p=o.worldScaling,{d:y,rect:I,isDot:w}=this.computDrawPoints(a,d),S=[I.x+I.w/2,I.y+I.h/2],C=new ue.Group({pos:S,anchor:[.5,.5],size:[I.w,I.h],name:t,id:t,normalize:!0,zIndex:c}),T={pos:[0,0],normalize:!0,d:y,fillColor:n,strokeColor:n,lineDash:d===se.Dotted&&!w?[1,a*2]:d===se.LongDotted&&!w?[a,a*2]:void 0,lineCap:d===se.Normal||w?void 0:"round",lineWidth:d===se.Normal||w?0:a};l&&(T.scale=l),u&&(T.rotate=u),h&&(T.translate=h);const N=new ue.Path(T);C.append(N),f&&(this.scaleType=ce.proportional,this.drawEraserlines({group:C,eraserlines:f,pos:S,layer:o},s)),this.replace(o,t,C);let x={x:Math.floor(I.x*p[0]+g[0]-U.SafeBorderPadding),y:Math.floor(I.y*p[1]+g[1]-U.SafeBorderPadding),w:Math.floor(I.w*p[0]+2*U.SafeBorderPadding),h:Math.floor(I.h*p[1]+2*U.SafeBorderPadding)};if(u||l||h){const D=N.getBoundingClientRect();x={x:Math.floor(D.x-U.SafeBorderPadding),y:Math.floor(D.y-U.SafeBorderPadding),w:Math.floor(D.width+U.SafeBorderPadding*2),h:Math.floor(D.height+U.SafeBorderPadding*2)}}return this.isDelete&&C.setAttribute("opacity",0),x}computDrawPoints(e,t){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.straightTipWidth?this.computFullPoints(e,t):this.computDotPoints(e)}computFullPoints(e,t){const o=k.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),s=k.Per(o).mul(e/2),n=Q.Sub(this.tmpPoints[0],s),a=Q.Add(this.tmpPoints[0],s),c=Q.Sub(this.tmpPoints[1],s),l=Q.Add(this.tmpPoints[1],s),u=Q.GetSemicircleStroke(this.tmpPoints[1],c,-1,8),h=Q.GetSemicircleStroke(this.tmpPoints[0],a,-1,8),d=[n,c,...u,l,a,...h];let f;return t!==se.Normal?f=ft(this.tmpPoints,!1):f=ft(d,!0),{d:f,rect:me(d),isDot:!1,pos:this.tmpPoints[0].XY}}computDotPoints(e){const t=Q.GetDotStroke(this.tmpPoints[0],e/2,8);return{d:ft(t,!0),rect:me(t),isDot:!0,pos:this.tmpPoints[0].XY}}updateTempPoints(e){const t=e.slice(-2),o=new Q(t[0],t[1]),s=this.tmpPoints[0],{thickness:n}=this.workOptions;if(s.isNear(o,n))return!1;if(this.tmpPoints.length===2){if(o.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=o}else this.tmpPoints.push(o);return!0}consumeService(e){var l,u;const{op:t,isFullWork:o,workState:s=A.Done}=e,n=(l=this.workId)==null?void 0:l.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new Q(t[h],t[h+1],t[h+2]));const a=o?this.fullLayer:this.drawLayer||this.fullLayer,c=this.draw({workId:n,layer:a,isDrawEraserlines:s===A.Done});return this.oldRect=c,(u=this.vNodes)==null||u.setInfo(n,{rect:c,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&U.getCenterPos(c,a)}),c}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var l,u;const{node:t,opt:o,vNodes:s}=e,{strokeColor:n,strokeType:a}=o,c=s.get(t.name);return n&&(t.tagName==="GROUP"?t.children.forEach(h=>{h.setAttribute("strokeColor",n),h.getAttribute("fillColor")&&h.setAttribute("fillColor",n)}):(t.setAttribute("strokeColor",n),t.setAttribute("fillColor",n)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=n)),a&&(c!=null&&c.opt)&&((u=c.opt)!=null&&u.strokeType)&&(c.opt.strokeType=a),c&&s.setInfo(t.name,c),U.updateNodeOpt(e)}}const gt=class gt extends U{constructor(e){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.proportional);M(this,"toolsType",v.Text);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");this.workOptions=e.toolsOpt}consume(){return{type:b.None}}consumeAll(){return{type:b.None}}consumeService(){}async draw(e){const{workId:t,layer:o,isDrawLabel:s}=e,{boxSize:n,boxPoint:a,zIndex:c}=this.workOptions,l=o.worldPosition,u=o.worldScaling;if(!a||!n)return;const h={name:t,id:t,pos:[a[0],a[1]],anchor:[0,0],size:n,zIndex:c},d=new ue.Group(h),f={x:a[0],y:a[1],w:n[0],h:n[1]},g={x:Math.floor(f.x*u[0]+l[0]),y:Math.floor(f.y*u[1]+l[1]),w:Math.floor(f.w*u[0])+2,h:Math.floor(f.h*u[1])+2};if(this.replace(o,t,d),s&&o&&this.workOptions.text){const p=await gt.createLabels(this.workOptions,o,g),{labels:y,maxWidth:I}=p;d.append(...y),g.w=Math.ceil(Math.max(I*o.worldScaling[0],g.w))}return g}async consumeServiceAsync(e){var l,u,h,d;const t=(l=this.workId)==null?void 0:l.toString();if(!t)return;const{isFullWork:o,replaceId:s,isDrawLabel:n}=e;this.oldRect=s&&((h=(u=this.vNodes)==null?void 0:u.get(s))==null?void 0:h.rect)||void 0;const a=o?this.fullLayer:this.drawLayer||this.fullLayer,c=await this.draw({workId:t,layer:a,isDrawLabel:typeof n>"u"&&this.workOptions.workState===A.Done||n});return(d=this.vNodes)==null||d.setInfo(t,{rect:c,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&U.getCenterPos(c,a)}),c}updataOptService(){}async updataOptServiceAsync(e,t){var g,p;if(!this.workId)return;const o=this.workId.toString(),{fontColor:s,fontBgColor:n,bold:a,italic:c,lineThrough:l,underline:u,zIndex:h}=e,d=(g=this.vNodes)==null?void 0:g.get(o);if(!d)return;s&&(d.opt.fontColor=s),n&&(d.opt.fontBgColor=n),a&&(d.opt.bold=a),c&&(d.opt.italic=c),zt(l)&&(d.opt.lineThrough=l),zt(u)&&(d.opt.underline=u),We(h)&&(d.opt.zIndex=h),this.oldRect=d.rect;const f=await this.draw({workId:o,layer:this.fullLayer,isDrawLabel:typeof t>"u"&&this.workOptions.workState===A.Done||t});return(p=this.vNodes)==null||p.setInfo(o,{rect:f,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:f&&U.getCenterPos(f,this.fullLayer)}),f}clearTmpPoints(){this.tmpPoints.length=0}static getSafetySnippetRatio(e){const t=(e==null?void 0:e.parent).displayRatio||1,o=Math.ceil(e.worldScaling[0]*10)/10;let s=o;return o>=.2&&o<1?s=o*t:o<=2&&o>=1?s=o*t*1.6:o>2&&o<=3?s=o*t*1.4:o>3&&o<=4?s=o*t*.8:o>4&&(s=o*t*.6),Math.floor(s*1e3)/1e3}static getSafetySnippetFontLength(e){return Math.floor(gt.textImageSnippetSize*3/4/e)||1}static async createLabels(e,t,o){var j;const s=[],{x:n,y:a}=o,{width:c,height:l}=(j=t.parent)==null?void 0:j.parent,u=bt(e.text),h=u.length,{fontSize:d,lineHeight:f,bold:g,textAlign:p,italic:y,fontFamily:I,verticalAlign:w,fontColor:S,fontBgColor:C,underline:T,lineThrough:N}=e,x=gt.getSafetySnippetRatio(t)||1,D=Math.floor(d*x),L=gt.getSafetySnippetFontLength(D);let z=0;for(let E=0;E<h;E++){const R=u[E],P=f||D*1.5;if(R){const Z=gy(R),_=[0,0],B=[0,d*1.2];w==="middle"&&(_[1]=E*d*1.2+5);const J=[0,-d*.15];_[0]=5;const ie=Math.sin(Math.PI/180*20);let le=0;const oe=[];let K=0;for(;K<Z;){p==="left"&&(J[0]=le),K===0&&y==="italic"&&(J[0]=J[0]-ie/2*d);const de=R.slice(K,K+L),Ue={anchor:[0,0],pos:J,text:de,fontFamily:I,fontSize:D,lineHeight:P,strokeColor:S,fontWeight:g,fillColor:S,textAlign:p,fontStyle:y,scale:[1/x,1/x]},De=new ue.Label(Ue),ze=await De.textImageReady;let Fe=!0;if(ze){const He=ze.rect&&ze.rect[2],ee=ze.rect&&ze.rect[3];if(He&&ee){const $=He/x,X=ee/x;le=$+le,y==="italic"&&(g==="bold"?le=le-ie*d*1.2:le=le-ie*d),((J[0]+_[0]+$)*t.worldScaling[0]+n<=0||(J[0]+_[0])*t.worldScaling[0]+n>=c||(J[1]+_[1]+X)*t.worldScaling[1]+a<=0||(J[1]+_[1])*t.worldScaling[1]+a>=l)&&(De.disconnect(),Fe=!1),Fe&&oe.push(De)}}K+=L}B[0]=le,y==="italic"&&(B[0]=B[0]+ie*d),z=Math.max(z,B[0]);let q=!0;if(((_[0]+B[0])*t.worldScaling[0]+n<=0||_[0]*t.worldScaling[0]+n>=c||(_[1]+B[1])*t.worldScaling[0]+a<=0||_[1]*t.worldScaling[1]+a>=l)&&(q=!1),q){if(T){const De=Math.floor(d/10),ze={normalize:!1,pos:[0,d*1.1+De/2],lineWidth:De,points:[0,0,Math.ceil(B[0]),0],strokeColor:S,className:"underline"},Fe=new ue.Polyline(ze);oe.push(Fe)}if(N){const De={normalize:!1,pos:[0,d*1.2/2],lineWidth:Math.floor(d/10),points:[0,0,Math.ceil(B[0]),0],strokeColor:S,className:"lineThrough"},ze=new ue.Polyline(De);oe.push(ze)}const de={pos:_,anchor:[0,0],size:B,bgcolor:C},Ue=new ue.Group(de);Ue.append(...oe),s.push(Ue)}}}return{labels:s,maxWidth:z}}static updateNodeOpt(e){const{node:t,opt:o,vNodes:s,targetNode:n}=e,{fontBgColor:a,fontColor:c,translate:l,originPoint:u,scenePoint:h,scale:d,bold:f,italic:g,lineThrough:p,underline:y,fontSize:I,textInfos:w,zIndex:S}=o,C=n&&Ae(n)||s.get(t.name);if(!C||!t.parent)return;const N=C.opt;if(We(S)&&(t.setAttribute("zIndex",S),C.opt.zIndex=S),c&&N.fontColor&&(N.fontColor=c,t.children.forEach(x=>{x.tagName==="GROUP"&&x.children.forEach(D=>{D.tagName==="LABEL"?(D.setAttribute("fillColor",c),D.setAttribute("strokeColor",c)):D.tagName==="POLYLINE"&&D.setAttribute("strokeColor",c)})})),a&&N.fontBgColor&&(N.fontBgColor=a,t.children.forEach(x=>{x.tagName==="GROUP"&&x.setAttribute("bgcolor",a)})),f&&(N.bold=f),g&&(N.italic=g),zt(p)&&(N.lineThrough=p),zt(y)&&(N.underline=y),I&&(N.fontSize=I),u&&h&&d&&n&&N.boxPoint){const x=w==null?void 0:w.get(t.name);if(x){const{fontSize:j,boxSize:E}=x;N.boxSize=E||N.boxSize,N.fontSize=j||N.fontSize}const D=[N.boxPoint[0],N.boxPoint[1]];mo(N.boxPoint,h,d,l);const L=[C.op[0],C.op[1]],z=[L[0]-D[0],L[1]-D[1]];if(C.centerPos=[C.centerPos[0]+z[0],C.centerPos[1]+z[1]],C.opt.eraserlines)for(const j of C.opt.eraserlines){const{op:E,thickness:R}=j;j.thickness=Math.round(R*Math.max(d[0],d[1]));for(let P=0;P<E.length;P++)wo(E[P],h,d,l)}}else if(l&&N.boxPoint&&(N.boxPoint=[N.boxPoint[0]+l[0],N.boxPoint[1]+l[1]],C.centerPos=[C.centerPos[0]+l[0],C.centerPos[1]+l[1]],C.opt.eraserlines))for(const x of C.opt.eraserlines){const{op:D}=x;for(let L=0;L<D.length;L++){const z=D[L].map((j,E)=>E%2?j+l[1]:j+l[0]);x.op[L]=z}}return C&&s.setInfo(t.name,C),C==null?void 0:C.rect}static getRectFromLayer(e,t){const o=e.getElementsByName(t)[0];if(o){const s=o.getBoundingClientRect();let n={x:Math.floor(s.x),y:Math.floor(s.y),w:Math.floor(s.width+2),h:Math.floor(s.height+2)};return o.children.forEach(a=>{if(a.tagName==="GROUP"){const c=o.getBoundingClientRect();n=he(n,{x:Math.floor(c.x),y:Math.floor(c.y),w:Math.floor(c.width+2),h:Math.floor(c.height+2)})}}),n}}};M(gt,"textImageSnippetSize",1024*4),M(gt,"SafeBorderPadding",30);let gi=gt;const Et=class Et extends U{constructor(e){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.none);M(this,"toolsType",v.PencilEraser);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"worldPosition");M(this,"worldScaling");M(this,"eraserRect");M(this,"eraserPolyline");this.workOptions=e.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}combineConsume(e){const{workerEngine:t}=e;if(this.tmpPoints.length<2)return{type:b.None};const{thickness:o}=this.workOptions,{width:s,height:n}=Et.eraserSizes[o],a=Math.round(Math.max(s,n)/this.worldScaling[0]),{rect:c,willNewNodes:l,willDeleteNodes:u}=this.getChangeNodes(a,t);return{...this.baseConsumeResult,type:b.DrawWork,rect:c,willNewNodes:l,willDeleteNodes:u}}consumeService(){}updateTempPoints(e,t){let o=this.tmpPoints.length-1;const s=Date.now();for(let n=0;n<e.length;n+=2){const a=this.tmpPoints.length,c=new Q(e[n],e[n+1]);if(a===0){this.tmpPoints.push(c);continue}const l=a-1,u=this.tmpPoints[l],h=k.Sub(c,u).uni();c.isNear(u,t/2)||(k.Equals(h,u.v,.02)&&(this.tmpPoints.pop(),o--),c.setv(h),c.setT(s),this.tmpPoints.push(c))}return Math.max(o,0)}getChangeNodes(e,t){const o=new Map,s=new Set;let n;if(!this.vNodes)return{willDeleteNodes:s,willNewNodes:o,rect:n};const a=this.worldPosition;let c=me(this.tmpPoints,e);c=Kt(c,a),c=mn(c,this.worldScaling,a);const{nodeRange:l}=this.vNodes.getRectIntersectRange(c);if(!l.size)return{willDeleteNodes:s,willNewNodes:o,rect:n};const u=this.computEraserPointLines(this.tmpPoints,90);for(const[h,d]of l.entries()){if(d.toolsType!==v.Pencil)continue;let f=Kt(d.rect,[-a[0],-a[1]]);f={x:f.x/this.worldScaling[0],y:f.y/this.worldScaling[1],w:f.w/this.worldScaling[0],h:f.h/this.worldScaling[1]};const g=[f.x,f.y,f.x+f.w,f.y+f.h],p=[],y=[];for(const I of u)_i.polyline(I,g,p);if(p.length&&d.opt)for(const I of p){const w=[];for(let S=0;S<I.length;S++)S!==0&<(I[S],I[S-1])||w.push(...I[S]);y.push(w)}if(y.length&&t){const I=t.createWorkShapeNode({workId:h,toolsType:v.Pencil,toolsOpt:d.opt});I.setWorkId(h);const w=I==null?void 0:I.computPencilPoints({op:d.op,eraserPolylines:y,eraserThickness:e});if(n=he(n,d.rect),s.add(h),t.removeNode(h),w.length)for(let S=0;S<w.length;S++){const C=`${h}_${Date.now()}_${S}`,T=C,x=t.setFullWork({workId:T,opt:d.opt,toolsType:v.Pencil}).consumeService({op:w[S],isFullWork:!0,replaceId:T});t.clearWorkShapeNodeCache(T),n=he(n,x),o.set(C,{...d,toolsType:v.Pencil,rect:x??d.rect,name:C,op:w[S]})}}}return{willNewNodes:o,willDeleteNodes:s,rect:n}}consume(e){const{data:t}=e,{op:o}=t;if(!o||o.length===0)return{type:b.None,...this.baseConsumeResult};const{thickness:s}=this.workOptions,{width:n,height:a}=Et.eraserSizes[s],c=Math.max(n,a)/this.worldScaling[0];return this.updateTempPoints(o,c),{type:b.None,...this.baseConsumeResult}}computEraserPointLines(e,t=60){const o=[];let s=0;const n=360-t;for(let a=1;a<e.length;a++){const c=e[a-1],l=e[a];if(a===1&&s===0&&(o[s]=[c.XY]),o[s].push(l.XY),a<e.length-1){const u=l.getAngleByPoints(c,e[a+1]);(u<t||u>n)&&(s++,o[s]=[l.XY])}}return e.length===1&&o.length===0&&o.push([e[0].XY,e[0].XY]),o}consumeAll(e){const{workerEngine:t}=e;if(this.replace(this.fullLayer,this.workId),!this.tmpPoints.length)return{type:b.None,...this.baseConsumeResult};const{thickness:o}=this.workOptions,{width:s,height:n}=Et.eraserSizes[o],a=Math.max(s,n)/this.worldScaling[0],{willDeleteNodes:c,willNewNodes:l,rect:u}=this.getChangeNodes(a,t);if(c.size===0&&l.size===0)return{type:b.FullWork,...this.baseConsumeResult,rect:u};const h=[];this.tmpPoints.map(f=>{h.push(f.x,f.y,a/2)});const d=Ye(h);return{...this.baseConsumeResult,type:b.FullWork,dataType:V.Local,rect:u,ops:d,willNewNodes:l,willDeleteNodes:c}}clearTmpPoints(){this.tmpPoints.length=0}};M(Et,"eraserSizes",uo);let fi=Et;const Ot=class Ot extends U{constructor(e){super(e);M(this,"canRotate",!1);M(this,"scaleType",ce.none);M(this,"toolsType",v.BitMapEraser);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"worldPosition");M(this,"worldScaling");M(this,"eraserRect");M(this,"eraserPolyline");M(this,"oldRect");this.workOptions=e.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}combineConsume(e){const{workerEngine:t}=e;if(this.tmpPoints.length<2)return{type:b.None};const{thickness:o}=this.workOptions,{width:s,height:n}=Ot.eraserSizes[o],a=Math.round(Math.max(s,n)/this.worldScaling[0]),{willDeleteNodes:c,rect:l}=this.getChangeNodes(a,t);return{...this.baseConsumeResult,type:b.DrawWork,rect:l,willDeleteNodes:c}}consumeService(){}updateTempPoints(e,t){let o=this.tmpPoints.length-1;const s=Date.now();for(let n=0;n<e.length;n+=2){const a=this.tmpPoints.length,c=new Q(e[n],e[n+1]);if(a===0){this.tmpPoints.push(c);continue}const l=a-1,u=this.tmpPoints[l],h=k.Sub(c,u).uni();c.isNear(u,t/2)||(k.Equals(h,u.v,.02)&&(this.tmpPoints.pop(),o--),c.setv(h),c.setT(s),this.tmpPoints.push(c))}return Math.max(o,0)}getChangeNodes(e,t){const o=new Map,s=new Set;let n;if(!this.vNodes)return{willDeleteNodes:s,willUpdateNodes:o,rect:n};const a=this.worldPosition;let c=me(this.tmpPoints,e);c=Kt(c,a),c=mn(c,this.worldScaling,a);const{nodeRange:l}=this.vNodes.getRectIntersectRange(c);if(!l.size)return{willDeleteNodes:s,willUpdateNodes:o,rect:n};const u=this.computEraserPointLines(this.tmpPoints);for(const[h,d]of l.entries()){if(d.toolsType===v.Text||d.toolsType===v.Image)continue;let f=Kt(d.rect,[-a[0],-a[1]]);f={x:f.x/this.worldScaling[0],y:f.y/this.worldScaling[1],w:f.w/this.worldScaling[0],h:f.h/this.worldScaling[1]};const g=[f.x,f.y,f.x+f.w,f.y+f.h],p=[],y=[];for(const S of u)_i.polyline(S,g,p);if(p.length&&d.opt)for(const S of p){const C=[];for(let T=0;T<S.length&&!(isNaN(S[T][0])||isNaN(S[T][1]));T++){const N=S[T].map(x=>Math.round(x*100)/100);if(T!==0){const x=S[T-1].map(D=>Math.round(D*100)/100);if(lt(N,x))continue}C.push(...N)}C.length!==0&&y.push(C)}if(!y.length)continue;const I=d.opt.eraserlines?d.opt.eraserlines:[],w=I.find(S=>S.workId===this.workId);if(w?w.op=y:I.push({workId:this.workId,op:y,thickness:e}),d.opt.eraserlines=I,t){const{toolsType:S}=d,C=t.createWorkShapeNode({workId:h,toolsType:S,toolsOpt:d.opt});C==null||C.setWorkId(h);const T=C==null?void 0:C.consumeService({op:d.op,isFullWork:!0,replaceId:h});if(n=he(n,T),C!=null&&C.isDelete){t.removeNode(h),s.add(h);continue}}o.set(h,d)}return{willUpdateNodes:o,willDeleteNodes:s,rect:n}}consume(e){const{data:t}=e,{op:o}=t;if(!o||o.length===0)return{type:b.None,...this.baseConsumeResult};const{thickness:s}=this.workOptions,{width:n,height:a}=Ot.eraserSizes[s],c=Math.round(Math.max(n,a)/this.worldScaling[0]);return this.updateTempPoints(o,c),{type:b.None,...this.baseConsumeResult}}computEraserPointLines(e,t=60){const o=[];let s=0;const n=360-t;for(let a=1;a<e.length;a++){const c=e[a-1],l=e[a];if(a===1&&s===0&&(o[s]=[c.XY]),o[s].push(l.XY),a<e.length-1){const u=l.getAngleByPoints(c,e[a+1]);(u<t||u>n)&&(s++,o[s]=[l.XY])}}return e.length===1&&o.length===0&&o.push([e[0].XY,e[0].XY]),o}consumeAll(e){const{workerEngine:t}=e;if(this.replace(this.fullLayer,this.workId),!this.tmpPoints.length)return{type:b.None,...this.baseConsumeResult};const{thickness:o}=this.workOptions,{width:s,height:n}=Ot.eraserSizes[o],a=Math.round(Math.max(s,n)/this.worldScaling[0]),{willDeleteNodes:c,willUpdateNodes:l,rect:u}=this.getChangeNodes(a,t);if(c.size===0&&l.size===0)return{type:b.FullWork,...this.baseConsumeResult,rect:u};const h=[];this.tmpPoints.map(f=>{h.push(f.x,f.y,a/2)});const d=Ye(h);return{...this.baseConsumeResult,type:b.FullWork,dataType:V.Local,rect:u,ops:d,willUpdateNodes:l,willDeleteNodes:c}}clearTmpPoints(){this.tmpPoints.length=0}};M(Ot,"eraserSizes",uo);let Mi=Ot;function hn(r){switch(r){case v.Arrow:return on;case v.Pencil:return Ks;case v.Straight:return ln;case v.Ellipse:return sn;case v.Polygon:case v.Triangle:return an;case v.Star:case v.Rhombus:return rn;case v.Rectangle:return nn;case v.SpeechBalloon:return cn;case v.Text:return gi;case v.LaserPen:return _s;case v.Eraser:return ui;case v.PencilEraser:return fi;case v.BitMapEraser:return Mi;case v.Selector:return pi;case v.Image:return qt}}function Li(r,i){const{toolsType:e,...t}=r;switch(e){case v.Arrow:return new on(t);case v.Pencil:return new Ks(t);case v.Straight:return new ln(t);case v.Ellipse:return new sn(t);case v.Polygon:case v.Triangle:return new an(t);case v.Star:case v.Rhombus:return new rn(t);case v.Rectangle:return new nn(t);case v.SpeechBalloon:return new cn(t);case v.Text:return new gi(t);case v.LaserPen:return new _s(t);case v.Eraser:return new ui(t,i);case v.BitMapEraser:return new Mi(t);case v.PencilEraser:return new fi(t);case v.Selector:return t.vNodes?new pi({...t,vNodes:t.vNodes,drawLayer:t.fullLayer}):void 0;case v.Image:return new qt(t);default:return}}function un(r){const i=[],e=["PATH","SPRITE","POLYLINE","RECT","ELLIPSE","LABEL"];for(const t of r){if(t.tagName==="GROUP"&&t.children.length){const o=un(t.children);i.push(...o)}t.tagName&&e.includes(t.tagName)&&i.push(t)}return i}const If="cursorhover",Mo=20,ge="mainView";class dn{constructor(i,e){M(this,"viewId");M(this,"scene");M(this,"fullLayer");M(this,"curNodeMap",new Map);M(this,"targetNodeMap",[]);M(this,"highLevelIds");M(this,"canClearUids");M(this,"localUid");this.viewId=i,this.scene=e}init(i){this.fullLayer=i}get(i){return this.curNodeMap.get(i)}setLocalUid(i){this.localUid=i}getLocalUid(){return this.localUid}setCanClearUids(i){this.canClearUids=i}getCanClearUids(){return this.canClearUids}getCanEraserNodes(i,e){const t=new Map;for(const[o,s]of i.entries())s.toolsType===v.Image&&(s.opt.locked||e&&e.disableEraseImage)||s.toolsType===v.Text&&(s.opt.workState===A.Doing||s.opt.workState===A.Start||e&&e.disableEraseText)||this.isCanClearWorkId(o)&&t.set(o,s);return t}getNodesByType(i){const e=new Map;return this.curNodeMap.forEach((t,o)=>{t.toolsType===i&&e.set(o,t)}),e}gethasEraserNodes(){const i=new Map;return this.curNodeMap.forEach((e,t)=>{var o;(o=e.opt.eraserlines)!=null&&o.length&&i.set(t,e)}),i}hasRenderNodes(){return!0}has(i){return this.curNodeMap.has(i)}setInfo(i,e){const t=this.curNodeMap.get(i)||{name:i,rect:e.rect};e.rect&&(t.rect=Ae(e.rect)),e.op&&ay(e.op)&&(t.op=Ae(e.op)),e.canRotate&&(t.canRotate=e.canRotate),e.scaleType&&(t.scaleType=e.scaleType),e.opt&&(t.opt=Ae(e.opt)),e.toolsType&&(t.toolsType=e.toolsType),e.centerPos&&(t.centerPos=Ae(e.centerPos)),zt(e.isSelected)&&(t.isSelected=e.isSelected),t.rect?this.curNodeMap.set(i,t):this.curNodeMap.delete(i)}selected(i){this.setInfo(i,{isSelected:!0})}unSelected(i){this.setInfo(i,{isSelected:!1})}delete(i){this.curNodeMap.delete(i)}clear(){this.curNodeMap.clear(),this.targetNodeMap.length=0}getRectIntersectRange(i,e=!0,t=!0){let o;const s=new Map;for(const[n,a]of this.curNodeMap.entries())if(Hi(i,a.rect)){if(e&&a.toolsType===v.Image&&a.opt.locked||t&&a.toolsType===v.Text&&(a.opt.workState===A.Doing||a.opt.workState===A.Start))continue;o=he(o,a.rect),s.set(n,a)}return{rectRange:o,nodeRange:s}}getNodeRectFormShape(i,e){const t=hn(e.toolsType);return this.fullLayer&&(t==null?void 0:t.getRectFromLayer(this.fullLayer,i))}updateNodeRect(i){const e=this.curNodeMap.get(i);if(e){const t=this.getNodeRectFormShape(i,e);if(!t){this.curNodeMap.delete(i);return}e.rect=t,this.curNodeMap.set(i,e)}}updateHighLevelNodesRect(i){this.highLevelIds=i;for(const e of this.highLevelIds.keys())this.updateNodeRect(e)}updateLowLevelNodesRect(){var i;for(const e of this.curNodeMap.keys())(i=this.highLevelIds)!=null&&i.has(e)||this.updateNodeRect(e)}clearHighLevelIds(){this.highLevelIds=void 0}setTargetAssignKeys(i){const e=new Map;for(const t of i){const o=this.curNodeMap.get(t);o&&e.set(t,Ae(o))}return this.targetNodeMap.push(Ae(e)),this.targetNodeMap.length-1}setTarget(){return this.targetNodeMap.push(Ae(this.curNodeMap)),this.targetNodeMap.length-1}getLastTarget(){return this.targetNodeMap[this.targetNodeMap.length-1]}deleteLastTarget(){this.targetNodeMap.length&&(this.targetNodeMap.length=this.targetNodeMap.length-1)}getTarget(i){return this.targetNodeMap[i]}deleteTarget(i){this.targetNodeMap.length=i}clearTarget(){this.targetNodeMap.length=0}isLocalWorkId(i){return i.split(Ze).length===1}isCanClearWorkId(i){if(this.canClearUids===void 0||this.canClearUids===!0)return!0;if(op(this.canClearUids)){const e=i.split(Ze);if(e.length===1)return this.canClearUids.has("localSelf")||this.localUid&&this.canClearUids.has(this.localUid);if(e.length===2)return this.canClearUids.has(e[0])}return!1}}class Tf{constructor(i,e,t){M(this,"viewId");M(this,"scene");M(this,"fullLayer");M(this,"vNodes");M(this,"dpr");M(this,"contextType");M(this,"opt");M(this,"cameraOpt");M(this,"isSafari",!1);M(this,"combinePostMsg",new Set);M(this,"workerTaskId");M(this,"protectedTask");M(this,"hasPriorityDraw",!0);M(this,"delayPostDoneResolve");M(this,"cacheImages",new Map);M(this,"imageResolveMap",new Map);M(this,"taskUpdateCameraId");M(this,"debounceUpdateCameraId");var o,s;if(this.viewId=i,this.opt=e,this.dpr=e.dpr,this.contextType=this.getSupportContextType(t,(o=e==null?void 0:e.offscreenCanvasOpt)==null?void 0:o.contextType),!this.contextType)throw new Error("Sorry, your browser doesn't support canvas context type 2d or webgl");try{this.createRenderLayer(e)}catch(n){if(this.contextType!=="2d")this.contextType="2d",(s=this.scene)==null||s.disconnect(),this.createRenderLayer(e);else throw n}this.vNodes=new dn(i,this.scene)}createRenderLayer(i){this.scene=this.createScene(i.offscreenCanvasOpt);const e=Me.bufferSize.full,t=Me.bufferSize.sub;this.fullLayer=this.createLayer("fullLayer",this.scene,{...i.layerOpt,bufferSize:this.viewId===ge?e:t*2})}async updateDpr(i){this.dpr=i,this.scene.displayRatio=i}getCachedImages(i){var e;return(e=this.cacheImages.get(i))==null?void 0:e.imageBitmap}getCachedImagesByWorkId(i){for(const[e,t]of this.cacheImages.entries())if(e===i&&t.imageBitmap)return t.imageBitmap}deleteCachedImagesByWorkId(i,e){for(const[t,o]of this.cacheImages.entries())e&&t===e||o.workId===i&&(o.imageBitmap.close(),this.cacheImages.delete(t))}clearCacheImages(){this.cacheImages.forEach(i=>i.imageBitmap.close()),this.cacheImages.clear()}clearImageResolveMap(){this.imageResolveMap.forEach(({timer:i})=>{i&&clearTimeout(i)}),this.imageResolveMap.clear()}setHasPriorityDraw(i){this.hasPriorityDraw=i}getPriorityDraw(){return this.hasPriorityDraw}setIsSafari(i){this.isSafari=i}async on(i){const{msgType:e,toolsType:t,opt:o,imageSrc:s,imageBitmap:n,workId:a,dpr:c}=i;switch(e){case b.UpdateDpr:We(c)&&await this.updateDpr(c);break;case b.UpdateCamera:await this.updateCamera(i);break;case b.Destroy:this.destroy();break;case b.Clear:await this.clearAll();break;case b.UpdateTools:if(t&&o){const l={toolsType:t,toolsOpt:o,combineUnitTime:i.combineUnitTime,maxCombineEraserTime:i.maxCombineEraserTime};this.localWork.setToolsOpt(l)}break;case b.GetImageBitMap:if(s&&n&&a){const l=a.toString();this.cacheImages.set(s,{imageBitmap:n,workId:l});const u=this.imageResolveMap.get(s);if(u){const{resolve:h,timer:d}=u;d&&clearTimeout(d),h&&h(s)}this.deleteCachedImagesByWorkId(l,s)}break}}getIconSize(i,e,t){const o=i*t,s=e*t;return o<=50||s<=50?[50,50]:o<=100||s<=100?[100,100]:o<=200||s<=200?[200,200]:o<=400||s<=400?[400,400]:o<=800||s<=800?[800,800]:[1600,1600]}async loadImageBitMap(i){const{toolsType:e,opt:t,workId:o,isSubWorker:s}=i;if(e===v.Image&&t&&o){const n=o.toString(),{src:a,type:c,width:l,height:u,strokeColor:h}=t;if(!a||!c||!l||!u)return;let d=a;if(c===St.Iconify){const[y,I]=this.getIconSize(l,u,this.dpr);d=`${a}?width=${y}&height=${I}&color=${h}`}if(this.cacheImages.has(d)){const y=this.getCachedImages(d);if(y)return y}if(this.imageResolveMap.has(d)){const y=this.getCachedImagesByWorkId(n);if(y)return y}const p=await new Promise(y=>{const I=this.imageResolveMap.get(d)||{resolve:void 0,timer:void 0};I.timer&&clearTimeout(I.timer),I.resolve=y,I.timer=setTimeout(()=>{const w=this.imageResolveMap.get(d);w!=null&&w.resolve&&w.resolve(d)},5e3),this.imageResolveMap.set(d,I),this._post({sp:[{imageSrc:d,workId:n,viewId:this.viewId,isgl:!!this.fullLayer.parent.gl,isSubWorker:s,type:b.GetImageBitMap}]})});return this.imageResolveMap.delete(p),this.getCachedImages(d)}}createLocalWork(i){const{workId:e,opt:t,toolsType:o}=i;e&&t&&(!this.localWork.getToolsOpt()&&o&&this.setToolsOpt({toolsType:o,toolsOpt:t}),this.setWorkOpt({workId:e,toolsOpt:t}))}updateScene(i){this.scene.attr({...i});const{width:e,height:t}=i;this.scene.container.width=e,this.scene.container.height=t,this.scene.width=e,this.scene.height=t,this.updateLayer({width:e,height:t})}updateLayer(i){const{width:e,height:t}=i;this.fullLayer&&(this.fullLayer.parent.setAttribute("width",e),this.fullLayer.parent.setAttribute("height",t),this.fullLayer.setAttribute("size",[e,t]),this.fullLayer.setAttribute("pos",[e*.5,t*.5]))}getSupportContextType(i,e){const t=new OffscreenCanvas(100,100);let o=["2d"];i===$i.Full&&this.viewId===ge&&(o=["webgl2","webgl","2d"],e&&o.unshift(e));for(const s of o)try{if(t.getContext(s))return s}catch(n){throw n}}createScene(i){const{width:e,height:t}=i,o=new OffscreenCanvas(e,t);i.contextType&&delete i.contextType;const s=new ue.Scene({container:o,displayRatio:this.dpr,depth:!1,desynchronized:!0,failIfMajorPerformanceCaveat:!0,...i,contextType:this.contextType,id:this.viewId});return s.setAttribute("id",this.viewId),s}createLayer(i,e,t){const{width:o,height:s}=t,n=`offscreen-${i}`,a=e.layer(n,t),c=new ue.Group({anchor:[.5,.5],pos:[o*.5,s*.5],size:[o,s],name:"viewport",id:i});return a.append(c),c}async clearAll(){var i;this.fullLayer&&(this.fullLayer.parent.children.forEach(e=>{e.name!=="viewport"&&e.remove()}),Be(this.fullLayer,this.fullLayer.parent)),this.taskUpdateCameraId&&(clearTimeout(this.taskUpdateCameraId),this.taskUpdateCameraId=void 0),this.debounceUpdateCameraId&&(clearTimeout(this.debounceUpdateCameraId),this.debounceUpdateCameraId=void 0),this.clearCacheImages(),this.clearImageResolveMap(),this.localWork.destroy(),(i=this.serviceWork)==null||i.destroy()}setToolsOpt(i){this.localWork.setToolsOpt(i)}setWorkOpt(i){const{workId:e,toolsOpt:t}=i;e&&t&&this.localWork.setWorkOptions(e.toString(),t)}destroy(){var i;this.vNodes.clear(),this.fullLayer.remove(),$e(this.fullLayer,this.fullLayer.parent),this.clearCacheImages(),this.clearImageResolveMap(),this.scene.remove(),this.localWork.destroy(),(i=this.serviceWork)==null||i.destroy()}async post(i){this.combinePostMsg.add(i),await this.runBatchPostData()}async runBatchPostData(){this.workerTaskId||(this.workerTaskId=setTimeout(()=>{this.workerTaskId=void 0,this.combinePost()},16)),this.type===$i.Full&&!this.delayPostDoneResolve&&await new Promise(e=>{this.delayPostDoneResolve=e})&&(this.delayPostDoneResolve=void 0)}combinePostData(){var a,c;this.workerTaskId=void 0;const i=[],e=[];let t,o,s;const n=new Set;for(const l of this.combinePostMsg.values()){if((a=l.render)!=null&&a.length)for(const u of l.render){let h=!1;if(u.workId&&n.add(u.workId),u.isClearAll&&(u.rect=this.getSceneRect(),u.isClear=!0,delete u.isClearAll),u.drawCanvas){const d=this.getLayer(u.drawCanvas);if(!d||!(d.parent instanceof ue.Layer))continue;if(d.parent.render(),u.isDrawAll){const f=this.getSceneRect();u.rect=f,delete u.isDrawAll}}for(const d of i)if(u.viewId===d.viewId){u.isClear&&d.clearCanvas&&d.isClear&&d.clearCanvas===u.clearCanvas&&(d.rect=he(d.rect,u.rect),h=!0),d.drawCanvas&&d.drawCanvas===u.drawCanvas&&(d.rect=he(d.rect,u.rect),h=!0);continue}h||(u.isClear&&!u.drawCanvas?i.unshift(u):i.push(u))}if((c=l.sp)!=null&&c.length)for(const u of l.sp){let h=!1;for(const d of e)if(lt(u,d)){h=!0;break}h||e.push(u)}We(l.fullWorkerDrawCount)&&(t=l.fullWorkerDrawCount),We(l.subWorkerDrawCount)&&(o=l.subWorkerDrawCount),We(l.consumeCount)&&(s=l.consumeCount)}return this.combinePostMsg.clear(),{render:i,sp:e,fullWorkerDrawCount:t,subWorkerDrawCount:o,consumeCount:s,workIds:n,viewId:this.viewId}}getSceneRect(){const{width:i,height:e}=this.scene;return{x:0,y:0,w:Math.floor(i),h:Math.floor(e)}}}class vf{constructor(i){M(this,"viewId");M(this,"vNodes");M(this,"thread");M(this,"fullLayer");M(this,"drawLayer");M(this,"_post");M(this,"tmpOpt");M(this,"workShapes",new Map);M(this,"drawCount",0);M(this,"consumeCount",0);M(this,"syncUnitTime",Me.syncOpt.interval);M(this,"combineUnitTime",Me.bezier.combineUnitTime);M(this,"maxCombineEraserTime",Me.pencilEraser.maxCombineTime);this.thread=i.thread,this.viewId=i.viewId,this.vNodes=i.vNodes,this.fullLayer=i.fullLayer,this.drawLayer=i.drawLayer,this._post=this.thread.post.bind(i.thread)}setmaxCombineEraserTime(i){this.maxCombineEraserTime=i}setCombineUnitTime(i){this.combineUnitTime=i}setSyncUnitTime(i){this.syncUnitTime=i}destroy(){this.workShapes.clear()}getWorkShapes(){return this.workShapes}getWorkShape(i){return this.workShapes.get(i)}createWorkShape(i,e){if(i&&this.tmpOpt){const t={toolsType:this.tmpOpt.toolsType,toolsOpt:e||this.tmpOpt.toolsOpt},o=this.createWorkShapeNode({...t,workId:i});o&&this.workShapes.set(i,o)}}setWorkOptions(i,e){const t=this.getWorkShape(i);t||this.createWorkShape(i,e),t==null||t.setWorkOptions(e)}createWorkShapeNode(i){var e;return Li({...i,vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer},(e=this.thread)==null?void 0:e.serviceWork)}setToolsOpt(i){var e,t,o;((e=this.tmpOpt)==null?void 0:e.toolsType)!==i.toolsType&&(t=this.tmpOpt)!=null&&t.toolsType&&this.clearAllWorkShapesCache(),this.tmpOpt=i,(o=i.toolsOpt)!=null&&o.syncUnitTime&&(this.syncUnitTime=i.toolsOpt.syncUnitTime),i.combineUnitTime&&(this.combineUnitTime=i.combineUnitTime),i.maxCombineEraserTime&&(this.maxCombineEraserTime=i.maxCombineEraserTime)}getToolsOpt(){return this.tmpOpt}clearWorkShapeNodeCache(i){var e;(e=this.getWorkShape(i))==null||e.clearTmpPoints(),this.workShapes.delete(i)}clearAllWorkShapesCache(){this.workShapes.forEach(i=>i.clearTmpPoints()),this.workShapes.clear()}setFullWork(i){const{workId:e,opt:t,toolsType:o}=i;if(e&&t&&o){const s=e.toString();let n;return e&&this.workShapes.has(s)?(n=this.workShapes.get(s),n==null||n.setWorkOptions(t)):n=this.createWorkShapeNode({toolsOpt:t,toolsType:o,workId:s}),n?(this.workShapes.set(s,n),n):void 0}}}function Nf(r){return r}var pn=Nf;function Sf(r,i,e){switch(e.length){case 0:return r.call(i);case 1:return r.call(i,e[0]);case 2:return r.call(i,e[0],e[1]);case 3:return r.call(i,e[0],e[1],e[2])}return r.apply(i,e)}var Cf=Sf,kf=Cf,ls=Math.max;function xf(r,i,e){return i=ls(i===void 0?r.length-1:i,0),function(){for(var t=arguments,o=-1,s=ls(t.length-i,0),n=Array(s);++o<s;)n[o]=t[i+o];o=-1;for(var a=Array(i+1);++o<i;)a[o]=t[o];return a[i]=e(n),kf(r,this,a)}}var bf=xf;function Df(r){return function(){return r}}var Lf=Df,Af=Lf,hs=bs,jf=pn,zf=hs?function(r,i){return hs(r,"toString",{configurable:!0,enumerable:!1,value:Af(i),writable:!0})}:jf,Pf=zf,Ef=800,Of=16,Rf=Date.now;function Wf(r){var i=0,e=0;return function(){var t=Rf(),o=Of-(t-e);if(e=t,o>0){if(++i>=Ef)return arguments[0]}else i=0;return r.apply(void 0,arguments)}}var Yf=Wf,Uf=Pf,Bf=Yf,Ff=Bf(Uf),Vf=Ff,Qf=pn,Zf=bf,$f=Vf;function Hf(r,i){return $f(Zf(r,i,Qf),r+"")}var Gf=Hf;function Xf(r,i,e,t){for(var o=r.length,s=e+(t?1:-1);t?s--:++s<o;)if(i(r[s],s,r))return s;return-1}var Jf=Xf;function qf(r){return r!==r}var Kf=qf;function _f(r,i,e){for(var t=e-1,o=r.length;++t<o;)if(r[t]===i)return t;return-1}var eM=_f,tM=Jf,iM=Kf,oM=eM;function sM(r,i,e){return i===i?oM(r,i,e):tM(r,iM,e)}var nM=sM,rM=nM;function aM(r,i){var e=r==null?0:r.length;return!!e&&rM(r,i,0)>-1}var gn=aM;function cM(r,i,e){for(var t=-1,o=r==null?0:r.length;++t<o;)if(e(i,r[t]))return!0;return!1}var fn=cM;function lM(r,i){for(var e=-1,t=r==null?0:r.length,o=Array(t);++e<t;)o[e]=i(r[e],e,r);return o}var hM=lM,uM=po,dM=gn,pM=fn,gM=hM,fM=xi,MM=go,yM=200;function mM(r,i,e,t){var o=-1,s=dM,n=!0,a=r.length,c=[],l=i.length;if(!a)return c;e&&(i=gM(i,fM(e))),t?(s=pM,n=!1):i.length>=yM&&(s=MM,n=!1,i=new uM(i));e:for(;++o<a;){var u=r[o],h=e==null?u:e(u);if(u=t||u!==0?u:0,n&&h===h){for(var d=l;d--;)if(i[d]===h)continue e;c.push(u)}else s(i,h,t)||c.push(u)}return c}var wM=mM,us=_t,IM=js,TM=ei,ds=us?us.isConcatSpreadable:void 0;function vM(r){return TM(r)||IM(r)||!!(ds&&r&&r[ds])}var NM=vM,SM=lo,CM=NM;function Mn(r,i,e,t,o){var s=-1,n=r.length;for(e||(e=CM),o||(o=[]);++s<n;){var a=r[s];i>0&&e(a)?i>1?Mn(a,i-1,e,t,o):SM(o,a):t||(o[o.length]=a)}return o}var kM=Mn;function xM(){}var bM=xM,Oi=Vs,DM=bM,LM=fo,AM=1/0,jM=Oi&&1/LM(new Oi([,-0]))[1]==AM?function(r){return new Oi(r)}:DM,zM=jM,PM=po,EM=gn,OM=fn,RM=go,WM=zM,YM=fo,UM=200;function BM(r,i,e){var t=-1,o=EM,s=r.length,n=!0,a=[],c=a;if(e)n=!1,o=OM;else if(s>=UM){var l=i?null:WM(r);if(l)return YM(l);n=!1,o=RM,c=new PM}else c=i?[]:a;e:for(;++t<s;){var u=r[t],h=i?i(u):u;if(u=e||u!==0?u:0,n&&h===h){for(var d=c.length;d--;)if(c[d]===h)continue e;i&&c.push(h),a.push(u)}else o(c,h,e)||(c!==a&&c.push(h),a.push(u))}return a}var FM=BM,VM=wM,QM=kM,ps=FM;function ZM(r,i,e){var t=r.length;if(t<2)return t?ps(r[0]):[];for(var o=-1,s=Array(t);++o<t;)for(var n=r[o],a=-1;++a<t;)a!=o&&(s[o]=VM(s[o]||n,r[a],i,e));return ps(QM(s,1),i,e)}var $M=ZM,HM=no,GM=at;function XM(r){return GM(r)&&HM(r)}var JM=XM,qM=Rs,KM=Gf,_M=$M,ey=JM;KM(function(r){return _M(qM(r,ey))});class ty extends vf{constructor(e){super(e);M(this,"drawWorkActiveId")}async runFullWork(e){var s;const t=this.setFullWork(e),o=e.ops&&bt(e.ops);if(t){let n,a;const c=(s=t.getWorkId())==null?void 0:s.toString();return t.toolsType===v.Image?n=await t.consumeServiceAsync({isFullWork:!0,worker:this.thread}):t.toolsType===v.Text?n=await t.consumeServiceAsync({isFullWork:!0,replaceId:c,isDrawLabel:!0}):(n=t.consumeService({op:o,isFullWork:!0,replaceId:c}),a=(e==null?void 0:e.updateNodeOpt)&&t.updataOptService(e.updateNodeOpt)),e.workId&&this.workShapes.delete(e.workId.toString()),he(n,a)}}runSelectWork(e){var o;const t=this.setFullWork(e);t&&((o=e.selectIds)!=null&&o.length)&&e.workId&&t.selectServiceNode(e.workId.toString(),{selectIds:e.selectIds},!1)}workShapesDone(){for(const e of this.workShapes.keys())this.clearWorkShapeNodeCache(e);Be(this.fullLayer,this.fullLayer.parent)}canUseSubWorker(e){const t=this.thread.getPriorityDraw();return t||!t&&e!==v.Pencil}async consumeDraw(e){const{workId:t,fullWorkerDrawCount:o,postCount:s}=e,n=t==null?void 0:t.toString(),a=n&&this.workShapes.get(n);if(!a)return;this.drawWorkActiveId&&this.drawWorkActiveId!==n&&(await this.consumeDrawAll({workId:this.drawWorkActiveId,viewId:this.viewId,msgType:b.DrawWork,dataType:V.Local}),this.drawWorkActiveId=void 0),!this.drawWorkActiveId&&n!==G&&(this.drawWorkActiveId=n);const c=a.toolsType;We(s)&&(this.consumeCount=s);const l=a.consume({data:e,drawCount:this.drawCount,isFullWork:!0,isSubWorker:!0,removeDrawCount:o});switch(c){case v.Selector:l&&(this.drawCount++,await this.drawSelector(l));break;case v.Ellipse:case v.Arrow:case v.Straight:case v.Rectangle:case v.Star:case v.Polygon:case v.SpeechBalloon:{l&&(this.drawCount++,await this.drawShape(l));break}case v.Pencil:{l&&(this.drawCount++,await this.drawPencil(l,t==null?void 0:t.toString()));break}case v.BitMapEraser:case v.PencilEraser:{l&&(this.drawCount++,await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount}));break}}}async consumeDrawAll(e){const{workId:t}=e;if(t){const o=t.toString();this.drawWorkActiveId===o&&(this.drawWorkActiveId=void 0);const s=this.workShapes.get(o);if(!s)return;switch(s.toolsType){case v.Selector:this.drawCount=0,Be(this.fullLayer,this.fullLayer.parent),this.clearWorkShapeNodeCache(o),this._post({render:[{isClearAll:!0,clearCanvas:we.Float,viewId:this.viewId}]});break;case v.Arrow:case v.Straight:case v.Ellipse:case v.Pencil:case v.Rectangle:case v.Star:case v.Polygon:case v.SpeechBalloon:case v.BitMapEraser:case v.PencilEraser:this.drawCount=0,Be(this.fullLayer,this.fullLayer.parent),this.clearWorkShapeNodeCache(o);break}}}async removeWork(e){const{workId:t}=e,o=t==null?void 0:t.toString();if(o){const s=this.removeNode(o);if(s){const n=[];n.push({rect:pt(s),clearCanvas:we.Float,isClear:!0,viewId:this.viewId},{rect:pt(s),drawCanvas:we.Float,viewId:this.viewId}),await this._post({render:n})}}}removeNode(e){const t=this.workShapes.has(e);let o;return t&&(this.fullLayer.getElementsByName(e).forEach(s=>{const n=s.getBoundingClientRect();o=he(o,{x:n.x-U.SafeBorderPadding,y:n.y-U.SafeBorderPadding,w:n.width+U.SafeBorderPadding*2,h:n.height+U.SafeBorderPadding*2}),s.remove(),$e(s,this.fullLayer.parent)}),o&&this.clearWorkShapeNodeCache(e)),o}async drawPencil(e,t){await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:e==null?void 0:e.rect,workId:t,drawCanvas:we.Float,viewId:this.viewId}],sp:(e==null?void 0:e.op)&&[e]})}async drawShape(e){await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:(e==null?void 0:e.rect)&&pt(e.rect),isClear:!0,clearCanvas:we.Float,viewId:this.viewId},{rect:(e==null?void 0:e.rect)&&pt(e.rect),drawCanvas:we.Float,viewId:this.viewId}]})}async drawSelector(e){await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:(e==null?void 0:e.rect)&&pt(e.rect),isClear:!0,clearCanvas:we.Float,viewId:this.viewId},{rect:(e==null?void 0:e.rect)&&pt(e.rect),drawCanvas:we.Float,viewId:this.viewId}]})}}class iy{constructor(i){M(this,"viewId");M(this,"vNodes");M(this,"topLayer");M(this,"thread");M(this,"post");M(this,"serviceWorkShapes",new Map);M(this,"localWorkShapes",new Map);M(this,"tmpOpt");M(this,"syncUnitTime",Me.syncOpt.interval);M(this,"animationId");this.viewId=i.viewId,this.vNodes=i.vNodes,this.topLayer=i.topLayer,this.thread=i.thread,this.post=i.thread.post.bind(i.thread)}canUseTopLayer(i){return i===v.LaserPen}getWorkShape(i){return this.localWorkShapes.get(i)}createWorkShape(i,e){if(i&&this.tmpOpt){const t={toolsType:this.tmpOpt.toolsType,toolsOpt:e||this.tmpOpt.toolsOpt},o=this.createWorkShapeNode({...t,workId:i});return o&&this.localWorkShapes.set(i,{node:o,toolsType:o.toolsType,workState:A.Start}),o}}setWorkOptions(i,e){var o;const t=(o=this.localWorkShapes.get(i))==null?void 0:o.node;t||this.createWorkShape(i,e),t==null||t.setWorkOptions(e)}createWorkShapeNode(i){const{toolsType:e}=i;if(e===v.LaserPen)return Li({...i,vNodes:this.vNodes,fullLayer:this.topLayer,drawLayer:this.topLayer})}clearAllWorkShapesCache(){this.localWorkShapes.forEach(i=>{var e;return(e=i.node)==null?void 0:e.clearTmpPoints()}),this.localWorkShapes.clear()}setToolsOpt(i){var e;this.tmpOpt=i,(e=i.toolsOpt)!=null&&e.syncUnitTime&&(this.syncUnitTime=i.toolsOpt.syncUnitTime)}getToolsOpt(){return this.tmpOpt}consumeDraw(i){const{workId:e,dataType:t}=i;if(t===V.Service)this.activeServiceWorkShape(i);else{const o=e==null?void 0:e.toString(),s=o&&this.localWorkShapes.get(o);if(!s)return;const n=s.node.consume({data:i,isFullWork:!1,isSubWorker:!0});n.rect&&(s.totalRect=he(n.rect,s.totalRect),s.result=n,s.workState=A.Doing,o&&this.localWorkShapes.set(o,s))}this.runAnimation()}consumeDrawAll(i){const{workId:e,dataType:t}=i;if(t===V.Service)this.activeServiceWorkShape(i);else{const o=e==null?void 0:e.toString(),s=o&&this.localWorkShapes.get(o);if(!s)return;const n=s.node.consumeAll({data:i});s.totalRect=he(n.rect,s.totalRect),s.result=n,s.workState=A.Done,o&&this.localWorkShapes.set(o,s)}this.runAnimation()}destroy(){this.serviceWorkShapes.clear(),this.localWorkShapes.clear()}setNodeKey(i,e,t,o){return e.toolsType=t,e.node=this.createWorkShapeNode({workId:i,toolsType:t,toolsOpt:o}),e}activeServiceWorkShape(i){var d,f;const{workId:e,opt:t,toolsType:o,type:s,updateNodeOpt:n,ops:a,op:c}=i;if(!e)return;const l=e.toString(),u=(d=this.vNodes.get(l))==null?void 0:d.rect;if(!((f=this.serviceWorkShapes)!=null&&f.has(l))){let g={toolsType:o,animationWorkData:c||[],animationIndex:0,type:s,updateNodeOpt:n,ops:a,oldRect:u};o&&t&&(g=this.setNodeKey(l,g,o,t)),this.serviceWorkShapes.set(l,g)}const h=this.serviceWorkShapes.get(l);s&&(h.type=s),a&&(h.animationWorkData=bt(a),h.ops=a),n&&(h.updateNodeOpt=n),c&&(h.animationWorkData=c),h.node&&h.node.getWorkId()!==l&&h.node.setWorkId(l),u&&(h.oldRect=u),o&&t&&(h.toolsType!==o&&o&&t&&this.setNodeKey(l,h,o,t),h.node&&h.node.setWorkOptions(t))}computNextAnimationIndex(i,e){const t=Math.floor((i.animationWorkData||[]).slice(i.animationIndex).length*32/e/this.syncUnitTime)*e;return Math.min((i.animationIndex||0)+(t||e),(i.animationWorkData||[]).length)}async animationDraw(){var n,a,c,l;this.animationId=void 0;let i=!1;const e=new Map,t=[],o=[],s=[];for(const[u,h]of this.serviceWorkShapes.entries())switch(h.toolsType){case v.LaserPen:{const f=this.computNextAnimationIndex(h,8),g=Math.max(0,h.animationIndex||0),p=(h.animationWorkData||[]).slice(g,f);if((h.animationIndex||0)<f){const y=(n=h.node)==null?void 0:n.consumeService({op:p,isFullWork:!1});h.totalRect=he(h.totalRect,y),h.animationIndex=f,p.length&&e.set(u,{workState:g===0?A.Start:f===((a=h.animationWorkData)==null?void 0:a.length)?A.Done:A.Doing,op:p.slice(-2)})}if(o.push({isClear:!0,rect:h.totalRect,clearCanvas:we.TopFloat,viewId:this.viewId}),t.push({rect:h.totalRect,drawCanvas:we.TopFloat,viewId:this.viewId}),h.isDel){(c=h.node)==null||c.clearTmpPoints(),this.serviceWorkShapes.delete(u);break}h.ops&&h.animationIndex===((l=h.animationWorkData)==null?void 0:l.length)&&!h.isDel&&(this.topLayer.getElementsByName(u.toString())[0]||(h.isDel=!0,this.serviceWorkShapes.set(u,h))),i=!0;break}}for(const[u,h]of this.localWorkShapes.entries()){const{result:d,toolsType:f,totalRect:g,isDel:p,workState:y}=h;switch(f){case v.LaserPen:{if(g&&(o.push({isClear:!0,rect:g,clearCanvas:we.TopFloat,viewId:this.viewId}),t.push({rect:g,drawCanvas:we.TopFloat,viewId:this.viewId})),p){h.node.clearTmpPoints(),this.localWorkShapes.delete(u),s.push({removeIds:[u.toString()],viewId:this.viewId,type:b.RemoveNode});break}d&&((d.op||d.ops)&&s.push(d),h.result=void 0),!this.topLayer.getElementsByName(u.toString())[0]&&y===A.Done&&(h.isDel=!0,this.localWorkShapes.set(u,h)),i=!0;break}}}i&&this.runAnimation(),e.size&&e.forEach((u,h)=>{s.push({type:b.Cursor,uid:h.split(Ze)[0],op:u.op,workState:u.workState,viewId:this.viewId})}),(t.length||o.length||s.length)&&this.post({render:[...o,...t],sp:s})}runAnimation(){this.animationId||(this.animationId=setTimeout(()=>{this.animationId=void 0,this.animationDraw()},16))}}var $i=(r=>(r.Full="full",r.Sub="sub",r))($i||{});class oy extends Tf{constructor(e,t,o){super(e,t,"sub");M(this,"type","sub");M(this,"_post");M(this,"topLayer");M(this,"snapshotFullLayer");M(this,"serviceWork");M(this,"localWork");M(this,"topLayerWork");this._post=o;const s=Me.bufferSize.sub;this.topLayer=this.createLayer("topLayer",this.scene,{...t.layerOpt,bufferSize:s,contextType:"2d"});const n={thread:this,viewId:this.viewId,vNodes:this.vNodes,fullLayer:this.fullLayer,topLayer:this.topLayer};this.localWork=new ty(n),this.topLayerWork=new iy(n),this.vNodes.init(this.fullLayer)}async combinePost(){var n,a;const{render:e,...t}=this.combinePostData();let o;if(e!=null&&e.length){const c=[];for(const l of e)if(l.rect){if(l.rect=py(Ae(l.rect),this.scene,this.dpr),!l.rect)continue;if(l.drawCanvas&&l.rect&&l.rect.w>0&&l.rect.h>0){const u=await this.getRectImageBitmap(l);l.imageBitmap=u,o||(o=[]),o.push(u)}c.push(l)}t.render=c}const s=(n=t.sp)==null?void 0:n.filter(c=>c.type!==b.None||c.isLockSentEventCursor);s!=null&&s.length?t.sp=s.map(c=>({...c,viewId:this.viewId})):delete t.sp,t.consumeCount===void 0&&delete t.consumeCount,t.subWorkerDrawCount===void 0&&delete t.subWorkerDrawCount,(s!=null&&s.length||t.consumeCount||t.subWorkerDrawCount||(a=t==null?void 0:t.render)!=null&&a.length)&&this._post(t,o),this.delayPostDoneResolve&&this.delayPostDoneResolve(!0)}getLayer(e,t){if(t&&this.snapshotFullLayer)return this.snapshotFullLayer;switch(e){case we.TopFloat:return this.topLayer;default:return this.fullLayer}}async on(e){const{msgType:t,toolsType:o,opt:s,dataType:n,workState:a,isLockSentEventCursor:c}=e;switch(t){case b.UpdateTools:if(o&&this.topLayerWork.canUseTopLayer(o)&&s){const l={toolsType:o,toolsOpt:s};this.topLayerWork.setToolsOpt(l);return}break;case b.CreateWork:this.createLocalWork(e);return;case b.DrawWork:a===A.Done&&n===V.Local?(await this.consumeDrawAll(n,e),o===v.LaserPen&&c&&this.post({sp:[{type:b.None,isLockSentEventCursor:c}]})):this.consumeDraw(n,e);return;case b.RemoveNode:await this.removeNode(e);return;case b.FullWork:o&&this.topLayerWork.canUseTopLayer(o)&&await this.consumeDrawAll(n,e);return;case b.Snapshot:this.snapshotFullLayer=this.createLayer("snapshotFullLayer",this.scene,{...this.opt.layerOpt,bufferSize:this.viewId===ge?6e3:3e3,contextType:"2d"}),this.snapshotFullLayer&&(await this.getSnapshot(e),this.snapshotFullLayer=void 0);return;case b.BoundingBox:this.snapshotFullLayer=this.createLayer("snapshotFullLayer",this.scene,{...this.opt.layerOpt,bufferSize:this.viewId===ge?6e3:3e3,contextType:"2d"}),this.snapshotFullLayer&&(await this.getBoundingRect(e),this.snapshotFullLayer=void 0);return}await super.on(e)}createLocalWork(e){const{workId:t,toolsType:o,opt:s}=e;if(o&&this.topLayerWork.canUseTopLayer(o)&&t&&s){this.topLayerWork.getToolsOpt()||this.topLayerWork.setToolsOpt({toolsType:o,toolsOpt:s}),this.topLayerWork.setWorkOptions(t.toString(),s);return}o&&this.localWork.canUseSubWorker(o)&&super.createLocalWork(e)}async removeNode(e){const{dataType:t}=e;t===V.Local&&await this.localWork.removeWork(e)}getOffscreen(e,t){return this.getLayer(e,t).parent.canvas}async consumeDraw(e,t){const{workId:o,toolsType:s}=t;if(o){if(s&&this.topLayerWork.canUseTopLayer(s)){e===V.Local&&(this.topLayerWork.getWorkShape(o.toString())||this.createLocalWork(t)),this.topLayerWork.consumeDraw(t);return}s&&this.localWork.canUseSubWorker(s)&&(this.localWork.getWorkShape(o.toString())||this.createLocalWork(t),await this.localWork.consumeDraw(t));return}}async consumeDrawAll(e,t){const{workId:o,toolsType:s,dataType:n}=t;if(o){const a=o.toString();if(s&&this.topLayerWork.canUseTopLayer(s)){n===V.Local&&(this.topLayerWork.getWorkShape(a)||this.createLocalWork(t)),this.topLayerWork.consumeDrawAll(t);return}s&&this.localWork.canUseSubWorker(s)&&(this.localWork.getWorkShape(a)||super.createLocalWork(t),this.localWork.consumeDrawAll(t));return}}async clearAll(){this.vNodes.clear(),super.clearAll(),this.topLayer&&(this.topLayer.parent.children.forEach(e=>{e.name!=="viewport"&&e.remove()}),Be(this.topLayer,this.topLayer.parent)),await this.post({render:[{isClearAll:!0,clearCanvas:we.TopFloat,viewId:this.viewId}],sp:[{type:b.Clear}]})}getRectImageBitmap(e,t=!1,o){const{rect:s,drawCanvas:n}=e,a=Math.floor(s.x*this.dpr),c=Math.floor(s.y*this.dpr),l=Math.floor(s.w*this.dpr||1),u=Math.floor(s.h*this.dpr||1);return createImageBitmap(this.getOffscreen(n,t),a,c,l,u,o)}updateLayer(e){const{width:t,height:o}=e;super.updateLayer(e),this.topLayer&&(this.topLayer.parent.setAttribute("width",t),this.topLayer.parent.setAttribute("height",o),this.topLayer.setAttribute("size",[t,o]),this.topLayer.setAttribute("pos",[t*.5,o*.5])),this.snapshotFullLayer&&(this.snapshotFullLayer.parent.setAttribute("width",t),this.snapshotFullLayer.parent.setAttribute("height",o),this.snapshotFullLayer.setAttribute("size",[t,o]),this.snapshotFullLayer.setAttribute("pos",[t*.5,o*.5]))}async updateDpr(e){super.updateDpr(e);const t=!!this.topLayerWork.localWorkShapes.size,o=!!this.localWork.getWorkShapes().size,s=[];o&&s.push({isClearAll:!0,clearCanvas:we.Float,viewId:this.viewId}),t&&s.push({isClearAll:!0,clearCanvas:we.TopFloat,viewId:this.viewId}),s.length&&await this.post({render:s})}async updateCamera(e){const t=[],{cameraOpt:o}=e;if(o&&!lt(this.cameraOpt,o)){const s=!!this.topLayerWork.localWorkShapes.size,n=!!this.localWork.getWorkShapes().size;if(n&&this.localWork.workShapesDone(),this.setCameraOpt(o),n&&t.push({isClearAll:!0,clearCanvas:we.Float,viewId:this.viewId}),s){t.push({isClearAll:!0,clearCanvas:we.TopFloat,viewId:this.viewId});for(const[a,c]of this.topLayerWork.localWorkShapes.entries())if(c.totalRect){let l;this.topLayer.getElementsByName(a.toString()).forEach(u=>{const h=u.getBoundingClientRect(),d=pt({x:h.x,y:h.y,w:h.width,h:h.height});l=he(l,d)}),c.totalRect=l,this.topLayerWork.localWorkShapes.set(a,c)}}t.length&&await this.post({render:t})}}setCameraOpt(e,t){this.cameraOpt=e;const{scale:o,centerX:s,centerY:n,width:a,height:c}=e;(a!==this.scene.width||c!==this.scene.height)&&this.updateScene({width:a,height:c}),t?(t.setAttribute("scale",[o,o]),t.setAttribute("translate",[-s,-n])):(this.fullLayer.setAttribute("scale",[o,o]),this.fullLayer.setAttribute("translate",[-s,-n]),this.topLayer.setAttribute("scale",[o,o]),this.topLayer.setAttribute("translate",[-s,-n]))}async getSnapshot(e){const{scenePath:t,scenes:o,cameraOpt:s,w:n,h:a}=e;if(t&&o&&s&&this.snapshotFullLayer){const c=Ae(this.cameraOpt);this.setCameraOpt(s,this.snapshotFullLayer),this.localWork.fullLayer=this.snapshotFullLayer,this.localWork.drawLayer=void 0;let l;for(const[h,d]of Object.entries(o))if(d!=null&&d.type)switch(d==null?void 0:d.type){case b.UpdateNode:case b.FullWork:{const{opt:f}=d,g={...d,opt:f,workId:h,msgType:b.FullWork,dataType:V.Service,viewId:this.viewId},p=await this.localWork.runFullWork(g);l=he(l,p);break}}let u;n&&a&&(u={resizeWidth:n,resizeHeight:a}),await this.getSnapshotRender({scenePath:t,curCameraOpt:c,options:u}),this.localWork.fullLayer=this.fullLayer,this.localWork.drawLayer=void 0}}async getSnapshotRender(e){var a;const{scenePath:t,curCameraOpt:o,options:s}=e;((a=this.snapshotFullLayer)==null?void 0:a.parent).render();const n=await this.getRectImageBitmap({rect:this.getSceneRect(),drawCanvas:we.None},!0,s);n&&(this._post({sp:[{type:b.Snapshot,scenePath:t,imageBitmap:n,viewId:this.viewId}]},[n]),n.close(),this.snapshotFullLayer&&Be(this.snapshotFullLayer,this.snapshotFullLayer.parent),this.setCameraOpt(o,this.fullLayer))}async getBoundingRect(e){const{scenePath:t,scenes:o,cameraOpt:s}=e;if(t&&o&&s&&this.snapshotFullLayer){const n=Ae(this.cameraOpt);this.setCameraOpt(s,this.snapshotFullLayer),this.localWork.fullLayer=this.snapshotFullLayer,this.localWork.drawLayer=void 0;let a;for(const[c,l]of Object.entries(o))if(l!=null&&l.type)switch(l==null?void 0:l.type){case b.UpdateNode:case b.FullWork:{const u=await this.localWork.runFullWork({...l,workId:c,msgType:b.FullWork,dataType:V.Service,viewId:this.viewId});a=he(a,u);break}}a&&await this.post({sp:[{type:b.BoundingBox,scenePath:t,rect:a}]}),this.localWork.fullLayer=this.fullLayer,this.localWork.drawLayer=void 0,Be(this.snapshotFullLayer,this.snapshotFullLayer.parent),this.setCameraOpt(n,this.fullLayer)}}}class qt extends U{constructor(e){super(e);M(this,"canRotate",!0);M(this,"scaleType",ce.all);M(this,"toolsType",v.Image);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");this.workOptions=e.toolsOpt,this.scaleType=qt.getScaleType(this.workOptions)}consume(){return{type:b.None}}consumeAll(){return{type:b.None}}draw(e){const{layer:t,workId:o,replaceId:s,imageBitmap:n}=e,{centerX:a,centerY:c,width:l,height:u,rotate:h,zIndex:d,eraserlines:f}=this.workOptions,g=new ue.Group({anchor:[.5,.5],pos:[a,c],name:o,size:[l,u],zIndex:d,rotate:h}),p={anchor:[.5,.5],pos:[0,0],size:[l,u],texture:n};n||(p.bgcolor="rgba(0,0,0,0.3)");const y=new ue.Sprite(p);g.append(y),f&&this.drawEraserlines({group:g,eraserlines:f,pos:[a,c],layer:t}),this.replace(t,s||o,g);const I=g.getBoundingClientRect();if(I)return{x:Math.floor(I.x-U.SafeBorderPadding),y:Math.floor(I.y-U.SafeBorderPadding),w:Math.floor(I.width+U.SafeBorderPadding*2),h:Math.floor(I.height+U.SafeBorderPadding*2)}}consumeService(){}async consumeServiceAsync(e){var u,h,d,f;const{isFullWork:t,replaceId:o,worker:s}=e,{src:n,uuid:a}=this.workOptions,c=((u=this.workId)==null?void 0:u.toString())||a,l=t?this.fullLayer:this.drawLayer||this.fullLayer;if(n){const g=await s.loadImageBitMap({toolsType:this.toolsType,opt:this.workOptions,workId:c,isSubWorker:s instanceof oy});if(g){const p=this.draw({workId:c,layer:l,replaceId:o,imageBitmap:g});return this.oldRect=c&&((d=(h=this.vNodes)==null?void 0:h.get(c))==null?void 0:d.rect)||void 0,(f=this.vNodes)==null||f.setInfo(c,{rect:p,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:p&&U.getCenterPos(p,l)}),p}}}clearTmpPoints(){this.tmpPoints.length=0}static getScaleType(e){const{uniformScale:t,rotate:o}=e;return t!==!1||o&&Math.abs(o)%90>0?ce.proportional:ce.all}static updateNodeOpt(e){const{node:t,opt:o,vNodes:s,targetNode:n}=e,{translate:a,originPoint:c,scenePoint:l,scale:u,angle:h,isLocked:d,zIndex:f,strokeColor:g}=o,p=n&&Ae(n)||s.get(t.name);if(!p)return;const y=t.parent;if(y){if(g&&(p.opt.strokeColor=g),We(f)&&(t.setAttribute("zIndex",f),p.opt.zIndex=f),zt(d)&&(p.opt.locked=d),c&&l&&u&&a){const{centerX:I,centerY:w,width:S,height:C,uniformScale:T}=p.opt,N=T!==!1?[u[0],u[0]]:u,x=[I,w],D=[I,w];mo(D,l,N,a);const L=[D[0]-x[0],D[1]-x[1]];if(p.centerPos=[p.centerPos[0]+L[0],p.centerPos[1]+L[1]],p.opt.width=Math.round(S*N[0]),p.opt.height=Math.round(C*N[1]),p.opt.centerX=D[0],p.opt.centerY=D[1],p.opt.eraserlines)for(const z of p.opt.eraserlines){const{op:j,thickness:E}=z;z.thickness=Math.round(E*Math.max(u[0],u[1]));for(let R=0;R<j.length;R++)wo(j[R],l,u,a)}}else if(a){if(p.opt.centerX=p.opt.centerX+a[0],p.opt.centerY=p.opt.centerY+a[1],p.centerPos=[p.centerPos[0]+a[0],p.centerPos[1]+a[1]],p.opt.eraserlines)for(const I of p.opt.eraserlines){const{op:w}=I;for(let S=0;S<w.length;S++){const C=w[S].map((T,N)=>N%2?T+a[1]:T+a[0]);I.op[S]=C}}}else if(We(h))if(p.opt.rotate=h,p.scaleType=qt.getScaleType(p.opt),n){const I=yn(p.rect,h);p.rect=I}else{const I=U.getRectFromLayer(y,t.name);p.rect=I||p.rect}return p&&s.setInfo(t.name,p),p==null?void 0:p.rect}}}function he(r,i){if(r&&i){const e=Math.min(r.x,i.x),t=Math.min(r.y,i.y),o=Math.max(r.x+r.w,i.x+i.w),s=Math.max(r.y+r.h,i.y+i.h),n=o-e,a=s-t;return{x:e,y:t,w:n,h:a}}return i||r}function yo(r,i){if(r&&i){const e=Math.min(r.originX,i.originX),t=Math.min(r.originY,i.originY),o=Math.max(r.originX+r.width,i.originX+i.width),s=Math.max(r.originY+r.height,i.originY+i.height),n=o-e,a=s-t;return{originX:e,originY:t,width:n,height:a}}return i||r}function me(r,i=0){const e={x:0,y:0,w:0,h:0};let t=1/0,o=1/0,s=-1/0,n=-1/0;return r.forEach(a=>{const[c,l]=a.XY;t=Math.min(t,c-i),o=Math.min(o,l-i),s=Math.max(s,c+i),n=Math.max(n,l+i)}),e.x=t,e.y=o,e.w=s-t,e.h=n-o,e}function Hi(r,i){return!(r.x+r.w<i.x||r.x>i.x+i.w||r.y+r.h<i.y||r.y>i.y+i.h)}function pt(r,i=10){return{x:Math.floor(r.x-i),y:Math.floor(r.y-i),w:Math.ceil(r.w+i*2),h:Math.ceil(r.h+i*2)}}function Kt(r,i){return{x:r.x+i[0],y:r.y+i[1],w:r.w,h:r.h}}function sy(r,i){const e=new k(r.x,r.y),t=new k(r.x+r.w,r.y),o=new k(r.x+r.w,r.y+r.h),s=new k(r.x,r.y+r.h),n=new k(r.x+r.w/2,r.y+r.h/2),a=Math.PI*i/180,c=k.RotWith(e,n,a),l=k.RotWith(t,n,a),u=k.RotWith(o,n,a),h=k.RotWith(s,n,a);return[c,l,u,h]}function yn(r,i){const e=sy(r,i);return me(e)}function mn(r,i,e){const t=new k(r.x,r.y),o=new k(r.x+r.w,r.y),s=new k(r.x+r.w,r.y+r.h),n=new k(r.x,r.y+r.h),a=new k(e[0],e[1]),c=new k(i[0],i[1]),l=k.ScaleWOrigin(t,c,a),u=k.ScaleWOrigin(o,c,a),h=k.ScaleWOrigin(s,c,a),d=k.ScaleWOrigin(n,c,a);return me([l,u,h,d])}function ny(r,i,e){const t=new k(i[0],i[1]);for(let o=0;o<r.length;o+=3){const s=new k(r[o],r[o+1]),n=Math.PI*e/180,a=k.RotWith(s,t,n);r[o]=a.x,r[o+1]=a.y}}function ry(r,i,e){const t=new k(i[0],i[1]);for(let o=0;o<r.length;o+=2){const s=new k(r[o],r[o+1]),n=Math.PI*e/180,a=k.RotWith(s,t,n);r[o]=a.x,r[o+1]=a.y}}function mo(r,i,e,t=[0,0]){const o=new k(i[0],i[1]);for(let s=0;s<r.length;s+=3){const n=new k(r[s],r[s+1]),a=new k(e[0],e[1]),c=k.ScaleWOrigin(n,a,o);r[s]=c.x+t[0],r[s+1]=c.y+t[1]}}function wo(r,i,e,t=[0,0]){const o=new k(i[0],i[1]);for(let s=0;s<r.length;s+=2){const n=new k(r[s],r[s+1]),a=new k(e[0],e[1]),c=k.ScaleWOrigin(n,a,o);r[s]=c.x+t[0],r[s+1]=c.y+t[1]}}function wn(r,i){return r[0]>=i.x&&r[0]<=i.x+i.w&&r[1]>=i.y&&r[1]<=i.y+i.h}function In(r,i){const e=r<=i?1:r/i,t=i<=r?1:i/r;return[e,t]}function ay(r){for(const i of r)if(isNaN(i)||i===1/0||i===-1/0)return!1;return!0}function cy(r){return r!==Math.floor(r)}function ly(r){const i=r.toString();return i.indexOf(".")!==-1?i.split(".")[1].length:0}function hy(r,i){for(;i!==0;)[r,i]=[i,r%i];return r}const uy=r=>{if(r.tagName==="GROUP"){const i=Object.getOwnPropertySymbols(r).find(e=>e.toString()==="Symbol(sealed)");if(i&&r[i])return!0}return!1},$e=(r,i)=>{if(r.mesh&&r.mesh.texture&&r.name==="eraserTexture"){const e=r.mesh.texture.image;i.deleteTexture(e)}else if(r.tagName==="GROUP"&&r&&r.children)for(const e of r.children)$e(e,i)},Be=(r,i)=>{$e(r,i),r.removeAllChildren()},dy=(r,i,e)=>{const t=e.parent;if(i){const o=i.children;if(o){for(const s of o)if($e(s,t),s.tagName==="GROUP")for(const n of s.children)$e(n,t)}}i.parent.replaceChild(r,i)},py=(r,i,e)=>{if(r.w+r.x<=0||r.h+r.y<=0||r.w<=0||r.h<=0)return;const t=i.width,o=i.height,s={x:Math.floor(Math.max(0,r.x)),y:Math.floor(Math.max(0,r.y)),w:Math.floor(Math.min(t,r.w)),h:Math.floor(Math.min(o,r.h))};if(s.x+s.w>t&&(s.w=Math.floor(t-s.x)),s.y+s.h>o&&(s.h=Math.floor(o-s.y)),cy(e)){const n=ly(e),a=Math.pow(10,n),c=hy(a,e*a),l=s.x%c,u=s.x-l;u>=0?(s.x=u,s.w=s.w+l):(s.x=0,s.w=s.w+l-u);const h=s.y%c,d=s.y-h;d>=0?(s.y=d,s.h=s.h+h):(s.y=0,s.h=s.h+h-d)}return s};function Lt(r){return`${yi(r.x)},${yi(r.y)} `}function At(r,i){return`${yi((r.x+i.x)/2)},${yi((r.y+i.y)/2)} `}function yi(r){return+r.toFixed(4)}const it=async(r,i,e=!1)=>{let t,o;return new Promise(function(s){if(e&&requestIdleCallback)requestIdleCallback(()=>{s(1)},{timeout:i});else{if(typeof window.requestIdleCallback=="function"){const n=typeof i=="number"&&!isNaN(i)&&i>0?i:0;o=window.requestIdleCallback(()=>{clearTimeout(t),s(1)},{timeout:n})}t=setTimeout(()=>{o&&window.cancelIdleCallback(o),s(1)},i||0)}}).then(function(){r()}).catch(function(){r()})},ht=r=>{const i=(r==null?void 0:r.webkitBackingStorePixelRatio)||(r==null?void 0:r.mozBackingStorePixelRatio)||(r==null?void 0:r.msBackingStorePixelRatio)||(r==null?void 0:r.oBackingStorePixelRatio)||(r==null?void 0:r.backingStorePixelRatio)||1;return Math.max(1,(window.devicePixelRatio||1)/i)},Io=(r,i)=>r.x+r.w<i.x||r.x>i.x+i.w||r.y+r.h<i.y||r.y>i.y+i.h?Nt.outside:r.x>=i.x&&r.y>=i.y&&r.x+r.w<=i.x+i.w&&r.y+r.h<=i.y+i.h?Nt.inside:Nt.intersect;function gy(r){let i=0;for(let e=0;e<r.length;e++){const t=r.charCodeAt(e);t>=1&&t<=126||65376<=t&&t<=65439?i++:i+=2}return i}class fy{constructor(i,e){M(this,"plugin");M(this,"uid");M(this,"control");this.control=i,this.plugin=e,this.uid=e.displayer.uid}getNamespaceData(){var i;return H.toJS((i=this.plugin)==null?void 0:i.attributes[this.namespace])||{}}getAuthSpaceData(){var i;return H.toJS((i=this.plugin)==null?void 0:i.attributes[this.authSpace])||{}}getUidFromKey(i){return i.split(Ze).length===2&&i.split(Ze)[0]||this.uid}isLocalId(i){return i.split(Ze).length===1}getLocalId(i){return i.split(Ze)[1]}isSelector(i){return this.getLocalId(i)===G}}const Xe=class Xe extends fy{constructor(e,t,o){super(e,t);M(this,"authSpace");M(this,"namespace");M(this,"serviceStorage",{});M(this,"storage",{});M(this,"authStorage",{});M(this,"stateDisposer");M(this,"authDisposer");M(this,"asyncClockState",!1);M(this,"limitNums",new Map);M(this,"syncInterval");M(this,"limitComponents",O.debounce((e,t)=>{var n,a,c,l,u,h,d,f;const o=((a=(n=this.storage)==null?void 0:n[e])==null?void 0:a[t])&&Object.keys(this.storage[e][t]).length||0;if(o===0)return;let s=this.limitNums.get(`${e}/${t}`);if(!s){const g=this.getLimitNum(o);this.limitNums.set(`${e}/${t}`,g),s=g}if(s>0&&o>=s){const g=Xe.componentsLimits.indexOf(s),p=g>=0&&g<Xe.componentsLimits.length-1;if((u=(l=(c=this.control.room)==null?void 0:c.callbacks)==null?void 0:l.listeners)!=null&&u.map.onObjectsLimit&&((d=(h=this.control.room)==null?void 0:h.callbacks)==null||d.dispatch("onObjectsLimit",I=>I(s,p))),!p){this.control.room.logger.error(`exceeds the limit of ${s} components, current: ${o}`),(f=this.control.room)==null||f.disconnect().then(()=>{var I,w,S,C,T;(S=(w=(I=this.control.room)==null?void 0:I.callbacks)==null?void 0:w.listeners)!=null&&S.map.onKickedWithReason&&((T=(C=this.control.room)==null?void 0:C.callbacks)==null||T.dispatch("onKickedWithReason",N=>N("kickByAdmin")))});return}console.warn(`exceeds the limit of ${s} components, current: ${o}`);const y=p?Xe.componentsLimits[g+1]:0;this.limitNums.set(`${e}/${t}`,y)}},2e3,{maxWait:5e3}));M(this,"clearLimitComponents",(e,t)=>{if(t)this.limitNums.delete(`${e}/${t}`);else for(const o of this.limitNums.keys())`${e}/`.indexOf(o)===0&&this.limitNums.delete(o)});this.syncInterval=o,this.namespace=Xe.namespace,this.authSpace=Xe.authSpace,this.serviceStorage=this.getNamespaceData(),this.storage=O.cloneDeep(this.serviceStorage),this.authStorage=this.getAuthSpaceData(),this.getLimitNums()}getLimitNum(e){return e>=Xe.componentsLimits[0]?Xe.componentsLimits[1]:Xe.componentsLimits[0]}getLimitNums(){for(const[e,t]of Object.entries(this.storage))if(e&&t){for(const[o,s]of Object.entries(t))if(o&&s){const n=this.getLimitNum(Object.keys(s).length);this.limitNums.set(`${e}/${o}`,n)}}}getViewIdBySecenPath(e){const t=this.getNamespaceData();for(const[o,s]of Object.entries(t))if(s){for(const n of Object.keys(s))if(n===e)return o}}getScenePathData(e){const t=this.getNamespaceData();for(const o of Object.values(t))if(o){for(const s of Object.keys(o))if(s===e)return O.cloneDeep(o[s])}}getStorageData(e,t){const o=this.getNamespaceData();return o&&o[e]&&O.cloneDeep(o[e][t])||void 0}hasSelector(e,t){const o=this.storage&&this.storage[e]&&this.storage[e][t];return!!(o&&Object.keys(o).find(s=>this.isOwn(s)&&this.getLocalId(s)===G))}hasIncludeSelector(e,t,o){for(const s of Object.keys(this.storage))if(!(t&&s!==t)){for(const n of Object.keys(this.storage[s]))if(!(o&&n!==o)){for(const a of Object.keys(this.storage[s][n]))if(this.getLocalId(a)===G){const c=this.storage[s][n][a],l=this.isLocalId(e)?this.transformKey(e):e;if(c&&c.selectIds&&c.selectIds.length&&c.selectIds.includes(l))return!0}}}return!1}addStorageStateListener(e){this.stateDisposer=H.autorun(async()=>{var c,l,u,h,d,f;const t=this.getNamespaceData(),{diffView:o,diffScenePath:s,diffData:n}=this.diffFunByView(this.serviceStorage,t);this.serviceStorage=t;const a={};if(Object.keys(o).length>0)for(const[g,p]of Object.entries(o))p&&!O.isEqual((c=this.storage)==null?void 0:c[g],p.newValue)&&(a.diffView||(a.diffView={}),a.diffView[g]=p,this.storage||(this.storage={}),p.newValue===void 0?delete this.storage[g]:this.storage[g]=O.cloneDeep(p.newValue));if(Object.keys(s).length>0){for(const[g,p]of Object.entries(s))if(p){const{viewId:y,newValue:I}=p;p&&!O.isEqual((u=(l=this.storage)==null?void 0:l[y])==null?void 0:u[g],I)&&(a.diffScenePath||(a.diffScenePath={}),a.diffScenePath[g]=p,this.storage||(this.storage={}),this.storage[y]||(this.storage[y]={}),p.newValue===void 0?delete this.storage[y][g]:this.storage[y][g]=O.cloneDeep(p.newValue))}}if(Object.keys(n).length>0){for(const[g,p]of Object.entries(n))if(p){const{viewId:y,scenePath:I,newValue:w}=p;p&&!O.isEqual((f=(d=(h=this.storage)==null?void 0:h[y])==null?void 0:d[I])==null?void 0:f[g],w)&&(a.diffData||(a.diffData={}),a.diffData[g]=p,this.storage||(this.storage={}),this.storage[y]||(this.storage[y]={}),this.storage[y][I]||(this.storage[y][I]={}),p.newValue===void 0?delete this.storage[y][I][g]:this.storage[y][I][g]=O.cloneDeep(p.newValue))}}Object.keys(a).length>0&&e(a)})}removeStorageStateListener(){this.stateDisposer&&this.stateDisposer()}diffFunByView(e,t){const o=Ee(e),s=Ee(t),n={},a={},c={};for(const l of s)if(!o.includes(l)||e[l]===void 0){n[l]={newValue:t[l],oldValue:void 0};continue}for(const l of o){if(O.isEqual(e[l],t[l]))continue;if(!s.includes(l)||t[l]===void 0){n[l]={newValue:void 0,oldValue:e[l]};continue}const u=this.diffFunByScenePath(e[l],t[l],l);Object.assign(a,u.diffScenePath),Object.assign(c,u.diffData)}return{diffData:c,diffScenePath:a,diffView:n}}diffFunByScenePath(e,t,o){const s=Ee(e),n=Ee(t),a={},c={};for(const l of n)if(!s.includes(l)||e[l]===void 0){a[l]={newValue:t[l],oldValue:void 0,viewId:o};continue}for(const l of s){if(O.isEqual(e[l],t[l]))continue;if(!n.includes(l)||t[l]===void 0){a[l]={newValue:void 0,oldValue:e[l],viewId:o};continue}const u=this.diffFunByKeys(e[l],t[l],l,o);Object.assign(c,u)}return{diffScenePath:a,diffData:c}}diffFunByKeys(e,t,o,s){const n=Ee(e),a=Ee(t),c={};for(const l of a)(!n.includes(l)||e[l]===void 0)&&(c[l]={oldValue:void 0,newValue:t[l],viewId:s,scenePath:o});for(const l of n)if(!O.isEqual(e[l],t[l])){if(!a.includes(l)||t[l]===void 0){c[l]={newValue:void 0,oldValue:e[l],viewId:s,scenePath:o};continue}a.includes(l)&&(c[l]={oldValue:e[l],newValue:t[l],viewId:s,scenePath:o})}return c}transformKey(e){return this.uid+Ze+e}isOwn(e){return e.split(Ze)[0]===this.uid}dispatch(e){const{type:t,workId:o,ops:s,index:n,opt:a,toolsType:c,removeIds:l,updateNodeOpt:u,op:h,selectIds:d,isSync:f,scenePath:g,viewId:p}=e;if(p)switch(t){case b.Clear:const y={};g&&this.storage[p]&&this.storage[p][g]?(delete this.storage[p][g],this.setState(y,{isSync:f,viewId:p,scenePath:g})):this.storage[p]&&(delete this.storage[p],this.setState(y,{isSync:f,viewId:p,scenePath:""})),it(()=>{var T;this.control.pluginManager.dispatchPluginEvent("syncStorage",p,g),(T=this.control.miniMapManager)==null||T.updateMiniMapCamera(p),this.clearLimitComponents(p,g)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback"));break;case b.CreateWork:if(g&&o&&c&&a){const T=this.isLocalId(o.toString())?this.transformKey(o):o;this.control.renderControl.isUsePageAuth(p)&&this.control.renderControl.addRenderPageElementId({viewId:p,scenePath:g,elementId:T.toString()}),this.updateValue(T.toString(),{type:b.CreateWork,workId:o,toolsType:c,opt:a},{isSync:f,viewId:p,scenePath:g})}break;case b.DrawWork:if(g&&o&&typeof n=="number"&&(h!=null&&h.length)){const T=this.isLocalId(o.toString())?this.transformKey(o):o,N=this.storage[p]&&this.storage[p][g]&&this.storage[p][g][T]||void 0;if(N!=null&&N.ops||(N==null?void 0:N.type)===b.FullWork)return;const x=n?((N==null?void 0:N.op)||[]).slice(0,n).concat(h):h||(N==null?void 0:N.op),D=c||(N==null?void 0:N.toolsType),L=a||(N==null?void 0:N.opt),z=u||(N==null?void 0:N.updateNodeOpt);o&&D&&L&&x&&(this.control.renderControl.isUsePageAuth(p)&&this.control.renderControl.addRenderPageElementId({viewId:p,scenePath:g,elementId:T.toString()}),this.updateValue(T.toString(),{...N,type:b.DrawWork,workId:o,updateNodeOpt:z,toolsType:D,opt:L,op:x,index:n},{isSync:f,viewId:p,scenePath:g}))}break;case b.FullWork:if(g&&o){const T=this.isLocalId(o.toString())?this.transformKey(o):o,N=this.storage[p]&&this.storage[p][g]&&this.storage[p][g][T]||void 0,x=u||(N==null?void 0:N.updateNodeOpt),D=c||(N==null?void 0:N.toolsType),L=a||(N==null?void 0:N.opt),z=s||(N==null?void 0:N.ops);D&&L&&(this.control.renderControl.isUsePageAuth(p)&&this.control.renderControl.addRenderPageElementId({viewId:p,scenePath:g,elementId:T.toString()}),this.updateValue(T.toString(),{type:b.FullWork,updateNodeOpt:x,workId:T,toolsType:D,opt:L,ops:z},{isSync:f,viewId:p,scenePath:g}),it(()=>{var j;this.control.pluginManager.dispatchPluginEvent("syncStorage",p,g),(j=this.control.miniMapManager)==null||j.updateMiniMapCamera(p),this.limitComponents(p,g)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}break;case b.RemoveNode:if(g&&(l!=null&&l.length)){const T=l.map(N=>this.isLocalId(N+"")?this.transformKey(N):N);this.storage[p]&&this.storage[p][g]&&(Object.keys(this.storage[p][g]).map(N=>{T!=null&&T.includes(N)&&(this.control.renderControl.isUsePageAuth(p)&&this.control.renderControl.delRenderPageElementId({viewId:p,scenePath:g,elementId:N}),this.updateValue(N,void 0,{isSync:f,viewId:p,scenePath:g}))}),it(()=>{var N;this.control.pluginManager.dispatchPluginEvent("syncStorage",p,g),(N=this.control.miniMapManager)==null||N.updateMiniMapCamera(p)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}break;case b.UpdateNode:if(g&&o&&(u||s||a)){const T=this.isLocalId(o.toString())?this.transformKey(o):o,N=this.storage[p]&&this.storage[p][g]&&this.storage[p][g][T]||void 0;N&&(N.updateNodeOpt=u,(s||h)&&(N.ops=s,N.op=h),a&&(N.opt=a),N.type=b.FullWork,this.updateValue(T.toString(),N,{isSync:f,viewId:p,scenePath:g}),it(()=>{var x;(x=this.control.miniMapManager)==null||x.updateMiniMapCamera(p)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}break;case b.Select:if(!g)return;let I;d!=null&&d.length&&(I=d.map(T=>this.isLocalId(T+"")?this.transformKey(T):T));const w=this.transformKey(G),S=this.storage[p]&&this.storage[p][g]&&this.storage[p][g][w]||void 0,C=a||(S==null?void 0:S.opt);I&&this.checkOtherSelector(w,I,{isSync:f,viewId:p,scenePath:g}),this.updateValue(w,I&&{type:b.Select,toolsType:v.Selector,opt:C,selectIds:I},{isSync:f,viewId:p,scenePath:g});break}}checkOtherSelector(e,t,o){const{viewId:s,scenePath:n}=o;for(const a of Object.keys(this.storage[s][n]))if(a!==e&&this.getLocalId(a)===G){const c=this.storage[s][n][a];if(c&&c.selectIds){const l=c.selectIds.filter(u=>!t.includes(u));l.length>0&&(c.selectIds=l),this.updateValue(a,l.length&&c||void 0,o)}}}setState(e,t){const{viewId:o,scenePath:s}=t,n=Ee(e);for(let a=0;a<n.length;a++){const c=n[a],l=e[c];typeof l<"u"?(this.storage[o]||(this.storage[o]={}),this.storage[o][s]||(this.storage[o][s]={}),this.storage[o][s][c]=l):delete this.storage[o][s][c]}this.runSyncService(t)}updateValue(e,t,o){const{viewId:s,scenePath:n,storage:a}=o,c=a||this.storage;t===void 0?delete c[s][n][e]:(c[s]||(c[s]={}),c[s][n]||(c[s][n]={}),c[s][n][e]=t),this.runSyncService(o)}runSyncService(e){if(!this.control.renderControl.isWritable){console.warn("The current state is not writable and synchronization cannot be synchronized");return}this.asyncClockState||(this.asyncClockState=!0,e.isSync?(this.asyncClockState=!1,this.syncSerivice(e)):it(()=>{this.asyncClockState=!1,this.syncSerivice(e)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}syncSerivice(e={storage:this.storage}){const{storage:t}=e,o=t||this.storage,s=Ee(this.serviceStorage),n=Ee(o),a=new Map;for(const c of s){if(!n.includes(c)){a.set(c,void 0);continue}O.isEqual(this.serviceStorage[c],o[c])||this.syncViewData(o,c)}for(const c of n)s.includes(c)||a.set(c,o[c]);if(a.size>5)this.syncStorageView(o);else for(const[c,l]of a.entries())this.syncUpdataView(o,c,l)}syncViewData(e,t){const o=Ee(this.serviceStorage[t]),s=Ee(e[t]),n=new Map;for(const a of o){if(!s.includes(a)){n.set(a,void 0);continue}O.isEqual(this.serviceStorage[t][a],e[t][a])||this.syncScenePathData(e,t,a)}for(const a of s)o.includes(a)||n.set(a,e[t][a]);if(n.size>5)this.syncStorageScenePath(t,e[t]);else for(const[a,c]of n.entries())this.syncUpdataScenePath(e,t,a,c)}syncScenePathData(e,t,o){const s=Ee(this.serviceStorage[t][o]),n=Ee(e[t][o]),a=new Map;for(const c of s){if(!n.includes(c)){a.set(c,void 0);continue}O.isEqual(this.serviceStorage[t][o][c],e[t][o][c])||a.set(c,e[t][o][c])}for(const c of n)s.includes(c)||a.set(c,e[t][o][c]);if(a.size>5)this.syncStorageKey(t,o,e[t][o]);else for(const[c,l]of a.entries())this.syncUpdataKey(e,t,o,c,l)}syncUpdataView(e,t,o){var n;Object.keys(this.serviceStorage).length?(n=this.plugin)==null||n.updateAttributes([this.namespace,t],o):this.syncStorageView(e)}syncStorageView(e){var t;(t=this.plugin)==null||t.updateAttributes([this.namespace],e)}syncUpdataScenePath(e,t,o,s){var a;Object.keys(this.serviceStorage[t]).length?(a=this.plugin)==null||a.updateAttributes([this.namespace,t,o],s):this.syncStorageScenePath(t,e[t])}syncStorageScenePath(e,t){var o;(o=this.plugin)==null||o.updateAttributes([this.namespace,e],t)}syncUpdataKey(e,t,o,s,n){var c;Object.keys(this.serviceStorage[t][o]).length?(c=this.plugin)==null||c.updateAttributes([this.namespace,t,o,s],n):this.syncStorageKey(t,o,e[t][o])}syncStorageKey(e,t,o){var s;(s=this.plugin)==null||s.updateAttributes([this.namespace,e,t],o)}keyTransformWorkId(e){const t=e.split(Ze);return t.length===2?t[1]:e}destroy(){this.removeStorageStateListener(),this.serviceStorage={},this.storage={},this.removeAuthStateListener(),this.authStorage={}}dispatchPageAuth(e,t=!0){var l,u,h,d,f,g,p,y,I,w,S,C,T,N,x,D,L,z,j,E,R,P,Z,_,B,J,ie,le,oe,K,q,de,Ue,De,ze,Fe,He,ee;const{operation:o,viewId:s,scenePath:n,pageId:a,pageData:c}=e;switch(o){case Re.addPage:{if(!s||!n||!a)return;const $=[this.authSpace];Object.keys(this.authStorage).length&&$.push("pageAuth");const X=this.authStorage.pageAuth||{};this.authStorage.pageAuth=X,Object.keys(X).length&&$.push(s),X[s]=X[s]||{},Object.keys(X[s]).length&&$.push(n),X[s][n]=X[s][n]||{render:(c==null?void 0:c.render)||"localSelf",pages:{}},Object.keys(X[s][n].pages).length&&$.push("pages",a);const te={};if(c!=null&&c.elementIds)for(const pe of c.elementIds.keys())te[pe]=!0;X[s][n].pages[a]=te,t&&($.length===1?(l=this.plugin)==null||l.updateAttributes($,O.cloneDeep(this.authStorage)):$.length===2?(u=this.plugin)==null||u.updateAttributes($,O.cloneDeep(X)):$.length===3?(h=this.plugin)==null||h.updateAttributes($,O.cloneDeep(X[s])):$.length===4?(d=this.plugin)==null||d.updateAttributes($,O.cloneDeep(X[s][n])):(f=this.plugin)==null||f.updateAttributes($,O.cloneDeep(te)));return}case Re.renderPage:{if(!s||!n||!(c!=null&&c.render))return;this.authStorage.pageAuth&&this.authStorage.pageAuth[s]&&this.authStorage.pageAuth[s][n]&&c.render!==this.authStorage.pageAuth[s][n].render&&(this.authStorage.pageAuth[s][n].render=c.render,t&&((g=this.plugin)==null||g.updateAttributes([this.authSpace,"pageAuth",s,n,"render"],c.render)));return}case Re.deletePage:{if(!s||!n||!a)return;(S=(w=(I=(y=(p=this.authStorage)==null?void 0:p.pageAuth)==null?void 0:y[s])==null?void 0:I[n])==null?void 0:w.pages)!=null&&S[a]&&(delete this.authStorage.pageAuth[s][n].pages[a],t&&((C=this.plugin)==null||C.updateAttributes([this.authSpace,"pageAuth",s,n,"pages",a],void 0)));return}case Re.clearPage:{if(!s||!n||!a)return;(L=(D=(x=(N=(T=this.authStorage)==null?void 0:T.pageAuth)==null?void 0:N[s])==null?void 0:x[n])==null?void 0:D.pages)!=null&&L[a]&&(delete this.authStorage.pageAuth[s][n].pages[a],t&&((z=this.plugin)==null||z.updateAttributes([this.authSpace,"pageAuth",s,n,"pages",a],{})));return}case Re.addElement:{if(!s||!n||!a||!(c!=null&&c.elementId))return;(Z=(P=(R=(E=(j=this.authStorage)==null?void 0:j.pageAuth)==null?void 0:E[s])==null?void 0:R[n])==null?void 0:P.pages)!=null&&Z[a]&&(this.authStorage.pageAuth[s][n].pages[a][c.elementId]=!0,t&&((_=this.plugin)==null||_.updateAttributes([this.authSpace,"pageAuth",s,n,"pages",a,c.elementId],!0)));return}case Re.deleteElement:{if(!s||!n||!a||!(c!=null&&c.elementId))return;(K=(oe=(le=(ie=(J=(B=this.authStorage)==null?void 0:B.pageAuth)==null?void 0:J[s])==null?void 0:ie[n])==null?void 0:le.pages)==null?void 0:oe[a])!=null&&K[c.elementId]&&(delete this.authStorage.pageAuth[s][n].pages[a][c.elementId],t&&((q=this.plugin)==null||q.updateAttributes([this.authSpace,"pageAuth",s,n,"pages",a,c.elementId],void 0)));return}case Re.clearViewScenePath:{if(!s||!n)return;(De=(Ue=(de=this.authStorage)==null?void 0:de.pageAuth)==null?void 0:Ue[s])!=null&&De[n]&&(delete this.authStorage.pageAuth[s][n],t&&((ze=this.plugin)==null||ze.updateAttributes([this.authSpace,"pageAuth",s,n],void 0)));return}case Re.clearView:{if(!s)return;(He=(Fe=this.authStorage)==null?void 0:Fe.pageAuth)!=null&&He[s]&&(delete this.authStorage.pageAuth[s],t&&((ee=this.plugin)==null||ee.updateAttributes([this.authSpace,"pageAuth",s],void 0)));return}}}dispatchRenderAuth(e,t=!0){var l,u,h,d,f,g,p,y,I,w,S,C,T,N,x,D,L,z,j,E;const{operation:o,viewId:s,uid:n,renderData:a,isClear:c}=e;if(s)switch(o){case tt.setAuth:{if(!a||a.render===void 0&&a.hide===void 0&&a.clear===void 0){this.authStorage.renderAuth&&this.authStorage.renderAuth[s]&&(delete this.authStorage.renderAuth[s],t&&((l=this.plugin)==null||l.updateAttributes([this.authSpace,"renderAuth",s],void 0)));return}const R=[this.authSpace];Object.keys(this.authStorage).length&&R.push("renderAuth");const P=this.authStorage.renderAuth||{};Object.keys(P).length&&R.push(s),P[s]={},this.authStorage.renderAuth=P;const{render:Z,hide:_,clear:B}=a;if(Z===!0)P[s].render=!0;else if(O.isSet(Z)){P[s].render={};for(const J of Z.keys())P[s].render[J]=!0}if(_===!0)P[s].hide=!0;else if(O.isSet(_)){P[s].hide={};for(const J of _.keys())P[s].hide[J]=!0}if(B===!0)P[s].clear=!0;else if(O.isSet(B)){P[s].clear={};for(const J of B.keys())P[s].clear[J]=!0}t&&(R.length===1?(u=this.plugin)==null||u.updateAttributes(R,O.cloneDeep(this.authStorage)):R.length===2?(h=this.plugin)==null||h.updateAttributes(R,O.cloneDeep(P)):(d=this.plugin)==null||d.updateAttributes(R,O.cloneDeep(P[s])));return}case tt.setShow:{if(!n)return;const R=[this.authSpace];Object.keys(this.authStorage).length&&R.push("renderAuth");const P=this.authStorage.renderAuth||{};Object.keys(P).length&&R.push(s),P[s]=P[s]||{},this.authStorage.renderAuth=P,Object.keys(P[s]).length&&R.push("render"),P[s].render=P[s].render||{},P[s].render!==!0&&(Object.keys(P[s].render).length&&R.push(n),P[s].render[n]=!0),P[s].hide!==!0&&((f=P[s].hide)!=null&&f[n])&&(delete P[s].hide[n],t&&((g=this.plugin)==null||g.updateAttributes([this.authSpace,"renderAuth",s,"hide",n],void 0))),t&&(R.length===1?(p=this.plugin)==null||p.updateAttributes(R,O.cloneDeep(this.authStorage)):R.length===2?(y=this.plugin)==null||y.updateAttributes(R,O.cloneDeep(P)):R.length===3?(I=this.plugin)==null||I.updateAttributes(R,O.cloneDeep(P[s])):(w=this.plugin)==null||w.updateAttributes(R,!0));return}case tt.setHide:{if(!n)return;const R=[this.authSpace];Object.keys(this.authStorage).length&&R.push("renderAuth");const P=this.authStorage.renderAuth||{};Object.keys(P).length&&R.push(s),P[s]=P[s]||{},this.authStorage.renderAuth=P,Object.keys(P[s]).length&&R.push("hide"),P[s].hide=P[s].hide||{},P[s].hide!==!0&&(Object.keys(P[s].hide).length&&R.push(n),P[s].hide[n]=!0),P[s].render!==!0&&((S=P[s].render)!=null&&S[n])&&(delete P[s].render[n],t&&((C=this.plugin)==null||C.updateAttributes([this.authSpace,"renderAuth",s,"render",n],void 0))),t&&(R.length===1?(T=this.plugin)==null||T.updateAttributes(R,O.cloneDeep(this.authStorage)):R.length===2?(N=this.plugin)==null||N.updateAttributes(R,O.cloneDeep(P)):R.length===3?(x=this.plugin)==null||x.updateAttributes(R,O.cloneDeep(P[s])):(D=this.plugin)==null||D.updateAttributes(R,!0));return}case tt.setClear:{if(!n)return;const R=[this.authSpace];Object.keys(this.authStorage).length&&R.push("renderAuth");const P=this.authStorage.renderAuth||{};Object.keys(P).length&&R.push(s),P[s]=P[s]||{},this.authStorage.renderAuth=P,Object.keys(P[s]).length&&R.push("clear"),P[s].clear=P[s].clear||{},P[s].clear!==!0&&(Object.keys(P[s].clear).length&&R.push(n),c?P[s].clear[n]=!0:delete P[s].clear[n]),t&&(R.length===1?(L=this.plugin)==null||L.updateAttributes(R,O.cloneDeep(this.authStorage)):R.length===2?(z=this.plugin)==null||z.updateAttributes(R,O.cloneDeep(P)):R.length===3?(j=this.plugin)==null||j.updateAttributes(R,O.cloneDeep(P[s])):(E=this.plugin)==null||E.updateAttributes(R,c?!0:void 0));return}}}addAuthStateListener(e){this.authDisposer=H.autorun(async()=>{const t=this.getAuthSpaceData(),{renderAuth:o,pageAuth:s}=t;let n,a;O.isEqual(o,this.authStorage.renderAuth)||(n=this.diffAuthFun(this.authStorage.renderAuth||{},o||{}),this.authStorage.renderAuth=o),O.isEqual(s,this.authStorage.pageAuth)||(a=this.diffAuthPageFun(this.authStorage.pageAuth||{},s||{}),this.authStorage.pageAuth=s),(n||a)&&e(n,a)})}removeAuthStateListener(){this.authDisposer&&this.authDisposer()}diffAuthFun(e,t){const o=Ee(e),s=Ee(t),n={};for(const a of s)if(!o.includes(a)||e[a]===void 0){n[a]={newValue:t[a],oldValue:void 0};continue}for(const a of o)if(!O.isEqual(e[a],t[a])){if(!s.includes(a)||t[a]===void 0){n[a]={newValue:void 0,oldValue:e[a]};continue}n[a]={newValue:t[a],oldValue:e[a]}}return n}diffAuthPageFun(e,t){const o=Ee(e),s=Ee(t),n={};for(const a of s)if(!o.includes(a)||e[a]===void 0){n[a]={newValue:t[a],oldValue:void 0};continue}for(const a of o)if(!O.isEqual(e[a],t[a])){if(!s.includes(a)||t[a]===void 0){n[a]={newValue:void 0,oldValue:e[a]};continue}n[a]={newValue:t[a],oldValue:e[a]}}return n}};M(Xe,"namespace","PluginState"),M(Xe,"authSpace","PluginAuth"),M(Xe,"componentsLimits",[500,1e3]);let Gi=Xe;class My{constructor(){M(this,"roomMembers",[]);M(this,"onChangeHooks",new Set)}setRoomMembers(i){this.executChangeUidHook(this.roomMembers,i),this.roomMembers=i}executChangeUidHook(i,e){const t={online:e.map(o=>{var s;return((s=o.payload)==null?void 0:s.uid)||o.session}),offline:i.map(o=>{var s;return((s=o.payload)==null?void 0:s.uid)||o.session})};this.onChangeHooks.forEach(o=>o(t))}getAllRoomMembers(){return this.roomMembers}getRoomMember(i){return this.roomMembers.find(e=>{var t;return((t=e.payload)==null?void 0:t.uid)===i})}isOnLine(i){return!!this.getRoomMember(i)}onUidChangeHook(i){this.onChangeHooks.add(i)}destroy(){this.onChangeHooks.clear()}}var ot=(r=>(r[r.Text=1]="Text",r[r.Shape=2]="Shape",r))(ot||{});const Qe=class Qe{createProxy(i){const e=new Proxy(i,{get(t,o,s){const n=Qe.interceptors.hasOwnProperty(o)?Qe.interceptors:t;return Reflect.get(n,o,s)}});return Qe.proxyToRaw.set(e,i),e}};M(Qe,"proxyToRaw",new WeakMap),M(Qe,"interceptors",{entries(...i){return Qe.proxyToRaw.get(this).entries(...i)},forEach(...i){return Qe.proxyToRaw.get(this).forEach(...i)},size(){return Qe.proxyToRaw.get(this).size},get(i){return Qe.proxyToRaw.get(this).get(i)},set(i,e){return Qe.proxyToRaw.get(this).set(i,e)},delete(i){return Qe.proxyToRaw.get(this).delete(i)},clear(){return Qe.proxyToRaw.get(this).clear()}});let It=Qe;class yy{constructor(i){M(this,"internalMsgEmitter");M(this,"publicMsgEmitter");M(this,"control");M(this,"editors");M(this,"activeId");M(this,"proxyMap");M(this,"taskqueue",new Map);const{control:e,internalMsgEmitter:t,publicMsgEmitter:o}=i;this.control=e,this.internalMsgEmitter=t,this.publicMsgEmitter=o;const s=new Map;this.proxyMap=new It;const n=this,a=It.interceptors.set;It.interceptors.set=function(l,u){return n.interceptors.set(l,u),a.call(this,l,u)};const c=It.interceptors.delete;It.interceptors.delete=function(l){return n.interceptors.delete(l),c.call(this,l)},this.editors=this.proxyMap.createProxy(s)}get collector(){return this.control.collector}filterEditor(i){const e=new Map;return this.editors.forEach((t,o)=>{t.viewId===i&&e.set(o,t)}),e}get interceptors(){return{set:(i,e)=>{var g,p,y,I,w,S,C,T;if(!this.collector)return!0;const{viewId:t,scenePath:o,canSync:s,canWorker:n,type:a,opt:c,dataType:l,updateNodeOpt:u}=e;if(!n&&!s)return!0;const d=((g=this.collector)==null?void 0:g.isLocalId(i))?(p=this.collector)==null?void 0:p.transformKey(i):i,f=((y=this.collector)==null?void 0:y.storage[t])&&this.collector.storage[t][o]&&this.collector.storage[t][o][d]||void 0;f?f.toolsType===v.Text&&(n&&(this.control.worker.queryTaskBatchData({workId:i,msgType:b.UpdateNode}).forEach(N=>{var x;(x=this.control.worker)==null||x.taskBatchData.delete(N)}),(C=this.control.worker)==null||C.taskBatchData.add({workId:i,msgType:b.UpdateNode,dataType:l||V.Local,toolsType:v.Text,opt:c,viewId:t,scenePath:o,willRefresh:!0}),(T=this.control.worker)==null||T.runAnimation()),s&&(it(()=>{var N;(N=this.collector)==null||N.dispatch({type:b.UpdateNode,workId:i,toolsType:v.Text,opt:c,viewId:t,scenePath:o,updateNodeOpt:u})},this.control.worker.maxLastSyncTime,this.control.hasPolyfillMethod("requestIdleCallback")),c.workState===A.Done&&this.control.runEffectWork(()=>{this.control.worker.setShapeSelectorByWorkId(i,t)}))):a===ot.Text&&(s&&((I=this.collector)==null||I.dispatch({type:c.text&&b.FullWork||b.CreateWork,workId:i,toolsType:v.Text,opt:c,isSync:!0,viewId:t,scenePath:o,updateNodeOpt:u})),n&&((w=this.control.worker)==null||w.taskBatchData.add({workId:i,msgType:c.text&&b.FullWork||b.CreateWork,dataType:l||V.Local,toolsType:v.Text,opt:c,viewId:t,scenePath:o,willRefresh:!0}),(S=this.control.worker)==null||S.runAnimation()))},delete:i=>{var a,c;if(!this.collector)return!0;const e=this.editors.get(i);if(!e)return!0;const{viewId:t,scenePath:o,canSync:s,canWorker:n}=e;if(!n&&!s)return!0;n&&((a=this.control.worker)==null||a.taskBatchData.add({workId:i,toolsType:v.Text,msgType:b.RemoveNode,dataType:V.Local,viewId:t,scenePath:o,willRefresh:!0}),(c=this.control.worker)==null||c.runAnimation()),s&&it(()=>{var l;(l=this.collector)==null||l.dispatch({type:b.RemoveNode,removeIds:[i],toolsType:v.Text,viewId:t,scenePath:o})},this.control.worker.maxLastSyncTime,this.control.hasPolyfillMethod("requestIdleCallback"))},clear(){return!0}}}computeTextActive(i,e){var s,n,a,c;const t=(s=this.control.viewContainerManager)==null?void 0:s.transformToScenePoint(i,e),o=(n=this.control.viewContainerManager)==null?void 0:n.getCurScenePath(e);e&&o&&((a=this.control.worker)==null||a.taskBatchData.add({msgType:b.GetTextActive,dataType:V.Local,op:t,viewId:e,scenePath:o}),(c=this.control.worker)==null||c.runAnimation())}checkEmptyTextBlur(){var e;let i=this.activeId;for(const[t,o]of this.editors.entries())if(o.opt.uid&&o.opt.uid===((e=this.collector)==null?void 0:e.uid)){i=t;break}if(i){const t=this.editors.get(i);(t==null?void 0:t.opt.text)&&(t==null?void 0:t.opt.text.replace(/\s*,/g,""))?this.unActive(i):this.delete(i,!0,!0)}}onCameraChange(i,e){var t,o;for(const[s,n]of this.editors.entries())if(n.viewId===e){const{boxPoint:a,boxSize:c}=n.opt,l=a&&((t=this.control.viewContainerManager)==null?void 0:t.transformToOriginPoint(a,n.viewId)),u=(o=this.control.viewContainerManager)==null?void 0:o.getCurScenePath(e);if(u&&e){const h={x:l&&l[0]||0,y:l&&l[1]||0,w:c&&c[0]||0,h:c&&c[1]||0,opt:n.opt,scale:i.scale,type:ot.Text,viewId:e,scenePath:u,canWorker:!1,canSync:!1};this.editors.set(s,h),this.control.viewContainerManager.updateTextEditorInfo(e,this.activeId)}}}onServiceDerive(i){var p,y,I;const{workId:e,opt:t,msgType:o,viewId:s,scenePath:n,dataType:a,updateNodeOpt:c}=i;if(!e||!s||!n)return;const l=e.toString();if(o===b.RemoveNode){this.delete(l,!0,!0);return}const{boxPoint:u,boxSize:h}=t,d=u&&((p=this.control.viewContainerManager)==null?void 0:p.transformToOriginPoint(u,s)),f=this.control.viewContainerManager.getView(s),g={x:d&&d[0]||0,y:d&&d[1]||0,w:h&&h[0]||0,h:h&&h[1]||0,opt:t,type:ot.Text,canWorker:!0,canSync:!1,dataType:a,scale:((y=f==null?void 0:f.cameraOpt)==null?void 0:y.scale)||1,viewId:s,scenePath:n};if(t&&t.workState===A.Done&&!this.control.cursor.isEnableCursor&&u&&h){let S=c==null?void 0:c.uid;if(!S){const C=this.editors.get(l);S=C&&((I=C.opt)==null?void 0:I.uid)}S&&this.control.cursor.collectServiceCursor({op:u&&[u[0]+h[0],u[1]+h[1]],uid:S,workState:A.Done,viewId:s,type:b.Cursor})}this.editors.set(l,g),a===V.Service&&t.workState===A.Done&&this.activeId===l&&(this.activeId=void 0),this.control.viewContainerManager.updateTextEditorInfo(s,this.activeId)}updateForViewEdited(i,e){var o;this.editors.set(i,e);const t=(o=this.taskqueue.get(i))==null?void 0:o.resolve;t&&t(e)}active(i){var t;const e=this.editors.get(i);e&&e.viewId&&(e.opt.workState=A.Start,e.opt.uid=(t=this.collector)==null?void 0:t.uid,this.activeId=i,e.canWorker=!0,e.canSync=!0,this.editors.set(i,e),this.control.viewContainerManager.updateTextEditorInfo(e.viewId,this.activeId))}unActive(i){const e=this.editors.get(i);e&&e.viewId&&(e.opt.workState=A.Done,e.opt.uid=void 0,e.canWorker=!0,e.canSync=!0,this.editors.set(i,e),this.activeId=void 0,this.control.viewContainerManager.updateTextEditorInfo(e.viewId,this.activeId))}createTextForMasterController(i,e){var n;const{workId:t,isActive:o,...s}=i;e&&this.internalMsgEmitter.emit("addUndoTicker",e,s.viewId),s.opt.uid=(n=this.collector)==null?void 0:n.uid,o&&(this.activeId=t),s.dataType=V.Local,s.canWorker=!0,s.canSync=!0,this.editors.set(t,s),this.control.viewContainerManager.updateTextEditorInfo(s.viewId,this.activeId)}updateTextForMasterController(i,e){var n;const{workId:t,...o}=i;e&&this.internalMsgEmitter.emit("addUndoTicker",e,o.viewId);const s=this.editors.get(t)||{};o.opt&&(o.opt.uid=(n=this.collector)==null?void 0:n.uid),o.dataType=V.Local,this.editors.set(t,{...s,...o}),this.control.viewContainerManager.updateTextEditorInfo(o.viewId,this.activeId)}async updateTextControllerWithEffectAsync(i,e){var u;const{workId:t,...o}=i;e&&this.internalMsgEmitter.emit("addUndoTicker",e,o.viewId);const s=this.editors.get(t)||{};o.opt&&(o.opt.uid=(u=this.collector)==null?void 0:u.uid),o.dataType=V.Local;const n={...s,...o};if(this.editors.set(t,n),this.control.viewContainerManager.updateTextEditorInfo(o.viewId,this.activeId),this.taskqueue.has(t)){const h=this.taskqueue.get(t);return h&&(h.clocker&&clearTimeout(h.clocker),this.taskqueue.delete(t)),await this.updateTextControllerWithEffectAsync(i)}const a=setTimeout(()=>{var d;const h=(d=this.taskqueue.get(t))==null?void 0:d.resolve;h&&h(n)},50),c=await new Promise(h=>{this.taskqueue.set(t,{resolve:h,clocker:a})}),l=this.taskqueue.get(t);return l&&(l.clocker&&clearTimeout(l.clocker),this.taskqueue.delete(t)),c}updateTextForWorker(i,e){const{workId:t,isActive:o,...s}=i,a={...this.editors.get(t)||{},...s};if(o){a.canWorker=!1,a.canSync=!1,this.editors.set(t,a),this.active(t);return}this.editors.set(t,a),this.control.viewContainerManager.updateTextEditorInfo(s.viewId,this.activeId),e&&this.internalMsgEmitter.emit("addUndoTicker",e,s.viewId)}get(i){return this.editors.get(i)}delete(i,e,t){const o=this.editors.get(i);if(o){const s=o.viewId;o.canSync=e,o.canWorker=t,this.editors.delete(i),this.activeId===i&&(this.activeId=void 0),this.control.viewContainerManager.updateTextEditorInfo(s,this.activeId)}}deleteBatch(i,e,t){const o=new Set;for(const s of i){const n=this.editors.get(s);if(n){const a=n.viewId;n.canSync=e,n.canWorker=t,this.editors.delete(s),this.activeId===s&&(this.activeId=void 0),o.add(a)}}for(const s of o)this.control.viewContainerManager.updateTextEditorInfo(s,this.activeId)}clear(i,e){this.editors.forEach((t,o)=>{t.viewId===i&&(e&&(t.canSync=!1),t.canWorker=!1,this.editors.delete(o))}),this.activeId=void 0,this.control.viewContainerManager.updateTextEditorInfo(i,this.activeId)}destory(){this.editors.clear(),this.activeId=void 0}insertText(i,e,t,o){var g,p;const s=(g=this.control.room)==null?void 0:g.state.memberState;if(!s)return;const n=this.control.viewContainerManager.getView(i);if(!(n!=null&&n.focusScenePath))return;const a=n==null?void 0:n.cameraOpt,c=this.control.getToolsOpt(v.Text,s);if(!c)return;const l=(p=this.control.viewContainerManager)==null?void 0:p.transformToOriginPoint([e,t],i),h=Ui(o,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]}).split(/\n/),d=c.toolsOpt;d.text=Ye(h),d.workState=A.Doing,d.boxPoint=[e,t],d.boxSize=[d.fontSize,d.fontSize];const f=this.control.worker.now;return this.control.textEditorManager.checkEmptyTextBlur(),this.control.textEditorManager.createTextForMasterController({workId:f.toString(),x:l&&l[0]||0,y:l&&l[1]||0,scale:(a==null?void 0:a.scale)||1,opt:d,type:ot.Text,isActive:!0,viewId:i,scenePath:n.focusScenePath},f),f.toString()}updateText(i,e){const t=this.editors.get(i.toString());if(!t)return;const s=Ui(e,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]}).split(/\n/);t.opt.text=Ye(s),this.control.textEditorManager.updateTextForMasterController({workId:i,opt:t.opt,viewId:t.viewId,canSync:!0,canWorker:!0},this.control.worker.now)}}class my{constructor(i){M(this,"expirationTime",Me.cursor.expirationTime);M(this,"isEnableCursor");M(this,"internalMsgEmitter");M(this,"publicMsgEmitter");M(this,"control");M(this,"eventName","applianc-cursor");M(this,"displayer");M(this,"roomMember");M(this,"animationId");M(this,"maxLastSyncTime");M(this,"willSendEventWorkers",[]);M(this,"willConsumeEventWorkers",new Map);M(this,"sendEventTimerId");M(this,"animationDrawWorkers",new Map);M(this,"animationEventWorkers",new Map);M(this,"cursorInfoMap",new Map);M(this,"doneRenderCursorInfoMap",new Map);const{control:e,internalMsgEmitter:t,publicMsgEmitter:o}=i;this.internalMsgEmitter=t,this.publicMsgEmitter=o,this.expirationTime=O.isNumber(e.pluginOptions.extras.cursor.expirationTime)?e.pluginOptions.extras.cursor.expirationTime:this.expirationTime,this.control=e,this.roomMember=e.roomMember,this.maxLastSyncTime=this.control.pluginOptions.extras.syncOpt.interval,this.isEnableCursor=this.control.pluginOptions.extras.cursor.enable}activeCollector(){this.control.plugin&&this.isEnableCursor&&(this.displayer=this.control.room||this.control.play,this.displayer.addMagixEventListener(this.eventName,this.mainMagixEventListener.bind(this)))}mainMagixEventListener(i){var a;const{event:e,payload:t}=i;if(e!==this.eventName)return;const{uid:o,op:s,type:n}=t;if(((a=this.control.collector)==null?void 0:a.uid)!==o&&n===Xt.Cursor&&(s!=null&&s.length)){const c=this.willConsumeEventWorkers.get(o)||[];for(const l of s){const{viewId:u}=l;O.isNumber(l.consumPoint[0])&&O.isNumber(l.consumPoint[1])&&(l.consumPoint=this.control.viewContainerManager.transformToOriginPoint(l.consumPoint,u)),this.control.renderControl.isFilterCursor(u)&&c.unshift({...l,timestamp:this.control.worker.now})}this.willConsumeEventWorkers.set(o,c),this.runAnimation()}}onFocusViewChange(){this.isEnableCursor&&(this.checkDrawWorks(),this.runAnimation())}updateRoomMembers(i){const{offline:e}=i;for(const t of this.cursorInfoMap.keys())t&&e.includes(t)&&this.cursorInfoMap.delete(t)}getKey(i,e){return`${i}${Ze}${e}`}getUidAndviewId(i){const[e,t]=i.split(Ze);return{uid:e,viewId:t}}runAnimation(){this.animationId||(this.animationId=requestAnimationFrame(this.animationCursor.bind(this)))}checkDrawWorks(){var e;const i=this.control.viewContainerManager.focuedViewId;for(const[t,o]of this.animationDrawWorkers.entries()){const{viewId:s,uid:n}=this.getUidAndviewId(t);n!==((e=this.control.collector)==null?void 0:e.uid)&&s!==i&&o.workState===A.Done&&(o.consumPoint=[void 0,void 0])}}animationCursor(){this.animationId=void 0;const i=this.control.worker.now;for(const[t,o]of this.animationDrawWorkers.entries()){const{uid:s,viewId:n}=this.getUidAndviewId(t),a=this.roomMember.getRoomMember(s);if(!a){this.animationDrawWorkers.delete(t);continue}const{consumPoint:c,timestamp:l,workState:u}=o,h=this.cursorInfoMap.get(n)||new Map;c&&O.isNumber(c[0])&&O.isNumber(c[1])&&l+this.expirationTime>i?h.set(a.memberId,{x:c[0],y:c[1],roomMember:a,timestamp:l,type:1,workState:u}):h.delete(a.memberId),h.size?this.cursorInfoMap.set(n,h):this.cursorInfoMap.delete(n),this.animationDrawWorkers.delete(t)}const e=new Set;for(const[t,o]of this.cursorInfoMap.entries())if(o)for(const[s,n]of o.entries())n.type===1&&n.workState!==A.Done&&e.add(s);else this.cursorInfoMap.delete(t);for(const[t,o]of this.willConsumeEventWorkers.entries()){const s=this.roomMember.getRoomMember(t);if(O.isNumber(s==null?void 0:s.memberId)&&!e.has(s.memberId)){const n=o.pop();n?this.animationEventWorkers.set(t,n):this.willConsumeEventWorkers.delete(t)}}for(const[t,o]of this.animationEventWorkers.entries()){const s=this.roomMember.getRoomMember(t);if(!s){this.animationEventWorkers.delete(t);continue}const{viewId:n,consumPoint:a,timestamp:c}=o,l=this.cursorInfoMap.get(n)||new Map;a&&O.isNumber(a[0])&&O.isNumber(a[1])&&c+this.expirationTime>i?l.set(s.memberId,{x:a[0],y:a[1],roomMember:s,timestamp:c,type:0}):l.delete(s.memberId),l.size?this.cursorInfoMap.set(n,l):this.cursorInfoMap.delete(n),this.animationEventWorkers.delete(t)}for(const t of this.doneRenderCursorInfoMap.keys())this.cursorInfoMap.has(t)||(this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([ne.Cursor,t],[]));for(const[t,o]of this.cursorInfoMap.entries())if(o!=null&&o.size){const s=[];for(const[a,c]of o.entries()){const{timestamp:l,...u}=c;l+this.expirationTime>i?s.push(u):(o.delete(a),o.size===0&&(this.cursorInfoMap.delete(t),this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([ne.Cursor,t],[])))}const n=this.doneRenderCursorInfoMap.get(t);O.isEqual(n,s)||(this.doneRenderCursorInfoMap.set(t,s),this.internalMsgEmitter.emit([ne.Cursor,t],s))}else this.cursorInfoMap.delete(t),this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([ne.Cursor,t],[]);(this.willConsumeEventWorkers.size||this.cursorInfoMap.size)&&this.runAnimation()}sendEvent(i,e){if(this.displayer&&H.isRoom(this.displayer)){const t=O.isNumber(i[0])&&O.isNumber(i[1])&&this.control.viewContainerManager.transformToScenePoint(i,e)||[void 0,void 0];this.willSendEventWorkers.push({consumPoint:t,viewId:e}),this.sendEventTimerId||(this.sendEventTimerId=setTimeout(()=>{this.dispatchMagixEvent()},this.maxLastSyncTime))}}dispatchMagixEvent(){var i;this.displayer&&H.isRoom(this.displayer)&&this.displayer.isWritable&&this.displayer.dispatchMagixEvent(this.eventName,{type:Xt.Cursor,op:O.cloneDeep(this.willSendEventWorkers),uid:(i=this.control.collector)==null?void 0:i.uid}),this.willSendEventWorkers.length=0,this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0)}collectServiceCursor(i){var n;if(!this.isEnableCursor&&!this.control.renderControl.isWritable)return;const{op:e,uid:t,workState:o,viewId:s}=i;if(t&&e&&o&&s){const a=this.roomMember.getRoomMember(t);if(!a||t===((n=this.control.collector)==null?void 0:n.uid))return;const c=this.getKey(t,s);let l=[void 0,void 0];if(O.isNumber(e[0])&&O.isNumber(e[1])){const[h,d]=this.control.viewContainerManager.transformToOriginPoint(e,s);l=[h,d]}if(o===A.Start){for(const h of this.cursorInfoMap.values())if(h!=null&&h.size)for(const d of h.keys())d===a.memberId&&h.delete(d)}const u={consumPoint:l,workState:o,viewId:s,timestamp:this.control.worker.now};if(o===A.Start||o===A.Done){const h=this.willConsumeEventWorkers.get(t);o===A.Start&&h&&this.willConsumeEventWorkers.delete(t),h&&o===A.Done&&(u.timestamp=u.timestamp-this.expirationTime)}this.animationDrawWorkers.set(c,u),this.runAnimation()}}unabled(){var i;this.displayer&&H.isRoom(this.displayer)&&(this.willSendEventWorkers.length=0,this.displayer.dispatchMagixEvent(this.eventName,{type:Xt.Cursor,op:[{viewId:this.control.viewContainerManager.focuedViewId,consumPoint:[void 0,void 0]}],uid:(i=this.control.collector)==null?void 0:i.uid}),this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0)),this.isEnableCursor||this.stopAnimation()}clearViewCursor(i){var e,t,o;for(const[s]of this.animationDrawWorkers.entries()){const{uid:n}=this.getUidAndviewId(s);n===((e=this.control.collector)==null?void 0:e.uid)&&i===i&&this.animationDrawWorkers.delete(s)}for(const[s]of this.willConsumeEventWorkers.entries())s===((t=this.control.collector)==null?void 0:t.uid)&&this.willConsumeEventWorkers.delete(s);for(const[s]of this.animationEventWorkers.entries())s===((o=this.control.collector)==null?void 0:o.uid)&&this.animationEventWorkers.delete(s);for(const[s]of this.cursorInfoMap.entries())s===s&&(this.cursorInfoMap.delete(s),this.doneRenderCursorInfoMap.delete(s),this.internalMsgEmitter.emit([ne.Cursor,s],[]))}stopAnimation(){this.animationDrawWorkers.clear(),this.willConsumeEventWorkers.clear(),this.cursorInfoMap.clear()}destroy(){var i;(i=this.displayer)==null||i.removeMagixEventListener(this.eventName),this.stopAnimation()}}class Ke{constructor(){M(this,"useEmtMsg");M(this,"emtType");M(this,"control");M(this,"mainEngine");M(this,"collectListener",(i,e)=>{this.collect(i,e)})}static dispatch(i,e,t){var o;(o=xe.InternalMsgEmitter)==null||o.emit([i,e],t)}get serviceColloctor(){return this.control.collector}registerForMainEngine(i,e){return this.emtType=i,this.control=e,this.mainEngine=e.worker,this.mainEngine.internalMsgEmitter.on([this.emtType,this.emitEventType],this.collectListener),this}destroy(){this.emtType&&this.mainEngine&&this.mainEngine.internalMsgEmitter.off([this.emtType,this.emitEventType],this.collectListener)}collectForLocalWorker(i,e){var t,o,s;for(const[n,a]of i)(t=this.mainEngine)==null||t.queryTaskBatchData(a).forEach(c=>{var l;(l=this.mainEngine)==null||l.taskBatchData.delete(c)}),(o=this.mainEngine)==null||o.taskBatchData.add(n);if(e){this.mainEngine.consume();return}(s=this.mainEngine)==null||s.runAnimation()}collectForServiceWorker(i){it(()=>{i.forEach(e=>{var t;(t=this.serviceColloctor)==null||t.dispatch(e)})},this.mainEngine.maxLastSyncTime,this.control.hasPolyfillMethod("requestIdleCallback"))}pause(){var i;if(this.lastEmtData){this.useEmtMsg=!0;const e={...this.lastEmtData,workState:A.Done};this.collect(e,!0),(i=xe.InternalMsgEmitter)==null||i.emit(F.ActiveMethod,!1)}}recover(){var i;this.useEmtMsg&&xe.InternalMsgEmitter.hasListeners(F.ActiveMethod)&&((i=xe.InternalMsgEmitter)==null||i.emit(F.ActiveMethod,!0))}}class wy extends Ke{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",F.CopyNode)}collect(e){var c;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:o}=e,s=this.control.viewContainerManager.getView(o);if(!(s!=null&&s.displayer))return;const n=s.focusScenePath,a=this.mainEngine.now;this.mainEngine.internalMsgEmitter.emit("addUndoTicker",a,o);for(const l of t){const u=l.toString(),d=this.serviceColloctor.isLocalId(u)?this.serviceColloctor.transformKey(l):u,f=(c=this.serviceColloctor.getStorageData(o,n))==null?void 0:c[d];if(f){if(l===G){const g=f&&this.copySelector({viewId:o,store:f});g&&this.pasteSelector({...g,viewId:o,scenePath:n,undoTickerId:a});break}if(f.toolsType===v.Text&&f.opt&&f.opt.workState&&f.opt.workState!==A.Done){const g=f&&this.copyText({viewId:o,store:f});g&&this.pasteText({...g,viewId:o,scenePath:n,key:d,store:f,undoTickerId:a});break}}}}copyText(e){const{viewId:t,store:o}=e,s=this.control.viewContainerManager.getView(t);if(!this.serviceColloctor||!s)return;const n=s==null?void 0:s.cameraOpt,a=n&&[n.centerX,n.centerY],c=o.opt,l=c.boxPoint&&c.boxSize&&[c.boxPoint[0]+c.boxSize[0]/2,c.boxPoint[1]+c.boxSize[1]/2];return{bgCenter:a,textCenter:l}}pasteText(e){var y,I;const{bgCenter:t,textCenter:o,store:s,key:n,viewId:a,scenePath:c,undoTickerId:l}=e,u=this.control.viewContainerManager.getView(a);if(!this.serviceColloctor||!u)return;const h=Math.floor(Math.random()*30+1),d=((y=u.cameraOpt)==null?void 0:y.scale)||1,f=t&&o&&[t[0]-o[0]+h,t[1]-o[1]+h]||[h/d,h/d],p=(this.serviceColloctor.isLocalId(n)?n:this.serviceColloctor.getLocalId(n.toString()))+"-"+l;if(s.toolsType===v.Text&&s.opt){const w=s.opt;if(w&&w.boxPoint&&w.text){w.workState=A.Done;const S=w.boxPoint;w.boxPoint=[S[0]+f[0],S[1]+f[1]],w.workState=A.Done;const C=this.control.viewContainerManager.transformToOriginPoint(w.boxPoint,a);this.control.textEditorManager.createTextForMasterController({workId:p,x:C[0],y:C[1],opt:w,scale:((I=u.cameraOpt)==null?void 0:I.scale)||1,type:ot.Text,isActive:!1,viewId:a,scenePath:c}),this.collectForServiceWorker([{...s,opt:w,type:b.FullWork,workId:p,viewId:a,scenePath:c}])}}}copySelector(e){var p,y,I,w,S,C,T,N,x;const{viewId:t,store:o}=e,s=this.control.viewContainerManager.getView(t),n=o.selectIds;if(!this.serviceColloctor||!(n!=null&&n.length)||!s)return;const a=new Map,c={offset:{x:0,y:0},cameraOpt:{centerX:((p=s.cameraOpt)==null?void 0:p.centerX)||0,centerY:((y=s.cameraOpt)==null?void 0:y.centerY)||0,scale:((I=s.cameraOpt)==null?void 0:I.scale)||1}},l=this.control.hasOffscreenCanvas()&&((w=s.displayer.canvasBgRef.current)==null?void 0:w.getBoundingClientRect())||((S=s.displayer.canvasContainerRef.current)==null?void 0:S.getBoundingClientRect()),u=(T=(C=s.displayer)==null?void 0:C.floatBarRef.current)==null?void 0:T.getBoundingClientRect(),h=l&&[l.x+l.width/2,l.y+l.height/2],d=u&&[u.x+u.width/2,u.y+u.height/2],f=h&&s.viewData&&s.viewData.convertToPointInWorld({x:h[0],y:h[1]}),g=d&&s.viewData&&s.viewData.convertToPointInWorld({x:d[0],y:d[1]});f&&g&&(c.offset={x:f.x-g.x,y:f.y-g.y});for(const D of n){const L=(x=(N=this.serviceColloctor)==null?void 0:N.getStorageData(s.id,s.focusScenePath))==null?void 0:x[D];L&&a.set(D,L)}return{copyStores:a,copyCoordInfo:c}}pasteSelector(e){var y,I,w,S;const{copyStores:t,copyCoordInfo:o,viewId:s,scenePath:n,undoTickerId:a}=e,c=this.control.viewContainerManager.getView(s);if(!t.size||!this.serviceColloctor||!c)return;const{offset:l,cameraOpt:u}=o,{scale:h}=u,d=Math.floor(Math.random()*30+1),f=l&&[l.x+d,l.y+d]||[d/h,d/h],g=[],p=[];for(const[C,T]of t.entries()){const x=(this.serviceColloctor.isLocalId(C)?C:this.serviceColloctor.getLocalId(C.toString()))+"-"+a,D={useAnimation:!1};if(T.toolsType===v.Text&&T.opt){const L=T.opt;if(L&&L.boxPoint&&L.text){L.workState=A.Done;const z=L.boxPoint;L.boxPoint=[z[0]+f[0],z[1]+f[1]],L.workState=A.Done;const j=this.control.viewContainerManager.transformToOriginPoint(L.boxPoint,s);this.control.textEditorManager.createTextForMasterController({workId:x,x:j[0],y:j[1],opt:L,scale:((y=c.cameraOpt)==null?void 0:y.scale)||1,type:ot.Text,isActive:!1,viewId:s,scenePath:n})}p.push({...T,opt:L,type:b.FullWork,workId:x,viewId:s,scenePath:n});continue}if(T.toolsType===v.Image&&(T.opt.uuid=x,T.opt.centerX=T.opt.centerX+f[0],T.opt.centerY=T.opt.centerY+f[1]),T.ops){const L=bt(T.ops).map((j,E)=>{const R=E%3;return R===0?j+f[0]:R===1?j+f[1]:j}),z=Ye(L);T.ops=z}if((I=T==null?void 0:T.opt)!=null&&I.eraserlines&&(w=T==null?void 0:T.opt)!=null&&w.eraserlines.length)for(const L of(S=T==null?void 0:T.opt)==null?void 0:S.eraserlines){const{op:z}=L;for(let j=0;j<z.length;j++){const E=z[j].map((R,P)=>P%2?R+f[1]:R+f[0]);L.op[j]=E}}p.push({...T,updateNodeOpt:D,type:b.FullWork,workId:x,viewId:s,scenePath:n}),g.push([{...T,updateNodeOpt:D,workId:x,msgType:b.FullWork,dataType:V.Local,emitEventType:F.CopyNode,willSyncService:!1,willRefresh:!0,viewId:s},{workId:x,msgType:b.FullWork,emitEventType:F.CopyNode}])}g.length&&this.collectForLocalWorker(g),p.length&&this.collectForServiceWorker(p)}}class Iy extends Ke{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",F.SetColorNode);M(this,"undoTickerId")}setTextColor(e,t,o,s){const{fontColor:n,fontBgColor:a}=o;t.opt&&(n&&(t.opt.fontColor=n),a&&(t.opt.fontBgColor=a),this.control.textEditorManager.updateTextForMasterController({workId:e,opt:t.opt,viewId:s,canSync:!0,canWorker:!0}))}collect(e){var w,S;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,strokeColor:o,fillColor:s,fontColor:n,fontBgColor:a,viewId:c,workState:l,thickness:u,strokeType:h}=e,d=this.control.viewContainerManager.getView(c);if(!(d!=null&&d.displayer))return;const f=d.focusScenePath,g=[...t],p=this.serviceColloctor.storage,y=[],I={};for((l===A.Start||!this.undoTickerId&&l===A.Done)&&(this.undoTickerId=this.mainEngine.now,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",this.undoTickerId,c));g.length;){const C=g.pop();if(!C)continue;const T=C.toString(),N=this.serviceColloctor.isLocalId(T),x=N?this.serviceColloctor.transformKey(C):T;let D=T;!N&&this.serviceColloctor.isOwn(D)&&(D=this.serviceColloctor.getLocalId(D));const L=(S=(w=p==null?void 0:p[c])==null?void 0:w[f])==null?void 0:S[x];if(L){const z=L.updateNodeOpt||{};if(n||a){if(n){z.fontColor=n;const[E,R,P,Z]=Gt(n);I.textColor=[E,R,P],I.textOpacity=Z}if(a)if(z.fontBgColor=ni(a)?"transparent":a,ni(a))I.textBgColor=void 0,I.textBgOpacity=void 0;else{const[E,R,P,Z]=Gt(a);I.textBgColor=[E,R,P],I.textBgOpacity=Z}if(L.toolsType===v.Text&&L.opt&&l!==A.Start){this.setTextColor(D,Ae(L),z,c),l===A.Done&&(this.undoTickerId=void 0);continue}}if(o){z.strokeColor=o;const[E,R,P,Z]=Gt(o);I.strokeColor=[E,R,P],I.strokeOpacity=Z}if(s)if(z.fillColor=ni(s)?"transparent":s,ni(s))I.fillColor=void 0,I.fillOpacity=void 0;else{const[E,R,P,Z]=Gt(s);I.fillColor=[E,R,P],I.fillOpacity=Z}u&&(z.thickness=u,I.strokeWidth=u),h&&(z.strokeType=h,I.strokeType=h);const j={workId:D,msgType:b.UpdateNode,dataType:V.Local,updateNodeOpt:z,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,textUpdateForWoker:!0,viewId:c};y.push([j,{workId:D,msgType:b.UpdateNode,emitEventType:this.emitEventType}])}}y.length&&(l===A.Done&&(this.undoTickerId=void 0),this.collectForLocalWorker(y)),Object.keys(I).length&&setTimeout(()=>{var C;(C=this.control.room)==null||C.setMemberState(I)},0)}}class Ty extends Ke{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",F.ZIndexNode);M(this,"zIndexMap",new Map)}clearZIndex(e){this.zIndexMap.delete(e)}getMinZIndex(e){var t;return((t=this.zIndexMap.get(e))==null?void 0:t.min)||0}getMaxZIndex(e){var t;return((t=this.zIndexMap.get(e))==null?void 0:t.max)||0}setMaxZIndex(e,t){const o=this.getMinZIndex(t);this.zIndexMap.set(t,{min:o,max:e})}setMinZIndex(e,t){const o=this.getMaxZIndex(t);this.zIndexMap.set(t,{min:e,max:o})}addMaxLayer(e){const t=this.getMaxZIndex(e)+1;this.setMaxZIndex(t,e)}addMinLayer(e){const t=this.getMinZIndex(e)-1;this.setMinZIndex(t,e)}correct(e){const t=e.sort((o,s)=>o[1]-s[1]);for(let o=1;o<t.length;o++){const s=t[o][1],n=t[o-1][1];s<=n&&(t[o][1]=n+1)}return t}collect(e){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,layer:o,viewId:s}=e,n=this.control.viewContainerManager.getView(s);if(!(n!=null&&n.displayer))return;const a=n.focusScenePath,c=[...t],l=this.serviceColloctor.storage,u=[],h=[];for(;c.length;){const f=c.pop();if(!f)continue;const g=f.toString(),p=this.serviceColloctor.isLocalId(g),y=p?this.serviceColloctor.transformKey(f):g;let I=g;!p&&this.serviceColloctor.isOwn(I)&&(I=this.serviceColloctor.getLocalId(I));const w=Ae(l[s][a][y]);let S;if(w&&I===G){if(w.selectIds){h.push(...w.selectIds),h.sort((x,D)=>{var j,E,R,P;const L=((E=(j=l[d(x,this.serviceColloctor)])==null?void 0:j.opt)==null?void 0:E.zIndex)||0,z=((P=(R=l[d(x,this.serviceColloctor)])==null?void 0:R.opt)==null?void 0:P.zIndex)||0;return L>z?1:x<D?-1:0});const C=w.updateNodeOpt||{};C.zIndexLayer=o;const T={workId:f,msgType:b.UpdateNode,dataType:V.Local,updateNodeOpt:C,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:s},N=new Map;o===Jt.Top?(this.addMaxLayer(s),S=this.getMaxZIndex(s)):(this.addMinLayer(s),S=this.getMinZIndex(s)),h.forEach(x=>{var j,E,R,P,Z;const D=(j=this.serviceColloctor)==null?void 0:j.isLocalId(x);let L=D&&((E=this.serviceColloctor)==null?void 0:E.transformKey(x))||x;const z=(P=(R=l==null?void 0:l[s])==null?void 0:R[a])==null?void 0:P[L];z&&(!D&&((Z=this.serviceColloctor)!=null&&Z.isOwn(L))&&(L=this.serviceColloctor.getLocalId(L)),C.zIndex=S,z!=null&&z.opt&&(z.opt.zIndex=S),z!=null&&z.opt&&N.set(L,{updateNodeOpt:z.updateNodeOpt,opt:z.opt}))}),T.selectStore=N,T.willSerializeData=!0,u.push([T,{workId:f,msgType:b.UpdateNode,emitEventType:this.emitEventType}])}continue}}u.length&&this.collectForLocalWorker(u);function d(f,g){return g.isLocalId(f)&&g.transformKey(f)||f}}}class vy extends Ke{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",F.TranslateNode);M(this,"cachePosition")}collect(e,t){var g,p,y;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:o,position:s,workState:n,viewId:a}=e;this.lastEmtData=e;const c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,u=[...o],h=(g=this.serviceColloctor)==null?void 0:g.storage,d=[],f=n===A.Start&&this.mainEngine.now||void 0;for(f&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",f,a);u.length;){const I=u.pop();if(!I)continue;const w=I.toString(),S=this.serviceColloctor.isLocalId(w),C=S&&this.serviceColloctor.transformKey(I)||w;let T=w;!S&&this.serviceColloctor.isOwn(T)&&(T=this.serviceColloctor.getLocalId(T));const N=(y=(p=h==null?void 0:h[a])==null?void 0:p[l])==null?void 0:y[C];if(N&&T===G){if(N.selectIds){const x=this.control.viewContainerManager.transformToScenePoint([s.x,s.y],a);if(n===A.Start&&(this.cachePosition=x),this.cachePosition){const D=N.updateNodeOpt||{};D.translate=[x[0]-this.cachePosition[0],x[1]-this.cachePosition[1]],D.workState=n,this.control.cursor.isEnableCursor?D.useAnimation=!1:(D.uid=this.serviceColloctor.uid,n===A.Start?D.useAnimation=!1:n===A.Done&&(D.useAnimation=!0));const L={workId:I,msgType:b.UpdateNode,dataType:V.Local,updateNodeOpt:D,emitEventType:this.emitEventType,willSyncService:!0,textUpdateForWoker:!0,viewId:a,smoothSync:this.mainEngine.smoothSync};n===A.Done&&(L.textUpdateForWoker=!0,L.willSerializeData=!0,this.cachePosition=void 0),d.push([L,{workId:I,msgType:b.UpdateNode,emitEventType:this.emitEventType,workState:n}])}}continue}}n===A.Start?this.mainEngine.unWritable():n===A.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length&&this.collectForLocalWorker(d,t)}}class Ny extends Ke{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",F.DeleteNode)}collect(e){var d,f;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:o}=e,s=this.control.viewContainerManager.getView(o);if(!(s!=null&&s.displayer))return;const n=s.focusScenePath,a=this.serviceColloctor.storage,c=[...t],l=[],u=[],h=this.mainEngine.now;for(;c.length;){const g=c.pop();if(!g)continue;const p=g.toString(),y=this.serviceColloctor.isLocalId(p),I=y?this.serviceColloctor.transformKey(g):p,w=(f=(d=a==null?void 0:a[o])==null?void 0:d[n])==null?void 0:f[I];if(w){let S=p;if(!y&&this.serviceColloctor.isOwn(S)&&(S=this.serviceColloctor.getLocalId(S)),w.toolsType===v.Text){this.control.textEditorManager.delete(S,!0,!0);continue}u.push(S)}}u.length&&(l.push([{msgType:b.RemoveNode,emitEventType:F.DeleteNode,removeIds:u,dataType:V.Local,willSyncService:!0,willRefresh:!0,viewId:o},void 0]),this.mainEngine.internalMsgEmitter.emit("addUndoTicker",h,o),this.collectForLocalWorker(l))}}class Sy extends Ke{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",F.ScaleNode);M(this,"targetText",new Map);M(this,"cacheTextInfo",new Map)}async setTextStyle(e,t,o){const s=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:e,opt:t,viewId:o,canSync:!1,canWorker:!1});return{key:e,textInfo:s}}async collect(e,t){var w,S,C,T,N,x,D;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:o,workState:s,viewId:n,originPoint:a,scenePoint:c,dir:l,scale:u,translate:h}=e;this.lastEmtData=e;const d=this.control.viewContainerManager.getView(n);if(!(d!=null&&d.displayer))return;const f=d.focusScenePath,g=[...o],p=(w=this.serviceColloctor)==null?void 0:w.storage,y=[],I=s===A.Start&&this.mainEngine.now||void 0;for(I&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",I,n);g.length;){const L=g.pop();if(!L)continue;const z=L.toString(),j=this.serviceColloctor.isLocalId(z),E=j&&this.serviceColloctor.transformKey(L)||z;let R=z;!j&&this.serviceColloctor.isOwn(R)&&(R=this.serviceColloctor.getLocalId(R));const P=(C=(S=p==null?void 0:p[n])==null?void 0:S[f])==null?void 0:C[E];if(P&&R===G&&P.selectIds){const Z=P.updateNodeOpt||{};if(Z.dir=l,Z.originPoint=a,Z.scenePoint=c,Z.workState=s,Z.scale=u,Z.translate=h,s===A.Start){this.cacheTextInfo.clear();for(const B of P.selectIds){const J=(T=this.serviceColloctor)==null?void 0:T.isLocalId(B),ie=J&&((N=this.serviceColloctor)==null?void 0:N.transformKey(B))||B;let le=ie;!J&&((x=this.serviceColloctor)!=null&&x.isOwn(ie))&&(le=this.serviceColloctor.getLocalId(ie));const oe=this.control.textEditorManager.get(le);oe&&s===A.Start&&this.targetText.set(le,Ae(oe))}}if(this.targetText.size&&s!==A.Start&&u){const B=[];for(const[ie,le]of this.targetText.entries()){const{opt:oe}=le,K=Math.floor(oe.fontSize*u[0]),q=this.cacheTextInfo.get(ie),de=!q&&oe.fontSize!==K||q&&q.fontSize!==K||!1,Ue=(D=this.control.textEditorManager.get(ie))==null?void 0:D.opt;if(de&&Ue&&oe.boxSize&&oe.boxPoint){const De=this.setTextStyle(ie,{...Ue,fontSize:K},n);B.push(De)}}const J=await Promise.all(B);for(const ie of J)if(ie){const{key:le,textInfo:oe}=ie;this.cacheTextInfo.set(le,{fontSize:oe.opt.fontSize,boxSize:oe.opt.boxSize,boxPoint:oe.opt.boxPoint})}Z.textInfos=this.cacheTextInfo}this.control.cursor.isEnableCursor?Z.useAnimation=!1:(Z.uid=this.serviceColloctor.uid,s===A.Start?Z.useAnimation=!1:s===A.Done&&(Z.useAnimation=!0));const _={workId:L,msgType:b.UpdateNode,dataType:V.Local,updateNodeOpt:Z,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:n,smoothSync:this.mainEngine.smoothSync};s===A.Done&&(_.willSerializeData=!0,this.targetText.clear()),y.push([_,{workId:L,msgType:b.UpdateNode,emitEventType:this.emitEventType,workState:s}]);continue}}s===A.Start?this.mainEngine.unWritable():s===A.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),y.length&&this.collectForLocalWorker(y,t)}}class Cy extends Ke{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",F.RotateNode);M(this,"cacheOriginRotate",0)}collect(e,t){var g,p,y,I,w,S,C;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:o,angle:s,workState:n,viewId:a}=e;this.lastEmtData=e;const c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,u=[...o],h=(g=this.serviceColloctor)==null?void 0:g.storage,d=[],f=n===A.Start&&this.mainEngine.now||void 0;for(f&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",f,a);u.length;){const T=u.pop();if(!T)continue;const N=T.toString(),x=this.serviceColloctor.isLocalId(N),D=x&&this.serviceColloctor.transformKey(T)||N;let L=N;!x&&this.serviceColloctor.isOwn(L)&&(L=this.serviceColloctor.getLocalId(L));const z=(y=(p=h==null?void 0:h[a])==null?void 0:p[l])==null?void 0:y[D];if(z&&L===G){if(((I=z.selectIds)==null?void 0:I.length)===1){const j=z.selectIds[0];if(n===A.Start){const Z=((w=this.serviceColloctor)==null?void 0:w.isLocalId(j))&&((S=this.serviceColloctor)==null?void 0:S.transformKey(j))||j,_=h[a][l][Z];this.cacheOriginRotate=((C=_==null?void 0:_.opt)==null?void 0:C.rotate)||0}const E=z.updateNodeOpt||{};E.angle=(s+this.cacheOriginRotate)%360,E.workState=n,this.control.cursor.isEnableCursor?E.useAnimation=!1:(E.uid=this.serviceColloctor.uid,n===A.Start?E.useAnimation=!1:n===A.Done&&(E.useAnimation=!0));const R={workId:T,msgType:b.UpdateNode,dataType:V.Local,updateNodeOpt:E,emitEventType:this.emitEventType,willRefreshSelector:!1,willSyncService:!0,viewId:a,smoothSync:this.mainEngine.smoothSync};n===A.Done&&(R.willRefreshSelector=!0,R.willSerializeData=!0,this.cacheOriginRotate=0),d.push([R,{workId:T,msgType:b.UpdateNode,emitEventType:this.emitEventType,workState:n}])}continue}}n===A.Start?this.mainEngine.unWritable():n===A.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length&&this.collectForLocalWorker(d,t)}}function ky(r){switch(r){case v.Text:return ot.Text;case v.SpeechBalloon:case v.Star:case v.Ellipse:case v.Rectangle:case v.Triangle:case v.Rhombus:case v.Polygon:return ot.Shape}}class xy extends Ke{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",F.SetFontStyle);M(this,"timerId")}async setTextStyle(e,t,o,s){const{bold:n,underline:a,lineThrough:c,italic:l,fontSize:u}=o;if(t.toolsType&&ky(t.toolsType)===ot.Text){t.opt&&(n&&(t.opt.bold=n),O.isBoolean(a)&&(t.opt.underline=a),O.isBoolean(c)&&(t.opt.lineThrough=c),l&&(t.opt.italic=l),u&&(t.opt.fontSize=u));const d=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:e,opt:t.opt,viewId:s,canSync:!1,canWorker:!1});return{key:e,textInfo:d}}}async collect(e){var w,S,C,T,N,x;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,bold:o,italic:s,lineThrough:n,underline:a,viewId:c,fontSize:l}=e,u=this.control.viewContainerManager.getView(c);if(!(u!=null&&u.displayer))return;const h=u.focusScenePath,d=[...t],f=this.serviceColloctor.storage,g={},p=this.mainEngine.now;this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,c);const y=[];for(;d.length;){const D=d.pop();if(!D)continue;const L=D.toString(),z=this.serviceColloctor.isLocalId(L),j=z?this.serviceColloctor.transformKey(D):L;let E=L;!z&&this.serviceColloctor.isOwn(E)&&(E=this.serviceColloctor.getLocalId(E));const R=(S=(w=f==null?void 0:f[c])==null?void 0:w[h])==null?void 0:S[j];if(R){const P=R.updateNodeOpt||{};if(o&&(P.bold=o,g.bold=o==="bold"),s&&(P.italic=s,g.italic=s==="italic"),O.isBoolean(n)&&(P.lineThrough=n,g.lineThrough=n),O.isBoolean(a)&&(P.underline=a,g.underline=a),l&&(P.fontSize=l,g.textSize=l),R.toolsType===v.Text&&R.opt){const Z=this.setTextStyle(E,O.cloneDeep(R),P,c);y.push(Z);continue}if(R&&E===G&&((C=R.selectIds)!=null&&C.length))for(const Z of R.selectIds){const _=(T=this.serviceColloctor)==null?void 0:T.isLocalId(Z);let B=_&&((N=this.serviceColloctor)==null?void 0:N.transformKey(Z))||Z;const J=f[c][h][B]||void 0;if(!_&&((x=this.serviceColloctor)!=null&&x.isOwn(B))&&(B=this.serviceColloctor.getLocalId(B)),J&&J.toolsType===v.Text&&R.opt){const ie=this.setTextStyle(B,O.cloneDeep(J),P,c);y.push(ie);continue}}}}const I=await Promise.all(y);for(const D of I)if(D){const{key:L,textInfo:z}=D;z&&(z.canSync=!0,z.canWorker=!0,this.control.textEditorManager.updateForViewEdited(L,z))}Object.keys(g).length&&(this.timerId&&(clearTimeout(this.timerId),this.timerId=void 0),this.timerId=setTimeout(()=>{var D;this.timerId=void 0,(D=this.control.room)==null||D.setMemberState(g)},0))}}class by extends Ke{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",F.SetPoint);M(this,"undoTickerId")}collect(e){var w,S,C;if(!this.serviceColloctor||!this.mainEngine)return;const{workId:t,pointMap:o,workState:s,viewId:n}=e,a=this.control.viewContainerManager.getView(n);if(!(a!=null&&a.displayer))return;const c=a.focusScenePath,l=(w=this.serviceColloctor)==null?void 0:w.storage,u=[],h=s===A.Start&&this.mainEngine.now||void 0;h&&(this.undoTickerId=h,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",h,n));const d=t;if(!d)return;const f=d.toString(),g=this.serviceColloctor.isLocalId(f),p=g&&this.serviceColloctor.transformKey(d)||f;let y=f;!g&&this.serviceColloctor.isOwn(y)&&(y=this.serviceColloctor.getLocalId(y));const I=(C=(S=l==null?void 0:l[n])==null?void 0:S[c])==null?void 0:C[p];if(I&&y===G&&I.selectIds){const T=I.updateNodeOpt||{};T.pointMap=o,T.workState=s;const N={workId:d,msgType:b.UpdateNode,dataType:V.Local,updateNodeOpt:T,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:n};s===A.Done&&(N.undoTickerId=this.undoTickerId),u.push([N,{workId:d,msgType:b.UpdateNode,emitEventType:this.emitEventType}])}s===A.Start?this.mainEngine.unWritable():s===A.Done&&this.mainEngine.abled(),u.length&&this.collectForLocalWorker(u)}}class Dy extends Ke{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",F.SetLock)}collect(e){var d,f;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,isLocked:o,viewId:s}=e,n=this.control.viewContainerManager.getView(s);if(!(n!=null&&n.displayer))return;const a=n.focusScenePath,c=[...t],l=this.serviceColloctor.storage,u=[],h=this.mainEngine.now;for(;c.length;){const g=c.pop();if(!g)continue;const p=g.toString(),y=this.serviceColloctor.isLocalId(p),I=y?this.serviceColloctor.transformKey(g):p;let w=p;!y&&this.serviceColloctor.isOwn(w)&&(w=this.serviceColloctor.getLocalId(w));const S=(f=(d=l==null?void 0:l[s])==null?void 0:d[a])==null?void 0:f[I];if(S){const C=S.updateNodeOpt||{};C.isLocked=o;const T={workId:w,msgType:b.UpdateNode,dataType:V.Local,updateNodeOpt:C,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:s};u.push([T,{workId:w,msgType:b.UpdateNode,emitEventType:this.emitEventType}])}}this.mainEngine.internalMsgEmitter.emit("addUndoTicker",h,s),u.length&&this.collectForLocalWorker(u)}}class Ly extends Ke{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",F.SetShapeOpt)}collect(e){var d,f;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:o,...s}=e,n=this.control.viewContainerManager.getView(o);if(!(n!=null&&n.displayer))return;const a=n.focusScenePath,c=[...t],l=this.serviceColloctor.storage,u=[],h=this.mainEngine.now;for(;c.length;){const g=c.pop();if(!g)continue;const p=g.toString(),y=this.serviceColloctor.isLocalId(p),I=y?this.serviceColloctor.transformKey(g):p;let w=p;!y&&this.serviceColloctor.isOwn(w)&&(w=this.serviceColloctor.getLocalId(w));const S=(f=(d=l==null?void 0:l[o])==null?void 0:d[a])==null?void 0:f[I];if(S){const C={...S.updateNodeOpt,...s,willRefresh:!0};if(S&&w===G){const T={workId:w,msgType:b.UpdateNode,dataType:V.Local,updateNodeOpt:C,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:o};u.push([T,{workId:w,msgType:b.UpdateNode,emitEventType:this.emitEventType}])}}}u.length&&(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",h,o),this.collectForLocalWorker(u))}}class ae{constructor(i){M(this,"builders",new Map);this.builders=new Map(i.map(e=>[e,this.build(e)]))}build(i){switch(i){case F.TranslateNode:return new vy;case F.ZIndexNode:return new Ty;case F.CopyNode:return new wy;case F.SetColorNode:return new Iy;case F.DeleteNode:return new Ny;case F.ScaleNode:return new Sy;case F.RotateNode:return new Cy;case F.SetFontStyle:return new xy;case F.SetPoint:return new by;case F.SetLock:return new Dy;case F.SetShapeOpt:return new Ly}}getBuilder(i){return this.builders.get(i)}registerForMainEngine(i,e){return this.builders.forEach(t=>{t&&t.registerForMainEngine(i,e)}),this}destroy(){this.builders.forEach(i=>{i&&i.destroy()}),this.builders.clear()}pause(){return this.builders.forEach(i=>{i&&i.pause()}),this}recover(){return this.builders.forEach(i=>{i&&i.recover()}),this}static emitMethod(i,e,t){Ke.dispatch(i,e,t)}static activeListener(i){xe.InternalMsgEmitter.on(F.ActiveMethod,i)}static unmountActiveListener(i){xe.InternalMsgEmitter.off(F.ActiveMethod,i)}}class Ay{constructor(i){M(this,"master");M(this,"mainThreadWorkerMap",new Map);this.master=i}updateCamera(){for(const[i,e]of this.mainThreadWorkerMap.entries()){const t=this.master.control.viewContainerManager.getView(i);if(t){const{cameraOpt:o}=t;e.updateCamera({cameraOpt:o,viewId:t.viewId,msgType:b.UpdateCamera,dataType:V.Local})}}}notifyDrawCount(i){const e=this.master.getFullWorkDrawCount(),t=this.mainThreadWorkerMap.get(i);t&&t.clearDrawLayer(e)}clearDrawCount(i){const e=this.mainThreadWorkerMap.get(i);e&&e.clearDrawLayer(1/0)}createMainThreadWorker(i,e){return new jy(i,e,this)}consume(i){var e;for(const t of i.values()){const{msgType:o,viewId:s,layerOpt:n,offscreenCanvasOpt:a,cameraOpt:c}=t;if(o===b.Console){console.log(this);continue}if(o===b.Init){const u=(e=this.master.control.viewContainerManager.getView(s))==null?void 0:e.displayer,h=u==null?void 0:u.subLocalCanvasContainerRef.current;if(u&&h&&n&&a){const d=this.createMainThreadWorker(s,{displayer:u,container:h,layerOpt:n,master:this.master,canvasOpt:a,post:this.post.bind(this)});this.mainThreadWorkerMap.set(s,d),d&&c&&d.setCameraOpt(c)}continue}if(o===b.TasksQueue)continue;const l=this.mainThreadWorkerMap.get(s);l&&(l.on(t),o===b.Destroy&&(l.destroy(),this.mainThreadWorkerMap.delete(s)))}}post(i){const{sp:e}=i;e&&this.master.collectorSyncData(e)}destroy(){for(const i of this.mainThreadWorkerMap.values())i.destroy();this.mainThreadWorkerMap.clear()}active(){}}class jy{constructor(i,e,t){M(this,"viewId");M(this,"opt");M(this,"manager");M(this,"subLocalLayer");M(this,"subLocalWork");M(this,"scene");M(this,"cameraOpt");this.viewId=i,this.opt=e,this.manager=t,this.scene=this.createScene({...e.canvasOpt,container:e.container});const o=Me.bufferSize.full,s=Me.bufferSize.sub;this.subLocalLayer=this.createLayer("subLocalLayer",this.scene,{...e.layerOpt,bufferSize:this.viewId===ge?o:s,contextType:"2d"});const n={thread:this};this.subLocalWork=new zy(n)}createScene(i){return new ue.Scene({displayRatio:this.opt.displayer.dpr,depth:!1,desynchronized:!0,...i,contextType:"2d",autoRender:!0,id:this.viewId})}createLayer(i,e,t){const{width:o,height:s}=t,n=`canvas-${i}`,a=e.layer(n,{...t,offscreen:!1}),c=new ue.Group({anchor:[.5,.5],pos:[o*.5,s*.5],size:[o,s],name:"viewport",id:i});return a.append(c),c}updateScene(i){this.scene.attr({...i});const{width:e,height:t}=i;this.scene.width=e,this.scene.height=t,this.updateLayer({width:e,height:t})}updateLayer(i){const{width:e,height:t}=i;this.subLocalLayer.parent.setAttribute("width",e),this.subLocalLayer.parent.setAttribute("height",t),this.subLocalLayer.setAttribute("size",[e,t]),this.subLocalLayer.setAttribute("pos",[e*.5,t*.5])}updateDpr(i){this.scene.displayRatio=i}on(i){const{msgType:e,toolsType:t,opt:o,dataType:s,workId:n,workState:a}=i,c=n==null?void 0:n.toString();switch(e){case b.Destroy:this.destroy();break;case b.Clear:this.clearAll();break;case b.UpdateDpr:O.isNumber(i.dpr)&&this.updateDpr(i.dpr);break;case b.UpdateCamera:this.updateCamera(i);break;case b.UpdateTools:if(t&&this.subLocalWork.canUseSubWorkerLayer(t)&&o){const l={toolsType:t,toolsOpt:o};this.subLocalWork.setToolsOpt(l)}break;case b.CreateWork:c&&o&&t&&this.subLocalWork.canUseSubWorkerLayer(t)&&(this.subLocalWork.getToolsOpt()||this.subLocalWork.setToolsOpt({toolsType:t,toolsOpt:o}),this.subLocalWork.setWorkOptions(c,o));break;case b.DrawWork:t&&this.subLocalWork.canUseSubWorkerLayer(t)&&(a===A.Done&&s===V.Local?this.subLocalWork.consumeDrawAll(i):this.subLocalWork.consumeDraw(i));break;case b.RemoveNode:this.subLocalWork.removeNode(i);return}}setCameraOpt(i){this.cameraOpt=i;const{scale:e,centerX:t,centerY:o,width:s,height:n}=i;(s!==this.scene.width||n!==this.scene.height)&&this.updateScene({width:s,height:n}),this.subLocalLayer&&(this.subLocalLayer.setAttribute("scale",[e,e]),this.subLocalLayer.setAttribute("translate",[-t,-o]))}updateCamera(i){const{cameraOpt:e}=i;e&&!O.isEqual(this.cameraOpt,e)&&(this.subLocalWork.workShapes.size&&this.clearAll(),this.setCameraOpt(e))}clearAll(){this.subLocalLayer.children.length&&(this.subLocalLayer.parent.children.forEach(i=>{i.name!=="viewport"&&i.remove()}),Be(this.subLocalLayer,this.subLocalLayer.parent)),this.subLocalWork.clearAll()}destroy(){this.subLocalLayer.remove(),$e(this.subLocalLayer,this.subLocalLayer.parent),this.scene.remove(),this.subLocalWork.destroy()}clearDrawLayer(i){if(i===1/0){this.clearAll();return}const e=this.subLocalLayer.children.filter(t=>t.id&&O.isNumber(parseInt(t.id))&&parseInt(t.id)<i);for(const t of e)t.remove(),$e(t,this.subLocalLayer.parent)}}class zy{constructor(i){M(this,"thread");M(this,"workShapes",new Map);M(this,"tmpOpt");M(this,"syncUnitTime",Me.syncOpt.interval);M(this,"subWorkerDrawCount",0);this.thread=i.thread}getToolsOpt(){return this.tmpOpt}consumeDrawAll(i){const{workId:e}=i,t=e==null?void 0:e.toString();t&&this.workShapes.get(t)&&(this.subWorkerDrawCount=0,Be(this.thread.subLocalLayer,this.thread.subLocalLayer.parent),this.clearWorkShapeNodeCache(t))}consumeDraw(i){const{workId:e,toolsType:t,postCount:o}=i;e&&t&&this.canUseSubWorkerLayer(t)&&(this.getWorkShape(e.toString())||this.createLocalWork(i));const s=e==null?void 0:e.toString(),n=s&&this.workShapes.get(s);if(!n)return;n.consume({data:i,drawCount:this.subWorkerDrawCount,isFullWork:!1,isSubWorker:!0}),this.subWorkerDrawCount++;const a=this.thread.manager.master;a.setSubWorkerDrawCount(this.subWorkerDrawCount);const c=Math.max(a.getMaxDrawCount(),this.subWorkerDrawCount);a.setMaxDrawCount(c),O.isNumber(o)&&a.setConsumeCount(o)}removeNode(i){const{workId:e}=i,t=e==null?void 0:e.toString();t&&this.workShapes.has(t)&&(this.thread.subLocalLayer.getElementsByName(t).forEach(s=>{s.remove()}),this.clearWorkShapeNodeCache(t))}createLocalWork(i){const{workId:e,toolsType:t,opt:o}=i,s=e==null?void 0:e.toString();t&&this.canUseSubWorkerLayer(t)&&s&&o&&(this.getToolsOpt()||this.setToolsOpt({toolsType:t,toolsOpt:o}),this.setWorkOptions(s,o))}setWorkOptions(i,e){let t=this.workShapes.get(i);if(!t&&this.tmpOpt){const{toolsType:o}=this.tmpOpt;this.tmpOpt.toolsOpt=e,t=this.createWorkShapeNode({workId:i,toolsType:o,toolsOpt:e}),t&&this.workShapes.set(i,t),this.setToolsOpt(this.tmpOpt)}e!=null&&e.syncUnitTime||(e.syncUnitTime=this.syncUnitTime),t&&t.setWorkOptions(e)}destroy(){this.clearAll()}clearAll(){Be(this.thread.subLocalLayer,this.thread.subLocalLayer.parent),this.workShapes.clear()}canUseSubWorkerLayer(i){return i===v.Pencil}setToolsOpt(i){var e;this.tmpOpt=i,(e=i.toolsOpt)!=null&&e.syncUnitTime&&(this.syncUnitTime=i.toolsOpt.syncUnitTime)}createWorkShapeNode(i){return Li({...i,fullLayer:this.thread.subLocalLayer,drawLayer:this.thread.subLocalLayer})}clearWorkShapeNodeCache(i){this.workShapes.delete(i)}getWorkShape(i){return this.workShapes.get(i)}}const Py=async(r,i)=>{const{src:e,isgl:t,isCache:o}=r;if(typeof Image=="function"){const s=new Image;return typeof e=="string"&&(s.crossOrigin="anonymous"),new Promise(n=>{s.onload=function(){createImageBitmap(s,{imageOrientation:t?"flipY":"none"}).then(a=>{n(a)})},s.onerror=function(){n(void 0)},s.src=e})}else return fetch(e,{method:"GET",mode:"cors",cache:"default"}).then(s=>s.blob()).then(s=>createImageBitmap(s,{imageOrientation:t?"flipY":"none"}).then(n=>n))};class Ey{get now(){var i;return((i=this.control.room)==null?void 0:i.calibrationTimestamp)||Date.now()}get newWorkId(){return this.now.toString()}setCurrentToolsData(i){this.currentToolsData=i}getCurrentToolsData(){return this.currentToolsData}setCurrentLocalWorkData(i){this.currentLocalWorkData=i}getWorkId(){return this.currentLocalWorkData.workId}get workState(){return this.currentLocalWorkData.workState}}class Oy extends Ey{constructor(e){super();M(this,"maxLastSyncTime",Me.syncOpt.interval);M(this,"combineUnitTime",Me.bezier.combineUnitTime);M(this,"maxCombineEraserTime",Me.pencilEraser.maxCombineTime);M(this,"smoothSync",Me.syncOpt.smoothSync);M(this,"isActive",!1);M(this,"currentToolsData");M(this,"currentLocalWorkData");M(this,"control");M(this,"internalMsgEmitter");M(this,"publicMsgEmitter");M(this,"taskBatchData",new Set);M(this,"fullWorker");M(this,"subWorker");M(this,"fullWorkerUrl");M(this,"subWorkerUrl");M(this,"methodBuilder");M(this,"zIndexNodeMethod");M(this,"subWorkerDrawCount",0);M(this,"fullWorkerDrawCount",0);M(this,"maxDrawCount",0);M(this,"_consumeCount",0);M(this,"_postCount",0);M(this,"reRenders",new Map);M(this,"localWorkViewId");M(this,"localPointsBatchData",new Map);M(this,"tasksqueue",new Map);M(this,"useTasksqueue",!1);M(this,"useTasksClockId");M(this,"mainTasksqueueCount");M(this,"workerTasksqueueCount");M(this,"snapshotMap",new Map);M(this,"boundingRectMap",new Map);M(this,"clearAllResolveMap",new Map);M(this,"delayWorkStateToDoneResolve");M(this,"animationId");M(this,"tmpImageConfigMap",new Map);M(this,"mainThread");M(this,"willSelectorWorkId");M(this,"isLockSentEventCursor",!1);M(this,"subMainThreadWorker");M(this,"getVNodeInfoResolveMap",new Map);M(this,"setFontFacesResolve",{});M(this,"isLocalWorkActive",!1);const{control:t,internalMsgEmitter:o,publicMsgEmitter:s}=e;this.control=t,this.maxLastSyncTime=this.control.pluginOptions.extras.syncOpt.interval,this.combineUnitTime=this.control.pluginOptions.extras.bezier.combineUnitTime||this.combineUnitTime,this.smoothSync=O.isBoolean(this.control.pluginOptions.extras.syncOpt.smoothSync)?this.control.pluginOptions.extras.syncOpt.smoothSync:this.smoothSync,this.maxCombineEraserTime=this.control.pluginOptions.extras.pencilEraser.maxCombineTime||this.maxCombineEraserTime,this.fullWorkerUrl=this.control.pluginOptions.cdn.fullWorkerUrl||"",this.subWorkerUrl=this.control.pluginOptions.cdn.subWorkerUrl||"",this.internalMsgEmitter=o,this.publicMsgEmitter=s,this.currentLocalWorkData={workState:A.Pending}}get isBezier(){return this.control.pluginOptions.extras.bezier.enable}destroy(){var e,t,o;(e=this.methodBuilder)==null||e.destroy(),this.unWritable(),this.taskBatchData.clear(),this.tasksqueue.clear(),this.tmpImageConfigMap.clear(),this.localPointsBatchData.clear(),this.isActive=!1,this.clearAllResolveMap.clear(),this.snapshotMap.clear(),this.boundingRectMap.clear(),(t=this.fullWorker)==null||t.terminate(),(o=this.subWorker)==null||o.terminate()}get consumeCount(){return this._consumeCount}set consumeCount(e){this._consumeCount=e}get postCount(){return this._postCount}set postCount(e){this._postCount=e}get viewContainerManager(){return this.control.viewContainerManager}get collector(){return this.control.collector}get isRunSubWork(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===v.Pencil||e===v.PencilEraser||e===v.BitMapEraser||e===v.LaserPen||e===v.Arrow||e===v.Straight||e===v.Ellipse||e===v.Rectangle||e===v.Star||e===v.Polygon||e===v.SpeechBalloon||e===v.Selector}get isCanDrawWork(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===v.Pencil||e===v.LaserPen||e===v.Arrow||e===v.Straight||e===v.Ellipse||e===v.Rectangle||e===v.Star||e===v.Polygon||e===v.SpeechBalloon||e===v.Triangle||e===v.Rhombus||e===v.BitMapEraser||e===v.PencilEraser}get isUseZIndex(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===v.Pencil||e===v.Arrow||e===v.Straight||e===v.Ellipse||e===v.Rectangle||e===v.Star||e===v.Polygon||e===v.SpeechBalloon||e===v.Text||e===v.Image}get isCanRecordUndoRedo(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===v.Pencil||e===v.Eraser||e===v.PencilEraser||e===v.BitMapEraser||e===v.Arrow||e===v.Straight||e===v.Ellipse||e===v.Rectangle||e===v.Star||e===v.Polygon||e===v.SpeechBalloon||e===v.Text||e===v.Image}get isCanSentCursor(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===v.Pencil||e===v.Text||e===v.LaserPen||e===v.Arrow||e===v.Straight||e===v.Ellipse||e===v.Rectangle||e===v.Star||e===v.Polygon||e===v.SpeechBalloon||e===v.Triangle||e===v.Rhombus||e===v.Eraser||e===v.PencilEraser||e===v.BitMapEraser||e===v.Selector}get isPostCountType(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===v.Pencil||e===v.Arrow||e===v.Straight||e===v.Ellipse||e===v.Rectangle||e===v.Star||e===v.Polygon||e===v.SpeechBalloon||e===v.Triangle||e===v.Rhombus||e===v.Eraser||e===v.PencilEraser||e===v.BitMapEraser||e===v.Selector}get isCanPostDraw(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===v.Pencil||e===v.PencilEraser||e===v.BitMapEraser}get isCanStartEventConsum(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===v.Selector||e===v.Eraser||e===v.PencilEraser||e===v.BitMapEraser}async init(){this.destroy(),await this.on(),this.internalMsgEmitterListener(),this.isActive=!0}async useMainThread(){console.info("no OffscreenCanvas"),this.control.hasExtendFontFaces&&await document.fonts.ready.then(()=>{this.control.room&&this.control.room.logger.info("set font faces in main thread success")});const{MainThreadManagerImpl:e}=await Promise.resolve().then(()=>require("./index-ggI7Ru6d.js"));this.mainThread=new e(this)}async on(){if(!this.control.hasOffscreenCanvas()){await this.useMainThread();return}if(!this.fullWorkerUrl||!this.subWorkerUrl){console.error("no worker url config");return}if(this.fullWorker=new Worker(this.fullWorkerUrl,{type:"classic"}),this.subWorker=new Worker(this.subWorkerUrl,{type:"classic"}),this.subMainThreadWorker=new Ay(this),this.fullWorker.onmessage=e=>{var t,o;if(e.data){const{render:s,sp:n,fullWorkerDrawCount:a,workerTasksqueueCount:c,viewId:l,consumeCount:u}=e.data;u&&(this.consumeCount=u),this.isBusy&&c&&this.setWorkerTasksqueueCount(c),n!=null&&n.length&&this.collectorSyncData(n);const h=(s==null?void 0:s.length)&&s||[];if(a&&l){if(this.fullWorkerDrawCount=a,this.fullWorkerDrawCount<1/0){const d=Math.max(this.maxDrawCount,this.fullWorkerDrawCount);this.setMaxDrawCount(d),this.control.priority==="ui"?(t=this.subMainThreadWorker)==null||t.notifyDrawCount(l):this.clearReRenders(this.fullWorkerDrawCount)}else this.setMaxDrawCount(0),this.control.priority==="ui"?(o=this.subMainThreadWorker)==null||o.clearDrawCount(l):this.clearReRenders(1/0);if(this.reRenders.size)for(const d of this.reRenders.values())h.push(...d)}h.length&&this.viewContainerManager.render(h)}},this.subWorker.onmessage=e=>{if(e.data){const{render:t,sp:o,subWorkerDrawCount:s,consumeCount:n}=e.data;n&&(this.consumeCount=n),o!=null&&o.length&&this.collectorSyncData(o);const a=(t==null?void 0:t.length)&&t||[];if(this.control.priority==="cpu"&&O.isNumber(s)){if(this.subWorkerDrawCount=s,this.fullWorkerDrawCount<1/0){const c=Math.max(this.maxDrawCount,this.subWorkerDrawCount);this.setMaxDrawCount(c)}if(t!=null&&t.length)if(this.subWorkerDrawCount>this.fullWorkerDrawCount){const c=[];for(const l of t)l.imageBitmap&&(l.isUnClose=!0,c.push(l));this.reRenders.set(this.subWorkerDrawCount,c)}else this.reRenders.size&&this.clearReRenders(this.subWorkerDrawCount)}a.length&&this.viewContainerManager.render(a)}},this.control.hasExtendFontFaces){const e=this.control.extendFontFaces;let t=[],o=[];this.control.room&&this.control.room.logger.info(`load before font faces ${JSON.stringify(e)}`),await new Promise(async s=>{this.setFontFacesResolve.resolve=s,this.setFontFacesResolve.timer=setTimeout(()=>{this.setFontFacesResolve.resolve&&(this.control.room?this.control.room.logger.error("set font faces timeout"):console.warn("set font faces timeout"),this.setFontFacesResolve.resolve(!1))},this.control.loadFontFacesTimeout);try{for(const n of e){const a=await this.loadFontInMainThread(n.src);!a||a.byteLength===0||(o.push({fontFamily:n.fontFamily,buffer:a}),t.push(a))}this.control.room&&this.control.room.logger.info("load end font faces"),this.fullWorker.postMessage(new Set([{type:b.SetFontFace,fontBuffers:o}]),t)}catch(n){this.setFontFacesResolve.timer&&(clearTimeout(this.setFontFacesResolve.timer),this.setFontFacesResolve.timer=void 0),this.setFontFacesResolve.resolve&&(this.setFontFacesResolve.resolve(!1),this.control.room?this.control.room.logger.error(`set font faces error: ${n}`):console.error(`set font faces error: ${n}`))}}).then(s=>{this.setFontFacesResolve.resolve=void 0,this.setFontFacesResolve.timer=void 0,this.control.room?s?this.control.room.logger.info("set font faces in web worker success"):this.control.room.logger.error("set font faces in web worker error"):s||console.error("set font faces in web worker error")})}}async loadFontInMainThread(e){try{const t=await fetch(e);if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);const o=await t.arrayBuffer();if(!o||o.byteLength===0)throw new Error("Empty font data received");const s=new Uint8Array(o);if(!this.validateFontData(s))throw new Error("Invalid font data format: not a valid font file");return o}catch(t){this.control.room?this.control.room.logger.error(`Failed to load font from ${e}: ${t}`):console.error(`Failed to load font from ${e}: ${t}`);return}}validateFontData(e){return e.length<4?!1:e[0]===119&&e[1]===79&&e[2]===70&&e[3]===50||e[0]===119&&e[1]===79&&e[2]===70&&e[3]===70||e[0]===0&&e[1]===1&&e[2]===0&&e[3]===0||e[0]===79&&e[1]===84&&e[2]===84&&e[3]===79||e.length>36&&e[36]===0&&e[37]===1&&e[38]===0&&e[39]===0}clearReRenders(e=1/0){for(const t of this.reRenders.keys())if(O.isNumber(Number(t))&&Number(t)<=e){const o=this.reRenders.get(Number(t));o==null||o.forEach(s=>{var n;(n=s.imageBitmap)==null||n.close()}),this.reRenders.delete(t)}}get isBusy(){return this.getTasksqueueState()===A.Doing}getLockSentEventCursor(){return this.isLockSentEventCursor}setLockSentEventCursor(e){this.isLockSentEventCursor=e}getTasksqueueState(){return this.useTasksqueue&&A.Doing||A.Done}setMaxDrawCount(e){this.maxDrawCount=e}getFullWorkDrawCount(){return this.fullWorkerDrawCount}getMaxDrawCount(){return this.maxDrawCount}setSubWorkerDrawCount(e){this.subWorkerDrawCount=e}setConsumeCount(e){this.consumeCount=e}getConsumeCount(){return this.consumeCount}setWorkerTasksqueueCount(e){const t=Math.max(this.workerTasksqueueCount||0,e);this.workerTasksqueueCount=t}collectorSyncData(e){var o,s,n,a;let t=!1;for(const c of e){const{type:l,selectIds:u,opt:h,selectRect:d,strokeColor:f,fillColor:g,willSyncService:p,isSync:y,imageBitmap:I,canvasHeight:w,canvasWidth:S,rect:C,op:T,canTextEdit:N,points:x,selectorColor:D,canRotate:L,scaleType:z,textOpt:j,toolsType:E,workId:R,viewId:P,dataType:Z,canLock:_,isLocked:B,shapeOpt:J,toolsTypes:ie,thickness:le,strokeType:oe,useStroke:K,isgl:q,imageSrc:de,isSubWorker:Ue,updateNodeOpt:De,setFontFaceResult:ze,failedFonts:Fe}=c;if(l===b.SetFontFace){ze&&this.setFontFacesResolve.resolve&&(Fe&&Fe.length>0&&(this.control.room?this.control.room.logger.info("set font face has failed fonts: "+Fe.join(", ")):console.info("set font face has failed fonts: "+Fe.join(", "))),this.setFontFacesResolve.resolve(ze));return}if(!P)return;const He=c.scenePath||this.viewContainerManager.getCurScenePath(P);switch(l){case b.Select:{const ee=u!=null&&u.length?{...d,selectIds:u,canvasHeight:w,canvasWidth:S,points:x}:void 0;ee&&(h!=null&&h.strokeColor)&&(ee.selectorColor=h.strokeColor),ee&&D&&(ee.selectorColor=D),ee&&f&&(ee.strokeColor=f),ee&&(h!=null&&h.fillColor)&&(ee.fillColor=h.fillColor),ee&&g&&(ee.fillColor=g),ee&&O.isBoolean(L)&&(ee.canRotate=L),ee&&z&&(ee.scaleType=z),ee&&N&&(ee.canTextEdit=N),ee&&j&&(ee.textOpt=j),ee&&O.isBoolean(_)&&(ee.canLock=_),ee&&O.isBoolean(B)&&(ee.isLocked=B),ee&&J&&(ee.shapeOpt=J),ee&&ie&&(ee.toolsTypes=ie),ee&&le&&(ee.thickness=le),ee&&oe&&(ee.strokeType=oe),ee&&O.isBoolean(K)&&(ee.useStroke=K),P&&this.viewContainerManager.showFloatBar(P,!!ee,ee),p&&((o=this.collector)==null||o.dispatch({type:l,selectIds:u,opt:h,isSync:y,viewId:P,scenePath:He}));break}case b.Snapshot:if(I&&He){const ee=this.snapshotMap.get(He);ee&&ee(I)}break;case b.BoundingBox:if(C&&He){const ee=this.boundingRectMap.get(He);ee&&ee(C)}break;case b.Cursor:T&&this.control.cursor.collectServiceCursor({...c});break;case b.Clear:if(P){this.viewContainerManager.showFloatBar(P,!1);const ee=(s=this.clearAllResolveMap.get(P))==null?void 0:s.resolve;ee&&ee(P)}break;case b.TextUpdate:if(E===v.Text&&R&&P){const ee=this.viewContainerManager.transformToOriginPoint((h==null?void 0:h.boxPoint)||[0,0],P),$=(h==null?void 0:h.boxSize)||[0,0],X=(n=this.viewContainerManager.getView(P))==null?void 0:n.cameraOpt;h?this.control.textEditorManager.updateTextForWorker({x:ee[0],y:ee[1],w:$[0],h:$[1],scale:(X==null?void 0:X.scale)||1,workId:R,opt:h,dataType:Z,viewId:P,canSync:p||!1,canWorker:!1,updateNodeOpt:De}):this.control.textEditorManager.delete(R,p||!1,!1)}break;case b.GetTextActive:E===v.Text&&R&&P&&this.control.textEditorManager.updateTextForWorker({workId:R,isActive:!0,viewId:P,dataType:V.Local,canWorker:!1,canSync:!0},this.now);break;case b.GetImageBitMap:de&&P&&R&&Py({src:de,isgl:q}).then(ee=>{var X;const $=new Set;if($.add({msgType:b.GetImageBitMap,dataType:V.Local,workId:R,viewId:P,imageSrc:de,isSubWorker:Ue,imageBitmap:ee}),!this.control.hasOffscreenCanvas())(X=this.mainThread)==null||X.consume($);else{const te=Ue?this.subWorker:this.fullWorker;ee?te.postMessage($,[ee]):te.postMessage($)}});break;case b.GetVNodeInfo:if(R){const ee=R.toString(),$=(a=this.getVNodeInfoResolveMap.get(ee))==null?void 0:a.resolve,X={...c,uuid:ee};$&&$(X)}break;default:t=!0;break}}t&&this.collectorAsyncData(e)}collectorAsyncData(e){var t,o,s,n;for(const a of e){const{type:c,op:l,workId:u,index:h,removeIds:d,ops:f,opt:g,updateNodeOpt:p,toolsType:y,isSync:I,viewId:w,isLockSentEventCursor:S,nextTasks:C}=a;if(!w){console.error("[MasterControlForWorker] collectorAsyncData on viewId in",a);return}const T=a.scenePath||this.viewContainerManager.getCurScenePath(w);switch(c){case b.None:{S&&it(()=>{this.setLockSentEventCursor(!1)},this.maxLastSyncTime);break}case b.DrawWork:{(t=this.collector)==null||t.dispatch({type:c,op:l,opt:g,toolsType:y,workId:u,index:h,isSync:I,viewId:w,scenePath:T,updateNodeOpt:p});break}case b.FullWork:{(o=this.collector)==null||o.dispatch({type:c,ops:f,workId:u,updateNodeOpt:p,opt:g,toolsType:y,isSync:I,viewId:w,scenePath:T}),this.willSelectorWorkId&&u&&u.toString()===this.willSelectorWorkId&&this.control.runEffectWork(()=>{this.setShapeSelectorByWorkId(this.willSelectorWorkId,w),this.willSelectorWorkId=void 0});break}case b.UpdateNode:{(s=this.collector)==null||s.dispatch({type:c,updateNodeOpt:p,workId:u,opt:g,ops:f,op:l,isSync:I,viewId:w,scenePath:T});break}case b.RemoveNode:{d&&this.control.textEditorManager.deleteBatch(d,!1,!1),(n=this.collector)==null||n.dispatch({type:c,removeIds:d,isSync:I,viewId:w,scenePath:T}),this.willSelectorWorkId&&(d!=null&&d.includes(this.willSelectorWorkId))&&(this.willSelectorWorkId=void 0);break}}C&&this.collectorAsyncData(C)}}async onLocalEventEnd(e,t){var l;const o=this.viewContainerManager.getView(t);if(!o)return;const{focusScenePath:s,cameraOpt:n}=o,a=this.viewContainerManager.transformToScenePoint(e,t),c=[];for(const u of this.localPointsBatchData.keys())if(((l=this.currentToolsData)==null?void 0:l.toolsType)===v.Text){const h=this.getLocalPointInfo(u),d=h==null?void 0:h.state;if(d&&d===A.Start){const f=this.currentLocalWorkData.toolsOpt;f.workState=A.Doing,f.boxPoint=a,f.boxSize=[f.fontSize,f.fontSize],this.control.textEditorManager.checkEmptyTextBlur(),this.control.textEditorManager.createTextForMasterController({workId:this.newWorkId,x:e[0],y:e[1],scale:(n==null?void 0:n.scale)||1,opt:f,type:ot.Text,isActive:!0,viewId:t,scenePath:s},this.now)}this.deleteLocalPoint(u);continue}else this.pushLocalPoint(u,a,A.Done,t),c.push(u);if(c.length){try{if(await new Promise(h=>{setTimeout(async()=>{c.forEach(d=>{this.setLocalPointIsFullWork(d)}),this.delayWorkStateToDoneResolve=h,this.consume()},0)})&&c[0]){const h=c[0];c.forEach(d=>{this.deleteLocalPoint(d)}),this.willSelectorWorkId=h.toString()}}catch(u){console.error("[MasterControlForWorker] onLocalEventEnd error:",u)}this.delayWorkStateToDoneResolve=void 0,c.length=0}}onLocalEventDoing(e,t){var s;if(((s=this.currentToolsData)==null?void 0:s.toolsType)===v.Text)return;this.currentLocalWorkData.workState===A.Start&&this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:A.Doing});let o=!1;for(const[n,{state:a}]of this.localPointsBatchData.entries())if(this.isAbled()&&a!==A.Pending){const c=this.viewContainerManager.transformToScenePoint(e,t);this.pushLocalPoint(n,c,a===A.Start?A.Doing:a,t),o=!0}if(o){this.runAnimation();return}}onLocalEventStart(e,t){var c,l,u;this.viewContainerManager.focuedViewId!==t&&this.viewContainerManager.setFocuedViewId(t),this.isCanDrawWork&&this.control.room&&!this.control.room.disableDeviceInputs&&(this.control.room.disableDeviceInputs=!0);const o=(c=this.currentToolsData)==null?void 0:c.toolsType,s=o===v.Selector?G:this.newWorkId,n=this.setZIndex(t);this.setCurrentLocalWorkData({workState:A.Start,toolsOpt:n,viewId:t});const a=this.viewContainerManager.transformToScenePoint(e,t);if(this.pushLocalPoint(s,a,A.Start,t,n),o!==v.Text){if(this.control.textEditorManager.checkEmptyTextBlur(),this.isCanRecordUndoRedo&&this.internalMsgEmitter.emit("addUndoTicker",s,t),s&&n&&o&&this.isCanStartEventConsum&&this.prepareOnceWork({workId:s,toolsOpt:n,viewId:t},o),this.consumeCount=0,this.postCount=0,this.maxDrawCount=0,this.fullWorkerDrawCount=0,this.subWorkerDrawCount=0,this.clearReRenders(1/0),(l=this.subMainThreadWorker)==null||l.clearDrawCount(t),this.isCanDrawWork){const h=this.viewContainerManager.getCurScenePath(t);h&&((u=this.collector)!=null&&u.hasSelector(t,h))&&this.blurSelector(t,h)}this.consume()}}setLocalPointIsFullWork(e){const t=this.getLocalPointInfo(e);t&&(t.isFullWork=!0,this.localPointsBatchData.set(e,t))}pushLocalPoint(e,t,o,s,n){let a=this.getLocalPointInfo(e);o===A.Start?a={state:A.Start,points:t,opt:n||this.currentLocalWorkData.toolsOpt,isFullWork:!1,viewId:s}:a&&(a.state=o,a.points.push(t[0],t[1])),a&&this.localPointsBatchData.set(e,a)}deleteLocalPoint(e){this.localPointsBatchData.delete(e)}getLocalPointInfo(e){return this.localPointsBatchData.get(e)}getLocalPointsInfo(){return this.localPointsBatchData}correctStorage(e,t,o){var c;const s=new Map,n=[];Object.keys(e).forEach(l=>{var h,d;const u=(d=(h=e[l])==null?void 0:h.opt)==null?void 0:d.zIndex;O.isNumber(u)&&n.push([l,u])});const a=n.length&&((c=this.zIndexNodeMethod)==null?void 0:c.correct(n))||[];this.zIndexNodeMethod&&a.length&&(this.zIndexNodeMethod.setMinZIndex(a[0][1]||0,t),this.zIndexNodeMethod.setMaxZIndex(a[a.length-1][1]||0,t));for(const[l,u]of a){if(!e[l])continue;const h=e[l];h.opt&&O.isNumber(h.opt.zIndex)&&h.opt.zIndex!==u&&(h.opt.zIndex=u,s.set(l,h))}return s.size&&s.forEach((l,u)=>{var h;(h=this.collector)==null||h.updateValue(u,l,{viewId:t,scenePath:o,isSync:!0}),e[u]=l}),e}async originalEventLintener(e,t,o){var c,l,u;if(!this.isAbled())return;const s=(c=this.collector)==null?void 0:c.uid,n=this.viewContainerManager.getCurScenePath(o);if(s&&!this.control.renderControl.isWritable)return;const a=((l=this.currentToolsData)==null?void 0:l.toolsType)===v.Selector;switch((u=this.currentToolsData)==null?void 0:u.toolsType){case v.Eraser:case v.PencilEraser:case v.BitMapEraser:{if(s&&!this.control.renderControl.isClearAble({uid:s,viewId:o,scenePath:n}))return;break}default:{if(s&&!this.control.renderControl.isRenderAble({uid:s,viewId:o,scenePath:n}))return;break}}switch(it(()=>{this.control.pluginManager.dispatchPluginEvent("localEvent",o,e,t)},Mo,this.control.hasPolyfillMethod("requestIdleCallback")),e){case A.Start:this.isLocalWorkActive=!0,this.setLocalWorkViewId(o),o&&this.onLocalEventStart(t,o),a&&this.viewContainerManager.showFloatBarBtn(o,!1);break;case A.Doing:o&&o===this.getLocalWorkViewId()&&this.onLocalEventDoing(t,o);break;case A.Done:o&&o===this.getLocalWorkViewId()&&(this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:A.Done}),await this.onLocalEventEnd(t,o),setTimeout(()=>{this.isLocalWorkActive=!1,this.setCurrentLocalWorkData({workState:A.Pending}),a&&this.viewContainerManager.showFloatBarBtn(o,!0),this.setLocalWorkViewId(void 0)},0));break}this.isLocalWorkActive&&this.viewContainerManager.focuedViewId===o&&this.publicMsgEmitter.emit("workState",e,o)}getLocalWorkViewId(){return this.localWorkViewId}setLocalWorkViewId(e){this.localWorkViewId=e}setCurrentToolsData(e){var s,n,a;const t=e.toolsType,o=((s=this.currentToolsData)==null?void 0:s.toolsType)!==e.toolsType;if(super.setCurrentToolsData(e),o){const c=(n=this.viewContainerManager)==null?void 0:n.getAllViews();for(const l of c)if(l){const{id:u,focusScenePath:h}=l;o&&u&&h&&((a=this.collector)!=null&&a.hasSelector(u,h)&&this.blurSelector(u,h),this.control.textEditorManager.checkEmptyTextBlur())}this.taskBatchData.add({msgType:b.UpdateTools,dataType:V.Local,toolsType:t,opt:{...e.toolsOpt,syncUnitTime:this.maxLastSyncTime},combineUnitTime:this.isBezier?this.combineUnitTime:1/0,maxCombineEraserTime:this.maxCombineEraserTime,isRunSubWork:this.isRunSubWork,viewId:ai}),this.runAnimation()}}prepareOnceWork(e,t){const{workId:o,toolsOpt:s,viewId:n}=e,a={msgType:b.CreateWork,dataType:V.Local,viewId:n,toolsType:t};this.queryTaskBatchData(a).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({...a,workId:o,opt:{...s,syncUnitTime:this.maxLastSyncTime},dataType:V.Local,isRunSubWork:this.isRunSubWork}),this.runAnimation()}createViewWorker(e,t){const{offscreenCanvasOpt:o,layerOpt:s,dpr:n,cameraOpt:a}=t;this.taskBatchData.add({msgType:b.Init,dataType:V.Local,viewId:e,offscreenCanvasOpt:o,layerOpt:s,dpr:n,cameraOpt:a,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1,combineUnitTime:this.isBezier?this.combineUnitTime:1/0,maxCombineEraserTime:this.maxCombineEraserTime,syncUnitTime:this.maxLastSyncTime}),this.isBusy&&this.destroyTaskQueue(),this.consume()}destroyViewWorker(e,t=!1){var o;this.getLocalWorkViewId()===e&&this.setLocalWorkViewId(void 0),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(e),this.taskBatchData.add({msgType:b.Destroy,dataType:V.Local,viewId:e,isRunSubWork:!0}),this.consume(),t||(o=this.collector)==null||o.dispatch({type:b.Clear,viewId:e}),this.control.renderControl.destoryByViewId(e,t)}onServiceDerive(e,t){var f,g,p,y,I,w,S,C;const{newValue:o,oldValue:s,viewId:n,scenePath:a}=t,c=O.cloneDeep(o)||{},l=e;let u=c.type;if(!o&&s){if(l&&((f=this.collector)==null?void 0:f.getLocalId(l))===G){this.collector.isOwn(l)?this.blurSelector(n,a):this.blurSelector(n,a,l);return}if(u=b.RemoveNode,s.toolsType===v.LaserPen)return}const h=(g=this.viewContainerManager.getView(n))==null?void 0:g.focusScenePath;if(h&&h!==a)return;if((p=this.collector)!=null&&p.isSelector(e)){const T=(y=this.collector)==null?void 0:y.getUidFromKey(e);if(T&&!this.control.roomMember.isOnLine(T))return}if(u&&l){if(!this.control.renderControl.isFilterAble({viewId:n,elementId:e,scenePath:a},u))return;const T=c;if(T.workId=(I=this.collector)!=null&&I.isOwn(l)?(w=this.collector)==null?void 0:w.getLocalId(l):l,T.msgType=u,T.toolsType===v.LaserPen&&(T.isRunSubWork=!0),T.dataType=V.Service,T.viewId=n,T.scenePath=a,T.useAnimation=this.smoothSync&&((S=T.updateNodeOpt)==null?void 0:S.useAnimation)||!1,T.selectIds&&(T.selectIds=T.selectIds.map(N=>{var x,D;return(x=this.collector)!=null&&x.isOwn(N)?(D=this.collector)==null?void 0:D.getLocalId(N):N})),T&&T.toolsType===v.Text||(s==null?void 0:s.toolsType)===v.Text){this.control.textEditorManager.onServiceDerive(T);return}T.isEnableCursor=this.control.cursor.isEnableCursor,this.taskBatchData.add(T)}this.runAnimation();const d=t.newValue&&((C=t.newValue.opt)==null?void 0:C.zIndex);if(this.zIndexNodeMethod&&O.isNumber(d)){const T=this.zIndexNodeMethod.getMinZIndex(n);this.zIndexNodeMethod.getMaxZIndex(n)<d&&this.zIndexNodeMethod.setMaxZIndex(d,n),T>d&&this.zIndexNodeMethod.setMinZIndex(d,n)}}pullServiceData(e,t,o={isAsync:!1,useAnimation:!1}){var c,l,u,h,d,f,g;let s=(c=this.collector)==null?void 0:c.getStorageData(e,t);const{isAsync:n,useAnimation:a}=o;if(s){this.control.renderControl.isWritable&&(s=this.correctStorage(s,e,t));const p=Object.keys(s);for(const y of p){if((l=this.collector)!=null&&l.isSelector(y)){const w=(u=this.collector)==null?void 0:u.getUidFromKey(y);if(w&&!this.control.roomMember.isOnLine(w))continue}const I=(h=s[y])==null?void 0:h.type;if(I&&y){if(!this.control.renderControl.isFilterAble({viewId:e,elementId:y,scenePath:t},I))continue;const w=s[y];if(w.workId=(d=this.collector)!=null&&d.isOwn(y)?(f=this.collector)==null?void 0:f.getLocalId(y):y,w.msgType=I,w.dataType=V.Service,w.viewId=e,w.scenePath=t,w.useAnimation=this.smoothSync&&(w.ops?!!a:(g=w.updateNodeOpt)==null?void 0:g.useAnimation)||!1,w.selectIds&&(w.selectIds=w.selectIds.map(S=>{var C,T;return(C=this.collector)!=null&&C.isOwn(S)?(T=this.collector)==null?void 0:T.getLocalId(S):S})),w.toolsType===v.Text){this.control.textEditorManager.onServiceDerive(w);continue}n&&w.updateNodeOpt&&w.updateNodeOpt.useAnimation&&(w.updateNodeOpt.useAnimation=!1),w.isEnableCursor=this.control.cursor.isEnableCursor,this.taskBatchData.add(w)}this.internalMsgEmitter.emit("excludeIds",p,e)}n?this.consume():this.runAnimation()}}runAnimation(){!this.animationId&&!this.isBusy&&(this.animationId=requestAnimationFrame(this.consume.bind(this)))}consume(){var t;this.animationId=void 0;const{viewId:e}=this.currentLocalWorkData;if(this.tasksqueue.size){const o=this.consumeQueue(),s=!!o.size;if(this.taskBatchData.size)for(const n of this.taskBatchData.values())n.dataType===V.Service&&(o.add(n),this.taskBatchData.delete(n));o.size?(this.post(o),s&&this.tasksqueue.clear()):this.tasksqueue.size&&(this.animationId=requestAnimationFrame(this.consume.bind(this)));return}if(this.isAbled()&&this.localPointsBatchData.size&&e)for(const[o,{state:s,isFullWork:n,points:a,opt:c}]of this.localPointsBatchData.entries()){if(s===A.Done&&!n||s===A.Start&&!this.isCanStartEventConsum)continue;const l=a.map(u=>u);if(l.length){if(this.isPostCountType&&s===A.Doing){if(this.postCount>this.consumeCount)continue;this.postCount++}this.delayWorkStateToDoneResolve&&s===A.Done&&(this.delayWorkStateToDoneResolve(!0),this.setLockSentEventCursor(!0)),this.taskBatchData.add({op:l,workState:s,workId:o,dataType:V.Local,msgType:b.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(t=this.currentToolsData)==null?void 0:t.toolsType,viewId:e,scenePath:e&&this.viewContainerManager.getCurScenePath(e),opt:c,smoothSync:this.smoothSync,isLockSentEventCursor:this.getLockSentEventCursor(),syncUnitTime:this.maxLastSyncTime,disableEraseImage:this.control.disableEraseImage,disableEraseText:this.control.disableEraseText,postCount:this.isPostCountType&&this.postCount||void 0,fullWorkerDrawCount:this.isCanPostDraw&&this.fullWorkerDrawCount||void 0}),a.length=0}}this.taskBatchData.size&&(this.post(this.taskBatchData),this.taskBatchData.clear()),this.taskBatchData.size&&(this.animationId=requestAnimationFrame(this.consume.bind(this)))}unWritable(){this.setCurrentLocalWorkData({workState:A.Unwritable}),this.setLockSentEventCursor(!0)}abled(){this.setCurrentLocalWorkData({workState:A.Pending}),this.setLockSentEventCursor(!1)}isAbled(){return this.currentLocalWorkData.workState!==A.Unwritable}post(e){var o;if(!this.control.hasOffscreenCanvas()){if(!this.mainThread){let s=[];s=O.cloneDeep([...e]),setTimeout(()=>{for(const n of s)this.taskBatchData.add(n)},0);return}this.mainThread.consume(e);return}this.fullWorker.postMessage(e);const t=new Set;for(const s of e.values()){const n=s.msgType;(n===b.Init||n===b.Clear||n===b.Destroy||n===b.UpdateCamera||s.isRunSubWork)&&t.add(s)}t.size&&(this.subWorker.postMessage(t),this.control.priority==="ui"&&((o=this.subMainThreadWorker)==null||o.consume(t)))}updateNode(e,t,o,s){this.taskBatchData.add({msgType:b.UpdateNode,workId:e,updateNodeOpt:t,viewId:o,scenePath:s,dataType:V.Local}),this.runAnimation()}destroyTaskQueue(){this.useTasksqueue=!1,this.useTasksClockId&&(clearTimeout(this.useTasksClockId),this.useTasksClockId=void 0),this.mainTasksqueueCount=void 0,this.workerTasksqueueCount=void 0}updateDpr(e,t){this.queryTaskBatchData({msgType:b.UpdateDpr,dataType:V.Local,viewId:e}).forEach(o=>{this.taskBatchData.delete(o)}),this.taskBatchData.add({dataType:V.Local,msgType:b.UpdateDpr,viewId:e,dpr:t,isRunSubWork:!0}),this.runAnimation()}updateCamera(e,t){var o;this.useTasksqueue||((o=this.methodBuilder)==null||o.pause(),this.blurCursor(e),this.checkDrawingWork(e),this.useTasksqueue=!0,this.mainTasksqueueCount=1,this.workerTasksqueueCount=1),this.useTasksqueue&&(this.tasksqueue.set(e,{msgType:b.UpdateCamera,dataType:V.Local,cameraOpt:{...t,width:t.width,height:t.height},scenePath:this.viewContainerManager.getCurScenePath(e),isRunSubWork:!0,viewId:e}),this.consume(),this.useTasksClockId&&clearTimeout(this.useTasksClockId),this.updateCameraDone())}updateCameraDone(){this.useTasksClockId=setTimeout(()=>{var e,t;this.useTasksClockId=void 0,this.mainTasksqueueCount===this.workerTasksqueueCount?(this.tasksqueue.size&&this.consume(),this.useTasksqueue=!1,this.mainTasksqueueCount=void 0,this.workerTasksqueueCount=void 0,this.control.priority==="ui"&&((e=this.subMainThreadWorker)==null||e.updateCamera()),(t=this.methodBuilder)==null||t.recover(),this.runAnimation()):this.updateCameraDone()},this.maxLastSyncTime)}consumeQueue(){const e=new Set;let t=!this.isBusy;if(this.isBusy&&this.mainTasksqueueCount&&this.workerTasksqueueCount&&this.mainTasksqueueCount<=this.workerTasksqueueCount&&(t=!0),t){this.mainTasksqueueCount&&this.workerTasksqueueCount&&this.mainTasksqueueCount++,e.add({msgType:b.TasksQueue,dataType:V.Local,isRunSubWork:!0,mainTasksqueueCount:this.mainTasksqueueCount,tasksqueue:this.tasksqueue,viewId:""});for(const[o,s]of this.tasksqueue.entries())s.cameraOpt&&this.control.textEditorManager.onCameraChange(s.cameraOpt,o)}return e}async clearViewScenePath(e,t,o){var n,a;const s=this.viewContainerManager.getCurScenePath(e);if(o){const c=(n=this.collector)==null?void 0:n.uid;if(c&&!this.control.renderControl.isClearAble({uid:c,viewId:e,scenePath:s}))return}this.control.textEditorManager.clear(e,t),this.queryTaskBatchData({msgType:b.Clear,dataType:V.Local,viewId:e}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({dataType:V.Local,msgType:b.Clear,viewId:e}),this.runAnimation(),t||(this.control.renderControl.isUsePageAuth(e)&&s?this.control.renderControl.clearRenderPage(e,s):(a=this.collector)==null||a.dispatch({type:b.Clear,viewId:e,scenePath:s})),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(e);for(const[c,l]of this.localPointsBatchData.entries())l.viewId===e&&this.localPointsBatchData.delete(c);await new Promise(c=>{const l=this.clearAllResolveMap.get(e)||{resolve:void 0,timer:void 0};l.timer&&clearTimeout(l.timer),l.resolve=c,l.timer=setTimeout(()=>{const u=this.clearAllResolveMap.get(e);u!=null&&u.resolve&&u.resolve(e)},this.maxLastSyncTime),this.clearAllResolveMap.set(e,l)}).then(c=>{this.clearAllResolveMap.delete(c)})}internalMsgEmitterListener(){var e;this.methodBuilder=new ae([F.CopyNode,F.SetColorNode,F.DeleteNode,F.RotateNode,F.ScaleNode,F.TranslateNode,F.ZIndexNode,F.SetFontStyle,F.SetPoint,F.SetLock,F.SetShapeOpt]).registerForMainEngine(ne.MainEngine,this.control),this.zIndexNodeMethod=(e=this.methodBuilder)==null?void 0:e.getBuilder(F.ZIndexNode)}setZIndex(e){const t=this.currentToolsData&&O.cloneDeep(this.currentToolsData.toolsOpt);return t&&this.zIndexNodeMethod&&this.isUseZIndex&&(this.zIndexNodeMethod.addMaxLayer(e),t.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),t}checkDrawingWork(e){var s,n,a;let t=!1;const o=[];for(const[c,{state:l,viewId:u,points:h,opt:d}]of this.localPointsBatchData.entries())if(e===u&&l===A.Start||l===A.Doing){if(l===A.Doing&&this.isCanDrawWork){Number(c)&&Number(c)+60>this.now&&(o.push(c.toString()),this.taskBatchData.add({msgType:b.RemoveNode,workId:c,viewId:u,dataType:V.Local,isRunSubWork:!0}));const f=h.map(g=>g);this.taskBatchData.add({op:f,workState:A.Done,workId:c,dataType:V.Local,msgType:b.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(s=this.currentToolsData)==null?void 0:s.toolsType,viewId:u,opt:d,scenePath:u&&this.viewContainerManager.getCurScenePath(u)}),t=!0}this.deleteLocalPoint(c)}if((t||o.length)&&(this.consume(),o.length)){const c=(n=this.viewContainerManager.getView(e))==null?void 0:n.focusScenePath;(a=this.collector)==null||a.dispatch({type:b.RemoveNode,removeIds:o,viewId:e,scenePath:c})}}removeDrawingWork(e){var o,s;const t=[];for(const[n,{state:a,viewId:c}]of this.localPointsBatchData.entries())(e===c&&a===A.Start||a===A.Doing)&&(this.deleteLocalPoint(n),a===A.Doing&&this.isCanDrawWork&&(t.push(n.toString()),this.taskBatchData.add({msgType:b.RemoveNode,workId:n,viewId:c,dataType:V.Local,isRunSubWork:!0})));if(t.length){this.consume();const n=(o=this.viewContainerManager.getView(e))==null?void 0:o.focusScenePath;(s=this.collector)==null||s.dispatch({type:b.RemoveNode,removeIds:t,viewId:e,scenePath:n})}}removeNodes(e,t){var s,n;const o=(s=this.viewContainerManager.getView(e))==null?void 0:s.focusScenePath;if(o&&t.length){for(const a of t)this.taskBatchData.add({msgType:b.RemoveNode,workId:a,viewId:e,dataType:V.Local,isRunSubWork:!1});this.consume(),(n=this.collector)==null||n.dispatch({type:b.RemoveNode,removeIds:t,viewId:e,scenePath:o})}}hoverCursor(e,t){var o;if(((o=this.currentToolsData)==null?void 0:o.toolsType)===v.Selector&&!this.isBusy){const s=this.viewContainerManager.getView(t);if(s&&s.displayer&&s.displayer.vDom){const c=s.displayer.vDom.state.floatBarData;if(c){const{x:l,y:u,w:h,h:d}=c;if(wn(e,{x:l,y:u,w:h,h:d}))return}}const n=this.viewContainerManager.transformToScenePoint(e,t),a={msgType:b.CursorHover,dataType:V.Local,point:n,toolsType:this.currentToolsData.toolsType,opt:this.currentToolsData.toolsOpt,isRunSubWork:!1,viewId:t};this.queryTaskBatchData({msgType:b.CursorHover,dataType:V.Local,toolsType:this.currentToolsData.toolsType,viewId:t}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add(a),this.runAnimation()}}blurCursor(e){var o;if(((o=this.currentToolsData)==null?void 0:o.toolsType)!==v.Selector)return;const t={msgType:b.CursorBlur,dataType:V.Local,isRunSubWork:!1,viewId:e};this.queryTaskBatchData({msgType:b.CursorHover,dataType:V.Local,viewId:e}).forEach(s=>{this.taskBatchData.delete(s)}),this.taskBatchData.add(t),this.consume()}sendCursorEvent(e,t){var c,l,u;if(!this.currentLocalWorkData||this.currentLocalWorkData.workState===A.Unwritable||this.isBusy)return;const o=(c=this.currentToolsData)==null?void 0:c.toolsType;if(!this.useTasksqueue&&this.workState===A.Pending&&o===v.Selector&&(O.isNumber(e[0])&&O.isNumber(e[1])?this.hoverCursor(e,t):e[0]===void 0&&e[1]===void 0&&this.blurCursor(t)),!this.currentToolsData||!this.isCanSentCursor||!this.control.pluginOptions.extras.cursor.enable)return;const s=(l=this.collector)==null?void 0:l.uid,n=this.viewContainerManager.getCurScenePath(t);switch((u=this.currentToolsData)==null?void 0:u.toolsType){case v.Eraser:case v.PencilEraser:case v.BitMapEraser:{if(s&&!this.control.renderControl.isClearAble({uid:s,viewId:t,filterLocalSelf:!1,scenePath:n}))return;break}default:if(s&&!this.control.renderControl.isWritable||s&&!this.control.renderControl.isRenderAble({uid:s,viewId:t,filterLocalSelf:!1,scenePath:n}))return;break}let a=[void 0,void 0];this.currentToolsData&&this.isCanSentCursor&&!this.localPointsBatchData.size&&!this.getLockSentEventCursor()&&(a=e,this.control.cursor.sendEvent(a,t))}getBoundingRect(e){var o,s;if(!((o=this.boundingRectMap)==null?void 0:o.get(e))){const n=(s=this.collector)==null?void 0:s.getScenePathData(e);if(!n)return;if(Object.keys(n).forEach(a=>{var c;((c=this.collector)==null?void 0:c.getLocalId(a))===G&&delete n[a]}),Object.keys(n).length&&this.viewContainerManager.mainView&&this.viewContainerManager.mainView.cameraOpt){const a={msgType:b.BoundingBox,dataType:V.Local,scenePath:e,scenes:n,cameraOpt:{...this.viewContainerManager.mainView.cameraOpt},isRunSubWork:!0,viewId:this.viewContainerManager.mainView.id};return this.taskBatchData.add(a),this.runAnimation(),new Promise(c=>{this.boundingRectMap.set(e,c)}).then(c=>(this.boundingRectMap.delete(e),c))}}}getSnapshot(e,t,o,s){var a,c,l,u,h;if(!((a=this.snapshotMap)==null?void 0:a.get(e))){const d=(c=this.collector)==null?void 0:c.getViewIdBySecenPath(e);if(!d)return;const f=(l=this.collector)==null?void 0:l.getStorageData(d,e);if(!f)return;if(Object.keys(f).forEach(g=>{var p;((p=this.collector)==null?void 0:p.getLocalId(g))===G&&delete f[g]}),Object.keys(f).length){const g=this.viewContainerManager.mainView;if(!g)return;const p=t||((u=g.cameraOpt)==null?void 0:u.width),y=o||((h=g.cameraOpt)==null?void 0:h.height),I={msgType:b.Snapshot,dataType:V.Local,scenePath:e,scenes:f,w:p,h:y,cameraOpt:s&&{...s,width:p,height:y}||g.cameraOpt,isRunSubWork:!0,viewId:g.id};return this.taskBatchData.add(I),this.runAnimation(),new Promise(w=>{this.snapshotMap.set(e,w)}).then(w=>(this.snapshotMap.delete(e),w))}}}queryTaskBatchData(e){const t=[];if(e)for(const o of this.taskBatchData.values()){let s=!0;for(const[n,a]of Object.entries(e))if(o[n]!==a){s=!1;break}s&&t.push(o)}return t}insertIconify(e,t){var a;const o=this.viewContainerManager.getView(e);if(!o)throw new Error("insertIconify viewId is not exist");if(!t.src)throw new Error("iconify src must be required");if(!/^(http|https):\/\//.test(t.src))throw new Error("iconify src must be http or https");t.strokeColor||(t.strokeColor=(a=this.currentLocalWorkData.toolsOpt)==null?void 0:a.strokeColor);const n=o==null?void 0:o.focusScenePath;if(e&&n){const c=this.now;xe.InternalMsgEmitter.emit("addUndoTicker",c,e);const l={...t,type:St.Iconify};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:b.FullWork,dataType:V.Local,toolsType:v.Image,workId:t.uuid,opt:l,viewId:e,willRefresh:!0,willSyncService:!0}),this.runAnimation()}}insertImage(e,t){const o=this.viewContainerManager.getView(e);if(!o)throw new Error("insertImage viewId is not exist");if(t.src&&!/^(http|https):\/\//.test(t.src))throw new Error("Image src must be http or https");const s=o==null?void 0:o.focusScenePath;if(e&&s){const{src:n,uuid:a}=t;if(a&&!n){this.tmpImageConfigMap.set(a,t);return}const c=this.now;xe.InternalMsgEmitter.emit("addUndoTicker",c,e);const l={...t,type:St.Image};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:b.FullWork,dataType:V.Local,toolsType:v.Image,workId:t.uuid,opt:l,viewId:e,willRefresh:!0,willSyncService:!0}),this.runAnimation()}}lockImage(e,t,o){var a,c;const s=this.viewContainerManager.getView(e);if(!s)throw new Error("insertImage viewId is not exist");const n=s==null?void 0:s.focusScenePath;if(e&&n&&this.collector){const l=this.collector.getStorageData(e,n);if(!l)return;for(const[u,h]of Object.entries(l))if(h&&h.toolsType===v.Image&&h.opt.uuid===t){const d=this.now;xe.InternalMsgEmitter.emit("addUndoTicker",d,e);const f=(a=this.collector)!=null&&a.isOwn(u)?(c=this.collector)==null?void 0:c.getLocalId(u):u,g={...h.opt,locked:o,type:St.Image};this.taskBatchData.add({msgType:b.FullWork,dataType:V.Local,toolsType:v.Image,workId:f,opt:g,viewId:e,willRefresh:!0,willSyncService:!0}),this.runAnimation();return}}}completeImageUpload(e,t,o){const s=this.viewContainerManager.getView(e);if(!s)throw new Error("insertImage viewId is not exist");const n=s==null?void 0:s.focusScenePath;if(e&&n){const a=this.tmpImageConfigMap.get(t);a&&(a.src=o,this.insertImage(e,a),this.tmpImageConfigMap.delete(t));return}}getImagesInformation(e){const t=[];if(this.collector){const o=this.collector.getScenePathData(e);if(!o)return t;for(const s of Object.values(o))if(s&&s.toolsType===v.Image){const n=s.opt;t.push({uuid:n.uuid,centerX:n.centerX,centerY:n.centerY,width:n.width,height:n.height,locked:n.locked,uniformScale:n.uniformScale,crossOrigin:n.crossOrigin})}}return t}setShapeSelectorByWorkId(e,t){this.taskBatchData.add({workId:G,selectIds:[e],msgType:b.Select,dataType:V.Local,viewId:t,willSyncService:!0}),this.runAnimation()}blurSelector(e,t,o){this.taskBatchData.add({workId:o||G,selectIds:[],msgType:b.Select,dataType:V.Service,viewId:e,scenePath:t}),this.runAnimation()}consoleWorkerInfo(){this.taskBatchData.add({msgType:b.Console,dataType:V.Local,isRunSubWork:!0,viewId:""}),this.consume()}setPriority(e){var s,n;const t=new Set,o=new Set;if(e==="cpu"&&((s=this.subMainThreadWorker)==null||s.destroy(),t.add({msgType:b.PriorityWorker,viewId:ai,dataType:V.Local,isRunSubWork:!0})),e==="ui"){t.add({msgType:b.PriorityMainThreadWorker,viewId:ai,dataType:V.Local,isRunSubWork:!0});const a=this.viewContainerManager.mainView;if(a){const l=this.viewContainerManager.getViewInitData(a.id);if(l){const{offscreenCanvasOpt:u,layerOpt:h,dpr:d,cameraOpt:f}=l;o.add({msgType:b.Init,dataType:V.Local,viewId:a.id,offscreenCanvasOpt:u,layerOpt:h,dpr:d,cameraOpt:f,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1})}}const c=this.viewContainerManager.appViews;for(const l of c.keys()){const u=this.viewContainerManager.getViewInitData(l);if(u){const{offscreenCanvasOpt:h,layerOpt:d,dpr:f,cameraOpt:g}=u;o.add({msgType:b.Init,dataType:V.Local,viewId:l,offscreenCanvasOpt:h,layerOpt:d,dpr:f,cameraOpt:g,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1})}}}t.size&&this.subWorker.postMessage(t),o.size&&((n=this.subMainThreadWorker)==null||n.consume(o))}sendClearUids(e,t){var s,n;const o=new Set;o.add({msgType:b.AuthClear,dataType:V.Local,viewId:e,clearUids:t,localUid:(s=this.collector)==null?void 0:s.uid}),this.control.hasOffscreenCanvas()?this.fullWorker.postMessage(o):(n=this.mainThread)==null||n.consume(o)}async getVNodeInfo(e,t,o){if(!this.getVNodeInfoResolveMap.has(e))return this.taskBatchData.add({msgType:b.GetVNodeInfo,dataType:V.Local,isRunSubWork:!0,viewId:t,workIds:o,workId:e}),this.consume(),await new Promise(s=>{const n=this.getVNodeInfoResolveMap.get(e)||{resolve:void 0,timer:void 0};n.timer&&clearTimeout(n.timer),n.resolve=s,n.timer=setTimeout(()=>{const a=this.getVNodeInfoResolveMap.get(e);a!=null&&a.resolve&&a.resolve({uuid:e})},this.maxLastSyncTime*5),this.getVNodeInfoResolveMap.set(e,n)}).then(s=>{const{uuid:n}=s;return this.getVNodeInfoResolveMap.delete(n),s})}}class Ry{constructor(i){M(this,"internalMsgEmitter");M(this,"control");M(this,"roomHotkeyCheckers");M(this,"tmpCopyStore",new Map);M(this,"tmpCopyCoordInfo");var o;const{control:e,internalMsgEmitter:t}=i;this.control=e,this.internalMsgEmitter=t,this.roomHotkeyCheckers=((o=this.control.room)==null?void 0:o.viewsParams.hotKeys.nodes)||[]}get isUseSelf(){var i,e;return((e=(i=this.control)==null?void 0:i.room)==null?void 0:e.disableDeviceInputs)||!1}get isSelector(){var i;return((i=this.control.worker.currentToolsData)==null?void 0:i.toolsType)===v.Selector}get collector(){return this.control.collector}get mainEngine(){return this.control.worker}get keyboardKind(){return/^Mac/i.test(navigator.platform)?"mac":"windows"}getEventKey(i){switch(i.type){case"keydown":return"KeyDown"}return"KeyUp"}onActiveHotkey(i){var o,s,n;const e=this.control.viewContainerManager.focuedViewId,t=(o=this.control.viewContainerManager.focuedView)==null?void 0:o.focusScenePath;if(e&&t)switch(i){case"delete":this.isSelector&&((s=this.collector)!=null&&s.hasSelector(e,t))&&ae.emitMethod(ne.MainEngine,F.DeleteNode,{workIds:[G],viewId:e});break;case"copy":this.isSelector&&((n=this.collector)!=null&&n.hasSelector(e,t))&&this.copySelectorToTemp(e,t);break;case"paste":this.tmpCopyStore.size&&this.pasteTempToFocusView(e,t);break}(i==="changeToPencil"||i==="redo"||i==="undo")&&this.onSelfActiveHotkey(i)}colloctHotkey(i){if(this.isUseSelf){const e=this.checkHotkey(i);e&&this.onSelfActiveHotkey(e)}}onSelfActiveHotkey(i){switch(i){case"changeToPencil":this.setMemberState({currentApplianceName:re.pencil,useNewPencil:!0});break;case"changeToArrow":this.setMemberState({currentApplianceName:re.arrow});break;case"changeToClick":this.setMemberState({currentApplianceName:re.clicker});break;case"changeToEllipse":this.setMemberState({currentApplianceName:re.ellipse});break;case"changeToEraser":this.setMemberState({currentApplianceName:re.eraser});break;case"changeToHand":this.setMemberState({currentApplianceName:re.hand});break;case"changeToLaserPointer":this.setMemberState({currentApplianceName:re.laserPointer});break;case"changeToSelector":this.setMemberState({currentApplianceName:re.selector});break;case"changeToRectangle":this.setMemberState({currentApplianceName:re.rectangle});break;case"changeToStraight":this.setMemberState({currentApplianceName:re.straight});break;case"redo":this.control.room&&!this.control.room.disableSerialization&&this.control.viewContainerManager.redo();break;case"undo":this.control.room&&!this.control.room.disableSerialization&&this.control.viewContainerManager.undo();break;case"changeToText":this.setMemberState({currentApplianceName:re.text});break;case"changeToPencilEraser":this.setMemberState({currentApplianceName:re.pencilEraser});break;case"delete":case"copy":case"paste":this.onActiveHotkey(i);break}}checkHotkey(i){for(const e of this.roomHotkeyCheckers){const{kind:t,checker:o}=e;if(o({nativeEvent:i,kind:this.getEventKey(i),key:i.key,altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey},this.keyboardKind))return t}}copySelectorToTemp(i,e){var l,u;const t=this.control.viewContainerManager.getView(i),o=(u=(l=this.mainEngine)==null?void 0:l.methodBuilder)==null?void 0:u.getBuilder(F.CopyNode);if(!t||!this.collector||!o)return;const s=this.collector.transformKey(G),n=this.collector.getStorageData(i,e);if(!n)return;const a=n[s],c=a&&o.copySelector({viewId:i,store:a});c&&(this.tmpCopyCoordInfo=c==null?void 0:c.copyCoordInfo,this.tmpCopyStore=c==null?void 0:c.copyStores)}pasteTempToFocusView(i,e){var s,n;const t=this.control.viewContainerManager.getView(i),o=(n=(s=this.mainEngine)==null?void 0:s.methodBuilder)==null?void 0:n.getBuilder(F.CopyNode);if(!(!t||!this.tmpCopyCoordInfo||!this.tmpCopyStore.size||!this.collector||!o)&&t.viewData&&this.tmpCopyCoordInfo){const a=O.cloneDeep(this.tmpCopyCoordInfo.offset),c=this.tmpCopyCoordInfo.cameraOpt,l=t.viewData.camera;a.x=a.x+l.centerX-c.centerX,a.y=a.y+l.centerY-c.centerY;const u=this.control.worker.now;this.control.worker.internalMsgEmitter.emit("addUndoTicker",u,i),o.pasteSelector({viewId:i,scenePath:e,copyStores:O.cloneDeep(this.tmpCopyStore),copyCoordInfo:{offset:a,cameraOpt:l},undoTickerId:u})}}setMemberState(i){var e;(e=this.control.room)==null||e.setMemberState(i)}}class Wy{constructor(i){M(this,"control");M(this,"roomMemberManager");M(this,"worker");M(this,"publicMsgEmitter");M(this,"renderUids",new Map);M(this,"pageAuth",new Map);M(this,"isLocalRender",!1);M(this,"isCurWritable",!1);var o;const{control:e,publicMsgEmitter:t}=i;this.control=e,this.publicMsgEmitter=t,this.roomMemberManager=e.roomMember,this.worker=e.worker,this.isCurWritable=((o=this.control.room)==null?void 0:o.isWritable)||!1}get isWritable(){return this.isCurWritable}onWritableChange(i){this.isCurWritable=i}addPage(i,e=!0){var l,u;const{viewId:t,render:o="localSelf",elementIds:s,pageId:n=(l=this.control.collector)==null?void 0:l.uid}=i,a=this.pageAuth.get(t)||new Map,c=this.control.viewContainerManager.getCurScenePath(t);if(c&&n){const h=a.get(c)||{render:"localSelf",pages:new Map};e&&(h.render=o);const d=s&&this.cloneElementIds(t,c,s,n)||new Set;h.pages.set(n,d),a.set(c,h),this.pageAuth.set(t,a),e&&this.pageAuthEffect(t),this.isLocalRender=!1,(u=this.control.collector)==null||u.dispatchPageAuth({operation:Re.addPage,viewId:t,scenePath:c,pageId:n,pageData:{render:o,elementIds:d}},!0)}}delPage(i,e){var n,a;const t=this.pageAuth.get(e);if(!t)return;const o=[...t.keys()].find(c=>{const l=t.get(c);return!!(l&&l.pages.has(i))});if(!o)return;const s=t.get(o);if(s){const{render:c,pages:l}=s,u=c==="localSelf"?(n=this.control.collector)==null?void 0:n.uid:c,h=l.get(i);h!=null&&h.size&&this.delElementIds(e,o,h),l.delete(i),u===i&&this.pageAuthEffect(e)}(a=this.control.collector)==null||a.dispatchPageAuth({operation:Re.deletePage,viewId:e,scenePath:o,pageId:i},!0)}delViewPage(i,e=!0){var o;this.pageAuth.get(i)&&(this.pageAuth.delete(i),e&&((o=this.control.collector)==null||o.dispatchPageAuth({operation:Re.clearView,viewId:i},e)))}clearRenderPage(i,e,t=!0){var a,c;const o=this.pageAuth.get(i);if(!o)return;const s=o.get(e);let n;if(s){const{render:l,pages:u}=s,h=l==="localSelf"?(a=this.control.collector)==null?void 0:a.uid:l;if(h){if(t){const d=u.get(h);d&&this.delElementIds(i,e,d)}u.set(h,new Set),n=h}}t&&n&&((c=this.control.collector)==null||c.dispatchPageAuth({operation:Re.clearPage,viewId:i,scenePath:e,pageId:n},t))}hasPage(i,e,t){const o=this.pageAuth.get(e);if(!o)return!1;const s=o.get(t);return s?s.pages.has(i):!1}getPageInfo(i,e,t){const o=this.pageAuth.get(e);if(!o)return;const s=o.get(t);if(s)return s.pages.get(i)}addRenderPageElementId(i,e=!0,t=!1){var u,h;const{viewId:o,elementId:s,scenePath:n}=i,a=this.pageAuth.get(o);if(!a)throw new Error(`no view info in viewId: ${o}`);const c=a.get(n);let l;if(c){const{render:d,pages:f}=c,g=d==="localSelf"?(u=this.control.collector)==null?void 0:u.uid:d;if(g&&f.has(g)){const p=f.get(g)||new Set;p.add(s),f.set(g,p),l=g}}t&&this.pageAuthEffect(o),e&&l&&((h=this.control.collector)==null||h.dispatchPageAuth({operation:Re.addElement,viewId:o,scenePath:n,pageId:l,pageData:{elementId:s}},e))}delRenderPageElementId(i,e=!0,t=!1){var u,h;const{viewId:o,elementId:s,scenePath:n}=i,a=this.pageAuth.get(o);if(!a)throw new Error(`no view info in viewId: ${o}`);const c=a.get(n);let l;if(c){const{render:d,pages:f}=c,g=d==="localSelf"?(u=this.control.collector)==null?void 0:u.uid:d;if(g&&f.has(g)){const p=f.get(g);p&&(p.delete(s),f.set(g,p),l=g)}}t&&this.pageAuthEffect(o),e&&l&&((h=this.control.collector)==null||h.dispatchPageAuth({operation:Re.deleteElement,viewId:o,scenePath:n,pageId:l,pageData:{elementId:s}},e))}setPageRender(i,e,t,o=!0){var a;const s=this.pageAuth.get(i);if(!s)throw new Error(`no view info in viewId: ${i}`);const n=s.get(e);n&&(n.render=t),e===this.control.viewContainerManager.getCurScenePath(i)&&this.pageAuthEffect(i),o||(this.isLocalRender=!0),o&&(this.isLocalRender=!1,(a=this.control.collector)==null||a.dispatchPageAuth({operation:Re.renderPage,viewId:i,scenePath:e,pageData:{render:t}},o))}isRenderAble(i){var c,l;const{uid:e,viewId:t,filterLocalSelf:o=!0,scenePath:s}=i,n=this.renderUids.get(t);if(n){const{render:u,hide:h}=n;if(u===void 0&&h===void 0)return!0;if(O.isSet(u)){if(u.has(e)||o&&((c=this.control.collector)==null?void 0:c.uid)===e&&u.has("localSelf"))return!0}else if(u===!0&&(!h||O.isSet(h)&&!h.has(e)&&!(o&&h.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===e)))return!0;return!1}const a=this.pageAuth.get(t);if(a&&s){const u=a.get(s);if(u){const{render:h}=u;if(h)return!(h==="localSelf"&&!o)}}return!0}isClearAble(i){var c;const{uid:e,viewId:t,filterLocalSelf:o=!0,scenePath:s}=i,n=this.renderUids.get(t);if(n){const{clear:l}=n;return!!(l===void 0||l===!0||O.isSet(l)&&(l.has(e)||o&&((c=this.control.collector)==null?void 0:c.uid)===e&&l.has("localSelf")))}const a=this.pageAuth.get(t);if(a&&s){const l=a.get(s);if(l){const{render:u}=l;if(u)return!(u==="localSelf"&&!o)}}return!0}isFilterAble(i,e){var c,l,u,h;const{viewId:t,scenePath:o,elementId:s}=i,n=this.renderUids.get(t);if(n&&s){const{render:d,hide:f}=n;if(d===void 0&&f===void 0)return!0;const g=(c=this.control.collector)==null?void 0:c.getUidFromKey(s);return g?!!(O.isSet(d)&&(d.has(g)||d.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===g)||d===!0&&(!f||O.isSet(f)&&!f.has(g)&&!(f.has("localSelf")&&((u=this.control.collector)==null?void 0:u.uid)===g))):!1}const a=this.pageAuth.get(t);if(a&&o&&s){const d=a.get(o);if(d){const{render:f,pages:g}=d;if(!f)return!0;const p=(h=this.control.collector)==null?void 0:h.uid,y=f==="localSelf"?p:f,I=y&&g.get(y)||void 0;if(I)switch(e){case b.RemoveNode:return!0;default:return I.has(s)}return!1}}return!0}isFilterCursor(i){if(this.isUsePageAuth(i)){const e=this.control.viewContainerManager.getCurScenePath(i),t=this.pageAuth.get(i);if(e&&t){const o=t.get(e);if(o){const{render:s}=o;return s!=="localSelf"}}}return!0}isUsePageAuth(i){var o;if(!this.pageAuth.has(i))return!1;const t=this.control.viewContainerManager.getCurScenePath(i);return t&&((o=this.pageAuth.get(i))==null?void 0:o.has(t))||!1}publishRender(i){var n;const{viewId:e,option:t,isSync:o=!0}=i,s={};if(t){const{render:a,hide:c,clear:l}=t;a&&(s.render=a===!0&&!0||new Set(a)),c&&(s.hide=c===!0&&!0||new Set(c)),l&&(s.clear=l===!0&&!0||new Set(l)),this.renderUids.set(e,s)}else this.renderUids.delete(e);o&&((n=this.control.collector)==null||n.dispatchRenderAuth({operation:tt.setAuth,viewId:e,renderData:s},o)),this.renderEffect(e)}publishOneRender(i,e,t,o=!0){var a;const s=this.renderUids.get(i);let n;switch(t){case"show":s?(s.render||(s.render=new Set),O.isSet(s.render)&&s.render.add(e),O.isSet(s.hide)&&s.hide.delete(e)):this.renderUids.set(i,{render:new Set([e])}),n=tt.setShow;break;case"hide":s?(s.hide||(s.hide=new Set),O.isSet(s.hide)&&s.hide.add(e),O.isSet(s.render)&&s.render.delete(e)):this.renderUids.set(i,{hide:new Set([e])}),n=tt.setHide;break}s?this.renderUids.set(i,s):this.renderUids.delete(i),o&&n&&((a=this.control.collector)==null||a.dispatchRenderAuth({operation:n,viewId:i,uid:e},o)),this.renderEffect(i)}publishOneClear(i,e,t,o=!0){var n;const s=this.renderUids.get(i);t?s?(s.clear||(s.clear=new Set),O.isSet(s.clear)&&s.clear.add(e)):this.renderUids.set(i,{clear:new Set([e])}):s&&O.isSet(s.clear)&&s.clear.has(e)&&s.clear.delete(e),s?this.renderUids.set(i,s):this.renderUids.delete(i),o&&((n=this.control.collector)==null||n.dispatchRenderAuth({operation:tt.setClear,viewId:i,uid:e,isClear:t},o)),this.renderEffect(i)}syncRenderUids(i,e,t,o){const s=e===!0?!0:e&&Object.keys(e)?new Set(Object.keys(e)):void 0,n=t===!0?!0:t&&Object.keys(t)?new Set(Object.keys(t)):void 0,a=o===!0?!0:o&&Object.keys(o)?new Set(Object.keys(o)):void 0;s||n||a?this.renderUids.set(i,{render:s,hide:n,clear:a}):this.renderUids.delete(i),this.renderEffect(i),this.publicMsgEmitter.emit("syncRenderUids",i,{render:s,hide:n,clear:a})}syncPageAuth(i,e,t=!1){let o=!1;if(!e)this.pageAuth.delete(i);else{const s=this.pageAuth.get(i)||new Map;for(const[n,a]of Object.entries(e)){const{render:c,pages:l}=a,u=s.get(n),h=this.isLocalRender?u==null?void 0:u.render:c;if(h){h!==(u==null?void 0:u.render)&&(o=!0);const d=new Map;for(const[g,p]of Object.entries(l))d.set(g,new Set(Object.keys(p)));const f={render:h,pages:d};d.size&&s.set(n,f)}}s.size&&(this.pageAuth.set(i,s),this.publicMsgEmitter.emit("syncPageAuth",i,s))}(t||o)&&this.pageAuthEffect(i)}destoryByViewId(i,e=!1){var t;this.renderUids.has(i)&&(this.renderUids.delete(i),e||(t=this.control.collector)==null||t.dispatchRenderAuth({operation:tt.setAuth,viewId:i})),this.pageAuth.has(i)&&this.control.renderControl.delViewPage(i,!e)}renderEffect(i){var t;const e=(t=this.control.viewContainerManager.getView(i))==null?void 0:t.focusScenePath;e&&this.worker.clearViewScenePath(i,!0).then(()=>{var o;this.worker.pullServiceData(i,e,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(i,(o=this.renderUids.get(i))==null?void 0:o.clear)})}pageAuthEffect(i){var t;const e=(t=this.control.viewContainerManager.getView(i))==null?void 0:t.focusScenePath;e&&this.worker.clearViewScenePath(i,!0).then(()=>{this.worker.pullServiceData(i,e,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(i,!0)})}cloneElementIds(i,e,t,o){var a,c;const s=(a=this.control.collector)==null?void 0:a.getStorageData(i,e),n=new Set;if(s){for(const l of Object.keys(s))if(t.has(l)){const u=`${l}_${o}`;if(n.add(u),!Object.keys(s).includes(u)){const h=O.cloneDeep(s[l]);(c=this.control.collector)==null||c.updateValue(u,{type:b.FullWork,...h,workId:u},{isSync:!0,viewId:i,scenePath:e})}}}return n}delElementIds(i,e,t){var s,n;const o=(s=this.control.collector)==null?void 0:s.getStorageData(i,e);if(o)for(const a of Object.keys(o))t.has(a)&&Object.keys(o).includes(a)&&((n=this.control.collector)==null||n.updateValue(a,void 0,{isSync:!0,viewId:i,scenePath:e}))}}class Yy{constructor(i){M(this,"internalMsgEmitter");M(this,"control");M(this,"maps",new Map);M(this,"showId");M(this,"color");M(this,"timer");M(this,"updateMiniMapCamera",O.debounce(async i=>{const e=this.maps.get(i);if(e){const t=await this.getMiniMapCamera(i);if(t){const o=t.width/t.scale,s=t.height/t.scale,n=e.miniMapCamera.width/e.miniMapCamera.scale,a=e.miniMapCamera.height/e.miniMapCamera.scale;(o>=n||s>=a)&&(e.miniMapCamera=t);const c=e.miniMapCanvas.current;if(c){const l=c.getContext("2d");if(l){const u=this.control.viewContainerManager.getView(i);if(!(u!=null&&u.focusScenePath))return;const{miniMapCamera:h,contianer:d}=e,{width:f,height:g}=d.getBoundingClientRect(),p=Math.min(f/h.width,g/h.height);l.clearRect(0,0,c.width,c.height),c.width=h.width,c.height=h.height,c.style.width=`${h.width*p}px`,c.style.height=`${h.height*p}px`,await this.control.screenshotToCanvas(l,u.focusScenePath,h.width,h.height,h),this.listener.emitAsync([i,"viewCameraUpate"],1)}}}}},2e3,{maxWait:5e3}));var o;const{control:e,internalMsgEmitter:t}=i;this.control=e,this.internalMsgEmitter=t,this.color=((o=this.control.worker.currentToolsData)==null?void 0:o.toolsOpt.strokeColor)||"#000"}get listener(){return this.internalMsgEmitter}get activeViewId(){return this.showId}get highlightColor(){return this.color}setHighlightColor(i){this.color=i}async createMiniMap(i,e,t){const o=this.control.viewContainerManager.getView(i);if(!o)throw new Error("view not found");const s=o.cameraOpt;if(!s)throw new Error("view camera not found");const{width:n,height:a}=e.getBoundingClientRect();if(!n||!a)throw new Error("contianer width or height is 0");const c=m.createRef();this.maps.set(i,{contianer:e,miniMapCanvas:c,miniMapCamera:t,viewCamera:s}),this.showId=i,this.control.viewContainerManager.setActiveMiniMap(this.showId,!0);const l=Math.min(n/t.width,a/t.height),u=await new Promise(h=>{this.listener.once([i,"miniMapCreate"],()=>{const d=c.current;d&&(d.width=t.width,d.height=t.height,d.style.width=`${t.width*l}px`,d.style.height=`${t.height*l}px`),h(!0)}),this.timer=setTimeout(()=>{h(!1)},2e3)});return this.timer&&clearTimeout(this.timer),u}async getMiniMapCamera(i){const e=this.control.viewContainerManager.getView(i);if(!e)return;const{cameraOpt:t,focusScenePath:o}=e;if(!t||!o)return;const s={originX:t.centerX-t.width/t.scale/2,originY:t.centerY-t.height/t.scale/2,width:t.width/t.scale,height:t.height/t.scale};let n=await this.control.getBoundingRect(o)||s;n=yo(n,s)||s;let a=n.width,c=n.height,l=1;const u=a>t.width&&Math.min(t.width/a,l)||l,h=c>t.height&&Math.min(t.height/c,l)||l;return u<=h?(a=u<1&&t.width||a,c=Math.floor(c*u)+1,l=u):u>h&&(c=h<1&&t.height||c,a=Math.floor(a*h)+1,l=h),{scale:l,centerX:n.originX+n.width/2,centerY:n.originY+n.height/2,width:a,height:c}}getMiniMapCanvas(i){const e=this.maps.get(i);return(e==null?void 0:e.miniMapCanvas.current)||null}updateViewCamera(i,e){const t=this.maps.get(i);t&&(t.viewCamera=e,this.listener.emitAsync([i,"viewCameraUpate"],1))}destroyMiniMap(i){const e=i||this.showId;e&&(this.maps.delete(e),this.control.viewContainerManager.setActiveMiniMap(e,!1))}}class Tn{constructor(){M(this,"control");M(this,"_listeners",{})}_inject(i){this.control=i}_onEvent(i,e){this._listeners[i]&&this._listeners[i](...e)}callbacks(i,e){this._listeners[i]=e}removeCallback(i){delete this._listeners[i]}}class Uy{constructor(i){M(this,"control");M(this,"worker");M(this,"publicMsgEmitter");M(this,"plugins",new Map);const{control:e,publicMsgEmitter:t}=i;this.control=e,this.publicMsgEmitter=t,this.worker=e.worker}use(i){this.plugins.set(i.kind,i),i._inject(this.control),i.onCreate()}destroy(){this.plugins.forEach(i=>{this.plugins.delete(i.kind),i.onDestroy()})}dispatchPluginEvent(i,...e){this.plugins.forEach(t=>{t._onEvent(i,e)})}}const Tt=class Tt{constructor(i){M(this,"version",Js);M(this,"plugin");M(this,"room");M(this,"play");M(this,"collector");M(this,"hasSwitchToSelectorEffect");M(this,"snapshootStateMap");M(this,"_disableDeviceInputs");M(this,"_disableEraseImage");M(this,"_disableEraseText");M(this,"_disableCameraTransform");M(this,"_disableUseWorker",!1);M(this,"priority","cpu");M(this,"effectResolve");M(this,"hotkeyManager");M(this,"pluginOptions");M(this,"roomMember");M(this,"cursor");M(this,"textEditorManager");M(this,"worker");M(this,"renderControl");M(this,"miniMapManager");M(this,"pluginManager");M(this,"_isPolyfill",{requestIdleCallback:!1,cancelIdleCallback:!1});M(this,"onSceneChange",async(i,e)=>{var n;const t=this.viewContainerManager.getView(e);t!=null&&t.focusScenePath&&(n=this.collector)!=null&&n.hasSelector(e,t.focusScenePath)&&this.worker.blurSelector(e,t.focusScenePath),this.textEditorManager.checkEmptyTextBlur();const o=t==null?void 0:t.displayer;o&&(o.setActive(!1),await o.stopEventHandler());const s=i;s&&this.viewContainerManager.setViewScenePath(e,s),o==null||o.setActive(!0)});M(this,"onRoomMembersChange",i=>{this.roomMember.setRoomMembers(H.toJS(i))});M(this,"onMemberChange",O.throttle(i=>{var n;if(!this.room||!this.worker||!i||!this.room.isWritable)return;const e=this.getToolsKey(i),t=(n=this.worker.getCurrentToolsData())==null?void 0:n.toolsType,o=this.viewContainerManager.focuedViewId;o&&t===v.Selector&&e!==v.Selector&&this.worker.blurCursor(o);const s=this.getToolsOpt(e,i);this.worker.setCurrentToolsData(s),this.pluginManager.dispatchPluginEvent("setToolkey",e),this.effectViewContainer(e),this.effectResolve&&this.effectResolve(!0)},100,{leading:!1}));M(this,"internalSceneChange",(i,e)=>{var o;this.miniMapManager.activeViewId===i&&this.miniMapManager.destroyMiniMap(i),this.pluginManager.dispatchPluginEvent("sceneChange",i,e),(o=this.worker)==null||o.clearViewScenePath(i,!0).then(()=>{var s;(s=this.worker)==null||s.pullServiceData(i,e,{isAsync:!0,useAnimation:!1})})});M(this,"internalCameraChange",(i,e)=>{var t;(t=this.worker)==null||t.updateCamera(i,e),this.miniMapManager.updateViewCamera(i,e)});var n;const{displayer:e,plugin:t,options:o}=i;this.plugin=t,this.room=H.isRoom(e)?e:void 0,this.play=H.isPlayer(e)?e:void 0,this.room&&(this._disableDeviceInputs=this.room.disableDeviceInputs,this._disableEraseImage=this.room.disableEraseImage,this._disableEraseText=!1),this.pluginOptions=o,((n=o.extras)==null?void 0:n.useWorker)==="mainThread"?this._disableUseWorker=!0:this._disableUseWorker=Jo!=="worker",this.roomMember=new My;const s={control:this,internalMsgEmitter:Tt.InternalMsgEmitter,publicMsgEmitter:Tt.PublicMsgEmitter};this.cursor=new my(s),this.textEditorManager=new yy(s),this.worker=new Oy(s),this.hotkeyManager=new Ry(s),this.renderControl=new Wy(s),this.miniMapManager=new Yy(s),this.pluginManager=new Uy(s)}hasPolyfillMethod(i){return this._isPolyfill[i]}registerPolyfillMethod(i){this._isPolyfill[i]=!0}get hasExtendFontFaces(){return this.extendFontFaces.length>0}get extendFontFaces(){var i;return((i=this.pluginOptions.extras.textEditor)==null?void 0:i.extendFontFaces)??Me.textEditor.extendFontFaces}get loadFontFacesTimeout(){var i;return((i=this.pluginOptions.extras.textEditor)==null?void 0:i.loadFontFacesTimeout)??Me.textEditor.loadFontFacesTimeout}get disableEraseText(){return this._disableEraseText||!1}set disableEraseText(i){this._disableEraseText=i}get disableEraseImage(){return this._disableEraseImage||!1}set disableEraseImage(i){this._disableEraseImage=i}get disableDeviceInputs(){return this._disableDeviceInputs||!1}set disableDeviceInputs(i){var t;this._disableDeviceInputs=i;const e=(t=this.worker.getCurrentToolsData())==null?void 0:t.toolsType;e&&this.effectViewContainer(e)}get disableCameraTransform(){return this._disableCameraTransform||!1}set disableCameraTransform(i){this._disableCameraTransform=i}get disableUseWorker(){return this._disableUseWorker||!1}set disableUseWorker(i){this._disableUseWorker=i}setPriority(i){var e;this.priority=i,this.hasOffscreenCanvas()&&((e=this.worker)==null||e.setPriority(i))}hasOffscreenCanvas(){return this._disableUseWorker?!1:Jo==="worker"}bindPlugin(i){this.plugin=i,this.collector&&(this.collector.removeStorageStateListener(),this.collector.removeAuthStateListener()),this.collector=new Gi(this,i,this.pluginOptions.extras.syncOpt.interval),this.activePlugin()}destroy(){var i,e,t,o,s,n;this.roomMember.destroy(),(i=this.collector)==null||i.destroy(),(e=this.worker)==null||e.destroy(),(t=this.viewContainerManager)==null||t.destroy(),(o=this.cursor)==null||o.destroy(),(s=this.textEditorManager)==null||s.destory(),(n=this.pluginManager)==null||n.destroy()}cleanCurrentScene(){const i=this.worker.now,e=this.worker.getLocalWorkViewId()||this.viewContainerManager.focuedViewId;e&&(Tt.InternalMsgEmitter.emit("addUndoTicker",i,e),this.worker.clearViewScenePath(e,!1,!0))}async setWritable(i){var e,t;if(!i){(e=this.cursor)==null||e.unabled(),this.textEditorManager.checkEmptyTextBlur();const o=this.viewContainerManager.getAllViews();for(const s of o){s!=null&&s.focusScenePath&&(t=this.collector)!=null&&t.hasSelector(s.id,s.focusScenePath)&&this.worker.blurSelector(s.id,s.focusScenePath);const n=s==null?void 0:s.displayer;n&&n.getActive()&&(n.setActive(!1),await n.stopEventHandler())}}await new Promise(o=>{setTimeout(()=>{o()},500)})}onWritableChange(i){var o;i?this.worker.abled():this.worker.unWritable(),((o=this.worker.getCurrentToolsData())==null?void 0:o.toolsType)===v.Text&&this.viewContainerManager.focuedViewId&&(i?this.viewContainerManager.activeTextEditor(this.viewContainerManager.focuedViewId):this.viewContainerManager.unActiveTextEditor(this.viewContainerManager.focuedViewId)),this.renderControl.onWritableChange(i),this.viewContainerManager.getAllViews().forEach(s=>{const n=s==null?void 0:s.displayer;n&&(n.bindToolsClass(),i?n.setActive(!0):n.setActive(!1))})}getToolsKey(i){const e=i.currentApplianceName;switch(this.hasSwitchToSelectorEffect=!1,e){case re.text:return i.textCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),v.Text;case re.pencil:return i.useLaserPen?v.LaserPen:v.Pencil;case re.eraser:return v.Eraser;case re.pencilEraser:return this.pluginOptions.extras.pencilEraser.useBitMap===!1?v.PencilEraser:v.BitMapEraser;case re.selector:return v.Selector;case re.arrow:return i.arrowCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),v.Arrow;case re.straight:return i.straightCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),v.Straight;case re.ellipse:return i.ellipseCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),v.Ellipse;case re.rectangle:return i.rectangleCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),v.Rectangle;case re.shape:if(i.shapeCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),i.shapeType===_e.Pentagram||i.shapeType===_e.Star)return v.Star;if(i.shapeType===_e.Polygon||i.shapeType===_e.Triangle||i.shapeType===_e.Rhombus)return v.Polygon;if(i.shapeType===_e.SpeechBalloon)return v.SpeechBalloon;break}return v.Clicker}getToolsOpt(i,e){if(i===v.Clicker)return{toolsType:i,toolsOpt:{}};const t={strokeColor:wt(e.strokeColor[0],e.strokeColor[1],e.strokeColor[2],e.strokeOpacity||1),thickness:e.strokeWidth,isOpacity:(e==null?void 0:e.strokeOpacity)&&e.strokeOpacity<1||(e==null?void 0:e.fillOpacity)&&e.fillOpacity<1||(e==null?void 0:e.textOpacity)&&e.textOpacity<1||(e==null?void 0:e.textBgOpacity)&&e.textBgOpacity<1||!1};switch(i){case v.Text:t.fontFamily=window.getComputedStyle(document.documentElement).getPropertyValue("font-family"),t.fontSize=(e==null?void 0:e.textSizeOverride)||(e==null?void 0:e.textSize)||Number(window.getComputedStyle(document.body).fontSize),t.textAlign=(e==null?void 0:e.textAlign)||"left",t.verticalAlign=(e==null?void 0:e.verticalAlign)||"middle",t.fontColor=(e==null?void 0:e.textColor)&&wt(e.textColor[0],e.textColor[1],e.textColor[2],e.textOpacity||1)||t.strokeColor||"rgba(0,0,0,1)",t.fontBgColor=Array.isArray(e==null?void 0:e.textBgColor)&&wt(e.textBgColor[0],e.textBgColor[1],e.textBgColor[2],e.textBgOpacity||1)||"transparent",t.bold=(e==null?void 0:e.bold)&&"bold"||void 0,t.italic=(e==null?void 0:e.italic)&&"italic"||void 0,t.underline=(e==null?void 0:e.underline)||void 0,t.lineThrough=(e==null?void 0:e.lineThrough)||void 0,t.text="",t.strokeColor=void 0;break;case v.Pencil:t.strokeType=(e==null?void 0:e.strokeType)||se.Normal;break;case v.PencilEraser:case v.BitMapEraser:case v.Eraser:t.thickness=Math.min(4,Math.max(1,Math.floor(e.pencilEraserSize||1)))-1;break;case v.LaserPen:t.duration=(e==null?void 0:e.duration)||1,e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===se.Stroke?t.strokeType=se.Normal:t.strokeType=(e==null?void 0:e.strokeType)||se.Normal;break;case v.Arrow:case v.Straight:e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===se.Stroke?t.strokeType=se.Normal:t.strokeType=(e==null?void 0:e.strokeType)||se.Normal;break;case v.Ellipse:case v.Rectangle:case v.Star:case v.Polygon:case v.SpeechBalloon:e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===se.Stroke?t.strokeType=se.Normal:t.strokeType=(e==null?void 0:e.strokeType)||se.Normal,i===v.Star&&(e.shapeType===_e.Pentagram?(t.vertices=10,t.innerVerticeStep=2,t.innerRatio=.4):e!=null&&e.vertices&&(e!=null&&e.innerVerticeStep)&&(e!=null&&e.innerRatio)&&(t.vertices=e.vertices,t.innerVerticeStep=e.innerVerticeStep,t.innerRatio=e.innerRatio)),i===v.Polygon&&(e.shapeType===_e.Triangle?t.vertices=3:e.shapeType===_e.Rhombus?t.vertices=4:e.vertices&&(t.vertices=e.vertices)),t.fillColor=(e==null?void 0:e.fillColor)&&wt(e.fillColor[0],e.fillColor[1],e.fillColor[2],e==null?void 0:e.fillOpacity)||"transparent",i===v.SpeechBalloon&&(t.placement=e.placement||"bottomLeft");break}return{toolsType:i,toolsOpt:t}}effectViewContainer(i){var e,t,o,s,n;if(this.disableDeviceInputs===!0)this.room.disableDeviceInputs=!0,(e=this.worker)==null||e.unWritable(),(t=this.cursor)==null||t.unabled();else switch(i!==v.Text&&this.viewContainerManager.focuedViewId&&this.viewContainerManager.unActiveTextEditor(this.viewContainerManager.focuedViewId),i){case v.Text:case v.Pencil:case v.LaserPen:case v.Arrow:case v.Straight:case v.Rectangle:case v.Ellipse:case v.Star:case v.Polygon:case v.SpeechBalloon:case v.Triangle:case v.Rhombus:case v.Eraser:case v.PencilEraser:case v.BitMapEraser:case v.Selector:this.room.disableDeviceInputs=!0,(o=this.worker)==null||o.abled(),i===v.Text&&this.viewContainerManager.focuedViewId&&this.viewContainerManager.activeTextEditor(this.viewContainerManager.focuedViewId);break;default:this.room.disableDeviceInputs=!1,(s=this.worker)==null||s.unWritable(),(n=this.cursor)==null||n.unabled();break}setTimeout(()=>{this.viewContainerManager.getAllViews().forEach(c=>{c!=null&&c.displayer&&c.displayer.bindToolsClass()})},0)}async getBoundingRect(i){var t,o,s,n,a;const e=await((t=this.worker)==null?void 0:t.getBoundingRect(i));if(e){const c=((s=(o=this.viewContainerManager.mainView)==null?void 0:o.viewData)==null?void 0:s.convertToPointInWorld({x:e.x,y:e.y}))||{x:e.x,y:e.y},l=((a=(n=this.viewContainerManager.mainView)==null?void 0:n.viewData)==null?void 0:a.camera.scale)||1;return{width:Math.floor(e.w/l)+1,height:Math.floor(e.h/l)+1,originX:c.x,originY:c.y}}}async screenshotToCanvas(i,e,t,o,s,n,a){const c=await this.worker.getSnapshot(e,t,o,s);c&&(i.drawImage(c,n||0,a||0),c.close())}async scenePreview(i,e){var n,a,c,l;const t=(n=this.collector)==null?void 0:n.getViewIdBySecenPath(i);if(!t)return;const o=this.viewContainerManager.getView(t);if(!o||!((a=o.cameraOpt)!=null&&a.width)||!((c=o.cameraOpt)!=null&&c.height))return;const s=await((l=this.worker)==null?void 0:l.getSnapshot(i));if(s&&this.worker){const u=document.createElement("canvas"),h=u.getContext("2d"),{width:d,height:f}=o.cameraOpt;u.width=d,u.height=f,h&&(h.drawImage(s,0,0),e.crossOrigin="anonymous",e.src=u.toDataURL(),e.onload=()=>{u.remove()},e.onerror=()=>{u.remove(),e.remove()}),s.close()}}switchToText(){var i;(i=this.room)==null||i.setMemberState({currentApplianceName:re.text})}switchToSelector(){var i;(i=this.room)==null||i.setMemberState({currentApplianceName:re.selector})}async runEffectWork(i){if(this.hasSwitchToSelectorEffect){const e=await new Promise(t=>{this.switchToSelector(),this.effectResolve=t});this.effectResolve=void 0,e&&i&&i()}}setSnapshootData(){var i;this.room&&(this.snapshootStateMap=new Map,this.snapshootStateMap.set("memberState",(i=this.room)==null?void 0:i.state.memberState))}getSnapshootData(i){var e;return(e=this.snapshootStateMap)==null?void 0:e.get(i)}clearSnapshootData(){var i;(i=this.snapshootStateMap)==null||i.clear(),this.snapshootStateMap=void 0}useBitMapEraser(i){this.pluginOptions.extras.pencilEraser.useBitMap=i}consoleWorkerInfo(){var i;(i=this.worker)==null||i.consoleWorkerInfo()}filterRenderByUid(i,e,t=!0){var s;this.viewContainerManager.getView(i)&&((s=this.renderControl)==null||s.publishRender({viewId:i,option:e,isSync:t}))}cancelFilterRender(i,e=!0){var t;(t=this.renderControl)==null||t.publishRender({viewId:i,isSync:e})}async createMiniMap(i,e){const t=await this.miniMapManager.getMiniMapCamera(i);if(t&&await this.miniMapManager.createMiniMap(i,e,t)){const s=this.miniMapManager.getMiniMapCanvas(i);if(s){const n=s.getContext("2d");if(n){const a=this.viewContainerManager.getView(i);a!=null&&a.focusScenePath&&this.screenshotToCanvas(n,a.focusScenePath,t.width,t.height,t)}}}}async destroyMiniMap(i){this.miniMapManager.destroyMiniMap(i)}insertIconify(i,e){var o;if(this.viewContainerManager.getView(i)&&this.room){const s=this.room.state.memberState,n=wt(s.strokeColor[0],s.strokeColor[1],s.strokeColor[2],s.strokeOpacity||1);(o=this.worker)==null||o.insertIconify(i,{...e,strokeColor:n})}}usePlugin(i){return this.pluginManager.use(i)}};M(Tt,"InternalMsgEmitter",new Yi),M(Tt,"PublicMsgEmitter",new Yi);let xe=Tt;const vt=class vt{constructor(i){M(this,"emitter",new Yi);M(this,"undoStack");M(this,"redoStack");M(this,"worker");M(this,"control");M(this,"room");M(this,"isTicking");M(this,"undoTickerId");M(this,"viewId");M(this,"scenePath");M(this,"tickStartStorerCache");M(this,"excludeIds",new Set);M(this,"onChangeScene",O.debounce(()=>{const i=this.control.viewContainerManager.getCurScenePath(this.viewId);if(i){let e=this.undoStack.filter(o=>o.scenePath===i).length;const t=this.redoStack.filter(o=>o.scenePath===i).length;e===0&&t===0&&this.tickStartStorerCache&&this.scenePath===i&&(e=1),this.emitter.emit("onCanUndoStepsUpdate",e),this.emitter.emit("onCanRedoStepsUpdate",t)}},vt.waitTime));const{control:e,internalMsgEmitter:t,viewId:o}=i;this.control=e,this.emitter=t,this.undoStack=[],this.redoStack=[],this.room=e.room,this.worker=e.worker,this.isTicking=!1,this.viewId=o}get collector(){return this.control.collector}addExcludeIds(i){if(this.isTicking)for(const e of i)this.excludeIds.add(e)}undoTickerStart(i,e){var t,o;if(this.collector&&(this.undoTickerId!==i||this.scenePath!==e)){!this.undoTickerId&&!this.tickStartStorerCache&&!this.scenePath&&this.emitter.emit("onCanUndoStepsUpdate",1),this.undoTickerId&&this.viewId&&this.scenePath&&this.undoTickerEndSync(this.undoTickerId,this.viewId,this.scenePath),this.isTicking=!0;const s=this.collector.transformKey(G);this.excludeIds.add(s),this.undoTickerId=i,this.scenePath=e;const n=((t=this.collector)==null?void 0:t.storage[this.viewId])&&((o=this.collector)==null?void 0:o.storage[this.viewId][this.scenePath])||{};this.tickStartStorerCache=new Map(Object.entries(O.cloneDeep(n)))}}undoTickerEndSync(i,e,t,o=!0){var s,n;if(i===this.undoTickerId&&t===this.scenePath&&e===this.viewId&&this.tickStartStorerCache){const a=((s=this.collector)==null?void 0:s.storage[e])&&((n=this.collector)==null?void 0:n.storage[e][t])||{},c=this.diffFun(this.tickStartStorerCache,new Map(Object.entries(a)));c.size&&(this.undoStack.push({id:i,type:2,data:O.cloneDeep(c),scenePath:t}),this.undoStack.length>vt.MaxStackLength&&this.undoStack.shift(),o&&this.emitter.emit("onCanUndoStepsUpdate",this.undoStack.length+1)),this.redoStack.length&&(this.redoStack.length=0,this.emitter.emit("onCanRedoStepsUpdate",this.redoStack.length)),this.isTicking=!1,this.scenePath=void 0,this.tickStartStorerCache=void 0,this.undoTickerId=void 0,this.excludeIds.clear()}}undo(i){this.undoTickerId&&this.tickStartStorerCache&&this.scenePath&&this.undoTickerEndSync(this.undoTickerId,this.viewId,this.scenePath,!1);let e=this.undoStack.length-1;for(;e>=0;){if(this.undoStack[e].scenePath===i){const n=this.undoStack[e];n&&(this.redoStack.push(n),n.type===2&&n.data&&this.refreshPlugin(n)),this.undoStack.splice(e,1);break}e--}const t=this.undoStack.filter(s=>s.scenePath===i).length,o=this.redoStack.filter(s=>s.scenePath===i).length;return this.emitter.emit("onCanUndoStepsUpdate",t),this.emitter.emit("onCanRedoStepsUpdate",o),t}redo(i){let e=this.redoStack.length-1;for(;e>=0;){if(this.redoStack[e].scenePath===i){const n=this.redoStack[e];n&&(!this.undoTickerId&&n.tickStartStorerCache?(this.undoTickerId=n.id,this.tickStartStorerCache=n.tickStartStorerCache,this.scenePath=n.scenePath):this.undoStack.push(n),n.type===2&&n.data&&this.refreshPlugin(n,!0)),this.redoStack.splice(e,1);break}e--}const t=this.undoStack.filter(s=>s.scenePath===i).length,o=this.redoStack.filter(s=>s.scenePath===i).length;return this.emitter.emit("onCanUndoStepsUpdate",t),this.emitter.emit("onCanRedoStepsUpdate",o),o}clear(){this.clearUndo(),this.clearRedo()}clearUndo(){this.undoStack.length=0,this.emitter.emit("onCanUndoStepsUpdate",this.undoStack.length)}clearRedo(){this.redoStack.length=0,this.emitter.emit("onCanRedoStepsUpdate",this.redoStack.length)}canUndo(){return!!this.undoStack.length}canRedo(){return!!this.redoStack.length}onFocusView(){const i=this.control.viewContainerManager.getCurScenePath(this.viewId);if(i){let e=this.undoStack.filter(o=>o.scenePath===i).length;const t=this.redoStack.filter(o=>o.scenePath===i).length;e===0&&t===0&&this.tickStartStorerCache&&this.scenePath===i&&(e=1),this.emitter.emit("onCanUndoStepsUpdate",e),this.emitter.emit("onCanRedoStepsUpdate",t)}}diffFun(i,e){const t=new Set,o=i.keys(),s=e.keys();for(const n of o){if(this.excludeIds.has(n))continue;const a=i.get(n),c=e.get(n);if(a&&c){if(O.isEqual(c,a))continue;t.add({dataType:3,key:n,data:[a,c]});continue}a&&t.add({dataType:2,key:n,data:a})}for(const n of s){if(this.excludeIds.has(n))continue;const a=e.get(n);a&&!i.has(n)&&t.add({dataType:1,key:n,data:a})}return t}isDrawEffectiveScene(i,e){const{key:t}=i;return!e.includes(t)}isDeleteEffectiveScene(i,e,t){var n;const{key:o}=i;if(!e.includes(o))return!1;const s=e.filter(a=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(a))===G&&!((l=this.collector)!=null&&l.isOwn(a))}).map(a=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][t][a]});for(const a of s)if((n=a==null?void 0:a.selectIds)!=null&&n.includes(o))return!1;return!0}isOldEffectiveScene(i,e,t){var n;const{key:o}=i;if(!e.includes(o))return!1;const s=e.filter(a=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(a))===G&&!((l=this.collector)!=null&&l.isOwn(a))}).map(a=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][t][a]});for(const a of s)if((n=a==null?void 0:a.selectIds)!=null&&n.includes(o))return!1;return!0}isNewEffectiveScene(i,e){const{key:t}=i;return!!e.includes(t)}refreshPlugin(i,e=!1){var a,c,l,u,h,d,f,g,p,y,I,w,S,C,T,N,x,D,L,z,j;let t;const{scenePath:o}=i,s=i.data;if(!s||!this.collector)return;const n=O.cloneDeep(this.collector.storage);for(const E of s.values()){const{dataType:R,data:P,key:Z}=E,_=this.collector.getStorageData(this.viewId,o),B=_&&Object.keys(_)||[];switch(R){case 1:if(t=e?this.isDrawEffectiveScene(E,B):this.isDeleteEffectiveScene(E,B,o),t)if(e&&!Array.isArray(P)){if((a=P.updateNodeOpt)!=null&&a.useAnimation&&(P.updateNodeOpt.useAnimation=!1),((c=this.collector)==null?void 0:c.getLocalId(Z))===G&&((l=this.collector)!=null&&l.isOwn(E.key))){const J=P.selectIds;if(J){const ie=B.filter(oe=>{var K,q;return((K=this.collector)==null?void 0:K.getLocalId(oe))===G&&!((q=this.collector)!=null&&q.isOwn(oe))}).map(oe=>{var K;return(K=this.collector)==null?void 0:K.storage[this.viewId][o][oe]});let le=!1;for(const oe of ie)for(let K=0;K<J.length;K++)(u=oe==null?void 0:oe.selectIds)!=null&&u.includes(J[K])&&(delete J[K],le=!0);le&&(P.selectIds=J.filter(oe=>!!oe))}}(h=this.collector)==null||h.updateValue(E.key,P,{viewId:this.viewId,scenePath:o,isSync:!0,storage:n})}else!e&&!Array.isArray(E.data)&&((d=this.collector)==null||d.updateValue(E.key,void 0,{viewId:this.viewId,scenePath:o,isSync:!0,storage:n}));break;case 2:if(t=e?this.isDeleteEffectiveScene(E,B,o):this.isDrawEffectiveScene(E,B),t){if(e&&!Array.isArray(P))(f=this.collector)==null||f.updateValue(Z,void 0,{viewId:this.viewId,scenePath:o,isSync:!0,storage:n});else if(!e&&!Array.isArray(P)){if((g=P.updateNodeOpt)!=null&&g.useAnimation&&(P.updateNodeOpt.useAnimation=!1),((p=this.collector)==null?void 0:p.getLocalId(E.key))===G&&((y=this.collector)!=null&&y.isOwn(E.key))){const J=P.selectIds;if(J){const ie=B.filter(oe=>{var K,q;return((K=this.collector)==null?void 0:K.getLocalId(oe))===G&&!((q=this.collector)!=null&&q.isOwn(oe))}).map(oe=>{var K;return(K=this.collector)==null?void 0:K.storage[this.viewId][o][oe]});let le=!1;for(const oe of ie)for(let K=0;K<J.length;K++)(I=oe==null?void 0:oe.selectIds)!=null&&I.includes(J[K])&&(delete J[K],le=!0);le&&(P.selectIds=J.filter(oe=>!!oe))}}(w=this.collector)==null||w.updateValue(E.key,E.data,{viewId:this.viewId,scenePath:o,isSync:!0,storage:n})}}break;case 3:if(t=e?this.isNewEffectiveScene(E,B):this.isOldEffectiveScene(E,B,o),t){if(e&&Array.isArray(P)&&P.length===2){const J=P[1];if((S=J.updateNodeOpt)!=null&&S.useAnimation&&(J.updateNodeOpt.useAnimation=!1),((C=this.collector)==null?void 0:C.getLocalId(E.key))===G&&((T=this.collector)!=null&&T.isOwn(E.key))){const ie=J.selectIds;if(ie){const le=B.filter(K=>{var q,de;return((q=this.collector)==null?void 0:q.getLocalId(K))===G&&!((de=this.collector)!=null&&de.isOwn(K))}).map(K=>{var q;return(q=this.collector)==null?void 0:q.storage[this.viewId][o][K]});let oe=!1;for(const K of le)for(let q=0;q<ie.length;q++)K!=null&&K.selectIds&&((N=K.selectIds)!=null&&N.includes(ie[q]))&&(delete ie[q],oe=!0);oe&&(J.selectIds=ie.filter(K=>!!K))}}(x=this.collector)==null||x.updateValue(Z,J,{viewId:this.viewId,scenePath:o,isSync:!0,storage:n})}else if(!e&&Array.isArray(P)&&P.length===2){const J=P[0];if((D=J.updateNodeOpt)!=null&&D.useAnimation&&(J.updateNodeOpt.useAnimation=!1),((L=this.collector)==null?void 0:L.getLocalId(E.key))===G&&((z=this.collector)!=null&&z.isOwn(E.key))){const ie=J.selectIds;if(ie){const le=B.filter(K=>{var q,de;return((q=this.collector)==null?void 0:q.getLocalId(K))===G&&!((de=this.collector)!=null&&de.isOwn(K))}).map(K=>{var q;return(q=this.collector)==null?void 0:q.storage[this.viewId][o][K]});let oe=!1;for(const K of le)for(let q=0;q<ie.length;q++)K!=null&&K.selectIds&&K.selectIds.includes(ie[q])&&(delete ie[q],oe=!0);oe&&(J.selectIds=ie.filter(K=>!!K))}}(j=this.collector)==null||j.updateValue(E.key,J,{viewId:this.viewId,scenePath:o,isSync:!0,storage:n})}}break}}}};M(vt,"sdkCallBack"),M(vt,"MaxStackLength",20),M(vt,"waitTime",100);let mi=vt;function By(r){return r instanceof TouchEvent||r instanceof window.TouchEvent||(r==null?void 0:r.touches)&&(r==null?void 0:r.touches.length)||(r==null?void 0:r.changedTouches)&&(r==null?void 0:r.changedTouches.length)}function Ct(r){return By(r)&&(r.touches&&r.touches.length===1||r.changedTouches&&r.changedTouches.length===1)}function To(r){return r.touches&&r.touches.length?{x:r.touches[0].pageX,y:r.touches[0].pageY}:r.changedTouches&&r.changedTouches.length?{x:r.changedTouches[0].pageX,y:r.changedTouches[0].pageY}:{x:r.pageX,y:r.pageY}}class Wt{constructor(i){M(this,"internalMsgEmitter");M(this,"control");M(this,"mainView");M(this,"appViews",new Map);M(this,"undoTickerStart",(i,e)=>{const t=this.getView(e);t&&t.displayer&&t.focusScenePath&&t.displayer.commiter.undoTickerStart(i,t.focusScenePath)});M(this,"addExcludeIds",(i,e)=>{const t=this.getView(e);t&&t.displayer&&t.focusScenePath&&t.displayer.commiter.addExcludeIds(i)});const{control:e,internalMsgEmitter:t}=i;this.control=e,this.internalMsgEmitter=t,this.internalMsgEmitter.on("addUndoTicker",this.undoTickerStart),this.internalMsgEmitter.on("excludeIds",this.addExcludeIds)}get worker(){return this.control.worker}undo(){const i=this.focuedView;let e=0;if(i){const t=i.focusScenePath;e=i.displayer.commiter.undo(t)||0}return e}redo(){const i=this.focuedView;let e=0;if(i){const t=i.focusScenePath;e=i.displayer.commiter.redo(t)||0}return e}validator(i,e,t){var n;const o=O.clone(i[e]),s=O.clone(t);e==="focusScenePath"&&t&&!O.isEqual(o,s)&&(this.control.internalSceneChange(i.id,s),(n=this.focuedView)==null||n.displayer.commiter.onChangeScene()),e==="cameraOpt"&&!O.isEqual(o,s)&&this.control.internalCameraChange(i.id,s)}destroyAppView(i,e=!1){const t=this.appViews.get(i);t&&(this.control.textEditorManager.clear(i,e),t.displayer.destroy(),this.appViews.delete(i))}createMianView(i){this.mainView=new Proxy(i,{set:(e,t,o)=>(this.worker.isActive&&this.validator(e,t,o),e[t]=o,!0)})}createAppView(i){const e=i.id,t=new Proxy(i,{set:(o,s,n)=>(this.worker.isActive&&this.validator(o,s,n),o[s]=n,!0)});this.appViews.set(e,t)}isAppView(i){return i!==ge&&this.appViews.has(i)}getView(i){var e;return i===ge?this.mainView:(e=this.appViews)==null?void 0:e.get(i)}getCurScenePath(i){const e=this.getView(i);if(e)return e.focusScenePath}getAllViews(){return[this.mainView,...this.appViews.values()]}setViewScenePath(i,e){var t;if(i===ge&&this.mainView)this.mainView.focusScenePath=e;else{const o=i&&((t=this.appViews)==null?void 0:t.get(i))||void 0;o&&(o.focusScenePath=e)}}setViewData(i,e){var t;if(i===ge&&this.mainView)this.mainView.viewData=e;else{const o=i&&((t=this.appViews)==null?void 0:t.get(i))||void 0;o&&(o.viewData=e)}}setFocuedViewId(i){var e;this.focuedViewId=i,i===ge?this.focuedView=this.mainView:this.focuedView=i&&((e=this.appViews)==null?void 0:e.get(i))||void 0,this.worker.currentToolsData&&this.worker.currentToolsData.toolsType===v.Text&&this.activeTextEditor(i),this.control.cursor.onFocusViewChange(),this.focuedView&&this.focuedView.displayer.commiter.onFocusView()}setViewFocusScenePath(i,e){var o;let t;i===ge?t=this.mainView:t=(o=this.appViews)==null?void 0:o.get(i),t&&(t.focusScenePath=e)}destroy(){var i;this.internalMsgEmitter.off("addUndoTicker",this.undoTickerStart),this.internalMsgEmitter.off("excludeIds",this.addExcludeIds),(i=this.mainView)==null||i.displayer.destroy(),this.control.destroyMiniMap(ge),this.appViews.forEach(e=>{this.destroyAppView(e.id,!0),this.worker.destroyViewWorker(e.id),this.control.destroyMiniMap(e.id)})}setFocuedViewCameraOpt(i){if(this.focuedView){const e=this.focuedView.cameraOpt;O.isEqual(e,i)||(this.focuedView.cameraOpt=i)}}transformToOriginPoint(i,e){const t=this.getView(e);if(t!=null&&t.viewData){const o=t.viewData.convertToPointOnScreen(i[0],i[1]);return[o.x,o.y]}return i}transformToScenePoint(i,e){const t=this.getView(e);if(t!=null&&t.viewData){const o=t.viewData.convertToPointInWorld({x:i[0],y:i[1]});return[o.x,o.y]}return i}render(i){var e,t,o,s,n,a,c,l,u,h,d,f,g,p,y,I,w;for(const S of i){const{rect:C,imageBitmap:T,isClear:N,isUnClose:x,drawCanvas:D,clearCanvas:L,viewId:z}=S,j=(e=this.getView(z))==null?void 0:e.displayer;if(j&&C){const{dpr:E,canvasBgRef:R,canvasFloatRef:P,canvasServiceFloatRef:Z,canvasTopRef:_}=j,B=Math.floor(C.w*E),J=Math.floor(C.h*E),ie=C.x*E,le=C.y*E;if(N){switch(L){case we.TopFloat:(o=(t=_.current)==null?void 0:t.getContext("2d"))==null||o.clearRect(ie,le,B,J);break;case we.Float:(n=(s=P.current)==null?void 0:s.getContext("2d"))==null||n.clearRect(ie,le,B,J);break;case we.ServiceFloat:(c=(a=Z.current)==null?void 0:a.getContext("2d"))==null||c.clearRect(ie,le,B,J);break;case we.Bg:(u=(l=R.current)==null?void 0:l.getContext("2d"))==null||u.clearRect(ie,le,B,J);break}continue}if(D&&T)switch(D){case we.TopFloat:(d=(h=_.current)==null?void 0:h.getContext("2d"))==null||d.drawImage(T,0,0,B,J,ie,le,B,J);break;case we.Float:{(g=(f=P.current)==null?void 0:f.getContext("2d"))==null||g.drawImage(T,0,0,B,J,ie,le,B,J);break}case we.ServiceFloat:{(y=(p=Z.current)==null?void 0:p.getContext("2d"))==null||y.drawImage(T,0,0,B,J,ie,le,B,J);break}case we.Bg:{(w=(I=R.current)==null?void 0:I.getContext("2d"))==null||w.drawImage(T,0,0,B,J,ie,le,B,J);break}}if(x)continue;T==null||T.close()}}}showFloatBar(i,e,t){const o=this.getView(i),s=o==null?void 0:o.displayer.vDom;s&&s.showFloatBar(e,t)}activeTextEditor(i){const e=this.getView(i),t=e==null?void 0:e.displayer.vDom;t&&t.activeTextEditor()}unActiveTextEditor(i){const e=this.getView(i),t=e==null?void 0:e.displayer.vDom;t&&t.unActiveTextEditor()}showFloatBarBtn(i,e){const t=this.getView(i),o=t==null?void 0:t.displayer.vDom;o&&o.showFloatBarBtn(e)}updateTextEditorInfo(i,e){const t=this.getView(i),o=t==null?void 0:t.displayer.vDom;o&&o.updateTextEditorInfo(e)}setActiveMiniMap(i,e){const t=this.getView(i),o=t==null?void 0:t.displayer.vDom;o&&o.setActiveMiniMap(e&&i||void 0)}}M(Wt,"defaultCameraOpt",{centerX:0,centerY:0,scale:1}),M(Wt,"defaultScreenCanvasOpt",{autoRender:!1,contextType:"webgl2"}),M(Wt,"defaultLayerOpt",{offscreen:!0,handleEvent:!1,depth:!1});class Fy{constructor(i,e,t){M(this,"viewId");M(this,"control");M(this,"internalMsgEmitter");M(this,"commiter");M(this,"cachePoint");M(this,"cacheCursorPoint");M(this,"active",!0);M(this,"toolsKey");M(this,"cursorMouseMove");M(this,"mousedown",i=>{var e;if(this.active&&i.button===0&&this.viewId){this.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset(),this.toolsKey=(e=this.worker.getCurrentToolsData())==null?void 0:e.toolsType;const t=this.getPoint(i);this.cachePoint=t,t&&this.worker.originalEventLintener(A.Start,t,this.viewId),document.addEventListener("mousemove",this.mousemove,!1),document.addEventListener("mouseleave",this.mouseup,!1),document.addEventListener("mouseup",this.mouseup,!1)}});M(this,"mousemove",i=>{if(this.active&&this.viewId){const e=this.getPoint(i);if(this.cachePoint=e,this.checkConsumeCount())return;e&&this.worker.originalEventLintener(A.Doing,e,this.viewId)}});M(this,"mouseup",i=>{if(this.active&&i.button===0&&this.viewId){const e=this.getPoint(i)||this.cachePoint;e?(this.worker.originalEventLintener(A.Done,e,this.viewId).finally(()=>{document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1)}),this.cachePoint=void 0):(document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1))}});M(this,"touchstart",i=>{var e;if(this.active){if(!Ct(i)){this.worker.unWritable(),this.viewId&&this.worker.removeDrawingWork(this.viewId);return}if(this.viewId){this.toolsKey=(e=this.worker.getCurrentToolsData())==null?void 0:e.toolsType,!this.worker.isAbled()&&this.toolsKey&&this.control.effectViewContainer(this.toolsKey),this.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(i);this.cachePoint=t,t&&(this.worker.originalEventLintener(A.Start,t,this.viewId),document.addEventListener("touchmove",this.touchmove,!1),document.addEventListener("touchend",this.touchend,!1))}}});M(this,"touchmove",i=>{if(this.active){if(!Ct(i)){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const e=this.getPoint(i);if(this.cachePoint=e,this.checkConsumeCount())return;e&&this.worker.originalEventLintener(A.Doing,e,this.viewId)}}});M(this,"touchend",i=>{if(this.active){if(!Ct(i)||!this.worker.isAbled()){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const e=this.getPoint(i)||this.cachePoint;e?(this.worker.originalEventLintener(A.Done,e,this.viewId).finally(()=>{document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1)}),this.cachePoint=void 0):(document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1))}}});M(this,"cursorMouseLeave",()=>{this.viewId&&(this.cursorMouseMove.cancel(),this.cacheCursorPoint=[void 0,void 0],this.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId))});M(this,"keydown",i=>{this.control.hotkeyManager.colloctHotkey(i)});this.viewId=i,this.control=e,this.internalMsgEmitter=t;const o={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:this.viewId};this.commiter=new mi(o),this.cursorMouseMove=O.debounce(s=>{const n=this.getPoint(s);this.cacheCursorPoint&&O.isEqual(n,this.cacheCursorPoint)||!this.viewId||(this.cacheCursorPoint=n,n&&this.worker.sendCursorEvent(n,this.viewId))},this.moveDelayTime,{trailing:!0})}get worker(){return this.control.worker}bindToolsClass(){var e,t;const i=(t=(e=this.worker)==null?void 0:e.currentToolsData)==null?void 0:t.toolsType;switch(i){case v.Text:case v.Pencil:case v.LaserPen:case v.Arrow:case v.Straight:case v.Rectangle:case v.Ellipse:case v.Star:case v.Polygon:case v.SpeechBalloon:case v.Eraser:case v.PencilEraser:case v.BitMapEraser:case v.Selector:this.eventTragetElement&&(this.eventTragetElement.className=`netless-whiteboard ${i===v.Selector?"cursor-selector":i===v.Text?"cursor-text":i===v.Eraser||i===v.PencilEraser||i===v.BitMapEraser?"cursor-eraser":i===v.Pencil||i===v.LaserPen?"cursor-pencil":"cursor-arrow"}`);break}}mountView(){this.setCanvassStyle(),this.control.viewContainerManager.mountView(this.viewId)}reflashContainerOffset(){this.eventTragetElement&&(this.containerOffset=this.getContainerOffset(this.eventTragetElement,{x:0,y:0}))}updateSize(){this.setCanvassStyle(),this.reflashContainerOffset()}setViewId(i){this.viewId=i}get parentElement(){var i;return(i=this.eventTragetElement)==null?void 0:i.parentElement}destroy(){this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.clearViewCursor(this.viewId),this.internalMsgEmitter.removeAllListeners([ne.Cursor,this.viewId])}getPoint(i){const e=To(i);if(e&&O.isNumber(e.x)&&O.isNumber(e.y))return[e.x-this.containerOffset.x,e.y-this.containerOffset.y]}getActive(){this.active=!0}setActive(i){this.active=i}async stopEventHandler(){this.cachePoint&&(await this.worker.originalEventLintener(A.Done,this.cachePoint,this.viewId).finally(()=>{document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1),document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1)}),this.cachePoint=void 0)}getTranslate(i){const t=(i.style.WebkitTransform||getComputedStyle(i,"").getPropertyValue("-webkit-transform")||i.style.transform||getComputedStyle(i,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),o=t&&parseInt(t[0])||0,s=t&&parseInt(t[1])||0;return[o,s]}getContainerOffset(i,e){var s;const t=this.getTranslate(i);let o={x:e.x+i.offsetLeft-i.scrollLeft+t[0],y:e.y+i.offsetTop-i.scrollTop+t[1]};return(s=i.offsetParent)!=null&&s.nodeName&&i.offsetParent.nodeName!=="BODY"&&(o=this.getContainerOffset(i.offsetParent,o)),o}get isBezier(){return this.control.pluginOptions.extras.bezier.enable}get moveDelayTime(){var i,e;return((e=(i=this.control.pluginOptions.extras)==null?void 0:i.cursor)==null?void 0:e.moveDelayTime)??Me.cursor.moveDelayTime}get maxDrawCount(){return this.control.pluginOptions.extras.bezier.maxDrawCount||Me.bezier.maxDrawCount}checkConsumeCount(){return this.cachePoint&&this.toolsKey&&this.toolsKey===v.Pencil&&this.worker.getConsumeCount()>this.maxDrawCount?(this.stopEventHandler().finally(()=>{this.worker.publicMsgEmitter.emit("forceStop",Ti.longPencil,this.viewId)}),!0):!1}bindDisplayerEvent(i){i.addEventListener("mousedown",this.mousedown,!1),i.addEventListener("touchstart",this.touchstart,!1),i.addEventListener("mousemove",this.cursorMouseMove,!1),i.addEventListener("mouseleave",this.cursorMouseLeave,!1),i.addEventListener("keydown",this.keydown,!0)}removeDisplayerEvent(i){i.removeEventListener("mousedown",this.mousedown,!1),i.removeEventListener("touchstart",this.touchstart,!1),document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1),document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1),i.removeEventListener("mousemove",this.cursorMouseMove,!1),i.removeEventListener("mouseleave",this.cursorMouseLeave,!1),i.removeEventListener("keydown",this.keydown,!0)}}class vn{constructor(i,e){M(this,"viewId",ge);M(this,"control");M(this,"internalMsgEmitter");M(this,"commiter");M(this,"cachePoint");M(this,"cacheCursorPoint");M(this,"active",!0);M(this,"toolsKey");M(this,"cursorMouseMove");M(this,"mousedown",i=>{var e;if(this.active&&i.button===0){this.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(i);this.cachePoint=t,this.toolsKey=(e=this.worker.getCurrentToolsData())==null?void 0:e.toolsType,t&&(this.worker.originalEventLintener(A.Start,t,this.viewId),document.addEventListener("mousemove",this.mousemove,!1),document.addEventListener("mouseleave",this.mouseup,!1),document.addEventListener("mouseup",this.mouseup,!1))}});M(this,"mousemove",i=>{if(!this.active)return;const e=this.getPoint(i);this.cachePoint=e,!this.checkConsumeCount()&&e&&this.worker.originalEventLintener(A.Doing,e,this.viewId)});M(this,"mouseup",i=>{if(this.active&&i.button===0){const e=this.getPoint(i)||this.cachePoint;e?(this.worker.originalEventLintener(A.Done,e,this.viewId).finally(()=>{document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1)}),this.cachePoint=void 0):(document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1))}});M(this,"touchstart",i=>{var t;if(!this.active)return;if(!Ct(i)){this.worker.unWritable(),this.viewId&&this.worker.removeDrawingWork(this.viewId);return}this.toolsKey=(t=this.worker.getCurrentToolsData())==null?void 0:t.toolsType,!this.worker.isAbled()&&this.toolsKey&&this.control.effectViewContainer(this.toolsKey),this.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const e=this.getPoint(i);this.cachePoint=e,e&&(this.worker.originalEventLintener(A.Start,e,this.viewId),document.addEventListener("touchmove",this.touchmove,!1),document.addEventListener("touchend",this.touchend,!1))});M(this,"touchmove",i=>{if(!this.active)return;if(!Ct(i)){this.worker.unWritable(),this.viewId&&this.worker.removeDrawingWork(this.viewId);return}const e=this.getPoint(i);this.cachePoint=e,!this.checkConsumeCount()&&e&&this.worker.originalEventLintener(A.Doing,e,this.viewId)});M(this,"touchend",i=>{if(!this.active)return;if(!Ct(i)||!this.worker.isAbled()){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId);return}const e=this.getPoint(i)||this.cachePoint;e?(this.worker.originalEventLintener(A.Done,e,this.viewId).finally(()=>{document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1)}),this.cachePoint=void 0):(document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1))});M(this,"cursorMouseLeave",()=>{this.cursorMouseMove.cancel(),this.cacheCursorPoint=[void 0,void 0],this.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId)});M(this,"keydown",i=>{this.control.hotkeyManager.colloctHotkey(i)});this.control=i,this.internalMsgEmitter=e;const t={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:this.viewId};this.commiter=new mi(t),this.cursorMouseMove=O.debounce(o=>{const s=this.getPoint(o);this.cacheCursorPoint&&O.isEqual(s,this.cacheCursorPoint)||(this.cacheCursorPoint=s,s&&this.worker.sendCursorEvent(s,this.viewId))},this.moveDelayTime,{trailing:!0})}get worker(){return this.control.worker}bindToolsClass(){var o,s;const i=(s=(o=this.worker)==null?void 0:o.currentToolsData)==null?void 0:s.toolsType,e=this.control.renderControl.isWritable,t=this.worker.isAbled();switch(i){case v.Text:case v.Pencil:case v.LaserPen:case v.Arrow:case v.Straight:case v.Rectangle:case v.Ellipse:case v.Star:case v.Polygon:case v.SpeechBalloon:case v.Eraser:case v.PencilEraser:case v.BitMapEraser:case v.Selector:this.eventTragetElement&&(this.eventTragetElement.className=e&&t?`netless-whiteboard ${i===v.Selector?"cursor-selector":i===v.Text?"cursor-text":i===v.Eraser||i===v.PencilEraser||i===v.BitMapEraser?"cursor-eraser":i===v.Pencil||i===v.LaserPen?"cursor-pencil":"cursor-arrow"}`:"netless-whiteboard");break}}mountView(){this.setCanvassStyle(),this.control.viewContainerManager.mountView(this.viewId)}updateSize(){this.setCanvassStyle()}reflashContainerOffset(){this.eventTragetElement&&(this.containerOffset=this.getContainerOffset(this.eventTragetElement,{x:0,y:0}))}get parentElement(){var i;return(i=this.eventTragetElement)==null?void 0:i.parentElement}destroy(){this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.destroy(),this.internalMsgEmitter.removeAllListeners([ne.Cursor,this.viewId])}getPoint(i){const e=To(i);if(e&&O.isNumber(e.x)&&O.isNumber(e.y))return[e.x-this.containerOffset.x,e.y-this.containerOffset.y]}getActive(){return this.active}setActive(i){this.active=i}async stopEventHandler(){this.cachePoint&&(await this.worker.originalEventLintener(A.Done,this.cachePoint,this.viewId).finally(()=>{document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1),document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1)}),this.cachePoint=void 0)}getTranslate(i){const t=(i.style.WebkitTransform||getComputedStyle(i,"").getPropertyValue("-webkit-transform")||i.style.transform||getComputedStyle(i,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),o=t&&parseInt(t[0])||0,s=t&&parseInt(t[1])||0;return[o,s]}getContainerOffset(i,e){var s;const t=this.getTranslate(i);let o={x:e.x+i.offsetLeft-i.scrollLeft+t[0],y:e.y+i.offsetTop-i.scrollTop+t[1]};return(s=i.offsetParent)!=null&&s.nodeName&&i.offsetParent.nodeName!=="BODY"&&(o=this.getContainerOffset(i.offsetParent,o)),o}get moveDelayTime(){var i,e;return((e=(i=this.control.pluginOptions.extras)==null?void 0:i.cursor)==null?void 0:e.moveDelayTime)??Me.cursor.moveDelayTime}get isBezier(){return this.control.pluginOptions.extras.bezier.enable}get maxDrawCount(){return this.control.pluginOptions.extras.bezier.maxDrawCount||Me.bezier.maxDrawCount}checkConsumeCount(){const i=this.worker.getConsumeCount();return this.cachePoint&&this.toolsKey&&this.toolsKey===v.Pencil&&i>this.maxDrawCount?(this.stopEventHandler().finally(()=>{this.worker.publicMsgEmitter.emit("forceStop",Ti.longPencil,this.viewId)}),!0):!1}bindDisplayerEvent(i){i.addEventListener("mousedown",this.mousedown,!1),i.addEventListener("touchstart",this.touchstart,!1),i.addEventListener("mousemove",this.cursorMouseMove,!1),i.addEventListener("mouseleave",this.cursorMouseLeave,!1),i.addEventListener("keydown",this.keydown,!0)}removeDisplayerEvent(i){i.removeEventListener("mousedown",this.mousedown,!1),document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1),i.removeEventListener("touchstart",this.touchstart,!1),document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1),i.removeEventListener("mousemove",this.cursorMouseMove,!1),i.removeEventListener("mouseleave",this.cursorMouseLeave,!1),i.removeEventListener("keydown",this.keydown,!0)}}const Vy="index-module__Container__nLsM3",Qy="index-module__CanvasBox__j2Xe-",Zy="index-module__FloatCanvas__d1YR7",$y="index-module__TopFloatCanvas__7IaCw",Hy="index-module__CanvasBoxSub__hcMeK",Gy="index-module__SnapshotBox__--eeE",Xy="index-module__FloatBar__cm-EL",Jy="index-module__RotateBtn__HSSkf",qy="index-module__ResizeBtn__yjvda",Ky="index-module__CursorBox__2UHvI",_y="index-module__TextEditorContainer__Qm8KC",em="index-module__ResizeTowBox__HOllX",tm="index-module__FloatBarBtn__FJrOG",Oe={Container:Vy,CanvasBox:Qy,FloatCanvas:Zy,TopFloatCanvas:$y,CanvasBoxSub:Hy,SnapshotBox:Gy,FloatBar:Xy,RotateBtn:Jy,ResizeBtn:qy,CursorBox:Ky,TextEditorContainer:_y,ResizeTowBox:em,FloatBarBtn:tm},im={delete:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDZ2NmEyIDIgMCAwIDEtMiAySDZhMiAyIDAgMCAxLTItMlY2aDBtMS0yYTIgMiAwIDAgMSAyLTJoMmEyIDIgMCAwIDEgMiAyaDBNMyA0aDEwIiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==",duplicate:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjxwYXRoIGQ9Ik0xMSAySDZhMSAxIDAgMCAwLTEgMXY4YTEgMSAwIDAgMCAxIDFoNmExIDEgMCAwIDAgMS0xVjRoMGwtMi0yeiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+PHBhdGggZD0iTTExIDJ2MWExIDEgMCAwIDAgMSAxaDFsLTItMnoiLz48cGF0aCBkPSJNOSAxNEg0YTEgMSAwIDAgMS0xLTFWNWgwIiBzdHJva2UtbGluZWNhcD0icm91bmQiLz48L2c+PC9zdmc+","layer-pressed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zz4=","to-bottom":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDEwdjhtMCAwLTItMm0yIDIgMi0ybS00IDZoMTJtLTYtNGg2bS02LTRoNm0tNi00aDYiIHN0cm9rZT0iIzQ0NEU2MCIgZmlsbD0ibm9uZSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PC9zdmc+","to-top":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDIydi04bTAgMC0yIDJtMi0yIDIgMm0tNC02aDEybS02IDRoNm0tNiA0aDZtLTYgNGg2IiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","bold-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQuNSAySDhhMi41IDIuNSAwIDAgMSAwIDVINS41aDBtLTEgMGg0YTMgMyAwIDAgMSAwIDZoLTQgMG0wIDFWMiIgc3Ryb2tlPSIjMzM4MUZGIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=",bold:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQuNSAySDhhMi41IDIuNSAwIDAgMSAwIDVINS41aDBtLTEgMGg0YTMgMyAwIDAgMSAwIDZoLTQgMG0wIDFWMiIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","underline-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDJ2NWE0IDQgMCAxIDEtOCAwVjJoME0zIDE0aDEwIiBzdHJva2U9IiMzMzgxRkYiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==",underline:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDJ2NWE0IDQgMCAxIDEtOCAwVjJoME0zIDE0aDEwIiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","line-through-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQgOGg4bS0xLTNhMyAzIDAgMCAwLTMtM2gtLjkzOEEyLjY0IDIuNjQgMCAwIDAgNC41IDRhMi41NyAyLjU3IDAgMCAwIDEuMzQ0IDIuOTIybDQuMzEyIDIuMTU2QTIuNTcgMi41NyAwIDAgMSAxMS41IDEyYTIuNjQgMi42NCAwIDAgMS0yLjU2MiAySDdhMyAzIDAgMCAxLT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Mjh2LTY0ek0yNDUuMzMzMzMzIDY4Mi42NjY2Njd2LTIzNC42NjY2NjdoLTY0VjY4Mi42NjY2NjdoNjR6IG0tNTQuNjEzMzMzLTIxMi4wNTMzMzRsODUuMzMzMzMzIDg1LjMzMzMzNCA0NS4yMjY2NjctNDUuMjI2NjY3LTg1LjMzMzMzMy04NS4zMzMzMzMtNDUuMjI2NjY3IDQ1LjIyNjY2NnogbTAtNDUuMjI2NjY2bC04NS4zMzMzMzMgODUuMzMzMzMzIDQ1LjIyNjY2NiA0NS4yMjY2NjcgODUuMzMzMzM0LTg1LjMzMzMzNC00NS4yMjY2NjctNDUuMjI2NjY2eiIgIGZpbGw9IiM0NDRFNjAiPjwvcGF0aD48L3N2Zz4="};function je(r){return im[r]}const om=r=>{const{workIds:i,mananger:e}=r;return m.createElement("div",{className:"button normal-button",style:{touchAction:"none"},onPointerUp:t=>{t.cancelable&&t.preventDefault(),t.stopPropagation(),t.nativeEvent.stopImmediatePropagation(),ae.emitMethod(ne.MainEngine,F.DeleteNode,{workIds:i||[G],viewId:e.viewId})}},m.createElement("img",{alt:"icon",src:je("delete")}))},sm=r=>{const{workIds:i,viewId:e}=r;return m.createElement("div",{className:"button normal-button",onPointerUp:t=>{t.stopPropagation(),ae.emitMethod(ne.MainEngine,F.CopyNode,{workIds:i||[G],viewId:e})}},m.createElement("img",{alt:"icon",src:je("duplicate")}))},gs=r=>{const{icon:i,onPointerUpHandler:e}=r;return m.createElement("div",{className:"button normal-button",onPointerUp:e},m.createElement("img",{src:je(i)}))},nm=r=>{const{open:i,setOpen:e,floatBarRef:t}=r,{floatBarData:o,mananger:s}=m.useContext(Se),[n,a]=m.useState([]),c=m.useMemo(()=>{if(t!=null&&t.current&&O.isNumber(o==null?void 0:o.y)&&(s!=null&&s.height)){if(t.current.offsetTop&&t.current.offsetTop+o.y>180){const h={};return h.top="inherit",h.bottom=50,h}else if(!t.current.offsetTop&&(s==null?void 0:s.height)-t.current.offsetTop-o.y<120){const h={};return h.top="inherit",h.bottom=50,h}}},[t==null?void 0:t.current,o,s]),l=m.useMemo(()=>i?m.createElement("div",{className:"image-layer-menu",style:c},m.createElement(gs,{icon:"to-top",onPointerUpHandler:h=>{h.stopPropagation(),ae.emitMethod(ne.MainEngine,F.ZIndexNode,{workIds:[G],layer:Jt.Top,viewId:s==null?void 0:s.viewId})}}),m.createElement(gs,{icon:"to-bottom",onPointerUpHandler:h=>{h.stopPropagation(),ae.emitMethod(ne.MainEngine,F.ZIndexNode,{workIds:[G],layer:Jt.Bottom,viewId:s==null?void 0:s.viewId})}})):null,[i,c]),u=h=>{h.stopPropagation(),h.nativeEvent.stopImmediatePropagation(),e(!i)};return m.useEffect(()=>{O.isEqual(o==null?void 0:o.selectIds,n)||o!=null&&o.selectIds&&!O.isEqual(o==null?void 0:o.selectIds,n)&&(a(o==null?void 0:o.selectIds),e(!1))},[i,o,n,e]),m.createElement("div",{className:`button normal-button ${i&&"active"}`,onPointerUp:u},l,m.createElement("img",{alt:"icon",src:je(i?"layer-pressed":"layer")}))},ii=r=>{r.stopPropagation(),r.nativeEvent.stopImmediatePropagation()},rm=()=>m.createElement("svg",{style:{marginLeft:"2px"},viewBox:"0 0 1025 1024",width:"14",height:"14"},m.createElement("path",{d:"M1016.5248 493.8752c-9.984-9.984-26.2144-9.984-36.1984 0l-183.6032 183.6032c-29.952 29.952-78.6944 29.952-108.5952 0l-239.2064-239.2064c-14.4384-14.4384-22.3744-33.6896-22.3744-54.3232s7.936-39.8848 22.3744-54.3232l183.6032-183.6032c9.984-9.984 9.984-26.2144 0-36.1984s-26.2144-9.984-36.1984 0l-183.6032 183.6032c-24.1152 24.1152-37.376 56.2176-37.376 90.5216 0 14.592 2.4576 28.8256 7.0656 42.1888l-374.8864 374.8864c-4.8128 4.8128-7.4752 11.3152-7.4752 18.1248l0 76.8c0 14.1312 11.4688 25.6 25.6 25.6l486.4 0c6.8096 0 13.312-2.7136 18.1248-7.4752l170.0864-170.0864c13.3632 4.6592 27.5968 7.0656 42.1888 7.0656 34.2528 0 66.4064-13.2608 90.5216-37.376l183.6032-183.6032c9.984-9.984 9.984-26.2144 0-36.1984zM501.4016 870.4l-450.2016 0 0-40.6016 358.5024-358.5024c1.024 1.0752 1.9968 2.1504 3.0208 3.1744l239.2064 239.2064c1.024 1.024 2.0992 2.048 3.1744 3.0208l-153.7024 153.7024z",fill:"#000000"})),Nn=r=>{const{activeColor:i,onPointerUpHandler:e}=r;return m.createElement("div",{className:`font-color-button ${i==="transparent"?"active":""}`,onPointerUp:e},m.createElement("div",{className:"circle none"}))},Ai=r=>{const{color:i,activeColor:e,onPointerUpHandler:t}=r;return m.createElement("div",{className:`font-color-button ${i===e?"active":""}`,onPointerUp:t},m.createElement("div",{className:"circle",style:{backgroundColor:be(i,1)}}))},ji=r=>{const{opacity:i,activeColor:e,setCurOpacity:t}=r,[o,s]=m.useState({x:108,y:0}),n=m.useRef(0);if(m.useEffect(()=>{s({x:i*100+8,y:0})},[]),!e)return null;const a=(h,d)=>{const f=Math.min(Math.max(h-8,0),100)/100;(i!==f||d===A.Done)&&t(f,e,d)},c=(h,d)=>{d.x!==(o==null?void 0:o.x)&&s({x:d.x,y:0}),!n.current&&(n.current=setTimeout(()=>{n.current=0,a(d.x,A.Doing)},100))},l=()=>{t(i,e,A.Start)},u=(h,d)=>{d.x!==(o==null?void 0:o.x)&&s({x:d.x,y:0}),n.current&&(clearTimeout(n.current),n.current=0),a(d.x,A.Done)};return m.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onPointerUp:h=>{n.current&&(clearTimeout(n.current),n.current=0);const d=h.nativeEvent.offsetX,f=Math.min(Math.max(d-12,0),100)/100;s({x:f*100+8,y:0}),t(f,e,A.Done)}},m.createElement("div",{className:"range-color",style:{background:`linear-gradient(to right, ${be(e,0)}, ${be(e,1)})`}}),m.createElement("div",{className:"range-opacity"},m.createElement(Yt,{bounds:"parent",axis:"x",position:o,onDrag:c,onStart:l,onStop:u},m.createElement("div",{className:"circle",style:{backgroundColor:be(e,i)},onPointerUp:ii}))))},am=r=>{const{min:i,max:e,activeNumber:t,setActiveNumber:o,color:s}=r,[n,a]=m.useState({x:108,y:0}),c=m.useRef(0);if(m.useEffect(()=>{const f=Math.ceil((t-i)/(e-i)*100)+8;a({x:f,y:0})},[]),!t)return null;const l=(f,g)=>{const p=Math.ceil(Math.max(f-8,0)/100*(e-i)+i);(t!==p||g===A.Done)&&o(p,g)},u=(f,g)=>{g.x!==(n==null?void 0:n.x)&&a({x:g.x,y:0}),!c.current&&(c.current=setTimeout(()=>{c.current=0,l(g.x,A.Doing)},100))},h=()=>{o(t,A.Start)},d=(f,g)=>{g.x!==(n==null?void 0:n.x)&&a({x:g.x,y:0}),c.current&&(clearTimeout(c.current),c.current=0),l(g.x,A.Done)};return m.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onPointerUp:f=>{c.current&&(clearTimeout(c.current),c.current=0);const g=f.nativeEvent.offsetX,p=Math.ceil(Math.max(g-12,0)/100*(e-i)+i),y=Math.ceil((p-i)/(e-i)*100)+8;a({x:y,y:0}),o(p,A.Done)}},m.createElement("div",{className:"range-color",style:{backgroundColor:s}}),m.createElement("div",{className:"range-opacity"},m.createElement(Yt,{bounds:"parent",axis:"x",position:n,onDrag:u,onStart:h,onStop:d},m.createElement("div",{className:"circle",style:{backgroundColor:s},onPointerUp:ii},m.createElement("div",{className:"range-opacity-data-icon"},t)))))},cm=r=>{const{useStroke:i,color:e,activeStrokeType:t,setStrokeType:o}=r;return m.createElement("div",{className:"stroke-type-box"},!!i&&m.createElement("div",{className:`stroke-type-box-item Stroke ${t===se.Stroke&&"active"}`,style:{backgroundColor:e},onPointerUp:()=>{o(se.Stroke)}}),m.createElement("div",{className:`stroke-type-box-item Normal ${t===se.Normal&&"active"}`,style:{borderColor:e},onPointerUp:()=>{o(se.Normal)}}),m.createElement("div",{className:`stroke-type-box-item Dotted ${t===se.Dotted&&"active"}`,style:{borderColor:e},onPointerUp:()=>{o(se.Dotted)}}),m.createElement("div",{className:`stroke-type-box-item LongDotted ${t===se.LongDotted&&"active"}`,style:{borderColor:e},onPointerUp:()=>{o(se.LongDotted)}}))},lm=r=>{const{open:i,setOpen:e,floatBarRef:t}=r,{floatBarData:o,floatBarColors:s,mananger:n,setFloatBarData:a}=m.useContext(Se),[c,l]=m.useState(),[u,h]=m.useState(1);m.useEffect(()=>{if(o!=null&&o.strokeColor){const[w,S]=Di(o.strokeColor);l(w),h(S)}},[o]);const d=m.useMemo(()=>{if(t!=null&&t.current&&o&&O.isNumber(o==null?void 0:o.y)&&(n!=null&&n.height)){if(t.current.offsetTop&&t.current.offsetTop+o.y>180){const w={};return w.top="inherit",w.bottom=50,w}else if(!t.current.offsetTop&&(n==null?void 0:n.height)-t.current.offsetTop-o.y<120){const w={};return w.top="inherit",w.bottom=50,w}}},[o,t,n==null?void 0:n.height]),f=m.useMemo(()=>m.createElement(ji,{key:"strokeColors",opacity:u,activeColor:c,setCurOpacity:(w,S,C)=>{h(w);const T=be(S,w);o!=null&&o.strokeColor&&a({strokeColor:T}),ae.emitMethod(ne.MainEngine,F.SetColorNode,{workIds:[G],strokeColor:T,workState:C,viewId:n==null?void 0:n.viewId})}}),[u,c,o==null?void 0:o.strokeColor,n==null?void 0:n.viewId,a]),g=m.useMemo(()=>c&&o&&o.thickness?m.createElement(am,{key:"strokeThickness",min:Math.min(o.thickness,(n==null?void 0:n.control.pluginOptions.extras.strokeWidth.min)||Me.strokeWidth.min),max:Math.max(o.thickness,(n==null?void 0:n.control.pluginOptions.extras.strokeWidth.max)||Me.strokeWidth.max),activeNumber:o.thickness,setActiveNumber:(w,S)=>{o!=null&&o.thickness&&a({thickness:w}),ae.emitMethod(ne.MainEngine,F.SetColorNode,{workIds:[G],thickness:w,workState:S,viewId:n==null?void 0:n.viewId})},color:c}):null,[c,o,n==null?void 0:n.control.pluginOptions.extras.strokeWidth.max,n==null?void 0:n.control.pluginOptions.extras.strokeWidth.min,n==null?void 0:n.viewId,a]),p=m.useMemo(()=>c&&o&&(o!=null&&o.strokeType)?m.createElement(cm,{key:"strokeType",useStroke:o==null?void 0:o.useStroke,activeStrokeType:o.strokeType,setStrokeType:w=>{o.strokeType&&a({strokeType:w}),ae.emitMethod(ne.MainEngine,F.SetColorNode,{workIds:[G],strokeType:w,workState:A.Done,viewId:n==null?void 0:n.viewId})},color:c}):null,[c,o,n==null?void 0:n.viewId,a]),y=m.useMemo(()=>i?m.createElement("div",{className:"font-colors-menu",style:d,onPointerUp:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},p,g,m.createElement("div",{className:"font-colors-line"}),s.concat().map((w,S)=>{const C=ti(...w);return m.createElement(Ai,{key:S,color:C,activeColor:c,onPointerUpHandler:T=>{T.stopPropagation(),l(C);const N=be(C,u);o!=null&&o.strokeColor&&(o.strokeColor=N,a({strokeColor:N})),ae.emitMethod(ne.MainEngine,F.SetColorNode,{workIds:[G],workState:A.Done,strokeColor:N,viewId:n==null?void 0:n.viewId})}})}),f):null,[i,d,p,g,s,f,c,u,o,n==null?void 0:n.viewId,a]),I=m.useMemo(()=>c?m.createElement("div",{className:"color-bar-ring",style:{backgroundColor:be(c,u)}},m.createElement("div",{className:"circle"})):null,[c,u]);return m.createElement("div",{className:`button normal-button font-colors-icon ${i&&"active"}`,onPointerUp:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),e(!i)}},I,y)},hm=r=>{const{open:i,setOpen:e,floatBarRef:t}=r,{floatBarData:o,floatBarColors:s,mananger:n,setFloatBarData:a}=m.useContext(Se),[c,l]=m.useState(),[u,h]=m.useState(1);m.useEffect(()=>{if(o!=null&&o.fillColor){const[y,I]=(o==null?void 0:o.fillColor)==="transparent"&&["transparent",1]||Di(o.fillColor);l(y),h(I)}},[o]);const d=m.useMemo(()=>{if(t!=null&&t.current&&O.isNumber(o==null?void 0:o.y)&&(n!=null&&n.height)){if(t.current.offsetTop&&t.current.offsetTop+o.y>200){const y={};return y.top="inherit",y.bottom=50,y}else if(!t.current.offsetTop&&(n==null?void 0:n.height)-t.current.offsetTop-o.y<140){const y={};return y.top="inherit",y.bottom=50,y}}},[t,o,n==null?void 0:n.height]),f=m.useMemo(()=>c&&c!=="transparent"?m.createElement(ji,{key:"fillColors",opacity:u||0,activeColor:c,setCurOpacity:(y,I,w)=>{h(y);const S=be(I,y);o!=null&&o.fillColor&&(o.fillColor=S,a({fillColor:S})),ae.emitMethod(ne.MainEngine,F.SetColorNode,{workIds:[G],fillColor:c&&be(I,y),workState:w,viewId:n==null?void 0:n.viewId})}}):null,[c,u,o,n==null?void 0:n.viewId,a]),g=m.useMemo(()=>i?m.createElement("div",{className:"font-colors-menu",style:d,onPointerUp:y=>{y.stopPropagation(),y.nativeEvent.stopImmediatePropagation()}},m.createElement(Nn,{activeColor:c,onPointerUpHandler:y=>{y.stopPropagation(),l("transparent");const I="transparent";o!=null&&o.fillColor&&(o.fillColor=I,a({fillColor:I})),ae.emitMethod(ne.MainEngine,F.SetColorNode,{workIds:[G],workState:A.Done,fillColor:I,viewId:n==null?void 0:n.viewId})}}),s.map((y,I)=>{const w=ti(...y);return m.createElement(Ai,{key:I,color:w,activeColor:c,onPointerUpHandler:S=>{S.cancelable&&S.preventDefault(),S.stopPropagation(),l(w);const C=be(w,u);o!=null&&o.fillColor&&(o.fillColor=C,a({fillColor:C})),ae.emitMethod(ne.MainEngine,F.SetColorNode,{workIds:[G],workState:A.Done,fillColor:C,viewId:n==null?void 0:n.viewId})}})}),f):null,[i,d,c,s,f,o,n==null?void 0:n.viewId,a,u]),p=m.useMemo(()=>{const y=c&&c!=="transparent"&&be(c,u)||"transparent";return m.createElement("div",{className:"color-bar-fill"},m.createElement("div",{className:"circle",style:{backgroundColor:y}}))},[c,u]);return m.createElement("div",{className:`button normal-button font-colors-icon ${i&&"active"}`,onPointerUp:y=>{y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),e(!i)}},p,g)},um=r=>{const{open:i,setOpen:e,textOpt:t,workIds:o,floatBarRef:s}=r,{floatBarColors:n,mananger:a,setFloatBarData:c,floatBarData:l}=m.useContext(Se),[u,h]=m.useState(),[d,f]=m.useState(1);m.useEffect(()=>{if(t!=null&&t.fontColor){const[w,S]=(t==null?void 0:t.fontColor)==="transparent"&&["transparent",0]||Di(t.fontColor);h(w),f(S)}},[t==null?void 0:t.fontColor]);const g=m.useMemo(()=>{if(s!=null&&s.current&&l&&O.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(s.current.offsetTop&&s.current.offsetTop+l.y>180){const w={};return w.top="inherit",w.bottom=50,w}else if(!s.current.offsetTop&&(a==null?void 0:a.height)-s.current.offsetTop-l.y<120){const w={};return w.top="inherit",w.bottom=50,w}}},[s,l,a==null?void 0:a.height]),p=m.useMemo(()=>u&&u!=="transparent"?m.createElement(ji,{key:"fontColors",opacity:d,activeColor:u,setCurOpacity:(w,S,C)=>{f(w);const T=be(S,w);l!=null&&l.textOpt&&(l.textOpt.fontColor=T,c({textOpt:l.textOpt})),ae.emitMethod(ne.MainEngine,F.SetColorNode,{workIds:o||[G],fontColor:u&&T,workState:C,viewId:a==null?void 0:a.viewId})}}):null,[c,u,d,a==null?void 0:a.control.room,a==null?void 0:a.viewId,l==null?void 0:l.textOpt,o]),y=m.useMemo(()=>i?m.createElement("div",{className:"font-colors-menu",style:g,onPointerUp:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},n.map((w,S)=>{const C=ti(...w);return m.createElement(Ai,{key:S,color:C,activeColor:u,onPointerUpHandler:T=>{T.stopPropagation(),h(C);const N=be(C,d);l!=null&&l.textOpt&&(l.textOpt.fontColor=N,c({textOpt:l.textOpt})),ae.emitMethod(ne.MainEngine,F.SetColorNode,{workIds:o||[G],workState:A.Done,fontColor:N,viewId:a==null?void 0:a.viewId})}})}),p):null,[c,i,n,p,u,d,l==null?void 0:l.textOpt,o,a==null?void 0:a.viewId,g]),I=m.useMemo(()=>{const w=u&&u!=="transparent"&&be(u,d)||"transparent";return m.createElement("div",{className:"color-bar"},m.createElement("div",{className:"color-bar-color",style:{backgroundColor:w}}))},[u,d]);return m.createElement("div",{className:`button normal-button font-colors-icon ${i&&"active"}`,onPointerUp:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),e(!i)}},m.createElement("img",{alt:"icon",src:je("font-colors")}),I,y)},dm=r=>{const{open:i,setOpen:e,textOpt:t,workIds:o,floatBarRef:s}=r,{floatBarColors:n,mananger:a,setFloatBarData:c,floatBarData:l}=m.useContext(Se),[u,h]=m.useState(),[d,f]=m.useState(1);m.useEffect(()=>{if(t!=null&&t.fontBgColor){const[w,S]=(t==null?void 0:t.fontBgColor)==="transparent"&&["transparent",1]||Di(t.fontBgColor);h(w),f(S)}},[t==null?void 0:t.fontBgColor]);const g=m.useMemo(()=>{if(s!=null&&s.current&&l&&O.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(s.current.offsetTop&&s.current.offsetTop+l.y>180){const w={};return w.top="inherit",w.bottom=50,w}else if(!s.current.offsetTop&&(a==null?void 0:a.height)-s.current.offsetTop-l.y<120){const w={};return w.top="inherit",w.bottom=50,w}}},[s,l,a==null?void 0:a.height]),p=m.useMemo(()=>u&&u!=="transparent"?m.createElement(ji,{key:"fontBgColor",opacity:d||0,activeColor:u,setCurOpacity:(w,S,C)=>{f(w);const T=be(S,w);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=T,c({textOpt:l.textOpt})),ae.emitMethod(ne.MainEngine,F.SetColorNode,{workIds:o||[G],fontBgColor:u&&be(S,w),workState:C,viewId:a==null?void 0:a.viewId})}}):null,[u,d,l==null?void 0:l.textOpt,o,a==null?void 0:a.viewId,c]),y=m.useMemo(()=>i?m.createElement("div",{className:"font-colors-menu",style:g,onPointerUp:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},m.createElement(Nn,{activeColor:u,onPointerUpHandler:w=>{w.stopPropagation();const S="transparent";h(S),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=S,c({textOpt:l.textOpt})),ae.emitMethod(ne.MainEngine,F.SetColorNode,{workIds:o||[G],workState:A.Done,fontBgColor:S,viewId:a==null?void 0:a.viewId})}}),n.map((w,S)=>{const C=ti(...w);return m.createElement(Ai,{key:S,color:C,activeColor:u,onPointerUpHandler:T=>{T.stopPropagation(),h(C);const N=be(C,d);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=N,c({textOpt:l.textOpt})),ae.emitMethod(ne.MainEngine,F.SetColorNode,{workIds:o||[G],workState:A.Done,fontBgColor:be(C,d),viewId:a==null?void 0:a.viewId})}})}),p):null,[c,i,n,p,d,u,l==null?void 0:l.textOpt,o,a==null?void 0:a.viewId,g]),I=m.useMemo(()=>{const w=u&&u!=="transparent"&&be(u,d)||"transparent";return m.createElement("div",{className:"color-bar",style:{marginTop:0}},m.createElement("div",{className:"color-bar-color",style:{backgroundColor:w}}))},[u,d]);return m.createElement("div",{className:`button normal-button font-colors-icon ${i&&"active"}`,onPointerUp:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),e(!i)}},m.createElement(rm,null),I,y)},pm=r=>{const{bold:i,setBold:e,workIds:t,viewId:o}=r,s=n=>{const a=i==="bold"?"normal":"bold";n==null||n.stopPropagation(),e(a),ae.emitMethod(ne.MainEngine,F.SetFontStyle,{workIds:t,viewId:o,bold:a})};return m.createElement("div",{className:"font-style-button",onPointerUp:s},m.createElement("img",{alt:"icon",src:je(i==="bold"?"bold-active":"bold")}))},gm=r=>{const{underline:i,setUnderline:e,workIds:t,viewId:o}=r,s=n=>{const a=!i;n==null||n.stopPropagation(),e(a),ae.emitMethod(ne.MainEngine,F.SetFontStyle,{workIds:t,viewId:o,underline:a})};return m.createElement("div",{className:"font-style-button",onPointerUp:s},m.createElement("img",{alt:"icon",src:je(i?"underline-active":"underline")}))},fm=r=>{const{lineThrough:i,setLineThrough:e,workIds:t,viewId:o}=r,s=n=>{const a=!i;n==null||n.stopPropagation(),e(a),ae.emitMethod(ne.MainEngine,F.SetFontStyle,{workIds:t,viewId:o,lineThrough:a})};return m.createElement("div",{className:"font-style-button",onPointerUp:s},m.createElement("img",{alt:"icon",src:je(i?"line-through-active":"line-through")}))},Mm=r=>{const{italic:i,setItalic:e,workIds:t,viewId:o}=r,s=n=>{const a=i==="italic"?"normal":"italic";n==null||n.stopPropagation(),e(a),ae.emitMethod(ne.MainEngine,F.SetFontStyle,{workIds:t,viewId:o,italic:a})};return m.createElement("div",{className:"font-style-button",onPointerUp:s},m.createElement("img",{alt:"icon",src:je(i==="italic"?"italic-active":"italic")}))},ym=r=>{const{open:i,setOpen:e,textOpt:t,workIds:o,style:s,floatBarRef:n}=r,{mananger:a,floatBarData:c}=m.useContext(Se),[l,u]=m.useState("normal"),[h,d]=m.useState("normal"),[f,g]=m.useState(!1),[p,y]=m.useState(!1);m.useEffect(()=>{t!=null&&t.bold&&u(t.bold),O.isBoolean(t==null?void 0:t.underline)&&g(t.underline||!1),O.isBoolean(t==null?void 0:t.lineThrough)&&y(t.lineThrough||!1),t!=null&&t.italic&&d(t.italic)},[t]);const I=m.useMemo(()=>{if(s&&(n!=null&&n.current)&&O.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(n.current.offsetTop&&n.current.offsetTop+c.y>180){const S={};return S.top="inherit",S.bottom=50,S}else if(!n.current.offsetTop&&(a==null?void 0:a.height)-n.current.offsetTop-c.y<120){const S={};return S.top="inherit",S.bottom=50,S}}},[s,n==null?void 0:n.current,c,a]),w=m.useMemo(()=>i?m.createElement("div",{className:"font-style-menu",style:I,onPointerUp:S=>{S.stopPropagation(),S.nativeEvent.stopImmediatePropagation()}},m.createElement(pm,{workIds:o||[G],bold:l,setBold:u,viewId:a==null?void 0:a.viewId}),m.createElement(gm,{workIds:o||[G],underline:f,setUnderline:g,viewId:a==null?void 0:a.viewId}),m.createElement(fm,{workIds:o||[G],lineThrough:p,setLineThrough:y,viewId:a==null?void 0:a.viewId}),m.createElement(Mm,{workIds:o||[G],italic:h,setItalic:d,viewId:a==null?void 0:a.viewId})):null,[i,o,l,a==null?void 0:a.viewId,f,p,h,I]);return m.createElement("div",{className:`button normal-button ${i&&"active"}`,onPointerUp:S=>{S.stopPropagation(),S.nativeEvent.stopImmediatePropagation(),e(!i)}},m.createElement("img",{alt:"icon",src:je(i?"font-style-active":"font-style")}),w)},rt=Object.freeze([12,14,18,24,36,48,64,80,144,288]),jt=["top","topLeft","topRight","bottom","bottomLeft","bottomRight","left","leftTop","leftBottom","right","rightTop","rightBottom"],mm=new Map([["selector","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAKeSURBVHgB3VTLi1JhFD86zlQ4ysxSXAy1GWYZzMxmYAhHagRB/QN8FLqPFq4FIQhXkS6kTQ4t2ilIKEWgSS0SmVpIm0BdaBJSaOP78XU+PXey6+saburAD+73uL/feX0H4H81GQdj7D7ilrCGFRonk3c6nXvhcJiFQiGWy+Xy/X7/WbPZ1K1KkBOsl0qlO36/n+3t7Q1hs9kYF+WC3W73MTpxc1lBmej7KuJaoVDInZ6eqsWXDw4OwGKxwPHx8Se1Wn1Wr9cjW1tbOTxi9D9bJCJHXEFslsvlR263+246nYZZptPpQK/Xg8lkSvZ6vbNGo5EgQRCLiSPhIqpoNHobo3keCARgkalUKjg5ORlGuL+/n8T6PVAqlefjYmKRdYQSsZ3P5z8aDAYVLGFarRbi8fhbhUKhx2VPEJGP3eEbfTrs4MUwr4EU49FYrVbweDy1SqXyipy95FaI7g8QXS6SyWReHx4e2ubVBc+HtTk6OjqvVqtvvF7vi0gkUiSByyyJ21BGwpswJ2Vmsxlw/0Kj0bxMJBJJl8vFPWkhGogLQoeyMhEJo2jGUzYRjcPh+Op0Oq2pVOoHkXE0SahF/w+E+3KYNEaX2pSyiSiKxeJTFPiGyyriO6FKEUgSESLp4ht4bzQaf4pFYrHYO/ysEXGNyJtjKRqM/zNNhFuf0B7vst3dXdjZ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4NTc2LDEyLjUgMjAsMTIuNSBaIiBpZD0i5b2i54q257uT5ZCIIiBmaWxsPSIjMjEyMzI0IiBmaWxsLXJ1bGU9Im5vbnplcm8iPjwvcGF0aD4KICAgICAgICAgICAgPC9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+"]]),wm=r=>{const{style:i,onClickHandler:e}=r;return m.createElement("div",{className:"font-size-menu",style:i,onPointerUp:t=>{t.stopPropagation(),t.nativeEvent.stopImmediatePropagation()}},rt.map(t=>m.createElement("div",{className:"font-size-btn",key:t,onPointerUp:()=>{e(t)}},t)))},Im=r=>{const i=m.useRef(null),{open:e,setOpen:t,textOpt:o,workIds:s,floatBarRef:n}=r,{mananger:a,floatBarData:c}=m.useContext(Se),[l,u]=m.useState(0),h=rt.length-1;m.useEffect(()=>{o!=null&&o.fontSize&&(u(o.fontSize),i.current&&(i.current.value=o.fontSize.toString()))},[o==null?void 0:o.fontSize]);const d=m.useMemo(()=>{if(n!=null&&n.current&&O.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(n.current.offsetTop&&n.current.offsetTop+c.y>180){const I={};return I.top="inherit",I.bottom=35,I}else if(!n.current.offsetTop&&(a==null?void 0:a.height)-n.current.offsetTop-c.y<120){const I={};return I.top="inherit",I.bottom=35,I}}},[n==null?void 0:n.current,c,a]);function f(I){u(I),I&&I>=rt[0]&&I<=rt[h]&&ae.emitMethod(ne.MainEngine,F.SetFontStyle,{workIds:s||[G],fontSize:I,viewId:a==null?void 0:a.viewId})}const g=I=>{var w;(w=i.current)==null||w.blur(),t(!1),y(I)},p=m.useMemo(()=>e?m.createElement(wm,{onClickHandler:g,style:d}):null,[e,g,d]),y=I=>{I>rt[h]&&(I=rt[h]),I<rt[0]&&(I=rt[0]),f(I)};return m.createElement("div",{className:"button normal-button font-size-barBtn",style:{width:50},onPointerUp:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation()}},m.createElement("input",{className:"font-size-input",ref:i,onTouchEnd:()=>{i.current&&i.current.focus()},onClick:()=>{t(!e),i.current&&i.current.focus()},onKeyDown:I=>{if(I.key==="Backspace"){const w=window.getSelection(),S=w==null?void 0:w.getRangeAt(0);if(S!=null&&S.collapsed)return I.cancelable&&I.preventDefault(),document.execCommand("delete",!1),!1}return!1},onKeyUp:I=>{var w;if(i.current){const S=i.current.value,C=parseInt(S);isNaN(C)?i.current.value="0":i.current.value=C.toString(),C&&I.key==="Enter"&&(y(C),(w=i.current)==null||w.blur(),t(!1))}}}),m.createElement("div",{className:"font-size-btns"},m.createElement("div",{className:"font-size-add",onPointerUp:()=>{y(l+rt[0])}}),m.createElement("div",{className:"font-size-cut",onPointerUp:()=>{y(l-rt[0])}})),p)},Tm=r=>{const{workIds:i,mananger:e,islocked:t}=r;return m.createElement("div",{className:"button normal-button",onPointerUp:o=>{o.stopPropagation(),ae.emitMethod(ne.MainEngine,F.SetLock,{workIds:i||[G],isLocked:!t,viewId:e==null?void 0:e.viewId})}},m.createElement("img",{alt:"icon",src:je(t?"unlock-new":"lock-new")}))},Xi=r=>{const{icon:i,min:e,max:t,step:o,value:s,onInputHandler:n}=r,[a,c]=m.useState(0),l=m.useRef(null),u=h=>{h>t&&(h=t),h<e&&(h=e),c(h),n(h),l.current&&(l.current.value=h.toString())};return m.useEffect(()=>{s&&(c(s),l.current&&(l.current.value=s.toString()))},[s]),m.createElement("div",{className:"button input-button"},m.createElement("img",{src:je(i)}),m.createElement("input",{className:"input-number",type:"text",ref:l,onPointerUp:()=>{l.current&&l.current.focus()},onKeyDown:h=>{if(h.key==="Backspace"){const d=window.getSelection(),f=d==null?void 0:d.getRangeAt(0);if(f!=null&&f.collapsed)return h.cancelable&&h.preventDefault(),document.execCommand("delete",!1),!1}},onKeyUp:()=>{if(l.current){const h=l.current.value,d=parseInt(h);isNaN(d)?l.current.value="0":l.current.value=d.toString()}},onChange:h=>{const d=h.target.value,f=parseInt(d);f&&f&&f>=e&&f<=t&&u(f)}}),m.createElement("div",{className:"input-number-btns"},m.createElement("div",{className:"input-number-add",onPointerUp:()=>{u(a+o)}}),m.createElement("div",{className:"input-number-cut",onPointerUp:()=>{u(a-o)}})))},vm=r=>{const{icon:i,min:e,max:t,step:o,value:s,onInputHandler:n}=r;return m.createElement("div",{className:"button input-button"},m.createElement("img",{src:je(i)}),m.createElement(Nm,{min:e,max:t,step:o,value:s,onInputHandler:n}))},Nm=r=>{const{value:i,min:e,max:t,onInputHandler:o}=r,[s,n]=m.useState({x:0,y:0});m.useEffect(()=>{n({x:i*100,y:0})},[]);const a=(u,h)=>{let d=Math.floor(Math.max(h.x,e*100));d=Math.floor(Math.min(d,t*100)),h.x!==(s==null?void 0:s.x)&&n({x:d,y:0});const f=d/100;i!==f&&o(f)},c=()=>{},l=(u,h)=>{let d=Math.floor(Math.max(h.x,e*100));d=Math.floor(Math.min(d,t*100)),h.x!==(s==null?void 0:s.x)&&n({x:d,y:0});const f=d/100;i!==f&&o(f)};return m.createElement("div",{className:"range-number-container",onPointerUp:u=>{const h=u.nativeEvent.offsetX-6;let d=Math.floor(Math.max(h,e*100));d=Math.floor(Math.min(d,t*100)),n({x:d,y:0});const f=d/100;i!==f&&o(f)}},m.createElement("div",{className:"range-number-color"}),m.createElement("div",{className:"range-number"},m.createElement(Yt,{bounds:"parent",axis:"x",position:s,onDrag:a,onStart:c,onStop:l},m.createElement("div",{className:"circle",onPointerUp:ii}))))},Sm=r=>{const{icon:i,value:e,onChangeHandler:t,style:o}=r,[s,n]=m.useState(0),[a,c]=m.useState(),l=m.useRef(null),u=m.useCallback(f=>{f>=jt.length&&(f=0),f<0&&(f=jt.length-1),n(f),t(jt[f]),c(!1),l.current&&(l.current.value=jt[f])},[t]),h=m.useMemo(()=>{if(o&&o.bottom){const f={};return f.top="inherit",f.bottom=50,f}},[o]);m.useEffect(()=>{e&&(n(jt.indexOf(e)),l.current&&(l.current.value=e))},[e]);const d=m.useMemo(()=>a?m.createElement(Cm,{options:jt,onClickHandler:u,style:h}):null,[a,u,h]);return m.createElement("div",{className:"button input-button"},m.createElement("img",{src:je(i)}),m.createElement("input",{readOnly:!0,className:"input-number",type:"text",ref:l,onPointerUp:()=>{l.current&&(l.current.focus(),c(!a))}}),m.createElement("div",{className:"input-number-btns"},m.createElement("div",{className:"input-number-add",onPointerUp:()=>{u(s+1)}}),m.createElement("div",{className:"input-number-cut",onPointerUp:()=>{u(s-1)}})),d)},Cm=r=>{const{options:i,style:e,onClickHandler:t}=r;return m.createElement("div",{className:"select-option-menu",style:e},i.map((o,s)=>m.createElement("div",{className:"select-option-btn",key:o,onPointerUp:()=>{t(s)}},o)))},km=r=>{const{innerRatio:i,innerVerticeStep:e,vertices:t,mananger:o,setShapeOpt:s}=r,n=l=>{s({vertices:l}),ae.emitMethod(ne.MainEngine,F.SetShapeOpt,{workIds:[G],toolsType:v.Star,viewId:o.viewId,vertices:l})},a=l=>{s({innerVerticeStep:l}),ae.emitMethod(ne.MainEngine,F.SetShapeOpt,{workIds:[G],toolsType:v.Star,viewId:o.viewId,innerVerticeStep:l})},c=l=>{s({innerRatio:l}),ae.emitMethod(ne.MainEngine,F.SetShapeOpt,{workIds:[G],toolsType:v.Star,viewId:o.viewId,innerRatio:l})};return m.createElement(m.Fragment,null,m.createElement(Xi,{value:t,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:n}),m.createElement(Xi,{value:e,icon:"star-innerVertex",min:1,max:100,step:1,onInputHandler:a}),m.createElement(vm,{value:i,icon:"star-innerRatio",min:.1,max:1,step:.1,onInputHandler:c}))},xm=r=>{const{mananger:i,vertices:e,setShapeOpt:t}=r,o=s=>{t({vertices:s}),ae.emitMethod(ne.MainEngine,F.SetShapeOpt,{workIds:[G],toolsType:v.Polygon,viewId:i.viewId,vertices:s})};return m.createElement(Xi,{value:e,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:o})},bm=r=>{const{mananger:i,placement:e,setShapeOpt:t}=r,o=s=>{t({placement:s}),ae.emitMethod(ne.MainEngine,F.SetShapeOpt,{workIds:[G],toolsType:v.SpeechBalloon,viewId:i.viewId,placement:s})};return m.createElement(Sm,{value:e,icon:"speechBallon-placement",onChangeHandler:o})},Ri=r=>{const{icon:i,isActive:e,onPointerUpHandler:t}=r;return m.createElement("div",{className:`button tab-button ${e?"active":""}`,onPointerUp:t},m.createElement("img",{src:je(i)}))},Dm=r=>{const{toolsTypes:i,style:e,mananger:t,shapeOpt:o,setShapeOpt:s}=r,[n,a]=m.useState();m.useEffect(()=>{i.includes(v.Polygon)?a(v.Polygon):i.includes(v.Star)?a(v.Star):a(v.SpeechBalloon)},[i]);const c=d=>{a(d)},l=m.useMemo(()=>n===v.Polygon&&t&&o.vertices?m.createElement(xm,{vertices:o.vertices,mananger:t,setShapeOpt:s}):null,[t,n,o,s]),u=m.useMemo(()=>n===v.Star&&t&&o.vertices&&o.innerVerticeStep&&o.innerRatio?m.createElement(km,{mananger:t,vertices:o.vertices,innerVerticeStep:o.innerVerticeStep,innerRatio:o.innerRatio,setShapeOpt:s}):null,[t,n,o,s]),h=m.useMemo(()=>n===v.SpeechBalloon&&t&&o.placement?m.createElement(bm,{mananger:t,placement:o.placement,setShapeOpt:s}):null,[n,t,o.placement,s]);return m.createElement("div",{className:"shapeOpt-sub-menu",style:e,onPointerUp:ii},m.createElement("div",{className:"shapeOpt-sub-menu-tabs"},i.includes(v.Polygon)&&m.createElement(Ri,{isActive:n===v.Polygon,icon:n===v.Polygon?"polygon-active":"polygon",onPointerUpHandler:c.bind(void 0,v.Polygon)})||null,i.includes(v.Star)&&m.createElement(Ri,{isActive:n===v.Star,icon:n===v.Star?"star-active":"star",onPointerUpHandler:c.bind(void 0,v.Star)})||null,i.includes(v.SpeechBalloon)&&m.createElement(Ri,{isActive:n===v.SpeechBalloon,icon:n===v.SpeechBalloon?"speechBallon-active":"speechBallon",onPointerUpHandler:c.bind(void 0,v.SpeechBalloon)})||null),m.createElement("div",{className:"shapeOpt-sub-menu-content"},l,u,h))},Lm=r=>{const{open:i,setOpen:e,floatBarRef:t,toolsTypes:o,shapeOpt:s}=r,{floatBarData:n,mananger:a,setFloatBarData:c}=m.useContext(Se),l=m.useRef(null),u=m.useMemo(()=>{if(t!=null&&t.current&&O.isNumber(n==null?void 0:n.x)&&O.isNumber(n==null?void 0:n.y)&&(a!=null&&a.height)){if(t.current.offsetTop&&t.current.offsetTop+n.y>200){const g={};return g.top="inherit",g.bottom=50,g}else if(!t.current.offsetTop&&(a==null?void 0:a.height)-t.current.offsetTop-(n==null?void 0:n.y)<140){const g={};return g.top="inherit",g.bottom=50,g}}},[t,n==null?void 0:n.x,n==null?void 0:n.y,a==null?void 0:a.height]),h=m.useCallback(g=>{c({shapeOpt:{...s,...g}})},[c,s]),d=m.useMemo(()=>i&&o&&a&&s?m.createElement(Dm,{shapeOpt:s,style:u,toolsTypes:o,mananger:a,setShapeOpt:h}):null,[i,u,o,a,s,h]),f=()=>{e(!i)};return m.createElement("div",{ref:l,className:`button normal-button ${i&&"active"}`,onPointerUp:f},d,m.createElement("img",{alt:"icon",src:je(i?"shapes-active":"shapes")}))},Sn=m.memo(r=>{const{textOpt:i,workIds:e,noLayer:t,position:o,noDelete:s,noCopy:n}=r,{floatBarData:a,mananger:c}=m.useContext(Se),[l,u]=m.useState(0),[h,d]=m.useState(),f=m.useRef(null);m.useEffect(()=>{var z,j,E,R;const x={},D=(a==null?void 0:a.w)||((z=i==null?void 0:i.boxSize)==null?void 0:z[0])||0,L=(a==null?void 0:a.h)||((j=i==null?void 0:i.boxSize)==null?void 0:j[1])||0;if(o&&D&&L&&(c!=null&&c.width)&&(c!=null&&c.height)){if(o.y<60?o.y+L<c.height-60?x.bottom=-120:o.y+L<c.height?x.bottom=-58:o.y>0?x.top=62:x.top=-o.y+62:x.top=0,o.x<0)x.left=-o.x+3;else if(o.x+(((E=f.current)==null?void 0:E.offsetWidth)||D)>c.width){const P=c.width-(((R=f.current)==null?void 0:R.offsetWidth)||D)-o.x;x.left=P}d(x);return}d(void 0)},[f,o,a==null?void 0:a.w,a==null?void 0:a.h,c==null?void 0:c.width,c==null?void 0:c.height,i==null?void 0:i.boxSize]);const g=m.useMemo(()=>a!=null&&a.fillColor?m.createElement(hm,{floatBarRef:f,open:l===3,setOpen:x=>{u(x===!0?3:0)}}):null,[a==null?void 0:a.fillColor,l,f]),p=m.useMemo(()=>a!=null&&a.strokeColor?m.createElement(lm,{floatBarRef:f,open:l===2,setOpen:x=>{u(x===!0?2:0)}}):null,[a==null?void 0:a.strokeColor,l,f]),y=m.useMemo(()=>i!=null&&i.fontColor&&(c!=null&&c.viewId)?m.createElement(um,{floatBarRef:f,open:l===4,setOpen:x=>{u(x===!0?4:0)},textOpt:i,workIds:e}):null,[i,l,e,c,f]),I=m.useMemo(()=>i!=null&&i.fontBgColor&&(c!=null&&c.viewId)?m.createElement(dm,{floatBarRef:f,open:l===5,setOpen:x=>{u(x===!0?5:0)},textOpt:i,workIds:e}):null,[i,l,e,c,f]),w=m.useMemo(()=>i&&(c!=null&&c.viewId)?m.createElement(ym,{floatBarRef:f,open:l===6,setOpen:x=>{u(x===!0?6:0)},textOpt:i,workIds:e,style:h}):null,[i,l,e,c,h,f]),S=m.useMemo(()=>i&&(c!=null&&c.viewId)?m.createElement(Im,{open:l===7,setOpen:x=>{u(x===!0?7:0)},textOpt:i,workIds:e,floatBarRef:f}):null,[i,l,e,c,f]),C=m.useMemo(()=>t?null:m.createElement(nm,{open:l===1,setOpen:x=>{u(x===!0?1:0)},floatBarRef:f}),[t,l,f]),T=m.useMemo(()=>a!=null&&a.canLock&&c?m.createElement(Tm,{workIds:e,mananger:c,islocked:a.isLocked}):null,[a,c,e]),N=m.useMemo(()=>c&&(c!=null&&c.viewId)&&h&&(a!=null&&a.shapeOpt)&&(a!=null&&a.toolsTypes)?m.createElement(Lm,{open:l===8,setOpen:x=>{u(x===!0?8:0)},floatBarRef:f,workIds:e,toolsTypes:a.toolsTypes,shapeOpt:a.shapeOpt}):null,[a,c,l,h,e,f]);return m.createElement("div",{className:"appliance-plugin-floatbtns",style:h,ref:f},c&&!s&&m.createElement(om,{workIds:e,mananger:c}),C,T,!!(c!=null&&c.viewId)&&!n&&m.createElement(sm,{workIds:e,viewId:c.viewId}),N,w,S,y,I,p,g)}),Am=r=>{const{data:i,workId:e,updateOptInfo:t,handlePointerDown:o,handlePointerUp:s}=r,{opt:n,scale:a,translate:c,x:l,y:u}=i,h=m.useRef(null),{floatBarData:d}=m.useContext(Se),f=m.useMemo(()=>{const{fontSize:y,fontFamily:I,underline:w,fontColor:S,lineThrough:C,textAlign:T,strokeColor:N,lineHeight:x,bold:D,italic:L}=n,z=x||y*1.2,j={fontSize:`${y}px`,lineHeight:`${z}px`,color:S,borderColor:N,minHeight:`${z}px`,pointerEvents:"none",paddingRight:`${L==="italic"?Math.round(y*.3):5}px`};return I&&(j.fontFamily=`${I}`),(C||w)&&(j.textDecoration=`${C&&"line-through"||""}${w&&" underline"||""}`),T&&(j.textAlign=`${T}`),D&&(j.fontWeight=`${D}`),L&&(j.fontStyle=`${L}`),j},[n]),g=m.useMemo(()=>{const y=[];if(n.text){const I=bt(n.text);for(let w=0;w<I.length;w++){const S=I[w];S===""?y.push(m.createElement("div",{key:w})):y.push(m.createElement("div",{key:w},S))}}return y.length?y:m.createElement("div",null)},[n.text]),p=m.useMemo(()=>{if(!d)return{};const y=`scale(${a||1}) ${c&&"translate("+c[0]+"px,"+c[1]+"px)"||""}`;return{left:`${l-d.x}px`,top:`${u-d.y}px`,zIndex:1,transform:y,transformOrigin:"left top",opacity:0,pointerEvents:"auto"}},[a,c,l,u,d]);return m.useEffect(()=>{var y,I;if((y=h.current)!=null&&y.offsetWidth&&((I=h.current)!=null&&I.offsetHeight)){const w=n.boxSize;if((w==null?void 0:w[0])!==h.current.offsetWidth||w[1]!==h.current.offsetHeight||!w){const S=[h.current.offsetWidth,h.current.offsetHeight];t({activeTextId:e,update:{boxSize:S,workState:A.Done}})}}},[n.fontSize,n.italic,n.bold,n.boxSize,e,t]),m.createElement("div",{className:"editor-box readonly",style:p,onPointerDown:()=>{o(e)},onPointerUp:()=>{s()}},m.createElement("div",{className:"editor",ref:h,style:f},g))},jm=r=>{const{mananger:i}=m.useContext(Se),e=m.useMemo(()=>{var o;const t=s=>{var u,h;if(!i)return;const{activeTextId:n,update:a,syncData:c}=s,l=n&&O.cloneDeep(((u=i.control.textEditorManager)==null?void 0:u.get(n))||((h=r.editors)==null?void 0:h.get(n)));l&&l.opt&&(l.opt={...l.opt,...a},c&&(l.canSync=Object.keys(c).includes("canSync")&&c.canSync||l.canSync,l.canWorker=Object.keys(c).includes("canWorker")&&c.canWorker||l.canWorker),i.control.textEditorManager.updateForViewEdited(n,l))};if((o=r.editors)!=null&&o.size){const s=[];return r.editors.forEach((n,a)=>{if(r.selectIds&&r.selectIds.includes(a)){const c=m.createElement(Am,{key:a,workId:a,data:n,updateOptInfo:t,handlePointerDown:r.handleTextEditorPointerDown,handlePointerUp:r.handleTextEditorPointerUp});s.push(c)}}),s}return null},[r.editors,r.selectIds,i,r.handleTextEditorPointerDown,r.handleTextEditorPointerUp]);return m.createElement(m.Fragment,null,e)},zm=r=>{const{position:i,textOpt:e,workIds:t,noLayer:o,noCopy:s,noDelete:n,style:a}=r,c=m.useRef(null);return m.createElement("div",{className:Oe.FloatBarBtn,ref:c,style:a},m.createElement(Sn,{position:i,textOpt:e,workIds:t,noLayer:o,noCopy:s,noDelete:n}))},Pm=r=>{const{data:i,workId:e,showFloatBtns:t,handleKeyUp:o,handleFocus:s,runAnimation:n,updateSize:a,rightBoundBreak:c}=r,{activeTextEditor:l,activeTextId:u,mananger:h}=m.useContext(Se),{opt:d,scale:f,translate:g,x:p,y}=i,{fontSize:I,fontFamily:w,underline:S,fontColor:C,lineThrough:T,textAlign:N,lineHeight:x,bold:D,italic:L}=d,z=m.useRef(null),j=m.useMemo(()=>{const $=I,X=x||$*1.2,te={fontSize:`${$}px`,lineHeight:`${X}px`,color:C,minHeight:`${X}px`,paddingRight:`${L==="italic"?Math.round($*.3):5}px`,borderWidth:`${Math.max(Math.round(1/(f||1)),1)}px`};return w&&(te.fontFamily=`${w}`),(T||S)&&(te.textDecoration=`${T&&"line-through"||""} ${S&&" underline"||""}`),N&&(te.textAlign=`${N}`),D&&(te.fontWeight=`${D}`),L&&(te.fontStyle=`${L}`),te},[D,C,w,I,L,x,T,f,N,S]),E=m.useRef(!1),R=m.useRef(6),P=m.useRef({fontSize:j.fontSize,lineHeight:j.lineHeight,fontStyle:j.fontStyle,fontWeight:j.fontWeight,fontFamily:j.fontFamily}),Z=m.useMemo(()=>u===e?"hover":d.workState===A.Doing||d.workState===A.Start?"editing":l?"active":"none",[u,e,d.workState,l]);function _($){if(z.current){const X=window==null?void 0:window.getSelection(),te=z.current,pe=(ye,Ie)=>{var fe;const Te=document.createRange();if(Ie.childNodes.length>0){const ke=Ie.lastChild;if(ke){const Pe=ke.lastChild;Pe&&Pe.nodeType===Node.TEXT_NODE?Te.setStart(Pe,((fe=Pe.textContent)==null?void 0:fe.length)||0):Te.setStart(ke,0)}else Te.setStart(Ie,0)}else Te.setStart(Ie,0);Te.collapse(!0),ye.removeAllRanges(),ye.addRange(Te)};if(X&&te)if($&&Ct($.nativeEvent)){const{x:ye,y:Ie}=To($.nativeEvent);if(document.caretPositionFromPoint){const Te=document.caretPositionFromPoint(ye,Ie);if(Te){const fe=document.createRange();fe.setStart(Te.offsetNode,Te.offset),fe.collapse(!0),X.removeAllRanges(),X.addRange(fe)}else pe(X,te)}else if(document.caretRangeFromPoint){const Te=document.caretRangeFromPoint(ye,Ie);Te?(X.removeAllRanges(),X.addRange(Te)):pe(X,te)}else pe(X,te)}else pe(X,te);z.current.focus()}}const B=m.useMemo(()=>{const $=`scale(${f||1}) ${g&&"translate("+g[0]+"px,"+g[1]+"px)"||""}`;return{left:`${p}px`,top:`${y}px`,zIndex:2,transform:$,transformOrigin:"left top",borderColor:Z==="editing"||Z==="hover"?C:"transparent"}},[f,g,p,y,C,Z]),J=m.useMemo(()=>{let $="";const X=`<div style="background-color:${d.fontBgColor};"></div>`;if(d.text){const te=bt(d.text);for(let pe=0;pe<te.length;pe++){const ye=te[pe];if(ye==="")$=$+X;else{const Ie=ye.replace(/[<>&]/g,Te=>({"<":"<",">":">","&":"&"})[Te]);$=$+`<div style="background-color:${d.fontBgColor}">${Ie}</div>`}}}else $=X;return $},[d.fontBgColor,d.text]),ie=m.useMemo(()=>{var $,X;if(Z==="hover"){if(f&&t&&O.isNumber(p)&&O.isNumber(y)&&d.boxSize&&O.isNumber(($=d.boxSize)==null?void 0:$[0])&&O.isNumber((X=d.boxSize)==null?void 0:X[1])){const te={x:p,y},pe={left:p,top:y,width:d.boxSize[0]*f,height:d.boxSize[1]*f};return m.createElement(zm,{position:te,style:pe,textOpt:d,workIds:[e],noLayer:!0,noCopy:!0,noDelete:!0})}return null}return null},[d,t,e,p,y,f,Z]);m.useEffect(()=>{u===e&&z.current&&(document.activeElement!==z.current&&_(),s(z.current))},[u,s,e]),m.useEffect(()=>{if(z.current){const $=parseInt(getComputedStyle(z.current).paddingRight,10)+parseInt(getComputedStyle(z.current).borderWidth,10);R.current=Number($)}},[]),m.useEffect(()=>{if(z.current){const $={fontSize:j.fontSize,lineHeight:j.lineHeight,fontStyle:j.fontStyle,fontWeight:j.fontWeight,fontFamily:j.fontFamily};if(!O.isEqual(P.current,$)){P.current=$;const X=[z.current.offsetWidth,z.current.offsetHeight];a(e,X)}}},[j,e,a]);const le=m.useCallback($=>{var Ie,Te;const X=h==null?void 0:h.parentElement;if(!X||!z.current||!c)return!1;const te=z.current.lastChild;if(!te)return!1;const pe=te.getBoundingClientRect(),ye=X.getBoundingClientRect();if(pe.right+$>ye.right){const fe=te.lastChild;if(!(fe instanceof Text))return!1;const ke=fe.length||0;let Pe=0,Ce=0,Ve=ke;for(;Ce<Ve;){const Le=Math.floor((Ce+Ve)/2),ut=document.createRange();ut.setStart(fe,0),ut.setEnd(fe,Le);const Dt=ut.getBoundingClientRect(),No=ye.right-Dt.right;if(No<$){if(Le>0){const yt=document.createRange();yt.setStart(fe,0),yt.setEnd(fe,Le-1);const $t=yt.getBoundingClientRect();if(ye.right-$t.right>=$){Pe=Le-1;break}}Ve=Le}else{const yt=Le+1;if(yt<ke){const $t=document.createRange();$t.setStart(fe,0),$t.setEnd(fe,yt);const So=$t.getBoundingClientRect();if(ye.right-So.right<=$&&No>$){Pe=Le;break}}Ce=yt}}if(!Pe){const Le=document.createRange();Le.setStart(fe,0),Le.setEnd(fe,Ce);const ut=Le.getBoundingClientRect();ye.right-ut.right>$?Pe=Ce:Ce>0&&(Pe=Ce-1)}if(Pe>0){const Le=((Ie=fe.textContent)==null?void 0:Ie.slice(0,Pe))||"",ut=((Te=fe.textContent)==null?void 0:Te.slice(Pe))||"";fe.textContent=Le;const Dt=document.createElement("div");return d.fontBgColor&&(Dt.style.backgroundColor=d.fontBgColor),ut&&(Dt.textContent=ut),z.current.appendChild(Dt),le($),!0}}return!1},[h==null?void 0:h.parentElement,d.fontBgColor,c]);function oe($){if($.key==="Backspace"){const X=window.getSelection(),te=X==null?void 0:X.getRangeAt(0);if(te!=null&&te.collapsed)return $.cancelable&&$.preventDefault(),document.execCommand("delete",!1),!1}return!1}function K($,X){const te=window==null?void 0:window.getSelection();if(te!=null&&te.rangeCount&&$&&te&&te.anchorNode){const pe=te.anchorOffset,ye=te.anchorNode.textContent||"",Ie=ye.slice(0,pe)||"",Te=ye.slice(pe)||"",fe=Ie.concat($)||"";q(fe,Te,X)}}function q($,X,te){const pe=window==null?void 0:window.getSelection();if(!(pe!=null&&pe.rangeCount)||!pe.anchorNode)return;const ye=$.split(/\n/);let Ie=pe.anchorNode.parentNode;Ie===te&&(Ie=pe.anchorNode);const Te=[...te.childNodes],fe=[];let ke,Pe=pe.anchorOffset;for(;Te.length;){const Ce=Te.pop();if(Ce){if(Ce===Ie){let Ve=ye[0];ye.length===1&&(Pe=ye[0].length,Ve=ye[0].concat(X)),Ie.nodeName==="#text"?(Ie.textContent=Ve,ke=Ie):Ie.nodeName==="DIV"&&(Ie.innerText=Ve,ke=Ie.childNodes[0]);break}fe.push(Ce),te.removeChild(Ce)}}if(ye.length>1)for(let Ce=1;Ce<ye.length;Ce++){let Ve=ye[Ce];const Le=document.createElement("div");d.fontBgColor&&(Le.style.backgroundColor=d.fontBgColor),Ce===ye.length-1&&(Pe=Ve.length,Ve=Ve.concat(X)),Le.innerText=Ve,te.appendChild(Le),Ce===ye.length-1&&(ke=Le.childNodes[0])}if(fe.length){fe.reverse();for(const Ce of fe)te.appendChild(Ce)}if(ke&&ke.nodeName==="#text"){pe.deleteFromDocument();const Ce=document.createRange(),Ve=Math.min(Pe,(ke==null?void 0:ke.length)||0);Ce.setStart(ke,Ve),Ce.collapse(!0),pe.removeAllRanges(),pe.addRange(Ce)}}function de($){if($.cancelable&&$.preventDefault(),$.stopPropagation(),$.stopImmediatePropagation(),z.current){const X=($.clipboardData||window.clipboardData).getData("text"),te=window==null?void 0:window.getSelection();if(!(te!=null&&te.rangeCount))return;if(X&&te&&te.anchorNode){const pe=Ui(X,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]});K(pe,z.current),o(z.current)}n()}}function Ue($){var te;const X=$.querySelector("div");if(X){const pe=document.createTreeWalker($,NodeFilter.SHOW_TEXT,null);let ye;const Ie=[];for(;(ye=pe.nextNode())!==null;)ye.parentNode===$&&Ie.push(ye);if(Ie.length>0){for(const fe of Ie)X.appendChild(fe);const Te=window.getSelection();if(Te){const fe=document.createRange(),ke=X.lastChild;ke&&ke.nodeType===Node.TEXT_NODE&&(fe.setStart(ke,((te=ke.textContent)==null?void 0:te.length)||0),fe.collapse(!0),Te.removeAllRanges(),Te.addRange(fe))}}}}const De=m.useCallback(()=>{const $=z.current;n(()=>{if(!E.current&&$){if(Ue($),le((f||1)*R.current)){const X=window.getSelection();if(!(X!=null&&X.rangeCount))return!1;const te=document.createRange(),pe=z.current.lastChild;te.selectNodeContents(pe),te.collapse(!1),X.removeAllRanges(),X.addRange(te)}o($)}})},[n,o,le,f]);function ze(){E.current=!0,n()}function Fe(){E.current=!1,De()}const He=m.useCallback(()=>{if(Z==="active"&&z.current&&z.current.parentElement){const $=z.current.parentElement;$.style.borderColor=C}},[Z,C]),ee=m.useCallback(()=>{if(Z==="active"&&z.current&&z.current.parentElement){const $=z.current.parentElement;$.style.borderColor="transparent"}},[Z]);return m.createElement(m.Fragment,null,ie,m.createElement("div",{className:`editor-box ${Z}`,style:B,onPointerUp:()=>{var $;if(Z==="editing"){n(()=>{var X;(X=document.activeElement)==null||X.blur(),h==null||h.control.textEditorManager.checkEmptyTextBlur()});return}if(Z==="active"&&h){if(($=h.control.collector)!=null&&$.hasIncludeSelector(e)){n(()=>{var X;(X=document.activeElement)==null||X.blur(),h==null||h.control.textEditorManager.checkEmptyTextBlur()});return}if(h&&u!==e){h.control.textEditorManager.checkEmptyTextBlur(),h.control.textEditorManager.active(e);return}}},onMouseOver:He,onMouseLeave:ee},m.createElement("div",{id:e,suppressContentEditableWarning:!0,contentEditable:!0,className:"editor",ref:z,style:j,onKeyDown:oe,onPaste:de,onTouchEnd:_,onInput:De,onCompositionStart:ze,onCompositionEnd:Fe,dangerouslySetInnerHTML:{__html:J}})))},Em=r=>{const i=m.useRef(null),{mananger:e}=m.useContext(Se),t=m.useRef(),o=m.useCallback(n=>{var h,d;const{activeTextId:a,update:c,syncData:l}=n;if(!e)return;const u=a&&O.cloneDeep(((h=e.control.textEditorManager)==null?void 0:h.get(a))||((d=r.editors)==null?void 0:d.get(a)));u&&u.opt&&(u.opt={...u.opt,...c},l&&(u.canSync=Object.keys(l).includes("canSync")&&l.canSync||u.canSync,u.canWorker=Object.keys(l).includes("canWorker")&&l.canWorker||u.canWorker),e.control.textEditorManager.updateForViewEdited(a,u))},[e,r.editors]),s=m.useMemo(()=>{var h;const n=d=>{const f=[];for(let g=0;g<d.childNodes.length;g++){const p=d.childNodes[g];if(p.nodeName==="#text"&&g===0){const y=p.textContent.split(/\n/),I=y.pop();f.push(...y),I&&f.push(I)}else if(p.nodeName==="DIV"){const y=p.innerText.split(/\n/);if(y.length===2&&y[0]===""&&y[1]==="")f.push("");else{const I=y.shift();(I||I==="")&&f.push(I);const w=y.pop();f.push(...y),w&&f.push(w)}}}return f},a=d=>{if(!e)return;const f=d.id,g=e.control.textEditorManager.get(f),p=A.Doing,y=[d.offsetWidth,d.offsetHeight];(!g||g&&(!O.isEqual(g.opt.boxSize,y)||!O.isEqual(g.opt.workState,p)))&&o({activeTextId:f,update:{boxSize:y,workState:p},syncData:{canSync:!0,canWorker:!0}})},c=d=>{var S,C;if(!e)return;const f=n(d),g=d.id,p=e.control.textEditorManager.get(g),y=Ye(f),I=A.Doing,w=[d.offsetWidth,d.offsetHeight];if(!p||p&&(p.opt.text!==y||!O.isEqual(p.opt.boxSize,w)||!O.isEqual(p.opt.workState,I))){const T=g&&O.cloneDeep(((S=e.control.textEditorManager)==null?void 0:S.get(g))||((C=r.editors)==null?void 0:C.get(g)));T&&T.opt&&(T.opt={...T.opt,text:y,boxSize:w,workState:I},T.canSync=!0,T.canWorker=!0,e.control.textEditorManager.updateForViewEdited(g,T)),e.control.textEditorManager.publicMsgEmitter.emit("textChange",g,d,f,T)}},l=(d,f)=>{if(!e)return;const g=d,p=e.control.textEditorManager.get(g);if(p&&!O.isEqual(p.opt.boxSize,f)){const y=O.cloneDeep(p);y.opt={...y.opt,boxSize:f},y.canSync=!1,y.canWorker=!1,e.control.textEditorManager.updateForViewEdited(g,y)}},u=d=>{t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(()=>{i!=null&&i.current&&(i==null||i.current.scrollTo({left:0,behavior:"instant"}),d&&d(),t.current=void 0)})};if((h=r.editors)!=null&&h.size){const d=[];return r.editors.forEach((f,g)=>{d.push(m.createElement(Pm,{key:g,workId:g,data:f,showFloatBtns:r.showFloatBtns||!1,handleFocus:a,handleKeyUp:c,updateSize:l,runAnimation:u,rightBoundBreak:r.rightBoundBreak||!1}))}),d}return null},[r.editors,r.showFloatBtns,r.rightBoundBreak,e,o]);return m.createElement("div",{className:`${r.className}`,ref:i},s)},Om=()=>{const{floatBarData:r}=m.useContext(Se);return m.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},m.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),m.createElement("div",{className:"point LC ew-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),m.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),m.createElement("div",{className:"point TC ns-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),m.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),m.createElement("div",{className:"point RC ew-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),m.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),m.createElement("div",{className:"point BC ns-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}))},Rm=()=>{const{floatBarData:r,mananger:i}=m.useContext(Se),[e,t]=m.useState(),[o,s]=m.useState();m.useEffect(()=>{const c=[];if(i&&O.isNumber(r==null?void 0:r.x)&&O.isNumber(r==null?void 0:r.y)&&(r!=null&&r.points)){const l=i.viewId;if(i.control.viewContainerManager.getView(l))for(const h of r.points){const d=i.control.viewContainerManager.transformToOriginPoint(h,l);c.push(d)}c[0]&&t({x:c[0][0]-((r==null?void 0:r.x)||0),y:c[0][1]-((r==null?void 0:r.y)||0)}),c[1]&&s({x:c[1][0]-((r==null?void 0:r.x)||0),y:c[1][1]-((r==null?void 0:r.y)||0)})}},[i,r==null?void 0:r.points,r==null?void 0:r.x,r==null?void 0:r.y]);const n=m.useMemo(()=>e?m.createElement("div",{className:"point point-dot",style:{borderColor:r==null?void 0:r.selectorColor,left:e.x,top:e.y}}):null,[r==null?void 0:r.selectorColor,e]),a=m.useMemo(()=>o?m.createElement("div",{className:"point point-dot",style:{borderColor:r==null?void 0:r.selectorColor,left:o.x,top:o.y}}):null,[o,r==null?void 0:r.selectorColor]);return m.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},n,a)},Wm=()=>{const{floatBarData:r}=m.useContext(Se);return m.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},m.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),m.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),m.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),m.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}))},Ym=()=>{const{floatBarData:r}=m.useContext(Se);return m.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},m.createElement("img",{className:"lock",alt:"lock",src:"https://sdk.netless.link/resource/icons/lock.svg"}))},Um=r=>{const{className:i}=r,{floatBarData:e,angle:t,setAngle:o,setOperationType:s,mananger:n}=m.useContext(Se),[a,c]=m.useState(A.Pending),[l,u]=m.useState(),[h,d]=m.useState(!1),[f,g]=m.useState(new Q),[p,y]=m.useState(new Q),[I,w]=m.useState(!1),S=m.useRef(0),C=m.useRef(null),T=z=>{if(!z){w(!0),d(!1),s(F.None),c(A.Pending);return}w(!1)},N=(z,j)=>{S.current&&(clearTimeout(S.current),S.current=0),c(A.Done),d(!1);const E=Math.round(Q.GetAngleByPoints(f,p,new Q(j.x,j.y)))||0;o(E),s(F.None),ae.emitMethod(ne.MainEngine,F.RotateNode,{workIds:[G],angle:E,workState:A.Done,viewId:n==null?void 0:n.viewId})};m.useEffect(()=>(ae.activeListener(T),()=>{ae.unmountActiveListener(T)}),[]),m.useEffect(()=>{if(e&&(a===A.Pending||a===A.Done)){const z={x:(e==null?void 0:e.x)-20,y:(e==null?void 0:e.y)+(e==null?void 0:e.h)},j={x:(e==null?void 0:e.x)+(e==null?void 0:e.w)/2,y:(e==null?void 0:e.y)+(e==null?void 0:e.h)/2};y(new Q(j.x,j.y)),g(new Q(z.x,z.y)),u({x:z.x,y:z.y})}},[e,a]);const x=(z,j)=>{if(n!=null&&n.control.worker.isBusy){w(!0),c(A.Pending);return}S.current&&(clearTimeout(S.current),S.current=0),c(A.Start),d(!0);const E=Math.round(Q.GetAngleByPoints(f,p,new Q(j.x,j.y)))||0;o(E),s(F.RotateNode),ae.emitMethod(ne.MainEngine,F.RotateNode,{workIds:[G],angle:0,workState:A.Start,viewId:n==null?void 0:n.viewId})},D=(z,j)=>{if(n!=null&&n.control.worker.isBusy){w(!0),N(z,j);return}N(z,j)},L=(z,j)=>{if(n!=null&&n.control.worker.isBusy){w(!0),N(z,j);return}S.current||(u({x:j.x,y:j.y}),d(!0),S.current=setTimeout(()=>{S.current=0;const E=Math.round(Q.GetAngleByPoints(f,p,new Q(j.x,j.y)))||0;o(E),s(F.RotateNode),c(A.Doing),ae.emitMethod(ne.MainEngine,F.RotateNode,{workIds:[G],angle:E,workState:A.Doing,viewId:n==null?void 0:n.viewId})},60))};return m.createElement(Yt,{disabled:I,position:l,onStart:x,onDrag:L,onStop:D},m.createElement("div",{className:`${i}`,style:e?{left:0,top:0,touchAction:"none"}:void 0},!h&&m.createElement("div",{className:"appliance-plugin-rotate-btn",style:{backgroundColor:e==null?void 0:e.selectorColor}},m.createElement("img",{alt:"icon",src:je("rotation-button")})),m.createElement("div",{ref:C,className:`appliance-plugin-rotate-mouse-pointer ${h?"active":""}`},m.createElement("img",{alt:"icon",src:je("rotation")}),m.createElement("div",{className:"angle-icon"},t,"°"))))},Bm=r=>{const{editors:i,canSelectorSwitch:e}=r,{floatBarData:t,setOperationType:o,mananger:s,isNoPointerEvents:n}=m.useContext(Se),[a,c]=m.useState(),[l,u]=m.useState(!1),h=m.useRef(0),d=m.useRef(),f=m.useRef(A.Pending),g=m.useMemo(()=>!!((t==null?void 0:t.scaleType)===ce.none&&(t!=null&&t.canLock)),[t]),p=m.useMemo(()=>t&&t.w&&t.h?{position:"absolute",left:0,top:0,width:t.w,height:t.h,zIndex:2,pointerEvents:g||n?"none":"auto",touchAction:"none"}:{display:"none",pointerEvents:"none"},[t,g,n]),y=N=>{if(!N||t!=null&&t.isLocked){u(!0),f.current=A.Pending,o(F.None);return}u(!1)},I=(N,x)=>{h.current&&(clearTimeout(h.current),h.current=0);const D={x:x.x,y:x.y};o(F.None),f.current=A.Done,c(D),ae.emitMethod(ne.MainEngine,F.TranslateNode,{workIds:[G],position:D,workState:A.Done,viewId:s==null?void 0:s.viewId})};m.useEffect(()=>(ae.activeListener(y),()=>{ae.unmountActiveListener(y)}),[]),m.useEffect(()=>{if(t&&(t!=null&&t.isLocked)||s!=null&&s.control.worker.isBusy){u(!0);return}u(!1)},[t,s==null?void 0:s.control.worker.isBusy]),m.useEffect(()=>{(f.current===A.Pending||f.current===A.Done)&&O.isNumber(t==null?void 0:t.x)&&O.isNumber(t==null?void 0:t.y)&&c({x:t==null?void 0:t.x,y:t==null?void 0:t.y})},[t==null?void 0:t.x,t==null?void 0:t.y]);const w=()=>{if(s!=null&&s.control.worker.isBusy){u(!0);return}h.current&&(clearTimeout(h.current),h.current=0),O.isNumber(t==null?void 0:t.x)&&O.isNumber(t==null?void 0:t.y)&&(o(F.TranslateNode),f.current=A.Start,ae.emitMethod(ne.MainEngine,F.TranslateNode,{workIds:[G],position:{x:t==null?void 0:t.x,y:t==null?void 0:t.y},workState:A.Start,viewId:s==null?void 0:s.viewId}))},S=(N,x)=>{var z;s!=null&&s.control.worker.isBusy&&u(!0);const D=f.current,L=d.current;if(I(N,x),d.current&&(d.current=void 0),D===A.Start&&(i!=null&&i.size)&&L){const j=(z=s==null?void 0:s.control.viewContainerManager.getView(s.viewId))==null?void 0:z.focusScenePath;j&&(s==null||s.control.worker.blurSelector(s.viewId,j))}},C=(N,x)=>{if(s!=null&&s.control.worker.isBusy){u(!0),I(N,x);return}if(h.current)return;const D={x:x.x,y:x.y};c(D),h.current=setTimeout(()=>{h.current=0,(D.x!==(a==null?void 0:a.x)||D.y!==(a==null?void 0:a.y))&&(d.current&&(d.current=void 0),f.current=A.Doing,ae.emitMethod(ne.MainEngine,F.TranslateNode,{workIds:[G],position:D,workState:A.Doing,viewId:s==null?void 0:s.viewId}))},60)},T=m.useMemo(()=>{if(i){const N=D=>{e&&(d.current=D)},x=()=>{s&&e&&f.current===A.Start&&d.current&&s.control.textEditorManager.active(d.current)};return m.createElement(jm,{editors:i,selectIds:(t==null?void 0:t.selectIds)||[],handleTextEditorPointerDown:N,handleTextEditorPointerUp:x})}return null},[i,t==null?void 0:t.selectIds,s,e]);return m.createElement(Yt,{disabled:l,position:a,onStart:w,onDrag:C,onStop:S},m.createElement("div",{style:p},T))},Fm=r=>{const{className:i}=r,[e,t]=m.useState({x:0,y:0,h:0,w:0}),[o,s]=m.useState(),[n,a]=m.useState(),[c,l]=m.useState(),{floatBarData:u,mananger:h,isNoPointerEvents:d,setOperationType:f}=m.useContext(Se),[g,p]=m.useState(),[y,I]=m.useState(!1),w=m.useRef(0);m.useEffect(()=>{if(u&&h){const j={x:u.x,y:u.y,w:u.w,h:u.h};t(j)}return ae.activeListener(C),()=>{ae.unmountActiveListener(C)}},[]),m.useEffect(()=>{if(h!=null&&h.control.worker.isBusy){I(!0);return}I(!1)},[h==null?void 0:h.control.worker.isBusy]);const S=()=>{if(w.current&&(clearTimeout(w.current),w.current=0),g){const{scale:j,translate:E}=g;f(F.None),ae.emitMethod(ne.MainEngine,F.ScaleNode,{workIds:[G],scale:j,dir:c,translate:E,originPoint:o,scenePoint:n,workState:A.Done,viewId:h==null?void 0:h.viewId})}},C=j=>{if(!j){I(!0);return}I(!1)},T=j=>[[j.x,j.y],[j.x+j.w,j.y],[j.x+j.w,j.y+j.h],[j.x,j.y+j.h]],N=(j,E)=>{switch(E){case"top":case"topLeft":case"left":return j[2];case"topRight":return j[3];case"right":case"bottomRight":case"bottom":return j[0];case"bottomLeft":return j[1]}},x=(j,E,R,P)=>{let Z=!1,_=!1;const B={x:e.x,y:e.y,w:e.w,h:e.h},J=[1,1],ie=[0,0];switch(j){case"top":{const q=E.height+e.h;q<0?(_=!0,B.y=e.y+e.h,B.h=Math.abs(q)):(B.y=e.y-E.height,B.h=e.h+E.height);break}case"topLeft":{const q=E.width+e.w;q<0?(Z=!0,B.x=e.x+e.w,B.w=Math.abs(q)):(B.x=e.x-E.width,B.w=e.w+E.width);const de=E.height+e.h;de<0?(_=!0,B.y=e.y+e.h,B.h=Math.abs(de)):(B.y=e.y-E.height,B.h=e.h+E.height);break}case"topRight":{const q=E.width+e.w;q<0?(Z=!0,B.x=e.x+q,B.w=Math.abs(q)):B.w=e.w+E.width;const de=E.height+e.h;de<0?(_=!0,B.y=e.y+e.h,B.h=Math.abs(de)):(B.y=e.y-E.height,B.h=e.h+E.height);break}case"bottom":{const q=E.height+e.h;q<0?(_=!0,B.y=e.y+q,B.h=Math.abs(q)):B.h=e.h+E.height;break}case"bottomLeft":{const q=E.width+e.w;q<0?(Z=!0,B.x=e.x+e.w,B.w=Math.abs(q)):(B.x=e.x-E.width,B.w=e.w+E.width);const de=E.height+e.h;de<0?(_=!0,B.y=e.y+de,B.h=Math.abs(de)):B.h=e.h+E.height;break}case"left":{const q=E.width+e.w;q<0?(Z=!0,B.x=e.x+e.w,B.w=Math.abs(q)):(B.x=e.x-E.width,B.w=e.w+E.width);break}case"bottomRight":{const q=E.width+e.w;q<0?(Z=!0,B.x=e.x+q,B.w=Math.abs(q)):B.w=e.w+E.width;const de=E.height+e.h;de<0?(_=!0,B.y=e.y+de,B.h=Math.abs(de)):B.h=e.h+E.height;break}case"right":{const q=E.width+e.w;q<0?(Z=!0,B.x=e.x+q,B.w=Math.abs(q)):B.w=e.w+E.width;break}}J[0]=B.w/e.w,J[1]=B.h/e.h;const oe=T(B).map(q=>R.control.viewContainerManager.transformToScenePoint(q,R.viewId)),K=N(oe,j);return _&&(ie[1]=K[1]-P[1]),Z&&(ie[0]=K[0]-P[0]),{scale:J,translate:ie}},D=(j,E)=>{if(w.current&&(clearTimeout(w.current),w.current=0),h!=null&&h.control.worker.isBusy){I(!0);return}if(u!=null&&u.w&&(u!=null&&u.h)&&h){const R={x:u.x,y:u.y,w:u.w,h:u.h},P=T(R),Z=P.map(J=>h.control.viewContainerManager.transformToScenePoint(J,h.viewId)),_=N(P,E),B=N(Z,E);t(R),s(_),a(B),l(E),f(F.ScaleNode),ae.emitMethod(ne.MainEngine,F.ScaleNode,{workIds:[G],originPoint:_,scenePoint:B,workState:A.Start,viewId:h.viewId})}},L=(j,E,R,P)=>{if(!(!h||!o||!n)){if(h!=null&&h.control.worker.isBusy){I(!0),S();return}w.current||(w.current=setTimeout(()=>{w.current=0;const{scale:Z,translate:_}=x(E,P,h,n);(!O.isEqual(Z,g==null?void 0:g.scale)||!O.isEqual(_,g==null?void 0:g.translate))&&(p({scale:Z,translate:_}),f(F.ScaleNode),ae.emitMethod(ne.MainEngine,F.ScaleNode,{workIds:[G],scale:Z,dir:E,translate:_,originPoint:o,scenePoint:n,workState:A.Doing,viewId:h.viewId}))},60))}},z=()=>{h!=null&&h.control.worker.isBusy&&I(!0),S()};return m.createElement(xn.Resizable,{className:`${i}`,boundsByDirection:!0,minWidth:-(((u==null?void 0:u.x)||0)+((u==null?void 0:u.w)||0)),minHeight:-(((u==null?void 0:u.y)||0)+((u==null?void 0:u.h)||0)),size:{width:(u==null?void 0:u.w)||0,height:(u==null?void 0:u.h)||0},style:{position:"absolute",left:u==null?void 0:u.x,top:u==null?void 0:u.y,pointerEvents:d?"none":"auto"},enable:y?!1:{top:(u==null?void 0:u.scaleType)===ce.all&&!0||!1,right:(u==null?void 0:u.scaleType)===ce.all&&!0||!1,bottom:(u==null?void 0:u.scaleType)===ce.all&&!0||!1,left:(u==null?void 0:u.scaleType)===ce.all&&!0||!1,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},lockAspectRatio:(u==null?void 0:u.scaleType)===ce.proportional,onResizeStart:D,onResize:L,onResizeStop:z})},fs=r=>{const{id:i,pos:e,pointMap:t,type:o}=r,{setOperationType:s,mananger:n,floatBarData:a}=m.useContext(Se),[c,l]=m.useState({x:0,y:0}),[u,h]=m.useState(A.Pending),[d,f]=m.useState(!1),g=m.useRef(0),p=m.useMemo(()=>a?{left:0,top:0}:{},[a]),y=T=>{if(!T||a!=null&&a.isLocked){f(!0),h(A.Pending),s(F.None);return}f(!1)};m.useEffect(()=>(ae.activeListener(y),()=>{ae.unmountActiveListener(y)}),[]),m.useEffect(()=>{O.isNumber(e.x)&&O.isNumber(e.y)&&(u===A.Pending||u===A.Done)&&l({x:e.x,y:e.y})},[e,u]),m.useEffect(()=>{if(a&&(a!=null&&a.isLocked)||n!=null&&n.control.worker.isBusy){f(!0);return}f(!1)},[a,n==null?void 0:n.control.worker.isBusy]);const I=(T,N)=>{g.current&&(clearTimeout(g.current),g.current=0),s(F.None),h(A.Done);const x={x:N.x,y:N.y};if(l(x),n!=null&&n.control.viewContainerManager){const D=n.control.viewContainerManager.transformToScenePoint([x.x,x.y],n.viewId),L=t.get(i);L&&o==="start"?L[0]=D:L&&o==="end"&&(L[1]=D),ae.emitMethod(ne.MainEngine,F.SetPoint,{workId:G,pointMap:t,workState:A.Done,viewId:n==null?void 0:n.viewId})}},w=()=>{if(g.current&&(clearTimeout(g.current),g.current=0),n!=null&&n.control.worker.isBusy){f(!0);return}O.isNumber(e.x)&&O.isNumber(e.y)&&(s(F.SetPoint),h(A.Start),ae.emitMethod(ne.MainEngine,F.SetPoint,{workId:G,pointMap:t,workState:A.Start,viewId:n==null?void 0:n.viewId}))},S=(T,N)=>{if(n!=null&&n.control.worker.isBusy){f(!0),I(T,N);return}if(g.current)return;const x={x:N.x,y:N.y};l(x),g.current=setTimeout(()=>{if(g.current=0,(x.x!==(N==null?void 0:N.x)||x.y!==(N==null?void 0:N.y))&&(n!=null&&n.control.viewContainerManager)){const D=n.control.viewContainerManager.transformToScenePoint([x.x,x.y],n.viewId),L=t.get(i);L&&o==="start"?L[0]=D:L&&o==="end"&&(L[1]=D),h(A.Doing),ae.emitMethod(ne.MainEngine,F.SetPoint,{workId:G,pointMap:t,workState:A.Doing,viewId:n==null?void 0:n.viewId})}},60)},C=(T,N)=>{n!=null&&n.control.worker.isBusy&&f(!0),I(T,N)};return m.createElement(Yt,{disabled:d,position:c,onStart:w,onDrag:S,onStop:C},m.createElement("div",{className:"appliance-plugin-point-draggable-btn",style:p}))},Vm=r=>{const{className:i}=r,{floatBarData:e,mananger:t}=m.useContext(Se),[o,s]=m.useState(),[n,a]=m.useState(),[c,l]=m.useState(new Map);m.useEffect(()=>{const d=[];if(t&&(e!=null&&e.points)){const f=t.viewId;if(t.control.viewContainerManager.getView(f))for(const p of e.points){const y=t.control.viewContainerManager.transformToOriginPoint(p,f);d.push(y)}e!=null&&e.selectIds&&e.selectIds.length===1&&(c.set(e.selectIds[0],e.points),l(c))}d[0]&&s({x:d[0][0],y:d[0][1]}),d[1]&&a({x:d[1][0],y:d[1][1]})},[t,e==null?void 0:e.points,e==null?void 0:e.selectIds,c]);const u=m.useMemo(()=>o&&(e!=null&&e.selectIds)?m.createElement(fs,{pos:o,type:"start",id:e.selectIds[0],pointMap:c}):null,[o,e==null?void 0:e.selectIds,c]),h=m.useMemo(()=>n&&(e!=null&&e.selectIds)?m.createElement(fs,{pos:n,type:"end",id:e.selectIds[0],pointMap:c}):null,[n,e==null?void 0:e.selectIds,c]);return m.createElement("div",{className:`${i}`},u,h)},Qm=m.forwardRef((r,i)=>{const{floatBarData:e,operationType:t}=m.useContext(Se),o=m.useMemo(()=>(e==null?void 0:e.scaleType)!==ce.all||t===F.RotateNode?null:m.createElement(Om,null),[e,t]),s=m.useMemo(()=>(e==null?void 0:e.scaleType)!==ce.both||t===F.RotateNode?null:m.createElement(Rm,null),[e,t]),n=m.useMemo(()=>(e==null?void 0:e.scaleType)!==ce.proportional||t===F.RotateNode?null:m.createElement(Wm,null),[e,t]),a=m.useMemo(()=>(e==null?void 0:e.scaleType)===ce.none&&(e!=null&&e.canLock)?m.createElement(Ym,null):null,[e]);return m.createElement("div",{ref:i,style:e?{transform:`translate(${e.x}px,${e.y}px)`,width:e.w,height:e.h,pointerEvents:"none"}:void 0},a,o,s,n,r.children)}),Zm=m.forwardRef((r,i)=>{const{floatBarData:e,operationType:t,mananger:o}=m.useContext(Se),{editors:s,isHide:n,canSelectorSwitch:a}=r,c=m.useMemo(()=>{var d;return e!=null&&e.canRotate&&((d=e==null?void 0:e.selectIds)==null?void 0:d.length)===1&&(t===F.None||t===F.RotateNode)?m.createElement(Um,{className:Oe.RotateBtn}):null},[e,t]),l=m.useMemo(()=>((e==null?void 0:e.scaleType)===ce.all||(e==null?void 0:e.scaleType)===ce.proportional)&&(t===F.None||t===F.ScaleNode)&&O.isNumber(e==null?void 0:e.x)&&O.isNumber(e==null?void 0:e.y)?m.createElement(Fm,{className:Oe.ResizeBtn}):null,[e==null?void 0:e.scaleType,t,e==null?void 0:e.x,e==null?void 0:e.y]),u=m.useMemo(()=>(e==null?void 0:e.scaleType)===ce.both&&(t===F.None||t===F.SetPoint)?m.createElement(Vm,{className:Oe.ResizeTowBox}):null,[e==null?void 0:e.scaleType,t]),h=m.useMemo(()=>n&&t===F.None&&O.isNumber(e==null?void 0:e.x)&&O.isNumber(e==null?void 0:e.y)&&O.isNumber(e==null?void 0:e.w)&&O.isNumber(e==null?void 0:e.h)?m.createElement("div",{className:Oe.FloatBarBtn,style:{left:e==null?void 0:e.x,top:e==null?void 0:e.y,width:e.w,height:e.h}},m.createElement(Sn,{position:{x:e.x,y:e.y},textOpt:e==null?void 0:e.textOpt,noLayer:e==null?void 0:e.isLocked})):null,[e==null?void 0:e.x,e==null?void 0:e.y,e==null?void 0:e.w,e==null?void 0:e.h,e==null?void 0:e.textOpt,e==null?void 0:e.isLocked,t,n]);return m.createElement("div",{className:Oe.FloatBar,onPointerOver:d=>(ii(d),o==null||o.control.worker.blurCursor(o.viewId),!1)},m.createElement(Qm,{ref:i}),m.createElement(Bm,{editors:s,canSelectorSwitch:a}),c,l,u,h)}),$m=m.memo(Zm,(r,i)=>!!O.isEqual(r,i));class Hm extends m.Component{constructor(e){super(e);M(this,"renderAvatar",e=>{var o;const t=`rgb(${e.memberState.strokeColor[0]}, ${e.memberState.strokeColor[1]}, ${e.memberState.strokeColor[2]})`;if(this.detectAvatar(e)){const s=this.getCursorName(e);return m.createElement("img",{className:"cursor-selector-avatar",style:{width:s?19:28,height:s?19:28,position:s?"initial":"absolute",borderColor:s?"white":t,marginRight:s?4:0},src:(o=e.payload)==null?void 0:o.avatar,alt:"avatar"})}else return null});M(this,"getOpacity",e=>{const t=this.getCursorName(e),o=this.detectAvatar(e);return t===void 0&&o===void 0?0:1});M(this,"getCursorName",e=>{if(e.payload)return e.payload.nickName||e.payload.cursorName||e.payload.uid});M(this,"getThemeClass",e=>e.payload&&e.payload.theme?"cursor-inner-mellow":"cursor-inner");M(this,"getCursorBackgroundColor",e=>{const t=this.getCursorName(e);return e.payload&&e.payload.cursorBackgroundColor?e.payload.cursorBackgroundColor:t?`rgb(${e.memberState.strokeColor[0]}, ${e.memberState.strokeColor[1]}, ${e.memberState.strokeColor[2]})`:void 0});M(this,"getCursorTextColor",e=>e.payload&&e.payload.cursorTextColor?e.payload.cursorTextColor:"#FFFFFF");M(this,"getCursorTagBackgroundColor",e=>e.payload&&e.payload.cursorTagBackgroundColor?e.payload.cursorTagBackgroundColor:this.getCursorBackgroundColor(e));M(this,"detectAvatar",e=>!!(e.payload&&e.payload.avatar));M(this,"renderTag",e=>{if(e.payload&&e.payload.cursorTagName)return m.createElement("span",{className:"cursor-tag-name",style:{backgroundColor:this.getCursorTagBackgroundColor(e)}},e.payload.cursorTagName)});M(this,"renderCursor",e=>{const t=mm.get(e);return t&&this.props.isEnableCursor?m.createElement("img",{className:`cursor-${e}-image`,src:t,alt:`${e}Cursor`}):null})}render(){const{roomMember:e}=this.props,t=this.getCursorName(e);switch(e.memberState.currentApplianceName){case re.pencil:return m.createElement("div",{className:"cursor-box"},m.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"5px",marginTop:"4px"}},m.createElement("div",{className:"cursor-name"},m.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),m.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),m.createElement("div",null,this.renderCursor("pencil"))));case re.selector:return m.createElement("div",{className:"cursor-box"},m.createElement("div",{className:"cursor-mid cursor-selector-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"3px",marginTop:"17px"}},m.createElement("div",{className:"cursor-name"},m.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),m.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),m.createElement("div",null,this.renderCursor("selector"))));case re.eraser:case re.pencilEraser:return m.createElement("div",{className:"cursor-box"},m.createElement("div",{className:"cursor-mid cursor-eraser-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"2px",marginTop:"8px"}},m.createElement("div",{className:"cursor-name"},m.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),m.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),m.createElement("div",null,this.renderCursor("eraser"))));case re.text:return m.createElement("div",{className:"cursor-box"},m.createElement("div",{className:"cursor-mid cursor-text-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"0px"}},m.createElement("div",{className:"cursor-name"},m.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),m.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),m.createElement("div",null,this.renderCursor("text"))));case re.rectangle:case re.arrow:case re.straight:case re.shape:case re.ellipse:return m.createElement("div",{className:"cursor-box"},m.createElement("div",{className:"cursor-mid cursor-shape-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"-3px",marginTop:"19px"}},m.createElement("div",{className:"cursor-name"},m.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),m.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),m.createElement("div",null,this.renderCursor("shape"))));default:return null}}}const Gm=r=>{var n;const{className:i,info:e,isEnableCursor:t}=r,{roomMember:o,...s}=e||{};return m.createElement("div",{"data-cursor-uid":(n=o==null?void 0:o.payload)==null?void 0:n.uid,className:`${i}`,style:s?{transform:`translate(${s.x}px, ${s.y}px)`}:{display:"none"}},o&&m.createElement(Hm,{roomMember:o,isEnableCursor:t}))},Xm=r=>{const{className:i,manager:e}=r,[t,o]=m.useState();m.useEffect(()=>(e.internalMsgEmitter.on([ne.Cursor,e.viewId],s),()=>{e.internalMsgEmitter.off([ne.Cursor,e.viewId],s)}),[e]);function s(a){o(a)}return m.useMemo(()=>{if(t!=null&&t.length){const a=t.map(c=>{var l;return c.roomMember?m.createElement(Gm,{key:(l=c.roomMember)==null?void 0:l.memberId,className:i,info:c,isEnableCursor:e.control.cursor.isEnableCursor}):null});return m.createElement(m.Fragment,null,a)}return null},[t])},Jm=r=>{const{viewId:i,miniMapCanvas:e,highlightColor:t,miniMapManager:o,contianer:s}=r,[n,a]=m.useState();m.useEffect(()=>(c(),o.listener.addListener([i,"viewCameraUpate"],c),o.listener.emitAsync([i,"miniMapCreate"],!0),()=>{o.listener.removeListener([i,"viewCameraUpate"],c)}),[]);const c=()=>{const h=o.maps.get(i);h&&l(h.miniMapCamera,h.viewCamera)},l=(h,d)=>{const{width:f,height:g}=s.getBoundingClientRect(),p=Math.min(f/h.width,g/h.height),y=d.width/d.scale,I=d.height/d.scale,w=[d.centerX,d.centerY],S=[h.centerX,h.centerY],C=[w[0]-S[0],w[1]-S[1]],T=Math.min(h.scale*p,h.scale*p),N=[C[0]*T,C[1]*T,y,I,T];a(N)},u=h=>{var d;if(o.control.renderControl.isWritable){const f=h.nativeEvent.target||h.nativeEvent.srcElement;if(f&&h.nativeEvent&&n){const{width:g,height:p}=f.getBoundingClientRect(),[y,I]=[g/2,p/2],[w,S]=[(h.nativeEvent.offsetX-y)/n[4],(h.nativeEvent.offsetY-I)/n[4]],C=o.maps.get(i);if(C!=null&&C.viewCamera){const[T,N]=[C.miniMapCamera.centerX+w,C.miniMapCamera.centerY+S];(d=o.control.room)==null||d.moveCamera({centerX:T,centerY:N,animationMode:"immediately"})}}}};return m.createElement("div",{style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",pointerEvents:"auto"},onClick:u},m.createElement("canvas",{style:{pointerEvents:"none"},ref:e}),n&&m.createElement("div",{className:"minimap-highlightBox",style:{position:"absolute",top:"50%",left:"50%",width:n[2]*n[4],height:n[3]*n[4],boxSizing:"content-box",border:`2px solid ${t}`,transform:`translate(calc(-50% + ${n[0]}px), calc(-50% + ${n[1]}px))`,pointerEvents:"none"}}))},qm=r=>{const{miniMapManager:i,active:e,className:t}=r,o=m.useMemo(()=>{const s=i.maps;if(e){const n=s.get(e);if(n){const{miniMapCamera:a,viewCamera:c,...l}=n;if(l.contianer&&a&&c){const u=i.highlightColor;return Ii.createPortal(m.createElement(Jm,{viewId:e,...l,highlightColor:u,miniMapManager:i}),l.contianer)}}}return null},[e,i]);return m.createElement("div",{className:t},o)},Se=m.createContext({viewId:"",mananger:void 0,floatBarColors:[],floatBarData:void 0,dpr:1,angle:0,operationType:F.None,scale:[1,1],isNoPointerEvents:!1,activeTextEditor:!1,activeTextId:void 0,setAngle:()=>{},setOperationType:()=>{},setFloatBarData:()=>{}});class vo extends m.Component{constructor(e){var o,s;super(e);M(this,"showTextFloatBar");M(this,"canSelectorSwitch");M(this,"rightBoundBreak");M(this,"setAngle",e=>{this.setState({angle:e})});M(this,"setOperationType",e=>{this.setState({operationType:e})});this.state={floatBarData:void 0,showFloatBar:!1,showFloatBarBtn:!0,dpr:1,angle:0,operationType:F.None,scale:[1,1],editors:this.editors,activeTextId:(o=this.props.mananger.control.textEditorManager)==null?void 0:o.activeId,activeMiniMapViewId:(s=this.props.mananger.control.miniMapManager)==null?void 0:s.activeViewId};const t=this.props.mananger.control.pluginOptions.extras.textEditor;this.showTextFloatBar=O.isBoolean(t.showFloatBar)?t.showFloatBar:Me.textEditor.showFloatBar,this.canSelectorSwitch=O.isBoolean(t==null?void 0:t.canSelectorSwitch)?t.canSelectorSwitch:Me.textEditor.canSelectorSwitch,this.rightBoundBreak=O.isBoolean(t==null?void 0:t.rightBoundBreak)?t.rightBoundBreak:Me.textEditor.rightBoundBreak}get editors(){return Ae(this.props.mananger.control.textEditorManager.filterEditor(this.props.mananger.viewId))}componentDidMount(){this.props.mananger.vDom=this,this.props.mananger.mountView(),this.setState({dpr:this.props.mananger.dpr})}componentWillUnmount(){}setActiveMiniMap(e){this.setState({activeMiniMapViewId:e})}showFloatBarBtn(e){this.setState({showFloatBarBtn:e})}showFloatBar(e,t){const o=e&&t&&{...this.state.floatBarData,...t}||void 0;this.setState({showFloatBar:e,floatBarData:o,angle:0})}activeTextEditor(){this.setState({activeTextEditor:!0})}unActiveTextEditor(){this.setState({activeTextEditor:!1})}updateTextEditorInfo(e){this.setState({activeTextId:e,editors:this.editors})}setFloatBarData(e){this.state.floatBarData&&this.setState({floatBarData:{...this.state.floatBarData,...e}})}render(){var t,o,s,n,a,c;const e=!!((o=(t=this.props.mananger.control)==null?void 0:t.room)!=null&&o.floatBarOptions);return m.createElement("div",{className:Oe.Container},!this.props.mananger.control.hasOffscreenCanvas()&&m.createElement("div",{className:Oe.CanvasBox,ref:this.props.refs.canvasContainerRef})||m.createElement("div",{className:Oe.CanvasBox},m.createElement("canvas",{id:"bgCanvas",ref:this.props.refs.canvasBgRef,style:{width:"100%",height:"100%"}}),m.createElement("canvas",{id:"serviceCanvas",className:Oe.FloatCanvas,ref:this.props.refs.canvasServiceFloatRef,style:{width:"100%",height:"100%"}}),m.createElement("canvas",{id:"localCanvas",className:Oe.FloatCanvas,ref:this.props.refs.canvasFloatRef,style:{width:"100%",height:"100%"}}),m.createElement("div",{id:"subLocalCanvas",className:Oe.CanvasBoxSub,ref:this.props.refs.subLocalCanvasContainerRef}),m.createElement("canvas",{id:"topCanvas",className:Oe.TopFloatCanvas,ref:this.props.refs.canvasTopRef,style:{width:"100%",height:"100%"}})),!this.props.mananger.control.hasOffscreenCanvas()&&this.props.refs.snapshotContainerRef&&m.createElement("div",{className:Oe.SnapshotBox,ref:this.props.refs.snapshotContainerRef})||null,m.createElement(Se.Provider,{value:{viewId:this.props.viewId,mananger:this.props.mananger,floatBarColors:e&&((a=(n=(s=this.props.mananger.control)==null?void 0:s.room)==null?void 0:n.floatBarOptions)==null?void 0:a.colors)||[],isNoPointerEvents:!this.state.showFloatBarBtn,floatBarData:this.state.floatBarData,dpr:this.state.dpr,angle:this.state.angle,operationType:this.state.operationType,scale:this.state.scale,activeTextEditor:this.state.activeTextEditor,activeTextId:this.state.activeTextId,setAngle:this.setAngle.bind(this),setOperationType:this.setOperationType.bind(this),setFloatBarData:this.setFloatBarData.bind(this)}},this.state.showFloatBar&&m.createElement($m,{ref:this.props.refs.floatBarRef,editors:this.state.editors,isHide:e&&this.state.showFloatBarBtn,canSelectorSwitch:this.canSelectorSwitch})||null,((c=this.state.editors)==null?void 0:c.size)&&m.createElement(Em,{className:Oe.TextEditorContainer,showFloatBtns:this.showTextFloatBar&&e&&this.state.showFloatBarBtn||!1,editors:this.state.editors,rightBoundBreak:this.rightBoundBreak})||null),m.createElement(Xm,{className:Oe.CursorBox,manager:this.props.mananger}),m.createElement(qm,{className:Oe.MiniMapBox,active:this.state.activeMiniMapViewId,miniMapManager:this.props.mananger.control.miniMapManager}))}}class Km extends vn{constructor(e,t){super(e,t);M(this,"width",1e3);M(this,"height",1e3);M(this,"dpr",ht());M(this,"vDom");M(this,"eventTragetElement");M(this,"snapshotContainerRef");M(this,"canvasContainerRef",m.createRef());M(this,"subLocalCanvasContainerRef",m.createRef());M(this,"canvasTopRef",m.createRef());M(this,"canvasServiceFloatRef",m.createRef());M(this,"canvasFloatRef",m.createRef());M(this,"canvasBgRef",m.createRef());M(this,"floatBarRef",m.createRef());M(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas()||(this.snapshotContainerRef=m.createRef())}setCanvassStyle(){if(this.eventTragetElement){const e=this.eventTragetElement.offsetWidth||this.width,t=this.eventTragetElement.offsetHeight||this.height;let o=ht();this.canvasBgRef.current&&(o=ht(this.canvasBgRef.current.getContext("2d"))),o!==this.dpr&&(this.dpr=o,this.control.worker.updateDpr(this.viewId,this.dpr)),e&&t&&this.canvasContainerRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.canvasContainerRef.current.style.width=`${e}px`,this.canvasContainerRef.current.style.height=`${t}px`),e&&t&&this.snapshotContainerRef&&this.snapshotContainerRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t),e&&t&&this.canvasBgRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.canvasBgRef.current.width=e*this.dpr,this.canvasBgRef.current.height=t*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=e*this.dpr,this.canvasFloatRef.current.height=t*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=e*this.dpr,this.canvasServiceFloatRef.current.height=t*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=e*this.dpr,this.canvasTopRef.current.height=t*this.dpr))}}destroy(){if(super.destroy(),this.eventTragetElement){const e=this.eventTragetElement.parentElement;if(e){const t=e.querySelectorAll(".appliance-plugin-main-view-displayer");for(const o of t)o.remove()}}}createMainViewDisplayer(e){const t=document.createElement("div");return t.className="appliance-plugin-main-view-displayer",e.appendChild(t),this.eventTragetElement=e.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),Ii.render(m.createElement(vo,{viewId:this.viewId,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,snapshotContainerRef:this.snapshotContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef}}),t),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement),this}}class _m extends Fy{constructor(e,t,o){super(e,t,o);M(this,"dpr",ht());M(this,"width",1e3);M(this,"height",1e3);M(this,"vDom");M(this,"eventTragetElement");M(this,"canvasContainerRef",m.createRef());M(this,"subLocalCanvasContainerRef",m.createRef());M(this,"canvasTopRef",m.createRef());M(this,"canvasServiceFloatRef",m.createRef());M(this,"canvasFloatRef",m.createRef());M(this,"canvasBgRef",m.createRef());M(this,"floatBarRef",m.createRef());M(this,"containerOffset",{x:0,y:0})}setCanvassStyle(){if(this.eventTragetElement){let e=ht();if(this.canvasBgRef.current&&(e=ht(this.canvasBgRef.current.getContext("2d"))),e!==this.dpr&&(this.dpr=e,this.control.worker.updateDpr(this.viewId,this.dpr)),this.canvasContainerRef.current){const t=this.eventTragetElement.offsetWidth||this.width,o=this.eventTragetElement.offsetHeight||this.height;t&&o&&(t!==this.width||o!==this.height)&&(this.width=t,this.height=o,this.canvasContainerRef.current.style.width=`${t}px`,this.canvasContainerRef.current.style.height=`${o}px`)}if(this.canvasBgRef.current){const t=this.eventTragetElement.offsetWidth||this.width,o=this.eventTragetElement.offsetHeight||this.height;t&&o&&(t!==this.width||o!==this.height)&&(this.width=t,this.height=o,this.canvasBgRef.current.width=t*this.dpr,this.canvasBgRef.current.height=o*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=t*this.dpr,this.canvasFloatRef.current.height=o*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=t*this.dpr,this.canvasServiceFloatRef.current.height=o*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=t*this.dpr,this.canvasTopRef.current.height=o*this.dpr))}}}createAppViewDisplayer(e,t){const o=document.createElement("div");return o.className="appliance-plugin-app-view-displayer",t.appendChild(o),this.eventTragetElement=t.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),Ii.render(m.createElement(vo,{viewId:e,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef}}),o),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement),this}}class Je extends Wt{constructor(e){super(e);M(this,"focuedViewId");M(this,"focuedView");M(this,"control");M(this,"tmpFocusedViewId");M(this,"checkScaleTimer");M(this,"onMainViewRelease",async e=>{this.control.textEditorManager.clear(ge,!0),this.mainViewDestroy(e),await new Promise(o=>{setTimeout(()=>{o(!0)},0)}),this.onMainViewMounted(e);const t=this.control.getSnapshootData("memberState");this.control.room&&this.control.onMemberChange(t),this.control.clearSnapshootData()});M(this,"mainViewDestroy",e=>{var t;if(this.mainView&&this.mainView.displayer){this.mainView.displayer.destroy();const o=e.divElement;if(o){const s=o.getElementsByClassName("appliance-plugin-main-view-displayer");for(const n of s)n.remove()}if(this.mainView.container&&o!==this.mainView.container){const s=this.mainView.container.getElementsByClassName("appliance-plugin-main-view-displayer");for(const n of s)n.remove()}(t=this.control.worker)==null||t.destroyViewWorker(this.mainView.id,!0),this.mainView.displayer.destroy(),this.mainView=void 0}});M(this,"onMainViewMounted",e=>{const t=e.divElement;if(!t||!e.focusScenePath||!(e.focusScenePath||e.scenePath))return;const s=new Km(this.control,xe.InternalMsgEmitter),n=e.size.width||s.width,a=e.size.height||s.height,l={dpr:s.dpr,originalPoint:[n/2,a/2],offscreenCanvasOpt:{...Je.defaultScreenCanvasOpt,width:n,height:a},layerOpt:{...Je.defaultLayerOpt,width:n,height:a},cameraOpt:{...Je.defaultCameraOpt,width:n,height:a}},{scale:u,...h}=e.camera;l.cameraOpt={...l.cameraOpt,...h,scale:u===1/0?1:u},this.createMianView({id:ge,container:t,displayer:s,focusScenePath:e.focusScenePath,cameraOpt:l.cameraOpt,viewData:e}),this.setFocuedViewId(ge),s.createMainViewDisplayer(t),e.callbacks.on("onSizeUpdated",this.onMainViewSizeUpdated),e.callbacks.on("onCameraUpdated",this.onMainViewCameraUpdated),e.callbacks.on("onActiveHotkey",this.onActiveHotkeyChange.bind(this))});M(this,"onMainViewSizeUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.mainView&&this.mainView.viewData&&this.updateMainViewCamera()});M(this,"onMainViewCameraUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.updateMainViewCamera()});M(this,"updateMainViewCamera",()=>{if(this.mainView&&this.mainView.viewData){const e=this.mainView.viewData.camera,t=this.mainView.cameraOpt;if(t){const o=t.width,s=t.height,{width:n,height:a}=this.mainView.viewData.size;(n!==o||a!==s)&&this.mainView.displayer.updateSize();const c=e.scale===1/0?1:e.scale,l=e.centerX||0,u=e.centerY||0,h={...t,scale:c,centerX:l,centerY:u,width:n,height:a};O.isEqual(t,h)||(this.mainView.cameraOpt=h),this.checkScaleTimer&&e.scale==1/0&&(clearTimeout(this.checkScaleTimer),this.checkScaleTimer=void 0),!this.checkScaleTimer&&e.scale===1/0&&this.mainView.viewData&&this.mainView.viewData.camera.scale===1/0&&(this.checkScaleTimer=setTimeout(()=>{var d,f;(f=(d=this.mainView)==null?void 0:d.viewData)==null||f.moveCamera({scale:c,centerX:l,centerY:u,animationMode:"immediately"}),this.checkScaleTimer=void 0},500))}}});M(this,"onAppViewMounted",async e=>{var d;const{appId:t,view:o}=e,s=o.divElement;if(!s||!o.focusScenePath)return;const n=this.appViews.get(t);if(n&&n.displayer){let f=s.getElementsByClassName("appliance-plugin-app-view-displayer");for(const g of f)g.remove();if(n.container&&n.container!==s){f=n.container.getElementsByClassName("appliance-plugin-app-view-displayer");for(const g of f)g.remove()}this.destroyAppView(e.appId,!0),(d=this.control.worker)==null||d.destroyViewWorker(t,!0),await new Promise(g=>{setTimeout(()=>{g(!0)},0)})}const a=new _m(t,this.control,xe.InternalMsgEmitter),c=o.size.width||a.width,l=o.size.height||a.height,h={dpr:a.dpr,originalPoint:[c/2,l/2],offscreenCanvasOpt:{...Je.defaultScreenCanvasOpt,width:c,height:l},layerOpt:{...Je.defaultLayerOpt,width:c,height:l},cameraOpt:{...Je.defaultCameraOpt,...o.camera,width:c,height:l}};if(this.createAppView({id:t,container:s,displayer:a,cameraOpt:h.cameraOpt,focusScenePath:o.focusScenePath,viewData:o}),a.createAppViewDisplayer(t,s),o.callbacks.on("onSizeUpdated",this.onAppViewSizeUpdated.bind(this,t)),o.callbacks.on("onCameraUpdated",this.onAppViewCameraUpdated.bind(this,t)),o.callbacks.on("onActiveHotkey",this.onActiveHotkeyChange.bind(this)),this.tmpFocusedViewId===t){const f=this.control.worker.getLocalWorkViewId();f&&f!==t?this.setFocuedViewId(f):this.setFocuedViewId(t),this.tmpFocusedViewId=void 0}setTimeout(()=>{this.onAppViewCameraUpdated(t)},0)});M(this,"onAppViewSizeUpdated",async e=>{await new Promise(o=>{setTimeout(()=>{o(!0)},0)});const t=this.appViews.get(e);t&&t.viewData&&this.updateAppCamera(e)});M(this,"onAppViewCameraUpdated",async e=>{await new Promise(t=>{setTimeout(()=>{t(!0)},0)}),this.updateAppCamera(e)});M(this,"updateAppCamera",e=>{const t=this.appViews.get(e);if(t&&t.viewData){const o=t.viewData.camera,s=t.cameraOpt;if(s){const{width:n,height:a}=t.viewData.size,c=s.width,l=s.height;(n!==c||a!==l)&&t.displayer.updateSize();const u=o.scale===1/0?1:o.scale,h=o.centerX||0,d=o.centerY||0,f={...s,scale:u,centerX:h,centerY:d,width:n,height:a};O.isEqual(f,s)||(t.cameraOpt=f)}}});this.control=e.control}getViewInitData(e){var o;const t=this.getView(e);if(t){const{width:s,height:n,dpr:a}=t.displayer;(o=this.control.pluginOptions.extras.canvasOpt)!=null&&o.contextType&&(Je.defaultScreenCanvasOpt.contextType=this.control.pluginOptions.extras.canvasOpt.contextType);const c={dpr:a,originalPoint:[s/2,n/2],offscreenCanvasOpt:{...Je.defaultScreenCanvasOpt,width:s,height:n},layerOpt:{...Je.defaultLayerOpt,width:s,height:n},cameraOpt:{...Je.defaultCameraOpt,width:s,height:n}};if(t.viewData){const{scale:l,...u}=t.viewData.camera;c.cameraOpt={...c.cameraOpt,...u,scale:l===1/0?1:l}}return c}}async mountView(e){var o,s;const t=this.getView(e);if(t){e===((o=this.mainView)==null?void 0:o.id)&&(this.control.cursor.activeCollector(),await this.control.activeWorker());const n=this.getViewInitData(e);if(n&&((s=this.control.worker)==null||s.createViewWorker(e,n)),t.focusScenePath&&this.control.collector){if(this.control.collector.authStorage){const{renderAuth:a,pageAuth:c}=this.control.collector.authStorage;if(a){const l=a[e];if(l){const{render:u,hide:h,clear:d}=l;this.control.renderControl.syncRenderUids(e,u,h,d);return}}if(c){const l=c[e];if(l){this.control.renderControl.syncPageAuth(e,l,!0);return}}}this.control.worker.pullServiceData(e,t.focusScenePath,{isAsync:!0,useAnimation:!1})}}}listenerWindowManager(e){e.emitter.on("focusedChange",t=>{const o=t||ge;if(this.focuedViewId!==o)if(this.getView(o)){const n=this.control.worker.getLocalWorkViewId();n&&n!==o?this.setFocuedViewId(n):this.setFocuedViewId(o)}else this.tmpFocusedViewId=o}),e.emitter.on("mainViewScenePathChange",t=>{this.control.onSceneChange(t,ge)}),e.emitter.on("onMainViewMounted",this.onMainViewMounted),e.emitter.on("onAppViewMounted",this.onAppViewMounted),e.emitter.on("onMainViewRebind",this.onMainViewRelease),e.emitter.on("onBoxClose",t=>{this.appViews.get(t.appId)&&(this.destroyAppView(t.appId),this.control.worker.destroyViewWorker(t.appId))}),e.emitter.on("onAppScenePathChange",t=>{const{appId:o,view:s}=t;this.control.onSceneChange(s.focusScenePath,o)}),e.emitter.on("appsChange",t=>{for(const o of this.appViews.keys())t.includes(o)||(this.destroyAppView(o),this.control.worker.destroyViewWorker(o,!0))})}onActiveHotkeyChange(e){this.control.hotkeyManager.onActiveHotkey(e)}}class dt extends xe{constructor(e){super(e);M(this,"windowManager");M(this,"viewContainerManager");const t={control:this,internalMsgEmitter:xe.InternalMsgEmitter,publicMsgEmitter:xe.PublicMsgEmitter};this.viewContainerManager=new Je(t)}init(){}activePlugin(){this.collector&&(this.collector.addAuthStateListener((e,t)=>{e&&Object.keys(e).forEach(o=>{var n;const s=(n=e[o])==null?void 0:n.newValue;this.renderControl.syncRenderUids(o,s==null?void 0:s.render,s==null?void 0:s.hide,s==null?void 0:s.clear)}),t&&Object.keys(t).forEach(o=>{var n;const s=(n=t[o])==null?void 0:n.newValue;this.renderControl.syncPageAuth(o,s)})}),this.collector.addStorageStateListener(e=>{var a,c;if((a=this.collector)!=null&&a.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(ge,!0);return}const{diffView:t,diffScenePath:o,diffData:s}=e,n=new Map;if(t){let l;Object.keys(t).forEach(u=>{var d;const h=t[u];if(h&&!h.newValue)(d=this.worker)==null||d.clearViewScenePath(u,!0),h.oldValue&&(l=h.oldValue);else if(h&&h.newValue){for(const f of Object.keys(h.newValue))this.worker.pullServiceData(u,f,{isAsync:!1,useAnimation:!1});l=h.newValue}if(l)for(const f of Object.values(l)){const g=new Set;for(const p of Object.keys(f))p&&g.add(p);n.set(u,g)}})}if(o){let l;Object.keys(o).forEach(u=>{var d;const h=o[u];if(h&&h.viewId&&!h.newValue?((d=this.worker)==null||d.clearViewScenePath(h.viewId,!0),h.oldValue&&(l=h.oldValue)):h&&h.viewId&&h.newValue&&(this.worker.pullServiceData(h.viewId,u,{isAsync:!1,useAnimation:!1}),l=h.newValue),h!=null&&h.viewId&&l){const f=new Set;for(const g of Object.keys(l))g&&f.add(g),n.set(h.viewId,f)}})}s&&Object.keys(s).forEach(l=>{var h,d;const u=s[l];if(u){const{viewId:f}=u,g=n.get(f)||new Set;g.add(l),n.set(f,g),(h=this.worker)==null||h.onServiceDerive(l,u),(d=this.miniMapManager)==null||d.updateMiniMapCamera(f)}});for(const[l,u]of n.entries())xe.InternalMsgEmitter.emit("excludeIds",[...u],l)}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(e=>{e&&e.focusScenePath&&this.worker.pullServiceData(e.id,e.focusScenePath,{isAsync:!0,useAnimation:!1})}),this.room&&this.roomMember.onUidChangeHook(e=>{var t,o;(t=this.collector)!=null&&t.serviceStorage&&this.viewContainerManager.getAllViews().forEach(s=>{var n,a,c,l;if(s&&s.focusScenePath&&((n=this.collector)!=null&&n.serviceStorage[s.id])&&this.collector.serviceStorage[s.id][s.focusScenePath]){const u=Object.keys(this.collector.serviceStorage[s.id][s.focusScenePath]);for(const h of u){const d=(a=this.collector)==null?void 0:a.getUidFromKey(h);if(d&&!e.online.includes(d))if((c=this.collector)!=null&&c.isSelector(h))this.renderControl.isWritable&&((l=this.collector)==null||l.updateValue(h,void 0,{viewId:s.id,scenePath:s.focusScenePath,isSync:!0})),this.worker.blurSelector(s.id,s.focusScenePath,h);else{const f=this.textEditorManager.editors.get(h);f&&f.opt&&(f.opt.workState===A.Doing||f.opt.workState===A.Start)&&(f.opt.text&&f.opt.text.replace(/\s*,/g,"")?this.textEditorManager.unActive(h):this.textEditorManager.delete(h))}}}}),(o=this.cursor)==null||o.updateRoomMembers(e)}))}async activeWorker(){await this.worker.init()}setWindowManager(e){var t,o,s,n,a;this.windowManager=e,(o=(t=this.windowManager)==null?void 0:t.mainView)!=null&&o.divElement&&this.viewContainerManager.onMainViewMounted(this.windowManager.mainView),(a=(n=(s=this.windowManager.appManager)==null?void 0:s.viewManager)==null?void 0:n.views)!=null&&a.size&&this.windowManager.appManager.viewManager.views.forEach((c,l)=>{this.viewContainerManager.onAppViewMounted({appId:l,view:c})}),this.viewContainerManager.listenerWindowManager(this.windowManager)}}const Y=class Y extends H.InvisiblePlugin{constructor(){super(...arguments);M(this,"onPhaseChanged",e=>{var t;e===H.RoomPhase.Reconnecting&&((t=Y.currentManager)==null||t.setSnapshootData())});M(this,"updateRoomWritable",()=>{var e;(e=Y.currentManager)==null||e.onWritableChange(this.displayer.isWritable)});M(this,"roomStateChangeListener",async e=>{var t,o;e!=null&&e.roomMembers&&((t=Y.currentManager)==null||t.onRoomMembersChange(e.roomMembers)),!(H.isRoom(this.displayer)&&!this.displayer.isWritable)&&e.memberState&&((o=Y.currentManager)==null||o.onMemberChange(e.memberState))})}static async getInstance(e,t){var g;t.options&&(((g=t.options.extras)==null?void 0:g.useWorker)==="mainThread"&&(t.options.cdn.fullWorkerUrl="",t.options.cdn.subWorkerUrl=""),(t.options.extras&&t.options.extras.useWorker!=="mainThread"||!t.options.extras)&&!t.options.cdn.fullWorkerUrl&&!t.options.cdn.subWorkerUrl&&Y.logger.error("[ApplianceMultiPlugin] you must adaptor options cdn fullWorkerUrl and subWorkerUrl"));const o=e.displayer,s=o.callbacks.on,n=o.callbacks.off,a=o.callbacks.once,c=e.cleanCurrentScene,l=e.mainView.setMemberState;let u;H.isRoom(o)&&(u=o.setWritable),t!=null&&t.logger&&(Y.logger=t.logger);let h=o.getInvisiblePlugin(Y.kind);h||(h=await Y.createApplianceMultiPlugin(o,Y.kind)),o&&h&&Y.createCurrentManager(e,{cdn:t.options.cdn,extras:{...Me,...t.options.extras}},h),h&&Y.currentManager&&(Y.currentManager.bindPlugin(h),h.init(o));const d={displayer:o,windowManager:e,currentManager:Y.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,getBoundingRectAsync:async function(p){var w;Y.logger.info("[ApplianceMultiPlugin] getBoundingRectAsync");const y=(e.mainView||o).getBoundingRect(p),I=await((w=Y.currentManager)==null?void 0:w.getBoundingRect(p));return!y.width||!y.height?I:yo(y,I)},screenshotToCanvasAsync:async function(p,y,I,w,S,C){var z;Y.logger.info("[ApplianceMultiPlugin] screenshotToCanvasAsync");let T=I,N=w,x=S.scale;T>this.maxScreenshotWidth&&(x=this.maxScreenshotWidth/T*x,T=this.maxScreenshotWidth),N>this.maxScreenshotHeight&&(x=Math.min(this.maxScreenshotHeight/N*x,x),N=this.maxScreenshotHeight),S.scale=x;const D=document.createElement("canvas"),L=D.getContext("2d");D.width=T*(C||1),D.height=N*(C||1),L&&((e.mainView||o).screenshotToCanvas(L,y,T,N,S,C),p.drawImage(D,Math.floor((I-T)/2),Math.floor((w-N)/2),T*(C||1),N*(C||1),0,0,T,N),D.remove()),Y.currentManager&&await((z=Y.currentManager)==null?void 0:z.screenshotToCanvas(p,y,T,N,S,Math.floor((I-T)/2),Math.floor((w-N)/2)))},scenePreviewAsync:async function(p,y,I,w,S){Y.logger.info("[ApplianceMultiPlugin] scenePreviewAsync"),(e.mainView||o).scenePreview(p,y,I,w,S);const C=document.createElement("img");C.className="appliance-plugin-fill-scene-snapshot-img",y.append(C),getComputedStyle(y).position||(y.style.position="relative"),Y.currentManager&&await Y.currentManager.scenePreview(p,C)},fillSceneSnapshotAsync:async function(p,y,I,w,S){Y.logger.info("[ApplianceMultiPlugin] fillSceneSnapshotAsync"),y.innerHTML="",(e.mainView||o).fillSceneSnapshot(p,y,I,w,S);const C=I||e.mainView.size.width,T=w||e.mainView.size.height;let N=await this.getBoundingRectAsync(p);N||(N={originX:0,originY:0,width:C,height:T});let x=Math.max(N==null?void 0:N.width,C),D=Math.max(N==null?void 0:N.height,T),L=1;const z=x>C&&Math.min(C/x,L)||L,j=D>T&&Math.min(T/D,L)||L;z<=j?(x=z<1&&C||x,D=Math.floor(D*z)+1,L=z):z>j&&(D=j<1&&T||D,x=Math.floor(x*j)+1,L=j);const E={scale:L,centerX:N.originX+N.width/2,centerY:N.originY+N.height/2},R=document.createElement("canvas"),P=R.getContext("2d");R.width=x,R.height=D,P&&await this.screenshotToCanvasAsync(P,p,x,D,E,devicePixelRatio);const Z=document.createElement("img");Z.className="appliance-plugin-fill-scene-snapshot-img",Z.src=R.toDataURL(),Z.onload=()=>{R.remove()},Z.onerror=()=>{R.remove(),Z.remove()},y.append(Z),getComputedStyle(y).position||(y.style.position="relative")},_callbacksOn:function(p,y){Y.logger.info(`[ApplianceMultiPlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&H.isRoom(o)&&o.isWritable?dt.InternalMsgEmitter.on(p,y):s.call(o.callbacks,p,y)},_callbacksOnce:function(p,y){Y.logger.info(`[ApplianceMultiPlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&H.isRoom(o)&&o.isWritable?dt.InternalMsgEmitter.on(p,y):a.call(o.callbacks,p,y)},_callbacksOff:function(p,y){Y.logger.info(`[ApplianceMultiPlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&H.isRoom(o)&&o.isWritable?dt.InternalMsgEmitter.off(p,y):n.call(o.callbacks,p,y)},canRedoSteps(){if(Y.logger.info("[ApplianceMultiPlugin] canRedoSteps"),Y.currentManager&&H.isRoom(o)&&!o.disableSerialization){const p=Y.currentManager.viewContainerManager.focuedView,y=p==null?void 0:p.focusScenePath;if(p&&y)return p.displayer.commiter.redoStack.filter(I=>I.scenePath===y).length}return 0},canUndoSteps(){if(Y.logger.info("[ApplianceMultiPlugin] canUndoSteps"),Y.currentManager&&H.isRoom(o)&&!o.disableSerialization){const p=Y.currentManager.viewContainerManager.focuedView,y=p==null?void 0:p.focusScenePath;if(p&&y)return p.displayer.commiter.undoStack.filter(I=>I.scenePath===y).length}return 0},undo:function(){return Y.logger.info("[ApplianceMultiPlugin] undo"),Y.currentManager&&H.isRoom(o)&&!o.disableSerialization?Y.currentManager.viewContainerManager.undo():0},redo:function(){return Y.logger.info("[ApplianceMultiPlugin] redo"),Y.currentManager&&H.isRoom(o)&&!o.disableSerialization?Y.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(){Y.logger.info("[ApplianceMultiPlugin] cleanCurrentScene"),Y.currentManager&&H.isRoom(o)&&o.isWritable&&(Y.currentManager.cleanCurrentScene(),c.call(e))},insertImage:function(p){if(Y.logger.info("[ApplianceMultiPlugin] insertImage"),Y.currentManager&&H.isRoom(o)&&o.isWritable){const y=Y.currentManager.viewContainerManager.focuedViewId||ge;Y.currentManager.worker.insertImage(y,p)}},lockImage:function(p,y){if(Y.logger.info("[ApplianceMultiPlugin] lockImage"),Y.currentManager&&H.isRoom(o)&&o.isWritable){const I=Y.currentManager.viewContainerManager.focuedViewId||ge;Y.currentManager.worker.lockImage(I,p,y)}},completeImageUpload:function(p,y){if(Y.logger.info("[ApplianceMultiPlugin] completeImageUpload"),Y.currentManager&&H.isRoom(o)&&o.isWritable){const I=Y.currentManager.viewContainerManager.focuedViewId||ge;Y.currentManager.worker.completeImageUpload(I,p,y)}},getImagesInformation:function(p){return Y.logger.info("[ApplianceMultiPlugin] completeImageUpload"),Y.currentManager&&H.isRoom(o)&&o.isWritable?Y.currentManager.worker.getImagesInformation(p):[]},insertText:function(p,y,I){if(Y.logger.info("[ApplianceMultiPlugin] insertText"),Y.currentManager&&H.isRoom(o)&&o.isWritable){const w=Y.currentManager.viewContainerManager.focuedViewId||ge;return Y.currentManager.textEditorManager.insertText(w,p,y,I)}},updateText:function(p,y){Y.logger.info("[ApplianceMultiPlugin] updateText"),Y.currentManager&&H.isRoom(o)&&o.isWritable&&Y.currentManager.textEditorManager.updateText(p,y)},callbacks:()=>(Y.logger.info("[ApplianceMultiPlugin] callbacks bind"),{...o.callbacks,on:d._callbacksOn.bind(d),once:d._callbacksOnce.bind(d),off:d._callbacksOff.bind(d)}),destroy(){Y.currentManager&&(Y.logger.info("[ApplianceMultiPlugin] destroy"),Y.currentManager.destroy(),Y.currentManager=void 0)},setMemberState(p){Y.logger.info(`[ApplianceMultiPlugin] setMemberState ${JSON.stringify(p)}`);const y=Object.keys(p);if(H.isRoom(o)&&o.isWritable){y.includes("currentApplianceName")&&(p.currentApplianceName&&p.currentApplianceName===re.laserPen?(p.currentApplianceName=re.pencil,p.useLaserPen=!0):p.currentApplianceName&&p.currentApplianceName===re.pencil&&(p.useLaserPen=!1)),l.call(e.mainView,p);return}throw new Error("[ApplianceMultiPlugin] setMemberState must be called in writable room")},setPerformancePriority(p){Y.logger.info("[ApplianceMultiPlugin] setPriority"),Y.currentManager&&Y.currentManager.setPriority(p)},createMiniMap:async function(p,y){if(Y.logger.info("[ApplianceMultiPlugin] createMiniMap"),Y.currentManager&&H.isRoom(o)&&o.isWritable)return Y.currentManager.createMiniMap(p,y)},destroyMiniMap:async function(p){if(Y.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),Y.currentManager&&H.isRoom(o)&&o.isWritable)return Y.currentManager.destroyMiniMap(p)},filterRenderByUid(p,y,I){if(Y.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),Y.currentManager&&H.isRoom(o)&&o.isWritable)return Y.currentManager.filterRenderByUid(p,y,I)},cancelFilterRender(p,y){if(Y.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),Y.currentManager&&H.isRoom(o)&&o.isWritable)return Y.currentManager.cancelFilterRender(p,y)},addListener:(p,y)=>{Y.logger.info(`[ApplianceMultiPlugin] addListener ${p}`),dt.PublicMsgEmitter.on(p,y)},removeListener:(p,y)=>{Y.logger.info(`[ApplianceMultiPlugin] removeListener ${p}`),dt.PublicMsgEmitter.off(p,y)},usePlugin:p=>{var y;Y.logger.info("[ApplianceMultiPlugin] usePlugin",p.kind),(y=Y.currentManager)==null||y.usePlugin(p)},getDisableDeviceInputs(){if(Y.currentManager&&H.isRoom(o))return Y.currentManager.disableDeviceInputs},setDisableDeviceInputs(p){Y.logger.info(`[ApplianceMultiPlugin] setDisableDeviceInputs ${p}`),Y.currentManager&&H.isRoom(o)&&(Y.currentManager.disableDeviceInputs=p)},getDisableCameraTransform(){if(Y.currentManager&&H.isRoom(o))return Y.currentManager.disableCameraTransform},setDisableCameraTransform(p){Y.logger.info(`[ApplianceMultiPlugin] setDisableCameraTransform ${p}`),Y.currentManager&&H.isRoom(o)&&(Y.currentManager.disableCameraTransform=p)},getDisableEraseImage(){if(Y.currentManager&&H.isRoom(o))return Y.currentManager.disableEraseImage},setDisableEraseImage(p){Y.logger.info(`[ApplianceMultiPlugin] setDisableEraseImage ${p}`),Y.currentManager&&H.isRoom(o)&&(Y.currentManager.disableEraseImage=p)},setWritable:async function(p){var y;Y.logger.info(`[ApplianceMultiPlugin] setWritable ${p}`),H.isRoom(o)&&u&&(await((y=Y.currentManager)==null?void 0:y.setWritable(p)),await u.call(o,p))},requestIdleCallback:(p,y)=>{const I=(y==null?void 0:y.timeout)||0,w=performance.now();let S;const C=new MessageChannel;let T;const N=x=>{try{p({didTimeout:x,timeRemaining:()=>{const L=performance.now()-w;return Math.max(0,I-L)}})}catch(D){Y.logger.error("[ApplianceMultiPlugin] requestIdleCallback error:",D)}finally{C.port1.close(),C.port2.close(),S!==void 0&&cancelAnimationFrame(S),T!==void 0&&clearTimeout(T)}};return C.port1.onmessage=()=>{S=requestAnimationFrame(()=>{I>0&&performance.now()-w>=I?N(!0):N(!1)})},C.port2.postMessage(null),I>0&&(T=setTimeout(()=>{N(!0)},I)),T||S||0},cancelIdleCallback:p=>{try{clearTimeout(p),cancelAnimationFrame(p)}catch(y){Y.logger.error("[ApplianceMultiPlugin] cancelIdleCallback error:",y)}},injectMethodToObject:(p,y)=>{if(Y.logger.info(`[ApplianceMultiPlugin] injectMethodToObject ${y}`),typeof p[y]=="function"||typeof p[y]>"u"){(y==="requestIdleCallback"||y==="cancelIdleCallback")&&Y.currentManager&&Y.currentManager.registerPolyfillMethod(y),p[y]=d[y];return}y==="callbacks"&&(p.callbacks.on=d._callbacksOn.bind(d),p.callbacks.off=d._callbacksOff.bind(d),p.callbacks.once=d._callbacksOnce.bind(d))},blurText:()=>{Y.logger.info("[ApplianceMultiPlugin] blurText"),Y.currentManager&&H.isRoom(o)&&o.isWritable&&Y.currentManager.textEditorManager.checkEmptyTextBlur()},hasElements:(p,y)=>{var I;if(Y.logger.info(`[ApplianceMultiPlugin] hasElements ${p}`),Y.currentManager&&H.isRoom(o)&&o.isWritable){let w=p;if(!w){const S=Y.currentManager.viewContainerManager.focuedView;w=S==null?void 0:S.focusScenePath}if(w){const S=(I=Y.currentManager.collector)==null?void 0:I.getScenePathData(w);if(S){const C=Object.values(S);return C.length>0?y?C.some(T=>y(T.toolsType)):!0:!1}return!1}return!1}}};d.injectMethodToObject(e,"undo"),d.injectMethodToObject(e,"redo"),d.injectMethodToObject(e,"cleanCurrentScene"),d.injectMethodToObject(e,"insertImage"),d.injectMethodToObject(e,"completeImageUpload"),d.injectMethodToObject(e,"lockImage"),d.injectMethodToObject(e,"insertText"),d.injectMethodToObject(e,"updateText"),d.injectMethodToObject(o,"getImagesInformation"),d.injectMethodToObject(o,"callbacks"),d.injectMethodToObject(o,"screenshotToCanvasAsync"),d.injectMethodToObject(o,"getBoundingRectAsync"),d.injectMethodToObject(o,"scenePreviewAsync"),d.injectMethodToObject(o,"fillSceneSnapshotAsync"),d.injectMethodToObject(e.mainView,"setMemberState"),H.isRoom(o)&&d.injectMethodToObject(o,"setWritable"),Object.defineProperty(e,"canUndoSteps",{get(){return d.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return d.canRedoSteps()}}),dt.InternalMsgEmitter.on("onCanUndoStepsUpdate",p=>{e.emitter.emit("canUndoStepsChange",p)}),dt.InternalMsgEmitter.on("onCanRedoStepsUpdate",p=>{e.emitter.emit("canRedoStepsChange",p)});const f={...d,callbacks:d.callbacks()};return Object.defineProperty(f,"disableDeviceInputs",{set(p){d.setDisableDeviceInputs(p)},get(){return d.getDisableDeviceInputs()}}),Object.defineProperty(f,"disableCameraTransform",{set(p){d.setDisableCameraTransform(p)},get(){return d.getDisableCameraTransform()}}),Object.defineProperty(f,"disableEraseImage",{set(p){d.setDisableEraseImage(p)},get(){return d.getDisableEraseImage()}}),e._appliancePlugin=f,e._appliancePlugin}static onCreate(e){e&&Y.currentManager&&(Y.currentManager.bindPlugin(e),e.init(e.displayer))}static async createApplianceMultiPlugin(e,t){try{await e.createInvisiblePlugin(Y,{})}catch(s){if(!e.isWritable){await e.setWritable(!0);const n=await this.createApplianceMultiPlugin(e,t);return await e.setWritable(!1),n}throw s}let o=e.getInvisiblePlugin(t);return o||(o=await Y.createApplianceMultiPlugin(e,t)),o}get isReplay(){return H.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(e){var o,s;const t=e.state;(o=Y.currentManager)==null||o.onRoomMembersChange(t.roomMembers),H.isRoom(e)&&((s=Y.currentManager)==null||s.onMemberChange(t.memberState)),this.displayer.callbacks.on(this.callbackName,this.roomStateChangeListener),this.displayer.callbacks.on("onEnableWriteNowChanged",this.updateRoomWritable),this.displayer.callbacks.on("onPhaseChanged",this.onPhaseChanged)}destroy(){var e;Y.logger.info("[ApplianceMultiPlugin] passive destroy"),(e=Y.currentManager)==null||e.destroy(),Y.currentManager=void 0}};M(Y,"kind","appliance-multi-plugin"),M(Y,"currentManager"),M(Y,"logger",{info:console.log,warn:console.warn,error:console.error}),M(Y,"createCurrentManager",(e,t,o)=>{Y.currentManager&&Y.currentManager.destroy();const s={plugin:o,displayer:e.displayer,options:t},n=new dt(s);if(Y.logger.info("[ApplianceMultiPlugin] refresh ApplianceMultiManager object"),n.setWindowManager(e),Y.currentManager=n,e.room){const a=n.hasOffscreenCanvas();e.room.logger.info(`[ApplianceMultiPlugin] use ${a?"worker":"mainThread"}`)}});let Ji=Y;var ew=st,tw=function(){return ew.Date.now()},iw=tw,ow=/\s/;function sw(r){for(var i=r.length;i--&&ow.test(r.charAt(i)););return i}var nw=sw,rw=nw,aw=/^\s+/;function cw(r){return r&&r.slice(0,rw(r)+1).replace(aw,"")}var lw=cw,hw=kt,uw=at,dw="[object Symbol]";function pw(r){return typeof r=="symbol"||uw(r)&&hw(r)==dw}var gw=pw,fw=lw,Ms=Mt,Mw=gw,ys=NaN,yw=/^[-+]0x[0-9a-f]+$/i,mw=/^0b[01]+$/i,ww=/^0o[0-7]+$/i,Iw=parseInt;function Tw(r){if(typeof r=="number")return r;if(Mw(r))return ys;if(Ms(r)){var i=typeof r.valueOf=="function"?r.valueOf():r;r=Ms(i)?i+"":i}if(typeof r!="string")return r===0?r:+r;r=fw(r);var e=mw.test(r);return e||ww.test(r)?Iw(r.slice(2),e?2:8):yw.test(r)?ys:+r}var vw=Tw,Nw=Mt,Wi=iw,ms=vw,Sw="Expected a function",Cw=Math.max,kw=Math.min;function xw(r,i,e){var t,o,s,n,a,c,l=0,u=!1,h=!1,d=!0;if(typeof r!="function")throw new TypeError(Sw);i=ms(i)||0,Nw(e)&&(u=!!e.leading,h="maxWait"in e,s=h?Cw(ms(e.maxWait)||0,i):s,d="trailing"in e?!!e.trailing:d);function f(N){var x=t,D=o;return t=o=void 0,l=N,n=r.apply(D,x),n}function g(N){return l=N,a=setTimeout(I,i),u?f(N):n}function p(N){var x=N-c,D=N-l,L=i-x;return h?kw(L,s-D):L}function y(N){var x=N-c,D=N-l;return c===void 0||x>=i||x<0||h&&D>=s}function I(){var N=Wi();if(y(N))return w(N);a=setTimeout(I,p(N))}function w(N){return a=void 0,d&&t?f(N):(t=o=void 0,n)}function S(){a!==void 0&&clearTimeout(a),l=0,t=c=o=a=void 0}function C(){return a===void 0?n:w(Wi())}function T(){var N=Wi(),x=y(N);if(t=arguments,o=this,c=N,x){if(a===void 0)return g(c);if(h)return clearTimeout(a),a=setTimeout(I,i),f(c)}return a===void 0&&(a=setTimeout(I,i)),n}return T.cancel=S,T.flush=C,T}var bw=xw,Dw=bw,Lw=Mt,Aw="Expected a function";function jw(r,i,e){var t=!0,o=!0;if(typeof r!="function")throw new TypeError(Aw);return Lw(e)&&(t="leading"in e?!!e.leading:t,o="trailing"in e?!!e.trailing:o),Dw(r,i,{leading:t,maxWait:i,trailing:o})}var zw=jw;const Pw=Ut(zw);class Ew extends vn{constructor(e,t){super(e,t);M(this,"width",1e3);M(this,"height",1e3);M(this,"dpr",ht());M(this,"vDom");M(this,"viewId",ge);M(this,"eventTragetElement");M(this,"snapshotContainerRef");M(this,"canvasContainerRef",m.createRef());M(this,"subLocalCanvasContainerRef",m.createRef());M(this,"canvasTopRef",m.createRef());M(this,"canvasServiceFloatRef",m.createRef());M(this,"canvasFloatRef",m.createRef());M(this,"canvasBgRef",m.createRef());M(this,"floatBarRef",m.createRef());M(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas()||(this.snapshotContainerRef=m.createRef())}setCanvassStyle(){if(this.eventTragetElement){const e=this.eventTragetElement.offsetWidth,t=this.eventTragetElement.offsetHeight;let o=ht();this.canvasBgRef.current&&(o=ht(this.canvasBgRef.current.getContext("2d"))),o!==this.dpr&&(this.dpr=o,this.control.worker.updateDpr(this.viewId,this.dpr)),e&&t&&this.canvasContainerRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t),e&&t&&this.canvasBgRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.canvasBgRef.current.width=e*this.dpr,this.canvasBgRef.current.height=t*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=e*this.dpr,this.canvasFloatRef.current.height=t*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=e*this.dpr,this.canvasServiceFloatRef.current.height=t*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=e*this.dpr,this.canvasTopRef.current.height=t*this.dpr))}}createMainViewDisplayer(e){return this.vDom||(this.containerOffset=this.getContainerOffset(e,this.containerOffset),this.eventTragetElement=e.parentElement.children[0],e.innerHTML="",Ii.render(m.createElement(vo,{viewId:this.viewId,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,snapshotContainerRef:this.snapshotContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef}}),e),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement)),this}}class ct extends Wt{constructor(e){super(e);M(this,"focuedViewId");M(this,"control");M(this,"focuedView");this.control=e.control}bindMainView(){if(!this.control.divMainView)return;const e=new Ew(this.control,xe.InternalMsgEmitter),{width:t,height:o,dpr:s}=e,n={dpr:s,originalPoint:[t/2,o/2],offscreenCanvasOpt:{...ct.defaultScreenCanvasOpt,width:t,height:o},layerOpt:{...ct.defaultLayerOpt,width:t,height:o},cameraOpt:{...ct.defaultCameraOpt,width:t,height:o}},a=this.control.room&&this.control.room.mainView||this.control.play&&this.control.play.mainView;if(a){const{scale:c,...l}=a.camera;n.cameraOpt={...n.cameraOpt,...l,scale:c===1/0?1:c},this.createMianView({id:ge,displayer:e,focusScenePath:a.focusScenePath||a.scenePath,cameraOpt:n.cameraOpt,viewData:a}),this.setFocuedViewId(ge),e.createMainViewDisplayer(this.control.divMainView)}}getViewInitData(e){var o;const t=this.getView(e);if(t){const{width:s,height:n,dpr:a}=t.displayer;(o=this.control.pluginOptions.extras.canvasOpt)!=null&&o.contextType&&(ct.defaultScreenCanvasOpt.contextType=this.control.pluginOptions.extras.canvasOpt.contextType);const c={dpr:a,originalPoint:[s/2,n/2],offscreenCanvasOpt:{...ct.defaultScreenCanvasOpt,width:s,height:n},layerOpt:{...ct.defaultLayerOpt,width:s,height:n},cameraOpt:{...ct.defaultCameraOpt,width:s,height:n}};if(t.viewData){const{scale:l,...u}=t.viewData.camera;c.cameraOpt={...c.cameraOpt,...u,scale:l===1/0?1:l}}return c}}async mountView(e){var o;const t=this.getView(e);if(t){this.control.worker.isActive||(this.control.cursor.activeCollector(),await this.control.activeWorker());const s=this.getViewInitData(e);s&&((o=this.control.worker)==null||o.createViewWorker(e,s)),t.focusScenePath&&this.control.collector&&this.control.worker.pullServiceData(e,t.focusScenePath,{isAsync:!0,useAnimation:!1})}}}class qe extends xe{constructor(e){super(e);M(this,"viewContainerManager");M(this,"divMainView");M(this,"onCameraChange",Pw(e=>{var o;const t=this.viewContainerManager.mainView;t&&t.cameraOpt&&(t.cameraOpt.width!==e.width||t.cameraOpt.height!==e.height)&&((o=this.viewContainerManager.mainView)==null||o.displayer.updateSize()),this.viewContainerManager.setFocuedViewCameraOpt(e)},Mo,{leading:!1}));const t={control:this,internalMsgEmitter:qe.InternalMsgEmitter,publicMsgEmitter:qe.PublicMsgEmitter};this.viewContainerManager=new ct(t)}init(){qe.InternalMsgEmitter.on(ne.BindMainView,e=>{this.divMainView=e,this.plugin&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView()})}activePlugin(){this.plugin&&this.divMainView&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView(),this.collector&&(this.collector.addStorageStateListener(e=>{var a,c;if((a=this.collector)!=null&&a.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(ge,!0);return}const{diffView:t,diffScenePath:o,diffData:s}=e,n=new Map;if(t){let l;Object.keys(t).forEach(u=>{var d;const h=t[u];if(h&&!h.newValue)(d=this.worker)==null||d.clearViewScenePath(u,!0),h.oldValue&&(l=h.oldValue);else if(h&&h.newValue){for(const f of Object.keys(h.newValue))this.worker.pullServiceData(u,f,{isAsync:!1,useAnimation:!0});l=h.newValue}if(l)for(const f of Object.values(l)){const g=new Set;for(const p of Object.keys(f))p&&g.add(p);n.set(u,g)}})}if(o){let l;Object.keys(o).forEach(u=>{var d;const h=o[u];if(h&&h.viewId&&!h.newValue?((d=this.worker)==null||d.clearViewScenePath(h.viewId,!0),h.oldValue&&(l=h.oldValue)):h&&h.viewId&&h.newValue&&(this.worker.pullServiceData(h.viewId,u,{isAsync:!1,useAnimation:!0}),l=h.newValue),h!=null&&h.viewId&&l){const f=new Set;for(const g of Object.keys(l))g&&f.add(g),n.set(h.viewId,f)}})}s&&Object.keys(s).forEach(l=>{var h,d;const u=s[l];if(u){const{viewId:f}=u,g=n.get(f)||new Set;g.add(l),n.set(f,g),(h=this.worker)==null||h.onServiceDerive(l,u),(d=this.miniMapManager)==null||d.updateMiniMapCamera(f)}});for(const[l,u]of n.entries())xe.InternalMsgEmitter.emit("excludeIds",[...u],l)}),this.room&&(this.roomMember.onUidChangeHook(e=>{var t;(t=this.collector)!=null&&t.serviceStorage&&this.viewContainerManager.getAllViews().forEach(o=>{var s,n,a,c,l,u;if(o&&o.focusScenePath&&((s=this.collector)!=null&&s.serviceStorage[o.id])&&((n=this.collector)!=null&&n.serviceStorage[o.id][o.focusScenePath])){const h=Object.keys((a=this.collector)==null?void 0:a.serviceStorage[o.id][o.focusScenePath]);for(const d of h){const f=(c=this.collector)==null?void 0:c.getUidFromKey(d);if(f&&!e.online.includes(f))if((l=this.collector)!=null&&l.isSelector(d))this.renderControl.isWritable&&((u=this.collector)==null||u.updateValue(d,void 0,{viewId:o.id,scenePath:o.focusScenePath,isSync:!0})),this.worker.blurSelector(o.id,o.focusScenePath,d);else{const g=this.textEditorManager.editors.get(d);g&&g.opt&&(g.opt.workState===A.Doing||g.opt.workState===A.Start)&&(g.opt.text&&g.opt.text.replace(/\s*,/g,"")?this.textEditorManager.unActive(d):this.textEditorManager.delete(d))}}}})}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(e=>{e&&e.focusScenePath&&this.worker.pullServiceData(e.id,e.focusScenePath,{isAsync:!0,useAnimation:!1})})))}async activeWorker(){await this.worker.init()}}const W=class W extends H.InvisiblePlugin{constructor(){super(...arguments);M(this,"onPhaseChanged",e=>{var t;e===H.RoomPhase.Reconnecting&&((t=W.currentManager)==null||t.setSnapshootData())});M(this,"updateRoomWritable",()=>{var e;(e=W.currentManager)==null||e.onWritableChange(this.displayer.isWritable)});M(this,"roomStateChangeListener",async e=>{var t,o;W.currentManager instanceof qe&&(e.cameraState&&W.currentManager.onCameraChange(e.cameraState),e.sceneState&&W.currentManager.onSceneChange(e.sceneState.scenePath,ge)),e!=null&&e.roomMembers&&((t=W.currentManager)==null||t.onRoomMembersChange(e.roomMembers)),!(H.isRoom(this.displayer)&&!this.displayer.isWritable)&&e.memberState&&((o=W.currentManager)==null||o.onMemberChange(e.memberState))})}static async getInstance(e,t){var f;t.options&&(((f=t.options.extras)==null?void 0:f.useWorker)==="mainThread"&&(t.options.cdn.fullWorkerUrl="",t.options.cdn.subWorkerUrl=""),(t.options.extras&&t.options.extras.useWorker!=="mainThread"||!t.options.extras)&&!t.options.cdn.fullWorkerUrl&&!t.options.cdn.subWorkerUrl&&W.logger.error("[ApplianceSinglePlugin] you must adaptor options cdn fullWorkerUrl and subWorkerUrl"));const o=e.callbacks.on,s=e.callbacks.off,n=e.callbacks.once,a=e.cleanCurrentScene.bind(e),c=e.setMemberState.bind(e);let l;H.isRoom(e)&&(l=e.setWritable),t!=null&&t.logger&&(W.logger=t.logger);let u=e.getInvisiblePlugin(W.kind);u||(u=await W.createAppliancePlugin(e,W.kind)),e&&u&&W.createCurrentManager(e,{cdn:t.options.cdn,extras:{...Me,...t.options.extras}},u),u&&W.currentManager&&(W.currentManager.bindPlugin(u),u.init(e)),t!=null&&t.cursorAdapter&&(W.cursorAdapter=t.cursorAdapter),W.effectInstance();const h={displayer:e,currentManager:W.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,_injectTargetObject:void 0,getBoundingRectAsync:async function(g){var I;W.logger.info("[ApplianceSinglePlugin] getBoundingRectAsync");const p=e.getBoundingRect(g),y=await((I=W.currentManager)==null?void 0:I.getBoundingRect(g));return!p.width||!p.height?y:yo(p,y)},screenshotToCanvasAsync:async function(g,p,y,I,w,S){var L;W.logger.info("[ApplianceSinglePlugin] screenshotToCanvasAsync");let C=y,T=I,N=w.scale;C>this.maxScreenshotWidth&&(N=this.maxScreenshotWidth/C*N,C=this.maxScreenshotWidth),T>this.maxScreenshotHeight&&(N=Math.min(this.maxScreenshotHeight/T*N,N),T=this.maxScreenshotHeight),w.scale=N;const x=document.createElement("canvas"),D=x.getContext("2d");x.width=C*(S||1),x.height=T*(S||1),D&&(e.screenshotToCanvas(D,p,C,T,w,S),g.drawImage(x,Math.floor((y-C)/2),Math.floor((I-T)/2),C*(S||1),T*(S||1),0,0,C,T),x.remove()),W.currentManager&&await((L=W.currentManager)==null?void 0:L.screenshotToCanvas(g,p,C,T,w,Math.floor((y-C)/2),Math.floor((I-T)/2)))},scenePreviewAsync:async function(g,p,y,I,w){W.logger.info("[ApplianceSinglePlugin] scenePreviewAsync"),e.scenePreview(g,p,y,I,w);const S=document.createElement("img");S.className="appliance-plugin-fill-scene-snapshot-img",p.append(S),getComputedStyle(p).position||(p.style.position="relative"),W.currentManager&&await W.currentManager.scenePreview(g,S)},fillSceneSnapshotAsync:async function(g,p,y,I,w){var Z,_;W.logger.info("[ApplianceSinglePlugin] fillSceneSnapshotAsync"),p.innerHTML="",e.fillSceneSnapshot(g,p,y,I,w);const S=y||((Z=e.state.cameraState)==null?void 0:Z.width)||0,C=I||((_=e.state.cameraState)==null?void 0:_.height)||0;let T=await this.getBoundingRectAsync(g);T||(T={originX:0,originY:0,width:S,height:C});let N=Math.max(T==null?void 0:T.width,S),x=Math.max(T==null?void 0:T.height,C),D=1;const L=N>S&&Math.min(S/N,D)||D,z=x>C&&Math.min(C/x,D)||D;L<=z?(N=L<1&&S||N,x=Math.floor(x*L)+1,D=L):L>z&&(x=z<1&&C||x,N=Math.floor(N*z)+1,D=z);const j={scale:D,centerX:T.originX+T.width/2,centerY:T.originY+T.height/2},E=document.createElement("canvas"),R=E.getContext("2d");E.width=N,E.height=x,R&&await this.screenshotToCanvasAsync(R,g,N,x,j,devicePixelRatio);const P=document.createElement("img");P.className="appliance-plugin-fill-scene-snapshot-img",P.src=E.toDataURL(),P.onload=()=>{E.remove()},P.onerror=()=>{E.remove(),P.remove()},p.append(P),getComputedStyle(p).position||(p.style.position="relative")},_callbacksOn:function(g,p){W.logger.info(`[ApplianceSinglePlugin] callbacks ${g}`),(g==="onCanUndoStepsUpdate"||g==="onCanRedoStepsUpdate")&&H.isRoom(e)&&e.isWritable?qe.InternalMsgEmitter.on(g,p):o.call(e.callbacks,g,p)},_callbacksOnce:function(g,p){W.logger.info(`[ApplianceSinglePlugin] callbacks ${g}`),(g==="onCanUndoStepsUpdate"||g==="onCanRedoStepsUpdate")&&H.isRoom(e)&&e.isWritable?qe.InternalMsgEmitter.on(g,p):n.call(e.callbacks,g,p)},_callbacksOff:function(g,p){W.logger.info(`[ApplianceSinglePlugin] callbacks ${g}`),(g==="onCanUndoStepsUpdate"||g==="onCanRedoStepsUpdate")&&H.isRoom(e)&&e.isWritable?qe.InternalMsgEmitter.off(g,p):s.call(e.callbacks,g,p)},canRedoSteps(){if(W.logger.info("[ApplianceSinglePlugin] canRedoSteps"),W.currentManager&&H.isRoom(e)&&!e.disableSerialization){const g=W.currentManager.viewContainerManager.focuedView,p=g==null?void 0:g.focusScenePath;if(g&&p)return g.displayer.commiter.redoStack.filter(y=>y.scenePath===p).length}return 0},canUndoSteps(){if(W.logger.info("[ApplianceSinglePlugin] canUndoSteps"),W.currentManager&&H.isRoom(e)&&!e.disableSerialization){const g=W.currentManager.viewContainerManager.focuedView,p=g==null?void 0:g.focusScenePath;if(g&&p)return g.displayer.commiter.undoStack.filter(y=>y.scenePath===p).length}return 0},undo:function(){return W.logger.info("[ApplianceSinglePlugin] undo"),W.currentManager&&H.isRoom(e)&&!e.disableSerialization?W.currentManager.viewContainerManager.undo():0},redo:function(){return W.logger.info("[ApplianceSinglePlugin] redo"),W.currentManager&&H.isRoom(e)&&!e.disableSerialization?W.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(g){W.logger.info("[ApplianceSinglePlugin] cleanCurrentScene"),W.currentManager&&H.isRoom(e)&&e.isWritable&&(W.currentManager.cleanCurrentScene(),a.call(e,g))},insertImage:function(g){W.logger.info("[ApplianceSinglePlugin] insertImage"),W.currentManager&&H.isRoom(e)&&e.isWritable&&W.currentManager.worker.insertImage(ge,g)},lockImage:function(g,p){W.logger.info("[ApplianceSinglePlugin] lockImage"),W.currentManager&&H.isRoom(e)&&e.isWritable&&W.currentManager.worker.lockImage(ge,g,p)},completeImageUpload:function(g,p){W.logger.info("[ApplianceSinglePlugin] completeImageUpload"),W.currentManager&&H.isRoom(e)&&e.isWritable&&W.currentManager.worker.completeImageUpload(ge,g,p)},getImagesInformation:function(g){return W.logger.info("[ApplianceSinglePlugin] completeImageUpload"),W.currentManager&&H.isRoom(e)&&e.isWritable?W.currentManager.worker.getImagesInformation(g):[]},insertText:function(g,p,y){if(W.logger.info("[ApplianceSinglePlugin] insertText"),W.currentManager&&H.isRoom(e)&&e.isWritable)return W.currentManager.textEditorManager.insertText(ge,g,p,y)},updateText:function(g,p){W.logger.info("[ApplianceMultiPlugin] updateText"),W.currentManager&&H.isRoom(e)&&e.isWritable&&W.currentManager.textEditorManager.updateText(g,p)},callbacks:()=>({...e.callbacks,on:h._callbacksOn.bind(h),once:h._callbacksOnce.bind(h),off:h._callbacksOff.bind(h)}),destroy(){W.currentManager&&(W.logger.info("[ApplianceSinglePlugin] destroy"),W.currentManager.destroy(),W.currentManager=void 0,W.cursorAdapter=void 0)},setMemberState(g){W.logger.info(`[ApplianceSinglePlugin] setMemberState ${JSON.stringify(g)}`);const p=Object.keys(g);if(H.isRoom(e)&&e.isWritable){p.includes("currentApplianceName")&&(g.currentApplianceName&&g.currentApplianceName===re.laserPen?(g.currentApplianceName=re.pencil,g.useLaserPen=!0):g.currentApplianceName&&g.currentApplianceName===re.pencil&&(g.useLaserPen=!1)),c(g);return}throw new Error("setMemberState must be called in writable room")},setPerformancePriority(g){W.logger.info("[ApplianceSinglePlugin] setPriority"),W.currentManager&&W.currentManager.setPriority(g)},createMiniMap:async function(g,p){if(W.logger.info("[ApplianceSinglePlugin] createMiniMap"),W.currentManager&&H.isRoom(e)&&e.isWritable)return W.currentManager.createMiniMap(g,p)},destroyMiniMap:async function(g){if(W.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),W.currentManager&&H.isRoom(e)&&e.isWritable)return W.currentManager.destroyMiniMap(g)},filterRenderByUid(g,p,y){if(W.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),W.currentManager&&H.isRoom(e)&&e.isWritable)return W.currentManager.filterRenderByUid(g,p,y)},cancelFilterRender(g,p){if(W.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),W.currentManager&&H.isRoom(e)&&e.isWritable)return W.currentManager.cancelFilterRender(g,p)},addListener:(g,p)=>{W.logger.info(`[ApplianceSinglePlugin] addListener ${g}`),qe.PublicMsgEmitter.on(g,p)},removeListener:(g,p)=>{W.logger.info(`[ApplianceSinglePlugin] removeListener ${g}`),qe.PublicMsgEmitter.off(g,p)},usePlugin:g=>{var p;W.logger.info("[ApplianceSinglePlugin] usePlugin",g.kind),(p=W.currentManager)==null||p.usePlugin(g)},getDisableDeviceInputs(){if(W.currentManager&&H.isRoom(e))return W.currentManager.disableDeviceInputs},setDisableDeviceInputs(g){W.logger.info(`[ApplianceSinglePlugin] setDisableDeviceInputs ${g}`),W.currentManager&&H.isRoom(e)&&(W.currentManager.disableDeviceInputs=g)},getDisableCameraTransform(){if(W.currentManager&&H.isRoom(e))return W.currentManager.disableCameraTransform},setDisableCameraTransform(g){W.logger.info(`[ApplianceSinglePlugin] setDisableCameraTransform ${g}`),W.currentManager&&H.isRoom(e)&&(W.currentManager.disableCameraTransform=g)},getDisableEraseImage(){if(W.currentManager&&H.isRoom(e))return W.currentManager.disableEraseImage},setDisableEraseImage(g){W.logger.info(`[ApplianceSinglePlugin] setDisableEraseImage ${g}`),W.currentManager&&H.isRoom(e)&&(W.currentManager.disableEraseImage=g)},setWritable:async function(g){var p;W.logger.info(`[ApplianceSinglePlugin] setWritable ${g}`),H.isRoom(e)&&l&&(await((p=W.currentManager)==null?void 0:p.setWritable(g)),await l.call(e,g))},requestIdleCallback:(g,p)=>{const y=(p==null?void 0:p.timeout)||0,I=performance.now();let w;const S=new MessageChannel;let C;const T=N=>{try{g({didTimeout:N,timeRemaining:()=>{const D=performance.now()-I;return Math.max(0,y-D)}})}catch(x){W.logger.error("[ApplianceSinglePlugin] requestIdleCallback error:",x)}finally{S.port1.close(),S.port2.close(),w!==void 0&&cancelAnimationFrame(w),C!==void 0&&clearTimeout(C)}};return S.port1.onmessage=()=>{w=requestAnimationFrame(()=>{y>0&&performance.now()-I>=y?T(!0):T(!1)})},S.port2.postMessage(null),y>0&&(C=setTimeout(()=>{T(!0)},y)),C||w||0},cancelIdleCallback:g=>{try{clearTimeout(g),cancelAnimationFrame(g)}catch(p){W.logger.error("[ApplianceSinglePlugin] cancelIdleCallback error:",p)}},injectMethodToObject:(g,p)=>{if(W.logger.info(`[ApplianceSinglePlugin] injectMethodToObject ${p}`),typeof g[p]=="function"||typeof g[p]>"u"){g[p]=h[p];return}p==="callbacks"&&(g.callbacks.on=h._callbacksOn.bind(h),g.callbacks.off=h._callbacksOff.bind(h),g.callbacks.once=h._callbacksOnce.bind(h))},blurText:()=>{W.logger.info("[ApplianceSinglePlugin] blurText"),W.currentManager&&H.isRoom(e)&&e.isWritable&&W.currentManager.textEditorManager.checkEmptyTextBlur()},hasElements:(g,p)=>{var y;if(W.logger.info(`[ApplianceSinglePlugin] hasElements ${g}`),W.currentManager&&H.isRoom(e)&&e.isWritable){let I=g;if(!I){const w=W.currentManager.viewContainerManager.focuedView;I=w==null?void 0:w.focusScenePath}if(I){const w=(y=W.currentManager.collector)==null?void 0:y.getScenePathData(I);if(w){const S=Object.values(w);return S.length>0?p?S.some(C=>p(C.toolsType)):!0:!1}return!1}return!1}}};h.injectMethodToObject(e,"undo"),h.injectMethodToObject(e,"redo"),h.injectMethodToObject(e,"cleanCurrentScene"),h.injectMethodToObject(e,"insertImage"),h.injectMethodToObject(e,"completeImageUpload"),h.injectMethodToObject(e,"lockImage"),h.injectMethodToObject(e,"getImagesInformation"),h.injectMethodToObject(e,"insertText"),h.injectMethodToObject(e,"updateText"),h.injectMethodToObject(e,"callbacks"),h.injectMethodToObject(e,"screenshotToCanvasAsync"),h.injectMethodToObject(e,"getBoundingRectAsync"),h.injectMethodToObject(e,"scenePreviewAsync"),h.injectMethodToObject(e,"fillSceneSnapshotAsync"),h.injectMethodToObject(e,"setMemberState"),H.isRoom(e)&&h.injectMethodToObject(e,"setWritable"),Object.defineProperty(e,"canUndoSteps",{get(){return h.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return h.canRedoSteps()}});const d={...h,callbacks:h.callbacks()};return Object.defineProperty(d,"disableDeviceInputs",{set(g){h.setDisableDeviceInputs(g)},get(){return h.getDisableDeviceInputs()}}),Object.defineProperty(d,"disableEraseImage",{set(g){h.setDisableEraseImage(g)},get(){return h.getDisableEraseImage()}}),Object.defineProperty(d,"disableCameraTransform",{set(g){h.setDisableCameraTransform(g)},get(){return h.getDisableCameraTransform()}}),e._appliancePlugin=d,e._appliancePlugin}static onCreate(e){e&&W.currentManager&&(W.currentManager.bindPlugin(e),e.init(e.displayer))}static async createAppliancePlugin(e,t){try{await e.createInvisiblePlugin(W,{})}catch(s){if(!e.isWritable){await e.setWritable(!0);const n=await this.createAppliancePlugin(e,t);return await e.setWritable(!1),n}throw s}let o=e.getInvisiblePlugin(t);return o||(o=await W.createAppliancePlugin(e,t)),o}static effectInstance(){if(W.cursorAdapter){const e=W.cursorAdapter.onAddedCursor;W.cursorAdapter.onAddedCursor=function(t){t.onCursorMemberChanged=o=>{try{o.appliance===re.pencil||o.appliance===re.shape||o.appliance===re.text||o.appliance===re.arrow||o.appliance===re.straight||o.appliance===re.rectangle||o.appliance===re.ellipse||o.appliance===re.eraser||o.appliance===re.selector?t!=null&&t.divElement&&(t.divElement.style.display="none"):t!=null&&t.divElement&&(t.divElement.style.display="block")}catch(s){throw s}},e.call(W.cursorAdapter,t)}}}get isReplay(){return H.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(e){var o,s;const t=e.state;(o=W.currentManager)==null||o.onRoomMembersChange(t.roomMembers),H.isRoom(e)&&t!=null&&t.memberState&&((s=W.currentManager)==null||s.onMemberChange(t.memberState)),this.displayer.callbacks.on(this.callbackName,this.roomStateChangeListener),this.displayer.callbacks.on("onEnableWriteNowChanged",this.updateRoomWritable),this.displayer.callbacks.on("onPhaseChanged",this.onPhaseChanged)}destroy(){var e;W.logger.info("[ApplianceSinglePlugin] passive destroy"),(e=W.currentManager)==null||e.destroy(),W.currentManager=void 0,W.cursorAdapter=void 0}};M(W,"kind","appliance-single-plugin"),M(W,"cursorAdapter"),M(W,"currentManager"),M(W,"logger",{info:console.log,warn:console.warn,error:console.error}),M(W,"createCurrentManager",(e,t,o)=>{W.currentManager&&W.currentManager.destroy();const s={plugin:o,displayer:e,options:t},n=new qe(s);if(n.init(),W.logger.info("[ApplianceSinglePlugin] refresh ApplianceSingleManager object"),W.currentManager=n,H.isRoom(e)){const a=n.hasOffscreenCanvas();e.logger.info(`[ApplianceSinglePlugin] use ${a?"worker":"mainThread"}`)}});let qi=W;const Rt=class Rt extends m.Component{constructor(){super(...arguments);M(this,"mainViewRef",null)}componentDidMount(){Rt.emiter||(Rt.emiter=qe.InternalMsgEmitter),Rt.emiter.emit(ne.BindMainView,this.mainViewRef)}render(){return m.createElement(m.Fragment,null,this.props.children,m.createElement("div",{className:"appliance-plugin-main-view-displayer",ref:e=>this.mainViewRef=e}))}};M(Rt,"emiter");let Ki=Rt;class Ow extends Tn{constructor(e){super();M(this,"kind","autoDraw");M(this,"localStorage",[]);M(this,"excludeStorage",[]);M(this,"timer");M(this,"hostServer");M(this,"iconsContainer");M(this,"icons",[]);M(this,"iconRect");M(this,"isActive",!1);M(this,"viewId",ge);M(this,"scenePath");M(this,"delay",2e3);const{container:t,hostServer:o,delay:s}=e;this.hostServer=o,this.iconsContainer=t,this.delay=s||2e3}get collector(){return this.control.collector}onDestroy(){this.unMount()}onCreate(){}onSetToolkey(e){e===v.Pencil?this.isActive=!0:(this.isActive&&(this.localStorage.length=0,this.timer&&clearTimeout(this.timer),this.timer=void 0,this.iconRect&&(this.iconRect=void 0),this.icons.length=0),this.isActive=!1)}syncStorage(e,t){if(!this.isActive||e!==this.viewId)return;if(!t){this.localStorage.length=0;return}const o=this.getOwnStorage(this.viewId,t);this.localStorage=o.map(s=>{var n;return((n=this.collector)==null?void 0:n.getLocalId(s))||s})}getOwnStorage(e,t){var n,a;if(!e||!t)return[];const o=(a=(n=this.collector)==null?void 0:n.storage[e])==null?void 0:a[t];return o?Object.keys(o).filter(c=>{var l,u;return((l=this.collector)==null?void 0:l.isOwn(c))&&((u=o[c])==null?void 0:u.toolsType)===v.Pencil&&!this.excludeStorage.includes(c)}):[]}async batchLocalDraw(){var a;if(this.localStorage.length===0||!this.scenePath||!((a=this.collector)==null?void 0:a.getStorageData(this.viewId,this.scenePath)))return;const t=this.localStorage.toString(),o=await this.control.worker.getVNodeInfo(this.localStorage.toString(),this.viewId,this.localStorage);if(!o)return;const{vInfo:s,uuid:n}=o;if(n===t&&s){const c={rect:{centerX:0,centerY:0,width:0,height:0},ink:[]};let l;const u=[];for(const{rect:h,op:d}of s){l=he(l,h);const f=[],g=[];for(let p=0;p<d.length;p+=3){f.push(d[p]),g.push(d[p+1]);const y=u.length&&u[u.length-1]||0;p===0?u.length===0?u.push(0):u.push(y+100):u.push(y+15)}c.ink.push([f,g,u])}return l&&(c.rect.centerX=Math.floor(l.x+l.w/2),c.rect.centerY=Math.floor(l.y+l.h/2),c.rect.width=Math.floor(l.w),c.rect.height=Math.floor(l.h)),c}}async computAutoDraw(e){const{rect:t,ink:o}=e;this.iconRect=t;const s=await fetch(this.hostServer,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({width:t.width,height:t.height,ink:o})}).then(n=>n.json()).then(n=>n.data);this.icons=s||[]}buildHTML(){var o;this.iconsContainer.innerHTML="";const e=document.createElement("div");e.style.display="flex",e.style.overflow="auto",e.style.padding="10px 0";const t=((o=this.control.worker.currentToolsData)==null?void 0:o.toolsOpt.strokeColor)||"#7f7f7f";this.icons.forEach(s=>{const n=document.createElement("img");n.src=`https://api.iconify.design/${s}.svg?color=${t}`,n.onclick=()=>{this.onClickIcon(s)},n.onload=()=>{e.appendChild(n)}}),this.iconsContainer.appendChild(e)}onClickIcon(e){var t,o;if(this.iconRect){const s=this.control.viewContainerManager.transformToScenePoint([this.iconRect.centerX,this.iconRect.centerY],this.viewId),n=((o=(t=this.control.viewContainerManager.getView(this.viewId))==null?void 0:t.cameraOpt)==null?void 0:o.scale)||1;this.icons.length=0,this.iconsContainer.innerHTML="";const a=Date.now().toString();this.control.worker.removeNodes(this.viewId,this.localStorage),this.localStorage.length=0,this.control.insertIconify(this.viewId,{uuid:a,centerX:s[0],centerY:s[1],width:Math.floor(this.iconRect.width/n),height:Math.floor(this.iconRect.height/n),src:`https://api.iconify.design/${e}.svg`,uniformScale:!1,locked:!1}),this.iconRect=void 0}}sceneChange(e,t){e===this.viewId&&(this.scenePath=t,this.excludeStorage=this.getOwnStorage(e,t)),this.localStorage.length=0}localEvent(e,t){var o;if(e===this.viewId&&((o=this.control.worker.currentToolsData)==null?void 0:o.toolsType)===v.Pencil)switch(t){case A.Start:this.timer&&(clearTimeout(this.timer),this.timer=void 0);break;case A.Done:this.timer&&clearTimeout(this.timer),this.timer=setTimeout(async()=>{this.timer=void 0;const s=await this.batchLocalDraw();s&&(await this.computAutoDraw(s),this.buildHTML())},this.delay);break}}mount(){var t,o;this.scenePath=(t=this.control.viewContainerManager.getView(this.viewId))==null?void 0:t.focusScenePath,this.excludeStorage=this.getOwnStorage(this.viewId,this.scenePath);const e=(o=this.control.worker.currentToolsData)==null?void 0:o.toolsType;e&&this.onSetToolkey(e),this.callbacks("setToolkey",this.onSetToolkey.bind(this)),this.callbacks("syncStorage",this.syncStorage.bind(this)),this.callbacks("sceneChange",this.sceneChange.bind(this)),this.callbacks("localEvent",this.localEvent.bind(this))}unMount(){this.timer&&clearTimeout(this.timer),this.timer=void 0,this.iconRect&&(this.iconRect=void 0),this.icons.length=0,this.excludeStorage.length=0,this.localStorage.length=0,this.iconsContainer.innerHTML="",this.removeCallback("setToolkey"),this.removeCallback("syncStorage"),this.removeCallback("sceneChange"),this.removeCallback("localEvent")}}exports.ActiveContainerType=Is;exports.ApplianceMultiPlugin=Ji;exports.ApplianceNames=re;exports.ApplianceSigleWrapper=Ki;exports.ApplianceSinglePlugin=qi;exports.AutoDrawPlugin=Ow;exports.Cursor_Hover_Id=If;exports.DefaultAppliancePluginExtrasOptions=Me;exports.ECanvasShowType=we;exports.EDataType=V;exports.EForceStopReason=Ti;exports.EImageType=St;exports.EMatrixrRelationType=Nt;exports.EOperationType=Re;exports.EPostMessageType=b;exports.ERenderFilterType=tt;exports.EScaleType=ce;exports.EStrokeType=se;exports.EToolsKey=v;exports.ElayerType=Jt;exports.EmitEventType=F;exports.EventMessageType=Xt;exports.EvevtWorkState=A;exports.EvevtWorkType=Ts;exports.InternalMsgEmitterType=ne;exports.Main_View_Id=ge;exports.Plugin=Tn;exports.ShapeType=_e;exports.Storage_Selector_key=G;exports.Storage_Splitter=Ze;exports.Storage_ViewId_ALL=ai;exports.Task_Time_Interval=Mo;exports.VNodeManager=dn;exports.ViewContainerManager=Wt;exports.computRect=he;exports.fullWorker=bn;exports.getRectMatrixrRelation=Io;exports.getSafetyRect=pt;exports.getShapeInstance=Li;exports.isEqual=lt;exports.isIntersectForPoint=wn;exports.isNumber=We;exports.removeAllChildren=Be;exports.removeTexture=$e;exports.requestAsyncCallBack=it;exports.subWorker=Dn;exports.transformToNormalData=bt;exports.transformToSerializableData=Ye;
|