@netless/appliance-plugin 1.1.3 → 1.1.4

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 Ai=(a,o,t)=>o in a?ji(a,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[o]=t;var M=(a,o,t)=>Ai(a,typeof o!="symbol"?o+"":o,t);const nt=require("white-web-sdk"),lt=require("spritejs"),Ds=require("lz-string"),Po=require("lineclip"),js=require("eventemitter2"),L=require("lodash"),Lo=require("react-dom"),g=require("react"),we=require("react-draggable"),Ei=require("re-resizable"),Oi="/fullWorker.js",Ri="/subWorker.js";var st=(a=>(a.selector="selector",a.clicker="clicker",a.laserPointer="laserPointer",a.pencil="pencil",a.rectangle="rectangle",a.ellipse="ellipse",a.shape="shape",a.eraser="eraser",a.pencilEraser="pencilEraser",a.text="text",a.straight="straight",a.arrow="arrow",a.hand="hand",a.laserPen="laserPen",a))(st||{}),_=(a=>(a.Normal="Normal",a.Stroke="Stroke",a.Dotted="Dotted",a.LongDotted="LongDotted",a))(_||{}),Ot=(a=>(a.Triangle="triangle",a.Rhombus="rhombus",a.Pentagram="pentagram",a.SpeechBalloon="speechBalloon",a.Star="star",a.Polygon="polygon",a))(Ot||{}),R=(a=>(a.None="None",a.ShowFloatBar="ShowFloatBar",a.ZIndexFloatBar="ZIndexFloatBar",a.DeleteNode="DeleteNode",a.CopyNode="CopyNode",a.ZIndexActive="ZIndexActive",a.ZIndexNode="ZIndexNode",a.RotateNode="RotateNode",a.SetColorNode="SetColorNode",a.TranslateNode="TranslateNode",a.ScaleNode="ScaleNode",a.OriginalEvent="OriginalEvent",a.CreateScene="CreateScene",a.ActiveCursor="ActiveCursor",a.MoveCursor="MoveCursor",a.CommandEditor="CommandEditor",a.SetEditorData="SetEditorData",a.SetFontStyle="SetFontStyle",a.SetPoint="SetPoint",a.SetLock="SetLock",a.SetShapeOpt="SetShapeOpt",a.CameraChange="CameraChange",a.ActiveMethod="ActiveMethod",a))(R||{}),q=(a=>(a.DisplayState="DisplayState",a.MainEngine="MainEngine",a.Cursor="Cursor",a.BindMainView="BindMainView",a))(q||{}),As=(a=>(a[a.MainView=0]="MainView",a[a.Plugin=1]="Plugin",a[a.Both=2]="Both",a))(As||{}),C=(a=>(a[a.Pencil=1]="Pencil",a[a.Eraser=2]="Eraser",a[a.PencilEraser=3]="PencilEraser",a[a.BitMapEraser=4]="BitMapEraser",a[a.Selector=5]="Selector",a[a.Clicker=6]="Clicker",a[a.Arrow=7]="Arrow",a[a.Hand=8]="Hand",a[a.LaserPen=9]="LaserPen",a[a.Text=10]="Text",a[a.Straight=11]="Straight",a[a.Rectangle=12]="Rectangle",a[a.Ellipse=13]="Ellipse",a[a.Star=14]="Star",a[a.Triangle=15]="Triangle",a[a.Rhombus=16]="Rhombus",a[a.Polygon=17]="Polygon",a[a.SpeechBalloon=18]="SpeechBalloon",a[a.Image=19]="Image",a))(C||{}),V=(a=>(a[a.Local=1]="Local",a[a.Service=2]="Service",a[a.Worker=3]="Worker",a))(V||{}),D=(a=>(a[a.Pending=0]="Pending",a[a.Start=1]="Start",a[a.Doing=2]="Doing",a[a.Done=3]="Done",a[a.Unwritable=4]="Unwritable",a))(D||{}),z=(a=>(a[a.None=0]="None",a[a.Init=1]="Init",a[a.UpdateCamera=2]="UpdateCamera",a[a.UpdateTools=3]="UpdateTools",a[a.CreateWork=4]="CreateWork",a[a.DrawWork=5]="DrawWork",a[a.FullWork=6]="FullWork",a[a.UpdateNode=7]="UpdateNode",a[a.RemoveNode=8]="RemoveNode",a[a.Clear=9]="Clear",a[a.Select=10]="Select",a[a.Destroy=11]="Destroy",a[a.Snapshot=12]="Snapshot",a[a.BoundingBox=13]="BoundingBox",a[a.Cursor=14]="Cursor",a[a.TextUpdate=15]="TextUpdate",a[a.GetTextActive=16]="GetTextActive",a[a.TasksQueue=17]="TasksQueue",a[a.CursorHover=18]="CursorHover",a[a.CursorBlur=19]="CursorBlur",a[a.Console=20]="Console",a[a.PriorityWorker=21]="PriorityWorker",a[a.PriorityMainThreadWorker=22]="PriorityMainThreadWorker",a[a.GetImageBitMap=23]="GetImageBitMap",a[a.AuthWriter=24]="AuthWriter",a[a.AuthReader=25]="AuthReader",a[a.AuthClear=26]="AuthClear",a[a.AuthPage=27]="AuthPage",a))(z||{}),Vt=(a=>(a[a.None=0]="None",a[a.Bg=1]="Bg",a[a.ServiceFloat=2]="ServiceFloat",a[a.Float=3]="Float",a[a.TopFloat=4]="TopFloat",a))(Vt||{}),be=(a=>(a[a.Cursor=1]="Cursor",a[a.TextCreate=2]="TextCreate",a))(be||{}),ie=(a=>(a[a.Top=1]="Top",a[a.Bottom=2]="Bottom",a))(ie||{}),ct=(a=>(a[a.none=1]="none",a[a.all=2]="all",a[a.both=3]="both",a[a.proportional=4]="proportional",a))(ct||{}),Es=(a=>(a[a.Pending=0]="Pending",a[a.Start=1]="Start",a[a.Doing=2]="Doing",a[a.Done=3]="Done",a[a.Unwritable=4]="Unwritable",a))(Es||{}),Pe=(a=>(a[a.inside=0]="inside",a[a.outside=1]="outside",a[a.intersect=2]="intersect",a))(Pe||{}),kt=(a=>(a.renderPage="renderPage",a.addPage="addPage",a.deletePage="deletePage",a.addElement="addElement",a.deleteElement="deleteElement",a.clearPage="clearPage",a.clearViewScenePath="clearViewScenePath",a.clearView="clearView",a))(kt||{}),Wt=(a=>(a.setAuth="setAuth",a.setShow="addShow",a.setHide="setHide",a.setClear="setClear",a))(Wt||{});const Yi={linear:a=>a,easeInQuad:a=>a*a,easeOutQuad:a=>a*(2-a),easeInOutQuad:a=>a<.5?2*a*a:-1+(4-2*a)*a,easeInCubic:a=>a*a*a,easeOutCubic:a=>--a*a*a+1,easeInOutCubic:a=>a<.5?4*a*a*a:(a-1)*(2*a-2)*(2*a-2)+1,easeInQuart:a=>a*a*a*a,easeOutQuart:a=>1- --a*a*a*a,easeInOutQuart:a=>a<.5?8*a*a*a*a:1-8*--a*a*a*a,easeInQuint:a=>a*a*a*a*a,easeOutQuint:a=>1+--a*a*a*a*a,easeInOutQuint:a=>a<.5?16*a*a*a*a*a:1+16*--a*a*a*a*a,easeInSine:a=>1-Math.cos(a*Math.PI/2),easeOutSine:a=>Math.sin(a*Math.PI/2),easeInOutSine:a=>-(Math.cos(Math.PI*a)-1)/2,easeInExpo:a=>a<=0?0:Math.pow(2,10*a-10),easeOutExpo:a=>a>=1?1:1-Math.pow(2,-10*a),easeInOutExpo:a=>a<=0?0:a>=1?1:a<.5?Math.pow(2,20*a-10)/2:(2-Math.pow(2,-20*a+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),r=Math.cos(e);return new k(t.x+(s*r-i*n),t.y+(s*n+i*r))}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=Yi.easeInQuad(i/(e-1)),r=k.Lrp(o,t,n);r.z=Math.min(1,.5+Math.abs(.5-Wi(n))*.65),s.push(r)}return s}static SnapToGrid(o,t=8){return new k(Math.round(o.x/t)*t,Math.round(o.y/t)*t)}}const Wi=a=>a<.5?2*a*a:-1+(4-2*a)*a;class F 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,r={x:s.x,y:s.y};return new F(o,t,e,r,i,n)}distance(o){return F.GetDistance(this,o)}isNear(o,t){return F.IsNear(this,o,t)}getAngleByPoints(o,t){return F.GetAngleByPoints(o,this,t)}static Sub(o,t){return new F(o.x-t.x,o.y-t.y)}static Add(o,t){return new F(o.x+t.x,o.y+t.y)}static GetDistance(o,t){return F.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,r=e.y-t.y;let c=0;const l=Math.sqrt(s*s+n*n),h=Math.sqrt(i*i+r*r);if(l&&h){const u=s*i+n*r;c=Math.acos(u/(l*h)),c=c/Math.PI*180;let d=s*r-n*i;d=d>0?1:-1,c=180+d*c}return c}static IsNear(o,t,e){return F.Len(o.clone().sub(t))<e}static RotWith(o,t,e,s=2){const i=o.x-t.x,n=o.y-t.y,r=Math.sin(e),c=Math.cos(e),l=Math.pow(10,s),h=Math.floor((t.x+(i*c-n*r))*l)/l,u=Math.floor((t.y+(i*r+n*c))*l)/l;return new F(h,u)}static GetDotStroke(o,t,e=16){const s=new k(1,1),i=Math.PI+.001,n=F.Add(o,F.Sub(o,s).uni().per().mul(-t)),r=[];for(let c=1/e,l=c;l<=1;l+=c)r.push(F.RotWith(n,o,i*2*l));return r}static GetSemicircleStroke(o,t,e=-1,s=8){const i=e*(Math.PI+.001),n=[];for(let r=1/s,c=r;c<=1;c+=r)n.push(F.RotWith(t,o,i*c));return n}}var Re=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ie(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var Ui=typeof Re=="object"&&Re&&Re.Object===Object&&Re,Os=Ui,Bi=Os,Fi=typeof self=="object"&&self&&self.Object===Object&&self,Vi=Bi||Fi||Function("return this")(),Bt=Vi,Hi=Bt,Qi=Hi.Symbol,oo=Qi,Qo=oo,Rs=Object.prototype,$i=Rs.hasOwnProperty,Gi=Rs.toString,ze=Qo?Qo.toStringTag:void 0;function Zi(a){var o=$i.call(a,ze),t=a[ze];try{a[ze]=void 0;var e=!0}catch{}var s=Gi.call(a);return e&&(o?a[ze]=t:delete a[ze]),s}var qi=Zi,Ji=Object.prototype,Xi=Ji.toString;function Ki(a){return Xi.call(a)}var _i=Ki,$o=oo,tn=qi,en=_i,on="[object Null]",sn="[object Undefined]",Go=$o?$o.toStringTag:void 0;function nn(a){return a==null?a===void 0?sn:on:Go&&Go in Object(a)?tn(a):en(a)}var re=nn;function rn(a){return a!=null&&typeof a=="object"}var Zt=rn,an=re,cn=Zt,ln="[object Number]";function hn(a){return typeof a=="number"||cn(a)&&an(a)==ln}var un=hn;const Ht=Ie(un);function dn(){this.__data__=[],this.size=0}var pn=dn;function fn(a,o){return a===o||a!==a&&o!==o}var Do=fn,gn=Do;function Mn(a,o){for(var t=a.length;t--;)if(gn(a[t][0],o))return t;return-1}var so=Mn,yn=so,mn=Array.prototype,wn=mn.splice;function In(a){var o=this.__data__,t=yn(o,a);if(t<0)return!1;var e=o.length-1;return t==e?o.pop():wn.call(o,t,1),--this.size,!0}var vn=In,Nn=so;function Tn(a){var o=this.__data__,t=Nn(o,a);return t<0?void 0:o[t][1]}var Sn=Tn,Cn=so;function kn(a){return Cn(this.__data__,a)>-1}var xn=kn,zn=so;function bn(a,o){var t=this.__data__,e=zn(t,a);return e<0?(++this.size,t.push([a,o])):t[e][1]=o,this}var Pn=bn,Ln=pn,Dn=vn,jn=Sn,An=xn,En=Pn;function ve(a){var o=-1,t=a==null?0:a.length;for(this.clear();++o<t;){var e=a[o];this.set(e[0],e[1])}}ve.prototype.clear=Ln;ve.prototype.delete=Dn;ve.prototype.get=jn;ve.prototype.has=An;ve.prototype.set=En;var io=ve,On=io;function Rn(){this.__data__=new On,this.size=0}var Yn=Rn;function Wn(a){var o=this.__data__,t=o.delete(a);return this.size=o.size,t}var Un=Wn;function Bn(a){return this.__data__.get(a)}var Fn=Bn;function Vn(a){return this.__data__.has(a)}var Hn=Vn;function Qn(a){var o=typeof a;return a!=null&&(o=="object"||o=="function")}var _t=Qn,$n=re,Gn=_t,Zn="[object AsyncFunction]",qn="[object Function]",Jn="[object GeneratorFunction]",Xn="[object Proxy]";function Kn(a){if(!Gn(a))return!1;var o=$n(a);return o==qn||o==Jn||o==Zn||o==Xn}var Ys=Kn,_n=Bt,tr=_n["__core-js_shared__"],er=tr,fo=er,Zo=function(){var a=/[^.]+$/.exec(fo&&fo.keys&&fo.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""}();function or(a){return!!Zo&&Zo in a}var sr=or,ir=Function.prototype,nr=ir.toString;function rr(a){if(a!=null){try{return nr.call(a)}catch{}try{return a+""}catch{}}return""}var Ws=rr,ar=Ys,cr=sr,lr=_t,hr=Ws,ur=/[\\^$.*+?()[\]{}|]/g,dr=/^\[object .+?Constructor\]$/,pr=Function.prototype,fr=Object.prototype,gr=pr.toString,Mr=fr.hasOwnProperty,yr=RegExp("^"+gr.call(Mr).replace(ur,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function mr(a){if(!lr(a)||cr(a))return!1;var o=ar(a)?yr:dr;return o.test(hr(a))}var wr=mr;function Ir(a,o){return a==null?void 0:a[o]}var vr=Ir,Nr=wr,Tr=vr;function Sr(a,o){var t=Tr(a,o);return Nr(t)?t:void 0}var ae=Sr,Cr=ae,kr=Bt,xr=Cr(kr,"Map"),jo=xr,zr=ae,br=zr(Object,"create"),no=br,qo=no;function Pr(){this.__data__=qo?qo(null):{},this.size=0}var Lr=Pr;function Dr(a){var o=this.has(a)&&delete this.__data__[a];return this.size-=o?1:0,o}var jr=Dr,Ar=no,Er="__lodash_hash_undefined__",Or=Object.prototype,Rr=Or.hasOwnProperty;function Yr(a){var o=this.__data__;if(Ar){var t=o[a];return t===Er?void 0:t}return Rr.call(o,a)?o[a]:void 0}var Wr=Yr,Ur=no,Br=Object.prototype,Fr=Br.hasOwnProperty;function Vr(a){var o=this.__data__;return Ur?o[a]!==void 0:Fr.call(o,a)}var Hr=Vr,Qr=no,$r="__lodash_hash_undefined__";function Gr(a,o){var t=this.__data__;return this.size+=this.has(a)?0:1,t[a]=Qr&&o===void 0?$r:o,this}var Zr=Gr,qr=Lr,Jr=jr,Xr=Wr,Kr=Hr,_r=Zr;function Ne(a){var o=-1,t=a==null?0:a.length;for(this.clear();++o<t;){var e=a[o];this.set(e[0],e[1])}}Ne.prototype.clear=qr;Ne.prototype.delete=Jr;Ne.prototype.get=Xr;Ne.prototype.has=Kr;Ne.prototype.set=_r;var ta=Ne,Jo=ta,ea=io,oa=jo;function sa(){this.size=0,this.__data__={hash:new Jo,map:new(oa||ea),string:new Jo}}var ia=sa;function na(a){var o=typeof a;return o=="string"||o=="number"||o=="symbol"||o=="boolean"?a!=="__proto__":a===null}var ra=na,aa=ra;function ca(a,o){var t=a.__data__;return aa(o)?t[typeof o=="string"?"string":"hash"]:t.map}var ro=ca,la=ro;function ha(a){var o=la(this,a).delete(a);return this.size-=o?1:0,o}var ua=ha,da=ro;function pa(a){return da(this,a).get(a)}var fa=pa,ga=ro;function Ma(a){return ga(this,a).has(a)}var ya=Ma,ma=ro;function wa(a,o){var t=ma(this,a),e=t.size;return t.set(a,o),this.size+=t.size==e?0:1,this}var Ia=wa,va=ia,Na=ua,Ta=fa,Sa=ya,Ca=Ia;function Te(a){var o=-1,t=a==null?0:a.length;for(this.clear();++o<t;){var e=a[o];this.set(e[0],e[1])}}Te.prototype.clear=va;Te.prototype.delete=Na;Te.prototype.get=Ta;Te.prototype.has=Sa;Te.prototype.set=Ca;var Us=Te,ka=io,xa=jo,za=Us,ba=200;function Pa(a,o){var t=this.__data__;if(t instanceof ka){var e=t.__data__;if(!xa||e.length<ba-1)return e.push([a,o]),this.size=++t.size,this;t=this.__data__=new za(e)}return t.set(a,o),this.size=t.size,this}var La=Pa,Da=io,ja=Yn,Aa=Un,Ea=Fn,Oa=Hn,Ra=La;function Se(a){var o=this.__data__=new Da(a);this.size=o.size}Se.prototype.clear=ja;Se.prototype.delete=Aa;Se.prototype.get=Ea;Se.prototype.has=Oa;Se.prototype.set=Ra;var Bs=Se;function Ya(a,o){for(var t=-1,e=a==null?0:a.length;++t<e&&o(a[t],t,a)!==!1;);return a}var Wa=Ya,Ua=ae,Ba=function(){try{var a=Ua(Object,"defineProperty");return a({},"",{}),a}catch{}}(),Fa=Ba,Xo=Fa;function Va(a,o,t){o=="__proto__"&&Xo?Xo(a,o,{configurable:!0,enumerable:!0,value:t,writable:!0}):a[o]=t}var Fs=Va,Ha=Fs,Qa=Do,$a=Object.prototype,Ga=$a.hasOwnProperty;function Za(a,o,t){var e=a[o];(!(Ga.call(a,o)&&Qa(e,t))||t===void 0&&!(o in a))&&Ha(a,o,t)}var Vs=Za,qa=Vs,Ja=Fs;function Xa(a,o,t,e){var s=!t;t||(t={});for(var i=-1,n=o.length;++i<n;){var r=o[i],c=e?e(t[r],a[r],r,t,a):void 0;c===void 0&&(c=a[r]),s?Ja(t,r,c):qa(t,r,c)}return t}var ao=Xa;function Ka(a,o){for(var t=-1,e=Array(a);++t<a;)e[t]=o(t);return e}var _a=Ka,tc=re,ec=Zt,oc="[object Arguments]";function sc(a){return ec(a)&&tc(a)==oc}var ic=sc,Ko=ic,nc=Zt,Hs=Object.prototype,rc=Hs.hasOwnProperty,ac=Hs.propertyIsEnumerable,cc=Ko(function(){return arguments}())?Ko:function(a){return nc(a)&&rc.call(a,"callee")&&!ac.call(a,"callee")},lc=cc,hc=Array.isArray,co=hc,He={exports:{}};function uc(){return!1}var dc=uc;He.exports;(function(a,o){var t=Bt,e=dc,s=o&&!o.nodeType&&o,i=s&&!0&&a&&!a.nodeType&&a,n=i&&i.exports===s,r=n?t.Buffer:void 0,c=r?r.isBuffer:void 0,l=c||e;a.exports=l})(He,He.exports);var Ao=He.exports,pc=9007199254740991,fc=/^(?:0|[1-9]\d*)$/;function gc(a,o){var t=typeof a;return o=o??pc,!!o&&(t=="number"||t!="symbol"&&fc.test(a))&&a>-1&&a%1==0&&a<o}var Mc=gc,yc=9007199254740991;function mc(a){return typeof a=="number"&&a>-1&&a%1==0&&a<=yc}var Qs=mc,wc=re,Ic=Qs,vc=Zt,Nc="[object Arguments]",Tc="[object Array]",Sc="[object Boolean]",Cc="[object Date]",kc="[object Error]",xc="[object Function]",zc="[object Map]",bc="[object Number]",Pc="[object Object]",Lc="[object RegExp]",Dc="[object Set]",jc="[object String]",Ac="[object WeakMap]",Ec="[object ArrayBuffer]",Oc="[object DataView]",Rc="[object Float32Array]",Yc="[object Float64Array]",Wc="[object Int8Array]",Uc="[object Int16Array]",Bc="[object Int32Array]",Fc="[object Uint8Array]",Vc="[object Uint8ClampedArray]",Hc="[object Uint16Array]",Qc="[object Uint32Array]",ft={};ft[Rc]=ft[Yc]=ft[Wc]=ft[Uc]=ft[Bc]=ft[Fc]=ft[Vc]=ft[Hc]=ft[Qc]=!0;ft[Nc]=ft[Tc]=ft[Ec]=ft[Sc]=ft[Oc]=ft[Cc]=ft[kc]=ft[xc]=ft[zc]=ft[bc]=ft[Pc]=ft[Lc]=ft[Dc]=ft[jc]=ft[Ac]=!1;function $c(a){return vc(a)&&Ic(a.length)&&!!ft[wc(a)]}var Gc=$c;function Zc(a){return function(o){return a(o)}}var Eo=Zc,Qe={exports:{}};Qe.exports;(function(a,o){var t=Os,e=o&&!o.nodeType&&o,s=e&&!0&&a&&!a.nodeType&&a,i=s&&s.exports===e,n=i&&t.process,r=function(){try{var c=s&&s.require&&s.require("util").types;return c||n&&n.binding&&n.binding("util")}catch{}}();a.exports=r})(Qe,Qe.exports);var Oo=Qe.exports,qc=Gc,Jc=Eo,_o=Oo,ts=_o&&_o.isTypedArray,Xc=ts?Jc(ts):qc,$s=Xc,Kc=_a,_c=lc,tl=co,el=Ao,ol=Mc,sl=$s,il=Object.prototype,nl=il.hasOwnProperty;function rl(a,o){var t=tl(a),e=!t&&_c(a),s=!t&&!e&&el(a),i=!t&&!e&&!s&&sl(a),n=t||e||s||i,r=n?Kc(a.length,String):[],c=r.length;for(var l in a)(o||nl.call(a,l))&&!(n&&(l=="length"||s&&(l=="offset"||l=="parent")||i&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||ol(l,c)))&&r.push(l);return r}var Gs=rl,al=Object.prototype;function cl(a){var o=a&&a.constructor,t=typeof o=="function"&&o.prototype||al;return a===t}var Ro=cl;function ll(a,o){return function(t){return a(o(t))}}var Zs=ll,hl=Zs,ul=hl(Object.keys,Object),dl=ul,pl=Ro,fl=dl,gl=Object.prototype,Ml=gl.hasOwnProperty;function yl(a){if(!pl(a))return fl(a);var o=[];for(var t in Object(a))Ml.call(a,t)&&t!="constructor"&&o.push(t);return o}var ml=yl,wl=Ys,Il=Qs;function vl(a){return a!=null&&Il(a.length)&&!wl(a)}var qs=vl,Nl=Gs,Tl=ml,Sl=qs;function Cl(a){return Sl(a)?Nl(a):Tl(a)}var Yo=Cl,kl=ao,xl=Yo;function zl(a,o){return a&&kl(o,xl(o),a)}var bl=zl;function Pl(a){var o=[];if(a!=null)for(var t in Object(a))o.push(t);return o}var Ll=Pl,Dl=_t,jl=Ro,Al=Ll,El=Object.prototype,Ol=El.hasOwnProperty;function Rl(a){if(!Dl(a))return Al(a);var o=jl(a),t=[];for(var e in a)e=="constructor"&&(o||!Ol.call(a,e))||t.push(e);return t}var Yl=Rl,Wl=Gs,Ul=Yl,Bl=qs;function Fl(a){return Bl(a)?Wl(a,!0):Ul(a)}var Wo=Fl,Vl=ao,Hl=Wo;function Ql(a,o){return a&&Vl(o,Hl(o),a)}var $l=Ql,$e={exports:{}};$e.exports;(function(a,o){var t=Bt,e=o&&!o.nodeType&&o,s=e&&!0&&a&&!a.nodeType&&a,i=s&&s.exports===e,n=i?t.Buffer:void 0,r=n?n.allocUnsafe:void 0;function c(l,h){if(h)return l.slice();var u=l.length,d=r?r(u):new l.constructor(u);return l.copy(d),d}a.exports=c})($e,$e.exports);var Gl=$e.exports;function Zl(a,o){var t=-1,e=a.length;for(o||(o=Array(e));++t<e;)o[t]=a[t];return o}var ql=Zl;function Jl(a,o){for(var t=-1,e=a==null?0:a.length,s=0,i=[];++t<e;){var n=a[t];o(n,t,a)&&(i[s++]=n)}return i}var Xl=Jl;function Kl(){return[]}var Js=Kl,_l=Xl,th=Js,eh=Object.prototype,oh=eh.propertyIsEnumerable,es=Object.getOwnPropertySymbols,sh=es?function(a){return a==null?[]:(a=Object(a),_l(es(a),function(o){return oh.call(a,o)}))}:th,Uo=sh,ih=ao,nh=Uo;function rh(a,o){return ih(a,nh(a),o)}var ah=rh;function ch(a,o){for(var t=-1,e=o.length,s=a.length;++t<e;)a[s+t]=o[t];return a}var Xs=ch,lh=Zs,hh=lh(Object.getPrototypeOf,Object),Ks=hh,uh=Xs,dh=Ks,ph=Uo,fh=Js,gh=Object.getOwnPropertySymbols,Mh=gh?function(a){for(var o=[];a;)uh(o,ph(a)),a=dh(a);return o}:fh,_s=Mh,yh=ao,mh=_s;function wh(a,o){return yh(a,mh(a),o)}var Ih=wh,vh=Xs,Nh=co;function Th(a,o,t){var e=o(a);return Nh(a)?e:vh(e,t(a))}var ti=Th,Sh=ti,Ch=Uo,kh=Yo;function xh(a){return Sh(a,kh,Ch)}var ei=xh,zh=ti,bh=_s,Ph=Wo;function Lh(a){return zh(a,Ph,bh)}var Dh=Lh,jh=ae,Ah=Bt,Eh=jh(Ah,"DataView"),Oh=Eh,Rh=ae,Yh=Bt,Wh=Rh(Yh,"Promise"),Uh=Wh,Bh=ae,Fh=Bt,Vh=Bh(Fh,"Set"),Hh=Vh,Qh=ae,$h=Bt,Gh=Qh($h,"WeakMap"),Zh=Gh,wo=Oh,Io=jo,vo=Uh,No=Hh,To=Zh,oi=re,Ce=Ws,os="[object Map]",qh="[object Object]",ss="[object Promise]",is="[object Set]",ns="[object WeakMap]",rs="[object DataView]",Jh=Ce(wo),Xh=Ce(Io),Kh=Ce(vo),_h=Ce(No),tu=Ce(To),ee=oi;(wo&&ee(new wo(new ArrayBuffer(1)))!=rs||Io&&ee(new Io)!=os||vo&&ee(vo.resolve())!=ss||No&&ee(new No)!=is||To&&ee(new To)!=ns)&&(ee=function(a){var o=oi(a),t=o==qh?a.constructor:void 0,e=t?Ce(t):"";if(e)switch(e){case Jh:return rs;case Xh:return os;case Kh:return ss;case _h:return is;case tu:return ns}return o});var lo=ee,eu=Object.prototype,ou=eu.hasOwnProperty;function su(a){var o=a.length,t=new a.constructor(o);return o&&typeof a[0]=="string"&&ou.call(a,"index")&&(t.index=a.index,t.input=a.input),t}var iu=su,nu=Bt,ru=nu.Uint8Array,si=ru,as=si;function au(a){var o=new a.constructor(a.byteLength);return new as(o).set(new as(a)),o}var Bo=au,cu=Bo;function lu(a,o){var t=o?cu(a.buffer):a.buffer;return new a.constructor(t,a.byteOffset,a.byteLength)}var hu=lu,uu=/\w*$/;function du(a){var o=new a.constructor(a.source,uu.exec(a));return o.lastIndex=a.lastIndex,o}var pu=du,cs=oo,ls=cs?cs.prototype:void 0,hs=ls?ls.valueOf:void 0;function fu(a){return hs?Object(hs.call(a)):{}}var gu=fu,Mu=Bo;function yu(a,o){var t=o?Mu(a.buffer):a.buffer;return new a.constructor(t,a.byteOffset,a.length)}var mu=yu,wu=Bo,Iu=hu,vu=pu,Nu=gu,Tu=mu,Su="[object Boolean]",Cu="[object Date]",ku="[object Map]",xu="[object Number]",zu="[object RegExp]",bu="[object Set]",Pu="[object String]",Lu="[object Symbol]",Du="[object ArrayBuffer]",ju="[object DataView]",Au="[object Float32Array]",Eu="[object Float64Array]",Ou="[object Int8Array]",Ru="[object Int16Array]",Yu="[object Int32Array]",Wu="[object Uint8Array]",Uu="[object Uint8ClampedArray]",Bu="[object Uint16Array]",Fu="[object Uint32Array]";function Vu(a,o,t){var e=a.constructor;switch(o){case Du:return wu(a);case Su:case Cu:return new e(+a);case ju:return Iu(a,t);case Au:case Eu:case Ou:case Ru:case Yu:case Wu:case Uu:case Bu:case Fu:return Tu(a,t);case ku:return new e;case xu:case Pu:return new e(a);case zu:return vu(a);case bu:return new e;case Lu:return Nu(a)}}var Hu=Vu,Qu=_t,us=Object.create,$u=function(){function a(){}return function(o){if(!Qu(o))return{};if(us)return us(o);a.prototype=o;var t=new a;return a.prototype=void 0,t}}(),Gu=$u,Zu=Gu,qu=Ks,Ju=Ro;function Xu(a){return typeof a.constructor=="function"&&!Ju(a)?Zu(qu(a)):{}}var Ku=Xu,_u=lo,td=Zt,ed="[object Map]";function od(a){return td(a)&&_u(a)==ed}var sd=od,id=sd,nd=Eo,ds=Oo,ps=ds&&ds.isMap,rd=ps?nd(ps):id,ad=rd,cd=lo,ld=Zt,hd="[object Set]";function ud(a){return ld(a)&&cd(a)==hd}var dd=ud,pd=dd,fd=Eo,fs=Oo,gs=fs&&fs.isSet,gd=gs?fd(gs):pd,ii=gd;const Md=Ie(ii);var yd=Bs,md=Wa,wd=Vs,Id=bl,vd=$l,Nd=Gl,Td=ql,Sd=ah,Cd=Ih,kd=ei,xd=Dh,zd=lo,bd=iu,Pd=Hu,Ld=Ku,Dd=co,jd=Ao,Ad=ad,Ed=_t,Od=ii,Rd=Yo,Yd=Wo,Wd=1,Ud=2,Bd=4,ni="[object Arguments]",Fd="[object Array]",Vd="[object Boolean]",Hd="[object Date]",Qd="[object Error]",ri="[object Function]",$d="[object GeneratorFunction]",Gd="[object Map]",Zd="[object Number]",ai="[object Object]",qd="[object RegExp]",Jd="[object Set]",Xd="[object String]",Kd="[object Symbol]",_d="[object WeakMap]",tp="[object ArrayBuffer]",ep="[object DataView]",op="[object Float32Array]",sp="[object Float64Array]",ip="[object Int8Array]",np="[object Int16Array]",rp="[object Int32Array]",ap="[object Uint8Array]",cp="[object Uint8ClampedArray]",lp="[object Uint16Array]",hp="[object Uint32Array]",pt={};pt[ni]=pt[Fd]=pt[tp]=pt[ep]=pt[Vd]=pt[Hd]=pt[op]=pt[sp]=pt[ip]=pt[np]=pt[rp]=pt[Gd]=pt[Zd]=pt[ai]=pt[qd]=pt[Jd]=pt[Xd]=pt[Kd]=pt[ap]=pt[cp]=pt[lp]=pt[hp]=!0;pt[Qd]=pt[ri]=pt[_d]=!1;function Fe(a,o,t,e,s,i){var n,r=o&Wd,c=o&Ud,l=o&Bd;if(t&&(n=s?t(a,e,s,i):t(a)),n!==void 0)return n;if(!Ed(a))return a;var h=Dd(a);if(h){if(n=bd(a),!r)return Td(a,n)}else{var u=zd(a),d=u==ri||u==$d;if(jd(a))return Nd(a,r);if(u==ai||u==ni||d&&!s){if(n=c||d?{}:Ld(a),!r)return c?Cd(a,vd(n,a)):Sd(a,Id(n,a))}else{if(!pt[u])return s?a:{};n=Pd(a,u,r)}}i||(i=new yd);var p=i.get(a);if(p)return p;i.set(a,n),Od(a)?a.forEach(function(y){n.add(Fe(y,o,t,y,a,i))}):Ad(a)&&a.forEach(function(y,N){n.set(N,Fe(y,o,t,N,a,i))});var f=l?c?xd:kd:c?Yd:Rd,m=h?void 0:f(a);return md(m||a,function(y,N){m&&(N=y,y=a[N]),wd(n,N,Fe(y,o,t,N,a,i))}),n}var up=Fe,dp=up,pp=1,fp=4;function gp(a){return dp(a,pp|fp)}var Mp=gp;const qt=Ie(Mp),ci="1.1.4",yp="@netless/appliance-plugin",li=typeof OffscreenCanvas=="function"?"worker":"mainThread";if(typeof window<"u"){let a=window.__netlessUA||"";a+=` ${yp}@${ci}_${li}`,window.__netlessUA=a}const Pt={syncOpt:{interval:500},cdn:{subWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/subWorker.js",fullWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/fullWorker.js"},cursor:{expirationTime:5e3},bufferSize:{full:2e4,sub:1e3},bezier:{combineUnitTime:100},pencilEraser:{useBitMap:!0}};function Xt(a,o=!0){const t=a.length;if(t<2)return"";let e=a[0],s=a[1];if(t===2)return`M${ce(e)}L${ce(s)}`;let i="";for(let n=2,r=t-1;n<r;n++)e=a[n],s=a[n+1],i+=le(e,s);return o?`M${le(a[0],a[1])}Q${ce(a[1])}${le(a[1],a[2])}T${i}${le(a[t-1],a[0])}${le(a[0],a[1])}Z`:`M${ce(a[0])}Q${ce(a[1])}${le(a[1],a[2])}${a.length>3?"T":""}${i}L${ce(a[t-1])}`}const bt=class bt{constructor(o){M(this,"syncUnitTime",Pt.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 r=n[0],{pos:c,zIndex:l,scale:h,angle:u,translate:d}=o,p={};Ht(l)&&(p.zIndex=l),c&&(p.pos=[c[0],c[1]]),h&&(p.scale=h),u&&(p.rotate=u),d&&(p.translate=d),r.attr(p);const f=r==null?void 0:r.getBoundingClientRect();return f&&(t=ut(t,{x:Math.floor(f.x-bt.SafeBorderPadding),y:Math.floor(f.y-bt.SafeBorderPadding),w:Math.floor(f.width+bt.SafeBorderPadding*2),h:Math.floor(f.height+bt.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,r=!!i.parent.gl;for(const c of e){const{thickness:l,op:h}=c;for(const u of h){const d=u.map((N,w)=>w%2?N-s[1]:N-s[0]),p=this.computEraserPoints(d,l),f=Xt(p,!0),m={pos:[0,0],d:f,fillColor:"rgba(0,0,0,1)"},y=new lt.Path(m);n&&(y.addEventListener("beforerender",({detail:N})=>{const w=N.context;r?w.blendFuncSeparate(w.ZERO,w.ZERO,w.ZERO,w.ZERO):w.globalCompositeOperation="destination-out"}),y.addEventListener("afterrender",({detail:N})=>{const w=N.context;r?w.blendFuncSeparate(w.SRC_ALPHA,w.ONE_MINUS_SRC_ALPHA,w.ONE,w.ONE_MINUS_SRC_ALPHA):w.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 F(o[0],o[1]);return F.GetDotStroke(e,t,8)}computLine(o,t){const e=[],s=[];let i,n;for(let r=0;r<o.length;r+=2){const c=new F(o[r],o[r+1]);let l;if(r==o.length-2){const h=new F(o[r-2],o[r-1]);l=k.Sub(c,h).uni(),i=c}else{r===0&&(n=c);const h=new F(o[r+2],o[r+3]);l=k.Sub(h,c).uni()}if(l){const h=k.Per(l).mul(t);e.push(F.Sub(c,h)),s.push(F.Add(c,h))}}if(i&&n){const r=F.GetSemicircleStroke(i,e[e.length-1],-1,8),c=F.GetSemicircleStroke(n,s[0],-1,8);return e.concat(r,s.reverse(),c)}return[]}replace(o,t,e){var r;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?(r=this.drawLayer)==null||r.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 w;const{node:t,opt:e,vNodes:s,willSerializeData:i,targetNode:n}=o,{zIndex:r,translate:c,angle:l,originPoint:h,scenePoint:u,scale:d,pointMap:p,thickness:f}=e;let m;const y=n&&qt(n)||s.get(t.name);if(!y)return;Ht(r)&&(t.setAttribute("zIndex",r),y.opt.zIndex=r);const N=t.parent;if(N){if(h&&d&&n){const I=[y.op[0],y.op[1]];Fo(y.op,u,d,c);const S=[y.op[0],y.op[1]],v=[S[0]-I[0],S[1]-I[1]];if(y.centerPos=[y.centerPos[0]+v[0],y.centerPos[1]+v[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++)Vo(x[A],u,d,c)}}else if(c)if(t.setAttribute("translate",c),y.opt.translate=c,n){const I=[c[0]*N.worldScaling[0],c[1]*N.worldScaling[1]];m=So(y.rect,I),y.rect=m}else{const I=bt.getRectFromLayer(N,t.name);y.rect=I||y.rect}else if(Ht(l))if(t.setAttribute("rotate",l),y.opt.rotate=l,n)m=Ci(y.rect,l),y.rect=m;else{const I=bt.getRectFromLayer(N,t.name);y.rect=I||y.rect}if(p){const I=p.get(t.name);if(I)for(let S=0,v=0;S<y.op.length;S+=3,v++)y.op[S]=I[v][0],y.op[S+1]=I[v][1]}if(f&&((w=y==null?void 0:y.opt)!=null&&w.thickness)&&(y.opt.thickness=f),i&&!(h&&d&&n)){if(c){const I=y.op.map((S,v)=>{const T=v%3;return T===0?S+c[0]:T===1?S+c[1]:S});if(y.op=I,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 S of Object.values(y.opt.eraserlines)){const{op:v}=S;for(let T=0;T<v.length;T++){const x=v[T].map((b,A)=>A%2?b+c[1]:b+c[0]);S.op[T]=x}}}else if(Ht(l)){const I=y.op;if(Df(I,y.centerPos,l),y.op=I,y!=null&&y.opt&&(y.opt.rotate=void 0),y.opt.eraserlines)for(const S of Object.values(y.opt.eraserlines)){const{op:v}=S;for(let T=0;T<v.length;T++)jf(v[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-bt.SafeBorderPadding),y:Math.floor(s.y-bt.SafeBorderPadding),w:Math.floor(s.width+bt.SafeBorderPadding*2),h:Math.floor(s.height+bt.SafeBorderPadding*2)}}}};M(bt,"SafeBorderPadding",10);let W=bt;function ke(a){return JSON.parse(Ds.decompress(a))}function Lt(a){return Ds.compress(JSON.stringify(a))}const Ct=Object.keys;class hi extends W{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 r;const t=(r=this.workId)==null?void 0:r.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:V.Local}}setWorkOptions(t){super.setWorkOptions(t),this.syncTimestamp=Date.now()}consume(t){const{data:e,isFullWork:s,isSubWorker:i,isMainThread:n,drawCount:r,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:r==null?void 0:r.toString()};let f,m=!1;const y=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),h.length&&(h[0].taskId-this.syncTimestamp>this.syncUnitTime&&(m=!0,this.syncTimestamp=h[0].taskId,this.syncIndex=this.tmpPoints.length),i||n)){const w=s?this.fullLayer:this.drawLayer||this.fullLayer;f=this.draw({attrs:p,tasks:h,effects:u,layer:w,replaceId:c})}if(i)return d>10&&this.tmpPoints.splice(0,d-10),{rect:f,type:z.DrawWork,dataType:V.Local};const N=[];return this.tmpPoints.slice(y).forEach(w=>{N.push(w.x,w.y,this.computRadius(w.z,this.workOptions.thickness))}),{...this.baseConsumeResult,type:z.DrawWork,dataType:V.Local,rect:f,op:m?N:void 0,index:m?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===D.Done&&this.workOptions.strokeType===_.Stroke&&this.updateTempPointsWithPressureWhenDone(u)}const s=this.transformDataAll(!0),i={name:e};let n;const r=this.fullLayer;if(s.length&&(n=this.draw({attrs:i,tasks:s,replaceId:e,layer:r})),this.tmpPoints.length<2)return this.replace(r,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=Lt(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&&W.getCenterPos(n,r)}),{...this.baseConsumeResult,rect:n,type:z.FullWork,dataType:V.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 F(e[d],e[d+1],e[d+2]);if(this.tmpPoints.length>0){const f=this.tmpPoints[this.tmpPoints.length-1],m=k.Sub(p,f).uni();p.setv(m)}this.tmpPoints.push(p)}if(this.tmpPoints.length<2)return;const n=this.transformDataAll(!0),r=(h=this.workId)==null?void 0:h.toString(),c={name:r};let l;if(r&&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(r,{rect:l,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:l&&W.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:r}=t,{strokeColor:c,strokeType:l,thickness:h,zIndex:u,scale:d,rotate:p,translate:f,eraserlines:m}=this.workOptions;n!=null&&n.size&&(n.forEach(v=>{var T;(T=r.getElementById(v+""))==null||T.remove()}),n.clear());let y;const N=[],w=r.worldPosition,I=r.worldScaling;for(let v=0;v<s.length;v++){const{pos:T,points:x}=s[v],{ps:b,rect:A}=this.computDrawPoints(x);let O;const j=x.length===1;l===_.Stroke||j?O=Xt(b,!0):O=Xt(b,!1);const E={pos:T,d:O,fillColor:l===_.Stroke||j?c:void 0,lineDash:l===_.Dotted&&!j?[1,h*2]:l===_.LongDotted&&!j?[h,h*2]:void 0,strokeColor:c,lineCap:l===_.Stroke||j?void 0:"round",lineWidth:l===_.Stroke||j?0:h};y=ut(y,{x:Math.floor((A.x+T[0])*I[0]+w[0]-W.SafeBorderPadding),y:Math.floor((A.y+T[1])*I[1]+w[1]-W.SafeBorderPadding),w:Math.floor(A.w*I[0]+2*W.SafeBorderPadding),h:Math.floor(A.h*I[1]+2*W.SafeBorderPadding)}),N.push(E)}d&&(e.scale=d),p&&(e.rotate=p),f&&(e.translate=f);const S=new lt.Group;if(y){this.centerPos=W.getCenterPos(y,r);const v=l===_.Stroke&&!m;S.attr({...e,normalize:!0,anchor:[.5,.5],bgcolor:v?c:void 0,pos:this.centerPos,size:[(y.w-2*W.SafeBorderPadding)/I[0],(y.h-2*W.SafeBorderPadding)/I[1]],zIndex:u});const T=N.map(x=>(x.pos=[x.pos[0]-this.centerPos[0],x.pos[1]-this.centerPos[1]],new lt.Path(x)));S.append(...T),v&&S.seal(),m&&this.drawEraserlines({group:S,eraserlines:m,pos:this.centerPos,layer:r}),this.replace(r,i||e.workId,S)}if(d||p||f){const v=S==null?void 0:S.getBoundingClientRect();if(v)return{x:Math.floor(v.x-W.SafeBorderPadding),y:Math.floor(v.y-W.SafeBorderPadding),w:Math.floor(v.width+W.SafeBorderPadding*2),h:Math.floor(v.height+W.SafeBorderPadding*2)}}return y}computDrawPoints(t){return this.workOptions.strokeType===_.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(F.Sub(h,p)),s.push(F.Add(h,p))}const i=t[t.length-1],n=F.GetSemicircleStroke(i.point,e[e.length-1],-1,8),r=F.GetSemicircleStroke(t[0].point,s[0],-1,8),c=e.concat(n,s.reverse(),r);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:F.GetDotStroke(e,s,8),rect:i}}transformData(t,e){const{op:s,workState:i}=t;let n=this.tmpPoints.length-1,r=[];if(s!=null&&s.length&&i){const{strokeType:c,thickness:l}=this.workOptions,h=new Set;n=c===_.Stroke?this.updateTempPointsWithPressure(s,l,h):this.updateTempPoints(s,l,h);const u=e?this.tmpPoints:this.tmpPoints.slice(n);return r=this.getTaskPoints(u,l),{tasks:r,effects:h,consumeIndex:n}}return{tasks:r,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,r=t[0].y,c=[n,r],l=[],h=t[0].t;for(;i<t.length;){const d=t[i],p=d.x-n,f=d.y-r,m=d.z,y=e?this.computRadius(m,e):m;if(l.push({point:new F(p,f,m,t[i].v),radius:y}),i>0&&i<t.length-1){const N=t[i].getAngleByPoints(t[i-1],t[i+1]);if(N<90||N>270){const w=(u=l.pop())==null?void 0:u.point.clone();w&&s.push({taskId:h,pos:c,points:[...l,{point:w,radius:y}]}),n=t[i].x,r=t[i].y,c=[n,r];const I=d.x-n,S=d.y-r;l=[{point:new F(I,S,m),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 r=n;for(let l=0;l<t.length;l+=2){r=Math.min(r,n);const h=this.tmpPoints.length,u=new F(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)),r=Math.min(r,d),h>1){let N=h-1;for(;N>0;){const w=this.tmpPoints[N].distance(this.tmpPoints[N-1]),I=Math.max(this.tmpPoints[N].z-this.uniThickness*w,0);if(this.tmpPoints[N-1].z>=I)break;this.tmpPoints[N-1].setz(I),r=Math.min(r,N-1),N--}}}else r=1/0;continue}u.setv(f);const m=u.distance(p),y=Math.max(p.z-this.uniThickness*m,0);h>1&&k.Equals(f,p.v,.02)&&(y>0||p.z<=0)&&(s&&p.t&&s.add(p.t),this.tmpPoints.pop(),r=Math.min(d,r)),u.setz(y),this.tmpPoints.push(u)}if(r===1/0)return this.tmpPoints.length;let c=n;if(r===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=r;l>=0;){const h=this.tmpPoints[l].t;if(h&&(s==null||s.add(h),l<=r)){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 r=n;for(let h=0;h<t.length;h+=2){const u=this.tmpPoints.length,d=new F(t[h],t[h+1]);if(u===0){this.tmpPoints.push(d);continue}const p=u-1,f=this.tmpPoints[p],m=k.Sub(d,f).uni();if(d.isNear(f,e/2)){r=Math.min(p,r);continue}k.Equals(m,f.v,.02)&&(s&&f.t&&s.add(f.t),this.tmpPoints.pop(),r=Math.min(p,r)),d.setv(m),this.tmpPoints.push(d)}let c=n;if(r===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,r);for(c=r;h>=0;){const u=(l=this.tmpPoints[h])==null?void 0:l.t;if(u&&(s==null||s.add(u),h<=r)){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 r=this.tmpPoints.length,c=new F(t[n],t[n+1]);if(r===0){this.tmpPoints.push(c);continue}const l=r-1,h=this.tmpPoints[l],u=k.Sub(c,h).uni(),d=c.distance(h);if(r>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)),r>1)){let f=r-1;for(;f>0;){const m=this.tmpPoints[f].distance(this.tmpPoints[f-1]),y=Math.max(this.tmpPoints[f].z-this.uniThickness*m,-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);r>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:r}=s,c=i.get(e.name);return n&&(e.tagName==="GROUP"?Ef(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)),r&&(c!=null&&c.opt)&&((h=c.opt)!=null&&h.strokeType)&&(c.opt.strokeType=r),c&&i.setInfo(e.name,c),W.updateNodeOpt(t)}}class ui extends W{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:r,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===_.Dotted?[1,c*2]:l===_.LongDotted?[c,c*2]:void 0,strokeColor:r,lineCap:"round",lineWidth:c,anchor:[.5,.5]},m=this.getTaskPoints(p);if(m.length){const N=Date.now();N-this.syncTimestamp>this.syncUnitTime&&(u=!0,this.syncTimestamp=N,this.syncIndex=this.tmpPoints.length),s&&this.draw({attrs:f,tasks:m,isDot:!1,layer:this.drawLayer||this.fullLayer})}const y=[];return this.tmpPoints.slice(d).forEach(N=>{y.push(N.x,N.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:V.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 r=this.tmpPoints.slice(this.consumeIndex);const c=r.length===1,{strokeColor:l,thickness:h,strokeType:u}=this.workOptions;if(c){const f=this.computDotStroke({point:r[0],radius:h/2});r=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===_.Dotted&&!c?[1,h*2]:u===_.LongDotted&&!c?[h,h*2]:void 0,strokeColor:l,lineCap:c?void 0:"round",lineWidth:c?0:h,anchor:[.5,.5]},p=this.getTaskPoints(r);p.length&&this.draw({attrs:d,tasks:p,isDot:c,layer:this.drawLayer||this.fullLayer})}const s=[];this.tmpPoints.forEach(r=>{s.push(r.x,r.y)});const i=Lt(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:V.Local,ops:i,index:this.syncIndex*2,...this.baseConsumeResult}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(t){var m;const{op:e,replaceId:s,isFullWork:i}=t,{strokeColor:n,thickness:r,strokeType:c}=this.workOptions;if(!e.length){const y=dt(this.tmpPoints,r);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:r/2});u=y.ps,h=y.rect}else h=dt(this.tmpPoints,r);const p={name:(m=this.workId)==null?void 0:m.toString(),fillColor:d?n:void 0,opacity:1,lineDash:c===_.Dotted&&!d?[1,r*2]:c===_.LongDotted&&!d?[r,r*2]:void 0,strokeColor:n,lineCap:d?void 0:"round",lineWidth:d?0:r,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:F.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 F(t[s],t[s+1]))}}async draw(t){const{attrs:e,tasks:s,isDot:i,layer:n}=t,{duration:r}=this.workOptions;for(const c of s){const l=new lt.Path,{pos:h,points:u}=c;let d;i?d=Xt(u,!0):d=Xt(u,!1),l.attr({...e,pos:h,d});const{vertex:p,fragment:f}=this.workOptions;if(p&&f){const m=n.renderer.createProgram({vertex:p,fragment:f}),{width:y,height:N}=n.getResolution();l.setUniforms({u_time:0,u_resolution:[y,N]}),l.setProgram(m)}n.appendChild(l),l.transition(r).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,r=[i,n],c=[];for(;s<t.length;){const h=t[s],u=h.x-i,d=h.y-n;if(c.push(new F(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:r,points:[...c,f]}),i=t[s].x,n=t[s].y,r=[i,n];const m=h.x-i,y=h.y-n;c=[new F(m,y)]}}s++}return e.push({pos:r,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 fe=class fe extends W{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}=fe.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:r,height:c}=fe.eraserSizes[this.workOptions.thickness],l=Math.min(r,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:r}=fe.eraserSizes[this.workOptions.thickness];return k.Dist(s,i)<Math.hypot(n,r)*.5}remove(t){const{curNodeMap:e,removeIds:s}=t;let i;for(const n of e.values())if(n.rect&&this.eraserRect&&this.eraserPolyline&&Ae(this.eraserRect,n.rect)){const{op:r}=n,c=[],l=[];for(let u=0;u<r.length;u+=3){const d=new k(r[u]*this.worldScaling[0]+this.worldPosition[0],r[u+1]*this.worldScaling[1]+this.worldPosition[1],r[u+2]);l.push(d),c.push(new F(d.x,d.y))}const h=c.length&&dt(c)||n.rect;Ae(h,this.eraserRect)&&(l.length>1?Po.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 r=this.fullLayer.getElementsByName(n);this.fullLayer.removeChild(r[0]),(c=this.vNodes)==null||c.delete(n)}),i&&(i.x-=W.SafeBorderPadding,i.y-=W.SafeBorderPadding,i.w+=W.SafeBorderPadding*2,i.h+=W.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 r=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:r});n=ut(n,h)}return n&&r.size?{type:z.RemoveNode,rect:n,removeIds:[...r]}:{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 r of i.values())if((e=r.selectIds)!=null&&e.length)for(const c of r.selectIds)s.delete(c);for(const r of n.keys())s.delete(r);return s}return t}};M(fe,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));let Ge=fe;const Ut="++",H="selector",Ve="all";var mp="__lodash_hash_undefined__";function wp(a){return this.__data__.set(a,mp),this}var Ip=wp;function vp(a){return this.__data__.has(a)}var Np=vp,Tp=Us,Sp=Ip,Cp=Np;function Ze(a){var o=-1,t=a==null?0:a.length;for(this.__data__=new Tp;++o<t;)this.add(a[o])}Ze.prototype.add=Ze.prototype.push=Sp;Ze.prototype.has=Cp;var kp=Ze;function xp(a,o){for(var t=-1,e=a==null?0:a.length;++t<e;)if(o(a[t],t,a))return!0;return!1}var zp=xp;function bp(a,o){return a.has(o)}var Pp=bp,Lp=kp,Dp=zp,jp=Pp,Ap=1,Ep=2;function Op(a,o,t,e,s,i){var n=t&Ap,r=a.length,c=o.length;if(r!=c&&!(n&&c>r))return!1;var l=i.get(a),h=i.get(o);if(l&&h)return l==o&&h==a;var u=-1,d=!0,p=t&Ep?new Lp:void 0;for(i.set(a,o),i.set(o,a);++u<r;){var f=a[u],m=o[u];if(e)var y=n?e(m,f,u,o,a,i):e(f,m,u,a,o,i);if(y!==void 0){if(y)continue;d=!1;break}if(p){if(!Dp(o,function(N,w){if(!jp(p,w)&&(f===N||s(f,N,t,e,i)))return p.push(w)})){d=!1;break}}else if(!(f===m||s(f,m,t,e,i))){d=!1;break}}return i.delete(a),i.delete(o),d}var di=Op;function Rp(a){var o=-1,t=Array(a.size);return a.forEach(function(e,s){t[++o]=[s,e]}),t}var Yp=Rp;function Wp(a){var o=-1,t=Array(a.size);return a.forEach(function(e){t[++o]=e}),t}var Up=Wp,Ms=oo,ys=si,Bp=Do,Fp=di,Vp=Yp,Hp=Up,Qp=1,$p=2,Gp="[object Boolean]",Zp="[object Date]",qp="[object Error]",Jp="[object Map]",Xp="[object Number]",Kp="[object RegExp]",_p="[object Set]",tf="[object String]",ef="[object Symbol]",of="[object ArrayBuffer]",sf="[object DataView]",ms=Ms?Ms.prototype:void 0,go=ms?ms.valueOf:void 0;function nf(a,o,t,e,s,i,n){switch(t){case sf:if(a.byteLength!=o.byteLength||a.byteOffset!=o.byteOffset)return!1;a=a.buffer,o=o.buffer;case of:return!(a.byteLength!=o.byteLength||!i(new ys(a),new ys(o)));case Gp:case Zp:case Xp:return Bp(+a,+o);case qp:return a.name==o.name&&a.message==o.message;case Kp:case tf:return a==o+"";case Jp:var r=Vp;case _p:var c=e&Qp;if(r||(r=Hp),a.size!=o.size&&!c)return!1;var l=n.get(a);if(l)return l==o;e|=$p,n.set(a,o);var h=Fp(r(a),r(o),e,s,i,n);return n.delete(a),h;case ef:if(go)return go.call(a)==go.call(o)}return!1}var rf=nf,ws=ei,af=1,cf=Object.prototype,lf=cf.hasOwnProperty;function hf(a,o,t,e,s,i){var n=t&af,r=ws(a),c=r.length,l=ws(o),h=l.length;if(c!=h&&!n)return!1;for(var u=c;u--;){var d=r[u];if(!(n?d in o:lf.call(o,d)))return!1}var p=i.get(a),f=i.get(o);if(p&&f)return p==o&&f==a;var m=!0;i.set(a,o),i.set(o,a);for(var y=n;++u<c;){d=r[u];var N=a[d],w=o[d];if(e)var I=n?e(w,N,d,o,a,i):e(N,w,d,a,o,i);if(!(I===void 0?N===w||s(N,w,t,e,i):I)){m=!1;break}y||(y=d=="constructor")}if(m&&!y){var S=a.constructor,v=o.constructor;S!=v&&"constructor"in a&&"constructor"in o&&!(typeof S=="function"&&S instanceof S&&typeof v=="function"&&v instanceof v)&&(m=!1)}return i.delete(a),i.delete(o),m}var uf=hf,Mo=Bs,df=di,pf=rf,ff=uf,Is=lo,vs=co,Ns=Ao,gf=$s,Mf=1,Ts="[object Arguments]",Ss="[object Array]",Ye="[object Object]",yf=Object.prototype,Cs=yf.hasOwnProperty;function mf(a,o,t,e,s,i){var n=vs(a),r=vs(o),c=n?Ss:Is(a),l=r?Ss:Is(o);c=c==Ts?Ye:c,l=l==Ts?Ye:l;var h=c==Ye,u=l==Ye,d=c==l;if(d&&Ns(a)){if(!Ns(o))return!1;n=!0,h=!1}if(d&&!h)return i||(i=new Mo),n||gf(a)?df(a,o,t,e,s,i):pf(a,o,c,t,e,s,i);if(!(t&Mf)){var p=h&&Cs.call(a,"__wrapped__"),f=u&&Cs.call(o,"__wrapped__");if(p||f){var m=p?a.value():a,y=f?o.value():o;return i||(i=new Mo),s(m,y,t,e,i)}}return d?(i||(i=new Mo),ff(a,o,t,e,s,i)):!1}var wf=mf,If=wf,ks=Zt;function pi(a,o,t,e,s){return a===o?!0:a==null||o==null||!ks(a)&&!ks(o)?a!==a&&o!==o:If(a,o,t,e,pi,s)}var vf=pi,Nf=vf;function Tf(a,o){return Nf(a,o)}var Sf=Tf;const de=Ie(Sf),eo=class eo extends W{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 F(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:r}=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(r){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:eo.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:r}=s;(l=(c=e.parent)==null?void 0:c.getElementById(t))==null||l.remove(),n&&this.drawSelector({drawRect:n,subNodeMap:r,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:r,canRotate:c,scaleType:l,toolsType:h}=n;this.selectorColor=this.workOptions.strokeColor,r.strokeColor&&(this.strokeColor=r.strokeColor),r.fillColor&&(this.fillColor=r.fillColor),r.textOpt&&(this.textOpt=r.textOpt),r.thickness&&(this.thickness=r.thickness),h!==C.Pencil&&(i=!1),r.strokeType&&(this.strokeType=r.strokeType),h===C.SpeechBalloon&&(e.add(h),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.placement=r.placement),h===C.Polygon&&(e.add(h),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=r.vertices),h===C.Star&&(e.add(h),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=r.vertices,this.shapeOpt.innerRatio=r.innerRatio,this.shapeOpt.innerVerticeStep=r.innerVerticeStep),h===C.Text&&(this.textOpt=r),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 r=0;r<i.length;r+=3)n.push([i[r],i[r+1]]);return n}}}consume(t){const{op:e,workState:s}=t.data;let i=this.oldSelectRect;if(s===D.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&&de(this.selectIds,n.selectIds))return{type:z.None};this.selectIds=n.selectIds;const r=n.intersectRect;this.getSelecteorInfo(n.subNodeMap),this.draw(H,this.fullLayer,n),this.oldSelectRect=r;const c=this.getChildrenPoints();return{type:z.Select,dataType:V.Local,rect:ut(r,i),selectIds:n.selectIds,selectRect:r,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:V.Local,rect:this.oldSelectRect,selectIds:this.selectIds,selectorColor:this.selectorColor,selectRect:this.oldSelectRect,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points: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 r;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(Ti(u).find(p=>p.isPointCollision(i,n))){r=h;break}}if(r){const h=r.name;if(!de(this.oldSelectRect,r.rect)){const u=new Map([[h,r]]);this.getSelecteorInfo(u),this.draw(e,this.fullLayer,{intersectRect:r.rect,subNodeMap:u,selectIds:this.selectIds||[]},s)}this.selectIds=[h],this.oldSelectRect=r.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 r;let s;const i=(r=t.parent)==null?void 0:r.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 v;const{updateSelectorOpt:e,selectIds:s,vNodes:i,willSerializeData:n,worker:r,offset:c}=t,l=this.fullLayer;if(!l)return;let h;const u=new Map,{originPoint:d,workState:p,angle:f,translate:m,dir:y,scale:N}=e;c&&(m?e.translate=[m[0]+c[0],m[1]+c[1]]:e.translate=c);let w;if(d||m||Ht(f)){if(p===D.Start&&s)return i.setTargetAssignKeys(s),{type:z.Select,dataType:V.Local,selectRect:this.oldSelectRect,rect:this.oldSelectRect};w=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 P;if(b){E.thickness&&x.opt.thickness&&(O=x.opt.thickness!==E.thickness),E.strokeType&&((v=x.opt)!=null&&v.strokeType)&&(j=x.opt.strokeType!==E.strokeType),P=w==null?void 0:w.get(T);const Y=vi(b);if(Y==null||Y.updateNodeOpt({node:A,opt:E,vNodes:i,willSerializeData:n,targetNode:P}),x&&r&&(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 et=r.createWorkShapeNode({workId:T,toolsType:b,toolsOpt:x.opt});et==null||et.setWorkId(T);let tt;if(b===C.Image)tt=await et.consumeServiceAsync({isFullWork:!0,replaceId:T,worker:r});else if(b===C.Text)tt=await et.consumeServiceAsync({isFullWork:!0,replaceId:T});else try{tt=et==null?void 0:et.consumeService({op:x.op,isFullWork:!0,replaceId:T})}catch{continue}tt&&(x.rect=tt)}x&&(u.set(T,x),h=ut(h,x.rect))}}}}w&&p===D.Done&&(i.deleteLastTarget(),w=void 0);const I=h;if(d&&m&&N&&y&&I&&!c){const T=[[I.x,I.y],[I.x+I.w,I.y],[I.x+I.w,I.y+I.h],[I.x,I.y+I.h]];let x;switch(y){case"top":case"topLeft":case"left":m[0]>0&&m[1]>0?x=T[0]:m[0]>0?x=T[3]:m[1]>0?x=T[1]:x=T[2];break;case"topRight":m[0]<0&&m[1]>0?x=T[1]:m[0]<0?x=T[2]:m[1]>0?x=T[0]:x=T[3];break;case"right":case"bottomRight":case"bottom":m[0]<0&&m[1]<0?x=T[2]:m[0]<0?x=T[1]:m[1]<0?x=T[3]:x=T[0];break;case"bottomLeft":m[0]>0&&m[1]<0?x=T[3]:m[0]>0?x=T[0]:m[1]<0?x=T[2]:x=T[1];break}const b=x&&[d[0]-x[0],d[1]-x[1]]||[0,0];if(!de(b,[0,0]))return await this.updateSelector({...t,updateSelectorOpt:{},offset:b})}this.getSelecteorInfo(u),this.draw(H,l,{selectIds:s||[],subNodeMap:u,intersectRect:I});const S=ut(this.oldSelectRect,I);return this.oldSelectRect=I,{type:z.Select,dataType:V.Local,selectRect:I,renderRect:h,rect:ut(S,I),selectIds:s}}blurSelector(){const t=this.unSelectedAllIds();return{type:z.Select,dataType:V.Local,rect:t,selectIds:[],willSyncService:!0}}getRightServiceId(t){return t.replace(Ut,"-")}selectServiceNode(t,e,s){const{selectIds:i}=e,n=this.getRightServiceId(t),r=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,r)}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(r=>!t.includes(r));if(s!=null&&s.length&&(e=this.unSelectedByIds(s)),t.length){const r=this.selectedByIds(t);e=ut(e,r)}this.selectIds=t;const i=this.reRenderSelector();return{bgRect:e,selectRect:i}}cursorHover(t){var n,r;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&&!de(e,this.oldSelectRect))return{type:z.CursorHover,dataType:V.Local,rect:ut(e,this.oldSelectRect),selectorColor:this.selectorColor,willSyncService:!1};if((r=this.selectIds)!=null&&r.length||(this.oldSelectRect=void 0),e&&!this.oldSelectRect)return this.cursorBlur(),{type:z.CursorHover,dataType:V.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(eo,"selectorBorderId","selector-border");let qe=eo;class fi extends W{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,r=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 F(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:r,layer:p})}if(!i){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{...this.baseConsumeResult,type:z.DrawWork,dataType:V.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:V.Local}}consumeAll(){var r;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=Lt(i);return(r=this.vNodes)==null||r.setInfo(t,{rect:s,op:i,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:W.getCenterPos(s,e)}),{rect:s,...this.baseConsumeResult,type:z.FullWork,dataType:V.Local,ops:n,isSync:!0}}draw(t){const{workId:e,layer:s}=t,{strokeColor:i,thickness:n,zIndex:r,scale:c,rotate:l,translate:h,strokeType:u,eraserlines:d}=this.workOptions,p=s.worldPosition,f=s.worldScaling,{points:m,pos:y,rect:N,isTriangle:w,trianglePoints:I,trianglePos:S}=this.computDrawPoints(n),v=[N.x+N.w/2,N.y+N.h/2],T={pos:v,name:e,id:e,zIndex:r,anchor:[.5,.5],size:[N.w,N.h]};c&&(T.scale=c),l&&(T.rotate=l),h&&(T.translate=h);const x=new lt.Group(T),b={points:I,pos:[S[0]-v[0],S[1]-v[1]],fillColor:i,strokeColor:i,lineWidth:0,normalize:!1},A=new lt.Polyline(b);if(x.append(A),!w&&m&&y){const O={points:m,pos:[y[0]-v[0],y[1]-v[1]],fillColor:i,strokeColor:i,lineDash:u===_.Dotted&&!w?[1,n*2]:u===_.LongDotted&&!w?[n,n*2]:void 0,lineCap:u===_.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:v,layer:s}),this.replace(s,e,x),c||l||h){const O=x.getBoundingClientRect();return{x:Math.floor(O.x-W.SafeBorderPadding),y:Math.floor(O.y-W.SafeBorderPadding),w:Math.floor(O.width+W.SafeBorderPadding*2),h:Math.floor(O.height+W.SafeBorderPadding*2)}}return{x:Math.floor(N.x*f[0]+p[0]-W.SafeBorderPadding),y:Math.floor(N.y*f[1]+p[1]-W.SafeBorderPadding),w:Math.floor(N.w*f[0]+2*W.SafeBorderPadding),h:Math.floor(N.h*f[1]+2*W.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=F.Sub(this.tmpPoints[0],s),n=F.Add(this.tmpPoints[0],s),r=k.Mul(e,this.arrowTipWidth),c=k.Sub(this.tmpPoints[1],r),l=F.Sub(c,s),h=F.Add(c,s),u=k.Per(e).mul(t*1.5),d=F.Sub(c,u),p=F.Add(c,u),f=[this.tmpPoints[0],c],m=[d,this.tmpPoints[1],p],y=[i,n,...m,l,h];return{trianglePoints:m.map(N=>F.Sub(N,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,points:f.map(N=>F.Sub(N,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=F.Sub(this.tmpPoints[0],s),n=F.Add(this.tmpPoints[0],s),r=[i,this.tmpPoints[1],n];return{trianglePoints:r.map(c=>F.Sub(c,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,rect:dt(r),isTriangle:!0}}updateTempPoints(t){const e=t.slice(-2),s=new F(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 F(e[h],e[h+1],e[h+2]));const n=s?this.fullLayer:this.drawLayer||this.fullLayer,r=this.draw({workId:i,layer:n});return this.oldRect=r,(l=this.vNodes)==null||l.setInfo(i,{rect:r,op:e,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:W.getCenterPos(r,n)}),r}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var l,h;const{node:e,opt:s,vNodes:i}=t,{strokeColor:n,strokeType:r}=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)),r&&(c!=null&&c.opt)&&((h=c.opt)!=null&&h.strokeType)&&(c.opt.strokeType=r),c&&i.setInfo(e.name,c),W.updateNodeOpt(t)}}class gi extends W{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,r=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 F(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:r,layer:p,isDrawing:!0})}if(!i){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:z.DrawWork,dataType:V.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:V.Local,...this.baseConsumeResult}}consumeAll(){var r;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=Lt(i);return(r=this.vNodes)==null||r.setInfo(t,{rect:s,op:i,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:s&&W.getCenterPos(s,e)}),{rect:s,type:z.FullWork,dataType:V.Local,...this.baseConsumeResult,ops:n,isSync:!0}}draw(t){const{workId:e,layer:s,isDrawing:i}=t,{strokeColor:n,fillColor:r,thickness:c,zIndex:l,scale:h,rotate:u,translate:d,strokeType:p,eraserlines:f}=this.workOptions,m=s.worldScaling,{radius:y,rect:N,pos:w}=this.computDrawPoints(c),I={pos:w,name:e,id:e,radius:y,lineWidth:c,fillColor:r!=="transparent"&&r||void 0,strokeColor:n,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:p===_.Dotted?[1,c*2]:p===_.LongDotted?[c,c*2]:void 0},S={name:e,id:e,zIndex:l,pos:w,anchor:[.5,.5],size:[N.w,N.h]};h&&(S.scale=h),u&&(S.rotate=u),d&&(S.translate=d);const v=new lt.Group(S);if(i){const b=new lt.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:n,lineWidth:1,scale:[1/m[0],1/m[1]]});v.append(b)}const T=new lt.Ellipse({...I,pos:[0,0]});v.append(T),f&&this.drawEraserlines({group:v,eraserlines:f,pos:w,layer:s}),this.replace(s,e,v);const x=v.getBoundingClientRect();return{x:Math.floor(x.x-W.SafeBorderPadding),y:Math.floor(x.y-W.SafeBorderPadding),w:Math.floor(x.width+W.SafeBorderPadding*2),h:Math.floor(x.height+W.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 F(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 F(e[h],e[h+1],e[h+2]));const n=s?this.fullLayer:this.drawLayer||this.fullLayer,r=this.draw({workId:i,layer:n,isDrawing:!1});return this.oldRect=r,(l=this.vNodes)==null||l.setInfo(i,{rect:r,op:e,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:W.getCenterPos(r,n)}),r}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var u,d,p;const{node:e,opt:s,vNodes:i}=t,{strokeColor:n,fillColor:r,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)),r&&(r==="transparent"?h.setAttribute("fillColor","rgba(0,0,0,0)"):h.setAttribute("fillColor",r),(d=l==null?void 0:l.opt)!=null&&d.fillColor&&(l.opt.fillColor=r)),c&&(l!=null&&l.opt)&&((p=l.opt)!=null&&p.strokeType)&&(l.opt.strokeType=c),l&&i.setInfo(e.name,l),W.updateNodeOpt(t)}}class Mi extends W{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 r of t)s.push(new k(...r));const i=dt(s,e),n=[i.x+i.w/2,i.y+i.h/2];return{rect:i,pos:n,points:s.map(r=>r.XY).flat(1)}}consume(t){const{data:e,isFullWork:s,isSubWorker:i,isMainThread:n}=t,r=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 F(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:r,layer:f,isDrawing:!0})}if(!i){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:z.DrawWork,dataType:V.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:V.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),r=Lt(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&&W.getCenterPos(i,s)}),{rect:i,type:z.FullWork,dataType:V.Local,ops:r,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:s,isDrawing:i,ps:n,replaceId:r}=t,{strokeColor:c,fillColor:l,thickness:h,zIndex:u,scale:d,rotate:p,translate:f,strokeType:m,eraserlines:y}=this.workOptions,N=s.worldPosition,w=s.worldScaling,{points:I,rect:S,pos:v}=this.computDrawPoints(n),T={close:!0,normalize:!0,points:I,lineWidth:h,fillColor:l!=="transparent"&&l||void 0,strokeColor:c,lineJoin:"round",lineCap:"round",lineDash:m===_.Dotted?[1,h*2]:m===_.LongDotted?[h,h*2]:void 0},x={x:Math.floor(S.x*w[0]+N[0]-W.SafeBorderPadding),y:Math.floor(S.y*w[1]+N[1]-W.SafeBorderPadding),w:Math.floor(S.w*w[0]+2*W.SafeBorderPadding),h:Math.floor(S.h*w[0]+2*W.SafeBorderPadding)},b=new lt.Group({name:e,id:e,zIndex:u,pos:v,anchor:[.5,.5],size:[S.w,S.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/w[0],1/w[1]]});b.appendChild(O)}if(y&&this.drawEraserlines({group:b,eraserlines:y,pos:v,layer:s}),this.replace(s,r||e,b),d||p||f){const O=b.getBoundingClientRect();return{x:Math.floor(O.x-W.SafeBorderPadding),y:Math.floor(O.y-W.SafeBorderPadding),w:Math.floor(O.width+2*W.SafeBorderPadding),h:Math.floor(O.height+2*W.SafeBorderPadding)}}return x}updateTempPoints(t){const e=t.slice(-2),s=new F(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 r=[];for(let d=0;d<e.length;d+=3)r.push([e[d],e[d+1],e[d+2]]);const c=s?this.fullLayer:this.drawLayer||this.fullLayer,l=this.draw({ps:r,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&&W.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:r,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)),r&&(r==="transparent"?h.setAttribute("fillColor","rgba(0,0,0,0)"):h.setAttribute("fillColor",r),(d=l==null?void 0:l.opt)!=null&&d.fillColor&&(l.opt.fillColor=r)),c&&(l!=null&&l.opt)&&((p=l.opt)!=null&&p.strokeType)&&(l.opt.strokeType=c),l&&i.setInfo(e.name,l),W.updateNodeOpt(t)}}class yi extends W{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,r=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 F(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:r,layer:p,isDrawing:!0})}if(!i){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:z.DrawWork,dataType:V.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:V.Local,...this.baseConsumeResult}}consumeAll(){var r;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=Lt(i);return(r=this.vNodes)==null||r.setInfo(t,{rect:s,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&W.getCenterPos(s,e)}),{rect:s,type:z.FullWork,dataType:V.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:s,isDrawing:i}=t,{strokeColor:n,fillColor:r,thickness:c,zIndex:l,vertices:h,innerVerticeStep:u,innerRatio:d,scale:p,rotate:f,translate:m,strokeType:y,eraserlines:N}=this.workOptions,w=s.worldScaling,{rect:I,pos:S,points:v}=this.computDrawPoints(c,h,u,d),T={close:!0,points:v,lineWidth:c,fillColor:r!=="transparent"&&r||void 0,strokeColor:n,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:y===_.Dotted?[1,c*2]:y===_.LongDotted?[c,c*2]:void 0},x={name:e,id:e,zIndex:l,pos:S,anchor:[.5,.5],size:[I.w,I.h]};p&&(x.scale=p),f&&(x.rotate=f),m&&(x.translate=m);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/w[0],1/w[1]]});b.append(j)}const A=new lt.Polyline({...T,pos:[0,0]});b.append(A),N&&this.drawEraserlines({group:b,eraserlines:N,pos:S,layer:s}),this.replace(s,e,b);const O=b.getBoundingClientRect();return{x:Math.floor(O.x-W.SafeBorderPadding),y:Math.floor(O.y-W.SafeBorderPadding),w:Math.floor(O.width+W.SafeBorderPadding*2),h:Math.floor(O.height+W.SafeBorderPadding*2)}}computDrawPoints(t,e,s,i){const n=dt(this.tmpPoints),r=[Math.floor(n.x+n.w/2),Math.floor(n.y+n.h/2)],c=xi(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 m=f*d-.5*Math.PI;let y,N;f%s===1?(y=h*c[0]*Math.cos(m),N=h*c[1]*Math.sin(m)):(y=l*c[0]*Math.cos(m),N=l*c[1]*Math.sin(m),u.push(y,N)),u.push(y,N)}return{rect:dt(this.tmpPoints,t),pos:r,points:u}}updateTempPoints(t){const e=t.slice(-2),s=new F(e[0],e[1]),i=this.tmpPoints[0],{thickness:n}=this.workOptions;if(i.isNear(s,n)||F.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 F(e[h],e[h+1],e[h+2]));const n=s?this.fullLayer:this.drawLayer||this.fullLayer,r=this.draw({workId:i,layer:n,isDrawing:!1});return this.oldRect=r,(l=this.vNodes)==null||l.setInfo(i,{rect:r,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:r&&W.getCenterPos(r,n)}),r}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var y;const{node:e,opt:s,vNodes:i}=t,{strokeColor:n,fillColor:r,toolsType:c,vertices:l,innerVerticeStep:h,innerRatio:u,strokeType:d}=s,p=i.get(e.name),f=p==null?void 0:p.opt;let m=e;return e.tagName==="GROUP"&&(m=e.children[0]),n&&(m.setAttribute("strokeColor",n),f!=null&&f.strokeColor&&(f.strokeColor=n)),r&&(r==="transparent"?m.setAttribute("fillColor","rgba(0,0,0,0)"):m.setAttribute("fillColor",r),f!=null&&f.fillColor&&(f.fillColor=r)),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}),W.updateNodeOpt(t)}}class mi extends W{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:r}=e,c=this.workId,l=r==null?void 0:r.length;if(!l||l<2)return{type:z.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new F(r[0],r[1])],h=!1):h=this.updateTempPoints(r),!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:V.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:V.Local,...this.baseConsumeResult}}consumeAll(){var r;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=Lt(i);return(r=this.vNodes)==null||r.setInfo(t,{rect:s,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&W.getCenterPos(s,e)}),{rect:s,type:z.FullWork,dataType:V.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:s,isDrawing:i}=t,{strokeColor:n,fillColor:r,thickness:c,zIndex:l,vertices:h,scale:u,rotate:d,translate:p,strokeType:f,eraserlines:m}=this.workOptions,y=s.worldScaling,{rect:N,pos:w,points:I}=this.computDrawPoints(c,h),S={close:!0,points:I,lineWidth:c,fillColor:r!=="transparent"&&r||void 0,strokeColor:n,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:f===_.Dotted?[1,c*2]:f===_.LongDotted?[c,c*2]:void 0},v={name:e,id:e,zIndex:l,pos:w,anchor:[.5,.5],size:[N.w,N.h]};u&&(v.scale=u),d&&(v.rotate=d),p&&(v.translate=p);const T=new lt.Group(v);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({...S,pos:[0,0]});T.append(x),m&&this.drawEraserlines({group:T,eraserlines:m,pos:w,layer:s}),this.replace(s,e,T);const b=T.getBoundingClientRect();return{x:Math.floor(b.x-W.SafeBorderPadding),y:Math.floor(b.y-W.SafeBorderPadding),w:Math.floor(b.width+W.SafeBorderPadding*2),h:Math.floor(b.height+W.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=xi(s.w,s.h),r=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=r*n[0]*Math.cos(d),f=r*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 F(e[0],e[1]),i=this.tmpPoints[0],{thickness:n}=this.workOptions;if(i.isNear(s,n)||F.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 F(e[h],e[h+1],e[h+2]));const n=s?this.fullLayer:this.drawLayer||this.fullLayer,r=this.draw({workId:i,layer:n,isDrawing:!1});return this.oldRect=r,(l=this.vNodes)==null||l.setInfo(i,{rect:r,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:r&&W.getCenterPos(r,n)}),r}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var f;const{node:e,opt:s,vNodes:i}=t,{strokeColor:n,fillColor:r,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)),r&&(r==="transparent"?p.setAttribute("fillColor","rgba(0,0,0,0)"):p.setAttribute("fillColor",r),d!=null&&d.fillColor&&(d.fillColor=r)),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}),W.updateNodeOpt(t)}}class Yt{static bezier(o,t){const e=[];for(let s=0;s<t.length;s+=4){const i=t[s],n=t[s+1],r=t[s+2],c=t[s+3];i&&n&&r&&c?e.push(...Yt.getBezierPoints(o,i,n,r,c)):i&&n&&r?e.push(...Yt.getBezierPoints(o,i,n,r)):i&&n?e.push(...Yt.getBezierPoints(o,i,n)):i&&e.push(i)}return e}static getBezierPoints(o=10,t,e,s,i){let n=null;const r=[];!s&&!i?n=Yt.oneBezier:s&&!i?n=Yt.twoBezier:s&&i&&(n=Yt.threeBezier);for(let c=0;c<o;c++)n&&r.push(n(c/o,t,e,s,i));return i?r.push(i):s&&r.push(s),r}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,r=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,r)}}class wi extends W{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,r=(p=e==null?void 0:e.workId)==null?void 0:p.toString();if(!r)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 F(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:r,layer:f,isDrawing:!0})}if(!i){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:z.DrawWork,dataType:V.Local,op:this.tmpPoints.map(m=>[...m.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:V.Local,...this.baseConsumeResult}}consumeAll(){var r;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=Lt(i);return(r=this.vNodes)==null||r.setInfo(t,{rect:s,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&W.getCenterPos(s,e)}),{rect:s,type:z.FullWork,dataType:V.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:s}=t,{strokeColor:i,fillColor:n,thickness:r,zIndex:c,placement:l,scale:h,rotate:u,translate:d,strokeType:p,eraserlines:f}=this.workOptions,{rect:m,pos:y,points:N}=this.computDrawPoints(r,l),w={points:N.map(x=>x.XY),lineWidth:r,fillColor:n!=="transparent"&&n||void 0,strokeColor:i,normalize:!0,className:`${y[0]},${y[1]}`,close:!0,lineJoin:"round",lineCap:"round",lineDash:p===_.Dotted?[1,r*2]:p===_.LongDotted?[r,r*2]:void 0},I={name:e,id:e,zIndex:c,pos:y,anchor:[.5,.5],size:[m.w,m.h]};h&&(I.scale=h),u&&(I.rotate=u),d&&(I.translate=d);const S=new lt.Group(I),v=new lt.Polyline({...w,pos:[0,0]});S.append(v),f&&this.drawEraserlines({group:S,eraserlines:f,pos:y,layer:s}),this.replace(s,e,S);const T=S.getBoundingClientRect();return{x:Math.floor(T.x-W.SafeBorderPadding),y:Math.floor(T.y-W.SafeBorderPadding),w:Math.floor(T.width+W.SafeBorderPadding*2),h:Math.floor(T.height+W.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),r=Math.floor(s.h*.1),c=[],l=k.Add(i[0],new k(0,r,0)),h=k.Add(i[0],new k(n,0,0)),u=Yt.getBezierPoints(10,l,i[0],h),d=k.Sub(i[1],new k(n,0,0)),p=k.Add(i[1],new k(0,r,0)),f=Yt.getBezierPoints(10,d,i[1],p),m=k.Sub(i[2],new k(0,r,0)),y=k.Sub(i[2],new k(n,0,0)),N=Yt.getBezierPoints(10,m,i[2],y),w=k.Add(i[3],new k(n,0,0)),I=k.Sub(i[3],new k(0,r,0)),S=Yt.getBezierPoints(10,w,i[3],I),v=n*(1-this.ratio)*10,T=r*(1-this.ratio)*10;switch(e){case"bottom":{const A=k.Sub(i[2],new k(n*5-v/2,0,0)),O=k.Sub(i[2],new k(n*5,-T,0)),j=k.Sub(i[2],new k(n*5+v/2,0,0));c.push(O,j,...S,...u,...f,...N,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+v/2,-T,0)),j=k.Sub(i[2],new k(n*1.1+v,0,0));c.push(O,j,...S,...u,...f,...N,A);break}case"bottomLeft":{const A=k.Add(i[3],new k(n*1.1+v,0,0)),O=k.Add(i[3],new k(n*1.1+v/2,T,0)),j=k.Add(i[3],new k(n*1.1,0,0));c.push(O,j,...S,...u,...f,...N,A);break}case"top":{const A=k.Sub(i[1],new k(n*5-v/2,0,0)),O=k.Sub(i[1],new k(n*5,T,0)),j=k.Sub(i[1],new k(n*5+v/2,0,0));c.push(O,A,...f,...N,...S,...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+v/2,T,0)),j=k.Sub(i[1],new k(n*1.1+v,0,0));c.push(O,A,...f,...N,...S,...u,j);break}case"topLeft":{const A=k.Add(i[0],new k(n*1.1+v,0,0)),O=k.Add(i[0],new k(n*1.1+v/2,-T,0)),j=k.Add(i[0],new k(n*1.1,0,0));c.push(O,A,...f,...N,...S,...u,j);break}case"left":{const A=k.Add(i[0],new k(0,r*5-T/2,0)),O=k.Add(i[0],new k(-v,r*5,0)),j=k.Add(i[0],new k(0,r*5+T/2,0));c.push(O,A,...u,...f,...N,...S,j);break}case"leftTop":{const A=k.Add(i[0],new k(0,r*1.1,0)),O=k.Add(i[0],new k(-v,r*1.1+T/2,0)),j=k.Add(i[0],new k(0,r*1.1+T,0));c.push(O,A,...u,...f,...N,...S,j);break}case"leftBottom":{const A=k.Sub(i[3],new k(0,r*1.1+T,0)),O=k.Sub(i[3],new k(v,r*1.1+T/2,0)),j=k.Sub(i[3],new k(0,r*1.1,0));c.push(O,A,...u,...f,...N,...S,j);break}case"right":{const A=k.Add(i[1],new k(0,r*5-T/2,0)),O=k.Add(i[1],new k(v,r*5,0)),j=k.Add(i[1],new k(0,r*5+T/2,0));c.push(O,j,...N,...S,...u,...f,A);break}case"rightTop":{const A=k.Add(i[1],new k(0,r*1.1,0)),O=k.Add(i[1],new k(v,r*1.1+T/2,0)),j=k.Add(i[1],new k(0,r*1.1+T,0));c.push(O,j,...N,...S,...u,...f,A);break}case"rightBottom":{const A=k.Sub(i[2],new k(0,r*1.1+T,0)),O=k.Sub(i[2],new k(-v,r*1.1+T/2,0)),j=k.Sub(i[2],new k(0,r*1.1,0));c.push(O,j,...N,...S,...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 F(e[0],e[1]),i=this.tmpPoints[0],{thickness:n}=this.workOptions;if(i.isNear(s,n)||F.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 F(e[h],e[h+1],e[h+2]));const n=s?this.fullLayer:this.drawLayer||this.fullLayer,r=this.draw({workId:i,layer:n,isDrawing:!1});return this.oldRect=r,(l=this.vNodes)==null||l.setInfo(i,{rect:r,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:r&&W.getCenterPos(r,n)}),r}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var f;const{node:e,opt:s,vNodes:i}=t,{strokeColor:n,fillColor:r,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)),r&&(r==="transparent"?p.setAttribute("fillColor","rgba(0,0,0,0)"):p.setAttribute("fillColor",r),d!=null&&d.fillColor&&(d.fillColor=r)),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}),W.updateNodeOpt(t)}}var Cf=re,kf=Zt,xf="[object Boolean]";function zf(a){return a===!0||a===!1||kf(a)&&Cf(a)==xf}var bf=zf;const pe=Ie(bf);class je extends W{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=je.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:r,centerY:c,width:l,height:h,rotate:u,zIndex:d,eraserlines:p}=this.workOptions,f=new lt.Group({anchor:[.5,.5],pos:[r,c],name:s,size:[l,h],zIndex:d,rotate:u}),m={anchor:[.5,.5],pos:[0,0],size:[l,h],texture:n};n||(m.bgcolor="rgba(0,0,0,0.3)");const y=new lt.Sprite(m);f.append(y),p&&this.drawEraserlines({group:f,eraserlines:p,pos:[r,c],layer:e}),this.replace(e,i||s,f);const N=f.getBoundingClientRect();if(N)return{x:Math.floor(N.x-W.SafeBorderPadding),y:Math.floor(N.y-W.SafeBorderPadding),w:Math.floor(N.width+W.SafeBorderPadding*2),h:Math.floor(N.height+W.SafeBorderPadding*2)}}consumeService(){}async consumeServiceAsync(t){var h,u,d,p;const{isFullWork:e,replaceId:s,worker:i}=t,{src:n,uuid:r}=this.workOptions,c=((h=this.workId)==null?void 0:h.toString())||r,l=e?this.fullLayer:this.drawLayer||this.fullLayer;if(n){const f=!!l.parent.gl;let m;i&&(m=await i.loadImageBitMap({toolsType:this.toolsType,opt:this.workOptions,workId:c})),m||(m=await fetch(n,{method:"GET",mode:"cors",cache:"default"}).then(N=>N.blob()).then(N=>createImageBitmap(N,{imageOrientation:f?"flipY":"none"}).then(w=>w)).catch(N=>{console.error(`load image error: ${N}`)}));const y=this.draw({workId:c,layer:l,replaceId:s,imageBitmap:m});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&&W.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:r,originPoint:c,scenePoint:l,scale:h,angle:u,isLocked:d,zIndex:p}=s,f=n&&qt(n)||i.get(e.name);if(!f)return;const m=e.parent;if(m){if(Ht(p)&&(e.setAttribute("zIndex",p),f.opt.zIndex=p),pe(d)&&(f.opt.locked=d),c&&l&&h&&r){const{centerX:y,centerY:N,width:w,height:I,uniformScale:S}=f.opt,v=S!==!1?[h[0],h[0]]:h,T=[y,N],x=[y,N];Fo(x,l,v,r);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(w*v[0]),f.opt.height=Math.round(I*v[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++)Vo(O[E],l,h,r)}}else if(r){if(f.opt.centerX=f.opt.centerX+r[0],f.opt.centerY=f.opt.centerY+r[1],f.centerPos=[f.centerPos[0]+r[0],f.centerPos[1]+r[1]],f.opt.eraserlines)for(const y of Object.values(f.opt.eraserlines)){const{op:N}=y;for(let w=0;w<N.length;w++){const I=N[w].map((S,v)=>v%2?S+r[1]:S+r[0]);y.op[w]=I}}}else if(Ht(u))if(f.opt.rotate=u,f.scaleType=je.getScaleType(f.opt),n){const y=Ci(f.rect,u);f.rect=y}else{const y=W.getRectFromLayer(m,e.name);f.rect=y||f.rect}return f&&i.setInfo(e.name,f),f==null?void 0:f.rect}}}class Ii extends W{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,r=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 F(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:r,layer:p})}if(!i){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:z.DrawWork,dataType:V.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:V.Local,...this.baseConsumeResult}}consumeAll(){var r;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=Lt(i);return(r=this.vNodes)==null||r.setInfo(t,{rect:s,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:s&&W.getCenterPos(s,e)}),{rect:s,type:z.FullWork,dataType:V.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:s}=t,{strokeColor:i,thickness:n,zIndex:r,scale:c,rotate:l,translate:h,strokeType:u,eraserlines:d}=this.workOptions,p=s.worldPosition,f=s.worldScaling,{d:m,rect:y,isDot:N}=this.computDrawPoints(n,u),w=[y.x+y.w/2,y.y+y.h/2],I=new lt.Group({pos:w,anchor:[.5,.5],size:[y.w,y.h],name:e,id:e,normalize:!0,zIndex:r}),S={pos:[0,0],normalize:!0,d:m,fillColor:i,strokeColor:i,lineDash:u===_.Dotted&&!N?[1,n*2]:u===_.LongDotted&&!N?[n,n*2]:void 0,lineCap:u===_.Normal||N?void 0:"round",lineWidth:u===_.Normal||N?0:n};c&&(S.scale=c),l&&(S.rotate=l),h&&(S.translate=h);const v=new lt.Path(S);if(I.append(v),d&&this.drawEraserlines({group:I,eraserlines:d,pos:w,layer:s}),this.replace(s,e,I),l||c||h){const x=v.getBoundingClientRect();return{x:Math.floor(x.x-W.SafeBorderPadding),y:Math.floor(x.y-W.SafeBorderPadding),w:Math.floor(x.width+W.SafeBorderPadding*2),h:Math.floor(x.height+W.SafeBorderPadding*2)}}return{x:Math.floor(y.x*f[0]+p[0]-W.SafeBorderPadding),y:Math.floor(y.y*f[1]+p[1]-W.SafeBorderPadding),w:Math.floor(y.w*f[0]+2*W.SafeBorderPadding),h:Math.floor(y.h*f[1]+2*W.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=F.Sub(this.tmpPoints[0],i),r=F.Add(this.tmpPoints[0],i),c=F.Sub(this.tmpPoints[1],i),l=F.Add(this.tmpPoints[1],i),h=F.GetSemicircleStroke(this.tmpPoints[1],c,-1,8),u=F.GetSemicircleStroke(this.tmpPoints[0],r,-1,8),d=[n,c,...h,l,r,...u];let p;return e!==_.Normal?p=Xt(this.tmpPoints,!1):p=Xt(d,!0),{d:p,rect:dt(d),isDot:!1,pos:this.tmpPoints[0].XY}}computDotPoints(t){const e=F.GetDotStroke(this.tmpPoints[0],t/2,8);return{d:Xt(e,!0),rect:dt(e),isDot:!0,pos:this.tmpPoints[0].XY}}updateTempPoints(t){const e=t.slice(-2),s=new F(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 F(e[h],e[h+1],e[h+2]));const n=s?this.fullLayer:this.drawLayer||this.fullLayer,r=this.draw({workId:i,layer:n});return this.oldRect=r,(l=this.vNodes)==null||l.setInfo(i,{rect:r,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:r&&W.getCenterPos(r,n)}),r}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var l,h;const{node:e,opt:s,vNodes:i}=t,{strokeColor:n,strokeType:r}=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)),r&&(c!=null&&c.opt)&&((h=c.opt)!=null&&h.strokeType)&&(c.opt.strokeType=r),c&&i.setInfo(e.name,c),W.updateNodeOpt(t)}}const Jt=class Jt extends W{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:r,zIndex:c,eraserlines:l}=this.workOptions,h=s.worldPosition,u=s.worldScaling;if(!r||!n)return;const d={name:e,id:e,pos:[r[0],r[1]],anchor:[0,0],size:n,zIndex:c},p=new lt.Group(d),f={x:r[0],y:r[1],w:n[0],h:n[1]},m={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 Jt.createLabels(this.workOptions,s,m),{labels:N,maxWidth:w}=y;p.append(...N),m.w=Math.ceil(Math.max(w*s.worldScaling[0],m.w))}return l&&this.drawEraserlines({group:p,eraserlines:l,pos:[r[0],r[1]],layer:s}),m}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 r=s?this.fullLayer:this.drawLayer||this.fullLayer,c=await this.draw({workId:e,layer:r,isDrawLabel:typeof n>"u"&&this.workOptions.workState===D.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&&W.getCenterPos(c,r)}),c}updataOptService(){}async updataOptServiceAsync(t,e){var f,m;if(!this.workId)return;const s=this.workId.toString(),{fontColor:i,fontBgColor:n,bold:r,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),r&&(d.opt.bold=r),c&&(d.opt.italic=c),pe(l)&&(d.opt.lineThrough=l),pe(h)&&(d.opt.underline=h),Ht(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===D.Done||e});return(m=this.vNodes)==null||m.setInfo(s,{rect:p,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:p&&W.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(Jt.textImageSnippetSize*3/4/t)||1}static async createLabels(t,e,s){var j;const i=[],{x:n,y:r}=s,{width:c,height:l}=(j=e.parent)==null?void 0:j.parent,h=ke(t.text),u=h.length,{fontSize:d,lineHeight:p,bold:f,textAlign:m,italic:y,fontFamily:N,verticalAlign:w,fontColor:I,fontBgColor:S,underline:v,lineThrough:T}=t,x=Jt.getSafetySnippetRatio(e)||1,b=Math.floor(d*x),A=Jt.getSafetySnippetFontLength(b);let O=0;for(let E=0;E<u;E++){const P=h[E],Y=p||b*1.5;if(P){const et=Rf(P),tt=[0,0],$=[0,d*1.2];w==="middle"&&(tt[1]=E*d*1.2+5);const J=[0,-d*.15];tt[0]=5;const G=Math.sin(Math.PI/180*20);let Z=0;const X=[];let rt=0;for(;rt<et;){m==="left"&&(J[0]=Z),rt===0&&y==="italic"&&(J[0]=J[0]-G/2*d);const ot=P.slice(rt,rt+A),at={anchor:[0,0],pos:J,text:ot,fontFamily:N,fontSize:b,lineHeight:Y,strokeColor:I,fontWeight:f,fillColor:I,textAlign:m,fontStyle:y,scale:[1/x,1/x]},U=new lt.Label(at),it=await U.textImageReady;let ht=!0;if(it){const It=it.rect&&it.rect[2],Ft=it.rect&&it.rect[3];if(It&&Ft){const yt=It/x,gt=Ft/x;Z=yt+Z,y==="italic"&&(f==="bold"?Z=Z-G*d*1.2:Z=Z-G*d),((J[0]+tt[0]+yt)*e.worldScaling[0]+n<=0||(J[0]+tt[0])*e.worldScaling[0]+n>=c||(J[1]+tt[1]+gt)*e.worldScaling[1]+r<=0||(J[1]+tt[1])*e.worldScaling[1]+r>=l)&&(U.disconnect(),ht=!1),ht&&X.push(U)}}rt+=A}$[0]=Z,y==="italic"&&($[0]=$[0]+G*d),O=Math.max(O,$[0]);let wt=!0;if(((tt[0]+$[0])*e.worldScaling[0]+n<=0||tt[0]*e.worldScaling[0]+n>=c||(tt[1]+$[1])*e.worldScaling[0]+r<=0||tt[1]*e.worldScaling[1]+r>=l)&&(wt=!1),wt){if(v){const U=Math.floor(d/10),it={normalize:!1,pos:[0,d*1.1+U/2],lineWidth:U,points:[0,0,Math.ceil($[0]),0],strokeColor:I,className:"underline"},ht=new lt.Polyline(it);X.push(ht)}if(T){const U={normalize:!1,pos:[0,d*1.2/2],lineWidth:Math.floor(d/10),points:[0,0,Math.ceil($[0]),0],strokeColor:I,className:"lineThrough"},it=new lt.Polyline(U);X.push(it)}const ot={pos:tt,anchor:[0,0],size:$,bgcolor:S},at=new lt.Group(ot);at.append(...X),i.push(at)}}}return{labels:i,maxWidth:O}}static updateNodeOpt(t){const{node:e,opt:s,vNodes:i,targetNode:n}=t,{fontBgColor:r,fontColor:c,translate:l,originPoint:h,scenePoint:u,scale:d,bold:p,italic:f,lineThrough:m,underline:y,fontSize:N,textInfos:w,zIndex:I}=s,S=n&&qt(n)||i.get(e.name);if(!S||!e.parent)return;const T=S.opt;if(Ht(I)&&(e.setAttribute("zIndex",I),S.opt.zIndex=I),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)})})),r&&T.fontBgColor&&(T.fontBgColor=r,e.children.forEach(x=>{x.tagName==="GROUP"&&x.setAttribute("bgcolor",r)})),p&&(T.bold=p),f&&(T.italic=f),pe(m)&&(T.lineThrough=m),pe(y)&&(T.underline=y),N&&(T.fontSize=N),h&&u&&d&&n&&T.boxPoint){const x=w==null?void 0:w.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]];Fo(T.boxPoint,u,d,l);const A=[S.op[0],S.op[1]],O=[A[0]-b[0],A[1]-b[1]];if(S.centerPos=[S.centerPos[0]+O[0],S.centerPos[1]+O[1]],S.opt.eraserlines)for(const j of Object.values(S.opt.eraserlines)){const{op:E,thickness:P}=j;j.thickness=P*Math.max(d[0],d[1]);for(let Y=0;Y<E.length;Y++)Vo(E[Y],u,d,l)}}else if(l&&T.boxPoint&&(T.boxPoint=[T.boxPoint[0]+l[0],T.boxPoint[1]+l[1]],S.centerPos=[S.centerPos[0]+l[0],S.centerPos[1]+l[1]],S.opt.eraserlines))for(const x of Object.values(S.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 S&&i.setInfo(e.name,S),S==null?void 0:S.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(r=>{if(r.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(Jt,"textImageSnippetSize",1024*4),M(Jt,"SafeBorderPadding",30);let Je=Jt;const ge=class ge extends W{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}=ge.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:r,height:c}=ge.eraserSizes[this.workOptions.thickness],l=Math.min(r,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:r}=ge.eraserSizes[this.workOptions.thickness];return k.Dist(s,i)<Math.hypot(n,r)*.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,m)=>m<d.length-1?r([f,d[m+1]],[l[0],l[1]]):!1);if(p!==-1&&p>-1){const f=[],m=d.slice(0,p+1);if(k.Equals(d[p],l[0])||m.push(l[0].clone().setz(d[p].z)),m.length>1&&f.push(m),p+l.length-1<d.length-1){const y=p+l.length-1,N=d.slice(y),w=l[l.length-1];k.Equals(d[y],w)||N.unshift(w.clone().setz(d[y].z)),N.length>1&&f.push(N)}return h.splice(u,1,...f),h}}return h}function r(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 r=0;for(;r<i.length;){const c=i[r],l=new k(c[0],c[1]);n.push(l),r++}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[r,c]of e.entries())if(c.rect&&this.eraserRect&&this.eraserPolyline&&Ae(this.eraserRect,c.rect)){const{op:l,toolsType:h}=c,u=this.isLineEraser(h,!1),d=[],p=[];for(let m=0;m<l.length;m+=3){const y=new k(l[m]*this.worldScaling[0]+this.worldPosition[0],l[m+1]*this.worldScaling[1]+this.worldPosition[1],l[m+2]);p.push(y),d.push(new F(y.x,y.y))}const f=d.length&&dt(d)||c.rect;if(Ae(f,this.eraserRect)){if(p.length>1){const m=Po.polyline(p.map(y=>y.XY),this.eraserPolyline);if(m.length&&(s.add(c.name),!u)){const y=this.translateIntersect(m),N=this.cutPolyline(y,p);for(let w=0;w<N.length;w++){const I=`${r}_s_${w}`,S=[];N[w].forEach(v=>{S.push((v.x-this.worldPosition[0])/this.worldScaling[0],(v.y-this.worldPosition[1])/this.worldScaling[1],v.z)}),c.opt&&c.toolsType&&this.vNodes&&(this.vNodes.setInfo(I,{rect:f,op:S,opt:c.opt,canRotate:c.canRotate,scaleType:c.scaleType,toolsType:c.toolsType}),i.set(I,{workId:I,op:S,opt:c.opt,toolsType:c.toolsType}))}}}else s.add(c.name);n=ut(n,f)}}return s.forEach(r=>{var c;return(c=this.vNodes)==null?void 0:c.delete(r)}),n&&(n.x-=W.SafeBorderPadding,n.y-=W.SafeBorderPadding,n.w+=W.SafeBorderPadding*2,n.h+=W.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 r=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:r,newWorkDatas:c});n=ut(n,u)}if(this.vNodes.deleteLastTarget(),n&&r.size){for(const h of c.keys())r.has(h)&&c.delete(h);return{type:z.RemoveNode,rect:n,removeIds:[...r],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=qt(t),i=this.serviceWork.selectorWorkShapes,n=this.serviceWork.workShapes;for(const r of i.values())if((e=r.selectIds)!=null&&e.length)for(const c of r.selectIds)s.delete(c);for(const r of n.keys())s.delete(r);return s}return t}};M(ge,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));let Xe=ge;const Le=class Le extends W{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",Pt.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 F(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 r=this.tmpPoints.length,c=new F(t[n],t[n+1]);if(r===0){this.tmpPoints.push(c);continue}const l=r-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=So(s,e),s=Lf(s,this.worldScaling,e);const{nodeRange:i}=this.vNodes.getRectIntersectRange(s);if(!i.size)return;const n=[];let r=0;for(let l=1;l<this.tmpPoints.length;l++){const h=this.tmpPoints[l-1],u=this.tmpPoints[l];if(l===1&&r===0&&(n[r]=[h.XY]),n[r].push(u.XY),l<this.tmpPoints.length-1){const d=u.getAngleByPoints(h,this.tmpPoints[l+1]);(d<90||d>270)&&(r++,n[r]=[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=So(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)Po.polyline(y,d,p);if(p.length&&h.opt)for(const y of p){const N=[];for(let w=0;w<y.length;w++)w!==0&&de(y[w],y[w-1])||N.push(...y[w]);f.push(N)}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,r]of s.entries()){const{toolsType:c}=r,l=i.createWorkShapeNode({workId:n,toolsType:c,toolsOpt:r.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:r.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}=Le.eraserSizes[s],r=Math.max(i,n)/this.worldScaling[0],c=this.tmpPoints.length,l=this.tmpPoints[this.tmpPoints.length-1],h=this.updateTempPoints(e,r),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),m=this.draw({consumePoints:f,layer:this.fullLayer,thickness:r});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(N=>{y.push(N.x,N.y,r/2)}),{...this.baseConsumeResult,type:z.DrawWork,dataType:V.Local,rect:m,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 r=s.getElementsByName(this.workId)[0],c=dt(e,i);const h=[{op:[e.map(u=>[u.x,u.y]).flat(1)],thickness:i}];return r||(r=new lt.Group({normalize:!0,name:n,pos:[0,0],anchor:[.5,.5],bgcolor:"rgba(0,0,0,0.3)",zIndex:9999}),s.appendChild(r)),this.drawEraserlines({group:r,eraserlines:h,pos:[0,0],layer:s,isClear:!0}),c={x:Math.floor(c.x*this.worldScaling[0]+this.worldPosition[0]-W.SafeBorderPadding),y:Math.floor(c.y*this.worldScaling[1]+this.worldPosition[1]-W.SafeBorderPadding),w:Math.floor(c.w*this.worldScaling[0]+2*W.SafeBorderPadding),h:Math.floor(c.h*this.worldScaling[1]+2*W.SafeBorderPadding)},c}consumeAll(){const t=this.fullLayer.getElementsByName(this.workId);let e;if(t.length&&(e=W.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}=Le.eraserSizes[s],r=Math.max(i,n)/this.worldScaling[0],c=this.getChangeNodes(r);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,r/2)});const h=Lt(l);return{...this.baseConsumeResult,type:z.FullWork,dataType:V.Local,rect:e,ops:h,willUpdateNodes:c}}clearTmpPoints(){this.tmpPoints.length=0}};M(Le,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));let Ke=Le;function vi(a){switch(a){case C.Arrow:return fi;case C.Pencil:return hi;case C.Straight:return Ii;case C.Ellipse:return gi;case C.Polygon:case C.Triangle:return mi;case C.Star:case C.Rhombus:return yi;case C.Rectangle:return Mi;case C.SpeechBalloon:return wi;case C.Text:return Je;case C.LaserPen:return ui;case C.Eraser:return Ge;case C.PencilEraser:return Xe;case C.BitMapEraser:return Ke;case C.Selector:return qe;case C.Image:return je}}function Ni(a,o){const{toolsType:t,...e}=a;switch(t){case C.Arrow:return new fi(e);case C.Pencil:return new hi(e);case C.Straight:return new Ii(e);case C.Ellipse:return new gi(e);case C.Polygon:case C.Triangle:return new mi(e);case C.Star:case C.Rhombus:return new yi(e);case C.Rectangle:return new Mi(e);case C.SpeechBalloon:return new wi(e);case C.Text:return new Je(e);case C.LaserPen:return new ui(e);case C.Eraser:return new Ge(e,o);case C.BitMapEraser:return new Ke(e);case C.PencilEraser:return new Xe(e,o);case C.Selector:return e.vNodes?new qe({...e,vNodes:e.vNodes,drawLayer:e.fullLayer}):void 0;case C.Image:return new je(e);default:return}}function Ti(a){const o=[],t=["PATH","SPRITE","POLYLINE","RECT","ELLIPSE","LABEL"];for(const e of a){if(e.tagName==="GROUP"&&e.children.length)return Ti(e.children);e.tagName&&t.includes(e.tagName)&&o.push(e)}return o}function ut(a,o){if(a&&o){const t=Math.min(a.x,o.x),e=Math.min(a.y,o.y),s=Math.max(a.x+a.w,o.x+o.w),i=Math.max(a.y+a.h,o.y+o.h),n=s-t,r=i-e;return{x:t,y:e,w:n,h:r}}return o||a}function Si(a,o){if(a&&o){const t=Math.min(a.originX,o.originX),e=Math.min(a.originY,o.originY),s=Math.max(a.originX+a.width,o.originX+o.width),i=Math.max(a.originY+a.height,o.originY+o.height),n=s-t,r=i-e;return{originX:t,originY:e,width:n,height:r}}return o||a}function dt(a,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 a.forEach(r=>{const[c,l]=r.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 Ae(a,o){return!(a.x+a.w<o.x||a.x>o.x+o.w||a.y+a.h<o.y||a.y>o.y+o.h)}function So(a,o){return{x:a.x+o[0],y:a.y+o[1],w:a.w,h:a.h}}function Pf(a,o){const t=new k(a.x,a.y),e=new k(a.x+a.w,a.y),s=new k(a.x+a.w,a.y+a.h),i=new k(a.x,a.y+a.h),n=new k(a.x+a.w/2,a.y+a.h/2),r=Math.PI*o/180,c=k.RotWith(t,n,r),l=k.RotWith(e,n,r),h=k.RotWith(s,n,r),u=k.RotWith(i,n,r);return[c,l,h,u]}function Ci(a,o){const t=Pf(a,o);return dt(t)}function Lf(a,o,t){const e=new k(a.x,a.y),s=new k(a.x+a.w,a.y),i=new k(a.x+a.w,a.y+a.h),n=new k(a.x,a.y+a.h),r=new k(t[0],t[1]),c=new k(o[0],o[1]),l=k.ScaleWOrigin(e,c,r),h=k.ScaleWOrigin(s,c,r),u=k.ScaleWOrigin(i,c,r),d=k.ScaleWOrigin(n,c,r);return dt([l,h,u,d])}function Df(a,o,t){const e=new k(o[0],o[1]);for(let s=0;s<a.length;s+=3){const i=new k(a[s],a[s+1]),n=Math.PI*t/180,r=k.RotWith(i,e,n);a[s]=r.x,a[s+1]=r.y}}function jf(a,o,t){const e=new k(o[0],o[1]);for(let s=0;s<a.length;s+=2){const i=new k(a[s],a[s+1]),n=Math.PI*t/180,r=k.RotWith(i,e,n);a[s]=r.x,a[s+1]=r.y}}function Fo(a,o,t,e=[0,0]){const s=new k(o[0],o[1]);for(let i=0;i<a.length;i+=3){const n=new k(a[i],a[i+1]),r=new k(t[0],t[1]),c=k.ScaleWOrigin(n,r,s);a[i]=c.x+e[0],a[i+1]=c.y+e[1]}}function Vo(a,o,t,e=[0,0]){const s=new k(o[0],o[1]);for(let i=0;i<a.length;i+=2){const n=new k(a[i],a[i+1]),r=new k(t[0],t[1]),c=k.ScaleWOrigin(n,r,s);a[i]=c.x+e[0],a[i+1]=c.y+e[1]}}function ki(a,o){return a[0]>=o.x&&a[0]<=o.x+o.w&&a[1]>=o.y&&a[1]<=o.y+o.h}function xi(a,o){const t=a<=o?1:a/o,e=o<=a?1:o/a;return[t,e]}function Af(a){for(const o of a)if(isNaN(o)||o===1/0||o===-1/0)return!1;return!0}const Ef=a=>{if(a.tagName==="GROUP"){const o=Object.getOwnPropertySymbols(a).find(t=>t.toString()==="Symbol(sealed)");if(o&&a[o])return!0}return!1};function ce(a){return`${_e(a.x)},${_e(a.y)} `}function le(a,o){return`${_e((a.x+o.x)/2)},${_e((a.y+o.y)/2)} `}function _e(a){return+a.toFixed(4)}const ne=(a,o)=>new Promise(function(t){window.requestIdleCallback?requestIdleCallback(()=>{t(1)},{timeout:o}):setTimeout(()=>{t(2)},o)}).then(function(){a()},()=>{a()}),Kt=a=>{const o=(a==null?void 0:a.webkitBackingStorePixelRatio)||(a==null?void 0:a.mozBackingStorePixelRatio)||(a==null?void 0:a.msBackingStorePixelRatio)||(a==null?void 0:a.oBackingStorePixelRatio)||(a==null?void 0:a.backingStorePixelRatio)||1;return Math.max(1,(window.devicePixelRatio||1)/o)},Of=(a,o)=>a.x+a.w<o.x||a.x>o.x+o.w||a.y+a.h<o.y||a.y>o.y+o.h?Pe.outside:a.x>=o.x&&a.y>=o.y&&a.x+a.w<=o.x+o.w&&a.y+a.h<=o.y+o.h?Pe.inside:Pe.intersect;function Rf(a){let o=0;for(let t=0;t<a.length;t++){const e=a.charCodeAt(t);e>=1&&e<=126||65376<=e&&e<=65439?o++:o+=2}return o}class Yf{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 nt.toJS((o=this.plugin)==null?void 0:o.attributes[this.namespace])||{}}getAuthSpaceData(){var o;return nt.toJS((o=this.plugin)==null?void 0:o.attributes[this.authSpace])||{}}getUidFromKey(o){return o.split(Ut).length===2&&o.split(Ut)[0]||this.uid}isLocalId(o){return o.split(Ut).length===1}getLocalId(o){return o.split(Ut)[1]}isSelector(o){return this.getLocalId(o)===H}}const Rt=class Rt extends Yf{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);Rt.syncInterval=(s||Rt.syncInterval)*.5,this.namespace=Rt.namespace,this.authSpace=Rt.authSpace,this.serviceStorage=this.getNamespaceData(),this.storage=L.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 L.cloneDeep(s[i])}}getStorageData(t,e){const s=this.getNamespaceData();return s&&s[t]&&L.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=nt.autorun(async()=>{var c;const e=this.getNamespaceData(),{diffView:s,diffScenePath:i,diffData:n}=this.diffFunByView(this.serviceStorage,e);this.serviceStorage=e;const r={};if(Object.keys(s).length>0){r.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]=L.cloneDeep(h.newValue);continue}}}if(Object.keys(i).length>0){r.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]=L.cloneDeep(d);continue}}}if(Object.keys(n).length>0){r.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],m=(c=this.storage[u])==null?void 0:c[d];if(f||(this.storage[u]={},f=this.storage[u],f[d]={},m=f[d]),m){if(m[l]&&p===void 0){delete m[l];continue}if(p&&u){m[l]=L.cloneDeep(p);continue}}}}}Object.keys(r).length>0&&t(r)})}removeStorageStateListener(){this.stateDisposer&&this.stateDisposer()}diffFunByView(t,e){const s=Ct(t),i=Ct(e),n={},r={},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(L.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(r,h.diffScenePath),Object.assign(c,h.diffData)}return{diffData:c,diffScenePath:r,diffView:n}}diffFunByScenePath(t,e,s){const i=Ct(t),n=Ct(e),r={},c={};for(const l of n)if(!i.includes(l)||t[l]===void 0){r[l]={newValue:e[l],oldValue:void 0,viewId:s};continue}for(const l of i){if(L.isEqual(t[l],e[l]))continue;if(!n.includes(l)||e[l]===void 0){r[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:r,diffData:c}}diffFunByKeys(t,e,s,i){const n=Ct(t),r=Ct(e),c={};for(const l of r)(!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(!L.isEqual(t[l],e[l])){if(!r.includes(l)||e[l]===void 0){c[l]={newValue:void 0,oldValue:t[l],viewId:i,scenePath:s};continue}r.includes(l)&&(c[l]={oldValue:t[l],newValue:e[l],viewId:i,scenePath:s})}return c}transformKey(t){return this.uid+Ut+t}isOwn(t){return t.split(Ut)[0]===this.uid}dispatch(t){const{type:e,workId:s,ops:i,index:n,opt:r,toolsType:c,removeIds:l,updateNodeOpt:h,op:u,selectIds:d,isSync:p,scenePath:f,viewId:m}=t;if(m)switch(e){case z.Clear:const y={};f&&this.storage[m]&&this.storage[m][f]?(delete this.storage[m][f],this.setState(y,{isSync:p,viewId:m,scenePath:f})):this.storage[m]&&(delete this.storage[m],this.setState(y,{isSync:p,viewId:m,scenePath:""}));break;case z.CreateWork:if(f&&s&&c&&r){const v=this.isLocalId(s.toString())?this.transformKey(s):s;this.control.renderControl.isUsePageAuth(m)&&this.control.renderControl.addRenderPageElementId({viewId:m,scenePath:f,elementId:v.toString()}),this.updateValue(v.toString(),{type:z.CreateWork,workId:s,toolsType:c,opt:r},{isSync:p,viewId:m,scenePath:f})}break;case z.DrawWork:if(f&&s&&typeof n=="number"&&(u!=null&&u.length)){const v=this.isLocalId(s.toString())?this.transformKey(s):s,T=this.storage[m]&&this.storage[m][f]&&this.storage[m][f][v]||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=r||(T==null?void 0:T.opt),O=h||(T==null?void 0:T.updateNodeOpt);s&&b&&A&&x&&(this.control.renderControl.isUsePageAuth(m)&&this.control.renderControl.addRenderPageElementId({viewId:m,scenePath:f,elementId:v.toString()}),this.updateValue(v.toString(),{...T,type:z.DrawWork,workId:s,updateNodeOpt:O,toolsType:b,opt:A,op:x,index:n},{isSync:p,viewId:m,scenePath:f}))}break;case z.FullWork:if(f&&s){const v=this.isLocalId(s.toString())?this.transformKey(s):s,T=this.storage[m]&&this.storage[m][f]&&this.storage[m][f][v]||void 0,x=h||(T==null?void 0:T.updateNodeOpt),b=c||(T==null?void 0:T.toolsType),A=r||(T==null?void 0:T.opt),O=i||(T==null?void 0:T.ops);b&&A&&(this.control.renderControl.isUsePageAuth(m)&&this.control.renderControl.addRenderPageElementId({viewId:m,scenePath:f,elementId:v.toString()}),this.updateValue(v.toString(),{type:z.FullWork,updateNodeOpt:x,workId:v,toolsType:b,opt:A,ops:O},{isSync:p,viewId:m,scenePath:f}))}break;case z.RemoveNode:if(f&&(l!=null&&l.length)){const v=l.map(T=>this.isLocalId(T+"")?this.transformKey(T):T);this.storage[m]&&this.storage[m][f]&&Object.keys(this.storage[m][f]).map(T=>{v!=null&&v.includes(T)&&(this.control.renderControl.isUsePageAuth(m)&&this.control.renderControl.delRenderPageElementId({viewId:m,scenePath:f,elementId:T}),this.updateValue(T,void 0,{isSync:p,viewId:m,scenePath:f}))})}break;case z.UpdateNode:if(f&&s&&(h||i||r)){const v=this.isLocalId(s.toString())?this.transformKey(s):s,T=this.storage[m]&&this.storage[m][f]&&this.storage[m][f][v]||void 0;T&&(T.updateNodeOpt=h,(i||u)&&(T.ops=i,T.op=u),r&&(T.opt=r),T.type=z.FullWork,this.updateValue(v.toString(),T,{isSync:p,viewId:m,scenePath:f}))}break;case z.Select:if(!f)return;let N;d!=null&&d.length&&(N=d.map(v=>this.isLocalId(v+"")?this.transformKey(v):v));const w=this.transformKey(H),I=this.storage[m]&&this.storage[m][f]&&this.storage[m][f][w]||void 0,S=r||(I==null?void 0:I.opt);N&&this.checkOtherSelector(w,N,{isSync:p,viewId:m,scenePath:f}),this.updateValue(w,N&&{type:z.Select,toolsType:C.Selector,opt:S,selectIds:N},{isSync:p,viewId:m,scenePath:f});break}}checkOtherSelector(t,e,s){const{viewId:i,scenePath:n}=s;for(const r of Object.keys(this.storage[i][n]))if(r!==t&&this.getLocalId(r)===H){const c=this.storage[i][n][r];if(c&&c.selectIds){const l=c.selectIds.filter(h=>!e.includes(h));l.length>0&&(c.selectIds=l),this.updateValue(r,l.length&&c||void 0,s)}}}setState(t,e){const{viewId:s,scenePath:i}=e,n=Ct(t);for(let r=0;r<n.length;r++){const c=n[r],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)):ne(()=>{this.asyncClockState=!1,this.syncSerivice(t.isAfterUpdate)},Rt.syncInterval)},t!=null&&t.isSync?0:Rt.syncInterval))}syncSerivice(t=!1){const e=Ct(this.serviceStorage),s=Ct(this.storage),i=new Map;for(const n of e){if(!s.includes(n)){i.set(n,void 0);continue}L.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,r]of i.entries())this.syncUpdataView(n,r,t)}syncViewData(t,e=!1){const s=Ct(this.serviceStorage[t]),i=Ct(this.storage[t]),n=new Map;for(const r of s){if(!i.includes(r)){n.set(r,void 0);continue}L.isEqual(this.serviceStorage[t][r],this.storage[t][r])||this.syncScenePathData(t,r,e)}for(const r of i)s.includes(r)||n.set(r,this.storage[t][r]);if(n.size>5)this.syncStorageScenePath(t,this.storage[t],e);else for(const[r,c]of n.entries())this.syncUpdataScenePath(t,r,c,e)}syncScenePathData(t,e,s=!1){const i=Ct(this.serviceStorage[t][e]),n=Ct(this.storage[t][e]),r=new Map;for(const c of i){if(!n.includes(c)){r.set(c,void 0);continue}L.isEqual(this.serviceStorage[t][e][c],this.storage[t][e][c])||r.set(c,this.storage[t][e][c])}for(const c of n)i.includes(c)||r.set(c,this.storage[t][e][c]);if(r.size>5)this.syncStorageKey(t,e,this.storage[t][e],s);else for(const[c,l]of r.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]=L.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=L.cloneDeep(t)),(s=this.plugin)==null||s.updateAttributes([this.namespace],t)}syncUpdataScenePath(t,e,s,i=!1){var r;Object.keys(this.serviceStorage[t]).length?(i||(s===void 0?delete this.serviceStorage[t][e]:this.serviceStorage[t][e]=s),(r=this.plugin)==null||r.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(Ut);return e.length===2?e[1]:t}destroy(){this.removeStorageStateListener(),this.serviceStorage={},this.storage={},this.removeAuthStateListener(),this.authStorage={}}dispatchPageAuth(t,e=!0){var l,h,u,d,p,f,m,y,N,w,I,S,v,T,x,b,A,O,j,E,P,Y,et,tt,$,J,G,Z,X,rt,wt,ot,at,U,it,ht,It,Ft;const{operation:s,viewId:i,scenePath:n,pageId:r,pageData:c}=t;switch(s){case kt.addPage:{if(!i||!n||!r)return;const yt=[this.authSpace];Object.keys(this.authStorage).length&&yt.push("pageAuth");const gt=this.authStorage.pageAuth||{};this.authStorage.pageAuth=gt,Object.keys(gt).length&&yt.push(i),gt[i]=gt[i]||{},Object.keys(gt[i]).length&&yt.push(n),gt[i][n]=gt[i][n]||{render:(c==null?void 0:c.render)||"localSelf",pages:{}},Object.keys(gt[i][n].pages).length&&yt.push("pages",r);const te={};if(c!=null&&c.elementIds)for(const Nt of c.elementIds.keys())te[Nt]=!0;gt[i][n].pages[r]=te,e&&(yt.length===1?(l=this.plugin)==null||l.updateAttributes(yt,L.cloneDeep(this.authStorage)):yt.length===2?(h=this.plugin)==null||h.updateAttributes(yt,L.cloneDeep(gt)):yt.length===3?(u=this.plugin)==null||u.updateAttributes(yt,L.cloneDeep(gt[i])):yt.length===4?(d=this.plugin)==null||d.updateAttributes(yt,L.cloneDeep(gt[i][n])):(p=this.plugin)==null||p.updateAttributes(yt,L.cloneDeep(te)));return}case kt.renderPage:{if(!i||!n||!(c!=null&&c.render))return;this.authStorage.pageAuth&&this.authStorage.pageAuth[i]&&this.authStorage.pageAuth[i][n]&&c.render!==this.authStorage.pageAuth[i][n].render&&(this.authStorage.pageAuth[i][n].render=c.render,e&&((f=this.plugin)==null||f.updateAttributes([this.authSpace,"pageAuth",i,n,"render"],c.render)));return}case kt.deletePage:{if(!i||!n||!r)return;(I=(w=(N=(y=(m=this.authStorage)==null?void 0:m.pageAuth)==null?void 0:y[i])==null?void 0:N[n])==null?void 0:w.pages)!=null&&I[r]&&(delete this.authStorage.pageAuth[i][n].pages[r],e&&((S=this.plugin)==null||S.updateAttributes([this.authSpace,"pageAuth",i,n,"pages",r],void 0)));return}case kt.clearPage:{if(!i||!n||!r)return;(A=(b=(x=(T=(v=this.authStorage)==null?void 0:v.pageAuth)==null?void 0:T[i])==null?void 0:x[n])==null?void 0:b.pages)!=null&&A[r]&&(delete this.authStorage.pageAuth[i][n].pages[r],e&&((O=this.plugin)==null||O.updateAttributes([this.authSpace,"pageAuth",i,n,"pages",r],{})));return}case kt.addElement:{if(!i||!n||!r||!(c!=null&&c.elementId))return;(et=(Y=(P=(E=(j=this.authStorage)==null?void 0:j.pageAuth)==null?void 0:E[i])==null?void 0:P[n])==null?void 0:Y.pages)!=null&&et[r]&&(this.authStorage.pageAuth[i][n].pages[r][c.elementId]=!0,e&&((tt=this.plugin)==null||tt.updateAttributes([this.authSpace,"pageAuth",i,n,"pages",r,c.elementId],!0)));return}case kt.deleteElement:{if(!i||!n||!r||!(c!=null&&c.elementId))return;(rt=(X=(Z=(G=(J=($=this.authStorage)==null?void 0:$.pageAuth)==null?void 0:J[i])==null?void 0:G[n])==null?void 0:Z.pages)==null?void 0:X[r])!=null&&rt[c.elementId]&&(delete this.authStorage.pageAuth[i][n].pages[r][c.elementId],e&&((wt=this.plugin)==null||wt.updateAttributes([this.authSpace,"pageAuth",i,n,"pages",r,c.elementId],void 0)));return}case kt.clearViewScenePath:{if(!i||!n)return;(U=(at=(ot=this.authStorage)==null?void 0:ot.pageAuth)==null?void 0:at[i])!=null&&U[n]&&(delete this.authStorage.pageAuth[i][n],e&&((it=this.plugin)==null||it.updateAttributes([this.authSpace,"pageAuth",i,n],void 0)));return}case kt.clearView:{if(!i)return;(It=(ht=this.authStorage)==null?void 0:ht.pageAuth)!=null&&It[i]&&(delete this.authStorage.pageAuth[i],e&&((Ft=this.plugin)==null||Ft.updateAttributes([this.authSpace,"pageAuth",i],void 0)));return}}}dispatchRenderAuth(t,e=!0){var l,h,u,d,p,f,m,y,N,w,I,S,v,T,x,b,A,O,j,E;const{operation:s,viewId:i,uid:n,renderData:r,isClear:c}=t;if(i)switch(s){case Wt.setAuth:{if(!r||r.render===void 0&&r.hide===void 0&&r.clear===void 0){this.authStorage.renderAuth&&this.authStorage.renderAuth[i]&&(delete this.authStorage.renderAuth[i],e&&((l=this.plugin)==null||l.updateAttributes([this.authSpace,"renderAuth",i],void 0)));return}const P=[this.authSpace];Object.keys(this.authStorage).length&&P.push("renderAuth");const Y=this.authStorage.renderAuth||{};Object.keys(Y).length&&P.push(i),Y[i]={},this.authStorage.renderAuth=Y;const{render:et,hide:tt,clear:$}=r;if(et===!0)Y[i].render=!0;else if(L.isSet(et)){Y[i].render={};for(const J of et.keys())Y[i].render[J]=!0}if(tt===!0)Y[i].hide=!0;else if(L.isSet(tt)){Y[i].hide={};for(const J of tt.keys())Y[i].hide[J]=!0}if($===!0)Y[i].clear=!0;else if(L.isSet($)){Y[i].clear={};for(const J of $.keys())Y[i].clear[J]=!0}e&&(P.length===1?(h=this.plugin)==null||h.updateAttributes(P,L.cloneDeep(this.authStorage)):P.length===2?(u=this.plugin)==null||u.updateAttributes(P,L.cloneDeep(Y)):(d=this.plugin)==null||d.updateAttributes(P,L.cloneDeep(Y[i])));return}case Wt.setShow:{if(!n)return;const P=[this.authSpace];Object.keys(this.authStorage).length&&P.push("renderAuth");const Y=this.authStorage.renderAuth||{};Object.keys(Y).length&&P.push(i),Y[i]=Y[i]||{},this.authStorage.renderAuth=Y,Object.keys(Y[i]).length&&P.push("render"),Y[i].render=Y[i].render||{},Y[i].render!==!0&&(Object.keys(Y[i].render).length&&P.push(n),Y[i].render[n]=!0),Y[i].hide!==!0&&((p=Y[i].hide)!=null&&p[n])&&(delete Y[i].hide[n],e&&((f=this.plugin)==null||f.updateAttributes([this.authSpace,"renderAuth",i,"hide",n],void 0))),e&&(P.length===1?(m=this.plugin)==null||m.updateAttributes(P,L.cloneDeep(this.authStorage)):P.length===2?(y=this.plugin)==null||y.updateAttributes(P,L.cloneDeep(Y)):P.length===3?(N=this.plugin)==null||N.updateAttributes(P,L.cloneDeep(Y[i])):(w=this.plugin)==null||w.updateAttributes(P,!0));return}case Wt.setHide:{if(!n)return;const P=[this.authSpace];Object.keys(this.authStorage).length&&P.push("renderAuth");const Y=this.authStorage.renderAuth||{};Object.keys(Y).length&&P.push(i),Y[i]=Y[i]||{},this.authStorage.renderAuth=Y,Object.keys(Y[i]).length&&P.push("hide"),Y[i].hide=Y[i].hide||{},Y[i].hide!==!0&&(Object.keys(Y[i].hide).length&&P.push(n),Y[i].hide[n]=!0),Y[i].render!==!0&&((I=Y[i].render)!=null&&I[n])&&(delete Y[i].render[n],e&&((S=this.plugin)==null||S.updateAttributes([this.authSpace,"renderAuth",i,"render",n],void 0))),e&&(P.length===1?(v=this.plugin)==null||v.updateAttributes(P,L.cloneDeep(this.authStorage)):P.length===2?(T=this.plugin)==null||T.updateAttributes(P,L.cloneDeep(Y)):P.length===3?(x=this.plugin)==null||x.updateAttributes(P,L.cloneDeep(Y[i])):(b=this.plugin)==null||b.updateAttributes(P,!0));return}case Wt.setClear:{if(!n)return;const P=[this.authSpace];Object.keys(this.authStorage).length&&P.push("renderAuth");const Y=this.authStorage.renderAuth||{};Object.keys(Y).length&&P.push(i),Y[i]=Y[i]||{},this.authStorage.renderAuth=Y,Object.keys(Y[i]).length&&P.push("clear"),Y[i].clear=Y[i].clear||{},Y[i].clear!==!0&&(Object.keys(Y[i].clear).length&&P.push(n),c?Y[i].clear[n]=!0:delete Y[i].clear[n]),e&&(P.length===1?(A=this.plugin)==null||A.updateAttributes(P,L.cloneDeep(this.authStorage)):P.length===2?(O=this.plugin)==null||O.updateAttributes(P,L.cloneDeep(Y)):P.length===3?(j=this.plugin)==null||j.updateAttributes(P,L.cloneDeep(Y[i])):(E=this.plugin)==null||E.updateAttributes(P,c?!0:void 0));return}}}addAuthStateListener(t){this.authDisposer=nt.autorun(async()=>{const e=this.getAuthSpaceData(),{renderAuth:s,pageAuth:i}=e;let n,r;L.isEqual(s,this.authStorage.renderAuth)||(n=this.diffAuthFun(this.authStorage.renderAuth||{},s||{}),this.authStorage.renderAuth=s),L.isEqual(i,this.authStorage.pageAuth)||(r=this.diffAuthPageFun(this.authStorage.pageAuth||{},i||{}),this.authStorage.pageAuth=i),(n||r)&&t(n,r)})}removeAuthStateListener(){this.authDisposer&&this.authDisposer()}diffAuthFun(t,e){const s=Ct(t),i=Ct(e),n={};for(const r of i)if(!s.includes(r)||t[r]===void 0){n[r]={newValue:e[r],oldValue:void 0};continue}for(const r of s)if(!L.isEqual(t[r],e[r])){if(!i.includes(r)||e[r]===void 0){n[r]={newValue:void 0,oldValue:t[r]};continue}n[r]={newValue:e[r],oldValue:t[r]}}return n}diffAuthPageFun(t,e){const s=Ct(t),i=Ct(e),n={};for(const r of i)if(!s.includes(r)||t[r]===void 0){n[r]={newValue:e[r],oldValue:void 0};continue}for(const r of s)if(!L.isEqual(t[r],e[r])){if(!i.includes(r)||e[r]===void 0){n[r]={newValue:void 0,oldValue:t[r]};continue}n[r]={newValue:e[r],oldValue:t[r]}}return n}};M(Rt,"namespace","PluginState"),M(Rt,"authSpace","PluginAuth"),M(Rt,"syncInterval",500);let Co=Rt;class Wf{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 Qt=(a=>(a[a.Text=1]="Text",a[a.Shape=2]="Shape",a))(Qt||{});const Uf="cursorhover",Bf=20,vt="mainView",zt=class zt{createProxy(o){const t=new Proxy(o,{get(e,s,i){const n=zt.interceptors.hasOwnProperty(s)?zt.interceptors:e;return Reflect.get(n,s,i)}});return zt.proxyToRaw.set(t,o),t}};M(zt,"proxyToRaw",new WeakMap),M(zt,"interceptors",{entries(...o){return zt.proxyToRaw.get(this).entries(...o)},forEach(...o){return zt.proxyToRaw.get(this).forEach(...o)},size(){return zt.proxyToRaw.get(this).size},get(o){return zt.proxyToRaw.get(this).get(o)},set(o,t){return zt.proxyToRaw.get(this).set(o,t)},delete(o,t){return zt.proxyToRaw.get(this).delete(o)},clear(){return zt.proxyToRaw.get(this).clear()}});let oe=zt;class Ff{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 oe;const i=this,n=oe.interceptors.set;oe.interceptors.set=function(c,l){return i.interceptors.set(c,l),n.call(this,c,l)};const r=oe.interceptors.delete;oe.interceptors.delete=function(c,l){return i.interceptors.delete(c,l),r.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,m,y,N,w,I,S;if(!this.collector)return!0;const{viewId:e,scenePath:s,canSync:i,canWorker:n,type:r,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=((m=this.collector)==null?void 0:m.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(v=>{var T;(T=this.control.worker)==null||T.taskBatchData.delete(v)}),(I=this.control.worker)==null||I.taskBatchData.add({workId:o,msgType:z.UpdateNode,dataType:l||V.Local,toolsType:C.Text,opt:c,viewId:e,scenePath:s,willRefresh:!0}),(S=this.control.worker)==null||S.runAnimation()),i&&ne(()=>{var v;(v=this.collector)==null||v.dispatch({type:z.UpdateNode,workId:o,toolsType:C.Text,opt:c,viewId:e,scenePath:s})},this.control.worker.maxLastSyncTime)):r===Qt.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&&((N=this.control.worker)==null||N.taskBatchData.add({workId:o,msgType:c.text&&z.FullWork||z.CreateWork,dataType:l||V.Local,toolsType:C.Text,opt:c,viewId:e,scenePath:s,willRefresh:!0}),(w=this.control.worker)==null||w.runAnimation()))},delete:o=>{var r,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&&((r=this.control.worker)==null||r.taskBatchData.add({workId:o,toolsType:C.Text,msgType:z.RemoveNode,dataType:V.Local,viewId:e,scenePath:s,willRefresh:!0}),(c=this.control.worker)==null||c.runAnimation()),i&&ne(()=>{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,r,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&&((r=this.control.worker)==null||r.taskBatchData.add({msgType:z.GetTextActive,dataType:V.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:r,boxSize:c}=n.opt,l=r&&((e=this.control.viewContainerManager)==null?void 0:e.transformToOriginPoint(r,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:Qt.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,m;const{workId:t,opt:e,msgType:s,viewId:i,scenePath:n,dataType:r}=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:Qt.Text,canWorker:!0,canSync:!1,dataType:r,scale:((m=d==null?void 0:d.cameraOpt)==null?void 0:m.scale)||1,viewId:i,scenePath:n};this.editors.set(c,p),r===V.Service&&e.workState===D.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=D.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=D.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=V.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=V.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=V.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 r=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:r})}),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,r={...this.editors.get(e)||{},...i};if(s){r.canWorker=!1,r.canSync=!1,this.editors.set(e,r),this.active(e);return}this.editors.set(e,r),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 r=n.viewId;n.canSync=t,n.canWorker=e,this.editors.delete(i),this.activeId===i&&(this.activeId=void 0),s.add(r)}}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 Vf{constructor(o){M(this,"expirationTime",Pt.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",Pt.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 r;const{event:t,payload:e}=o;if(t!==this.eventName)return;const{uid:s,op:i,type:n}=e;if(((r=this.control.collector)==null?void 0:r.uid)!==s&&n===be.Cursor&&(i!=null&&i.length)){const c=this.willConsumeEventWorkers.get(s)||[];for(const l of i){const{viewId:h}=l;L.isNumber(l.consumPoint[0])&&L.isNumber(l.consumPoint[1])&&(l.consumPoint=this.control.viewContainerManager.transformToOriginPoint(l.consumPoint,h)),this.control.renderControl.isFilterCursor(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}${Ut}${t}`}getUidAndviewId(o){const[t,e]=o.split(Ut);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===D.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),r=this.roomMember.getRoomMember(i);if(!r){this.animationDrawWorkers.delete(e);continue}const{consumPoint:c,timestamp:l,workState:h}=s,u=this.cursorInfoMap.get(n)||new Map;c&&L.isNumber(c[0])&&L.isNumber(c[1])&&l+this.expirationTime>o?u.set(r.memberId,{x:c[0],y:c[1],roomMember:r,timestamp:l,type:1,workState:h}):u.delete(r.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!==D.Done&&t.add(i);else this.cursorInfoMap.delete(e);for(const[e,s]of this.willConsumeEventWorkers.entries()){const i=this.roomMember.getRoomMember(e);if(L.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:r,timestamp:c}=s,l=this.cursorInfoMap.get(n)||new Map;r&&L.isNumber(r[0])&&L.isNumber(r[1])&&c+this.expirationTime>o?l.set(i.memberId,{x:r[0],y:r[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([q.Cursor,e],[]));for(const[e,s]of this.cursorInfoMap.entries())if(s!=null&&s.size){const i=[];for(const[r,c]of s.entries()){const{timestamp:l,...h}=c;l+this.expirationTime>o?i.push(h):(s.delete(r),s.size===0&&(this.cursorInfoMap.delete(e),this.doneRenderCursorInfoMap.delete(e),this.internalMsgEmitter.emit([q.Cursor,e],[])))}const n=this.doneRenderCursorInfoMap.get(e);L.isEqual(n,i)||(this.doneRenderCursorInfoMap.set(e,i),this.internalMsgEmitter.emit([q.Cursor,e],i))}else this.cursorInfoMap.delete(e),this.doneRenderCursorInfoMap.delete(e),this.internalMsgEmitter.emit([q.Cursor,e],[]);(this.willConsumeEventWorkers.size||this.cursorInfoMap.size)&&this.runAnimation()}sendEvent(o,t){if(this.displayer&&nt.isRoom(this.displayer)){const e=L.isNumber(o[0])&&L.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:be.Cursor,op:L.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 r=this.roomMember.getRoomMember(e);if(!r||e===((n=this.control.collector)==null?void 0:n.uid))return;const c=this.getKey(e,i);let l=[void 0,void 0];if(L.isNumber(t[0])&&L.isNumber(t[1])){const[u,d]=this.control.viewContainerManager.transformToOriginPoint(t,i);l=[u,d]}if(s===D.Start){for(const u of this.cursorInfoMap.values())if(u!=null&&u.size)for(const d of u.keys())d===r.memberId&&u.delete(d)}const h={consumPoint:l,workState:s,viewId:i,timestamp:Date.now()};if(s===D.Start||s===D.Done){const u=this.willConsumeEventWorkers.get(e);s===D.Start&&u&&this.willConsumeEventWorkers.delete(e),u&&s===D.Done&&(h.timestamp=h.timestamp-this.expirationTime)}this.animationDrawWorkers.set(c,h),this.runAnimation()}}unabled(){var o;this.displayer&&nt.isRoom(this.displayer)&&(this.willSendEventWorkers.length=0,this.displayer.dispatchMagixEvent(this.eventName,{type:be.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([q.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 At{constructor(){M(this,"useEmtMsg");M(this,"emtType");M(this,"control");M(this,"mainEngine")}static dispatch(o,t,e){var s;(s=Tt.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,r]of o)(e=this.mainEngine)==null||e.queryTaskBatchData(r).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){ne(()=>{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:D.Done};this.collect(t,!0),(o=Tt.InternalMsgEmitter)==null||o.emit(R.ActiveMethod,!1)}}recover(){var o;this.useEmtMsg&&Tt.InternalMsgEmitter.hasListeners(R.ActiveMethod)&&((o=Tt.InternalMsgEmitter)==null||o.emit(R.ActiveMethod,!0))}}class Hf extends At{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,r=Date.now();this.mainEngine.internalMsgEmitter.emit("addUndoTicker",r,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:r});break}if(p.toolsType===C.Text&&p.opt&&p.opt.workState&&p.opt.workState!==D.Done){const f=p&&this.copyText({viewId:s,store:p});f&&this.pasteText({...f,viewId:s,scenePath:n,key:d,store:p,undoTickerId:r});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,r=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:r,textCenter:l}}pasteText(t){var y,N;const{bgCenter:e,textCenter:s,store:i,key:n,viewId:r,scenePath:c,undoTickerId:l}=t,h=this.control.viewContainerManager.getView(r);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],m=(this.serviceColloctor.isLocalId(n)?n:this.serviceColloctor.getLocalId(n.toString()))+"-"+l;if(i.toolsType===C.Text&&i.opt){const w=i.opt;if(w&&w.boxPoint&&w.text){w.workState=D.Done;const I=w.boxPoint;w.boxPoint=[I[0]+p[0],I[1]+p[1]],w.workState=D.Done;const S=this.control.viewContainerManager.transformToOriginPoint(w.boxPoint,r);this.control.textEditorManager.createTextForMasterController({workId:m,x:S[0],y:S[1],opt:w,scale:((N=h.cameraOpt)==null?void 0:N.scale)||1,type:Qt.Text,isActive:!1,viewId:r,scenePath:c}),this.collectForServiceWorker([{...i,opt:w,type:z.FullWork,workId:m,viewId:r,scenePath:c}])}}}copySelector(t){var m,y,N,w,I,S,v,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 r=new Map,c={offset:{x:0,y:0},cameraOpt:{centerX:((m=i.cameraOpt)==null?void 0:m.centerX)||0,centerY:((y=i.cameraOpt)==null?void 0:y.centerY)||0,scale:((N=i.cameraOpt)==null?void 0:N.scale)||1}},l=this.control.hasOffscreenCanvas()&&((w=i.displayer.canvasBgRef.current)==null?void 0:w.getBoundingClientRect())||((I=i.displayer.canvasContainerRef.current)==null?void 0:I.getBoundingClientRect()),h=(v=(S=i.displayer)==null?void 0:S.floatBarRef.current)==null?void 0:v.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&&r.set(b,A)}return{copyStores:r,copyCoordInfo:c}}pasteSelector(t){var m;const{copyStores:e,copyCoordInfo:s,viewId:i,scenePath:n,undoTickerId:r}=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,N]of e.entries()){const I=(this.serviceColloctor.isLocalId(y)?y:this.serviceColloctor.getLocalId(y.toString()))+"-"+r,S={useAnimation:!1};if(N.toolsType===C.Text&&N.opt){const v=N.opt;if(v&&v.boxPoint&&v.text){v.workState=D.Done;const T=v.boxPoint;v.boxPoint=[T[0]+d[0],T[1]+d[1]],v.workState=D.Done;const x=this.control.viewContainerManager.transformToOriginPoint(v.boxPoint,i);this.control.textEditorManager.createTextForMasterController({workId:I,x:x[0],y:x[1],opt:v,scale:((m=c.cameraOpt)==null?void 0:m.scale)||1,type:Qt.Text,isActive:!1,viewId:i,scenePath:n})}f.push({...N,opt:v,type:z.FullWork,workId:I,viewId:i,scenePath:n});continue}if(N.toolsType===C.Image&&(N.opt.uuid=I,N.opt.centerX=N.opt.centerX+d[0],N.opt.centerY=N.opt.centerY+d[1]),N.ops){const v=ke(N.ops).map((x,b)=>{const A=b%3;return A===0?x+d[0]:A===1?x+d[1]:x}),T=Lt(v);N.ops=T}f.push({...N,updateNodeOpt:S,type:z.FullWork,workId:I,viewId:i,scenePath:n}),p.push([{...N,updateNodeOpt:S,workId:I,msgType:z.FullWork,dataType:V.Local,emitEventType:R.CopyNode,willSyncService:!1,willRefresh:!0,viewId:i},{workId:I,msgType:z.FullWork,emitEventType:R.CopyNode}])}p.length&&this.collectForLocalWorker(p),f.length&&this.collectForServiceWorker(f)}}function Oe(a,o,t){return"#"+((a<<16)+(o<<8)+t).toString(16).padStart(6,"0")}function Mt(a,o=1){return"rgba("+parseInt("0x"+a.slice(1,3))+","+parseInt("0x"+a.slice(3,5))+","+parseInt("0x"+a.slice(5,7))+","+o+")"}function We(a,o,t,e=1){return`rgba(${a},${o},${t},${e})`}function ho(a){const o=a.split(","),t=parseInt(o[0].split("(")[1]),e=parseInt(o[1]),s=parseInt(o[2]),i=Number(o[3].split(")")[0]);return[Oe(t,e,s),i]}function Ue(a){const o=a.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 Be(a){return a==="transparent"}class Qf extends At{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.SetColorNode);M(this,"undoTickerId")}setTextColor(t,e,s,i){const{fontColor:n,fontBgColor:r}=s;e.opt&&(n&&(e.opt.fontColor=n),r&&(e.opt.fontBgColor=r),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:r,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],m=this.serviceColloctor.storage,y=[],N={};for((l===D.Start||!this.undoTickerId&&l===D.Done)&&(this.undoTickerId=Date.now(),this.mainEngine.internalMsgEmitter.emit("addUndoTicker",this.undoTickerId,c));f.length;){const w=f.pop();if(!w)continue;const I=w.toString(),S=this.serviceColloctor.isLocalId(I),v=S?this.serviceColloctor.transformKey(w):I;let T=I;!S&&this.serviceColloctor.isOwn(T)&&(T=this.serviceColloctor.getLocalId(T));const x=m[c][p][v]||void 0;if(x){const b=x.updateNodeOpt||{};if(n||r){if(n){b.fontColor=n;const[O,j,E,P]=Ue(n);N.textColor=[O,j,E],N.textOpacity=P}if(r)if(b.fontBgColor=Be(r)?"transparent":r,Be(r))N.textBgColor=void 0,N.textBgOpacity=void 0;else{const[O,j,E,P]=Ue(r);N.textBgColor=[O,j,E],N.textBgOpacity=P}if(x.toolsType===C.Text&&x.opt&&l!==D.Start){this.setTextColor(T,qt(x),b,c),l===D.Done&&(this.undoTickerId=void 0);continue}}if(s){b.strokeColor=s;const[O,j,E,P]=Ue(s);N.strokeColor=[O,j,E],N.strokeOpacity=P}if(i)if(b.fillColor=Be(i)?"transparent":i,Be(i))N.fillColor=void 0,N.fillOpacity=void 0;else{const[O,j,E,P]=Ue(i);N.fillColor=[O,j,E],N.fillOpacity=P}h&&(b.thickness=h,N.strokeWidth=h),u&&(b.strokeType=u,N.strokeType=u);const A={workId:T,msgType:z.UpdateNode,dataType:V.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===D.Done&&(this.undoTickerId=void 0),this.collectForLocalWorker(y)),Object.keys(N).length&&setTimeout(()=>{var w;(w=this.control.room)==null||w.setMemberState(N)},0)}}class $f extends At{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 r=n.focusScenePath,c=[...e],l=this.serviceColloctor.storage,h=[],u=[];for(;c.length;){const p=c.pop();if(!p)continue;const f=p.toString(),m=this.serviceColloctor.isLocalId(f),y=m?this.serviceColloctor.transformKey(p):f;let N=f;!m&&this.serviceColloctor.isOwn(N)&&(N=this.serviceColloctor.getLocalId(N));const w=qt(l[i][r][y]);let I;if(w&&N===H){if(w.selectIds){u.push(...w.selectIds),u.sort((x,b)=>{var j,E,P,Y;const A=((E=(j=l[d(x,this.serviceColloctor)])==null?void 0:j.opt)==null?void 0:E.zIndex)||0,O=((Y=(P=l[d(x,this.serviceColloctor)])==null?void 0:P.opt)==null?void 0:Y.zIndex)||0;return A>O?1:x<b?-1:0});const S=w.updateNodeOpt||{};S.zIndexLayer=s;const v={workId:p,msgType:z.UpdateNode,dataType:V.Local,updateNodeOpt:S,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:i},T=new Map;s===ie.Top?(this.addMaxLayer(i),I=this.getMaxZIndex(i)):(this.addMinLayer(i),I=this.getMinZIndex(i)),u.forEach(x=>{var j,E,P;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][r][A];!b&&((P=this.serviceColloctor)!=null&&P.isOwn(A))&&(A=this.serviceColloctor.getLocalId(A)),S.zIndex=I,O!=null&&O.opt&&(O.opt.zIndex=I),O!=null&&O.opt&&T.set(A,{updateNodeOpt:O.updateNodeOpt,opt:O.opt})}),v.selectStore=T,v.willSerializeData=!0,h.push([v,{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 Gf extends At{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:r}=t;this.lastEmtData=t;const c=this.control.viewContainerManager.getView(r);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,h=[...s],u=(f=this.serviceColloctor)==null?void 0:f.storage,d=[],p=n===D.Start&&Date.now()||void 0;for(p&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,r);h.length;){const m=h.pop();if(!m)continue;const y=m.toString(),N=this.serviceColloctor.isLocalId(y),w=N&&this.serviceColloctor.transformKey(m)||y;let I=y;!N&&this.serviceColloctor.isOwn(I)&&(I=this.serviceColloctor.getLocalId(I));const S=u[r][l][w];if(S&&I===H){if(S.selectIds){const v=this.control.viewContainerManager.transformToScenePoint([i.x,i.y],r);if(n===D.Start&&(this.cachePosition=v),this.cachePosition){const T=S.updateNodeOpt||{};T.translate=[v[0]-this.cachePosition[0],v[1]-this.cachePosition[1]],T.workState=n;const x={workId:m,msgType:z.UpdateNode,dataType:V.Local,updateNodeOpt:T,emitEventType:this.emitEventType,willSyncService:!0,textUpdateForWoker:!0,viewId:r};n===D.Done&&(x.textUpdateForWoker=!0,x.willSerializeData=!0,this.cachePosition=void 0),d.push([x,{workId:m,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}}continue}}n===D.Start?this.mainEngine.unWritable():n===D.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length&&this.collectForLocalWorker(d,e)}}class Zf extends At{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,r=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),m=f?this.serviceColloctor.transformKey(d):p,y=r[s][n][m];if(y){let N=p;if(!f&&this.serviceColloctor.isOwn(N)&&(N=this.serviceColloctor.getLocalId(N)),y.toolsType===C.Text){this.control.textEditorManager.delete(N,!0,!0);continue}h.push(N)}}h.length&&(l.push([{msgType:z.RemoveNode,emitEventType:R.DeleteNode,removeIds:h,dataType:V.Local,willSyncService:!0,willRefresh:!0,viewId:s},void 0]),this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,s),this.collectForLocalWorker(l))}}class qf extends At{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 w,I,S,v,T;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:s,workState:i,viewId:n,originPoint:r,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],m=(w=this.serviceColloctor)==null?void 0:w.storage,y=[],N=i===D.Start&&Date.now()||void 0;for(N&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",N,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=m[n][p][O];if(E&&j===H&&E.selectIds){const P=E.updateNodeOpt||{};if(P.dir=l,P.originPoint=r,P.scenePoint=c,P.workState=i,P.scale=h,P.translate=u,i===D.Start){this.cacheTextInfo.clear();for(const et of E.selectIds){const tt=(I=this.serviceColloctor)==null?void 0:I.isLocalId(et),$=tt&&((S=this.serviceColloctor)==null?void 0:S.transformKey(et))||et;let J=$;!tt&&((v=this.serviceColloctor)!=null&&v.isOwn($))&&(J=this.serviceColloctor.getLocalId($));const G=this.control.textEditorManager.get(J);G&&i===D.Start&&this.targetText.set(J,qt(G))}}if(this.targetText.size&&i!==D.Start&&h){const et=[];for(const[$,J]of this.targetText.entries()){const{opt:G}=J,Z=Math.floor(G.fontSize*h[0]),X=this.cacheTextInfo.get($),rt=!X&&G.fontSize!==Z||X&&X.fontSize!==Z||!1,wt=(T=this.control.textEditorManager.get($))==null?void 0:T.opt;if(rt&&wt&&G.boxSize&&G.boxPoint){const ot=this.setTextStyle($,{...wt,fontSize:Z},n);et.push(ot)}}const tt=await Promise.all(et);for(const $ of tt)if($){const{key:J,textInfo:G}=$;this.cacheTextInfo.set(J,{fontSize:G.opt.fontSize,boxSize:G.opt.boxSize,boxPoint:G.opt.boxPoint})}P.textInfos=this.cacheTextInfo}const Y={workId:x,msgType:z.UpdateNode,dataType:V.Local,updateNodeOpt:P,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:n};i===D.Done&&(Y.willSerializeData=!0,this.targetText.clear()),y.push([Y,{workId:x,msgType:z.UpdateNode,emitEventType:this.emitEventType}]);continue}}i===D.Start?this.mainEngine.unWritable():i===D.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),y.length&&this.collectForLocalWorker(y,e)}}class Jf extends At{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.RotateNode);M(this,"cacheOriginRotate",0)}collect(t,e){var f,m,y,N,w;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:s,angle:i,workState:n,viewId:r}=t;this.lastEmtData=t;const c=this.control.viewContainerManager.getView(r);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,h=[...s],u=(f=this.serviceColloctor)==null?void 0:f.storage,d=[],p=n===D.Start&&Date.now()||void 0;for(p&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,r);h.length;){const I=h.pop();if(!I)continue;const S=I.toString(),v=this.serviceColloctor.isLocalId(S),T=v&&this.serviceColloctor.transformKey(I)||S;let x=S;!v&&this.serviceColloctor.isOwn(x)&&(x=this.serviceColloctor.getLocalId(x));const b=u[r][l][T];if(b&&x===H){if(((m=b.selectIds)==null?void 0:m.length)===1){const A=b.selectIds[0];if(n===D.Start){const P=((y=this.serviceColloctor)==null?void 0:y.isLocalId(A))&&((N=this.serviceColloctor)==null?void 0:N.transformKey(A))||A,Y=u[r][l][P];this.cacheOriginRotate=((w=Y==null?void 0:Y.opt)==null?void 0:w.rotate)||0}const O=b.updateNodeOpt||{};O.angle=(i+this.cacheOriginRotate)%360,O.workState=n;const j={workId:I,msgType:z.UpdateNode,dataType:V.Local,updateNodeOpt:O,emitEventType:this.emitEventType,willRefreshSelector:!1,willSyncService:!0,viewId:r};n===D.Done&&(j.willRefreshSelector=!0,j.willSerializeData=!0,this.cacheOriginRotate=0),d.push([j,{workId:I,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}continue}}n===D.Start?this.mainEngine.unWritable():n===D.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length&&this.collectForLocalWorker(d,e)}}function Xf(a){switch(a){case C.Text:return Qt.Text;case C.SpeechBalloon:case C.Star:case C.Ellipse:case C.Rectangle:case C.Triangle:case C.Rhombus:case C.Polygon:return Qt.Shape}}class Kf extends At{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.SetFontStyle);M(this,"timerId")}async setTextStyle(t,e,s,i){const{bold:n,underline:r,lineThrough:c,italic:l,fontSize:h}=s;if(e.toolsType&&Xf(e.toolsType)===Qt.Text){e.opt&&(n&&(e.opt.bold=n),L.isBoolean(r)&&(e.opt.underline=r),L.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 w,I,S,v;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,bold:s,italic:i,lineThrough:n,underline:r,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={},m=Date.now();this.mainEngine.internalMsgEmitter.emit("addUndoTicker",m,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"),L.isBoolean(n)&&(E.lineThrough=n,f.lineThrough=n),L.isBoolean(r)&&(E.underline=r,f.underline=r),l&&(E.fontSize=l,f.textSize=l),j.toolsType===C.Text&&j.opt){const P=this.setTextStyle(O,L.cloneDeep(j),E,c);y.push(P);continue}if(j&&O===H&&((w=j.selectIds)!=null&&w.length))for(const P of j.selectIds){const Y=(I=this.serviceColloctor)==null?void 0:I.isLocalId(P);let et=Y&&((S=this.serviceColloctor)==null?void 0:S.transformKey(P))||P;const tt=p[c][u][et]||void 0;if(!Y&&((v=this.serviceColloctor)!=null&&v.isOwn(et))&&(et=this.serviceColloctor.getLocalId(et)),tt&&tt.toolsType===C.Text&&j.opt){const $=this.setTextStyle(et,L.cloneDeep(tt),E,c);y.push($);continue}}}}const N=await Promise.all(y);for(const T of N)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 _f extends At{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.SetPoint);M(this,"undoTickerId")}collect(t){var w;if(!this.serviceColloctor||!this.mainEngine)return;const{workId:e,pointMap:s,workState:i,viewId:n}=t,r=this.control.viewContainerManager.getView(n);if(!(r!=null&&r.displayer))return;const c=r.focusScenePath,l=(w=this.serviceColloctor)==null?void 0:w.storage,h=[],u=i===D.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),m=f&&this.serviceColloctor.transformKey(d)||p;let y=p;!f&&this.serviceColloctor.isOwn(y)&&(y=this.serviceColloctor.getLocalId(y));const N=l[n][c][m];if(N&&y===H&&N.selectIds){const I=N.updateNodeOpt||{};I.pointMap=s,I.workState=i;const S={workId:d,msgType:z.UpdateNode,dataType:V.Local,updateNodeOpt:I,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:n};i===D.Done&&(S.undoTickerId=this.undoTickerId),h.push([S,{workId:d,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}i===D.Start?this.mainEngine.unWritable():i===D.Done&&this.mainEngine.abled(),h.length&&this.collectForLocalWorker(h)}}class tg extends At{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 r=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),m=f?this.serviceColloctor.transformKey(d):p;let y=p;!f&&this.serviceColloctor.isOwn(y)&&(y=this.serviceColloctor.getLocalId(y));const N=l[i][r][m]||void 0;if(N){const w=N.updateNodeOpt||{};w.isLocked=s;const I={workId:y,msgType:z.UpdateNode,dataType:V.Local,updateNodeOpt:w,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:i};h.push([I,{workId:y,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}}this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,i),h.length&&this.collectForLocalWorker(h)}}class eg extends At{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 r=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),m=f?this.serviceColloctor.transformKey(d):p;let y=p;!f&&this.serviceColloctor.isOwn(y)&&(y=this.serviceColloctor.getLocalId(y));const N=l[s][r][m]||void 0;if(N){const w={...N.updateNodeOpt,...i,willRefresh:!0};if(N&&y===H){const I={workId:y,msgType:z.UpdateNode,dataType:V.Local,updateNodeOpt:w,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:s};h.push([I,{workId:y,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}}}h.length&&(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,s),this.collectForLocalWorker(h))}}class K{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 Gf;case R.ZIndexNode:return new $f;case R.CopyNode:return new Hf;case R.SetColorNode:return new Qf;case R.DeleteNode:return new Zf;case R.ScaleNode:return new qf;case R.RotateNode:return new Jf;case R.SetFontStyle:return new Kf;case R.SetPoint:return new _f;case R.SetLock:return new tg;case R.SetShapeOpt:return new eg}}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){At.dispatch(o,t,e)}static activeListener(o){Tt.InternalMsgEmitter.on(R.ActiveMethod,o)}static unmountActiveListener(o){Tt.InternalMsgEmitter.off(R.ActiveMethod,o)}}class og{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:V.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 sg(o,t,this)}consume(o){var t;for(const e of o.values()){const{msgType:s,viewId:i,layerOpt:n,offscreenCanvasOpt:r,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&&r){const d=this.createMainThreadWorker(i,{displayer:h,container:u,layerOpt:n,master:this.master,canvasOpt:r,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 sg{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=Pt.bufferSize.full,i=Pt.bufferSize.sub;this.subLocalLayer=this.createLayer("subLocalLayer",this.scene,{...t.layerOpt,bufferSize:this.viewId===vt?s:i});const n={thread:this};this.subLocalWork=new ig(n)}createScene(o){return new lt.Scene({displayRatio:this.opt.displayer.dpr,depth:!1,desynchronized:!0,...o,contextType:"2d",autoRender:!0,id:this.viewId})}createLayer(o,t,e){const{width:s,height:i}=e,n=`canvas-${o}`,r=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 r.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:r}=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)&&(r===D.Done&&i===V.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&&!L.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&&L.isNumber(parseInt(e.id))&&parseInt(e.id)<o);for(const e of t)e.disconnect(),this.subLocalLayer.removeChild(e)}}class ig{constructor(o){M(this,"thread");M(this,"workShapes",new Map);M(this,"tmpOpt");M(this,"syncUnitTime",Pt.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 r=Math.max(n.getMaxDrawCount(),this.drawCount);n.setMaxDrawCount(r)}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 Ni({...o,fullLayer:this.thread.subLocalLayer,drawLayer:this.thread.subLocalLayer})}clearWorkShapeNodeCache(o){this.workShapes.delete(o)}getWorkShape(o){return this.workShapes.get(o)}}const ng=async(a,o)=>{const{src:t,isgl:e,isCache:s}=a;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(r=>{n(r)})},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 rg{constructor(){M(this,"maxLastSyncTime",Pt.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 ag extends rg{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:D.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-BG79OM_x.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 og(this),this.fullWorker.onmessage=t=>{var e,s;if(t.data){const{render:i,sp:n,drawCount:r,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(r&&l){if(this.setWorkDrawCount(r),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"&&L.isNumber(i)){if(this.setSubWorkerDrawCount(i),this.wokerDrawCount<1/0){const r=Math.max(this.maxDrawCount,this.subWorkerDrawCount);this.setMaxDrawCount(r)}if(e!=null&&e.length)if(this.subWorkerDrawCount>this.wokerDrawCount){const r=[];for(const c of e)c.imageBitmap&&(c.isUnClose=!0,r.push(c));this.reRenders.set(this.subWorkerDrawCount,r)}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(L.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()===D.Doing}getLockSentEventCursor(){return this.isLockSentEventCursor}setLockSentEventCursor(t){this.isLockSentEventCursor=t}getTasksqueueState(){return this.useTasksqueue&&D.Doing||D.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 r of t){const{type:c,selectIds:l,opt:h,selectRect:u,strokeColor:d,fillColor:p,willSyncService:f,isSync:m,imageBitmap:y,canvasHeight:N,canvasWidth:w,rect:I,op:S,canTextEdit:v,points:T,selectorColor:x,canRotate:b,scaleType:A,textOpt:O,toolsType:j,workId:E,viewId:P,dataType:Y,canLock:et,isLocked:tt,shapeOpt:$,toolsTypes:J,thickness:G,strokeType:Z,useStroke:X,isgl:rt,imageSrc:wt,isSubWorker:ot}=r;if(!P)return;const at=r.scenePath||this.viewContainerManager.getCurScenePath(P);switch(c){case z.Select:{const U=l!=null&&l.length?{...u,selectIds:l,canvasHeight:N,canvasWidth:w,points:T}:void 0;U&&(h!=null&&h.strokeColor)&&(U.selectorColor=h.strokeColor),U&&x&&(U.selectorColor=x),U&&d&&(U.strokeColor=d),U&&(h!=null&&h.fillColor)&&(U.fillColor=h.fillColor),U&&p&&(U.fillColor=p),U&&L.isBoolean(b)&&(U.canRotate=b),U&&A&&(U.scaleType=A),U&&v&&(U.canTextEdit=v),U&&O&&(U.textOpt=O),U&&L.isBoolean(et)&&(U.canLock=et),U&&L.isBoolean(tt)&&(U.isLocked=tt),U&&$&&(U.shapeOpt=$),U&&J&&(U.toolsTypes=J),U&&G&&(U.thickness=G),U&&Z&&(U.strokeType=Z),U&&L.isBoolean(X)&&(U.useStroke=X),P&&this.viewContainerManager.showFloatBar(P,!!U,U),f&&((s=this.collector)==null||s.dispatch({type:c,selectIds:l,opt:h,isSync:m,viewId:P,scenePath:at}));break}case z.Snapshot:if(y&&at){const U=this.snapshotMap.get(at);U&&U(y)}break;case z.BoundingBox:if(I&&at){const U=this.boundingRectMap.get(at);U&&U(I)}break;case z.Cursor:S&&this.control.cursor.collectServiceCursor({...r});break;case z.Clear:if(P){this.viewContainerManager.showFloatBar(P,!1);const U=(i=this.clearAllResolveMap.get(P))==null?void 0:i.resolve;U&&U(P)}break;case z.TextUpdate:if(j===C.Text&&E&&P){const U=this.viewContainerManager.transformToOriginPoint((h==null?void 0:h.boxPoint)||[0,0],P),it=(h==null?void 0:h.boxSize)||[0,0],ht=(n=this.viewContainerManager.getView(P))==null?void 0:n.cameraOpt;h?this.control.textEditorManager.updateTextForWorker({x:U[0],y:U[1],w:it[0],h:it[1],scale:(ht==null?void 0:ht.scale)||1,workId:E,opt:h,dataType:Y,viewId:P,canSync:f||!1,canWorker:!1}):this.control.textEditorManager.delete(E,f||!1,!1)}break;case z.GetTextActive:j===C.Text&&E&&P&&this.control.textEditorManager.updateTextForWorker({workId:E,isActive:!0,viewId:P,dataType:V.Local,canWorker:!1,canSync:!0},Date.now());break;case z.GetImageBitMap:wt&&E&&P&&ng({src:wt,isgl:rt}).then(U=>{var ht;const it=new Set;if(it.add({msgType:z.GetImageBitMap,dataType:V.Local,workId:E,viewId:P,imageSrc:wt,isSubWorker:ot,imageBitmap:U}),!this.control.hasOffscreenCanvas())(ht=this.mainThread)==null||ht.consume(it);else{const It=ot?this.subWorker:this.fullWorker;U?It.postMessage(it,[U]):It.postMessage(it)}});break;default:e=!0;break}}e&&ne(()=>{this.collectorAsyncData(t)},this.maxLastSyncTime)}collectorAsyncData(t){var e,s,i,n;for(const r of t){const{type:c,op:l,workId:h,index:u,removeIds:d,ops:p,opt:f,updateNodeOpt:m,toolsType:y,isSync:N,viewId:w,isLockSentEventCursor:I,nextTasks:S}=r;if(!w){console.error("collectorAsyncData",r);return}const v=r.scenePath||this.viewContainerManager.getCurScenePath(w);switch(c){case z.None:{I&&ne(()=>{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:N,viewId:w,scenePath:v,updateNodeOpt:m});break}case z.FullWork:{(s=this.collector)==null||s.dispatch({type:c,ops:p,workId:h,updateNodeOpt:m,opt:f,toolsType:y,isSync:N,viewId:w,scenePath:v}),this.willSelectorWorkId&&h&&h.toString()===this.willSelectorWorkId&&this.control.runEffectWork(()=>{this.setShapeSelectorByWorkId(this.willSelectorWorkId,w),this.willSelectorWorkId=void 0});break}case z.UpdateNode:{(i=this.collector)==null||i.dispatch({type:c,updateNodeOpt:m,workId:h,opt:f,ops:p,op:l,isSync:N,viewId:w,scenePath:v});break}case z.RemoveNode:{d&&this.control.textEditorManager.deleteBatch(d,!1,!1),(n=this.collector)==null||n.dispatch({type:c,removeIds:d,isSync:N,viewId:w,scenePath:v}),this.willSelectorWorkId&&(d!=null&&d.includes(this.willSelectorWorkId))&&(this.willSelectorWorkId=void 0);break}}S&&ne(()=>{this.collectorAsyncData(S)},this.maxLastSyncTime)}}async onLocalEventEnd(t,e){var l;const s=this.viewContainerManager.getView(e);if(!s)return;const{focusScenePath:i,cameraOpt:n}=s,r=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===D.Start){const p=this.currentLocalWorkData.toolsOpt;p.workState=D.Doing,p.boxPoint=r,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:Qt.Text,isActive:!0,viewId:e,scenePath:i},Date.now())}this.deleteLocalPoint(h);continue}else this.pushLocalPoint(h,r,D.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===D.Start&&this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:D.Doing});let s=!1;for(const[n,{state:r}]of this.localPointsBatchData.entries())if(this.isAbled()&&r!==D.Pending){const c=this.viewContainerManager.transformToScenePoint(t,e);this.pushLocalPoint(n,c,r===D.Start?D.Doing:r,e),s=!0}if(s){this.runAnimation();return}this.useTasksqueue||this.hoverCursor(t,e)}onLocalEventStart(t,e){var r,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=((r=this.currentToolsData)==null?void 0:r.toolsType)===C.Selector?H:Date.now(),i=this.setZIndex(e);this.setCurrentLocalWorkData({workState:D.Start,toolsOpt:i,viewId:e});const n=this.viewContainerManager.transformToScenePoint(t,e);if(this.pushLocalPoint(s,n,D.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 r=this.getLocalPointInfo(t);s===D.Start?r={state:D.Start,points:e,opt:n||this.currentLocalWorkData.toolsOpt,isFullWork:!1,viewId:i}:r&&(r.state=s,r.points.push(e[0],e[1])),r&&this.localPointsBatchData.set(t,r)}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;L.isNumber(h)&&n.push([l,h])});const r=n.length&&((c=this.zIndexNodeMethod)==null?void 0:c.correct(n))||[];this.zIndexNodeMethod&&r.length&&(this.zIndexNodeMethod.setMinZIndex(r[0][1]||0,e),this.zIndexNodeMethod.setMaxZIndex(r[r.length-1][1]||0,e));for(const[l,h]of r){if(!t[l])continue;const u=t[l];u.opt&&L.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 r,c;if(!this.isAbled())return;const i=(r=this.collector)==null?void 0:r.uid,n=this.viewContainerManager.getCurScenePath(s);if(!(i&&!this.control.renderControl.isWriteable())){switch((c=this.currentToolsData)==null?void 0:c.toolsType){case C.Eraser:case C.PencilEraser:case C.BitMapEraser:{if(i&&!this.control.renderControl.isClearAble({uid:i,viewId:s,scenePath:n}))return;break}default:{if(i&&!this.control.renderControl.isRenderAble({uid:i,viewId:s,scenePath:n}))return;break}}switch(t){case D.Start:this.setLocalWorkViewId(s),s&&this.onLocalEventStart(e,s);break;case D.Doing:s&&s===this.getLocalWorkViewId()&&this.onLocalEventDoing(e,s);break;case D.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,r;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&&((r=this.collector)!=null&&r.hasSelector(h,u)&&this.blurSelector(h,u),this.control.textEditorManager.checkEmptyTextBlur())}this.taskBatchData.add({msgType:z.UpdateTools,dataType:V.Local,toolsType:e,opt:{...t.toolsOpt,syncUnitTime:this.maxLastSyncTime},isRunSubWork:this.isRunSubWork,viewId:Ve}),this.runAnimation()}}prepareOnceWork(t,e){const{workId:s,toolsOpt:i,viewId:n}=t;this.queryTaskBatchData({msgType:z.CreateWork,dataType:V.Local,viewId:n,toolsType:e}).forEach(r=>{this.taskBatchData.delete(r)}),this.taskBatchData.add({msgType:z.CreateWork,workId:s,toolsType:e,opt:{...i,syncUnitTime:this.maxLastSyncTime},dataType:V.Local,isRunSubWork:this.isRunSubWork,viewId:n}),this.runAnimation()}createViewWorker(t,e){const{offscreenCanvasOpt:s,layerOpt:i,dpr:n,cameraOpt:r}=e;this.taskBatchData.add({msgType:z.Init,dataType:V.Local,viewId:t,offscreenCanvasOpt:s,layerOpt:i,dpr:n,cameraOpt:r,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.taskBatchData.add({msgType:z.Destroy,dataType:V.Local,viewId:t,isRunSubWork:!0}),this.consume(),e||(s=this.collector)==null||s.dispatch({type:z.Clear,viewId:t}),this.control.renderControl.destoryByViewId(t,e)}onServiceDerive(t,e){var p,f,m,y,N;const{newValue:s,oldValue:i,viewId:n,scenePath:r}=e,c=L.cloneDeep(s)||{},l=t;let h=c.type;if(!s&&i){if(l&&((p=this.collector)==null?void 0:p.getLocalId(l))===H){this.collector.isOwn(l)?this.blurSelector(n,r):this.blurSelector(n,r,l);return}if(h=z.RemoveNode,i.toolsType===C.LaserPen)return}const u=(f=this.viewContainerManager.getView(n))==null?void 0:f.focusScenePath;if(u&&u!==r)return;if(h&&l){if(!this.control.renderControl.isFilterAble({viewId:n,elementId:t,scenePath:r},h))return;const w=c;if(w.workId=(m=this.collector)!=null&&m.isOwn(l)?(y=this.collector)==null?void 0:y.getLocalId(l):l,w.msgType=h,w.toolsType===C.LaserPen&&(w.isRunSubWork=!0),w.dataType=V.Service,w.viewId=n,w.scenePath=r,w.selectIds&&(w.selectIds=w.selectIds.map(I=>{var S,v;return(S=this.collector)!=null&&S.isOwn(I)?(v=this.collector)==null?void 0:v.getLocalId(I):I})),w&&w.toolsType===C.Text||(i==null?void 0:i.toolsType)===C.Text){this.control.textEditorManager.onServiceDerive(w);return}this.taskBatchData.add(w)}this.runAnimation();const d=e.newValue&&((N=e.newValue.opt)==null?void 0:N.zIndex);if(this.zIndexNodeMethod&&L.isNumber(d)){const w=this.zIndexNodeMethod.getMinZIndex(n);this.zIndexNodeMethod.getMaxZIndex(n)<d&&this.zIndexNodeMethod.setMaxZIndex(d,n),w>d&&this.zIndexNodeMethod.setMinZIndex(d,n)}}pullServiceData(t,e,s={isAsync:!1,useAnimation:!1}){var c,l,h,u;let i=(c=this.collector)==null?void 0:c.getStorageData(t,e);const{isAsync:n,useAnimation:r}=s;if(i){this.control.renderControl.isWriteable()&&(i=this.correctStorage(i,t,e));const d=Object.keys(i);for(const p of d){const f=(l=i[p])==null?void 0:l.type;if(f&&p){if(!this.control.renderControl.isFilterAble({viewId:t,elementId:p,scenePath:e},f))continue;const m=i[p];if(m.workId=(h=this.collector)!=null&&h.isOwn(p)?(u=this.collector)==null?void 0:u.getLocalId(p):p,m.msgType=f,m.dataType=V.Service,m.viewId=t,m.scenePath=e,m.useAnimation=!!r,m.selectIds&&(m.selectIds=m.selectIds.map(y=>{var N,w;return(N=this.collector)!=null&&N.isOwn(y)?(w=this.collector)==null?void 0:w.getLocalId(y):y})),m.toolsType===C.Text){this.control.textEditorManager.onServiceDerive(m);continue}this.taskBatchData.add(m)}this.internalMsgEmitter.emit("excludeIds",d,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===V.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:r,opt:c}]of this.localPointsBatchData.entries()){if(i===D.Done&&!n||i===D.Start&&!this.isCanStartEventConsum)continue;const l=r.map(h=>h);l.length&&(this.delayWorkStateToDoneResolve&&i===D.Done&&(this.delayWorkStateToDoneResolve(!0),this.setLockSentEventCursor(!0)),this.taskBatchData.add({op:l,workState:i,workId:s,dataType:V.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}),r.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:D.Unwritable,workId:void 0})}abled(){this.setCurrentLocalWorkData({workState:D.Pending,workId:void 0})}isAbled(){return this.currentLocalWorkData.workState!==D.Unwritable}post(t){var s;if(!this.control.hasOffscreenCanvas()){if(!this.mainThread){let i=[];i=L.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:V.Local}),this.runAnimation()}destroyTaskQueue(){this.useTasksqueue=!1,this.useTasksClockId&&(clearTimeout(this.useTasksClockId),this.useTasksClockId=void 0),this.mainTasksqueueCount=void 0,this.workerTasksqueueCount=void 0}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:V.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:V.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 n,r;const i=this.viewContainerManager.getCurScenePath(t);if(s){const c=(n=this.collector)==null?void 0:n.uid;if(c&&!this.control.renderControl.isClearAble({uid:c,viewId:t,scenePath:i}))return}this.control.textEditorManager.clear(t,e),this.queryTaskBatchData({msgType:z.Clear,dataType:V.Local,viewId:t}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({dataType:V.Local,msgType:z.Clear,viewId:t}),this.runAnimation(),e||(this.control.renderControl.isUsePageAuth(t)&&i?this.control.renderControl.clearRenderPage(t,i):(r=this.collector)==null||r.dispatch({type:z.Clear,viewId:t,scenePath:i})),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(t),this.localPointsBatchData.clear(),await new Promise(c=>{const l=this.clearAllResolveMap.get(t)||{resolve:void 0,timer:void 0};l.timer&&clearTimeout(l.timer),l.resolve=c,l.timer=setTimeout(()=>{const h=this.clearAllResolveMap.get(t);h!=null&&h.resolve&&h.resolve(t)},this.maxLastSyncTime),this.clearAllResolveMap.set(t,l)}).then(c=>{this.clearAllResolveMap.delete(c)})}internalMsgEmitterListener(){var t;this.methodBuilder=new K([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(q.MainEngine,this.control),this.zIndexNodeMethod=(t=this.methodBuilder)==null?void 0:t.getBuilder(R.ZIndexNode)}setZIndex(t){const e=this.currentToolsData&&L.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,r;let e=!1;const s=[];for(const[c,{state:l,viewId:h,points:u,opt:d}]of this.localPointsBatchData.entries())if(t===h&&l===D.Start||l===D.Doing){if(l===D.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:V.Local,isRunSubWork:!0}));const p=u.map(f=>f);this.taskBatchData.add({op:p,workState:D.Done,workId:c,dataType:V.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;(r=this.collector)==null||r.dispatch({type:z.RemoveNode,removeIds:s,viewId:t,scenePath:c})}}removeDrawingWork(t){var s,i;const e=[];for(const[n,{state:r,viewId:c}]of this.localPointsBatchData.entries())(t===c&&r===D.Start||r===D.Doing)&&(this.deleteLocalPoint(n),r===D.Doing&&this.isCanDrawWork&&(e.push(n.toString()),this.taskBatchData.add({msgType:z.RemoveNode,workId:n,viewId:c,dataType:V.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(ki(t,{x:l,y:h,w:u,h:d}))return}}const n=this.viewContainerManager.transformToScenePoint(t,e),r={msgType:z.CursorHover,dataType:V.Local,point:n,toolsType:this.currentToolsData.toolsType,opt:this.currentToolsData.toolsOpt,isRunSubWork:!1,viewId:e};this.queryTaskBatchData({msgType:z.CursorHover,dataType:V.Local,toolsType:this.currentToolsData.toolsType,viewId:e}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add(r),this.runAnimation()}}blurCursor(t){var s;if(((s=this.currentToolsData)==null?void 0:s.toolsType)!==C.Selector)return;const e={msgType:z.CursorBlur,dataType:V.Local,isRunSubWork:!1,viewId:t};this.queryTaskBatchData({msgType:z.CursorHover,dataType:V.Local,viewId:t}).forEach(i=>{this.taskBatchData.delete(i)}),this.taskBatchData.add(e),this.consume()}sendCursorEvent(t,e){var r,c;if(!this.currentLocalWorkData||this.currentLocalWorkData.workState===D.Unwritable||!this.currentToolsData||!this.isCanSentCursor)return;const s=(r=this.collector)==null?void 0:r.uid,i=this.viewContainerManager.getCurScenePath(e);switch((c=this.currentToolsData)==null?void 0:c.toolsType){case C.Eraser:case C.PencilEraser:case C.BitMapEraser:{if(s&&!this.control.renderControl.isClearAble({uid:s,viewId:e,filterLocalSelf:!1,scenePath:i}))return;break}default:if(s&&!this.control.renderControl.isWriteable()||s&&!this.control.renderControl.isRenderAble({uid:s,viewId:e,filterLocalSelf:!1,scenePath:i}))return;break}let n=[void 0,void 0];this.currentToolsData&&this.isCanSentCursor&&!this.localPointsBatchData.size&&!this.getLockSentEventCursor()&&(n=t,this.control.cursor.sendEvent(n,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(r=>{var c;((c=this.collector)==null?void 0:c.getLocalId(r))===H&&delete n[r]}),Object.keys(n).length&&this.viewContainerManager.mainView&&this.viewContainerManager.mainView.cameraOpt){const r={msgType:z.BoundingBox,dataType:V.Local,scenePath:t,scenes:n,cameraOpt:{...this.viewContainerManager.mainView.cameraOpt},isRunSubWork:!0,viewId:this.viewContainerManager.mainView.id};return this.taskBatchData.add(r),this.runAnimation(),new Promise(c=>{this.boundingRectMap.set(t,c)}).then(c=>(this.boundingRectMap.delete(t),c))}}}getSnapshot(t,e,s,i){var r,c,l,h,u;if(!((r=this.snapshotMap)==null?void 0:r.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 m;((m=this.collector)==null?void 0:m.getLocalId(f))===H&&delete p[f]}),Object.keys(p).length){const f=this.viewContainerManager.mainView;if(!f)return;const m=e||((h=f.cameraOpt)==null?void 0:h.width),y=s||((u=f.cameraOpt)==null?void 0:u.height),N={msgType:z.Snapshot,dataType:V.Local,scenePath:t,scenes:p,w:m,h:y,cameraOpt:i&&{...i,width:m,height:y}||f.cameraOpt,isRunSubWork:!0,viewId:f.id};return this.taskBatchData.add(N),this.runAnimation(),new Promise(w=>{this.snapshotMap.set(t,w)}).then(w=>(this.snapshotMap.delete(t),w))}}}queryTaskBatchData(t){const e=[];if(t)for(const s of this.taskBatchData.values()){let i=!0;for(const[n,r]of Object.entries(t))if(s[n]!==r){i=!1;break}i&&e.push(s)}return e}insertImage(t,e){const s=this.viewContainerManager.getView(t);if(!s)throw new Error("insertImage viewId is not exist");if(e.src&&!/^(http|https):\/\//.test(e.src))throw new Error("Image src must be http or https");const i=s==null?void 0:s.focusScenePath;if(t&&i){const{src:n,uuid:r}=e;if(r&&!n){this.tmpImageConfigMap.set(r,e);return}const c=Date.now();Tt.InternalMsgEmitter.emit("addUndoTicker",c,t);const l={...e};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(t),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(t)),this.taskBatchData.add({msgType:z.FullWork,dataType:V.Local,toolsType:C.Image,workId:e.uuid,opt:l,viewId:t,willRefresh:!0,willSyncService:!0}),this.runAnimation()}}lockImage(t,e,s){var r,c;const i=this.viewContainerManager.getView(t);if(!i)throw new Error("insertImage viewId is not exist");const n=i==null?void 0:i.focusScenePath;if(t&&n&&this.collector){const l=this.collector.getStorageData(t,n);if(!l)return;for(const[h,u]of Object.entries(l))if(u&&u.toolsType===C.Image&&u.opt.uuid===e){const d=Date.now();Tt.InternalMsgEmitter.emit("addUndoTicker",d,t);const p=(r=this.collector)!=null&&r.isOwn(h)?(c=this.collector)==null?void 0:c.getLocalId(h):h,f={...u.opt,locked:s};this.taskBatchData.add({msgType:z.FullWork,dataType:V.Local,toolsType:C.Image,workId:p,opt:f,viewId:t,willRefresh:!0,willSyncService:!0}),this.runAnimation();return}}}completeImageUpload(t,e,s){const i=this.viewContainerManager.getView(t);if(!i)throw new Error("insertImage viewId is not exist");const n=i==null?void 0:i.focusScenePath;if(t&&n){const r=this.tmpImageConfigMap.get(e);r&&(r.src=s,this.insertImage(t,r),this.tmpImageConfigMap.delete(e));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:V.Local,viewId:e,willSyncService:!0}),this.runAnimation()}blurSelector(t,e,s){this.taskBatchData.add({workId:s||H,selectIds:[],msgType:z.Select,dataType:V.Service,viewId:t,scenePath:e}),this.runAnimation()}consoleWorkerInfo(){this.taskBatchData.add({msgType:z.Console,dataType:V.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:Ve,dataType:V.Local,isRunSubWork:!0})),t==="ui"){e.add({msgType:z.PriorityMainThreadWorker,viewId:Ve,dataType:V.Local,isRunSubWork:!0});const r=this.viewContainerManager.mainView;if(r){const l=this.viewContainerManager.getViewInitData(r.id);if(l){const{offscreenCanvasOpt:h,layerOpt:u,dpr:d,cameraOpt:p}=l;s.add({msgType:z.Init,dataType:V.Local,viewId:r.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:V.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:V.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 cg=Bt,lg=function(){return cg.Date.now()},hg=lg,ug=/\s/;function dg(a){for(var o=a.length;o--&&ug.test(a.charAt(o)););return o}var pg=dg,fg=pg,gg=/^\s+/;function Mg(a){return a&&a.slice(0,fg(a)+1).replace(gg,"")}var yg=Mg,mg=re,wg=Zt,Ig="[object Symbol]";function vg(a){return typeof a=="symbol"||wg(a)&&mg(a)==Ig}var Ng=vg,Tg=yg,xs=_t,Sg=Ng,zs=NaN,Cg=/^[-+]0x[0-9a-f]+$/i,kg=/^0b[01]+$/i,xg=/^0o[0-7]+$/i,zg=parseInt;function bg(a){if(typeof a=="number")return a;if(Sg(a))return zs;if(xs(a)){var o=typeof a.valueOf=="function"?a.valueOf():a;a=xs(o)?o+"":o}if(typeof a!="string")return a===0?a:+a;a=Tg(a);var t=kg.test(a);return t||xg.test(a)?zg(a.slice(2),t?2:8):Cg.test(a)?zs:+a}var Pg=bg,Lg=_t,yo=hg,bs=Pg,Dg="Expected a function",jg=Math.max,Ag=Math.min;function Eg(a,o,t){var e,s,i,n,r,c,l=0,h=!1,u=!1,d=!0;if(typeof a!="function")throw new TypeError(Dg);o=bs(o)||0,Lg(t)&&(h=!!t.leading,u="maxWait"in t,i=u?jg(bs(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=a.apply(b,x),n}function f(T){return l=T,r=setTimeout(N,o),h?p(T):n}function m(T){var x=T-c,b=T-l,A=o-x;return u?Ag(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 N(){var T=yo();if(y(T))return w(T);r=setTimeout(N,m(T))}function w(T){return r=void 0,d&&e?p(T):(e=s=void 0,n)}function I(){r!==void 0&&clearTimeout(r),l=0,e=c=s=r=void 0}function S(){return r===void 0?n:w(yo())}function v(){var T=yo(),x=y(T);if(e=arguments,s=this,c=T,x){if(r===void 0)return f(c);if(u)return clearTimeout(r),r=setTimeout(N,o),p(c)}return r===void 0&&(r=setTimeout(N,o)),n}return v.cancel=I,v.flush=S,v}var Og=Eg,Rg=Og,Yg=_t,Wg="Expected a function";function Ug(a,o,t){var e=!0,s=!0;if(typeof a!="function")throw new TypeError(Wg);return Yg(t)&&(e="leading"in t?!!t.leading:e,s="trailing"in t?!!t.trailing:s),Rg(a,o,{leading:e,maxWait:o,trailing:s})}var Bg=Ug;const Ee=Ie(Bg);class Fg{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))&&K.emitMethod(q.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:st.pencil,useNewPencil:!0});break;case"changeToArrow":this.setMemberState({currentApplianceName:st.arrow});break;case"changeToClick":this.setMemberState({currentApplianceName:st.clicker});break;case"changeToEllipse":this.setMemberState({currentApplianceName:st.ellipse});break;case"changeToEraser":this.setMemberState({currentApplianceName:st.eraser,isLine:!0});break;case"changeToHand":this.setMemberState({currentApplianceName:st.hand});break;case"changeToLaserPointer":this.setMemberState({currentApplianceName:st.laserPointer});break;case"changeToSelector":this.setMemberState({currentApplianceName:st.selector});break;case"changeToRectangle":this.setMemberState({currentApplianceName:st.rectangle});break;case"changeToStraight":this.setMemberState({currentApplianceName:st.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:st.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 r=n[i],c=r&&s.copySelector({viewId:o,store:r});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 r=L.cloneDeep(this.tmpCopyCoordInfo.offset),c=this.tmpCopyCoordInfo.cameraOpt,l=e.viewData.camera;r.x=r.x+l.centerX-c.centerX,r.y=r.y+l.centerY-c.centerY;const h=Date.now();this.control.worker.internalMsgEmitter.emit("addUndoTicker",h,o),s.pasteSelector({viewId:o,scenePath:t,copyStores:L.cloneDeep(this.tmpCopyStore),copyCoordInfo:{offset:r,cameraOpt:l},undoTickerId:h})}}setMemberState(o){var t;(t=this.control.room)==null||t.setMemberState(o)}}class Vg{constructor(o){M(this,"control");M(this,"roomMemberManager");M(this,"worker");M(this,"renderUids",new Map);M(this,"pageAuth",new Map);M(this,"isLocalRender",!1);M(this,"isCurWritable",!1);var e;const{control:t}=o;this.control=t,this.roomMemberManager=t.roomMember,this.worker=t.worker,this.isCurWritable=((e=this.control.room)==null?void 0:e.isWritable)||!1}onWritableChange(o){this.isCurWritable=o}addPage(o,t=!0){var l,h;const{viewId:e,render:s="localSelf",elementIds:i,pageId:n=(l=this.control.collector)==null?void 0:l.uid}=o,r=this.pageAuth.get(e)||new Map,c=this.control.viewContainerManager.getCurScenePath(e);if(c&&n){const u=r.get(c)||{render:"localSelf",pages:new Map};t&&(u.render=s);const d=i&&this.cloneElementIds(e,c,i,n)||new Set;u.pages.set(n,d),r.set(c,u),this.pageAuth.set(e,r),t&&this.pageAuthEffect(e),this.isLocalRender=!1,(h=this.control.collector)==null||h.dispatchPageAuth({operation:kt.addPage,viewId:e,scenePath:c,pageId:n,pageData:{render:s,elementIds:d}},!0)}}delPage(o,t){var n,r;const e=this.pageAuth.get(t);if(!e)return;const s=[...e.keys()].find(c=>{const l=e.get(c);return!!(l&&l.pages.has(o))});if(!s)return;const i=e.get(s);if(i){const{render:c,pages:l}=i,h=c==="localSelf"?(n=this.control.collector)==null?void 0:n.uid:c,u=l.get(o);u!=null&&u.size&&this.delElementIds(t,s,u),l.delete(o),h===o&&this.pageAuthEffect(t)}(r=this.control.collector)==null||r.dispatchPageAuth({operation:kt.deletePage,viewId:t,scenePath:s,pageId:o},!0)}delViewPage(o,t=!0){var s;this.pageAuth.get(o)&&(this.pageAuth.delete(o),t&&((s=this.control.collector)==null||s.dispatchPageAuth({operation:kt.clearView,viewId:o},t)))}clearRenderPage(o,t,e=!0){var r,c;const s=this.pageAuth.get(o);if(!s)return;const i=s.get(t);let n;if(i){const{render:l,pages:h}=i,u=l==="localSelf"?(r=this.control.collector)==null?void 0:r.uid:l;if(u){if(e){const d=h.get(u);d&&this.delElementIds(o,t,d)}h.set(u,new Set),n=u}}e&&n&&((c=this.control.collector)==null||c.dispatchPageAuth({operation:kt.clearPage,viewId:o,scenePath:t,pageId:n},e))}hasPage(o,t,e){const s=this.pageAuth.get(t);if(!s)return!1;const i=s.get(e);return i?i.pages.has(o):!1}getPageInfo(o,t,e){const s=this.pageAuth.get(t);if(!s)return;const i=s.get(e);if(i)return i.pages.get(o)}addRenderPageElementId(o,t=!0,e=!1){var h,u;const{viewId:s,elementId:i,scenePath:n}=o,r=this.pageAuth.get(s);if(!r)throw new Error(`no view info in viewId: ${s}`);const c=r.get(n);let l;if(c){const{render:d,pages:p}=c,f=d==="localSelf"?(h=this.control.collector)==null?void 0:h.uid:d;if(f&&p.has(f)){const m=p.get(f)||new Set;m.add(i),p.set(f,m),l=f}}e&&this.pageAuthEffect(s),t&&l&&((u=this.control.collector)==null||u.dispatchPageAuth({operation:kt.addElement,viewId:s,scenePath:n,pageId:l,pageData:{elementId:i}},t))}delRenderPageElementId(o,t=!0,e=!1){var h,u;const{viewId:s,elementId:i,scenePath:n}=o,r=this.pageAuth.get(s);if(!r)throw new Error(`no view info in viewId: ${s}`);const c=r.get(n);let l;if(c){const{render:d,pages:p}=c,f=d==="localSelf"?(h=this.control.collector)==null?void 0:h.uid:d;if(f&&p.has(f)){const m=p.get(f);m&&(m.delete(i),p.set(f,m),l=f)}}e&&this.pageAuthEffect(s),t&&l&&((u=this.control.collector)==null||u.dispatchPageAuth({operation:kt.deleteElement,viewId:s,scenePath:n,pageId:l,pageData:{elementId:i}},t))}setPageRender(o,t,e,s=!0){var r;const i=this.pageAuth.get(o);if(!i)throw new Error(`no view info in viewId: ${o}`);const n=i.get(t);n&&(n.render=e),t===this.control.viewContainerManager.getCurScenePath(o)&&this.pageAuthEffect(o),s||(this.isLocalRender=!0),s&&(this.isLocalRender=!1,(r=this.control.collector)==null||r.dispatchPageAuth({operation:kt.renderPage,viewId:o,scenePath:t,pageData:{render:e}},s))}isWriteable(){return this.isCurWritable}isRenderAble(o){var c,l;const{uid:t,viewId:e,filterLocalSelf:s=!0,scenePath:i}=o,n=this.renderUids.get(e);if(n){const{render:h,hide:u}=n;if(h===void 0&&u===void 0)return!0;if(L.isSet(h)){if(h.has(t)||s&&((c=this.control.collector)==null?void 0:c.uid)===t&&h.has("localSelf"))return!0}else if(h===!0&&(!u||L.isSet(u)&&!u.has(t)&&!(s&&u.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===t)))return!0;return!1}const r=this.pageAuth.get(e);if(r&&i){const h=r.get(i);if(h){const{render:u}=h;if(u)return!(u==="localSelf"&&!s)}}return!0}isClearAble(o){var c;const{uid:t,viewId:e,filterLocalSelf:s=!0,scenePath:i}=o,n=this.renderUids.get(e);if(n){const{clear:l}=n;return!!(l===void 0||l===!0||L.isSet(l)&&(l.has(t)||s&&((c=this.control.collector)==null?void 0:c.uid)===t&&l.has("localSelf")))}const r=this.pageAuth.get(e);if(r&&i){const l=r.get(i);if(l){const{render:h}=l;if(h)return!(h==="localSelf"&&!s)}}return!0}isFilterAble(o,t){var c,l,h,u;const{viewId:e,scenePath:s,elementId:i}=o,n=this.renderUids.get(e);if(n&&i){const{render:d,hide:p}=n;if(d===void 0&&p===void 0)return!0;const f=(c=this.control.collector)==null?void 0:c.getUidFromKey(i);return f?!!(L.isSet(d)&&(d.has(f)||d.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===f)||d===!0&&(!p||L.isSet(p)&&!p.has(f)&&!(p.has("localSelf")&&((h=this.control.collector)==null?void 0:h.uid)===f))):!1}const r=this.pageAuth.get(e);if(r&&s&&i){const d=r.get(s);if(d){const{render:p,pages:f}=d;if(!p)return!0;const m=(u=this.control.collector)==null?void 0:u.uid,y=p==="localSelf"?m:p,N=y&&f.get(y)||void 0;if(N)switch(t){case z.RemoveNode:return!0;default:return N.has(i)}return!1}}return!0}isFilterCursor(o){if(this.isUsePageAuth(o)){const t=this.control.viewContainerManager.getCurScenePath(o),e=this.pageAuth.get(o);if(t&&e){const s=e.get(t);if(s){const{render:i}=s;return i!=="localSelf"}}}return!0}isUsePageAuth(o){var s;if(!this.pageAuth.has(o))return!1;const e=this.control.viewContainerManager.getCurScenePath(o);return e&&((s=this.pageAuth.get(o))==null?void 0:s.has(e))||!1}publishRender(o){var n;const{viewId:t,option:e,isSync:s=!0}=o,i={};if(e){const{render:r,hide:c,clear:l}=e;r&&(i.render=r===!0&&!0||new Set(r)),c&&(i.hide=c===!0&&!0||new Set(c)),l&&(i.clear=l===!0&&!0||new Set(l)),this.renderUids.set(t,i)}else this.renderUids.delete(t);s&&((n=this.control.collector)==null||n.dispatchRenderAuth({operation:Wt.setAuth,viewId:t,renderData:i},s)),this.renderEffect(t)}publishOneRender(o,t,e,s=!0){var r;const i=this.renderUids.get(o);let n;switch(e){case"show":i?(i.render||(i.render=new Set),L.isSet(i.render)&&i.render.add(t),L.isSet(i.hide)&&i.hide.delete(t)):this.renderUids.set(o,{render:new Set([t])}),n=Wt.setShow;break;case"hide":i?(i.hide||(i.hide=new Set),L.isSet(i.hide)&&i.hide.add(t),L.isSet(i.render)&&i.render.delete(t)):this.renderUids.set(o,{hide:new Set([t])}),n=Wt.setHide;break}i?this.renderUids.set(o,i):this.renderUids.delete(o),s&&n&&((r=this.control.collector)==null||r.dispatchRenderAuth({operation:n,viewId:o,uid:t},s)),this.renderEffect(o)}publishOneClear(o,t,e,s=!0){var n;const i=this.renderUids.get(o);e?i?(i.clear||(i.clear=new Set),L.isSet(i.clear)&&i.clear.add(t)):this.renderUids.set(o,{clear:new Set([t])}):i&&L.isSet(i.clear)&&i.clear.has(t)&&i.clear.delete(t),i?this.renderUids.set(o,i):this.renderUids.delete(o),s&&((n=this.control.collector)==null||n.dispatchRenderAuth({operation:Wt.setClear,viewId:o,uid:t,isClear:e},s)),this.renderEffect(o)}syncRenderUids(o,t,e,s){const i=t===!0?!0:t&&Object.keys(t)?new Set(Object.keys(t)):void 0,n=e===!0?!0:e&&Object.keys(e)?new Set(Object.keys(e)):void 0,r=s===!0?!0:s&&Object.keys(s)?new Set(Object.keys(s)):void 0;i||n||r?this.renderUids.set(o,{render:i,hide:n,clear:r}):this.renderUids.delete(o),this.renderEffect(o)}syncPageAuth(o,t,e=!1){let s=!1;if(!t)this.pageAuth.delete(o);else{const i=this.pageAuth.get(o)||new Map;for(const[n,r]of Object.entries(t)){const{render:c,pages:l}=r,h=i.get(n),u=this.isLocalRender?h==null?void 0:h.render:c;if(u){u!==(h==null?void 0:h.render)&&(s=!0);const d=new Map;for(const[f,m]of Object.entries(l))d.set(f,new Set(Object.keys(m)));const p={render:u,pages:d};d.size&&i.set(n,p)}}i.size&&this.pageAuth.set(o,i)}(e||s)&&this.pageAuthEffect(o)}destoryByViewId(o,t=!1){var e;this.renderUids.has(o)&&(this.renderUids.delete(o),t||(e=this.control.collector)==null||e.dispatchRenderAuth({operation:Wt.setAuth,viewId:o})),this.pageAuth.has(o)&&this.control.renderControl.delViewPage(o,!t)}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)})}pageAuthEffect(o){var e;const t=(e=this.control.viewContainerManager.getView(o))==null?void 0:e.focusScenePath;t&&this.worker.clearViewScenePath(o,!0).then(()=>{this.worker.pullServiceData(o,t,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(o,!0)})}cloneElementIds(o,t,e,s){var r,c;const i=(r=this.control.collector)==null?void 0:r.getStorageData(o,t),n=new Set;if(i){for(const l of Object.keys(i))if(e.has(l)){const h=`${l}_${s}`;if(n.add(h),!Object.keys(i).includes(h)){const u=L.cloneDeep(i[l]);(c=this.control.collector)==null||c.updateValue(h,{type:z.FullWork,...u,workId:h},{isSync:!0,viewId:o,scenePath:t})}}}return n}delElementIds(o,t,e){var i,n;const s=(i=this.control.collector)==null?void 0:i.getStorageData(o,t);if(s)for(const r of Object.keys(s))e.has(r)&&Object.keys(s).includes(r)&&((n=this.control.collector)==null||n.updateValue(r,void 0,{isSync:!0,viewId:o,scenePath:t}))}}const De=class De{constructor(o){M(this,"version",ci);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(nt.toJS(o))});M(this,"onMemberChange",Ee(o=>{if(!this.room||!this.worker||!o||!this.room.isWritable)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=nt.isRoom(t)?t:void 0,this.play=nt.isPlayer(t)?t:void 0,this.pluginOptions=s,this.roomMember=new Wf;const i={control:this,internalMsgEmitter:De.InternalMsgEmitter};this.cursor=new Vf(i),this.textEditorManager=new Ff(i),this.worker=new ag(i),this.hotkeyManager=new Fg(i),this.renderControl=new Vg(i)}setPriority(o){var t;this.priority=o,this.hasOffscreenCanvas()&&((t=this.worker)==null||t.setPriority(o))}hasOffscreenCanvas(){return li==="worker"}bindPlugin(o){var t,e;this.plugin=o,this.collector&&(this.collector.removeStorageStateListener(),this.collector.removeAuthStateListener()),this.collector=new Co(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&&(De.InternalMsgEmitter.emit("addUndoTicker",o,t),this.worker.clearViewScenePath(t,!1,!0))}onWritableChange(o){var t,e;o?(e=this.worker)==null||e.abled():(t=this.worker)==null||t.unWritable(),this.renderControl.onWritableChange(o)}getToolsKey(o){var e;const t=o.currentApplianceName;switch(this.hasSwitchToSelectorEffect=!1,t){case st.text:return o.textCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Text;case st.pencil:return o.useLaserPen?C.LaserPen:C.Pencil;case st.eraser:return C.Eraser;case st.pencilEraser:return((e=this.pluginOptions.pencilEraser)==null?void 0:e.useBitMap)===!1?C.PencilEraser:C.BitMapEraser;case st.selector:return C.Selector;case st.arrow:return o.arrowCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Arrow;case st.straight:return o.straightCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Straight;case st.ellipse:return o.ellipseCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Ellipse;case st.rectangle:return o.rectangleCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Rectangle;case st.shape:if(o.shapeCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),o.shapeType===Ot.Pentagram||o.shapeType===Ot.Star)return C.Star;if(o.shapeType===Ot.Polygon||o.shapeType===Ot.Triangle||o.shapeType===Ot.Rhombus)return C.Polygon;if(o.shapeType===Ot.SpeechBalloon)return C.SpeechBalloon;break}return C.Clicker}getToolsOpt(o,t){if(o===C.Clicker)return{toolsType:o,toolsOpt:{}};const e={strokeColor:We(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)&&We(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)&&We(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)||_.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)===_.Stroke?e.strokeType=_.Normal:e.strokeType=(t==null?void 0:t.strokeType)||_.Normal;break;case C.Arrow:case C.Straight:t!=null&&t.strokeType&&(t==null?void 0:t.strokeType)===_.Stroke?e.strokeType=_.Normal:e.strokeType=(t==null?void 0:t.strokeType)||_.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)===_.Stroke?e.strokeType=_.Normal:e.strokeType=(t==null?void 0:t.strokeType)||_.Normal,o===C.Star&&(t.shapeType===Ot.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===Ot.Triangle?e.vertices=3:t.shapeType===Ot.Rhombus?e.vertices=4:t.vertices&&(e.vertices=t.vertices)),e.fillColor=(t==null?void 0:t.fillColor)&&We(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,r;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=((r=(n=this.viewContainerManager.mainView)==null?void 0:n.viewData)==null?void 0:r.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,r){const c=await this.worker.getSnapshot(t,e,s,i);c&&(o.drawImage(c,n||0,r||0),c.close())}async scenePreview(o,t){var n,r,c,l;const e=(n=this.collector)==null?void 0:n.getViewIdBySecenPath(o);if(!e)return;const s=this.viewContainerManager.getView(e);if(!s||!((r=s.cameraOpt)!=null&&r.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:st.text})}switchToSelector(){var o;(o=this.room)==null||o.setMemberState({currentApplianceName:st.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()}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(De,"InternalMsgEmitter",new js);let Tt=De;const se=class se{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",L.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)}},se.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(L.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])||{},r=this.diffFun(this.tickStartStorerCache,new Map(Object.entries(n)));r.size&&(this.undoStack.push({id:o,type:2,data:L.cloneDeep(r),scenePath:e}),this.undoStack.length>se.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 r=o.get(n),c=t.get(n);if(r&&c){if(L.isEqual(c,r))continue;e.add({dataType:3,key:n,data:[r,c]});continue}r&&e.add({dataType:2,key:n,data:r})}for(const n of i){if(this.excludeIds.has(n))continue;const r=t.get(n);r&&!o.has(n)&&e.add({dataType:1,key:n,data:r})}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(r=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(r))===H&&!((l=this.collector)!=null&&l.isOwn(r))}).map(r=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][e][r]});for(const r of i)if((n=r==null?void 0:r.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(r=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(r))===H&&!((l=this.collector)!=null&&l.isOwn(r))}).map(r=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][e][r]});for(const r of i)if((n=r==null?void 0:r.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,r,c,l,h,u,d,p,f,m,y,N,w,I,S,v,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:P,key:Y}=j,et=this.collector.getStorageData(this.viewId,s),tt=et&&Object.keys(et)||[];switch(E){case 1:if(e=t?this.isDrawEffectiveScene(j,tt):this.isDeleteEffectiveScene(j,tt,s),e)if(t&&!Array.isArray(P)){if((n=P.updateNodeOpt)!=null&&n.useAnimation&&(P.updateNodeOpt.useAnimation=!1),((r=this.collector)==null?void 0:r.getLocalId(Y))===H&&((c=this.collector)!=null&&c.isOwn(j.key))){const $=P.selectIds;if($){const J=tt.filter(Z=>{var X,rt;return((X=this.collector)==null?void 0:X.getLocalId(Z))===H&&!((rt=this.collector)!=null&&rt.isOwn(Z))}).map(Z=>{var X;return(X=this.collector)==null?void 0:X.storage[this.viewId][s][Z]});let G=!1;for(const Z of J)for(let X=0;X<$.length;X++)(l=Z==null?void 0:Z.selectIds)!=null&&l.includes($[X])&&(delete $[X],G=!0);G&&(P.selectIds=$.filter(Z=>!!Z))}}(h=this.collector)==null||h.updateValue(j.key,P,{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(P))(d=this.collector)==null||d.updateValue(Y,void 0,{isAfterUpdate:!0,viewId:this.viewId,scenePath:s,isSync:!0});else if(!t&&!Array.isArray(P)){if((p=P.updateNodeOpt)!=null&&p.useAnimation&&(P.updateNodeOpt.useAnimation=!1),((f=this.collector)==null?void 0:f.getLocalId(j.key))===H&&((m=this.collector)!=null&&m.isOwn(j.key))){const $=P.selectIds;if($){const J=tt.filter(Z=>{var X,rt;return((X=this.collector)==null?void 0:X.getLocalId(Z))===H&&!((rt=this.collector)!=null&&rt.isOwn(Z))}).map(Z=>{var X;return(X=this.collector)==null?void 0:X.storage[this.viewId][s][Z]});let G=!1;for(const Z of J)for(let X=0;X<$.length;X++)(y=Z==null?void 0:Z.selectIds)!=null&&y.includes($[X])&&(delete $[X],G=!0);G&&(P.selectIds=$.filter(Z=>!!Z))}}(N=this.collector)==null||N.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(P)&&P.length===2){const $=P[1];if((w=$.updateNodeOpt)!=null&&w.useAnimation&&($.updateNodeOpt.useAnimation=!1),((I=this.collector)==null?void 0:I.getLocalId(j.key))===H&&((S=this.collector)!=null&&S.isOwn(j.key))){const J=$.selectIds;if(J){const G=tt.filter(X=>{var rt,wt;return((rt=this.collector)==null?void 0:rt.getLocalId(X))===H&&!((wt=this.collector)!=null&&wt.isOwn(X))}).map(X=>{var rt;return(rt=this.collector)==null?void 0:rt.storage[this.viewId][s][X]});let Z=!1;for(const X of G)for(let rt=0;rt<J.length;rt++)X!=null&&X.selectIds&&((v=X.selectIds)!=null&&v.includes(J[rt]))&&(delete J[rt],Z=!0);Z&&($.selectIds=J.filter(X=>!!X))}}(T=this.collector)==null||T.updateValue(Y,$,{isAfterUpdate:!0,viewId:this.viewId,scenePath:s,isSync:!0})}else if(!t&&Array.isArray(P)&&P.length===2){const $=P[0];if((x=$.updateNodeOpt)!=null&&x.useAnimation&&($.updateNodeOpt.useAnimation=!1),((b=this.collector)==null?void 0:b.getLocalId(j.key))===H&&((A=this.collector)!=null&&A.isOwn(j.key))){const J=$.selectIds;if(J){const G=tt.filter(X=>{var rt,wt;return((rt=this.collector)==null?void 0:rt.getLocalId(X))===H&&!((wt=this.collector)!=null&&wt.isOwn(X))}).map(X=>{var rt;return(rt=this.collector)==null?void 0:rt.storage[this.viewId][s][X]});let Z=!1;for(const X of G)for(let rt=0;rt<J.length;rt++)X!=null&&X.selectIds&&X.selectIds.includes(J[rt])&&(delete J[rt],Z=!0);Z&&($.selectIds=J.filter(X=>!!X))}}(O=this.collector)==null||O.updateValue(j.key,$,{isAfterUpdate:!0,viewId:this.viewId,scenePath:s,isSync:!0})}}break}}}};M(se,"sdkCallBack"),M(se,"MaxStackLength",20),M(se,"waitTime",100);let to=se;function Hg(a){return a instanceof TouchEvent||a instanceof window.TouchEvent||(a==null?void 0:a.touches)&&(a==null?void 0:a.touches.length)||(a==null?void 0:a.changedTouches)&&(a==null?void 0:a.changedTouches.length)}function ye(a){return Hg(a)&&(a.touches&&a.touches.length===1||a.changedTouches&&a.changedTouches.length===1)}function zi(a){return a.touches&&a.touches.length?{x:a.touches[0].pageX,y:a.touches[0].pageY}:a.changedTouches&&a.changedTouches.length?{x:a.changedTouches[0].pageX,y:a.changedTouches[0].pageY}:{x:a.pageX,y:a.pageY}}class me{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=L.clone(o[t]),i=L.clone(e);t==="focusScenePath"&&e&&!L.isEqual(s,i)&&(this.control.internalSceneChange(o.id,i),(n=this.focuedView)==null||n.displayer.commiter.onChangeScene()),t==="cameraOpt"&&!L.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!==vt&&this.appViews.has(o)}getView(o){var t;return o===vt?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===vt&&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===vt&&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===vt?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===vt?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;L.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,r,c,l,h,u,d,p,f,m,y,N,w;for(const I of o){const{rect:S,imageBitmap:v,isClear:T,isUnClose:x,drawCanvas:b,clearCanvas:A,viewId:O}=I,j=(t=this.getView(O))==null?void 0:t.displayer;if(j&&S){const{dpr:E,canvasBgRef:P,canvasFloatRef:Y,canvasServiceFloatRef:et,canvasTopRef:tt}=j,$=Math.floor(S.w*E),J=Math.floor(S.h*E),G=S.x*E,Z=S.y*E;if(T){switch(A){case Vt.TopFloat:(s=(e=tt.current)==null?void 0:e.getContext("2d"))==null||s.clearRect(G,Z,$,J);break;case Vt.Float:(n=(i=Y.current)==null?void 0:i.getContext("2d"))==null||n.clearRect(G,Z,$,J);break;case Vt.ServiceFloat:(c=(r=et.current)==null?void 0:r.getContext("2d"))==null||c.clearRect(G,Z,$,J);break;case Vt.Bg:(h=(l=P.current)==null?void 0:l.getContext("2d"))==null||h.clearRect(G,Z,$,J);break}continue}if(b&&v)switch(b){case Vt.TopFloat:(d=(u=tt.current)==null?void 0:u.getContext("2d"))==null||d.drawImage(v,0,0,$,J,G,Z,$,J);break;case Vt.Float:{(f=(p=Y.current)==null?void 0:p.getContext("2d"))==null||f.drawImage(v,0,0,$,J,G,Z,$,J);break}case Vt.ServiceFloat:{(y=(m=et.current)==null?void 0:m.getContext("2d"))==null||y.drawImage(v,0,0,$,J,G,Z,$,J);break}case Vt.Bg:{(w=(N=P.current)==null?void 0:N.getContext("2d"))==null||w.drawImage(v,0,0,$,J,G,Z,$,J);break}}if(x)continue;v==null||v.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(me,"defaultCameraOpt",{centerX:0,centerY:0,scale:1}),M(me,"defaultScreenCanvasOpt",{autoRender:!1,contextType:"webgl2"}),M(me,"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(D.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(D.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(D.Done,t,this.viewId),this.cachePoint=void 0}});M(this,"touchstart",o=>{var t;if(this.active){if(!ye(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(D.Start,e,this.viewId)}}});M(this,"touchmove",o=>{if(this.active){if(!ye(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(D.Doing,t,this.viewId)}}});M(this,"touchend",o=>{if(this.active){if(!ye(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(D.Done,t,this.viewId),this.cachePoint=void 0}}});M(this,"cursorMouseMove",L.throttle(o=>{const t=this.getPoint(o);this.cacheCursorPoint&&L.isEqual(t,this.cacheCursorPoint)||!this.viewId||(this.cacheCursorPoint=t,t&&this.control.worker.sendCursorEvent(t,this.viewId))},30,{leading:!1}));M(this,"cursorMouseLeave",L.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 to(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([q.Cursor,this.viewId])}getPoint(o){const t=zi(o);if(t&&L.isNumber(t.x)&&L.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(D.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 bi{constructor(o,t){M(this,"viewId",vt);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(D.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(D.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(D.Done,t,this.viewId),this.cachePoint=void 0}});M(this,"touchstart",o=>{var e;if(!this.active)return;if(!ye(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(D.Start,t,this.viewId)});M(this,"touchmove",o=>{if(!this.active)return;if(!ye(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(D.Doing,t,this.viewId)});M(this,"touchend",o=>{if(!this.active)return;if(!ye(o)||!this.control.worker.isAbled()){this.control.worker.removeDrawingWork(this.viewId);return}const t=this.getPoint(o)||this.cachePoint;t&&this.control.worker.originalEventLintener(D.Done,t,this.viewId),this.cachePoint=void 0});M(this,"cursorMouseMove",L.throttle(o=>{const t=this.getPoint(o);this.cacheCursorPoint&&L.isEqual(t,this.cacheCursorPoint)||(this.cacheCursorPoint=t,t&&this.control.worker.sendCursorEvent(t,this.viewId))},30,{leading:!1}));M(this,"cursorMouseLeave",L.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 to(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([q.Cursor,this.viewId])}getPoint(o){const t=zi(o);if(t&&L.isNumber(t.x)&&L.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(D.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 $g="index-module__Container__nLsM3",Gg="index-module__CanvasBox__j2Xe-",Zg="index-module__FloatCanvas__d1YR7",qg="index-module__TopFloatCanvas__7IaCw",Jg="index-module__CanvasBoxSub__hcMeK",Xg="index-module__SnapshotBox__--eeE",Kg="index-module__FloatBar__cm-EL",_g="index-module__RotateBtn__HSSkf",tM="index-module__ResizeBtn__yjvda",eM="index-module__CursorBox__2UHvI",oM="index-module__TextEditorContainer__Qm8KC",sM="index-module__ResizeTowBox__HOllX",iM="index-module__FloatBarBtn__FJrOG",xt={Container:$g,CanvasBox:Gg,FloatCanvas:Zg,TopFloatCanvas:qg,CanvasBoxSub:Jg,SnapshotBox:Xg,FloatBar:Kg,RotateBtn:_g,ResizeBtn:tM,CursorBox:eM,TextEditorContainer:oM,ResizeTowBox:sM,FloatBarBtn:iM},nM={delete:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDZ2NmEyIDIgMCAwIDEtMiAySDZhMiAyIDAgMCAxLTItMlY2aDBtMS0yYTIgMiAwIDAgMSAyLTJoMmEyIDIgMCAwIDEgMiAyaDBNMyA0aDEwIiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==",duplicate:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjxwYXRoIGQ9Ik0xMSAySDZhMSAxIDAgMCAwLTEgMXY4YTEgMSAwIDAgMCAxIDFoNmExIDEgMCAwIDAgMS0xVjRoMGwtMi0yeiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+PHBhdGggZD0iTTExIDJ2MWExIDEgMCAwIDAgMSAxaDFsLTItMnoiLz48cGF0aCBkPSJNOSAxNEg0YTEgMSAwIDAgMS0xLTFWNWgwIiBzdHJva2UtbGluZWNhcD0icm91bmQiLz48L2c+PC9zdmc+","layer-pressed":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8v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tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","underline-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDJ2NWE0IDQgMCAxIDEtOCAwVjJoME0zIDE0aDEwIiBzdHJva2U9IiMzMzgxRkYiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==",underline:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDJ2NWE0IDQgMCAxIDEtOCAwVjJoME0zIDE0aDEwIiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","line-through-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQgOGg4bS0xLTNhMyAzIDAgMCAwLTMtM2gtLjkzOEEyLjY0IDIuNjQgMCAwIDAgNC41IDRhMi41NyAyLjU3IDAgMCAwIDEuMzQ0IDIuOTIybDQuMzEyIDIuMTU2QTIuNTcgMi41NyAwIDAgMSAxMS41IDEyYTIuNjQgMi42NCAwIDAgMS0yLjU2MiAySDdhMyAzIDAgMCAxLTMtM2gwIiBzdHJva2U9IiMzMzgxRkYiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","line-through":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQgOGg4bS0xLTNhMyAzIDAgMCAwLTMtM2gtLjkzOEEyLjY0IDIuNjQgMCAwIDAgNC41IDRhMi41NyAyLjU3IDAgMCAwIDEuMzQ0IDIuOTIybDQuMzEyIDIuMTU2QTIuNTcgMi41NyAwIDAgMSAxMS41IDEyYTIuNjQgMi42NCAwIDAgMS0yLjU2MiAySDdhMyAzIDAgMCAxLTMtM2gwIiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","italic-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTcgMTQgOSAyTTUgMTRoNE03IDJoNCIgc3Ryb2tlPSIjMzM4MUZGIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=",italic:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTcgMTQgOSAyTTUgMTRoNE03IDJoNCIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","unlock-new":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhl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Y2NjdoNjR6IG0tNTQuNjEzMzMzLTIxMi4wNTMzMzRsODUuMzMzMzMzIDg1LjMzMzMzNCA0NS4yMjY2NjctNDUuMjI2NjY3LTg1LjMzMzMzMy04NS4zMzMzMzMtNDUuMjI2NjY3IDQ1LjIyNjY2NnogbTAtNDUuMjI2NjY2bC04NS4zMzMzMzMgODUuMzMzMzMzIDQ1LjIyNjY2NiA0NS4yMjY2NjcgODUuMzMzMzM0LTg1LjMzMzMzNC00NS4yMjY2NjctNDUuMjI2NjY2eiIgIGZpbGw9IiM0NDRFNjAiPjwvcGF0aD48L3N2Zz4="};function St(a){return nM[a]}const rM=a=>{const{workIds:o,mananger:t}=a;return g.createElement("div",{className:"button normal-button",style:{touchAction:"none"},onClick:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),K.emitMethod(q.MainEngine,R.DeleteNode,{workIds:o||[H],viewId:t.viewId})},onTouchEnd:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),K.emitMethod(q.MainEngine,R.DeleteNode,{workIds:o||[H],viewId:t.viewId})}},g.createElement("img",{alt:"icon",src:St("delete")}))},aM=a=>{const{workIds:o,viewId:t}=a;return g.createElement("div",{className:"button normal-button",onClick:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),K.emitMethod(q.MainEngine,R.CopyNode,{workIds:o||[H],viewId:t})},onTouchEnd:e=>{e.stopPropagation(),K.emitMethod(q.MainEngine,R.CopyNode,{workIds:o||[H],viewId:t})}},g.createElement("img",{alt:"icon",src:St("duplicate")}))},Ps=a=>{const{icon:o,onClickHandler:t,onTouchEndHandler:e}=a;return g.createElement("div",{className:"button normal-button",onClick:t,onTouchEnd:e},g.createElement("img",{src:St(o)}))},cM=a=>{const{open:o,setOpen:t,floatBarRef:e}=a,{floatBarData:s,mananger:i}=g.useContext(mt),[n,r]=g.useState([]),c=g.useMemo(()=>{if(e!=null&&e.current&&L.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(Ps,{icon:"to-top",onClickHandler:d=>{d.cancelable&&d.preventDefault(),d.stopPropagation(),K.emitMethod(q.MainEngine,R.ZIndexNode,{workIds:[H],layer:ie.Top,viewId:i==null?void 0:i.viewId})},onTouchEndHandler:d=>{d.stopPropagation(),K.emitMethod(q.MainEngine,R.ZIndexNode,{workIds:[H],layer:ie.Top,viewId:i==null?void 0:i.viewId})}}),g.createElement(Ps,{icon:"to-bottom",onClickHandler:d=>{d.cancelable&&d.preventDefault(),d.stopPropagation(),K.emitMethod(q.MainEngine,R.ZIndexNode,{workIds:[H],layer:ie.Bottom,viewId:i==null?void 0:i.viewId})},onTouchEndHandler:d=>{d.stopPropagation(),K.emitMethod(q.MainEngine,R.ZIndexNode,{workIds:[H],layer:ie.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(()=>{L.isEqual(s==null?void 0:s.selectIds,n)||s!=null&&s.selectIds&&!L.isEqual(s==null?void 0:s.selectIds,n)&&(r(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:St(o?"layer-pressed":"layer")}))},lM=()=>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"})),Pi=a=>{const{activeColor:o,onClickHandler:t,onTouchEndHandler:e}=a;return g.createElement("div",{className:`font-color-button ${o==="transparent"?"active":""}`,onClick:t,onTouchEnd:e},g.createElement("div",{className:"circle none"}))},uo=a=>{const{color:o,activeColor:t,onClickHandler:e,onTouchEndHandler:s}=a;return g.createElement("div",{className:`font-color-button ${o===t?"active":""}`,onClick:e,onTouchEnd:s},g.createElement("div",{className:"circle",style:{backgroundColor:Mt(o,1)}}))},po=a=>{const{opacity:o,activeColor:t,setCurOpacity:e}=a,[s,i]=g.useState({x:108,y:0});if(g.useEffect(()=>{i({x:o*100+8,y:0})},[]),!t)return null;const n=L.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,D.Doing)},100,{leading:!1}),r=l=>{l.cancelable&&l.preventDefault(),l.stopPropagation(),e(o,t,D.Start)},c=L.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,D.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,D.Done)}},g.createElement("div",{className:"range-color",style:{background:`linear-gradient(to right, ${Mt(t,0)}, ${Mt(t,1)})`}}),g.createElement("div",{className:"range-opacity"},g.createElement(we,{bounds:"parent",axis:"x",position:s,onDrag:n,onStart:r,onStop:c},g.createElement("div",{className:"circle",style:{backgroundColor:Mt(t,o)},onClick:l=>{l.cancelable&&l.preventDefault(),l.stopPropagation()}}))))},hM=a=>{const{min:o,max:t,activeNumber:e,setActiveNumber:s,color:i}=a,[n,r]=g.useState({x:108,y:0});if(g.useEffect(()=>{const u=Math.ceil((e-o)/(t-o)*100)+8;r({x:u,y:0})},[]),!e)return null;const c=L.throttle((u,d)=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),d.x!==(n==null?void 0:n.x)&&r({x:d.x,y:0});const p=Math.ceil(Math.max(d.x-8,0)/100*(t-o)+o);e!==p&&s(p,D.Doing)},100,{leading:!1}),l=u=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),s(e,D.Start)},h=L.throttle((u,d)=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),d.x!==(n==null?void 0:n.x)&&r({x:d.x,y:0});const p=Math.ceil(Math.max(d.x-8,0)/100*(t-o)+o);s(p,D.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;r({x:f,y:0}),s(p,D.Done)}},g.createElement("div",{className:"range-color",style:{backgroundColor:i}}),g.createElement("div",{className:"range-opacity"},g.createElement(we,{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)))))},uM=a=>{const{useStroke:o,color:t,activeStrokeType:e,setStrokeType:s}=a;return g.createElement("div",{className:"stroke-type-box"},!!o&&g.createElement("div",{className:`stroke-type-box-item Stroke ${e===_.Stroke&&"active"}`,style:{backgroundColor:t},onClick:()=>{s(_.Stroke)},onTouchEnd:()=>{s(_.Stroke)}}),g.createElement("div",{className:`stroke-type-box-item Normal ${e===_.Normal&&"active"}`,style:{borderColor:t},onClick:()=>{s(_.Normal)},onTouchEnd:()=>{s(_.Normal)}}),g.createElement("div",{className:`stroke-type-box-item Dotted ${e===_.Dotted&&"active"}`,style:{borderColor:t},onClick:()=>{s(_.Dotted)},onTouchEnd:()=>{s(_.Dotted)}}),g.createElement("div",{className:`stroke-type-box-item LongDotted ${e===_.LongDotted&&"active"}`,style:{borderColor:t},onClick:()=>{s(_.LongDotted)},onTouchEnd:()=>{s(_.LongDotted)}}))},dM=a=>{const{open:o,setOpen:t,floatBarRef:e}=a,{floatBarData:s,floatBarColors:i,mananger:n,setFloatBarData:r}=g.useContext(mt),[c,l]=g.useState(),[h,u]=g.useState(1);g.useEffect(()=>{if(s!=null&&s.strokeColor){const[w,I]=ho(s.strokeColor);l(w),u(I)}},[s]);const d=g.useMemo(()=>{if(e!=null&&e.current&&L.isNumber(s==null?void 0:s.y)&&(n!=null&&n.height)){if(e.current.offsetTop&&e.current.offsetTop+s.y>180){const w={};return w.top="inherit",w.bottom=50,w}else if(!e.current.offsetTop&&(n==null?void 0:n.height)-e.current.offsetTop-s.y<120){const w={};return w.top="inherit",w.bottom=50,w}}},[(e==null?void 0:e.current)&&s,n==null?void 0:n.height]),p=g.useMemo(()=>g.createElement(po,{key:"strokeColors",opacity:h,activeColor:c,setCurOpacity:(w,I,S)=>{S===D.Start&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!0),S===D.Done&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!1),u(w);const v=Mt(I,w);s!=null&&s.strokeColor&&r({strokeColor:v}),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[H],strokeColor:v,workState:S,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(hM,{key:"strokeThickness",min:1,max:10,activeNumber:s.thickness,setActiveNumber:(w,I)=>{I===D.Start&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!0),I===D.Done&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!1),s!=null&&s.thickness&&r({thickness:w}),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[H],thickness:w,workState:I,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]),m=g.useMemo(()=>c&&(s!=null&&s.strokeType)?g.createElement(uM,{key:"strokeType",useStroke:s==null?void 0:s.useStroke,activeStrokeType:s.strokeType,setStrokeType:w=>{s.strokeType&&r({strokeType:w}),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[H],strokeType:w,workState:D.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:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},m,f,g.createElement("div",{className:"font-colors-line"}),i.concat().map((w,I)=>{const S=Oe(...w);return g.createElement(uo,{key:I,color:S,activeColor:c,onTouchEndHandler:v=>{v.stopPropagation(),l(S);const T=Mt(S,h);s!=null&&s.strokeColor&&(s.strokeColor=T,r({strokeColor:T})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[H],workState:D.Done,strokeColor:T,viewId:n==null?void 0:n.viewId})},onClickHandler:v=>{v.cancelable&&v.preventDefault(),v.stopPropagation(),l(S);const T=Mt(S,h);s!=null&&s.strokeColor&&(s.strokeColor=T,r({strokeColor:T})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[H],workState:D.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]),N=g.useMemo(()=>c?g.createElement("div",{className:"color-bar-ring",style:{backgroundColor:Mt(c,h)}},g.createElement("div",{className:"circle"})):null,[c,h]);return g.createElement("div",{className:`button normal-button font-colors-icon ${o&&"active"}`,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),t(!o)},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),t(!o)}},N,y)},pM=a=>{const{open:o,setOpen:t,floatBarRef:e}=a,{floatBarData:s,floatBarColors:i,mananger:n,setFloatBarData:r}=g.useContext(mt),[c,l]=g.useState(),[h,u]=g.useState(1);g.useEffect(()=>{if(s!=null&&s.fillColor){const[y,N]=(s==null?void 0:s.fillColor)==="transparent"&&["transparent",1]||ho(s.fillColor);l(y),u(N)}},[s]);const d=g.useMemo(()=>{if(e!=null&&e.current&&L.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(po,{key:"fillColors",opacity:h||0,activeColor:c,setCurOpacity:(y,N,w)=>{w===D.Start&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!0),w===D.Done&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!1),u(y);const I=Mt(N,y);s!=null&&s.fillColor&&(s.fillColor=I,r({fillColor:I})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[H],fillColor:c&&Mt(N,y),workState:w,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(Pi,{activeColor:c,onTouchEndHandler:y=>{y.stopPropagation(),l("transparent");const N="transparent";s!=null&&s.fillColor&&(s.fillColor=N,r({fillColor:N})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[H],workState:D.Done,fillColor:N,viewId:n==null?void 0:n.viewId})},onClickHandler:y=>{y.cancelable&&y.preventDefault(),y.stopPropagation(),l("transparent");const N="transparent";s!=null&&s.fillColor&&(s.fillColor=N,r({fillColor:N})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[H],workState:D.Done,fillColor:N,viewId:n==null?void 0:n.viewId})}}),i.map((y,N)=>{const w=Oe(...y);return g.createElement(uo,{key:N,color:w,activeColor:c,onTouchEndHandler:I=>{I.cancelable&&I.preventDefault(),I.stopPropagation(),l(w);const S=Mt(w,h);s!=null&&s.fillColor&&(s.fillColor=S,r({fillColor:S})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[H],workState:D.Done,fillColor:S,viewId:n==null?void 0:n.viewId})},onClickHandler:I=>{I.cancelable&&I.preventDefault(),I.stopPropagation(),l(w);const S=Mt(w,h);s!=null&&s.fillColor&&(s.fillColor=S,r({fillColor:S})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:[H],workState:D.Done,fillColor:S,viewId:n==null?void 0:n.viewId})}})}),p):null,[o,c,i,p,s,n==null?void 0:n.viewId,h,d]),m=g.useMemo(()=>{const y=c&&c!=="transparent"&&Mt(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)}},m,f)},fM=a=>{const{open:o,setOpen:t,textOpt:e,workIds:s,floatBarRef:i}=a,{floatBarColors:n,mananger:r,setFloatBarData:c,floatBarData:l}=g.useContext(mt),[h,u]=g.useState(),[d,p]=g.useState(1);g.useEffect(()=>{if(e!=null&&e.fontColor){const[w,I]=(e==null?void 0:e.fontColor)==="transparent"&&["transparent",0]||ho(e.fontColor);u(w),p(I)}},[e==null?void 0:e.fontColor]);const f=g.useMemo(()=>{if(i!=null&&i.current&&L.isNumber(l==null?void 0:l.y)&&(r!=null&&r.height)){if(i.current.offsetTop&&i.current.offsetTop+l.y>180){const w={};return w.top="inherit",w.bottom=50,w}else if(!i.current.offsetTop&&(r==null?void 0:r.height)-i.current.offsetTop-l.y<120){const w={};return w.top="inherit",w.bottom=50,w}}},[i==null?void 0:i.current,l,r]),m=g.useMemo(()=>h&&h!=="transparent"?g.createElement(po,{key:"fontColors",opacity:d,activeColor:h,setCurOpacity:(w,I,S)=>{S===D.Start&&(r!=null&&r.control.room)&&(r.control.room.disableDeviceInputs=!0),S===D.Done&&(r!=null&&r.control.room)&&(r.control.room.disableDeviceInputs=!1),p(w);const v=Mt(I,w);l!=null&&l.textOpt&&(l.textOpt.fontColor=v,c({textOpt:l.textOpt})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:s||[H],fontColor:h&&v,workState:S,viewId:r==null?void 0:r.viewId})}}):null,[h,d,r==null?void 0:r.control.room,r==null?void 0:r.viewId,l==null?void 0:l.textOpt,s]),y=g.useMemo(()=>o?g.createElement("div",{className:"font-colors-menu",style:f,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},n.map((w,I)=>{const S=Oe(...w);return g.createElement(uo,{key:I,color:S,activeColor:h,onTouchEndHandler:v=>{v.stopPropagation(),u(S);const T=Mt(S,d);l!=null&&l.textOpt&&(l.textOpt.fontColor=T,c({textOpt:l.textOpt})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:s||[H],workState:D.Done,fontColor:T,viewId:r==null?void 0:r.viewId})},onClickHandler:v=>{v.cancelable&&v.preventDefault(),v.stopPropagation(),u(S);const T=Mt(S,d);l!=null&&l.textOpt&&(l.textOpt.fontColor=T,c({textOpt:l.textOpt})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:s||[H],workState:D.Done,fontColor:T,viewId:r==null?void 0:r.viewId})}})}),m):null,[o,n,m,h,d,l==null?void 0:l.textOpt,s,r==null?void 0:r.viewId,f]),N=g.useMemo(()=>{const w=h&&h!=="transparent"&&Mt(h,d)||"transparent";return g.createElement("div",{className:"color-bar"},g.createElement("div",{className:"color-bar-color",style:{backgroundColor:w}}))},[h,d]);return g.createElement("div",{className:`button normal-button font-colors-icon ${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:St("font-colors")}),N,y)},gM=a=>{const{open:o,setOpen:t,textOpt:e,workIds:s,floatBarRef:i}=a,{floatBarColors:n,mananger:r,setFloatBarData:c,floatBarData:l}=g.useContext(mt),[h,u]=g.useState(),[d,p]=g.useState(1);g.useEffect(()=>{if(e!=null&&e.fontBgColor){const[w,I]=(e==null?void 0:e.fontBgColor)==="transparent"&&["transparent",1]||ho(e.fontBgColor);u(w),p(I)}},[e==null?void 0:e.fontBgColor]);const f=g.useMemo(()=>{if(i!=null&&i.current&&L.isNumber(l==null?void 0:l.y)&&(r!=null&&r.height)){if(i.current.offsetTop&&i.current.offsetTop+l.y>180){const w={};return w.top="inherit",w.bottom=50,w}else if(!i.current.offsetTop&&(r==null?void 0:r.height)-i.current.offsetTop-l.y<120){const w={};return w.top="inherit",w.bottom=50,w}}},[i==null?void 0:i.current,l,r]),m=g.useMemo(()=>h&&h!=="transparent"?g.createElement(po,{key:"fontBgColor",opacity:d||0,activeColor:h,setCurOpacity:(w,I,S)=>{S===D.Start&&(r!=null&&r.control.room)&&(r.control.room.disableDeviceInputs=!0),S===D.Done&&(r!=null&&r.control.room)&&(r.control.room.disableDeviceInputs=!1),p(w);const v=Mt(I,w);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=v,c({textOpt:l.textOpt})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:s||[H],fontBgColor:h&&Mt(I,w),workState:S,viewId:r==null?void 0:r.viewId})}}):null,[h,d,r==null?void 0:r.control.room,r==null?void 0:r.viewId,l==null?void 0:l.textOpt,s]),y=g.useMemo(()=>o?g.createElement("div",{className:"font-colors-menu",style:f,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},g.createElement(Pi,{activeColor:h,onTouchEndHandler:w=>{w.stopPropagation();const I="transparent";u(I),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=I,c({textOpt:l.textOpt})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:s||[H],workState:D.Done,fontBgColor:I,viewId:r==null?void 0:r.viewId})},onClickHandler:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation();const I="transparent";u(I),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=I,c({textOpt:l.textOpt})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:s||[H],workState:D.Done,fontBgColor:I,viewId:r==null?void 0:r.viewId})}}),n.map((w,I)=>{const S=Oe(...w);return g.createElement(uo,{key:I,color:S,activeColor:h,onTouchEndHandler:v=>{v.stopPropagation(),u(S);const T=Mt(S,d);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=T,c({textOpt:l.textOpt})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:s||[H],workState:D.Done,fontBgColor:Mt(S,d),viewId:r==null?void 0:r.viewId})},onClickHandler:v=>{v.cancelable&&v.preventDefault(),v.stopPropagation(),u(S);const T=Mt(S,d);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=T,c({textOpt:l.textOpt})),K.emitMethod(q.MainEngine,R.SetColorNode,{workIds:s||[H],workState:D.Done,fontBgColor:Mt(S,d),viewId:r==null?void 0:r.viewId})}})}),m):null,[o,n,m,d,h,l==null?void 0:l.textOpt,s,r==null?void 0:r.viewId,f]),N=g.useMemo(()=>{const w=h&&h!=="transparent"&&Mt(h,d)||"transparent";return g.createElement("div",{className:"color-bar",style:{marginTop:0}},g.createElement("div",{className:"color-bar-color",style:{backgroundColor:w}}))},[h,d]);return g.createElement("div",{className:`button normal-button font-colors-icon ${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(lM,null),N,y)},MM=a=>{const{bold:o,setBold:t,workIds:e,viewId:s}=a,i=n=>{const r=o==="bold"?"normal":"bold";n.cancelable&&n.preventDefault(),n==null||n.stopPropagation(),t(r),K.emitMethod(q.MainEngine,R.SetFontStyle,{workIds:e,viewId:s,bold:r})};return g.createElement("div",{className:"font-style-button",onClick:i,onTouchEnd:i},g.createElement("img",{alt:"icon",src:St(o==="bold"?"bold-active":"bold")}))},yM=a=>{const{underline:o,setUnderline:t,workIds:e,viewId:s}=a,i=n=>{const r=!o;n.cancelable&&n.preventDefault(),n==null||n.stopPropagation(),t(r),K.emitMethod(q.MainEngine,R.SetFontStyle,{workIds:e,viewId:s,underline:r})};return g.createElement("div",{className:"font-style-button",onClick:i,onTouchEnd:i},g.createElement("img",{alt:"icon",src:St(o?"underline-active":"underline")}))},mM=a=>{const{lineThrough:o,setLineThrough:t,workIds:e,viewId:s}=a,i=n=>{const r=!o;n.cancelable&&n.preventDefault(),n==null||n.stopPropagation(),t(r),K.emitMethod(q.MainEngine,R.SetFontStyle,{workIds:e,viewId:s,lineThrough:r})};return g.createElement("div",{className:"font-style-button",onClick:i,onTouchEnd:i},g.createElement("img",{alt:"icon",src:St(o?"line-through-active":"line-through")}))},wM=a=>{const{italic:o,setItalic:t,workIds:e,viewId:s}=a,i=n=>{const r=o==="italic"?"normal":"italic";n.cancelable&&n.preventDefault(),n==null||n.stopPropagation(),t(r),K.emitMethod(q.MainEngine,R.SetFontStyle,{workIds:e,viewId:s,italic:r})};return g.createElement("div",{className:"font-style-button",onClick:i,onTouchEnd:i},g.createElement("img",{alt:"icon",src:St(o==="italic"?"italic-active":"italic")}))},IM=a=>{const{open:o,setOpen:t,textOpt:e,workIds:s,style:i,floatBarRef:n}=a,{mananger:r,floatBarData:c}=g.useContext(mt),[l,h]=g.useState("normal"),[u,d]=g.useState("normal"),[p,f]=g.useState(!1),[m,y]=g.useState(!1);g.useEffect(()=>{e!=null&&e.bold&&h(e.bold),L.isBoolean(e==null?void 0:e.underline)&&f(e.underline||!1),L.isBoolean(e==null?void 0:e.lineThrough)&&y(e.lineThrough||!1),e!=null&&e.italic&&d(e.italic)},[e]);const N=g.useMemo(()=>{if(i&&(n!=null&&n.current)&&L.isNumber(c==null?void 0:c.y)&&(r!=null&&r.height)){if(n.current.offsetTop&&n.current.offsetTop+c.y>180){const I={};return I.top="inherit",I.bottom=50,I}else if(!n.current.offsetTop&&(r==null?void 0:r.height)-n.current.offsetTop-c.y<120){const I={};return I.top="inherit",I.bottom=50,I}}},[i,n==null?void 0:n.current,c,r]),w=g.useMemo(()=>o?g.createElement("div",{className:"font-style-menu",style:N,onTouchEnd:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation()},onClick:I=>{I.cancelable&&I.preventDefault(),I.stopPropagation(),I.nativeEvent.stopImmediatePropagation()}},g.createElement(MM,{workIds:s||[H],bold:l,setBold:h,viewId:r==null?void 0:r.viewId}),g.createElement(yM,{workIds:s||[H],underline:p,setUnderline:f,viewId:r==null?void 0:r.viewId}),g.createElement(mM,{workIds:s||[H],lineThrough:m,setLineThrough:y,viewId:r==null?void 0:r.viewId}),g.createElement(wM,{workIds:s||[H],italic:u,setItalic:d,viewId:r==null?void 0:r.viewId})):null,[o,s,l,r==null?void 0:r.viewId,p,m,u,N]);return g.createElement("div",{className:`button normal-button ${o&&"active"}`,onTouchEnd:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation(),t(!o)},onClick:I=>{I.cancelable&&I.preventDefault(),I.stopPropagation(),I.nativeEvent.stopImmediatePropagation(),t(!o)}},g.createElement("img",{alt:"icon",src:St(o?"font-style-active":"font-style")}),w)},Dt=Object.freeze([12,14,18,24,36,48,64,80,144,288]),he=["top","topLeft","topRight","bottom","bottomLeft","bottomRight","left","leftTop","leftBottom","right","rightTop","rightBottom"],vM=a=>{const{style:o,onClickHandler:t}=a;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()}},Dt.map(e=>g.createElement("div",{className:"font-size-btn",key:e,onClick:()=>{t(e)},onTouchEnd:()=>{t(e)}},e)))},NM=a=>{const o=g.useRef(null),{open:t,setOpen:e,textOpt:s,workIds:i,floatBarRef:n}=a,{mananger:r,floatBarData:c}=g.useContext(mt),[l,h]=g.useState(0),[u,d]=g.useState(),p=Dt.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&&L.isNumber(c==null?void 0:c.y)&&(r!=null&&r.height)){if(n.current.offsetTop&&n.current.offsetTop+c.y>180){const I={};return I.top="inherit",I.bottom=35,I}else if(!n.current.offsetTop&&(r==null?void 0:r.height)-n.current.offsetTop-c.y<120){const I={};return I.top="inherit",I.bottom=35,I}}},[n==null?void 0:n.current,c,r]);function m(I){h(I),I&&I>=Dt[0]&&I<=Dt[p]&&K.emitMethod(q.MainEngine,R.SetFontStyle,{workIds:i||[H],fontSize:I,viewId:r==null?void 0:r.viewId})}const y=I=>{var S;(S=o.current)==null||S.blur(),e(!1),w(I)},N=g.useMemo(()=>t?g.createElement(vM,{onClickHandler:y,style:f}):null,[t,y,f]),w=I=>{I>Dt[p]&&(I=Dt[p]),I<Dt[0]&&(I=Dt[0]),m(I)};return g.useEffect(()=>()=>{r!=null&&r.control.room&&L.isBoolean(u)&&(r.control.room.disableDeviceInputs=u)},[r,u]),g.createElement("div",{className:"button normal-button font-size-barBtn",style:{width:50},onTouchEnd:I=>{I.stopPropagation(),I.nativeEvent.stopImmediatePropagation()},onClick:I=>{I.cancelable&&I.preventDefault(),I.stopPropagation(),I.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:I=>{if(I.key==="Backspace"){const S=window.getSelection(),v=S==null?void 0:S.getRangeAt(0);if(v!=null&&v.collapsed)return I.cancelable&&I.preventDefault(),document.execCommand("delete",!1),!1}return!1},onKeyUp:I=>{var S;if(o.current){const v=o.current.value,T=parseInt(v);isNaN(T)?o.current.value="0":o.current.value=T.toString(),T&&I.key==="Enter"&&(w(T),(S=o.current)==null||S.blur(),e(!1))}},onFocus:()=>{r!=null&&r.control.room&&!r.control.room.disableDeviceInputs&&(d(r.control.room.disableDeviceInputs),r.control.room.disableDeviceInputs=!0)},onBlur:()=>{r!=null&&r.control.room&&L.isBoolean(u)&&(r.control.room.disableDeviceInputs=u)}}),g.createElement("div",{className:"font-size-btns"},g.createElement("div",{className:"font-size-add",onClick:()=>{w(l+Dt[0])},onTouchEnd:()=>{w(l+Dt[0])}}),g.createElement("div",{className:"font-size-cut",onClick:()=>{w(l-Dt[0])},onTouchEnd:()=>{w(l-Dt[0])}})),N)},TM=a=>{const{workIds:o,mananger:t,islocked:e}=a;return g.createElement("div",{className:"button normal-button",onClick:s=>{s.cancelable&&s.preventDefault(),s.stopPropagation(),K.emitMethod(q.MainEngine,R.SetLock,{workIds:o||[H],isLocked:!e,viewId:t==null?void 0:t.viewId})},onTouchEnd:s=>{s.stopPropagation(),K.emitMethod(q.MainEngine,R.SetLock,{workIds:o||[H],isLocked:!e,viewId:t==null?void 0:t.viewId})}},g.createElement("img",{alt:"icon",src:St(e?"unlock-new":"lock-new")}))},ko=a=>{const{icon:o,min:t,max:e,step:s,value:i,onInputHandler:n}=a,[r,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:St(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(r+s)},onTouchEnd:()=>{h(r+s)}}),g.createElement("div",{className:"input-number-cut",onClick:()=>{h(r-s)},onTouchEnd:()=>{h(r-s)}})))},SM=a=>{const{icon:o,min:t,max:e,step:s,value:i,onInputHandler:n}=a;return g.createElement("div",{className:"button input-button"},g.createElement("img",{src:St(o)}),g.createElement(CM,{min:t,max:e,step:s,value:i,onInputHandler:n}))},CM=a=>{const{value:o,min:t,max:e,onInputHandler:s}=a,[i,n]=g.useState({x:0,y:0});g.useEffect(()=>{n({x:o*100,y:0})},[]);const r=L.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=L.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(we,{bounds:"parent",axis:"x",position:i,onDrag:r,onStart:c,onStop:l},g.createElement("div",{className:"circle",onClick:c}))))},kM=a=>{const{icon:o,value:t,onChangeHandler:e,style:s}=a,[i,n]=g.useState(0),[r,c]=g.useState(),l=g.useRef(null),h=g.useCallback(p=>{p>=he.length&&(p=0),p<0&&(p=he.length-1),n(p),e(he[p]),c(!1),l.current&&(l.current.value=he[p])},[e]),u=g.useMemo(()=>{if(s&&s.bottom){const p={};return p.top="inherit",p.bottom=50,p}},[s]);g.useEffect(()=>{t&&(n(he.indexOf(t)),l.current&&(l.current.value=t))},[t]);const d=g.useMemo(()=>r?g.createElement(xM,{options:he,onClickHandler:h,style:u}):null,[r,h,u]);return g.createElement("div",{className:"button input-button"},g.createElement("img",{src:St(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(!r))}}),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)},xM=a=>{const{options:o,style:t,onClickHandler:e}=a;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)))},zM=a=>{const{mananger:o,innerRatio:t,innerVerticeStep:e,vertices:s}=a,i=c=>{K.emitMethod(q.MainEngine,R.SetShapeOpt,{workIds:[H],toolsType:C.Star,viewId:o.viewId,vertices:c})},n=c=>{K.emitMethod(q.MainEngine,R.SetShapeOpt,{workIds:[H],toolsType:C.Star,viewId:o.viewId,innerVerticeStep:c})},r=c=>{K.emitMethod(q.MainEngine,R.SetShapeOpt,{workIds:[H],toolsType:C.Star,viewId:o.viewId,innerRatio:c})};return g.createElement(g.Fragment,null,g.createElement(ko,{value:s,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:i}),g.createElement(ko,{value:e,icon:"star-innerVertex",min:1,max:100,step:1,onInputHandler:n}),g.createElement(SM,{value:t,icon:"star-innerRatio",min:.1,max:1,step:.1,onInputHandler:r}))},bM=a=>{const{mananger:o,vertices:t}=a,e=s=>{K.emitMethod(q.MainEngine,R.SetShapeOpt,{workIds:[H],toolsType:C.Polygon,viewId:o.viewId,vertices:s})};return g.createElement(ko,{value:t,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:e})},PM=a=>{const{mananger:o,placement:t}=a,e=s=>{K.emitMethod(q.MainEngine,R.SetShapeOpt,{workIds:[H],toolsType:C.SpeechBalloon,viewId:o.viewId,placement:s})};return g.createElement(kM,{value:t,icon:"speechBallon-placement",onChangeHandler:e})},mo=a=>{const{icon:o,isActive:t,onClickHandler:e,onTouchEndHandler:s}=a;return g.createElement("div",{className:`button tab-button ${t?"active":""}`,onClick:e,onTouchEnd:s},g.createElement("img",{src:St(o)}))},LM=a=>{const{toolsTypes:o,style:t,mananger:e,shapeOpt:s}=a,[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 r=(u,d)=>{d.cancelable&&d.preventDefault(),d==null||d.stopPropagation(),n(u)},c=g.useMemo(()=>i===C.Polygon&&e&&s.vertices?g.createElement(bM,{vertices:s.vertices,mananger:e}):null,[e,i,s]),l=g.useMemo(()=>i===C.Star&&e&&s.vertices&&s.innerVerticeStep&&s.innerRatio?g.createElement(zM,{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(PM,{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(mo,{isActive:i===C.Polygon,icon:i===C.Polygon?"polygon-active":"polygon",onClickHandler:r.bind(void 0,C.Polygon),onTouchEndHandler:r.bind(void 0,C.Polygon)})||null,o.includes(C.Star)&&g.createElement(mo,{isActive:i===C.Star,icon:i===C.Star?"star-active":"star",onClickHandler:r.bind(void 0,C.Star),onTouchEndHandler:r.bind(void 0,C.Star)})||null,o.includes(C.SpeechBalloon)&&g.createElement(mo,{isActive:i===C.SpeechBalloon,icon:i===C.SpeechBalloon?"speechBallon-active":"speechBallon",onClickHandler:r.bind(void 0,C.SpeechBalloon),onTouchEndHandler:r.bind(void 0,C.SpeechBalloon)})||null),g.createElement("div",{className:"shapeOpt-sub-menu-content"},c,l,h))},DM=a=>{const{open:o,setOpen:t,floatBarRef:e,toolsTypes:s,shapeOpt:i}=a,{floatBarData:n,mananger:r}=g.useContext(mt),[c,l]=g.useState([]),[h,u]=g.useState(),d=g.useMemo(()=>{if(e!=null&&e.current&&L.isNumber(n==null?void 0:n.x)&&L.isNumber(n==null?void 0:n.y)&&(r!=null&&r.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&&(r==null?void 0:r.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,r==null?void 0:r.height]),p=g.useMemo(()=>o&&s&&r&&i?(r.control.room&&!r.control.room.disableDeviceInputs&&(u(r.control.room.disableDeviceInputs),r.control.room.disableDeviceInputs=!0),g.createElement(LM,{shapeOpt:i,style:d,toolsTypes:s,mananger:r})):(r!=null&&r.control.room&&L.isBoolean(h)&&(r.control.room.disableDeviceInputs=h),null),[o,d,s,r,i]),f=y=>{y.cancelable&&y.preventDefault(),y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),t(!o)},m=y=>{y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),t(!o)};return g.useEffect(()=>{L.isEqual(n==null?void 0:n.selectIds,c)||n!=null&&n.selectIds&&!L.isEqual(n==null?void 0:n.selectIds,c)&&(l(n==null?void 0:n.selectIds),t(!1))},[o,n,c,t]),g.useEffect(()=>()=>{o&&r!=null&&r.control.room&&L.isBoolean(h)&&(r.control.room.disableDeviceInputs=h)},[o,r,h]),g.createElement("div",{className:`button normal-button ${o&&"active"}`,onClick:f,onTouchEnd:m},p,g.createElement("img",{alt:"icon",src:St(o?"shapes-active":"shapes")}))},Li=g.memo(a=>{const{textOpt:o,workIds:t,noLayer:e,position:s}=a,{floatBarData:i,mananger:n}=g.useContext(mt),[r,c]=g.useState(0),[l,h]=g.useState(),u=g.useRef(null);g.useEffect(()=>{var b,A,O,j;const v={},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?v.bottom=-120:s.y+x<n.height?v.bottom=-58:s.y>0?v.top=62:v.top=-s.y+62:v.top=0,s.x<0)v.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;v.left=E}h(v);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(pM,{floatBarRef:u,open:r===3,setOpen:v=>{c(v===!0?3:0)}}):null,[i==null?void 0:i.fillColor,r,u]),p=g.useMemo(()=>i!=null&&i.strokeColor?g.createElement(dM,{floatBarRef:u,open:r===2,setOpen:v=>{c(v===!0?2:0)}}):null,[i==null?void 0:i.strokeColor,r,u]),f=g.useMemo(()=>o!=null&&o.fontColor&&(n!=null&&n.viewId)?g.createElement(fM,{floatBarRef:u,open:r===4,setOpen:v=>{c(v===!0?4:0)},textOpt:o,workIds:t}):null,[o,r,t,n,u]),m=g.useMemo(()=>o!=null&&o.fontBgColor&&(n!=null&&n.viewId)?g.createElement(gM,{floatBarRef:u,open:r===5,setOpen:v=>{c(v===!0?5:0)},textOpt:o,workIds:t}):null,[o,r,t,n,u]),y=g.useMemo(()=>o&&(n!=null&&n.viewId)?g.createElement(IM,{floatBarRef:u,open:r===6,setOpen:v=>{c(v===!0?6:0)},textOpt:o,workIds:t,style:l}):null,[o,r,t,n,l,u]),N=g.useMemo(()=>o&&(n!=null&&n.viewId)?g.createElement(NM,{open:r===7,setOpen:v=>{c(v===!0?7:0)},textOpt:o,workIds:t,floatBarRef:u}):null,[o,r,t,n,u]),w=g.useMemo(()=>e?null:g.createElement(cM,{open:r===1,setOpen:v=>{c(v===!0?1:0)},floatBarRef:u}),[e,r,u]),I=g.useMemo(()=>i!=null&&i.canLock&&n?g.createElement(TM,{workIds:t,mananger:n,islocked:i.isLocked}):null,[i,n,t]),S=g.useMemo(()=>n&&(n!=null&&n.viewId)&&l&&(i!=null&&i.shapeOpt)&&(i!=null&&i.toolsTypes)?g.createElement(DM,{open:r===8,setOpen:v=>{c(v===!0?8:0)},floatBarRef:u,workIds:t,toolsTypes:i.toolsTypes,shapeOpt:i.shapeOpt}):null,[i,n,r,l,t,u]);return g.createElement("div",{className:"appliance-plugin-floatbtns",style:l,ref:u,onMouseOver:v=>(v.stopPropagation(),v.cancelable&&v.preventDefault(),n==null||n.control.worker.blurCursor(n.viewId),!1),onMouseMove:v=>(v.stopPropagation(),v.cancelable&&v.preventDefault(),!1)},n&&g.createElement(rM,{workIds:t,mananger:n}),w,I,!!(n!=null&&n.viewId)&&g.createElement(aM,{workIds:t,viewId:n.viewId}),S,N,y,f,m,p,d)}),jM=a=>{const{data:o,isActive:t,manager:e,workId:s}=a,{opt:i,scale:n,translate:r,x:c,y:l}=o,h=`scale(${n||1}) ${r&&"translate("+r[0]+"px,"+r[1]+"px)"||""}`,{fontSize:u,fontFamily:d,underline:p,fontColor:f,lineThrough:m,textAlign:y,strokeColor:N,lineHeight:w,bold:I,italic:S,uid:v,workState:T}=i,x=u,b=w||x*1.2,A={fontSize:`${x}px`,lineHeight:`${b}px`,color:f,borderColor:N,minHeight:`${b}px`,paddingRight:`${S==="italic"?Math.round(x*.3):5}px`};d&&(A.fontFamily=`${d}`),(m||p)&&(A.textDecoration=`${m&&"line-through"||""}${p&&" underline"||""}`),I&&(A.fontWeight=`${I}`),S&&(A.fontStyle=`${S}`),y&&(A.textAlign=`${y}`);function O(){var E;t&&(v&&v===((E=e.control.collector)==null?void 0:E.uid)||!v)&&e.control.textEditorManager.active(s)}const j=g.useMemo(()=>{const E=[];if(i.text){const P=ke(i.text);for(let Y=0;Y<P.length;Y++){const et=P[Y];et===""?E.push(g.createElement("div",{style:{backgroundColor:i.fontBgColor},key:Y},g.createElement("br",null))):E.push(g.createElement("div",{style:{backgroundColor:i.fontBgColor},key:Y},et))}}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===D.Done?0:1}},g.createElement("div",{className:`editor ${t?"":"readOnly"}`,style:A,onClick:O},j))},AM=g.memo(a=>{const{data:o,left:t,top:e,workId:s,updateOptInfo:i}=a,{opt:n,scale:r,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:D.Done}})}}},[n.fontSize,n.italic,n.bold,n.boxSize,s]);const h=`scale(${r||1}) ${c&&"translate("+c[0]+"px,"+c[1]+"px)"||""}`,{fontSize:u,fontFamily:d,underline:p,fontColor:f,lineThrough:m,textAlign:y,strokeColor:N,lineHeight:w,bold:I,italic:S}=n,v=u,T=w||v*1.2,x={fontSize:`${v}px`,lineHeight:`${T}px`,color:f,borderColor:N,minHeight:`${T}px`,pointerEvents:"none",paddingRight:`${S==="italic"?Math.round(v*.3):5}px`};d&&(x.fontFamily=`${d}`),(m||p)&&(x.textDecoration=`${m&&"line-through"||""}${p&&" underline"||""}`),y&&(x.textAlign=`${y}`),I&&(x.fontWeight=`${I}`),S&&(x.fontStyle=`${S}`);const b=g.useMemo(()=>{const A=[];if(n.text){const O=ke(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))},(a,o)=>!(a.workId!==o.workId||a.left!==o.left||a.top!==o.top||!L.isEqual(a.data,o.data))),EM=a=>{const{data:o,workId:t,isSelect:e,showFloatBtns:s,handleKeyUp:i,handleFocus:n,updateOptInfo:r,manager:c,runAnimation:l}=a,[h,u]=g.useState(),{opt:d,scale:p,translate:f,x:m,y}=o,{fontSize:N,fontFamily:w,underline:I,fontColor:S,lineThrough:v,textAlign:T,strokeColor:x,lineHeight:b,bold:A,italic:O,boxSize:j}=d,E=g.useRef(null),P=g.useMemo(()=>{const ot=N,at=b||ot*1.2,U={fontSize:`${ot}px`,lineHeight:`${at}px`,color:S,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 w&&(U.fontFamily=`${w}`),(v||I)&&(U.textDecoration=`${v&&"line-through"||""} ${I&&" underline"||""}`),T&&(U.textAlign=`${T}`),A&&(U.fontWeight=`${A}`),O&&(U.fontStyle=`${O}`),U},[A,S,w,N,O,b,v,p,x,T,I]),Y=g.useMemo(()=>{const ot=`scale(${p||1}) ${f&&"translate("+f[0]+"px,"+f[1]+"px)"||""}`;return{left:`${m}px`,top:`${y}px`,zIndex:2,pointerEvents:"none",transform:ot,transformOrigin:"left top"}},[p,f,m,y]),et=g.useMemo(()=>{var ot,at;return!e&&p&&s&&L.isNumber(m)&&L.isNumber(y)&&d.boxSize&&L.isNumber((ot=d.boxSize)==null?void 0:ot[0])&&L.isNumber((at=d.boxSize)==null?void 0:at[1])?g.createElement("div",{className:xt.FloatBarBtn,style:{left:m,top:y,width:d.boxSize[0]*p,height:d.boxSize[1]*p}},g.createElement(Li,{position:{x:m,y},textOpt:d,workIds:[t],noLayer:!0})):null},[e,d,s,t,m,y,p]),tt=g.useMemo(()=>{let ot="";if(d.text){const at=ke(d.text);for(let U=0;U<at.length;U++){const it=at[U];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]),$=g.useMemo(()=>typeof tt=="string"?g.createElement("div",{id:t,suppressContentEditableWarning:!0,contentEditable:!0,className:"editor",ref:E,style:P,onKeyDown:G,onKeyUp:i,onClick:J,onTouchEnd:J,onFocus:n,onPaste:rt,onInput:wt,dangerouslySetInnerHTML:{__html:tt}}):null,[tt,P,t]);g.useEffect(()=>{$&&E.current&&(E.current.click(),setTimeout(()=>{var ot;if(E.current){const at=window==null?void 0:window.getSelection(),U=E.current.lastChild;if(at&&U){const it=document.createRange(),ht=((ot=U.textContent)==null?void 0:ot.length)||0;(U==null?void 0:U.nodeName)==="#text"?it.setStart(U,ht):it.setStart(U,ht&&1||0),it.collapse(!0),at.removeAllRanges(),at.addRange(it)}}},20))},[$,E.current]),g.useEffect(()=>{var ot,at,U,it;if($&&((ot=E.current)!=null&&ot.offsetWidth||(at=E.current)!=null&&at.offsetHeight||(U=E.current)!=null&&U.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)&&r({activeTextId:t,update:{boxSize:ht,workState:D.Doing}})}},[j,$,P,t]);function J(){E.current&&E.current.focus(),l()}function G(ot){if(ot.key==="Backspace"){const at=window.getSelection(),U=at==null?void 0:at.getRangeAt(0);if(U!=null&&U.collapsed)return ot.cancelable&&ot.preventDefault(),document.execCommand("delete",!1),!1}return l(),!1}function Z(ot,at){const U=window==null?void 0:window.getSelection();if(U!=null&&U.rangeCount&&ot&&U&&U.anchorNode){const it=U.anchorOffset,ht=U.anchorNode.textContent||"",It=ht.slice(0,it)||"",Ft=ht.slice(it)||"",yt=It.concat(ot)||"";X(yt,Ft,at)}}function X(ot,at,U){const it=window==null?void 0:window.getSelection();if(!(it!=null&&it.rangeCount)||!it.anchorNode)return;const ht=ot.split(/\n/);let It=it.anchorNode.parentNode;It===U&&(It=it.anchorNode);const Ft=[...U.childNodes],yt=[];let gt,te=it.anchorOffset;for(;Ft.length;){const Nt=Ft.pop();if(Nt){if(Nt===It){let Et=ht[0];ht.length===1&&(te=ht[0].length,Et=ht[0].concat(at)),It.nodeName==="#text"?(It.textContent=Et,gt=It):It.nodeName==="DIV"&&(It.innerText=Et,gt=It.childNodes[0]);break}yt.push(Nt),U.removeChild(Nt)}}if(ht.length>1)for(let Nt=1;Nt<ht.length;Nt++){let Et=ht[Nt];const xe=document.createElement("div");d.fontBgColor&&(xe.style.backgroundColor=d.fontBgColor),Nt===ht.length-1&&(te=Et.length,Et=Et.concat(at)),Et===""?xe.innerHTML="<br/>":xe.innerText=Et,U.appendChild(xe),Nt===ht.length-1&&(gt=xe.childNodes[0])}if(yt.length){yt.reverse();for(const Nt of yt)U.appendChild(Nt)}if(gt&&gt.nodeName==="#text"){it.deleteFromDocument();const Nt=document.createRange(),Et=Math.min(te,(gt==null?void 0:gt.length)||0);Nt.setStart(gt,Et),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"),U=window==null?void 0:window.getSelection();if(!(U!=null&&U.rangeCount))return;at&&U&&U.anchorNode&&Z(at,E.current),l()}}function wt(ot){i(ot),l()}return g.createElement(g.Fragment,null,et,g.createElement("div",{className:"editor-box",style:Y,onFocus:()=>{c.control.room&&!c.control.room.disableDeviceInputs&&(u(c.control.room.disableDeviceInputs),c.control.room.disableDeviceInputs=!0)},onBlur:()=>{c!=null&&c.control.room&&L.isBoolean(h)&&(c.control.room.disableDeviceInputs=h)}},$))};class Di 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 r=i.pop();t.push(...i),r&&t.push(r)}}}return t}updateOptInfo(o){var n,r;const{activeTextId:t,update:e,syncData:s}=o,i=t&&L.cloneDeep(((n=this.props.manager.control.textEditorManager)==null?void 0:n.get(t))||((r=this.props.editors)==null?void 0:r.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:r}=this.props.box,{x:c,y:l}=e,h=`${c-n}px`,u=`${l-r}px`,d=g.createElement(AM,{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 OM extends Di{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=Lt(e),r=D.Doing,c=[t.nativeEvent.target.offsetWidth,t.nativeEvent.target.offsetHeight];(!i||i&&(i.opt.text!==n||!L.isEqual(i.opt.boxSize,c)||!L.isEqual(i.opt.workState,r)))&&this.updateOptInfo({activeTextId:s,update:{text:n,boxSize:c,workState:r},syncData:{canSync:!0,canWorker:!0}})}}handleFocus(t){const e=this.props.activeTextId;if(e){const s=this.props.manager.control.textEditorManager.get(e),i=D.Doing,n=[t.nativeEvent.target.offsetWidth,t.nativeEvent.target.offsetHeight];(!s||s&&(!L.isEqual(s.opt.boxSize,n)||!L.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(EM,{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===D.Doing||s.opt.workState===D.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 RM=()=>{const{floatBarData:a}=g.useContext(mt);return g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:a==null?void 0:a.selectorColor}},g.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point LC ew-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point TC ns-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point RC ew-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point BC ns-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}))},YM=()=>{const{floatBarData:a,mananger:o}=g.useContext(mt),[t,e]=g.useState(),[s,i]=g.useState();g.useEffect(()=>{const c=[];if(o&&L.isNumber(a==null?void 0:a.x)&&L.isNumber(a==null?void 0:a.y)&&(a!=null&&a.points)){const l=o.viewId;if(o.control.viewContainerManager.getView(l))for(const u of a.points){const d=o.control.viewContainerManager.transformToOriginPoint(u,l);c.push(d)}c[0]&&e({x:c[0][0]-((a==null?void 0:a.x)||0),y:c[0][1]-((a==null?void 0:a.y)||0)}),c[1]&&i({x:c[1][0]-((a==null?void 0:a.x)||0),y:c[1][1]-((a==null?void 0:a.y)||0)})}},[o,a==null?void 0:a.points,a==null?void 0:a.x,a==null?void 0:a.y]);const n=g.useMemo(()=>t?g.createElement("div",{className:"point point-dot",style:{borderColor:a==null?void 0:a.selectorColor,left:t.x,top:t.y}}):null,[a==null?void 0:a.selectorColor,t]),r=g.useMemo(()=>s?g.createElement("div",{className:"point point-dot",style:{borderColor:a==null?void 0:a.selectorColor,left:s.x,top:s.y}}):null,[s,a==null?void 0:a.selectorColor]);return g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:a==null?void 0:a.selectorColor}},n,r)},WM=()=>{const{floatBarData:a}=g.useContext(mt);return g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:a==null?void 0:a.selectorColor}},g.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),g.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}))},UM=()=>{const{floatBarData:a}=g.useContext(mt);return g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:a==null?void 0:a.selectorColor}},g.createElement("img",{className:"lock",alt:"lock",src:"https://sdk.netless.link/resource/icons/lock.svg"}))},BM=a=>{const{className:o}=a,{floatBarData:t,angle:e,setAngle:s,setOperationType:i,mananger:n}=g.useContext(mt),[r,c]=g.useState(!1),[l,h]=g.useState(new F),[u,d]=g.useState(new F),[p,f]=g.useState(!1);g.useEffect(()=>(K.activeListener(m),()=>{K.unmountActiveListener(m)}),[]);const m=I=>{var S;if(!I){f(!0),c(!1),i(R.None);return}f(!1),(S=n==null?void 0:n.control.room)!=null&&S.disableDeviceInputs&&(n.control.room.disableDeviceInputs=!1)};g.useEffect(()=>{if(t){const I=Math.floor(t.w/2),S=Math.floor(-t.h/2);d(new F(I,S)),h(new F)}},[t]);const y=(I,S)=>{if(I.cancelable&&I.preventDefault(),I.stopPropagation(),n!=null&&n.control.worker.isBusy){f(!0);return}c(!0);const v=Math.round(F.GetAngleByPoints(l,u,new F(S.x,S.y)))||0;s(v),i(R.RotateNode),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=!0),K.emitMethod(q.MainEngine,R.RotateNode,{workIds:[H],angle:v,workState:D.Start,viewId:n==null?void 0:n.viewId})},N=Ee((I,S)=>{if(I.cancelable&&I.preventDefault(),I.stopPropagation(),n!=null&&n.control.worker.isBusy){f(!0);return}c(!1);const v=Math.round(F.GetAngleByPoints(l,u,new F(S.x,S.y)))||0;s(v),i(R.None),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=!1),K.emitMethod(q.MainEngine,R.RotateNode,{workIds:[H],angle:v,workState:D.Done,viewId:n==null?void 0:n.viewId})},100,{leading:!1}),w=Ee((I,S)=>{if(I.cancelable&&I.preventDefault(),I.stopPropagation(),n!=null&&n.control.worker.isBusy){f(!0);return}c(!0);const v=Math.round(F.GetAngleByPoints(l,u,new F(S.x,S.y)))||0;s(v),i(R.RotateNode),K.emitMethod(q.MainEngine,R.RotateNode,{workIds:[H],angle:v,workState:D.Doing,viewId:n==null?void 0:n.viewId})},100,{leading:!1});return g.createElement(we,{disabled:p,handle:".appliance-plugin-rotate-mouse-pointer",onStart:y,onDrag:w,onStop:N},g.createElement("div",{className:`${o}`,style:t?{left:t.x-30,top:t.y+t.h+20,touchAction:"none"}:void 0},!r&&g.createElement("div",{className:"appliance-plugin-rotate-btn",style:{backgroundColor:t==null?void 0:t.selectorColor}},g.createElement("img",{alt:"icon",src:St("rotation-button")})),g.createElement("div",{className:`appliance-plugin-rotate-mouse-pointer ${r?"active":""}`},g.createElement("img",{alt:"icon",src:St("rotation")}),g.createElement("div",{className:"angle-icon"},e,"°"))))},FM=a=>{const{floatBarData:o,setOperationType:t,mananger:e}=g.useContext(mt),{onClickHandle:s}=a,[i,n]=g.useState(D.Pending),[r,c]=g.useState(),[l,h]=g.useState(),[u,d]=g.useState(!1);g.useEffect(()=>(K.activeListener(p),()=>{K.unmountActiveListener(p)}),[]);const p=I=>{var S;if(!I||o!=null&&o.isLocked){d(!0),n(D.Pending),t(R.None);return}d(!1),(S=e==null?void 0:e.control.room)!=null&&S.disableDeviceInputs&&(e.control.room.disableDeviceInputs=!1)};g.useEffect(()=>{if(o!=null&&o.isLocked||e!=null&&e.control.worker.isBusy){d(!0),n(D.Pending);return}d(!1)},[o==null?void 0:o.isLocked]),g.useEffect(()=>{L.isNumber(o==null?void 0:o.x)&&L.isNumber(o==null?void 0:o.y)&&(i===D.Pending||i===D.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=I=>{if(I.cancelable&&I.preventDefault(),I.stopPropagation(),e!=null&&e.control.worker.isBusy){d(!0),n(D.Pending);return}L.isNumber(o==null?void 0:o.x)&&L.isNumber(o==null?void 0:o.y)&&(t(R.TranslateNode),n(D.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),K.emitMethod(q.MainEngine,R.TranslateNode,{workIds:[H],position:{x:o==null?void 0:o.x,y:o==null?void 0:o.y},workState:D.Start,viewId:e==null?void 0:e.viewId}))},m=L.throttle((I,S)=>{if(I.cancelable&&I.preventDefault(),e!=null&&e.control.worker.isBusy){d(!0),n(D.Pending);return}I.stopPropagation();const v={x:S.x,y:S.y};t(R.None),n(D.Done),e!=null&&e.control.room&&(e.control.room.disableDeviceInputs=!1),K.emitMethod(q.MainEngine,R.TranslateNode,{workIds:[H],position:v,workState:D.Done,viewId:e==null?void 0:e.viewId})},100,{leading:!1}),y=L.throttle((I,S)=>{if(I.cancelable&&I.preventDefault(),I.stopPropagation(),e!=null&&e.control.worker.isBusy){d(!0),n(D.Pending);return}const v={x:S.x,y:S.y};(S.x!==(o==null?void 0:o.x)||S.y!==(o==null?void 0:o.y))&&(n(D.Doing),K.emitMethod(q.MainEngine,R.TranslateNode,{workIds:[H],position:v,workState:D.Doing,viewId:e==null?void 0:e.viewId}))},100,{leading:!1}),N=g.useMemo(()=>!!((o==null?void 0:o.scaleType)===ct.none&&(o!=null&&o.canLock)),[o]),w=L.throttle(I=>(I.stopPropagation(),I.cancelable&&I.preventDefault(),(r==null?void 0:r.x)===(o==null?void 0:o.x)&&(r==null?void 0:r.y)===(o==null?void 0:o.y)&&s(I),!1),100,{leading:!1});return g.createElement(we,{disabled:u,position:l,onStart:f,onDrag:y,onStop:m},g.createElement("div",{style:o?{position:"absolute",left:0,top:0,width:o.w,height:o.h,zIndex:2,pointerEvents:N?"none":"auto",touchAction:"none"}:void 0,onClick:I=>{I.persist(),w(I)},onTouchEnd:I=>{I.persist(),w(I)}}))},VM=a=>{const{className:o}=a,[t,e]=g.useState({x:0,y:0,h:0,w:0}),[s,i]=g.useState(),[n,r]=g.useState(),[c,l]=g.useState(),{floatBarData:h,mananger:u}=g.useContext(mt),[d,p]=g.useState(),[f,m]=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 K.activeListener(y),()=>{K.unmountActiveListener(y)}},[]);const y=x=>{var b;if(!x){m(!0);return}m(!1),(b=u==null?void 0:u.control.room)!=null&&b.disableDeviceInputs&&(u.control.room.disableDeviceInputs=!1)},N=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]],w=(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]}},I=(x,b,A,O)=>{let j=!1,E=!1;const P={x:t.x,y:t.y,w:t.w,h:t.h},Y=[1,1],et=[0,0];switch(x){case"top":{const G=b.height+t.h;G<0?(E=!0,P.y=t.y+t.h,P.h=Math.abs(G)):(P.y=t.y-b.height,P.h=t.h+b.height);break}case"topLeft":{const G=b.width+t.w;G<0?(j=!0,P.x=t.x+t.w,P.w=Math.abs(G)):(P.x=t.x-b.width,P.w=t.w+b.width);const Z=b.height+t.h;Z<0?(E=!0,P.y=t.y+t.h,P.h=Math.abs(Z)):(P.y=t.y-b.height,P.h=t.h+b.height);break}case"topRight":{const G=b.width+t.w;G<0?(j=!0,P.x=t.x+G,P.w=Math.abs(G)):P.w=t.w+b.width;const Z=b.height+t.h;Z<0?(E=!0,P.y=t.y+t.h,P.h=Math.abs(Z)):(P.y=t.y-b.height,P.h=t.h+b.height);break}case"bottom":{const G=b.height+t.h;G<0?(E=!0,P.y=t.y+G,P.h=Math.abs(G)):P.h=t.h+b.height;break}case"bottomLeft":{const G=b.width+t.w;G<0?(j=!0,P.x=t.x+t.w,P.w=Math.abs(G)):(P.x=t.x-b.width,P.w=t.w+b.width);const Z=b.height+t.h;Z<0?(E=!0,P.y=t.y+Z,P.h=Math.abs(Z)):P.h=t.h+b.height;break}case"left":{const G=b.width+t.w;G<0?(j=!0,P.x=t.x+t.w,P.w=Math.abs(G)):(P.x=t.x-b.width,P.w=t.w+b.width);break}case"bottomRight":{const G=b.width+t.w;G<0?(j=!0,P.x=t.x+G,P.w=Math.abs(G)):P.w=t.w+b.width;const Z=b.height+t.h;Z<0?(E=!0,P.y=t.y+Z,P.h=Math.abs(Z)):P.h=t.h+b.height;break}case"right":{const G=b.width+t.w;G<0?(j=!0,P.x=t.x+G,P.w=Math.abs(G)):P.w=t.w+b.width;break}}Y[0]=P.w/t.w,Y[1]=P.h/t.h;const $=N(P).map(G=>A.control.viewContainerManager.transformToScenePoint(G,A.viewId)),J=w($,x);return E&&(et[1]=J[1]-O[1]),j&&(et[0]=J[0]-O[0]),{scale:Y,translate:et}},S=(x,b)=>{if(x.cancelable&&x.preventDefault(),x.stopPropagation(),u!=null&&u.control.worker.isBusy){m(!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=N(A),j=O.map(Y=>u.control.viewContainerManager.transformToScenePoint(Y,u.viewId)),E=w(O,b),P=w(j,b);e(A),i(E),r(P),l(b),u!=null&&u.control.room&&(u.control.room.disableDeviceInputs=!0),K.emitMethod(q.MainEngine,R.ScaleNode,{workIds:[H],originPoint:E,scenePoint:P,workState:D.Start,viewId:u.viewId})}},v=L.throttle((x,b,A,O)=>{if(x.cancelable&&x.preventDefault(),x.stopPropagation(),!u||!s||!n)return;if(u!=null&&u.control.worker.isBusy){m(!0);return}const{scale:j,translate:E}=I(b,O,u,n);(!L.isEqual(j,d==null?void 0:d.scale)||!L.isEqual(E,d==null?void 0:d.translate))&&(p({scale:j,translate:E}),K.emitMethod(q.MainEngine,R.ScaleNode,{workIds:[H],scale:j,dir:b,translate:E,originPoint:s,scenePoint:n,workState:D.Doing,viewId:u.viewId}))},100,{leading:!1}),T=L.throttle(x=>{if(x.cancelable&&x.preventDefault(),x.stopPropagation(),!(!u||!s||!n)){if(u!=null&&u.control.worker.isBusy){m(!0);return}if(u!=null&&u.control.room&&(u.control.room.disableDeviceInputs=!1),d){const{scale:b,translate:A}=d;K.emitMethod(q.MainEngine,R.ScaleNode,{workIds:[H],scale:b,dir:c,translate:A,originPoint:s,scenePoint:n,workState:D.Done,viewId:u.viewId})}}},100,{leading:!1});return g.createElement(Ei.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:S,onResize:v,onResizeStop:T})},Ls=a=>{const{id:o,pos:t,pointMap:e,type:s}=a,{setOperationType:i,mananger:n,floatBarData:r}=g.useContext(mt),[c,l]=g.useState({x:0,y:0}),[h,u]=g.useState(D.Pending),[d,p]=g.useState(!1);g.useEffect(()=>(K.activeListener(f),()=>{K.unmountActiveListener(f)}),[]);const f=w=>{var I;if(!w||r!=null&&r.isLocked){p(!0),u(D.Pending),i(R.None);return}p(!1),(I=n==null?void 0:n.control.room)!=null&&I.disableDeviceInputs&&(n.control.room.disableDeviceInputs=!1)};g.useEffect(()=>{L.isNumber(t.x)&&L.isNumber(t.y)&&(h===D.Pending||h===D.Done)&&l({x:t.x,y:t.y})},[t,h]);const m=w=>{if(w.cancelable&&w.preventDefault(),w.stopPropagation(),n!=null&&n.control.worker.isBusy){p(!0),u(D.Pending);return}L.isNumber(t.x)&&L.isNumber(t.y)&&(i(R.SetPoint),u(D.Start),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=!0),K.emitMethod(q.MainEngine,R.SetPoint,{workId:H,pointMap:e,workState:D.Start,viewId:n==null?void 0:n.viewId}))},y=L.throttle((w,I)=>{if(w.cancelable&&w.preventDefault(),w.stopPropagation(),n!=null&&n.control.worker.isBusy){p(!0),u(D.Pending);return}const S={x:I.x,y:I.y};if((S.x!==(t==null?void 0:t.x)||S.y!==(t==null?void 0:t.y))&&(n!=null&&n.control.viewContainerManager)){const v=n.control.viewContainerManager.transformToScenePoint([S.x,S.y],n.viewId),T=e.get(o);T&&s==="start"?T[0]=v:T&&s==="end"&&(T[1]=v),u(D.Doing),K.emitMethod(q.MainEngine,R.SetPoint,{workId:H,pointMap:e,workState:D.Doing,viewId:n==null?void 0:n.viewId})}},100,{leading:!1}),N=L.throttle((w,I)=>{if(w.cancelable&&w.preventDefault(),n!=null&&n.control.worker.isBusy){p(!0),u(D.Pending);return}w.stopPropagation(),i(R.None),u(D.Done);const S={x:I.x,y:I.y};if(n!=null&&n.control.viewContainerManager){const v=n.control.viewContainerManager.transformToScenePoint([S.x,S.y],n.viewId),T=e.get(o);T&&s==="start"?T[0]=v:T&&s==="end"&&(T[1]=v),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=!1),K.emitMethod(q.MainEngine,R.SetPoint,{workId:H,pointMap:e,workState:D.Done,viewId:n==null?void 0:n.viewId})}},100,{leading:!1});return g.createElement(we,{disabled:d,position:c,onStart:m,onDrag:y,onStop:N},g.createElement("div",{className:"appliance-plugin-point-draggable-btn",style:r?{left:0,top:0}:void 0}))},HM=a=>{const{className:o}=a,{floatBarData:t,mananger:e}=g.useContext(mt),[s,i]=g.useState(),[n,r]=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 m of t.points){const y=e.control.viewContainerManager.transformToOriginPoint(m,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]&&r({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((a,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(RM,null),[t,e]),i=g.useMemo(()=>(t==null?void 0:t.scaleType)!==ct.both||e===R.RotateNode?null:g.createElement(YM,null),[t,e]),n=g.useMemo(()=>(t==null?void 0:t.scaleType)!==ct.proportional||e===R.RotateNode?null:g.createElement(WM,null),[t,e]),r=g.useMemo(()=>(t==null?void 0:t.scaleType)===ct.none&&(t!=null&&t.canLock)?g.createElement(UM,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},r,s,i,n,a.children)}),$M=g.forwardRef((a,o)=>{var d;const{floatBarData:t,operationType:e,mananger:s}=g.useContext(mt),{editors:i,activeTextId:n}=a,r=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(BM,{className:xt.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)&&L.isNumber(t==null?void 0:t.x)&&L.isNumber(t==null?void 0:t.y)?g.createElement(VM,{className:xt.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:xt.ResizeTowBox}):null,[t==null?void 0:t.scaleType,e]),h=g.useMemo(()=>{const p=(t==null?void 0:t.selectIds)||[];return i&&s&&p&&L.isNumber(t==null?void 0:t.x)&&L.isNumber(t==null?void 0:t.y)&&L.isNumber(t==null?void 0:t.w)&&L.isNumber(t==null?void 0:t.h)?g.createElement(Di,{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&&L.isNumber(t==null?void 0:t.x)&&L.isNumber(t==null?void 0:t.y)&&L.isNumber(t==null?void 0:t.w)&&L.isNumber(t==null?void 0:t.h)?g.createElement("div",{className:xt.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:xt.FloatBar,onMouseOver:()=>{s==null||s.control.worker.blurCursor(s.viewId)}},g.createElement(QM,{ref:o},g.createElement(g.Fragment,null,h)),g.createElement(FM,{onClickHandle:p=>{if(s&&(i!=null&&i.size)){const f=s.getPoint(p.nativeEvent);f&&s.control.textEditorManager.computeTextActive(f,s.viewId)}}}),r,c,l,u)}),GM=g.memo($M,(a,o)=>!!L.isEqual(a,o)),ZM="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAYISURBVHgB7ZpNSCtXFIBPEuvz+dMGpYUKD/sWFX+Qti6kK7Hqpm6e9q0rIoIUFUShPLV10VZx4+JZqa9v20LBhdq9fyBUCtKNPH8qYl2IOw3G38Rkek4y15y5uTOZJDOWggcOSSYzN/ebc+45554JwIM8iBCPyTEP+86T4vyMfsRN4b+nQTKIJp0vzuGvlpID7os8EQNEIBD4oKio6Bm9DwaDv/v9/n/076JgbtWUYPchwrW8qD7UnOvr6wFNkpubm+/wu7f0c7y6mrnlvQufxB0Iau7V1dX3BDA/P6/V1dVpzc3N2uLiIofK1c8VYHys/wRKBUN3/hGHqaysNOjc3FwMis6hc0FtLTHuvYLxCCZgci8uLn4wg5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HJlMnTSrwSRFIlfXt7m3V5ngJGuJtqzaQtZkFBVNJezN5ZAdmwjKo2k9tVtrcI3OXk4tPgcg7ChCDZ1URgMOu72Xa5VFHOkymQhWVU60YVmjN6wiC7k6p+S1syCACOwJBYFaexV+yhBekNPsMBO6KAEeE4BMaCU67RsoYhSbXgaT//ht709vZCaWmp6YkEbLFmVJWzas04+iBL7EKpm0J7duqu0B7+CTUpNJuyvb1NCfMj1CqI9wLKUOlOUMeG+gGFkHii4HizUF4z/KFUrPsJ8WbEIyx7nnZ0dDynME6BAuce09iFHo+GrnmGltltb2//E4wVAN82y7vOjKOZXSBhJdHNiT3TYWD8OY2PTUJkdd7MkJMnT5wZVQF2RFX6yBMUdzPMvvfqxz3sXHF+GNT9ANXit/10O1sgHkZvdQAOKvs9B5L7ARELGAAXLSTvM8QExTE+YbHe+HURhZp1aRyF4CJXClbbWwGketgkW9VsY+YaiBCVhfgE+XvxRwgZSM4jUVCDZFQ9pytmXR8hUTB2gnidx4XffVWydN0yQjwmx/jkAZJBrIBI5J7ZvQGZWUgVSuU/EqmOAzicKNMVu816DdRWUV1/7xAP8n+SfwF3Du3NF2sYhwAAAABJRU5ErkJggg==",qM="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",JM="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",XM="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAgrSURBVHgB7ZprTBRXFIDP7gIt8lQppTwE5V0KaAn6o1pqNGkDDTEmTUhsgKRp+gNJw68CFkLbVC2QkDS+gD8KJdWmARvbFBNNWpuIRGPFWBXQRMPDqIki+KLATs+ZnTvcvXtnX8w2beJJToaduTP3fH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JyUlpRmc5xpPMD599LIYnLNyUKKndKjGxsakXbt2deMCLIE8IVvs0YRM1fjdu3d/wrXN5+BcnzEgvor2uN3rjzAYMp5lPEoQlE5fA0fWo8GfhlCbKVFQ1pKNIfzcOHH58mWqaimVUwJI0+6n59D4pIlzmdZPMPiZzXjDjX47Le5g0Uu8x2zgPqWyKpjVe7x3+AUbq9NYjQbgp2dsBud5o8TP7d5kHAWcQchQfoEmLgn8HjOiBIF7o5hI1x6CEbLNP3bdqYAF44JzyWLzcN1i8DcT/o3awbm8Fz3DAy2A62INwPV/E3wWdx5inmBHuwChCBD6R2JwHge80TIQRQLjt7e8DTkGZgfX8cUMZTDAteFDkveaIlzjX9ySQs8X18r2t2VHUURPKoICmDR+eCO9aSdmOIub3/w9RgpgUpiJhvraXpa6jZKHGEqyusw0GLFzX+5RhN/8kYnMSNMMfyH/V/kHST6OYVElTPAAAAAASUVORK5CYII=";class KM 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 st.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:ZM,alt:"pencilCursor"}))));case st.eraser:case st.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:XM,alt:"pencilEraser"}))));case st.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:JM,alt:"textCursor"}))));case st.rectangle:case st.arrow:case st.straight:case st.shape:case st.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:qM,alt:"shapeCursor"}))));default:return null}}}const _M=a=>{const{className:o,info:t}=a,{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(KM,{roomMember:e}))},ty=a=>{const{className:o,manager:t}=a,[e,s]=g.useState();g.useEffect(()=>(t.internalMsgEmitter.on([q.Cursor,t.viewId],i),()=>{t.internalMsgEmitter.off([q.Cursor,t.viewId],i)}),[t]);function i(r){s(r)}return g.useMemo(()=>{if(e!=null&&e.length){const r=e.map(c=>{var l;return c.roomMember?g.createElement(_M,{key:(l=c.roomMember)==null?void 0:l.memberId,className:o,info:c}):null});return g.createElement(g.Fragment,null,r)}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 qt(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,r,c,l;const t=!!((s=(e=this.props.mananger.control)==null?void 0:e.room)!=null&&s.floatBarOptions);return g.createElement("div",{className:xt.Container},!this.props.mananger.control.hasOffscreenCanvas()&&g.createElement("div",{className:xt.CanvasBox,ref:this.props.refs.canvasContainerRef})||g.createElement("div",{className:xt.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:xt.FloatCanvas,ref:this.props.refs.canvasServiceFloatRef,style:{width:"100%",height:"100%"}}),g.createElement("canvas",{id:"localCanvas",className:xt.FloatCanvas,ref:this.props.refs.canvasFloatRef,style:{width:"100%",height:"100%"}}),g.createElement("div",{id:"subLocalCanvas",className:xt.CanvasBoxSub,ref:this.props.refs.subLocalCanvasContainerRef}),g.createElement("canvas",{id:"topCanvas",className:xt.TopFloatCanvas,ref:this.props.refs.canvasTopRef,style:{width:"100%",height:"100%"}})),!this.props.mananger.control.hasOffscreenCanvas()&&this.props.refs.snapshotContainerRef&&g.createElement("div",{className:xt.SnapshotBox,ref:this.props.refs.snapshotContainerRef})||null,g.createElement(mt.Provider,{value:{mananger:this.props.mananger,floatBarColors:t&&((r=(n=(i=this.props.mananger.control)==null?void 0:i.room)==null?void 0:n.floatBarOptions)==null?void 0:r.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(GM,{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(OM,{className:xt.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(ty,{className:xt.CursorBox,manager:this.props.mananger}))}}class ey extends bi{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=Kt(),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=Kt(),this.width=t,this.height=e),t&&e&&this.canvasBgRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=Kt(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 oy 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=Kt(),this.canvasContainerRef.current.style.width=`${t}px`,this.canvasContainerRef.current.style.height=`${e}px`)}if(this.canvasBgRef.current){this.dpr=Kt(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 jt extends me{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(vt,!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 ey(this.control,Tt.InternalMsgEmitter),n=t.size.width||i.width,r=t.size.height||i.height,l={dpr:i.dpr,originalPoint:[n/2,r/2],offscreenCanvasOpt:{...jt.defaultScreenCanvasOpt,width:n,height:r},layerOpt:{...jt.defaultLayerOpt,width:n,height:r},cameraOpt:{...jt.defaultCameraOpt,width:n,height:r}},{scale:h,...u}=t.camera;l.cameraOpt={...l.cameraOpt,...u,scale:h===1/0?1:h},this.focuedViewId=vt,this.createMianView({id:vt,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:r}=this.mainView.viewData.size;(n!==s||r!==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:r};L.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 r=new oy(e,this.control,Tt.InternalMsgEmitter),c=s.size.width||r.width,l=s.size.height||r.height,u={dpr:r.dpr,originalPoint:[c/2,l/2],offscreenCanvasOpt:{...jt.defaultScreenCanvasOpt,width:c,height:l},layerOpt:{...jt.defaultLayerOpt,width:c,height:l},cameraOpt:{...jt.defaultCameraOpt,...s.camera,width:c,height:l}};if(this.createAppView({id:e,container:i,displayer:r,cameraOpt:u.cameraOpt,focusScenePath:s.focusScenePath,viewData:s}),r.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:r}=e.viewData.size,c=i.width,l=i.height;(n!==c||r!==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:r};L.isEqual(p,i)||(e.cameraOpt=p)}}});this.control=t.control}getViewInitData(t){var s;const e=this.getView(t);if(e){const{width:i,height:n,dpr:r}=e.displayer;(s=this.control.pluginOptions.canvasOpt)!=null&&s.contextType&&(jt.defaultScreenCanvasOpt.contextType=this.control.pluginOptions.canvasOpt.contextType);const c={dpr:r,originalPoint:[i/2,n/2],offscreenCanvasOpt:{...jt.defaultScreenCanvasOpt,width:i,height:n},layerOpt:{...jt.defaultLayerOpt,width:i,height:n},cameraOpt:{...jt.defaultCameraOpt,width:i,height:n}};if(e.viewData){const{scale:l,...h}=e.viewData.camera;c.cameraOpt={...c.cameraOpt,...h,scale:l===1/0?1:l}}return c}}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:r,pageAuth:c}=this.control.collector.authStorage;if(r){const l=r[t];if(l){const{render:h,hide:u,clear:d}=l;this.control.renderControl.syncRenderUids(t,h,u,d);return}}if(c){const l=c[t];if(l){this.control.renderControl.syncPageAuth(t,l,!0);return}}}this.control.worker.pullServiceData(t,e.focusScenePath,{isAsync:!0,useAnimation:!1})}}}listenerWindowManager(t){t.emitter.on("focusedChange",e=>{const s=e||vt;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,vt)}),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 ue extends Tt{constructor(t){super(t);M(this,"windowManager");M(this,"viewContainerManager");const e={control:this,internalMsgEmitter:Tt.InternalMsgEmitter};this.viewContainerManager=new jt(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,e)=>{t&&Object.keys(t).forEach(s=>{var n;const i=(n=t[s])==null?void 0:n.newValue;this.renderControl.syncRenderUids(s,i==null?void 0:i.render,i==null?void 0:i.hide,i==null?void 0:i.clear)}),e&&Object.keys(e).forEach(s=>{var n;const i=(n=e[s])==null?void 0:n.newValue;this.renderControl.syncPageAuth(s,i)})}),this.collector.addStorageStateListener(t=>{var r,c;if((r=this.collector)!=null&&r.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(vt,!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 m of Object.keys(p))m&&f.add(m);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())Tt.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 r;if(n&&n.focusScenePath&&((r=this.collector)!=null&&r.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:r,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:r,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,r;this.windowManager=t,(s=(e=this.windowManager)==null?void 0:e.mainView)!=null&&s.divElement&&this.viewContainerManager.onMainViewMounted(this.windowManager.mainView),(r=(n=(i=this.windowManager.appManager)==null?void 0:i.viewManager)==null?void 0:n.views)!=null&&r.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 nt.InvisiblePlugin{constructor(){super(...arguments);M(this,"onPhaseChanged",t=>{var e;t===nt.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;t!=null&&t.roomMembers&&((e=Q.currentManager)==null||e.onRoomMembersChange(t.roomMembers)),!(nt.isRoom(this.displayer)&&!this.displayer.isWritable)&&t.memberState&&((s=Q.currentManager)==null||s.onMemberChange(t.memberState))})}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,r=s.callbacks.once,c=t.cleanCurrentScene,l=t.mainView.setMemberState;e!=null&&e.logger&&(Q.logger=e.logger),e.options&&(Q.options={...Pt,...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(f){var N;Q.logger.info("[ApplianceMultiPlugin] getBoundingRectAsync");const m=(t.mainView||s).getBoundingRect(f),y=await((N=Q.currentManager)==null?void 0:N.getBoundingRect(f));return!m.width||!m.height?y:Si(m,y)},screenshotToCanvasAsync:async function(f,m,y,N,w,I){var A;Q.logger.info("[ApplianceMultiPlugin] screenshotToCanvasAsync");let S=y,v=N,T=w.scale;S>this.maxScreenshotWidth&&(T=this.maxScreenshotWidth/S*T,S=this.maxScreenshotWidth),v>this.maxScreenshotHeight&&(T=Math.min(this.maxScreenshotHeight/v*T,T),v=this.maxScreenshotHeight),w.scale=T;const x=document.createElement("canvas"),b=x.getContext("2d");x.width=S*(I||1),x.height=v*(I||1),b&&((t.mainView||s).screenshotToCanvas(b,m,S,v,w,I),f.drawImage(x,Math.floor((y-S)/2),Math.floor((N-v)/2),S*(I||1),v*(I||1),0,0,S,v),x.remove()),Q.currentManager&&await((A=Q.currentManager)==null?void 0:A.screenshotToCanvas(f,m,S,v,w,Math.floor((y-S)/2),Math.floor((N-v)/2)))},scenePreviewAsync:async function(f,m,y,N,w){Q.logger.info("[ApplianceMultiPlugin] scenePreviewAsync"),(t.mainView||s).scenePreview(f,m,y,N,w);const I=document.createElement("img");I.className="appliance-plugin-fill-scene-snapshot-img",m.append(I),getComputedStyle(m).position||(m.style.position="relative"),Q.currentManager&&await Q.currentManager.scenePreview(f,I)},fillSceneSnapshotAsync:async function(f,m,y,N,w){Q.logger.info("[ApplianceMultiPlugin] fillSceneSnapshotAsync"),m.innerHTML="",(t.mainView||s).fillSceneSnapshot(f,m,y,N,w);const I=y||t.mainView.size.width,S=N||t.mainView.size.height;let v=await this.getBoundingRectAsync(f);v||(v={originX:0,originY:0,width:I,height:S});let T=Math.max(v==null?void 0:v.width,I),x=Math.max(v==null?void 0:v.height,S),b=1;const A=T>I&&Math.min(I/T,b)||b,O=x>S&&Math.min(S/x,b)||b;A<=O?(T=A<1&&I||T,x=Math.floor(x*A)+1,b=A):A>O&&(x=O<1&&S||x,T=Math.floor(T*O)+1,b=O);const j={scale:b,centerX:v.originX+v.width/2,centerY:v.originY+v.height/2},E=document.createElement("canvas"),P=E.getContext("2d");E.width=T,E.height=x,P&&await this.screenshotToCanvasAsync(P,f,T,x,j,devicePixelRatio);const Y=document.createElement("img");Y.className="appliance-plugin-fill-scene-snapshot-img",Y.src=E.toDataURL(),Y.onload=()=>{E.remove()},Y.onerror=()=>{E.remove(),Y.remove()},m.append(Y),getComputedStyle(m).position||(m.style.position="relative")},_callbacksOn:function(f,m){Q.logger.info(`[ApplianceMultiPlugin] callbacks ${f}`),(f==="onCanUndoStepsUpdate"||f==="onCanRedoStepsUpdate")&&nt.isRoom(s)&&s.isWritable?ue.InternalMsgEmitter.on(f,m):i.call(s.callbacks,f,m)},_callbacksOnce:function(f,m){Q.logger.info(`[ApplianceMultiPlugin] callbacks ${f}`),(f==="onCanUndoStepsUpdate"||f==="onCanRedoStepsUpdate")&&nt.isRoom(s)&&s.isWritable?ue.InternalMsgEmitter.on(f,m):r.call(s.callbacks,f,m)},_callbacksOff:function(f,m){Q.logger.info(`[ApplianceMultiPlugin] callbacks ${f}`),(f==="onCanUndoStepsUpdate"||f==="onCanRedoStepsUpdate")&&nt.isRoom(s)&&s.isWritable?ue.InternalMsgEmitter.off(f,m):n.call(s.callbacks,f,m)},canRedoSteps(){if(Q.logger.info("[ApplianceMultiPlugin] canRedoSteps"),Q.currentManager&&nt.isRoom(s)&&!s.disableSerialization){const f=Q.currentManager.viewContainerManager.focuedView,m=f==null?void 0:f.focusScenePath;if(f&&m)return f.displayer.commiter.redoStack.filter(y=>y.scenePath===m).length}return 0},canUndoSteps(){if(Q.logger.info("[ApplianceMultiPlugin] canUndoSteps"),Q.currentManager&&nt.isRoom(s)&&!s.disableSerialization){const f=Q.currentManager.viewContainerManager.focuedView,m=f==null?void 0:f.focusScenePath;if(f&&m)return f.displayer.commiter.undoStack.filter(y=>y.scenePath===m).length}return 0},undo:function(){return Q.logger.info("[ApplianceMultiPlugin] undo"),Q.currentManager&&nt.isRoom(s)&&!s.disableSerialization?Q.currentManager.viewContainerManager.undo():0},redo:function(){return Q.logger.info("[ApplianceMultiPlugin] redo"),Q.currentManager&&nt.isRoom(s)&&!s.disableSerialization?Q.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(){Q.logger.info("[ApplianceMultiPlugin] cleanCurrentScene"),Q.currentManager&&nt.isRoom(s)&&s.isWritable&&(Q.currentManager.cleanCurrentScene(),c.call(t))},insertImage:function(f){Q.logger.info("[ApplianceMultiPlugin] insertImage"),Q.currentManager&&nt.isRoom(s)&&s.isWritable&&Q.currentManager.worker.insertImage("mainView",f)},lockImage:function(f,m){Q.logger.info("[ApplianceMultiPlugin] lockImage"),Q.currentManager&&nt.isRoom(s)&&s.isWritable&&Q.currentManager.worker.lockImage("mainView",f,m)},completeImageUpload:function(f,m){Q.logger.info("[ApplianceMultiPlugin] completeImageUpload"),Q.currentManager&&nt.isRoom(s)&&s.isWritable&&Q.currentManager.worker.completeImageUpload("mainView",f,m)},getImagesInformation:function(f){return Q.logger.info("[ApplianceMultiPlugin] completeImageUpload"),Q.currentManager&&nt.isRoom(s)&&s.isWritable?Q.currentManager.worker.getImagesInformation(f):[]},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(f){Q.logger.info("[ApplianceMultiPlugin] setMemberState");const m=Object.keys(f);if(nt.isRoom(s)&&s.isWritable){m.includes("currentApplianceName")&&(f.currentApplianceName&&f.currentApplianceName===st.laserPen?(f.currentApplianceName=st.pencil,f.useLaserPen=!0):f.currentApplianceName&&f.currentApplianceName===st.pencil&&(f.useLaserPen=!1)),l.call(t.mainView,f);return}throw new Error("[ApplianceMultiPlugin] setMemberState must be called in writable room")},setPerformancePriority(f){Q.logger.info("[ApplianceMultiPlugin] setPriority"),Q.currentManager&&Q.currentManager.setPriority(f)}},d=(f,m)=>{if(Q.logger.info(`[ApplianceMultiPlugin] injectMethodToObject ${m}`),typeof f[m]=="function"||typeof f[m]>"u"){f[m]=u[m];return}m==="callbacks"&&(f.callbacks.on=u._callbacksOn.bind(u),f.callbacks.off=u._callbacksOff.bind(u),f.callbacks.once=u._callbacksOnce.bind(u))};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()}}),ue.InternalMsgEmitter.on("onCanUndoStepsUpdate",f=>{t.emitter.emit("canUndoStepsChange",f)}),ue.InternalMsgEmitter.on("onCanRedoStepsUpdate",f=>{t.emitter.emit("canRedoStepsChange",f)});const p={...u,callbacks:u.callbacks()};return t._appliancePlugin=p,t._appliancePlugin}static onCreate(t){t&&Q.currentManager&&(Q.currentManager.bindPlugin(t),t.init(t.displayer))}static async createApplianceMultiPlugin(t,e){try{await t.createInvisiblePlugin(Q,{})}catch{if(!t.isWritable){await t.setWritable(!0);const n=await this.createApplianceMultiPlugin(t,e);return await t.setWritable(!1),n}}let s=t.getInvisiblePlugin(e);return s||(s=await Q.createApplianceMultiPlugin(t,e)),s}get isReplay(){return nt.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),nt.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",Pt),M(Q,"createCurrentManager",(t,e,s)=>{Q.currentManager&&Q.currentManager.destroy();const i={plugin:s,displayer:t.displayer,options:e},n=new ue(i);Q.logger.info("[ApplianceMultiPlugin] refresh ApplianceMultiManager object"),n.setWindowManager(t),Q.currentManager=n});let xo=Q;class sy extends bi{constructor(t,e){super(t,e);M(this,"width",1e3);M(this,"height",1e3);M(this,"dpr",1);M(this,"vDom");M(this,"viewId",vt);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=Kt()),t&&e&&this.canvasContainerRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=Kt(),this.width=t,this.height=e),t&&e&&this.canvasBgRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=Kt(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 me{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 sy(this.control,Tt.InternalMsgEmitter);this.focuedViewId=vt;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}},r=this.control.room&&this.control.room.mainView||this.control.play&&this.control.play.mainView;if(r){const{scale:c,...l}=r.camera;n.cameraOpt={...n.cameraOpt,...l,scale:c===1/0?1:c},this.createMianView({id:vt,displayer:t,focusScenePath:r.focusScenePath||r.scenePath,cameraOpt:n.cameraOpt,viewData:r}),this.focuedView=this.mainView,t.createMainViewDisplayer(this.control.divMainView)}}getViewInitData(t){var s;const e=this.getView(t);if(e){const{width:i,height:n,dpr:r}=e.displayer;(s=this.control.pluginOptions.canvasOpt)!=null&&s.contextType&&($t.defaultScreenCanvasOpt.contextType=this.control.pluginOptions.canvasOpt.contextType);const c={dpr:r,originalPoint:[i/2,n/2],offscreenCanvasOpt:{...$t.defaultScreenCanvasOpt,width:i,height:n},layerOpt:{...$t.defaultLayerOpt,width:i,height:n},cameraOpt:{...$t.defaultCameraOpt,width:i,height:n}};if(e.viewData){const{scale:l,...h}=e.viewData.camera;c.cameraOpt={...c.cameraOpt,...h,scale:l===1/0?1:l}}return c}}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 Gt extends Tt{constructor(t){super(t);M(this,"viewContainerManager");M(this,"divMainView");M(this,"onCameraChange",Ee(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:Gt.InternalMsgEmitter};this.viewContainerManager=new $t(e)}init(){Gt.InternalMsgEmitter.on(q.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 r,c;if((r=this.collector)!=null&&r.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(vt,!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 m of Object.keys(p))m&&f.add(m);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())Tt.InternalMsgEmitter.emit("excludeIds",[...h],l)}),this.room&&(this.roomMember.onUidChangeHook(t=>{var e,s,i,n;if((e=this.collector)!=null&&e.serviceStorage){const r=[];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&&r.push(...d)}}),r.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 B=class B extends nt.InvisiblePlugin{constructor(){super(...arguments);M(this,"onPhaseChanged",t=>{var e;t===nt.RoomPhase.Reconnecting&&((e=B.currentManager)==null||e.setSnapshootData())});M(this,"updateRoomWritable",()=>{var t;(t=B.currentManager)==null||t.onWritableChange(this.displayer.isWritable)});M(this,"roomStateChangeListener",async t=>{var e,s;B.currentManager instanceof Gt&&(t.cameraState&&B.currentManager.onCameraChange(t.cameraState),t.sceneState&&B.currentManager.onSceneChange(t.sceneState.scenePath,vt)),t!=null&&t.roomMembers&&((e=B.currentManager)==null||e.onRoomMembersChange(t.roomMembers)),!(nt.isRoom(this.displayer)&&!this.displayer.isWritable)&&t.memberState&&((s=B.currentManager)==null||s.onMemberChange(t.memberState))})}static async getInstance(t,e){const s=t.callbacks.on,i=t.callbacks.off,n=t.callbacks.once,r=t.cleanCurrentScene.bind(t),c=t.setMemberState.bind(t);e!=null&&e.logger&&(B.logger=e.logger),e.options&&(B.options={...Pt,...e.options});let l=t.getInvisiblePlugin(B.kind);l||(l=await B.createAppliancePlugin(t,B.kind)),t&&l&&B.createCurrentManager(t,B.options,l),l&&B.currentManager&&(B.currentManager.bindPlugin(l),l.init(t)),e!=null&&e.cursorAdapter&&(B.cursorAdapter=e.cursorAdapter),B.effectInstance();const h={displayer:t,currentManager:B.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,_injectTargetObject:void 0,getBoundingRectAsync:async function(p){var y;B.logger.info("[ApplianceSinglePlugin] getBoundingRectAsync");const f=t.getBoundingRect(p),m=await((y=B.currentManager)==null?void 0:y.getBoundingRect(p));return!f.width||!f.height?m:Si(f,m)},screenshotToCanvasAsync:async function(p,f,m,y,N,w){var b;B.logger.info("[ApplianceSinglePlugin] screenshotToCanvasAsync");let I=m,S=y,v=N.scale;I>this.maxScreenshotWidth&&(v=this.maxScreenshotWidth/I*v,I=this.maxScreenshotWidth),S>this.maxScreenshotHeight&&(v=Math.min(this.maxScreenshotHeight/S*v,v),S=this.maxScreenshotHeight),N.scale=v;const T=document.createElement("canvas"),x=T.getContext("2d");T.width=I*(w||1),T.height=S*(w||1),x&&(t.screenshotToCanvas(x,f,I,S,N,w),p.drawImage(T,Math.floor((m-I)/2),Math.floor((y-S)/2),I*(w||1),S*(w||1),0,0,I,S),T.remove()),B.currentManager&&await((b=B.currentManager)==null?void 0:b.screenshotToCanvas(p,f,I,S,N,Math.floor((m-I)/2),Math.floor((y-S)/2)))},scenePreviewAsync:async function(p,f,m,y,N){B.logger.info("[ApplianceSinglePlugin] scenePreviewAsync"),t.scenePreview(p,f,m,y,N);const w=document.createElement("img");w.className="appliance-plugin-fill-scene-snapshot-img",f.append(w),getComputedStyle(f).position||(f.style.position="relative"),B.currentManager&&await B.currentManager.scenePreview(p,w)},fillSceneSnapshotAsync:async function(p,f,m,y,N){var Y,et;B.logger.info("[ApplianceSinglePlugin] fillSceneSnapshotAsync"),f.innerHTML="",t.fillSceneSnapshot(p,f,m,y,N);const w=m||((Y=t.state.cameraState)==null?void 0:Y.width)||0,I=y||((et=t.state.cameraState)==null?void 0:et.height)||0;let S=await this.getBoundingRectAsync(p);S||(S={originX:0,originY:0,width:w,height:I});let v=Math.max(S==null?void 0:S.width,w),T=Math.max(S==null?void 0:S.height,I),x=1;const b=v>w&&Math.min(w/v,x)||x,A=T>I&&Math.min(I/T,x)||x;b<=A?(v=b<1&&w||v,T=Math.floor(T*b)+1,x=b):b>A&&(T=A<1&&I||T,v=Math.floor(v*A)+1,x=A);const O={scale:x,centerX:S.originX+S.width/2,centerY:S.originY+S.height/2},j=document.createElement("canvas"),E=j.getContext("2d");j.width=v,j.height=T,E&&await this.screenshotToCanvasAsync(E,p,v,T,O,devicePixelRatio);const P=document.createElement("img");P.className="appliance-plugin-fill-scene-snapshot-img",P.src=j.toDataURL(),P.onload=()=>{j.remove()},P.onerror=()=>{j.remove(),P.remove()},f.append(P),getComputedStyle(f).position||(f.style.position="relative")},_callbacksOn:function(p,f){B.logger.info(`[ApplianceSinglePlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&nt.isRoom(t)&&t.isWritable?Gt.InternalMsgEmitter.on(p,f):s.call(t.callbacks,p,f)},_callbacksOnce:function(p,f){B.logger.info(`[ApplianceSinglePlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&nt.isRoom(t)&&t.isWritable?Gt.InternalMsgEmitter.on(p,f):n.call(t.callbacks,p,f)},_callbacksOff:function(p,f){B.logger.info(`[ApplianceSinglePlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&nt.isRoom(t)&&t.isWritable?Gt.InternalMsgEmitter.off(p,f):i.call(t.callbacks,p,f)},canRedoSteps(){if(B.logger.info("[ApplianceSinglePlugin] canRedoSteps"),B.currentManager&&nt.isRoom(t)&&!t.disableSerialization){const p=B.currentManager.viewContainerManager.focuedView,f=p==null?void 0:p.focusScenePath;if(p&&f)return p.displayer.commiter.redoStack.filter(m=>m.scenePath===f).length}return 0},canUndoSteps(){if(B.logger.info("[ApplianceSinglePlugin] canUndoSteps"),B.currentManager&&nt.isRoom(t)&&!t.disableSerialization){const p=B.currentManager.viewContainerManager.focuedView,f=p==null?void 0:p.focusScenePath;if(p&&f)return p.displayer.commiter.undoStack.filter(m=>m.scenePath===f).length}return 0},undo:function(){return B.logger.info("[ApplianceSinglePlugin] undo"),B.currentManager&&nt.isRoom(t)&&!t.disableSerialization?B.currentManager.viewContainerManager.undo():0},redo:function(){return B.logger.info("[ApplianceSinglePlugin] redo"),B.currentManager&&nt.isRoom(t)&&!t.disableSerialization?B.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(p){B.logger.info("[ApplianceSinglePlugin] cleanCurrentScene"),B.currentManager&&nt.isRoom(t)&&t.isWritable&&(B.currentManager.cleanCurrentScene(),r.call(t,p))},insertImage:function(p){B.logger.info("[ApplianceSinglePlugin] insertImage"),B.currentManager&&nt.isRoom(t)&&t.isWritable&&B.currentManager.worker.insertImage("mainView",p)},lockImage:function(p,f){B.logger.info("[ApplianceSinglePlugin] lockImage"),B.currentManager&&nt.isRoom(t)&&t.isWritable&&B.currentManager.worker.lockImage("mainView",p,f)},completeImageUpload:function(p,f){B.logger.info("[ApplianceSinglePlugin] completeImageUpload"),B.currentManager&&nt.isRoom(t)&&t.isWritable&&B.currentManager.worker.completeImageUpload("mainView",p,f)},getImagesInformation:function(p){return B.logger.info("[ApplianceSinglePlugin] completeImageUpload"),B.currentManager&&nt.isRoom(t)&&t.isWritable?B.currentManager.worker.getImagesInformation(p):[]},callbacks:()=>({...t.callbacks,on:h._callbacksOn.bind(h),once:h._callbacksOnce.bind(h),off:h._callbacksOff.bind(h)}),destroy(){B.currentManager&&(B.logger.info("[ApplianceSinglePlugin] destroy"),B.currentManager.destroy(),B.currentManager=void 0,B.cursorAdapter=void 0)},setMemberState(p){B.logger.info("[ApplianceSinglePlugin] setMemberState");const f=Object.keys(p);if(nt.isRoom(t)&&t.isWritable){f.includes("currentApplianceName")&&(p.currentApplianceName&&p.currentApplianceName===st.laserPen?(p.currentApplianceName=st.pencil,p.useLaserPen=!0):p.currentApplianceName&&p.currentApplianceName===st.pencil&&(p.useLaserPen=!1)),c(p);return}throw new Error("setMemberState must be called in writable room")},setPerformancePriority(p){B.logger.info("[ApplianceSinglePlugin] setPriority"),B.currentManager&&B.currentManager.setPriority(p)}},u=(p,f)=>{if(B.logger.info(`[ApplianceSinglePlugin] injectMethodToObject ${f}`),typeof p[f]=="function"||typeof p[f]>"u"){p[f]=h[f];return}f==="callbacks"&&(p.callbacks.on=h._callbacksOn.bind(h),p.callbacks.off=h._callbacksOff.bind(h),p.callbacks.once=h._callbacksOnce.bind(h))};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()}});const d={...h,callbacks:h.callbacks()};return t._appliancePlugin=d,t._appliancePlugin}static onCreate(t){t&&B.currentManager&&(B.currentManager.bindPlugin(t),t.init(t.displayer))}static async createAppliancePlugin(t,e){try{await t.createInvisiblePlugin(B,{})}catch{if(!t.isWritable){await t.setWritable(!0);const n=await this.createAppliancePlugin(t,e);return await t.setWritable(!1),n}}let s=t.getInvisiblePlugin(e);return s||(s=await B.createAppliancePlugin(t,e)),s}static effectInstance(){if(B.cursorAdapter){const t=B.cursorAdapter.onAddedCursor;B.cursorAdapter.onAddedCursor=function(e){e.onCursorMemberChanged=s=>{try{s.appliance===st.pencil||s.appliance===st.shape||s.appliance===st.text||s.appliance===st.arrow||s.appliance===st.straight||s.appliance===st.rectangle||s.appliance===st.ellipse||s.appliance===st.eraser?e!=null&&e.divElement&&(e.divElement.style.display="none"):e!=null&&e.divElement&&(e.divElement.style.display="block")}catch{}},t.call(B.cursorAdapter,e)}}}get isReplay(){return nt.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(t){var s,i;const e=t.state;(s=B.currentManager)==null||s.onRoomMembersChange(e.roomMembers),nt.isRoom(t)&&e!=null&&e.memberState&&((i=B.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;B.logger.info("[ApplianceSinglePlugin] passive destroy"),(t=B.currentManager)==null||t.destroy(),B.currentManager=void 0,B.cursorAdapter=void 0}};M(B,"kind","appliance-aids-single-plugin"),M(B,"cursorAdapter"),M(B,"currentManager"),M(B,"logger",{info:console.log,warn:console.warn,error:console.error}),M(B,"options",Pt),M(B,"createCurrentManager",(t,e,s)=>{B.currentManager&&B.currentManager.destroy();const i={plugin:s,displayer:t,options:e},n=new Gt(i);n.init(),B.logger.info("[ApplianceSinglePlugin] refresh ApplianceSingleManager object"),B.currentManager=n});let zo=B;const Me=class Me extends g.Component{constructor(){super(...arguments);M(this,"mainViewRef",null)}componentDidMount(){Me.emiter||(Me.emiter=Gt.InternalMsgEmitter),Me.emiter.emit(q.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(Me,"emiter");let bo=Me;exports.ActiveContainerType=As;exports.ApplianceMultiPlugin=xo;exports.ApplianceNames=st;exports.ApplianceSigleWrapper=bo;exports.ApplianceSinglePlugin=zo;exports.Cursor_Hover_Id=Uf;exports.DefaultAppliancePluginOptions=Pt;exports.ECanvasShowType=Vt;exports.EDataType=V;exports.EMatrixrRelationType=Pe;exports.EOperationType=kt;exports.EPostMessageType=z;exports.ERenderFilterType=Wt;exports.EScaleType=ct;exports.EStrokeType=_;exports.EToolsKey=C;exports.ElayerType=ie;exports.EmitEventType=R;exports.EventMessageType=be;exports.EvevtWorkState=D;exports.EvevtWorkType=Es;exports.InternalMsgEmitterType=q;exports.Main_View_Id=vt;exports.ShapeType=Ot;exports.Storage_Selector_key=H;exports.Storage_Splitter=Ut;exports.Storage_ViewId_ALL=Ve;exports.Task_Time_Interval=Bf;exports.ViewContainerManager=me;exports.checkOp=Af;exports.cloneDeep=qt;exports.computRect=ut;exports.fullWorker=Oi;exports.getRectMatrixrRelation=Of;exports.getShapeInstance=Ni;exports.getShapeTools=vi;exports.isBoolean=pe;exports.isEqual=de;exports.isIntersect=Ae;exports.isIntersectForPoint=ki;exports.isNumber=Ht;exports.isSet=Md;exports.subWorker=Ri;exports.throttle=Ee;exports.transformToNormalData=ke;exports.transformToSerializableData=Lt;