@netless/appliance-plugin 1.1.35-beta.0 → 1.1.36-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/cdn.js +1 -1
- package/cdn/{fullWorker-BShzOf.js → fullWorker-Cu37fr.js} +1 -1
- package/cdn/{subWorker-DofGU2.js → subWorker-le1nnC.js} +1 -1
- package/dist/appliance-plugin.js +1 -1
- package/dist/appliance-plugin.mjs +1 -1
- package/dist/assets/{fullWorker-BLBp1QlT.js → fullWorker-C_pHxd3d.js} +1 -1
- package/dist/assets/{subWorker-CA5sK8hX.js → subWorker-mLNCeIEX.js} +1 -1
- package/dist/bridge-DO3A2FRh.js +1 -0
- package/dist/{bridge-D6IerdOk.mjs → bridge-DskXXarZ.mjs} +5 -5
- package/dist/bridge-white-web-sdk.d.ts +1 -0
- package/dist/bridge.js +1 -1
- package/dist/bridge.mjs +1 -1
- package/dist/component/textEditor/utils.d.ts +3 -0
- package/dist/fullWorker.js +1 -1
- package/dist/index-B00mKJ2E.js +1 -0
- package/dist/{index-CPmHcL9u.mjs → index-B4Npl8dw.mjs} +1 -1
- package/dist/{index-4k563Sm-.mjs → index-BAT55jp1.mjs} +2522 -2508
- package/dist/{index-DR2km5D4.mjs → index-BBcEMXkc.mjs} +1 -1
- package/dist/{index-D-IWIyEl.mjs → index-BVkfyJQn.mjs} +1 -1
- package/dist/{index-DDL0Hq_X.js → index-CqQPnW7_.js} +1 -1
- package/dist/index-D50QxS0c.js +1 -0
- package/dist/{index-IQRiGPX7.mjs → index-DDULymwD.mjs} +1 -1
- package/dist/{index-D1p6YXf0.mjs → index-DTMQbvIh.mjs} +2390 -2324
- package/dist/{index-328yD4vj.js → index-DlkXPynh.js} +1 -1
- package/dist/{index-DXx1-O0K.js → index-DoKk1ccL.js} +1 -1
- package/dist/{index-CBE_U7Gn.js → index-vfn-RVQz.js} +1 -1
- package/dist/subWorker.js +1 -1
- package/package.json +2 -1
- package/dist/bridge-s6K3XU2g.js +0 -1
- package/dist/index-C89lvDjQ.js +0 -1
- package/dist/index-DbLWM-6h.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var Zr=Object.defineProperty;var $r=(r,n,e)=>n in r?Zr(r,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[n]=e;var I=(r,n,e)=>$r(r,typeof n!="symbol"?n+"":n,e);const F=require("white-web-sdk");require("spritejs");const _i=require("lz-string");require("clipper-lib");require("lineclip");const Cn=require("xss"),x=require("lodash"),Sn=require("eventemitter2"),d=require("react"),rn=require("react-dom"),xt=require("react-draggable"),Hr=require("re-resizable"),Jr="/fullWorker.js",Xr="/subWorker.js";var te=(r=>(r.selector="selector",r.clicker="clicker",r.laserPointer="laserPointer",r.pencil="pencil",r.rectangle="rectangle",r.ellipse="ellipse",r.shape="shape",r.eraser="eraser",r.pencilEraser="pencilEraser",r.text="text",r.straight="straight",r.arrow="arrow",r.hand="hand",r.laserPen="laserPen",r))(te||{}),de=(r=>(r.Normal="Normal",r.Stroke="Stroke",r.Dotted="Dotted",r.LongDotted="LongDotted",r))(de||{}),Ye=(r=>(r.Triangle="triangle",r.Rhombus="rhombus",r.Pentagram="pentagram",r.SpeechBalloon="speechBalloon",r.Star="star",r.Polygon="polygon",r))(Ye||{}),W=(r=>(r.None="None",r.ShowFloatBar="ShowFloatBar",r.ZIndexFloatBar="ZIndexFloatBar",r.DeleteNode="DeleteNode",r.CopyNode="CopyNode",r.ZIndexNode="ZIndexNode",r.ZIndexBackgroundSVG="ZIndexBackgroundSVG",r.RotateNode="RotateNode",r.SetColorNode="SetColorNode",r.TranslateNode="TranslateNode",r.ScaleNode="ScaleNode",r.OriginalEvent="OriginalEvent",r.CreateScene="CreateScene",r.ActiveCursor="ActiveCursor",r.MoveCursor="MoveCursor",r.CommandEditor="CommandEditor",r.SetEditorData="SetEditorData",r.SetFontStyle="SetFontStyle",r.SetPoint="SetPoint",r.SetLock="SetLock",r.SetShapeOpt="SetShapeOpt",r.CameraChange="CameraChange",r.ActiveMethod="ActiveMethod",r.HidFloatBarBtn="HidFloatBarBtn",r))(W||{}),_=(r=>(r.MainEngine="MainEngine",r.Cursor="Cursor",r.BindMainView="BindMainView",r))(_||{}),er=(r=>(r[r.MainView=0]="MainView",r[r.Plugin=1]="Plugin",r[r.Both=2]="Both",r))(er||{}),Fn=(r=>(r.longPencil="longPencil",r))(Fn||{}),T=(r=>(r[r.Pencil=1]="Pencil",r[r.Eraser=2]="Eraser",r[r.PencilEraser=3]="PencilEraser",r[r.BitMapEraser=4]="BitMapEraser",r[r.Selector=5]="Selector",r[r.Clicker=6]="Clicker",r[r.Arrow=7]="Arrow",r[r.Hand=8]="Hand",r[r.LaserPen=9]="LaserPen",r[r.Text=10]="Text",r[r.Straight=11]="Straight",r[r.Rectangle=12]="Rectangle",r[r.Ellipse=13]="Ellipse",r[r.Star=14]="Star",r[r.Triangle=15]="Triangle",r[r.Rhombus=16]="Rhombus",r[r.Polygon=17]="Polygon",r[r.SpeechBalloon=18]="SpeechBalloon",r[r.Image=19]="Image",r[r.BackgroundSVG=20]="BackgroundSVG",r))(T||{}),X=(r=>(r[r.Local=1]="Local",r[r.Service=2]="Service",r[r.Worker=3]="Worker",r))(X||{}),j=(r=>(r[r.Pending=0]="Pending",r[r.Start=1]="Start",r[r.Doing=2]="Doing",r[r.Done=3]="Done",r[r.Unwritable=4]="Unwritable",r))(j||{}),Y=(r=>(r[r.None=0]="None",r[r.Init=1]="Init",r[r.UpdateCamera=2]="UpdateCamera",r[r.UpdateTools=3]="UpdateTools",r[r.CreateWork=4]="CreateWork",r[r.DrawWork=5]="DrawWork",r[r.FullWork=6]="FullWork",r[r.UpdateNode=7]="UpdateNode",r[r.RemoveNode=8]="RemoveNode",r[r.Clear=9]="Clear",r[r.Select=10]="Select",r[r.Destroy=11]="Destroy",r[r.Snapshot=12]="Snapshot",r[r.BoundingBox=13]="BoundingBox",r[r.Cursor=14]="Cursor",r[r.TextUpdate=15]="TextUpdate",r[r.GetTextActive=16]="GetTextActive",r[r.TasksQueue=17]="TasksQueue",r[r.CursorHover=18]="CursorHover",r[r.CursorBlur=19]="CursorBlur",r[r.Console=20]="Console",r[r.GetImageBitMap=23]="GetImageBitMap",r[r.AuthWriter=24]="AuthWriter",r[r.AuthReader=25]="AuthReader",r[r.AuthClear=26]="AuthClear",r[r.AuthPage=27]="AuthPage",r[r.GetVNodeInfo=28]="GetVNodeInfo",r[r.UpdateDpr=29]="UpdateDpr",r[r.SetFontFace=30]="SetFontFace",r[r.ReportError=31]="ReportError",r[r.ReportLog=32]="ReportLog",r[r.BackgroundSVGUpdate=33]="BackgroundSVGUpdate",r[r.BackgroundSVGDelete=34]="BackgroundSVGDelete",r))(Y||{}),$e=(r=>(r[r.None=0]="None",r[r.Bg=1]="Bg",r[r.ServiceFloat=2]="ServiceFloat",r[r.Float=3]="Float",r[r.TopFloat=4]="TopFloat",r))($e||{}),Ut=(r=>(r[r.Cursor=1]="Cursor",r[r.TextCreate=2]="TextCreate",r))(Ut||{}),Ct=(r=>(r[r.Top=1]="Top",r[r.Bottom=2]="Bottom",r))(Ct||{}),Oe=(r=>(r[r.none=1]="none",r[r.all=2]="all",r[r.both=3]="both",r[r.proportional=4]="proportional",r))(Oe||{}),Bt=(r=>(r[r.inside=0]="inside",r[r.outside=1]="outside",r[r.intersect=2]="intersect",r))(Bt||{}),Ce=(r=>(r.renderPage="renderPage",r.addPage="addPage",r.deletePage="deletePage",r.addElement="addElement",r.deleteElement="deleteElement",r.clearPage="clearPage",r.clearViewScenePath="clearViewScenePath",r.clearView="clearView",r.syncUndoStack="syncUndoStack",r.syncRedoStack="syncRedoStack",r))(Ce||{}),Ve=(r=>(r.setAuth="setAuth",r.setShow="addShow",r.setHide="setHide",r.setClear="setClear",r))(Ve||{}),Wt=(r=>(r.Image="image",r.Iconify="iconify",r))(Wt||{}),Vt=(r=>(r.url="url",r.markmap="markmap",r))(Vt||{});const qr="cursorhover",Qn=20,ge="mainView",Kr={linear:r=>r,easeInQuad:r=>r*r,easeOutQuad:r=>r*(2-r),easeInOutQuad:r=>r<.5?2*r*r:-1+(4-2*r)*r,easeInCubic:r=>r*r*r,easeOutCubic:r=>--r*r*r+1,easeInOutCubic:r=>r<.5?4*r*r*r:(r-1)*(2*r-2)*(2*r-2)+1,easeInQuart:r=>r*r*r*r,easeOutQuart:r=>1- --r*r*r*r,easeInOutQuart:r=>r<.5?8*r*r*r*r:1-8*--r*r*r*r,easeInQuint:r=>r*r*r*r*r,easeOutQuint:r=>1+--r*r*r*r*r,easeInOutQuint:r=>r<.5?16*r*r*r*r*r:1+16*--r*r*r*r*r,easeInSine:r=>1-Math.cos(r*Math.PI/2),easeOutSine:r=>Math.sin(r*Math.PI/2),easeInOutSine:r=>-(Math.cos(Math.PI*r)-1)/2,easeInExpo:r=>r<=0?0:Math.pow(2,10*r-10),easeOutExpo:r=>r>=1?1:1-Math.pow(2,-10*r),easeInOutExpo:r=>r<=0?0:r>=1?1:r<.5?Math.pow(2,20*r-10)/2:(2-Math.pow(2,-20*r+10))/2};class B{constructor(n=0,e=0,t=1){this.x=n,this.y=e,this.z=t}get XY(){return[this.x,this.y]}setz(n){return this.z=n,this}setXY(n=this.x,e=this.y){return this.x=n,this.y=e,this}set(n=this.x,e=this.y,t=this.z){return this.x=n,this.y=e,this.z=t,this}setTo({x:n=0,y:e=0,z:t=1}){return this.x=n,this.y=e,this.z=t,this}rot(n){if(n===0)return this;const{x:e,y:t}=this,i=Math.sin(n),o=Math.cos(n);return this.x=e*o-t*i,this.y=e*i+t*o,this}rotWith(n,e){if(e===0)return this;const t=this.x-n.x,i=this.y-n.y,o=Math.sin(e),s=Math.cos(e);return this.x=n.x+(t*s-i*o),this.y=n.y+(t*o+i*s),this}clone(){const{x:n,y:e,z:t}=this;return new B(n,e,t)}sub(n){return this.x-=n.x,this.y-=n.y,this}subXY(n,e){return this.x-=n,this.y-=e,this}subScalar(n){return this.x-=n,this.y-=n,this}add(n){return this.x+=n.x,this.y+=n.y,this}addXY(n,e){return this.x+=n,this.y+=e,this}addScalar(n){return this.x+=n,this.y+=n,this}clamp(n,e){return this.x=Math.max(this.x,n),this.y=Math.max(this.y,n),e!==void 0&&(this.x=Math.min(this.x,e),this.y=Math.min(this.y,e)),this}div(n){return this.x/=n,this.y/=n,this}divV(n){return this.x/=n.x,this.y/=n.y,this}mul(n){return this.x*=n,this.y*=n,this}mulV(n){return this.x*=n.x,this.y*=n.y,this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this}nudge(n,e){const t=B.Tan(n,this);return this.add(t.mul(e))}neg(){return this.x*=-1,this.y*=-1,this}cross(n){return this.x=this.y*n.z-this.z*n.y,this.y=this.z*n.x-this.x*n.z,this}dpr(n){return B.Dpr(this,n)}cpr(n){return B.Cpr(this,n)}len2(){return B.Len2(this)}len(){return B.Len(this)}pry(n){return B.Pry(this,n)}per(){const{x:n,y:e}=this;return this.x=e,this.y=-n,this}uni(){return B.Uni(this)}tan(n){return B.Tan(this,n)}dist(n){return B.Dist(this,n)}distanceToLineSegment(n,e){return B.DistanceToLineSegment(n,e,this)}slope(n){return B.Slope(this,n)}snapToGrid(n){return this.x=Math.round(this.x/n)*n,this.y=Math.round(this.y/n)*n,this}angle(n){return B.Angle(this,n)}toAngle(){return B.ToAngle(this)}lrp(n,e){return this.x=this.x+(n.x-this.x)*e,this.y=this.y+(n.y-this.y)*e,this}equals(n,e){return B.Equals(this,n,e)}equalsXY(n,e){return B.EqualsXY(this,n,e)}norm(){const n=this.len();return this.x=n===0?0:this.x/n,this.y=n===0?0:this.y/n,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(n,e){return new B(n.x+e.x,n.y+e.y)}static AddXY(n,e,t){return new B(n.x+e,n.y+t)}static Sub(n,e){return new B(n.x-e.x,n.y-e.y)}static SubXY(n,e,t){return new B(n.x-e,n.y-t)}static AddScalar(n,e){return new B(n.x+e,n.y+e)}static SubScalar(n,e){return new B(n.x-e,n.y-e)}static Div(n,e){return new B(n.x/e,n.y/e)}static Mul(n,e){return new B(n.x*e,n.y*e)}static DivV(n,e){return new B(n.x/e.x,n.y/e.y)}static MulV(n,e){return new B(n.x*e.x,n.y*e.y)}static Neg(n){return new B(-n.x,-n.y)}static Per(n){return new B(n.y,-n.x)}static Dist2(n,e){return B.Sub(n,e).len2()}static Abs(n){return new B(Math.abs(n.x),Math.abs(n.y))}static Dist(n,e){return Math.hypot(n.y-e.y,n.x-e.x)}static Dpr(n,e){return n.x*e.x+n.y*e.y}static Cross(n,e){return new B(n.y*e.z-n.z*e.y,n.z*e.x-n.x*e.z)}static Cpr(n,e){return n.x*e.y-e.x*n.y}static Len2(n){return n.x*n.x+n.y*n.y}static Len(n){return Math.hypot(n.x,n.y)}static Pry(n,e){return B.Dpr(n,e)/B.Len(e)}static Uni(n){return B.Div(n,B.Len(n))}static Tan(n,e){return B.Uni(B.Sub(n,e))}static Min(n,e){return new B(Math.min(n.x,e.x),Math.min(n.y,e.y))}static Max(n,e){return new B(Math.max(n.x,e.x),Math.max(n.y,e.y))}static From(n){return new B().add(n)}static FromArray(n){return new B(n[0],n[1])}static Rot(n,e=0){const t=Math.sin(e),i=Math.cos(e);return new B(n.x*i-n.y*t,n.x*t+n.y*i)}static RotWith(n,e,t){const i=n.x-e.x,o=n.y-e.y,s=Math.sin(t),a=Math.cos(t);return new B(e.x+(i*a-o*s),e.y+(i*s+o*a))}static NearestPointOnLineThroughPoint(n,e,t){return B.Mul(e,B.Sub(t,n).pry(e)).add(n)}static NearestPointOnLineSegment(n,e,t,i=!0){const o=B.Tan(e,n),s=B.Add(n,B.Mul(o,B.Sub(t,n).pry(o)));if(i){if(s.x<Math.min(n.x,e.x))return B.Cast(n.x<e.x?n:e);if(s.x>Math.max(n.x,e.x))return B.Cast(n.x>e.x?n:e);if(s.y<Math.min(n.y,e.y))return B.Cast(n.y<e.y?n:e);if(s.y>Math.max(n.y,e.y))return B.Cast(n.y>e.y?n:e)}return s}static DistanceToLineThroughPoint(n,e,t){return B.Dist(t,B.NearestPointOnLineThroughPoint(n,e,t))}static DistanceToLineSegment(n,e,t,i=!0){return B.Dist(t,B.NearestPointOnLineSegment(n,e,t,i))}static Snap(n,e=1){return new B(Math.round(n.x/e)*e,Math.round(n.y/e)*e)}static Cast(n){return n instanceof B?n:B.From(n)}static Slope(n,e){return n.x===e.y?NaN:(n.y-e.y)/(n.x-e.x)}static Angle(n,e){return Math.atan2(e.y-n.y,e.x-n.x)}static Lrp(n,e,t){return B.Sub(e,n).mul(t).add(n)}static Med(n,e){return new B((n.x+e.x)/2,(n.y+e.y)/2)}static Equals(n,e,t=1e-4){return Math.abs(n.x-e.x)<t&&Math.abs(n.y-e.y)<t}static EqualsXY(n,e,t){return n.x===e&&n.y===t}static EqualsXYZ(n,e,t=1e-4){return B.Equals(n,e,t)&&Math.abs((n.z||0)-(e.z||0))<t}static Clockwise(n,e,t){return(t.x-n.x)*(e.y-n.y)-(e.x-n.x)*(t.y-n.y)<0}static Rescale(n,e){const t=B.Len(n);return new B(e*n.x/t,e*n.y/t)}static ScaleWithOrigin(n,e,t){return B.Sub(n,t).mul(e).add(t)}static ScaleWOrigin(n,e,t){return B.Sub(n,t).mulV(e).add(t)}static ToFixed(n,e=2){return new B(+n.x.toFixed(e),+n.y.toFixed(e),+n.z.toFixed(e))}static Nudge(n,e,t){return B.Add(n,B.Tan(e,n).mul(t))}static ToString(n){return`${n.x}, ${n.y}`}static ToAngle(n){let e=Math.atan2(n.y,n.x);return e<0&&(e+=Math.PI*2),e}static FromAngle(n,e=1){return new B(Math.cos(n)*e,Math.sin(n)*e)}static ToArray(n){return[n.x,n.y,n.z]}static ToJson(n){const{x:e,y:t,z:i}=n;return{x:e,y:t,z:i}}static Average(n){const e=n.length,t=new B(0,0);for(let i=0;i<e;i++)t.add(n[i]);return t.div(e)}static Clamp(n,e,t){return t===void 0?new B(Math.min(Math.max(n.x,e)),Math.min(Math.max(n.y,e))):new B(Math.min(Math.max(n.x,e),t),Math.min(Math.max(n.y,e),t))}static PointsBetween(n,e,t=6){const i=[];for(let o=0;o<t;o++){const s=Kr.easeInQuad(o/(t-1)),a=B.Lrp(n,e,s);a.z=Math.min(1,.5+Math.abs(.5-_r(s))*.65),i.push(a)}return i}static SnapToGrid(n,e=8){return new B(Math.round(n.x/e)*e,Math.round(n.y/e)*e)}}const _r=r=>r<.5?2*r*r:-1+(4-2*r)*r;class pe extends B{constructor(n=0,e=0,t=0,i={x:0,y:0},o=0,s=0){super(n,e,t),this.x=n,this.y=e,this.z=t,this.v=i,this.t=o,this.a=s}get timestamp(){return this.t}get pressure(){return this.z}get angleNum(){return this.a}get XY(){return[this.x,this.y]}setA(n){this.a=n}setT(n){this.t=n}setv(n){return this.v={x:n.x,y:n.y},this}set(n=this.x,e=this.y,t=this.z,i=this.v,o=this.t,s=this.a){return this.x=n,this.y=e,this.z=t,this.v=i,this.t=o,this.a=s,this}clone(){const{x:n,y:e,z:t,v:i,t:o,a:s}=this,a={x:i.x,y:i.y};return new pe(n,e,t,a,o,s)}distance(n){return pe.GetDistance(this,n)}isNear(n,e){return pe.IsNear(this,n,e)}getAngleByPoints(n,e){return pe.GetAngleByPoints(n,this,e)}static Sub(n,e){return new pe(n.x-e.x,n.y-e.y)}static Add(n,e){return new pe(n.x+e.x,n.y+e.y)}static GetDistance(n,e){return pe.Len(n.clone().sub(e))}static GetAngleByPoints(n,e,t){const i=e.x-n.x,o=t.x-e.x,s=e.y-n.y,a=t.y-e.y;let c=0;const l=Math.sqrt(i*i+s*s),h=Math.sqrt(o*o+a*a);if(l&&h){const u=i*o+s*a;c=Math.acos(u/(l*h)),c=c/Math.PI*180;let f=i*a-s*o;f=f>0?1:-1,c=180+f*c}return c}static IsNear(n,e,t){return pe.Len(n.clone().sub(e))<t}static RotWith(n,e,t,i=2){const o=n.x-e.x,s=n.y-e.y,a=Math.sin(t),c=Math.cos(t),l=Math.pow(10,i),h=Math.floor((e.x+(o*c-s*a))*l)/l,u=Math.floor((e.y+(o*a+s*c))*l)/l;return new pe(h,u)}static GetDotStroke(n,e,t=16){const i=new B(1,1),o=Math.PI+.001,s=pe.Add(n,pe.Sub(n,i).uni().per().mul(-e)),a=[];for(let c=1/t,l=c;l<=1;l+=c)a.push(pe.RotWith(s,n,o*2*l));return a}static GetSemicircleStroke(n,e,t=-1,i=8){const o=t*(Math.PI+.001),s=[];for(let a=1/i,c=a;c<=1;c+=a)s.push(pe.RotWith(e,n,o*c));return s}}var Ht=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function on(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var eo=typeof Ht=="object"&&Ht&&Ht.Object===Object&&Ht,tr=eo,to=tr,no=typeof self=="object"&&self&&self.Object===Object&&self,io=to||no||Function("return this")(),Qe=io,ro=Qe,oo=ro.Symbol,Ft=oo,di=Ft,nr=Object.prototype,so=nr.hasOwnProperty,ao=nr.toString,Ot=di?di.toStringTag:void 0;function co(r){var n=so.call(r,Ot),e=r[Ot];try{r[Ot]=void 0;var t=!0}catch{}var i=ao.call(r);return t&&(n?r[Ot]=e:delete r[Ot]),i}var lo=co,uo=Object.prototype,ho=uo.toString;function go(r){return ho.call(r)}var fo=go,gi=Ft,Mo=lo,po=fo,yo="[object Null]",mo="[object Undefined]",fi=gi?gi.toStringTag:void 0;function Io(r){return r==null?r===void 0?mo:yo:fi&&fi in Object(r)?Mo(r):po(r)}var jt=Io;function wo(r){return r!=null&&typeof r=="object"}var at=wo;function To(){this.__data__=[],this.size=0}var No=To;function vo(r,n){return r===n||r!==r&&n!==n}var Gn=vo,Co=Gn;function So(r,n){for(var e=r.length;e--;)if(Co(r[e][0],n))return e;return-1}var sn=So,ko=sn,xo=Array.prototype,jo=xo.splice;function Do(r){var n=this.__data__,e=ko(n,r);if(e<0)return!1;var t=n.length-1;return e==t?n.pop():jo.call(n,e,1),--this.size,!0}var bo=Do,Ao=sn;function zo(r){var n=this.__data__,e=Ao(n,r);return e<0?void 0:n[e][1]}var Eo=zo,Lo=sn;function Po(r){return Lo(this.__data__,r)>-1}var Oo=Po,Ro=sn;function Yo(r,n){var e=this.__data__,t=Ro(e,r);return t<0?(++this.size,e.push([r,n])):e[t][1]=n,this}var Uo=Yo,Bo=No,Wo=bo,Vo=Eo,Fo=Oo,Qo=Uo;function Dt(r){var n=-1,e=r==null?0:r.length;for(this.clear();++n<e;){var t=r[n];this.set(t[0],t[1])}}Dt.prototype.clear=Bo;Dt.prototype.delete=Wo;Dt.prototype.get=Vo;Dt.prototype.has=Fo;Dt.prototype.set=Qo;var an=Dt,Go=an;function Zo(){this.__data__=new Go,this.size=0}var $o=Zo;function Ho(r){var n=this.__data__,e=n.delete(r);return this.size=n.size,e}var Jo=Ho;function Xo(r){return this.__data__.get(r)}var qo=Xo;function Ko(r){return this.__data__.has(r)}var _o=Ko;function es(r){var n=typeof r;return r!=null&&(n=="object"||n=="function")}var ct=es,ts=jt,ns=ct,is="[object AsyncFunction]",rs="[object Function]",os="[object GeneratorFunction]",ss="[object Proxy]";function as(r){if(!ns(r))return!1;var n=ts(r);return n==rs||n==os||n==is||n==ss}var ir=as,cs=Qe,ls=cs["__core-js_shared__"],us=ls,In=us,Mi=function(){var r=/[^.]+$/.exec(In&&In.keys&&In.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function hs(r){return!!Mi&&Mi in r}var ds=hs,gs=Function.prototype,fs=gs.toString;function Ms(r){if(r!=null){try{return fs.call(r)}catch{}try{return r+""}catch{}}return""}var rr=Ms,ps=ir,ys=ds,ms=ct,Is=rr,ws=/[\\^$.*+?()[\]{}|]/g,Ts=/^\[object .+?Constructor\]$/,Ns=Function.prototype,vs=Object.prototype,Cs=Ns.toString,Ss=vs.hasOwnProperty,ks=RegExp("^"+Cs.call(Ss).replace(ws,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function xs(r){if(!ms(r)||ys(r))return!1;var n=ps(r)?ks:Ts;return n.test(Is(r))}var js=xs;function Ds(r,n){return r==null?void 0:r[n]}var bs=Ds,As=js,zs=bs;function Es(r,n){var e=zs(r,n);return As(e)?e:void 0}var yt=Es,Ls=yt,Ps=Qe,Os=Ls(Ps,"Map"),Zn=Os,Rs=yt,Ys=Rs(Object,"create"),cn=Ys,pi=cn;function Us(){this.__data__=pi?pi(null):{},this.size=0}var Bs=Us;function Ws(r){var n=this.has(r)&&delete this.__data__[r];return this.size-=n?1:0,n}var Vs=Ws,Fs=cn,Qs="__lodash_hash_undefined__",Gs=Object.prototype,Zs=Gs.hasOwnProperty;function $s(r){var n=this.__data__;if(Fs){var e=n[r];return e===Qs?void 0:e}return Zs.call(n,r)?n[r]:void 0}var Hs=$s,Js=cn,Xs=Object.prototype,qs=Xs.hasOwnProperty;function Ks(r){var n=this.__data__;return Js?n[r]!==void 0:qs.call(n,r)}var _s=Ks,ea=cn,ta="__lodash_hash_undefined__";function na(r,n){var e=this.__data__;return this.size+=this.has(r)?0:1,e[r]=ea&&n===void 0?ta:n,this}var ia=na,ra=Bs,oa=Vs,sa=Hs,aa=_s,ca=ia;function bt(r){var n=-1,e=r==null?0:r.length;for(this.clear();++n<e;){var t=r[n];this.set(t[0],t[1])}}bt.prototype.clear=ra;bt.prototype.delete=oa;bt.prototype.get=sa;bt.prototype.has=aa;bt.prototype.set=ca;var la=bt,yi=la,ua=an,ha=Zn;function da(){this.size=0,this.__data__={hash:new yi,map:new(ha||ua),string:new yi}}var ga=da;function fa(r){var n=typeof r;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?r!=="__proto__":r===null}var Ma=fa,pa=Ma;function ya(r,n){var e=r.__data__;return pa(n)?e[typeof n=="string"?"string":"hash"]:e.map}var ln=ya,ma=ln;function Ia(r){var n=ma(this,r).delete(r);return this.size-=n?1:0,n}var wa=Ia,Ta=ln;function Na(r){return Ta(this,r).get(r)}var va=Na,Ca=ln;function Sa(r){return Ca(this,r).has(r)}var ka=Sa,xa=ln;function ja(r,n){var e=xa(this,r),t=e.size;return e.set(r,n),this.size+=e.size==t?0:1,this}var Da=ja,ba=ga,Aa=wa,za=va,Ea=ka,La=Da;function At(r){var n=-1,e=r==null?0:r.length;for(this.clear();++n<e;){var t=r[n];this.set(t[0],t[1])}}At.prototype.clear=ba;At.prototype.delete=Aa;At.prototype.get=za;At.prototype.has=Ea;At.prototype.set=La;var or=At,Pa=an,Oa=Zn,Ra=or,Ya=200;function Ua(r,n){var e=this.__data__;if(e instanceof Pa){var t=e.__data__;if(!Oa||t.length<Ya-1)return t.push([r,n]),this.size=++e.size,this;e=this.__data__=new Ra(t)}return e.set(r,n),this.size=e.size,this}var Ba=Ua,Wa=an,Va=$o,Fa=Jo,Qa=qo,Ga=_o,Za=Ba;function zt(r){var n=this.__data__=new Wa(r);this.size=n.size}zt.prototype.clear=Va;zt.prototype.delete=Fa;zt.prototype.get=Qa;zt.prototype.has=Ga;zt.prototype.set=Za;var sr=zt;function $a(r,n){for(var e=-1,t=r==null?0:r.length;++e<t&&n(r[e],e,r)!==!1;);return r}var Ha=$a,Ja=yt,Xa=function(){try{var r=Ja(Object,"defineProperty");return r({},"",{}),r}catch{}}(),ar=Xa,mi=ar;function qa(r,n,e){n=="__proto__"&&mi?mi(r,n,{configurable:!0,enumerable:!0,value:e,writable:!0}):r[n]=e}var cr=qa,Ka=cr,_a=Gn,ec=Object.prototype,tc=ec.hasOwnProperty;function nc(r,n,e){var t=r[n];(!(tc.call(r,n)&&_a(t,e))||e===void 0&&!(n in r))&&Ka(r,n,e)}var lr=nc,ic=lr,rc=cr;function oc(r,n,e,t){var i=!e;e||(e={});for(var o=-1,s=n.length;++o<s;){var a=n[o],c=t?t(e[a],r[a],a,e,r):void 0;c===void 0&&(c=r[a]),i?rc(e,a,c):ic(e,a,c)}return e}var un=oc;function sc(r,n){for(var e=-1,t=Array(r);++e<r;)t[e]=n(e);return t}var ac=sc,cc=jt,lc=at,uc="[object Arguments]";function hc(r){return lc(r)&&cc(r)==uc}var dc=hc,Ii=dc,gc=at,ur=Object.prototype,fc=ur.hasOwnProperty,Mc=ur.propertyIsEnumerable,pc=Ii(function(){return arguments}())?Ii:function(r){return gc(r)&&fc.call(r,"callee")&&!Mc.call(r,"callee")},hr=pc,yc=Array.isArray,Qt=yc,Kt={exports:{}};function mc(){return!1}var Ic=mc;Kt.exports;(function(r,n){var e=Qe,t=Ic,i=n&&!n.nodeType&&n,o=i&&!0&&r&&!r.nodeType&&r,s=o&&o.exports===i,a=s?e.Buffer:void 0,c=a?a.isBuffer:void 0,l=c||t;r.exports=l})(Kt,Kt.exports);var $n=Kt.exports,wc=9007199254740991,Tc=/^(?:0|[1-9]\d*)$/;function Nc(r,n){var e=typeof r;return n=n??wc,!!n&&(e=="number"||e!="symbol"&&Tc.test(r))&&r>-1&&r%1==0&&r<n}var vc=Nc,Cc=9007199254740991;function Sc(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=Cc}var dr=Sc,kc=jt,xc=dr,jc=at,Dc="[object Arguments]",bc="[object Array]",Ac="[object Boolean]",zc="[object Date]",Ec="[object Error]",Lc="[object Function]",Pc="[object Map]",Oc="[object Number]",Rc="[object Object]",Yc="[object RegExp]",Uc="[object Set]",Bc="[object String]",Wc="[object WeakMap]",Vc="[object ArrayBuffer]",Fc="[object DataView]",Qc="[object Float32Array]",Gc="[object Float64Array]",Zc="[object Int8Array]",$c="[object Int16Array]",Hc="[object Int32Array]",Jc="[object Uint8Array]",Xc="[object Uint8ClampedArray]",qc="[object Uint16Array]",Kc="[object Uint32Array]",Me={};Me[Qc]=Me[Gc]=Me[Zc]=Me[$c]=Me[Hc]=Me[Jc]=Me[Xc]=Me[qc]=Me[Kc]=!0;Me[Dc]=Me[bc]=Me[Vc]=Me[Ac]=Me[Fc]=Me[zc]=Me[Ec]=Me[Lc]=Me[Pc]=Me[Oc]=Me[Rc]=Me[Yc]=Me[Uc]=Me[Bc]=Me[Wc]=!1;function _c(r){return jc(r)&&xc(r.length)&&!!Me[kc(r)]}var el=_c;function tl(r){return function(n){return r(n)}}var hn=tl,_t={exports:{}};_t.exports;(function(r,n){var e=tr,t=n&&!n.nodeType&&n,i=t&&!0&&r&&!r.nodeType&&r,o=i&&i.exports===t,s=o&&e.process,a=function(){try{var c=i&&i.require&&i.require("util").types;return c||s&&s.binding&&s.binding("util")}catch{}}();r.exports=a})(_t,_t.exports);var Hn=_t.exports,nl=el,il=hn,wi=Hn,Ti=wi&&wi.isTypedArray,rl=Ti?il(Ti):nl,gr=rl,ol=ac,sl=hr,al=Qt,cl=$n,ll=vc,ul=gr,hl=Object.prototype,dl=hl.hasOwnProperty;function gl(r,n){var e=al(r),t=!e&&sl(r),i=!e&&!t&&cl(r),o=!e&&!t&&!i&&ul(r),s=e||t||i||o,a=s?ol(r.length,String):[],c=a.length;for(var l in r)(n||dl.call(r,l))&&!(s&&(l=="length"||i&&(l=="offset"||l=="parent")||o&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||ll(l,c)))&&a.push(l);return a}var fr=gl,fl=Object.prototype;function Ml(r){var n=r&&r.constructor,e=typeof n=="function"&&n.prototype||fl;return r===e}var Jn=Ml;function pl(r,n){return function(e){return r(n(e))}}var Mr=pl,yl=Mr,ml=yl(Object.keys,Object),Il=ml,wl=Jn,Tl=Il,Nl=Object.prototype,vl=Nl.hasOwnProperty;function Cl(r){if(!wl(r))return Tl(r);var n=[];for(var e in Object(r))vl.call(r,e)&&e!="constructor"&&n.push(e);return n}var Sl=Cl,kl=ir,xl=dr;function jl(r){return r!=null&&xl(r.length)&&!kl(r)}var Xn=jl,Dl=fr,bl=Sl,Al=Xn;function zl(r){return Al(r)?Dl(r):bl(r)}var qn=zl,El=un,Ll=qn;function Pl(r,n){return r&&El(n,Ll(n),r)}var Ol=Pl;function Rl(r){var n=[];if(r!=null)for(var e in Object(r))n.push(e);return n}var Yl=Rl,Ul=ct,Bl=Jn,Wl=Yl,Vl=Object.prototype,Fl=Vl.hasOwnProperty;function Ql(r){if(!Ul(r))return Wl(r);var n=Bl(r),e=[];for(var t in r)t=="constructor"&&(n||!Fl.call(r,t))||e.push(t);return e}var Gl=Ql,Zl=fr,$l=Gl,Hl=Xn;function Jl(r){return Hl(r)?Zl(r,!0):$l(r)}var Kn=Jl,Xl=un,ql=Kn;function Kl(r,n){return r&&Xl(n,ql(n),r)}var _l=Kl,en={exports:{}};en.exports;(function(r,n){var e=Qe,t=n&&!n.nodeType&&n,i=t&&!0&&r&&!r.nodeType&&r,o=i&&i.exports===t,s=o?e.Buffer:void 0,a=s?s.allocUnsafe:void 0;function c(l,h){if(h)return l.slice();var u=l.length,f=a?a(u):new l.constructor(u);return l.copy(f),f}r.exports=c})(en,en.exports);var eu=en.exports;function tu(r,n){var e=-1,t=r.length;for(n||(n=Array(t));++e<t;)n[e]=r[e];return n}var nu=tu;function iu(r,n){for(var e=-1,t=r==null?0:r.length,i=0,o=[];++e<t;){var s=r[e];n(s,e,r)&&(o[i++]=s)}return o}var pr=iu;function ru(){return[]}var yr=ru,ou=pr,su=yr,au=Object.prototype,cu=au.propertyIsEnumerable,Ni=Object.getOwnPropertySymbols,lu=Ni?function(r){return r==null?[]:(r=Object(r),ou(Ni(r),function(n){return cu.call(r,n)}))}:su,_n=lu,uu=un,hu=_n;function du(r,n){return uu(r,hu(r),n)}var gu=du;function fu(r,n){for(var e=-1,t=n.length,i=r.length;++e<t;)r[i+e]=n[e];return r}var ei=fu,Mu=Mr,pu=Mu(Object.getPrototypeOf,Object),mr=pu,yu=ei,mu=mr,Iu=_n,wu=yr,Tu=Object.getOwnPropertySymbols,Nu=Tu?function(r){for(var n=[];r;)yu(n,Iu(r)),r=mu(r);return n}:wu,Ir=Nu,vu=un,Cu=Ir;function Su(r,n){return vu(r,Cu(r),n)}var ku=Su,xu=ei,ju=Qt;function Du(r,n,e){var t=n(r);return ju(r)?t:xu(t,e(r))}var wr=Du,bu=wr,Au=_n,zu=qn;function Eu(r){return bu(r,zu,Au)}var Tr=Eu,Lu=wr,Pu=Ir,Ou=Kn;function Ru(r){return Lu(r,Ou,Pu)}var Yu=Ru,Uu=yt,Bu=Qe,Wu=Uu(Bu,"DataView"),Vu=Wu,Fu=yt,Qu=Qe,Gu=Fu(Qu,"Promise"),Zu=Gu,$u=yt,Hu=Qe,Ju=$u(Hu,"Set"),Nr=Ju,Xu=yt,qu=Qe,Ku=Xu(qu,"WeakMap"),_u=Ku,kn=Vu,xn=Zn,jn=Zu,Dn=Nr,bn=_u,vr=jt,Et=rr,vi="[object Map]",eh="[object Object]",Ci="[object Promise]",Si="[object Set]",ki="[object WeakMap]",xi="[object DataView]",th=Et(kn),nh=Et(xn),ih=Et(jn),rh=Et(Dn),oh=Et(bn),gt=vr;(kn&>(new kn(new ArrayBuffer(1)))!=xi||xn&>(new xn)!=vi||jn&>(jn.resolve())!=Ci||Dn&>(new Dn)!=Si||bn&>(new bn)!=ki)&&(gt=function(r){var n=vr(r),e=n==eh?r.constructor:void 0,t=e?Et(e):"";if(t)switch(t){case th:return xi;case nh:return vi;case ih:return Ci;case rh:return Si;case oh:return ki}return n});var dn=gt,sh=Object.prototype,ah=sh.hasOwnProperty;function ch(r){var n=r.length,e=new r.constructor(n);return n&&typeof r[0]=="string"&&ah.call(r,"index")&&(e.index=r.index,e.input=r.input),e}var lh=ch,uh=Qe,hh=uh.Uint8Array,Cr=hh,ji=Cr;function dh(r){var n=new r.constructor(r.byteLength);return new ji(n).set(new ji(r)),n}var ti=dh,gh=ti;function fh(r,n){var e=n?gh(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.byteLength)}var Mh=fh,ph=/\w*$/;function yh(r){var n=new r.constructor(r.source,ph.exec(r));return n.lastIndex=r.lastIndex,n}var mh=yh,Di=Ft,bi=Di?Di.prototype:void 0,Ai=bi?bi.valueOf:void 0;function Ih(r){return Ai?Object(Ai.call(r)):{}}var wh=Ih,Th=ti;function Nh(r,n){var e=n?Th(r.buffer):r.buffer;return new r.constructor(e,r.byteOffset,r.length)}var vh=Nh,Ch=ti,Sh=Mh,kh=mh,xh=wh,jh=vh,Dh="[object Boolean]",bh="[object Date]",Ah="[object Map]",zh="[object Number]",Eh="[object RegExp]",Lh="[object Set]",Ph="[object String]",Oh="[object Symbol]",Rh="[object ArrayBuffer]",Yh="[object DataView]",Uh="[object Float32Array]",Bh="[object Float64Array]",Wh="[object Int8Array]",Vh="[object Int16Array]",Fh="[object Int32Array]",Qh="[object Uint8Array]",Gh="[object Uint8ClampedArray]",Zh="[object Uint16Array]",$h="[object Uint32Array]";function Hh(r,n,e){var t=r.constructor;switch(n){case Rh:return Ch(r);case Dh:case bh:return new t(+r);case Yh:return Sh(r,e);case Uh:case Bh:case Wh:case Vh:case Fh:case Qh:case Gh:case Zh:case $h:return jh(r,e);case Ah:return new t;case zh:case Ph:return new t(r);case Eh:return kh(r);case Lh:return new t;case Oh:return xh(r)}}var Jh=Hh,Xh=ct,zi=Object.create,qh=function(){function r(){}return function(n){if(!Xh(n))return{};if(zi)return zi(n);r.prototype=n;var e=new r;return r.prototype=void 0,e}}(),Kh=qh,_h=Kh,ed=mr,td=Jn;function nd(r){return typeof r.constructor=="function"&&!td(r)?_h(ed(r)):{}}var id=nd,rd=dn,od=at,sd="[object Map]";function ad(r){return od(r)&&rd(r)==sd}var cd=ad,ld=cd,ud=hn,Ei=Hn,Li=Ei&&Ei.isMap,hd=Li?ud(Li):ld,dd=hd,gd=dn,fd=at,Md="[object Set]";function pd(r){return fd(r)&&gd(r)==Md}var yd=pd,md=yd,Id=hn,Pi=Hn,Oi=Pi&&Pi.isSet,wd=Oi?Id(Oi):md,Sr=wd;const Td=on(Sr);var Nd=sr,vd=Ha,Cd=lr,Sd=Ol,kd=_l,xd=eu,jd=nu,Dd=gu,bd=ku,Ad=Tr,zd=Yu,Ed=dn,Ld=lh,Pd=Jh,Od=id,Rd=Qt,Yd=$n,Ud=dd,Bd=ct,Wd=Sr,Vd=qn,Fd=Kn,Qd=1,Gd=2,Zd=4,kr="[object Arguments]",$d="[object Array]",Hd="[object Boolean]",Jd="[object Date]",Xd="[object Error]",xr="[object Function]",qd="[object GeneratorFunction]",Kd="[object Map]",_d="[object Number]",jr="[object Object]",eg="[object RegExp]",tg="[object Set]",ng="[object String]",ig="[object Symbol]",rg="[object WeakMap]",og="[object ArrayBuffer]",sg="[object DataView]",ag="[object Float32Array]",cg="[object Float64Array]",lg="[object Int8Array]",ug="[object Int16Array]",hg="[object Int32Array]",dg="[object Uint8Array]",gg="[object Uint8ClampedArray]",fg="[object Uint16Array]",Mg="[object Uint32Array]",fe={};fe[kr]=fe[$d]=fe[og]=fe[sg]=fe[Hd]=fe[Jd]=fe[ag]=fe[cg]=fe[lg]=fe[ug]=fe[hg]=fe[Kd]=fe[_d]=fe[jr]=fe[eg]=fe[tg]=fe[ng]=fe[ig]=fe[dg]=fe[gg]=fe[fg]=fe[Mg]=!0;fe[Xd]=fe[xr]=fe[rg]=!1;function Xt(r,n,e,t,i,o){var s,a=n&Qd,c=n&Gd,l=n&Zd;if(e&&(s=i?e(r,t,i,o):e(r)),s!==void 0)return s;if(!Bd(r))return r;var h=Rd(r);if(h){if(s=Ld(r),!a)return jd(r,s)}else{var u=Ed(r),f=u==xr||u==qd;if(Yd(r))return xd(r,a);if(u==jr||u==kr||f&&!i){if(s=c||f?{}:Od(r),!a)return c?bd(r,kd(s,r)):Dd(r,Sd(s,r))}else{if(!fe[u])return i?r:{};s=Pd(r,u,a)}}o||(o=new Nd);var p=o.get(r);if(p)return p;o.set(r,s),Wd(r)?r.forEach(function(w){s.add(Xt(w,n,e,w,r,o))}):Ud(r)&&r.forEach(function(w,y){s.set(y,Xt(w,n,e,y,r,o))});var g=l?c?zd:Ad:c?Fd:Vd,m=h?void 0:g(r);return vd(m||r,function(w,y){m&&(y=w,w=r[y]),Cd(s,y,Xt(w,n,e,y,r,o))}),s}var pg=Xt,yg=pg,mg=1,Ig=4;function wg(r){return yg(r,mg|Ig)}var Tg=wg;const Gt=on(Tg),Dr="1.1.36-beta.0",Ng="@netless/appliance-plugin",Ri=typeof OffscreenCanvas=="function"?"worker":"mainThread";if(typeof window<"u"){let r=window.__netlessUA||"";r+=` ${Ng}@${Dr}`,window.__netlessUA=r}const me={useWorker:"auto",useSimple:!1,useBackgroundThread:!1,syncOpt:{interval:300,smoothSync:!0},cursor:{enable:!0,expirationTime:5e3,moveDelayTime:100},bufferSize:{full:2e4,sub:600},bezier:{enable:!0,maxDrawCount:1/0,combineUnitTime:300},pencilEraser:{useBitMap:!0,maxImageWidth:1920,maxImageHeight:1920,maxCombineTime:500},strokeWidth:{min:1,max:10},textEditor:{showFloatBar:!0,canSelectorSwitch:!0,rightBoundBreak:!1,extendFontFaces:[],loadFontFacesTimeout:1e4},longDottedStroke:{lineCap:"round",segment:1,gap:2},dottedStroke:{lineCap:"round",segment:1,gap:2},normalStroke:{lineCap:"round"},undoRedo:{enableGlobal:!1,maxStackLength:20},markmap:{enable:!0,timeout:1e4,options:{autoFit:!0,duration:0,zoom:!1,pan:!1,maxInitialScale:10}}};function gn(r){return JSON.parse(_i.decompress(r))}function St(r){return _i.compress(JSON.stringify(r))}const ke=Object.keys,Je="++",Z="selector",br="all";var vg="__lodash_hash_undefined__";function Cg(r){return this.__data__.set(r,vg),this}var Sg=Cg;function kg(r){return this.__data__.has(r)}var xg=kg,jg=or,Dg=Sg,bg=xg;function tn(r){var n=-1,e=r==null?0:r.length;for(this.__data__=new jg;++n<e;)this.add(r[n])}tn.prototype.add=tn.prototype.push=Dg;tn.prototype.has=bg;var ni=tn;function Ag(r,n){for(var e=-1,t=r==null?0:r.length;++e<t;)if(n(r[e],e,r))return!0;return!1}var zg=Ag;function Eg(r,n){return r.has(n)}var ii=Eg,Lg=ni,Pg=zg,Og=ii,Rg=1,Yg=2;function Ug(r,n,e,t,i,o){var s=e&Rg,a=r.length,c=n.length;if(a!=c&&!(s&&c>a))return!1;var l=o.get(r),h=o.get(n);if(l&&h)return l==n&&h==r;var u=-1,f=!0,p=e&Yg?new Lg:void 0;for(o.set(r,n),o.set(n,r);++u<a;){var g=r[u],m=n[u];if(t)var w=s?t(m,g,u,n,r,o):t(g,m,u,r,n,o);if(w!==void 0){if(w)continue;f=!1;break}if(p){if(!Pg(n,function(y,M){if(!Og(p,M)&&(g===y||i(g,y,e,t,o)))return p.push(M)})){f=!1;break}}else if(!(g===m||i(g,m,e,t,o))){f=!1;break}}return o.delete(r),o.delete(n),f}var Ar=Ug;function Bg(r){var n=-1,e=Array(r.size);return r.forEach(function(t,i){e[++n]=[i,t]}),e}var Wg=Bg;function Vg(r){var n=-1,e=Array(r.size);return r.forEach(function(t){e[++n]=t}),e}var ri=Vg,Yi=Ft,Ui=Cr,Fg=Gn,Qg=Ar,Gg=Wg,Zg=ri,$g=1,Hg=2,Jg="[object Boolean]",Xg="[object Date]",qg="[object Error]",Kg="[object Map]",_g="[object Number]",ef="[object RegExp]",tf="[object Set]",nf="[object String]",rf="[object Symbol]",of="[object ArrayBuffer]",sf="[object DataView]",Bi=Yi?Yi.prototype:void 0,wn=Bi?Bi.valueOf:void 0;function af(r,n,e,t,i,o,s){switch(e){case sf:if(r.byteLength!=n.byteLength||r.byteOffset!=n.byteOffset)return!1;r=r.buffer,n=n.buffer;case of:return!(r.byteLength!=n.byteLength||!o(new Ui(r),new Ui(n)));case Jg:case Xg:case _g:return Fg(+r,+n);case qg:return r.name==n.name&&r.message==n.message;case ef:case nf:return r==n+"";case Kg:var a=Gg;case tf:var c=t&$g;if(a||(a=Zg),r.size!=n.size&&!c)return!1;var l=s.get(r);if(l)return l==n;t|=Hg,s.set(r,n);var h=Qg(a(r),a(n),t,i,o,s);return s.delete(r),h;case rf:if(wn)return wn.call(r)==wn.call(n)}return!1}var cf=af;function Zt(r,n,e){return"#"+((r<<16)+(n<<8)+e).toString(16).padStart(6,"0")}function xe(r,n=1){return"rgba("+parseInt("0x"+r.slice(1,3))+","+parseInt("0x"+r.slice(3,5))+","+parseInt("0x"+r.slice(5,7))+","+n+")"}function Tt(r,n,e,t=1){return`rgba(${r},${n},${e},${t})`}function fn(r){const n=r.split(","),e=parseInt(n[0].split("(")[1]),t=parseInt(n[1]),i=parseInt(n[2]),o=Number(n[3].split(")")[0]);return[Zt(e,t,i),o]}function Yt(r){const n=r.split(","),e=parseInt(n[0].split("(")[1]),t=parseInt(n[1]),i=parseInt(n[2]),o=Number(n[3].split(")")[0]);return[e,t,i,o]}function Jt(r){return r==="transparent"}var Fe=(r=>(r[r.Text=1]="Text",r[r.Shape=2]="Shape",r))(Fe||{});const Re=class Re{createProxy(n){const e=new Proxy(n,{get(t,i,o){const s=Re.interceptors.hasOwnProperty(i)?Re.interceptors:t;return Reflect.get(s,i,o)}});return Re.proxyToRaw.set(e,n),e}};I(Re,"proxyToRaw",new WeakMap),I(Re,"interceptors",{entries(...n){return Re.proxyToRaw.get(this).entries(...n)},forEach(...n){return Re.proxyToRaw.get(this).forEach(...n)},size(){return Re.proxyToRaw.get(this).size},get(n){return Re.proxyToRaw.get(this).get(n)},set(n,e){return Re.proxyToRaw.get(this).set(n,e)},delete(n){return Re.proxyToRaw.get(this).delete(n)},clear(){return Re.proxyToRaw.get(this).clear()}});let ft=Re;const An=5;class lf{constructor(n){I(this,"internalMsgEmitter");I(this,"publicMsgEmitter");I(this,"control");I(this,"editors");I(this,"activeId");I(this,"proxyMap");I(this,"taskqueue",new Map);I(this,"undoTickerId");I(this,"checkLocalTextBlur",x.debounce(()=>{if(this.collector)for(const[n,e]of this.editors.entries())e.opt.workState!==j.Done&&this.collector.isLocalId(n)&&this.activeId!==n&&(e.opt.text&&e.opt.text.replace(/\s*,/g,"")?this.unActive(n):this.delete(n,!0,!0))},100));const{control:e,internalMsgEmitter:t,publicMsgEmitter:i}=n;this.control=e,this.internalMsgEmitter=t,this.publicMsgEmitter=i;const o=new Map;this.proxyMap=new ft;const s=this,a=ft.interceptors.set;ft.interceptors.set=function(l,h){return s.interceptors.set(l,h),a.call(this,l,h)};const c=ft.interceptors.delete;ft.interceptors.delete=function(l){return s.interceptors.delete(l),c.call(this,l)},this.editors=this.proxyMap.createProxy(o)}get collector(){return this.control.collector}set UndoTickerId(n){this.undoTickerId=n}filterEditor(n){const e=new Map;return this.editors.forEach((t,i)=>{t.viewId===n&&e.set(i,t)}),e}get interceptors(){return{set:(n,e)=>{var g,m,w,y,M,v,S,C,k;if(!this.collector)return!0;const{viewId:t,scenePath:i,canSync:o,canWorker:s,type:a,opt:c,dataType:l,updateNodeOpt:h}=e;if(!s&&!o)return!0;const f=((g=this.collector)==null?void 0:g.isLocalId(n))?(m=this.collector)==null?void 0:m.transformKey(n):n,p=((w=this.collector)==null?void 0:w.storage[t])&&this.collector.storage[t][i]&&this.collector.storage[t][i][f]||void 0;p?p.toolsType===T.Text&&(s&&(this.control.worker.queryTaskBatchData({workId:n,msgType:Y.UpdateNode}).forEach(N=>{var z;(z=this.control.worker)==null||z.taskBatchData.delete(N)}),(S=this.control.worker)==null||S.taskBatchData.add({workId:n,msgType:Y.UpdateNode,dataType:l||X.Local,toolsType:T.Text,opt:c,viewId:t,scenePath:i,willRefresh:!0}),(C=this.control.worker)==null||C.runAnimation()),o&&((k=this.collector)==null||k.dispatch({type:Y.UpdateNode,workId:n,toolsType:T.Text,opt:c,viewId:t,scenePath:i,updateNodeOpt:h}),c.workState===j.Done&&this.undoTickerId&&this.control.viewContainerManager.getUndoTickerId(t)===this.undoTickerId&&(this.internalMsgEmitter.emit("forceUndoTickerEnd",this.undoTickerId,t),this.undoTickerId=void 0),c.workState===j.Done&&this.control.runEffectWork(()=>{this.control.worker.setShapeSelectorByWorkId(n,t)}))):a===Fe.Text&&(o&&((y=this.collector)==null||y.dispatch({type:c.text&&Y.FullWork||Y.CreateWork,workId:n,toolsType:T.Text,opt:c,isSync:!0,viewId:t,scenePath:i,updateNodeOpt:h})),s&&((M=this.control.worker)==null||M.taskBatchData.add({workId:n,msgType:c.text&&Y.FullWork||Y.CreateWork,dataType:l||X.Local,toolsType:T.Text,opt:c,viewId:t,scenePath:i,willRefresh:!0}),(v=this.control.worker)==null||v.runAnimation()))},delete:n=>{var a,c,l;if(!this.collector)return!0;const e=this.editors.get(n);if(!e)return!0;const{viewId:t,scenePath:i,canSync:o,canWorker:s}=e;if(!s&&!o)return!0;s&&((a=this.control.worker)==null||a.taskBatchData.add({workId:n,toolsType:T.Text,msgType:Y.RemoveNode,dataType:X.Local,viewId:t,scenePath:i,willRefresh:!0}),(c=this.control.worker)==null||c.runAnimation()),o&&((l=this.collector)==null||l.dispatch({type:Y.RemoveNode,removeIds:[n],toolsType:T.Text,viewId:t,scenePath:i}),this.undoTickerId&&this.control.viewContainerManager.getUndoTickerId(t)===this.undoTickerId&&(this.internalMsgEmitter.emit("forceUndoTickerEnd",this.undoTickerId,t),this.undoTickerId=void 0))},clear(){return!0}}}computeTextActive(n,e){var o,s,a,c;const t=(o=this.control.viewContainerManager)==null?void 0:o.transformToScenePoint(n,e),i=(s=this.control.viewContainerManager)==null?void 0:s.getCurScenePath(e);e&&i&&((a=this.control.worker)==null||a.taskBatchData.add({msgType:Y.GetTextActive,dataType:X.Local,op:t,viewId:e,scenePath:i}),(c=this.control.worker)==null||c.runAnimation())}checkEmptyTextBlur(){var e;let n=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)){n=t;break}if(n){const t=this.editors.get(n);(t==null?void 0:t.opt.text)&&(t==null?void 0:t.opt.text.replace(/\s*,/g,""))?this.unActive(n):this.delete(n,!0,!0)}this.checkLocalTextBlur()}onCameraChange(n,e){var t,i;for(const[o,s]of this.editors.entries())if(s.viewId===e){const{boxPoint:a,boxSize:c}=s.opt,l=a&&((t=this.control.viewContainerManager)==null?void 0:t.transformToOriginPoint(a,s.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:s.opt,scale:n.scale,type:Fe.Text,viewId:e,scenePath:h,canWorker:!1,canSync:!1};this.editors.set(o,u),this.control.viewContainerManager.updateTextEditorInfo(e,this.activeId)}}}onServiceDerive(n){var m,w,y;const{workId:e,opt:t,msgType:i,viewId:o,scenePath:s,dataType:a,updateNodeOpt:c}=n;if(!e||!o||!s)return;const l=e.toString();if(i===Y.RemoveNode){this.delete(l,!0,!0);return}const{boxPoint:h,boxSize:u}=t,f=h&&((m=this.control.viewContainerManager)==null?void 0:m.transformToOriginPoint(h,o)),p=this.control.viewContainerManager.getView(o),g={x:f&&f[0]||0,y:f&&f[1]||0,w:u&&u[0]||0,h:u&&u[1]||0,opt:t,type:Fe.Text,canWorker:!0,canSync:!1,dataType:a,scale:((w=p==null?void 0:p.cameraOpt)==null?void 0:w.scale)||1,viewId:o,scenePath:s};if(t&&t.workState===j.Done&&!this.control.cursor.isEnableCursor&&h&&u){let v=c==null?void 0:c.uid;if(!v){const S=this.editors.get(l);v=S&&((y=S.opt)==null?void 0:y.uid)}v&&this.control.cursor.collectServiceCursor({op:h&&[h[0]+u[0],h[1]+u[1]],uid:v,workState:j.Done,viewId:o,type:Y.Cursor})}this.editors.set(l,g),a===X.Service&&t.workState===j.Done&&this.activeId===l&&(this.activeId=void 0),this.control.viewContainerManager.updateTextEditorInfo(o,this.activeId)}updateForViewEdited(n,e){var i;this.editors.set(n,e);const t=(i=this.taskqueue.get(n))==null?void 0:i.resolve;t&&t(e)}active(n,e){var i;const t=this.editors.get(n);t&&t.viewId&&(t.opt.workState=j.Start,t.opt.uid=(i=this.collector)==null?void 0:i.uid,this.activeId=n,t.canWorker=!0,t.canSync=!0,e&&t.viewId&&this.addUndoTicker(e,t.viewId),this.editors.set(n,t),this.control.viewContainerManager.updateTextEditorInfo(t.viewId,this.activeId))}unActive(n){var t;const e=this.editors.get(n);if(e&&e.viewId){e.opt.workState=j.Done,e.opt.uid=void 0,e.canWorker=!0,e.canSync=!0,this.editors.set(n,e),this.activeId=void 0;const i=(t=this.control.viewContainerManager.getView(e.viewId))==null?void 0:t.container;if(i){const o=CSS.escape(n),s=i.querySelector(`.editor-box #${o}`);s&&s.blur()}this.control.viewContainerManager.updateTextEditorInfo(e.viewId,this.activeId)}}addUndoTicker(n,e){this.internalMsgEmitter.emit("addUndoTicker",n,e),this.undoTickerId=n}createTextForMasterController(n,e){var s;const{workId:t,isActive:i,...o}=n;e&&this.addUndoTicker(e,o.viewId),o.opt.uid=(s=this.collector)==null?void 0:s.uid,i&&(this.activeId=t),o.dataType=X.Local,o.canWorker=!0,o.canSync=!0,this.editors.set(t,o),this.control.viewContainerManager.updateTextEditorInfo(o.viewId,this.activeId)}updateTextForMasterController(n,e){var s;const{workId:t,...i}=n;e&&this.addUndoTicker(e,i.viewId);const o=this.editors.get(t)||{};i.opt&&(i.opt.uid=(s=this.collector)==null?void 0:s.uid),i.dataType=X.Local,this.editors.set(t,{...o,...i}),this.control.viewContainerManager.updateTextEditorInfo(i.viewId,this.activeId)}async updateTextControllerWithEffectAsync(n,e){var h;const{workId:t,...i}=n;e&&this.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=X.Local;const s={...o,...i};if(this.editors.set(t,s),this.control.viewContainerManager.updateTextEditorInfo(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(n)}const a=setTimeout(()=>{var f;const u=(f=this.taskqueue.get(t))==null?void 0:f.resolve;u&&u(s)},50),c=await new Promise(u=>{this.taskqueue.set(t,{resolve:u,clocker:a})}),l=this.taskqueue.get(t);return l&&(l.clocker&&clearTimeout(l.clocker),this.taskqueue.delete(t)),c}updateTextForWorker(n,e){const{workId:t,isActive:i,...o}=n,a={...this.editors.get(t)||{},...o};if(e&&this.addUndoTicker(e,o.viewId),i){a.canWorker=!1,a.canSync=!1,this.editors.set(t,a),this.active(t);return}this.editors.set(t,a),this.control.viewContainerManager.updateTextEditorInfo(o.viewId,this.activeId)}get(n){return this.editors.get(n)}delete(n,e,t){const i=this.editors.get(n);if(i){const o=i.viewId;i.canSync=e,i.canWorker=t,this.editors.delete(n),this.activeId===n&&(this.activeId=void 0),this.control.viewContainerManager.updateTextEditorInfo(o,this.activeId)}}deleteBatch(n,e,t){const i=new Set;for(const o of n){const s=this.editors.get(o);if(s){const a=s.viewId;s.canSync=e,s.canWorker=t,this.editors.delete(o),this.activeId===o&&(this.activeId=void 0),i.add(a)}}for(const o of i)this.control.viewContainerManager.updateTextEditorInfo(o,this.activeId)}clear(n,e){this.editors.forEach((t,i)=>{t.viewId===n&&(e&&(t.canSync=!1),t.canWorker=!1,this.editors.delete(i))}),this.activeId=void 0,this.control.viewContainerManager.updateTextEditorInfo(n,this.activeId)}destory(){this.editors.clear(),this.activeId=void 0}insertText(n,e,t,i){var g,m;const o=(g=this.control.room)==null?void 0:g.state.memberState;if(!o)return;const s=this.control.viewContainerManager.getView(n);if(!(s!=null&&s.focusScenePath))return;const a=s==null?void 0:s.cameraOpt,c=this.control.getToolsOpt(T.Text,o);if(!c)return;const l=(m=this.control.viewContainerManager)==null?void 0:m.transformToOriginPoint([e,t],n),u=Cn(i,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]}).split(/\n/),f=c.toolsOpt;f.text=St(u),f.workState=j.Doing,f.boxPoint=[Math.round(e),Math.round(t)],f.boxSize=[f.fontSize,f.fontSize];const p=this.control.worker.now;return this.control.textEditorManager.checkEmptyTextBlur(),this.control.textEditorManager.createTextForMasterController({workId:p.toString(),x:l&&l[0]||0,y:l&&l[1]||0,scale:(a==null?void 0:a.scale)||1,opt:f,type:Fe.Text,isActive:!0,viewId:n,scenePath:s.focusScenePath},p),p.toString()}updateText(n,e){const t=this.editors.get(n.toString());if(!t)return;const o=Cn(e,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]}).split(/\n/);t.opt.text=St(o),this.control.textEditorManager.updateTextForMasterController({workId:n,opt:t.opt,viewId:t.viewId,canSync:!0,canWorker:!0},this.control.worker.now)}}function uf(r){return r}var zr=uf;function hf(r,n,e){switch(e.length){case 0:return r.call(n);case 1:return r.call(n,e[0]);case 2:return r.call(n,e[0],e[1]);case 3:return r.call(n,e[0],e[1],e[2])}return r.apply(n,e)}var df=hf,gf=df,Wi=Math.max;function ff(r,n,e){return n=Wi(n===void 0?r.length-1:n,0),function(){for(var t=arguments,i=-1,o=Wi(t.length-n,0),s=Array(o);++i<o;)s[i]=t[n+i];i=-1;for(var a=Array(n+1);++i<n;)a[i]=t[i];return a[n]=e(s),gf(r,this,a)}}var Mf=ff;function pf(r){return function(){return r}}var yf=pf,mf=yf,Vi=ar,If=zr,wf=Vi?function(r,n){return Vi(r,"toString",{configurable:!0,enumerable:!1,value:mf(n),writable:!0})}:If,Tf=wf,Nf=800,vf=16,Cf=Date.now;function Sf(r){var n=0,e=0;return function(){var t=Cf(),i=vf-(t-e);if(e=t,i>0){if(++n>=Nf)return arguments[0]}else n=0;return r.apply(void 0,arguments)}}var kf=Sf,xf=Tf,jf=kf,Df=jf(xf),bf=Df,Af=zr,zf=Mf,Ef=bf;function Lf(r,n){return Ef(zf(r,n,Af),r+"")}var Pf=Lf;function Of(r,n,e,t){for(var i=r.length,o=e+(t?1:-1);t?o--:++o<i;)if(n(r[o],o,r))return o;return-1}var Rf=Of;function Yf(r){return r!==r}var Uf=Yf;function Bf(r,n,e){for(var t=e-1,i=r.length;++t<i;)if(r[t]===n)return t;return-1}var Wf=Bf,Vf=Rf,Ff=Uf,Qf=Wf;function Gf(r,n,e){return n===n?Qf(r,n,e):Vf(r,Ff,e)}var Zf=Gf,$f=Zf;function Hf(r,n){var e=r==null?0:r.length;return!!e&&$f(r,n,0)>-1}var Er=Hf;function Jf(r,n,e){for(var t=-1,i=r==null?0:r.length;++t<i;)if(e(n,r[t]))return!0;return!1}var Lr=Jf;function Xf(r,n){for(var e=-1,t=r==null?0:r.length,i=Array(t);++e<t;)i[e]=n(r[e],e,r);return i}var qf=Xf,Kf=ni,_f=Er,eM=Lr,tM=qf,nM=hn,iM=ii,rM=200;function oM(r,n,e,t){var i=-1,o=_f,s=!0,a=r.length,c=[],l=n.length;if(!a)return c;e&&(n=tM(n,nM(e))),t?(o=eM,s=!1):n.length>=rM&&(o=iM,s=!1,n=new Kf(n));e:for(;++i<a;){var h=r[i],u=e==null?h:e(h);if(h=t||h!==0?h:0,s&&u===u){for(var f=l;f--;)if(n[f]===u)continue e;c.push(h)}else o(n,u,t)||c.push(h)}return c}var sM=oM,Fi=Ft,aM=hr,cM=Qt,Qi=Fi?Fi.isConcatSpreadable:void 0;function lM(r){return cM(r)||aM(r)||!!(Qi&&r&&r[Qi])}var uM=lM,hM=ei,dM=uM;function Pr(r,n,e,t,i){var o=-1,s=r.length;for(e||(e=dM),i||(i=[]);++o<s;){var a=r[o];n>0&&e(a)?n>1?Pr(a,n-1,e,t,i):hM(i,a):t||(i[i.length]=a)}return i}var gM=Pr;function fM(){}var MM=fM,Tn=Nr,pM=MM,yM=ri,mM=1/0,IM=Tn&&1/yM(new Tn([,-0]))[1]==mM?function(r){return new Tn(r)}:pM,wM=IM,TM=ni,NM=Er,vM=Lr,CM=ii,SM=wM,kM=ri,xM=200;function jM(r,n,e){var t=-1,i=NM,o=r.length,s=!0,a=[],c=a;if(e)s=!1,i=vM;else if(o>=xM){var l=n?null:SM(r);if(l)return kM(l);s=!1,i=CM,c=new TM}else c=n?[]:a;e:for(;++t<o;){var h=r[t],u=n?n(h):h;if(h=e||h!==0?h:0,s&&u===u){for(var f=c.length;f--;)if(c[f]===u)continue e;n&&c.push(u),a.push(h)}else i(c,u,e)||(c!==a&&c.push(u),a.push(h))}return a}var DM=jM,bM=sM,AM=gM,Gi=DM;function zM(r,n,e){var t=r.length;if(t<2)return t?Gi(r[0]):[];for(var i=-1,o=Array(t);++i<t;)for(var s=r[i],a=-1;++a<t;)a!=i&&(o[i]=bM(o[i]||s,r[a],n,e));return Gi(AM(o,1),n,e)}var EM=zM,LM=Xn,PM=at;function OM(r){return PM(r)&&LM(r)}var RM=OM,YM=pr,UM=Pf,BM=EM,WM=RM;UM(function(r){return BM(YM(r,WM))});function VM(r,n){if(r&&n){const e=Math.min(r.x,n.x),t=Math.min(r.y,n.y),i=Math.max(r.x+r.w,n.x+n.w),o=Math.max(r.y+r.h,n.y+n.h),s=i-e,a=o-t;return{x:e,y:t,w:s,h:a}}return n||r}function oi(r,n){if(r&&n){const e=Math.min(r.originX,n.originX),t=Math.min(r.originY,n.originY),i=Math.max(r.originX+r.width,n.originX+n.width),o=Math.max(r.originY+r.height,n.originY+n.height),s=i-e,a=o-t;return{originX:e,originY:t,width:s,height:a}}return n||r}function si(r,n=0){const e={x:0,y:0,w:0,h:0};let t=1/0,i=1/0,o=-1/0,s=-1/0;return r.forEach(a=>{const[c,l]=a.XY;t=Math.min(t,c-n),i=Math.min(i,l-n),o=Math.max(o,c+n),s=Math.max(s,l+n)}),e.x=t,e.y=i,e.w=o-t,e.h=s-i,e}function FM(r,n){return!(r.x+r.w<n.x||r.x>n.x+n.w||r.y+r.h<n.y||r.y>n.y+n.h)}function QM(r,n=10){return{x:Math.floor(r.x-n),y:Math.floor(r.y-n),w:Math.ceil(r.w+n*2),h:Math.ceil(r.h+n*2)}}function GM(r,n){return{x:r.x+n[0],y:r.y+n[1],w:r.w,h:r.h}}function ZM(r,n){const e=new B(r.x,r.y),t=new B(r.x+r.w,r.y),i=new B(r.x+r.w,r.y+r.h),o=new B(r.x,r.y+r.h),s=new B(r.x+r.w/2,r.y+r.h/2),a=Math.PI*n/180,c=B.RotWith(e,s,a),l=B.RotWith(t,s,a),h=B.RotWith(i,s,a),u=B.RotWith(o,s,a);return[c,l,h,u]}function $M(r,n){const e=ZM(r,n);return si(e)}function HM(r,n,e){const t=new B(r.x,r.y),i=new B(r.x+r.w,r.y),o=new B(r.x+r.w,r.y+r.h),s=new B(r.x,r.y+r.h),a=new B(e[0],e[1]),c=new B(n[0],n[1]),l=B.ScaleWOrigin(t,c,a),h=B.ScaleWOrigin(i,c,a),u=B.ScaleWOrigin(o,c,a),f=B.ScaleWOrigin(s,c,a);return si([l,h,u,f])}function JM(r,n,e){const t=new B(n[0],n[1]);for(let i=0;i<r.length;i+=3){const o=new B(r[i],r[i+1]),s=Math.PI*e/180,a=B.RotWith(o,t,s);r[i]=a.x,r[i+1]=a.y}}function XM(r,n,e){const t=new B(n[0],n[1]);for(let i=0;i<r.length;i+=2){const o=new B(r[i],r[i+1]),s=Math.PI*e/180,a=B.RotWith(o,t,s);r[i]=a.x,r[i+1]=a.y}}function qM(r,n,e,t=[0,0]){const i=new B(n[0],n[1]);for(let o=0;o<r.length;o+=3){const s=new B(r[o],r[o+1]),a=new B(e[0],e[1]),c=B.ScaleWOrigin(s,a,i);r[o]=c.x+t[0],r[o+1]=c.y+t[1]}}function KM(r,n,e,t=[0,0]){const i=new B(n[0],n[1]);for(let o=0;o<r.length;o+=2){const s=new B(r[o],r[o+1]),a=new B(e[0],e[1]),c=B.ScaleWOrigin(s,a,i);r[o]=c.x+t[0],r[o+1]=c.y+t[1]}}function Or(r,n){return r[0]>=n.x&&r[0]<=n.x+n.w&&r[1]>=n.y&&r[1]<=n.y+n.h}function _M(r,n){const e=r<=n?1:r/n,t=n<=r?1:n/r;return[e,t]}function ep(r){for(const n of r)if(isNaN(n)||n===1/0||n===-1/0)return!1;return!0}function tp(r){return r!==Math.floor(r)}function np(r){const n=r.toString();return n.indexOf(".")!==-1?n.split(".")[1].length:0}function ip(r,n){for(;n!==0;)[r,n]=[n,r%n];return r}function rp(r){return`${nn(r.x)},${nn(r.y)} `}function op(r,n){return`${nn((r.x+n.x)/2)},${nn((r.y+n.y)/2)} `}function nn(r){return+r.toFixed(4)}const He=async(r,n,e=!1)=>{let t,i;return new Promise(function(o){if(e&&requestIdleCallback)requestIdleCallback(()=>{o(1)},{timeout:n});else{if(typeof window.requestIdleCallback=="function"){const s=typeof n=="number"&&!isNaN(n)&&n>0?n:0;i=window.requestIdleCallback(()=>{clearTimeout(t),o(1)},{timeout:s})}t=setTimeout(()=>{i&&window.cancelIdleCallback(i),o(1)},n||0)}}).then(function(){r()}).catch(function(){r()})},kt=r=>Math.max(1,(window.devicePixelRatio||1)/1),sp=(r,n)=>r.x+r.w<n.x||r.x>n.x+n.w||r.y+r.h<n.y||r.y>n.y+n.h?Bt.outside:r.x>=n.x&&r.y>=n.y&&r.x+r.w<=n.x+n.w&&r.y+r.h<=n.y+n.h?Bt.inside:Bt.intersect;function ap(r){let n=0;for(let e=0;e<r.length;e++){const t=r.charCodeAt(e);t>=1&&t<=126||65376<=t&&t<=65439?n++:n+=2}return n}function cp(r){if(!r||typeof r!="string")return!1;const n=r.trim();if(!n)return!1;const e=[/^\s*#{1,6}\s+.+/m,/^\s*[-*+]\s+.+/m,/^\s*\d+\.\s+.+/m,/\[([^\]]+)\]\(([^)]+)\)/,/\[([^\]]+)\]\[([^\]]+)\]/,/```[\s\S]*?```/,/`[^`]+`/,/^\s*\|.+\|/m,/!\[([^\]]*)\]\(([^)]+)\)/,/\*\*[^*]+\*\*/,/__[^_]+__/,/\*[^*]+\*/,/_[^_]+_/,/~~[^~]+~~/,/==[^=]+==/,/^\s*[-*+]\s+\[[ xX]\]\s+.+/m,/^\s*>\s+.+/m,/^\s*[-*]{3,}\s*$/m];let t=0;for(const s of e)s.test(n)&&t++;const o=[/^\s*#{1,6}\s+/m,/^\s*[-*+]\s+/m,/^\s*\d+\.\s+/m,/```[\s\S]*?```/,/^\s*\|.+\|/m].some(s=>s.test(n));return t>=2||o}class lp{constructor(n,e){I(this,"plugin");I(this,"uid");I(this,"control");this.control=n,this.plugin=e,this.uid=e.displayer.uid}getNamespaceData(){var n;return F.toJS((n=this.plugin)==null?void 0:n.attributes[this.namespace])||{}}getAuthSpaceData(){var n;return F.toJS((n=this.plugin)==null?void 0:n.attributes[this.authSpace])||{}}getGlobalUndoRedoStackData(){var n;return F.toJS((n=this.plugin)==null?void 0:n.attributes[this.globalUndoRedoStackSpace])||{}}getUidFromKey(n){return n.split(Je).length===2&&n.split(Je)[0]||this.uid}isLocalId(n){return n.split(Je).length===1}getLocalId(n){return n.split(Je)[1]}isSelector(n){return this.getLocalId(n)===Z}}const Pe=class Pe extends lp{constructor(e,t,i){super(e,t);I(this,"namespace");I(this,"authSpace");I(this,"globalUndoRedoStackSpace");I(this,"serviceStorage",{});I(this,"storage",{});I(this,"authStorage",{});I(this,"globalUndoRedoStackStorage",{});I(this,"stateDisposer");I(this,"authDisposer");I(this,"asyncClockState",!1);I(this,"limitNums",new Map);I(this,"syncInterval");I(this,"limitComponents",x.debounce((e,t)=>{var s,a,c,l,h,u,f,p;const i=((a=(s=this.storage)==null?void 0:s[e])==null?void 0:a[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=Pe.componentsLimits.indexOf(o),m=g>=0&&g<Pe.componentsLimits.length-1;if((h=(l=(c=this.control.room)==null?void 0:c.callbacks)==null?void 0:l.listeners)!=null&&h.map.onObjectsLimit&&((f=(u=this.control.room)==null?void 0:u.callbacks)==null||f.dispatch("onObjectsLimit",y=>y(o,m))),!m){this.Logger.error(`[Appliance]: exceeds the limit of ${o} components, current: ${i}`),(p=this.control.room)==null||p.disconnect().then(()=>{var y,M,v,S,C;(v=(M=(y=this.control.room)==null?void 0:y.callbacks)==null?void 0:M.listeners)!=null&&v.map.onKickedWithReason&&(this.Logger.info("[Appliance]: onKickedWithReason callback is called"),(C=(S=this.control.room)==null?void 0:S.callbacks)==null||C.dispatch("onKickedWithReason",k=>k("kickByAdmin")))});return}console.warn(`exceeds the limit of ${o} components, current: ${i}`);const w=m?Pe.componentsLimits[g+1]:0;this.limitNums.set(`${e}/${t}`,w)}},2e3,{maxWait:5e3}));I(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)});this.syncInterval=i,this.namespace=Pe.namespace,this.authSpace=Pe.authSpace,this.globalUndoRedoStackSpace=Pe.globalUndoRedoStackSpace,this.serviceStorage=this.getNamespaceData(),this.storage=x.cloneDeep(this.serviceStorage),this.authStorage=this.getAuthSpaceData(),this.globalUndoRedoStackStorage={},this.getLimitNums()}get Logger(){return this.control.logger}hasId(e,t,i){const o=this.getLocalId(i)?this.transformKey(i):i;return!!(this.storage[e]&&this.storage[e][t]&&this.storage[e][t][o])}getLimitNum(e){return e>=Pe.componentsLimits[0]?Pe.componentsLimits[1]:Pe.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 s=this.getLimitNum(Object.keys(o).length);this.limitNums.set(`${e}/${i}`,s)}}}getViewIdBySecenPath(e){const t=this.getNamespaceData();for(const[i,o]of Object.entries(t))if(o){for(const s of Object.keys(o))if(s===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 x.cloneDeep(i[o])}}hasTargetDataByViewId(e,t){const i=this.getNamespaceData();if(i&&i[e]){for(const o of Object.values(i[e]))for(const s of Object.keys(o))if(s===t)return!0}}getTargetDataByViewId(e,t){const i=this.getNamespaceData();let o,s;if(i&&i[e])for(const[a,c]of Object.entries(i[e]))for(const l of Object.keys(c))l===t&&(o=x.cloneDeep(c[l]),s=a);return{data:o,scenePath:s}}getStorageData(e,t){const i=this.getNamespaceData();return i&&i[e]&&x.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)===Z))}hasIncludeSelector(e,t,i){for(const o of Object.keys(this.storage))if(!(t&&o!==t)){for(const s of Object.keys(this.storage[o]))if(!(i&&s!==i)){for(const a of Object.keys(this.storage[o][s]))if(this.getLocalId(a)===Z){const c=this.storage[o][s][a],l=this.isLocalId(e)?this.transformKey(e):e;if(c&&c.selectIds&&c.selectIds.length&&c.selectIds.includes(l))return!0}}}return!1}addStorageStateListener(e){this.stateDisposer=F.autorun(async()=>{var c,l,h,u,f,p;const t=this.getNamespaceData(),{diffView:i,diffScenePath:o,diffData:s}=this.diffFunByView(this.serviceStorage,t);this.serviceStorage=t;const a={};if(Object.keys(i).length>0)for(const[g,m]of Object.entries(i))m&&!x.isEqual((c=this.storage)==null?void 0:c[g],m.newValue)&&(a.diffView||(a.diffView={}),a.diffView[g]=m,this.storage||(this.storage={}),m.newValue===void 0?delete this.storage[g]:this.storage[g]=x.cloneDeep(m.newValue));if(Object.keys(o).length>0){for(const[g,m]of Object.entries(o))if(m){const{viewId:w,newValue:y}=m;m&&!x.isEqual((h=(l=this.storage)==null?void 0:l[w])==null?void 0:h[g],y)&&(a.diffScenePath||(a.diffScenePath={}),a.diffScenePath[g]=m,this.storage||(this.storage={}),this.storage[w]||(this.storage[w]={}),m.newValue===void 0?delete this.storage[w][g]:this.storage[w][g]=x.cloneDeep(m.newValue))}}if(Object.keys(s).length>0){for(const[g,m]of Object.entries(s))if(m){const{viewId:w,scenePath:y,newValue:M}=m;m&&!x.isEqual((p=(f=(u=this.storage)==null?void 0:u[w])==null?void 0:f[y])==null?void 0:p[g],M)&&(a.diffData||(a.diffData={}),a.diffData[g]=m,this.storage||(this.storage={}),this.storage[w]||(this.storage[w]={}),this.storage[w][y]||(this.storage[w][y]={}),m.newValue===void 0?delete this.storage[w][y][g]:this.storage[w][y][g]=x.cloneDeep(m.newValue))}}Object.keys(a).length>0&&e(a),this.control.worker.publicMsgEmitter.emit("syncStorageChange",this.serviceStorage)})}removeStorageStateListener(){this.stateDisposer&&this.stateDisposer()}diffFunByView(e,t){const i=ke(e),o=ke(t),s={},a={},c={};for(const l of o)if(!i.includes(l)||e[l]===void 0){s[l]={newValue:t[l],oldValue:void 0};continue}for(const l of i){if(x.isEqual(e[l],t[l]))continue;if(!o.includes(l)||t[l]===void 0){s[l]={newValue:void 0,oldValue:e[l]};continue}const h=this.diffFunByScenePath(e[l],t[l],l);Object.assign(a,h.diffScenePath),Object.assign(c,h.diffData)}return{diffData:c,diffScenePath:a,diffView:s}}diffFunByScenePath(e,t,i){const o=ke(e),s=ke(t),a={},c={};for(const l of s)if(!o.includes(l)||e[l]===void 0){a[l]={newValue:t[l],oldValue:void 0,viewId:i};continue}for(const l of o){if(x.isEqual(e[l],t[l]))continue;if(!s.includes(l)||t[l]===void 0){a[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:a,diffData:c}}diffFunByKeys(e,t,i,o){const s=ke(e),a=ke(t),c={};for(const l of a)(!s.includes(l)||e[l]===void 0)&&(c[l]={oldValue:void 0,newValue:t[l],viewId:o,scenePath:i});for(const l of s)if(!x.isEqual(e[l],t[l])){if(!a.includes(l)||t[l]===void 0){c[l]={newValue:void 0,oldValue:e[l],viewId:o,scenePath:i};continue}a.includes(l)&&(c[l]={oldValue:e[l],newValue:t[l],viewId:o,scenePath:i})}return c}transformKey(e){return this.uid+Je+e}isOwn(e){return e.split(Je)[0]===this.uid}dispatch(e){var w;const{type:t,workId:i,ops:o,index:s,opt:a,toolsType:c,removeIds:l,updateNodeOpt:h,op:u,selectIds:f,isSync:p,scenePath:g,viewId:m}=e;if(m)switch(t){case Y.Clear:const y={};g&&this.storage[m]&&this.storage[m][g]?(delete this.storage[m][g],this.setState(y,{isSync:p,viewId:m,scenePath:g})):this.storage[m]&&(delete this.storage[m],this.setState(y,{isSync:p,viewId:m,scenePath:""})),He(()=>{var k,N;(k=this.control.pluginManager)==null||k.dispatchPluginEvent("syncStorage",m,g),this.control.isUseSimple||(N=this.control.miniMapManager)==null||N.updateMiniMapCamera(m),this.clearLimitComponents(m,g)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback"));break;case Y.CreateWork:if(g&&i&&c&&a){const k=this.isLocalId(i.toString())?this.transformKey(i):i;this.control.renderControl.isUsePageAuth(m)&&this.control.renderControl.addRenderPageElementId({viewId:m,scenePath:g,elementId:k.toString()}),this.updateValue(k.toString(),{type:Y.CreateWork,workId:i,toolsType:c,opt:a},{isSync:p,viewId:m,scenePath:g})}break;case Y.DrawWork:if(g&&i&&typeof s=="number"&&(u!=null&&u.length)){const k=this.isLocalId(i.toString())?this.transformKey(i):i,N=this.storage[m]&&this.storage[m][g]&&this.storage[m][g][k]||void 0;if(N!=null&&N.ops||(N==null?void 0:N.type)===Y.FullWork)return;const z=s?((N==null?void 0:N.op)||[]).slice(0,s).concat(u):u||(N==null?void 0:N.op),P=c||(N==null?void 0:N.toolsType),L=a||(N==null?void 0:N.opt),R=h||(N==null?void 0:N.updateNodeOpt);i&&P&&L&&z&&(this.control.renderControl.isUsePageAuth(m)&&this.control.renderControl.addRenderPageElementId({viewId:m,scenePath:g,elementId:k.toString()}),this.updateValue(k.toString(),{...N,type:Y.DrawWork,workId:i,updateNodeOpt:R,toolsType:P,opt:L,op:z,index:s},{isSync:p,viewId:m,scenePath:g}))}break;case Y.FullWork:if(g&&i){const k=this.isLocalId(i.toString())?this.transformKey(i):i,N=this.storage[m]&&this.storage[m][g]&&this.storage[m][g][k]||void 0,z=h||(N==null?void 0:N.updateNodeOpt),P=c||(N==null?void 0:N.toolsType),L=a||(N==null?void 0:N.opt),R=o||(N==null?void 0:N.ops);P&&L&&(this.control.renderControl.isUsePageAuth(m)&&this.control.renderControl.addRenderPageElementId({viewId:m,scenePath:g,elementId:k.toString()}),this.updateValue(k.toString(),{type:Y.FullWork,updateNodeOpt:z,workId:k,toolsType:P,opt:L,ops:R},{isSync:p,viewId:m,scenePath:g}),He(()=>{var E,O;(E=this.control.pluginManager)==null||E.dispatchPluginEvent("syncStorage",m,g),this.control.isUseSimple||(O=this.control.miniMapManager)==null||O.updateMiniMapCamera(m),this.limitComponents(m,g)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}break;case Y.RemoveNode:if(g&&(l!=null&&l.length)){const k=l.map(N=>this.isLocalId(N+"")?this.transformKey(N):N);this.storage[m]&&this.storage[m][g]&&(Object.keys(this.storage[m][g]).map(N=>{k!=null&&k.includes(N)&&(this.control.renderControl.isUsePageAuth(m)&&this.control.renderControl.delRenderPageElementId({viewId:m,scenePath:g,elementId:N}),this.updateValue(N,void 0,{isSync:p,viewId:m,scenePath:g}))}),(w=this.control.pluginManager)==null||w.dispatchPluginEvent("syncStorage",m,g),this.control.isUseSimple||He(()=>{var N;(N=this.control.miniMapManager)==null||N.updateMiniMapCamera(m)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}break;case Y.UpdateNode:if(g&&i&&(h||o||a)){const k=this.isLocalId(i.toString())?this.transformKey(i):i,N=this.storage[m]&&this.storage[m][g]&&this.storage[m][g][k]||void 0;N&&(N.updateNodeOpt=h,(o||u)&&(N.ops=o,N.op=u),a&&(N.opt=a),N.type=Y.FullWork,this.updateValue(k.toString(),N,{isSync:p,viewId:m,scenePath:g}),this.control.isUseSimple||He(()=>{var z;(z=this.control.miniMapManager)==null||z.updateMiniMapCamera(m)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}break;case Y.Select:if(!g)return;let M;f!=null&&f.length&&(M=f.map(k=>this.isLocalId(k+"")?this.transformKey(k):k));const v=this.transformKey(Z),S=this.storage[m]&&this.storage[m][g]&&this.storage[m][g][v]||void 0,C=a||(S==null?void 0:S.opt);M&&this.checkOtherSelector(v,M,{isSync:p,viewId:m,scenePath:g}),this.updateValue(v,M&&{type:Y.Select,toolsType:T.Selector,opt:C,selectIds:M},{isSync:p,viewId:m,scenePath:g});break}}checkOtherSelector(e,t,i){const{viewId:o,scenePath:s}=i;for(const a of Object.keys(this.storage[o][s]))if(a!==e&&this.getLocalId(a)===Z){const c=this.storage[o][s][a];if(c&&c.selectIds){const l=c.selectIds.filter(h=>!t.includes(h));l.length>0&&(c.selectIds=l),this.updateValue(a,l.length&&c||void 0,i)}}}setState(e,t){const{viewId:i,scenePath:o}=t,s=ke(e);for(let a=0;a<s.length;a++){const c=s[a],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:s,storage:a}=i,c=a||this.storage;t===void 0?delete c[o][s][e]:(c[o]||(c[o]={}),c[o][s]||(c[o][s]={}),c[o][s][e]=t),this.runSyncService(i)}runSyncService(e){if(!this.control.renderControl.isWritable){this.Logger.error("[Appliance]: The current state is not writable and synchronization cannot be synchronized");return}this.asyncClockState||(this.asyncClockState=!0,e.isSync?(this.asyncClockState=!1,this.syncSerivice(e)):He(()=>{this.asyncClockState=!1,this.syncSerivice(e)},this.syncInterval,this.control.hasPolyfillMethod("requestIdleCallback")))}syncSerivice(e={storage:this.storage}){const{storage:t}=e,i=t||this.storage,o=ke(this.serviceStorage),s=ke(i),a=new Map;for(const c of o){if(!s.includes(c)){a.set(c,void 0);continue}x.isEqual(this.serviceStorage[c],i[c])||this.syncViewData(i,c)}for(const c of s)o.includes(c)||a.set(c,i[c]);if(a.size>5)this.syncStorageView(i);else for(const[c,l]of a.entries())this.syncUpdataView(i,c,l)}syncViewData(e,t){const i=ke(this.serviceStorage[t]),o=ke(e[t]),s=new Map;for(const a of i){if(!o.includes(a)){s.set(a,void 0);continue}x.isEqual(this.serviceStorage[t][a],e[t][a])||this.syncScenePathData(e,t,a)}for(const a of o)i.includes(a)||s.set(a,e[t][a]);if(s.size>5)this.syncStorageScenePath(t,e[t]);else for(const[a,c]of s.entries())this.syncUpdataScenePath(e,t,a,c)}syncScenePathData(e,t,i){const o=ke(this.serviceStorage[t][i]),s=ke(e[t][i]),a=new Map;for(const c of o){if(!s.includes(c)){a.set(c,void 0);continue}x.isEqual(this.serviceStorage[t][i][c],e[t][i][c])||a.set(c,e[t][i][c])}for(const c of s)o.includes(c)||a.set(c,e[t][i][c]);if(a.size>5)this.syncStorageKey(t,i,e[t][i]);else for(const[c,l]of a.entries())this.syncUpdataKey(e,t,i,c,l)}syncUpdataView(e,t,i){var s;Object.keys(this.serviceStorage).length?(s=this.plugin)==null||s.updateAttributes([this.namespace,t],i):this.syncStorageView(e)}syncStorageView(e){var t;(t=this.plugin)==null||t.updateAttributes([this.namespace],e)}syncUpdataScenePath(e,t,i,o){var a;Object.keys(this.serviceStorage[t]).length?(a=this.plugin)==null||a.updateAttributes([this.namespace,t,i],o):this.syncStorageScenePath(t,e[t])}syncStorageScenePath(e,t){var i;(i=this.plugin)==null||i.updateAttributes([this.namespace,e],t)}syncUpdataKey(e,t,i,o,s){var c;Object.keys(this.serviceStorage[t][i]).length?(c=this.plugin)==null||c.updateAttributes([this.namespace,t,i,o],s):this.syncStorageKey(t,i,e[t][i])}syncStorageKey(e,t,i){var o;(o=this.plugin)==null||o.updateAttributes([this.namespace,e,t],i)}keyTransformWorkId(e){const t=e.split(Je);return t.length===2?t[1]:e}destroy(){this.removeStorageStateListener(),this.serviceStorage={},this.storage={},this.removeAuthStateListener(),this.authStorage={},this.globalUndoRedoStackStorage={}}transformToSerializableUndoStackItemData(e){const{data:t,scenePath:i}=e,o={};for(const s of t)o[s.key]={dataType:s.dataType,data:s.data};return{data:o,scenePath:i}}dispatchUndoTicker(e){const{viewId:t,undoTickerId:i,data:o,syncType:s,operation:a}=e,c=a===Ce.syncUndoStack?"undoStack":"redoStack",l=s==="delete"?void 0:this.transformToSerializableUndoStackItemData(o);if(this.plugin)if(this.plugin.getAttributesValue([this.globalUndoRedoStackSpace]))if(this.plugin.getAttributesValue([this.globalUndoRedoStackSpace,t]))if(this.plugin.getAttributesValue([this.globalUndoRedoStackSpace,t,c]))this.globalUndoRedoStackStorage[t][c][i]=l,this.plugin.updateAttributes([this.globalUndoRedoStackSpace,t,c,i],l);else{const h={[i]:l};this.globalUndoRedoStackStorage[t][c]=h,this.plugin.updateAttributes([this.globalUndoRedoStackSpace,t,c],h)}else{const h={[c]:{[i]:l}};this.globalUndoRedoStackStorage[t]=h,this.plugin.updateAttributes([this.globalUndoRedoStackSpace,t],h)}else{const h={[t]:{[c]:{[i]:l}}};this.globalUndoRedoStackStorage=h,this.plugin.updateAttributes(this.globalUndoRedoStackSpace,h)}}addGlobalUndoRedoStackListener(e){this.authDisposer=F.autorun(async()=>{const t=this.getGlobalUndoRedoStackData();if(x.isEqual(this.globalUndoRedoStackStorage,t))return;const i=this.diffGlobalUndoRedoStackFun(this.globalUndoRedoStackStorage,t);this.globalUndoRedoStackStorage=t,e(i)})}diffGlobalUndoRedoStackFun(e,t){const i=ke(e),o=ke(t),s={};for(const a of o)if(!i.includes(a)||e[a]===void 0){s[a]={newValue:t[a],oldValue:void 0};continue}for(const a of i)if(!x.isEqual(e[a],t[a])){if(!o.includes(a)||t[a]===void 0){s[a]={newValue:void 0,oldValue:e[a]};continue}s[a]={newValue:t[a],oldValue:e[a]}}return s}dispatchPageAuth(e,t=!0){var l,h,u,f,p,g,m,w,y,M,v,S,C,k,N,z,P,L,R,E,O,D,V,J,U,Q,H,oe,ne,q,$,ae,Ge,Ke,lt,_e,et,tt;const{operation:i,viewId:o,scenePath:s,pageId:a,pageData:c}=e;switch(i){case Ce.addPage:{if(!o||!s||!a)return;const je=[this.authSpace];Object.keys(this.authStorage).length&&je.push("pageAuth");const Ne=this.authStorage.pageAuth||{};this.authStorage.pageAuth=Ne,Object.keys(Ne).length&&je.push(o),Ne[o]=Ne[o]||{},Object.keys(Ne[o]).length&&je.push(s),Ne[o][s]=Ne[o][s]||{render:(c==null?void 0:c.render)||"localSelf",pages:{}},Object.keys(Ne[o][s].pages).length&&je.push("pages",a);const K={};if(c!=null&&c.elementIds)for(const Ae of c.elementIds.keys())K[Ae]=!0;Ne[o][s].pages[a]=K,t&&(je.length===1?(l=this.plugin)==null||l.updateAttributes(je,x.cloneDeep(this.authStorage)):je.length===2?(h=this.plugin)==null||h.updateAttributes(je,x.cloneDeep(Ne)):je.length===3?(u=this.plugin)==null||u.updateAttributes(je,x.cloneDeep(Ne[o])):je.length===4?(f=this.plugin)==null||f.updateAttributes(je,x.cloneDeep(Ne[o][s])):(p=this.plugin)==null||p.updateAttributes(je,x.cloneDeep(K)));return}case Ce.renderPage:{if(!o||!s||!(c!=null&&c.render))return;this.authStorage.pageAuth&&this.authStorage.pageAuth[o]&&this.authStorage.pageAuth[o][s]&&c.render!==this.authStorage.pageAuth[o][s].render&&(this.authStorage.pageAuth[o][s].render=c.render,t&&((g=this.plugin)==null||g.updateAttributes([this.authSpace,"pageAuth",o,s,"render"],c.render)));return}case Ce.deletePage:{if(!o||!s||!a)return;(v=(M=(y=(w=(m=this.authStorage)==null?void 0:m.pageAuth)==null?void 0:w[o])==null?void 0:y[s])==null?void 0:M.pages)!=null&&v[a]&&(delete this.authStorage.pageAuth[o][s].pages[a],t&&((S=this.plugin)==null||S.updateAttributes([this.authSpace,"pageAuth",o,s,"pages",a],void 0)));return}case Ce.clearPage:{if(!o||!s||!a)return;(P=(z=(N=(k=(C=this.authStorage)==null?void 0:C.pageAuth)==null?void 0:k[o])==null?void 0:N[s])==null?void 0:z.pages)!=null&&P[a]&&(delete this.authStorage.pageAuth[o][s].pages[a],t&&((L=this.plugin)==null||L.updateAttributes([this.authSpace,"pageAuth",o,s,"pages",a],{})));return}case Ce.addElement:{if(!o||!s||!a||!(c!=null&&c.elementId))return;(V=(D=(O=(E=(R=this.authStorage)==null?void 0:R.pageAuth)==null?void 0:E[o])==null?void 0:O[s])==null?void 0:D.pages)!=null&&V[a]&&(this.authStorage.pageAuth[o][s].pages[a][c.elementId]=!0,t&&((J=this.plugin)==null||J.updateAttributes([this.authSpace,"pageAuth",o,s,"pages",a,c.elementId],!0)));return}case Ce.deleteElement:{if(!o||!s||!a||!(c!=null&&c.elementId))return;(q=(ne=(oe=(H=(Q=(U=this.authStorage)==null?void 0:U.pageAuth)==null?void 0:Q[o])==null?void 0:H[s])==null?void 0:oe.pages)==null?void 0:ne[a])!=null&&q[c.elementId]&&(delete this.authStorage.pageAuth[o][s].pages[a][c.elementId],t&&(($=this.plugin)==null||$.updateAttributes([this.authSpace,"pageAuth",o,s,"pages",a,c.elementId],void 0)));return}case Ce.clearViewScenePath:{if(!o||!s)return;(Ke=(Ge=(ae=this.authStorage)==null?void 0:ae.pageAuth)==null?void 0:Ge[o])!=null&&Ke[s]&&(delete this.authStorage.pageAuth[o][s],t&&((lt=this.plugin)==null||lt.updateAttributes([this.authSpace,"pageAuth",o,s],void 0)));return}case Ce.clearView:{if(!o)return;(et=(_e=this.authStorage)==null?void 0:_e.pageAuth)!=null&&et[o]&&(delete this.authStorage.pageAuth[o],t&&((tt=this.plugin)==null||tt.updateAttributes([this.authSpace,"pageAuth",o],void 0)));return}}}dispatchRenderAuth(e,t=!0){var l,h,u,f,p,g,m,w,y,M,v,S,C,k,N,z,P,L,R,E;const{operation:i,viewId:o,uid:s,renderData:a,isClear:c}=e;if(o)switch(i){case Ve.setAuth:{if(!a||a.render===void 0&&a.hide===void 0&&a.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 O=[this.authSpace];Object.keys(this.authStorage).length&&O.push("renderAuth");const D=this.authStorage.renderAuth||{};Object.keys(D).length&&O.push(o),D[o]={},this.authStorage.renderAuth=D;const{render:V,hide:J,clear:U}=a;if(V===!0)D[o].render=!0;else if(x.isSet(V)){D[o].render={};for(const Q of V.keys())D[o].render[Q]=!0}if(J===!0)D[o].hide=!0;else if(x.isSet(J)){D[o].hide={};for(const Q of J.keys())D[o].hide[Q]=!0}if(U===!0)D[o].clear=!0;else if(x.isSet(U)){D[o].clear={};for(const Q of U.keys())D[o].clear[Q]=!0}t&&(O.length===1?(h=this.plugin)==null||h.updateAttributes(O,x.cloneDeep(this.authStorage)):O.length===2?(u=this.plugin)==null||u.updateAttributes(O,x.cloneDeep(D)):(f=this.plugin)==null||f.updateAttributes(O,x.cloneDeep(D[o])));return}case Ve.setShow:{if(!s)return;const O=[this.authSpace];Object.keys(this.authStorage).length&&O.push("renderAuth");const D=this.authStorage.renderAuth||{};Object.keys(D).length&&O.push(o),D[o]=D[o]||{},this.authStorage.renderAuth=D,Object.keys(D[o]).length&&O.push("render"),D[o].render=D[o].render||{},D[o].render!==!0&&(Object.keys(D[o].render).length&&O.push(s),D[o].render[s]=!0),D[o].hide!==!0&&((p=D[o].hide)!=null&&p[s])&&(delete D[o].hide[s],t&&((g=this.plugin)==null||g.updateAttributes([this.authSpace,"renderAuth",o,"hide",s],void 0))),t&&(O.length===1?(m=this.plugin)==null||m.updateAttributes(O,x.cloneDeep(this.authStorage)):O.length===2?(w=this.plugin)==null||w.updateAttributes(O,x.cloneDeep(D)):O.length===3?(y=this.plugin)==null||y.updateAttributes(O,x.cloneDeep(D[o])):(M=this.plugin)==null||M.updateAttributes(O,!0));return}case Ve.setHide:{if(!s)return;const O=[this.authSpace];Object.keys(this.authStorage).length&&O.push("renderAuth");const D=this.authStorage.renderAuth||{};Object.keys(D).length&&O.push(o),D[o]=D[o]||{},this.authStorage.renderAuth=D,Object.keys(D[o]).length&&O.push("hide"),D[o].hide=D[o].hide||{},D[o].hide!==!0&&(Object.keys(D[o].hide).length&&O.push(s),D[o].hide[s]=!0),D[o].render!==!0&&((v=D[o].render)!=null&&v[s])&&(delete D[o].render[s],t&&((S=this.plugin)==null||S.updateAttributes([this.authSpace,"renderAuth",o,"render",s],void 0))),t&&(O.length===1?(C=this.plugin)==null||C.updateAttributes(O,x.cloneDeep(this.authStorage)):O.length===2?(k=this.plugin)==null||k.updateAttributes(O,x.cloneDeep(D)):O.length===3?(N=this.plugin)==null||N.updateAttributes(O,x.cloneDeep(D[o])):(z=this.plugin)==null||z.updateAttributes(O,!0));return}case Ve.setClear:{if(!s)return;const O=[this.authSpace];Object.keys(this.authStorage).length&&O.push("renderAuth");const D=this.authStorage.renderAuth||{};Object.keys(D).length&&O.push(o),D[o]=D[o]||{},this.authStorage.renderAuth=D,Object.keys(D[o]).length&&O.push("clear"),D[o].clear=D[o].clear||{},D[o].clear!==!0&&(Object.keys(D[o].clear).length&&O.push(s),c?D[o].clear[s]=!0:delete D[o].clear[s]),t&&(O.length===1?(P=this.plugin)==null||P.updateAttributes(O,x.cloneDeep(this.authStorage)):O.length===2?(L=this.plugin)==null||L.updateAttributes(O,x.cloneDeep(D)):O.length===3?(R=this.plugin)==null||R.updateAttributes(O,x.cloneDeep(D[o])):(E=this.plugin)==null||E.updateAttributes(O,c?!0:void 0));return}}}addAuthStateListener(e){this.authDisposer=F.autorun(async()=>{const t=this.getAuthSpaceData(),{renderAuth:i,pageAuth:o}=t;let s,a;x.isEqual(i,this.authStorage.renderAuth)||(s=this.diffAuthFun(this.authStorage.renderAuth||{},i||{}),this.authStorage.renderAuth=i),x.isEqual(o,this.authStorage.pageAuth)||(a=this.diffAuthPageFun(this.authStorage.pageAuth||{},o||{}),this.authStorage.pageAuth=o),(s||a)&&e(s,a)})}removeAuthStateListener(){this.authDisposer&&this.authDisposer()}diffAuthFun(e,t){const i=ke(e),o=ke(t),s={};for(const a of o)if(!i.includes(a)||e[a]===void 0){s[a]={newValue:t[a],oldValue:void 0};continue}for(const a of i)if(!x.isEqual(e[a],t[a])){if(!o.includes(a)||t[a]===void 0){s[a]={newValue:void 0,oldValue:e[a]};continue}s[a]={newValue:t[a],oldValue:e[a]}}return s}diffAuthPageFun(e,t){const i=ke(e),o=ke(t),s={};for(const a of o)if(!i.includes(a)||e[a]===void 0){s[a]={newValue:t[a],oldValue:void 0};continue}for(const a of i)if(!x.isEqual(e[a],t[a])){if(!o.includes(a)||t[a]===void 0){s[a]={newValue:void 0,oldValue:e[a]};continue}s[a]={newValue:t[a],oldValue:e[a]}}return s}};I(Pe,"namespace","PluginState"),I(Pe,"authSpace","PluginAuth"),I(Pe,"globalUndoRedoStackSpace","GlobalUndoRedoStack"),I(Pe,"componentsLimits",[500,1e3]);let zn=Pe;var Ue=(r=>(r[r.Draw=1]="Draw",r[r.Delete=2]="Delete",r[r.Update=3]="Update",r))(Ue||{});class up{constructor(){I(this,"roomMembers",[]);I(this,"onChangeHooks",new Set)}setRoomMembers(n){this.executChangeUidHook(this.roomMembers,n),this.roomMembers=n}executChangeUidHook(n,e){const t={online:e.map(i=>{var o;return((o=i.payload)==null?void 0:o.uid)||i.session}),offline:n.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(n){return this.roomMembers.find(e=>{var t;return((t=e.payload)==null?void 0:t.uid)===n})}isOnLine(n){return!!this.getRoomMember(n)}onUidChangeHook(n){this.onChangeHooks.add(n)}destroy(){this.onChangeHooks.clear()}}class hp{constructor(n){I(this,"expirationTime",me.cursor.expirationTime);I(this,"isEnableCursor");I(this,"internalMsgEmitter");I(this,"publicMsgEmitter");I(this,"control");I(this,"eventName","applianc-cursor");I(this,"displayer");I(this,"roomMember");I(this,"animationId");I(this,"maxLastSyncTime");I(this,"willSendEventWorkers",[]);I(this,"willConsumeEventWorkers",new Map);I(this,"sendEventTimerId");I(this,"animationDrawWorkers",new Map);I(this,"animationEventWorkers",new Map);I(this,"cursorInfoMap",new Map);I(this,"doneRenderCursorInfoMap",new Map);const{control:e,internalMsgEmitter:t,publicMsgEmitter:i}=n;this.internalMsgEmitter=t,this.publicMsgEmitter=i,this.expirationTime=x.isNumber(e.pluginOptions.extras.cursor.expirationTime)?e.pluginOptions.extras.cursor.expirationTime:this.expirationTime,this.control=e,this.roomMember=e.roomMember,this.maxLastSyncTime=this.control.pluginOptions.extras.syncOpt.interval,this.isEnableCursor=this.control.pluginOptions.extras.cursor.enable}activeCollector(){this.control.plugin&&this.isEnableCursor&&(this.displayer=this.control.room||this.control.play,this.displayer.addMagixEventListener(this.eventName,this.mainMagixEventListener.bind(this)))}mainMagixEventListener(n){var a;const{event:e,payload:t}=n;if(e!==this.eventName)return;const{uid:i,op:o,type:s}=t;if(((a=this.control.collector)==null?void 0:a.uid)!==i&&s===Ut.Cursor&&(o!=null&&o.length)){const c=this.willConsumeEventWorkers.get(i)||[];for(const l of o){const{viewId:h}=l;x.isNumber(l.consumPoint[0])&&x.isNumber(l.consumPoint[1])&&(l.consumPoint=this.control.viewContainerManager.transformToOriginPoint(l.consumPoint,h)),this.control.renderControl.isFilterCursor(h)&&c.unshift({...l,timestamp:this.control.worker.now})}this.willConsumeEventWorkers.set(i,c),this.runAnimation()}}onFocusViewChange(){this.isEnableCursor&&(this.checkDrawWorks(),this.runAnimation())}updateRoomMembers(n){const{offline:e}=n;for(const t of this.cursorInfoMap.keys())t&&e.includes(t)&&this.cursorInfoMap.delete(t)}getKey(n,e){return`${n}${Je}${e}`}getUidAndviewId(n){const[e,t]=n.split(Je);return{uid:e,viewId:t}}runAnimation(){this.animationId||(this.animationId=requestAnimationFrame(this.animationCursor.bind(this)))}checkDrawWorks(){var e;const n=this.control.viewContainerManager.focuedViewId;for(const[t,i]of this.animationDrawWorkers.entries()){const{viewId:o,uid:s}=this.getUidAndviewId(t);s!==((e=this.control.collector)==null?void 0:e.uid)&&o!==n&&i.workState===j.Done&&(i.consumPoint=[void 0,void 0])}}animationCursor(){this.animationId=void 0;const n=this.control.worker.now;for(const[t,i]of this.animationDrawWorkers.entries()){const{uid:o,viewId:s}=this.getUidAndviewId(t),a=this.roomMember.getRoomMember(o);if(!a){this.animationDrawWorkers.delete(t);continue}const{consumPoint:c,timestamp:l,workState:h}=i,u=this.cursorInfoMap.get(s)||new Map;c&&x.isNumber(c[0])&&x.isNumber(c[1])&&l+this.expirationTime>n?u.set(a.memberId,{x:c[0],y:c[1],roomMember:a,timestamp:l,type:1,workState:h}):u.delete(a.memberId),u.size?this.cursorInfoMap.set(s,u):this.cursorInfoMap.delete(s),this.animationDrawWorkers.delete(t)}const e=new Set;for(const[t,i]of this.cursorInfoMap.entries())if(i)for(const[o,s]of i.entries())s.type===1&&s.workState!==j.Done&&e.add(o);else this.cursorInfoMap.delete(t);for(const[t,i]of this.willConsumeEventWorkers.entries()){const o=this.roomMember.getRoomMember(t);if(x.isNumber(o==null?void 0:o.memberId)&&!e.has(o.memberId)){const s=i.pop();s?this.animationEventWorkers.set(t,s):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:s,consumPoint:a,timestamp:c}=i,l=this.cursorInfoMap.get(s)||new Map;a&&x.isNumber(a[0])&&x.isNumber(a[1])&&c+this.expirationTime>n?l.set(o.memberId,{x:a[0],y:a[1],roomMember:o,timestamp:c,type:0}):l.delete(o.memberId),l.size?this.cursorInfoMap.set(s,l):this.cursorInfoMap.delete(s),this.animationEventWorkers.delete(t)}for(const t of this.doneRenderCursorInfoMap.keys())this.cursorInfoMap.has(t)||(this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([_.Cursor,t],[]));for(const[t,i]of this.cursorInfoMap.entries())if(i!=null&&i.size){const o=[];for(const[a,c]of i.entries()){const{timestamp:l,...h}=c;l+this.expirationTime>n?o.push(h):(i.delete(a),i.size===0&&(this.cursorInfoMap.delete(t),this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([_.Cursor,t],[])))}const s=this.doneRenderCursorInfoMap.get(t);x.isEqual(s,o)||(this.doneRenderCursorInfoMap.set(t,o),this.internalMsgEmitter.emit([_.Cursor,t],o))}else this.cursorInfoMap.delete(t),this.doneRenderCursorInfoMap.delete(t),this.internalMsgEmitter.emit([_.Cursor,t],[]);(this.willConsumeEventWorkers.size||this.cursorInfoMap.size)&&this.runAnimation()}sendEvent(n,e){if(this.displayer&&F.isRoom(this.displayer)){const t=x.isNumber(n[0])&&x.isNumber(n[1])&&this.control.viewContainerManager.transformToScenePoint(n,e)||[void 0,void 0];this.willSendEventWorkers.push({consumPoint:t,viewId:e}),this.sendEventTimerId||(this.sendEventTimerId=setTimeout(()=>{this.dispatchMagixEvent()},this.maxLastSyncTime))}}dispatchMagixEvent(){var n;this.displayer&&F.isRoom(this.displayer)&&this.displayer.isWritable&&this.displayer.dispatchMagixEvent(this.eventName,{type:Ut.Cursor,op:x.cloneDeep(this.willSendEventWorkers),uid:(n=this.control.collector)==null?void 0:n.uid}),this.willSendEventWorkers.length=0,this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0)}collectServiceCursor(n){var s;if(!this.isEnableCursor&&!this.control.renderControl.isWritable)return;const{op:e,uid:t,workState:i,viewId:o}=n;if(t&&e&&i&&o){const a=this.roomMember.getRoomMember(t);if(!a||t===((s=this.control.collector)==null?void 0:s.uid))return;const c=this.getKey(t,o);let l=[void 0,void 0];if(x.isNumber(e[0])&&x.isNumber(e[1])){const[u,f]=this.control.viewContainerManager.transformToOriginPoint(e,o);l=[u,f]}if(i===j.Start){for(const u of this.cursorInfoMap.values())if(u!=null&&u.size)for(const f of u.keys())f===a.memberId&&u.delete(f)}const h={consumPoint:l,workState:i,viewId:o,timestamp:this.control.worker.now};if(i===j.Start||i===j.Done){const u=this.willConsumeEventWorkers.get(t);i===j.Start&&u&&this.willConsumeEventWorkers.delete(t),u&&i===j.Done&&(h.timestamp=h.timestamp-this.expirationTime)}this.animationDrawWorkers.set(c,h),this.runAnimation()}}unabled(){var n;this.displayer&&F.isRoom(this.displayer)&&(this.willSendEventWorkers.length=0,this.displayer.dispatchMagixEvent(this.eventName,{type:Ut.Cursor,op:[{viewId:this.control.viewContainerManager.focuedViewId,consumPoint:[void 0,void 0]}],uid:(n=this.control.collector)==null?void 0:n.uid}),this.sendEventTimerId&&(clearTimeout(this.sendEventTimerId),this.sendEventTimerId=void 0)),this.isEnableCursor||this.stopAnimation()}clearViewCursor(n){var e,t,i;for(const[o]of this.animationDrawWorkers.entries()){const{uid:s}=this.getUidAndviewId(o);s===((e=this.control.collector)==null?void 0:e.uid)&&n===n&&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([_.Cursor,o],[]))}stopAnimation(){this.animationDrawWorkers.clear(),this.willConsumeEventWorkers.clear(),this.cursorInfoMap.clear()}destroy(){var n;(n=this.displayer)==null||n.removeMagixEventListener(this.eventName),this.stopAnimation()}}class We{constructor(){I(this,"useEmtMsg");I(this,"emtType");I(this,"control");I(this,"mainEngine");I(this,"collectListener",(n,e)=>{this.collect(n,e)})}static dispatch(n,e,t){var i;(i=we.InternalMsgEmitter)==null||i.emit([n,e],t)}get serviceColloctor(){return this.control.collector}registerForMainEngine(n,e){return this.emtType=n,this.control=e,this.mainEngine=e.worker,this.mainEngine.internalMsgEmitter.on([this.emtType,this.emitEventType],this.collectListener),this}destroy(){this.emtType&&this.mainEngine&&this.mainEngine.internalMsgEmitter.off([this.emtType,this.emitEventType],this.collectListener)}collectForLocalWorker(n,e){var t,i,o;for(const[s,a]of n)(t=this.mainEngine)==null||t.queryTaskBatchData(a).forEach(c=>{var l;(l=this.mainEngine)==null||l.taskBatchData.delete(c)}),(i=this.mainEngine)==null||i.taskBatchData.add(s);if(e){this.mainEngine.consume();return}(o=this.mainEngine)==null||o.runAnimation()}collectForServiceWorker(n){He(()=>{n.forEach(e=>{var t;(t=this.serviceColloctor)==null||t.dispatch(e)})},this.mainEngine.maxLastSyncTime,this.control.hasPolyfillMethod("requestIdleCallback"))}pause(){var n;if(this.lastEmtData){this.useEmtMsg=!0;const e={...this.lastEmtData,workState:j.Done};this.collect(e,!0),(n=we.InternalMsgEmitter)==null||n.emit(W.ActiveMethod,!1)}}recover(){var n;this.useEmtMsg&&we.InternalMsgEmitter.hasListeners(W.ActiveMethod)&&((n=we.InternalMsgEmitter)==null||n.emit(W.ActiveMethod,!0))}}class dp extends We{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",W.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 s=o.focusScenePath,a=this.mainEngine.now;this.mainEngine.internalMsgEmitter.emit("addUndoTicker",a,i);for(const l of t){const h=l.toString(),f=this.serviceColloctor.isLocalId(h)?this.serviceColloctor.transformKey(l):h,p=(c=this.serviceColloctor.getStorageData(i,s))==null?void 0:c[f];if(p){if(l===Z){const g=p&&this.copySelector({viewId:i,store:p});g&&this.pasteSelector({...g,viewId:i,scenePath:s,undoTickerId:a});break}if(p.toolsType===T.Text&&p.opt&&p.opt.workState&&p.opt.workState!==j.Done){const g=p&&this.copyText({viewId:i,store:p});g&&this.pasteText({...g,viewId:i,scenePath:s,key:f,store:p,undoTickerId:a});break}}}}copyText(e){const{viewId:t,store:i}=e,o=this.control.viewContainerManager.getView(t);if(!this.serviceColloctor||!o)return;const s=o==null?void 0:o.cameraOpt,a=s&&[s.centerX,s.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:a,textCenter:l}}pasteText(e){var w,y;const{bgCenter:t,textCenter:i,store:o,key:s,viewId:a,scenePath:c,undoTickerId:l}=e,h=this.control.viewContainerManager.getView(a);if(!this.serviceColloctor||!h)return;const u=Math.floor(Math.random()*30+1),f=((w=h.cameraOpt)==null?void 0:w.scale)||1,p=t&&i&&[t[0]-i[0]+u,t[1]-i[1]+u]||[u/f,u/f],m=(this.serviceColloctor.isLocalId(s)?s:this.serviceColloctor.getLocalId(s.toString()))+"-"+l;if(o.toolsType===T.Text&&o.opt){const M=o.opt;if(M&&M.boxPoint&&M.text){M.workState=j.Done;const v=M.boxPoint;M.boxPoint=[Math.round(v[0]+p[0]),Math.round(v[1]+p[1])],M.workState=j.Done;const S=this.control.viewContainerManager.transformToOriginPoint(M.boxPoint,a);this.control.textEditorManager.createTextForMasterController({workId:m,x:S[0],y:S[1],opt:M,scale:((y=h.cameraOpt)==null?void 0:y.scale)||1,type:Fe.Text,isActive:!1,viewId:a,scenePath:c}),this.collectForServiceWorker([{...o,opt:M,type:Y.FullWork,workId:m,viewId:a,scenePath:c}])}}}copySelector(e){var m,w,y,M,v,S,C,k,N;const{viewId:t,store:i}=e,o=this.control.viewContainerManager.getView(t),s=i.selectIds;if(!this.serviceColloctor||!(s!=null&&s.length)||!o)return;const a=new Map,c={offset:{x:0,y:0},cameraOpt:{centerX:((m=o.cameraOpt)==null?void 0:m.centerX)||0,centerY:((w=o.cameraOpt)==null?void 0:w.centerY)||0,scale:((y=o.cameraOpt)==null?void 0:y.scale)||1}},l=this.control.hasOffscreenCanvas&&((M=o.displayer.canvasBgRef.current)==null?void 0:M.getBoundingClientRect())||((v=o.displayer.canvasContainerRef.current)==null?void 0:v.getBoundingClientRect()),h=(C=(S=o.displayer)==null?void 0:S.floatBarRef.current)==null?void 0:C.getBoundingClientRect(),u=l&&[l.x+l.width/2,l.y+l.height/2],f=h&&[h.x+h.width/2,h.y+h.height/2],p=u&&o.viewData&&o.viewData.convertToPointInWorld({x:u[0],y:u[1]}),g=f&&o.viewData&&o.viewData.convertToPointInWorld({x:f[0],y:f[1]});p&&g&&(c.offset={x:p.x-g.x,y:p.y-g.y});for(const z of s){const P=(N=(k=this.serviceColloctor)==null?void 0:k.getStorageData(o.id,o.focusScenePath))==null?void 0:N[z];P&&a.set(z,P)}return{copyStores:a,copyCoordInfo:c}}pasteSelector(e){var w,y,M,v;const{copyStores:t,copyCoordInfo:i,viewId:o,scenePath:s,undoTickerId:a}=e,c=this.control.viewContainerManager.getView(o);if(!t.size||!this.serviceColloctor||!c)return;const{offset:l,cameraOpt:h}=i,{scale:u}=h,f=Math.floor(Math.random()*30+1),p=l&&[l.x+f,l.y+f]||[f/u,f/u],g=[],m=[];for(const[S,C]of t.entries()){const N=(this.serviceColloctor.isLocalId(S)?S:this.serviceColloctor.getLocalId(S.toString()))+"-"+a,z={useAnimation:!1};if(C.toolsType===T.Text&&C.opt){const P=C.opt;if(P&&P.boxPoint&&P.text){P.workState=j.Done;const L=P.boxPoint;P.boxPoint=[Math.round(L[0]+p[0]),Math.round(L[1]+p[1])],P.workState=j.Done;const R=this.control.viewContainerManager.transformToOriginPoint(P.boxPoint,o);this.control.textEditorManager.createTextForMasterController({workId:N,x:R[0],y:R[1],opt:P,scale:((w=c.cameraOpt)==null?void 0:w.scale)||1,type:Fe.Text,isActive:!1,viewId:o,scenePath:s})}m.push({...C,opt:P,type:Y.FullWork,workId:N,viewId:o,scenePath:s});continue}if((C.toolsType===T.Image||C.toolsType===T.BackgroundSVG)&&(C.opt.uuid=N,C.opt.centerX=C.opt.centerX+p[0],C.opt.centerY=C.opt.centerY+p[1]),C.ops){const P=gn(C.ops).map((R,E)=>{const O=E%3;return O===0?R+p[0]:O===1?R+p[1]:R}),L=St(P);C.ops=L}if((y=C==null?void 0:C.opt)!=null&&y.eraserlines&&(M=C==null?void 0:C.opt)!=null&&M.eraserlines.length)for(const P of(v=C==null?void 0:C.opt)==null?void 0:v.eraserlines){const{op:L}=P;for(let R=0;R<L.length;R++){const E=L[R].map((O,D)=>D%2?O+p[1]:O+p[0]);P.op[R]=E}}m.push({...C,updateNodeOpt:z,type:Y.FullWork,workId:N,viewId:o,scenePath:s}),g.push([{...C,updateNodeOpt:z,workId:N,msgType:Y.FullWork,dataType:X.Local,emitEventType:W.CopyNode,willSyncService:!1,willRefresh:!0,viewId:o,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(o),isRunBackgroundThread:this.control.isUseBackgroundThread},{workId:N,msgType:Y.FullWork,emitEventType:W.CopyNode}])}g.length&&this.collectForLocalWorker(g),m.length&&this.collectForServiceWorker(m)}}class gp extends We{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",W.SetColorNode);I(this,"undoTickerId")}setTextColor(e,t,i,o){const{fontColor:s,fontBgColor:a}=i;t.opt&&(s&&(t.opt.fontColor=s),a&&(t.opt.fontBgColor=a),this.control.textEditorManager.updateTextForMasterController({workId:e,opt:t.opt,viewId:o,canSync:!0,canWorker:!0}))}collect(e){var M,v;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,strokeColor:i,fillColor:o,fontColor:s,fontBgColor:a,viewId:c,workState:l,thickness:h,strokeType:u}=e,f=this.control.viewContainerManager.getView(c);if(!(f!=null&&f.displayer))return;const p=f.focusScenePath,g=[...t],m=this.serviceColloctor.storage,w=[],y={};for((l===j.Start||!this.undoTickerId&&l===j.Done)&&(this.undoTickerId=this.mainEngine.now,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",this.undoTickerId,c));g.length;){const S=g.pop();if(!S)continue;const C=S.toString(),k=this.serviceColloctor.isLocalId(C),N=k?this.serviceColloctor.transformKey(S):C;let z=C;!k&&this.serviceColloctor.isOwn(z)&&(z=this.serviceColloctor.getLocalId(z));const P=(v=(M=m==null?void 0:m[c])==null?void 0:M[p])==null?void 0:v[N];if(P){const L=P.updateNodeOpt||{};if(s||a){if(s){L.fontColor=s;const[E,O,D,V]=Yt(s);y.textColor=[E,O,D],y.textOpacity=V}if(a)if(L.fontBgColor=Jt(a)?"transparent":a,Jt(a))y.textBgColor=void 0,y.textBgOpacity=void 0;else{const[E,O,D,V]=Yt(a);y.textBgColor=[E,O,D],y.textBgOpacity=V}if(P.toolsType===T.Text&&P.opt&&l!==j.Start){this.setTextColor(z,Gt(P),L,c),l===j.Done&&(this.undoTickerId=void 0);continue}}if(i){L.strokeColor=i;const[E,O,D,V]=Yt(i);y.strokeColor=[E,O,D],y.strokeOpacity=V}if(o)if(L.fillColor=Jt(o)?"transparent":o,Jt(o))y.fillColor=void 0,y.fillOpacity=void 0;else{const[E,O,D,V]=Yt(o);y.fillColor=[E,O,D],y.fillOpacity=V}h&&(L.thickness=h,y.strokeWidth=h),u&&(y.strokeType=u,L.strokeType=u,L.lineCap=this.control.getLineCap(u),L.lineDash=this.control.getLineDash(u));const R={workId:z,msgType:Y.UpdateNode,dataType:X.Local,updateNodeOpt:L,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,textUpdateForWoker:!0,viewId:c,needUndoTicker:l===j.Done&&this.control.viewContainerManager.getUndoTickerId(c)||void 0};w.push([R,{workId:z,msgType:Y.UpdateNode,emitEventType:this.emitEventType}])}}w.length&&(l===j.Done&&(this.undoTickerId=void 0),this.collectForLocalWorker(w)),Object.keys(y).length&&setTimeout(()=>{var S;(S=this.control.room)==null||S.setMemberState(y)},0)}}class fp extends We{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",W.ZIndexNode);I(this,"zIndexMap",new Map);I(this,"zIndexMapForBackgroundSVG",new Map)}clearZIndex(e){this.zIndexMap.delete(e),this.zIndexMapForBackgroundSVG.delete(e)}getMinZIndex(e){var t;return((t=this.zIndexMap.get(e))==null?void 0:t.min)||0}getMinZIndexForBackgroundSVG(e){var t;return((t=this.zIndexMapForBackgroundSVG.get(e))==null?void 0:t.min)||0}getMaxZIndex(e){var t;return((t=this.zIndexMap.get(e))==null?void 0:t.max)||0}getMaxZIndexForBackgroundSVG(e){var t;return((t=this.zIndexMapForBackgroundSVG.get(e))==null?void 0:t.max)||0}setMaxZIndex(e,t){const i=this.getMinZIndex(t);this.zIndexMap.set(t,{min:i,max:e})}setMaxZIndexForBackgroundSVG(e,t){const i=this.getMinZIndexForBackgroundSVG(t);this.zIndexMapForBackgroundSVG.set(t,{min:i,max:e})}setMinZIndex(e,t){const i=this.getMaxZIndex(t);this.zIndexMap.set(t,{min:e,max:i})}setMinZIndexForBackgroundSVG(e,t){const i=this.getMaxZIndexForBackgroundSVG(t);this.zIndexMapForBackgroundSVG.set(t,{min:e,max:i})}addMaxLayer(e){const t=this.getMaxZIndex(e)+1;this.setMaxZIndex(t,e)}addMaxLayerForBackgroundSVG(e){const t=this.getMaxZIndexForBackgroundSVG(e)+1;this.setMaxZIndexForBackgroundSVG(t,e)}addMinLayer(e){const t=this.getMinZIndex(e)-1;this.setMinZIndex(t,e)}addMinLayerForBackgroundSVG(e){const t=this.getMinZIndexForBackgroundSVG(e)-1;this.setMinZIndexForBackgroundSVG(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],s=t[i-1][1];o<=s&&(t[i][1]=s+1)}return t}collect(e){var g,m;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,layer:i,viewId:o}=e,s=this.control.viewContainerManager.getView(o);if(!(s!=null&&s.displayer))return;const a=s.focusScenePath,c=[...t],l=this.serviceColloctor.storage,h=[],u=[],f=[];for(;c.length;){const w=c.pop();if(!w)continue;const y=w.toString(),M=this.serviceColloctor.isLocalId(y),v=M?this.serviceColloctor.transformKey(w):y;let S=y;!M&&this.serviceColloctor.isOwn(S)&&(S=this.serviceColloctor.getLocalId(S));const C=Gt(l[o][a][v]);let k,N;if(C&&S===Z){if(C.selectIds){for(const L of C.selectIds){const R=p(L,this.serviceColloctor),E=(m=(g=l==null?void 0:l[o])==null?void 0:g[a])==null?void 0:m[R];E&&E.toolsType===T.BackgroundSVG?(f.push(L),f.sort((O,D)=>{var U,Q,H,oe;const V=((Q=(U=l[p(O,this.serviceColloctor)])==null?void 0:U.opt)==null?void 0:Q.zIndex)||0,J=((oe=(H=l[p(O,this.serviceColloctor)])==null?void 0:H.opt)==null?void 0:oe.zIndex)||0;return V>J?1:O<D?-1:0})):(u.push(L),u.sort((O,D)=>{var U,Q,H,oe;const V=((Q=(U=l[p(O,this.serviceColloctor)])==null?void 0:U.opt)==null?void 0:Q.zIndex)||0,J=((oe=(H=l[p(O,this.serviceColloctor)])==null?void 0:H.opt)==null?void 0:oe.zIndex)||0;return V>J?1:O<D?-1:0}))}const z=C.updateNodeOpt||{};z.zIndexLayer=i;const P={workId:w,msgType:Y.UpdateNode,dataType:X.Local,updateNodeOpt:z,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:o};u.length&&(i===Ct.Top?(this.addMaxLayer(o),k=this.getMaxZIndex(o)):(this.addMinLayer(o),k=this.getMinZIndex(o)),u.forEach(L=>{var D,V,J,U,Q;const R=(D=this.serviceColloctor)==null?void 0:D.isLocalId(L);let E=R&&((V=this.serviceColloctor)==null?void 0:V.transformKey(L))||L;const O=(U=(J=l==null?void 0:l[o])==null?void 0:J[a])==null?void 0:U[E];O&&(!R&&((Q=this.serviceColloctor)!=null&&Q.isOwn(E))&&(E=this.serviceColloctor.getLocalId(E)),z.zIndex=k,O!=null&&O.opt&&(O.opt.zIndex=k))})),f.length&&(i===Ct.Top?(this.addMaxLayerForBackgroundSVG(o),N=this.getMaxZIndexForBackgroundSVG(o)):(this.addMinLayerForBackgroundSVG(o),N=this.getMinZIndexForBackgroundSVG(o)),f.forEach(L=>{var D,V,J,U,Q;const R=(D=this.serviceColloctor)==null?void 0:D.isLocalId(L);let E=R&&((V=this.serviceColloctor)==null?void 0:V.transformKey(L))||L;const O=(U=(J=l==null?void 0:l[o])==null?void 0:J[a])==null?void 0:U[E];O&&(!R&&((Q=this.serviceColloctor)!=null&&Q.isOwn(E))&&(E=this.serviceColloctor.getLocalId(E)),z.zIndexForBackgroundSVG=N,O!=null&&O.opt&&(O.opt.zIndex=N))})),P.willSerializeData=!0,h.push([P,{workId:w,msgType:Y.UpdateNode,emitEventType:this.emitEventType}])}continue}}h.length&&this.collectForLocalWorker(h);function p(w,y){return y.isLocalId(w)&&y.transformKey(w)||w}}}class Mp extends We{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",W.TranslateNode);I(this,"cachePosition")}collect(e,t){var g,m,w;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:i,position:o,workState:s,viewId:a}=e;this.lastEmtData=e;const c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,h=[...i],u=(g=this.serviceColloctor)==null?void 0:g.storage,f=[],p=s===j.Start&&this.mainEngine.now||void 0;for(p&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,a);h.length;){const y=h.pop();if(!y)continue;const M=y.toString(),v=this.serviceColloctor.isLocalId(M),S=v&&this.serviceColloctor.transformKey(y)||M;let C=M;!v&&this.serviceColloctor.isOwn(C)&&(C=this.serviceColloctor.getLocalId(C));const k=(w=(m=u==null?void 0:u[a])==null?void 0:m[l])==null?void 0:w[S];if(k&&C===Z){if(k.selectIds){const N=this.control.viewContainerManager.transformToScenePoint([o.x,o.y],a);if(s===j.Start&&(this.cachePosition=N),this.cachePosition){const z=k.updateNodeOpt||{};z.translate=[N[0]-this.cachePosition[0],N[1]-this.cachePosition[1]],z.workState=s,this.control.cursor.isEnableCursor?z.useAnimation=!1:(z.uid=this.serviceColloctor.uid,s===j.Start?z.useAnimation=!1:s===j.Done&&(z.useAnimation=!0));const P={workId:y,msgType:Y.UpdateNode,dataType:X.Local,updateNodeOpt:z,emitEventType:this.emitEventType,willSyncService:!0,textUpdateForWoker:!0,viewId:a,smoothSync:this.mainEngine.smoothSync};s===j.Done&&(P.textUpdateForWoker=!0,P.willSerializeData=!0,this.cachePosition=void 0,P.needUndoTicker=this.control.viewContainerManager.getUndoTickerId(a)),f.push([P,{workId:y,msgType:Y.UpdateNode,emitEventType:this.emitEventType,workState:s}])}}continue}}s===j.Start?this.mainEngine.unWritable():s===j.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),f.length&&this.collectForLocalWorker(f,t)}}class pp extends We{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",W.DeleteNode)}collect(e){var f,p;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 s=o.focusScenePath,a=this.serviceColloctor.storage,c=[...t],l=[],h=[],u=this.mainEngine.now;for(;c.length;){const g=c.pop();if(!g)continue;const m=g.toString(),w=this.serviceColloctor.isLocalId(m),y=w?this.serviceColloctor.transformKey(g):m,M=(p=(f=a==null?void 0:a[i])==null?void 0:f[s])==null?void 0:p[y];if(M){let v=m;if(!w&&this.serviceColloctor.isOwn(v)&&(v=this.serviceColloctor.getLocalId(v)),M.toolsType===T.Text){this.control.textEditorManager.delete(v,!0,!0);continue}h.push(v)}}h.length&&(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,i),l.push([{msgType:Y.RemoveNode,emitEventType:W.DeleteNode,removeIds:h,dataType:X.Local,willSyncService:!0,willRefresh:!0,viewId:i,isRunBackgroundThread:this.control.isUseBackgroundThread,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(i)},void 0]),this.collectForLocalWorker(l))}}class yp extends We{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",W.ScaleNode);I(this,"targetText",new Map);I(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 M,v,S,C,k,N,z;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:i,workState:o,viewId:s,originPoint:a,scenePoint:c,dir:l,scale:h,translate:u}=e;this.lastEmtData=e;const f=this.control.viewContainerManager.getView(s);if(!(f!=null&&f.displayer))return;const p=f.focusScenePath,g=[...i],m=(M=this.serviceColloctor)==null?void 0:M.storage,w=[],y=o===j.Start&&this.mainEngine.now||void 0;for(y&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",y,s);g.length;){const P=g.pop();if(!P)continue;const L=P.toString(),R=this.serviceColloctor.isLocalId(L),E=R&&this.serviceColloctor.transformKey(P)||L;let O=L;!R&&this.serviceColloctor.isOwn(O)&&(O=this.serviceColloctor.getLocalId(O));const D=(S=(v=m==null?void 0:m[s])==null?void 0:v[p])==null?void 0:S[E];if(D&&O===Z&&D.selectIds){const V=D.updateNodeOpt||{};if(V.dir=l,V.originPoint=a,V.scenePoint=c,V.workState=o,V.scale=h,V.translate=u,o===j.Start){this.cacheTextInfo.clear();for(const U of D.selectIds){const Q=(C=this.serviceColloctor)==null?void 0:C.isLocalId(U),H=Q&&((k=this.serviceColloctor)==null?void 0:k.transformKey(U))||U;let oe=H;!Q&&((N=this.serviceColloctor)!=null&&N.isOwn(H))&&(oe=this.serviceColloctor.getLocalId(H));const ne=this.control.textEditorManager.get(oe);ne&&o===j.Start&&this.targetText.set(oe,Gt(ne))}}if(this.targetText.size&&o!==j.Start&&h){const U=[];for(const[H,oe]of this.targetText.entries()){const{opt:ne}=oe,q=Math.floor(ne.fontSize*h[0]),$=this.cacheTextInfo.get(H),ae=!$&&ne.fontSize!==q||$&&$.fontSize!==q||!1,Ge=(z=this.control.textEditorManager.get(H))==null?void 0:z.opt;if(ae&&Ge&&ne.boxSize&&ne.boxPoint){const Ke=this.setTextStyle(H,{...Ge,fontSize:q},s);U.push(Ke)}}const Q=await Promise.all(U);for(const H of Q)if(H){const{key:oe,textInfo:ne}=H;this.cacheTextInfo.set(oe,{fontSize:ne.opt.fontSize,boxSize:ne.opt.boxSize,boxPoint:ne.opt.boxPoint})}V.textInfos=this.cacheTextInfo}this.control.cursor.isEnableCursor?V.useAnimation=!1:(V.uid=this.serviceColloctor.uid,o===j.Start?V.useAnimation=!1:o===j.Done&&(V.useAnimation=!0));const J={workId:P,msgType:Y.UpdateNode,dataType:X.Local,updateNodeOpt:V,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:s,smoothSync:this.mainEngine.smoothSync};o===j.Done&&(J.willSerializeData=!0,this.targetText.clear(),J.needUndoTicker=this.control.viewContainerManager.getUndoTickerId(s)),w.push([J,{workId:P,msgType:Y.UpdateNode,emitEventType:this.emitEventType,workState:o}]);continue}}o===j.Start?this.mainEngine.unWritable():o===j.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),w.length&&this.collectForLocalWorker(w,t)}}class mp extends We{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",W.RotateNode);I(this,"cacheOriginRotate",0)}collect(e,t){var g,m,w,y,M,v,S;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:i,angle:o,workState:s,viewId:a}=e;this.lastEmtData=e;const c=this.control.viewContainerManager.getView(a);if(!(c!=null&&c.displayer))return;const l=c.focusScenePath,h=[...i],u=(g=this.serviceColloctor)==null?void 0:g.storage,f=[],p=s===j.Start&&this.mainEngine.now||void 0;for(p&&this.mainEngine.internalMsgEmitter.emit("addUndoTicker",p,a);h.length;){const C=h.pop();if(!C)continue;const k=C.toString(),N=this.serviceColloctor.isLocalId(k),z=N&&this.serviceColloctor.transformKey(C)||k;let P=k;!N&&this.serviceColloctor.isOwn(P)&&(P=this.serviceColloctor.getLocalId(P));const L=(w=(m=u==null?void 0:u[a])==null?void 0:m[l])==null?void 0:w[z];if(L&&P===Z){if(((y=L.selectIds)==null?void 0:y.length)===1){const R=L.selectIds[0];if(s===j.Start){const V=((M=this.serviceColloctor)==null?void 0:M.isLocalId(R))&&((v=this.serviceColloctor)==null?void 0:v.transformKey(R))||R,J=u[a][l][V];this.cacheOriginRotate=((S=J==null?void 0:J.opt)==null?void 0:S.rotate)||0}const E=L.updateNodeOpt||{};E.angle=(o+this.cacheOriginRotate)%360,E.workState=s,this.control.cursor.isEnableCursor?E.useAnimation=!1:(E.uid=this.serviceColloctor.uid,s===j.Start?E.useAnimation=!1:s===j.Done&&(E.useAnimation=!0));const O={workId:C,msgType:Y.UpdateNode,dataType:X.Local,updateNodeOpt:E,emitEventType:this.emitEventType,willRefreshSelector:!1,willSyncService:!0,viewId:a,smoothSync:this.mainEngine.smoothSync};s===j.Done&&(O.willRefreshSelector=!0,O.willSerializeData=!0,this.cacheOriginRotate=0,O.needUndoTicker=this.control.viewContainerManager.getUndoTickerId(a)),f.push([O,{workId:C,msgType:Y.UpdateNode,emitEventType:this.emitEventType,workState:s}])}continue}}s===j.Start?this.mainEngine.unWritable():s===j.Done&&(this.mainEngine.abled(),this.lastEmtData=void 0),f.length&&this.collectForLocalWorker(f,t)}}function Ip(r){switch(r){case T.Text:return Fe.Text;case T.SpeechBalloon:case T.Star:case T.Ellipse:case T.Rectangle:case T.Triangle:case T.Rhombus:case T.Polygon:return Fe.Shape}}function wp(r){const n=r.lastChild;if(!n){const i=document.createElement("div"),o=document.createTextNode("");return i.appendChild(o),r.appendChild(i),o}if(n.nodeType===Node.TEXT_NODE)return n;const e=n;if(!e.lastChild){const i=document.createTextNode("");return e.appendChild(i),i}if(e.lastChild.nodeType===Node.TEXT_NODE)return e.lastChild;const t=document.createTextNode("");return e.appendChild(t),t}function Tp(r,n){var i;const e=document.createRange(),t=wp(n);t.nodeType===Node.TEXT_NODE?e.setStart(t,((i=t.textContent)==null?void 0:i.length)||0):e.setStart(t,0),e.collapse(!0),r.removeAllRanges(),r.addRange(e)}function Np(r,n){return!!(r!=null&&r.anchorNode)&&n.contains(r.anchorNode)}class vp extends We{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",W.SetFontStyle);I(this,"timerId")}async setTextStyle(e,t,i,o){const{bold:s,underline:a,lineThrough:c,italic:l,fontSize:h}=i;if(t.toolsType&&Ip(t.toolsType)===Fe.Text){t.opt&&(s&&(t.opt.bold=s),x.isBoolean(a)&&(t.opt.underline=a),x.isBoolean(c)&&(t.opt.lineThrough=c),l&&(t.opt.italic=l),h&&(t.opt.fontSize=h));const f=await this.control.textEditorManager.updateTextControllerWithEffectAsync({workId:e,opt:t.opt,viewId:o,canSync:!1,canWorker:!1});return{key:e,textInfo:f}}}async collect(e){var M,v,S,C,k,N;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,bold:i,italic:o,lineThrough:s,underline:a,viewId:c,fontSize:l}=e,h=this.control.viewContainerManager.getView(c);if(!(h!=null&&h.displayer))return;const u=h.focusScenePath,f=[...t],p=this.serviceColloctor.storage,g={},m=this.mainEngine.now;this.mainEngine.internalMsgEmitter.emit("addUndoTicker",m,c),this.control.textEditorManager.UndoTickerId=m;const w=[];for(;f.length;){const z=f.pop();if(!z)continue;const P=z.toString(),L=this.serviceColloctor.isLocalId(P),R=L?this.serviceColloctor.transformKey(z):P;let E=P;!L&&this.serviceColloctor.isOwn(E)&&(E=this.serviceColloctor.getLocalId(E));const O=(v=(M=p==null?void 0:p[c])==null?void 0:M[u])==null?void 0:v[R];if(O){const D=O.updateNodeOpt||{};if(i&&(D.bold=i,g.bold=i==="bold"),o&&(D.italic=o,g.italic=o==="italic"),x.isBoolean(s)&&(D.lineThrough=s,g.lineThrough=s),x.isBoolean(a)&&(D.underline=a,g.underline=a),l&&(D.fontSize=l,g.textSize=l),O.toolsType===T.Text&&O.opt){const V=this.setTextStyle(E,x.cloneDeep(O),D,c);w.push(V);continue}if(O&&E===Z&&((S=O.selectIds)!=null&&S.length))for(const V of O.selectIds){const J=(C=this.serviceColloctor)==null?void 0:C.isLocalId(V);let U=J&&((k=this.serviceColloctor)==null?void 0:k.transformKey(V))||V;const Q=p[c][u][U]||void 0;if(!J&&((N=this.serviceColloctor)!=null&&N.isOwn(U))&&(U=this.serviceColloctor.getLocalId(U)),Q&&Q.toolsType===T.Text&&O.opt){const H=this.setTextStyle(U,x.cloneDeep(Q),D,c);w.push(H);continue}}}}const y=await Promise.all(w);for(const z of y)if(z){const{key:P,textInfo:L}=z;L&&(L.canSync=!0,L.canWorker=!0,this.control.textEditorManager.updateForViewEdited(P,L))}Object.keys(g).length&&(this.timerId&&(clearTimeout(this.timerId),this.timerId=void 0),this.timerId=setTimeout(()=>{var z;this.timerId=void 0,(z=this.control.room)==null||z.setMemberState(g)},0))}}class Cp extends We{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",W.SetPoint);I(this,"undoTickerId")}collect(e){var M,v,S;if(!this.serviceColloctor||!this.mainEngine)return;const{workId:t,pointMap:i,workState:o,viewId:s}=e,a=this.control.viewContainerManager.getView(s);if(!(a!=null&&a.displayer))return;const c=a.focusScenePath,l=(M=this.serviceColloctor)==null?void 0:M.storage,h=[],u=o===j.Start&&this.mainEngine.now||void 0;u&&(this.undoTickerId=u,this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,s));const f=t;if(!f)return;const p=f.toString(),g=this.serviceColloctor.isLocalId(p),m=g&&this.serviceColloctor.transformKey(f)||p;let w=p;!g&&this.serviceColloctor.isOwn(w)&&(w=this.serviceColloctor.getLocalId(w));const y=(S=(v=l==null?void 0:l[s])==null?void 0:v[c])==null?void 0:S[m];if(y&&w===Z&&y.selectIds){const C=y.updateNodeOpt||{};C.pointMap=i,C.workState=o;const k={workId:f,msgType:Y.UpdateNode,dataType:X.Local,updateNodeOpt:C,emitEventType:this.emitEventType,willRefreshSelector:!0,willSyncService:!0,viewId:s,needUndoTicker:o===j.Done&&this.control.viewContainerManager.getUndoTickerId(s)||void 0};o===j.Done&&(k.undoTickerId=this.undoTickerId),h.push([k,{workId:f,msgType:Y.UpdateNode,emitEventType:this.emitEventType}])}o===j.Start?this.mainEngine.unWritable():o===j.Done&&this.mainEngine.abled(),h.length&&this.collectForLocalWorker(h)}}class Sp extends We{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",W.SetLock)}collect(e){var f,p;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,isLocked:i,viewId:o}=e,s=this.control.viewContainerManager.getView(o);if(!(s!=null&&s.displayer))return;const a=s.focusScenePath,c=[...t],l=this.serviceColloctor.storage,h=[],u=this.mainEngine.now;for(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,o);c.length;){const g=c.pop();if(!g)continue;const m=g.toString(),w=this.serviceColloctor.isLocalId(m),y=w?this.serviceColloctor.transformKey(g):m;let M=m;!w&&this.serviceColloctor.isOwn(M)&&(M=this.serviceColloctor.getLocalId(M));const v=(p=(f=l==null?void 0:l[o])==null?void 0:f[a])==null?void 0:p[y];if(v){const S=v.updateNodeOpt||{};S.isLocked=i;const C={workId:M,msgType:Y.UpdateNode,dataType:X.Local,updateNodeOpt:S,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:o,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(o)};h.push([C,{workId:M,msgType:Y.UpdateNode,emitEventType:this.emitEventType}])}}h.length&&this.collectForLocalWorker(h)}}class kp extends We{constructor(){super(...arguments);I(this,"lastEmtData");I(this,"emitEventType",W.SetShapeOpt)}collect(e){var f,p;if(!this.serviceColloctor||!this.mainEngine)return;const{workIds:t,viewId:i,...o}=e,s=this.control.viewContainerManager.getView(i);if(!(s!=null&&s.displayer))return;const a=s.focusScenePath,c=[...t],l=this.serviceColloctor.storage,h=[],u=this.mainEngine.now;for(this.mainEngine.internalMsgEmitter.emit("addUndoTicker",u,i);c.length;){const g=c.pop();if(!g)continue;const m=g.toString(),w=this.serviceColloctor.isLocalId(m),y=w?this.serviceColloctor.transformKey(g):m;let M=m;!w&&this.serviceColloctor.isOwn(M)&&(M=this.serviceColloctor.getLocalId(M));const v=(p=(f=l==null?void 0:l[i])==null?void 0:f[a])==null?void 0:p[y];if(v){const S={...v.updateNodeOpt,...o,willRefresh:!0};if(v&&M===Z){const C={workId:M,msgType:Y.UpdateNode,dataType:X.Local,updateNodeOpt:S,emitEventType:this.emitEventType,willRefresh:!0,willRefreshSelector:!0,willSyncService:!0,viewId:i,needUndoTicker:this.control.viewContainerManager.getUndoTickerId(i)};h.push([C,{workId:M,msgType:Y.UpdateNode,emitEventType:this.emitEventType}])}}}h.length&&this.collectForLocalWorker(h)}}class re{constructor(n){I(this,"builders",new Map);this.builders=new Map(n.map(e=>[e,this.build(e)]))}build(n){switch(n){case W.TranslateNode:return new Mp;case W.ZIndexNode:return new fp;case W.CopyNode:return new dp;case W.SetColorNode:return new gp;case W.DeleteNode:return new pp;case W.ScaleNode:return new yp;case W.RotateNode:return new mp;case W.SetFontStyle:return new vp;case W.SetPoint:return new Cp;case W.SetLock:return new Sp;case W.SetShapeOpt:return new kp}}getBuilder(n){return this.builders.get(n)}registerForMainEngine(n,e){return this.builders.forEach(t=>{t&&t.registerForMainEngine(n,e)}),this}destroy(){this.builders.forEach(n=>{n&&n.destroy()}),this.builders.clear()}pause(){return this.builders.forEach(n=>{n&&n.pause()}),this}recover(){return this.builders.forEach(n=>{n&&n.recover()}),this}static emitMethod(n,e,t){We.dispatch(n,e,t)}static activeListener(n){we.InternalMsgEmitter.on(W.ActiveMethod,n)}static unmountActiveListener(n){we.InternalMsgEmitter.off(W.ActiveMethod,n)}}const xp=async(r,n)=>{const{src:e,isgl:t}=r;if(typeof Image=="function"){const i=new Image;return typeof e=="string"&&(i.crossOrigin="anonymous"),new Promise(o=>{i.onload=function(){createImageBitmap(i,{imageOrientation:t?"flipY":"none"}).then(s=>{o(s)})},i.onerror=function(){o(void 0)},i.src=e})}else return fetch(e,{method:"GET",mode:"cors",cache:"default"}).then(i=>i.blob()).then(i=>createImageBitmap(i,{imageOrientation:t?"flipY":"none"}).then(o=>o))},pt=class pt{constructor(){I(this,"fontDB");I(this,"FONT_DB_NAME","__APPLIANCE_PLUGIN_FONT_DB");I(this,"FONT_STORE_NAME","fonts");I(this,"FONT_DB_VERSION",1)}static getInstance(){return pt.instance||(pt.instance=new pt),pt.instance}async initFontDB(){return this.fontDB?this.fontDB:new Promise((n,e)=>{const t=indexedDB.open(this.FONT_DB_NAME,this.FONT_DB_VERSION);t.onerror=()=>{e(new Error(`Failed to open font database: ${t.error}`))},t.onsuccess=()=>{this.fontDB=t.result,n(t.result)},t.onupgradeneeded=i=>{const o=i.target.result;o.objectStoreNames.contains(this.FONT_STORE_NAME)||o.createObjectStore(this.FONT_STORE_NAME,{keyPath:"fontFamily"}).createIndex("url","url",{unique:!1})}})}async getFontFromDB(n){try{return this.fontDB||(this.fontDB=await this.initFontDB()),new Promise((e,t)=>{const s=this.fontDB.transaction([this.FONT_STORE_NAME],"readonly").objectStore(this.FONT_STORE_NAME).get(n);s.onsuccess=()=>{s.result&&s.result.buffer?e(s.result.buffer):e(null)},s.onerror=()=>{t(s.error)}})}catch(e){return console.error(`Failed to get font from database for ${n}:`,e),null}}async saveFontToDB(n,e,t){try{return this.fontDB||(this.fontDB=await this.initFontDB()),new Promise((i,o)=>{const a=this.fontDB.transaction([this.FONT_STORE_NAME],"readwrite").objectStore(this.FONT_STORE_NAME),c={fontFamily:n,url:e,buffer:t,timestamp:Date.now()},l=a.put(c);l.onsuccess=()=>{i(!0)},l.onerror=()=>{o(l.error)}})}catch(i){return console.error(`Failed to save font to database for ${n}:`,i),!1}}async clearFontCache(){try{return this.fontDB||(this.fontDB=await this.initFontDB()),new Promise((n,e)=>{const o=this.fontDB.transaction([this.FONT_STORE_NAME],"readwrite").objectStore(this.FONT_STORE_NAME).clear();o.onsuccess=()=>{console.log("Font cache cleared successfully"),n(!0)},o.onerror=()=>{e(o.error)}})}catch(n){return console.error("Failed to clear font cache:",n),!1}}async getFontCacheStatus(){try{return this.fontDB||(this.fontDB=await this.initFontDB()),new Promise((n,e)=>{const o=this.fontDB.transaction([this.FONT_STORE_NAME],"readonly").objectStore(this.FONT_STORE_NAME).getAll();o.onsuccess=()=>{const s=o.result||[],a=s.reduce((c,l)=>c+(l.buffer?l.buffer.byteLength:0),0);n({count:s.length,totalSize:a})},o.onerror=()=>{e(o.error)}})}catch(n){return console.error("Failed to get font cache status:",n),{count:0,totalSize:0}}}};I(pt,"instance");let En=pt;function jp(r){return r===de.Stroke?de.Normal:r}function mt(r){const{pencilOptions:n}=r,e=jp(n.strokeType);return{strokeColor:n.strokeColor,thickness:n.thickness,isOpacity:n.isOpacity,zIndex:n.zIndex,scale:n.scale,rotate:n.rotate,translate:n.translate,eraserlines:n.eraserlines,strokeType:e,lineCap:e===de.Normal?void 0:n.lineCap,lineDash:e===de.Normal?void 0:n.lineDash}}function Rr(r){return[r.start[0],r.start[1],0,r.end[0],r.end[1],0]}function Mn(r){const{minX:n,minY:e,maxX:t,maxY:i}=r.bbox;return[n,e,0,t,i,0]}function Dp(r){const{minX:n,minY:e,maxX:t,maxY:i}=r.bbox;return[n,e,0,t,e,0,t,i,0,n,i,0]}const bp=(r,n)=>({toolsType:T.Straight,opt:mt(n),op:Rr(r)}),Ap=(r,n)=>({toolsType:T.Arrow,opt:mt(n),op:Rr(r)}),zp=(r,n)=>({toolsType:T.Rectangle,opt:{...mt(n),fillColor:"transparent"},op:Dp(r)}),Ep=(r,n)=>({toolsType:T.Ellipse,opt:{...mt(n),fillColor:"transparent"},op:Mn(r)}),Lp=(r,n)=>({toolsType:T.Polygon,opt:{...mt(n),fillColor:"transparent",vertices:3,shapeType:Ye.Triangle},op:Mn(r)}),Pp=(r,n)=>({toolsType:T.Polygon,opt:{...mt(n),fillColor:"transparent",vertices:4,shapeType:Ye.Rhombus},op:Mn(r)}),Op=(r,n)=>({toolsType:T.Star,opt:{...mt(n),fillColor:"transparent",vertices:10,innerVerticeStep:2,innerRatio:.4,shapeType:Ye.Pentagram},op:Mn(r)}),ht={straight:bp,arrow:Ap,rectangle:zp,ellipse:Ep,triangle:Lp,rhombus:Pp,star:Op};function Rp(r){return St(r.op)}function st(r){if(!r.length)return r;const[n,e]=r[0],[t,i]=r[r.length-1];return n===t&&e===i?r:[...r,r[0]]}function Yp(r,n){const e=st(r).slice(0,-1),t=(n%e.length+e.length)%e.length;return st(e.slice(t).concat(e.slice(0,t)))}function ai(r){return[...r].reverse()}function It(r,n,e,t,i){const o=[];for(let s=0;s<i;s++){const a=Yp(e,s),c=ai(a);o.push({id:`${n}-cw-${s}`,semanticKind:r,points:a,threshold:t},{id:`${n}-ccw-${s}`,semanticKind:r,points:c,threshold:t})}return o}function Up(r,n,e,t){const i=[];return e.forEach((o,s)=>{i.push({id:`${n}-forward-${s}`,semanticKind:r,points:o,threshold:t},{id:`${n}-reverse-${s}`,semanticKind:r,points:ai(o),threshold:t})}),i}const Zi=[[0,.5],[.25,.5],[.5,.5],[.75,.5],[1,.5]],Bp=[[.05,.5],[.3,.5],[.55,.5],[.78,.5],[1,.5],[.8,.32],[1,.5],[.8,.68]],Wp=[[.05,.5],[.3,.5],[.55,.5],[.78,.5],[1,.5],[.8,.68],[1,.5],[.8,.32]],Vp=st([[.15,.2],[.85,.2],[.85,.8],[.15,.8]]),Fp=st([[.5,.12],[.88,.82],[.12,.82]]),Qp=st([[.5,.08],[.92,.5],[.5,.92],[.08,.5]]),Gp=st([[.5,.04],[.62,.34],[.95,.36],[.68,.56],[.78,.9],[.5,.7],[.22,.9],[.32,.56],[.05,.36],[.38,.34]]),Zp=st([[.5,.04],[.74,.88],[.08,.34],[.92,.34],[.26,.88]]),$p=Array.from({length:24},(r,n)=>{const e=Math.PI*2*n/24;return[.5+Math.cos(e)*.42,.5+Math.sin(e)*.3]}),dt=[{id:"straight-base",semanticKind:"straight",points:Zi,threshold:.72},{id:"straight-reverse",semanticKind:"straight",points:ai(Zi),threshold:.72},...Up("arrow","arrow",[Bp,Wp],.71),...It("rectangle","rectangle",Vp,.68,4),...It("ellipse","ellipse",st($p),.64,12),...It("triangle","triangle",Fp,.68,3),...It("rhombus","rhombus",Qp,.66,4),...It("star","star",Gp,.7,5),...It("star","pentagram",Zp,.68,5)];function Rt(r,n,e,t){const{metrics:i}=n;return i.closureRatio>.24||i.cornerCount<e||i.cornerCount>t?null:r}const Hp=[{kind:"straight",templates:dt.filter(r=>r.semanticKind==="straight"),postProcessor(r,n){const{metrics:e}=n;return e.bboxDiagonal<8||e.closureRatio<.75||e.straightness<.94&&r.score<.8?null:r},mapper:ht.straight,enabledInV1:!0},{kind:"arrow",templates:dt.filter(r=>r.semanticKind==="arrow"),postProcessor(r,n){const{metrics:e}=n;return e.closureRatio<.12||e.cornerCount<4||e.cornerCount>7||e.straightness>.93?null:r.score>=Math.max(r.threshold,.71)?r:null},mapper:ht.arrow,enabledInV1:!0},{kind:"rectangle",templates:dt.filter(r=>r.semanticKind==="rectangle"),postProcessor(r,n){const e=Rt(r,n,4,6);return!e||n.metrics.bboxCornerCloseness>.15||n.metrics.bboxCornerCloseness>=n.metrics.diamondCloseness?null:e},mapper:ht.rectangle,enabledInV1:!0},{kind:"ellipse",templates:dt.filter(r=>r.semanticKind==="ellipse"),postProcessor(r,n){const e=Rt(r,n,6,12);return!e||n.metrics.radialVariance>.5?null:e},mapper:ht.ellipse,enabledInV1:!0},{kind:"triangle",templates:dt.filter(r=>r.semanticKind==="triangle"),postProcessor(r,n){return Rt(r,n,3,4)},mapper:ht.triangle,enabledInV1:!0},{kind:"rhombus",templates:dt.filter(r=>r.semanticKind==="rhombus"),postProcessor(r,n){const e=Rt(r,n,4,5);return!e||n.metrics.diamondCloseness>=n.metrics.bboxCornerCloseness?null:e},mapper:ht.rhombus,enabledInV1:!0},{kind:"star",templates:dt.filter(r=>r.semanticKind==="star"),postProcessor(r,n){const e=r.templateId.startsWith("pentagram"),t=Rt(r,n,e?5:8,12);if(!t)return null;if(e){if(n.metrics.bboxCornerCloseness<.22||n.metrics.angleVariance<35)return null}else if(n.metrics.radialVariance<.34)return null;return t},mapper:ht.star,enabledInV1:!0}];function ci(){return Hp}const Jp=64,Ln=250;function qe(r,n){const e=r[0]-n[0],t=r[1]-n[1];return Math.hypot(e,t)}function Xp(r){const n=[];for(const e of r){const t=n[n.length-1];(!t||qe(t,e)>.5)&&n.push(e)}return n}function Yr(r){let n=0;for(let e=1;e<r.length;e++)n+=qe(r[e-1],r[e]);return n}function Ur(r){let n=Number.POSITIVE_INFINITY,e=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(const[o,s]of r)n=Math.min(n,o),e=Math.min(e,s),t=Math.max(t,o),i=Math.max(i,s);return{minX:n,minY:e,maxX:t,maxY:i}}function qp(r,n=Jp){if(r.length<=1)return r;const e=Yr(r)/Math.max(n-1,1),t=[r[0]];let i=0,o=r[0],s=1;const a=[...r];for(;s<a.length;){const c=a[s],l=qe(o,c);if(l===0){s++;continue}if(i+l>=e){const h=(e-i)/l,u=[o[0]+h*(c[0]-o[0]),o[1]+h*(c[1]-o[1])];t.push(u),a.splice(s,0,u),i=0,o=u,s++}else i+=l,o=c,s++}for(;t.length<n;)t.push(a[a.length-1]);return t}function pn(r){const n=r.reduce((e,t)=>[e[0]+t[0],e[1]+t[1]],[0,0]);return[n[0]/r.length,n[1]/r.length]}function Kp(r,n){const e=pn(r),t=Math.cos(n),i=Math.sin(n);return r.map(([o,s])=>{const a=o-e[0],c=s-e[1];return[a*t-c*i+e[0],a*i+c*t+e[1]]})}function _p(r){const n=pn(r);return Math.atan2(n[1]-r[0][1],n[0]-r[0][0])}function ey(r,n=Ln){const e=Ur(r),t=Math.max(e.maxX-e.minX,1),i=Math.max(e.maxY-e.minY,1);return r.map(([o,s])=>[(o-e.minX)/t*n,(s-e.minY)/i*n])}function ty(r){const n=pn(r);return r.map(([e,t])=>[e-n[0],t-n[1]])}function Br(r){const n=qp(r),e=Kp(n,-_p(n)),t=ey(e);return ty(t)}function ny(r,n){let e=0;const t=Math.min(r.length,n.length);for(let i=0;i<t;i++)e+=qe(r[i],n[i]);return e/Math.max(t,1)}function iy(r,n,e){const[t,i]=r,[o,s]=n,[a,c]=e,l=Math.abs((c-s)*t-(a-o)*i+a*s-c*o),h=Math.hypot(c-s,a-o)||1;return l/h}function Pn(r,n){if(r.length<=2)return r;let e=0,t=0;for(let s=1;s<r.length-1;s++){const a=iy(r[s],r[0],r[r.length-1]);a>e&&(e=a,t=s)}if(e<=n)return[r[0],r[r.length-1]];const i=Pn(r.slice(0,t+1),n),o=Pn(r.slice(t),n);return i.slice(0,-1).concat(o)}function ry(r){if(r.length<3)return[];const n=[];for(let e=0;e<r.length;e++){const t=r[(e-1+r.length)%r.length],i=r[e],o=r[(e+1)%r.length],s=[t[0]-i[0],t[1]-i[1]],a=[o[0]-i[0],o[1]-i[1]],c=s[0]*a[0]+s[1]*a[1],l=Math.hypot(s[0],s[1])*Math.hypot(a[0],a[1])||1,h=Math.acos(Math.max(-1,Math.min(1,c/l)));n.push(h*180/Math.PI)}return n}function oy(r){const n=Ur(r),e=Math.max(n.maxX-n.minX,1),t=Math.max(n.maxY-n.minY,1),i=Math.hypot(e,t)||1,o=Yr(r),s=qe(r[0],r[r.length-1]),a=qe(r[0],r[r.length-1]),c=a/i,l=i*.045,u=c<.24&&r.length>2?r.slice(0,qe(r[0],r[r.length-1])<.5?-1:r.length):r,f=Pn(u,l),p=ry(f),g=p.length>0?Math.max(...p.map(N=>Math.abs(N-90))):90,m=f.map(([N,z])=>[(N-n.minX)/e,(z-n.minY)/t]),w=[[0,0],[1,0],[1,1],[0,1]],y=[[.5,0],[1,.5],[.5,1],[0,.5]],M=(N,z)=>N.reduce((P,L)=>{const R=Math.min(...z.map(E=>qe(L,E)));return P+R},0)/Math.max(N.length,1),v=pn(r),S=r.map(N=>qe(N,v)),C=S.reduce((N,z)=>N+z,0)/Math.max(S.length,1),k=C>0?S.reduce((N,z)=>N+Math.abs(z-C)/C,0)/Math.max(S.length,1):0;return{bbox:n,metrics:{pathLength:o,chordLength:s,straightness:s/Math.max(o,1),closureDistance:a,closureRatio:c,bboxWidth:e,bboxHeight:t,bboxDiagonal:i,aspectRatio:e/t,cornerCount:Math.max(0,f.length),angleVariance:g,radialVariance:k,bboxCornerCloseness:M(m,w),diamondCloseness:M(m,y)}}}function sy(r){return r.map(n=>({template:n,normalized:Br(n.points)}))}const ay=sy(ci().flatMap(r=>r.templates));function cy(r){const n=Xp(r.rawPoints);if(n.length<2)return null;const{bbox:e,metrics:t}=oy(n);return{rawPoints:r.rawPoints,points:n,pencilOptions:r.pencilOptions,viewId:r.viewId,scenePath:r.scenePath,start:n[0],end:n[n.length-1],bbox:e,metrics:t}}function ly(r){const n=Br(r.points),e=new Map;for(const{template:t,normalized:i}of ay){const o=ny(n,i),s=Math.max(0,1-o/(.5*Math.sqrt(2*Ln*Ln))),a={kind:t.semanticKind,templateId:t.id,threshold:t.threshold||.7,distance:o,score:s},c=e.get(t.semanticKind);(!c||a.score>c.score)&&e.set(t.semanticKind,a)}return[...e.values()].sort((t,i)=>i.score-t.score)}function uy(r){const n=ci(),e=ly(r);if(r.metrics.bboxDiagonal>=8&&r.metrics.straightness>.975&&r.metrics.closureRatio>.75){const i=e.find(o=>o.kind==="straight")||{templateId:"straight-heuristic",score:.99,threshold:.72};return{kind:"straight",score:i.score,threshold:i.threshold,recognized:!0,bbox:r.bbox,start:r.start,end:r.end,points:r.points,templateId:i.templateId,metrics:r.metrics,candidates:e}}for(const i of e){const o=n.find(a=>a.kind===i.kind);if(!o||i.score<i.threshold)continue;const s=o.postProcessor?o.postProcessor(i,r):i;if(s)return{kind:o.kind,score:s.score,threshold:s.threshold,recognized:!0,bbox:r.bbox,start:r.start,end:r.end,points:r.points,templateId:s.templateId,metrics:r.metrics,candidates:e}}const t=e[0];return{kind:"none",score:(t==null?void 0:t.score)||0,threshold:(t==null?void 0:t.threshold)||1,recognized:!1,bbox:r.bbox,start:r.start,end:r.end,points:r.points,templateId:t==null?void 0:t.templateId,metrics:r.metrics,candidates:e}}function hy(r){return cy(r)}function dy(r){return uy(r)}function $i(r,n){if(!r.recognized||r.kind==="none")return null;const e=ci().find(t=>t.kind===r.kind);return(e==null?void 0:e.mapper(r,n))||null}class gy{get now(){var n;return((n=this.control.room)==null?void 0:n.calibrationTimestamp)||Date.now()}get newWorkId(){return this.now.toString()}setCurrentToolsData(n){this.currentToolsData=n}getCurrentToolsData(){return this.currentToolsData}setCurrentLocalWorkData(n){this.currentLocalWorkData=n}getWorkId(){return this.currentLocalWorkData.workId}get workState(){return this.currentLocalWorkData.workState}}class fy extends gy{constructor(e){super();I(this,"maxLastSyncTime",me.syncOpt.interval);I(this,"combineUnitTime",me.bezier.combineUnitTime);I(this,"maxCombineEraserTime",me.pencilEraser.maxCombineTime);I(this,"smoothSync",me.syncOpt.smoothSync);I(this,"isActive",!1);I(this,"currentToolsData");I(this,"currentLocalWorkData");I(this,"control");I(this,"internalMsgEmitter");I(this,"publicMsgEmitter");I(this,"taskBatchData",new Set);I(this,"fullWorker");I(this,"subWorker");I(this,"fullWorkerUrl");I(this,"subWorkerUrl");I(this,"methodBuilder");I(this,"zIndexNodeMethod");I(this,"subWorkerDrawCount",0);I(this,"fullWorkerDrawCount",0);I(this,"maxDrawCount",0);I(this,"_consumeCount",0);I(this,"_postCount",0);I(this,"reRenders",new Map);I(this,"localWorkViewId");I(this,"localPointsBatchData",new Map);I(this,"tasksqueue",new Map);I(this,"useTasksqueue",!1);I(this,"useTasksClockId");I(this,"mainTasksqueueCount");I(this,"workerTasksqueueCount");I(this,"snapshotMap",new Map);I(this,"boundingRectMap",new Map);I(this,"clearAllResolveMap",new Map);I(this,"delayWorkStateToDoneResolve");I(this,"animationId");I(this,"tmpImageConfigMap",new Map);I(this,"mainThread");I(this,"backgroundThreadManager");I(this,"willSelectorWorkId");I(this,"isLockSentEventCursor",!1);I(this,"getVNodeInfoResolveMap",new Map);I(this,"setFontFacesResolve",{});I(this,"isLocalWorkActive",!1);I(this,"indexDBUtils",En.getInstance());I(this,"markmapIdResolveMap",new Map);const{control:t,internalMsgEmitter:i,publicMsgEmitter:o}=e;this.control=t,this.maxLastSyncTime=this.control.pluginOptions.extras.syncOpt.interval,this.combineUnitTime=this.control.pluginOptions.extras.bezier.combineUnitTime||this.combineUnitTime,this.smoothSync=x.isBoolean(this.control.pluginOptions.extras.syncOpt.smoothSync)?this.control.pluginOptions.extras.syncOpt.smoothSync:this.smoothSync,this.maxCombineEraserTime=this.control.pluginOptions.extras.pencilEraser.maxCombineTime||this.maxCombineEraserTime,this.fullWorkerUrl=this.control.pluginOptions.cdn.fullWorkerUrl||"",this.subWorkerUrl=this.control.pluginOptions.cdn.subWorkerUrl||"",this.internalMsgEmitter=i,this.publicMsgEmitter=o,this.currentLocalWorkData={workState:j.Pending}}get isBezier(){return this.control.pluginOptions.extras.bezier.enable}get Logger(){return this.control.logger}destroy(){var e,t,i,o,s;(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.mainThread)==null||t.destroy(),this.mainThread=void 0,(i=this.backgroundThreadManager)==null||i.destroy(),this.backgroundThreadManager=void 0,(o=this.fullWorker)==null||o.terminate(),this.fullWorker=void 0,(s=this.subWorker)==null||s.terminate(),this.subWorker=void 0}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===T.Pencil||e===T.PencilEraser||e===T.BitMapEraser||e===T.LaserPen||e===T.Arrow||e===T.Straight||e===T.Ellipse||e===T.Rectangle||e===T.Star||e===T.Polygon||e===T.SpeechBalloon||e===T.Selector}get isCanDrawWork(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.LaserPen||e===T.Arrow||e===T.Straight||e===T.Ellipse||e===T.Rectangle||e===T.Star||e===T.Polygon||e===T.SpeechBalloon||e===T.Triangle||e===T.Rhombus||e===T.BitMapEraser||e===T.PencilEraser}get isUseZIndex(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.Arrow||e===T.Straight||e===T.Ellipse||e===T.Rectangle||e===T.Star||e===T.Polygon||e===T.SpeechBalloon||e===T.Text||e===T.Image}get isCanRecordUndoRedo(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.Eraser||e===T.PencilEraser||e===T.BitMapEraser||e===T.Arrow||e===T.Straight||e===T.Ellipse||e===T.Rectangle||e===T.Star||e===T.Polygon||e===T.SpeechBalloon||e===T.Text||e===T.Image}get isCanSentCursor(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.Text||e===T.LaserPen||e===T.Arrow||e===T.Straight||e===T.Ellipse||e===T.Rectangle||e===T.Star||e===T.Polygon||e===T.SpeechBalloon||e===T.Triangle||e===T.Rhombus||e===T.Eraser||e===T.PencilEraser||e===T.BitMapEraser||e===T.Selector}get isPostCountType(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.Arrow||e===T.Straight||e===T.Ellipse||e===T.Rectangle||e===T.Star||e===T.Polygon||e===T.SpeechBalloon||e===T.Triangle||e===T.Rhombus||e===T.Eraser||e===T.PencilEraser||e===T.BitMapEraser||e===T.Selector}get isCanPostDraw(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Pencil||e===T.PencilEraser||e===T.BitMapEraser}get isCanStartEventConsum(){var t;const e=(t=this.currentToolsData)==null?void 0:t.toolsType;return e===T.Selector||e===T.Eraser||e===T.PencilEraser||e===T.BitMapEraser}async init(){this.destroy(),await this.on(),this.internalMsgEmitterListener(),this.isActive=!0}async useBackgroundThread(){console.info("use background thread");const{BackgroundThreadManagerImpl:e}=await Promise.resolve().then(()=>require("./index-vfn-RVQz.js"));this.backgroundThreadManager=new e(this)}async useMainThread(){console.info("no OffscreenCanvas"),this.control.hasExtendFontFaces&&await document.fonts.ready.then(()=>{this.Logger.info("[Appliance]: set font faces in main thread success")});const{MainThreadManagerImpl:e}=await Promise.resolve().then(()=>require("./index-DlkXPynh.js"));this.mainThread=new e(this)}async on(){if(this.control.isUseBackgroundThread&&await this.useBackgroundThread(),!this.control.hasOffscreenCanvas){await this.useMainThread();return}if(!this.fullWorkerUrl||!this.subWorkerUrl){console.error("no worker url config");return}if(this.fullWorker=new Worker(this.fullWorkerUrl,{type:"classic"}),this.control.isUseSimple||(this.subWorker=new Worker(this.subWorkerUrl,{type:"classic"})),this.fullWorker.onmessage=e=>{if(e.data){const{render:t,sp:i,fullWorkerDrawCount:o,workerTasksqueueCount:s,viewId:a,consumeCount:c}=e.data;if(c&&(this.consumeCount=c),this.isBusy&&s&&this.setWorkerTasksqueueCount(s),i!=null&&i.length&&this.collectorSyncData(i),this.control.isUseSimple){if(this.control.isUseOffscreenTransfer)return;t&&(t!=null&&t.length)&&this.viewContainerManager.render(t);return}const l=(t==null?void 0:t.length)&&t||[];if(o&&a){if(this.fullWorkerDrawCount=o,this.fullWorkerDrawCount<1/0){const h=Math.max(this.maxDrawCount,this.fullWorkerDrawCount);this.setMaxDrawCount(h),this.clearReRenders(this.fullWorkerDrawCount)}else this.setMaxDrawCount(0),this.clearReRenders(1/0);if(this.reRenders.size)for(const h of this.reRenders.values())l.push(...h)}l.length&&this.viewContainerManager.render(l)}},this.subWorker&&(this.subWorker.onmessage=e=>{if(e.data){const{render:t,sp:i,subWorkerDrawCount:o,consumeCount:s}=e.data;s&&(this.consumeCount=s),i!=null&&i.length&&this.collectorSyncData(i);const a=(t==null?void 0:t.length)&&t||[];if(x.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)}a.length&&this.viewContainerManager.render(a)}}),this.control.hasExtendFontFaces){const e=this.control.extendFontFaces,t=[],i=[];this.control.room&&this.Logger.info(`[Appliance]: load before font faces ${JSON.stringify(e)}`),await new Promise(async o=>{this.setFontFacesResolve.resolve=o,this.setFontFacesResolve.timer=setTimeout(()=>{this.setFontFacesResolve.resolve&&(this.Logger.warn("[Appliance]: set font faces timeout"),this.setFontFacesResolve.resolve(!1))},this.control.loadFontFacesTimeout);try{for(const s of e){let a;a=await this.indexDBUtils.getFontFromDB(s.fontFamily)||void 0,a||(a=await this.loadFontInMainThread(s.src),a&&a.byteLength>0&&(await this.indexDBUtils.saveFontToDB(s.fontFamily,s.src,a)||this.Logger.warn(`[Appliance]: Failed to save font ${s.fontFamily} to IndexedDB, but continuing with font loading`))),a&&a.byteLength>0?(i.push({fontFamily:s.fontFamily,buffer:a}),t.push(a)):this.Logger.warn(`[Appliance]: Font ${s.fontFamily} could not be loaded from any source`)}this.Logger.info("[Appliance]: load end font faces"),i.length?this.fullWorker.postMessage(new Set([{type:Y.SetFontFace,fontBuffers:i}]),t):this.setFontFacesResolve.resolve(!0)}catch(s){this.setFontFacesResolve.timer&&(clearTimeout(this.setFontFacesResolve.timer),this.setFontFacesResolve.timer=void 0),this.setFontFacesResolve.resolve&&(this.setFontFacesResolve.resolve(!1),this.Logger.error(`[Appliance]: set font faces error: ${s}`))}}).then(o=>{this.setFontFacesResolve.resolve=void 0,this.setFontFacesResolve.timer=void 0,o?this.Logger.info("[Appliance]: set font faces in web worker success"):this.Logger.error("[Appliance]: set font faces in web worker error")})}}async clearFontCache(){return await this.indexDBUtils.clearFontCache()}async getFontCacheStatus(){return await this.indexDBUtils.getFontCacheStatus()}async loadFontInMainThread(e){try{const t=await fetch(e);if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);const i=await t.arrayBuffer();if(!i||i.byteLength===0)throw new Error("Empty font data received");const o=new Uint8Array(i);if(!this.validateFontData(o))throw new Error("Invalid font data format: not a valid font file");return i}catch(t){this.Logger.error(`[Appliance]: Failed to load font from ${e}: ${t instanceof Error?t.message:String(t)}`);return}}validateFontData(e){return e.length<4?!1:e[0]===119&&e[1]===79&&e[2]===70&&e[3]===50||e[0]===119&&e[1]===79&&e[2]===70&&e[3]===70||e[0]===0&&e[1]===1&&e[2]===0&&e[3]===0||e[0]===79&&e[1]===84&&e[2]===84&&e[3]===79||e.length>36&&e[36]===0&&e[37]===1&&e[38]===0&&e[39]===0}clearReRenders(e=1/0){for(const t of this.reRenders.keys())if(x.isNumber(Number(t))&&Number(t)<=e){const i=this.reRenders.get(Number(t));i==null||i.forEach(o=>{var s;(s=o.imageBitmap)==null||s.close()}),this.reRenders.delete(t)}}get isBusy(){return this.getTasksqueueState()===j.Doing}getLockSentEventCursor(){return this.isLockSentEventCursor}setLockSentEventCursor(e){this.isLockSentEventCursor=e}getTasksqueueState(){return this.useTasksqueue&&j.Doing||j.Done}setMaxDrawCount(e){this.maxDrawCount=e}getFullWorkDrawCount(){return this.fullWorkerDrawCount}getMaxDrawCount(){return this.maxDrawCount}setSubWorkerDrawCount(e){this.subWorkerDrawCount=e}setConsumeCount(e){this.consumeCount=e}getConsumeCount(){return this.consumeCount}setWorkerTasksqueueCount(e){const t=Math.max(this.workerTasksqueueCount||0,e);this.workerTasksqueueCount=t}collectorSyncData(e){var i,o,s,a;let t=!1;for(const c of e){const{type:l,selectIds:h,opt:u,selectRect:f,strokeColor:p,fillColor:g,willSyncService:m,isSync:w,imageBitmap:y,canvasHeight:M,canvasWidth:v,rect:S,op:C,canTextEdit:k,points:N,selectorColor:z,canRotate:P,scaleType:L,textOpt:R,toolsType:E,workId:O,viewId:D,dataType:V,canLock:J,isLocked:U,shapeOpt:Q,toolsTypes:H,thickness:oe,strokeType:ne,useStroke:q,isgl:$,imageSrc:ae,isSubWorker:Ge,updateNodeOpt:Ke,setFontFaceResult:lt,failedFonts:_e,reportString:et,index:tt,imageElement:je}=c;if(l===Y.SetFontFace){lt&&this.setFontFacesResolve.resolve&&(_e&&_e.length>0&&this.Logger.info("[Appliance]: set font face has failed fonts: "+_e.join(", ")),this.setFontFacesResolve.resolve(lt));return}if(!D)return;const Ne=c.scenePath||this.viewContainerManager.getCurScenePath(D);switch(l){case Y.Select:{const K=h!=null&&h.length?{...f,selectIds:h,canvasHeight:M,canvasWidth:v,points:N}:void 0;K&&(u!=null&&u.strokeColor)&&(K.selectorColor=u.strokeColor),K&&z&&(K.selectorColor=z),K&&p&&(K.strokeColor=p),K&&(u!=null&&u.fillColor)&&(K.fillColor=u.fillColor),K&&g&&(K.fillColor=g),K&&x.isBoolean(P)&&(K.canRotate=P),K&&L&&(K.scaleType=L),K&&k&&(K.canTextEdit=k),K&&R&&(K.textOpt=R),K&&x.isBoolean(J)&&(K.canLock=J),K&&x.isBoolean(U)&&(K.isLocked=U),K&&Q&&(K.shapeOpt=Q),K&&H&&(K.toolsTypes=H),K&&oe&&(K.thickness=oe),K&&ne&&(K.strokeType=ne),K&&x.isBoolean(q)&&(K.useStroke=q),D&&this.viewContainerManager.showFloatBar(D,!!K,K),m&&((i=this.collector)==null||i.dispatch({type:l,selectIds:h,opt:u,isSync:w,viewId:D,scenePath:Ne}));break}case Y.Snapshot:if((y||je)&&Ne){const K=this.snapshotMap.get(Ne);if(K){const{resolve:Ae,value:Ee}=K;if(Ee&&Ae){const G=tt||0;Ee[G]=y||je,Ee.every(ie=>ie!==void 0)&&Ae(Ee)}}}break;case Y.BoundingBox:if(S&&Ne){const K=this.boundingRectMap.get(Ne);K&&K(S)}break;case Y.Cursor:C&&this.control.cursor.collectServiceCursor({...c});break;case Y.Clear:if(D){this.viewContainerManager.showFloatBar(D,!1);const K=(o=this.clearAllResolveMap.get(D))==null?void 0:o.resolve;K&&K(D)}break;case Y.BackgroundSVGDelete:this.backgroundThreadManager&&D&&this.backgroundThreadManager.consumeTargetOne(D,{...c,msgType:Y.BackgroundSVGDelete,viewId:D,dataType:X.Local});break;case Y.BackgroundSVGUpdate:this.backgroundThreadManager&&D&&this.backgroundThreadManager.consumeTargetOne(D,{...c,msgType:Y.BackgroundSVGUpdate,viewId:D,dataType:X.Local});break;case Y.TextUpdate:if(E===T.Text&&O&&D){const K=this.viewContainerManager.transformToOriginPoint((u==null?void 0:u.boxPoint)||[0,0],D),Ae=(u==null?void 0:u.boxSize)||[0,0],Ee=(s=this.viewContainerManager.getView(D))==null?void 0:s.cameraOpt;u?this.control.textEditorManager.updateTextForWorker({x:K[0],y:K[1],w:Ae[0],h:Ae[1],scale:(Ee==null?void 0:Ee.scale)||1,workId:O,opt:u,dataType:V,viewId:D,canSync:m||!1,canWorker:!1,updateNodeOpt:Ke}):this.control.textEditorManager.delete(O,m||!1,!1)}break;case Y.GetTextActive:E===T.Text&&O&&D&&this.control.textEditorManager.updateTextForWorker({workId:O,isActive:!0,viewId:D,dataType:X.Local,canWorker:!1,canSync:!0},this.now);break;case Y.GetImageBitMap:ae&&D&&O&&xp({src:ae,isgl:$}).then(K=>{var Ee;const Ae=new Set;if(Ae.add({msgType:Y.GetImageBitMap,dataType:X.Local,workId:O,viewId:D,imageSrc:ae,isSubWorker:Ge,imageBitmap:K}),!this.control.hasOffscreenCanvas)(Ee=this.mainThread)==null||Ee.consume(Ae);else{const G=Ge&&this.subWorker?this.subWorker:this.fullWorker;K?G.postMessage(Ae,[K]):G.postMessage(Ae)}});break;case Y.GetVNodeInfo:if(O){const K=O.toString(),Ae=(a=this.getVNodeInfoResolveMap.get(K))==null?void 0:a.resolve,Ee={...c,uuid:K};Ae&&Ae(Ee)}break;case Y.ReportError:case Y.ReportLog:et&&(l===Y.ReportError?this.Logger.error(`[Appliance]: [MasterControlForWorker] reportError ${et}`):this.Logger.info(`[Appliance]: [MasterControlForWorker] reportLog ${et}`));break;default:t=!0;break}}t&&this.collectorAsyncData(e)}foceUndoTickerEnd(e,t){this.internalMsgEmitter.emit("forceUndoTickerEnd",e,t)}collectorAsyncData(e){var t,i,o,s;for(const a of e){const{type:c,op:l,workId:h,index:u,removeIds:f,ops:p,opt:g,updateNodeOpt:m,toolsType:w,isSync:y,viewId:M,isLockSentEventCursor:v,nextTasks:S,needUndoTicker:C}=a;if(!M){console.error("[MasterControlForWorker] collectorAsyncData on viewId in",a);return}const k=a.scenePath||this.viewContainerManager.getCurScenePath(M);switch(c){case Y.None:{v&&He(()=>{this.setLockSentEventCursor(!1)},this.maxLastSyncTime,this.control.hasPolyfillMethod("requestIdleCallback")),C&&Number(C)&&He(()=>{this.foceUndoTickerEnd(Number(C),M)},0,this.control.hasPolyfillMethod("requestIdleCallback"));break}case Y.DrawWork:{(t=this.collector)==null||t.dispatch({type:c,op:l,opt:g,toolsType:w,workId:h,index:u,isSync:y,viewId:M,scenePath:k,updateNodeOpt:m});break}case Y.FullWork:{if((i=this.collector)==null||i.dispatch({type:c,ops:p,workId:h,updateNodeOpt:m,opt:g,toolsType:w,isSync:y,viewId:M,scenePath:k}),a.autoShapeResult&&console.info("[autoShape][sync]",{viewId:M,scenePath:k,workId:h==null?void 0:h.toString(),toolsType:w,kind:a.autoShapeResult.kind,score:a.autoShapeResult.score,threshold:a.autoShapeResult.threshold}),w===T.BackgroundSVG&&h&&this.markmapIdResolveMap.has(h.toString())){const N=this.markmapIdResolveMap.get(h.toString());N!=null&&N.timer&&(clearTimeout(N.timer),N.timer=void 0),N!=null&&N.resolve&&N.resolve(h.toString()),this.markmapIdResolveMap.delete(h.toString())}this.willSelectorWorkId&&h&&h.toString()===this.willSelectorWorkId&&this.control.runEffectWork(()=>{this.setShapeSelectorByWorkId(this.willSelectorWorkId,M),this.willSelectorWorkId=void 0});break}case Y.UpdateNode:{(o=this.collector)==null||o.dispatch({type:c,updateNodeOpt:m,workId:h,opt:g,ops:p,op:l,isSync:y,viewId:M,scenePath:k});break}case Y.RemoveNode:{f&&this.control.textEditorManager.deleteBatch(f,!1,!1),(s=this.collector)==null||s.dispatch({type:c,removeIds:f,isSync:y,viewId:M,scenePath:k}),this.willSelectorWorkId&&(f!=null&&f.includes(this.willSelectorWorkId))&&(this.willSelectorWorkId=void 0);break}}S&&this.collectorAsyncData(S)}}async onLocalEventEnd(e,t){var h;const i=this.viewContainerManager.getView(t);if(!i)return;const{focusScenePath:o,cameraOpt:s}=i,a=this.viewContainerManager.transformToScenePoint(e,t),c=[],l=[];for(const u of this.localPointsBatchData.keys())if(((h=this.currentToolsData)==null?void 0:h.toolsType)===T.Text){const f=this.getLocalPointInfo(u),p=f==null?void 0:f.state;if(p&&p===j.Start){const g=this.currentLocalWorkData.toolsOpt;g.workState=j.Doing,g.boxPoint=[Math.round(a[0]),Math.round(a[1])],g.boxSize=[g.fontSize,g.fontSize],this.control.textEditorManager.checkEmptyTextBlur(),this.control.textEditorManager.createTextForMasterController({workId:this.newWorkId,x:e[0],y:e[1],scale:(s==null?void 0:s.scale)||1,opt:g,type:Fe.Text,isActive:!0,viewId:t,scenePath:o},this.now)}this.deleteLocalPoint(u);continue}else{this.pushLocalPoint(u,a,j.Done,t);const f=this.getLocalPointInfo(u);if(f){const p=this.createAutoShapeTask({workId:u,viewId:t,scenePath:o,points:[...f.rawPoints],opt:f.opt});p&&l.push(p)}c.push(u)}if(c.length){try{if(await new Promise(f=>{setTimeout(async()=>{const p=new Set(l.map(g=>{var m;return(m=g.workId)==null?void 0:m.toString()}).filter(Boolean));c.forEach(g=>{if(p.has(g.toString())){this.deleteLocalPoint(g);return}this.setLocalPointIsFullWork(g)}),l.forEach(g=>{this.taskBatchData.add(g)}),this.delayWorkStateToDoneResolve=f,l.length&&p.size===c.length&&this.delayWorkStateToDoneResolve(!0),this.consume()},0)})&&c[0]){const f=c[0];c.forEach(p=>{this.deleteLocalPoint(p)}),this.willSelectorWorkId=f.toString()}}catch(u){this.Logger.error(`[Appliance]: [MasterControlForWorker] onLocalEventEnd error: ${u instanceof Error?u.message:String(u)}`)}this.delayWorkStateToDoneResolve=void 0,c.length=0}}onLocalEventDoing(e,t){var o;if(((o=this.currentToolsData)==null?void 0:o.toolsType)===T.Text)return;this.currentLocalWorkData.workState===j.Start&&this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:j.Doing});let i=!1;for(const[s,{state:a}]of this.localPointsBatchData.entries())if(this.isAbled()&&a!==j.Pending){const c=this.viewContainerManager.transformToScenePoint(e,t);this.pushLocalPoint(s,c,a===j.Start?j.Doing:a,t),i=!0}if(i){this.runAnimation();return}}onLocalEventStart(e,t){var c,l;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===T.Selector?Z:this.newWorkId,s=this.setZIndex(t);this.setCurrentLocalWorkData({workState:j.Start,toolsOpt:s,viewId:t});const a=this.viewContainerManager.transformToScenePoint(e,t);if(this.pushLocalPoint(o,a,j.Start,t,s),i!==T.Text){if(this.control.textEditorManager.checkEmptyTextBlur(),this.isCanRecordUndoRedo&&this.internalMsgEmitter.emit("addUndoTicker",this.now,t),o&&s&&i&&this.isCanStartEventConsum&&this.prepareOnceWork({workId:o,toolsOpt:s,viewId:t},i),this.consumeCount=0,this.postCount=0,this.maxDrawCount=0,this.fullWorkerDrawCount=0,this.subWorkerDrawCount=0,this.clearReRenders(1/0),this.isCanDrawWork){const h=this.viewContainerManager.getCurScenePath(t);h&&((l=this.collector)!=null&&l.hasSelector(t,h))&&this.blurSelector(t,h)}this.consume()}}setLocalPointIsFullWork(e){const t=this.getLocalPointInfo(e);t&&(t.isFullWork=!0,this.localPointsBatchData.set(e,t))}pushLocalPoint(e,t,i,o,s){let a=this.getLocalPointInfo(e);i===j.Start?a={state:j.Start,points:[...t],rawPoints:[...t],opt:s||this.currentLocalWorkData.toolsOpt,isFullWork:!1,viewId:o}:a&&(a.state=i,a.points.push(t[0],t[1]),a.rawPoints.push(t[0],t[1])),a&&this.localPointsBatchData.set(e,a)}deleteLocalPoint(e){this.localPointsBatchData.delete(e)}getLocalPointInfo(e){return this.localPointsBatchData.get(e)}getLocalPointsInfo(){return this.localPointsBatchData}shouldUseAutoShape(e){var t;return((t=this.currentToolsData)==null?void 0:t.toolsType)===T.Pencil&&!!(e!=null&&e.autoShape)}toAutoShapePoints(e){const t=[];for(let i=0;i<e.length-1;i+=2)t.push([e[i],e[i+1]]);return t}logAutoShapeResult(e){}emitAutoShapeResult(e){const{viewId:t,workId:i,scenePath:o,result:s,recognized:a,mappedToolsType:c}=e,l=s.candidates[0],h={workId:i.toString(),viewId:t,scenePath:o,recognized:a,fallbackToPencil:!a,kind:s.kind,score:s.score,threshold:s.threshold,templateId:s.templateId,mappedToolsType:c,topCandidate:l?{kind:l.kind,score:l.score,threshold:l.threshold,templateId:l.templateId}:void 0,metrics:{cornerCount:s.metrics.cornerCount,straightness:s.metrics.straightness,closureRatio:s.metrics.closureRatio,radialVariance:s.metrics.radialVariance,bboxCornerCloseness:s.metrics.bboxCornerCloseness,diamondCloseness:s.metrics.diamondCloseness}};this.publicMsgEmitter.emit("autoShape",h)}createAutoShapeTask(e){const{workId:t,viewId:i,scenePath:o,points:s,opt:a}=e;if(!this.shouldUseAutoShape(a))return;const c=hy({rawPoints:this.toAutoShapePoints(s),pencilOptions:x.cloneDeep(a),viewId:i,scenePath:o});if(!c)return;const l=dy(c),h=$i(l,c)||this.mapAutoShapeFallback(l,c);if(this.logAutoShapeResult({viewId:i,workId:t,result:l,recognized:!!h}),this.emitAutoShapeResult({viewId:i,workId:t,scenePath:o,result:l,recognized:!!h,mappedToolsType:h==null?void 0:h.toolsType}),!!h)return{msgType:Y.FullWork,dataType:X.Local,workId:t,viewId:i,scenePath:o,toolsType:h.toolsType,opt:h.opt,ops:Rp(h),willRefresh:!0,willSyncService:!0,isRunSubWork:!0,clearPreviewLocalWork:!0,isLockSentEventCursor:!0,autoShapeResult:l,needUndoTicker:this.viewContainerManager.getUndoTickerId(i)}}mapAutoShapeFallback(e,t){const{metrics:i}=e;if(e.recognized||i.closureRatio>.1)return null;let o;return i.cornerCount>=4&&i.cornerCount<=6&&i.bboxCornerCloseness<=.15&&i.diamondCloseness>i.bboxCornerCloseness+.15?o="rectangle":i.cornerCount===3&&i.radialVariance<.28?o="triangle":i.cornerCount>=8&&i.cornerCount<=12&&i.radialVariance>.28?o="star":i.cornerCount>=5&&i.radialVariance<.22&&i.bboxCornerCloseness>.2&&(o="ellipse"),o?$i({...e,kind:o,recognized:!0},t):null}correctStorage(e,t,i){var u,f;const o=new Map,s=[],a=new Map,c=[];Object.keys(e).forEach(p=>{var w,y,M;const g=(y=(w=e[p])==null?void 0:w.opt)==null?void 0:y.zIndex,m=(M=e[p])==null?void 0:M.toolsType;x.isNumber(g)&&(m&&m===T.BackgroundSVG?c.push([p,g]):s.push([p,g]))});const l=s.length&&((u=this.zIndexNodeMethod)==null?void 0:u.correct(s))||[],h=c.length&&((f=this.zIndexNodeMethod)==null?void 0:f.correct(c))||[];this.zIndexNodeMethod&&l.length&&(this.zIndexNodeMethod.setMinZIndex(l[0][1]||0,t),this.zIndexNodeMethod.setMaxZIndex(l[l.length-1][1]||0,t)),this.zIndexNodeMethod&&h.length&&(this.zIndexNodeMethod.setMinZIndexForBackgroundSVG(h[0][1]||0,t),this.zIndexNodeMethod.setMaxZIndexForBackgroundSVG(h[h.length-1][1]||0,t));for(const[p,g]of l){if(!e[p])continue;const m=e[p];m.opt&&x.isNumber(m.opt.zIndex)&&m.opt.zIndex!==g&&(m.opt.zIndex=g,o.set(p,m))}o.size&&o.forEach((p,g)=>{var m;(m=this.collector)==null||m.updateValue(g,p,{viewId:t,scenePath:i,isSync:!0}),e[g]=p});for(const[p,g]of h){if(!e[p])continue;const m=e[p];m.opt&&x.isNumber(m.opt.zIndex)&&m.opt.zIndex!==g&&(m.opt.zIndex=g,a.set(p,m))}return a.size&&a.forEach((p,g)=>{var m;(m=this.collector)==null||m.updateValue(g,p,{viewId:t,scenePath:i,isSync:!0}),e[g]=p}),e}async originalEventLintener(e,t,i){var c,l,h;if(!this.isAbled())return;const o=(c=this.collector)==null?void 0:c.uid,s=this.viewContainerManager.getCurScenePath(i);if(o&&!this.control.renderControl.isWritable)return;const a=((l=this.currentToolsData)==null?void 0:l.toolsType)===T.Selector;switch((h=this.currentToolsData)==null?void 0:h.toolsType){case T.Eraser:case T.PencilEraser:case T.BitMapEraser:{if(o&&!this.control.renderControl.isClearAble({uid:o,viewId:i,scenePath:s}))return;break}default:{if(o&&!this.control.renderControl.isRenderAble({uid:o,viewId:i,scenePath:s}))return;break}}switch(e){case j.Start:this.isLocalWorkActive=!0,this.setLocalWorkViewId(i),i&&this.onLocalEventStart(t,i),a&&this.viewContainerManager.showFloatBarBtn(i,!1);break;case j.Doing:i&&i===this.getLocalWorkViewId()&&this.onLocalEventDoing(t,i);break;case j.Done:i&&i===this.getLocalWorkViewId()&&(this.setCurrentLocalWorkData({...this.currentLocalWorkData,workState:j.Done}),await this.onLocalEventEnd(t,i),setTimeout(()=>{this.isLocalWorkActive=!1,this.setCurrentLocalWorkData({workState:j.Pending}),a&&this.viewContainerManager.showFloatBarBtn(i,!0),this.setLocalWorkViewId(void 0)},0));break}this.isLocalWorkActive&&this.viewContainerManager.focuedViewId===i&&this.publicMsgEmitter.emit("workState",e,i),He(()=>{var u;(u=this.control.pluginManager)==null||u.dispatchPluginEvent("localEvent",i,e,t)},Qn,this.control.hasPolyfillMethod("requestIdleCallback"))}getLocalWorkViewId(){return this.localWorkViewId}setLocalWorkViewId(e){this.localWorkViewId=e}setCurrentToolsData(e){var o,s,a;const t=e.toolsType,i=((o=this.currentToolsData)==null?void 0:o.toolsType)!==e.toolsType;if(super.setCurrentToolsData(e),i){const c=(s=this.viewContainerManager)==null?void 0:s.getAllViews();for(const l of c)if(l){const{id:h,focusScenePath:u}=l;i&&h&&u&&((a=this.collector)!=null&&a.hasSelector(h,u)&&this.blurSelector(h,u),this.control.textEditorManager.checkEmptyTextBlur())}this.taskBatchData.add({msgType:Y.UpdateTools,dataType:X.Local,toolsType:t,opt:{...e.toolsOpt,syncUnitTime:this.maxLastSyncTime},combineUnitTime:this.isBezier?this.combineUnitTime:1/0,maxCombineEraserTime:this.maxCombineEraserTime,isRunSubWork:this.isRunSubWork,viewId:br,isRunBackgroundThread:this.control.isUseBackgroundThread}),this.runAnimation()}}prepareOnceWork(e,t){const{workId:i,toolsOpt:o,viewId:s}=e,a={msgType:Y.CreateWork,dataType:X.Local,viewId:s,toolsType:t};this.queryTaskBatchData(a).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({...a,workId:i,opt:{...o,syncUnitTime:this.maxLastSyncTime},dataType:X.Local,isRunSubWork:this.isRunSubWork}),this.runAnimation()}createViewWorker(e,t,i){const{offscreenCanvasOpt:o,layerOpt:s,dpr:a,cameraOpt:c}=t,l={msgType:Y.Init,dataType:X.Local,viewId:e,offscreenCanvasOpt:o,layerOpt:s,dpr:a,cameraOpt:c,isRunSubWork:!0,isSafari:navigator.userAgent.indexOf("Safari")!==-1&&navigator.userAgent.indexOf("Chrome")===-1,combineUnitTime:this.isBezier?this.combineUnitTime:1/0,maxCombineEraserTime:this.maxCombineEraserTime,syncUnitTime:this.maxLastSyncTime,isUseSimple:this.control.isUseSimple,offscreenCanvas:i.transferControlToOffscreenCanvas};this.isBusy&&this.destroyTaskQueue(),this.post(new Set([l])),this.taskBatchData.size&&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:Y.Destroy,dataType:X.Local,viewId:e,isRunSubWork:!0}),this.consume(),t||(i=this.collector)==null||i.dispatch({type:Y.Clear,viewId:e}),this.control.renderControl.destoryByViewId(e,t)}onServiceDerive(e,t){var g,m,w,y,M,v,S,C,k;const{newValue:i,oldValue:o,viewId:s,scenePath:a}=t,c=x.cloneDeep(i)||{},l=e;let h=c.type;if(!i&&o){if(l&&((g=this.collector)==null?void 0:g.getLocalId(l))===Z){this.collector.isOwn(l)?this.blurSelector(s,a):this.blurSelector(s,a,l);return}if(h=Y.RemoveNode,o.toolsType===T.LaserPen)return}const u=(m=this.viewContainerManager.getView(s))==null?void 0:m.focusScenePath;if(u&&u!==a)return;if((w=this.collector)!=null&&w.isSelector(e)){const N=(y=this.collector)==null?void 0:y.getUidFromKey(e);if(N&&!this.control.roomMember.isOnLine(N))return}if(h&&l){if(!this.control.renderControl.isFilterAble({viewId:s,elementId:e,scenePath:a},h))return;const N=c;if(N.workId=(M=this.collector)!=null&&M.isOwn(l)?(v=this.collector)==null?void 0:v.getLocalId(l):l,N.msgType=h,N.toolsType===T.LaserPen&&(N.isRunSubWork=!0),N.toolsType===T.BackgroundSVG){if(!this.control.isUseBackgroundThread)return;N.isRunBackgroundThread=!0}if(N.dataType=X.Service,N.viewId=s,N.scenePath=a,N.useAnimation=this.smoothSync&&((S=N.updateNodeOpt)==null?void 0:S.useAnimation)||!1,N.selectIds&&(N.selectIds=N.selectIds.map(z=>{var P,L;return(P=this.collector)!=null&&P.isOwn(z)?(L=this.collector)==null?void 0:L.getLocalId(z):z})),N&&N.toolsType===T.Text||(o==null?void 0:o.toolsType)===T.Text){this.control.textEditorManager.onServiceDerive(N);return}N.isEnableCursor=this.control.cursor.isEnableCursor,this.taskBatchData.add(N)}this.runAnimation();const f=t.newValue&&((C=t.newValue)==null?void 0:C.toolsType),p=t.newValue&&((k=t.newValue.opt)==null?void 0:k.zIndex);if(f&&f===T.BackgroundSVG){if(this.zIndexNodeMethod&&x.isNumber(p)){const N=this.zIndexNodeMethod.getMinZIndexForBackgroundSVG(s);this.zIndexNodeMethod.getMaxZIndexForBackgroundSVG(s)<p&&this.zIndexNodeMethod.setMaxZIndexForBackgroundSVG(p,s),N>p&&this.zIndexNodeMethod.setMinZIndexForBackgroundSVG(p,s)}}else if(this.zIndexNodeMethod&&x.isNumber(p)){const N=this.zIndexNodeMethod.getMinZIndex(s);this.zIndexNodeMethod.getMaxZIndex(s)<p&&this.zIndexNodeMethod.setMaxZIndex(p,s),N>p&&this.zIndexNodeMethod.setMinZIndex(p,s)}}pullServiceData(e,t,i={isAsync:!1,useAnimation:!1}){var c,l,h,u,f,p,g;let o=(c=this.collector)==null?void 0:c.getStorageData(e,t);const{isAsync:s,useAnimation:a}=i;if(o){this.control.renderControl.isWritable&&(o=this.correctStorage(o,e,t));const m=Object.keys(o);for(const w of m){if((l=this.collector)!=null&&l.isSelector(w)){const M=(h=this.collector)==null?void 0:h.getUidFromKey(w);if(M&&!this.control.roomMember.isOnLine(M))continue}const y=(u=o[w])==null?void 0:u.type;if(y&&w){if(!this.control.renderControl.isFilterAble({viewId:e,elementId:w,scenePath:t},y))continue;const M=o[w];if(M.workId=(f=this.collector)!=null&&f.isOwn(w)?(p=this.collector)==null?void 0:p.getLocalId(w):w,M.msgType=y,M.dataType=X.Service,M.viewId=e,M.scenePath=t,M.useAnimation=this.smoothSync&&(M.ops?!!a:(g=M.updateNodeOpt)==null?void 0:g.useAnimation)||!1,M.selectIds&&(M.selectIds=M.selectIds.map(v=>{var S,C;return(S=this.collector)!=null&&S.isOwn(v)?(C=this.collector)==null?void 0:C.getLocalId(v):v})),M.toolsType===T.Text){this.control.textEditorManager.onServiceDerive(M);continue}if(M.toolsType===T.BackgroundSVG){if(!this.control.isUseBackgroundThread)continue;M.isRunBackgroundThread=!0}s&&M.updateNodeOpt&&M.updateNodeOpt.useAnimation&&(M.updateNodeOpt.useAnimation=!1),M.isEnableCursor=this.control.cursor.isEnableCursor,this.taskBatchData.add(M)}this.internalMsgEmitter.emit("excludeIds",m,e)}s?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 s of this.taskBatchData.values())s.dataType===X.Service&&(i.add(s),this.taskBatchData.delete(s));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:s,points:a,opt:c}]of this.localPointsBatchData.entries()){if(o===j.Done&&!s||o===j.Start&&!this.isCanStartEventConsum)continue;const l=a.map(h=>h);if(l.length){if(this.isPostCountType&&o===j.Doing){if(this.postCount>this.consumeCount)continue;this.postCount++}this.delayWorkStateToDoneResolve&&o===j.Done&&(this.delayWorkStateToDoneResolve(!0),this.setLockSentEventCursor(!0)),this.taskBatchData.add({op:l,workState:o,workId:i,dataType:X.Local,msgType:Y.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(t=this.currentToolsData)==null?void 0:t.toolsType,viewId:e,scenePath:e&&this.viewContainerManager.getCurScenePath(e),opt:c,smoothSync:this.smoothSync,isLockSentEventCursor:this.getLockSentEventCursor(),syncUnitTime:this.maxLastSyncTime,disableEraseImage:this.control.disableEraseImage,disableEraseText:this.control.disableEraseText,postCount:this.isPostCountType&&this.postCount||void 0,fullWorkerDrawCount:this.isCanPostDraw&&this.fullWorkerDrawCount||void 0,needUndoTicker:o===j.Done&&this.viewContainerManager.getUndoTickerId(e)||void 0}),a.length=0}}if(this.taskBatchData.size){const i=new Set(this.taskBatchData);this.post(i),this.taskBatchData.clear()}this.taskBatchData.size&&(this.animationId=requestAnimationFrame(this.consume.bind(this)))}unWritable(){this.setCurrentLocalWorkData({workState:j.Unwritable}),this.setLockSentEventCursor(!0)}abled(){this.setCurrentLocalWorkData({workState:j.Pending}),this.setLockSentEventCursor(!1)}isAbled(){return this.currentLocalWorkData.workState!==j.Unwritable}postMainThread(e){if(!this.control.hasOffscreenCanvas&&this.mainThread){this.mainThread.consume(e);return}}postWebWorker(e){if(this.control.isUseSimple){const t=[...e].find(i=>i.msgType===Y.Init&&i.offscreenCanvas);t!=null&&t.offscreenCanvas?this.fullWorker.postMessage(e,[t.offscreenCanvas.bgCanvas,t.offscreenCanvas.localCanvas,t.offscreenCanvas.serviceCanvas]):this.fullWorker.postMessage(e);return}else if(this.subWorker){this.fullWorker.postMessage(e);const t=new Set;for(const i of e.values()){const o=i.msgType;(o===Y.Init||o===Y.Clear||o===Y.Destroy||o===Y.UpdateCamera||o===Y.Console||i.isRunSubWork)&&t.add(i)}t.size&&this.subWorker.postMessage(t)}}post(e){if(this.control.isUseBackgroundThread){if(!this.backgroundThreadManager){let i=[];i=x.cloneDeep([...e]),setTimeout(()=>{for(const o of i)this.taskBatchData.add(o)},0);return}const t=new Set;for(const i of e.values()){const o=i.msgType;(o===Y.Init||o===Y.Clear||o===Y.Destroy||o===Y.Console||i.isRunBackgroundThread)&&t.add(i)}t.size&&this.backgroundThreadManager.consume(t)}if(!this.control.hasOffscreenCanvas){if(!this.mainThread){let t=[];t=x.cloneDeep([...e]),setTimeout(()=>{for(const i of t)this.taskBatchData.add(i)},0);return}this.postMainThread(e);return}this.postWebWorker(e)}updateNode(e,t,i,o){this.taskBatchData.add({msgType:Y.UpdateNode,workId:e,updateNodeOpt:t,viewId:i,scenePath:o,dataType:X.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:Y.UpdateDpr,dataType:X.Local,viewId:e}).forEach(i=>{this.taskBatchData.delete(i)}),this.taskBatchData.add({dataType:X.Local,msgType:Y.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:Y.UpdateCamera,dataType:X.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;this.useTasksClockId=void 0,this.mainTasksqueueCount===this.workerTasksqueueCount?(this.tasksqueue.size&&this.consume(),this.useTasksqueue=!1,this.mainTasksqueueCount=void 0,this.workerTasksqueueCount=void 0,(e=this.methodBuilder)==null||e.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:Y.TasksQueue,dataType:X.Local,isRunSubWork:!0,isRunBackgroundThread:this.control.isUseBackgroundThread,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 s,a;const o=this.viewContainerManager.getCurScenePath(e);if(i){const c=(s=this.collector)==null?void 0:s.uid;if(c&&!this.control.renderControl.isClearAble({uid:c,viewId:e,scenePath:o}))return}this.control.textEditorManager.clear(e,t),this.queryTaskBatchData({msgType:Y.Clear,dataType:X.Local,viewId:e}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add({dataType:X.Local,msgType:Y.Clear,viewId:e}),this.runAnimation(),t||(this.control.renderControl.isUsePageAuth(e)&&o?this.control.renderControl.clearRenderPage(e,o):(a=this.collector)==null||a.dispatch({type:Y.Clear,viewId:e,scenePath:o})),this.zIndexNodeMethod&&this.zIndexNodeMethod.clearZIndex(e);for(const[c,l]of this.localPointsBatchData.entries())l.viewId===e&&this.localPointsBatchData.delete(c);await new Promise(c=>{const l=this.clearAllResolveMap.get(e)||{resolve:void 0,timer:void 0};l.timer&&clearTimeout(l.timer),l.resolve=c,l.timer=setTimeout(()=>{const 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 re([W.CopyNode,W.SetColorNode,W.DeleteNode,W.RotateNode,W.ScaleNode,W.TranslateNode,W.ZIndexNode,W.SetFontStyle,W.SetPoint,W.SetLock,W.SetShapeOpt]).registerForMainEngine(_.MainEngine,this.control),this.zIndexNodeMethod=(e=this.methodBuilder)==null?void 0:e.getBuilder(W.ZIndexNode)}setZIndex(e){const t=this.currentToolsData&&x.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,s,a;let t=!1;const i=[];for(const[c,{state:l,viewId:h,points:u,opt:f}]of this.localPointsBatchData.entries())if(e===h&&l===j.Start||l===j.Doing){if(l===j.Doing&&this.isCanDrawWork){Number(c)&&Number(c)+60>this.now&&(i.push(c.toString()),this.taskBatchData.add({msgType:Y.RemoveNode,workId:c,viewId:h,dataType:X.Local,isRunSubWork:!0}));const p=u.map(g=>g);this.taskBatchData.add({op:p,workState:j.Done,workId:c,dataType:X.Local,msgType:Y.DrawWork,isRunSubWork:this.isRunSubWork,toolsType:(o=this.currentToolsData)==null?void 0:o.toolsType,viewId:h,opt:f,scenePath:h&&this.viewContainerManager.getCurScenePath(h)}),t=!0}this.deleteLocalPoint(c)}if((t||i.length)&&(this.consume(),i.length)){const c=(s=this.viewContainerManager.getView(e))==null?void 0:s.focusScenePath;(a=this.collector)==null||a.dispatch({type:Y.RemoveNode,removeIds:i,viewId:e,scenePath:c})}}removeDrawingWork(e){var i,o;const t=[];for(const[s,{state:a,viewId:c}]of this.localPointsBatchData.entries())(e===c&&a===j.Start||a===j.Doing)&&(this.deleteLocalPoint(s),a===j.Doing&&this.isCanDrawWork&&(t.push(s.toString()),this.taskBatchData.add({msgType:Y.RemoveNode,workId:s,viewId:c,dataType:X.Local,isRunSubWork:!0})));if(t.length){this.consume();const s=(i=this.viewContainerManager.getView(e))==null?void 0:i.focusScenePath;(o=this.collector)==null||o.dispatch({type:Y.RemoveNode,removeIds:t,viewId:e,scenePath:s})}}removeNodes(e,t){var o,s;const i=(o=this.viewContainerManager.getView(e))==null?void 0:o.focusScenePath;if(i&&t.length){for(const a of t)this.taskBatchData.add({msgType:Y.RemoveNode,workId:a,viewId:e,dataType:X.Local,isRunSubWork:!1});this.consume(),(s=this.collector)==null||s.dispatch({type:Y.RemoveNode,removeIds:t,viewId:e,scenePath:i})}}hoverCursor(e,t){var i;if(((i=this.currentToolsData)==null?void 0:i.toolsType)===T.Selector&&!this.isBusy){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:f}=c;if(Or(e,{x:l,y:h,w:u,h:f}))return}}const s=this.viewContainerManager.transformToScenePoint(e,t),a={msgType:Y.CursorHover,dataType:X.Local,point:s,toolsType:this.currentToolsData.toolsType,opt:this.currentToolsData.toolsOpt,isRunSubWork:!1,viewId:t};this.queryTaskBatchData({msgType:Y.CursorHover,dataType:X.Local,toolsType:this.currentToolsData.toolsType,viewId:t}).forEach(c=>{this.taskBatchData.delete(c)}),this.taskBatchData.add(a),this.runAnimation()}}blurCursor(e){var i;if(((i=this.currentToolsData)==null?void 0:i.toolsType)!==T.Selector)return;const t={msgType:Y.CursorBlur,dataType:X.Local,isRunSubWork:!1,viewId:e};this.queryTaskBatchData({msgType:Y.CursorHover,dataType:X.Local,viewId:e}).forEach(o=>{this.taskBatchData.delete(o)}),this.taskBatchData.add(t),this.consume()}sendCursorEvent(e,t){var c,l,h;if(!this.currentLocalWorkData||this.currentLocalWorkData.workState===j.Unwritable||this.isBusy)return;const i=(c=this.currentToolsData)==null?void 0:c.toolsType;if(!this.useTasksqueue&&this.workState===j.Pending&&i===T.Selector&&(x.isNumber(e[0])&&x.isNumber(e[1])?this.hoverCursor(e,t):e[0]===void 0&&e[1]===void 0&&this.blurCursor(t)),!this.currentToolsData||!this.isCanSentCursor||!this.control.pluginOptions.extras.cursor.enable)return;const o=(l=this.collector)==null?void 0:l.uid,s=this.viewContainerManager.getCurScenePath(t);switch((h=this.currentToolsData)==null?void 0:h.toolsType){case T.Eraser:case T.PencilEraser:case T.BitMapEraser:{if(o&&!this.control.renderControl.isClearAble({uid:o,viewId:t,filterLocalSelf:!1,scenePath:s}))return;break}default:if(o&&!this.control.renderControl.isWritable||o&&!this.control.renderControl.isRenderAble({uid:o,viewId:t,filterLocalSelf:!1,scenePath:s}))return;break}let a=[void 0,void 0];this.currentToolsData&&this.isCanSentCursor&&!this.localPointsBatchData.size&&!this.getLockSentEventCursor()&&(a=e,this.control.cursor.sendEvent(a,t))}getBoundingRect(e){var i,o;if(!((i=this.boundingRectMap)==null?void 0:i.get(e))){const s=(o=this.collector)==null?void 0:o.getScenePathData(e);if(!s)return;if(Object.keys(s).forEach(a=>{var c;((c=this.collector)==null?void 0:c.getLocalId(a))===Z&&delete s[a]}),Object.keys(s).length&&this.viewContainerManager.mainView&&this.viewContainerManager.mainView.cameraOpt){const a={msgType:Y.BoundingBox,dataType:X.Local,scenePath:e,scenes:s,cameraOpt:{...this.viewContainerManager.mainView.cameraOpt},isRunSubWork:!0,viewId:this.viewContainerManager.mainView.id};return this.taskBatchData.add(a),this.runAnimation(),new Promise(c=>{this.boundingRectMap.set(e,c)}).then(c=>(this.boundingRectMap.delete(e),c))}}}getSnapshot(e,t,i,o){var a,c,l,h,u;if(!((a=this.snapshotMap)==null?void 0:a.get(e))){const f=(c=this.collector)==null?void 0:c.getViewIdBySecenPath(e);if(!f)return;const p=(l=this.collector)==null?void 0:l.getStorageData(f,e);if(!p)return;if(Object.keys(p).forEach(g=>{var m;((m=this.collector)==null?void 0:m.getLocalId(g))===Z&&delete p[g]}),Object.keys(p).length){const g=this.viewContainerManager.mainView;if(!g)return;const m=t||((h=g.cameraOpt)==null?void 0:h.width),w=i||((u=g.cameraOpt)==null?void 0:u.height),y={msgType:Y.Snapshot,dataType:X.Local,scenePath:e,scenes:p,w:m,h:w,cameraOpt:o&&{...o,width:m,height:w}||g.cameraOpt,isRunSubWork:!0,isRunBackgroundThread:this.control.isUseBackgroundThread,viewId:f};return this.taskBatchData.add(y),this.runAnimation(),new Promise(M=>{this.snapshotMap.set(e,{resolve:M,value:this.control.isUseBackgroundThread?[void 0,void 0]:[void 0]})}).then(M=>(this.snapshotMap.delete(e),M.reverse()))}}}queryTaskBatchData(e){const t=[];if(e)for(const i of this.taskBatchData.values()){let o=!0;for(const[s,a]of Object.entries(e))if(i[s]!==a){o=!1;break}o&&t.push(i)}return t}insertIconify(e,t){var a;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=(a=this.currentLocalWorkData.toolsOpt)==null?void 0:a.strokeColor);const s=i==null?void 0:i.focusScenePath;if(e&&s){const c=this.now;we.InternalMsgEmitter.emit("addUndoTicker",c,e);const l={...t,type:Wt.Iconify};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:Y.FullWork,dataType:X.Local,toolsType:T.Image,workId:t.uuid,opt:l,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:c}),this.runAnimation()}}insertBackgroundSVG(e,t){if(!this.control.isUseBackgroundThread)throw new Error("useBackgroundThread of pluginOptions should be true");const i=this.viewContainerManager.getView(e);if(!i)throw new Error("insertBackgroundSVG viewId is not exist");if(!t.src)throw new Error("src must be required");if(t.src&&!/^(http|https):\/\//.test(t.src))throw new Error("iconify src must be http or https");const o=i==null?void 0:i.focusScenePath;if(e&&o){const s=this.now;we.InternalMsgEmitter.emit("addUndoTicker",s,e);const a={...t,type:Vt.url};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayerForBackgroundSVG(e),a.zIndex=this.zIndexNodeMethod.getMaxZIndexForBackgroundSVG(e)),this.taskBatchData.add({msgType:Y.FullWork,dataType:X.Local,toolsType:T.BackgroundSVG,workId:t.uuid,opt:a,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:s,isRunBackgroundThread:!0}),this.runAnimation()}}async insertBackgroundMarkMap(e,t){var s;if(!this.control.isUseBackgroundThread)throw new Error("useBackgroundThread of pluginOptions should be true");const i=this.viewContainerManager.getView(e);if(!i)throw new Error("instertBackgroundMarkMap viewId is not exist");if(!t.data)throw new Error("data must be required");if(t.data&&!cp(t.data))throw new Error("data must be markdown string");const o=i==null?void 0:i.focusScenePath;if(e&&o){const a=t.uuid.toString();if((s=this.collector)!=null&&s.hasId(e,o,a))throw new Error("instertBackgroundMarkMap svgInfo.uuid is already exist");if(this.markmapIdResolveMap.has(a))throw new Error("instertBackgroundMarkMap svgInfo.uuid is already resolving");const c=this.now;we.InternalMsgEmitter.emit("addUndoTicker",c,e);const l={...t,type:Vt.markmap};return this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayerForBackgroundSVG(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndexForBackgroundSVG(e)),this.taskBatchData.add({msgType:Y.FullWork,dataType:X.Local,toolsType:T.BackgroundSVG,workId:a,opt:l,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:c,isRunBackgroundThread:!0}),this.runAnimation(),new Promise((h,u)=>{this.markmapIdResolveMap.set(a,{resolve:h,timer:setTimeout(()=>{const f=this.markmapIdResolveMap.get(a);f!=null&&f.timer&&(f.timer=void 0),u(a)},this.control.pluginOptions.extras.markmap.timeout)})}).then(h=>{if(h)return this.markmapIdResolveMap.delete(h),h}).catch(h=>{throw this.markmapIdResolveMap.delete(h),new Error(`instertBackgroundMarkMap svgInfo.uuid ${h} insert timeout`)})}}async updateBackgroundMarkMap(e,t,i){var l;const o=this.viewContainerManager.getView(e);if(!o)throw new Error("updateBackgroundMarkMap viewId is not exist");const s=o==null?void 0:o.focusScenePath;if(!s)throw new Error("updateBackgroundMarkMap scenePath is not exist");if((l=this.collector)!=null&&l.hasId(e,s,t))throw new Error("instertBackgroundMarkMap svgInfo.uuid is already exist");if(this.markmapIdResolveMap.has(t))throw new Error("instertBackgroundMarkMap svgInfo.uuid is already resolving");const a=this.now;we.InternalMsgEmitter.emit("addUndoTicker",a,e);const c={...i,type:Vt.markmap};this.taskBatchData.add({msgType:Y.UpdateNode,dataType:X.Local,toolsType:T.BackgroundSVG,workId:t,opt:c,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:a,isRunBackgroundThread:!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:s,uuid:a}=t;if(a&&!s){this.tmpImageConfigMap.set(a,t);return}const c=this.now;we.InternalMsgEmitter.emit("addUndoTicker",c,e);const l={...t,type:Wt.Image};this.zIndexNodeMethod&&(this.zIndexNodeMethod.addMaxLayer(e),l.zIndex=this.zIndexNodeMethod.getMaxZIndex(e)),this.taskBatchData.add({msgType:Y.FullWork,dataType:X.Local,toolsType:T.Image,workId:t.uuid,opt:l,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:c}),this.runAnimation()}}lockImage(e,t,i){var a,c;const o=this.viewContainerManager.getView(e);if(!o)throw new Error("insertImage viewId is not exist");const s=o==null?void 0:o.focusScenePath;if(e&&s&&this.collector){const l=this.collector.getStorageData(e,s);if(!l)return;for(const[h,u]of Object.entries(l))if(u&&u.toolsType===T.Image&&u.opt.uuid===t){const f=this.now;we.InternalMsgEmitter.emit("addUndoTicker",f,e);const p=(a=this.collector)!=null&&a.isOwn(h)?(c=this.collector)==null?void 0:c.getLocalId(h):h,g={...u.opt,locked:i,type:Wt.Image};this.taskBatchData.add({msgType:Y.FullWork,dataType:X.Local,toolsType:T.Image,workId:p,opt:g,viewId:e,willRefresh:!0,willSyncService:!0,needUndoTicker:f}),this.runAnimation();return}}}completeImageUpload(e,t,i){const o=this.viewContainerManager.getView(e);if(!o)throw new Error("insertImage viewId is not exist");const s=o==null?void 0:o.focusScenePath;if(e&&s){const a=this.tmpImageConfigMap.get(t);a&&(a.src=i,this.insertImage(e,a),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===T.Image){const s=o.opt;t.push({uuid:s.uuid,centerX:s.centerX,centerY:s.centerY,width:s.width,height:s.height,locked:s.locked,uniformScale:s.uniformScale,crossOrigin:s.crossOrigin})}}return t}setShapeSelectorByWorkId(e,t){this.taskBatchData.add({workId:Z,selectIds:[e],msgType:Y.Select,dataType:X.Local,viewId:t,willSyncService:!0}),this.runAnimation()}blurSelector(e,t,i){this.taskBatchData.add({workId:i||Z,selectIds:[],msgType:Y.Select,dataType:X.Service,viewId:e,scenePath:t}),this.runAnimation()}consoleWorkerInfo(){this.taskBatchData.add({msgType:Y.Console,dataType:X.Local,isRunSubWork:!0,viewId:""}),this.consume()}sendClearUids(e,t){var o,s;const i=new Set;i.add({msgType:Y.AuthClear,dataType:X.Local,viewId:e,clearUids:t,localUid:(o=this.collector)==null?void 0:o.uid}),this.control.hasOffscreenCanvas?this.fullWorker.postMessage(i):(s=this.mainThread)==null||s.consume(i)}async getVNodeInfo(e,t,i){if(!this.getVNodeInfoResolveMap.has(e))return this.taskBatchData.add({msgType:Y.GetVNodeInfo,dataType:X.Local,isRunSubWork:!0,viewId:t,workIds:i,workId:e}),this.consume(),await new Promise(o=>{const s=this.getVNodeInfoResolveMap.get(e)||{resolve:void 0,timer:void 0};s.timer&&clearTimeout(s.timer),s.resolve=o,s.timer=setTimeout(()=>{const a=this.getVNodeInfoResolveMap.get(e);a!=null&&a.resolve&&a.resolve({uuid:e})},this.maxLastSyncTime*5),this.getVNodeInfoResolveMap.set(e,s)}).then(o=>{const{uuid:s}=o;return this.getVNodeInfoResolveMap.delete(s),o})}}class My{constructor(n){I(this,"internalMsgEmitter");I(this,"control");I(this,"roomHotkeyCheckers");I(this,"tmpCopyStore",new Map);I(this,"tmpCopyCoordInfo");var i;const{control:e,internalMsgEmitter:t}=n;this.control=e,this.internalMsgEmitter=t,this.roomHotkeyCheckers=((i=this.control.room)==null?void 0:i.viewsParams.hotKeys.nodes)||[]}get isUseSelf(){var n,e;return((e=(n=this.control)==null?void 0:n.room)==null?void 0:e.disableDeviceInputs)||!1}get isSelector(){var n;return((n=this.control.worker.currentToolsData)==null?void 0:n.toolsType)===T.Selector}get collector(){return this.control.collector}get mainEngine(){return this.control.worker}get keyboardKind(){return/^Mac/i.test(navigator.platform)?"mac":"windows"}getEventKey(n){switch(n.type){case"keydown":return"KeyDown"}return"KeyUp"}onActiveHotkey(n){var i,o,s;const e=this.control.viewContainerManager.focuedViewId,t=(i=this.control.viewContainerManager.focuedView)==null?void 0:i.focusScenePath;if(e&&t)switch(n){case"delete":this.isSelector&&((o=this.collector)!=null&&o.hasSelector(e,t))&&re.emitMethod(_.MainEngine,W.DeleteNode,{workIds:[Z],viewId:e});break;case"copy":this.isSelector&&((s=this.collector)!=null&&s.hasSelector(e,t))&&this.copySelectorToTemp(e,t);break;case"paste":this.tmpCopyStore.size&&this.pasteTempToFocusView(e,t);break}(n==="changeToPencil"||n==="redo"||n==="undo")&&this.onSelfActiveHotkey(n)}colloctHotkey(n){if(this.isUseSelf){const e=this.checkHotkey(n);e&&this.onSelfActiveHotkey(e)}}onSelfActiveHotkey(n){switch(n){case"changeToPencil":this.setMemberState({currentApplianceName:te.pencil,useNewPencil:!0});break;case"changeToArrow":this.setMemberState({currentApplianceName:te.arrow});break;case"changeToClick":this.setMemberState({currentApplianceName:te.clicker});break;case"changeToEllipse":this.setMemberState({currentApplianceName:te.ellipse});break;case"changeToEraser":this.setMemberState({currentApplianceName:te.eraser});break;case"changeToHand":this.setMemberState({currentApplianceName:te.hand});break;case"changeToLaserPointer":this.setMemberState({currentApplianceName:te.laserPointer});break;case"changeToSelector":this.setMemberState({currentApplianceName:te.selector});break;case"changeToRectangle":this.setMemberState({currentApplianceName:te.rectangle});break;case"changeToStraight":this.setMemberState({currentApplianceName:te.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:te.text});break;case"changeToPencilEraser":this.setMemberState({currentApplianceName:te.pencilEraser});break;case"delete":case"copy":case"paste":this.onActiveHotkey(n);break}}checkHotkey(n){for(const e of this.roomHotkeyCheckers){const{kind:t,checker:i}=e;if(i({nativeEvent:n,kind:this.getEventKey(n),key:n.key,altKey:n.altKey,ctrlKey:n.ctrlKey,shiftKey:n.shiftKey},this.keyboardKind))return t}}copySelectorToTemp(n,e){var l,h;const t=this.control.viewContainerManager.getView(n),i=(h=(l=this.mainEngine)==null?void 0:l.methodBuilder)==null?void 0:h.getBuilder(W.CopyNode);if(!t||!this.collector||!i)return;const o=this.collector.transformKey(Z),s=this.collector.getStorageData(n,e);if(!s)return;const a=s[o],c=a&&i.copySelector({viewId:n,store:a});c&&(this.tmpCopyCoordInfo=c==null?void 0:c.copyCoordInfo,this.tmpCopyStore=c==null?void 0:c.copyStores)}pasteTempToFocusView(n,e){var o,s;const t=this.control.viewContainerManager.getView(n),i=(s=(o=this.mainEngine)==null?void 0:o.methodBuilder)==null?void 0:s.getBuilder(W.CopyNode);if(!(!t||!this.tmpCopyCoordInfo||!this.tmpCopyStore.size||!this.collector||!i)&&t.viewData&&this.tmpCopyCoordInfo){const a=x.cloneDeep(this.tmpCopyCoordInfo.offset),c=this.tmpCopyCoordInfo.cameraOpt,l=t.viewData.camera;a.x=a.x+l.centerX-c.centerX,a.y=a.y+l.centerY-c.centerY;const h=this.control.worker.now;this.control.worker.internalMsgEmitter.emit("addUndoTicker",h,n),i.pasteSelector({viewId:n,scenePath:e,copyStores:x.cloneDeep(this.tmpCopyStore),copyCoordInfo:{offset:a,cameraOpt:l},undoTickerId:h})}}setMemberState(n){var e;(e=this.control.room)==null||e.setMemberState(n)}}class py{constructor(n){I(this,"control");I(this,"roomMemberManager");I(this,"worker");I(this,"publicMsgEmitter");I(this,"renderUids",new Map);I(this,"pageAuth",new Map);I(this,"isLocalRender",!1);I(this,"isCurWritable",!1);var i;const{control:e,publicMsgEmitter:t}=n;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}get isWritable(){return this.isCurWritable}onWritableChange(n){this.isCurWritable=n}addPage(n,e=!0){var l,h;const{viewId:t,render:i="localSelf",elementIds:o,pageId:s=(l=this.control.collector)==null?void 0:l.uid}=n,a=this.pageAuth.get(t)||new Map,c=this.control.viewContainerManager.getCurScenePath(t);if(c&&s){const u=a.get(c)||{render:"localSelf",pages:new Map};e&&(u.render=i);const f=o&&this.cloneElementIds(t,c,o,s)||new Set;u.pages.set(s,f),a.set(c,u),this.pageAuth.set(t,a),e&&this.pageAuthEffect(t),this.isLocalRender=!1,(h=this.control.collector)==null||h.dispatchPageAuth({operation:Ce.addPage,viewId:t,scenePath:c,pageId:s,pageData:{render:i,elementIds:f}},!0)}}delPage(n,e){var s,a;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(n))});if(!i)return;const o=t.get(i);if(o){const{render:c,pages:l}=o,h=c==="localSelf"?(s=this.control.collector)==null?void 0:s.uid:c,u=l.get(n);u!=null&&u.size&&this.delElementIds(e,i,u),l.delete(n),h===n&&this.pageAuthEffect(e)}(a=this.control.collector)==null||a.dispatchPageAuth({operation:Ce.deletePage,viewId:e,scenePath:i,pageId:n},!0)}delViewPage(n,e=!0){var i;this.pageAuth.get(n)&&(this.pageAuth.delete(n),e&&((i=this.control.collector)==null||i.dispatchPageAuth({operation:Ce.clearView,viewId:n},e)))}clearRenderPage(n,e,t=!0){var a,c;const i=this.pageAuth.get(n);if(!i)return;const o=i.get(e);let s;if(o){const{render:l,pages:h}=o,u=l==="localSelf"?(a=this.control.collector)==null?void 0:a.uid:l;if(u){if(t){const f=h.get(u);f&&this.delElementIds(n,e,f)}h.set(u,new Set),s=u}}t&&s&&((c=this.control.collector)==null||c.dispatchPageAuth({operation:Ce.clearPage,viewId:n,scenePath:e,pageId:s},t))}hasPage(n,e,t){const i=this.pageAuth.get(e);if(!i)return!1;const o=i.get(t);return o?o.pages.has(n):!1}getPageInfo(n,e,t){const i=this.pageAuth.get(e);if(!i)return;const o=i.get(t);if(o)return o.pages.get(n)}addRenderPageElementId(n,e=!0,t=!1){var h,u;const{viewId:i,elementId:o,scenePath:s}=n,a=this.pageAuth.get(i);if(!a)throw new Error(`no view info in viewId: ${i}`);const c=a.get(s);let l;if(c){const{render:f,pages:p}=c,g=f==="localSelf"?(h=this.control.collector)==null?void 0:h.uid:f;if(g&&p.has(g)){const m=p.get(g)||new Set;m.add(o),p.set(g,m),l=g}}t&&this.pageAuthEffect(i),e&&l&&((u=this.control.collector)==null||u.dispatchPageAuth({operation:Ce.addElement,viewId:i,scenePath:s,pageId:l,pageData:{elementId:o}},e))}delRenderPageElementId(n,e=!0,t=!1){var h,u;const{viewId:i,elementId:o,scenePath:s}=n,a=this.pageAuth.get(i);if(!a)throw new Error(`no view info in viewId: ${i}`);const c=a.get(s);let l;if(c){const{render:f,pages:p}=c,g=f==="localSelf"?(h=this.control.collector)==null?void 0:h.uid:f;if(g&&p.has(g)){const m=p.get(g);m&&(m.delete(o),p.set(g,m),l=g)}}t&&this.pageAuthEffect(i),e&&l&&((u=this.control.collector)==null||u.dispatchPageAuth({operation:Ce.deleteElement,viewId:i,scenePath:s,pageId:l,pageData:{elementId:o}},e))}setPageRender(n,e,t,i=!0){var a;const o=this.pageAuth.get(n);if(!o)throw new Error(`no view info in viewId: ${n}`);const s=o.get(e);s&&(s.render=t),e===this.control.viewContainerManager.getCurScenePath(n)&&this.pageAuthEffect(n),i||(this.isLocalRender=!0),i&&(this.isLocalRender=!1,(a=this.control.collector)==null||a.dispatchPageAuth({operation:Ce.renderPage,viewId:n,scenePath:e,pageData:{render:t}},i))}isRenderAble(n){var c,l;const{uid:e,viewId:t,filterLocalSelf:i=!0,scenePath:o}=n,s=this.renderUids.get(t);if(s){const{render:h,hide:u}=s;if(h===void 0&&u===void 0)return!0;if(x.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||x.isSet(u)&&!u.has(e)&&!(i&&u.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===e)))return!0;return!1}const a=this.pageAuth.get(t);if(a&&o){const h=a.get(o);if(h){const{render:u}=h;if(u)return!(u==="localSelf"&&!i)}}return!0}isClearAble(n){var c;const{uid:e,viewId:t,filterLocalSelf:i=!0,scenePath:o}=n,s=this.renderUids.get(t);if(s){const{clear:l}=s;return!!(l===void 0||l===!0||x.isSet(l)&&(l.has(e)||i&&((c=this.control.collector)==null?void 0:c.uid)===e&&l.has("localSelf")))}const a=this.pageAuth.get(t);if(a&&o){const l=a.get(o);if(l){const{render:h}=l;if(h)return!(h==="localSelf"&&!i)}}return!0}isFilterAble(n,e){var c,l,h,u;const{viewId:t,scenePath:i,elementId:o}=n,s=this.renderUids.get(t);if(s&&o){const{render:f,hide:p}=s;if(f===void 0&&p===void 0)return!0;const g=(c=this.control.collector)==null?void 0:c.getUidFromKey(o);return g?!!(x.isSet(f)&&(f.has(g)||f.has("localSelf")&&((l=this.control.collector)==null?void 0:l.uid)===g)||f===!0&&(!p||x.isSet(p)&&!p.has(g)&&!(p.has("localSelf")&&((h=this.control.collector)==null?void 0:h.uid)===g))):!1}const a=this.pageAuth.get(t);if(a&&i&&o){const f=a.get(i);if(f){const{render:p,pages:g}=f;if(!p)return!0;const m=(u=this.control.collector)==null?void 0:u.uid,w=p==="localSelf"?m:p,y=w&&g.get(w)||void 0;if(y)switch(e){case Y.RemoveNode:return!0;default:return y.has(o)}return!1}}return!0}isFilterCursor(n){if(this.isUsePageAuth(n)){const e=this.control.viewContainerManager.getCurScenePath(n),t=this.pageAuth.get(n);if(e&&t){const i=t.get(e);if(i){const{render:o}=i;return o!=="localSelf"}}}return!0}isUsePageAuth(n){var i;if(!this.pageAuth.has(n))return!1;const t=this.control.viewContainerManager.getCurScenePath(n);return t&&((i=this.pageAuth.get(n))==null?void 0:i.has(t))||!1}publishRender(n){var s;const{viewId:e,option:t,isSync:i=!0}=n,o={};if(t){const{render:a,hide:c,clear:l}=t;a&&(o.render=a===!0&&!0||new Set(a)),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&&((s=this.control.collector)==null||s.dispatchRenderAuth({operation:Ve.setAuth,viewId:e,renderData:o},i)),this.renderEffect(e)}publishOneRender(n,e,t,i=!0){var a;const o=this.renderUids.get(n);let s;switch(t){case"show":o?(o.render||(o.render=new Set),x.isSet(o.render)&&o.render.add(e),x.isSet(o.hide)&&o.hide.delete(e)):this.renderUids.set(n,{render:new Set([e])}),s=Ve.setShow;break;case"hide":o?(o.hide||(o.hide=new Set),x.isSet(o.hide)&&o.hide.add(e),x.isSet(o.render)&&o.render.delete(e)):this.renderUids.set(n,{hide:new Set([e])}),s=Ve.setHide;break}o?this.renderUids.set(n,o):this.renderUids.delete(n),i&&s&&((a=this.control.collector)==null||a.dispatchRenderAuth({operation:s,viewId:n,uid:e},i)),this.renderEffect(n)}publishOneClear(n,e,t,i=!0){var s;const o=this.renderUids.get(n);t?o?(o.clear||(o.clear=new Set),x.isSet(o.clear)&&o.clear.add(e)):this.renderUids.set(n,{clear:new Set([e])}):o&&x.isSet(o.clear)&&o.clear.has(e)&&o.clear.delete(e),o?this.renderUids.set(n,o):this.renderUids.delete(n),i&&((s=this.control.collector)==null||s.dispatchRenderAuth({operation:Ve.setClear,viewId:n,uid:e,isClear:t},i)),this.renderEffect(n)}syncRenderUids(n,e,t,i){const o=e===!0?!0:e&&Object.keys(e)?new Set(Object.keys(e)):void 0,s=t===!0?!0:t&&Object.keys(t)?new Set(Object.keys(t)):void 0,a=i===!0?!0:i&&Object.keys(i)?new Set(Object.keys(i)):void 0;o||s||a?this.renderUids.set(n,{render:o,hide:s,clear:a}):this.renderUids.delete(n),this.renderEffect(n),this.publicMsgEmitter.emit("syncRenderUids",n,{render:o,hide:s,clear:a})}syncPageAuth(n,e,t=!1){let i=!1;if(!e)this.pageAuth.delete(n);else{const o=this.pageAuth.get(n)||new Map;for(const[s,a]of Object.entries(e)){const{render:c,pages:l}=a,h=o.get(s),u=this.isLocalRender?h==null?void 0:h.render:c;if(u){u!==(h==null?void 0:h.render)&&(i=!0);const f=new Map;for(const[g,m]of Object.entries(l))f.set(g,new Set(Object.keys(m)));const p={render:u,pages:f};f.size&&o.set(s,p)}}o.size&&(this.pageAuth.set(n,o),this.publicMsgEmitter.emit("syncPageAuth",n,o))}(t||i)&&this.pageAuthEffect(n)}destoryByViewId(n,e=!1){var t;this.renderUids.has(n)&&(this.renderUids.delete(n),e||(t=this.control.collector)==null||t.dispatchRenderAuth({operation:Ve.setAuth,viewId:n})),this.pageAuth.has(n)&&this.control.renderControl.delViewPage(n,!e)}renderEffect(n){var t;const e=(t=this.control.viewContainerManager.getView(n))==null?void 0:t.focusScenePath;e&&this.worker.clearViewScenePath(n,!0).then(()=>{var i;this.worker.pullServiceData(n,e,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(n,(i=this.renderUids.get(n))==null?void 0:i.clear)})}pageAuthEffect(n){var t;const e=(t=this.control.viewContainerManager.getView(n))==null?void 0:t.focusScenePath;e&&this.worker.clearViewScenePath(n,!0).then(()=>{this.worker.pullServiceData(n,e,{isAsync:!0,useAnimation:!1}),this.worker.sendClearUids(n,!0)})}cloneElementIds(n,e,t,i){var a,c;const o=(a=this.control.collector)==null?void 0:a.getStorageData(n,e),s=new Set;if(o){for(const l of Object.keys(o))if(t.has(l)){const h=`${l}_${i}`;if(s.add(h),!Object.keys(o).includes(h)){const u=x.cloneDeep(o[l]);(c=this.control.collector)==null||c.updateValue(h,{type:Y.FullWork,...u,workId:h},{isSync:!0,viewId:n,scenePath:e})}}}return s}delElementIds(n,e,t){var o,s;const i=(o=this.control.collector)==null?void 0:o.getStorageData(n,e);if(i)for(const a of Object.keys(i))t.has(a)&&Object.keys(i).includes(a)&&((s=this.control.collector)==null||s.updateValue(a,void 0,{isSync:!0,viewId:n,scenePath:e}))}}class yy{constructor(n){I(this,"internalMsgEmitter");I(this,"control");I(this,"maps",new Map);I(this,"showId");I(this,"color");I(this,"timer");I(this,"updateMiniMapCamera",x.debounce(async n=>{const e=this.maps.get(n);if(e){const t=await this.getMiniMapCamera(n);if(t){const i=t.width/t.scale,o=t.height/t.scale,s=e.miniMapCamera.width/e.miniMapCamera.scale,a=e.miniMapCamera.height/e.miniMapCamera.scale;(i>=s||o>=a)&&(e.miniMapCamera=t);const c=e.miniMapCanvas.current;if(c){const l=c.getContext("2d");if(l){const h=this.control.viewContainerManager.getView(n);if(!(h!=null&&h.focusScenePath))return;const{miniMapCamera:u,contianer:f}=e,{width:p,height:g}=f.getBoundingClientRect(),m=Math.min(p/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*m}px`,c.style.height=`${u.height*m}px`,await this.control.screenshotToCanvas(l,h.focusScenePath,u.width,u.height,u),this.listener.emitAsync([n,"viewCameraUpate"],1)}}}}},2e3,{maxWait:5e3}));var i;const{control:e,internalMsgEmitter:t}=n;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(n){this.color=n}async createMiniMap(n,e,t){const i=this.control.viewContainerManager.getView(n);if(!i)throw new Error("view not found");const o=i.cameraOpt;if(!o)throw new Error("view camera not found");const{width:s,height:a}=e.getBoundingClientRect();if(!s||!a)throw new Error("contianer width or height is 0");const c=d.createRef();this.maps.set(n,{contianer:e,miniMapCanvas:c,miniMapCamera:t,viewCamera:o}),this.showId=n,this.control.viewContainerManager.setActiveMiniMap(this.showId,!0);const l=Math.min(s/t.width,a/t.height),h=await new Promise(u=>{this.listener.once([n,"miniMapCreate"],()=>{const f=c.current;f&&(f.width=t.width,f.height=t.height,f.style.width=`${t.width*l}px`,f.style.height=`${t.height*l}px`),u(!0)}),this.timer=setTimeout(()=>{u(!1)},2e3)});return this.timer&&clearTimeout(this.timer),h}async getMiniMapCamera(n){const e=this.control.viewContainerManager.getView(n);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 s=await this.control.getBoundingRect(i)||o;s=oi(s,o)||o;let a=s.width,c=s.height,l=1;const h=a>t.width&&Math.min(t.width/a,l)||l,u=c>t.height&&Math.min(t.height/c,l)||l;return h<=u?(a=h<1&&t.width||a,c=Math.floor(c*h)+1,l=h):h>u&&(c=u<1&&t.height||c,a=Math.floor(a*u)+1,l=u),{scale:l,centerX:s.originX+s.width/2,centerY:s.originY+s.height/2,width:a,height:c}}getMiniMapCanvas(n){const e=this.maps.get(n);return(e==null?void 0:e.miniMapCanvas.current)||null}updateViewCamera(n,e){const t=this.maps.get(n);t&&(t.viewCamera=e,this.listener.emitAsync([n,"viewCameraUpate"],1))}destroyMiniMap(n){const e=n||this.showId;e&&(this.maps.delete(e),this.control.viewContainerManager.setActiveMiniMap(e,!1))}}class my{constructor(){I(this,"control");I(this,"_listeners",{})}_inject(n){this.control=n}_onEvent(n,e){this._listeners[n]&&this._listeners[n](...e)}callbacks(n,e){this._listeners[n]=e}removeCallback(n){delete this._listeners[n]}}class Iy{constructor(n){I(this,"control");I(this,"worker");I(this,"publicMsgEmitter");I(this,"plugins",new Map);const{control:e,publicMsgEmitter:t}=n;this.control=e,this.publicMsgEmitter=t,this.worker=e.worker}use(n){this.plugins.set(n.kind,n),n._inject(this.control),n.onCreate()}destroy(){this.plugins.forEach(n=>{this.plugins.delete(n.kind),n.onDestroy()})}dispatchPluginEvent(n,...e){this.plugins.forEach(t=>{t._onEvent(n,e)})}}function wy(r){return r instanceof TouchEvent||r instanceof window.TouchEvent||(r==null?void 0:r.touches)&&(r==null?void 0:r.touches.length)||(r==null?void 0:r.changedTouches)&&(r==null?void 0:r.changedTouches.length)}function qt(r){return wy(r)&&(r.touches&&r.touches.length===1||r.changedTouches&&r.changedTouches.length===1)}function Wr(r){return r.touches&&r.touches.length?{x:r.touches[0].pageX,y:r.touches[0].pageY}:r.changedTouches&&r.changedTouches.length?{x:r.changedTouches[0].pageX,y:r.changedTouches[0].pageY}:{x:r.pageX,y:r.pageY}}class Ty{constructor(n){I(this,"_logger");this._logger=n}error(...n){this._logger?this._logger.error(...n):console.error(...n)}info(...n){this._logger?this._logger.info(...n):console.info(...n)}warn(...n){this._logger?this._logger.warn(...n):console.warn(...n)}}const ot=class ot{constructor(n){I(this,"version",Dr);I(this,"plugin");I(this,"logger");I(this,"room");I(this,"play");I(this,"collector");I(this,"hasSwitchToSelectorEffect");I(this,"snapshootStateMap");I(this,"_disableDeviceInputs");I(this,"_disableEraseImage");I(this,"_disableEraseText");I(this,"_disableCameraTransform");I(this,"_disableUseWorker",!1);I(this,"effectResolve");I(this,"hotkeyManager");I(this,"pluginOptions");I(this,"roomMember");I(this,"cursor");I(this,"textEditorManager");I(this,"worker");I(this,"renderControl");I(this,"miniMapManager");I(this,"pluginManager");I(this,"_isPolyfill",{requestIdleCallback:!1,cancelIdleCallback:!1});I(this,"onSceneChange",async(n,e)=>{var s;const t=this.viewContainerManager.getView(e);t!=null&&t.focusScenePath&&(s=this.collector)!=null&&s.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=n;o&&this.viewContainerManager.setViewScenePath(e,o),i==null||i.setActive(!0)});I(this,"onRoomMembersChange",n=>{this.roomMember.setRoomMembers(F.toJS(n))});I(this,"onMemberChange",x.throttle(n=>{var s,a;if(!this.room||!this.worker||!n||!this.room.isWritable)return;const e=this.getToolsKey(n),t=(s=this.worker.getCurrentToolsData())==null?void 0:s.toolsType,i=this.viewContainerManager.focuedViewId;i&&t===T.Selector&&e!==T.Selector&&this.worker.blurCursor(i);const o=this.getToolsOpt(e,n);this.worker.setCurrentToolsData(o),(a=this.pluginManager)==null||a.dispatchPluginEvent("setToolkey",e),this.effectViewContainer(e),this.effectResolve&&this.effectResolve(!0)},100,{leading:!1}));I(this,"internalSceneChange",(n,e)=>{var t,i,o,s;this.isUseSimple||((t=this.miniMapManager)==null?void 0:t.activeViewId)===n&&((i=this.miniMapManager)==null||i.destroyMiniMap(n)),(o=this.pluginManager)==null||o.dispatchPluginEvent("sceneChange",n,e),(s=this.worker)==null||s.clearViewScenePath(n,!0).then(()=>{var a;(a=this.worker)==null||a.pullServiceData(n,e,{isAsync:!0,useAnimation:!1})})});I(this,"internalCameraChange",(n,e)=>{var t,i;(t=this.worker)==null||t.updateCamera(n,e),this.isUseSimple||(i=this.miniMapManager)==null||i.updateViewCamera(n,e)});var a,c;const{displayer:e,plugin:t,options:i}=n;this.plugin=t,this.room=F.isRoom(e)?e:void 0,this.play=F.isPlayer(e)?e:void 0;let o;this.room&&(o=(a=this.room)==null?void 0:a.logger,this._disableDeviceInputs=this.room.disableDeviceInputs,this._disableEraseImage=this.room.disableEraseImage,this._disableEraseText=!1),this.pluginOptions=i,((c=i.extras)==null?void 0:c.useWorker)==="mainThread"?this._disableUseWorker=!0:this._disableUseWorker=Ri!=="worker",this.roomMember=new up;const s={control:this,internalMsgEmitter:ot.InternalMsgEmitter,publicMsgEmitter:ot.PublicMsgEmitter};this.cursor=new hp(s),this.textEditorManager=new lf(s),this.worker=new fy(s),this.hotkeyManager=new My(s),this.renderControl=new py(s),this.pluginManager=new Iy(s),this.isUseSimple||(this.miniMapManager=new yy(s)),this.logger=new Ty(o)}hasPolyfillMethod(n){return this._isPolyfill[n]}registerPolyfillMethod(n){this._isPolyfill[n]=!0}get hasExtendFontFaces(){return this.extendFontFaces.length>0}get extendFontFaces(){var n;return((n=this.pluginOptions.extras.textEditor)==null?void 0:n.extendFontFaces)??me.textEditor.extendFontFaces}get loadFontFacesTimeout(){var n;return((n=this.pluginOptions.extras.textEditor)==null?void 0:n.loadFontFacesTimeout)??me.textEditor.loadFontFacesTimeout}get disableEraseText(){return this._disableEraseText||!1}set disableEraseText(n){this._disableEraseText=n}get disableEraseImage(){return this._disableEraseImage||!1}set disableEraseImage(n){this._disableEraseImage=n}get disableDeviceInputs(){return this._disableDeviceInputs||!1}set disableDeviceInputs(n){var t;this._disableDeviceInputs=n;const e=(t=this.worker.getCurrentToolsData())==null?void 0:t.toolsType;e&&this.effectViewContainer(e)}get disableCameraTransform(){return this._disableCameraTransform||!1}set disableCameraTransform(n){this._disableCameraTransform=n}get disableUseWorker(){return this._disableUseWorker||!1}set disableUseWorker(n){this._disableUseWorker=n}get hasOffscreenCanvas(){return this._disableUseWorker?!1:Ri==="worker"}get canUseTransferControlToOffscreen(){return this._disableUseWorker?!1:!!HTMLCanvasElement.prototype.transferControlToOffscreen}get isUseOffscreenTransfer(){return this.isUseSimple&&this.hasOffscreenCanvas&&this.canUseTransferControlToOffscreen}get isUseSimple(){return this.pluginOptions.extras.useSimple}get isUseBackgroundThread(){return this.pluginOptions.extras.useBackgroundThread}bindPlugin(n){this.plugin=n,this.collector&&(this.collector.removeStorageStateListener(),this.collector.removeAuthStateListener()),this.collector=new zn(this,n,this.pluginOptions.extras.syncOpt.interval),this.activePlugin()}destroy(){var n,e,t,i,o,s,a;this.roomMember.destroy(),(n=this.collector)==null||n.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(),(s=this.pluginManager)==null||s.destroy(),(a=this.miniMapManager)==null||a.destroyMiniMap()}cleanCurrentScene(){const n=this.worker.now,e=this.worker.getLocalWorkViewId()||this.viewContainerManager.focuedViewId;e&&(ot.InternalMsgEmitter.emit("addUndoTicker",n,e),this.worker.clearViewScenePath(e,!1,!0).then(()=>{ot.InternalMsgEmitter.emit("forceUndoTickerEnd",n,e)}))}async setWritable(n){var e,t;if(!n){(e=this.cursor)==null||e.unabled(),this.textEditorManager.checkEmptyTextBlur();const i=this.viewContainerManager.getAllViews();for(const o of i){o!=null&&o.focusScenePath&&(t=this.collector)!=null&&t.hasSelector(o.id,o.focusScenePath)&&this.worker.blurSelector(o.id,o.focusScenePath);const s=o==null?void 0:o.displayer;s&&(s.setActive(!1),await s.stopEventHandler())}}await new Promise(i=>{setTimeout(()=>{i()},500)})}onWritableChange(n){var i;n?this.worker.abled():this.worker.unWritable(),((i=this.worker.getCurrentToolsData())==null?void 0:i.toolsType)===T.Text&&this.viewContainerManager.focuedViewId&&(n?this.viewContainerManager.activeTextEditor(this.viewContainerManager.focuedViewId):this.viewContainerManager.unActiveTextEditor(this.viewContainerManager.focuedViewId)),this.renderControl.onWritableChange(n),this.viewContainerManager.getAllViews().forEach(o=>{const s=o==null?void 0:o.displayer;s&&(s.bindToolsClass(),n?s.setActive(!0):s.setActive(!1))})}getToolsKey(n){const e=n.currentApplianceName;switch(this.hasSwitchToSelectorEffect=!1,e){case te.text:return n.textCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),T.Text;case te.pencil:return n.useLaserPen?T.LaserPen:T.Pencil;case te.eraser:return T.Eraser;case te.pencilEraser:return this.pluginOptions.extras.pencilEraser.useBitMap===!1?T.PencilEraser:T.BitMapEraser;case te.selector:return T.Selector;case te.arrow:return n.arrowCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),T.Arrow;case te.straight:return n.straightCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),T.Straight;case te.ellipse:return n.ellipseCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),T.Ellipse;case te.rectangle:return n.rectangleCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),T.Rectangle;case te.shape:if(n.shapeCompleteToSelector&&(this.hasSwitchToSelectorEffect=!0),n.shapeType===Ye.Pentagram||n.shapeType===Ye.Star)return T.Star;if(n.shapeType===Ye.Polygon||n.shapeType===Ye.Triangle||n.shapeType===Ye.Rhombus)return T.Polygon;if(n.shapeType===Ye.SpeechBalloon)return T.SpeechBalloon;break}return T.Clicker}getToolsOpt(n,e){if(n===T.Clicker)return{toolsType:n,toolsOpt:{}};const t={strokeColor:Tt(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(n){case T.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)&&Tt(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)&&Tt(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 T.Pencil:{const i=(e==null?void 0:e.strokeType)||de.Normal;t.strokeType=i,t.autoShape=!!(e!=null&&e.autoShape),t.previewLocalOnly=!!(e!=null&&e.autoShape),t.lineCap=this.getLineCap(i),t.lineDash=this.getLineDash(i);break}case T.PencilEraser:case T.BitMapEraser:case T.Eraser:t.thickness=Math.min(4,Math.max(1,Math.floor(e.pencilEraserSize||1)))-1;break;case T.LaserPen:{t.duration=(e==null?void 0:e.duration)||1,e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===de.Stroke?t.strokeType=de.Normal:t.strokeType=(e==null?void 0:e.strokeType)||de.Normal;const i=t.strokeType;t.lineCap=this.getLineCap(i),t.lineDash=this.getLineDash(i);break}case T.Arrow:case T.Straight:{e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===de.Stroke?t.strokeType=de.Normal:t.strokeType=(e==null?void 0:e.strokeType)||de.Normal;const i=t.strokeType;t.strokeType=i,t.lineCap=this.getLineCap(i),t.lineDash=this.getLineDash(i);break}case T.Ellipse:case T.Rectangle:case T.Star:case T.Polygon:case T.SpeechBalloon:{e!=null&&e.strokeType&&(e==null?void 0:e.strokeType)===de.Stroke?t.strokeType=de.Normal:t.strokeType=(e==null?void 0:e.strokeType)||de.Normal;const i=t.strokeType;t.lineCap=this.getLineCap(i),t.lineDash=this.getLineDash(i),n===T.Star&&(e.shapeType===Ye.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)),n===T.Polygon&&(e.shapeType===Ye.Triangle?t.vertices=3:e.shapeType===Ye.Rhombus?t.vertices=4:e.vertices&&(t.vertices=e.vertices)),t.fillColor=(e==null?void 0:e.fillColor)&&Tt(e.fillColor[0],e.fillColor[1],e.fillColor[2],e==null?void 0:e.fillOpacity)||"transparent",n===T.SpeechBalloon&&(t.placement=e.placement||"bottomLeft");break}}return{toolsType:n,toolsOpt:t}}getLineCap(n){switch(n){case de.Normal:return this.pluginOptions.extras.normalStroke.lineCap||me.normalStroke.lineCap;case de.Dotted:return this.pluginOptions.extras.dottedStroke.lineCap||me.dottedStroke.lineCap;case de.LongDotted:return this.pluginOptions.extras.longDottedStroke.lineCap||me.longDottedStroke.lineCap;default:return}}getLineDash(n){switch(n){case de.Normal:return;case de.Dotted:{const{segment:e,gap:t}=this.pluginOptions.extras.dottedStroke||me.dottedStroke;return[e,t]}case de.LongDotted:{const{segment:e,gap:t}=this.pluginOptions.extras.longDottedStroke||me.longDottedStroke;return[e,t]}default:return}}effectViewContainer(n){var e,t,i,o,s;if(this.disableDeviceInputs===!0)this.room.disableDeviceInputs=!0,(e=this.worker)==null||e.unWritable(),(t=this.cursor)==null||t.unabled();else switch(n!==T.Text&&this.viewContainerManager.focuedViewId&&this.viewContainerManager.unActiveTextEditor(this.viewContainerManager.focuedViewId),n){case T.Text:case T.Pencil:case T.LaserPen:case T.Arrow:case T.Straight:case T.Rectangle:case T.Ellipse:case T.Star:case T.Polygon:case T.SpeechBalloon:case T.Triangle:case T.Rhombus:case T.Eraser:case T.PencilEraser:case T.BitMapEraser:case T.Selector:this.room.disableDeviceInputs=!0,(i=this.worker)==null||i.abled(),n===T.Text&&this.viewContainerManager.focuedViewId&&this.viewContainerManager.activeTextEditor(this.viewContainerManager.focuedViewId);break;default:this.room.disableDeviceInputs=!1,(o=this.worker)==null||o.unWritable(),(s=this.cursor)==null||s.unabled();break}setTimeout(()=>{this.viewContainerManager.getAllViews().forEach(c=>{c!=null&&c.displayer&&c.displayer.bindToolsClass()})},0)}async getBoundingRect(n){var t,i,o,s,a;const e=await((t=this.worker)==null?void 0:t.getBoundingRect(n));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=((a=(s=this.viewContainerManager.mainView)==null?void 0:s.viewData)==null?void 0:a.camera.scale)||1;return{width:Math.floor(e.w/l)+1,height:Math.floor(e.h/l)+1,originX:c.x,originY:c.y}}}async screenshotToCanvas(n,e,t,i,o,s,a){const c=await this.worker.getSnapshot(e,t,i,o);c&&c.forEach(l=>{if(l)try{console.log("[screenshotToCanvas] Drawing ImageBitmap:",l.width,l.height),n.drawImage(l,s||0,a||0)}catch(h){console.error("[screenshotToCanvas] Failed to draw ImageBitmap:",h)}l instanceof ImageBitmap?l.close():l instanceof HTMLImageElement&&l.remove()})}async scenePreview(n,e){var s,a,c,l;const t=(s=this.collector)==null?void 0:s.getViewIdBySecenPath(n);if(!t)return;const i=this.viewContainerManager.getView(t);if(!i||!((a=i.cameraOpt)!=null&&a.width)||!((c=i.cameraOpt)!=null&&c.height))return;const o=await((l=this.worker)==null?void 0:l.getSnapshot(n));if(o&&this.worker){const h=document.createElement("canvas"),u=h.getContext("2d"),{width:f,height:p}=i.cameraOpt;h.width=f,h.height=p,u&&(o.forEach(g=>{g&&(u.drawImage(g,0,0),g instanceof ImageBitmap?g.close():g instanceof HTMLImageElement&&g.remove())}),e.crossOrigin="anonymous",e.src=h.toDataURL(),e.onload=()=>{h.remove()},e.onerror=()=>{h.remove(),e.remove()})}}switchToText(){var n;(n=this.room)==null||n.setMemberState({currentApplianceName:te.text})}switchToSelector(){var n;(n=this.room)==null||n.setMemberState({currentApplianceName:te.selector})}async runEffectWork(n){if(this.hasSwitchToSelectorEffect){const e=await new Promise(t=>{this.switchToSelector(),this.effectResolve=t});this.effectResolve=void 0,e&&n&&n()}}setSnapshootData(){var n;this.room&&(this.snapshootStateMap=new Map,this.snapshootStateMap.set("memberState",(n=this.room)==null?void 0:n.state.memberState))}getSnapshootData(n){var e;return(e=this.snapshootStateMap)==null?void 0:e.get(n)}clearSnapshootData(){var n;(n=this.snapshootStateMap)==null||n.clear(),this.snapshootStateMap=void 0}useBitMapEraser(n){this.pluginOptions.extras.pencilEraser.useBitMap=n}consoleWorkerInfo(){var n;(n=this.worker)==null||n.consoleWorkerInfo()}filterRenderByUid(n,e,t=!0){var o;this.viewContainerManager.getView(n)&&((o=this.renderControl)==null||o.publishRender({viewId:n,option:e,isSync:t}))}cancelFilterRender(n,e=!0){var t;(t=this.renderControl)==null||t.publishRender({viewId:n,isSync:e})}async createMiniMap(n,e){var i,o,s;if(this.isUseSimple)throw new Error("simple mode not support createMiniMap");const t=await((i=this.miniMapManager)==null?void 0:i.getMiniMapCamera(n));if(t&&await((o=this.miniMapManager)==null?void 0:o.createMiniMap(n,e,t))){const c=(s=this.miniMapManager)==null?void 0:s.getMiniMapCanvas(n);if(c){const l=c.getContext("2d");if(l){const h=this.viewContainerManager.getView(n);h!=null&&h.focusScenePath&&this.screenshotToCanvas(l,h.focusScenePath,t.width,t.height,t)}}}}async destroyMiniMap(n){var e;(e=this.miniMapManager)==null||e.destroyMiniMap(n)}insertIconify(n,e){var i;if(this.viewContainerManager.getView(n)&&this.room){const o=this.room.state.memberState,s=Tt(o.strokeColor[0],o.strokeColor[1],o.strokeColor[2],o.strokeOpacity||1);(i=this.worker)==null||i.insertIconify(n,{...e,strokeColor:s})}}insertBackgroundSVG(n,e){var t;if(!this.isUseBackgroundThread)throw new Error("useBackgroundThread of pluginOptions should be true");(t=this.worker)==null||t.insertBackgroundSVG(n,e)}async insertBackgroundMarkMap(n,e){var t;if(!this.isUseBackgroundThread)throw new Error("useBackgroundThread of pluginOptions should be true");return await((t=this.worker)==null?void 0:t.insertBackgroundMarkMap(n,e))}updateBackgroundMarkMap(n,e,t){var o;const i=this.viewContainerManager.getView(n);if(i&&this.collector&&this.collector.hasTargetDataByViewId(n,e)){const{data:s,scenePath:a}=this.collector.getTargetDataByViewId(n,e);if(!a)throw new Error("updateBackgroundMarkMap scenePath is not exist");const c=i.focusScenePath;if(c&&c!==a)throw new Error("updateBackgroundMarkMap scenePath is not the focus scene path");if(s&&a)(o=this.worker)==null||o.updateBackgroundMarkMap(n,e,t);else throw new Error("updateBackgroundMarkMap data or scenePath is not exist")}}usePlugin(n){var e;return(e=this.pluginManager)==null?void 0:e.use(n)}async stopDraw(n){var t;const e=this.viewContainerManager.getView(n);e&&await((t=e.displayer)==null?void 0:t.stopEventHandler())}async setViewLocalScenePathChange(n,e){this.viewContainerManager.getView(n)&&await this.onSceneChange(e,n)}};I(ot,"InternalMsgEmitter",new Sn),I(ot,"PublicMsgEmitter",new Sn);let we=ot;var On=(r=>(r.Undo="undo",r.Redo="redo",r))(On||{});const se=class se{createProxy(n,e,t){const i=new Proxy(n,{get(o,s,a){if(typeof s=="string"&&/^\d+$/.test(s))return Reflect.get(o,s,a);const c=se.interceptors.hasOwnProperty(s)?se.interceptors:o,l=Reflect.get(c,s,a);return typeof l=="function"&&c===se.interceptors?l.bind(i):l},set(o,s,a,c){const l=se.proxyCallbacks.get(c),h=(l==null?void 0:l.arrayType)||"undo";if(s==="length"){const u=o.length,f=[];if(a<u)for(let g=a;g<u;g++)f.push(o[g]);const p=Reflect.set(o,s,a,c);if(l!=null&&l.callback)for(let g=0;g<f.length;g++)l.callback({operation:"delete",index:a+g,oldValue:f[g],arrayType:h});return p}return typeof s=="string"&&/^\d+$/.test(s),Reflect.set(o,s,a,c)},deleteProperty(o,s){const a=se.proxyCallbacks.get(i),c=(a==null?void 0:a.arrayType)||"undo";if(typeof s=="string"&&/^\d+$/.test(s)){const l=parseInt(s,10),h=o[l],u=Reflect.deleteProperty(o,s);return a!=null&&a.callback&&h!==void 0&&a.callback({operation:"delete",index:l,oldValue:h,arrayType:c}),u}return Reflect.deleteProperty(o,s)}});return se.proxyToRaw.set(i,n),se.proxyCallbacks.set(i,{callback:e,arrayType:t}),i}};I(se,"proxyToRaw",new WeakMap),I(se,"proxyCallbacks",new WeakMap),I(se,"interceptors",{entries(...n){return se.proxyToRaw.get(this).entries(...n)},forEach(...n){return se.proxyToRaw.get(this).forEach(...n)},map(...n){return se.proxyToRaw.get(this).map(...n)},filter(...n){return se.proxyToRaw.get(this).filter(...n)},find(...n){return se.proxyToRaw.get(this).find(...n)},findIndex(...n){return se.proxyToRaw.get(this).findIndex(...n)},includes(...n){return se.proxyToRaw.get(this).includes(...n)},indexOf(...n){return se.proxyToRaw.get(this).indexOf(...n)},slice(...n){return se.proxyToRaw.get(this).slice(...n)},concat(...n){return se.proxyToRaw.get(this).concat(...n)},push(...n){const e=se.proxyToRaw.get(this),t=this,i=se.proxyCallbacks.get(t),o=(i==null?void 0:i.arrayType)||"undo",s=e.length,a=e.push(...n);if(i!=null&&i.callback)for(let c=s;c<e.length;c++)i.callback({operation:"add",index:c,newValue:e[c],arrayType:o});return a},customPush(...n){return se.proxyToRaw.get(this).push(...n)},pop(){const n=se.proxyToRaw.get(this),e=this,t=se.proxyCallbacks.get(e),i=(t==null?void 0:t.arrayType)||"undo",o=n.length,s=n[o-1],a=n.pop();return t!=null&&t.callback&&o>0&&t.callback({operation:"delete",index:o-1,oldValue:s,arrayType:i}),a},shift(){const n=se.proxyToRaw.get(this),e=this,t=se.proxyCallbacks.get(e),i=(t==null?void 0:t.arrayType)||"undo",o=n[0],s=n.shift();return t!=null&&t.callback&&n.length>0&&t.callback({operation:"delete",index:0,oldValue:o,arrayType:i}),s},unshift(...n){const e=se.proxyToRaw.get(this),t=this,i=se.proxyCallbacks.get(t),o=(i==null?void 0:i.arrayType)||"undo",s=e.unshift(...n);if(i!=null&&i.callback)for(let a=0;a<n.length;a++)i.callback({operation:"add",index:a,newValue:e[a],arrayType:o});return s},splice(n,e,...t){const i=se.proxyToRaw.get(this),o=this,s=se.proxyCallbacks.get(o),a=(s==null?void 0:s.arrayType)||"undo",c=e??i.length-n,l=i.slice(n,n+c),h=i.splice(n,c,...t);if(s!=null&&s.callback){for(let u=0;u<l.length;u++)s.callback({operation:"delete",index:n+u,oldValue:l[u],arrayType:a});for(let u=0;u<t.length;u++)s.callback({operation:"add",index:n+u,newValue:i[n+u],arrayType:a})}return h},customSplice(n,e,...t){const i=se.proxyToRaw.get(this),o=e??i.length-n;return i.splice(n,o,...t)},get length(){return se.proxyToRaw.get(this).length},set length(n){const e=se.proxyToRaw.get(this),t=this,i=se.proxyCallbacks.get(t),o=(i==null?void 0:i.arrayType)||"undo",s=e.length,a=[];if(n<s)for(let c=n;c<s;c++)a.push(e[c]);if(e.length=n,i!=null&&i.callback)for(let c=0;c<a.length;c++)i.callback({operation:"delete",index:n+c,oldValue:a[c],arrayType:o})}});let Rn=se;const Xe=class Xe{constructor(n){I(this,"emitter",new Sn);I(this,"undoStack");I(this,"redoStack");I(this,"worker");I(this,"control");I(this,"room");I(this,"viewId");I(this,"enableGlobal");I(this,"isTicking");I(this,"_undoTickerId");I(this,"scenePath");I(this,"tickStartStorerCache");I(this,"excludeIds",new Set);I(this,"onChangeScene",x.debounce(()=>{const n=this.control.viewContainerManager.getCurScenePath(this.viewId);if(n){const e=this.undoStack.filter(i=>i.scenePath===n).length,t=this.redoStack.filter(i=>i.scenePath===n).length;this.emitter.emitAsync("onCanUndoStepsUpdate",e,this.viewId),this.emitter.emitAsync("onCanRedoStepsUpdate",t,this.viewId)}},Xe.waitTime));const{control:e,internalMsgEmitter:t,viewId:i,enableGlobal:o}=n;this.control=e,this.emitter=t,Xe.MaxStackLength=this.control.pluginOptions.extras.undoRedo.maxStackLength||me.undoRedo.maxStackLength;const s=new Rn,a=[],c=[];this.undoStack=s.createProxy(a,l=>{this.control.renderControl.isWritable&&this.handleArrayChange(l,Ce.syncUndoStack)},On.Undo),this.redoStack=s.createProxy(c,l=>{this.control.renderControl.isWritable&&this.handleArrayChange(l,Ce.syncRedoStack)},On.Redo),this.room=e.room,this.worker=e.worker,this.isTicking=!1,this.viewId=i,this.enableGlobal=o}handleArrayChange(n,e){if(!this.collector||!this.enableGlobal)return;const{operation:t,oldValue:i,newValue:o}=n;let s,a;t==="delete"&&i?(s=i,a=i.id):t==="add"&&o&&(s=o,a=o.id),s&&a&&this.collector.dispatchUndoTicker({operation:e,syncType:t,viewId:this.viewId,undoTickerId:a,data:s})}get collector(){return this.control.collector}get undoTickerId(){return this._undoTickerId}get tmpTickStartStorerCache(){return this.tickStartStorerCache}get uid(){var n;return((n=this.control.collector)==null?void 0:n.uid)||""}addExcludeIds(n){if(this.isTicking)for(const e of n)this.excludeIds.add(e)}undoTickerStart(n,e){var t,i;if(this.collector&&(this.undoTickerId!==n||this.scenePath!==e)){this.undoTickerId&&this.viewId&&this.scenePath&&this.undoTickerEndSync(this.undoTickerId,this.viewId,this.scenePath),this.isTicking=!0;const o=this.collector.transformKey(Z);this.excludeIds.add(o),this._undoTickerId=n,this.scenePath=e;const s=((t=this.collector)==null?void 0:t.storage[this.viewId])&&((i=this.collector)==null?void 0:i.storage[this.viewId][this.scenePath])||{};this.tickStartStorerCache=new Map(Object.entries(x.cloneDeep(s)))}}undoTickerEnd(n,e){this.undoTickerId&&n===this.undoTickerId&&e===this.scenePath?this.undoTickerEndSync(n,this.viewId,e):(this.isTicking=!1,this.scenePath=void 0,this.tickStartStorerCache=void 0,this._undoTickerId=void 0,this.excludeIds.clear())}undoTickerEndSync(n,e,t,i=!0){var o,s;if(n===this.undoTickerId&&t===this.scenePath&&e===this.viewId&&this.tickStartStorerCache){const a=((o=this.collector)==null?void 0:o.storage[e])&&((s=this.collector)==null?void 0:s.storage[e][t])||{},c=this.diffFun(this.tickStartStorerCache,new Map(Object.entries(a)),!0);c.size&&(this.undoStack.push({id:`${n}-${this.uid}`,data:x.cloneDeep(c),scenePath:t}),this.undoStack.length>Xe.MaxStackLength&&this.undoStack.shift(),i&&this.emitter.emitAsync("onCanUndoStepsUpdate",this.undoStack.length,this.viewId),this.redoStack.length&&(this.redoStack.length=0,i&&this.emitter.emitAsync("onCanRedoStepsUpdate",this.redoStack.length,this.viewId))),this.isTicking=!1,this.scenePath=void 0,this.tickStartStorerCache=void 0,this._undoTickerId=void 0,this.excludeIds.clear()}}transformToUndoStackItem(n){const e=[];for(const[t,i]of Object.entries(n)){const o=new Set;for(const[s,a]of Object.entries(i.data))o.add({key:s,dataType:a.dataType,data:a.data});e.push({id:t,scenePath:i.scenePath,data:o})}return e}pullServiceData(n){if(n){const{undoStack:e,redoStack:t}=n;if(e){const i=this.transformToUndoStackItem(e);for(let o=this.undoStack.length-1;o>=0;o--){const s=this.undoStack[o];i.findIndex(c=>c.id===s.id)===-1&&this.undoStack.customSplice(o,1)}for(const o of i){const s=this.undoStack.findIndex(a=>a.id===o.id);s!==-1?this.undoStack[s]=o:this.undoStack.customPush(o)}this.undoStack.sort((o,s)=>{const a=parseInt(o.id.split("-")[0]),c=parseInt(s.id.split("-")[0]);return a-c}),this.emitter.emitAsync("onCanUndoStepsUpdate",this.undoStack.length,this.viewId)}if(t){const i=this.transformToUndoStackItem(t);for(let o=this.redoStack.length-1;o>=0;o--){const s=this.redoStack[o];i.findIndex(c=>c.id===s.id)===-1&&this.redoStack.customSplice(o,1)}for(const o of i){const s=this.redoStack.findIndex(a=>a.id===o.id);s!==-1?this.redoStack[s]=o:this.redoStack.customPush(o)}this.redoStack.sort((o,s)=>{const a=parseInt(o.id.split("-")[0]);return parseInt(s.id.split("-")[0])-a}),this.emitter.emitAsync("onCanRedoStepsUpdate",this.redoStack.length,this.viewId)}}else this.clear()}undo(n){var o,s;let e;if(this.undoTickerId&&this.tickStartStorerCache&&this.scenePath){const a=((o=this.collector)==null?void 0:o.storage[this.viewId])&&((s=this.collector)==null?void 0:s.storage[this.viewId][n])||{},c=this.diffFun(this.tickStartStorerCache,new Map(Object.entries(a)),!1),l=this.diffFun(this.tickStartStorerCache,new Map(Object.entries(a)),!0);c.size===l.size?(this.undoStack.push({id:`${this.undoTickerId}-${this.uid}`,data:x.cloneDeep(c),scenePath:n}),this.undoStack.length>Xe.MaxStackLength&&this.undoStack.shift()):c.size&&!l.size&&(e={id:`${this.undoTickerId}-${this.uid}`,data:x.cloneDeep(c),scenePath:n}),this.isTicking=!1,this.scenePath=void 0,this.tickStartStorerCache=void 0,this._undoTickerId=void 0,this.excludeIds.clear()}if(e)this.refreshPlugin(e);else{let a=this.undoStack.length-1;for(;a>=0;){if(this.undoStack[a].scenePath===n){const l=this.undoStack[a];l&&(this.redoStack.push(l),l.data&&this.refreshPlugin(l)),this.undoStack.splice(a,1);break}a--}}const t=this.undoStack.filter(a=>a.scenePath===n).length,i=this.redoStack.filter(a=>a.scenePath===n).length;return this.emitter.emitAsync("onCanUndoStepsUpdate",t,this.viewId),this.emitter.emitAsync("onCanRedoStepsUpdate",i,this.viewId),t}redo(n){let e=this.redoStack.length-1;for(;e>=0;){if(this.redoStack[e].scenePath===n){const s=this.redoStack[e];s&&(this.undoStack.push(s),s.data&&this.refreshPlugin(s,!0)),this.redoStack.splice(e,1);break}e--}const t=this.undoStack.filter(o=>o.scenePath===n).length,i=this.redoStack.filter(o=>o.scenePath===n).length;return this.emitter.emitAsync("onCanUndoStepsUpdate",t,this.viewId),this.emitter.emitAsync("onCanRedoStepsUpdate",i,this.viewId),i}clear(){this.clearUndo(),this.clearRedo()}clearUndo(){this.undoStack.length=0,this.emitter.emitAsync("onCanUndoStepsUpdate",this.undoStack.length,this.viewId)}clearRedo(){this.redoStack.length=0,this.emitter.emitAsync("onCanRedoStepsUpdate",this.redoStack.length,this.viewId)}canUndo(){return!!this.undoStack.length}canRedo(){return!!this.redoStack.length}onFocusView(){const n=this.control.viewContainerManager.getCurScenePath(this.viewId);if(n){const e=this.undoStack.filter(i=>i.scenePath===n).length,t=this.redoStack.filter(i=>i.scenePath===n).length;this.emitter.emitAsync("onCanUndoStepsUpdate",e,this.viewId),this.emitter.emitAsync("onCanRedoStepsUpdate",t,this.viewId)}}especialDiff(n,e,t,i){if(e===Ue.Update)switch(t==null?void 0:t.toolsType){case T.Text:{if(i!=null&&i.opt&&(t!=null&&t.opt)){const s=x.omit(i.opt,["uid","workState"]),a=x.omit(t.opt,["uid","workState"]);if(n&&x.isEqual(s,a))return!0;i.opt.workState!==j.Done&&(i.opt.workState=j.Done),t.opt.workState!==j.Done&&(t.opt.workState=j.Done)}break}}else if(e===Ue.Draw||e===Ue.Delete)switch(t==null?void 0:t.toolsType){case T.Text:{if(t!=null&&t.opt){const s=t.opt.text;if(n&&!s)return!0;t.opt.workState!==j.Done&&(t.opt.workState=j.Done)}break}}return!1}diffFun(n,e,t=!0){const i=new Set,o=n.keys(),s=e.keys();for(const a of o){if(this.excludeIds.has(a))continue;const c=n.get(a),l=x.cloneDeep(e.get(a));if(c&&l){if(x.isEqual(l,c)||this.especialDiff(t,Ue.Update,l,c))continue;i.add({dataType:Ue.Update,key:a,data:[c,l]});continue}this.especialDiff(t,Ue.Delete,c)||c&&i.add({dataType:Ue.Delete,key:a,data:c})}for(const a of s){if(this.excludeIds.has(a))continue;const c=x.cloneDeep(e.get(a));if(c&&!n.has(a)){if(this.especialDiff(t,Ue.Draw,c))continue;i.add({dataType:Ue.Draw,key:a,data:c})}}return i}isDrawEffectiveScene(n,e){const{key:t}=n;return!e.includes(t)}isDeleteEffectiveScene(n,e){const{key:t}=n;return!!e.includes(t)}isOldEffectiveScene(n,e){const{key:t}=n;return!!e.includes(t)}isNewEffectiveScene(n,e){const{key:t}=n;return!!e.includes(t)}refreshPlugin(n,e=!1){var a,c,l,h,u,f,p,g,m,w,y,M,v,S,C,k,N,z,P,L,R;let t;const{scenePath:i}=n,o=n.data;if(!o||!this.collector)return;const s=x.cloneDeep(this.collector.storage);for(const E of o.values()){const{dataType:O,data:D,key:V}=E,J=this.collector.getStorageData(this.viewId,i),U=J&&Object.keys(J)||[];switch(O){case Ue.Draw:if(t=e?this.isDrawEffectiveScene(E,U):this.isDeleteEffectiveScene(E,U),t)if(e&&!Array.isArray(D)){if((a=D.updateNodeOpt)!=null&&a.useAnimation&&(D.updateNodeOpt.useAnimation=!1),((c=this.collector)==null?void 0:c.getLocalId(V))===Z&&((l=this.collector)!=null&&l.isOwn(E.key))){const Q=D.selectIds;if(Q){const H=U.filter(ne=>{var q,$;return((q=this.collector)==null?void 0:q.getLocalId(ne))===Z&&!(($=this.collector)!=null&&$.isOwn(ne))}).map(ne=>{var q;return(q=this.collector)==null?void 0:q.storage[this.viewId][i][ne]});let oe=!1;for(const ne of H)for(let q=0;q<Q.length;q++)(h=ne==null?void 0:ne.selectIds)!=null&&h.includes(Q[q])&&(delete Q[q],oe=!0);oe&&(D.selectIds=Q.filter(ne=>!!ne))}}(u=this.collector)==null||u.updateValue(E.key,D,{viewId:this.viewId,scenePath:i,isSync:!0,storage:s})}else!e&&!Array.isArray(E.data)&&((f=this.collector)==null||f.updateValue(E.key,void 0,{viewId:this.viewId,scenePath:i,isSync:!0,storage:s}));break;case Ue.Delete:if(t=e?this.isDeleteEffectiveScene(E,U):this.isDrawEffectiveScene(E,U),t){if(e&&!Array.isArray(D))(p=this.collector)==null||p.updateValue(V,void 0,{viewId:this.viewId,scenePath:i,isSync:!0,storage:s});else if(!e&&!Array.isArray(D)){if((g=D.updateNodeOpt)!=null&&g.useAnimation&&(D.updateNodeOpt.useAnimation=!1),((m=this.collector)==null?void 0:m.getLocalId(E.key))===Z&&((w=this.collector)!=null&&w.isOwn(E.key))){const Q=D.selectIds;if(Q){const H=U.filter(ne=>{var q,$;return((q=this.collector)==null?void 0:q.getLocalId(ne))===Z&&!(($=this.collector)!=null&&$.isOwn(ne))}).map(ne=>{var q;return(q=this.collector)==null?void 0:q.storage[this.viewId][i][ne]});let oe=!1;for(const ne of H)for(let q=0;q<Q.length;q++)(y=ne==null?void 0:ne.selectIds)!=null&&y.includes(Q[q])&&(delete Q[q],oe=!0);oe&&(D.selectIds=Q.filter(ne=>!!ne))}}(M=this.collector)==null||M.updateValue(E.key,E.data,{viewId:this.viewId,scenePath:i,isSync:!0,storage:s})}}break;case Ue.Update:if(t=e?this.isNewEffectiveScene(E,U):this.isOldEffectiveScene(E,U),t){if(e&&Array.isArray(D)&&D.length===2){const Q=D[1];if((v=Q.updateNodeOpt)!=null&&v.useAnimation&&(Q.updateNodeOpt.useAnimation=!1),((S=this.collector)==null?void 0:S.getLocalId(E.key))===Z&&((C=this.collector)!=null&&C.isOwn(E.key))){const H=Q.selectIds;if(H){const oe=U.filter(q=>{var $,ae;return(($=this.collector)==null?void 0:$.getLocalId(q))===Z&&!((ae=this.collector)!=null&&ae.isOwn(q))}).map(q=>{var $;return($=this.collector)==null?void 0:$.storage[this.viewId][i][q]});let ne=!1;for(const q of oe)for(let $=0;$<H.length;$++)q!=null&&q.selectIds&&((k=q.selectIds)!=null&&k.includes(H[$]))&&(delete H[$],ne=!0);ne&&(Q.selectIds=H.filter(q=>!!q))}}(N=this.collector)==null||N.updateValue(V,Q,{viewId:this.viewId,scenePath:i,isSync:!0,storage:s})}else if(!e&&Array.isArray(D)&&D.length===2){const Q=D[0];if((z=Q.updateNodeOpt)!=null&&z.useAnimation&&(Q.updateNodeOpt.useAnimation=!1),((P=this.collector)==null?void 0:P.getLocalId(E.key))===Z&&((L=this.collector)!=null&&L.isOwn(E.key))){const H=Q.selectIds;if(H){const oe=U.filter(q=>{var $,ae;return(($=this.collector)==null?void 0:$.getLocalId(q))===Z&&!((ae=this.collector)!=null&&ae.isOwn(q))}).map(q=>{var $;return($=this.collector)==null?void 0:$.storage[this.viewId][i][q]});let ne=!1;for(const q of oe)for(let $=0;$<H.length;$++)q!=null&&q.selectIds&&q.selectIds.includes(H[$])&&(delete H[$],ne=!0);ne&&(Q.selectIds=H.filter(q=>!!q))}}(R=this.collector)==null||R.updateValue(E.key,Q,{viewId:this.viewId,scenePath:i,isSync:!0,storage:s})}}break}}}};I(Xe,"sdkCallBack"),I(Xe,"MaxStackLength",me.undoRedo.maxStackLength),I(Xe,"waitTime",100);let Yn=Xe;class vt{constructor(n){I(this,"internalMsgEmitter");I(this,"control");I(this,"mainView");I(this,"appViews",new Map);I(this,"undoTickerStart",(n,e)=>{const t=this.getView(e);t&&t.displayer&&t.focusScenePath&&t.displayer.commiter.undoTickerStart(n,t.focusScenePath)});I(this,"undoTickerEnd",(n,e)=>{const t=this.getView(e);t&&t.displayer&&t.focusScenePath&&t.displayer.commiter.undoTickerEnd(n,t.focusScenePath)});I(this,"addExcludeIds",(n,e)=>{const t=this.getView(e);t&&t.displayer&&t.focusScenePath&&t.displayer.commiter.addExcludeIds(n)});const{control:e,internalMsgEmitter:t}=n;this.control=e,this.internalMsgEmitter=t,this.internalMsgEmitter.on("addUndoTicker",this.undoTickerStart),this.internalMsgEmitter.on("forceUndoTickerEnd",this.undoTickerEnd),this.internalMsgEmitter.on("excludeIds",this.addExcludeIds)}get worker(){return this.control.worker}getUndoTickerId(n){const e=this.getView(n);if(e&&e.displayer&&e.focusScenePath)return e.displayer.commiter.undoTickerId}undo(){const n=this.focuedView;let e=0;if(n){const t=n.focusScenePath;e=n.displayer.commiter.undo(t)||0}return e}redo(){const n=this.focuedView;let e=0;if(n){const t=n.focusScenePath;e=n.displayer.commiter.redo(t)||0}return e}validator(n,e,t){var s;const i=x.clone(n[e]),o=x.clone(t);e==="focusScenePath"&&t&&!x.isEqual(i,o)&&(this.control.internalSceneChange(n.id,o),(s=this.focuedView)==null||s.displayer.commiter.onChangeScene()),e==="cameraOpt"&&!x.isEqual(i,o)&&this.control.internalCameraChange(n.id,o)}destroyAppView(n,e=!1){const t=this.appViews.get(n);t&&(this.control.textEditorManager.clear(n,e),t.displayer.destroy(),this.appViews.delete(n))}createMianView(n){this.mainView=new Proxy(n,{set:(e,t,i)=>(this.worker.isActive&&this.validator(e,t,i),e[t]=i,!0)})}createAppView(n){const e=n.id,t=new Proxy(n,{set:(i,o,s)=>(this.worker.isActive&&this.validator(i,o,s),i[o]=s,!0)});this.appViews.set(e,t)}isAppView(n){return n!==ge&&this.appViews.has(n)}getView(n){var e;return n===ge?this.mainView:(e=this.appViews)==null?void 0:e.get(n)}getCurScenePath(n){const e=this.getView(n);if(e)return e.focusScenePath}getAllViews(){return[this.mainView,...this.appViews.values()]}setViewScenePath(n,e){var t;if(n===ge&&this.mainView)this.mainView.focusScenePath=e;else{const i=n&&((t=this.appViews)==null?void 0:t.get(n))||void 0;i&&(i.focusScenePath=e)}}setViewData(n,e){var t;if(n===ge&&this.mainView)this.mainView.viewData=e;else{const i=n&&((t=this.appViews)==null?void 0:t.get(n))||void 0;i&&(i.viewData=e)}}setFocuedViewId(n){var e;this.focuedViewId=n,n===ge?this.focuedView=this.mainView:this.focuedView=n&&((e=this.appViews)==null?void 0:e.get(n))||void 0,this.worker.currentToolsData&&this.worker.currentToolsData.toolsType===T.Text&&this.activeTextEditor(n),this.control.cursor.onFocusViewChange(),this.focuedView&&this.focuedView.displayer.commiter.onFocusView()}setViewFocusScenePath(n,e){var i;let t;n===ge?t=this.mainView:t=(i=this.appViews)==null?void 0:i.get(n),t&&(t.focusScenePath=e)}destroy(){var n;this.internalMsgEmitter.off("addUndoTicker",this.undoTickerStart),this.internalMsgEmitter.off("excludeIds",this.addExcludeIds),this.internalMsgEmitter.off("forceUndoTickerEnd",this.undoTickerEnd),(n=this.mainView)==null||n.displayer.destroy(),this.control.destroyMiniMap(ge),this.appViews.forEach(e=>{this.destroyAppView(e.id,!0),this.worker.destroyViewWorker(e.id),this.control.destroyMiniMap(e.id)})}setFocuedViewCameraOpt(n){if(this.focuedView){const e=this.focuedView.cameraOpt;x.isEqual(e,n)||(this.focuedView.cameraOpt=n)}}transformToOriginPoint(n,e){const t=this.getView(e);if(t!=null&&t.viewData){const i=t.viewData.convertToPointOnScreen(n[0],n[1]);return[i.x,i.y]}return n}transformToScenePoint(n,e){const t=this.getView(e);if(t!=null&&t.viewData){const i=t.viewData.convertToPointInWorld({x:n[0],y:n[1]});return[i.x,i.y]}return n}render(n){var e,t,i,o,s,a,c,l,h,u,f,p,g,m,w,y,M;for(const v of n){const{rect:S,imageBitmap:C,isClear:k,isUnClose:N,drawCanvas:z,clearCanvas:P,viewId:L}=v,R=(e=this.getView(L))==null?void 0:e.displayer;if(R&&S){const{dpr:E,canvasBgRef:O,canvasFloatRef:D,canvasServiceFloatRef:V,canvasTopRef:J}=R,U=Math.floor(S.w*E),Q=Math.floor(S.h*E),H=S.x*E,oe=S.y*E;if(k){switch(P){case $e.TopFloat:(i=(t=J==null?void 0:J.current)==null?void 0:t.getContext("2d"))==null||i.clearRect(H,oe,U,Q);break;case $e.Float:(s=(o=D.current)==null?void 0:o.getContext("2d"))==null||s.clearRect(H,oe,U,Q);break;case $e.ServiceFloat:(c=(a=V.current)==null?void 0:a.getContext("2d"))==null||c.clearRect(H,oe,U,Q);break;case $e.Bg:(h=(l=O.current)==null?void 0:l.getContext("2d"))==null||h.clearRect(H,oe,U,Q);break}continue}if(z&&C)switch(z){case $e.TopFloat:(f=(u=J==null?void 0:J.current)==null?void 0:u.getContext("2d"))==null||f.drawImage(C,0,0,U,Q,H,oe,U,Q);break;case $e.Float:{(g=(p=D.current)==null?void 0:p.getContext("2d"))==null||g.drawImage(C,0,0,U,Q,H,oe,U,Q);break}case $e.ServiceFloat:{(w=(m=V.current)==null?void 0:m.getContext("2d"))==null||w.drawImage(C,0,0,U,Q,H,oe,U,Q);break}case $e.Bg:{(M=(y=O.current)==null?void 0:y.getContext("2d"))==null||M.drawImage(C,0,0,U,Q,H,oe,U,Q);break}}if(N)continue;C==null||C.close()}}}showFloatBar(n,e,t){const i=this.getView(n),o=i==null?void 0:i.displayer.vDom;o&&o.showFloatBar(e,t)}activeTextEditor(n){const e=this.getView(n),t=e==null?void 0:e.displayer.vDom;t&&t.activeTextEditor()}unActiveTextEditor(n){const e=this.getView(n),t=e==null?void 0:e.displayer.vDom;t&&t.unActiveTextEditor()}showFloatBarBtn(n,e){const t=this.getView(n),i=t==null?void 0:t.displayer.vDom;i&&i.showFloatBarBtn(e)}updateTextEditorInfo(n,e){const t=this.getView(n),i=t==null?void 0:t.displayer.vDom;i&&i.updateTextEditorInfo(e)}setActiveMiniMap(n,e){const t=this.getView(n),i=t==null?void 0:t.displayer.vDom;i&&i.setActiveMiniMap(e&&n||void 0)}}I(vt,"defaultCameraOpt",{centerX:0,centerY:0,scale:1}),I(vt,"defaultScreenCanvasOpt",{autoRender:!1,contextType:"2d"}),I(vt,"defaultLayerOpt",{offscreen:!0,handleEvent:!1,depth:!1});class Vr{constructor(n,e,t){I(this,"control");I(this,"internalMsgEmitter");I(this,"commiter");I(this,"cachePoint");I(this,"cacheCursorPoint");I(this,"active",!0);I(this,"toolsKey");I(this,"activePointers",new Set);I(this,"currentDrawingPointerId");I(this,"cursorMouseMove");I(this,"cursorMouseMoveDebounced");I(this,"cursorMouseMoveThrottled");I(this,"cursorMouseMoveFun");I(this,"_transferControlToOffscreenCanvas");I(this,"cursorMouseLeave",()=>{this.control.pluginOptions.extras.cursor.enable?this.cursorMouseMoveThrottled.cancel():this.cursorMouseMoveDebounced.cancel(),this.cacheCursorPoint=[void 0,void 0],this.worker.sendCursorEvent(this.cacheCursorPoint,this.viewId)});I(this,"mousedown",n=>{var e;if(this.active&&n.button===0&&this.viewId){this.toolsKey=(e=this.worker.getCurrentToolsData())==null?void 0:e.toolsType,!this.worker.isAbled()&&this.toolsKey&&this.control.effectViewContainer(this.toolsKey),this.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(n);this.cachePoint=t,t&&(this.worker.originalEventLintener(j.Start,t,this.viewId),document.addEventListener("mousemove",this.mousemove,!1),document.addEventListener("mouseleave",this.mouseup,!1),document.addEventListener("mouseup",this.mouseup,!1))}});I(this,"mousemove",n=>{if(this.active&&this.viewId){const e=this.getPoint(n);if(this.cachePoint=e,this.checkConsumeCount())return;e&&this.worker.originalEventLintener(j.Doing,e,this.viewId)}});I(this,"mouseup",n=>{if(this.active&&n.button===0&&this.viewId){const e=this.getPoint(n)||this.cachePoint;e?(this.worker.originalEventLintener(j.Done,e,this.viewId).finally(()=>{document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1)}),this.cachePoint=void 0):(document.removeEventListener("mouseleave",this.mouseup,!1),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1))}});I(this,"touchstart",n=>{var e;if(this.active){if(!qt(n)){this.worker.unWritable(),this.viewId&&this.worker.removeDrawingWork(this.viewId);return}if(this.viewId){this.toolsKey=(e=this.worker.getCurrentToolsData())==null?void 0:e.toolsType,!this.worker.isAbled()&&this.toolsKey&&this.control.effectViewContainer(this.toolsKey),this.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(n);this.cachePoint=t,t&&(this.worker.originalEventLintener(j.Start,t,this.viewId),document.addEventListener("touchmove",this.touchmove,!1),document.addEventListener("touchend",this.touchend,!1))}}});I(this,"touchmove",n=>{if(this.active){if(!qt(n)){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const e=this.getPoint(n);if(this.cachePoint=e,this.checkConsumeCount())return;e&&this.worker.originalEventLintener(j.Doing,e,this.viewId)}}});I(this,"touchend",n=>{if(this.active){if(!qt(n)||!this.worker.isAbled()){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId);return}if(this.viewId){const e=this.getPoint(n)||this.cachePoint;e?(this.worker.originalEventLintener(j.Done,e,this.viewId).finally(()=>{document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1)}),this.cachePoint=void 0):(document.removeEventListener("touchmove",this.touchmove,!1),document.removeEventListener("touchend",this.touchend,!1))}}});I(this,"keydown",n=>{n.stopPropagation(),n.stopImmediatePropagation(),this.control.hotkeyManager.colloctHotkey(n)});I(this,"pointerdown",n=>{var e;if(this.active){if(n.pointerType==="touch"&&(this.activePointers.add(n.pointerId),this.activePointers.size>1)){this.worker.unWritable(),this.viewId&&this.worker.removeDrawingWork(this.viewId),document.removeEventListener("pointermove",this.pointermove,!1),document.removeEventListener("pointerup",this.pointerup,!1),document.removeEventListener("pointercancel",this.pointerup,!1),this.currentDrawingPointerId=void 0,this.cachePoint=void 0,this.activePointers.clear();return}if(n.button===0&&this.viewId){this.toolsKey=(e=this.worker.getCurrentToolsData())==null?void 0:e.toolsType,!this.worker.isAbled()&&this.toolsKey&&this.control.effectViewContainer(this.toolsKey),this.worker.checkDrawingWork(this.viewId),this.reflashContainerOffset();const t=this.getPoint(n);this.cachePoint=t,t&&(this.currentDrawingPointerId=n.pointerId,this.worker.originalEventLintener(j.Start,t,this.viewId),document.addEventListener("pointermove",this.pointermove,!1),document.addEventListener("pointerup",this.pointerup,!1),document.addEventListener("pointercancel",this.pointerup,!1))}}});I(this,"pointermove",n=>{if(this.active){if(n.pointerType==="touch"){if(this.activePointers.size>1){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId);return}if(this.currentDrawingPointerId!==void 0&&n.pointerId!==this.currentDrawingPointerId)return;if(!this.worker.isAbled()){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId);return}}if(this.viewId){const e=this.getPoint(n);if(this.cachePoint=e,this.checkConsumeCount())return;e&&this.worker.originalEventLintener(j.Doing,e,this.viewId)}}});I(this,"pointerup",n=>{if(this.active&&(n.pointerType==="touch"&&this.activePointers.delete(n.pointerId),!(this.currentDrawingPointerId!==void 0&&n.pointerId!==this.currentDrawingPointerId))){if(this.currentDrawingPointerId===void 0){document.removeEventListener("pointermove",this.pointermove,!1),document.removeEventListener("pointerup",this.pointerup,!1),document.removeEventListener("pointercancel",this.pointerup,!1);return}if(n.pointerType==="touch"&&(this.activePointers.size>0||!this.worker.isAbled())){this.worker.unWritable(),this.worker.removeDrawingWork(this.viewId),document.removeEventListener("pointermove",this.pointermove,!1),document.removeEventListener("pointerup",this.pointerup,!1),document.removeEventListener("pointercancel",this.pointerup,!1),this.cachePoint=void 0,this.currentDrawingPointerId=void 0;return}if(n.button===0&&this.viewId){const e=this.getPoint(n)||this.cachePoint;e?(this.worker.originalEventLintener(j.Done,e,this.viewId).finally(()=>{document.removeEventListener("pointermove",this.pointermove,!1),document.removeEventListener("pointerup",this.pointerup,!1),document.removeEventListener("pointercancel",this.pointerup,!1)}),this.cachePoint=void 0,this.currentDrawingPointerId=void 0):(document.removeEventListener("pointermove",this.pointermove,!1),document.removeEventListener("pointerup",this.pointerup,!1),document.removeEventListener("pointercancel",this.pointerup,!1),this.currentDrawingPointerId=void 0)}n.pointerType==="touch"&&this.activePointers.size===0&&this.activePointers.clear()}});this.control=n,this.internalMsgEmitter=e;const i={control:this.control,internalMsgEmitter:this.internalMsgEmitter,viewId:t,enableGlobal:!!this.control.pluginOptions.extras.undoRedo.enableGlobal};this.commiter=new Yn(i),this.cursorMouseMoveFun=o=>{const s=this.getPoint(o);this.cacheCursorPoint&&x.isEqual(s,this.cacheCursorPoint)||(this.cacheCursorPoint=s,s&&this.worker.sendCursorEvent(s,this.viewId))},this.cursorMouseMoveDebounced=x.debounce(this.cursorMouseMoveFun,this.moveDelayTime,{trailing:!0}),this.cursorMouseMoveThrottled=x.throttle(this.cursorMouseMoveFun,this.moveDelayTime,{leading:!0}),this.cursorMouseMove=o=>{this.control.pluginOptions.extras.cursor.enable?this.cursorMouseMoveThrottled(o):this.cursorMouseMoveDebounced(o)},this.setActive(n.renderControl.isWritable)}get moveDelayTime(){var n,e;return((e=(n=this.control.pluginOptions.extras)==null?void 0:n.cursor)==null?void 0:e.moveDelayTime)??me.cursor.moveDelayTime}setTransferControlToOffscreenCanvas(n){this._transferControlToOffscreenCanvas={bgCanvas:n.bgCanvas.transferControlToOffscreen(),serviceCanvas:n.serviceCanvas.transferControlToOffscreen(),localCanvas:n.localCanvas.transferControlToOffscreen()}}get transferControlToOffscreenCanvas(){return this._transferControlToOffscreenCanvas}get worker(){return this.control.worker}bindToolsClass(){var i,o;const n=(o=(i=this.worker)==null?void 0:i.currentToolsData)==null?void 0:o.toolsType,e=this.control.renderControl.isWritable,t=this.worker.isAbled();switch(n){case T.Text:case T.Pencil:case T.LaserPen:case T.Arrow:case T.Straight:case T.Rectangle:case T.Ellipse:case T.Star:case T.Polygon:case T.SpeechBalloon:case T.Eraser:case T.PencilEraser:case T.BitMapEraser:case T.Selector:this.eventTragetElement&&(this.eventTragetElement.className=e&&t?`netless-whiteboard ${n===T.Selector?"cursor-selector":n===T.Text?"cursor-text":n===T.Eraser||n===T.PencilEraser||n===T.BitMapEraser?"cursor-eraser":n===T.Pencil||n===T.LaserPen?"cursor-pencil":"cursor-arrow"}`:"netless-whiteboard");break}}mountView(){this.setCanvassStyle(),this.control.viewContainerManager.mountView(this.viewId)}updateSize(){this.setCanvassStyle(),this.reflashContainerOffset()}reflashContainerOffset(){this.eventTragetElement&&(this.containerOffset=this.getContainerOffset(this.eventTragetElement,{x:0,y:0}))}get parentElement(){var n;return(n=this.eventTragetElement)==null?void 0:n.parentElement}destroy(){this.eventTragetElement&&this.removeDisplayerEvent(this.eventTragetElement),this.vDom=void 0,this.control.cursor.clearViewCursor(this.viewId),this.internalMsgEmitter.removeAllListeners([_.Cursor,this.viewId])}getPoint(n){const e=Wr(n);if(e&&x.isNumber(e.x)&&x.isNumber(e.y))return[e.x-this.containerOffset.x,e.y-this.containerOffset.y]}getActive(){return this.active}setActive(n){this.active=n,this.control.isUseBackgroundThread&&this.backgroundContainerRef&&this.backgroundContainerRef.current&&this.backgroundContainerRef.current.classList.toggle("appliance-plugin-background-isWritable",n)}focusElement(){var n;(n=this.eventTragetElement)==null||n.focus()}async stopEventHandler(){this.cachePoint&&(await this.worker.originalEventLintener(j.Done,this.cachePoint,this.viewId).finally(()=>{document.removeEventListener("pointermove",this.pointermove,!1),document.removeEventListener("pointerup",this.pointerup,!1),document.removeEventListener("pointercancel",this.pointerup,!1)}),this.cachePoint=void 0,this.activePointers.clear(),this.currentDrawingPointerId=void 0)}getTranslate(n){const t=(n.style.WebkitTransform||getComputedStyle(n,"").getPropertyValue("-webkit-transform")||n.style.transform||getComputedStyle(n,"").getPropertyValue("transform")).match(/-?[0-9]+\.?[0-9]*/g),i=t&&parseInt(t[0])||0,o=t&&parseInt(t[1])||0;return[i,o]}getContainerOffset(n,e){var o;const t=this.getTranslate(n);let i={x:e.x+n.offsetLeft-n.scrollLeft+t[0],y:e.y+n.offsetTop-n.scrollTop+t[1]};return(o=n.offsetParent)!=null&&o.nodeName&&n.offsetParent.nodeName!=="BODY"&&(i=this.getContainerOffset(n.offsetParent,i)),i}bindDisplayerEvent(n){n.addEventListener("pointerdown",this.pointerdown,!1),n.addEventListener("mousemove",this.cursorMouseMove,!1),n.addEventListener("mouseleave",this.cursorMouseLeave,!1),n.addEventListener("keydown",this.keydown,!0)}removeDisplayerEvent(n){n.removeEventListener("pointerdown",this.pointerdown,!1),document.removeEventListener("pointermove",this.pointermove,!1),document.removeEventListener("pointerup",this.pointerup,!1),document.removeEventListener("pointerleave",this.pointerup,!1),n.removeEventListener("mousemove",this.cursorMouseMove,!1),n.removeEventListener("mouseleave",this.cursorMouseLeave,!1),n.removeEventListener("keydown",this.keydown,!0)}get isBezier(){return this.control.pluginOptions.extras.bezier.enable}get maxDrawCount(){return this.control.pluginOptions.extras.bezier.maxDrawCount||me.bezier.maxDrawCount}checkConsumeCount(){const n=this.worker.getConsumeCount();return this.cachePoint&&this.toolsKey&&this.toolsKey===T.Pencil&&n>this.maxDrawCount?(this.stopEventHandler().finally(()=>{this.worker.publicMsgEmitter.emit("forceStop",Fn.longPencil,this.viewId)}),!0):!1}}class Ny extends Vr{constructor(e,t,i){super(t,i,e);I(this,"_viewId");this._viewId=e}get viewId(){return this._viewId}setViewId(e){this._viewId=e}}class Fr extends Vr{constructor(n,e){super(n,e,ge)}get viewId(){return ge}updateSize(){this.setCanvassStyle()}destroy(){super.destroy(),this.control.cursor.destroy()}}const vy="index-module__Container__nLsM3",Cy="index-module__BackgroundBox__zfthZ",Sy="index-module__BackgroundSvgBox__Fv1ay",ky="index-module__BackgroundSnapshotContent__NFLAl",xy="index-module__BackgroundSnapshotBox__NEM-C",jy="index-module__CanvasBox__j2Xe-",Dy="index-module__FloatCanvas__d1YR7",by="index-module__TopFloatCanvas__7IaCw",Ay="index-module__CanvasBoxSub__hcMeK",zy="index-module__SnapshotBox__--eeE",Ey="index-module__FloatBar__cm-EL",Ly="index-module__RotateBtn__HSSkf",Py="index-module__ResizeBtn__yjvda",Oy="index-module__CursorBox__2UHvI",Ry="index-module__TextEditorContainer__Qm8KC",Yy="index-module__ResizeTowBox__HOllX",Uy="index-module__FloatBarBtn__FJrOG",Te={Container:vy,BackgroundBox:Cy,BackgroundSvgBox:Sy,BackgroundSnapshotContent:ky,BackgroundSnapshotBox:xy,CanvasBox:jy,FloatCanvas:Dy,TopFloatCanvas:by,CanvasBoxSub:Ay,SnapshotBox:zy,FloatBar:Ey,RotateBtn:Ly,ResizeBtn:Py,CursorBox:Oy,TextEditorContainer:Ry,ResizeTowBox:Yy,FloatBarBtn:Uy},By={delete:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDZ2NmEyIDIgMCAwIDEtMiAySDZhMiAyIDAgMCAxLTItMlY2aDBtMS0yYTIgMiAwIDAgMSAyLTJoMmEyIDIgMCAwIDEgMiAyaDBNMyA0aDEwIiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==",duplicate:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjxwYXRoIGQ9Ik0xMSAySDZhMSAxIDAgMCAwLTEgMXY4YTEgMSAwIDAgMCAxIDFoNmExIDEgMCAwIDAgMS0xVjRoMGwtMi0yeiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+PHBhdGggZD0iTTExIDJ2MWExIDEgMCAwIDAgMSAxaDFsLTItMnoiLz48cGF0aCBkPSJNOSAxNEg0YTEgMSAwIDAgMS0xLTFWNWgwIiBzdHJva2UtbGluZWNhcD0icm91bmQiLz48L2c+PC9zdmc+","layer-pressed":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTE2IDEwLTYgNCA2IDQgNi00em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MC0yLjA4Ny01LjAzOEE3LjEwMyA3LjEwMyAwIDAgMCAxMiA0Ljg3NWE3LjEwMyA3LjEwMyAwIDAgMC01LjAzOCAyLjA4NyA3LjEwMSA3LjEwMSAwIDAgMC0yLjA4NiA0LjkyIDcuMTAzIDcuMTAzIDAgMCAwIDEuNzY2IDQuODE1bDEuOTQ1LTEuNTg0IDIuMzk0IDcuMTgyLTcuMjIyLTIuNDA4IDEuNzkxLTEuNzlBOC44NDYgOC44NDYgMCAwIDEgMy4xMjUgMTJjMC0yLjI3MS44NjYtNC41NDMgMi42LTYuMjc2eiIgc3Ryb2tlPSIjRkZGIiBzdHJva2Utd2lkdGg9Ii41IiBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L2c+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+PHBhdGggZD0iTTEyIDEwdjhtMC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9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","underline-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDJ2NWE0IDQgMCAxIDEtOCAwVjJoME0zIDE0aDEwIiBzdHJva2U9IiMzMzgxRkYiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==",underline:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDJ2NWE0IDQgMCAxIDEtOCAwVjJoME0zIDE0aDEwIiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","line-through-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQgOGg4bS0xLTNhMyAzIDAgMCAwLTMtM2gtLjkzOEEyLjY0IDIuNjQgMCAwIDAgNC41IDRhMi41NyAyLjU3IDAgMCAwIDEuMzQ0IDIuOTIybDQuMzEyIDIuMTU2QTIuNTcgMi41NyAwIDAgMSAxMS41IDEyYTIuNjQgMi42NCAwIDAgMS0yLjU2MiAySDdhMyAzIDAgMCAxLTMtM2gwIiBzdHJva2U9IiMzMzgxRkYiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","line-through":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTQgOGg4bS0xLTNhMyAzIDAgMCAwLTMtM2gtLjkzOEEyLjY0IDIuNjQgMCAwIDAgNC41IDRhMi41NyAyLjU3IDAgMCAwIDEuMzQ0IDIuOTIybDQuMzEyIDIuMTU2QTIuNTcgMi41NyAwIDAgMSAxMS41IDEyYTIuNjQgMi42NCAwIDAgMS0yLjU2MiAySDdhMyAzIDAgMCAxLTMtM2gwIiBzdHJva2U9IiM0NDRFNjAiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==","italic-active":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTcgMTQgOSAyTTUgMTRoNE03IDJoNCIgc3Ryb2tlPSIjMzM4MUZGIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=",italic:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTcgMTQgOSAyTTUgMTRoNE03IDJoNCIgc3Ryb2tlPSIjNDQ0RTYwIiBmaWxsPSJub25lIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=","unlock-new":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZ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MzNCA0NS4yMjY2NjctNDUuMjI2NjY3LTg1LjMzMzMzMy04NS4zMzMzMzMtNDUuMjI2NjY3IDQ1LjIyNjY2NnogbTAtNDUuMjI2NjY2bC04NS4zMzMzMzMgODUuMzMzMzMzIDQ1LjIyNjY2NiA0NS4yMjY2NjcgODUuMzMzMzM0LTg1LjMzMzMzNC00NS4yMjY2NjctNDUuMjI2NjY2eiIgIGZpbGw9IiM0NDRFNjAiPjwvcGF0aD48L3N2Zz4="};function be(r){return By[r]}const Wy=r=>{const{workIds:n,mananger:e}=r;return d.createElement("div",{className:"button normal-button",style:{touchAction:"none"},onPointerUp:t=>{t.cancelable&&t.preventDefault(),t.stopPropagation(),t.nativeEvent.stopImmediatePropagation(),re.emitMethod(_.MainEngine,W.DeleteNode,{workIds:n||[Z],viewId:e.viewId})}},d.createElement("img",{alt:"icon",src:be("delete")}))},Vy=r=>{const{workIds:n,viewId:e}=r;return d.createElement("div",{className:"button normal-button",onPointerUp:t=>{t.stopPropagation(),re.emitMethod(_.MainEngine,W.CopyNode,{workIds:n||[Z],viewId:e})}},d.createElement("img",{alt:"icon",src:be("duplicate")}))},Hi=r=>{const{icon:n,onPointerUpHandler:e}=r;return d.createElement("div",{className:"button normal-button",onPointerUp:e},d.createElement("img",{src:be(n)}))},Fy=r=>{const{open:n,setOpen:e,floatBarRef:t}=r,{floatBarData:i,mananger:o}=d.useContext(ye),[s,a]=d.useState([]),c=d.useMemo(()=>{if(t!=null&&t.current&&x.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=d.useMemo(()=>n?d.createElement("div",{className:"image-layer-menu",style:c},d.createElement(Hi,{icon:"to-top",onPointerUpHandler:u=>{u.stopPropagation(),re.emitMethod(_.MainEngine,W.ZIndexNode,{workIds:[Z],layer:Ct.Top,viewId:o==null?void 0:o.viewId})}}),d.createElement(Hi,{icon:"to-bottom",onPointerUpHandler:u=>{u.stopPropagation(),re.emitMethod(_.MainEngine,W.ZIndexNode,{workIds:[Z],layer:Ct.Bottom,viewId:o==null?void 0:o.viewId})}})):null,[n,c]),h=u=>{u.stopPropagation(),u.nativeEvent.stopImmediatePropagation(),e(!n)};return d.useEffect(()=>{x.isEqual(i==null?void 0:i.selectIds,s)||i!=null&&i.selectIds&&!x.isEqual(i==null?void 0:i.selectIds,s)&&(a(i==null?void 0:i.selectIds),e(!1))},[n,i,s,e]),d.createElement("div",{className:`button normal-button ${n&&"active"}`,onPointerUp:h},l,d.createElement("img",{alt:"icon",src:be(n?"layer-pressed":"layer")}))},$t=r=>{r.stopPropagation(),r.nativeEvent.stopImmediatePropagation()},Qy=()=>d.createElement("svg",{style:{marginLeft:"2px"},viewBox:"0 0 1025 1024",width:"14",height:"14"},d.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"})),Qr=r=>{const{activeColor:n,onPointerUpHandler:e}=r;return d.createElement("div",{className:`font-color-button ${n==="transparent"?"active":""}`,onPointerUp:e},d.createElement("div",{className:"circle none"}))},yn=r=>{const{color:n,activeColor:e,onPointerUpHandler:t}=r;return d.createElement("div",{className:`font-color-button ${n===e?"active":""}`,onPointerUp:t},d.createElement("div",{className:"circle",style:{backgroundColor:xe(n,1)}}))},mn=r=>{const{opacity:n,activeColor:e,setCurOpacity:t}=r,[i,o]=d.useState({x:108,y:0}),s=d.useRef(0);if(d.useEffect(()=>{o({x:n*100+8,y:0})},[]),!e)return null;const a=(u,f)=>{const p=Math.min(Math.max(u-8,0),100)/100;(n!==p||f===j.Done)&&t(p,e,f)},c=(u,f)=>{f.x!==(i==null?void 0:i.x)&&o({x:f.x,y:0}),!s.current&&(s.current=setTimeout(()=>{s.current=0,a(f.x,j.Doing)},100))},l=()=>{t(n,e,j.Start)},h=(u,f)=>{f.x!==(i==null?void 0:i.x)&&o({x:f.x,y:0}),s.current&&(clearTimeout(s.current),s.current=0),a(f.x,j.Done)};return d.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onPointerUp:u=>{s.current&&(clearTimeout(s.current),s.current=0);const f=u.nativeEvent.offsetX,p=Math.min(Math.max(f-12,0),100)/100;o({x:p*100+8,y:0}),t(p,e,j.Done)}},d.createElement("div",{className:"range-color",style:{background:`linear-gradient(to right, ${xe(e,0)}, ${xe(e,1)})`}}),d.createElement("div",{className:"range-opacity"},d.createElement(xt,{bounds:"parent",axis:"x",position:i,onDrag:c,onStart:l,onStop:h},d.createElement("div",{className:"circle",style:{backgroundColor:xe(e,n)},onPointerUp:$t}))))},Gy=r=>{const{min:n,max:e,activeNumber:t,setActiveNumber:i,color:o}=r,[s,a]=d.useState({x:108,y:0}),c=d.useRef(0);if(d.useEffect(()=>{const p=Math.ceil((t-n)/(e-n)*100)+8;a({x:p,y:0})},[]),!t)return null;const l=(p,g)=>{const m=Math.ceil(Math.max(p-8,0)/100*(e-n)+n);(t!==m||g===j.Done)&&i(m,g)},h=(p,g)=>{g.x!==(s==null?void 0:s.x)&&a({x:g.x,y:0}),!c.current&&(c.current=setTimeout(()=>{c.current=0,l(g.x,j.Doing)},100))},u=()=>{i(t,j.Start)},f=(p,g)=>{g.x!==(s==null?void 0:s.x)&&a({x:g.x,y:0}),c.current&&(clearTimeout(c.current),c.current=0),l(g.x,j.Done)};return d.createElement("div",{className:"font-color-opacity",style:{marginLeft:"10px"},onPointerUp:p=>{c.current&&(clearTimeout(c.current),c.current=0);const g=p.nativeEvent.offsetX,m=Math.ceil(Math.max(g-12,0)/100*(e-n)+n),w=Math.ceil((m-n)/(e-n)*100)+8;a({x:w,y:0}),i(m,j.Done)}},d.createElement("div",{className:"range-color",style:{backgroundColor:o}}),d.createElement("div",{className:"range-opacity"},d.createElement(xt,{bounds:"parent",axis:"x",position:s,onDrag:h,onStart:u,onStop:f},d.createElement("div",{className:"circle",style:{backgroundColor:o},onPointerUp:$t},d.createElement("div",{className:"range-opacity-data-icon"},t)))))},Zy=r=>{const{useStroke:n,color:e,activeStrokeType:t,setStrokeType:i}=r;return d.createElement("div",{className:"stroke-type-box"},!!n&&d.createElement("div",{className:`stroke-type-box-item Stroke ${t===de.Stroke&&"active"}`,style:{backgroundColor:e},onPointerUp:()=>{i(de.Stroke)}}),d.createElement("div",{className:`stroke-type-box-item Normal ${t===de.Normal&&"active"}`,style:{borderColor:e},onPointerUp:()=>{i(de.Normal)}}),d.createElement("div",{className:`stroke-type-box-item Dotted ${t===de.Dotted&&"active"}`,style:{borderColor:e},onPointerUp:()=>{i(de.Dotted)}}),d.createElement("div",{className:`stroke-type-box-item LongDotted ${t===de.LongDotted&&"active"}`,style:{borderColor:e},onPointerUp:()=>{i(de.LongDotted)}}))},$y=r=>{const{open:n,setOpen:e,floatBarRef:t}=r,{floatBarData:i,floatBarColors:o,mananger:s,setFloatBarData:a}=d.useContext(ye),[c,l]=d.useState(),[h,u]=d.useState(1);d.useEffect(()=>{if(i!=null&&i.strokeColor){const[M,v]=fn(i.strokeColor);l(M),u(v)}},[i]);const f=d.useMemo(()=>{if(t!=null&&t.current&&i&&x.isNumber(i==null?void 0:i.y)&&(s!=null&&s.height)){if(t.current.offsetTop&&t.current.offsetTop+i.y>180){const M={};return M.top="inherit",M.bottom=50,M}else if(!t.current.offsetTop&&(s==null?void 0:s.height)-t.current.offsetTop-i.y<120){const M={};return M.top="inherit",M.bottom=50,M}}},[i,t,s==null?void 0:s.height]),p=d.useMemo(()=>d.createElement(mn,{key:"strokeColors",opacity:h,activeColor:c,setCurOpacity:(M,v,S)=>{u(M);const C=xe(v,M);i!=null&&i.strokeColor&&a({strokeColor:C}),re.emitMethod(_.MainEngine,W.SetColorNode,{workIds:[Z],strokeColor:C,workState:S,viewId:s==null?void 0:s.viewId})}}),[h,c,i==null?void 0:i.strokeColor,s==null?void 0:s.viewId,a]),g=d.useMemo(()=>c&&i&&i.thickness?d.createElement(Gy,{key:"strokeThickness",min:Math.min(i.thickness,(s==null?void 0:s.control.pluginOptions.extras.strokeWidth.min)||me.strokeWidth.min),max:Math.max(i.thickness,(s==null?void 0:s.control.pluginOptions.extras.strokeWidth.max)||me.strokeWidth.max),activeNumber:i.thickness,setActiveNumber:(M,v)=>{i!=null&&i.thickness&&a({thickness:M}),re.emitMethod(_.MainEngine,W.SetColorNode,{workIds:[Z],thickness:M,workState:v,viewId:s==null?void 0:s.viewId})},color:c}):null,[c,i,s==null?void 0:s.control.pluginOptions.extras.strokeWidth.max,s==null?void 0:s.control.pluginOptions.extras.strokeWidth.min,s==null?void 0:s.viewId,a]),m=d.useMemo(()=>c&&i&&(i!=null&&i.strokeType)?d.createElement(Zy,{key:"strokeType",useStroke:i==null?void 0:i.useStroke,activeStrokeType:i.strokeType,setStrokeType:M=>{i.strokeType&&a({strokeType:M}),re.emitMethod(_.MainEngine,W.SetColorNode,{workIds:[Z],strokeType:M,workState:j.Done,viewId:s==null?void 0:s.viewId})},color:c}):null,[c,i,s==null?void 0:s.viewId,a]),w=d.useMemo(()=>n?d.createElement("div",{className:"font-colors-menu",style:f,onPointerUp:M=>{M.stopPropagation(),M.nativeEvent.stopImmediatePropagation()}},m,g,d.createElement("div",{className:"font-colors-line"}),o.concat().map((M,v)=>{const S=Zt(...M);return d.createElement(yn,{key:v,color:S,activeColor:c,onPointerUpHandler:C=>{C.stopPropagation(),l(S);const k=xe(S,h);i!=null&&i.strokeColor&&(i.strokeColor=k,a({strokeColor:k})),re.emitMethod(_.MainEngine,W.SetColorNode,{workIds:[Z],workState:j.Done,strokeColor:k,viewId:s==null?void 0:s.viewId})}})}),p):null,[n,f,m,g,o,p,c,h,i,s==null?void 0:s.viewId,a]),y=d.useMemo(()=>c?d.createElement("div",{className:"color-bar-ring",style:{backgroundColor:xe(c,h)}},d.createElement("div",{className:"circle"})):null,[c,h]);return d.createElement("div",{className:`button normal-button font-colors-icon ${n&&"active"}`,onPointerUp:M=>{M.stopPropagation(),M.nativeEvent.stopImmediatePropagation(),e(!n)}},y,w)},Hy=r=>{const{open:n,setOpen:e,floatBarRef:t}=r,{floatBarData:i,floatBarColors:o,mananger:s,setFloatBarData:a}=d.useContext(ye),[c,l]=d.useState(),[h,u]=d.useState(1);d.useEffect(()=>{if(i!=null&&i.fillColor){const[w,y]=(i==null?void 0:i.fillColor)==="transparent"&&["transparent",1]||fn(i.fillColor);l(w),u(y)}},[i]);const f=d.useMemo(()=>{if(t!=null&&t.current&&x.isNumber(i==null?void 0:i.y)&&(s!=null&&s.height)){if(t.current.offsetTop&&t.current.offsetTop+i.y>200){const w={};return w.top="inherit",w.bottom=50,w}else if(!t.current.offsetTop&&(s==null?void 0:s.height)-t.current.offsetTop-i.y<140){const w={};return w.top="inherit",w.bottom=50,w}}},[t,i,s==null?void 0:s.height]),p=d.useMemo(()=>c&&c!=="transparent"?d.createElement(mn,{key:"fillColors",opacity:h||0,activeColor:c,setCurOpacity:(w,y,M)=>{u(w);const v=xe(y,w);i!=null&&i.fillColor&&(i.fillColor=v,a({fillColor:v})),re.emitMethod(_.MainEngine,W.SetColorNode,{workIds:[Z],fillColor:c&&xe(y,w),workState:M,viewId:s==null?void 0:s.viewId})}}):null,[c,h,i,s==null?void 0:s.viewId,a]),g=d.useMemo(()=>n?d.createElement("div",{className:"font-colors-menu",style:f,onPointerUp:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation()}},d.createElement(Qr,{activeColor:c,onPointerUpHandler:w=>{w.stopPropagation(),l("transparent");const y="transparent";i!=null&&i.fillColor&&(i.fillColor=y,a({fillColor:y})),re.emitMethod(_.MainEngine,W.SetColorNode,{workIds:[Z],workState:j.Done,fillColor:y,viewId:s==null?void 0:s.viewId})}}),o.map((w,y)=>{const M=Zt(...w);return d.createElement(yn,{key:y,color:M,activeColor:c,onPointerUpHandler:v=>{v.cancelable&&v.preventDefault(),v.stopPropagation(),l(M);const S=xe(M,h);i!=null&&i.fillColor&&(i.fillColor=S,a({fillColor:S})),re.emitMethod(_.MainEngine,W.SetColorNode,{workIds:[Z],workState:j.Done,fillColor:S,viewId:s==null?void 0:s.viewId})}})}),p):null,[n,f,c,o,p,i,s==null?void 0:s.viewId,a,h]),m=d.useMemo(()=>{const w=c&&c!=="transparent"&&xe(c,h)||"transparent";return d.createElement("div",{className:"color-bar-fill"},d.createElement("div",{className:"circle",style:{backgroundColor:w}}))},[c,h]);return d.createElement("div",{className:`button normal-button font-colors-icon ${n&&"active"}`,onPointerUp:w=>{w.stopPropagation(),w.nativeEvent.stopImmediatePropagation(),e(!n)}},m,g)},Jy=r=>{const{open:n,setOpen:e,textOpt:t,workIds:i,floatBarRef:o}=r,{floatBarColors:s,mananger:a,setFloatBarData:c,floatBarData:l}=d.useContext(ye),[h,u]=d.useState(),[f,p]=d.useState(1);d.useEffect(()=>{if(t!=null&&t.fontColor){const[M,v]=(t==null?void 0:t.fontColor)==="transparent"&&["transparent",0]||fn(t.fontColor);u(M),p(v)}},[t==null?void 0:t.fontColor]);const g=d.useMemo(()=>{if(o!=null&&o.current&&l&&x.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(o.current.offsetTop&&o.current.offsetTop+l.y>180){const M={};return M.top="inherit",M.bottom=50,M}else if(!o.current.offsetTop&&(a==null?void 0:a.height)-o.current.offsetTop-l.y<120){const M={};return M.top="inherit",M.bottom=50,M}}},[o,l,a==null?void 0:a.height]),m=d.useMemo(()=>h&&h!=="transparent"?d.createElement(mn,{key:"fontColors",opacity:f,activeColor:h,setCurOpacity:(M,v,S)=>{p(M);const C=xe(v,M);l!=null&&l.textOpt&&(l.textOpt.fontColor=C,c({textOpt:l.textOpt})),re.emitMethod(_.MainEngine,W.SetColorNode,{workIds:i||[Z],fontColor:h&&C,workState:S,viewId:a==null?void 0:a.viewId})}}):null,[c,h,f,a==null?void 0:a.control.room,a==null?void 0:a.viewId,l==null?void 0:l.textOpt,i]),w=d.useMemo(()=>n?d.createElement("div",{className:"font-colors-menu",style:g,onPointerUp:M=>{M.stopPropagation(),M.nativeEvent.stopImmediatePropagation()}},s.map((M,v)=>{const S=Zt(...M);return d.createElement(yn,{key:v,color:S,activeColor:h,onPointerUpHandler:C=>{C.stopPropagation(),u(S);const k=xe(S,f);l!=null&&l.textOpt&&(l.textOpt.fontColor=k,c({textOpt:l.textOpt})),re.emitMethod(_.MainEngine,W.SetColorNode,{workIds:i||[Z],workState:j.Done,fontColor:k,viewId:a==null?void 0:a.viewId})}})}),m):null,[c,n,s,m,h,f,l==null?void 0:l.textOpt,i,a==null?void 0:a.viewId,g]),y=d.useMemo(()=>{const M=h&&h!=="transparent"&&xe(h,f)||"transparent";return d.createElement("div",{className:"color-bar"},d.createElement("div",{className:"color-bar-color",style:{backgroundColor:M}}))},[h,f]);return d.createElement("div",{className:`button normal-button font-colors-icon ${n&&"active"}`,onPointerUp:M=>{M.stopPropagation(),M.nativeEvent.stopImmediatePropagation(),e(!n)}},d.createElement("img",{alt:"icon",src:be("font-colors")}),y,w)},Xy=r=>{const{open:n,setOpen:e,textOpt:t,workIds:i,floatBarRef:o}=r,{floatBarColors:s,mananger:a,setFloatBarData:c,floatBarData:l}=d.useContext(ye),[h,u]=d.useState(),[f,p]=d.useState(1);d.useEffect(()=>{if(t!=null&&t.fontBgColor){const[M,v]=(t==null?void 0:t.fontBgColor)==="transparent"&&["transparent",1]||fn(t.fontBgColor);u(M),p(v)}},[t==null?void 0:t.fontBgColor]);const g=d.useMemo(()=>{if(o!=null&&o.current&&l&&x.isNumber(l==null?void 0:l.y)&&(a!=null&&a.height)){if(o.current.offsetTop&&o.current.offsetTop+l.y>180){const M={};return M.top="inherit",M.bottom=50,M}else if(!o.current.offsetTop&&(a==null?void 0:a.height)-o.current.offsetTop-l.y<120){const M={};return M.top="inherit",M.bottom=50,M}}},[o,l,a==null?void 0:a.height]),m=d.useMemo(()=>h&&h!=="transparent"?d.createElement(mn,{key:"fontBgColor",opacity:f||0,activeColor:h,setCurOpacity:(M,v,S)=>{p(M);const C=xe(v,M);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=C,c({textOpt:l.textOpt})),re.emitMethod(_.MainEngine,W.SetColorNode,{workIds:i||[Z],fontBgColor:h&&xe(v,M),workState:S,viewId:a==null?void 0:a.viewId})}}):null,[h,f,l==null?void 0:l.textOpt,i,a==null?void 0:a.viewId,c]),w=d.useMemo(()=>n?d.createElement("div",{className:"font-colors-menu",style:g,onPointerUp:M=>{M.stopPropagation(),M.nativeEvent.stopImmediatePropagation()}},d.createElement(Qr,{activeColor:h,onPointerUpHandler:M=>{M.stopPropagation();const v="transparent";u(v),l!=null&&l.textOpt&&(l.textOpt.fontBgColor=v,c({textOpt:l.textOpt})),re.emitMethod(_.MainEngine,W.SetColorNode,{workIds:i||[Z],workState:j.Done,fontBgColor:v,viewId:a==null?void 0:a.viewId})}}),s.map((M,v)=>{const S=Zt(...M);return d.createElement(yn,{key:v,color:S,activeColor:h,onPointerUpHandler:C=>{C.stopPropagation(),u(S);const k=xe(S,f);l!=null&&l.textOpt&&(l.textOpt.fontBgColor=k,c({textOpt:l.textOpt})),re.emitMethod(_.MainEngine,W.SetColorNode,{workIds:i||[Z],workState:j.Done,fontBgColor:xe(S,f),viewId:a==null?void 0:a.viewId})}})}),m):null,[c,n,s,m,f,h,l==null?void 0:l.textOpt,i,a==null?void 0:a.viewId,g]),y=d.useMemo(()=>{const M=h&&h!=="transparent"&&xe(h,f)||"transparent";return d.createElement("div",{className:"color-bar",style:{marginTop:0}},d.createElement("div",{className:"color-bar-color",style:{backgroundColor:M}}))},[h,f]);return d.createElement("div",{className:`button normal-button font-colors-icon ${n&&"active"}`,onPointerUp:M=>{M.stopPropagation(),M.nativeEvent.stopImmediatePropagation(),e(!n)}},d.createElement(Qy,null),y,w)},qy=r=>{const{bold:n,setBold:e,workIds:t,viewId:i}=r,o=s=>{const a=n==="bold"?"normal":"bold";s==null||s.stopPropagation(),e(a),re.emitMethod(_.MainEngine,W.SetFontStyle,{workIds:t,viewId:i,bold:a})};return d.createElement("div",{className:"font-style-button",onPointerUp:o},d.createElement("img",{alt:"icon",src:be(n==="bold"?"bold-active":"bold")}))},Ky=r=>{const{underline:n,setUnderline:e,workIds:t,viewId:i}=r,o=s=>{const a=!n;s==null||s.stopPropagation(),e(a),re.emitMethod(_.MainEngine,W.SetFontStyle,{workIds:t,viewId:i,underline:a})};return d.createElement("div",{className:"font-style-button",onPointerUp:o},d.createElement("img",{alt:"icon",src:be(n?"underline-active":"underline")}))},_y=r=>{const{lineThrough:n,setLineThrough:e,workIds:t,viewId:i}=r,o=s=>{const a=!n;s==null||s.stopPropagation(),e(a),re.emitMethod(_.MainEngine,W.SetFontStyle,{workIds:t,viewId:i,lineThrough:a})};return d.createElement("div",{className:"font-style-button",onPointerUp:o},d.createElement("img",{alt:"icon",src:be(n?"line-through-active":"line-through")}))},em=r=>{const{italic:n,setItalic:e,workIds:t,viewId:i}=r,o=s=>{const a=n==="italic"?"normal":"italic";s==null||s.stopPropagation(),e(a),re.emitMethod(_.MainEngine,W.SetFontStyle,{workIds:t,viewId:i,italic:a})};return d.createElement("div",{className:"font-style-button",onPointerUp:o},d.createElement("img",{alt:"icon",src:be(n==="italic"?"italic-active":"italic")}))},tm=r=>{const{open:n,setOpen:e,textOpt:t,workIds:i,style:o,floatBarRef:s}=r,{mananger:a,floatBarData:c}=d.useContext(ye),[l,h]=d.useState("normal"),[u,f]=d.useState("normal"),[p,g]=d.useState(!1),[m,w]=d.useState(!1);d.useEffect(()=>{t!=null&&t.bold&&h(t.bold),x.isBoolean(t==null?void 0:t.underline)&&g(t.underline||!1),x.isBoolean(t==null?void 0:t.lineThrough)&&w(t.lineThrough||!1),t!=null&&t.italic&&f(t.italic)},[t]);const y=d.useMemo(()=>{if(o&&(s!=null&&s.current)&&x.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(s.current.offsetTop&&s.current.offsetTop+c.y>180){const v={};return v.top="inherit",v.bottom=50,v}else if(!s.current.offsetTop&&(a==null?void 0:a.height)-s.current.offsetTop-c.y<120){const v={};return v.top="inherit",v.bottom=50,v}}},[o,s==null?void 0:s.current,c,a]),M=d.useMemo(()=>n?d.createElement("div",{className:"font-style-menu",style:y,onPointerUp:v=>{v.stopPropagation(),v.nativeEvent.stopImmediatePropagation()}},d.createElement(qy,{workIds:i||[Z],bold:l,setBold:h,viewId:a==null?void 0:a.viewId}),d.createElement(Ky,{workIds:i||[Z],underline:p,setUnderline:g,viewId:a==null?void 0:a.viewId}),d.createElement(_y,{workIds:i||[Z],lineThrough:m,setLineThrough:w,viewId:a==null?void 0:a.viewId}),d.createElement(em,{workIds:i||[Z],italic:u,setItalic:f,viewId:a==null?void 0:a.viewId})):null,[n,i,l,a==null?void 0:a.viewId,p,m,u,y]);return d.createElement("div",{className:`button normal-button ${n&&"active"}`,onPointerUp:v=>{v.stopPropagation(),v.nativeEvent.stopImmediatePropagation(),e(!n)}},d.createElement("img",{alt:"icon",src:be(n?"font-style-active":"font-style")}),M)},Ze=Object.freeze([12,14,18,24,36,48,64,80,144,288]),wt=["top","topLeft","topRight","bottom","bottomLeft","bottomRight","left","leftTop","leftBottom","right","rightTop","rightBottom"],nm=new Map([["selector","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAKeSURBVHgB3VTLi1JhFD86zlQ4ysxSXAy1GWYZzMxmYAhHagRB/QN8FLqPFq4FIQhXkS6kTQ4t2ilIKEWgSS0SmVpIm0BdaBJSaOP78XU+PXey6+saburAD+73uL/feX0H4H81GQdj7D7ilrCGFRonk3c6nXvhcJiFQiGWy+Xy/X7/WbPZ1K1KkBOsl0qlO36/n+3t7Q1hs9kYF+WC3W73MTpxc1lBmej7KuJaoVDInZ6eqsWXDw4OwGKxwPHx8Se1Wn1Wr9cjW1tbOTxi9D9bJCJHXEFslsvlR263+246nYZZptPpQK/Xg8lkSvZ6vbNGo5EgQRCLiSPhIqpoNHobo3keCARgkalUKjg5ORlGuL+/n8T6PVAqlefjYmKRdYQSsZ3P5z8aDAYVLGFarRbi8fhbhUKhx2VPEJGP3eEbfTrs4MUwr4EU49FYrVbweDy1SqXyipy95FaI7g8QXS6SyWReHx4e2ubVBc+HtTk6OjqvVqtvvF7vi0gkUiSByyyJ21BGwpswJ2Vmsxlw/0Kj0bxMJBJJl8vFPWkhGogLQoeyMhEJo2jGUzYRjcPh+Op0Oq2pVOoHkXE0SahF/w+E+3KYNEaX2pSyiSiKxeJTFPiGyyriO6FKEUgSESLp4ht4bzQaf4pFYrHYO/ysEXGNyJtjKRqM/zNNhFuf0B7vst3dXdjZ2Yn4fL4vRFwn8jaMGqYPU179LBEGf3bZcNNutwPOtScwKnCLPJ9KLMWEh7mNuIFdVsNXzbBNP+D6Ou1vwAqm8hqMWlmbzWYf4mz6HAwGzbjWwGgqrEklmucJT+UG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9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+"]]),im=r=>{const{style:n,onClickHandler:e}=r;return d.createElement("div",{className:"font-size-menu",style:n,onPointerUp:t=>{t.stopPropagation(),t.nativeEvent.stopImmediatePropagation()}},Ze.map(t=>d.createElement("div",{className:"font-size-btn",key:t,onPointerUp:()=>{e(t)}},t)))},rm=r=>{const n=d.useRef(null),{open:e,setOpen:t,textOpt:i,workIds:o,floatBarRef:s}=r,{mananger:a,floatBarData:c}=d.useContext(ye),[l,h]=d.useState(0),u=Ze.length-1;d.useEffect(()=>{i!=null&&i.fontSize&&(h(i.fontSize),n.current&&(n.current.value=i.fontSize.toString()))},[i==null?void 0:i.fontSize]);const f=d.useMemo(()=>{if(s!=null&&s.current&&x.isNumber(c==null?void 0:c.y)&&(a!=null&&a.height)){if(s.current.offsetTop&&s.current.offsetTop+c.y>180){const y={};return y.top="inherit",y.bottom=35,y}else if(!s.current.offsetTop&&(a==null?void 0:a.height)-s.current.offsetTop-c.y<120){const y={};return y.top="inherit",y.bottom=35,y}}},[s==null?void 0:s.current,c,a]);function p(y){h(y),y&&y>=Ze[0]&&y<=Ze[u]&&re.emitMethod(_.MainEngine,W.SetFontStyle,{workIds:o||[Z],fontSize:y,viewId:a==null?void 0:a.viewId})}const g=y=>{var M;(M=n.current)==null||M.blur(),t(!1),w(y)},m=d.useMemo(()=>e?d.createElement(im,{onClickHandler:g,style:f}):null,[e,g,f]),w=y=>{y>Ze[u]&&(y=Ze[u]),y<Ze[0]&&(y=Ze[0]),p(y)};return d.createElement("div",{className:"button normal-button font-size-barBtn",style:{width:50},onPointerUp:y=>{y.stopPropagation(),y.nativeEvent.stopImmediatePropagation()}},d.createElement("input",{className:"font-size-input",ref:n,onTouchEnd:()=>{n.current&&n.current.focus()},onClick:()=>{t(!e),n.current&&n.current.focus()},onKeyDown:y=>{if(y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),y.key==="Backspace"){const M=window.getSelection(),v=M==null?void 0:M.getRangeAt(0);if(v!=null&&v.collapsed)return y.cancelable&&y.preventDefault(),document.execCommand("delete",!1),!1}return!1},onKeyUp:y=>{var M;if(y.stopPropagation(),y.nativeEvent.stopImmediatePropagation(),n.current){const v=n.current.value,S=parseInt(v);isNaN(S)?n.current.value="0":n.current.value=S.toString(),S&&y.key==="Enter"&&(w(S),(M=n.current)==null||M.blur(),t(!1))}}}),d.createElement("div",{className:"font-size-btns"},d.createElement("div",{className:"font-size-add",onPointerUp:()=>{w(l+Ze[0])}}),d.createElement("div",{className:"font-size-cut",onPointerUp:()=>{w(l-Ze[0])}})),m)},om=r=>{const{workIds:n,mananger:e,islocked:t}=r;return d.createElement("div",{className:"button normal-button",onPointerUp:i=>{i.stopPropagation(),re.emitMethod(_.MainEngine,W.SetLock,{workIds:n||[Z],isLocked:!t,viewId:e==null?void 0:e.viewId})}},d.createElement("img",{alt:"icon",src:be(t?"unlock-new":"lock-new")}))},Un=r=>{const{icon:n,min:e,max:t,step:i,value:o,onInputHandler:s}=r,[a,c]=d.useState(0),l=d.useRef(null),h=u=>{u>t&&(u=t),u<e&&(u=e),c(u),s(u),l.current&&(l.current.value=u.toString())};return d.useEffect(()=>{o&&(c(o),l.current&&(l.current.value=o.toString()))},[o]),d.createElement("div",{className:"button input-button"},d.createElement("img",{src:be(n)}),d.createElement("input",{className:"input-number",type:"text",ref:l,onPointerUp:()=>{l.current&&l.current.focus()},onKeyDown:u=>{if(u.stopPropagation(),u.nativeEvent.stopImmediatePropagation(),u.key==="Backspace"){const f=window.getSelection(),p=f==null?void 0:f.getRangeAt(0);if(p!=null&&p.collapsed)return u.cancelable&&u.preventDefault(),document.execCommand("delete",!1),!1}},onKeyUp:u=>{if(u.stopPropagation(),u.nativeEvent.stopImmediatePropagation(),l.current){const f=l.current.value,p=parseInt(f);isNaN(p)?l.current.value="0":l.current.value=p.toString()}},onChange:u=>{const f=u.target.value,p=parseInt(f);p&&p&&p>=e&&p<=t&&h(p)}}),d.createElement("div",{className:"input-number-btns"},d.createElement("div",{className:"input-number-add",onPointerUp:()=>{h(a+i)}}),d.createElement("div",{className:"input-number-cut",onPointerUp:()=>{h(a-i)}})))},sm=r=>{const{icon:n,min:e,max:t,step:i,value:o,onInputHandler:s}=r;return d.createElement("div",{className:"button input-button"},d.createElement("img",{src:be(n)}),d.createElement(am,{min:e,max:t,step:i,value:o,onInputHandler:s}))},am=r=>{const{value:n,min:e,max:t,onInputHandler:i}=r,[o,s]=d.useState({x:0,y:0});d.useEffect(()=>{s({x:n*100,y:0})},[]);const a=(h,u)=>{let f=Math.floor(Math.max(u.x,e*100));f=Math.floor(Math.min(f,t*100)),u.x!==(o==null?void 0:o.x)&&s({x:f,y:0});const p=f/100;n!==p&&i(p)},c=()=>{},l=(h,u)=>{let f=Math.floor(Math.max(u.x,e*100));f=Math.floor(Math.min(f,t*100)),u.x!==(o==null?void 0:o.x)&&s({x:f,y:0});const p=f/100;n!==p&&i(p)};return d.createElement("div",{className:"range-number-container",onPointerUp:h=>{const u=h.nativeEvent.offsetX-6;let f=Math.floor(Math.max(u,e*100));f=Math.floor(Math.min(f,t*100)),s({x:f,y:0});const p=f/100;n!==p&&i(p)}},d.createElement("div",{className:"range-number-color"}),d.createElement("div",{className:"range-number"},d.createElement(xt,{bounds:"parent",axis:"x",position:o,onDrag:a,onStart:c,onStop:l},d.createElement("div",{className:"circle",onPointerUp:$t}))))},cm=r=>{const{icon:n,value:e,onChangeHandler:t,style:i}=r,[o,s]=d.useState(0),[a,c]=d.useState(),l=d.useRef(null),h=d.useCallback(p=>{p>=wt.length&&(p=0),p<0&&(p=wt.length-1),s(p),t(wt[p]),c(!1),l.current&&(l.current.value=wt[p])},[t]),u=d.useMemo(()=>{if(i&&i.bottom){const p={};return p.top="inherit",p.bottom=50,p}},[i]);d.useEffect(()=>{e&&(s(wt.indexOf(e)),l.current&&(l.current.value=e))},[e]);const f=d.useMemo(()=>a?d.createElement(lm,{options:wt,onClickHandler:h,style:u}):null,[a,h,u]);return d.createElement("div",{className:"button input-button"},d.createElement("img",{src:be(n)}),d.createElement("input",{readOnly:!0,className:"input-number",type:"text",ref:l,onPointerUp:()=>{l.current&&(l.current.focus(),c(!a))}}),d.createElement("div",{className:"input-number-btns"},d.createElement("div",{className:"input-number-add",onPointerUp:()=>{h(o+1)}}),d.createElement("div",{className:"input-number-cut",onPointerUp:()=>{h(o-1)}})),f)},lm=r=>{const{options:n,style:e,onClickHandler:t}=r;return d.createElement("div",{className:"select-option-menu",style:e},n.map((i,o)=>d.createElement("div",{className:"select-option-btn",key:i,onPointerUp:()=>{t(o)}},i)))},um=r=>{const{innerRatio:n,innerVerticeStep:e,vertices:t,mananger:i,setShapeOpt:o}=r,s=l=>{o({vertices:l}),re.emitMethod(_.MainEngine,W.SetShapeOpt,{workIds:[Z],toolsType:T.Star,viewId:i.viewId,vertices:l})},a=l=>{o({innerVerticeStep:l}),re.emitMethod(_.MainEngine,W.SetShapeOpt,{workIds:[Z],toolsType:T.Star,viewId:i.viewId,innerVerticeStep:l})},c=l=>{o({innerRatio:l}),re.emitMethod(_.MainEngine,W.SetShapeOpt,{workIds:[Z],toolsType:T.Star,viewId:i.viewId,innerRatio:l})};return d.createElement(d.Fragment,null,d.createElement(Un,{value:t,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:s}),d.createElement(Un,{value:e,icon:"star-innerVertex",min:1,max:100,step:1,onInputHandler:a}),d.createElement(sm,{value:n,icon:"star-innerRatio",min:.1,max:1,step:.1,onInputHandler:c}))},hm=r=>{const{mananger:n,vertices:e,setShapeOpt:t}=r,i=o=>{t({vertices:o}),re.emitMethod(_.MainEngine,W.SetShapeOpt,{workIds:[Z],toolsType:T.Polygon,viewId:n.viewId,vertices:o})};return d.createElement(Un,{value:e,icon:"polygon-vertex",min:3,max:100,step:1,onInputHandler:i})},dm=r=>{const{mananger:n,placement:e,setShapeOpt:t}=r,i=o=>{t({placement:o}),re.emitMethod(_.MainEngine,W.SetShapeOpt,{workIds:[Z],toolsType:T.SpeechBalloon,viewId:n.viewId,placement:o})};return d.createElement(cm,{value:e,icon:"speechBallon-placement",onChangeHandler:i})},Nn=r=>{const{icon:n,isActive:e,onPointerUpHandler:t}=r;return d.createElement("div",{className:`button tab-button ${e?"active":""}`,onPointerUp:t},d.createElement("img",{src:be(n)}))},gm=r=>{const{toolsTypes:n,style:e,mananger:t,shapeOpt:i,setShapeOpt:o}=r,[s,a]=d.useState();d.useEffect(()=>{n.includes(T.Polygon)?a(T.Polygon):n.includes(T.Star)?a(T.Star):a(T.SpeechBalloon)},[n]);const c=f=>{a(f)},l=d.useMemo(()=>s===T.Polygon&&t&&i.vertices?d.createElement(hm,{vertices:i.vertices,mananger:t,setShapeOpt:o}):null,[t,s,i,o]),h=d.useMemo(()=>s===T.Star&&t&&i.vertices&&i.innerVerticeStep&&i.innerRatio?d.createElement(um,{mananger:t,vertices:i.vertices,innerVerticeStep:i.innerVerticeStep,innerRatio:i.innerRatio,setShapeOpt:o}):null,[t,s,i,o]),u=d.useMemo(()=>s===T.SpeechBalloon&&t&&i.placement?d.createElement(dm,{mananger:t,placement:i.placement,setShapeOpt:o}):null,[s,t,i.placement,o]);return d.createElement("div",{className:"shapeOpt-sub-menu",style:e,onPointerUp:$t},d.createElement("div",{className:"shapeOpt-sub-menu-tabs"},n.includes(T.Polygon)&&d.createElement(Nn,{isActive:s===T.Polygon,icon:s===T.Polygon?"polygon-active":"polygon",onPointerUpHandler:c.bind(void 0,T.Polygon)})||null,n.includes(T.Star)&&d.createElement(Nn,{isActive:s===T.Star,icon:s===T.Star?"star-active":"star",onPointerUpHandler:c.bind(void 0,T.Star)})||null,n.includes(T.SpeechBalloon)&&d.createElement(Nn,{isActive:s===T.SpeechBalloon,icon:s===T.SpeechBalloon?"speechBallon-active":"speechBallon",onPointerUpHandler:c.bind(void 0,T.SpeechBalloon)})||null),d.createElement("div",{className:"shapeOpt-sub-menu-content"},l,h,u))},fm=r=>{const{open:n,setOpen:e,floatBarRef:t,toolsTypes:i,shapeOpt:o}=r,{floatBarData:s,mananger:a,setFloatBarData:c}=d.useContext(ye),l=d.useRef(null),h=d.useMemo(()=>{if(t!=null&&t.current&&x.isNumber(s==null?void 0:s.x)&&x.isNumber(s==null?void 0:s.y)&&(a!=null&&a.height)){if(t.current.offsetTop&&t.current.offsetTop+s.y>200){const g={};return g.top="inherit",g.bottom=50,g}else if(!t.current.offsetTop&&(a==null?void 0:a.height)-t.current.offsetTop-(s==null?void 0:s.y)<140){const g={};return g.top="inherit",g.bottom=50,g}}},[t,s==null?void 0:s.x,s==null?void 0:s.y,a==null?void 0:a.height]),u=d.useCallback(g=>{c({shapeOpt:{...o,...g}})},[c,o]),f=d.useMemo(()=>n&&i&&a&&o?d.createElement(gm,{shapeOpt:o,style:h,toolsTypes:i,mananger:a,setShapeOpt:u}):null,[n,h,i,a,o,u]),p=()=>{e(!n)};return d.createElement("div",{ref:l,className:`button normal-button ${n&&"active"}`,onPointerUp:p},f,d.createElement("img",{alt:"icon",src:be(n?"shapes-active":"shapes")}))},Gr=d.memo(r=>{const{textOpt:n,workIds:e,noLayer:t,position:i,noDelete:o,noCopy:s}=r,{floatBarData:a,mananger:c}=d.useContext(ye),[l,h]=d.useState(0),[u,f]=d.useState(),p=d.useRef(null);d.useEffect(()=>{var L,R,E,O;const N={},z=(a==null?void 0:a.w)||((L=n==null?void 0:n.boxSize)==null?void 0:L[0])||0,P=(a==null?void 0:a.h)||((R=n==null?void 0:n.boxSize)==null?void 0:R[1])||0;if(i&&z&&P&&(c!=null&&c.width)&&(c!=null&&c.height)){if(i.y<60?i.y+P<c.height-60?N.bottom=-120:i.y+P<c.height?N.bottom=-58:i.y>0?N.top=62:N.top=-i.y+62:N.top=0,i.x<0)N.left=-i.x+3;else if(i.x+(((E=p.current)==null?void 0:E.offsetWidth)||z)>c.width){const D=c.width-(((O=p.current)==null?void 0:O.offsetWidth)||z)-i.x;N.left=D}f(N);return}f(void 0)},[p,i,a==null?void 0:a.w,a==null?void 0:a.h,c==null?void 0:c.width,c==null?void 0:c.height,n==null?void 0:n.boxSize]);const g=d.useMemo(()=>a!=null&&a.fillColor?d.createElement(Hy,{floatBarRef:p,open:l===3,setOpen:N=>{h(N===!0?3:0)}}):null,[a==null?void 0:a.fillColor,l,p]),m=d.useMemo(()=>a!=null&&a.strokeColor?d.createElement($y,{floatBarRef:p,open:l===2,setOpen:N=>{h(N===!0?2:0)}}):null,[a==null?void 0:a.strokeColor,l,p]),w=d.useMemo(()=>n!=null&&n.fontColor&&(c!=null&&c.viewId)?d.createElement(Jy,{floatBarRef:p,open:l===4,setOpen:N=>{h(N===!0?4:0)},textOpt:n,workIds:e}):null,[n,l,e,c,p]),y=d.useMemo(()=>n!=null&&n.fontBgColor&&(c!=null&&c.viewId)?d.createElement(Xy,{floatBarRef:p,open:l===5,setOpen:N=>{h(N===!0?5:0)},textOpt:n,workIds:e}):null,[n,l,e,c,p]),M=d.useMemo(()=>n&&(c!=null&&c.viewId)?d.createElement(tm,{floatBarRef:p,open:l===6,setOpen:N=>{h(N===!0?6:0)},textOpt:n,workIds:e,style:u}):null,[n,l,e,c,u,p]),v=d.useMemo(()=>n&&(c!=null&&c.viewId)?d.createElement(rm,{open:l===7,setOpen:N=>{h(N===!0?7:0)},textOpt:n,workIds:e,floatBarRef:p}):null,[n,l,e,c,p]),S=d.useMemo(()=>t?null:d.createElement(Fy,{open:l===1,setOpen:N=>{h(N===!0?1:0)},floatBarRef:p}),[t,l,p]),C=d.useMemo(()=>a!=null&&a.canLock&&c?d.createElement(om,{workIds:e,mananger:c,islocked:a.isLocked}):null,[a,c,e]),k=d.useMemo(()=>c&&(c!=null&&c.viewId)&&u&&(a!=null&&a.shapeOpt)&&(a!=null&&a.toolsTypes)?d.createElement(fm,{open:l===8,setOpen:N=>{h(N===!0?8:0)},floatBarRef:p,workIds:e,toolsTypes:a.toolsTypes,shapeOpt:a.shapeOpt}):null,[a,c,l,u,e,p]);return d.createElement("div",{className:"appliance-plugin-floatbtns",style:u,ref:p},c&&!o&&d.createElement(Wy,{workIds:e,mananger:c}),S,C,!!(c!=null&&c.viewId)&&!s&&d.createElement(Vy,{workIds:e,viewId:c.viewId}),k,M,v,w,y,m,g)}),Mm=r=>{const{data:n,workId:e,updateOptInfo:t,handlePointerDown:i,handlePointerUp:o}=r,{opt:s,scale:a,translate:c,x:l,y:h}=n,u=d.useRef(null),{floatBarData:f}=d.useContext(ye),p=d.useMemo(()=>{const{fontSize:w,fontFamily:y,underline:M,fontColor:v,lineThrough:S,textAlign:C,strokeColor:k,lineHeight:N,bold:z,italic:P}=s,L=N||w*1.2,R={fontSize:`${w}px`,lineHeight:`${L}px`,color:"transparent",caretColor:v,borderColor:k,minHeight:`${L}px`,pointerEvents:"none",paddingRight:`${P==="italic"?Math.round(w*.3):5}px`};return y&&(R.fontFamily=`${y}`),(S||M)&&(R.textDecoration=`${S&&"line-through"||""}${M&&" underline"||""}`),C&&(R.textAlign=`${C}`),z&&(R.fontWeight=`${z}`),P&&(R.fontStyle=`${P}`),R},[s]),g=d.useMemo(()=>{const w=[];if(s.text){const y=gn(s.text);for(let M=0;M<y.length;M++){const v=y[M];v===""?w.push(d.createElement("div",{key:M})):w.push(d.createElement("div",{key:M},v))}}return w.length?w:d.createElement("div",null)},[s.text]),m=d.useMemo(()=>{if(!f)return{};const w=`scale(${a||1}) ${c&&"translate("+c[0]+"px,"+c[1]+"px)"||""}`;return{left:`${l-f.x}px`,top:`${h-f.y}px`,zIndex:1,transform:w,transformOrigin:"left top",opacity:0,pointerEvents:"auto"}},[a,c,l,h,f]);return d.useEffect(()=>{var w,y;if((w=u.current)!=null&&w.offsetWidth&&((y=u.current)!=null&&y.offsetHeight)){const M=s.boxSize;if((M==null?void 0:M[0])!==u.current.offsetWidth||M[1]!==u.current.offsetHeight||!M){const v=[u.current.offsetWidth,u.current.offsetHeight];t({activeTextId:e,update:{boxSize:v,workState:j.Done}})}}},[s.fontSize,s.italic,s.bold,s.boxSize,e,t]),d.createElement("div",{className:"editor-box readonly",style:m,onPointerDown:()=>{i(e)},onPointerUp:()=>{o()}},d.createElement("div",{className:"editor",ref:u,style:p},g))},pm=r=>{const{mananger:n}=d.useContext(ye),e=d.useMemo(()=>{var i;const t=o=>{var h,u;if(!n)return;const{activeTextId:s,update:a,syncData:c}=o,l=s&&x.cloneDeep(((h=n.control.textEditorManager)==null?void 0:h.get(s))||((u=r.editors)==null?void 0:u.get(s)));l&&l.opt&&(l.opt={...l.opt,...a},c&&(l.canSync=Object.keys(c).includes("canSync")&&c.canSync||l.canSync,l.canWorker=Object.keys(c).includes("canWorker")&&c.canWorker||l.canWorker),n.control.textEditorManager.updateForViewEdited(s,l))};if((i=r.editors)!=null&&i.size){const o=[];return r.editors.forEach((s,a)=>{if(r.selectIds&&r.selectIds.includes(a)){const c=d.createElement(Mm,{key:a,workId:a,data:s,updateOptInfo:t,handlePointerDown:r.handleTextEditorPointerDown,handlePointerUp:r.handleTextEditorPointerUp});o.push(c)}}),o}return null},[r.editors,r.selectIds,n]);return d.createElement(d.Fragment,null,e)},ym=r=>{const{position:n,textOpt:e,workIds:t,noLayer:i,noCopy:o,noDelete:s,style:a}=r,c=d.useRef(null);return d.createElement("div",{className:Te.FloatBarBtn,ref:c,style:a},d.createElement(Gr,{position:n,textOpt:e,workIds:t,noLayer:i,noCopy:o,noDelete:s}))},mm=r=>{const{data:n,workId:e,showFloatBtns:t,handleKeyUp:i,handleFocus:o,runAnimation:s,updateSize:a,rightBoundBreak:c}=r,{activeTextEditor:l,activeTextId:h,mananger:u}=d.useContext(ye),{opt:f,scale:p,translate:g,x:m,y:w}=n,{fontSize:y,fontFamily:M,underline:v,fontColor:S,lineThrough:C,textAlign:k,lineHeight:N,bold:z,italic:P}=f,L=d.useRef(null),R=d.useMemo(()=>{const G=y,ie=N||G*1.2,ee={fontSize:`${G}px`,lineHeight:`${ie}px`,caretColor:S,color:"transparent",minHeight:`${ie}px`,paddingRight:`${P==="italic"?Math.round(G*.3):5}px`,borderWidth:0};return M&&(ee.fontFamily=`${M}`),(C||v)&&(ee.textDecoration=`${C&&"line-through"||""} ${v&&" underline"||""}`),k&&(ee.textAlign=`${k}`),z&&(ee.fontWeight=`${z}`),P&&(ee.fontStyle=`${P}`),ee},[z,S,M,y,P,N,C,p,k,v]),E=d.useRef(!1),O=d.useRef(6),D=d.useRef(),V=d.useRef(),J=d.useRef(!1),U=d.useRef({fontSize:R.fontSize,lineHeight:R.lineHeight,fontStyle:R.fontStyle,fontWeight:R.fontWeight,fontFamily:R.fontFamily}),Q=d.useMemo(()=>typeof window>"u"?!1:navigator.maxTouchPoints>0||"ontouchstart"in window,[]),H=d.useMemo(()=>h===e?"hover":f.workState===j.Doing||f.workState===j.Start?"editing":l?"active":"none",[h,e,f.workState,l]);function oe(G){if(!L.current)return;const ee=G&&qt(G.nativeEvent)?Wr(G.nativeEvent):void 0,ue=()=>{D.current&&(cancelAnimationFrame(D.current),D.current=void 0),V.current&&(window.clearTimeout(V.current),V.current=void 0)},he=Ie=>{const Se=L.current,ce=window==null?void 0:window.getSelection();if(!(!Se||!ce||!J.current)){if(document.activeElement!==Se)try{Se.focus({preventScroll:!0})}catch{Se.focus()}if(Ie){const{x:ve,y:Le}=Ie;if(document.caretPositionFromPoint){const le=document.caretPositionFromPoint(ve,Le);if(le){const De=document.createRange();De.setStart(le.offsetNode,le.offset),De.collapse(!0),ce.removeAllRanges(),ce.addRange(De);return}}else if(document.caretRangeFromPoint){const le=document.caretRangeFromPoint(ve,Le);if(le){ce.removeAllRanges(),ce.addRange(le);return}}}Tp(ce,Se)}};ue(),he(ee),Q&&(D.current=requestAnimationFrame(()=>{he(),V.current=window.setTimeout(()=>{he(),V.current=void 0},32),D.current=void 0}))}const ne=d.useMemo(()=>{const G=`scale(${p||1}) ${g&&"translate("+g[0]+"px,"+g[1]+"px)"||""}`;return{left:`${m-An*(p||1)}px`,top:`${w-An*(p||1)}px`,zIndex:2,transform:G,transformOrigin:"left top",borderColor:H==="editing"||H==="hover"?S:"transparent"}},[p,g,m,w,S,H]),q=d.useMemo(()=>{let G="";const ie="<div></div>";if(f.text){const ee=gn(f.text);for(let ue=0;ue<ee.length;ue++){const he=ee[ue];if(he==="")G=G+ie;else{const Ie=he.replace(/[<>&]/g,Se=>({"<":"<",">":">","&":"&"})[Se]);G=G+`<div>${Ie}</div>`}}}else G=ie;return G},[f.fontBgColor,f.text]),$=d.useMemo(()=>{var G,ie;if(H==="hover"){if(p&&t&&x.isNumber(m)&&x.isNumber(w)&&f.boxSize&&x.isNumber((G=f.boxSize)==null?void 0:G[0])&&x.isNumber((ie=f.boxSize)==null?void 0:ie[1])){const ee={x:m,y:w},ue={left:m,top:w,width:f.boxSize[0]*p,height:f.boxSize[1]*p};return d.createElement(ym,{position:ee,style:ue,textOpt:f,workIds:[e],noLayer:!0,noCopy:!0,noDelete:!0})}return null}return null},[f,t,e,m,w,p,H]);d.useEffect(()=>{J.current=h===e,h!==e&&(D.current&&(cancelAnimationFrame(D.current),D.current=void 0),V.current&&(window.clearTimeout(V.current),V.current=void 0))},[h,e]),d.useEffect(()=>{if(h===e&&L.current){const G=window==null?void 0:window.getSelection(),ie=Np(G,L.current);(document.activeElement!==L.current||!ie)&&oe(),o(L.current)}},[h,o,e,Q]),d.useEffect(()=>()=>{D.current&&cancelAnimationFrame(D.current),V.current&&window.clearTimeout(V.current)},[]),d.useEffect(()=>{if(L.current){const G=parseInt(getComputedStyle(L.current).paddingRight,10)+parseInt(getComputedStyle(L.current).borderWidth,10);O.current=Number(G)}},[]),d.useEffect(()=>{if(L.current){const G={fontSize:R.fontSize,lineHeight:R.lineHeight,fontStyle:R.fontStyle,fontWeight:R.fontWeight,fontFamily:R.fontFamily};if(!x.isEqual(U.current,G)){U.current=G;const ie=[L.current.offsetWidth,L.current.offsetHeight];a(e,ie)}}},[R,e,a]);const ae=d.useCallback(G=>{var Ie,Se;const ie=u==null?void 0:u.parentElement;if(!ie||!L.current||!c)return!1;const ee=L.current.lastChild;if(!ee||ee instanceof Text)return!1;const ue=ee==null?void 0:ee.getBoundingClientRect(),he=ie==null?void 0:ie.getBoundingClientRect();if(!ue||!he)return!1;if(ue.right+G>he.right){const ce=ee.lastChild;if(!(ce instanceof Text))return!1;const ve=ce.length||0;let Le=0,le=0,De=ve;for(;le<De;){const ze=Math.floor((le+De)/2),nt=document.createRange();nt.setStart(ce,0),nt.setEnd(ce,ze);const Lt=nt.getBoundingClientRect(),ui=he.right-Lt.right;if(ui<G){if(ze>0){const ut=document.createRange();ut.setStart(ce,0),ut.setEnd(ce,ze-1);const Pt=ut.getBoundingClientRect();if(he.right-Pt.right>=G){Le=ze-1;break}}De=ze}else{const ut=ze+1;if(ut<ve){const Pt=document.createRange();Pt.setStart(ce,0),Pt.setEnd(ce,ut);const hi=Pt.getBoundingClientRect();if(he.right-hi.right<=G&&ui>G){Le=ze;break}}le=ut}}if(!Le){const ze=document.createRange();ze.setStart(ce,0),ze.setEnd(ce,le);const nt=ze.getBoundingClientRect();he.right-nt.right>G?Le=le:le>0&&(Le=le-1)}if(Le>0){const ze=((Ie=ce.textContent)==null?void 0:Ie.slice(0,Le))||"",nt=((Se=ce.textContent)==null?void 0:Se.slice(Le))||"";ce.textContent=ze;const Lt=document.createElement("div");return nt&&(Lt.textContent=nt),L.current.appendChild(Lt),ae(G),!0}}return!1},[u==null?void 0:u.parentElement,f.fontBgColor,c]);function Ge(G){if(G.stopPropagation(),G.nativeEvent.stopImmediatePropagation(),G.key==="Backspace"){const ie=window.getSelection(),ee=ie==null?void 0:ie.getRangeAt(0);if(ee!=null&&ee.collapsed)return G.cancelable&&G.preventDefault(),document.execCommand("delete",!1),!1}return!1}function Ke(G,ie){const ee=window==null?void 0:window.getSelection();if(ee!=null&&ee.rangeCount&&G&&ee&&ee.anchorNode){const ue=ee.anchorOffset,he=ee.anchorNode.textContent||"",Ie=he.slice(0,ue)||"",Se=he.slice(ue)||"",ce=Ie.concat(G)||"";lt(ce,Se,ie)}}function lt(G,ie,ee){const ue=window==null?void 0:window.getSelection();if(!(ue!=null&&ue.rangeCount)||!ue.anchorNode)return;const he=G.split(/\n/);let Ie=ue.anchorNode.parentNode;Ie===ee&&(Ie=ue.anchorNode);const Se=[...ee.childNodes],ce=[];let ve,Le=ue.anchorOffset;for(;Se.length;){const le=Se.pop();if(le){if(le===Ie){let De=he[0];he.length===1&&(Le=he[0].length,De=he[0].concat(ie)),Ie.nodeName==="#text"?(Ie.textContent=De,ve=Ie):Ie.nodeName==="DIV"&&(Ie.innerText=De,ve=Ie.childNodes[0]);break}ce.push(le),ee.removeChild(le)}}if(he.length>1)for(let le=1;le<he.length;le++){let De=he[le];const ze=document.createElement("div");le===he.length-1&&(Le=De.length,De=De.concat(ie)),ze.innerText=De,ee.appendChild(ze),le===he.length-1&&(ve=ze.childNodes[0])}if(ce.length){ce.reverse();for(const le of ce)ee.appendChild(le)}if(ve&&ve.nodeName==="#text"){ue.deleteFromDocument();const le=document.createRange(),De=Math.min(Le,(ve==null?void 0:ve.length)||0);le.setStart(ve,De),le.collapse(!0),ue.removeAllRanges(),ue.addRange(le)}}function _e(G){if(G.cancelable&&G.preventDefault(),G.stopPropagation(),G.nativeEvent.stopImmediatePropagation(),L.current){const ie=(G.clipboardData||window.clipboardData).getData("text"),ee=window==null?void 0:window.getSelection();if(!(ee!=null&&ee.rangeCount))return;if(ie&&ee&&ee.anchorNode){const ue=Cn(ie,{whiteList:{},stripIgnoreTag:!0,stripIgnoreTagBody:["script"]});Ke(ue,L.current),ae((p||1)*O.current),i(L.current)}s()}return!1}function et(G){var ee;const ie=G.querySelector("div");if(ie){const ue=document.createTreeWalker(G,NodeFilter.SHOW_TEXT,null);let he;const Ie=[];for(;(he=ue.nextNode())!==null;)he.parentNode===G&&Ie.push(he);if(Ie.length>0){for(const ce of Ie)ie.appendChild(ce);const Se=window.getSelection();if(Se){const ce=document.createRange(),ve=ie.lastChild;ve&&ve.nodeType===Node.TEXT_NODE&&(ce.setStart(ve,((ee=ve.textContent)==null?void 0:ee.length)||0),ce.collapse(!0),Se.removeAllRanges(),Se.addRange(ce))}}}}const tt=d.useCallback(()=>{const G=L.current;s(()=>{if(G){if(et(G),!E.current&&ae((p||1)*O.current)){const ie=window.getSelection();if(!(ie!=null&&ie.rangeCount))return!1;const ee=document.createRange(),ue=L.current.lastChild;ee.selectNodeContents(ue),ee.collapse(!1),ie.removeAllRanges(),ie.addRange(ee)}i(G)}})},[s,i,ae,p]);function je(){E.current=!0,s()}function Ne(){E.current=!1,tt()}function K(){tt(),s()}const Ae=d.useCallback(()=>{if(H==="active"&&L.current&&L.current.parentElement){const G=L.current.parentElement;G.style.borderColor=S}},[H,S]),Ee=d.useCallback(()=>{if(H==="active"&&L.current&&L.current.parentElement){const G=L.current.parentElement;G.style.borderColor="transparent"}},[H]);return d.createElement(d.Fragment,null,$,d.createElement("div",{className:`editor-box ${H}`,style:ne,onPointerUp:()=>{var G;if(H==="editing"){s(()=>{var ie;(ie=document.activeElement)==null||ie.blur(),u==null||u.control.textEditorManager.checkEmptyTextBlur()});return}if(H==="active"&&u){if((G=u.control.collector)!=null&&G.hasIncludeSelector(e)){s(()=>{var ie;(ie=document.activeElement)==null||ie.blur(),u==null||u.control.textEditorManager.checkEmptyTextBlur()});return}if(u&&h!==e){u.control.textEditorManager.checkEmptyTextBlur(),u.control.textEditorManager.active(e,u.worker.now);return}}},onMouseOver:Ae,onMouseLeave:Ee},d.createElement("div",{id:e,suppressContentEditableWarning:!0,contentEditable:!0,className:"editor",ref:L,style:R,onKeyDown:Ge,onPaste:_e,onTouchEnd:oe,onInput:tt,onCompositionStart:je,onCompositionUpdate:K,onCompositionEnd:Ne,dangerouslySetInnerHTML:{__html:q}})))},Im=r=>{const n=d.useRef(null),{mananger:e}=d.useContext(ye),t=d.useRef(),i=d.useCallback(s=>{var u,f;const{activeTextId:a,update:c,syncData:l}=s;if(!e)return;const h=a&&x.cloneDeep(((u=e.control.textEditorManager)==null?void 0:u.get(a))||((f=r.editors)==null?void 0:f.get(a)));h&&h.opt&&(h.opt={...h.opt,...c},l&&(h.canSync=Object.keys(l).includes("canSync")&&l.canSync||h.canSync,h.canWorker=Object.keys(l).includes("canWorker")&&l.canWorker||h.canWorker),e.control.textEditorManager.updateForViewEdited(a,h))},[e,r.editors]),o=d.useMemo(()=>{var u;const s=f=>{const p=[];for(let g=0;g<f.childNodes.length;g++){const m=f.childNodes[g];if(m.nodeName==="#text"&&g===0){const w=m.textContent.split(/\n/),y=w.pop();p.push(...w),y&&p.push(y)}else if(m.nodeName==="DIV"){const w=m.innerText.split(/\n/);if(w.length===2&&w[0]===""&&w[1]==="")p.push("");else{const y=w.shift();(y||y==="")&&p.push(y);const M=w.pop();p.push(...w),M&&p.push(M)}}}return p},a=f=>{if(!e)return;const p=f.id,g=e.control.textEditorManager.get(p),m=j.Doing,w=[f.offsetWidth,f.offsetHeight];(!g||g&&(!x.isEqual(g.opt.boxSize,w)||!x.isEqual(g.opt.workState,m)))&&i({activeTextId:p,update:{boxSize:w,workState:m},syncData:{canSync:!0,canWorker:!0}})},c=f=>{var v,S;if(!e)return;const p=s(f),g=f.id,m=e.control.textEditorManager.get(g),w=St(p),y=j.Doing,M=[f.offsetWidth,f.offsetHeight];if(!m||m&&(m.opt.text!==w||!x.isEqual(m.opt.boxSize,M)||!x.isEqual(m.opt.workState,y))){const C=g&&x.cloneDeep(((v=e.control.textEditorManager)==null?void 0:v.get(g))||((S=r.editors)==null?void 0:S.get(g)));C&&C.opt&&(C.opt={...C.opt,text:w,boxSize:M,workState:y},C.canSync=!0,C.canWorker=!0,e.control.textEditorManager.updateForViewEdited(g,C)),e.control.textEditorManager.publicMsgEmitter.emit("textChange",g,f,p,C)}},l=(f,p)=>{if(!e)return;const g=f,m=e.control.textEditorManager.get(g);if(m&&!x.isEqual(m.opt.boxSize,p)){const w=x.cloneDeep(m);w.opt={...w.opt,boxSize:p},w.canSync=!1,w.canWorker=!1,e.control.textEditorManager.updateForViewEdited(g,w)}},h=f=>{t.current&&cancelAnimationFrame(t.current),t.current=requestAnimationFrame(()=>{n!=null&&n.current&&(n==null||n.current.scrollTo({left:0,behavior:"instant"}),f&&f(),t.current=void 0)})};if((u=r.editors)!=null&&u.size){const f=[];return r.editors.forEach((p,g)=>{f.push(d.createElement(mm,{key:g,workId:g,data:p,showFloatBtns:r.showFloatBtns||!1,handleFocus:a,handleKeyUp:c,updateSize:l,runAnimation:h,rightBoundBreak:r.rightBoundBreak||!1}))}),f}return null},[r.editors,r.showFloatBtns,r.rightBoundBreak,e,i]);return d.createElement("div",{className:`${r.className}`,ref:n},o)},wm=()=>{const{floatBarData:r}=d.useContext(ye);return d.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},d.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),d.createElement("div",{className:"point LC ew-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),d.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),d.createElement("div",{className:"point TC ns-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),d.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),d.createElement("div",{className:"point RC ew-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),d.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),d.createElement("div",{className:"point BC ns-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}))},Tm=()=>{const{floatBarData:r,mananger:n}=d.useContext(ye),[e,t]=d.useState(),[i,o]=d.useState();d.useEffect(()=>{const c=[];if(n&&x.isNumber(r==null?void 0:r.x)&&x.isNumber(r==null?void 0:r.y)&&(r!=null&&r.points)){const l=n.viewId;if(n.control.viewContainerManager.getView(l))for(const u of r.points){const f=n.control.viewContainerManager.transformToOriginPoint(u,l);c.push(f)}c[0]&&t({x:c[0][0]-((r==null?void 0:r.x)||0),y:c[0][1]-((r==null?void 0:r.y)||0)}),c[1]&&o({x:c[1][0]-((r==null?void 0:r.x)||0),y:c[1][1]-((r==null?void 0:r.y)||0)})}},[n,r==null?void 0:r.points,r==null?void 0:r.x,r==null?void 0:r.y]);const s=d.useMemo(()=>e?d.createElement("div",{className:"point point-dot",style:{borderColor:r==null?void 0:r.selectorColor,left:e.x,top:e.y}}):null,[r==null?void 0:r.selectorColor,e]),a=d.useMemo(()=>i?d.createElement("div",{className:"point point-dot",style:{borderColor:r==null?void 0:r.selectorColor,left:i.x,top:i.y}}):null,[i,r==null?void 0:r.selectorColor]);return d.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},s,a)},Nm=()=>{const{floatBarData:r}=d.useContext(ye);return d.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},d.createElement("div",{className:"point LT nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),d.createElement("div",{className:"point LB nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),d.createElement("div",{className:"point RT nesw-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}),d.createElement("div",{className:"point RB nwse-resize",style:{backgroundColor:r==null?void 0:r.selectorColor}}))},vm=()=>{const{floatBarData:r}=d.useContext(ye);return d.createElement("div",{className:"appliance-plugin-hightlight-box",style:{borderColor:r==null?void 0:r.selectorColor}},d.createElement("img",{className:"lock",alt:"lock",src:"https://sdk.netless.link/resource/icons/lock.svg"}))},Cm=r=>{const{className:n}=r,{floatBarData:e,angle:t,setAngle:i,setOperationType:o,mananger:s}=d.useContext(ye),[a,c]=d.useState(j.Pending),[l,h]=d.useState(),[u,f]=d.useState(!1),[p,g]=d.useState(new pe),[m,w]=d.useState(new pe),[y,M]=d.useState(!1),v=d.useRef(0),S=d.useRef(null),C=L=>{if(!L){M(!0),f(!1),o(W.None),c(j.Pending);return}M(!1)},k=(L,R)=>{v.current&&(clearTimeout(v.current),v.current=0),c(j.Done),f(!1);const E=Math.round(pe.GetAngleByPoints(p,m,new pe(R.x,R.y)))||0;i(E),o(W.None),re.emitMethod(_.MainEngine,W.RotateNode,{workIds:[Z],angle:E,workState:j.Done,viewId:s==null?void 0:s.viewId}),s==null||s.focusElement()};d.useEffect(()=>(re.activeListener(C),()=>{re.unmountActiveListener(C)}),[]),d.useEffect(()=>{if(e&&(a===j.Pending||a===j.Done)){const L={x:(e==null?void 0:e.x)-20,y:(e==null?void 0:e.y)+(e==null?void 0:e.h)},R={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};w(new pe(R.x,R.y)),g(new pe(L.x,L.y)),h({x:L.x,y:L.y})}},[e,a]);const N=(L,R)=>{if(s!=null&&s.control.worker.isBusy){M(!0),c(j.Pending);return}v.current&&(clearTimeout(v.current),v.current=0),c(j.Start),f(!0);const E=Math.round(pe.GetAngleByPoints(p,m,new pe(R.x,R.y)))||0;i(E),o(W.RotateNode),re.emitMethod(_.MainEngine,W.RotateNode,{workIds:[Z],angle:0,workState:j.Start,viewId:s==null?void 0:s.viewId})},z=(L,R)=>{if(s!=null&&s.control.worker.isBusy){M(!0),k(L,R);return}k(L,R)},P=(L,R)=>{if(s!=null&&s.control.worker.isBusy){M(!0),k(L,R);return}v.current||(h({x:R.x,y:R.y}),f(!0),v.current=setTimeout(()=>{v.current=0;const E=Math.round(pe.GetAngleByPoints(p,m,new pe(R.x,R.y)))||0;i(E),o(W.RotateNode),c(j.Doing),re.emitMethod(_.MainEngine,W.RotateNode,{workIds:[Z],angle:E,workState:j.Doing,viewId:s==null?void 0:s.viewId})},60))};return d.createElement(xt,{disabled:y,position:l,onStart:N,onDrag:P,onStop:z},d.createElement("div",{className:`${n}`,style:e?{left:0,top:0,touchAction:"none"}:void 0},!u&&d.createElement("div",{className:"appliance-plugin-rotate-btn",style:{backgroundColor:e==null?void 0:e.selectorColor}},d.createElement("img",{alt:"icon",src:be("rotation-button")})),d.createElement("div",{ref:S,className:`appliance-plugin-rotate-mouse-pointer ${u?"active":""}`},d.createElement("img",{alt:"icon",src:be("rotation")}),d.createElement("div",{className:"angle-icon"},t,"°"))))},Sm=d.memo(r=>{const{editors:n,canSelectorSwitch:e}=r,{floatBarData:t,setOperationType:i,mananger:o,isNoPointerEvents:s}=d.useContext(ye),[a,c]=d.useState(),[l,h]=d.useState(!1),u=d.useRef(0),f=d.useRef(),p=d.useRef(j.Pending),g=d.useMemo(()=>!!((t==null?void 0:t.scaleType)===Oe.none&&(t!=null&&t.canLock)),[t]),m=d.useMemo(()=>t&&t.w&&t.h?{position:"absolute",left:0,top:0,width:t.w,height:t.h,zIndex:2,pointerEvents:g||s?"none":"auto",touchAction:"none"}:{display:"none",pointerEvents:"none"},[t,g,s]),w=N=>{if(!N||t!=null&&t.isLocked){h(!0),p.current=j.Pending,i(W.None);return}h(!1)},y=(N,z)=>{u.current&&(clearTimeout(u.current),u.current=0);const P={x:z.x,y:z.y};i(W.None),p.current=j.Done,c(P),re.emitMethod(_.MainEngine,W.TranslateNode,{workIds:[Z],position:P,workState:j.Done,viewId:o==null?void 0:o.viewId})};d.useEffect(()=>(re.activeListener(w),()=>{re.unmountActiveListener(w)}),[]),d.useEffect(()=>{if(t&&(t!=null&&t.isLocked)||o!=null&&o.control.worker.isBusy){h(!0);return}h(!1)},[t,o==null?void 0:o.control.worker.isBusy]),d.useEffect(()=>{(p.current===j.Pending||p.current===j.Done)&&x.isNumber(t==null?void 0:t.x)&&x.isNumber(t==null?void 0:t.y)&&c({x:t==null?void 0:t.x,y:t==null?void 0:t.y})},[t==null?void 0:t.x,t==null?void 0:t.y]);const M=()=>{if(o!=null&&o.control.worker.isBusy){h(!0);return}u.current&&(clearTimeout(u.current),u.current=0),x.isNumber(t==null?void 0:t.x)&&x.isNumber(t==null?void 0:t.y)&&(i(W.TranslateNode),p.current=j.Start,re.emitMethod(_.MainEngine,W.TranslateNode,{workIds:[Z],position:{x:t==null?void 0:t.x,y:t==null?void 0:t.y},workState:j.Start,viewId:o==null?void 0:o.viewId}))},v=(N,z)=>{var R;o!=null&&o.control.worker.isBusy&&h(!0);const P=p.current,L=f.current;if(y(N,z),f.current&&(f.current=void 0),P===j.Start&&(n!=null&&n.size)&&L){const E=(R=o==null?void 0:o.control.viewContainerManager.getView(o.viewId))==null?void 0:R.focusScenePath;E&&(o==null||o.control.worker.blurSelector(o.viewId,E))}o==null||o.focusElement()},S=(N,z)=>{if(o!=null&&o.control.worker.isBusy){h(!0),y(N,z);return}if(u.current)return;const P={x:z.x,y:z.y};c(P),u.current=setTimeout(()=>{u.current=0,(P.x!==(a==null?void 0:a.x)||P.y!==(a==null?void 0:a.y))&&(f.current&&(f.current=void 0),p.current=j.Doing,re.emitMethod(_.MainEngine,W.TranslateNode,{workIds:[Z],position:P,workState:j.Doing,viewId:o==null?void 0:o.viewId}))},60)},C=N=>{e&&(f.current=N)},k=()=>{o&&e&&p.current===j.Start&&f.current&&o.control.textEditorManager.active(f.current)};return d.createElement(xt,{disabled:l,position:a,onStart:M,onDrag:S,onStop:v},d.createElement("div",{style:m},d.createElement(km,{editors:n,selectIds:(t==null?void 0:t.selectIds)||[],handleTextEditorPointerDown:C,handleTextEditorPointerUp:k})))},(r,n)=>!!x.isEqual(r,n)),km=d.memo(r=>{const{editors:n,selectIds:e,handleTextEditorPointerDown:t,handleTextEditorPointerUp:i}=r;return n?d.createElement(pm,{editors:n,selectIds:e||[],handleTextEditorPointerDown:t,handleTextEditorPointerUp:i}):null},(r,n)=>!(!x.isEqual(r.editors,n.editors)||!x.isEqual(r.selectIds,n.selectIds))),xm=r=>{const{className:n}=r,[e,t]=d.useState({x:0,y:0,h:0,w:0}),[i,o]=d.useState(),[s,a]=d.useState(),[c,l]=d.useState(),{floatBarData:h,mananger:u,isNoPointerEvents:f,setOperationType:p}=d.useContext(ye),[g,m]=d.useState(),[w,y]=d.useState(!1),M=d.useRef(0);d.useEffect(()=>{if(h&&u){const R={x:h.x,y:h.y,w:h.w,h:h.h};t(R)}return re.activeListener(S),()=>{re.unmountActiveListener(S)}},[]),d.useEffect(()=>{if(u!=null&&u.control.worker.isBusy){y(!0);return}y(!1)},[u==null?void 0:u.control.worker.isBusy]);const v=()=>{if(M.current&&(clearTimeout(M.current),M.current=0),g){const{scale:R,translate:E}=g;p(W.None),re.emitMethod(_.MainEngine,W.ScaleNode,{workIds:[Z],scale:R,dir:c,translate:E,originPoint:i,scenePoint:s,workState:j.Done,viewId:u==null?void 0:u.viewId})}u==null||u.focusElement()},S=R=>{if(!R){y(!0);return}y(!1)},C=R=>[[R.x,R.y],[R.x+R.w,R.y],[R.x+R.w,R.y+R.h],[R.x,R.y+R.h]],k=(R,E)=>{switch(E){case"top":case"topLeft":case"left":return R[2];case"topRight":return R[3];case"right":case"bottomRight":case"bottom":return R[0];case"bottomLeft":return R[1]}},N=(R,E,O,D)=>{let V=!1,J=!1;const U={x:e.x,y:e.y,w:e.w,h:e.h},Q=[1,1],H=[0,0];switch(R){case"top":{const $=E.height+e.h;$<0?(J=!0,U.y=e.y+e.h,U.h=Math.abs($)):(U.y=e.y-E.height,U.h=e.h+E.height);break}case"topLeft":{const $=E.width+e.w;$<0?(V=!0,U.x=e.x+e.w,U.w=Math.abs($)):(U.x=e.x-E.width,U.w=e.w+E.width);const ae=E.height+e.h;ae<0?(J=!0,U.y=e.y+e.h,U.h=Math.abs(ae)):(U.y=e.y-E.height,U.h=e.h+E.height);break}case"topRight":{const $=E.width+e.w;$<0?(V=!0,U.x=e.x+$,U.w=Math.abs($)):U.w=e.w+E.width;const ae=E.height+e.h;ae<0?(J=!0,U.y=e.y+e.h,U.h=Math.abs(ae)):(U.y=e.y-E.height,U.h=e.h+E.height);break}case"bottom":{const $=E.height+e.h;$<0?(J=!0,U.y=e.y+$,U.h=Math.abs($)):U.h=e.h+E.height;break}case"bottomLeft":{const $=E.width+e.w;$<0?(V=!0,U.x=e.x+e.w,U.w=Math.abs($)):(U.x=e.x-E.width,U.w=e.w+E.width);const ae=E.height+e.h;ae<0?(J=!0,U.y=e.y+ae,U.h=Math.abs(ae)):U.h=e.h+E.height;break}case"left":{const $=E.width+e.w;$<0?(V=!0,U.x=e.x+e.w,U.w=Math.abs($)):(U.x=e.x-E.width,U.w=e.w+E.width);break}case"bottomRight":{const $=E.width+e.w;$<0?(V=!0,U.x=e.x+$,U.w=Math.abs($)):U.w=e.w+E.width;const ae=E.height+e.h;ae<0?(J=!0,U.y=e.y+ae,U.h=Math.abs(ae)):U.h=e.h+E.height;break}case"right":{const $=E.width+e.w;$<0?(V=!0,U.x=e.x+$,U.w=Math.abs($)):U.w=e.w+E.width;break}}Q[0]=U.w/e.w,Q[1]=U.h/e.h;const ne=C(U).map($=>O.control.viewContainerManager.transformToScenePoint($,O.viewId)),q=k(ne,R);return J&&(H[1]=q[1]-D[1]),V&&(H[0]=q[0]-D[0]),{scale:Q,translate:H}},z=(R,E)=>{if(M.current&&(clearTimeout(M.current),M.current=0),u!=null&&u.control.worker.isBusy){y(!0);return}if(h!=null&&h.w&&(h!=null&&h.h)&&u){const O={x:h.x,y:h.y,w:h.w,h:h.h},D=C(O),V=D.map(Q=>u.control.viewContainerManager.transformToScenePoint(Q,u.viewId)),J=k(D,E),U=k(V,E);t(O),o(J),a(U),l(E),p(W.ScaleNode),re.emitMethod(_.MainEngine,W.ScaleNode,{workIds:[Z],originPoint:J,scenePoint:U,workState:j.Start,viewId:u.viewId})}},P=(R,E,O,D)=>{if(!(!u||!i||!s)){if(u!=null&&u.control.worker.isBusy){y(!0),v();return}M.current||(M.current=setTimeout(()=>{M.current=0;const{scale:V,translate:J}=N(E,D,u,s);(!x.isEqual(V,g==null?void 0:g.scale)||!x.isEqual(J,g==null?void 0:g.translate))&&(m({scale:V,translate:J}),p(W.ScaleNode),re.emitMethod(_.MainEngine,W.ScaleNode,{workIds:[Z],scale:V,dir:E,translate:J,originPoint:i,scenePoint:s,workState:j.Doing,viewId:u.viewId}))},60))}},L=()=>{u!=null&&u.control.worker.isBusy&&y(!0),v()};return d.createElement(Hr.Resizable,{className:`${n}`,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",left:h==null?void 0:h.x,top:h==null?void 0:h.y,pointerEvents:f?"none":"auto"},enable:w?!1:{top:(h==null?void 0:h.scaleType)===Oe.all&&!0||!1,right:(h==null?void 0:h.scaleType)===Oe.all&&!0||!1,bottom:(h==null?void 0:h.scaleType)===Oe.all&&!0||!1,left:(h==null?void 0:h.scaleType)===Oe.all&&!0||!1,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},lockAspectRatio:(h==null?void 0:h.scaleType)===Oe.proportional,onResizeStart:z,onResize:P,onResizeStop:L})},Ji=r=>{const{id:n,pos:e,pointMap:t,type:i}=r,{setOperationType:o,mananger:s,floatBarData:a}=d.useContext(ye),[c,l]=d.useState({x:0,y:0}),[h,u]=d.useState(j.Pending),[f,p]=d.useState(!1),g=d.useRef(0),m=d.useMemo(()=>a?{left:0,top:0}:{},[a]),w=C=>{if(!C||a!=null&&a.isLocked){p(!0),u(j.Pending),o(W.None);return}p(!1)};d.useEffect(()=>(re.activeListener(w),()=>{re.unmountActiveListener(w)}),[]),d.useEffect(()=>{x.isNumber(e.x)&&x.isNumber(e.y)&&(h===j.Pending||h===j.Done)&&l({x:e.x,y:e.y})},[e,h]),d.useEffect(()=>{if(a&&(a!=null&&a.isLocked)||s!=null&&s.control.worker.isBusy){p(!0);return}p(!1)},[a,s==null?void 0:s.control.worker.isBusy]);const y=(C,k)=>{g.current&&(clearTimeout(g.current),g.current=0),o(W.None),u(j.Done);const N={x:k.x,y:k.y};if(l(N),s!=null&&s.control.viewContainerManager){const z=s.control.viewContainerManager.transformToScenePoint([N.x,N.y],s.viewId),P=t.get(n);P&&i==="start"?P[0]=z:P&&i==="end"&&(P[1]=z),re.emitMethod(_.MainEngine,W.SetPoint,{workId:Z,pointMap:t,workState:j.Done,viewId:s==null?void 0:s.viewId})}s==null||s.focusElement()},M=()=>{if(g.current&&(clearTimeout(g.current),g.current=0),s!=null&&s.control.worker.isBusy){p(!0);return}x.isNumber(e.x)&&x.isNumber(e.y)&&(o(W.SetPoint),u(j.Start),re.emitMethod(_.MainEngine,W.SetPoint,{workId:Z,pointMap:t,workState:j.Start,viewId:s==null?void 0:s.viewId}))},v=(C,k)=>{if(s!=null&&s.control.worker.isBusy){p(!0),y(C,k);return}if(g.current)return;const N={x:k.x,y:k.y};l(N),g.current=setTimeout(()=>{if(g.current=0,(N.x!==(k==null?void 0:k.x)||N.y!==(k==null?void 0:k.y))&&(s!=null&&s.control.viewContainerManager)){const z=s.control.viewContainerManager.transformToScenePoint([N.x,N.y],s.viewId),P=t.get(n);P&&i==="start"?P[0]=z:P&&i==="end"&&(P[1]=z),u(j.Doing),re.emitMethod(_.MainEngine,W.SetPoint,{workId:Z,pointMap:t,workState:j.Doing,viewId:s==null?void 0:s.viewId})}},60)},S=(C,k)=>{s!=null&&s.control.worker.isBusy&&p(!0),y(C,k)};return d.createElement(xt,{disabled:f,position:c,onStart:M,onDrag:v,onStop:S},d.createElement("div",{className:"appliance-plugin-point-draggable-btn",style:m}))},jm=r=>{const{className:n}=r,{floatBarData:e,mananger:t}=d.useContext(ye),[i,o]=d.useState(),[s,a]=d.useState(),[c,l]=d.useState(new Map);d.useEffect(()=>{const f=[];if(t&&(e!=null&&e.points)){const p=t.viewId;if(t.control.viewContainerManager.getView(p))for(const m of e.points){const w=t.control.viewContainerManager.transformToOriginPoint(m,p);f.push(w)}e!=null&&e.selectIds&&e.selectIds.length===1&&(c.set(e.selectIds[0],e.points),l(c))}f[0]&&o({x:f[0][0],y:f[0][1]}),f[1]&&a({x:f[1][0],y:f[1][1]})},[t,e==null?void 0:e.points,e==null?void 0:e.selectIds,c]);const h=d.useMemo(()=>i&&(e!=null&&e.selectIds)?d.createElement(Ji,{pos:i,type:"start",id:e.selectIds[0],pointMap:c}):null,[i,e==null?void 0:e.selectIds,c]),u=d.useMemo(()=>s&&(e!=null&&e.selectIds)?d.createElement(Ji,{pos:s,type:"end",id:e.selectIds[0],pointMap:c}):null,[s,e==null?void 0:e.selectIds,c]);return d.createElement("div",{className:`${n}`},h,u)},Dm=d.forwardRef((r,n)=>{const{floatBarData:e,operationType:t}=d.useContext(ye),i=d.useMemo(()=>(e==null?void 0:e.scaleType)!==Oe.all||t===W.RotateNode?null:d.createElement(wm,null),[e,t]),o=d.useMemo(()=>(e==null?void 0:e.scaleType)!==Oe.both||t===W.RotateNode?null:d.createElement(Tm,null),[e,t]),s=d.useMemo(()=>(e==null?void 0:e.scaleType)!==Oe.proportional||t===W.RotateNode?null:d.createElement(Nm,null),[e,t]),a=d.useMemo(()=>(e==null?void 0:e.scaleType)===Oe.none&&(e!=null&&e.canLock)?d.createElement(vm,null):null,[e]);return d.createElement("div",{ref:n,style:e?{transform:`translate(${e.x}px,${e.y}px)`,width:e.w,height:e.h,pointerEvents:"none"}:void 0},a,i,o,s,r.children)}),bm=d.memo(r=>{const{isHide:n,operationType:e,floatBarData:t}=r;return n&&e===W.None&&x.isNumber(t==null?void 0:t.x)&&x.isNumber(t==null?void 0:t.y)&&x.isNumber(t==null?void 0:t.w)&&x.isNumber(t==null?void 0:t.h)?d.createElement("div",{className:Te.FloatBarBtn,style:{left:t==null?void 0:t.x,top:t==null?void 0:t.y,width:t.w,height:t.h}},d.createElement(Gr,{position:{x:t.x,y:t.y},textOpt:t==null?void 0:t.textOpt,noLayer:t==null?void 0:t.isLocked})):null},(r,n)=>!!x.isEqual(r,n)),Am=d.forwardRef((r,n)=>{const{floatBarData:e,operationType:t,mananger:i}=d.useContext(ye),{editors:o,isHide:s,canSelectorSwitch:a}=r,c=d.useMemo(()=>{var u;return e!=null&&e.canRotate&&((u=e==null?void 0:e.selectIds)==null?void 0:u.length)===1&&(t===W.None||t===W.RotateNode)?d.createElement(Cm,{className:Te.RotateBtn}):null},[e,t]),l=d.useMemo(()=>((e==null?void 0:e.scaleType)===Oe.all||(e==null?void 0:e.scaleType)===Oe.proportional)&&(t===W.None||t===W.ScaleNode)&&x.isNumber(e==null?void 0:e.x)&&x.isNumber(e==null?void 0:e.y)?d.createElement(xm,{className:Te.ResizeBtn}):null,[e==null?void 0:e.scaleType,t,e==null?void 0:e.x,e==null?void 0:e.y]),h=d.useMemo(()=>(e==null?void 0:e.scaleType)===Oe.both&&(t===W.None||t===W.SetPoint)?d.createElement(jm,{className:Te.ResizeTowBox}):null,[e==null?void 0:e.scaleType,t]);return d.createElement("div",{className:Te.FloatBar,onPointerOver:u=>($t(u),i==null||i.control.worker.blurCursor(i.viewId),!1)},d.createElement(Dm,{ref:n}),d.createElement(Sm,{editors:o,canSelectorSwitch:a}),c,l,h,d.createElement(bm,{isHide:s,operationType:t,floatBarData:e}))}),zm=d.memo(Am,(r,n)=>!!x.isEqual(r,n));class Em extends d.Component{constructor(e){super(e);I(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 d.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});I(this,"getOpacity",e=>{const t=this.getCursorName(e),i=this.detectAvatar(e);return t===void 0&&i===void 0?0:1});I(this,"getCursorName",e=>{if(e.payload)return e.payload.nickName||e.payload.cursorName||e.payload.uid});I(this,"getThemeClass",e=>e.payload&&e.payload.theme?"cursor-inner-mellow":"cursor-inner");I(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});I(this,"getCursorTextColor",e=>e.payload&&e.payload.cursorTextColor?e.payload.cursorTextColor:"#FFFFFF");I(this,"getCursorTagBackgroundColor",e=>e.payload&&e.payload.cursorTagBackgroundColor?e.payload.cursorTagBackgroundColor:this.getCursorBackgroundColor(e));I(this,"detectAvatar",e=>!!(e.payload&&e.payload.avatar));I(this,"renderTag",e=>{if(e.payload&&e.payload.cursorTagName)return d.createElement("span",{className:"cursor-tag-name",style:{backgroundColor:this.getCursorTagBackgroundColor(e)}},e.payload.cursorTagName)});I(this,"renderCursor",e=>{const t=nm.get(e);return t&&this.props.isEnableCursor?d.createElement("img",{className:`cursor-${e}-image`,src:t,alt:`${e}Cursor`}):null})}render(){const{roomMember:e}=this.props,t=this.getCursorName(e);switch(e.memberState.currentApplianceName){case te.pencil:return d.createElement("div",{className:"cursor-box"},d.createElement("div",{className:"cursor-mid cursor-pencil-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"5px",marginTop:"4px"}},d.createElement("div",{className:"cursor-name"},d.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),d.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),d.createElement("div",null,this.renderCursor("pencil"))));case te.selector:return d.createElement("div",{className:"cursor-box"},d.createElement("div",{className:"cursor-mid cursor-selector-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"3px",marginTop:"17px"}},d.createElement("div",{className:"cursor-name"},d.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),d.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),d.createElement("div",null,this.renderCursor("selector"))));case te.eraser:case te.pencilEraser:return d.createElement("div",{className:"cursor-box"},d.createElement("div",{className:"cursor-mid cursor-eraser-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"2px",marginTop:"8px"}},d.createElement("div",{className:"cursor-name"},d.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),d.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),d.createElement("div",null,this.renderCursor("eraser"))));case te.text:return d.createElement("div",{className:"cursor-box"},d.createElement("div",{className:"cursor-mid cursor-text-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"0px"}},d.createElement("div",{className:"cursor-name"},d.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),d.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),d.createElement("div",null,this.renderCursor("text"))));case te.rectangle:case te.arrow:case te.straight:case te.shape:case te.ellipse:return d.createElement("div",{className:"cursor-box"},d.createElement("div",{className:"cursor-mid cursor-shape-offset",style:{transform:"translate(-50%, -100%)",marginLeft:"-3px",marginTop:"19px"}},d.createElement("div",{className:"cursor-name"},d.createElement("div",{style:{opacity:this.getOpacity(e),backgroundColor:this.getCursorBackgroundColor(e),color:this.getCursorTextColor(e)},className:this.getThemeClass(e)},this.renderAvatar(e),d.createElement("span",{className:"cursor-name-text"},t),this.renderTag(e))),d.createElement("div",null,this.renderCursor("shape"))));default:return null}}}const Lm=r=>{var s;const{className:n,info:e,isEnableCursor:t}=r,{roomMember:i,...o}=e||{};return d.createElement("div",{"data-cursor-uid":(s=i==null?void 0:i.payload)==null?void 0:s.uid,className:`${n}`,style:o?{transform:`translate(${o.x}px, ${o.y}px)`}:{display:"none"}},i&&d.createElement(Em,{roomMember:i,isEnableCursor:t}))},Pm=r=>{const{className:n,manager:e}=r,[t,i]=d.useState();d.useEffect(()=>(e.internalMsgEmitter.on([_.Cursor,e.viewId],o),()=>{e.internalMsgEmitter.off([_.Cursor,e.viewId],o)}),[e]);function o(a){i(a)}return d.useMemo(()=>{if(t!=null&&t.length){const a=t.map(c=>{var l;return c.roomMember?d.createElement(Lm,{key:(l=c.roomMember)==null?void 0:l.memberId,className:n,info:c,isEnableCursor:e.control.cursor.isEnableCursor}):null});return d.createElement(d.Fragment,null,a)}return null},[t])},Om=r=>{const{viewId:n,miniMapCanvas:e,highlightColor:t,miniMapManager:i,contianer:o}=r,[s,a]=d.useState();d.useEffect(()=>(c(),i.listener.addListener([n,"viewCameraUpate"],c),i.listener.emitAsync([n,"miniMapCreate"],!0),()=>{i.listener.removeListener([n,"viewCameraUpate"],c)}),[]);const c=()=>{const u=i.maps.get(n);u&&l(u.miniMapCamera,u.viewCamera)},l=(u,f)=>{const{width:p,height:g}=o.getBoundingClientRect(),m=Math.min(p/u.width,g/u.height),w=f.width/f.scale,y=f.height/f.scale,M=[f.centerX,f.centerY],v=[u.centerX,u.centerY],S=[M[0]-v[0],M[1]-v[1]],C=Math.min(u.scale*m,u.scale*m),k=[S[0]*C,S[1]*C,w,y,C];a(k)},h=u=>{var f;if(i.control.renderControl.isWritable){const p=u.nativeEvent.target||u.nativeEvent.srcElement;if(p&&u.nativeEvent&&s){const{width:g,height:m}=p.getBoundingClientRect(),[w,y]=[g/2,m/2],[M,v]=[(u.nativeEvent.offsetX-w)/s[4],(u.nativeEvent.offsetY-y)/s[4]],S=i.maps.get(n);if(S!=null&&S.viewCamera){const[C,k]=[S.miniMapCamera.centerX+M,S.miniMapCamera.centerY+v];(f=i.control.room)==null||f.moveCamera({centerX:C,centerY:k,animationMode:"immediately"})}}}};return d.createElement("div",{style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",pointerEvents:"auto"},onClick:h},d.createElement("canvas",{style:{pointerEvents:"none"},ref:e}),s&&d.createElement("div",{className:"minimap-highlightBox",style:{position:"absolute",top:"50%",left:"50%",width:s[2]*s[4],height:s[3]*s[4],boxSizing:"content-box",border:`2px solid ${t}`,transform:`translate(calc(-50% + ${s[0]}px), calc(-50% + ${s[1]}px))`,pointerEvents:"none"}}))},Rm=r=>{const{miniMapManager:n,active:e,className:t}=r,i=d.useMemo(()=>{const o=n.maps;if(e){const s=o.get(e);if(s){const{miniMapCamera:a,viewCamera:c,...l}=s;if(l.contianer&&a&&c){const h=n.highlightColor;return rn.createPortal(d.createElement(Om,{viewId:e,...l,highlightColor:h,miniMapManager:n}),l.contianer)}}}return null},[e,n]);return d.createElement("div",{className:t},i)},ye=d.createContext({viewId:"",mananger:void 0,floatBarColors:[],floatBarData:void 0,dpr:1,angle:0,operationType:W.None,scale:[1,1],isNoPointerEvents:!1,activeTextEditor:!1,activeTextId:void 0,setAngle:()=>{},setOperationType:()=>{},setFloatBarData:()=>{}});class li extends d.Component{constructor(e){var i,o;super(e);I(this,"showTextFloatBar");I(this,"canSelectorSwitch");I(this,"rightBoundBreak");I(this,"setAngle",e=>{this.setState({angle:e})});I(this,"setOperationType",e=>{this.setState({operationType:e})});this.state={floatBarData:void 0,showFloatBar:!1,showFloatBarBtn:!0,dpr:1,angle:0,operationType:W.None,scale:[1,1],editors:this.editors,activeTextId:(i=this.props.mananger.control.textEditorManager)==null?void 0:i.activeId,activeMiniMapViewId:(o=this.props.mananger.control.miniMapManager)==null?void 0:o.activeViewId};const t=this.props.mananger.control.pluginOptions.extras.textEditor;this.showTextFloatBar=x.isBoolean(t.showFloatBar)?t.showFloatBar:me.textEditor.showFloatBar,this.canSelectorSwitch=x.isBoolean(t==null?void 0:t.canSelectorSwitch)?t.canSelectorSwitch:me.textEditor.canSelectorSwitch,this.rightBoundBreak=x.isBoolean(t==null?void 0:t.rightBoundBreak)?t.rightBoundBreak:me.textEditor.rightBoundBreak}get editors(){return Gt(this.props.mananger.control.textEditorManager.filterEditor(this.props.mananger.viewId))}componentDidMount(){this.props.mananger.vDom=this,this.props.mananger.mountView(),this.setState({dpr:this.props.mananger.dpr})}componentWillUnmount(){}setActiveMiniMap(e){this.setState({activeMiniMapViewId:e})}showFloatBarBtn(e){this.setState({showFloatBarBtn:e})}showFloatBar(e,t){const i=e&&t&&{...this.state.floatBarData,...t}||void 0;this.setState({showFloatBar:e,floatBarData:i,angle:0})}activeTextEditor(){this.setState({activeTextEditor:!0})}unActiveTextEditor(){this.setState({activeTextEditor:!1})}updateTextEditorInfo(e){this.setState({activeTextId:e,editors:this.editors})}setFloatBarData(e){this.state.floatBarData&&this.setState({floatBarData:{...this.state.floatBarData,...e}})}render(){var t,i,o,s,a,c;const e=!!((i=(t=this.props.mananger.control)==null?void 0:t.room)!=null&&i.floatBarOptions);return d.createElement("div",{className:Te.Container},!this.props.mananger.control.hasOffscreenCanvas&&d.createElement("div",{className:Te.CanvasBox,ref:this.props.refs.canvasContainerRef})||d.createElement("div",{className:Te.CanvasBox},d.createElement("canvas",{id:"bgCanvas",ref:this.props.refs.canvasBgRef,style:{width:"100%",height:"100%"}}),d.createElement("canvas",{id:"serviceCanvas",className:Te.FloatCanvas,ref:this.props.refs.canvasServiceFloatRef,style:{width:"100%",height:"100%"}}),d.createElement("canvas",{id:"localCanvas",className:Te.FloatCanvas,ref:this.props.refs.canvasFloatRef,style:{width:"100%",height:"100%"}}),!this.props.mananger.control.isUseSimple&&d.createElement("div",{id:"subLocalCanvas",className:Te.CanvasBoxSub,ref:this.props.refs.subLocalCanvasContainerRef}),!this.props.mananger.control.isUseSimple&&d.createElement("canvas",{id:"topCanvas",className:Te.TopFloatCanvas,ref:this.props.refs.canvasTopRef,style:{width:"100%",height:"100%"}})),!this.props.mananger.control.hasOffscreenCanvas&&this.props.refs.snapshotContainerRef&&d.createElement("div",{className:Te.SnapshotBox,ref:this.props.refs.snapshotContainerRef})||null,this.props.mananger.control.isUseBackgroundThread&&!!this.props.refs.backgroundContainerRef&&d.createElement("div",{className:Te.BackgroundBox},d.createElement("div",{className:Te.BackgroundSvgBox,ref:this.props.refs.backgroundContainerRef}),!!this.props.refs.backgroundSnapshotContainerRef&&d.createElement("div",{className:Te.BackgroundSnapshotBox},d.createElement("div",{className:Te.BackgroundSnapshotContent,ref:this.props.refs.backgroundSnapshotContainerRef})))||null,d.createElement(ye.Provider,{value:{viewId:this.props.viewId,mananger:this.props.mananger,floatBarColors:e&&((a=(s=(o=this.props.mananger.control)==null?void 0:o.room)==null?void 0:s.floatBarOptions)==null?void 0:a.colors)||[],isNoPointerEvents:!this.state.showFloatBarBtn,floatBarData:this.state.floatBarData,dpr:this.state.dpr,angle:this.state.angle,operationType:this.state.operationType,scale:this.state.scale,activeTextEditor:this.state.activeTextEditor,activeTextId:this.state.activeTextId,setAngle:this.setAngle.bind(this),setOperationType:this.setOperationType.bind(this),setFloatBarData:this.setFloatBarData.bind(this)}},this.state.showFloatBar&&d.createElement(zm,{ref:this.props.refs.floatBarRef,editors:this.state.editors,isHide:e&&this.state.showFloatBarBtn,canSelectorSwitch:this.canSelectorSwitch})||null,((c=this.state.editors)==null?void 0:c.size)&&d.createElement(Im,{className:Te.TextEditorContainer,showFloatBtns:this.showTextFloatBar&&e&&this.state.showFloatBarBtn||!1,editors:this.state.editors,rightBoundBreak:this.rightBoundBreak})||null),d.createElement(Pm,{className:Te.CursorBox,manager:this.props.mananger}),!this.props.mananger.control.isUseSimple&&d.createElement(Rm,{className:Te.MiniMapBox,active:this.state.activeMiniMapViewId,miniMapManager:this.props.mananger.control.miniMapManager}))}}class Ym extends Fr{constructor(e,t){super(e,t);I(this,"width",1e3);I(this,"height",1e3);I(this,"dpr",kt());I(this,"vDom");I(this,"eventTragetElement");I(this,"snapshotContainerRef");I(this,"backgroundSnapshotContainerRef");I(this,"canvasContainerRef",d.createRef());I(this,"subLocalCanvasContainerRef");I(this,"canvasTopRef");I(this,"canvasServiceFloatRef",d.createRef());I(this,"canvasFloatRef",d.createRef());I(this,"canvasBgRef",d.createRef());I(this,"backgroundContainerRef");I(this,"floatBarRef",d.createRef());I(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas||(this.snapshotContainerRef=d.createRef()),this.control.isUseSimple||(this.canvasTopRef=d.createRef(),this.subLocalCanvasContainerRef=d.createRef()),this.control.isUseBackgroundThread&&(this.backgroundContainerRef=d.createRef(),this.backgroundSnapshotContainerRef=d.createRef())}setCanvassStyle(){var e,t;if(this.eventTragetElement){const i=this.eventTragetElement.offsetWidth||this.width,o=this.eventTragetElement.offsetHeight||this.height,s=kt();s!==this.dpr&&(this.dpr=s,this.control.worker.updateDpr(this.viewId,this.dpr)),i&&o&&this.canvasContainerRef.current&&(i!==this.width||o!==this.height)&&(this.width=i,this.height=o,this.canvasContainerRef.current.style.width=`${i}px`,this.canvasContainerRef.current.style.height=`${o}px`),i&&o&&this.snapshotContainerRef&&this.snapshotContainerRef.current&&(i!==this.width||o!==this.height)&&(this.width=i,this.height=o),i&&o&&this.canvasBgRef.current&&(i!==this.width||o!==this.height)&&(this.width=i,this.height=o,this.control.isUseOffscreenTransfer||(this.canvasBgRef.current.width=i*this.dpr,this.canvasBgRef.current.height=o*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=i*this.dpr,this.canvasFloatRef.current.height=o*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=i*this.dpr,this.canvasServiceFloatRef.current.height=o*this.dpr),(e=this.canvasTopRef)!=null&&e.current&&(this.canvasTopRef.current.width=i*this.dpr,this.canvasTopRef.current.height=o*this.dpr))),i&&o&&this.backgroundContainerRef&&((t=this.backgroundContainerRef)!=null&&t.current)&&(i!==this.width||o!==this.height)&&(this.backgroundContainerRef.current.style.width=`${i}px`,this.backgroundContainerRef.current.style.height=`${o}px`,this.backgroundContainerRef.current.classList.toggle("appliance-plugin-background-isWritable",this.control.renderControl.isWritable))}}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(),rn.render(d.createElement(li,{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,backgroundContainerRef:this.backgroundContainerRef,backgroundSnapshotContainerRef:this.backgroundSnapshotContainerRef}}),t),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement),this}}class Um extends Ny{constructor(e,t,i){super(e,t,i);I(this,"dpr",kt());I(this,"width",1e3);I(this,"height",1e3);I(this,"vDom");I(this,"eventTragetElement");I(this,"canvasContainerRef",d.createRef());I(this,"subLocalCanvasContainerRef");I(this,"canvasTopRef");I(this,"canvasServiceFloatRef",d.createRef());I(this,"canvasFloatRef",d.createRef());I(this,"canvasBgRef",d.createRef());I(this,"backgroundContainerRef");I(this,"floatBarRef",d.createRef());I(this,"containerOffset",{x:0,y:0});this.control.isUseSimple||(this.canvasTopRef=d.createRef(),this.subLocalCanvasContainerRef=d.createRef()),this.control.isUseBackgroundThread&&(this.backgroundContainerRef=d.createRef())}setCanvassStyle(){var e,t;if(this.eventTragetElement){const i=kt();if(i!==this.dpr&&(this.dpr=i,this.control.worker.updateDpr(this.viewId,this.dpr)),this.canvasContainerRef.current){const o=this.eventTragetElement.offsetWidth||this.width,s=this.eventTragetElement.offsetHeight||this.height;o&&s&&(o!==this.width||s!==this.height)&&(this.width=o,this.height=s,this.canvasContainerRef.current.style.width=`${o}px`,this.canvasContainerRef.current.style.height=`${s}px`)}if(this.canvasBgRef.current){const o=this.eventTragetElement.offsetWidth||this.width,s=this.eventTragetElement.offsetHeight||this.height;o&&s&&(o!==this.width||s!==this.height)&&(this.width=o,this.height=s,this.control.isUseOffscreenTransfer||(this.canvasBgRef.current.width=o*this.dpr,this.canvasBgRef.current.height=s*this.dpr,this.canvasFloatRef.current&&(this.canvasFloatRef.current.width=o*this.dpr,this.canvasFloatRef.current.height=s*this.dpr),this.canvasServiceFloatRef.current&&(this.canvasServiceFloatRef.current.width=o*this.dpr,this.canvasServiceFloatRef.current.height=s*this.dpr),(e=this.canvasTopRef)!=null&&e.current&&(this.canvasTopRef.current.width=o*this.dpr,this.canvasTopRef.current.height=s*this.dpr)))}if(this.backgroundContainerRef&&((t=this.backgroundContainerRef)!=null&&t.current)){const o=this.eventTragetElement.offsetWidth||this.width,s=this.eventTragetElement.offsetHeight||this.height;o&&s&&(o!==this.width||s!==this.height)&&(this.backgroundContainerRef.current.style.width=`${o}px`,this.backgroundContainerRef.current.style.height=`${s}px`,this.backgroundContainerRef.current.classList.toggle("appliance-plugin-background-isWritable",this.control.renderControl.isWritable))}}}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(),rn.render(d.createElement(li,{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,backgroundContainerRef:this.backgroundContainerRef}}),i),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement),this}}class rt extends vt{constructor(e){super(e);I(this,"focuedViewId");I(this,"focuedView");I(this,"control");I(this,"tmpFocusedViewId");I(this,"checkScaleTimer");I(this,"mainViewHotkeyListener",e=>{this.onActiveHotkeyChange(e)});I(this,"appViewListeners",new Map);I(this,"onMainViewRelease",async e=>{this.control.textEditorManager.clear(ge,!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()});I(this,"mainViewDestroy",e=>{var t;if(this.mainView&&this.mainView.displayer){this.removeMainViewListeners(this.mainView.viewData),this.mainView.displayer.destroy();const i=e.divElement;if(i){const o=i.getElementsByClassName("appliance-plugin-main-view-displayer");for(const s of o)s.remove()}if(this.mainView.container&&i!==this.mainView.container){const o=this.mainView.container.getElementsByClassName("appliance-plugin-main-view-displayer");for(const s of o)s.remove()}(t=this.control.worker)==null||t.destroyViewWorker(this.mainView.id,!0),this.mainView=void 0}});I(this,"onMainViewMounted",e=>{const t=e.divElement;if(!t||!e.focusScenePath||!(e.focusScenePath||e.scenePath))return;const o=new Ym(this.control,we.InternalMsgEmitter),s=e.size.width||o.width,a=e.size.height||o.height;o.dpr;const c={cameraOpt:{...rt.defaultCameraOpt,width:s,height:a}},{scale:l,...h}=e.camera;c.cameraOpt={...c.cameraOpt,...h,scale:l===1/0?1:l},this.createMianView({id:ge,container:t,displayer:o,focusScenePath:e.focusScenePath,cameraOpt:c.cameraOpt,viewData:e}),this.setFocuedViewId(ge),o.createMainViewDisplayer(t),e.callbacks.on("onSizeUpdated",this.onMainViewSizeUpdated),e.callbacks.on("onCameraUpdated",this.onMainViewCameraUpdated),e.callbacks.on("onActiveHotkey",this.mainViewHotkeyListener)});I(this,"onMainViewSizeUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.mainView&&this.mainView.viewData&&this.updateMainViewCamera()});I(this,"onMainViewCameraUpdated",async()=>{await new Promise(e=>{setTimeout(()=>{e(!0)},0)}),this.updateMainViewCamera()});I(this,"updateMainViewCamera",()=>{if(this.mainView&&this.mainView.viewData){const e=this.mainView.viewData.camera;if(!x.isNumber(e.scale)||e.scale===1/0)return;const t=this.mainView.cameraOpt;if(t){const i=t.width,o=t.height,{width:s,height:a}=this.mainView.viewData.size;(s!==i||a!==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:s,height:a};x.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 f,p;(p=(f=this.mainView)==null?void 0:f.viewData)==null||p.moveCamera({scale:c,centerX:l,centerY:h,animationMode:"immediately"}),this.checkScaleTimer=void 0},500))}}});I(this,"onAppViewMounted",async e=>{var f;const{appId:t,view:i}=e,o=i.divElement;if(!o||!i.focusScenePath)return;const s=this.appViews.get(t);if(s&&s.displayer){let p=o.getElementsByClassName("appliance-plugin-app-view-displayer");for(const g of p)g.remove();if(s.container&&s.container!==o){p=s.container.getElementsByClassName("appliance-plugin-app-view-displayer");for(const g of p)g.remove()}this.destroyAppView(e.appId,!0),(f=this.control.worker)==null||f.destroyViewWorker(t,!0),await new Promise(g=>{setTimeout(()=>{g(!0)},0)})}const a=new Um(t,this.control,we.InternalMsgEmitter),c=i.size.width||a.width,l=i.size.height||a.height;a.dpr;const h={cameraOpt:{...rt.defaultCameraOpt,...i.camera,width:c,height:l}};this.createAppView({id:t,container:o,displayer:a,cameraOpt:h.cameraOpt,focusScenePath:i.focusScenePath,viewData:i}),a.createAppViewDisplayer(t,o);const u=this.getAppViewListeners(t);if(i.callbacks.on("onSizeUpdated",u.onSizeUpdated),i.callbacks.on("onCameraUpdated",u.onCameraUpdated),i.callbacks.on("onActiveHotkey",u.onActiveHotkey),this.tmpFocusedViewId===t){const p=this.control.worker.getLocalWorkViewId();p&&p!==t?this.setFocuedViewId(p):this.setFocuedViewId(t),this.tmpFocusedViewId=void 0}setTimeout(()=>{this.onAppViewCameraUpdated(t)},0)});I(this,"onAppViewSizeUpdated",async e=>{await new Promise(i=>{setTimeout(()=>{i(!0)},0)});const t=this.appViews.get(e);t&&t.viewData&&this.updateAppCamera(e)});I(this,"onAppViewCameraUpdated",async e=>{await new Promise(t=>{setTimeout(()=>{t(!0)},0)}),this.updateAppCamera(e)});I(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:s,height:a}=t.viewData.size,c=o.width,l=o.height;(s!==c||a!==l)&&t.displayer.updateSize();const h=i.scale===1/0?1:i.scale,u=i.centerX||0,f=i.centerY||0,p={...o,scale:h,centerX:u,centerY:f,width:s,height:a};x.isEqual(p,o)||(t.cameraOpt=p)}}});this.control=e.control}getAppViewListeners(e){let t=this.appViewListeners.get(e);return t||(t={onSizeUpdated:()=>{this.onAppViewSizeUpdated(e)},onCameraUpdated:()=>{this.onAppViewCameraUpdated(e)},onActiveHotkey:i=>{this.onActiveHotkeyChange(i)}},this.appViewListeners.set(e,t)),t}removeMainViewListeners(e){e&&(e.callbacks.off("onSizeUpdated",this.onMainViewSizeUpdated),e.callbacks.off("onCameraUpdated",this.onMainViewCameraUpdated),e.callbacks.off("onActiveHotkey",this.mainViewHotkeyListener))}removeAppViewListeners(e,t){const i=this.appViewListeners.get(e);t&&i&&(t.callbacks.off("onSizeUpdated",i.onSizeUpdated),t.callbacks.off("onCameraUpdated",i.onCameraUpdated),t.callbacks.off("onActiveHotkey",i.onActiveHotkey)),this.appViewListeners.delete(e)}destroyAppView(e,t=!1){const i=this.appViews.get(e);this.removeAppViewListeners(e,i==null?void 0:i.viewData),super.destroyAppView(e,t)}destroy(){var e;this.removeMainViewListeners((e=this.mainView)==null?void 0:e.viewData);for(const[t,i]of this.appViews.entries())this.removeAppViewListeners(t,i.viewData);super.destroy(),this.appViewListeners.clear()}getViewInitData(e){var i;const t=this.getView(e);if(t){const{width:o,height:s,dpr:a}=t.displayer;(i=this.control.pluginOptions.extras.canvasOpt)!=null&&i.contextType&&(rt.defaultScreenCanvasOpt.contextType=this.control.pluginOptions.extras.canvasOpt.contextType);const c={dpr:a,originalPoint:[o/2,s/2],offscreenCanvasOpt:{...rt.defaultScreenCanvasOpt,width:o,height:s},layerOpt:{...rt.defaultLayerOpt,width:o,height:s},cameraOpt:{...rt.defaultCameraOpt,width:o,height:s}};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,s;const t=this.getView(e);if(t){e===((i=this.mainView)==null?void 0:i.id)&&(this.control.cursor.activeCollector(),await this.control.activeWorker()),this.control.isUseOffscreenTransfer&&t.displayer.canvasBgRef.current&&t.displayer.canvasServiceFloatRef.current&&t.displayer.canvasFloatRef.current&&t.displayer.setTransferControlToOffscreenCanvas({bgCanvas:t.displayer.canvasBgRef.current,serviceCanvas:t.displayer.canvasServiceFloatRef.current,localCanvas:t.displayer.canvasFloatRef.current});const a=this.getViewInitData(e);if(a&&((o=this.control.worker)==null||o.createViewWorker(e,a,t.displayer)),t.focusScenePath&&this.control.collector){if(this.control.collector.authStorage){const{renderAuth:c,pageAuth:l}=this.control.collector.authStorage;if(c){const h=c[e];if(h){const{render:u,hide:f,clear:p}=h;this.control.renderControl.syncRenderUids(e,u,f,p);return}}if(l){const h=l[e];if(h){this.control.renderControl.syncPageAuth(e,h,!0);return}}}this.control.worker.pullServiceData(e,t.focusScenePath,{isAsync:!0,useAnimation:!1}),this.control.pluginOptions.extras.undoRedo.enableGlobal&&t.displayer.commiter&&((s=this.control.collector)!=null&&s.globalUndoRedoStackStorage[t.id])&&t.displayer.commiter.pullServiceData(this.control.collector.globalUndoRedoStackStorage[t.id])}}}listenerWindowManager(e){e.emitter.on("focusedChange",t=>{const i=t||ge;if(this.focuedViewId!==i)if(this.getView(i)){const s=this.control.worker.getLocalWorkViewId();s&&s!==i?this.setFocuedViewId(s):this.setFocuedViewId(i)}else this.tmpFocusedViewId=i}),e.emitter.on("mainViewScenePathChange",t=>{this.control.onSceneChange(t,ge)}),e.emitter.on("onMainViewMounted",this.onMainViewMounted),e.emitter.on("onAppViewMounted",this.onAppViewMounted),e.emitter.on("onMainViewRebind",this.onMainViewRelease),e.emitter.on("onBoxClose",t=>{this.appViews.get(t.appId)&&(this.destroyAppView(t.appId),this.control.worker.destroyViewWorker(t.appId))}),e.emitter.on("onAppScenePathChange",t=>{const{appId: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 it extends we{constructor(e){super(e);I(this,"windowManager");I(this,"viewContainerManager");const t={control:this,internalMsgEmitter:we.InternalMsgEmitter,publicMsgEmitter:we.PublicMsgEmitter};this.viewContainerManager=new rt(t)}init(){}activePlugin(){this.collector&&(this.collector.addAuthStateListener((e,t)=>{e&&Object.keys(e).forEach(i=>{var s;const o=(s=e[i])==null?void 0:s.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 s;const o=(s=t[i])==null?void 0:s.newValue;this.renderControl.syncPageAuth(i,o)})}),this.collector.addStorageStateListener(e=>{var a,c;if((a=this.collector)!=null&&a.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(ge,!0);return}const{diffView:t,diffScenePath:i,diffData:o}=e,s=new Map;if(t){let l;Object.keys(t).forEach(h=>{var f;const u=t[h];if(u&&!u.newValue)(f=this.worker)==null||f.clearViewScenePath(h,!0),u.oldValue&&(l=u.oldValue);else if(u&&u.newValue){for(const p of Object.keys(u.newValue))this.worker.pullServiceData(h,p,{isAsync:!1,useAnimation:!1});l=u.newValue}if(l)for(const p of Object.values(l)){const g=new Set;for(const m of Object.keys(p))m&&g.add(m);s.set(h,g)}})}if(i){let l;Object.keys(i).forEach(h=>{var f;const u=i[h];if(u&&u.viewId&&!u.newValue?((f=this.worker)==null||f.clearViewScenePath(u.viewId,!0),u.oldValue&&(l=u.oldValue)):u&&u.viewId&&u.newValue&&(this.worker.pullServiceData(u.viewId,h,{isAsync:!1,useAnimation:!1}),l=u.newValue),u!=null&&u.viewId&&l){const p=new Set;for(const g of Object.keys(l))g&&p.add(g),s.set(u.viewId,p)}})}o&&Object.keys(o).forEach(l=>{var u,f;const h=o[l];if(h){const{viewId:p}=h,g=s.get(p)||new Set;g.add(l),s.set(p,g),(u=this.worker)==null||u.onServiceDerive(l,h),(f=this.miniMapManager)==null||f.updateMiniMapCamera(p)}});for(const[l,h]of s.entries())we.InternalMsgEmitter.emit("excludeIds",[...h],l)}),this.pluginOptions.extras.undoRedo.enableGlobal&&this.collector.addGlobalUndoRedoStackListener(e=>{Object.keys(e).forEach(t=>{var s;const i=e[t],o=(s=this.viewContainerManager.getView(t))==null?void 0:s.displayer.commiter;o&&o.pullServiceData(i==null?void 0:i.newValue)})}),this.worker.isActive&&this.viewContainerManager.getAllViews().forEach(e=>{e&&e.focusScenePath&&this.worker.pullServiceData(e.id,e.focusScenePath,{isAsync:!0,useAnimation:!1})}),this.room&&this.roomMember.onUidChangeHook(e=>{var t,i;(t=this.collector)!=null&&t.serviceStorage&&this.viewContainerManager.getAllViews().forEach(o=>{var s,a,c,l;if(o&&o.focusScenePath&&((s=this.collector)!=null&&s.serviceStorage[o.id])&&this.collector.serviceStorage[o.id][o.focusScenePath]){const h=Object.keys(this.collector.serviceStorage[o.id][o.focusScenePath]);for(const u of h){const f=(a=this.collector)==null?void 0:a.getUidFromKey(u);if(f&&!e.online.includes(f))if((c=this.collector)!=null&&c.isSelector(u))this.renderControl.isWritable&&((l=this.collector)==null||l.updateValue(u,void 0,{viewId:o.id,scenePath:o.focusScenePath,isSync:!0})),this.worker.blurSelector(o.id,o.focusScenePath,u);else{const p=this.textEditorManager.editors.get(u);p&&p.opt&&(p.opt.workState===j.Doing||p.opt.workState===j.Start)&&(p.opt.text&&p.opt.text.replace(/\s*,/g,"")?this.textEditorManager.unActive(u):this.textEditorManager.delete(u))}}}}),(i=this.cursor)==null||i.updateRoomMembers(e)}))}async activeWorker(){await this.worker.init()}setWindowManager(e){var t,i,o,s,a;this.windowManager=e,(i=(t=this.windowManager)==null?void 0:t.mainView)!=null&&i.divElement&&this.viewContainerManager.onMainViewMounted(this.windowManager.mainView),(a=(s=(o=this.windowManager.appManager)==null?void 0:o.viewManager)==null?void 0:s.views)!=null&&a.size&&this.windowManager.appManager.viewManager.views.forEach((c,l)=>{this.viewContainerManager.onAppViewMounted({appId:l,view:c})}),this.viewContainerManager.listenerWindowManager(this.windowManager)}}const b=class b extends F.InvisiblePlugin{constructor(){super(...arguments);I(this,"onPhaseChanged",e=>{var t;e===F.RoomPhase.Reconnecting&&((t=b.currentManager)==null||t.setSnapshootData())});I(this,"updateRoomWritable",()=>{var e;(e=b.currentManager)==null||e.onWritableChange(this.displayer.isWritable)});I(this,"roomStateChangeListener",async e=>{var t,i;e!=null&&e.roomMembers&&((t=b.currentManager)==null||t.onRoomMembersChange(e.roomMembers)),!(F.isRoom(this.displayer)&&!this.displayer.isWritable)&&e.memberState&&((i=b.currentManager)==null||i.onMemberChange(e.memberState))})}static async getInstance(e,t){var w;t.options&&(((w=t.options.extras)==null?void 0:w.useWorker)==="mainThread"&&(t.options.cdn.fullWorkerUrl="",t.options.cdn.subWorkerUrl=""),(t.options.extras&&t.options.extras.useWorker!=="mainThread"||!t.options.extras)&&!t.options.cdn.fullWorkerUrl&&!t.options.cdn.subWorkerUrl&&b.logger.error("[Appliance]: [ApplianceMultiPlugin] you must adaptor options cdn fullWorkerUrl and subWorkerUrl"));const i=e.displayer,o=i.callbacks.on,s=i.callbacks.off,a=i.callbacks.once,c=e.cleanCurrentScene,l=e.mainView.setMemberState;let h;F.isRoom(i)&&(h=i.setWritable),t!=null&&t.logger&&(b.logger=t.logger);let u=i.getInvisiblePlugin(b.kind);u||(u=await b.createApplianceMultiPlugin(i,b.kind)),i&&u&&b.createCurrentManager(e,{cdn:t.options.cdn,extras:{...me,...t.options.extras}},u);const f={displayer:i,windowManager:e,currentManager:b.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,getBoundingRectAsync:async function(y){var S;b.logger.info("[ApplianceMultiPlugin] getBoundingRectAsync");const M=(e.mainView||i).getBoundingRect(y),v=await((S=b.currentManager)==null?void 0:S.getBoundingRect(y));return!M.width||!M.height?v:oi(M,v)},screenshotToCanvasAsync:async function(y,M,v,S,C,k){var E;b.logger.info("[ApplianceMultiPlugin] screenshotToCanvasAsync");let N=v,z=S,P=C.scale;N>this.maxScreenshotWidth&&(P=this.maxScreenshotWidth/N*P,N=this.maxScreenshotWidth),z>this.maxScreenshotHeight&&(P=Math.min(this.maxScreenshotHeight/z*P,P),z=this.maxScreenshotHeight),C.scale=P;const L=document.createElement("canvas"),R=L.getContext("2d");L.width=N*(k||1),L.height=z*(k||1),R&&((e.mainView||i).screenshotToCanvas(R,M,N,z,C,k),y.drawImage(L,Math.floor((v-N)/2),Math.floor((S-z)/2),N*(k||1),z*(k||1),0,0,N,z),L.remove()),b.currentManager&&await((E=b.currentManager)==null?void 0:E.screenshotToCanvas(y,M,N,z,C,Math.floor((v-N)/2),Math.floor((S-z)/2)))},scenePreviewAsync:async function(y,M,v,S,C){b.logger.info("[ApplianceMultiPlugin] scenePreviewAsync"),(e.mainView||i).scenePreview(y,M,v,S,C);const k=document.createElement("img");k.className="appliance-plugin-fill-scene-snapshot-img",M.append(k),getComputedStyle(M).position||(M.style.position="relative"),b.currentManager&&await b.currentManager.scenePreview(y,k)},fillSceneSnapshotAsync:async function(y,M,v,S,C){b.logger.info("[ApplianceMultiPlugin] fillSceneSnapshotAsync"),M.innerHTML="",(e.mainView||i).fillSceneSnapshot(y,M,v,S,C);const k=v||e.mainView.size.width,N=S||e.mainView.size.height;let z=await this.getBoundingRectAsync(y);z||(z={originX:0,originY:0,width:k,height:N});let P=Math.max(z==null?void 0:z.width,k),L=Math.max(z==null?void 0:z.height,N),R=1;const E=P>k&&Math.min(k/P,R)||R,O=L>N&&Math.min(N/L,R)||R;E<=O?(P=E<1&&k||P,L=Math.floor(L*E)+1,R=E):E>O&&(L=O<1&&N||L,P=Math.floor(P*O)+1,R=O);const D={scale:R,centerX:z.originX+z.width/2,centerY:z.originY+z.height/2},V=document.createElement("canvas"),J=V.getContext("2d");V.width=P,V.height=L,J&&await this.screenshotToCanvasAsync(J,y,P,L,D,devicePixelRatio);const U=document.createElement("img");U.className="appliance-plugin-fill-scene-snapshot-img",U.src=V.toDataURL(),U.onload=()=>{V.remove()},U.onerror=()=>{V.remove(),U.remove()},M.append(U),getComputedStyle(M).position||(M.style.position="relative")},_callbacksOn:function(y,M){b.logger.info(`[ApplianceMultiPlugin] callbacks ${y}`),(y==="onCanUndoStepsUpdate"||y==="onCanRedoStepsUpdate")&&F.isRoom(i)&&i.isWritable?it.InternalMsgEmitter.on(y,M):o.call(i.callbacks,y,M)},_callbacksOnce:function(y,M){b.logger.info(`[ApplianceMultiPlugin] callbacks ${y}`),(y==="onCanUndoStepsUpdate"||y==="onCanRedoStepsUpdate")&&F.isRoom(i)&&i.isWritable?it.InternalMsgEmitter.on(y,M):a.call(i.callbacks,y,M)},_callbacksOff:function(y,M){b.logger.info(`[ApplianceMultiPlugin] callbacks ${y}`),(y==="onCanUndoStepsUpdate"||y==="onCanRedoStepsUpdate")&&F.isRoom(i)&&i.isWritable?it.InternalMsgEmitter.off(y,M):s.call(i.callbacks,y,M)},canRedoSteps(){if(b.logger.info("[ApplianceMultiPlugin] canRedoSteps"),b.currentManager&&F.isRoom(i)&&!i.disableSerialization){const y=b.currentManager.viewContainerManager.focuedView,M=y==null?void 0:y.focusScenePath;if(y&&M)return y.displayer.commiter.redoStack.filter(v=>v.scenePath===M).length}return 0},canUndoSteps(){if(b.logger.info("[ApplianceMultiPlugin] canUndoSteps"),b.currentManager&&F.isRoom(i)&&!i.disableSerialization){const y=b.currentManager.viewContainerManager.focuedView,M=y==null?void 0:y.focusScenePath;if(y&&M)return y.displayer.commiter.undoStack.filter(C=>C.scenePath===M).length}return 0},undo:function(){return b.logger.info("[ApplianceMultiPlugin] undo"),b.currentManager&&F.isRoom(i)&&!i.disableSerialization&&i.isWritable?b.currentManager.viewContainerManager.undo():0},redo:function(){return b.logger.info("[ApplianceMultiPlugin] redo"),b.currentManager&&F.isRoom(i)&&!i.disableSerialization&&i.isWritable?b.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(){b.logger.info("[ApplianceMultiPlugin] cleanCurrentScene"),b.currentManager&&F.isRoom(i)&&i.isWritable&&(b.currentManager.logger.info("[Appliance]: cleanCurrentScene"),b.currentManager.cleanCurrentScene(),c.call(e))},insertImage:function(y){if(b.logger.info("[ApplianceMultiPlugin] insertImage"),b.currentManager&&F.isRoom(i)&&i.isWritable){const M=b.currentManager.viewContainerManager.focuedViewId||ge;b.currentManager.worker.insertImage(M,y)}},lockImage:function(y,M){if(b.logger.info("[ApplianceMultiPlugin] lockImage"),b.currentManager&&F.isRoom(i)&&i.isWritable){const v=b.currentManager.viewContainerManager.focuedViewId||ge;b.currentManager.worker.lockImage(v,y,M)}},completeImageUpload:function(y,M){if(b.logger.info("[ApplianceMultiPlugin] completeImageUpload"),b.currentManager&&F.isRoom(i)&&i.isWritable){const v=b.currentManager.viewContainerManager.focuedViewId||ge;b.currentManager.worker.completeImageUpload(v,y,M)}},getImagesInformation:function(y){return b.logger.info("[ApplianceMultiPlugin] completeImageUpload"),b.currentManager&&F.isRoom(i)&&i.isWritable?b.currentManager.worker.getImagesInformation(y):[]},insertText:function(y,M,v){if(b.logger.info("[ApplianceMultiPlugin] insertText"),b.currentManager&&F.isRoom(i)&&i.isWritable){const S=b.currentManager.viewContainerManager.focuedViewId||ge;return b.currentManager.textEditorManager.insertText(S,y,M,v)}},updateText:function(y,M){b.logger.info("[ApplianceMultiPlugin] updateText"),b.currentManager&&F.isRoom(i)&&i.isWritable&&b.currentManager.textEditorManager.updateText(y,M)},callbacks:()=>(b.logger.info("[ApplianceMultiPlugin] callbacks bind"),{...i.callbacks,on:f._callbacksOn.bind(f),once:f._callbacksOnce.bind(f),off:f._callbacksOff.bind(f)}),destroy(){b.currentManager&&(b.currentManager.logger.info("[Appliance]: [ApplianceMultiPlugin] destroy"),b.currentManager.destroy(),b.currentManager=void 0)},setMemberState(y){if(b.currentManager){b.currentManager.logger.info(`[Appliance]: setMemberState ${JSON.stringify(y)}`);const M=Object.keys(y);if(F.isRoom(i)&&i.isWritable){if(M.includes("currentApplianceName"))if(y.currentApplianceName&&y.currentApplianceName===te.laserPen){if(b.currentManager.isUseSimple)throw b.currentManager.logger.error("[Appliance]: [ApplianceMultiPlugin] laserPen must be not support in simple mode"),new Error("[Appliance]: [ApplianceMultiPlugin] laserPen must be not support in simple mode");y.currentApplianceName=te.pencil,y.useLaserPen=!0}else y.currentApplianceName&&y.currentApplianceName===te.pencil&&(y.useLaserPen=!1);l.call(e.mainView,y);return}}throw b.logger.error("[Appliance]: [ApplianceMultiPlugin] setMemberState must be called in writable room"),new Error("[Appliance]: [ApplianceMultiPlugin] setMemberState must be called in writable room")},createMiniMap:async function(y,M){if(b.logger.info("[ApplianceMultiPlugin] createMiniMap"),b.currentManager&&F.isRoom(i)&&i.isWritable)return b.currentManager.logger.info("[Appliance]: [ApplianceMultiPlugin] createMiniMap"),b.currentManager.createMiniMap(y,M)},destroyMiniMap:async function(y){if(b.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),b.currentManager&&F.isRoom(i)&&i.isWritable)return b.currentManager.logger.info("[Appliance]: [ApplianceMultiPlugin] destroyeMiniMap"),b.currentManager.destroyMiniMap(y)},filterRenderByUid(y,M,v){if(b.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),b.currentManager&&F.isRoom(i)&&i.isWritable)return b.currentManager.filterRenderByUid(y,M,v)},cancelFilterRender(y,M){if(b.logger.info("[ApplianceMultiPlugin] filterRenderByUid"),b.currentManager&&F.isRoom(i)&&i.isWritable)return b.currentManager.cancelFilterRender(y,M)},addListener:(y,M)=>{b.logger.info(`[ApplianceMultiPlugin] addListener ${y}`),it.PublicMsgEmitter.on(y,M)},removeListener:(y,M)=>{b.logger.info(`[ApplianceMultiPlugin] removeListener ${y}`),it.PublicMsgEmitter.off(y,M)},usePlugin:y=>{var M;b.logger.info("[ApplianceMultiPlugin] usePlugin",y.kind),(M=b.currentManager)==null||M.usePlugin(y)},getDisableDeviceInputs(){if(b.currentManager&&F.isRoom(i))return b.currentManager.disableDeviceInputs},setDisableDeviceInputs(y){b.logger.info(`[ApplianceMultiPlugin] setDisableDeviceInputs ${y}`),b.currentManager&&F.isRoom(i)&&(b.currentManager.disableDeviceInputs=y)},getDisableCameraTransform(){if(b.currentManager&&F.isRoom(i))return b.currentManager.disableCameraTransform},setDisableCameraTransform(y){b.logger.info(`[ApplianceMultiPlugin] setDisableCameraTransform ${y}`),b.currentManager&&F.isRoom(i)&&(b.currentManager.disableCameraTransform=y)},getDisableEraseImage(){if(b.currentManager&&F.isRoom(i))return b.currentManager.disableEraseImage},setDisableEraseImage(y){b.logger.info(`[ApplianceMultiPlugin] setDisableEraseImage ${y}`),b.currentManager&&F.isRoom(i)&&(b.currentManager.disableEraseImage=y)},setWritable:async function(y){var M;b.logger.info(`[ApplianceMultiPlugin] setWritable ${y}`),F.isRoom(i)&&h&&(await((M=b.currentManager)==null?void 0:M.setWritable(y)),await h.call(i,y))},requestIdleCallback:(y,M)=>{const v=(M==null?void 0:M.timeout)||0,S=performance.now();let C;const k=new MessageChannel;let N;const z=P=>{try{y({didTimeout:P,timeRemaining:()=>{const R=performance.now()-S;return Math.max(0,v-R)}})}catch(L){b.logger.error("[ApplianceMultiPlugin] requestIdleCallback error:",L)}finally{k.port1.close(),k.port2.close(),C!==void 0&&cancelAnimationFrame(C),N!==void 0&&clearTimeout(N)}};return k.port1.onmessage=()=>{C=requestAnimationFrame(()=>{v>0&&performance.now()-S>=v?z(!0):z(!1)})},k.port2.postMessage(null),v>0&&(N=setTimeout(()=>{z(!0)},v)),N||C||0},cancelIdleCallback:y=>{try{clearTimeout(y),cancelAnimationFrame(y)}catch(M){b.logger.error("[ApplianceMultiPlugin] cancelIdleCallback error:",M)}},injectMethodToObject:(y,M)=>{if(b.logger.info(`[ApplianceMultiPlugin] injectMethodToObject ${M}`),typeof y[M]=="function"||typeof y[M]>"u"){(M==="requestIdleCallback"||M==="cancelIdleCallback")&&b.currentManager&&b.currentManager.registerPolyfillMethod(M),y[M]=f[M];return}M==="callbacks"&&(y.callbacks.on=f._callbacksOn.bind(f),y.callbacks.off=f._callbacksOff.bind(f),y.callbacks.once=f._callbacksOnce.bind(f))},blurText:()=>{b.logger.info("[ApplianceMultiPlugin] blurText"),b.currentManager&&F.isRoom(i)&&i.isWritable&&b.currentManager.textEditorManager.checkEmptyTextBlur()},hasElements:(y,M)=>{var v;if(b.logger.info(`[ApplianceMultiPlugin] hasElements ${y}`),b.currentManager&&F.isRoom(i)&&i.isWritable){let S=y;if(!S){const C=b.currentManager.viewContainerManager.focuedView;S=C==null?void 0:C.focusScenePath}if(S){const C=(v=b.currentManager.collector)==null?void 0:v.getScenePathData(S);if(C){const k=Object.values(C);return k.length>0?M?k.some(N=>M(N.toolsType)):!0:!1}return!1}return!1}},getElements:(y,M)=>{var v;if(b.logger.info(`[ApplianceMultiPlugin] getElements ${y}`),b.currentManager&&F.isRoom(i)&&i.isWritable){let S=y;if(!S){const C=b.currentManager.viewContainerManager.focuedView;S=C==null?void 0:C.focusScenePath}if(S){const C=(v=b.currentManager.collector)==null?void 0:v.getScenePathData(S),k=C&&Object.values(C)||[];return C&&k.length>0&&M?k.filter(N=>M(N.toolsType)):k}return[]}},stopDraw:y=>{if(b.logger.info(`[ApplianceMultiPlugin] stopDraw ${y}`),b.currentManager&&F.isRoom(i))return b.currentManager.stopDraw(y)},setViewLocalScenePathChange:async(y,M)=>{b.logger.info(`[ApplianceMultiPlugin] setViewLocalScenePathChange ${y} ${M}`),b.currentManager&&await b.currentManager.setViewLocalScenePathChange(M,y)},insertMarkmap:async(y,M)=>{if(b.logger.info(`[ApplianceMultiPlugin] insertMarkmap: ${y}, info: ${JSON.stringify(M)}`),b.currentManager&&b.currentManager.isUseBackgroundThread)return b.currentManager.worker.insertBackgroundMarkMap(y,M)},updateMarkmap:async(y,M,v)=>{if(b.logger.info(`[ApplianceMultiPlugin] updateMarkmap: ${y}, markmapId: ${M}, info: ${JSON.stringify(v)}`),b.currentManager&&b.currentManager.isUseBackgroundThread)return b.currentManager.worker.updateBackgroundMarkMap(y,M,v)},insertBackgroundImage:async(y,M)=>{if(b.logger.info(`[ApplianceMultiPlugin] insertBackgroundImage: ${y}, info: ${JSON.stringify(M)}`),b.currentManager&&b.currentManager.isUseBackgroundThread)return b.currentManager.worker.insertBackgroundSVG(y,M)}};f.injectMethodToObject(e,"undo"),f.injectMethodToObject(e,"redo"),f.injectMethodToObject(e,"cleanCurrentScene"),f.injectMethodToObject(e,"insertImage"),f.injectMethodToObject(e,"completeImageUpload"),f.injectMethodToObject(e,"lockImage"),f.injectMethodToObject(e,"insertText"),f.injectMethodToObject(e,"updateText"),f.injectMethodToObject(i,"getImagesInformation"),f.injectMethodToObject(i,"callbacks"),f.injectMethodToObject(i,"screenshotToCanvasAsync"),f.injectMethodToObject(i,"getBoundingRectAsync"),f.injectMethodToObject(i,"scenePreviewAsync"),f.injectMethodToObject(i,"fillSceneSnapshotAsync"),f.injectMethodToObject(e.mainView,"setMemberState"),F.isRoom(i)&&f.injectMethodToObject(i,"setWritable"),Object.defineProperty(e,"canUndoSteps",{get(){return f.canUndoSteps()}}),Object.defineProperty(e,"canRedoSteps",{get(){return f.canRedoSteps()}});const p=(y,M,v=3)=>{const S=e.focused||ge;v>0&&S!==y?setTimeout(()=>{p(y,M,v-1)},100):e.emitter.emit("canUndoStepsChange",M)};it.InternalMsgEmitter.on("onCanUndoStepsUpdate",(y,M)=>{p(M,y)});const g=(y,M,v=3)=>{const S=e.focused||ge;v>0&&S!==y?setTimeout(()=>{g(y,M,v-1)},100):e.emitter.emit("canRedoStepsChange",M)};it.InternalMsgEmitter.on("onCanRedoStepsUpdate",(y,M)=>{g(M,y)});const m={...f,callbacks:f.callbacks()};return Object.defineProperty(m,"disableDeviceInputs",{set(y){f.setDisableDeviceInputs(y)},get(){return f.getDisableDeviceInputs()}}),Object.defineProperty(m,"disableCameraTransform",{set(y){f.setDisableCameraTransform(y)},get(){return f.getDisableCameraTransform()}}),Object.defineProperty(m,"disableEraseImage",{set(y){f.setDisableEraseImage(y)},get(){return f.getDisableEraseImage()}}),u&&b.currentManager&&(b.currentManager.bindPlugin(u),u.init(i)),e._appliancePlugin=m,e._appliancePlugin}static onCreate(e){e&&b.currentManager&&(b.currentManager.bindPlugin(e),e.init(e.displayer))}static async createApplianceMultiPlugin(e,t){try{await e.createInvisiblePlugin(b,{})}catch(o){if(!e.isWritable){await e.setWritable(!0);const s=await this.createApplianceMultiPlugin(e,t);return await e.setWritable(!1),s}throw o}let i=e.getInvisiblePlugin(t);return i||(i=await b.createApplianceMultiPlugin(e,t)),i}get isReplay(){return F.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(e){var i,o;const t=e.state;(i=b.currentManager)==null||i.onRoomMembersChange(t.roomMembers),F.isRoom(e)&&((o=b.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;b.logger.info("[ApplianceMultiPlugin] passive destroy"),(e=b.currentManager)==null||e.destroy(),b.currentManager=void 0}};I(b,"kind","appliance-multi-plugin"),I(b,"currentManager"),I(b,"logger",{info:console.log,warn:console.warn,error:console.error}),I(b,"createCurrentManager",(e,t,i)=>{b.currentManager&&b.currentManager.destroy();const o={plugin:i,displayer:e.displayer,options:t},s=new it(o);if(b.logger.info("[ApplianceMultiPlugin] refresh ApplianceMultiManager object"),s.setWindowManager(e),b.currentManager=s,e.room){const a=s.hasOffscreenCanvas;e.room.logger.info(`[Appliance]: [ApplianceMultiPlugin] use ${a?"worker":"mainThread"}`)}});let Bn=b;var Bm=Qe,Wm=function(){return Bm.Date.now()},Vm=Wm,Fm=/\s/;function Qm(r){for(var n=r.length;n--&&Fm.test(r.charAt(n)););return n}var Gm=Qm,Zm=Gm,$m=/^\s+/;function Hm(r){return r&&r.slice(0,Zm(r)+1).replace($m,"")}var Jm=Hm,Xm=jt,qm=at,Km="[object Symbol]";function _m(r){return typeof r=="symbol"||qm(r)&&Xm(r)==Km}var eI=_m,tI=Jm,Xi=ct,nI=eI,qi=NaN,iI=/^[-+]0x[0-9a-f]+$/i,rI=/^0b[01]+$/i,oI=/^0o[0-7]+$/i,sI=parseInt;function aI(r){if(typeof r=="number")return r;if(nI(r))return qi;if(Xi(r)){var n=typeof r.valueOf=="function"?r.valueOf():r;r=Xi(n)?n+"":n}if(typeof r!="string")return r===0?r:+r;r=tI(r);var e=rI.test(r);return e||oI.test(r)?sI(r.slice(2),e?2:8):iI.test(r)?qi:+r}var cI=aI,lI=ct,vn=Vm,Ki=cI,uI="Expected a function",hI=Math.max,dI=Math.min;function gI(r,n,e){var t,i,o,s,a,c,l=0,h=!1,u=!1,f=!0;if(typeof r!="function")throw new TypeError(uI);n=Ki(n)||0,lI(e)&&(h=!!e.leading,u="maxWait"in e,o=u?hI(Ki(e.maxWait)||0,n):o,f="trailing"in e?!!e.trailing:f);function p(k){var N=t,z=i;return t=i=void 0,l=k,s=r.apply(z,N),s}function g(k){return l=k,a=setTimeout(y,n),h?p(k):s}function m(k){var N=k-c,z=k-l,P=n-N;return u?dI(P,o-z):P}function w(k){var N=k-c,z=k-l;return c===void 0||N>=n||N<0||u&&z>=o}function y(){var k=vn();if(w(k))return M(k);a=setTimeout(y,m(k))}function M(k){return a=void 0,f&&t?p(k):(t=i=void 0,s)}function v(){a!==void 0&&clearTimeout(a),l=0,t=c=i=a=void 0}function S(){return a===void 0?s:M(vn())}function C(){var k=vn(),N=w(k);if(t=arguments,i=this,c=k,N){if(a===void 0)return g(c);if(u)return clearTimeout(a),a=setTimeout(y,n),p(c)}return a===void 0&&(a=setTimeout(y,n)),s}return C.cancel=v,C.flush=S,C}var fI=gI,MI=fI,pI=ct,yI="Expected a function";function mI(r,n,e){var t=!0,i=!0;if(typeof r!="function")throw new TypeError(yI);return pI(e)&&(t="leading"in e?!!e.leading:t,i="trailing"in e?!!e.trailing:i),MI(r,n,{leading:t,maxWait:n,trailing:i})}var II=mI;const wI=on(II);class TI extends Fr{constructor(e,t){super(e,t);I(this,"width",1e3);I(this,"height",1e3);I(this,"dpr",kt());I(this,"vDom");I(this,"eventTragetElement");I(this,"snapshotContainerRef");I(this,"backgroundContainerRef");I(this,"backgroundSnapshotContainerRef");I(this,"canvasContainerRef",d.createRef());I(this,"subLocalCanvasContainerRef");I(this,"canvasTopRef");I(this,"canvasServiceFloatRef",d.createRef());I(this,"canvasFloatRef",d.createRef());I(this,"canvasBgRef",d.createRef());I(this,"floatBarRef",d.createRef());I(this,"containerOffset",{x:0,y:0});this.control.hasOffscreenCanvas||(this.snapshotContainerRef=d.createRef()),this.control.isUseSimple||(this.canvasTopRef=d.createRef(),this.subLocalCanvasContainerRef=d.createRef()),this.control.isUseBackgroundThread&&(this.backgroundContainerRef=d.createRef(),this.backgroundSnapshotContainerRef=d.createRef())}setCanvassStyle(){var e;if(this.eventTragetElement){const t=this.eventTragetElement.offsetWidth,i=this.eventTragetElement.offsetHeight,o=kt();o!==this.dpr&&(this.dpr=o,this.control.worker.updateDpr(this.viewId,this.dpr)),t&&i&&this.canvasContainerRef.current&&(t!==this.width||i!==this.height)&&(this.width=t,this.height=i),t&&i&&this.backgroundContainerRef&&this.backgroundContainerRef.current&&(t!==this.width||i!==this.height)&&(this.width=t,this.height=i,this.backgroundContainerRef.current.style.width=`${t}px`,this.backgroundContainerRef.current.style.height=`${i}px`,this.backgroundContainerRef.current.classList.toggle("appliance-plugin-background-isWritable",this.control.renderControl.isWritable)),t&&i&&this.canvasBgRef.current&&(t!==this.width||i!==this.height)&&(this.width=t,this.height=i,this.control.isUseOffscreenTransfer||(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),(e=this.canvasTopRef)!=null&&e.current&&(this.canvasTopRef.current.width=t*this.dpr,this.canvasTopRef.current.height=i*this.dpr)))}}createMainViewDisplayer(e){return this.vDom||(this.containerOffset=this.getContainerOffset(e,this.containerOffset),this.eventTragetElement=e.parentElement.children[0],e.innerHTML="",rn.render(d.createElement(li,{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,backgroundContainerRef:this.backgroundContainerRef,backgroundSnapshotContainerRef:this.backgroundSnapshotContainerRef}}),e),this.control.room&&this.bindDisplayerEvent(this.eventTragetElement)),this}}class Mt extends vt{constructor(e){super(e);I(this,"focuedViewId");I(this,"control");I(this,"focuedView");this.control=e.control}bindMainView(){if(!this.control.divMainView)return;const e=new TI(this.control,we.InternalMsgEmitter),{width:t,height:i,dpr:o}=e,s={cameraOpt:{...Mt.defaultCameraOpt,width:t,height:i}},a=this.control.room&&this.control.room.mainView||this.control.play&&this.control.play.mainView;if(a){const{scale:c,...l}=a.camera;s.cameraOpt={...s.cameraOpt,...l,scale:c===1/0?1:c},this.createMianView({id:ge,displayer:e,focusScenePath:a.focusScenePath||a.scenePath,cameraOpt:s.cameraOpt,viewData:a}),this.setFocuedViewId(ge),e.createMainViewDisplayer(this.control.divMainView)}}getViewInitData(e){var i;const t=this.getView(e);if(t){const{width:o,height:s,dpr:a}=t.displayer;(i=this.control.pluginOptions.extras.canvasOpt)!=null&&i.contextType&&(Mt.defaultScreenCanvasOpt.contextType=this.control.pluginOptions.extras.canvasOpt.contextType);const c={dpr:a,originalPoint:[o/2,s/2],offscreenCanvasOpt:{...Mt.defaultScreenCanvasOpt,width:o,height:s},layerOpt:{...Mt.defaultLayerOpt,width:o,height:s},cameraOpt:{...Mt.defaultCameraOpt,width:o,height:s}};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(),this.control.isUseOffscreenTransfer&&t.displayer.canvasBgRef.current&&t.displayer.canvasServiceFloatRef.current&&t.displayer.canvasFloatRef.current&&t.displayer.setTransferControlToOffscreenCanvas({bgCanvas:t.displayer.canvasBgRef.current,serviceCanvas:t.displayer.canvasServiceFloatRef.current,localCanvas:t.displayer.canvasFloatRef.current}),await this.control.activeWorker());const o=this.getViewInitData(e);o&&((i=this.control.worker)==null||i.createViewWorker(e,o,t.displayer)),t.focusScenePath&&this.control.collector&&this.control.worker.pullServiceData(e,t.focusScenePath,{isAsync:!0,useAnimation:!1})}}}class Be extends we{constructor(e){super(e);I(this,"viewContainerManager");I(this,"divMainView");I(this,"onCameraChange",wI(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)},Qn,{leading:!1}));const t={control:this,internalMsgEmitter:Be.InternalMsgEmitter,publicMsgEmitter:Be.PublicMsgEmitter};this.viewContainerManager=new Mt(t)}init(){Be.InternalMsgEmitter.on(_.BindMainView,e=>{this.divMainView=e,this.plugin&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView()})}activePlugin(){this.plugin&&this.divMainView&&!this.viewContainerManager.mainView&&this.viewContainerManager.bindMainView(),this.collector&&(this.collector.addStorageStateListener(e=>{var a,c;if((a=this.collector)!=null&&a.storage&&Object.keys(this.collector.storage).length===0){(c=this.worker)==null||c.clearViewScenePath(ge,!0);return}const{diffView:t,diffScenePath:i,diffData:o}=e,s=new Map;if(t){let l;Object.keys(t).forEach(h=>{var f;const u=t[h];if(u&&!u.newValue)(f=this.worker)==null||f.clearViewScenePath(h,!0),u.oldValue&&(l=u.oldValue);else if(u&&u.newValue){for(const p of Object.keys(u.newValue))this.worker.pullServiceData(h,p,{isAsync:!1,useAnimation:!0});l=u.newValue}if(l)for(const p of Object.values(l)){const g=new Set;for(const m of Object.keys(p))m&&g.add(m);s.set(h,g)}})}if(i){let l;Object.keys(i).forEach(h=>{var f;const u=i[h];if(u&&u.viewId&&!u.newValue?((f=this.worker)==null||f.clearViewScenePath(u.viewId,!0),u.oldValue&&(l=u.oldValue)):u&&u.viewId&&u.newValue&&(this.worker.pullServiceData(u.viewId,h,{isAsync:!1,useAnimation:!0}),l=u.newValue),u!=null&&u.viewId&&l){const p=new Set;for(const g of Object.keys(l))g&&p.add(g),s.set(u.viewId,p)}})}o&&Object.keys(o).forEach(l=>{var u,f;const h=o[l];if(h){const{viewId:p}=h,g=s.get(p)||new Set;g.add(l),s.set(p,g),(u=this.worker)==null||u.onServiceDerive(l,h),(f=this.miniMapManager)==null||f.updateMiniMapCamera(p)}});for(const[l,h]of s.entries())we.InternalMsgEmitter.emit("excludeIds",[...h],l)}),this.room&&(this.roomMember.onUidChangeHook(e=>{var t;(t=this.collector)!=null&&t.serviceStorage&&this.viewContainerManager.getAllViews().forEach(i=>{var o,s,a,c,l,h;if(i&&i.focusScenePath&&((o=this.collector)!=null&&o.serviceStorage[i.id])&&((s=this.collector)!=null&&s.serviceStorage[i.id][i.focusScenePath])){const u=Object.keys((a=this.collector)==null?void 0:a.serviceStorage[i.id][i.focusScenePath]);for(const f of u){const p=(c=this.collector)==null?void 0:c.getUidFromKey(f);if(p&&!e.online.includes(p))if((l=this.collector)!=null&&l.isSelector(f))this.renderControl.isWritable&&((h=this.collector)==null||h.updateValue(f,void 0,{viewId:i.id,scenePath:i.focusScenePath,isSync:!0})),this.worker.blurSelector(i.id,i.focusScenePath,f);else{const g=this.textEditorManager.editors.get(f);g&&g.opt&&(g.opt.workState===j.Doing||g.opt.workState===j.Start)&&(g.opt.text&&g.opt.text.replace(/\s*,/g,"")?this.textEditorManager.unActive(f):this.textEditorManager.delete(f))}}}})}),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 A=class A extends F.InvisiblePlugin{constructor(){super(...arguments);I(this,"onPhaseChanged",e=>{var t;e===F.RoomPhase.Reconnecting&&((t=A.currentManager)==null||t.setSnapshootData())});I(this,"updateRoomWritable",()=>{var e;(e=A.currentManager)==null||e.onWritableChange(this.displayer.isWritable)});I(this,"roomStateChangeListener",async e=>{var t,i;A.currentManager instanceof Be&&(e.cameraState&&A.currentManager.onCameraChange(e.cameraState),e.sceneState&&A.currentManager.onSceneChange(e.sceneState.scenePath,ge)),e!=null&&e.roomMembers&&((t=A.currentManager)==null||t.onRoomMembersChange(e.roomMembers)),!(F.isRoom(this.displayer)&&!this.displayer.isWritable)&&e.memberState&&((i=A.currentManager)==null||i.onMemberChange(e.memberState))})}static async getInstance(e,t){var p;t.options&&(((p=t.options.extras)==null?void 0:p.useWorker)==="mainThread"&&(t.options.cdn.fullWorkerUrl="",t.options.cdn.subWorkerUrl=""),(t.options.extras&&t.options.extras.useWorker!=="mainThread"||!t.options.extras)&&!t.options.cdn.fullWorkerUrl&&!t.options.cdn.subWorkerUrl&&A.logger.error("[ApplianceSinglePlugin] you must adaptor options cdn fullWorkerUrl and subWorkerUrl"));const i=e.callbacks.on,o=e.callbacks.off,s=e.callbacks.once,a=e.cleanCurrentScene.bind(e),c=e.setMemberState.bind(e);let l;F.isRoom(e)&&(l=e.setWritable),t!=null&&t.logger&&(A.logger=t.logger);let h=e.getInvisiblePlugin(A.kind);h||(h=await A.createAppliancePlugin(e,A.kind)),e&&h&&A.createCurrentManager(e,{cdn:t.options.cdn,extras:{...me,...t.options.extras}},h),h&&A.currentManager&&(A.currentManager.bindPlugin(h),h.init(e)),t!=null&&t.cursorAdapter&&(A.cursorAdapter=t.cursorAdapter),A.effectInstance();const u={displayer:e,currentManager:A.currentManager,maxScreenshotWidth:10*1024,maxScreenshotHeight:10*1024,_injectTargetObject:void 0,getBoundingRectAsync:async function(g){var y;A.logger.info("[ApplianceSinglePlugin] getBoundingRectAsync");const m=e.getBoundingRect(g),w=await((y=A.currentManager)==null?void 0:y.getBoundingRect(g));return!m.width||!m.height?w:oi(m,w)},screenshotToCanvasAsync:async function(g,m,w,y,M,v){var P;A.logger.info("[ApplianceSinglePlugin] screenshotToCanvasAsync");let S=w,C=y,k=M.scale;S>this.maxScreenshotWidth&&(k=this.maxScreenshotWidth/S*k,S=this.maxScreenshotWidth),C>this.maxScreenshotHeight&&(k=Math.min(this.maxScreenshotHeight/C*k,k),C=this.maxScreenshotHeight),M.scale=k;const N=document.createElement("canvas"),z=N.getContext("2d");N.width=S*(v||1),N.height=C*(v||1),z&&(e.screenshotToCanvas(z,m,S,C,M,v),g.drawImage(N,Math.floor((w-S)/2),Math.floor((y-C)/2),S*(v||1),C*(v||1),0,0,S,C),N.remove()),A.currentManager&&await((P=A.currentManager)==null?void 0:P.screenshotToCanvas(g,m,S,C,M,Math.floor((w-S)/2),Math.floor((y-C)/2)))},scenePreviewAsync:async function(g,m,w,y,M){A.logger.info("[ApplianceSinglePlugin] scenePreviewAsync"),e.scenePreview(g,m,w,y,M);const v=document.createElement("img");v.className="appliance-plugin-fill-scene-snapshot-img",m.append(v),getComputedStyle(m).position||(m.style.position="relative"),A.currentManager&&await A.currentManager.scenePreview(g,v)},fillSceneSnapshotAsync:async function(g,m,w,y,M){var V,J;A.logger.info("[ApplianceSinglePlugin] fillSceneSnapshotAsync"),m.innerHTML="",e.fillSceneSnapshot(g,m,w,y,M);const v=w||((V=e.state.cameraState)==null?void 0:V.width)||0,S=y||((J=e.state.cameraState)==null?void 0:J.height)||0;let C=await this.getBoundingRectAsync(g);C||(C={originX:0,originY:0,width:v,height:S});let k=Math.max(C==null?void 0:C.width,v),N=Math.max(C==null?void 0:C.height,S),z=1;const P=k>v&&Math.min(v/k,z)||z,L=N>S&&Math.min(S/N,z)||z;P<=L?(k=P<1&&v||k,N=Math.floor(N*P)+1,z=P):P>L&&(N=L<1&&S||N,k=Math.floor(k*L)+1,z=L);const R={scale:z,centerX:C.originX+C.width/2,centerY:C.originY+C.height/2},E=document.createElement("canvas"),O=E.getContext("2d");E.width=k,E.height=N,O&&await this.screenshotToCanvasAsync(O,g,k,N,R,devicePixelRatio);const D=document.createElement("img");D.className="appliance-plugin-fill-scene-snapshot-img",D.src=E.toDataURL(),D.onload=()=>{E.remove()},D.onerror=()=>{E.remove(),D.remove()},m.append(D),getComputedStyle(m).position||(m.style.position="relative")},_callbacksOn:function(g,m){A.logger.info(`[ApplianceSinglePlugin] callbacks ${g}`),(g==="onCanUndoStepsUpdate"||g==="onCanRedoStepsUpdate")&&F.isRoom(e)&&e.isWritable?Be.InternalMsgEmitter.on(g,m):i.call(e.callbacks,g,m)},_callbacksOnce:function(g,m){A.logger.info(`[ApplianceSinglePlugin] callbacks ${g}`),(g==="onCanUndoStepsUpdate"||g==="onCanRedoStepsUpdate")&&F.isRoom(e)&&e.isWritable?Be.InternalMsgEmitter.on(g,m):s.call(e.callbacks,g,m)},_callbacksOff:function(g,m){A.logger.info(`[ApplianceSinglePlugin] callbacks ${g}`),(g==="onCanUndoStepsUpdate"||g==="onCanRedoStepsUpdate")&&F.isRoom(e)&&e.isWritable?Be.InternalMsgEmitter.off(g,m):o.call(e.callbacks,g,m)},canRedoSteps(){if(A.logger.info("[ApplianceSinglePlugin] canRedoSteps"),A.currentManager&&F.isRoom(e)&&!e.disableSerialization){const g=A.currentManager.viewContainerManager.focuedView,m=g==null?void 0:g.focusScenePath;if(g&&m)return g.displayer.commiter.redoStack.filter(w=>w.scenePath===m).length}return 0},canUndoSteps(){if(A.logger.info("[ApplianceSinglePlugin] canUndoSteps"),A.currentManager&&F.isRoom(e)&&!e.disableSerialization){const g=A.currentManager.viewContainerManager.focuedView,m=g==null?void 0:g.focusScenePath;if(g&&m)return g.displayer.commiter.undoStack.filter(w=>w.scenePath===m).length}return 0},undo:function(){return A.logger.info("[ApplianceSinglePlugin] undo"),A.currentManager&&F.isRoom(e)&&!e.disableSerialization?A.currentManager.viewContainerManager.undo():0},redo:function(){return A.logger.info("[ApplianceSinglePlugin] redo"),A.currentManager&&F.isRoom(e)&&!e.disableSerialization?A.currentManager.viewContainerManager.redo():0},cleanCurrentScene:function(g){A.logger.info("[ApplianceSinglePlugin] cleanCurrentScene"),A.currentManager&&F.isRoom(e)&&e.isWritable&&(A.currentManager.cleanCurrentScene(),a.call(e,g))},insertImage:function(g){A.logger.info("[ApplianceSinglePlugin] insertImage"),A.currentManager&&F.isRoom(e)&&e.isWritable&&A.currentManager.worker.insertImage(ge,g)},lockImage:function(g,m){A.logger.info("[ApplianceSinglePlugin] lockImage"),A.currentManager&&F.isRoom(e)&&e.isWritable&&A.currentManager.worker.lockImage(ge,g,m)},completeImageUpload:function(g,m){A.logger.info("[ApplianceSinglePlugin] completeImageUpload"),A.currentManager&&F.isRoom(e)&&e.isWritable&&A.currentManager.worker.completeImageUpload(ge,g,m)},getImagesInformation:function(g){return A.logger.info("[ApplianceSinglePlugin] completeImageUpload"),A.currentManager&&F.isRoom(e)&&e.isWritable?A.currentManager.worker.getImagesInformation(g):[]},insertText:function(g,m,w){if(A.logger.info("[ApplianceSinglePlugin] insertText"),A.currentManager&&F.isRoom(e)&&e.isWritable)return A.currentManager.textEditorManager.insertText(ge,g,m,w)},updateText:function(g,m){A.logger.info("[ApplianceMultiPlugin] updateText"),A.currentManager&&F.isRoom(e)&&e.isWritable&&A.currentManager.textEditorManager.updateText(g,m)},callbacks:()=>({...e.callbacks,on:u._callbacksOn.bind(u),once:u._callbacksOnce.bind(u),off:u._callbacksOff.bind(u)}),destroy(){A.currentManager&&(A.logger.info("[ApplianceSinglePlugin] destroy"),A.currentManager.destroy(),A.currentManager=void 0,A.cursorAdapter=void 0)},setMemberState(g){var w;A.logger.info(`[ApplianceSinglePlugin] setMemberState ${JSON.stringify(g)}`);const m=Object.keys(g);if(F.isRoom(e)&&e.isWritable){if(m.includes("currentApplianceName"))if(g.currentApplianceName&&g.currentApplianceName===te.laserPen){if((w=A.currentManager)!=null&&w.isUseSimple)throw new Error("[ApplianceMultiPlugin] laserPen must be not support in simple mode");g.currentApplianceName=te.pencil,g.useLaserPen=!0}else g.currentApplianceName&&g.currentApplianceName===te.pencil&&(g.useLaserPen=!1);c(g);return}throw new Error("setMemberState must be called in writable room")},createMiniMap:async function(g,m){if(A.logger.info("[ApplianceSinglePlugin] createMiniMap"),A.currentManager&&F.isRoom(e)&&e.isWritable)return A.currentManager.createMiniMap(g,m)},destroyMiniMap:async function(g){if(A.logger.info("[ApplianceMultiPlugin] destroyeMiniMap"),A.currentManager&&F.isRoom(e)&&e.isWritable)return A.currentManager.destroyMiniMap(g)},filterRenderByUid(g,m,w){if(A.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),A.currentManager&&F.isRoom(e)&&e.isWritable)return A.currentManager.filterRenderByUid(g,m,w)},cancelFilterRender(g,m){if(A.logger.info("[ApplianceSinglePlugin] filterRenderByUid"),A.currentManager&&F.isRoom(e)&&e.isWritable)return A.currentManager.cancelFilterRender(g,m)},addListener:(g,m)=>{A.logger.info(`[ApplianceSinglePlugin] addListener ${g}`),Be.PublicMsgEmitter.on(g,m)},removeListener:(g,m)=>{A.logger.info(`[ApplianceSinglePlugin] removeListener ${g}`),Be.PublicMsgEmitter.off(g,m)},usePlugin:g=>{var m;A.logger.info("[ApplianceSinglePlugin] usePlugin",g.kind),(m=A.currentManager)==null||m.usePlugin(g)},getDisableDeviceInputs(){if(A.currentManager&&F.isRoom(e))return A.currentManager.disableDeviceInputs},setDisableDeviceInputs(g){A.logger.info(`[ApplianceSinglePlugin] setDisableDeviceInputs ${g}`),A.currentManager&&F.isRoom(e)&&(A.currentManager.disableDeviceInputs=g)},getDisableCameraTransform(){if(A.currentManager&&F.isRoom(e))return A.currentManager.disableCameraTransform},setDisableCameraTransform(g){A.logger.info(`[ApplianceSinglePlugin] setDisableCameraTransform ${g}`),A.currentManager&&F.isRoom(e)&&(A.currentManager.disableCameraTransform=g)},getDisableEraseImage(){if(A.currentManager&&F.isRoom(e))return A.currentManager.disableEraseImage},setDisableEraseImage(g){A.logger.info(`[ApplianceSinglePlugin] setDisableEraseImage ${g}`),A.currentManager&&F.isRoom(e)&&(A.currentManager.disableEraseImage=g)},setWritable:async function(g){var m;A.logger.info(`[ApplianceSinglePlugin] setWritable ${g}`),F.isRoom(e)&&l&&(await((m=A.currentManager)==null?void 0:m.setWritable(g)),await l.call(e,g))},requestIdleCallback:(g,m)=>{const w=(m==null?void 0:m.timeout)||0,y=performance.now();let M;const v=new MessageChannel;let S;const C=k=>{try{g({didTimeout:k,timeRemaining:()=>{const z=performance.now()-y;return Math.max(0,w-z)}})}catch(N){A.logger.error("[ApplianceSinglePlugin] requestIdleCallback error:",N)}finally{v.port1.close(),v.port2.close(),M!==void 0&&cancelAnimationFrame(M),S!==void 0&&clearTimeout(S)}};return v.port1.onmessage=()=>{M=requestAnimationFrame(()=>{w>0&&performance.now()-y>=w?C(!0):C(!1)})},v.port2.postMessage(null),w>0&&(S=setTimeout(()=>{C(!0)},w)),S||M||0},cancelIdleCallback:g=>{try{clearTimeout(g),cancelAnimationFrame(g)}catch(m){A.logger.error("[ApplianceSinglePlugin] cancelIdleCallback error:",m)}},injectMethodToObject:(g,m)=>{if(A.logger.info(`[ApplianceSinglePlugin] injectMethodToObject ${m}`),typeof g[m]=="function"||typeof g[m]>"u"){g[m]=u[m];return}m==="callbacks"&&(g.callbacks.on=u._callbacksOn.bind(u),g.callbacks.off=u._callbacksOff.bind(u),g.callbacks.once=u._callbacksOnce.bind(u))},blurText:()=>{A.logger.info("[ApplianceSinglePlugin] blurText"),A.currentManager&&F.isRoom(e)&&e.isWritable&&A.currentManager.textEditorManager.checkEmptyTextBlur()},hasElements:(g,m)=>{var w;if(A.logger.info(`[ApplianceSinglePlugin] hasElements ${g}`),A.currentManager&&F.isRoom(e)&&e.isWritable){let y=g;if(!y){const M=A.currentManager.viewContainerManager.focuedView;y=M==null?void 0:M.focusScenePath}if(y){const M=(w=A.currentManager.collector)==null?void 0:w.getScenePathData(y);if(M){const v=Object.values(M);return v.length>0?m?v.some(S=>m(S.toolsType)):!0:!1}return!1}return!1}},getElements:(g,m)=>{var w;if(A.logger.info(`[ApplianceSinglePlugin] getElements ${g}`),A.currentManager&&F.isRoom(e)&&e.isWritable){let y=g;if(!y){const M=A.currentManager.viewContainerManager.focuedView;y=M==null?void 0:M.focusScenePath}if(y){const M=(w=A.currentManager.collector)==null?void 0:w.getScenePathData(y),v=M&&Object.values(M)||[];return M&&v.length>0&&m?v.filter(S=>m(S.toolsType)):v}return[]}},stopDraw:g=>{if(A.logger.info(`[ApplianceSinglePlugin] stopDraw ${g}`),A.currentManager&&F.isRoom(e))return A.currentManager.stopDraw(g)},setViewLocalScenePathChange:async(g,m)=>{A.logger.info(`[ApplianceSinglePlugin] setViewLocalScenePathChange ${g} ${m}`),A.currentManager&&await A.currentManager.setViewLocalScenePathChange(g,m)},insertMarkmap:async(g,m)=>{if(A.logger.info(`[ApplianceSinglePlugin] insertMarkmap: ${g}, info: ${JSON.stringify(m)}`),A.currentManager&&A.currentManager.isUseBackgroundThread)return A.currentManager.worker.insertBackgroundMarkMap(g,m)},updateMarkmap:async(g,m,w)=>{if(A.logger.info(`[ApplianceSinglePlugin] updateMarkmap: ${g}, markmapId: ${m}, info: ${JSON.stringify(w)}`),A.currentManager&&A.currentManager.isUseBackgroundThread)return A.currentManager.worker.updateBackgroundMarkMap(g,m,w)},insertBackgroundImage:async(g,m)=>{if(A.logger.info(`[ApplianceSinglePlugin] insertBackgroundImage: ${g}, info: ${JSON.stringify(m)}`),A.currentManager&&A.currentManager.isUseBackgroundThread)return A.currentManager.worker.insertBackgroundSVG(g,m)}};u.injectMethodToObject(e,"undo"),u.injectMethodToObject(e,"redo"),u.injectMethodToObject(e,"cleanCurrentScene"),u.injectMethodToObject(e,"insertImage"),u.injectMethodToObject(e,"completeImageUpload"),u.injectMethodToObject(e,"lockImage"),u.injectMethodToObject(e,"getImagesInformation"),u.injectMethodToObject(e,"insertText"),u.injectMethodToObject(e,"updateText"),u.injectMethodToObject(e,"callbacks"),u.injectMethodToObject(e,"screenshotToCanvasAsync"),u.injectMethodToObject(e,"getBoundingRectAsync"),u.injectMethodToObject(e,"scenePreviewAsync"),u.injectMethodToObject(e,"fillSceneSnapshotAsync"),u.injectMethodToObject(e,"setMemberState"),F.isRoom(e)&&u.injectMethodToObject(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()}}),Object.defineProperty(f,"disableCameraTransform",{set(g){u.setDisableCameraTransform(g)},get(){return u.getDisableCameraTransform()}}),e._appliancePlugin=f,e._appliancePlugin}static onCreate(e){e&&A.currentManager&&(A.currentManager.bindPlugin(e),e.init(e.displayer))}static async createAppliancePlugin(e,t){try{await e.createInvisiblePlugin(A,{})}catch(o){if(!e.isWritable){await e.setWritable(!0);const s=await this.createAppliancePlugin(e,t);return await e.setWritable(!1),s}throw o}let i=e.getInvisiblePlugin(t);return i||(i=await A.createAppliancePlugin(e,t)),i}static effectInstance(){if(A.cursorAdapter){const e=A.cursorAdapter.onAddedCursor;A.cursorAdapter.onAddedCursor=function(t){t.onCursorMemberChanged=i=>{try{i.appliance===te.pencil||i.appliance===te.shape||i.appliance===te.text||i.appliance===te.arrow||i.appliance===te.straight||i.appliance===te.rectangle||i.appliance===te.ellipse||i.appliance===te.eraser||i.appliance===te.selector?t!=null&&t.divElement&&(t.divElement.style.display="none"):t!=null&&t.divElement&&(t.divElement.style.display="block")}catch(o){throw o}},e.call(A.cursorAdapter,t)}}}get isReplay(){return F.isPlayer(this.displayer)}get callbackName(){return this.isReplay?"onPlayerStateChanged":"onRoomStateChanged"}init(e){var i,o;const t=e.state;(i=A.currentManager)==null||i.onRoomMembersChange(t.roomMembers),F.isRoom(e)&&t!=null&&t.memberState&&((o=A.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;A.logger.info("[ApplianceSinglePlugin] passive destroy"),(e=A.currentManager)==null||e.destroy(),A.currentManager=void 0,A.cursorAdapter=void 0}};I(A,"kind","appliance-single-plugin"),I(A,"cursorAdapter"),I(A,"currentManager"),I(A,"logger",{info:console.log,warn:console.warn,error:console.error}),I(A,"createCurrentManager",(e,t,i)=>{A.currentManager&&A.currentManager.destroy();const o={plugin:i,displayer:e,options:t},s=new Be(o);if(s.init(),A.logger.info("[ApplianceSinglePlugin] refresh ApplianceSingleManager object"),A.currentManager=s,F.isRoom(e)){const a=s.hasOffscreenCanvas,c=s.isUseOffscreenTransfer,l=s.pluginOptions,h=s.isUseSimple;e.logger.info(`[Appliance]: [ApplianceSinglePlugin] use ${a?"worker":"mainThread"}, isUseSimple: ${h} ${c?"offscreenTransfer":""}, options: ${JSON.stringify(l)}`)}});let Wn=A;const Nt=class Nt extends d.Component{constructor(){super(...arguments);I(this,"mainViewRef",null)}componentDidMount(){Nt.emiter||(Nt.emiter=Be.InternalMsgEmitter),Nt.emiter.emit(_.BindMainView,this.mainViewRef)}render(){return d.createElement(d.Fragment,null,this.props.children,d.createElement("div",{className:"appliance-plugin-main-view-displayer",ref:e=>this.mainViewRef=e}))}};I(Nt,"emiter");let Vn=Nt;exports.ActiveContainerType=er;exports.ApplianceMultiPlugin=Bn;exports.ApplianceNames=te;exports.ApplianceSigleWrapper=Vn;exports.ApplianceSinglePlugin=Wn;exports.Cursor_Hover_Id=qr;exports.DefaultAppliancePluginExtrasOptions=me;exports.ECanvasShowType=$e;exports.EDataType=X;exports.EForceStopReason=Fn;exports.EImageType=Wt;exports.EMatrixrRelationType=Bt;exports.EOperationType=Ce;exports.EPostMessageType=Y;exports.ERenderFilterType=Ve;exports.ESVGType=Vt;exports.EScaleType=Oe;exports.EStrokeType=de;exports.EToolsKey=T;exports.ElayerType=Ct;exports.EmitEventType=W;exports.EventMessageType=Ut;exports.EventWorkState=j;exports.InternalMsgEmitterType=_;exports.Main_View_Id=ge;exports.Plugin=my;exports.Point2d=pe;exports.ShapeType=Ye;exports.Storage_Selector_key=Z;exports.Storage_Splitter=Je;exports.Storage_ViewId_ALL=br;exports.Task_Time_Interval=Qn;exports.TextBoxPadding=An;exports.Vec2d=B;exports.ViewContainerManager=vt;exports._Stack=sr;exports._baseGetTag=jt;exports._equalArrays=Ar;exports._equalByTag=cf;exports._getAllKeys=Tr;exports._getTag=dn;exports.average=op;exports.checkOp=ep;exports.cloneDeep=Gt;exports.colorRGBA2Array=Yt;exports.computRect=VM;exports.decimalPlaces=np;exports.fullWorker=Jr;exports.gcd=ip;exports.getDefaultExportFromCjs=on;exports.getRectFromPoints=si;exports.getRectMatrixrRelation=sp;exports.getRectRotated=$M;exports.getRectScaleWPoint=HM;exports.getRectTranslated=GM;exports.getSafetyRect=QM;exports.getWHRatio=_M;exports.isArray_1=Qt;exports.isBufferExports=$n;exports.isDecimal=tp;exports.isIntersect=FM;exports.isIntersectForPoint=Or;exports.isObjectLike_1=at;exports.isSet=Td;exports.isTypedArray_1=gr;exports.precise=rp;exports.requestAsyncCallBack=He;exports.rgbToRgba=Tt;exports.rotateLitePoints=XM;exports.rotatePoints=JM;exports.scaleLitePoints=KM;exports.scalePoints=qM;exports.strlen=ap;exports.subWorker=Xr;exports.transformToNormalData=gn;exports.transformToSerializableData=St;
|