@netless/appliance-plugin 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/cdn.js +1 -1
- package/cdn/{fullWorker-C9GaK9.js → fullWorker-CjGKnN.js} +2 -2
- package/cdn/{subWorker-BqoFdX.js → subWorker-DUJqv_.js} +2 -2
- package/dist/appliance-plugin.js +1 -1
- package/dist/appliance-plugin.mjs +1 -1
- package/dist/fullWorker.js +2 -2
- package/dist/{index-D8qYooNV.js → index-C29o_HLi.js} +1 -1
- package/dist/{index-BJIMFi3a.mjs → index-C4KNxHht.mjs} +1 -1
- package/dist/{index-C3iivLNQ.mjs → index-CIJP6_Qj.mjs} +21 -32
- package/dist/index-DmfRoAiB.js +1 -0
- package/dist/subWorker.js +2 -2
- package/package.json +1 -1
- package/dist/index-A33g679O.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var Pi=Object.defineProperty;var ji=(r,s,t)=>s in r?Pi(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t;var M=(r,s,t)=>ji(r,typeof s!="symbol"?s+"":s,t);const st=require("white-web-sdk"),lt=require("spritejs"),Ps=require("lz-string"),Lo=require("lineclip"),js=require("eventemitter2"),O=require("lodash"),bo=require("react-dom"),g=require("react"),Me=require("react-draggable"),Di=require("re-resizable"),Ei="/fullWorker.js",Ai="/subWorker.js";var et=(r=>(r.selector="selector",r.clicker="clicker",r.laserPointer="laserPointer",r.pencil="pencil",r.rectangle="rectangle",r.ellipse="ellipse",r.shape="shape",r.eraser="eraser",r.pencilEraser="pencilEraser",r.text="text",r.straight="straight",r.arrow="arrow",r.hand="hand",r.laserPen="laserPen",r))(et||{}),X=(r=>(r.Normal="Normal",r.Stroke="Stroke",r.Dotted="Dotted",r.LongDotted="LongDotted",r))(X||{}),Dt=(r=>(r.Triangle="triangle",r.Rhombus="rhombus",r.Pentagram="pentagram",r.SpeechBalloon="speechBalloon",r.Star="star",r.Polygon="polygon",r))(Dt||{}),R=(r=>(r.None="None",r.ShowFloatBar="ShowFloatBar",r.ZIndexFloatBar="ZIndexFloatBar",r.DeleteNode="DeleteNode",r.CopyNode="CopyNode",r.ZIndexActive="ZIndexActive",r.ZIndexNode="ZIndexNode",r.RotateNode="RotateNode",r.SetColorNode="SetColorNode",r.TranslateNode="TranslateNode",r.ScaleNode="ScaleNode",r.OriginalEvent="OriginalEvent",r.CreateScene="CreateScene",r.ActiveCursor="ActiveCursor",r.MoveCursor="MoveCursor",r.CommandEditor="CommandEditor",r.SetEditorData="SetEditorData",r.SetFontStyle="SetFontStyle",r.SetPoint="SetPoint",r.SetLock="SetLock",r.SetShapeOpt="SetShapeOpt",r.CameraChange="CameraChange",r.ActiveMethod="ActiveMethod",r))(R||{}),Z=(r=>(r.DisplayState="DisplayState",r.MainEngine="MainEngine",r.Cursor="Cursor",r.BindMainView="BindMainView",r))(Z||{}),Ds=(r=>(r[r.MainView=0]="MainView",r[r.Plugin=1]="Plugin",r[r.Both=2]="Both",r))(Ds||{}),C=(r=>(r[r.Pencil=1]="Pencil",r[r.Eraser=2]="Eraser",r[r.PencilEraser=3]="PencilEraser",r[r.BitMapEraser=4]="BitMapEraser",r[r.Selector=5]="Selector",r[r.Clicker=6]="Clicker",r[r.Arrow=7]="Arrow",r[r.Hand=8]="Hand",r[r.LaserPen=9]="LaserPen",r[r.Text=10]="Text",r[r.Straight=11]="Straight",r[r.Rectangle=12]="Rectangle",r[r.Ellipse=13]="Ellipse",r[r.Star=14]="Star",r[r.Triangle=15]="Triangle",r[r.Rhombus=16]="Rhombus",r[r.Polygon=17]="Polygon",r[r.SpeechBalloon=18]="SpeechBalloon",r[r.Image=19]="Image",r))(C||{}),F=(r=>(r[r.Local=1]="Local",r[r.Service=2]="Service",r[r.Worker=3]="Worker",r))(F||{}),b=(r=>(r[r.Pending=0]="Pending",r[r.Start=1]="Start",r[r.Doing=2]="Doing",r[r.Done=3]="Done",r[r.Unwritable=4]="Unwritable",r))(b||{}),z=(r=>(r[r.None=0]="None",r[r.Init=1]="Init",r[r.UpdateCamera=2]="UpdateCamera",r[r.UpdateTools=3]="UpdateTools",r[r.CreateWork=4]="CreateWork",r[r.DrawWork=5]="DrawWork",r[r.FullWork=6]="FullWork",r[r.UpdateNode=7]="UpdateNode",r[r.RemoveNode=8]="RemoveNode",r[r.Clear=9]="Clear",r[r.Select=10]="Select",r[r.Destroy=11]="Destroy",r[r.Snapshot=12]="Snapshot",r[r.BoundingBox=13]="BoundingBox",r[r.Cursor=14]="Cursor",r[r.TextUpdate=15]="TextUpdate",r[r.GetTextActive=16]="GetTextActive",r[r.TasksQueue=17]="TasksQueue",r[r.CursorHover=18]="CursorHover",r[r.CursorBlur=19]="CursorBlur",r[r.Console=20]="Console",r[r.PriorityWorker=21]="PriorityWorker",r[r.PriorityMainThreadWorker=22]="PriorityMainThreadWorker",r[r.GetImageBitMap=23]="GetImageBitMap",r))(z||{}),_e=(r=>(r.Webgl2="webgl2",r.Webgl="webgl",r.Canvas2d="2d",r))(_e||{}),Yt=(r=>(r[r.None=0]="None",r[r.Bg=1]="Bg",r[r.ServiceFloat=2]="ServiceFloat",r[r.Float=3]="Float",r[r.TopFloat=4]="TopFloat",r))(Yt||{}),Ce=(r=>(r[r.Cursor=1]="Cursor",r[r.TextCreate=2]="TextCreate",r))(Ce||{}),oe=(r=>(r[r.Top=1]="Top",r[r.Bottom=2]="Bottom",r))(oe||{}),ct=(r=>(r[r.none=1]="none",r[r.all=2]="all",r[r.both=3]="both",r[r.proportional=4]="proportional",r))(ct||{}),Es=(r=>(r[r.Pending=0]="Pending",r[r.Start=1]="Start",r[r.Doing=2]="Doing",r[r.Done=3]="Done",r[r.Unwritable=4]="Unwritable",r))(Es||{}),ke=(r=>(r[r.inside=0]="inside",r[r.outside=1]="outside",r[r.intersect=2]="intersect",r))(ke||{});const Oi={linear:r=>r,easeInQuad:r=>r*r,easeOutQuad:r=>r*(2-r),easeInOutQuad:r=>r<.5?2*r*r:-1+(4-2*r)*r,easeInCubic:r=>r*r*r,easeOutCubic:r=>--r*r*r+1,easeInOutCubic:r=>r<.5?4*r*r*r:(r-1)*(2*r-2)*(2*r-2)+1,easeInQuart:r=>r*r*r*r,easeOutQuart:r=>1- --r*r*r*r,easeInOutQuart:r=>r<.5?8*r*r*r*r:1-8*--r*r*r*r,easeInQuint:r=>r*r*r*r*r,easeOutQuint:r=>1+--r*r*r*r*r,easeInOutQuint:r=>r<.5?16*r*r*r*r*r:1+16*--r*r*r*r*r,easeInSine:r=>1-Math.cos(r*Math.PI/2),easeOutSine:r=>Math.sin(r*Math.PI/2),easeInOutSine:r=>-(Math.cos(Math.PI*r)-1)/2,easeInExpo:r=>r<=0?0:Math.pow(2,10*r-10),easeOutExpo:r=>r>=1?1:1-Math.pow(2,-10*r),easeInOutExpo:r=>r<=0?0:r>=1?1:r<.5?Math.pow(2,20*r-10)/2:(2-Math.pow(2,-20*r+10))/2};class k{constructor(s=0,t=0,e=1){this.x=s,this.y=t,this.z=e}get XY(){return[this.x,this.y]}setz(s){return this.z=s,this}setXY(s=this.x,t=this.y){return this.x=s,this.y=t,this}set(s=this.x,t=this.y,e=this.z){return this.x=s,this.y=t,this.z=e,this}setTo({x:s=0,y:t=0,z:e=1}){return this.x=s,this.y=t,this.z=e,this}rot(s){if(s===0)return this;const{x:t,y:e}=this,o=Math.sin(s),n=Math.cos(s);return this.x=t*n-e*o,this.y=t*o+e*n,this}rotWith(s,t){if(t===0)return this;const e=this.x-s.x,o=this.y-s.y,n=Math.sin(t),i=Math.cos(t);return this.x=s.x+(e*i-o*n),this.y=s.y+(e*n+o*i),this}clone(){const{x:s,y:t,z:e}=this;return new k(s,t,e)}sub(s){return this.x-=s.x,this.y-=s.y,this}subXY(s,t){return this.x-=s,this.y-=t,this}subScalar(s){return this.x-=s,this.y-=s,this}add(s){return this.x+=s.x,this.y+=s.y,this}addXY(s,t){return this.x+=s,this.y+=t,this}addScalar(s){return this.x+=s,this.y+=s,this}clamp(s,t){return this.x=Math.max(this.x,s),this.y=Math.max(this.y,s),t!==void 0&&(this.x=Math.min(this.x,t),this.y=Math.min(this.y,t)),this}div(s){return this.x/=s,this.y/=s,this}divV(s){return this.x/=s.x,this.y/=s.y,this}mul(s){return this.x*=s,this.y*=s,this}mulV(s){return this.x*=s.x,this.y*=s.y,this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this}nudge(s,t){const e=k.Tan(s,this);return this.add(e.mul(t))}neg(){return this.x*=-1,this.y*=-1,this}cross(s){return this.x=this.y*s.z-this.z*s.y,this.y=this.z*s.x-this.x*s.z,this}dpr(s){return k.Dpr(this,s)}cpr(s){return k.Cpr(this,s)}len2(){return k.Len2(this)}len(){return k.Len(this)}pry(s){return k.Pry(this,s)}per(){const{x:s,y:t}=this;return this.x=t,this.y=-s,this}uni(){return k.Uni(this)}tan(s){return k.Tan(this,s)}dist(s){return k.Dist(this,s)}distanceToLineSegment(s,t){return k.DistanceToLineSegment(s,t,this)}slope(s){return k.Slope(this,s)}snapToGrid(s){return this.x=Math.round(this.x/s)*s,this.y=Math.round(this.y/s)*s,this}angle(s){return k.Angle(this,s)}toAngle(){return k.ToAngle(this)}lrp(s,t){return this.x=this.x+(s.x-this.x)*t,this.y=this.y+(s.y-this.y)*t,this}equals(s,t){return k.Equals(this,s,t)}equalsXY(s,t){return k.EqualsXY(this,s,t)}norm(){const s=this.len();return this.x=s===0?0:this.x/s,this.y=s===0?0:this.y/s,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(s,t){return new k(s.x+t.x,s.y+t.y)}static AddXY(s,t,e){return new k(s.x+t,s.y+e)}static Sub(s,t){return new k(s.x-t.x,s.y-t.y)}static SubXY(s,t,e){return new k(s.x-t,s.y-e)}static AddScalar(s,t){return new k(s.x+t,s.y+t)}static SubScalar(s,t){return new k(s.x-t,s.y-t)}static Div(s,t){return new k(s.x/t,s.y/t)}static Mul(s,t){return new k(s.x*t,s.y*t)}static DivV(s,t){return new k(s.x/t.x,s.y/t.y)}static MulV(s,t){return new k(s.x*t.x,s.y*t.y)}static Neg(s){return new k(-s.x,-s.y)}static Per(s){return new k(s.y,-s.x)}static Dist2(s,t){return k.Sub(s,t).len2()}static Abs(s){return new k(Math.abs(s.x),Math.abs(s.y))}static Dist(s,t){return Math.hypot(s.y-t.y,s.x-t.x)}static Dpr(s,t){return s.x*t.x+s.y*t.y}static Cross(s,t){return new k(s.y*t.z-s.z*t.y,s.z*t.x-s.x*t.z)}static Cpr(s,t){return s.x*t.y-t.x*s.y}static Len2(s){return s.x*s.x+s.y*s.y}static Len(s){return Math.hypot(s.x,s.y)}static Pry(s,t){return k.Dpr(s,t)/k.Len(t)}static Uni(s){return k.Div(s,k.Len(s))}static Tan(s,t){return k.Uni(k.Sub(s,t))}static Min(s,t){return new k(Math.min(s.x,t.x),Math.min(s.y,t.y))}static Max(s,t){return new k(Math.max(s.x,t.x),Math.max(s.y,t.y))}static From(s){return new k().add(s)}static FromArray(s){return new k(s[0],s[1])}static Rot(s,t=0){const e=Math.sin(t),o=Math.cos(t);return new k(s.x*o-s.y*e,s.x*e+s.y*o)}static RotWith(s,t,e){const o=s.x-t.x,n=s.y-t.y,i=Math.sin(e),a=Math.cos(e);return new k(t.x+(o*a-n*i),t.y+(o*i+n*a))}static NearestPointOnLineThroughPoint(s,t,e){return k.Mul(t,k.Sub(e,s).pry(t)).add(s)}static NearestPointOnLineSegment(s,t,e,o=!0){const n=k.Tan(t,s),i=k.Add(s,k.Mul(n,k.Sub(e,s).pry(n)));if(o){if(i.x<Math.min(s.x,t.x))return k.Cast(s.x<t.x?s:t);if(i.x>Math.max(s.x,t.x))return k.Cast(s.x>t.x?s:t);if(i.y<Math.min(s.y,t.y))return k.Cast(s.y<t.y?s:t);if(i.y>Math.max(s.y,t.y))return k.Cast(s.y>t.y?s:t)}return i}static DistanceToLineThroughPoint(s,t,e){return k.Dist(e,k.NearestPointOnLineThroughPoint(s,t,e))}static DistanceToLineSegment(s,t,e,o=!0){return k.Dist(e,k.NearestPointOnLineSegment(s,t,e,o))}static Snap(s,t=1){return new k(Math.round(s.x/t)*t,Math.round(s.y/t)*t)}static Cast(s){return s instanceof k?s:k.From(s)}static Slope(s,t){return s.x===t.y?NaN:(s.y-t.y)/(s.x-t.x)}static Angle(s,t){return Math.atan2(t.y-s.y,t.x-s.x)}static Lrp(s,t,e){return k.Sub(t,s).mul(e).add(s)}static Med(s,t){return new k((s.x+t.x)/2,(s.y+t.y)/2)}static Equals(s,t,e=1e-4){return Math.abs(s.x-t.x)<e&&Math.abs(s.y-t.y)<e}static EqualsXY(s,t,e){return s.x===t&&s.y===e}static EqualsXYZ(s,t,e=1e-4){return k.Equals(s,t,e)&&Math.abs((s.z||0)-(t.z||0))<e}static Clockwise(s,t,e){return(e.x-s.x)*(t.y-s.y)-(t.x-s.x)*(e.y-s.y)<0}static Rescale(s,t){const e=k.Len(s);return new k(t*s.x/e,t*s.y/e)}static ScaleWithOrigin(s,t,e){return k.Sub(s,e).mul(t).add(e)}static ScaleWOrigin(s,t,e){return k.Sub(s,e).mulV(t).add(e)}static ToFixed(s,t=2){return new k(+s.x.toFixed(t),+s.y.toFixed(t),+s.z.toFixed(t))}static Nudge(s,t,e){return k.Add(s,k.Tan(t,s).mul(e))}static ToString(s){return`${s.x}, ${s.y}`}static ToAngle(s){let t=Math.atan2(s.y,s.x);return t<0&&(t+=Math.PI*2),t}static FromAngle(s,t=1){return new k(Math.cos(s)*t,Math.sin(s)*t)}static ToArray(s){return[s.x,s.y,s.z]}static ToJson(s){const{x:t,y:e,z:o}=s;return{x:t,y:e,z:o}}static Average(s){const t=s.length,e=new k(0,0);for(let o=0;o<t;o++)e.add(s[o]);return e.div(t)}static Clamp(s,t,e){return e===void 0?new k(Math.min(Math.max(s.x,t)),Math.min(Math.max(s.y,t))):new k(Math.min(Math.max(s.x,t),e),Math.min(Math.max(s.y,t),e))}static PointsBetween(s,t,e=6){const o=[];for(let n=0;n<e;n++){const i=Oi.easeInQuad(n/(e-1)),a=k.Lrp(s,t,i);a.z=Math.min(1,.5+Math.abs(.5-Ri(i))*.65),o.push(a)}return o}static SnapToGrid(s,t=8){return new k(Math.round(s.x/t)*t,Math.round(s.y/t)*t)}}const Ri=r=>r<.5?2*r*r:-1+(4-2*r)*r;class B extends k{constructor(s=0,t=0,e=0,o={x:0,y:0},n=0,i=0){super(s,t,e),this.x=s,this.y=t,this.z=e,this.v=o,this.t=n,this.a=i}get timestamp(){return this.t}get pressure(){return this.z}get angleNum(){return this.a}get XY(){return[this.x,this.y]}setA(s){this.a=s}setT(s){this.t=s}setv(s){return this.v={x:s.x,y:s.y},this}set(s=this.x,t=this.y,e=this.z,o=this.v,n=this.t,i=this.a){return this.x=s,this.y=t,this.z=e,this.v=o,this.t=n,this.a=i,this}clone(){const{x:s,y:t,z:e,v:o,t:n,a:i}=this,a={x:o.x,y:o.y};return new B(s,t,e,a,n,i)}distance(s){return B.GetDistance(this,s)}isNear(s,t){return B.IsNear(this,s,t)}getAngleByPoints(s,t){return B.GetAngleByPoints(s,this,t)}static Sub(s,t){return new B(s.x-t.x,s.y-t.y)}static Add(s,t){return new B(s.x+t.x,s.y+t.y)}static GetDistance(s,t){return B.Len(s.clone().sub(t))}static GetAngleByPoints(s,t,e){const o=t.x-s.x,n=e.x-t.x,i=t.y-s.y,a=e.y-t.y;let c=0;const l=Math.sqrt(o*o+i*i),h=Math.sqrt(n*n+a*a);if(l&&h){const u=o*n+i*a;c=Math.acos(u/(l*h)),c=c/Math.PI*180;let d=o*a-i*n;d=d>0?1:-1,c=180+d*c}return c}static IsNear(s,t,e){return B.Len(s.clone().sub(t))<e}static RotWith(s,t,e,o=2){const n=s.x-t.x,i=s.y-t.y,a=Math.sin(e),c=Math.cos(e),l=Math.pow(10,o),h=Math.floor((t.x+(n*c-i*a))*l)/l,u=Math.floor((t.y+(n*a+i*c))*l)/l;return new B(h,u)}static GetDotStroke(s,t,e=16){const o=new k(1,1),n=Math.PI+.001,i=B.Add(s,B.Sub(s,o).uni().per().mul(-t)),a=[];for(let c=1/e,l=c;l<=1;l+=c)a.push(B.RotWith(i,s,n*2*l));return a}static GetSemicircleStroke(s,t,e=-1,o=8){const n=e*(Math.PI+.001),i=[];for(let a=1/o,c=a;c<=1;c+=a)i.push(B.RotWith(t,s,n*c));return i}}var Ee=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function je(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Yi=typeof Ee=="object"&&Ee&&Ee.Object===Object&&Ee,As=Yi,Wi=As,Ui=typeof self=="object"&&self&&self.Object===Object&&self,Bi=Wi||Ui||Function("return this")(),Rt=Bi,Fi=Rt,Hi=Fi.Symbol,to=Hi,Qo=to,Os=Object.prototype,Qi=Os.hasOwnProperty,Vi=Os.toString,Se=Qo?Qo.toStringTag:void 0;function $i(r){var s=Qi.call(r,Se),t=r[Se];try{r[Se]=void 0;var e=!0}catch{}var o=Vi.call(r);return e&&(s?r[Se]=t:delete r[Se]),o}var Gi=$i,Zi=Object.prototype,qi=Zi.toString;function Ji(r){return qi.call(r)}var Xi=Ji,Vo=to,Ki=Gi,_i=Xi,tn="[object Null]",en="[object Undefined]",$o=Vo?Vo.toStringTag:void 0;function on(r){return r==null?r===void 0?en:tn:$o&&$o in Object(r)?Ki(r):_i(r)}var se=on;function sn(r){return r!=null&&typeof r=="object"}var Qt=sn,nn=se,rn=Qt,an="[object Number]";function cn(r){return typeof r=="number"||rn(r)&&nn(r)==an}var ln=cn;const Wt=je(ln);function hn(){this.__data__=[],this.size=0}var un=hn;function dn(r,s){return r===s||r!==r&&s!==s}var Po=dn,pn=Po;function fn(r,s){for(var t=r.length;t--;)if(pn(r[t][0],s))return t;return-1}var eo=fn,gn=eo,Mn=Array.prototype,yn=Mn.splice;function mn(r){var s=this.__data__,t=gn(s,r);if(t<0)return!1;var e=s.length-1;return t==e?s.pop():yn.call(s,t,1),--this.size,!0}var wn=mn,In=eo;function vn(r){var s=this.__data__,t=In(s,r);return t<0?void 0:s[t][1]}var Nn=vn,Tn=eo;function Sn(r){return Tn(this.__data__,r)>-1}var Cn=Sn,kn=eo;function xn(r,s){var t=this.__data__,e=kn(t,r);return e<0?(++this.size,t.push([r,s])):t[e][1]=s,this}var zn=xn,Ln=un,bn=wn,Pn=Nn,jn=Cn,Dn=zn;function ye(r){var s=-1,t=r==null?0:r.length;for(this.clear();++s<t;){var e=r[s];this.set(e[0],e[1])}}ye.prototype.clear=Ln;ye.prototype.delete=bn;ye.prototype.get=Pn;ye.prototype.has=jn;ye.prototype.set=Dn;var oo=ye,En=oo;function An(){this.__data__=new En,this.size=0}var On=An;function Rn(r){var s=this.__data__,t=s.delete(r);return this.size=s.size,t}var Yn=Rn;function Wn(r){return this.__data__.get(r)}var Un=Wn;function Bn(r){return this.__data__.has(r)}var Fn=Bn;function Hn(r){var s=typeof r;return r!=null&&(s=="object"||s=="function")}var Xt=Hn,Qn=se,Vn=Xt,$n="[object AsyncFunction]",Gn="[object Function]",Zn="[object GeneratorFunction]",qn="[object Proxy]";function Jn(r){if(!Vn(r))return!1;var s=Qn(r);return s==Gn||s==Zn||s==$n||s==qn}var Rs=Jn,Xn=Rt,Kn=Xn["__core-js_shared__"],_n=Kn,po=_n,Go=function(){var r=/[^.]+$/.exec(po&&po.keys&&po.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function tr(r){return!!Go&&Go in r}var er=tr,or=Function.prototype,sr=or.toString;function ir(r){if(r!=null){try{return sr.call(r)}catch{}try{return r+""}catch{}}return""}var Ys=ir,nr=Rs,rr=er,ar=Xt,cr=Ys,lr=/[\\^$.*+?()[\]{}|]/g,hr=/^\[object .+?Constructor\]$/,ur=Function.prototype,dr=Object.prototype,pr=ur.toString,fr=dr.hasOwnProperty,gr=RegExp("^"+pr.call(fr).replace(lr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Mr(r){if(!ar(r)||rr(r))return!1;var s=nr(r)?gr:hr;return s.test(cr(r))}var yr=Mr;function mr(r,s){return r==null?void 0:r[s]}var wr=mr,Ir=yr,vr=wr;function Nr(r,s){var t=vr(r,s);return Ir(t)?t:void 0}var ie=Nr,Tr=ie,Sr=Rt,Cr=Tr(Sr,"Map"),jo=Cr,kr=ie,xr=kr(Object,"create"),so=xr,Zo=so;function zr(){this.__data__=Zo?Zo(null):{},this.size=0}var Lr=zr;function br(r){var s=this.has(r)&&delete this.__data__[r];return this.size-=s?1:0,s}var Pr=br,jr=so,Dr="__lodash_hash_undefined__",Er=Object.prototype,Ar=Er.hasOwnProperty;function Or(r){var s=this.__data__;if(jr){var t=s[r];return t===Dr?void 0:t}return Ar.call(s,r)?s[r]:void 0}var Rr=Or,Yr=so,Wr=Object.prototype,Ur=Wr.hasOwnProperty;function Br(r){var s=this.__data__;return Yr?s[r]!==void 0:Ur.call(s,r)}var Fr=Br,Hr=so,Qr="__lodash_hash_undefined__";function Vr(r,s){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=Hr&&s===void 0?Qr:s,this}var $r=Vr,Gr=Lr,Zr=Pr,qr=Rr,Jr=Fr,Xr=$r;function me(r){var s=-1,t=r==null?0:r.length;for(this.clear();++s<t;){var e=r[s];this.set(e[0],e[1])}}me.prototype.clear=Gr;me.prototype.delete=Zr;me.prototype.get=qr;me.prototype.has=Jr;me.prototype.set=Xr;var Kr=me,qo=Kr,_r=oo,ta=jo;function ea(){this.size=0,this.__data__={hash:new qo,map:new(ta||_r),string:new qo}}var oa=ea;function sa(r){var s=typeof r;return s=="string"||s=="number"||s=="symbol"||s=="boolean"?r!=="__proto__":r===null}var ia=sa,na=ia;function ra(r,s){var t=r.__data__;return na(s)?t[typeof s=="string"?"string":"hash"]:t.map}var io=ra,aa=io;function ca(r){var s=aa(this,r).delete(r);return this.size-=s?1:0,s}var la=ca,ha=io;function ua(r){return ha(this,r).get(r)}var da=ua,pa=io;function fa(r){return pa(this,r).has(r)}var ga=fa,Ma=io;function ya(r,s){var t=Ma(this,r),e=t.size;return t.set(r,s),this.size+=t.size==e?0:1,this}var ma=ya,wa=oa,Ia=la,va=da,Na=ga,Ta=ma;function we(r){var s=-1,t=r==null?0:r.length;for(this.clear();++s<t;){var e=r[s];this.set(e[0],e[1])}}we.prototype.clear=wa;we.prototype.delete=Ia;we.prototype.get=va;we.prototype.has=Na;we.prototype.set=Ta;var Ws=we,Sa=oo,Ca=jo,ka=Ws,xa=200;function za(r,s){var t=this.__data__;if(t instanceof Sa){var e=t.__data__;if(!Ca||e.length<xa-1)return e.push([r,s]),this.size=++t.size,this;t=this.__data__=new ka(e)}return t.set(r,s),this.size=t.size,this}var La=za,ba=oo,Pa=On,ja=Yn,Da=Un,Ea=Fn,Aa=La;function Ie(r){var s=this.__data__=new ba(r);this.size=s.size}Ie.prototype.clear=Pa;Ie.prototype.delete=ja;Ie.prototype.get=Da;Ie.prototype.has=Ea;Ie.prototype.set=Aa;var Us=Ie;function Oa(r,s){for(var t=-1,e=r==null?0:r.length;++t<e&&s(r[t],t,r)!==!1;);return r}var Ra=Oa,Ya=ie,Wa=function(){try{var r=Ya(Object,"defineProperty");return r({},"",{}),r}catch{}}(),Ua=Wa,Jo=Ua;function Ba(r,s,t){s=="__proto__"&&Jo?Jo(r,s,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[s]=t}var Bs=Ba,Fa=Bs,Ha=Po,Qa=Object.prototype,Va=Qa.hasOwnProperty;function $a(r,s,t){var e=r[s];(!(Va.call(r,s)&&Ha(e,t))||t===void 0&&!(s in r))&&Fa(r,s,t)}var Fs=$a,Ga=Fs,Za=Bs;function qa(r,s,t,e){var o=!t;t||(t={});for(var n=-1,i=s.length;++n<i;){var a=s[n],c=e?e(t[a],r[a],a,t,r):void 0;c===void 0&&(c=r[a]),o?Za(t,a,c):Ga(t,a,c)}return t}var no=qa;function Ja(r,s){for(var t=-1,e=Array(r);++t<r;)e[t]=s(t);return e}var Xa=Ja,Ka=se,_a=Qt,tc="[object Arguments]";function ec(r){return _a(r)&&Ka(r)==tc}var oc=ec,Xo=oc,sc=Qt,Hs=Object.prototype,ic=Hs.hasOwnProperty,nc=Hs.propertyIsEnumerable,rc=Xo(function(){return arguments}())?Xo:function(r){return sc(r)&&ic.call(r,"callee")&&!nc.call(r,"callee")},ac=rc,cc=Array.isArray,ro=cc,Be={exports:{}};function lc(){return!1}var hc=lc;Be.exports;(function(r,s){var t=Rt,e=hc,o=s&&!s.nodeType&&s,n=o&&!0&&r&&!r.nodeType&&r,i=n&&n.exports===o,a=i?t.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||e;r.exports=l})(Be,Be.exports);var Do=Be.exports,uc=9007199254740991,dc=/^(?:0|[1-9]\d*)$/;function pc(r,s){var t=typeof r;return s=s??uc,!!s&&(t=="number"||t!="symbol"&&dc.test(r))&&r>-1&&r%1==0&&r<s}var fc=pc,gc=9007199254740991;function Mc(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=gc}var Qs=Mc,yc=se,mc=Qs,wc=Qt,Ic="[object Arguments]",vc="[object Array]",Nc="[object Boolean]",Tc="[object Date]",Sc="[object Error]",Cc="[object Function]",kc="[object Map]",xc="[object Number]",zc="[object Object]",Lc="[object RegExp]",bc="[object Set]",Pc="[object String]",jc="[object WeakMap]",Dc="[object ArrayBuffer]",Ec="[object DataView]",Ac="[object Float32Array]",Oc="[object Float64Array]",Rc="[object Int8Array]",Yc="[object Int16Array]",Wc="[object Int32Array]",Uc="[object Uint8Array]",Bc="[object Uint8ClampedArray]",Fc="[object Uint16Array]",Hc="[object Uint32Array]",ft={};ft[Ac]=ft[Oc]=ft[Rc]=ft[Yc]=ft[Wc]=ft[Uc]=ft[Bc]=ft[Fc]=ft[Hc]=!0;ft[Ic]=ft[vc]=ft[Dc]=ft[Nc]=ft[Ec]=ft[Tc]=ft[Sc]=ft[Cc]=ft[kc]=ft[xc]=ft[zc]=ft[Lc]=ft[bc]=ft[Pc]=ft[jc]=!1;function Qc(r){return wc(r)&&mc(r.length)&&!!ft[yc(r)]}var Vc=Qc;function $c(r){return function(s){return r(s)}}var Eo=$c,Fe={exports:{}};Fe.exports;(function(r,s){var t=As,e=s&&!s.nodeType&&s,o=e&&!0&&r&&!r.nodeType&&r,n=o&&o.exports===e,i=n&&t.process,a=function(){try{var c=o&&o.require&&o.require("util").types;return c||i&&i.binding&&i.binding("util")}catch{}}();r.exports=a})(Fe,Fe.exports);var Ao=Fe.exports,Gc=Vc,Zc=Eo,Ko=Ao,_o=Ko&&Ko.isTypedArray,qc=_o?Zc(_o):Gc,Vs=qc,Jc=Xa,Xc=ac,Kc=ro,_c=Do,tl=fc,el=Vs,ol=Object.prototype,sl=ol.hasOwnProperty;function il(r,s){var t=Kc(r),e=!t&&Xc(r),o=!t&&!e&&_c(r),n=!t&&!e&&!o&&el(r),i=t||e||o||n,a=i?Jc(r.length,String):[],c=a.length;for(var l in r)(s||sl.call(r,l))&&!(i&&(l=="length"||o&&(l=="offset"||l=="parent")||n&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||tl(l,c)))&&a.push(l);return a}var $s=il,nl=Object.prototype;function rl(r){var s=r&&r.constructor,t=typeof s=="function"&&s.prototype||nl;return r===t}var Oo=rl;function al(r,s){return function(t){return r(s(t))}}var Gs=al,cl=Gs,ll=cl(Object.keys,Object),hl=ll,ul=Oo,dl=hl,pl=Object.prototype,fl=pl.hasOwnProperty;function gl(r){if(!ul(r))return dl(r);var s=[];for(var t in Object(r))fl.call(r,t)&&t!="constructor"&&s.push(t);return s}var Ml=gl,yl=Rs,ml=Qs;function wl(r){return r!=null&&ml(r.length)&&!yl(r)}var Zs=wl,Il=$s,vl=Ml,Nl=Zs;function Tl(r){return Nl(r)?Il(r):vl(r)}var Ro=Tl,Sl=no,Cl=Ro;function kl(r,s){return r&&Sl(s,Cl(s),r)}var xl=kl;function zl(r){var s=[];if(r!=null)for(var t in Object(r))s.push(t);return s}var Ll=zl,bl=Xt,Pl=Oo,jl=Ll,Dl=Object.prototype,El=Dl.hasOwnProperty;function Al(r){if(!bl(r))return jl(r);var s=Pl(r),t=[];for(var e in r)e=="constructor"&&(s||!El.call(r,e))||t.push(e);return t}var Ol=Al,Rl=$s,Yl=Ol,Wl=Zs;function Ul(r){return Wl(r)?Rl(r,!0):Yl(r)}var Yo=Ul,Bl=no,Fl=Yo;function Hl(r,s){return r&&Bl(s,Fl(s),r)}var Ql=Hl,He={exports:{}};He.exports;(function(r,s){var t=Rt,e=s&&!s.nodeType&&s,o=e&&!0&&r&&!r.nodeType&&r,n=o&&o.exports===e,i=n?t.Buffer:void 0,a=i?i.allocUnsafe:void 0;function c(l,h){if(h)return l.slice();var u=l.length,d=a?a(u):new l.constructor(u);return l.copy(d),d}r.exports=c})(He,He.exports);var Vl=He.exports;function $l(r,s){var t=-1,e=r.length;for(s||(s=Array(e));++t<e;)s[t]=r[t];return s}var Gl=$l;function Zl(r,s){for(var t=-1,e=r==null?0:r.length,o=0,n=[];++t<e;){var i=r[t];s(i,t,r)&&(n[o++]=i)}return n}var ql=Zl;function Jl(){return[]}var qs=Jl,Xl=ql,Kl=qs,_l=Object.prototype,th=_l.propertyIsEnumerable,ts=Object.getOwnPropertySymbols,eh=ts?function(r){return r==null?[]:(r=Object(r),Xl(ts(r),function(s){return th.call(r,s)}))}:Kl,Wo=eh,oh=no,sh=Wo;function ih(r,s){return oh(r,sh(r),s)}var nh=ih;function rh(r,s){for(var t=-1,e=s.length,o=r.length;++t<e;)r[o+t]=s[t];return r}var Js=rh,ah=Gs,ch=ah(Object.getPrototypeOf,Object),Xs=ch,lh=Js,hh=Xs,uh=Wo,dh=qs,ph=Object.getOwnPropertySymbols,fh=ph?function(r){for(var s=[];r;)lh(s,uh(r)),r=hh(r);return s}:dh,Ks=fh,gh=no,Mh=Ks;function yh(r,s){return gh(r,Mh(r),s)}var mh=yh,wh=Js,Ih=ro;function vh(r,s,t){var e=s(r);return Ih(r)?e:wh(e,t(r))}var _s=vh,Nh=_s,Th=Wo,Sh=Ro;function Ch(r){return Nh(r,Sh,Th)}var ti=Ch,kh=_s,xh=Ks,zh=Yo;function Lh(r){return kh(r,zh,xh)}var bh=Lh,Ph=ie,jh=Rt,Dh=Ph(jh,"DataView"),Eh=Dh,Ah=ie,Oh=Rt,Rh=Ah(Oh,"Promise"),Yh=Rh,Wh=ie,Uh=Rt,Bh=Wh(Uh,"Set"),Fh=Bh,Hh=ie,Qh=Rt,Vh=Hh(Qh,"WeakMap"),$h=Vh,mo=Eh,wo=jo,Io=Yh,vo=Fh,No=$h,ei=se,ve=Ys,es="[object Map]",Gh="[object Object]",os="[object Promise]",ss="[object Set]",is="[object WeakMap]",ns="[object DataView]",Zh=ve(mo),qh=ve(wo),Jh=ve(Io),Xh=ve(vo),Kh=ve(No),_t=ei;(mo&&_t(new mo(new ArrayBuffer(1)))!=ns||wo&&_t(new wo)!=es||Io&&_t(Io.resolve())!=os||vo&&_t(new vo)!=ss||No&&_t(new No)!=is)&&(_t=function(r){var s=ei(r),t=s==Gh?r.constructor:void 0,e=t?ve(t):"";if(e)switch(e){case Zh:return ns;case qh:return es;case Jh:return os;case Xh:return ss;case Kh:return is}return s});var ao=_t,_h=Object.prototype,tu=_h.hasOwnProperty;function eu(r){var s=r.length,t=new r.constructor(s);return s&&typeof r[0]=="string"&&tu.call(r,"index")&&(t.index=r.index,t.input=r.input),t}var ou=eu,su=Rt,iu=su.Uint8Array,oi=iu,rs=oi;function nu(r){var s=new r.constructor(r.byteLength);return new rs(s).set(new rs(r)),s}var Uo=nu,ru=Uo;function au(r,s){var t=s?ru(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.byteLength)}var cu=au,lu=/\w*$/;function hu(r){var s=new r.constructor(r.source,lu.exec(r));return s.lastIndex=r.lastIndex,s}var uu=hu,as=to,cs=as?as.prototype:void 0,ls=cs?cs.valueOf:void 0;function du(r){return ls?Object(ls.call(r)):{}}var pu=du,fu=Uo;function gu(r,s){var t=s?fu(r.buffer):r.buffer;return new r.constructor(t,r.byteOffset,r.length)}var Mu=gu,yu=Uo,mu=cu,wu=uu,Iu=pu,vu=Mu,Nu="[object Boolean]",Tu="[object Date]",Su="[object Map]",Cu="[object Number]",ku="[object RegExp]",xu="[object Set]",zu="[object String]",Lu="[object Symbol]",bu="[object ArrayBuffer]",Pu="[object DataView]",ju="[object Float32Array]",Du="[object Float64Array]",Eu="[object Int8Array]",Au="[object Int16Array]",Ou="[object Int32Array]",Ru="[object Uint8Array]",Yu="[object Uint8ClampedArray]",Wu="[object Uint16Array]",Uu="[object Uint32Array]";function Bu(r,s,t){var e=r.constructor;switch(s){case bu:return yu(r);case Nu:case Tu:return new e(+r);case Pu:return mu(r,t);case ju:case Du:case Eu:case Au:case Ou:case Ru:case Yu:case Wu:case Uu:return vu(r,t);case Su:return new e;case Cu:case zu:return new e(r);case ku:return wu(r);case xu:return new e;case Lu:return Iu(r)}}var Fu=Bu,Hu=Xt,hs=Object.create,Qu=function(){function r(){}return function(s){if(!Hu(s))return{};if(hs)return hs(s);r.prototype=s;var t=new r;return r.prototype=void 0,t}}(),Vu=Qu,$u=Vu,Gu=Xs,Zu=Oo;function qu(r){return typeof r.constructor=="function"&&!Zu(r)?$u(Gu(r)):{}}var Ju=qu,Xu=ao,Ku=Qt,_u="[object Map]";function td(r){return Ku(r)&&Xu(r)==_u}var ed=td,od=ed,sd=Eo,us=Ao,ds=us&&us.isMap,id=ds?sd(ds):od,nd=id,rd=ao,ad=Qt,cd="[object Set]";function ld(r){return ad(r)&&rd(r)==cd}var hd=ld,ud=hd,dd=Eo,ps=Ao,fs=ps&&ps.isSet,pd=fs?dd(fs):ud,fd=pd,gd=Us,Md=Ra,yd=Fs,md=xl,wd=Ql,Id=Vl,vd=Gl,Nd=nh,Td=mh,Sd=ti,Cd=bh,kd=ao,xd=ou,zd=Fu,Ld=Ju,bd=ro,Pd=Do,jd=nd,Dd=Xt,Ed=fd,Ad=Ro,Od=Yo,Rd=1,Yd=2,Wd=4,si="[object Arguments]",Ud="[object Array]",Bd="[object Boolean]",Fd="[object Date]",Hd="[object Error]",ii="[object Function]",Qd="[object GeneratorFunction]",Vd="[object Map]",$d="[object Number]",ni="[object Object]",Gd="[object RegExp]",Zd="[object Set]",qd="[object String]",Jd="[object Symbol]",Xd="[object WeakMap]",Kd="[object ArrayBuffer]",_d="[object DataView]",tp="[object Float32Array]",ep="[object Float64Array]",op="[object Int8Array]",sp="[object Int16Array]",ip="[object Int32Array]",np="[object Uint8Array]",rp="[object Uint8ClampedArray]",ap="[object Uint16Array]",cp="[object Uint32Array]",pt={};pt[si]=pt[Ud]=pt[Kd]=pt[_d]=pt[Bd]=pt[Fd]=pt[tp]=pt[ep]=pt[op]=pt[sp]=pt[ip]=pt[Vd]=pt[$d]=pt[ni]=pt[Gd]=pt[Zd]=pt[qd]=pt[Jd]=pt[np]=pt[rp]=pt[ap]=pt[cp]=!0;pt[Hd]=pt[ii]=pt[Xd]=!1;function We(r,s,t,e,o,n){var i,a=s&Rd,c=s&Yd,l=s&Wd;if(t&&(i=o?t(r,e,o,n):t(r)),i!==void 0)return i;if(!Dd(r))return r;var h=bd(r);if(h){if(i=xd(r),!a)return vd(r,i)}else{var u=kd(r),d=u==ii||u==Qd;if(Pd(r))return Id(r,a);if(u==ni||u==si||d&&!o){if(i=c||d?{}:Ld(r),!a)return c?Td(r,wd(i,r)):Nd(r,md(i,r))}else{if(!pt[u])return o?r:{};i=zd(r,u,a)}}n||(n=new gd);var p=n.get(r);if(p)return p;n.set(r,i),Ed(r)?r.forEach(function(y){i.add(We(y,s,t,y,r,n))}):jd(r)&&r.forEach(function(y,v){i.set(v,We(y,s,t,v,r,n))});var f=l?c?Cd:Sd:c?Od:Ad,I=h?void 0:f(r);return Md(I||r,function(y,v){I&&(v=y,y=r[v]),yd(i,v,We(y,s,t,v,r,n))}),i}var lp=We,hp=lp,up=1,dp=4;function pp(r){return hp(r,up|dp)}var fp=pp;const Vt=je(fp),ri="1.0.10",gp="@netless/appliance-plugin",ai=typeof OffscreenCanvas=="function"?"worker":"mainThread";if(typeof window<"u"){let r=window.__netlessUA||"";r+=` ${gp}@${ri}_${ai}`,window.__netlessUA=r}const xt={syncOpt:{interval:500},canvasOpt:{contextType:_e.Canvas2d},cdn:{subWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/subWorker.js",fullWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/fullWorker.js"},cursor:{expirationTime:5e3},bufferSize:{full:2e4,sub:1e3},bezier:{combineUnitTime:100},pencilEraser:{useBitMap:!0}};function qt(r,s=!0){const t=r.length;if(t<2)return"";let e=r[0],o=r[1];if(t===2)return`M${ne(e)}L${ne(o)}`;let n="";for(let i=2,a=t-1;i<a;i++)e=r[i],o=r[i+1],n+=re(e,o);return s?`M${re(r[0],r[1])}Q${ne(r[1])}${re(r[1],r[2])}T${n}${re(r[t-1],r[0])}${re(r[0],r[1])}Z`:`M${ne(r[0])}Q${ne(r[1])}${re(r[1],r[2])}${r.length>3?"T":""}${n}L${ne(r[t-1])}`}const kt=class kt{constructor(s){M(this,"syncUnitTime",xt.syncOpt.interval);M(this,"vNodes");M(this,"drawLayer");M(this,"fullLayer");M(this,"workId");const{vNodes:t,fullLayer:e,drawLayer:o,workId:n,toolsOpt:i}=s;this.vNodes=t,this.fullLayer=e,this.drawLayer=o,this.workId=n,this.syncUnitTime=i.syncUnitTime||this.syncUnitTime}get baseConsumeResult(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions}}filterSamePoints(s,t=.01){return s.reduce((e,o)=>{const n=e[e.length-1];return(o&&!n||o&&n&&!o.isNear(n,t))&&e.push(o),e},[])}setWorkId(s){this.workId=s}getWorkId(){return this.workId}getWorkOptions(){return this.workOptions}setWorkOptions(s){var o,n,i;this.workOptions=s,this.syncUnitTime=s.syncUnitTime||this.syncUnitTime;const t=(o=this.workId)==null?void 0:o.toString(),e=t&&((n=this.vNodes)==null?void 0:n.get(t))||void 0;t&&e&&(e.opt=s,(i=this.vNodes)==null||i.setInfo(t,e))}updataOptService(s){var o,n;let t;const e=(o=this.workId)==null?void 0:o.toString();if(e&&s){const i=this.fullLayer.getElementsByName(e)||this.drawLayer&&this.drawLayer.getElementsByName(e)||[];if(i.length!==1)return;const a=i[0],{pos:c,zIndex:l,scale:h,angle:u,translate:d}=s,p={};Wt(l)&&(p.zIndex=l),c&&(p.pos=[c[0],c[1]]),h&&(p.scale=h),u&&(p.rotate=u),d&&(p.translate=d),a.attr(p);const f=a==null?void 0:a.getBoundingClientRect();return f&&(t=ut(t,{x:Math.floor(f.x-kt.SafeBorderPadding),y:Math.floor(f.y-kt.SafeBorderPadding),w:Math.floor(f.width+kt.SafeBorderPadding*2),h:Math.floor(f.height+kt.SafeBorderPadding*2)})),(n=this.vNodes)==null||n.setInfo(e,{rect:t,centerPos:c}),t}}drawEraserlines(s){const{group:t,eraserlines:e,pos:o,layer:n,isClear:i=!0}=s,a=!!n.parent.gl;for(const c of e){const{thickness:l,op:h}=c;for(const u of h){const d=u.map((v,m)=>m%2?v-o[1]:v-o[0]),p=this.computEraserPoints(d,l),f=qt(p,!0),I={pos:[0,0],d:f,fillColor:"rgba(0,0,0,1)"},y=new lt.Path(I);i&&(y.addEventListener("beforerender",({detail:v})=>{const m=v.context;a?m.blendFuncSeparate(m.ZERO,m.ZERO,m.ZERO,m.ZERO):m.globalCompositeOperation="destination-out"}),y.addEventListener("afterrender",({detail:v})=>{const m=v.context;a?m.blendFuncSeparate(m.SRC_ALPHA,m.ONE_MINUS_SRC_ALPHA,m.ONE,m.ONE_MINUS_SRC_ALPHA):m.globalCompositeOperation="source-over"})),t.append(y)}}}computEraserPoints(s,t){const e=Math.ceil(t/2);return s.length===2?this.computDot(s,e):this.computLine(s,e)}computDot(s,t){const e=new B(s[0],s[1]);return B.GetDotStroke(e,t,8)}computLine(s,t){const e=[],o=[];let n,i;for(let a=0;a<s.length;a+=2){const c=new B(s[a],s[a+1]);let l;if(a==s.length-2){const h=new B(s[a-2],s[a-1]);l=k.Sub(c,h).uni(),n=c}else{a===0&&(i=c);const h=new B(s[a+2],s[a+3]);l=k.Sub(h,c).uni()}if(l){const h=k.Per(l).mul(t);e.push(B.Sub(c,h)),o.push(B.Add(c,h))}}if(n&&i){const a=B.GetSemicircleStroke(n,e[e.length-1],-1,8),c=B.GetSemicircleStroke(i,o[0],-1,8);return e.concat(a,o.reverse(),c)}return[]}replace(s,t,e){var a;const o=s.getElementsByName(t),n=o.length;if(n){if(n>1)for(let c=1;c<o.length;c++)s.removeChild(o[c]),o[c].disconnect();e?s.replaceChild(e,o[0]):s.removeChild(o[0]),o[0].disconnect()}else e&&s.append(e);this.fullLayer===s?(a=this.drawLayer)==null||a.getElementsByName(t).forEach(c=>{var l;(l=this.drawLayer)==null||l.removeChild(c),c.disconnect()}):this.fullLayer.getElementsByName(t).forEach(c=>{this.fullLayer.removeChild(c),c.disconnect()})}static updateNodeOpt(s){var m;const{node:t,opt:e,vNodes:o,willSerializeData:n,targetNode:i}=s,{zIndex:a,translate:c,angle:l,originPoint:h,scenePoint:u,scale:d,pointMap:p,thickness:f}=e;let I;const y=i&&Vt(i)||o.get(t.name);if(!y)return;Wt(a)&&(t.setAttribute("zIndex",a),y.opt.zIndex=a);const v=t.parent;if(v){if(h&&d&&i){const w=[y.op[0],y.op[1]];Bo(y.op,u,d,c);const S=[y.op[0],y.op[1]],N=[S[0]-w[0],S[1]-w[1]];if(y.centerPos=[y.centerPos[0]+N[0],y.centerPos[1]+N[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:L}=T;T.thickness=L*Math.max(d[0],d[1]);for(let D=0;D<x.length;D++)Fo(x[D],u,d,c)}}else if(c)if(t.setAttribute("translate",c),y.opt.translate=c,i){const w=[c[0]*v.worldScaling[0],c[1]*v.worldScaling[1]];I=To(y.rect,w),y.rect=I}else{const w=kt.getRectFromLayer(v,t.name);y.rect=w||y.rect}else if(Wt(l))if(t.setAttribute("rotate",l),y.opt.rotate=l,i)I=Ti(y.rect,l),y.rect=I;else{const w=kt.getRectFromLayer(v,t.name);y.rect=w||y.rect}if(p){const w=p.get(t.name);if(w)for(let S=0,N=0;S<y.op.length;S+=3,N++)y.op[S]=w[N][0],y.op[S+1]=w[N][1]}if(f&&((m=y==null?void 0:y.opt)!=null&&m.thickness)&&(y.opt.thickness=f),n&&!(h&&d&&i)){if(c){const w=y.op.map((S,N)=>{const T=N%3;return T===0?S+c[0]:T===1?S+c[1]:S});if(y.op=w,y.centerPos=[y.centerPos[0]+c[0],y.centerPos[1]+c[1]],y!=null&&y.opt&&(y.opt.translate=void 0),y.opt.eraserlines)for(const S of Object.values(y.opt.eraserlines)){const{op:N}=S;for(let T=0;T<N.length;T++){const x=N[T].map((L,D)=>D%2?L+c[1]:L+c[0]);S.op[T]=x}}}else if(Wt(l)){const w=y.op;if(bf(w,y.centerPos,l),y.op=w,y!=null&&y.opt&&(y.opt.rotate=void 0),y.opt.eraserlines)for(const S of Object.values(y.opt.eraserlines)){const{op:N}=S;for(let T=0;T<N.length;T++)Pf(N[T],y.centerPos,l)}}}y&&o.setInfo(t.name,y)}}static getCenterPos(s,t){const{worldPosition:e,worldScaling:o}=t;return[(s.x+s.w/2-e[0])/o[0],(s.y+s.h/2-e[1])/o[1]]}static getRectFromLayer(s,t){const e=s.getElementsByName(t)[0];if(e){const o=e.getBoundingClientRect();return{x:Math.floor(o.x-kt.SafeBorderPadding),y:Math.floor(o.y-kt.SafeBorderPadding),w:Math.floor(o.width+kt.SafeBorderPadding*2),h:Math.floor(o.height+kt.SafeBorderPadding*2)}}}};M(kt,"SafeBorderPadding",10);let Y=kt;function Ne(r){return JSON.parse(Ps.decompress(r))}function zt(r){return Ps.compress(JSON.stringify(r))}const Ct=Object.keys;class ci extends Y{constructor(t){super(t);M(this,"canRotate",!0);M(this,"scaleType",ct.all);M(this,"toolsType",C.Pencil);M(this,"syncTimestamp");M(this,"syncIndex",0);M(this,"tmpPoints",[]);M(this,"MAX_REPEAR",10);M(this,"uniThickness");M(this,"workOptions");M(this,"centerPos",[0,0]);this.workOptions=t.toolsOpt,this.uniThickness=this.MAX_REPEAR/this.workOptions.thickness/10,this.syncTimestamp=0}combineConsume(){var a;const t=(a=this.workId)==null?void 0:a.toString();if(this.tmpPoints.length<2)return{type:z.None};const e=this.transformDataAll(!0),o={name:t};let n;const i=this.drawLayer||this.fullLayer;return e.length&&(n=this.draw({attrs:o,tasks:e,replaceId:t,layer:i})),{rect:n,type:z.DrawWork,dataType:F.Local}}setWorkOptions(t){super.setWorkOptions(t),this.syncTimestamp=Date.now()}consume(t){const{data:e,isFullWork:o,isSubWorker:n,isMainThread:i,drawCount:a,replaceId:c}=t,{workId:l}=e,{tasks:h,effects:u,consumeIndex:d}=this.transformData(e,!1);this.syncIndex=Math.min(this.syncIndex,d,Math.max(0,this.tmpPoints.length-2));const p={name:l,id:a==null?void 0:a.toString()};let f,I=!1;const y=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),h.length&&(h[0].taskId-this.syncTimestamp>this.syncUnitTime&&(I=!0,this.syncTimestamp=h[0].taskId,this.syncIndex=this.tmpPoints.length),n||i)){const m=o?this.fullLayer:this.drawLayer||this.fullLayer;f=this.draw({attrs:p,tasks:h,effects:u,layer:m,replaceId:c})}if(n)return d>10&&this.tmpPoints.splice(0,d-10),{rect:f,type:z.DrawWork,dataType:F.Local};const v=[];return this.tmpPoints.slice(y).forEach(m=>{v.push(m.x,m.y,this.computRadius(m.z,this.workOptions.thickness))}),{...this.baseConsumeResult,type:z.DrawWork,dataType:F.Local,rect:f,op:I?v:void 0,index:I?y*3:void 0,updateNodeOpt:{useAnimation:!0}}}consumeAll(t){var h;const e=this.workId;if(t.data){const{op:u,workState:d}=t.data;u!=null&&u.length&&d===b.Done&&this.workOptions.strokeType===X.Stroke&&this.updateTempPointsWithPressureWhenDone(u)}const o=this.transformDataAll(!0),n={name:e};let i;const a=this.fullLayer;if(o.length&&(i=this.draw({attrs:n,tasks:o,replaceId:e,layer:a})),this.tmpPoints.length<2)return this.replace(a,e),{type:z.RemoveNode,removeIds:[e],rect:i};const c=[];this.tmpPoints.map(u=>{c.push(u.x,u.y,u.z)}),this.syncTimestamp=0,delete this.workOptions.syncUnitTime;const l=zt(c);return(h=this.vNodes)==null||h.setInfo(e,{rect:i,op:c,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&Y.getCenterPos(i,a)}),{...this.baseConsumeResult,rect:i,type:z.FullWork,dataType:F.Local,ops:l,updateNodeOpt:{pos:this.centerPos,useAnimation:!0}}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(t){var h,u;const{op:e,isFullWork:o,replaceId:n}=t;this.tmpPoints.length=0;for(let d=0;d<e.length;d+=3){const p=new B(e[d],e[d+1],e[d+2]);if(this.tmpPoints.length>0){const f=this.tmpPoints[this.tmpPoints.length-1],I=k.Sub(p,f).uni();p.setv(I)}this.tmpPoints.push(p)}if(this.tmpPoints.length<2)return;const i=this.transformDataAll(!0),a=(h=this.workId)==null?void 0:h.toString(),c={name:a};let l;if(a&&i.length){const d=o?this.fullLayer:this.drawLayer||this.fullLayer;l=this.draw({attrs:c,tasks:i,replaceId:n,layer:d}),(u=this.vNodes)==null||u.setInfo(a,{rect:l,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:l&&Y.getCenterPos(l,d)})}return l}transformDataAll(t=!0){const e=this.filterSamePoints(this.tmpPoints,this.workOptions.thickness);return this.getTaskPoints(e,t&&this.workOptions.thickness||void 0)}draw(t){const{attrs:e,tasks:o,replaceId:n,effects:i,layer:a}=t,{strokeColor:c,strokeType:l,thickness:h,zIndex:u,scale:d,rotate:p,translate:f,eraserlines:I}=this.workOptions;i!=null&&i.size&&(i.forEach(N=>{var T;(T=a.getElementById(N+""))==null||T.remove()}),i.clear());let y;const v=[],m=a.worldPosition,w=a.worldScaling;for(let N=0;N<o.length;N++){const{pos:T,points:x}=o[N],{ps:L,rect:D}=this.computDrawPoints(x);let A;const P=x.length===1;l===X.Stroke||P?A=qt(L,!0):A=qt(L,!1);const E={pos:T,d:A,fillColor:l===X.Stroke||P?c:void 0,lineDash:l===X.Dotted&&!P?[1,h*2]:l===X.LongDotted&&!P?[h,h*2]:void 0,strokeColor:c,lineCap:l===X.Stroke||P?void 0:"round",lineWidth:l===X.Stroke||P?0:h};y=ut(y,{x:Math.floor((D.x+T[0])*w[0]+m[0]-Y.SafeBorderPadding),y:Math.floor((D.y+T[1])*w[1]+m[1]-Y.SafeBorderPadding),w:Math.floor(D.w*w[0]+2*Y.SafeBorderPadding),h:Math.floor(D.h*w[1]+2*Y.SafeBorderPadding)}),v.push(E)}d&&(e.scale=d),p&&(e.rotate=p),f&&(e.translate=f);const S=new lt.Group;if(y){this.centerPos=Y.getCenterPos(y,a);const N=l===X.Stroke&&!I;S.attr({...e,normalize:!0,anchor:[.5,.5],bgcolor:N?c:void 0,pos:this.centerPos,size:[(y.w-2*Y.SafeBorderPadding)/w[0],(y.h-2*Y.SafeBorderPadding)/w[1]],zIndex:u});const T=v.map(x=>(x.pos=[x.pos[0]-this.centerPos[0],x.pos[1]-this.centerPos[1]],new lt.Path(x)));S.append(...T),N&&S.seal(),I&&this.drawEraserlines({group:S,eraserlines:I,pos:this.centerPos,layer:a}),this.replace(a,n||e.workId,S)}if(d||p||f){const N=S==null?void 0:S.getBoundingClientRect();if(N)return{x:Math.floor(N.x-Y.SafeBorderPadding),y:Math.floor(N.y-Y.SafeBorderPadding),w:Math.floor(N.width+Y.SafeBorderPadding*2),h:Math.floor(N.height+Y.SafeBorderPadding*2)}}return y}computDrawPoints(t){return this.workOptions.strokeType===X.Stroke||t.length===1?this.computStroke(t):this.computNomal(t)}computNomal(t){let e=this.workOptions.thickness;const o=t.map(n=>(e=Math.max(e,n.radius),n.point));return{ps:o,rect:dt(o,e)}}computStroke(t){return t.length===1?this.computDotStroke(t[0]):this.computLineStroke(t)}computLineStroke(t){const e=[],o=[];for(let l=0;l<t.length;l++){const{point:h,radius:u}=t[l];let d=h.v;l===0&&t.length>1&&(d=t[l+1].point.v);const p=k.Per(d).mul(u);e.push(B.Sub(h,p)),o.push(B.Add(h,p))}const n=t[t.length-1],i=B.GetSemicircleStroke(n.point,e[e.length-1],-1,8),a=B.GetSemicircleStroke(t[0].point,o[0],-1,8),c=e.concat(i,o.reverse(),a);return{ps:c,rect:dt(c)}}computDotStroke(t){const{point:e,radius:o}=t,n={x:e.x-o,y:e.y-o,w:o*2,h:o*2};return{ps:B.GetDotStroke(e,o,8),rect:n}}transformData(t,e){const{op:o,workState:n}=t;let i=this.tmpPoints.length-1,a=[];if(o!=null&&o.length&&n){const{strokeType:c,thickness:l}=this.workOptions,h=new Set;i=c===X.Stroke?this.updateTempPointsWithPressure(o,l,h):this.updateTempPoints(o,l,h);const u=e?this.tmpPoints:this.tmpPoints.slice(i);return a=this.getTaskPoints(u,l),{tasks:a,effects:h,consumeIndex:i}}return{tasks:a,consumeIndex:i}}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 o=[];if(t.length===0)return[];let n=0,i=t[0].x,a=t[0].y,c=[i,a],l=[],h=t[0].t;for(;n<t.length;){const d=t[n],p=d.x-i,f=d.y-a,I=d.z,y=e?this.computRadius(I,e):I;if(l.push({point:new B(p,f,I,t[n].v),radius:y}),n>0&&n<t.length-1){const v=t[n].getAngleByPoints(t[n-1],t[n+1]);if(v<90||v>270){const m=(u=l.pop())==null?void 0:u.point.clone();m&&o.push({taskId:h,pos:c,points:[...l,{point:m,radius:y}]}),i=t[n].x,a=t[n].y,c=[i,a];const w=d.x-i,S=d.y-a;l=[{point:new B(w,S,I),radius:y}],h=Date.now()}}n++}return o.push({taskId:h,pos:c,points:l}),o}updateTempPointsWithPressure(t,e,o){const n=Date.now(),i=this.tmpPoints.length;let a=i;for(let l=0;l<t.length;l+=2){a=Math.min(a,i);const h=this.tmpPoints.length,u=new B(t[l],t[l+1]);if(h===0){this.tmpPoints.push(u);continue}const d=h-1,p=this.tmpPoints[d],f=k.Sub(u,p).uni();if(u.isNear(p,e)){if(p.z<this.MAX_REPEAR){if(p.setz(Math.min(p.z+1,this.MAX_REPEAR)),a=Math.min(a,d),h>1){let v=h-1;for(;v>0;){const m=this.tmpPoints[v].distance(this.tmpPoints[v-1]),w=Math.max(this.tmpPoints[v].z-this.uniThickness*m,0);if(this.tmpPoints[v-1].z>=w)break;this.tmpPoints[v-1].setz(w),a=Math.min(a,v-1),v--}}}else a=1/0;continue}u.setv(f);const I=u.distance(p),y=Math.max(p.z-this.uniThickness*I,0);h>1&&k.Equals(f,p.v,.02)&&(y>0||p.z<=0)&&(o&&p.t&&o.add(p.t),this.tmpPoints.pop(),a=Math.min(d,a)),u.setz(y),this.tmpPoints.push(u)}if(a===1/0)return this.tmpPoints.length;let c=i;if(a===i){c=Math.max(c-1,0);const l=this.tmpPoints[c].t;l&&(o==null||o.add(l))}else{let l=i-1;for(c=a;l>=0;){const h=this.tmpPoints[l].t;if(h&&(o==null||o.add(h),l<=a)){c=l,l=-1;break}l--}}return this.tmpPoints[c].setT(n),c}updateTempPoints(t,e,o){var l;const n=Date.now(),i=this.tmpPoints.length;let a=i;for(let h=0;h<t.length;h+=2){const u=this.tmpPoints.length,d=new B(t[h],t[h+1]);if(u===0){this.tmpPoints.push(d);continue}const p=u-1,f=this.tmpPoints[p],I=k.Sub(d,f).uni();if(d.isNear(f,e/2)){a=Math.min(p,a);continue}k.Equals(I,f.v,.02)&&(o&&f.t&&o.add(f.t),this.tmpPoints.pop(),a=Math.min(p,a)),d.setv(I),this.tmpPoints.push(d)}let c=i;if(a===i){c=Math.max(c-1,0);const h=this.tmpPoints[c].t;h&&(o==null||o.add(h))}else{let h=Math.min(i-1,a);for(c=a;h>=0;){const u=(l=this.tmpPoints[h])==null?void 0:l.t;if(u&&(o==null||o.add(u),h<=a)){c=h,h=-1;break}h--}}return this.tmpPoints[c].setT(n),c}updateTempPointsWithPressureWhenDone(t){const{thickness:e}=this.workOptions,o=t.length,n=this.getMinZ(e);for(let i=0;i<o;i+=2){const a=this.tmpPoints.length,c=new B(t[i],t[i+1]);if(a===0){this.tmpPoints.push(c);continue}const l=a-1,h=this.tmpPoints[l],u=k.Sub(c,h).uni(),d=c.distance(h);if(a>1&&h.z===n)break;if(c.isNear(h,e/2)){if(o<3&&h.z<this.MAX_REPEAR&&(h.setz(Math.min(h.z+1,this.MAX_REPEAR)),a>1)){let f=a-1;for(;f>0;){const I=this.tmpPoints[f].distance(this.tmpPoints[f-1]),y=Math.max(this.tmpPoints[f].z-this.uniThickness*I,-e/4);if(this.tmpPoints[f-1].z>=y)break;this.tmpPoints[f-1].setz(y),f--}}continue}c.setv(u);const p=Math.max(h.z-this.uniThickness*d,n);a>1&&k.Equals(u,h.v,.02)&&h.z<=0&&this.tmpPoints.pop(),c.setz(p),this.tmpPoints.push(c)}}static updateNodeOpt(t){var l,h;const{node:e,opt:o,vNodes:n}=t,{strokeColor:i,strokeType:a}=o,c=n.get(e.name);return i&&(e.tagName==="GROUP"?Df(e)?e.setAttribute("bgcolor",i):e.children.forEach(u=>{u.setAttribute("strokeColor",i),u.getAttribute("fillColor")&&u.setAttribute("fillColor",i)}):(e.setAttribute("strokeColor",i),e.setAttribute("fillColor",i)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=i)),a&&(c!=null&&c.opt)&&((h=c.opt)!=null&&h.strokeType)&&(c.opt.strokeType=a),c&&n.setInfo(e.name,c),Y.updateNodeOpt(t)}}class li extends Y{constructor(t){super(t);M(this,"toolsType",C.LaserPen);M(this,"canRotate",!1);M(this,"scaleType",ct.none);M(this,"syncTimestamp");M(this,"syncIndex",0);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"consumeIndex",0);this.workOptions=t.toolsOpt,this.syncTimestamp=0}combineConsume(){}setWorkOptions(t){super.setWorkOptions(t),this.syncTimestamp=Date.now()}consume(t){const{data:e,isSubWorker:o}=t,{workId:n,op:i}=e;if((i==null?void 0:i.length)===0)return{type:z.None};if(this.updateTempPoints(i||[]),this.consumeIndex>this.tmpPoints.length-4)return{type:z.None};const{strokeColor:a,thickness:c,strokeType:l}=this.workOptions,h=dt(this.tmpPoints,c);let u=!1;const d=this.syncIndex,p=this.tmpPoints.slice(this.consumeIndex);this.consumeIndex=this.tmpPoints.length-1,this.syncTimestamp===0&&(this.syncTimestamp=Date.now());const f={name:n==null?void 0:n.toString(),opacity:1,lineDash:l===X.Dotted?[1,c*2]:l===X.LongDotted?[c,c*2]:void 0,strokeColor:a,lineCap:"round",lineWidth:c,anchor:[.5,.5]},I=this.getTaskPoints(p);if(I.length){const v=Date.now();v-this.syncTimestamp>this.syncUnitTime&&(u=!0,this.syncTimestamp=v,this.syncIndex=this.tmpPoints.length),o&&this.draw({attrs:f,tasks:I,isDot:!1,layer:this.drawLayer||this.fullLayer})}const y=[];return this.tmpPoints.slice(d).forEach(v=>{y.push(v.x,v.y)}),{rect:{x:h.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:h.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:h.w*this.fullLayer.worldScaling[0],h:h.h*this.fullLayer.worldScaling[1]},type:z.DrawWork,dataType:F.Local,op:u?y:void 0,index:u?d*2:void 0,...this.baseConsumeResult}}consumeAll(){var i;const t=(i=this.workId)==null?void 0:i.toString();let e;if(this.tmpPoints.length-1>this.consumeIndex){let a=this.tmpPoints.slice(this.consumeIndex);const c=a.length===1,{strokeColor:l,thickness:h,strokeType:u}=this.workOptions;if(c){const f=this.computDotStroke({point:a[0],radius:h/2});a=f.ps,e=f.rect}else e=dt(this.tmpPoints,h);const d={name:t==null?void 0:t.toString(),fillColor:c?l:void 0,opacity:1,lineDash:u===X.Dotted&&!c?[1,h*2]:u===X.LongDotted&&!c?[h,h*2]:void 0,strokeColor:l,lineCap:c?void 0:"round",lineWidth:c?0:h,anchor:[.5,.5]},p=this.getTaskPoints(a);p.length&&this.draw({attrs:d,tasks:p,isDot:c,layer:this.drawLayer||this.fullLayer})}const o=[];this.tmpPoints.forEach(a=>{o.push(a.x,a.y)});const n=zt(o);return{rect:e&&{x:e.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:e.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:e.w*this.fullLayer.worldScaling[0],h:e.h*this.fullLayer.worldScaling[1]},type:z.FullWork,dataType:F.Local,ops:n,index:this.syncIndex*2,...this.baseConsumeResult}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(t){var I;const{op:e,replaceId:o,isFullWork:n}=t,{strokeColor:i,thickness:a,strokeType:c}=this.workOptions;if(!e.length){const y=dt(this.tmpPoints,a);return{x:y.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:y.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:y.w*this.fullLayer.worldScaling[0],h:y.h*this.fullLayer.worldScaling[1]}}const l=Math.max(0,this.tmpPoints.length-1);this.updateTempPoints(e||[]);let h,u=this.tmpPoints.slice(l);const d=u.length===1;if(d){const y=this.computDotStroke({point:u[0],radius:a/2});u=y.ps,h=y.rect}else h=dt(this.tmpPoints,a);const p={name:(I=this.workId)==null?void 0:I.toString(),fillColor:d?i:void 0,opacity:1,lineDash:c===X.Dotted&&!d?[1,a*2]:c===X.LongDotted&&!d?[a,a*2]:void 0,strokeColor:i,lineCap:d?void 0:"round",lineWidth:d?0:a,anchor:[.5,.5]},f=this.getTaskPoints(u);if(f.length){const y=n?this.fullLayer:this.drawLayer||this.fullLayer;this.draw({attrs:p,tasks:f,isDot:d,replaceId:o,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:o}=t,n={x:e.x-o,y:e.y-o,w:o*2,h:o*2};return{ps:B.GetDotStroke(e,o,8),rect:n}}updateTempPoints(t){const e=this.tmpPoints.length;for(let o=0;o<t.length;o+=2){if(e){const n=this.tmpPoints.slice(-1)[0];n&&n.x===t[o]&&n.y===t[o+1]&&this.tmpPoints.pop()}this.tmpPoints.push(new B(t[o],t[o+1]))}}async draw(t){const{attrs:e,tasks:o,isDot:n,layer:i}=t,{duration:a}=this.workOptions;for(const c of o){const l=new lt.Path,{pos:h,points:u}=c;let d;n?d=qt(u,!0):d=qt(u,!1),l.attr({...e,pos:h,d});const{vertex:p,fragment:f}=this.workOptions;if(p&&f){const I=i.renderer.createProgram({vertex:p,fragment:f}),{width:y,height:v}=i.getResolution();l.setUniforms({u_time:0,u_resolution:[y,v]}),l.setProgram(I)}i.appendChild(l),l.transition(a).attr({scale:n?[.1,.1]:[1,1],lineWidth:n?0:1}).then(()=>{l.remove()})}}getTaskPoints(t){var l;const e=[];if(t.length===0)return[];let o=0,n=t[0].x,i=t[0].y,a=[n,i],c=[];for(;o<t.length;){const h=t[o],u=h.x-n,d=h.y-i;if(c.push(new B(u,d)),o>0&&o<t.length-1){const p=t[o].getAngleByPoints(t[o-1],t[o+1]);if(p<90||p>270){const f=(l=c.pop())==null?void 0:l.clone();f&&e.push({pos:a,points:[...c,f]}),n=t[o].x,i=t[o].y,a=[n,i];const I=h.x-n,y=h.y-i;c=[new B(I,y)]}}o++}return e.push({pos:a,points:c}),e}removeLocal(){}removeService(t){let e;const o=[];return this.fullLayer.getElementsByName(t).forEach(n=>{if(n.name===t){const i=n.getBoundingClientRect();e=ut(e,{x:i.x,y:i.y,w:i.width,h:i.height}),o.push(n)}}),o.length&&o.forEach(n=>n.remove()),e}}const ue=class ue extends Y{constructor(t,e){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.none);M(this,"toolsType",C.Eraser);M(this,"serviceWork");M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"worldPosition");M(this,"worldScaling");M(this,"eraserRect");M(this,"eraserPolyline");this.serviceWork=e,this.workOptions=t.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}combineConsume(){}consumeService(){}setWorkOptions(t){super.setWorkOptions(t)}createEraserRect(t){const e=t[0]*this.worldScaling[0]+this.worldPosition[0],o=t[1]*this.worldScaling[1]+this.worldPosition[1],{width:n,height:i}=ue.eraserSizes[this.workOptions.thickness];this.eraserRect={x:e-n*.5,y:o-i*.5,w:n,h:i},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]),o=new k(this.tmpPoints[2],this.tmpPoints[3]),n=k.Sub(o,e).uni(),i=k.Dist(e,o),{width:a,height:c}=ue.eraserSizes[this.workOptions.thickness],l=Math.min(a,c),h=Math.round(i/l);if(h>1){const u=[];for(let d=0;d<h;d++){const p=k.Mul(n,d*l);u.push(this.tmpPoints[0]+p.x,this.tmpPoints[1]+p.y)}return u.concat(t)}}return t}isNear(t,e){const o=new k(t[0],t[1]),n=new k(e[0],e[1]),{width:i,height:a}=ue.eraserSizes[this.workOptions.thickness];return k.Dist(o,n)<Math.hypot(i,a)*.5}remove(t){const{curNodeMap:e,removeIds:o}=t;let n;for(const i of e.values())if(i.rect&&this.eraserRect&&this.eraserPolyline&&be(this.eraserRect,i.rect)){const{op:a}=i,c=[],l=[];for(let u=0;u<a.length;u+=3){const d=new k(a[u]*this.worldScaling[0]+this.worldPosition[0],a[u+1]*this.worldScaling[1]+this.worldPosition[1],a[u+2]);l.push(d),c.push(new B(d.x,d.y))}const h=c.length&&dt(c)||i.rect;be(h,this.eraserRect)&&(l.length>1?Lo.polyline(l.map(d=>d.XY),this.eraserPolyline).length&&o.add(i.name):o.add(i.name),n=ut(n,h))}return o.forEach(i=>{var c;const a=this.fullLayer.getElementsByName(i);this.fullLayer.removeChild(a[0]),(c=this.vNodes)==null||c.delete(i)}),n&&(n.x-=Y.SafeBorderPadding,n.y-=Y.SafeBorderPadding,n.w+=Y.SafeBorderPadding*2,n.h+=Y.SafeBorderPadding*2),n}consume(t){const{op:e}=t.data;if(!e||e.length===0)return{type:z.None,...this.baseConsumeResult};const o=this.tmpPoints.length;if(o>1&&this.isNear([e[0],e[1]],[this.tmpPoints[o-2],this.tmpPoints[o-1]]))return{type:z.None,...this.baseConsumeResult};o<3?this.tmpPoints.push(e[0],e[1]):this.tmpPoints.splice(2,2,e[0],e[1]);const n=this.computRectCenterPoints();let i;const a=new Set;if(!this.vNodes)return{type:z.None,...this.baseConsumeResult};const c=this.getUnLockNodeMap(this.vNodes.getUnLockNodes());for(let l=0;l<n.length-1;l+=2){this.createEraserRect(n.slice(l,l+2));const h=this.remove({curNodeMap:c,removeIds:a});i=ut(i,h)}return i&&a.size?{type:z.RemoveNode,rect:i,removeIds:[...a]}:{type:z.None,...this.baseConsumeResult}}consumeAll(t){return this.consume(t)}clearTmpPoints(){this.tmpPoints.length=0}getUnLockNodeMap(t){var e;if(this.serviceWork){const o=new Map(t),n=this.serviceWork.selectorWorkShapes,i=this.serviceWork.workShapes;for(const a of n.values())if((e=a.selectIds)!=null&&e.length)for(const c of a.selectIds)o.delete(c);for(const a of i.keys())o.delete(a);return o}return t}};M(ue,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));let Qe=ue;const Ot="++",H="selector",Ue="all";var Mp="__lodash_hash_undefined__";function yp(r){return this.__data__.set(r,Mp),this}var mp=yp;function wp(r){return this.__data__.has(r)}var Ip=wp,vp=Ws,Np=mp,Tp=Ip;function Ve(r){var s=-1,t=r==null?0:r.length;for(this.__data__=new vp;++s<t;)this.add(r[s])}Ve.prototype.add=Ve.prototype.push=Np;Ve.prototype.has=Tp;var Sp=Ve;function Cp(r,s){for(var t=-1,e=r==null?0:r.length;++t<e;)if(s(r[t],t,r))return!0;return!1}var kp=Cp;function xp(r,s){return r.has(s)}var zp=xp,Lp=Sp,bp=kp,Pp=zp,jp=1,Dp=2;function Ep(r,s,t,e,o,n){var i=t&jp,a=r.length,c=s.length;if(a!=c&&!(i&&c>a))return!1;var l=n.get(r),h=n.get(s);if(l&&h)return l==s&&h==r;var u=-1,d=!0,p=t&Dp?new Lp:void 0;for(n.set(r,s),n.set(s,r);++u<a;){var f=r[u],I=s[u];if(e)var y=i?e(I,f,u,s,r,n):e(f,I,u,r,s,n);if(y!==void 0){if(y)continue;d=!1;break}if(p){if(!bp(s,function(v,m){if(!Pp(p,m)&&(f===v||o(f,v,t,e,n)))return p.push(m)})){d=!1;break}}else if(!(f===I||o(f,I,t,e,n))){d=!1;break}}return n.delete(r),n.delete(s),d}var hi=Ep;function Ap(r){var s=-1,t=Array(r.size);return r.forEach(function(e,o){t[++s]=[o,e]}),t}var Op=Ap;function Rp(r){var s=-1,t=Array(r.size);return r.forEach(function(e){t[++s]=e}),t}var Yp=Rp,gs=to,Ms=oi,Wp=Po,Up=hi,Bp=Op,Fp=Yp,Hp=1,Qp=2,Vp="[object Boolean]",$p="[object Date]",Gp="[object Error]",Zp="[object Map]",qp="[object Number]",Jp="[object RegExp]",Xp="[object Set]",Kp="[object String]",_p="[object Symbol]",tf="[object ArrayBuffer]",ef="[object DataView]",ys=gs?gs.prototype:void 0,fo=ys?ys.valueOf:void 0;function of(r,s,t,e,o,n,i){switch(t){case ef:if(r.byteLength!=s.byteLength||r.byteOffset!=s.byteOffset)return!1;r=r.buffer,s=s.buffer;case tf:return!(r.byteLength!=s.byteLength||!n(new Ms(r),new Ms(s)));case Vp:case $p:case qp:return Wp(+r,+s);case Gp:return r.name==s.name&&r.message==s.message;case Jp:case Kp:return r==s+"";case Zp:var a=Bp;case Xp:var c=e&Hp;if(a||(a=Fp),r.size!=s.size&&!c)return!1;var l=i.get(r);if(l)return l==s;e|=Qp,i.set(r,s);var h=Up(a(r),a(s),e,o,n,i);return i.delete(r),h;case _p:if(fo)return fo.call(r)==fo.call(s)}return!1}var sf=of,ms=ti,nf=1,rf=Object.prototype,af=rf.hasOwnProperty;function cf(r,s,t,e,o,n){var i=t&nf,a=ms(r),c=a.length,l=ms(s),h=l.length;if(c!=h&&!i)return!1;for(var u=c;u--;){var d=a[u];if(!(i?d in s:af.call(s,d)))return!1}var p=n.get(r),f=n.get(s);if(p&&f)return p==s&&f==r;var I=!0;n.set(r,s),n.set(s,r);for(var y=i;++u<c;){d=a[u];var v=r[d],m=s[d];if(e)var w=i?e(m,v,d,s,r,n):e(v,m,d,r,s,n);if(!(w===void 0?v===m||o(v,m,t,e,n):w)){I=!1;break}y||(y=d=="constructor")}if(I&&!y){var S=r.constructor,N=s.constructor;S!=N&&"constructor"in r&&"constructor"in s&&!(typeof S=="function"&&S instanceof S&&typeof N=="function"&&N instanceof N)&&(I=!1)}return n.delete(r),n.delete(s),I}var lf=cf,go=Us,hf=hi,uf=sf,df=lf,ws=ao,Is=ro,vs=Do,pf=Vs,ff=1,Ns="[object Arguments]",Ts="[object Array]",Ae="[object Object]",gf=Object.prototype,Ss=gf.hasOwnProperty;function Mf(r,s,t,e,o,n){var i=Is(r),a=Is(s),c=i?Ts:ws(r),l=a?Ts:ws(s);c=c==Ns?Ae:c,l=l==Ns?Ae:l;var h=c==Ae,u=l==Ae,d=c==l;if(d&&vs(r)){if(!vs(s))return!1;i=!0,h=!1}if(d&&!h)return n||(n=new go),i||pf(r)?hf(r,s,t,e,o,n):uf(r,s,c,t,e,o,n);if(!(t&ff)){var p=h&&Ss.call(r,"__wrapped__"),f=u&&Ss.call(s,"__wrapped__");if(p||f){var I=p?r.value():r,y=f?s.value():s;return n||(n=new go),o(I,y,t,e,n)}}return d?(n||(n=new go),df(r,s,t,e,o,n)):!1}var yf=Mf,mf=yf,Cs=Qt;function ui(r,s,t,e,o){return r===s?!0:r==null||s==null||!Cs(r)&&!Cs(s)?r!==r&&s!==s:mf(r,s,t,e,ui,o)}var wf=ui,If=wf;function vf(r,s){return If(r,s)}var Nf=vf;const le=je(Nf),Ke=class Ke extends Y{constructor(t){super(t);M(this,"toolsType",C.Selector);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"vNodes");M(this,"selectIds");M(this,"selectorColor");M(this,"strokeColor");M(this,"fillColor");M(this,"oldSelectRect");M(this,"canRotate",!1);M(this,"canTextEdit",!1);M(this,"canLock",!1);M(this,"scaleType",ct.all);M(this,"toolsTypes");M(this,"shapeOpt");M(this,"textOpt");M(this,"isLocked");M(this,"thickness");M(this,"strokeType");M(this,"useStroke");this.workOptions=t.toolsOpt,this.vNodes=t.vNodes}computSelector(t=!0){const e=dt(this.tmpPoints);if(e.w===0||e.h===0)return{selectIds:[],intersectRect:void 0,subNodeMap:new Map};const{rectRange:o,nodeRange:n}=this.vNodes.getRectIntersectRange(e,t);return{selectIds:[...n.keys()],intersectRect:o,subNodeMap:n}}updateTempPoints(t){const e=this.tmpPoints.length,o=t.length;if(o>1){const n=new B(t[o-2]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],t[o-1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]);e===2?this.tmpPoints.splice(1,1,n):this.tmpPoints.push(n)}}drawSelector(t){const{drawRect:e,subNodeMap:o,selectorId:n,layer:i,isService:a}=t,c=new lt.Group({pos:[e.x,e.y],anchor:[0,0],size:[e.w,e.h],id:n,name:n,zIndex:9999}),l=[];if(a){const h=new lt.Rect({normalize:!0,pos:[e.w/2,e.h/2],lineWidth:1,strokeColor:this.selectorColor||this.workOptions.strokeColor,width:e.w,height:e.h,name:Ke.selectorBorderId});l.push(h)}o.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:o.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),(i==null?void 0:i.parent).appendChild(c)}draw(t,e,o,n=!1){var c,l;const{intersectRect:i,subNodeMap:a}=o;(l=(c=e.parent)==null?void 0:c.getElementById(t))==null||l.remove(),i&&this.drawSelector({drawRect:i,subNodeMap:a,selectorId:t,layer:e,isService:n})}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 o,n=!0;for(const i of t.values()){const{opt:a,canRotate:c,scaleType:l,toolsType:h}=i;this.selectorColor=this.workOptions.strokeColor,a.strokeColor&&(this.strokeColor=a.strokeColor),a.fillColor&&(this.fillColor=a.fillColor),a.textOpt&&(this.textOpt=a.textOpt),a.thickness&&(this.thickness=a.thickness),h!==C.Pencil&&(n=!1),a.strokeType&&(this.strokeType=a.strokeType),h===C.SpeechBalloon&&(e.add(h),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.placement=a.placement),h===C.Polygon&&(e.add(h),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices),h===C.Star&&(e.add(h),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=a.vertices,this.shapeOpt.innerRatio=a.innerRatio,this.shapeOpt.innerVerticeStep=a.innerVerticeStep),h===C.Text&&(this.textOpt=a),t.size===1&&(this.textOpt&&(this.canTextEdit=!0),this.canRotate=c,this.scaleType=l),l===ct.none&&(this.scaleType=l),h===C.Image&&(o=i)}n&&(this.useStroke=!0),e.size&&(this.toolsTypes=[...e]),o&&(t.size===1?(this.canLock=!0,o.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&&!o.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 o=this.selectIds[0],n=(e=this.vNodes.get(o))==null?void 0:e.op;if(n){const i=[];for(let a=0;a<n.length;a+=3)i.push([n[a],n[a+1]]);return i}}}consume(t){const{op:e,workState:o}=t.data;let n=this.oldSelectRect;if(o===b.Start&&(n=this.unSelectedAllIds()),!(e!=null&&e.length)||!this.vNodes.curNodeMap.size)return{type:z.None};this.updateTempPoints(e);const i=this.computSelector();if(this.selectIds&&le(this.selectIds,i.selectIds))return{type:z.None};this.selectIds=i.selectIds;const a=i.intersectRect;this.getSelecteorInfo(i.subNodeMap),this.draw(H,this.fullLayer,i),this.oldSelectRect=a;const c=this.getChildrenPoints();return{type:z.Select,dataType:F.Local,rect:ut(a,n),selectIds:i.selectIds,selectRect:a,selectorColor:this.selectorColor,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:c,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType,...this.baseConsumeResult}}consumeAll(){var e,o;let t=this.oldSelectRect;if(!((e=this.selectIds)!=null&&e.length)&&this.tmpPoints[0]&&this.selectSingleTool(this.tmpPoints[0].XY,H,!1),(o=this.selectIds)!=null&&o.length&&(t=this.selectedByIds(this.selectIds)),t){const n=this.getChildrenPoints();return{type:z.Select,dataType:F.Local,rect:this.oldSelectRect,selectIds:this.selectIds,selectorColor:this.selectorColor,selectRect:this.oldSelectRect,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:n,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,o=!1){if(t.length===2){const n=t[0],i=t[1];let a;const{nodeRange:c}=this.vNodes.getRectIntersectRange({x:n,y:i,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(vi(u).find(p=>p.isPointCollision(n,i))){a=h;break}}if(a){const h=a.name;if(!le(this.oldSelectRect,a.rect)){const u=new Map([[h,a]]);this.getSelecteorInfo(u),this.draw(e,this.fullLayer,{intersectRect:a.rect,subNodeMap:u,selectIds:this.selectIds||[]},o)}this.selectIds=[h],this.oldSelectRect=a.rect}}}unSelectedAllIds(){let t;for(const[e,o]of this.vNodes.curNodeMap.entries())o.isSelected&&(t=ut(t,o.rect),this.vNodes.unSelected(e));return t}unSelectedByIds(t){let e;for(const o of t){const n=this.vNodes.get(o);n&&n.isSelected&&(e=ut(e,n.rect),this.vNodes.unSelected(o))}return e}selectedByIds(t){let e;for(const o of t){const n=this.vNodes.get(o);n&&(e=ut(e,n.rect),this.vNodes.selected(o))}return e}getSelectorRect(t,e){var a;let o;const n=(a=t.parent)==null?void 0:a.getElementById(e),i=n==null?void 0:n.getBoundingClientRect();return i&&(o=ut(o,{x:Math.floor(i.x),y:Math.floor(i.y),w:Math.floor(i.width+1),h:Math.floor(i.height+1)})),o}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 N;const{updateSelectorOpt:e,selectIds:o,vNodes:n,willSerializeData:i,worker:a,offset:c}=t,l=this.fullLayer;if(!l)return;let h;const u=new Map,{originPoint:d,workState:p,angle:f,translate:I,dir:y,scale:v}=e;c&&(I?e.translate=[I[0]+c[0],I[1]+c[1]]:e.translate=c);let m;if(d||I||Wt(f)){if(p===b.Start&&o)return n.setTargetAssignKeys(o),{type:z.Select,dataType:F.Local,selectRect:this.oldSelectRect,rect:this.oldSelectRect};m=n.getLastTarget()}if(o)for(const T of o){const x=n.get(T);if(x){const{toolsType:L}=x,D=(l==null?void 0:l.getElementsByName(T))[0];if(D){let A=!1,P=!1;const E={...e};let j;if(L){E.thickness&&x.opt.thickness&&(A=x.opt.thickness!==E.thickness),E.strokeType&&((N=x.opt)!=null&&N.strokeType)&&(P=x.opt.strokeType!==E.strokeType),j=m==null?void 0:m.get(T);const _=wi(L);if(_==null||_.updateNodeOpt({node:D,opt:E,vNodes:n,willSerializeData:i,targetNode:j}),x&&a&&(i&&(E.angle||E.translate)||E.originPoint&&E.scenePoint&&E.scale||E.pointMap&&E.pointMap.has(T)||L===C.Text&&(E.fontSize||E.translate||E.textInfos&&E.textInfos.get(T))||L===C.Image&&(E.angle||E.translate||E.scale)||L===E.toolsType&&E.willRefresh||A||P)){const nt=a.createWorkShapeNode({workId:T,toolsType:L,toolsOpt:x.opt});nt==null||nt.setWorkId(T);let tt;if(L===C.Image)tt=await nt.consumeServiceAsync({isFullWork:!0,replaceId:T,worker:a});else if(L===C.Text)tt=await nt.consumeServiceAsync({isFullWork:!0,replaceId:T});else try{tt=nt==null?void 0:nt.consumeService({op:x.op,isFullWork:!0,replaceId:T})}catch{continue}tt&&(x.rect=tt)}x&&(u.set(T,x),h=ut(h,x.rect))}}}}m&&p===b.Done&&(n.deleteLastTarget(),m=void 0);const w=h;if(d&&I&&v&&y&&w&&!c){const T=[[w.x,w.y],[w.x+w.w,w.y],[w.x+w.w,w.y+w.h],[w.x,w.y+w.h]];let x;switch(y){case"top":case"topLeft":case"left":I[0]>0&&I[1]>0?x=T[0]:I[0]>0?x=T[3]:I[1]>0?x=T[1]:x=T[2];break;case"topRight":I[0]<0&&I[1]>0?x=T[1]:I[0]<0?x=T[2]:I[1]>0?x=T[0]:x=T[3];break;case"right":case"bottomRight":case"bottom":I[0]<0&&I[1]<0?x=T[2]:I[0]<0?x=T[1]:I[1]<0?x=T[3]:x=T[0];break;case"bottomLeft":I[0]>0&&I[1]<0?x=T[3]:I[0]>0?x=T[0]:I[1]<0?x=T[2]:x=T[1];break}const L=x&&[d[0]-x[0],d[1]-x[1]]||[0,0];if(!le(L,[0,0]))return await this.updateSelector({...t,updateSelectorOpt:{},offset:L})}this.getSelecteorInfo(u),this.draw(H,l,{selectIds:o||[],subNodeMap:u,intersectRect:w});const S=ut(this.oldSelectRect,w);return this.oldSelectRect=w,{type:z.Select,dataType:F.Local,selectRect:w,renderRect:h,rect:ut(S,w),selectIds:o}}blurSelector(){const t=this.unSelectedAllIds();return{type:z.Select,dataType:F.Local,rect:t,selectIds:[],willSyncService:!0}}getRightServiceId(t){return t.replace(Ot,"-")}selectServiceNode(t,e,o){const{selectIds:n}=e,i=this.getRightServiceId(t),a=this.getSelectorRect(this.fullLayer,i);let c;const l=new Map;return n==null||n.forEach(h=>{const u=this.vNodes.get(h);u&&(c=ut(c,u.rect),l.set(h,u))}),this.getSelecteorInfo(l),this.draw(i,this.fullLayer,{intersectRect:c,selectIds:n||[],subNodeMap:l},o),ut(c,a)}reRenderSelector(){var o;let t;const e=new Map;return(o=this.selectIds)==null||o.forEach(n=>{const i=this.vNodes.get(n);i&&(t=ut(t,i.rect),e.set(n,i))},this),this.getSelecteorInfo(e),this.draw(H,this.fullLayer,{intersectRect:t,subNodeMap:e,selectIds:this.selectIds||[]}),this.oldSelectRect=t,t}updateSelectIds(t){var i;let e;const o=(i=this.selectIds)==null?void 0:i.filter(a=>!t.includes(a));if(o!=null&&o.length&&(e=this.unSelectedByIds(o)),t.length){const a=this.selectedByIds(t);e=ut(e,a)}this.selectIds=t;const n=this.reRenderSelector();return{bgRect:e,selectRect:n}}cursorHover(t){var i,a;const e=this.oldSelectRect;this.selectIds=[];const o=(i=this.workId)==null?void 0:i.toString(),n=[t[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],t[1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]];if(this.selectSingleTool(n,o,!0),this.oldSelectRect&&!le(e,this.oldSelectRect))return{type:z.CursorHover,dataType:F.Local,rect:ut(e,this.oldSelectRect),selectorColor:this.selectorColor,willSyncService:!1};if((a=this.selectIds)!=null&&a.length||(this.oldSelectRect=void 0),e&&!this.oldSelectRect)return this.cursorBlur(),{type:z.CursorHover,dataType:F.Local,rect:e,selectorColor:this.selectorColor,willSyncService:!1}}cursorBlur(){var e,o;this.selectIds=[];const t=(e=this.workId)==null?void 0:e.toString();((o=this.fullLayer)==null?void 0:o.parent).children.forEach(n=>{n.name===t&&n.remove()})}};M(Ke,"selectorBorderId","selector-border");let $e=Ke;class di extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.both);M(this,"toolsType",C.Arrow);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"arrowTipWidth");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.arrowTipWidth=this.workOptions.thickness*4,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:o,isSubWorker:n,isMainThread:i}=t,a=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:z.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new B(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:z.None};let u;if(n||i){const p=o?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:a,layer:p})}if(!n){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{...this.baseConsumeResult,type:z.DrawWork,dataType:F.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0}):{type:z.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,...this.baseConsumeResult,type:z.DrawWork,dataType:F.Local}}consumeAll(){var a;const t=this.workId;if(this.tmpPoints.length<2)return{type:z.RemoveNode,removeIds:[t]};const e=this.fullLayer,o=this.draw({workId:t,layer:e});this.oldRect=o;const n=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),i=zt(n);return(a=this.vNodes)==null||a.setInfo(t,{rect:o,op:n,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:Y.getCenterPos(o,e)}),{rect:o,...this.baseConsumeResult,type:z.FullWork,dataType:F.Local,ops:i,isSync:!0}}draw(t){const{workId:e,layer:o}=t,{strokeColor:n,thickness:i,zIndex:a,scale:c,rotate:l,translate:h,strokeType:u,eraserlines:d}=this.workOptions,p=o.worldPosition,f=o.worldScaling,{points:I,pos:y,rect:v,isTriangle:m,trianglePoints:w,trianglePos:S}=this.computDrawPoints(i),N=[v.x+v.w/2,v.y+v.h/2],T={pos:N,name:e,id:e,zIndex:a,anchor:[.5,.5],size:[v.w,v.h]};c&&(T.scale=c),l&&(T.rotate=l),h&&(T.translate=h);const x=new lt.Group(T),L={points:w,pos:[S[0]-N[0],S[1]-N[1]],fillColor:n,strokeColor:n,lineWidth:0,normalize:!1},D=new lt.Polyline(L);if(x.append(D),!m&&I&&y){const A={points:I,pos:[y[0]-N[0],y[1]-N[1]],fillColor:n,strokeColor:n,lineDash:u===X.Dotted&&!m?[1,i*2]:u===X.LongDotted&&!m?[i,i*2]:void 0,lineCap:u===X.Normal?void 0:"round",lineWidth:i,normalize:!1},P=new lt.Polyline(A);x.append(P)}if(d&&this.drawEraserlines({group:x,eraserlines:d,pos:N,layer:o}),this.replace(o,e,x),c||l||h){const A=x.getBoundingClientRect();return{x:Math.floor(A.x-Y.SafeBorderPadding),y:Math.floor(A.y-Y.SafeBorderPadding),w:Math.floor(A.width+Y.SafeBorderPadding*2),h:Math.floor(A.height+Y.SafeBorderPadding*2)}}return{x:Math.floor(v.x*f[0]+p[0]-Y.SafeBorderPadding),y:Math.floor(v.y*f[1]+p[1]-Y.SafeBorderPadding),w:Math.floor(v.w*f[0]+2*Y.SafeBorderPadding),h:Math.floor(v.h*f[1]+2*Y.SafeBorderPadding)}}computDrawPoints(t){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.arrowTipWidth?this.computFullArrowPoints(t):this.computTrianglePoints()}computFullArrowPoints(t){const e=k.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),o=k.Per(e).mul(t/2),n=B.Sub(this.tmpPoints[0],o),i=B.Add(this.tmpPoints[0],o),a=k.Mul(e,this.arrowTipWidth),c=k.Sub(this.tmpPoints[1],a),l=B.Sub(c,o),h=B.Add(c,o),u=k.Per(e).mul(t*1.5),d=B.Sub(c,u),p=B.Add(c,u),f=[this.tmpPoints[0],c],I=[d,this.tmpPoints[1],p],y=[n,i,...I,l,h];return{trianglePoints:I.map(v=>B.Sub(v,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,points:f.map(v=>B.Sub(v,this.tmpPoints[0]).XY).flat(1),rect:dt(y),isTriangle:!1,pos:this.tmpPoints[0].XY}}computTrianglePoints(){const t=k.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),e=this.tmpPoints[1].distance(this.tmpPoints[0]),o=k.Per(t).mul(Math.floor(e*3/8)),n=B.Sub(this.tmpPoints[0],o),i=B.Add(this.tmpPoints[0],o),a=[n,this.tmpPoints[1],i];return{trianglePoints:a.map(c=>B.Sub(c,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,rect:dt(a),isTriangle:!0}}updateTempPoints(t){const e=t.slice(-2),o=new B(e[0],e[1]),n=this.tmpPoints[0],{thickness:i}=this.workOptions;if(n.isNear(o,i))return!1;if(this.tmpPoints.length===2){if(o.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=o}else this.tmpPoints.push(o);return!0}consumeService(t){var c,l;const{op:e,isFullWork:o}=t,n=(c=this.workId)==null?void 0:c.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new B(e[h],e[h+1],e[h+2]));const i=o?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:n,layer:i});return this.oldRect=a,(l=this.vNodes)==null||l.setInfo(n,{rect:a,op:e,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:Y.getCenterPos(a,i)}),a}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var l,h;const{node:e,opt:o,vNodes:n}=t,{strokeColor:i,strokeType:a}=o,c=n.get(e.name);return i&&(e.tagName==="GROUP"?e.children.forEach(u=>{u.setAttribute("strokeColor",i),u.getAttribute("fillColor")&&u.setAttribute("fillColor",i)}):(e.setAttribute("strokeColor",i),e.setAttribute("fillColor",i)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=i)),a&&(c!=null&&c.opt)&&((h=c.opt)!=null&&h.strokeType)&&(c.opt.strokeType=a),c&&n.setInfo(e.name,c),Y.updateNodeOpt(t)}}class pi extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.all);M(this,"toolsType",C.Ellipse);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:o,isSubWorker:n,isMainThread:i}=t,a=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:z.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new B(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:z.None};let u;if(n||i){const p=o?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:a,layer:p,isDrawing:!0})}if(!n){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:z.DrawWork,dataType:F.Local,...this.baseConsumeResult,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0}):{type:z.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:z.DrawWork,dataType:F.Local,...this.baseConsumeResult}}consumeAll(){var a;const t=this.workId;if(this.tmpPoints.length<2)return{type:z.RemoveNode,removeIds:[t]};const e=this.fullLayer,o=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=o;const n=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),i=zt(n);return(a=this.vNodes)==null||a.setInfo(t,{rect:o,op:n,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:o&&Y.getCenterPos(o,e)}),{rect:o,type:z.FullWork,dataType:F.Local,...this.baseConsumeResult,ops:i,isSync:!0}}draw(t){const{workId:e,layer:o,isDrawing:n}=t,{strokeColor:i,fillColor:a,thickness:c,zIndex:l,scale:h,rotate:u,translate:d,strokeType:p,eraserlines:f}=this.workOptions,I=o.worldScaling,{radius:y,rect:v,pos:m}=this.computDrawPoints(c),w={pos:m,name:e,id:e,radius:y,lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:i,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:p===X.Dotted?[1,c*2]:p===X.LongDotted?[c,c*2]:void 0},S={name:e,id:e,zIndex:l,pos:m,anchor:[.5,.5],size:[v.w,v.h]};h&&(S.scale=h),u&&(S.rotate=u),d&&(S.translate=d);const N=new lt.Group(S);if(n){const L=new lt.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:i,lineWidth:1,scale:[1/I[0],1/I[1]]});N.append(L)}const T=new lt.Ellipse({...w,pos:[0,0]});N.append(T),f&&this.drawEraserlines({group:N,eraserlines:f,pos:m,layer:o}),this.replace(o,e,N);const x=N.getBoundingClientRect();return{x:Math.floor(x.x-Y.SafeBorderPadding),y:Math.floor(x.y-Y.SafeBorderPadding),w:Math.floor(x.width+Y.SafeBorderPadding*2),h:Math.floor(x.height+Y.SafeBorderPadding*2)}}computDrawPoints(t){const e=dt(this.tmpPoints),o=dt(this.tmpPoints,t),n=[Math.floor(e.x+e.w/2),Math.floor(e.y+e.h/2)];return{rect:o,pos:n,radius:[Math.floor(e.w/2),Math.floor(e.h/2)]}}updateTempPoints(t){const e=t.slice(-2),o=new B(e[0],e[1]),n=this.tmpPoints[0],{thickness:i}=this.workOptions;if(n.isNear(o,i))return!1;if(this.tmpPoints.length===2){if(o.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=o}else this.tmpPoints.push(o);return!0}consumeService(t){var c,l;const{op:e,isFullWork:o}=t,n=(c=this.workId)==null?void 0:c.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new B(e[h],e[h+1],e[h+2]));const i=o?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:n,layer:i,isDrawing:!1});return this.oldRect=a,(l=this.vNodes)==null||l.setInfo(n,{rect:a,op:e,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:Y.getCenterPos(a,i)}),a}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var u,d,p;const{node:e,opt:o,vNodes:n}=t,{strokeColor:i,fillColor:a,strokeType:c}=o,l=n.get(e.name);let h=e;return e.tagName==="GROUP"&&(h=e.children[0]),i&&(h.setAttribute("strokeColor",i),(u=l==null?void 0:l.opt)!=null&&u.strokeColor&&(l.opt.strokeColor=i)),a&&(a==="transparent"?h.setAttribute("fillColor","rgba(0,0,0,0)"):h.setAttribute("fillColor",a),(d=l==null?void 0:l.opt)!=null&&d.fillColor&&(l.opt.fillColor=a)),c&&(l!=null&&l.opt)&&((p=l.opt)!=null&&p.strokeType)&&(l.opt.strokeType=c),l&&n.setInfo(e.name,l),Y.updateNodeOpt(t)}}class fi extends Y{constructor(t){super(t);M(this,"canRotate",!0);M(this,"scaleType",ct.all);M(this,"toolsType",C.Rectangle);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}transformData(){const t=dt(this.tmpPoints);return[[t.x,t.y,0],[t.x+t.w,t.y,0],[t.x+t.w,t.y+t.h,0],[t.x,t.y+t.h,0]]}computDrawPoints(t){const{thickness:e}=this.workOptions,o=[];for(const a of t)o.push(new k(...a));const n=dt(o,e),i=[n.x+n.w/2,n.y+n.h/2];return{rect:n,pos:i,points:o.map(a=>a.XY).flat(1)}}consume(t){const{data:e,isFullWork:o,isSubWorker:n,isMainThread:i}=t,a=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:z.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new B(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:z.None};const u=this.transformData();let d;if(n||i){const f=o?this.fullLayer:this.drawLayer||this.fullLayer;d=this.draw({ps:u,workId:a,layer:f,isDrawing:!0})}if(!n){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:z.DrawWork,dataType:F.Local,op:u.flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:z.None}}const p=ut(d,this.oldRect);return this.oldRect=d,{rect:p,type:z.DrawWork,dataType:F.Local,...this.baseConsumeResult}}consumeAll(){var c;const t=this.workId;if(this.tmpPoints.length<2)return{type:z.RemoveNode,removeIds:[t]};const e=this.transformData(),o=this.fullLayer,n=this.draw({ps:e,workId:t,layer:o,isDrawing:!1});this.oldRect=n;const i=e.flat(1),a=zt(i);return(c=this.vNodes)==null||c.setInfo(t,{rect:n,op:i,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&Y.getCenterPos(n,o)}),{rect:n,type:z.FullWork,dataType:F.Local,ops:a,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:o,isDrawing:n,ps:i,replaceId:a}=t,{strokeColor:c,fillColor:l,thickness:h,zIndex:u,scale:d,rotate:p,translate:f,strokeType:I,eraserlines:y}=this.workOptions,v=o.worldPosition,m=o.worldScaling,{points:w,rect:S,pos:N}=this.computDrawPoints(i),T={close:!0,normalize:!0,points:w,lineWidth:h,fillColor:l!=="transparent"&&l||void 0,strokeColor:c,lineJoin:"round",lineCap:"round",lineDash:I===X.Dotted?[1,h*2]:I===X.LongDotted?[h,h*2]:void 0},x={x:Math.floor(S.x*m[0]+v[0]-Y.SafeBorderPadding),y:Math.floor(S.y*m[1]+v[1]-Y.SafeBorderPadding),w:Math.floor(S.w*m[0]+2*Y.SafeBorderPadding),h:Math.floor(S.h*m[0]+2*Y.SafeBorderPadding)},L=new lt.Group({name:e,id:e,zIndex:u,pos:N,anchor:[.5,.5],size:[S.w,S.h],scale:d,rotate:p,translate:f}),D=new lt.Polyline({...T,pos:[0,0]});if(L.appendChild(D),n){const A=new lt.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:c,lineWidth:1,scale:[1/m[0],1/m[1]]});L.appendChild(A)}if(y&&this.drawEraserlines({group:L,eraserlines:y,pos:N,layer:o}),this.replace(o,a||e,L),d||p||f){const A=L.getBoundingClientRect();return{x:Math.floor(A.x-Y.SafeBorderPadding),y:Math.floor(A.y-Y.SafeBorderPadding),w:Math.floor(A.width+2*Y.SafeBorderPadding),h:Math.floor(A.height+2*Y.SafeBorderPadding)}}return x}updateTempPoints(t){const e=t.slice(-2),o=new B(e[0],e[1]),n=this.tmpPoints[0],{thickness:i}=this.workOptions;if(n.isNear(o,i))return!1;if(this.tmpPoints.length===2){if(o.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=o}else this.tmpPoints.push(o);return!0}consumeService(t){var h,u;const{op:e,isFullWork:o,replaceId:n}=t,i=(h=this.workId)==null?void 0:h.toString();if(!i)return;const a=[];for(let d=0;d<e.length;d+=3)a.push([e[d],e[d+1],e[d+2]]);const c=o?this.fullLayer:this.drawLayer||this.fullLayer,l=this.draw({ps:a,workId:i,layer:c,isDrawing:!1,replaceId:n});return this.oldRect=l,(u=this.vNodes)==null||u.setInfo(i,{rect:l,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:l&&Y.getCenterPos(l,c)}),l}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var u,d,p;const{node:e,opt:o,vNodes:n}=t,{strokeColor:i,fillColor:a,strokeType:c}=o,l=n.get(e.name);let h=e;return e.tagName==="GROUP"&&(h=e.children[0]),i&&(h.setAttribute("strokeColor",i),(u=l==null?void 0:l.opt)!=null&&u.strokeColor&&(l.opt.strokeColor=i)),a&&(a==="transparent"?h.setAttribute("fillColor","rgba(0,0,0,0)"):h.setAttribute("fillColor",a),(d=l==null?void 0:l.opt)!=null&&d.fillColor&&(l.opt.fillColor=a)),c&&(l!=null&&l.opt)&&((p=l.opt)!=null&&p.strokeType)&&(l.opt.strokeType=c),l&&n.setInfo(e.name,l),Y.updateNodeOpt(t)}}class gi extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.all);M(this,"toolsType",C.Star);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:o,isSubWorker:n,isMainThread:i}=t,a=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:z.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new B(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:z.None};let u;if(n||i){const p=o?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:a,layer:p,isDrawing:!0})}if(!n){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:z.DrawWork,dataType:F.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:z.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:z.DrawWork,dataType:F.Local,...this.baseConsumeResult}}consumeAll(){var a;const t=this.workId;if(this.tmpPoints.length<2)return{type:z.RemoveNode,removeIds:[t]};const e=this.fullLayer,o=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=o;const n=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),i=zt(n);return(a=this.vNodes)==null||a.setInfo(t,{rect:o,op:n,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&Y.getCenterPos(o,e)}),{rect:o,type:z.FullWork,dataType:F.Local,ops:i,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:o,isDrawing:n}=t,{strokeColor:i,fillColor:a,thickness:c,zIndex:l,vertices:h,innerVerticeStep:u,innerRatio:d,scale:p,rotate:f,translate:I,strokeType:y,eraserlines:v}=this.workOptions,m=o.worldScaling,{rect:w,pos:S,points:N}=this.computDrawPoints(c,h,u,d),T={close:!0,points:N,lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:i,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:y===X.Dotted?[1,c*2]:y===X.LongDotted?[c,c*2]:void 0},x={name:e,id:e,zIndex:l,pos:S,anchor:[.5,.5],size:[w.w,w.h]};p&&(x.scale=p),f&&(x.rotate=f),I&&(x.translate=I);const L=new lt.Group(x);if(n){const P=new lt.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:i,lineWidth:1,scale:[1/m[0],1/m[1]]});L.append(P)}const D=new lt.Polyline({...T,pos:[0,0]});L.append(D),v&&this.drawEraserlines({group:L,eraserlines:v,pos:S,layer:o}),this.replace(o,e,L);const A=L.getBoundingClientRect();return{x:Math.floor(A.x-Y.SafeBorderPadding),y:Math.floor(A.y-Y.SafeBorderPadding),w:Math.floor(A.width+Y.SafeBorderPadding*2),h:Math.floor(A.height+Y.SafeBorderPadding*2)}}computDrawPoints(t,e,o,n){const i=dt(this.tmpPoints),a=[Math.floor(i.x+i.w/2),Math.floor(i.y+i.h/2)],c=Ci(i.w,i.h),l=Math.floor(Math.min(i.w,i.h)/2),h=n*l,u=[],d=2*Math.PI/e;for(let f=0;f<e;f++){const I=f*d-.5*Math.PI;let y,v;f%o===1?(y=h*c[0]*Math.cos(I),v=h*c[1]*Math.sin(I)):(y=l*c[0]*Math.cos(I),v=l*c[1]*Math.sin(I),u.push(y,v)),u.push(y,v)}return{rect:dt(this.tmpPoints,t),pos:a,points:u}}updateTempPoints(t){const e=t.slice(-2),o=new B(e[0],e[1]),n=this.tmpPoints[0],{thickness:i}=this.workOptions;if(n.isNear(o,i)||B.Sub(n,o).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(o.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=o}else this.tmpPoints.push(o);return!0}consumeService(t){var c,l;const{op:e,isFullWork:o}=t,n=(c=this.workId)==null?void 0:c.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new B(e[h],e[h+1],e[h+2]));const i=o?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:n,layer:i,isDrawing:!1});return this.oldRect=a,(l=this.vNodes)==null||l.setInfo(n,{rect:a,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&Y.getCenterPos(a,i)}),a}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var y;const{node:e,opt:o,vNodes:n}=t,{strokeColor:i,fillColor:a,toolsType:c,vertices:l,innerVerticeStep:h,innerRatio:u,strokeType:d}=o,p=n.get(e.name),f=p==null?void 0:p.opt;let I=e;return e.tagName==="GROUP"&&(I=e.children[0]),i&&(I.setAttribute("strokeColor",i),f!=null&&f.strokeColor&&(f.strokeColor=i)),a&&(a==="transparent"?I.setAttribute("fillColor","rgba(0,0,0,0)"):I.setAttribute("fillColor",a),f!=null&&f.fillColor&&(f.fillColor=a)),c===C.Star&&(l&&(f.vertices=l),h&&(f.innerVerticeStep=h),u&&(f.innerRatio=u)),d&&(p!=null&&p.opt)&&((y=p.opt)!=null&&y.strokeType)&&(p.opt.strokeType=d),p&&n.setInfo(e.name,{...p,opt:f}),Y.updateNodeOpt(t)}}class Mi extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.all);M(this,"toolsType",C.Polygon);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:o,isSubWorker:n,isMainThread:i}=t,{op:a}=e,c=this.workId,l=a==null?void 0:a.length;if(!l||l<2)return{type:z.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new B(a[0],a[1])],h=!1):h=this.updateTempPoints(a),!h)return{type:z.None};let u;if(n||i){const p=o?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:c,layer:p,isDrawing:!0})}if(!n){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:z.DrawWork,dataType:F.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:z.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:z.DrawWork,dataType:F.Local,...this.baseConsumeResult}}consumeAll(){var a;const t=this.workId;if(this.tmpPoints.length<2)return{type:z.RemoveNode,removeIds:[t]};const e=this.fullLayer,o=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=o;const n=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),i=zt(n);return(a=this.vNodes)==null||a.setInfo(t,{rect:o,op:n,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&Y.getCenterPos(o,e)}),{rect:o,type:z.FullWork,dataType:F.Local,ops:i,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:o,isDrawing:n}=t,{strokeColor:i,fillColor:a,thickness:c,zIndex:l,vertices:h,scale:u,rotate:d,translate:p,strokeType:f,eraserlines:I}=this.workOptions,y=o.worldScaling,{rect:v,pos:m,points:w}=this.computDrawPoints(c,h),S={close:!0,points:w,lineWidth:c,fillColor:a!=="transparent"&&a||void 0,strokeColor:i,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:f===X.Dotted?[1,c*2]:f===X.LongDotted?[c,c*2]:void 0},N={name:e,id:e,zIndex:l,pos:m,anchor:[.5,.5],size:[v.w,v.h]};u&&(N.scale=u),d&&(N.rotate=d),p&&(N.translate=p);const T=new lt.Group(N);if(n){const D=new lt.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:i,lineWidth:1,scale:[1/y[0],1/y[1]]});T.append(D)}const x=new lt.Polyline({...S,pos:[0,0]});T.append(x),I&&this.drawEraserlines({group:T,eraserlines:I,pos:m,layer:o}),this.replace(o,e,T);const L=T.getBoundingClientRect();return{x:Math.floor(L.x-Y.SafeBorderPadding),y:Math.floor(L.y-Y.SafeBorderPadding),w:Math.floor(L.width+Y.SafeBorderPadding*2),h:Math.floor(L.height+Y.SafeBorderPadding*2)}}computDrawPoints(t,e){const o=dt(this.tmpPoints),n=[Math.floor(o.x+o.w/2),Math.floor(o.y+o.h/2)],i=Ci(o.w,o.h),a=Math.floor(Math.min(o.w,o.h)/2),c=[],l=2*Math.PI/e;for(let u=0;u<e;u++){const d=u*l-.5*Math.PI,p=a*i[0]*Math.cos(d),f=a*i[1]*Math.sin(d);c.push(p,f)}return{rect:dt(this.tmpPoints,t),pos:n,points:c}}updateTempPoints(t){const e=t.slice(-2),o=new B(e[0],e[1]),n=this.tmpPoints[0],{thickness:i}=this.workOptions;if(n.isNear(o,i)||B.Sub(n,o).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(o.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=o}else this.tmpPoints.push(o);return!0}consumeService(t){var c,l;const{op:e,isFullWork:o}=t,n=(c=this.workId)==null?void 0:c.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new B(e[h],e[h+1],e[h+2]));const i=o?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:n,layer:i,isDrawing:!1});return this.oldRect=a,(l=this.vNodes)==null||l.setInfo(n,{rect:a,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&Y.getCenterPos(a,i)}),a}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var f;const{node:e,opt:o,vNodes:n}=t,{strokeColor:i,fillColor:a,toolsType:c,vertices:l,strokeType:h}=o,u=n.get(e.name),d=u==null?void 0:u.opt;let p=e;return e.tagName==="GROUP"&&(p=e.children[0]),i&&(p.setAttribute("strokeColor",i),d!=null&&d.strokeColor&&(d.strokeColor=i)),a&&(a==="transparent"?p.setAttribute("fillColor","rgba(0,0,0,0)"):p.setAttribute("fillColor",a),d!=null&&d.fillColor&&(d.fillColor=a)),c===C.Polygon&&l&&(d.vertices=l),h&&(u!=null&&u.opt)&&((f=u.opt)!=null&&f.strokeType)&&(u.opt.strokeType=h),u&&n.setInfo(e.name,{...u,opt:d}),Y.updateNodeOpt(t)}}class At{static bezier(s,t){const e=[];for(let o=0;o<t.length;o+=4){const n=t[o],i=t[o+1],a=t[o+2],c=t[o+3];n&&i&&a&&c?e.push(...At.getBezierPoints(s,n,i,a,c)):n&&i&&a?e.push(...At.getBezierPoints(s,n,i,a)):n&&i?e.push(...At.getBezierPoints(s,n,i)):n&&e.push(n)}return e}static getBezierPoints(s=10,t,e,o,n){let i=null;const a=[];!o&&!n?i=At.oneBezier:o&&!n?i=At.twoBezier:o&&n&&(i=At.threeBezier);for(let c=0;c<s;c++)i&&a.push(i(c/s,t,e,o,n));return n?a.push(n):o&&a.push(o),a}static oneBezier(s,t,e){const o=t.x+(e.x-t.x)*s,n=t.y+(e.y-t.y)*s;return new k(o,n)}static twoBezier(s,t,e,o){const n=(1-s)*(1-s)*t.x+2*s*(1-s)*e.x+s*s*o.x,i=(1-s)*(1-s)*t.y+2*s*(1-s)*e.y+s*s*o.y;return new k(n,i)}static threeBezier(s,t,e,o,n){const i=t.x*(1-s)*(1-s)*(1-s)+3*e.x*s*(1-s)*(1-s)+3*o.x*s*s*(1-s)+n.x*s*s*s,a=t.y*(1-s)*(1-s)*(1-s)+3*e.y*s*(1-s)*(1-s)+3*o.y*s*s*(1-s)+n.y*s*s*s;return new k(i,a)}}class yi extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.all);M(this,"toolsType",C.SpeechBalloon);M(this,"ratio",.8);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){var p;const{data:e,isFullWork:o,isSubWorker:n,isMainThread:i}=t,a=(p=e==null?void 0:e.workId)==null?void 0:p.toString();if(!a)return{type:z.None};const{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:z.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new B(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:z.None};let u;if(n||i){const f=o?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:a,layer:f,isDrawing:!0})}if(!n){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:z.DrawWork,dataType:F.Local,op:this.tmpPoints.map(I=>[...I.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:z.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:z.DrawWork,dataType:F.Local,...this.baseConsumeResult}}consumeAll(){var a;const t=this.workId;if(this.tmpPoints.length<2)return{type:z.RemoveNode,removeIds:[t]};const e=this.fullLayer,o=this.draw({workId:t,layer:e,isDrawing:!1});this.oldRect=o;const n=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),i=zt(n);return(a=this.vNodes)==null||a.setInfo(t,{rect:o,op:n,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&Y.getCenterPos(o,e)}),{rect:o,type:z.FullWork,dataType:F.Local,ops:i,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:o}=t,{strokeColor:n,fillColor:i,thickness:a,zIndex:c,placement:l,scale:h,rotate:u,translate:d,strokeType:p,eraserlines:f}=this.workOptions,{rect:I,pos:y,points:v}=this.computDrawPoints(a,l),m={points:v.map(x=>x.XY),lineWidth:a,fillColor:i!=="transparent"&&i||void 0,strokeColor:n,normalize:!0,className:`${y[0]},${y[1]}`,close:!0,lineJoin:"round",lineCap:"round",lineDash:p===X.Dotted?[1,a*2]:p===X.LongDotted?[a,a*2]:void 0},w={name:e,id:e,zIndex:c,pos:y,anchor:[.5,.5],size:[I.w,I.h]};h&&(w.scale=h),u&&(w.rotate=u),d&&(w.translate=d);const S=new lt.Group(w),N=new lt.Polyline({...m,pos:[0,0]});S.append(N),f&&this.drawEraserlines({group:S,eraserlines:f,pos:y,layer:o}),this.replace(o,e,S);const T=S.getBoundingClientRect();return{x:Math.floor(T.x-Y.SafeBorderPadding),y:Math.floor(T.y-Y.SafeBorderPadding),w:Math.floor(T.width+Y.SafeBorderPadding*2),h:Math.floor(T.height+Y.SafeBorderPadding*2)}}transformControlPoints(t){const e=dt(this.tmpPoints);switch(t){case"bottom":case"bottomLeft":case"bottomRight":{const o=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,o,0),new k(e.x,o,0)]}case"top":case"topLeft":case"topRight":{const o=e.y+e.h*(1-this.ratio);return[new k(e.x,o,0),new k(e.x+e.w,o,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 o=e.x+e.w*(1-this.ratio);return[new k(o,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(o,e.y+e.h,0)]}case"right":case"rightBottom":case"rightTop":{const o=e.x+e.w*this.ratio;return[new k(e.x,e.y,0),new k(o,e.y,0),new k(o,e.y+e.h,0),new k(e.x,e.y+e.h,0)]}}}computDrawPoints(t,e){const o=dt(this.tmpPoints),n=this.transformControlPoints(e),i=Math.floor(o.w*.1),a=Math.floor(o.h*.1),c=[],l=k.Add(n[0],new k(0,a,0)),h=k.Add(n[0],new k(i,0,0)),u=At.getBezierPoints(10,l,n[0],h),d=k.Sub(n[1],new k(i,0,0)),p=k.Add(n[1],new k(0,a,0)),f=At.getBezierPoints(10,d,n[1],p),I=k.Sub(n[2],new k(0,a,0)),y=k.Sub(n[2],new k(i,0,0)),v=At.getBezierPoints(10,I,n[2],y),m=k.Add(n[3],new k(i,0,0)),w=k.Sub(n[3],new k(0,a,0)),S=At.getBezierPoints(10,m,n[3],w),N=i*(1-this.ratio)*10,T=a*(1-this.ratio)*10;switch(e){case"bottom":{const D=k.Sub(n[2],new k(i*5-N/2,0,0)),A=k.Sub(n[2],new k(i*5,-T,0)),P=k.Sub(n[2],new k(i*5+N/2,0,0));c.push(A,P,...S,...u,...f,...v,D);break}case"bottomRight":{const D=k.Sub(n[2],new k(i*1.1,0,0)),A=k.Sub(n[2],new k(i*1.1+N/2,-T,0)),P=k.Sub(n[2],new k(i*1.1+N,0,0));c.push(A,P,...S,...u,...f,...v,D);break}case"bottomLeft":{const D=k.Add(n[3],new k(i*1.1+N,0,0)),A=k.Add(n[3],new k(i*1.1+N/2,T,0)),P=k.Add(n[3],new k(i*1.1,0,0));c.push(A,P,...S,...u,...f,...v,D);break}case"top":{const D=k.Sub(n[1],new k(i*5-N/2,0,0)),A=k.Sub(n[1],new k(i*5,T,0)),P=k.Sub(n[1],new k(i*5+N/2,0,0));c.push(A,D,...f,...v,...S,...u,P);break}case"topRight":{const D=k.Sub(n[1],new k(i*1.1,0,0)),A=k.Sub(n[1],new k(i*1.1+N/2,T,0)),P=k.Sub(n[1],new k(i*1.1+N,0,0));c.push(A,D,...f,...v,...S,...u,P);break}case"topLeft":{const D=k.Add(n[0],new k(i*1.1+N,0,0)),A=k.Add(n[0],new k(i*1.1+N/2,-T,0)),P=k.Add(n[0],new k(i*1.1,0,0));c.push(A,D,...f,...v,...S,...u,P);break}case"left":{const D=k.Add(n[0],new k(0,a*5-T/2,0)),A=k.Add(n[0],new k(-N,a*5,0)),P=k.Add(n[0],new k(0,a*5+T/2,0));c.push(A,D,...u,...f,...v,...S,P);break}case"leftTop":{const D=k.Add(n[0],new k(0,a*1.1,0)),A=k.Add(n[0],new k(-N,a*1.1+T/2,0)),P=k.Add(n[0],new k(0,a*1.1+T,0));c.push(A,D,...u,...f,...v,...S,P);break}case"leftBottom":{const D=k.Sub(n[3],new k(0,a*1.1+T,0)),A=k.Sub(n[3],new k(N,a*1.1+T/2,0)),P=k.Sub(n[3],new k(0,a*1.1,0));c.push(A,D,...u,...f,...v,...S,P);break}case"right":{const D=k.Add(n[1],new k(0,a*5-T/2,0)),A=k.Add(n[1],new k(N,a*5,0)),P=k.Add(n[1],new k(0,a*5+T/2,0));c.push(A,P,...v,...S,...u,...f,D);break}case"rightTop":{const D=k.Add(n[1],new k(0,a*1.1,0)),A=k.Add(n[1],new k(N,a*1.1+T/2,0)),P=k.Add(n[1],new k(0,a*1.1+T,0));c.push(A,P,...v,...S,...u,...f,D);break}case"rightBottom":{const D=k.Sub(n[2],new k(0,a*1.1+T,0)),A=k.Sub(n[2],new k(-N,a*1.1+T/2,0)),P=k.Sub(n[2],new k(0,a*1.1,0));c.push(A,P,...v,...S,...u,...f,D);break}}const x=dt(this.tmpPoints,t),L=[Math.floor(x.x+x.w/2),Math.floor(x.y+x.h/2)];return{rect:x,pos:L,points:c}}updateTempPoints(t){const e=t.slice(-2),o=new B(e[0],e[1]),n=this.tmpPoints[0],{thickness:i}=this.workOptions;if(n.isNear(o,i)||B.Sub(n,o).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(o.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=o}else this.tmpPoints.push(o);return!0}consumeService(t){var c,l;const{op:e,isFullWork:o}=t,n=(c=this.workId)==null?void 0:c.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new B(e[h],e[h+1],e[h+2]));const i=o?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:n,layer:i,isDrawing:!1});return this.oldRect=a,(l=this.vNodes)==null||l.setInfo(n,{rect:a,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&Y.getCenterPos(a,i)}),a}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var f;const{node:e,opt:o,vNodes:n}=t,{strokeColor:i,fillColor:a,toolsType:c,placement:l,strokeType:h}=o,u=n.get(e.name),d=u==null?void 0:u.opt;let p=e;return e.tagName==="GROUP"&&(p=e.children[0]),i&&(p.setAttribute("strokeColor",i),d!=null&&d.strokeColor&&(d.strokeColor=i)),a&&(a==="transparent"?p.setAttribute("fillColor","rgba(0,0,0,0)"):p.setAttribute("fillColor",a),d!=null&&d.fillColor&&(d.fillColor=a)),c===C.SpeechBalloon&&l&&(d.placement=l),h&&(u!=null&&u.opt)&&((f=u.opt)!=null&&f.strokeType)&&(u.opt.strokeType=h),u&&n.setInfo(e.name,{...u,opt:d}),Y.updateNodeOpt(t)}}var Tf=se,Sf=Qt,Cf="[object Boolean]";function kf(r){return r===!0||r===!1||Sf(r)&&Tf(r)==Cf}var xf=kf;const he=je(xf);class Le extends Y{constructor(t){super(t);M(this,"canRotate",!0);M(this,"scaleType",ct.all);M(this,"toolsType",C.Image);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");this.workOptions=t.toolsOpt,this.scaleType=Le.getScaleType(this.workOptions)}consume(){return{type:z.None}}consumeAll(){return{type:z.None}}draw(t){const{layer:e,workId:o,replaceId:n,imageBitmap:i}=t,{centerX:a,centerY:c,width:l,height:h,rotate:u,zIndex:d,eraserlines:p}=this.workOptions,f=new lt.Group({anchor:[.5,.5],pos:[a,c],name:o,size:[l,h],zIndex:d,rotate:u}),I={anchor:[.5,.5],pos:[0,0],size:[l,h],texture:i};i||(I.bgcolor="rgba(0,0,0,0.3)");const y=new lt.Sprite(I);f.append(y),p&&this.drawEraserlines({group:f,eraserlines:p,pos:[a,c],layer:e}),this.replace(e,n||o,f);const v=f.getBoundingClientRect();if(v)return{x:Math.floor(v.x-Y.SafeBorderPadding),y:Math.floor(v.y-Y.SafeBorderPadding),w:Math.floor(v.width+Y.SafeBorderPadding*2),h:Math.floor(v.height+Y.SafeBorderPadding*2)}}consumeService(){}async consumeServiceAsync(t){var h,u,d,p;const{isFullWork:e,replaceId:o,worker:n}=t,{src:i,uuid:a}=this.workOptions,c=((h=this.workId)==null?void 0:h.toString())||a,l=e?this.fullLayer:this.drawLayer||this.fullLayer;if(i){const f=!!l.parent.gl;let I;n&&(I=await n.loadImageBitMap({toolsType:this.toolsType,opt:this.workOptions,workId:c})),I||(I=await fetch(i,{method:"GET",mode:"cors",cache:"default"}).then(v=>v.blob()).then(v=>createImageBitmap(v,{imageOrientation:f?"flipY":"none"}).then(m=>m)).catch(v=>{console.error(`load image error: ${v}`)}));const y=this.draw({workId:c,layer:l,replaceId:o,imageBitmap:I});return this.oldRect=c&&((d=(u=this.vNodes)==null?void 0:u.get(c))==null?void 0:d.rect)||void 0,(p=this.vNodes)==null||p.setInfo(c,{rect:y,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:y&&Y.getCenterPos(y,l)}),y}}clearTmpPoints(){this.tmpPoints.length=0}static getScaleType(t){const{uniformScale:e,rotate:o}=t;return e!==!1||o&&Math.abs(o)%90>0?ct.proportional:ct.all}static updateNodeOpt(t){const{node:e,opt:o,vNodes:n,targetNode:i}=t,{translate:a,originPoint:c,scenePoint:l,scale:h,angle:u,isLocked:d,zIndex:p}=o,f=i&&Vt(i)||n.get(e.name);if(!f)return;const I=e.parent;if(I){if(Wt(p)&&(e.setAttribute("zIndex",p),f.opt.zIndex=p),he(d)&&(f.opt.locked=d),c&&l&&h&&a){const{centerX:y,centerY:v,width:m,height:w,uniformScale:S}=f.opt,N=S!==!1?[h[0],h[0]]:h,T=[y,v],x=[y,v];Bo(x,l,N,a);const L=[x[0]-T[0],x[1]-T[1]];if(f.centerPos=[f.centerPos[0]+L[0],f.centerPos[1]+L[1]],f.opt.width=Math.round(m*N[0]),f.opt.height=Math.round(w*N[1]),f.opt.centerX=x[0],f.opt.centerY=x[1],f.opt.eraserlines)for(const D of Object.values(f.opt.eraserlines)){const{op:A,thickness:P}=D;D.thickness=P*Math.max(h[0],h[1]);for(let E=0;E<A.length;E++)Fo(A[E],l,h,a)}}else if(a){if(f.opt.centerX=f.opt.centerX+a[0],f.opt.centerY=f.opt.centerY+a[1],f.centerPos=[f.centerPos[0]+a[0],f.centerPos[1]+a[1]],f.opt.eraserlines)for(const y of Object.values(f.opt.eraserlines)){const{op:v}=y;for(let m=0;m<v.length;m++){const w=v[m].map((S,N)=>N%2?S+a[1]:S+a[0]);y.op[m]=w}}}else if(Wt(u))if(f.opt.rotate=u,f.scaleType=Le.getScaleType(f.opt),i){const y=Ti(f.rect,u);f.rect=y}else{const y=Y.getRectFromLayer(I,e.name);f.rect=y||f.rect}return f&&n.setInfo(e.name,f),f==null?void 0:f.rect}}}class mi extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.both);M(this,"toolsType",C.Straight);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");M(this,"straightTipWidth");M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.straightTipWidth=this.workOptions.thickness/2,this.syncTimestamp=0,this.syncUnitTime=50}consume(t){const{data:e,isFullWork:o,isSubWorker:n,isMainThread:i}=t,a=this.workId,{op:c}=e,l=c==null?void 0:c.length;if(!l||l<2)return{type:z.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new B(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:z.None};let u;if(n||i){const p=o?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:a,layer:p})}if(!n){const p=Date.now();return p-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=p,{type:z.DrawWork,dataType:F.Local,op:this.tmpPoints.map(f=>[...f.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:z.None}}const d=ut(u,this.oldRect);return this.oldRect=u,{rect:d,type:z.DrawWork,dataType:F.Local,...this.baseConsumeResult}}consumeAll(){var a;const t=this.workId;if(this.tmpPoints.length<2)return{type:z.RemoveNode,removeIds:[t]};const e=this.fullLayer,o=this.draw({workId:t,layer:e});this.oldRect=o;const n=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),i=zt(n);return(a=this.vNodes)==null||a.setInfo(t,{rect:o,op:n,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&Y.getCenterPos(o,e)}),{rect:o,type:z.FullWork,dataType:F.Local,ops:i,isSync:!0,...this.baseConsumeResult}}draw(t){const{workId:e,layer:o}=t,{strokeColor:n,thickness:i,zIndex:a,scale:c,rotate:l,translate:h,strokeType:u,eraserlines:d}=this.workOptions,p=o.worldPosition,f=o.worldScaling,{d:I,rect:y,isDot:v}=this.computDrawPoints(i,u),m=[y.x+y.w/2,y.y+y.h/2],w=new lt.Group({pos:m,anchor:[.5,.5],size:[y.w,y.h],name:e,id:e,normalize:!0,zIndex:a}),S={pos:[0,0],normalize:!0,d:I,fillColor:n,strokeColor:n,lineDash:u===X.Dotted&&!v?[1,i*2]:u===X.LongDotted&&!v?[i,i*2]:void 0,lineCap:u===X.Normal||v?void 0:"round",lineWidth:u===X.Normal||v?0:i};c&&(S.scale=c),l&&(S.rotate=l),h&&(S.translate=h);const N=new lt.Path(S);if(w.append(N),d&&this.drawEraserlines({group:w,eraserlines:d,pos:m,layer:o}),this.replace(o,e,w),l||c||h){const x=N.getBoundingClientRect();return{x:Math.floor(x.x-Y.SafeBorderPadding),y:Math.floor(x.y-Y.SafeBorderPadding),w:Math.floor(x.width+Y.SafeBorderPadding*2),h:Math.floor(x.height+Y.SafeBorderPadding*2)}}return{x:Math.floor(y.x*f[0]+p[0]-Y.SafeBorderPadding),y:Math.floor(y.y*f[1]+p[1]-Y.SafeBorderPadding),w:Math.floor(y.w*f[0]+2*Y.SafeBorderPadding),h:Math.floor(y.h*f[1]+2*Y.SafeBorderPadding)}}computDrawPoints(t,e){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.straightTipWidth?this.computFullPoints(t,e):this.computDotPoints(t)}computFullPoints(t,e){const o=k.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),n=k.Per(o).mul(t/2),i=B.Sub(this.tmpPoints[0],n),a=B.Add(this.tmpPoints[0],n),c=B.Sub(this.tmpPoints[1],n),l=B.Add(this.tmpPoints[1],n),h=B.GetSemicircleStroke(this.tmpPoints[1],c,-1,8),u=B.GetSemicircleStroke(this.tmpPoints[0],a,-1,8),d=[i,c,...h,l,a,...u];let p;return e!==X.Normal?p=qt(this.tmpPoints,!1):p=qt(d,!0),{d:p,rect:dt(d),isDot:!1,pos:this.tmpPoints[0].XY}}computDotPoints(t){const e=B.GetDotStroke(this.tmpPoints[0],t/2,8);return{d:qt(e,!0),rect:dt(e),isDot:!0,pos:this.tmpPoints[0].XY}}updateTempPoints(t){const e=t.slice(-2),o=new B(e[0],e[1]),n=this.tmpPoints[0],{thickness:i}=this.workOptions;if(n.isNear(o,i))return!1;if(this.tmpPoints.length===2){if(o.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=o}else this.tmpPoints.push(o);return!0}consumeService(t){var c,l;const{op:e,isFullWork:o}=t,n=(c=this.workId)==null?void 0:c.toString();if(!n)return;this.tmpPoints.length=0;for(let h=0;h<e.length;h+=3)this.tmpPoints.push(new B(e[h],e[h+1],e[h+2]));const i=o?this.fullLayer:this.drawLayer||this.fullLayer,a=this.draw({workId:n,layer:i});return this.oldRect=a,(l=this.vNodes)==null||l.setInfo(n,{rect:a,op:e,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:a&&Y.getCenterPos(a,i)}),a}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(t){var l,h;const{node:e,opt:o,vNodes:n}=t,{strokeColor:i,strokeType:a}=o,c=n.get(e.name);return i&&(e.tagName==="GROUP"?e.children.forEach(u=>{u.setAttribute("strokeColor",i),u.getAttribute("fillColor")&&u.setAttribute("fillColor",i)}):(e.setAttribute("strokeColor",i),e.setAttribute("fillColor",i)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=i)),a&&(c!=null&&c.opt)&&((h=c.opt)!=null&&h.strokeType)&&(c.opt.strokeType=a),c&&n.setInfo(e.name,c),Y.updateNodeOpt(t)}}const Gt=class Gt extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.proportional);M(this,"toolsType",C.Text);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"oldRect");this.workOptions=t.toolsOpt}consume(){return{type:z.None}}consumeAll(){return{type:z.None}}consumeService(){}async draw(t){const{workId:e,layer:o,isDrawLabel:n}=t,{boxSize:i,boxPoint:a,zIndex:c,eraserlines:l}=this.workOptions,h=o.worldPosition,u=o.worldScaling;if(!a||!i)return;const d={name:e,id:e,pos:[a[0],a[1]],anchor:[0,0],size:i,zIndex:c},p=new lt.Group(d),f={x:a[0],y:a[1],w:i[0],h:i[1]},I={x:Math.floor(f.x*u[0]+h[0]),y:Math.floor(f.y*u[1]+h[1]),w:Math.floor(f.w*u[0])+2,h:Math.floor(f.h*u[1])+2};if(this.replace(o,e,p),n&&o&&this.workOptions.text){const y=await Gt.createLabels(this.workOptions,o,I),{labels:v,maxWidth:m}=y;p.append(...v),I.w=Math.ceil(Math.max(m*o.worldScaling[0],I.w))}return l&&this.drawEraserlines({group:p,eraserlines:l,pos:[a[0],a[1]],layer:o}),I}async consumeServiceAsync(t){var l,h,u,d;const e=(l=this.workId)==null?void 0:l.toString();if(!e)return;const{isFullWork:o,replaceId:n,isDrawLabel:i}=t;this.oldRect=n&&((u=(h=this.vNodes)==null?void 0:h.get(n))==null?void 0:u.rect)||void 0;const a=o?this.fullLayer:this.drawLayer||this.fullLayer,c=await this.draw({workId:e,layer:a,isDrawLabel:typeof i>"u"&&this.workOptions.workState===b.Done||i});return(d=this.vNodes)==null||d.setInfo(e,{rect:c,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&Y.getCenterPos(c,a)}),c}updataOptService(){}async updataOptServiceAsync(t,e){var f,I;if(!this.workId)return;const o=this.workId.toString(),{fontColor:n,fontBgColor:i,bold:a,italic:c,lineThrough:l,underline:h,zIndex:u}=t,d=(f=this.vNodes)==null?void 0:f.get(o);if(!d)return;n&&(d.opt.fontColor=n),i&&(d.opt.fontBgColor=i),a&&(d.opt.bold=a),c&&(d.opt.italic=c),he(l)&&(d.opt.lineThrough=l),he(h)&&(d.opt.underline=h),Wt(u)&&(d.opt.zIndex=u),this.oldRect=d.rect;const p=await this.draw({workId:o,layer:this.fullLayer,isDrawLabel:typeof e>"u"&&this.workOptions.workState===b.Done||e});return(I=this.vNodes)==null||I.setInfo(o,{rect:p,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:p&&Y.getCenterPos(p,this.fullLayer)}),p}clearTmpPoints(){this.tmpPoints.length=0}static getSafetySnippetRatio(t){const e=(t==null?void 0:t.parent).displayRatio||1,o=Math.ceil(t.worldScaling[0]*10)/10;let n=o;return o>=.2&&o<1?n=o*e:o<=2&&o>=1?n=o*e*1.6:o>2&&o<=3?n=o*e*1.4:o>3&&o<=4?n=o*e*.8:o>4&&(n=o*e*.6),Math.floor(n*1e3)/1e3}static getSafetySnippetFontLength(t){return Math.floor(Gt.textImageSnippetSize*3/4/t)||1}static async createLabels(t,e,o){var P;const n=[],{x:i,y:a}=o,{width:c,height:l}=(P=e.parent)==null?void 0:P.parent,h=Ne(t.text),u=h.length,{fontSize:d,lineHeight:p,bold:f,textAlign:I,italic:y,fontFamily:v,verticalAlign:m,fontColor:w,fontBgColor:S,underline:N,lineThrough:T}=t,x=Gt.getSafetySnippetRatio(e)||1,L=Math.floor(d*x),D=Gt.getSafetySnippetFontLength(L);let A=0;for(let E=0;E<u;E++){const j=h[E],_=p||L*1.5;if(j){const nt=Of(j),tt=[0,0],V=[0,d*1.2];m==="middle"&&(tt[1]=E*d*1.2+5);const K=[0,-d*.15];tt[0]=5;const $=Math.sin(Math.PI/180*20);let G=0;const J=[];let rt=0;for(;rt<nt;){I==="left"&&(K[0]=G),rt===0&&y==="italic"&&(K[0]=K[0]-$/2*d);const ot=j.slice(rt,rt+D),at={anchor:[0,0],pos:K,text:ot,fontFamily:v,fontSize:L,lineHeight:_,strokeColor:w,fontWeight:f,fillColor:w,textAlign:I,fontStyle:y,scale:[1/x,1/x]},W=new lt.Label(at),it=await W.textImageReady;let ht=!0;if(it){const vt=it.rect&&it.rect[2],Kt=it.rect&&it.rect[3];if(vt&&Kt){const Bt=vt/x,Pt=Kt/x;G=Bt+G,y==="italic"&&(f==="bold"?G=G-$*d*1.2:G=G-$*d),((K[0]+tt[0]+Bt)*e.worldScaling[0]+i<=0||(K[0]+tt[0])*e.worldScaling[0]+i>=c||(K[1]+tt[1]+Pt)*e.worldScaling[1]+a<=0||(K[1]+tt[1])*e.worldScaling[1]+a>=l)&&(W.disconnect(),ht=!1),ht&&J.push(W)}}rt+=D}V[0]=G,y==="italic"&&(V[0]=V[0]+$*d),A=Math.max(A,V[0]);let It=!0;if(((tt[0]+V[0])*e.worldScaling[0]+i<=0||tt[0]*e.worldScaling[0]+i>=c||(tt[1]+V[1])*e.worldScaling[0]+a<=0||tt[1]*e.worldScaling[1]+a>=l)&&(It=!1),It){if(N){const W=Math.floor(d/10),it={normalize:!1,pos:[0,d*1.1+W/2],lineWidth:W,points:[0,0,Math.ceil(V[0]),0],strokeColor:w,className:"underline"},ht=new lt.Polyline(it);J.push(ht)}if(T){const W={normalize:!1,pos:[0,d*1.2/2],lineWidth:Math.floor(d/10),points:[0,0,Math.ceil(V[0]),0],strokeColor:w,className:"lineThrough"},it=new lt.Polyline(W);J.push(it)}const ot={pos:tt,anchor:[0,0],size:V,bgcolor:S},at=new lt.Group(ot);at.append(...J),n.push(at)}}}return{labels:n,maxWidth:A}}static updateNodeOpt(t){const{node:e,opt:o,vNodes:n,targetNode:i}=t,{fontBgColor:a,fontColor:c,translate:l,originPoint:h,scenePoint:u,scale:d,bold:p,italic:f,lineThrough:I,underline:y,fontSize:v,textInfos:m,zIndex:w}=o,S=i&&Vt(i)||n.get(e.name);if(!S||!e.parent)return;const T=S.opt;if(Wt(w)&&(e.setAttribute("zIndex",w),S.opt.zIndex=w),c&&T.fontColor&&(T.fontColor=c,e.children.forEach(x=>{x.tagName==="GROUP"&&x.children.forEach(L=>{L.tagName==="LABEL"?(L.setAttribute("fillColor",c),L.setAttribute("strokeColor",c)):L.tagName==="POLYLINE"&&L.setAttribute("strokeColor",c)})})),a&&T.fontBgColor&&(T.fontBgColor=a,e.children.forEach(x=>{x.tagName==="GROUP"&&x.setAttribute("bgcolor",a)})),p&&(T.bold=p),f&&(T.italic=f),he(I)&&(T.lineThrough=I),he(y)&&(T.underline=y),v&&(T.fontSize=v),h&&u&&d&&i&&T.boxPoint){const x=m==null?void 0:m.get(e.name);if(x){const{fontSize:P,boxSize:E}=x;T.boxSize=E||T.boxSize,T.fontSize=P||T.fontSize}const L=[T.boxPoint[0],T.boxPoint[1]];Bo(T.boxPoint,u,d,l);const D=[S.op[0],S.op[1]],A=[D[0]-L[0],D[1]-L[1]];if(S.centerPos=[S.centerPos[0]+A[0],S.centerPos[1]+A[1]],S.opt.eraserlines)for(const P of Object.values(S.opt.eraserlines)){const{op:E,thickness:j}=P;P.thickness=j*Math.max(d[0],d[1]);for(let _=0;_<E.length;_++)Fo(E[_],u,d,l)}}else if(l&&T.boxPoint&&(T.boxPoint=[T.boxPoint[0]+l[0],T.boxPoint[1]+l[1]],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:L}=x;for(let D=0;D<L.length;D++){const A=L[D].map((P,E)=>E%2?P+l[1]:P+l[0]);x.op[D]=A}}return S&&n.setInfo(e.name,S),S==null?void 0:S.rect}static getRectFromLayer(t,e){const o=t.getElementsByName(e)[0];if(o){const n=o.getBoundingClientRect();let i={x:Math.floor(n.x),y:Math.floor(n.y),w:Math.floor(n.width+2),h:Math.floor(n.height+2)};return o.children.forEach(a=>{if(a.tagName==="GROUP"){const c=o.getBoundingClientRect();i=ut(i,{x:Math.floor(c.x),y:Math.floor(c.y),w:Math.floor(c.width+2),h:Math.floor(c.height+2)})}}),i}}};M(Gt,"textImageSnippetSize",1024*4),M(Gt,"SafeBorderPadding",30);let Ge=Gt;const de=class de extends Y{constructor(t,e){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.none);M(this,"toolsType",C.PencilEraser);M(this,"serviceWork");M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"worldPosition");M(this,"worldScaling");M(this,"eraserRect");M(this,"eraserPolyline");this.serviceWork=e,this.workOptions=t.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}consumeService(){}createEraserRect(t){const e=t[0]*this.worldScaling[0]+this.worldPosition[0],o=t[1]*this.worldScaling[1]+this.worldPosition[1],{width:n,height:i}=de.eraserSizes[this.workOptions.thickness];this.eraserRect={x:e-n*.5,y:o-i*.5,w:n,h:i},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]),o=new k(this.tmpPoints[2],this.tmpPoints[3]),n=k.Sub(o,e).uni(),i=k.Dist(e,o),{width:a,height:c}=de.eraserSizes[this.workOptions.thickness],l=Math.min(a,c),h=Math.round(i/l);if(h>1){const u=[];for(let d=0;d<h;d++){const p=k.Mul(n,d*l);u.push(this.tmpPoints[0]+p.x,this.tmpPoints[1]+p.y)}return u.concat(t)}}return t}isNear(t,e){const o=new k(t[0],t[1]),n=new k(e[0],e[1]),{width:i,height:a}=de.eraserSizes[this.workOptions.thickness];return k.Dist(o,n)<Math.hypot(i,a)*.5}cutPolyline(t,e){let o=[e],n=0;for(;n<t.length;){const c=t[n];if(c.length<2)break;o=i(o,c),n++}return o;function i(c,l){const h=c;for(let u=0;u<c.length;u++){const d=c[u],p=d.findIndex((f,I)=>I<d.length-1?a([f,d[I+1]],[l[0],l[1]]):!1);if(p!==-1&&p>-1){const f=[],I=d.slice(0,p+1);if(k.Equals(d[p],l[0])||I.push(l[0].clone().setz(d[p].z)),I.length>1&&f.push(I),p+l.length-1<d.length-1){const y=p+l.length-1,v=d.slice(y),m=l[l.length-1];k.Equals(d[y],m)||v.unshift(m.clone().setz(d[y].z)),v.length>1&&f.push(v)}return h.splice(u,1,...f),h}}return h}function a(c,l){const h=k.Sub(c[1],c[0]),u=k.Sub(l[1],l[0]),d=k.Sub(l[0],c[0]);return Math.abs(k.Cpr(h,u))<.1&&Math.abs(k.Cpr(h,d))<.1}}isSamePoint(t,e){return t[0]===e[0]&&t[1]===e[1]}translateIntersect(t){const e=[];for(let o=0;o<t.length;o++){const n=t[o].filter((c,l,h)=>!(l>0&&this.isSamePoint(c,h[l-1]))),i=[];let a=0;for(;a<n.length;){const c=n[a],l=new k(c[0],c[1]);i.push(l),a++}e.push(i)}return e}isLineEraser(t,e){return!(t===C.Pencil&&!e)}remove(t){const{curNodeMap:e,removeIds:o,newWorkDatas:n}=t;let i;for(const[a,c]of e.entries())if(c.rect&&this.eraserRect&&this.eraserPolyline&&be(this.eraserRect,c.rect)){const{op:l,toolsType:h}=c,u=this.isLineEraser(h,!1),d=[],p=[];for(let I=0;I<l.length;I+=3){const y=new k(l[I]*this.worldScaling[0]+this.worldPosition[0],l[I+1]*this.worldScaling[1]+this.worldPosition[1],l[I+2]);p.push(y),d.push(new B(y.x,y.y))}const f=d.length&&dt(d)||c.rect;if(be(f,this.eraserRect)){if(p.length>1){const I=Lo.polyline(p.map(y=>y.XY),this.eraserPolyline);if(I.length&&(o.add(c.name),!u)){const y=this.translateIntersect(I),v=this.cutPolyline(y,p);for(let m=0;m<v.length;m++){const w=`${a}_s_${m}`,S=[];v[m].forEach(N=>{S.push((N.x-this.worldPosition[0])/this.worldScaling[0],(N.y-this.worldPosition[1])/this.worldScaling[1],N.z)}),c.opt&&c.toolsType&&this.vNodes&&(this.vNodes.setInfo(w,{rect:f,op:S,opt:c.opt,canRotate:c.canRotate,scaleType:c.scaleType,toolsType:c.toolsType}),n.set(w,{workId:w,op:S,opt:c.opt,toolsType:c.toolsType}))}}}else o.add(c.name);i=ut(i,f)}}return o.forEach(a=>{var c;return(c=this.vNodes)==null?void 0:c.delete(a)}),i&&(i.x-=Y.SafeBorderPadding,i.y-=Y.SafeBorderPadding,i.w+=Y.SafeBorderPadding*2,i.h+=Y.SafeBorderPadding*2),i}consume(t){const{op:e}=t.data;if(!e||e.length===0)return{type:z.None,...this.baseConsumeResult};const o=this.tmpPoints.length;if(o>1&&this.isNear([e[0],e[1]],[this.tmpPoints[o-2],this.tmpPoints[o-1]]))return{type:z.None,...this.baseConsumeResult};o<3?this.tmpPoints.push(e[0],e[1]):this.tmpPoints.splice(2,2,e[0],e[1]);const n=this.computRectCenterPoints();let i;const a=new Set,c=new Map;if(!this.vNodes)return{type:z.None,...this.baseConsumeResult};this.vNodes.setTarget();const l=this.getUnLockNodeMap(this.vNodes.getLastTarget());for(let h=0;h<n.length-1;h+=2){this.createEraserRect(n.slice(h,h+2));const u=this.remove({curNodeMap:l,removeIds:a,newWorkDatas:c});i=ut(i,u)}if(this.vNodes.deleteLastTarget(),i&&a.size){for(const h of c.keys())a.has(h)&&c.delete(h);return{type:z.RemoveNode,rect:i,removeIds:[...a],newWorkDatas:c}}return{type:z.None,...this.baseConsumeResult}}consumeAll(t){return this.consume(t)}clearTmpPoints(){this.tmpPoints.length=0}getUnLockNodeMap(t){var e;if(this.serviceWork){const o=Vt(t),n=this.serviceWork.selectorWorkShapes,i=this.serviceWork.workShapes;for(const a of n.values())if((e=a.selectIds)!=null&&e.length)for(const c of a.selectIds)o.delete(c);for(const a of i.keys())o.delete(a);return o}return t}};M(de,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));let Ze=de;const xe=class xe extends Y{constructor(t){super(t);M(this,"canRotate",!1);M(this,"scaleType",ct.none);M(this,"toolsType",C.BitMapEraser);M(this,"tmpPoints",[]);M(this,"workOptions");M(this,"worldPosition");M(this,"worldScaling");M(this,"eraserRect");M(this,"eraserPolyline");M(this,"syncUnitTime",xt.syncOpt.interval);M(this,"syncIndex",0);M(this,"syncTimestamp");this.workOptions=t.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling,this.syncTimestamp=0}consumeService(t){const{op:e,isFullWork:o}=t;this.tmpPoints.length=0;for(let c=0;c<e.length;c+=3){const l=new B(e[c],e[c+1],e[c+2]);if(this.tmpPoints.length>0){const h=this.tmpPoints[this.tmpPoints.length-1],u=k.Sub(l,h).uni();l.setv(u)}this.tmpPoints.push(l)}if(this.tmpPoints.length<2)return;const n=this.tmpPoints[0].z*2,i=o?this.fullLayer:this.drawLayer||this.fullLayer;return this.draw({consumePoints:this.tmpPoints,layer:i,thickness:n})}updateTempPoints(t,e){let o=this.tmpPoints.length-1;const n=Date.now();for(let i=0;i<t.length;i+=2){const a=this.tmpPoints.length,c=new B(t[i],t[i+1]);if(a===0){this.tmpPoints.push(c);continue}const l=a-1,h=this.tmpPoints[l],u=k.Sub(c,h).uni();c.isNear(h,e/2)||(k.Equals(u,h.v,.02)&&(this.tmpPoints.pop(),o--),c.setv(u),c.setT(n),this.tmpPoints.push(c))}return Math.max(o,0)}getChangeNodes(t){if(!this.vNodes)return;const e=this.worldPosition;let o=dt(this.tmpPoints,t);o=To(o,e),o=Lf(o,this.worldScaling,e);const{nodeRange:n}=this.vNodes.getRectIntersectRange(o);if(!n.size)return;const i=[];let a=0;for(let l=1;l<this.tmpPoints.length;l++){const h=this.tmpPoints[l-1],u=this.tmpPoints[l];if(l===1&&a===0&&(i[a]=[h.XY]),i[a].push(u.XY),l<this.tmpPoints.length-1){const d=u.getAngleByPoints(h,this.tmpPoints[l+1]);(d<90||d>270)&&(a++,i[a]=[u.XY])}}this.tmpPoints.length===1&&i.length===0&&i.push([this.tmpPoints[0].XY,this.tmpPoints[0].XY]);const c=new Map;for(const[l,h]of n.entries()){let u=To(h.rect,[-e[0],-e[1]]);u={x:u.x/this.worldScaling[0],y:u.y/this.worldScaling[1],w:u.w/this.worldScaling[0],h:u.h/this.worldScaling[1]};const d=[u.x,u.y,u.x+u.w,u.y+u.h],p=[],f=[];for(const y of i)Lo.polyline(y,d,p);if(p.length&&h.opt)for(const y of p){const v=[];for(let m=0;m<y.length;m++)m!==0&&le(y[m],y[m-1])||v.push(...y[m]);f.push(v)}h.opt.eraserlines||(h.opt.eraserlines=[]),h.opt.eraserlines&&(h.opt.eraserlines.push({op:f,thickness:t}),c.set(l,h))}return c}async reRenderEffectNodes(t){let e;const{willUpdateNodes:o,worker:n}=t;for(const[i,a]of o.entries()){const{toolsType:c}=a,l=n.createWorkShapeNode({workId:i,toolsType:c,toolsOpt:a.opt});l==null||l.setWorkId(i);let h;if(c===C.Image)h=await l.consumeServiceAsync({isFullWork:!0,replaceId:i,worker:n});else if(c===C.Text)h=await l.consumeServiceAsync({isFullWork:!0,replaceId:i});else try{h=l==null?void 0:l.consumeService({op:a.op,isFullWork:!0,replaceId:i})}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:o}=this.workOptions,{width:n,height:i}=xe.eraserSizes[o],a=Math.max(n,i)/this.worldScaling[0],c=this.tmpPoints.length,l=this.tmpPoints[this.tmpPoints.length-1],h=this.updateTempPoints(e,a),u=this.tmpPoints[this.tmpPoints.length-1];if(c===this.tmpPoints.length&&u.equalsXY(l.x,l.y))return{type:z.None,...this.baseConsumeResult};this.syncIndex=Math.min(this.syncIndex,h,Math.max(0,this.tmpPoints.length-2));const d=this.syncIndex;this.syncTimestamp===0&&(this.syncTimestamp=Date.now());let p=!1;const f=this.tmpPoints.slice(h),I=this.draw({consumePoints:f,layer:this.fullLayer,thickness:a});f[0].t-this.syncTimestamp>this.syncUnitTime&&(p=!0,this.syncTimestamp=f[0].t,this.syncIndex=this.tmpPoints.length);const y=[];return this.tmpPoints.slice(d).forEach(v=>{y.push(v.x,v.y,a/2)}),{...this.baseConsumeResult,type:z.DrawWork,dataType:F.Local,rect:I,op:p?y:void 0,index:p?d*3:void 0,updateNodeOpt:{useAnimation:!0}}}draw(t){const{consumePoints:e,layer:o,thickness:n}=t,i=this.workId;let a=o.getElementsByName(this.workId)[0],c=dt(e,n);const h=[{op:[e.map(u=>[u.x,u.y]).flat(1)],thickness:n}];return a||(a=new lt.Group({normalize:!0,name:i,pos:[0,0],anchor:[.5,.5],bgcolor:"rgba(0,0,0,0.3)",zIndex:9999}),o.appendChild(a)),this.drawEraserlines({group:a,eraserlines:h,pos:[0,0],layer:o,isClear:!0}),c={x:Math.floor(c.x*this.worldScaling[0]+this.worldPosition[0]-Y.SafeBorderPadding),y:Math.floor(c.y*this.worldScaling[1]+this.worldPosition[1]-Y.SafeBorderPadding),w:Math.floor(c.w*this.worldScaling[0]+2*Y.SafeBorderPadding),h:Math.floor(c.h*this.worldScaling[1]+2*Y.SafeBorderPadding)},c}consumeAll(){const t=this.fullLayer.getElementsByName(this.workId);let e;if(t.length&&(e=Y.getRectFromLayer(this.fullLayer,this.workId)),t.forEach(u=>{u.remove(),u.disconnect()}),!this.tmpPoints.length)return{type:z.None,...this.baseConsumeResult};const{thickness:o}=this.workOptions,{width:n,height:i}=xe.eraserSizes[o],a=Math.max(n,i)/this.worldScaling[0],c=this.getChangeNodes(a);if(!(c!=null&&c.size))return{type:z.None,...this.baseConsumeResult,rect:e};const l=[];this.tmpPoints.map(u=>{l.push(u.x,u.y,a/2)});const h=zt(l);return{...this.baseConsumeResult,type:z.FullWork,dataType:F.Local,rect:e,ops:h,willUpdateNodes:c}}clearTmpPoints(){this.tmpPoints.length=0}};M(xe,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50})]));let qe=xe;function wi(r){switch(r){case C.Arrow:return di;case C.Pencil:return ci;case C.Straight:return mi;case C.Ellipse:return pi;case C.Polygon:case C.Triangle:return Mi;case C.Star:case C.Rhombus:return gi;case C.Rectangle:return fi;case C.SpeechBalloon:return yi;case C.Text:return Ge;case C.LaserPen:return li;case C.Eraser:return Qe;case C.PencilEraser:return Ze;case C.BitMapEraser:return qe;case C.Selector:return $e;case C.Image:return Le}}function Ii(r,s){const{toolsType:t,...e}=r;switch(t){case C.Arrow:return new di(e);case C.Pencil:return new ci(e);case C.Straight:return new mi(e);case C.Ellipse:return new pi(e);case C.Polygon:case C.Triangle:return new Mi(e);case C.Star:case C.Rhombus:return new gi(e);case C.Rectangle:return new fi(e);case C.SpeechBalloon:return new yi(e);case C.Text:return new Ge(e);case C.LaserPen:return new li(e);case C.Eraser:return new Qe(e,s);case C.BitMapEraser:return new qe(e);case C.PencilEraser:return new Ze(e,s);case C.Selector:return e.vNodes?new $e({...e,vNodes:e.vNodes,drawLayer:e.fullLayer}):void 0;case C.Image:return new Le(e);default:return}}function vi(r){const s=[],t=["PATH","SPRITE","POLYLINE","RECT","ELLIPSE","LABEL"];for(const e of r){if(e.tagName==="GROUP"&&e.children.length)return vi(e.children);e.tagName&&t.includes(e.tagName)&&s.push(e)}return s}function ut(r,s){if(r&&s){const t=Math.min(r.x,s.x),e=Math.min(r.y,s.y),o=Math.max(r.x+r.w,s.x+s.w),n=Math.max(r.y+r.h,s.y+s.h),i=o-t,a=n-e;return{x:t,y:e,w:i,h:a}}return s||r}function Ni(r,s){if(r&&s){const t=Math.min(r.originX,s.originX),e=Math.min(r.originY,s.originY),o=Math.max(r.originX+r.width,s.originX+s.width),n=Math.max(r.originY+r.height,s.originY+s.height),i=o-t,a=n-e;return{originX:t,originY:e,width:i,height:a}}return s||r}function dt(r,s=0){const t={x:0,y:0,w:0,h:0};let e=1/0,o=1/0,n=-1/0,i=-1/0;return r.forEach(a=>{const[c,l]=a.XY;e=Math.min(e,c-s),o=Math.min(o,l-s),n=Math.max(n,c+s),i=Math.max(i,l+s)}),t.x=e,t.y=o,t.w=n-e,t.h=i-o,t}function be(r,s){return!(r.x+r.w<s.x||r.x>s.x+s.w||r.y+r.h<s.y||r.y>s.y+s.h)}function To(r,s){return{x:r.x+s[0],y:r.y+s[1],w:r.w,h:r.h}}function zf(r,s){const t=new k(r.x,r.y),e=new k(r.x+r.w,r.y),o=new k(r.x+r.w,r.y+r.h),n=new k(r.x,r.y+r.h),i=new k(r.x+r.w/2,r.y+r.h/2),a=Math.PI*s/180,c=k.RotWith(t,i,a),l=k.RotWith(e,i,a),h=k.RotWith(o,i,a),u=k.RotWith(n,i,a);return[c,l,h,u]}function Ti(r,s){const t=zf(r,s);return dt(t)}function Lf(r,s,t){const e=new k(r.x,r.y),o=new k(r.x+r.w,r.y),n=new k(r.x+r.w,r.y+r.h),i=new k(r.x,r.y+r.h),a=new k(t[0],t[1]),c=new k(s[0],s[1]),l=k.ScaleWOrigin(e,c,a),h=k.ScaleWOrigin(o,c,a),u=k.ScaleWOrigin(n,c,a),d=k.ScaleWOrigin(i,c,a);return dt([l,h,u,d])}function bf(r,s,t){const e=new k(s[0],s[1]);for(let o=0;o<r.length;o+=3){const n=new k(r[o],r[o+1]),i=Math.PI*t/180,a=k.RotWith(n,e,i);r[o]=a.x,r[o+1]=a.y}}function Pf(r,s,t){const e=new k(s[0],s[1]);for(let o=0;o<r.length;o+=2){const n=new k(r[o],r[o+1]),i=Math.PI*t/180,a=k.RotWith(n,e,i);r[o]=a.x,r[o+1]=a.y}}function Bo(r,s,t,e=[0,0]){const o=new k(s[0],s[1]);for(let n=0;n<r.length;n+=3){const i=new k(r[n],r[n+1]),a=new k(t[0],t[1]),c=k.ScaleWOrigin(i,a,o);r[n]=c.x+e[0],r[n+1]=c.y+e[1]}}function Fo(r,s,t,e=[0,0]){const o=new k(s[0],s[1]);for(let n=0;n<r.length;n+=2){const i=new k(r[n],r[n+1]),a=new k(t[0],t[1]),c=k.ScaleWOrigin(i,a,o);r[n]=c.x+e[0],r[n+1]=c.y+e[1]}}function Si(r,s){return r[0]>=s.x&&r[0]<=s.x+s.w&&r[1]>=s.y&&r[1]<=s.y+s.h}function Ci(r,s){const t=r<=s?1:r/s,e=s<=r?1:s/r;return[t,e]}function jf(r){for(const s of r)if(isNaN(s)||s===1/0||s===-1/0)return!1;return!0}const Df=r=>{if(r.tagName==="GROUP"){const s=Object.getOwnPropertySymbols(r).find(t=>t.toString()==="Symbol(sealed)");if(s&&r[s])return!0}return!1},Ef=r=>!r.isHid;function ne(r){return`${Je(r.x)},${Je(r.y)} `}function re(r,s){return`${Je((r.x+s.x)/2)},${Je((r.y+s.y)/2)} `}function Je(r){return+r.toFixed(4)}const Zt=(r,s)=>new Promise(function(t){window.requestIdleCallback?requestIdleCallback(()=>{t(1)},{timeout:s}):setTimeout(()=>{t(2)},s)}).then(function(){r()},()=>{r()}),Jt=r=>{const s=(r==null?void 0:r.webkitBackingStorePixelRatio)||(r==null?void 0:r.mozBackingStorePixelRatio)||(r==null?void 0:r.msBackingStorePixelRatio)||(r==null?void 0:r.oBackingStorePixelRatio)||(r==null?void 0:r.backingStorePixelRatio)||1;return Math.max(1,(window.devicePixelRatio||1)/s)},Af=(r,s)=>r.x+r.w<s.x||r.x>s.x+s.w||r.y+r.h<s.y||r.y>s.y+s.h?ke.outside:r.x>=s.x&&r.y>=s.y&&r.x+r.w<=s.x+s.w&&r.y+r.h<=s.y+s.h?ke.inside:ke.intersect;function Of(r){let s=0;for(let t=0;t<r.length;t++){const e=r.charCodeAt(t);e>=1&&e<=126||65376<=e&&e<=65439?s++:s+=2}return s}class Rf{constructor(s,t){M(this,"plugin");M(this,"uid");M(this,"control");this.control=s,this.plugin=t,this.uid=t.displayer.uid}getNamespaceData(){var s;return st.toJS((s=this.plugin)==null?void 0:s.attributes[this.namespace])||{}}getUidFromKey(s){return s.split(Ot).length===2&&s.split(Ot)[0]||this.uid}isLocalId(s){return s.split(Ot).length===1}getLocalId(s){return s.split(Ot)[1]}isSelector(s){return this.getLocalId(s)===H}}const Ft=class Ft extends Rf{constructor(t,e,o){super(t,e);M(this,"namespace");M(this,"serviceStorage",{});M(this,"storage",{});M(this,"stateDisposer");M(this,"asyncClockState",!1);Ft.syncInterval=(o||Ft.syncInterval)*.5,this.namespace=Ft.namespace,this.serviceStorage=this.getNamespaceData(),this.storage=O.cloneDeep(this.serviceStorage)}getViewIdBySecenPath(t){const e=this.getNamespaceData();for(const[o,n]of Object.entries(e))if(n){for(const i of Object.keys(n))if(i===t)return o}}getScenePathData(t){const e=this.getNamespaceData();for(const o of Object.values(e))if(o){for(const n of Object.keys(o))if(n===t)return O.cloneDeep(o[n])}}getStorageData(t,e){const o=this.getNamespaceData();return o&&o[t]&&O.cloneDeep(o[t][e])||void 0}hasSelector(t,e){const o=this.storage&&this.storage[t]&&this.storage[t][e];return!!(o&&Object.keys(o).find(n=>this.isOwn(n)&&this.getLocalId(n)===H))}addStorageStateListener(t){this.stateDisposer=st.autorun(async()=>{var c;const e=this.getNamespaceData(),{diffView:o,diffScenePath:n,diffData:i}=this.diffFunByView(this.serviceStorage,e);this.serviceStorage=e;const a={};if(Object.keys(o).length>0){a.diffView=o;for(const[l,h]of Object.entries(o)){if(h&&h.newValue===void 0&&this.storage[l]){delete this.storage[l];continue}if(h&&h.newValue){this.storage[l]=O.cloneDeep(h.newValue);continue}}}if(Object.keys(n).length>0){a.diffScenePath=n;for(const[l,h]of Object.entries(n))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]=O.cloneDeep(d);continue}}}if(Object.keys(i).length>0){a.diffData=i;for(const[l,h]of Object.entries(i))if(h){const{viewId:u,scenePath:d,newValue:p}=h;if(u&&d){let f=this.storage[u],I=(c=this.storage[u])==null?void 0:c[d];if(f||(this.storage[u]={},f=this.storage[u],f[d]={},I=f[d]),I){if(I[l]&&p===void 0){delete I[l];continue}if(p&&u){I[l]=O.cloneDeep(p);continue}}}}}Object.keys(a).length>0&&t(a)})}removeStorageStateListener(){this.stateDisposer&&this.stateDisposer()}diffFunByView(t,e){const o=Ct(t),n=Ct(e),i={},a={},c={};for(const l of n)if(!o.includes(l)||t[l]===void 0){i[l]={newValue:e[l],oldValue:void 0};continue}for(const l of o){if(O.isEqual(t[l],e[l]))continue;if(!n.includes(l)||e[l]===void 0){i[l]={newValue:void 0,oldValue:t[l]};continue}const h=this.diffFunByScenePath(t[l],e[l],l);Object.assign(a,h.diffScenePath),Object.assign(c,h.diffData)}return{diffData:c,diffScenePath:a,diffView:i}}diffFunByScenePath(t,e,o){const n=Ct(t),i=Ct(e),a={},c={};for(const l of i)if(!n.includes(l)||t[l]===void 0){a[l]={newValue:e[l],oldValue:void 0,viewId:o};continue}for(const l of n){if(O.isEqual(t[l],e[l]))continue;if(!i.includes(l)||e[l]===void 0){a[l]={newValue:void 0,oldValue:t[l],viewId:o};continue}const h=this.diffFunByKeys(t[l],e[l],l,o);Object.assign(c,h)}return{diffScenePath:a,diffData:c}}diffFunByKeys(t,e,o,n){const i=Ct(t),a=Ct(e),c={};for(const l of a)(!i.includes(l)||t[l]===void 0)&&(c[l]={oldValue:void 0,newValue:e[l],viewId:n,scenePath:o});for(const l of i)if(!O.isEqual(t[l],e[l])){if(!a.includes(l)||e[l]===void 0){c[l]={newValue:void 0,oldValue:t[l],viewId:n,scenePath:o};continue}a.includes(l)&&(c[l]={oldValue:t[l],newValue:e[l],viewId:n,scenePath:o})}return c}transformKey(t){return this.uid+Ot+t}isOwn(t){return t.split(Ot)[0]===this.uid}dispatch(t){const{type:e,workId:o,ops:n,index:i,opt:a,toolsType:c,removeIds:l,updateNodeOpt:h,op:u,selectIds:d,isSync:p,scenePath:f,viewId:I}=t;if(I)switch(e){case z.Clear:const y={};f&&this.storage[I]&&this.storage[I][f]?(delete this.storage[I][f],this.setState(y,{isSync:p,viewId:I,scenePath:f})):this.storage[I]&&(delete this.storage[I],this.setState(y,{isSync:p,viewId:I,scenePath:""}));break;case z.CreateWork:if(f&&o&&c&&a){const N=this.isLocalId(o.toString())?this.transformKey(o):o;this.updateValue(N.toString(),{type:z.CreateWork,workId:o,toolsType:c,opt:a},{isSync:p,viewId:I,scenePath:f})}break;case z.DrawWork:if(f&&o&&typeof i=="number"&&(u!=null&&u.length)){const N=this.isLocalId(o.toString())?this.transformKey(o):o,T=this.storage[I]&&this.storage[I][f]&&this.storage[I][f][N]||void 0;if(T!=null&&T.ops||(T==null?void 0:T.type)===z.FullWork)return;const x=i?((T==null?void 0:T.op)||[]).slice(0,i).concat(u):u||(T==null?void 0:T.op),L=c||(T==null?void 0:T.toolsType),D=a||(T==null?void 0:T.opt),A=h||(T==null?void 0:T.updateNodeOpt);o&&L&&D&&x&&this.updateValue(N.toString(),{...T,type:z.DrawWork,workId:o,updateNodeOpt:A,toolsType:L,opt:D,op:x,index:i},{isSync:p,viewId:I,scenePath:f})}break;case z.FullWork:if(f&&o){const N=this.isLocalId(o.toString())?this.transformKey(o):o,T=this.storage[I]&&this.storage[I][f]&&this.storage[I][f][N]||void 0,x=h||(T==null?void 0:T.updateNodeOpt),L=c||(T==null?void 0:T.toolsType),D=a||(T==null?void 0:T.opt),A=n||(T==null?void 0:T.ops);L&&D&&this.updateValue(N.toString(),{type:z.FullWork,updateNodeOpt:x,workId:N,toolsType:L,opt:D,ops:A},{isSync:p,viewId:I,scenePath:f})}break;case z.RemoveNode:if(f&&(l!=null&&l.length)){const N=l.map(T=>this.isLocalId(T+"")?this.transformKey(T):T);this.storage[I]&&this.storage[I][f]&&Object.keys(this.storage[I][f]).map(T=>{N!=null&&N.includes(T)&&this.updateValue(T,void 0,{isSync:p,viewId:I,scenePath:f})})}break;case z.UpdateNode:if(f&&o&&(h||n||a)){const N=this.isLocalId(o.toString())?this.transformKey(o):o,T=this.storage[I]&&this.storage[I][f]&&this.storage[I][f][N]||void 0;T&&(T.updateNodeOpt=h,(n||u)&&(T.ops=n,T.op=u),a&&(T.opt=a),T.type=z.FullWork,this.updateValue(N.toString(),T,{isSync:p,viewId:I,scenePath:f}))}break;case z.Select:if(!f)return;let v;d!=null&&d.length&&(v=d.map(N=>this.isLocalId(N+"")?this.transformKey(N):N));const m=this.transformKey(H),w=this.storage[I]&&this.storage[I][f]&&this.storage[I][f][m]||void 0,S=a||(w==null?void 0:w.opt);v&&this.checkOtherSelector(m,v,{isSync:p,viewId:I,scenePath:f}),this.updateValue(m,v&&{type:z.Select,toolsType:C.Selector,opt:S,selectIds:v},{isSync:p,viewId:I,scenePath:f});break}}checkOtherSelector(t,e,o){const{viewId:n,scenePath:i}=o;for(const a of Object.keys(this.storage[n][i]))if(a!==t&&this.getLocalId(a)===H){const c=this.storage[n][i][a];if(c&&c.selectIds){const l=c.selectIds.filter(h=>!e.includes(h));l.length>0&&(c.selectIds=l),this.updateValue(a,l.length&&c||void 0,o)}}}setState(t,e){const{viewId:o,scenePath:n}=e,i=Ct(t);for(let a=0;a<i.length;a++){const c=i[a],l=t[c];typeof l<"u"?(this.storage[o]||(this.storage[o]={}),this.storage[o][n]||(this.storage[o][n]={}),this.storage[o][n][c]=l):delete this.storage[o][n][c]}this.runSyncService(e)}updateValue(t,e,o){const{viewId:n,scenePath:i}=o;e===void 0?delete this.storage[n][i][t]:(this.storage[n]||(this.storage[n]={}),this.storage[n][i]||(this.storage[n][i]={}),this.storage[n][i][t]=e),this.runSyncService(o)}runSyncService(t){this.asyncClockState||(this.asyncClockState=!0,setTimeout(()=>{t.isSync?(this.asyncClockState=!1,this.syncSerivice(t.isAfterUpdate)):Zt(()=>{this.asyncClockState=!1,this.syncSerivice(t.isAfterUpdate)},Ft.syncInterval)},t!=null&&t.isSync?0:Ft.syncInterval))}syncSerivice(t=!1){const e=Ct(this.serviceStorage),o=Ct(this.storage),n=new Map;for(const i of e){if(!o.includes(i)){n.set(i,void 0);continue}O.isEqual(this.serviceStorage[i],this.storage[i])||this.syncViewData(i,t)}for(const i of o)e.includes(i)||n.set(i,this.storage[i]);if(n.size>5)this.syncStorageView(this.storage,t);else for(const[i,a]of n.entries())this.syncUpdataView(i,a,t)}syncViewData(t,e=!1){const o=Ct(this.serviceStorage[t]),n=Ct(this.storage[t]),i=new Map;for(const a of o){if(!n.includes(a)){i.set(a,void 0);continue}O.isEqual(this.serviceStorage[t][a],this.storage[t][a])||this.syncScenePathData(t,a,e)}for(const a of n)o.includes(a)||i.set(a,this.storage[t][a]);if(i.size>5)this.syncStorageScenePath(t,this.storage[t],e);else for(const[a,c]of i.entries())this.syncUpdataScenePath(t,a,c,e)}syncScenePathData(t,e,o=!1){const n=Ct(this.serviceStorage[t][e]),i=Ct(this.storage[t][e]),a=new Map;for(const c of n){if(!i.includes(c)){a.set(c,void 0);continue}O.isEqual(this.serviceStorage[t][e][c],this.storage[t][e][c])||a.set(c,this.storage[t][e][c])}for(const c of i)n.includes(c)||a.set(c,this.storage[t][e][c]);if(a.size>5)this.syncStorageKey(t,e,this.storage[t][e],o);else for(const[c,l]of a.entries())this.syncUpdataKey(t,e,c,l,o)}syncUpdataView(t,e,o=!1){var i;Object.keys(this.serviceStorage).length?(o||(e===void 0?delete this.serviceStorage[t]:this.serviceStorage[t]=O.cloneDeep(e)),(i=this.plugin)==null||i.updateAttributes([this.namespace,t],e)):this.syncStorageView(this.storage,o)}syncStorageView(t,e=!1){var o;e||t&&(this.serviceStorage=O.cloneDeep(t)),(o=this.plugin)==null||o.updateAttributes([this.namespace],t)}syncUpdataScenePath(t,e,o,n=!1){var a;Object.keys(this.serviceStorage[t]).length?(n||(o===void 0?delete this.serviceStorage[t][e]:this.serviceStorage[t][e]=o),(a=this.plugin)==null||a.updateAttributes([this.namespace,t,e],o)):this.syncStorageScenePath(t,this.storage[t],n)}syncStorageScenePath(t,e,o=!1){var n;o||e&&(this.serviceStorage[t]=e),(n=this.plugin)==null||n.updateAttributes([this.namespace,t],e)}syncUpdataKey(t,e,o,n,i=!1){var c;Object.keys(this.serviceStorage[t][e]).length?(i||(n===void 0?delete this.serviceStorage[t][e][o]:this.serviceStorage[t][e][o]=n),(c=this.plugin)==null||c.updateAttributes([this.namespace,t,e,o],n)):this.syncStorageKey(t,e,this.storage[t][e],i)}syncStorageKey(t,e,o,n=!1){var i;n||(this.serviceStorage[t][e]=o),(i=this.plugin)==null||i.updateAttributes([this.namespace,t,e],o)}keyTransformWorkId(t){const e=t.split(Ot);return e.length===2?e[1]:t}destroy(){this.removeStorageStateListener(),this.serviceStorage={},this.storage={}}};M(Ft,"namespace","PluginState"),M(Ft,"syncInterval",500);let So=Ft;class Yf{constructor(){M(this,"roomMembers",[]);M(this,"onChangeHooks",new Set)}setRoomMembers(s){this.executChangeUidHook(this.roomMembers,s),this.roomMembers=s}executChangeUidHook(s,t){const e={online:t.map(o=>{var n;return((n=o.payload)==null?void 0:n.uid)||o.session}),offline:s.map(o=>{var n;return((n=o.payload)==null?void 0:n.uid)||o.session})};this.onChangeHooks.forEach(o=>o(e))}getRoomMember(s){return this.roomMembers.find(t=>{var e;return((e=t.payload)==null?void 0:e.uid)===s})}isOnLine(s){return!this.getRoomMember(s)}onUidChangeHook(s){this.onChangeHooks.add(s)}destroy(){this.onChangeHooks.clear()}}var Ut=(r=>(r[r.Text=1]="Text",r[r.Shape=2]="Shape",r))(Ut||{});const Wf="cursorhover",Uf=20,yt="mainView",St=class St{createProxy(s){const t=new Proxy(s,{get(e,o,n){const i=St.interceptors.hasOwnProperty(o)?St.interceptors:e;return Reflect.get(i,o,n)}});return St.proxyToRaw.set(t,s),t}};M(St,"proxyToRaw",new WeakMap),M(St,"interceptors",{entries(...s){return St.proxyToRaw.get(this).entries(...s)},forEach(...s){return St.proxyToRaw.get(this).forEach(...s)},size(){return St.proxyToRaw.get(this).size},get(s){return St.proxyToRaw.get(this).get(s)},set(s,t){return St.proxyToRaw.get(this).set(s,t)},delete(s,t){return St.proxyToRaw.get(this).delete(s)},clear(){return St.proxyToRaw.get(this).clear()}});let te=St;class Bf{constructor(s){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}=s;this.control=t,this.internalMsgEmitter=e;const o=new Map;this.proxyMap=new te;const n=this,i=te.interceptors.set;te.interceptors.set=function(c,l){return n.interceptors.set(c,l),i.call(this,c,l)};const a=te.interceptors.delete;te.interceptors.delete=function(c,l){return n.interceptors.delete(c,l),a.call(this,c)},this.editors=this.proxyMap.createProxy(o)}get collector(){return this.control.collector}filterEditor(s){const t=new Map;return this.editors.forEach((e,o)=>{e.viewId===s&&t.set(o,e)}),t}get interceptors(){return{set:(s,t)=>{var p,f,I,y,v,m,w,S;if(!this.collector)return!0;const{viewId:e,scenePath:o,canSync:n,canWorker:i,type:a,opt:c,dataType:l}=t;if(!i&&!n)return!0;const u=((p=this.collector)==null?void 0:p.isLocalId(s))?(f=this.collector)==null?void 0:f.transformKey(s):s,d=((I=this.collector)==null?void 0:I.storage[e])&&this.collector.storage[e][o]&&this.collector.storage[e][o][u]||void 0;d?d.toolsType===C.Text&&(i&&(this.control.worker.queryTaskBatchData({workId:s,msgType:z.UpdateNode}).forEach(N=>{var T;(T=this.control.worker)==null||T.taskBatchData.delete(N)}),(w=this.control.worker)==null||w.taskBatchData.add({workId:s,msgType:z.UpdateNode,dataType:l||F.Local,toolsType:C.Text,opt:c,viewId:e,scenePath:o,willRefresh:!0}),(S=this.control.worker)==null||S.runAnimation()),n&&Zt(()=>{var N;(N=this.collector)==null||N.dispatch({type:z.UpdateNode,workId:s,toolsType:C.Text,opt:c,viewId:e,scenePath:o})},this.control.worker.maxLastSyncTime)):a===Ut.Text&&(n&&((y=this.collector)==null||y.dispatch({type:c.text&&z.FullWork||z.CreateWork,workId:s,toolsType:C.Text,opt:c,isSync:!0,viewId:e,scenePath:o})),i&&((v=this.control.worker)==null||v.taskBatchData.add({workId:s,msgType:c.text&&z.FullWork||z.CreateWork,dataType:l||F.Local,toolsType:C.Text,opt:c,viewId:e,scenePath:o,willRefresh:!0}),(m=this.control.worker)==null||m.runAnimation()))},delete:s=>{var a,c;if(!this.collector)return!0;const t=this.editors.get(s);if(!t)return!0;const{viewId:e,scenePath:o,canSync:n,canWorker:i}=t;if(!i&&!n)return!0;i&&((a=this.control.worker)==null||a.taskBatchData.add({workId:s,toolsType:C.Text,msgType:z.RemoveNode,dataType:F.Local,viewId:e,scenePath:o,willRefresh:!0}),(c=this.control.worker)==null||c.runAnimation()),n&&Zt(()=>{var l;(l=this.collector)==null||l.dispatch({type:z.RemoveNode,removeIds:[s],toolsType:C.Text,viewId:e,scenePath:o})},this.control.worker.maxLastSyncTime)},clear(){return!0}}}computeTextActive(s,t){var n,i,a,c;const e=(n=this.control.viewContainerManager)==null?void 0:n.transformToScenePoint(s,t),o=(i=this.control.viewContainerManager)==null?void 0:i.getCurScenePath(t);t&&o&&((a=this.control.worker)==null||a.taskBatchData.add({msgType:z.GetTextActive,dataType:F.Local,op:e,viewId:t,scenePath:o}),(c=this.control.worker)==null||c.runAnimation())}checkEmptyTextBlur(){var t;let s=this.activeId;for(const[e,o]of this.editors.entries())if(o.opt.uid&&o.opt.uid===((t=this.collector)==null?void 0:t.uid)){s=e;break}if(s){const e=this.editors.get(s);(e==null?void 0:e.opt.text)&&(e==null?void 0:e.opt.text.replace(/\s*,/g,""))?this.unActive(s):this.delete(s,!0,!0)}}onCameraChange(s,t){var e,o;for(const[n,i]of this.editors.entries())if(i.viewId===t){const{boxPoint:a,boxSize:c}=i.opt,l=a&&((e=this.control.viewContainerManager)==null?void 0:e.transformToOriginPoint(a,i.viewId)),h=(o=this.control.viewContainerManager)==null?void 0:o.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:i.opt,scale:s.scale,type:Ut.Text,viewId:t,scenePath:h,canWorker:!1,canSync:!1};this.editors.set(n,u),this.control.viewContainerManager.setActiveTextEditor(t,this.activeId)}}}onServiceDerive(s){var f,I;const{workId:t,opt:e,msgType:o,viewId:n,scenePath:i,dataType:a}=s;if(!t||!n||!i)return;const c=t.toString();if(o===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,n)),d=this.control.viewContainerManager.getView(n),p={x:u&&u[0]||0,y:u&&u[1]||0,w:h&&h[0]||0,h:h&&h[1]||0,opt:e,type:Ut.Text,canWorker:!0,canSync:!1,dataType:a,scale:((I=d==null?void 0:d.cameraOpt)==null?void 0:I.scale)||1,viewId:n,scenePath:i};this.editors.set(c,p),a===F.Service&&e.workState===b.Done&&this.activeId===c&&(this.activeId=void 0),this.control.viewContainerManager.setActiveTextEditor(n,this.activeId)}updateForViewEdited(s,t){var o;this.editors.set(s,t);const e=(o=this.taskqueue.get(s))==null?void 0:o.resolve;e&&e(t)}active(s){var e;const t=this.editors.get(s);t&&t.viewId&&(t.opt.workState=b.Start,t.opt.uid=(e=this.collector)==null?void 0:e.uid,this.activeId=s,t.canWorker=!0,t.canSync=!0,this.editors.set(s,t),this.control.viewContainerManager.setActiveTextEditor(t.viewId,this.activeId))}unActive(s){const t=this.editors.get(s);t&&t.viewId&&(t.opt.workState=b.Done,t.opt.uid=void 0,t.canWorker=!0,t.canSync=!0,this.editors.set(s,t),this.activeId=void 0,this.control.viewContainerManager.setActiveTextEditor(t.viewId,this.activeId))}createTextForMasterController(s,t){var i;const{workId:e,isActive:o,...n}=s;t&&this.internalMsgEmitter.emit("addUndoTicker",t,n.viewId),n.opt.uid=(i=this.collector)==null?void 0:i.uid,o&&(this.activeId=e),n.dataType=F.Local,n.canWorker=!0,n.canSync=!0,this.editors.set(e,n),this.control.viewContainerManager.setActiveTextEditor(n.viewId,this.activeId)}updateTextForMasterController(s,t){var i;const{workId:e,...o}=s;t&&this.internalMsgEmitter.emit("addUndoTicker",t,o.viewId);const n=this.editors.get(e)||{};o.opt&&(o.opt.uid=(i=this.collector)==null?void 0:i.uid),o.dataType=F.Local,this.editors.set(e,{...n,...o}),this.control.viewContainerManager.setActiveTextEditor(o.viewId,this.activeId)}async updateTextControllerWithEffectAsync(s,t){var h;const{workId:e,...o}=s;t&&this.internalMsgEmitter.emit("addUndoTicker",t,o.viewId);const n=this.editors.get(e)||{};o.opt&&(o.opt.uid=(h=this.collector)==null?void 0:h.uid),o.dataType=F.Local;const i={...n,...o};if(this.editors.set(e,i),this.control.viewContainerManager.setActiveTextEditor(o.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(s)}const a=setTimeout(()=>{var d;const u=(d=this.taskqueue.get(e))==null?void 0:d.resolve;u&&u(i)},50),c=await new Promise(u=>{this.taskqueue.set(e,{resolve:u,clocker:a})}),l=this.taskqueue.get(e);return l&&(l.clocker&&clearTimeout(l.clocker),this.taskqueue.delete(e)),c}updateTextForWorker(s,t){const{workId:e,isActive:o,...n}=s,a={...this.editors.get(e)||{},...n};if(o){a.canWorker=!1,a.canSync=!1,this.editors.set(e,a),this.active(e);return}this.editors.set(e,a),this.control.viewContainerManager.setActiveTextEditor(n.viewId,this.activeId),t&&this.internalMsgEmitter.emit("addUndoTicker",t,n.viewId)}get(s){return this.editors.get(s)}delete(s,t,e){const o=this.editors.get(s);if(o){const n=o.viewId;o.canSync=t,o.canWorker=e,this.editors.delete(s),this.activeId===s&&(this.activeId=void 0),this.control.viewContainerManager.setActiveTextEditor(n,this.activeId)}}deleteBatch(s,t,e){const o=new Set;for(const n of s){const i=this.editors.get(n);if(i){const a=i.viewId;i.canSync=t,i.canWorker=e,this.editors.delete(n),this.activeId===n&&(this.activeId=void 0),o.add(a)}}for(const n of o)this.control.viewContainerManager.setActiveTextEditor(n,this.activeId)}clear(s,t){this.editors.forEach((e,o)=>{e.viewId===s&&(t&&(e.canSync=!1),e.canWorker=!1,this.editors.delete(o))}),this.activeId=void 0,this.control.viewContainerManager.setActiveTextEditor(s,this.activeId)}destory(){this.editors.clear(),this.activeId=void 0}}class Ff{constructor(s){M(this,"expirationTime",xt.cursor.expirationTime);M(this,"internalMsgEmitter");M(this,"control");M(this,"eventName","applianc-cursor");M(this,"displayer");M(this,"roomMember");M(this,"animationId");M(this,"maxLastSyncTime",xt.syncOpt.interval);M(this,"willSendEventWorkers",[]);M(this,"willConsumeEventWorkers",new Map);M(this,"sendEventTimerId");M(this,"animationDrawWorkers",new Map);M(this,"animationEventWorkers",new Map);M(this,"cursorInfoMap",new Map);M(this,"doneRenderCursorInfoMap",new Map);M(this,"eventCollector");var o,n;const{control:t,internalMsgEmitter:e}=s;this.internalMsgEmitter=e,this.control=t,this.roomMember=t.roomMember,this.maxLastSyncTime=((n=(o=this.control.pluginOptions)==null?void 0:o.syncOpt)==null?void 0:n.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(s){var a;const{event:t,payload:e}=s;if(t!==this.eventName)return;const{uid:o,op:n,type:i}=e;if(((a=this.control.collector)==null?void 0:a.uid)!==o&&i===Ce.Cursor&&(n!=null&&n.length)){const c=this.willConsumeEventWorkers.get(o)||[];for(const l of n){const{viewId:h}=l;O.isNumber(l.consumPoint[0])&&O.isNumber(l.consumPoint[1])&&(l.consumPoint=this.control.viewContainerManager.transformToOriginPoint(l.consumPoint,h)),c.unshift({...l,timestamp:Date.now()})}this.willConsumeEventWorkers.set(o,c),this.runAnimation()}}onFocusViewChange(){this.checkDrawWorks(),this.runAnimation()}updateRoomMembers(s){const{offline:t}=s;for(const e of this.cursorInfoMap.keys())e&&t.includes(e)&&this.cursorInfoMap.delete(e)}getKey(s,t){return`${s}${Ot}${t}`}getUidAndviewId(s){const[t,e]=s.split(Ot);return{uid:t,viewId:e}}runAnimation(){this.animationId||(this.animationId=requestAnimationFrame(this.animationCursor.bind(this)))}checkDrawWorks(){var t;const s=this.control.viewContainerManager.focuedViewId;for(const[e,o]of this.animationDrawWorkers.entries()){const{viewId:n,uid:i}=this.getUidAndviewId(e);i!==((t=this.control.collector)==null?void 0:t.uid)&&n!==s&&o.workState===b.Done&&(o.consumPoint=[void 0,void 0])}}animationCursor(){this.animationId=void 0;const s=Date.now();for(const[e,o]of this.animationDrawWorkers.entries()){const{uid:n,viewId:i}=this.getUidAndviewId(e),a=this.roomMember.getRoomMember(n);if(!a){this.animationDrawWorkers.delete(e);continue}const{consumPoint:c,timestamp:l,workState:h}=o,u=this.cursorInfoMap.get(i)||new Map;c&&O.isNumber(c[0])&&O.isNumber(c[1])&&l+this.expirationTime>s?u.set(a.memberId,{x:c[0],y:c[1],roomMember:a,timestamp:l,type:1,workState:h}):u.delete(a.memberId),u.size?this.cursorInfoMap.set(i,u):this.cursorInfoMap.delete(i),this.animationDrawWorkers.delete(e)}const t=new Set;for(const[e,o]of this.cursorInfoMap.entries())if(o)for(const[n,i]of o.entries())i.type===1&&i.workState!==b.Done&&t.add(n);else this.cursorInfoMap.delete(e);for(const[e,o]of this.willConsumeEventWorkers.entries()){const n=this.roomMember.getRoomMember(e);if(O.isNumber(n==null?void 0:n.memberId)&&!t.has(n.memberId)){const i=o.pop();i?this.animationEventWorkers.set(e,i):this.willConsumeEventWorkers.delete(e)}}for(const[e,o]of this.animationEventWorkers.entries()){const n=this.roomMember.getRoomMember(e);if(!n){this.animationEventWorkers.delete(e);continue}const{viewId:i,consumPoint:a,timestamp:c}=o,l=this.cursorInfoMap.get(i)||new Map;a&&O.isNumber(a[0])&&O.isNumber(a[1])&&c+this.expirationTime>s?l.set(n.memberId,{x:a[0],y:a[1],roomMember:n,timestamp:c,type:0}):l.delete(n.memberId),l.size?this.cursorInfoMap.set(i,l):this.cursorInfoMap.delete(i),this.animationEventWorkers.delete(e)}for(const e of this.doneRenderCursorInfoMap.keys())this.cursorInfoMap.has(e)||(this.doneRenderCursorInfoMap.delete(e),this.internalMsgEmitter.emit([Z.Cursor,e],[]));for(const[e,o]of this.cursorInfoMap.entries())if(o!=null&&o.size){const n=[];for(const[a,c]of o.entries()){const{timestamp:l,...h}=c;l+this.expirationTime>s?n.push(h):(o.delete(a),o.size===0&&(this.cursorInfoMap.delete(e),this.doneRenderCursorInfoMap.delete(e),this.internalMsgEmitter.emit([Z.Cursor,e],[])))}const i=this.doneRenderCursorInfoMap.get(e);O.isEqual(i,n)||(this.doneRenderCursorInfoMap.set(e,n),this.internalMsgEmitter.emit([Z.Cursor,e],n))}else this.cursorInfoMap.delete(e),this.doneRenderCursorInfoMap.delete(e),this.internalMsgEmitter.emit([Z.Cursor,e],[]);(this.willConsumeEventWorkers.size||this.cursorInfoMap.size)&&this.runAnimation()}sendEvent(s,t){if(this.displayer&&st.isRoom(this.displayer)){const e=O.isNumber(s[0])&&O.isNumber(s[1])&&this.control.viewContainerManager.transformToScenePoint(s,t)||[void 0,void 0];this.willSendEventWorkers.push({consumPoint:e,viewId:t}),this.sendEventTimerId||(this.sendEventTimerId=setTimeout(()=>{this.dispatchMagixEvent()},this.maxLastSyncTime))}}dispatchMagixEvent(){var s;this.displayer.dispatchMagixEvent(this.eventName,{type:Ce.Cursor,op:O.cloneDeep(this.willSendEventWorkers),uid:(s=this.control.collector)==null?void 0:s.uid}),this.willSendEventWorkers.length=0,this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0)}collectServiceCursor(s){var i;const{op:t,uid:e,workState:o,viewId:n}=s;if(e&&t&&o&&n){const a=this.roomMember.getRoomMember(e);if(!a||e===((i=this.control.collector)==null?void 0:i.uid))return;const c=this.getKey(e,n);let l=[void 0,void 0];if(O.isNumber(t[0])&&O.isNumber(t[1])){const[u,d]=this.control.viewContainerManager.transformToOriginPoint(t,n);l=[u,d]}if(o===b.Start){for(const u of this.cursorInfoMap.values())if(u!=null&&u.size)for(const d of u.keys())d===a.memberId&&u.delete(d)}const h={consumPoint:l,workState:o,viewId:n,timestamp:Date.now()};if(o===b.Start||o===b.Done){const u=this.willConsumeEventWorkers.get(e);o===b.Start&&u&&this.willConsumeEventWorkers.delete(e),u&&o===b.Done&&(h.timestamp=h.timestamp-this.expirationTime)}this.animationDrawWorkers.set(c,h),this.runAnimation()}}unabled(){var s;this.displayer&&st.isRoom(this.displayer)&&(this.willSendEventWorkers.length=0,this.displayer.dispatchMagixEvent(this.eventName,{type:Ce.Cursor,op:[{viewId:this.control.viewContainerManager.focuedViewId,consumPoint:[void 0,void 0]}],uid:(s=this.control.collector)==null?void 0:s.uid}),this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0))}clearViewCursor(s){var t,e,o;for(const[n]of this.animationDrawWorkers.entries()){const{uid:i}=this.getUidAndviewId(n);i===((t=this.control.collector)==null?void 0:t.uid)&&s===s&&this.animationDrawWorkers.delete(n)}for(const[n]of this.willConsumeEventWorkers.entries())n===((e=this.control.collector)==null?void 0:e.uid)&&this.willConsumeEventWorkers.delete(n);for(const[n]of this.animationEventWorkers.entries())n===((o=this.control.collector)==null?void 0:o.uid)&&this.animationEventWorkers.delete(n);for(const[n]of this.cursorInfoMap.entries())n===n&&(this.cursorInfoMap.delete(n),this.doneRenderCursorInfoMap.delete(n),this.internalMsgEmitter.emit([Z.Cursor,n],[]))}stopAnimation(){this.animationDrawWorkers.clear(),this.willConsumeEventWorkers.clear(),this.cursorInfoMap.clear()}destroy(){var s;(s=this.displayer)==null||s.removeMagixEventListener(this.eventName),this.stopAnimation()}}class bt{constructor(){M(this,"useEmtMsg");M(this,"emtType");M(this,"control");M(this,"mainEngine")}static dispatch(s,t,e){var o;(o=mt.InternalMsgEmitter)==null||o.emit([s,t],e)}get serviceColloctor(){return this.control.collector}registerForMainEngine(s,t){return this.emtType=s,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(s,t){var e,o,n;for(const[i,a]of s)(e=this.mainEngine)==null||e.queryTaskBatchData(a).forEach(c=>{var l;(l=this.mainEngine)==null||l.taskBatchData.delete(c)}),(o=this.mainEngine)==null||o.taskBatchData.add(i);if(t){this.mainEngine.consume();return}(n=this.mainEngine)==null||n.runAnimation()}collectForServiceWorker(s){Zt(()=>{s.forEach(t=>{var e;(e=this.serviceColloctor)==null||e.dispatch(t)})},this.mainEngine.maxLastSyncTime)}pause(){var s;if(this.lastEmtData){this.useEmtMsg=!0;const t={...this.lastEmtData,workState:b.Done};this.collect(t,!0),(s=mt.InternalMsgEmitter)==null||s.emit(R.ActiveMethod,!1)}}recover(){var s;this.useEmtMsg&&mt.InternalMsgEmitter.hasListeners(R.ActiveMethod)&&((s=mt.InternalMsgEmitter)==null||s.emit(R.ActiveMethod,!0))}}class Hf extends bt{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:o}=t,n=this.control.viewContainerManager.getView(o);if(!(n!=null&&n.displayer))return;const i=n.focusScenePath,a=Date.now();this.mainEngine.internalMsgEmitter.emit("addUndoTicker",a,o);for(const l of e){const h=l.toString(),d=this.serviceColloctor.isLocalId(h)?this.serviceColloctor.transformKey(l):h,p=(c=this.serviceColloctor.getStorageData(o,i))==null?void 0:c[d];if(p){if(l===H){const f=p&&this.copySelector({viewId:o,store:p});f&&this.pasteSelector({...f,viewId:o,scenePath:i,undoTickerId:a});break}if(p.toolsType===C.Text&&p.opt&&p.opt.workState&&p.opt.workState!==b.Done){const f=p&&this.copyText({viewId:o,store:p});f&&this.pasteText({...f,viewId:o,scenePath:i,key:d,store:p,undoTickerId:a});break}}}}copyText(t){const{viewId:e,store:o}=t,n=this.control.viewContainerManager.getView(e);if(!this.serviceColloctor||!n)return;const i=n==null?void 0:n.cameraOpt,a=i&&[i.centerX,i.centerY],c=o.opt,l=c.boxPoint&&c.boxSize&&[c.boxPoint[0]+c.boxSize[0]/2,c.boxPoint[1]+c.boxSize[1]/2];return{bgCenter:a,textCenter:l}}pasteText(t){var y,v;const{bgCenter:e,textCenter:o,store:n,key:i,viewId:a,scenePath:c,undoTickerId:l}=t,h=this.control.viewContainerManager.getView(a);if(!this.serviceColloctor||!h)return;const u=Math.floor(Math.random()*30+1),d=((y=h.cameraOpt)==null?void 0:y.scale)||1,p=e&&o&&[e[0]-o[0]+u,e[1]-o[1]+u]||[u/d,u/d],I=(this.serviceColloctor.isLocalId(i)?i:this.serviceColloctor.getLocalId(i.toString()))+"-"+l;if(n.toolsType===C.Text&&n.opt){const m=n.opt;if(m&&m.boxPoint&&m.text){m.workState=b.Done;const w=m.boxPoint;m.boxPoint=[w[0]+p[0],w[1]+p[1]],m.workState=b.Done;const S=this.control.viewContainerManager.transformToOriginPoint(m.boxPoint,a);this.control.textEditorManager.createTextForMasterController({workId:I,x:S[0],y:S[1],opt:m,scale:((v=h.cameraOpt)==null?void 0:v.scale)||1,type:Ut.Text,isActive:!1,viewId:a,scenePath:c}),this.collectForServiceWorker([{...n,opt:m,type:z.FullWork,workId:I,viewId:a,scenePath:c}])}}}copySelector(t){var I,y,v,m,w,S,N,T,x;const{viewId:e,store:o}=t,n=this.control.viewContainerManager.getView(e),i=o.selectIds;if(!this.serviceColloctor||!(i!=null&&i.length)||!n)return;const a=new Map,c={offset:{x:0,y:0},cameraOpt:{centerX:((I=n.cameraOpt)==null?void 0:I.centerX)||0,centerY:((y=n.cameraOpt)==null?void 0:y.centerY)||0,scale:((v=n.cameraOpt)==null?void 0:v.scale)||1}},l=this.control.hasOffscreenCanvas()&&((m=n.displayer.canvasBgRef.current)==null?void 0:m.getBoundingClientRect())||((w=n.displayer.canvasContainerRef.current)==null?void 0:w.getBoundingClientRect()),h=(N=(S=n.displayer)==null?void 0:S.floatBarRef.current)==null?void 0:N.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&&n.viewData&&n.viewData.convertToPointInWorld({x:u[0],y:u[1]}),f=d&&n.viewData&&n.viewData.convertToPointInWorld({x:d[0],y:d[1]});p&&f&&(c.offset={x:p.x-f.x,y:p.y-f.y});for(const L of i){const D=(x=(T=this.serviceColloctor)==null?void 0:T.getStorageData(n.id,n.focusScenePath))==null?void 0:x[L];D&&a.set(L,D)}return{copyStores:a,copyCoordInfo:c}}pasteSelector(t){var I;const{copyStores:e,copyCoordInfo:o,viewId:n,scenePath:i,undoTickerId:a}=t,c=this.control.viewContainerManager.getView(n);if(!e.size||!this.serviceColloctor||!c)return;const{offset:l,cameraOpt:h}=o,u=Math.floor(Math.random()*30+1),d=[l.x+u,l.y+u],p=[],f=[];for(const[y,v]of e.entries()){const w=(this.serviceColloctor.isLocalId(y)?y:this.serviceColloctor.getLocalId(y.toString()))+"-"+a,S={useAnimation:!1};if(v.toolsType===C.Text&&v.opt){const N=v.opt;if(N&&N.boxPoint&&N.text){N.workState=b.Done;const T=N.boxPoint;N.boxPoint=[T[0]+d[0],T[1]+d[1]],N.workState=b.Done;const x=this.control.viewContainerManager.transformToOriginPoint(N.boxPoint,n);this.control.textEditorManager.createTextForMasterController({workId:w,x:x[0],y:x[1],opt:N,scale:((I=c.cameraOpt)==null?void 0:I.scale)||1,type:Ut.Text,isActive:!1,viewId:n,scenePath:i})}f.push({...v,opt:N,type:z.FullWork,workId:w,viewId:n,scenePath:i});continue}if(v.toolsType===C.Image&&(v.opt.uuid=w,v.opt.centerX=v.opt.centerX+d[0],v.opt.centerY=v.opt.centerY+d[1]),v.ops){const N=Ne(v.ops).map((x,L)=>{const D=L%3;return D===0?x+d[0]:D===1?x+d[1]:x}),T=zt(N);v.ops=T}f.push({...v,updateNodeOpt:S,type:z.FullWork,workId:w,viewId:n,scenePath:i}),p.push([{...v,updateNodeOpt:S,workId:w,msgType:z.FullWork,dataType:F.Local,emitEventType:R.CopyNode,willSyncService:!1,willRefresh:!0,viewId:n},{workId:w,msgType:z.FullWork,emitEventType:R.CopyNode}])}p.length&&this.collectForLocalWorker(p),f.length&&this.collectForServiceWorker(f)}}function De(r,s,t){return"#"+((r<<16)+(s<<8)+t).toString(16).padStart(6,"0")}function gt(r,s=1){return"rgba("+parseInt("0x"+r.slice(1,3))+","+parseInt("0x"+r.slice(3,5))+","+parseInt("0x"+r.slice(5,7))+","+s+")"}function Oe(r,s,t,e=1){return`rgba(${r},${s},${t},${e})`}function co(r){const s=r.split(","),t=parseInt(s[0].split("(")[1]),e=parseInt(s[1]),o=parseInt(s[2]),n=Number(s[3].split(")")[0]);return[De(t,e,o),n]}function Re(r){const s=r.split(","),t=parseInt(s[0].split("(")[1]),e=parseInt(s[1]),o=parseInt(s[2]),n=Number(s[3].split(")")[0]);return[t,e,o,n]}function Ye(r){return r==="transparent"}class Qf extends bt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.SetColorNode);M(this,"undoTickerId")}setTextColor(t,e,o,n){const{fontColor:i,fontBgColor:a}=o;e.opt&&(i&&(e.opt.fontColor=i),a&&(e.opt.fontBgColor=a),this.control.textEditorManager.updateTextForMasterController({workId:t,opt:e.opt,viewId:n,canSync:!0,canWorker:!0}))}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,strokeColor:o,fillColor:n,fontColor:i,fontBgColor:a,viewId:c,workState:l,thickness:h,strokeType:u}=t,d=this.control.viewContainerManager.getView(c);if(!(d!=null&&d.displayer))return;const p=d.focusScenePath,f=[...e],I=this.serviceColloctor.storage,y=[],v={};for((l===b.Start||!this.undoTickerId&&l===b.Done)&&(this.undoTickerId=Date.now(),this.mainEngine.internalMsgEmitter.emit("addUndoTicker",this.undoTickerId,c));f.length;){const m=f.pop();if(!m)continue;const w=m.toString(),S=this.serviceColloctor.isLocalId(w),N=S?this.serviceColloctor.transformKey(m):w;let T=w;!S&&this.serviceColloctor.isOwn(T)&&(T=this.serviceColloctor.getLocalId(T));const x=I[c][p][N]||void 0;if(x){const L=x.updateNodeOpt||{};if(i||a){if(i){L.fontColor=i;const[A,P,E,j]=Re(i);v.textColor=[A,P,E],v.textOpacity=j}if(a)if(L.fontBgColor=Ye(a)?"transparent":a,Ye(a))v.textBgColor=void 0,v.textBgOpacity=void 0;else{const[A,P,E,j]=Re(a);v.textBgColor=[A,P,E],v.textBgOpacity=j}if(x.toolsType===C.Text&&x.opt&&l!==b.Start){this.setTextColor(T,Vt(x),L,c),l===b.Done&&(this.undoTickerId=void 0);continue}}if(o){L.strokeColor=o;const[A,P,E,j]=Re(o);v.strokeColor=[A,P,E],v.strokeOpacity=j}if(n)if(L.fillColor=Ye(n)?"transparent":n,Ye(n))v.fillColor=void 0,v.fillOpacity=void 0;else{const[A,P,E,j]=Re(n);v.fillColor=[A,P,E],v.fillOpacity=j}h&&(L.thickness=h,v.strokeWidth=h),u&&(L.strokeType=u,v.strokeType=u);const D={workId:T,msgType:z.UpdateNode,dataType:F.Local,updateNodeOpt:L,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,textUpdateForWoker:!0,viewId:c};y.push([D,{workId:T,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}}y.length&&(l===b.Done&&(this.undoTickerId=void 0),this.collectForLocalWorker(y)),Object.keys(v).length&&setTimeout(()=>{var m;(m=this.control.room)==null||m.setMemberState(v)},0)}}class Vf extends bt{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 o=this.getMinZIndex(e);this.zIndexMap.set(e,{min:o,max:t})}setMinZIndex(t,e){const o=this.getMaxZIndex(e);this.zIndexMap.set(e,{min:t,max:o})}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((o,n)=>o[1]-n[1]);for(let o=1;o<e.length;o++){const n=e[o][1],i=e[o-1][1];n<=i&&(e[o][1]=i+1)}return e}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,layer:o,viewId:n}=t,i=this.control.viewContainerManager.getView(n);if(!(i!=null&&i.displayer))return;const a=i.focusScenePath,c=[...e],l=this.serviceColloctor.storage,h=[],u=[];for(;c.length;){const p=c.pop();if(!p)continue;const f=p.toString(),I=this.serviceColloctor.isLocalId(f),y=I?this.serviceColloctor.transformKey(p):f;let v=f;!I&&this.serviceColloctor.isOwn(v)&&(v=this.serviceColloctor.getLocalId(v));const m=Vt(l[n][a][y]);let w;if(m&&v===H){if(m.selectIds){u.push(...m.selectIds),u.sort((x,L)=>{var P,E,j,_;const D=((E=(P=l[d(x,this.serviceColloctor)])==null?void 0:P.opt)==null?void 0:E.zIndex)||0,A=((_=(j=l[d(x,this.serviceColloctor)])==null?void 0:j.opt)==null?void 0:_.zIndex)||0;return D>A?1:x<L?-1:0});const S=m.updateNodeOpt||{};S.zIndexLayer=o;const N={workId:p,msgType:z.UpdateNode,dataType:F.Local,updateNodeOpt:S,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:n},T=new Map;o===oe.Top?(this.addMaxLayer(n),w=this.getMaxZIndex(n)):(this.addMinLayer(n),w=this.getMinZIndex(n)),u.forEach(x=>{var P,E,j;const L=(P=this.serviceColloctor)==null?void 0:P.isLocalId(x);let D=L&&((E=this.serviceColloctor)==null?void 0:E.transformKey(x))||x;const A=l[n][a][D];!L&&((j=this.serviceColloctor)!=null&&j.isOwn(D))&&(D=this.serviceColloctor.getLocalId(D)),S.zIndex=w,A!=null&&A.opt&&(A.opt.zIndex=w),A!=null&&A.opt&&T.set(D,{updateNodeOpt:A.updateNodeOpt,opt:A.opt})}),N.selectStore=T,N.willSerializeData=!0,h.push([N,{workId:p,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}continue}}h.length&&this.collectForLocalWorker(h);function d(p,f){return f.isLocalId(p)&&f.transformKey(p)||p}}}class $f extends bt{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:o,position:n,workState:i,viewId:a}=t;this.lastEmtData=t;const c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,h=[...o],u=(f=this.serviceColloctor)==null?void 0:f.storage,d=[],p=i===b.Start&&Date.now()||void 0;for(p&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,a);h.length;){const I=h.pop();if(!I)continue;const y=I.toString(),v=this.serviceColloctor.isLocalId(y),m=v&&this.serviceColloctor.transformKey(I)||y;let w=y;!v&&this.serviceColloctor.isOwn(w)&&(w=this.serviceColloctor.getLocalId(w));const S=u[a][l][m];if(S&&w===H){if(S.selectIds){const N=this.control.viewContainerManager.transformToScenePoint([n.x,n.y],a);if(i===b.Start&&(this.cachePosition=N),this.cachePosition){const T=S.updateNodeOpt||{};T.translate=[N[0]-this.cachePosition[0],N[1]-this.cachePosition[1]],T.workState=i;const x={workId:I,msgType:z.UpdateNode,dataType:F.Local,updateNodeOpt:T,emitEventType:this.emitEventType,willSyncService:!0,textUpdateForWoker:!0,viewId:a};i===b.Done&&(x.textUpdateForWoker=!0,x.willSerializeData=!0,this.cachePosition=void 0),d.push([x,{workId:I,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}}continue}}i===b.Start?this.mainEngine.unWritable():i===b.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length&&this.collectForLocalWorker(d,e)}}class Gf extends bt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.DeleteNode)}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,viewId:o}=t,n=this.control.viewContainerManager.getView(o);if(!(n!=null&&n.displayer))return;const i=n.focusScenePath,a=this.serviceColloctor.storage,c=[...e],l=[],h=[],u=Date.now();for(;c.length;){const d=c.pop();if(!d)continue;const p=d.toString(),f=this.serviceColloctor.isLocalId(p),I=f?this.serviceColloctor.transformKey(d):p,y=a[o][i][I];if(y){let v=p;if(!f&&this.serviceColloctor.isOwn(v)&&(v=this.serviceColloctor.getLocalId(v)),y.toolsType===C.Text){this.control.textEditorManager.delete(v,!0,!0);continue}h.push(v)}}h.length&&(l.push([{msgType:z.RemoveNode,emitEventType:R.DeleteNode,removeIds:h,dataType:F.Local,willSyncService:!0,willRefresh:!0,viewId:o},void 0]),this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,o),this.collectForLocalWorker(l))}}class Zf extends bt{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,o){const n=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:t,opt:e,viewId:o,canSync:!1,canWorker:!1});return{key:t,textInfo:n}}async collect(t,e){var m,w,S,N,T;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:o,workState:n,viewId:i,originPoint:a,scenePoint:c,dir:l,scale:h,translate:u}=t;this.lastEmtData=t;const d=this.control.viewContainerManager.getView(i);if(!(d!=null&&d.displayer))return;const p=d.focusScenePath,f=[...o],I=(m=this.serviceColloctor)==null?void 0:m.storage,y=[],v=n===b.Start&&Date.now()||void 0;for(v&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",v,i);f.length;){const x=f.pop();if(!x)continue;const L=x.toString(),D=this.serviceColloctor.isLocalId(L),A=D&&this.serviceColloctor.transformKey(x)||L;let P=L;!D&&this.serviceColloctor.isOwn(P)&&(P=this.serviceColloctor.getLocalId(P));const E=I[i][p][A];if(E&&P===H&&E.selectIds){const j=E.updateNodeOpt||{};if(j.dir=l,j.originPoint=a,j.scenePoint=c,j.workState=n,j.scale=h,j.translate=u,n===b.Start){this.cacheTextInfo.clear();for(const nt of E.selectIds){const tt=(w=this.serviceColloctor)==null?void 0:w.isLocalId(nt),V=tt&&((S=this.serviceColloctor)==null?void 0:S.transformKey(nt))||nt;let K=V;!tt&&((N=this.serviceColloctor)!=null&&N.isOwn(V))&&(K=this.serviceColloctor.getLocalId(V));const $=this.control.textEditorManager.get(K);$&&n===b.Start&&this.targetText.set(K,Vt($))}}if(this.targetText.size&&n!==b.Start&&h){const nt=[];for(const[V,K]of this.targetText.entries()){const{opt:$}=K,G=Math.floor($.fontSize*h[0]),J=this.cacheTextInfo.get(V),rt=!J&&$.fontSize!==G||J&&J.fontSize!==G||!1,It=(T=this.control.textEditorManager.get(V))==null?void 0:T.opt;if(rt&&It&&$.boxSize&&$.boxPoint){const ot=this.setTextStyle(V,{...It,fontSize:G},i);nt.push(ot)}}const tt=await Promise.all(nt);for(const V of tt)if(V){const{key:K,textInfo:$}=V;this.cacheTextInfo.set(K,{fontSize:$.opt.fontSize,boxSize:$.opt.boxSize,boxPoint:$.opt.boxPoint})}j.textInfos=this.cacheTextInfo}const _={workId:x,msgType:z.UpdateNode,dataType:F.Local,updateNodeOpt:j,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:i};n===b.Done&&(_.willSerializeData=!0,this.targetText.clear()),y.push([_,{workId:x,msgType:z.UpdateNode,emitEventType:this.emitEventType}]);continue}}n===b.Start?this.mainEngine.unWritable():n===b.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),y.length&&this.collectForLocalWorker(y,e)}}class qf extends bt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.RotateNode);M(this,"cacheOriginRotate",0)}collect(t,e){var f,I,y,v,m;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:o,angle:n,workState:i,viewId:a}=t;this.lastEmtData=t;const c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,h=[...o],u=(f=this.serviceColloctor)==null?void 0:f.storage,d=[],p=i===b.Start&&Date.now()||void 0;for(p&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,a);h.length;){const w=h.pop();if(!w)continue;const S=w.toString(),N=this.serviceColloctor.isLocalId(S),T=N&&this.serviceColloctor.transformKey(w)||S;let x=S;!N&&this.serviceColloctor.isOwn(x)&&(x=this.serviceColloctor.getLocalId(x));const L=u[a][l][T];if(L&&x===H){if(((I=L.selectIds)==null?void 0:I.length)===1){const D=L.selectIds[0];if(i===b.Start){const j=((y=this.serviceColloctor)==null?void 0:y.isLocalId(D))&&((v=this.serviceColloctor)==null?void 0:v.transformKey(D))||D,_=u[a][l][j];this.cacheOriginRotate=((m=_==null?void 0:_.opt)==null?void 0:m.rotate)||0}const A=L.updateNodeOpt||{};A.angle=(n+this.cacheOriginRotate)%360,A.workState=i;const P={workId:w,msgType:z.UpdateNode,dataType:F.Local,updateNodeOpt:A,emitEventType:this.emitEventType,willRefreshSelector:!1,willSyncService:!0,viewId:a};i===b.Done&&(P.willRefreshSelector=!0,P.willSerializeData=!0,this.cacheOriginRotate=0),d.push([P,{workId:w,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}continue}}i===b.Start?this.mainEngine.unWritable():i===b.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length&&this.collectForLocalWorker(d,e)}}function Jf(r){switch(r){case C.Text:return Ut.Text;case C.SpeechBalloon:case C.Star:case C.Ellipse:case C.Rectangle:case C.Triangle:case C.Rhombus:case C.Polygon:return Ut.Shape}}class Xf extends bt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.SetFontStyle);M(this,"timerId")}async setTextStyle(t,e,o,n){const{bold:i,underline:a,lineThrough:c,italic:l,fontSize:h}=o;if(e.toolsType&&Jf(e.toolsType)===Ut.Text){e.opt&&(i&&(e.opt.bold=i),O.isBoolean(a)&&(e.opt.underline=a),O.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:n,canSync:!1,canWorker:!1});return{key:t,textInfo:d}}}async collect(t){var m,w,S,N;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,bold:o,italic:n,lineThrough:i,underline:a,viewId:c,fontSize:l}=t,h=this.control.viewContainerManager.getView(c);if(!(h!=null&&h.displayer))return;const u=h.focusScenePath,d=[...e],p=this.serviceColloctor.storage,f={},I=Date.now();this.mainEngine.internalMsgEmitter.emit("addUndoTicker",I,c);const y=[];for(;d.length;){const T=d.pop();if(!T)continue;const x=T.toString(),L=this.serviceColloctor.isLocalId(x),D=L?this.serviceColloctor.transformKey(T):x;let A=x;!L&&this.serviceColloctor.isOwn(A)&&(A=this.serviceColloctor.getLocalId(A));const P=p[c][u][D]||void 0;if(P){const E=P.updateNodeOpt||{};if(o&&(E.bold=o,f.bold=o==="bold"),n&&(E.italic=n,f.italic=n==="italic"),O.isBoolean(i)&&(E.lineThrough=i,f.lineThrough=i),O.isBoolean(a)&&(E.underline=a,f.underline=a),l&&(E.fontSize=l,f.textSize=l),P.toolsType===C.Text&&P.opt){const j=this.setTextStyle(A,O.cloneDeep(P),E,c);y.push(j);continue}if(P&&A===H&&((m=P.selectIds)!=null&&m.length))for(const j of P.selectIds){const _=(w=this.serviceColloctor)==null?void 0:w.isLocalId(j);let nt=_&&((S=this.serviceColloctor)==null?void 0:S.transformKey(j))||j;const tt=p[c][u][nt]||void 0;if(!_&&((N=this.serviceColloctor)!=null&&N.isOwn(nt))&&(nt=this.serviceColloctor.getLocalId(nt)),tt&&tt.toolsType===C.Text&&P.opt){const V=this.setTextStyle(nt,O.cloneDeep(tt),E,c);y.push(V);continue}}}}const v=await Promise.all(y);for(const T of v)if(T){const{key:x,textInfo:L}=T;L&&(L.canSync=!0,L.canWorker=!0,this.control.textEditorManager.updateForViewEdited(x,L))}Object.keys(f).length&&(this.timerId&&(clearTimeout(this.timerId),this.timerId=void 0),this.timerId=setTimeout(()=>{var T;this.timerId=void 0,(T=this.control.room)==null||T.setMemberState(f)},0))}}class Kf extends bt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.SetPoint);M(this,"undoTickerId")}collect(t){var m;if(!this.serviceColloctor||!this.mainEngine)return;const{workId:e,pointMap:o,workState:n,viewId:i}=t,a=this.control.viewContainerManager.getView(i);if(!(a!=null&&a.displayer))return;const c=a.focusScenePath,l=(m=this.serviceColloctor)==null?void 0:m.storage,h=[],u=n===b.Start&&Date.now()||void 0;u&&(this.undoTickerId=u,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,i));const d=e;if(!d)return;const p=d.toString(),f=this.serviceColloctor.isLocalId(p),I=f&&this.serviceColloctor.transformKey(d)||p;let y=p;!f&&this.serviceColloctor.isOwn(y)&&(y=this.serviceColloctor.getLocalId(y));const v=l[i][c][I];if(v&&y===H&&v.selectIds){const w=v.updateNodeOpt||{};w.pointMap=o,w.workState=n;const S={workId:d,msgType:z.UpdateNode,dataType:F.Local,updateNodeOpt:w,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:i};n===b.Done&&(S.undoTickerId=this.undoTickerId),h.push([S,{workId:d,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}n===b.Start?this.mainEngine.unWritable():n===b.Done&&this.mainEngine.abled(),h.length&&this.collectForLocalWorker(h)}}class _f extends bt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.SetLock)}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,isLocked:o,viewId:n}=t,i=this.control.viewContainerManager.getView(n);if(!(i!=null&&i.displayer))return;const a=i.focusScenePath,c=[...e],l=this.serviceColloctor.storage,h=[],u=Date.now();for(;c.length;){const d=c.pop();if(!d)continue;const p=d.toString(),f=this.serviceColloctor.isLocalId(p),I=f?this.serviceColloctor.transformKey(d):p;let y=p;!f&&this.serviceColloctor.isOwn(y)&&(y=this.serviceColloctor.getLocalId(y));const v=l[n][a][I]||void 0;if(v){const m=v.updateNodeOpt||{};m.isLocked=o;const w={workId:y,msgType:z.UpdateNode,dataType:F.Local,updateNodeOpt:m,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:n};h.push([w,{workId:y,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}}this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,n),h.length&&this.collectForLocalWorker(h)}}class tg extends bt{constructor(){super(...arguments);M(this,"lastEmtData");M(this,"emitEventType",R.SetShapeOpt)}collect(t){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:e,viewId:o,...n}=t,i=this.control.viewContainerManager.getView(o);if(!(i!=null&&i.displayer))return;const a=i.focusScenePath,c=[...e],l=this.serviceColloctor.storage,h=[],u=Date.now();for(;c.length;){const d=c.pop();if(!d)continue;const p=d.toString(),f=this.serviceColloctor.isLocalId(p),I=f?this.serviceColloctor.transformKey(d):p;let y=p;!f&&this.serviceColloctor.isOwn(y)&&(y=this.serviceColloctor.getLocalId(y));const v=l[o][a][I]||void 0;if(v){const m={...v.updateNodeOpt,...n,willRefresh:!0};if(v&&y===H){const w={workId:y,msgType:z.UpdateNode,dataType:F.Local,updateNodeOpt:m,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:o};h.push([w,{workId:y,msgType:z.UpdateNode,emitEventType:this.emitEventType}])}}}h.length&&(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,o),this.collectForLocalWorker(h))}}class q{constructor(s){M(this,"builders",new Map);this.builders=new Map(s.map(t=>[t,this.build(t)]))}build(s){switch(s){case R.TranslateNode:return new $f;case R.ZIndexNode:return new Vf;case R.CopyNode:return new Hf;case R.SetColorNode:return new Qf;case R.DeleteNode:return new Gf;case R.ScaleNode:return new Zf;case R.RotateNode:return new qf;case R.SetFontStyle:return new Xf;case R.SetPoint:return new Kf;case R.SetLock:return new _f;case R.SetShapeOpt:return new tg}}getBuilder(s){return this.builders.get(s)}registerForMainEngine(s,t){return this.builders.forEach(e=>{e&&e.registerForMainEngine(s,t)}),this}destroy(){this.builders.forEach(s=>{s&&s.destroy()}),this.builders.clear()}pause(){return this.builders.forEach(s=>{s&&s.pause()}),this}recover(){return this.builders.forEach(s=>{s&&s.recover()}),this}static emitMethod(s,t,e){bt.dispatch(s,t,e)}static activeListener(s){mt.InternalMsgEmitter.on(R.ActiveMethod,s)}static unmountActiveListener(s){mt.InternalMsgEmitter.off(R.ActiveMethod,s)}}class eg{constructor(s){M(this,"master");M(this,"mainThreadWorkerMap",new Map);this.master=s}updateCamera(){for(const[s,t]of this.mainThreadWorkerMap.entries()){const e=this.master.control.viewContainerManager.getView(s);if(e){const{cameraOpt:o}=e;t.updateCamera({cameraOpt:o,viewId:e.viewId,msgType:z.UpdateCamera,dataType:F.Local})}}}notifyDrawCount(s){const t=this.master.getWorkDrawCount(),e=this.mainThreadWorkerMap.get(s);e&&e.clearDrawLayer(t)}clearDrawCount(s){const t=this.mainThreadWorkerMap.get(s);t&&t.clearDrawLayer(1/0)}createMainThreadWorker(s,t){return new og(s,t,this)}consume(s){var t;for(const e of s.values()){const{msgType:o,viewId:n,layerOpt:i,offscreenCanvasOpt:a,cameraOpt:c}=e;if(o===z.Console){console.log(this);continue}if(o===z.Init){const h=(t=this.master.control.viewContainerManager.getView(n))==null?void 0:t.displayer,u=h==null?void 0:h.subLocalCanvasContainerRef.current;if(h&&u&&i&&a){const d=this.createMainThreadWorker(n,{displayer:h,container:u,layerOpt:i,master:this.master,canvasOpt:a,post:this.post.bind(this)});this.mainThreadWorkerMap.set(n,d),d&&c&&d.setCameraOpt(c)}continue}if(o===z.TasksQueue)continue;const l=this.mainThreadWorkerMap.get(n);l&&(l.on(e),o===z.Destroy&&(l.destroy(),this.mainThreadWorkerMap.delete(n)))}}post(s){const{sp:t}=s;t&&this.master.collectorSyncData(t)}destroy(){for(const s of this.mainThreadWorkerMap.values())s.destroy();this.mainThreadWorkerMap.clear()}active(){}}class og{constructor(s,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=s,this.opt=t,this.manager=e,this.scene=this.createScene({...t.canvasOpt,container:t.container});const o=xt.bufferSize.full,n=xt.bufferSize.sub;this.subLocalLayer=this.createLayer("subLocalLayer",this.scene,{...t.layerOpt,bufferSize:this.viewId===yt?o:n});const i={thread:this};this.subLocalWork=new sg(i)}createScene(s){return new lt.Scene({displayRatio:this.opt.displayer.dpr,depth:!1,desynchronized:!0,...s,autoRender:!0,id:this.viewId})}createLayer(s,t,e){const{width:o,height:n}=e,i=`canvas-${s}`,a=t.layer(i,{...e,offscreen:!1}),c=new lt.Group({anchor:[.5,.5],pos:[o*.5,n*.5],size:[o,n],name:"viewport",id:s});return a.append(c),c}updateScene(s){this.scene.attr({...s});const{width:t,height:e}=s;this.scene.width=t,this.scene.height=e,this.updateLayer({width:t,height:e})}updateLayer(s){const{width:t,height:e}=s;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(s){const{msgType:t,toolsType:e,opt:o,dataType:n,workId:i,workState:a}=s,c=i==null?void 0:i.toString();switch(t){case z.Destroy:this.destroy();break;case z.Clear:this.clearAll();break;case z.UpdateCamera:this.updateCamera(s);break;case z.UpdateTools:if(e&&this.subLocalWork.canUseSubWorkerLayer(e)&&o){const l={toolsType:e,toolsOpt:o};this.subLocalWork.setToolsOpt(l)}break;case z.CreateWork:c&&o&&e&&this.subLocalWork.canUseSubWorkerLayer(e)&&(this.subLocalWork.getToolsOpt()||this.subLocalWork.setToolsOpt({toolsType:e,toolsOpt:o}),this.subLocalWork.setWorkOptions(c,o));break;case z.DrawWork:e&&this.subLocalWork.canUseSubWorkerLayer(e)&&(a===b.Done&&n===F.Local?this.subLocalWork.consumeDrawAll(s):this.subLocalWork.consumeDraw(s));break;case z.RemoveNode:this.subLocalWork.removeNode(s);return}}setCameraOpt(s){this.cameraOpt=s;const{scale:t,centerX:e,centerY:o,width:n,height:i}=s;(n!==this.scene.width||i!==this.scene.height)&&this.updateScene({width:n,height:i}),this.subLocalLayer&&(this.subLocalLayer.setAttribute("scale",[t,t]),this.subLocalLayer.setAttribute("translate",[-e,-o]))}updateCamera(s){const{cameraOpt:t}=s;t&&!O.isEqual(this.cameraOpt,t)&&(this.subLocalWork.workShapes.size&&this.clearAll(),this.setCameraOpt(t))}clearAll(){this.subLocalLayer.children.length&&(this.subLocalLayer.parent.children.forEach(s=>{s.name!=="viewport"&&s.remove()}),this.subLocalLayer.removeAllChildren()),this.subLocalWork.clearAll()}destroy(){this.subLocalLayer.remove(),this.scene.remove(),this.subLocalWork.destroy()}clearDrawLayer(s){if(s===1/0){this.clearAll();return}const t=this.subLocalLayer.children.filter(e=>e.id&&O.isNumber(parseInt(e.id))&&parseInt(e.id)<s);for(const e of t)e.disconnect(),this.subLocalLayer.removeChild(e)}}class sg{constructor(s){M(this,"thread");M(this,"workShapes",new Map);M(this,"tmpOpt");M(this,"syncUnitTime",xt.syncOpt.interval);M(this,"drawCount",0);this.thread=s.thread}getToolsOpt(){return this.tmpOpt}consumeDrawAll(s){const{workId:t}=s,e=t==null?void 0:t.toString();e&&this.workShapes.get(e)&&(this.drawCount=0,this.thread.subLocalLayer.removeAllChildren(),this.clearWorkShapeNodeCache(e))}consumeDraw(s){const{workId:t,toolsType:e}=s;t&&e&&this.canUseSubWorkerLayer(e)&&(this.getWorkShape(t.toString())||this.createLocalWork(s));const o=t==null?void 0:t.toString(),n=o&&this.workShapes.get(o);if(!n)return;n.consume({data:s,drawCount:this.drawCount,isFullWork:!1,isSubWorker:!0}),this.drawCount++;const i=this.thread.manager.master;i.setSubWorkerDrawCount(this.drawCount);const a=Math.max(i.getMaxDrawCount(),this.drawCount);i.setMaxDrawCount(a)}removeNode(s){const{workId:t}=s,e=t==null?void 0:t.toString();e&&this.workShapes.has(e)&&(this.thread.subLocalLayer.getElementsByName(e).forEach(n=>{n.remove()}),this.clearWorkShapeNodeCache(e))}createLocalWork(s){const{workId:t,toolsType:e,opt:o}=s,n=t==null?void 0:t.toString();e&&this.canUseSubWorkerLayer(e)&&n&&o&&(this.getToolsOpt()||this.setToolsOpt({toolsType:e,toolsOpt:o}),this.setWorkOptions(n,o))}setWorkOptions(s,t){let e=this.workShapes.get(s);if(!e&&this.tmpOpt){const{toolsType:o}=this.tmpOpt;this.tmpOpt.toolsOpt=t,e=this.createWorkShapeNode({workId:s,toolsType:o,toolsOpt:t}),e&&this.workShapes.set(s,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(s){return s===C.Pencil}setToolsOpt(s){var t;this.tmpOpt=s,(t=s.toolsOpt)!=null&&t.syncUnitTime&&(this.syncUnitTime=s.toolsOpt.syncUnitTime)}createWorkShapeNode(s){return Ii({...s,fullLayer:this.thread.subLocalLayer,drawLayer:this.thread.subLocalLayer})}clearWorkShapeNodeCache(s){this.workShapes.delete(s)}getWorkShape(s){return this.workShapes.get(s)}}const ig=async(r,s)=>{const{src:t,isgl:e,isCache:o}=r;if(typeof Image=="function"){const n=new Image;return typeof t=="string"&&(n.crossOrigin="anonymous"),new Promise(i=>{n.onload=function(){createImageBitmap(n,{imageOrientation:e?"flipY":"none"}).then(a=>{i(a)})},n.onerror=function(){i(void 0)},n.src=t})}else return fetch(t,{method:"GET",mode:"cors",cache:"default"}).then(n=>n.blob()).then(n=>createImageBitmap(n,{imageOrientation:e?"flipY":"none"}).then(i=>i))};class ng{constructor(){M(this,"maxLastSyncTime",xt.syncOpt.interval)}setCurrentToolsData(s){this.currentToolsData=s}getCurrentToolsData(){return this.currentToolsData}setCurrentLocalWorkData(s){this.currentLocalWorkData=s}getWorkId(){return this.currentLocalWorkData.workId}getWorkState(){return this.currentLocalWorkData.workState}}class rg extends ng{constructor(t){var n,i;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:o}=t;this.control=e,this.maxLastSyncTime=((i=(n=this.control.pluginOptions)==null?void 0:n.syncOpt)==null?void 0:i.interval)||this.maxLastSyncTime,this.fullWorkerUrl=this.control.pluginOptions.cdn.fullWorkerUrl,this.subWorkerUrl=this.control.pluginOptions.cdn.subWorkerUrl,this.internalMsgEmitter=o,this.currentLocalWorkData={workState:b.Pending}}destroy(){var t,e,o;(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(),(o=this.subWorker)==null||o.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.BitMapEraser}get isCanStartEventConsum(){var e;const t=(e=this.currentToolsData)==null?void 0:e.toolsType;return t===C.Selector||t===C.Eraser||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-C29o_HLi.js"));this.mainThread=new t(this)}async on(){if(!this.control.hasOffscreenCanvas()){await this.useMainThread();return}if(!this.fullWorkerUrl||!this.subWorkerUrl){console.error("no worker url config");return}this.fullWorker=new Worker(this.fullWorkerUrl,{type:"classic"}),this.subWorker=new Worker(this.subWorkerUrl,{type:"classic"}),this.subMainThreadWorker=new eg(this),this.fullWorker.onmessage=t=>{var e,o;if(t.data){const{render:n,sp:i,drawCount:a,workerTasksqueueCount:c,viewId:l}=t.data;this.isBusy&&c&&this.setWorkerTasksqueueCount(c),i!=null&&i.length&&this.collectorSyncData(i);const h=(n==null?void 0:n.length)&&n||[];if(a&&l){if(this.setWorkDrawCount(a),this.wokerDrawCount<1/0){const u=Math.max(this.maxDrawCount,this.wokerDrawCount);this.setMaxDrawCount(u),this.control.priority==="ui"?(e=this.subMainThreadWorker)==null||e.notifyDrawCount(l):this.clearReRenders(this.wokerDrawCount)}else this.setMaxDrawCount(0),this.control.priority==="ui"?(o=this.subMainThreadWorker)==null||o.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:o,drawCount:n}=t.data;o!=null&&o.length&&this.collectorSyncData(o);const i=(e==null?void 0:e.length)&&e||[];if(this.control.priority==="cpu"&&O.isNumber(n)){if(this.setSubWorkerDrawCount(n),this.wokerDrawCount<1/0){const a=Math.max(this.maxDrawCount,this.subWorkerDrawCount);this.setMaxDrawCount(a)}if(e!=null&&e.length)if(this.subWorkerDrawCount>this.wokerDrawCount){const a=[];for(const c of e)c.imageBitmap&&(c.isUnClose=!0,a.push(c));this.reRenders.set(this.subWorkerDrawCount,a)}else this.reRenders.size&&this.clearReRenders(this.subWorkerDrawCount)}i.length&&this.viewContainerManager.render(i)}}}clearReRenders(t=1/0){for(const e of this.reRenders.keys())if(O.isNumber(Number(e))&&Number(e)<=t){const o=this.reRenders.get(Number(e));o==null||o.forEach(n=>{var i;(i=n.imageBitmap)==null||i.close()}),this.reRenders.delete(e)}}get isBusy(){return this.getTasksqueueState()===b.Doing}getLockSentEventCursor(){return this.isLockSentEventCursor}setLockSentEventCursor(t){this.isLockSentEventCursor=t}getTasksqueueState(){return this.useTasksqueue&&b.Doing||b.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 o,n,i;let e=!1;for(const a of t){const{type:c,selectIds:l,opt:h,selectRect:u,strokeColor:d,fillColor:p,willSyncService:f,isSync:I,imageBitmap:y,canvasHeight:v,canvasWidth:m,rect:w,op:S,canTextEdit:N,points:T,selectorColor:x,canRotate:L,scaleType:D,textOpt:A,toolsType:P,workId:E,viewId:j,dataType:_,canLock:nt,isLocked:tt,shapeOpt:V,toolsTypes:K,thickness:$,strokeType:G,useStroke:J,isgl:rt,imageSrc:It,isSubWorker:ot}=a;if(!j)return;const at=a.scenePath||this.viewContainerManager.getCurScenePath(j);switch(c){case z.Select:{const W=l!=null&&l.length?{...u,selectIds:l,canvasHeight:v,canvasWidth:m,points:T}:void 0;W&&(h!=null&&h.strokeColor)&&(W.selectorColor=h.strokeColor),W&&x&&(W.selectorColor=x),W&&d&&(W.strokeColor=d),W&&(h!=null&&h.fillColor)&&(W.fillColor=h.fillColor),W&&p&&(W.fillColor=p),W&&O.isBoolean(L)&&(W.canRotate=L),W&&D&&(W.scaleType=D),W&&N&&(W.canTextEdit=N),W&&A&&(W.textOpt=A),W&&O.isBoolean(nt)&&(W.canLock=nt),W&&O.isBoolean(tt)&&(W.isLocked=tt),W&&V&&(W.shapeOpt=V),W&&K&&(W.toolsTypes=K),W&&$&&(W.thickness=$),W&&G&&(W.strokeType=G),W&&O.isBoolean(J)&&(W.useStroke=J),j&&this.viewContainerManager.showFloatBar(j,!!W,W),f&&((o=this.collector)==null||o.dispatch({type:c,selectIds:l,opt:h,isSync:I,viewId:j,scenePath:at}));break}case z.Snapshot:if(y&&at){const W=this.snapshotMap.get(at);W&&W(y)}break;case z.BoundingBox:if(w&&at){const W=this.boundingRectMap.get(at);W&&W(w)}break;case z.Cursor:S&&this.control.cursor.collectServiceCursor({...a});break;case z.Clear:if(j){this.viewContainerManager.showFloatBar(j,!1);const W=(n=this.clearAllResolveMap.get(j))==null?void 0:n.resolve;W&&W(j)}break;case z.TextUpdate:if(P===C.Text&&E&&j){const W=this.viewContainerManager.transformToOriginPoint((h==null?void 0:h.boxPoint)||[0,0],j),it=(h==null?void 0:h.boxSize)||[0,0],ht=(i=this.viewContainerManager.getView(j))==null?void 0:i.cameraOpt;h?this.control.textEditorManager.updateTextForWorker({x:W[0],y:W[1],w:it[0],h:it[1],scale:(ht==null?void 0:ht.scale)||1,workId:E,opt:h,dataType:_,viewId:j,canSync:f||!1,canWorker:!1}):this.control.textEditorManager.delete(E,f||!1,!1)}break;case z.GetTextActive:P===C.Text&&E&&j&&this.control.textEditorManager.updateTextForWorker({workId:E,isActive:!0,viewId:j,dataType:F.Local,canWorker:!1,canSync:!0},Date.now());break;case z.GetImageBitMap:It&&E&&j&&ig({src:It,isgl:rt}).then(W=>{var ht;const it=new Set;if(it.add({msgType:z.GetImageBitMap,dataType:F.Local,workId:E,viewId:j,imageSrc:It,isSubWorker:ot,imageBitmap:W}),!this.control.hasOffscreenCanvas())(ht=this.mainThread)==null||ht.consume(it);else{const vt=ot?this.subWorker:this.fullWorker;W?vt.postMessage(it,[W]):vt.postMessage(it)}});break;default:e=!0;break}}e&&Zt(()=>{this.collectorAsyncData(t)},this.maxLastSyncTime)}collectorAsyncData(t){var e,o,n,i;for(const a of t){const{type:c,op:l,workId:h,index:u,removeIds:d,ops:p,opt:f,updateNodeOpt:I,toolsType:y,isSync:v,viewId:m,isLockSentEventCursor:w,nextTasks:S}=a;if(!m){console.error("collectorAsyncData",a);return}const N=a.scenePath||this.viewContainerManager.getCurScenePath(m);switch(c){case z.DrawWork:{(e=this.collector)==null||e.dispatch({type:c,op:l,opt:f,toolsType:y,workId:h,index:u,isSync:v,viewId:m,scenePath:N,updateNodeOpt:I});break}case z.FullWork:{(o=this.collector)==null||o.dispatch({type:c,ops:p,workId:h,updateNodeOpt:I,opt:f,toolsType:y,isSync:v,viewId:m,scenePath:N}),this.willSelectorWorkId&&h&&h.toString()===this.willSelectorWorkId&&this.control.runEffectWork(()=>{this.setShapeSelectorByWorkId(this.willSelectorWorkId,m),this.willSelectorWorkId=void 0}),w&&Zt(()=>{this.setLockSentEventCursor(!1)},this.maxLastSyncTime);break}case z.UpdateNode:{(n=this.collector)==null||n.dispatch({type:c,updateNodeOpt:I,workId:h,opt:f,ops:p,op:l,isSync:v,viewId:m,scenePath:N});break}case z.RemoveNode:{d&&this.control.textEditorManager.deleteBatch(d,!1,!1),(i=this.collector)==null||i.dispatch({type:c,removeIds:d,isSync:v,viewId:m,scenePath:N}),this.willSelectorWorkId&&(d!=null&&d.includes(this.willSelectorWorkId))&&(this.willSelectorWorkId=void 0),w&&Zt(()=>{this.setLockSentEventCursor(!1)},this.maxLastSyncTime);break}}S&&Zt(()=>{this.collectorAsyncData(S)},this.maxLastSyncTime)}}async onLocalEventEnd(t,e){var l;const o=this.viewContainerManager.getView(e);if(!o)return;const{focusScenePath:n,cameraOpt:i}=o,a=this.viewContainerManager.transformToScenePoint(t,e),c=[];for(const h of this.localPointsBatchData.keys())if(((l=this.currentToolsData)==null?void 0:l.toolsType)===C.Text){const u=this.getLocalPointInfo(h),d=u==null?void 0:u.state;if(d&&d===b.Start){const p=this.currentLocalWorkData.toolsOpt;p.workState=b.Doing,p.boxPoint=a,p.boxSize=[p.fontSize,p.fontSize],this.control.textEditorManager.checkEmptyTextBlur(),this.control.textEditorManager.createTextForMasterController({workId:Date.now().toString(),x:t[0],y:t[1],scale:(i==null?void 0:i.scale)||1,opt:p,type:Ut.Text,isActive:!0,viewId:e,scenePath:n},Date.now())}this.deleteLocalPoint(h);continue}else this.pushLocalPoint(h,a,b.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 n;if(((n=this.currentToolsData)==null?void 0:n.toolsType)===C.Text)return;this.currentLocalWorkData.workState===b.Start&&this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:b.Doing});let o=!1;for(const[i,{state:a}]of this.localPointsBatchData.entries())if(this.isAbled()&&a!==b.Pending){const c=this.viewContainerManager.transformToScenePoint(t,e);this.pushLocalPoint(i,c,a===b.Start?b.Doing:a,e),o=!0}if(o){this.runAnimation();return}this.useTasksqueue||this.hoverCursor(t,e)}onLocalEventStart(t,e){var a,c,l,h,u,d;this.viewContainerManager.focuedViewId!==e&&this.viewContainerManager.setFocuedViewId(e),this.isCanDrawWork&&this.control.room&&!this.control.room.disableDeviceInputs&&(this.control.room.disableDeviceInputs=!0);const o=((a=this.currentToolsData)==null?void 0:a.toolsType)===C.Selector?H:Date.now(),n=this.setZIndex(e);this.setCurrentLocalWorkData({workState:b.Start,toolsOpt:n,viewId:e});const i=this.viewContainerManager.transformToScenePoint(t,e);if(this.pushLocalPoint(o,i,b.Start,e,n),((c=this.currentToolsData)==null?void 0:c.toolsType)!==C.Text){if(this.control.textEditorManager.checkEmptyTextBlur(),this.isCanRecordUndoRedo&&this.internalMsgEmitter.emit("addUndoTicker",o,e),o&&n&&((l=this.currentToolsData)!=null&&l.toolsType)&&this.isCanStartEventConsum&&this.prepareOnceWork({workId:o,toolsOpt:n,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,o,n,i){let a=this.getLocalPointInfo(t);o===b.Start?a={state:b.Start,points:e,opt:i||this.currentLocalWorkData.toolsOpt,isFullWork:!1,viewId:n}:a&&(a.state=o,a.points.push(e[0],e[1])),a&&this.localPointsBatchData.set(t,a)}deleteLocalPoint(t){this.localPointsBatchData.delete(t)}getLocalPointInfo(t){return this.localPointsBatchData.get(t)}getLocalPointsInfo(){return this.localPointsBatchData}correctStorage(t,e,o){var c;const n=new Map,i=[];Object.keys(t).forEach(l=>{var u,d;const h=(d=(u=t[l])==null?void 0:u.opt)==null?void 0:d.zIndex;O.isNumber(h)&&i.push([l,h])});const a=i.length&&((c=this.zIndexNodeMethod)==null?void 0:c.correct(i))||[];this.zIndexNodeMethod&&a.length&&(this.zIndexNodeMethod.setMinZIndex(a[0][1]||0,e),this.zIndexNodeMethod.setMaxZIndex(a[a.length-1][1]||0,e));for(const[l,h]of a){if(!t[l])continue;const u=t[l];u.opt&&O.isNumber(u.opt.zIndex)&&u.opt.zIndex!==h&&(u.opt.zIndex=h,n.set(l,u))}return n.size&&n.forEach((l,h)=>{var u;(u=this.collector)==null||u.updateValue(h,l,{viewId:e,scenePath:o,isSync:!0}),t[h]=l}),t}async originalEventLintener(t,e,o){if(this.isAbled())switch(t){case b.Start:this.setLocalWorkViewId(o),o&&this.onLocalEventStart(e,o);break;case b.Doing:o&&o===this.getLocalWorkViewId()&&this.onLocalEventDoing(e,o);break;case b.Done:o&&o===this.getLocalWorkViewId()&&await this.onLocalEventEnd(e,o);break}}getLocalWorkViewId(){return this.localWorkViewId}setLocalWorkViewId(t){this.localWorkViewId=t}setCurrentToolsData(t){var n,i,a;const e=t.toolsType,o=((n=this.currentToolsData)==null?void 0:n.toolsType)!==t.toolsType;if(super.setCurrentToolsData(t),o){const c=(i=this.viewContainerManager)==null?void 0:i.getAllViews();for(const l of c)if(l){const{id:h,focusScenePath:u}=l;o&&h&&u&&((a=this.collector)!=null&&a.hasSelector(h,u)&&this.blurSelector(h,u),this.control.textEditorManager.checkEmptyTextBlur())}this.taskBatchData.add({msgType:z.UpdateTools,dataType:F.Local,toolsType:e,opt:{...t.toolsOpt,syncUnitTime:this.maxLastSyncTime},isRunSubWork:this.isRunSubWork,viewId:Ue}),this.runAnimation()}}prepareOnceWork(t,e){const{workId:o,toolsOpt:n,viewId:i}=t;this.queryTaskBatchData({msgType:z.CreateWork,dataType:F.Local,viewId:i,toolsType:e}).forEach(a=>{this.taskBatchData.delete(a)}),this.taskBatchData.add({msgType:z.CreateWork,workId:o,toolsType:e,opt:{...n,syncUnitTime:this.maxLastSyncTime},dataType:F.Local,isRunSubWork:this.isRunSubWork,viewId:i}),this.runAnimation()}createViewWorker(t,e){const{offscreenCanvasOpt:o,layerOpt:n,dpr:i,cameraOpt:a}=e;this.taskBatchData.add({msgType:z.Init,dataType:F.Local,viewId:t,offscreenCanvasOpt:o,layerOpt:n,dpr:i,cameraOpt:a,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1}),this.isBusy&&this.destroyTaskQueue(),this.consume()}destroyViewWorker(t,e=!1){var o;this.getLocalWorkViewId()===t&&this.setLocalWorkViewId(void 0),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(t),this.taskBatchData.add({msgType:z.Destroy,dataType:F.Local,viewId:t,isRunSubWork:!0}),this.consume(),e||(o=this.collector)==null||o.dispatch({type:z.Clear,viewId:t})}onServiceDerive(t,e){var p,f,I,y,v;const{newValue:o,oldValue:n,viewId:i,scenePath:a}=e,c=O.cloneDeep(o)||{},l=t;let h=c.type;if(!o&&n){if(l&&((p=this.collector)==null?void 0:p.getLocalId(l))===H){this.collector.isOwn(l)?this.blurSelector(i,a):this.blurSelector(i,a,l);return}if(h=z.RemoveNode,n.toolsType===C.LaserPen)return}const u=(f=this.viewContainerManager.getView(i))==null?void 0:f.focusScenePath;if(u&&u!==a)return;if(h&&l){const m=c;if(m.workId=(I=this.collector)!=null&&I.isOwn(l)?(y=this.collector)==null?void 0:y.getLocalId(l):l,m.msgType=h,m.toolsType===C.LaserPen&&(m.isRunSubWork=!0),m.dataType=F.Service,m.viewId=i,m.scenePath=a,m.selectIds&&(m.selectIds=m.selectIds.map(w=>{var S,N;return(S=this.collector)!=null&&S.isOwn(w)?(N=this.collector)==null?void 0:N.getLocalId(w):w})),m&&m.toolsType===C.Text||(n==null?void 0:n.toolsType)===C.Text){this.control.textEditorManager.onServiceDerive(m);return}this.taskBatchData.add(m)}this.runAnimation();const d=e.newValue&&((v=e.newValue.opt)==null?void 0:v.zIndex);if(this.zIndexNodeMethod&&O.isNumber(d)){const m=this.zIndexNodeMethod.getMinZIndex(i);this.zIndexNodeMethod.getMaxZIndex(i)<d&&this.zIndexNodeMethod.setMaxZIndex(d,i),m>d&&this.zIndexNodeMethod.setMinZIndex(d,i)}}pullServiceData(t,e,o={isAsync:!1,useAnimation:!1}){var c,l,h,u;let n=(c=this.collector)==null?void 0:c.getStorageData(t,e);const{isAsync:i,useAnimation:a}=o;if(n){n=this.correctStorage(n,t,e);const d=Object.keys(n);for(const p of d){const f=(l=n[p])==null?void 0:l.type;if(f&&p){const I=n[p];if(I.workId=(h=this.collector)!=null&&h.isOwn(p)?(u=this.collector)==null?void 0:u.getLocalId(p):p,I.msgType=f,I.dataType=F.Service,I.viewId=t,I.scenePath=e,I.useAnimation=!!a,I.selectIds&&(I.selectIds=I.selectIds.map(y=>{var v,m;return(v=this.collector)!=null&&v.isOwn(y)?(m=this.collector)==null?void 0:m.getLocalId(y):y})),I.toolsType===C.Text){this.control.textEditorManager.onServiceDerive(I);continue}this.taskBatchData.add(I)}this.internalMsgEmitter.emit("excludeIds",d,t)}i?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 o=this.consumeQueue(),n=!!o.size;if(this.taskBatchData.size)for(const i of this.taskBatchData.values())i.dataType===F.Service&&(o.add(i),this.taskBatchData.delete(i));o.size?(this.post(o),n&&this.tasksqueue.clear()):this.tasksqueue.size&&(this.animationId=requestAnimationFrame(this.consume.bind(this)));return}if(this.isAbled()&&this.localPointsBatchData.size&&t)for(const[o,{state:n,isFullWork:i,points:a,opt:c}]of this.localPointsBatchData.entries()){if(n===b.Done&&!i||n===b.Start&&!this.isCanStartEventConsum)continue;const l=a.map(h=>h);l.length&&(this.delayWorkStateToDoneResolve&&n===b.Done&&(this.delayWorkStateToDoneResolve(!0),this.setLockSentEventCursor(!0)),this.taskBatchData.add({op:l,workState:n,workId:o,dataType:F.Local,msgType:z.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(e=this.currentToolsData)==null?void 0:e.toolsType,viewId:t,scenePath:t&&this.viewContainerManager.getCurScenePath(t),opt:c,isLockSentEventCursor:this.getLockSentEventCursor(),syncUnitTime:this.maxLastSyncTime}),a.length=0)}this.taskBatchData.size&&(this.post(this.taskBatchData),this.taskBatchData.clear()),this.taskBatchData.size&&(this.animationId=requestAnimationFrame(this.consume.bind(this)))}unWritable(){this.setCurrentLocalWorkData({workState:b.Unwritable,workId:void 0})}abled(){this.setCurrentLocalWorkData({workState:b.Pending,workId:void 0})}isAbled(){return this.currentLocalWorkData.workState!==b.Unwritable}post(t){var o;if(!this.control.hasOffscreenCanvas()){if(!this.mainThread){let n=[];n=O.cloneDeep([...t]),setTimeout(()=>{for(const i of n)this.taskBatchData.add(i)},0);return}this.mainThread.consume(t);return}this.fullWorker.postMessage(t);const e=new Set;for(const n of t.values()){const i=n.msgType;(i===z.Init||i===z.Clear||i===z.Destroy||i===z.UpdateCamera||n.isRunSubWork)&&e.add(n)}e.size&&(this.subWorker.postMessage(e),this.control.priority==="ui"&&((o=this.subMainThreadWorker)==null||o.consume(e)))}updateNode(t,e,o,n){this.taskBatchData.add({msgType:z.UpdateNode,workId:t,updateNodeOpt:e,viewId:o,scenePath:n,dataType:F.Local}),this.runAnimation()}destroyTaskQueue(){this.useTasksqueue=!1,this.useTasksClockId&&(clearTimeout(this.useTasksClockId),this.useTasksClockId=void 0),this.mainTasksqueueCount=void 0,this.workerTasksqueueCount=void 0}updateCamera(t,e){var o;this.useTasksqueue||((o=this.methodBuilder)==null||o.pause(),this.blurCursor(t),this.checkDrawingWork(t),this.useTasksqueue=!0,this.mainTasksqueueCount=1,this.workerTasksqueueCount=1),this.useTasksqueue&&(this.tasksqueue.set(t,{msgType:z.UpdateCamera,dataType:F.Local,cameraOpt:{...e,width:e.width,height:e.height},scenePath:this.viewContainerManager.getCurScenePath(t),isRunSubWork:!0,viewId:t}),this.consume(),this.useTasksClockId&&clearTimeout(this.useTasksClockId),this.updateCameraDone())}updateCameraDone(){this.useTasksClockId=setTimeout(()=>{var t,e;this.useTasksClockId=void 0,this.mainTasksqueueCount===this.workerTasksqueueCount?(this.tasksqueue.size&&this.consume(),this.useTasksqueue=!1,this.mainTasksqueueCount=void 0,this.workerTasksqueueCount=void 0,this.control.priority==="ui"&&((t=this.subMainThreadWorker)==null||t.updateCamera()),(e=this.methodBuilder)==null||e.recover(),this.runAnimation()):this.updateCameraDone()},this.maxLastSyncTime)}consumeQueue(){const t=new Set;let e=!this.isBusy;if(this.isBusy&&this.mainTasksqueueCount&&this.workerTasksqueueCount&&this.mainTasksqueueCount<=this.workerTasksqueueCount&&(e=!0),e){this.mainTasksqueueCount&&this.workerTasksqueueCount&&this.mainTasksqueueCount++,t.add({msgType:z.TasksQueue,dataType:F.Local,isRunSubWork:!0,mainTasksqueueCount:this.mainTasksqueueCount,tasksqueue:this.tasksqueue,viewId:""});for(const[o,n]of this.tasksqueue.entries())n.cameraOpt&&this.control.textEditorManager.onCameraChange(n.cameraOpt,o)}return t}async clearViewScenePath(t,e){var o;if(this.control.textEditorManager.clear(t,e),this.queryTaskBatchData({msgType:z.Clear,dataType:F.Local,viewId:t}).forEach(n=>{this.taskBatchData.delete(n)}),this.taskBatchData.add({dataType:F.Local,msgType:z.Clear,viewId:t}),this.runAnimation(),!e){const n=this.viewContainerManager.getCurScenePath(t);(o=this.collector)==null||o.dispatch({type:z.Clear,viewId:t,scenePath:n})}this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(t),this.localPointsBatchData.clear(),await new Promise(n=>{const i=this.clearAllResolveMap.get(t)||{resolve:void 0,timer:void 0};i.timer&&clearTimeout(i.timer),i.resolve=n,i.timer=setTimeout(()=>{const a=this.clearAllResolveMap.get(t);a!=null&&a.resolve&&a.resolve(t)},this.maxLastSyncTime),this.clearAllResolveMap.set(t,i)}).then(n=>{this.clearAllResolveMap.delete(n)})}internalMsgEmitterListener(){var t;this.methodBuilder=new q([R.CopyNode,R.SetColorNode,R.DeleteNode,R.RotateNode,R.ScaleNode,R.TranslateNode,R.ZIndexNode,R.RotateNode,R.SetFontStyle,R.SetPoint,R.SetLock,R.SetShapeOpt]).registerForMainEngine(Z.MainEngine,this.control),this.zIndexNodeMethod=(t=this.methodBuilder)==null?void 0:t.getBuilder(R.ZIndexNode)}setZIndex(t){const e=this.currentToolsData&&O.cloneDeep(this.currentToolsData.toolsOpt);return e&&this.zIndexNodeMethod&&this.isUseZIndex&&(this.zIndexNodeMethod.addMaxLayer(t),e.zIndex=this.zIndexNodeMethod.getMaxZIndex(t)),e}checkDrawingWork(t){var n,i,a;let e=!1;const o=[];for(const[c,{state:l,viewId:h,points:u,opt:d}]of this.localPointsBatchData.entries())if(t===h&&l===b.Start||l===b.Doing){if(l===b.Doing&&this.isCanDrawWork){Number(c)&&Number(c)+60>Date.now()&&(o.push(c.toString()),this.taskBatchData.add({msgType:z.RemoveNode,workId:c,viewId:h,dataType:F.Local,isRunSubWork:!0}));const p=u.map(f=>f);this.taskBatchData.add({op:p,workState:b.Done,workId:c,dataType:F.Local,msgType:z.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(n=this.currentToolsData)==null?void 0:n.toolsType,viewId:h,opt:d,scenePath:h&&this.viewContainerManager.getCurScenePath(h)}),e=!0}this.deleteLocalPoint(c)}if((e||o.length)&&(this.consume(),o.length)){const c=(i=this.viewContainerManager.getView(t))==null?void 0:i.focusScenePath;(a=this.collector)==null||a.dispatch({type:z.RemoveNode,removeIds:o,viewId:t,scenePath:c})}}removeDrawingWork(t){var o,n;const e=[];for(const[i,{state:a,viewId:c}]of this.localPointsBatchData.entries())(t===c&&a===b.Start||a===b.Doing)&&(this.deleteLocalPoint(i),a===b.Doing&&this.isCanDrawWork&&(e.push(i.toString()),this.taskBatchData.add({msgType:z.RemoveNode,workId:i,viewId:c,dataType:F.Local,isRunSubWork:!0})));if(e.length){this.consume();const i=(o=this.viewContainerManager.getView(t))==null?void 0:o.focusScenePath;(n=this.collector)==null||n.dispatch({type:z.RemoveNode,removeIds:e,viewId:t,scenePath:i})}}hoverCursor(t,e){var o;if(((o=this.currentToolsData)==null?void 0:o.toolsType)===C.Selector){const n=this.viewContainerManager.getView(e);if(n&&n.displayer&&n.displayer.vDom){const c=n.displayer.vDom.state.floatBarData;if(c){const{x:l,y:h,w:u,h:d}=c;if(Si(t,{x:l,y:h,w:u,h:d}))return}}const i=this.viewContainerManager.transformToScenePoint(t,e),a={msgType:z.CursorHover,dataType:F.Local,point:i,toolsType:this.currentToolsData.toolsType,opt:this.currentToolsData.toolsOpt,isRunSubWork:!1,viewId:e};this.queryTaskBatchData({msgType:z.CursorHover,dataType:F.Local,toolsType:this.currentToolsData.toolsType,viewId:e}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add(a),this.runAnimation()}}blurCursor(t){var o;if(((o=this.currentToolsData)==null?void 0:o.toolsType)!==C.Selector)return;const e={msgType:z.CursorBlur,dataType:F.Local,isRunSubWork:!1,viewId:t};this.queryTaskBatchData({msgType:z.CursorHover,dataType:F.Local,viewId:t}).forEach(n=>{this.taskBatchData.delete(n)}),this.taskBatchData.add(e),this.consume()}sendCursorEvent(t,e){if(!this.currentLocalWorkData||this.currentLocalWorkData.workState===b.Unwritable||!this.currentToolsData||!this.isCanSentCursor)return;let o=[void 0,void 0];this.currentToolsData&&(this.isCanDrawWork||this.currentToolsData.toolsType===C.Text)&&!this.localPointsBatchData.size&&!this.getLockSentEventCursor()&&(o=t,this.control.cursor.sendEvent(o,e))}getBoundingRect(t){var o,n;if(!((o=this.boundingRectMap)==null?void 0:o.get(t))){const i=(n=this.collector)==null?void 0:n.getScenePathData(t);if(!i)return;if(Object.keys(i).forEach(a=>{var c;((c=this.collector)==null?void 0:c.getLocalId(a))===H&&delete i[a]}),Object.keys(i).length&&this.viewContainerManager.mainView&&this.viewContainerManager.mainView.cameraOpt){const a={msgType:z.BoundingBox,dataType:F.Local,scenePath:t,scenes:i,cameraOpt:{...this.viewContainerManager.mainView.cameraOpt},isRunSubWork:!0,viewId:this.viewContainerManager.mainView.id};return this.taskBatchData.add(a),this.runAnimation(),new Promise(c=>{this.boundingRectMap.set(t,c)}).then(c=>(this.boundingRectMap.delete(t),c))}}}getSnapshot(t,e,o,n){var a,c,l,h,u;if(!((a=this.snapshotMap)==null?void 0:a.get(t))){const d=(c=this.collector)==null?void 0:c.getViewIdBySecenPath(t);if(!d)return;const p=(l=this.collector)==null?void 0:l.getStorageData(d,t);if(!p)return;if(Object.keys(p).forEach(f=>{var I;((I=this.collector)==null?void 0:I.getLocalId(f))===H&&delete p[f]}),Object.keys(p).length){const f=this.viewContainerManager.mainView;if(!f)return;const I=e||((h=f.cameraOpt)==null?void 0:h.width),y=o||((u=f.cameraOpt)==null?void 0:u.height),v={msgType:z.Snapshot,dataType:F.Local,scenePath:t,scenes:p,w:I,h:y,cameraOpt:n&&{...n,width:I,height:y}||f.cameraOpt,isRunSubWork:!0,viewId:f.id};return this.taskBatchData.add(v),this.runAnimation(),new Promise(m=>{this.snapshotMap.set(t,m)}).then(m=>(this.snapshotMap.delete(t),m))}}}queryTaskBatchData(t){const e=[];if(t)for(const o of this.taskBatchData.values()){let n=!0;for(const[i,a]of Object.entries(t))if(o[i]!==a){n=!1;break}n&&e.push(o)}return e}insertImage(t){const e=this.viewContainerManager.mainView,o=e==null?void 0:e.id,n=e==null?void 0:e.focusScenePath;if(o&&n){const{src:i,uuid:a}=t;if(a&&!i){this.tmpImageConfigMap.set(a,t);return}const c=Date.now();mt.InternalMsgEmitter.emit("addUndoTicker",c,o);const l={...t};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(o),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(o)),this.taskBatchData.add({msgType:z.FullWork,dataType:F.Local,toolsType:C.Image,workId:t.uuid,opt:l,viewId:o,willRefresh:!0,willSyncService:!0}),this.runAnimation()}}lockImage(t,e){var a,c;const o=this.viewContainerManager.mainView,n=o==null?void 0:o.id,i=o==null?void 0:o.focusScenePath;if(n&&i&&this.collector){const l=this.collector.getStorageData(n,i);if(!l)return;for(const[h,u]of Object.entries(l))if(u&&u.toolsType===C.Image&&u.opt.uuid===t){const d=Date.now();mt.InternalMsgEmitter.emit("addUndoTicker",d,n);const p=(a=this.collector)!=null&&a.isOwn(h)?(c=this.collector)==null?void 0:c.getLocalId(h):h,f={...u.opt,locked:e};this.taskBatchData.add({msgType:z.FullWork,dataType:F.Local,toolsType:C.Image,workId:p,opt:f,viewId:n,willRefresh:!0,willSyncService:!0}),this.runAnimation();return}}}completeImageUpload(t,e){const o=this.viewContainerManager.mainView,n=o==null?void 0:o.id,i=o==null?void 0:o.focusScenePath;if(n&&i){const a=this.tmpImageConfigMap.get(t);a&&(a.src=e,this.insertImage(a),this.tmpImageConfigMap.delete(t));return}}getImagesInformation(t){const e=[];if(this.collector){const o=this.collector.getScenePathData(t);if(!o)return e;for(const n of Object.values(o))if(n&&n.toolsType===C.Image){const i=n.opt;e.push({uuid:i.uuid,centerX:i.centerX,centerY:i.centerY,width:i.width,height:i.height,locked:i.locked,uniformScale:i.uniformScale,crossOrigin:i.crossOrigin})}}return e}setShapeSelectorByWorkId(t,e){this.taskBatchData.add({workId:H,selectIds:[t],msgType:z.Select,dataType:F.Local,viewId:e,willSyncService:!0}),this.runAnimation()}blurSelector(t,e,o){this.taskBatchData.add({workId:o||H,selectIds:[],msgType:z.Select,dataType:F.Service,viewId:t,scenePath:e}),this.runAnimation()}consoleWorkerInfo(){this.taskBatchData.add({msgType:z.Console,dataType:F.Local,isRunSubWork:!0,viewId:""}),this.consume()}setPriority(t){var n,i;const e=new Set,o=new Set;if(t==="cpu"&&((n=this.subMainThreadWorker)==null||n.destroy(),e.add({msgType:z.PriorityWorker,viewId:Ue,dataType:F.Local,isRunSubWork:!0})),t==="ui"){e.add({msgType:z.PriorityMainThreadWorker,viewId:Ue,dataType:F.Local,isRunSubWork:!0});const a=this.viewContainerManager.mainView;if(a){const l=this.viewContainerManager.getViewInitData(a.id);if(l){const{offscreenCanvasOpt:h,layerOpt:u,dpr:d,cameraOpt:p}=l;o.add({msgType:z.Init,dataType:F.Local,viewId:a.id,offscreenCanvasOpt:h,layerOpt:u,dpr:d,cameraOpt:p,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1})}}const c=this.viewContainerManager.appViews;for(const l of c.keys()){const h=this.viewContainerManager.getViewInitData(l);if(h){const{offscreenCanvasOpt:u,layerOpt:d,dpr:p,cameraOpt:f}=h;o.add({msgType:z.Init,dataType:F.Local,viewId:l,offscreenCanvasOpt:u,layerOpt:d,dpr:p,cameraOpt:f,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1})}}}e.size&&this.subWorker.postMessage(e),o.size&&((i=this.subMainThreadWorker)==null||i.consume(o))}}var ag=Rt,cg=function(){return ag.Date.now()},lg=cg,hg=/\s/;function ug(r){for(var s=r.length;s--&&hg.test(r.charAt(s)););return s}var dg=ug,pg=dg,fg=/^\s+/;function gg(r){return r&&r.slice(0,pg(r)+1).replace(fg,"")}var Mg=gg,yg=se,mg=Qt,wg="[object Symbol]";function Ig(r){return typeof r=="symbol"||mg(r)&&yg(r)==wg}var vg=Ig,Ng=Mg,ks=Xt,Tg=vg,xs=NaN,Sg=/^[-+]0x[0-9a-f]+$/i,Cg=/^0b[01]+$/i,kg=/^0o[0-7]+$/i,xg=parseInt;function zg(r){if(typeof r=="number")return r;if(Tg(r))return xs;if(ks(r)){var s=typeof r.valueOf=="function"?r.valueOf():r;r=ks(s)?s+"":s}if(typeof r!="string")return r===0?r:+r;r=Ng(r);var t=Cg.test(r);return t||kg.test(r)?xg(r.slice(2),t?2:8):Sg.test(r)?xs:+r}var Lg=zg,bg=Xt,Mo=lg,zs=Lg,Pg="Expected a function",jg=Math.max,Dg=Math.min;function Eg(r,s,t){var e,o,n,i,a,c,l=0,h=!1,u=!1,d=!0;if(typeof r!="function")throw new TypeError(Pg);s=zs(s)||0,bg(t)&&(h=!!t.leading,u="maxWait"in t,n=u?jg(zs(t.maxWait)||0,s):n,d="trailing"in t?!!t.trailing:d);function p(T){var x=e,L=o;return e=o=void 0,l=T,i=r.apply(L,x),i}function f(T){return l=T,a=setTimeout(v,s),h?p(T):i}function I(T){var x=T-c,L=T-l,D=s-x;return u?Dg(D,n-L):D}function y(T){var x=T-c,L=T-l;return c===void 0||x>=s||x<0||u&&L>=n}function v(){var T=Mo();if(y(T))return m(T);a=setTimeout(v,I(T))}function m(T){return a=void 0,d&&e?p(T):(e=o=void 0,i)}function w(){a!==void 0&&clearTimeout(a),l=0,e=c=o=a=void 0}function S(){return a===void 0?i:m(Mo())}function N(){var T=Mo(),x=y(T);if(e=arguments,o=this,c=T,x){if(a===void 0)return f(c);if(u)return clearTimeout(a),a=setTimeout(v,s),p(c)}return a===void 0&&(a=setTimeout(v,s)),i}return N.cancel=w,N.flush=S,N}var Ag=Eg,Og=Ag,Rg=Xt,Yg="Expected a function";function Wg(r,s,t){var e=!0,o=!0;if(typeof r!="function")throw new TypeError(Yg);return Rg(t)&&(e="leading"in t?!!t.leading:e,o="trailing"in t?!!t.trailing:o),Og(r,s,{leading:e,maxWait:s,trailing:o})}var Ug=Wg;const Pe=je(Ug);class Bg{constructor(s){M(this,"internalMsgEmitter");M(this,"control");M(this,"roomHotkeyCheckers");M(this,"tmpCopyStore",new Map);M(this,"tmpCopyCoordInfo");var o;const{control:t,internalMsgEmitter:e}=s;this.control=t,this.internalMsgEmitter=e,this.roomHotkeyCheckers=((o=this.control.room)==null?void 0:o.viewsParams.hotKeys.nodes)||[]}get isUseSelf(){var s;return((s=this.control.room)==null?void 0:s.disableDeviceInputs)||!1}get isSelector(){var s;return((s=this.control.worker.currentToolsData)==null?void 0:s.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(s){switch(s.type){case"keydown":return"KeyDown"}return"KeyUp"}onActiveHotkey(s){var o,n,i;const t=this.control.viewContainerManager.focuedViewId,e=(o=this.control.viewContainerManager.focuedView)==null?void 0:o.focusScenePath;if(t&&e)switch(s){case"delete":this.isSelector&&((n=this.collector)!=null&&n.hasSelector(t,e))&&q.emitMethod(Z.MainEngine,R.DeleteNode,{workIds:[H],viewId:t});break;case"copy":this.isSelector&&((i=this.collector)!=null&&i.hasSelector(t,e))&&this.copySelectorToTemp(t,e);break;case"paste":this.tmpCopyStore.size&&this.pasteTempToFocusView(t,e);break}(s==="changeToPencil"||s==="redo"||s==="undo")&&this.onSelfActiveHotkey(s)}colloctHotkey(s){if(this.isUseSelf){const t=this.checkHotkey(s);t&&this.onSelfActiveHotkey(t)}}onSelfActiveHotkey(s){switch(s){case"changeToPencil":this.setMemberState({currentApplianceName:et.pencil,useNewPencil:!0});break;case"changeToArrow":this.setMemberState({currentApplianceName:et.arrow});break;case"changeToClick":this.setMemberState({currentApplianceName:et.clicker});break;case"changeToEllipse":this.setMemberState({currentApplianceName:et.ellipse});break;case"changeToEraser":this.setMemberState({currentApplianceName:et.eraser,isLine:!0});break;case"changeToHand":this.setMemberState({currentApplianceName:et.hand});break;case"changeToLaserPointer":this.setMemberState({currentApplianceName:et.laserPointer});break;case"changeToSelector":this.setMemberState({currentApplianceName:et.selector});break;case"changeToRectangle":this.setMemberState({currentApplianceName:et.rectangle});break;case"changeToStraight":this.setMemberState({currentApplianceName:et.straight});break;case"redo":this.control.room&&!this.control.room.disableSerialization&&this.control.viewContainerManager.redo();break;case"undo":this.control.room&&!this.control.room.disableSerialization&&this.control.viewContainerManager.undo();break;case"changeToText":this.setMemberState({currentApplianceName:et.text});break}}checkHotkey(s){for(const t of this.roomHotkeyCheckers){const{kind:e,checker:o}=t;if(o({nativeEvent:s,kind:this.getEventKey(s),key:s.key,altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey},this.keyboardKind))return e}}copySelectorToTemp(s,t){var l,h;const e=this.control.viewContainerManager.getView(s),o=(h=(l=this.mainEngine)==null?void 0:l.methodBuilder)==null?void 0:h.getBuilder(R.CopyNode);if(!e||!this.collector||!o)return;const n=this.collector.transformKey(H),i=this.collector.getStorageData(s,t);if(!i)return;const a=i[n],c=a&&o.copySelector({viewId:s,store:a});c&&(this.tmpCopyCoordInfo=c==null?void 0:c.copyCoordInfo,this.tmpCopyStore=c==null?void 0:c.copyStores)}pasteTempToFocusView(s,t){var n,i;const e=this.control.viewContainerManager.getView(s),o=(i=(n=this.mainEngine)==null?void 0:n.methodBuilder)==null?void 0:i.getBuilder(R.CopyNode);if(!(!e||!this.tmpCopyCoordInfo||!this.tmpCopyStore.size||!this.collector||!o)&&e.viewData&&this.tmpCopyCoordInfo){const a=O.cloneDeep(this.tmpCopyCoordInfo.offset),c=this.tmpCopyCoordInfo.cameraOpt,l=e.viewData.camera;a.x=a.x+l.centerX-c.centerX,a.y=a.y+l.centerY-c.centerY;const h=Date.now();this.control.worker.internalMsgEmitter.emit("addUndoTicker",h,s),o.pasteSelector({viewId:s,scenePath:t,copyStores:O.cloneDeep(this.tmpCopyStore),copyCoordInfo:{offset:a,cameraOpt:l},undoTickerId:h})}}setMemberState(s){var t;(t=this.control.room)==null||t.setMemberState(s)}}const ze=class ze{constructor(s){M(this,"version",ri);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,"onSceneChange",async(s,t)=>{var i;const e=this.viewContainerManager.getView(t);e!=null&&e.focusScenePath&&(i=this.collector)!=null&&i.hasSelector(t,e.focusScenePath)&&this.worker.blurSelector(t,e.focusScenePath),this.textEditorManager.checkEmptyTextBlur();const o=e==null?void 0:e.displayer;o&&(o.setActive(!1),await o.stopEventHandler());const n=s;n&&this.viewContainerManager.setViewScenePath(t,n),o==null||o.setActive(!0)});M(this,"onRoomMembersChange",s=>{this.roomMember.setRoomMembers(st.toJS(s))});M(this,"onMemberChange",Pe(s=>{if(!this.room||!this.worker||!s)return;const t=this.getToolsKey(s),e=this.getToolsOpt(t,s);this.worker.setCurrentToolsData(e),this.effectViewContainer(t),this.effectResolve&&this.effectResolve(!0)},100,{leading:!1}));M(this,"internalSceneChange",(s,t)=>{var e;(e=this.worker)==null||e.clearViewScenePath(s,!0).then(()=>{var o;(o=this.worker)==null||o.pullServiceData(s,t,{isAsync:!0,useAnimation:!1})})});M(this,"internalCameraChange",(s,t)=>{var e;(e=this.worker)==null||e.updateCamera(s,t)});const{displayer:t,plugin:e,options:o}=s;this.plugin=e,this.room=st.isRoom(t)?t:void 0,this.play=st.isPlayer(t)?t:void 0,this.pluginOptions=o,this.roomMember=new Yf;const n={control:this,internalMsgEmitter:ze.InternalMsgEmitter};this.cursor=new Ff(n),this.textEditorManager=new Bf(n),this.worker=new rg(n),this.hotkeyManager=new Bg(n)}setPriority(s){var t;this.priority=s,this.hasOffscreenCanvas()&&((t=this.worker)==null||t.setPriority(s))}hasOffscreenCanvas(){return ai==="worker"}bindPlugin(s){var t,e;this.plugin=s,this.collector&&this.collector.removeStorageStateListener(),this.collector=new So(this,s,(e=(t=this.pluginOptions)==null?void 0:t.syncOpt)==null?void 0:e.interval),this.activePlugin()}destroy(){var s,t,e,o,n;this.roomMember.destroy(),(s=this.collector)==null||s.destroy(),(t=this.worker)==null||t.destroy(),(e=this.viewContainerManager)==null||e.destroy(),(o=this.cursor)==null||o.destroy(),(n=this.textEditorManager)==null||n.destory()}cleanCurrentScene(){const s=Date.now(),t=this.worker.getLocalWorkViewId()||this.viewContainerManager.focuedViewId;t&&(ze.InternalMsgEmitter.emit("addUndoTicker",s,t),this.worker.clearViewScenePath(t))}onWritableChange(s){var t,e;s?(e=this.worker)==null||e.abled():(t=this.worker)==null||t.unWritable()}getToolsKey(s){var e;const t=s.currentApplianceName;switch(this.hasSwitchToSelectorEffect=!1,t){case et.text:return s.textCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Text;case et.pencil:return s.useLaserPen?C.LaserPen:C.Pencil;case et.eraser:return C.Eraser;case et.pencilEraser:return((e=this.pluginOptions.pencilEraser)==null?void 0:e.useBitMap)===!1?C.PencilEraser:C.BitMapEraser;case et.selector:return C.Selector;case et.arrow:return s.arrowCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Arrow;case et.straight:return s.straightCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Straight;case et.ellipse:return s.ellipseCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Ellipse;case et.rectangle:return s.rectangleCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),C.Rectangle;case et.shape:if(s.shapeCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),s.shapeType===Dt.Pentagram||s.shapeType===Dt.Star)return C.Star;if(s.shapeType===Dt.Polygon||s.shapeType===Dt.Triangle||s.shapeType===Dt.Rhombus)return C.Polygon;if(s.shapeType===Dt.SpeechBalloon)return C.SpeechBalloon;break}return C.Clicker}getToolsOpt(s,t){if(s===C.Clicker)return{toolsType:s,toolsOpt:{}};const e={strokeColor:Oe(t.strokeColor[0],t.strokeColor[1],t.strokeColor[2],t.strokeOpacity||1),thickness:t.strokeWidth,isOpacity:(t==null?void 0:t.strokeOpacity)&&t.strokeOpacity<1||(t==null?void 0:t.fillOpacity)&&t.fillOpacity<1||(t==null?void 0:t.textOpacity)&&t.textOpacity<1||(t==null?void 0:t.textBgOpacity)&&t.textBgOpacity<1||!1};switch(s){case C.Text:e.fontFamily=window.getComputedStyle(document.documentElement).getPropertyValue("font-family"),e.fontSize=(t==null?void 0:t.textSizeOverride)||(t==null?void 0:t.textSize)||Number(window.getComputedStyle(document.body).fontSize),e.textAlign=(t==null?void 0:t.textAlign)||"left",e.verticalAlign=(t==null?void 0:t.verticalAlign)||"middle",e.fontColor=(t==null?void 0:t.textColor)&&Oe(t.textColor[0],t.textColor[1],t.textColor[2],t.textOpacity||1)||e.strokeColor||"rgba(0,0,0,1)",e.fontBgColor=Array.isArray(t==null?void 0:t.textBgColor)&&Oe(t.textBgColor[0],t.textBgColor[1],t.textBgColor[2],t.textBgOpacity||1)||"transparent",e.bold=(t==null?void 0:t.bold)&&"bold"||void 0,e.italic=(t==null?void 0:t.italic)&&"italic"||void 0,e.underline=(t==null?void 0:t.underline)||void 0,e.lineThrough=(t==null?void 0:t.lineThrough)||void 0,e.text="",e.strokeColor=void 0;break;case C.Pencil:e.strokeType=(t==null?void 0:t.strokeType)||X.Normal;break;case C.PencilEraser:case C.BitMapEraser:case C.Eraser:e.thickness=Math.min(3,Math.max(1,Math.floor(t.pencilEraserSize||1)))-1;break;case C.LaserPen:e.duration=(t==null?void 0:t.duration)||1,t!=null&&t.strokeType&&(t==null?void 0:t.strokeType)===X.Stroke?e.strokeType=X.Normal:e.strokeType=(t==null?void 0:t.strokeType)||X.Normal;break;case C.Arrow:case C.Straight:t!=null&&t.strokeType&&(t==null?void 0:t.strokeType)===X.Stroke?e.strokeType=X.Normal:e.strokeType=(t==null?void 0:t.strokeType)||X.Normal;break;case C.Ellipse:case C.Rectangle:case C.Star:case C.Polygon:case C.SpeechBalloon:t!=null&&t.strokeType&&(t==null?void 0:t.strokeType)===X.Stroke?e.strokeType=X.Normal:e.strokeType=(t==null?void 0:t.strokeType)||X.Normal,s===C.Star&&(t.shapeType===Dt.Pentagram?(e.vertices=10,e.innerVerticeStep=2,e.innerRatio=.4):t!=null&&t.vertices&&(t!=null&&t.innerVerticeStep)&&(t!=null&&t.innerRatio)&&(e.vertices=t.vertices,e.innerVerticeStep=t.innerVerticeStep,e.innerRatio=t.innerRatio)),s===C.Polygon&&(t.shapeType===Dt.Triangle?e.vertices=3:t.shapeType===Dt.Rhombus?e.vertices=4:t.vertices&&(e.vertices=t.vertices)),e.fillColor=(t==null?void 0:t.fillColor)&&Oe(t.fillColor[0],t.fillColor[1],t.fillColor[2],t==null?void 0:t.fillOpacity)||"transparent",s===C.SpeechBalloon&&(e.placement=t.placement||"bottomLeft");break}return{toolsType:s,toolsOpt:e}}effectViewContainer(s){var t,e,o,n,i;switch(s){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.PencilEraser:case C.BitMapEraser:this.room.disableDeviceInputs=!0,(t=this.worker)==null||t.abled();break;case C.Eraser:case C.Selector:this.room.disableDeviceInputs=!1,(e=this.cursor)==null||e.unabled(),(o=this.worker)==null||o.abled();break;default:this.room.disableDeviceInputs=!1,(n=this.worker)==null||n.unWritable(),(i=this.cursor)==null||i.unabled();break}setTimeout(()=>{this.viewContainerManager.getAllViews().forEach(c=>{c!=null&&c.displayer&&c.displayer.bindToolsClass()})},0)}async getBoundingRect(s){var e,o,n,i,a;const t=await((e=this.worker)==null?void 0:e.getBoundingRect(s));if(t){const c=((n=(o=this.viewContainerManager.mainView)==null?void 0:o.viewData)==null?void 0:n.convertToPointInWorld({x:t.x,y:t.y}))||{x:t.x,y:t.y},l=((a=(i=this.viewContainerManager.mainView)==null?void 0:i.viewData)==null?void 0:a.camera.scale)||1;return{width:Math.floor(t.w/l)+1,height:Math.floor(t.h/l)+1,originX:c.x,originY:c.y}}}async screenshotToCanvas(s,t,e,o,n,i,a){const c=await this.worker.getSnapshot(t,e,o,n);c&&(s.drawImage(c,i||0,a||0),c.close())}async scenePreview(s,t){var i,a,c,l;const e=(i=this.collector)==null?void 0:i.getViewIdBySecenPath(s);if(!e)return;const o=this.viewContainerManager.getView(e);if(!o||!((a=o.cameraOpt)!=null&&a.width)||!((c=o.cameraOpt)!=null&&c.height))return;const n=await((l=this.worker)==null?void 0:l.getSnapshot(s));if(n&&this.worker){const h=document.createElement("canvas"),u=h.getContext("2d"),{width:d,height:p}=o.cameraOpt;h.width=d,h.height=p,u&&(u.drawImage(n,0,0),t.crossOrigin="anonymous",t.src=h.toDataURL(),t.onload=()=>{h.remove()},t.onerror=()=>{h.remove(),t.remove()}),n.close()}}switchToText(){var s;(s=this.room)==null||s.setMemberState({currentApplianceName:et.text})}switchToSelector(){var s;(s=this.room)==null||s.setMemberState({currentApplianceName:et.selector})}async runEffectWork(s){if(this.hasSwitchToSelectorEffect){const t=await new Promise(e=>{this.switchToSelector(),this.effectResolve=e});this.effectResolve=void 0,t&&s&&s()}}setSnapshootData(){var s;this.room&&(this.snapshootStateMap=new Map,this.snapshootStateMap.set("memberState",(s=this.room)==null?void 0:s.state.memberState))}getSnapshootData(s){var t;return(t=this.snapshootStateMap)==null?void 0:t.get(s)}clearSnapshootData(){var s;(s=this.snapshootStateMap)==null||s.clear(),this.snapshootStateMap=void 0}useBitMapEraser(s){var t;if(((t=this.pluginOptions.pencilEraser)==null?void 0:t.useBitMap)===void 0){this.pluginOptions.pencilEraser={useBitMap:s};return}this.pluginOptions.pencilEraser.useBitMap=s}consoleWorkerInfo(){var s;(s=this.worker)==null||s.consoleWorkerInfo()}};M(ze,"InternalMsgEmitter",new js);let mt=ze;const ee=class ee{constructor(s){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",O.debounce(()=>{const s=this.control.viewContainerManager.getCurScenePath(this.viewId);if(s){let t=this.undoStack.filter(o=>o.scenePath===s).length;const e=this.redoStack.filter(o=>o.scenePath===s).length;t===0&&e===0&&this.tickStartStorerCache&&this.scenePath===s&&(t=1),this.emitter.emit("onCanUndoStepsUpdate",t),this.emitter.emit("onCanRedoStepsUpdate",e)}},ee.waitTime));const{control:t,internalMsgEmitter:e,viewId:o}=s;this.control=t,this.emitter=e,this.undoStack=[],this.redoStack=[],this.room=t.room,this.worker=t.worker,this.isTicking=!1,this.viewId=o}get collector(){return this.control.collector}addExcludeIds(s){if(this.isTicking)for(const t of s)this.excludeIds.add(t)}undoTickerStart(s,t){if(this.collector&&(this.undoTickerId!==s||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=s,this.scenePath=t;const o=this.collector.getStorageData(this.viewId,t)||{};this.tickStartStorerCache=new Map(Object.entries(O.cloneDeep(o)))}}undoTickerEndSync(s,t,e){var o,n;if(s===this.undoTickerId&&e===this.scenePath&&t===this.viewId&&this.tickStartStorerCache){const i=((o=this.collector)==null?void 0:o.storage[t])&&((n=this.collector)==null?void 0:n.storage[t][e])||{},a=this.diffFun(this.tickStartStorerCache,new Map(Object.entries(i)));a.size&&(this.undoStack.push({id:s,type:2,data:O.cloneDeep(a),scenePath:e}),this.undoStack.length>ee.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(s){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===s){const i=this.undoStack[t];i&&(this.redoStack.push(i),i.type===2&&i.data&&this.refreshPlugin(i)),this.undoStack.splice(t,1);break}t--}const e=this.undoStack.filter(n=>n.scenePath===s).length,o=this.redoStack.filter(n=>n.scenePath===s).length;return this.emitter.emit("onCanUndoStepsUpdate",e),this.emitter.emit("onCanRedoStepsUpdate",o),e}redo(s){let t=this.redoStack.length-1;for(;t>=0;){if(this.redoStack[t].scenePath===s){const i=this.redoStack[t];i&&(!this.undoTickerId&&i.tickStartStorerCache?(this.undoTickerId=i.id,this.tickStartStorerCache=i.tickStartStorerCache,this.scenePath=i.scenePath):this.undoStack.push(i),i.type===2&&i.data&&this.refreshPlugin(i,!0)),this.redoStack.splice(t,1);break}t--}const e=this.undoStack.filter(n=>n.scenePath===s).length,o=this.redoStack.filter(n=>n.scenePath===s).length;return this.emitter.emit("onCanUndoStepsUpdate",e),this.emitter.emit("onCanRedoStepsUpdate",o),o}clear(){this.clearUndo(),this.clearRedo()}clearUndo(){this.undoStack.length=0,this.emitter.emit("onCanUndoStepsUpdate",this.undoStack.length)}clearRedo(){this.redoStack.length=0,this.emitter.emit("onCanRedoStepsUpdate",this.redoStack.length)}canUndo(){return!!this.undoStack.length}canRedo(){return!!this.redoStack.length}onFocusView(){const s=this.control.viewContainerManager.getCurScenePath(this.viewId);if(s){let t=this.undoStack.filter(o=>o.scenePath===s).length;const e=this.redoStack.filter(o=>o.scenePath===s).length;t===0&&e===0&&this.tickStartStorerCache&&this.scenePath===s&&(t=1),this.emitter.emit("onCanUndoStepsUpdate",t),this.emitter.emit("onCanRedoStepsUpdate",e)}}diffFun(s,t){const e=new Set,o=s.keys(),n=t.keys();for(const i of o){if(this.excludeIds.has(i))continue;const a=s.get(i),c=t.get(i);if(a&&c){if(O.isEqual(c,a))continue;e.add({dataType:3,key:i,data:[a,c]});continue}a&&e.add({dataType:2,key:i,data:a})}for(const i of n){if(this.excludeIds.has(i))continue;const a=t.get(i);a&&!s.has(i)&&e.add({dataType:1,key:i,data:a})}return e}isDrawEffectiveScene(s,t){const{key:e}=s;return!t.includes(e)}isDeleteEffectiveScene(s,t,e){var i;const{key:o}=s;if(!t.includes(o))return!1;const n=t.filter(a=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(a))===H&&!((l=this.collector)!=null&&l.isOwn(a))}).map(a=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][e][a]});for(const a of n)if((i=a==null?void 0:a.selectIds)!=null&&i.includes(o))return!1;return!0}isOldEffectiveScene(s,t,e){var i;const{key:o}=s;if(!t.includes(o))return!1;const n=t.filter(a=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(a))===H&&!((l=this.collector)!=null&&l.isOwn(a))}).map(a=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][e][a]});for(const a of n)if((i=a==null?void 0:a.selectIds)!=null&&i.includes(o))return!1;return!0}isNewEffectiveScene(s,t){const{key:e}=s;return!!t.includes(e)}refreshPlugin(s,t=!1){var i,a,c,l,h,u,d,p,f,I,y,v,m,w,S,N,T,x,L,D,A;let e;const{scenePath:o}=s,n=s.data;if(!(!n||!this.collector))for(const P of n.values()){const{dataType:E,data:j,key:_}=P,nt=this.collector.getStorageData(this.viewId,o),tt=nt&&Object.keys(nt)||[];switch(E){case 1:if(e=t?this.isDrawEffectiveScene(P,tt):this.isDeleteEffectiveScene(P,tt,o),e)if(t&&!Array.isArray(j)){if((i=j.updateNodeOpt)!=null&&i.useAnimation&&(j.updateNodeOpt.useAnimation=!1),((a=this.collector)==null?void 0:a.getLocalId(_))===H&&((c=this.collector)!=null&&c.isOwn(P.key))){const V=j.selectIds;if(V){const K=tt.filter(G=>{var J,rt;return((J=this.collector)==null?void 0:J.getLocalId(G))===H&&!((rt=this.collector)!=null&&rt.isOwn(G))}).map(G=>{var J;return(J=this.collector)==null?void 0:J.storage[this.viewId][o][G]});let $=!1;for(const G of K)for(let J=0;J<V.length;J++)(l=G==null?void 0:G.selectIds)!=null&&l.includes(V[J])&&(delete V[J],$=!0);$&&(j.selectIds=V.filter(G=>!!G))}}(h=this.collector)==null||h.updateValue(P.key,j,{isAfterUpdate:!0,viewId:this.viewId,scenePath:o,isSync:!0})}else!t&&!Array.isArray(P.data)&&((u=this.collector)==null||u.updateValue(P.key,void 0,{isAfterUpdate:!0,viewId:this.viewId,scenePath:o,isSync:!0}));break;case 2:if(e=t?this.isDeleteEffectiveScene(P,tt,o):this.isDrawEffectiveScene(P,tt),e){if(t&&!Array.isArray(j))(d=this.collector)==null||d.updateValue(_,void 0,{isAfterUpdate:!0,viewId:this.viewId,scenePath:o,isSync:!0});else if(!t&&!Array.isArray(j)){if((p=j.updateNodeOpt)!=null&&p.useAnimation&&(j.updateNodeOpt.useAnimation=!1),((f=this.collector)==null?void 0:f.getLocalId(P.key))===H&&((I=this.collector)!=null&&I.isOwn(P.key))){const V=j.selectIds;if(V){const K=tt.filter(G=>{var J,rt;return((J=this.collector)==null?void 0:J.getLocalId(G))===H&&!((rt=this.collector)!=null&&rt.isOwn(G))}).map(G=>{var J;return(J=this.collector)==null?void 0:J.storage[this.viewId][o][G]});let $=!1;for(const G of K)for(let J=0;J<V.length;J++)(y=G==null?void 0:G.selectIds)!=null&&y.includes(V[J])&&(delete V[J],$=!0);$&&(j.selectIds=V.filter(G=>!!G))}}(v=this.collector)==null||v.updateValue(P.key,P.data,{isAfterUpdate:!0,viewId:this.viewId,scenePath:o,isSync:!0})}}break;case 3:if(e=t?this.isNewEffectiveScene(P,tt):this.isOldEffectiveScene(P,tt,o),e){if(t&&Array.isArray(j)&&j.length===2){const V=j[1];if((m=V.updateNodeOpt)!=null&&m.useAnimation&&(V.updateNodeOpt.useAnimation=!1),((w=this.collector)==null?void 0:w.getLocalId(P.key))===H&&((S=this.collector)!=null&&S.isOwn(P.key))){const K=V.selectIds;if(K){const $=tt.filter(J=>{var rt,It;return((rt=this.collector)==null?void 0:rt.getLocalId(J))===H&&!((It=this.collector)!=null&&It.isOwn(J))}).map(J=>{var rt;return(rt=this.collector)==null?void 0:rt.storage[this.viewId][o][J]});let G=!1;for(const J of $)for(let rt=0;rt<K.length;rt++)J!=null&&J.selectIds&&((N=J.selectIds)!=null&&N.includes(K[rt]))&&(delete K[rt],G=!0);G&&(V.selectIds=K.filter(J=>!!J))}}(T=this.collector)==null||T.updateValue(_,V,{isAfterUpdate:!0,viewId:this.viewId,scenePath:o,isSync:!0})}else if(!t&&Array.isArray(j)&&j.length===2){const V=j[0];if((x=V.updateNodeOpt)!=null&&x.useAnimation&&(V.updateNodeOpt.useAnimation=!1),((L=this.collector)==null?void 0:L.getLocalId(P.key))===H&&((D=this.collector)!=null&&D.isOwn(P.key))){const K=V.selectIds;if(K){const $=tt.filter(J=>{var rt,It;return((rt=this.collector)==null?void 0:rt.getLocalId(J))===H&&!((It=this.collector)!=null&&It.isOwn(J))}).map(J=>{var rt;return(rt=this.collector)==null?void 0:rt.storage[this.viewId][o][J]});let G=!1;for(const J of $)for(let rt=0;rt<K.length;rt++)J!=null&&J.selectIds&&J.selectIds.includes(K[rt])&&(delete K[rt],G=!0);G&&(V.selectIds=K.filter(J=>!!J))}}(A=this.collector)==null||A.updateValue(P.key,V,{isAfterUpdate:!0,viewId:this.viewId,scenePath:o,isSync:!0})}}break}}}};M(ee,"sdkCallBack"),M(ee,"MaxStackLength",20),M(ee,"waitTime",100);let Xe=ee;function Fg(r){return r instanceof TouchEvent||r instanceof window.TouchEvent||(r==null?void 0:r.touches)&&(r==null?void 0:r.touches.length)||(r==null?void 0:r.changedTouches)&&(r==null?void 0:r.changedTouches.length)}function fe(r){return Fg(r)&&(r.touches&&r.touches.length===1||r.changedTouches&&r.changedTouches.length===1)}function ki(r){return r.touches&&r.touches.length?{x:r.touches[0].pageX,y:r.touches[0].pageY}:r.changedTouches&&r.changedTouches.length?{x:r.changedTouches[0].pageX,y:r.changedTouches[0].pageY}:{x:r.pageX,y:r.pageY}}class ge{constructor(s){M(this,"internalMsgEmitter");M(this,"control");M(this,"mainView");M(this,"appViews",new Map);const{control:t,internalMsgEmitter:e}=s;this.control=t,this.internalMsgEmitter=e,this.internalMsgEmitter.on("addUndoTicker",this.undoTickerStart.bind(this)),this.internalMsgEmitter.on("excludeIds",this.addExcludeIds.bind(this))}undoTickerStart(s,t){const e=this.getView(t);e&&e.displayer&&e.focusScenePath&&e.displayer.commiter.undoTickerStart(s,e.focusScenePath)}addExcludeIds(s,t){const e=this.getView(t);e&&e.displayer&&e.focusScenePath&&e.displayer.commiter.addExcludeIds(s)}undo(){const s=this.focuedView;let t=0;if(s){const e=s.focusScenePath;t=s.displayer.commiter.undo(e)||0}return t}redo(){const s=this.focuedView;let t=0;if(s){const e=s.focusScenePath;t=s.displayer.commiter.redo(e)||0}return t}validator(s,t,e){var i;const o=O.clone(s[t]),n=O.clone(e);t==="focusScenePath"&&e&&!O.isEqual(o,n)&&(this.control.internalSceneChange(s.id,n),(i=this.focuedView)==null||i.displayer.commiter.onChangeScene()),t==="cameraOpt"&&!O.isEqual(o,n)&&this.control.internalCameraChange(s.id,n)}destroyAppView(s,t=!1){const e=this.appViews.get(s);e&&(this.control.textEditorManager.clear(s,t),e.displayer.destroy(),this.appViews.delete(s))}createMianView(s){this.mainView=new Proxy(s,{set:(t,e,o)=>(this.control.worker.isActive&&this.validator(t,e,o),t[e]=o,!0)})}createAppView(s){const t=s.id,e=new Proxy(s,{set:(o,n,i)=>(this.control.worker.isActive&&this.validator(o,n,i),o[n]=i,!0)});this.appViews.set(t,e)}isAppView(s){return s!==yt&&this.appViews.has(s)}getView(s){var t;return s===yt?this.mainView:(t=this.appViews)==null?void 0:t.get(s)}getCurScenePath(s){const t=this.getView(s);if(t)return t.focusScenePath}getAllViews(){return[this.mainView,...this.appViews.values()]}setViewScenePath(s,t){var e;if(s===yt&&this.mainView)this.mainView.focusScenePath=t;else{const o=s&&((e=this.appViews)==null?void 0:e.get(s))||void 0;o&&(o.focusScenePath=t)}}setViewData(s,t){var e;if(s===yt&&this.mainView)this.mainView.viewData=t;else{const o=s&&((e=this.appViews)==null?void 0:e.get(s))||void 0;o&&(o.viewData=t)}}setFocuedViewId(s){var t;this.focuedViewId=s,s===yt?this.focuedView=this.mainView:this.focuedView=s&&((t=this.appViews)==null?void 0:t.get(s))||void 0,this.control.cursor.onFocusViewChange(),this.focuedView&&this.focuedView.displayer.commiter.onFocusView()}setViewFocusScenePath(s,t){var o;let e;s===yt?e=this.mainView:e=(o=this.appViews)==null?void 0:o.get(s),e&&(e.focusScenePath=t)}destroy(){var s;this.internalMsgEmitter.removeAllListeners("addUndoTicker"),this.internalMsgEmitter.removeAllListeners("excludeIds"),(s=this.mainView)==null||s.displayer.destroy(),this.appViews.forEach(t=>{this.destroyAppView(t.id,!0),this.control.worker.destroyViewWorker(t.id)})}setFocuedViewCameraOpt(s){if(this.focuedView){const t=this.focuedView.cameraOpt;O.isEqual(t,s)||(this.focuedView.cameraOpt=s)}}transformToOriginPoint(s,t){const e=this.getView(t);if(e!=null&&e.viewData){const o=e.viewData.convertToPointOnScreen(s[0],s[1]);return[o.x,o.y]}return s}transformToScenePoint(s,t){const e=this.getView(t);if(e!=null&&e.viewData){const o=e.viewData.convertToPointInWorld({x:s[0],y:s[1]});return[o.x,o.y]}return s}render(s){var t,e,o,n,i,a,c,l,h,u,d,p,f,I,y,v,m;for(const w of s){const{rect:S,imageBitmap:N,isClear:T,isUnClose:x,drawCanvas:L,clearCanvas:D,viewId:A}=w,P=(t=this.getView(A))==null?void 0:t.displayer;if(P&&S){const{dpr:E,canvasBgRef:j,canvasFloatRef:_,canvasServiceFloatRef:nt,canvasTopRef:tt}=P,V=Math.floor(S.w*E),K=Math.floor(S.h*E),$=S.x*E,G=S.y*E;if(T){switch(D){case Yt.TopFloat:(o=(e=tt.current)==null?void 0:e.getContext("2d"))==null||o.clearRect($,G,V,K);break;case Yt.Float:(i=(n=_.current)==null?void 0:n.getContext("2d"))==null||i.clearRect($,G,V,K);break;case Yt.ServiceFloat:(c=(a=nt.current)==null?void 0:a.getContext("2d"))==null||c.clearRect($,G,V,K);break;case Yt.Bg:(h=(l=j.current)==null?void 0:l.getContext("2d"))==null||h.clearRect($,G,V,K);break}continue}if(L&&N)switch(L){case Yt.TopFloat:(d=(u=tt.current)==null?void 0:u.getContext("2d"))==null||d.drawImage(N,0,0,V,K,$,G,V,K);break;case Yt.Float:{(f=(p=_.current)==null?void 0:p.getContext("2d"))==null||f.drawImage(N,0,0,V,K,$,G,V,K);break}case Yt.ServiceFloat:{(y=(I=nt.current)==null?void 0:I.getContext("2d"))==null||y.drawImage(N,0,0,V,K,$,G,V,K);break}case Yt.Bg:{(m=(v=j.current)==null?void 0:v.getContext("2d"))==null||m.drawImage(N,0,0,V,K,$,G,V,K);break}}if(x)continue;N==null||N.close()}}}showFloatBar(s,t,e){const o=this.getView(s),n=o==null?void 0:o.displayer.vDom;n&&n.showFloatBar(t,e)}setActiveTextEditor(s,t){const e=this.getView(s),o=e==null?void 0:e.displayer.vDom;o&&o.setActiveTextEditor(t)}}M(ge,"defaultCameraOpt",{centerX:0,centerY:0,scale:1}),M(ge,"defaultScreenCanvasOpt",{autoRender:!1,contextType:_e.Canvas2d}),M(ge,"defaultLayerOpt",{offscreen:!0,handleEvent:!1,depth:!1});class Hg{constructor(s,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",s=>{if(this.active&&s.button===0&&this.viewId){this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(s);this.cachePoint=t,t&&this.control.worker.originalEventLintener(b.Start,t,this.viewId)}});M(this,"mousemove",s=>{if(this.active&&this.viewId){const t=this.getPoint(s);this.cachePoint=t,t&&this.control.worker.originalEventLintener(b.Doing,t,this.viewId)}});M(this,"mouseup",s=>{if(this.active&&s.button===0&&this.viewId){const t=this.getPoint(s)||this.cachePoint;t&&this.control.worker.originalEventLintener(b.Done,t,this.viewId),this.cachePoint=void 0}});M(this,"touchstart",s=>{var t;if(this.active){if(!fe(s)){this.control.worker.unWritable(),this.viewId&&this.control.worker.removeDrawingWork(this.viewId);return}if(this.viewId){if(!this.control.worker.isAbled()){const o=(t=this.control.worker.getCurrentToolsData())==null?void 0:t.toolsType;o&&this.control.effectViewContainer(o)}this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const e=this.getPoint(s);this.cachePoint=e,e&&this.control.worker.originalEventLintener(b.Start,e,this.viewId)}}});M(this,"touchmove",s=>{if(this.active){if(!fe(s)){this.control.worker.unWritable(),this.control.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const t=this.getPoint(s);this.cachePoint=t,t&&this.control.worker.originalEventLintener(b.Doing,t,this.viewId)}}});M(this,"touchend",s=>{if(this.active){if(!fe(s)||!this.control.worker.isAbled()){this.control.worker.unWritable(),this.control.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const t=this.getPoint(s)||this.cachePoint;t&&this.control.worker.originalEventLintener(b.Done,t,this.viewId),this.cachePoint=void 0}}});M(this,"cursorMouseMove",O.throttle(s=>{const t=this.getPoint(s);this.cacheCursorPoint&&O.isEqual(t,this.cacheCursorPoint)||!this.viewId||(this.cacheCursorPoint=t,t&&this.control.worker.sendCursorEvent(t,this.viewId))},30,{leading:!1}));M(this,"cursorMouseLeave",O.throttle(()=>{this.viewId&&(this.cacheCursorPoint=[void 0,void 0],this.control.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId))},30,{leading:!1}));M(this,"keydown",s=>{this.control.hotkeyManager.colloctHotkey(s)});this.viewId=s,this.control=t,this.internalMsgEmitter=e;const o={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:this.viewId};this.commiter=new Xe(o)}bindToolsClass(){var t,e;const s=(e=(t=this.control.worker)==null?void 0:t.currentToolsData)==null?void 0:e.toolsType;switch(s){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.PencilEraser:case C.BitMapEraser:this.eventTragetElement&&(this.eventTragetElement.className=`netless-whiteboard ${s===C.Text?"cursor-text":s===C.PencilEraser||s===C.BitMapEraser?"cursor-eraser":s===C.Pencil||s===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(s){this.viewId=s}destroy(){this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.clearViewCursor(this.viewId),this.internalMsgEmitter.removeAllListeners([Z.Cursor,this.viewId])}getPoint(s){const t=ki(s);if(t&&O.isNumber(t.x)&&O.isNumber(t.y))return[t.x-this.containerOffset.x,t.y-this.containerOffset.y]}setActive(s){this.active=s}async stopEventHandler(){this.cachePoint&&(await this.control.worker.originalEventLintener(b.Done,this.cachePoint,this.viewId),this.cachePoint=void 0)}getTranslate(s){const e=(s.style.WebkitTransform||getComputedStyle(s,"").getPropertyValue("-webkit-transform")||s.style.transform||getComputedStyle(s,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),o=e&&parseInt(e[0])||0,n=e&&parseInt(e[1])||0;return[o,n]}getContainerOffset(s,t){var n;const e=this.getTranslate(s);let o={x:t.x+s.offsetLeft+e[0],y:t.y+s.offsetTop+e[1]};return(n=s.offsetParent)!=null&&n.nodeName&&s.offsetParent.nodeName!=="BODY"&&(o=this.getContainerOffset(s.offsetParent,o)),o}bindDisplayerEvent(s){s.addEventListener("mousedown",this.mousedown,!1),s.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}),s.addEventListener("mousemove",this.cursorMouseMove,!1),s.addEventListener("mouseleave",this.cursorMouseLeave,!1),s.addEventListener("keydown",this.keydown,!0)}removeDisplayerEvent(s){s.removeEventListener("mousedown",this.mousedown),s.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),s.removeEventListener("mousemove",this.cursorMouseMove),s.removeEventListener("mouseleave",this.cursorMouseLeave),s.removeEventListener("keydown",this.keydown)}}class xi{constructor(s,t){M(this,"viewId",yt);M(this,"control");M(this,"internalMsgEmitter");M(this,"commiter");M(this,"cachePoint");M(this,"cacheCursorPoint");M(this,"active",!0);M(this,"mousedown",s=>{if(this.active&&s.button===0){this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(s);this.cachePoint=t,t&&this.control.worker.originalEventLintener(b.Start,t,this.viewId)}});M(this,"mousemove",s=>{if(!this.active)return;const t=this.getPoint(s);this.cachePoint=t,t&&this.control.worker.originalEventLintener(b.Doing,t,this.viewId)});M(this,"mouseup",s=>{if(this.active&&s.button===0){const t=this.getPoint(s)||this.cachePoint;t&&this.control.worker.originalEventLintener(b.Done,t,this.viewId),this.cachePoint=void 0}});M(this,"touchstart",s=>{var e;if(!this.active)return;if(!fe(s)){this.control.worker.unWritable(),this.viewId&&this.control.worker.removeDrawingWork(this.viewId);return}if(!this.control.worker.isAbled()){const o=(e=this.control.worker.getCurrentToolsData())==null?void 0:e.toolsType;o&&this.control.effectViewContainer(o)}this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(s);this.cachePoint=t,t&&this.control.worker.originalEventLintener(b.Start,t,this.viewId)});M(this,"touchmove",s=>{if(!this.active)return;if(!fe(s)){this.control.worker.unWritable(),this.viewId&&this.control.worker.removeDrawingWork(this.viewId);return}const t=this.getPoint(s);this.cachePoint=t,t&&this.control.worker.originalEventLintener(b.Doing,t,this.viewId)});M(this,"touchend",s=>{if(!this.active)return;if(!fe(s)||!this.control.worker.isAbled()){this.control.worker.removeDrawingWork(this.viewId);return}const t=this.getPoint(s)||this.cachePoint;t&&this.control.worker.originalEventLintener(b.Done,t,this.viewId),this.cachePoint=void 0});M(this,"cursorMouseMove",O.throttle(s=>{const t=this.getPoint(s);this.cacheCursorPoint&&O.isEqual(t,this.cacheCursorPoint)||(this.cacheCursorPoint=t,t&&this.control.worker.sendCursorEvent(t,this.viewId))},30,{leading:!1}));M(this,"cursorMouseLeave",O.throttle(()=>{this.cacheCursorPoint=[void 0,void 0],this.control.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId)},30,{leading:!1}));M(this,"keydown",s=>{this.control.hotkeyManager.colloctHotkey(s)});this.control=s,this.internalMsgEmitter=t;const e={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:this.viewId};this.commiter=new Xe(e)}bindToolsClass(){var t,e;const s=(e=(t=this.control.worker)==null?void 0:t.currentToolsData)==null?void 0:e.toolsType;switch(s){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.PencilEraser:case C.BitMapEraser:this.eventTragetElement&&(this.eventTragetElement.className=`netless-whiteboard ${s===C.Text?"cursor-text":s===C.PencilEraser||s===C.BitMapEraser?"cursor-eraser":s===C.Pencil||s===C.LaserPen?"cursor-pencil":"cursor-arrow"}`);break}}mountView(){this.setCanvassStyle(),this.control.viewContainerManager.mountView(this.viewId)}updateSize(){this.setCanvassStyle()}reflashContainerOffset(){this.eventTragetElement&&(this.containerOffset=this.getContainerOffset(this.eventTragetElement,{x:0,y:0}))}destroy(){this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.destroy(),this.internalMsgEmitter.removeAllListeners([Z.Cursor,this.viewId])}getPoint(s){const t=ki(s);if(t&&O.isNumber(t.x)&&O.isNumber(t.y))return[t.x-this.containerOffset.x,t.y-this.containerOffset.y]}setActive(s){this.active=s}async stopEventHandler(){this.cachePoint&&(await this.control.worker.originalEventLintener(b.Done,this.cachePoint,this.viewId),this.cachePoint=void 0)}getTranslate(s){const e=(s.style.WebkitTransform||getComputedStyle(s,"").getPropertyValue("-webkit-transform")||s.style.transform||getComputedStyle(s,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),o=e&&parseInt(e[0])||0,n=e&&parseInt(e[1])||0;return[o,n]}getContainerOffset(s,t){var n;const e=this.getTranslate(s);let o={x:t.x+s.offsetLeft+e[0],y:t.y+s.offsetTop+e[1]};return(n=s.offsetParent)!=null&&n.nodeName&&s.offsetParent.nodeName!=="BODY"&&(o=this.getContainerOffset(s.offsetParent,o)),o}bindDisplayerEvent(s){s.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),s.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}),s.addEventListener("mousemove",this.cursorMouseMove,!0),s.addEventListener("mouseleave",this.cursorMouseLeave,!0),s.addEventListener("keydown",this.keydown,!0)}removeDisplayerEvent(s){s.removeEventListener("mousedown",this.mousedown),s.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),s.removeEventListener("mousemove",this.cursorMouseMove),s.removeEventListener("mouseleave",this.cursorMouseLeave),s.removeEventListener("keydown",this.keydown)}}const Qg="index-module__Container__nLsM3",Vg="index-module__CanvasBox__j2Xe-",$g="index-module__FloatCanvas__d1YR7",Gg="index-module__TopFloatCanvas__7IaCw",Zg="index-module__CanvasBoxSub__hcMeK",qg="index-module__SnapshotBox__--eeE",Jg="index-module__FloatBar__cm-EL",Xg="index-module__RotateBtn__HSSkf",Kg="index-module__ResizeBtn__yjvda",_g="index-module__CursorBox__2UHvI",tM="index-module__TextEditorContainer__Qm8KC",eM="index-module__ResizeTowBox__HOllX",oM="index-module__FloatBarBtn__FJrOG",Tt={Container:Qg,CanvasBox:Vg,FloatCanvas:$g,TopFloatCanvas:Gg,CanvasBoxSub:Zg,SnapshotBox:qg,FloatBar:Jg,RotateBtn:Xg,ResizeBtn:Kg,CursorBox:_g,TextEditorContainer:tM,ResizeTowBox:eM,FloatBarBtn:oM},sM={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,PHN2ZyB3aWR0aD0iMzIiIGhlaWd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IDZoLTQgMG0wIDFWMiIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","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;base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IzNC42NjY2NjdoLTY0VjY4Mi42NjY2NjdoNjR6IG0tNTQuNjEzMzMzLTIxMi4wNTMzMzRsODUuMzMzMzMzIDg1LjMzMzMzNCA0NS4yMjY2NjctNDUuMjI2NjY3LTg1LjMzMzMzMy04NS4zMzMzMzMtNDUuMjI2NjY3IDQ1LjIyNjY2NnogbTAtNDUuMjI2NjY2bC04NS4zMzMzMzMgODUuMzMzMzMzIDQ1LjIyNjY2NiA0NS4yMjY2NjcgODUuMzMzMzM0LTg1LjMzMzMzNC00NS4yMjY2NjctNDUuMjI2NjY2eiIgIGZpbGw9IiM0NDRFNjAiPjwvcGF0aD48L3N2Zz4="};function wt(r){return sM[r]}const iM=r=>{const{workIds:s,mananger:t}=r;return g.createElement("div",{className:"button normal-button",style:{touchAction:"none"},onClick:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),q.emitMethod(Z.MainEngine,R.DeleteNode,{workIds:s||[H],viewId:t.viewId})},onTouchEnd:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),q.emitMethod(Z.MainEngine,R.DeleteNode,{workIds:s||[H],viewId:t.viewId})}},g.createElement("img",{alt:"icon",src:wt("delete")}))},nM=r=>{const{workIds:s,viewId:t}=r;return g.createElement("div",{className:"button normal-button",onClick:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),q.emitMethod(Z.MainEngine,R.CopyNode,{workIds:s||[H],viewId:t})},onTouchEnd:e=>{e.stopPropagation(),q.emitMethod(Z.MainEngine,R.CopyNode,{workIds:s||[H],viewId:t})}},g.createElement("img",{alt:"icon",src:wt("duplicate")}))},Ls=r=>{const{icon:s,onClickHandler:t,onTouchEndHandler:e}=r;return g.createElement("div",{className:"button normal-button",onClick:t,onTouchEnd:e},g.createElement("img",{src:wt(s)}))},rM=r=>{const{open:s,setOpen:t,floatBarRef:e}=r,{floatBarData:o,mananger:n}=g.useContext(Mt),[i,a]=g.useState([]),c=g.useMemo(()=>{if(e!=null&&e.current&&O.isNumber(o==null?void 0:o.y)&&(n!=null&&n.height)){if(e.current.offsetTop&&e.current.offsetTop+o.y>180){const d={};return d.top="inherit",d.bottom=50,d}else if(!e.current.offsetTop&&(n==null?void 0:n.height)-e.current.offsetTop-o.y<120){const d={};return d.top="inherit",d.bottom=50,d}}},[e==null?void 0:e.current,o,n]),l=g.useMemo(()=>s?g.createElement("div",{className:"image-layer-menu",style:c},g.createElement(Ls,{icon:"to-top",onClickHandler:d=>{d.cancelable&&d.preventDefault(),d.stopPropagation(),q.emitMethod(Z.MainEngine,R.ZIndexNode,{workIds:[H],layer:oe.Top,viewId:n==null?void 0:n.viewId})},onTouchEndHandler:d=>{d.stopPropagation(),q.emitMethod(Z.MainEngine,R.ZIndexNode,{workIds:[H],layer:oe.Top,viewId:n==null?void 0:n.viewId})}}),g.createElement(Ls,{icon:"to-bottom",onClickHandler:d=>{d.cancelable&&d.preventDefault(),d.stopPropagation(),q.emitMethod(Z.MainEngine,R.ZIndexNode,{workIds:[H],layer:oe.Bottom,viewId:n==null?void 0:n.viewId})},onTouchEndHandler:d=>{d.stopPropagation(),q.emitMethod(Z.MainEngine,R.ZIndexNode,{workIds:[H],layer:oe.Bottom,viewId:n==null?void 0:n.viewId})}})):null,[s,c]),h=d=>{d.cancelable&&d.preventDefault(),d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),t(!s)},u=d=>{d.stopPropagation(),d.nativeEvent.stopImmediatePropagation(),t(!s)};return g.useEffect(()=>{O.isEqual(o==null?void 0:o.selectIds,i)||o!=null&&o.selectIds&&!O.isEqual(o==null?void 0:o.selectIds,i)&&(a(o==null?void 0:o.selectIds),t(!1))},[s,o,i,t]),g.createElement("div",{className:`button normal-button ${s&&"active"}`,onClick:h,onTouchEnd:u},l,g.createElement("img",{alt:"icon",src:wt(s?"layer-pressed":"layer")}))},aM=()=>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"})),zi=r=>{const{activeColor:s,onClickHandler:t,onTouchEndHandler:e}=r;return g.createElement("div",{className:`font-color-button ${s==="transparent"?"active":""}`,onClick:t,onTouchEnd:e},g.createElement("div",{className:"circle none"}))},lo=r=>{const{color:s,activeColor:t,onClickHandler:e,onTouchEndHandler:o}=r;return g.createElement("div",{className:`font-color-button ${s===t?"active":""}`,onClick:e,onTouchEnd:o},g.createElement("div",{className:"circle",style:{backgroundColor:gt(s,1)}}))},ho=r=>{const{opacity:s,activeColor:t,setCurOpacity:e}=r,[o,n]=g.useState({x:108,y:0});if(g.useEffect(()=>{n({x:s*100+8,y:0})},[]),!t)return null;const i=O.throttle((l,h)=>{l.cancelable&&l.preventDefault(),l.stopPropagation(),h.x!==(o==null?void 0:o.x)&&n({x:h.x,y:0});const u=Math.min(Math.max(h.x-8,0),100)/100;s!==u&&e(u,t,b.Doing)},100,{leading:!1}),a=l=>{l.cancelable&&l.preventDefault(),l.stopPropagation(),e(s,t,b.Start)},c=O.throttle((l,h)=>{l.cancelable&&l.preventDefault(),l.stopPropagation(),h.x!==(o==null?void 0:o.x)&&n({x:h.x,y:0});const u=Math.min(Math.max(h.x-8,0),100)/100;e(u,t,b.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;n({x:u*100+8,y:0}),e(u,t,b.Done)}},g.createElement("div",{className:"range-color",style:{background:`linear-gradient(to right, ${gt(t,0)}, ${gt(t,1)})`}}),g.createElement("div",{className:"range-opacity"},g.createElement(Me,{bounds:"parent",axis:"x",position:o,onDrag:i,onStart:a,onStop:c},g.createElement("div",{className:"circle",style:{backgroundColor:gt(t,s)},onClick:l=>{l.cancelable&&l.preventDefault(),l.stopPropagation()}}))))},cM=r=>{const{min:s,max:t,activeNumber:e,setActiveNumber:o,color:n}=r,[i,a]=g.useState({x:108,y:0});if(g.useEffect(()=>{const u=Math.ceil((e-s)/(t-s)*100)+8;a({x:u,y:0})},[]),!e)return null;const c=O.throttle((u,d)=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),d.x!==(i==null?void 0:i.x)&&a({x:d.x,y:0});const p=Math.ceil(Math.max(d.x-8,0)/100*(t-s)+s);e!==p&&o(p,b.Doing)},100,{leading:!1}),l=u=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),o(e,b.Start)},h=O.throttle((u,d)=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),d.x!==(i==null?void 0:i.x)&&a({x:d.x,y:0});const p=Math.ceil(Math.max(d.x-8,0)/100*(t-s)+s);o(p,b.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-s)+s),f=Math.ceil((p-s)/(t-s)*100)+8;a({x:f,y:0}),o(p,b.Done)}},g.createElement("div",{className:"range-color",style:{backgroundColor:n}}),g.createElement("div",{className:"range-opacity"},g.createElement(Me,{bounds:"parent",axis:"x",position:i,onDrag:c,onStart:l,onStop:h},g.createElement("div",{className:"circle",style:{backgroundColor:n},onClick:u=>{u.cancelable&&u.preventDefault(),u.stopPropagation()}},g.createElement("div",{className:"range-opacity-data-icon"},e)))))},lM=r=>{const{useStroke:s,color:t,activeStrokeType:e,setStrokeType:o}=r;return g.createElement("div",{className:"stroke-type-box"},!!s&&g.createElement("div",{className:`stroke-type-box-item Stroke ${e===X.Stroke&&"active"}`,style:{backgroundColor:t},onClick:()=>{o(X.Stroke)},onTouchEnd:()=>{o(X.Stroke)}}),g.createElement("div",{className:`stroke-type-box-item Normal ${e===X.Normal&&"active"}`,style:{borderColor:t},onClick:()=>{o(X.Normal)},onTouchEnd:()=>{o(X.Normal)}}),g.createElement("div",{className:`stroke-type-box-item Dotted ${e===X.Dotted&&"active"}`,style:{borderColor:t},onClick:()=>{o(X.Dotted)},onTouchEnd:()=>{o(X.Dotted)}}),g.createElement("div",{className:`stroke-type-box-item LongDotted ${e===X.LongDotted&&"active"}`,style:{borderColor:t},onClick:()=>{o(X.LongDotted)},onTouchEnd:()=>{o(X.LongDotted)}}))},hM=r=>{const{open:s,setOpen:t,floatBarRef:e}=r,{floatBarData:o,floatBarColors:n,mananger:i,setFloatBarData:a}=g.useContext(Mt),[c,l]=g.useState(),[h,u]=g.useState(1);g.useEffect(()=>{if(o!=null&&o.strokeColor){const[m,w]=co(o.strokeColor);l(m),u(w)}},[o]);const d=g.useMemo(()=>{if(e!=null&&e.current&&O.isNumber(o==null?void 0:o.y)&&(i!=null&&i.height)){if(e.current.offsetTop&&e.current.offsetTop+o.y>180){const m={};return m.top="inherit",m.bottom=50,m}else if(!e.current.offsetTop&&(i==null?void 0:i.height)-e.current.offsetTop-o.y<120){const m={};return m.top="inherit",m.bottom=50,m}}},[(e==null?void 0:e.current)&&o,i==null?void 0:i.height]),p=g.useMemo(()=>g.createElement(ho,{key:"strokeColors",opacity:h,activeColor:c,setCurOpacity:(m,w,S)=>{S===b.Start&&(i!=null&&i.control.room)&&(i.control.room.disableDeviceInputs=!0),S===b.Done&&(i!=null&&i.control.room)&&(i.control.room.disableDeviceInputs=!1),u(m);const N=gt(w,m);o!=null&&o.strokeColor&&a({strokeColor:N}),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],strokeColor:N,workState:S,viewId:i==null?void 0:i.viewId})}}),[h,c,i==null?void 0:i.control.room,i==null?void 0:i.viewId,o]),f=g.useMemo(()=>c&&(o!=null&&o.thickness)?g.createElement(cM,{key:"strokeThickness",min:1,max:10,activeNumber:o.thickness,setActiveNumber:(m,w)=>{w===b.Start&&(i!=null&&i.control.room)&&(i.control.room.disableDeviceInputs=!0),w===b.Done&&(i!=null&&i.control.room)&&(i.control.room.disableDeviceInputs=!1),o!=null&&o.thickness&&a({thickness:m}),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],thickness:m,workState:w,viewId:i==null?void 0:i.viewId})},color:c}):null,[c,o==null?void 0:o.thickness,i==null?void 0:i.control.room,i==null?void 0:i.viewId]),I=g.useMemo(()=>c&&(o!=null&&o.strokeType)?g.createElement(lM,{key:"strokeType",useStroke:o==null?void 0:o.useStroke,activeStrokeType:o.strokeType,setStrokeType:m=>{o.strokeType&&a({strokeType:m}),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],strokeType:m,workState:b.Done,viewId:i==null?void 0:i.viewId})},color:c}):null,[c,o==null?void 0:o.strokeType,i==null?void 0:i.control.room,i==null?void 0:i.viewId,o==null?void 0:o.useStroke]),y=g.useMemo(()=>s?g.createElement("div",{className:"font-colors-menu",style:d,onTouchEnd:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()},onClick:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()}},I,f,g.createElement("div",{className:"font-colors-line"}),n.concat().map((m,w)=>{const S=De(...m);return g.createElement(lo,{key:w,color:S,activeColor:c,onTouchEndHandler:N=>{N.stopPropagation(),l(S);const T=gt(S,h);o!=null&&o.strokeColor&&(o.strokeColor=T,a({strokeColor:T})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],workState:b.Done,strokeColor:T,viewId:i==null?void 0:i.viewId})},onClickHandler:N=>{N.cancelable&&N.preventDefault(),N.stopPropagation(),l(S);const T=gt(S,h);o!=null&&o.strokeColor&&(o.strokeColor=T,a({strokeColor:T})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],workState:b.Done,strokeColor:T,viewId:i==null?void 0:i.viewId})}})}),p):null,[s,n,p,c,h,o,i==null?void 0:i.viewId,d]),v=g.useMemo(()=>c?g.createElement("div",{className:"color-bar-ring",style:{backgroundColor:gt(c,h)}},g.createElement("div",{className:"circle"})):null,[c,h]);return g.createElement("div",{className:`button normal-button font-colors-icon ${s&&"active"}`,onTouchEnd:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),t(!s)},onClick:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),t(!s)}},v,y)},uM=r=>{const{open:s,setOpen:t,floatBarRef:e}=r,{floatBarData:o,floatBarColors:n,mananger:i,setFloatBarData:a}=g.useContext(Mt),[c,l]=g.useState(),[h,u]=g.useState(1);g.useEffect(()=>{if(o!=null&&o.fillColor){const[y,v]=(o==null?void 0:o.fillColor)==="transparent"&&["transparent",1]||co(o.fillColor);l(y),u(v)}},[o]);const d=g.useMemo(()=>{if(e!=null&&e.current&&O.isNumber(o==null?void 0:o.y)&&(i!=null&&i.height)){if(e.current.offsetTop&&e.current.offsetTop+o.y>200){const y={};return y.top="inherit",y.bottom=50,y}else if(!e.current.offsetTop&&(i==null?void 0:i.height)-e.current.offsetTop-o.y<140){const y={};return y.top="inherit",y.bottom=50,y}}},[e==null?void 0:e.current,o,i==null?void 0:i.height]),p=g.useMemo(()=>c&&c!=="transparent"?g.createElement(ho,{key:"fillColors",opacity:h||0,activeColor:c,setCurOpacity:(y,v,m)=>{m===b.Start&&(i!=null&&i.control.room)&&(i.control.room.disableDeviceInputs=!0),m===b.Done&&(i!=null&&i.control.room)&&(i.control.room.disableDeviceInputs=!1),u(y);const w=gt(v,y);o!=null&&o.fillColor&&(o.fillColor=w,a({fillColor:w})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],fillColor:c&>(v,y),workState:m,viewId:i==null?void 0:i.viewId})}}):null,[c,h,i==null?void 0:i.control.room,i==null?void 0:i.viewId,o]),f=g.useMemo(()=>s?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(zi,{activeColor:c,onTouchEndHandler:y=>{y.stopPropagation(),l("transparent");const v="transparent";o!=null&&o.fillColor&&(o.fillColor=v,a({fillColor:v})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],workState:b.Done,fillColor:v,viewId:i==null?void 0:i.viewId})},onClickHandler:y=>{y.cancelable&&y.preventDefault(),y.stopPropagation(),l("transparent");const v="transparent";o!=null&&o.fillColor&&(o.fillColor=v,a({fillColor:v})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],workState:b.Done,fillColor:v,viewId:i==null?void 0:i.viewId})}}),n.map((y,v)=>{const m=De(...y);return g.createElement(lo,{key:v,color:m,activeColor:c,onTouchEndHandler:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),l(m);const S=gt(m,h);o!=null&&o.fillColor&&(o.fillColor=S,a({fillColor:S})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],workState:b.Done,fillColor:S,viewId:i==null?void 0:i.viewId})},onClickHandler:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),l(m);const S=gt(m,h);o!=null&&o.fillColor&&(o.fillColor=S,a({fillColor:S})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:[H],workState:b.Done,fillColor:S,viewId:i==null?void 0:i.viewId})}})}),p):null,[s,c,n,p,o,i==null?void 0:i.viewId,h,d]),I=g.useMemo(()=>{const y=c&&c!=="transparent"&>(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 ${s&&"active"}`,onTouchEnd:y=>{y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),t(!s)},onClick:y=>{y.cancelable&&y.preventDefault(),y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),t(!s)}},I,f)},dM=r=>{const{open:s,setOpen:t,textOpt:e,workIds:o,floatBarRef:n}=r,{floatBarColors:i,mananger:a,setFloatBarData:c,floatBarData:l}=g.useContext(Mt),[h,u]=g.useState(),[d,p]=g.useState(1);g.useEffect(()=>{if(e!=null&&e.fontColor){const[m,w]=(e==null?void 0:e.fontColor)==="transparent"&&["transparent",0]||co(e.fontColor);u(m),p(w)}},[e==null?void 0:e.fontColor]);const f=g.useMemo(()=>{if(n!=null&&n.current&&O.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(n.current.offsetTop&&n.current.offsetTop+l.y>180){const m={};return m.top="inherit",m.bottom=50,m}else if(!n.current.offsetTop&&(a==null?void 0:a.height)-n.current.offsetTop-l.y<120){const m={};return m.top="inherit",m.bottom=50,m}}},[n==null?void 0:n.current,l,a]),I=g.useMemo(()=>h&&h!=="transparent"?g.createElement(ho,{key:"fontColors",opacity:d,activeColor:h,setCurOpacity:(m,w,S)=>{S===b.Start&&(a!=null&&a.control.room)&&(a.control.room.disableDeviceInputs=!0),S===b.Done&&(a!=null&&a.control.room)&&(a.control.room.disableDeviceInputs=!1),p(m);const N=gt(w,m);l!=null&&l.textOpt&&(l.textOpt.fontColor=N,c({textOpt:l.textOpt})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:o||[H],fontColor:h&&N,workState:S,viewId:a==null?void 0:a.viewId})}}):null,[h,d,a==null?void 0:a.control.room,a==null?void 0:a.viewId,l==null?void 0:l.textOpt,o]),y=g.useMemo(()=>s?g.createElement("div",{className:"font-colors-menu",style:f,onTouchEnd:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()},onClick:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()}},i.map((m,w)=>{const S=De(...m);return g.createElement(lo,{key:w,color:S,activeColor:h,onTouchEndHandler:N=>{N.stopPropagation(),u(S);const T=gt(S,d);l!=null&&l.textOpt&&(l.textOpt.fontColor=T,c({textOpt:l.textOpt})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:o||[H],workState:b.Done,fontColor:T,viewId:a==null?void 0:a.viewId})},onClickHandler:N=>{N.cancelable&&N.preventDefault(),N.stopPropagation(),u(S);const T=gt(S,d);l!=null&&l.textOpt&&(l.textOpt.fontColor=T,c({textOpt:l.textOpt})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:o||[H],workState:b.Done,fontColor:T,viewId:a==null?void 0:a.viewId})}})}),I):null,[s,i,I,h,d,l==null?void 0:l.textOpt,o,a==null?void 0:a.viewId,f]),v=g.useMemo(()=>{const m=h&&h!=="transparent"&>(h,d)||"transparent";return g.createElement("div",{className:"color-bar"},g.createElement("div",{className:"color-bar-color",style:{backgroundColor:m}}))},[h,d]);return g.createElement("div",{className:`button normal-button font-colors-icon ${s&&"active"}`,onTouchEnd:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),t(!s)},onClick:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),t(!s)}},g.createElement("img",{alt:"icon",src:wt("font-colors")}),v,y)},pM=r=>{const{open:s,setOpen:t,textOpt:e,workIds:o,floatBarRef:n}=r,{floatBarColors:i,mananger:a,setFloatBarData:c,floatBarData:l}=g.useContext(Mt),[h,u]=g.useState(),[d,p]=g.useState(1);g.useEffect(()=>{if(e!=null&&e.fontBgColor){const[m,w]=(e==null?void 0:e.fontBgColor)==="transparent"&&["transparent",1]||co(e.fontBgColor);u(m),p(w)}},[e==null?void 0:e.fontBgColor]);const f=g.useMemo(()=>{if(n!=null&&n.current&&O.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(n.current.offsetTop&&n.current.offsetTop+l.y>180){const m={};return m.top="inherit",m.bottom=50,m}else if(!n.current.offsetTop&&(a==null?void 0:a.height)-n.current.offsetTop-l.y<120){const m={};return m.top="inherit",m.bottom=50,m}}},[n==null?void 0:n.current,l,a]),I=g.useMemo(()=>h&&h!=="transparent"?g.createElement(ho,{key:"fontBgColor",opacity:d||0,activeColor:h,setCurOpacity:(m,w,S)=>{S===b.Start&&(a!=null&&a.control.room)&&(a.control.room.disableDeviceInputs=!0),S===b.Done&&(a!=null&&a.control.room)&&(a.control.room.disableDeviceInputs=!1),p(m);const N=gt(w,m);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=N,c({textOpt:l.textOpt})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:o||[H],fontBgColor:h&>(w,m),workState:S,viewId:a==null?void 0:a.viewId})}}):null,[h,d,a==null?void 0:a.control.room,a==null?void 0:a.viewId,l==null?void 0:l.textOpt,o]),y=g.useMemo(()=>s?g.createElement("div",{className:"font-colors-menu",style:f,onTouchEnd:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()},onClick:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()}},g.createElement(zi,{activeColor:h,onTouchEndHandler:m=>{m.stopPropagation();const w="transparent";u(w),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=w,c({textOpt:l.textOpt})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:o||[H],workState:b.Done,fontBgColor:w,viewId:a==null?void 0:a.viewId})},onClickHandler:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation();const w="transparent";u(w),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=w,c({textOpt:l.textOpt})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:o||[H],workState:b.Done,fontBgColor:w,viewId:a==null?void 0:a.viewId})}}),i.map((m,w)=>{const S=De(...m);return g.createElement(lo,{key:w,color:S,activeColor:h,onTouchEndHandler:N=>{N.stopPropagation(),u(S);const T=gt(S,d);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=T,c({textOpt:l.textOpt})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:o||[H],workState:b.Done,fontBgColor:gt(S,d),viewId:a==null?void 0:a.viewId})},onClickHandler:N=>{N.cancelable&&N.preventDefault(),N.stopPropagation(),u(S);const T=gt(S,d);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=T,c({textOpt:l.textOpt})),q.emitMethod(Z.MainEngine,R.SetColorNode,{workIds:o||[H],workState:b.Done,fontBgColor:gt(S,d),viewId:a==null?void 0:a.viewId})}})}),I):null,[s,i,I,d,h,l==null?void 0:l.textOpt,o,a==null?void 0:a.viewId,f]),v=g.useMemo(()=>{const m=h&&h!=="transparent"&>(h,d)||"transparent";return g.createElement("div",{className:"color-bar",style:{marginTop:0}},g.createElement("div",{className:"color-bar-color",style:{backgroundColor:m}}))},[h,d]);return g.createElement("div",{className:`button normal-button font-colors-icon ${s&&"active"}`,onTouchEnd:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),t(!s)},onClick:m=>{m.cancelable&&m.preventDefault(),m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),t(!s)}},g.createElement(aM,null),v,y)},fM=r=>{const{bold:s,setBold:t,workIds:e,viewId:o}=r,n=i=>{const a=s==="bold"?"normal":"bold";i.cancelable&&i.preventDefault(),i==null||i.stopPropagation(),t(a),q.emitMethod(Z.MainEngine,R.SetFontStyle,{workIds:e,viewId:o,bold:a})};return g.createElement("div",{className:"font-style-button",onClick:n,onTouchEnd:n},g.createElement("img",{alt:"icon",src:wt(s==="bold"?"bold-active":"bold")}))},gM=r=>{const{underline:s,setUnderline:t,workIds:e,viewId:o}=r,n=i=>{const a=!s;i.cancelable&&i.preventDefault(),i==null||i.stopPropagation(),t(a),q.emitMethod(Z.MainEngine,R.SetFontStyle,{workIds:e,viewId:o,underline:a})};return g.createElement("div",{className:"font-style-button",onClick:n,onTouchEnd:n},g.createElement("img",{alt:"icon",src:wt(s?"underline-active":"underline")}))},MM=r=>{const{lineThrough:s,setLineThrough:t,workIds:e,viewId:o}=r,n=i=>{const a=!s;i.cancelable&&i.preventDefault(),i==null||i.stopPropagation(),t(a),q.emitMethod(Z.MainEngine,R.SetFontStyle,{workIds:e,viewId:o,lineThrough:a})};return g.createElement("div",{className:"font-style-button",onClick:n,onTouchEnd:n},g.createElement("img",{alt:"icon",src:wt(s?"line-through-active":"line-through")}))},yM=r=>{const{italic:s,setItalic:t,workIds:e,viewId:o}=r,n=i=>{const a=s==="italic"?"normal":"italic";i.cancelable&&i.preventDefault(),i==null||i.stopPropagation(),t(a),q.emitMethod(Z.MainEngine,R.SetFontStyle,{workIds:e,viewId:o,italic:a})};return g.createElement("div",{className:"font-style-button",onClick:n,onTouchEnd:n},g.createElement("img",{alt:"icon",src:wt(s==="italic"?"italic-active":"italic")}))},mM=r=>{const{open:s,setOpen:t,textOpt:e,workIds:o,style:n,floatBarRef:i}=r,{mananger:a,floatBarData:c}=g.useContext(Mt),[l,h]=g.useState("normal"),[u,d]=g.useState("normal"),[p,f]=g.useState(!1),[I,y]=g.useState(!1);g.useEffect(()=>{e!=null&&e.bold&&h(e.bold),O.isBoolean(e==null?void 0:e.underline)&&f(e.underline||!1),O.isBoolean(e==null?void 0:e.lineThrough)&&y(e.lineThrough||!1),e!=null&&e.italic&&d(e.italic)},[e]);const v=g.useMemo(()=>{if(n&&(i!=null&&i.current)&&O.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(i.current.offsetTop&&i.current.offsetTop+c.y>180){const w={};return w.top="inherit",w.bottom=50,w}else if(!i.current.offsetTop&&(a==null?void 0:a.height)-i.current.offsetTop-c.y<120){const w={};return w.top="inherit",w.bottom=50,w}}},[n,i==null?void 0:i.current,c,a]),m=g.useMemo(()=>s?g.createElement("div",{className:"font-style-menu",style:v,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},g.createElement(fM,{workIds:o||[H],bold:l,setBold:h,viewId:a==null?void 0:a.viewId}),g.createElement(gM,{workIds:o||[H],underline:p,setUnderline:f,viewId:a==null?void 0:a.viewId}),g.createElement(MM,{workIds:o||[H],lineThrough:I,setLineThrough:y,viewId:a==null?void 0:a.viewId}),g.createElement(yM,{workIds:o||[H],italic:u,setItalic:d,viewId:a==null?void 0:a.viewId})):null,[s,o,l,a==null?void 0:a.viewId,p,I,u,v]);return g.createElement("div",{className:`button normal-button ${s&&"active"}`,onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),t(!s)},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),t(!s)}},g.createElement("img",{alt:"icon",src:wt(s?"font-style-active":"font-style")}),m)},Lt=Object.freeze([12,14,18,24,36,48,64,80,144,288]),ae=["top","topLeft","topRight","bottom","bottomLeft","bottomRight","left","leftTop","leftBottom","right","rightTop","rightBottom"],wM=r=>{const{style:s,onClickHandler:t}=r;return g.createElement("div",{className:"font-size-menu",style:s,onTouchEnd:e=>{e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()},onClick:e=>{e.cancelable&&e.preventDefault(),e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()}},Lt.map(e=>g.createElement("div",{className:"font-size-btn",key:e,onClick:()=>{t(e)},onTouchEnd:()=>{t(e)}},e)))},IM=r=>{const s=g.useRef(null),{open:t,setOpen:e,textOpt:o,workIds:n,floatBarRef:i}=r,{mananger:a,floatBarData:c}=g.useContext(Mt),[l,h]=g.useState(0),[u,d]=g.useState(),p=Lt.length-1;g.useEffect(()=>{o!=null&&o.fontSize&&(h(o.fontSize),s.current&&(s.current.value=o.fontSize.toString()))},[o==null?void 0:o.fontSize]);const f=g.useMemo(()=>{if(i!=null&&i.current&&O.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(i.current.offsetTop&&i.current.offsetTop+c.y>180){const w={};return w.top="inherit",w.bottom=35,w}else if(!i.current.offsetTop&&(a==null?void 0:a.height)-i.current.offsetTop-c.y<120){const w={};return w.top="inherit",w.bottom=35,w}}},[i==null?void 0:i.current,c,a]);function I(w){h(w),w&&w>=Lt[0]&&w<=Lt[p]&&q.emitMethod(Z.MainEngine,R.SetFontStyle,{workIds:n||[H],fontSize:w,viewId:a==null?void 0:a.viewId})}const y=w=>{var S;(S=s.current)==null||S.blur(),e(!1),m(w)},v=g.useMemo(()=>t?g.createElement(wM,{onClickHandler:y,style:f}):null,[t,y,f]),m=w=>{w>Lt[p]&&(w=Lt[p]),w<Lt[0]&&(w=Lt[0]),I(w)};return g.useEffect(()=>()=>{a!=null&&a.control.room&&O.isBoolean(u)&&(a.control.room.disableDeviceInputs=u)},[a,u]),g.createElement("div",{className:"button normal-button font-size-barBtn",style:{width:50},onTouchEnd:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()},onClick:w=>{w.cancelable&&w.preventDefault(),w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},g.createElement("input",{className:"font-size-input",ref:s,onTouchEnd:()=>{s.current&&s.current.focus()},onClick:()=>{e(!t),s.current&&s.current.focus()},onKeyDown:w=>{if(w.key==="Backspace"){const S=window.getSelection(),N=S==null?void 0:S.getRangeAt(0);if(N!=null&&N.collapsed)return w.cancelable&&w.preventDefault(),document.execCommand("delete",!1),!1}return!1},onKeyUp:w=>{var S;if(s.current){const N=s.current.value,T=parseInt(N);isNaN(T)?s.current.value="0":s.current.value=T.toString(),T&&w.key==="Enter"&&(m(T),(S=s.current)==null||S.blur(),e(!1))}},onFocus:()=>{a!=null&&a.control.room&&!a.control.room.disableDeviceInputs&&(d(a.control.room.disableDeviceInputs),a.control.room.disableDeviceInputs=!0)},onBlur:()=>{a!=null&&a.control.room&&O.isBoolean(u)&&(a.control.room.disableDeviceInputs=u)}}),g.createElement("div",{className:"font-size-btns"},g.createElement("div",{className:"font-size-add",onClick:()=>{m(l+Lt[0])},onTouchEnd:()=>{m(l+Lt[0])}}),g.createElement("div",{className:"font-size-cut",onClick:()=>{m(l-Lt[0])},onTouchEnd:()=>{m(l-Lt[0])}})),v)},vM=r=>{const{workIds:s,mananger:t,islocked:e}=r;return g.createElement("div",{className:"button normal-button",onClick:o=>{o.cancelable&&o.preventDefault(),o.stopPropagation(),q.emitMethod(Z.MainEngine,R.SetLock,{workIds:s||[H],isLocked:!e,viewId:t==null?void 0:t.viewId})},onTouchEnd:o=>{o.stopPropagation(),q.emitMethod(Z.MainEngine,R.SetLock,{workIds:s||[H],isLocked:!e,viewId:t==null?void 0:t.viewId})}},g.createElement("img",{alt:"icon",src:wt(e?"unlock-new":"lock-new")}))},Co=r=>{const{icon:s,min:t,max:e,step:o,value:n,onInputHandler:i}=r,[a,c]=g.useState(0),l=g.useRef(null),h=u=>{u>e&&(u=e),u<t&&(u=t),c(u),i(u),l.current&&(l.current.value=u.toString())};return g.useEffect(()=>{n&&(c(n),l.current&&(l.current.value=n.toString()))},[n]),g.createElement("div",{className:"button input-button",onTouchEnd:u=>{u.stopPropagation(),u.nativeEvent.stopImmediatePropagation()},onClick:u=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),u.nativeEvent.stopImmediatePropagation()}},g.createElement("img",{src:wt(s)}),g.createElement("input",{className:"input-number",type:"text",ref:l,onTouchEnd:()=>{l.current&&l.current.focus()},onClick:()=>{l.current&&l.current.focus()},onKeyDown:u=>{if(u.key==="Backspace"){const d=window.getSelection(),p=d==null?void 0:d.getRangeAt(0);if(p!=null&&p.collapsed)return u.cancelable&&u.preventDefault(),document.execCommand("delete",!1),!1}},onKeyUp:()=>{if(l.current){const u=l.current.value,d=parseInt(u);isNaN(d)?l.current.value="0":l.current.value=d.toString()}},onChange:u=>{const d=u.target.value,p=parseInt(d);p&&p&&p>=t&&p<=e&&h(p)}}),g.createElement("div",{className:"input-number-btns"},g.createElement("div",{className:"input-number-add",onClick:()=>{h(a+o)},onTouchEnd:()=>{h(a+o)}}),g.createElement("div",{className:"input-number-cut",onClick:()=>{h(a-o)},onTouchEnd:()=>{h(a-o)}})))},NM=r=>{const{icon:s,min:t,max:e,step:o,value:n,onInputHandler:i}=r;return g.createElement("div",{className:"button input-button"},g.createElement("img",{src:wt(s)}),g.createElement(TM,{min:t,max:e,step:o,value:n,onInputHandler:i}))},TM=r=>{const{value:s,min:t,max:e,onInputHandler:o}=r,[n,i]=g.useState({x:0,y:0});g.useEffect(()=>{i({x:s*100,y:0})},[]);const a=O.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!==(n==null?void 0:n.x)&&i({x:d,y:0});const p=d/100;s!==p&&o(p)},100,{leading:!1}),c=h=>{h.cancelable&&h.preventDefault(),h.stopPropagation()},l=O.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!==(n==null?void 0:n.x)&&i({x:d,y:0});const p=d/100;s!==p&&o(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)),i({x:d,y:0});const p=d/100;s!==p&&o(p)}},g.createElement("div",{className:"range-number-color"}),g.createElement("div",{className:"range-number"},g.createElement(Me,{bounds:"parent",axis:"x",position:n,onDrag:a,onStart:c,onStop:l},g.createElement("div",{className:"circle",onClick:c}))))},SM=r=>{const{icon:s,value:t,onChangeHandler:e,style:o}=r,[n,i]=g.useState(0),[a,c]=g.useState(),l=g.useRef(null),h=g.useCallback(p=>{p>=ae.length&&(p=0),p<0&&(p=ae.length-1),i(p),e(ae[p]),c(!1),l.current&&(l.current.value=ae[p])},[e]),u=g.useMemo(()=>{if(o&&o.bottom){const p={};return p.top="inherit",p.bottom=50,p}},[o]);g.useEffect(()=>{t&&(i(ae.indexOf(t)),l.current&&(l.current.value=t))},[t]);const d=g.useMemo(()=>a?g.createElement(CM,{options:ae,onClickHandler:h,style:u}):null,[a,h,u]);return g.createElement("div",{className:"button input-button"},g.createElement("img",{src:wt(s)}),g.createElement("input",{readOnly:!0,className:"input-number",type:"text",ref:l,onTouchEnd:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),l.current&&l.current.focus()},onClick:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),l.current&&(l.current.focus(),c(!a))}}),g.createElement("div",{className:"input-number-btns"},g.createElement("div",{className:"input-number-add",onClick:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),h(n+1)},onTouchEnd:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),h(n+1)}}),g.createElement("div",{className:"input-number-cut",onClick:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),h(n-1)},onTouchEnd:p=>{p.cancelable&&p.preventDefault(),p.stopPropagation(),h(n-1)}})),d)},CM=r=>{const{options:s,style:t,onClickHandler:e}=r;return g.createElement("div",{className:"select-option-menu",style:t,onTouchEnd:o=>{o.cancelable&&o.preventDefault(),o.stopPropagation(),o.nativeEvent.stopImmediatePropagation()},onClick:o=>{o.cancelable&&o.preventDefault(),o.stopPropagation(),o.nativeEvent.stopImmediatePropagation()}},s.map((o,n)=>g.createElement("div",{className:"select-option-btn",key:o,onClick:i=>{i.cancelable&&i.preventDefault(),i.stopPropagation(),e(n)},onTouchEnd:i=>{i.cancelable&&i.preventDefault(),i.stopPropagation(),e(n)}},o)))},kM=r=>{const{mananger:s,innerRatio:t,innerVerticeStep:e,vertices:o}=r,n=c=>{q.emitMethod(Z.MainEngine,R.SetShapeOpt,{workIds:[H],toolsType:C.Star,viewId:s.viewId,vertices:c})},i=c=>{q.emitMethod(Z.MainEngine,R.SetShapeOpt,{workIds:[H],toolsType:C.Star,viewId:s.viewId,innerVerticeStep:c})},a=c=>{q.emitMethod(Z.MainEngine,R.SetShapeOpt,{workIds:[H],toolsType:C.Star,viewId:s.viewId,innerRatio:c})};return g.createElement(g.Fragment,null,g.createElement(Co,{value:o,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:n}),g.createElement(Co,{value:e,icon:"star-innerVertex",min:1,max:100,step:1,onInputHandler:i}),g.createElement(NM,{value:t,icon:"star-innerRatio",min:.1,max:1,step:.1,onInputHandler:a}))},xM=r=>{const{mananger:s,vertices:t}=r,e=o=>{q.emitMethod(Z.MainEngine,R.SetShapeOpt,{workIds:[H],toolsType:C.Polygon,viewId:s.viewId,vertices:o})};return g.createElement(Co,{value:t,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:e})},zM=r=>{const{mananger:s,placement:t}=r,e=o=>{q.emitMethod(Z.MainEngine,R.SetShapeOpt,{workIds:[H],toolsType:C.SpeechBalloon,viewId:s.viewId,placement:o})};return g.createElement(SM,{value:t,icon:"speechBallon-placement",onChangeHandler:e})},yo=r=>{const{icon:s,isActive:t,onClickHandler:e,onTouchEndHandler:o}=r;return g.createElement("div",{className:`button tab-button ${t?"active":""}`,onClick:e,onTouchEnd:o},g.createElement("img",{src:wt(s)}))},LM=r=>{const{toolsTypes:s,style:t,mananger:e,shapeOpt:o}=r,[n,i]=g.useState();g.useEffect(()=>{s.includes(C.Polygon)?i(C.Polygon):s.includes(C.Star)?i(C.Star):i(C.SpeechBalloon)},[s]);const a=(u,d)=>{d.cancelable&&d.preventDefault(),d==null||d.stopPropagation(),i(u)},c=g.useMemo(()=>n===C.Polygon&&e&&o.vertices?g.createElement(xM,{vertices:o.vertices,mananger:e}):null,[e,n,o]),l=g.useMemo(()=>n===C.Star&&e&&o.vertices&&o.innerVerticeStep&&o.innerRatio?g.createElement(kM,{mananger:e,vertices:o.vertices,innerVerticeStep:o.innerVerticeStep,innerRatio:o.innerRatio}):null,[e,n,o]),h=g.useMemo(()=>n===C.SpeechBalloon&&e&&o.placement?g.createElement(zM,{mananger:e,placement:o.placement}):null,[e,n,o]);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"},s.includes(C.Polygon)&&g.createElement(yo,{isActive:n===C.Polygon,icon:n===C.Polygon?"polygon-active":"polygon",onClickHandler:a.bind(void 0,C.Polygon),onTouchEndHandler:a.bind(void 0,C.Polygon)})||null,s.includes(C.Star)&&g.createElement(yo,{isActive:n===C.Star,icon:n===C.Star?"star-active":"star",onClickHandler:a.bind(void 0,C.Star),onTouchEndHandler:a.bind(void 0,C.Star)})||null,s.includes(C.SpeechBalloon)&&g.createElement(yo,{isActive:n===C.SpeechBalloon,icon:n===C.SpeechBalloon?"speechBallon-active":"speechBallon",onClickHandler:a.bind(void 0,C.SpeechBalloon),onTouchEndHandler:a.bind(void 0,C.SpeechBalloon)})||null),g.createElement("div",{className:"shapeOpt-sub-menu-content"},c,l,h))},bM=r=>{const{open:s,setOpen:t,floatBarRef:e,toolsTypes:o,shapeOpt:n}=r,{floatBarData:i,mananger:a}=g.useContext(Mt),[c,l]=g.useState([]),[h,u]=g.useState(),d=g.useMemo(()=>{if(e!=null&&e.current&&O.isNumber(i==null?void 0:i.x)&&O.isNumber(i==null?void 0:i.y)&&(a!=null&&a.height)){if(e.current.offsetTop&&e.current.offsetTop+i.y>200){const y={};return y.top="inherit",y.bottom=50,y}else if(!e.current.offsetTop&&(a==null?void 0:a.height)-e.current.offsetTop-(i==null?void 0:i.y)<140){const y={};return y.top="inherit",y.bottom=50,y}}},[e,i==null?void 0:i.x,i==null?void 0:i.y,a==null?void 0:a.height]),p=g.useMemo(()=>s&&o&&a&&n?(a.control.room&&!a.control.room.disableDeviceInputs&&(u(a.control.room.disableDeviceInputs),a.control.room.disableDeviceInputs=!0),g.createElement(LM,{shapeOpt:n,style:d,toolsTypes:o,mananger:a})):(a!=null&&a.control.room&&O.isBoolean(h)&&(a.control.room.disableDeviceInputs=h),null),[s,d,o,a,n]),f=y=>{y.cancelable&&y.preventDefault(),y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),t(!s)},I=y=>{y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),t(!s)};return g.useEffect(()=>{O.isEqual(i==null?void 0:i.selectIds,c)||i!=null&&i.selectIds&&!O.isEqual(i==null?void 0:i.selectIds,c)&&(l(i==null?void 0:i.selectIds),t(!1))},[s,i,c,t]),g.useEffect(()=>()=>{s&&a!=null&&a.control.room&&O.isBoolean(h)&&(a.control.room.disableDeviceInputs=h)},[s,a,h]),g.createElement("div",{className:`button normal-button ${s&&"active"}`,onClick:f,onTouchEnd:I},p,g.createElement("img",{alt:"icon",src:wt(s?"shapes-active":"shapes")}))},Li=g.memo(r=>{const{textOpt:s,workIds:t,noLayer:e,position:o}=r,{floatBarData:n,mananger:i}=g.useContext(Mt),[a,c]=g.useState(0),[l,h]=g.useState(),u=g.useRef(null);g.useEffect(()=>{var L,D,A,P;const N={},T=(n==null?void 0:n.w)||((L=s==null?void 0:s.boxSize)==null?void 0:L[0])||0,x=(n==null?void 0:n.h)||((D=s==null?void 0:s.boxSize)==null?void 0:D[1])||0;if(o&&T&&x&&(i!=null&&i.width)&&(i!=null&&i.height)){if(o.y<60?o.y+x<i.height-60?N.bottom=-120:o.y+x<i.height?N.bottom=-58:o.y>0?N.top=62:N.top=-o.y+62:N.top=0,o.x<0)N.left=-o.x+3;else if(o.x+(((A=u.current)==null?void 0:A.offsetWidth)||T)>i.width){const E=i.width-(((P=u.current)==null?void 0:P.offsetWidth)||T)-o.x;N.left=E}h(N);return}h(void 0)},[u,o,n==null?void 0:n.w,n==null?void 0:n.h,i==null?void 0:i.width,i==null?void 0:i.height,s==null?void 0:s.boxSize]);const d=g.useMemo(()=>n!=null&&n.fillColor?g.createElement(uM,{floatBarRef:u,open:a===3,setOpen:N=>{c(N===!0?3:0)}}):null,[n==null?void 0:n.fillColor,a,u]),p=g.useMemo(()=>n!=null&&n.strokeColor?g.createElement(hM,{floatBarRef:u,open:a===2,setOpen:N=>{c(N===!0?2:0)}}):null,[n==null?void 0:n.strokeColor,a,u]),f=g.useMemo(()=>s!=null&&s.fontColor&&(i!=null&&i.viewId)?g.createElement(dM,{floatBarRef:u,open:a===4,setOpen:N=>{c(N===!0?4:0)},textOpt:s,workIds:t}):null,[s,a,t,i,u]),I=g.useMemo(()=>s!=null&&s.fontBgColor&&(i!=null&&i.viewId)?g.createElement(pM,{floatBarRef:u,open:a===5,setOpen:N=>{c(N===!0?5:0)},textOpt:s,workIds:t}):null,[s,a,t,i,u]),y=g.useMemo(()=>s&&(i!=null&&i.viewId)?g.createElement(mM,{floatBarRef:u,open:a===6,setOpen:N=>{c(N===!0?6:0)},textOpt:s,workIds:t,style:l}):null,[s,a,t,i,l,u]),v=g.useMemo(()=>s&&(i!=null&&i.viewId)?g.createElement(IM,{open:a===7,setOpen:N=>{c(N===!0?7:0)},textOpt:s,workIds:t,floatBarRef:u}):null,[s,a,t,i,u]),m=g.useMemo(()=>e?null:g.createElement(rM,{open:a===1,setOpen:N=>{c(N===!0?1:0)},floatBarRef:u}),[e,a,u]),w=g.useMemo(()=>n!=null&&n.canLock&&i?g.createElement(vM,{workIds:t,mananger:i,islocked:n.isLocked}):null,[n,i,t]),S=g.useMemo(()=>i&&(i!=null&&i.viewId)&&l&&(n!=null&&n.shapeOpt)&&(n!=null&&n.toolsTypes)?g.createElement(bM,{open:a===8,setOpen:N=>{c(N===!0?8:0)},floatBarRef:u,workIds:t,toolsTypes:n.toolsTypes,shapeOpt:n.shapeOpt}):null,[n,i,a,l,t,u]);return g.createElement("div",{className:"appliance-plugin-floatbtns",style:l,ref:u,onMouseOver:N=>(N.stopPropagation(),N.cancelable&&N.preventDefault(),i==null||i.control.worker.blurCursor(i.viewId),!1),onMouseMove:N=>(N.stopPropagation(),N.cancelable&&N.preventDefault(),!1)},i&&g.createElement(iM,{workIds:t,mananger:i}),m,w,!!(i!=null&&i.viewId)&&g.createElement(nM,{workIds:t,viewId:i.viewId}),S,v,y,f,I,p,d)}),PM=r=>{const{data:s,isActive:t,manager:e,workId:o}=r,{opt:n,scale:i,translate:a,x:c,y:l}=s,h=`scale(${i||1}) ${a&&"translate("+a[0]+"px,"+a[1]+"px)"||""}`,{fontSize:u,fontFamily:d,underline:p,fontColor:f,lineThrough:I,textAlign:y,strokeColor:v,lineHeight:m,bold:w,italic:S,uid:N,workState:T}=n,x=u,L=m||x*1.2,D={fontSize:`${x}px`,lineHeight:`${L}px`,color:f,borderColor:v,minHeight:`${L}px`,paddingRight:`${S==="italic"?Math.round(x*.3):5}px`};d&&(D.fontFamily=`${d}`),(I||p)&&(D.textDecoration=`${I&&"line-through"||""}${p&&" underline"||""}`),w&&(D.fontWeight=`${w}`),S&&(D.fontStyle=`${S}`),y&&(D.textAlign=`${y}`);function A(){var E;t&&(N&&N===((E=e.control.collector)==null?void 0:E.uid)||!N)&&e.control.textEditorManager.active(o)}const P=g.useMemo(()=>{const E=[];if(n.text){const j=Ne(n.text);for(let _=0;_<j.length;_++){const nt=j[_];nt===""?E.push(g.createElement("div",{style:{backgroundColor:n.fontBgColor},key:_},g.createElement("br",null))):E.push(g.createElement("div",{style:{backgroundColor:n.fontBgColor},key:_},nt))}}return E.length?E:null},[n.fontBgColor,n.text]);return g.createElement("div",{className:"editor-box",style:{left:`${c}px`,top:`${l}px`,transform:h,transformOrigin:"left top",pointerEvents:"none",opacity:T===b.Done?0:1}},g.createElement("div",{className:`editor ${t?"":"readOnly"}`,style:D,onClick:A},P))},jM=g.memo(r=>{const{data:s,left:t,top:e,workId:o,updateOptInfo:n}=r,{opt:i,scale:a,translate:c}=s,l=g.useRef(null);g.useEffect(()=>{var D,A;if((D=l.current)!=null&&D.offsetWidth&&((A=l.current)!=null&&A.offsetHeight)){const P=i.boxSize;if((P==null?void 0:P[0])!==l.current.offsetWidth||P[1]!==l.current.offsetHeight||!P){const E=[l.current.offsetWidth,l.current.offsetHeight];n({activeTextId:o,update:{boxSize:E,workState:b.Done}})}}},[i.fontSize,i.italic,i.bold,i.boxSize,o]);const h=`scale(${a||1}) ${c&&"translate("+c[0]+"px,"+c[1]+"px)"||""}`,{fontSize:u,fontFamily:d,underline:p,fontColor:f,lineThrough:I,textAlign:y,strokeColor:v,lineHeight:m,bold:w,italic:S}=i,N=u,T=m||N*1.2,x={fontSize:`${N}px`,lineHeight:`${T}px`,color:f,borderColor:v,minHeight:`${T}px`,pointerEvents:"none",paddingRight:`${S==="italic"?Math.round(N*.3):5}px`};d&&(x.fontFamily=`${d}`),(I||p)&&(x.textDecoration=`${I&&"line-through"||""}${p&&" underline"||""}`),y&&(x.textAlign=`${y}`),w&&(x.fontWeight=`${w}`),S&&(x.fontStyle=`${S}`);const L=g.useMemo(()=>{const D=[];if(i.text){const A=Ne(i.text);for(let P=0;P<A.length;P++){const E=A[P];E===""?D.push(g.createElement("div",{key:P},g.createElement("br",null))):D.push(g.createElement("div",{key:P},E))}}return D.length?D:null},[i.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},L))},(r,s)=>!(r.workId!==s.workId||r.left!==s.left||r.top!==s.top||!O.isEqual(r.data,s.data))),DM=r=>{const{data:s,workId:t,isSelect:e,showFloatBtns:o,handleKeyUp:n,handleFocus:i,updateOptInfo:a,manager:c,runAnimation:l}=r,[h,u]=g.useState(),{opt:d,scale:p,translate:f,x:I,y}=s,{fontSize:v,fontFamily:m,underline:w,fontColor:S,lineThrough:N,textAlign:T,strokeColor:x,lineHeight:L,bold:D,italic:A,boxSize:P}=d,E=g.useRef(null),j=g.useMemo(()=>{const ot=v,at=L||ot*1.2,W={fontSize:`${ot}px`,lineHeight:`${at}px`,color:S,borderColor:x,minHeight:`${at}px`,paddingRight:`${A==="italic"?Math.round(ot*.3):5}px`,borderWidth:`${Math.max(Math.round(1/(p||1)),1)}px`};return m&&(W.fontFamily=`${m}`),(N||w)&&(W.textDecoration=`${N&&"line-through"||""} ${w&&" underline"||""}`),T&&(W.textAlign=`${T}`),D&&(W.fontWeight=`${D}`),A&&(W.fontStyle=`${A}`),W},[D,S,m,v,A,L,N,p,x,T,w]),_=g.useMemo(()=>{const ot=`scale(${p||1}) ${f&&"translate("+f[0]+"px,"+f[1]+"px)"||""}`;return{left:`${I}px`,top:`${y}px`,zIndex:2,pointerEvents:"none",transform:ot,transformOrigin:"left top"}},[p,f,I,y]),nt=g.useMemo(()=>{var ot,at;return!e&&p&&o&&O.isNumber(I)&&O.isNumber(y)&&d.boxSize&&O.isNumber((ot=d.boxSize)==null?void 0:ot[0])&&O.isNumber((at=d.boxSize)==null?void 0:at[1])?g.createElement("div",{className:Tt.FloatBarBtn,style:{left:I,top:y,width:d.boxSize[0]*p,height:d.boxSize[1]*p}},g.createElement(Li,{position:{x:I,y},textOpt:d,workIds:[t],noLayer:!0})):null},[e,d,o,t,I,y,p]),tt=g.useMemo(()=>{let ot="";if(d.text){const at=Ne(d.text);for(let W=0;W<at.length;W++){const it=at[W];it===""?ot=ot+"<div><br/></div>":ot=ot+`<div style="background-color:${d.fontBgColor}">${it}</div>`}}else ot=`<div style="background-color:${d.fontBgColor}"></div>`;return ot},[d.fontBgColor,d.text]),V=g.useMemo(()=>typeof tt=="string"?g.createElement("div",{id:t,suppressContentEditableWarning:!0,contentEditable:!0,className:"editor",ref:E,style:j,onKeyDown:$,onKeyUp:n,onClick:K,onTouchEnd:K,onFocus:i,onPaste:rt,onInput:It,dangerouslySetInnerHTML:{__html:tt}}):null,[tt,j,t]);g.useEffect(()=>{V&&E.current&&(E.current.click(),setTimeout(()=>{var ot;if(E.current){const at=window==null?void 0:window.getSelection(),W=E.current.lastChild;if(at&&W){const it=document.createRange(),ht=((ot=W.textContent)==null?void 0:ot.length)||0;(W==null?void 0:W.nodeName)==="#text"?it.setStart(W,ht):it.setStart(W,ht&&1||0),it.collapse(!0),at.removeAllRanges(),at.addRange(it)}}},20))},[V,E.current]),g.useEffect(()=>{var ot,at,W,it;if(V&&((ot=E.current)!=null&&ot.offsetWidth||(at=E.current)!=null&&at.offsetHeight||(W=E.current)!=null&&W.offsetLeft||(it=E.current)!=null&&it.offsetTop)){const ht=[E.current.offsetWidth,E.current.offsetHeight];(P&&P[0]!==ht[0]&&P[1]!==ht[1]||!P)&&a({activeTextId:t,update:{boxSize:ht,workState:b.Doing}})}},[P,V,j,t]);function K(){E.current&&E.current.focus(),l()}function $(ot){if(ot.key==="Backspace"){const at=window.getSelection(),W=at==null?void 0:at.getRangeAt(0);if(W!=null&&W.collapsed)return ot.cancelable&&ot.preventDefault(),document.execCommand("delete",!1),!1}return l(),!1}function G(ot,at){const W=window==null?void 0:window.getSelection();if(W!=null&&W.rangeCount&&ot&&W&&W.anchorNode){const it=W.anchorOffset,ht=W.anchorNode.textContent||"",vt=ht.slice(0,it)||"",Kt=ht.slice(it)||"",Bt=vt.concat(ot)||"";J(Bt,Kt,at)}}function J(ot,at,W){const it=window==null?void 0:window.getSelection();if(!(it!=null&&it.rangeCount)||!it.anchorNode)return;const ht=ot.split(/\n/);let vt=it.anchorNode.parentNode;vt===W&&(vt=it.anchorNode);const Kt=[...W.childNodes],Bt=[];let Pt,uo=it.anchorOffset;for(;Kt.length;){const Nt=Kt.pop();if(Nt){if(Nt===vt){let jt=ht[0];ht.length===1&&(uo=ht[0].length,jt=ht[0].concat(at)),vt.nodeName==="#text"?(vt.textContent=jt,Pt=vt):vt.nodeName==="DIV"&&(vt.innerText=jt,Pt=vt.childNodes[0]);break}Bt.push(Nt),W.removeChild(Nt)}}if(ht.length>1)for(let Nt=1;Nt<ht.length;Nt++){let jt=ht[Nt];const Te=document.createElement("div");d.fontBgColor&&(Te.style.backgroundColor=d.fontBgColor),Nt===ht.length-1&&(uo=jt.length,jt=jt.concat(at)),jt===""?Te.innerHTML="<br/>":Te.innerText=jt,W.appendChild(Te),Nt===ht.length-1&&(Pt=Te.childNodes[0])}if(Bt.length){Bt.reverse();for(const Nt of Bt)W.appendChild(Nt)}if(Pt&&Pt.nodeName==="#text"){it.deleteFromDocument();const Nt=document.createRange(),jt=Math.min(uo,(Pt==null?void 0:Pt.length)||0);Nt.setStart(Pt,jt),Nt.collapse(!0),it.removeAllRanges(),it.addRange(Nt)}}function rt(ot){if(ot.cancelable&&ot.preventDefault(),ot.stopPropagation(),E.current){const at=(ot.clipboardData||window.clipboardData).getData("text"),W=window==null?void 0:window.getSelection();if(!(W!=null&&W.rangeCount))return;at&&W&&W.anchorNode&&G(at,E.current),l()}}function It(ot){n(ot),l()}return g.createElement(g.Fragment,null,nt,g.createElement("div",{className:"editor-box",style:_,onFocus:()=>{c.control.room&&!c.control.room.disableDeviceInputs&&(u(c.control.room.disableDeviceInputs),c.control.room.disableDeviceInputs=!0)},onBlur:()=>{c!=null&&c.control.room&&O.isBoolean(h)&&(c.control.room.disableDeviceInputs=h)}},V))};class bi extends g.Component{constructor(s){super(s)}getInnerText(s){const t=[];for(let e=0;e<s.childNodes.length;e++){const o=s.childNodes[e];if(o.nodeName==="#text"&&e===0){const n=o.textContent.split(/\n/),i=n.pop();t.push(...n),i&&t.push(i)}else if(o.nodeName==="DIV"){const n=o.innerText.split(/\n/);if(n.length===2&&n[0]===""&&n[1]==="")t.push("");else{const i=n.shift();i&&t.push(i);const a=n.pop();t.push(...n),a&&t.push(a)}}}return t}updateOptInfo(s){var i,a;const{activeTextId:t,update:e,syncData:o}=s,n=t&&O.cloneDeep(((i=this.props.manager.control.textEditorManager)==null?void 0:i.get(t))||((a=this.props.editors)==null?void 0:a.get(t)));n&&n.opt&&(n.opt={...n.opt,...e},o&&(n.canSync=Object.keys(o).includes("canSync")&&o.canSync||n.canSync,n.canWorker=Object.keys(o).includes("canWorker")&&o.canWorker||n.canWorker),this.props.manager.control.textEditorManager.updateForViewEdited(t,n))}get editorUI(){var s;if((s=this.props.editors)!=null&&s.size){const t=[];return this.props.editors.forEach((e,o)=>{if(this.props.selectIds.includes(o)&&!(this.props.activeTextId==o)&&this.props.box){const{x:i,y:a}=this.props.box,{x:c,y:l}=e,h=`${c-i}px`,u=`${l-a}px`,d=g.createElement(jM,{left:h,top:u,key:o,data:e,workId:o,isSelect:!0,updateOptInfo:this.updateOptInfo.bind(this),manager:this.props.manager});t.push(d)}}),t}return null}render(){return g.createElement(g.Fragment,null,this.editorUI)}}class EM extends bi{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),o=this.props.activeTextId;if(o){const n=this.props.manager.control.textEditorManager.get(o),i=zt(e),a=b.Doing,c=[t.nativeEvent.target.offsetWidth,t.nativeEvent.target.offsetHeight];(!n||n&&(n.opt.text!==i||!O.isEqual(n.opt.boxSize,c)||!O.isEqual(n.opt.workState,a)))&&this.updateOptInfo({activeTextId:o,update:{text:i,boxSize:c,workState:a},syncData:{canSync:!0,canWorker:!0}})}}handleFocus(t){const e=this.props.activeTextId;if(e){const o=this.props.manager.control.textEditorManager.get(e),n=b.Doing,i=[t.nativeEvent.target.offsetWidth,t.nativeEvent.target.offsetHeight];(!o||o&&(!O.isEqual(o.opt.boxSize,i)||!O.isEqual(o.opt.workState,n)))&&this.updateOptInfo({activeTextId:e,update:{boxSize:i,workState:n},syncData:{canSync:!0,canWorker:!0}})}}get editorUI(){var t;if((t=this.props.editors)!=null&&t.size){const e=[];return this.props.editors.forEach((o,n)=>{if(!(this.props.selectIds.includes(n)&&this.props.activeTextId!==n)){const c=this.props.activeTextId==n?g.createElement(DM,{key:n,data:o,workId:n,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(PM,{manager:this.props.manager,isActive:o.opt.workState===b.Doing||o.opt.workState===b.Start||!1,key:n,data:o,workId:n});e.push(c)}}),e}return null}render(){return g.createElement("div",{className:`${this.props.className}`,ref:this.ref},this.editorUI)}}const AM=()=>{const{floatBarData:r}=g.useContext(Mt);return g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},g.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point LC ew-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point TC ns-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point RC ew-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point BC ns-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}))},OM=()=>{const{floatBarData:r,mananger:s}=g.useContext(Mt),[t,e]=g.useState(),[o,n]=g.useState();g.useEffect(()=>{const c=[];if(s&&O.isNumber(r==null?void 0:r.x)&&O.isNumber(r==null?void 0:r.y)&&(r!=null&&r.points)){const l=s.viewId;if(s.control.viewContainerManager.getView(l))for(const u of r.points){const d=s.control.viewContainerManager.transformToOriginPoint(u,l);c.push(d)}c[0]&&e({x:c[0][0]-((r==null?void 0:r.x)||0),y:c[0][1]-((r==null?void 0:r.y)||0)}),c[1]&&n({x:c[1][0]-((r==null?void 0:r.x)||0),y:c[1][1]-((r==null?void 0:r.y)||0)})}},[s,r==null?void 0:r.points,r==null?void 0:r.x,r==null?void 0:r.y]);const i=g.useMemo(()=>t?g.createElement("div",{className:"point point-dot",style:{borderColor:r==null?void 0:r.selectorColor,left:t.x,top:t.y}}):null,[r==null?void 0:r.selectorColor,t]),a=g.useMemo(()=>o?g.createElement("div",{className:"point point-dot",style:{borderColor:r==null?void 0:r.selectorColor,left:o.x,top:o.y}}):null,[o,r==null?void 0:r.selectorColor]);return g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},i,a)},RM=()=>{const{floatBarData:r}=g.useContext(Mt);return g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},g.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),g.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}))},YM=()=>{const{floatBarData:r}=g.useContext(Mt);return g.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},g.createElement("img",{className:"lock",alt:"lock",src:"https://sdk.netless.link/resource/icons/lock.svg"}))},WM=r=>{const{className:s}=r,{floatBarData:t,angle:e,setAngle:o,setOperationType:n,mananger:i}=g.useContext(Mt),[a,c]=g.useState(!1),[l,h]=g.useState(new B),[u,d]=g.useState(new B),[p,f]=g.useState(!1);g.useEffect(()=>(q.activeListener(I),()=>{q.unmountActiveListener(I)}),[]);const I=w=>{var S;if(!w){f(!0),c(!1),n(R.None);return}f(!1),(S=i==null?void 0:i.control.room)!=null&&S.disableDeviceInputs&&(i.control.room.disableDeviceInputs=!1)};g.useEffect(()=>{if(t){const w=Math.floor(t.w/2),S=Math.floor(-t.h/2);d(new B(w,S)),h(new B)}},[t]);const y=(w,S)=>{if(w.cancelable&&w.preventDefault(),w.stopPropagation(),i!=null&&i.control.worker.isBusy){f(!0);return}c(!0);const N=Math.round(B.GetAngleByPoints(l,u,new B(S.x,S.y)))||0;o(N),n(R.RotateNode),i!=null&&i.control.room&&(i.control.room.disableDeviceInputs=!0),q.emitMethod(Z.MainEngine,R.RotateNode,{workIds:[H],angle:N,workState:b.Start,viewId:i==null?void 0:i.viewId})},v=Pe((w,S)=>{if(w.cancelable&&w.preventDefault(),w.stopPropagation(),i!=null&&i.control.worker.isBusy){f(!0);return}c(!1);const N=Math.round(B.GetAngleByPoints(l,u,new B(S.x,S.y)))||0;o(N),n(R.None),i!=null&&i.control.room&&(i.control.room.disableDeviceInputs=!1),q.emitMethod(Z.MainEngine,R.RotateNode,{workIds:[H],angle:N,workState:b.Done,viewId:i==null?void 0:i.viewId})},100,{leading:!1}),m=Pe((w,S)=>{if(w.cancelable&&w.preventDefault(),w.stopPropagation(),i!=null&&i.control.worker.isBusy){f(!0);return}c(!0);const N=Math.round(B.GetAngleByPoints(l,u,new B(S.x,S.y)))||0;o(N),n(R.RotateNode),q.emitMethod(Z.MainEngine,R.RotateNode,{workIds:[H],angle:N,workState:b.Doing,viewId:i==null?void 0:i.viewId})},100,{leading:!1});return g.createElement(Me,{disabled:p,handle:".appliance-plugin-rotate-mouse-pointer",onStart:y,onDrag:m,onStop:v},g.createElement("div",{className:`${s}`,style:t?{left:t.x-30,top:t.y+t.h+20,touchAction:"none"}:void 0},!a&&g.createElement("div",{className:"appliance-plugin-rotate-btn",style:{backgroundColor:t==null?void 0:t.selectorColor}},g.createElement("img",{alt:"icon",src:wt("rotation-button")})),g.createElement("div",{className:`appliance-plugin-rotate-mouse-pointer ${a?"active":""}`},g.createElement("img",{alt:"icon",src:wt("rotation")}),g.createElement("div",{className:"angle-icon"},e,"°"))))},UM=r=>{const{floatBarData:s,setOperationType:t,mananger:e}=g.useContext(Mt),{onClickHandle:o}=r,[n,i]=g.useState(b.Pending),[a,c]=g.useState(),[l,h]=g.useState(),[u,d]=g.useState(!1);g.useEffect(()=>(q.activeListener(p),()=>{q.unmountActiveListener(p)}),[]);const p=w=>{var S;if(!w||s!=null&&s.isLocked){d(!0),i(b.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(s!=null&&s.isLocked||e!=null&&e.control.worker.isBusy){d(!0),i(b.Pending);return}d(!1)},[s==null?void 0:s.isLocked]),g.useEffect(()=>{O.isNumber(s==null?void 0:s.x)&&O.isNumber(s==null?void 0:s.y)&&(n===b.Pending||n===b.Done)&&h({x:s==null?void 0:s.x,y:s==null?void 0:s.y})},[n,s==null?void 0:s.x,s==null?void 0:s.y]);const f=w=>{if(w.cancelable&&w.preventDefault(),w.stopPropagation(),e!=null&&e.control.worker.isBusy){d(!0),i(b.Pending);return}O.isNumber(s==null?void 0:s.x)&&O.isNumber(s==null?void 0:s.y)&&(t(R.TranslateNode),i(b.Start),c({x:s==null?void 0:s.x,y:s==null?void 0:s.y}),e!=null&&e.control.room&&(e.control.room.disableDeviceInputs=!0),q.emitMethod(Z.MainEngine,R.TranslateNode,{workIds:[H],position:{x:s==null?void 0:s.x,y:s==null?void 0:s.y},workState:b.Start,viewId:e==null?void 0:e.viewId}))},I=O.throttle((w,S)=>{if(w.cancelable&&w.preventDefault(),e!=null&&e.control.worker.isBusy){d(!0),i(b.Pending);return}w.stopPropagation();const N={x:S.x,y:S.y};t(R.None),i(b.Done),e!=null&&e.control.room&&(e.control.room.disableDeviceInputs=!1),q.emitMethod(Z.MainEngine,R.TranslateNode,{workIds:[H],position:N,workState:b.Done,viewId:e==null?void 0:e.viewId})},100,{leading:!1}),y=O.throttle((w,S)=>{if(w.cancelable&&w.preventDefault(),w.stopPropagation(),e!=null&&e.control.worker.isBusy){d(!0),i(b.Pending);return}const N={x:S.x,y:S.y};(S.x!==(s==null?void 0:s.x)||S.y!==(s==null?void 0:s.y))&&(i(b.Doing),q.emitMethod(Z.MainEngine,R.TranslateNode,{workIds:[H],position:N,workState:b.Doing,viewId:e==null?void 0:e.viewId}))},100,{leading:!1}),v=g.useMemo(()=>!!((s==null?void 0:s.scaleType)===ct.none&&(s!=null&&s.canLock)),[s]),m=O.throttle(w=>(w.stopPropagation(),w.cancelable&&w.preventDefault(),(a==null?void 0:a.x)===(s==null?void 0:s.x)&&(a==null?void 0:a.y)===(s==null?void 0:s.y)&&o(w),!1),100,{leading:!1});return g.createElement(Me,{disabled:u,position:l,onStart:f,onDrag:y,onStop:I},g.createElement("div",{style:s?{position:"absolute",left:0,top:0,width:s.w,height:s.h,zIndex:2,pointerEvents:v?"none":"auto",touchAction:"none"}:void 0,onClick:w=>{w.persist(),m(w)},onTouchEnd:w=>{w.persist(),m(w)}}))},BM=r=>{const{className:s}=r,[t,e]=g.useState({x:0,y:0,h:0,w:0}),[o,n]=g.useState(),[i,a]=g.useState(),[c,l]=g.useState(),{floatBarData:h,mananger:u}=g.useContext(Mt),[d,p]=g.useState(),[f,I]=g.useState(!1);g.useEffect(()=>{if(h&&u){const x={x:h.x,y:h.y,w:h.w,h:h.h};e(x)}return q.activeListener(y),()=>{q.unmountActiveListener(y)}},[]);const y=x=>{var L;if(!x){I(!0);return}I(!1),(L=u==null?void 0:u.control.room)!=null&&L.disableDeviceInputs&&(u.control.room.disableDeviceInputs=!1)},v=x=>[[x.x,x.y],[x.x+x.w,x.y],[x.x+x.w,x.y+x.h],[x.x,x.y+x.h]],m=(x,L)=>{switch(L){case"top":case"topLeft":case"left":return x[2];case"topRight":return x[3];case"right":case"bottomRight":case"bottom":return x[0];case"bottomLeft":return x[1]}},w=(x,L,D,A)=>{let P=!1,E=!1;const j={x:t.x,y:t.y,w:t.w,h:t.h},_=[1,1],nt=[0,0];switch(x){case"top":{const $=L.height+t.h;$<0?(E=!0,j.y=t.y+t.h,j.h=Math.abs($)):(j.y=t.y-L.height,j.h=t.h+L.height);break}case"topLeft":{const $=L.width+t.w;$<0?(P=!0,j.x=t.x+t.w,j.w=Math.abs($)):(j.x=t.x-L.width,j.w=t.w+L.width);const G=L.height+t.h;G<0?(E=!0,j.y=t.y+t.h,j.h=Math.abs(G)):(j.y=t.y-L.height,j.h=t.h+L.height);break}case"topRight":{const $=L.width+t.w;$<0?(P=!0,j.x=t.x+$,j.w=Math.abs($)):j.w=t.w+L.width;const G=L.height+t.h;G<0?(E=!0,j.y=t.y+t.h,j.h=Math.abs(G)):(j.y=t.y-L.height,j.h=t.h+L.height);break}case"bottom":{const $=L.height+t.h;$<0?(E=!0,j.y=t.y+$,j.h=Math.abs($)):j.h=t.h+L.height;break}case"bottomLeft":{const $=L.width+t.w;$<0?(P=!0,j.x=t.x+t.w,j.w=Math.abs($)):(j.x=t.x-L.width,j.w=t.w+L.width);const G=L.height+t.h;G<0?(E=!0,j.y=t.y+G,j.h=Math.abs(G)):j.h=t.h+L.height;break}case"left":{const $=L.width+t.w;$<0?(P=!0,j.x=t.x+t.w,j.w=Math.abs($)):(j.x=t.x-L.width,j.w=t.w+L.width);break}case"bottomRight":{const $=L.width+t.w;$<0?(P=!0,j.x=t.x+$,j.w=Math.abs($)):j.w=t.w+L.width;const G=L.height+t.h;G<0?(E=!0,j.y=t.y+G,j.h=Math.abs(G)):j.h=t.h+L.height;break}case"right":{const $=L.width+t.w;$<0?(P=!0,j.x=t.x+$,j.w=Math.abs($)):j.w=t.w+L.width;break}}_[0]=j.w/t.w,_[1]=j.h/t.h;const V=v(j).map($=>D.control.viewContainerManager.transformToScenePoint($,D.viewId)),K=m(V,x);return E&&(nt[1]=K[1]-A[1]),P&&(nt[0]=K[0]-A[0]),{scale:_,translate:nt}},S=(x,L)=>{if(x.cancelable&&x.preventDefault(),x.stopPropagation(),u!=null&&u.control.worker.isBusy){I(!0);return}if(h!=null&&h.w&&(h!=null&&h.h)&&u){const D={x:h.x,y:h.y,w:h.w,h:h.h},A=v(D),P=A.map(_=>u.control.viewContainerManager.transformToScenePoint(_,u.viewId)),E=m(A,L),j=m(P,L);e(D),n(E),a(j),l(L),u!=null&&u.control.room&&(u.control.room.disableDeviceInputs=!0),q.emitMethod(Z.MainEngine,R.ScaleNode,{workIds:[H],originPoint:E,scenePoint:j,workState:b.Start,viewId:u.viewId})}},N=O.throttle((x,L,D,A)=>{if(x.cancelable&&x.preventDefault(),x.stopPropagation(),!u||!o||!i)return;if(u!=null&&u.control.worker.isBusy){I(!0);return}const{scale:P,translate:E}=w(L,A,u,i);(!O.isEqual(P,d==null?void 0:d.scale)||!O.isEqual(E,d==null?void 0:d.translate))&&(p({scale:P,translate:E}),q.emitMethod(Z.MainEngine,R.ScaleNode,{workIds:[H],scale:P,dir:L,translate:E,originPoint:o,scenePoint:i,workState:b.Doing,viewId:u.viewId}))},100,{leading:!1}),T=O.throttle(x=>{if(x.cancelable&&x.preventDefault(),x.stopPropagation(),!(!u||!o||!i)){if(u!=null&&u.control.worker.isBusy){I(!0);return}if(u!=null&&u.control.room&&(u.control.room.disableDeviceInputs=!1),d){const{scale:L,translate:D}=d;q.emitMethod(Z.MainEngine,R.ScaleNode,{workIds:[H],scale:L,dir:c,translate:D,originPoint:o,scenePoint:i,workState:b.Done,viewId:u.viewId})}}},100,{leading:!1});return g.createElement(Di.Resizable,{className:`${s}`,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:N,onResizeStop:T})},bs=r=>{const{id:s,pos:t,pointMap:e,type:o}=r,{setOperationType:n,mananger:i,floatBarData:a}=g.useContext(Mt),[c,l]=g.useState({x:0,y:0}),[h,u]=g.useState(b.Pending),[d,p]=g.useState(!1);g.useEffect(()=>(q.activeListener(f),()=>{q.unmountActiveListener(f)}),[]);const f=m=>{var w;if(!m||a!=null&&a.isLocked){p(!0),u(b.Pending),n(R.None);return}p(!1),(w=i==null?void 0:i.control.room)!=null&&w.disableDeviceInputs&&(i.control.room.disableDeviceInputs=!1)};g.useEffect(()=>{O.isNumber(t.x)&&O.isNumber(t.y)&&(h===b.Pending||h===b.Done)&&l({x:t.x,y:t.y})},[t,h]);const I=m=>{if(m.cancelable&&m.preventDefault(),m.stopPropagation(),i!=null&&i.control.worker.isBusy){p(!0),u(b.Pending);return}O.isNumber(t.x)&&O.isNumber(t.y)&&(n(R.SetPoint),u(b.Start),i!=null&&i.control.room&&(i.control.room.disableDeviceInputs=!0),q.emitMethod(Z.MainEngine,R.SetPoint,{workId:H,pointMap:e,workState:b.Start,viewId:i==null?void 0:i.viewId}))},y=O.throttle((m,w)=>{if(m.cancelable&&m.preventDefault(),m.stopPropagation(),i!=null&&i.control.worker.isBusy){p(!0),u(b.Pending);return}const S={x:w.x,y:w.y};if((S.x!==(t==null?void 0:t.x)||S.y!==(t==null?void 0:t.y))&&(i!=null&&i.control.viewContainerManager)){const N=i.control.viewContainerManager.transformToScenePoint([S.x,S.y],i.viewId),T=e.get(s);T&&o==="start"?T[0]=N:T&&o==="end"&&(T[1]=N),u(b.Doing),q.emitMethod(Z.MainEngine,R.SetPoint,{workId:H,pointMap:e,workState:b.Doing,viewId:i==null?void 0:i.viewId})}},100,{leading:!1}),v=O.throttle((m,w)=>{if(m.cancelable&&m.preventDefault(),i!=null&&i.control.worker.isBusy){p(!0),u(b.Pending);return}m.stopPropagation(),n(R.None),u(b.Done);const S={x:w.x,y:w.y};if(i!=null&&i.control.viewContainerManager){const N=i.control.viewContainerManager.transformToScenePoint([S.x,S.y],i.viewId),T=e.get(s);T&&o==="start"?T[0]=N:T&&o==="end"&&(T[1]=N),i!=null&&i.control.room&&(i.control.room.disableDeviceInputs=!1),q.emitMethod(Z.MainEngine,R.SetPoint,{workId:H,pointMap:e,workState:b.Done,viewId:i==null?void 0:i.viewId})}},100,{leading:!1});return g.createElement(Me,{disabled:d,position:c,onStart:I,onDrag:y,onStop:v},g.createElement("div",{className:"appliance-plugin-point-draggable-btn",style:a?{left:0,top:0}:void 0}))},FM=r=>{const{className:s}=r,{floatBarData:t,mananger:e}=g.useContext(Mt),[o,n]=g.useState(),[i,a]=g.useState(),[c,l]=g.useState(new Map);g.useEffect(()=>{const d=[];if(e&&(t!=null&&t.points)){const p=e.viewId;if(e.control.viewContainerManager.getView(p))for(const I of t.points){const y=e.control.viewContainerManager.transformToOriginPoint(I,p);d.push(y)}t!=null&&t.selectIds&&t.selectIds.length===1&&(c.set(t.selectIds[0],t.points),l(c))}d[0]&&n({x:d[0][0],y:d[0][1]}),d[1]&&a({x:d[1][0],y:d[1][1]})},[e,t==null?void 0:t.points,t==null?void 0:t.selectIds,c]);const h=g.useMemo(()=>o&&(t!=null&&t.selectIds)?g.createElement(bs,{pos:o,type:"start",id:t.selectIds[0],pointMap:c}):null,[o,t==null?void 0:t.selectIds,c]),u=g.useMemo(()=>i&&(t!=null&&t.selectIds)?g.createElement(bs,{pos:i,type:"end",id:t.selectIds[0],pointMap:c}):null,[i,t==null?void 0:t.selectIds,c]);return g.createElement("div",{className:`${s}`},h,u)},HM=g.forwardRef((r,s)=>{const{floatBarData:t,operationType:e}=g.useContext(Mt),o=g.useMemo(()=>(t==null?void 0:t.scaleType)!==ct.all||e===R.RotateNode?null:g.createElement(AM,null),[t,e]),n=g.useMemo(()=>(t==null?void 0:t.scaleType)!==ct.both||e===R.RotateNode?null:g.createElement(OM,null),[t,e]),i=g.useMemo(()=>(t==null?void 0:t.scaleType)!==ct.proportional||e===R.RotateNode?null:g.createElement(RM,null),[t,e]),a=g.useMemo(()=>(t==null?void 0:t.scaleType)===ct.none&&(t!=null&&t.canLock)?g.createElement(YM,null):null,[t]);return g.createElement("div",{ref:s,style:t?{transform:`translate(${t.x}px,${t.y}px)`,width:t.w,height:t.h,pointerEvents:"none"}:void 0},a,o,n,i,r.children)}),QM=g.forwardRef((r,s)=>{var d;const{floatBarData:t,operationType:e,mananger:o}=g.useContext(Mt),{editors:n,activeTextId:i}=r,a=g.useMemo(()=>{var p;return t!=null&&t.canRotate&&((p=t==null?void 0:t.selectIds)==null?void 0:p.length)===1&&(e===R.None||e===R.RotateNode)?g.createElement(WM,{className:Tt.RotateBtn}):null},[t==null?void 0:t.canRotate,(d=t==null?void 0:t.selectIds)==null?void 0:d.length,e]),c=g.useMemo(()=>((t==null?void 0:t.scaleType)===ct.all||(t==null?void 0:t.scaleType)===ct.proportional)&&(e===R.None||e===R.ScaleNode)&&O.isNumber(t==null?void 0:t.x)&&O.isNumber(t==null?void 0:t.y)?g.createElement(BM,{className:Tt.ResizeBtn}):null,[t==null?void 0:t.scaleType,e,t==null?void 0:t.x,t==null?void 0:t.y]),l=g.useMemo(()=>(t==null?void 0:t.scaleType)===ct.both&&(e===R.None||e===R.SetPoint)?g.createElement(FM,{className:Tt.ResizeTowBox}):null,[t==null?void 0:t.scaleType,e]),h=g.useMemo(()=>{const p=(t==null?void 0:t.selectIds)||[];return n&&o&&p&&O.isNumber(t==null?void 0:t.x)&&O.isNumber(t==null?void 0:t.y)&&O.isNumber(t==null?void 0:t.w)&&O.isNumber(t==null?void 0:t.h)?g.createElement(bi,{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:o,selectIds:p,activeTextId:i,editors:n}):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,n,o,i]),u=g.useMemo(()=>e===R.None&&O.isNumber(t==null?void 0:t.x)&&O.isNumber(t==null?void 0:t.y)&&O.isNumber(t==null?void 0:t.w)&&O.isNumber(t==null?void 0:t.h)?g.createElement("div",{className:Tt.FloatBarBtn,style:{left:t==null?void 0:t.x,top:t==null?void 0:t.y,width:t.w,height:t.h}},g.createElement(Li,{position:{x:t.x,y:t.y},textOpt:t==null?void 0:t.textOpt,noLayer:t==null?void 0:t.isLocked})):null,[t==null?void 0:t.x,t==null?void 0:t.y,t==null?void 0:t.w,t==null?void 0:t.h,t==null?void 0:t.textOpt,t==null?void 0:t.isLocked,e]);return g.createElement("div",{className:Tt.FloatBar,onMouseOver:()=>{o==null||o.control.worker.blurCursor(o.viewId)}},g.createElement(HM,{ref:s},g.createElement(g.Fragment,null,h)),g.createElement(UM,{onClickHandle:p=>{if(o&&(n!=null&&n.size)){const f=o.getPoint(p.nativeEvent);f&&o.control.textEditorManager.computeTextActive(f,o.viewId)}}}),a,c,l,u)}),VM=g.memo(QM,(r,s)=>!!O.isEqual(r,s)),$M="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAYISURBVHgB7ZpNSCtXFIBPEuvz+dMGpYUKD/sWFX+Qti6kK7Hqpm6e9q0rIoIUFUShPLV10VZx4+JZqa9v20LBhdq9fyBUCtKNPH8qYl2IOw3G38Rkek4y15y5uTOZJDOWggcOSSYzN/ebc+45554JwIM8iBCPyTEP+86T4vyMfsRN4b+nQTKIJp0vzuGvlpID7os8EQNEIBD4oKio6Bm9DwaDv/v9/n/076JgbtWUYPchwrW8qD7UnOvr6wFNkpubm+/wu7f0c7y6mrnlvQufxB0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7DgMVgsChjTEgCIKGG4ZU+EWkgNBzN1qamq+pAMTExPgFMzW1tZrhHkFyWE5KxgSszx0527RaDRmOSpRshEOU11dPQPG8CwHARHJlMnTSrwSRFIlfXt7m3V5ngJGuJtqzaQtZkFBVNJezN5ZAdmwjKo2k9tVtrcI3OXk4tPgcg7ChCDZ1URgMOu72Xa5VFHOkymQhWVU60YVmjN6wiC7k6p+S1syCACOwJBYFaexV+yhBekNPsMBO6KAEeE4BMaCU67RsoYhSbXgaT//ht709vZCaWmp6YkEbLFmVJWzas04+iBL7EKpm0J7duqu0B7+CTUpNJuyvb1NCfMj1CqI9wLKUOlOUMeG+gGFkHii4HizUF4z/KFUrPsJ8WbEIyx7nnZ0dDynME6BAuce09iFHo+GrnmGltltb2//E4wVAN82y7vOjKOZXSBhJdHNiT3TYWD8OY2PTUJkdd7MkJMnT5wZVQF2RFX6yBMUdzPMvvfqxz3sXHF+GNT9ANXit/10O1sgHkZvdQAOKvs9B5L7ARELGAAXLSTvM8QExTE+YbHe+HURhZp1aRyF4CJXClbbWwGketgkW9VsY+YaiBCVhfgE+XvxRwgZSM4jUVCDZFQ9pytmXR8hUTB2gnidx4XffVWydN0yQjwmx/jkAZJBrIBI5J7ZvQGZWUgVSuU/EqmOAzicKNMVu816DdRWUV1/7xAP8n+SfwF3Du3NF2sYhwAAAABJRU5ErkJggg==",GM="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",ZM="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",qM="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAgrSURBVHgB7ZprTBRXFIDP7gIt8lQppTwE5V0KaAn6o1pqNGkDDTEmT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hk8V2OWm7ieYTXhBc3+BgaZyqAISjOYxSMVvXsBTNlzdiNQDgRao2AtK3pjggpmrqbGpqSsLPIN/dv38/gaBwUjTshMHcvn27JyUlpRmc5xpPMD599LIYnLNyUKKndKjGxsakXbt2deMCLIE8IVvs0YRM1fjdu3d/wrXN5+BcnzEgvor2uN3rjzAYMp5lPEoQlE5fA0fWo8GfhlCbKVFQ1pKNIfzcOHH58mWqaimVUwJI0+6n59D4pIlzmdZPMPiZzXjDjX47Le5g0Uu8x2zgPqWyKpjVe7x3+AUbq9NYjQbgp2dsBud5o8TP7d5kHAWcQchQfoEmLgn8HjOiBIF7o5hI1x6CEbLNP3bdqYAF44JzyWLzcN1i8DcT/o3awbm8Fz3DAy2A62INwPV/E3wWdx5inmBHuwChCBD6R2JwHge80TIQRQLjt7e8DTkGZgfX8cUMZTDAteFDkveaIlzjX9ySQs8X18r2t2VHUURPKoICmDR+eCO9aSdmOIub3/w9RgpgUpiJhvraXpa6jZKHGEqyusw0GLFzX+5RhN/8kYnMSNMMfyH/V/kHST6OYVElTPAAAAAASUVORK5CYII=";class JM extends g.Component{constructor(t){super(t);M(this,"renderAvatar",t=>{var o;const e=`rgb(${t.memberState.strokeColor[0]}, ${t.memberState.strokeColor[1]}, ${t.memberState.strokeColor[2]})`;if(this.detectAvatar(t)){const n=this.detectCursorName(t);return g.createElement("img",{className:"cursor-selector-avatar",style:{width:n?19:28,height:n?19:28,position:n?"initial":"absolute",borderColor:n?"white":e,marginRight:n?4:0},src:(o=t.payload)==null?void 0:o.avatar,alt:"avatar"})}else return null});M(this,"getOpacity",t=>{const e=this.getCursorName(t),o=this.detectAvatar(t);return e===void 0&&o===void 0?0:1});M(this,"getCursorName",t=>{if(t.payload&&(t.payload.nickName||t.payload.cursorName))return t.payload.nickName||t.payload.cursorName});M(this,"getThemeClass",t=>t.payload&&t.payload.theme?"cursor-inner-mellow":"cursor-inner");M(this,"getCursorBackgroundColor",t=>{const e=this.detectCursorName(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,"detectCursorName",t=>!!(t.payload&&t.payload.cursorName));M(this,"detectAvatar",t=>!!(t.payload&&t.payload.avatar));M(this,"renderTag",t=>{if(t.payload&&t.payload.cursorTagName)return g.createElement("span",{className:"cursor-tag-name",style:{backgroundColor:this.getCursorTagBackgroundColor(t)}},t.payload.cursorTagName)})}render(){const{roomMember:t}=this.props,e=this.getCursorName(t);switch(t.memberState.currentApplianceName){case et.pencil:return g.createElement("div",{className:"cursor-box"},g.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -90%)",marginLeft:"10px"}},g.createElement("div",{className:"cursor-name"},g.createElement("div",{style:{opacity:this.getOpacity(t),backgroundColor:this.getCursorBackgroundColor(t),color:this.getCursorTextColor(t)},className:this.getThemeClass(t)},this.renderAvatar(t),e,this.renderTag(t))),g.createElement("div",null,g.createElement("img",{className:"cursor-pencil-image",src:$M,alt:"pencilCursor"}))));case et.pencilEraser:return g.createElement("div",{className:"cursor-box"},g.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -90%)",marginLeft:"0px"}},g.createElement("div",{className:"cursor-name"},g.createElement("div",{style:{opacity:this.getOpacity(t),backgroundColor:this.getCursorBackgroundColor(t),color:this.getCursorTextColor(t)},className:this.getThemeClass(t)},this.renderAvatar(t),e,this.renderTag(t))),g.createElement("div",null,g.createElement("img",{className:"cursor-pencil-image",src:qM,alt:"pencilEraser"}))));case et.text:return g.createElement("div",{className:"cursor-box"},g.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -65%)",marginLeft:"0px"}},g.createElement("div",{className:"cursor-name"},g.createElement("div",{style:{opacity:this.getOpacity(t),backgroundColor:this.getCursorBackgroundColor(t),color:this.getCursorTextColor(t)},className:this.getThemeClass(t)},this.renderAvatar(t),e,this.renderTag(t))),g.createElement("div",null,g.createElement("img",{className:"cursor-arrow-image",src:ZM,alt:"textCursor"}))));case et.rectangle:case et.arrow:case et.straight:case et.shape:case et.ellipse:return g.createElement("div",{className:"cursor-box"},g.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -65%)",marginLeft:"0px"}},g.createElement("div",{className:"cursor-name"},g.createElement("div",{style:{opacity:this.getOpacity(t),backgroundColor:this.getCursorBackgroundColor(t),color:this.getCursorTextColor(t)},className:this.getThemeClass(t)},this.renderAvatar(t),e,this.renderTag(t))),g.createElement("div",null,g.createElement("img",{className:"cursor-arrow-image",src:GM,alt:"shapeCursor"}))));default:return null}}}const XM=r=>{const{className:s,info:t}=r,{roomMember:e,...o}=t||{};return g.createElement("div",{className:`${s}`,style:o?{transform:`translate(${o.x}px, ${o.y}px)`}:{display:"none"}},e&&g.createElement(JM,{roomMember:e}))},KM=r=>{const{className:s,manager:t}=r,[e,o]=g.useState();g.useEffect(()=>(t.internalMsgEmitter.on([Z.Cursor,t.viewId],n),()=>{t.internalMsgEmitter.off([Z.Cursor,t.viewId],n)}),[t]);function n(a){o(a)}return g.useMemo(()=>{if(e!=null&&e.length){const a=e.map(c=>{var l;return c.roomMember?g.createElement(XM,{key:(l=c.roomMember)==null?void 0:l.memberId,className:s,info:c}):null});return g.createElement(g.Fragment,null,a)}return null},[e])},Mt=g.createContext({mananger:void 0,floatBarColors:[],floatBarData:void 0,dpr:1,angle:0,operationType:R.None,scale:[1,1],setAngle:()=>{},setOperationType:()=>{},setFloatBarData:()=>{}});class Ho extends g.Component{constructor(t){var e;super(t);M(this,"setAngle",t=>{this.setState({angle:t})});M(this,"setOperationType",t=>{this.setState({operationType:t})});this.state={floatBarData:void 0,showFloatBar:!1,dpr:1,angle:0,operationType:R.None,scale:[1,1],editors:this.editors,activeTextId:(e=this.props.mananger.control.textEditorManager)==null?void 0:e.activeId}}get editors(){return Vt(this.props.mananger.control.textEditorManager.filterEditor(this.props.mananger.viewId))}componentDidMount(){this.props.mananger.vDom=this,this.props.mananger.mountView(),this.setState({dpr:this.props.mananger.dpr})}componentWillUnmount(){}showFloatBar(t,e){const o=t&&e&&{...this.state.floatBarData,...e}||void 0;this.setState({showFloatBar:t,floatBarData:o,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,o,n,i,a,c,l;const t=!!((o=(e=this.props.mananger.control)==null?void 0:e.room)!=null&&o.floatBarOptions);return g.createElement("div",{className:Tt.Container},!this.props.mananger.control.hasOffscreenCanvas()&&g.createElement("div",{className:Tt.CanvasBox,ref:this.props.refs.canvasContainerRef})||g.createElement("div",{className:Tt.CanvasBox,onMouseDown:h=>{h.cancelable&&h.preventDefault(),h.stopPropagation()},onTouchStart:h=>{h.stopPropagation()},onMouseMove:h=>{this.props.mananger.cursorMouseMove(h)}},g.createElement("canvas",{id:"bgCanvas",ref:this.props.refs.canvasBgRef,style:{width:"100%",height:"100%"}}),g.createElement("canvas",{id:"serviceCanvas",className:Tt.FloatCanvas,ref:this.props.refs.canvasServiceFloatRef,style:{width:"100%",height:"100%"}}),g.createElement("canvas",{id:"localCanvas",className:Tt.FloatCanvas,ref:this.props.refs.canvasFloatRef,style:{width:"100%",height:"100%"}}),g.createElement("div",{id:"subLocalCanvas",className:Tt.CanvasBoxSub,ref:this.props.refs.subLocalCanvasContainerRef}),g.createElement("canvas",{id:"topCanvas",className:Tt.TopFloatCanvas,ref:this.props.refs.canvasTopRef,style:{width:"100%",height:"100%"}})),!this.props.mananger.control.hasOffscreenCanvas()&&this.props.refs.snapshotContainerRef&&g.createElement("div",{className:Tt.SnapshotBox,ref:this.props.refs.snapshotContainerRef})||null,g.createElement(Mt.Provider,{value:{mananger:this.props.mananger,floatBarColors:t&&((a=(i=(n=this.props.mananger.control)==null?void 0:n.room)==null?void 0:i.floatBarOptions)==null?void 0:a.colors)||[],floatBarData:this.state.floatBarData,dpr:this.state.dpr,angle:this.state.angle,operationType:this.state.operationType,scale:this.state.scale,setAngle:this.setAngle.bind(this),setOperationType:this.setOperationType.bind(this),setFloatBarData:this.setFloatBarData.bind(this)}},this.state.showFloatBar&&g.createElement(VM,{ref:this.props.refs.floatBarRef,editors:this.state.editors,activeTextId:this.state.activeTextId})||null,((c=this.state.editors)==null?void 0:c.size)&&g.createElement(EM,{className:Tt.TextEditorContainer,showFloatBtns:t,manager:this.props.mananger,selectIds:((l=this.state.floatBarData)==null?void 0:l.selectIds)||[],editors:this.state.editors,activeTextId:this.state.activeTextId})||null),g.createElement(KM,{className:Tt.CursorBox,manager:this.props.mananger}))}}class _M extends xi{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=Jt(),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=Jt(),this.width=t,this.height=e),t&&e&&this.canvasBgRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=Jt(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 o of e)o.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(),bo.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 ty extends Hg{constructor(t,e,o){super(t,e,o);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=Jt(),this.canvasContainerRef.current.style.width=`${t}px`,this.canvasContainerRef.current.style.height=`${e}px`)}if(this.canvasBgRef.current){this.dpr=Jt(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 o=document.createElement("div");return o.className="appliance-plugin-app-view-displayer",e.appendChild(o),this.eventTragetElement=e.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),bo.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}}),o),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement),this}}class Et extends ge{constructor(t){super(t);M(this,"focuedViewId");M(this,"focuedView");M(this,"control");M(this,"tmpFocusedViewId");M(this,"checkScaleTimer");M(this,"onMainViewRelease",async t=>{this.control.textEditorManager.clear(yt,!0),this.mainViewDestroy(t),await new Promise(o=>{setTimeout(()=>{o(!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 o=t.divElement;if(o){const n=o.getElementsByClassName("appliance-plugin-main-view-displayer");for(const i of n)i.remove()}if(this.mainView.container&&o!==this.mainView.container){const n=this.mainView.container.getElementsByClassName("appliance-plugin-main-view-displayer");for(const i of n)i.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 n=new _M(this.control,mt.InternalMsgEmitter),i=t.size.width||n.width,a=t.size.height||n.height,l={dpr:n.dpr,originalPoint:[i/2,a/2],offscreenCanvasOpt:{...Et.defaultScreenCanvasOpt,width:i,height:a},layerOpt:{...Et.defaultLayerOpt,width:i,height:a},cameraOpt:{...Et.defaultCameraOpt,width:i,height:a}},{scale:h,...u}=t.camera;l.cameraOpt={...l.cameraOpt,...u,scale:h===1/0?1:h},this.focuedViewId=yt,this.createMianView({id:yt,container:e,displayer:n,focusScenePath:t.focusScenePath,cameraOpt:l.cameraOpt,viewData:t}),this.focuedView=this.mainView,n.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 o=e.width,n=e.height,{width:i,height:a}=this.mainView.viewData.size;(i!==o||a!==n)&&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:i,height:a};O.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:o}=t,n=o.divElement;if(!n||!o.focusScenePath)return;const i=this.appViews.get(e);if(i&&i.displayer){let p=n.getElementsByClassName("appliance-plugin-app-view-displayer");for(const f of p)f.remove();if(i.container&&i.container!==n){p=i.container.getElementsByClassName("appliance-plugin-app-view-displayer");for(const f of p)f.remove()}this.destroyAppView(t.appId,!0),(d=this.control.worker)==null||d.destroyViewWorker(e,!0),await new Promise(f=>{setTimeout(()=>{f(!0)},0)})}const a=new ty(e,this.control,mt.InternalMsgEmitter),c=o.size.width||a.width,l=o.size.height||a.height,u={dpr:a.dpr,originalPoint:[c/2,l/2],offscreenCanvasOpt:{...Et.defaultScreenCanvasOpt,width:c,height:l},layerOpt:{...Et.defaultLayerOpt,width:c,height:l},cameraOpt:{...Et.defaultCameraOpt,...o.camera,width:c,height:l}};if(this.createAppView({id:e,container:n,displayer:a,cameraOpt:u.cameraOpt,focusScenePath:o.focusScenePath,viewData:o}),a.createAppViewDisplayer(e,n),o.callbacks.on("onSizeUpdated",this.onAppViewSizeUpdated.bind(this,e)),o.callbacks.on("onCameraUpdated",this.onAppViewCameraUpdated.bind(this,e)),o.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(o=>{setTimeout(()=>{o(!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 o=e.viewData.camera,n=e.cameraOpt;if(n){const{width:i,height:a}=e.viewData.size,c=n.width,l=n.height;(i!==c||a!==l)&&e.displayer.updateSize();const h=o.scale===1/0?1:o.scale,u=o.centerX||0,d=o.centerY||0,p={...n,scale:h,centerX:u,centerY:d,width:i,height:a};O.isEqual(p,n)||(e.cameraOpt=p)}}});this.control=t.control}getViewInitData(t){const e=this.getView(t);if(e){const{width:o,height:n,dpr:i}=e.displayer,a={dpr:i,originalPoint:[o/2,n/2],offscreenCanvasOpt:{...Et.defaultScreenCanvasOpt,width:o,height:n},layerOpt:{...Et.defaultLayerOpt,width:o,height:n},cameraOpt:{...Et.defaultCameraOpt,width:o,height:n}};if(e.viewData){const{scale:c,...l}=e.viewData.camera;a.cameraOpt={...a.cameraOpt,...l,scale:c===1/0?1:c}}return a}}async mountView(t){var o,n;const e=this.getView(t);if(e){t===((o=this.mainView)==null?void 0:o.id)&&(this.control.cursor.activeCollector(),await this.control.activeWorker());const i=this.getViewInitData(t);i&&((n=this.control.worker)==null||n.createViewWorker(t,i)),e.focusScenePath&&this.control.collector&&this.control.worker.pullServiceData(t,e.focusScenePath,{isAsync:!0,useAnimation:!1})}}listenerWindowManager(t){t.emitter.on("focusedChange",e=>{const o=e||yt;if(this.focuedViewId!==o)if(this.getView(o)){const i=this.control.worker.getLocalWorkViewId();i&&i!==o?this.setFocuedViewId(i):this.setFocuedViewId(o)}else this.tmpFocusedViewId=o}),t.emitter.on("mainViewScenePathChange",e=>{this.control.onSceneChange(e,yt)}),t.emitter.on("onMainViewMounted",this.onMainViewMounted),t.emitter.on("onAppViewMounted",this.onAppViewMounted),t.emitter.on("onMainViewRebind",this.onMainViewRelease),t.emitter.on("onBoxClose",e=>{this.appViews.get(e.appId)&&(this.destroyAppView(e.appId),this.control.worker.destroyViewWorker(e.appId))}),t.emitter.on("onAppScenePathChange",e=>{const{appId:o,view:n}=e;this.control.onSceneChange(n.focusScenePath,o)}),t.emitter.on("appsChange",e=>{for(const o of this.appViews.keys())e.includes(o)||(this.destroyAppView(o),this.control.worker.destroyViewWorker(o,!0))})}onActiveHotkeyChange(t){this.control.hotkeyManager.onActiveHotkey(t)}}class ce extends mt{constructor(t){super(t);M(this,"windowManager");M(this,"viewContainerManager");const e={control:this,internalMsgEmitter:mt.InternalMsgEmitter};this.viewContainerManager=new Et(e)}init(){}destroy(){var t,e,o,n;this.roomMember.destroy(),(t=this.collector)==null||t.destroy(),(e=this.worker)==null||e.destroy(),(o=this.viewContainerManager)==null||o.destroy(),(n=this.cursor)==null||n.destroy()}activePlugin(){this.collector&&(this.collector.addStorageStateListener(t=>{var a,c;if((a=this.collector)!=null&&a.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(yt,!0);return}const{diffView:e,diffScenePath:o,diffData:n}=t,i=new Map;if(e){let l;Object.keys(e).forEach(h=>{var d;const u=e[h];if(u&&!u.newValue)(d=this.worker)==null||d.clearViewScenePath(h,!0),u.oldValue&&(l=u.oldValue);else if(u&&u.newValue){for(const p of Object.keys(u.newValue))this.worker.pullServiceData(h,p,{isAsync:!1,useAnimation:!0});l=u.newValue}if(l)for(const p of Object.values(l)){const f=new Set;for(const I of Object.keys(p))I&&f.add(I);i.set(h,f)}})}if(o){let l;Object.keys(o).forEach(h=>{var d;const u=o[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),i.set(u.viewId,p)}})}n&&Object.keys(n).forEach(l=>{var u;const h=n[l];if(h){const{viewId:d}=h,p=i.get(d)||new Set;p.add(l),i.set(d,p),(u=this.worker)==null||u.onServiceDerive(l,h)}});for(const[l,h]of i.entries())mt.InternalMsgEmitter.emit("excludeIds",[...h],l)}),this.room&&this.roomMember.onUidChangeHook(t=>{var e,o;if((e=this.collector)!=null&&e.serviceStorage){const n=[];this.viewContainerManager.getAllViews().forEach(i=>{var a;if(i&&i.focusScenePath&&((a=this.collector)!=null&&a.serviceStorage[i.id])&&this.collector.serviceStorage[i.id][i.focusScenePath]){const c=Object.keys(this.collector.serviceStorage[i.id][i.focusScenePath]).filter(l=>{var h;return(h=this.collector)==null?void 0:h.isSelector(l)}).map(l=>({viewId:i.id,scenePath:i.focusScenePath,key:l}));c.length&&n.push(...c)}}),n.forEach(({key:i,viewId:a,scenePath:c})=>{var h,u;const l=(h=this.collector)==null?void 0:h.getUidFromKey(i);l&&!t.online.includes(l)&&((u=this.collector)==null||u.updateValue(i,void 0,{isAfterUpdate:!0,viewId:a,scenePath:c}))})}(o=this.cursor)==null||o.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,o,n,i,a;this.windowManager=t,(o=(e=this.windowManager)==null?void 0:e.mainView)!=null&&o.divElement&&this.viewContainerManager.onMainViewMounted(this.windowManager.mainView),(a=(i=(n=this.windowManager.appManager)==null?void 0:n.viewManager)==null?void 0:i.views)!=null&&a.size&&this.windowManager.appManager.viewManager.views.forEach((c,l)=>{this.viewContainerManager.onAppViewMounted({appId:l,view:c})}),this.viewContainerManager.listenerWindowManager(this.windowManager)}}const Q=class Q extends st.InvisiblePlugin{constructor(){super(...arguments);M(this,"onPhaseChanged",t=>{var e;t===st.RoomPhase.Reconnecting&&((e=Q.currentManager)==null||e.setSnapshootData())});M(this,"updateRoomWritable",()=>{var t;(t=Q.currentManager)==null||t.onWritableChange(this.displayer.isWritable)});M(this,"roomStateChangeListener",async t=>{var e,o;st.isRoom(this.displayer)&&!this.displayer.isWritable||(t.memberState&&((e=Q.currentManager)==null||e.onMemberChange(t.memberState)),t!=null&&t.roomMembers&&((o=Q.currentManager)==null||o.onRoomMembersChange(t.roomMembers)))})}static async getInstance(t,e){!e.options.cdn.fullWorkerUrl&&!e.options.cdn.subWorkerUrl&&Q.logger.error("[ApplianceMultiPlugin] you must adaptor options cdn fullWorkerUrl and subWorkerUrl");const o=t.displayer,n=o.callbacks.on,i=o.callbacks.off,a=o.callbacks.once,c=t.cleanCurrentScene,l=t.mainView.setMemberState;e!=null&&e.logger&&(Q.logger=e.logger),e.options&&(Q.options={...xt,...e.options});let h=o.getInvisiblePlugin(Q.kind);h||(h=await Q.createApplianceMultiPlugin(o,Q.kind)),o&&h&&Q.createCurrentManager(t,Q.options,h),h&&Q.currentManager&&(Q.currentManager.bindPlugin(h),h.init(o));const u={displayer:o,windowManager:t,currentManager:Q.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,getBoundingRectAsync:async function(p){var y;Q.logger.info("[ApplianceMultiPlugin] getBoundingRectAsync");const f=(t.mainView||o).getBoundingRect(p),I=await((y=Q.currentManager)==null?void 0:y.getBoundingRect(p));return!f.width||!f.height?I:Ni(f,I)},screenshotToCanvasAsync:async function(p,f,I,y,v,m){var L;Q.logger.info("[ApplianceMultiPlugin] screenshotToCanvasAsync");let w=I,S=y,N=v.scale;w>this.maxScreenshotWidth&&(N=this.maxScreenshotWidth/w*N,w=this.maxScreenshotWidth),S>this.maxScreenshotHeight&&(N=Math.min(this.maxScreenshotHeight/S*N,N),S=this.maxScreenshotHeight),v.scale=N;const T=document.createElement("canvas"),x=T.getContext("2d");T.width=w*(m||1),T.height=S*(m||1),x&&((t.mainView||o).screenshotToCanvas(x,f,w,S,v,m),p.drawImage(T,Math.floor((I-w)/2),Math.floor((y-S)/2),w*(m||1),S*(m||1),0,0,w,S),T.remove()),Q.currentManager&&await((L=Q.currentManager)==null?void 0:L.screenshotToCanvas(p,f,w,S,v,Math.floor((I-w)/2),Math.floor((y-S)/2)))},scenePreviewAsync:async function(p,f,I,y,v){Q.logger.info("[ApplianceMultiPlugin] scenePreviewAsync"),(t.mainView||o).scenePreview(p,f,I,y,v);const m=document.createElement("img");m.className="appliance-plugin-fill-scene-snapshot-img",f.append(m),getComputedStyle(f).position||(f.style.position="relative"),Q.currentManager&&await Q.currentManager.scenePreview(p,m)},fillSceneSnapshotAsync:async function(p,f,I,y,v){Q.logger.info("[ApplianceMultiPlugin] fillSceneSnapshotAsync"),f.innerHTML="",(t.mainView||o).fillSceneSnapshot(p,f,I,y,v);const m=I||t.mainView.size.width,w=y||t.mainView.size.height;let S=await this.getBoundingRectAsync(p);S||(S={originX:0,originY:0,width:m,height:w});let N=Math.max(S==null?void 0:S.width,m),T=Math.max(S==null?void 0:S.height,w),x=1;const L=N>m&&Math.min(m/N,x)||x,D=T>w&&Math.min(w/T,x)||x;L<=D?(N=L<1&&m||N,T=Math.floor(T*L)+1,x=L):L>D&&(T=D<1&&w||T,N=Math.floor(N*D)+1,x=D);const A={scale:x,centerX:S.originX+S.width/2,centerY:S.originY+S.height/2},P=document.createElement("canvas"),E=P.getContext("2d");P.width=N,P.height=T,E&&await this.screenshotToCanvasAsync(E,p,N,T,A,devicePixelRatio);const j=document.createElement("img");j.className="appliance-plugin-fill-scene-snapshot-img",j.src=P.toDataURL(),j.onload=()=>{P.remove()},j.onerror=()=>{P.remove(),j.remove()},f.append(j),getComputedStyle(f).position||(f.style.position="relative")},_callbacksOn:function(p,f){Q.logger.info(`[ApplianceMultiPlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&st.isRoom(o)&&o.isWritable?ce.InternalMsgEmitter.on(p,f):n.call(o.callbacks,p,f)},_callbacksOnce:function(p,f){Q.logger.info(`[ApplianceMultiPlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&st.isRoom(o)&&o.isWritable?ce.InternalMsgEmitter.on(p,f):a.call(o.callbacks,p,f)},_callbacksOff:function(p,f){Q.logger.info(`[ApplianceMultiPlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&st.isRoom(o)&&o.isWritable?ce.InternalMsgEmitter.off(p,f):i.call(o.callbacks,p,f)},canRedoSteps(){if(Q.logger.info("[ApplianceMultiPlugin] canRedoSteps"),Q.currentManager&&st.isRoom(o)&&!o.disableSerialization){const p=Q.currentManager.viewContainerManager.focuedView,f=p==null?void 0:p.focusScenePath;if(p&&f)return p.displayer.commiter.redoStack.filter(I=>I.scenePath===f).length}return 0},canUndoSteps(){if(Q.logger.info("[ApplianceMultiPlugin] canUndoSteps"),Q.currentManager&&st.isRoom(o)&&!o.disableSerialization){const p=Q.currentManager.viewContainerManager.focuedView,f=p==null?void 0:p.focusScenePath;if(p&&f)return p.displayer.commiter.undoStack.filter(I=>I.scenePath===f).length}return 0},undo:function(){return Q.logger.info("[ApplianceMultiPlugin] undo"),Q.currentManager&&st.isRoom(o)&&!o.disableSerialization?Q.currentManager.viewContainerManager.undo():0},redo:function(){return Q.logger.info("[ApplianceMultiPlugin] redo"),Q.currentManager&&st.isRoom(o)&&!o.disableSerialization?Q.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(){Q.logger.info("[ApplianceMultiPlugin] cleanCurrentScene"),Q.currentManager&&st.isRoom(o)&&o.isWritable&&(Q.currentManager.cleanCurrentScene(),c.call(t))},insertImage:function(p){Q.logger.info("[ApplianceMultiPlugin] insertImage"),Q.currentManager&&st.isRoom(o)&&o.isWritable&&Q.currentManager.worker.insertImage(p)},lockImage:function(p,f){Q.logger.info("[ApplianceMultiPlugin] lockImage"),Q.currentManager&&st.isRoom(o)&&o.isWritable&&Q.currentManager.worker.lockImage(p,f)},completeImageUpload:function(p,f){Q.logger.info("[ApplianceMultiPlugin] completeImageUpload"),Q.currentManager&&st.isRoom(o)&&o.isWritable&&Q.currentManager.worker.completeImageUpload(p,f)},getImagesInformation:function(p){return Q.logger.info("[ApplianceMultiPlugin] completeImageUpload"),Q.currentManager&&st.isRoom(o)&&o.isWritable?Q.currentManager.worker.getImagesInformation(p):[]},callbacks:()=>(Q.logger.info("[ApplianceMultiPlugin] callbacks bind"),{...o.callbacks,on:u._callbacksOn.bind(u),once:u._callbacksOnce.bind(u),off:u._callbacksOff.bind(u)}),destroy(){Q.currentManager&&(Q.logger.info("[ApplianceMultiPlugin] destroy"),Q.currentManager.destroy(),Q.currentManager=void 0)},setMemberState(p){Q.logger.info("[ApplianceMultiPlugin] setMemberState");const f=Object.keys(p);if(st.isRoom(o)&&o.isWritable){f.includes("currentApplianceName")&&(p.currentApplianceName&&p.currentApplianceName===et.laserPen?(p.currentApplianceName=et.pencil,p.useLaserPen=!0):p.currentApplianceName&&p.currentApplianceName===et.pencil&&(p.useLaserPen=!1)),l.call(t.mainView,p);return}throw new Error("setMemberState must be called in writable room")},setPerformancePriority(p){Q.logger.info("[ApplianceMultiPlugin] setPriority"),Q.currentManager&&Q.currentManager.setPriority(p)}},d=(p,f)=>{if(Q.logger.info(`[ApplianceMultiPlugin] injectMethodToObject ${f}`),typeof p[f]=="function"||typeof p[f]>"u"){p[f]=u[f];return}f==="callbacks"&&(p.callbacks.on=u._callbacksOn.bind(u),p.callbacks.off=u._callbacksOff.bind(u),p.callbacks.once=u._callbacksOnce.bind(u))};return d(t,"undo"),d(t,"redo"),d(t,"cleanCurrentScene"),d(t,"insertImage"),d(t,"completeImageUpload"),d(t,"lockImage"),d(o,"getImagesInformation"),d(o,"callbacks"),d(o,"screenshotToCanvasAsync"),d(o,"getBoundingRectAsync"),d(o,"scenePreviewAsync"),d(o,"fillSceneSnapshotAsync"),d(t.mainView,"setMemberState"),Object.defineProperty(t,"canUndoSteps",{get(){return u.canUndoSteps()}}),Object.defineProperty(t,"canRedoSteps",{get(){return u.canRedoSteps()}}),ce.InternalMsgEmitter.on("onCanUndoStepsUpdate",p=>{t.emitter.emit("canUndoStepsChange",p)}),ce.InternalMsgEmitter.on("onCanRedoStepsUpdate",p=>{t.emitter.emit("canRedoStepsChange",p)}),{...u,callbacks:u.callbacks()}}static onCreate(t){t&&Q.currentManager&&(Q.currentManager.bindPlugin(t),t.init(t.displayer))}static async createApplianceMultiPlugin(t,e){await t.createInvisiblePlugin(Q,{});let o=t.getInvisiblePlugin(e);return o||(o=await Q.createApplianceMultiPlugin(t,e)),o}get isReplay(){return st.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(t){var o,n;const e=t.state;(o=Q.currentManager)==null||o.onRoomMembersChange(e.roomMembers),st.isRoom(t)&&((n=Q.currentManager)==null||n.onMemberChange(e.memberState)),this.displayer.callbacks.on(this.callbackName,this.roomStateChangeListener),this.displayer.callbacks.on("onEnableWriteNowChanged",this.updateRoomWritable),this.displayer.callbacks.on("onPhaseChanged",this.onPhaseChanged)}destroy(){var t;Q.logger.info("[ApplianceMultiPlugin] passive destroy"),(t=Q.currentManager)==null||t.destroy(),Q.currentManager=void 0}};M(Q,"kind","appliance-multi-plugin"),M(Q,"currentManager"),M(Q,"logger",{info:console.log,warn:console.warn,error:console.error}),M(Q,"options",xt),M(Q,"createCurrentManager",(t,e,o)=>{Q.currentManager&&Q.currentManager.destroy();const n={plugin:o,displayer:t.displayer,options:e},i=new ce(n);Q.logger.info("[ApplianceMultiPlugin] refresh ApplianceMultiManager object"),i.setWindowManager(t),Q.currentManager=i});let ko=Q;class ey extends xi{constructor(t,e){super(t,e);M(this,"width",1e3);M(this,"height",1e3);M(this,"dpr",1);M(this,"vDom");M(this,"viewId",yt);M(this,"eventTragetElement");M(this,"snapshotContainerRef");M(this,"canvasContainerRef",g.createRef());M(this,"subLocalCanvasContainerRef",g.createRef());M(this,"canvasTopRef",g.createRef());M(this,"canvasServiceFloatRef",g.createRef());M(this,"canvasFloatRef",g.createRef());M(this,"canvasBgRef",g.createRef());M(this,"floatBarRef",g.createRef());M(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas()||(this.snapshotContainerRef=g.createRef())}setCanvassStyle(){if(this.eventTragetElement){const t=this.eventTragetElement.offsetWidth,e=this.eventTragetElement.offsetHeight;t&&e&&this.canvasContainerRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=Jt()),t&&e&&this.canvasContainerRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=Jt(),this.width=t,this.height=e),t&&e&&this.canvasBgRef.current&&(t!==this.width||e!==this.height)&&(this.dpr=Jt(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="",bo.render(g.createElement(Ho,{viewId:this.viewId,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,snapshotContainerRef:this.snapshotContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef}}),t),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement)),this}}class $t extends ge{constructor(t){super(t);M(this,"focuedViewId");M(this,"control");M(this,"focuedView");this.control=t.control}bindMainView(){if(!this.control.divMainView)return;const t=new ey(this.control,mt.InternalMsgEmitter);this.focuedViewId=yt;const{width:e,height:o,dpr:n}=t,i={dpr:n,originalPoint:[e/2,o/2],offscreenCanvasOpt:{...$t.defaultScreenCanvasOpt,width:e,height:o},layerOpt:{...$t.defaultLayerOpt,width:e,height:o},cameraOpt:{...$t.defaultCameraOpt,width:e,height:o}},a=this.control.room&&this.control.room.mainView||this.control.play&&this.control.play.mainView;if(a){const{scale:c,...l}=a.camera;i.cameraOpt={...i.cameraOpt,...l,scale:c===1/0?1:c},this.createMianView({id:yt,displayer:t,focusScenePath:a.focusScenePath||a.scenePath,cameraOpt:i.cameraOpt,viewData:a}),this.focuedView=this.mainView,t.createMainViewDisplayer(this.control.divMainView)}}getViewInitData(t){const e=this.getView(t);if(e){const{width:o,height:n,dpr:i}=e.displayer,a={dpr:i,originalPoint:[o/2,n/2],offscreenCanvasOpt:{...$t.defaultScreenCanvasOpt,width:o,height:n},layerOpt:{...$t.defaultLayerOpt,width:o,height:n},cameraOpt:{...$t.defaultCameraOpt,width:o,height:n}};if(e.viewData){const{scale:c,...l}=e.viewData.camera;a.cameraOpt={...a.cameraOpt,...l,scale:c===1/0?1:c}}return a}}async mountView(t){var o;const e=this.getView(t);if(e){this.control.worker.isActive||(this.control.cursor.activeCollector(),await this.control.activeWorker());const n=this.getViewInitData(t);n&&((o=this.control.worker)==null||o.createViewWorker(t,n)),e.focusScenePath&&this.control.collector&&this.control.worker.pullServiceData(t,e.focusScenePath,{isAsync:!0,useAnimation:!1})}}}class Ht extends mt{constructor(t){super(t);M(this,"viewContainerManager");M(this,"divMainView");M(this,"onCameraChange",Pe(t=>{var o;const e=this.viewContainerManager.mainView;e&&e.cameraOpt&&(e.cameraOpt.width!==t.width||e.cameraOpt.height!==t.height)&&((o=this.viewContainerManager.mainView)==null||o.displayer.updateSize()),this.viewContainerManager.setFocuedViewCameraOpt(t)},20,{leading:!1}));const e={control:this,internalMsgEmitter:Ht.InternalMsgEmitter};this.viewContainerManager=new $t(e)}init(){Ht.InternalMsgEmitter.on(Z.BindMainView,t=>{this.divMainView=t,this.plugin&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView()})}activePlugin(){this.plugin&&this.divMainView&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView(),this.collector&&(this.collector.addStorageStateListener(t=>{var a,c;if((a=this.collector)!=null&&a.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(yt,!0);return}const{diffView:e,diffScenePath:o,diffData:n}=t,i=new Map;if(e){let l;Object.keys(e).forEach(h=>{var d;const u=e[h];if(u&&!u.newValue)(d=this.worker)==null||d.clearViewScenePath(h,!0),u.oldValue&&(l=u.oldValue);else if(u&&u.newValue){for(const p of Object.keys(u.newValue))this.worker.pullServiceData(h,p,{isAsync:!1,useAnimation:!0});l=u.newValue}if(l)for(const p of Object.values(l)){const f=new Set;for(const I of Object.keys(p))I&&f.add(I);i.set(h,f)}})}if(o){let l;Object.keys(o).forEach(h=>{var d;const u=o[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),i.set(u.viewId,p)}})}n&&Object.keys(n).forEach(l=>{var u;const h=n[l];if(h){const{viewId:d}=h,p=i.get(d)||new Set;p.add(l),i.set(d,p),(u=this.worker)==null||u.onServiceDerive(l,h)}});for(const[l,h]of i.entries())mt.InternalMsgEmitter.emit("excludeIds",[...h],l)}),this.room&&(this.roomMember.onUidChangeHook(t=>{var e,o,n,i;if((e=this.collector)!=null&&e.serviceStorage){const a=[];this.viewContainerManager.getAllViews().forEach(c=>{var l,h,u;if(c&&c.focusScenePath&&((l=this.collector)!=null&&l.serviceStorage[c.id])&&((h=this.collector)!=null&&h.serviceStorage[c.id][c.focusScenePath])){const d=Object.keys((u=this.collector)==null?void 0:u.serviceStorage[c.id][c.focusScenePath]).filter(p=>{var f;return(f=this.collector)==null?void 0:f.isSelector(p)}).map(p=>({viewId:c.id,scenePath:c.focusScenePath,key:p}));d.length&&a.push(...d)}}),a.forEach(({key:c,viewId:l,scenePath:h})=>{var d,p;const u=(d=this.collector)==null?void 0:d.getUidFromKey(c);u&&!t.online.includes(u)&&((p=this.collector)==null||p.updateValue(c,void 0,{isAfterUpdate:!0,viewId:l,scenePath:h}))})}(n=(o=this.cursor)==null?void 0:o.eventCollector)!=null&&n.serviceStorage&&Object.keys((i=this.cursor)==null?void 0:i.eventCollector.serviceStorage).forEach(c=>{var l,h;t.online.includes(c)||(h=(l=this.cursor)==null?void 0:l.eventCollector)==null||h.clearValue(c)})}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(t=>{t&&t.focusScenePath&&this.worker.pullServiceData(t.id,t.focusScenePath,{isAsync:!0,useAnimation:!1})})))}async activeWorker(){await this.worker.init()}}const U=class U extends st.InvisiblePlugin{constructor(){super(...arguments);M(this,"onPhaseChanged",t=>{var e;t===st.RoomPhase.Reconnecting&&((e=U.currentManager)==null||e.setSnapshootData())});M(this,"updateRoomWritable",()=>{var t;(t=U.currentManager)==null||t.onWritableChange(this.displayer.isWritable)});M(this,"roomStateChangeListener",async t=>{var e,o;U.currentManager instanceof Ht&&(t.cameraState&&U.currentManager.onCameraChange(t.cameraState),t.sceneState&&U.currentManager.onSceneChange(t.sceneState.scenePath,yt)),!(st.isRoom(this.displayer)&&!this.displayer.isWritable)&&(t.memberState&&((e=U.currentManager)==null||e.onMemberChange(t.memberState)),t!=null&&t.roomMembers&&((o=U.currentManager)==null||o.onRoomMembersChange(t.roomMembers)))})}static async getInstance(t,e){const o=t.callbacks.on,n=t.callbacks.off,i=t.callbacks.once,a=t.cleanCurrentScene.bind(t),c=t.setMemberState.bind(t);e!=null&&e.logger&&(U.logger=e.logger),e.options&&(U.options={...xt,...e.options});let l=t.getInvisiblePlugin(U.kind);l||(l=await U.createAppliancePlugin(t,U.kind)),t&&l&&U.createCurrentManager(t,U.options,l),l&&U.currentManager&&(U.currentManager.bindPlugin(l),l.init(t)),e!=null&&e.cursorAdapter&&(U.cursorAdapter=e.cursorAdapter),U.effectInstance();const h={displayer:t,currentManager:U.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,_injectTargetObject:void 0,getBoundingRectAsync:async function(d){var I;U.logger.info("[ApplianceSinglePlugin] getBoundingRectAsync");const p=t.getBoundingRect(d),f=await((I=U.currentManager)==null?void 0:I.getBoundingRect(d));return!p.width||!p.height?f:Ni(p,f)},screenshotToCanvasAsync:async function(d,p,f,I,y,v){var x;U.logger.info("[ApplianceSinglePlugin] screenshotToCanvasAsync");let m=f,w=I,S=y.scale;m>this.maxScreenshotWidth&&(S=this.maxScreenshotWidth/m*S,m=this.maxScreenshotWidth),w>this.maxScreenshotHeight&&(S=Math.min(this.maxScreenshotHeight/w*S,S),w=this.maxScreenshotHeight),y.scale=S;const N=document.createElement("canvas"),T=N.getContext("2d");N.width=m*(v||1),N.height=w*(v||1),T&&(t.screenshotToCanvas(T,p,m,w,y,v),d.drawImage(N,Math.floor((f-m)/2),Math.floor((I-w)/2),m*(v||1),w*(v||1),0,0,m,w),N.remove()),U.currentManager&&await((x=U.currentManager)==null?void 0:x.screenshotToCanvas(d,p,m,w,y,Math.floor((f-m)/2),Math.floor((I-w)/2)))},scenePreviewAsync:async function(d,p,f,I,y){U.logger.info("[ApplianceSinglePlugin] scenePreviewAsync"),t.scenePreview(d,p,f,I,y);const v=document.createElement("img");v.className="appliance-plugin-fill-scene-snapshot-img",p.append(v),getComputedStyle(p).position||(p.style.position="relative"),U.currentManager&&await U.currentManager.scenePreview(d,v)},fillSceneSnapshotAsync:async function(d,p,f,I,y){var j,_;U.logger.info("[ApplianceSinglePlugin] fillSceneSnapshotAsync"),p.innerHTML="",t.fillSceneSnapshot(d,p,f,I,y);const v=f||((j=t.state.cameraState)==null?void 0:j.width)||0,m=I||((_=t.state.cameraState)==null?void 0:_.height)||0;let w=await this.getBoundingRectAsync(d);w||(w={originX:0,originY:0,width:v,height:m});let S=Math.max(w==null?void 0:w.width,v),N=Math.max(w==null?void 0:w.height,m),T=1;const x=S>v&&Math.min(v/S,T)||T,L=N>m&&Math.min(m/N,T)||T;x<=L?(S=x<1&&v||S,N=Math.floor(N*x)+1,T=x):x>L&&(N=L<1&&m||N,S=Math.floor(S*L)+1,T=L);const D={scale:T,centerX:w.originX+w.width/2,centerY:w.originY+w.height/2},A=document.createElement("canvas"),P=A.getContext("2d");A.width=S,A.height=N,P&&await this.screenshotToCanvasAsync(P,d,S,N,D,devicePixelRatio);const E=document.createElement("img");E.className="appliance-plugin-fill-scene-snapshot-img",E.src=A.toDataURL(),E.onload=()=>{A.remove()},E.onerror=()=>{A.remove(),E.remove()},p.append(E),getComputedStyle(p).position||(p.style.position="relative")},_callbacksOn:function(d,p){U.logger.info(`[ApplianceSinglePlugin] callbacks ${d}`),(d==="onCanUndoStepsUpdate"||d==="onCanRedoStepsUpdate")&&st.isRoom(t)&&t.isWritable?Ht.InternalMsgEmitter.on(d,p):o.call(t.callbacks,d,p)},_callbacksOnce:function(d,p){U.logger.info(`[ApplianceSinglePlugin] callbacks ${d}`),(d==="onCanUndoStepsUpdate"||d==="onCanRedoStepsUpdate")&&st.isRoom(t)&&t.isWritable?Ht.InternalMsgEmitter.on(d,p):i.call(t.callbacks,d,p)},_callbacksOff:function(d,p){U.logger.info(`[ApplianceSinglePlugin] callbacks ${d}`),(d==="onCanUndoStepsUpdate"||d==="onCanRedoStepsUpdate")&&st.isRoom(t)&&t.isWritable?Ht.InternalMsgEmitter.off(d,p):n.call(t.callbacks,d,p)},canRedoSteps(){if(U.logger.info("[ApplianceSinglePlugin] canRedoSteps"),U.currentManager&&st.isRoom(t)&&!t.disableSerialization){const d=U.currentManager.viewContainerManager.focuedView,p=d==null?void 0:d.focusScenePath;if(d&&p)return d.displayer.commiter.redoStack.filter(f=>f.scenePath===p).length}return 0},canUndoSteps(){if(U.logger.info("[ApplianceSinglePlugin] canUndoSteps"),U.currentManager&&st.isRoom(t)&&!t.disableSerialization){const d=U.currentManager.viewContainerManager.focuedView,p=d==null?void 0:d.focusScenePath;if(d&&p)return d.displayer.commiter.undoStack.filter(f=>f.scenePath===p).length}return 0},undo:function(){return U.logger.info("[ApplianceSinglePlugin] undo"),U.currentManager&&st.isRoom(t)&&!t.disableSerialization?U.currentManager.viewContainerManager.undo():0},redo:function(){return U.logger.info("[ApplianceSinglePlugin] redo"),U.currentManager&&st.isRoom(t)&&!t.disableSerialization?U.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(d){U.logger.info("[ApplianceSinglePlugin] cleanCurrentScene"),U.currentManager&&st.isRoom(t)&&t.isWritable&&(U.currentManager.cleanCurrentScene(),a.call(t,d))},insertImage:function(d){U.logger.info("[ApplianceSinglePlugin] insertImage"),U.currentManager&&st.isRoom(t)&&t.isWritable&&U.currentManager.worker.insertImage(d)},lockImage:function(d,p){U.logger.info("[ApplianceSinglePlugin] lockImage"),U.currentManager&&st.isRoom(t)&&t.isWritable&&U.currentManager.worker.lockImage(d,p)},completeImageUpload:function(d,p){U.logger.info("[ApplianceSinglePlugin] completeImageUpload"),U.currentManager&&st.isRoom(t)&&t.isWritable&&U.currentManager.worker.completeImageUpload(d,p)},getImagesInformation:function(d){return U.logger.info("[ApplianceSinglePlugin] completeImageUpload"),U.currentManager&&st.isRoom(t)&&t.isWritable?U.currentManager.worker.getImagesInformation(d):[]},callbacks:()=>({...t.callbacks,on:h._callbacksOn.bind(h),once:h._callbacksOnce.bind(h),off:h._callbacksOff.bind(h)}),destroy(){U.currentManager&&(U.logger.info("[ApplianceSinglePlugin] destroy"),U.currentManager.destroy(),U.currentManager=void 0,U.cursorAdapter=void 0)},setMemberState(d){U.logger.info("[ApplianceSinglePlugin] setMemberState");const p=Object.keys(d);if(st.isRoom(t)&&t.isWritable){p.includes("currentApplianceName")&&(d.currentApplianceName&&d.currentApplianceName===et.laserPen?(d.currentApplianceName=et.pencil,d.useLaserPen=!0):d.currentApplianceName&&d.currentApplianceName===et.pencil&&(d.useLaserPen=!1)),c(d);return}throw new Error("setMemberState must be called in writable room")},setPerformancePriority(d){U.logger.info("[ApplianceSinglePlugin] setPriority"),U.currentManager&&U.currentManager.setPriority(d)}},u=(d,p)=>{if(U.logger.info(`[ApplianceSinglePlugin] injectMethodToObject ${p}`),typeof d[p]=="function"||typeof d[p]>"u"){d[p]=h[p];return}p==="callbacks"&&(d.callbacks.on=h._callbacksOn.bind(h),d.callbacks.off=h._callbacksOff.bind(h),d.callbacks.once=h._callbacksOnce.bind(h))};return u(t,"undo"),u(t,"redo"),u(t,"cleanCurrentScene"),u(t,"insertImage"),u(t,"completeImageUpload"),u(t,"lockImage"),u(t,"getImagesInformation"),u(t,"callbacks"),u(t,"screenshotToCanvasAsync"),u(t,"getBoundingRectAsync"),u(t,"scenePreviewAsync"),u(t,"fillSceneSnapshotAsync"),u(t,"setMemberState"),Object.defineProperty(t,"canUndoSteps",{get(){return h.canUndoSteps()}}),Object.defineProperty(t,"canRedoSteps",{get(){return h.canRedoSteps()}}),{...h,callbacks:h.callbacks()}}static onCreate(t){t&&U.currentManager&&(U.currentManager.bindPlugin(t),t.init(t.displayer))}static async createAppliancePlugin(t,e){await t.createInvisiblePlugin(U,{});let o=t.getInvisiblePlugin(e);return o||(o=await U.createAppliancePlugin(t,e)),o}static effectInstance(){if(U.cursorAdapter){const t=U.cursorAdapter.onAddedCursor;U.cursorAdapter.onAddedCursor=function(e){e.onCursorMemberChanged=o=>{try{o.appliance===et.pencil||o.appliance===et.shape||o.appliance===et.text||o.appliance===et.arrow||o.appliance===et.straight||o.appliance===et.rectangle||o.appliance===et.ellipse||o.appliance===et.eraser?e!=null&&e.divElement&&(e.divElement.style.display="none"):e!=null&&e.divElement&&(e.divElement.style.display="block")}catch{}},t.call(U.cursorAdapter,e)}}}get isReplay(){return st.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(t){var o,n;const e=t.state;(o=U.currentManager)==null||o.onRoomMembersChange(e.roomMembers),st.isRoom(t)&&e!=null&&e.memberState&&((n=U.currentManager)==null||n.onMemberChange(e.memberState)),this.displayer.callbacks.on(this.callbackName,this.roomStateChangeListener),this.displayer.callbacks.on("onEnableWriteNowChanged",this.updateRoomWritable),this.displayer.callbacks.on("onPhaseChanged",this.onPhaseChanged)}destroy(){var t;U.logger.info("[ApplianceSinglePlugin] passive destroy"),(t=U.currentManager)==null||t.destroy(),U.currentManager=void 0,U.cursorAdapter=void 0}};M(U,"kind","appliance-aids-single-plugin"),M(U,"cursorAdapter"),M(U,"currentManager"),M(U,"logger",{info:console.log,warn:console.warn,error:console.error}),M(U,"options",xt),M(U,"createCurrentManager",(t,e,o)=>{U.currentManager&&U.currentManager.destroy();const n={plugin:o,displayer:t,options:e},i=new Ht(n);i.init(),U.logger.info("[ApplianceSinglePlugin] refresh ApplianceSingleManager object"),U.currentManager=i});let xo=U;const pe=class pe extends g.Component{constructor(){super(...arguments);M(this,"mainViewRef",null)}componentDidMount(){pe.emiter||(pe.emiter=Ht.InternalMsgEmitter),pe.emiter.emit(Z.BindMainView,this.mainViewRef)}render(){return g.createElement(g.Fragment,null,this.props.children,g.createElement("div",{className:"appliance-plugin-main-view-displayer",ref:t=>this.mainViewRef=t}))}};M(pe,"emiter");let zo=pe;exports.ActiveContainerType=Ds;exports.ApplianceMultiPlugin=ko;exports.ApplianceNames=et;exports.ApplianceSigleWrapper=zo;exports.ApplianceSinglePlugin=xo;exports.Cursor_Hover_Id=Wf;exports.DefaultAppliancePluginOptions=xt;exports.ECanvasContextType=_e;exports.ECanvasShowType=Yt;exports.EDataType=F;exports.EMatrixrRelationType=ke;exports.EPostMessageType=z;exports.EScaleType=ct;exports.EStrokeType=X;exports.EToolsKey=C;exports.ElayerType=oe;exports.EmitEventType=R;exports.EventMessageType=Ce;exports.EvevtWorkState=b;exports.EvevtWorkType=Es;exports.InternalMsgEmitterType=Z;exports.Main_View_Id=yt;exports.ShapeType=Dt;exports.Storage_Selector_key=H;exports.Storage_Splitter=Ot;exports.Storage_ViewId_ALL=Ue;exports.Task_Time_Interval=Uf;exports.ViewContainerManager=ge;exports.checkOp=jf;exports.cloneDeep=Vt;exports.computRect=ut;exports.fullWorker=Ei;exports.getRectMatrixrRelation=Af;exports.getShapeInstance=Ii;exports.getShapeTools=wi;exports.isBoolean=he;exports.isEqual=le;exports.isIntersect=be;exports.isIntersectForPoint=Si;exports.isNumber=Wt;exports.isRenderNode=Ef;exports.subWorker=Ai;exports.throttle=Pe;exports.transformToNormalData=Ne;exports.transformToSerializableData=zt;
|