@netless/appliance-plugin 1.1.0 → 1.1.1-beta.0

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.
@@ -0,0 +1 @@
1
+ "use strict";var ji=Object.defineProperty;var Di=(r,o,t)=>o in r?ji(r,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[o]=t;var M=(r,o,t)=>Di(r,typeof o!="symbol"?o+"":o,t);const st=require("white-web-sdk"),lt=require("spritejs"),Ps=require("lz-string"),bo=require("lineclip"),js=require("eventemitter2"),P=require("lodash"),Lo=require("react-dom"),g=require("react"),Me=require("react-draggable"),Ai=require("re-resizable"),Ei="/fullWorker.js",Oi="/subWorker.js";var et=(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))(et||{}),X=(r=>(r.Normal="Normal",r.Stroke="Stroke",r.Dotted="Dotted",r.LongDotted="LongDotted",r))(X||{}),Dt=(r=>(r.Triangle="triangle",r.Rhombus="rhombus",r.Pentagram="pentagram",r.SpeechBalloon="speechBalloon",r.Star="star",r.Polygon="polygon",r))(Dt||{}),R=(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))(R||{}),Z=(r=>(r.DisplayState="DisplayState",r.MainEngine="MainEngine",r.Cursor="Cursor",r.BindMainView="BindMainView",r))(Z||{}),Ds=(r=>(r[r.MainView=0]="MainView",r[r.Plugin=1]="Plugin",r[r.Both=2]="Both",r))(Ds||{}),C=(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))(C||{}),F=(r=>(r[r.Local=1]="Local",r[r.Service=2]="Service",r[r.Worker=3]="Worker",r))(F||{}),L=(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))(L||{}),z=(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))(z||{}),_e=(r=>(r.Webgl2="webgl2",r.Webgl="webgl",r.Canvas2d="2d",r))(_e||{}),Wt=(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))(Wt||{}),ke=(r=>(r[r.Cursor=1]="Cursor",r[r.TextCreate=2]="TextCreate",r))(ke||{}),ee=(r=>(r[r.Top=1]="Top",r[r.Bottom=2]="Bottom",r))(ee||{}),ct=(r=>(r[r.none=1]="none",r[r.all=2]="all",r[r.both=3]="both",r[r.proportional=4]="proportional",r))(ct||{}),As=(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))(As||{}),xe=(r=>(r[r.inside=0]="inside",r[r.outside=1]="outside",r[r.intersect=2]="intersect",r))(xe||{});const Ri={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(o=0,t=0,e=1){this.x=o,this.y=t,this.z=e}get XY(){return[this.x,this.y]}setz(o){return this.z=o,this}setXY(o=this.x,t=this.y){return this.x=o,this.y=t,this}set(o=this.x,t=this.y,e=this.z){return this.x=o,this.y=t,this.z=e,this}setTo({x:o=0,y:t=0,z:e=1}){return this.x=o,this.y=t,this.z=e,this}rot(o){if(o===0)return this;const{x:t,y:e}=this,s=Math.sin(o),i=Math.cos(o);return this.x=t*i-e*s,this.y=t*s+e*i,this}rotWith(o,t){if(t===0)return this;const e=this.x-o.x,s=this.y-o.y,i=Math.sin(t),n=Math.cos(t);return this.x=o.x+(e*n-s*i),this.y=o.y+(e*i+s*n),this}clone(){const{x:o,y:t,z:e}=this;return new k(o,t,e)}sub(o){return this.x-=o.x,this.y-=o.y,this}subXY(o,t){return this.x-=o,this.y-=t,this}subScalar(o){return this.x-=o,this.y-=o,this}add(o){return this.x+=o.x,this.y+=o.y,this}addXY(o,t){return this.x+=o,this.y+=t,this}addScalar(o){return this.x+=o,this.y+=o,this}clamp(o,t){return this.x=Math.max(this.x,o),this.y=Math.max(this.y,o),t!==void 0&&(this.x=Math.min(this.x,t),this.y=Math.min(this.y,t)),this}div(o){return this.x/=o,this.y/=o,this}divV(o){return this.x/=o.x,this.y/=o.y,this}mul(o){return this.x*=o,this.y*=o,this}mulV(o){return this.x*=o.x,this.y*=o.y,this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this}nudge(o,t){const e=k.Tan(o,this);return this.add(e.mul(t))}neg(){return this.x*=-1,this.y*=-1,this}cross(o){return this.x=this.y*o.z-this.z*o.y,this.y=this.z*o.x-this.x*o.z,this}dpr(o){return k.Dpr(this,o)}cpr(o){return k.Cpr(this,o)}len2(){return k.Len2(this)}len(){return k.Len(this)}pry(o){return k.Pry(this,o)}per(){const{x:o,y:t}=this;return this.x=t,this.y=-o,this}uni(){return k.Uni(this)}tan(o){return k.Tan(this,o)}dist(o){return k.Dist(this,o)}distanceToLineSegment(o,t){return k.DistanceToLineSegment(o,t,this)}slope(o){return k.Slope(this,o)}snapToGrid(o){return this.x=Math.round(this.x/o)*o,this.y=Math.round(this.y/o)*o,this}angle(o){return k.Angle(this,o)}toAngle(){return k.ToAngle(this)}lrp(o,t){return this.x=this.x+(o.x-this.x)*t,this.y=this.y+(o.y-this.y)*t,this}equals(o,t){return k.Equals(this,o,t)}equalsXY(o,t){return k.EqualsXY(this,o,t)}norm(){const o=this.len();return this.x=o===0?0:this.x/o,this.y=o===0?0:this.y/o,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(o,t){return new k(o.x+t.x,o.y+t.y)}static AddXY(o,t,e){return new k(o.x+t,o.y+e)}static Sub(o,t){return new k(o.x-t.x,o.y-t.y)}static SubXY(o,t,e){return new k(o.x-t,o.y-e)}static AddScalar(o,t){return new k(o.x+t,o.y+t)}static SubScalar(o,t){return new k(o.x-t,o.y-t)}static Div(o,t){return new k(o.x/t,o.y/t)}static Mul(o,t){return new k(o.x*t,o.y*t)}static DivV(o,t){return new k(o.x/t.x,o.y/t.y)}static MulV(o,t){return new k(o.x*t.x,o.y*t.y)}static Neg(o){return new k(-o.x,-o.y)}static Per(o){return new k(o.y,-o.x)}static Dist2(o,t){return k.Sub(o,t).len2()}static Abs(o){return new k(Math.abs(o.x),Math.abs(o.y))}static Dist(o,t){return Math.hypot(o.y-t.y,o.x-t.x)}static Dpr(o,t){return o.x*t.x+o.y*t.y}static Cross(o,t){return new k(o.y*t.z-o.z*t.y,o.z*t.x-o.x*t.z)}static Cpr(o,t){return o.x*t.y-t.x*o.y}static Len2(o){return o.x*o.x+o.y*o.y}static Len(o){return Math.hypot(o.x,o.y)}static Pry(o,t){return k.Dpr(o,t)/k.Len(t)}static Uni(o){return k.Div(o,k.Len(o))}static Tan(o,t){return k.Uni(k.Sub(o,t))}static Min(o,t){return new k(Math.min(o.x,t.x),Math.min(o.y,t.y))}static Max(o,t){return new k(Math.max(o.x,t.x),Math.max(o.y,t.y))}static From(o){return new k().add(o)}static FromArray(o){return new k(o[0],o[1])}static Rot(o,t=0){const e=Math.sin(t),s=Math.cos(t);return new k(o.x*s-o.y*e,o.x*e+o.y*s)}static RotWith(o,t,e){const s=o.x-t.x,i=o.y-t.y,n=Math.sin(e),a=Math.cos(e);return new k(t.x+(s*a-i*n),t.y+(s*n+i*a))}static NearestPointOnLineThroughPoint(o,t,e){return k.Mul(t,k.Sub(e,o).pry(t)).add(o)}static NearestPointOnLineSegment(o,t,e,s=!0){const i=k.Tan(t,o),n=k.Add(o,k.Mul(i,k.Sub(e,o).pry(i)));if(s){if(n.x<Math.min(o.x,t.x))return k.Cast(o.x<t.x?o:t);if(n.x>Math.max(o.x,t.x))return k.Cast(o.x>t.x?o:t);if(n.y<Math.min(o.y,t.y))return k.Cast(o.y<t.y?o:t);if(n.y>Math.max(o.y,t.y))return k.Cast(o.y>t.y?o:t)}return n}static DistanceToLineThroughPoint(o,t,e){return k.Dist(e,k.NearestPointOnLineThroughPoint(o,t,e))}static DistanceToLineSegment(o,t,e,s=!0){return k.Dist(e,k.NearestPointOnLineSegment(o,t,e,s))}static Snap(o,t=1){return new k(Math.round(o.x/t)*t,Math.round(o.y/t)*t)}static Cast(o){return o instanceof k?o:k.From(o)}static Slope(o,t){return o.x===t.y?NaN:(o.y-t.y)/(o.x-t.x)}static Angle(o,t){return Math.atan2(t.y-o.y,t.x-o.x)}static Lrp(o,t,e){return k.Sub(t,o).mul(e).add(o)}static Med(o,t){return new k((o.x+t.x)/2,(o.y+t.y)/2)}static Equals(o,t,e=1e-4){return Math.abs(o.x-t.x)<e&&Math.abs(o.y-t.y)<e}static EqualsXY(o,t,e){return o.x===t&&o.y===e}static EqualsXYZ(o,t,e=1e-4){return k.Equals(o,t,e)&&Math.abs((o.z||0)-(t.z||0))<e}static Clockwise(o,t,e){return(e.x-o.x)*(t.y-o.y)-(t.x-o.x)*(e.y-o.y)<0}static Rescale(o,t){const e=k.Len(o);return new k(t*o.x/e,t*o.y/e)}static ScaleWithOrigin(o,t,e){return k.Sub(o,e).mul(t).add(e)}static ScaleWOrigin(o,t,e){return k.Sub(o,e).mulV(t).add(e)}static ToFixed(o,t=2){return new k(+o.x.toFixed(t),+o.y.toFixed(t),+o.z.toFixed(t))}static Nudge(o,t,e){return k.Add(o,k.Tan(t,o).mul(e))}static ToString(o){return`${o.x}, ${o.y}`}static ToAngle(o){let t=Math.atan2(o.y,o.x);return t<0&&(t+=Math.PI*2),t}static FromAngle(o,t=1){return new k(Math.cos(o)*t,Math.sin(o)*t)}static ToArray(o){return[o.x,o.y,o.z]}static ToJson(o){const{x:t,y:e,z:s}=o;return{x:t,y:e,z:s}}static Average(o){const t=o.length,e=new k(0,0);for(let s=0;s<t;s++)e.add(o[s]);return e.div(t)}static Clamp(o,t,e){return e===void 0?new k(Math.min(Math.max(o.x,t)),Math.min(Math.max(o.y,t))):new k(Math.min(Math.max(o.x,t),e),Math.min(Math.max(o.y,t),e))}static PointsBetween(o,t,e=6){const s=[];for(let i=0;i<e;i++){const n=Ri.easeInQuad(i/(e-1)),a=k.Lrp(o,t,n);a.z=Math.min(1,.5+Math.abs(.5-Yi(n))*.65),s.push(a)}return s}static SnapToGrid(o,t=8){return new k(Math.round(o.x/t)*t,Math.round(o.y/t)*t)}}const Yi=r=>r<.5?2*r*r:-1+(4-2*r)*r;class B extends k{constructor(o=0,t=0,e=0,s={x:0,y:0},i=0,n=0){super(o,t,e),this.x=o,this.y=t,this.z=e,this.v=s,this.t=i,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(o){this.a=o}setT(o){this.t=o}setv(o){return this.v={x:o.x,y:o.y},this}set(o=this.x,t=this.y,e=this.z,s=this.v,i=this.t,n=this.a){return this.x=o,this.y=t,this.z=e,this.v=s,this.t=i,this.a=n,this}clone(){const{x:o,y:t,z:e,v:s,t:i,a:n}=this,a={x:s.x,y:s.y};return new B(o,t,e,a,i,n)}distance(o){return B.GetDistance(this,o)}isNear(o,t){return B.IsNear(this,o,t)}getAngleByPoints(o,t){return B.GetAngleByPoints(o,this,t)}static Sub(o,t){return new B(o.x-t.x,o.y-t.y)}static Add(o,t){return new B(o.x+t.x,o.y+t.y)}static GetDistance(o,t){return B.Len(o.clone().sub(t))}static GetAngleByPoints(o,t,e){const s=t.x-o.x,i=e.x-t.x,n=t.y-o.y,a=e.y-t.y;let c=0;const l=Math.sqrt(s*s+n*n),h=Math.sqrt(i*i+a*a);if(l&&h){const u=s*i+n*a;c=Math.acos(u/(l*h)),c=c/Math.PI*180;let d=s*a-n*i;d=d>0?1:-1,c=180+d*c}return c}static IsNear(o,t,e){return B.Len(o.clone().sub(t))<e}static RotWith(o,t,e,s=2){const i=o.x-t.x,n=o.y-t.y,a=Math.sin(e),c=Math.cos(e),l=Math.pow(10,s),h=Math.floor((t.x+(i*c-n*a))*l)/l,u=Math.floor((t.y+(i*a+n*c))*l)/l;return new B(h,u)}static GetDotStroke(o,t,e=16){const s=new k(1,1),i=Math.PI+.001,n=B.Add(o,B.Sub(o,s).uni().per().mul(-t)),a=[];for(let c=1/e,l=c;l<=1;l+=c)a.push(B.RotWith(n,o,i*2*l));return a}static GetSemicircleStroke(o,t,e=-1,s=8){const i=e*(Math.PI+.001),n=[];for(let a=1/s,c=a;c<=1;c+=a)n.push(B.RotWith(t,o,i*c));return n}}var Ae=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ye(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Wi=typeof Ae=="object"&&Ae&&Ae.Object===Object&&Ae,Es=Wi,Ui=Es,Bi=typeof self=="object"&&self&&self.Object===Object&&self,Fi=Ui||Bi||Function("return this")(),Yt=Fi,Hi=Yt,Qi=Hi.Symbol,to=Qi,Qo=to,Os=Object.prototype,Vi=Os.hasOwnProperty,$i=Os.toString,Ce=Qo?Qo.toStringTag:void 0;function Gi(r){var o=Vi.call(r,Ce),t=r[Ce];try{r[Ce]=void 0;var e=!0}catch{}var s=$i.call(r);return e&&(o?r[Ce]=t:delete r[Ce]),s}var Zi=Gi,qi=Object.prototype,Ji=qi.toString;function Xi(r){return Ji.call(r)}var Ki=Xi,Vo=to,_i=Zi,tn=Ki,en="[object Null]",on="[object Undefined]",$o=Vo?Vo.toStringTag:void 0;function sn(r){return r==null?r===void 0?on:en:$o&&$o in Object(r)?_i(r):tn(r)}var se=sn;function nn(r){return r!=null&&typeof r=="object"}var Qt=nn,rn=se,an=Qt,cn="[object Number]";function ln(r){return typeof r=="number"||an(r)&&rn(r)==cn}var hn=ln;const Ut=ye(hn);function un(){this.__data__=[],this.size=0}var dn=un;function pn(r,o){return r===o||r!==r&&o!==o}var Po=pn,fn=Po;function gn(r,o){for(var t=r.length;t--;)if(fn(r[t][0],o))return t;return-1}var eo=gn,Mn=eo,yn=Array.prototype,mn=yn.splice;function wn(r){var o=this.__data__,t=Mn(o,r);if(t<0)return!1;var e=o.length-1;return t==e?o.pop():mn.call(o,t,1),--this.size,!0}var In=wn,vn=eo;function Nn(r){var o=this.__data__,t=vn(o,r);return t<0?void 0:o[t][1]}var Tn=Nn,Sn=eo;function Cn(r){return Sn(this.__data__,r)>-1}var kn=Cn,xn=eo;function zn(r,o){var t=this.__data__,e=xn(t,r);return e<0?(++this.size,t.push([r,o])):t[e][1]=o,this}var bn=zn,Ln=dn,Pn=In,jn=Tn,Dn=kn,An=bn;function me(r){var o=-1,t=r==null?0:r.length;for(this.clear();++o<t;){var e=r[o];this.set(e[0],e[1])}}me.prototype.clear=Ln;me.prototype.delete=Pn;me.prototype.get=jn;me.prototype.has=Dn;me.prototype.set=An;var oo=me,En=oo;function On(){this.__data__=new En,this.size=0}var Rn=On;function Yn(r){var o=this.__data__,t=o.delete(r);return this.size=o.size,t}var Wn=Yn;function Un(r){return this.__data__.get(r)}var Bn=Un;function Fn(r){return this.__data__.has(r)}var Hn=Fn;function Qn(r){var o=typeof r;return r!=null&&(o=="object"||o=="function")}var Jt=Qn,Vn=se,$n=Jt,Gn="[object AsyncFunction]",Zn="[object Function]",qn="[object GeneratorFunction]",Jn="[object Proxy]";function Xn(r){if(!$n(r))return!1;var o=Vn(r);return o==Zn||o==qn||o==Gn||o==Jn}var Rs=Xn,Kn=Yt,_n=Kn["__core-js_shared__"],tr=_n,po=tr,Go=function(){var r=/[^.]+$/.exec(po&&po.keys&&po.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function er(r){return!!Go&&Go in r}var or=er,sr=Function.prototype,ir=sr.toString;function nr(r){if(r!=null){try{return ir.call(r)}catch{}try{return r+""}catch{}}return""}var Ys=nr,rr=Rs,ar=or,cr=Jt,lr=Ys,hr=/[\\^$.*+?()[\]{}|]/g,ur=/^\[object .+?Constructor\]$/,dr=Function.prototype,pr=Object.prototype,fr=dr.toString,gr=pr.hasOwnProperty,Mr=RegExp("^"+fr.call(gr).replace(hr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function yr(r){if(!cr(r)||ar(r))return!1;var o=rr(r)?Mr:ur;return o.test(lr(r))}var mr=yr;function wr(r,o){return r==null?void 0:r[o]}var Ir=wr,vr=mr,Nr=Ir;function Tr(r,o){var t=Nr(r,o);return vr(t)?t:void 0}var ie=Tr,Sr=ie,Cr=Yt,kr=Sr(Cr,"Map"),jo=kr,xr=ie,zr=xr(Object,"create"),so=zr,Zo=so;function br(){this.__data__=Zo?Zo(null):{},this.size=0}var Lr=br;function Pr(r){var o=this.has(r)&&delete this.__data__[r];return this.size-=o?1:0,o}var jr=Pr,Dr=so,Ar="__lodash_hash_undefined__",Er=Object.prototype,Or=Er.hasOwnProperty;function Rr(r){var o=this.__data__;if(Dr){var t=o[r];return t===Ar?void 0:t}return Or.call(o,r)?o[r]:void 0}var Yr=Rr,Wr=so,Ur=Object.prototype,Br=Ur.hasOwnProperty;function Fr(r){var o=this.__data__;return Wr?o[r]!==void 0:Br.call(o,r)}var Hr=Fr,Qr=so,Vr="__lodash_hash_undefined__";function $r(r,o){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=Qr&&o===void 0?Vr:o,this}var Gr=$r,Zr=Lr,qr=jr,Jr=Yr,Xr=Hr,Kr=Gr;function we(r){var o=-1,t=r==null?0:r.length;for(this.clear();++o<t;){var e=r[o];this.set(e[0],e[1])}}we.prototype.clear=Zr;we.prototype.delete=qr;we.prototype.get=Jr;we.prototype.has=Xr;we.prototype.set=Kr;var _r=we,qo=_r,ta=oo,ea=jo;function oa(){this.size=0,this.__data__={hash:new qo,map:new(ea||ta),string:new qo}}var sa=oa;function ia(r){var o=typeof r;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?r!=="__proto__":r===null}var na=ia,ra=na;function aa(r,o){var t=r.__data__;return ra(o)?t[typeof o=="string"?"string":"hash"]:t.map}var io=aa,ca=io;function la(r){var o=ca(this,r).delete(r);return this.size-=o?1:0,o}var ha=la,ua=io;function da(r){return ua(this,r).get(r)}var pa=da,fa=io;function ga(r){return fa(this,r).has(r)}var Ma=ga,ya=io;function ma(r,o){var t=ya(this,r),e=t.size;return t.set(r,o),this.size+=t.size==e?0:1,this}var wa=ma,Ia=sa,va=ha,Na=pa,Ta=Ma,Sa=wa;function Ie(r){var o=-1,t=r==null?0:r.length;for(this.clear();++o<t;){var e=r[o];this.set(e[0],e[1])}}Ie.prototype.clear=Ia;Ie.prototype.delete=va;Ie.prototype.get=Na;Ie.prototype.has=Ta;Ie.prototype.set=Sa;var Ws=Ie,Ca=oo,ka=jo,xa=Ws,za=200;function ba(r,o){var t=this.__data__;if(t instanceof Ca){var e=t.__data__;if(!ka||e.length<za-1)return e.push([r,o]),this.size=++t.size,this;t=this.__data__=new xa(e)}return t.set(r,o),this.size=t.size,this}var La=ba,Pa=oo,ja=Rn,Da=Wn,Aa=Bn,Ea=Hn,Oa=La;function ve(r){var o=this.__data__=new Pa(r);this.size=o.size}ve.prototype.clear=ja;ve.prototype.delete=Da;ve.prototype.get=Aa;ve.prototype.has=Ea;ve.prototype.set=Oa;var Us=ve;function Ra(r,o){for(var t=-1,e=r==null?0:r.length;++t<e&&o(r[t],t,r)!==!1;);return r}var Ya=Ra,Wa=ie,Ua=function(){try{var r=Wa(Object,"defineProperty");return r({},"",{}),r}catch{}}(),Ba=Ua,Jo=Ba;function Fa(r,o,t){o=="__proto__"&&Jo?Jo(r,o,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[o]=t}var Bs=Fa,Ha=Bs,Qa=Po,Va=Object.prototype,$a=Va.hasOwnProperty;function Ga(r,o,t){var e=r[o];(!($a.call(r,o)&&Qa(e,t))||t===void 0&&!(o in r))&&Ha(r,o,t)}var Fs=Ga,Za=Fs,qa=Bs;function Ja(r,o,t,e){var s=!t;t||(t={});for(var i=-1,n=o.length;++i<n;){var a=o[i],c=e?e(t[a],r[a],a,t,r):void 0;c===void 0&&(c=r[a]),s?qa(t,a,c):Za(t,a,c)}return t}var no=Ja;function Xa(r,o){for(var t=-1,e=Array(r);++t<r;)e[t]=o(t);return e}var Ka=Xa,_a=se,tc=Qt,ec="[object Arguments]";function oc(r){return tc(r)&&_a(r)==ec}var sc=oc,Xo=sc,ic=Qt,Hs=Object.prototype,nc=Hs.hasOwnProperty,rc=Hs.propertyIsEnumerable,ac=Xo(function(){return arguments}())?Xo:function(r){return ic(r)&&nc.call(r,"callee")&&!rc.call(r,"callee")},cc=ac,lc=Array.isArray,ro=lc,Be={exports:{}};function hc(){return!1}var uc=hc;Be.exports;(function(r,o){var t=Yt,e=uc,s=o&&!o.nodeType&&o,i=s&&!0&&r&&!r.nodeType&&r,n=i&&i.exports===s,a=n?t.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||e;r.exports=l})(Be,Be.exports);var Do=Be.exports,dc=9007199254740991,pc=/^(?:0|[1-9]\d*)$/;function fc(r,o){var t=typeof r;return o=o??dc,!!o&&(t=="number"||t!="symbol"&&pc.test(r))&&r>-1&&r%1==0&&r<o}var gc=fc,Mc=9007199254740991;function yc(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=Mc}var Qs=yc,mc=se,wc=Qs,Ic=Qt,vc="[object Arguments]",Nc="[object Array]",Tc="[object Boolean]",Sc="[object Date]",Cc="[object Error]",kc="[object Function]",xc="[object Map]",zc="[object Number]",bc="[object Object]",Lc="[object RegExp]",Pc="[object Set]",jc="[object String]",Dc="[object WeakMap]",Ac="[object ArrayBuffer]",Ec="[object DataView]",Oc="[object Float32Array]",Rc="[object Float64Array]",Yc="[object Int8Array]",Wc="[object Int16Array]",Uc="[object Int32Array]",Bc="[object Uint8Array]",Fc="[object Uint8ClampedArray]",Hc="[object Uint16Array]",Qc="[object Uint32Array]",ft={};ft[Oc]=ft[Rc]=ft[Yc]=ft[Wc]=ft[Uc]=ft[Bc]=ft[Fc]=ft[Hc]=ft[Qc]=!0;ft[vc]=ft[Nc]=ft[Ac]=ft[Tc]=ft[Ec]=ft[Sc]=ft[Cc]=ft[kc]=ft[xc]=ft[zc]=ft[bc]=ft[Lc]=ft[Pc]=ft[jc]=ft[Dc]=!1;function Vc(r){return Ic(r)&&wc(r.length)&&!!ft[mc(r)]}var $c=Vc;function Gc(r){return function(o){return r(o)}}var Ao=Gc,Fe={exports:{}};Fe.exports;(function(r,o){var t=Es,e=o&&!o.nodeType&&o,s=e&&!0&&r&&!r.nodeType&&r,i=s&&s.exports===e,n=i&&t.process,a=function(){try{var c=s&&s.require&&s.require("util").types;return c||n&&n.binding&&n.binding("util")}catch{}}();r.exports=a})(Fe,Fe.exports);var Eo=Fe.exports,Zc=$c,qc=Ao,Ko=Eo,_o=Ko&&Ko.isTypedArray,Jc=_o?qc(_o):Zc,Vs=Jc,Xc=Ka,Kc=cc,_c=ro,tl=Do,el=gc,ol=Vs,sl=Object.prototype,il=sl.hasOwnProperty;function nl(r,o){var t=_c(r),e=!t&&Kc(r),s=!t&&!e&&tl(r),i=!t&&!e&&!s&&ol(r),n=t||e||s||i,a=n?Xc(r.length,String):[],c=a.length;for(var l in r)(o||il.call(r,l))&&!(n&&(l=="length"||s&&(l=="offset"||l=="parent")||i&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||el(l,c)))&&a.push(l);return a}var $s=nl,rl=Object.prototype;function al(r){var o=r&&r.constructor,t=typeof o=="function"&&o.prototype||rl;return r===t}var Oo=al;function cl(r,o){return function(t){return r(o(t))}}var Gs=cl,ll=Gs,hl=ll(Object.keys,Object),ul=hl,dl=Oo,pl=ul,fl=Object.prototype,gl=fl.hasOwnProperty;function Ml(r){if(!dl(r))return pl(r);var o=[];for(var t in Object(r))gl.call(r,t)&&t!="constructor"&&o.push(t);return o}var yl=Ml,ml=Rs,wl=Qs;function Il(r){return r!=null&&wl(r.length)&&!ml(r)}var Zs=Il,vl=$s,Nl=yl,Tl=Zs;function Sl(r){return Tl(r)?vl(r):Nl(r)}var Ro=Sl,Cl=no,kl=Ro;function xl(r,o){return r&&Cl(o,kl(o),r)}var zl=xl;function bl(r){var o=[];if(r!=null)for(var t in Object(r))o.push(t);return o}var Ll=bl,Pl=Jt,jl=Oo,Dl=Ll,Al=Object.prototype,El=Al.hasOwnProperty;function Ol(r){if(!Pl(r))return Dl(r);var o=jl(r),t=[];for(var e in r)e=="constructor"&&(o||!El.call(r,e))||t.push(e);return t}var Rl=Ol,Yl=$s,Wl=Rl,Ul=Zs;function Bl(r){return Ul(r)?Yl(r,!0):Wl(r)}var Yo=Bl,Fl=no,Hl=Yo;function Ql(r,o){return r&&Fl(o,Hl(o),r)}var Vl=Ql,He={exports:{}};He.exports;(function(r,o){var t=Yt,e=o&&!o.nodeType&&o,s=e&&!0&&r&&!r.nodeType&&r,i=s&&s.exports===e,n=i?t.Buffer:void 0,a=n?n.allocUnsafe:void 0;function c(l,h){if(h)return l.slice();var u=l.length,d=a?a(u):new l.constructor(u);return l.copy(d),d}r.exports=c})(He,He.exports);var $l=He.exports;function Gl(r,o){var t=-1,e=r.length;for(o||(o=Array(e));++t<e;)o[t]=r[t];return o}var Zl=Gl;function ql(r,o){for(var t=-1,e=r==null?0:r.length,s=0,i=[];++t<e;){var n=r[t];o(n,t,r)&&(i[s++]=n)}return i}var Jl=ql;function Xl(){return[]}var qs=Xl,Kl=Jl,_l=qs,th=Object.prototype,eh=th.propertyIsEnumerable,ts=Object.getOwnPropertySymbols,oh=ts?function(r){return r==null?[]:(r=Object(r),Kl(ts(r),function(o){return eh.call(r,o)}))}:_l,Wo=oh,sh=no,ih=Wo;function nh(r,o){return sh(r,ih(r),o)}var rh=nh;function ah(r,o){for(var t=-1,e=o.length,s=r.length;++t<e;)r[s+t]=o[t];return r}var Js=ah,ch=Gs,lh=ch(Object.getPrototypeOf,Object),Xs=lh,hh=Js,uh=Xs,dh=Wo,ph=qs,fh=Object.getOwnPropertySymbols,gh=fh?function(r){for(var o=[];r;)hh(o,dh(r)),r=uh(r);return o}:ph,Ks=gh,Mh=no,yh=Ks;function mh(r,o){return Mh(r,yh(r),o)}var wh=mh,Ih=Js,vh=ro;function Nh(r,o,t){var e=o(r);return vh(r)?e:Ih(e,t(r))}var _s=Nh,Th=_s,Sh=Wo,Ch=Ro;function kh(r){return Th(r,Ch,Sh)}var ti=kh,xh=_s,zh=Ks,bh=Yo;function Lh(r){return xh(r,bh,zh)}var Ph=Lh,jh=ie,Dh=Yt,Ah=jh(Dh,"DataView"),Eh=Ah,Oh=ie,Rh=Yt,Yh=Oh(Rh,"Promise"),Wh=Yh,Uh=ie,Bh=Yt,Fh=Uh(Bh,"Set"),Hh=Fh,Qh=ie,Vh=Yt,$h=Qh(Vh,"WeakMap"),Gh=$h,mo=Eh,wo=jo,Io=Wh,vo=Hh,No=Gh,ei=se,Ne=Ys,es="[object Map]",Zh="[object Object]",os="[object Promise]",ss="[object Set]",is="[object WeakMap]",ns="[object DataView]",qh=Ne(mo),Jh=Ne(wo),Xh=Ne(Io),Kh=Ne(vo),_h=Ne(No),Kt=ei;(mo&&Kt(new mo(new ArrayBuffer(1)))!=ns||wo&&Kt(new wo)!=es||Io&&Kt(Io.resolve())!=os||vo&&Kt(new vo)!=ss||No&&Kt(new No)!=is)&&(Kt=function(r){var o=ei(r),t=o==Zh?r.constructor:void 0,e=t?Ne(t):"";if(e)switch(e){case qh:return ns;case Jh:return es;case Xh:return os;case Kh:return ss;case _h:return is}return o});var ao=Kt,tu=Object.prototype,eu=tu.hasOwnProperty;function ou(r){var o=r.length,t=new r.constructor(o);return o&&typeof r[0]=="string"&&eu.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var su=ou,iu=Yt,nu=iu.Uint8Array,oi=nu,rs=oi;function ru(r){var o=new r.constructor(r.byteLength);return new rs(o).set(new rs(r)),o}var Uo=ru,au=Uo;function cu(r,o){var t=o?au(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var lu=cu,hu=/\w*$/;function uu(r){var o=new r.constructor(r.source,hu.exec(r));return o.lastIndex=r.lastIndex,o}var du=uu,as=to,cs=as?as.prototype:void 0,ls=cs?cs.valueOf:void 0;function pu(r){return ls?Object(ls.call(r)):{}}var fu=pu,gu=Uo;function Mu(r,o){var t=o?gu(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.length)}var yu=Mu,mu=Uo,wu=lu,Iu=du,vu=fu,Nu=yu,Tu="[object Boolean]",Su="[object Date]",Cu="[object Map]",ku="[object Number]",xu="[object RegExp]",zu="[object Set]",bu="[object String]",Lu="[object Symbol]",Pu="[object ArrayBuffer]",ju="[object DataView]",Du="[object Float32Array]",Au="[object Float64Array]",Eu="[object Int8Array]",Ou="[object Int16Array]",Ru="[object Int32Array]",Yu="[object Uint8Array]",Wu="[object Uint8ClampedArray]",Uu="[object Uint16Array]",Bu="[object Uint32Array]";function Fu(r,o,t){var e=r.constructor;switch(o){case Pu:return mu(r);case Tu:case Su:return new e(+r);case ju:return wu(r,t);case Du:case Au:case Eu:case Ou:case Ru:case Yu:case Wu:case Uu:case Bu:return Nu(r,t);case Cu:return new e;case ku:case bu:return new e(r);case xu:return Iu(r);case zu:return new e;case Lu:return vu(r)}}var Hu=Fu,Qu=Jt,hs=Object.create,Vu=function(){function r(){}return function(o){if(!Qu(o))return{};if(hs)return hs(o);r.prototype=o;var t=new r;return r.prototype=void 0,t}}(),$u=Vu,Gu=$u,Zu=Xs,qu=Oo;function Ju(r){return typeof r.constructor=="function"&&!qu(r)?Gu(Zu(r)):{}}var Xu=Ju,Ku=ao,_u=Qt,td="[object Map]";function ed(r){return _u(r)&&Ku(r)==td}var od=ed,sd=od,id=Ao,us=Eo,ds=us&&us.isMap,nd=ds?id(ds):sd,rd=nd,ad=ao,cd=Qt,ld="[object Set]";function hd(r){return cd(r)&&ad(r)==ld}var ud=hd,dd=ud,pd=Ao,ps=Eo,fs=ps&&ps.isSet,fd=fs?pd(fs):dd,si=fd;const gd=ye(si);var Md=Us,yd=Ya,md=Fs,wd=zl,Id=Vl,vd=$l,Nd=Zl,Td=rh,Sd=wh,Cd=ti,kd=Ph,xd=ao,zd=su,bd=Hu,Ld=Xu,Pd=ro,jd=Do,Dd=rd,Ad=Jt,Ed=si,Od=Ro,Rd=Yo,Yd=1,Wd=2,Ud=4,ii="[object Arguments]",Bd="[object Array]",Fd="[object Boolean]",Hd="[object Date]",Qd="[object Error]",ni="[object Function]",Vd="[object GeneratorFunction]",$d="[object Map]",Gd="[object Number]",ri="[object Object]",Zd="[object RegExp]",qd="[object Set]",Jd="[object String]",Xd="[object Symbol]",Kd="[object WeakMap]",_d="[object ArrayBuffer]",tp="[object DataView]",ep="[object Float32Array]",op="[object Float64Array]",sp="[object Int8Array]",ip="[object Int16Array]",np="[object Int32Array]",rp="[object Uint8Array]",ap="[object Uint8ClampedArray]",cp="[object Uint16Array]",lp="[object Uint32Array]",pt={};pt[ii]=pt[Bd]=pt[_d]=pt[tp]=pt[Fd]=pt[Hd]=pt[ep]=pt[op]=pt[sp]=pt[ip]=pt[np]=pt[$d]=pt[Gd]=pt[ri]=pt[Zd]=pt[qd]=pt[Jd]=pt[Xd]=pt[rp]=pt[ap]=pt[cp]=pt[lp]=!0;pt[Qd]=pt[ni]=pt[Kd]=!1;function We(r,o,t,e,s,i){var n,a=o&Yd,c=o&Wd,l=o&Ud;if(t&&(n=s?t(r,e,s,i):t(r)),n!==void 0)return n;if(!Ad(r))return r;var h=Pd(r);if(h){if(n=zd(r),!a)return Nd(r,n)}else{var u=xd(r),d=u==ni||u==Vd;if(jd(r))return vd(r,a);if(u==ri||u==ii||d&&!s){if(n=c||d?{}:Ld(r),!a)return c?Sd(r,Id(n,r)):Td(r,wd(n,r))}else{if(!pt[u])return s?r:{};n=bd(r,u,a)}}i||(i=new Md);var p=i.get(r);if(p)return p;i.set(r,n),Ed(r)?r.forEach(function(y){n.add(We(y,o,t,y,r,i))}):Dd(r)&&r.forEach(function(y,v){n.set(v,We(y,o,t,v,r,i))});var f=l?c?kd:Cd:c?Rd:Od,I=h?void 0:f(r);return yd(I||r,function(y,v){I&&(v=y,y=r[v]),md(n,v,We(y,o,t,v,r,i))}),n}var hp=We,up=hp,dp=1,pp=4;function fp(r){return up(r,dp|pp)}var gp=fp;const Vt=ye(gp),ai="1.1.1-beta.0",Mp="@netless/appliance-plugin",ci=typeof OffscreenCanvas=="function"?"worker":"mainThread";if(typeof window<"u"){let r=window.__netlessUA||"";r+=` ${Mp}@${ai}_${ci}`,window.__netlessUA=r}const xt={syncOpt:{interval:500},canvasOpt:{contextType:_e.Canvas2d},cdn:{subWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/subWorker.js",fullWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/fullWorker.js"},cursor:{expirationTime:5e3},bufferSize:{full:2e4,sub:1e3},bezier:{combineUnitTime:100},pencilEraser:{useBitMap:!0}};function Zt(r,o=!0){const t=r.length;if(t<2)return"";let e=r[0],s=r[1];if(t===2)return`M${ne(e)}L${ne(s)}`;let i="";for(let n=2,a=t-1;n<a;n++)e=r[n],s=r[n+1],i+=re(e,s);return o?`M${re(r[0],r[1])}Q${ne(r[1])}${re(r[1],r[2])}T${i}${re(r[t-1],r[0])}${re(r[0],r[1])}Z`:`M${ne(r[0])}Q${ne(r[1])}${re(r[1],r[2])}${r.length>3?"T":""}${i}L${ne(r[t-1])}`}const kt=class kt{constructor(o){M(this,"syncUnitTime",xt.syncOpt.interval);M(this,"vNodes");M(this,"drawLayer");M(this,"fullLayer");M(this,"workId");const{vNodes:t,fullLayer:e,drawLayer:s,workId:i,toolsOpt:n}=o;this.vNodes=t,this.fullLayer=e,this.drawLayer=s,this.workId=i,this.syncUnitTime=n.syncUnitTime||this.syncUnitTime}get baseConsumeResult(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions}}filterSamePoints(o,t=.01){return o.reduce((e,s)=>{const i=e[e.length-1];return(s&&!i||s&&i&&!s.isNear(i,t))&&e.push(s),e},[])}setWorkId(o){this.workId=o}getWorkId(){return this.workId}getWorkOptions(){return this.workOptions}setWorkOptions(o){var s,i,n;this.workOptions=o,this.syncUnitTime=o.syncUnitTime||this.syncUnitTime;const t=(s=this.workId)==null?void 0:s.toString(),e=t&&((i=this.vNodes)==null?void 0:i.get(t))||void 0;t&&e&&(e.opt=o,(n=this.vNodes)==null||n.setInfo(t,e))}updataOptService(o){var s,i;let t;const e=(s=this.workId)==null?void 0:s.toString();if(e&&o){const n=this.fullLayer.getElementsByName(e)||this.drawLayer&&this.drawLayer.getElementsByName(e)||[];if(n.length!==1)return;const a=n[0],{pos:c,zIndex:l,scale:h,angle:u,translate:d}=o,p={};Ut(l)&&(p.zIndex=l),c&&(p.pos=[c[0],c[1]]),h&&(p.scale=h),u&&(p.rotate=u),d&&(p.translate=d),a.attr(p);const f=a==null?void 0:a.getBoundingClientRect();return f&&(t=ut(t,{x:Math.floor(f.x-kt.SafeBorderPadding),y:Math.floor(f.y-kt.SafeBorderPadding),w:Math.floor(f.width+kt.SafeBorderPadding*2),h:Math.floor(f.height+kt.SafeBorderPadding*2)})),(i=this.vNodes)==null||i.setInfo(e,{rect:t,centerPos:c}),t}}drawEraserlines(o){const{group:t,eraserlines:e,pos:s,layer:i,isClear:n=!0}=o,a=!!i.parent.gl;for(const c of e){const{thickness:l,op:h}=c;for(const u of h){const d=u.map((v,m)=>m%2?v-s[1]:v-s[0]),p=this.computEraserPoints(d,l),f=Zt(p,!0),I={pos:[0,0],d:f,fillColor:"rgba(0,0,0,1)"},y=new lt.Path(I);n&&(y.addEventListener("beforerender",({detail:v})=>{const m=v.context;a?m.blendFuncSeparate(m.ZERO,m.ZERO,m.ZERO,m.ZERO):m.globalCompositeOperation="destination-out"}),y.addEventListener("afterrender",({detail:v})=>{const m=v.context;a?m.blendFuncSeparate(m.SRC_ALPHA,m.ONE_MINUS_SRC_ALPHA,m.ONE,m.ONE_MINUS_SRC_ALPHA):m.globalCompositeOperation="source-over"})),t.append(y)}}}computEraserPoints(o,t){const e=Math.ceil(t/2);return o.length===2?this.computDot(o,e):this.computLine(o,e)}computDot(o,t){const e=new B(o[0],o[1]);return B.GetDotStroke(e,t,8)}computLine(o,t){const e=[],s=[];let i,n;for(let a=0;a<o.length;a+=2){const c=new B(o[a],o[a+1]);let l;if(a==o.length-2){const h=new B(o[a-2],o[a-1]);l=k.Sub(c,h).uni(),i=c}else{a===0&&(n=c);const h=new B(o[a+2],o[a+3]);l=k.Sub(h,c).uni()}if(l){const h=k.Per(l).mul(t);e.push(B.Sub(c,h)),s.push(B.Add(c,h))}}if(i&&n){const a=B.GetSemicircleStroke(i,e[e.length-1],-1,8),c=B.GetSemicircleStroke(n,s[0],-1,8);return e.concat(a,s.reverse(),c)}return[]}replace(o,t,e){var a;const s=o.getElementsByName(t),i=s.length;if(i){if(i>1)for(let c=1;c<s.length;c++)o.removeChild(s[c]),s[c].disconnect();e?o.replaceChild(e,s[0]):o.removeChild(s[0]),s[0].disconnect()}else e&&o.append(e);this.fullLayer===o?(a=this.drawLayer)==null||a.getElementsByName(t).forEach(c=>{var l;(l=this.drawLayer)==null||l.removeChild(c),c.disconnect()}):this.fullLayer.getElementsByName(t).forEach(c=>{this.fullLayer.removeChild(c),c.disconnect()})}static updateNodeOpt(o){var m;const{node:t,opt:e,vNodes:s,willSerializeData:i,targetNode:n}=o,{zIndex:a,translate:c,angle:l,originPoint:h,scenePoint:u,scale:d,pointMap:p,thickness:f}=e;let I;const y=n&&Vt(n)||s.get(t.name);if(!y)return;Ut(a)&&(t.setAttribute("zIndex",a),y.opt.zIndex=a);const v=t.parent;if(v){if(h&&d&&n){const w=[y.op[0],y.op[1]];Bo(y.op,u,d,c);const N=[y.op[0],y.op[1]],S=[N[0]-w[0],N[1]-w[1]];if(y.centerPos=[y.centerPos[0]+S[0],y.centerPos[1]+S[1]],y.opt.translate=void 0,y.opt.scale=void 0,y.opt.eraserlines)for(const T of Object.values(y.opt.eraserlines)){const{op:x,thickness:b}=T;T.thickness=b*Math.max(d[0],d[1]);for(let A=0;A<x.length;A++)Fo(x[A],u,d,c)}}else if(c)if(t.setAttribute("translate",c),y.opt.translate=c,n){const w=[c[0]*v.worldScaling[0],c[1]*v.worldScaling[1]];I=To(y.rect,w),y.rect=I}else{const w=kt.getRectFromLayer(v,t.name);y.rect=w||y.rect}else if(Ut(l))if(t.setAttribute("rotate",l),y.opt.rotate=l,n)I=Si(y.rect,l),y.rect=I;else{const w=kt.getRectFromLayer(v,t.name);y.rect=w||y.rect}if(p){const w=p.get(t.name);if(w)for(let N=0,S=0;N<y.op.length;N+=3,S++)y.op[N]=w[S][0],y.op[N+1]=w[S][1]}if(f&&((m=y==null?void 0:y.opt)!=null&&m.thickness)&&(y.opt.thickness=f),i&&!(h&&d&&n)){if(c){const w=y.op.map((N,S)=>{const T=S%3;return T===0?N+c[0]:T===1?N+c[1]:N});if(y.op=w,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(const N of Object.values(y.opt.eraserlines)){const{op:S}=N;for(let T=0;T<S.length;T++){const x=S[T].map((b,A)=>A%2?b+c[1]:b+c[0]);N.op[T]=x}}}else if(Ut(l)){const w=y.op;if(Pf(w,y.centerPos,l),y.op=w,y!=null&&y.opt&&(y.opt.rotate=void 0),y.opt.eraserlines)for(const N of Object.values(y.opt.eraserlines)){const{op:S}=N;for(let T=0;T<S.length;T++)jf(S[T],y.centerPos,l)}}}y&&s.setInfo(t.name,y)}}static getCenterPos(o,t){const{worldPosition:e,worldScaling:s}=t;return[(o.x+o.w/2-e[0])/s[0],(o.y+o.h/2-e[1])/s[1]]}static getRectFromLayer(o,t){const e=o.getElementsByName(t)[0];if(e){const s=e.getBoundingClientRect();return{x:Math.floor(s.x-kt.SafeBorderPadding),y:Math.floor(s.y-kt.SafeBorderPadding),w:Math.floor(s.width+kt.SafeBorderPadding*2),h:Math.floor(s.height+kt.SafeBorderPadding*2)}}}};M(kt,"SafeBorderPadding",10);let Y=kt;function Te(r){return JSON.parse(Ps.decompress(r))}function zt(r){return Ps.compress(JSON.stringify(r))}const St=Object.keys;class li extends Y{constructor(t){super(t);M(this,"canRotate",!0);M(this,"scaleType",ct.all);M(this,"toolsType",C.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=t.toolsOpt,this.uniThickness=this.MAX_REPEAR/this.workOptions.thickness/10,this.syncTimestamp=0}combineConsume(){var a;const t=(a=this.workId)==null?void 0:a.toString();if(this.tmpPoints.length<2)return{type:z.None};const e=this.transformDataAll(!0),s={name:t};let i;const n=this.drawLayer||this.fullLayer;return e.length&&(i=this.draw({attrs:s,tasks:e,replaceId:t,layer:n})),{rect:i,type:z.DrawWork,dataType:F.Local}}setWorkOptions(t){super.setWorkOptions(t),this.syncTimestamp=Date.now()}consume(t){const{data:e,isFullWork:s,isSubWorker:i,isMainThread:n,drawCount:a,replaceId:c}=t,{workId:l}=e,{tasks:h,effects:u,consumeIndex:d}=this.transformData(e,!1);this.syncIndex=Math.min(this.syncIndex,d,Math.max(0,this.tmpPoints.length-2));const p={name:l,id:a==null?void 0:a.toString()};let f,I=!1;const y=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),h.length&&(h[0].taskId-this.syncTimestamp>this.syncUnitTime&&(I=!0,this.syncTimestamp=h[0].taskId,this.syncIndex=this.tmpPoints.length),i||n)){const m=s?this.fullLayer:this.drawLayer||this.fullLayer;f=this.draw({attrs:p,tasks:h,effects:u,layer:m,replaceId:c})}if(i)return d>10&&this.tmpPoints.splice(0,d-10),{rect:f,type:z.DrawWork,dataType:F.Local};const v=[];return this.tmpPoints.slice(y).forEach(m=>{v.push(m.x,m.y,this.computRadius(m.z,this.workOptions.thickness))}),{...this.baseConsumeResult,type:z.DrawWork,dataType:F.Local,rect:f,op:I?v:void 0,index:I?y*3:void 0,updateNodeOpt:{useAnimation:!0}}}consumeAll(t){var h;const e=this.workId;if(t.data){const{op:u,workState:d}=t.data;u!=null&&u.length&&d===L.Done&&this.workOptions.strokeType===X.Stroke&&this.updateTempPointsWithPressureWhenDone(u)}const s=this.transformDataAll(!0),i={name:e};let n;const a=this.fullLayer;if(s.length&&(n=this.draw({attrs:i,tasks:s,replaceId:e,layer:a})),this.tmpPoints.length<2)return this.replace(a,e),{type:z.RemoveNode,removeIds:[e],rect:n};const c=[];this.tmpPoints.map(u=>{c.push(u.x,u.y,u.z)}),this.syncTimestamp=0,delete this.workOptions.syncUnitTime;const l=zt(c);return(h=this.vNodes)==null||h.setInfo(e,{rect:n,op:c,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&Y.getCenterPos(n,a)}),{...this.baseConsumeResult,rect:n,type:z.FullWork,dataType:F.Local,ops:l,updateNodeOpt:{pos:this.centerPos,useAnimation:!0}}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(t){var h,u;const{op:e,isFullWork:s,replaceId:i}=t;this.tmpPoints.length=0;for(let d=0;d<e.length;d+=3){const p=new B(e[d],e[d+1],e[d+2]);if(this.tmpPoints.length>0){const f=this.tmpPoints[this.tmpPoints.length-1],I=k.Sub(p,f).uni();p.setv(I)}this.tmpPoints.push(p)}if(this.tmpPoints.length<2)return;const n=this.transformDataAll(!0),a=(h=this.workId)==null?void 0:h.toString(),c={name:a};let l;if(a&&n.length){const d=s?this.fullLayer:this.drawLayer||this.fullLayer;l=this.draw({attrs:c,tasks:n,replaceId:i,layer:d}),(u=this.vNodes)==null||u.setInfo(a,{rect:l,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:l&&Y.getCenterPos(l,d)})}return l}transformDataAll(t=!0){const e=this.filterSamePoints(this.tmpPoints,this.workOptions.thickness);return this.getTaskPoints(e,t&&this.workOptions.thickness||void 0)}draw(t){const{attrs:e,tasks:s,replaceId:i,effects:n,layer:a}=t,{strokeColor:c,strokeType:l,thickness:h,zIndex:u,scale:d,rotate:p,translate:f,eraserlines:I}=this.workOptions;n!=null&&n.size&&(n.forEach(S=>{var T;(T=a.getElementById(S+""))==null||T.remove()}),n.clear());let y;const v=[],m=a.worldPosition,w=a.worldScaling;for(let S=0;S<s.length;S++){const{pos:T,points:x}=s[S],{ps:b,rect:A}=this.computDrawPoints(x);let O;const j=x.length===1;l===X.Stroke||j?O=Zt(b,!0):O=Zt(b,!1);const E={pos:T,d:O,fillColor:l===X.Stroke||j?c:void 0,lineDash:l===X.Dotted&&!j?[1,h*2]:l===X.LongDotted&&!j?[h,h*2]:void 0,strokeColor:c,lineCap:l===X.Stroke||j?void 0:"round",lineWidth:l===X.Stroke||j?0:h};y=ut(y,{x:Math.floor((A.x+T[0])*w[0]+m[0]-Y.SafeBorderPadding),y:Math.floor((A.y+T[1])*w[1]+m[1]-Y.SafeBorderPadding),w:Math.floor(A.w*w[0]+2*Y.SafeBorderPadding),h:Math.floor(A.h*w[1]+2*Y.SafeBorderPadding)}),v.push(E)}d&&(e.scale=d),p&&(e.rotate=p),f&&(e.translate=f);const N=new lt.Group;if(y){this.centerPos=Y.getCenterPos(y,a);const S=l===X.Stroke&&!I;N.attr({...e,normalize:!0,anchor:[.5,.5],bgcolor:S?c:void 0,pos:this.centerPos,size:[(y.w-2*Y.SafeBorderPadding)/w[0],(y.h-2*Y.SafeBorderPadding)/w[1]],zIndex:u});const T=v.map(x=>(x.pos=[x.pos[0]-this.centerPos[0],x.pos[1]-this.centerPos[1]],new lt.Path(x)));N.append(...T),S&&N.seal(),I&&this.drawEraserlines({group:N,eraserlines:I,pos:this.centerPos,layer:a}),this.replace(a,i||e.workId,N)}if(d||p||f){const S=N==null?void 0:N.getBoundingClientRect();if(S)return{x:Math.floor(S.x-Y.SafeBorderPadding),y:Math.floor(S.y-Y.SafeBorderPadding),w:Math.floor(S.width+Y.SafeBorderPadding*2),h:Math.floor(S.height+Y.SafeBorderPadding*2)}}return y}computDrawPoints(t){return this.workOptions.strokeType===X.Stroke||t.length===1?this.computStroke(t):this.computNomal(t)}computNomal(t){let e=this.workOptions.thickness;const s=t.map(i=>(e=Math.max(e,i.radius),i.point));return{ps:s,rect:dt(s,e)}}computStroke(t){return t.length===1?this.computDotStroke(t[0]):this.computLineStroke(t)}computLineStroke(t){const e=[],s=[];for(let l=0;l<t.length;l++){const{point:h,radius:u}=t[l];let d=h.v;l===0&&t.length>1&&(d=t[l+1].point.v);const p=k.Per(d).mul(u);e.push(B.Sub(h,p)),s.push(B.Add(h,p))}const i=t[t.length-1],n=B.GetSemicircleStroke(i.point,e[e.length-1],-1,8),a=B.GetSemicircleStroke(t[0].point,s[0],-1,8),c=e.concat(n,s.reverse(),a);return{ps:c,rect:dt(c)}}computDotStroke(t){const{point:e,radius:s}=t,i={x:e.x-s,y:e.y-s,w:s*2,h:s*2};return{ps:B.GetDotStroke(e,s,8),rect:i}}transformData(t,e){const{op:s,workState:i}=t;let n=this.tmpPoints.length-1,a=[];if(s!=null&&s.length&&i){const{strokeType:c,thickness:l}=this.workOptions,h=new Set;n=c===X.Stroke?this.updateTempPointsWithPressure(s,l,h):this.updateTempPoints(s,l,h);const u=e?this.tmpPoints:this.tmpPoints.slice(n);return a=this.getTaskPoints(u,l),{tasks:a,effects:h,consumeIndex:n}}return{tasks:a,consumeIndex:n}}computRadius(t,e){return t*.03*e+e*.5}getMinZ(t,e){return((e||Math.max(1,Math.floor(t*.3)))-t*.5)*100/t/3}getTaskPoints(t,e){var u;const s=[];if(t.length===0)return[];let i=0,n=t[0].x,a=t[0].y,c=[n,a],l=[],h=t[0].t;for(;i<t.length;){const d=t[i],p=d.x-n,f=d.y-a,I=d.z,y=e?this.computRadius(I,e):I;if(l.push({point:new B(p,f,I,t[i].v),radius:y}),i>0&&i<t.length-1){const v=t[i].getAngleByPoints(t[i-1],t[i+1]);if(v<90||v>270){const m=(u=l.pop())==null?void 0:u.point.clone();m&&s.push({taskId:h,pos:c,points:[...l,{point:m,radius:y}]}),n=t[i].x,a=t[i].y,c=[n,a];const w=d.x-n,N=d.y-a;l=[{point:new B(w,N,I),radius:y}],h=Date.now()}}i++}return s.push({taskId:h,pos:c,points:l}),s}updateTempPointsWithPressure(t,e,s){const i=Date.now(),n=this.tmpPoints.length;let a=n;for(let l=0;l<t.length;l+=2){a=Math.min(a,n);const h=this.tmpPoints.length,u=new B(t[l],t[l+1]);if(h===0){this.tmpPoints.push(u);continue}const d=h-1,p=this.tmpPoints[d],f=k.Sub(u,p).uni();if(u.isNear(p,e)){if(p.z<this.MAX_REPEAR){if(p.setz(Math.min(p.z+1,this.MAX_REPEAR)),a=Math.min(a,d),h>1){let v=h-1;for(;v>0;){const m=this.tmpPoints[v].distance(this.tmpPoints[v-1]),w=Math.max(this.tmpPoints[v].z-this.uniThickness*m,0);if(this.tmpPoints[v-1].z>=w)break;this.tmpPoints[v-1].setz(w),a=Math.min(a,v-1),v--}}}else a=1/0;continue}u.setv(f);const I=u.distance(p),y=Math.max(p.z-this.uniThickness*I,0);h>1&&k.Equals(f,p.v,.02)&&(y>0||p.z<=0)&&(s&&p.t&&s.add(p.t),this.tmpPoints.pop(),a=Math.min(d,a)),u.setz(y),this.tmpPoints.push(u)}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&&(s==null||s.add(l))}else{let l=n-1;for(c=a;l>=0;){const h=this.tmpPoints[l].t;if(h&&(s==null||s.add(h),l<=a)){c=l,l=-1;break}l--}}return this.tmpPoints[c].setT(i),c}updateTempPoints(t,e,s){var l;const i=Date.now(),n=this.tmpPoints.length;let a=n;for(let h=0;h<t.length;h+=2){const u=this.tmpPoints.length,d=new B(t[h],t[h+1]);if(u===0){this.tmpPoints.push(d);continue}const p=u-1,f=this.tmpPoints[p],I=k.Sub(d,f).uni();if(d.isNear(f,e/2)){a=Math.min(p,a);continue}k.Equals(I,f.v,.02)&&(s&&f.t&&s.add(f.t),this.tmpPoints.pop(),a=Math.min(p,a)),d.setv(I),this.tmpPoints.push(d)}let c=n;if(a===n){c=Math.max(c-1,0);const h=this.tmpPoints[c].t;h&&(s==null||s.add(h))}else{let h=Math.min(n-1,a);for(c=a;h>=0;){const u=(l=this.tmpPoints[h])==null?void 0:l.t;if(u&&(s==null||s.add(u),h<=a)){c=h,h=-1;break}h--}}return this.tmpPoints[c].setT(i),c}updateTempPointsWithPressureWhenDone(t){const{thickness:e}=this.workOptions,s=t.length,i=this.getMinZ(e);for(let n=0;n<s;n+=2){const a=this.tmpPoints.length,c=new B(t[n],t[n+1]);if(a===0){this.tmpPoints.push(c);continue}const l=a-1,h=this.tmpPoints[l],u=k.Sub(c,h).uni(),d=c.distance(h);if(a>1&&h.z===i)break;if(c.isNear(h,e/2)){if(s<3&&h.z<this.MAX_REPEAR&&(h.setz(Math.min(h.z+1,this.MAX_REPEAR)),a>1)){let f=a-1;for(;f>0;){const I=this.tmpPoints[f].distance(this.tmpPoints[f-1]),y=Math.max(this.tmpPoints[f].z-this.uniThickness*I,-e/4);if(this.tmpPoints[f-1].z>=y)break;this.tmpPoints[f-1].setz(y),f--}}continue}c.setv(u);const p=Math.max(h.z-this.uniThickness*d,i);a>1&&k.Equals(u,h.v,.02)&&h.z<=0&&this.tmpPoints.pop(),c.setz(p),this.tmpPoints.push(c)}}static updateNodeOpt(t){var l,h;const{node:e,opt:s,vNodes:i}=t,{strokeColor:n,strokeType:a}=s,c=i.get(e.name);return n&&(e.tagName==="GROUP"?Af(e)?e.setAttribute("bgcolor",n):e.children.forEach(u=>{u.setAttribute("strokeColor",n),u.getAttribute("fillColor")&&u.setAttribute("fillColor",n)}):(e.setAttribute("strokeColor",n),e.setAttribute("fillColor",n)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=n)),a&&(c!=null&&c.opt)&&((h=c.opt)!=null&&h.strokeType)&&(c.opt.strokeType=a),c&&i.setInfo(e.name,c),Y.updateNodeOpt(t)}}class hi extends Y{constructor(t){super(t);M(this,"toolsType",C.LaserPen);M(this,"canRotate",!1);M(this,"scaleType",ct.none);M(this,"syncTimestamp");M(this,"syncIndex",0);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"consumeIndex",0);this.workOptions=t.toolsOpt,this.syncTimestamp=0}combineConsume(){}setWorkOptions(t){super.setWorkOptions(t),this.syncTimestamp=Date.now()}consume(t){const{data:e,isSubWorker:s}=t,{workId:i,op:n}=e;if((n==null?void 0:n.length)===0)return{type:z.None};if(this.updateTempPoints(n||[]),this.consumeIndex>this.tmpPoints.length-4)return{type:z.None};const{strokeColor:a,thickness:c,strokeType:l}=this.workOptions,h=dt(this.tmpPoints,c);let u=!1;const d=this.syncIndex,p=this.tmpPoints.slice(this.consumeIndex);this.consumeIndex=this.tmpPoints.length-1,this.syncTimestamp===0&&(this.syncTimestamp=Date.now());const f={name:i==null?void 0:i.toString(),opacity:1,lineDash:l===X.Dotted?[1,c*2]:l===X.LongDotted?[c,c*2]:void 0,strokeColor:a,lineCap:"round",lineWidth:c,anchor:[.5,.5]},I=this.getTaskPoints(p);if(I.length){const v=Date.now();v-this.syncTimestamp>this.syncUnitTime&&(u=!0,this.syncTimestamp=v,this.syncIndex=this.tmpPoints.length),s&&this.draw({attrs:f,tasks:I,isDot:!1,layer:this.drawLayer||this.fullLayer})}const y=[];return this.tmpPoints.slice(d).forEach(v=>{y.push(v.x,v.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:z.DrawWork,dataType:F.Local,op:u?y:void 0,index:u?d*2:void 0,...this.baseConsumeResult}}consumeAll(){var n;const t=(n=this.workId)==null?void 0:n.toString();let e;if(this.tmpPoints.length-1>this.consumeIndex){let a=this.tmpPoints.slice(this.consumeIndex);const c=a.length===1,{strokeColor:l,thickness:h,strokeType:u}=this.workOptions;if(c){const f=this.computDotStroke({point:a[0],radius:h/2});a=f.ps,e=f.rect}else e=dt(this.tmpPoints,h);const d={name:t==null?void 0:t.toString(),fillColor:c?l:void 0,opacity:1,lineDash:u===X.Dotted&&!c?[1,h*2]:u===X.LongDotted&&!c?[h,h*2]:void 0,strokeColor:l,lineCap:c?void 0:"round",lineWidth:c?0:h,anchor:[.5,.5]},p=this.getTaskPoints(a);p.length&&this.draw({attrs:d,tasks:p,isDot:c,layer:this.drawLayer||this.fullLayer})}const s=[];this.tmpPoints.forEach(a=>{s.push(a.x,a.y)});const i=zt(s);return{rect:e&&{x:e.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:e.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:e.w*this.fullLayer.worldScaling[0],h:e.h*this.fullLayer.worldScaling[1]},type:z.FullWork,dataType:F.Local,ops:i,index:this.syncIndex*2,...this.baseConsumeResult}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(t){var I;const{op:e,replaceId:s,isFullWork:i}=t,{strokeColor:n,thickness:a,strokeType:c}=this.workOptions;if(!e.length){const y=dt(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(e||[]);let h,u=this.tmpPoints.slice(l);const d=u.length===1;if(d){const y=this.computDotStroke({point:u[0],radius:a/2});u=y.ps,h=y.rect}else h=dt(this.tmpPoints,a);const p={name:(I=this.workId)==null?void 0:I.toString(),fillColor:d?n:void 0,opacity:1,lineDash:c===X.Dotted&&!d?[1,a*2]:c===X.LongDotted&&!d?[a,a*2]:void 0,strokeColor:n,lineCap:d?void 0:"round",lineWidth:d?0:a,anchor:[.5,.5]},f=this.getTaskPoints(u);if(f.length){const y=i?this.fullLayer:this.drawLayer||this.fullLayer;this.draw({attrs:p,tasks:f,isDot:d,replaceId:s,layer:y})}return{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]}}computDotStroke(t){const{point:e,radius:s}=t,i={x:e.x-s,y:e.y-s,w:s*2,h:s*2};return{ps:B.GetDotStroke(e,s,8),rect:i}}updateTempPoints(t){const e=this.tmpPoints.length;for(let s=0;s<t.length;s+=2){if(e){const i=this.tmpPoints.slice(-1)[0];i&&i.x===t[s]&&i.y===t[s+1]&&this.tmpPoints.pop()}this.tmpPoints.push(new B(t[s],t[s+1]))}}async draw(t){const{attrs:e,tasks:s,isDot:i,layer:n}=t,{duration:a}=this.workOptions;for(const c of s){const l=new lt.Path,{pos:h,points:u}=c;let d;i?d=Zt(u,!0):d=Zt(u,!1),l.attr({...e,pos:h,d});const{vertex:p,fragment:f}=this.workOptions;if(p&&f){const I=n.renderer.createProgram({vertex:p,fragment:f}),{width:y,height:v}=n.getResolution();l.setUniforms({u_time:0,u_resolution:[y,v]}),l.setProgram(I)}n.appendChild(l),l.transition(a).attr({scale:i?[.1,.1]:[1,1],lineWidth:i?0:1}).then(()=>{l.remove()})}}getTaskPoints(t){var l;const e=[];if(t.length===0)return[];let s=0,i=t[0].x,n=t[0].y,a=[i,n],c=[];for(;s<t.length;){const h=t[s],u=h.x-i,d=h.y-n;if(c.push(new B(u,d)),s>0&&s<t.length-1){const p=t[s].getAngleByPoints(t[s-1],t[s+1]);if(p<90||p>270){const f=(l=c.pop())==null?void 0:l.clone();f&&e.push({pos:a,points:[...c,f]}),i=t[s].x,n=t[s].y,a=[i,n];const I=h.x-i,y=h.y-n;c=[new B(I,y)]}}s++}return e.push({pos:a,points:c}),e}removeLocal(){}removeService(t){let e;const s=[];return this.fullLayer.getElementsByName(t).forEach(i=>{if(i.name===t){const n=i.getBoundingClientRect();e=ut(e,{x:n.x,y:n.y,w:n.width,h:n.height}),s.push(i)}}),s.length&&s.forEach(i=>i.remove()),e}}const ue=class ue extends Y{constructor(t,e){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.none);M(this,"toolsType",C.Eraser);M(this,"serviceWork");M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"worldPosition");M(this,"worldScaling");M(this,"eraserRect");M(this,"eraserPolyline");this.serviceWork=e,this.workOptions=t.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}combineConsume(){}consumeService(){}setWorkOptions(t){super.setWorkOptions(t)}createEraserRect(t){const e=t[0]*this.worldScaling[0]+this.worldPosition[0],s=t[1]*this.worldScaling[1]+this.worldPosition[1],{width:i,height:n}=ue.eraserSizes[this.workOptions.thickness];this.eraserRect={x:e-i*.5,y:s-n*.5,w:i,h:n},this.eraserPolyline=[this.eraserRect.x,this.eraserRect.y,this.eraserRect.x+this.eraserRect.w,this.eraserRect.y+this.eraserRect.h]}computRectCenterPoints(){const t=this.tmpPoints.slice(-2);if(this.tmpPoints.length===4){const e=new k(this.tmpPoints[0],this.tmpPoints[1]),s=new k(this.tmpPoints[2],this.tmpPoints[3]),i=k.Sub(s,e).uni(),n=k.Dist(e,s),{width:a,height:c}=ue.eraserSizes[this.workOptions.thickness],l=Math.min(a,c),h=Math.round(n/l);if(h>1){const u=[];for(let d=0;d<h;d++){const p=k.Mul(i,d*l);u.push(this.tmpPoints[0]+p.x,this.tmpPoints[1]+p.y)}return u.concat(t)}}return t}isNear(t,e){const s=new k(t[0],t[1]),i=new k(e[0],e[1]),{width:n,height:a}=ue.eraserSizes[this.workOptions.thickness];return k.Dist(s,i)<Math.hypot(n,a)*.5}remove(t){const{curNodeMap:e,removeIds:s}=t;let i;for(const n of e.values())if(n.rect&&this.eraserRect&&this.eraserPolyline&&Pe(this.eraserRect,n.rect)){const{op:a}=n,c=[],l=[];for(let u=0;u<a.length;u+=3){const d=new k(a[u]*this.worldScaling[0]+this.worldPosition[0],a[u+1]*this.worldScaling[1]+this.worldPosition[1],a[u+2]);l.push(d),c.push(new B(d.x,d.y))}const h=c.length&&dt(c)||n.rect;Pe(h,this.eraserRect)&&(l.length>1?bo.polyline(l.map(d=>d.XY),this.eraserPolyline).length&&s.add(n.name):s.add(n.name),i=ut(i,h))}return s.forEach(n=>{var c;const a=this.fullLayer.getElementsByName(n);this.fullLayer.removeChild(a[0]),(c=this.vNodes)==null||c.delete(n)}),i&&(i.x-=Y.SafeBorderPadding,i.y-=Y.SafeBorderPadding,i.w+=Y.SafeBorderPadding*2,i.h+=Y.SafeBorderPadding*2),i}consume(t){const{op:e}=t.data;if(!e||e.length===0)return{type:z.None,...this.baseConsumeResult};const s=this.tmpPoints.length;if(s>1&&this.isNear([e[0],e[1]],[this.tmpPoints[s-2],this.tmpPoints[s-1]]))return{type:z.None,...this.baseConsumeResult};s<3?this.tmpPoints.push(e[0],e[1]):this.tmpPoints.splice(2,2,e[0],e[1]);const i=this.computRectCenterPoints();let n;const a=new Set;if(!this.vNodes)return{type:z.None,...this.baseConsumeResult};const c=this.getCanEraserNodeMap(this.vNodes.getCanEraserNodes(this.vNodes.curNodeMap));for(let l=0;l<i.length-1;l+=2){this.createEraserRect(i.slice(l,l+2));const h=this.remove({curNodeMap:c,removeIds:a});n=ut(n,h)}return n&&a.size?{type:z.RemoveNode,rect:n,removeIds:[...a]}:{type:z.None,...this.baseConsumeResult}}consumeAll(t){return this.consume(t)}clearTmpPoints(){this.tmpPoints.length=0}getCanEraserNodeMap(t){var e;if(this.serviceWork){const s=new Map(t),i=this.serviceWork.selectorWorkShapes,n=this.serviceWork.workShapes;for(const a of i.values())if((e=a.selectIds)!=null&&e.length)for(const c of a.selectIds)s.delete(c);for(const a of n.keys())s.delete(a);return s}return t}};M(ue,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));let Qe=ue;const Rt="++",H="selector",Ue="all";var yp="__lodash_hash_undefined__";function mp(r){return this.__data__.set(r,yp),this}var wp=mp;function Ip(r){return this.__data__.has(r)}var vp=Ip,Np=Ws,Tp=wp,Sp=vp;function Ve(r){var o=-1,t=r==null?0:r.length;for(this.__data__=new Np;++o<t;)this.add(r[o])}Ve.prototype.add=Ve.prototype.push=Tp;Ve.prototype.has=Sp;var Cp=Ve;function kp(r,o){for(var t=-1,e=r==null?0:r.length;++t<e;)if(o(r[t],t,r))return!0;return!1}var xp=kp;function zp(r,o){return r.has(o)}var bp=zp,Lp=Cp,Pp=xp,jp=bp,Dp=1,Ap=2;function Ep(r,o,t,e,s,i){var n=t&Dp,a=r.length,c=o.length;if(a!=c&&!(n&&c>a))return!1;var l=i.get(r),h=i.get(o);if(l&&h)return l==o&&h==r;var u=-1,d=!0,p=t&Ap?new Lp:void 0;for(i.set(r,o),i.set(o,r);++u<a;){var f=r[u],I=o[u];if(e)var y=n?e(I,f,u,o,r,i):e(f,I,u,r,o,i);if(y!==void 0){if(y)continue;d=!1;break}if(p){if(!Pp(o,function(v,m){if(!jp(p,m)&&(f===v||s(f,v,t,e,i)))return p.push(m)})){d=!1;break}}else if(!(f===I||s(f,I,t,e,i))){d=!1;break}}return i.delete(r),i.delete(o),d}var ui=Ep;function Op(r){var o=-1,t=Array(r.size);return r.forEach(function(e,s){t[++o]=[s,e]}),t}var Rp=Op;function Yp(r){var o=-1,t=Array(r.size);return r.forEach(function(e){t[++o]=e}),t}var Wp=Yp,gs=to,Ms=oi,Up=Po,Bp=ui,Fp=Rp,Hp=Wp,Qp=1,Vp=2,$p="[object Boolean]",Gp="[object Date]",Zp="[object Error]",qp="[object Map]",Jp="[object Number]",Xp="[object RegExp]",Kp="[object Set]",_p="[object String]",tf="[object Symbol]",ef="[object ArrayBuffer]",of="[object DataView]",ys=gs?gs.prototype:void 0,fo=ys?ys.valueOf:void 0;function sf(r,o,t,e,s,i,n){switch(t){case of:if(r.byteLength!=o.byteLength||r.byteOffset!=o.byteOffset)return!1;r=r.buffer,o=o.buffer;case ef:return!(r.byteLength!=o.byteLength||!i(new Ms(r),new Ms(o)));case $p:case Gp:case Jp:return Up(+r,+o);case Zp:return r.name==o.name&&r.message==o.message;case Xp:case _p:return r==o+"";case qp:var a=Fp;case Kp:var c=e&Qp;if(a||(a=Hp),r.size!=o.size&&!c)return!1;var l=n.get(r);if(l)return l==o;e|=Vp,n.set(r,o);var h=Bp(a(r),a(o),e,s,i,n);return n.delete(r),h;case tf:if(fo)return fo.call(r)==fo.call(o)}return!1}var nf=sf,ms=ti,rf=1,af=Object.prototype,cf=af.hasOwnProperty;function lf(r,o,t,e,s,i){var n=t&rf,a=ms(r),c=a.length,l=ms(o),h=l.length;if(c!=h&&!n)return!1;for(var u=c;u--;){var d=a[u];if(!(n?d in o:cf.call(o,d)))return!1}var p=i.get(r),f=i.get(o);if(p&&f)return p==o&&f==r;var I=!0;i.set(r,o),i.set(o,r);for(var y=n;++u<c;){d=a[u];var v=r[d],m=o[d];if(e)var w=n?e(m,v,d,o,r,i):e(v,m,d,r,o,i);if(!(w===void 0?v===m||s(v,m,t,e,i):w)){I=!1;break}y||(y=d=="constructor")}if(I&&!y){var N=r.constructor,S=o.constructor;N!=S&&"constructor"in r&&"constructor"in o&&!(typeof N=="function"&&N instanceof N&&typeof S=="function"&&S instanceof S)&&(I=!1)}return i.delete(r),i.delete(o),I}var hf=lf,go=Us,uf=ui,df=nf,pf=hf,ws=ao,Is=ro,vs=Do,ff=Vs,gf=1,Ns="[object Arguments]",Ts="[object Array]",Ee="[object Object]",Mf=Object.prototype,Ss=Mf.hasOwnProperty;function yf(r,o,t,e,s,i){var n=Is(r),a=Is(o),c=n?Ts:ws(r),l=a?Ts:ws(o);c=c==Ns?Ee:c,l=l==Ns?Ee:l;var h=c==Ee,u=l==Ee,d=c==l;if(d&&vs(r)){if(!vs(o))return!1;n=!0,h=!1}if(d&&!h)return i||(i=new go),n||ff(r)?uf(r,o,t,e,s,i):df(r,o,c,t,e,s,i);if(!(t&gf)){var p=h&&Ss.call(r,"__wrapped__"),f=u&&Ss.call(o,"__wrapped__");if(p||f){var I=p?r.value():r,y=f?o.value():o;return i||(i=new go),s(I,y,t,e,i)}}return d?(i||(i=new go),pf(r,o,t,e,s,i)):!1}var mf=yf,wf=mf,Cs=Qt;function di(r,o,t,e,s){return r===o?!0:r==null||o==null||!Cs(r)&&!Cs(o)?r!==r&&o!==o:wf(r,o,t,e,di,s)}var If=di,vf=If;function Nf(r,o){return vf(r,o)}var Tf=Nf;const le=ye(Tf),Ke=class Ke extends Y{constructor(t){super(t);M(this,"toolsType",C.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",ct.all);M(this,"toolsTypes");M(this,"shapeOpt");M(this,"textOpt");M(this,"isLocked");M(this,"thickness");M(this,"strokeType");M(this,"useStroke");this.workOptions=t.toolsOpt,this.vNodes=t.vNodes}computSelector(t=!0){const e=dt(this.tmpPoints);if(e.w===0||e.h===0)return{selectIds:[],intersectRect:void 0,subNodeMap:new Map};const{rectRange:s,nodeRange:i}=this.vNodes.getRectIntersectRange(e,t);return{selectIds:[...i.keys()],intersectRect:s,subNodeMap:i}}updateTempPoints(t){const e=this.tmpPoints.length,s=t.length;if(s>1){const i=new B(t[s-2]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],t[s-1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]);e===2?this.tmpPoints.splice(1,1,i):this.tmpPoints.push(i)}}drawSelector(t){const{drawRect:e,subNodeMap:s,selectorId:i,layer:n,isService:a}=t,c=new lt.Group({pos:[e.x,e.y],anchor:[0,0],size:[e.w,e.h],id:i,name:i,zIndex:9999}),l=[];if(a){const h=new lt.Rect({normalize:!0,pos:[e.w/2,e.h/2],lineWidth:1,strokeColor:this.selectorColor||this.workOptions.strokeColor,width:e.w,height:e.h,name:Ke.selectorBorderId});l.push(h)}s.forEach((h,u)=>{const d=[h.rect.x+h.rect.w/2-e.x,h.rect.y+h.rect.h/2-e.y],p=new lt.Rect({normalize:!0,pos:d,lineWidth:1,strokeColor:s.size>1?this.selectorColor||this.workOptions.strokeColor:void 0,width:h.rect.w,height:h.rect.h,id:`selector-${u}`,name:`selector-${u}`});l.push(p)}),l&&c.append(...l),(n==null?void 0:n.parent).appendChild(c)}draw(t,e,s,i=!1){var c,l;const{intersectRect:n,subNodeMap:a}=s;(l=(c=e.parent)==null?void 0:c.getElementById(t))==null||l.remove(),n&&this.drawSelector({drawRect:n,subNodeMap:a,selectorId:t,layer:e,isService:i})}getSelecteorInfo(t){this.scaleType=ct.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 e=new Set;let s,i=!0;for(const n of t.values()){const{opt:a,canRotate:c,scaleType:l,toolsType:h}=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),h!==C.Pencil&&(i=!1),a.strokeType&&(this.strokeType=a.strokeType),h===C.SpeechBalloon&&(e.add(h),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.placement=a.placement),h===C.Polygon&&(e.add(h),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices),h===C.Star&&(e.add(h),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices,this.shapeOpt.innerRatio=a.innerRatio,this.shapeOpt.innerVerticeStep=a.innerVerticeStep),h===C.Text&&(this.textOpt=a),t.size===1&&(this.textOpt&&(this.canTextEdit=!0),this.canRotate=c,this.scaleType=l),l===ct.none&&(this.scaleType=l),h===C.Image&&(s=n)}i&&(this.useStroke=!0),e.size&&(this.toolsTypes=[...e]),s&&(t.size===1?(this.canLock=!0,s.opt.locked&&(this.isLocked=!0,this.scaleType=ct.none,this.canRotate=!1,this.textOpt=void 0,this.fillColor=void 0,this.selectorColor="rgb(177,177,177)",this.strokeColor=void 0,this.canTextEdit=!1,this.thickness=void 0,this.strokeType=void 0,this.useStroke=void 0)):t.size>1&&!s.opt.locked&&(this.canLock=!1,this.canRotate=!1))}getChildrenPoints(){var t,e;if(this.scaleType===ct.both&&((t=this.selectIds)==null?void 0:t.length)===1){const s=this.selectIds[0],i=(e=this.vNodes.get(s))==null?void 0:e.op;if(i){const n=[];for(let a=0;a<i.length;a+=3)n.push([i[a],i[a+1]]);return n}}}consume(t){const{op:e,workState:s}=t.data;let i=this.oldSelectRect;if(s===L.Start&&(i=this.unSelectedAllIds()),!(e!=null&&e.length)||!this.vNodes.curNodeMap.size)return{type:z.None};this.updateTempPoints(e);const n=this.computSelector();if(this.selectIds&&le(this.selectIds,n.selectIds))return{type:z.None};this.selectIds=n.selectIds;const a=n.intersectRect;this.getSelecteorInfo(n.subNodeMap),this.draw(H,this.fullLayer,n),this.oldSelectRect=a;const c=this.getChildrenPoints();return{type:z.Select,dataType:F.Local,rect:ut(a,i),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 e,s;let t=this.oldSelectRect;if(!((e=this.selectIds)!=null&&e.length)&&this.tmpPoints[0]&&this.selectSingleTool(this.tmpPoints[0].XY,H,!1),(s=this.selectIds)!=null&&s.length&&(t=this.selectedByIds(this.selectIds)),t){const i=this.getChildrenPoints();return{type:z.Select,dataType:F.Local,rect:this.oldSelectRect,selectIds:this.selectIds,selectorColor:this.selectorColor,selectRect:this.oldSelectRect,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:i,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType,...this.baseConsumeResult}}return{type:z.None}}consumeService(){}clearTmpPoints(){this.tmpPoints.length=0}clearSelectData(){this.selectIds=void 0,this.oldSelectRect=void 0}selectSingleTool(t,e=H,s=!1){if(t.length===2){const i=t[0],n=t[1];let a;const{nodeRange:c}=this.vNodes.getRectIntersectRange({x:i,y:n,w:0,h:0},!1),l=[...c.values()].sort((h,u)=>(u.opt.zIndex||0)-(h.opt.zIndex||0));for(const h of l){const u=this.fullLayer.getElementsByName(h.name);if(Ni(u).find(p=>p.isPointCollision(i,n))){a=h;break}}if(a){const h=a.name;if(!le(this.oldSelectRect,a.rect)){const u=new Map([[h,a]]);this.getSelecteorInfo(u),this.draw(e,this.fullLayer,{intersectRect:a.rect,subNodeMap:u,selectIds:this.selectIds||[]},s)}this.selectIds=[h],this.oldSelectRect=a.rect}}}unSelectedAllIds(){let t;for(const[e,s]of this.vNodes.curNodeMap.entries())s.isSelected&&(t=ut(t,s.rect),this.vNodes.unSelected(e));return t}unSelectedByIds(t){let e;for(const s of t){const i=this.vNodes.get(s);i&&i.isSelected&&(e=ut(e,i.rect),this.vNodes.unSelected(s))}return e}selectedByIds(t){let e;for(const s of t){const i=this.vNodes.get(s);i&&(e=ut(e,i.rect),this.vNodes.selected(s))}return e}getSelectorRect(t,e){var a;let s;const i=(a=t.parent)==null?void 0:a.getElementById(e),n=i==null?void 0:i.getBoundingClientRect();return n&&(s=ut(s,{x:Math.floor(n.x),y:Math.floor(n.y),w:Math.floor(n.width+1),h:Math.floor(n.height+1)})),s}isCanFillColor(t){return t===C.Ellipse||t===C.Triangle||t===C.Rectangle||t===C.Polygon||t===C.Star||t===C.SpeechBalloon}async updateSelector(t){var S;const{updateSelectorOpt:e,selectIds:s,vNodes:i,willSerializeData:n,worker:a,offset:c}=t,l=this.fullLayer;if(!l)return;let h;const u=new Map,{originPoint:d,workState:p,angle:f,translate:I,dir:y,scale:v}=e;c&&(I?e.translate=[I[0]+c[0],I[1]+c[1]]:e.translate=c);let m;if(d||I||Ut(f)){if(p===L.Start&&s)return i.setTargetAssignKeys(s),{type:z.Select,dataType:F.Local,selectRect:this.oldSelectRect,rect:this.oldSelectRect};m=i.getLastTarget()}if(s)for(const T of s){const x=i.get(T);if(x){const{toolsType:b}=x,A=(l==null?void 0:l.getElementsByName(T))[0];if(A){let O=!1,j=!1;const E={...e};let D;if(b){E.thickness&&x.opt.thickness&&(O=x.opt.thickness!==E.thickness),E.strokeType&&((S=x.opt)!=null&&S.strokeType)&&(j=x.opt.strokeType!==E.strokeType),D=m==null?void 0:m.get(T);const _=Ii(b);if(_==null||_.updateNodeOpt({node:A,opt:E,vNodes:i,willSerializeData:n,targetNode:D}),x&&a&&(n&&(E.angle||E.translate)||E.originPoint&&E.scenePoint&&E.scale||E.pointMap&&E.pointMap.has(T)||b===C.Text&&(E.fontSize||E.translate||E.textInfos&&E.textInfos.get(T))||b===C.Image&&(E.angle||E.translate||E.scale)||b===E.toolsType&&E.willRefresh||O||j)){const nt=a.createWorkShapeNode({workId:T,toolsType:b,toolsOpt:x.opt});nt==null||nt.setWorkId(T);let tt;if(b===C.Image)tt=await nt.consumeServiceAsync({isFullWork:!0,replaceId:T,worker:a});else if(b===C.Text)tt=await nt.consumeServiceAsync({isFullWork:!0,replaceId:T});else try{tt=nt==null?void 0:nt.consumeService({op:x.op,isFullWork:!0,replaceId:T})}catch{continue}tt&&(x.rect=tt)}x&&(u.set(T,x),h=ut(h,x.rect))}}}}m&&p===L.Done&&(i.deleteLastTarget(),m=void 0);const w=h;if(d&&I&&v&&y&&w&&!c){const T=[[w.x,w.y],[w.x+w.w,w.y],[w.x+w.w,w.y+w.h],[w.x,w.y+w.h]];let x;switch(y){case"top":case"topLeft":case"left":I[0]>0&&I[1]>0?x=T[0]:I[0]>0?x=T[3]:I[1]>0?x=T[1]:x=T[2];break;case"topRight":I[0]<0&&I[1]>0?x=T[1]:I[0]<0?x=T[2]:I[1]>0?x=T[0]:x=T[3];break;case"right":case"bottomRight":case"bottom":I[0]<0&&I[1]<0?x=T[2]:I[0]<0?x=T[1]:I[1]<0?x=T[3]:x=T[0];break;case"bottomLeft":I[0]>0&&I[1]<0?x=T[3]:I[0]>0?x=T[0]:I[1]<0?x=T[2]:x=T[1];break}const b=x&&[d[0]-x[0],d[1]-x[1]]||[0,0];if(!le(b,[0,0]))return await this.updateSelector({...t,updateSelectorOpt:{},offset:b})}this.getSelecteorInfo(u),this.draw(H,l,{selectIds:s||[],subNodeMap:u,intersectRect:w});const N=ut(this.oldSelectRect,w);return this.oldSelectRect=w,{type:z.Select,dataType:F.Local,selectRect:w,renderRect:h,rect:ut(N,w),selectIds:s}}blurSelector(){const t=this.unSelectedAllIds();return{type:z.Select,dataType:F.Local,rect:t,selectIds:[],willSyncService:!0}}getRightServiceId(t){return t.replace(Rt,"-")}selectServiceNode(t,e,s){const{selectIds:i}=e,n=this.getRightServiceId(t),a=this.getSelectorRect(this.fullLayer,n);let c;const l=new Map;return i==null||i.forEach(h=>{const u=this.vNodes.get(h);u&&(c=ut(c,u.rect),l.set(h,u))}),this.getSelecteorInfo(l),this.draw(n,this.fullLayer,{intersectRect:c,selectIds:i||[],subNodeMap:l},s),ut(c,a)}reRenderSelector(){var s;let t;const e=new Map;return(s=this.selectIds)==null||s.forEach(i=>{const n=this.vNodes.get(i);n&&(t=ut(t,n.rect),e.set(i,n))},this),this.getSelecteorInfo(e),this.draw(H,this.fullLayer,{intersectRect:t,subNodeMap:e,selectIds:this.selectIds||[]}),this.oldSelectRect=t,t}updateSelectIds(t){var n;let e;const s=(n=this.selectIds)==null?void 0:n.filter(a=>!t.includes(a));if(s!=null&&s.length&&(e=this.unSelectedByIds(s)),t.length){const a=this.selectedByIds(t);e=ut(e,a)}this.selectIds=t;const i=this.reRenderSelector();return{bgRect:e,selectRect:i}}cursorHover(t){var n,a;const e=this.oldSelectRect;this.selectIds=[];const s=(n=this.workId)==null?void 0:n.toString(),i=[t[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],t[1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]];if(this.selectSingleTool(i,s,!0),this.oldSelectRect&&!le(e,this.oldSelectRect))return{type:z.CursorHover,dataType:F.Local,rect:ut(e,this.oldSelectRect),selectorColor:this.selectorColor,willSyncService:!1};if((a=this.selectIds)!=null&&a.length||(this.oldSelectRect=void 0),e&&!this.oldSelectRect)return this.cursorBlur(),{type:z.CursorHover,dataType:F.Local,rect:e,selectorColor:this.selectorColor,willSyncService:!1}}cursorBlur(){var e,s;this.selectIds=[];const t=(e=this.workId)==null?void 0:e.toString();((s=this.fullLayer)==null?void 0:s.parent).children.forEach(i=>{i.name===t&&i.remove()})}};M(Ke,"selectorBorderId","selector-border");let $e=Ke;class pi extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.both);M(this,"toolsType",C.Arrow);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"arrowTipWidth");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.arrowTipWidth=this.workOptions.thickness*4,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:s,isSubWorker:i,isMainThread:n}=t,a=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:z.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new B(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:z.None};let u;if(i||n){const p=s?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:a,layer:p})}if(!i){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{...this.baseConsumeResult,type:z.DrawWork,dataType:F.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0}):{type:z.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,...this.baseConsumeResult,type:z.DrawWork,dataType:F.Local}}consumeAll(){var a;const t=this.workId;if(this.tmpPoints.length<2)return{type:z.RemoveNode,removeIds:[t]};const e=this.fullLayer,s=this.draw({workId:t,layer:e});this.oldRect=s;const i=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=zt(i);return(a=this.vNodes)==null||a.setInfo(t,{rect:s,op:i,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:Y.getCenterPos(s,e)}),{rect:s,...this.baseConsumeResult,type:z.FullWork,dataType:F.Local,ops:n,isSync:!0}}draw(t){const{workId:e,layer:s}=t,{strokeColor:i,thickness:n,zIndex:a,scale:c,rotate:l,translate:h,strokeType:u,eraserlines:d}=this.workOptions,p=s.worldPosition,f=s.worldScaling,{points:I,pos:y,rect:v,isTriangle:m,trianglePoints:w,trianglePos:N}=this.computDrawPoints(n),S=[v.x+v.w/2,v.y+v.h/2],T={pos:S,name:e,id:e,zIndex:a,anchor:[.5,.5],size:[v.w,v.h]};c&&(T.scale=c),l&&(T.rotate=l),h&&(T.translate=h);const x=new lt.Group(T),b={points:w,pos:[N[0]-S[0],N[1]-S[1]],fillColor:i,strokeColor:i,lineWidth:0,normalize:!1},A=new lt.Polyline(b);if(x.append(A),!m&&I&&y){const O={points:I,pos:[y[0]-S[0],y[1]-S[1]],fillColor:i,strokeColor:i,lineDash:u===X.Dotted&&!m?[1,n*2]:u===X.LongDotted&&!m?[n,n*2]:void 0,lineCap:u===X.Normal?void 0:"round",lineWidth:n,normalize:!1},j=new lt.Polyline(O);x.append(j)}if(d&&this.drawEraserlines({group:x,eraserlines:d,pos:S,layer:s}),this.replace(s,e,x),c||l||h){const O=x.getBoundingClientRect();return{x:Math.floor(O.x-Y.SafeBorderPadding),y:Math.floor(O.y-Y.SafeBorderPadding),w:Math.floor(O.width+Y.SafeBorderPadding*2),h:Math.floor(O.height+Y.SafeBorderPadding*2)}}return{x:Math.floor(v.x*f[0]+p[0]-Y.SafeBorderPadding),y:Math.floor(v.y*f[1]+p[1]-Y.SafeBorderPadding),w:Math.floor(v.w*f[0]+2*Y.SafeBorderPadding),h:Math.floor(v.h*f[1]+2*Y.SafeBorderPadding)}}computDrawPoints(t){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.arrowTipWidth?this.computFullArrowPoints(t):this.computTrianglePoints()}computFullArrowPoints(t){const e=k.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),s=k.Per(e).mul(t/2),i=B.Sub(this.tmpPoints[0],s),n=B.Add(this.tmpPoints[0],s),a=k.Mul(e,this.arrowTipWidth),c=k.Sub(this.tmpPoints[1],a),l=B.Sub(c,s),h=B.Add(c,s),u=k.Per(e).mul(t*1.5),d=B.Sub(c,u),p=B.Add(c,u),f=[this.tmpPoints[0],c],I=[d,this.tmpPoints[1],p],y=[i,n,...I,l,h];return{trianglePoints:I.map(v=>B.Sub(v,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,points:f.map(v=>B.Sub(v,this.tmpPoints[0]).XY).flat(1),rect:dt(y),isTriangle:!1,pos:this.tmpPoints[0].XY}}computTrianglePoints(){const t=k.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),e=this.tmpPoints[1].distance(this.tmpPoints[0]),s=k.Per(t).mul(Math.floor(e*3/8)),i=B.Sub(this.tmpPoints[0],s),n=B.Add(this.tmpPoints[0],s),a=[i,this.tmpPoints[1],n];return{trianglePoints:a.map(c=>B.Sub(c,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,rect:dt(a),isTriangle:!0}}updateTempPoints(t){const e=t.slice(-2),s=new B(e[0],e[1]),i=this.tmpPoints[0],{thickness:n}=this.workOptions;if(i.isNear(s,n))return!1;if(this.tmpPoints.length===2){if(s.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=s}else this.tmpPoints.push(s);return!0}consumeService(t){var c,l;const{op:e,isFullWork:s}=t,i=(c=this.workId)==null?void 0:c.toString();if(!i)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new B(e[h],e[h+1],e[h+2]));const n=s?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:i,layer:n});return this.oldRect=a,(l=this.vNodes)==null||l.setInfo(i,{rect:a,op:e,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:Y.getCenterPos(a,n)}),a}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var l,h;const{node:e,opt:s,vNodes:i}=t,{strokeColor:n,strokeType:a}=s,c=i.get(e.name);return n&&(e.tagName==="GROUP"?e.children.forEach(u=>{u.setAttribute("strokeColor",n),u.getAttribute("fillColor")&&u.setAttribute("fillColor",n)}):(e.setAttribute("strokeColor",n),e.setAttribute("fillColor",n)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=n)),a&&(c!=null&&c.opt)&&((h=c.opt)!=null&&h.strokeType)&&(c.opt.strokeType=a),c&&i.setInfo(e.name,c),Y.updateNodeOpt(t)}}class fi extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.all);M(this,"toolsType",C.Ellipse);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:s,isSubWorker:i,isMainThread:n}=t,a=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:z.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new B(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:z.None};let u;if(i||n){const p=s?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:a,layer:p,isDrawing:!0})}if(!i){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:z.DrawWork,dataType:F.Local,...this.baseConsumeResult,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0}):{type:z.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:z.DrawWork,dataType:F.Local,...this.baseConsumeResult}}consumeAll(){var a;const t=this.workId;if(this.tmpPoints.length<2)return{type:z.RemoveNode,removeIds:[t]};const e=this.fullLayer,s=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=s;const i=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=zt(i);return(a=this.vNodes)==null||a.setInfo(t,{rect:s,op:i,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:s&&Y.getCenterPos(s,e)}),{rect:s,type:z.FullWork,dataType:F.Local,...this.baseConsumeResult,ops:n,isSync:!0}}draw(t){const{workId:e,layer:s,isDrawing:i}=t,{strokeColor:n,fillColor:a,thickness:c,zIndex:l,scale:h,rotate:u,translate:d,strokeType:p,eraserlines:f}=this.workOptions,I=s.worldScaling,{radius:y,rect:v,pos:m}=this.computDrawPoints(c),w={pos:m,name:e,id:e,radius:y,lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:n,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:p===X.Dotted?[1,c*2]:p===X.LongDotted?[c,c*2]:void 0},N={name:e,id:e,zIndex:l,pos:m,anchor:[.5,.5],size:[v.w,v.h]};h&&(N.scale=h),u&&(N.rotate=u),d&&(N.translate=d);const S=new lt.Group(N);if(i){const b=new lt.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:n,lineWidth:1,scale:[1/I[0],1/I[1]]});S.append(b)}const T=new lt.Ellipse({...w,pos:[0,0]});S.append(T),f&&this.drawEraserlines({group:S,eraserlines:f,pos:m,layer:s}),this.replace(s,e,S);const x=S.getBoundingClientRect();return{x:Math.floor(x.x-Y.SafeBorderPadding),y:Math.floor(x.y-Y.SafeBorderPadding),w:Math.floor(x.width+Y.SafeBorderPadding*2),h:Math.floor(x.height+Y.SafeBorderPadding*2)}}computDrawPoints(t){const e=dt(this.tmpPoints),s=dt(this.tmpPoints,t),i=[Math.floor(e.x+e.w/2),Math.floor(e.y+e.h/2)];return{rect:s,pos:i,radius:[Math.floor(e.w/2),Math.floor(e.h/2)]}}updateTempPoints(t){const e=t.slice(-2),s=new B(e[0],e[1]),i=this.tmpPoints[0],{thickness:n}=this.workOptions;if(i.isNear(s,n))return!1;if(this.tmpPoints.length===2){if(s.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=s}else this.tmpPoints.push(s);return!0}consumeService(t){var c,l;const{op:e,isFullWork:s}=t,i=(c=this.workId)==null?void 0:c.toString();if(!i)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new B(e[h],e[h+1],e[h+2]));const n=s?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:i,layer:n,isDrawing:!1});return this.oldRect=a,(l=this.vNodes)==null||l.setInfo(i,{rect:a,op:e,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:Y.getCenterPos(a,n)}),a}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var u,d,p;const{node:e,opt:s,vNodes:i}=t,{strokeColor:n,fillColor:a,strokeType:c}=s,l=i.get(e.name);let h=e;return e.tagName==="GROUP"&&(h=e.children[0]),n&&(h.setAttribute("strokeColor",n),(u=l==null?void 0:l.opt)!=null&&u.strokeColor&&(l.opt.strokeColor=n)),a&&(a==="transparent"?h.setAttribute("fillColor","rgba(0,0,0,0)"):h.setAttribute("fillColor",a),(d=l==null?void 0:l.opt)!=null&&d.fillColor&&(l.opt.fillColor=a)),c&&(l!=null&&l.opt)&&((p=l.opt)!=null&&p.strokeType)&&(l.opt.strokeType=c),l&&i.setInfo(e.name,l),Y.updateNodeOpt(t)}}class gi extends Y{constructor(t){super(t);M(this,"canRotate",!0);M(this,"scaleType",ct.all);M(this,"toolsType",C.Rectangle);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}transformData(){const t=dt(this.tmpPoints);return[[t.x,t.y,0],[t.x+t.w,t.y,0],[t.x+t.w,t.y+t.h,0],[t.x,t.y+t.h,0]]}computDrawPoints(t){const{thickness:e}=this.workOptions,s=[];for(const a of t)s.push(new k(...a));const i=dt(s,e),n=[i.x+i.w/2,i.y+i.h/2];return{rect:i,pos:n,points:s.map(a=>a.XY).flat(1)}}consume(t){const{data:e,isFullWork:s,isSubWorker:i,isMainThread:n}=t,a=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:z.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new B(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:z.None};const u=this.transformData();let d;if(i||n){const f=s?this.fullLayer:this.drawLayer||this.fullLayer;d=this.draw({ps:u,workId:a,layer:f,isDrawing:!0})}if(!i){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:z.DrawWork,dataType:F.Local,op:u.flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:z.None}}const p=ut(d,this.oldRect);return this.oldRect=d,{rect:p,type:z.DrawWork,dataType:F.Local,...this.baseConsumeResult}}consumeAll(){var c;const t=this.workId;if(this.tmpPoints.length<2)return{type:z.RemoveNode,removeIds:[t]};const e=this.transformData(),s=this.fullLayer,i=this.draw({ps:e,workId:t,layer:s,isDrawing:!1});this.oldRect=i;const n=e.flat(1),a=zt(n);return(c=this.vNodes)==null||c.setInfo(t,{rect:i,op:n,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&Y.getCenterPos(i,s)}),{rect:i,type:z.FullWork,dataType:F.Local,ops:a,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:s,isDrawing:i,ps:n,replaceId:a}=t,{strokeColor:c,fillColor:l,thickness:h,zIndex:u,scale:d,rotate:p,translate:f,strokeType:I,eraserlines:y}=this.workOptions,v=s.worldPosition,m=s.worldScaling,{points:w,rect:N,pos:S}=this.computDrawPoints(n),T={close:!0,normalize:!0,points:w,lineWidth:h,fillColor:l!=="transparent"&&l||void 0,strokeColor:c,lineJoin:"round",lineCap:"round",lineDash:I===X.Dotted?[1,h*2]:I===X.LongDotted?[h,h*2]:void 0},x={x:Math.floor(N.x*m[0]+v[0]-Y.SafeBorderPadding),y:Math.floor(N.y*m[1]+v[1]-Y.SafeBorderPadding),w:Math.floor(N.w*m[0]+2*Y.SafeBorderPadding),h:Math.floor(N.h*m[0]+2*Y.SafeBorderPadding)},b=new lt.Group({name:e,id:e,zIndex:u,pos:S,anchor:[.5,.5],size:[N.w,N.h],scale:d,rotate:p,translate:f}),A=new lt.Polyline({...T,pos:[0,0]});if(b.appendChild(A),i){const O=new lt.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:c,lineWidth:1,scale:[1/m[0],1/m[1]]});b.appendChild(O)}if(y&&this.drawEraserlines({group:b,eraserlines:y,pos:S,layer:s}),this.replace(s,a||e,b),d||p||f){const O=b.getBoundingClientRect();return{x:Math.floor(O.x-Y.SafeBorderPadding),y:Math.floor(O.y-Y.SafeBorderPadding),w:Math.floor(O.width+2*Y.SafeBorderPadding),h:Math.floor(O.height+2*Y.SafeBorderPadding)}}return x}updateTempPoints(t){const e=t.slice(-2),s=new B(e[0],e[1]),i=this.tmpPoints[0],{thickness:n}=this.workOptions;if(i.isNear(s,n))return!1;if(this.tmpPoints.length===2){if(s.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=s}else this.tmpPoints.push(s);return!0}consumeService(t){var h,u;const{op:e,isFullWork:s,replaceId:i}=t,n=(h=this.workId)==null?void 0:h.toString();if(!n)return;const a=[];for(let d=0;d<e.length;d+=3)a.push([e[d],e[d+1],e[d+2]]);const c=s?this.fullLayer:this.drawLayer||this.fullLayer,l=this.draw({ps:a,workId:n,layer:c,isDrawing:!1,replaceId:i});return this.oldRect=l,(u=this.vNodes)==null||u.setInfo(n,{rect:l,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:l&&Y.getCenterPos(l,c)}),l}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var u,d,p;const{node:e,opt:s,vNodes:i}=t,{strokeColor:n,fillColor:a,strokeType:c}=s,l=i.get(e.name);let h=e;return e.tagName==="GROUP"&&(h=e.children[0]),n&&(h.setAttribute("strokeColor",n),(u=l==null?void 0:l.opt)!=null&&u.strokeColor&&(l.opt.strokeColor=n)),a&&(a==="transparent"?h.setAttribute("fillColor","rgba(0,0,0,0)"):h.setAttribute("fillColor",a),(d=l==null?void 0:l.opt)!=null&&d.fillColor&&(l.opt.fillColor=a)),c&&(l!=null&&l.opt)&&((p=l.opt)!=null&&p.strokeType)&&(l.opt.strokeType=c),l&&i.setInfo(e.name,l),Y.updateNodeOpt(t)}}class Mi extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.all);M(this,"toolsType",C.Star);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:s,isSubWorker:i,isMainThread:n}=t,a=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:z.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new B(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:z.None};let u;if(i||n){const p=s?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:a,layer:p,isDrawing:!0})}if(!i){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:z.DrawWork,dataType:F.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:z.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:z.DrawWork,dataType:F.Local,...this.baseConsumeResult}}consumeAll(){var a;const t=this.workId;if(this.tmpPoints.length<2)return{type:z.RemoveNode,removeIds:[t]};const e=this.fullLayer,s=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=s;const i=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=zt(i);return(a=this.vNodes)==null||a.setInfo(t,{rect:s,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&Y.getCenterPos(s,e)}),{rect:s,type:z.FullWork,dataType:F.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:s,isDrawing:i}=t,{strokeColor:n,fillColor:a,thickness:c,zIndex:l,vertices:h,innerVerticeStep:u,innerRatio:d,scale:p,rotate:f,translate:I,strokeType:y,eraserlines:v}=this.workOptions,m=s.worldScaling,{rect:w,pos:N,points:S}=this.computDrawPoints(c,h,u,d),T={close:!0,points:S,lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:n,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:y===X.Dotted?[1,c*2]:y===X.LongDotted?[c,c*2]:void 0},x={name:e,id:e,zIndex:l,pos:N,anchor:[.5,.5],size:[w.w,w.h]};p&&(x.scale=p),f&&(x.rotate=f),I&&(x.translate=I);const b=new lt.Group(x);if(i){const j=new lt.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:n,lineWidth:1,scale:[1/m[0],1/m[1]]});b.append(j)}const A=new lt.Polyline({...T,pos:[0,0]});b.append(A),v&&this.drawEraserlines({group:b,eraserlines:v,pos:N,layer:s}),this.replace(s,e,b);const O=b.getBoundingClientRect();return{x:Math.floor(O.x-Y.SafeBorderPadding),y:Math.floor(O.y-Y.SafeBorderPadding),w:Math.floor(O.width+Y.SafeBorderPadding*2),h:Math.floor(O.height+Y.SafeBorderPadding*2)}}computDrawPoints(t,e,s,i){const n=dt(this.tmpPoints),a=[Math.floor(n.x+n.w/2),Math.floor(n.y+n.h/2)],c=ki(n.w,n.h),l=Math.floor(Math.min(n.w,n.h)/2),h=i*l,u=[],d=2*Math.PI/e;for(let f=0;f<e;f++){const I=f*d-.5*Math.PI;let y,v;f%s===1?(y=h*c[0]*Math.cos(I),v=h*c[1]*Math.sin(I)):(y=l*c[0]*Math.cos(I),v=l*c[1]*Math.sin(I),u.push(y,v)),u.push(y,v)}return{rect:dt(this.tmpPoints,t),pos:a,points:u}}updateTempPoints(t){const e=t.slice(-2),s=new B(e[0],e[1]),i=this.tmpPoints[0],{thickness:n}=this.workOptions;if(i.isNear(s,n)||B.Sub(i,s).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(s.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=s}else this.tmpPoints.push(s);return!0}consumeService(t){var c,l;const{op:e,isFullWork:s}=t,i=(c=this.workId)==null?void 0:c.toString();if(!i)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new B(e[h],e[h+1],e[h+2]));const n=s?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:i,layer:n,isDrawing:!1});return this.oldRect=a,(l=this.vNodes)==null||l.setInfo(i,{rect:a,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&Y.getCenterPos(a,n)}),a}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var y;const{node:e,opt:s,vNodes:i}=t,{strokeColor:n,fillColor:a,toolsType:c,vertices:l,innerVerticeStep:h,innerRatio:u,strokeType:d}=s,p=i.get(e.name),f=p==null?void 0:p.opt;let I=e;return e.tagName==="GROUP"&&(I=e.children[0]),n&&(I.setAttribute("strokeColor",n),f!=null&&f.strokeColor&&(f.strokeColor=n)),a&&(a==="transparent"?I.setAttribute("fillColor","rgba(0,0,0,0)"):I.setAttribute("fillColor",a),f!=null&&f.fillColor&&(f.fillColor=a)),c===C.Star&&(l&&(f.vertices=l),h&&(f.innerVerticeStep=h),u&&(f.innerRatio=u)),d&&(p!=null&&p.opt)&&((y=p.opt)!=null&&y.strokeType)&&(p.opt.strokeType=d),p&&i.setInfo(e.name,{...p,opt:f}),Y.updateNodeOpt(t)}}class yi extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.all);M(this,"toolsType",C.Polygon);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:s,isSubWorker:i,isMainThread:n}=t,{op:a}=e,c=this.workId,l=a==null?void 0:a.length;if(!l||l<2)return{type:z.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new B(a[0],a[1])],h=!1):h=this.updateTempPoints(a),!h)return{type:z.None};let u;if(i||n){const p=s?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:c,layer:p,isDrawing:!0})}if(!i){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:z.DrawWork,dataType:F.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:z.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:z.DrawWork,dataType:F.Local,...this.baseConsumeResult}}consumeAll(){var a;const t=this.workId;if(this.tmpPoints.length<2)return{type:z.RemoveNode,removeIds:[t]};const e=this.fullLayer,s=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=s;const i=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=zt(i);return(a=this.vNodes)==null||a.setInfo(t,{rect:s,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&Y.getCenterPos(s,e)}),{rect:s,type:z.FullWork,dataType:F.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:s,isDrawing:i}=t,{strokeColor:n,fillColor:a,thickness:c,zIndex:l,vertices:h,scale:u,rotate:d,translate:p,strokeType:f,eraserlines:I}=this.workOptions,y=s.worldScaling,{rect:v,pos:m,points:w}=this.computDrawPoints(c,h),N={close:!0,points:w,lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:n,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:f===X.Dotted?[1,c*2]:f===X.LongDotted?[c,c*2]:void 0},S={name:e,id:e,zIndex:l,pos:m,anchor:[.5,.5],size:[v.w,v.h]};u&&(S.scale=u),d&&(S.rotate=d),p&&(S.translate=p);const T=new lt.Group(S);if(i){const A=new lt.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:n,lineWidth:1,scale:[1/y[0],1/y[1]]});T.append(A)}const x=new lt.Polyline({...N,pos:[0,0]});T.append(x),I&&this.drawEraserlines({group:T,eraserlines:I,pos:m,layer:s}),this.replace(s,e,T);const b=T.getBoundingClientRect();return{x:Math.floor(b.x-Y.SafeBorderPadding),y:Math.floor(b.y-Y.SafeBorderPadding),w:Math.floor(b.width+Y.SafeBorderPadding*2),h:Math.floor(b.height+Y.SafeBorderPadding*2)}}computDrawPoints(t,e){const s=dt(this.tmpPoints),i=[Math.floor(s.x+s.w/2),Math.floor(s.y+s.h/2)],n=ki(s.w,s.h),a=Math.floor(Math.min(s.w,s.h)/2),c=[],l=2*Math.PI/e;for(let u=0;u<e;u++){const d=u*l-.5*Math.PI,p=a*n[0]*Math.cos(d),f=a*n[1]*Math.sin(d);c.push(p,f)}return{rect:dt(this.tmpPoints,t),pos:i,points:c}}updateTempPoints(t){const e=t.slice(-2),s=new B(e[0],e[1]),i=this.tmpPoints[0],{thickness:n}=this.workOptions;if(i.isNear(s,n)||B.Sub(i,s).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(s.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=s}else this.tmpPoints.push(s);return!0}consumeService(t){var c,l;const{op:e,isFullWork:s}=t,i=(c=this.workId)==null?void 0:c.toString();if(!i)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new B(e[h],e[h+1],e[h+2]));const n=s?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:i,layer:n,isDrawing:!1});return this.oldRect=a,(l=this.vNodes)==null||l.setInfo(i,{rect:a,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&Y.getCenterPos(a,n)}),a}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var f;const{node:e,opt:s,vNodes:i}=t,{strokeColor:n,fillColor:a,toolsType:c,vertices:l,strokeType:h}=s,u=i.get(e.name),d=u==null?void 0:u.opt;let p=e;return e.tagName==="GROUP"&&(p=e.children[0]),n&&(p.setAttribute("strokeColor",n),d!=null&&d.strokeColor&&(d.strokeColor=n)),a&&(a==="transparent"?p.setAttribute("fillColor","rgba(0,0,0,0)"):p.setAttribute("fillColor",a),d!=null&&d.fillColor&&(d.fillColor=a)),c===C.Polygon&&l&&(d.vertices=l),h&&(u!=null&&u.opt)&&((f=u.opt)!=null&&f.strokeType)&&(u.opt.strokeType=h),u&&i.setInfo(e.name,{...u,opt:d}),Y.updateNodeOpt(t)}}class Ot{static bezier(o,t){const e=[];for(let s=0;s<t.length;s+=4){const i=t[s],n=t[s+1],a=t[s+2],c=t[s+3];i&&n&&a&&c?e.push(...Ot.getBezierPoints(o,i,n,a,c)):i&&n&&a?e.push(...Ot.getBezierPoints(o,i,n,a)):i&&n?e.push(...Ot.getBezierPoints(o,i,n)):i&&e.push(i)}return e}static getBezierPoints(o=10,t,e,s,i){let n=null;const a=[];!s&&!i?n=Ot.oneBezier:s&&!i?n=Ot.twoBezier:s&&i&&(n=Ot.threeBezier);for(let c=0;c<o;c++)n&&a.push(n(c/o,t,e,s,i));return i?a.push(i):s&&a.push(s),a}static oneBezier(o,t,e){const s=t.x+(e.x-t.x)*o,i=t.y+(e.y-t.y)*o;return new k(s,i)}static twoBezier(o,t,e,s){const i=(1-o)*(1-o)*t.x+2*o*(1-o)*e.x+o*o*s.x,n=(1-o)*(1-o)*t.y+2*o*(1-o)*e.y+o*o*s.y;return new k(i,n)}static threeBezier(o,t,e,s,i){const n=t.x*(1-o)*(1-o)*(1-o)+3*e.x*o*(1-o)*(1-o)+3*s.x*o*o*(1-o)+i.x*o*o*o,a=t.y*(1-o)*(1-o)*(1-o)+3*e.y*o*(1-o)*(1-o)+3*s.y*o*o*(1-o)+i.y*o*o*o;return new k(n,a)}}class mi extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.all);M(this,"toolsType",C.SpeechBalloon);M(this,"ratio",.8);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){var p;const{data:e,isFullWork:s,isSubWorker:i,isMainThread:n}=t,a=(p=e==null?void 0:e.workId)==null?void 0:p.toString();if(!a)return{type:z.None};const{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:z.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new B(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:z.None};let u;if(i||n){const f=s?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:a,layer:f,isDrawing:!0})}if(!i){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:z.DrawWork,dataType:F.Local,op:this.tmpPoints.map(I=>[...I.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:z.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:z.DrawWork,dataType:F.Local,...this.baseConsumeResult}}consumeAll(){var a;const t=this.workId;if(this.tmpPoints.length<2)return{type:z.RemoveNode,removeIds:[t]};const e=this.fullLayer,s=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=s;const i=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=zt(i);return(a=this.vNodes)==null||a.setInfo(t,{rect:s,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&Y.getCenterPos(s,e)}),{rect:s,type:z.FullWork,dataType:F.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:s}=t,{strokeColor:i,fillColor:n,thickness:a,zIndex:c,placement:l,scale:h,rotate:u,translate:d,strokeType:p,eraserlines:f}=this.workOptions,{rect:I,pos:y,points:v}=this.computDrawPoints(a,l),m={points:v.map(x=>x.XY),lineWidth:a,fillColor:n!=="transparent"&&n||void 0,strokeColor:i,normalize:!0,className:`${y[0]},${y[1]}`,close:!0,lineJoin:"round",lineCap:"round",lineDash:p===X.Dotted?[1,a*2]:p===X.LongDotted?[a,a*2]:void 0},w={name:e,id:e,zIndex:c,pos:y,anchor:[.5,.5],size:[I.w,I.h]};h&&(w.scale=h),u&&(w.rotate=u),d&&(w.translate=d);const N=new lt.Group(w),S=new lt.Polyline({...m,pos:[0,0]});N.append(S),f&&this.drawEraserlines({group:N,eraserlines:f,pos:y,layer:s}),this.replace(s,e,N);const T=N.getBoundingClientRect();return{x:Math.floor(T.x-Y.SafeBorderPadding),y:Math.floor(T.y-Y.SafeBorderPadding),w:Math.floor(T.width+Y.SafeBorderPadding*2),h:Math.floor(T.height+Y.SafeBorderPadding*2)}}transformControlPoints(t){const e=dt(this.tmpPoints);switch(t){case"bottom":case"bottomLeft":case"bottomRight":{const s=e.y+e.h*this.ratio;return[new k(e.x,e.y,0),new k(e.x+e.w,e.y,0),new k(e.x+e.w,s,0),new k(e.x,s,0)]}case"top":case"topLeft":case"topRight":{const s=e.y+e.h*(1-this.ratio);return[new k(e.x,s,0),new k(e.x+e.w,s,0),new k(e.x+e.w,e.y+e.h,0),new k(e.x,e.y+e.h,0)]}case"left":case"leftBottom":case"leftTop":{const s=e.x+e.w*(1-this.ratio);return[new k(s,e.y,0),new k(e.x+e.w,e.y,0),new k(e.x+e.w,e.y+e.h,0),new k(s,e.y+e.h,0)]}case"right":case"rightBottom":case"rightTop":{const s=e.x+e.w*this.ratio;return[new k(e.x,e.y,0),new k(s,e.y,0),new k(s,e.y+e.h,0),new k(e.x,e.y+e.h,0)]}}}computDrawPoints(t,e){const s=dt(this.tmpPoints),i=this.transformControlPoints(e),n=Math.floor(s.w*.1),a=Math.floor(s.h*.1),c=[],l=k.Add(i[0],new k(0,a,0)),h=k.Add(i[0],new k(n,0,0)),u=Ot.getBezierPoints(10,l,i[0],h),d=k.Sub(i[1],new k(n,0,0)),p=k.Add(i[1],new k(0,a,0)),f=Ot.getBezierPoints(10,d,i[1],p),I=k.Sub(i[2],new k(0,a,0)),y=k.Sub(i[2],new k(n,0,0)),v=Ot.getBezierPoints(10,I,i[2],y),m=k.Add(i[3],new k(n,0,0)),w=k.Sub(i[3],new k(0,a,0)),N=Ot.getBezierPoints(10,m,i[3],w),S=n*(1-this.ratio)*10,T=a*(1-this.ratio)*10;switch(e){case"bottom":{const A=k.Sub(i[2],new k(n*5-S/2,0,0)),O=k.Sub(i[2],new k(n*5,-T,0)),j=k.Sub(i[2],new k(n*5+S/2,0,0));c.push(O,j,...N,...u,...f,...v,A);break}case"bottomRight":{const A=k.Sub(i[2],new k(n*1.1,0,0)),O=k.Sub(i[2],new k(n*1.1+S/2,-T,0)),j=k.Sub(i[2],new k(n*1.1+S,0,0));c.push(O,j,...N,...u,...f,...v,A);break}case"bottomLeft":{const A=k.Add(i[3],new k(n*1.1+S,0,0)),O=k.Add(i[3],new k(n*1.1+S/2,T,0)),j=k.Add(i[3],new k(n*1.1,0,0));c.push(O,j,...N,...u,...f,...v,A);break}case"top":{const A=k.Sub(i[1],new k(n*5-S/2,0,0)),O=k.Sub(i[1],new k(n*5,T,0)),j=k.Sub(i[1],new k(n*5+S/2,0,0));c.push(O,A,...f,...v,...N,...u,j);break}case"topRight":{const A=k.Sub(i[1],new k(n*1.1,0,0)),O=k.Sub(i[1],new k(n*1.1+S/2,T,0)),j=k.Sub(i[1],new k(n*1.1+S,0,0));c.push(O,A,...f,...v,...N,...u,j);break}case"topLeft":{const A=k.Add(i[0],new k(n*1.1+S,0,0)),O=k.Add(i[0],new k(n*1.1+S/2,-T,0)),j=k.Add(i[0],new k(n*1.1,0,0));c.push(O,A,...f,...v,...N,...u,j);break}case"left":{const A=k.Add(i[0],new k(0,a*5-T/2,0)),O=k.Add(i[0],new k(-S,a*5,0)),j=k.Add(i[0],new k(0,a*5+T/2,0));c.push(O,A,...u,...f,...v,...N,j);break}case"leftTop":{const A=k.Add(i[0],new k(0,a*1.1,0)),O=k.Add(i[0],new k(-S,a*1.1+T/2,0)),j=k.Add(i[0],new k(0,a*1.1+T,0));c.push(O,A,...u,...f,...v,...N,j);break}case"leftBottom":{const A=k.Sub(i[3],new k(0,a*1.1+T,0)),O=k.Sub(i[3],new k(S,a*1.1+T/2,0)),j=k.Sub(i[3],new k(0,a*1.1,0));c.push(O,A,...u,...f,...v,...N,j);break}case"right":{const A=k.Add(i[1],new k(0,a*5-T/2,0)),O=k.Add(i[1],new k(S,a*5,0)),j=k.Add(i[1],new k(0,a*5+T/2,0));c.push(O,j,...v,...N,...u,...f,A);break}case"rightTop":{const A=k.Add(i[1],new k(0,a*1.1,0)),O=k.Add(i[1],new k(S,a*1.1+T/2,0)),j=k.Add(i[1],new k(0,a*1.1+T,0));c.push(O,j,...v,...N,...u,...f,A);break}case"rightBottom":{const A=k.Sub(i[2],new k(0,a*1.1+T,0)),O=k.Sub(i[2],new k(-S,a*1.1+T/2,0)),j=k.Sub(i[2],new k(0,a*1.1,0));c.push(O,j,...v,...N,...u,...f,A);break}}const x=dt(this.tmpPoints,t),b=[Math.floor(x.x+x.w/2),Math.floor(x.y+x.h/2)];return{rect:x,pos:b,points:c}}updateTempPoints(t){const e=t.slice(-2),s=new B(e[0],e[1]),i=this.tmpPoints[0],{thickness:n}=this.workOptions;if(i.isNear(s,n)||B.Sub(i,s).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(s.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=s}else this.tmpPoints.push(s);return!0}consumeService(t){var c,l;const{op:e,isFullWork:s}=t,i=(c=this.workId)==null?void 0:c.toString();if(!i)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new B(e[h],e[h+1],e[h+2]));const n=s?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:i,layer:n,isDrawing:!1});return this.oldRect=a,(l=this.vNodes)==null||l.setInfo(i,{rect:a,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&Y.getCenterPos(a,n)}),a}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var f;const{node:e,opt:s,vNodes:i}=t,{strokeColor:n,fillColor:a,toolsType:c,placement:l,strokeType:h}=s,u=i.get(e.name),d=u==null?void 0:u.opt;let p=e;return e.tagName==="GROUP"&&(p=e.children[0]),n&&(p.setAttribute("strokeColor",n),d!=null&&d.strokeColor&&(d.strokeColor=n)),a&&(a==="transparent"?p.setAttribute("fillColor","rgba(0,0,0,0)"):p.setAttribute("fillColor",a),d!=null&&d.fillColor&&(d.fillColor=a)),c===C.SpeechBalloon&&l&&(d.placement=l),h&&(u!=null&&u.opt)&&((f=u.opt)!=null&&f.strokeType)&&(u.opt.strokeType=h),u&&i.setInfo(e.name,{...u,opt:d}),Y.updateNodeOpt(t)}}var Sf=se,Cf=Qt,kf="[object Boolean]";function xf(r){return r===!0||r===!1||Cf(r)&&Sf(r)==kf}var zf=xf;const he=ye(zf);class Le extends Y{constructor(t){super(t);M(this,"canRotate",!0);M(this,"scaleType",ct.all);M(this,"toolsType",C.Image);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");this.workOptions=t.toolsOpt,this.scaleType=Le.getScaleType(this.workOptions)}consume(){return{type:z.None}}consumeAll(){return{type:z.None}}draw(t){const{layer:e,workId:s,replaceId:i,imageBitmap:n}=t,{centerX:a,centerY:c,width:l,height:h,rotate:u,zIndex:d,eraserlines:p}=this.workOptions,f=new lt.Group({anchor:[.5,.5],pos:[a,c],name:s,size:[l,h],zIndex:d,rotate:u}),I={anchor:[.5,.5],pos:[0,0],size:[l,h],texture:n};n||(I.bgcolor="rgba(0,0,0,0.3)");const y=new lt.Sprite(I);f.append(y),p&&this.drawEraserlines({group:f,eraserlines:p,pos:[a,c],layer:e}),this.replace(e,i||s,f);const v=f.getBoundingClientRect();if(v)return{x:Math.floor(v.x-Y.SafeBorderPadding),y:Math.floor(v.y-Y.SafeBorderPadding),w:Math.floor(v.width+Y.SafeBorderPadding*2),h:Math.floor(v.height+Y.SafeBorderPadding*2)}}consumeService(){}async consumeServiceAsync(t){var h,u,d,p;const{isFullWork:e,replaceId:s,worker:i}=t,{src:n,uuid:a}=this.workOptions,c=((h=this.workId)==null?void 0:h.toString())||a,l=e?this.fullLayer:this.drawLayer||this.fullLayer;if(n){const f=!!l.parent.gl;let I;i&&(I=await i.loadImageBitMap({toolsType:this.toolsType,opt:this.workOptions,workId:c})),I||(I=await fetch(n,{method:"GET",mode:"cors",cache:"default"}).then(v=>v.blob()).then(v=>createImageBitmap(v,{imageOrientation:f?"flipY":"none"}).then(m=>m)).catch(v=>{console.error(`load image error: ${v}`)}));const y=this.draw({workId:c,layer:l,replaceId:s,imageBitmap:I});return this.oldRect=c&&((d=(u=this.vNodes)==null?void 0:u.get(c))==null?void 0:d.rect)||void 0,(p=this.vNodes)==null||p.setInfo(c,{rect:y,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:y&&Y.getCenterPos(y,l)}),y}}clearTmpPoints(){this.tmpPoints.length=0}static getScaleType(t){const{uniformScale:e,rotate:s}=t;return e!==!1||s&&Math.abs(s)%90>0?ct.proportional:ct.all}static updateNodeOpt(t){const{node:e,opt:s,vNodes:i,targetNode:n}=t,{translate:a,originPoint:c,scenePoint:l,scale:h,angle:u,isLocked:d,zIndex:p}=s,f=n&&Vt(n)||i.get(e.name);if(!f)return;const I=e.parent;if(I){if(Ut(p)&&(e.setAttribute("zIndex",p),f.opt.zIndex=p),he(d)&&(f.opt.locked=d),c&&l&&h&&a){const{centerX:y,centerY:v,width:m,height:w,uniformScale:N}=f.opt,S=N!==!1?[h[0],h[0]]:h,T=[y,v],x=[y,v];Bo(x,l,S,a);const b=[x[0]-T[0],x[1]-T[1]];if(f.centerPos=[f.centerPos[0]+b[0],f.centerPos[1]+b[1]],f.opt.width=Math.round(m*S[0]),f.opt.height=Math.round(w*S[1]),f.opt.centerX=x[0],f.opt.centerY=x[1],f.opt.eraserlines)for(const A of Object.values(f.opt.eraserlines)){const{op:O,thickness:j}=A;A.thickness=j*Math.max(h[0],h[1]);for(let E=0;E<O.length;E++)Fo(O[E],l,h,a)}}else if(a){if(f.opt.centerX=f.opt.centerX+a[0],f.opt.centerY=f.opt.centerY+a[1],f.centerPos=[f.centerPos[0]+a[0],f.centerPos[1]+a[1]],f.opt.eraserlines)for(const y of Object.values(f.opt.eraserlines)){const{op:v}=y;for(let m=0;m<v.length;m++){const w=v[m].map((N,S)=>S%2?N+a[1]:N+a[0]);y.op[m]=w}}}else if(Ut(u))if(f.opt.rotate=u,f.scaleType=Le.getScaleType(f.opt),n){const y=Si(f.rect,u);f.rect=y}else{const y=Y.getRectFromLayer(I,e.name);f.rect=y||f.rect}return f&&i.setInfo(e.name,f),f==null?void 0:f.rect}}}class wi extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.both);M(this,"toolsType",C.Straight);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"straightTipWidth");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.straightTipWidth=this.workOptions.thickness/2,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:s,isSubWorker:i,isMainThread:n}=t,a=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:z.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new B(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:z.None};let u;if(i||n){const p=s?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:a,layer:p})}if(!i){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:z.DrawWork,dataType:F.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:z.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:z.DrawWork,dataType:F.Local,...this.baseConsumeResult}}consumeAll(){var a;const t=this.workId;if(this.tmpPoints.length<2)return{type:z.RemoveNode,removeIds:[t]};const e=this.fullLayer,s=this.draw({workId:t,layer:e});this.oldRect=s;const i=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=zt(i);return(a=this.vNodes)==null||a.setInfo(t,{rect:s,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&Y.getCenterPos(s,e)}),{rect:s,type:z.FullWork,dataType:F.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:s}=t,{strokeColor:i,thickness:n,zIndex:a,scale:c,rotate:l,translate:h,strokeType:u,eraserlines:d}=this.workOptions,p=s.worldPosition,f=s.worldScaling,{d:I,rect:y,isDot:v}=this.computDrawPoints(n,u),m=[y.x+y.w/2,y.y+y.h/2],w=new lt.Group({pos:m,anchor:[.5,.5],size:[y.w,y.h],name:e,id:e,normalize:!0,zIndex:a}),N={pos:[0,0],normalize:!0,d:I,fillColor:i,strokeColor:i,lineDash:u===X.Dotted&&!v?[1,n*2]:u===X.LongDotted&&!v?[n,n*2]:void 0,lineCap:u===X.Normal||v?void 0:"round",lineWidth:u===X.Normal||v?0:n};c&&(N.scale=c),l&&(N.rotate=l),h&&(N.translate=h);const S=new lt.Path(N);if(w.append(S),d&&this.drawEraserlines({group:w,eraserlines:d,pos:m,layer:s}),this.replace(s,e,w),l||c||h){const x=S.getBoundingClientRect();return{x:Math.floor(x.x-Y.SafeBorderPadding),y:Math.floor(x.y-Y.SafeBorderPadding),w:Math.floor(x.width+Y.SafeBorderPadding*2),h:Math.floor(x.height+Y.SafeBorderPadding*2)}}return{x:Math.floor(y.x*f[0]+p[0]-Y.SafeBorderPadding),y:Math.floor(y.y*f[1]+p[1]-Y.SafeBorderPadding),w:Math.floor(y.w*f[0]+2*Y.SafeBorderPadding),h:Math.floor(y.h*f[1]+2*Y.SafeBorderPadding)}}computDrawPoints(t,e){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.straightTipWidth?this.computFullPoints(t,e):this.computDotPoints(t)}computFullPoints(t,e){const s=k.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),i=k.Per(s).mul(t/2),n=B.Sub(this.tmpPoints[0],i),a=B.Add(this.tmpPoints[0],i),c=B.Sub(this.tmpPoints[1],i),l=B.Add(this.tmpPoints[1],i),h=B.GetSemicircleStroke(this.tmpPoints[1],c,-1,8),u=B.GetSemicircleStroke(this.tmpPoints[0],a,-1,8),d=[n,c,...h,l,a,...u];let p;return e!==X.Normal?p=Zt(this.tmpPoints,!1):p=Zt(d,!0),{d:p,rect:dt(d),isDot:!1,pos:this.tmpPoints[0].XY}}computDotPoints(t){const e=B.GetDotStroke(this.tmpPoints[0],t/2,8);return{d:Zt(e,!0),rect:dt(e),isDot:!0,pos:this.tmpPoints[0].XY}}updateTempPoints(t){const e=t.slice(-2),s=new B(e[0],e[1]),i=this.tmpPoints[0],{thickness:n}=this.workOptions;if(i.isNear(s,n))return!1;if(this.tmpPoints.length===2){if(s.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=s}else this.tmpPoints.push(s);return!0}consumeService(t){var c,l;const{op:e,isFullWork:s}=t,i=(c=this.workId)==null?void 0:c.toString();if(!i)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new B(e[h],e[h+1],e[h+2]));const n=s?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:i,layer:n});return this.oldRect=a,(l=this.vNodes)==null||l.setInfo(i,{rect:a,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&Y.getCenterPos(a,n)}),a}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var l,h;const{node:e,opt:s,vNodes:i}=t,{strokeColor:n,strokeType:a}=s,c=i.get(e.name);return n&&(e.tagName==="GROUP"?e.children.forEach(u=>{u.setAttribute("strokeColor",n),u.getAttribute("fillColor")&&u.setAttribute("fillColor",n)}):(e.setAttribute("strokeColor",n),e.setAttribute("fillColor",n)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=n)),a&&(c!=null&&c.opt)&&((h=c.opt)!=null&&h.strokeType)&&(c.opt.strokeType=a),c&&i.setInfo(e.name,c),Y.updateNodeOpt(t)}}const Gt=class Gt extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.proportional);M(this,"toolsType",C.Text);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");this.workOptions=t.toolsOpt}consume(){return{type:z.None}}consumeAll(){return{type:z.None}}consumeService(){}async draw(t){const{workId:e,layer:s,isDrawLabel:i}=t,{boxSize:n,boxPoint:a,zIndex:c,eraserlines:l}=this.workOptions,h=s.worldPosition,u=s.worldScaling;if(!a||!n)return;const d={name:e,id:e,pos:[a[0],a[1]],anchor:[0,0],size:n,zIndex:c},p=new lt.Group(d),f={x:a[0],y:a[1],w:n[0],h:n[1]},I={x:Math.floor(f.x*u[0]+h[0]),y:Math.floor(f.y*u[1]+h[1]),w:Math.floor(f.w*u[0])+2,h:Math.floor(f.h*u[1])+2};if(this.replace(s,e,p),i&&s&&this.workOptions.text){const y=await Gt.createLabels(this.workOptions,s,I),{labels:v,maxWidth:m}=y;p.append(...v),I.w=Math.ceil(Math.max(m*s.worldScaling[0],I.w))}return l&&this.drawEraserlines({group:p,eraserlines:l,pos:[a[0],a[1]],layer:s}),I}async consumeServiceAsync(t){var l,h,u,d;const e=(l=this.workId)==null?void 0:l.toString();if(!e)return;const{isFullWork:s,replaceId:i,isDrawLabel:n}=t;this.oldRect=i&&((u=(h=this.vNodes)==null?void 0:h.get(i))==null?void 0:u.rect)||void 0;const a=s?this.fullLayer:this.drawLayer||this.fullLayer,c=await this.draw({workId:e,layer:a,isDrawLabel:typeof n>"u"&&this.workOptions.workState===L.Done||n});return(d=this.vNodes)==null||d.setInfo(e,{rect:c,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&Y.getCenterPos(c,a)}),c}updataOptService(){}async updataOptServiceAsync(t,e){var f,I;if(!this.workId)return;const s=this.workId.toString(),{fontColor:i,fontBgColor:n,bold:a,italic:c,lineThrough:l,underline:h,zIndex:u}=t,d=(f=this.vNodes)==null?void 0:f.get(s);if(!d)return;i&&(d.opt.fontColor=i),n&&(d.opt.fontBgColor=n),a&&(d.opt.bold=a),c&&(d.opt.italic=c),he(l)&&(d.opt.lineThrough=l),he(h)&&(d.opt.underline=h),Ut(u)&&(d.opt.zIndex=u),this.oldRect=d.rect;const p=await this.draw({workId:s,layer:this.fullLayer,isDrawLabel:typeof e>"u"&&this.workOptions.workState===L.Done||e});return(I=this.vNodes)==null||I.setInfo(s,{rect:p,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:p&&Y.getCenterPos(p,this.fullLayer)}),p}clearTmpPoints(){this.tmpPoints.length=0}static getSafetySnippetRatio(t){const e=(t==null?void 0:t.parent).displayRatio||1,s=Math.ceil(t.worldScaling[0]*10)/10;let i=s;return s>=.2&&s<1?i=s*e:s<=2&&s>=1?i=s*e*1.6:s>2&&s<=3?i=s*e*1.4:s>3&&s<=4?i=s*e*.8:s>4&&(i=s*e*.6),Math.floor(i*1e3)/1e3}static getSafetySnippetFontLength(t){return Math.floor(Gt.textImageSnippetSize*3/4/t)||1}static async createLabels(t,e,s){var j;const i=[],{x:n,y:a}=s,{width:c,height:l}=(j=e.parent)==null?void 0:j.parent,h=Te(t.text),u=h.length,{fontSize:d,lineHeight:p,bold:f,textAlign:I,italic:y,fontFamily:v,verticalAlign:m,fontColor:w,fontBgColor:N,underline:S,lineThrough:T}=t,x=Gt.getSafetySnippetRatio(e)||1,b=Math.floor(d*x),A=Gt.getSafetySnippetFontLength(b);let O=0;for(let E=0;E<u;E++){const D=h[E],_=p||b*1.5;if(D){const nt=Of(D),tt=[0,0],V=[0,d*1.2];m==="middle"&&(tt[1]=E*d*1.2+5);const K=[0,-d*.15];tt[0]=5;const $=Math.sin(Math.PI/180*20);let G=0;const J=[];let rt=0;for(;rt<nt;){I==="left"&&(K[0]=G),rt===0&&y==="italic"&&(K[0]=K[0]-$/2*d);const ot=D.slice(rt,rt+A),at={anchor:[0,0],pos:K,text:ot,fontFamily:v,fontSize:b,lineHeight:_,strokeColor:w,fontWeight:f,fillColor:w,textAlign:I,fontStyle:y,scale:[1/x,1/x]},W=new lt.Label(at),it=await W.textImageReady;let ht=!0;if(it){const vt=it.rect&&it.rect[2],Xt=it.rect&&it.rect[3];if(vt&&Xt){const Ft=vt/x,Pt=Xt/x;G=Ft+G,y==="italic"&&(f==="bold"?G=G-$*d*1.2:G=G-$*d),((K[0]+tt[0]+Ft)*e.worldScaling[0]+n<=0||(K[0]+tt[0])*e.worldScaling[0]+n>=c||(K[1]+tt[1]+Pt)*e.worldScaling[1]+a<=0||(K[1]+tt[1])*e.worldScaling[1]+a>=l)&&(W.disconnect(),ht=!1),ht&&J.push(W)}}rt+=A}V[0]=G,y==="italic"&&(V[0]=V[0]+$*d),O=Math.max(O,V[0]);let It=!0;if(((tt[0]+V[0])*e.worldScaling[0]+n<=0||tt[0]*e.worldScaling[0]+n>=c||(tt[1]+V[1])*e.worldScaling[0]+a<=0||tt[1]*e.worldScaling[1]+a>=l)&&(It=!1),It){if(S){const W=Math.floor(d/10),it={normalize:!1,pos:[0,d*1.1+W/2],lineWidth:W,points:[0,0,Math.ceil(V[0]),0],strokeColor:w,className:"underline"},ht=new lt.Polyline(it);J.push(ht)}if(T){const W={normalize:!1,pos:[0,d*1.2/2],lineWidth:Math.floor(d/10),points:[0,0,Math.ceil(V[0]),0],strokeColor:w,className:"lineThrough"},it=new lt.Polyline(W);J.push(it)}const ot={pos:tt,anchor:[0,0],size:V,bgcolor:N},at=new lt.Group(ot);at.append(...J),i.push(at)}}}return{labels:i,maxWidth:O}}static updateNodeOpt(t){const{node:e,opt:s,vNodes:i,targetNode:n}=t,{fontBgColor:a,fontColor:c,translate:l,originPoint:h,scenePoint:u,scale:d,bold:p,italic:f,lineThrough:I,underline:y,fontSize:v,textInfos:m,zIndex:w}=s,N=n&&Vt(n)||i.get(e.name);if(!N||!e.parent)return;const T=N.opt;if(Ut(w)&&(e.setAttribute("zIndex",w),N.opt.zIndex=w),c&&T.fontColor&&(T.fontColor=c,e.children.forEach(x=>{x.tagName==="GROUP"&&x.children.forEach(b=>{b.tagName==="LABEL"?(b.setAttribute("fillColor",c),b.setAttribute("strokeColor",c)):b.tagName==="POLYLINE"&&b.setAttribute("strokeColor",c)})})),a&&T.fontBgColor&&(T.fontBgColor=a,e.children.forEach(x=>{x.tagName==="GROUP"&&x.setAttribute("bgcolor",a)})),p&&(T.bold=p),f&&(T.italic=f),he(I)&&(T.lineThrough=I),he(y)&&(T.underline=y),v&&(T.fontSize=v),h&&u&&d&&n&&T.boxPoint){const x=m==null?void 0:m.get(e.name);if(x){const{fontSize:j,boxSize:E}=x;T.boxSize=E||T.boxSize,T.fontSize=j||T.fontSize}const b=[T.boxPoint[0],T.boxPoint[1]];Bo(T.boxPoint,u,d,l);const A=[N.op[0],N.op[1]],O=[A[0]-b[0],A[1]-b[1]];if(N.centerPos=[N.centerPos[0]+O[0],N.centerPos[1]+O[1]],N.opt.eraserlines)for(const j of Object.values(N.opt.eraserlines)){const{op:E,thickness:D}=j;j.thickness=D*Math.max(d[0],d[1]);for(let _=0;_<E.length;_++)Fo(E[_],u,d,l)}}else if(l&&T.boxPoint&&(T.boxPoint=[T.boxPoint[0]+l[0],T.boxPoint[1]+l[1]],N.centerPos=[N.centerPos[0]+l[0],N.centerPos[1]+l[1]],N.opt.eraserlines))for(const x of Object.values(N.opt.eraserlines)){const{op:b}=x;for(let A=0;A<b.length;A++){const O=b[A].map((j,E)=>E%2?j+l[1]:j+l[0]);x.op[A]=O}}return N&&i.setInfo(e.name,N),N==null?void 0:N.rect}static getRectFromLayer(t,e){const s=t.getElementsByName(e)[0];if(s){const i=s.getBoundingClientRect();let n={x:Math.floor(i.x),y:Math.floor(i.y),w:Math.floor(i.width+2),h:Math.floor(i.height+2)};return s.children.forEach(a=>{if(a.tagName==="GROUP"){const c=s.getBoundingClientRect();n=ut(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 Ge=Gt;const de=class de extends Y{constructor(t,e){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.none);M(this,"toolsType",C.PencilEraser);M(this,"serviceWork");M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"worldPosition");M(this,"worldScaling");M(this,"eraserRect");M(this,"eraserPolyline");this.serviceWork=e,this.workOptions=t.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}consumeService(){}createEraserRect(t){const e=t[0]*this.worldScaling[0]+this.worldPosition[0],s=t[1]*this.worldScaling[1]+this.worldPosition[1],{width:i,height:n}=de.eraserSizes[this.workOptions.thickness];this.eraserRect={x:e-i*.5,y:s-n*.5,w:i,h:n},this.eraserPolyline=[this.eraserRect.x,this.eraserRect.y,this.eraserRect.x+this.eraserRect.w,this.eraserRect.y+this.eraserRect.h]}computRectCenterPoints(){const t=this.tmpPoints.slice(-2);if(this.tmpPoints.length===4){const e=new k(this.tmpPoints[0],this.tmpPoints[1]),s=new k(this.tmpPoints[2],this.tmpPoints[3]),i=k.Sub(s,e).uni(),n=k.Dist(e,s),{width:a,height:c}=de.eraserSizes[this.workOptions.thickness],l=Math.min(a,c),h=Math.round(n/l);if(h>1){const u=[];for(let d=0;d<h;d++){const p=k.Mul(i,d*l);u.push(this.tmpPoints[0]+p.x,this.tmpPoints[1]+p.y)}return u.concat(t)}}return t}isNear(t,e){const s=new k(t[0],t[1]),i=new k(e[0],e[1]),{width:n,height:a}=de.eraserSizes[this.workOptions.thickness];return k.Dist(s,i)<Math.hypot(n,a)*.5}cutPolyline(t,e){let s=[e],i=0;for(;i<t.length;){const c=t[i];if(c.length<2)break;s=n(s,c),i++}return s;function n(c,l){const h=c;for(let u=0;u<c.length;u++){const d=c[u],p=d.findIndex((f,I)=>I<d.length-1?a([f,d[I+1]],[l[0],l[1]]):!1);if(p!==-1&&p>-1){const f=[],I=d.slice(0,p+1);if(k.Equals(d[p],l[0])||I.push(l[0].clone().setz(d[p].z)),I.length>1&&f.push(I),p+l.length-1<d.length-1){const y=p+l.length-1,v=d.slice(y),m=l[l.length-1];k.Equals(d[y],m)||v.unshift(m.clone().setz(d[y].z)),v.length>1&&f.push(v)}return h.splice(u,1,...f),h}}return h}function a(c,l){const h=k.Sub(c[1],c[0]),u=k.Sub(l[1],l[0]),d=k.Sub(l[0],c[0]);return Math.abs(k.Cpr(h,u))<.1&&Math.abs(k.Cpr(h,d))<.1}}isSamePoint(t,e){return t[0]===e[0]&&t[1]===e[1]}translateIntersect(t){const e=[];for(let s=0;s<t.length;s++){const i=t[s].filter((c,l,h)=>!(l>0&&this.isSamePoint(c,h[l-1]))),n=[];let a=0;for(;a<i.length;){const c=i[a],l=new k(c[0],c[1]);n.push(l),a++}e.push(n)}return e}isLineEraser(t,e){return!(t===C.Pencil&&!e)}remove(t){const{curNodeMap:e,removeIds:s,newWorkDatas:i}=t;let n;for(const[a,c]of e.entries())if(c.rect&&this.eraserRect&&this.eraserPolyline&&Pe(this.eraserRect,c.rect)){const{op:l,toolsType:h}=c,u=this.isLineEraser(h,!1),d=[],p=[];for(let I=0;I<l.length;I+=3){const y=new k(l[I]*this.worldScaling[0]+this.worldPosition[0],l[I+1]*this.worldScaling[1]+this.worldPosition[1],l[I+2]);p.push(y),d.push(new B(y.x,y.y))}const f=d.length&&dt(d)||c.rect;if(Pe(f,this.eraserRect)){if(p.length>1){const I=bo.polyline(p.map(y=>y.XY),this.eraserPolyline);if(I.length&&(s.add(c.name),!u)){const y=this.translateIntersect(I),v=this.cutPolyline(y,p);for(let m=0;m<v.length;m++){const w=`${a}_s_${m}`,N=[];v[m].forEach(S=>{N.push((S.x-this.worldPosition[0])/this.worldScaling[0],(S.y-this.worldPosition[1])/this.worldScaling[1],S.z)}),c.opt&&c.toolsType&&this.vNodes&&(this.vNodes.setInfo(w,{rect:f,op:N,opt:c.opt,canRotate:c.canRotate,scaleType:c.scaleType,toolsType:c.toolsType}),i.set(w,{workId:w,op:N,opt:c.opt,toolsType:c.toolsType}))}}}else s.add(c.name);n=ut(n,f)}}return s.forEach(a=>{var c;return(c=this.vNodes)==null?void 0:c.delete(a)}),n&&(n.x-=Y.SafeBorderPadding,n.y-=Y.SafeBorderPadding,n.w+=Y.SafeBorderPadding*2,n.h+=Y.SafeBorderPadding*2),n}consume(t){const{op:e}=t.data;if(!e||e.length===0)return{type:z.None,...this.baseConsumeResult};const s=this.tmpPoints.length;if(s>1&&this.isNear([e[0],e[1]],[this.tmpPoints[s-2],this.tmpPoints[s-1]]))return{type:z.None,...this.baseConsumeResult};s<3?this.tmpPoints.push(e[0],e[1]):this.tmpPoints.splice(2,2,e[0],e[1]);const i=this.computRectCenterPoints();let n;const a=new Set,c=new Map;if(!this.vNodes)return{type:z.None,...this.baseConsumeResult};this.vNodes.setTarget();const l=this.getCanEraserNodeMap(this.vNodes.getCanEraserNodes(this.vNodes.getLastTarget()));for(let h=0;h<i.length-1;h+=2){this.createEraserRect(i.slice(h,h+2));const u=this.remove({curNodeMap:l,removeIds:a,newWorkDatas:c});n=ut(n,u)}if(this.vNodes.deleteLastTarget(),n&&a.size){for(const h of c.keys())a.has(h)&&c.delete(h);return{type:z.RemoveNode,rect:n,removeIds:[...a],newWorkDatas:c}}return{type:z.None,...this.baseConsumeResult}}consumeAll(t){return this.consume(t)}clearTmpPoints(){this.tmpPoints.length=0}getCanEraserNodeMap(t){var e;if(this.serviceWork){const s=Vt(t),i=this.serviceWork.selectorWorkShapes,n=this.serviceWork.workShapes;for(const a of i.values())if((e=a.selectIds)!=null&&e.length)for(const c of a.selectIds)s.delete(c);for(const a of n.keys())s.delete(a);return s}return t}};M(de,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));let Ze=de;const ze=class ze extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.none);M(this,"toolsType",C.BitMapEraser);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"worldPosition");M(this,"worldScaling");M(this,"eraserRect");M(this,"eraserPolyline");M(this,"syncUnitTime",xt.syncOpt.interval);M(this,"syncIndex",0);M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling,this.syncTimestamp=0}consumeService(t){const{op:e,isFullWork:s}=t;this.tmpPoints.length=0;for(let c=0;c<e.length;c+=3){const l=new B(e[c],e[c+1],e[c+2]);if(this.tmpPoints.length>0){const h=this.tmpPoints[this.tmpPoints.length-1],u=k.Sub(l,h).uni();l.setv(u)}this.tmpPoints.push(l)}if(this.tmpPoints.length<2)return;const i=this.tmpPoints[0].z*2,n=s?this.fullLayer:this.drawLayer||this.fullLayer;return this.draw({consumePoints:this.tmpPoints,layer:n,thickness:i})}updateTempPoints(t,e){let s=this.tmpPoints.length-1;const i=Date.now();for(let n=0;n<t.length;n+=2){const a=this.tmpPoints.length,c=new B(t[n],t[n+1]);if(a===0){this.tmpPoints.push(c);continue}const l=a-1,h=this.tmpPoints[l],u=k.Sub(c,h).uni();c.isNear(h,e/2)||(k.Equals(u,h.v,.02)&&(this.tmpPoints.pop(),s--),c.setv(u),c.setT(i),this.tmpPoints.push(c))}return Math.max(s,0)}getChangeNodes(t){if(!this.vNodes)return;const e=this.worldPosition;let s=dt(this.tmpPoints,t);s=To(s,e),s=Lf(s,this.worldScaling,e);const{nodeRange:i}=this.vNodes.getRectIntersectRange(s);if(!i.size)return;const n=[];let a=0;for(let l=1;l<this.tmpPoints.length;l++){const h=this.tmpPoints[l-1],u=this.tmpPoints[l];if(l===1&&a===0&&(n[a]=[h.XY]),n[a].push(u.XY),l<this.tmpPoints.length-1){const d=u.getAngleByPoints(h,this.tmpPoints[l+1]);(d<90||d>270)&&(a++,n[a]=[u.XY])}}this.tmpPoints.length===1&&n.length===0&&n.push([this.tmpPoints[0].XY,this.tmpPoints[0].XY]);const c=new Map;for(const[l,h]of i.entries()){let u=To(h.rect,[-e[0],-e[1]]);u={x:u.x/this.worldScaling[0],y:u.y/this.worldScaling[1],w:u.w/this.worldScaling[0],h:u.h/this.worldScaling[1]};const d=[u.x,u.y,u.x+u.w,u.y+u.h],p=[],f=[];for(const y of n)bo.polyline(y,d,p);if(p.length&&h.opt)for(const y of p){const v=[];for(let m=0;m<y.length;m++)m!==0&&le(y[m],y[m-1])||v.push(...y[m]);f.push(v)}h.opt.eraserlines||(h.opt.eraserlines=[]),h.opt.eraserlines&&(h.opt.eraserlines.push({op:f,thickness:t}),c.set(l,h))}return c}async reRenderEffectNodes(t){let e;const{willUpdateNodes:s,worker:i}=t;for(const[n,a]of s.entries()){const{toolsType:c}=a,l=i.createWorkShapeNode({workId:n,toolsType:c,toolsOpt:a.opt});l==null||l.setWorkId(n);let h;if(c===C.Image)h=await l.consumeServiceAsync({isFullWork:!0,replaceId:n,worker:i});else if(c===C.Text)h=await l.consumeServiceAsync({isFullWork:!0,replaceId:n});else try{h=l==null?void 0:l.consumeService({op:a.op,isFullWork:!0,replaceId:n})}catch{continue}h&&(e=ut(e,h))}return e}consume(t){const{op:e}=t.data;if(!e||e.length===0)return{type:z.None,...this.baseConsumeResult};const{thickness:s}=this.workOptions,{width:i,height:n}=ze.eraserSizes[s],a=Math.max(i,n)/this.worldScaling[0],c=this.tmpPoints.length,l=this.tmpPoints[this.tmpPoints.length-1],h=this.updateTempPoints(e,a),u=this.tmpPoints[this.tmpPoints.length-1];if(c===this.tmpPoints.length&&u.equalsXY(l.x,l.y))return{type:z.None,...this.baseConsumeResult};this.syncIndex=Math.min(this.syncIndex,h,Math.max(0,this.tmpPoints.length-2));const d=this.syncIndex;this.syncTimestamp===0&&(this.syncTimestamp=Date.now());let p=!1;const f=this.tmpPoints.slice(h),I=this.draw({consumePoints:f,layer:this.fullLayer,thickness:a});f[0].t-this.syncTimestamp>this.syncUnitTime&&(p=!0,this.syncTimestamp=f[0].t,this.syncIndex=this.tmpPoints.length);const y=[];return this.tmpPoints.slice(d).forEach(v=>{y.push(v.x,v.y,a/2)}),{...this.baseConsumeResult,type:z.DrawWork,dataType:F.Local,rect:I,op:p?y:void 0,index:p?d*3:void 0,updateNodeOpt:{useAnimation:!0}}}draw(t){const{consumePoints:e,layer:s,thickness:i}=t,n=this.workId;let a=s.getElementsByName(this.workId)[0],c=dt(e,i);const h=[{op:[e.map(u=>[u.x,u.y]).flat(1)],thickness:i}];return a||(a=new lt.Group({normalize:!0,name:n,pos:[0,0],anchor:[.5,.5],bgcolor:"rgba(0,0,0,0.3)",zIndex:9999}),s.appendChild(a)),this.drawEraserlines({group:a,eraserlines:h,pos:[0,0],layer:s,isClear:!0}),c={x:Math.floor(c.x*this.worldScaling[0]+this.worldPosition[0]-Y.SafeBorderPadding),y:Math.floor(c.y*this.worldScaling[1]+this.worldPosition[1]-Y.SafeBorderPadding),w:Math.floor(c.w*this.worldScaling[0]+2*Y.SafeBorderPadding),h:Math.floor(c.h*this.worldScaling[1]+2*Y.SafeBorderPadding)},c}consumeAll(){const t=this.fullLayer.getElementsByName(this.workId);let e;if(t.length&&(e=Y.getRectFromLayer(this.fullLayer,this.workId)),t.forEach(u=>{u.remove(),u.disconnect()}),!this.tmpPoints.length)return{type:z.None,...this.baseConsumeResult};const{thickness:s}=this.workOptions,{width:i,height:n}=ze.eraserSizes[s],a=Math.max(i,n)/this.worldScaling[0],c=this.getChangeNodes(a);if(!(c!=null&&c.size))return{type:z.FullWork,...this.baseConsumeResult,rect:e};const l=[];this.tmpPoints.map(u=>{l.push(u.x,u.y,a/2)});const h=zt(l);return{...this.baseConsumeResult,type:z.FullWork,dataType:F.Local,rect:e,ops:h,willUpdateNodes:c}}clearTmpPoints(){this.tmpPoints.length=0}};M(ze,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));let qe=ze;function Ii(r){switch(r){case C.Arrow:return pi;case C.Pencil:return li;case C.Straight:return wi;case C.Ellipse:return fi;case C.Polygon:case C.Triangle:return yi;case C.Star:case C.Rhombus:return Mi;case C.Rectangle:return gi;case C.SpeechBalloon:return mi;case C.Text:return Ge;case C.LaserPen:return hi;case C.Eraser:return Qe;case C.PencilEraser:return Ze;case C.BitMapEraser:return qe;case C.Selector:return $e;case C.Image:return Le}}function vi(r,o){const{toolsType:t,...e}=r;switch(t){case C.Arrow:return new pi(e);case C.Pencil:return new li(e);case C.Straight:return new wi(e);case C.Ellipse:return new fi(e);case C.Polygon:case C.Triangle:return new yi(e);case C.Star:case C.Rhombus:return new Mi(e);case C.Rectangle:return new gi(e);case C.SpeechBalloon:return new mi(e);case C.Text:return new Ge(e);case C.LaserPen:return new hi(e);case C.Eraser:return new Qe(e,o);case C.BitMapEraser:return new qe(e);case C.PencilEraser:return new Ze(e,o);case C.Selector:return e.vNodes?new $e({...e,vNodes:e.vNodes,drawLayer:e.fullLayer}):void 0;case C.Image:return new Le(e);default:return}}function Ni(r){const o=[],t=["PATH","SPRITE","POLYLINE","RECT","ELLIPSE","LABEL"];for(const e of r){if(e.tagName==="GROUP"&&e.children.length)return Ni(e.children);e.tagName&&t.includes(e.tagName)&&o.push(e)}return o}function ut(r,o){if(r&&o){const t=Math.min(r.x,o.x),e=Math.min(r.y,o.y),s=Math.max(r.x+r.w,o.x+o.w),i=Math.max(r.y+r.h,o.y+o.h),n=s-t,a=i-e;return{x:t,y:e,w:n,h:a}}return o||r}function Ti(r,o){if(r&&o){const t=Math.min(r.originX,o.originX),e=Math.min(r.originY,o.originY),s=Math.max(r.originX+r.width,o.originX+o.width),i=Math.max(r.originY+r.height,o.originY+o.height),n=s-t,a=i-e;return{originX:t,originY:e,width:n,height:a}}return o||r}function dt(r,o=0){const t={x:0,y:0,w:0,h:0};let e=1/0,s=1/0,i=-1/0,n=-1/0;return r.forEach(a=>{const[c,l]=a.XY;e=Math.min(e,c-o),s=Math.min(s,l-o),i=Math.max(i,c+o),n=Math.max(n,l+o)}),t.x=e,t.y=s,t.w=i-e,t.h=n-s,t}function Pe(r,o){return!(r.x+r.w<o.x||r.x>o.x+o.w||r.y+r.h<o.y||r.y>o.y+o.h)}function To(r,o){return{x:r.x+o[0],y:r.y+o[1],w:r.w,h:r.h}}function bf(r,o){const t=new k(r.x,r.y),e=new k(r.x+r.w,r.y),s=new k(r.x+r.w,r.y+r.h),i=new k(r.x,r.y+r.h),n=new k(r.x+r.w/2,r.y+r.h/2),a=Math.PI*o/180,c=k.RotWith(t,n,a),l=k.RotWith(e,n,a),h=k.RotWith(s,n,a),u=k.RotWith(i,n,a);return[c,l,h,u]}function Si(r,o){const t=bf(r,o);return dt(t)}function Lf(r,o,t){const e=new k(r.x,r.y),s=new k(r.x+r.w,r.y),i=new k(r.x+r.w,r.y+r.h),n=new k(r.x,r.y+r.h),a=new k(t[0],t[1]),c=new k(o[0],o[1]),l=k.ScaleWOrigin(e,c,a),h=k.ScaleWOrigin(s,c,a),u=k.ScaleWOrigin(i,c,a),d=k.ScaleWOrigin(n,c,a);return dt([l,h,u,d])}function Pf(r,o,t){const e=new k(o[0],o[1]);for(let s=0;s<r.length;s+=3){const i=new k(r[s],r[s+1]),n=Math.PI*t/180,a=k.RotWith(i,e,n);r[s]=a.x,r[s+1]=a.y}}function jf(r,o,t){const e=new k(o[0],o[1]);for(let s=0;s<r.length;s+=2){const i=new k(r[s],r[s+1]),n=Math.PI*t/180,a=k.RotWith(i,e,n);r[s]=a.x,r[s+1]=a.y}}function Bo(r,o,t,e=[0,0]){const s=new k(o[0],o[1]);for(let i=0;i<r.length;i+=3){const n=new k(r[i],r[i+1]),a=new k(t[0],t[1]),c=k.ScaleWOrigin(n,a,s);r[i]=c.x+e[0],r[i+1]=c.y+e[1]}}function Fo(r,o,t,e=[0,0]){const s=new k(o[0],o[1]);for(let i=0;i<r.length;i+=2){const n=new k(r[i],r[i+1]),a=new k(t[0],t[1]),c=k.ScaleWOrigin(n,a,s);r[i]=c.x+e[0],r[i+1]=c.y+e[1]}}function Ci(r,o){return r[0]>=o.x&&r[0]<=o.x+o.w&&r[1]>=o.y&&r[1]<=o.y+o.h}function ki(r,o){const t=r<=o?1:r/o,e=o<=r?1:o/r;return[t,e]}function Df(r){for(const o of r)if(isNaN(o)||o===1/0||o===-1/0)return!1;return!0}const Af=r=>{if(r.tagName==="GROUP"){const o=Object.getOwnPropertySymbols(r).find(t=>t.toString()==="Symbol(sealed)");if(o&&r[o])return!0}return!1};function ne(r){return`${Je(r.x)},${Je(r.y)} `}function re(r,o){return`${Je((r.x+o.x)/2)},${Je((r.y+o.y)/2)} `}function Je(r){return+r.toFixed(4)}const oe=(r,o)=>new Promise(function(t){window.requestIdleCallback?requestIdleCallback(()=>{t(1)},{timeout:o}):setTimeout(()=>{t(2)},o)}).then(function(){r()},()=>{r()}),qt=r=>{const o=(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)/o)},Ef=(r,o)=>r.x+r.w<o.x||r.x>o.x+o.w||r.y+r.h<o.y||r.y>o.y+o.h?xe.outside:r.x>=o.x&&r.y>=o.y&&r.x+r.w<=o.x+o.w&&r.y+r.h<=o.y+o.h?xe.inside:xe.intersect;function Of(r){let o=0;for(let t=0;t<r.length;t++){const e=r.charCodeAt(t);e>=1&&e<=126||65376<=e&&e<=65439?o++:o+=2}return o}class Rf{constructor(o,t){M(this,"plugin");M(this,"uid");M(this,"control");this.control=o,this.plugin=t,this.uid=t.displayer.uid}getNamespaceData(){var o;return st.toJS((o=this.plugin)==null?void 0:o.attributes[this.namespace])||{}}getAuthSpaceData(){var o;return st.toJS((o=this.plugin)==null?void 0:o.attributes[this.authSpace])||{}}getUidFromKey(o){return o.split(Rt).length===2&&o.split(Rt)[0]||this.uid}isLocalId(o){return o.split(Rt).length===1}getLocalId(o){return o.split(Rt)[1]}isSelector(o){return this.getLocalId(o)===H}}const Et=class Et extends Rf{constructor(t,e,s){super(t,e);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);Et.syncInterval=(s||Et.syncInterval)*.5,this.namespace=Et.namespace,this.authSpace=Et.authSpace,this.serviceStorage=this.getNamespaceData(),this.storage=P.cloneDeep(this.serviceStorage),this.authStorage=this.getAuthSpaceData()}getViewIdBySecenPath(t){const e=this.getNamespaceData();for(const[s,i]of Object.entries(e))if(i){for(const n of Object.keys(i))if(n===t)return s}}getScenePathData(t){const e=this.getNamespaceData();for(const s of Object.values(e))if(s){for(const i of Object.keys(s))if(i===t)return P.cloneDeep(s[i])}}getStorageData(t,e){const s=this.getNamespaceData();return s&&s[t]&&P.cloneDeep(s[t][e])||void 0}hasSelector(t,e){const s=this.storage&&this.storage[t]&&this.storage[t][e];return!!(s&&Object.keys(s).find(i=>this.isOwn(i)&&this.getLocalId(i)===H))}addStorageStateListener(t){this.stateDisposer=st.autorun(async()=>{var c;const e=this.getNamespaceData(),{diffView:s,diffScenePath:i,diffData:n}=this.diffFunByView(this.serviceStorage,e);this.serviceStorage=e;const a={};if(Object.keys(s).length>0){a.diffView=s;for(const[l,h]of Object.entries(s)){if(h&&h.newValue===void 0&&this.storage[l]){delete this.storage[l];continue}if(h&&h.newValue){this.storage[l]=P.cloneDeep(h.newValue);continue}}}if(Object.keys(i).length>0){a.diffScenePath=i;for(const[l,h]of Object.entries(i))if(h){const{viewId:u,newValue:d}=h;let p=this.storage[u];if(p&&p[l]&&d===void 0){delete p[l];continue}if(d&&u){p===void 0&&(this.storage[u]={},p=this.storage[u]),p[l]=P.cloneDeep(d);continue}}}if(Object.keys(n).length>0){a.diffData=n;for(const[l,h]of Object.entries(n))if(h){const{viewId:u,scenePath:d,newValue:p}=h;if(u&&d){let f=this.storage[u],I=(c=this.storage[u])==null?void 0:c[d];if(f||(this.storage[u]={},f=this.storage[u],f[d]={},I=f[d]),I){if(I[l]&&p===void 0){delete I[l];continue}if(p&&u){I[l]=P.cloneDeep(p);continue}}}}}Object.keys(a).length>0&&t(a)})}removeStorageStateListener(){this.stateDisposer&&this.stateDisposer()}diffFunByView(t,e){const s=St(t),i=St(e),n={},a={},c={};for(const l of i)if(!s.includes(l)||t[l]===void 0){n[l]={newValue:e[l],oldValue:void 0};continue}for(const l of s){if(P.isEqual(t[l],e[l]))continue;if(!i.includes(l)||e[l]===void 0){n[l]={newValue:void 0,oldValue:t[l]};continue}const h=this.diffFunByScenePath(t[l],e[l],l);Object.assign(a,h.diffScenePath),Object.assign(c,h.diffData)}return{diffData:c,diffScenePath:a,diffView:n}}diffFunByScenePath(t,e,s){const i=St(t),n=St(e),a={},c={};for(const l of n)if(!i.includes(l)||t[l]===void 0){a[l]={newValue:e[l],oldValue:void 0,viewId:s};continue}for(const l of i){if(P.isEqual(t[l],e[l]))continue;if(!n.includes(l)||e[l]===void 0){a[l]={newValue:void 0,oldValue:t[l],viewId:s};continue}const h=this.diffFunByKeys(t[l],e[l],l,s);Object.assign(c,h)}return{diffScenePath:a,diffData:c}}diffFunByKeys(t,e,s,i){const n=St(t),a=St(e),c={};for(const l of a)(!n.includes(l)||t[l]===void 0)&&(c[l]={oldValue:void 0,newValue:e[l],viewId:i,scenePath:s});for(const l of n)if(!P.isEqual(t[l],e[l])){if(!a.includes(l)||e[l]===void 0){c[l]={newValue:void 0,oldValue:t[l],viewId:i,scenePath:s};continue}a.includes(l)&&(c[l]={oldValue:t[l],newValue:e[l],viewId:i,scenePath:s})}return c}transformKey(t){return this.uid+Rt+t}isOwn(t){return t.split(Rt)[0]===this.uid}dispatch(t){const{type:e,workId:s,ops:i,index:n,opt:a,toolsType:c,removeIds:l,updateNodeOpt:h,op:u,selectIds:d,isSync:p,scenePath:f,viewId:I}=t;if(I)switch(e){case z.Clear:const y={};f&&this.storage[I]&&this.storage[I][f]?(delete this.storage[I][f],this.setState(y,{isSync:p,viewId:I,scenePath:f})):this.storage[I]&&(delete this.storage[I],this.setState(y,{isSync:p,viewId:I,scenePath:""}));break;case z.CreateWork:if(f&&s&&c&&a){const S=this.isLocalId(s.toString())?this.transformKey(s):s;this.updateValue(S.toString(),{type:z.CreateWork,workId:s,toolsType:c,opt:a},{isSync:p,viewId:I,scenePath:f})}break;case z.DrawWork:if(f&&s&&typeof n=="number"&&(u!=null&&u.length)){const S=this.isLocalId(s.toString())?this.transformKey(s):s,T=this.storage[I]&&this.storage[I][f]&&this.storage[I][f][S]||void 0;if(T!=null&&T.ops||(T==null?void 0:T.type)===z.FullWork)return;const x=n?((T==null?void 0:T.op)||[]).slice(0,n).concat(u):u||(T==null?void 0:T.op),b=c||(T==null?void 0:T.toolsType),A=a||(T==null?void 0:T.opt),O=h||(T==null?void 0:T.updateNodeOpt);s&&b&&A&&x&&this.updateValue(S.toString(),{...T,type:z.DrawWork,workId:s,updateNodeOpt:O,toolsType:b,opt:A,op:x,index:n},{isSync:p,viewId:I,scenePath:f})}break;case z.FullWork:if(f&&s){const S=this.isLocalId(s.toString())?this.transformKey(s):s,T=this.storage[I]&&this.storage[I][f]&&this.storage[I][f][S]||void 0,x=h||(T==null?void 0:T.updateNodeOpt),b=c||(T==null?void 0:T.toolsType),A=a||(T==null?void 0:T.opt),O=i||(T==null?void 0:T.ops);b&&A&&this.updateValue(S.toString(),{type:z.FullWork,updateNodeOpt:x,workId:S,toolsType:b,opt:A,ops:O},{isSync:p,viewId:I,scenePath:f})}break;case z.RemoveNode:if(f&&(l!=null&&l.length)){const S=l.map(T=>this.isLocalId(T+"")?this.transformKey(T):T);this.storage[I]&&this.storage[I][f]&&Object.keys(this.storage[I][f]).map(T=>{S!=null&&S.includes(T)&&this.updateValue(T,void 0,{isSync:p,viewId:I,scenePath:f})})}break;case z.UpdateNode:if(f&&s&&(h||i||a)){const S=this.isLocalId(s.toString())?this.transformKey(s):s,T=this.storage[I]&&this.storage[I][f]&&this.storage[I][f][S]||void 0;T&&(T.updateNodeOpt=h,(i||u)&&(T.ops=i,T.op=u),a&&(T.opt=a),T.type=z.FullWork,this.updateValue(S.toString(),T,{isSync:p,viewId:I,scenePath:f}))}break;case z.Select:if(!f)return;let v;d!=null&&d.length&&(v=d.map(S=>this.isLocalId(S+"")?this.transformKey(S):S));const m=this.transformKey(H),w=this.storage[I]&&this.storage[I][f]&&this.storage[I][f][m]||void 0,N=a||(w==null?void 0:w.opt);v&&this.checkOtherSelector(m,v,{isSync:p,viewId:I,scenePath:f}),this.updateValue(m,v&&{type:z.Select,toolsType:C.Selector,opt:N,selectIds:v},{isSync:p,viewId:I,scenePath:f});break}}checkOtherSelector(t,e,s){const{viewId:i,scenePath:n}=s;for(const a of Object.keys(this.storage[i][n]))if(a!==t&&this.getLocalId(a)===H){const c=this.storage[i][n][a];if(c&&c.selectIds){const l=c.selectIds.filter(h=>!e.includes(h));l.length>0&&(c.selectIds=l),this.updateValue(a,l.length&&c||void 0,s)}}}setState(t,e){const{viewId:s,scenePath:i}=e,n=St(t);for(let a=0;a<n.length;a++){const c=n[a],l=t[c];typeof l<"u"?(this.storage[s]||(this.storage[s]={}),this.storage[s][i]||(this.storage[s][i]={}),this.storage[s][i][c]=l):delete this.storage[s][i][c]}this.runSyncService(e)}updateValue(t,e,s){const{viewId:i,scenePath:n}=s;e===void 0?delete this.storage[i][n][t]:(this.storage[i]||(this.storage[i]={}),this.storage[i][n]||(this.storage[i][n]={}),this.storage[i][n][t]=e),this.runSyncService(s)}runSyncService(t){this.asyncClockState||(this.asyncClockState=!0,setTimeout(()=>{t.isSync?(this.asyncClockState=!1,this.syncSerivice(t.isAfterUpdate)):oe(()=>{this.asyncClockState=!1,this.syncSerivice(t.isAfterUpdate)},Et.syncInterval)},t!=null&&t.isSync?0:Et.syncInterval))}syncSerivice(t=!1){const e=St(this.serviceStorage),s=St(this.storage),i=new Map;for(const n of e){if(!s.includes(n)){i.set(n,void 0);continue}P.isEqual(this.serviceStorage[n],this.storage[n])||this.syncViewData(n,t)}for(const n of s)e.includes(n)||i.set(n,this.storage[n]);if(i.size>5)this.syncStorageView(this.storage,t);else for(const[n,a]of i.entries())this.syncUpdataView(n,a,t)}syncViewData(t,e=!1){const s=St(this.serviceStorage[t]),i=St(this.storage[t]),n=new Map;for(const a of s){if(!i.includes(a)){n.set(a,void 0);continue}P.isEqual(this.serviceStorage[t][a],this.storage[t][a])||this.syncScenePathData(t,a,e)}for(const a of i)s.includes(a)||n.set(a,this.storage[t][a]);if(n.size>5)this.syncStorageScenePath(t,this.storage[t],e);else for(const[a,c]of n.entries())this.syncUpdataScenePath(t,a,c,e)}syncScenePathData(t,e,s=!1){const i=St(this.serviceStorage[t][e]),n=St(this.storage[t][e]),a=new Map;for(const c of i){if(!n.includes(c)){a.set(c,void 0);continue}P.isEqual(this.serviceStorage[t][e][c],this.storage[t][e][c])||a.set(c,this.storage[t][e][c])}for(const c of n)i.includes(c)||a.set(c,this.storage[t][e][c]);if(a.size>5)this.syncStorageKey(t,e,this.storage[t][e],s);else for(const[c,l]of a.entries())this.syncUpdataKey(t,e,c,l,s)}syncUpdataView(t,e,s=!1){var n;Object.keys(this.serviceStorage).length?(s||(e===void 0?delete this.serviceStorage[t]:this.serviceStorage[t]=P.cloneDeep(e)),(n=this.plugin)==null||n.updateAttributes([this.namespace,t],e)):this.syncStorageView(this.storage,s)}syncStorageView(t,e=!1){var s;e||t&&(this.serviceStorage=P.cloneDeep(t)),(s=this.plugin)==null||s.updateAttributes([this.namespace],t)}syncUpdataScenePath(t,e,s,i=!1){var a;Object.keys(this.serviceStorage[t]).length?(i||(s===void 0?delete this.serviceStorage[t][e]:this.serviceStorage[t][e]=s),(a=this.plugin)==null||a.updateAttributes([this.namespace,t,e],s)):this.syncStorageScenePath(t,this.storage[t],i)}syncStorageScenePath(t,e,s=!1){var i;s||e&&(this.serviceStorage[t]=e),(i=this.plugin)==null||i.updateAttributes([this.namespace,t],e)}syncUpdataKey(t,e,s,i,n=!1){var c;Object.keys(this.serviceStorage[t][e]).length?(n||(i===void 0?delete this.serviceStorage[t][e][s]:this.serviceStorage[t][e][s]=i),(c=this.plugin)==null||c.updateAttributes([this.namespace,t,e,s],i)):this.syncStorageKey(t,e,this.storage[t][e],n)}syncStorageKey(t,e,s,i=!1){var n;i||(this.serviceStorage[t][e]=s),(n=this.plugin)==null||n.updateAttributes([this.namespace,t,e],s)}keyTransformWorkId(t){const e=t.split(Rt);return e.length===2?e[1]:t}destroy(){this.removeStorageStateListener(),this.serviceStorage={},this.storage={},this.removeAuthStateListener(),this.authStorage={}}setAuth(t,e){var a;const{writable:s,readOnly:i,renderAuth:n}=t;s===!0||P.isArray(s)&&s.length?this.authStorage.writable=s:delete this.authStorage.writable,i===!0||P.isArray(i)&&i.length?this.authStorage.readOnly=i:delete this.authStorage.readOnly,n&&Object.keys(n).length?this.authStorage.renderAuth=n:delete this.authStorage.renderAuth,e&&((a=this.plugin)==null||a.updateAttributes([this.authSpace],this.authStorage))}dispatchAuth(t,e=!0){const{type:s,writeData:i,viewId:n,renderData:a}=t;switch(s){case z.AuthWriter:{if(i){const{writable:c,readOnly:l}=i;this.setAuth({...this.authStorage,writable:c,readOnly:l},e);break}break}case z.AuthReader:{if(n)if(a&&(a.render||a.hide||a.clear)){const c=this.authStorage.renderAuth||{};c[n]=a,this.setAuth({...this.authStorage,renderAuth:c},e)}else{const c=this.authStorage.renderAuth;c&&(c!=null&&c[n])&&(c==null||delete c[n],this.setAuth({...this.authStorage,renderAuth:c},e))}break}}}addAuthStateListener(t){this.authDisposer=st.autorun(async()=>{const e=this.getAuthSpaceData(),{writable:s,readOnly:i,renderAuth:n}=e;if((!P.isEqual(s,this.authStorage.writable)||!P.isEqual(i,this.authStorage.readOnly))&&(console.log("addAuthStateListener",s,i),this.authStorage.writable=s,this.authStorage.readOnly=i,this.control.renderControl.syncWriteable(s,i)),!P.isEqual(n,this.authStorage.renderAuth)){const a=this.diffAuthFun(this.authStorage.renderAuth||{},n||{});console.log("diffAuthRender",a),this.authStorage.renderAuth=n,t(a)}})}removeAuthStateListener(){this.authDisposer&&this.authDisposer()}diffAuthFun(t,e){const s=St(t),i=St(e),n={};for(const a of i)if(!s.includes(a)||t[a]===void 0){n[a]={newValue:e[a],oldValue:void 0};continue}for(const a of s)if(!P.isEqual(t[a],e[a])){if(!i.includes(a)||e[a]===void 0){n[a]={newValue:void 0,oldValue:t[a]};continue}n[a]={newValue:e[a],oldValue:t[a]}}return n}};M(Et,"namespace","PluginState"),M(Et,"authSpace","PluginAuth"),M(Et,"syncInterval",500);let So=Et;class Yf{constructor(){M(this,"roomMembers",[]);M(this,"onChangeHooks",new Set)}setRoomMembers(o){this.executChangeUidHook(this.roomMembers,o),this.roomMembers=o}executChangeUidHook(o,t){const e={online:t.map(s=>{var i;return((i=s.payload)==null?void 0:i.uid)||s.session}),offline:o.map(s=>{var i;return((i=s.payload)==null?void 0:i.uid)||s.session})};this.onChangeHooks.forEach(s=>s(e))}getAllRoomMembers(){return this.roomMembers}getRoomMember(o){return this.roomMembers.find(t=>{var e;return((e=t.payload)==null?void 0:e.uid)===o})}isOnLine(o){return!this.getRoomMember(o)}onUidChangeHook(o){this.onChangeHooks.add(o)}destroy(){this.onChangeHooks.clear()}}var Bt=(r=>(r[r.Text=1]="Text",r[r.Shape=2]="Shape",r))(Bt||{});const Wf="cursorhover",Uf=20,yt="mainView",Ct=class Ct{createProxy(o){const t=new Proxy(o,{get(e,s,i){const n=Ct.interceptors.hasOwnProperty(s)?Ct.interceptors:e;return Reflect.get(n,s,i)}});return Ct.proxyToRaw.set(t,o),t}};M(Ct,"proxyToRaw",new WeakMap),M(Ct,"interceptors",{entries(...o){return Ct.proxyToRaw.get(this).entries(...o)},forEach(...o){return Ct.proxyToRaw.get(this).forEach(...o)},size(){return Ct.proxyToRaw.get(this).size},get(o){return Ct.proxyToRaw.get(this).get(o)},set(o,t){return Ct.proxyToRaw.get(this).set(o,t)},delete(o,t){return Ct.proxyToRaw.get(this).delete(o)},clear(){return Ct.proxyToRaw.get(this).clear()}});let _t=Ct;class Bf{constructor(o){M(this,"internalMsgEmitter");M(this,"control");M(this,"editors");M(this,"activeId");M(this,"proxyMap");M(this,"taskqueue",new Map);const{control:t,internalMsgEmitter:e}=o;this.control=t,this.internalMsgEmitter=e;const s=new Map;this.proxyMap=new _t;const i=this,n=_t.interceptors.set;_t.interceptors.set=function(c,l){return i.interceptors.set(c,l),n.call(this,c,l)};const a=_t.interceptors.delete;_t.interceptors.delete=function(c,l){return i.interceptors.delete(c,l),a.call(this,c)},this.editors=this.proxyMap.createProxy(s)}get collector(){return this.control.collector}filterEditor(o){const t=new Map;return this.editors.forEach((e,s)=>{e.viewId===o&&t.set(s,e)}),t}get interceptors(){return{set:(o,t)=>{var p,f,I,y,v,m,w,N;if(!this.collector)return!0;const{viewId:e,scenePath:s,canSync:i,canWorker:n,type:a,opt:c,dataType:l}=t;if(!n&&!i)return!0;const u=((p=this.collector)==null?void 0:p.isLocalId(o))?(f=this.collector)==null?void 0:f.transformKey(o):o,d=((I=this.collector)==null?void 0:I.storage[e])&&this.collector.storage[e][s]&&this.collector.storage[e][s][u]||void 0;d?d.toolsType===C.Text&&(n&&(this.control.worker.queryTaskBatchData({workId:o,msgType:z.UpdateNode}).forEach(S=>{var T;(T=this.control.worker)==null||T.taskBatchData.delete(S)}),(w=this.control.worker)==null||w.taskBatchData.add({workId:o,msgType:z.UpdateNode,dataType:l||F.Local,toolsType:C.Text,opt:c,viewId:e,scenePath:s,willRefresh:!0}),(N=this.control.worker)==null||N.runAnimation()),i&&oe(()=>{var S;(S=this.collector)==null||S.dispatch({type:z.UpdateNode,workId:o,toolsType:C.Text,opt:c,viewId:e,scenePath:s})},this.control.worker.maxLastSyncTime)):a===Bt.Text&&(i&&((y=this.collector)==null||y.dispatch({type:c.text&&z.FullWork||z.CreateWork,workId:o,toolsType:C.Text,opt:c,isSync:!0,viewId:e,scenePath:s})),n&&((v=this.control.worker)==null||v.taskBatchData.add({workId:o,msgType:c.text&&z.FullWork||z.CreateWork,dataType:l||F.Local,toolsType:C.Text,opt:c,viewId:e,scenePath:s,willRefresh:!0}),(m=this.control.worker)==null||m.runAnimation()))},delete:o=>{var a,c;if(!this.collector)return!0;const t=this.editors.get(o);if(!t)return!0;const{viewId:e,scenePath:s,canSync:i,canWorker:n}=t;if(!n&&!i)return!0;n&&((a=this.control.worker)==null||a.taskBatchData.add({workId:o,toolsType:C.Text,msgType:z.RemoveNode,dataType:F.Local,viewId:e,scenePath:s,willRefresh:!0}),(c=this.control.worker)==null||c.runAnimation()),i&&oe(()=>{var l;(l=this.collector)==null||l.dispatch({type:z.RemoveNode,removeIds:[o],toolsType:C.Text,viewId:e,scenePath:s})},this.control.worker.maxLastSyncTime)},clear(){return!0}}}computeTextActive(o,t){var i,n,a,c;const e=(i=this.control.viewContainerManager)==null?void 0:i.transformToScenePoint(o,t),s=(n=this.control.viewContainerManager)==null?void 0:n.getCurScenePath(t);t&&s&&((a=this.control.worker)==null||a.taskBatchData.add({msgType:z.GetTextActive,dataType:F.Local,op:e,viewId:t,scenePath:s}),(c=this.control.worker)==null||c.runAnimation())}checkEmptyTextBlur(){var t;let o=this.activeId;for(const[e,s]of this.editors.entries())if(s.opt.uid&&s.opt.uid===((t=this.collector)==null?void 0:t.uid)){o=e;break}if(o){const e=this.editors.get(o);(e==null?void 0:e.opt.text)&&(e==null?void 0:e.opt.text.replace(/\s*,/g,""))?this.unActive(o):this.delete(o,!0,!0)}}onCameraChange(o,t){var e,s;for(const[i,n]of this.editors.entries())if(n.viewId===t){const{boxPoint:a,boxSize:c}=n.opt,l=a&&((e=this.control.viewContainerManager)==null?void 0:e.transformToOriginPoint(a,n.viewId)),h=(s=this.control.viewContainerManager)==null?void 0:s.getCurScenePath(t);if(h&&t){const u={x:l&&l[0]||0,y:l&&l[1]||0,w:c&&c[0]||0,h:c&&c[1]||0,opt:n.opt,scale:o.scale,type:Bt.Text,viewId:t,scenePath:h,canWorker:!1,canSync:!1};this.editors.set(i,u),this.control.viewContainerManager.setActiveTextEditor(t,this.activeId)}}}onServiceDerive(o){var f,I;const{workId:t,opt:e,msgType:s,viewId:i,scenePath:n,dataType:a}=o;if(!t||!i||!n)return;const c=t.toString();if(s===z.RemoveNode){this.delete(c,!0,!0);return}const{boxPoint:l,boxSize:h}=e,u=l&&((f=this.control.viewContainerManager)==null?void 0:f.transformToOriginPoint(l,i)),d=this.control.viewContainerManager.getView(i),p={x:u&&u[0]||0,y:u&&u[1]||0,w:h&&h[0]||0,h:h&&h[1]||0,opt:e,type:Bt.Text,canWorker:!0,canSync:!1,dataType:a,scale:((I=d==null?void 0:d.cameraOpt)==null?void 0:I.scale)||1,viewId:i,scenePath:n};this.editors.set(c,p),a===F.Service&&e.workState===L.Done&&this.activeId===c&&(this.activeId=void 0),this.control.viewContainerManager.setActiveTextEditor(i,this.activeId)}updateForViewEdited(o,t){var s;this.editors.set(o,t);const e=(s=this.taskqueue.get(o))==null?void 0:s.resolve;e&&e(t)}active(o){var e;const t=this.editors.get(o);t&&t.viewId&&(t.opt.workState=L.Start,t.opt.uid=(e=this.collector)==null?void 0:e.uid,this.activeId=o,t.canWorker=!0,t.canSync=!0,this.editors.set(o,t),this.control.viewContainerManager.setActiveTextEditor(t.viewId,this.activeId))}unActive(o){const t=this.editors.get(o);t&&t.viewId&&(t.opt.workState=L.Done,t.opt.uid=void 0,t.canWorker=!0,t.canSync=!0,this.editors.set(o,t),this.activeId=void 0,this.control.viewContainerManager.setActiveTextEditor(t.viewId,this.activeId))}createTextForMasterController(o,t){var n;const{workId:e,isActive:s,...i}=o;t&&this.internalMsgEmitter.emit("addUndoTicker",t,i.viewId),i.opt.uid=(n=this.collector)==null?void 0:n.uid,s&&(this.activeId=e),i.dataType=F.Local,i.canWorker=!0,i.canSync=!0,this.editors.set(e,i),this.control.viewContainerManager.setActiveTextEditor(i.viewId,this.activeId)}updateTextForMasterController(o,t){var n;const{workId:e,...s}=o;t&&this.internalMsgEmitter.emit("addUndoTicker",t,s.viewId);const i=this.editors.get(e)||{};s.opt&&(s.opt.uid=(n=this.collector)==null?void 0:n.uid),s.dataType=F.Local,this.editors.set(e,{...i,...s}),this.control.viewContainerManager.setActiveTextEditor(s.viewId,this.activeId)}async updateTextControllerWithEffectAsync(o,t){var h;const{workId:e,...s}=o;t&&this.internalMsgEmitter.emit("addUndoTicker",t,s.viewId);const i=this.editors.get(e)||{};s.opt&&(s.opt.uid=(h=this.collector)==null?void 0:h.uid),s.dataType=F.Local;const n={...i,...s};if(this.editors.set(e,n),this.control.viewContainerManager.setActiveTextEditor(s.viewId,this.activeId),this.taskqueue.has(e)){const u=this.taskqueue.get(e);return u&&(u.clocker&&clearTimeout(u.clocker),this.taskqueue.delete(e)),await this.updateTextControllerWithEffectAsync(o)}const a=setTimeout(()=>{var d;const u=(d=this.taskqueue.get(e))==null?void 0:d.resolve;u&&u(n)},50),c=await new Promise(u=>{this.taskqueue.set(e,{resolve:u,clocker:a})}),l=this.taskqueue.get(e);return l&&(l.clocker&&clearTimeout(l.clocker),this.taskqueue.delete(e)),c}updateTextForWorker(o,t){const{workId:e,isActive:s,...i}=o,a={...this.editors.get(e)||{},...i};if(s){a.canWorker=!1,a.canSync=!1,this.editors.set(e,a),this.active(e);return}this.editors.set(e,a),this.control.viewContainerManager.setActiveTextEditor(i.viewId,this.activeId),t&&this.internalMsgEmitter.emit("addUndoTicker",t,i.viewId)}get(o){return this.editors.get(o)}delete(o,t,e){const s=this.editors.get(o);if(s){const i=s.viewId;s.canSync=t,s.canWorker=e,this.editors.delete(o),this.activeId===o&&(this.activeId=void 0),this.control.viewContainerManager.setActiveTextEditor(i,this.activeId)}}deleteBatch(o,t,e){const s=new Set;for(const i of o){const n=this.editors.get(i);if(n){const a=n.viewId;n.canSync=t,n.canWorker=e,this.editors.delete(i),this.activeId===i&&(this.activeId=void 0),s.add(a)}}for(const i of s)this.control.viewContainerManager.setActiveTextEditor(i,this.activeId)}clear(o,t){this.editors.forEach((e,s)=>{e.viewId===o&&(t&&(e.canSync=!1),e.canWorker=!1,this.editors.delete(s))}),this.activeId=void 0,this.control.viewContainerManager.setActiveTextEditor(o,this.activeId)}destory(){this.editors.clear(),this.activeId=void 0}}class Ff{constructor(o){M(this,"expirationTime",xt.cursor.expirationTime);M(this,"internalMsgEmitter");M(this,"control");M(this,"eventName","applianc-cursor");M(this,"displayer");M(this,"roomMember");M(this,"animationId");M(this,"maxLastSyncTime",xt.syncOpt.interval);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);M(this,"eventCollector");var s,i;const{control:t,internalMsgEmitter:e}=o;this.internalMsgEmitter=e,this.control=t,this.roomMember=t.roomMember,this.maxLastSyncTime=((i=(s=this.control.pluginOptions)==null?void 0:s.syncOpt)==null?void 0:i.interval)||this.maxLastSyncTime}activeCollector(){this.control.plugin&&(this.displayer=this.control.room||this.control.play,this.displayer.addMagixEventListener(this.eventName,this.mainMagixEventListener.bind(this)))}mainMagixEventListener(o){var a;const{event:t,payload:e}=o;if(t!==this.eventName)return;const{uid:s,op:i,type:n}=e;if(((a=this.control.collector)==null?void 0:a.uid)!==s&&n===ke.Cursor&&(i!=null&&i.length)){const c=this.willConsumeEventWorkers.get(s)||[];for(const l of i){const{viewId:h}=l;P.isNumber(l.consumPoint[0])&&P.isNumber(l.consumPoint[1])&&(l.consumPoint=this.control.viewContainerManager.transformToOriginPoint(l.consumPoint,h)),c.unshift({...l,timestamp:Date.now()})}this.willConsumeEventWorkers.set(s,c),this.runAnimation()}}onFocusViewChange(){this.checkDrawWorks(),this.runAnimation()}updateRoomMembers(o){const{offline:t}=o;for(const e of this.cursorInfoMap.keys())e&&t.includes(e)&&this.cursorInfoMap.delete(e)}getKey(o,t){return`${o}${Rt}${t}`}getUidAndviewId(o){const[t,e]=o.split(Rt);return{uid:t,viewId:e}}runAnimation(){this.animationId||(this.animationId=requestAnimationFrame(this.animationCursor.bind(this)))}checkDrawWorks(){var t;const o=this.control.viewContainerManager.focuedViewId;for(const[e,s]of this.animationDrawWorkers.entries()){const{viewId:i,uid:n}=this.getUidAndviewId(e);n!==((t=this.control.collector)==null?void 0:t.uid)&&i!==o&&s.workState===L.Done&&(s.consumPoint=[void 0,void 0])}}animationCursor(){this.animationId=void 0;const o=Date.now();for(const[e,s]of this.animationDrawWorkers.entries()){const{uid:i,viewId:n}=this.getUidAndviewId(e),a=this.roomMember.getRoomMember(i);if(!a){this.animationDrawWorkers.delete(e);continue}const{consumPoint:c,timestamp:l,workState:h}=s,u=this.cursorInfoMap.get(n)||new Map;c&&P.isNumber(c[0])&&P.isNumber(c[1])&&l+this.expirationTime>o?u.set(a.memberId,{x:c[0],y:c[1],roomMember:a,timestamp:l,type:1,workState:h}):u.delete(a.memberId),u.size?this.cursorInfoMap.set(n,u):this.cursorInfoMap.delete(n),this.animationDrawWorkers.delete(e)}const t=new Set;for(const[e,s]of this.cursorInfoMap.entries())if(s)for(const[i,n]of s.entries())n.type===1&&n.workState!==L.Done&&t.add(i);else this.cursorInfoMap.delete(e);for(const[e,s]of this.willConsumeEventWorkers.entries()){const i=this.roomMember.getRoomMember(e);if(P.isNumber(i==null?void 0:i.memberId)&&!t.has(i.memberId)){const n=s.pop();n?this.animationEventWorkers.set(e,n):this.willConsumeEventWorkers.delete(e)}}for(const[e,s]of this.animationEventWorkers.entries()){const i=this.roomMember.getRoomMember(e);if(!i){this.animationEventWorkers.delete(e);continue}const{viewId:n,consumPoint:a,timestamp:c}=s,l=this.cursorInfoMap.get(n)||new Map;a&&P.isNumber(a[0])&&P.isNumber(a[1])&&c+this.expirationTime>o?l.set(i.memberId,{x:a[0],y:a[1],roomMember:i,timestamp:c,type:0}):l.delete(i.memberId),l.size?this.cursorInfoMap.set(n,l):this.cursorInfoMap.delete(n),this.animationEventWorkers.delete(e)}for(const e of this.doneRenderCursorInfoMap.keys())this.cursorInfoMap.has(e)||(this.doneRenderCursorInfoMap.delete(e),this.internalMsgEmitter.emit([Z.Cursor,e],[]));for(const[e,s]of this.cursorInfoMap.entries())if(s!=null&&s.size){const i=[];for(const[a,c]of s.entries()){const{timestamp:l,...h}=c;l+this.expirationTime>o?i.push(h):(s.delete(a),s.size===0&&(this.cursorInfoMap.delete(e),this.doneRenderCursorInfoMap.delete(e),this.internalMsgEmitter.emit([Z.Cursor,e],[])))}const n=this.doneRenderCursorInfoMap.get(e);P.isEqual(n,i)||(this.doneRenderCursorInfoMap.set(e,i),this.internalMsgEmitter.emit([Z.Cursor,e],i))}else this.cursorInfoMap.delete(e),this.doneRenderCursorInfoMap.delete(e),this.internalMsgEmitter.emit([Z.Cursor,e],[]);(this.willConsumeEventWorkers.size||this.cursorInfoMap.size)&&this.runAnimation()}sendEvent(o,t){if(this.displayer&&st.isRoom(this.displayer)){const e=P.isNumber(o[0])&&P.isNumber(o[1])&&this.control.viewContainerManager.transformToScenePoint(o,t)||[void 0,void 0];this.willSendEventWorkers.push({consumPoint:e,viewId:t}),this.sendEventTimerId||(this.sendEventTimerId=setTimeout(()=>{this.dispatchMagixEvent()},this.maxLastSyncTime))}}dispatchMagixEvent(){var o;this.displayer.dispatchMagixEvent(this.eventName,{type:ke.Cursor,op:P.cloneDeep(this.willSendEventWorkers),uid:(o=this.control.collector)==null?void 0:o.uid}),this.willSendEventWorkers.length=0,this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0)}collectServiceCursor(o){var n;const{op:t,uid:e,workState:s,viewId:i}=o;if(e&&t&&s&&i){const a=this.roomMember.getRoomMember(e);if(!a||e===((n=this.control.collector)==null?void 0:n.uid))return;const c=this.getKey(e,i);let l=[void 0,void 0];if(P.isNumber(t[0])&&P.isNumber(t[1])){const[u,d]=this.control.viewContainerManager.transformToOriginPoint(t,i);l=[u,d]}if(s===L.Start){for(const u of this.cursorInfoMap.values())if(u!=null&&u.size)for(const d of u.keys())d===a.memberId&&u.delete(d)}const h={consumPoint:l,workState:s,viewId:i,timestamp:Date.now()};if(s===L.Start||s===L.Done){const u=this.willConsumeEventWorkers.get(e);s===L.Start&&u&&this.willConsumeEventWorkers.delete(e),u&&s===L.Done&&(h.timestamp=h.timestamp-this.expirationTime)}this.animationDrawWorkers.set(c,h),this.runAnimation()}}unabled(){var o;this.displayer&&st.isRoom(this.displayer)&&(this.willSendEventWorkers.length=0,this.displayer.dispatchMagixEvent(this.eventName,{type:ke.Cursor,op:[{viewId:this.control.viewContainerManager.focuedViewId,consumPoint:[void 0,void 0]}],uid:(o=this.control.collector)==null?void 0:o.uid}),this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0))}clearViewCursor(o){var t,e,s;for(const[i]of this.animationDrawWorkers.entries()){const{uid:n}=this.getUidAndviewId(i);n===((t=this.control.collector)==null?void 0:t.uid)&&o===o&&this.animationDrawWorkers.delete(i)}for(const[i]of this.willConsumeEventWorkers.entries())i===((e=this.control.collector)==null?void 0:e.uid)&&this.willConsumeEventWorkers.delete(i);for(const[i]of this.animationEventWorkers.entries())i===((s=this.control.collector)==null?void 0:s.uid)&&this.animationEventWorkers.delete(i);for(const[i]of this.cursorInfoMap.entries())i===i&&(this.cursorInfoMap.delete(i),this.doneRenderCursorInfoMap.delete(i),this.internalMsgEmitter.emit([Z.Cursor,i],[]))}stopAnimation(){this.animationDrawWorkers.clear(),this.willConsumeEventWorkers.clear(),this.cursorInfoMap.clear()}destroy(){var o;(o=this.displayer)==null||o.removeMagixEventListener(this.eventName),this.stopAnimation()}}class Lt{constructor(){M(this,"useEmtMsg");M(this,"emtType");M(this,"control");M(this,"mainEngine")}static dispatch(o,t,e){var s;(s=mt.InternalMsgEmitter)==null||s.emit([o,t],e)}get serviceColloctor(){return this.control.collector}registerForMainEngine(o,t){return this.emtType=o,this.control=t,this.mainEngine=t.worker,this.mainEngine.internalMsgEmitter.on([this.emtType,this.emitEventType],this.collect.bind(this)),this}destroy(){this.emtType&&this.mainEngine&&this.mainEngine.internalMsgEmitter.off([this.emtType,this.emitEventType],this.collect.bind(this))}collectForLocalWorker(o,t){var e,s,i;for(const[n,a]of o)(e=this.mainEngine)==null||e.queryTaskBatchData(a).forEach(c=>{var l;(l=this.mainEngine)==null||l.taskBatchData.delete(c)}),(s=this.mainEngine)==null||s.taskBatchData.add(n);if(t){this.mainEngine.consume();return}(i=this.mainEngine)==null||i.runAnimation()}collectForServiceWorker(o){oe(()=>{o.forEach(t=>{var e;(e=this.serviceColloctor)==null||e.dispatch(t)})},this.mainEngine.maxLastSyncTime)}pause(){var o;if(this.lastEmtData){this.useEmtMsg=!0;const t={...this.lastEmtData,workState:L.Done};this.collect(t,!0),(o=mt.InternalMsgEmitter)==null||o.emit(R.ActiveMethod,!1)}}recover(){var o;this.useEmtMsg&&mt.InternalMsgEmitter.hasListeners(R.ActiveMethod)&&((o=mt.InternalMsgEmitter)==null||o.emit(R.ActiveMethod,!0))}}class Hf extends Lt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.CopyNode)}collect(t){var c;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,viewId:s}=t,i=this.control.viewContainerManager.getView(s);if(!(i!=null&&i.displayer))return;const n=i.focusScenePath,a=Date.now();this.mainEngine.internalMsgEmitter.emit("addUndoTicker",a,s);for(const l of e){const h=l.toString(),d=this.serviceColloctor.isLocalId(h)?this.serviceColloctor.transformKey(l):h,p=(c=this.serviceColloctor.getStorageData(s,n))==null?void 0:c[d];if(p){if(l===H){const f=p&&this.copySelector({viewId:s,store:p});f&&this.pasteSelector({...f,viewId:s,scenePath:n,undoTickerId:a});break}if(p.toolsType===C.Text&&p.opt&&p.opt.workState&&p.opt.workState!==L.Done){const f=p&&this.copyText({viewId:s,store:p});f&&this.pasteText({...f,viewId:s,scenePath:n,key:d,store:p,undoTickerId:a});break}}}}copyText(t){const{viewId:e,store:s}=t,i=this.control.viewContainerManager.getView(e);if(!this.serviceColloctor||!i)return;const n=i==null?void 0:i.cameraOpt,a=n&&[n.centerX,n.centerY],c=s.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(t){var y,v;const{bgCenter:e,textCenter:s,store:i,key:n,viewId:a,scenePath:c,undoTickerId:l}=t,h=this.control.viewContainerManager.getView(a);if(!this.serviceColloctor||!h)return;const u=Math.floor(Math.random()*30+1),d=((y=h.cameraOpt)==null?void 0:y.scale)||1,p=e&&s&&[e[0]-s[0]+u,e[1]-s[1]+u]||[u/d,u/d],I=(this.serviceColloctor.isLocalId(n)?n:this.serviceColloctor.getLocalId(n.toString()))+"-"+l;if(i.toolsType===C.Text&&i.opt){const m=i.opt;if(m&&m.boxPoint&&m.text){m.workState=L.Done;const w=m.boxPoint;m.boxPoint=[w[0]+p[0],w[1]+p[1]],m.workState=L.Done;const N=this.control.viewContainerManager.transformToOriginPoint(m.boxPoint,a);this.control.textEditorManager.createTextForMasterController({workId:I,x:N[0],y:N[1],opt:m,scale:((v=h.cameraOpt)==null?void 0:v.scale)||1,type:Bt.Text,isActive:!1,viewId:a,scenePath:c}),this.collectForServiceWorker([{...i,opt:m,type:z.FullWork,workId:I,viewId:a,scenePath:c}])}}}copySelector(t){var I,y,v,m,w,N,S,T,x;const{viewId:e,store:s}=t,i=this.control.viewContainerManager.getView(e),n=s.selectIds;if(!this.serviceColloctor||!(n!=null&&n.length)||!i)return;const a=new Map,c={offset:{x:0,y:0},cameraOpt:{centerX:((I=i.cameraOpt)==null?void 0:I.centerX)||0,centerY:((y=i.cameraOpt)==null?void 0:y.centerY)||0,scale:((v=i.cameraOpt)==null?void 0:v.scale)||1}},l=this.control.hasOffscreenCanvas()&&((m=i.displayer.canvasBgRef.current)==null?void 0:m.getBoundingClientRect())||((w=i.displayer.canvasContainerRef.current)==null?void 0:w.getBoundingClientRect()),h=(S=(N=i.displayer)==null?void 0:N.floatBarRef.current)==null?void 0:S.getBoundingClientRect(),u=l&&[l.x+l.width/2,l.y+l.height/2],d=h&&[h.x+h.width/2,h.y+h.height/2],p=u&&i.viewData&&i.viewData.convertToPointInWorld({x:u[0],y:u[1]}),f=d&&i.viewData&&i.viewData.convertToPointInWorld({x:d[0],y:d[1]});p&&f&&(c.offset={x:p.x-f.x,y:p.y-f.y});for(const b of n){const A=(x=(T=this.serviceColloctor)==null?void 0:T.getStorageData(i.id,i.focusScenePath))==null?void 0:x[b];A&&a.set(b,A)}return{copyStores:a,copyCoordInfo:c}}pasteSelector(t){var I;const{copyStores:e,copyCoordInfo:s,viewId:i,scenePath:n,undoTickerId:a}=t,c=this.control.viewContainerManager.getView(i);if(!e.size||!this.serviceColloctor||!c)return;const{offset:l,cameraOpt:h}=s,u=Math.floor(Math.random()*30+1),d=[l.x+u,l.y+u],p=[],f=[];for(const[y,v]of e.entries()){const w=(this.serviceColloctor.isLocalId(y)?y:this.serviceColloctor.getLocalId(y.toString()))+"-"+a,N={useAnimation:!1};if(v.toolsType===C.Text&&v.opt){const S=v.opt;if(S&&S.boxPoint&&S.text){S.workState=L.Done;const T=S.boxPoint;S.boxPoint=[T[0]+d[0],T[1]+d[1]],S.workState=L.Done;const x=this.control.viewContainerManager.transformToOriginPoint(S.boxPoint,i);this.control.textEditorManager.createTextForMasterController({workId:w,x:x[0],y:x[1],opt:S,scale:((I=c.cameraOpt)==null?void 0:I.scale)||1,type:Bt.Text,isActive:!1,viewId:i,scenePath:n})}f.push({...v,opt:S,type:z.FullWork,workId:w,viewId:i,scenePath:n});continue}if(v.toolsType===C.Image&&(v.opt.uuid=w,v.opt.centerX=v.opt.centerX+d[0],v.opt.centerY=v.opt.centerY+d[1]),v.ops){const S=Te(v.ops).map((x,b)=>{const A=b%3;return A===0?x+d[0]:A===1?x+d[1]:x}),T=zt(S);v.ops=T}f.push({...v,updateNodeOpt:N,type:z.FullWork,workId:w,viewId:i,scenePath:n}),p.push([{...v,updateNodeOpt:N,workId:w,msgType:z.FullWork,dataType:F.Local,emitEventType:R.CopyNode,willSyncService:!1,willRefresh:!0,viewId:i},{workId:w,msgType:z.FullWork,emitEventType:R.CopyNode}])}p.length&&this.collectForLocalWorker(p),f.length&&this.collectForServiceWorker(f)}}function De(r,o,t){return"#"+((r<<16)+(o<<8)+t).toString(16).padStart(6,"0")}function gt(r,o=1){return"rgba("+parseInt("0x"+r.slice(1,3))+","+parseInt("0x"+r.slice(3,5))+","+parseInt("0x"+r.slice(5,7))+","+o+")"}function Oe(r,o,t,e=1){return`rgba(${r},${o},${t},${e})`}function co(r){const o=r.split(","),t=parseInt(o[0].split("(")[1]),e=parseInt(o[1]),s=parseInt(o[2]),i=Number(o[3].split(")")[0]);return[De(t,e,s),i]}function Re(r){const o=r.split(","),t=parseInt(o[0].split("(")[1]),e=parseInt(o[1]),s=parseInt(o[2]),i=Number(o[3].split(")")[0]);return[t,e,s,i]}function Ye(r){return r==="transparent"}class Qf extends Lt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.SetColorNode);M(this,"undoTickerId")}setTextColor(t,e,s,i){const{fontColor:n,fontBgColor:a}=s;e.opt&&(n&&(e.opt.fontColor=n),a&&(e.opt.fontBgColor=a),this.control.textEditorManager.updateTextForMasterController({workId:t,opt:e.opt,viewId:i,canSync:!0,canWorker:!0}))}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,strokeColor:s,fillColor:i,fontColor:n,fontBgColor:a,viewId:c,workState:l,thickness:h,strokeType:u}=t,d=this.control.viewContainerManager.getView(c);if(!(d!=null&&d.displayer))return;const p=d.focusScenePath,f=[...e],I=this.serviceColloctor.storage,y=[],v={};for((l===L.Start||!this.undoTickerId&&l===L.Done)&&(this.undoTickerId=Date.now(),this.mainEngine.internalMsgEmitter.emit("addUndoTicker",this.undoTickerId,c));f.length;){const m=f.pop();if(!m)continue;const w=m.toString(),N=this.serviceColloctor.isLocalId(w),S=N?this.serviceColloctor.transformKey(m):w;let T=w;!N&&this.serviceColloctor.isOwn(T)&&(T=this.serviceColloctor.getLocalId(T));const x=I[c][p][S]||void 0;if(x){const b=x.updateNodeOpt||{};if(n||a){if(n){b.fontColor=n;const[O,j,E,D]=Re(n);v.textColor=[O,j,E],v.textOpacity=D}if(a)if(b.fontBgColor=Ye(a)?"transparent":a,Ye(a))v.textBgColor=void 0,v.textBgOpacity=void 0;else{const[O,j,E,D]=Re(a);v.textBgColor=[O,j,E],v.textBgOpacity=D}if(x.toolsType===C.Text&&x.opt&&l!==L.Start){this.setTextColor(T,Vt(x),b,c),l===L.Done&&(this.undoTickerId=void 0);continue}}if(s){b.strokeColor=s;const[O,j,E,D]=Re(s);v.strokeColor=[O,j,E],v.strokeOpacity=D}if(i)if(b.fillColor=Ye(i)?"transparent":i,Ye(i))v.fillColor=void 0,v.fillOpacity=void 0;else{const[O,j,E,D]=Re(i);v.fillColor=[O,j,E],v.fillOpacity=D}h&&(b.thickness=h,v.strokeWidth=h),u&&(b.strokeType=u,v.strokeType=u);const A={workId:T,msgType:z.UpdateNode,dataType:F.Local,updateNodeOpt:b,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,textUpdateForWoker:!0,viewId:c};y.push([A,{workId:T,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}}y.length&&(l===L.Done&&(this.undoTickerId=void 0),this.collectForLocalWorker(y)),Object.keys(v).length&&setTimeout(()=>{var m;(m=this.control.room)==null||m.setMemberState(v)},0)}}class Vf extends Lt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.ZIndexNode);M(this,"zIndexMap",new Map)}clearZIndex(t){this.zIndexMap.delete(t)}getMinZIndex(t){var e;return((e=this.zIndexMap.get(t))==null?void 0:e.min)||0}getMaxZIndex(t){var e;return((e=this.zIndexMap.get(t))==null?void 0:e.max)||0}setMaxZIndex(t,e){const s=this.getMinZIndex(e);this.zIndexMap.set(e,{min:s,max:t})}setMinZIndex(t,e){const s=this.getMaxZIndex(e);this.zIndexMap.set(e,{min:t,max:s})}addMaxLayer(t){const e=this.getMaxZIndex(t)+1;this.setMaxZIndex(e,t)}addMinLayer(t){const e=this.getMinZIndex(t)-1;this.setMinZIndex(e,t)}correct(t){const e=t.sort((s,i)=>s[1]-i[1]);for(let s=1;s<e.length;s++){const i=e[s][1],n=e[s-1][1];i<=n&&(e[s][1]=n+1)}return e}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,layer:s,viewId:i}=t,n=this.control.viewContainerManager.getView(i);if(!(n!=null&&n.displayer))return;const a=n.focusScenePath,c=[...e],l=this.serviceColloctor.storage,h=[],u=[];for(;c.length;){const p=c.pop();if(!p)continue;const f=p.toString(),I=this.serviceColloctor.isLocalId(f),y=I?this.serviceColloctor.transformKey(p):f;let v=f;!I&&this.serviceColloctor.isOwn(v)&&(v=this.serviceColloctor.getLocalId(v));const m=Vt(l[i][a][y]);let w;if(m&&v===H){if(m.selectIds){u.push(...m.selectIds),u.sort((x,b)=>{var j,E,D,_;const A=((E=(j=l[d(x,this.serviceColloctor)])==null?void 0:j.opt)==null?void 0:E.zIndex)||0,O=((_=(D=l[d(x,this.serviceColloctor)])==null?void 0:D.opt)==null?void 0:_.zIndex)||0;return A>O?1:x<b?-1:0});const N=m.updateNodeOpt||{};N.zIndexLayer=s;const S={workId:p,msgType:z.UpdateNode,dataType:F.Local,updateNodeOpt:N,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:i},T=new Map;s===ee.Top?(this.addMaxLayer(i),w=this.getMaxZIndex(i)):(this.addMinLayer(i),w=this.getMinZIndex(i)),u.forEach(x=>{var j,E,D;const b=(j=this.serviceColloctor)==null?void 0:j.isLocalId(x);let A=b&&((E=this.serviceColloctor)==null?void 0:E.transformKey(x))||x;const O=l[i][a][A];!b&&((D=this.serviceColloctor)!=null&&D.isOwn(A))&&(A=this.serviceColloctor.getLocalId(A)),N.zIndex=w,O!=null&&O.opt&&(O.opt.zIndex=w),O!=null&&O.opt&&T.set(A,{updateNodeOpt:O.updateNodeOpt,opt:O.opt})}),S.selectStore=T,S.willSerializeData=!0,h.push([S,{workId:p,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}continue}}h.length&&this.collectForLocalWorker(h);function d(p,f){return f.isLocalId(p)&&f.transformKey(p)||p}}}class $f extends Lt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.TranslateNode);M(this,"cachePosition")}collect(t,e){var f;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:s,position:i,workState:n,viewId:a}=t;this.lastEmtData=t;const c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,h=[...s],u=(f=this.serviceColloctor)==null?void 0:f.storage,d=[],p=n===L.Start&&Date.now()||void 0;for(p&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,a);h.length;){const I=h.pop();if(!I)continue;const y=I.toString(),v=this.serviceColloctor.isLocalId(y),m=v&&this.serviceColloctor.transformKey(I)||y;let w=y;!v&&this.serviceColloctor.isOwn(w)&&(w=this.serviceColloctor.getLocalId(w));const N=u[a][l][m];if(N&&w===H){if(N.selectIds){const S=this.control.viewContainerManager.transformToScenePoint([i.x,i.y],a);if(n===L.Start&&(this.cachePosition=S),this.cachePosition){const T=N.updateNodeOpt||{};T.translate=[S[0]-this.cachePosition[0],S[1]-this.cachePosition[1]],T.workState=n;const x={workId:I,msgType:z.UpdateNode,dataType:F.Local,updateNodeOpt:T,emitEventType:this.emitEventType,willSyncService:!0,textUpdateForWoker:!0,viewId:a};n===L.Done&&(x.textUpdateForWoker=!0,x.willSerializeData=!0,this.cachePosition=void 0),d.push([x,{workId:I,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}}continue}}n===L.Start?this.mainEngine.unWritable():n===L.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length&&this.collectForLocalWorker(d,e)}}class Gf extends Lt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.DeleteNode)}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,viewId:s}=t,i=this.control.viewContainerManager.getView(s);if(!(i!=null&&i.displayer))return;const n=i.focusScenePath,a=this.serviceColloctor.storage,c=[...e],l=[],h=[],u=Date.now();for(;c.length;){const d=c.pop();if(!d)continue;const p=d.toString(),f=this.serviceColloctor.isLocalId(p),I=f?this.serviceColloctor.transformKey(d):p,y=a[s][n][I];if(y){let v=p;if(!f&&this.serviceColloctor.isOwn(v)&&(v=this.serviceColloctor.getLocalId(v)),y.toolsType===C.Text){this.control.textEditorManager.delete(v,!0,!0);continue}h.push(v)}}h.length&&(l.push([{msgType:z.RemoveNode,emitEventType:R.DeleteNode,removeIds:h,dataType:F.Local,willSyncService:!0,willRefresh:!0,viewId:s},void 0]),this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,s),this.collectForLocalWorker(l))}}class Zf extends Lt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.ScaleNode);M(this,"targetText",new Map);M(this,"cacheTextInfo",new Map)}async setTextStyle(t,e,s){const i=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:t,opt:e,viewId:s,canSync:!1,canWorker:!1});return{key:t,textInfo:i}}async collect(t,e){var m,w,N,S,T;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:s,workState:i,viewId:n,originPoint:a,scenePoint:c,dir:l,scale:h,translate:u}=t;this.lastEmtData=t;const d=this.control.viewContainerManager.getView(n);if(!(d!=null&&d.displayer))return;const p=d.focusScenePath,f=[...s],I=(m=this.serviceColloctor)==null?void 0:m.storage,y=[],v=i===L.Start&&Date.now()||void 0;for(v&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",v,n);f.length;){const x=f.pop();if(!x)continue;const b=x.toString(),A=this.serviceColloctor.isLocalId(b),O=A&&this.serviceColloctor.transformKey(x)||b;let j=b;!A&&this.serviceColloctor.isOwn(j)&&(j=this.serviceColloctor.getLocalId(j));const E=I[n][p][O];if(E&&j===H&&E.selectIds){const D=E.updateNodeOpt||{};if(D.dir=l,D.originPoint=a,D.scenePoint=c,D.workState=i,D.scale=h,D.translate=u,i===L.Start){this.cacheTextInfo.clear();for(const nt of E.selectIds){const tt=(w=this.serviceColloctor)==null?void 0:w.isLocalId(nt),V=tt&&((N=this.serviceColloctor)==null?void 0:N.transformKey(nt))||nt;let K=V;!tt&&((S=this.serviceColloctor)!=null&&S.isOwn(V))&&(K=this.serviceColloctor.getLocalId(V));const $=this.control.textEditorManager.get(K);$&&i===L.Start&&this.targetText.set(K,Vt($))}}if(this.targetText.size&&i!==L.Start&&h){const nt=[];for(const[V,K]of this.targetText.entries()){const{opt:$}=K,G=Math.floor($.fontSize*h[0]),J=this.cacheTextInfo.get(V),rt=!J&&$.fontSize!==G||J&&J.fontSize!==G||!1,It=(T=this.control.textEditorManager.get(V))==null?void 0:T.opt;if(rt&&It&&$.boxSize&&$.boxPoint){const ot=this.setTextStyle(V,{...It,fontSize:G},n);nt.push(ot)}}const tt=await Promise.all(nt);for(const V of tt)if(V){const{key:K,textInfo:$}=V;this.cacheTextInfo.set(K,{fontSize:$.opt.fontSize,boxSize:$.opt.boxSize,boxPoint:$.opt.boxPoint})}D.textInfos=this.cacheTextInfo}const _={workId:x,msgType:z.UpdateNode,dataType:F.Local,updateNodeOpt:D,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:n};i===L.Done&&(_.willSerializeData=!0,this.targetText.clear()),y.push([_,{workId:x,msgType:z.UpdateNode,emitEventType:this.emitEventType}]);continue}}i===L.Start?this.mainEngine.unWritable():i===L.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),y.length&&this.collectForLocalWorker(y,e)}}class qf extends Lt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.RotateNode);M(this,"cacheOriginRotate",0)}collect(t,e){var f,I,y,v,m;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:s,angle:i,workState:n,viewId:a}=t;this.lastEmtData=t;const c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,h=[...s],u=(f=this.serviceColloctor)==null?void 0:f.storage,d=[],p=n===L.Start&&Date.now()||void 0;for(p&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,a);h.length;){const w=h.pop();if(!w)continue;const N=w.toString(),S=this.serviceColloctor.isLocalId(N),T=S&&this.serviceColloctor.transformKey(w)||N;let x=N;!S&&this.serviceColloctor.isOwn(x)&&(x=this.serviceColloctor.getLocalId(x));const b=u[a][l][T];if(b&&x===H){if(((I=b.selectIds)==null?void 0:I.length)===1){const A=b.selectIds[0];if(n===L.Start){const D=((y=this.serviceColloctor)==null?void 0:y.isLocalId(A))&&((v=this.serviceColloctor)==null?void 0:v.transformKey(A))||A,_=u[a][l][D];this.cacheOriginRotate=((m=_==null?void 0:_.opt)==null?void 0:m.rotate)||0}const O=b.updateNodeOpt||{};O.angle=(i+this.cacheOriginRotate)%360,O.workState=n;const j={workId:w,msgType:z.UpdateNode,dataType:F.Local,updateNodeOpt:O,emitEventType:this.emitEventType,willRefreshSelector:!1,willSyncService:!0,viewId:a};n===L.Done&&(j.willRefreshSelector=!0,j.willSerializeData=!0,this.cacheOriginRotate=0),d.push([j,{workId:w,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}continue}}n===L.Start?this.mainEngine.unWritable():n===L.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length&&this.collectForLocalWorker(d,e)}}function Jf(r){switch(r){case C.Text:return Bt.Text;case C.SpeechBalloon:case C.Star:case C.Ellipse:case C.Rectangle:case C.Triangle:case C.Rhombus:case C.Polygon:return Bt.Shape}}class Xf extends Lt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.SetFontStyle);M(this,"timerId")}async setTextStyle(t,e,s,i){const{bold:n,underline:a,lineThrough:c,italic:l,fontSize:h}=s;if(e.toolsType&&Jf(e.toolsType)===Bt.Text){e.opt&&(n&&(e.opt.bold=n),P.isBoolean(a)&&(e.opt.underline=a),P.isBoolean(c)&&(e.opt.lineThrough=c),l&&(e.opt.italic=l),h&&(e.opt.fontSize=h));const d=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:t,opt:e.opt,viewId:i,canSync:!1,canWorker:!1});return{key:t,textInfo:d}}}async collect(t){var m,w,N,S;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,bold:s,italic:i,lineThrough:n,underline:a,viewId:c,fontSize:l}=t,h=this.control.viewContainerManager.getView(c);if(!(h!=null&&h.displayer))return;const u=h.focusScenePath,d=[...e],p=this.serviceColloctor.storage,f={},I=Date.now();this.mainEngine.internalMsgEmitter.emit("addUndoTicker",I,c);const y=[];for(;d.length;){const T=d.pop();if(!T)continue;const x=T.toString(),b=this.serviceColloctor.isLocalId(x),A=b?this.serviceColloctor.transformKey(T):x;let O=x;!b&&this.serviceColloctor.isOwn(O)&&(O=this.serviceColloctor.getLocalId(O));const j=p[c][u][A]||void 0;if(j){const E=j.updateNodeOpt||{};if(s&&(E.bold=s,f.bold=s==="bold"),i&&(E.italic=i,f.italic=i==="italic"),P.isBoolean(n)&&(E.lineThrough=n,f.lineThrough=n),P.isBoolean(a)&&(E.underline=a,f.underline=a),l&&(E.fontSize=l,f.textSize=l),j.toolsType===C.Text&&j.opt){const D=this.setTextStyle(O,P.cloneDeep(j),E,c);y.push(D);continue}if(j&&O===H&&((m=j.selectIds)!=null&&m.length))for(const D of j.selectIds){const _=(w=this.serviceColloctor)==null?void 0:w.isLocalId(D);let nt=_&&((N=this.serviceColloctor)==null?void 0:N.transformKey(D))||D;const tt=p[c][u][nt]||void 0;if(!_&&((S=this.serviceColloctor)!=null&&S.isOwn(nt))&&(nt=this.serviceColloctor.getLocalId(nt)),tt&&tt.toolsType===C.Text&&j.opt){const V=this.setTextStyle(nt,P.cloneDeep(tt),E,c);y.push(V);continue}}}}const v=await Promise.all(y);for(const T of v)if(T){const{key:x,textInfo:b}=T;b&&(b.canSync=!0,b.canWorker=!0,this.control.textEditorManager.updateForViewEdited(x,b))}Object.keys(f).length&&(this.timerId&&(clearTimeout(this.timerId),this.timerId=void 0),this.timerId=setTimeout(()=>{var T;this.timerId=void 0,(T=this.control.room)==null||T.setMemberState(f)},0))}}class Kf extends Lt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.SetPoint);M(this,"undoTickerId")}collect(t){var m;if(!this.serviceColloctor||!this.mainEngine)return;const{workId:e,pointMap:s,workState:i,viewId:n}=t,a=this.control.viewContainerManager.getView(n);if(!(a!=null&&a.displayer))return;const c=a.focusScenePath,l=(m=this.serviceColloctor)==null?void 0:m.storage,h=[],u=i===L.Start&&Date.now()||void 0;u&&(this.undoTickerId=u,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,n));const d=e;if(!d)return;const p=d.toString(),f=this.serviceColloctor.isLocalId(p),I=f&&this.serviceColloctor.transformKey(d)||p;let y=p;!f&&this.serviceColloctor.isOwn(y)&&(y=this.serviceColloctor.getLocalId(y));const v=l[n][c][I];if(v&&y===H&&v.selectIds){const w=v.updateNodeOpt||{};w.pointMap=s,w.workState=i;const N={workId:d,msgType:z.UpdateNode,dataType:F.Local,updateNodeOpt:w,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:n};i===L.Done&&(N.undoTickerId=this.undoTickerId),h.push([N,{workId:d,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}i===L.Start?this.mainEngine.unWritable():i===L.Done&&this.mainEngine.abled(),h.length&&this.collectForLocalWorker(h)}}class _f extends Lt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.SetLock)}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,isLocked:s,viewId:i}=t,n=this.control.viewContainerManager.getView(i);if(!(n!=null&&n.displayer))return;const a=n.focusScenePath,c=[...e],l=this.serviceColloctor.storage,h=[],u=Date.now();for(;c.length;){const d=c.pop();if(!d)continue;const p=d.toString(),f=this.serviceColloctor.isLocalId(p),I=f?this.serviceColloctor.transformKey(d):p;let y=p;!f&&this.serviceColloctor.isOwn(y)&&(y=this.serviceColloctor.getLocalId(y));const v=l[i][a][I]||void 0;if(v){const m=v.updateNodeOpt||{};m.isLocked=s;const w={workId:y,msgType:z.UpdateNode,dataType:F.Local,updateNodeOpt:m,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:i};h.push([w,{workId:y,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}}this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,i),h.length&&this.collectForLocalWorker(h)}}class tg extends Lt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.SetShapeOpt)}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,viewId:s,...i}=t,n=this.control.viewContainerManager.getView(s);if(!(n!=null&&n.displayer))return;const a=n.focusScenePath,c=[...e],l=this.serviceColloctor.storage,h=[],u=Date.now();for(;c.length;){const d=c.pop();if(!d)continue;const p=d.toString(),f=this.serviceColloctor.isLocalId(p),I=f?this.serviceColloctor.transformKey(d):p;let y=p;!f&&this.serviceColloctor.isOwn(y)&&(y=this.serviceColloctor.getLocalId(y));const v=l[s][a][I]||void 0;if(v){const m={...v.updateNodeOpt,...i,willRefresh:!0};if(v&&y===H){const w={workId:y,msgType:z.UpdateNode,dataType:F.Local,updateNodeOpt:m,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:s};h.push([w,{workId:y,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}}}h.length&&(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,s),this.collectForLocalWorker(h))}}class q{constructor(o){M(this,"builders",new Map);this.builders=new Map(o.map(t=>[t,this.build(t)]))}build(o){switch(o){case R.TranslateNode:return new $f;case R.ZIndexNode:return new Vf;case R.CopyNode:return new Hf;case R.SetColorNode:return new Qf;case R.DeleteNode:return new Gf;case R.ScaleNode:return new Zf;case R.RotateNode:return new qf;case R.SetFontStyle:return new Xf;case R.SetPoint:return new Kf;case R.SetLock:return new _f;case R.SetShapeOpt:return new tg}}getBuilder(o){return this.builders.get(o)}registerForMainEngine(o,t){return this.builders.forEach(e=>{e&&e.registerForMainEngine(o,t)}),this}destroy(){this.builders.forEach(o=>{o&&o.destroy()}),this.builders.clear()}pause(){return this.builders.forEach(o=>{o&&o.pause()}),this}recover(){return this.builders.forEach(o=>{o&&o.recover()}),this}static emitMethod(o,t,e){Lt.dispatch(o,t,e)}static activeListener(o){mt.InternalMsgEmitter.on(R.ActiveMethod,o)}static unmountActiveListener(o){mt.InternalMsgEmitter.off(R.ActiveMethod,o)}}class eg{constructor(o){M(this,"master");M(this,"mainThreadWorkerMap",new Map);this.master=o}updateCamera(){for(const[o,t]of this.mainThreadWorkerMap.entries()){const e=this.master.control.viewContainerManager.getView(o);if(e){const{cameraOpt:s}=e;t.updateCamera({cameraOpt:s,viewId:e.viewId,msgType:z.UpdateCamera,dataType:F.Local})}}}notifyDrawCount(o){const t=this.master.getWorkDrawCount(),e=this.mainThreadWorkerMap.get(o);e&&e.clearDrawLayer(t)}clearDrawCount(o){const t=this.mainThreadWorkerMap.get(o);t&&t.clearDrawLayer(1/0)}createMainThreadWorker(o,t){return new og(o,t,this)}consume(o){var t;for(const e of o.values()){const{msgType:s,viewId:i,layerOpt:n,offscreenCanvasOpt:a,cameraOpt:c}=e;if(s===z.Console){console.log(this);continue}if(s===z.Init){const h=(t=this.master.control.viewContainerManager.getView(i))==null?void 0:t.displayer,u=h==null?void 0:h.subLocalCanvasContainerRef.current;if(h&&u&&n&&a){const d=this.createMainThreadWorker(i,{displayer:h,container:u,layerOpt:n,master:this.master,canvasOpt:a,post:this.post.bind(this)});this.mainThreadWorkerMap.set(i,d),d&&c&&d.setCameraOpt(c)}continue}if(s===z.TasksQueue)continue;const l=this.mainThreadWorkerMap.get(i);l&&(l.on(e),s===z.Destroy&&(l.destroy(),this.mainThreadWorkerMap.delete(i)))}}post(o){const{sp:t}=o;t&&this.master.collectorSyncData(t)}destroy(){for(const o of this.mainThreadWorkerMap.values())o.destroy();this.mainThreadWorkerMap.clear()}active(){}}class og{constructor(o,t,e){M(this,"viewId");M(this,"opt");M(this,"manager");M(this,"subLocalLayer");M(this,"subLocalWork");M(this,"scene");M(this,"cameraOpt");this.viewId=o,this.opt=t,this.manager=e,this.scene=this.createScene({...t.canvasOpt,container:t.container});const s=xt.bufferSize.full,i=xt.bufferSize.sub;this.subLocalLayer=this.createLayer("subLocalLayer",this.scene,{...t.layerOpt,bufferSize:this.viewId===yt?s:i});const n={thread:this};this.subLocalWork=new sg(n)}createScene(o){return new lt.Scene({displayRatio:this.opt.displayer.dpr,depth:!1,desynchronized:!0,...o,autoRender:!0,id:this.viewId})}createLayer(o,t,e){const{width:s,height:i}=e,n=`canvas-${o}`,a=t.layer(n,{...e,offscreen:!1}),c=new lt.Group({anchor:[.5,.5],pos:[s*.5,i*.5],size:[s,i],name:"viewport",id:o});return a.append(c),c}updateScene(o){this.scene.attr({...o});const{width:t,height:e}=o;this.scene.width=t,this.scene.height=e,this.updateLayer({width:t,height:e})}updateLayer(o){const{width:t,height:e}=o;this.subLocalLayer.parent.setAttribute("width",t),this.subLocalLayer.parent.setAttribute("height",e),this.subLocalLayer.setAttribute("size",[t,e]),this.subLocalLayer.setAttribute("pos",[t*.5,e*.5])}on(o){const{msgType:t,toolsType:e,opt:s,dataType:i,workId:n,workState:a}=o,c=n==null?void 0:n.toString();switch(t){case z.Destroy:this.destroy();break;case z.Clear:this.clearAll();break;case z.UpdateCamera:this.updateCamera(o);break;case z.UpdateTools:if(e&&this.subLocalWork.canUseSubWorkerLayer(e)&&s){const l={toolsType:e,toolsOpt:s};this.subLocalWork.setToolsOpt(l)}break;case z.CreateWork:c&&s&&e&&this.subLocalWork.canUseSubWorkerLayer(e)&&(this.subLocalWork.getToolsOpt()||this.subLocalWork.setToolsOpt({toolsType:e,toolsOpt:s}),this.subLocalWork.setWorkOptions(c,s));break;case z.DrawWork:e&&this.subLocalWork.canUseSubWorkerLayer(e)&&(a===L.Done&&i===F.Local?this.subLocalWork.consumeDrawAll(o):this.subLocalWork.consumeDraw(o));break;case z.RemoveNode:this.subLocalWork.removeNode(o);return}}setCameraOpt(o){this.cameraOpt=o;const{scale:t,centerX:e,centerY:s,width:i,height:n}=o;(i!==this.scene.width||n!==this.scene.height)&&this.updateScene({width:i,height:n}),this.subLocalLayer&&(this.subLocalLayer.setAttribute("scale",[t,t]),this.subLocalLayer.setAttribute("translate",[-e,-s]))}updateCamera(o){const{cameraOpt:t}=o;t&&!P.isEqual(this.cameraOpt,t)&&(this.subLocalWork.workShapes.size&&this.clearAll(),this.setCameraOpt(t))}clearAll(){this.subLocalLayer.children.length&&(this.subLocalLayer.parent.children.forEach(o=>{o.name!=="viewport"&&o.remove()}),this.subLocalLayer.removeAllChildren()),this.subLocalWork.clearAll()}destroy(){this.subLocalLayer.remove(),this.scene.remove(),this.subLocalWork.destroy()}clearDrawLayer(o){if(o===1/0){this.clearAll();return}const t=this.subLocalLayer.children.filter(e=>e.id&&P.isNumber(parseInt(e.id))&&parseInt(e.id)<o);for(const e of t)e.disconnect(),this.subLocalLayer.removeChild(e)}}class sg{constructor(o){M(this,"thread");M(this,"workShapes",new Map);M(this,"tmpOpt");M(this,"syncUnitTime",xt.syncOpt.interval);M(this,"drawCount",0);this.thread=o.thread}getToolsOpt(){return this.tmpOpt}consumeDrawAll(o){const{workId:t}=o,e=t==null?void 0:t.toString();e&&this.workShapes.get(e)&&(this.drawCount=0,this.thread.subLocalLayer.removeAllChildren(),this.clearWorkShapeNodeCache(e))}consumeDraw(o){const{workId:t,toolsType:e}=o;t&&e&&this.canUseSubWorkerLayer(e)&&(this.getWorkShape(t.toString())||this.createLocalWork(o));const s=t==null?void 0:t.toString(),i=s&&this.workShapes.get(s);if(!i)return;i.consume({data:o,drawCount:this.drawCount,isFullWork:!1,isSubWorker:!0}),this.drawCount++;const n=this.thread.manager.master;n.setSubWorkerDrawCount(this.drawCount);const a=Math.max(n.getMaxDrawCount(),this.drawCount);n.setMaxDrawCount(a)}removeNode(o){const{workId:t}=o,e=t==null?void 0:t.toString();e&&this.workShapes.has(e)&&(this.thread.subLocalLayer.getElementsByName(e).forEach(i=>{i.remove()}),this.clearWorkShapeNodeCache(e))}createLocalWork(o){const{workId:t,toolsType:e,opt:s}=o,i=t==null?void 0:t.toString();e&&this.canUseSubWorkerLayer(e)&&i&&s&&(this.getToolsOpt()||this.setToolsOpt({toolsType:e,toolsOpt:s}),this.setWorkOptions(i,s))}setWorkOptions(o,t){let e=this.workShapes.get(o);if(!e&&this.tmpOpt){const{toolsType:s}=this.tmpOpt;this.tmpOpt.toolsOpt=t,e=this.createWorkShapeNode({workId:o,toolsType:s,toolsOpt:t}),e&&this.workShapes.set(o,e),this.setToolsOpt(this.tmpOpt)}t!=null&&t.syncUnitTime||(t.syncUnitTime=this.syncUnitTime),e&&e.setWorkOptions(t)}destroy(){this.clearAll()}clearAll(){this.thread.subLocalLayer.removeAllChildren(),this.workShapes.clear()}canUseSubWorkerLayer(o){return o===C.Pencil}setToolsOpt(o){var t;this.tmpOpt=o,(t=o.toolsOpt)!=null&&t.syncUnitTime&&(this.syncUnitTime=o.toolsOpt.syncUnitTime)}createWorkShapeNode(o){return vi({...o,fullLayer:this.thread.subLocalLayer,drawLayer:this.thread.subLocalLayer})}clearWorkShapeNodeCache(o){this.workShapes.delete(o)}getWorkShape(o){return this.workShapes.get(o)}}const ig=async(r,o)=>{const{src:t,isgl:e,isCache:s}=r;if(typeof Image=="function"){const i=new Image;return typeof t=="string"&&(i.crossOrigin="anonymous"),new Promise(n=>{i.onload=function(){createImageBitmap(i,{imageOrientation:e?"flipY":"none"}).then(a=>{n(a)})},i.onerror=function(){n(void 0)},i.src=t})}else return fetch(t,{method:"GET",mode:"cors",cache:"default"}).then(i=>i.blob()).then(i=>createImageBitmap(i,{imageOrientation:e?"flipY":"none"}).then(n=>n))};class ng{constructor(){M(this,"maxLastSyncTime",xt.syncOpt.interval)}setCurrentToolsData(o){this.currentToolsData=o}getCurrentToolsData(){return this.currentToolsData}setCurrentLocalWorkData(o){this.currentLocalWorkData=o}getWorkId(){return this.currentLocalWorkData.workId}getWorkState(){return this.currentLocalWorkData.workState}}class rg extends ng{constructor(t){var i,n;super();M(this,"isActive",!1);M(this,"currentToolsData");M(this,"currentLocalWorkData");M(this,"control");M(this,"internalMsgEmitter");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,"wokerDrawCount",0);M(this,"maxDrawCount",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");const{control:e,internalMsgEmitter:s}=t;this.control=e,this.maxLastSyncTime=((n=(i=this.control.pluginOptions)==null?void 0:i.syncOpt)==null?void 0:n.interval)||this.maxLastSyncTime,this.fullWorkerUrl=this.control.pluginOptions.cdn.fullWorkerUrl,this.subWorkerUrl=this.control.pluginOptions.cdn.subWorkerUrl,this.internalMsgEmitter=s,this.currentLocalWorkData={workState:L.Pending}}destroy(){var t,e,s;(t=this.methodBuilder)==null||t.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(),(e=this.fullWorker)==null||e.terminate(),(s=this.subWorker)==null||s.terminate()}get viewContainerManager(){return this.control.viewContainerManager}get collector(){return this.control.collector}get isRunSubWork(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===C.Pencil||t===C.LaserPen||t===C.Arrow||t===C.Straight||t===C.Ellipse||t===C.Rectangle||t===C.Star||t===C.Polygon||t===C.SpeechBalloon}get isCanDrawWork(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===C.Pencil||t===C.LaserPen||t===C.Arrow||t===C.Straight||t===C.Ellipse||t===C.Rectangle||t===C.Star||t===C.Polygon||t===C.SpeechBalloon||t===C.Triangle||t===C.Rhombus||t===C.BitMapEraser}get isUseZIndex(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===C.Pencil||t===C.Arrow||t===C.Straight||t===C.Ellipse||t===C.Rectangle||t===C.Star||t===C.Polygon||t===C.SpeechBalloon||t===C.Text||t===C.Image}get isCanRecordUndoRedo(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===C.Pencil||t===C.Eraser||t===C.BitMapEraser||t===C.Arrow||t===C.Straight||t===C.Ellipse||t===C.Rectangle||t===C.Star||t===C.Polygon||t===C.SpeechBalloon||t===C.Text||t===C.Image}get isCanSentCursor(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===C.Pencil||t===C.Text||t===C.LaserPen||t===C.Arrow||t===C.Straight||t===C.Ellipse||t===C.Rectangle||t===C.Star||t===C.Polygon||t===C.SpeechBalloon||t===C.Triangle||t===C.Rhombus||t===C.Eraser||t===C.PencilEraser||t===C.BitMapEraser}get isCanStartEventConsum(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===C.Selector||t===C.Eraser||t===C.PencilEraser||t===C.BitMapEraser}async init(){this.destroy(),await this.on(),this.internalMsgEmitterListener(),this.isActive=!0}async useMainThread(){console.info("no OffscreenCanvas");const{MainThreadManagerImpl:t}=await Promise.resolve().then(()=>require("./index-gKuc4bsw.js"));this.mainThread=new t(this)}async on(){if(!this.control.hasOffscreenCanvas()){await this.useMainThread();return}if(!this.fullWorkerUrl||!this.subWorkerUrl){console.error("no worker url config");return}this.fullWorker=new Worker(this.fullWorkerUrl,{type:"classic"}),this.subWorker=new Worker(this.subWorkerUrl,{type:"classic"}),this.subMainThreadWorker=new eg(this),this.fullWorker.onmessage=t=>{var e,s;if(t.data){const{render:i,sp:n,drawCount:a,workerTasksqueueCount:c,viewId:l}=t.data;this.isBusy&&c&&this.setWorkerTasksqueueCount(c),n!=null&&n.length&&this.collectorSyncData(n);const h=(i==null?void 0:i.length)&&i||[];if(a&&l){if(this.setWorkDrawCount(a),this.wokerDrawCount<1/0){const u=Math.max(this.maxDrawCount,this.wokerDrawCount);this.setMaxDrawCount(u),this.control.priority==="ui"?(e=this.subMainThreadWorker)==null||e.notifyDrawCount(l):this.clearReRenders(this.wokerDrawCount)}else this.setMaxDrawCount(0),this.control.priority==="ui"?(s=this.subMainThreadWorker)==null||s.clearDrawCount(l):this.clearReRenders(1/0);if(this.reRenders.size)for(const u of this.reRenders.values())h.push(...u)}h.length&&this.viewContainerManager.render(h)}},this.subWorker.onmessage=t=>{if(t.data){const{render:e,sp:s,drawCount:i}=t.data;s!=null&&s.length&&this.collectorSyncData(s);const n=(e==null?void 0:e.length)&&e||[];if(this.control.priority==="cpu"&&P.isNumber(i)){if(this.setSubWorkerDrawCount(i),this.wokerDrawCount<1/0){const a=Math.max(this.maxDrawCount,this.subWorkerDrawCount);this.setMaxDrawCount(a)}if(e!=null&&e.length)if(this.subWorkerDrawCount>this.wokerDrawCount){const a=[];for(const c of e)c.imageBitmap&&(c.isUnClose=!0,a.push(c));this.reRenders.set(this.subWorkerDrawCount,a)}else this.reRenders.size&&this.clearReRenders(this.subWorkerDrawCount)}n.length&&this.viewContainerManager.render(n)}}}clearReRenders(t=1/0){for(const e of this.reRenders.keys())if(P.isNumber(Number(e))&&Number(e)<=t){const s=this.reRenders.get(Number(e));s==null||s.forEach(i=>{var n;(n=i.imageBitmap)==null||n.close()}),this.reRenders.delete(e)}}get isBusy(){return this.getTasksqueueState()===L.Doing}getLockSentEventCursor(){return this.isLockSentEventCursor}setLockSentEventCursor(t){this.isLockSentEventCursor=t}getTasksqueueState(){return this.useTasksqueue&&L.Doing||L.Done}setMaxDrawCount(t){this.maxDrawCount=t}getWorkDrawCount(){return this.wokerDrawCount}getSubWorkerDrawCount(){return this.subWorkerDrawCount}getMaxDrawCount(){return this.maxDrawCount}setWorkDrawCount(t){this.wokerDrawCount=t}setSubWorkerDrawCount(t){this.subWorkerDrawCount=t}setWorkerTasksqueueCount(t){const e=Math.max(this.workerTasksqueueCount||0,t);this.workerTasksqueueCount=e}collectorSyncData(t){var s,i,n;let e=!1;for(const a of t){const{type:c,selectIds:l,opt:h,selectRect:u,strokeColor:d,fillColor:p,willSyncService:f,isSync:I,imageBitmap:y,canvasHeight:v,canvasWidth:m,rect:w,op:N,canTextEdit:S,points:T,selectorColor:x,canRotate:b,scaleType:A,textOpt:O,toolsType:j,workId:E,viewId:D,dataType:_,canLock:nt,isLocked:tt,shapeOpt:V,toolsTypes:K,thickness:$,strokeType:G,useStroke:J,isgl:rt,imageSrc:It,isSubWorker:ot}=a;if(!D)return;const at=a.scenePath||this.viewContainerManager.getCurScenePath(D);switch(c){case z.Select:{const W=l!=null&&l.length?{...u,selectIds:l,canvasHeight:v,canvasWidth:m,points:T}:void 0;W&&(h!=null&&h.strokeColor)&&(W.selectorColor=h.strokeColor),W&&x&&(W.selectorColor=x),W&&d&&(W.strokeColor=d),W&&(h!=null&&h.fillColor)&&(W.fillColor=h.fillColor),W&&p&&(W.fillColor=p),W&&P.isBoolean(b)&&(W.canRotate=b),W&&A&&(W.scaleType=A),W&&S&&(W.canTextEdit=S),W&&O&&(W.textOpt=O),W&&P.isBoolean(nt)&&(W.canLock=nt),W&&P.isBoolean(tt)&&(W.isLocked=tt),W&&V&&(W.shapeOpt=V),W&&K&&(W.toolsTypes=K),W&&$&&(W.thickness=$),W&&G&&(W.strokeType=G),W&&P.isBoolean(J)&&(W.useStroke=J),D&&this.viewContainerManager.showFloatBar(D,!!W,W),f&&((s=this.collector)==null||s.dispatch({type:c,selectIds:l,opt:h,isSync:I,viewId:D,scenePath:at}));break}case z.Snapshot:if(y&&at){const W=this.snapshotMap.get(at);W&&W(y)}break;case z.BoundingBox:if(w&&at){const W=this.boundingRectMap.get(at);W&&W(w)}break;case z.Cursor:N&&this.control.cursor.collectServiceCursor({...a});break;case z.Clear:if(D){this.viewContainerManager.showFloatBar(D,!1);const W=(i=this.clearAllResolveMap.get(D))==null?void 0:i.resolve;W&&W(D)}break;case z.TextUpdate:if(j===C.Text&&E&&D){const W=this.viewContainerManager.transformToOriginPoint((h==null?void 0:h.boxPoint)||[0,0],D),it=(h==null?void 0:h.boxSize)||[0,0],ht=(n=this.viewContainerManager.getView(D))==null?void 0:n.cameraOpt;h?this.control.textEditorManager.updateTextForWorker({x:W[0],y:W[1],w:it[0],h:it[1],scale:(ht==null?void 0:ht.scale)||1,workId:E,opt:h,dataType:_,viewId:D,canSync:f||!1,canWorker:!1}):this.control.textEditorManager.delete(E,f||!1,!1)}break;case z.GetTextActive:j===C.Text&&E&&D&&this.control.textEditorManager.updateTextForWorker({workId:E,isActive:!0,viewId:D,dataType:F.Local,canWorker:!1,canSync:!0},Date.now());break;case z.GetImageBitMap:It&&E&&D&&ig({src:It,isgl:rt}).then(W=>{var ht;const it=new Set;if(it.add({msgType:z.GetImageBitMap,dataType:F.Local,workId:E,viewId:D,imageSrc:It,isSubWorker:ot,imageBitmap:W}),!this.control.hasOffscreenCanvas())(ht=this.mainThread)==null||ht.consume(it);else{const vt=ot?this.subWorker:this.fullWorker;W?vt.postMessage(it,[W]):vt.postMessage(it)}});break;default:e=!0;break}}e&&oe(()=>{this.collectorAsyncData(t)},this.maxLastSyncTime)}collectorAsyncData(t){var e,s,i,n;for(const a of t){const{type:c,op:l,workId:h,index:u,removeIds:d,ops:p,opt:f,updateNodeOpt:I,toolsType:y,isSync:v,viewId:m,isLockSentEventCursor:w,nextTasks:N}=a;if(!m){console.error("collectorAsyncData",a);return}const S=a.scenePath||this.viewContainerManager.getCurScenePath(m);switch(c){case z.None:{w&&oe(()=>{this.setLockSentEventCursor(!1)},this.maxLastSyncTime);break}case z.DrawWork:{(e=this.collector)==null||e.dispatch({type:c,op:l,opt:f,toolsType:y,workId:h,index:u,isSync:v,viewId:m,scenePath:S,updateNodeOpt:I});break}case z.FullWork:{(s=this.collector)==null||s.dispatch({type:c,ops:p,workId:h,updateNodeOpt:I,opt:f,toolsType:y,isSync:v,viewId:m,scenePath:S}),this.willSelectorWorkId&&h&&h.toString()===this.willSelectorWorkId&&this.control.runEffectWork(()=>{this.setShapeSelectorByWorkId(this.willSelectorWorkId,m),this.willSelectorWorkId=void 0});break}case z.UpdateNode:{(i=this.collector)==null||i.dispatch({type:c,updateNodeOpt:I,workId:h,opt:f,ops:p,op:l,isSync:v,viewId:m,scenePath:S});break}case z.RemoveNode:{d&&this.control.textEditorManager.deleteBatch(d,!1,!1),(n=this.collector)==null||n.dispatch({type:c,removeIds:d,isSync:v,viewId:m,scenePath:S}),this.willSelectorWorkId&&(d!=null&&d.includes(this.willSelectorWorkId))&&(this.willSelectorWorkId=void 0);break}}N&&oe(()=>{this.collectorAsyncData(N)},this.maxLastSyncTime)}}async onLocalEventEnd(t,e){var l;const s=this.viewContainerManager.getView(e);if(!s)return;const{focusScenePath:i,cameraOpt:n}=s,a=this.viewContainerManager.transformToScenePoint(t,e),c=[];for(const h of this.localPointsBatchData.keys())if(((l=this.currentToolsData)==null?void 0:l.toolsType)===C.Text){const u=this.getLocalPointInfo(h),d=u==null?void 0:u.state;if(d&&d===L.Start){const p=this.currentLocalWorkData.toolsOpt;p.workState=L.Doing,p.boxPoint=a,p.boxSize=[p.fontSize,p.fontSize],this.control.textEditorManager.checkEmptyTextBlur(),this.control.textEditorManager.createTextForMasterController({workId:Date.now().toString(),x:t[0],y:t[1],scale:(n==null?void 0:n.scale)||1,opt:p,type:Bt.Text,isActive:!0,viewId:e,scenePath:i},Date.now())}this.deleteLocalPoint(h);continue}else this.pushLocalPoint(h,a,L.Done,e),c.push(h);if(c.length){try{if(await new Promise(u=>{setTimeout(async()=>{c.forEach(d=>{this.setLocalPointIsFullWork(d)}),this.delayWorkStateToDoneResolve=u,this.consume()},0)})&&c[0]){const u=c[0];c.forEach(d=>{this.deleteLocalPoint(d)}),this.willSelectorWorkId=u.toString()}}catch(h){console.log("error",h)}this.delayWorkStateToDoneResolve=void 0,c.length=0}}onLocalEventDoing(t,e){var i;if(((i=this.currentToolsData)==null?void 0:i.toolsType)===C.Text)return;this.currentLocalWorkData.workState===L.Start&&this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:L.Doing});let s=!1;for(const[n,{state:a}]of this.localPointsBatchData.entries())if(this.isAbled()&&a!==L.Pending){const c=this.viewContainerManager.transformToScenePoint(t,e);this.pushLocalPoint(n,c,a===L.Start?L.Doing:a,e),s=!0}if(s){this.runAnimation();return}this.useTasksqueue||this.hoverCursor(t,e)}onLocalEventStart(t,e){var a,c,l,h,u,d;this.viewContainerManager.focuedViewId!==e&&this.viewContainerManager.setFocuedViewId(e),this.isCanDrawWork&&this.control.room&&!this.control.room.disableDeviceInputs&&(this.control.room.disableDeviceInputs=!0);const s=((a=this.currentToolsData)==null?void 0:a.toolsType)===C.Selector?H:Date.now(),i=this.setZIndex(e);this.setCurrentLocalWorkData({workState:L.Start,toolsOpt:i,viewId:e});const n=this.viewContainerManager.transformToScenePoint(t,e);if(this.pushLocalPoint(s,n,L.Start,e,i),((c=this.currentToolsData)==null?void 0:c.toolsType)!==C.Text){if(this.control.textEditorManager.checkEmptyTextBlur(),this.isCanRecordUndoRedo&&this.internalMsgEmitter.emit("addUndoTicker",s,e),s&&i&&((l=this.currentToolsData)!=null&&l.toolsType)&&this.isCanStartEventConsum&&this.prepareOnceWork({workId:s,toolsOpt:i,viewId:e},(h=this.currentToolsData)==null?void 0:h.toolsType),this.maxDrawCount=0,this.wokerDrawCount=0,this.subWorkerDrawCount=0,this.clearReRenders(1/0),(u=this.subMainThreadWorker)==null||u.clearDrawCount(e),this.isCanDrawWork){const p=this.viewContainerManager.getCurScenePath(e);p&&((d=this.collector)!=null&&d.hasSelector(e,p))&&this.blurSelector(e,p)}this.consume()}}setLocalPointIsFullWork(t){const e=this.getLocalPointInfo(t);e&&(e.isFullWork=!0,this.localPointsBatchData.set(t,e))}pushLocalPoint(t,e,s,i,n){let a=this.getLocalPointInfo(t);s===L.Start?a={state:L.Start,points:e,opt:n||this.currentLocalWorkData.toolsOpt,isFullWork:!1,viewId:i}:a&&(a.state=s,a.points.push(e[0],e[1])),a&&this.localPointsBatchData.set(t,a)}deleteLocalPoint(t){this.localPointsBatchData.delete(t)}getLocalPointInfo(t){return this.localPointsBatchData.get(t)}getLocalPointsInfo(){return this.localPointsBatchData}correctStorage(t,e,s){var c;const i=new Map,n=[];Object.keys(t).forEach(l=>{var u,d;const h=(d=(u=t[l])==null?void 0:u.opt)==null?void 0:d.zIndex;P.isNumber(h)&&n.push([l,h])});const a=n.length&&((c=this.zIndexNodeMethod)==null?void 0:c.correct(n))||[];this.zIndexNodeMethod&&a.length&&(this.zIndexNodeMethod.setMinZIndex(a[0][1]||0,e),this.zIndexNodeMethod.setMaxZIndex(a[a.length-1][1]||0,e));for(const[l,h]of a){if(!t[l])continue;const u=t[l];u.opt&&P.isNumber(u.opt.zIndex)&&u.opt.zIndex!==h&&(u.opt.zIndex=h,i.set(l,u))}return i.size&&i.forEach((l,h)=>{var u;(u=this.collector)==null||u.updateValue(h,l,{viewId:e,scenePath:s,isSync:!0}),t[h]=l}),t}async originalEventLintener(t,e,s){var n,a;if(!this.isAbled())return;const i=(n=this.collector)==null?void 0:n.uid;switch((a=this.currentToolsData)==null?void 0:a.toolsType){case C.Eraser:case C.PencilEraser:case C.BitMapEraser:{if(i&&!this.control.renderControl.isClearAble(i,s))return;break}default:if(i&&!this.control.renderControl.isWriteable(i)||i&&!this.control.renderControl.isRenderAble(i,s))return;break}switch(t){case L.Start:this.setLocalWorkViewId(s),s&&this.onLocalEventStart(e,s);break;case L.Doing:s&&s===this.getLocalWorkViewId()&&this.onLocalEventDoing(e,s);break;case L.Done:s&&s===this.getLocalWorkViewId()&&await this.onLocalEventEnd(e,s);break}}getLocalWorkViewId(){return this.localWorkViewId}setLocalWorkViewId(t){this.localWorkViewId=t}setCurrentToolsData(t){var i,n,a;const e=t.toolsType,s=((i=this.currentToolsData)==null?void 0:i.toolsType)!==t.toolsType;if(super.setCurrentToolsData(t),s){const c=(n=this.viewContainerManager)==null?void 0:n.getAllViews();for(const l of c)if(l){const{id:h,focusScenePath:u}=l;s&&h&&u&&((a=this.collector)!=null&&a.hasSelector(h,u)&&this.blurSelector(h,u),this.control.textEditorManager.checkEmptyTextBlur())}this.taskBatchData.add({msgType:z.UpdateTools,dataType:F.Local,toolsType:e,opt:{...t.toolsOpt,syncUnitTime:this.maxLastSyncTime},isRunSubWork:this.isRunSubWork,viewId:Ue}),this.runAnimation()}}prepareOnceWork(t,e){const{workId:s,toolsOpt:i,viewId:n}=t;this.queryTaskBatchData({msgType:z.CreateWork,dataType:F.Local,viewId:n,toolsType:e}).forEach(a=>{this.taskBatchData.delete(a)}),this.taskBatchData.add({msgType:z.CreateWork,workId:s,toolsType:e,opt:{...i,syncUnitTime:this.maxLastSyncTime},dataType:F.Local,isRunSubWork:this.isRunSubWork,viewId:n}),this.runAnimation()}createViewWorker(t,e){const{offscreenCanvasOpt:s,layerOpt:i,dpr:n,cameraOpt:a}=e;this.taskBatchData.add({msgType:z.Init,dataType:F.Local,viewId:t,offscreenCanvasOpt:s,layerOpt:i,dpr:n,cameraOpt:a,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1}),this.isBusy&&this.destroyTaskQueue(),this.consume()}destroyViewWorker(t,e=!1){var s;this.getLocalWorkViewId()===t&&this.setLocalWorkViewId(void 0),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(t),this.control.renderControl.destoryByViewId(t,e),this.taskBatchData.add({msgType:z.Destroy,dataType:F.Local,viewId:t,isRunSubWork:!0}),this.consume(),e||(s=this.collector)==null||s.dispatch({type:z.Clear,viewId:t})}onServiceDerive(t,e){var f,I,y,v,m,w;const{newValue:s,oldValue:i,viewId:n,scenePath:a}=e,c=P.cloneDeep(s)||{},l=t;let h=c.type;const u=(f=this.collector)==null?void 0:f.getUidFromKey(t);if(u&&!this.control.renderControl.isRenderAble(u,n))return;if(!s&&i){if(l&&((I=this.collector)==null?void 0:I.getLocalId(l))===H){this.collector.isOwn(l)?this.blurSelector(n,a):this.blurSelector(n,a,l);return}if(h=z.RemoveNode,i.toolsType===C.LaserPen)return}const d=(y=this.viewContainerManager.getView(n))==null?void 0:y.focusScenePath;if(d&&d!==a)return;if(h&&l){const N=c;if(N.workId=(v=this.collector)!=null&&v.isOwn(l)?(m=this.collector)==null?void 0:m.getLocalId(l):l,N.msgType=h,N.toolsType===C.LaserPen&&(N.isRunSubWork=!0),N.dataType=F.Service,N.viewId=n,N.scenePath=a,N.selectIds&&(N.selectIds=N.selectIds.map(S=>{var T,x;return(T=this.collector)!=null&&T.isOwn(S)?(x=this.collector)==null?void 0:x.getLocalId(S):S})),N&&N.toolsType===C.Text||(i==null?void 0:i.toolsType)===C.Text){this.control.textEditorManager.onServiceDerive(N);return}this.taskBatchData.add(N)}this.runAnimation();const p=e.newValue&&((w=e.newValue.opt)==null?void 0:w.zIndex);if(this.zIndexNodeMethod&&P.isNumber(p)){const N=this.zIndexNodeMethod.getMinZIndex(n);this.zIndexNodeMethod.getMaxZIndex(n)<p&&this.zIndexNodeMethod.setMaxZIndex(p,n),N>p&&this.zIndexNodeMethod.setMinZIndex(p,n)}}pullServiceData(t,e,s={isAsync:!1,useAnimation:!1}){var c,l,h,u,d;let i=(c=this.collector)==null?void 0:c.getStorageData(t,e);const{isAsync:n,useAnimation:a}=s;if(i){i=this.correctStorage(i,t,e);const p=Object.keys(i);for(const f of p){const I=(l=this.collector)==null?void 0:l.getUidFromKey(f);if(I&&!this.control.renderControl.isRenderAble(I,t))continue;const y=(h=i[f])==null?void 0:h.type;if(y&&f){const v=i[f];if(v.workId=(u=this.collector)!=null&&u.isOwn(f)?(d=this.collector)==null?void 0:d.getLocalId(f):f,v.msgType=y,v.dataType=F.Service,v.viewId=t,v.scenePath=e,v.useAnimation=!!a,v.selectIds&&(v.selectIds=v.selectIds.map(m=>{var w,N;return(w=this.collector)!=null&&w.isOwn(m)?(N=this.collector)==null?void 0:N.getLocalId(m):m})),v.toolsType===C.Text){this.control.textEditorManager.onServiceDerive(v);continue}this.taskBatchData.add(v)}this.internalMsgEmitter.emit("excludeIds",p,t)}n?this.consume():this.runAnimation()}}runAnimation(){!this.animationId&&!this.isBusy&&(this.animationId=requestAnimationFrame(this.consume.bind(this)))}consume(){var e;this.animationId=void 0;const{viewId:t}=this.currentLocalWorkData;if(this.tasksqueue.size){const s=this.consumeQueue(),i=!!s.size;if(this.taskBatchData.size)for(const n of this.taskBatchData.values())n.dataType===F.Service&&(s.add(n),this.taskBatchData.delete(n));s.size?(this.post(s),i&&this.tasksqueue.clear()):this.tasksqueue.size&&(this.animationId=requestAnimationFrame(this.consume.bind(this)));return}if(this.isAbled()&&this.localPointsBatchData.size&&t)for(const[s,{state:i,isFullWork:n,points:a,opt:c}]of this.localPointsBatchData.entries()){if(i===L.Done&&!n||i===L.Start&&!this.isCanStartEventConsum)continue;const l=a.map(h=>h);l.length&&(this.delayWorkStateToDoneResolve&&i===L.Done&&(this.delayWorkStateToDoneResolve(!0),this.setLockSentEventCursor(!0)),this.taskBatchData.add({op:l,workState:i,workId:s,dataType:F.Local,msgType:z.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(e=this.currentToolsData)==null?void 0:e.toolsType,viewId:t,scenePath:t&&this.viewContainerManager.getCurScenePath(t),opt:c,isLockSentEventCursor:this.getLockSentEventCursor(),syncUnitTime:this.maxLastSyncTime}),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:L.Unwritable,workId:void 0})}abled(){this.setCurrentLocalWorkData({workState:L.Pending,workId:void 0})}isAbled(){return this.currentLocalWorkData.workState!==L.Unwritable}post(t){var s;if(!this.control.hasOffscreenCanvas()){if(!this.mainThread){let i=[];i=P.cloneDeep([...t]),setTimeout(()=>{for(const n of i)this.taskBatchData.add(n)},0);return}this.mainThread.consume(t);return}this.fullWorker.postMessage(t);const e=new Set;for(const i of t.values()){const n=i.msgType;(n===z.Init||n===z.Clear||n===z.Destroy||n===z.UpdateCamera||i.isRunSubWork)&&e.add(i)}e.size&&(this.subWorker.postMessage(e),this.control.priority==="ui"&&((s=this.subMainThreadWorker)==null||s.consume(e)))}updateNode(t,e,s,i){this.taskBatchData.add({msgType:z.UpdateNode,workId:t,updateNodeOpt:e,viewId:s,scenePath:i,dataType:F.Local}),this.runAnimation()}destroyTaskQueue(){this.useTasksqueue=!1,this.useTasksClockId&&(clearTimeout(this.useTasksClockId),this.useTasksClockId=void 0),this.mainTasksqueueCount=void 0,this.workerTasksqueueCount=void 0}updateCamera(t,e){var s;this.useTasksqueue||((s=this.methodBuilder)==null||s.pause(),this.blurCursor(t),this.checkDrawingWork(t),this.useTasksqueue=!0,this.mainTasksqueueCount=1,this.workerTasksqueueCount=1),this.useTasksqueue&&(this.tasksqueue.set(t,{msgType:z.UpdateCamera,dataType:F.Local,cameraOpt:{...e,width:e.width,height:e.height},scenePath:this.viewContainerManager.getCurScenePath(t),isRunSubWork:!0,viewId:t}),this.consume(),this.useTasksClockId&&clearTimeout(this.useTasksClockId),this.updateCameraDone())}updateCameraDone(){this.useTasksClockId=setTimeout(()=>{var t,e;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"&&((t=this.subMainThreadWorker)==null||t.updateCamera()),(e=this.methodBuilder)==null||e.recover(),this.runAnimation()):this.updateCameraDone()},this.maxLastSyncTime)}consumeQueue(){const t=new Set;let e=!this.isBusy;if(this.isBusy&&this.mainTasksqueueCount&&this.workerTasksqueueCount&&this.mainTasksqueueCount<=this.workerTasksqueueCount&&(e=!0),e){this.mainTasksqueueCount&&this.workerTasksqueueCount&&this.mainTasksqueueCount++,t.add({msgType:z.TasksQueue,dataType:F.Local,isRunSubWork:!0,mainTasksqueueCount:this.mainTasksqueueCount,tasksqueue:this.tasksqueue,viewId:""});for(const[s,i]of this.tasksqueue.entries())i.cameraOpt&&this.control.textEditorManager.onCameraChange(i.cameraOpt,s)}return t}async clearViewScenePath(t,e,s){var i,n;if(s){const a=(i=this.collector)==null?void 0:i.uid;if(a&&!this.control.renderControl.isClearAble(a,t))return}if(this.control.textEditorManager.clear(t,e),this.queryTaskBatchData({msgType:z.Clear,dataType:F.Local,viewId:t}).forEach(a=>{this.taskBatchData.delete(a)}),this.taskBatchData.add({dataType:F.Local,msgType:z.Clear,viewId:t}),this.runAnimation(),!e){const a=this.viewContainerManager.getCurScenePath(t);(n=this.collector)==null||n.dispatch({type:z.Clear,viewId:t,scenePath:a})}this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(t),this.localPointsBatchData.clear(),await new Promise(a=>{const c=this.clearAllResolveMap.get(t)||{resolve:void 0,timer:void 0};c.timer&&clearTimeout(c.timer),c.resolve=a,c.timer=setTimeout(()=>{const l=this.clearAllResolveMap.get(t);l!=null&&l.resolve&&l.resolve(t)},this.maxLastSyncTime),this.clearAllResolveMap.set(t,c)}).then(a=>{this.clearAllResolveMap.delete(a)})}internalMsgEmitterListener(){var t;this.methodBuilder=new q([R.CopyNode,R.SetColorNode,R.DeleteNode,R.RotateNode,R.ScaleNode,R.TranslateNode,R.ZIndexNode,R.RotateNode,R.SetFontStyle,R.SetPoint,R.SetLock,R.SetShapeOpt]).registerForMainEngine(Z.MainEngine,this.control),this.zIndexNodeMethod=(t=this.methodBuilder)==null?void 0:t.getBuilder(R.ZIndexNode)}setZIndex(t){const e=this.currentToolsData&&P.cloneDeep(this.currentToolsData.toolsOpt);return e&&this.zIndexNodeMethod&&this.isUseZIndex&&(this.zIndexNodeMethod.addMaxLayer(t),e.zIndex=this.zIndexNodeMethod.getMaxZIndex(t)),e}checkDrawingWork(t){var i,n,a;let e=!1;const s=[];for(const[c,{state:l,viewId:h,points:u,opt:d}]of this.localPointsBatchData.entries())if(t===h&&l===L.Start||l===L.Doing){if(l===L.Doing&&this.isCanDrawWork){Number(c)&&Number(c)+60>Date.now()&&(s.push(c.toString()),this.taskBatchData.add({msgType:z.RemoveNode,workId:c,viewId:h,dataType:F.Local,isRunSubWork:!0}));const p=u.map(f=>f);this.taskBatchData.add({op:p,workState:L.Done,workId:c,dataType:F.Local,msgType:z.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(i=this.currentToolsData)==null?void 0:i.toolsType,viewId:h,opt:d,scenePath:h&&this.viewContainerManager.getCurScenePath(h)}),e=!0}this.deleteLocalPoint(c)}if((e||s.length)&&(this.consume(),s.length)){const c=(n=this.viewContainerManager.getView(t))==null?void 0:n.focusScenePath;(a=this.collector)==null||a.dispatch({type:z.RemoveNode,removeIds:s,viewId:t,scenePath:c})}}removeDrawingWork(t){var s,i;const e=[];for(const[n,{state:a,viewId:c}]of this.localPointsBatchData.entries())(t===c&&a===L.Start||a===L.Doing)&&(this.deleteLocalPoint(n),a===L.Doing&&this.isCanDrawWork&&(e.push(n.toString()),this.taskBatchData.add({msgType:z.RemoveNode,workId:n,viewId:c,dataType:F.Local,isRunSubWork:!0})));if(e.length){this.consume();const n=(s=this.viewContainerManager.getView(t))==null?void 0:s.focusScenePath;(i=this.collector)==null||i.dispatch({type:z.RemoveNode,removeIds:e,viewId:t,scenePath:n})}}hoverCursor(t,e){var s;if(((s=this.currentToolsData)==null?void 0:s.toolsType)===C.Selector){const i=this.viewContainerManager.getView(e);if(i&&i.displayer&&i.displayer.vDom){const c=i.displayer.vDom.state.floatBarData;if(c){const{x:l,y:h,w:u,h:d}=c;if(Ci(t,{x:l,y:h,w:u,h:d}))return}}const n=this.viewContainerManager.transformToScenePoint(t,e),a={msgType:z.CursorHover,dataType:F.Local,point:n,toolsType:this.currentToolsData.toolsType,opt:this.currentToolsData.toolsOpt,isRunSubWork:!1,viewId:e};this.queryTaskBatchData({msgType:z.CursorHover,dataType:F.Local,toolsType:this.currentToolsData.toolsType,viewId:e}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add(a),this.runAnimation()}}blurCursor(t){var s;if(((s=this.currentToolsData)==null?void 0:s.toolsType)!==C.Selector)return;const e={msgType:z.CursorBlur,dataType:F.Local,isRunSubWork:!1,viewId:t};this.queryTaskBatchData({msgType:z.CursorHover,dataType:F.Local,viewId:t}).forEach(i=>{this.taskBatchData.delete(i)}),this.taskBatchData.add(e),this.consume()}sendCursorEvent(t,e){var n,a;if(!this.currentLocalWorkData||this.currentLocalWorkData.workState===L.Unwritable||!this.currentToolsData||!this.isCanSentCursor)return;const s=(n=this.collector)==null?void 0:n.uid;switch((a=this.currentToolsData)==null?void 0:a.toolsType){case C.Eraser:case C.PencilEraser:case C.BitMapEraser:{if(s&&!this.control.renderControl.isClearAble(s,e,!1))return;break}default:if(s&&!this.control.renderControl.isWriteable(s)||s&&!this.control.renderControl.isRenderAble(s,e,!1))return;break}let i=[void 0,void 0];this.currentToolsData&&this.isCanSentCursor&&!this.localPointsBatchData.size&&!this.getLockSentEventCursor()&&(i=t,this.control.cursor.sendEvent(i,e))}getBoundingRect(t){var s,i;if(!((s=this.boundingRectMap)==null?void 0:s.get(t))){const n=(i=this.collector)==null?void 0:i.getScenePathData(t);if(!n)return;if(Object.keys(n).forEach(a=>{var c;((c=this.collector)==null?void 0:c.getLocalId(a))===H&&delete n[a]}),Object.keys(n).length&&this.viewContainerManager.mainView&&this.viewContainerManager.mainView.cameraOpt){const a={msgType:z.BoundingBox,dataType:F.Local,scenePath:t,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(t,c)}).then(c=>(this.boundingRectMap.delete(t),c))}}}getSnapshot(t,e,s,i){var a,c,l,h,u;if(!((a=this.snapshotMap)==null?void 0:a.get(t))){const d=(c=this.collector)==null?void 0:c.getViewIdBySecenPath(t);if(!d)return;const p=(l=this.collector)==null?void 0:l.getStorageData(d,t);if(!p)return;if(Object.keys(p).forEach(f=>{var I;((I=this.collector)==null?void 0:I.getLocalId(f))===H&&delete p[f]}),Object.keys(p).length){const f=this.viewContainerManager.mainView;if(!f)return;const I=e||((h=f.cameraOpt)==null?void 0:h.width),y=s||((u=f.cameraOpt)==null?void 0:u.height),v={msgType:z.Snapshot,dataType:F.Local,scenePath:t,scenes:p,w:I,h:y,cameraOpt:i&&{...i,width:I,height:y}||f.cameraOpt,isRunSubWork:!0,viewId:f.id};return this.taskBatchData.add(v),this.runAnimation(),new Promise(m=>{this.snapshotMap.set(t,m)}).then(m=>(this.snapshotMap.delete(t),m))}}}queryTaskBatchData(t){const e=[];if(t)for(const s of this.taskBatchData.values()){let i=!0;for(const[n,a]of Object.entries(t))if(s[n]!==a){i=!1;break}i&&e.push(s)}return e}insertImage(t){const e=this.viewContainerManager.mainView,s=e==null?void 0:e.id,i=e==null?void 0:e.focusScenePath;if(s&&i){const{src:n,uuid:a}=t;if(a&&!n){this.tmpImageConfigMap.set(a,t);return}const c=Date.now();mt.InternalMsgEmitter.emit("addUndoTicker",c,s);const l={...t};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(s),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(s)),this.taskBatchData.add({msgType:z.FullWork,dataType:F.Local,toolsType:C.Image,workId:t.uuid,opt:l,viewId:s,willRefresh:!0,willSyncService:!0}),this.runAnimation()}}lockImage(t,e){var a,c;const s=this.viewContainerManager.mainView,i=s==null?void 0:s.id,n=s==null?void 0:s.focusScenePath;if(i&&n&&this.collector){const l=this.collector.getStorageData(i,n);if(!l)return;for(const[h,u]of Object.entries(l))if(u&&u.toolsType===C.Image&&u.opt.uuid===t){const d=Date.now();mt.InternalMsgEmitter.emit("addUndoTicker",d,i);const p=(a=this.collector)!=null&&a.isOwn(h)?(c=this.collector)==null?void 0:c.getLocalId(h):h,f={...u.opt,locked:e};this.taskBatchData.add({msgType:z.FullWork,dataType:F.Local,toolsType:C.Image,workId:p,opt:f,viewId:i,willRefresh:!0,willSyncService:!0}),this.runAnimation();return}}}completeImageUpload(t,e){const s=this.viewContainerManager.mainView,i=s==null?void 0:s.id,n=s==null?void 0:s.focusScenePath;if(i&&n){const a=this.tmpImageConfigMap.get(t);a&&(a.src=e,this.insertImage(a),this.tmpImageConfigMap.delete(t));return}}getImagesInformation(t){const e=[];if(this.collector){const s=this.collector.getScenePathData(t);if(!s)return e;for(const i of Object.values(s))if(i&&i.toolsType===C.Image){const n=i.opt;e.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 e}setShapeSelectorByWorkId(t,e){this.taskBatchData.add({workId:H,selectIds:[t],msgType:z.Select,dataType:F.Local,viewId:e,willSyncService:!0}),this.runAnimation()}blurSelector(t,e,s){this.taskBatchData.add({workId:s||H,selectIds:[],msgType:z.Select,dataType:F.Service,viewId:t,scenePath:e}),this.runAnimation()}consoleWorkerInfo(){this.taskBatchData.add({msgType:z.Console,dataType:F.Local,isRunSubWork:!0,viewId:""}),this.consume()}setPriority(t){var i,n;const e=new Set,s=new Set;if(t==="cpu"&&((i=this.subMainThreadWorker)==null||i.destroy(),e.add({msgType:z.PriorityWorker,viewId:Ue,dataType:F.Local,isRunSubWork:!0})),t==="ui"){e.add({msgType:z.PriorityMainThreadWorker,viewId:Ue,dataType:F.Local,isRunSubWork:!0});const a=this.viewContainerManager.mainView;if(a){const l=this.viewContainerManager.getViewInitData(a.id);if(l){const{offscreenCanvasOpt:h,layerOpt:u,dpr:d,cameraOpt:p}=l;s.add({msgType:z.Init,dataType:F.Local,viewId:a.id,offscreenCanvasOpt:h,layerOpt:u,dpr:d,cameraOpt:p,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 h=this.viewContainerManager.getViewInitData(l);if(h){const{offscreenCanvasOpt:u,layerOpt:d,dpr:p,cameraOpt:f}=h;s.add({msgType:z.Init,dataType:F.Local,viewId:l,offscreenCanvasOpt:u,layerOpt:d,dpr:p,cameraOpt:f,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1})}}}e.size&&this.subWorker.postMessage(e),s.size&&((n=this.subMainThreadWorker)==null||n.consume(s))}sendClearUids(t,e){var i,n;const s=new Set;s.add({msgType:z.AuthClear,dataType:F.Local,viewId:t,clearUids:e,localUid:(i=this.collector)==null?void 0:i.uid}),this.control.hasOffscreenCanvas()?this.fullWorker.postMessage(s):(n=this.mainThread)==null||n.consume(s)}}var ag=Yt,cg=function(){return ag.Date.now()},lg=cg,hg=/\s/;function ug(r){for(var o=r.length;o--&&hg.test(r.charAt(o)););return o}var dg=ug,pg=dg,fg=/^\s+/;function gg(r){return r&&r.slice(0,pg(r)+1).replace(fg,"")}var Mg=gg,yg=se,mg=Qt,wg="[object Symbol]";function Ig(r){return typeof r=="symbol"||mg(r)&&yg(r)==wg}var vg=Ig,Ng=Mg,ks=Jt,Tg=vg,xs=NaN,Sg=/^[-+]0x[0-9a-f]+$/i,Cg=/^0b[01]+$/i,kg=/^0o[0-7]+$/i,xg=parseInt;function zg(r){if(typeof r=="number")return r;if(Tg(r))return xs;if(ks(r)){var o=typeof r.valueOf=="function"?r.valueOf():r;r=ks(o)?o+"":o}if(typeof r!="string")return r===0?r:+r;r=Ng(r);var t=Cg.test(r);return t||kg.test(r)?xg(r.slice(2),t?2:8):Sg.test(r)?xs:+r}var bg=zg,Lg=Jt,Mo=lg,zs=bg,Pg="Expected a function",jg=Math.max,Dg=Math.min;function Ag(r,o,t){var e,s,i,n,a,c,l=0,h=!1,u=!1,d=!0;if(typeof r!="function")throw new TypeError(Pg);o=zs(o)||0,Lg(t)&&(h=!!t.leading,u="maxWait"in t,i=u?jg(zs(t.maxWait)||0,o):i,d="trailing"in t?!!t.trailing:d);function p(T){var x=e,b=s;return e=s=void 0,l=T,n=r.apply(b,x),n}function f(T){return l=T,a=setTimeout(v,o),h?p(T):n}function I(T){var x=T-c,b=T-l,A=o-x;return u?Dg(A,i-b):A}function y(T){var x=T-c,b=T-l;return c===void 0||x>=o||x<0||u&&b>=i}function v(){var T=Mo();if(y(T))return m(T);a=setTimeout(v,I(T))}function m(T){return a=void 0,d&&e?p(T):(e=s=void 0,n)}function w(){a!==void 0&&clearTimeout(a),l=0,e=c=s=a=void 0}function N(){return a===void 0?n:m(Mo())}function S(){var T=Mo(),x=y(T);if(e=arguments,s=this,c=T,x){if(a===void 0)return f(c);if(u)return clearTimeout(a),a=setTimeout(v,o),p(c)}return a===void 0&&(a=setTimeout(v,o)),n}return S.cancel=w,S.flush=N,S}var Eg=Ag,Og=Eg,Rg=Jt,Yg="Expected a function";function Wg(r,o,t){var e=!0,s=!0;if(typeof r!="function")throw new TypeError(Yg);return Rg(t)&&(e="leading"in t?!!t.leading:e,s="trailing"in t?!!t.trailing:s),Og(r,o,{leading:e,maxWait:o,trailing:s})}var Ug=Wg;const je=ye(Ug);class Bg{constructor(o){M(this,"internalMsgEmitter");M(this,"control");M(this,"roomHotkeyCheckers");M(this,"tmpCopyStore",new Map);M(this,"tmpCopyCoordInfo");var s;const{control:t,internalMsgEmitter:e}=o;this.control=t,this.internalMsgEmitter=e,this.roomHotkeyCheckers=((s=this.control.room)==null?void 0:s.viewsParams.hotKeys.nodes)||[]}get isUseSelf(){var o;return((o=this.control.room)==null?void 0:o.disableDeviceInputs)||!1}get isSelector(){var o;return((o=this.control.worker.currentToolsData)==null?void 0:o.toolsType)===C.Selector}get collector(){return this.control.collector}get mainEngine(){return this.control.worker}get keyboardKind(){return/^Mac/i.test(navigator.platform)?"mac":"windows"}getEventKey(o){switch(o.type){case"keydown":return"KeyDown"}return"KeyUp"}onActiveHotkey(o){var s,i,n;const t=this.control.viewContainerManager.focuedViewId,e=(s=this.control.viewContainerManager.focuedView)==null?void 0:s.focusScenePath;if(t&&e)switch(o){case"delete":this.isSelector&&((i=this.collector)!=null&&i.hasSelector(t,e))&&q.emitMethod(Z.MainEngine,R.DeleteNode,{workIds:[H],viewId:t});break;case"copy":this.isSelector&&((n=this.collector)!=null&&n.hasSelector(t,e))&&this.copySelectorToTemp(t,e);break;case"paste":this.tmpCopyStore.size&&this.pasteTempToFocusView(t,e);break}(o==="changeToPencil"||o==="redo"||o==="undo")&&this.onSelfActiveHotkey(o)}colloctHotkey(o){if(this.isUseSelf){const t=this.checkHotkey(o);t&&this.onSelfActiveHotkey(t)}}onSelfActiveHotkey(o){switch(o){case"changeToPencil":this.setMemberState({currentApplianceName:et.pencil,useNewPencil:!0});break;case"changeToArrow":this.setMemberState({currentApplianceName:et.arrow});break;case"changeToClick":this.setMemberState({currentApplianceName:et.clicker});break;case"changeToEllipse":this.setMemberState({currentApplianceName:et.ellipse});break;case"changeToEraser":this.setMemberState({currentApplianceName:et.eraser,isLine:!0});break;case"changeToHand":this.setMemberState({currentApplianceName:et.hand});break;case"changeToLaserPointer":this.setMemberState({currentApplianceName:et.laserPointer});break;case"changeToSelector":this.setMemberState({currentApplianceName:et.selector});break;case"changeToRectangle":this.setMemberState({currentApplianceName:et.rectangle});break;case"changeToStraight":this.setMemberState({currentApplianceName:et.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:et.text});break}}checkHotkey(o){for(const t of this.roomHotkeyCheckers){const{kind:e,checker:s}=t;if(s({nativeEvent:o,kind:this.getEventKey(o),key:o.key,altKey:o.altKey,ctrlKey:o.ctrlKey,shiftKey:o.shiftKey},this.keyboardKind))return e}}copySelectorToTemp(o,t){var l,h;const e=this.control.viewContainerManager.getView(o),s=(h=(l=this.mainEngine)==null?void 0:l.methodBuilder)==null?void 0:h.getBuilder(R.CopyNode);if(!e||!this.collector||!s)return;const i=this.collector.transformKey(H),n=this.collector.getStorageData(o,t);if(!n)return;const a=n[i],c=a&&s.copySelector({viewId:o,store:a});c&&(this.tmpCopyCoordInfo=c==null?void 0:c.copyCoordInfo,this.tmpCopyStore=c==null?void 0:c.copyStores)}pasteTempToFocusView(o,t){var i,n;const e=this.control.viewContainerManager.getView(o),s=(n=(i=this.mainEngine)==null?void 0:i.methodBuilder)==null?void 0:n.getBuilder(R.CopyNode);if(!(!e||!this.tmpCopyCoordInfo||!this.tmpCopyStore.size||!this.collector||!s)&&e.viewData&&this.tmpCopyCoordInfo){const a=P.cloneDeep(this.tmpCopyCoordInfo.offset),c=this.tmpCopyCoordInfo.cameraOpt,l=e.viewData.camera;a.x=a.x+l.centerX-c.centerX,a.y=a.y+l.centerY-c.centerY;const h=Date.now();this.control.worker.internalMsgEmitter.emit("addUndoTicker",h,o),s.pasteSelector({viewId:o,scenePath:t,copyStores:P.cloneDeep(this.tmpCopyStore),copyCoordInfo:{offset:a,cameraOpt:l},undoTickerId:h})}}setMemberState(o){var t;(t=this.control.room)==null||t.setMemberState(o)}}class Fg{constructor(o){M(this,"control");M(this,"roomMemberManager");M(this,"worker");M(this,"writeableUids",new Set);M(this,"readonlyUids",new Set);M(this,"renderUids",new Map);M(this,"isCurWrite",!0);const{control:t}=o;this.control=t,this.roomMemberManager=t.roomMember,this.worker=t.worker}onSetWriteable(o){var e;this.isCurWrite=o;const t=(e=this.control.collector)==null?void 0:e.uid;t&&this.publishOneWriteAble(t,o?"write":"readOnly",!0)}getCurWriteable(){return this.isCurWrite}isWriteable(o){return P.isSet(this.readonlyUids)&&!this.readonlyUids.has(o)?!0:!!(P.isSet(this.writeableUids)&&this.writeableUids.has(o))}isRenderAble(o,t,e=!0){var a,c;const s=this.renderUids.get(t);if(!s)return!0;const{render:i,hide:n}=s;if(i===void 0&&n===void 0)return!0;if(P.isSet(i)){if(i.has(o)||e&&((a=this.control.collector)==null?void 0:a.uid)===o&&i.has("localSelf"))return!0}else if(i===!0&&(!n||P.isSet(n)&&!n.has(o)&&!(e&&n.has("localSelf")&&((c=this.control.collector)==null?void 0:c.uid)===o)))return!0;return!1}isClearAble(o,t,e=!0){var n;const s=this.renderUids.get(t);if(!s)return!0;const{clear:i}=s;return!!(i===void 0||i===!0||P.isSet(i)&&(i.has(o)||e&&((n=this.control.collector)==null?void 0:n.uid)===o&&i.has("localSelf")))}publishWriteAble(o,t){var e;if(o===!0)this.writeableUids=!0;else if(P.isArray(o)){const s=new Set(o);this.writeableUids=s}else this.writeableUids=new Set;if(t===!0)this.readonlyUids=!0;else if(P.isArray(t)){const s=new Set(t);this.readonlyUids=s}else this.readonlyUids=new Set;this.writeEffect(),(e=this.control.collector)==null||e.dispatchAuth({type:z.AuthWriter,writeData:{writable:o,readOnly:t}})}publishOneWriteAble(o,t,e=!0){var s;if(P.isString(o)){switch(t){case"write":P.isSet(this.writeableUids)&&this.writeableUids.add(o),P.isSet(this.readonlyUids)&&this.readonlyUids.has(o)&&this.readonlyUids.delete(o);break;case"readOnly":P.isSet(this.readonlyUids)&&this.readonlyUids.add(o),P.isSet(this.writeableUids)&&this.writeableUids.has(o)&&this.writeableUids.delete(o);break}this.writeEffect(),e&&((s=this.control.collector)==null||s.dispatchAuth({type:z.AuthWriter,writeData:{writable:this.writeableUids===!0&&!0||Array.from(this.writeableUids),readOnly:this.readonlyUids===!0&&!0||Array.from(this.readonlyUids)}}))}}publishRender(o){var i;const{viewId:t,option:e,isSync:s=!0}=o;if(e){const n={},{render:a,hide:c,clear:l}=e;a&&(n.render=a===!0&&!0||new Set(a)),c&&(n.hide=c===!0&&!0||new Set(c)),l&&(n.clear=l===!0&&!0||new Set(l)),this.renderUids.set(t,n)}else this.renderUids.delete(t);this.renderEffect(t),s&&((i=this.control.collector)==null||i.dispatchAuth({type:z.AuthReader,viewId:t,renderData:e},s))}publishOneRender(o,t,e,s=!0){var n;const i=this.renderUids.get(o);switch(e){case"show":i?(i.render||(i.render=new Set),P.isSet(i.render)&&i.render.add(t),P.isSet(i.hide)&&i.hide.delete(t)):this.renderUids.set(o,{render:new Set([t])});break;case"hide":i?(i.hide||(i.hide=new Set),P.isSet(i.hide)&&i.hide.add(t),P.isSet(i.render)&&i.render.delete(t)):this.renderUids.set(o,{hide:new Set([t])});break}if(i?this.renderUids.set(o,i):this.renderUids.delete(o),this.renderEffect(o),s){const a={};if(i)for(const c of Object.keys(i)){const l=i[c];a[c]=l===!0?!0:P.isSet(l)&&l.size?Array.from(l):void 0}(n=this.control.collector)==null||n.dispatchAuth({type:z.AuthReader,viewId:o,renderData:a},s)}}publishOneClear(o,t,e,s=!0){var n;const i=this.renderUids.get(o);if(e?i?(i.clear||(i.clear=new Set),P.isSet(i.clear)&&i.clear.add(t)):this.renderUids.set(o,{clear:new Set([t])}):i&&P.isSet(i.clear)&&i.clear.has(t)&&i.clear.delete(t),i?this.renderUids.set(o,i):this.renderUids.delete(o),this.renderEffect(o),s){const a={};if(i)for(const c of Object.keys(i)){const l=i[c];a[c]=l===!0?!0:P.isSet(l)&&l.size?Array.from(l):void 0}(n=this.control.collector)==null||n.dispatchAuth({type:z.AuthReader,viewId:o,renderData:a},s)}}syncRenderUids(o,t,e,s){const i=t===!0?!0:P.isArray(t)?new Set(t):void 0,n=e===!0?!0:P.isArray(e)?new Set(e):void 0,a=s===!0?!0:P.isArray(s)?new Set(s):void 0;i||n||a?this.renderUids.set(o,{render:i,hide:n,clear:a}):this.renderUids.delete(o),this.renderEffect(o)}syncWriteable(o,t){o?this.writeableUids=o===!0?!0:new Set(o):this.writeableUids=new Set,t?this.readonlyUids=t===!0?!0:new Set(t):this.readonlyUids=new Set,this.writeEffect()}destoryByViewId(o,t=!1){var e;this.renderUids.delete(o),t||(e=this.control.collector)==null||e.dispatchAuth({type:z.AuthReader,viewId:o})}renderEffect(o){var e;const t=(e=this.control.viewContainerManager.getView(o))==null?void 0:e.focusScenePath;t&&this.worker.clearViewScenePath(o,!0).then(()=>{var s;this.worker.pullServiceData(o,t,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(o,(s=this.renderUids.get(o))==null?void 0:s.clear)})}writeEffect(){var e,s,i,n,a;const o=this.writeableUids,t=this.readonlyUids;if((e=this.control.collector)!=null&&e.uid){if(o===!0){if(P.isSet(t)&&t.has(this.control.collector.uid)){(s=this.control.room)==null||s.setWritable(!1);return}(i=this.control.room)==null||i.setWritable(!0);return}if(P.isSet(o)){if(o.has(this.control.collector.uid)){(n=this.control.room)==null||n.setWritable(!0);return}if(P.isSet(t)&&t.has(this.control.collector.uid)||t===!0){(a=this.control.room)==null||a.setWritable(!1);return}}}}}const be=class be{constructor(o){M(this,"version",ai);M(this,"plugin");M(this,"room");M(this,"play");M(this,"collector");M(this,"hasSwitchToSelectorEffect");M(this,"snapshootStateMap");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,"onSceneChange",async(o,t)=>{var n;const e=this.viewContainerManager.getView(t);e!=null&&e.focusScenePath&&(n=this.collector)!=null&&n.hasSelector(t,e.focusScenePath)&&this.worker.blurSelector(t,e.focusScenePath),this.textEditorManager.checkEmptyTextBlur();const s=e==null?void 0:e.displayer;s&&(s.setActive(!1),await s.stopEventHandler());const i=o;i&&this.viewContainerManager.setViewScenePath(t,i),s==null||s.setActive(!0)});M(this,"onRoomMembersChange",o=>{this.roomMember.setRoomMembers(st.toJS(o))});M(this,"onMemberChange",je(o=>{if(!this.room||!this.worker||!o)return;const t=this.getToolsKey(o),e=this.getToolsOpt(t,o);this.worker.setCurrentToolsData(e),this.effectViewContainer(t),this.effectResolve&&this.effectResolve(!0)},100,{leading:!1}));M(this,"internalSceneChange",(o,t)=>{var e;(e=this.worker)==null||e.clearViewScenePath(o,!0).then(()=>{var s;(s=this.worker)==null||s.pullServiceData(o,t,{isAsync:!0,useAnimation:!1})})});M(this,"internalCameraChange",(o,t)=>{var e;(e=this.worker)==null||e.updateCamera(o,t)});const{displayer:t,plugin:e,options:s}=o;this.plugin=e,this.room=st.isRoom(t)?t:void 0,this.play=st.isPlayer(t)?t:void 0,this.pluginOptions=s,this.roomMember=new Yf;const i={control:this,internalMsgEmitter:be.InternalMsgEmitter};this.cursor=new Ff(i),this.textEditorManager=new Bf(i),this.worker=new rg(i),this.hotkeyManager=new Bg(i),this.renderControl=new Fg(i)}setPriority(o){var t;this.priority=o,this.hasOffscreenCanvas()&&((t=this.worker)==null||t.setPriority(o))}hasOffscreenCanvas(){return ci==="worker"}bindPlugin(o){var t,e;this.plugin=o,this.collector&&(this.collector.removeStorageStateListener(),this.collector.removeAuthStateListener()),this.collector=new So(this,o,(e=(t=this.pluginOptions)==null?void 0:t.syncOpt)==null?void 0:e.interval),this.activePlugin()}destroy(){var o,t,e,s,i;this.roomMember.destroy(),(o=this.collector)==null||o.destroy(),(t=this.worker)==null||t.destroy(),(e=this.viewContainerManager)==null||e.destroy(),(s=this.cursor)==null||s.destroy(),(i=this.textEditorManager)==null||i.destory()}cleanCurrentScene(){const o=Date.now(),t=this.worker.getLocalWorkViewId()||this.viewContainerManager.focuedViewId;t&&(be.InternalMsgEmitter.emit("addUndoTicker",o,t),this.worker.clearViewScenePath(t,!1,!0))}onWritableChange(o){var t,e,s,i;o?((s=this.renderControl)==null||s.onSetWriteable(!0),(i=this.worker)==null||i.abled()):((t=this.renderControl)==null||t.onSetWriteable(!1),(e=this.worker)==null||e.unWritable())}getToolsKey(o){var e;const t=o.currentApplianceName;switch(this.hasSwitchToSelectorEffect=!1,t){case et.text:return o.textCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Text;case et.pencil:return o.useLaserPen?C.LaserPen:C.Pencil;case et.eraser:return C.Eraser;case et.pencilEraser:return((e=this.pluginOptions.pencilEraser)==null?void 0:e.useBitMap)===!1?C.PencilEraser:C.BitMapEraser;case et.selector:return C.Selector;case et.arrow:return o.arrowCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Arrow;case et.straight:return o.straightCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Straight;case et.ellipse:return o.ellipseCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Ellipse;case et.rectangle:return o.rectangleCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Rectangle;case et.shape:if(o.shapeCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),o.shapeType===Dt.Pentagram||o.shapeType===Dt.Star)return C.Star;if(o.shapeType===Dt.Polygon||o.shapeType===Dt.Triangle||o.shapeType===Dt.Rhombus)return C.Polygon;if(o.shapeType===Dt.SpeechBalloon)return C.SpeechBalloon;break}return C.Clicker}getToolsOpt(o,t){if(o===C.Clicker)return{toolsType:o,toolsOpt:{}};const e={strokeColor:Oe(t.strokeColor[0],t.strokeColor[1],t.strokeColor[2],t.strokeOpacity||1),thickness:t.strokeWidth,isOpacity:(t==null?void 0:t.strokeOpacity)&&t.strokeOpacity<1||(t==null?void 0:t.fillOpacity)&&t.fillOpacity<1||(t==null?void 0:t.textOpacity)&&t.textOpacity<1||(t==null?void 0:t.textBgOpacity)&&t.textBgOpacity<1||!1};switch(o){case C.Text:e.fontFamily=window.getComputedStyle(document.documentElement).getPropertyValue("font-family"),e.fontSize=(t==null?void 0:t.textSizeOverride)||(t==null?void 0:t.textSize)||Number(window.getComputedStyle(document.body).fontSize),e.textAlign=(t==null?void 0:t.textAlign)||"left",e.verticalAlign=(t==null?void 0:t.verticalAlign)||"middle",e.fontColor=(t==null?void 0:t.textColor)&&Oe(t.textColor[0],t.textColor[1],t.textColor[2],t.textOpacity||1)||e.strokeColor||"rgba(0,0,0,1)",e.fontBgColor=Array.isArray(t==null?void 0:t.textBgColor)&&Oe(t.textBgColor[0],t.textBgColor[1],t.textBgColor[2],t.textBgOpacity||1)||"transparent",e.bold=(t==null?void 0:t.bold)&&"bold"||void 0,e.italic=(t==null?void 0:t.italic)&&"italic"||void 0,e.underline=(t==null?void 0:t.underline)||void 0,e.lineThrough=(t==null?void 0:t.lineThrough)||void 0,e.text="",e.strokeColor=void 0;break;case C.Pencil:e.strokeType=(t==null?void 0:t.strokeType)||X.Normal;break;case C.PencilEraser:case C.BitMapEraser:case C.Eraser:e.thickness=Math.min(3,Math.max(1,Math.floor(t.pencilEraserSize||1)))-1;break;case C.LaserPen:e.duration=(t==null?void 0:t.duration)||1,t!=null&&t.strokeType&&(t==null?void 0:t.strokeType)===X.Stroke?e.strokeType=X.Normal:e.strokeType=(t==null?void 0:t.strokeType)||X.Normal;break;case C.Arrow:case C.Straight:t!=null&&t.strokeType&&(t==null?void 0:t.strokeType)===X.Stroke?e.strokeType=X.Normal:e.strokeType=(t==null?void 0:t.strokeType)||X.Normal;break;case C.Ellipse:case C.Rectangle:case C.Star:case C.Polygon:case C.SpeechBalloon:t!=null&&t.strokeType&&(t==null?void 0:t.strokeType)===X.Stroke?e.strokeType=X.Normal:e.strokeType=(t==null?void 0:t.strokeType)||X.Normal,o===C.Star&&(t.shapeType===Dt.Pentagram?(e.vertices=10,e.innerVerticeStep=2,e.innerRatio=.4):t!=null&&t.vertices&&(t!=null&&t.innerVerticeStep)&&(t!=null&&t.innerRatio)&&(e.vertices=t.vertices,e.innerVerticeStep=t.innerVerticeStep,e.innerRatio=t.innerRatio)),o===C.Polygon&&(t.shapeType===Dt.Triangle?e.vertices=3:t.shapeType===Dt.Rhombus?e.vertices=4:t.vertices&&(e.vertices=t.vertices)),e.fillColor=(t==null?void 0:t.fillColor)&&Oe(t.fillColor[0],t.fillColor[1],t.fillColor[2],t==null?void 0:t.fillOpacity)||"transparent",o===C.SpeechBalloon&&(e.placement=t.placement||"bottomLeft");break}return{toolsType:o,toolsOpt:e}}effectViewContainer(o){var t,e,s,i,n;switch(o){case C.Text:case C.Pencil:case C.LaserPen:case C.Arrow:case C.Straight:case C.Rectangle:case C.Ellipse:case C.Star:case C.Polygon:case C.SpeechBalloon:case C.Triangle:case C.Rhombus:case C.Eraser:case C.PencilEraser:case C.BitMapEraser:this.room.disableDeviceInputs=!0,(t=this.worker)==null||t.abled();break;case C.Selector:this.room.disableDeviceInputs=!1,(e=this.cursor)==null||e.unabled(),(s=this.worker)==null||s.abled();break;default:this.room.disableDeviceInputs=!1,(i=this.worker)==null||i.unWritable(),(n=this.cursor)==null||n.unabled();break}setTimeout(()=>{this.viewContainerManager.getAllViews().forEach(c=>{c!=null&&c.displayer&&c.displayer.bindToolsClass()})},0)}async getBoundingRect(o){var e,s,i,n,a;const t=await((e=this.worker)==null?void 0:e.getBoundingRect(o));if(t){const c=((i=(s=this.viewContainerManager.mainView)==null?void 0:s.viewData)==null?void 0:i.convertToPointInWorld({x:t.x,y:t.y}))||{x:t.x,y:t.y},l=((a=(n=this.viewContainerManager.mainView)==null?void 0:n.viewData)==null?void 0:a.camera.scale)||1;return{width:Math.floor(t.w/l)+1,height:Math.floor(t.h/l)+1,originX:c.x,originY:c.y}}}async screenshotToCanvas(o,t,e,s,i,n,a){const c=await this.worker.getSnapshot(t,e,s,i);c&&(o.drawImage(c,n||0,a||0),c.close())}async scenePreview(o,t){var n,a,c,l;const e=(n=this.collector)==null?void 0:n.getViewIdBySecenPath(o);if(!e)return;const s=this.viewContainerManager.getView(e);if(!s||!((a=s.cameraOpt)!=null&&a.width)||!((c=s.cameraOpt)!=null&&c.height))return;const i=await((l=this.worker)==null?void 0:l.getSnapshot(o));if(i&&this.worker){const h=document.createElement("canvas"),u=h.getContext("2d"),{width:d,height:p}=s.cameraOpt;h.width=d,h.height=p,u&&(u.drawImage(i,0,0),t.crossOrigin="anonymous",t.src=h.toDataURL(),t.onload=()=>{h.remove()},t.onerror=()=>{h.remove(),t.remove()}),i.close()}}switchToText(){var o;(o=this.room)==null||o.setMemberState({currentApplianceName:et.text})}switchToSelector(){var o;(o=this.room)==null||o.setMemberState({currentApplianceName:et.selector})}async runEffectWork(o){if(this.hasSwitchToSelectorEffect){const t=await new Promise(e=>{this.switchToSelector(),this.effectResolve=e});this.effectResolve=void 0,t&&o&&o()}}setSnapshootData(){var o;this.room&&(this.snapshootStateMap=new Map,this.snapshootStateMap.set("memberState",(o=this.room)==null?void 0:o.state.memberState))}getSnapshootData(o){var t;return(t=this.snapshootStateMap)==null?void 0:t.get(o)}clearSnapshootData(){var o;(o=this.snapshootStateMap)==null||o.clear(),this.snapshootStateMap=void 0}useBitMapEraser(o){var t;if(((t=this.pluginOptions.pencilEraser)==null?void 0:t.useBitMap)===void 0){this.pluginOptions.pencilEraser={useBitMap:o};return}this.pluginOptions.pencilEraser.useBitMap=o}consoleWorkerInfo(){var o;(o=this.worker)==null||o.consoleWorkerInfo()}publishSelfWriteable(o,t=!0){var s,i;const e=(s=this.collector)==null?void 0:s.uid;e&&((i=this.renderControl)==null||i.publishOneWriteAble(e,o&&"write"||"readOnly",t))}filterRenderByUid(o,t,e=!0){var i;this.viewContainerManager.getView(o)&&((i=this.renderControl)==null||i.publishRender({viewId:o,option:t,isSync:e}))}cancelFilterRender(o,t=!0){var e;(e=this.renderControl)==null||e.publishRender({viewId:o,isSync:t})}};M(be,"InternalMsgEmitter",new js);let mt=be;const te=class te{constructor(o){M(this,"emitter",new js);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",P.debounce(()=>{const o=this.control.viewContainerManager.getCurScenePath(this.viewId);if(o){let t=this.undoStack.filter(s=>s.scenePath===o).length;const e=this.redoStack.filter(s=>s.scenePath===o).length;t===0&&e===0&&this.tickStartStorerCache&&this.scenePath===o&&(t=1),this.emitter.emit("onCanUndoStepsUpdate",t),this.emitter.emit("onCanRedoStepsUpdate",e)}},te.waitTime));const{control:t,internalMsgEmitter:e,viewId:s}=o;this.control=t,this.emitter=e,this.undoStack=[],this.redoStack=[],this.room=t.room,this.worker=t.worker,this.isTicking=!1,this.viewId=s}get collector(){return this.control.collector}addExcludeIds(o){if(this.isTicking)for(const t of o)this.excludeIds.add(t)}undoTickerStart(o,t){if(this.collector&&(this.undoTickerId!==o||this.scenePath!==t)){!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 e=this.collector.transformKey(H);this.excludeIds.add(e),this.undoTickerId=o,this.scenePath=t;const s=this.collector.getStorageData(this.viewId,t)||{};this.tickStartStorerCache=new Map(Object.entries(P.cloneDeep(s)))}}undoTickerEndSync(o,t,e){var s,i;if(o===this.undoTickerId&&e===this.scenePath&&t===this.viewId&&this.tickStartStorerCache){const n=((s=this.collector)==null?void 0:s.storage[t])&&((i=this.collector)==null?void 0:i.storage[t][e])||{},a=this.diffFun(this.tickStartStorerCache,new Map(Object.entries(n)));a.size&&(this.undoStack.push({id:o,type:2,data:P.cloneDeep(a),scenePath:e}),this.undoStack.length>te.MaxStackLength&&this.undoStack.shift(),this.emitter.emit("onCanUndoStepsUpdate",this.undoStack.length)),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(o){this.undoTickerId&&this.tickStartStorerCache&&this.scenePath&&this.undoTickerEndSync(this.undoTickerId,this.viewId,this.scenePath);let t=this.undoStack.length-1;for(;t>=0;){if(this.undoStack[t].scenePath===o){const n=this.undoStack[t];n&&(this.redoStack.push(n),n.type===2&&n.data&&this.refreshPlugin(n)),this.undoStack.splice(t,1);break}t--}const e=this.undoStack.filter(i=>i.scenePath===o).length,s=this.redoStack.filter(i=>i.scenePath===o).length;return this.emitter.emit("onCanUndoStepsUpdate",e),this.emitter.emit("onCanRedoStepsUpdate",s),e}redo(o){let t=this.redoStack.length-1;for(;t>=0;){if(this.redoStack[t].scenePath===o){const n=this.redoStack[t];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(t,1);break}t--}const e=this.undoStack.filter(i=>i.scenePath===o).length,s=this.redoStack.filter(i=>i.scenePath===o).length;return this.emitter.emit("onCanUndoStepsUpdate",e),this.emitter.emit("onCanRedoStepsUpdate",s),s}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 o=this.control.viewContainerManager.getCurScenePath(this.viewId);if(o){let t=this.undoStack.filter(s=>s.scenePath===o).length;const e=this.redoStack.filter(s=>s.scenePath===o).length;t===0&&e===0&&this.tickStartStorerCache&&this.scenePath===o&&(t=1),this.emitter.emit("onCanUndoStepsUpdate",t),this.emitter.emit("onCanRedoStepsUpdate",e)}}diffFun(o,t){const e=new Set,s=o.keys(),i=t.keys();for(const n of s){if(this.excludeIds.has(n))continue;const a=o.get(n),c=t.get(n);if(a&&c){if(P.isEqual(c,a))continue;e.add({dataType:3,key:n,data:[a,c]});continue}a&&e.add({dataType:2,key:n,data:a})}for(const n of i){if(this.excludeIds.has(n))continue;const a=t.get(n);a&&!o.has(n)&&e.add({dataType:1,key:n,data:a})}return e}isDrawEffectiveScene(o,t){const{key:e}=o;return!t.includes(e)}isDeleteEffectiveScene(o,t,e){var n;const{key:s}=o;if(!t.includes(s))return!1;const i=t.filter(a=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(a))===H&&!((l=this.collector)!=null&&l.isOwn(a))}).map(a=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][e][a]});for(const a of i)if((n=a==null?void 0:a.selectIds)!=null&&n.includes(s))return!1;return!0}isOldEffectiveScene(o,t,e){var n;const{key:s}=o;if(!t.includes(s))return!1;const i=t.filter(a=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(a))===H&&!((l=this.collector)!=null&&l.isOwn(a))}).map(a=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][e][a]});for(const a of i)if((n=a==null?void 0:a.selectIds)!=null&&n.includes(s))return!1;return!0}isNewEffectiveScene(o,t){const{key:e}=o;return!!t.includes(e)}refreshPlugin(o,t=!1){var n,a,c,l,h,u,d,p,f,I,y,v,m,w,N,S,T,x,b,A,O;let e;const{scenePath:s}=o,i=o.data;if(!(!i||!this.collector))for(const j of i.values()){const{dataType:E,data:D,key:_}=j,nt=this.collector.getStorageData(this.viewId,s),tt=nt&&Object.keys(nt)||[];switch(E){case 1:if(e=t?this.isDrawEffectiveScene(j,tt):this.isDeleteEffectiveScene(j,tt,s),e)if(t&&!Array.isArray(D)){if((n=D.updateNodeOpt)!=null&&n.useAnimation&&(D.updateNodeOpt.useAnimation=!1),((a=this.collector)==null?void 0:a.getLocalId(_))===H&&((c=this.collector)!=null&&c.isOwn(j.key))){const V=D.selectIds;if(V){const K=tt.filter(G=>{var J,rt;return((J=this.collector)==null?void 0:J.getLocalId(G))===H&&!((rt=this.collector)!=null&&rt.isOwn(G))}).map(G=>{var J;return(J=this.collector)==null?void 0:J.storage[this.viewId][s][G]});let $=!1;for(const G of K)for(let J=0;J<V.length;J++)(l=G==null?void 0:G.selectIds)!=null&&l.includes(V[J])&&(delete V[J],$=!0);$&&(D.selectIds=V.filter(G=>!!G))}}(h=this.collector)==null||h.updateValue(j.key,D,{isAfterUpdate:!0,viewId:this.viewId,scenePath:s,isSync:!0})}else!t&&!Array.isArray(j.data)&&((u=this.collector)==null||u.updateValue(j.key,void 0,{isAfterUpdate:!0,viewId:this.viewId,scenePath:s,isSync:!0}));break;case 2:if(e=t?this.isDeleteEffectiveScene(j,tt,s):this.isDrawEffectiveScene(j,tt),e){if(t&&!Array.isArray(D))(d=this.collector)==null||d.updateValue(_,void 0,{isAfterUpdate:!0,viewId:this.viewId,scenePath:s,isSync:!0});else if(!t&&!Array.isArray(D)){if((p=D.updateNodeOpt)!=null&&p.useAnimation&&(D.updateNodeOpt.useAnimation=!1),((f=this.collector)==null?void 0:f.getLocalId(j.key))===H&&((I=this.collector)!=null&&I.isOwn(j.key))){const V=D.selectIds;if(V){const K=tt.filter(G=>{var J,rt;return((J=this.collector)==null?void 0:J.getLocalId(G))===H&&!((rt=this.collector)!=null&&rt.isOwn(G))}).map(G=>{var J;return(J=this.collector)==null?void 0:J.storage[this.viewId][s][G]});let $=!1;for(const G of K)for(let J=0;J<V.length;J++)(y=G==null?void 0:G.selectIds)!=null&&y.includes(V[J])&&(delete V[J],$=!0);$&&(D.selectIds=V.filter(G=>!!G))}}(v=this.collector)==null||v.updateValue(j.key,j.data,{isAfterUpdate:!0,viewId:this.viewId,scenePath:s,isSync:!0})}}break;case 3:if(e=t?this.isNewEffectiveScene(j,tt):this.isOldEffectiveScene(j,tt,s),e){if(t&&Array.isArray(D)&&D.length===2){const V=D[1];if((m=V.updateNodeOpt)!=null&&m.useAnimation&&(V.updateNodeOpt.useAnimation=!1),((w=this.collector)==null?void 0:w.getLocalId(j.key))===H&&((N=this.collector)!=null&&N.isOwn(j.key))){const K=V.selectIds;if(K){const $=tt.filter(J=>{var rt,It;return((rt=this.collector)==null?void 0:rt.getLocalId(J))===H&&!((It=this.collector)!=null&&It.isOwn(J))}).map(J=>{var rt;return(rt=this.collector)==null?void 0:rt.storage[this.viewId][s][J]});let G=!1;for(const J of $)for(let rt=0;rt<K.length;rt++)J!=null&&J.selectIds&&((S=J.selectIds)!=null&&S.includes(K[rt]))&&(delete K[rt],G=!0);G&&(V.selectIds=K.filter(J=>!!J))}}(T=this.collector)==null||T.updateValue(_,V,{isAfterUpdate:!0,viewId:this.viewId,scenePath:s,isSync:!0})}else if(!t&&Array.isArray(D)&&D.length===2){const V=D[0];if((x=V.updateNodeOpt)!=null&&x.useAnimation&&(V.updateNodeOpt.useAnimation=!1),((b=this.collector)==null?void 0:b.getLocalId(j.key))===H&&((A=this.collector)!=null&&A.isOwn(j.key))){const K=V.selectIds;if(K){const $=tt.filter(J=>{var rt,It;return((rt=this.collector)==null?void 0:rt.getLocalId(J))===H&&!((It=this.collector)!=null&&It.isOwn(J))}).map(J=>{var rt;return(rt=this.collector)==null?void 0:rt.storage[this.viewId][s][J]});let G=!1;for(const J of $)for(let rt=0;rt<K.length;rt++)J!=null&&J.selectIds&&J.selectIds.includes(K[rt])&&(delete K[rt],G=!0);G&&(V.selectIds=K.filter(J=>!!J))}}(O=this.collector)==null||O.updateValue(j.key,V,{isAfterUpdate:!0,viewId:this.viewId,scenePath:s,isSync:!0})}}break}}}};M(te,"sdkCallBack"),M(te,"MaxStackLength",20),M(te,"waitTime",100);let Xe=te;function Hg(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 fe(r){return Hg(r)&&(r.touches&&r.touches.length===1||r.changedTouches&&r.changedTouches.length===1)}function xi(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 ge{constructor(o){M(this,"internalMsgEmitter");M(this,"control");M(this,"mainView");M(this,"appViews",new Map);const{control:t,internalMsgEmitter:e}=o;this.control=t,this.internalMsgEmitter=e,this.internalMsgEmitter.on("addUndoTicker",this.undoTickerStart.bind(this)),this.internalMsgEmitter.on("excludeIds",this.addExcludeIds.bind(this))}undoTickerStart(o,t){const e=this.getView(t);e&&e.displayer&&e.focusScenePath&&e.displayer.commiter.undoTickerStart(o,e.focusScenePath)}addExcludeIds(o,t){const e=this.getView(t);e&&e.displayer&&e.focusScenePath&&e.displayer.commiter.addExcludeIds(o)}undo(){const o=this.focuedView;let t=0;if(o){const e=o.focusScenePath;t=o.displayer.commiter.undo(e)||0}return t}redo(){const o=this.focuedView;let t=0;if(o){const e=o.focusScenePath;t=o.displayer.commiter.redo(e)||0}return t}validator(o,t,e){var n;const s=P.clone(o[t]),i=P.clone(e);t==="focusScenePath"&&e&&!P.isEqual(s,i)&&(this.control.internalSceneChange(o.id,i),(n=this.focuedView)==null||n.displayer.commiter.onChangeScene()),t==="cameraOpt"&&!P.isEqual(s,i)&&this.control.internalCameraChange(o.id,i)}destroyAppView(o,t=!1){const e=this.appViews.get(o);e&&(this.control.textEditorManager.clear(o,t),e.displayer.destroy(),this.appViews.delete(o))}createMianView(o){this.mainView=new Proxy(o,{set:(t,e,s)=>(this.control.worker.isActive&&this.validator(t,e,s),t[e]=s,!0)})}createAppView(o){const t=o.id,e=new Proxy(o,{set:(s,i,n)=>(this.control.worker.isActive&&this.validator(s,i,n),s[i]=n,!0)});this.appViews.set(t,e)}isAppView(o){return o!==yt&&this.appViews.has(o)}getView(o){var t;return o===yt?this.mainView:(t=this.appViews)==null?void 0:t.get(o)}getCurScenePath(o){const t=this.getView(o);if(t)return t.focusScenePath}getAllViews(){return[this.mainView,...this.appViews.values()]}setViewScenePath(o,t){var e;if(o===yt&&this.mainView)this.mainView.focusScenePath=t;else{const s=o&&((e=this.appViews)==null?void 0:e.get(o))||void 0;s&&(s.focusScenePath=t)}}setViewData(o,t){var e;if(o===yt&&this.mainView)this.mainView.viewData=t;else{const s=o&&((e=this.appViews)==null?void 0:e.get(o))||void 0;s&&(s.viewData=t)}}setFocuedViewId(o){var t;this.focuedViewId=o,o===yt?this.focuedView=this.mainView:this.focuedView=o&&((t=this.appViews)==null?void 0:t.get(o))||void 0,this.control.cursor.onFocusViewChange(),this.focuedView&&this.focuedView.displayer.commiter.onFocusView()}setViewFocusScenePath(o,t){var s;let e;o===yt?e=this.mainView:e=(s=this.appViews)==null?void 0:s.get(o),e&&(e.focusScenePath=t)}destroy(){var o;this.internalMsgEmitter.removeAllListeners("addUndoTicker"),this.internalMsgEmitter.removeAllListeners("excludeIds"),(o=this.mainView)==null||o.displayer.destroy(),this.appViews.forEach(t=>{this.destroyAppView(t.id,!0),this.control.worker.destroyViewWorker(t.id)})}setFocuedViewCameraOpt(o){if(this.focuedView){const t=this.focuedView.cameraOpt;P.isEqual(t,o)||(this.focuedView.cameraOpt=o)}}transformToOriginPoint(o,t){const e=this.getView(t);if(e!=null&&e.viewData){const s=e.viewData.convertToPointOnScreen(o[0],o[1]);return[s.x,s.y]}return o}transformToScenePoint(o,t){const e=this.getView(t);if(e!=null&&e.viewData){const s=e.viewData.convertToPointInWorld({x:o[0],y:o[1]});return[s.x,s.y]}return o}render(o){var t,e,s,i,n,a,c,l,h,u,d,p,f,I,y,v,m;for(const w of o){const{rect:N,imageBitmap:S,isClear:T,isUnClose:x,drawCanvas:b,clearCanvas:A,viewId:O}=w,j=(t=this.getView(O))==null?void 0:t.displayer;if(j&&N){const{dpr:E,canvasBgRef:D,canvasFloatRef:_,canvasServiceFloatRef:nt,canvasTopRef:tt}=j,V=Math.floor(N.w*E),K=Math.floor(N.h*E),$=N.x*E,G=N.y*E;if(T){switch(A){case Wt.TopFloat:(s=(e=tt.current)==null?void 0:e.getContext("2d"))==null||s.clearRect($,G,V,K);break;case Wt.Float:(n=(i=_.current)==null?void 0:i.getContext("2d"))==null||n.clearRect($,G,V,K);break;case Wt.ServiceFloat:(c=(a=nt.current)==null?void 0:a.getContext("2d"))==null||c.clearRect($,G,V,K);break;case Wt.Bg:(h=(l=D.current)==null?void 0:l.getContext("2d"))==null||h.clearRect($,G,V,K);break}continue}if(b&&S)switch(b){case Wt.TopFloat:(d=(u=tt.current)==null?void 0:u.getContext("2d"))==null||d.drawImage(S,0,0,V,K,$,G,V,K);break;case Wt.Float:{(f=(p=_.current)==null?void 0:p.getContext("2d"))==null||f.drawImage(S,0,0,V,K,$,G,V,K);break}case Wt.ServiceFloat:{(y=(I=nt.current)==null?void 0:I.getContext("2d"))==null||y.drawImage(S,0,0,V,K,$,G,V,K);break}case Wt.Bg:{(m=(v=D.current)==null?void 0:v.getContext("2d"))==null||m.drawImage(S,0,0,V,K,$,G,V,K);break}}if(x)continue;S==null||S.close()}}}showFloatBar(o,t,e){const s=this.getView(o),i=s==null?void 0:s.displayer.vDom;i&&i.showFloatBar(t,e)}setActiveTextEditor(o,t){const e=this.getView(o),s=e==null?void 0:e.displayer.vDom;s&&s.setActiveTextEditor(t)}}M(ge,"defaultCameraOpt",{centerX:0,centerY:0,scale:1}),M(ge,"defaultScreenCanvasOpt",{autoRender:!1,contextType:_e.Canvas2d}),M(ge,"defaultLayerOpt",{offscreen:!0,handleEvent:!1,depth:!1});class Qg{constructor(o,t,e){M(this,"viewId");M(this,"control");M(this,"internalMsgEmitter");M(this,"commiter");M(this,"cachePoint");M(this,"cacheCursorPoint");M(this,"active",!0);M(this,"mousedown",o=>{if(this.active&&o.button===0&&this.viewId){this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(L.Start,t,this.viewId)}});M(this,"mousemove",o=>{if(this.active&&this.viewId){const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(L.Doing,t,this.viewId)}});M(this,"mouseup",o=>{if(this.active&&o.button===0&&this.viewId){const t=this.getPoint(o)||this.cachePoint;t&&this.control.worker.originalEventLintener(L.Done,t,this.viewId),this.cachePoint=void 0}});M(this,"touchstart",o=>{var t;if(this.active){if(!fe(o)){this.control.worker.unWritable(),this.viewId&&this.control.worker.removeDrawingWork(this.viewId);return}if(this.viewId){if(!this.control.worker.isAbled()){const s=(t=this.control.worker.getCurrentToolsData())==null?void 0:t.toolsType;s&&this.control.effectViewContainer(s)}this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const e=this.getPoint(o);this.cachePoint=e,e&&this.control.worker.originalEventLintener(L.Start,e,this.viewId)}}});M(this,"touchmove",o=>{if(this.active){if(!fe(o)){this.control.worker.unWritable(),this.control.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(L.Doing,t,this.viewId)}}});M(this,"touchend",o=>{if(this.active){if(!fe(o)||!this.control.worker.isAbled()){this.control.worker.unWritable(),this.control.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const t=this.getPoint(o)||this.cachePoint;t&&this.control.worker.originalEventLintener(L.Done,t,this.viewId),this.cachePoint=void 0}}});M(this,"cursorMouseMove",P.throttle(o=>{const t=this.getPoint(o);this.cacheCursorPoint&&P.isEqual(t,this.cacheCursorPoint)||!this.viewId||(this.cacheCursorPoint=t,t&&this.control.worker.sendCursorEvent(t,this.viewId))},30,{leading:!1}));M(this,"cursorMouseLeave",P.throttle(()=>{this.viewId&&(this.cacheCursorPoint=[void 0,void 0],this.control.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId))},30,{leading:!1}));M(this,"keydown",o=>{this.control.hotkeyManager.colloctHotkey(o)});this.viewId=o,this.control=t,this.internalMsgEmitter=e;const s={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:this.viewId};this.commiter=new Xe(s)}bindToolsClass(){var t,e;const o=(e=(t=this.control.worker)==null?void 0:t.currentToolsData)==null?void 0:e.toolsType;switch(o){case C.Text:case C.Pencil:case C.LaserPen:case C.Arrow:case C.Straight:case C.Rectangle:case C.Ellipse:case C.Star:case C.Polygon:case C.SpeechBalloon:case C.Eraser:case C.PencilEraser:case C.BitMapEraser:this.eventTragetElement&&(this.eventTragetElement.className=`netless-whiteboard ${o===C.Text?"cursor-text":o===C.Eraser||o===C.PencilEraser||o===C.BitMapEraser?"cursor-eraser":o===C.Pencil||o===C.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(o){this.viewId=o}destroy(){this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.clearViewCursor(this.viewId),this.internalMsgEmitter.removeAllListeners([Z.Cursor,this.viewId])}getPoint(o){const t=xi(o);if(t&&P.isNumber(t.x)&&P.isNumber(t.y))return[t.x-this.containerOffset.x,t.y-this.containerOffset.y]}setActive(o){this.active=o}async stopEventHandler(){this.cachePoint&&(await this.control.worker.originalEventLintener(L.Done,this.cachePoint,this.viewId),this.cachePoint=void 0)}getTranslate(o){const e=(o.style.WebkitTransform||getComputedStyle(o,"").getPropertyValue("-webkit-transform")||o.style.transform||getComputedStyle(o,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),s=e&&parseInt(e[0])||0,i=e&&parseInt(e[1])||0;return[s,i]}getContainerOffset(o,t){var i;const e=this.getTranslate(o);let s={x:t.x+o.offsetLeft+e[0],y:t.y+o.offsetTop+e[1]};return(i=o.offsetParent)!=null&&i.nodeName&&o.offsetParent.nodeName!=="BODY"&&(s=this.getContainerOffset(o.offsetParent,s)),s}bindDisplayerEvent(o){o.addEventListener("mousedown",this.mousedown,!1),o.addEventListener("touchstart",this.touchstart,{capture:!0,passive:!1}),window.addEventListener("mouseleave",this.mouseup,!1),window.addEventListener("mousemove",this.mousemove,{capture:!0,passive:!1}),window.addEventListener("mouseup",this.mouseup,!1),window.addEventListener("touchmove",this.touchmove,{capture:!0,passive:!1}),window.addEventListener("touchend",this.touchend,{capture:!0,passive:!1}),o.addEventListener("mousemove",this.cursorMouseMove,!1),o.addEventListener("mouseleave",this.cursorMouseLeave,!1),o.addEventListener("keydown",this.keydown,!0)}removeDisplayerEvent(o){o.removeEventListener("mousedown",this.mousedown),o.removeEventListener("touchstart",this.touchstart),window.removeEventListener("mouseleave",this.mouseup),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),o.removeEventListener("mousemove",this.cursorMouseMove),o.removeEventListener("mouseleave",this.cursorMouseLeave),o.removeEventListener("keydown",this.keydown)}}class zi{constructor(o,t){M(this,"viewId",yt);M(this,"control");M(this,"internalMsgEmitter");M(this,"commiter");M(this,"cachePoint");M(this,"cacheCursorPoint");M(this,"active",!0);M(this,"mousedown",o=>{if(this.active&&o.button===0){this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(L.Start,t,this.viewId)}});M(this,"mousemove",o=>{if(!this.active)return;const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(L.Doing,t,this.viewId)});M(this,"mouseup",o=>{if(this.active&&o.button===0){const t=this.getPoint(o)||this.cachePoint;t&&this.control.worker.originalEventLintener(L.Done,t,this.viewId),this.cachePoint=void 0}});M(this,"touchstart",o=>{var e;if(!this.active)return;if(!fe(o)){this.control.worker.unWritable(),this.viewId&&this.control.worker.removeDrawingWork(this.viewId);return}if(!this.control.worker.isAbled()){const s=(e=this.control.worker.getCurrentToolsData())==null?void 0:e.toolsType;s&&this.control.effectViewContainer(s)}this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(L.Start,t,this.viewId)});M(this,"touchmove",o=>{if(!this.active)return;if(!fe(o)){this.control.worker.unWritable(),this.viewId&&this.control.worker.removeDrawingWork(this.viewId);return}const t=this.getPoint(o);this.cachePoint=t,t&&this.control.worker.originalEventLintener(L.Doing,t,this.viewId)});M(this,"touchend",o=>{if(!this.active)return;if(!fe(o)||!this.control.worker.isAbled()){this.control.worker.removeDrawingWork(this.viewId);return}const t=this.getPoint(o)||this.cachePoint;t&&this.control.worker.originalEventLintener(L.Done,t,this.viewId),this.cachePoint=void 0});M(this,"cursorMouseMove",P.throttle(o=>{const t=this.getPoint(o);this.cacheCursorPoint&&P.isEqual(t,this.cacheCursorPoint)||(this.cacheCursorPoint=t,t&&this.control.worker.sendCursorEvent(t,this.viewId))},30,{leading:!1}));M(this,"cursorMouseLeave",P.throttle(()=>{this.cacheCursorPoint=[void 0,void 0],this.control.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId)},30,{leading:!1}));M(this,"keydown",o=>{this.control.hotkeyManager.colloctHotkey(o)});this.control=o,this.internalMsgEmitter=t;const e={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:this.viewId};this.commiter=new Xe(e)}bindToolsClass(){var t,e;const o=(e=(t=this.control.worker)==null?void 0:t.currentToolsData)==null?void 0:e.toolsType;switch(o){case C.Text:case C.Pencil:case C.LaserPen:case C.Arrow:case C.Straight:case C.Rectangle:case C.Ellipse:case C.Star:case C.Polygon:case C.SpeechBalloon:case C.Eraser:case C.PencilEraser:case C.BitMapEraser:this.eventTragetElement&&(this.eventTragetElement.className=`netless-whiteboard ${o===C.Text?"cursor-text":o===C.Eraser||o===C.PencilEraser||o===C.BitMapEraser?"cursor-eraser":o===C.Pencil||o===C.LaserPen?"cursor-pencil":"cursor-arrow"}`);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}))}destroy(){this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.destroy(),this.internalMsgEmitter.removeAllListeners([Z.Cursor,this.viewId])}getPoint(o){const t=xi(o);if(t&&P.isNumber(t.x)&&P.isNumber(t.y))return[t.x-this.containerOffset.x,t.y-this.containerOffset.y]}setActive(o){this.active=o}async stopEventHandler(){this.cachePoint&&(await this.control.worker.originalEventLintener(L.Done,this.cachePoint,this.viewId),this.cachePoint=void 0)}getTranslate(o){const e=(o.style.WebkitTransform||getComputedStyle(o,"").getPropertyValue("-webkit-transform")||o.style.transform||getComputedStyle(o,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),s=e&&parseInt(e[0])||0,i=e&&parseInt(e[1])||0;return[s,i]}getContainerOffset(o,t){var i;const e=this.getTranslate(o);let s={x:t.x+o.offsetLeft+e[0],y:t.y+o.offsetTop+e[1]};return(i=o.offsetParent)!=null&&i.nodeName&&o.offsetParent.nodeName!=="BODY"&&(s=this.getContainerOffset(o.offsetParent,s)),s}bindDisplayerEvent(o){o.addEventListener("mousedown",this.mousedown,!1),window.addEventListener("mouseleave",this.mouseup,!1),window.addEventListener("mousemove",this.mousemove,{capture:!1,passive:!1}),window.addEventListener("mouseup",this.mouseup,!1),o.addEventListener("touchstart",this.touchstart,{capture:!0,passive:!1}),window.addEventListener("touchmove",this.touchmove,{capture:!0,passive:!1}),window.addEventListener("touchend",this.touchend,{capture:!0,passive:!1}),o.addEventListener("mousemove",this.cursorMouseMove,!0),o.addEventListener("mouseleave",this.cursorMouseLeave,!0),o.addEventListener("keydown",this.keydown,!0)}removeDisplayerEvent(o){o.removeEventListener("mousedown",this.mousedown),o.removeEventListener("touchstart",this.touchstart),window.removeEventListener("mouseleave",this.mouseup),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),o.removeEventListener("mousemove",this.cursorMouseMove),o.removeEventListener("mouseleave",this.cursorMouseLeave),o.removeEventListener("keydown",this.keydown)}}const Vg="index-module__Container__nLsM3",$g="index-module__CanvasBox__j2Xe-",Gg="index-module__FloatCanvas__d1YR7",Zg="index-module__TopFloatCanvas__7IaCw",qg="index-module__CanvasBoxSub__hcMeK",Jg="index-module__SnapshotBox__--eeE",Xg="index-module__FloatBar__cm-EL",Kg="index-module__RotateBtn__HSSkf",_g="index-module__ResizeBtn__yjvda",tM="index-module__CursorBox__2UHvI",eM="index-module__TextEditorContainer__Qm8KC",oM="index-module__ResizeTowBox__HOllX",sM="index-module__FloatBarBtn__FJrOG",Tt={Container:Vg,CanvasBox:$g,FloatCanvas:Gg,TopFloatCanvas:Zg,CanvasBoxSub:qg,SnapshotBox:Jg,FloatBar:Xg,RotateBtn:Kg,ResizeBtn:_g,CursorBox:tM,TextEditorContainer:eM,ResizeTowBox:oM,FloatBarBtn:sM},iM={delete:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDZ2NmEyIDIgMCAwIDEtMiAySDZhMiAyIDAgMCAxLTItMlY2aDBtMS0yYTIgMiAwIDAgMSAyLTJoMmEyIDIgMCAwI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S44NjYtNC41NDMgMi42LTYuMjc2eiIgc3Ryb2tlPSIjRkZGIiBzdHJva2Utd2lkdGg9Ii41IiBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L2c+PC9zdmc+","font-colors-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTQgMTEgNC05IDQgOU02IDdoNCIgc3Ryb2tlPSIjMzM4MUZGIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","font-colors":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTQgMTEgNC05IDQgOU02IDdoNCIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","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+PHBhdGggZD0iTTEyIDJ2NWE0IDQgMCAxIDEtOCAwVjJoME0zIDE0aDEwIiBzdHJva2U9IiMzMzgxRkYiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVq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ananger:t}=r;return g.createElement("div",{className:"button normal-button",style:{touchAction:"none"},onClick:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),q.emitMethod(Z.MainEngine,R.DeleteNode,{workIds:o||[H],viewId:t.viewId})},onTouchEnd:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),q.emitMethod(Z.MainEngine,R.DeleteNode,{workIds:o||[H],viewId:t.viewId})}},g.createElement("img",{alt:"icon",src:wt("delete")}))},rM=r=>{const{workIds:o,viewId:t}=r;return g.createElement("div",{className:"button normal-button",onClick:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),q.emitMethod(Z.MainEngine,R.CopyNode,{workIds:o||[H],viewId:t})},onTouchEnd:e=>{e.stopPropagation(),q.emitMethod(Z.MainEngine,R.CopyNode,{workIds:o||[H],viewId:t})}},g.createElement("img",{alt:"icon",src:wt("duplicate")}))},bs=r=>{const{icon:o,onClickHandler:t,onTouchEndHandler:e}=r;return g.createElement("div",{className:"button normal-button",onClick:t,onTouchEnd:e},g.createElement("img",{src:wt(o)}))},aM=r=>{const{open:o,setOpen:t,floatBarRef:e}=r,{floatBarData:s,mananger:i}=g.useContext(Mt),[n,a]=g.useState([]),c=g.useMemo(()=>{if(e!=null&&e.current&&P.isNumber(s==null?void 0:s.y)&&(i!=null&&i.height)){if(e.current.offsetTop&&e.current.offsetTop+s.y>180){const d={};return d.top="inherit",d.bottom=50,d}else if(!e.current.offsetTop&&(i==null?void 0:i.height)-e.current.offsetTop-s.y<120){const d={};return d.top="inherit",d.bottom=50,d}}},[e==null?void 0:e.current,s,i]),l=g.useMemo(()=>o?g.createElement("div",{className:"image-layer-menu",style:c},g.createElement(bs,{icon:"to-top",onClickHandler:d=>{d.cancelable&&d.preventDefault(),d.stopPropagation(),q.emitMethod(Z.MainEngine,R.ZIndexNode,{workIds:[H],layer:ee.Top,viewId:i==null?void 0:i.viewId})},onTouchEndHandler:d=>{d.stopPropagation(),q.emitMethod(Z.MainEngine,R.ZIndexNode,{workIds:[H],layer:ee.Top,viewId:i==null?void 0:i.viewId})}}),g.createElement(bs,{icon:"to-bottom",onClickHandler:d=>{d.cancelable&&d.preventDefault(),d.stopPropagation(),q.emitMethod(Z.MainEngine,R.ZIndexNode,{workIds:[H],layer:ee.Bottom,viewId:i==null?void 0:i.viewId})},onTouchEndHandler:d=>{d.stopPropagation(),q.emitMethod(Z.MainEngine,R.ZIndexNode,{workIds:[H],layer:ee.Bottom,viewId:i==null?void 0:i.viewId})}})):null,[o,c]),h=d=>{d.cancelable&&d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),t(!o)},u=d=>{d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),t(!o)};return g.useEffect(()=>{P.isEqual(s==null?void 0:s.selectIds,n)||s!=null&&s.selectIds&&!P.isEqual(s==null?void 0:s.selectIds,n)&&(a(s==null?void 0:s.selectIds),t(!1))},[o,s,n,t]),g.createElement("div",{className:`button normal-button ${o&&"active"}`,onClick:h,onTouchEnd:u},l,g.createElement("img",{alt:"icon",src:wt(o?"layer-pressed":"layer")}))},cM=()=>g.createElement("svg",{style:{marginLeft:"2px"},viewBox:"0 0 1025 1024",width:"14",height:"14"},g.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"})),bi=r=>{const{activeColor:o,onClickHandler:t,onTouchEndHandler:e}=r;return g.createElement("div",{className:`font-color-button ${o==="transparent"?"active":""}`,onClick:t,onTouchEnd:e},g.createElement("div",{className:"circle none"}))},lo=r=>{const{color:o,activeColor:t,onClickHandler:e,onTouchEndHandler:s}=r;return g.createElement("div",{className:`font-color-button ${o===t?"active":""}`,onClick:e,onTouchEnd:s},g.createElement("div",{className:"circle",style:{backgroundColor:gt(o,1)}}))},ho=r=>{const{opacity:o,activeColor:t,setCurOpacity:e}=r,[s,i]=g.useState({x:108,y:0});if(g.useEffect(()=>{i({x:o*100+8,y:0})},[]),!t)return null;const n=P.throttle((l,h)=>{l.cancelable&&l.preventDefault(),l.stopPropagation(),h.x!==(s==null?void 0:s.x)&&i({x:h.x,y:0});const u=Math.min(Math.max(h.x-8,0),100)/100;o!==u&&e(u,t,L.Doing)},100,{leading:!1}),a=l=>{l.cancelable&&l.preventDefault(),l.stopPropagation(),e(o,t,L.Start)},c=P.throttle((l,h)=>{l.cancelable&&l.preventDefault(),l.stopPropagation(),h.x!==(s==null?void 0:s.x)&&i({x:h.x,y:0});const u=Math.min(Math.max(h.x-8,0),100)/100;e(u,t,L.Done)},100,{leading:!1});return g.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onClick:l=>{const h=l.nativeEvent.offsetX,u=Math.min(Math.max(h-12,0),100)/100;i({x:u*100+8,y:0}),e(u,t,L.Done)}},g.createElement("div",{className:"range-color",style:{background:`linear-gradient(to right, ${gt(t,0)}, ${gt(t,1)})`}}),g.createElement("div",{className:"range-opacity"},g.createElement(Me,{bounds:"parent",axis:"x",position:s,onDrag:n,onStart:a,onStop:c},g.createElement("div",{className:"circle",style:{backgroundColor:gt(t,o)},onClick:l=>{l.cancelable&&l.preventDefault(),l.stopPropagation()}}))))},lM=r=>{const{min:o,max:t,activeNumber:e,setActiveNumber:s,color:i}=r,[n,a]=g.useState({x:108,y:0});if(g.useEffect(()=>{const u=Math.ceil((e-o)/(t-o)*100)+8;a({x:u,y:0})},[]),!e)return null;const c=P.throttle((u,d)=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),d.x!==(n==null?void 0:n.x)&&a({x:d.x,y:0});const p=Math.ceil(Math.max(d.x-8,0)/100*(t-o)+o);e!==p&&s(p,L.Doing)},100,{leading:!1}),l=u=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),s(e,L.Start)},h=P.throttle((u,d)=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),d.x!==(n==null?void 0:n.x)&&a({x:d.x,y:0});const p=Math.ceil(Math.max(d.x-8,0)/100*(t-o)+o);s(p,L.Done)},100,{leading:!1});return g.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onClick:u=>{const d=u.nativeEvent.offsetX,p=Math.ceil(Math.max(d-12,0)/100*(t-o)+o),f=Math.ceil((p-o)/(t-o)*100)+8;a({x:f,y:0}),s(p,L.Done)}},g.createElement("div",{className:"range-color",style:{backgroundColor:i}}),g.createElement("div",{className:"range-opacity"},g.createElement(Me,{bounds:"parent",axis:"x",position:n,onDrag:c,onStart:l,onStop:h},g.createElement("div",{className:"circle",style:{backgroundColor:i},onClick:u=>{u.cancelable&&u.preventDefault(),u.stopPropagation()}},g.createElement("div",{className:"range-opacity-data-icon"},e)))))},hM=r=>{const{useStroke:o,color:t,activeStrokeType:e,setStrokeType:s}=r;return g.createElement("div",{className:"stroke-type-box"},!!o&&g.createElement("div",{className:`stroke-type-box-item Stroke ${e===X.Stroke&&"active"}`,style:{backgroundColor:t},onClick:()=>{s(X.Stroke)},onTouchEnd:()=>{s(X.Stroke)}}),g.createElement("div",{className:`stroke-type-box-item Normal ${e===X.Normal&&"active"}`,style:{borderColor:t},onClick:()=>{s(X.Normal)},onTouchEnd:()=>{s(X.Normal)}}),g.createElement("div",{className:`stroke-type-box-item Dotted ${e===X.Dotted&&"active"}`,style:{borderColor:t},onClick:()=>{s(X.Dotted)},onTouchEnd:()=>{s(X.Dotted)}}),g.createElement("div",{className:`stroke-type-box-item LongDotted ${e===X.LongDotted&&"active"}`,style:{borderColor:t},onClick:()=>{s(X.LongDotted)},onTouchEnd:()=>{s(X.LongDotted)}}))},uM=r=>{const{open:o,setOpen:t,floatBarRef:e}=r,{floatBarData:s,floatBarColors:i,mananger:n,setFloatBarData:a}=g.useContext(Mt),[c,l]=g.useState(),[h,u]=g.useState(1);g.useEffect(()=>{if(s!=null&&s.strokeColor){const[m,w]=co(s.strokeColor);l(m),u(w)}},[s]);const d=g.useMemo(()=>{if(e!=null&&e.current&&P.isNumber(s==null?void 0:s.y)&&(n!=null&&n.height)){if(e.current.offsetTop&&e.current.offsetTop+s.y>180){const m={};return m.top="inherit",m.bottom=50,m}else if(!e.current.offsetTop&&(n==null?void 0:n.height)-e.current.offsetTop-s.y<120){const m={};return m.top="inherit",m.bottom=50,m}}},[(e==null?void 0:e.current)&&s,n==null?void 0:n.height]),p=g.useMemo(()=>g.createElement(ho,{key:"strokeColors",opacity:h,activeColor:c,setCurOpacity:(m,w,N)=>{N===L.Start&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!0),N===L.Done&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!1),u(m);const S=gt(w,m);s!=null&&s.strokeColor&&a({strokeColor:S}),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],strokeColor:S,workState:N,viewId:n==null?void 0:n.viewId})}}),[h,c,n==null?void 0:n.control.room,n==null?void 0:n.viewId,s]),f=g.useMemo(()=>c&&(s!=null&&s.thickness)?g.createElement(lM,{key:"strokeThickness",min:1,max:10,activeNumber:s.thickness,setActiveNumber:(m,w)=>{w===L.Start&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!0),w===L.Done&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!1),s!=null&&s.thickness&&a({thickness:m}),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],thickness:m,workState:w,viewId:n==null?void 0:n.viewId})},color:c}):null,[c,s==null?void 0:s.thickness,n==null?void 0:n.control.room,n==null?void 0:n.viewId]),I=g.useMemo(()=>c&&(s!=null&&s.strokeType)?g.createElement(hM,{key:"strokeType",useStroke:s==null?void 0:s.useStroke,activeStrokeType:s.strokeType,setStrokeType:m=>{s.strokeType&&a({strokeType:m}),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],strokeType:m,workState:L.Done,viewId:n==null?void 0:n.viewId})},color:c}):null,[c,s==null?void 0:s.strokeType,n==null?void 0:n.control.room,n==null?void 0:n.viewId,s==null?void 0:s.useStroke]),y=g.useMemo(()=>o?g.createElement("div",{className:"font-colors-menu",style:d,onTouchEnd:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()},onClick:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()}},I,f,g.createElement("div",{className:"font-colors-line"}),i.concat().map((m,w)=>{const N=De(...m);return g.createElement(lo,{key:w,color:N,activeColor:c,onTouchEndHandler:S=>{S.stopPropagation(),l(N);const T=gt(N,h);s!=null&&s.strokeColor&&(s.strokeColor=T,a({strokeColor:T})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],workState:L.Done,strokeColor:T,viewId:n==null?void 0:n.viewId})},onClickHandler:S=>{S.cancelable&&S.preventDefault(),S.stopPropagation(),l(N);const T=gt(N,h);s!=null&&s.strokeColor&&(s.strokeColor=T,a({strokeColor:T})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],workState:L.Done,strokeColor:T,viewId:n==null?void 0:n.viewId})}})}),p):null,[o,i,p,c,h,s,n==null?void 0:n.viewId,d]),v=g.useMemo(()=>c?g.createElement("div",{className:"color-bar-ring",style:{backgroundColor:gt(c,h)}},g.createElement("div",{className:"circle"})):null,[c,h]);return g.createElement("div",{className:`button normal-button font-colors-icon ${o&&"active"}`,onTouchEnd:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),t(!o)},onClick:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),t(!o)}},v,y)},dM=r=>{const{open:o,setOpen:t,floatBarRef:e}=r,{floatBarData:s,floatBarColors:i,mananger:n,setFloatBarData:a}=g.useContext(Mt),[c,l]=g.useState(),[h,u]=g.useState(1);g.useEffect(()=>{if(s!=null&&s.fillColor){const[y,v]=(s==null?void 0:s.fillColor)==="transparent"&&["transparent",1]||co(s.fillColor);l(y),u(v)}},[s]);const d=g.useMemo(()=>{if(e!=null&&e.current&&P.isNumber(s==null?void 0:s.y)&&(n!=null&&n.height)){if(e.current.offsetTop&&e.current.offsetTop+s.y>200){const y={};return y.top="inherit",y.bottom=50,y}else if(!e.current.offsetTop&&(n==null?void 0:n.height)-e.current.offsetTop-s.y<140){const y={};return y.top="inherit",y.bottom=50,y}}},[e==null?void 0:e.current,s,n==null?void 0:n.height]),p=g.useMemo(()=>c&&c!=="transparent"?g.createElement(ho,{key:"fillColors",opacity:h||0,activeColor:c,setCurOpacity:(y,v,m)=>{m===L.Start&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!0),m===L.Done&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!1),u(y);const w=gt(v,y);s!=null&&s.fillColor&&(s.fillColor=w,a({fillColor:w})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],fillColor:c&&gt(v,y),workState:m,viewId:n==null?void 0:n.viewId})}}):null,[c,h,n==null?void 0:n.control.room,n==null?void 0:n.viewId,s]),f=g.useMemo(()=>o?g.createElement("div",{className:"font-colors-menu",style:d,onTouchEnd:y=>{y.stopPropagation(),y.nativeEvent.stopImmediatePropagation()},onClick:y=>{y.cancelable&&y.preventDefault(),y.stopPropagation(),y.nativeEvent.stopImmediatePropagation()}},g.createElement(bi,{activeColor:c,onTouchEndHandler:y=>{y.stopPropagation(),l("transparent");const v="transparent";s!=null&&s.fillColor&&(s.fillColor=v,a({fillColor:v})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],workState:L.Done,fillColor:v,viewId:n==null?void 0:n.viewId})},onClickHandler:y=>{y.cancelable&&y.preventDefault(),y.stopPropagation(),l("transparent");const v="transparent";s!=null&&s.fillColor&&(s.fillColor=v,a({fillColor:v})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],workState:L.Done,fillColor:v,viewId:n==null?void 0:n.viewId})}}),i.map((y,v)=>{const m=De(...y);return g.createElement(lo,{key:v,color:m,activeColor:c,onTouchEndHandler:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),l(m);const N=gt(m,h);s!=null&&s.fillColor&&(s.fillColor=N,a({fillColor:N})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],workState:L.Done,fillColor:N,viewId:n==null?void 0:n.viewId})},onClickHandler:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),l(m);const N=gt(m,h);s!=null&&s.fillColor&&(s.fillColor=N,a({fillColor:N})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],workState:L.Done,fillColor:N,viewId:n==null?void 0:n.viewId})}})}),p):null,[o,c,i,p,s,n==null?void 0:n.viewId,h,d]),I=g.useMemo(()=>{const y=c&&c!=="transparent"&&gt(c,h)||"transparent";return g.createElement("div",{className:"color-bar-fill"},g.createElement("div",{className:"circle",style:{backgroundColor:y}}))},[c,h]);return g.createElement("div",{className:`button normal-button font-colors-icon ${o&&"active"}`,onTouchEnd:y=>{y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),t(!o)},onClick:y=>{y.cancelable&&y.preventDefault(),y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),t(!o)}},I,f)},pM=r=>{const{open:o,setOpen:t,textOpt:e,workIds:s,floatBarRef:i}=r,{floatBarColors:n,mananger:a,setFloatBarData:c,floatBarData:l}=g.useContext(Mt),[h,u]=g.useState(),[d,p]=g.useState(1);g.useEffect(()=>{if(e!=null&&e.fontColor){const[m,w]=(e==null?void 0:e.fontColor)==="transparent"&&["transparent",0]||co(e.fontColor);u(m),p(w)}},[e==null?void 0:e.fontColor]);const f=g.useMemo(()=>{if(i!=null&&i.current&&P.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(i.current.offsetTop&&i.current.offsetTop+l.y>180){const m={};return m.top="inherit",m.bottom=50,m}else if(!i.current.offsetTop&&(a==null?void 0:a.height)-i.current.offsetTop-l.y<120){const m={};return m.top="inherit",m.bottom=50,m}}},[i==null?void 0:i.current,l,a]),I=g.useMemo(()=>h&&h!=="transparent"?g.createElement(ho,{key:"fontColors",opacity:d,activeColor:h,setCurOpacity:(m,w,N)=>{N===L.Start&&(a!=null&&a.control.room)&&(a.control.room.disableDeviceInputs=!0),N===L.Done&&(a!=null&&a.control.room)&&(a.control.room.disableDeviceInputs=!1),p(m);const S=gt(w,m);l!=null&&l.textOpt&&(l.textOpt.fontColor=S,c({textOpt:l.textOpt})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:s||[H],fontColor:h&&S,workState:N,viewId:a==null?void 0:a.viewId})}}):null,[h,d,a==null?void 0:a.control.room,a==null?void 0:a.viewId,l==null?void 0:l.textOpt,s]),y=g.useMemo(()=>o?g.createElement("div",{className:"font-colors-menu",style:f,onTouchEnd:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()},onClick:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()}},n.map((m,w)=>{const N=De(...m);return g.createElement(lo,{key:w,color:N,activeColor:h,onTouchEndHandler:S=>{S.stopPropagation(),u(N);const T=gt(N,d);l!=null&&l.textOpt&&(l.textOpt.fontColor=T,c({textOpt:l.textOpt})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:s||[H],workState:L.Done,fontColor:T,viewId:a==null?void 0:a.viewId})},onClickHandler:S=>{S.cancelable&&S.preventDefault(),S.stopPropagation(),u(N);const T=gt(N,d);l!=null&&l.textOpt&&(l.textOpt.fontColor=T,c({textOpt:l.textOpt})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:s||[H],workState:L.Done,fontColor:T,viewId:a==null?void 0:a.viewId})}})}),I):null,[o,n,I,h,d,l==null?void 0:l.textOpt,s,a==null?void 0:a.viewId,f]),v=g.useMemo(()=>{const m=h&&h!=="transparent"&&gt(h,d)||"transparent";return g.createElement("div",{className:"color-bar"},g.createElement("div",{className:"color-bar-color",style:{backgroundColor:m}}))},[h,d]);return g.createElement("div",{className:`button normal-button font-colors-icon ${o&&"active"}`,onTouchEnd:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),t(!o)},onClick:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),t(!o)}},g.createElement("img",{alt:"icon",src:wt("font-colors")}),v,y)},fM=r=>{const{open:o,setOpen:t,textOpt:e,workIds:s,floatBarRef:i}=r,{floatBarColors:n,mananger:a,setFloatBarData:c,floatBarData:l}=g.useContext(Mt),[h,u]=g.useState(),[d,p]=g.useState(1);g.useEffect(()=>{if(e!=null&&e.fontBgColor){const[m,w]=(e==null?void 0:e.fontBgColor)==="transparent"&&["transparent",1]||co(e.fontBgColor);u(m),p(w)}},[e==null?void 0:e.fontBgColor]);const f=g.useMemo(()=>{if(i!=null&&i.current&&P.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(i.current.offsetTop&&i.current.offsetTop+l.y>180){const m={};return m.top="inherit",m.bottom=50,m}else if(!i.current.offsetTop&&(a==null?void 0:a.height)-i.current.offsetTop-l.y<120){const m={};return m.top="inherit",m.bottom=50,m}}},[i==null?void 0:i.current,l,a]),I=g.useMemo(()=>h&&h!=="transparent"?g.createElement(ho,{key:"fontBgColor",opacity:d||0,activeColor:h,setCurOpacity:(m,w,N)=>{N===L.Start&&(a!=null&&a.control.room)&&(a.control.room.disableDeviceInputs=!0),N===L.Done&&(a!=null&&a.control.room)&&(a.control.room.disableDeviceInputs=!1),p(m);const S=gt(w,m);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=S,c({textOpt:l.textOpt})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:s||[H],fontBgColor:h&&gt(w,m),workState:N,viewId:a==null?void 0:a.viewId})}}):null,[h,d,a==null?void 0:a.control.room,a==null?void 0:a.viewId,l==null?void 0:l.textOpt,s]),y=g.useMemo(()=>o?g.createElement("div",{className:"font-colors-menu",style:f,onTouchEnd:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()},onClick:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()}},g.createElement(bi,{activeColor:h,onTouchEndHandler:m=>{m.stopPropagation();const w="transparent";u(w),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=w,c({textOpt:l.textOpt})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:s||[H],workState:L.Done,fontBgColor:w,viewId:a==null?void 0:a.viewId})},onClickHandler:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation();const w="transparent";u(w),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=w,c({textOpt:l.textOpt})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:s||[H],workState:L.Done,fontBgColor:w,viewId:a==null?void 0:a.viewId})}}),n.map((m,w)=>{const N=De(...m);return g.createElement(lo,{key:w,color:N,activeColor:h,onTouchEndHandler:S=>{S.stopPropagation(),u(N);const T=gt(N,d);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=T,c({textOpt:l.textOpt})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:s||[H],workState:L.Done,fontBgColor:gt(N,d),viewId:a==null?void 0:a.viewId})},onClickHandler:S=>{S.cancelable&&S.preventDefault(),S.stopPropagation(),u(N);const T=gt(N,d);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=T,c({textOpt:l.textOpt})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:s||[H],workState:L.Done,fontBgColor:gt(N,d),viewId:a==null?void 0:a.viewId})}})}),I):null,[o,n,I,d,h,l==null?void 0:l.textOpt,s,a==null?void 0:a.viewId,f]),v=g.useMemo(()=>{const m=h&&h!=="transparent"&&gt(h,d)||"transparent";return g.createElement("div",{className:"color-bar",style:{marginTop:0}},g.createElement("div",{className:"color-bar-color",style:{backgroundColor:m}}))},[h,d]);return g.createElement("div",{className:`button normal-button font-colors-icon ${o&&"active"}`,onTouchEnd:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),t(!o)},onClick:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),t(!o)}},g.createElement(cM,null),v,y)},gM=r=>{const{bold:o,setBold:t,workIds:e,viewId:s}=r,i=n=>{const a=o==="bold"?"normal":"bold";n.cancelable&&n.preventDefault(),n==null||n.stopPropagation(),t(a),q.emitMethod(Z.MainEngine,R.SetFontStyle,{workIds:e,viewId:s,bold:a})};return g.createElement("div",{className:"font-style-button",onClick:i,onTouchEnd:i},g.createElement("img",{alt:"icon",src:wt(o==="bold"?"bold-active":"bold")}))},MM=r=>{const{underline:o,setUnderline:t,workIds:e,viewId:s}=r,i=n=>{const a=!o;n.cancelable&&n.preventDefault(),n==null||n.stopPropagation(),t(a),q.emitMethod(Z.MainEngine,R.SetFontStyle,{workIds:e,viewId:s,underline:a})};return g.createElement("div",{className:"font-style-button",onClick:i,onTouchEnd:i},g.createElement("img",{alt:"icon",src:wt(o?"underline-active":"underline")}))},yM=r=>{const{lineThrough:o,setLineThrough:t,workIds:e,viewId:s}=r,i=n=>{const a=!o;n.cancelable&&n.preventDefault(),n==null||n.stopPropagation(),t(a),q.emitMethod(Z.MainEngine,R.SetFontStyle,{workIds:e,viewId:s,lineThrough:a})};return g.createElement("div",{className:"font-style-button",onClick:i,onTouchEnd:i},g.createElement("img",{alt:"icon",src:wt(o?"line-through-active":"line-through")}))},mM=r=>{const{italic:o,setItalic:t,workIds:e,viewId:s}=r,i=n=>{const a=o==="italic"?"normal":"italic";n.cancelable&&n.preventDefault(),n==null||n.stopPropagation(),t(a),q.emitMethod(Z.MainEngine,R.SetFontStyle,{workIds:e,viewId:s,italic:a})};return g.createElement("div",{className:"font-style-button",onClick:i,onTouchEnd:i},g.createElement("img",{alt:"icon",src:wt(o==="italic"?"italic-active":"italic")}))},wM=r=>{const{open:o,setOpen:t,textOpt:e,workIds:s,style:i,floatBarRef:n}=r,{mananger:a,floatBarData:c}=g.useContext(Mt),[l,h]=g.useState("normal"),[u,d]=g.useState("normal"),[p,f]=g.useState(!1),[I,y]=g.useState(!1);g.useEffect(()=>{e!=null&&e.bold&&h(e.bold),P.isBoolean(e==null?void 0:e.underline)&&f(e.underline||!1),P.isBoolean(e==null?void 0:e.lineThrough)&&y(e.lineThrough||!1),e!=null&&e.italic&&d(e.italic)},[e]);const v=g.useMemo(()=>{if(i&&(n!=null&&n.current)&&P.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(n.current.offsetTop&&n.current.offsetTop+c.y>180){const w={};return w.top="inherit",w.bottom=50,w}else if(!n.current.offsetTop&&(a==null?void 0:a.height)-n.current.offsetTop-c.y<120){const w={};return w.top="inherit",w.bottom=50,w}}},[i,n==null?void 0:n.current,c,a]),m=g.useMemo(()=>o?g.createElement("div",{className:"font-style-menu",style:v,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},g.createElement(gM,{workIds:s||[H],bold:l,setBold:h,viewId:a==null?void 0:a.viewId}),g.createElement(MM,{workIds:s||[H],underline:p,setUnderline:f,viewId:a==null?void 0:a.viewId}),g.createElement(yM,{workIds:s||[H],lineThrough:I,setLineThrough:y,viewId:a==null?void 0:a.viewId}),g.createElement(mM,{workIds:s||[H],italic:u,setItalic:d,viewId:a==null?void 0:a.viewId})):null,[o,s,l,a==null?void 0:a.viewId,p,I,u,v]);return g.createElement("div",{className:`button normal-button ${o&&"active"}`,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),t(!o)},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),t(!o)}},g.createElement("img",{alt:"icon",src:wt(o?"font-style-active":"font-style")}),m)},bt=Object.freeze([12,14,18,24,36,48,64,80,144,288]),ae=["top","topLeft","topRight","bottom","bottomLeft","bottomRight","left","leftTop","leftBottom","right","rightTop","rightBottom"],IM=r=>{const{style:o,onClickHandler:t}=r;return g.createElement("div",{className:"font-size-menu",style:o,onTouchEnd:e=>{e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()},onClick:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()}},bt.map(e=>g.createElement("div",{className:"font-size-btn",key:e,onClick:()=>{t(e)},onTouchEnd:()=>{t(e)}},e)))},vM=r=>{const o=g.useRef(null),{open:t,setOpen:e,textOpt:s,workIds:i,floatBarRef:n}=r,{mananger:a,floatBarData:c}=g.useContext(Mt),[l,h]=g.useState(0),[u,d]=g.useState(),p=bt.length-1;g.useEffect(()=>{s!=null&&s.fontSize&&(h(s.fontSize),o.current&&(o.current.value=s.fontSize.toString()))},[s==null?void 0:s.fontSize]);const f=g.useMemo(()=>{if(n!=null&&n.current&&P.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(n.current.offsetTop&&n.current.offsetTop+c.y>180){const w={};return w.top="inherit",w.bottom=35,w}else if(!n.current.offsetTop&&(a==null?void 0:a.height)-n.current.offsetTop-c.y<120){const w={};return w.top="inherit",w.bottom=35,w}}},[n==null?void 0:n.current,c,a]);function I(w){h(w),w&&w>=bt[0]&&w<=bt[p]&&q.emitMethod(Z.MainEngine,R.SetFontStyle,{workIds:i||[H],fontSize:w,viewId:a==null?void 0:a.viewId})}const y=w=>{var N;(N=o.current)==null||N.blur(),e(!1),m(w)},v=g.useMemo(()=>t?g.createElement(IM,{onClickHandler:y,style:f}):null,[t,y,f]),m=w=>{w>bt[p]&&(w=bt[p]),w<bt[0]&&(w=bt[0]),I(w)};return g.useEffect(()=>()=>{a!=null&&a.control.room&&P.isBoolean(u)&&(a.control.room.disableDeviceInputs=u)},[a,u]),g.createElement("div",{className:"button normal-button font-size-barBtn",style:{width:50},onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},g.createElement("input",{className:"font-size-input",ref:o,onTouchEnd:()=>{o.current&&o.current.focus()},onClick:()=>{e(!t),o.current&&o.current.focus()},onKeyDown:w=>{if(w.key==="Backspace"){const N=window.getSelection(),S=N==null?void 0:N.getRangeAt(0);if(S!=null&&S.collapsed)return w.cancelable&&w.preventDefault(),document.execCommand("delete",!1),!1}return!1},onKeyUp:w=>{var N;if(o.current){const S=o.current.value,T=parseInt(S);isNaN(T)?o.current.value="0":o.current.value=T.toString(),T&&w.key==="Enter"&&(m(T),(N=o.current)==null||N.blur(),e(!1))}},onFocus:()=>{a!=null&&a.control.room&&!a.control.room.disableDeviceInputs&&(d(a.control.room.disableDeviceInputs),a.control.room.disableDeviceInputs=!0)},onBlur:()=>{a!=null&&a.control.room&&P.isBoolean(u)&&(a.control.room.disableDeviceInputs=u)}}),g.createElement("div",{className:"font-size-btns"},g.createElement("div",{className:"font-size-add",onClick:()=>{m(l+bt[0])},onTouchEnd:()=>{m(l+bt[0])}}),g.createElement("div",{className:"font-size-cut",onClick:()=>{m(l-bt[0])},onTouchEnd:()=>{m(l-bt[0])}})),v)},NM=r=>{const{workIds:o,mananger:t,islocked:e}=r;return g.createElement("div",{className:"button normal-button",onClick:s=>{s.cancelable&&s.preventDefault(),s.stopPropagation(),q.emitMethod(Z.MainEngine,R.SetLock,{workIds:o||[H],isLocked:!e,viewId:t==null?void 0:t.viewId})},onTouchEnd:s=>{s.stopPropagation(),q.emitMethod(Z.MainEngine,R.SetLock,{workIds:o||[H],isLocked:!e,viewId:t==null?void 0:t.viewId})}},g.createElement("img",{alt:"icon",src:wt(e?"unlock-new":"lock-new")}))},Co=r=>{const{icon:o,min:t,max:e,step:s,value:i,onInputHandler:n}=r,[a,c]=g.useState(0),l=g.useRef(null),h=u=>{u>e&&(u=e),u<t&&(u=t),c(u),n(u),l.current&&(l.current.value=u.toString())};return g.useEffect(()=>{i&&(c(i),l.current&&(l.current.value=i.toString()))},[i]),g.createElement("div",{className:"button input-button",onTouchEnd:u=>{u.stopPropagation(),u.nativeEvent.stopImmediatePropagation()},onClick:u=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),u.nativeEvent.stopImmediatePropagation()}},g.createElement("img",{src:wt(o)}),g.createElement("input",{className:"input-number",type:"text",ref:l,onTouchEnd:()=>{l.current&&l.current.focus()},onClick:()=>{l.current&&l.current.focus()},onKeyDown:u=>{if(u.key==="Backspace"){const d=window.getSelection(),p=d==null?void 0:d.getRangeAt(0);if(p!=null&&p.collapsed)return u.cancelable&&u.preventDefault(),document.execCommand("delete",!1),!1}},onKeyUp:()=>{if(l.current){const u=l.current.value,d=parseInt(u);isNaN(d)?l.current.value="0":l.current.value=d.toString()}},onChange:u=>{const d=u.target.value,p=parseInt(d);p&&p&&p>=t&&p<=e&&h(p)}}),g.createElement("div",{className:"input-number-btns"},g.createElement("div",{className:"input-number-add",onClick:()=>{h(a+s)},onTouchEnd:()=>{h(a+s)}}),g.createElement("div",{className:"input-number-cut",onClick:()=>{h(a-s)},onTouchEnd:()=>{h(a-s)}})))},TM=r=>{const{icon:o,min:t,max:e,step:s,value:i,onInputHandler:n}=r;return g.createElement("div",{className:"button input-button"},g.createElement("img",{src:wt(o)}),g.createElement(SM,{min:t,max:e,step:s,value:i,onInputHandler:n}))},SM=r=>{const{value:o,min:t,max:e,onInputHandler:s}=r,[i,n]=g.useState({x:0,y:0});g.useEffect(()=>{n({x:o*100,y:0})},[]);const a=P.throttle((h,u)=>{h.cancelable&&h.preventDefault(),h.stopPropagation();let d=Math.floor(Math.max(u.x,t*100));d=Math.floor(Math.min(d,e*100)),u.x!==(i==null?void 0:i.x)&&n({x:d,y:0});const p=d/100;o!==p&&s(p)},100,{leading:!1}),c=h=>{h.cancelable&&h.preventDefault(),h.stopPropagation()},l=P.throttle((h,u)=>{h.cancelable&&h.preventDefault(),h.stopPropagation();let d=Math.floor(Math.max(u.x,t*100));d=Math.floor(Math.min(d,e*100)),u.x!==(i==null?void 0:i.x)&&n({x:d,y:0});const p=d/100;o!==p&&s(p)},100,{leading:!1});return g.createElement("div",{className:"range-number-container",onClick:h=>{const u=h.nativeEvent.offsetX-6;let d=Math.floor(Math.max(u,t*100));d=Math.floor(Math.min(d,e*100)),n({x:d,y:0});const p=d/100;o!==p&&s(p)}},g.createElement("div",{className:"range-number-color"}),g.createElement("div",{className:"range-number"},g.createElement(Me,{bounds:"parent",axis:"x",position:i,onDrag:a,onStart:c,onStop:l},g.createElement("div",{className:"circle",onClick:c}))))},CM=r=>{const{icon:o,value:t,onChangeHandler:e,style:s}=r,[i,n]=g.useState(0),[a,c]=g.useState(),l=g.useRef(null),h=g.useCallback(p=>{p>=ae.length&&(p=0),p<0&&(p=ae.length-1),n(p),e(ae[p]),c(!1),l.current&&(l.current.value=ae[p])},[e]),u=g.useMemo(()=>{if(s&&s.bottom){const p={};return p.top="inherit",p.bottom=50,p}},[s]);g.useEffect(()=>{t&&(n(ae.indexOf(t)),l.current&&(l.current.value=t))},[t]);const d=g.useMemo(()=>a?g.createElement(kM,{options:ae,onClickHandler:h,style:u}):null,[a,h,u]);return g.createElement("div",{className:"button input-button"},g.createElement("img",{src:wt(o)}),g.createElement("input",{readOnly:!0,className:"input-number",type:"text",ref:l,onTouchEnd:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),l.current&&l.current.focus()},onClick:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),l.current&&(l.current.focus(),c(!a))}}),g.createElement("div",{className:"input-number-btns"},g.createElement("div",{className:"input-number-add",onClick:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),h(i+1)},onTouchEnd:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),h(i+1)}}),g.createElement("div",{className:"input-number-cut",onClick:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),h(i-1)},onTouchEnd:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),h(i-1)}})),d)},kM=r=>{const{options:o,style:t,onClickHandler:e}=r;return g.createElement("div",{className:"select-option-menu",style:t,onTouchEnd:s=>{s.cancelable&&s.preventDefault(),s.stopPropagation(),s.nativeEvent.stopImmediatePropagation()},onClick:s=>{s.cancelable&&s.preventDefault(),s.stopPropagation(),s.nativeEvent.stopImmediatePropagation()}},o.map((s,i)=>g.createElement("div",{className:"select-option-btn",key:s,onClick:n=>{n.cancelable&&n.preventDefault(),n.stopPropagation(),e(i)},onTouchEnd:n=>{n.cancelable&&n.preventDefault(),n.stopPropagation(),e(i)}},s)))},xM=r=>{const{mananger:o,innerRatio:t,innerVerticeStep:e,vertices:s}=r,i=c=>{q.emitMethod(Z.MainEngine,R.SetShapeOpt,{workIds:[H],toolsType:C.Star,viewId:o.viewId,vertices:c})},n=c=>{q.emitMethod(Z.MainEngine,R.SetShapeOpt,{workIds:[H],toolsType:C.Star,viewId:o.viewId,innerVerticeStep:c})},a=c=>{q.emitMethod(Z.MainEngine,R.SetShapeOpt,{workIds:[H],toolsType:C.Star,viewId:o.viewId,innerRatio:c})};return g.createElement(g.Fragment,null,g.createElement(Co,{value:s,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:i}),g.createElement(Co,{value:e,icon:"star-innerVertex",min:1,max:100,step:1,onInputHandler:n}),g.createElement(TM,{value:t,icon:"star-innerRatio",min:.1,max:1,step:.1,onInputHandler:a}))},zM=r=>{const{mananger:o,vertices:t}=r,e=s=>{q.emitMethod(Z.MainEngine,R.SetShapeOpt,{workIds:[H],toolsType:C.Polygon,viewId:o.viewId,vertices:s})};return g.createElement(Co,{value:t,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:e})},bM=r=>{const{mananger:o,placement:t}=r,e=s=>{q.emitMethod(Z.MainEngine,R.SetShapeOpt,{workIds:[H],toolsType:C.SpeechBalloon,viewId:o.viewId,placement:s})};return g.createElement(CM,{value:t,icon:"speechBallon-placement",onChangeHandler:e})},yo=r=>{const{icon:o,isActive:t,onClickHandler:e,onTouchEndHandler:s}=r;return g.createElement("div",{className:`button tab-button ${t?"active":""}`,onClick:e,onTouchEnd:s},g.createElement("img",{src:wt(o)}))},LM=r=>{const{toolsTypes:o,style:t,mananger:e,shapeOpt:s}=r,[i,n]=g.useState();g.useEffect(()=>{o.includes(C.Polygon)?n(C.Polygon):o.includes(C.Star)?n(C.Star):n(C.SpeechBalloon)},[o]);const a=(u,d)=>{d.cancelable&&d.preventDefault(),d==null||d.stopPropagation(),n(u)},c=g.useMemo(()=>i===C.Polygon&&e&&s.vertices?g.createElement(zM,{vertices:s.vertices,mananger:e}):null,[e,i,s]),l=g.useMemo(()=>i===C.Star&&e&&s.vertices&&s.innerVerticeStep&&s.innerRatio?g.createElement(xM,{mananger:e,vertices:s.vertices,innerVerticeStep:s.innerVerticeStep,innerRatio:s.innerRatio}):null,[e,i,s]),h=g.useMemo(()=>i===C.SpeechBalloon&&e&&s.placement?g.createElement(bM,{mananger:e,placement:s.placement}):null,[e,i,s]);return g.createElement("div",{className:"shapeOpt-sub-menu",style:t,onClick:u=>{u.stopPropagation(),u.nativeEvent.stopImmediatePropagation(),u.cancelable&&u.preventDefault()}},g.createElement("div",{className:"shapeOpt-sub-menu-tabs"},o.includes(C.Polygon)&&g.createElement(yo,{isActive:i===C.Polygon,icon:i===C.Polygon?"polygon-active":"polygon",onClickHandler:a.bind(void 0,C.Polygon),onTouchEndHandler:a.bind(void 0,C.Polygon)})||null,o.includes(C.Star)&&g.createElement(yo,{isActive:i===C.Star,icon:i===C.Star?"star-active":"star",onClickHandler:a.bind(void 0,C.Star),onTouchEndHandler:a.bind(void 0,C.Star)})||null,o.includes(C.SpeechBalloon)&&g.createElement(yo,{isActive:i===C.SpeechBalloon,icon:i===C.SpeechBalloon?"speechBallon-active":"speechBallon",onClickHandler:a.bind(void 0,C.SpeechBalloon),onTouchEndHandler:a.bind(void 0,C.SpeechBalloon)})||null),g.createElement("div",{className:"shapeOpt-sub-menu-content"},c,l,h))},PM=r=>{const{open:o,setOpen:t,floatBarRef:e,toolsTypes:s,shapeOpt:i}=r,{floatBarData:n,mananger:a}=g.useContext(Mt),[c,l]=g.useState([]),[h,u]=g.useState(),d=g.useMemo(()=>{if(e!=null&&e.current&&P.isNumber(n==null?void 0:n.x)&&P.isNumber(n==null?void 0:n.y)&&(a!=null&&a.height)){if(e.current.offsetTop&&e.current.offsetTop+n.y>200){const y={};return y.top="inherit",y.bottom=50,y}else if(!e.current.offsetTop&&(a==null?void 0:a.height)-e.current.offsetTop-(n==null?void 0:n.y)<140){const y={};return y.top="inherit",y.bottom=50,y}}},[e,n==null?void 0:n.x,n==null?void 0:n.y,a==null?void 0:a.height]),p=g.useMemo(()=>o&&s&&a&&i?(a.control.room&&!a.control.room.disableDeviceInputs&&(u(a.control.room.disableDeviceInputs),a.control.room.disableDeviceInputs=!0),g.createElement(LM,{shapeOpt:i,style:d,toolsTypes:s,mananger:a})):(a!=null&&a.control.room&&P.isBoolean(h)&&(a.control.room.disableDeviceInputs=h),null),[o,d,s,a,i]),f=y=>{y.cancelable&&y.preventDefault(),y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),t(!o)},I=y=>{y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),t(!o)};return g.useEffect(()=>{P.isEqual(n==null?void 0:n.selectIds,c)||n!=null&&n.selectIds&&!P.isEqual(n==null?void 0:n.selectIds,c)&&(l(n==null?void 0:n.selectIds),t(!1))},[o,n,c,t]),g.useEffect(()=>()=>{o&&a!=null&&a.control.room&&P.isBoolean(h)&&(a.control.room.disableDeviceInputs=h)},[o,a,h]),g.createElement("div",{className:`button normal-button ${o&&"active"}`,onClick:f,onTouchEnd:I},p,g.createElement("img",{alt:"icon",src:wt(o?"shapes-active":"shapes")}))},Li=g.memo(r=>{const{textOpt:o,workIds:t,noLayer:e,position:s}=r,{floatBarData:i,mananger:n}=g.useContext(Mt),[a,c]=g.useState(0),[l,h]=g.useState(),u=g.useRef(null);g.useEffect(()=>{var b,A,O,j;const S={},T=(i==null?void 0:i.w)||((b=o==null?void 0:o.boxSize)==null?void 0:b[0])||0,x=(i==null?void 0:i.h)||((A=o==null?void 0:o.boxSize)==null?void 0:A[1])||0;if(s&&T&&x&&(n!=null&&n.width)&&(n!=null&&n.height)){if(s.y<60?s.y+x<n.height-60?S.bottom=-120:s.y+x<n.height?S.bottom=-58:s.y>0?S.top=62:S.top=-s.y+62:S.top=0,s.x<0)S.left=-s.x+3;else if(s.x+(((O=u.current)==null?void 0:O.offsetWidth)||T)>n.width){const E=n.width-(((j=u.current)==null?void 0:j.offsetWidth)||T)-s.x;S.left=E}h(S);return}h(void 0)},[u,s,i==null?void 0:i.w,i==null?void 0:i.h,n==null?void 0:n.width,n==null?void 0:n.height,o==null?void 0:o.boxSize]);const d=g.useMemo(()=>i!=null&&i.fillColor?g.createElement(dM,{floatBarRef:u,open:a===3,setOpen:S=>{c(S===!0?3:0)}}):null,[i==null?void 0:i.fillColor,a,u]),p=g.useMemo(()=>i!=null&&i.strokeColor?g.createElement(uM,{floatBarRef:u,open:a===2,setOpen:S=>{c(S===!0?2:0)}}):null,[i==null?void 0:i.strokeColor,a,u]),f=g.useMemo(()=>o!=null&&o.fontColor&&(n!=null&&n.viewId)?g.createElement(pM,{floatBarRef:u,open:a===4,setOpen:S=>{c(S===!0?4:0)},textOpt:o,workIds:t}):null,[o,a,t,n,u]),I=g.useMemo(()=>o!=null&&o.fontBgColor&&(n!=null&&n.viewId)?g.createElement(fM,{floatBarRef:u,open:a===5,setOpen:S=>{c(S===!0?5:0)},textOpt:o,workIds:t}):null,[o,a,t,n,u]),y=g.useMemo(()=>o&&(n!=null&&n.viewId)?g.createElement(wM,{floatBarRef:u,open:a===6,setOpen:S=>{c(S===!0?6:0)},textOpt:o,workIds:t,style:l}):null,[o,a,t,n,l,u]),v=g.useMemo(()=>o&&(n!=null&&n.viewId)?g.createElement(vM,{open:a===7,setOpen:S=>{c(S===!0?7:0)},textOpt:o,workIds:t,floatBarRef:u}):null,[o,a,t,n,u]),m=g.useMemo(()=>e?null:g.createElement(aM,{open:a===1,setOpen:S=>{c(S===!0?1:0)},floatBarRef:u}),[e,a,u]),w=g.useMemo(()=>i!=null&&i.canLock&&n?g.createElement(NM,{workIds:t,mananger:n,islocked:i.isLocked}):null,[i,n,t]),N=g.useMemo(()=>n&&(n!=null&&n.viewId)&&l&&(i!=null&&i.shapeOpt)&&(i!=null&&i.toolsTypes)?g.createElement(PM,{open:a===8,setOpen:S=>{c(S===!0?8:0)},floatBarRef:u,workIds:t,toolsTypes:i.toolsTypes,shapeOpt:i.shapeOpt}):null,[i,n,a,l,t,u]);return g.createElement("div",{className:"appliance-plugin-floatbtns",style:l,ref:u,onMouseOver:S=>(S.stopPropagation(),S.cancelable&&S.preventDefault(),n==null||n.control.worker.blurCursor(n.viewId),!1),onMouseMove:S=>(S.stopPropagation(),S.cancelable&&S.preventDefault(),!1)},n&&g.createElement(nM,{workIds:t,mananger:n}),m,w,!!(n!=null&&n.viewId)&&g.createElement(rM,{workIds:t,viewId:n.viewId}),N,v,y,f,I,p,d)}),jM=r=>{const{data:o,isActive:t,manager:e,workId:s}=r,{opt:i,scale:n,translate:a,x:c,y:l}=o,h=`scale(${n||1}) ${a&&"translate("+a[0]+"px,"+a[1]+"px)"||""}`,{fontSize:u,fontFamily:d,underline:p,fontColor:f,lineThrough:I,textAlign:y,strokeColor:v,lineHeight:m,bold:w,italic:N,uid:S,workState:T}=i,x=u,b=m||x*1.2,A={fontSize:`${x}px`,lineHeight:`${b}px`,color:f,borderColor:v,minHeight:`${b}px`,paddingRight:`${N==="italic"?Math.round(x*.3):5}px`};d&&(A.fontFamily=`${d}`),(I||p)&&(A.textDecoration=`${I&&"line-through"||""}${p&&" underline"||""}`),w&&(A.fontWeight=`${w}`),N&&(A.fontStyle=`${N}`),y&&(A.textAlign=`${y}`);function O(){var E;t&&(S&&S===((E=e.control.collector)==null?void 0:E.uid)||!S)&&e.control.textEditorManager.active(s)}const j=g.useMemo(()=>{const E=[];if(i.text){const D=Te(i.text);for(let _=0;_<D.length;_++){const nt=D[_];nt===""?E.push(g.createElement("div",{style:{backgroundColor:i.fontBgColor},key:_},g.createElement("br",null))):E.push(g.createElement("div",{style:{backgroundColor:i.fontBgColor},key:_},nt))}}return E.length?E:null},[i.fontBgColor,i.text]);return g.createElement("div",{className:"editor-box",style:{left:`${c}px`,top:`${l}px`,transform:h,transformOrigin:"left top",pointerEvents:"none",opacity:T===L.Done?0:1}},g.createElement("div",{className:`editor ${t?"":"readOnly"}`,style:A,onClick:O},j))},DM=g.memo(r=>{const{data:o,left:t,top:e,workId:s,updateOptInfo:i}=r,{opt:n,scale:a,translate:c}=o,l=g.useRef(null);g.useEffect(()=>{var A,O;if((A=l.current)!=null&&A.offsetWidth&&((O=l.current)!=null&&O.offsetHeight)){const j=n.boxSize;if((j==null?void 0:j[0])!==l.current.offsetWidth||j[1]!==l.current.offsetHeight||!j){const E=[l.current.offsetWidth,l.current.offsetHeight];i({activeTextId:s,update:{boxSize:E,workState:L.Done}})}}},[n.fontSize,n.italic,n.bold,n.boxSize,s]);const h=`scale(${a||1}) ${c&&"translate("+c[0]+"px,"+c[1]+"px)"||""}`,{fontSize:u,fontFamily:d,underline:p,fontColor:f,lineThrough:I,textAlign:y,strokeColor:v,lineHeight:m,bold:w,italic:N}=n,S=u,T=m||S*1.2,x={fontSize:`${S}px`,lineHeight:`${T}px`,color:f,borderColor:v,minHeight:`${T}px`,pointerEvents:"none",paddingRight:`${N==="italic"?Math.round(S*.3):5}px`};d&&(x.fontFamily=`${d}`),(I||p)&&(x.textDecoration=`${I&&"line-through"||""}${p&&" underline"||""}`),y&&(x.textAlign=`${y}`),w&&(x.fontWeight=`${w}`),N&&(x.fontStyle=`${N}`);const b=g.useMemo(()=>{const A=[];if(n.text){const O=Te(n.text);for(let j=0;j<O.length;j++){const E=O[j];E===""?A.push(g.createElement("div",{key:j},g.createElement("br",null))):A.push(g.createElement("div",{key:j},E))}}return A.length?A:null},[n.text]);return g.createElement("div",{className:"editor-box",style:{left:`${t}`,top:`${e}`,transform:h,transformOrigin:"left top",zIndex:1,pointerEvents:"none",opacity:0}},g.createElement("div",{className:"editor readOnly",ref:l,style:x},b))},(r,o)=>!(r.workId!==o.workId||r.left!==o.left||r.top!==o.top||!P.isEqual(r.data,o.data))),AM=r=>{const{data:o,workId:t,isSelect:e,showFloatBtns:s,handleKeyUp:i,handleFocus:n,updateOptInfo:a,manager:c,runAnimation:l}=r,[h,u]=g.useState(),{opt:d,scale:p,translate:f,x:I,y}=o,{fontSize:v,fontFamily:m,underline:w,fontColor:N,lineThrough:S,textAlign:T,strokeColor:x,lineHeight:b,bold:A,italic:O,boxSize:j}=d,E=g.useRef(null),D=g.useMemo(()=>{const ot=v,at=b||ot*1.2,W={fontSize:`${ot}px`,lineHeight:`${at}px`,color:N,borderColor:x,minHeight:`${at}px`,paddingRight:`${O==="italic"?Math.round(ot*.3):5}px`,borderWidth:`${Math.max(Math.round(1/(p||1)),1)}px`};return m&&(W.fontFamily=`${m}`),(S||w)&&(W.textDecoration=`${S&&"line-through"||""} ${w&&" underline"||""}`),T&&(W.textAlign=`${T}`),A&&(W.fontWeight=`${A}`),O&&(W.fontStyle=`${O}`),W},[A,N,m,v,O,b,S,p,x,T,w]),_=g.useMemo(()=>{const ot=`scale(${p||1}) ${f&&"translate("+f[0]+"px,"+f[1]+"px)"||""}`;return{left:`${I}px`,top:`${y}px`,zIndex:2,pointerEvents:"none",transform:ot,transformOrigin:"left top"}},[p,f,I,y]),nt=g.useMemo(()=>{var ot,at;return!e&&p&&s&&P.isNumber(I)&&P.isNumber(y)&&d.boxSize&&P.isNumber((ot=d.boxSize)==null?void 0:ot[0])&&P.isNumber((at=d.boxSize)==null?void 0:at[1])?g.createElement("div",{className:Tt.FloatBarBtn,style:{left:I,top:y,width:d.boxSize[0]*p,height:d.boxSize[1]*p}},g.createElement(Li,{position:{x:I,y},textOpt:d,workIds:[t],noLayer:!0})):null},[e,d,s,t,I,y,p]),tt=g.useMemo(()=>{let ot="";if(d.text){const at=Te(d.text);for(let W=0;W<at.length;W++){const it=at[W];it===""?ot=ot+"<div><br/></div>":ot=ot+`<div style="background-color:${d.fontBgColor}">${it}</div>`}}else ot=`<div style="background-color:${d.fontBgColor}"></div>`;return ot},[d.fontBgColor,d.text]),V=g.useMemo(()=>typeof tt=="string"?g.createElement("div",{id:t,suppressContentEditableWarning:!0,contentEditable:!0,className:"editor",ref:E,style:D,onKeyDown:$,onKeyUp:i,onClick:K,onTouchEnd:K,onFocus:n,onPaste:rt,onInput:It,dangerouslySetInnerHTML:{__html:tt}}):null,[tt,D,t]);g.useEffect(()=>{V&&E.current&&(E.current.click(),setTimeout(()=>{var ot;if(E.current){const at=window==null?void 0:window.getSelection(),W=E.current.lastChild;if(at&&W){const it=document.createRange(),ht=((ot=W.textContent)==null?void 0:ot.length)||0;(W==null?void 0:W.nodeName)==="#text"?it.setStart(W,ht):it.setStart(W,ht&&1||0),it.collapse(!0),at.removeAllRanges(),at.addRange(it)}}},20))},[V,E.current]),g.useEffect(()=>{var ot,at,W,it;if(V&&((ot=E.current)!=null&&ot.offsetWidth||(at=E.current)!=null&&at.offsetHeight||(W=E.current)!=null&&W.offsetLeft||(it=E.current)!=null&&it.offsetTop)){const ht=[E.current.offsetWidth,E.current.offsetHeight];(j&&j[0]!==ht[0]&&j[1]!==ht[1]||!j)&&a({activeTextId:t,update:{boxSize:ht,workState:L.Doing}})}},[j,V,D,t]);function K(){E.current&&E.current.focus(),l()}function $(ot){if(ot.key==="Backspace"){const at=window.getSelection(),W=at==null?void 0:at.getRangeAt(0);if(W!=null&&W.collapsed)return ot.cancelable&&ot.preventDefault(),document.execCommand("delete",!1),!1}return l(),!1}function G(ot,at){const W=window==null?void 0:window.getSelection();if(W!=null&&W.rangeCount&&ot&&W&&W.anchorNode){const it=W.anchorOffset,ht=W.anchorNode.textContent||"",vt=ht.slice(0,it)||"",Xt=ht.slice(it)||"",Ft=vt.concat(ot)||"";J(Ft,Xt,at)}}function J(ot,at,W){const it=window==null?void 0:window.getSelection();if(!(it!=null&&it.rangeCount)||!it.anchorNode)return;const ht=ot.split(/\n/);let vt=it.anchorNode.parentNode;vt===W&&(vt=it.anchorNode);const Xt=[...W.childNodes],Ft=[];let Pt,uo=it.anchorOffset;for(;Xt.length;){const Nt=Xt.pop();if(Nt){if(Nt===vt){let jt=ht[0];ht.length===1&&(uo=ht[0].length,jt=ht[0].concat(at)),vt.nodeName==="#text"?(vt.textContent=jt,Pt=vt):vt.nodeName==="DIV"&&(vt.innerText=jt,Pt=vt.childNodes[0]);break}Ft.push(Nt),W.removeChild(Nt)}}if(ht.length>1)for(let Nt=1;Nt<ht.length;Nt++){let jt=ht[Nt];const Se=document.createElement("div");d.fontBgColor&&(Se.style.backgroundColor=d.fontBgColor),Nt===ht.length-1&&(uo=jt.length,jt=jt.concat(at)),jt===""?Se.innerHTML="<br/>":Se.innerText=jt,W.appendChild(Se),Nt===ht.length-1&&(Pt=Se.childNodes[0])}if(Ft.length){Ft.reverse();for(const Nt of Ft)W.appendChild(Nt)}if(Pt&&Pt.nodeName==="#text"){it.deleteFromDocument();const Nt=document.createRange(),jt=Math.min(uo,(Pt==null?void 0:Pt.length)||0);Nt.setStart(Pt,jt),Nt.collapse(!0),it.removeAllRanges(),it.addRange(Nt)}}function rt(ot){if(ot.cancelable&&ot.preventDefault(),ot.stopPropagation(),E.current){const at=(ot.clipboardData||window.clipboardData).getData("text"),W=window==null?void 0:window.getSelection();if(!(W!=null&&W.rangeCount))return;at&&W&&W.anchorNode&&G(at,E.current),l()}}function It(ot){i(ot),l()}return g.createElement(g.Fragment,null,nt,g.createElement("div",{className:"editor-box",style:_,onFocus:()=>{c.control.room&&!c.control.room.disableDeviceInputs&&(u(c.control.room.disableDeviceInputs),c.control.room.disableDeviceInputs=!0)},onBlur:()=>{c!=null&&c.control.room&&P.isBoolean(h)&&(c.control.room.disableDeviceInputs=h)}},V))};class Pi extends g.Component{constructor(o){super(o)}getInnerText(o){const t=[];for(let e=0;e<o.childNodes.length;e++){const s=o.childNodes[e];if(s.nodeName==="#text"&&e===0){const i=s.textContent.split(/\n/),n=i.pop();t.push(...i),n&&t.push(n)}else if(s.nodeName==="DIV"){const i=s.innerText.split(/\n/);if(i.length===2&&i[0]===""&&i[1]==="")t.push("");else{const n=i.shift();n&&t.push(n);const a=i.pop();t.push(...i),a&&t.push(a)}}}return t}updateOptInfo(o){var n,a;const{activeTextId:t,update:e,syncData:s}=o,i=t&&P.cloneDeep(((n=this.props.manager.control.textEditorManager)==null?void 0:n.get(t))||((a=this.props.editors)==null?void 0:a.get(t)));i&&i.opt&&(i.opt={...i.opt,...e},s&&(i.canSync=Object.keys(s).includes("canSync")&&s.canSync||i.canSync,i.canWorker=Object.keys(s).includes("canWorker")&&s.canWorker||i.canWorker),this.props.manager.control.textEditorManager.updateForViewEdited(t,i))}get editorUI(){var o;if((o=this.props.editors)!=null&&o.size){const t=[];return this.props.editors.forEach((e,s)=>{if(this.props.selectIds.includes(s)&&!(this.props.activeTextId==s)&&this.props.box){const{x:n,y:a}=this.props.box,{x:c,y:l}=e,h=`${c-n}px`,u=`${l-a}px`,d=g.createElement(DM,{left:h,top:u,key:s,data:e,workId:s,isSelect:!0,updateOptInfo:this.updateOptInfo.bind(this),manager:this.props.manager});t.push(d)}}),t}return null}render(){return g.createElement(g.Fragment,null,this.editorUI)}}class EM extends Pi{constructor(t){super(t);M(this,"ref");M(this,"isRunAnimation");this.ref=g.createRef(),this.isRunAnimation=void 0}runAnimation(){this.isRunAnimation||(this.isRunAnimation=requestAnimationFrame(()=>{var t,e;(t=this.ref)!=null&&t.current&&((e=this.ref)==null||e.current.scrollTo({left:0,behavior:"instant"})),this.isRunAnimation=void 0}))}handleKeyUp(t){const e=this.getInnerText(t.nativeEvent.target),s=this.props.activeTextId;if(s){const i=this.props.manager.control.textEditorManager.get(s),n=zt(e),a=L.Doing,c=[t.nativeEvent.target.offsetWidth,t.nativeEvent.target.offsetHeight];(!i||i&&(i.opt.text!==n||!P.isEqual(i.opt.boxSize,c)||!P.isEqual(i.opt.workState,a)))&&this.updateOptInfo({activeTextId:s,update:{text:n,boxSize:c,workState:a},syncData:{canSync:!0,canWorker:!0}})}}handleFocus(t){const e=this.props.activeTextId;if(e){const s=this.props.manager.control.textEditorManager.get(e),i=L.Doing,n=[t.nativeEvent.target.offsetWidth,t.nativeEvent.target.offsetHeight];(!s||s&&(!P.isEqual(s.opt.boxSize,n)||!P.isEqual(s.opt.workState,i)))&&this.updateOptInfo({activeTextId:e,update:{boxSize:n,workState:i},syncData:{canSync:!0,canWorker:!0}})}}get editorUI(){var t;if((t=this.props.editors)!=null&&t.size){const e=[];return this.props.editors.forEach((s,i)=>{if(!(this.props.selectIds.includes(i)&&this.props.activeTextId!==i)){const c=this.props.activeTextId==i?g.createElement(AM,{key:i,data:s,workId:i,showFloatBtns:this.props.showFloatBtns||!1,handleFocus:this.handleFocus.bind(this),handleKeyUp:this.handleKeyUp.bind(this),updateOptInfo:this.updateOptInfo.bind(this),manager:this.props.manager,runAnimation:this.runAnimation.bind(this)}):g.createElement(jM,{manager:this.props.manager,isActive:s.opt.workState===L.Doing||s.opt.workState===L.Start||!1,key:i,data:s,workId:i});e.push(c)}}),e}return null}render(){return g.createElement("div",{className:`${this.props.className}`,ref:this.ref},this.editorUI)}}const OM=()=>{const{floatBarData:r}=g.useContext(Mt);return g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},g.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point LC ew-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point TC ns-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point RC ew-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point BC ns-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}))},RM=()=>{const{floatBarData:r,mananger:o}=g.useContext(Mt),[t,e]=g.useState(),[s,i]=g.useState();g.useEffect(()=>{const c=[];if(o&&P.isNumber(r==null?void 0:r.x)&&P.isNumber(r==null?void 0:r.y)&&(r!=null&&r.points)){const l=o.viewId;if(o.control.viewContainerManager.getView(l))for(const u of r.points){const d=o.control.viewContainerManager.transformToOriginPoint(u,l);c.push(d)}c[0]&&e({x:c[0][0]-((r==null?void 0:r.x)||0),y:c[0][1]-((r==null?void 0:r.y)||0)}),c[1]&&i({x:c[1][0]-((r==null?void 0:r.x)||0),y:c[1][1]-((r==null?void 0:r.y)||0)})}},[o,r==null?void 0:r.points,r==null?void 0:r.x,r==null?void 0:r.y]);const n=g.useMemo(()=>t?g.createElement("div",{className:"point point-dot",style:{borderColor:r==null?void 0:r.selectorColor,left:t.x,top:t.y}}):null,[r==null?void 0:r.selectorColor,t]),a=g.useMemo(()=>s?g.createElement("div",{className:"point point-dot",style:{borderColor:r==null?void 0:r.selectorColor,left:s.x,top:s.y}}):null,[s,r==null?void 0:r.selectorColor]);return g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},n,a)},YM=()=>{const{floatBarData:r}=g.useContext(Mt);return g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},g.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}))},WM=()=>{const{floatBarData:r}=g.useContext(Mt);return g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},g.createElement("img",{className:"lock",alt:"lock",src:"https://sdk.netless.link/resource/icons/lock.svg"}))},UM=r=>{const{className:o}=r,{floatBarData:t,angle:e,setAngle:s,setOperationType:i,mananger:n}=g.useContext(Mt),[a,c]=g.useState(!1),[l,h]=g.useState(new B),[u,d]=g.useState(new B),[p,f]=g.useState(!1);g.useEffect(()=>(q.activeListener(I),()=>{q.unmountActiveListener(I)}),[]);const I=w=>{var N;if(!w){f(!0),c(!1),i(R.None);return}f(!1),(N=n==null?void 0:n.control.room)!=null&&N.disableDeviceInputs&&(n.control.room.disableDeviceInputs=!1)};g.useEffect(()=>{if(t){const w=Math.floor(t.w/2),N=Math.floor(-t.h/2);d(new B(w,N)),h(new B)}},[t]);const y=(w,N)=>{if(w.cancelable&&w.preventDefault(),w.stopPropagation(),n!=null&&n.control.worker.isBusy){f(!0);return}c(!0);const S=Math.round(B.GetAngleByPoints(l,u,new B(N.x,N.y)))||0;s(S),i(R.RotateNode),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=!0),q.emitMethod(Z.MainEngine,R.RotateNode,{workIds:[H],angle:S,workState:L.Start,viewId:n==null?void 0:n.viewId})},v=je((w,N)=>{if(w.cancelable&&w.preventDefault(),w.stopPropagation(),n!=null&&n.control.worker.isBusy){f(!0);return}c(!1);const S=Math.round(B.GetAngleByPoints(l,u,new B(N.x,N.y)))||0;s(S),i(R.None),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=!1),q.emitMethod(Z.MainEngine,R.RotateNode,{workIds:[H],angle:S,workState:L.Done,viewId:n==null?void 0:n.viewId})},100,{leading:!1}),m=je((w,N)=>{if(w.cancelable&&w.preventDefault(),w.stopPropagation(),n!=null&&n.control.worker.isBusy){f(!0);return}c(!0);const S=Math.round(B.GetAngleByPoints(l,u,new B(N.x,N.y)))||0;s(S),i(R.RotateNode),q.emitMethod(Z.MainEngine,R.RotateNode,{workIds:[H],angle:S,workState:L.Doing,viewId:n==null?void 0:n.viewId})},100,{leading:!1});return g.createElement(Me,{disabled:p,handle:".appliance-plugin-rotate-mouse-pointer",onStart:y,onDrag:m,onStop:v},g.createElement("div",{className:`${o}`,style:t?{left:t.x-30,top:t.y+t.h+20,touchAction:"none"}:void 0},!a&&g.createElement("div",{className:"appliance-plugin-rotate-btn",style:{backgroundColor:t==null?void 0:t.selectorColor}},g.createElement("img",{alt:"icon",src:wt("rotation-button")})),g.createElement("div",{className:`appliance-plugin-rotate-mouse-pointer ${a?"active":""}`},g.createElement("img",{alt:"icon",src:wt("rotation")}),g.createElement("div",{className:"angle-icon"},e,"°"))))},BM=r=>{const{floatBarData:o,setOperationType:t,mananger:e}=g.useContext(Mt),{onClickHandle:s}=r,[i,n]=g.useState(L.Pending),[a,c]=g.useState(),[l,h]=g.useState(),[u,d]=g.useState(!1);g.useEffect(()=>(q.activeListener(p),()=>{q.unmountActiveListener(p)}),[]);const p=w=>{var N;if(!w||o!=null&&o.isLocked){d(!0),n(L.Pending),t(R.None);return}d(!1),(N=e==null?void 0:e.control.room)!=null&&N.disableDeviceInputs&&(e.control.room.disableDeviceInputs=!1)};g.useEffect(()=>{if(o!=null&&o.isLocked||e!=null&&e.control.worker.isBusy){d(!0),n(L.Pending);return}d(!1)},[o==null?void 0:o.isLocked]),g.useEffect(()=>{P.isNumber(o==null?void 0:o.x)&&P.isNumber(o==null?void 0:o.y)&&(i===L.Pending||i===L.Done)&&h({x:o==null?void 0:o.x,y:o==null?void 0:o.y})},[i,o==null?void 0:o.x,o==null?void 0:o.y]);const f=w=>{if(w.cancelable&&w.preventDefault(),w.stopPropagation(),e!=null&&e.control.worker.isBusy){d(!0),n(L.Pending);return}P.isNumber(o==null?void 0:o.x)&&P.isNumber(o==null?void 0:o.y)&&(t(R.TranslateNode),n(L.Start),c({x:o==null?void 0:o.x,y:o==null?void 0:o.y}),e!=null&&e.control.room&&(e.control.room.disableDeviceInputs=!0),q.emitMethod(Z.MainEngine,R.TranslateNode,{workIds:[H],position:{x:o==null?void 0:o.x,y:o==null?void 0:o.y},workState:L.Start,viewId:e==null?void 0:e.viewId}))},I=P.throttle((w,N)=>{if(w.cancelable&&w.preventDefault(),e!=null&&e.control.worker.isBusy){d(!0),n(L.Pending);return}w.stopPropagation();const S={x:N.x,y:N.y};t(R.None),n(L.Done),e!=null&&e.control.room&&(e.control.room.disableDeviceInputs=!1),q.emitMethod(Z.MainEngine,R.TranslateNode,{workIds:[H],position:S,workState:L.Done,viewId:e==null?void 0:e.viewId})},100,{leading:!1}),y=P.throttle((w,N)=>{if(w.cancelable&&w.preventDefault(),w.stopPropagation(),e!=null&&e.control.worker.isBusy){d(!0),n(L.Pending);return}const S={x:N.x,y:N.y};(N.x!==(o==null?void 0:o.x)||N.y!==(o==null?void 0:o.y))&&(n(L.Doing),q.emitMethod(Z.MainEngine,R.TranslateNode,{workIds:[H],position:S,workState:L.Doing,viewId:e==null?void 0:e.viewId}))},100,{leading:!1}),v=g.useMemo(()=>!!((o==null?void 0:o.scaleType)===ct.none&&(o!=null&&o.canLock)),[o]),m=P.throttle(w=>(w.stopPropagation(),w.cancelable&&w.preventDefault(),(a==null?void 0:a.x)===(o==null?void 0:o.x)&&(a==null?void 0:a.y)===(o==null?void 0:o.y)&&s(w),!1),100,{leading:!1});return g.createElement(Me,{disabled:u,position:l,onStart:f,onDrag:y,onStop:I},g.createElement("div",{style:o?{position:"absolute",left:0,top:0,width:o.w,height:o.h,zIndex:2,pointerEvents:v?"none":"auto",touchAction:"none"}:void 0,onClick:w=>{w.persist(),m(w)},onTouchEnd:w=>{w.persist(),m(w)}}))},FM=r=>{const{className:o}=r,[t,e]=g.useState({x:0,y:0,h:0,w:0}),[s,i]=g.useState(),[n,a]=g.useState(),[c,l]=g.useState(),{floatBarData:h,mananger:u}=g.useContext(Mt),[d,p]=g.useState(),[f,I]=g.useState(!1);g.useEffect(()=>{if(h&&u){const x={x:h.x,y:h.y,w:h.w,h:h.h};e(x)}return q.activeListener(y),()=>{q.unmountActiveListener(y)}},[]);const y=x=>{var b;if(!x){I(!0);return}I(!1),(b=u==null?void 0:u.control.room)!=null&&b.disableDeviceInputs&&(u.control.room.disableDeviceInputs=!1)},v=x=>[[x.x,x.y],[x.x+x.w,x.y],[x.x+x.w,x.y+x.h],[x.x,x.y+x.h]],m=(x,b)=>{switch(b){case"top":case"topLeft":case"left":return x[2];case"topRight":return x[3];case"right":case"bottomRight":case"bottom":return x[0];case"bottomLeft":return x[1]}},w=(x,b,A,O)=>{let j=!1,E=!1;const D={x:t.x,y:t.y,w:t.w,h:t.h},_=[1,1],nt=[0,0];switch(x){case"top":{const $=b.height+t.h;$<0?(E=!0,D.y=t.y+t.h,D.h=Math.abs($)):(D.y=t.y-b.height,D.h=t.h+b.height);break}case"topLeft":{const $=b.width+t.w;$<0?(j=!0,D.x=t.x+t.w,D.w=Math.abs($)):(D.x=t.x-b.width,D.w=t.w+b.width);const G=b.height+t.h;G<0?(E=!0,D.y=t.y+t.h,D.h=Math.abs(G)):(D.y=t.y-b.height,D.h=t.h+b.height);break}case"topRight":{const $=b.width+t.w;$<0?(j=!0,D.x=t.x+$,D.w=Math.abs($)):D.w=t.w+b.width;const G=b.height+t.h;G<0?(E=!0,D.y=t.y+t.h,D.h=Math.abs(G)):(D.y=t.y-b.height,D.h=t.h+b.height);break}case"bottom":{const $=b.height+t.h;$<0?(E=!0,D.y=t.y+$,D.h=Math.abs($)):D.h=t.h+b.height;break}case"bottomLeft":{const $=b.width+t.w;$<0?(j=!0,D.x=t.x+t.w,D.w=Math.abs($)):(D.x=t.x-b.width,D.w=t.w+b.width);const G=b.height+t.h;G<0?(E=!0,D.y=t.y+G,D.h=Math.abs(G)):D.h=t.h+b.height;break}case"left":{const $=b.width+t.w;$<0?(j=!0,D.x=t.x+t.w,D.w=Math.abs($)):(D.x=t.x-b.width,D.w=t.w+b.width);break}case"bottomRight":{const $=b.width+t.w;$<0?(j=!0,D.x=t.x+$,D.w=Math.abs($)):D.w=t.w+b.width;const G=b.height+t.h;G<0?(E=!0,D.y=t.y+G,D.h=Math.abs(G)):D.h=t.h+b.height;break}case"right":{const $=b.width+t.w;$<0?(j=!0,D.x=t.x+$,D.w=Math.abs($)):D.w=t.w+b.width;break}}_[0]=D.w/t.w,_[1]=D.h/t.h;const V=v(D).map($=>A.control.viewContainerManager.transformToScenePoint($,A.viewId)),K=m(V,x);return E&&(nt[1]=K[1]-O[1]),j&&(nt[0]=K[0]-O[0]),{scale:_,translate:nt}},N=(x,b)=>{if(x.cancelable&&x.preventDefault(),x.stopPropagation(),u!=null&&u.control.worker.isBusy){I(!0);return}if(h!=null&&h.w&&(h!=null&&h.h)&&u){const A={x:h.x,y:h.y,w:h.w,h:h.h},O=v(A),j=O.map(_=>u.control.viewContainerManager.transformToScenePoint(_,u.viewId)),E=m(O,b),D=m(j,b);e(A),i(E),a(D),l(b),u!=null&&u.control.room&&(u.control.room.disableDeviceInputs=!0),q.emitMethod(Z.MainEngine,R.ScaleNode,{workIds:[H],originPoint:E,scenePoint:D,workState:L.Start,viewId:u.viewId})}},S=P.throttle((x,b,A,O)=>{if(x.cancelable&&x.preventDefault(),x.stopPropagation(),!u||!s||!n)return;if(u!=null&&u.control.worker.isBusy){I(!0);return}const{scale:j,translate:E}=w(b,O,u,n);(!P.isEqual(j,d==null?void 0:d.scale)||!P.isEqual(E,d==null?void 0:d.translate))&&(p({scale:j,translate:E}),q.emitMethod(Z.MainEngine,R.ScaleNode,{workIds:[H],scale:j,dir:b,translate:E,originPoint:s,scenePoint:n,workState:L.Doing,viewId:u.viewId}))},100,{leading:!1}),T=P.throttle(x=>{if(x.cancelable&&x.preventDefault(),x.stopPropagation(),!(!u||!s||!n)){if(u!=null&&u.control.worker.isBusy){I(!0);return}if(u!=null&&u.control.room&&(u.control.room.disableDeviceInputs=!1),d){const{scale:b,translate:A}=d;q.emitMethod(Z.MainEngine,R.ScaleNode,{workIds:[H],scale:b,dir:c,translate:A,originPoint:s,scenePoint:n,workState:L.Done,viewId:u.viewId})}}},100,{leading:!1});return g.createElement(Ai.Resizable,{className:`${o}`,boundsByDirection:!0,minWidth:-(((h==null?void 0:h.x)||0)+((h==null?void 0:h.w)||0)),minHeight:-(((h==null?void 0:h.y)||0)+((h==null?void 0:h.h)||0)),size:{width:(h==null?void 0:h.w)||0,height:(h==null?void 0:h.h)||0},style:{position:"absolute",pointerEvents:"auto",left:h==null?void 0:h.x,top:h==null?void 0:h.y},enable:f?!1:{top:(h==null?void 0:h.scaleType)===ct.all&&!0||!1,right:(h==null?void 0:h.scaleType)===ct.all&&!0||!1,bottom:(h==null?void 0:h.scaleType)===ct.all&&!0||!1,left:(h==null?void 0:h.scaleType)===ct.all&&!0||!1,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},lockAspectRatio:(h==null?void 0:h.scaleType)===ct.proportional,onResizeStart:N,onResize:S,onResizeStop:T})},Ls=r=>{const{id:o,pos:t,pointMap:e,type:s}=r,{setOperationType:i,mananger:n,floatBarData:a}=g.useContext(Mt),[c,l]=g.useState({x:0,y:0}),[h,u]=g.useState(L.Pending),[d,p]=g.useState(!1);g.useEffect(()=>(q.activeListener(f),()=>{q.unmountActiveListener(f)}),[]);const f=m=>{var w;if(!m||a!=null&&a.isLocked){p(!0),u(L.Pending),i(R.None);return}p(!1),(w=n==null?void 0:n.control.room)!=null&&w.disableDeviceInputs&&(n.control.room.disableDeviceInputs=!1)};g.useEffect(()=>{P.isNumber(t.x)&&P.isNumber(t.y)&&(h===L.Pending||h===L.Done)&&l({x:t.x,y:t.y})},[t,h]);const I=m=>{if(m.cancelable&&m.preventDefault(),m.stopPropagation(),n!=null&&n.control.worker.isBusy){p(!0),u(L.Pending);return}P.isNumber(t.x)&&P.isNumber(t.y)&&(i(R.SetPoint),u(L.Start),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=!0),q.emitMethod(Z.MainEngine,R.SetPoint,{workId:H,pointMap:e,workState:L.Start,viewId:n==null?void 0:n.viewId}))},y=P.throttle((m,w)=>{if(m.cancelable&&m.preventDefault(),m.stopPropagation(),n!=null&&n.control.worker.isBusy){p(!0),u(L.Pending);return}const N={x:w.x,y:w.y};if((N.x!==(t==null?void 0:t.x)||N.y!==(t==null?void 0:t.y))&&(n!=null&&n.control.viewContainerManager)){const S=n.control.viewContainerManager.transformToScenePoint([N.x,N.y],n.viewId),T=e.get(o);T&&s==="start"?T[0]=S:T&&s==="end"&&(T[1]=S),u(L.Doing),q.emitMethod(Z.MainEngine,R.SetPoint,{workId:H,pointMap:e,workState:L.Doing,viewId:n==null?void 0:n.viewId})}},100,{leading:!1}),v=P.throttle((m,w)=>{if(m.cancelable&&m.preventDefault(),n!=null&&n.control.worker.isBusy){p(!0),u(L.Pending);return}m.stopPropagation(),i(R.None),u(L.Done);const N={x:w.x,y:w.y};if(n!=null&&n.control.viewContainerManager){const S=n.control.viewContainerManager.transformToScenePoint([N.x,N.y],n.viewId),T=e.get(o);T&&s==="start"?T[0]=S:T&&s==="end"&&(T[1]=S),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=!1),q.emitMethod(Z.MainEngine,R.SetPoint,{workId:H,pointMap:e,workState:L.Done,viewId:n==null?void 0:n.viewId})}},100,{leading:!1});return g.createElement(Me,{disabled:d,position:c,onStart:I,onDrag:y,onStop:v},g.createElement("div",{className:"appliance-plugin-point-draggable-btn",style:a?{left:0,top:0}:void 0}))},HM=r=>{const{className:o}=r,{floatBarData:t,mananger:e}=g.useContext(Mt),[s,i]=g.useState(),[n,a]=g.useState(),[c,l]=g.useState(new Map);g.useEffect(()=>{const d=[];if(e&&(t!=null&&t.points)){const p=e.viewId;if(e.control.viewContainerManager.getView(p))for(const I of t.points){const y=e.control.viewContainerManager.transformToOriginPoint(I,p);d.push(y)}t!=null&&t.selectIds&&t.selectIds.length===1&&(c.set(t.selectIds[0],t.points),l(c))}d[0]&&i({x:d[0][0],y:d[0][1]}),d[1]&&a({x:d[1][0],y:d[1][1]})},[e,t==null?void 0:t.points,t==null?void 0:t.selectIds,c]);const h=g.useMemo(()=>s&&(t!=null&&t.selectIds)?g.createElement(Ls,{pos:s,type:"start",id:t.selectIds[0],pointMap:c}):null,[s,t==null?void 0:t.selectIds,c]),u=g.useMemo(()=>n&&(t!=null&&t.selectIds)?g.createElement(Ls,{pos:n,type:"end",id:t.selectIds[0],pointMap:c}):null,[n,t==null?void 0:t.selectIds,c]);return g.createElement("div",{className:`${o}`},h,u)},QM=g.forwardRef((r,o)=>{const{floatBarData:t,operationType:e}=g.useContext(Mt),s=g.useMemo(()=>(t==null?void 0:t.scaleType)!==ct.all||e===R.RotateNode?null:g.createElement(OM,null),[t,e]),i=g.useMemo(()=>(t==null?void 0:t.scaleType)!==ct.both||e===R.RotateNode?null:g.createElement(RM,null),[t,e]),n=g.useMemo(()=>(t==null?void 0:t.scaleType)!==ct.proportional||e===R.RotateNode?null:g.createElement(YM,null),[t,e]),a=g.useMemo(()=>(t==null?void 0:t.scaleType)===ct.none&&(t!=null&&t.canLock)?g.createElement(WM,null):null,[t]);return g.createElement("div",{ref:o,style:t?{transform:`translate(${t.x}px,${t.y}px)`,width:t.w,height:t.h,pointerEvents:"none"}:void 0},a,s,i,n,r.children)}),VM=g.forwardRef((r,o)=>{var d;const{floatBarData:t,operationType:e,mananger:s}=g.useContext(Mt),{editors:i,activeTextId:n}=r,a=g.useMemo(()=>{var p;return t!=null&&t.canRotate&&((p=t==null?void 0:t.selectIds)==null?void 0:p.length)===1&&(e===R.None||e===R.RotateNode)?g.createElement(UM,{className:Tt.RotateBtn}):null},[t==null?void 0:t.canRotate,(d=t==null?void 0:t.selectIds)==null?void 0:d.length,e]),c=g.useMemo(()=>((t==null?void 0:t.scaleType)===ct.all||(t==null?void 0:t.scaleType)===ct.proportional)&&(e===R.None||e===R.ScaleNode)&&P.isNumber(t==null?void 0:t.x)&&P.isNumber(t==null?void 0:t.y)?g.createElement(FM,{className:Tt.ResizeBtn}):null,[t==null?void 0:t.scaleType,e,t==null?void 0:t.x,t==null?void 0:t.y]),l=g.useMemo(()=>(t==null?void 0:t.scaleType)===ct.both&&(e===R.None||e===R.SetPoint)?g.createElement(HM,{className:Tt.ResizeTowBox}):null,[t==null?void 0:t.scaleType,e]),h=g.useMemo(()=>{const p=(t==null?void 0:t.selectIds)||[];return i&&s&&p&&P.isNumber(t==null?void 0:t.x)&&P.isNumber(t==null?void 0:t.y)&&P.isNumber(t==null?void 0:t.w)&&P.isNumber(t==null?void 0:t.h)?g.createElement(Pi,{box:{x:t==null?void 0:t.x,y:t==null?void 0:t.y,w:t==null?void 0:t.w,h:t==null?void 0:t.h},manager:s,selectIds:p,activeTextId:n,editors:i}):null},[t==null?void 0:t.selectIds,t==null?void 0:t.x,t==null?void 0:t.y,t==null?void 0:t.w,t==null?void 0:t.h,i,s,n]),u=g.useMemo(()=>e===R.None&&P.isNumber(t==null?void 0:t.x)&&P.isNumber(t==null?void 0:t.y)&&P.isNumber(t==null?void 0:t.w)&&P.isNumber(t==null?void 0:t.h)?g.createElement("div",{className:Tt.FloatBarBtn,style:{left:t==null?void 0:t.x,top:t==null?void 0:t.y,width:t.w,height:t.h}},g.createElement(Li,{position:{x:t.x,y:t.y},textOpt:t==null?void 0:t.textOpt,noLayer:t==null?void 0:t.isLocked})):null,[t==null?void 0:t.x,t==null?void 0:t.y,t==null?void 0:t.w,t==null?void 0:t.h,t==null?void 0:t.textOpt,t==null?void 0:t.isLocked,e]);return g.createElement("div",{className:Tt.FloatBar,onMouseOver:()=>{s==null||s.control.worker.blurCursor(s.viewId)}},g.createElement(QM,{ref:o},g.createElement(g.Fragment,null,h)),g.createElement(BM,{onClickHandle:p=>{if(s&&(i!=null&&i.size)){const f=s.getPoint(p.nativeEvent);f&&s.control.textEditorManager.computeTextActive(f,s.viewId)}}}),a,c,l,u)}),$M=g.memo(VM,(r,o)=>!!P.isEqual(r,o)),GM="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAYISURBVHgB7ZpNSCtXFIBPEuvz+dMGpYUKD/sWFX+Qti6kK7Hqpm6e9q0rIoIUFUShPLV10VZx4+JZqa9v20LBhdq9fyBUCtKNPH8qYl2IOw3G38Rkek4y15y5uTOZJDOWggcOSSYzN/ebc+45554JwIM8iBCPyTEP+86T4vyMfsRN4b+nQTKIJp0vzuGvlpID7os8EQNEIBD4oKio6Bm9DwaDv/v9/n/076JgbtWUYPchwrW8qD7UnOvr6wFNkpubm+/wu7f0c7y6mrnlvQufxB0Iau7V1dX3BDA/P6/V1dVpzc3N2uLiIofK1c8VYHys/wRKBUN3/hGHqaysNOjc3FwMis6hc0FtLTHuvYLxCCZgci8uLn4wg5Gh6Fy8Jk+/NkcCAlAAuUkoW4g0B+d5tLS05O/r67O8eGxsDNra2uDy8nKsoKCAwCIQDxQa0yTxgrvCYXyTk5Ml+Orf2dlJeeHIyAigFSE/P38ELfUNqNdSkjgF5FF89jL1TU1NlQwODl5gZPujp6cHWltbUw7Koc7Pz8mkZpHPFeFrJuZeqLnoMoPoZqe0JjDP/IZgnyLUG/o8NDRkuo5Ua2pjY6MC4oFCFf1cA0oKzRSOp6enRfTaGh0d/QxBt+1CUVgnOTs7+xrHfQzGyOcKkK3QTJMnQffZ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ce09iFHo+GrnmGltltb2//E4wVAN82y7vOjKOZXSBhJdHNiT3TYWD8OY2PTUJkdd7MkJMnT5wZVQF2RFX6yBMUdzPMvvfqxz3sXHF+GNT9ANXit/10O1sgHkZvdQAOKvs9B5L7ARELGAAXLSTvM8QExTE+YbHe+HURhZp1aRyF4CJXClbbWwGketgkW9VsY+YaiBCVhfgE+XvxRwgZSM4jUVCDZFQ9pytmXR8hUTB2gnidx4XffVWydN0yQjwmx/jkAZJBrIBI5J7ZvQGZWUgVSuU/EqmOAzicKNMVu816DdRWUV1/7xAP8n+SfwF3Du3NF2sYhwAAAABJRU5ErkJggg==",ZM="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='40px'%20height='40px'%20viewBox='0%200%2040%2040'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3c!--%20Generator:%20Sketch%2060.1%20(88133)%20-%20https://sketch.com%20--%3e%3ctitle%3eshape-cursor%3c/title%3e%3cdesc%3eCreated%20with%20Sketch.%3c/desc%3e%3cdefs%3e%3cpath%20d='M20,21.5%20C20.2454599,21.5%2020.4496084,21.6768752%2020.4919443,21.9101244%20L20.5,22%20L20.5,27%20C20.5,27.2761424%2020.2761424,27.5%2020,27.5%20C19.7545401,27.5%2019.5503916,27.3231248%2019.5080557,27.0898756%20L19.5,27%20L19.5,22%20C19.5,21.7238576%2019.7238576,21.5%2020,21.5%20Z%20M27,19.5%20C27.2761424,19.5%2027.5,19.7238576%2027.5,20%20C27.5,20.2454599%2027.3231248,20.4496084%2027.0898756,20.4919443%20L27,20.5%20L22,20.5%20C21.7238576,20.5%2021.5,20.2761424%2021.5,20%20C21.5,19.7545401%2021.6768752,19.5503916%2021.9101244,19.5080557%20L22,19.5%20L27,19.5%20Z%20M18,19.5%20C18.2761424,19.5%2018.5,19.7238576%2018.5,20%20C18.5,20.2454599%2018.3231248,20.4496084%2018.0898756,20.4919443%20L18,20.5%20L13,20.5%20C12.7238576,20.5%2012.5,20.2761424%2012.5,20%20C12.5,19.7545401%2012.6768752,19.5503916%2012.9101244,19.5080557%20L13,19.5%20L18,19.5%20Z%20M20,12.5%20C20.2454599,12.5%2020.4496084,12.6768752%2020.4919443,12.9101244%20L20.5,13%20L20.5,18%20C20.5,18.2761424%2020.2761424,18.5%2020,18.5%20C19.7545401,18.5%2019.5503916,18.3231248%2019.5080557,18.0898756%20L19.5,18%20L19.5,13%20C19.5,12.7238576%2019.7238576,12.5%2020,12.5%20Z'%20id='path-1'%3e%3c/path%3e%3cfilter%20x='-64.6%25'%20y='-59.5%25'%20width='229.3%25'%20height='246.1%25'%20filterUnits='objectBoundingBox'%20id='filter-2'%3e%3cfeMorphology%20radius='1'%20operator='dilate'%20in='SourceAlpha'%20result='shadowSpreadOuter1'%3e%3c/feMorphology%3e%3cfeOffset%20dx='0'%20dy='2'%20in='shadowSpreadOuter1'%20result='shadowOffsetOuter1'%3e%3c/feOffset%3e%3cfeGaussianBlur%20stdDeviation='3'%20in='shadowOffsetOuter1'%20result='shadowBlurOuter1'%3e%3c/feGaussianBlur%3e%3cfeComposite%20in='shadowBlurOuter1'%20in2='SourceAlpha'%20operator='out'%20result='shadowBlurOuter1'%3e%3c/feComposite%3e%3cfeColorMatrix%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200.16%200'%20type='matrix'%20in='shadowBlurOuter1'%3e%3c/feColorMatrix%3e%3c/filter%3e%3c/defs%3e%3cg%20id='页面-4'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cg%20id='Whiteboard-Guidelines'%20transform='translate(-344.000000,%20-751.000000)'%3e%3cg%20id='shape-cursor'%20transform='translate(344.000000,%20751.000000)'%3e%3crect%20id='矩形备份-44'%20fill='%23FFFFFF'%20opacity='0.01'%20x='0'%20y='0'%20width='40'%20height='40'%20rx='2'%3e%3c/rect%3e%3cg%20id='形状结合'%20fill-rule='nonzero'%3e%3cuse%20fill='black'%20fill-opacity='1'%20filter='url(%23filter-2)'%20xlink:href='%23path-1'%3e%3c/use%3e%3cpath%20stroke='%23FFFFFF'%20stroke-width='1'%20d='M20,21%20C20.4854103,21%2020.898085,21.3479993%2020.9899479,21.8654877%20L21,22%20L21,27%20C21,27.5522847%2020.5522847,28%2020,28%20C19.5145897,28%2019.101915,27.6520007%2019.0100521,27.1345123%20L19,27%20L19,22%20C19,21.4477153%2019.4477153,21%2020,21%20Z%20M27,19%20C27.5522847,19%2028,19.4477153%2028,20%20C28,20.4854103%2027.6520007,20.898085%2027.1345123,20.9899479%20L27,21%20L22,21%20C21.4477153,21%2021,20.5522847%2021,20%20C21,19.5145897%2021.3479993,19.101915%2021.8654877,19.0100521%20L22,19%20L27,19%20Z%20M18,19%20C18.5522847,19%2019,19.4477153%2019,20%20C19,20.4854103%2018.6520007,20.898085%2018.1345123,20.9899479%20L18,21%20L13,21%20C12.4477153,21%2012,20.5522847%2012,20%20C12,19.5145897%2012.3479993,19.101915%2012.8654877,19.0100521%20L13,19%20L18,19%20Z%20M20,12%20C20.4854103,12%2020.898085,12.3479993%2020.9899479,12.8654877%20L21,13%20L21,18%20C21,18.5522847%2020.5522847,19%2020,19%20C19.5145897,19%2019.101915,18.6520007%2019.0100521,18.1345123%20L19,18%20L19,13%20C19,12.4477153%2019.4477153,12%2020,12%20Z'%20fill='%23212324'%20fill-rule='evenodd'%3e%3c/path%3e%3c/g%3e%3crect%20id='矩形'%20fill='%23FFFFFF'%20x='18.5'%20y='17'%20width='3'%20height='6'%3e%3c/rect%3e%3crect%20id='矩形'%20fill='%23FFFFFF'%20x='17'%20y='18.5'%20width='6'%20height='3'%3e%3c/rect%3e%3cpath%20d='M20,21.5%20C20.2454599,21.5%2020.4496084,21.6768752%2020.4919443,21.9101244%20L20.5,22%20L20.5,27%20C20.5,27.2761424%2020.2761424,27.5%2020,27.5%20C19.7545401,27.5%2019.5503916,27.3231248%2019.5080557,27.0898756%20L19.5,27%20L19.5,22%20C19.5,21.7238576%2019.7238576,21.5%2020,21.5%20Z%20M27,19.5%20C27.2761424,19.5%2027.5,19.7238576%2027.5,20%20C27.5,20.2454599%2027.3231248,20.4496084%2027.0898756,20.4919443%20L27,20.5%20L22,20.5%20C21.7238576,20.5%2021.5,20.2761424%2021.5,20%20C21.5,19.7545401%2021.6768752,19.5503916%2021.9101244,19.5080557%20L22,19.5%20L27,19.5%20Z%20M18,19.5%20C18.2761424,19.5%2018.5,19.7238576%2018.5,20%20C18.5,20.2454599%2018.3231248,20.4496084%2018.0898756,20.4919443%20L18,20.5%20L13,20.5%20C12.7238576,20.5%2012.5,20.2761424%2012.5,20%20C12.5,19.7545401%2012.6768752,19.5503916%2012.9101244,19.5080557%20L13,19.5%20L18,19.5%20Z%20M20,12.5%20C20.2454599,12.5%2020.4496084,12.6768752%2020.4919443,12.9101244%20L20.5,13%20L20.5,18%20C20.5,18.2761424%2020.2761424,18.5%2020,18.5%20C19.7545401,18.5%2019.5503916,18.3231248%2019.5080557,18.0898756%20L19.5,18%20L19.5,13%20C19.5,12.7238576%2019.7238576,12.5%2020,12.5%20Z'%20id='形状结合'%20fill='%23212324'%20fill-rule='nonzero'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",qM="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='47px'%20height='40px'%20viewBox='0%200%2047%2040'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3c!--%20Generator:%20Sketch%2060.1%20(88133)%20-%20https://sketch.com%20--%3e%3ctitle%3etext-cursor%3c/title%3e%3cdesc%3eCreated%20with%20Sketch.%3c/desc%3e%3cdefs%3e%3cpath%20d='M16,26.5%20C15.7238576,26.5%2015.5,26.2761424%2015.5,26%20C15.5,25.7545401%2015.6768752,25.5503916%2015.9101244,25.5080557%20L16,25.5%20L19.5,25.5%20L19.5,14.5%20L16,14.5%20C15.7238576,14.5%2015.5,14.2761424%2015.5,14%20C15.5,13.7545401%2015.6768752,13.5503916%2015.9101244,13.5080557%20L16,13.5%20L24,13.5%20C24.2761424,13.5%2024.5,13.7238576%2024.5,14%20C24.5,14.2454599%2024.3231248,14.4496084%2024.0898756,14.4919443%20L24,14.5%20L20.5,14.5%20L20.5,25.5%20L24,25.5%20C24.2761424,25.5%2024.5,25.7238576%2024.5,26%20C24.5,26.2454599%2024.3231248,26.4496084%2024.0898756,26.4919443%20L24,26.5%20L16,26.5%20Z'%20id='path-1'%3e%3c/path%3e%3cfilter%20x='-284.0%25'%20y='-81.5%25'%20width='668.1%25'%20height='293.9%25'%20filterUnits='objectBoundingBox'%20id='filter-2'%3e%3cfeMorphology%20radius='1'%20operator='dilate'%20in='SourceAlpha'%20result='shadowSpreadOuter1'%3e%3c/feMorphology%3e%3cfeOffset%20dx='0'%20dy='2'%20in='shadowSpreadOuter1'%20result='shadowOffsetOuter1'%3e%3c/feOffset%3e%3cfeGaussianBlur%20stdDeviation='3'%20in='shadowOffsetOuter1'%20result='shadowBlurOuter1'%3e%3c/feGaussianBlur%3e%3cfeComposite%20in='shadowBlurOuter1'%20in2='SourceAlpha'%20operator='out'%20result='shadowBlurOuter1'%3e%3c/feComposite%3e%3cfeColorMatrix%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200.16%200'%20type='matrix'%20in='shadowBlurOuter1'%3e%3c/feColorMatrix%3e%3c/filter%3e%3c/defs%3e%3cg%20id='页面-4'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cg%20id='Whiteboard-Guidelines'%20transform='translate(-388.000000,%20-672.000000)'%3e%3cg%20id='text-cursor'%20transform='translate(392.000000,%20672.000000)'%3e%3crect%20id='矩形备份-40'%20fill='%23FFFFFF'%20opacity='0.01'%20x='0'%20y='0'%20width='40'%20height='40'%20rx='2'%3e%3c/rect%3e%3cg%20id='形状结合'%20fill-rule='nonzero'%3e%3cuse%20fill='black'%20fill-opacity='1'%20filter='url(%23filter-2)'%20xlink:href='%23path-1'%3e%3c/use%3e%3cpath%20stroke='%23FFFFFF'%20stroke-width='1'%20d='M19,25%20L19,15%20L16,15%20C15.4477153,15%2015,14.5522847%2015,14%20C15,13.5145897%2015.3479993,13.101915%2015.8654877,13.0100521%20L16,13%20L24,13%20C24.5522847,13%2025,13.4477153%2025,14%20C25,14.4854103%2024.6520007,14.898085%2024.1345123,14.9899479%20L24,15%20L21,15%20L21,25%20L24,25%20C24.5522847,25%2025,25.4477153%2025,26%20C25,26.4854103%2024.6520007,26.898085%2024.1345123,26.9899479%20L24,27%20L16,27%20C15.4477153,27%2015,26.5522847%2015,26%20C15,25.5145897%2015.3479993,25.101915%2015.8654877,25.0100521%20L16,25%20L19,25%20Z'%20fill='%23212324'%20fill-rule='evenodd'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",JM="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAgrSURBVHgB7ZprTBRXFIDP7gIt8lQppTwE5V0KaAn6o1pqNGkDDTEmTUhsgKRp+gNJw68CFkLbVC2QkDS+gD8KJdWmARvbFBNNWpuIRGPFWBXQRMPDqIki+KLATs+ZnTvcvXtnX8w2beJJToaduTP3fHPOPffcOwC8kP+2WCDwIvahGFxTuN8KmNSZmULPNjLeqF9F8rdPkIEGEn+r+vjx46LQ0NA8/Dsader58+e/h4WFDWntFO7ot6fMFAt3JLWi2lCDpqamCux2+2+KROj82NhYGrXT2lu5Z/DP/deFByElA4Pv3LlTiHY/nJ6eVnbv3q1s2bJFyc7OVrZu3arU1dUp4+PjxPUQoT+g9tp9PkMFgpo9kxljHRoaWp2Xl3duYmIiurKyEvDoclNCQgIcPnxYPc7MzHwcGRnZhaft4Ag7O9fUbRhaITCie4lgcnNzT7q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A62INwPV/E3wWdx5inmBHuwChCBD6R2JwHge80TIQRQLjt7e8DTkGZgfX8cUMZTDAteFDkveaIlzjX9ySQs8X18r2t2VHUURPKoICmDR+eCO9aSdmOIub3/w9RgpgUpiJhvraXpa6jZKHGEqyusw0GLFzX+5RhN/8kYnMSNMMfyH/V/kHST6OYVElTPAAAAAASUVORK5CYII=";class XM extends g.Component{constructor(t){super(t);M(this,"renderAvatar",t=>{var s;const e=`rgb(${t.memberState.strokeColor[0]}, ${t.memberState.strokeColor[1]}, ${t.memberState.strokeColor[2]})`;if(this.detectAvatar(t)){const i=this.getCursorName(t);return g.createElement("img",{className:"cursor-selector-avatar",style:{width:i?19:28,height:i?19:28,position:i?"initial":"absolute",borderColor:i?"white":e,marginRight:i?4:0},src:(s=t.payload)==null?void 0:s.avatar,alt:"avatar"})}else return null});M(this,"getOpacity",t=>{const e=this.getCursorName(t),s=this.detectAvatar(t);return e===void 0&&s===void 0?0:1});M(this,"getCursorName",t=>{if(t.payload)return t.payload.nickName||t.payload.cursorName||t.payload.uid});M(this,"getThemeClass",t=>t.payload&&t.payload.theme?"cursor-inner-mellow":"cursor-inner");M(this,"getCursorBackgroundColor",t=>{const e=this.getCursorName(t);return t.payload&&t.payload.cursorBackgroundColor?t.payload.cursorBackgroundColor:e?`rgb(${t.memberState.strokeColor[0]}, ${t.memberState.strokeColor[1]}, ${t.memberState.strokeColor[2]})`:void 0});M(this,"getCursorTextColor",t=>t.payload&&t.payload.cursorTextColor?t.payload.cursorTextColor:"#FFFFFF");M(this,"getCursorTagBackgroundColor",t=>t.payload&&t.payload.cursorTagBackgroundColor?t.payload.cursorTagBackgroundColor:this.getCursorBackgroundColor(t));M(this,"detectAvatar",t=>!!(t.payload&&t.payload.avatar));M(this,"renderTag",t=>{if(t.payload&&t.payload.cursorTagName)return g.createElement("span",{className:"cursor-tag-name",style:{backgroundColor:this.getCursorTagBackgroundColor(t)}},t.payload.cursorTagName)})}render(){const{roomMember:t}=this.props,e=this.getCursorName(t);switch(t.memberState.currentApplianceName){case et.pencil:return g.createElement("div",{className:"cursor-box"},g.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -90%)",marginLeft:"10px"}},g.createElement("div",{className:"cursor-name"},g.createElement("div",{style:{opacity:this.getOpacity(t),backgroundColor:this.getCursorBackgroundColor(t),color:this.getCursorTextColor(t)},className:this.getThemeClass(t)},this.renderAvatar(t),e,this.renderTag(t))),g.createElement("div",null,g.createElement("img",{className:"cursor-pencil-image",src:GM,alt:"pencilCursor"}))));case et.eraser:case et.pencilEraser:return g.createElement("div",{className:"cursor-box"},g.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -90%)",marginLeft:"0px"}},g.createElement("div",{className:"cursor-name"},g.createElement("div",{style:{opacity:this.getOpacity(t),backgroundColor:this.getCursorBackgroundColor(t),color:this.getCursorTextColor(t)},className:this.getThemeClass(t)},this.renderAvatar(t),e,this.renderTag(t))),g.createElement("div",null,g.createElement("img",{className:"cursor-pencil-image",src:JM,alt:"pencilEraser"}))));case et.text:return g.createElement("div",{className:"cursor-box"},g.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -65%)",marginLeft:"0px"}},g.createElement("div",{className:"cursor-name"},g.createElement("div",{style:{opacity:this.getOpacity(t),backgroundColor:this.getCursorBackgroundColor(t),color:this.getCursorTextColor(t)},className:this.getThemeClass(t)},this.renderAvatar(t),e,this.renderTag(t))),g.createElement("div",null,g.createElement("img",{className:"cursor-arrow-image",src:qM,alt:"textCursor"}))));case et.rectangle:case et.arrow:case et.straight:case et.shape:case et.ellipse:return g.createElement("div",{className:"cursor-box"},g.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -65%)",marginLeft:"0px"}},g.createElement("div",{className:"cursor-name"},g.createElement("div",{style:{opacity:this.getOpacity(t),backgroundColor:this.getCursorBackgroundColor(t),color:this.getCursorTextColor(t)},className:this.getThemeClass(t)},this.renderAvatar(t),e,this.renderTag(t))),g.createElement("div",null,g.createElement("img",{className:"cursor-arrow-image",src:ZM,alt:"shapeCursor"}))));default:return null}}}const KM=r=>{const{className:o,info:t}=r,{roomMember:e,...s}=t||{};return g.createElement("div",{className:`${o}`,style:s?{transform:`translate(${s.x}px, ${s.y}px)`}:{display:"none"}},e&&g.createElement(XM,{roomMember:e}))},_M=r=>{const{className:o,manager:t}=r,[e,s]=g.useState();g.useEffect(()=>(t.internalMsgEmitter.on([Z.Cursor,t.viewId],i),()=>{t.internalMsgEmitter.off([Z.Cursor,t.viewId],i)}),[t]);function i(a){s(a)}return g.useMemo(()=>{if(e!=null&&e.length){const a=e.map(c=>{var l;return c.roomMember?g.createElement(KM,{key:(l=c.roomMember)==null?void 0:l.memberId,className:o,info:c}):null});return g.createElement(g.Fragment,null,a)}return null},[e])},Mt=g.createContext({mananger:void 0,floatBarColors:[],floatBarData:void 0,dpr:1,angle:0,operationType:R.None,scale:[1,1],setAngle:()=>{},setOperationType:()=>{},setFloatBarData:()=>{}});class Ho extends g.Component{constructor(t){var e;super(t);M(this,"setAngle",t=>{this.setState({angle:t})});M(this,"setOperationType",t=>{this.setState({operationType:t})});this.state={floatBarData:void 0,showFloatBar:!1,dpr:1,angle:0,operationType:R.None,scale:[1,1],editors:this.editors,activeTextId:(e=this.props.mananger.control.textEditorManager)==null?void 0:e.activeId}}get editors(){return Vt(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(){}showFloatBar(t,e){const s=t&&e&&{...this.state.floatBarData,...e}||void 0;this.setState({showFloatBar:t,floatBarData:s,angle:0})}setActiveTextEditor(t){this.setState({activeTextId:t,editors:this.editors})}setFloatBarData(t){this.state.floatBarData&&this.setState({floatBarData:{...this.state.floatBarData,...t}})}render(){var e,s,i,n,a,c,l;const t=!!((s=(e=this.props.mananger.control)==null?void 0:e.room)!=null&&s.floatBarOptions);return g.createElement("div",{className:Tt.Container},!this.props.mananger.control.hasOffscreenCanvas()&&g.createElement("div",{className:Tt.CanvasBox,ref:this.props.refs.canvasContainerRef})||g.createElement("div",{className:Tt.CanvasBox,onMouseDown:h=>{h.cancelable&&h.preventDefault(),h.stopPropagation()},onTouchStart:h=>{h.stopPropagation()},onMouseMove:h=>{this.props.mananger.cursorMouseMove(h)}},g.createElement("canvas",{id:"bgCanvas",ref:this.props.refs.canvasBgRef,style:{width:"100%",height:"100%"}}),g.createElement("canvas",{id:"serviceCanvas",className:Tt.FloatCanvas,ref:this.props.refs.canvasServiceFloatRef,style:{width:"100%",height:"100%"}}),g.createElement("canvas",{id:"localCanvas",className:Tt.FloatCanvas,ref:this.props.refs.canvasFloatRef,style:{width:"100%",height:"100%"}}),g.createElement("div",{id:"subLocalCanvas",className:Tt.CanvasBoxSub,ref:this.props.refs.subLocalCanvasContainerRef}),g.createElement("canvas",{id:"topCanvas",className:Tt.TopFloatCanvas,ref:this.props.refs.canvasTopRef,style:{width:"100%",height:"100%"}})),!this.props.mananger.control.hasOffscreenCanvas()&&this.props.refs.snapshotContainerRef&&g.createElement("div",{className:Tt.SnapshotBox,ref:this.props.refs.snapshotContainerRef})||null,g.createElement(Mt.Provider,{value:{mananger:this.props.mananger,floatBarColors:t&&((a=(n=(i=this.props.mananger.control)==null?void 0:i.room)==null?void 0:n.floatBarOptions)==null?void 0:a.colors)||[],floatBarData:this.state.floatBarData,dpr:this.state.dpr,angle:this.state.angle,operationType:this.state.operationType,scale:this.state.scale,setAngle:this.setAngle.bind(this),setOperationType:this.setOperationType.bind(this),setFloatBarData:this.setFloatBarData.bind(this)}},this.state.showFloatBar&&g.createElement($M,{ref:this.props.refs.floatBarRef,editors:this.state.editors,activeTextId:this.state.activeTextId})||null,((c=this.state.editors)==null?void 0:c.size)&&g.createElement(EM,{className:Tt.TextEditorContainer,showFloatBtns:t,manager:this.props.mananger,selectIds:((l=this.state.floatBarData)==null?void 0:l.selectIds)||[],editors:this.state.editors,activeTextId:this.state.activeTextId})||null),g.createElement(_M,{className:Tt.CursorBox,manager:this.props.mananger}))}}class ty extends zi{constructor(t,e){super(t,e);M(this,"width",1e3);M(this,"height",1e3);M(this,"dpr",1);M(this,"vDom");M(this,"eventTragetElement");M(this,"snapshotContainerRef");M(this,"canvasContainerRef",g.createRef());M(this,"subLocalCanvasContainerRef",g.createRef());M(this,"canvasTopRef",g.createRef());M(this,"canvasServiceFloatRef",g.createRef());M(this,"canvasFloatRef",g.createRef());M(this,"canvasBgRef",g.createRef());M(this,"floatBarRef",g.createRef());M(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas()||(this.snapshotContainerRef=g.createRef())}setCanvassStyle(){if(this.eventTragetElement){const t=this.eventTragetElement.offsetWidth||this.width,e=this.eventTragetElement.offsetHeight||this.height;t&&e&&this.canvasContainerRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=qt(),this.width=t,this.height=e,this.canvasContainerRef.current.style.width=`${t}px`,this.canvasContainerRef.current.style.height=`${e}px`),t&&e&&this.snapshotContainerRef&&this.snapshotContainerRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=qt(),this.width=t,this.height=e),t&&e&&this.canvasBgRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=qt(this.canvasBgRef.current.getContext("2d")),this.width=t,this.height=e,this.canvasBgRef.current.width=t*this.dpr,this.canvasBgRef.current.height=e*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=t*this.dpr,this.canvasFloatRef.current.height=e*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=t*this.dpr,this.canvasServiceFloatRef.current.height=e*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=t*this.dpr,this.canvasTopRef.current.height=e*this.dpr))}}destroy(){if(super.destroy(),this.eventTragetElement){const t=this.eventTragetElement.parentElement;if(t){const e=t.querySelectorAll(".appliance-plugin-main-view-displayer");for(const s of e)s.remove()}}}createMainViewDisplayer(t){const e=document.createElement("div");return e.className="appliance-plugin-main-view-displayer",t.appendChild(e),this.eventTragetElement=t.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),Lo.render(g.createElement(Ho,{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 ey extends Qg{constructor(t,e,s){super(t,e,s);M(this,"dpr",1);M(this,"width",1e3);M(this,"height",1e3);M(this,"vDom");M(this,"eventTragetElement");M(this,"canvasContainerRef",g.createRef());M(this,"subLocalCanvasContainerRef",g.createRef());M(this,"canvasTopRef",g.createRef());M(this,"canvasServiceFloatRef",g.createRef());M(this,"canvasFloatRef",g.createRef());M(this,"canvasBgRef",g.createRef());M(this,"floatBarRef",g.createRef());M(this,"containerOffset",{x:0,y:0})}setCanvassStyle(){if(this.eventTragetElement){if(this.canvasContainerRef.current){const t=this.eventTragetElement.offsetWidth||this.width,e=this.eventTragetElement.offsetHeight||this.height;t&&e&&(t!==this.width||e!==this.height)&&(this.width=t,this.height=e,this.dpr=qt(),this.canvasContainerRef.current.style.width=`${t}px`,this.canvasContainerRef.current.style.height=`${e}px`)}if(this.canvasBgRef.current){this.dpr=qt(this.canvasBgRef.current.getContext("2d"));const t=this.eventTragetElement.offsetWidth||this.width,e=this.eventTragetElement.offsetHeight||this.height;t&&e&&(t!==this.width||e!==this.height)&&(this.width=t,this.height=e,this.canvasBgRef.current.width=t*this.dpr,this.canvasBgRef.current.height=e*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=t*this.dpr,this.canvasFloatRef.current.height=e*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=t*this.dpr,this.canvasServiceFloatRef.current.height=e*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=t*this.dpr,this.canvasTopRef.current.height=e*this.dpr))}}}createAppViewDisplayer(t,e){const s=document.createElement("div");return s.className="appliance-plugin-app-view-displayer",e.appendChild(s),this.eventTragetElement=e.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),Lo.render(g.createElement(Ho,{viewId:t,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef}}),s),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement),this}}class At extends ge{constructor(t){super(t);M(this,"focuedViewId");M(this,"focuedView");M(this,"control");M(this,"tmpFocusedViewId");M(this,"checkScaleTimer");M(this,"onMainViewRelease",async t=>{this.control.textEditorManager.clear(yt,!0),this.mainViewDestroy(t),await new Promise(s=>{setTimeout(()=>{s(!0)},0)}),this.onMainViewMounted(t);const e=this.control.getSnapshootData("memberState");this.control.room&&this.control.onMemberChange(e),this.control.clearSnapshootData()});M(this,"mainViewDestroy",t=>{var e;if(this.mainView&&this.mainView.displayer){this.mainView.displayer.destroy();const s=t.divElement;if(s){const i=s.getElementsByClassName("appliance-plugin-main-view-displayer");for(const n of i)n.remove()}if(this.mainView.container&&s!==this.mainView.container){const i=this.mainView.container.getElementsByClassName("appliance-plugin-main-view-displayer");for(const n of i)n.remove()}(e=this.control.worker)==null||e.destroyViewWorker(this.mainView.id,!0),this.mainView.displayer.destroy(),this.mainView=void 0}});M(this,"onMainViewMounted",t=>{const e=t.divElement;if(!e||!t.focusScenePath||!(t.focusScenePath||t.scenePath))return;const i=new ty(this.control,mt.InternalMsgEmitter),n=t.size.width||i.width,a=t.size.height||i.height,l={dpr:i.dpr,originalPoint:[n/2,a/2],offscreenCanvasOpt:{...At.defaultScreenCanvasOpt,width:n,height:a},layerOpt:{...At.defaultLayerOpt,width:n,height:a},cameraOpt:{...At.defaultCameraOpt,width:n,height:a}},{scale:h,...u}=t.camera;l.cameraOpt={...l.cameraOpt,...u,scale:h===1/0?1:h},this.focuedViewId=yt,this.createMianView({id:yt,container:e,displayer:i,focusScenePath:t.focusScenePath,cameraOpt:l.cameraOpt,viewData:t}),this.focuedView=this.mainView,i.createMainViewDisplayer(e),t.callbacks.on("onSizeUpdated",this.onMainViewSizeUpdated),t.callbacks.on("onCameraUpdated",this.onMainViewCameraUpdated),t.callbacks.on("onActiveHotkey",this.onActiveHotkeyChange.bind(this))});M(this,"onMainViewSizeUpdated",async()=>{await new Promise(t=>{setTimeout(()=>{t(!0)},0)}),this.mainView&&this.mainView.viewData&&this.updateMainViewCamera()});M(this,"onMainViewCameraUpdated",async()=>{await new Promise(t=>{setTimeout(()=>{t(!0)},0)}),this.updateMainViewCamera()});M(this,"updateMainViewCamera",()=>{if(this.mainView&&this.mainView.viewData){const t=this.mainView.viewData.camera,e=this.mainView.cameraOpt;if(e){const s=e.width,i=e.height,{width:n,height:a}=this.mainView.viewData.size;(n!==s||a!==i)&&this.mainView.displayer.updateSize();const c=t.scale===1/0?1:t.scale,l=t.centerX||0,h=t.centerY||0,u={...e,scale:c,centerX:l,centerY:h,width:n,height:a};P.isEqual(e,u)||(this.mainView.cameraOpt=u),this.checkScaleTimer&&t.scale==1/0&&(clearTimeout(this.checkScaleTimer),this.checkScaleTimer=void 0),!this.checkScaleTimer&&t.scale===1/0&&this.mainView.viewData&&this.mainView.viewData.camera.scale===1/0&&(this.checkScaleTimer=setTimeout(()=>{var d,p;(p=(d=this.mainView)==null?void 0:d.viewData)==null||p.moveCamera({scale:c,centerX:l,centerY:h,animationMode:"immediately"}),this.checkScaleTimer=void 0},500))}}});M(this,"onAppViewMounted",async t=>{var d;const{appId:e,view:s}=t,i=s.divElement;if(!i||!s.focusScenePath)return;const n=this.appViews.get(e);if(n&&n.displayer){let p=i.getElementsByClassName("appliance-plugin-app-view-displayer");for(const f of p)f.remove();if(n.container&&n.container!==i){p=n.container.getElementsByClassName("appliance-plugin-app-view-displayer");for(const f of p)f.remove()}this.destroyAppView(t.appId,!0),(d=this.control.worker)==null||d.destroyViewWorker(e,!0),await new Promise(f=>{setTimeout(()=>{f(!0)},0)})}const a=new ey(e,this.control,mt.InternalMsgEmitter),c=s.size.width||a.width,l=s.size.height||a.height,u={dpr:a.dpr,originalPoint:[c/2,l/2],offscreenCanvasOpt:{...At.defaultScreenCanvasOpt,width:c,height:l},layerOpt:{...At.defaultLayerOpt,width:c,height:l},cameraOpt:{...At.defaultCameraOpt,...s.camera,width:c,height:l}};if(this.createAppView({id:e,container:i,displayer:a,cameraOpt:u.cameraOpt,focusScenePath:s.focusScenePath,viewData:s}),a.createAppViewDisplayer(e,i),s.callbacks.on("onSizeUpdated",this.onAppViewSizeUpdated.bind(this,e)),s.callbacks.on("onCameraUpdated",this.onAppViewCameraUpdated.bind(this,e)),s.callbacks.on("onActiveHotkey",this.onActiveHotkeyChange.bind(this)),this.tmpFocusedViewId===e){const p=this.control.worker.getLocalWorkViewId();p&&p!==e?this.setFocuedViewId(p):this.setFocuedViewId(e),this.tmpFocusedViewId=void 0}setTimeout(()=>{this.onAppViewCameraUpdated(e)},0)});M(this,"onAppViewSizeUpdated",async t=>{await new Promise(s=>{setTimeout(()=>{s(!0)},0)});const e=this.appViews.get(t);e&&e.viewData&&this.updateAppCamera(t)});M(this,"onAppViewCameraUpdated",async t=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.updateAppCamera(t)});M(this,"updateAppCamera",t=>{const e=this.appViews.get(t);if(e&&e.viewData){const s=e.viewData.camera,i=e.cameraOpt;if(i){const{width:n,height:a}=e.viewData.size,c=i.width,l=i.height;(n!==c||a!==l)&&e.displayer.updateSize();const h=s.scale===1/0?1:s.scale,u=s.centerX||0,d=s.centerY||0,p={...i,scale:h,centerX:u,centerY:d,width:n,height:a};P.isEqual(p,i)||(e.cameraOpt=p)}}});this.control=t.control}getViewInitData(t){const e=this.getView(t);if(e){const{width:s,height:i,dpr:n}=e.displayer,a={dpr:n,originalPoint:[s/2,i/2],offscreenCanvasOpt:{...At.defaultScreenCanvasOpt,width:s,height:i},layerOpt:{...At.defaultLayerOpt,width:s,height:i},cameraOpt:{...At.defaultCameraOpt,width:s,height:i}};if(e.viewData){const{scale:c,...l}=e.viewData.camera;a.cameraOpt={...a.cameraOpt,...l,scale:c===1/0?1:c}}return a}}async mountView(t){var s,i;const e=this.getView(t);if(e){t===((s=this.mainView)==null?void 0:s.id)&&(this.control.cursor.activeCollector(),await this.control.activeWorker());const n=this.getViewInitData(t);if(n&&((i=this.control.worker)==null||i.createViewWorker(t,n)),e.focusScenePath&&this.control.collector){if(this.control.collector.authStorage){const{renderAuth:a,writable:c,readOnly:l}=this.control.collector.authStorage;if(this.control.renderControl.syncWriteable(c,l),a){const h=a[t];if(h){const{render:u,hide:d,clear:p}=h;this.control.renderControl.syncRenderUids(t,u,d,p);return}}}this.control.worker.pullServiceData(t,e.focusScenePath,{isAsync:!0,useAnimation:!1})}}}listenerWindowManager(t){t.emitter.on("focusedChange",e=>{const s=e||yt;if(this.focuedViewId!==s)if(this.getView(s)){const n=this.control.worker.getLocalWorkViewId();n&&n!==s?this.setFocuedViewId(n):this.setFocuedViewId(s)}else this.tmpFocusedViewId=s}),t.emitter.on("mainViewScenePathChange",e=>{this.control.onSceneChange(e,yt)}),t.emitter.on("onMainViewMounted",this.onMainViewMounted),t.emitter.on("onAppViewMounted",this.onAppViewMounted),t.emitter.on("onMainViewRebind",this.onMainViewRelease),t.emitter.on("onBoxClose",e=>{this.appViews.get(e.appId)&&(this.destroyAppView(e.appId),this.control.worker.destroyViewWorker(e.appId))}),t.emitter.on("onAppScenePathChange",e=>{const{appId:s,view:i}=e;this.control.onSceneChange(i.focusScenePath,s)}),t.emitter.on("appsChange",e=>{for(const s of this.appViews.keys())e.includes(s)||(this.destroyAppView(s),this.control.worker.destroyViewWorker(s,!0))})}onActiveHotkeyChange(t){this.control.hotkeyManager.onActiveHotkey(t)}}class ce extends mt{constructor(t){super(t);M(this,"windowManager");M(this,"viewContainerManager");const e={control:this,internalMsgEmitter:mt.InternalMsgEmitter};this.viewContainerManager=new At(e)}init(){}destroy(){var t,e,s,i;this.roomMember.destroy(),(t=this.collector)==null||t.destroy(),(e=this.worker)==null||e.destroy(),(s=this.viewContainerManager)==null||s.destroy(),(i=this.cursor)==null||i.destroy()}activePlugin(){this.collector&&(this.collector.addAuthStateListener(t=>{t&&Object.keys(t).forEach(e=>{var i;const s=(i=t[e])==null?void 0:i.newValue;this.renderControl.syncRenderUids(e,s==null?void 0:s.render,s==null?void 0:s.hide,s==null?void 0:s.clear)})}),this.collector.addStorageStateListener(t=>{var a,c;if((a=this.collector)!=null&&a.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(yt,!0);return}const{diffView:e,diffScenePath:s,diffData:i}=t,n=new Map;if(e){let l;Object.keys(e).forEach(h=>{var d;const u=e[h];if(u&&!u.newValue)(d=this.worker)==null||d.clearViewScenePath(h,!0),u.oldValue&&(l=u.oldValue);else if(u&&u.newValue){for(const p of Object.keys(u.newValue))this.worker.pullServiceData(h,p,{isAsync:!1,useAnimation:!0});l=u.newValue}if(l)for(const p of Object.values(l)){const f=new Set;for(const I of Object.keys(p))I&&f.add(I);n.set(h,f)}})}if(s){let l;Object.keys(s).forEach(h=>{var d;const u=s[h];if(u&&u.viewId&&!u.newValue?((d=this.worker)==null||d.clearViewScenePath(u.viewId,!0),u.oldValue&&(l=u.oldValue)):u&&u.viewId&&u.newValue&&(this.worker.pullServiceData(u.viewId,h,{isAsync:!1,useAnimation:!0}),l=u.newValue),u!=null&&u.viewId&&l){const p=new Set;for(const f of Object.keys(l))f&&p.add(f),n.set(u.viewId,p)}})}i&&Object.keys(i).forEach(l=>{var u;const h=i[l];if(h){const{viewId:d}=h,p=n.get(d)||new Set;p.add(l),n.set(d,p),(u=this.worker)==null||u.onServiceDerive(l,h)}});for(const[l,h]of n.entries())mt.InternalMsgEmitter.emit("excludeIds",[...h],l)}),this.room&&this.roomMember.onUidChangeHook(t=>{var e,s;if((e=this.collector)!=null&&e.serviceStorage){const i=[];this.viewContainerManager.getAllViews().forEach(n=>{var a;if(n&&n.focusScenePath&&((a=this.collector)!=null&&a.serviceStorage[n.id])&&this.collector.serviceStorage[n.id][n.focusScenePath]){const c=Object.keys(this.collector.serviceStorage[n.id][n.focusScenePath]).filter(l=>{var h;return(h=this.collector)==null?void 0:h.isSelector(l)}).map(l=>({viewId:n.id,scenePath:n.focusScenePath,key:l}));c.length&&i.push(...c)}}),i.forEach(({key:n,viewId:a,scenePath:c})=>{var h,u;const l=(h=this.collector)==null?void 0:h.getUidFromKey(n);l&&!t.online.includes(l)&&((u=this.collector)==null||u.updateValue(n,void 0,{isAfterUpdate:!0,viewId:a,scenePath:c}))})}(s=this.cursor)==null||s.updateRoomMembers(t)}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(t=>{t&&t.focusScenePath&&this.worker.pullServiceData(t.id,t.focusScenePath,{isAsync:!0,useAnimation:!1})}))}async activeWorker(){await this.worker.init()}setWindowManager(t){var e,s,i,n,a;this.windowManager=t,(s=(e=this.windowManager)==null?void 0:e.mainView)!=null&&s.divElement&&this.viewContainerManager.onMainViewMounted(this.windowManager.mainView),(a=(n=(i=this.windowManager.appManager)==null?void 0:i.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 Q=class Q extends st.InvisiblePlugin{constructor(){super(...arguments);M(this,"onPhaseChanged",t=>{var e;t===st.RoomPhase.Reconnecting&&((e=Q.currentManager)==null||e.setSnapshootData())});M(this,"updateRoomWritable",()=>{var t;(t=Q.currentManager)==null||t.onWritableChange(this.displayer.isWritable)});M(this,"roomStateChangeListener",async t=>{var e,s;st.isRoom(this.displayer)&&!this.displayer.isWritable||(t.memberState&&((e=Q.currentManager)==null||e.onMemberChange(t.memberState)),t!=null&&t.roomMembers&&((s=Q.currentManager)==null||s.onRoomMembersChange(t.roomMembers)))})}static async getInstance(t,e){!e.options.cdn.fullWorkerUrl&&!e.options.cdn.subWorkerUrl&&Q.logger.error("[ApplianceMultiPlugin] you must adaptor options cdn fullWorkerUrl and subWorkerUrl");const s=t.displayer,i=s.callbacks.on,n=s.callbacks.off,a=s.callbacks.once,c=t.cleanCurrentScene,l=t.mainView.setMemberState;e!=null&&e.logger&&(Q.logger=e.logger),e.options&&(Q.options={...xt,...e.options});let h=s.getInvisiblePlugin(Q.kind);h||(h=await Q.createApplianceMultiPlugin(s,Q.kind)),s&&h&&Q.createCurrentManager(t,Q.options,h),h&&Q.currentManager&&(Q.currentManager.bindPlugin(h),h.init(s));const u={displayer:s,windowManager:t,currentManager:Q.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,getBoundingRectAsync:async function(p){var y;Q.logger.info("[ApplianceMultiPlugin] getBoundingRectAsync");const f=(t.mainView||s).getBoundingRect(p),I=await((y=Q.currentManager)==null?void 0:y.getBoundingRect(p));return!f.width||!f.height?I:Ti(f,I)},screenshotToCanvasAsync:async function(p,f,I,y,v,m){var b;Q.logger.info("[ApplianceMultiPlugin] screenshotToCanvasAsync");let w=I,N=y,S=v.scale;w>this.maxScreenshotWidth&&(S=this.maxScreenshotWidth/w*S,w=this.maxScreenshotWidth),N>this.maxScreenshotHeight&&(S=Math.min(this.maxScreenshotHeight/N*S,S),N=this.maxScreenshotHeight),v.scale=S;const T=document.createElement("canvas"),x=T.getContext("2d");T.width=w*(m||1),T.height=N*(m||1),x&&((t.mainView||s).screenshotToCanvas(x,f,w,N,v,m),p.drawImage(T,Math.floor((I-w)/2),Math.floor((y-N)/2),w*(m||1),N*(m||1),0,0,w,N),T.remove()),Q.currentManager&&await((b=Q.currentManager)==null?void 0:b.screenshotToCanvas(p,f,w,N,v,Math.floor((I-w)/2),Math.floor((y-N)/2)))},scenePreviewAsync:async function(p,f,I,y,v){Q.logger.info("[ApplianceMultiPlugin] scenePreviewAsync"),(t.mainView||s).scenePreview(p,f,I,y,v);const m=document.createElement("img");m.className="appliance-plugin-fill-scene-snapshot-img",f.append(m),getComputedStyle(f).position||(f.style.position="relative"),Q.currentManager&&await Q.currentManager.scenePreview(p,m)},fillSceneSnapshotAsync:async function(p,f,I,y,v){Q.logger.info("[ApplianceMultiPlugin] fillSceneSnapshotAsync"),f.innerHTML="",(t.mainView||s).fillSceneSnapshot(p,f,I,y,v);const m=I||t.mainView.size.width,w=y||t.mainView.size.height;let N=await this.getBoundingRectAsync(p);N||(N={originX:0,originY:0,width:m,height:w});let S=Math.max(N==null?void 0:N.width,m),T=Math.max(N==null?void 0:N.height,w),x=1;const b=S>m&&Math.min(m/S,x)||x,A=T>w&&Math.min(w/T,x)||x;b<=A?(S=b<1&&m||S,T=Math.floor(T*b)+1,x=b):b>A&&(T=A<1&&w||T,S=Math.floor(S*A)+1,x=A);const O={scale:x,centerX:N.originX+N.width/2,centerY:N.originY+N.height/2},j=document.createElement("canvas"),E=j.getContext("2d");j.width=S,j.height=T,E&&await this.screenshotToCanvasAsync(E,p,S,T,O,devicePixelRatio);const D=document.createElement("img");D.className="appliance-plugin-fill-scene-snapshot-img",D.src=j.toDataURL(),D.onload=()=>{j.remove()},D.onerror=()=>{j.remove(),D.remove()},f.append(D),getComputedStyle(f).position||(f.style.position="relative")},_callbacksOn:function(p,f){Q.logger.info(`[ApplianceMultiPlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&st.isRoom(s)&&s.isWritable?ce.InternalMsgEmitter.on(p,f):i.call(s.callbacks,p,f)},_callbacksOnce:function(p,f){Q.logger.info(`[ApplianceMultiPlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&st.isRoom(s)&&s.isWritable?ce.InternalMsgEmitter.on(p,f):a.call(s.callbacks,p,f)},_callbacksOff:function(p,f){Q.logger.info(`[ApplianceMultiPlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&st.isRoom(s)&&s.isWritable?ce.InternalMsgEmitter.off(p,f):n.call(s.callbacks,p,f)},canRedoSteps(){if(Q.logger.info("[ApplianceMultiPlugin] canRedoSteps"),Q.currentManager&&st.isRoom(s)&&!s.disableSerialization){const p=Q.currentManager.viewContainerManager.focuedView,f=p==null?void 0:p.focusScenePath;if(p&&f)return p.displayer.commiter.redoStack.filter(I=>I.scenePath===f).length}return 0},canUndoSteps(){if(Q.logger.info("[ApplianceMultiPlugin] canUndoSteps"),Q.currentManager&&st.isRoom(s)&&!s.disableSerialization){const p=Q.currentManager.viewContainerManager.focuedView,f=p==null?void 0:p.focusScenePath;if(p&&f)return p.displayer.commiter.undoStack.filter(I=>I.scenePath===f).length}return 0},undo:function(){return Q.logger.info("[ApplianceMultiPlugin] undo"),Q.currentManager&&st.isRoom(s)&&!s.disableSerialization?Q.currentManager.viewContainerManager.undo():0},redo:function(){return Q.logger.info("[ApplianceMultiPlugin] redo"),Q.currentManager&&st.isRoom(s)&&!s.disableSerialization?Q.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(){Q.logger.info("[ApplianceMultiPlugin] cleanCurrentScene"),Q.currentManager&&st.isRoom(s)&&s.isWritable&&(Q.currentManager.cleanCurrentScene(),c.call(t))},insertImage:function(p){Q.logger.info("[ApplianceMultiPlugin] insertImage"),Q.currentManager&&st.isRoom(s)&&s.isWritable&&Q.currentManager.worker.insertImage(p)},lockImage:function(p,f){Q.logger.info("[ApplianceMultiPlugin] lockImage"),Q.currentManager&&st.isRoom(s)&&s.isWritable&&Q.currentManager.worker.lockImage(p,f)},completeImageUpload:function(p,f){Q.logger.info("[ApplianceMultiPlugin] completeImageUpload"),Q.currentManager&&st.isRoom(s)&&s.isWritable&&Q.currentManager.worker.completeImageUpload(p,f)},getImagesInformation:function(p){return Q.logger.info("[ApplianceMultiPlugin] completeImageUpload"),Q.currentManager&&st.isRoom(s)&&s.isWritable?Q.currentManager.worker.getImagesInformation(p):[]},callbacks:()=>(Q.logger.info("[ApplianceMultiPlugin] callbacks bind"),{...s.callbacks,on:u._callbacksOn.bind(u),once:u._callbacksOnce.bind(u),off:u._callbacksOff.bind(u)}),destroy(){Q.currentManager&&(Q.logger.info("[ApplianceMultiPlugin] destroy"),Q.currentManager.destroy(),Q.currentManager=void 0)},setMemberState(p){Q.logger.info("[ApplianceMultiPlugin] setMemberState");const f=Object.keys(p);if(st.isRoom(s)&&s.isWritable){f.includes("currentApplianceName")&&(p.currentApplianceName&&p.currentApplianceName===et.laserPen?(p.currentApplianceName=et.pencil,p.useLaserPen=!0):p.currentApplianceName&&p.currentApplianceName===et.pencil&&(p.useLaserPen=!1)),l.call(t.mainView,p);return}throw new Error("setMemberState must be called in writable room")},setPerformancePriority(p){Q.logger.info("[ApplianceMultiPlugin] setPriority"),Q.currentManager&&Q.currentManager.setPriority(p)}},d=(p,f)=>{if(Q.logger.info(`[ApplianceMultiPlugin] injectMethodToObject ${f}`),typeof p[f]=="function"||typeof p[f]>"u"){p[f]=u[f];return}f==="callbacks"&&(p.callbacks.on=u._callbacksOn.bind(u),p.callbacks.off=u._callbacksOff.bind(u),p.callbacks.once=u._callbacksOnce.bind(u))};return d(t,"undo"),d(t,"redo"),d(t,"cleanCurrentScene"),d(t,"insertImage"),d(t,"completeImageUpload"),d(t,"lockImage"),d(s,"getImagesInformation"),d(s,"callbacks"),d(s,"screenshotToCanvasAsync"),d(s,"getBoundingRectAsync"),d(s,"scenePreviewAsync"),d(s,"fillSceneSnapshotAsync"),d(t.mainView,"setMemberState"),Object.defineProperty(t,"canUndoSteps",{get(){return u.canUndoSteps()}}),Object.defineProperty(t,"canRedoSteps",{get(){return u.canRedoSteps()}}),ce.InternalMsgEmitter.on("onCanUndoStepsUpdate",p=>{t.emitter.emit("canUndoStepsChange",p)}),ce.InternalMsgEmitter.on("onCanRedoStepsUpdate",p=>{t.emitter.emit("canRedoStepsChange",p)}),{...u,callbacks:u.callbacks()}}static onCreate(t){t&&Q.currentManager&&(Q.currentManager.bindPlugin(t),t.init(t.displayer))}static async createApplianceMultiPlugin(t,e){await t.createInvisiblePlugin(Q,{});let s=t.getInvisiblePlugin(e);return s||(s=await Q.createApplianceMultiPlugin(t,e)),s}get isReplay(){return st.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(t){var s,i;const e=t.state;(s=Q.currentManager)==null||s.onRoomMembersChange(e.roomMembers),st.isRoom(t)&&((i=Q.currentManager)==null||i.onMemberChange(e.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 t;Q.logger.info("[ApplianceMultiPlugin] passive destroy"),(t=Q.currentManager)==null||t.destroy(),Q.currentManager=void 0}};M(Q,"kind","appliance-multi-plugin"),M(Q,"currentManager"),M(Q,"logger",{info:console.log,warn:console.warn,error:console.error}),M(Q,"options",xt),M(Q,"createCurrentManager",(t,e,s)=>{Q.currentManager&&Q.currentManager.destroy();const i={plugin:s,displayer:t.displayer,options:e},n=new ce(i);Q.logger.info("[ApplianceMultiPlugin] refresh ApplianceMultiManager object"),n.setWindowManager(t),Q.currentManager=n});let ko=Q;class oy extends zi{constructor(t,e){super(t,e);M(this,"width",1e3);M(this,"height",1e3);M(this,"dpr",1);M(this,"vDom");M(this,"viewId",yt);M(this,"eventTragetElement");M(this,"snapshotContainerRef");M(this,"canvasContainerRef",g.createRef());M(this,"subLocalCanvasContainerRef",g.createRef());M(this,"canvasTopRef",g.createRef());M(this,"canvasServiceFloatRef",g.createRef());M(this,"canvasFloatRef",g.createRef());M(this,"canvasBgRef",g.createRef());M(this,"floatBarRef",g.createRef());M(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas()||(this.snapshotContainerRef=g.createRef())}setCanvassStyle(){if(this.eventTragetElement){const t=this.eventTragetElement.offsetWidth,e=this.eventTragetElement.offsetHeight;t&&e&&this.canvasContainerRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=qt()),t&&e&&this.canvasContainerRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=qt(),this.width=t,this.height=e),t&&e&&this.canvasBgRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=qt(this.canvasBgRef.current.getContext("2d")),this.width=t,this.height=e,this.canvasBgRef.current.width=t*this.dpr,this.canvasBgRef.current.height=e*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=t*this.dpr,this.canvasFloatRef.current.height=e*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=t*this.dpr,this.canvasServiceFloatRef.current.height=e*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=t*this.dpr,this.canvasTopRef.current.height=e*this.dpr))}}createMainViewDisplayer(t){return this.vDom||(this.containerOffset=this.getContainerOffset(t,this.containerOffset),this.eventTragetElement=t.parentElement.children[0],t.innerHTML="",Lo.render(g.createElement(Ho,{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 $t extends ge{constructor(t){super(t);M(this,"focuedViewId");M(this,"control");M(this,"focuedView");this.control=t.control}bindMainView(){if(!this.control.divMainView)return;const t=new oy(this.control,mt.InternalMsgEmitter);this.focuedViewId=yt;const{width:e,height:s,dpr:i}=t,n={dpr:i,originalPoint:[e/2,s/2],offscreenCanvasOpt:{...$t.defaultScreenCanvasOpt,width:e,height:s},layerOpt:{...$t.defaultLayerOpt,width:e,height:s},cameraOpt:{...$t.defaultCameraOpt,width:e,height:s}},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:yt,displayer:t,focusScenePath:a.focusScenePath||a.scenePath,cameraOpt:n.cameraOpt,viewData:a}),this.focuedView=this.mainView,t.createMainViewDisplayer(this.control.divMainView)}}getViewInitData(t){const e=this.getView(t);if(e){const{width:s,height:i,dpr:n}=e.displayer,a={dpr:n,originalPoint:[s/2,i/2],offscreenCanvasOpt:{...$t.defaultScreenCanvasOpt,width:s,height:i},layerOpt:{...$t.defaultLayerOpt,width:s,height:i},cameraOpt:{...$t.defaultCameraOpt,width:s,height:i}};if(e.viewData){const{scale:c,...l}=e.viewData.camera;a.cameraOpt={...a.cameraOpt,...l,scale:c===1/0?1:c}}return a}}async mountView(t){var s;const e=this.getView(t);if(e){this.control.worker.isActive||(this.control.cursor.activeCollector(),await this.control.activeWorker());const i=this.getViewInitData(t);i&&((s=this.control.worker)==null||s.createViewWorker(t,i)),e.focusScenePath&&this.control.collector&&this.control.worker.pullServiceData(t,e.focusScenePath,{isAsync:!0,useAnimation:!1})}}}class Ht extends mt{constructor(t){super(t);M(this,"viewContainerManager");M(this,"divMainView");M(this,"onCameraChange",je(t=>{var s;const e=this.viewContainerManager.mainView;e&&e.cameraOpt&&(e.cameraOpt.width!==t.width||e.cameraOpt.height!==t.height)&&((s=this.viewContainerManager.mainView)==null||s.displayer.updateSize()),this.viewContainerManager.setFocuedViewCameraOpt(t)},20,{leading:!1}));const e={control:this,internalMsgEmitter:Ht.InternalMsgEmitter};this.viewContainerManager=new $t(e)}init(){Ht.InternalMsgEmitter.on(Z.BindMainView,t=>{this.divMainView=t,this.plugin&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView()})}activePlugin(){this.plugin&&this.divMainView&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView(),this.collector&&(this.collector.addStorageStateListener(t=>{var a,c;if((a=this.collector)!=null&&a.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(yt,!0);return}const{diffView:e,diffScenePath:s,diffData:i}=t,n=new Map;if(e){let l;Object.keys(e).forEach(h=>{var d;const u=e[h];if(u&&!u.newValue)(d=this.worker)==null||d.clearViewScenePath(h,!0),u.oldValue&&(l=u.oldValue);else if(u&&u.newValue){for(const p of Object.keys(u.newValue))this.worker.pullServiceData(h,p,{isAsync:!1,useAnimation:!0});l=u.newValue}if(l)for(const p of Object.values(l)){const f=new Set;for(const I of Object.keys(p))I&&f.add(I);n.set(h,f)}})}if(s){let l;Object.keys(s).forEach(h=>{var d;const u=s[h];if(u&&u.viewId&&!u.newValue?((d=this.worker)==null||d.clearViewScenePath(u.viewId,!0),u.oldValue&&(l=u.oldValue)):u&&u.viewId&&u.newValue&&(this.worker.pullServiceData(u.viewId,h,{isAsync:!1,useAnimation:!0}),l=u.newValue),u!=null&&u.viewId&&l){const p=new Set;for(const f of Object.keys(l))f&&p.add(f),n.set(u.viewId,p)}})}i&&Object.keys(i).forEach(l=>{var u;const h=i[l];if(h){const{viewId:d}=h,p=n.get(d)||new Set;p.add(l),n.set(d,p),(u=this.worker)==null||u.onServiceDerive(l,h)}});for(const[l,h]of n.entries())mt.InternalMsgEmitter.emit("excludeIds",[...h],l)}),this.room&&(this.roomMember.onUidChangeHook(t=>{var e,s,i,n;if((e=this.collector)!=null&&e.serviceStorage){const a=[];this.viewContainerManager.getAllViews().forEach(c=>{var l,h,u;if(c&&c.focusScenePath&&((l=this.collector)!=null&&l.serviceStorage[c.id])&&((h=this.collector)!=null&&h.serviceStorage[c.id][c.focusScenePath])){const d=Object.keys((u=this.collector)==null?void 0:u.serviceStorage[c.id][c.focusScenePath]).filter(p=>{var f;return(f=this.collector)==null?void 0:f.isSelector(p)}).map(p=>({viewId:c.id,scenePath:c.focusScenePath,key:p}));d.length&&a.push(...d)}}),a.forEach(({key:c,viewId:l,scenePath:h})=>{var d,p;const u=(d=this.collector)==null?void 0:d.getUidFromKey(c);u&&!t.online.includes(u)&&((p=this.collector)==null||p.updateValue(c,void 0,{isAfterUpdate:!0,viewId:l,scenePath:h}))})}(i=(s=this.cursor)==null?void 0:s.eventCollector)!=null&&i.serviceStorage&&Object.keys((n=this.cursor)==null?void 0:n.eventCollector.serviceStorage).forEach(c=>{var l,h;t.online.includes(c)||(h=(l=this.cursor)==null?void 0:l.eventCollector)==null||h.clearValue(c)})}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(t=>{t&&t.focusScenePath&&this.worker.pullServiceData(t.id,t.focusScenePath,{isAsync:!0,useAnimation:!1})})))}async activeWorker(){await this.worker.init()}}const U=class U extends st.InvisiblePlugin{constructor(){super(...arguments);M(this,"onPhaseChanged",t=>{var e;t===st.RoomPhase.Reconnecting&&((e=U.currentManager)==null||e.setSnapshootData())});M(this,"updateRoomWritable",()=>{var t;(t=U.currentManager)==null||t.onWritableChange(this.displayer.isWritable)});M(this,"roomStateChangeListener",async t=>{var e,s;U.currentManager instanceof Ht&&(t.cameraState&&U.currentManager.onCameraChange(t.cameraState),t.sceneState&&U.currentManager.onSceneChange(t.sceneState.scenePath,yt)),!(st.isRoom(this.displayer)&&!this.displayer.isWritable)&&(t.memberState&&((e=U.currentManager)==null||e.onMemberChange(t.memberState)),t!=null&&t.roomMembers&&((s=U.currentManager)==null||s.onRoomMembersChange(t.roomMembers)))})}static async getInstance(t,e){const s=t.callbacks.on,i=t.callbacks.off,n=t.callbacks.once,a=t.cleanCurrentScene.bind(t),c=t.setMemberState.bind(t);e!=null&&e.logger&&(U.logger=e.logger),e.options&&(U.options={...xt,...e.options});let l=t.getInvisiblePlugin(U.kind);l||(l=await U.createAppliancePlugin(t,U.kind)),t&&l&&U.createCurrentManager(t,U.options,l),l&&U.currentManager&&(U.currentManager.bindPlugin(l),l.init(t)),e!=null&&e.cursorAdapter&&(U.cursorAdapter=e.cursorAdapter),U.effectInstance();const h={displayer:t,currentManager:U.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,_injectTargetObject:void 0,getBoundingRectAsync:async function(d){var I;U.logger.info("[ApplianceSinglePlugin] getBoundingRectAsync");const p=t.getBoundingRect(d),f=await((I=U.currentManager)==null?void 0:I.getBoundingRect(d));return!p.width||!p.height?f:Ti(p,f)},screenshotToCanvasAsync:async function(d,p,f,I,y,v){var x;U.logger.info("[ApplianceSinglePlugin] screenshotToCanvasAsync");let m=f,w=I,N=y.scale;m>this.maxScreenshotWidth&&(N=this.maxScreenshotWidth/m*N,m=this.maxScreenshotWidth),w>this.maxScreenshotHeight&&(N=Math.min(this.maxScreenshotHeight/w*N,N),w=this.maxScreenshotHeight),y.scale=N;const S=document.createElement("canvas"),T=S.getContext("2d");S.width=m*(v||1),S.height=w*(v||1),T&&(t.screenshotToCanvas(T,p,m,w,y,v),d.drawImage(S,Math.floor((f-m)/2),Math.floor((I-w)/2),m*(v||1),w*(v||1),0,0,m,w),S.remove()),U.currentManager&&await((x=U.currentManager)==null?void 0:x.screenshotToCanvas(d,p,m,w,y,Math.floor((f-m)/2),Math.floor((I-w)/2)))},scenePreviewAsync:async function(d,p,f,I,y){U.logger.info("[ApplianceSinglePlugin] scenePreviewAsync"),t.scenePreview(d,p,f,I,y);const v=document.createElement("img");v.className="appliance-plugin-fill-scene-snapshot-img",p.append(v),getComputedStyle(p).position||(p.style.position="relative"),U.currentManager&&await U.currentManager.scenePreview(d,v)},fillSceneSnapshotAsync:async function(d,p,f,I,y){var D,_;U.logger.info("[ApplianceSinglePlugin] fillSceneSnapshotAsync"),p.innerHTML="",t.fillSceneSnapshot(d,p,f,I,y);const v=f||((D=t.state.cameraState)==null?void 0:D.width)||0,m=I||((_=t.state.cameraState)==null?void 0:_.height)||0;let w=await this.getBoundingRectAsync(d);w||(w={originX:0,originY:0,width:v,height:m});let N=Math.max(w==null?void 0:w.width,v),S=Math.max(w==null?void 0:w.height,m),T=1;const x=N>v&&Math.min(v/N,T)||T,b=S>m&&Math.min(m/S,T)||T;x<=b?(N=x<1&&v||N,S=Math.floor(S*x)+1,T=x):x>b&&(S=b<1&&m||S,N=Math.floor(N*b)+1,T=b);const A={scale:T,centerX:w.originX+w.width/2,centerY:w.originY+w.height/2},O=document.createElement("canvas"),j=O.getContext("2d");O.width=N,O.height=S,j&&await this.screenshotToCanvasAsync(j,d,N,S,A,devicePixelRatio);const E=document.createElement("img");E.className="appliance-plugin-fill-scene-snapshot-img",E.src=O.toDataURL(),E.onload=()=>{O.remove()},E.onerror=()=>{O.remove(),E.remove()},p.append(E),getComputedStyle(p).position||(p.style.position="relative")},_callbacksOn:function(d,p){U.logger.info(`[ApplianceSinglePlugin] callbacks ${d}`),(d==="onCanUndoStepsUpdate"||d==="onCanRedoStepsUpdate")&&st.isRoom(t)&&t.isWritable?Ht.InternalMsgEmitter.on(d,p):s.call(t.callbacks,d,p)},_callbacksOnce:function(d,p){U.logger.info(`[ApplianceSinglePlugin] callbacks ${d}`),(d==="onCanUndoStepsUpdate"||d==="onCanRedoStepsUpdate")&&st.isRoom(t)&&t.isWritable?Ht.InternalMsgEmitter.on(d,p):n.call(t.callbacks,d,p)},_callbacksOff:function(d,p){U.logger.info(`[ApplianceSinglePlugin] callbacks ${d}`),(d==="onCanUndoStepsUpdate"||d==="onCanRedoStepsUpdate")&&st.isRoom(t)&&t.isWritable?Ht.InternalMsgEmitter.off(d,p):i.call(t.callbacks,d,p)},canRedoSteps(){if(U.logger.info("[ApplianceSinglePlugin] canRedoSteps"),U.currentManager&&st.isRoom(t)&&!t.disableSerialization){const d=U.currentManager.viewContainerManager.focuedView,p=d==null?void 0:d.focusScenePath;if(d&&p)return d.displayer.commiter.redoStack.filter(f=>f.scenePath===p).length}return 0},canUndoSteps(){if(U.logger.info("[ApplianceSinglePlugin] canUndoSteps"),U.currentManager&&st.isRoom(t)&&!t.disableSerialization){const d=U.currentManager.viewContainerManager.focuedView,p=d==null?void 0:d.focusScenePath;if(d&&p)return d.displayer.commiter.undoStack.filter(f=>f.scenePath===p).length}return 0},undo:function(){return U.logger.info("[ApplianceSinglePlugin] undo"),U.currentManager&&st.isRoom(t)&&!t.disableSerialization?U.currentManager.viewContainerManager.undo():0},redo:function(){return U.logger.info("[ApplianceSinglePlugin] redo"),U.currentManager&&st.isRoom(t)&&!t.disableSerialization?U.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(d){U.logger.info("[ApplianceSinglePlugin] cleanCurrentScene"),U.currentManager&&st.isRoom(t)&&t.isWritable&&(U.currentManager.cleanCurrentScene(),a.call(t,d))},insertImage:function(d){U.logger.info("[ApplianceSinglePlugin] insertImage"),U.currentManager&&st.isRoom(t)&&t.isWritable&&U.currentManager.worker.insertImage(d)},lockImage:function(d,p){U.logger.info("[ApplianceSinglePlugin] lockImage"),U.currentManager&&st.isRoom(t)&&t.isWritable&&U.currentManager.worker.lockImage(d,p)},completeImageUpload:function(d,p){U.logger.info("[ApplianceSinglePlugin] completeImageUpload"),U.currentManager&&st.isRoom(t)&&t.isWritable&&U.currentManager.worker.completeImageUpload(d,p)},getImagesInformation:function(d){return U.logger.info("[ApplianceSinglePlugin] completeImageUpload"),U.currentManager&&st.isRoom(t)&&t.isWritable?U.currentManager.worker.getImagesInformation(d):[]},callbacks:()=>({...t.callbacks,on:h._callbacksOn.bind(h),once:h._callbacksOnce.bind(h),off:h._callbacksOff.bind(h)}),destroy(){U.currentManager&&(U.logger.info("[ApplianceSinglePlugin] destroy"),U.currentManager.destroy(),U.currentManager=void 0,U.cursorAdapter=void 0)},setMemberState(d){U.logger.info("[ApplianceSinglePlugin] setMemberState");const p=Object.keys(d);if(st.isRoom(t)&&t.isWritable){p.includes("currentApplianceName")&&(d.currentApplianceName&&d.currentApplianceName===et.laserPen?(d.currentApplianceName=et.pencil,d.useLaserPen=!0):d.currentApplianceName&&d.currentApplianceName===et.pencil&&(d.useLaserPen=!1)),c(d);return}throw new Error("setMemberState must be called in writable room")},setPerformancePriority(d){U.logger.info("[ApplianceSinglePlugin] setPriority"),U.currentManager&&U.currentManager.setPriority(d)}},u=(d,p)=>{if(U.logger.info(`[ApplianceSinglePlugin] injectMethodToObject ${p}`),typeof d[p]=="function"||typeof d[p]>"u"){d[p]=h[p];return}p==="callbacks"&&(d.callbacks.on=h._callbacksOn.bind(h),d.callbacks.off=h._callbacksOff.bind(h),d.callbacks.once=h._callbacksOnce.bind(h))};return u(t,"undo"),u(t,"redo"),u(t,"cleanCurrentScene"),u(t,"insertImage"),u(t,"completeImageUpload"),u(t,"lockImage"),u(t,"getImagesInformation"),u(t,"callbacks"),u(t,"screenshotToCanvasAsync"),u(t,"getBoundingRectAsync"),u(t,"scenePreviewAsync"),u(t,"fillSceneSnapshotAsync"),u(t,"setMemberState"),Object.defineProperty(t,"canUndoSteps",{get(){return h.canUndoSteps()}}),Object.defineProperty(t,"canRedoSteps",{get(){return h.canRedoSteps()}}),{...h,callbacks:h.callbacks()}}static onCreate(t){t&&U.currentManager&&(U.currentManager.bindPlugin(t),t.init(t.displayer))}static async createAppliancePlugin(t,e){await t.createInvisiblePlugin(U,{});let s=t.getInvisiblePlugin(e);return s||(s=await U.createAppliancePlugin(t,e)),s}static effectInstance(){if(U.cursorAdapter){const t=U.cursorAdapter.onAddedCursor;U.cursorAdapter.onAddedCursor=function(e){e.onCursorMemberChanged=s=>{try{s.appliance===et.pencil||s.appliance===et.shape||s.appliance===et.text||s.appliance===et.arrow||s.appliance===et.straight||s.appliance===et.rectangle||s.appliance===et.ellipse||s.appliance===et.eraser?e!=null&&e.divElement&&(e.divElement.style.display="none"):e!=null&&e.divElement&&(e.divElement.style.display="block")}catch{}},t.call(U.cursorAdapter,e)}}}get isReplay(){return st.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(t){var s,i;const e=t.state;(s=U.currentManager)==null||s.onRoomMembersChange(e.roomMembers),st.isRoom(t)&&e!=null&&e.memberState&&((i=U.currentManager)==null||i.onMemberChange(e.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 t;U.logger.info("[ApplianceSinglePlugin] passive destroy"),(t=U.currentManager)==null||t.destroy(),U.currentManager=void 0,U.cursorAdapter=void 0}};M(U,"kind","appliance-aids-single-plugin"),M(U,"cursorAdapter"),M(U,"currentManager"),M(U,"logger",{info:console.log,warn:console.warn,error:console.error}),M(U,"options",xt),M(U,"createCurrentManager",(t,e,s)=>{U.currentManager&&U.currentManager.destroy();const i={plugin:s,displayer:t,options:e},n=new Ht(i);n.init(),U.logger.info("[ApplianceSinglePlugin] refresh ApplianceSingleManager object"),U.currentManager=n});let xo=U;const pe=class pe extends g.Component{constructor(){super(...arguments);M(this,"mainViewRef",null)}componentDidMount(){pe.emiter||(pe.emiter=Ht.InternalMsgEmitter),pe.emiter.emit(Z.BindMainView,this.mainViewRef)}render(){return g.createElement(g.Fragment,null,this.props.children,g.createElement("div",{className:"appliance-plugin-main-view-displayer",ref:t=>this.mainViewRef=t}))}};M(pe,"emiter");let zo=pe;exports.ActiveContainerType=Ds;exports.ApplianceMultiPlugin=ko;exports.ApplianceNames=et;exports.ApplianceSigleWrapper=zo;exports.ApplianceSinglePlugin=xo;exports.Cursor_Hover_Id=Wf;exports.DefaultAppliancePluginOptions=xt;exports.ECanvasContextType=_e;exports.ECanvasShowType=Wt;exports.EDataType=F;exports.EMatrixrRelationType=xe;exports.EPostMessageType=z;exports.EScaleType=ct;exports.EStrokeType=X;exports.EToolsKey=C;exports.ElayerType=ee;exports.EmitEventType=R;exports.EventMessageType=ke;exports.EvevtWorkState=L;exports.EvevtWorkType=As;exports.InternalMsgEmitterType=Z;exports.Main_View_Id=yt;exports.ShapeType=Dt;exports.Storage_Selector_key=H;exports.Storage_Splitter=Rt;exports.Storage_ViewId_ALL=Ue;exports.Task_Time_Interval=Uf;exports.ViewContainerManager=ge;exports.checkOp=Df;exports.cloneDeep=Vt;exports.computRect=ut;exports.fullWorker=Ei;exports.getRectMatrixrRelation=Ef;exports.getShapeInstance=vi;exports.getShapeTools=Ii;exports.isBoolean=he;exports.isEqual=le;exports.isIntersect=Pe;exports.isIntersectForPoint=Ci;exports.isNumber=Ut;exports.isSet=gd;exports.subWorker=Oi;exports.throttle=je;exports.transformToNormalData=Te;exports.transformToSerializableData=zt;