@netless/appliance-plugin 1.1.13 → 1.1.14-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/cdn.js +1 -1
- package/cdn/{fullWorker-gIfxem.js → fullWorker-BPEN62.js} +93 -87
- package/cdn/{subWorker-BA8EkW.js → subWorker-BGZBNP.js} +93 -87
- package/dist/appliance-plugin.js +1 -1
- package/dist/appliance-plugin.mjs +1 -1
- package/dist/core/mainEngine.d.ts +3 -4
- package/dist/core/mainThread/subLocalThread.d.ts +2 -3
- package/dist/core/mainThread/subServiceThread.d.ts +1 -1
- package/dist/core/mainThread/workerMainThread.d.ts +1 -1
- package/dist/core/tools/base.d.ts +10 -2
- package/dist/core/tools/image.d.ts +3 -3
- package/dist/core/tools/pencil.d.ts +1 -1
- package/dist/core/tools/pencilEraserBitMap.d.ts +20 -10
- package/dist/core/tools/selector.d.ts +2 -2
- package/dist/core/types.d.ts +2 -3
- package/dist/core/worker/base.d.ts +1 -0
- package/dist/core/worker/fullWorkerLocal.d.ts +6 -3
- package/dist/fullWorker.js +93 -87
- package/dist/{index-BbDR836g.mjs → index-20s2n69K.mjs} +356 -358
- package/dist/index-BEY3BEPC.js +1 -0
- package/dist/{index-0fBM84zK.mjs → index-DFl78uPi.mjs} +6006 -6102
- package/dist/index-Dob0H3xr.js +1 -0
- package/dist/plugin/baseApplianceManager.d.ts +1 -0
- package/dist/plugin/baseViewContainerManager.d.ts +2 -0
- package/dist/plugin/types.d.ts +2 -0
- package/dist/subWorker.js +93 -87
- package/package.json +2 -3
- package/dist/index-BwLQzsnp.js +0 -1
- package/dist/index-Wi09G9p1.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var sn=Object.defineProperty;var on=(a,s,e)=>s in a?sn(a,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[s]=e;var y=(a,s,e)=>on(a,typeof s!="symbol"?s+"":s,e);const q=require("white-web-sdk"),le=require("spritejs"),Xi=require("lz-string"),Ws=require("lineclip"),ks=require("eventemitter2"),D=require("lodash"),M=require("react"),ns=require("react-dom"),Nt=require("react-draggable"),nn=require("re-resizable"),rn="/fullWorker.js",an="/subWorker.js";var ne=(a=>(a.selector="selector",a.clicker="clicker",a.laserPointer="laserPointer",a.pencil="pencil",a.rectangle="rectangle",a.ellipse="ellipse",a.shape="shape",a.eraser="eraser",a.pencilEraser="pencilEraser",a.text="text",a.straight="straight",a.arrow="arrow",a.hand="hand",a.laserPen="laserPen",a))(ne||{}),ee=(a=>(a.Normal="Normal",a.Stroke="Stroke",a.Dotted="Dotted",a.LongDotted="LongDotted",a))(ee||{}),Ve=(a=>(a.Triangle="triangle",a.Rhombus="rhombus",a.Pentagram="pentagram",a.SpeechBalloon="speechBalloon",a.Star="star",a.Polygon="polygon",a))(Ve||{}),F=(a=>(a.None="None",a.ShowFloatBar="ShowFloatBar",a.ZIndexFloatBar="ZIndexFloatBar",a.DeleteNode="DeleteNode",a.CopyNode="CopyNode",a.ZIndexActive="ZIndexActive",a.ZIndexNode="ZIndexNode",a.RotateNode="RotateNode",a.SetColorNode="SetColorNode",a.TranslateNode="TranslateNode",a.ScaleNode="ScaleNode",a.OriginalEvent="OriginalEvent",a.CreateScene="CreateScene",a.ActiveCursor="ActiveCursor",a.MoveCursor="MoveCursor",a.CommandEditor="CommandEditor",a.SetEditorData="SetEditorData",a.SetFontStyle="SetFontStyle",a.SetPoint="SetPoint",a.SetLock="SetLock",a.SetShapeOpt="SetShapeOpt",a.CameraChange="CameraChange",a.ActiveMethod="ActiveMethod",a))(F||{}),te=(a=>(a.DisplayState="DisplayState",a.MainEngine="MainEngine",a.Cursor="Cursor",a.BindMainView="BindMainView",a))(te||{}),Ji=(a=>(a[a.MainView=0]="MainView",a[a.Plugin=1]="Plugin",a[a.Both=2]="Both",a))(Ji||{}),I=(a=>(a[a.Pencil=1]="Pencil",a[a.Eraser=2]="Eraser",a[a.PencilEraser=3]="PencilEraser",a[a.BitMapEraser=4]="BitMapEraser",a[a.Selector=5]="Selector",a[a.Clicker=6]="Clicker",a[a.Arrow=7]="Arrow",a[a.Hand=8]="Hand",a[a.LaserPen=9]="LaserPen",a[a.Text=10]="Text",a[a.Straight=11]="Straight",a[a.Rectangle=12]="Rectangle",a[a.Ellipse=13]="Ellipse",a[a.Star=14]="Star",a[a.Triangle=15]="Triangle",a[a.Rhombus=16]="Rhombus",a[a.Polygon=17]="Polygon",a[a.SpeechBalloon=18]="SpeechBalloon",a[a.Image=19]="Image",a))(I||{}),B=(a=>(a[a.Local=1]="Local",a[a.Service=2]="Service",a[a.Worker=3]="Worker",a))(B||{}),P=(a=>(a[a.Pending=0]="Pending",a[a.Start=1]="Start",a[a.Doing=2]="Doing",a[a.Done=3]="Done",a[a.Unwritable=4]="Unwritable",a))(P||{}),x=(a=>(a[a.None=0]="None",a[a.Init=1]="Init",a[a.UpdateCamera=2]="UpdateCamera",a[a.UpdateTools=3]="UpdateTools",a[a.CreateWork=4]="CreateWork",a[a.DrawWork=5]="DrawWork",a[a.FullWork=6]="FullWork",a[a.UpdateNode=7]="UpdateNode",a[a.RemoveNode=8]="RemoveNode",a[a.Clear=9]="Clear",a[a.Select=10]="Select",a[a.Destroy=11]="Destroy",a[a.Snapshot=12]="Snapshot",a[a.BoundingBox=13]="BoundingBox",a[a.Cursor=14]="Cursor",a[a.TextUpdate=15]="TextUpdate",a[a.GetTextActive=16]="GetTextActive",a[a.TasksQueue=17]="TasksQueue",a[a.CursorHover=18]="CursorHover",a[a.CursorBlur=19]="CursorBlur",a[a.Console=20]="Console",a[a.PriorityWorker=21]="PriorityWorker",a[a.PriorityMainThreadWorker=22]="PriorityMainThreadWorker",a[a.GetImageBitMap=23]="GetImageBitMap",a[a.AuthWriter=24]="AuthWriter",a[a.AuthReader=25]="AuthReader",a[a.AuthClear=26]="AuthClear",a[a.AuthPage=27]="AuthPage",a[a.GetVNodeInfo=28]="GetVNodeInfo",a[a.UpdateDpr=29]="UpdateDpr",a))(x||{}),ye=(a=>(a[a.None=0]="None",a[a.Bg=1]="Bg",a[a.ServiceFloat=2]="ServiceFloat",a[a.Float=3]="Float",a[a.TopFloat=4]="TopFloat",a))(ye||{}),At=(a=>(a[a.Cursor=1]="Cursor",a[a.TextCreate=2]="TextCreate",a))(At||{}),Et=(a=>(a[a.Top=1]="Top",a[a.Bottom=2]="Bottom",a))(Et||{}),re=(a=>(a[a.none=1]="none",a[a.all=2]="all",a[a.both=3]="both",a[a.proportional=4]="proportional",a))(re||{}),Ki=(a=>(a[a.Pending=0]="Pending",a[a.Start=1]="Start",a[a.Doing=2]="Doing",a[a.Done=3]="Done",a[a.Unwritable=4]="Unwritable",a))(Ki||{}),jt=(a=>(a[a.inside=0]="inside",a[a.outside=1]="outside",a[a.intersect=2]="intersect",a))(jt||{}),De=(a=>(a.renderPage="renderPage",a.addPage="addPage",a.deletePage="deletePage",a.addElement="addElement",a.deleteElement="deleteElement",a.clearPage="clearPage",a.clearViewScenePath="clearViewScenePath",a.clearView="clearView",a))(De||{}),He=(a=>(a.setAuth="setAuth",a.setShow="addShow",a.setHide="setHide",a.setClear="setClear",a))(He||{}),lt=(a=>(a.Image="image",a.Iconify="iconify",a))(lt||{});const cn={linear:a=>a,easeInQuad:a=>a*a,easeOutQuad:a=>a*(2-a),easeInOutQuad:a=>a<.5?2*a*a:-1+(4-2*a)*a,easeInCubic:a=>a*a*a,easeOutCubic:a=>--a*a*a+1,easeInOutCubic:a=>a<.5?4*a*a*a:(a-1)*(2*a-2)*(2*a-2)+1,easeInQuart:a=>a*a*a*a,easeOutQuart:a=>1- --a*a*a*a,easeInOutQuart:a=>a<.5?8*a*a*a*a:1-8*--a*a*a*a,easeInQuint:a=>a*a*a*a*a,easeOutQuint:a=>1+--a*a*a*a*a,easeInOutQuint:a=>a<.5?16*a*a*a*a*a:1+16*--a*a*a*a*a,easeInSine:a=>1-Math.cos(a*Math.PI/2),easeOutSine:a=>Math.sin(a*Math.PI/2),easeInOutSine:a=>-(Math.cos(Math.PI*a)-1)/2,easeInExpo:a=>a<=0?0:Math.pow(2,10*a-10),easeOutExpo:a=>a>=1?1:1-Math.pow(2,-10*a),easeInOutExpo:a=>a<=0?0:a>=1?1:a<.5?Math.pow(2,20*a-10)/2:(2-Math.pow(2,-20*a+10))/2};class b{constructor(s=0,e=0,t=1){this.x=s,this.y=e,this.z=t}get XY(){return[this.x,this.y]}setz(s){return this.z=s,this}setXY(s=this.x,e=this.y){return this.x=s,this.y=e,this}set(s=this.x,e=this.y,t=this.z){return this.x=s,this.y=e,this.z=t,this}setTo({x:s=0,y:e=0,z:t=1}){return this.x=s,this.y=e,this.z=t,this}rot(s){if(s===0)return this;const{x:e,y:t}=this,i=Math.sin(s),o=Math.cos(s);return this.x=e*o-t*i,this.y=e*i+t*o,this}rotWith(s,e){if(e===0)return this;const t=this.x-s.x,i=this.y-s.y,o=Math.sin(e),n=Math.cos(e);return this.x=s.x+(t*n-i*o),this.y=s.y+(t*o+i*n),this}clone(){const{x:s,y:e,z:t}=this;return new b(s,e,t)}sub(s){return this.x-=s.x,this.y-=s.y,this}subXY(s,e){return this.x-=s,this.y-=e,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,e){return this.x+=s,this.y+=e,this}addScalar(s){return this.x+=s,this.y+=s,this}clamp(s,e){return this.x=Math.max(this.x,s),this.y=Math.max(this.y,s),e!==void 0&&(this.x=Math.min(this.x,e),this.y=Math.min(this.y,e)),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,e){const t=b.Tan(s,this);return this.add(t.mul(e))}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 b.Dpr(this,s)}cpr(s){return b.Cpr(this,s)}len2(){return b.Len2(this)}len(){return b.Len(this)}pry(s){return b.Pry(this,s)}per(){const{x:s,y:e}=this;return this.x=e,this.y=-s,this}uni(){return b.Uni(this)}tan(s){return b.Tan(this,s)}dist(s){return b.Dist(this,s)}distanceToLineSegment(s,e){return b.DistanceToLineSegment(s,e,this)}slope(s){return b.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 b.Angle(this,s)}toAngle(){return b.ToAngle(this)}lrp(s,e){return this.x=this.x+(s.x-this.x)*e,this.y=this.y+(s.y-this.y)*e,this}equals(s,e){return b.Equals(this,s,e)}equalsXY(s,e){return b.EqualsXY(this,s,e)}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 b.ToFixed(this)}toString(){return b.ToString(b.ToFixed(this))}toJson(){return b.ToJson(this)}toArray(){return b.ToArray(this)}static Add(s,e){return new b(s.x+e.x,s.y+e.y)}static AddXY(s,e,t){return new b(s.x+e,s.y+t)}static Sub(s,e){return new b(s.x-e.x,s.y-e.y)}static SubXY(s,e,t){return new b(s.x-e,s.y-t)}static AddScalar(s,e){return new b(s.x+e,s.y+e)}static SubScalar(s,e){return new b(s.x-e,s.y-e)}static Div(s,e){return new b(s.x/e,s.y/e)}static Mul(s,e){return new b(s.x*e,s.y*e)}static DivV(s,e){return new b(s.x/e.x,s.y/e.y)}static MulV(s,e){return new b(s.x*e.x,s.y*e.y)}static Neg(s){return new b(-s.x,-s.y)}static Per(s){return new b(s.y,-s.x)}static Dist2(s,e){return b.Sub(s,e).len2()}static Abs(s){return new b(Math.abs(s.x),Math.abs(s.y))}static Dist(s,e){return Math.hypot(s.y-e.y,s.x-e.x)}static Dpr(s,e){return s.x*e.x+s.y*e.y}static Cross(s,e){return new b(s.y*e.z-s.z*e.y,s.z*e.x-s.x*e.z)}static Cpr(s,e){return s.x*e.y-e.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,e){return b.Dpr(s,e)/b.Len(e)}static Uni(s){return b.Div(s,b.Len(s))}static Tan(s,e){return b.Uni(b.Sub(s,e))}static Min(s,e){return new b(Math.min(s.x,e.x),Math.min(s.y,e.y))}static Max(s,e){return new b(Math.max(s.x,e.x),Math.max(s.y,e.y))}static From(s){return new b().add(s)}static FromArray(s){return new b(s[0],s[1])}static Rot(s,e=0){const t=Math.sin(e),i=Math.cos(e);return new b(s.x*i-s.y*t,s.x*t+s.y*i)}static RotWith(s,e,t){const i=s.x-e.x,o=s.y-e.y,n=Math.sin(t),r=Math.cos(t);return new b(e.x+(i*r-o*n),e.y+(i*n+o*r))}static NearestPointOnLineThroughPoint(s,e,t){return b.Mul(e,b.Sub(t,s).pry(e)).add(s)}static NearestPointOnLineSegment(s,e,t,i=!0){const o=b.Tan(e,s),n=b.Add(s,b.Mul(o,b.Sub(t,s).pry(o)));if(i){if(n.x<Math.min(s.x,e.x))return b.Cast(s.x<e.x?s:e);if(n.x>Math.max(s.x,e.x))return b.Cast(s.x>e.x?s:e);if(n.y<Math.min(s.y,e.y))return b.Cast(s.y<e.y?s:e);if(n.y>Math.max(s.y,e.y))return b.Cast(s.y>e.y?s:e)}return n}static DistanceToLineThroughPoint(s,e,t){return b.Dist(t,b.NearestPointOnLineThroughPoint(s,e,t))}static DistanceToLineSegment(s,e,t,i=!0){return b.Dist(t,b.NearestPointOnLineSegment(s,e,t,i))}static Snap(s,e=1){return new b(Math.round(s.x/e)*e,Math.round(s.y/e)*e)}static Cast(s){return s instanceof b?s:b.From(s)}static Slope(s,e){return s.x===e.y?NaN:(s.y-e.y)/(s.x-e.x)}static Angle(s,e){return Math.atan2(e.y-s.y,e.x-s.x)}static Lrp(s,e,t){return b.Sub(e,s).mul(t).add(s)}static Med(s,e){return new b((s.x+e.x)/2,(s.y+e.y)/2)}static Equals(s,e,t=1e-4){return Math.abs(s.x-e.x)<t&&Math.abs(s.y-e.y)<t}static EqualsXY(s,e,t){return s.x===e&&s.y===t}static EqualsXYZ(s,e,t=1e-4){return b.Equals(s,e,t)&&Math.abs((s.z||0)-(e.z||0))<t}static Clockwise(s,e,t){return(t.x-s.x)*(e.y-s.y)-(e.x-s.x)*(t.y-s.y)<0}static Rescale(s,e){const t=b.Len(s);return new b(e*s.x/t,e*s.y/t)}static ScaleWithOrigin(s,e,t){return b.Sub(s,t).mul(e).add(t)}static ScaleWOrigin(s,e,t){return b.Sub(s,t).mulV(e).add(t)}static ToFixed(s,e=2){return new b(+s.x.toFixed(e),+s.y.toFixed(e),+s.z.toFixed(e))}static Nudge(s,e,t){return b.Add(s,b.Tan(e,s).mul(t))}static ToString(s){return`${s.x}, ${s.y}`}static ToAngle(s){let e=Math.atan2(s.y,s.x);return e<0&&(e+=Math.PI*2),e}static FromAngle(s,e=1){return new b(Math.cos(s)*e,Math.sin(s)*e)}static ToArray(s){return[s.x,s.y,s.z]}static ToJson(s){const{x:e,y:t,z:i}=s;return{x:e,y:t,z:i}}static Average(s){const e=s.length,t=new b(0,0);for(let i=0;i<e;i++)t.add(s[i]);return t.div(e)}static Clamp(s,e,t){return t===void 0?new b(Math.min(Math.max(s.x,e)),Math.min(Math.max(s.y,e))):new b(Math.min(Math.max(s.x,e),t),Math.min(Math.max(s.y,e),t))}static PointsBetween(s,e,t=6){const i=[];for(let o=0;o<t;o++){const n=cn.easeInQuad(o/(t-1)),r=b.Lrp(s,e,n);r.z=Math.min(1,.5+Math.abs(.5-ln(n))*.65),i.push(r)}return i}static SnapToGrid(s,e=8){return new b(Math.round(s.x/e)*e,Math.round(s.y/e)*e)}}const ln=a=>a<.5?2*a*a:-1+(4-2*a)*a;class V extends b{constructor(s=0,e=0,t=0,i={x:0,y:0},o=0,n=0){super(s,e,t),this.x=s,this.y=e,this.z=t,this.v=i,this.t=o,this.a=n}get timestamp(){return this.t}get pressure(){return this.z}get angleNum(){return this.a}get XY(){return[this.x,this.y]}setA(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,e=this.y,t=this.z,i=this.v,o=this.t,n=this.a){return this.x=s,this.y=e,this.z=t,this.v=i,this.t=o,this.a=n,this}clone(){const{x:s,y:e,z:t,v:i,t:o,a:n}=this,r={x:i.x,y:i.y};return new V(s,e,t,r,o,n)}distance(s){return V.GetDistance(this,s)}isNear(s,e){return V.IsNear(this,s,e)}getAngleByPoints(s,e){return V.GetAngleByPoints(s,this,e)}static Sub(s,e){return new V(s.x-e.x,s.y-e.y)}static Add(s,e){return new V(s.x+e.x,s.y+e.y)}static GetDistance(s,e){return V.Len(s.clone().sub(e))}static GetAngleByPoints(s,e,t){const i=e.x-s.x,o=t.x-e.x,n=e.y-s.y,r=t.y-e.y;let c=0;const l=Math.sqrt(i*i+n*n),h=Math.sqrt(o*o+r*r);if(l&&h){const u=i*o+n*r;c=Math.acos(u/(l*h)),c=c/Math.PI*180;let d=i*r-n*o;d=d>0?1:-1,c=180+d*c}return c}static IsNear(s,e,t){return V.Len(s.clone().sub(e))<t}static RotWith(s,e,t,i=2){const o=s.x-e.x,n=s.y-e.y,r=Math.sin(t),c=Math.cos(t),l=Math.pow(10,i),h=Math.floor((e.x+(o*c-n*r))*l)/l,u=Math.floor((e.y+(o*r+n*c))*l)/l;return new V(h,u)}static GetDotStroke(s,e,t=16){const i=new b(1,1),o=Math.PI+.001,n=V.Add(s,V.Sub(s,i).uni().per().mul(-e)),r=[];for(let c=1/t,l=c;l<=1;l+=c)r.push(V.RotWith(n,s,o*2*l));return r}static GetSemicircleStroke(s,e,t=-1,i=8){const o=t*(Math.PI+.001),n=[];for(let r=1/i,c=r;c<=1;c+=r)n.push(V.RotWith(e,s,o*c));return n}}var Bt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function St(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var hn=typeof Bt=="object"&&Bt&&Bt.Object===Object&&Bt,_i=hn,un=_i,dn=typeof self=="object"&&self&&self.Object===Object&&self,pn=un||dn||Function("return this")(),Qe=pn,fn=Qe,gn=fn.Symbol,Wt=gn,oi=Wt,eo=Object.prototype,yn=eo.hasOwnProperty,Mn=eo.toString,zt=oi?oi.toStringTag:void 0;function mn(a){var s=yn.call(a,zt),e=a[zt];try{a[zt]=void 0;var t=!0}catch{}var i=Mn.call(a);return t&&(s?a[zt]=e:delete a[zt]),i}var wn=mn,vn=Object.prototype,In=vn.toString;function Nn(a){return In.call(a)}var Sn=Nn,ni=Wt,Tn=wn,kn=Sn,Cn="[object Null]",bn="[object Undefined]",ri=ni?ni.toStringTag:void 0;function xn(a){return a==null?a===void 0?bn:Cn:ri&&ri in Object(a)?Tn(a):kn(a)}var ht=xn;function Ln(a){return a!=null&&typeof a=="object"}var qe=Ln,zn=ht,Pn=qe,Dn="[object Number]";function An(a){return typeof a=="number"||Pn(a)&&zn(a)==Dn}var jn=An;const Ae=St(jn);function En(){this.__data__=[],this.size=0}var On=En;function Rn(a,s){return a===s||a!==a&&s!==s}var Ys=Rn,Wn=Ys;function Yn(a,s){for(var e=a.length;e--;)if(Wn(a[e][0],s))return e;return-1}var rs=Yn,Un=rs,Bn=Array.prototype,Fn=Bn.splice;function Vn(a){var s=this.__data__,e=Un(s,a);if(e<0)return!1;var t=s.length-1;return e==t?s.pop():Fn.call(s,e,1),--this.size,!0}var $n=Vn,Hn=rs;function Qn(a){var s=this.__data__,e=Hn(s,a);return e<0?void 0:s[e][1]}var Gn=Qn,Zn=rs;function qn(a){return Zn(this.__data__,a)>-1}var Xn=qn,Jn=rs;function Kn(a,s){var e=this.__data__,t=Jn(e,a);return t<0?(++this.size,e.push([a,s])):e[t][1]=s,this}var _n=Kn,er=On,tr=$n,sr=Gn,ir=Xn,or=_n;function Tt(a){var s=-1,e=a==null?0:a.length;for(this.clear();++s<e;){var t=a[s];this.set(t[0],t[1])}}Tt.prototype.clear=er;Tt.prototype.delete=tr;Tt.prototype.get=sr;Tt.prototype.has=ir;Tt.prototype.set=or;var as=Tt,nr=as;function rr(){this.__data__=new nr,this.size=0}var ar=rr;function cr(a){var s=this.__data__,e=s.delete(a);return this.size=s.size,e}var lr=cr;function hr(a){return this.__data__.get(a)}var ur=hr;function dr(a){return this.__data__.has(a)}var pr=dr;function fr(a){var s=typeof a;return a!=null&&(s=="object"||s=="function")}var st=fr,gr=ht,yr=st,Mr="[object AsyncFunction]",mr="[object Function]",wr="[object GeneratorFunction]",vr="[object Proxy]";function Ir(a){if(!yr(a))return!1;var s=gr(a);return s==mr||s==wr||s==Mr||s==vr}var to=Ir,Nr=Qe,Sr=Nr["__core-js_shared__"],Tr=Sr,ws=Tr,ai=function(){var a=/[^.]+$/.exec(ws&&ws.keys&&ws.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""}();function kr(a){return!!ai&&ai in a}var Cr=kr,br=Function.prototype,xr=br.toString;function Lr(a){if(a!=null){try{return xr.call(a)}catch{}try{return a+""}catch{}}return""}var so=Lr,zr=to,Pr=Cr,Dr=st,Ar=so,jr=/[\\^$.*+?()[\]{}|]/g,Er=/^\[object .+?Constructor\]$/,Or=Function.prototype,Rr=Object.prototype,Wr=Or.toString,Yr=Rr.hasOwnProperty,Ur=RegExp("^"+Wr.call(Yr).replace(jr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Br(a){if(!Dr(a)||Pr(a))return!1;var s=zr(a)?Ur:Er;return s.test(Ar(a))}var Fr=Br;function Vr(a,s){return a==null?void 0:a[s]}var $r=Vr,Hr=Fr,Qr=$r;function Gr(a,s){var e=Qr(a,s);return Hr(e)?e:void 0}var ut=Gr,Zr=ut,qr=Qe,Xr=Zr(qr,"Map"),Us=Xr,Jr=ut,Kr=Jr(Object,"create"),cs=Kr,ci=cs;function _r(){this.__data__=ci?ci(null):{},this.size=0}var ea=_r;function ta(a){var s=this.has(a)&&delete this.__data__[a];return this.size-=s?1:0,s}var sa=ta,ia=cs,oa="__lodash_hash_undefined__",na=Object.prototype,ra=na.hasOwnProperty;function aa(a){var s=this.__data__;if(ia){var e=s[a];return e===oa?void 0:e}return ra.call(s,a)?s[a]:void 0}var ca=aa,la=cs,ha=Object.prototype,ua=ha.hasOwnProperty;function da(a){var s=this.__data__;return la?s[a]!==void 0:ua.call(s,a)}var pa=da,fa=cs,ga="__lodash_hash_undefined__";function ya(a,s){var e=this.__data__;return this.size+=this.has(a)?0:1,e[a]=fa&&s===void 0?ga:s,this}var Ma=ya,ma=ea,wa=sa,va=ca,Ia=pa,Na=Ma;function kt(a){var s=-1,e=a==null?0:a.length;for(this.clear();++s<e;){var t=a[s];this.set(t[0],t[1])}}kt.prototype.clear=ma;kt.prototype.delete=wa;kt.prototype.get=va;kt.prototype.has=Ia;kt.prototype.set=Na;var Sa=kt,li=Sa,Ta=as,ka=Us;function Ca(){this.size=0,this.__data__={hash:new li,map:new(ka||Ta),string:new li}}var ba=Ca;function xa(a){var s=typeof a;return s=="string"||s=="number"||s=="symbol"||s=="boolean"?a!=="__proto__":a===null}var La=xa,za=La;function Pa(a,s){var e=a.__data__;return za(s)?e[typeof s=="string"?"string":"hash"]:e.map}var ls=Pa,Da=ls;function Aa(a){var s=Da(this,a).delete(a);return this.size-=s?1:0,s}var ja=Aa,Ea=ls;function Oa(a){return Ea(this,a).get(a)}var Ra=Oa,Wa=ls;function Ya(a){return Wa(this,a).has(a)}var Ua=Ya,Ba=ls;function Fa(a,s){var e=Ba(this,a),t=e.size;return e.set(a,s),this.size+=e.size==t?0:1,this}var Va=Fa,$a=ba,Ha=ja,Qa=Ra,Ga=Ua,Za=Va;function Ct(a){var s=-1,e=a==null?0:a.length;for(this.clear();++s<e;){var t=a[s];this.set(t[0],t[1])}}Ct.prototype.clear=$a;Ct.prototype.delete=Ha;Ct.prototype.get=Qa;Ct.prototype.has=Ga;Ct.prototype.set=Za;var io=Ct,qa=as,Xa=Us,Ja=io,Ka=200;function _a(a,s){var e=this.__data__;if(e instanceof qa){var t=e.__data__;if(!Xa||t.length<Ka-1)return t.push([a,s]),this.size=++e.size,this;e=this.__data__=new Ja(t)}return e.set(a,s),this.size=e.size,this}var ec=_a,tc=as,sc=ar,ic=lr,oc=ur,nc=pr,rc=ec;function bt(a){var s=this.__data__=new tc(a);this.size=s.size}bt.prototype.clear=sc;bt.prototype.delete=ic;bt.prototype.get=oc;bt.prototype.has=nc;bt.prototype.set=rc;var oo=bt;function ac(a,s){for(var e=-1,t=a==null?0:a.length;++e<t&&s(a[e],e,a)!==!1;);return a}var cc=ac,lc=ut,hc=function(){try{var a=lc(Object,"defineProperty");return a({},"",{}),a}catch{}}(),no=hc,hi=no;function uc(a,s,e){s=="__proto__"&&hi?hi(a,s,{configurable:!0,enumerable:!0,value:e,writable:!0}):a[s]=e}var ro=uc,dc=ro,pc=Ys,fc=Object.prototype,gc=fc.hasOwnProperty;function yc(a,s,e){var t=a[s];(!(gc.call(a,s)&&pc(t,e))||e===void 0&&!(s in a))&&dc(a,s,e)}var ao=yc,Mc=ao,mc=ro;function wc(a,s,e,t){var i=!e;e||(e={});for(var o=-1,n=s.length;++o<n;){var r=s[o],c=t?t(e[r],a[r],r,e,a):void 0;c===void 0&&(c=a[r]),i?mc(e,r,c):Mc(e,r,c)}return e}var hs=wc;function vc(a,s){for(var e=-1,t=Array(a);++e<a;)t[e]=s(e);return t}var Ic=vc,Nc=ht,Sc=qe,Tc="[object Arguments]";function kc(a){return Sc(a)&&Nc(a)==Tc}var Cc=kc,ui=Cc,bc=qe,co=Object.prototype,xc=co.hasOwnProperty,Lc=co.propertyIsEnumerable,zc=ui(function(){return arguments}())?ui:function(a){return bc(a)&&xc.call(a,"callee")&&!Lc.call(a,"callee")},lo=zc,Pc=Array.isArray,Yt=Pc,Gt={exports:{}};function Dc(){return!1}var Ac=Dc;Gt.exports;(function(a,s){var e=Qe,t=Ac,i=s&&!s.nodeType&&s,o=i&&!0&&a&&!a.nodeType&&a,n=o&&o.exports===i,r=n?e.Buffer:void 0,c=r?r.isBuffer:void 0,l=c||t;a.exports=l})(Gt,Gt.exports);var Bs=Gt.exports,jc=9007199254740991,Ec=/^(?:0|[1-9]\d*)$/;function Oc(a,s){var e=typeof a;return s=s??jc,!!s&&(e=="number"||e!="symbol"&&Ec.test(a))&&a>-1&&a%1==0&&a<s}var Rc=Oc,Wc=9007199254740991;function Yc(a){return typeof a=="number"&&a>-1&&a%1==0&&a<=Wc}var ho=Yc,Uc=ht,Bc=ho,Fc=qe,Vc="[object Arguments]",$c="[object Array]",Hc="[object Boolean]",Qc="[object Date]",Gc="[object Error]",Zc="[object Function]",qc="[object Map]",Xc="[object Number]",Jc="[object Object]",Kc="[object RegExp]",_c="[object Set]",el="[object String]",tl="[object WeakMap]",sl="[object ArrayBuffer]",il="[object DataView]",ol="[object Float32Array]",nl="[object Float64Array]",rl="[object Int8Array]",al="[object Int16Array]",cl="[object Int32Array]",ll="[object Uint8Array]",hl="[object Uint8ClampedArray]",ul="[object Uint16Array]",dl="[object Uint32Array]",Me={};Me[ol]=Me[nl]=Me[rl]=Me[al]=Me[cl]=Me[ll]=Me[hl]=Me[ul]=Me[dl]=!0;Me[Vc]=Me[$c]=Me[sl]=Me[Hc]=Me[il]=Me[Qc]=Me[Gc]=Me[Zc]=Me[qc]=Me[Xc]=Me[Jc]=Me[Kc]=Me[_c]=Me[el]=Me[tl]=!1;function pl(a){return Fc(a)&&Bc(a.length)&&!!Me[Uc(a)]}var fl=pl;function gl(a){return function(s){return a(s)}}var us=gl,Zt={exports:{}};Zt.exports;(function(a,s){var e=_i,t=s&&!s.nodeType&&s,i=t&&!0&&a&&!a.nodeType&&a,o=i&&i.exports===t,n=o&&e.process,r=function(){try{var c=i&&i.require&&i.require("util").types;return c||n&&n.binding&&n.binding("util")}catch{}}();a.exports=r})(Zt,Zt.exports);var Fs=Zt.exports,yl=fl,Ml=us,di=Fs,pi=di&&di.isTypedArray,ml=pi?Ml(pi):yl,uo=ml,wl=Ic,vl=lo,Il=Yt,Nl=Bs,Sl=Rc,Tl=uo,kl=Object.prototype,Cl=kl.hasOwnProperty;function bl(a,s){var e=Il(a),t=!e&&vl(a),i=!e&&!t&&Nl(a),o=!e&&!t&&!i&&Tl(a),n=e||t||i||o,r=n?wl(a.length,String):[],c=r.length;for(var l in a)(s||Cl.call(a,l))&&!(n&&(l=="length"||i&&(l=="offset"||l=="parent")||o&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||Sl(l,c)))&&r.push(l);return r}var po=bl,xl=Object.prototype;function Ll(a){var s=a&&a.constructor,e=typeof s=="function"&&s.prototype||xl;return a===e}var Vs=Ll;function zl(a,s){return function(e){return a(s(e))}}var fo=zl,Pl=fo,Dl=Pl(Object.keys,Object),Al=Dl,jl=Vs,El=Al,Ol=Object.prototype,Rl=Ol.hasOwnProperty;function Wl(a){if(!jl(a))return El(a);var s=[];for(var e in Object(a))Rl.call(a,e)&&e!="constructor"&&s.push(e);return s}var Yl=Wl,Ul=to,Bl=ho;function Fl(a){return a!=null&&Bl(a.length)&&!Ul(a)}var $s=Fl,Vl=po,$l=Yl,Hl=$s;function Ql(a){return Hl(a)?Vl(a):$l(a)}var Hs=Ql,Gl=hs,Zl=Hs;function ql(a,s){return a&&Gl(s,Zl(s),a)}var Xl=ql;function Jl(a){var s=[];if(a!=null)for(var e in Object(a))s.push(e);return s}var Kl=Jl,_l=st,eh=Vs,th=Kl,sh=Object.prototype,ih=sh.hasOwnProperty;function oh(a){if(!_l(a))return th(a);var s=eh(a),e=[];for(var t in a)t=="constructor"&&(s||!ih.call(a,t))||e.push(t);return e}var nh=oh,rh=po,ah=nh,ch=$s;function lh(a){return ch(a)?rh(a,!0):ah(a)}var Qs=lh,hh=hs,uh=Qs;function dh(a,s){return a&&hh(s,uh(s),a)}var ph=dh,qt={exports:{}};qt.exports;(function(a,s){var e=Qe,t=s&&!s.nodeType&&s,i=t&&!0&&a&&!a.nodeType&&a,o=i&&i.exports===t,n=o?e.Buffer:void 0,r=n?n.allocUnsafe:void 0;function c(l,h){if(h)return l.slice();var u=l.length,d=r?r(u):new l.constructor(u);return l.copy(d),d}a.exports=c})(qt,qt.exports);var fh=qt.exports;function gh(a,s){var e=-1,t=a.length;for(s||(s=Array(t));++e<t;)s[e]=a[e];return s}var yh=gh;function Mh(a,s){for(var e=-1,t=a==null?0:a.length,i=0,o=[];++e<t;){var n=a[e];s(n,e,a)&&(o[i++]=n)}return o}var go=Mh;function mh(){return[]}var yo=mh,wh=go,vh=yo,Ih=Object.prototype,Nh=Ih.propertyIsEnumerable,fi=Object.getOwnPropertySymbols,Sh=fi?function(a){return a==null?[]:(a=Object(a),wh(fi(a),function(s){return Nh.call(a,s)}))}:vh,Gs=Sh,Th=hs,kh=Gs;function Ch(a,s){return Th(a,kh(a),s)}var bh=Ch;function xh(a,s){for(var e=-1,t=s.length,i=a.length;++e<t;)a[i+e]=s[e];return a}var Zs=xh,Lh=fo,zh=Lh(Object.getPrototypeOf,Object),Mo=zh,Ph=Zs,Dh=Mo,Ah=Gs,jh=yo,Eh=Object.getOwnPropertySymbols,Oh=Eh?function(a){for(var s=[];a;)Ph(s,Ah(a)),a=Dh(a);return s}:jh,mo=Oh,Rh=hs,Wh=mo;function Yh(a,s){return Rh(a,Wh(a),s)}var Uh=Yh,Bh=Zs,Fh=Yt;function Vh(a,s,e){var t=s(a);return Fh(a)?t:Bh(t,e(a))}var wo=Vh,$h=wo,Hh=Gs,Qh=Hs;function Gh(a){return $h(a,Qh,Hh)}var vo=Gh,Zh=wo,qh=mo,Xh=Qs;function Jh(a){return Zh(a,Xh,qh)}var Kh=Jh,_h=ut,eu=Qe,tu=_h(eu,"DataView"),su=tu,iu=ut,ou=Qe,nu=iu(ou,"Promise"),ru=nu,au=ut,cu=Qe,lu=au(cu,"Set"),Io=lu,hu=ut,uu=Qe,du=hu(uu,"WeakMap"),pu=du,Cs=su,bs=Us,xs=ru,Ls=Io,zs=pu,No=ht,xt=so,gi="[object Map]",fu="[object Object]",yi="[object Promise]",Mi="[object Set]",mi="[object WeakMap]",wi="[object DataView]",gu=xt(Cs),yu=xt(bs),Mu=xt(xs),mu=xt(Ls),wu=xt(zs),nt=No;(Cs&&nt(new Cs(new ArrayBuffer(1)))!=wi||bs&&nt(new bs)!=gi||xs&&nt(xs.resolve())!=yi||Ls&&nt(new Ls)!=Mi||zs&&nt(new zs)!=mi)&&(nt=function(a){var s=No(a),e=s==fu?a.constructor:void 0,t=e?xt(e):"";if(t)switch(t){case gu:return wi;case yu:return gi;case Mu:return yi;case mu:return Mi;case wu:return mi}return s});var ds=nt,vu=Object.prototype,Iu=vu.hasOwnProperty;function Nu(a){var s=a.length,e=new a.constructor(s);return s&&typeof a[0]=="string"&&Iu.call(a,"index")&&(e.index=a.index,e.input=a.input),e}var Su=Nu,Tu=Qe,ku=Tu.Uint8Array,So=ku,vi=So;function Cu(a){var s=new a.constructor(a.byteLength);return new vi(s).set(new vi(a)),s}var qs=Cu,bu=qs;function xu(a,s){var e=s?bu(a.buffer):a.buffer;return new a.constructor(e,a.byteOffset,a.byteLength)}var Lu=xu,zu=/\w*$/;function Pu(a){var s=new a.constructor(a.source,zu.exec(a));return s.lastIndex=a.lastIndex,s}var Du=Pu,Ii=Wt,Ni=Ii?Ii.prototype:void 0,Si=Ni?Ni.valueOf:void 0;function Au(a){return Si?Object(Si.call(a)):{}}var ju=Au,Eu=qs;function Ou(a,s){var e=s?Eu(a.buffer):a.buffer;return new a.constructor(e,a.byteOffset,a.length)}var Ru=Ou,Wu=qs,Yu=Lu,Uu=Du,Bu=ju,Fu=Ru,Vu="[object Boolean]",$u="[object Date]",Hu="[object Map]",Qu="[object Number]",Gu="[object RegExp]",Zu="[object Set]",qu="[object String]",Xu="[object Symbol]",Ju="[object ArrayBuffer]",Ku="[object DataView]",_u="[object Float32Array]",ed="[object Float64Array]",td="[object Int8Array]",sd="[object Int16Array]",id="[object Int32Array]",od="[object Uint8Array]",nd="[object Uint8ClampedArray]",rd="[object Uint16Array]",ad="[object Uint32Array]";function cd(a,s,e){var t=a.constructor;switch(s){case Ju:return Wu(a);case Vu:case $u:return new t(+a);case Ku:return Yu(a,e);case _u:case ed:case td:case sd:case id:case od:case nd:case rd:case ad:return Fu(a,e);case Hu:return new t;case Qu:case qu:return new t(a);case Gu:return Uu(a);case Zu:return new t;case Xu:return Bu(a)}}var ld=cd,hd=st,Ti=Object.create,ud=function(){function a(){}return function(s){if(!hd(s))return{};if(Ti)return Ti(s);a.prototype=s;var e=new a;return a.prototype=void 0,e}}(),dd=ud,pd=dd,fd=Mo,gd=Vs;function yd(a){return typeof a.constructor=="function"&&!gd(a)?pd(fd(a)):{}}var Md=yd,md=ds,wd=qe,vd="[object Map]";function Id(a){return wd(a)&&md(a)==vd}var Nd=Id,Sd=Nd,Td=us,ki=Fs,Ci=ki&&ki.isMap,kd=Ci?Td(Ci):Sd,Cd=kd,bd=ds,xd=qe,Ld="[object Set]";function zd(a){return xd(a)&&bd(a)==Ld}var Pd=zd,Dd=Pd,Ad=us,bi=Fs,xi=bi&&bi.isSet,jd=xi?Ad(xi):Dd,To=jd;const Ed=St(To);var Od=oo,Rd=cc,Wd=ao,Yd=Xl,Ud=ph,Bd=fh,Fd=yh,Vd=bh,$d=Uh,Hd=vo,Qd=Kh,Gd=ds,Zd=Su,qd=ld,Xd=Md,Jd=Yt,Kd=Bs,_d=Cd,ep=st,tp=To,sp=Hs,ip=Qs,op=1,np=2,rp=4,ko="[object Arguments]",ap="[object Array]",cp="[object Boolean]",lp="[object Date]",hp="[object Error]",Co="[object Function]",up="[object GeneratorFunction]",dp="[object Map]",pp="[object Number]",bo="[object Object]",fp="[object RegExp]",gp="[object Set]",yp="[object String]",Mp="[object Symbol]",mp="[object WeakMap]",wp="[object ArrayBuffer]",vp="[object DataView]",Ip="[object Float32Array]",Np="[object Float64Array]",Sp="[object Int8Array]",Tp="[object Int16Array]",kp="[object Int32Array]",Cp="[object Uint8Array]",bp="[object Uint8ClampedArray]",xp="[object Uint16Array]",Lp="[object Uint32Array]",ge={};ge[ko]=ge[ap]=ge[wp]=ge[vp]=ge[cp]=ge[lp]=ge[Ip]=ge[Np]=ge[Sp]=ge[Tp]=ge[kp]=ge[dp]=ge[pp]=ge[bo]=ge[fp]=ge[gp]=ge[yp]=ge[Mp]=ge[Cp]=ge[bp]=ge[xp]=ge[Lp]=!0;ge[hp]=ge[Co]=ge[mp]=!1;function Ht(a,s,e,t,i,o){var n,r=s&op,c=s&np,l=s&rp;if(e&&(n=i?e(a,t,i,o):e(a)),n!==void 0)return n;if(!ep(a))return a;var h=Jd(a);if(h){if(n=Zd(a),!r)return Fd(a,n)}else{var u=Gd(a),d=u==Co||u==up;if(Kd(a))return Bd(a,r);if(u==bo||u==ko||d&&!i){if(n=c||d?{}:Xd(a),!r)return c?$d(a,Ud(n,a)):Vd(a,Yd(n,a))}else{if(!ge[u])return i?a:{};n=qd(a,u,r)}}o||(o=new Od);var f=o.get(a);if(f)return f;o.set(a,n),tp(a)?a.forEach(function(m){n.add(Ht(m,s,e,m,a,o))}):_d(a)&&a.forEach(function(m,N){n.set(N,Ht(m,s,e,N,a,o))});var g=l?c?Qd:Hd:c?ip:sp,p=h?void 0:g(a);return Rd(p||a,function(m,N){p&&(N=m,m=a[N]),Wd(n,N,Ht(m,s,e,N,a,o))}),n}var zp=Ht,Pp=zp,Dp=1,Ap=4;function jp(a){return Pp(a,Dp|Ap)}var Ep=jp;const Ce=St(Ep),xo="1.1.14-beta.1",Op="@netless/appliance-plugin",Xs=typeof OffscreenCanvas=="function"?"worker":"mainThread";if(typeof window<"u"){let a=window.__netlessUA||"";a+=` ${Op}@${xo}`,window.__netlessUA=a}const be={syncOpt:{interval:500},cdn:{subWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/subWorker.js",fullWorkerUrl:"https://cdn.jsdelivr.net/npm/@netless/appliance-plugin@latest/dist/fullWorker.js"},cursor:{expirationTime:5e3},bufferSize:{full:2e4,sub:600},bezier:{combineUnitTime:100},pencilEraser:{useBitMap:!0},strokeWidth:{min:1,max:10}};function Je(a,s=!0){const e=a.length;if(e<2)return"";let t=a[0],i=a[1];if(e===2)return`M${dt(t)}L${dt(i)}`;let o="";for(let n=2,r=e-1;n<r;n++)t=a[n],i=a[n+1],o+=pt(t,i);return s?`M${pt(a[0],a[1])}Q${dt(a[1])}${pt(a[1],a[2])}T${o}${pt(a[e-1],a[0])}${pt(a[0],a[1])}Z`:`M${dt(a[0])}Q${dt(a[1])}${pt(a[1],a[2])}${a.length>3?"T":""}${o}L${dt(a[e-1])}`}const ze=class ze{constructor(s){y(this,"syncUnitTime",be.syncOpt.interval);y(this,"vNodes");y(this,"drawLayer");y(this,"fullLayer");y(this,"workId");y(this,"isDelete",!1);const{vNodes:e,fullLayer:t,drawLayer:i,workId:o,toolsOpt:n}=s;this.vNodes=e,this.fullLayer=t,this.drawLayer=i,this.workId=o,this.syncUnitTime=n.syncUnitTime||this.syncUnitTime}get baseConsumeResult(){return{workId:this.workId,toolsType:this.toolsType,opt:this.workOptions}}filterSamePoints(s,e=.01){return s.reduce((t,i)=>{const o=t[t.length-1];return(i&&!o||i&&o&&!i.isNear(o,e))&&t.push(i),t},[])}setWorkId(s){this.workId=s}getWorkId(){return this.workId}getWorkOptions(){return this.workOptions}setWorkOptions(s){var i,o,n;this.workOptions=s,this.syncUnitTime=s.syncUnitTime||this.syncUnitTime;const e=(i=this.workId)==null?void 0:i.toString(),t=e&&((o=this.vNodes)==null?void 0:o.get(e))||void 0;e&&t&&(t.opt=s,(n=this.vNodes)==null||n.setInfo(e,t))}updataOptService(s){var i,o;let e;const t=(i=this.workId)==null?void 0:i.toString();if(t&&s){const n=this.fullLayer.getElementsByName(t)||this.drawLayer&&this.drawLayer.getElementsByName(t)||[];if(n.length!==1)return;const r=n[0],{pos:c,zIndex:l,scale:h,angle:u,translate:d}=s,f={};Ae(l)&&(f.zIndex=l),c&&(f.pos=[c[0],c[1]]),h&&(f.scale=h),u&&(f.rotate=u),d&&(f.translate=d),r.attr(f);const g=r==null?void 0:r.getBoundingClientRect();return g&&(e=ce(e,{x:Math.floor(g.x-ze.SafeBorderPadding),y:Math.floor(g.y-ze.SafeBorderPadding),w:Math.floor(g.width+ze.SafeBorderPadding*2),h:Math.floor(g.height+ze.SafeBorderPadding*2)})),(o=this.vNodes)==null||o.setInfo(t,{rect:e,centerPos:c}),e}}drawEraserlines(s){var C;const{group:e,eraserlines:t,pos:i,layer:o}=s,n=!!o.renderer.glRenderer,r=o.parent,c=o.parent.parent,l=o.getAttribute("scale"),h=o.getAttribute("translate"),u=this.createVmRenderNode(`${this.workId}_bitMapLayer`,c,{offscreen:r.offscreen,width:r.width,height:r.height,contextType:"2d",autoRender:!1,bufferSize:500},l,h),d=e.cloneNode(!0);this.addEraserlines(d,t,i,!1),u.appendChild(d);const f=u.parent;f.render();const g=u.renderer.canvasRenderer,p=d.getBoundingClientRect(),m={x:Math.floor(p.x-ze.SafeBorderPadding),y:Math.floor(p.y-ze.SafeBorderPadding),width:Math.floor(p.width+ze.SafeBorderPadding*2),height:Math.floor(p.height+ze.SafeBorderPadding*2)},N=g.options.displayRatio,v=Math.floor(m.x*N),T=Math.floor(m.y*N),k=Math.floor(m.width*N),S=Math.floor(m.height*N),w=this.isTransparentRectByCanvas(g.context,{x:v,y:T,w:k,h:S});if(c.removeChild(f),w){this.isDelete=!0,console.log("isTransparent===>",this.workId,(C=this.vNodes)==null?void 0:C.curNodeMap.size);return}this.addEraserlines(e,t,i,n)}createVmRenderNode(s,e,t,i,o){const{width:n,height:r}=t,c=`bitMap-${s}`,l=e.layer(c,t),h=new le.Group({anchor:[.5,.5],pos:[n*.5,r*.5],size:[n,r],name:"viewport",id:s});return h.setAttribute("scale",i),h.setAttribute("translate",o),l.append(h),h}addEraserlines(s,e,t,i=!0){for(const o of e){const{thickness:n,op:r}=o;for(const c of r){const l=c.map((g,p)=>p%2?g-t[1]:g-t[0]),h=this.computEraserPoints(l,n),u=Je(h,!0),d={pos:[0,0],d:u,fillColor:"rgba(0,0,0,1)"},f=new le.Path(d);f.addEventListener("beforerender",({detail:g})=>{const p=g.context;i?p.blendFuncSeparate(p.ZERO,p.ZERO,p.ZERO,p.ZERO):p.globalCompositeOperation="destination-out"}),f.addEventListener("afterrender",({detail:g})=>{const p=g.context;i?p.blendFuncSeparate(p.SRC_ALPHA,p.ONE_MINUS_SRC_ALPHA,p.ONE,p.ONE_MINUS_SRC_ALPHA):p.globalCompositeOperation="source-over"}),s.append(f)}}}isTransparentRectByCanvas(s,e){if(!s)return!1;const{x:t,y:i,w:o,h:n}=e,r=s.getImageData(t,i,o,n);let c=!0;for(let l=0;l<r.data.length;l+=4)if(r.data[l+3]!==0){c=!1;break}return c}computEraserPoints(s,e){const t=Math.ceil(e/2);return s.length===2?this.computDot(s,t):this.computLine(s,t)}computDot(s,e){const t=new V(s[0],s[1]);return V.GetDotStroke(t,e,8)}computLine(s,e){const t=[],i=[];let o,n;for(let r=0;r<s.length;r+=2){const c=new V(s[r],s[r+1]);let l;if(r==s.length-2){const h=new V(s[r-2],s[r-1]);l=b.Sub(c,h).uni(),o=c}else{r===0&&(n=c);const h=new V(s[r+2],s[r+3]);l=b.Sub(h,c).uni()}if(l){const h=b.Per(l).mul(e);t.push(V.Sub(c,h)),i.push(V.Add(c,h))}}if(o&&n){const r=V.GetSemicircleStroke(o,t[t.length-1],-1,8),c=V.GetSemicircleStroke(n,i[0],-1,8);return t.concat(r,i.reverse(),c)}return[]}replace(s,e,t){var r;if(!e){t&&s.append(t);return}const i=s.getElementsByName(e),o=i.length;if(o){if(o>1)for(let c=1;c<i.length;c++)s.removeChild(i[c]),i[c].disconnect();t?s.replaceChild(t,i[0]):s.removeChild(i[0]),i[0].disconnect()}else t&&s.append(t);this.fullLayer===s?(r=this.drawLayer)==null||r.getElementsByName(e).forEach(c=>{var l;(l=this.drawLayer)==null||l.removeChild(c),c.disconnect()}):this.fullLayer.getElementsByName(e).forEach(c=>{this.fullLayer.removeChild(c),c.disconnect()})}removeDrawCountNodes(s,e){const t=[];s.getElementsByName(this.workId).forEach(i=>{i.id&&e&&Number(i.id)<e&&t.push(i)});for(const i of t)i.remove(),i.disconnect()}static updateNodeOpt(s){var v;const{node:e,opt:t,vNodes:i,willSerializeData:o,targetNode:n}=s,{zIndex:r,translate:c,angle:l,originPoint:h,scenePoint:u,scale:d,pointMap:f,thickness:g}=t;let p;const m=n&&Ce(n)||i.get(e.name);if(!m)return;Ae(r)&&(e.setAttribute("zIndex",r),m.opt.zIndex=r);const N=e.parent;if(N){if(h&&d&&n){const T=[m.op[0],m.op[1]];ti(m.op,u,d,c);const k=[m.op[0],m.op[1]],S=[k[0]-T[0],k[1]-T[1]];if(m.centerPos=[m.centerPos[0]+S[0],m.centerPos[1]+S[1]],m.opt.translate=void 0,m.opt.scale=void 0,m.opt.eraserlines)for(const w of Object.values(m.opt.eraserlines)){const{op:C,thickness:L}=w;w.thickness=L*Math.max(d[0],d[1]);for(let j=0;j<C.length;j++)si(C[j],u,d,c)}}else if(c)if(e.setAttribute("translate",c),m.opt.translate=c,n){const T=[c[0]*N.worldScaling[0],c[1]*N.worldScaling[1]];p=Ds(m.rect,T),m.rect=p}else{const T=ze.getRectFromLayer(N,e.name);m.rect=T||m.rect}else if(Ae(l))if(e.setAttribute("rotate",l),m.opt.rotate=l,n)p=Go(m.rect,l),m.rect=p;else{const T=ze.getRectFromLayer(N,e.name);m.rect=T||m.rect}if(f){const T=f.get(e.name);if(T)for(let k=0,S=0;k<m.op.length;k+=3,S++)m.op[k]=T[S][0],m.op[k+1]=T[S][1]}if(g&&((v=m==null?void 0:m.opt)!=null&&v.thickness)&&(m.opt.thickness=g),o&&!(h&&d&&n)){if(c){const T=m.op.map((k,S)=>{const w=S%3;return w===0?k+c[0]:w===1?k+c[1]:k});if(m.op=T,m.centerPos=[m.centerPos[0]+c[0],m.centerPos[1]+c[1]],m!=null&&m.opt&&(m.opt.translate=void 0),m.opt.eraserlines)for(const k of Object.values(m.opt.eraserlines)){const{op:S}=k;for(let w=0;w<S.length;w++){const C=S[w].map((L,j)=>j%2?L+c[1]:L+c[0]);k.op[w]=C}}}else if(Ae(l)){const T=m.op;if(dM(T,m.centerPos,l),m.op=T,m!=null&&m.opt&&(m.opt.rotate=void 0),m.opt.eraserlines)for(const k of Object.values(m.opt.eraserlines)){const{op:S}=k;for(let w=0;w<S.length;w++)pM(S[w],m.centerPos,l)}}}m&&i.setInfo(e.name,m)}}static getCenterPos(s,e){const{worldPosition:t,worldScaling:i}=e;return[(s.x+s.w/2-t[0])/i[0],(s.y+s.h/2-t[1])/i[1]]}static getRectFromLayer(s,e){const t=s.getElementsByName(e)[0];if(t){const i=t.getBoundingClientRect();return{x:Math.floor(i.x-ze.SafeBorderPadding),y:Math.floor(i.y-ze.SafeBorderPadding),w:Math.floor(i.width+ze.SafeBorderPadding*2),h:Math.floor(i.height+ze.SafeBorderPadding*2)}}}};y(ze,"SafeBorderPadding",10);let Y=ze;function it(a){return JSON.parse(Xi.decompress(a))}function Re(a){return Xi.compress(JSON.stringify(a))}const Le=Object.keys;class Lo extends Y{constructor(e){super(e);y(this,"canRotate",!0);y(this,"scaleType",re.all);y(this,"toolsType",I.Pencil);y(this,"syncTimestamp");y(this,"syncIndex",0);y(this,"tmpPoints",[]);y(this,"MAX_REPEAR",10);y(this,"uniThickness");y(this,"workOptions");y(this,"centerPos",[0,0]);this.workOptions=e.toolsOpt,this.uniThickness=this.MAX_REPEAR/this.workOptions.thickness/10,this.syncTimestamp=0}combineConsume(){var r;const e=(r=this.workId)==null?void 0:r.toString();if(this.tmpPoints.length<2)return{type:x.None};const t=this.transformDataAll(!0),i={name:e};let o;const n=this.drawLayer||this.fullLayer;return t.length&&(o=this.draw({attrs:i,tasks:t,replaceId:e,layer:n})),{rect:o,type:x.DrawWork,dataType:B.Local}}setWorkOptions(e){super.setWorkOptions(e),this.syncTimestamp=Date.now()}consume(e){const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n,drawCount:r,removeDrawCount:c}=e,{workId:l}=t,{tasks:h,effects:u,consumeIndex:d}=this.transformData(t,!1);this.syncIndex=Math.min(this.syncIndex,d,Math.max(0,this.tmpPoints.length-2));const f={name:l,id:Ae(r)&&r.toString()||void 0};let g,p=!1;const m=this.syncIndex;if(this.syncTimestamp===0&&(this.syncTimestamp=Date.now()),h.length&&(h[0].taskId-this.syncTimestamp>this.syncUnitTime&&(p=!0,this.syncTimestamp=h[0].taskId,this.syncIndex=this.tmpPoints.length),o||n)){const v=i?this.fullLayer:this.drawLayer||this.fullLayer;g=this.draw({attrs:f,tasks:h,effects:u,layer:v,removeDrawCount:c})}if(o)return d>10&&this.tmpPoints.splice(0,d-10),{rect:g,type:x.DrawWork,dataType:B.Local};const N=[];return this.tmpPoints.slice(m).forEach(v=>{N.push(v.x,v.y,this.computRadius(v.z,this.workOptions.thickness))}),{...this.baseConsumeResult,type:x.DrawWork,dataType:B.Local,rect:g,op:p?N:void 0,index:p?m*3:void 0,updateNodeOpt:{useAnimation:!0}}}consumeAll(e){var h;const t=this.workId;if(e.data){const{op:u,workState:d}=e.data;u!=null&&u.length&&d===P.Done&&this.workOptions.strokeType===ee.Stroke&&this.updateTempPointsWithPressureWhenDone(u)}const i=this.transformDataAll(!0),o={name:t};let n;const r=this.fullLayer;if(i.length&&(n=this.draw({attrs:o,tasks:i,replaceId:t,layer:r})),this.tmpPoints.length<2)return this.replace(r,t),{type:x.RemoveNode,removeIds:[t],rect:n};const c=[];this.tmpPoints.map(u=>{c.push(u.x,u.y,u.z)}),this.syncTimestamp=0,delete this.workOptions.syncUnitTime;const l=Re(c);return(h=this.vNodes)==null||h.setInfo(t,{rect:n,op:c,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:n&&Y.getCenterPos(n,r)}),{...this.baseConsumeResult,rect:n,type:x.FullWork,dataType:B.Local,ops:l,updateNodeOpt:{pos:this.centerPos,useAnimation:!0}}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(e){var h,u;const{op:t,isFullWork:i,replaceId:o}=e;this.tmpPoints.length=0;for(let d=0;d<t.length;d+=3){const f=new V(t[d],t[d+1],t[d+2]);if(this.tmpPoints.length>0){const g=this.tmpPoints[this.tmpPoints.length-1],p=b.Sub(f,g).uni();f.setv(p)}this.tmpPoints.push(f)}if(this.tmpPoints.length<2)return;const n=this.transformDataAll(!0),r=(h=this.workId)==null?void 0:h.toString(),c={name:r};let l;if(r&&n.length){const d=i?this.fullLayer:this.drawLayer||this.fullLayer;l=this.draw({attrs:c,tasks:n,replaceId:o,layer:d}),(u=this.vNodes)==null||u.setInfo(r,{rect:l,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:l&&Y.getCenterPos(l,d)})}return l}transformDataAll(e=!0){const t=this.filterSamePoints(this.tmpPoints,this.workOptions.thickness);return this.getTaskPoints(t,e&&this.workOptions.thickness||void 0)}draw(e){const{attrs:t,tasks:i,replaceId:o,effects:n,layer:r,removeDrawCount:c}=e,{strokeColor:l,strokeType:h,thickness:u,zIndex:d,scale:f,rotate:g,translate:p,eraserlines:m}=this.workOptions;n!=null&&n.size&&(n.forEach(w=>{var C;(C=r.getElementById(w+""))==null||C.remove()}),n.clear()),c&&this.removeDrawCountNodes(r,c);let N;const v=[],T=r.worldPosition,k=r.worldScaling;for(let w=0;w<i.length;w++){const{pos:C,points:L}=i[w],{ps:j,rect:E}=this.computDrawPoints(L);let A;const W=L.length===1;h===ee.Stroke||W?A=Je(j,!0):A=Je(j,!1);const z={pos:C,d:A,fillColor:h===ee.Stroke||W?l:void 0,lineDash:h===ee.Dotted&&!W?[1,u*2]:h===ee.LongDotted&&!W?[u,u*2]:void 0,strokeColor:l,lineCap:h===ee.Stroke||W?void 0:"round",lineWidth:h===ee.Stroke||W?0:u};N=ce(N,{x:Math.floor((E.x+C[0])*k[0]+T[0]-Y.SafeBorderPadding),y:Math.floor((E.y+C[1])*k[1]+T[1]-Y.SafeBorderPadding),w:Math.floor(E.w*k[0]+2*Y.SafeBorderPadding),h:Math.floor(E.h*k[1]+2*Y.SafeBorderPadding)}),v.push(z)}f&&(t.scale=f),g&&(t.rotate=g),p&&(t.translate=p);const S=new le.Group;if(N){this.centerPos=Y.getCenterPos(N,r);const w=h===ee.Stroke&&!m;S.attr({...t,normalize:!0,anchor:[.5,.5],bgcolor:w?l:void 0,pos:this.centerPos,size:[(N.w-2*Y.SafeBorderPadding)/k[0],(N.h-2*Y.SafeBorderPadding)/k[1]],zIndex:d});const C=v.map(L=>(L.pos=[L.pos[0]-this.centerPos[0],L.pos[1]-this.centerPos[1]],new le.Path(L)));S.append(...C),w&&S.seal(),m&&(this.scaleType=re.proportional,this.drawEraserlines({group:S,eraserlines:m,pos:this.centerPos,layer:r})),this.replace(r,o,S)}if(f||g||p){const w=S==null?void 0:S.getBoundingClientRect();if(w)return{x:Math.floor(w.x-Y.SafeBorderPadding),y:Math.floor(w.y-Y.SafeBorderPadding),w:Math.floor(w.width+Y.SafeBorderPadding*2),h:Math.floor(w.height+Y.SafeBorderPadding*2)}}return N}computDrawPoints(e){return this.workOptions.strokeType===ee.Stroke||e.length===1?this.computStroke(e):this.computNomal(e)}computNomal(e){let t=this.workOptions.thickness;const i=e.map(o=>(t=Math.max(t,o.radius),o.point));return{ps:i,rect:pe(i,t)}}computStroke(e){return e.length===1?this.computDotStroke(e[0]):this.computLineStroke(e)}computLineStroke(e){const t=[],i=[];for(let l=0;l<e.length;l++){const{point:h,radius:u}=e[l];let d=h.v;l===0&&e.length>1&&(d=e[l+1].point.v);const f=b.Per(d).mul(u);t.push(V.Sub(h,f)),i.push(V.Add(h,f))}const o=e[e.length-1],n=V.GetSemicircleStroke(o.point,t[t.length-1],-1,8),r=V.GetSemicircleStroke(e[0].point,i[0],-1,8),c=t.concat(n,i.reverse(),r);return{ps:c,rect:pe(c)}}computDotStroke(e){const{point:t,radius:i}=e,o={x:t.x-i,y:t.y-i,w:i*2,h:i*2};return{ps:V.GetDotStroke(t,i,8),rect:o}}transformData(e,t){const{op:i,workState:o}=e;let n=this.tmpPoints.length-1,r=[];if(i!=null&&i.length&&o){const{strokeType:c,thickness:l}=this.workOptions,h=new Set;n=c===ee.Stroke?this.updateTempPointsWithPressure(i,l,h):this.updateTempPoints(i,l,h);const u=t?this.tmpPoints:this.tmpPoints.slice(n);return r=this.getTaskPoints(u,l),{tasks:r,effects:h,consumeIndex:n}}return{tasks:r,consumeIndex:n}}computRadius(e,t){return e*.03*t+t*.5}getMinZ(e,t){return((t||Math.max(1,Math.floor(e*.3)))-e*.5)*100/e/3}getTaskPoints(e,t){var u;const i=[];if(e.length===0)return[];let o=0,n=e[0].x,r=e[0].y,c=[n,r],l=[],h=e[0].t;for(;o<e.length;){const d=e[o],f=d.x-n,g=d.y-r,p=d.z,m=t?this.computRadius(p,t):p;if(l.push({point:new V(f,g,p,e[o].v),radius:m}),o>0&&o<e.length-1){const N=e[o].getAngleByPoints(e[o-1],e[o+1]);if(N<60||N>300){const v=(u=l.pop())==null?void 0:u.point.clone();v&&i.push({taskId:h,pos:c,points:[...l,{point:v,radius:m}]}),n=e[o].x,r=e[o].y,c=[n,r];const T=d.x-n,k=d.y-r;l=[{point:new V(T,k,p),radius:m}],h=Date.now()}}o++}return i.push({taskId:h,pos:c,points:l}),i}updateTempPointsWithPressure(e,t,i){const o=Date.now(),n=this.tmpPoints.length;let r=n;for(let l=0;l<e.length;l+=2){r=Math.min(r,n);const h=this.tmpPoints.length,u=new V(e[l],e[l+1]);if(h===0){this.tmpPoints.push(u);continue}const d=h-1,f=this.tmpPoints[d],g=b.Sub(u,f).uni();if(u.isNear(f,t)){if(f.z<this.MAX_REPEAR){if(f.setz(Math.min(f.z+1,this.MAX_REPEAR)),r=Math.min(r,d),h>1){let N=h-1;for(;N>0;){const v=this.tmpPoints[N].distance(this.tmpPoints[N-1]),T=Math.max(this.tmpPoints[N].z-this.uniThickness*v,0);if(this.tmpPoints[N-1].z>=T)break;this.tmpPoints[N-1].setz(T),r=Math.min(r,N-1),N--}}}else r=1/0;continue}u.setv(g);const p=u.distance(f),m=Math.max(f.z-this.uniThickness*p,0);h>1&&b.Equals(g,f.v,.02)&&(m>0||f.z<=0)&&(i&&f.t&&i.add(f.t),this.tmpPoints.pop(),r=Math.min(d,r)),u.setz(m),this.tmpPoints.push(u)}if(r===1/0)return this.tmpPoints.length;let c=n;if(r===n){c=Math.max(c-1,0);const l=this.tmpPoints[c].t;l&&(i==null||i.add(l))}else{let l=n-1;for(c=r;l>=0;){const h=this.tmpPoints[l].t;if(h&&(i==null||i.add(h),l<=r)){c=l,l=-1;break}l--}}return this.tmpPoints[c].setT(o),c}updateTempPoints(e,t,i){var l;const o=Date.now(),n=this.tmpPoints.length;let r=n;for(let h=0;h<e.length;h+=2){const u=this.tmpPoints.length,d=new V(e[h],e[h+1]);if(u===0){this.tmpPoints.push(d);continue}const f=u-1,g=this.tmpPoints[f],p=b.Sub(d,g).uni();if(d.isNear(g,t/2)){r=Math.min(f,r);continue}b.Equals(p,g.v,.02)&&(i&&g.t&&i.add(g.t),this.tmpPoints.pop(),r=Math.min(f,r)),d.setv(p),this.tmpPoints.push(d)}let c=n;if(r===n){c=Math.max(c-1,0);const h=this.tmpPoints[c].t;h&&(i==null||i.add(h))}else{let h=Math.min(n-1,r);for(c=r;h>=0;){const u=(l=this.tmpPoints[h])==null?void 0:l.t;if(u&&(i==null||i.add(u),h<=r)){c=h,h=-1;break}h--}}return this.tmpPoints[c].setT(o),c}updateTempPointsWithPressureWhenDone(e){const{thickness:t}=this.workOptions,i=e.length,o=this.getMinZ(t);for(let n=0;n<i;n+=2){const r=this.tmpPoints.length,c=new V(e[n],e[n+1]);if(r===0){this.tmpPoints.push(c);continue}const l=r-1,h=this.tmpPoints[l],u=b.Sub(c,h).uni(),d=c.distance(h);if(r>1&&h.z===o)break;if(c.isNear(h,t/2)){if(i<3&&h.z<this.MAX_REPEAR&&(h.setz(Math.min(h.z+1,this.MAX_REPEAR)),r>1)){let g=r-1;for(;g>0;){const p=this.tmpPoints[g].distance(this.tmpPoints[g-1]),m=Math.max(this.tmpPoints[g].z-this.uniThickness*p,-t/4);if(this.tmpPoints[g-1].z>=m)break;this.tmpPoints[g-1].setz(m),g--}}continue}c.setv(u);const f=Math.max(h.z-this.uniThickness*d,o);r>1&&b.Equals(u,h.v,.02)&&h.z<=0&&this.tmpPoints.pop(),c.setz(f),this.tmpPoints.push(c)}}static updateNodeOpt(e){var l,h;const{node:t,opt:i,vNodes:o}=e,{strokeColor:n,strokeType:r}=i,c=o.get(t.name);return n&&(t.tagName==="GROUP"?mM(t)?t.setAttribute("bgcolor",n):t.children.forEach(u=>{u.setAttribute("strokeColor",n),u.getAttribute("fillColor")&&u.setAttribute("fillColor",n)}):(t.setAttribute("strokeColor",n),t.setAttribute("fillColor",n)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=n)),r&&(c!=null&&c.opt)&&((h=c.opt)!=null&&h.strokeType)&&(c.opt.strokeType=r),c&&o.setInfo(t.name,c),Y.updateNodeOpt(e)}}class zo extends Y{constructor(e){super(e);y(this,"toolsType",I.LaserPen);y(this,"canRotate",!1);y(this,"scaleType",re.none);y(this,"syncTimestamp");y(this,"syncIndex",0);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"consumeIndex",0);this.workOptions=e.toolsOpt,this.syncTimestamp=0}combineConsume(){}setWorkOptions(e){super.setWorkOptions(e),this.syncTimestamp=Date.now()}consume(e){const{data:t,isSubWorker:i}=e,{workId:o,op:n}=t;if((n==null?void 0:n.length)===0)return{type:x.None};if(this.updateTempPoints(n||[]),this.consumeIndex>this.tmpPoints.length-4)return{type:x.None};const{strokeColor:r,thickness:c,strokeType:l}=this.workOptions,h=pe(this.tmpPoints,c);let u=!1;const d=this.syncIndex,f=this.tmpPoints.slice(this.consumeIndex);this.consumeIndex=this.tmpPoints.length-1,this.syncTimestamp===0&&(this.syncTimestamp=Date.now());const g={name:o==null?void 0:o.toString(),opacity:1,lineDash:l===ee.Dotted?[1,c*2]:l===ee.LongDotted?[c,c*2]:void 0,strokeColor:r,lineCap:"round",lineWidth:c,anchor:[.5,.5]},p=this.getTaskPoints(f);if(p.length){const N=Date.now();N-this.syncTimestamp>this.syncUnitTime&&(u=!0,this.syncTimestamp=N,this.syncIndex=this.tmpPoints.length),i&&this.draw({attrs:g,tasks:p,isDot:!1,layer:this.drawLayer||this.fullLayer})}const m=[];return this.tmpPoints.slice(d).forEach(N=>{m.push(N.x,N.y)}),{rect:{x:h.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:h.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:h.w*this.fullLayer.worldScaling[0],h:h.h*this.fullLayer.worldScaling[1]},type:x.DrawWork,dataType:B.Local,op:u?m:void 0,index:u?d*2:void 0,...this.baseConsumeResult}}consumeAll(){var n;const e=(n=this.workId)==null?void 0:n.toString();let t;if(this.tmpPoints.length-1>this.consumeIndex){let r=this.tmpPoints.slice(this.consumeIndex);const c=r.length===1,{strokeColor:l,thickness:h,strokeType:u}=this.workOptions;if(c){const g=this.computDotStroke({point:r[0],radius:h/2});r=g.ps,t=g.rect}else t=pe(this.tmpPoints,h);const d={name:e==null?void 0:e.toString(),fillColor:c?l:void 0,opacity:1,lineDash:u===ee.Dotted&&!c?[1,h*2]:u===ee.LongDotted&&!c?[h,h*2]:void 0,strokeColor:l,lineCap:c?void 0:"round",lineWidth:c?0:h,anchor:[.5,.5]},f=this.getTaskPoints(r);f.length&&this.draw({attrs:d,tasks:f,isDot:c,layer:this.drawLayer||this.fullLayer})}const i=[];this.tmpPoints.forEach(r=>{i.push(r.x,r.y)});const o=Re(i);return{rect:t&&{x:t.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:t.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:t.w*this.fullLayer.worldScaling[0],h:t.h*this.fullLayer.worldScaling[1]},type:x.FullWork,dataType:B.Local,ops:o,index:this.syncIndex*2,...this.baseConsumeResult}}clearTmpPoints(){this.tmpPoints.length=0,this.syncTimestamp=0,this.syncIndex=0}consumeService(e){var p;const{op:t,replaceId:i,isFullWork:o}=e,{strokeColor:n,thickness:r,strokeType:c}=this.workOptions;if(!t.length){const m=pe(this.tmpPoints,r);return{x:m.x*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],y:m.y*this.fullLayer.worldScaling[1]+this.fullLayer.worldPosition[1],w:m.w*this.fullLayer.worldScaling[0],h:m.h*this.fullLayer.worldScaling[1]}}const l=Math.max(0,this.tmpPoints.length-1);this.updateTempPoints(t||[]);let h,u=this.tmpPoints.slice(l);const d=u.length===1;if(d){const m=this.computDotStroke({point:u[0],radius:r/2});u=m.ps,h=m.rect}else h=pe(this.tmpPoints,r);const f={name:(p=this.workId)==null?void 0:p.toString(),fillColor:d?n:void 0,opacity:1,lineDash:c===ee.Dotted&&!d?[1,r*2]:c===ee.LongDotted&&!d?[r,r*2]:void 0,strokeColor:n,lineCap:d?void 0:"round",lineWidth:d?0:r,anchor:[.5,.5]},g=this.getTaskPoints(u);if(g.length){const m=o?this.fullLayer:this.drawLayer||this.fullLayer;this.draw({attrs:f,tasks:g,isDot:d,replaceId:i,layer:m})}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(e){const{point:t,radius:i}=e,o={x:t.x-i,y:t.y-i,w:i*2,h:i*2};return{ps:V.GetDotStroke(t,i,8),rect:o}}updateTempPoints(e){const t=this.tmpPoints.length;for(let i=0;i<e.length;i+=2){if(t){const o=this.tmpPoints.slice(-1)[0];o&&o.x===e[i]&&o.y===e[i+1]&&this.tmpPoints.pop()}this.tmpPoints.push(new V(e[i],e[i+1]))}}async draw(e){const{attrs:t,tasks:i,isDot:o,layer:n}=e,{duration:r}=this.workOptions;for(const c of i){const l=new le.Path,{pos:h,points:u}=c;let d;o?d=Je(u,!0):d=Je(u,!1),l.attr({...t,pos:h,d});const{vertex:f,fragment:g}=this.workOptions;if(f&&g){const p=n.renderer.createProgram({vertex:f,fragment:g}),{width:m,height:N}=n.getResolution();l.setUniforms({u_time:0,u_resolution:[m,N]}),l.setProgram(p)}n.appendChild(l),l.transition(r).attr({scale:o?[.1,.1]:[1,1],lineWidth:o?0:1}).then(()=>{l.remove()})}}getTaskPoints(e){var l;const t=[];if(e.length===0)return[];let i=0,o=e[0].x,n=e[0].y,r=[o,n],c=[];for(;i<e.length;){const h=e[i],u=h.x-o,d=h.y-n;if(c.push(new V(u,d)),i>0&&i<e.length-1){const f=e[i].getAngleByPoints(e[i-1],e[i+1]);if(f<60||f>300){const g=(l=c.pop())==null?void 0:l.clone();g&&t.push({pos:r,points:[...c,g]}),o=e[i].x,n=e[i].y,r=[o,n];const p=h.x-o,m=h.y-n;c=[new V(p,m)]}}i++}return t.push({pos:r,points:c}),t}removeLocal(){}removeService(e){let t;const i=[];return this.fullLayer.getElementsByName(e).forEach(o=>{if(o.name===e){const n=o.getBoundingClientRect();t=ce(t,{x:n.x,y:n.y,w:n.width,h:n.height}),i.push(o)}}),i.length&&i.forEach(o=>o.remove()),t}}const yt=class yt extends Y{constructor(e,t){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.none);y(this,"toolsType",I.Eraser);y(this,"serviceWork");y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"worldPosition");y(this,"worldScaling");y(this,"eraserRect");y(this,"eraserPolyline");this.serviceWork=t,this.workOptions=e.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}combineConsume(){}consumeService(){}setWorkOptions(e){super.setWorkOptions(e)}createEraserRect(e){const t=e[0]*this.worldScaling[0]+this.worldPosition[0],i=e[1]*this.worldScaling[1]+this.worldPosition[1],{width:o,height:n}=yt.eraserSizes[this.workOptions.thickness];this.eraserRect={x:t-o*.5,y:i-n*.5,w:o,h:n},this.eraserPolyline=[this.eraserRect.x,this.eraserRect.y,this.eraserRect.x+this.eraserRect.w,this.eraserRect.y+this.eraserRect.h]}computRectCenterPoints(){const e=this.tmpPoints.slice(-2);if(this.tmpPoints.length===4){const t=new b(this.tmpPoints[0],this.tmpPoints[1]),i=new b(this.tmpPoints[2],this.tmpPoints[3]),o=b.Sub(i,t).uni(),n=b.Dist(t,i),{width:r,height:c}=yt.eraserSizes[this.workOptions.thickness],l=Math.min(r,c),h=Math.round(n/l);if(h>1){const u=[];for(let d=0;d<h;d++){const f=b.Mul(o,d*l);u.push(this.tmpPoints[0]+f.x,this.tmpPoints[1]+f.y)}return u.concat(e)}}return e}isNear(e,t){const i=new b(e[0],e[1]),o=new b(t[0],t[1]),{width:n,height:r}=yt.eraserSizes[this.workOptions.thickness];return b.Dist(i,o)<Math.hypot(n,r)*.5}remove(e){const{curNodeMap:t,removeIds:i}=e;let o;for(const n of t.values())if(n.rect&&this.eraserRect&&this.eraserPolyline&&Rt(this.eraserRect,n.rect)){const{op:r}=n,c=[],l=[];for(let u=0;u<r.length;u+=3){const d=new b(r[u]*this.worldScaling[0]+this.worldPosition[0],r[u+1]*this.worldScaling[1]+this.worldPosition[1],r[u+2]);l.push(d),c.push(new V(d.x,d.y))}const h=c.length&&pe(c)||n.rect;Rt(h,this.eraserRect)&&(l.length>1?Ws.polyline(l.map(d=>d.XY),this.eraserPolyline).length&&i.add(n.name):i.add(n.name),o=ce(o,n.rect||h))}return i.forEach(n=>{var c;const r=this.fullLayer.getElementsByName(n);this.fullLayer.removeChild(r[0]),(c=this.vNodes)==null||c.delete(n)}),o&&(o.x-=Y.SafeBorderPadding,o.y-=Y.SafeBorderPadding,o.w+=Y.SafeBorderPadding*2,o.h+=Y.SafeBorderPadding*2),o}consume(e){const{op:t,disableEraseImage:i,disableEraseText:o}=e.data;if(!t||t.length===0)return{type:x.None,...this.baseConsumeResult};const n=this.tmpPoints.length;if(n>1&&this.isNear([t[0],t[1]],[this.tmpPoints[n-2],this.tmpPoints[n-1]]))return{type:x.None,...this.baseConsumeResult};n<3?this.tmpPoints.push(t[0],t[1]):this.tmpPoints.splice(2,2,t[0],t[1]);const r=this.computRectCenterPoints();let c;const l=new Set;if(!this.vNodes)return{type:x.None,...this.baseConsumeResult};const h=this.getCanEraserNodeMap(this.vNodes.getCanEraserNodes(this.vNodes.curNodeMap,{disableEraseImage:i,disableEraseText:o}));for(let u=0;u<r.length-1;u+=2){this.createEraserRect(r.slice(u,u+2));const d=this.remove({curNodeMap:h,removeIds:l});c=ce(c,d)}return c&&l.size?{type:x.RemoveNode,rect:c,removeIds:[...l]}:{type:x.None,...this.baseConsumeResult}}consumeAll(e){return this.consume(e)}clearTmpPoints(){this.tmpPoints.length=0}getCanEraserNodeMap(e){var t;if(this.serviceWork){const i=new Map(e),o=this.serviceWork.selectorWorkShapes,n=this.serviceWork.workShapes;for(const r of o.values())if((t=r.selectIds)!=null&&t.length)for(const c of r.selectIds)i.delete(c);for(const r of n.keys())i.delete(r);return i}return e}};y(yt,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50}),Object.freeze({width:48,height:74})]));let Xt=yt;const Ee="++",Q="selector",Qt="all";var Rp="__lodash_hash_undefined__";function Wp(a){return this.__data__.set(a,Rp),this}var Yp=Wp;function Up(a){return this.__data__.has(a)}var Bp=Up,Fp=io,Vp=Yp,$p=Bp;function Jt(a){var s=-1,e=a==null?0:a.length;for(this.__data__=new Fp;++s<e;)this.add(a[s])}Jt.prototype.add=Jt.prototype.push=Vp;Jt.prototype.has=$p;var Js=Jt;function Hp(a,s){for(var e=-1,t=a==null?0:a.length;++e<t;)if(s(a[e],e,a))return!0;return!1}var Qp=Hp;function Gp(a,s){return a.has(s)}var Ks=Gp,Zp=Js,qp=Qp,Xp=Ks,Jp=1,Kp=2;function _p(a,s,e,t,i,o){var n=e&Jp,r=a.length,c=s.length;if(r!=c&&!(n&&c>r))return!1;var l=o.get(a),h=o.get(s);if(l&&h)return l==s&&h==a;var u=-1,d=!0,f=e&Kp?new Zp:void 0;for(o.set(a,s),o.set(s,a);++u<r;){var g=a[u],p=s[u];if(t)var m=n?t(p,g,u,s,a,o):t(g,p,u,a,s,o);if(m!==void 0){if(m)continue;d=!1;break}if(f){if(!qp(s,function(N,v){if(!Xp(f,v)&&(g===N||i(g,N,e,t,o)))return f.push(v)})){d=!1;break}}else if(!(g===p||i(g,p,e,t,o))){d=!1;break}}return o.delete(a),o.delete(s),d}var Po=_p;function ef(a){var s=-1,e=Array(a.size);return a.forEach(function(t,i){e[++s]=[i,t]}),e}var tf=ef;function sf(a){var s=-1,e=Array(a.size);return a.forEach(function(t){e[++s]=t}),e}var _s=sf,Li=Wt,zi=So,of=Ys,nf=Po,rf=tf,af=_s,cf=1,lf=2,hf="[object Boolean]",uf="[object Date]",df="[object Error]",pf="[object Map]",ff="[object Number]",gf="[object RegExp]",yf="[object Set]",Mf="[object String]",mf="[object Symbol]",wf="[object ArrayBuffer]",vf="[object DataView]",Pi=Li?Li.prototype:void 0,vs=Pi?Pi.valueOf:void 0;function If(a,s,e,t,i,o,n){switch(e){case vf:if(a.byteLength!=s.byteLength||a.byteOffset!=s.byteOffset)return!1;a=a.buffer,s=s.buffer;case wf:return!(a.byteLength!=s.byteLength||!o(new zi(a),new zi(s)));case hf:case uf:case ff:return of(+a,+s);case df:return a.name==s.name&&a.message==s.message;case gf:case Mf:return a==s+"";case pf:var r=rf;case yf:var c=t&cf;if(r||(r=af),a.size!=s.size&&!c)return!1;var l=n.get(a);if(l)return l==s;t|=lf,n.set(a,s);var h=nf(r(a),r(s),t,i,o,n);return n.delete(a),h;case mf:if(vs)return vs.call(a)==vs.call(s)}return!1}var Nf=If,Di=vo,Sf=1,Tf=Object.prototype,kf=Tf.hasOwnProperty;function Cf(a,s,e,t,i,o){var n=e&Sf,r=Di(a),c=r.length,l=Di(s),h=l.length;if(c!=h&&!n)return!1;for(var u=c;u--;){var d=r[u];if(!(n?d in s:kf.call(s,d)))return!1}var f=o.get(a),g=o.get(s);if(f&&g)return f==s&&g==a;var p=!0;o.set(a,s),o.set(s,a);for(var m=n;++u<c;){d=r[u];var N=a[d],v=s[d];if(t)var T=n?t(v,N,d,s,a,o):t(N,v,d,a,s,o);if(!(T===void 0?N===v||i(N,v,e,t,o):T)){p=!1;break}m||(m=d=="constructor")}if(p&&!m){var k=a.constructor,S=s.constructor;k!=S&&"constructor"in a&&"constructor"in s&&!(typeof k=="function"&&k instanceof k&&typeof S=="function"&&S instanceof S)&&(p=!1)}return o.delete(a),o.delete(s),p}var bf=Cf,Is=oo,xf=Po,Lf=Nf,zf=bf,Ai=ds,ji=Yt,Ei=Bs,Pf=uo,Df=1,Oi="[object Arguments]",Ri="[object Array]",Ft="[object Object]",Af=Object.prototype,Wi=Af.hasOwnProperty;function jf(a,s,e,t,i,o){var n=ji(a),r=ji(s),c=n?Ri:Ai(a),l=r?Ri:Ai(s);c=c==Oi?Ft:c,l=l==Oi?Ft:l;var h=c==Ft,u=l==Ft,d=c==l;if(d&&Ei(a)){if(!Ei(s))return!1;n=!0,h=!1}if(d&&!h)return o||(o=new Is),n||Pf(a)?xf(a,s,e,t,i,o):Lf(a,s,c,e,t,i,o);if(!(e&Df)){var f=h&&Wi.call(a,"__wrapped__"),g=u&&Wi.call(s,"__wrapped__");if(f||g){var p=f?a.value():a,m=g?s.value():s;return o||(o=new Is),i(p,m,e,t,o)}}return d?(o||(o=new Is),zf(a,s,e,t,i,o)):!1}var Ef=jf,Of=Ef,Yi=qe;function Do(a,s,e,t,i){return a===s?!0:a==null||s==null||!Yi(a)&&!Yi(s)?a!==a&&s!==s:Of(a,s,e,t,Do,i)}var Rf=Do,Wf=Rf;function Yf(a,s){return Wf(a,s)}var Uf=Yf;const tt=St(Uf),os=class os extends Y{constructor(e){super(e);y(this,"toolsType",I.Selector);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"vNodes");y(this,"selectIds");y(this,"selectorColor");y(this,"strokeColor");y(this,"fillColor");y(this,"oldSelectRect");y(this,"canRotate",!1);y(this,"canTextEdit",!1);y(this,"canLock",!1);y(this,"scaleType",re.all);y(this,"toolsTypes");y(this,"shapeOpt");y(this,"textOpt");y(this,"isLocked");y(this,"thickness");y(this,"strokeType");y(this,"useStroke");this.workOptions=e.toolsOpt,this.vNodes=e.vNodes}computSelector(e=!0){const t=pe(this.tmpPoints);if(t.w===0||t.h===0)return{selectIds:[],intersectRect:void 0,subNodeMap:new Map};const{rectRange:i,nodeRange:o}=this.vNodes.getRectIntersectRange(t,e);return{selectIds:[...o.keys()],intersectRect:i,subNodeMap:o}}updateTempPoints(e){const t=this.tmpPoints.length,i=e.length;if(i>1){const o=new V(e[i-2]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],e[i-1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]);t===2?this.tmpPoints.splice(1,1,o):this.tmpPoints.push(o)}}drawSelector(e){const{drawRect:t,subNodeMap:i,selectorId:o,layer:n,isService:r}=e,c=new le.Group({pos:[t.x,t.y],anchor:[0,0],size:[t.w,t.h],id:o,name:o,zIndex:9999}),l=[];if(r){const h=new le.Rect({normalize:!0,pos:[t.w/2,t.h/2],lineWidth:1,strokeColor:this.selectorColor||this.workOptions.strokeColor,width:t.w,height:t.h,name:os.selectorBorderId});l.push(h)}i.forEach((h,u)=>{const d=[h.rect.x+h.rect.w/2-t.x,h.rect.y+h.rect.h/2-t.y],f=new le.Rect({normalize:!0,pos:d,lineWidth:1,strokeColor:i.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(f)}),l&&c.append(...l),(n==null?void 0:n.parent).appendChild(c)}draw(e,t,i,o=!1){var c,l;const{intersectRect:n,subNodeMap:r}=i;(l=(c=t.parent)==null?void 0:c.getElementById(e))==null||l.remove(),n&&this.drawSelector({drawRect:n,subNodeMap:r,selectorId:e,layer:t,isService:o})}getSelecteorInfo(e){this.scaleType=re.all,this.canRotate=!1,this.textOpt=void 0,this.strokeColor=void 0,this.fillColor=void 0,this.canTextEdit=!1,this.canLock=!1,this.isLocked=!1,this.toolsTypes=void 0,this.shapeOpt=void 0,this.thickness=void 0,this.strokeType=void 0,this.useStroke=!1;const t=new Set;let i,o=!0;for(const n of e.values()){const{opt:r,canRotate:c,scaleType:l,toolsType:h}=n;this.selectorColor=this.workOptions.strokeColor,r.strokeColor&&(this.strokeColor=r.strokeColor),r.fillColor&&(this.fillColor=r.fillColor),r.textOpt&&(this.textOpt=r.textOpt),r.thickness&&(this.thickness=r.thickness),h!==I.Pencil&&(o=!1),r.strokeType&&(this.strokeType=r.strokeType),h===I.SpeechBalloon&&(t.add(h),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.placement=r.placement),h===I.Polygon&&(t.add(h),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=r.vertices),h===I.Star&&(t.add(h),this.shapeOpt||(this.shapeOpt={}),this.shapeOpt.vertices=r.vertices,this.shapeOpt.innerRatio=r.innerRatio,this.shapeOpt.innerVerticeStep=r.innerVerticeStep),h===I.Text&&(this.textOpt=r),e.size===1&&(this.textOpt&&(this.canTextEdit=!0),this.canRotate=c,this.scaleType=l),l===re.none&&(this.scaleType=l),h===I.Image&&(i=n)}o&&(this.useStroke=!0),t.size&&(this.toolsTypes=[...t]),i&&(e.size===1?(this.canLock=!0,i.opt.locked&&(this.isLocked=!0,this.scaleType=re.none,this.canRotate=!1,this.textOpt=void 0,this.fillColor=void 0,this.selectorColor="rgb(177,177,177)",this.strokeColor=void 0,this.canTextEdit=!1,this.thickness=void 0,this.strokeType=void 0,this.useStroke=void 0)):e.size>1&&!i.opt.locked&&(this.canLock=!1,this.canRotate=!1))}getChildrenPoints(){var e,t;if(this.scaleType===re.both&&((e=this.selectIds)==null?void 0:e.length)===1){const i=this.selectIds[0],o=(t=this.vNodes.get(i))==null?void 0:t.op;if(o){const n=[];for(let r=0;r<o.length;r+=3)n.push([o[r],o[r+1]]);return n}}}consume(e){const{op:t,workState:i}=e.data;let o=this.oldSelectRect;if(i===P.Start&&(o=this.unSelectedAllIds()),!(t!=null&&t.length)||!this.vNodes.curNodeMap.size)return{type:x.None};this.updateTempPoints(t);const n=this.computSelector();if(this.selectIds&&tt(this.selectIds,n.selectIds))return{type:x.None};this.selectIds=n.selectIds;const r=n.intersectRect;this.getSelecteorInfo(n.subNodeMap),this.draw(Q,this.fullLayer,n),this.oldSelectRect=r;const c=this.getChildrenPoints();return{type:x.Select,dataType:B.Local,rect:ce(r,o),selectIds:n.selectIds,selectRect:r,selectorColor:this.selectorColor,strokeColor:this.strokeColor,fillColor:this.fillColor,textOpt:this.textOpt,canTextEdit:this.canTextEdit,canRotate:this.canRotate,canLock:this.canLock,scaleType:this.scaleType,willSyncService:!0,points:c,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType,...this.baseConsumeResult}}consumeAll(){var t,i;let e=this.oldSelectRect;if(!((t=this.selectIds)!=null&&t.length)&&this.tmpPoints[0]&&this.selectSingleTool(this.tmpPoints[0].XY,Q,!1),(i=this.selectIds)!=null&&i.length&&(e=this.selectedByIds(this.selectIds)),e){const o=this.getChildrenPoints();return{type:x.Select,dataType:B.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:o,isLocked:this.isLocked,toolsTypes:this.toolsTypes,shapeOpt:this.shapeOpt,thickness:this.thickness,useStroke:this.useStroke,strokeType:this.strokeType,...this.baseConsumeResult}}return{type:x.None}}consumeService(){}clearTmpPoints(){this.tmpPoints.length=0}clearSelectData(){this.selectIds=void 0,this.oldSelectRect=void 0}selectSingleTool(e,t=Q,i=!1){if(e.length===2){const o=e[0],n=e[1];let r;const{nodeRange:c}=this.vNodes.getRectIntersectRange({x:o,y:n,w:0,h:0},!1),l=[...c.values()].sort((h,u)=>(u.opt.zIndex||0)-(h.opt.zIndex||0));for(const h of l){const u=this.fullLayer.getElementsByName(h.name);if(Bo(u).find(f=>f.isPointCollision(o,n))){r=h;break}}if(r){const h=r.name;if(!tt(this.oldSelectRect,r.rect)){const u=new Map([[h,r]]);this.getSelecteorInfo(u),this.draw(t,this.fullLayer,{intersectRect:r.rect,subNodeMap:u,selectIds:this.selectIds||[]},i)}this.selectIds=[h],this.oldSelectRect=r.rect}}}unSelectedAllIds(){let e;for(const[t,i]of this.vNodes.curNodeMap.entries())i.isSelected&&(e=ce(e,i.rect),this.vNodes.unSelected(t));return e}unSelectedByIds(e){let t;for(const i of e){const o=this.vNodes.get(i);o&&o.isSelected&&(t=ce(t,o.rect),this.vNodes.unSelected(i))}return t}selectedByIds(e){let t;for(const i of e){const o=this.vNodes.get(i);o&&(t=ce(t,o.rect),this.vNodes.selected(i))}return t}getSelectorRect(e,t){var r;let i;const o=(r=e.parent)==null?void 0:r.getElementById(t),n=o==null?void 0:o.getBoundingClientRect();return n&&(i=ce(i,{x:Math.floor(n.x),y:Math.floor(n.y),w:Math.floor(n.width+1),h:Math.floor(n.height+1)})),i}isCanFillColor(e){return e===I.Ellipse||e===I.Triangle||e===I.Rectangle||e===I.Polygon||e===I.Star||e===I.SpeechBalloon}async updateSelector(e){var S;const{updateSelectorOpt:t,selectIds:i,vNodes:o,willSerializeData:n,worker:r,offset:c}=e,l=this.fullLayer;if(!l)return;let h;const u=new Map,{originPoint:d,workState:f,angle:g,translate:p,dir:m,scale:N}=t;c&&(p?t.translate=[p[0]+c[0],p[1]+c[1]]:t.translate=c);let v;if(d||p||Ae(g)){if(f===P.Start&&i)return o.setTargetAssignKeys(i),{type:x.Select,dataType:B.Local,selectRect:this.oldSelectRect,rect:this.oldSelectRect};if(v=o.getLastTarget(),!v)return}if(i)for(const w of i){const C=o.get(w);if(C){const{toolsType:L,opt:j}=C,E=(l==null?void 0:l.getElementsByName(w))[0];if(E){let A=!1,W=!1;const z={...t};let O;if(L){z.thickness&&C.opt.thickness&&(A=C.opt.thickness!==z.thickness),z.strokeType&&((S=C.opt)!=null&&S.strokeType)&&(W=C.opt.strokeType!==z.strokeType),O=v==null?void 0:v.get(w);const se=Uo(L);if(se==null||se.updateNodeOpt({node:E,opt:z,vNodes:o,willSerializeData:n,targetNode:O}),C&&r&&(n&&(z.angle||z.translate)||z.originPoint&&z.scenePoint&&z.scale||z.pointMap&&z.pointMap.has(w)||L===I.Text&&(z.fontSize||z.translate||z.textInfos&&z.textInfos.get(w))||L===I.Image&&(z.angle||z.translate||z.scale||z.strokeColor&&j.type===lt.Iconify)||L===z.toolsType&&z.willRefresh||A||W)){const _=r.createWorkShapeNode({workId:w,toolsType:L,toolsOpt:C.opt});_==null||_.setWorkId(w);let H;if(L===I.Image)H=await _.consumeServiceAsync({isFullWork:!0,replaceId:w,worker:r});else if(L===I.Text)H=await _.consumeServiceAsync({isFullWork:!0,replaceId:w});else try{H=_==null?void 0:_.consumeService({op:C.op,isFullWork:!0,replaceId:w})}catch{continue}H&&(C.rect=H)}C&&(u.set(w,C),h=ce(h,C.rect))}}}}v&&f===P.Done&&(o.deleteLastTarget(),v=void 0);const T=h;if(d&&p&&N&&m&&T&&!c){const w=[[T.x,T.y],[T.x+T.w,T.y],[T.x+T.w,T.y+T.h],[T.x,T.y+T.h]];let C;switch(m){case"top":case"topLeft":case"left":p[0]>0&&p[1]>0?C=w[0]:p[0]>0?C=w[3]:p[1]>0?C=w[1]:C=w[2];break;case"topRight":p[0]<0&&p[1]>0?C=w[1]:p[0]<0?C=w[2]:p[1]>0?C=w[0]:C=w[3];break;case"right":case"bottomRight":case"bottom":p[0]<0&&p[1]<0?C=w[2]:p[0]<0?C=w[1]:p[1]<0?C=w[3]:C=w[0];break;case"bottomLeft":p[0]>0&&p[1]<0?C=w[3]:p[0]>0?C=w[0]:p[1]<0?C=w[2]:C=w[1];break}const L=C&&[d[0]-C[0],d[1]-C[1]]||[0,0];if(!tt(L,[0,0]))return await this.updateSelector({...e,updateSelectorOpt:{},offset:L})}this.getSelecteorInfo(u),this.draw(Q,l,{selectIds:i||[],subNodeMap:u,intersectRect:T});const k=ce(this.oldSelectRect,T);return this.oldSelectRect=T,{type:x.Select,dataType:B.Local,selectRect:T,renderRect:h,rect:ce(k,T),selectIds:i}}blurSelector(){const e=this.unSelectedAllIds();return{type:x.Select,dataType:B.Local,rect:e,selectIds:[],willSyncService:!0}}getRightServiceId(e){return e.replace(Ee,"-")}selectServiceNode(e,t,i){const{selectIds:o}=t,n=this.getRightServiceId(e),r=this.getSelectorRect(this.fullLayer,n);let c;const l=new Map;return o==null||o.forEach(h=>{const u=this.vNodes.get(h);u&&(c=ce(c,u.rect),l.set(h,u))}),this.getSelecteorInfo(l),this.draw(n,this.fullLayer,{intersectRect:c,selectIds:o||[],subNodeMap:l},i),ce(c,r)}reRenderSelector(){var i;let e;const t=new Map;return(i=this.selectIds)==null||i.forEach(o=>{const n=this.vNodes.get(o);n&&(e=ce(e,n.rect),t.set(o,n))},this),this.getSelecteorInfo(t),this.draw(Q,this.fullLayer,{intersectRect:e,subNodeMap:t,selectIds:this.selectIds||[]}),this.oldSelectRect=e,e}updateSelectIds(e){var n;let t;const i=(n=this.selectIds)==null?void 0:n.filter(r=>!e.includes(r));if(i!=null&&i.length&&(t=this.unSelectedByIds(i)),e.length){const r=this.selectedByIds(e);t=ce(t,r)}this.selectIds=e;const o=this.reRenderSelector();return{bgRect:t,selectRect:o}}cursorHover(e){var n,r;const t=this.oldSelectRect;this.selectIds=[];const i=(n=this.workId)==null?void 0:n.toString(),o=[e[0]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[0],e[1]*this.fullLayer.worldScaling[0]+this.fullLayer.worldPosition[1]];if(this.selectSingleTool(o,i,!0),this.oldSelectRect&&!tt(t,this.oldSelectRect))return{type:x.CursorHover,dataType:B.Local,rect:ce(t,this.oldSelectRect),selectorColor:this.selectorColor,willSyncService:!1};if((r=this.selectIds)!=null&&r.length||(this.oldSelectRect=void 0),t&&!this.oldSelectRect)return this.cursorBlur(),{type:x.CursorHover,dataType:B.Local,rect:t,selectorColor:this.selectorColor,willSyncService:!1}}cursorBlur(){var t,i;this.selectIds=[];const e=(t=this.workId)==null?void 0:t.toString();((i=this.fullLayer)==null?void 0:i.parent).children.forEach(o=>{o.name===e&&o.remove()})}};y(os,"selectorBorderId","selector-border");let Kt=os;class Ao extends Y{constructor(e){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.both);y(this,"toolsType",I.Arrow);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"oldRect");y(this,"arrowTipWidth");y(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.arrowTipWidth=this.workOptions.thickness*4,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n}=e,r=this.workId,{op:c}=t,l=c==null?void 0:c.length;if(!l||l<2)return{type:x.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new V(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:x.None};let u;if(o||n){const f=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:r,layer:f})}if(!o){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{...this.baseConsumeResult,type:x.DrawWork,dataType:B.Local,op:this.tmpPoints.map(g=>[...g.XY,0]).flat(1),isSync:!0,index:0}):{type:x.None}}const d=ce(u,this.oldRect);return this.oldRect=u,{rect:d,...this.baseConsumeResult,type:x.DrawWork,dataType:B.Local}}consumeAll(){var r;const e=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[e]};const t=this.fullLayer,i=this.draw({workId:e,layer:t});this.oldRect=i;const o=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Re(o);return(r=this.vNodes)==null||r.setInfo(e,{rect:i,op:o,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:Y.getCenterPos(i,t)}),{rect:i,...this.baseConsumeResult,type:x.FullWork,dataType:B.Local,ops:n,isSync:!0}}draw(e){const{workId:t,layer:i}=e,{strokeColor:o,thickness:n,zIndex:r,scale:c,rotate:l,translate:h,strokeType:u,eraserlines:d}=this.workOptions,f=i.worldPosition,g=i.worldScaling,{points:p,pos:m,rect:N,isTriangle:v,trianglePoints:T,trianglePos:k}=this.computDrawPoints(n),S=[N.x+N.w/2,N.y+N.h/2],w={pos:S,name:t,id:t,zIndex:r,anchor:[.5,.5],size:[N.w,N.h]};c&&(w.scale=c),l&&(w.rotate=l),h&&(w.translate=h);const C=new le.Group(w),L={points:T,pos:[k[0]-S[0],k[1]-S[1]],fillColor:o,strokeColor:o,lineWidth:0,normalize:!1},j=new le.Polyline(L);if(C.append(j),!v&&p&&m){const E={points:p,pos:[m[0]-S[0],m[1]-S[1]],fillColor:o,strokeColor:o,lineDash:u===ee.Dotted&&!v?[1,n*2]:u===ee.LongDotted&&!v?[n,n*2]:void 0,lineCap:u===ee.Normal?void 0:"round",lineWidth:n,normalize:!1},A=new le.Polyline(E);C.append(A)}if(d&&(this.scaleType=re.proportional,this.drawEraserlines({group:C,eraserlines:d,pos:S,layer:i})),this.replace(i,t,C),c||l||h){const E=C.getBoundingClientRect();return{x:Math.floor(E.x-Y.SafeBorderPadding),y:Math.floor(E.y-Y.SafeBorderPadding),w:Math.floor(E.width+Y.SafeBorderPadding*2),h:Math.floor(E.height+Y.SafeBorderPadding*2)}}return{x:Math.floor(N.x*g[0]+f[0]-Y.SafeBorderPadding),y:Math.floor(N.y*g[1]+f[1]-Y.SafeBorderPadding),w:Math.floor(N.w*g[0]+2*Y.SafeBorderPadding),h:Math.floor(N.h*g[1]+2*Y.SafeBorderPadding)}}computDrawPoints(e){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.arrowTipWidth?this.computFullArrowPoints(e):this.computTrianglePoints()}computFullArrowPoints(e){const t=b.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),i=b.Per(t).mul(e/2),o=V.Sub(this.tmpPoints[0],i),n=V.Add(this.tmpPoints[0],i),r=b.Mul(t,this.arrowTipWidth),c=b.Sub(this.tmpPoints[1],r),l=V.Sub(c,i),h=V.Add(c,i),u=b.Per(t).mul(e*1.5),d=V.Sub(c,u),f=V.Add(c,u),g=[this.tmpPoints[0],c],p=[d,this.tmpPoints[1],f],m=[o,n,...p,l,h];return{trianglePoints:p.map(N=>V.Sub(N,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,points:g.map(N=>V.Sub(N,this.tmpPoints[0]).XY).flat(1),rect:pe(m),isTriangle:!1,pos:this.tmpPoints[0].XY}}computTrianglePoints(){const e=b.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),t=this.tmpPoints[1].distance(this.tmpPoints[0]),i=b.Per(e).mul(Math.floor(t*3/8)),o=V.Sub(this.tmpPoints[0],i),n=V.Add(this.tmpPoints[0],i),r=[o,this.tmpPoints[1],n];return{trianglePoints:r.map(c=>V.Sub(c,this.tmpPoints[1]).XY).flat(1),trianglePos:this.tmpPoints[1].XY,rect:pe(r),isTriangle:!0}}updateTempPoints(e){const t=e.slice(-2),i=new V(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(i,n))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(e){var c,l;const{op:t,isFullWork:i}=e,o=(c=this.workId)==null?void 0:c.toString();if(!o)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new V(t[h],t[h+1],t[h+2]));const n=i?this.fullLayer:this.drawLayer||this.fullLayer,r=this.draw({workId:o,layer:n});return this.oldRect=r,(l=this.vNodes)==null||l.setInfo(o,{rect:r,op:t,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:Y.getCenterPos(r,n)}),r}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var l,h;const{node:t,opt:i,vNodes:o}=e,{strokeColor:n,strokeType:r}=i,c=o.get(t.name);return n&&(t.tagName==="GROUP"?t.children.forEach(u=>{u.setAttribute("strokeColor",n),u.getAttribute("fillColor")&&u.setAttribute("fillColor",n)}):(t.setAttribute("strokeColor",n),t.setAttribute("fillColor",n)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=n)),r&&(c!=null&&c.opt)&&((h=c.opt)!=null&&h.strokeType)&&(c.opt.strokeType=r),c&&o.setInfo(t.name,c),Y.updateNodeOpt(e)}}class jo extends Y{constructor(e){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.all);y(this,"toolsType",I.Ellipse);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"oldRect");y(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n}=e,r=this.workId,{op:c}=t,l=c==null?void 0:c.length;if(!l||l<2)return{type:x.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new V(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:x.None};let u;if(o||n){const f=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:r,layer:f,isDrawing:!0})}if(!o){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:x.DrawWork,dataType:B.Local,...this.baseConsumeResult,op:this.tmpPoints.map(g=>[...g.XY,0]).flat(1),isSync:!0,index:0}):{type:x.None}}const d=ce(u,this.oldRect);return this.oldRect=u,{rect:d,type:x.DrawWork,dataType:B.Local,...this.baseConsumeResult}}consumeAll(){var r;const e=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[e]};const t=this.fullLayer,i=this.draw({workId:e,layer:t,isDrawing:!1});this.oldRect=i;const o=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Re(o);return(r=this.vNodes)==null||r.setInfo(e,{rect:i,op:o,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:i&&Y.getCenterPos(i,t)}),{rect:i,type:x.FullWork,dataType:B.Local,...this.baseConsumeResult,ops:n,isSync:!0}}draw(e){const{workId:t,layer:i,isDrawing:o}=e,{strokeColor:n,fillColor:r,thickness:c,zIndex:l,scale:h,rotate:u,translate:d,strokeType:f,eraserlines:g}=this.workOptions,p=i.worldScaling,{radius:m,rect:N,pos:v}=this.computDrawPoints(c),T={pos:v,name:t,id:t,radius:m,lineWidth:c,fillColor:r!=="transparent"&&r||void 0,strokeColor:n,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:f===ee.Dotted?[1,c*2]:f===ee.LongDotted?[c,c*2]:void 0},k={name:t,id:t,zIndex:l,pos:v,anchor:[.5,.5],size:[N.w,N.h]};h&&(k.scale=h),u&&(k.rotate=u),d&&(k.translate=d);const S=new le.Group(k);if(o){const L=new le.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:n,lineWidth:1,scale:[1/p[0],1/p[1]]});S.append(L)}const w=new le.Ellipse({...T,pos:[0,0]});S.append(w),g&&(this.scaleType=re.proportional,this.drawEraserlines({group:S,eraserlines:g,pos:v,layer:i})),this.replace(i,t,S);const C=S.getBoundingClientRect();return{x:Math.floor(C.x-Y.SafeBorderPadding),y:Math.floor(C.y-Y.SafeBorderPadding),w:Math.floor(C.width+Y.SafeBorderPadding*2),h:Math.floor(C.height+Y.SafeBorderPadding*2)}}computDrawPoints(e){const t=pe(this.tmpPoints),i=pe(this.tmpPoints,e),o=[Math.floor(t.x+t.w/2),Math.floor(t.y+t.h/2)];return{rect:i,pos:o,radius:[Math.floor(t.w/2),Math.floor(t.h/2)]}}updateTempPoints(e){const t=e.slice(-2),i=new V(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(i,n))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(e){var c,l;const{op:t,isFullWork:i}=e,o=(c=this.workId)==null?void 0:c.toString();if(!o)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new V(t[h],t[h+1],t[h+2]));const n=i?this.fullLayer:this.drawLayer||this.fullLayer,r=this.draw({workId:o,layer:n,isDrawing:!1});return this.oldRect=r,(l=this.vNodes)==null||l.setInfo(o,{rect:r,op:t,opt:this.workOptions,toolsType:this.toolsType,canRotate:this.canRotate,scaleType:this.scaleType,centerPos:Y.getCenterPos(r,n)}),r}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var u,d,f;const{node:t,opt:i,vNodes:o}=e,{strokeColor:n,fillColor:r,strokeType:c}=i,l=o.get(t.name);let h=t;return t.tagName==="GROUP"&&(h=t.children[0]),n&&(h.setAttribute("strokeColor",n),(u=l==null?void 0:l.opt)!=null&&u.strokeColor&&(l.opt.strokeColor=n)),r&&(r==="transparent"?h.setAttribute("fillColor","rgba(0,0,0,0)"):h.setAttribute("fillColor",r),(d=l==null?void 0:l.opt)!=null&&d.fillColor&&(l.opt.fillColor=r)),c&&(l!=null&&l.opt)&&((f=l.opt)!=null&&f.strokeType)&&(l.opt.strokeType=c),l&&o.setInfo(t.name,l),Y.updateNodeOpt(e)}}class Eo extends Y{constructor(e){super(e);y(this,"canRotate",!0);y(this,"scaleType",re.all);y(this,"toolsType",I.Rectangle);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"oldRect");y(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}transformData(){const e=pe(this.tmpPoints);return[[e.x,e.y,0],[e.x+e.w,e.y,0],[e.x+e.w,e.y+e.h,0],[e.x,e.y+e.h,0]]}computDrawPoints(e){const{thickness:t}=this.workOptions,i=[];for(const r of e)i.push(new b(...r));const o=pe(i,t),n=[o.x+o.w/2,o.y+o.h/2];return{rect:o,pos:n,points:i.map(r=>r.XY).flat(1)}}consume(e){const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n}=e,r=this.workId,{op:c}=t,l=c==null?void 0:c.length;if(!l||l<2)return{type:x.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new V(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:x.None};const u=this.transformData();let d;if(o||n){const g=i?this.fullLayer:this.drawLayer||this.fullLayer;d=this.draw({ps:u,workId:r,layer:g,isDrawing:!0})}if(!o){const g=Date.now();return g-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=g,{type:x.DrawWork,dataType:B.Local,op:u.flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:x.None}}const f=ce(d,this.oldRect);return this.oldRect=d,{rect:f,type:x.DrawWork,dataType:B.Local,...this.baseConsumeResult}}consumeAll(){var c;const e=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[e]};const t=this.transformData(),i=this.fullLayer,o=this.draw({ps:t,workId:e,layer:i,isDrawing:!1});this.oldRect=o;const n=t.flat(1),r=Re(n);return(c=this.vNodes)==null||c.setInfo(e,{rect:o,op:n,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:o&&Y.getCenterPos(o,i)}),{rect:o,type:x.FullWork,dataType:B.Local,ops:r,isSync:!0,...this.baseConsumeResult}}draw(e){const{workId:t,layer:i,isDrawing:o,ps:n,replaceId:r}=e,{strokeColor:c,fillColor:l,thickness:h,zIndex:u,scale:d,rotate:f,translate:g,strokeType:p,eraserlines:m}=this.workOptions,N=i.worldPosition,v=i.worldScaling,{points:T,rect:k,pos:S}=this.computDrawPoints(n),w={close:!0,normalize:!0,points:T,lineWidth:h,fillColor:l!=="transparent"&&l||void 0,strokeColor:c,lineJoin:"round",lineCap:"round",lineDash:p===ee.Dotted?[1,h*2]:p===ee.LongDotted?[h,h*2]:void 0},C={x:Math.floor(k.x*v[0]+N[0]-Y.SafeBorderPadding),y:Math.floor(k.y*v[1]+N[1]-Y.SafeBorderPadding),w:Math.floor(k.w*v[0]+2*Y.SafeBorderPadding),h:Math.floor(k.h*v[0]+2*Y.SafeBorderPadding)},L=new le.Group({name:t,id:t,zIndex:u,pos:S,anchor:[.5,.5],size:[k.w,k.h],scale:d,rotate:f,translate:g}),j=new le.Polyline({...w,pos:[0,0]});if(L.appendChild(j),o){const E=new le.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:c,lineWidth:1,scale:[1/v[0],1/v[1]]});L.appendChild(E)}if(m&&(this.scaleType=re.proportional,this.drawEraserlines({group:L,eraserlines:m,pos:S,layer:i})),this.replace(i,r||t,L),d||f||g){const E=L.getBoundingClientRect();return{x:Math.floor(E.x-Y.SafeBorderPadding),y:Math.floor(E.y-Y.SafeBorderPadding),w:Math.floor(E.width+2*Y.SafeBorderPadding),h:Math.floor(E.height+2*Y.SafeBorderPadding)}}return C}updateTempPoints(e){const t=e.slice(-2),i=new V(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(i,n))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(e){var h,u;const{op:t,isFullWork:i,replaceId:o}=e,n=(h=this.workId)==null?void 0:h.toString();if(!n)return;const r=[];for(let d=0;d<t.length;d+=3)r.push([t[d],t[d+1],t[d+2]]);const c=i?this.fullLayer:this.drawLayer||this.fullLayer,l=this.draw({ps:r,workId:n,layer:c,isDrawing:!1,replaceId:o});return this.oldRect=l,(u=this.vNodes)==null||u.setInfo(n,{rect:l,op:t,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(e){var u,d,f;const{node:t,opt:i,vNodes:o}=e,{strokeColor:n,fillColor:r,strokeType:c}=i,l=o.get(t.name);let h=t;return t.tagName==="GROUP"&&(h=t.children[0]),n&&(h.setAttribute("strokeColor",n),(u=l==null?void 0:l.opt)!=null&&u.strokeColor&&(l.opt.strokeColor=n)),r&&(r==="transparent"?h.setAttribute("fillColor","rgba(0,0,0,0)"):h.setAttribute("fillColor",r),(d=l==null?void 0:l.opt)!=null&&d.fillColor&&(l.opt.fillColor=r)),c&&(l!=null&&l.opt)&&((f=l.opt)!=null&&f.strokeType)&&(l.opt.strokeType=c),l&&o.setInfo(t.name,l),Y.updateNodeOpt(e)}}class Oo extends Y{constructor(e){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.all);y(this,"toolsType",I.Star);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"oldRect");y(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n}=e,r=this.workId,{op:c}=t,l=c==null?void 0:c.length;if(!l||l<2)return{type:x.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new V(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:x.None};let u;if(o||n){const f=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:r,layer:f,isDrawing:!0})}if(!o){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:x.DrawWork,dataType:B.Local,op:this.tmpPoints.map(g=>[...g.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:x.None}}const d=ce(u,this.oldRect);return this.oldRect=u,{rect:d,type:x.DrawWork,dataType:B.Local,...this.baseConsumeResult}}consumeAll(){var r;const e=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[e]};const t=this.fullLayer,i=this.draw({workId:e,layer:t,isDrawing:!1});this.oldRect=i;const o=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Re(o);return(r=this.vNodes)==null||r.setInfo(e,{rect:i,op:o,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&Y.getCenterPos(i,t)}),{rect:i,type:x.FullWork,dataType:B.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(e){const{workId:t,layer:i,isDrawing:o}=e,{strokeColor:n,fillColor:r,thickness:c,zIndex:l,vertices:h,innerVerticeStep:u,innerRatio:d,scale:f,rotate:g,translate:p,strokeType:m,eraserlines:N}=this.workOptions,v=i.worldScaling,{rect:T,pos:k,points:S}=this.computDrawPoints(c,h,u,d),w={close:!0,points:S,lineWidth:c,fillColor:r!=="transparent"&&r||void 0,strokeColor:n,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:m===ee.Dotted?[1,c*2]:m===ee.LongDotted?[c,c*2]:void 0},C={name:t,id:t,zIndex:l,pos:k,anchor:[.5,.5],size:[T.w,T.h]};f&&(C.scale=f),g&&(C.rotate=g),p&&(C.translate=p);const L=new le.Group(C);if(o){const A=new le.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:n,lineWidth:1,scale:[1/v[0],1/v[1]]});L.append(A)}const j=new le.Polyline({...w,pos:[0,0]});L.append(j),N&&(this.scaleType=re.proportional,this.drawEraserlines({group:L,eraserlines:N,pos:k,layer:i})),this.replace(i,t,L);const E=L.getBoundingClientRect();return{x:Math.floor(E.x-Y.SafeBorderPadding),y:Math.floor(E.y-Y.SafeBorderPadding),w:Math.floor(E.width+Y.SafeBorderPadding*2),h:Math.floor(E.height+Y.SafeBorderPadding*2)}}computDrawPoints(e,t,i,o){const n=pe(this.tmpPoints),r=[Math.floor(n.x+n.w/2),Math.floor(n.y+n.h/2)],c=qo(n.w,n.h),l=Math.floor(Math.min(n.w,n.h)/2),h=o*l,u=[],d=2*Math.PI/t;for(let g=0;g<t;g++){const p=g*d-.5*Math.PI;let m,N;g%i===1?(m=h*c[0]*Math.cos(p),N=h*c[1]*Math.sin(p)):(m=l*c[0]*Math.cos(p),N=l*c[1]*Math.sin(p),u.push(m,N)),u.push(m,N)}return{rect:pe(this.tmpPoints,e),pos:r,points:u}}updateTempPoints(e){const t=e.slice(-2),i=new V(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(i,n)||V.Sub(o,i).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(e){var c,l;const{op:t,isFullWork:i}=e,o=(c=this.workId)==null?void 0:c.toString();if(!o)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new V(t[h],t[h+1],t[h+2]));const n=i?this.fullLayer:this.drawLayer||this.fullLayer,r=this.draw({workId:o,layer:n,isDrawing:!1});return this.oldRect=r,(l=this.vNodes)==null||l.setInfo(o,{rect:r,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:r&&Y.getCenterPos(r,n)}),r}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var m;const{node:t,opt:i,vNodes:o}=e,{strokeColor:n,fillColor:r,toolsType:c,vertices:l,innerVerticeStep:h,innerRatio:u,strokeType:d}=i,f=o.get(t.name),g=f==null?void 0:f.opt;let p=t;return t.tagName==="GROUP"&&(p=t.children[0]),n&&(p.setAttribute("strokeColor",n),g!=null&&g.strokeColor&&(g.strokeColor=n)),r&&(r==="transparent"?p.setAttribute("fillColor","rgba(0,0,0,0)"):p.setAttribute("fillColor",r),g!=null&&g.fillColor&&(g.fillColor=r)),c===I.Star&&(l&&(g.vertices=l),h&&(g.innerVerticeStep=h),u&&(g.innerRatio=u)),d&&(f!=null&&f.opt)&&((m=f.opt)!=null&&m.strokeType)&&(f.opt.strokeType=d),f&&o.setInfo(t.name,{...f,opt:g}),Y.updateNodeOpt(e)}}class Ro extends Y{constructor(e){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.all);y(this,"toolsType",I.Polygon);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"oldRect");y(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n}=e,{op:r}=t,c=this.workId,l=r==null?void 0:r.length;if(!l||l<2)return{type:x.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new V(r[0],r[1])],h=!1):h=this.updateTempPoints(r),!h)return{type:x.None};let u;if(o||n){const f=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:c,layer:f,isDrawing:!0})}if(!o){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:x.DrawWork,dataType:B.Local,op:this.tmpPoints.map(g=>[...g.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:x.None}}const d=ce(u,this.oldRect);return this.oldRect=u,{rect:d,type:x.DrawWork,dataType:B.Local,...this.baseConsumeResult}}consumeAll(){var r;const e=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[e]};const t=this.fullLayer,i=this.draw({workId:e,layer:t,isDrawing:!1});this.oldRect=i;const o=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Re(o);return(r=this.vNodes)==null||r.setInfo(e,{rect:i,op:o,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&Y.getCenterPos(i,t)}),{rect:i,type:x.FullWork,dataType:B.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(e){const{workId:t,layer:i,isDrawing:o}=e,{strokeColor:n,fillColor:r,thickness:c,zIndex:l,vertices:h,scale:u,rotate:d,translate:f,strokeType:g,eraserlines:p}=this.workOptions,m=i.worldScaling,{rect:N,pos:v,points:T}=this.computDrawPoints(c,h),k={close:!0,points:T,lineWidth:c,fillColor:r!=="transparent"&&r||void 0,strokeColor:n,normalize:!0,lineJoin:"round",lineCap:"round",lineDash:g===ee.Dotted?[1,c*2]:g===ee.LongDotted?[c,c*2]:void 0},S={name:t,id:t,zIndex:l,pos:v,anchor:[.5,.5],size:[N.w,N.h]};u&&(S.scale=u),d&&(S.rotate=d),f&&(S.translate=f);const w=new le.Group(S);if(o){const j=new le.Path({d:"M-4,0H4M0,-4V4",normalize:!0,pos:[0,0],strokeColor:n,lineWidth:1,scale:[1/m[0],1/m[1]]});w.append(j)}const C=new le.Polyline({...k,pos:[0,0]});w.append(C),p&&(this.scaleType=re.proportional,this.drawEraserlines({group:w,eraserlines:p,pos:v,layer:i})),this.replace(i,t,w);const L=w.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(e,t){const i=pe(this.tmpPoints),o=[Math.floor(i.x+i.w/2),Math.floor(i.y+i.h/2)],n=qo(i.w,i.h),r=Math.floor(Math.min(i.w,i.h)/2),c=[],l=2*Math.PI/t;for(let u=0;u<t;u++){const d=u*l-.5*Math.PI,f=r*n[0]*Math.cos(d),g=r*n[1]*Math.sin(d);c.push(f,g)}return{rect:pe(this.tmpPoints,e),pos:o,points:c}}updateTempPoints(e){const t=e.slice(-2),i=new V(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(i,n)||V.Sub(o,i).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(e){var c,l;const{op:t,isFullWork:i}=e,o=(c=this.workId)==null?void 0:c.toString();if(!o)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new V(t[h],t[h+1],t[h+2]));const n=i?this.fullLayer:this.drawLayer||this.fullLayer,r=this.draw({workId:o,layer:n,isDrawing:!1});return this.oldRect=r,(l=this.vNodes)==null||l.setInfo(o,{rect:r,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:r&&Y.getCenterPos(r,n)}),r}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var g;const{node:t,opt:i,vNodes:o}=e,{strokeColor:n,fillColor:r,toolsType:c,vertices:l,strokeType:h}=i,u=o.get(t.name),d=u==null?void 0:u.opt;let f=t;return t.tagName==="GROUP"&&(f=t.children[0]),n&&(f.setAttribute("strokeColor",n),d!=null&&d.strokeColor&&(d.strokeColor=n)),r&&(r==="transparent"?f.setAttribute("fillColor","rgba(0,0,0,0)"):f.setAttribute("fillColor",r),d!=null&&d.fillColor&&(d.fillColor=r)),c===I.Polygon&&l&&(d.vertices=l),h&&(u!=null&&u.opt)&&((g=u.opt)!=null&&g.strokeType)&&(u.opt.strokeType=h),u&&o.setInfo(t.name,{...u,opt:d}),Y.updateNodeOpt(e)}}class $e{static bezier(s,e){const t=[];for(let i=0;i<e.length;i+=4){const o=e[i],n=e[i+1],r=e[i+2],c=e[i+3];o&&n&&r&&c?t.push(...$e.getBezierPoints(s,o,n,r,c)):o&&n&&r?t.push(...$e.getBezierPoints(s,o,n,r)):o&&n?t.push(...$e.getBezierPoints(s,o,n)):o&&t.push(o)}return t}static getBezierPoints(s=10,e,t,i,o){let n=null;const r=[];!i&&!o?n=$e.oneBezier:i&&!o?n=$e.twoBezier:i&&o&&(n=$e.threeBezier);for(let c=0;c<s;c++)n&&r.push(n(c/s,e,t,i,o));return o?r.push(o):i&&r.push(i),r}static oneBezier(s,e,t){const i=e.x+(t.x-e.x)*s,o=e.y+(t.y-e.y)*s;return new b(i,o)}static twoBezier(s,e,t,i){const o=(1-s)*(1-s)*e.x+2*s*(1-s)*t.x+s*s*i.x,n=(1-s)*(1-s)*e.y+2*s*(1-s)*t.y+s*s*i.y;return new b(o,n)}static threeBezier(s,e,t,i,o){const n=e.x*(1-s)*(1-s)*(1-s)+3*t.x*s*(1-s)*(1-s)+3*i.x*s*s*(1-s)+o.x*s*s*s,r=e.y*(1-s)*(1-s)*(1-s)+3*t.y*s*(1-s)*(1-s)+3*i.y*s*s*(1-s)+o.y*s*s*s;return new b(n,r)}}class Wo extends Y{constructor(e){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.all);y(this,"toolsType",I.SpeechBalloon);y(this,"ratio",.8);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"oldRect");y(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){var f;const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n}=e,r=(f=t==null?void 0:t.workId)==null?void 0:f.toString();if(!r)return{type:x.None};const{op:c}=t,l=c==null?void 0:c.length;if(!l||l<2)return{type:x.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new V(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:x.None};let u;if(o||n){const g=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:r,layer:g,isDrawing:!0})}if(!o){const g=Date.now();return g-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=g,{type:x.DrawWork,dataType:B.Local,op:this.tmpPoints.map(p=>[...p.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:x.None}}const d=ce(u,this.oldRect);return this.oldRect=u,{rect:d,type:x.DrawWork,dataType:B.Local,...this.baseConsumeResult}}consumeAll(){var r;const e=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[e]};const t=this.fullLayer,i=this.draw({workId:e,layer:t,isDrawing:!1});this.oldRect=i;const o=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Re(o);return(r=this.vNodes)==null||r.setInfo(e,{rect:i,op:o,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&Y.getCenterPos(i,t)}),{rect:i,type:x.FullWork,dataType:B.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(e){const{workId:t,layer:i}=e,{strokeColor:o,fillColor:n,thickness:r,zIndex:c,placement:l,scale:h,rotate:u,translate:d,strokeType:f,eraserlines:g}=this.workOptions,{rect:p,pos:m,points:N}=this.computDrawPoints(r,l),v={points:N.map(C=>C.XY),lineWidth:r,fillColor:n!=="transparent"&&n||void 0,strokeColor:o,normalize:!0,className:`${m[0]},${m[1]}`,close:!0,lineJoin:"round",lineCap:"round",lineDash:f===ee.Dotted?[1,r*2]:f===ee.LongDotted?[r,r*2]:void 0},T={name:t,id:t,zIndex:c,pos:m,anchor:[.5,.5],size:[p.w,p.h]};h&&(T.scale=h),u&&(T.rotate=u),d&&(T.translate=d);const k=new le.Group(T),S=new le.Polyline({...v,pos:[0,0]});k.append(S),g&&(this.scaleType=re.proportional,this.drawEraserlines({group:k,eraserlines:g,pos:m,layer:i})),this.replace(i,t,k);const w=k.getBoundingClientRect();return{x:Math.floor(w.x-Y.SafeBorderPadding),y:Math.floor(w.y-Y.SafeBorderPadding),w:Math.floor(w.width+Y.SafeBorderPadding*2),h:Math.floor(w.height+Y.SafeBorderPadding*2)}}transformControlPoints(e){const t=pe(this.tmpPoints);switch(e){case"bottom":case"bottomLeft":case"bottomRight":{const i=t.y+t.h*this.ratio;return[new b(t.x,t.y,0),new b(t.x+t.w,t.y,0),new b(t.x+t.w,i,0),new b(t.x,i,0)]}case"top":case"topLeft":case"topRight":{const i=t.y+t.h*(1-this.ratio);return[new b(t.x,i,0),new b(t.x+t.w,i,0),new b(t.x+t.w,t.y+t.h,0),new b(t.x,t.y+t.h,0)]}case"left":case"leftBottom":case"leftTop":{const i=t.x+t.w*(1-this.ratio);return[new b(i,t.y,0),new b(t.x+t.w,t.y,0),new b(t.x+t.w,t.y+t.h,0),new b(i,t.y+t.h,0)]}case"right":case"rightBottom":case"rightTop":{const i=t.x+t.w*this.ratio;return[new b(t.x,t.y,0),new b(i,t.y,0),new b(i,t.y+t.h,0),new b(t.x,t.y+t.h,0)]}}}computDrawPoints(e,t){const i=pe(this.tmpPoints),o=this.transformControlPoints(t),n=Math.floor(i.w*.1),r=Math.floor(i.h*.1),c=[],l=b.Add(o[0],new b(0,r,0)),h=b.Add(o[0],new b(n,0,0)),u=$e.getBezierPoints(10,l,o[0],h),d=b.Sub(o[1],new b(n,0,0)),f=b.Add(o[1],new b(0,r,0)),g=$e.getBezierPoints(10,d,o[1],f),p=b.Sub(o[2],new b(0,r,0)),m=b.Sub(o[2],new b(n,0,0)),N=$e.getBezierPoints(10,p,o[2],m),v=b.Add(o[3],new b(n,0,0)),T=b.Sub(o[3],new b(0,r,0)),k=$e.getBezierPoints(10,v,o[3],T),S=n*(1-this.ratio)*10,w=r*(1-this.ratio)*10;switch(t){case"bottom":{const j=b.Sub(o[2],new b(n*5-S/2,0,0)),E=b.Sub(o[2],new b(n*5,-w,0)),A=b.Sub(o[2],new b(n*5+S/2,0,0));c.push(E,A,...k,...u,...g,...N,j);break}case"bottomRight":{const j=b.Sub(o[2],new b(n*1.1,0,0)),E=b.Sub(o[2],new b(n*1.1+S/2,-w,0)),A=b.Sub(o[2],new b(n*1.1+S,0,0));c.push(E,A,...k,...u,...g,...N,j);break}case"bottomLeft":{const j=b.Add(o[3],new b(n*1.1+S,0,0)),E=b.Add(o[3],new b(n*1.1+S/2,w,0)),A=b.Add(o[3],new b(n*1.1,0,0));c.push(E,A,...k,...u,...g,...N,j);break}case"top":{const j=b.Sub(o[1],new b(n*5-S/2,0,0)),E=b.Sub(o[1],new b(n*5,w,0)),A=b.Sub(o[1],new b(n*5+S/2,0,0));c.push(E,j,...g,...N,...k,...u,A);break}case"topRight":{const j=b.Sub(o[1],new b(n*1.1,0,0)),E=b.Sub(o[1],new b(n*1.1+S/2,w,0)),A=b.Sub(o[1],new b(n*1.1+S,0,0));c.push(E,j,...g,...N,...k,...u,A);break}case"topLeft":{const j=b.Add(o[0],new b(n*1.1+S,0,0)),E=b.Add(o[0],new b(n*1.1+S/2,-w,0)),A=b.Add(o[0],new b(n*1.1,0,0));c.push(E,j,...g,...N,...k,...u,A);break}case"left":{const j=b.Add(o[0],new b(0,r*5-w/2,0)),E=b.Add(o[0],new b(-S,r*5,0)),A=b.Add(o[0],new b(0,r*5+w/2,0));c.push(E,j,...u,...g,...N,...k,A);break}case"leftTop":{const j=b.Add(o[0],new b(0,r*1.1,0)),E=b.Add(o[0],new b(-S,r*1.1+w/2,0)),A=b.Add(o[0],new b(0,r*1.1+w,0));c.push(E,j,...u,...g,...N,...k,A);break}case"leftBottom":{const j=b.Sub(o[3],new b(0,r*1.1+w,0)),E=b.Sub(o[3],new b(S,r*1.1+w/2,0)),A=b.Sub(o[3],new b(0,r*1.1,0));c.push(E,j,...u,...g,...N,...k,A);break}case"right":{const j=b.Add(o[1],new b(0,r*5-w/2,0)),E=b.Add(o[1],new b(S,r*5,0)),A=b.Add(o[1],new b(0,r*5+w/2,0));c.push(E,A,...N,...k,...u,...g,j);break}case"rightTop":{const j=b.Add(o[1],new b(0,r*1.1,0)),E=b.Add(o[1],new b(S,r*1.1+w/2,0)),A=b.Add(o[1],new b(0,r*1.1+w,0));c.push(E,A,...N,...k,...u,...g,j);break}case"rightBottom":{const j=b.Sub(o[2],new b(0,r*1.1+w,0)),E=b.Sub(o[2],new b(-S,r*1.1+w/2,0)),A=b.Sub(o[2],new b(0,r*1.1,0));c.push(E,A,...N,...k,...u,...g,j);break}}const C=pe(this.tmpPoints,e),L=[Math.floor(C.x+C.w/2),Math.floor(C.y+C.h/2)];return{rect:C,pos:L,points:c}}updateTempPoints(e){const t=e.slice(-2),i=new V(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(i,n)||V.Sub(o,i).XY.includes(0))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(e){var c,l;const{op:t,isFullWork:i}=e,o=(c=this.workId)==null?void 0:c.toString();if(!o)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new V(t[h],t[h+1],t[h+2]));const n=i?this.fullLayer:this.drawLayer||this.fullLayer,r=this.draw({workId:o,layer:n,isDrawing:!1});return this.oldRect=r,(l=this.vNodes)==null||l.setInfo(o,{rect:r,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:r&&Y.getCenterPos(r,n)}),r}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var g;const{node:t,opt:i,vNodes:o}=e,{strokeColor:n,fillColor:r,toolsType:c,placement:l,strokeType:h}=i,u=o.get(t.name),d=u==null?void 0:u.opt;let f=t;return t.tagName==="GROUP"&&(f=t.children[0]),n&&(f.setAttribute("strokeColor",n),d!=null&&d.strokeColor&&(d.strokeColor=n)),r&&(r==="transparent"?f.setAttribute("fillColor","rgba(0,0,0,0)"):f.setAttribute("fillColor",r),d!=null&&d.fillColor&&(d.fillColor=r)),c===I.SpeechBalloon&&l&&(d.placement=l),h&&(u!=null&&u.opt)&&((g=u.opt)!=null&&g.strokeType)&&(u.opt.strokeType=h),u&&o.setInfo(t.name,{...u,opt:d}),Y.updateNodeOpt(e)}}var Bf=ht,Ff=qe,Vf="[object Boolean]";function $f(a){return a===!0||a===!1||Ff(a)&&Bf(a)==Vf}var Hf=$f;const gt=St(Hf);class Yo extends Y{constructor(e){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.both);y(this,"toolsType",I.Straight);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"oldRect");y(this,"straightTipWidth");y(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.straightTipWidth=this.workOptions.thickness/2,this.syncTimestamp=0,this.syncUnitTime=50}consume(e){const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n}=e,r=this.workId,{op:c}=t,l=c==null?void 0:c.length;if(!l||l<2)return{type:x.None};let h;if(this.tmpPoints.length===0?(this.tmpPoints=[new V(c[0],c[1])],h=!1):h=this.updateTempPoints(c),!h)return{type:x.None};let u;if(o||n){const f=i?this.fullLayer:this.drawLayer||this.fullLayer;u=this.draw({workId:r,layer:f})}if(!o){const f=Date.now();return f-this.syncTimestamp>this.syncUnitTime?(this.syncTimestamp=f,{type:x.DrawWork,dataType:B.Local,op:this.tmpPoints.map(g=>[...g.XY,0]).flat(1),isSync:!0,index:0,...this.baseConsumeResult}):{type:x.None}}const d=ce(u,this.oldRect);return this.oldRect=u,{rect:d,type:x.DrawWork,dataType:B.Local,...this.baseConsumeResult}}consumeAll(){var r;const e=this.workId;if(this.tmpPoints.length<2)return{type:x.RemoveNode,removeIds:[e]};const t=this.fullLayer,i=this.draw({workId:e,layer:t});this.oldRect=i;const o=this.tmpPoints.map(c=>[...c.XY,0]).flat(1),n=Re(o);return(r=this.vNodes)==null||r.setInfo(e,{rect:i,op:o,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:i&&Y.getCenterPos(i,t)}),{rect:i,type:x.FullWork,dataType:B.Local,ops:n,isSync:!0,...this.baseConsumeResult}}draw(e){const{workId:t,layer:i}=e,{strokeColor:o,thickness:n,zIndex:r,scale:c,rotate:l,translate:h,strokeType:u,eraserlines:d}=this.workOptions,f=i.worldPosition,g=i.worldScaling,{d:p,rect:m,isDot:N}=this.computDrawPoints(n,u),v=[m.x+m.w/2,m.y+m.h/2],T=new le.Group({pos:v,anchor:[.5,.5],size:[m.w,m.h],name:t,id:t,normalize:!0,zIndex:r}),k={pos:[0,0],normalize:!0,d:p,fillColor:o,strokeColor:o,lineDash:u===ee.Dotted&&!N?[1,n*2]:u===ee.LongDotted&&!N?[n,n*2]:void 0,lineCap:u===ee.Normal||N?void 0:"round",lineWidth:u===ee.Normal||N?0:n};c&&(k.scale=c),l&&(k.rotate=l),h&&(k.translate=h);const S=new le.Path(k);if(T.append(S),d&&(this.scaleType=re.proportional,this.drawEraserlines({group:T,eraserlines:d,pos:v,layer:i})),this.replace(i,t,T),l||c||h){const C=S.getBoundingClientRect();return{x:Math.floor(C.x-Y.SafeBorderPadding),y:Math.floor(C.y-Y.SafeBorderPadding),w:Math.floor(C.width+Y.SafeBorderPadding*2),h:Math.floor(C.height+Y.SafeBorderPadding*2)}}return{x:Math.floor(m.x*g[0]+f[0]-Y.SafeBorderPadding),y:Math.floor(m.y*g[1]+f[1]-Y.SafeBorderPadding),w:Math.floor(m.w*g[0]+2*Y.SafeBorderPadding),h:Math.floor(m.h*g[1]+2*Y.SafeBorderPadding)}}computDrawPoints(e,t){return this.tmpPoints[1].distance(this.tmpPoints[0])>this.straightTipWidth?this.computFullPoints(e,t):this.computDotPoints(e)}computFullPoints(e,t){const i=b.Sub(this.tmpPoints[1],this.tmpPoints[0]).uni(),o=b.Per(i).mul(e/2),n=V.Sub(this.tmpPoints[0],o),r=V.Add(this.tmpPoints[0],o),c=V.Sub(this.tmpPoints[1],o),l=V.Add(this.tmpPoints[1],o),h=V.GetSemicircleStroke(this.tmpPoints[1],c,-1,8),u=V.GetSemicircleStroke(this.tmpPoints[0],r,-1,8),d=[n,c,...h,l,r,...u];let f;return t!==ee.Normal?f=Je(this.tmpPoints,!1):f=Je(d,!0),{d:f,rect:pe(d),isDot:!1,pos:this.tmpPoints[0].XY}}computDotPoints(e){const t=V.GetDotStroke(this.tmpPoints[0],e/2,8);return{d:Je(t,!0),rect:pe(t),isDot:!0,pos:this.tmpPoints[0].XY}}updateTempPoints(e){const t=e.slice(-2),i=new V(t[0],t[1]),o=this.tmpPoints[0],{thickness:n}=this.workOptions;if(o.isNear(i,n))return!1;if(this.tmpPoints.length===2){if(i.isNear(this.tmpPoints[1],1))return!1;this.tmpPoints[1]=i}else this.tmpPoints.push(i);return!0}consumeService(e){var c,l;const{op:t,isFullWork:i}=e,o=(c=this.workId)==null?void 0:c.toString();if(!o)return;this.tmpPoints.length=0;for(let h=0;h<t.length;h+=3)this.tmpPoints.push(new V(t[h],t[h+1],t[h+2]));const n=i?this.fullLayer:this.drawLayer||this.fullLayer,r=this.draw({workId:o,layer:n});return this.oldRect=r,(l=this.vNodes)==null||l.setInfo(o,{rect:r,op:t,opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:r&&Y.getCenterPos(r,n)}),r}clearTmpPoints(){this.tmpPoints.length=0}static updateNodeOpt(e){var l,h;const{node:t,opt:i,vNodes:o}=e,{strokeColor:n,strokeType:r}=i,c=o.get(t.name);return n&&(t.tagName==="GROUP"?t.children.forEach(u=>{u.setAttribute("strokeColor",n),u.getAttribute("fillColor")&&u.setAttribute("fillColor",n)}):(t.setAttribute("strokeColor",n),t.setAttribute("fillColor",n)),(l=c==null?void 0:c.opt)!=null&&l.strokeColor&&(c.opt.strokeColor=n)),r&&(c!=null&&c.opt)&&((h=c.opt)!=null&&h.strokeType)&&(c.opt.strokeType=r),c&&o.setInfo(t.name,c),Y.updateNodeOpt(e)}}const et=class et extends Y{constructor(e){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.proportional);y(this,"toolsType",I.Text);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"oldRect");this.workOptions=e.toolsOpt}consume(){return{type:x.None}}consumeAll(){return{type:x.None}}consumeService(){}async draw(e){const{workId:t,layer:i,isDrawLabel:o}=e,{boxSize:n,boxPoint:r,zIndex:c}=this.workOptions,l=i.worldPosition,h=i.worldScaling;if(!r||!n)return;const u={name:t,id:t,pos:[r[0],r[1]],anchor:[0,0],size:n,zIndex:c},d=new le.Group(u),f={x:r[0],y:r[1],w:n[0],h:n[1]},g={x:Math.floor(f.x*h[0]+l[0]),y:Math.floor(f.y*h[1]+l[1]),w:Math.floor(f.w*h[0])+2,h:Math.floor(f.h*h[1])+2};if(this.replace(i,t,d),o&&i&&this.workOptions.text){const p=await et.createLabels(this.workOptions,i,g),{labels:m,maxWidth:N}=p;d.append(...m),g.w=Math.ceil(Math.max(N*i.worldScaling[0],g.w))}return g}async consumeServiceAsync(e){var l,h,u,d;const t=(l=this.workId)==null?void 0:l.toString();if(!t)return;const{isFullWork:i,replaceId:o,isDrawLabel:n}=e;this.oldRect=o&&((u=(h=this.vNodes)==null?void 0:h.get(o))==null?void 0:u.rect)||void 0;const r=i?this.fullLayer:this.drawLayer||this.fullLayer,c=await this.draw({workId:t,layer:r,isDrawLabel:typeof n>"u"&&this.workOptions.workState===P.Done||n});return(d=this.vNodes)==null||d.setInfo(t,{rect:c,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:c&&Y.getCenterPos(c,r)}),c}updataOptService(){}async updataOptServiceAsync(e,t){var g,p;if(!this.workId)return;const i=this.workId.toString(),{fontColor:o,fontBgColor:n,bold:r,italic:c,lineThrough:l,underline:h,zIndex:u}=e,d=(g=this.vNodes)==null?void 0:g.get(i);if(!d)return;o&&(d.opt.fontColor=o),n&&(d.opt.fontBgColor=n),r&&(d.opt.bold=r),c&&(d.opt.italic=c),gt(l)&&(d.opt.lineThrough=l),gt(h)&&(d.opt.underline=h),Ae(u)&&(d.opt.zIndex=u),this.oldRect=d.rect;const f=await this.draw({workId:i,layer:this.fullLayer,isDrawLabel:typeof t>"u"&&this.workOptions.workState===P.Done||t});return(p=this.vNodes)==null||p.setInfo(i,{rect:f,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:f&&Y.getCenterPos(f,this.fullLayer)}),f}clearTmpPoints(){this.tmpPoints.length=0}static getSafetySnippetRatio(e){const t=(e==null?void 0:e.parent).displayRatio||1,i=Math.ceil(e.worldScaling[0]*10)/10;let o=i;return i>=.2&&i<1?o=i*t:i<=2&&i>=1?o=i*t*1.6:i>2&&i<=3?o=i*t*1.4:i>3&&i<=4?o=i*t*.8:i>4&&(o=i*t*.6),Math.floor(o*1e3)/1e3}static getSafetySnippetFontLength(e){return Math.floor(et.textImageSnippetSize*3/4/e)||1}static async createLabels(e,t,i){var A;const o=[],{x:n,y:r}=i,{width:c,height:l}=(A=t.parent)==null?void 0:A.parent,h=it(e.text),u=h.length,{fontSize:d,lineHeight:f,bold:g,textAlign:p,italic:m,fontFamily:N,verticalAlign:v,fontColor:T,fontBgColor:k,underline:S,lineThrough:w}=e,C=et.getSafetySnippetRatio(t)||1,L=Math.floor(d*C),j=et.getSafetySnippetFontLength(L);let E=0;for(let W=0;W<u;W++){const z=h[W],O=f||L*1.5;if(z){const se=vM(z),_=[0,0],H=[0,d*1.2];v==="middle"&&(_[1]=W*d*1.2+5);const X=[0,-d*.15];_[0]=5;const G=Math.sin(Math.PI/180*20);let Z=0;const K=[];let ae=0;for(;ae<se;){p==="left"&&(X[0]=Z),ae===0&&m==="italic"&&(X[0]=X[0]-G/2*d);const ie=z.slice(ae,ae+j),he={anchor:[0,0],pos:X,text:ie,fontFamily:N,fontSize:L,lineHeight:O,strokeColor:T,fontWeight:g,fillColor:T,textAlign:p,fontStyle:m,scale:[1/C,1/C]},J=new le.Label(he),$=await J.textImageReady;let ue=!0;if($){const fe=$.rect&&$.rect[2],Oe=$.rect&&$.rect[3];if(fe&&Oe){const we=fe/C,me=Oe/C;Z=we+Z,m==="italic"&&(g==="bold"?Z=Z-G*d*1.2:Z=Z-G*d),((X[0]+_[0]+we)*t.worldScaling[0]+n<=0||(X[0]+_[0])*t.worldScaling[0]+n>=c||(X[1]+_[1]+me)*t.worldScaling[1]+r<=0||(X[1]+_[1])*t.worldScaling[1]+r>=l)&&(J.disconnect(),ue=!1),ue&&K.push(J)}}ae+=j}H[0]=Z,m==="italic"&&(H[0]=H[0]+G*d),E=Math.max(E,H[0]);let Te=!0;if(((_[0]+H[0])*t.worldScaling[0]+n<=0||_[0]*t.worldScaling[0]+n>=c||(_[1]+H[1])*t.worldScaling[0]+r<=0||_[1]*t.worldScaling[1]+r>=l)&&(Te=!1),Te){if(S){const J=Math.floor(d/10),$={normalize:!1,pos:[0,d*1.1+J/2],lineWidth:J,points:[0,0,Math.ceil(H[0]),0],strokeColor:T,className:"underline"},ue=new le.Polyline($);K.push(ue)}if(w){const J={normalize:!1,pos:[0,d*1.2/2],lineWidth:Math.floor(d/10),points:[0,0,Math.ceil(H[0]),0],strokeColor:T,className:"lineThrough"},$=new le.Polyline(J);K.push($)}const ie={pos:_,anchor:[0,0],size:H,bgcolor:k},he=new le.Group(ie);he.append(...K),o.push(he)}}}return{labels:o,maxWidth:E}}static updateNodeOpt(e){const{node:t,opt:i,vNodes:o,targetNode:n}=e,{fontBgColor:r,fontColor:c,translate:l,originPoint:h,scenePoint:u,scale:d,bold:f,italic:g,lineThrough:p,underline:m,fontSize:N,textInfos:v,zIndex:T}=i,k=n&&Ce(n)||o.get(t.name);if(!k||!t.parent)return;const w=k.opt;if(Ae(T)&&(t.setAttribute("zIndex",T),k.opt.zIndex=T),c&&w.fontColor&&(w.fontColor=c,t.children.forEach(C=>{C.tagName==="GROUP"&&C.children.forEach(L=>{L.tagName==="LABEL"?(L.setAttribute("fillColor",c),L.setAttribute("strokeColor",c)):L.tagName==="POLYLINE"&&L.setAttribute("strokeColor",c)})})),r&&w.fontBgColor&&(w.fontBgColor=r,t.children.forEach(C=>{C.tagName==="GROUP"&&C.setAttribute("bgcolor",r)})),f&&(w.bold=f),g&&(w.italic=g),gt(p)&&(w.lineThrough=p),gt(m)&&(w.underline=m),N&&(w.fontSize=N),h&&u&&d&&n&&w.boxPoint){const C=v==null?void 0:v.get(t.name);if(C){const{fontSize:A,boxSize:W}=C;w.boxSize=W||w.boxSize,w.fontSize=A||w.fontSize}const L=[w.boxPoint[0],w.boxPoint[1]];ti(w.boxPoint,u,d,l);const j=[k.op[0],k.op[1]],E=[j[0]-L[0],j[1]-L[1]];if(k.centerPos=[k.centerPos[0]+E[0],k.centerPos[1]+E[1]],k.opt.eraserlines)for(const A of Object.values(k.opt.eraserlines)){const{op:W,thickness:z}=A;A.thickness=z*Math.max(d[0],d[1]);for(let O=0;O<W.length;O++)si(W[O],u,d,l)}}else if(l&&w.boxPoint&&(w.boxPoint=[w.boxPoint[0]+l[0],w.boxPoint[1]+l[1]],k.centerPos=[k.centerPos[0]+l[0],k.centerPos[1]+l[1]],k.opt.eraserlines))for(const C of Object.values(k.opt.eraserlines)){const{op:L}=C;for(let j=0;j<L.length;j++){const E=L[j].map((A,W)=>W%2?A+l[1]:A+l[0]);C.op[j]=E}}return k&&o.setInfo(t.name,k),k==null?void 0:k.rect}static getRectFromLayer(e,t){const i=e.getElementsByName(t)[0];if(i){const o=i.getBoundingClientRect();let n={x:Math.floor(o.x),y:Math.floor(o.y),w:Math.floor(o.width+2),h:Math.floor(o.height+2)};return i.children.forEach(r=>{if(r.tagName==="GROUP"){const c=i.getBoundingClientRect();n=ce(n,{x:Math.floor(c.x),y:Math.floor(c.y),w:Math.floor(c.width+2),h:Math.floor(c.height+2)})}}),n}}};y(et,"textImageSnippetSize",1024*4),y(et,"SafeBorderPadding",30);let _t=et;const Mt=class Mt extends Y{constructor(e,t){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.none);y(this,"toolsType",I.PencilEraser);y(this,"serviceWork");y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"worldPosition");y(this,"worldScaling");y(this,"eraserRect");y(this,"eraserPolyline");this.serviceWork=t,this.workOptions=e.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling}consumeService(){}createEraserRect(e){const t=e[0]*this.worldScaling[0]+this.worldPosition[0],i=e[1]*this.worldScaling[1]+this.worldPosition[1],{width:o,height:n}=Mt.eraserSizes[this.workOptions.thickness];this.eraserRect={x:t-o*.5,y:i-n*.5,w:o,h:n},this.eraserPolyline=[this.eraserRect.x,this.eraserRect.y,this.eraserRect.x+this.eraserRect.w,this.eraserRect.y+this.eraserRect.h]}computRectCenterPoints(){const e=this.tmpPoints.slice(-2);if(this.tmpPoints.length===4){const t=new b(this.tmpPoints[0],this.tmpPoints[1]),i=new b(this.tmpPoints[2],this.tmpPoints[3]),o=b.Sub(i,t).uni(),n=b.Dist(t,i),{width:r,height:c}=Mt.eraserSizes[this.workOptions.thickness],l=Math.min(r,c),h=Math.round(n/l);if(h>1){const u=[];for(let d=0;d<h;d++){const f=b.Mul(o,d*l);u.push(this.tmpPoints[0]+f.x,this.tmpPoints[1]+f.y)}return u.concat(e)}}return e}isNear(e,t){const i=new b(e[0],e[1]),o=new b(t[0],t[1]),{width:n,height:r}=Mt.eraserSizes[this.workOptions.thickness];return b.Dist(i,o)<Math.hypot(n,r)*.5}cutPolyline(e,t){let i=[t],o=0;for(;o<e.length;){const c=e[o];if(c.length<2)break;i=n(i,c),o++}return i;function n(c,l){const h=c;for(let u=0;u<c.length;u++){const d=c[u],f=d.findIndex((g,p)=>p<d.length-1?r([g,d[p+1]],[l[0],l[1]]):!1);if(f!==-1&&f>-1){const g=[],p=d.slice(0,f+1);if(b.Equals(d[f],l[0])||p.push(l[0].clone().setz(d[f].z)),p.length>1&&g.push(p),f+l.length-1<d.length-1){const m=f+l.length-1,N=d.slice(m),v=l[l.length-1];b.Equals(d[m],v)||N.unshift(v.clone().setz(d[m].z)),N.length>1&&g.push(N)}return h.splice(u,1,...g),h}}return h}function r(c,l){const h=b.Sub(c[1],c[0]),u=b.Sub(l[1],l[0]),d=b.Sub(l[0],c[0]);return Math.abs(b.Cpr(h,u))<.1&&Math.abs(b.Cpr(h,d))<.1}}isSamePoint(e,t){return e[0]===t[0]&&e[1]===t[1]}translateIntersect(e){const t=[];for(let i=0;i<e.length;i++){const o=e[i].filter((c,l,h)=>!(l>0&&this.isSamePoint(c,h[l-1]))),n=[];let r=0;for(;r<o.length;){const c=o[r],l=new b(c[0],c[1]);n.push(l),r++}t.push(n)}return t}isLineEraser(e,t){return!(e===I.Pencil&&!t)}remove(e){const{curNodeMap:t,removeIds:i,newWorkDatas:o}=e;let n;for(const[r,c]of t.entries())if(c.rect&&this.eraserRect&&this.eraserPolyline&&Rt(this.eraserRect,c.rect)){const{op:l,toolsType:h}=c,u=this.isLineEraser(h,!1),d=[],f=[];for(let p=0;p<l.length;p+=3){const m=new b(l[p]*this.worldScaling[0]+this.worldPosition[0],l[p+1]*this.worldScaling[1]+this.worldPosition[1],l[p+2]);f.push(m),d.push(new V(m.x,m.y))}const g=d.length&&pe(d)||c.rect;if(Rt(g,this.eraserRect)){if(f.length>1){const p=Ws.polyline(f.map(m=>m.XY),this.eraserPolyline);if(p.length&&(i.add(c.name),!u)){const m=this.translateIntersect(p),N=this.cutPolyline(m,f);for(let v=0;v<N.length;v++){const T=`${r}_s_${v}`,k=[];N[v].forEach(S=>{k.push((S.x-this.worldPosition[0])/this.worldScaling[0],(S.y-this.worldPosition[1])/this.worldScaling[1],S.z)}),c.opt&&c.toolsType&&this.vNodes&&(this.vNodes.setInfo(T,{rect:g,op:k,opt:c.opt,canRotate:c.canRotate,scaleType:c.scaleType,toolsType:c.toolsType}),o.set(T,{workId:T,op:k,opt:c.opt,toolsType:c.toolsType}))}}}else i.add(c.name);n=ce(n,g)}}return i.forEach(r=>{var c;return(c=this.vNodes)==null?void 0:c.delete(r)}),n&&(n.x-=Y.SafeBorderPadding,n.y-=Y.SafeBorderPadding,n.w+=Y.SafeBorderPadding*2,n.h+=Y.SafeBorderPadding*2),n}consume(e){const{op:t,disableEraseImage:i,disableEraseText:o}=e.data;if(!t||t.length===0)return{type:x.None,...this.baseConsumeResult};const n=this.tmpPoints.length;if(n>1&&this.isNear([t[0],t[1]],[this.tmpPoints[n-2],this.tmpPoints[n-1]]))return{type:x.None,...this.baseConsumeResult};n<3?this.tmpPoints.push(t[0],t[1]):this.tmpPoints.splice(2,2,t[0],t[1]);const r=this.computRectCenterPoints();let c;const l=new Set,h=new Map;if(!this.vNodes)return{type:x.None,...this.baseConsumeResult};this.vNodes.setTarget();const u=this.getCanEraserNodeMap(this.vNodes.getCanEraserNodes(this.vNodes.getLastTarget(),{disableEraseImage:i,disableEraseText:o}));for(let d=0;d<r.length-1;d+=2){this.createEraserRect(r.slice(d,d+2));const f=this.remove({curNodeMap:u,removeIds:l,newWorkDatas:h});c=ce(c,f)}if(this.vNodes.deleteLastTarget(),c&&l.size){for(const d of h.keys())l.has(d)&&h.delete(d);return{type:x.RemoveNode,rect:c,removeIds:[...l],newWorkDatas:h}}return{type:x.None,...this.baseConsumeResult}}consumeAll(e){return this.consume(e)}clearTmpPoints(){this.tmpPoints.length=0}getCanEraserNodeMap(e){var t;if(this.serviceWork){const i=Ce(e),o=this.serviceWork.selectorWorkShapes,n=this.serviceWork.workShapes;for(const r of o.values())if((t=r.selectIds)!=null&&t.length)for(const c of r.selectIds)i.delete(c);for(const r of n.keys())i.delete(r);return i}return e}};y(Mt,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50}),Object.freeze({width:48,height:74})]));let es=Mt;const mt=class mt extends Y{constructor(e){super(e);y(this,"canRotate",!1);y(this,"scaleType",re.none);y(this,"toolsType",I.BitMapEraser);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"worldPosition");y(this,"worldScaling");y(this,"eraserRect");y(this,"eraserPolyline");y(this,"syncUnitTime",be.syncOpt.interval);y(this,"syncIndex",0);y(this,"syncTimestamp");this.workOptions=e.toolsOpt,this.worldPosition=this.fullLayer.worldPosition,this.worldScaling=this.fullLayer.worldScaling,this.syncTimestamp=0}combineConsume(){if(this.tmpPoints.length<2)return{type:x.None};const{thickness:e}=this.workOptions,{width:t,height:i}=mt.eraserSizes[e],o=Math.max(t,i)/this.worldScaling[0],n=this.drawLayer||this.fullLayer,r=this.workId,c={name:r};return{rect:this.draw({attrs:c,consumePoints:this.tmpPoints,replaceId:r,layer:n,thickness:o}),type:x.DrawWork,dataType:B.Local}}consumeService(e){const{op:t,isFullWork:i,replaceId:o}=e;this.tmpPoints.length=0;for(let u=0;u<t.length;u+=3){const d=new V(t[u],t[u+1],t[u+2]);if(this.tmpPoints.length>0){const f=this.tmpPoints[this.tmpPoints.length-1],g=b.Sub(d,f).uni();d.setv(g)}this.tmpPoints.push(d)}if(this.tmpPoints.length<2)return;const n=this.tmpPoints[0].z*2,r=i?this.fullLayer:this.drawLayer||this.fullLayer,l={name:this.workId};return this.draw({attrs:l,consumePoints:this.tmpPoints,layer:r,thickness:n,replaceId:o})}updateTempPoints(e,t){let i=this.tmpPoints.length-1;const o=Date.now();for(let n=0;n<e.length;n+=2){const r=this.tmpPoints.length,c=new V(e[n],e[n+1]);if(r===0){this.tmpPoints.push(c);continue}const l=r-1,h=this.tmpPoints[l],u=b.Sub(c,h).uni();c.isNear(h,t/2)||(b.Equals(u,h.v,.02)&&(this.tmpPoints.pop(),i--),c.setv(u),c.setT(o),this.tmpPoints.push(c))}return Math.max(i,0)}getChangeNodes(e,t){const i=new Map,o=new Set;let n;if(!this.vNodes)return{willDeleteNodes:o,willUpdateNodes:i,rect:n};const r=this.worldPosition;let c=pe(this.tmpPoints,e);c=Ds(c,r),c=uM(c,this.worldScaling,r);const{nodeRange:l}=this.vNodes.getRectIntersectRange(c);if(!l.size)return{willDeleteNodes:o,willUpdateNodes:i,rect:n};const h=this.computEraserPointLines(this.tmpPoints);for(const[u,d]of l.entries()){if(d.toolsType===I.Text||d.toolsType===I.Image)continue;let f=Ds(d.rect,[-r[0],-r[1]]);f={x:f.x/this.worldScaling[0],y:f.y/this.worldScaling[1],w:f.w/this.worldScaling[0],h:f.h/this.worldScaling[1]};const g=[f.x,f.y,f.x+f.w,f.y+f.h],p=[],m=[];for(const v of h)Ws.polyline(v,g,p);if(p.length&&d.opt)for(const v of p){const T=[];for(let k=0;k<v.length;k++)k!==0&&tt(v[k],v[k-1])||T.push(...v[k]);m.push(T)}if(d.opt.eraserlines||(d.opt.eraserlines=[]),d.opt.eraserlines){if(d.opt.eraserlines.push({op:m,thickness:e}),t){const{toolsType:v}=d,T=t.createWorkShapeNode({workId:u,toolsType:v,toolsOpt:d.opt});T==null||T.setWorkId(u);const k=T==null?void 0:T.consumeService({op:d.op,isFullWork:!0,replaceId:u});if(n=ce(n,k),T!=null&&T.isDelete){t.removeNode(u),o.add(u);continue}}i.set(u,d)}}return{willUpdateNodes:i,willDeleteNodes:o,rect:n}}consume(e){const{data:t,isFullWork:i,isSubWorker:o,isMainThread:n,removeDrawCount:r,drawCount:c}=e,{op:l}=t;if(!l||l.length===0)return{type:x.None,...this.baseConsumeResult};const{thickness:h}=this.workOptions,{width:u,height:d}=mt.eraserSizes[h],f=Math.max(u,d)/this.worldScaling[0],g=this.tmpPoints.length,p=this.tmpPoints[this.tmpPoints.length-1],m=this.updateTempPoints(l,f),N=this.tmpPoints[this.tmpPoints.length-1];if(g===this.tmpPoints.length&&N.equalsXY(p.x,p.y))return{type:x.None,...this.baseConsumeResult};this.syncIndex=Math.min(this.syncIndex,m,Math.max(0,this.tmpPoints.length-2));const v={name:this.workId,id:Ae(c)&&c.toString()||void 0},T=this.syncIndex;this.syncTimestamp===0&&(this.syncTimestamp=Date.now());let k=!1,S;const w=this.tmpPoints.slice(m);if(o||n){const L=i?this.fullLayer:this.drawLayer||this.fullLayer;S=this.draw({attrs:v,consumePoints:w,layer:L,removeDrawCount:r,thickness:f})}if(o)return m>10&&this.tmpPoints.splice(0,m-10),{rect:S,type:x.DrawWork,dataType:B.Local};w[0].t-this.syncTimestamp>this.syncUnitTime&&(k=!0,this.syncTimestamp=w[0].t,this.syncIndex=this.tmpPoints.length);const C=[];return this.tmpPoints.slice(T).forEach(L=>{C.push(L.x,L.y,f/2)}),{...this.baseConsumeResult,type:x.DrawWork,dataType:B.Local,rect:S,op:k?C:void 0,index:k?T*3:void 0,updateNodeOpt:{useAnimation:!0}}}draw(e){const{attrs:t,consumePoints:i,layer:o,thickness:n,replaceId:r,removeDrawCount:c}=e;c&&this.removeDrawCountNodes(o,c);let l=pe(i,n);l={x:Math.floor(l.x*this.worldScaling[0]+this.worldPosition[0]-Y.SafeBorderPadding),y:Math.floor(l.y*this.worldScaling[1]+this.worldPosition[1]-Y.SafeBorderPadding),w:Math.floor(l.w*this.worldScaling[0]+2*Y.SafeBorderPadding),h:Math.floor(l.h*this.worldScaling[1]+2*Y.SafeBorderPadding)};const h=new le.Group({...t,normalize:!0,pos:[0,0],anchor:[.5,.5],zIndex:9999,bgcolor:"rgba(136,136,136,0.3)"}),u=this.computEraserPointLines(i),d=[];for(const f of u)d.push({op:f,thickness:n});for(const f of d){const{thickness:g,op:p}=f,m=p.reduce((S,w,C,L)=>C>0&&L[C-1][0]===w[0]&&L[C-1][1]===w[1]?S:S.concat(w[0],w[1]),[]),N=this.computEraserPoints(m,g),v=Je(N,!0),T={pos:[0,0],d:v,fillColor:"rgba(136,136,136,0.3)"},k=new le.Path(T);h.append(k),h.seal()}return this.replace(o,r,h),l}computEraserPointLines(e,t=60){const i=[];let o=0;const n=360-t;for(let r=1;r<e.length;r++){const c=e[r-1],l=e[r];if(r===1&&o===0&&(i[o]=[c.XY]),i[o].push(l.XY),r<e.length-1){const h=l.getAngleByPoints(c,e[r+1]);(h<t||h>n)&&(o++,i[o]=[l.XY])}}return e.length===1&&i.length===0&&i.push([e[0].XY,e[0].XY]),i}consumeAll(e){const{workerEngine:t}=e;if(this.replace(this.fullLayer,this.workId),!this.tmpPoints.length)return{type:x.None,...this.baseConsumeResult};const{thickness:i}=this.workOptions,{width:o,height:n}=mt.eraserSizes[i],r=Math.max(o,n)/this.worldScaling[0],{willDeleteNodes:c,willUpdateNodes:l,rect:h}=this.getChangeNodes(r,t);if(c.size===0&&l.size===0)return{type:x.FullWork,...this.baseConsumeResult,rect:h};const u=[];this.tmpPoints.map(f=>{u.push(f.x,f.y,r/2)});const d=Re(u);return{...this.baseConsumeResult,type:x.FullWork,dataType:B.Local,rect:h,ops:d,willUpdateNodes:l,willDeleteNodes:c}}clearTmpPoints(){this.tmpPoints.length=0}};y(mt,"eraserSizes",Object.freeze([Object.freeze({width:18,height:26}),Object.freeze({width:26,height:34}),Object.freeze({width:34,height:50}),Object.freeze({width:48,height:74})]));let ts=mt;function Uo(a){switch(a){case I.Arrow:return Ao;case I.Pencil:return Lo;case I.Straight:return Yo;case I.Ellipse:return jo;case I.Polygon:case I.Triangle:return Ro;case I.Star:case I.Rhombus:return Oo;case I.Rectangle:return Eo;case I.SpeechBalloon:return Wo;case I.Text:return _t;case I.LaserPen:return zo;case I.Eraser:return Xt;case I.PencilEraser:return es;case I.BitMapEraser:return ts;case I.Selector:return Kt;case I.Image:return Ot}}function ps(a,s){const{toolsType:e,...t}=a;switch(e){case I.Arrow:return new Ao(t);case I.Pencil:return new Lo(t);case I.Straight:return new Yo(t);case I.Ellipse:return new jo(t);case I.Polygon:case I.Triangle:return new Ro(t);case I.Star:case I.Rhombus:return new Oo(t);case I.Rectangle:return new Eo(t);case I.SpeechBalloon:return new Wo(t);case I.Text:return new _t(t);case I.LaserPen:return new zo(t);case I.Eraser:return new Xt(t,s);case I.BitMapEraser:return new ts(t);case I.PencilEraser:return new es(t,s);case I.Selector:return t.vNodes?new Kt({...t,vNodes:t.vNodes,drawLayer:t.fullLayer}):void 0;case I.Image:return new Ot(t);default:return}}function Bo(a){const s=[],e=["PATH","SPRITE","POLYLINE","RECT","ELLIPSE","LABEL"];for(const t of a){if(t.tagName==="GROUP"&&t.children.length)return Bo(t.children);t.tagName&&e.includes(t.tagName)&&s.push(t)}return s}const Qf="cursorhover",fs=20,de="mainView";class Fo{constructor(s,e){y(this,"viewId");y(this,"scene");y(this,"fullLayer");y(this,"curNodeMap",new Map);y(this,"targetNodeMap",[]);y(this,"highLevelIds");y(this,"canClearUids");y(this,"localUid");this.viewId=s,this.scene=e}init(s){this.fullLayer=s}get(s){return this.curNodeMap.get(s)}setLocalUid(s){this.localUid=s}getLocalUid(){return this.localUid}setCanClearUids(s){this.canClearUids=s}getCanClearUids(){return this.canClearUids}getCanEraserNodes(s,e){const t=new Map;for(const[i,o]of s.entries())o.toolsType===I.Image&&(o.opt.locked||e&&e.disableEraseImage)||o.toolsType===I.Text&&(o.opt.workState===P.Doing||o.opt.workState===P.Start||e&&e.disableEraseText)||this.isCanClearWorkId(i)&&t.set(i,o);return t}getNodesByType(s){const e=new Map;return this.curNodeMap.forEach((t,i)=>{t.toolsType===s&&e.set(i,t)}),e}gethasEraserNodes(){const s=new Map;return this.curNodeMap.forEach((e,t)=>{var i;(i=e.opt.eraserlines)!=null&&i.length&&s.set(t,e)}),s}hasRenderNodes(){return!0}has(s){return this.curNodeMap.has(s)}setInfo(s,e){const t=this.curNodeMap.get(s)||{name:s,rect:e.rect};e.rect&&(t.rect=Ce(e.rect)),e.op&&fM(e.op)&&(t.op=Ce(e.op)),e.canRotate&&(t.canRotate=e.canRotate),e.scaleType&&(t.scaleType=e.scaleType),e.opt&&(t.opt=Ce(e.opt)),e.toolsType&&(t.toolsType=e.toolsType),e.centerPos&&(t.centerPos=Ce(e.centerPos)),gt(e.isSelected)&&(t.isSelected=e.isSelected),t.rect?this.curNodeMap.set(s,t):this.curNodeMap.delete(s)}selected(s){this.setInfo(s,{isSelected:!0})}unSelected(s){this.setInfo(s,{isSelected:!1})}delete(s){this.curNodeMap.delete(s)}clear(){this.curNodeMap.clear(),this.targetNodeMap.length=0}getRectIntersectRange(s,e=!0,t=!0){let i;const o=new Map;for(const[n,r]of this.curNodeMap.entries())if(Rt(s,r.rect)){if(e&&r.toolsType===I.Image&&r.opt.locked||t&&r.toolsType===I.Text&&(r.opt.workState===P.Doing||r.opt.workState===P.Start))continue;i=ce(i,r.rect),o.set(n,r)}return{rectRange:i,nodeRange:o}}getNodeRectFormShape(s,e){const t=Uo(e.toolsType);return this.fullLayer&&(t==null?void 0:t.getRectFromLayer(this.fullLayer,s))}updateNodeRect(s){const e=this.curNodeMap.get(s);if(e){const t=this.getNodeRectFormShape(s,e);if(!t){this.curNodeMap.delete(s);return}e.rect=t,this.curNodeMap.set(s,e)}}updateHighLevelNodesRect(s){this.highLevelIds=s;for(const e of this.highLevelIds.keys())this.updateNodeRect(e)}updateLowLevelNodesRect(){var s;for(const e of this.curNodeMap.keys())(s=this.highLevelIds)!=null&&s.has(e)||this.updateNodeRect(e)}clearHighLevelIds(){this.highLevelIds=void 0}setTargetAssignKeys(s){const e=new Map;for(const t of s){const i=this.curNodeMap.get(t);i&&e.set(t,Ce(i))}return this.targetNodeMap.push(Ce(e)),this.targetNodeMap.length-1}setTarget(){return this.targetNodeMap.push(Ce(this.curNodeMap)),this.targetNodeMap.length-1}getLastTarget(){return this.targetNodeMap[this.targetNodeMap.length-1]}deleteLastTarget(){this.targetNodeMap.length&&(this.targetNodeMap.length=this.targetNodeMap.length-1)}getTarget(s){return this.targetNodeMap[s]}deleteTarget(s){this.targetNodeMap.length=s}clearTarget(){this.targetNodeMap.length=0}isLocalWorkId(s){return s.split(Ee).length===1}isCanClearWorkId(s){if(this.canClearUids===void 0||this.canClearUids===!0)return!0;if(Ed(this.canClearUids)){const e=s.split(Ee);if(e.length===1)return this.canClearUids.has("localSelf")||this.localUid&&this.canClearUids.has(this.localUid);if(e.length===2)return this.canClearUids.has(e[0])}return!1}}class Gf{constructor(s,e,t){y(this,"viewId");y(this,"scene");y(this,"fullLayer");y(this,"vNodes");y(this,"dpr");y(this,"contextType");y(this,"opt");y(this,"cameraOpt");y(this,"isSafari",!1);y(this,"combinePostMsg",new Set);y(this,"workerTaskId");y(this,"protectedTask");y(this,"hasPriorityDraw",!0);y(this,"delayPostDoneResolve");y(this,"cacheImages",new Map);y(this,"imageResolveMap",new Map);var i,o;if(this.viewId=s,this.opt=e,this.dpr=e.dpr,this.contextType=this.getSupportContextType(t,(i=e==null?void 0:e.offscreenCanvasOpt)==null?void 0:i.contextType),!this.contextType)throw new Error("Sorry, your browser doesn't support canvas context type 2d or webgl");try{this.createRenderLayer(e)}catch{if(this.contextType!=="2d")this.contextType="2d",(o=this.scene)==null||o.disconnect(),this.createRenderLayer(e);else throw new Error(`Sorry, your browser doesn't support canvas context type ${this.contextType}`)}this.vNodes=new Fo(s,this.scene)}createRenderLayer(s){this.scene=this.createScene(s.offscreenCanvasOpt);const e=be.bufferSize.full,t=be.bufferSize.sub;this.fullLayer=this.createLayer("fullLayer",this.scene,{...s.layerOpt,bufferSize:this.viewId===de?e:t*2})}async updateDpr(s){this.dpr=s,this.scene.displayRatio=s}getCachedImages(s){var e;return(e=this.cacheImages.get(s))==null?void 0:e.imageBitmap}getCachedImagesByWorkId(s){for(const[e,t]of this.cacheImages.entries())if(e===s&&t.imageBitmap)return t.imageBitmap}deleteCachedImagesByWorkId(s,e){for(const[t,i]of this.cacheImages.entries())e&&t===e||i.workId===s&&(i.imageBitmap.close(),this.cacheImages.delete(t))}clearCacheImages(){this.cacheImages.forEach(s=>s.imageBitmap.close()),this.cacheImages.clear()}clearImageResolveMap(){this.imageResolveMap.forEach(({timer:s})=>{s&&clearTimeout(s)}),this.imageResolveMap.clear()}setHasPriorityDraw(s){this.hasPriorityDraw=s}getPriorityDraw(){return this.hasPriorityDraw}setIsSafari(s){this.isSafari=s}async on(s){const{msgType:e,toolsType:t,opt:i,imageSrc:o,imageBitmap:n,workId:r,dpr:c}=s;switch(e){case x.UpdateDpr:Ae(c)&&await this.updateDpr(c);break;case x.UpdateCamera:await this.updateCamera(s);break;case x.Destroy:this.destroy();break;case x.Clear:await this.clearAll();break;case x.UpdateTools:if(t&&i){const l={toolsType:t,toolsOpt:i};this.localWork.setToolsOpt(l)}break;case x.GetImageBitMap:if(o&&n&&r){const l=r.toString();this.cacheImages.set(o,{imageBitmap:n,workId:l});const h=this.imageResolveMap.get(o);if(h){const{resolve:u,timer:d}=h;d&&clearTimeout(d),u&&u(o)}this.deleteCachedImagesByWorkId(l,o)}break}}getIconSize(s,e,t){const i=s*t,o=e*t;return i<=50||o<=50?[50,50]:i<=100||o<=100?[100,100]:i<=200||o<=200?[200,200]:i<=400||o<=400?[400,400]:i<=800||o<=800?[800,800]:[1600,1600]}async loadImageBitMap(s){const{toolsType:e,opt:t,workId:i,isSubWorker:o}=s;if(e===I.Image&&t&&i){const n=i.toString(),{src:r,type:c,width:l,height:h,strokeColor:u}=t;if(!r||!c||!l||!h)return;let d=r;if(c===lt.Iconify){const[m,N]=this.getIconSize(l,h,this.dpr);d=`${r}?width=${m}&height=${N}&color=${u}`}if(this.cacheImages.has(d)){const m=this.getCachedImages(d);if(m)return m}if(this.imageResolveMap.has(d)){const m=this.getCachedImagesByWorkId(n);if(m)return m}const p=await new Promise(m=>{const N=this.imageResolveMap.get(d)||{resolve:void 0,timer:void 0};N.timer&&clearTimeout(N.timer),N.resolve=m,N.timer=setTimeout(()=>{const v=this.imageResolveMap.get(d);v!=null&&v.resolve&&v.resolve(d)},5e3),this.imageResolveMap.set(d,N),this._post({sp:[{imageSrc:d,workId:n,viewId:this.viewId,isgl:!!this.fullLayer.parent.gl,isSubWorker:o,type:x.GetImageBitMap}]})});return this.imageResolveMap.delete(p),this.getCachedImages(d)}}createLocalWork(s){const{workId:e,opt:t,toolsType:i}=s;e&&t&&(!this.localWork.getToolsOpt()&&i&&this.setToolsOpt({toolsType:i,toolsOpt:t}),this.setWorkOpt({workId:e,toolsOpt:t}))}updateScene(s){this.scene.attr({...s});const{width:e,height:t}=s;this.scene.container.width=e,this.scene.container.height=t,this.scene.width=e,this.scene.height=t,this.updateLayer({width:e,height:t})}updateLayer(s){const{width:e,height:t}=s;this.fullLayer&&(this.fullLayer.parent.setAttribute("width",e),this.fullLayer.parent.setAttribute("height",t),this.fullLayer.setAttribute("size",[e,t]),this.fullLayer.setAttribute("pos",[e*.5,t*.5]))}getSupportContextType(s,e){const t=new OffscreenCanvas(100,100);let i=["2d"];s===Ps.Full&&this.viewId===de&&(i=["webgl2","webgl","2d"],e&&i.unshift(e));for(const o of i)try{if(t.getContext(o))return o}catch{continue}}createScene(s){const{width:e,height:t}=s,i=new OffscreenCanvas(e,t);s.contextType&&delete s.contextType;const o=new le.Scene({container:i,displayRatio:this.dpr,depth:!1,desynchronized:!0,failIfMajorPerformanceCaveat:!0,...s,contextType:this.contextType,id:this.viewId});return o.setAttribute("id",this.viewId),o}createLayer(s,e,t){const{width:i,height:o}=t,n=`offscreen-${s}`,r=e.layer(n,t),c=new le.Group({anchor:[.5,.5],pos:[i*.5,o*.5],size:[i,o],name:"viewport",id:s});return r.append(c),c}async clearAll(){var s;this.fullLayer&&(this.fullLayer.parent.children.forEach(e=>{e.name!=="viewport"&&e.remove()}),this.fullLayer.removeAllChildren()),this.clearCacheImages(),this.clearImageResolveMap(),this.localWork.destroy(),(s=this.serviceWork)==null||s.destroy()}setToolsOpt(s){this.localWork.setToolsOpt(s)}setWorkOpt(s){const{workId:e,toolsOpt:t}=s;e&&t&&this.localWork.setWorkOptions(e.toString(),t)}destroy(){var s;this.vNodes.clear(),this.fullLayer.remove(),this.clearCacheImages(),this.clearImageResolveMap(),this.scene.remove(),this.localWork.destroy(),(s=this.serviceWork)==null||s.destroy()}async post(s){this.combinePostMsg.add(s),await this.runBatchPostData()}async runBatchPostData(){this.workerTaskId||(this.workerTaskId=setTimeout(()=>{this.workerTaskId=void 0,this.combinePost()},16)),this.type===Ps.Full&&!this.delayPostDoneResolve&&await new Promise(e=>{this.delayPostDoneResolve=e})&&(this.delayPostDoneResolve=void 0)}combinePostData(){var r,c;this.workerTaskId=void 0;const s=[],e=[];let t,i,o;const n=new Set;for(const l of this.combinePostMsg.values()){if((r=l.render)!=null&&r.length)for(const h of l.render){let u=!1;if(h.workId&&n.add(h.workId),h.isClearAll&&(h.rect=this.getSceneRect(),h.isClear=!0,delete h.isClearAll),h.drawCanvas){const d=this.getLayer(h.drawCanvas);if(!d||!(d.parent instanceof le.Layer))continue;if(d.parent.render(),h.isDrawAll){const f=this.getSceneRect();h.rect=f,delete h.isDrawAll}}for(const d of s)if(h.viewId===d.viewId){h.isClear&&d.clearCanvas&&d.isClear&&d.clearCanvas===h.clearCanvas&&(d.rect=ce(d.rect,h.rect),u=!0),d.drawCanvas&&d.drawCanvas===h.drawCanvas&&(d.rect=ce(d.rect,h.rect),u=!0);continue}u||(h.isClear&&!h.drawCanvas?s.unshift(h):s.push(h))}if((c=l.sp)!=null&&c.length)for(const h of l.sp){let u=!1;for(const d of e)if(tt(h,d)){u=!0;break}u||e.push(h)}Ae(l.fullWorkerDrawCount)&&(t=l.fullWorkerDrawCount),Ae(l.subWorkerDrawCount)&&(i=l.subWorkerDrawCount),Ae(l.consumeCount)&&(o=l.consumeCount)}return this.combinePostMsg.clear(),{render:s,sp:e,fullWorkerDrawCount:t,subWorkerDrawCount:i,consumeCount:o,workIds:n,viewId:this.viewId}}safariFixRect(s,e){if(s.w+s.x<=0||s.h+s.y<=0||s.w<=0||s.h<=0)return;const t=this.scene.width,i=this.scene.height,o={x:Math.floor(Math.max(0,s.x)),y:Math.floor(Math.max(0,s.y)),w:Math.floor(Math.min(t,s.w)),h:Math.floor(Math.min(i,s.h))};if(o.x+o.w>t&&(o.w=Math.floor(t-o.x)),o.y+o.h>i&&(o.h=Math.floor(i-o.y)),gM(e)){const n=yM(e),r=Math.pow(10,n),c=MM(r,e*r),l=o.x%c,h=o.x-l;h>=0?(o.x=h,o.w=o.w+l):(o.x=0,o.w=o.w+l-h);const u=o.y%c,d=o.y-u;d>=0?(o.y=d,o.h=o.h+u):(o.y=0,o.h=o.h+u-d)}return o}getSceneRect(){const{width:s,height:e}=this.scene;return{x:0,y:0,w:Math.floor(s),h:Math.floor(e)}}}class Zf{constructor(s){y(this,"viewId");y(this,"vNodes");y(this,"thread");y(this,"fullLayer");y(this,"drawLayer");y(this,"_post");y(this,"tmpOpt");y(this,"workShapes",new Map);y(this,"drawCount",0);y(this,"consumeCount",0);y(this,"syncUnitTime",be.syncOpt.interval);this.thread=s.thread,this.viewId=s.viewId,this.vNodes=s.vNodes,this.fullLayer=s.fullLayer,this.drawLayer=s.drawLayer,this._post=this.thread.post.bind(s.thread)}destroy(){this.workShapes.clear()}getWorkShapes(){return this.workShapes}getWorkShape(s){return this.workShapes.get(s)}createWorkShape(s,e){if(s&&this.tmpOpt){const t={toolsType:this.tmpOpt.toolsType,toolsOpt:e||this.tmpOpt.toolsOpt},i=this.createWorkShapeNode({...t,workId:s});i&&this.workShapes.set(s,i)}}setWorkOptions(s,e){const t=this.getWorkShape(s);t||this.createWorkShape(s,e),t==null||t.setWorkOptions(e)}createWorkShapeNode(s){var e;return ps({...s,vNodes:this.vNodes,fullLayer:this.fullLayer,drawLayer:this.drawLayer},(e=this.thread)==null?void 0:e.serviceWork)}setToolsOpt(s){var e,t,i;((e=this.tmpOpt)==null?void 0:e.toolsType)!==s.toolsType&&(t=this.tmpOpt)!=null&&t.toolsType&&this.clearAllWorkShapesCache(),this.tmpOpt=s,(i=s.toolsOpt)!=null&&i.syncUnitTime&&(this.syncUnitTime=s.toolsOpt.syncUnitTime)}getToolsOpt(){return this.tmpOpt}clearWorkShapeNodeCache(s){var e;(e=this.getWorkShape(s))==null||e.clearTmpPoints(),this.workShapes.delete(s)}clearAllWorkShapesCache(){this.workShapes.forEach(s=>s.clearTmpPoints()),this.workShapes.clear()}setFullWork(s){const{workId:e,opt:t,toolsType:i}=s;if(e&&t&&i){const o=e.toString();let n;return e&&this.workShapes.has(o)?(n=this.workShapes.get(o),n==null||n.setWorkOptions(t)):n=this.createWorkShapeNode({toolsOpt:t,toolsType:i,workId:o}),n?(this.workShapes.set(o,n),n):void 0}}}var qf=Qe,Xf=function(){return qf.Date.now()},Jf=Xf,Kf=/\s/;function _f(a){for(var s=a.length;s--&&Kf.test(a.charAt(s)););return s}var eg=_f,tg=eg,sg=/^\s+/;function ig(a){return a&&a.slice(0,tg(a)+1).replace(sg,"")}var og=ig,ng=ht,rg=qe,ag="[object Symbol]";function cg(a){return typeof a=="symbol"||rg(a)&&ng(a)==ag}var lg=cg,hg=og,Ui=st,ug=lg,Bi=NaN,dg=/^[-+]0x[0-9a-f]+$/i,pg=/^0b[01]+$/i,fg=/^0o[0-7]+$/i,gg=parseInt;function yg(a){if(typeof a=="number")return a;if(ug(a))return Bi;if(Ui(a)){var s=typeof a.valueOf=="function"?a.valueOf():a;a=Ui(s)?s+"":s}if(typeof a!="string")return a===0?a:+a;a=hg(a);var e=pg.test(a);return e||fg.test(a)?gg(a.slice(2),e?2:8):dg.test(a)?Bi:+a}var Mg=yg,mg=st,Ns=Jf,Fi=Mg,wg="Expected a function",vg=Math.max,Ig=Math.min;function Ng(a,s,e){var t,i,o,n,r,c,l=0,h=!1,u=!1,d=!0;if(typeof a!="function")throw new TypeError(wg);s=Fi(s)||0,mg(e)&&(h=!!e.leading,u="maxWait"in e,o=u?vg(Fi(e.maxWait)||0,s):o,d="trailing"in e?!!e.trailing:d);function f(w){var C=t,L=i;return t=i=void 0,l=w,n=a.apply(L,C),n}function g(w){return l=w,r=setTimeout(N,s),h?f(w):n}function p(w){var C=w-c,L=w-l,j=s-C;return u?Ig(j,o-L):j}function m(w){var C=w-c,L=w-l;return c===void 0||C>=s||C<0||u&&L>=o}function N(){var w=Ns();if(m(w))return v(w);r=setTimeout(N,p(w))}function v(w){return r=void 0,d&&t?f(w):(t=i=void 0,n)}function T(){r!==void 0&&clearTimeout(r),l=0,t=c=i=r=void 0}function k(){return r===void 0?n:v(Ns())}function S(){var w=Ns(),C=m(w);if(t=arguments,i=this,c=w,C){if(r===void 0)return g(c);if(u)return clearTimeout(r),r=setTimeout(N,s),f(c)}return r===void 0&&(r=setTimeout(N,s)),n}return S.cancel=T,S.flush=k,S}var Sg=Ng,Tg=Sg,kg=st,Cg="Expected a function";function bg(a,s,e){var t=!0,i=!0;if(typeof a!="function")throw new TypeError(Cg);return kg(e)&&(t="leading"in e?!!e.leading:t,i="trailing"in e?!!e.trailing:i),Tg(a,s,{leading:t,maxWait:s,trailing:i})}var xg=bg;const gs=St(xg);function Lg(a){return a}var Vo=Lg;function zg(a,s,e){switch(e.length){case 0:return a.call(s);case 1:return a.call(s,e[0]);case 2:return a.call(s,e[0],e[1]);case 3:return a.call(s,e[0],e[1],e[2])}return a.apply(s,e)}var Pg=zg,Dg=Pg,Vi=Math.max;function Ag(a,s,e){return s=Vi(s===void 0?a.length-1:s,0),function(){for(var t=arguments,i=-1,o=Vi(t.length-s,0),n=Array(o);++i<o;)n[i]=t[s+i];i=-1;for(var r=Array(s+1);++i<s;)r[i]=t[i];return r[s]=e(n),Dg(a,this,r)}}var jg=Ag;function Eg(a){return function(){return a}}var Og=Eg,Rg=Og,$i=no,Wg=Vo,Yg=$i?function(a,s){return $i(a,"toString",{configurable:!0,enumerable:!1,value:Rg(s),writable:!0})}:Wg,Ug=Yg,Bg=800,Fg=16,Vg=Date.now;function $g(a){var s=0,e=0;return function(){var t=Vg(),i=Fg-(t-e);if(e=t,i>0){if(++s>=Bg)return arguments[0]}else s=0;return a.apply(void 0,arguments)}}var Hg=$g,Qg=Ug,Gg=Hg,Zg=Gg(Qg),qg=Zg,Xg=Vo,Jg=jg,Kg=qg;function _g(a,s){return Kg(Jg(a,s,Xg),a+"")}var ey=_g;function ty(a,s,e,t){for(var i=a.length,o=e+(t?1:-1);t?o--:++o<i;)if(s(a[o],o,a))return o;return-1}var sy=ty;function iy(a){return a!==a}var oy=iy;function ny(a,s,e){for(var t=e-1,i=a.length;++t<i;)if(a[t]===s)return t;return-1}var ry=ny,ay=sy,cy=oy,ly=ry;function hy(a,s,e){return s===s?ly(a,s,e):ay(a,cy,e)}var uy=hy,dy=uy;function py(a,s){var e=a==null?0:a.length;return!!e&&dy(a,s,0)>-1}var $o=py;function fy(a,s,e){for(var t=-1,i=a==null?0:a.length;++t<i;)if(e(s,a[t]))return!0;return!1}var Ho=fy;function gy(a,s){for(var e=-1,t=a==null?0:a.length,i=Array(t);++e<t;)i[e]=s(a[e],e,a);return i}var yy=gy,My=Js,my=$o,wy=Ho,vy=yy,Iy=us,Ny=Ks,Sy=200;function Ty(a,s,e,t){var i=-1,o=my,n=!0,r=a.length,c=[],l=s.length;if(!r)return c;e&&(s=vy(s,Iy(e))),t?(o=wy,n=!1):s.length>=Sy&&(o=Ny,n=!1,s=new My(s));e:for(;++i<r;){var h=a[i],u=e==null?h:e(h);if(h=t||h!==0?h:0,n&&u===u){for(var d=l;d--;)if(s[d]===u)continue e;c.push(h)}else o(s,u,t)||c.push(h)}return c}var ky=Ty,Hi=Wt,Cy=lo,by=Yt,Qi=Hi?Hi.isConcatSpreadable:void 0;function xy(a){return by(a)||Cy(a)||!!(Qi&&a&&a[Qi])}var Ly=xy,zy=Zs,Py=Ly;function Qo(a,s,e,t,i){var o=-1,n=a.length;for(e||(e=Py),i||(i=[]);++o<n;){var r=a[o];s>0&&e(r)?s>1?Qo(r,s-1,e,t,i):zy(i,r):t||(i[i.length]=r)}return i}var Dy=Qo;function Ay(){}var jy=Ay,Ss=Io,Ey=jy,Oy=_s,Ry=1/0,Wy=Ss&&1/Oy(new Ss([,-0]))[1]==Ry?function(a){return new Ss(a)}:Ey,Yy=Wy,Uy=Js,By=$o,Fy=Ho,Vy=Ks,$y=Yy,Hy=_s,Qy=200;function Gy(a,s,e){var t=-1,i=By,o=a.length,n=!0,r=[],c=r;if(e)n=!1,i=Fy;else if(o>=Qy){var l=s?null:$y(a);if(l)return Hy(l);n=!1,i=Vy,c=new Uy}else c=s?[]:r;e:for(;++t<o;){var h=a[t],u=s?s(h):h;if(h=e||h!==0?h:0,n&&u===u){for(var d=c.length;d--;)if(c[d]===u)continue e;s&&c.push(u),r.push(h)}else i(c,u,e)||(c!==r&&c.push(u),r.push(h))}return r}var Zy=Gy,qy=ky,Xy=Dy,Gi=Zy;function Jy(a,s,e){var t=a.length;if(t<2)return t?Gi(a[0]):[];for(var i=-1,o=Array(t);++i<t;)for(var n=a[i],r=-1;++r<t;)r!=i&&(o[i]=qy(o[i]||n,a[r],s,e));return Gi(Xy(o,1),s,e)}var Ky=Jy,_y=$s,eM=qe;function tM(a){return eM(a)&&_y(a)}var sM=tM,iM=go,oM=ey,nM=Ky,rM=sM;oM(function(a){return nM(iM(a,rM))});class aM extends Zf{constructor(e){super(e);y(this,"drawWorkActiveId")}async runFullWork(e){var o;const t=this.setFullWork(e),i=e.ops&&it(e.ops);if(t){let n,r;const c=(o=t.getWorkId())==null?void 0:o.toString();return t.toolsType===I.Image?n=await t.consumeServiceAsync({isFullWork:!0,worker:this.thread}):t.toolsType===I.Text?n=await t.consumeServiceAsync({isFullWork:!0,replaceId:c,isDrawLabel:!0}):(n=t.consumeService({op:i,isFullWork:!0,replaceId:c}),r=(e==null?void 0:e.updateNodeOpt)&&t.updataOptService(e.updateNodeOpt)),e.workId&&this.workShapes.delete(e.workId.toString()),ce(n,r)}}runSelectWork(e){var i;const t=this.setFullWork(e);t&&((i=e.selectIds)!=null&&i.length)&&e.workId&&t.selectServiceNode(e.workId.toString(),{selectIds:e.selectIds},!1)}workShapesDone(){for(const e of this.workShapes.keys())this.clearWorkShapeNodeCache(e);this.fullLayer.removeAllChildren()}canUseSubWorker(e){const t=this.thread.getPriorityDraw();return t||!t&&e!==I.Pencil}async consumeDraw(e){const{workId:t,fullWorkerDrawCount:i,postCount:o}=e,n=t==null?void 0:t.toString(),r=n&&this.workShapes.get(n);if(!r)return;this.drawWorkActiveId&&this.drawWorkActiveId!==n&&(await this.consumeDrawAll({workId:this.drawWorkActiveId,viewId:this.viewId,msgType:x.DrawWork,dataType:B.Local}),this.drawWorkActiveId=void 0),!this.drawWorkActiveId&&n!==Q&&(this.drawWorkActiveId=n);const c=r.toolsType;Ae(o)&&(this.consumeCount=o);const l=r.consume({data:e,drawCount:this.drawCount,isFullWork:!0,isSubWorker:!0,removeDrawCount:i});switch(c){case I.Arrow:case I.Straight:case I.Ellipse:case I.Rectangle:case I.Star:case I.Polygon:case I.SpeechBalloon:{l&&(this.drawCount++,await this.drawShape(l));break}case I.Pencil:case I.BitMapEraser:{l&&(this.drawCount++,await this.drawPencil(l,t==null?void 0:t.toString()));break}}}async consumeDrawAll(e){const{workId:t}=e;if(t){const i=t.toString();this.drawWorkActiveId===i&&(this.drawWorkActiveId=void 0);const o=this.workShapes.get(i);if(!o)return;switch(o.toolsType){case I.Arrow:case I.Straight:case I.Ellipse:case I.Pencil:case I.Rectangle:case I.Star:case I.Polygon:case I.SpeechBalloon:case I.BitMapEraser:this.drawCount=0,this.fullLayer.removeAllChildren(),this.clearWorkShapeNodeCache(i);break}}}async removeWork(e){const{workId:t}=e,i=t==null?void 0:t.toString();if(i){const o=this.removeNode(i);if(o){const n=[];n.push({rect:Dt(o),clearCanvas:ye.Float,isClear:!0,viewId:this.viewId},{rect:Dt(o),drawCanvas:ye.Float,viewId:this.viewId}),await this._post({render:n})}}}removeNode(e){const t=this.workShapes.has(e);let i;return t&&(this.fullLayer.getElementsByName(e).forEach(o=>{const n=o.getBoundingClientRect();i=ce(i,{x:n.x-Y.SafeBorderPadding,y:n.y-Y.SafeBorderPadding,w:n.width+Y.SafeBorderPadding*2,h:n.height+Y.SafeBorderPadding*2}),o.remove()}),i&&this.clearWorkShapeNodeCache(e)),i}async drawPencil(e,t){await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:e==null?void 0:e.rect,workId:t,drawCanvas:ye.Float,viewId:this.viewId}],sp:(e==null?void 0:e.op)&&[e]})}async drawShape(e){await this._post({subWorkerDrawCount:this.drawCount,consumeCount:this.consumeCount,render:[{rect:(e==null?void 0:e.rect)&&Dt(e.rect),isClear:!0,clearCanvas:ye.Float,viewId:this.viewId},{rect:(e==null?void 0:e.rect)&&Dt(e.rect),drawCanvas:ye.Float,viewId:this.viewId}]})}}class cM{constructor(s){y(this,"viewId");y(this,"vNodes");y(this,"topLayer");y(this,"thread");y(this,"post");y(this,"serviceWorkShapes",new Map);y(this,"localWorkShapes",new Map);y(this,"tmpOpt");y(this,"syncUnitTime",be.syncOpt.interval);y(this,"animationId");this.viewId=s.viewId,this.vNodes=s.vNodes,this.topLayer=s.topLayer,this.thread=s.thread,this.post=s.thread.post.bind(s.thread)}canUseTopLayer(s){return s===I.LaserPen}getWorkShape(s){return this.localWorkShapes.get(s)}createWorkShape(s,e){if(s&&this.tmpOpt){const t={toolsType:this.tmpOpt.toolsType,toolsOpt:e||this.tmpOpt.toolsOpt},i=this.createWorkShapeNode({...t,workId:s});return i&&this.localWorkShapes.set(s,{node:i,toolsType:i.toolsType,workState:P.Start}),i}}setWorkOptions(s,e){var i;const t=(i=this.localWorkShapes.get(s))==null?void 0:i.node;t||this.createWorkShape(s,e),t==null||t.setWorkOptions(e)}createWorkShapeNode(s){const{toolsType:e}=s;if(e===I.LaserPen)return ps({...s,vNodes:this.vNodes,fullLayer:this.topLayer,drawLayer:this.topLayer})}clearAllWorkShapesCache(){this.localWorkShapes.forEach(s=>{var e;return(e=s.node)==null?void 0:e.clearTmpPoints()}),this.localWorkShapes.clear()}setToolsOpt(s){var e;this.tmpOpt=s,(e=s.toolsOpt)!=null&&e.syncUnitTime&&(this.syncUnitTime=s.toolsOpt.syncUnitTime)}getToolsOpt(){return this.tmpOpt}consumeDraw(s){const{workId:e,dataType:t}=s;if(t===B.Service)this.activeServiceWorkShape(s);else{const i=e==null?void 0:e.toString(),o=i&&this.localWorkShapes.get(i);if(!o)return;const n=o.node.consume({data:s,isFullWork:!1,isSubWorker:!0});n.rect&&(o.totalRect=ce(n.rect,o.totalRect),o.result=n,o.workState=P.Doing,i&&this.localWorkShapes.set(i,o))}this.runAnimation()}consumeDrawAll(s){const{workId:e,dataType:t}=s;if(t===B.Service)this.activeServiceWorkShape(s);else{const i=e==null?void 0:e.toString(),o=i&&this.localWorkShapes.get(i);if(!o)return;const n=o.node.consumeAll({data:s});o.totalRect=ce(n.rect,o.totalRect),o.result=n,o.workState=P.Done,i&&this.localWorkShapes.set(i,o)}this.runAnimation()}destroy(){this.serviceWorkShapes.clear(),this.localWorkShapes.clear()}setNodeKey(s,e,t,i){return e.toolsType=t,e.node=this.createWorkShapeNode({workId:s,toolsType:t,toolsOpt:i}),e}activeServiceWorkShape(s){var d,f;const{workId:e,opt:t,toolsType:i,type:o,updateNodeOpt:n,ops:r,op:c}=s;if(!e)return;const l=e.toString(),h=(d=this.vNodes.get(l))==null?void 0:d.rect;if(!((f=this.serviceWorkShapes)!=null&&f.has(l))){let g={toolsType:i,animationWorkData:c||[],animationIndex:0,type:o,updateNodeOpt:n,ops:r,oldRect:h};i&&t&&(g=this.setNodeKey(l,g,i,t)),this.serviceWorkShapes.set(l,g)}const u=this.serviceWorkShapes.get(l);o&&(u.type=o),r&&(u.animationWorkData=it(r),u.ops=r),n&&(u.updateNodeOpt=n),c&&(u.animationWorkData=c),u.node&&u.node.getWorkId()!==l&&u.node.setWorkId(l),h&&(u.oldRect=h),i&&t&&(u.toolsType!==i&&i&&t&&this.setNodeKey(l,u,i,t),u.node&&u.node.setWorkOptions(t))}computNextAnimationIndex(s,e){const t=Math.floor((s.animationWorkData||[]).slice(s.animationIndex).length*32/e/this.syncUnitTime)*e;return Math.min((s.animationIndex||0)+(t||e),(s.animationWorkData||[]).length)}async animationDraw(){var n,r,c,l;this.animationId=void 0;let s=!1;const e=new Map,t=[],i=[],o=[];for(const[h,u]of this.serviceWorkShapes.entries())switch(u.toolsType){case I.LaserPen:{const f=this.computNextAnimationIndex(u,8),g=Math.max(0,u.animationIndex||0),p=(u.animationWorkData||[]).slice(g,f);if((u.animationIndex||0)<f){const m=(n=u.node)==null?void 0:n.consumeService({op:p,isFullWork:!1});u.totalRect=ce(u.totalRect,m),u.animationIndex=f,p.length&&e.set(h,{workState:g===0?P.Start:f===((r=u.animationWorkData)==null?void 0:r.length)?P.Done:P.Doing,op:p.slice(-2)})}if(i.push({isClear:!0,rect:u.totalRect,clearCanvas:ye.TopFloat,viewId:this.viewId}),t.push({rect:u.totalRect,drawCanvas:ye.TopFloat,viewId:this.viewId}),u.isDel){(c=u.node)==null||c.clearTmpPoints(),this.serviceWorkShapes.delete(h);break}u.ops&&u.animationIndex===((l=u.animationWorkData)==null?void 0:l.length)&&!u.isDel&&(this.topLayer.getElementsByName(h.toString())[0]||(u.isDel=!0,this.serviceWorkShapes.set(h,u))),s=!0;break}}for(const[h,u]of this.localWorkShapes.entries()){const{result:d,toolsType:f,totalRect:g,isDel:p,workState:m}=u;switch(f){case I.LaserPen:{if(g&&(i.push({isClear:!0,rect:g,clearCanvas:ye.TopFloat,viewId:this.viewId}),t.push({rect:g,drawCanvas:ye.TopFloat,viewId:this.viewId})),p){u.node.clearTmpPoints(),this.localWorkShapes.delete(h),o.push({removeIds:[h.toString()],viewId:this.viewId,type:x.RemoveNode});break}d&&((d.op||d.ops)&&o.push(d),u.result=void 0),!this.topLayer.getElementsByName(h.toString())[0]&&m===P.Done&&(u.isDel=!0,this.localWorkShapes.set(h,u)),s=!0;break}}}s&&this.runAnimation(),e.size&&e.forEach((h,u)=>{o.push({type:x.Cursor,uid:u.split(Ee)[0],op:h.op,workState:h.workState,viewId:this.viewId})}),(t.length||i.length||o.length)&&this.post({render:[...i,...t],sp:o})}runAnimation(){this.animationId||(this.animationId=setTimeout(()=>{this.animationId=void 0,this.animationDraw()},16))}}var Ps=(a=>(a.Full="full",a.Sub="sub",a))(Ps||{});class lM extends Gf{constructor(e,t,i){super(e,t,"sub");y(this,"type","sub");y(this,"_post");y(this,"topLayer");y(this,"snapshotFullLayer");y(this,"serviceWork");y(this,"localWork");y(this,"topLayerWork");this._post=i;const o=be.bufferSize.sub;this.topLayer=this.createLayer("topLayer",this.scene,{...t.layerOpt,bufferSize:o,contextType:"2d"});const n={thread:this,viewId:this.viewId,vNodes:this.vNodes,fullLayer:this.fullLayer,topLayer:this.topLayer};this.localWork=new aM(n),this.topLayerWork=new cM(n),this.vNodes.init(this.fullLayer)}async combinePost(){var n,r;const{render:e,...t}=this.combinePostData();let i;if(e!=null&&e.length){const c=[];for(const l of e)if(l.rect){if(l.rect=this.safariFixRect(Ce(l.rect),this.dpr),!l.rect)continue;if(l.drawCanvas&&l.rect&&l.rect.w>0&&l.rect.h>0){const h=await this.getRectImageBitmap(l);l.imageBitmap=h,i||(i=[]),i.push(h)}c.push(l)}t.render=c}const o=(n=t.sp)==null?void 0:n.filter(c=>c.type!==x.None);o!=null&&o.length?t.sp=o.map(c=>({...c,viewId:this.viewId})):delete t.sp,t.consumeCount===void 0&&delete t.consumeCount,t.subWorkerDrawCount===void 0&&delete t.subWorkerDrawCount,(o!=null&&o.length||t.consumeCount||t.subWorkerDrawCount||(r=t==null?void 0:t.render)!=null&&r.length)&&this._post(t,i),this.delayPostDoneResolve&&this.delayPostDoneResolve(!0)}getLayer(e,t){if(t&&this.snapshotFullLayer)return this.snapshotFullLayer;switch(e){case ye.TopFloat:return this.topLayer;default:return this.fullLayer}}async on(e){const{msgType:t,toolsType:i,opt:o,dataType:n,workState:r}=e;switch(t){case x.UpdateTools:if(i&&this.topLayerWork.canUseTopLayer(i)&&o){const c={toolsType:i,toolsOpt:o};this.topLayerWork.setToolsOpt(c);return}break;case x.CreateWork:this.createLocalWork(e);return;case x.DrawWork:r===P.Done&&n===B.Local?await this.consumeDrawAll(n,e):this.consumeDraw(n,e);return;case x.RemoveNode:await this.removeNode(e);return;case x.FullWork:i&&this.topLayerWork.canUseTopLayer(i)&&await this.consumeDrawAll(n,e);return;case x.Snapshot:this.snapshotFullLayer=this.createLayer("snapshotFullLayer",this.scene,{...this.opt.layerOpt,bufferSize:this.viewId===de?6e3:3e3,contextType:"2d"}),this.snapshotFullLayer&&(await this.getSnapshot(e),this.snapshotFullLayer=void 0);return;case x.BoundingBox:this.snapshotFullLayer=this.createLayer("snapshotFullLayer",this.scene,{...this.opt.layerOpt,bufferSize:this.viewId===de?6e3:3e3,contextType:"2d"}),this.snapshotFullLayer&&(await this.getBoundingRect(e),this.snapshotFullLayer=void 0);return}await super.on(e)}createLocalWork(e){const{workId:t,toolsType:i,opt:o}=e;if(i&&this.topLayerWork.canUseTopLayer(i)&&t&&o){this.topLayerWork.getToolsOpt()||this.topLayerWork.setToolsOpt({toolsType:i,toolsOpt:o}),this.topLayerWork.setWorkOptions(t.toString(),o);return}i&&this.localWork.canUseSubWorker(i)&&super.createLocalWork(e)}async removeNode(e){const{dataType:t}=e;t===B.Local&&await this.localWork.removeWork(e)}getOffscreen(e,t){return this.getLayer(e,t).parent.canvas}async consumeDraw(e,t){const{workId:i,toolsType:o}=t;if(i){if(o&&this.topLayerWork.canUseTopLayer(o)){e===B.Local&&(this.topLayerWork.getWorkShape(i.toString())||this.createLocalWork(t)),this.topLayerWork.consumeDraw(t);return}o&&this.localWork.canUseSubWorker(o)&&(this.localWork.getWorkShape(i.toString())||this.createLocalWork(t),await this.localWork.consumeDraw(t));return}}async consumeDrawAll(e,t){const{workId:i,toolsType:o,dataType:n}=t;if(i){const r=i.toString();if(o&&this.topLayerWork.canUseTopLayer(o)){n===B.Local&&(this.topLayerWork.getWorkShape(r)||this.createLocalWork(t)),this.topLayerWork.consumeDrawAll(t);return}o&&this.localWork.canUseSubWorker(o)&&(this.localWork.getWorkShape(r)||super.createLocalWork(t),this.localWork.consumeDrawAll(t));return}}async clearAll(){this.vNodes.clear(),super.clearAll(),this.topLayer&&(this.topLayer.parent.children.forEach(e=>{e.name!=="viewport"&&e.remove()}),this.topLayer.removeAllChildren()),await this.post({render:[{isClearAll:!0,clearCanvas:ye.TopFloat,viewId:this.viewId}],sp:[{type:x.Clear}]})}getRectImageBitmap(e,t=!1,i){const{rect:o,drawCanvas:n}=e,r=Math.floor(o.x*this.dpr),c=Math.floor(o.y*this.dpr),l=Math.floor(o.w*this.dpr||1),h=Math.floor(o.h*this.dpr||1);return createImageBitmap(this.getOffscreen(n,t),r,c,l,h,i)}updateLayer(e){const{width:t,height:i}=e;super.updateLayer(e),this.topLayer&&(this.topLayer.parent.setAttribute("width",t),this.topLayer.parent.setAttribute("height",i),this.topLayer.setAttribute("size",[t,i]),this.topLayer.setAttribute("pos",[t*.5,i*.5])),this.snapshotFullLayer&&(this.snapshotFullLayer.parent.setAttribute("width",t),this.snapshotFullLayer.parent.setAttribute("height",i),this.snapshotFullLayer.setAttribute("size",[t,i]),this.snapshotFullLayer.setAttribute("pos",[t*.5,i*.5]))}async updateDpr(e){super.updateDpr(e);const t=!!this.topLayerWork.localWorkShapes.size,i=!!this.localWork.getWorkShapes().size,o=[];i&&o.push({isClearAll:!0,clearCanvas:ye.Float,viewId:this.viewId}),t&&o.push({isClearAll:!0,clearCanvas:ye.TopFloat,viewId:this.viewId}),o.length&&await this.post({render:o})}async updateCamera(e){const t=[],{cameraOpt:i}=e;if(i&&!tt(this.cameraOpt,i)){const o=!!this.topLayerWork.localWorkShapes.size,n=!!this.localWork.getWorkShapes().size;if(n&&this.localWork.workShapesDone(),this.setCameraOpt(i),n&&t.push({isClearAll:!0,clearCanvas:ye.Float,viewId:this.viewId}),o){t.push({isClearAll:!0,clearCanvas:ye.TopFloat,viewId:this.viewId});for(const[r,c]of this.topLayerWork.localWorkShapes.entries())if(c.totalRect){let l;this.topLayer.getElementsByName(r.toString()).forEach(h=>{const u=h.getBoundingClientRect(),d=Dt({x:u.x,y:u.y,w:u.width,h:u.height});l=ce(l,d)}),c.totalRect=l,this.topLayerWork.localWorkShapes.set(r,c)}}t.length&&await this.post({render:t})}}setCameraOpt(e,t){this.cameraOpt=e;const{scale:i,centerX:o,centerY:n,width:r,height:c}=e;(r!==this.scene.width||c!==this.scene.height)&&this.updateScene({width:r,height:c}),t?(t.setAttribute("scale",[i,i]),t.setAttribute("translate",[-o,-n])):(this.fullLayer.setAttribute("scale",[i,i]),this.fullLayer.setAttribute("translate",[-o,-n]),this.topLayer.setAttribute("scale",[i,i]),this.topLayer.setAttribute("translate",[-o,-n]))}async getSnapshot(e){const{scenePath:t,scenes:i,cameraOpt:o,w:n,h:r}=e;if(t&&i&&o&&this.snapshotFullLayer){const c=Ce(this.cameraOpt);this.setCameraOpt(o,this.snapshotFullLayer),this.localWork.fullLayer=this.snapshotFullLayer,this.localWork.drawLayer=void 0;let l;for(const[u,d]of Object.entries(i))if(d!=null&&d.type)switch(d==null?void 0:d.type){case x.UpdateNode:case x.FullWork:{const{opt:f}=d,g={...d,opt:f,workId:u,msgType:x.FullWork,dataType:B.Service,viewId:this.viewId},p=await this.localWork.runFullWork(g);l=ce(l,p);break}}let h;n&&r&&(h={resizeWidth:n,resizeHeight:r}),await this.getSnapshotRender({scenePath:t,curCameraOpt:c,options:h}),this.localWork.fullLayer=this.fullLayer,this.localWork.drawLayer=void 0}}async getSnapshotRender(e){var r,c;const{scenePath:t,curCameraOpt:i,options:o}=e;((r=this.snapshotFullLayer)==null?void 0:r.parent).render();const n=await this.getRectImageBitmap({rect:this.getSceneRect(),drawCanvas:ye.None},!0,o);n&&(this._post({sp:[{type:x.Snapshot,scenePath:t,imageBitmap:n,viewId:this.viewId}]},[n]),n.close(),(c=this.snapshotFullLayer)==null||c.removeAllChildren(),this.setCameraOpt(i,this.fullLayer))}async getBoundingRect(e){const{scenePath:t,scenes:i,cameraOpt:o}=e;if(t&&i&&o&&this.snapshotFullLayer){const n=Ce(this.cameraOpt);this.setCameraOpt(o,this.snapshotFullLayer),this.localWork.fullLayer=this.snapshotFullLayer,this.localWork.drawLayer=void 0;let r;for(const[c,l]of Object.entries(i))if(l!=null&&l.type)switch(l==null?void 0:l.type){case x.UpdateNode:case x.FullWork:{const h=await this.localWork.runFullWork({...l,workId:c,msgType:x.FullWork,dataType:B.Service,viewId:this.viewId});r=ce(r,h);break}}r&&await this.post({sp:[{type:x.BoundingBox,scenePath:t,rect:r}]}),this.localWork.fullLayer=this.fullLayer,this.localWork.drawLayer=void 0,this.snapshotFullLayer.removeAllChildren(),this.setCameraOpt(n,this.fullLayer)}}}class Ot extends Y{constructor(e){super(e);y(this,"canRotate",!0);y(this,"scaleType",re.all);y(this,"toolsType",I.Image);y(this,"tmpPoints",[]);y(this,"workOptions");y(this,"oldRect");this.workOptions=e.toolsOpt,this.scaleType=Ot.getScaleType(this.workOptions)}consume(){return{type:x.None}}consumeAll(){return{type:x.None}}draw(e){const{layer:t,workId:i,replaceId:o,imageBitmap:n}=e,{centerX:r,centerY:c,width:l,height:h,rotate:u,zIndex:d,eraserlines:f}=this.workOptions,g=new le.Group({anchor:[.5,.5],pos:[r,c],name:i,size:[l,h],zIndex:d,rotate:u}),p={anchor:[.5,.5],pos:[0,0],size:[l,h],texture:n};n||(p.bgcolor="rgba(0,0,0,0.3)");const m=new le.Sprite(p);g.append(m),f&&this.drawEraserlines({group:g,eraserlines:f,pos:[r,c],layer:t}),this.replace(t,o||i,g);const N=g.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)}}consumeService(){}async consumeServiceAsync(e){var h,u,d,f;const{isFullWork:t,replaceId:i,worker:o}=e,{src:n,uuid:r}=this.workOptions,c=((h=this.workId)==null?void 0:h.toString())||r,l=t?this.fullLayer:this.drawLayer||this.fullLayer;if(n){const g=await o.loadImageBitMap({toolsType:this.toolsType,opt:this.workOptions,workId:c,isSubWorker:o instanceof lM});if(g){const p=this.draw({workId:c,layer:l,replaceId:i,imageBitmap:g});return this.oldRect=c&&((d=(u=this.vNodes)==null?void 0:u.get(c))==null?void 0:d.rect)||void 0,(f=this.vNodes)==null||f.setInfo(c,{rect:p,op:[],opt:this.workOptions,toolsType:this.toolsType,scaleType:this.scaleType,canRotate:this.canRotate,centerPos:p&&Y.getCenterPos(p,l)}),p}}}clearTmpPoints(){this.tmpPoints.length=0}static getScaleType(e){const{uniformScale:t,rotate:i}=e;return t!==!1||i&&Math.abs(i)%90>0?re.proportional:re.all}static updateNodeOpt(e){const{node:t,opt:i,vNodes:o,targetNode:n}=e,{translate:r,originPoint:c,scenePoint:l,scale:h,angle:u,isLocked:d,zIndex:f,strokeColor:g}=i,p=n&&Ce(n)||o.get(t.name);if(!p)return;const m=t.parent;if(m){if(g&&(p.opt.strokeColor=g),Ae(f)&&(t.setAttribute("zIndex",f),p.opt.zIndex=f),gt(d)&&(p.opt.locked=d),c&&l&&h&&r){const{centerX:N,centerY:v,width:T,height:k,uniformScale:S}=p.opt,w=S!==!1?[h[0],h[0]]:h,C=[N,v],L=[N,v];ti(L,l,w,r);const j=[L[0]-C[0],L[1]-C[1]];if(p.centerPos=[p.centerPos[0]+j[0],p.centerPos[1]+j[1]],p.opt.width=Math.round(T*w[0]),p.opt.height=Math.round(k*w[1]),p.opt.centerX=L[0],p.opt.centerY=L[1],p.opt.eraserlines)for(const E of Object.values(p.opt.eraserlines)){const{op:A,thickness:W}=E;E.thickness=W*Math.max(h[0],h[1]);for(let z=0;z<A.length;z++)si(A[z],l,h,r)}}else if(r){if(p.opt.centerX=p.opt.centerX+r[0],p.opt.centerY=p.opt.centerY+r[1],p.centerPos=[p.centerPos[0]+r[0],p.centerPos[1]+r[1]],p.opt.eraserlines)for(const N of Object.values(p.opt.eraserlines)){const{op:v}=N;for(let T=0;T<v.length;T++){const k=v[T].map((S,w)=>w%2?S+r[1]:S+r[0]);N.op[T]=k}}}else if(Ae(u))if(p.opt.rotate=u,p.scaleType=Ot.getScaleType(p.opt),n){const N=Go(p.rect,u);p.rect=N}else{const N=Y.getRectFromLayer(m,t.name);p.rect=N||p.rect}return p&&o.setInfo(t.name,p),p==null?void 0:p.rect}}}function ce(a,s){if(a&&s){const e=Math.min(a.x,s.x),t=Math.min(a.y,s.y),i=Math.max(a.x+a.w,s.x+s.w),o=Math.max(a.y+a.h,s.y+s.h),n=i-e,r=o-t;return{x:e,y:t,w:n,h:r}}return s||a}function ei(a,s){if(a&&s){const e=Math.min(a.originX,s.originX),t=Math.min(a.originY,s.originY),i=Math.max(a.originX+a.width,s.originX+s.width),o=Math.max(a.originY+a.height,s.originY+s.height),n=i-e,r=o-t;return{originX:e,originY:t,width:n,height:r}}return s||a}function pe(a,s=0){const e={x:0,y:0,w:0,h:0};let t=1/0,i=1/0,o=-1/0,n=-1/0;return a.forEach(r=>{const[c,l]=r.XY;t=Math.min(t,c-s),i=Math.min(i,l-s),o=Math.max(o,c+s),n=Math.max(n,l+s)}),e.x=t,e.y=i,e.w=o-t,e.h=n-i,e}function Rt(a,s){return!(a.x+a.w<s.x||a.x>s.x+s.w||a.y+a.h<s.y||a.y>s.y+s.h)}function Dt(a,s=10){return{x:Math.floor(a.x-s),y:Math.floor(a.y-s),w:Math.ceil(a.w+s*2),h:Math.ceil(a.h+s*2)}}function Ds(a,s){return{x:a.x+s[0],y:a.y+s[1],w:a.w,h:a.h}}function hM(a,s){const e=new b(a.x,a.y),t=new b(a.x+a.w,a.y),i=new b(a.x+a.w,a.y+a.h),o=new b(a.x,a.y+a.h),n=new b(a.x+a.w/2,a.y+a.h/2),r=Math.PI*s/180,c=b.RotWith(e,n,r),l=b.RotWith(t,n,r),h=b.RotWith(i,n,r),u=b.RotWith(o,n,r);return[c,l,h,u]}function Go(a,s){const e=hM(a,s);return pe(e)}function uM(a,s,e){const t=new b(a.x,a.y),i=new b(a.x+a.w,a.y),o=new b(a.x+a.w,a.y+a.h),n=new b(a.x,a.y+a.h),r=new b(e[0],e[1]),c=new b(s[0],s[1]),l=b.ScaleWOrigin(t,c,r),h=b.ScaleWOrigin(i,c,r),u=b.ScaleWOrigin(o,c,r),d=b.ScaleWOrigin(n,c,r);return pe([l,h,u,d])}function dM(a,s,e){const t=new b(s[0],s[1]);for(let i=0;i<a.length;i+=3){const o=new b(a[i],a[i+1]),n=Math.PI*e/180,r=b.RotWith(o,t,n);a[i]=r.x,a[i+1]=r.y}}function pM(a,s,e){const t=new b(s[0],s[1]);for(let i=0;i<a.length;i+=2){const o=new b(a[i],a[i+1]),n=Math.PI*e/180,r=b.RotWith(o,t,n);a[i]=r.x,a[i+1]=r.y}}function ti(a,s,e,t=[0,0]){const i=new b(s[0],s[1]);for(let o=0;o<a.length;o+=3){const n=new b(a[o],a[o+1]),r=new b(e[0],e[1]),c=b.ScaleWOrigin(n,r,i);a[o]=c.x+t[0],a[o+1]=c.y+t[1]}}function si(a,s,e,t=[0,0]){const i=new b(s[0],s[1]);for(let o=0;o<a.length;o+=2){const n=new b(a[o],a[o+1]),r=new b(e[0],e[1]),c=b.ScaleWOrigin(n,r,i);a[o]=c.x+t[0],a[o+1]=c.y+t[1]}}function Zo(a,s){return a[0]>=s.x&&a[0]<=s.x+s.w&&a[1]>=s.y&&a[1]<=s.y+s.h}function qo(a,s){const e=a<=s?1:a/s,t=s<=a?1:s/a;return[e,t]}function fM(a){for(const s of a)if(isNaN(s)||s===1/0||s===-1/0)return!1;return!0}function gM(a){return a!==Math.floor(a)}function yM(a){const s=a.toString();return s.indexOf(".")!==-1?s.split(".")[1].length:0}function MM(a,s){for(;s!==0;)[a,s]=[s,a%s];return a}const mM=a=>{if(a.tagName==="GROUP"){const s=Object.getOwnPropertySymbols(a).find(e=>e.toString()==="Symbol(sealed)");if(s&&a[s])return!0}return!1};function dt(a){return`${ss(a.x)},${ss(a.y)} `}function pt(a,s){return`${ss((a.x+s.x)/2)},${ss((a.y+s.y)/2)} `}function ss(a){return+a.toFixed(4)}const Ue=(a,s)=>new Promise(function(e){window.requestIdleCallback?requestIdleCallback(()=>{e(1)},{timeout:s}):setTimeout(()=>{e(2)},s)}).then(function(){a()},()=>{a()}),Ke=a=>{const s=(a==null?void 0:a.webkitBackingStorePixelRatio)||(a==null?void 0:a.mozBackingStorePixelRatio)||(a==null?void 0:a.msBackingStorePixelRatio)||(a==null?void 0:a.oBackingStorePixelRatio)||(a==null?void 0:a.backingStorePixelRatio)||1;return Math.max(1,(window.devicePixelRatio||1)/s)},wM=(a,s)=>a.x+a.w<s.x||a.x>s.x+s.w||a.y+a.h<s.y||a.y>s.y+s.h?jt.outside:a.x>=s.x&&a.y>=s.y&&a.x+a.w<=s.x+s.w&&a.y+a.h<=s.y+s.h?jt.inside:jt.intersect;function vM(a){let s=0;for(let e=0;e<a.length;e++){const t=a.charCodeAt(e);t>=1&&t<=126||65376<=t&&t<=65439?s++:s+=2}return s}class IM{constructor(s,e){y(this,"plugin");y(this,"uid");y(this,"control");this.control=s,this.plugin=e,this.uid=e.displayer.uid}getNamespaceData(){var s;return q.toJS((s=this.plugin)==null?void 0:s.attributes[this.namespace])||{}}getAuthSpaceData(){var s;return q.toJS((s=this.plugin)==null?void 0:s.attributes[this.authSpace])||{}}getUidFromKey(s){return s.split(Ee).length===2&&s.split(Ee)[0]||this.uid}isLocalId(s){return s.split(Ee).length===1}getLocalId(s){return s.split(Ee)[1]}isSelector(s){return this.getLocalId(s)===Q}}const ve=class ve extends IM{constructor(e,t,i){super(e,t);y(this,"authSpace");y(this,"namespace");y(this,"serviceStorage",{});y(this,"storage",{});y(this,"authStorage",{});y(this,"stateDisposer");y(this,"authDisposer");y(this,"asyncClockState",!1);y(this,"limitNums",new Map);y(this,"limitComponents",D.debounce((e,t)=>{var n,r,c,l,h,u,d,f;const i=((r=(n=this.storage)==null?void 0:n[e])==null?void 0:r[t])&&Object.keys(this.storage[e][t]).length||0;if(i===0)return;let o=this.limitNums.get(`${e}/${t}`);if(!o){const g=this.getLimitNum(i);this.limitNums.set(`${e}/${t}`,g),o=g}if(o>0&&i>=o){const g=ve.componentsLimits.indexOf(o),p=g>=0&&g<ve.componentsLimits.length-1;if((h=(l=(c=this.control.room)==null?void 0:c.callbacks)==null?void 0:l.listeners)!=null&&h.map.onObjectsLimit&&((d=(u=this.control.room)==null?void 0:u.callbacks)==null||d.dispatch("onObjectsLimit",N=>N(o,p))),!p){this.control.room.logger.error(`exceeds the limit of ${o} components, current: ${i}`),(f=this.control.room)==null||f.disconnect().then(()=>{var N,v,T,k,S;(T=(v=(N=this.control.room)==null?void 0:N.callbacks)==null?void 0:v.listeners)!=null&&T.map.onKickedWithReason&&((S=(k=this.control.room)==null?void 0:k.callbacks)==null||S.dispatch("onKickedWithReason",w=>w("kickByAdmin")))});return}console.warn(`exceeds the limit of ${o} components, current: ${i}`);const m=p?ve.componentsLimits[g+1]:0;this.limitNums.set(`${e}/${t}`,m)}},2e3,{maxWait:5e3}));y(this,"clearLimitComponents",(e,t)=>{if(t)this.limitNums.delete(`${e}/${t}`);else for(const i of this.limitNums.keys())`${e}/`.indexOf(i)===0&&this.limitNums.delete(i)});ve.syncInterval=(i||ve.syncInterval)*.5,this.namespace=ve.namespace,this.authSpace=ve.authSpace,this.serviceStorage=this.getNamespaceData(),this.storage=D.cloneDeep(this.serviceStorage),this.authStorage=this.getAuthSpaceData(),this.getLimitNums()}getLimitNum(e){return e>=ve.componentsLimits[0]?ve.componentsLimits[1]:ve.componentsLimits[0]}getLimitNums(){for(const[e,t]of Object.entries(this.storage))if(e&&t){for(const[i,o]of Object.entries(t))if(i&&o){const n=this.getLimitNum(Object.keys(o).length);this.limitNums.set(`${e}/${i}`,n)}}}getViewIdBySecenPath(e){const t=this.getNamespaceData();for(const[i,o]of Object.entries(t))if(o){for(const n of Object.keys(o))if(n===e)return i}}getScenePathData(e){const t=this.getNamespaceData();for(const i of Object.values(t))if(i){for(const o of Object.keys(i))if(o===e)return D.cloneDeep(i[o])}}getStorageData(e,t){const i=this.getNamespaceData();return i&&i[e]&&D.cloneDeep(i[e][t])||void 0}hasSelector(e,t){const i=this.storage&&this.storage[e]&&this.storage[e][t];return!!(i&&Object.keys(i).find(o=>this.isOwn(o)&&this.getLocalId(o)===Q))}addStorageStateListener(e){this.stateDisposer=q.autorun(async()=>{var c;const t=this.getNamespaceData(),{diffView:i,diffScenePath:o,diffData:n}=this.diffFunByView(this.serviceStorage,t);this.serviceStorage=t;const r={};if(Object.keys(i).length>0){r.diffView=i;for(const[l,h]of Object.entries(i)){if(h&&h.newValue===void 0&&this.storage[l]){delete this.storage[l];continue}if(h&&h.newValue){this.storage[l]=D.cloneDeep(h.newValue);continue}}}if(Object.keys(o).length>0){r.diffScenePath=o;for(const[l,h]of Object.entries(o))if(h){const{viewId:u,newValue:d}=h;let f=this.storage[u];if(f&&f[l]&&d===void 0){delete f[l];continue}if(d&&u){f===void 0&&(this.storage[u]={},f=this.storage[u]),f[l]=D.cloneDeep(d);continue}}}if(Object.keys(n).length>0){r.diffData=n;for(const[l,h]of Object.entries(n))if(h){const{viewId:u,scenePath:d,newValue:f}=h;if(u&&d){let g=this.storage[u],p=(c=this.storage[u])==null?void 0:c[d];if(g||(this.storage[u]={},g=this.storage[u],g[d]={},p=g[d]),p){if(p[l]&&f===void 0){delete p[l];continue}if(f&&u){p[l]=D.cloneDeep(f);continue}}}}}Object.keys(r).length>0&&e(r)})}removeStorageStateListener(){this.stateDisposer&&this.stateDisposer()}diffFunByView(e,t){const i=Le(e),o=Le(t),n={},r={},c={};for(const l of o)if(!i.includes(l)||e[l]===void 0){n[l]={newValue:t[l],oldValue:void 0};continue}for(const l of i){if(D.isEqual(e[l],t[l]))continue;if(!o.includes(l)||t[l]===void 0){n[l]={newValue:void 0,oldValue:e[l]};continue}const h=this.diffFunByScenePath(e[l],t[l],l);Object.assign(r,h.diffScenePath),Object.assign(c,h.diffData)}return{diffData:c,diffScenePath:r,diffView:n}}diffFunByScenePath(e,t,i){const o=Le(e),n=Le(t),r={},c={};for(const l of n)if(!o.includes(l)||e[l]===void 0){r[l]={newValue:t[l],oldValue:void 0,viewId:i};continue}for(const l of o){if(D.isEqual(e[l],t[l]))continue;if(!n.includes(l)||t[l]===void 0){r[l]={newValue:void 0,oldValue:e[l],viewId:i};continue}const h=this.diffFunByKeys(e[l],t[l],l,i);Object.assign(c,h)}return{diffScenePath:r,diffData:c}}diffFunByKeys(e,t,i,o){const n=Le(e),r=Le(t),c={};for(const l of r)(!n.includes(l)||e[l]===void 0)&&(c[l]={oldValue:void 0,newValue:t[l],viewId:o,scenePath:i});for(const l of n)if(!D.isEqual(e[l],t[l])){if(!r.includes(l)||t[l]===void 0){c[l]={newValue:void 0,oldValue:e[l],viewId:o,scenePath:i};continue}r.includes(l)&&(c[l]={oldValue:e[l],newValue:t[l],viewId:o,scenePath:i})}return c}transformKey(e){return this.uid+Ee+e}isOwn(e){return e.split(Ee)[0]===this.uid}dispatch(e){const{type:t,workId:i,ops:o,index:n,opt:r,toolsType:c,removeIds:l,updateNodeOpt:h,op:u,selectIds:d,isSync:f,scenePath:g,viewId:p}=e;if(p)switch(t){case x.Clear:const m={};g&&this.storage[p]&&this.storage[p][g]?(delete this.storage[p][g],this.setState(m,{isSync:f,viewId:p,scenePath:g})):this.storage[p]&&(delete this.storage[p],this.setState(m,{isSync:f,viewId:p,scenePath:""})),Ue(()=>{var S;this.control.pluginManager.dispatchPluginEvent("syncStorage",p,g),(S=this.control.miniMapManager)==null||S.updateMiniMapCamera(p),this.clearLimitComponents(p,g)},ve.syncInterval);break;case x.CreateWork:if(g&&i&&c&&r){const S=this.isLocalId(i.toString())?this.transformKey(i):i;this.control.renderControl.isUsePageAuth(p)&&this.control.renderControl.addRenderPageElementId({viewId:p,scenePath:g,elementId:S.toString()}),this.updateValue(S.toString(),{type:x.CreateWork,workId:i,toolsType:c,opt:r},{isSync:f,viewId:p,scenePath:g})}break;case x.DrawWork:if(g&&i&&typeof n=="number"&&(u!=null&&u.length)){const S=this.isLocalId(i.toString())?this.transformKey(i):i,w=this.storage[p]&&this.storage[p][g]&&this.storage[p][g][S]||void 0;if(w!=null&&w.ops||(w==null?void 0:w.type)===x.FullWork)return;const C=n?((w==null?void 0:w.op)||[]).slice(0,n).concat(u):u||(w==null?void 0:w.op),L=c||(w==null?void 0:w.toolsType),j=r||(w==null?void 0:w.opt),E=h||(w==null?void 0:w.updateNodeOpt);i&&L&&j&&C&&(this.control.renderControl.isUsePageAuth(p)&&this.control.renderControl.addRenderPageElementId({viewId:p,scenePath:g,elementId:S.toString()}),this.updateValue(S.toString(),{...w,type:x.DrawWork,workId:i,updateNodeOpt:E,toolsType:L,opt:j,op:C,index:n},{isSync:f,viewId:p,scenePath:g}))}break;case x.FullWork:if(g&&i){const S=this.isLocalId(i.toString())?this.transformKey(i):i,w=this.storage[p]&&this.storage[p][g]&&this.storage[p][g][S]||void 0,C=h||(w==null?void 0:w.updateNodeOpt),L=c||(w==null?void 0:w.toolsType),j=r||(w==null?void 0:w.opt),E=o||(w==null?void 0:w.ops);L&&j&&(this.control.renderControl.isUsePageAuth(p)&&this.control.renderControl.addRenderPageElementId({viewId:p,scenePath:g,elementId:S.toString()}),this.updateValue(S.toString(),{type:x.FullWork,updateNodeOpt:C,workId:S,toolsType:L,opt:j,ops:E},{isSync:f,viewId:p,scenePath:g}),Ue(()=>{var A;this.control.pluginManager.dispatchPluginEvent("syncStorage",p,g),(A=this.control.miniMapManager)==null||A.updateMiniMapCamera(p),this.limitComponents(p,g)},ve.syncInterval))}break;case x.RemoveNode:if(g&&(l!=null&&l.length)){const S=l.map(w=>this.isLocalId(w+"")?this.transformKey(w):w);this.storage[p]&&this.storage[p][g]&&(Object.keys(this.storage[p][g]).map(w=>{S!=null&&S.includes(w)&&(this.control.renderControl.isUsePageAuth(p)&&this.control.renderControl.delRenderPageElementId({viewId:p,scenePath:g,elementId:w}),this.updateValue(w,void 0,{isSync:f,viewId:p,scenePath:g}))}),Ue(()=>{var w;this.control.pluginManager.dispatchPluginEvent("syncStorage",p,g),(w=this.control.miniMapManager)==null||w.updateMiniMapCamera(p)},ve.syncInterval))}break;case x.UpdateNode:if(g&&i&&(h||o||r)){const S=this.isLocalId(i.toString())?this.transformKey(i):i,w=this.storage[p]&&this.storage[p][g]&&this.storage[p][g][S]||void 0;w&&(w.updateNodeOpt=h,(o||u)&&(w.ops=o,w.op=u),r&&(w.opt=r),w.type=x.FullWork,this.updateValue(S.toString(),w,{isSync:f,viewId:p,scenePath:g}),Ue(()=>{var C;(C=this.control.miniMapManager)==null||C.updateMiniMapCamera(p)},ve.syncInterval))}break;case x.Select:if(!g)return;let N;d!=null&&d.length&&(N=d.map(S=>this.isLocalId(S+"")?this.transformKey(S):S));const v=this.transformKey(Q),T=this.storage[p]&&this.storage[p][g]&&this.storage[p][g][v]||void 0,k=r||(T==null?void 0:T.opt);N&&this.checkOtherSelector(v,N,{isSync:f,viewId:p,scenePath:g}),this.updateValue(v,N&&{type:x.Select,toolsType:I.Selector,opt:k,selectIds:N},{isSync:f,viewId:p,scenePath:g});break}}checkOtherSelector(e,t,i){const{viewId:o,scenePath:n}=i;for(const r of Object.keys(this.storage[o][n]))if(r!==e&&this.getLocalId(r)===Q){const c=this.storage[o][n][r];if(c&&c.selectIds){const l=c.selectIds.filter(h=>!t.includes(h));l.length>0&&(c.selectIds=l),this.updateValue(r,l.length&&c||void 0,i)}}}setState(e,t){const{viewId:i,scenePath:o}=t,n=Le(e);for(let r=0;r<n.length;r++){const c=n[r],l=e[c];typeof l<"u"?(this.storage[i]||(this.storage[i]={}),this.storage[i][o]||(this.storage[i][o]={}),this.storage[i][o][c]=l):delete this.storage[i][o][c]}this.runSyncService(t)}updateValue(e,t,i){const{viewId:o,scenePath:n}=i;t===void 0?delete this.storage[o][n][e]:(this.storage[o]||(this.storage[o]={}),this.storage[o][n]||(this.storage[o][n]={}),this.storage[o][n][e]=t),this.runSyncService(i)}runSyncService(e){this.asyncClockState||(this.asyncClockState=!0,setTimeout(()=>{e.isSync?(this.asyncClockState=!1,this.syncSerivice(e.isAfterUpdate)):Ue(()=>{this.asyncClockState=!1,this.syncSerivice(e.isAfterUpdate)},ve.syncInterval)},e!=null&&e.isSync?0:ve.syncInterval))}syncSerivice(e=!1){const t=Le(this.serviceStorage),i=Le(this.storage),o=new Map;for(const n of t){if(!i.includes(n)){o.set(n,void 0);continue}D.isEqual(this.serviceStorage[n],this.storage[n])||this.syncViewData(n,e)}for(const n of i)t.includes(n)||o.set(n,this.storage[n]);if(o.size>5)this.syncStorageView(this.storage,e);else for(const[n,r]of o.entries())this.syncUpdataView(n,r,e)}syncViewData(e,t=!1){const i=Le(this.serviceStorage[e]),o=Le(this.storage[e]),n=new Map;for(const r of i){if(!o.includes(r)){n.set(r,void 0);continue}D.isEqual(this.serviceStorage[e][r],this.storage[e][r])||this.syncScenePathData(e,r,t)}for(const r of o)i.includes(r)||n.set(r,this.storage[e][r]);if(n.size>5)this.syncStorageScenePath(e,this.storage[e],t);else for(const[r,c]of n.entries())this.syncUpdataScenePath(e,r,c,t)}syncScenePathData(e,t,i=!1){const o=Le(this.serviceStorage[e][t]),n=Le(this.storage[e][t]),r=new Map;for(const c of o){if(!n.includes(c)){r.set(c,void 0);continue}D.isEqual(this.serviceStorage[e][t][c],this.storage[e][t][c])||r.set(c,this.storage[e][t][c])}for(const c of n)o.includes(c)||r.set(c,this.storage[e][t][c]);if(r.size>5)this.syncStorageKey(e,t,this.storage[e][t],i);else for(const[c,l]of r.entries())this.syncUpdataKey(e,t,c,l,i)}syncUpdataView(e,t,i=!1){var n;Object.keys(this.serviceStorage).length?(i||(t===void 0?delete this.serviceStorage[e]:this.serviceStorage[e]=D.cloneDeep(t)),(n=this.plugin)==null||n.updateAttributes([this.namespace,e],t)):this.syncStorageView(this.storage,i)}syncStorageView(e,t=!1){var i;t||e&&(this.serviceStorage=D.cloneDeep(e)),(i=this.plugin)==null||i.updateAttributes([this.namespace],e)}syncUpdataScenePath(e,t,i,o=!1){var r;Object.keys(this.serviceStorage[e]).length?(o||(i===void 0?delete this.serviceStorage[e][t]:this.serviceStorage[e][t]=i),(r=this.plugin)==null||r.updateAttributes([this.namespace,e,t],i)):this.syncStorageScenePath(e,this.storage[e],o)}syncStorageScenePath(e,t,i=!1){var o;i||t&&(this.serviceStorage[e]=t),(o=this.plugin)==null||o.updateAttributes([this.namespace,e],t)}syncUpdataKey(e,t,i,o,n=!1){var c;Object.keys(this.serviceStorage[e][t]).length?(n||(o===void 0?delete this.serviceStorage[e][t][i]:this.serviceStorage[e][t][i]=o),(c=this.plugin)==null||c.updateAttributes([this.namespace,e,t,i],o)):this.syncStorageKey(e,t,this.storage[e][t],n)}syncStorageKey(e,t,i,o=!1){var n;o||(this.serviceStorage[e][t]=i),(n=this.plugin)==null||n.updateAttributes([this.namespace,e,t],i)}keyTransformWorkId(e){const t=e.split(Ee);return t.length===2?t[1]:e}destroy(){this.removeStorageStateListener(),this.serviceStorage={},this.storage={},this.removeAuthStateListener(),this.authStorage={}}dispatchPageAuth(e,t=!0){var l,h,u,d,f,g,p,m,N,v,T,k,S,w,C,L,j,E,A,W,z,O,se,_,H,X,G,Z,K,ae,Te,ie,he,J,$,ue,fe,Oe;const{operation:i,viewId:o,scenePath:n,pageId:r,pageData:c}=e;switch(i){case De.addPage:{if(!o||!n||!r)return;const we=[this.authSpace];Object.keys(this.authStorage).length&&we.push("pageAuth");const me=this.authStorage.pageAuth||{};this.authStorage.pageAuth=me,Object.keys(me).length&&we.push(o),me[o]=me[o]||{},Object.keys(me[o]).length&&we.push(n),me[o][n]=me[o][n]||{render:(c==null?void 0:c.render)||"localSelf",pages:{}},Object.keys(me[o][n].pages).length&&we.push("pages",r);const ot={};if(c!=null&&c.elementIds)for(const ke of c.elementIds.keys())ot[ke]=!0;me[o][n].pages[r]=ot,t&&(we.length===1?(l=this.plugin)==null||l.updateAttributes(we,D.cloneDeep(this.authStorage)):we.length===2?(h=this.plugin)==null||h.updateAttributes(we,D.cloneDeep(me)):we.length===3?(u=this.plugin)==null||u.updateAttributes(we,D.cloneDeep(me[o])):we.length===4?(d=this.plugin)==null||d.updateAttributes(we,D.cloneDeep(me[o][n])):(f=this.plugin)==null||f.updateAttributes(we,D.cloneDeep(ot)));return}case De.renderPage:{if(!o||!n||!(c!=null&&c.render))return;this.authStorage.pageAuth&&this.authStorage.pageAuth[o]&&this.authStorage.pageAuth[o][n]&&c.render!==this.authStorage.pageAuth[o][n].render&&(this.authStorage.pageAuth[o][n].render=c.render,t&&((g=this.plugin)==null||g.updateAttributes([this.authSpace,"pageAuth",o,n,"render"],c.render)));return}case De.deletePage:{if(!o||!n||!r)return;(T=(v=(N=(m=(p=this.authStorage)==null?void 0:p.pageAuth)==null?void 0:m[o])==null?void 0:N[n])==null?void 0:v.pages)!=null&&T[r]&&(delete this.authStorage.pageAuth[o][n].pages[r],t&&((k=this.plugin)==null||k.updateAttributes([this.authSpace,"pageAuth",o,n,"pages",r],void 0)));return}case De.clearPage:{if(!o||!n||!r)return;(j=(L=(C=(w=(S=this.authStorage)==null?void 0:S.pageAuth)==null?void 0:w[o])==null?void 0:C[n])==null?void 0:L.pages)!=null&&j[r]&&(delete this.authStorage.pageAuth[o][n].pages[r],t&&((E=this.plugin)==null||E.updateAttributes([this.authSpace,"pageAuth",o,n,"pages",r],{})));return}case De.addElement:{if(!o||!n||!r||!(c!=null&&c.elementId))return;(se=(O=(z=(W=(A=this.authStorage)==null?void 0:A.pageAuth)==null?void 0:W[o])==null?void 0:z[n])==null?void 0:O.pages)!=null&&se[r]&&(this.authStorage.pageAuth[o][n].pages[r][c.elementId]=!0,t&&((_=this.plugin)==null||_.updateAttributes([this.authSpace,"pageAuth",o,n,"pages",r,c.elementId],!0)));return}case De.deleteElement:{if(!o||!n||!r||!(c!=null&&c.elementId))return;(ae=(K=(Z=(G=(X=(H=this.authStorage)==null?void 0:H.pageAuth)==null?void 0:X[o])==null?void 0:G[n])==null?void 0:Z.pages)==null?void 0:K[r])!=null&&ae[c.elementId]&&(delete this.authStorage.pageAuth[o][n].pages[r][c.elementId],t&&((Te=this.plugin)==null||Te.updateAttributes([this.authSpace,"pageAuth",o,n,"pages",r,c.elementId],void 0)));return}case De.clearViewScenePath:{if(!o||!n)return;(J=(he=(ie=this.authStorage)==null?void 0:ie.pageAuth)==null?void 0:he[o])!=null&&J[n]&&(delete this.authStorage.pageAuth[o][n],t&&(($=this.plugin)==null||$.updateAttributes([this.authSpace,"pageAuth",o,n],void 0)));return}case De.clearView:{if(!o)return;(fe=(ue=this.authStorage)==null?void 0:ue.pageAuth)!=null&&fe[o]&&(delete this.authStorage.pageAuth[o],t&&((Oe=this.plugin)==null||Oe.updateAttributes([this.authSpace,"pageAuth",o],void 0)));return}}}dispatchRenderAuth(e,t=!0){var l,h,u,d,f,g,p,m,N,v,T,k,S,w,C,L,j,E,A,W;const{operation:i,viewId:o,uid:n,renderData:r,isClear:c}=e;if(o)switch(i){case He.setAuth:{if(!r||r.render===void 0&&r.hide===void 0&&r.clear===void 0){this.authStorage.renderAuth&&this.authStorage.renderAuth[o]&&(delete this.authStorage.renderAuth[o],t&&((l=this.plugin)==null||l.updateAttributes([this.authSpace,"renderAuth",o],void 0)));return}const z=[this.authSpace];Object.keys(this.authStorage).length&&z.push("renderAuth");const O=this.authStorage.renderAuth||{};Object.keys(O).length&&z.push(o),O[o]={},this.authStorage.renderAuth=O;const{render:se,hide:_,clear:H}=r;if(se===!0)O[o].render=!0;else if(D.isSet(se)){O[o].render={};for(const X of se.keys())O[o].render[X]=!0}if(_===!0)O[o].hide=!0;else if(D.isSet(_)){O[o].hide={};for(const X of _.keys())O[o].hide[X]=!0}if(H===!0)O[o].clear=!0;else if(D.isSet(H)){O[o].clear={};for(const X of H.keys())O[o].clear[X]=!0}t&&(z.length===1?(h=this.plugin)==null||h.updateAttributes(z,D.cloneDeep(this.authStorage)):z.length===2?(u=this.plugin)==null||u.updateAttributes(z,D.cloneDeep(O)):(d=this.plugin)==null||d.updateAttributes(z,D.cloneDeep(O[o])));return}case He.setShow:{if(!n)return;const z=[this.authSpace];Object.keys(this.authStorage).length&&z.push("renderAuth");const O=this.authStorage.renderAuth||{};Object.keys(O).length&&z.push(o),O[o]=O[o]||{},this.authStorage.renderAuth=O,Object.keys(O[o]).length&&z.push("render"),O[o].render=O[o].render||{},O[o].render!==!0&&(Object.keys(O[o].render).length&&z.push(n),O[o].render[n]=!0),O[o].hide!==!0&&((f=O[o].hide)!=null&&f[n])&&(delete O[o].hide[n],t&&((g=this.plugin)==null||g.updateAttributes([this.authSpace,"renderAuth",o,"hide",n],void 0))),t&&(z.length===1?(p=this.plugin)==null||p.updateAttributes(z,D.cloneDeep(this.authStorage)):z.length===2?(m=this.plugin)==null||m.updateAttributes(z,D.cloneDeep(O)):z.length===3?(N=this.plugin)==null||N.updateAttributes(z,D.cloneDeep(O[o])):(v=this.plugin)==null||v.updateAttributes(z,!0));return}case He.setHide:{if(!n)return;const z=[this.authSpace];Object.keys(this.authStorage).length&&z.push("renderAuth");const O=this.authStorage.renderAuth||{};Object.keys(O).length&&z.push(o),O[o]=O[o]||{},this.authStorage.renderAuth=O,Object.keys(O[o]).length&&z.push("hide"),O[o].hide=O[o].hide||{},O[o].hide!==!0&&(Object.keys(O[o].hide).length&&z.push(n),O[o].hide[n]=!0),O[o].render!==!0&&((T=O[o].render)!=null&&T[n])&&(delete O[o].render[n],t&&((k=this.plugin)==null||k.updateAttributes([this.authSpace,"renderAuth",o,"render",n],void 0))),t&&(z.length===1?(S=this.plugin)==null||S.updateAttributes(z,D.cloneDeep(this.authStorage)):z.length===2?(w=this.plugin)==null||w.updateAttributes(z,D.cloneDeep(O)):z.length===3?(C=this.plugin)==null||C.updateAttributes(z,D.cloneDeep(O[o])):(L=this.plugin)==null||L.updateAttributes(z,!0));return}case He.setClear:{if(!n)return;const z=[this.authSpace];Object.keys(this.authStorage).length&&z.push("renderAuth");const O=this.authStorage.renderAuth||{};Object.keys(O).length&&z.push(o),O[o]=O[o]||{},this.authStorage.renderAuth=O,Object.keys(O[o]).length&&z.push("clear"),O[o].clear=O[o].clear||{},O[o].clear!==!0&&(Object.keys(O[o].clear).length&&z.push(n),c?O[o].clear[n]=!0:delete O[o].clear[n]),t&&(z.length===1?(j=this.plugin)==null||j.updateAttributes(z,D.cloneDeep(this.authStorage)):z.length===2?(E=this.plugin)==null||E.updateAttributes(z,D.cloneDeep(O)):z.length===3?(A=this.plugin)==null||A.updateAttributes(z,D.cloneDeep(O[o])):(W=this.plugin)==null||W.updateAttributes(z,c?!0:void 0));return}}}addAuthStateListener(e){this.authDisposer=q.autorun(async()=>{const t=this.getAuthSpaceData(),{renderAuth:i,pageAuth:o}=t;let n,r;D.isEqual(i,this.authStorage.renderAuth)||(n=this.diffAuthFun(this.authStorage.renderAuth||{},i||{}),this.authStorage.renderAuth=i),D.isEqual(o,this.authStorage.pageAuth)||(r=this.diffAuthPageFun(this.authStorage.pageAuth||{},o||{}),this.authStorage.pageAuth=o),(n||r)&&e(n,r)})}removeAuthStateListener(){this.authDisposer&&this.authDisposer()}diffAuthFun(e,t){const i=Le(e),o=Le(t),n={};for(const r of o)if(!i.includes(r)||e[r]===void 0){n[r]={newValue:t[r],oldValue:void 0};continue}for(const r of i)if(!D.isEqual(e[r],t[r])){if(!o.includes(r)||t[r]===void 0){n[r]={newValue:void 0,oldValue:e[r]};continue}n[r]={newValue:t[r],oldValue:e[r]}}return n}diffAuthPageFun(e,t){const i=Le(e),o=Le(t),n={};for(const r of o)if(!i.includes(r)||e[r]===void 0){n[r]={newValue:t[r],oldValue:void 0};continue}for(const r of i)if(!D.isEqual(e[r],t[r])){if(!o.includes(r)||t[r]===void 0){n[r]={newValue:void 0,oldValue:e[r]};continue}n[r]={newValue:t[r],oldValue:e[r]}}return n}};y(ve,"namespace","PluginState"),y(ve,"authSpace","PluginAuth"),y(ve,"syncInterval",500),y(ve,"componentsLimits",[500,1e3]);let As=ve;class NM{constructor(){y(this,"roomMembers",[]);y(this,"onChangeHooks",new Set)}setRoomMembers(s){this.executChangeUidHook(this.roomMembers,s),this.roomMembers=s}executChangeUidHook(s,e){const t={online:e.map(i=>{var o;return((o=i.payload)==null?void 0:o.uid)||i.session}),offline:s.map(i=>{var o;return((o=i.payload)==null?void 0:o.uid)||i.session})};this.onChangeHooks.forEach(i=>i(t))}getAllRoomMembers(){return this.roomMembers}getRoomMember(s){return this.roomMembers.find(e=>{var t;return((t=e.payload)==null?void 0:t.uid)===s})}isOnLine(s){return!this.getRoomMember(s)}onUidChangeHook(s){this.onChangeHooks.add(s)}destroy(){this.onChangeHooks.clear()}}var Ze=(a=>(a[a.Text=1]="Text",a[a.Shape=2]="Shape",a))(Ze||{});const je=class je{createProxy(s){const e=new Proxy(s,{get(t,i,o){const n=je.interceptors.hasOwnProperty(i)?je.interceptors:t;return Reflect.get(n,i,o)}});return je.proxyToRaw.set(e,s),e}};y(je,"proxyToRaw",new WeakMap),y(je,"interceptors",{entries(...s){return je.proxyToRaw.get(this).entries(...s)},forEach(...s){return je.proxyToRaw.get(this).forEach(...s)},size(){return je.proxyToRaw.get(this).size},get(s){return je.proxyToRaw.get(this).get(s)},set(s,e){return je.proxyToRaw.get(this).set(s,e)},delete(s,e){return je.proxyToRaw.get(this).delete(s)},clear(){return je.proxyToRaw.get(this).clear()}});let rt=je;class SM{constructor(s){y(this,"internalMsgEmitter");y(this,"control");y(this,"editors");y(this,"activeId");y(this,"proxyMap");y(this,"taskqueue",new Map);const{control:e,internalMsgEmitter:t}=s;this.control=e,this.internalMsgEmitter=t;const i=new Map;this.proxyMap=new rt;const o=this,n=rt.interceptors.set;rt.interceptors.set=function(c,l){return o.interceptors.set(c,l),n.call(this,c,l)};const r=rt.interceptors.delete;rt.interceptors.delete=function(c,l){return o.interceptors.delete(c,l),r.call(this,c)},this.editors=this.proxyMap.createProxy(i)}get collector(){return this.control.collector}filterEditor(s){const e=new Map;return this.editors.forEach((t,i)=>{t.viewId===s&&e.set(i,t)}),e}get interceptors(){return{set:(s,e)=>{var f,g,p,m,N,v,T,k;if(!this.collector)return!0;const{viewId:t,scenePath:i,canSync:o,canWorker:n,type:r,opt:c,dataType:l}=e;if(!n&&!o)return!0;const u=((f=this.collector)==null?void 0:f.isLocalId(s))?(g=this.collector)==null?void 0:g.transformKey(s):s,d=((p=this.collector)==null?void 0:p.storage[t])&&this.collector.storage[t][i]&&this.collector.storage[t][i][u]||void 0;d?d.toolsType===I.Text&&(n&&(this.control.worker.queryTaskBatchData({workId:s,msgType:x.UpdateNode}).forEach(S=>{var w;(w=this.control.worker)==null||w.taskBatchData.delete(S)}),(T=this.control.worker)==null||T.taskBatchData.add({workId:s,msgType:x.UpdateNode,dataType:l||B.Local,toolsType:I.Text,opt:c,viewId:t,scenePath:i,willRefresh:!0}),(k=this.control.worker)==null||k.runAnimation()),o&&Ue(()=>{var S;(S=this.collector)==null||S.dispatch({type:x.UpdateNode,workId:s,toolsType:I.Text,opt:c,viewId:t,scenePath:i})},this.control.worker.maxLastSyncTime)):r===Ze.Text&&(o&&((m=this.collector)==null||m.dispatch({type:c.text&&x.FullWork||x.CreateWork,workId:s,toolsType:I.Text,opt:c,isSync:!0,viewId:t,scenePath:i})),n&&((N=this.control.worker)==null||N.taskBatchData.add({workId:s,msgType:c.text&&x.FullWork||x.CreateWork,dataType:l||B.Local,toolsType:I.Text,opt:c,viewId:t,scenePath:i,willRefresh:!0}),(v=this.control.worker)==null||v.runAnimation()))},delete:s=>{var r,c;if(!this.collector)return!0;const e=this.editors.get(s);if(!e)return!0;const{viewId:t,scenePath:i,canSync:o,canWorker:n}=e;if(!n&&!o)return!0;n&&((r=this.control.worker)==null||r.taskBatchData.add({workId:s,toolsType:I.Text,msgType:x.RemoveNode,dataType:B.Local,viewId:t,scenePath:i,willRefresh:!0}),(c=this.control.worker)==null||c.runAnimation()),o&&Ue(()=>{var l;(l=this.collector)==null||l.dispatch({type:x.RemoveNode,removeIds:[s],toolsType:I.Text,viewId:t,scenePath:i})},this.control.worker.maxLastSyncTime)},clear(){return!0}}}computeTextActive(s,e){var o,n,r,c;const t=(o=this.control.viewContainerManager)==null?void 0:o.transformToScenePoint(s,e),i=(n=this.control.viewContainerManager)==null?void 0:n.getCurScenePath(e);e&&i&&((r=this.control.worker)==null||r.taskBatchData.add({msgType:x.GetTextActive,dataType:B.Local,op:t,viewId:e,scenePath:i}),(c=this.control.worker)==null||c.runAnimation())}checkEmptyTextBlur(){var e;let s=this.activeId;for(const[t,i]of this.editors.entries())if(i.opt.uid&&i.opt.uid===((e=this.collector)==null?void 0:e.uid)){s=t;break}if(s){const t=this.editors.get(s);(t==null?void 0:t.opt.text)&&(t==null?void 0:t.opt.text.replace(/\s*,/g,""))?this.unActive(s):this.delete(s,!0,!0)}}onCameraChange(s,e){var t,i;for(const[o,n]of this.editors.entries())if(n.viewId===e){const{boxPoint:r,boxSize:c}=n.opt,l=r&&((t=this.control.viewContainerManager)==null?void 0:t.transformToOriginPoint(r,n.viewId)),h=(i=this.control.viewContainerManager)==null?void 0:i.getCurScenePath(e);if(h&&e){const u={x:l&&l[0]||0,y:l&&l[1]||0,w:c&&c[0]||0,h:c&&c[1]||0,opt:n.opt,scale:s.scale,type:Ze.Text,viewId:e,scenePath:h,canWorker:!1,canSync:!1};this.editors.set(o,u),this.control.viewContainerManager.setActiveTextEditor(e,this.activeId)}}}onServiceDerive(s){var g,p;const{workId:e,opt:t,msgType:i,viewId:o,scenePath:n,dataType:r}=s;if(!e||!o||!n)return;const c=e.toString();if(i===x.RemoveNode){this.delete(c,!0,!0);return}const{boxPoint:l,boxSize:h}=t,u=l&&((g=this.control.viewContainerManager)==null?void 0:g.transformToOriginPoint(l,o)),d=this.control.viewContainerManager.getView(o),f={x:u&&u[0]||0,y:u&&u[1]||0,w:h&&h[0]||0,h:h&&h[1]||0,opt:t,type:Ze.Text,canWorker:!0,canSync:!1,dataType:r,scale:((p=d==null?void 0:d.cameraOpt)==null?void 0:p.scale)||1,viewId:o,scenePath:n};this.editors.set(c,f),r===B.Service&&t.workState===P.Done&&this.activeId===c&&(this.activeId=void 0),this.control.viewContainerManager.setActiveTextEditor(o,this.activeId)}updateForViewEdited(s,e){var i;this.editors.set(s,e);const t=(i=this.taskqueue.get(s))==null?void 0:i.resolve;t&&t(e)}active(s){var t;const e=this.editors.get(s);e&&e.viewId&&(e.opt.workState=P.Start,e.opt.uid=(t=this.collector)==null?void 0:t.uid,this.activeId=s,e.canWorker=!0,e.canSync=!0,this.editors.set(s,e),this.control.viewContainerManager.setActiveTextEditor(e.viewId,this.activeId))}unActive(s){const e=this.editors.get(s);e&&e.viewId&&(e.opt.workState=P.Done,e.opt.uid=void 0,e.canWorker=!0,e.canSync=!0,this.editors.set(s,e),this.activeId=void 0,this.control.viewContainerManager.setActiveTextEditor(e.viewId,this.activeId))}createTextForMasterController(s,e){var n;const{workId:t,isActive:i,...o}=s;e&&this.internalMsgEmitter.emit("addUndoTicker",e,o.viewId),o.opt.uid=(n=this.collector)==null?void 0:n.uid,i&&(this.activeId=t),o.dataType=B.Local,o.canWorker=!0,o.canSync=!0,this.editors.set(t,o),this.control.viewContainerManager.setActiveTextEditor(o.viewId,this.activeId)}updateTextForMasterController(s,e){var n;const{workId:t,...i}=s;e&&this.internalMsgEmitter.emit("addUndoTicker",e,i.viewId);const o=this.editors.get(t)||{};i.opt&&(i.opt.uid=(n=this.collector)==null?void 0:n.uid),i.dataType=B.Local,this.editors.set(t,{...o,...i}),this.control.viewContainerManager.setActiveTextEditor(i.viewId,this.activeId)}async updateTextControllerWithEffectAsync(s,e){var h;const{workId:t,...i}=s;e&&this.internalMsgEmitter.emit("addUndoTicker",e,i.viewId);const o=this.editors.get(t)||{};i.opt&&(i.opt.uid=(h=this.collector)==null?void 0:h.uid),i.dataType=B.Local;const n={...o,...i};if(this.editors.set(t,n),this.control.viewContainerManager.setActiveTextEditor(i.viewId,this.activeId),this.taskqueue.has(t)){const u=this.taskqueue.get(t);return u&&(u.clocker&&clearTimeout(u.clocker),this.taskqueue.delete(t)),await this.updateTextControllerWithEffectAsync(s)}const r=setTimeout(()=>{var d;const u=(d=this.taskqueue.get(t))==null?void 0:d.resolve;u&&u(n)},50),c=await new Promise(u=>{this.taskqueue.set(t,{resolve:u,clocker:r})}),l=this.taskqueue.get(t);return l&&(l.clocker&&clearTimeout(l.clocker),this.taskqueue.delete(t)),c}updateTextForWorker(s,e){const{workId:t,isActive:i,...o}=s,r={...this.editors.get(t)||{},...o};if(i){r.canWorker=!1,r.canSync=!1,this.editors.set(t,r),this.active(t);return}this.editors.set(t,r),this.control.viewContainerManager.setActiveTextEditor(o.viewId,this.activeId),e&&this.internalMsgEmitter.emit("addUndoTicker",e,o.viewId)}get(s){return this.editors.get(s)}delete(s,e,t){const i=this.editors.get(s);if(i){const o=i.viewId;i.canSync=e,i.canWorker=t,this.editors.delete(s),this.activeId===s&&(this.activeId=void 0),this.control.viewContainerManager.setActiveTextEditor(o,this.activeId)}}deleteBatch(s,e,t){const i=new Set;for(const o of s){const n=this.editors.get(o);if(n){const r=n.viewId;n.canSync=e,n.canWorker=t,this.editors.delete(o),this.activeId===o&&(this.activeId=void 0),i.add(r)}}for(const o of i)this.control.viewContainerManager.setActiveTextEditor(o,this.activeId)}clear(s,e){this.editors.forEach((t,i)=>{t.viewId===s&&(e&&(t.canSync=!1),t.canWorker=!1,this.editors.delete(i))}),this.activeId=void 0,this.control.viewContainerManager.setActiveTextEditor(s,this.activeId)}destory(){this.editors.clear(),this.activeId=void 0}}class TM{constructor(s){y(this,"expirationTime",be.cursor.expirationTime);y(this,"internalMsgEmitter");y(this,"control");y(this,"eventName","applianc-cursor");y(this,"displayer");y(this,"roomMember");y(this,"animationId");y(this,"maxLastSyncTime",be.syncOpt.interval);y(this,"willSendEventWorkers",[]);y(this,"willConsumeEventWorkers",new Map);y(this,"sendEventTimerId");y(this,"animationDrawWorkers",new Map);y(this,"animationEventWorkers",new Map);y(this,"cursorInfoMap",new Map);y(this,"doneRenderCursorInfoMap",new Map);y(this,"eventCollector");var i,o;const{control:e,internalMsgEmitter:t}=s;this.internalMsgEmitter=t,this.control=e,this.roomMember=e.roomMember,this.maxLastSyncTime=((o=(i=this.control.pluginOptions)==null?void 0:i.syncOpt)==null?void 0:o.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 r;const{event:e,payload:t}=s;if(e!==this.eventName)return;const{uid:i,op:o,type:n}=t;if(((r=this.control.collector)==null?void 0:r.uid)!==i&&n===At.Cursor&&(o!=null&&o.length)){const c=this.willConsumeEventWorkers.get(i)||[];for(const l of o){const{viewId:h}=l;D.isNumber(l.consumPoint[0])&&D.isNumber(l.consumPoint[1])&&(l.consumPoint=this.control.viewContainerManager.transformToOriginPoint(l.consumPoint,h)),this.control.renderControl.isFilterCursor(h)&&c.unshift({...l,timestamp:Date.now()})}this.willConsumeEventWorkers.set(i,c),this.runAnimation()}}onFocusViewChange(){this.checkDrawWorks(),this.runAnimation()}updateRoomMembers(s){const{offline:e}=s;for(const t of this.cursorInfoMap.keys())t&&e.includes(t)&&this.cursorInfoMap.delete(t)}getKey(s,e){return`${s}${Ee}${e}`}getUidAndviewId(s){const[e,t]=s.split(Ee);return{uid:e,viewId:t}}runAnimation(){this.animationId||(this.animationId=requestAnimationFrame(this.animationCursor.bind(this)))}checkDrawWorks(){var e;const s=this.control.viewContainerManager.focuedViewId;for(const[t,i]of this.animationDrawWorkers.entries()){const{viewId:o,uid:n}=this.getUidAndviewId(t);n!==((e=this.control.collector)==null?void 0:e.uid)&&o!==s&&i.workState===P.Done&&(i.consumPoint=[void 0,void 0])}}animationCursor(){this.animationId=void 0;const s=Date.now();for(const[t,i]of this.animationDrawWorkers.entries()){const{uid:o,viewId:n}=this.getUidAndviewId(t),r=this.roomMember.getRoomMember(o);if(!r){this.animationDrawWorkers.delete(t);continue}const{consumPoint:c,timestamp:l,workState:h}=i,u=this.cursorInfoMap.get(n)||new Map;c&&D.isNumber(c[0])&&D.isNumber(c[1])&&l+this.expirationTime>s?u.set(r.memberId,{x:c[0],y:c[1],roomMember:r,timestamp:l,type:1,workState:h}):u.delete(r.memberId),u.size?this.cursorInfoMap.set(n,u):this.cursorInfoMap.delete(n),this.animationDrawWorkers.delete(t)}const e=new Set;for(const[t,i]of this.cursorInfoMap.entries())if(i)for(const[o,n]of i.entries())n.type===1&&n.workState!==P.Done&&e.add(o);else this.cursorInfoMap.delete(t);for(const[t,i]of this.willConsumeEventWorkers.entries()){const o=this.roomMember.getRoomMember(t);if(D.isNumber(o==null?void 0:o.memberId)&&!e.has(o.memberId)){const n=i.pop();n?this.animationEventWorkers.set(t,n):this.willConsumeEventWorkers.delete(t)}}for(const[t,i]of this.animationEventWorkers.entries()){const o=this.roomMember.getRoomMember(t);if(!o){this.animationEventWorkers.delete(t);continue}const{viewId:n,consumPoint:r,timestamp:c}=i,l=this.cursorInfoMap.get(n)||new Map;r&&D.isNumber(r[0])&&D.isNumber(r[1])&&c+this.expirationTime>s?l.set(o.memberId,{x:r[0],y:r[1],roomMember:o,timestamp:c,type:0}):l.delete(o.memberId),l.size?this.cursorInfoMap.set(n,l):this.cursorInfoMap.delete(n),this.animationEventWorkers.delete(t)}for(const t of this.doneRenderCursorInfoMap.keys())this.cursorInfoMap.has(t)||(this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([te.Cursor,t],[]));for(const[t,i]of this.cursorInfoMap.entries())if(i!=null&&i.size){const o=[];for(const[r,c]of i.entries()){const{timestamp:l,...h}=c;l+this.expirationTime>s?o.push(h):(i.delete(r),i.size===0&&(this.cursorInfoMap.delete(t),this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([te.Cursor,t],[])))}const n=this.doneRenderCursorInfoMap.get(t);D.isEqual(n,o)||(this.doneRenderCursorInfoMap.set(t,o),this.internalMsgEmitter.emit([te.Cursor,t],o))}else this.cursorInfoMap.delete(t),this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([te.Cursor,t],[]);(this.willConsumeEventWorkers.size||this.cursorInfoMap.size)&&this.runAnimation()}sendEvent(s,e){if(this.displayer&&q.isRoom(this.displayer)){const t=D.isNumber(s[0])&&D.isNumber(s[1])&&this.control.viewContainerManager.transformToScenePoint(s,e)||[void 0,void 0];this.willSendEventWorkers.push({consumPoint:t,viewId:e}),this.sendEventTimerId||(this.sendEventTimerId=setTimeout(()=>{this.dispatchMagixEvent()},this.maxLastSyncTime))}}dispatchMagixEvent(){var s;this.displayer.dispatchMagixEvent(this.eventName,{type:At.Cursor,op:D.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 n;const{op:e,uid:t,workState:i,viewId:o}=s;if(t&&e&&i&&o){const r=this.roomMember.getRoomMember(t);if(!r||t===((n=this.control.collector)==null?void 0:n.uid))return;const c=this.getKey(t,o);let l=[void 0,void 0];if(D.isNumber(e[0])&&D.isNumber(e[1])){const[u,d]=this.control.viewContainerManager.transformToOriginPoint(e,o);l=[u,d]}if(i===P.Start){for(const u of this.cursorInfoMap.values())if(u!=null&&u.size)for(const d of u.keys())d===r.memberId&&u.delete(d)}const h={consumPoint:l,workState:i,viewId:o,timestamp:Date.now()};if(i===P.Start||i===P.Done){const u=this.willConsumeEventWorkers.get(t);i===P.Start&&u&&this.willConsumeEventWorkers.delete(t),u&&i===P.Done&&(h.timestamp=h.timestamp-this.expirationTime)}this.animationDrawWorkers.set(c,h),this.runAnimation()}}unabled(){var s;this.displayer&&q.isRoom(this.displayer)&&(this.willSendEventWorkers.length=0,this.displayer.dispatchMagixEvent(this.eventName,{type:At.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 e,t,i;for(const[o]of this.animationDrawWorkers.entries()){const{uid:n}=this.getUidAndviewId(o);n===((e=this.control.collector)==null?void 0:e.uid)&&s===s&&this.animationDrawWorkers.delete(o)}for(const[o]of this.willConsumeEventWorkers.entries())o===((t=this.control.collector)==null?void 0:t.uid)&&this.willConsumeEventWorkers.delete(o);for(const[o]of this.animationEventWorkers.entries())o===((i=this.control.collector)==null?void 0:i.uid)&&this.animationEventWorkers.delete(o);for(const[o]of this.cursorInfoMap.entries())o===o&&(this.cursorInfoMap.delete(o),this.doneRenderCursorInfoMap.delete(o),this.internalMsgEmitter.emit([te.Cursor,o],[]))}stopAnimation(){this.animationDrawWorkers.clear(),this.willConsumeEventWorkers.clear(),this.cursorInfoMap.clear()}destroy(){var s;(s=this.displayer)==null||s.removeMagixEventListener(this.eventName),this.stopAnimation()}}class Be{constructor(){y(this,"useEmtMsg");y(this,"emtType");y(this,"control");y(this,"mainEngine")}static dispatch(s,e,t){var i;(i=Ne.InternalMsgEmitter)==null||i.emit([s,e],t)}get serviceColloctor(){return this.control.collector}registerForMainEngine(s,e){return this.emtType=s,this.control=e,this.mainEngine=e.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,e){var t,i,o;for(const[n,r]of s)(t=this.mainEngine)==null||t.queryTaskBatchData(r).forEach(c=>{var l;(l=this.mainEngine)==null||l.taskBatchData.delete(c)}),(i=this.mainEngine)==null||i.taskBatchData.add(n);if(e){this.mainEngine.consume();return}(o=this.mainEngine)==null||o.runAnimation()}collectForServiceWorker(s){Ue(()=>{s.forEach(e=>{var t;(t=this.serviceColloctor)==null||t.dispatch(e)})},this.mainEngine.maxLastSyncTime)}pause(){var s;if(this.lastEmtData){this.useEmtMsg=!0;const e={...this.lastEmtData,workState:P.Done};this.collect(e,!0),(s=Ne.InternalMsgEmitter)==null||s.emit(F.ActiveMethod,!1)}}recover(){var s;this.useEmtMsg&&Ne.InternalMsgEmitter.hasListeners(F.ActiveMethod)&&((s=Ne.InternalMsgEmitter)==null||s.emit(F.ActiveMethod,!0))}}class kM extends Be{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",F.CopyNode)}collect(e){var c;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:i}=e,o=this.control.viewContainerManager.getView(i);if(!(o!=null&&o.displayer))return;const n=o.focusScenePath,r=Date.now();this.mainEngine.internalMsgEmitter.emit("addUndoTicker",r,i);for(const l of t){const h=l.toString(),d=this.serviceColloctor.isLocalId(h)?this.serviceColloctor.transformKey(l):h,f=(c=this.serviceColloctor.getStorageData(i,n))==null?void 0:c[d];if(f){if(l===Q){const g=f&&this.copySelector({viewId:i,store:f});g&&this.pasteSelector({...g,viewId:i,scenePath:n,undoTickerId:r});break}if(f.toolsType===I.Text&&f.opt&&f.opt.workState&&f.opt.workState!==P.Done){const g=f&&this.copyText({viewId:i,store:f});g&&this.pasteText({...g,viewId:i,scenePath:n,key:d,store:f,undoTickerId:r});break}}}}copyText(e){const{viewId:t,store:i}=e,o=this.control.viewContainerManager.getView(t);if(!this.serviceColloctor||!o)return;const n=o==null?void 0:o.cameraOpt,r=n&&[n.centerX,n.centerY],c=i.opt,l=c.boxPoint&&c.boxSize&&[c.boxPoint[0]+c.boxSize[0]/2,c.boxPoint[1]+c.boxSize[1]/2];return{bgCenter:r,textCenter:l}}pasteText(e){var m,N;const{bgCenter:t,textCenter:i,store:o,key:n,viewId:r,scenePath:c,undoTickerId:l}=e,h=this.control.viewContainerManager.getView(r);if(!this.serviceColloctor||!h)return;const u=Math.floor(Math.random()*30+1),d=((m=h.cameraOpt)==null?void 0:m.scale)||1,f=t&&i&&[t[0]-i[0]+u,t[1]-i[1]+u]||[u/d,u/d],p=(this.serviceColloctor.isLocalId(n)?n:this.serviceColloctor.getLocalId(n.toString()))+"-"+l;if(o.toolsType===I.Text&&o.opt){const v=o.opt;if(v&&v.boxPoint&&v.text){v.workState=P.Done;const T=v.boxPoint;v.boxPoint=[T[0]+f[0],T[1]+f[1]],v.workState=P.Done;const k=this.control.viewContainerManager.transformToOriginPoint(v.boxPoint,r);this.control.textEditorManager.createTextForMasterController({workId:p,x:k[0],y:k[1],opt:v,scale:((N=h.cameraOpt)==null?void 0:N.scale)||1,type:Ze.Text,isActive:!1,viewId:r,scenePath:c}),this.collectForServiceWorker([{...o,opt:v,type:x.FullWork,workId:p,viewId:r,scenePath:c}])}}}copySelector(e){var p,m,N,v,T,k,S,w,C;const{viewId:t,store:i}=e,o=this.control.viewContainerManager.getView(t),n=i.selectIds;if(!this.serviceColloctor||!(n!=null&&n.length)||!o)return;const r=new Map,c={offset:{x:0,y:0},cameraOpt:{centerX:((p=o.cameraOpt)==null?void 0:p.centerX)||0,centerY:((m=o.cameraOpt)==null?void 0:m.centerY)||0,scale:((N=o.cameraOpt)==null?void 0:N.scale)||1}},l=this.control.hasOffscreenCanvas()&&((v=o.displayer.canvasBgRef.current)==null?void 0:v.getBoundingClientRect())||((T=o.displayer.canvasContainerRef.current)==null?void 0:T.getBoundingClientRect()),h=(S=(k=o.displayer)==null?void 0:k.floatBarRef.current)==null?void 0:S.getBoundingClientRect(),u=l&&[l.x+l.width/2,l.y+l.height/2],d=h&&[h.x+h.width/2,h.y+h.height/2],f=u&&o.viewData&&o.viewData.convertToPointInWorld({x:u[0],y:u[1]}),g=d&&o.viewData&&o.viewData.convertToPointInWorld({x:d[0],y:d[1]});f&&g&&(c.offset={x:f.x-g.x,y:f.y-g.y});for(const L of n){const j=(C=(w=this.serviceColloctor)==null?void 0:w.getStorageData(o.id,o.focusScenePath))==null?void 0:C[L];j&&r.set(L,j)}return{copyStores:r,copyCoordInfo:c}}pasteSelector(e){var m;const{copyStores:t,copyCoordInfo:i,viewId:o,scenePath:n,undoTickerId:r}=e,c=this.control.viewContainerManager.getView(o);if(!t.size||!this.serviceColloctor||!c)return;const{offset:l,cameraOpt:h}=i,{scale:u}=h,d=Math.floor(Math.random()*30+1),f=l&&[l.x+d,l.y+d]||[d/u,d/u],g=[],p=[];for(const[N,v]of t.entries()){const k=(this.serviceColloctor.isLocalId(N)?N:this.serviceColloctor.getLocalId(N.toString()))+"-"+r,S={useAnimation:!1};if(v.toolsType===I.Text&&v.opt){const w=v.opt;if(w&&w.boxPoint&&w.text){w.workState=P.Done;const C=w.boxPoint;w.boxPoint=[C[0]+f[0],C[1]+f[1]],w.workState=P.Done;const L=this.control.viewContainerManager.transformToOriginPoint(w.boxPoint,o);this.control.textEditorManager.createTextForMasterController({workId:k,x:L[0],y:L[1],opt:w,scale:((m=c.cameraOpt)==null?void 0:m.scale)||1,type:Ze.Text,isActive:!1,viewId:o,scenePath:n})}p.push({...v,opt:w,type:x.FullWork,workId:k,viewId:o,scenePath:n});continue}if(v.toolsType===I.Image&&(v.opt.uuid=k,v.opt.centerX=v.opt.centerX+f[0],v.opt.centerY=v.opt.centerY+f[1]),v.ops){const w=it(v.ops).map((L,j)=>{const E=j%3;return E===0?L+f[0]:E===1?L+f[1]:L}),C=Re(w);v.ops=C}p.push({...v,updateNodeOpt:S,type:x.FullWork,workId:k,viewId:o,scenePath:n}),g.push([{...v,updateNodeOpt:S,workId:k,msgType:x.FullWork,dataType:B.Local,emitEventType:F.CopyNode,willSyncService:!1,willRefresh:!0,viewId:o},{workId:k,msgType:x.FullWork,emitEventType:F.CopyNode}])}g.length&&this.collectForLocalWorker(g),p.length&&this.collectForServiceWorker(p)}}function Ut(a,s,e){return"#"+((a<<16)+(s<<8)+e).toString(16).padStart(6,"0")}function Se(a,s=1){return"rgba("+parseInt("0x"+a.slice(1,3))+","+parseInt("0x"+a.slice(3,5))+","+parseInt("0x"+a.slice(5,7))+","+s+")"}function Pt(a,s,e,t=1){return`rgba(${a},${s},${e},${t})`}function ys(a){const s=a.split(","),e=parseInt(s[0].split("(")[1]),t=parseInt(s[1]),i=parseInt(s[2]),o=Number(s[3].split(")")[0]);return[Ut(e,t,i),o]}function Vt(a){const s=a.split(","),e=parseInt(s[0].split("(")[1]),t=parseInt(s[1]),i=parseInt(s[2]),o=Number(s[3].split(")")[0]);return[e,t,i,o]}function $t(a){return a==="transparent"}class CM extends Be{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",F.SetColorNode);y(this,"undoTickerId")}setTextColor(e,t,i,o){const{fontColor:n,fontBgColor:r}=i;t.opt&&(n&&(t.opt.fontColor=n),r&&(t.opt.fontBgColor=r),this.control.textEditorManager.updateTextForMasterController({workId:e,opt:t.opt,viewId:o,canSync:!0,canWorker:!0}))}collect(e){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,strokeColor:i,fillColor:o,fontColor:n,fontBgColor:r,viewId:c,workState:l,thickness:h,strokeType:u}=e,d=this.control.viewContainerManager.getView(c);if(!(d!=null&&d.displayer))return;const f=d.focusScenePath,g=[...t],p=this.serviceColloctor.storage,m=[],N={};for((l===P.Start||!this.undoTickerId&&l===P.Done)&&(this.undoTickerId=Date.now(),this.mainEngine.internalMsgEmitter.emit("addUndoTicker",this.undoTickerId,c));g.length;){const v=g.pop();if(!v)continue;const T=v.toString(),k=this.serviceColloctor.isLocalId(T),S=k?this.serviceColloctor.transformKey(v):T;let w=T;!k&&this.serviceColloctor.isOwn(w)&&(w=this.serviceColloctor.getLocalId(w));const C=p[c][f][S]||void 0;if(C){const L=C.updateNodeOpt||{};if(n||r){if(n){L.fontColor=n;const[E,A,W,z]=Vt(n);N.textColor=[E,A,W],N.textOpacity=z}if(r)if(L.fontBgColor=$t(r)?"transparent":r,$t(r))N.textBgColor=void 0,N.textBgOpacity=void 0;else{const[E,A,W,z]=Vt(r);N.textBgColor=[E,A,W],N.textBgOpacity=z}if(C.toolsType===I.Text&&C.opt&&l!==P.Start){this.setTextColor(w,Ce(C),L,c),l===P.Done&&(this.undoTickerId=void 0);continue}}if(i){L.strokeColor=i;const[E,A,W,z]=Vt(i);N.strokeColor=[E,A,W],N.strokeOpacity=z}if(o)if(L.fillColor=$t(o)?"transparent":o,$t(o))N.fillColor=void 0,N.fillOpacity=void 0;else{const[E,A,W,z]=Vt(o);N.fillColor=[E,A,W],N.fillOpacity=z}h&&(L.thickness=h,N.strokeWidth=h),u&&(L.strokeType=u,N.strokeType=u);const j={workId:w,msgType:x.UpdateNode,dataType:B.Local,updateNodeOpt:L,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,textUpdateForWoker:!0,viewId:c};m.push([j,{workId:w,msgType:x.UpdateNode,emitEventType:this.emitEventType}])}}m.length&&(l===P.Done&&(this.undoTickerId=void 0),this.collectForLocalWorker(m)),Object.keys(N).length&&setTimeout(()=>{var v;(v=this.control.room)==null||v.setMemberState(N)},0)}}class bM extends Be{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",F.ZIndexNode);y(this,"zIndexMap",new Map)}clearZIndex(e){this.zIndexMap.delete(e)}getMinZIndex(e){var t;return((t=this.zIndexMap.get(e))==null?void 0:t.min)||0}getMaxZIndex(e){var t;return((t=this.zIndexMap.get(e))==null?void 0:t.max)||0}setMaxZIndex(e,t){const i=this.getMinZIndex(t);this.zIndexMap.set(t,{min:i,max:e})}setMinZIndex(e,t){const i=this.getMaxZIndex(t);this.zIndexMap.set(t,{min:e,max:i})}addMaxLayer(e){const t=this.getMaxZIndex(e)+1;this.setMaxZIndex(t,e)}addMinLayer(e){const t=this.getMinZIndex(e)-1;this.setMinZIndex(t,e)}correct(e){const t=e.sort((i,o)=>i[1]-o[1]);for(let i=1;i<t.length;i++){const o=t[i][1],n=t[i-1][1];o<=n&&(t[i][1]=n+1)}return t}collect(e){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,layer:i,viewId:o}=e,n=this.control.viewContainerManager.getView(o);if(!(n!=null&&n.displayer))return;const r=n.focusScenePath,c=[...t],l=this.serviceColloctor.storage,h=[],u=[];for(;c.length;){const f=c.pop();if(!f)continue;const g=f.toString(),p=this.serviceColloctor.isLocalId(g),m=p?this.serviceColloctor.transformKey(f):g;let N=g;!p&&this.serviceColloctor.isOwn(N)&&(N=this.serviceColloctor.getLocalId(N));const v=Ce(l[o][r][m]);let T;if(v&&N===Q){if(v.selectIds){u.push(...v.selectIds),u.sort((C,L)=>{var A,W,z,O;const j=((W=(A=l[d(C,this.serviceColloctor)])==null?void 0:A.opt)==null?void 0:W.zIndex)||0,E=((O=(z=l[d(C,this.serviceColloctor)])==null?void 0:z.opt)==null?void 0:O.zIndex)||0;return j>E?1:C<L?-1:0});const k=v.updateNodeOpt||{};k.zIndexLayer=i;const S={workId:f,msgType:x.UpdateNode,dataType:B.Local,updateNodeOpt:k,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:o},w=new Map;i===Et.Top?(this.addMaxLayer(o),T=this.getMaxZIndex(o)):(this.addMinLayer(o),T=this.getMinZIndex(o)),u.forEach(C=>{var A,W,z;const L=(A=this.serviceColloctor)==null?void 0:A.isLocalId(C);let j=L&&((W=this.serviceColloctor)==null?void 0:W.transformKey(C))||C;const E=l[o][r][j];!L&&((z=this.serviceColloctor)!=null&&z.isOwn(j))&&(j=this.serviceColloctor.getLocalId(j)),k.zIndex=T,E!=null&&E.opt&&(E.opt.zIndex=T),E!=null&&E.opt&&w.set(j,{updateNodeOpt:E.updateNodeOpt,opt:E.opt})}),S.selectStore=w,S.willSerializeData=!0,h.push([S,{workId:f,msgType:x.UpdateNode,emitEventType:this.emitEventType}])}continue}}h.length&&this.collectForLocalWorker(h);function d(f,g){return g.isLocalId(f)&&g.transformKey(f)||f}}}class xM extends Be{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",F.TranslateNode);y(this,"cachePosition")}collect(e,t){var g;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:i,position:o,workState:n,viewId:r}=e;this.lastEmtData=e;const c=this.control.viewContainerManager.getView(r);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,h=[...i],u=(g=this.serviceColloctor)==null?void 0:g.storage,d=[],f=n===P.Start&&Date.now()||void 0;for(f&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",f,r);h.length;){const p=h.pop();if(!p)continue;const m=p.toString(),N=this.serviceColloctor.isLocalId(m),v=N&&this.serviceColloctor.transformKey(p)||m;let T=m;!N&&this.serviceColloctor.isOwn(T)&&(T=this.serviceColloctor.getLocalId(T));const k=u[r][l][v];if(k&&T===Q){if(k.selectIds){const S=this.control.viewContainerManager.transformToScenePoint([o.x,o.y],r);if(n===P.Start&&(this.cachePosition=S),this.cachePosition){const w=k.updateNodeOpt||{};w.translate=[S[0]-this.cachePosition[0],S[1]-this.cachePosition[1]],w.workState=n;const C={workId:p,msgType:x.UpdateNode,dataType:B.Local,updateNodeOpt:w,emitEventType:this.emitEventType,willSyncService:!0,textUpdateForWoker:!0,viewId:r};n===P.Done&&(C.textUpdateForWoker=!0,C.willSerializeData=!0,this.cachePosition=void 0),d.push([C,{workId:p,msgType:x.UpdateNode,emitEventType:this.emitEventType,workState:n}])}}continue}}n===P.Start?this.mainEngine.unWritable():n===P.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length&&this.collectForLocalWorker(d,t)}}class LM extends Be{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",F.DeleteNode)}collect(e){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:i}=e,o=this.control.viewContainerManager.getView(i);if(!(o!=null&&o.displayer))return;const n=o.focusScenePath,r=this.serviceColloctor.storage,c=[...t],l=[],h=[],u=Date.now();for(;c.length;){const d=c.pop();if(!d)continue;const f=d.toString(),g=this.serviceColloctor.isLocalId(f),p=g?this.serviceColloctor.transformKey(d):f,m=r[i][n][p];if(m){let N=f;if(!g&&this.serviceColloctor.isOwn(N)&&(N=this.serviceColloctor.getLocalId(N)),m.toolsType===I.Text){this.control.textEditorManager.delete(N,!0,!0);continue}h.push(N)}}h.length&&(l.push([{msgType:x.RemoveNode,emitEventType:F.DeleteNode,removeIds:h,dataType:B.Local,willSyncService:!0,willRefresh:!0,viewId:i},void 0]),this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,i),this.collectForLocalWorker(l))}}class zM extends Be{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",F.ScaleNode);y(this,"targetText",new Map);y(this,"cacheTextInfo",new Map)}async setTextStyle(e,t,i){const o=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:e,opt:t,viewId:i,canSync:!1,canWorker:!1});return{key:e,textInfo:o}}async collect(e,t){var v,T,k,S,w;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:i,workState:o,viewId:n,originPoint:r,scenePoint:c,dir:l,scale:h,translate:u}=e;this.lastEmtData=e;const d=this.control.viewContainerManager.getView(n);if(!(d!=null&&d.displayer))return;const f=d.focusScenePath,g=[...i],p=(v=this.serviceColloctor)==null?void 0:v.storage,m=[],N=o===P.Start&&Date.now()||void 0;for(N&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",N,n);g.length;){const C=g.pop();if(!C)continue;const L=C.toString(),j=this.serviceColloctor.isLocalId(L),E=j&&this.serviceColloctor.transformKey(C)||L;let A=L;!j&&this.serviceColloctor.isOwn(A)&&(A=this.serviceColloctor.getLocalId(A));const W=p[n][f][E];if(W&&A===Q&&W.selectIds){const z=W.updateNodeOpt||{};if(z.dir=l,z.originPoint=r,z.scenePoint=c,z.workState=o,z.scale=h,z.translate=u,o===P.Start){this.cacheTextInfo.clear();for(const se of W.selectIds){const _=(T=this.serviceColloctor)==null?void 0:T.isLocalId(se),H=_&&((k=this.serviceColloctor)==null?void 0:k.transformKey(se))||se;let X=H;!_&&((S=this.serviceColloctor)!=null&&S.isOwn(H))&&(X=this.serviceColloctor.getLocalId(H));const G=this.control.textEditorManager.get(X);G&&o===P.Start&&this.targetText.set(X,Ce(G))}}if(this.targetText.size&&o!==P.Start&&h){const se=[];for(const[H,X]of this.targetText.entries()){const{opt:G}=X,Z=Math.floor(G.fontSize*h[0]),K=this.cacheTextInfo.get(H),ae=!K&&G.fontSize!==Z||K&&K.fontSize!==Z||!1,Te=(w=this.control.textEditorManager.get(H))==null?void 0:w.opt;if(ae&&Te&&G.boxSize&&G.boxPoint){const ie=this.setTextStyle(H,{...Te,fontSize:Z},n);se.push(ie)}}const _=await Promise.all(se);for(const H of _)if(H){const{key:X,textInfo:G}=H;this.cacheTextInfo.set(X,{fontSize:G.opt.fontSize,boxSize:G.opt.boxSize,boxPoint:G.opt.boxPoint})}z.textInfos=this.cacheTextInfo}const O={workId:C,msgType:x.UpdateNode,dataType:B.Local,updateNodeOpt:z,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:n};o===P.Done&&(O.willSerializeData=!0,this.targetText.clear()),m.push([O,{workId:C,msgType:x.UpdateNode,emitEventType:this.emitEventType,workState:o}]);continue}}o===P.Start?this.mainEngine.unWritable():o===P.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),m.length&&this.collectForLocalWorker(m,t)}}class PM extends Be{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",F.RotateNode);y(this,"cacheOriginRotate",0)}collect(e,t){var g,p,m,N,v;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:i,angle:o,workState:n,viewId:r}=e;this.lastEmtData=e;const c=this.control.viewContainerManager.getView(r);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,h=[...i],u=(g=this.serviceColloctor)==null?void 0:g.storage,d=[],f=n===P.Start&&Date.now()||void 0;for(f&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",f,r);h.length;){const T=h.pop();if(!T)continue;const k=T.toString(),S=this.serviceColloctor.isLocalId(k),w=S&&this.serviceColloctor.transformKey(T)||k;let C=k;!S&&this.serviceColloctor.isOwn(C)&&(C=this.serviceColloctor.getLocalId(C));const L=u[r][l][w];if(L&&C===Q){if(((p=L.selectIds)==null?void 0:p.length)===1){const j=L.selectIds[0];if(n===P.Start){const z=((m=this.serviceColloctor)==null?void 0:m.isLocalId(j))&&((N=this.serviceColloctor)==null?void 0:N.transformKey(j))||j,O=u[r][l][z];this.cacheOriginRotate=((v=O==null?void 0:O.opt)==null?void 0:v.rotate)||0}const E=L.updateNodeOpt||{};E.angle=(o+this.cacheOriginRotate)%360,E.workState=n;const A={workId:T,msgType:x.UpdateNode,dataType:B.Local,updateNodeOpt:E,emitEventType:this.emitEventType,willRefreshSelector:!1,willSyncService:!0,viewId:r};n===P.Done&&(A.willRefreshSelector=!0,A.willSerializeData=!0,this.cacheOriginRotate=0),d.push([A,{workId:T,msgType:x.UpdateNode,emitEventType:this.emitEventType,workState:n}])}continue}}n===P.Start?this.mainEngine.unWritable():n===P.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),d.length&&this.collectForLocalWorker(d,t)}}function DM(a){switch(a){case I.Text:return Ze.Text;case I.SpeechBalloon:case I.Star:case I.Ellipse:case I.Rectangle:case I.Triangle:case I.Rhombus:case I.Polygon:return Ze.Shape}}class AM extends Be{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",F.SetFontStyle);y(this,"timerId")}async setTextStyle(e,t,i,o){const{bold:n,underline:r,lineThrough:c,italic:l,fontSize:h}=i;if(t.toolsType&&DM(t.toolsType)===Ze.Text){t.opt&&(n&&(t.opt.bold=n),D.isBoolean(r)&&(t.opt.underline=r),D.isBoolean(c)&&(t.opt.lineThrough=c),l&&(t.opt.italic=l),h&&(t.opt.fontSize=h));const d=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:e,opt:t.opt,viewId:o,canSync:!1,canWorker:!1});return{key:e,textInfo:d}}}async collect(e){var v,T,k,S;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,bold:i,italic:o,lineThrough:n,underline:r,viewId:c,fontSize:l}=e,h=this.control.viewContainerManager.getView(c);if(!(h!=null&&h.displayer))return;const u=h.focusScenePath,d=[...t],f=this.serviceColloctor.storage,g={},p=Date.now();this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,c);const m=[];for(;d.length;){const w=d.pop();if(!w)continue;const C=w.toString(),L=this.serviceColloctor.isLocalId(C),j=L?this.serviceColloctor.transformKey(w):C;let E=C;!L&&this.serviceColloctor.isOwn(E)&&(E=this.serviceColloctor.getLocalId(E));const A=f[c][u][j]||void 0;if(A){const W=A.updateNodeOpt||{};if(i&&(W.bold=i,g.bold=i==="bold"),o&&(W.italic=o,g.italic=o==="italic"),D.isBoolean(n)&&(W.lineThrough=n,g.lineThrough=n),D.isBoolean(r)&&(W.underline=r,g.underline=r),l&&(W.fontSize=l,g.textSize=l),A.toolsType===I.Text&&A.opt){const z=this.setTextStyle(E,D.cloneDeep(A),W,c);m.push(z);continue}if(A&&E===Q&&((v=A.selectIds)!=null&&v.length))for(const z of A.selectIds){const O=(T=this.serviceColloctor)==null?void 0:T.isLocalId(z);let se=O&&((k=this.serviceColloctor)==null?void 0:k.transformKey(z))||z;const _=f[c][u][se]||void 0;if(!O&&((S=this.serviceColloctor)!=null&&S.isOwn(se))&&(se=this.serviceColloctor.getLocalId(se)),_&&_.toolsType===I.Text&&A.opt){const H=this.setTextStyle(se,D.cloneDeep(_),W,c);m.push(H);continue}}}}const N=await Promise.all(m);for(const w of N)if(w){const{key:C,textInfo:L}=w;L&&(L.canSync=!0,L.canWorker=!0,this.control.textEditorManager.updateForViewEdited(C,L))}Object.keys(g).length&&(this.timerId&&(clearTimeout(this.timerId),this.timerId=void 0),this.timerId=setTimeout(()=>{var w;this.timerId=void 0,(w=this.control.room)==null||w.setMemberState(g)},0))}}class jM extends Be{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",F.SetPoint);y(this,"undoTickerId")}collect(e){var v;if(!this.serviceColloctor||!this.mainEngine)return;const{workId:t,pointMap:i,workState:o,viewId:n}=e,r=this.control.viewContainerManager.getView(n);if(!(r!=null&&r.displayer))return;const c=r.focusScenePath,l=(v=this.serviceColloctor)==null?void 0:v.storage,h=[],u=o===P.Start&&Date.now()||void 0;u&&(this.undoTickerId=u,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,n));const d=t;if(!d)return;const f=d.toString(),g=this.serviceColloctor.isLocalId(f),p=g&&this.serviceColloctor.transformKey(d)||f;let m=f;!g&&this.serviceColloctor.isOwn(m)&&(m=this.serviceColloctor.getLocalId(m));const N=l[n][c][p];if(N&&m===Q&&N.selectIds){const T=N.updateNodeOpt||{};T.pointMap=i,T.workState=o;const k={workId:d,msgType:x.UpdateNode,dataType:B.Local,updateNodeOpt:T,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:n};o===P.Done&&(k.undoTickerId=this.undoTickerId),h.push([k,{workId:d,msgType:x.UpdateNode,emitEventType:this.emitEventType}])}o===P.Start?this.mainEngine.unWritable():o===P.Done&&this.mainEngine.abled(),h.length&&this.collectForLocalWorker(h)}}class EM extends Be{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",F.SetLock)}collect(e){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,isLocked:i,viewId:o}=e,n=this.control.viewContainerManager.getView(o);if(!(n!=null&&n.displayer))return;const r=n.focusScenePath,c=[...t],l=this.serviceColloctor.storage,h=[],u=Date.now();for(;c.length;){const d=c.pop();if(!d)continue;const f=d.toString(),g=this.serviceColloctor.isLocalId(f),p=g?this.serviceColloctor.transformKey(d):f;let m=f;!g&&this.serviceColloctor.isOwn(m)&&(m=this.serviceColloctor.getLocalId(m));const N=l[o][r][p]||void 0;if(N){const v=N.updateNodeOpt||{};v.isLocked=i;const T={workId:m,msgType:x.UpdateNode,dataType:B.Local,updateNodeOpt:v,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:o};h.push([T,{workId:m,msgType:x.UpdateNode,emitEventType:this.emitEventType}])}}this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,o),h.length&&this.collectForLocalWorker(h)}}class OM extends Be{constructor(){super(...arguments);y(this,"lastEmtData");y(this,"emitEventType",F.SetShapeOpt)}collect(e){if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:i,...o}=e,n=this.control.viewContainerManager.getView(i);if(!(n!=null&&n.displayer))return;const r=n.focusScenePath,c=[...t],l=this.serviceColloctor.storage,h=[],u=Date.now();for(;c.length;){const d=c.pop();if(!d)continue;const f=d.toString(),g=this.serviceColloctor.isLocalId(f),p=g?this.serviceColloctor.transformKey(d):f;let m=f;!g&&this.serviceColloctor.isOwn(m)&&(m=this.serviceColloctor.getLocalId(m));const N=l[i][r][p]||void 0;if(N){const v={...N.updateNodeOpt,...o,willRefresh:!0};if(N&&m===Q){const T={workId:m,msgType:x.UpdateNode,dataType:B.Local,updateNodeOpt:v,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:i};h.push([T,{workId:m,msgType:x.UpdateNode,emitEventType:this.emitEventType}])}}}h.length&&(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,i),this.collectForLocalWorker(h))}}class oe{constructor(s){y(this,"builders",new Map);this.builders=new Map(s.map(e=>[e,this.build(e)]))}build(s){switch(s){case F.TranslateNode:return new xM;case F.ZIndexNode:return new bM;case F.CopyNode:return new kM;case F.SetColorNode:return new CM;case F.DeleteNode:return new LM;case F.ScaleNode:return new zM;case F.RotateNode:return new PM;case F.SetFontStyle:return new AM;case F.SetPoint:return new jM;case F.SetLock:return new EM;case F.SetShapeOpt:return new OM}}getBuilder(s){return this.builders.get(s)}registerForMainEngine(s,e){return this.builders.forEach(t=>{t&&t.registerForMainEngine(s,e)}),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,e,t){Be.dispatch(s,e,t)}static activeListener(s){Ne.InternalMsgEmitter.on(F.ActiveMethod,s)}static unmountActiveListener(s){Ne.InternalMsgEmitter.off(F.ActiveMethod,s)}}class RM{constructor(s){y(this,"master");y(this,"mainThreadWorkerMap",new Map);this.master=s}updateCamera(){for(const[s,e]of this.mainThreadWorkerMap.entries()){const t=this.master.control.viewContainerManager.getView(s);if(t){const{cameraOpt:i}=t;e.updateCamera({cameraOpt:i,viewId:t.viewId,msgType:x.UpdateCamera,dataType:B.Local})}}}notifyDrawCount(s){const e=this.master.getFullWorkDrawCount(),t=this.mainThreadWorkerMap.get(s);t&&t.clearDrawLayer(e)}clearDrawCount(s){const e=this.mainThreadWorkerMap.get(s);e&&e.clearDrawLayer(1/0)}createMainThreadWorker(s,e){return new WM(s,e,this)}consume(s){var e;for(const t of s.values()){const{msgType:i,viewId:o,layerOpt:n,offscreenCanvasOpt:r,cameraOpt:c}=t;if(i===x.Console){console.log(this);continue}if(i===x.Init){const h=(e=this.master.control.viewContainerManager.getView(o))==null?void 0:e.displayer,u=h==null?void 0:h.subLocalCanvasContainerRef.current;if(h&&u&&n&&r){const d=this.createMainThreadWorker(o,{displayer:h,container:u,layerOpt:n,master:this.master,canvasOpt:r,post:this.post.bind(this)});this.mainThreadWorkerMap.set(o,d),d&&c&&d.setCameraOpt(c)}continue}if(i===x.TasksQueue)continue;const l=this.mainThreadWorkerMap.get(o);l&&(l.on(t),i===x.Destroy&&(l.destroy(),this.mainThreadWorkerMap.delete(o)))}}post(s){const{sp:e}=s;e&&this.master.collectorSyncData(e)}destroy(){for(const s of this.mainThreadWorkerMap.values())s.destroy();this.mainThreadWorkerMap.clear()}active(){}}class WM{constructor(s,e,t){y(this,"viewId");y(this,"opt");y(this,"manager");y(this,"subLocalLayer");y(this,"subLocalWork");y(this,"scene");y(this,"cameraOpt");this.viewId=s,this.opt=e,this.manager=t,this.scene=this.createScene({...e.canvasOpt,container:e.container});const i=be.bufferSize.full,o=be.bufferSize.sub;this.subLocalLayer=this.createLayer("subLocalLayer",this.scene,{...e.layerOpt,bufferSize:this.viewId===de?i:o,contextType:"2d"});const n={thread:this};this.subLocalWork=new YM(n)}createScene(s){return new le.Scene({displayRatio:this.opt.displayer.dpr,depth:!1,desynchronized:!0,...s,contextType:"2d",autoRender:!0,id:this.viewId})}createLayer(s,e,t){const{width:i,height:o}=t,n=`canvas-${s}`,r=e.layer(n,{...t,offscreen:!1}),c=new le.Group({anchor:[.5,.5],pos:[i*.5,o*.5],size:[i,o],name:"viewport",id:s});return r.append(c),c}updateScene(s){this.scene.attr({...s});const{width:e,height:t}=s;this.scene.width=e,this.scene.height=t,this.updateLayer({width:e,height:t})}updateLayer(s){const{width:e,height:t}=s;this.subLocalLayer.parent.setAttribute("width",e),this.subLocalLayer.parent.setAttribute("height",t),this.subLocalLayer.setAttribute("size",[e,t]),this.subLocalLayer.setAttribute("pos",[e*.5,t*.5])}updateDpr(s){this.scene.displayRatio=s}on(s){const{msgType:e,toolsType:t,opt:i,dataType:o,workId:n,workState:r}=s,c=n==null?void 0:n.toString();switch(e){case x.Destroy:this.destroy();break;case x.Clear:this.clearAll();break;case x.UpdateDpr:D.isNumber(s.dpr)&&this.updateDpr(s.dpr);break;case x.UpdateCamera:this.updateCamera(s);break;case x.UpdateTools:if(t&&this.subLocalWork.canUseSubWorkerLayer(t)&&i){const l={toolsType:t,toolsOpt:i};this.subLocalWork.setToolsOpt(l)}break;case x.CreateWork:c&&i&&t&&this.subLocalWork.canUseSubWorkerLayer(t)&&(this.subLocalWork.getToolsOpt()||this.subLocalWork.setToolsOpt({toolsType:t,toolsOpt:i}),this.subLocalWork.setWorkOptions(c,i));break;case x.DrawWork:t&&this.subLocalWork.canUseSubWorkerLayer(t)&&(r===P.Done&&o===B.Local?this.subLocalWork.consumeDrawAll(s):this.subLocalWork.consumeDraw(s));break;case x.RemoveNode:this.subLocalWork.removeNode(s);return}}setCameraOpt(s){this.cameraOpt=s;const{scale:e,centerX:t,centerY:i,width:o,height:n}=s;(o!==this.scene.width||n!==this.scene.height)&&this.updateScene({width:o,height:n}),this.subLocalLayer&&(this.subLocalLayer.setAttribute("scale",[e,e]),this.subLocalLayer.setAttribute("translate",[-t,-i]))}updateCamera(s){const{cameraOpt:e}=s;e&&!D.isEqual(this.cameraOpt,e)&&(this.subLocalWork.workShapes.size&&this.clearAll(),this.setCameraOpt(e))}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 e=this.subLocalLayer.children.filter(t=>t.id&&D.isNumber(parseInt(t.id))&&parseInt(t.id)<s);for(const t of e)t.disconnect(),this.subLocalLayer.removeChild(t)}}class YM{constructor(s){y(this,"thread");y(this,"workShapes",new Map);y(this,"tmpOpt");y(this,"syncUnitTime",be.syncOpt.interval);y(this,"subWorkerDrawCount",0);this.thread=s.thread}getToolsOpt(){return this.tmpOpt}consumeDrawAll(s){const{workId:e}=s,t=e==null?void 0:e.toString();t&&this.workShapes.get(t)&&(this.subWorkerDrawCount=0,this.thread.subLocalLayer.removeAllChildren(),this.clearWorkShapeNodeCache(t))}consumeDraw(s){const{workId:e,toolsType:t,postCount:i}=s;e&&t&&this.canUseSubWorkerLayer(t)&&(this.getWorkShape(e.toString())||this.createLocalWork(s));const o=e==null?void 0:e.toString(),n=o&&this.workShapes.get(o);if(!n)return;n.consume({data:s,drawCount:this.subWorkerDrawCount,isFullWork:!1,isSubWorker:!0}),this.subWorkerDrawCount++;const r=this.thread.manager.master;r.setSubWorkerDrawCount(this.subWorkerDrawCount);const c=Math.max(r.getMaxDrawCount(),this.subWorkerDrawCount);r.setMaxDrawCount(c),D.isNumber(i)&&r.setConsumeCount(i)}removeNode(s){const{workId:e}=s,t=e==null?void 0:e.toString();t&&this.workShapes.has(t)&&(this.thread.subLocalLayer.getElementsByName(t).forEach(o=>{o.remove()}),this.clearWorkShapeNodeCache(t))}createLocalWork(s){const{workId:e,toolsType:t,opt:i}=s,o=e==null?void 0:e.toString();t&&this.canUseSubWorkerLayer(t)&&o&&i&&(this.getToolsOpt()||this.setToolsOpt({toolsType:t,toolsOpt:i}),this.setWorkOptions(o,i))}setWorkOptions(s,e){let t=this.workShapes.get(s);if(!t&&this.tmpOpt){const{toolsType:i}=this.tmpOpt;this.tmpOpt.toolsOpt=e,t=this.createWorkShapeNode({workId:s,toolsType:i,toolsOpt:e}),t&&this.workShapes.set(s,t),this.setToolsOpt(this.tmpOpt)}e!=null&&e.syncUnitTime||(e.syncUnitTime=this.syncUnitTime),t&&t.setWorkOptions(e)}destroy(){this.clearAll()}clearAll(){this.thread.subLocalLayer.removeAllChildren(),this.workShapes.clear()}canUseSubWorkerLayer(s){return s===I.Pencil}setToolsOpt(s){var e;this.tmpOpt=s,(e=s.toolsOpt)!=null&&e.syncUnitTime&&(this.syncUnitTime=s.toolsOpt.syncUnitTime)}createWorkShapeNode(s){return ps({...s,fullLayer:this.thread.subLocalLayer,drawLayer:this.thread.subLocalLayer})}clearWorkShapeNodeCache(s){this.workShapes.delete(s)}getWorkShape(s){return this.workShapes.get(s)}}const UM=async(a,s)=>{const{src:e,isgl:t,isCache:i}=a;if(typeof Image=="function"){const o=new Image;return typeof e=="string"&&(o.crossOrigin="anonymous"),new Promise(n=>{o.onload=function(){createImageBitmap(o,{imageOrientation:t?"flipY":"none"}).then(r=>{n(r)})},o.onerror=function(){n(void 0)},o.src=e})}else return fetch(e,{method:"GET",mode:"cors",cache:"default"}).then(o=>o.blob()).then(o=>createImageBitmap(o,{imageOrientation:t?"flipY":"none"}).then(n=>n))};class BM{constructor(){y(this,"maxLastSyncTime",be.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 FM extends BM{constructor(e){var o,n;super();y(this,"isActive",!1);y(this,"currentToolsData");y(this,"currentLocalWorkData");y(this,"control");y(this,"internalMsgEmitter");y(this,"taskBatchData",new Set);y(this,"fullWorker");y(this,"subWorker");y(this,"fullWorkerUrl");y(this,"subWorkerUrl");y(this,"methodBuilder");y(this,"zIndexNodeMethod");y(this,"subWorkerDrawCount",0);y(this,"fullWorkerDrawCount",0);y(this,"maxDrawCount",0);y(this,"_consumeCount",0);y(this,"_postCount",0);y(this,"reRenders",new Map);y(this,"localWorkViewId");y(this,"localPointsBatchData",new Map);y(this,"tasksqueue",new Map);y(this,"useTasksqueue",!1);y(this,"useTasksClockId");y(this,"mainTasksqueueCount");y(this,"workerTasksqueueCount");y(this,"snapshotMap",new Map);y(this,"boundingRectMap",new Map);y(this,"clearAllResolveMap",new Map);y(this,"delayWorkStateToDoneResolve");y(this,"animationId");y(this,"tmpImageConfigMap",new Map);y(this,"mainThread");y(this,"willSelectorWorkId");y(this,"isLockSentEventCursor",!1);y(this,"subMainThreadWorker");y(this,"getVNodeInfoResolveMap",new Map);const{control:t,internalMsgEmitter:i}=e;this.control=t,this.maxLastSyncTime=((n=(o=this.control.pluginOptions)==null?void 0:o.syncOpt)==null?void 0:n.interval)||this.maxLastSyncTime,this.fullWorkerUrl=this.control.pluginOptions.cdn.fullWorkerUrl,this.subWorkerUrl=this.control.pluginOptions.cdn.subWorkerUrl,this.internalMsgEmitter=i,this.currentLocalWorkData={workState:P.Pending}}destroy(){var e,t,i;(e=this.methodBuilder)==null||e.destroy(),this.unWritable(),this.taskBatchData.clear(),this.tasksqueue.clear(),this.tmpImageConfigMap.clear(),this.localPointsBatchData.clear(),this.isActive=!1,this.clearAllResolveMap.clear(),this.snapshotMap.clear(),this.boundingRectMap.clear(),(t=this.fullWorker)==null||t.terminate(),(i=this.subWorker)==null||i.terminate()}get consumeCount(){return this._consumeCount}set consumeCount(e){this._consumeCount=e}get postCount(){return this._postCount}set postCount(e){this._postCount=e}get viewContainerManager(){return this.control.viewContainerManager}get collector(){return this.control.collector}get isRunSubWork(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===I.Pencil||e===I.BitMapEraser||e===I.LaserPen||e===I.Arrow||e===I.Straight||e===I.Ellipse||e===I.Rectangle||e===I.Star||e===I.Polygon||e===I.SpeechBalloon}get isCanDrawWork(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===I.Pencil||e===I.LaserPen||e===I.Arrow||e===I.Straight||e===I.Ellipse||e===I.Rectangle||e===I.Star||e===I.Polygon||e===I.SpeechBalloon||e===I.Triangle||e===I.Rhombus||e===I.BitMapEraser}get isUseZIndex(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===I.Pencil||e===I.Arrow||e===I.Straight||e===I.Ellipse||e===I.Rectangle||e===I.Star||e===I.Polygon||e===I.SpeechBalloon||e===I.Text||e===I.Image}get isCanRecordUndoRedo(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===I.Pencil||e===I.Eraser||e===I.BitMapEraser||e===I.Arrow||e===I.Straight||e===I.Ellipse||e===I.Rectangle||e===I.Star||e===I.Polygon||e===I.SpeechBalloon||e===I.Text||e===I.Image}get isCanSentCursor(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===I.Pencil||e===I.Text||e===I.LaserPen||e===I.Arrow||e===I.Straight||e===I.Ellipse||e===I.Rectangle||e===I.Star||e===I.Polygon||e===I.SpeechBalloon||e===I.Triangle||e===I.Rhombus||e===I.Eraser||e===I.PencilEraser||e===I.BitMapEraser}get isPostCountType(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===I.Pencil||e===I.Arrow||e===I.Straight||e===I.Ellipse||e===I.Rectangle||e===I.Star||e===I.Polygon||e===I.SpeechBalloon||e===I.Triangle||e===I.Rhombus||e===I.Eraser||e===I.PencilEraser||e===I.BitMapEraser}get isCanPostDraw(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===I.Pencil||e===I.BitMapEraser}get isCanStartEventConsum(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===I.Selector||e===I.Eraser||e===I.PencilEraser||e===I.BitMapEraser}async init(){this.destroy(),await this.on(),this.internalMsgEmitterListener(),this.isActive=!0}async useMainThread(){console.info("no OffscreenCanvas");const{MainThreadManagerImpl:e}=await Promise.resolve().then(()=>require("./index-Dob0H3xr.js"));this.mainThread=new e(this)}async on(){if(!this.control.hasOffscreenCanvas()){await this.useMainThread();return}if(!this.fullWorkerUrl||!this.subWorkerUrl){console.error("no worker url config");return}this.fullWorker=new Worker(this.fullWorkerUrl,{type:"classic"}),this.subWorker=new Worker(this.subWorkerUrl,{type:"classic"}),this.subMainThreadWorker=new RM(this),this.fullWorker.onmessage=e=>{var t,i;if(e.data){const{render:o,sp:n,fullWorkerDrawCount:r,workerTasksqueueCount:c,viewId:l,consumeCount:h}=e.data;h&&(this.consumeCount=h),this.isBusy&&c&&this.setWorkerTasksqueueCount(c),n!=null&&n.length&&this.collectorSyncData(n);const u=(o==null?void 0:o.length)&&o||[];if(r&&l){if(this.fullWorkerDrawCount=r,this.fullWorkerDrawCount<1/0){const d=Math.max(this.maxDrawCount,this.fullWorkerDrawCount);this.setMaxDrawCount(d),this.control.priority==="ui"?(t=this.subMainThreadWorker)==null||t.notifyDrawCount(l):this.clearReRenders(this.fullWorkerDrawCount)}else this.setMaxDrawCount(0),this.control.priority==="ui"?(i=this.subMainThreadWorker)==null||i.clearDrawCount(l):this.clearReRenders(1/0);if(this.reRenders.size)for(const d of this.reRenders.values())u.push(...d)}u.length&&this.viewContainerManager.render(u)}},this.subWorker.onmessage=e=>{if(e.data){const{render:t,sp:i,subWorkerDrawCount:o,consumeCount:n}=e.data;n&&(this.consumeCount=n),i!=null&&i.length&&this.collectorSyncData(i);const r=(t==null?void 0:t.length)&&t||[];if(this.control.priority==="cpu"&&D.isNumber(o)){if(this.subWorkerDrawCount=o,this.fullWorkerDrawCount<1/0){const c=Math.max(this.maxDrawCount,this.subWorkerDrawCount);this.setMaxDrawCount(c)}if(t!=null&&t.length)if(this.subWorkerDrawCount>this.fullWorkerDrawCount){const c=[];for(const l of t)l.imageBitmap&&(l.isUnClose=!0,c.push(l));this.reRenders.set(this.subWorkerDrawCount,c)}else this.reRenders.size&&this.clearReRenders(this.subWorkerDrawCount)}r.length&&this.viewContainerManager.render(r)}}}clearReRenders(e=1/0){for(const t of this.reRenders.keys())if(D.isNumber(Number(t))&&Number(t)<=e){const i=this.reRenders.get(Number(t));i==null||i.forEach(o=>{var n;(n=o.imageBitmap)==null||n.close()}),this.reRenders.delete(t)}}get isBusy(){return this.getTasksqueueState()===P.Doing}getLockSentEventCursor(){return this.isLockSentEventCursor}setLockSentEventCursor(e){this.isLockSentEventCursor=e}getTasksqueueState(){return this.useTasksqueue&&P.Doing||P.Done}setMaxDrawCount(e){this.maxDrawCount=e}getFullWorkDrawCount(){return this.fullWorkerDrawCount}getMaxDrawCount(){return this.maxDrawCount}setSubWorkerDrawCount(e){this.subWorkerDrawCount=e}setConsumeCount(e){this.consumeCount=e}setWorkerTasksqueueCount(e){const t=Math.max(this.workerTasksqueueCount||0,e);this.workerTasksqueueCount=t}collectorSyncData(e){var i,o,n,r;let t=!1;for(const c of e){const{type:l,selectIds:h,opt:u,selectRect:d,strokeColor:f,fillColor:g,willSyncService:p,isSync:m,imageBitmap:N,canvasHeight:v,canvasWidth:T,rect:k,op:S,canTextEdit:w,points:C,selectorColor:L,canRotate:j,scaleType:E,textOpt:A,toolsType:W,workId:z,viewId:O,dataType:se,canLock:_,isLocked:H,shapeOpt:X,toolsTypes:G,thickness:Z,strokeType:K,useStroke:ae,isgl:Te,imageSrc:ie,isSubWorker:he}=c;if(!O)return;const J=c.scenePath||this.viewContainerManager.getCurScenePath(O);switch(l){case x.Select:{const $=h!=null&&h.length?{...d,selectIds:h,canvasHeight:v,canvasWidth:T,points:C}:void 0;$&&(u!=null&&u.strokeColor)&&($.selectorColor=u.strokeColor),$&&L&&($.selectorColor=L),$&&f&&($.strokeColor=f),$&&(u!=null&&u.fillColor)&&($.fillColor=u.fillColor),$&&g&&($.fillColor=g),$&&D.isBoolean(j)&&($.canRotate=j),$&&E&&($.scaleType=E),$&&w&&($.canTextEdit=w),$&&A&&($.textOpt=A),$&&D.isBoolean(_)&&($.canLock=_),$&&D.isBoolean(H)&&($.isLocked=H),$&&X&&($.shapeOpt=X),$&&G&&($.toolsTypes=G),$&&Z&&($.thickness=Z),$&&K&&($.strokeType=K),$&&D.isBoolean(ae)&&($.useStroke=ae),O&&this.viewContainerManager.showFloatBar(O,!!$,$),p&&((i=this.collector)==null||i.dispatch({type:l,selectIds:h,opt:u,isSync:m,viewId:O,scenePath:J}));break}case x.Snapshot:if(N&&J){const $=this.snapshotMap.get(J);$&&$(N)}break;case x.BoundingBox:if(k&&J){const $=this.boundingRectMap.get(J);$&&$(k)}break;case x.Cursor:S&&this.control.cursor.collectServiceCursor({...c});break;case x.Clear:if(O){this.viewContainerManager.showFloatBar(O,!1);const $=(o=this.clearAllResolveMap.get(O))==null?void 0:o.resolve;$&&$(O)}break;case x.TextUpdate:if(W===I.Text&&z&&O){const $=this.viewContainerManager.transformToOriginPoint((u==null?void 0:u.boxPoint)||[0,0],O),ue=(u==null?void 0:u.boxSize)||[0,0],fe=(n=this.viewContainerManager.getView(O))==null?void 0:n.cameraOpt;u?this.control.textEditorManager.updateTextForWorker({x:$[0],y:$[1],w:ue[0],h:ue[1],scale:(fe==null?void 0:fe.scale)||1,workId:z,opt:u,dataType:se,viewId:O,canSync:p||!1,canWorker:!1}):this.control.textEditorManager.delete(z,p||!1,!1)}break;case x.GetTextActive:W===I.Text&&z&&O&&this.control.textEditorManager.updateTextForWorker({workId:z,isActive:!0,viewId:O,dataType:B.Local,canWorker:!1,canSync:!0},Date.now());break;case x.GetImageBitMap:ie&&O&&z&&UM({src:ie,isgl:Te}).then($=>{var fe;const ue=new Set;if(ue.add({msgType:x.GetImageBitMap,dataType:B.Local,workId:z,viewId:O,imageSrc:ie,isSubWorker:he,imageBitmap:$}),!this.control.hasOffscreenCanvas())(fe=this.mainThread)==null||fe.consume(ue);else{const Oe=he?this.subWorker:this.fullWorker;$?Oe.postMessage(ue,[$]):Oe.postMessage(ue)}});break;case x.GetVNodeInfo:if(z){const $=z.toString(),ue=(r=this.getVNodeInfoResolveMap.get($))==null?void 0:r.resolve,fe={...c,uuid:$};ue&&ue(fe)}break;default:t=!0;break}}t&&Ue(()=>{this.collectorAsyncData(e)},this.maxLastSyncTime)}collectorAsyncData(e){var t,i,o,n;for(const r of e){const{type:c,op:l,workId:h,index:u,removeIds:d,ops:f,opt:g,updateNodeOpt:p,toolsType:m,isSync:N,viewId:v,isLockSentEventCursor:T,nextTasks:k}=r;if(!v){console.error("collectorAsyncData",r);return}const S=r.scenePath||this.viewContainerManager.getCurScenePath(v);switch(c){case x.None:{T&&Ue(()=>{this.setLockSentEventCursor(!1)},this.maxLastSyncTime);break}case x.DrawWork:{(t=this.collector)==null||t.dispatch({type:c,op:l,opt:g,toolsType:m,workId:h,index:u,isSync:N,viewId:v,scenePath:S,updateNodeOpt:p});break}case x.FullWork:{(i=this.collector)==null||i.dispatch({type:c,ops:f,workId:h,updateNodeOpt:p,opt:g,toolsType:m,isSync:N,viewId:v,scenePath:S}),this.willSelectorWorkId&&h&&h.toString()===this.willSelectorWorkId&&this.control.runEffectWork(()=>{this.setShapeSelectorByWorkId(this.willSelectorWorkId,v),this.willSelectorWorkId=void 0});break}case x.UpdateNode:{(o=this.collector)==null||o.dispatch({type:c,updateNodeOpt:p,workId:h,opt:g,ops:f,op:l,isSync:N,viewId:v,scenePath:S});break}case x.RemoveNode:{d&&this.control.textEditorManager.deleteBatch(d,!1,!1),(n=this.collector)==null||n.dispatch({type:c,removeIds:d,isSync:N,viewId:v,scenePath:S}),this.willSelectorWorkId&&(d!=null&&d.includes(this.willSelectorWorkId))&&(this.willSelectorWorkId=void 0);break}}k&&Ue(()=>{this.collectorAsyncData(k)},this.maxLastSyncTime)}}async onLocalEventEnd(e,t){var l;const i=this.viewContainerManager.getView(t);if(!i)return;const{focusScenePath:o,cameraOpt:n}=i,r=this.viewContainerManager.transformToScenePoint(e,t),c=[];for(const h of this.localPointsBatchData.keys())if(((l=this.currentToolsData)==null?void 0:l.toolsType)===I.Text){const u=this.getLocalPointInfo(h),d=u==null?void 0:u.state;if(d&&d===P.Start){const f=this.currentLocalWorkData.toolsOpt;f.workState=P.Doing,f.boxPoint=r,f.boxSize=[f.fontSize,f.fontSize],this.control.textEditorManager.checkEmptyTextBlur(),this.control.textEditorManager.createTextForMasterController({workId:Date.now().toString(),x:e[0],y:e[1],scale:(n==null?void 0:n.scale)||1,opt:f,type:Ze.Text,isActive:!0,viewId:t,scenePath:o},Date.now())}this.deleteLocalPoint(h);continue}else this.pushLocalPoint(h,r,P.Done,t),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(e,t){var o;if(((o=this.currentToolsData)==null?void 0:o.toolsType)===I.Text)return;this.currentLocalWorkData.workState===P.Start&&this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:P.Doing});let i=!1;for(const[n,{state:r}]of this.localPointsBatchData.entries())if(this.isAbled()&&r!==P.Pending){const c=this.viewContainerManager.transformToScenePoint(e,t);this.pushLocalPoint(n,c,r===P.Start?P.Doing:r,t),i=!0}if(i){this.runAnimation();return}this.useTasksqueue||this.hoverCursor(e,t)}onLocalEventStart(e,t){var c,l,h;this.viewContainerManager.focuedViewId!==t&&this.viewContainerManager.setFocuedViewId(t),this.isCanDrawWork&&this.control.room&&!this.control.room.disableDeviceInputs&&(this.control.room.disableDeviceInputs=!0);const i=(c=this.currentToolsData)==null?void 0:c.toolsType,o=i===I.Selector?Q:Date.now(),n=this.setZIndex(t);this.setCurrentLocalWorkData({workState:P.Start,toolsOpt:n,viewId:t});const r=this.viewContainerManager.transformToScenePoint(e,t);if(this.pushLocalPoint(o,r,P.Start,t,n),i!==I.Text){if(this.control.textEditorManager.checkEmptyTextBlur(),this.isCanRecordUndoRedo&&this.internalMsgEmitter.emit("addUndoTicker",o,t),o&&n&&i&&this.isCanStartEventConsum&&this.prepareOnceWork({workId:o,toolsOpt:n,viewId:t},i),this.consumeCount=0,this.postCount=0,this.maxDrawCount=0,this.fullWorkerDrawCount=0,this.subWorkerDrawCount=0,this.clearReRenders(1/0),(l=this.subMainThreadWorker)==null||l.clearDrawCount(t),this.isCanDrawWork){const u=this.viewContainerManager.getCurScenePath(t);u&&((h=this.collector)!=null&&h.hasSelector(t,u))&&this.blurSelector(t,u)}this.consume()}}setLocalPointIsFullWork(e){const t=this.getLocalPointInfo(e);t&&(t.isFullWork=!0,this.localPointsBatchData.set(e,t))}pushLocalPoint(e,t,i,o,n){let r=this.getLocalPointInfo(e);i===P.Start?r={state:P.Start,points:t,opt:n||this.currentLocalWorkData.toolsOpt,isFullWork:!1,viewId:o}:r&&(r.state=i,r.points.push(t[0],t[1])),r&&this.localPointsBatchData.set(e,r)}deleteLocalPoint(e){this.localPointsBatchData.delete(e)}getLocalPointInfo(e){return this.localPointsBatchData.get(e)}getLocalPointsInfo(){return this.localPointsBatchData}correctStorage(e,t,i){var c;const o=new Map,n=[];Object.keys(e).forEach(l=>{var u,d;const h=(d=(u=e[l])==null?void 0:u.opt)==null?void 0:d.zIndex;D.isNumber(h)&&n.push([l,h])});const r=n.length&&((c=this.zIndexNodeMethod)==null?void 0:c.correct(n))||[];this.zIndexNodeMethod&&r.length&&(this.zIndexNodeMethod.setMinZIndex(r[0][1]||0,t),this.zIndexNodeMethod.setMaxZIndex(r[r.length-1][1]||0,t));for(const[l,h]of r){if(!e[l])continue;const u=e[l];u.opt&&D.isNumber(u.opt.zIndex)&&u.opt.zIndex!==h&&(u.opt.zIndex=h,o.set(l,u))}return o.size&&o.forEach((l,h)=>{var u;(u=this.collector)==null||u.updateValue(h,l,{viewId:t,scenePath:i,isSync:!0}),e[h]=l}),e}async originalEventLintener(e,t,i){var r,c;if(!this.isAbled())return;const o=(r=this.collector)==null?void 0:r.uid,n=this.viewContainerManager.getCurScenePath(i);if(!(o&&!this.control.renderControl.isWriteable())){switch((c=this.currentToolsData)==null?void 0:c.toolsType){case I.Eraser:case I.PencilEraser:case I.BitMapEraser:{if(o&&!this.control.renderControl.isClearAble({uid:o,viewId:i,scenePath:n}))return;break}default:{if(o&&!this.control.renderControl.isRenderAble({uid:o,viewId:i,scenePath:n}))return;break}}switch(Ue(()=>{this.control.pluginManager.dispatchPluginEvent("localEvent",i,e,t)},fs),e){case P.Start:this.setLocalWorkViewId(i),i&&this.onLocalEventStart(t,i);break;case P.Doing:i&&i===this.getLocalWorkViewId()&&this.onLocalEventDoing(t,i);break;case P.Done:i&&i===this.getLocalWorkViewId()&&await this.onLocalEventEnd(t,i);break}}}getLocalWorkViewId(){return this.localWorkViewId}setLocalWorkViewId(e){this.localWorkViewId=e}setCurrentToolsData(e){var o,n,r;const t=e.toolsType,i=((o=this.currentToolsData)==null?void 0:o.toolsType)!==e.toolsType;if(super.setCurrentToolsData(e),i){const c=(n=this.viewContainerManager)==null?void 0:n.getAllViews();for(const l of c)if(l){const{id:h,focusScenePath:u}=l;i&&h&&u&&((r=this.collector)!=null&&r.hasSelector(h,u)&&this.blurSelector(h,u),this.control.textEditorManager.checkEmptyTextBlur())}this.taskBatchData.add({msgType:x.UpdateTools,dataType:B.Local,toolsType:t,opt:{...e.toolsOpt,syncUnitTime:this.maxLastSyncTime},isRunSubWork:this.isRunSubWork,viewId:Qt}),this.runAnimation()}}prepareOnceWork(e,t){const{workId:i,toolsOpt:o,viewId:n}=e,r={msgType:x.CreateWork,dataType:B.Local,viewId:n,toolsType:t};this.queryTaskBatchData(r).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({...r,workId:i,opt:{...o,syncUnitTime:this.maxLastSyncTime},dataType:B.Local,isRunSubWork:this.isRunSubWork}),this.runAnimation()}createViewWorker(e,t){const{offscreenCanvasOpt:i,layerOpt:o,dpr:n,cameraOpt:r}=t;this.taskBatchData.add({msgType:x.Init,dataType:B.Local,viewId:e,offscreenCanvasOpt:i,layerOpt:o,dpr:n,cameraOpt:r,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1}),this.isBusy&&this.destroyTaskQueue(),this.consume()}destroyViewWorker(e,t=!1){var i;this.getLocalWorkViewId()===e&&this.setLocalWorkViewId(void 0),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(e),this.taskBatchData.add({msgType:x.Destroy,dataType:B.Local,viewId:e,isRunSubWork:!0}),this.consume(),t||(i=this.collector)==null||i.dispatch({type:x.Clear,viewId:e}),this.control.renderControl.destoryByViewId(e,t)}onServiceDerive(e,t){var f,g,p,m,N;const{newValue:i,oldValue:o,viewId:n,scenePath:r}=t,c=D.cloneDeep(i)||{},l=e;let h=c.type;if(!i&&o){if(l&&((f=this.collector)==null?void 0:f.getLocalId(l))===Q){this.collector.isOwn(l)?this.blurSelector(n,r):this.blurSelector(n,r,l);return}if(h=x.RemoveNode,o.toolsType===I.LaserPen)return}const u=(g=this.viewContainerManager.getView(n))==null?void 0:g.focusScenePath;if(u&&u!==r)return;if(h&&l){if(!this.control.renderControl.isFilterAble({viewId:n,elementId:e,scenePath:r},h))return;const v=c;if(v.workId=(p=this.collector)!=null&&p.isOwn(l)?(m=this.collector)==null?void 0:m.getLocalId(l):l,v.msgType=h,v.toolsType===I.LaserPen&&(v.isRunSubWork=!0),v.dataType=B.Service,v.viewId=n,v.scenePath=r,v.selectIds&&(v.selectIds=v.selectIds.map(T=>{var k,S;return(k=this.collector)!=null&&k.isOwn(T)?(S=this.collector)==null?void 0:S.getLocalId(T):T})),v&&v.toolsType===I.Text||(o==null?void 0:o.toolsType)===I.Text){this.control.textEditorManager.onServiceDerive(v);return}this.taskBatchData.add(v)}this.runAnimation();const d=t.newValue&&((N=t.newValue.opt)==null?void 0:N.zIndex);if(this.zIndexNodeMethod&&D.isNumber(d)){const v=this.zIndexNodeMethod.getMinZIndex(n);this.zIndexNodeMethod.getMaxZIndex(n)<d&&this.zIndexNodeMethod.setMaxZIndex(d,n),v>d&&this.zIndexNodeMethod.setMinZIndex(d,n)}}pullServiceData(e,t,i={isAsync:!1,useAnimation:!1}){var c,l,h,u;let o=(c=this.collector)==null?void 0:c.getStorageData(e,t);const{isAsync:n,useAnimation:r}=i;if(o){this.control.renderControl.isWriteable()&&(o=this.correctStorage(o,e,t));const d=Object.keys(o);for(const f of d){const g=(l=o[f])==null?void 0:l.type;if(g&&f){if(!this.control.renderControl.isFilterAble({viewId:e,elementId:f,scenePath:t},g))continue;const p=o[f];if(p.workId=(h=this.collector)!=null&&h.isOwn(f)?(u=this.collector)==null?void 0:u.getLocalId(f):f,p.msgType=g,p.dataType=B.Service,p.viewId=e,p.scenePath=t,p.useAnimation=!!r,p.selectIds&&(p.selectIds=p.selectIds.map(m=>{var N,v;return(N=this.collector)!=null&&N.isOwn(m)?(v=this.collector)==null?void 0:v.getLocalId(m):m})),p.toolsType===I.Text){this.control.textEditorManager.onServiceDerive(p);continue}this.taskBatchData.add(p)}this.internalMsgEmitter.emit("excludeIds",d,e)}n?this.consume():this.runAnimation()}}runAnimation(){!this.animationId&&!this.isBusy&&(this.animationId=requestAnimationFrame(this.consume.bind(this)))}consume(){var t;this.animationId=void 0;const{viewId:e}=this.currentLocalWorkData;if(this.tasksqueue.size){const i=this.consumeQueue(),o=!!i.size;if(this.taskBatchData.size)for(const n of this.taskBatchData.values())n.dataType===B.Service&&(i.add(n),this.taskBatchData.delete(n));i.size?(this.post(i),o&&this.tasksqueue.clear()):this.tasksqueue.size&&(this.animationId=requestAnimationFrame(this.consume.bind(this)));return}if(this.isAbled()&&this.localPointsBatchData.size&&e)for(const[i,{state:o,isFullWork:n,points:r,opt:c}]of this.localPointsBatchData.entries()){if(o===P.Done&&!n||o===P.Start&&!this.isCanStartEventConsum)continue;const l=r.map(h=>h);if(l.length){if(this.isPostCountType&&o===P.Doing){if(this.postCount>this.consumeCount)continue;this.postCount++}this.delayWorkStateToDoneResolve&&o===P.Done&&(this.delayWorkStateToDoneResolve(!0),this.setLockSentEventCursor(!0)),this.taskBatchData.add({op:l,workState:o,workId:i,dataType:B.Local,msgType:x.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(t=this.currentToolsData)==null?void 0:t.toolsType,viewId:e,scenePath:e&&this.viewContainerManager.getCurScenePath(e),opt:c,isLockSentEventCursor:this.getLockSentEventCursor(),syncUnitTime:this.maxLastSyncTime,disableEraseImage:this.control.disableEraseImage,disableEraseText:this.control.disableEraseText,postCount:this.isPostCountType&&this.postCount||void 0,fullWorkerDrawCount:this.isCanPostDraw&&this.fullWorkerDrawCount||void 0}),r.length=0}}this.taskBatchData.size&&(this.post(this.taskBatchData),this.taskBatchData.clear()),this.taskBatchData.size&&(this.animationId=requestAnimationFrame(this.consume.bind(this)))}unWritable(){this.setCurrentLocalWorkData({workState:P.Unwritable,workId:void 0})}abled(){this.setCurrentLocalWorkData({workState:P.Pending,workId:void 0})}isAbled(){return this.currentLocalWorkData.workState!==P.Unwritable}post(e){var i;if(!this.control.hasOffscreenCanvas()){if(!this.mainThread){let o=[];o=D.cloneDeep([...e]),setTimeout(()=>{for(const n of o)this.taskBatchData.add(n)},0);return}this.mainThread.consume(e);return}this.fullWorker.postMessage(e);const t=new Set;for(const o of e.values()){const n=o.msgType;(n===x.Init||n===x.Clear||n===x.Destroy||n===x.UpdateCamera||o.isRunSubWork)&&t.add(o)}t.size&&(this.subWorker.postMessage(t),this.control.priority==="ui"&&((i=this.subMainThreadWorker)==null||i.consume(t)))}updateNode(e,t,i,o){this.taskBatchData.add({msgType:x.UpdateNode,workId:e,updateNodeOpt:t,viewId:i,scenePath:o,dataType:B.Local}),this.runAnimation()}destroyTaskQueue(){this.useTasksqueue=!1,this.useTasksClockId&&(clearTimeout(this.useTasksClockId),this.useTasksClockId=void 0),this.mainTasksqueueCount=void 0,this.workerTasksqueueCount=void 0}updateDpr(e,t){this.queryTaskBatchData({msgType:x.UpdateDpr,dataType:B.Local,viewId:e}).forEach(i=>{this.taskBatchData.delete(i)}),this.taskBatchData.add({dataType:B.Local,msgType:x.UpdateDpr,viewId:e,dpr:t,isRunSubWork:!0}),this.runAnimation()}updateCamera(e,t){var i;this.useTasksqueue||((i=this.methodBuilder)==null||i.pause(),this.blurCursor(e),this.checkDrawingWork(e),this.useTasksqueue=!0,this.mainTasksqueueCount=1,this.workerTasksqueueCount=1),this.useTasksqueue&&(this.tasksqueue.set(e,{msgType:x.UpdateCamera,dataType:B.Local,cameraOpt:{...t,width:t.width,height:t.height},scenePath:this.viewContainerManager.getCurScenePath(e),isRunSubWork:!0,viewId:e}),this.consume(),this.useTasksClockId&&clearTimeout(this.useTasksClockId),this.updateCameraDone())}updateCameraDone(){this.useTasksClockId=setTimeout(()=>{var e,t;this.useTasksClockId=void 0,this.mainTasksqueueCount===this.workerTasksqueueCount?(this.tasksqueue.size&&this.consume(),this.useTasksqueue=!1,this.mainTasksqueueCount=void 0,this.workerTasksqueueCount=void 0,this.control.priority==="ui"&&((e=this.subMainThreadWorker)==null||e.updateCamera()),(t=this.methodBuilder)==null||t.recover(),this.runAnimation()):this.updateCameraDone()},this.maxLastSyncTime)}consumeQueue(){const e=new Set;let t=!this.isBusy;if(this.isBusy&&this.mainTasksqueueCount&&this.workerTasksqueueCount&&this.mainTasksqueueCount<=this.workerTasksqueueCount&&(t=!0),t){this.mainTasksqueueCount&&this.workerTasksqueueCount&&this.mainTasksqueueCount++,e.add({msgType:x.TasksQueue,dataType:B.Local,isRunSubWork:!0,mainTasksqueueCount:this.mainTasksqueueCount,tasksqueue:this.tasksqueue,viewId:""});for(const[i,o]of this.tasksqueue.entries())o.cameraOpt&&this.control.textEditorManager.onCameraChange(o.cameraOpt,i)}return e}async clearViewScenePath(e,t,i){var n,r;const o=this.viewContainerManager.getCurScenePath(e);if(i){const c=(n=this.collector)==null?void 0:n.uid;if(c&&!this.control.renderControl.isClearAble({uid:c,viewId:e,scenePath:o}))return}this.control.textEditorManager.clear(e,t),this.queryTaskBatchData({msgType:x.Clear,dataType:B.Local,viewId:e}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({dataType:B.Local,msgType:x.Clear,viewId:e}),this.runAnimation(),t||(this.control.renderControl.isUsePageAuth(e)&&o?this.control.renderControl.clearRenderPage(e,o):(r=this.collector)==null||r.dispatch({type:x.Clear,viewId:e,scenePath:o})),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(e),this.localPointsBatchData.clear(),await new Promise(c=>{const l=this.clearAllResolveMap.get(e)||{resolve:void 0,timer:void 0};l.timer&&clearTimeout(l.timer),l.resolve=c,l.timer=setTimeout(()=>{const h=this.clearAllResolveMap.get(e);h!=null&&h.resolve&&h.resolve(e)},this.maxLastSyncTime),this.clearAllResolveMap.set(e,l)}).then(c=>{this.clearAllResolveMap.delete(c)})}internalMsgEmitterListener(){var e;this.methodBuilder=new oe([F.CopyNode,F.SetColorNode,F.DeleteNode,F.RotateNode,F.ScaleNode,F.TranslateNode,F.ZIndexNode,F.SetFontStyle,F.SetPoint,F.SetLock,F.SetShapeOpt]).registerForMainEngine(te.MainEngine,this.control),this.zIndexNodeMethod=(e=this.methodBuilder)==null?void 0:e.getBuilder(F.ZIndexNode)}setZIndex(e){const t=this.currentToolsData&&D.cloneDeep(this.currentToolsData.toolsOpt);return t&&this.zIndexNodeMethod&&this.isUseZIndex&&(this.zIndexNodeMethod.addMaxLayer(e),t.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),t}checkDrawingWork(e){var o,n,r;let t=!1;const i=[];for(const[c,{state:l,viewId:h,points:u,opt:d}]of this.localPointsBatchData.entries())if(e===h&&l===P.Start||l===P.Doing){if(l===P.Doing&&this.isCanDrawWork){Number(c)&&Number(c)+60>Date.now()&&(i.push(c.toString()),this.taskBatchData.add({msgType:x.RemoveNode,workId:c,viewId:h,dataType:B.Local,isRunSubWork:!0}));const f=u.map(g=>g);this.taskBatchData.add({op:f,workState:P.Done,workId:c,dataType:B.Local,msgType:x.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(o=this.currentToolsData)==null?void 0:o.toolsType,viewId:h,opt:d,scenePath:h&&this.viewContainerManager.getCurScenePath(h)}),t=!0}this.deleteLocalPoint(c)}if((t||i.length)&&(this.consume(),i.length)){const c=(n=this.viewContainerManager.getView(e))==null?void 0:n.focusScenePath;(r=this.collector)==null||r.dispatch({type:x.RemoveNode,removeIds:i,viewId:e,scenePath:c})}}removeDrawingWork(e){var i,o;const t=[];for(const[n,{state:r,viewId:c}]of this.localPointsBatchData.entries())(e===c&&r===P.Start||r===P.Doing)&&(this.deleteLocalPoint(n),r===P.Doing&&this.isCanDrawWork&&(t.push(n.toString()),this.taskBatchData.add({msgType:x.RemoveNode,workId:n,viewId:c,dataType:B.Local,isRunSubWork:!0})));if(t.length){this.consume();const n=(i=this.viewContainerManager.getView(e))==null?void 0:i.focusScenePath;(o=this.collector)==null||o.dispatch({type:x.RemoveNode,removeIds:t,viewId:e,scenePath:n})}}removeNodes(e,t){var o,n;const i=(o=this.viewContainerManager.getView(e))==null?void 0:o.focusScenePath;if(i&&t.length){for(const r of t)this.taskBatchData.add({msgType:x.RemoveNode,workId:r,viewId:e,dataType:B.Local,isRunSubWork:!1});this.consume(),(n=this.collector)==null||n.dispatch({type:x.RemoveNode,removeIds:t,viewId:e,scenePath:i})}}hoverCursor(e,t){var i;if(((i=this.currentToolsData)==null?void 0:i.toolsType)===I.Selector){const o=this.viewContainerManager.getView(t);if(o&&o.displayer&&o.displayer.vDom){const c=o.displayer.vDom.state.floatBarData;if(c){const{x:l,y:h,w:u,h:d}=c;if(Zo(e,{x:l,y:h,w:u,h:d}))return}}const n=this.viewContainerManager.transformToScenePoint(e,t),r={msgType:x.CursorHover,dataType:B.Local,point:n,toolsType:this.currentToolsData.toolsType,opt:this.currentToolsData.toolsOpt,isRunSubWork:!1,viewId:t};this.queryTaskBatchData({msgType:x.CursorHover,dataType:B.Local,toolsType:this.currentToolsData.toolsType,viewId:t}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add(r),this.runAnimation()}}blurCursor(e){var i;if(((i=this.currentToolsData)==null?void 0:i.toolsType)!==I.Selector)return;const t={msgType:x.CursorBlur,dataType:B.Local,isRunSubWork:!1,viewId:e};this.queryTaskBatchData({msgType:x.CursorHover,dataType:B.Local,viewId:e}).forEach(o=>{this.taskBatchData.delete(o)}),this.taskBatchData.add(t),this.consume()}sendCursorEvent(e,t){var r,c;if(!this.currentLocalWorkData||this.currentLocalWorkData.workState===P.Unwritable||!this.currentToolsData||!this.isCanSentCursor)return;const i=(r=this.collector)==null?void 0:r.uid,o=this.viewContainerManager.getCurScenePath(t);switch((c=this.currentToolsData)==null?void 0:c.toolsType){case I.Eraser:case I.PencilEraser:case I.BitMapEraser:{if(i&&!this.control.renderControl.isClearAble({uid:i,viewId:t,filterLocalSelf:!1,scenePath:o}))return;break}default:if(i&&!this.control.renderControl.isWriteable()||i&&!this.control.renderControl.isRenderAble({uid:i,viewId:t,filterLocalSelf:!1,scenePath:o}))return;break}let n=[void 0,void 0];this.currentToolsData&&this.isCanSentCursor&&!this.localPointsBatchData.size&&!this.getLockSentEventCursor()&&(n=e,this.control.cursor.sendEvent(n,t))}getBoundingRect(e){var i,o;if(!((i=this.boundingRectMap)==null?void 0:i.get(e))){const n=(o=this.collector)==null?void 0:o.getScenePathData(e);if(!n)return;if(Object.keys(n).forEach(r=>{var c;((c=this.collector)==null?void 0:c.getLocalId(r))===Q&&delete n[r]}),Object.keys(n).length&&this.viewContainerManager.mainView&&this.viewContainerManager.mainView.cameraOpt){const r={msgType:x.BoundingBox,dataType:B.Local,scenePath:e,scenes:n,cameraOpt:{...this.viewContainerManager.mainView.cameraOpt},isRunSubWork:!0,viewId:this.viewContainerManager.mainView.id};return this.taskBatchData.add(r),this.runAnimation(),new Promise(c=>{this.boundingRectMap.set(e,c)}).then(c=>(this.boundingRectMap.delete(e),c))}}}getSnapshot(e,t,i,o){var r,c,l,h,u;if(!((r=this.snapshotMap)==null?void 0:r.get(e))){const d=(c=this.collector)==null?void 0:c.getViewIdBySecenPath(e);if(!d)return;const f=(l=this.collector)==null?void 0:l.getStorageData(d,e);if(!f)return;if(Object.keys(f).forEach(g=>{var p;((p=this.collector)==null?void 0:p.getLocalId(g))===Q&&delete f[g]}),Object.keys(f).length){const g=this.viewContainerManager.mainView;if(!g)return;const p=t||((h=g.cameraOpt)==null?void 0:h.width),m=i||((u=g.cameraOpt)==null?void 0:u.height),N={msgType:x.Snapshot,dataType:B.Local,scenePath:e,scenes:f,w:p,h:m,cameraOpt:o&&{...o,width:p,height:m}||g.cameraOpt,isRunSubWork:!0,viewId:g.id};return this.taskBatchData.add(N),this.runAnimation(),new Promise(v=>{this.snapshotMap.set(e,v)}).then(v=>(this.snapshotMap.delete(e),v))}}}queryTaskBatchData(e){const t=[];if(e)for(const i of this.taskBatchData.values()){let o=!0;for(const[n,r]of Object.entries(e))if(i[n]!==r){o=!1;break}o&&t.push(i)}return t}insertIconify(e,t){var r;const i=this.viewContainerManager.getView(e);if(!i)throw new Error("insertIconify viewId is not exist");if(!t.src)throw new Error("iconify src must be required");if(!/^(http|https):\/\//.test(t.src))throw new Error("iconify src must be http or https");t.strokeColor||(t.strokeColor=(r=this.currentLocalWorkData.toolsOpt)==null?void 0:r.strokeColor);const n=i==null?void 0:i.focusScenePath;if(e&&n){const c=Date.now();Ne.InternalMsgEmitter.emit("addUndoTicker",c,e);const l={...t,type:lt.Iconify};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:x.FullWork,dataType:B.Local,toolsType:I.Image,workId:t.uuid,opt:l,viewId:e,willRefresh:!0,willSyncService:!0}),this.runAnimation()}}insertImage(e,t){const i=this.viewContainerManager.getView(e);if(!i)throw new Error("insertImage viewId is not exist");if(t.src&&!/^(http|https):\/\//.test(t.src))throw new Error("Image src must be http or https");const o=i==null?void 0:i.focusScenePath;if(e&&o){const{src:n,uuid:r}=t;if(r&&!n){this.tmpImageConfigMap.set(r,t);return}const c=Date.now();Ne.InternalMsgEmitter.emit("addUndoTicker",c,e);const l={...t,type:lt.Image};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:x.FullWork,dataType:B.Local,toolsType:I.Image,workId:t.uuid,opt:l,viewId:e,willRefresh:!0,willSyncService:!0}),this.runAnimation()}}lockImage(e,t,i){var r,c;const o=this.viewContainerManager.getView(e);if(!o)throw new Error("insertImage viewId is not exist");const n=o==null?void 0:o.focusScenePath;if(e&&n&&this.collector){const l=this.collector.getStorageData(e,n);if(!l)return;for(const[h,u]of Object.entries(l))if(u&&u.toolsType===I.Image&&u.opt.uuid===t){const d=Date.now();Ne.InternalMsgEmitter.emit("addUndoTicker",d,e);const f=(r=this.collector)!=null&&r.isOwn(h)?(c=this.collector)==null?void 0:c.getLocalId(h):h,g={...u.opt,locked:i,type:lt.Image};this.taskBatchData.add({msgType:x.FullWork,dataType:B.Local,toolsType:I.Image,workId:f,opt:g,viewId:e,willRefresh:!0,willSyncService:!0}),this.runAnimation();return}}}completeImageUpload(e,t,i){const o=this.viewContainerManager.getView(e);if(!o)throw new Error("insertImage viewId is not exist");const n=o==null?void 0:o.focusScenePath;if(e&&n){const r=this.tmpImageConfigMap.get(t);r&&(r.src=i,this.insertImage(e,r),this.tmpImageConfigMap.delete(t));return}}getImagesInformation(e){const t=[];if(this.collector){const i=this.collector.getScenePathData(e);if(!i)return t;for(const o of Object.values(i))if(o&&o.toolsType===I.Image){const n=o.opt;t.push({uuid:n.uuid,centerX:n.centerX,centerY:n.centerY,width:n.width,height:n.height,locked:n.locked,uniformScale:n.uniformScale,crossOrigin:n.crossOrigin})}}return t}setShapeSelectorByWorkId(e,t){this.taskBatchData.add({workId:Q,selectIds:[e],msgType:x.Select,dataType:B.Local,viewId:t,willSyncService:!0}),this.runAnimation()}blurSelector(e,t,i){this.taskBatchData.add({workId:i||Q,selectIds:[],msgType:x.Select,dataType:B.Service,viewId:e,scenePath:t}),this.runAnimation()}consoleWorkerInfo(){this.taskBatchData.add({msgType:x.Console,dataType:B.Local,isRunSubWork:!0,viewId:""}),this.consume()}setPriority(e){var o,n;const t=new Set,i=new Set;if(e==="cpu"&&((o=this.subMainThreadWorker)==null||o.destroy(),t.add({msgType:x.PriorityWorker,viewId:Qt,dataType:B.Local,isRunSubWork:!0})),e==="ui"){t.add({msgType:x.PriorityMainThreadWorker,viewId:Qt,dataType:B.Local,isRunSubWork:!0});const r=this.viewContainerManager.mainView;if(r){const l=this.viewContainerManager.getViewInitData(r.id);if(l){const{offscreenCanvasOpt:h,layerOpt:u,dpr:d,cameraOpt:f}=l;i.add({msgType:x.Init,dataType:B.Local,viewId:r.id,offscreenCanvasOpt:h,layerOpt:u,dpr:d,cameraOpt:f,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1})}}const c=this.viewContainerManager.appViews;for(const l of c.keys()){const h=this.viewContainerManager.getViewInitData(l);if(h){const{offscreenCanvasOpt:u,layerOpt:d,dpr:f,cameraOpt:g}=h;i.add({msgType:x.Init,dataType:B.Local,viewId:l,offscreenCanvasOpt:u,layerOpt:d,dpr:f,cameraOpt:g,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1})}}}t.size&&this.subWorker.postMessage(t),i.size&&((n=this.subMainThreadWorker)==null||n.consume(i))}sendClearUids(e,t){var o,n;const i=new Set;i.add({msgType:x.AuthClear,dataType:B.Local,viewId:e,clearUids:t,localUid:(o=this.collector)==null?void 0:o.uid}),this.control.hasOffscreenCanvas()?this.fullWorker.postMessage(i):(n=this.mainThread)==null||n.consume(i)}async getVNodeInfo(e,t,i){if(!this.getVNodeInfoResolveMap.has(e))return this.taskBatchData.add({msgType:x.GetVNodeInfo,dataType:B.Local,isRunSubWork:!0,viewId:t,workIds:i,workId:e}),this.consume(),await new Promise(o=>{const n=this.getVNodeInfoResolveMap.get(e)||{resolve:void 0,timer:void 0};n.timer&&clearTimeout(n.timer),n.resolve=o,n.timer=setTimeout(()=>{const r=this.getVNodeInfoResolveMap.get(e);r!=null&&r.resolve&&r.resolve({uuid:e})},this.maxLastSyncTime*5),this.getVNodeInfoResolveMap.set(e,n)}).then(o=>{const{uuid:n}=o;return this.getVNodeInfoResolveMap.delete(n),o})}}class VM{constructor(s){y(this,"internalMsgEmitter");y(this,"control");y(this,"roomHotkeyCheckers");y(this,"tmpCopyStore",new Map);y(this,"tmpCopyCoordInfo");var i;const{control:e,internalMsgEmitter:t}=s;this.control=e,this.internalMsgEmitter=t,this.roomHotkeyCheckers=((i=this.control.room)==null?void 0:i.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)===I.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 i,o,n;const e=this.control.viewContainerManager.focuedViewId,t=(i=this.control.viewContainerManager.focuedView)==null?void 0:i.focusScenePath;if(e&&t)switch(s){case"delete":this.isSelector&&((o=this.collector)!=null&&o.hasSelector(e,t))&&oe.emitMethod(te.MainEngine,F.DeleteNode,{workIds:[Q],viewId:e});break;case"copy":this.isSelector&&((n=this.collector)!=null&&n.hasSelector(e,t))&&this.copySelectorToTemp(e,t);break;case"paste":this.tmpCopyStore.size&&this.pasteTempToFocusView(e,t);break}(s==="changeToPencil"||s==="redo"||s==="undo")&&this.onSelfActiveHotkey(s)}colloctHotkey(s){if(this.isUseSelf){const e=this.checkHotkey(s);e&&this.onSelfActiveHotkey(e)}}onSelfActiveHotkey(s){switch(s){case"changeToPencil":this.setMemberState({currentApplianceName:ne.pencil,useNewPencil:!0});break;case"changeToArrow":this.setMemberState({currentApplianceName:ne.arrow});break;case"changeToClick":this.setMemberState({currentApplianceName:ne.clicker});break;case"changeToEllipse":this.setMemberState({currentApplianceName:ne.ellipse});break;case"changeToEraser":this.setMemberState({currentApplianceName:ne.eraser,isLine:!0});break;case"changeToHand":this.setMemberState({currentApplianceName:ne.hand});break;case"changeToLaserPointer":this.setMemberState({currentApplianceName:ne.laserPointer});break;case"changeToSelector":this.setMemberState({currentApplianceName:ne.selector});break;case"changeToRectangle":this.setMemberState({currentApplianceName:ne.rectangle});break;case"changeToStraight":this.setMemberState({currentApplianceName:ne.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:ne.text});break}}checkHotkey(s){for(const e of this.roomHotkeyCheckers){const{kind:t,checker:i}=e;if(i({nativeEvent:s,kind:this.getEventKey(s),key:s.key,altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey},this.keyboardKind))return t}}copySelectorToTemp(s,e){var l,h;const t=this.control.viewContainerManager.getView(s),i=(h=(l=this.mainEngine)==null?void 0:l.methodBuilder)==null?void 0:h.getBuilder(F.CopyNode);if(!t||!this.collector||!i)return;const o=this.collector.transformKey(Q),n=this.collector.getStorageData(s,e);if(!n)return;const r=n[o],c=r&&i.copySelector({viewId:s,store:r});c&&(this.tmpCopyCoordInfo=c==null?void 0:c.copyCoordInfo,this.tmpCopyStore=c==null?void 0:c.copyStores)}pasteTempToFocusView(s,e){var o,n;const t=this.control.viewContainerManager.getView(s),i=(n=(o=this.mainEngine)==null?void 0:o.methodBuilder)==null?void 0:n.getBuilder(F.CopyNode);if(!(!t||!this.tmpCopyCoordInfo||!this.tmpCopyStore.size||!this.collector||!i)&&t.viewData&&this.tmpCopyCoordInfo){const r=D.cloneDeep(this.tmpCopyCoordInfo.offset),c=this.tmpCopyCoordInfo.cameraOpt,l=t.viewData.camera;r.x=r.x+l.centerX-c.centerX,r.y=r.y+l.centerY-c.centerY;const h=Date.now();this.control.worker.internalMsgEmitter.emit("addUndoTicker",h,s),i.pasteSelector({viewId:s,scenePath:e,copyStores:D.cloneDeep(this.tmpCopyStore),copyCoordInfo:{offset:r,cameraOpt:l},undoTickerId:h})}}setMemberState(s){var e;(e=this.control.room)==null||e.setMemberState(s)}}class $M{constructor(s){y(this,"control");y(this,"roomMemberManager");y(this,"worker");y(this,"publicMsgEmitter");y(this,"renderUids",new Map);y(this,"pageAuth",new Map);y(this,"isLocalRender",!1);y(this,"isCurWritable",!1);var i;const{control:e,publicMsgEmitter:t}=s;this.control=e,this.publicMsgEmitter=t,this.roomMemberManager=e.roomMember,this.worker=e.worker,this.isCurWritable=((i=this.control.room)==null?void 0:i.isWritable)||!1}onWritableChange(s){this.isCurWritable=s}addPage(s,e=!0){var l,h;const{viewId:t,render:i="localSelf",elementIds:o,pageId:n=(l=this.control.collector)==null?void 0:l.uid}=s,r=this.pageAuth.get(t)||new Map,c=this.control.viewContainerManager.getCurScenePath(t);if(c&&n){const u=r.get(c)||{render:"localSelf",pages:new Map};e&&(u.render=i);const d=o&&this.cloneElementIds(t,c,o,n)||new Set;u.pages.set(n,d),r.set(c,u),this.pageAuth.set(t,r),e&&this.pageAuthEffect(t),this.isLocalRender=!1,(h=this.control.collector)==null||h.dispatchPageAuth({operation:De.addPage,viewId:t,scenePath:c,pageId:n,pageData:{render:i,elementIds:d}},!0)}}delPage(s,e){var n,r;const t=this.pageAuth.get(e);if(!t)return;const i=[...t.keys()].find(c=>{const l=t.get(c);return!!(l&&l.pages.has(s))});if(!i)return;const o=t.get(i);if(o){const{render:c,pages:l}=o,h=c==="localSelf"?(n=this.control.collector)==null?void 0:n.uid:c,u=l.get(s);u!=null&&u.size&&this.delElementIds(e,i,u),l.delete(s),h===s&&this.pageAuthEffect(e)}(r=this.control.collector)==null||r.dispatchPageAuth({operation:De.deletePage,viewId:e,scenePath:i,pageId:s},!0)}delViewPage(s,e=!0){var i;this.pageAuth.get(s)&&(this.pageAuth.delete(s),e&&((i=this.control.collector)==null||i.dispatchPageAuth({operation:De.clearView,viewId:s},e)))}clearRenderPage(s,e,t=!0){var r,c;const i=this.pageAuth.get(s);if(!i)return;const o=i.get(e);let n;if(o){const{render:l,pages:h}=o,u=l==="localSelf"?(r=this.control.collector)==null?void 0:r.uid:l;if(u){if(t){const d=h.get(u);d&&this.delElementIds(s,e,d)}h.set(u,new Set),n=u}}t&&n&&((c=this.control.collector)==null||c.dispatchPageAuth({operation:De.clearPage,viewId:s,scenePath:e,pageId:n},t))}hasPage(s,e,t){const i=this.pageAuth.get(e);if(!i)return!1;const o=i.get(t);return o?o.pages.has(s):!1}getPageInfo(s,e,t){const i=this.pageAuth.get(e);if(!i)return;const o=i.get(t);if(o)return o.pages.get(s)}addRenderPageElementId(s,e=!0,t=!1){var h,u;const{viewId:i,elementId:o,scenePath:n}=s,r=this.pageAuth.get(i);if(!r)throw new Error(`no view info in viewId: ${i}`);const c=r.get(n);let l;if(c){const{render:d,pages:f}=c,g=d==="localSelf"?(h=this.control.collector)==null?void 0:h.uid:d;if(g&&f.has(g)){const p=f.get(g)||new Set;p.add(o),f.set(g,p),l=g}}t&&this.pageAuthEffect(i),e&&l&&((u=this.control.collector)==null||u.dispatchPageAuth({operation:De.addElement,viewId:i,scenePath:n,pageId:l,pageData:{elementId:o}},e))}delRenderPageElementId(s,e=!0,t=!1){var h,u;const{viewId:i,elementId:o,scenePath:n}=s,r=this.pageAuth.get(i);if(!r)throw new Error(`no view info in viewId: ${i}`);const c=r.get(n);let l;if(c){const{render:d,pages:f}=c,g=d==="localSelf"?(h=this.control.collector)==null?void 0:h.uid:d;if(g&&f.has(g)){const p=f.get(g);p&&(p.delete(o),f.set(g,p),l=g)}}t&&this.pageAuthEffect(i),e&&l&&((u=this.control.collector)==null||u.dispatchPageAuth({operation:De.deleteElement,viewId:i,scenePath:n,pageId:l,pageData:{elementId:o}},e))}setPageRender(s,e,t,i=!0){var r;const o=this.pageAuth.get(s);if(!o)throw new Error(`no view info in viewId: ${s}`);const n=o.get(e);n&&(n.render=t),e===this.control.viewContainerManager.getCurScenePath(s)&&this.pageAuthEffect(s),i||(this.isLocalRender=!0),i&&(this.isLocalRender=!1,(r=this.control.collector)==null||r.dispatchPageAuth({operation:De.renderPage,viewId:s,scenePath:e,pageData:{render:t}},i))}isWriteable(){return this.isCurWritable}isRenderAble(s){var c,l;const{uid:e,viewId:t,filterLocalSelf:i=!0,scenePath:o}=s,n=this.renderUids.get(t);if(n){const{render:h,hide:u}=n;if(h===void 0&&u===void 0)return!0;if(D.isSet(h)){if(h.has(e)||i&&((c=this.control.collector)==null?void 0:c.uid)===e&&h.has("localSelf"))return!0}else if(h===!0&&(!u||D.isSet(u)&&!u.has(e)&&!(i&&u.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===e)))return!0;return!1}const r=this.pageAuth.get(t);if(r&&o){const h=r.get(o);if(h){const{render:u}=h;if(u)return!(u==="localSelf"&&!i)}}return!0}isClearAble(s){var c;const{uid:e,viewId:t,filterLocalSelf:i=!0,scenePath:o}=s,n=this.renderUids.get(t);if(n){const{clear:l}=n;return!!(l===void 0||l===!0||D.isSet(l)&&(l.has(e)||i&&((c=this.control.collector)==null?void 0:c.uid)===e&&l.has("localSelf")))}const r=this.pageAuth.get(t);if(r&&o){const l=r.get(o);if(l){const{render:h}=l;if(h)return!(h==="localSelf"&&!i)}}return!0}isFilterAble(s,e){var c,l,h,u;const{viewId:t,scenePath:i,elementId:o}=s,n=this.renderUids.get(t);if(n&&o){const{render:d,hide:f}=n;if(d===void 0&&f===void 0)return!0;const g=(c=this.control.collector)==null?void 0:c.getUidFromKey(o);return g?!!(D.isSet(d)&&(d.has(g)||d.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===g)||d===!0&&(!f||D.isSet(f)&&!f.has(g)&&!(f.has("localSelf")&&((h=this.control.collector)==null?void 0:h.uid)===g))):!1}const r=this.pageAuth.get(t);if(r&&i&&o){const d=r.get(i);if(d){const{render:f,pages:g}=d;if(!f)return!0;const p=(u=this.control.collector)==null?void 0:u.uid,m=f==="localSelf"?p:f,N=m&&g.get(m)||void 0;if(N)switch(e){case x.RemoveNode:return!0;default:return N.has(o)}return!1}}return!0}isFilterCursor(s){if(this.isUsePageAuth(s)){const e=this.control.viewContainerManager.getCurScenePath(s),t=this.pageAuth.get(s);if(e&&t){const i=t.get(e);if(i){const{render:o}=i;return o!=="localSelf"}}}return!0}isUsePageAuth(s){var i;if(!this.pageAuth.has(s))return!1;const t=this.control.viewContainerManager.getCurScenePath(s);return t&&((i=this.pageAuth.get(s))==null?void 0:i.has(t))||!1}publishRender(s){var n;const{viewId:e,option:t,isSync:i=!0}=s,o={};if(t){const{render:r,hide:c,clear:l}=t;r&&(o.render=r===!0&&!0||new Set(r)),c&&(o.hide=c===!0&&!0||new Set(c)),l&&(o.clear=l===!0&&!0||new Set(l)),this.renderUids.set(e,o)}else this.renderUids.delete(e);i&&((n=this.control.collector)==null||n.dispatchRenderAuth({operation:He.setAuth,viewId:e,renderData:o},i)),this.renderEffect(e)}publishOneRender(s,e,t,i=!0){var r;const o=this.renderUids.get(s);let n;switch(t){case"show":o?(o.render||(o.render=new Set),D.isSet(o.render)&&o.render.add(e),D.isSet(o.hide)&&o.hide.delete(e)):this.renderUids.set(s,{render:new Set([e])}),n=He.setShow;break;case"hide":o?(o.hide||(o.hide=new Set),D.isSet(o.hide)&&o.hide.add(e),D.isSet(o.render)&&o.render.delete(e)):this.renderUids.set(s,{hide:new Set([e])}),n=He.setHide;break}o?this.renderUids.set(s,o):this.renderUids.delete(s),i&&n&&((r=this.control.collector)==null||r.dispatchRenderAuth({operation:n,viewId:s,uid:e},i)),this.renderEffect(s)}publishOneClear(s,e,t,i=!0){var n;const o=this.renderUids.get(s);t?o?(o.clear||(o.clear=new Set),D.isSet(o.clear)&&o.clear.add(e)):this.renderUids.set(s,{clear:new Set([e])}):o&&D.isSet(o.clear)&&o.clear.has(e)&&o.clear.delete(e),o?this.renderUids.set(s,o):this.renderUids.delete(s),i&&((n=this.control.collector)==null||n.dispatchRenderAuth({operation:He.setClear,viewId:s,uid:e,isClear:t},i)),this.renderEffect(s)}syncRenderUids(s,e,t,i){const o=e===!0?!0:e&&Object.keys(e)?new Set(Object.keys(e)):void 0,n=t===!0?!0:t&&Object.keys(t)?new Set(Object.keys(t)):void 0,r=i===!0?!0:i&&Object.keys(i)?new Set(Object.keys(i)):void 0;o||n||r?this.renderUids.set(s,{render:o,hide:n,clear:r}):this.renderUids.delete(s),this.renderEffect(s),this.publicMsgEmitter.emit("syncRenderUids",s,{render:o,hide:n,clear:r})}syncPageAuth(s,e,t=!1){let i=!1;if(!e)this.pageAuth.delete(s);else{const o=this.pageAuth.get(s)||new Map;for(const[n,r]of Object.entries(e)){const{render:c,pages:l}=r,h=o.get(n),u=this.isLocalRender?h==null?void 0:h.render:c;if(u){u!==(h==null?void 0:h.render)&&(i=!0);const d=new Map;for(const[g,p]of Object.entries(l))d.set(g,new Set(Object.keys(p)));const f={render:u,pages:d};d.size&&o.set(n,f)}}o.size&&(this.pageAuth.set(s,o),this.publicMsgEmitter.emit("syncPageAuth",s,o))}(t||i)&&this.pageAuthEffect(s)}destoryByViewId(s,e=!1){var t;this.renderUids.has(s)&&(this.renderUids.delete(s),e||(t=this.control.collector)==null||t.dispatchRenderAuth({operation:He.setAuth,viewId:s})),this.pageAuth.has(s)&&this.control.renderControl.delViewPage(s,!e)}renderEffect(s){var t;const e=(t=this.control.viewContainerManager.getView(s))==null?void 0:t.focusScenePath;e&&this.worker.clearViewScenePath(s,!0).then(()=>{var i;this.worker.pullServiceData(s,e,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(s,(i=this.renderUids.get(s))==null?void 0:i.clear)})}pageAuthEffect(s){var t;const e=(t=this.control.viewContainerManager.getView(s))==null?void 0:t.focusScenePath;e&&this.worker.clearViewScenePath(s,!0).then(()=>{this.worker.pullServiceData(s,e,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(s,!0)})}cloneElementIds(s,e,t,i){var r,c;const o=(r=this.control.collector)==null?void 0:r.getStorageData(s,e),n=new Set;if(o){for(const l of Object.keys(o))if(t.has(l)){const h=`${l}_${i}`;if(n.add(h),!Object.keys(o).includes(h)){const u=D.cloneDeep(o[l]);(c=this.control.collector)==null||c.updateValue(h,{type:x.FullWork,...u,workId:h},{isSync:!0,viewId:s,scenePath:e})}}}return n}delElementIds(s,e,t){var o,n;const i=(o=this.control.collector)==null?void 0:o.getStorageData(s,e);if(i)for(const r of Object.keys(i))t.has(r)&&Object.keys(i).includes(r)&&((n=this.control.collector)==null||n.updateValue(r,void 0,{isSync:!0,viewId:s,scenePath:e}))}}class HM{constructor(s){y(this,"internalMsgEmitter");y(this,"control");y(this,"maps",new Map);y(this,"showId");y(this,"color");y(this,"timer");y(this,"updateMiniMapCamera",D.debounce(async s=>{const e=this.maps.get(s);if(e){const t=await this.getMiniMapCamera(s);if(t){const i=t.width/t.scale,o=t.height/t.scale,n=e.miniMapCamera.width/e.miniMapCamera.scale,r=e.miniMapCamera.height/e.miniMapCamera.scale;(i>=n||o>=r)&&(e.miniMapCamera=t);const c=e.miniMapCanvas.current;if(c){const l=c.getContext("2d");if(l){const h=this.control.viewContainerManager.getView(s);if(!(h!=null&&h.focusScenePath))return;const{miniMapCamera:u,contianer:d}=e,{width:f,height:g}=d.getBoundingClientRect(),p=Math.min(f/u.width,g/u.height);l.clearRect(0,0,c.width,c.height),c.width=u.width,c.height=u.height,c.style.width=`${u.width*p}px`,c.style.height=`${u.height*p}px`,await this.control.screenshotToCanvas(l,h.focusScenePath,u.width,u.height,u),this.listener.emitAsync([s,"viewCameraUpate"],1)}}}}},2e3,{maxWait:5e3}));var i;const{control:e,internalMsgEmitter:t}=s;this.control=e,this.internalMsgEmitter=t,this.color=((i=this.control.worker.currentToolsData)==null?void 0:i.toolsOpt.strokeColor)||"#000"}get listener(){return this.internalMsgEmitter}get activeViewId(){return this.showId}get highlightColor(){return this.color}setHighlightColor(s){this.color=s}async createMiniMap(s,e,t){const i=this.control.viewContainerManager.getView(s);if(!i)throw new Error("view not found");const o=i.cameraOpt;if(!o)throw new Error("view camera not found");const{width:n,height:r}=e.getBoundingClientRect();if(!n||!r)throw new Error("contianer width or height is 0");const c=M.createRef();this.maps.set(s,{contianer:e,miniMapCanvas:c,miniMapCamera:t,viewCamera:o}),this.showId=s,this.control.viewContainerManager.setActiveMiniMap(this.showId,!0);const l=Math.min(n/t.width,r/t.height),h=await new Promise(u=>{this.listener.once([s,"miniMapCreate"],()=>{const d=c.current;d&&(d.width=t.width,d.height=t.height,d.style.width=`${t.width*l}px`,d.style.height=`${t.height*l}px`),u(!0)}),this.timer=setTimeout(()=>{u(!1)},2e3)});return this.timer&&clearTimeout(this.timer),h}async getMiniMapCamera(s){const e=this.control.viewContainerManager.getView(s);if(!e)return;const{cameraOpt:t,focusScenePath:i}=e;if(!t||!i)return;const o={originX:t.centerX-t.width/t.scale/2,originY:t.centerY-t.height/t.scale/2,width:t.width/t.scale,height:t.height/t.scale};let n=await this.control.getBoundingRect(i)||o;n=ei(n,o)||o;let r=n.width,c=n.height,l=1;const h=r>t.width&&Math.min(t.width/r,l)||l,u=c>t.height&&Math.min(t.height/c,l)||l;return h<=u?(r=h<1&&t.width||r,c=Math.floor(c*h)+1,l=h):h>u&&(c=u<1&&t.height||c,r=Math.floor(r*u)+1,l=u),{scale:l,centerX:n.originX+n.width/2,centerY:n.originY+n.height/2,width:r,height:c}}getMiniMapCanvas(s){const e=this.maps.get(s);return(e==null?void 0:e.miniMapCanvas.current)||null}updateViewCamera(s,e){const t=this.maps.get(s);t&&(t.viewCamera=e,this.listener.emitAsync([s,"viewCameraUpate"],1))}destroyMiniMap(s){const e=s||this.showId;e&&(this.maps.delete(e),this.control.viewContainerManager.setActiveMiniMap(e,!1))}}class Xo{constructor(){y(this,"control");y(this,"_listeners",{})}_inject(s){this.control=s}_onEvent(s,e){this._listeners[s]&&this._listeners[s](...e)}callbacks(s,e){this._listeners[s]=e}removeCallback(s){delete this._listeners[s]}}class QM{constructor(s){y(this,"control");y(this,"worker");y(this,"publicMsgEmitter");y(this,"plugins",new Map);const{control:e,publicMsgEmitter:t}=s;this.control=e,this.publicMsgEmitter=t,this.worker=e.worker}use(s){this.plugins.set(s.kind,s),s._inject(this.control),s.onCreate()}destroy(){this.plugins.forEach(s=>{this.plugins.delete(s.kind),s.onDestroy()})}dispatchPluginEvent(s,...e){this.plugins.forEach(t=>{t._onEvent(s,e)})}}const at=class at{constructor(s){y(this,"version",xo);y(this,"plugin");y(this,"room");y(this,"play");y(this,"collector");y(this,"hasSwitchToSelectorEffect");y(this,"snapshootStateMap");y(this,"_disableDeviceInputs");y(this,"_disableEraseImage");y(this,"_disableEraseText");y(this,"priority","cpu");y(this,"effectResolve");y(this,"hotkeyManager");y(this,"pluginOptions");y(this,"roomMember");y(this,"cursor");y(this,"textEditorManager");y(this,"worker");y(this,"renderControl");y(this,"miniMapManager");y(this,"pluginManager");y(this,"onSceneChange",async(s,e)=>{var n;const t=this.viewContainerManager.getView(e);t!=null&&t.focusScenePath&&(n=this.collector)!=null&&n.hasSelector(e,t.focusScenePath)&&this.worker.blurSelector(e,t.focusScenePath),this.textEditorManager.checkEmptyTextBlur();const i=t==null?void 0:t.displayer;i&&(i.setActive(!1),await i.stopEventHandler());const o=s;o&&this.viewContainerManager.setViewScenePath(e,o),i==null||i.setActive(!0)});y(this,"onRoomMembersChange",s=>{this.roomMember.setRoomMembers(q.toJS(s))});y(this,"onMemberChange",gs(s=>{if(!this.room||!this.worker||!s||!this.room.isWritable)return;const e=this.getToolsKey(s),t=this.getToolsOpt(e,s);this.worker.setCurrentToolsData(t),this.pluginManager.dispatchPluginEvent("setToolkey",e),this.effectViewContainer(e),this.effectResolve&&this.effectResolve(!0)},100,{leading:!1}));y(this,"internalSceneChange",(s,e)=>{var i;this.miniMapManager.activeViewId===s&&this.miniMapManager.destroyMiniMap(s),this.pluginManager.dispatchPluginEvent("sceneChange",s,e),(i=this.worker)==null||i.clearViewScenePath(s,!0).then(()=>{var o;(o=this.worker)==null||o.pullServiceData(s,e,{isAsync:!0,useAnimation:!1})})});y(this,"internalCameraChange",(s,e)=>{var t;(t=this.worker)==null||t.updateCamera(s,e),this.miniMapManager.updateViewCamera(s,e)});const{displayer:e,plugin:t,options:i}=s;this.plugin=t,this.room=q.isRoom(e)?e:void 0,this.play=q.isPlayer(e)?e:void 0,this.room&&(this._disableDeviceInputs=this.room.disableDeviceInputs,this._disableEraseImage=this.room.disableEraseImage,this._disableEraseText=!1),this.pluginOptions=i,this.roomMember=new NM;const o={control:this,internalMsgEmitter:at.InternalMsgEmitter,publicMsgEmitter:at.PublicMsgEmitter};this.cursor=new TM(o),this.textEditorManager=new SM(o),this.worker=new FM(o),this.hotkeyManager=new VM(o),this.renderControl=new $M(o),this.miniMapManager=new HM(o),this.pluginManager=new QM(o)}get disableEraseText(){return this._disableEraseText||!1}set disableEraseText(s){this._disableEraseText=s}get disableEraseImage(){return this._disableEraseImage||!1}set disableEraseImage(s){this._disableEraseImage=s}get disableDeviceInputs(){return this._disableDeviceInputs||!1}set disableDeviceInputs(s){var t;this._disableDeviceInputs=s;const e=(t=this.worker.getCurrentToolsData())==null?void 0:t.toolsType;e&&this.effectViewContainer(e)}setPriority(s){var e;this.priority=s,this.hasOffscreenCanvas()&&((e=this.worker)==null||e.setPriority(s))}hasOffscreenCanvas(){return Xs==="worker"}bindPlugin(s){var e,t;this.plugin=s,this.collector&&(this.collector.removeStorageStateListener(),this.collector.removeAuthStateListener()),this.collector=new As(this,s,(t=(e=this.pluginOptions)==null?void 0:e.syncOpt)==null?void 0:t.interval),this.activePlugin()}destroy(){var s,e,t,i,o,n;this.roomMember.destroy(),(s=this.collector)==null||s.destroy(),(e=this.worker)==null||e.destroy(),(t=this.viewContainerManager)==null||t.destroy(),(i=this.cursor)==null||i.destroy(),(o=this.textEditorManager)==null||o.destory(),(n=this.pluginManager)==null||n.destroy()}cleanCurrentScene(){const s=Date.now(),e=this.worker.getLocalWorkViewId()||this.viewContainerManager.focuedViewId;e&&(at.InternalMsgEmitter.emit("addUndoTicker",s,e),this.worker.clearViewScenePath(e,!1,!0))}async setWritable(s){var e;if(!s){this.textEditorManager.checkEmptyTextBlur();const t=this.viewContainerManager.getAllViews();for(const i of t){i!=null&&i.focusScenePath&&(e=this.collector)!=null&&e.hasSelector(i.id,i.focusScenePath)&&this.worker.blurSelector(i.id,i.focusScenePath);const o=i==null?void 0:i.displayer;o&&o.getActive()&&(o.setActive(!1),await o.stopEventHandler())}}await new Promise(t=>{setTimeout(()=>{t()},500)})}onWritableChange(s){var t,i;s?(i=this.worker)==null||i.abled():(t=this.worker)==null||t.unWritable(),this.renderControl.onWritableChange(s),this.viewContainerManager.getAllViews().forEach(o=>{const n=o==null?void 0:o.displayer;n&&(n.bindToolsClass(),s?n.setActive(!0):n.setActive(!1))})}getToolsKey(s){var t;const e=s.currentApplianceName;switch(this.hasSwitchToSelectorEffect=!1,e){case ne.text:return s.textCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),I.Text;case ne.pencil:return s.useLaserPen?I.LaserPen:I.Pencil;case ne.eraser:return I.Eraser;case ne.pencilEraser:return((t=this.pluginOptions.pencilEraser)==null?void 0:t.useBitMap)===!1?I.PencilEraser:I.BitMapEraser;case ne.selector:return I.Selector;case ne.arrow:return s.arrowCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),I.Arrow;case ne.straight:return s.straightCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),I.Straight;case ne.ellipse:return s.ellipseCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),I.Ellipse;case ne.rectangle:return s.rectangleCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),I.Rectangle;case ne.shape:if(s.shapeCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),s.shapeType===Ve.Pentagram||s.shapeType===Ve.Star)return I.Star;if(s.shapeType===Ve.Polygon||s.shapeType===Ve.Triangle||s.shapeType===Ve.Rhombus)return I.Polygon;if(s.shapeType===Ve.SpeechBalloon)return I.SpeechBalloon;break}return I.Clicker}getToolsOpt(s,e){if(s===I.Clicker)return{toolsType:s,toolsOpt:{}};const t={strokeColor:Pt(e.strokeColor[0],e.strokeColor[1],e.strokeColor[2],e.strokeOpacity||1),thickness:e.strokeWidth,isOpacity:(e==null?void 0:e.strokeOpacity)&&e.strokeOpacity<1||(e==null?void 0:e.fillOpacity)&&e.fillOpacity<1||(e==null?void 0:e.textOpacity)&&e.textOpacity<1||(e==null?void 0:e.textBgOpacity)&&e.textBgOpacity<1||!1};switch(s){case I.Text:t.fontFamily=window.getComputedStyle(document.documentElement).getPropertyValue("font-family"),t.fontSize=(e==null?void 0:e.textSizeOverride)||(e==null?void 0:e.textSize)||Number(window.getComputedStyle(document.body).fontSize),t.textAlign=(e==null?void 0:e.textAlign)||"left",t.verticalAlign=(e==null?void 0:e.verticalAlign)||"middle",t.fontColor=(e==null?void 0:e.textColor)&&Pt(e.textColor[0],e.textColor[1],e.textColor[2],e.textOpacity||1)||t.strokeColor||"rgba(0,0,0,1)",t.fontBgColor=Array.isArray(e==null?void 0:e.textBgColor)&&Pt(e.textBgColor[0],e.textBgColor[1],e.textBgColor[2],e.textBgOpacity||1)||"transparent",t.bold=(e==null?void 0:e.bold)&&"bold"||void 0,t.italic=(e==null?void 0:e.italic)&&"italic"||void 0,t.underline=(e==null?void 0:e.underline)||void 0,t.lineThrough=(e==null?void 0:e.lineThrough)||void 0,t.text="",t.strokeColor=void 0;break;case I.Pencil:t.strokeType=(e==null?void 0:e.strokeType)||ee.Normal;break;case I.PencilEraser:case I.BitMapEraser:case I.Eraser:t.thickness=Math.min(4,Math.max(1,Math.floor(e.pencilEraserSize||1)))-1;break;case I.LaserPen:t.duration=(e==null?void 0:e.duration)||1,e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===ee.Stroke?t.strokeType=ee.Normal:t.strokeType=(e==null?void 0:e.strokeType)||ee.Normal;break;case I.Arrow:case I.Straight:e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===ee.Stroke?t.strokeType=ee.Normal:t.strokeType=(e==null?void 0:e.strokeType)||ee.Normal;break;case I.Ellipse:case I.Rectangle:case I.Star:case I.Polygon:case I.SpeechBalloon:e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===ee.Stroke?t.strokeType=ee.Normal:t.strokeType=(e==null?void 0:e.strokeType)||ee.Normal,s===I.Star&&(e.shapeType===Ve.Pentagram?(t.vertices=10,t.innerVerticeStep=2,t.innerRatio=.4):e!=null&&e.vertices&&(e!=null&&e.innerVerticeStep)&&(e!=null&&e.innerRatio)&&(t.vertices=e.vertices,t.innerVerticeStep=e.innerVerticeStep,t.innerRatio=e.innerRatio)),s===I.Polygon&&(e.shapeType===Ve.Triangle?t.vertices=3:e.shapeType===Ve.Rhombus?t.vertices=4:e.vertices&&(t.vertices=e.vertices)),t.fillColor=(e==null?void 0:e.fillColor)&&Pt(e.fillColor[0],e.fillColor[1],e.fillColor[2],e==null?void 0:e.fillOpacity)||"transparent",s===I.SpeechBalloon&&(t.placement=e.placement||"bottomLeft");break}return{toolsType:s,toolsOpt:t}}effectViewContainer(s){var e,t,i,o,n,r,c;if(this.disableDeviceInputs===!0)this.room.disableDeviceInputs=!0,(e=this.worker)==null||e.unWritable(),(t=this.cursor)==null||t.unabled();else switch(s){case I.Text:case I.Pencil:case I.LaserPen:case I.Arrow:case I.Straight:case I.Rectangle:case I.Ellipse:case I.Star:case I.Polygon:case I.SpeechBalloon:case I.Triangle:case I.Rhombus:case I.Eraser:case I.PencilEraser:case I.BitMapEraser:this.room.disableDeviceInputs=!0,(i=this.worker)==null||i.abled();break;case I.Selector:this.room.disableDeviceInputs=!1,(o=this.cursor)==null||o.unabled(),(n=this.worker)==null||n.abled();break;default:this.room.disableDeviceInputs=!1,(r=this.worker)==null||r.unWritable(),(c=this.cursor)==null||c.unabled();break}setTimeout(()=>{this.viewContainerManager.getAllViews().forEach(h=>{h!=null&&h.displayer&&h.displayer.bindToolsClass()})},0)}async getBoundingRect(s){var t,i,o,n,r;const e=await((t=this.worker)==null?void 0:t.getBoundingRect(s));if(e){const c=((o=(i=this.viewContainerManager.mainView)==null?void 0:i.viewData)==null?void 0:o.convertToPointInWorld({x:e.x,y:e.y}))||{x:e.x,y:e.y},l=((r=(n=this.viewContainerManager.mainView)==null?void 0:n.viewData)==null?void 0:r.camera.scale)||1;return{width:Math.floor(e.w/l)+1,height:Math.floor(e.h/l)+1,originX:c.x,originY:c.y}}}async screenshotToCanvas(s,e,t,i,o,n,r){const c=await this.worker.getSnapshot(e,t,i,o);c&&(s.drawImage(c,n||0,r||0),c.close())}async scenePreview(s,e){var n,r,c,l;const t=(n=this.collector)==null?void 0:n.getViewIdBySecenPath(s);if(!t)return;const i=this.viewContainerManager.getView(t);if(!i||!((r=i.cameraOpt)!=null&&r.width)||!((c=i.cameraOpt)!=null&&c.height))return;const o=await((l=this.worker)==null?void 0:l.getSnapshot(s));if(o&&this.worker){const h=document.createElement("canvas"),u=h.getContext("2d"),{width:d,height:f}=i.cameraOpt;h.width=d,h.height=f,u&&(u.drawImage(o,0,0),e.crossOrigin="anonymous",e.src=h.toDataURL(),e.onload=()=>{h.remove()},e.onerror=()=>{h.remove(),e.remove()}),o.close()}}switchToText(){var s;(s=this.room)==null||s.setMemberState({currentApplianceName:ne.text})}switchToSelector(){var s;(s=this.room)==null||s.setMemberState({currentApplianceName:ne.selector})}async runEffectWork(s){if(this.hasSwitchToSelectorEffect){const e=await new Promise(t=>{this.switchToSelector(),this.effectResolve=t});this.effectResolve=void 0,e&&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 e;return(e=this.snapshootStateMap)==null?void 0:e.get(s)}clearSnapshootData(){var s;(s=this.snapshootStateMap)==null||s.clear(),this.snapshootStateMap=void 0}useBitMapEraser(s){var e;if(((e=this.pluginOptions.pencilEraser)==null?void 0:e.useBitMap)===void 0){this.pluginOptions.pencilEraser={useBitMap:s};return}this.pluginOptions.pencilEraser.useBitMap=s}consoleWorkerInfo(){var s;(s=this.worker)==null||s.consoleWorkerInfo()}filterRenderByUid(s,e,t=!0){var o;this.viewContainerManager.getView(s)&&((o=this.renderControl)==null||o.publishRender({viewId:s,option:e,isSync:t}))}cancelFilterRender(s,e=!0){var t;(t=this.renderControl)==null||t.publishRender({viewId:s,isSync:e})}async createMiniMap(s,e){const t=await this.miniMapManager.getMiniMapCamera(s);if(t&&await this.miniMapManager.createMiniMap(s,e,t)){const o=this.miniMapManager.getMiniMapCanvas(s);if(o){const n=o.getContext("2d");if(n){const r=this.viewContainerManager.getView(s);r!=null&&r.focusScenePath&&this.screenshotToCanvas(n,r.focusScenePath,t.width,t.height,t)}}}}async destroyMiniMap(s){this.miniMapManager.destroyMiniMap(s)}insertIconify(s,e){var i;if(this.viewContainerManager.getView(s)&&this.room){const o=this.room.state.memberState,n=Pt(o.strokeColor[0],o.strokeColor[1],o.strokeColor[2],o.strokeOpacity||1);(i=this.worker)==null||i.insertIconify(s,{...e,strokeColor:n})}}usePlugin(s){return this.pluginManager.use(s)}};y(at,"InternalMsgEmitter",new ks),y(at,"PublicMsgEmitter",new ks);let Ne=at;const ct=class ct{constructor(s){y(this,"emitter",new ks);y(this,"undoStack");y(this,"redoStack");y(this,"worker");y(this,"control");y(this,"room");y(this,"isTicking");y(this,"undoTickerId");y(this,"viewId");y(this,"scenePath");y(this,"tickStartStorerCache");y(this,"excludeIds",new Set);y(this,"onChangeScene",D.debounce(()=>{const s=this.control.viewContainerManager.getCurScenePath(this.viewId);if(s){let e=this.undoStack.filter(i=>i.scenePath===s).length;const t=this.redoStack.filter(i=>i.scenePath===s).length;e===0&&t===0&&this.tickStartStorerCache&&this.scenePath===s&&(e=1),this.emitter.emit("onCanUndoStepsUpdate",e),this.emitter.emit("onCanRedoStepsUpdate",t)}},ct.waitTime));const{control:e,internalMsgEmitter:t,viewId:i}=s;this.control=e,this.emitter=t,this.undoStack=[],this.redoStack=[],this.room=e.room,this.worker=e.worker,this.isTicking=!1,this.viewId=i}get collector(){return this.control.collector}addExcludeIds(s){if(this.isTicking)for(const e of s)this.excludeIds.add(e)}undoTickerStart(s,e){if(this.collector&&(this.undoTickerId!==s||this.scenePath!==e)){!this.undoTickerId&&!this.tickStartStorerCache&&!this.scenePath&&this.emitter.emit("onCanUndoStepsUpdate",1),this.undoTickerId&&this.viewId&&this.scenePath&&this.undoTickerEndSync(this.undoTickerId,this.viewId,this.scenePath),this.isTicking=!0;const t=this.collector.transformKey(Q);this.excludeIds.add(t),this.undoTickerId=s,this.scenePath=e;const i=this.collector.getStorageData(this.viewId,e)||{};this.tickStartStorerCache=new Map(Object.entries(D.cloneDeep(i)))}}undoTickerEndSync(s,e,t){var i,o;if(s===this.undoTickerId&&t===this.scenePath&&e===this.viewId&&this.tickStartStorerCache){const n=((i=this.collector)==null?void 0:i.storage[e])&&((o=this.collector)==null?void 0:o.storage[e][t])||{},r=this.diffFun(this.tickStartStorerCache,new Map(Object.entries(n)));r.size&&(this.undoStack.push({id:s,type:2,data:D.cloneDeep(r),scenePath:t}),this.undoStack.length>ct.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 e=this.undoStack.length-1;for(;e>=0;){if(this.undoStack[e].scenePath===s){const n=this.undoStack[e];n&&(this.redoStack.push(n),n.type===2&&n.data&&this.refreshPlugin(n)),this.undoStack.splice(e,1);break}e--}const t=this.undoStack.filter(o=>o.scenePath===s).length,i=this.redoStack.filter(o=>o.scenePath===s).length;return this.emitter.emit("onCanUndoStepsUpdate",t),this.emitter.emit("onCanRedoStepsUpdate",i),t}redo(s){let e=this.redoStack.length-1;for(;e>=0;){if(this.redoStack[e].scenePath===s){const n=this.redoStack[e];n&&(!this.undoTickerId&&n.tickStartStorerCache?(this.undoTickerId=n.id,this.tickStartStorerCache=n.tickStartStorerCache,this.scenePath=n.scenePath):this.undoStack.push(n),n.type===2&&n.data&&this.refreshPlugin(n,!0)),this.redoStack.splice(e,1);break}e--}const t=this.undoStack.filter(o=>o.scenePath===s).length,i=this.redoStack.filter(o=>o.scenePath===s).length;return this.emitter.emit("onCanUndoStepsUpdate",t),this.emitter.emit("onCanRedoStepsUpdate",i),i}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 e=this.undoStack.filter(i=>i.scenePath===s).length;const t=this.redoStack.filter(i=>i.scenePath===s).length;e===0&&t===0&&this.tickStartStorerCache&&this.scenePath===s&&(e=1),this.emitter.emit("onCanUndoStepsUpdate",e),this.emitter.emit("onCanRedoStepsUpdate",t)}}diffFun(s,e){const t=new Set,i=s.keys(),o=e.keys();for(const n of i){if(this.excludeIds.has(n))continue;const r=s.get(n),c=e.get(n);if(r&&c){if(D.isEqual(c,r))continue;t.add({dataType:3,key:n,data:[r,c]});continue}r&&t.add({dataType:2,key:n,data:r})}for(const n of o){if(this.excludeIds.has(n))continue;const r=e.get(n);r&&!s.has(n)&&t.add({dataType:1,key:n,data:r})}return t}isDrawEffectiveScene(s,e){const{key:t}=s;return!e.includes(t)}isDeleteEffectiveScene(s,e,t){var n;const{key:i}=s;if(!e.includes(i))return!1;const o=e.filter(r=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(r))===Q&&!((l=this.collector)!=null&&l.isOwn(r))}).map(r=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][t][r]});for(const r of o)if((n=r==null?void 0:r.selectIds)!=null&&n.includes(i))return!1;return!0}isOldEffectiveScene(s,e,t){var n;const{key:i}=s;if(!e.includes(i))return!1;const o=e.filter(r=>{var c,l;return((c=this.collector)==null?void 0:c.getLocalId(r))===Q&&!((l=this.collector)!=null&&l.isOwn(r))}).map(r=>{var c;return(c=this.collector)==null?void 0:c.storage[this.viewId][t][r]});for(const r of o)if((n=r==null?void 0:r.selectIds)!=null&&n.includes(i))return!1;return!0}isNewEffectiveScene(s,e){const{key:t}=s;return!!e.includes(t)}refreshPlugin(s,e=!1){var n,r,c,l,h,u,d,f,g,p,m,N,v,T,k,S,w,C,L,j,E;let t;const{scenePath:i}=s,o=s.data;if(!(!o||!this.collector))for(const A of o.values()){const{dataType:W,data:z,key:O}=A,se=this.collector.getStorageData(this.viewId,i),_=se&&Object.keys(se)||[];switch(W){case 1:if(t=e?this.isDrawEffectiveScene(A,_):this.isDeleteEffectiveScene(A,_,i),t)if(e&&!Array.isArray(z)){if((n=z.updateNodeOpt)!=null&&n.useAnimation&&(z.updateNodeOpt.useAnimation=!1),((r=this.collector)==null?void 0:r.getLocalId(O))===Q&&((c=this.collector)!=null&&c.isOwn(A.key))){const H=z.selectIds;if(H){const X=_.filter(Z=>{var K,ae;return((K=this.collector)==null?void 0:K.getLocalId(Z))===Q&&!((ae=this.collector)!=null&&ae.isOwn(Z))}).map(Z=>{var K;return(K=this.collector)==null?void 0:K.storage[this.viewId][i][Z]});let G=!1;for(const Z of X)for(let K=0;K<H.length;K++)(l=Z==null?void 0:Z.selectIds)!=null&&l.includes(H[K])&&(delete H[K],G=!0);G&&(z.selectIds=H.filter(Z=>!!Z))}}(h=this.collector)==null||h.updateValue(A.key,z,{isAfterUpdate:!0,viewId:this.viewId,scenePath:i,isSync:!0})}else!e&&!Array.isArray(A.data)&&((u=this.collector)==null||u.updateValue(A.key,void 0,{isAfterUpdate:!0,viewId:this.viewId,scenePath:i,isSync:!0}));break;case 2:if(t=e?this.isDeleteEffectiveScene(A,_,i):this.isDrawEffectiveScene(A,_),t){if(e&&!Array.isArray(z))(d=this.collector)==null||d.updateValue(O,void 0,{isAfterUpdate:!0,viewId:this.viewId,scenePath:i,isSync:!0});else if(!e&&!Array.isArray(z)){if((f=z.updateNodeOpt)!=null&&f.useAnimation&&(z.updateNodeOpt.useAnimation=!1),((g=this.collector)==null?void 0:g.getLocalId(A.key))===Q&&((p=this.collector)!=null&&p.isOwn(A.key))){const H=z.selectIds;if(H){const X=_.filter(Z=>{var K,ae;return((K=this.collector)==null?void 0:K.getLocalId(Z))===Q&&!((ae=this.collector)!=null&&ae.isOwn(Z))}).map(Z=>{var K;return(K=this.collector)==null?void 0:K.storage[this.viewId][i][Z]});let G=!1;for(const Z of X)for(let K=0;K<H.length;K++)(m=Z==null?void 0:Z.selectIds)!=null&&m.includes(H[K])&&(delete H[K],G=!0);G&&(z.selectIds=H.filter(Z=>!!Z))}}(N=this.collector)==null||N.updateValue(A.key,A.data,{isAfterUpdate:!0,viewId:this.viewId,scenePath:i,isSync:!0})}}break;case 3:if(t=e?this.isNewEffectiveScene(A,_):this.isOldEffectiveScene(A,_,i),t){if(e&&Array.isArray(z)&&z.length===2){const H=z[1];if((v=H.updateNodeOpt)!=null&&v.useAnimation&&(H.updateNodeOpt.useAnimation=!1),((T=this.collector)==null?void 0:T.getLocalId(A.key))===Q&&((k=this.collector)!=null&&k.isOwn(A.key))){const X=H.selectIds;if(X){const G=_.filter(K=>{var ae,Te;return((ae=this.collector)==null?void 0:ae.getLocalId(K))===Q&&!((Te=this.collector)!=null&&Te.isOwn(K))}).map(K=>{var ae;return(ae=this.collector)==null?void 0:ae.storage[this.viewId][i][K]});let Z=!1;for(const K of G)for(let ae=0;ae<X.length;ae++)K!=null&&K.selectIds&&((S=K.selectIds)!=null&&S.includes(X[ae]))&&(delete X[ae],Z=!0);Z&&(H.selectIds=X.filter(K=>!!K))}}(w=this.collector)==null||w.updateValue(O,H,{isAfterUpdate:!0,viewId:this.viewId,scenePath:i,isSync:!0})}else if(!e&&Array.isArray(z)&&z.length===2){const H=z[0];if((C=H.updateNodeOpt)!=null&&C.useAnimation&&(H.updateNodeOpt.useAnimation=!1),((L=this.collector)==null?void 0:L.getLocalId(A.key))===Q&&((j=this.collector)!=null&&j.isOwn(A.key))){const X=H.selectIds;if(X){const G=_.filter(K=>{var ae,Te;return((ae=this.collector)==null?void 0:ae.getLocalId(K))===Q&&!((Te=this.collector)!=null&&Te.isOwn(K))}).map(K=>{var ae;return(ae=this.collector)==null?void 0:ae.storage[this.viewId][i][K]});let Z=!1;for(const K of G)for(let ae=0;ae<X.length;ae++)K!=null&&K.selectIds&&K.selectIds.includes(X[ae])&&(delete X[ae],Z=!0);Z&&(H.selectIds=X.filter(K=>!!K))}}(E=this.collector)==null||E.updateValue(A.key,H,{isAfterUpdate:!0,viewId:this.viewId,scenePath:i,isSync:!0})}}break}}}};y(ct,"sdkCallBack"),y(ct,"MaxStackLength",20),y(ct,"waitTime",100);let is=ct;function GM(a){return a instanceof TouchEvent||a instanceof window.TouchEvent||(a==null?void 0:a.touches)&&(a==null?void 0:a.touches.length)||(a==null?void 0:a.changedTouches)&&(a==null?void 0:a.changedTouches.length)}function vt(a){return GM(a)&&(a.touches&&a.touches.length===1||a.changedTouches&&a.changedTouches.length===1)}function Jo(a){return a.touches&&a.touches.length?{x:a.touches[0].pageX,y:a.touches[0].pageY}:a.changedTouches&&a.changedTouches.length?{x:a.changedTouches[0].pageX,y:a.changedTouches[0].pageY}:{x:a.pageX,y:a.pageY}}class It{constructor(s){y(this,"internalMsgEmitter");y(this,"control");y(this,"mainView");y(this,"appViews",new Map);const{control:e,internalMsgEmitter:t}=s;this.control=e,this.internalMsgEmitter=t,this.internalMsgEmitter.on("addUndoTicker",this.undoTickerStart.bind(this)),this.internalMsgEmitter.on("excludeIds",this.addExcludeIds.bind(this))}undoTickerStart(s,e){const t=this.getView(e);t&&t.displayer&&t.focusScenePath&&t.displayer.commiter.undoTickerStart(s,t.focusScenePath)}addExcludeIds(s,e){const t=this.getView(e);t&&t.displayer&&t.focusScenePath&&t.displayer.commiter.addExcludeIds(s)}undo(){const s=this.focuedView;let e=0;if(s){const t=s.focusScenePath;e=s.displayer.commiter.undo(t)||0}return e}redo(){const s=this.focuedView;let e=0;if(s){const t=s.focusScenePath;e=s.displayer.commiter.redo(t)||0}return e}validator(s,e,t){var n;const i=D.clone(s[e]),o=D.clone(t);e==="focusScenePath"&&t&&!D.isEqual(i,o)&&(this.control.internalSceneChange(s.id,o),(n=this.focuedView)==null||n.displayer.commiter.onChangeScene()),e==="cameraOpt"&&!D.isEqual(i,o)&&this.control.internalCameraChange(s.id,o)}destroyAppView(s,e=!1){const t=this.appViews.get(s);t&&(this.control.textEditorManager.clear(s,e),t.displayer.destroy(),this.appViews.delete(s))}createMianView(s){this.mainView=new Proxy(s,{set:(e,t,i)=>(this.control.worker.isActive&&this.validator(e,t,i),e[t]=i,!0)})}createAppView(s){const e=s.id,t=new Proxy(s,{set:(i,o,n)=>(this.control.worker.isActive&&this.validator(i,o,n),i[o]=n,!0)});this.appViews.set(e,t)}isAppView(s){return s!==de&&this.appViews.has(s)}getView(s){var e;return s===de?this.mainView:(e=this.appViews)==null?void 0:e.get(s)}getCurScenePath(s){const e=this.getView(s);if(e)return e.focusScenePath}getAllViews(){return[this.mainView,...this.appViews.values()]}setViewScenePath(s,e){var t;if(s===de&&this.mainView)this.mainView.focusScenePath=e;else{const i=s&&((t=this.appViews)==null?void 0:t.get(s))||void 0;i&&(i.focusScenePath=e)}}setViewData(s,e){var t;if(s===de&&this.mainView)this.mainView.viewData=e;else{const i=s&&((t=this.appViews)==null?void 0:t.get(s))||void 0;i&&(i.viewData=e)}}setFocuedViewId(s){var e;this.focuedViewId=s,s===de?this.focuedView=this.mainView:this.focuedView=s&&((e=this.appViews)==null?void 0:e.get(s))||void 0,this.control.cursor.onFocusViewChange(),this.focuedView&&this.focuedView.displayer.commiter.onFocusView()}setViewFocusScenePath(s,e){var i;let t;s===de?t=this.mainView:t=(i=this.appViews)==null?void 0:i.get(s),t&&(t.focusScenePath=e)}destroy(){var s;this.internalMsgEmitter.removeAllListeners("addUndoTicker"),this.internalMsgEmitter.removeAllListeners("excludeIds"),(s=this.mainView)==null||s.displayer.destroy(),this.control.destroyMiniMap(de),this.appViews.forEach(e=>{this.destroyAppView(e.id,!0),this.control.worker.destroyViewWorker(e.id),this.control.destroyMiniMap(e.id)})}setFocuedViewCameraOpt(s){if(this.focuedView){const e=this.focuedView.cameraOpt;D.isEqual(e,s)||(this.focuedView.cameraOpt=s)}}transformToOriginPoint(s,e){const t=this.getView(e);if(t!=null&&t.viewData){const i=t.viewData.convertToPointOnScreen(s[0],s[1]);return[i.x,i.y]}return s}transformToScenePoint(s,e){const t=this.getView(e);if(t!=null&&t.viewData){const i=t.viewData.convertToPointInWorld({x:s[0],y:s[1]});return[i.x,i.y]}return s}render(s){var e,t,i,o,n,r,c,l,h,u,d,f,g,p,m,N,v;for(const T of s){const{rect:k,imageBitmap:S,isClear:w,isUnClose:C,drawCanvas:L,clearCanvas:j,viewId:E}=T,A=(e=this.getView(E))==null?void 0:e.displayer;if(A&&k){const{dpr:W,canvasBgRef:z,canvasFloatRef:O,canvasServiceFloatRef:se,canvasTopRef:_}=A,H=Math.floor(k.w*W),X=Math.floor(k.h*W),G=k.x*W,Z=k.y*W;if(w){switch(j){case ye.TopFloat:(i=(t=_.current)==null?void 0:t.getContext("2d"))==null||i.clearRect(G,Z,H,X);break;case ye.Float:(n=(o=O.current)==null?void 0:o.getContext("2d"))==null||n.clearRect(G,Z,H,X);break;case ye.ServiceFloat:(c=(r=se.current)==null?void 0:r.getContext("2d"))==null||c.clearRect(G,Z,H,X);break;case ye.Bg:(h=(l=z.current)==null?void 0:l.getContext("2d"))==null||h.clearRect(G,Z,H,X);break}continue}if(L&&S)switch(L){case ye.TopFloat:(d=(u=_.current)==null?void 0:u.getContext("2d"))==null||d.drawImage(S,0,0,H,X,G,Z,H,X);break;case ye.Float:{(g=(f=O.current)==null?void 0:f.getContext("2d"))==null||g.drawImage(S,0,0,H,X,G,Z,H,X);break}case ye.ServiceFloat:{(m=(p=se.current)==null?void 0:p.getContext("2d"))==null||m.drawImage(S,0,0,H,X,G,Z,H,X);break}case ye.Bg:{(v=(N=z.current)==null?void 0:N.getContext("2d"))==null||v.drawImage(S,0,0,H,X,G,Z,H,X);break}}if(C)continue;S==null||S.close()}}}showFloatBar(s,e,t){const i=this.getView(s),o=i==null?void 0:i.displayer.vDom;o&&o.showFloatBar(e,t)}setActiveTextEditor(s,e){const t=this.getView(s),i=t==null?void 0:t.displayer.vDom;i&&i.setActiveTextEditor(e)}setActiveMiniMap(s,e){const t=this.getView(s),i=t==null?void 0:t.displayer.vDom;i&&i.setActiveMiniMap(e&&s||void 0)}}y(It,"defaultCameraOpt",{centerX:0,centerY:0,scale:1}),y(It,"defaultScreenCanvasOpt",{autoRender:!1,contextType:"webgl2"}),y(It,"defaultLayerOpt",{offscreen:!0,handleEvent:!1,depth:!1});class ZM{constructor(s,e,t){y(this,"viewId");y(this,"control");y(this,"internalMsgEmitter");y(this,"commiter");y(this,"cachePoint");y(this,"cacheCursorPoint");y(this,"active",!0);y(this,"mousedown",s=>{if(this.active&&s.button===0&&this.viewId){this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const e=this.getPoint(s);this.cachePoint=e,e&&this.control.worker.originalEventLintener(P.Start,e,this.viewId)}});y(this,"mousemove",s=>{if(this.active&&this.viewId){const e=this.getPoint(s);this.cachePoint=e,e&&this.control.worker.originalEventLintener(P.Doing,e,this.viewId)}});y(this,"mouseup",s=>{if(this.active&&s.button===0&&this.viewId){const e=this.getPoint(s)||this.cachePoint;e&&this.control.worker.originalEventLintener(P.Done,e,this.viewId),this.cachePoint=void 0}});y(this,"touchstart",s=>{var e;if(this.active){if(!vt(s)){this.control.worker.unWritable(),this.viewId&&this.control.worker.removeDrawingWork(this.viewId);return}if(this.viewId){if(!this.control.worker.isAbled()){const i=(e=this.control.worker.getCurrentToolsData())==null?void 0:e.toolsType;i&&this.control.effectViewContainer(i)}this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(s);this.cachePoint=t,t&&this.control.worker.originalEventLintener(P.Start,t,this.viewId)}}});y(this,"touchmove",s=>{if(this.active){if(!vt(s)){this.control.worker.unWritable(),this.control.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const e=this.getPoint(s);this.cachePoint=e,e&&this.control.worker.originalEventLintener(P.Doing,e,this.viewId)}}});y(this,"touchend",s=>{if(this.active){if(!vt(s)||!this.control.worker.isAbled()){this.control.worker.unWritable(),this.control.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const e=this.getPoint(s)||this.cachePoint;e&&this.control.worker.originalEventLintener(P.Done,e,this.viewId),this.cachePoint=void 0}}});y(this,"cursorMouseMove",D.throttle(s=>{const e=this.getPoint(s);this.cacheCursorPoint&&D.isEqual(e,this.cacheCursorPoint)||!this.viewId||(this.cacheCursorPoint=e,e&&this.control.worker.sendCursorEvent(e,this.viewId))},30,{leading:!1}));y(this,"cursorMouseLeave",D.throttle(()=>{this.viewId&&(this.cacheCursorPoint=[void 0,void 0],this.control.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId))},30,{leading:!1}));y(this,"keydown",s=>{this.control.hotkeyManager.colloctHotkey(s)});this.viewId=s,this.control=e,this.internalMsgEmitter=t;const i={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:this.viewId};this.commiter=new is(i)}bindToolsClass(){var e,t;const s=(t=(e=this.control.worker)==null?void 0:e.currentToolsData)==null?void 0:t.toolsType;switch(s){case I.Text:case I.Pencil:case I.LaserPen:case I.Arrow:case I.Straight:case I.Rectangle:case I.Ellipse:case I.Star:case I.Polygon:case I.SpeechBalloon:case I.Eraser:case I.PencilEraser:case I.BitMapEraser:this.eventTragetElement&&(this.eventTragetElement.className=`netless-whiteboard ${s===I.Text?"cursor-text":s===I.Eraser||s===I.PencilEraser||s===I.BitMapEraser?"cursor-eraser":s===I.Pencil||s===I.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([te.Cursor,this.viewId])}getPoint(s){const e=Jo(s);if(e&&D.isNumber(e.x)&&D.isNumber(e.y))return[e.x-this.containerOffset.x,e.y-this.containerOffset.y]}getActive(){this.active=!0}setActive(s){this.active=s}async stopEventHandler(){this.cachePoint&&(await this.control.worker.originalEventLintener(P.Done,this.cachePoint,this.viewId),this.cachePoint=void 0)}getTranslate(s){const t=(s.style.WebkitTransform||getComputedStyle(s,"").getPropertyValue("-webkit-transform")||s.style.transform||getComputedStyle(s,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),i=t&&parseInt(t[0])||0,o=t&&parseInt(t[1])||0;return[i,o]}getContainerOffset(s,e){var o;const t=this.getTranslate(s);let i={x:e.x+s.offsetLeft+t[0],y:e.y+s.offsetTop+t[1]};return(o=s.offsetParent)!=null&&o.nodeName&&s.offsetParent.nodeName!=="BODY"&&(i=this.getContainerOffset(s.offsetParent,i)),i}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 Ko{constructor(s,e){y(this,"viewId",de);y(this,"control");y(this,"internalMsgEmitter");y(this,"commiter");y(this,"cachePoint");y(this,"cacheCursorPoint");y(this,"active",!0);y(this,"mousedown",s=>{if(this.active&&s.button===0){this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const e=this.getPoint(s);this.cachePoint=e,e&&this.control.worker.originalEventLintener(P.Start,e,this.viewId)}});y(this,"mousemove",s=>{if(!this.active)return;const e=this.getPoint(s);this.cachePoint=e,e&&this.control.worker.originalEventLintener(P.Doing,e,this.viewId)});y(this,"mouseup",s=>{if(this.active&&s.button===0){const e=this.getPoint(s)||this.cachePoint;e&&this.control.worker.originalEventLintener(P.Done,e,this.viewId),this.cachePoint=void 0}});y(this,"touchstart",s=>{var t;if(!this.active)return;if(!vt(s)){this.control.worker.unWritable(),this.viewId&&this.control.worker.removeDrawingWork(this.viewId);return}if(!this.control.worker.isAbled()){const i=(t=this.control.worker.getCurrentToolsData())==null?void 0:t.toolsType;i&&this.control.effectViewContainer(i)}this.control.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const e=this.getPoint(s);this.cachePoint=e,e&&this.control.worker.originalEventLintener(P.Start,e,this.viewId)});y(this,"touchmove",s=>{if(!this.active)return;if(!vt(s)){this.control.worker.unWritable(),this.viewId&&this.control.worker.removeDrawingWork(this.viewId);return}const e=this.getPoint(s);this.cachePoint=e,e&&this.control.worker.originalEventLintener(P.Doing,e,this.viewId)});y(this,"touchend",s=>{if(!this.active)return;if(!vt(s)||!this.control.worker.isAbled()){this.control.worker.removeDrawingWork(this.viewId);return}const e=this.getPoint(s)||this.cachePoint;e&&this.control.worker.originalEventLintener(P.Done,e,this.viewId),this.cachePoint=void 0});y(this,"cursorMouseMove",D.throttle(s=>{const e=this.getPoint(s);this.cacheCursorPoint&&D.isEqual(e,this.cacheCursorPoint)||(this.cacheCursorPoint=e,e&&this.control.worker.sendCursorEvent(e,this.viewId))},30,{leading:!1}));y(this,"cursorMouseLeave",D.throttle(()=>{this.cacheCursorPoint=[void 0,void 0],this.control.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId)},30,{leading:!1}));y(this,"keydown",s=>{this.control.hotkeyManager.colloctHotkey(s)});this.control=s,this.internalMsgEmitter=e;const t={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:this.viewId};this.commiter=new is(t)}bindToolsClass(){var i,o;const s=(o=(i=this.control.worker)==null?void 0:i.currentToolsData)==null?void 0:o.toolsType,e=this.control.renderControl.isWriteable(),t=this.control.worker.isAbled();switch(s){case I.Text:case I.Pencil:case I.LaserPen:case I.Arrow:case I.Straight:case I.Rectangle:case I.Ellipse:case I.Star:case I.Polygon:case I.SpeechBalloon:case I.Eraser:case I.PencilEraser:case I.BitMapEraser:this.eventTragetElement&&(this.eventTragetElement.className=e&&t?`netless-whiteboard ${s===I.Text?"cursor-text":s===I.Eraser||s===I.PencilEraser||s===I.BitMapEraser?"cursor-eraser":s===I.Pencil||s===I.LaserPen?"cursor-pencil":"cursor-arrow"}`:"netless-whiteboard");break}}mountView(){this.setCanvassStyle(),this.control.viewContainerManager.mountView(this.viewId)}updateSize(){this.setCanvassStyle()}reflashContainerOffset(){this.eventTragetElement&&(this.containerOffset=this.getContainerOffset(this.eventTragetElement,{x:0,y:0}))}destroy(){this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.destroy(),this.internalMsgEmitter.removeAllListeners([te.Cursor,this.viewId])}getPoint(s){const e=Jo(s);if(e&&D.isNumber(e.x)&&D.isNumber(e.y))return[e.x-this.containerOffset.x,e.y-this.containerOffset.y]}getActive(){return this.active}setActive(s){this.active=s}async stopEventHandler(){this.cachePoint&&(await this.control.worker.originalEventLintener(P.Done,this.cachePoint,this.viewId),this.cachePoint=void 0)}getTranslate(s){const t=(s.style.WebkitTransform||getComputedStyle(s,"").getPropertyValue("-webkit-transform")||s.style.transform||getComputedStyle(s,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),i=t&&parseInt(t[0])||0,o=t&&parseInt(t[1])||0;return[i,o]}getContainerOffset(s,e){var o;const t=this.getTranslate(s);let i={x:e.x+s.offsetLeft+t[0],y:e.y+s.offsetTop+t[1]};return(o=s.offsetParent)!=null&&o.nodeName&&s.offsetParent.nodeName!=="BODY"&&(i=this.getContainerOffset(s.offsetParent,i)),i}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 qM="index-module__Container__nLsM3",XM="index-module__CanvasBox__j2Xe-",JM="index-module__FloatCanvas__d1YR7",KM="index-module__TopFloatCanvas__7IaCw",_M="index-module__CanvasBoxSub__hcMeK",em="index-module__SnapshotBox__--eeE",tm="index-module__FloatBar__cm-EL",sm="index-module__RotateBtn__HSSkf",im="index-module__ResizeBtn__yjvda",om="index-module__CursorBox__2UHvI",nm="index-module__TextEditorContainer__Qm8KC",rm="index-module__ResizeTowBox__HOllX",am="index-module__FloatBarBtn__FJrOG",Pe={Container:qM,CanvasBox:XM,FloatCanvas:JM,TopFloatCanvas:KM,CanvasBoxSub:_M,SnapshotBox:em,FloatBar:tm,RotateBtn:sm,ResizeBtn:im,CursorBox:om,TextEditorContainer:nm,ResizeTowBox:rm,FloatBarBtn:am},cm={delete:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDZ2NmEyIDIgMCAwIDEtMiAySDZhMiAyIDAgMCAxLTItMlY2aDBtMS0yYTIgMiAwIDAgMSA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xMjUgMTJjMC0yLjI3MS44NjYtNC41NDMgMi42LTYuMjc2eiIgc3Ryb2tlPSIjRkZGIiBzdHJva2Utd2lkdGg9Ii41IiBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L2c+PC9zdmc+","font-colors-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTQgMTEgNC05IDQgOU02IDdoNCIgc3Ryb2tlPSIjMzM4MUZGIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","font-colors":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTQgMTEgNC05IDQgOU02IDdoNCIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","to-bottom":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDEwdjhtMCAwLTItMm0yIDIgMi0ybS00IDZoMTJtLTYtNGg2bS02LTRoNm0tNi00aDYiIHN0cm9rZT0iIzQ0NEU2MCIgZmlsbD0ibm9uZSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PC9zdmc+","to-top":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDIydi04bTAgMC0yIDJtMi0yIDIgMm0tNC02aDEybS02IDRoNm0tNiA0aDZtLTYgNGg2IiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","bold-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQuNSAySDhhMi41IDIuNSAwIDAgMSAwIDVINS41aDBtLTEgMGg0YTMgMyAwIDAgMSAwIDZoLTQgMG0wIDFWMiIgc3Ryb2tlPSIjMzM4MUZGIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=",bold:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQuNSAySDhhMi41IDIuNSAwIDAgMSAwIDVINS41aDBtLTEgMGg0YTMgMyAwIDAgMSAwIDZoLTQgMG0wIDFWMiIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","underline-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDJ2NWE0IDQgMCAxIDEtOCAwVjJoME0zIDE0aDEwIiBzdHJva2U9IiMzMzgxRkYiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCI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}const lm=a=>{const{workIds:s,mananger:e}=a;return M.createElement("div",{className:"button normal-button",style:{touchAction:"none"},onPointerUp:t=>{t.cancelable&&t.preventDefault(),t.stopPropagation(),oe.emitMethod(te.MainEngine,F.DeleteNode,{workIds:s||[Q],viewId:e.viewId})}},M.createElement("img",{alt:"icon",src:xe("delete")}))},hm=a=>{const{workIds:s,viewId:e}=a;return M.createElement("div",{className:"button normal-button",onPointerUp:t=>{t.stopPropagation(),oe.emitMethod(te.MainEngine,F.CopyNode,{workIds:s||[Q],viewId:e})}},M.createElement("img",{alt:"icon",src:xe("duplicate")}))},Zi=a=>{const{icon:s,onPointerUpHandler:e}=a;return M.createElement("div",{className:"button normal-button",onPointerUp:e},M.createElement("img",{src:xe(s)}))},um=a=>{const{open:s,setOpen:e,floatBarRef:t}=a,{floatBarData:i,mananger:o}=M.useContext(Ie),[n,r]=M.useState([]),c=M.useMemo(()=>{if(t!=null&&t.current&&D.isNumber(i==null?void 0:i.y)&&(o!=null&&o.height)){if(t.current.offsetTop&&t.current.offsetTop+i.y>180){const u={};return u.top="inherit",u.bottom=50,u}else if(!t.current.offsetTop&&(o==null?void 0:o.height)-t.current.offsetTop-i.y<120){const u={};return u.top="inherit",u.bottom=50,u}}},[t==null?void 0:t.current,i,o]),l=M.useMemo(()=>s?M.createElement("div",{className:"image-layer-menu",style:c},M.createElement(Zi,{icon:"to-top",onPointerUpHandler:u=>{u.stopPropagation(),oe.emitMethod(te.MainEngine,F.ZIndexNode,{workIds:[Q],layer:Et.Top,viewId:o==null?void 0:o.viewId})}}),M.createElement(Zi,{icon:"to-bottom",onPointerUpHandler:u=>{u.stopPropagation(),oe.emitMethod(te.MainEngine,F.ZIndexNode,{workIds:[Q],layer:Et.Bottom,viewId:o==null?void 0:o.viewId})}})):null,[s,c]),h=u=>{u.stopPropagation(),u.nativeEvent.stopImmediatePropagation(),e(!s)};return M.useEffect(()=>{D.isEqual(i==null?void 0:i.selectIds,n)||i!=null&&i.selectIds&&!D.isEqual(i==null?void 0:i.selectIds,n)&&(r(i==null?void 0:i.selectIds),e(!1))},[s,i,n,e]),M.createElement("div",{className:`button normal-button ${s&&"active"}`,onPointerUp:h},l,M.createElement("img",{alt:"icon",src:xe(s?"layer-pressed":"layer")}))},dm=()=>M.createElement("svg",{style:{marginLeft:"2px"},viewBox:"0 0 1025 1024",width:"14",height:"14"},M.createElement("path",{d:"M1016.5248 493.8752c-9.984-9.984-26.2144-9.984-36.1984 0l-183.6032 183.6032c-29.952 29.952-78.6944 29.952-108.5952 0l-239.2064-239.2064c-14.4384-14.4384-22.3744-33.6896-22.3744-54.3232s7.936-39.8848 22.3744-54.3232l183.6032-183.6032c9.984-9.984 9.984-26.2144 0-36.1984s-26.2144-9.984-36.1984 0l-183.6032 183.6032c-24.1152 24.1152-37.376 56.2176-37.376 90.5216 0 14.592 2.4576 28.8256 7.0656 42.1888l-374.8864 374.8864c-4.8128 4.8128-7.4752 11.3152-7.4752 18.1248l0 76.8c0 14.1312 11.4688 25.6 25.6 25.6l486.4 0c6.8096 0 13.312-2.7136 18.1248-7.4752l170.0864-170.0864c13.3632 4.6592 27.5968 7.0656 42.1888 7.0656 34.2528 0 66.4064-13.2608 90.5216-37.376l183.6032-183.6032c9.984-9.984 9.984-26.2144 0-36.1984zM501.4016 870.4l-450.2016 0 0-40.6016 358.5024-358.5024c1.024 1.0752 1.9968 2.1504 3.0208 3.1744l239.2064 239.2064c1.024 1.024 2.0992 2.048 3.1744 3.0208l-153.7024 153.7024z",fill:"#000000"})),_o=a=>{const{activeColor:s,onPointerUpHandler:e}=a;return M.createElement("div",{className:`font-color-button ${s==="transparent"?"active":""}`,onPointerUp:e},M.createElement("div",{className:"circle none"}))},Ms=a=>{const{color:s,activeColor:e,onPointerUpHandler:t}=a;return M.createElement("div",{className:`font-color-button ${s===e?"active":""}`,onPointerUp:t},M.createElement("div",{className:"circle",style:{backgroundColor:Se(s,1)}}))},ms=a=>{const{opacity:s,activeColor:e,setCurOpacity:t}=a,[i,o]=M.useState({x:108,y:0});if(M.useEffect(()=>{o({x:s*100+8,y:0})},[]),!e)return null;const n=D.throttle((l,h)=>{l.cancelable&&l.preventDefault(),l.stopPropagation(),h.x!==(i==null?void 0:i.x)&&o({x:h.x,y:0});const u=Math.min(Math.max(h.x-8,0),100)/100;s!==u&&t(u,e,P.Doing)},100,{trailing:!0}),r=l=>{l.cancelable&&l.preventDefault(),l.stopPropagation(),t(s,e,P.Start)},c=(l,h)=>{n.cancel(),l.cancelable&&l.preventDefault(),l.stopPropagation(),h.x!==(i==null?void 0:i.x)&&o({x:h.x,y:0});const u=Math.min(Math.max(h.x-8,0),100)/100;t(u,e,P.Done)};return M.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;o({x:u*100+8,y:0}),t(u,e,P.Done)}},M.createElement("div",{className:"range-color",style:{background:`linear-gradient(to right, ${Se(e,0)}, ${Se(e,1)})`}}),M.createElement("div",{className:"range-opacity"},M.createElement(Nt,{bounds:"parent",axis:"x",position:i,onDrag:n,onStart:r,onStop:c},M.createElement("div",{className:"circle",style:{backgroundColor:Se(e,s)},onClick:l=>{l.cancelable&&l.preventDefault(),l.stopPropagation()}}))))},pm=a=>{const{min:s,max:e,activeNumber:t,setActiveNumber:i,color:o}=a,[n,r]=M.useState({x:108,y:0});if(M.useEffect(()=>{const u=Math.ceil((t-s)/(e-s)*100)+8;r({x:u,y:0})},[]),!t)return null;const c=D.throttle((u,d)=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),d.x!==(n==null?void 0:n.x)&&r({x:d.x,y:0});const f=Math.ceil(Math.max(d.x-8,0)/100*(e-s)+s);t!==f&&i(f,P.Doing)},100,{trailing:!0}),l=u=>{u.cancelable&&u.preventDefault(),u.stopPropagation(),i(t,P.Start)},h=(u,d)=>{c.cancel(),u.cancelable&&u.preventDefault(),u.stopPropagation(),d.x!==(n==null?void 0:n.x)&&r({x:d.x,y:0});const f=Math.ceil(Math.max(d.x-8,0)/100*(e-s)+s);i(f,P.Done)};return M.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onClick:u=>{const d=u.nativeEvent.offsetX,f=Math.ceil(Math.max(d-12,0)/100*(e-s)+s),g=Math.ceil((f-s)/(e-s)*100)+8;r({x:g,y:0}),i(f,P.Done)}},M.createElement("div",{className:"range-color",style:{backgroundColor:o}}),M.createElement("div",{className:"range-opacity"},M.createElement(Nt,{bounds:"parent",axis:"x",position:n,onDrag:c,onStart:l,onStop:h},M.createElement("div",{className:"circle",style:{backgroundColor:o},onClick:u=>{u.cancelable&&u.preventDefault(),u.stopPropagation()}},M.createElement("div",{className:"range-opacity-data-icon"},t)))))},fm=a=>{const{useStroke:s,color:e,activeStrokeType:t,setStrokeType:i}=a;return M.createElement("div",{className:"stroke-type-box"},!!s&&M.createElement("div",{className:`stroke-type-box-item Stroke ${t===ee.Stroke&&"active"}`,style:{backgroundColor:e},onPointerUp:()=>{i(ee.Stroke)}}),M.createElement("div",{className:`stroke-type-box-item Normal ${t===ee.Normal&&"active"}`,style:{borderColor:e},onPointerUp:()=>{i(ee.Normal)}}),M.createElement("div",{className:`stroke-type-box-item Dotted ${t===ee.Dotted&&"active"}`,style:{borderColor:e},onPointerUp:()=>{i(ee.Dotted)}}),M.createElement("div",{className:`stroke-type-box-item LongDotted ${t===ee.LongDotted&&"active"}`,style:{borderColor:e},onPointerUp:()=>{i(ee.LongDotted)}}))},gm=a=>{const{open:s,setOpen:e,floatBarRef:t}=a,{floatBarData:i,floatBarColors:o,mananger:n,setFloatBarData:r}=M.useContext(Ie),[c,l]=M.useState(),[h,u]=M.useState(1);M.useEffect(()=>{if(i!=null&&i.strokeColor){const[v,T]=ys(i.strokeColor);l(v),u(T)}},[i]);const d=M.useMemo(()=>{if(t!=null&&t.current&&D.isNumber(i==null?void 0:i.y)&&(n!=null&&n.height)){if(t.current.offsetTop&&t.current.offsetTop+i.y>180){const v={};return v.top="inherit",v.bottom=50,v}else if(!t.current.offsetTop&&(n==null?void 0:n.height)-t.current.offsetTop-i.y<120){const v={};return v.top="inherit",v.bottom=50,v}}},[(t==null?void 0:t.current)&&i,n==null?void 0:n.height]),f=M.useMemo(()=>M.createElement(ms,{key:"strokeColors",opacity:h,activeColor:c,setCurOpacity:(v,T,k)=>{k===P.Start&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!0),k===P.Done&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!1),u(v);const S=Se(T,v);i!=null&&i.strokeColor&&r({strokeColor:S}),oe.emitMethod(te.MainEngine,F.SetColorNode,{workIds:[Q],strokeColor:S,workState:k,viewId:n==null?void 0:n.viewId})}}),[h,c,n==null?void 0:n.control.room,n==null?void 0:n.viewId,i]),g=M.useMemo(()=>{var v,T;return c&&(i!=null&&i.thickness)?M.createElement(pm,{key:"strokeThickness",min:Math.min(i.thickness,((v=n==null?void 0:n.control.pluginOptions.strokeWidth)==null?void 0:v.min)||1),max:Math.max(i.thickness,((T=n==null?void 0:n.control.pluginOptions.strokeWidth)==null?void 0:T.max)||10),activeNumber:i.thickness,setActiveNumber:(k,S)=>{S===P.Start&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!0),S===P.Done&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!1),i!=null&&i.thickness&&r({thickness:k}),oe.emitMethod(te.MainEngine,F.SetColorNode,{workIds:[Q],thickness:k,workState:S,viewId:n==null?void 0:n.viewId})},color:c}):null},[c,i==null?void 0:i.thickness,n==null?void 0:n.control.room,n==null?void 0:n.viewId]),p=M.useMemo(()=>c&&(i!=null&&i.strokeType)?M.createElement(fm,{key:"strokeType",useStroke:i==null?void 0:i.useStroke,activeStrokeType:i.strokeType,setStrokeType:v=>{i.strokeType&&r({strokeType:v}),oe.emitMethod(te.MainEngine,F.SetColorNode,{workIds:[Q],strokeType:v,workState:P.Done,viewId:n==null?void 0:n.viewId})},color:c}):null,[c,i==null?void 0:i.strokeType,n==null?void 0:n.control.room,n==null?void 0:n.viewId,i==null?void 0:i.useStroke]),m=M.useMemo(()=>s?M.createElement("div",{className:"font-colors-menu",style:d,onPointerUp:v=>{v.stopPropagation(),v.nativeEvent.stopImmediatePropagation()}},p,g,M.createElement("div",{className:"font-colors-line"}),o.concat().map((v,T)=>{const k=Ut(...v);return M.createElement(Ms,{key:T,color:k,activeColor:c,onPointerUpHandler:S=>{S.stopPropagation(),l(k);const w=Se(k,h);i!=null&&i.strokeColor&&(i.strokeColor=w,r({strokeColor:w})),oe.emitMethod(te.MainEngine,F.SetColorNode,{workIds:[Q],workState:P.Done,strokeColor:w,viewId:n==null?void 0:n.viewId})}})}),f):null,[s,o,f,c,h,i,n==null?void 0:n.viewId,d]),N=M.useMemo(()=>c?M.createElement("div",{className:"color-bar-ring",style:{backgroundColor:Se(c,h)}},M.createElement("div",{className:"circle"})):null,[c,h]);return M.createElement("div",{className:`button normal-button font-colors-icon ${s&&"active"}`,onPointerUp:v=>{v.stopPropagation(),v.nativeEvent.stopImmediatePropagation(),e(!s)}},N,m)},ym=a=>{const{open:s,setOpen:e,floatBarRef:t}=a,{floatBarData:i,floatBarColors:o,mananger:n,setFloatBarData:r}=M.useContext(Ie),[c,l]=M.useState(),[h,u]=M.useState(1);M.useEffect(()=>{if(i!=null&&i.fillColor){const[m,N]=(i==null?void 0:i.fillColor)==="transparent"&&["transparent",1]||ys(i.fillColor);l(m),u(N)}},[i]);const d=M.useMemo(()=>{if(t!=null&&t.current&&D.isNumber(i==null?void 0:i.y)&&(n!=null&&n.height)){if(t.current.offsetTop&&t.current.offsetTop+i.y>200){const m={};return m.top="inherit",m.bottom=50,m}else if(!t.current.offsetTop&&(n==null?void 0:n.height)-t.current.offsetTop-i.y<140){const m={};return m.top="inherit",m.bottom=50,m}}},[t==null?void 0:t.current,i,n==null?void 0:n.height]),f=M.useMemo(()=>c&&c!=="transparent"?M.createElement(ms,{key:"fillColors",opacity:h||0,activeColor:c,setCurOpacity:(m,N,v)=>{v===P.Start&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!0),v===P.Done&&(n!=null&&n.control.room)&&(n.control.room.disableDeviceInputs=!1),u(m);const T=Se(N,m);i!=null&&i.fillColor&&(i.fillColor=T,r({fillColor:T})),oe.emitMethod(te.MainEngine,F.SetColorNode,{workIds:[Q],fillColor:c&&Se(N,m),workState:v,viewId:n==null?void 0:n.viewId})}}):null,[c,h,n==null?void 0:n.control.room,n==null?void 0:n.viewId,i]),g=M.useMemo(()=>s?M.createElement("div",{className:"font-colors-menu",style:d,onPointerUp:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation()}},M.createElement(_o,{activeColor:c,onPointerUpHandler:m=>{m.stopPropagation(),l("transparent");const N="transparent";i!=null&&i.fillColor&&(i.fillColor=N,r({fillColor:N})),oe.emitMethod(te.MainEngine,F.SetColorNode,{workIds:[Q],workState:P.Done,fillColor:N,viewId:n==null?void 0:n.viewId})}}),o.map((m,N)=>{const v=Ut(...m);return M.createElement(Ms,{key:N,color:v,activeColor:c,onPointerUpHandler:T=>{T.cancelable&&T.preventDefault(),T.stopPropagation(),l(v);const k=Se(v,h);i!=null&&i.fillColor&&(i.fillColor=k,r({fillColor:k})),oe.emitMethod(te.MainEngine,F.SetColorNode,{workIds:[Q],workState:P.Done,fillColor:k,viewId:n==null?void 0:n.viewId})}})}),f):null,[s,c,o,f,i,n==null?void 0:n.viewId,h,d]),p=M.useMemo(()=>{const m=c&&c!=="transparent"&&Se(c,h)||"transparent";return M.createElement("div",{className:"color-bar-fill"},M.createElement("div",{className:"circle",style:{backgroundColor:m}}))},[c,h]);return M.createElement("div",{className:`button normal-button font-colors-icon ${s&&"active"}`,onPointerUp:m=>{m.stopPropagation(),m.nativeEvent.stopImmediatePropagation(),e(!s)}},p,g)},Mm=a=>{const{open:s,setOpen:e,textOpt:t,workIds:i,floatBarRef:o}=a,{floatBarColors:n,mananger:r,setFloatBarData:c,floatBarData:l}=M.useContext(Ie),[h,u]=M.useState(),[d,f]=M.useState(1);M.useEffect(()=>{if(t!=null&&t.fontColor){const[v,T]=(t==null?void 0:t.fontColor)==="transparent"&&["transparent",0]||ys(t.fontColor);u(v),f(T)}},[t==null?void 0:t.fontColor]);const g=M.useMemo(()=>{if(o!=null&&o.current&&D.isNumber(l==null?void 0:l.y)&&(r!=null&&r.height)){if(o.current.offsetTop&&o.current.offsetTop+l.y>180){const v={};return v.top="inherit",v.bottom=50,v}else if(!o.current.offsetTop&&(r==null?void 0:r.height)-o.current.offsetTop-l.y<120){const v={};return v.top="inherit",v.bottom=50,v}}},[o==null?void 0:o.current,l,r]),p=M.useMemo(()=>h&&h!=="transparent"?M.createElement(ms,{key:"fontColors",opacity:d,activeColor:h,setCurOpacity:(v,T,k)=>{k===P.Start&&(r!=null&&r.control.room)&&(r.control.room.disableDeviceInputs=!0),k===P.Done&&(r!=null&&r.control.room)&&(r.control.room.disableDeviceInputs=!1),f(v);const S=Se(T,v);l!=null&&l.textOpt&&(l.textOpt.fontColor=S,c({textOpt:l.textOpt})),oe.emitMethod(te.MainEngine,F.SetColorNode,{workIds:i||[Q],fontColor:h&&S,workState:k,viewId:r==null?void 0:r.viewId})}}):null,[h,d,r==null?void 0:r.control.room,r==null?void 0:r.viewId,l==null?void 0:l.textOpt,i]),m=M.useMemo(()=>s?M.createElement("div",{className:"font-colors-menu",style:g,onPointerUp:v=>{v.stopPropagation(),v.nativeEvent.stopImmediatePropagation()}},n.map((v,T)=>{const k=Ut(...v);return M.createElement(Ms,{key:T,color:k,activeColor:h,onPointerUpHandler:S=>{S.stopPropagation(),u(k);const w=Se(k,d);l!=null&&l.textOpt&&(l.textOpt.fontColor=w,c({textOpt:l.textOpt})),oe.emitMethod(te.MainEngine,F.SetColorNode,{workIds:i||[Q],workState:P.Done,fontColor:w,viewId:r==null?void 0:r.viewId})}})}),p):null,[s,n,p,h,d,l==null?void 0:l.textOpt,i,r==null?void 0:r.viewId,g]),N=M.useMemo(()=>{const v=h&&h!=="transparent"&&Se(h,d)||"transparent";return M.createElement("div",{className:"color-bar"},M.createElement("div",{className:"color-bar-color",style:{backgroundColor:v}}))},[h,d]);return M.createElement("div",{className:`button normal-button font-colors-icon ${s&&"active"}`,onPointerUp:v=>{v.stopPropagation(),v.nativeEvent.stopImmediatePropagation(),e(!s)}},M.createElement("img",{alt:"icon",src:xe("font-colors")}),N,m)},mm=a=>{const{open:s,setOpen:e,textOpt:t,workIds:i,floatBarRef:o}=a,{floatBarColors:n,mananger:r,setFloatBarData:c,floatBarData:l}=M.useContext(Ie),[h,u]=M.useState(),[d,f]=M.useState(1);M.useEffect(()=>{if(t!=null&&t.fontBgColor){const[v,T]=(t==null?void 0:t.fontBgColor)==="transparent"&&["transparent",1]||ys(t.fontBgColor);u(v),f(T)}},[t==null?void 0:t.fontBgColor]);const g=M.useMemo(()=>{if(o!=null&&o.current&&D.isNumber(l==null?void 0:l.y)&&(r!=null&&r.height)){if(o.current.offsetTop&&o.current.offsetTop+l.y>180){const v={};return v.top="inherit",v.bottom=50,v}else if(!o.current.offsetTop&&(r==null?void 0:r.height)-o.current.offsetTop-l.y<120){const v={};return v.top="inherit",v.bottom=50,v}}},[o==null?void 0:o.current,l,r]),p=M.useMemo(()=>h&&h!=="transparent"?M.createElement(ms,{key:"fontBgColor",opacity:d||0,activeColor:h,setCurOpacity:(v,T,k)=>{k===P.Start&&(r!=null&&r.control.room)&&(r.control.room.disableDeviceInputs=!0),k===P.Done&&(r!=null&&r.control.room)&&(r.control.room.disableDeviceInputs=!1),f(v);const S=Se(T,v);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=S,c({textOpt:l.textOpt})),oe.emitMethod(te.MainEngine,F.SetColorNode,{workIds:i||[Q],fontBgColor:h&&Se(T,v),workState:k,viewId:r==null?void 0:r.viewId})}}):null,[h,d,r==null?void 0:r.control.room,r==null?void 0:r.viewId,l==null?void 0:l.textOpt,i]),m=M.useMemo(()=>s?M.createElement("div",{className:"font-colors-menu",style:g,onPointerUp:v=>{v.stopPropagation(),v.nativeEvent.stopImmediatePropagation()}},M.createElement(_o,{activeColor:h,onPointerUpHandler:v=>{v.stopPropagation();const T="transparent";u(T),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=T,c({textOpt:l.textOpt})),oe.emitMethod(te.MainEngine,F.SetColorNode,{workIds:i||[Q],workState:P.Done,fontBgColor:T,viewId:r==null?void 0:r.viewId})}}),n.map((v,T)=>{const k=Ut(...v);return M.createElement(Ms,{key:T,color:k,activeColor:h,onPointerUpHandler:S=>{S.stopPropagation(),u(k);const w=Se(k,d);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=w,c({textOpt:l.textOpt})),oe.emitMethod(te.MainEngine,F.SetColorNode,{workIds:i||[Q],workState:P.Done,fontBgColor:Se(k,d),viewId:r==null?void 0:r.viewId})}})}),p):null,[s,n,p,d,h,l==null?void 0:l.textOpt,i,r==null?void 0:r.viewId,g]),N=M.useMemo(()=>{const v=h&&h!=="transparent"&&Se(h,d)||"transparent";return M.createElement("div",{className:"color-bar",style:{marginTop:0}},M.createElement("div",{className:"color-bar-color",style:{backgroundColor:v}}))},[h,d]);return M.createElement("div",{className:`button normal-button font-colors-icon ${s&&"active"}`,onPointerUp:v=>{v.stopPropagation(),v.nativeEvent.stopImmediatePropagation(),e(!s)}},M.createElement(dm,null),N,m)},wm=a=>{const{bold:s,setBold:e,workIds:t,viewId:i}=a,o=n=>{const r=s==="bold"?"normal":"bold";n==null||n.stopPropagation(),e(r),oe.emitMethod(te.MainEngine,F.SetFontStyle,{workIds:t,viewId:i,bold:r})};return M.createElement("div",{className:"font-style-button",onPointerUp:o},M.createElement("img",{alt:"icon",src:xe(s==="bold"?"bold-active":"bold")}))},vm=a=>{const{underline:s,setUnderline:e,workIds:t,viewId:i}=a,o=n=>{const r=!s;n==null||n.stopPropagation(),e(r),oe.emitMethod(te.MainEngine,F.SetFontStyle,{workIds:t,viewId:i,underline:r})};return M.createElement("div",{className:"font-style-button",onPointerUp:o},M.createElement("img",{alt:"icon",src:xe(s?"underline-active":"underline")}))},Im=a=>{const{lineThrough:s,setLineThrough:e,workIds:t,viewId:i}=a,o=n=>{const r=!s;n==null||n.stopPropagation(),e(r),oe.emitMethod(te.MainEngine,F.SetFontStyle,{workIds:t,viewId:i,lineThrough:r})};return M.createElement("div",{className:"font-style-button",onPointerUp:o},M.createElement("img",{alt:"icon",src:xe(s?"line-through-active":"line-through")}))},Nm=a=>{const{italic:s,setItalic:e,workIds:t,viewId:i}=a,o=n=>{const r=s==="italic"?"normal":"italic";n==null||n.stopPropagation(),e(r),oe.emitMethod(te.MainEngine,F.SetFontStyle,{workIds:t,viewId:i,italic:r})};return M.createElement("div",{className:"font-style-button",onPointerUp:o},M.createElement("img",{alt:"icon",src:xe(s==="italic"?"italic-active":"italic")}))},Sm=a=>{const{open:s,setOpen:e,textOpt:t,workIds:i,style:o,floatBarRef:n}=a,{mananger:r,floatBarData:c}=M.useContext(Ie),[l,h]=M.useState("normal"),[u,d]=M.useState("normal"),[f,g]=M.useState(!1),[p,m]=M.useState(!1);M.useEffect(()=>{t!=null&&t.bold&&h(t.bold),D.isBoolean(t==null?void 0:t.underline)&&g(t.underline||!1),D.isBoolean(t==null?void 0:t.lineThrough)&&m(t.lineThrough||!1),t!=null&&t.italic&&d(t.italic)},[t]);const N=M.useMemo(()=>{if(o&&(n!=null&&n.current)&&D.isNumber(c==null?void 0:c.y)&&(r!=null&&r.height)){if(n.current.offsetTop&&n.current.offsetTop+c.y>180){const T={};return T.top="inherit",T.bottom=50,T}else if(!n.current.offsetTop&&(r==null?void 0:r.height)-n.current.offsetTop-c.y<120){const T={};return T.top="inherit",T.bottom=50,T}}},[o,n==null?void 0:n.current,c,r]),v=M.useMemo(()=>s?M.createElement("div",{className:"font-style-menu",style:N,onPointerUp:T=>{T.stopPropagation(),T.nativeEvent.stopImmediatePropagation()}},M.createElement(wm,{workIds:i||[Q],bold:l,setBold:h,viewId:r==null?void 0:r.viewId}),M.createElement(vm,{workIds:i||[Q],underline:f,setUnderline:g,viewId:r==null?void 0:r.viewId}),M.createElement(Im,{workIds:i||[Q],lineThrough:p,setLineThrough:m,viewId:r==null?void 0:r.viewId}),M.createElement(Nm,{workIds:i||[Q],italic:u,setItalic:d,viewId:r==null?void 0:r.viewId})):null,[s,i,l,r==null?void 0:r.viewId,f,p,u,N]);return M.createElement("div",{className:`button normal-button ${s&&"active"}`,onPointerUp:T=>{T.stopPropagation(),T.nativeEvent.stopImmediatePropagation(),e(!s)}},M.createElement("img",{alt:"icon",src:xe(s?"font-style-active":"font-style")}),v)},Ge=Object.freeze([12,14,18,24,36,48,64,80,144,288]),ft=["top","topLeft","topRight","bottom","bottomLeft","bottomRight","left","leftTop","leftBottom","right","rightTop","rightBottom"],Tm=a=>{const{style:s,onClickHandler:e}=a;return M.createElement("div",{className:"font-size-menu",style:s,onPointerUp:t=>{t.stopPropagation(),t.nativeEvent.stopImmediatePropagation()}},Ge.map(t=>M.createElement("div",{className:"font-size-btn",key:t,onPointerUp:()=>{e(t)}},t)))},km=a=>{const s=M.useRef(null),{open:e,setOpen:t,textOpt:i,workIds:o,floatBarRef:n}=a,{mananger:r,floatBarData:c}=M.useContext(Ie),[l,h]=M.useState(0),[u,d]=M.useState(),f=Ge.length-1;M.useEffect(()=>{i!=null&&i.fontSize&&(h(i.fontSize),s.current&&(s.current.value=i.fontSize.toString()))},[i==null?void 0:i.fontSize]);const g=M.useMemo(()=>{if(n!=null&&n.current&&D.isNumber(c==null?void 0:c.y)&&(r!=null&&r.height)){if(n.current.offsetTop&&n.current.offsetTop+c.y>180){const T={};return T.top="inherit",T.bottom=35,T}else if(!n.current.offsetTop&&(r==null?void 0:r.height)-n.current.offsetTop-c.y<120){const T={};return T.top="inherit",T.bottom=35,T}}},[n==null?void 0:n.current,c,r]);function p(T){h(T),T&&T>=Ge[0]&&T<=Ge[f]&&oe.emitMethod(te.MainEngine,F.SetFontStyle,{workIds:o||[Q],fontSize:T,viewId:r==null?void 0:r.viewId})}const m=T=>{var k;(k=s.current)==null||k.blur(),t(!1),v(T)},N=M.useMemo(()=>e?M.createElement(Tm,{onClickHandler:m,style:g}):null,[e,m,g]),v=T=>{T>Ge[f]&&(T=Ge[f]),T<Ge[0]&&(T=Ge[0]),p(T)};return M.useEffect(()=>()=>{r!=null&&r.control.room&&D.isBoolean(u)&&(r.control.room.disableDeviceInputs=u)},[r,u]),M.createElement("div",{className:"button normal-button font-size-barBtn",style:{width:50},onPointerUp:T=>{T.stopPropagation(),T.nativeEvent.stopImmediatePropagation()}},M.createElement("input",{className:"font-size-input",ref:s,onTouchEnd:()=>{s.current&&s.current.focus()},onClick:()=>{t(!e),s.current&&s.current.focus()},onKeyDown:T=>{if(T.key==="Backspace"){const k=window.getSelection(),S=k==null?void 0:k.getRangeAt(0);if(S!=null&&S.collapsed)return T.cancelable&&T.preventDefault(),document.execCommand("delete",!1),!1}return!1},onKeyUp:T=>{var k;if(s.current){const S=s.current.value,w=parseInt(S);isNaN(w)?s.current.value="0":s.current.value=w.toString(),w&&T.key==="Enter"&&(v(w),(k=s.current)==null||k.blur(),t(!1))}},onFocus:()=>{r!=null&&r.control.room&&!r.control.room.disableDeviceInputs&&(d(r.control.room.disableDeviceInputs),r.control.room.disableDeviceInputs=!0)},onBlur:()=>{r!=null&&r.control.room&&D.isBoolean(u)&&(r.control.room.disableDeviceInputs=u)}}),M.createElement("div",{className:"font-size-btns"},M.createElement("div",{className:"font-size-add",onPointerUp:()=>{v(l+Ge[0])}}),M.createElement("div",{className:"font-size-cut",onPointerUp:()=>{v(l-Ge[0])}})),N)},Cm=a=>{const{workIds:s,mananger:e,islocked:t}=a;return M.createElement("div",{className:"button normal-button",onPointerUp:i=>{i.stopPropagation(),oe.emitMethod(te.MainEngine,F.SetLock,{workIds:s||[Q],isLocked:!t,viewId:e==null?void 0:e.viewId})}},M.createElement("img",{alt:"icon",src:xe(t?"unlock-new":"lock-new")}))},js=a=>{const{icon:s,min:e,max:t,step:i,value:o,onInputHandler:n}=a,[r,c]=M.useState(0),l=M.useRef(null),h=u=>{u>t&&(u=t),u<e&&(u=e),c(u),n(u),l.current&&(l.current.value=u.toString())};return M.useEffect(()=>{o&&(c(o),l.current&&(l.current.value=o.toString()))},[o]),M.createElement("div",{className:"button input-button",onPointerUp:u=>{u.stopPropagation(),u.nativeEvent.stopImmediatePropagation()}},M.createElement("img",{src:xe(s)}),M.createElement("input",{className:"input-number",type:"text",ref:l,onPointerUp:()=>{l.current&&l.current.focus()},onKeyDown:u=>{if(u.key==="Backspace"){const d=window.getSelection(),f=d==null?void 0:d.getRangeAt(0);if(f!=null&&f.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,f=parseInt(d);f&&f&&f>=e&&f<=t&&h(f)}}),M.createElement("div",{className:"input-number-btns"},M.createElement("div",{className:"input-number-add",onPointerUp:()=>{h(r+i)}}),M.createElement("div",{className:"input-number-cut",onPointerUp:()=>{h(r-i)}})))},bm=a=>{const{icon:s,min:e,max:t,step:i,value:o,onInputHandler:n}=a;return M.createElement("div",{className:"button input-button"},M.createElement("img",{src:xe(s)}),M.createElement(xm,{min:e,max:t,step:i,value:o,onInputHandler:n}))},xm=a=>{const{value:s,min:e,max:t,onInputHandler:i}=a,[o,n]=M.useState({x:0,y:0});M.useEffect(()=>{n({x:s*100,y:0})},[]);const r=D.throttle((h,u)=>{h.cancelable&&h.preventDefault(),h.stopPropagation();let d=Math.floor(Math.max(u.x,e*100));d=Math.floor(Math.min(d,t*100)),u.x!==(o==null?void 0:o.x)&&n({x:d,y:0});const f=d/100;s!==f&&i(f)},100,{trailing:!0}),c=h=>{h.cancelable&&h.preventDefault(),h.stopPropagation()},l=(h,u)=>{r.cancel(),h.cancelable&&h.preventDefault(),h.stopPropagation();let d=Math.floor(Math.max(u.x,e*100));d=Math.floor(Math.min(d,t*100)),u.x!==(o==null?void 0:o.x)&&n({x:d,y:0});const f=d/100;s!==f&&i(f)};return M.createElement("div",{className:"range-number-container",onClick:h=>{const u=h.nativeEvent.offsetX-6;let d=Math.floor(Math.max(u,e*100));d=Math.floor(Math.min(d,t*100)),n({x:d,y:0});const f=d/100;s!==f&&i(f)}},M.createElement("div",{className:"range-number-color"}),M.createElement("div",{className:"range-number"},M.createElement(Nt,{bounds:"parent",axis:"x",position:o,onDrag:r,onStart:c,onStop:l},M.createElement("div",{className:"circle",onClick:c}))))},Lm=a=>{const{icon:s,value:e,onChangeHandler:t,style:i}=a,[o,n]=M.useState(0),[r,c]=M.useState(),l=M.useRef(null),h=M.useCallback(f=>{f>=ft.length&&(f=0),f<0&&(f=ft.length-1),n(f),t(ft[f]),c(!1),l.current&&(l.current.value=ft[f])},[t]),u=M.useMemo(()=>{if(i&&i.bottom){const f={};return f.top="inherit",f.bottom=50,f}},[i]);M.useEffect(()=>{e&&(n(ft.indexOf(e)),l.current&&(l.current.value=e))},[e]);const d=M.useMemo(()=>r?M.createElement(zm,{options:ft,onClickHandler:h,style:u}):null,[r,h,u]);return M.createElement("div",{className:"button input-button"},M.createElement("img",{src:xe(s)}),M.createElement("input",{readOnly:!0,className:"input-number",type:"text",ref:l,onTouchEnd:f=>{f.stopPropagation(),l.current&&l.current.focus()},onClick:f=>{f.cancelable&&f.preventDefault(),f.stopPropagation(),l.current&&(l.current.focus(),c(!r))}}),M.createElement("div",{className:"input-number-btns"},M.createElement("div",{className:"input-number-add",onPointerUp:f=>{f.stopPropagation(),h(o+1)}}),M.createElement("div",{className:"input-number-cut",onPointerUp:f=>{f.stopPropagation(),h(o-1)}})),d)},zm=a=>{const{options:s,style:e,onClickHandler:t}=a;return M.createElement("div",{className:"select-option-menu",style:e,onPointerUp:i=>{i.stopPropagation(),i.nativeEvent.stopImmediatePropagation()}},s.map((i,o)=>M.createElement("div",{className:"select-option-btn",key:i,onPointerUp:n=>{n.stopPropagation(),t(o)}},i)))},Pm=a=>{const{mananger:s,innerRatio:e,innerVerticeStep:t,vertices:i}=a,o=c=>{oe.emitMethod(te.MainEngine,F.SetShapeOpt,{workIds:[Q],toolsType:I.Star,viewId:s.viewId,vertices:c})},n=c=>{oe.emitMethod(te.MainEngine,F.SetShapeOpt,{workIds:[Q],toolsType:I.Star,viewId:s.viewId,innerVerticeStep:c})},r=c=>{oe.emitMethod(te.MainEngine,F.SetShapeOpt,{workIds:[Q],toolsType:I.Star,viewId:s.viewId,innerRatio:c})};return M.createElement(M.Fragment,null,M.createElement(js,{value:i,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:o}),M.createElement(js,{value:t,icon:"star-innerVertex",min:1,max:100,step:1,onInputHandler:n}),M.createElement(bm,{value:e,icon:"star-innerRatio",min:.1,max:1,step:.1,onInputHandler:r}))},Dm=a=>{const{mananger:s,vertices:e}=a,t=i=>{oe.emitMethod(te.MainEngine,F.SetShapeOpt,{workIds:[Q],toolsType:I.Polygon,viewId:s.viewId,vertices:i})};return M.createElement(js,{value:e,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:t})},Am=a=>{const{mananger:s,placement:e}=a,t=i=>{oe.emitMethod(te.MainEngine,F.SetShapeOpt,{workIds:[Q],toolsType:I.SpeechBalloon,viewId:s.viewId,placement:i})};return M.createElement(Lm,{value:e,icon:"speechBallon-placement",onChangeHandler:t})},Ts=a=>{const{icon:s,isActive:e,onPointerUpHandler:t}=a;return M.createElement("div",{className:`button tab-button ${e?"active":""}`,onPointerUp:t},M.createElement("img",{src:xe(s)}))},jm=a=>{const{toolsTypes:s,style:e,mananger:t,shapeOpt:i}=a,[o,n]=M.useState();M.useEffect(()=>{s.includes(I.Polygon)?n(I.Polygon):s.includes(I.Star)?n(I.Star):n(I.SpeechBalloon)},[s]);const r=(u,d)=>{d==null||d.stopPropagation(),n(u)},c=M.useMemo(()=>o===I.Polygon&&t&&i.vertices?M.createElement(Dm,{vertices:i.vertices,mananger:t}):null,[t,o,i]),l=M.useMemo(()=>o===I.Star&&t&&i.vertices&&i.innerVerticeStep&&i.innerRatio?M.createElement(Pm,{mananger:t,vertices:i.vertices,innerVerticeStep:i.innerVerticeStep,innerRatio:i.innerRatio}):null,[t,o,i]),h=M.useMemo(()=>o===I.SpeechBalloon&&t&&i.placement?M.createElement(Am,{mananger:t,placement:i.placement}):null,[t,o,i]);return M.createElement("div",{className:"shapeOpt-sub-menu",style:e,onClick:u=>{u.stopPropagation(),u.nativeEvent.stopImmediatePropagation(),u.cancelable&&u.preventDefault()}},M.createElement("div",{className:"shapeOpt-sub-menu-tabs"},s.includes(I.Polygon)&&M.createElement(Ts,{isActive:o===I.Polygon,icon:o===I.Polygon?"polygon-active":"polygon",onPointerUpHandler:r.bind(void 0,I.Polygon)})||null,s.includes(I.Star)&&M.createElement(Ts,{isActive:o===I.Star,icon:o===I.Star?"star-active":"star",onPointerUpHandler:r.bind(void 0,I.Star)})||null,s.includes(I.SpeechBalloon)&&M.createElement(Ts,{isActive:o===I.SpeechBalloon,icon:o===I.SpeechBalloon?"speechBallon-active":"speechBallon",onPointerUpHandler:r.bind(void 0,I.SpeechBalloon)})||null),M.createElement("div",{className:"shapeOpt-sub-menu-content"},c,l,h))},Em=a=>{const{open:s,setOpen:e,floatBarRef:t,toolsTypes:i,shapeOpt:o}=a,{floatBarData:n,mananger:r}=M.useContext(Ie),[c,l]=M.useState([]),[h,u]=M.useState(),d=M.useMemo(()=>{if(t!=null&&t.current&&D.isNumber(n==null?void 0:n.x)&&D.isNumber(n==null?void 0:n.y)&&(r!=null&&r.height)){if(t.current.offsetTop&&t.current.offsetTop+n.y>200){const p={};return p.top="inherit",p.bottom=50,p}else if(!t.current.offsetTop&&(r==null?void 0:r.height)-t.current.offsetTop-(n==null?void 0:n.y)<140){const p={};return p.top="inherit",p.bottom=50,p}}},[t,n==null?void 0:n.x,n==null?void 0:n.y,r==null?void 0:r.height]),f=M.useMemo(()=>s&&i&&r&&o?(r.control.room&&!r.control.room.disableDeviceInputs&&(u(r.control.room.disableDeviceInputs),r.control.room.disableDeviceInputs=!0),M.createElement(jm,{shapeOpt:o,style:d,toolsTypes:i,mananger:r})):(r!=null&&r.control.room&&D.isBoolean(h)&&(r.control.room.disableDeviceInputs=h),null),[s,d,i,r,o]),g=p=>{p.stopPropagation(),p.nativeEvent.stopImmediatePropagation(),e(!s)};return M.useEffect(()=>{D.isEqual(n==null?void 0:n.selectIds,c)||n!=null&&n.selectIds&&!D.isEqual(n==null?void 0:n.selectIds,c)&&(l(n==null?void 0:n.selectIds),e(!1))},[s,n,c,e]),M.useEffect(()=>()=>{s&&r!=null&&r.control.room&&D.isBoolean(h)&&(r.control.room.disableDeviceInputs=h)},[s,r,h]),M.createElement("div",{className:`button normal-button ${s&&"active"}`,onPointerUp:g},f,M.createElement("img",{alt:"icon",src:xe(s?"shapes-active":"shapes")}))},en=M.memo(a=>{const{textOpt:s,workIds:e,noLayer:t,position:i}=a,{floatBarData:o,mananger:n}=M.useContext(Ie),[r,c]=M.useState(0),[l,h]=M.useState(),u=M.useRef(null);M.useEffect(()=>{var L,j,E,A;const S={},w=(o==null?void 0:o.w)||((L=s==null?void 0:s.boxSize)==null?void 0:L[0])||0,C=(o==null?void 0:o.h)||((j=s==null?void 0:s.boxSize)==null?void 0:j[1])||0;if(i&&w&&C&&(n!=null&&n.width)&&(n!=null&&n.height)){if(i.y<60?i.y+C<n.height-60?S.bottom=-120:i.y+C<n.height?S.bottom=-58:i.y>0?S.top=62:S.top=-i.y+62:S.top=0,i.x<0)S.left=-i.x+3;else if(i.x+(((E=u.current)==null?void 0:E.offsetWidth)||w)>n.width){const W=n.width-(((A=u.current)==null?void 0:A.offsetWidth)||w)-i.x;S.left=W}h(S);return}h(void 0)},[u,i,o==null?void 0:o.w,o==null?void 0:o.h,n==null?void 0:n.width,n==null?void 0:n.height,s==null?void 0:s.boxSize]);const d=M.useMemo(()=>o!=null&&o.fillColor?M.createElement(ym,{floatBarRef:u,open:r===3,setOpen:S=>{c(S===!0?3:0)}}):null,[o==null?void 0:o.fillColor,r,u]),f=M.useMemo(()=>o!=null&&o.strokeColor?M.createElement(gm,{floatBarRef:u,open:r===2,setOpen:S=>{c(S===!0?2:0)}}):null,[o==null?void 0:o.strokeColor,r,u]),g=M.useMemo(()=>s!=null&&s.fontColor&&(n!=null&&n.viewId)?M.createElement(Mm,{floatBarRef:u,open:r===4,setOpen:S=>{c(S===!0?4:0)},textOpt:s,workIds:e}):null,[s,r,e,n,u]),p=M.useMemo(()=>s!=null&&s.fontBgColor&&(n!=null&&n.viewId)?M.createElement(mm,{floatBarRef:u,open:r===5,setOpen:S=>{c(S===!0?5:0)},textOpt:s,workIds:e}):null,[s,r,e,n,u]),m=M.useMemo(()=>s&&(n!=null&&n.viewId)?M.createElement(Sm,{floatBarRef:u,open:r===6,setOpen:S=>{c(S===!0?6:0)},textOpt:s,workIds:e,style:l}):null,[s,r,e,n,l,u]),N=M.useMemo(()=>s&&(n!=null&&n.viewId)?M.createElement(km,{open:r===7,setOpen:S=>{c(S===!0?7:0)},textOpt:s,workIds:e,floatBarRef:u}):null,[s,r,e,n,u]),v=M.useMemo(()=>t?null:M.createElement(um,{open:r===1,setOpen:S=>{c(S===!0?1:0)},floatBarRef:u}),[t,r,u]),T=M.useMemo(()=>o!=null&&o.canLock&&n?M.createElement(Cm,{workIds:e,mananger:n,islocked:o.isLocked}):null,[o,n,e]),k=M.useMemo(()=>n&&(n!=null&&n.viewId)&&l&&(o!=null&&o.shapeOpt)&&(o!=null&&o.toolsTypes)?M.createElement(Em,{open:r===8,setOpen:S=>{c(S===!0?8:0)},floatBarRef:u,workIds:e,toolsTypes:o.toolsTypes,shapeOpt:o.shapeOpt}):null,[o,n,r,l,e,u]);return M.createElement("div",{className:"appliance-plugin-floatbtns",style:l,ref:u,onMouseOver:S=>(S.stopPropagation(),S.cancelable&&S.preventDefault(),n==null||n.control.worker.blurCursor(n.viewId),!1),onMouseMove:S=>(S.stopPropagation(),S.cancelable&&S.preventDefault(),!1)},n&&M.createElement(lm,{workIds:e,mananger:n}),v,T,!!(n!=null&&n.viewId)&&M.createElement(hm,{workIds:e,viewId:n.viewId}),k,N,m,g,p,f,d)}),Om=a=>{const{data:s,isActive:e,manager:t,workId:i}=a,{opt:o,scale:n,translate:r,x:c,y:l}=s,h=`scale(${n||1}) ${r&&"translate("+r[0]+"px,"+r[1]+"px)"||""}`,{fontSize:u,fontFamily:d,underline:f,fontColor:g,lineThrough:p,textAlign:m,strokeColor:N,lineHeight:v,bold:T,italic:k,uid:S,workState:w}=o,C=u,L=v||C*1.2,j={fontSize:`${C}px`,lineHeight:`${L}px`,color:g,borderColor:N,minHeight:`${L}px`,paddingRight:`${k==="italic"?Math.round(C*.3):5}px`};d&&(j.fontFamily=`${d}`),(p||f)&&(j.textDecoration=`${p&&"line-through"||""}${f&&" underline"||""}`),T&&(j.fontWeight=`${T}`),k&&(j.fontStyle=`${k}`),m&&(j.textAlign=`${m}`);function E(){var W;e&&(S&&S===((W=t.control.collector)==null?void 0:W.uid)||!S)&&t.control.textEditorManager.active(i)}const A=M.useMemo(()=>{const W=[];if(o.text){const z=it(o.text);for(let O=0;O<z.length;O++){const se=z[O];se===""?W.push(M.createElement("div",{style:{backgroundColor:o.fontBgColor},key:O},M.createElement("br",null))):W.push(M.createElement("div",{style:{backgroundColor:o.fontBgColor},key:O},se))}}return W.length?W:null},[o.fontBgColor,o.text]);return M.createElement("div",{className:"editor-box",style:{left:`${c}px`,top:`${l}px`,transform:h,transformOrigin:"left top",pointerEvents:"none",opacity:w===P.Done?0:1}},M.createElement("div",{className:`editor ${e?"":"readOnly"}`,style:j,onClick:E},A))},Rm=M.memo(a=>{const{data:s,left:e,top:t,workId:i,updateOptInfo:o}=a,{opt:n,scale:r,translate:c}=s,l=M.useRef(null);M.useEffect(()=>{var j,E;if((j=l.current)!=null&&j.offsetWidth&&((E=l.current)!=null&&E.offsetHeight)){const A=n.boxSize;if((A==null?void 0:A[0])!==l.current.offsetWidth||A[1]!==l.current.offsetHeight||!A){const W=[l.current.offsetWidth,l.current.offsetHeight];o({activeTextId:i,update:{boxSize:W,workState:P.Done}})}}},[n.fontSize,n.italic,n.bold,n.boxSize,i]);const h=`scale(${r||1}) ${c&&"translate("+c[0]+"px,"+c[1]+"px)"||""}`,{fontSize:u,fontFamily:d,underline:f,fontColor:g,lineThrough:p,textAlign:m,strokeColor:N,lineHeight:v,bold:T,italic:k}=n,S=u,w=v||S*1.2,C={fontSize:`${S}px`,lineHeight:`${w}px`,color:g,borderColor:N,minHeight:`${w}px`,pointerEvents:"none",paddingRight:`${k==="italic"?Math.round(S*.3):5}px`};d&&(C.fontFamily=`${d}`),(p||f)&&(C.textDecoration=`${p&&"line-through"||""}${f&&" underline"||""}`),m&&(C.textAlign=`${m}`),T&&(C.fontWeight=`${T}`),k&&(C.fontStyle=`${k}`);const L=M.useMemo(()=>{const j=[];if(n.text){const E=it(n.text);for(let A=0;A<E.length;A++){const W=E[A];W===""?j.push(M.createElement("div",{key:A},M.createElement("br",null))):j.push(M.createElement("div",{key:A},W))}}return j.length?j:null},[n.text]);return M.createElement("div",{className:"editor-box",style:{left:`${e}`,top:`${t}`,transform:h,transformOrigin:"left top",zIndex:1,pointerEvents:"none",opacity:0}},M.createElement("div",{className:"editor readOnly",ref:l,style:C},L))},(a,s)=>!(a.workId!==s.workId||a.left!==s.left||a.top!==s.top||!D.isEqual(a.data,s.data))),Wm=a=>{const{data:s,workId:e,isSelect:t,showFloatBtns:i,handleKeyUp:o,handleFocus:n,updateOptInfo:r,manager:c,runAnimation:l}=a,[h,u]=M.useState(),{opt:d,scale:f,translate:g,x:p,y:m}=s,{fontSize:N,fontFamily:v,underline:T,fontColor:k,lineThrough:S,textAlign:w,strokeColor:C,lineHeight:L,bold:j,italic:E,boxSize:A}=d,W=M.useRef(null),z=M.useMemo(()=>{const ie=N,he=L||ie*1.2,J={fontSize:`${ie}px`,lineHeight:`${he}px`,color:k,borderColor:C,minHeight:`${he}px`,paddingRight:`${E==="italic"?Math.round(ie*.3):5}px`,borderWidth:`${Math.max(Math.round(1/(f||1)),1)}px`};return v&&(J.fontFamily=`${v}`),(S||T)&&(J.textDecoration=`${S&&"line-through"||""} ${T&&" underline"||""}`),w&&(J.textAlign=`${w}`),j&&(J.fontWeight=`${j}`),E&&(J.fontStyle=`${E}`),J},[j,k,v,N,E,L,S,f,C,w,T]),O=M.useMemo(()=>{const ie=`scale(${f||1}) ${g&&"translate("+g[0]+"px,"+g[1]+"px)"||""}`;return{left:`${p}px`,top:`${m}px`,zIndex:2,pointerEvents:"none",transform:ie,transformOrigin:"left top"}},[f,g,p,m]),se=M.useMemo(()=>{var ie,he;return!t&&f&&i&&D.isNumber(p)&&D.isNumber(m)&&d.boxSize&&D.isNumber((ie=d.boxSize)==null?void 0:ie[0])&&D.isNumber((he=d.boxSize)==null?void 0:he[1])?M.createElement("div",{className:Pe.FloatBarBtn,style:{left:p,top:m,width:d.boxSize[0]*f,height:d.boxSize[1]*f}},M.createElement(en,{position:{x:p,y:m},textOpt:d,workIds:[e],noLayer:!0})):null},[t,d,i,e,p,m,f]),_=M.useMemo(()=>{let ie="";if(d.text){const he=it(d.text);for(let J=0;J<he.length;J++){const $=he[J];$===""?ie=ie+"<div><br/></div>":ie=ie+`<div style="background-color:${d.fontBgColor}">${$}</div>`}}else ie=`<div style="background-color:${d.fontBgColor}"></div>`;return ie},[d.fontBgColor,d.text]),H=M.useMemo(()=>typeof _=="string"?M.createElement("div",{id:e,suppressContentEditableWarning:!0,contentEditable:!0,className:"editor",ref:W,style:z,onKeyDown:G,onKeyUp:o,onPointerUp:X,onFocus:n,onPaste:ae,onInput:Te,dangerouslySetInnerHTML:{__html:_}}):null,[_,z,e]);M.useEffect(()=>{H&&W.current&&(W.current.click(),setTimeout(()=>{var ie;if(W.current){const he=window==null?void 0:window.getSelection(),J=W.current.lastChild;if(he&&J){const $=document.createRange(),ue=((ie=J.textContent)==null?void 0:ie.length)||0;(J==null?void 0:J.nodeName)==="#text"?$.setStart(J,ue):$.setStart(J,ue&&1||0),$.collapse(!0),he.removeAllRanges(),he.addRange($)}}},fs))},[H,W.current]),M.useEffect(()=>{var ie,he,J,$;if(H&&((ie=W.current)!=null&&ie.offsetWidth||(he=W.current)!=null&&he.offsetHeight||(J=W.current)!=null&&J.offsetLeft||($=W.current)!=null&&$.offsetTop)){const ue=[W.current.offsetWidth,W.current.offsetHeight];(A&&A[0]!==ue[0]&&A[1]!==ue[1]||!A)&&r({activeTextId:e,update:{boxSize:ue,workState:P.Doing}})}},[A,H,z,e]);function X(){W.current&&W.current.focus(),l()}function G(ie){if(ie.key==="Backspace"){const he=window.getSelection(),J=he==null?void 0:he.getRangeAt(0);if(J!=null&&J.collapsed)return ie.cancelable&&ie.preventDefault(),document.execCommand("delete",!1),!1}return l(),!1}function Z(ie,he){const J=window==null?void 0:window.getSelection();if(J!=null&&J.rangeCount&&ie&&J&&J.anchorNode){const $=J.anchorOffset,ue=J.anchorNode.textContent||"",fe=ue.slice(0,$)||"",Oe=ue.slice($)||"",we=fe.concat(ie)||"";K(we,Oe,he)}}function K(ie,he,J){const $=window==null?void 0:window.getSelection();if(!($!=null&&$.rangeCount)||!$.anchorNode)return;const ue=ie.split(/\n/);let fe=$.anchorNode.parentNode;fe===J&&(fe=$.anchorNode);const Oe=[...J.childNodes],we=[];let me,ot=$.anchorOffset;for(;Oe.length;){const ke=Oe.pop();if(ke){if(ke===fe){let Fe=ue[0];ue.length===1&&(ot=ue[0].length,Fe=ue[0].concat(he)),fe.nodeName==="#text"?(fe.textContent=Fe,me=fe):fe.nodeName==="DIV"&&(fe.innerText=Fe,me=fe.childNodes[0]);break}we.push(ke),J.removeChild(ke)}}if(ue.length>1)for(let ke=1;ke<ue.length;ke++){let Fe=ue[ke];const Lt=document.createElement("div");d.fontBgColor&&(Lt.style.backgroundColor=d.fontBgColor),ke===ue.length-1&&(ot=Fe.length,Fe=Fe.concat(he)),Fe===""?Lt.innerHTML="<br/>":Lt.innerText=Fe,J.appendChild(Lt),ke===ue.length-1&&(me=Lt.childNodes[0])}if(we.length){we.reverse();for(const ke of we)J.appendChild(ke)}if(me&&me.nodeName==="#text"){$.deleteFromDocument();const ke=document.createRange(),Fe=Math.min(ot,(me==null?void 0:me.length)||0);ke.setStart(me,Fe),ke.collapse(!0),$.removeAllRanges(),$.addRange(ke)}}function ae(ie){if(ie.cancelable&&ie.preventDefault(),ie.stopPropagation(),W.current){const he=(ie.clipboardData||window.clipboardData).getData("text"),J=window==null?void 0:window.getSelection();if(!(J!=null&&J.rangeCount))return;he&&J&&J.anchorNode&&Z(he,W.current),l()}}function Te(ie){o(ie),l()}return M.createElement(M.Fragment,null,se,M.createElement("div",{className:"editor-box",style:O,onFocus:()=>{c.control.room&&!c.control.room.disableDeviceInputs&&(u(c.control.room.disableDeviceInputs),c.control.room.disableDeviceInputs=!0)},onBlur:()=>{c!=null&&c.control.room&&D.isBoolean(h)&&(c.control.room.disableDeviceInputs=h)}},H))};class tn extends M.Component{constructor(s){super(s)}getInnerText(s){const e=[];for(let t=0;t<s.childNodes.length;t++){const i=s.childNodes[t];if(i.nodeName==="#text"&&t===0){const o=i.textContent.split(/\n/),n=o.pop();e.push(...o),n&&e.push(n)}else if(i.nodeName==="DIV"){const o=i.innerText.split(/\n/);if(o.length===2&&o[0]===""&&o[1]==="")e.push("");else{const n=o.shift();n&&e.push(n);const r=o.pop();e.push(...o),r&&e.push(r)}}}return e}updateOptInfo(s){var n,r;const{activeTextId:e,update:t,syncData:i}=s,o=e&&D.cloneDeep(((n=this.props.manager.control.textEditorManager)==null?void 0:n.get(e))||((r=this.props.editors)==null?void 0:r.get(e)));o&&o.opt&&(o.opt={...o.opt,...t},i&&(o.canSync=Object.keys(i).includes("canSync")&&i.canSync||o.canSync,o.canWorker=Object.keys(i).includes("canWorker")&&i.canWorker||o.canWorker),this.props.manager.control.textEditorManager.updateForViewEdited(e,o))}get editorUI(){var s;if((s=this.props.editors)!=null&&s.size){const e=[];return this.props.editors.forEach((t,i)=>{if(this.props.selectIds.includes(i)&&!(this.props.activeTextId==i)&&this.props.box){const{x:n,y:r}=this.props.box,{x:c,y:l}=t,h=`${c-n}px`,u=`${l-r}px`,d=M.createElement(Rm,{left:h,top:u,key:i,data:t,workId:i,isSelect:!0,updateOptInfo:this.updateOptInfo.bind(this),manager:this.props.manager});e.push(d)}}),e}return null}render(){return M.createElement(M.Fragment,null,this.editorUI)}}class Ym extends tn{constructor(e){super(e);y(this,"ref");y(this,"isRunAnimation");this.ref=M.createRef(),this.isRunAnimation=void 0}runAnimation(){this.isRunAnimation||(this.isRunAnimation=requestAnimationFrame(()=>{var e,t;(e=this.ref)!=null&&e.current&&((t=this.ref)==null||t.current.scrollTo({left:0,behavior:"instant"})),this.isRunAnimation=void 0}))}handleKeyUp(e){const t=this.getInnerText(e.nativeEvent.target),i=this.props.activeTextId;if(i){const o=this.props.manager.control.textEditorManager.get(i),n=Re(t),r=P.Doing,c=[e.nativeEvent.target.offsetWidth,e.nativeEvent.target.offsetHeight];(!o||o&&(o.opt.text!==n||!D.isEqual(o.opt.boxSize,c)||!D.isEqual(o.opt.workState,r)))&&this.updateOptInfo({activeTextId:i,update:{text:n,boxSize:c,workState:r},syncData:{canSync:!0,canWorker:!0}})}}handleFocus(e){const t=this.props.activeTextId;if(t){const i=this.props.manager.control.textEditorManager.get(t),o=P.Doing,n=[e.nativeEvent.target.offsetWidth,e.nativeEvent.target.offsetHeight];(!i||i&&(!D.isEqual(i.opt.boxSize,n)||!D.isEqual(i.opt.workState,o)))&&this.updateOptInfo({activeTextId:t,update:{boxSize:n,workState:o},syncData:{canSync:!0,canWorker:!0}})}}get editorUI(){var e;if((e=this.props.editors)!=null&&e.size){const t=[];return this.props.editors.forEach((i,o)=>{if(!(this.props.selectIds.includes(o)&&this.props.activeTextId!==o)){const c=this.props.activeTextId==o?M.createElement(Wm,{key:o,data:i,workId:o,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)}):M.createElement(Om,{manager:this.props.manager,isActive:i.opt.workState===P.Doing||i.opt.workState===P.Start||!1,key:o,data:i,workId:o});t.push(c)}}),t}return null}render(){return M.createElement("div",{className:`${this.props.className}`,ref:this.ref},this.editorUI)}}const Um=()=>{const{floatBarData:a}=M.useContext(Ie);return M.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:a==null?void 0:a.selectorColor}},M.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),M.createElement("div",{className:"point LC ew-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),M.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),M.createElement("div",{className:"point TC ns-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),M.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),M.createElement("div",{className:"point RC ew-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),M.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),M.createElement("div",{className:"point BC ns-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}))},Bm=()=>{const{floatBarData:a,mananger:s}=M.useContext(Ie),[e,t]=M.useState(),[i,o]=M.useState();M.useEffect(()=>{const c=[];if(s&&D.isNumber(a==null?void 0:a.x)&&D.isNumber(a==null?void 0:a.y)&&(a!=null&&a.points)){const l=s.viewId;if(s.control.viewContainerManager.getView(l))for(const u of a.points){const d=s.control.viewContainerManager.transformToOriginPoint(u,l);c.push(d)}c[0]&&t({x:c[0][0]-((a==null?void 0:a.x)||0),y:c[0][1]-((a==null?void 0:a.y)||0)}),c[1]&&o({x:c[1][0]-((a==null?void 0:a.x)||0),y:c[1][1]-((a==null?void 0:a.y)||0)})}},[s,a==null?void 0:a.points,a==null?void 0:a.x,a==null?void 0:a.y]);const n=M.useMemo(()=>e?M.createElement("div",{className:"point point-dot",style:{borderColor:a==null?void 0:a.selectorColor,left:e.x,top:e.y}}):null,[a==null?void 0:a.selectorColor,e]),r=M.useMemo(()=>i?M.createElement("div",{className:"point point-dot",style:{borderColor:a==null?void 0:a.selectorColor,left:i.x,top:i.y}}):null,[i,a==null?void 0:a.selectorColor]);return M.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:a==null?void 0:a.selectorColor}},n,r)},Fm=()=>{const{floatBarData:a}=M.useContext(Ie);return M.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:a==null?void 0:a.selectorColor}},M.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),M.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),M.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}),M.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:a==null?void 0:a.selectorColor}}))},Vm=()=>{const{floatBarData:a}=M.useContext(Ie);return M.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:a==null?void 0:a.selectorColor}},M.createElement("img",{className:"lock",alt:"lock",src:"https://sdk.netless.link/resource/icons/lock.svg"}))},$m=a=>{const{className:s}=a,{floatBarData:e,angle:t,setAngle:i,setOperationType:o,mananger:n}=M.useContext(Ie),[r,c]=M.useState(),[l,h]=M.useState(!1),[u,d]=M.useState(new V),[f,g]=M.useState(new V),[p,m]=M.useState(!1);M.useEffect(()=>(oe.activeListener(N),()=>{oe.unmountActiveListener(N)}),[]),M.useEffect(()=>{if(e){const S={x:(e==null?void 0:e.x)-20,y:(e==null?void 0:e.y)+(e==null?void 0:e.h)},w={x:(e==null?void 0:e.x)+(e==null?void 0:e.w)/2,y:(e==null?void 0:e.y)+(e==null?void 0:e.h)/2};g(new V(w.x,w.y)),d(new V(S.x,S.y)),c({x:S.x,y:S.y})}},[e==null?void 0:e.x,e==null?void 0:e.y,e==null?void 0:e.h]);const N=S=>{var w;if(!S){m(!0),h(!1),o(F.None);return}m(!1),(w=n==null?void 0:n.control.room)!=null&&w.disableDeviceInputs&&(n.control.room.disableDeviceInputs=!1)},v=(S,w)=>{if(S.cancelable&&S.preventDefault(),S.stopPropagation(),n!=null&&n.control.worker.isBusy){m(!0);return}h(!0);const C=Math.round(V.GetAngleByPoints(u,f,new V(w.x,w.y)))||0;i(C),o(F.RotateNode),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=!0),oe.emitMethod(te.MainEngine,F.RotateNode,{workIds:[Q],angle:0,workState:P.Start,viewId:n==null?void 0:n.viewId})},T=(S,w)=>{if(k.cancel(),S.cancelable&&S.preventDefault(),S.stopPropagation(),n!=null&&n.control.worker.isBusy){m(!0);return}h(!1);const C=Math.round(V.GetAngleByPoints(u,f,new V(w.x,w.y)))||0;i(C),o(F.None),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=!1),oe.emitMethod(te.MainEngine,F.RotateNode,{workIds:[Q],angle:C,workState:P.Done,viewId:n==null?void 0:n.viewId})},k=gs((S,w)=>{if(S.cancelable&&S.preventDefault(),S.stopPropagation(),n!=null&&n.control.worker.isBusy){m(!0);return}h(!0);const C=Math.round(V.GetAngleByPoints(u,f,new V(w.x,w.y)))||0;i(C),c({x:w.x,y:w.y}),o(F.RotateNode),oe.emitMethod(te.MainEngine,F.RotateNode,{workIds:[Q],angle:C,workState:P.Doing,viewId:n==null?void 0:n.viewId})},100,{trailing:!0});return M.createElement(Nt,{disabled:p,position:r,handle:".appliance-plugin-rotate-mouse-pointer",onStart:v,onDrag:k,onStop:T},M.createElement("div",{className:`${s}`,style:e?{left:0,top:0,touchAction:"none"}:void 0},!l&&M.createElement("div",{className:"appliance-plugin-rotate-btn",style:{backgroundColor:e==null?void 0:e.selectorColor}},M.createElement("img",{alt:"icon",src:xe("rotation-button")})),M.createElement("div",{className:`appliance-plugin-rotate-mouse-pointer ${l?"active":""}`},M.createElement("img",{alt:"icon",src:xe("rotation")}),M.createElement("div",{className:"angle-icon"},t,"°"))))},Hm=a=>{const{floatBarData:s,setOperationType:e,mananger:t}=M.useContext(Ie),{onClickHandle:i}=a,[o,n]=M.useState(P.Pending),[r,c]=M.useState(),[l,h]=M.useState(),[u,d]=M.useState(!1);M.useEffect(()=>(oe.activeListener(f),()=>{oe.unmountActiveListener(f)}),[]);const f=T=>{var k;if(!T||s!=null&&s.isLocked){d(!0),n(P.Pending),e(F.None);return}d(!1),(k=t==null?void 0:t.control.room)!=null&&k.disableDeviceInputs&&(t.control.room.disableDeviceInputs=!1)};M.useEffect(()=>{if(s!=null&&s.isLocked||t!=null&&t.control.worker.isBusy){d(!0),n(P.Pending);return}d(!1)},[s==null?void 0:s.isLocked]),M.useEffect(()=>{D.isNumber(s==null?void 0:s.x)&&D.isNumber(s==null?void 0:s.y)&&(o===P.Pending||o===P.Done)&&h({x:s==null?void 0:s.x,y:s==null?void 0:s.y})},[o,s==null?void 0:s.x,s==null?void 0:s.y]);const g=T=>{if(T.cancelable&&T.preventDefault(),T.stopPropagation(),t!=null&&t.control.worker.isBusy){d(!0),n(P.Pending);return}D.isNumber(s==null?void 0:s.x)&&D.isNumber(s==null?void 0:s.y)&&(e(F.TranslateNode),n(P.Start),c({x:s==null?void 0:s.x,y:s==null?void 0:s.y}),t!=null&&t.control.room&&(t.control.room.disableDeviceInputs=!0),oe.emitMethod(te.MainEngine,F.TranslateNode,{workIds:[Q],position:{x:s==null?void 0:s.x,y:s==null?void 0:s.y},workState:P.Start,viewId:t==null?void 0:t.viewId}))},p=(T,k)=>{if(m.cancel(),T.cancelable&&T.preventDefault(),t!=null&&t.control.worker.isBusy){d(!0),n(P.Pending);return}T.stopPropagation();const S={x:k.x,y:k.y};e(F.None),n(P.Done),t!=null&&t.control.room&&(t.control.room.disableDeviceInputs=!1),oe.emitMethod(te.MainEngine,F.TranslateNode,{workIds:[Q],position:S,workState:P.Done,viewId:t==null?void 0:t.viewId})},m=D.throttle((T,k)=>{if(T.cancelable&&T.preventDefault(),T.stopPropagation(),t!=null&&t.control.worker.isBusy){d(!0),n(P.Pending);return}const S={x:k.x,y:k.y};(k.x!==(s==null?void 0:s.x)||k.y!==(s==null?void 0:s.y))&&(n(P.Doing),oe.emitMethod(te.MainEngine,F.TranslateNode,{workIds:[Q],position:S,workState:P.Doing,viewId:t==null?void 0:t.viewId}))},100,{trailing:!0}),N=M.useMemo(()=>!!((s==null?void 0:s.scaleType)===re.none&&(s!=null&&s.canLock)),[s]),v=D.debounce(T=>(m.cancel(),T.stopPropagation(),T.cancelable&&T.preventDefault(),(r==null?void 0:r.x)===(s==null?void 0:s.x)&&(r==null?void 0:r.y)===(s==null?void 0:s.y)&&i(T),!1),100,{trailing:!0});return M.createElement(Nt,{disabled:u,position:l,onStart:g,onDrag:m,onStop:p},M.createElement("div",{style:s?{position:"absolute",left:0,top:0,width:s.w,height:s.h,zIndex:2,pointerEvents:N?"none":"auto",touchAction:"none"}:void 0,onPointerUp:T=>{T.persist(),v(T)}}))},Qm=a=>{const{className:s}=a,[e,t]=M.useState({x:0,y:0,h:0,w:0}),[i,o]=M.useState(),[n,r]=M.useState(),[c,l]=M.useState(),{floatBarData:h,mananger:u}=M.useContext(Ie),[d,f]=M.useState(),[g,p]=M.useState(!1);M.useEffect(()=>{if(h&&u){const C={x:h.x,y:h.y,w:h.w,h:h.h};t(C)}return oe.activeListener(m),()=>{oe.unmountActiveListener(m)}},[]);const m=C=>{var L;if(!C){p(!0);return}p(!1),(L=u==null?void 0:u.control.room)!=null&&L.disableDeviceInputs&&(u.control.room.disableDeviceInputs=!1)},N=C=>[[C.x,C.y],[C.x+C.w,C.y],[C.x+C.w,C.y+C.h],[C.x,C.y+C.h]],v=(C,L)=>{switch(L){case"top":case"topLeft":case"left":return C[2];case"topRight":return C[3];case"right":case"bottomRight":case"bottom":return C[0];case"bottomLeft":return C[1]}},T=(C,L,j,E)=>{let A=!1,W=!1;const z={x:e.x,y:e.y,w:e.w,h:e.h},O=[1,1],se=[0,0];switch(C){case"top":{const G=L.height+e.h;G<0?(W=!0,z.y=e.y+e.h,z.h=Math.abs(G)):(z.y=e.y-L.height,z.h=e.h+L.height);break}case"topLeft":{const G=L.width+e.w;G<0?(A=!0,z.x=e.x+e.w,z.w=Math.abs(G)):(z.x=e.x-L.width,z.w=e.w+L.width);const Z=L.height+e.h;Z<0?(W=!0,z.y=e.y+e.h,z.h=Math.abs(Z)):(z.y=e.y-L.height,z.h=e.h+L.height);break}case"topRight":{const G=L.width+e.w;G<0?(A=!0,z.x=e.x+G,z.w=Math.abs(G)):z.w=e.w+L.width;const Z=L.height+e.h;Z<0?(W=!0,z.y=e.y+e.h,z.h=Math.abs(Z)):(z.y=e.y-L.height,z.h=e.h+L.height);break}case"bottom":{const G=L.height+e.h;G<0?(W=!0,z.y=e.y+G,z.h=Math.abs(G)):z.h=e.h+L.height;break}case"bottomLeft":{const G=L.width+e.w;G<0?(A=!0,z.x=e.x+e.w,z.w=Math.abs(G)):(z.x=e.x-L.width,z.w=e.w+L.width);const Z=L.height+e.h;Z<0?(W=!0,z.y=e.y+Z,z.h=Math.abs(Z)):z.h=e.h+L.height;break}case"left":{const G=L.width+e.w;G<0?(A=!0,z.x=e.x+e.w,z.w=Math.abs(G)):(z.x=e.x-L.width,z.w=e.w+L.width);break}case"bottomRight":{const G=L.width+e.w;G<0?(A=!0,z.x=e.x+G,z.w=Math.abs(G)):z.w=e.w+L.width;const Z=L.height+e.h;Z<0?(W=!0,z.y=e.y+Z,z.h=Math.abs(Z)):z.h=e.h+L.height;break}case"right":{const G=L.width+e.w;G<0?(A=!0,z.x=e.x+G,z.w=Math.abs(G)):z.w=e.w+L.width;break}}O[0]=z.w/e.w,O[1]=z.h/e.h;const H=N(z).map(G=>j.control.viewContainerManager.transformToScenePoint(G,j.viewId)),X=v(H,C);return W&&(se[1]=X[1]-E[1]),A&&(se[0]=X[0]-E[0]),{scale:O,translate:se}},k=(C,L)=>{if(C.cancelable&&C.preventDefault(),C.stopPropagation(),u!=null&&u.control.worker.isBusy){p(!0);return}if(h!=null&&h.w&&(h!=null&&h.h)&&u){const j={x:h.x,y:h.y,w:h.w,h:h.h},E=N(j),A=E.map(O=>u.control.viewContainerManager.transformToScenePoint(O,u.viewId)),W=v(E,L),z=v(A,L);t(j),o(W),r(z),l(L),u!=null&&u.control.room&&(u.control.room.disableDeviceInputs=!0),oe.emitMethod(te.MainEngine,F.ScaleNode,{workIds:[Q],originPoint:W,scenePoint:z,workState:P.Start,viewId:u.viewId})}},S=D.throttle((C,L,j,E)=>{if(C.cancelable&&C.preventDefault(),C.stopPropagation(),!u||!i||!n)return;if(u!=null&&u.control.worker.isBusy){p(!0);return}const{scale:A,translate:W}=T(L,E,u,n);(!D.isEqual(A,d==null?void 0:d.scale)||!D.isEqual(W,d==null?void 0:d.translate))&&(f({scale:A,translate:W}),oe.emitMethod(te.MainEngine,F.ScaleNode,{workIds:[Q],scale:A,dir:L,translate:W,originPoint:i,scenePoint:n,workState:P.Doing,viewId:u.viewId}))},100,{trailing:!0}),w=C=>{if(S.cancel(),C.cancelable&&C.preventDefault(),C.stopPropagation(),!(!u||!i||!n)){if(u!=null&&u.control.worker.isBusy){p(!0);return}if(u!=null&&u.control.room&&(u.control.room.disableDeviceInputs=!1),d){const{scale:L,translate:j}=d;oe.emitMethod(te.MainEngine,F.ScaleNode,{workIds:[Q],scale:L,dir:c,translate:j,originPoint:i,scenePoint:n,workState:P.Done,viewId:u.viewId})}}};return M.createElement(nn.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:g?!1:{top:(h==null?void 0:h.scaleType)===re.all&&!0||!1,right:(h==null?void 0:h.scaleType)===re.all&&!0||!1,bottom:(h==null?void 0:h.scaleType)===re.all&&!0||!1,left:(h==null?void 0:h.scaleType)===re.all&&!0||!1,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},lockAspectRatio:(h==null?void 0:h.scaleType)===re.proportional,onResizeStart:k,onResize:S,onResizeStop:w})},qi=a=>{const{id:s,pos:e,pointMap:t,type:i}=a,{setOperationType:o,mananger:n,floatBarData:r}=M.useContext(Ie),[c,l]=M.useState({x:0,y:0}),[h,u]=M.useState(P.Pending),[d,f]=M.useState(!1);M.useEffect(()=>(oe.activeListener(g),()=>{oe.unmountActiveListener(g)}),[]);const g=v=>{var T;if(!v||r!=null&&r.isLocked){f(!0),u(P.Pending),o(F.None);return}f(!1),(T=n==null?void 0:n.control.room)!=null&&T.disableDeviceInputs&&(n.control.room.disableDeviceInputs=!1)};M.useEffect(()=>{D.isNumber(e.x)&&D.isNumber(e.y)&&(h===P.Pending||h===P.Done)&&l({x:e.x,y:e.y})},[e,h]);const p=v=>{if(v.cancelable&&v.preventDefault(),v.stopPropagation(),n!=null&&n.control.worker.isBusy){f(!0),u(P.Pending);return}D.isNumber(e.x)&&D.isNumber(e.y)&&(o(F.SetPoint),u(P.Start),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=!0),oe.emitMethod(te.MainEngine,F.SetPoint,{workId:Q,pointMap:t,workState:P.Start,viewId:n==null?void 0:n.viewId}))},m=D.throttle((v,T)=>{if(v.cancelable&&v.preventDefault(),v.stopPropagation(),n!=null&&n.control.worker.isBusy){f(!0),u(P.Pending);return}const k={x:T.x,y:T.y};if((k.x!==(e==null?void 0:e.x)||k.y!==(e==null?void 0:e.y))&&(n!=null&&n.control.viewContainerManager)){const S=n.control.viewContainerManager.transformToScenePoint([k.x,k.y],n.viewId),w=t.get(s);w&&i==="start"?w[0]=S:w&&i==="end"&&(w[1]=S),u(P.Doing),oe.emitMethod(te.MainEngine,F.SetPoint,{workId:Q,pointMap:t,workState:P.Doing,viewId:n==null?void 0:n.viewId})}},100,{trailing:!0}),N=(v,T)=>{if(m.cancel(),v.cancelable&&v.preventDefault(),n!=null&&n.control.worker.isBusy){f(!0),u(P.Pending);return}v.stopPropagation(),o(F.None),u(P.Done);const k={x:T.x,y:T.y};if(n!=null&&n.control.viewContainerManager){const S=n.control.viewContainerManager.transformToScenePoint([k.x,k.y],n.viewId),w=t.get(s);w&&i==="start"?w[0]=S:w&&i==="end"&&(w[1]=S),n!=null&&n.control.room&&(n.control.room.disableDeviceInputs=!1),oe.emitMethod(te.MainEngine,F.SetPoint,{workId:Q,pointMap:t,workState:P.Done,viewId:n==null?void 0:n.viewId})}};return M.createElement(Nt,{disabled:d,position:c,onStart:p,onDrag:m,onStop:N},M.createElement("div",{className:"appliance-plugin-point-draggable-btn",style:r?{left:0,top:0}:void 0}))},Gm=a=>{const{className:s}=a,{floatBarData:e,mananger:t}=M.useContext(Ie),[i,o]=M.useState(),[n,r]=M.useState(),[c,l]=M.useState(new Map);M.useEffect(()=>{const d=[];if(t&&(e!=null&&e.points)){const f=t.viewId;if(t.control.viewContainerManager.getView(f))for(const p of e.points){const m=t.control.viewContainerManager.transformToOriginPoint(p,f);d.push(m)}e!=null&&e.selectIds&&e.selectIds.length===1&&(c.set(e.selectIds[0],e.points),l(c))}d[0]&&o({x:d[0][0],y:d[0][1]}),d[1]&&r({x:d[1][0],y:d[1][1]})},[t,e==null?void 0:e.points,e==null?void 0:e.selectIds,c]);const h=M.useMemo(()=>i&&(e!=null&&e.selectIds)?M.createElement(qi,{pos:i,type:"start",id:e.selectIds[0],pointMap:c}):null,[i,e==null?void 0:e.selectIds,c]),u=M.useMemo(()=>n&&(e!=null&&e.selectIds)?M.createElement(qi,{pos:n,type:"end",id:e.selectIds[0],pointMap:c}):null,[n,e==null?void 0:e.selectIds,c]);return M.createElement("div",{className:`${s}`},h,u)},Zm=M.forwardRef((a,s)=>{const{floatBarData:e,operationType:t}=M.useContext(Ie),i=M.useMemo(()=>(e==null?void 0:e.scaleType)!==re.all||t===F.RotateNode?null:M.createElement(Um,null),[e,t]),o=M.useMemo(()=>(e==null?void 0:e.scaleType)!==re.both||t===F.RotateNode?null:M.createElement(Bm,null),[e,t]),n=M.useMemo(()=>(e==null?void 0:e.scaleType)!==re.proportional||t===F.RotateNode?null:M.createElement(Fm,null),[e,t]),r=M.useMemo(()=>(e==null?void 0:e.scaleType)===re.none&&(e!=null&&e.canLock)?M.createElement(Vm,null):null,[e]);return M.createElement("div",{ref:s,style:e?{transform:`translate(${e.x}px,${e.y}px)`,width:e.w,height:e.h,pointerEvents:"none"}:void 0},r,i,o,n,a.children)}),qm=M.forwardRef((a,s)=>{var f;const{floatBarData:e,operationType:t,mananger:i}=M.useContext(Ie),{editors:o,activeTextId:n,isHide:r}=a,c=M.useMemo(()=>{var g;return e!=null&&e.canRotate&&((g=e==null?void 0:e.selectIds)==null?void 0:g.length)===1&&(t===F.None||t===F.RotateNode)?M.createElement($m,{className:Pe.RotateBtn}):null},[e==null?void 0:e.canRotate,(f=e==null?void 0:e.selectIds)==null?void 0:f.length,t]),l=M.useMemo(()=>((e==null?void 0:e.scaleType)===re.all||(e==null?void 0:e.scaleType)===re.proportional)&&(t===F.None||t===F.ScaleNode)&&D.isNumber(e==null?void 0:e.x)&&D.isNumber(e==null?void 0:e.y)?M.createElement(Qm,{className:Pe.ResizeBtn}):null,[e==null?void 0:e.scaleType,t,e==null?void 0:e.x,e==null?void 0:e.y]),h=M.useMemo(()=>(e==null?void 0:e.scaleType)===re.both&&(t===F.None||t===F.SetPoint)?M.createElement(Gm,{className:Pe.ResizeTowBox}):null,[e==null?void 0:e.scaleType,t]),u=M.useMemo(()=>{const g=(e==null?void 0:e.selectIds)||[];return o&&i&&g&&D.isNumber(e==null?void 0:e.x)&&D.isNumber(e==null?void 0:e.y)&&D.isNumber(e==null?void 0:e.w)&&D.isNumber(e==null?void 0:e.h)?M.createElement(tn,{box:{x:e==null?void 0:e.x,y:e==null?void 0:e.y,w:e==null?void 0:e.w,h:e==null?void 0:e.h},manager:i,selectIds:g,activeTextId:n,editors:o}):null},[e==null?void 0:e.selectIds,e==null?void 0:e.x,e==null?void 0:e.y,e==null?void 0:e.w,e==null?void 0:e.h,o,i,n]),d=M.useMemo(()=>r&&t===F.None&&D.isNumber(e==null?void 0:e.x)&&D.isNumber(e==null?void 0:e.y)&&D.isNumber(e==null?void 0:e.w)&&D.isNumber(e==null?void 0:e.h)?M.createElement("div",{className:Pe.FloatBarBtn,style:{left:e==null?void 0:e.x,top:e==null?void 0:e.y,width:e.w,height:e.h}},M.createElement(en,{position:{x:e.x,y:e.y},textOpt:e==null?void 0:e.textOpt,noLayer:e==null?void 0:e.isLocked})):null,[e==null?void 0:e.x,e==null?void 0:e.y,e==null?void 0:e.w,e==null?void 0:e.h,e==null?void 0:e.textOpt,e==null?void 0:e.isLocked,t,r]);return M.createElement("div",{className:Pe.FloatBar,onMouseOver:()=>{i==null||i.control.worker.blurCursor(i.viewId)}},M.createElement(Zm,{ref:s},M.createElement(M.Fragment,null,u)),M.createElement(Hm,{onClickHandle:g=>{if(i&&(o!=null&&o.size)){const p=i.getPoint(g.nativeEvent);p&&i.control.textEditorManager.computeTextActive(p,i.viewId)}}}),c,l,h,d)}),Xm=M.memo(qm,(a,s)=>!!D.isEqual(a,s)),Jm="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAYISURBVHgB7ZpNSCtXFIBPEuvz+dMGpYUKD/sWFX+Qti6kK7Hqpm6e9q0rIoIUFUShPLV10VZx4+JZqa9v20LBhdq9fyBUCtKNPH8qYl2IOw3G38Rkek4y15y5uTOZJDOWggcOSSYzN/ebc+45554JwIM8iBCPyTEP+86T4vyMfsRN4b+nQTKIJp0vzuGvlpID7os8EQNEIBD4oKio6Bm9DwaDv/v9/n/076JgbtWUYPchwrW8qD7UnOvr6wFNkpubm+/wu7f0c7y6mrnlvQufxB0Iau7V1dX3BDA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gCIKGG4ZU+EWkgNBzN1qamq+pAMTExPgFMzW1tZrhHkFyWE5KxgSszx0527RaDRmOSpRshEOU11dPQPG8CwHARHJlMnTSrwSRFIlfXt7m3V5ngJGuJtqzaQtZkFBVNJezN5ZAdmwjKo2k9tVtrcI3OXk4tPgcg7ChCDZ1URgMOu72Xa5VFHOkymQhWVU60YVmjN6wiC7k6p+S1syCACOwJBYFaexV+yhBekNPsMBO6KAEeE4BMaCU67RsoYhSbXgaT//ht709vZCaWmp6YkEbLFmVJWzas04+iBL7EKpm0J7duqu0B7+CTUpNJuyvb1NCfMj1CqI9wLKUOlOUMeG+gGFkHii4HizUF4z/KFUrPsJ8WbEIyx7nnZ0dDynME6BAuce09iFHo+GrnmGltltb2//E4wVAN82y7vOjKOZXSBhJdHNiT3TYWD8OY2PTUJkdd7MkJMnT5wZVQF2RFX6yBMUdzPMvvfqxz3sXHF+GNT9ANXit/10O1sgHkZvdQAOKvs9B5L7ARELGAAXLSTvM8QExTE+YbHe+HURhZp1aRyF4CJXClbbWwGketgkW9VsY+YaiBCVhfgE+XvxRwgZSM4jUVCDZFQ9pytmXR8hUTB2gnidx4XffVWydN0yQjwmx/jkAZJBrIBI5J7ZvQGZWUgVSuU/EqmOAzicKNMVu816DdRWUV1/7xAP8n+SfwF3Du3NF2sYhwAAAABJRU5ErkJggg==",Km="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",_m="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",ew="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAgrSURBVHgB7ZprTBRXFIDP7gIt8lQppTwE5V0KaAn6o1pqNGkDDTEmTUhsgKRp+gNJw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TXhBc3+BgaZyqAISjOYxSMVvXsBTNlzdiNQDgRao2AtK3pjggpmrqbGpqSsLPIN/dv38/gaBwUjTshMHcvn27JyUlpRmc5xpPMD599LIYnLNyUKKndKjGxsakXbt2deMCLIE8IVvs0YRM1fjdu3d/wrXN5+BcnzEgvor2uN3rjzAYMp5lPEoQlE5fA0fWo8GfhlCbKVFQ1pKNIfzcOHH58mWqaimVUwJI0+6n59D4pIlzmdZPMPiZzXjDjX47Le5g0Uu8x2zgPqWyKpjVe7x3+AUbq9NYjQbgp2dsBud5o8TP7d5kHAWcQchQfoEmLgn8HjOiBIF7o5hI1x6CEbLNP3bdqYAF44JzyWLzcN1i8DcT/o3awbm8Fz3DAy2A62INwPV/E3wWdx5inmBHuwChCBD6R2JwHge80TIQRQLjt7e8DTkGZgfX8cUMZTDAteFDkveaIlzjX9ySQs8X18r2t2VHUURPKoICmDR+eCO9aSdmOIub3/w9RgpgUpiJhvraXpa6jZKHGEqyusw0GLFzX+5RhN/8kYnMSNMMfyH/V/kHST6OYVElTPAAAAAASUVORK5CYII=";class tw extends M.Component{constructor(e){super(e);y(this,"renderAvatar",e=>{var i;const t=`rgb(${e.memberState.strokeColor[0]}, ${e.memberState.strokeColor[1]}, ${e.memberState.strokeColor[2]})`;if(this.detectAvatar(e)){const o=this.getCursorName(e);return M.createElement("img",{className:"cursor-selector-avatar",style:{width:o?19:28,height:o?19:28,position:o?"initial":"absolute",borderColor:o?"white":t,marginRight:o?4:0},src:(i=e.payload)==null?void 0:i.avatar,alt:"avatar"})}else return null});y(this,"getOpacity",e=>{const t=this.getCursorName(e),i=this.detectAvatar(e);return t===void 0&&i===void 0?0:1});y(this,"getCursorName",e=>{if(e.payload)return e.payload.nickName||e.payload.cursorName||e.payload.uid});y(this,"getThemeClass",e=>e.payload&&e.payload.theme?"cursor-inner-mellow":"cursor-inner");y(this,"getCursorBackgroundColor",e=>{const t=this.getCursorName(e);return e.payload&&e.payload.cursorBackgroundColor?e.payload.cursorBackgroundColor:t?`rgb(${e.memberState.strokeColor[0]}, ${e.memberState.strokeColor[1]}, ${e.memberState.strokeColor[2]})`:void 0});y(this,"getCursorTextColor",e=>e.payload&&e.payload.cursorTextColor?e.payload.cursorTextColor:"#FFFFFF");y(this,"getCursorTagBackgroundColor",e=>e.payload&&e.payload.cursorTagBackgroundColor?e.payload.cursorTagBackgroundColor:this.getCursorBackgroundColor(e));y(this,"detectAvatar",e=>!!(e.payload&&e.payload.avatar));y(this,"renderTag",e=>{if(e.payload&&e.payload.cursorTagName)return M.createElement("span",{className:"cursor-tag-name",style:{backgroundColor:this.getCursorTagBackgroundColor(e)}},e.payload.cursorTagName)})}render(){const{roomMember:e}=this.props,t=this.getCursorName(e);switch(e.memberState.currentApplianceName){case ne.pencil:return M.createElement("div",{className:"cursor-box"},M.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -90%)",marginLeft:"10px"}},M.createElement("div",{className:"cursor-name"},M.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),t,this.renderTag(e))),M.createElement("div",null,M.createElement("img",{className:"cursor-pencil-image",src:Jm,alt:"pencilCursor"}))));case ne.eraser:case ne.pencilEraser:return M.createElement("div",{className:"cursor-box"},M.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -90%)",marginLeft:"0px"}},M.createElement("div",{className:"cursor-name"},M.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),t,this.renderTag(e))),M.createElement("div",null,M.createElement("img",{className:"cursor-pencil-image",src:ew,alt:"pencilEraser"}))));case ne.text:return M.createElement("div",{className:"cursor-box"},M.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -65%)",marginLeft:"0px"}},M.createElement("div",{className:"cursor-name"},M.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),t,this.renderTag(e))),M.createElement("div",null,M.createElement("img",{className:"cursor-arrow-image",src:_m,alt:"textCursor"}))));case ne.rectangle:case ne.arrow:case ne.straight:case ne.shape:case ne.ellipse:return M.createElement("div",{className:"cursor-box"},M.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -65%)",marginLeft:"0px"}},M.createElement("div",{className:"cursor-name"},M.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),t,this.renderTag(e))),M.createElement("div",null,M.createElement("img",{className:"cursor-arrow-image",src:Km,alt:"shapeCursor"}))));default:return null}}}const sw=a=>{const{className:s,info:e}=a,{roomMember:t,...i}=e||{};return M.createElement("div",{className:`${s}`,style:i?{transform:`translate(${i.x}px, ${i.y}px)`}:{display:"none"}},t&&M.createElement(tw,{roomMember:t}))},iw=a=>{const{className:s,manager:e}=a,[t,i]=M.useState();M.useEffect(()=>(e.internalMsgEmitter.on([te.Cursor,e.viewId],o),()=>{e.internalMsgEmitter.off([te.Cursor,e.viewId],o)}),[e]);function o(r){i(r)}return M.useMemo(()=>{if(t!=null&&t.length){const r=t.map(c=>{var l;return c.roomMember?M.createElement(sw,{key:(l=c.roomMember)==null?void 0:l.memberId,className:s,info:c}):null});return M.createElement(M.Fragment,null,r)}return null},[t])},ow=a=>{const{viewId:s,miniMapCanvas:e,highlightColor:t,miniMapManager:i,contianer:o}=a,[n,r]=M.useState();M.useEffect(()=>(c(),i.listener.addListener([s,"viewCameraUpate"],c),i.listener.emitAsync([s,"miniMapCreate"],!0),()=>{i.listener.removeListener([s,"viewCameraUpate"],c)}),[]);const c=()=>{const u=i.maps.get(s);u&&l(u.miniMapCamera,u.viewCamera)},l=(u,d)=>{const{width:f,height:g}=o.getBoundingClientRect(),p=Math.min(f/u.width,g/u.height),m=d.width/d.scale,N=d.height/d.scale,v=[d.centerX,d.centerY],T=[u.centerX,u.centerY],k=[v[0]-T[0],v[1]-T[1]],S=Math.min(u.scale*p,u.scale*p),w=[k[0]*S,k[1]*S,m,N,S];r(w)},h=u=>{var d;if(i.control.renderControl.isWriteable()){const f=u.nativeEvent.target||u.nativeEvent.srcElement;if(f&&u.nativeEvent&&n){const{width:g,height:p}=f.getBoundingClientRect(),[m,N]=[g/2,p/2],[v,T]=[(u.nativeEvent.offsetX-m)/n[4],(u.nativeEvent.offsetY-N)/n[4]],k=i.maps.get(s);if(k!=null&&k.viewCamera){const[S,w]=[k.miniMapCamera.centerX+v,k.miniMapCamera.centerY+T];(d=i.control.room)==null||d.moveCamera({centerX:S,centerY:w,animationMode:"immediately"})}}}};return M.createElement("div",{style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",pointerEvents:"auto"},onClick:h},M.createElement("canvas",{style:{pointerEvents:"none"},ref:e}),n&&M.createElement("div",{className:"minimap-highlightBox",style:{position:"absolute",top:"50%",left:"50%",width:n[2]*n[4],height:n[3]*n[4],boxSizing:"content-box",border:`2px solid ${t}`,transform:`translate(calc(-50% + ${n[0]}px), calc(-50% + ${n[1]}px))`,pointerEvents:"none"}}))},nw=a=>{const{miniMapManager:s,active:e,className:t}=a,i=M.useMemo(()=>{const o=s.maps;if(e){const n=o.get(e);if(n){const{miniMapCamera:r,viewCamera:c,...l}=n;if(l.contianer&&r&&c){const h=s.highlightColor;return ns.createPortal(M.createElement(ow,{viewId:e,...l,highlightColor:h,miniMapManager:s}),l.contianer)}}}return null},[e,s]);return M.createElement("div",{className:t},i)},Ie=M.createContext({mananger:void 0,floatBarColors:[],floatBarData:void 0,dpr:1,angle:0,operationType:F.None,scale:[1,1],setAngle:()=>{},setOperationType:()=>{},setFloatBarData:()=>{}});class ii extends M.Component{constructor(e){var t,i;super(e);y(this,"setAngle",e=>{this.setState({angle:e})});y(this,"setOperationType",e=>{this.setState({operationType:e})});this.state={floatBarData:void 0,showFloatBar:!1,dpr:1,angle:0,operationType:F.None,scale:[1,1],editors:this.editors,activeTextId:(t=this.props.mananger.control.textEditorManager)==null?void 0:t.activeId,activeMiniMapViewId:(i=this.props.mananger.control.miniMapManager)==null?void 0:i.activeViewId}}get editors(){return Ce(this.props.mananger.control.textEditorManager.filterEditor(this.props.mananger.viewId))}componentDidMount(){this.props.mananger.vDom=this,this.props.mananger.mountView(),this.setState({dpr:this.props.mananger.dpr})}componentWillUnmount(){}setActiveMiniMap(e){this.setState({activeMiniMapViewId:e})}showFloatBar(e,t){const i=e&&t&&{...this.state.floatBarData,...t}||void 0;this.setState({showFloatBar:e,floatBarData:i,angle:0})}setActiveTextEditor(e){this.setState({activeTextId:e,editors:this.editors})}setFloatBarData(e){this.state.floatBarData&&this.setState({floatBarData:{...this.state.floatBarData,...e}})}render(){var t,i,o,n,r,c,l;const e=!!((i=(t=this.props.mananger.control)==null?void 0:t.room)!=null&&i.floatBarOptions);return M.createElement("div",{className:Pe.Container},!this.props.mananger.control.hasOffscreenCanvas()&&M.createElement("div",{className:Pe.CanvasBox,ref:this.props.refs.canvasContainerRef})||M.createElement("div",{className:Pe.CanvasBox,onMouseDown:h=>{h.cancelable&&h.preventDefault(),h.stopPropagation()},onMouseUp:h=>{h.cancelable&&h.preventDefault(),h.stopPropagation()},onPointerDown:h=>{h.stopPropagation()},onPointerUp:h=>{h.stopPropagation()},onTouchStart:h=>{h.stopPropagation()},onTouchEnd:h=>{h.stopPropagation()},onMouseMove:h=>{this.props.mananger.cursorMouseMove(h)}},M.createElement("canvas",{id:"bgCanvas",ref:this.props.refs.canvasBgRef,style:{width:"100%",height:"100%"}}),M.createElement("canvas",{id:"serviceCanvas",className:Pe.FloatCanvas,ref:this.props.refs.canvasServiceFloatRef,style:{width:"100%",height:"100%"}}),M.createElement("canvas",{id:"localCanvas",className:Pe.FloatCanvas,ref:this.props.refs.canvasFloatRef,style:{width:"100%",height:"100%"}}),M.createElement("div",{id:"subLocalCanvas",className:Pe.CanvasBoxSub,ref:this.props.refs.subLocalCanvasContainerRef}),M.createElement("canvas",{id:"topCanvas",className:Pe.TopFloatCanvas,ref:this.props.refs.canvasTopRef,style:{width:"100%",height:"100%"}})),!this.props.mananger.control.hasOffscreenCanvas()&&this.props.refs.snapshotContainerRef&&M.createElement("div",{className:Pe.SnapshotBox,ref:this.props.refs.snapshotContainerRef})||null,M.createElement(Ie.Provider,{value:{mananger:this.props.mananger,floatBarColors:e&&((r=(n=(o=this.props.mananger.control)==null?void 0:o.room)==null?void 0:n.floatBarOptions)==null?void 0:r.colors)||[],floatBarData:this.state.floatBarData,dpr:this.state.dpr,angle:this.state.angle,operationType:this.state.operationType,scale:this.state.scale,setAngle:this.setAngle.bind(this),setOperationType:this.setOperationType.bind(this),setFloatBarData:this.setFloatBarData.bind(this)}},this.state.showFloatBar&&M.createElement(Xm,{ref:this.props.refs.floatBarRef,editors:this.state.editors,activeTextId:this.state.activeTextId,isHide:e})||null,((c=this.state.editors)==null?void 0:c.size)&&M.createElement(Ym,{className:Pe.TextEditorContainer,showFloatBtns:e,manager:this.props.mananger,selectIds:((l=this.state.floatBarData)==null?void 0:l.selectIds)||[],editors:this.state.editors,activeTextId:this.state.activeTextId})||null),M.createElement(iw,{className:Pe.CursorBox,manager:this.props.mananger}),M.createElement(nw,{className:Pe.MiniMapBox,active:this.state.activeMiniMapViewId,miniMapManager:this.props.mananger.control.miniMapManager}))}}class rw extends Ko{constructor(e,t){super(e,t);y(this,"width",1e3);y(this,"height",1e3);y(this,"dpr",Ke());y(this,"vDom");y(this,"eventTragetElement");y(this,"snapshotContainerRef");y(this,"canvasContainerRef",M.createRef());y(this,"subLocalCanvasContainerRef",M.createRef());y(this,"canvasTopRef",M.createRef());y(this,"canvasServiceFloatRef",M.createRef());y(this,"canvasFloatRef",M.createRef());y(this,"canvasBgRef",M.createRef());y(this,"floatBarRef",M.createRef());y(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas()||(this.snapshotContainerRef=M.createRef())}setCanvassStyle(){if(this.eventTragetElement){const e=this.eventTragetElement.offsetWidth||this.width,t=this.eventTragetElement.offsetHeight||this.height;let i=Ke();this.canvasBgRef.current&&(i=Ke(this.canvasBgRef.current.getContext("2d"))),i!==this.dpr&&(this.dpr=i,this.control.worker.updateDpr(this.viewId,this.dpr)),e&&t&&this.canvasContainerRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.canvasContainerRef.current.style.width=`${e}px`,this.canvasContainerRef.current.style.height=`${t}px`),e&&t&&this.snapshotContainerRef&&this.snapshotContainerRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t),e&&t&&this.canvasBgRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.canvasBgRef.current.width=e*this.dpr,this.canvasBgRef.current.height=t*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=e*this.dpr,this.canvasFloatRef.current.height=t*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=e*this.dpr,this.canvasServiceFloatRef.current.height=t*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=e*this.dpr,this.canvasTopRef.current.height=t*this.dpr))}}destroy(){if(super.destroy(),this.eventTragetElement){const e=this.eventTragetElement.parentElement;if(e){const t=e.querySelectorAll(".appliance-plugin-main-view-displayer");for(const i of t)i.remove()}}}createMainViewDisplayer(e){const t=document.createElement("div");return t.className="appliance-plugin-main-view-displayer",e.appendChild(t),this.eventTragetElement=e.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),ns.render(M.createElement(ii,{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 aw extends ZM{constructor(e,t,i){super(e,t,i);y(this,"dpr",Ke());y(this,"width",1e3);y(this,"height",1e3);y(this,"vDom");y(this,"eventTragetElement");y(this,"canvasContainerRef",M.createRef());y(this,"subLocalCanvasContainerRef",M.createRef());y(this,"canvasTopRef",M.createRef());y(this,"canvasServiceFloatRef",M.createRef());y(this,"canvasFloatRef",M.createRef());y(this,"canvasBgRef",M.createRef());y(this,"floatBarRef",M.createRef());y(this,"containerOffset",{x:0,y:0})}setCanvassStyle(){if(this.eventTragetElement){let e=Ke();if(this.canvasBgRef.current&&(e=Ke(this.canvasBgRef.current.getContext("2d"))),e!==this.dpr&&(this.dpr=e,this.control.worker.updateDpr(this.viewId,this.dpr)),this.canvasContainerRef.current){const t=this.eventTragetElement.offsetWidth||this.width,i=this.eventTragetElement.offsetHeight||this.height;t&&i&&(t!==this.width||i!==this.height)&&(this.width=t,this.height=i,this.canvasContainerRef.current.style.width=`${t}px`,this.canvasContainerRef.current.style.height=`${i}px`)}if(this.canvasBgRef.current){const t=this.eventTragetElement.offsetWidth||this.width,i=this.eventTragetElement.offsetHeight||this.height;t&&i&&(t!==this.width||i!==this.height)&&(this.width=t,this.height=i,this.canvasBgRef.current.width=t*this.dpr,this.canvasBgRef.current.height=i*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=t*this.dpr,this.canvasFloatRef.current.height=i*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=t*this.dpr,this.canvasServiceFloatRef.current.height=i*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=t*this.dpr,this.canvasTopRef.current.height=i*this.dpr))}}}createAppViewDisplayer(e,t){const i=document.createElement("div");return i.className="appliance-plugin-app-view-displayer",t.appendChild(i),this.eventTragetElement=t.children[0],this.containerOffset=this.getContainerOffset(this.eventTragetElement,this.containerOffset),this.bindToolsClass(),ns.render(M.createElement(ii,{viewId:e,mananger:this,refs:{canvasServiceFloatRef:this.canvasServiceFloatRef,canvasFloatRef:this.canvasFloatRef,canvasBgRef:this.canvasBgRef,floatBarRef:this.floatBarRef,canvasTopRef:this.canvasTopRef,canvasContainerRef:this.canvasContainerRef,subLocalCanvasContainerRef:this.subLocalCanvasContainerRef}}),i),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement),this}}class We extends It{constructor(e){super(e);y(this,"focuedViewId");y(this,"focuedView");y(this,"control");y(this,"tmpFocusedViewId");y(this,"checkScaleTimer");y(this,"onMainViewRelease",async e=>{this.control.textEditorManager.clear(de,!0),this.mainViewDestroy(e),await new Promise(i=>{setTimeout(()=>{i(!0)},0)}),this.onMainViewMounted(e);const t=this.control.getSnapshootData("memberState");this.control.room&&this.control.onMemberChange(t),this.control.clearSnapshootData()});y(this,"mainViewDestroy",e=>{var t;if(this.mainView&&this.mainView.displayer){this.mainView.displayer.destroy();const i=e.divElement;if(i){const o=i.getElementsByClassName("appliance-plugin-main-view-displayer");for(const n of o)n.remove()}if(this.mainView.container&&i!==this.mainView.container){const o=this.mainView.container.getElementsByClassName("appliance-plugin-main-view-displayer");for(const n of o)n.remove()}(t=this.control.worker)==null||t.destroyViewWorker(this.mainView.id,!0),this.mainView.displayer.destroy(),this.mainView=void 0}});y(this,"onMainViewMounted",e=>{const t=e.divElement;if(!t||!e.focusScenePath||!(e.focusScenePath||e.scenePath))return;const o=new rw(this.control,Ne.InternalMsgEmitter),n=e.size.width||o.width,r=e.size.height||o.height,l={dpr:o.dpr,originalPoint:[n/2,r/2],offscreenCanvasOpt:{...We.defaultScreenCanvasOpt,width:n,height:r},layerOpt:{...We.defaultLayerOpt,width:n,height:r},cameraOpt:{...We.defaultCameraOpt,width:n,height:r}},{scale:h,...u}=e.camera;l.cameraOpt={...l.cameraOpt,...u,scale:h===1/0?1:h},this.focuedViewId=de,this.createMianView({id:de,container:t,displayer:o,focusScenePath:e.focusScenePath,cameraOpt:l.cameraOpt,viewData:e}),this.focuedView=this.mainView,o.createMainViewDisplayer(t),e.callbacks.on("onSizeUpdated",this.onMainViewSizeUpdated),e.callbacks.on("onCameraUpdated",this.onMainViewCameraUpdated),e.callbacks.on("onActiveHotkey",this.onActiveHotkeyChange.bind(this))});y(this,"onMainViewSizeUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.mainView&&this.mainView.viewData&&this.updateMainViewCamera()});y(this,"onMainViewCameraUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.updateMainViewCamera()});y(this,"updateMainViewCamera",()=>{if(this.mainView&&this.mainView.viewData){const e=this.mainView.viewData.camera,t=this.mainView.cameraOpt;if(t){const i=t.width,o=t.height,{width:n,height:r}=this.mainView.viewData.size;(n!==i||r!==o)&&this.mainView.displayer.updateSize();const c=e.scale===1/0?1:e.scale,l=e.centerX||0,h=e.centerY||0,u={...t,scale:c,centerX:l,centerY:h,width:n,height:r};D.isEqual(t,u)||(this.mainView.cameraOpt=u),this.checkScaleTimer&&e.scale==1/0&&(clearTimeout(this.checkScaleTimer),this.checkScaleTimer=void 0),!this.checkScaleTimer&&e.scale===1/0&&this.mainView.viewData&&this.mainView.viewData.camera.scale===1/0&&(this.checkScaleTimer=setTimeout(()=>{var d,f;(f=(d=this.mainView)==null?void 0:d.viewData)==null||f.moveCamera({scale:c,centerX:l,centerY:h,animationMode:"immediately"}),this.checkScaleTimer=void 0},500))}}});y(this,"onAppViewMounted",async e=>{var d;const{appId:t,view:i}=e,o=i.divElement;if(!o||!i.focusScenePath)return;const n=this.appViews.get(t);if(n&&n.displayer){let f=o.getElementsByClassName("appliance-plugin-app-view-displayer");for(const g of f)g.remove();if(n.container&&n.container!==o){f=n.container.getElementsByClassName("appliance-plugin-app-view-displayer");for(const g of f)g.remove()}this.destroyAppView(e.appId,!0),(d=this.control.worker)==null||d.destroyViewWorker(t,!0),await new Promise(g=>{setTimeout(()=>{g(!0)},0)})}const r=new aw(t,this.control,Ne.InternalMsgEmitter),c=i.size.width||r.width,l=i.size.height||r.height,u={dpr:r.dpr,originalPoint:[c/2,l/2],offscreenCanvasOpt:{...We.defaultScreenCanvasOpt,width:c,height:l},layerOpt:{...We.defaultLayerOpt,width:c,height:l},cameraOpt:{...We.defaultCameraOpt,...i.camera,width:c,height:l}};if(this.createAppView({id:t,container:o,displayer:r,cameraOpt:u.cameraOpt,focusScenePath:i.focusScenePath,viewData:i}),r.createAppViewDisplayer(t,o),i.callbacks.on("onSizeUpdated",this.onAppViewSizeUpdated.bind(this,t)),i.callbacks.on("onCameraUpdated",this.onAppViewCameraUpdated.bind(this,t)),i.callbacks.on("onActiveHotkey",this.onActiveHotkeyChange.bind(this)),this.tmpFocusedViewId===t){const f=this.control.worker.getLocalWorkViewId();f&&f!==t?this.setFocuedViewId(f):this.setFocuedViewId(t),this.tmpFocusedViewId=void 0}setTimeout(()=>{this.onAppViewCameraUpdated(t)},0)});y(this,"onAppViewSizeUpdated",async e=>{await new Promise(i=>{setTimeout(()=>{i(!0)},0)});const t=this.appViews.get(e);t&&t.viewData&&this.updateAppCamera(e)});y(this,"onAppViewCameraUpdated",async e=>{await new Promise(t=>{setTimeout(()=>{t(!0)},0)}),this.updateAppCamera(e)});y(this,"updateAppCamera",e=>{const t=this.appViews.get(e);if(t&&t.viewData){const i=t.viewData.camera,o=t.cameraOpt;if(o){const{width:n,height:r}=t.viewData.size,c=o.width,l=o.height;(n!==c||r!==l)&&t.displayer.updateSize();const h=i.scale===1/0?1:i.scale,u=i.centerX||0,d=i.centerY||0,f={...o,scale:h,centerX:u,centerY:d,width:n,height:r};D.isEqual(f,o)||(t.cameraOpt=f)}}});this.control=e.control}getViewInitData(e){var i;const t=this.getView(e);if(t){const{width:o,height:n,dpr:r}=t.displayer;(i=this.control.pluginOptions.canvasOpt)!=null&&i.contextType&&(We.defaultScreenCanvasOpt.contextType=this.control.pluginOptions.canvasOpt.contextType);const c={dpr:r,originalPoint:[o/2,n/2],offscreenCanvasOpt:{...We.defaultScreenCanvasOpt,width:o,height:n},layerOpt:{...We.defaultLayerOpt,width:o,height:n},cameraOpt:{...We.defaultCameraOpt,width:o,height:n}};if(t.viewData){const{scale:l,...h}=t.viewData.camera;c.cameraOpt={...c.cameraOpt,...h,scale:l===1/0?1:l}}return c}}async mountView(e){var i,o;const t=this.getView(e);if(t){e===((i=this.mainView)==null?void 0:i.id)&&(this.control.cursor.activeCollector(),await this.control.activeWorker());const n=this.getViewInitData(e);if(n&&((o=this.control.worker)==null||o.createViewWorker(e,n)),t.focusScenePath&&this.control.collector){if(this.control.collector.authStorage){const{renderAuth:r,pageAuth:c}=this.control.collector.authStorage;if(r){const l=r[e];if(l){const{render:h,hide:u,clear:d}=l;this.control.renderControl.syncRenderUids(e,h,u,d);return}}if(c){const l=c[e];if(l){this.control.renderControl.syncPageAuth(e,l,!0);return}}}this.control.worker.pullServiceData(e,t.focusScenePath,{isAsync:!0,useAnimation:!1})}}}listenerWindowManager(e){e.emitter.on("focusedChange",t=>{const i=t||de;if(this.focuedViewId!==i)if(this.getView(i)){const n=this.control.worker.getLocalWorkViewId();n&&n!==i?this.setFocuedViewId(n):this.setFocuedViewId(i)}else this.tmpFocusedViewId=i}),e.emitter.on("mainViewScenePathChange",t=>{this.control.onSceneChange(t,de)}),e.emitter.on("onMainViewMounted",this.onMainViewMounted),e.emitter.on("onAppViewMounted",this.onAppViewMounted),e.emitter.on("onMainViewRebind",this.onMainViewRelease),e.emitter.on("onBoxClose",t=>{this.appViews.get(t.appId)&&(this.destroyAppView(t.appId),this.control.worker.destroyViewWorker(t.appId))}),e.emitter.on("onAppScenePathChange",t=>{const{appId:i,view:o}=t;this.control.onSceneChange(o.focusScenePath,i)}),e.emitter.on("appsChange",t=>{for(const i of this.appViews.keys())t.includes(i)||(this.destroyAppView(i),this.control.worker.destroyViewWorker(i,!0))})}onActiveHotkeyChange(e){this.control.hotkeyManager.onActiveHotkey(e)}}class _e extends Ne{constructor(e){super(e);y(this,"windowManager");y(this,"viewContainerManager");const t={control:this,internalMsgEmitter:Ne.InternalMsgEmitter,publicMsgEmitter:Ne.PublicMsgEmitter};this.viewContainerManager=new We(t)}init(){}activePlugin(){this.collector&&(this.collector.addAuthStateListener((e,t)=>{e&&Object.keys(e).forEach(i=>{var n;const o=(n=e[i])==null?void 0:n.newValue;this.renderControl.syncRenderUids(i,o==null?void 0:o.render,o==null?void 0:o.hide,o==null?void 0:o.clear)}),t&&Object.keys(t).forEach(i=>{var n;const o=(n=t[i])==null?void 0:n.newValue;this.renderControl.syncPageAuth(i,o)})}),this.collector.addStorageStateListener(e=>{var r,c;if((r=this.collector)!=null&&r.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(de,!0);return}const{diffView:t,diffScenePath:i,diffData:o}=e,n=new Map;if(t){let l;Object.keys(t).forEach(h=>{var d;const u=t[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 f of Object.keys(u.newValue))this.worker.pullServiceData(h,f,{isAsync:!1,useAnimation:!0});l=u.newValue}if(l)for(const f of Object.values(l)){const g=new Set;for(const p of Object.keys(f))p&&g.add(p);n.set(h,g)}})}if(i){let l;Object.keys(i).forEach(h=>{var d;const u=i[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 f=new Set;for(const g of Object.keys(l))g&&f.add(g),n.set(u.viewId,f)}})}o&&Object.keys(o).forEach(l=>{var u,d;const h=o[l];if(h){const{viewId:f}=h,g=n.get(f)||new Set;g.add(l),n.set(f,g),(u=this.worker)==null||u.onServiceDerive(l,h),(d=this.miniMapManager)==null||d.updateMiniMapCamera(f)}});for(const[l,h]of n.entries())Ne.InternalMsgEmitter.emit("excludeIds",[...h],l)}),this.room&&this.roomMember.onUidChangeHook(e=>{var t,i;if((t=this.collector)!=null&&t.serviceStorage){const o=[];this.viewContainerManager.getAllViews().forEach(n=>{var r;if(n&&n.focusScenePath&&((r=this.collector)!=null&&r.serviceStorage[n.id])&&this.collector.serviceStorage[n.id][n.focusScenePath]){const c=Object.keys(this.collector.serviceStorage[n.id][n.focusScenePath]).filter(l=>{var h;return(h=this.collector)==null?void 0:h.isSelector(l)}).map(l=>({viewId:n.id,scenePath:n.focusScenePath,key:l}));c.length&&o.push(...c)}}),o.forEach(({key:n,viewId:r,scenePath:c})=>{var h,u;const l=(h=this.collector)==null?void 0:h.getUidFromKey(n);l&&!e.online.includes(l)&&((u=this.collector)==null||u.updateValue(n,void 0,{isAfterUpdate:!0,viewId:r,scenePath:c}))})}(i=this.cursor)==null||i.updateRoomMembers(e)}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(e=>{e&&e.focusScenePath&&this.worker.pullServiceData(e.id,e.focusScenePath,{isAsync:!0,useAnimation:!1})}))}async activeWorker(){await this.worker.init()}setWindowManager(e){var t,i,o,n,r;this.windowManager=e,(i=(t=this.windowManager)==null?void 0:t.mainView)!=null&&i.divElement&&this.viewContainerManager.onMainViewMounted(this.windowManager.mainView),(r=(n=(o=this.windowManager.appManager)==null?void 0:o.viewManager)==null?void 0:n.views)!=null&&r.size&&this.windowManager.appManager.viewManager.views.forEach((c,l)=>{this.viewContainerManager.onAppViewMounted({appId:l,view:c})}),this.viewContainerManager.listenerWindowManager(this.windowManager)}}const U=class U extends q.InvisiblePlugin{constructor(){super(...arguments);y(this,"onPhaseChanged",e=>{var t;e===q.RoomPhase.Reconnecting&&((t=U.currentManager)==null||t.setSnapshootData())});y(this,"updateRoomWritable",()=>{var e;(e=U.currentManager)==null||e.onWritableChange(this.displayer.isWritable)});y(this,"roomStateChangeListener",async e=>{var t,i;e!=null&&e.roomMembers&&((t=U.currentManager)==null||t.onRoomMembersChange(e.roomMembers)),!(q.isRoom(this.displayer)&&!this.displayer.isWritable)&&e.memberState&&((i=U.currentManager)==null||i.onMemberChange(e.memberState))})}static async getInstance(e,t){!t.options.cdn.fullWorkerUrl&&!t.options.cdn.subWorkerUrl&&U.logger.error("[ApplianceMultiPlugin] you must adaptor options cdn fullWorkerUrl and subWorkerUrl");const i=e.displayer,o=i.callbacks.on,n=i.callbacks.off,r=i.callbacks.once,c=e.cleanCurrentScene,l=e.mainView.setMemberState;let h;q.isRoom(i)&&(h=i.setWritable),t!=null&&t.logger&&(U.logger=t.logger),t.options&&(U.options={...be,...t.options});let u=i.getInvisiblePlugin(U.kind);u||(u=await U.createApplianceMultiPlugin(i,U.kind)),i&&u&&U.createCurrentManager(e,U.options,u),u&&U.currentManager&&(U.currentManager.bindPlugin(u),u.init(i));const d={displayer:i,windowManager:e,currentManager:U.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,getBoundingRectAsync:async function(p){var v;U.logger.info("[ApplianceMultiPlugin] getBoundingRectAsync");const m=(e.mainView||i).getBoundingRect(p),N=await((v=U.currentManager)==null?void 0:v.getBoundingRect(p));return!m.width||!m.height?N:ei(m,N)},screenshotToCanvasAsync:async function(p,m,N,v,T,k){var E;U.logger.info("[ApplianceMultiPlugin] screenshotToCanvasAsync");let S=N,w=v,C=T.scale;S>this.maxScreenshotWidth&&(C=this.maxScreenshotWidth/S*C,S=this.maxScreenshotWidth),w>this.maxScreenshotHeight&&(C=Math.min(this.maxScreenshotHeight/w*C,C),w=this.maxScreenshotHeight),T.scale=C;const L=document.createElement("canvas"),j=L.getContext("2d");L.width=S*(k||1),L.height=w*(k||1),j&&((e.mainView||i).screenshotToCanvas(j,m,S,w,T,k),p.drawImage(L,Math.floor((N-S)/2),Math.floor((v-w)/2),S*(k||1),w*(k||1),0,0,S,w),L.remove()),U.currentManager&&await((E=U.currentManager)==null?void 0:E.screenshotToCanvas(p,m,S,w,T,Math.floor((N-S)/2),Math.floor((v-w)/2)))},scenePreviewAsync:async function(p,m,N,v,T){U.logger.info("[ApplianceMultiPlugin] scenePreviewAsync"),(e.mainView||i).scenePreview(p,m,N,v,T);const k=document.createElement("img");k.className="appliance-plugin-fill-scene-snapshot-img",m.append(k),getComputedStyle(m).position||(m.style.position="relative"),U.currentManager&&await U.currentManager.scenePreview(p,k)},fillSceneSnapshotAsync:async function(p,m,N,v,T){U.logger.info("[ApplianceMultiPlugin] fillSceneSnapshotAsync"),m.innerHTML="",(e.mainView||i).fillSceneSnapshot(p,m,N,v,T);const k=N||e.mainView.size.width,S=v||e.mainView.size.height;let w=await this.getBoundingRectAsync(p);w||(w={originX:0,originY:0,width:k,height:S});let C=Math.max(w==null?void 0:w.width,k),L=Math.max(w==null?void 0:w.height,S),j=1;const E=C>k&&Math.min(k/C,j)||j,A=L>S&&Math.min(S/L,j)||j;E<=A?(C=E<1&&k||C,L=Math.floor(L*E)+1,j=E):E>A&&(L=A<1&&S||L,C=Math.floor(C*A)+1,j=A);const W={scale:j,centerX:w.originX+w.width/2,centerY:w.originY+w.height/2},z=document.createElement("canvas"),O=z.getContext("2d");z.width=C,z.height=L,O&&await this.screenshotToCanvasAsync(O,p,C,L,W,devicePixelRatio);const se=document.createElement("img");se.className="appliance-plugin-fill-scene-snapshot-img",se.src=z.toDataURL(),se.onload=()=>{z.remove()},se.onerror=()=>{z.remove(),se.remove()},m.append(se),getComputedStyle(m).position||(m.style.position="relative")},_callbacksOn:function(p,m){U.logger.info(`[ApplianceMultiPlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&q.isRoom(i)&&i.isWritable?_e.InternalMsgEmitter.on(p,m):o.call(i.callbacks,p,m)},_callbacksOnce:function(p,m){U.logger.info(`[ApplianceMultiPlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&q.isRoom(i)&&i.isWritable?_e.InternalMsgEmitter.on(p,m):r.call(i.callbacks,p,m)},_callbacksOff:function(p,m){U.logger.info(`[ApplianceMultiPlugin] callbacks ${p}`),(p==="onCanUndoStepsUpdate"||p==="onCanRedoStepsUpdate")&&q.isRoom(i)&&i.isWritable?_e.InternalMsgEmitter.off(p,m):n.call(i.callbacks,p,m)},canRedoSteps(){if(U.logger.info("[ApplianceMultiPlugin] canRedoSteps"),U.currentManager&&q.isRoom(i)&&!i.disableSerialization){const p=U.currentManager.viewContainerManager.focuedView,m=p==null?void 0:p.focusScenePath;if(p&&m)return p.displayer.commiter.redoStack.filter(N=>N.scenePath===m).length}return 0},canUndoSteps(){if(U.logger.info("[ApplianceMultiPlugin] canUndoSteps"),U.currentManager&&q.isRoom(i)&&!i.disableSerialization){const p=U.currentManager.viewContainerManager.focuedView,m=p==null?void 0:p.focusScenePath;if(p&&m)return p.displayer.commiter.undoStack.filter(N=>N.scenePath===m).length}return 0},undo:function(){return U.logger.info("[ApplianceMultiPlugin] undo"),U.currentManager&&q.isRoom(i)&&!i.disableSerialization?U.currentManager.viewContainerManager.undo():0},redo:function(){return U.logger.info("[ApplianceMultiPlugin] redo"),U.currentManager&&q.isRoom(i)&&!i.disableSerialization?U.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(){U.logger.info("[ApplianceMultiPlugin] cleanCurrentScene"),U.currentManager&&q.isRoom(i)&&i.isWritable&&(U.currentManager.cleanCurrentScene(),c.call(e))},insertImage:function(p){U.logger.info("[ApplianceMultiPlugin] insertImage"),U.currentManager&&q.isRoom(i)&&i.isWritable&&U.currentManager.worker.insertImage(de,p)},lockImage:function(p,m){U.logger.info("[ApplianceMultiPlugin] lockImage"),U.currentManager&&q.isRoom(i)&&i.isWritable&&U.currentManager.worker.lockImage(de,p,m)},completeImageUpload:function(p,m){U.logger.info("[ApplianceMultiPlugin] completeImageUpload"),U.currentManager&&q.isRoom(i)&&i.isWritable&&U.currentManager.worker.completeImageUpload(de,p,m)},getImagesInformation:function(p){return U.logger.info("[ApplianceMultiPlugin] completeImageUpload"),U.currentManager&&q.isRoom(i)&&i.isWritable?U.currentManager.worker.getImagesInformation(p):[]},callbacks:()=>(U.logger.info("[ApplianceMultiPlugin] callbacks bind"),{...i.callbacks,on:d._callbacksOn.bind(d),once:d._callbacksOnce.bind(d),off:d._callbacksOff.bind(d)}),destroy(){U.currentManager&&(U.logger.info("[ApplianceMultiPlugin] destroy"),U.currentManager.destroy(),U.currentManager=void 0)},setMemberState(p){U.logger.info(`[ApplianceMultiPlugin] setMemberState ${JSON.stringify(p)}`);const m=Object.keys(p);if(q.isRoom(i)&&i.isWritable){m.includes("currentApplianceName")&&(p.currentApplianceName&&p.currentApplianceName===ne.laserPen?(p.currentApplianceName=ne.pencil,p.useLaserPen=!0):p.currentApplianceName&&p.currentApplianceName===ne.pencil&&(p.useLaserPen=!1)),l.call(e.mainView,p);return}throw new Error("[ApplianceMultiPlugin] setMemberState must be called in writable room")},setPerformancePriority(p){U.logger.info("[ApplianceMultiPlugin] setPriority"),U.currentManager&&U.currentManager.setPriority(p)},createMiniMap:async function(p,m){if(U.logger.info("[ApplianceMultiPlugin] createMiniMap"),U.currentManager&&q.isRoom(i)&&i.isWritable)return U.currentManager.createMiniMap(p,m)},destroyMiniMap:async function(p){if(U.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),U.currentManager&&q.isRoom(i)&&i.isWritable)return U.currentManager.destroyMiniMap(p)},filterRenderByUid(p,m,N){if(U.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),U.currentManager&&q.isRoom(i)&&i.isWritable)return U.currentManager.filterRenderByUid(p,m,N)},cancelFilterRender(p,m){if(U.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),U.currentManager&&q.isRoom(i)&&i.isWritable)return U.currentManager.cancelFilterRender(p,m)},addListener:(p,m)=>{U.logger.info(`[ApplianceMultiPlugin] addListener ${p}`),_e.PublicMsgEmitter.on(p,m)},removeListener:(p,m)=>{U.logger.info(`[ApplianceMultiPlugin] removeListener ${p}`),_e.PublicMsgEmitter.off(p,m)},usePlugin:p=>{var m;U.logger.info("[ApplianceMultiPlugin] usePlugin"),(m=U.currentManager)==null||m.usePlugin(p)},getDisableDeviceInputs(){if(U.logger.info("[ApplianceMultiPlugin] getDisableDeviceInputs"),U.currentManager&&q.isRoom(i))return U.currentManager.disableDeviceInputs},setDisableDeviceInputs(p){U.logger.info("[ApplianceMultiPlugin] setDisableDeviceInputs"),U.currentManager&&q.isRoom(i)&&(U.currentManager.disableDeviceInputs=p)},getDisableEraseImage(){if(U.logger.info("[ApplianceMultiPlugin] getDisableEraseImage"),U.currentManager&&q.isRoom(i))return U.currentManager.disableEraseImage},setDisableEraseImage(p){U.logger.info("[ApplianceMultiPlugin] setDisableEraseImage"),U.currentManager&&q.isRoom(i)&&(U.currentManager.disableEraseImage=p)},setWritable:async function(p){var m;U.logger.info(`[ApplianceMultiPlugin] setWritable ${p}`),q.isRoom(i)&&h&&(await((m=U.currentManager)==null?void 0:m.setWritable(p)),await h.call(i,p))}},f=(p,m)=>{if(U.logger.info(`[ApplianceMultiPlugin] injectMethodToObject ${m}`),typeof p[m]=="function"||typeof p[m]>"u"){p[m]=d[m];return}m==="callbacks"&&(p.callbacks.on=d._callbacksOn.bind(d),p.callbacks.off=d._callbacksOff.bind(d),p.callbacks.once=d._callbacksOnce.bind(d))};f(e,"undo"),f(e,"redo"),f(e,"cleanCurrentScene"),f(e,"insertImage"),f(e,"completeImageUpload"),f(e,"lockImage"),f(i,"getImagesInformation"),f(i,"callbacks"),f(i,"screenshotToCanvasAsync"),f(i,"getBoundingRectAsync"),f(i,"scenePreviewAsync"),f(i,"fillSceneSnapshotAsync"),f(e.mainView,"setMemberState"),q.isRoom(i)&&f(i,"setWritable"),Object.defineProperty(e,"canUndoSteps",{get(){return d.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return d.canRedoSteps()}}),_e.InternalMsgEmitter.on("onCanUndoStepsUpdate",p=>{e.emitter.emit("canUndoStepsChange",p)}),_e.InternalMsgEmitter.on("onCanRedoStepsUpdate",p=>{e.emitter.emit("canRedoStepsChange",p)});const g={...d,callbacks:d.callbacks()};return Object.defineProperty(g,"disableDeviceInputs",{set(p){d.setDisableDeviceInputs(p)},get(){return d.getDisableDeviceInputs()}}),Object.defineProperty(g,"disableEraseImage",{set(p){d.setDisableEraseImage(p)},get(){return d.getDisableEraseImage()}}),e._appliancePlugin=g,e._appliancePlugin}static onCreate(e){e&&U.currentManager&&(U.currentManager.bindPlugin(e),e.init(e.displayer))}static async createApplianceMultiPlugin(e,t){try{await e.createInvisiblePlugin(U,{})}catch{if(!e.isWritable){await e.setWritable(!0);const n=await this.createApplianceMultiPlugin(e,t);return await e.setWritable(!1),n}}let i=e.getInvisiblePlugin(t);return i||(i=await U.createApplianceMultiPlugin(e,t)),i}get isReplay(){return q.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(e){var i,o;const t=e.state;(i=U.currentManager)==null||i.onRoomMembersChange(t.roomMembers),q.isRoom(e)&&((o=U.currentManager)==null||o.onMemberChange(t.memberState)),this.displayer.callbacks.on(this.callbackName,this.roomStateChangeListener),this.displayer.callbacks.on("onEnableWriteNowChanged",this.updateRoomWritable),this.displayer.callbacks.on("onPhaseChanged",this.onPhaseChanged)}destroy(){var e;U.logger.info("[ApplianceMultiPlugin] passive destroy"),(e=U.currentManager)==null||e.destroy(),U.currentManager=void 0}};y(U,"kind","appliance-multi-plugin"),y(U,"currentManager"),y(U,"logger",{info:console.log,warn:console.warn,error:console.error}),y(U,"options",be),y(U,"createCurrentManager",(e,t,i)=>{U.currentManager&&U.currentManager.destroy();const o={plugin:i,displayer:e.displayer,options:t},n=new _e(o);U.logger.info("[ApplianceMultiPlugin] refresh ApplianceMultiManager object"),n.setWindowManager(e),U.currentManager=n,e.room&&e.room.logger.info(`[ApplianceMultiPlugin] use ${Xs}`)});let Es=U;class cw extends Ko{constructor(e,t){super(e,t);y(this,"width",1e3);y(this,"height",1e3);y(this,"dpr",Ke());y(this,"vDom");y(this,"viewId",de);y(this,"eventTragetElement");y(this,"snapshotContainerRef");y(this,"canvasContainerRef",M.createRef());y(this,"subLocalCanvasContainerRef",M.createRef());y(this,"canvasTopRef",M.createRef());y(this,"canvasServiceFloatRef",M.createRef());y(this,"canvasFloatRef",M.createRef());y(this,"canvasBgRef",M.createRef());y(this,"floatBarRef",M.createRef());y(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas()||(this.snapshotContainerRef=M.createRef())}setCanvassStyle(){if(this.eventTragetElement){const e=this.eventTragetElement.offsetWidth,t=this.eventTragetElement.offsetHeight;let i=Ke();this.canvasBgRef.current&&(i=Ke(this.canvasBgRef.current.getContext("2d"))),i!==this.dpr&&(this.dpr=i,this.control.worker.updateDpr(this.viewId,this.dpr)),e&&t&&this.canvasContainerRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t),e&&t&&this.canvasBgRef.current&&(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.canvasBgRef.current.width=e*this.dpr,this.canvasBgRef.current.height=t*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=e*this.dpr,this.canvasFloatRef.current.height=t*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=e*this.dpr,this.canvasServiceFloatRef.current.height=t*this.dpr),this.canvasTopRef.current&&(this.canvasTopRef.current.width=e*this.dpr,this.canvasTopRef.current.height=t*this.dpr))}}createMainViewDisplayer(e){return this.vDom||(this.containerOffset=this.getContainerOffset(e,this.containerOffset),this.eventTragetElement=e.parentElement.children[0],e.innerHTML="",ns.render(M.createElement(ii,{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 Xe extends It{constructor(e){super(e);y(this,"focuedViewId");y(this,"control");y(this,"focuedView");this.control=e.control}bindMainView(){if(!this.control.divMainView)return;const e=new cw(this.control,Ne.InternalMsgEmitter);this.focuedViewId=de;const{width:t,height:i,dpr:o}=e,n={dpr:o,originalPoint:[t/2,i/2],offscreenCanvasOpt:{...Xe.defaultScreenCanvasOpt,width:t,height:i},layerOpt:{...Xe.defaultLayerOpt,width:t,height:i},cameraOpt:{...Xe.defaultCameraOpt,width:t,height:i}},r=this.control.room&&this.control.room.mainView||this.control.play&&this.control.play.mainView;if(r){const{scale:c,...l}=r.camera;n.cameraOpt={...n.cameraOpt,...l,scale:c===1/0?1:c},this.createMianView({id:de,displayer:e,focusScenePath:r.focusScenePath||r.scenePath,cameraOpt:n.cameraOpt,viewData:r}),this.focuedView=this.mainView,e.createMainViewDisplayer(this.control.divMainView)}}getViewInitData(e){var i;const t=this.getView(e);if(t){const{width:o,height:n,dpr:r}=t.displayer;(i=this.control.pluginOptions.canvasOpt)!=null&&i.contextType&&(Xe.defaultScreenCanvasOpt.contextType=this.control.pluginOptions.canvasOpt.contextType);const c={dpr:r,originalPoint:[o/2,n/2],offscreenCanvasOpt:{...Xe.defaultScreenCanvasOpt,width:o,height:n},layerOpt:{...Xe.defaultLayerOpt,width:o,height:n},cameraOpt:{...Xe.defaultCameraOpt,width:o,height:n}};if(t.viewData){const{scale:l,...h}=t.viewData.camera;c.cameraOpt={...c.cameraOpt,...h,scale:l===1/0?1:l}}return c}}async mountView(e){var i;const t=this.getView(e);if(t){this.control.worker.isActive||(this.control.cursor.activeCollector(),await this.control.activeWorker());const o=this.getViewInitData(e);o&&((i=this.control.worker)==null||i.createViewWorker(e,o)),t.focusScenePath&&this.control.collector&&this.control.worker.pullServiceData(e,t.focusScenePath,{isAsync:!0,useAnimation:!1})}}}class Ye extends Ne{constructor(e){super(e);y(this,"viewContainerManager");y(this,"divMainView");y(this,"onCameraChange",gs(e=>{var i;const t=this.viewContainerManager.mainView;t&&t.cameraOpt&&(t.cameraOpt.width!==e.width||t.cameraOpt.height!==e.height)&&((i=this.viewContainerManager.mainView)==null||i.displayer.updateSize()),this.viewContainerManager.setFocuedViewCameraOpt(e)},fs,{leading:!1}));const t={control:this,internalMsgEmitter:Ye.InternalMsgEmitter,publicMsgEmitter:Ye.PublicMsgEmitter};this.viewContainerManager=new Xe(t)}init(){Ye.InternalMsgEmitter.on(te.BindMainView,e=>{this.divMainView=e,this.plugin&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView()})}activePlugin(){this.plugin&&this.divMainView&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView(),this.collector&&(this.collector.addStorageStateListener(e=>{var r,c;if((r=this.collector)!=null&&r.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(de,!0);return}const{diffView:t,diffScenePath:i,diffData:o}=e,n=new Map;if(t){let l;Object.keys(t).forEach(h=>{var d;const u=t[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 f of Object.keys(u.newValue))this.worker.pullServiceData(h,f,{isAsync:!1,useAnimation:!0});l=u.newValue}if(l)for(const f of Object.values(l)){const g=new Set;for(const p of Object.keys(f))p&&g.add(p);n.set(h,g)}})}if(i){let l;Object.keys(i).forEach(h=>{var d;const u=i[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 f=new Set;for(const g of Object.keys(l))g&&f.add(g),n.set(u.viewId,f)}})}o&&Object.keys(o).forEach(l=>{var u,d;const h=o[l];if(h){const{viewId:f}=h,g=n.get(f)||new Set;g.add(l),n.set(f,g),(u=this.worker)==null||u.onServiceDerive(l,h),(d=this.miniMapManager)==null||d.updateMiniMapCamera(f)}});for(const[l,h]of n.entries())Ne.InternalMsgEmitter.emit("excludeIds",[...h],l)}),this.room&&(this.roomMember.onUidChangeHook(e=>{var t,i,o,n;if((t=this.collector)!=null&&t.serviceStorage){const r=[];this.viewContainerManager.getAllViews().forEach(c=>{var l,h,u;if(c&&c.focusScenePath&&((l=this.collector)!=null&&l.serviceStorage[c.id])&&((h=this.collector)!=null&&h.serviceStorage[c.id][c.focusScenePath])){const d=Object.keys((u=this.collector)==null?void 0:u.serviceStorage[c.id][c.focusScenePath]).filter(f=>{var g;return(g=this.collector)==null?void 0:g.isSelector(f)}).map(f=>({viewId:c.id,scenePath:c.focusScenePath,key:f}));d.length&&r.push(...d)}}),r.forEach(({key:c,viewId:l,scenePath:h})=>{var d,f;const u=(d=this.collector)==null?void 0:d.getUidFromKey(c);u&&!e.online.includes(u)&&((f=this.collector)==null||f.updateValue(c,void 0,{isAfterUpdate:!0,viewId:l,scenePath:h}))})}(o=(i=this.cursor)==null?void 0:i.eventCollector)!=null&&o.serviceStorage&&Object.keys((n=this.cursor)==null?void 0:n.eventCollector.serviceStorage).forEach(c=>{var l,h;e.online.includes(c)||(h=(l=this.cursor)==null?void 0:l.eventCollector)==null||h.clearValue(c)})}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(e=>{e&&e.focusScenePath&&this.worker.pullServiceData(e.id,e.focusScenePath,{isAsync:!0,useAnimation:!1})})))}async activeWorker(){await this.worker.init()}}const R=class R extends q.InvisiblePlugin{constructor(){super(...arguments);y(this,"onPhaseChanged",e=>{var t;e===q.RoomPhase.Reconnecting&&((t=R.currentManager)==null||t.setSnapshootData())});y(this,"updateRoomWritable",()=>{var e;(e=R.currentManager)==null||e.onWritableChange(this.displayer.isWritable)});y(this,"roomStateChangeListener",async e=>{var t,i;R.currentManager instanceof Ye&&(e.cameraState&&R.currentManager.onCameraChange(e.cameraState),e.sceneState&&R.currentManager.onSceneChange(e.sceneState.scenePath,de)),e!=null&&e.roomMembers&&((t=R.currentManager)==null||t.onRoomMembersChange(e.roomMembers)),!(q.isRoom(this.displayer)&&!this.displayer.isWritable)&&e.memberState&&((i=R.currentManager)==null||i.onMemberChange(e.memberState))})}static async getInstance(e,t){const i=e.callbacks.on,o=e.callbacks.off,n=e.callbacks.once,r=e.cleanCurrentScene.bind(e),c=e.setMemberState.bind(e);let l;q.isRoom(e)&&(l=e.setWritable),t!=null&&t.logger&&(R.logger=t.logger),t.options&&(R.options={...be,...t.options});let h=e.getInvisiblePlugin(R.kind);h||(h=await R.createAppliancePlugin(e,R.kind)),e&&h&&R.createCurrentManager(e,R.options,h),h&&R.currentManager&&(R.currentManager.bindPlugin(h),h.init(e)),t!=null&&t.cursorAdapter&&(R.cursorAdapter=t.cursorAdapter),R.effectInstance();const u={displayer:e,currentManager:R.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,_injectTargetObject:void 0,getBoundingRectAsync:async function(g){var N;R.logger.info("[ApplianceSinglePlugin] getBoundingRectAsync");const p=e.getBoundingRect(g),m=await((N=R.currentManager)==null?void 0:N.getBoundingRect(g));return!p.width||!p.height?m:ei(p,m)},screenshotToCanvasAsync:async function(g,p,m,N,v,T){var j;R.logger.info("[ApplianceSinglePlugin] screenshotToCanvasAsync");let k=m,S=N,w=v.scale;k>this.maxScreenshotWidth&&(w=this.maxScreenshotWidth/k*w,k=this.maxScreenshotWidth),S>this.maxScreenshotHeight&&(w=Math.min(this.maxScreenshotHeight/S*w,w),S=this.maxScreenshotHeight),v.scale=w;const C=document.createElement("canvas"),L=C.getContext("2d");C.width=k*(T||1),C.height=S*(T||1),L&&(e.screenshotToCanvas(L,p,k,S,v,T),g.drawImage(C,Math.floor((m-k)/2),Math.floor((N-S)/2),k*(T||1),S*(T||1),0,0,k,S),C.remove()),R.currentManager&&await((j=R.currentManager)==null?void 0:j.screenshotToCanvas(g,p,k,S,v,Math.floor((m-k)/2),Math.floor((N-S)/2)))},scenePreviewAsync:async function(g,p,m,N,v){R.logger.info("[ApplianceSinglePlugin] scenePreviewAsync"),e.scenePreview(g,p,m,N,v);const T=document.createElement("img");T.className="appliance-plugin-fill-scene-snapshot-img",p.append(T),getComputedStyle(p).position||(p.style.position="relative"),R.currentManager&&await R.currentManager.scenePreview(g,T)},fillSceneSnapshotAsync:async function(g,p,m,N,v){var se,_;R.logger.info("[ApplianceSinglePlugin] fillSceneSnapshotAsync"),p.innerHTML="",e.fillSceneSnapshot(g,p,m,N,v);const T=m||((se=e.state.cameraState)==null?void 0:se.width)||0,k=N||((_=e.state.cameraState)==null?void 0:_.height)||0;let S=await this.getBoundingRectAsync(g);S||(S={originX:0,originY:0,width:T,height:k});let w=Math.max(S==null?void 0:S.width,T),C=Math.max(S==null?void 0:S.height,k),L=1;const j=w>T&&Math.min(T/w,L)||L,E=C>k&&Math.min(k/C,L)||L;j<=E?(w=j<1&&T||w,C=Math.floor(C*j)+1,L=j):j>E&&(C=E<1&&k||C,w=Math.floor(w*E)+1,L=E);const A={scale:L,centerX:S.originX+S.width/2,centerY:S.originY+S.height/2},W=document.createElement("canvas"),z=W.getContext("2d");W.width=w,W.height=C,z&&await this.screenshotToCanvasAsync(z,g,w,C,A,devicePixelRatio);const O=document.createElement("img");O.className="appliance-plugin-fill-scene-snapshot-img",O.src=W.toDataURL(),O.onload=()=>{W.remove()},O.onerror=()=>{W.remove(),O.remove()},p.append(O),getComputedStyle(p).position||(p.style.position="relative")},_callbacksOn:function(g,p){R.logger.info(`[ApplianceSinglePlugin] callbacks ${g}`),(g==="onCanUndoStepsUpdate"||g==="onCanRedoStepsUpdate")&&q.isRoom(e)&&e.isWritable?Ye.InternalMsgEmitter.on(g,p):i.call(e.callbacks,g,p)},_callbacksOnce:function(g,p){R.logger.info(`[ApplianceSinglePlugin] callbacks ${g}`),(g==="onCanUndoStepsUpdate"||g==="onCanRedoStepsUpdate")&&q.isRoom(e)&&e.isWritable?Ye.InternalMsgEmitter.on(g,p):n.call(e.callbacks,g,p)},_callbacksOff:function(g,p){R.logger.info(`[ApplianceSinglePlugin] callbacks ${g}`),(g==="onCanUndoStepsUpdate"||g==="onCanRedoStepsUpdate")&&q.isRoom(e)&&e.isWritable?Ye.InternalMsgEmitter.off(g,p):o.call(e.callbacks,g,p)},canRedoSteps(){if(R.logger.info("[ApplianceSinglePlugin] canRedoSteps"),R.currentManager&&q.isRoom(e)&&!e.disableSerialization){const g=R.currentManager.viewContainerManager.focuedView,p=g==null?void 0:g.focusScenePath;if(g&&p)return g.displayer.commiter.redoStack.filter(m=>m.scenePath===p).length}return 0},canUndoSteps(){if(R.logger.info("[ApplianceSinglePlugin] canUndoSteps"),R.currentManager&&q.isRoom(e)&&!e.disableSerialization){const g=R.currentManager.viewContainerManager.focuedView,p=g==null?void 0:g.focusScenePath;if(g&&p)return g.displayer.commiter.undoStack.filter(m=>m.scenePath===p).length}return 0},undo:function(){return R.logger.info("[ApplianceSinglePlugin] undo"),R.currentManager&&q.isRoom(e)&&!e.disableSerialization?R.currentManager.viewContainerManager.undo():0},redo:function(){return R.logger.info("[ApplianceSinglePlugin] redo"),R.currentManager&&q.isRoom(e)&&!e.disableSerialization?R.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(g){R.logger.info("[ApplianceSinglePlugin] cleanCurrentScene"),R.currentManager&&q.isRoom(e)&&e.isWritable&&(R.currentManager.cleanCurrentScene(),r.call(e,g))},insertImage:function(g){R.logger.info("[ApplianceSinglePlugin] insertImage"),R.currentManager&&q.isRoom(e)&&e.isWritable&&R.currentManager.worker.insertImage(de,g)},lockImage:function(g,p){R.logger.info("[ApplianceSinglePlugin] lockImage"),R.currentManager&&q.isRoom(e)&&e.isWritable&&R.currentManager.worker.lockImage(de,g,p)},completeImageUpload:function(g,p){R.logger.info("[ApplianceSinglePlugin] completeImageUpload"),R.currentManager&&q.isRoom(e)&&e.isWritable&&R.currentManager.worker.completeImageUpload(de,g,p)},getImagesInformation:function(g){return R.logger.info("[ApplianceSinglePlugin] completeImageUpload"),R.currentManager&&q.isRoom(e)&&e.isWritable?R.currentManager.worker.getImagesInformation(g):[]},callbacks:()=>({...e.callbacks,on:u._callbacksOn.bind(u),once:u._callbacksOnce.bind(u),off:u._callbacksOff.bind(u)}),destroy(){R.currentManager&&(R.logger.info("[ApplianceSinglePlugin] destroy"),R.currentManager.destroy(),R.currentManager=void 0,R.cursorAdapter=void 0)},setMemberState(g){R.logger.info(`[ApplianceSinglePlugin] setMemberState ${JSON.stringify(g)}`);const p=Object.keys(g);if(q.isRoom(e)&&e.isWritable){p.includes("currentApplianceName")&&(g.currentApplianceName&&g.currentApplianceName===ne.laserPen?(g.currentApplianceName=ne.pencil,g.useLaserPen=!0):g.currentApplianceName&&g.currentApplianceName===ne.pencil&&(g.useLaserPen=!1)),c(g);return}throw new Error("setMemberState must be called in writable room")},setPerformancePriority(g){R.logger.info("[ApplianceSinglePlugin] setPriority"),R.currentManager&&R.currentManager.setPriority(g)},createMiniMap:async function(g,p){if(R.logger.info("[ApplianceSinglePlugin] createMiniMap"),R.currentManager&&q.isRoom(e)&&e.isWritable)return R.currentManager.createMiniMap(g,p)},destroyMiniMap:async function(g){if(R.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),R.currentManager&&q.isRoom(e)&&e.isWritable)return R.currentManager.destroyMiniMap(g)},filterRenderByUid(g,p,m){if(R.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),R.currentManager&&q.isRoom(e)&&e.isWritable)return R.currentManager.filterRenderByUid(g,p,m)},cancelFilterRender(g,p){if(R.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),R.currentManager&&q.isRoom(e)&&e.isWritable)return R.currentManager.cancelFilterRender(g,p)},addListener:(g,p)=>{R.logger.info(`[ApplianceSinglePlugin] addListener ${g}`),Ye.PublicMsgEmitter.on(g,p)},removeListener:(g,p)=>{R.logger.info(`[ApplianceSinglePlugin] removeListener ${g}`),Ye.PublicMsgEmitter.off(g,p)},usePlugin:g=>{var p;R.logger.info("[ApplianceSinglePlugin] usePlugin"),(p=R.currentManager)==null||p.usePlugin(g)},getDisableDeviceInputs(){if(R.logger.info("[ApplianceSinglePlugin] getDisableDeviceInputs"),R.currentManager&&q.isRoom(e))return R.currentManager.disableDeviceInputs},setDisableDeviceInputs(g){R.logger.info("[ApplianceSinglePlugin] setDisableDeviceInputs"),R.currentManager&&q.isRoom(e)&&(R.currentManager.disableDeviceInputs=g)},getDisableEraseImage(){if(R.logger.info("[ApplianceSinglePlugin] getDisableEraseImage"),R.currentManager&&q.isRoom(e))return R.currentManager.disableEraseImage},setDisableEraseImage(g){R.logger.info("[ApplianceSinglePlugin] setDisableEraseImage"),R.currentManager&&q.isRoom(e)&&(R.currentManager.disableEraseImage=g)},setWritable:async function(g){var p;R.logger.info(`[ApplianceSinglePlugin] setWritable ${g}`),q.isRoom(e)&&l&&(await((p=R.currentManager)==null?void 0:p.setWritable(g)),await l.call(e,g))}},d=(g,p)=>{if(R.logger.info(`[ApplianceSinglePlugin] injectMethodToObject ${p}`),typeof g[p]=="function"||typeof g[p]>"u"){g[p]=u[p];return}p==="callbacks"&&(g.callbacks.on=u._callbacksOn.bind(u),g.callbacks.off=u._callbacksOff.bind(u),g.callbacks.once=u._callbacksOnce.bind(u))};d(e,"undo"),d(e,"redo"),d(e,"cleanCurrentScene"),d(e,"insertImage"),d(e,"completeImageUpload"),d(e,"lockImage"),d(e,"getImagesInformation"),d(e,"callbacks"),d(e,"screenshotToCanvasAsync"),d(e,"getBoundingRectAsync"),d(e,"scenePreviewAsync"),d(e,"fillSceneSnapshotAsync"),d(e,"setMemberState"),q.isRoom(e)&&d(e,"setWritable"),Object.defineProperty(e,"canUndoSteps",{get(){return u.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return u.canRedoSteps()}});const f={...u,callbacks:u.callbacks()};return Object.defineProperty(f,"disableDeviceInputs",{set(g){u.setDisableDeviceInputs(g)},get(){return u.getDisableDeviceInputs()}}),Object.defineProperty(f,"disableEraseImage",{set(g){u.setDisableEraseImage(g)},get(){return u.getDisableEraseImage()}}),e._appliancePlugin=f,e._appliancePlugin}static onCreate(e){e&&R.currentManager&&(R.currentManager.bindPlugin(e),e.init(e.displayer))}static async createAppliancePlugin(e,t){try{await e.createInvisiblePlugin(R,{})}catch{if(!e.isWritable){await e.setWritable(!0);const n=await this.createAppliancePlugin(e,t);return await e.setWritable(!1),n}}let i=e.getInvisiblePlugin(t);return i||(i=await R.createAppliancePlugin(e,t)),i}static effectInstance(){if(R.cursorAdapter){const e=R.cursorAdapter.onAddedCursor;R.cursorAdapter.onAddedCursor=function(t){t.onCursorMemberChanged=i=>{try{i.appliance===ne.pencil||i.appliance===ne.shape||i.appliance===ne.text||i.appliance===ne.arrow||i.appliance===ne.straight||i.appliance===ne.rectangle||i.appliance===ne.ellipse||i.appliance===ne.eraser?t!=null&&t.divElement&&(t.divElement.style.display="none"):t!=null&&t.divElement&&(t.divElement.style.display="block")}catch{}},e.call(R.cursorAdapter,t)}}}get isReplay(){return q.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(e){var i,o;const t=e.state;(i=R.currentManager)==null||i.onRoomMembersChange(t.roomMembers),q.isRoom(e)&&t!=null&&t.memberState&&((o=R.currentManager)==null||o.onMemberChange(t.memberState)),this.displayer.callbacks.on(this.callbackName,this.roomStateChangeListener),this.displayer.callbacks.on("onEnableWriteNowChanged",this.updateRoomWritable),this.displayer.callbacks.on("onPhaseChanged",this.onPhaseChanged)}destroy(){var e;R.logger.info("[ApplianceSinglePlugin] passive destroy"),(e=R.currentManager)==null||e.destroy(),R.currentManager=void 0,R.cursorAdapter=void 0}};y(R,"kind","appliance-aids-single-plugin"),y(R,"cursorAdapter"),y(R,"currentManager"),y(R,"logger",{info:console.log,warn:console.warn,error:console.error}),y(R,"options",be),y(R,"createCurrentManager",(e,t,i)=>{R.currentManager&&R.currentManager.destroy();const o={plugin:i,displayer:e,options:t},n=new Ye(o);n.init(),R.logger.info("[ApplianceSinglePlugin] refresh ApplianceSingleManager object"),R.currentManager=n,q.isRoom(e)&&e.logger.info(`[ApplianceSinglePlugin] use ${Xs}`)});let Os=R;const wt=class wt extends M.Component{constructor(){super(...arguments);y(this,"mainViewRef",null)}componentDidMount(){wt.emiter||(wt.emiter=Ye.InternalMsgEmitter),wt.emiter.emit(te.BindMainView,this.mainViewRef)}render(){return M.createElement(M.Fragment,null,this.props.children,M.createElement("div",{className:"appliance-plugin-main-view-displayer",ref:e=>this.mainViewRef=e}))}};y(wt,"emiter");let Rs=wt;class lw extends Xo{constructor(e){super();y(this,"kind","autoDraw");y(this,"localStorage",[]);y(this,"excludeStorage",[]);y(this,"timer");y(this,"hostServer");y(this,"iconsContainer");y(this,"icons",[]);y(this,"iconRect");y(this,"isActive",!1);y(this,"viewId",de);y(this,"scenePath");y(this,"delay",2e3);const{container:t,hostServer:i,delay:o}=e;this.hostServer=i,this.iconsContainer=t,this.delay=o||2e3}get collector(){return this.control.collector}onDestroy(){this.unMount()}onCreate(){}onSetToolkey(e){e===I.Pencil?this.isActive=!0:(this.isActive&&(this.localStorage.length=0,this.timer&&clearTimeout(this.timer),this.timer=void 0,this.iconRect&&(this.iconRect=void 0),this.icons.length=0),this.isActive=!1)}syncStorage(e,t){if(!this.isActive||e!==this.viewId)return;if(!t){this.localStorage.length=0;return}const i=this.getOwnStorage(this.viewId,t);this.localStorage=i.map(o=>{var n;return((n=this.collector)==null?void 0:n.getLocalId(o))||o})}getOwnStorage(e,t){var n,r;if(!e||!t)return[];const i=(r=(n=this.collector)==null?void 0:n.storage[e])==null?void 0:r[t];return i?Object.keys(i).filter(c=>{var l,h;return((l=this.collector)==null?void 0:l.isOwn(c))&&((h=i[c])==null?void 0:h.toolsType)===I.Pencil&&!this.excludeStorage.includes(c)}):[]}async batchLocalDraw(){var r;if(this.localStorage.length===0||!this.scenePath||!((r=this.collector)==null?void 0:r.getStorageData(this.viewId,this.scenePath)))return;const t=this.localStorage.toString(),i=await this.control.worker.getVNodeInfo(this.localStorage.toString(),this.viewId,this.localStorage);if(!i)return;const{vInfo:o,uuid:n}=i;if(n===t&&o){const c={rect:{centerX:0,centerY:0,width:0,height:0},ink:[]};let l;const h=[];for(const{rect:u,op:d}of o){l=ce(l,u);const f=[],g=[];for(let p=0;p<d.length;p+=3){f.push(d[p]),g.push(d[p+1]);const m=h.length&&h[h.length-1]||0;p===0?h.length===0?h.push(0):h.push(m+100):h.push(m+15)}c.ink.push([f,g,h])}return l&&(c.rect.centerX=Math.floor(l.x+l.w/2),c.rect.centerY=Math.floor(l.y+l.h/2),c.rect.width=Math.floor(l.w),c.rect.height=Math.floor(l.h)),c}}async computAutoDraw(e){const{rect:t,ink:i}=e;this.iconRect=t;const o=await fetch(this.hostServer,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({width:t.width,height:t.height,ink:i})}).then(n=>n.json()).then(n=>n.data);this.icons=o||[]}buildHTML(){var i;this.iconsContainer.innerHTML="";const e=document.createElement("div");e.style.display="flex",e.style.overflow="auto",e.style.padding="10px 0";const t=((i=this.control.worker.currentToolsData)==null?void 0:i.toolsOpt.strokeColor)||"#7f7f7f";this.icons.forEach(o=>{const n=document.createElement("img");n.src=`https://api.iconify.design/${o}.svg?color=${t}`,n.onclick=()=>{this.onClickIcon(o)},n.onload=()=>{e.appendChild(n)}}),this.iconsContainer.appendChild(e)}onClickIcon(e){var t,i;if(this.iconRect){const o=this.control.viewContainerManager.transformToScenePoint([this.iconRect.centerX,this.iconRect.centerY],this.viewId),n=((i=(t=this.control.viewContainerManager.getView(this.viewId))==null?void 0:t.cameraOpt)==null?void 0:i.scale)||1;this.icons.length=0,this.iconsContainer.innerHTML="";const r=Date.now().toString();this.control.worker.removeNodes(this.viewId,this.localStorage),this.localStorage.length=0,this.control.insertIconify(this.viewId,{uuid:r,centerX:o[0],centerY:o[1],width:Math.floor(this.iconRect.width/n),height:Math.floor(this.iconRect.height/n),src:`https://api.iconify.design/${e}.svg`,uniformScale:!1,locked:!1}),this.iconRect=void 0}}sceneChange(e,t){e===this.viewId&&(this.scenePath=t,this.excludeStorage=this.getOwnStorage(e,t)),this.localStorage.length=0}localEvent(e,t){var i;if(e===this.viewId&&((i=this.control.worker.currentToolsData)==null?void 0:i.toolsType)===I.Pencil)switch(t){case P.Start:this.timer&&(clearTimeout(this.timer),this.timer=void 0);break;case P.Done:this.timer&&clearTimeout(this.timer),this.timer=setTimeout(async()=>{this.timer=void 0;const o=await this.batchLocalDraw();o&&(await this.computAutoDraw(o),this.buildHTML())},this.delay);break}}mount(){var t,i;this.scenePath=(t=this.control.viewContainerManager.getView(this.viewId))==null?void 0:t.focusScenePath,this.excludeStorage=this.getOwnStorage(this.viewId,this.scenePath);const e=(i=this.control.worker.currentToolsData)==null?void 0:i.toolsType;e&&this.onSetToolkey(e),this.callbacks("setToolkey",this.onSetToolkey.bind(this)),this.callbacks("syncStorage",this.syncStorage.bind(this)),this.callbacks("sceneChange",this.sceneChange.bind(this)),this.callbacks("localEvent",this.localEvent.bind(this))}unMount(){this.timer&&clearTimeout(this.timer),this.timer=void 0,this.iconRect&&(this.iconRect=void 0),this.icons.length=0,this.excludeStorage.length=0,this.localStorage.length=0,this.iconsContainer.innerHTML="",this.removeCallback("setToolkey"),this.removeCallback("syncStorage"),this.removeCallback("sceneChange"),this.removeCallback("localEvent")}}exports.ActiveContainerType=Ji;exports.ApplianceMultiPlugin=Es;exports.ApplianceNames=ne;exports.ApplianceSigleWrapper=Rs;exports.ApplianceSinglePlugin=Os;exports.AutoDrawPlugin=lw;exports.Cursor_Hover_Id=Qf;exports.DefaultAppliancePluginOptions=be;exports.ECanvasShowType=ye;exports.EDataType=B;exports.EImageType=lt;exports.EMatrixrRelationType=jt;exports.EOperationType=De;exports.EPostMessageType=x;exports.ERenderFilterType=He;exports.EScaleType=re;exports.EStrokeType=ee;exports.EToolsKey=I;exports.ElayerType=Et;exports.EmitEventType=F;exports.EventMessageType=At;exports.EvevtWorkState=P;exports.EvevtWorkType=Ki;exports.InternalMsgEmitterType=te;exports.Main_View_Id=de;exports.Plugin=Xo;exports.ShapeType=Ve;exports.Storage_Selector_key=Q;exports.Storage_Splitter=Ee;exports.Storage_ViewId_ALL=Qt;exports.Task_Time_Interval=fs;exports.VNodeManager=Fo;exports.ViewContainerManager=It;exports.computRect=ce;exports.fullWorker=rn;exports.getRectMatrixrRelation=wM;exports.getShapeInstance=ps;exports.isEqual=tt;exports.isIntersectForPoint=Zo;exports.isNumber=Ae;exports.subWorker=an;exports.throttle=gs;exports.transformToNormalData=it;exports.transformToSerializableData=Re;
|